@idraw/core 0.4.2 → 1.0.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/board/index.d.ts +2 -2
- package/dist/esm/board/index.js +23 -12
- package/dist/esm/board/sharer.d.ts +3 -3
- package/dist/esm/board/sharer.js +10 -10
- package/dist/esm/board/viewer.d.ts +3 -3
- package/dist/esm/board/viewer.js +14 -14
- package/dist/esm/board/watcher.d.ts +3 -3
- package/dist/esm/board/watcher.js +68 -43
- package/dist/esm/core.d.ts +52 -0
- package/dist/esm/core.js +393 -0
- package/dist/esm/cursor/cursor-image.d.ts +2 -0
- package/dist/esm/cursor/cursor-image.js +2 -0
- package/dist/esm/cursor/cursor.js +60 -24
- package/dist/esm/index.d.ts +12 -61
- package/dist/esm/index.js +11 -389
- package/dist/esm/middlewares/common.d.ts +4 -0
- package/dist/esm/middlewares/common.js +13 -0
- package/dist/esm/middlewares/creator/dom.d.ts +11 -0
- package/dist/esm/middlewares/creator/dom.js +52 -0
- package/dist/esm/middlewares/creator/index.d.ts +5 -0
- package/dist/esm/middlewares/creator/index.js +136 -0
- package/dist/esm/middlewares/creator/static.d.ts +14 -0
- package/dist/esm/middlewares/creator/static.js +19 -0
- package/dist/esm/middlewares/creator/styles.d.ts +4 -0
- package/dist/esm/middlewares/creator/styles.js +32 -0
- package/dist/esm/middlewares/creator/types.d.ts +7 -0
- package/dist/esm/middlewares/creator/types.js +1 -0
- package/dist/esm/middlewares/creator/util.d.ts +10 -0
- package/dist/esm/middlewares/creator/util.js +52 -0
- package/dist/esm/middlewares/dragger/index.js +5 -5
- package/dist/esm/middlewares/info/draw-info.d.ts +11 -11
- package/dist/esm/middlewares/info/draw-info.js +18 -18
- package/dist/esm/middlewares/info/index.d.ts +2 -1
- package/dist/esm/middlewares/info/index.js +48 -51
- package/dist/esm/middlewares/info/static.d.ts +6 -0
- package/dist/esm/middlewares/info/{config.js → static.js} +6 -1
- package/dist/esm/middlewares/info/types.d.ts +2 -2
- package/dist/esm/middlewares/layout-selector/dom.d.ts +10 -0
- package/dist/esm/middlewares/layout-selector/dom.js +108 -0
- package/dist/esm/middlewares/layout-selector/index.d.ts +1 -1
- package/dist/esm/middlewares/layout-selector/index.js +89 -141
- package/dist/esm/middlewares/layout-selector/static.d.ts +32 -0
- package/dist/esm/middlewares/layout-selector/static.js +39 -0
- package/dist/esm/middlewares/layout-selector/styles.d.ts +4 -0
- package/dist/esm/middlewares/layout-selector/styles.js +127 -0
- package/dist/esm/middlewares/layout-selector/types.d.ts +6 -6
- package/dist/esm/middlewares/layout-selector/types.js +2 -2
- package/dist/esm/middlewares/layout-selector/util.d.ts +4 -4
- package/dist/esm/middlewares/layout-selector/util.js +19 -19
- package/dist/esm/middlewares/path-creator/dom.d.ts +29 -0
- package/dist/esm/middlewares/path-creator/dom.js +145 -0
- package/dist/esm/middlewares/path-creator/index.d.ts +5 -0
- package/dist/esm/middlewares/path-creator/index.js +203 -0
- package/dist/esm/middlewares/path-creator/static.d.ts +23 -0
- package/dist/esm/middlewares/path-creator/static.js +49 -0
- package/dist/esm/middlewares/path-creator/types.d.ts +1 -0
- package/dist/esm/middlewares/path-editor/calc.d.ts +6 -0
- package/dist/esm/middlewares/path-editor/calc.js +51 -0
- package/dist/esm/middlewares/path-editor/dom.d.ts +32 -0
- package/dist/esm/middlewares/path-editor/dom.js +575 -0
- package/dist/esm/middlewares/path-editor/draw.d.ts +7 -0
- package/dist/esm/middlewares/path-editor/draw.js +113 -0
- package/dist/esm/middlewares/path-editor/index.d.ts +5 -0
- package/dist/esm/middlewares/path-editor/index.js +312 -0
- package/dist/esm/middlewares/path-editor/parse.d.ts +5 -0
- package/dist/esm/middlewares/path-editor/parse.js +37 -0
- package/dist/esm/middlewares/path-editor/static.d.ts +34 -0
- package/dist/esm/middlewares/path-editor/static.js +82 -0
- package/dist/esm/middlewares/path-editor/types.d.ts +26 -0
- package/dist/esm/middlewares/path-editor/types.js +1 -0
- package/dist/esm/middlewares/path-editor/util.d.ts +5 -0
- package/dist/esm/middlewares/path-editor/util.js +21 -0
- package/dist/esm/middlewares/pointer/index.js +5 -5
- package/dist/esm/middlewares/pointer/types.d.ts +2 -2
- package/dist/esm/middlewares/ruler/index.d.ts +2 -0
- package/dist/esm/middlewares/ruler/index.js +12 -19
- package/dist/esm/middlewares/ruler/static.d.ts +8 -0
- package/dist/esm/middlewares/ruler/{config.js → static.js} +16 -3
- package/dist/esm/middlewares/ruler/types.d.ts +2 -2
- package/dist/esm/middlewares/ruler/util.d.ts +6 -6
- package/dist/esm/middlewares/ruler/util.js +31 -31
- package/dist/esm/middlewares/scaler/index.js +2 -2
- package/dist/esm/middlewares/scroller/dom.d.ts +14 -0
- package/dist/esm/middlewares/scroller/dom.js +53 -0
- package/dist/esm/middlewares/scroller/index.d.ts +2 -0
- package/dist/esm/middlewares/scroller/index.js +111 -46
- package/dist/esm/middlewares/scroller/static.d.ts +21 -0
- package/dist/esm/middlewares/scroller/static.js +29 -0
- package/dist/esm/middlewares/scroller/styles.d.ts +4 -0
- package/dist/esm/middlewares/scroller/styles.js +73 -0
- package/dist/esm/middlewares/scroller/types.d.ts +8 -6
- package/dist/esm/middlewares/scroller/types.js +1 -1
- package/dist/esm/middlewares/scroller/util.d.ts +6 -13
- package/dist/esm/middlewares/scroller/util.js +15 -144
- package/dist/esm/middlewares/selector/dom.d.ts +21 -0
- package/dist/esm/middlewares/selector/dom.js +395 -0
- package/dist/esm/middlewares/selector/draw-base.d.ts +9 -21
- package/dist/esm/middlewares/selector/draw-base.js +19 -43
- package/dist/esm/middlewares/selector/draw-reference.d.ts +4 -5
- package/dist/esm/middlewares/selector/draw-reference.js +5 -5
- package/dist/esm/middlewares/selector/index.d.ts +4 -2
- package/dist/esm/middlewares/selector/index.js +315 -439
- package/dist/esm/middlewares/selector/reference.d.ts +5 -5
- package/dist/esm/middlewares/selector/reference.js +36 -30
- package/dist/esm/middlewares/selector/render-frame.d.ts +11 -0
- package/dist/esm/middlewares/selector/render-frame.js +107 -0
- package/dist/esm/middlewares/selector/resize.d.ts +7 -0
- package/dist/esm/middlewares/selector/resize.js +27 -0
- package/dist/esm/middlewares/selector/static.d.ts +67 -0
- package/dist/esm/middlewares/selector/static.js +92 -0
- package/dist/esm/middlewares/selector/styles.d.ts +4 -0
- package/dist/esm/middlewares/selector/styles.js +153 -0
- package/dist/esm/middlewares/selector/types.d.ts +27 -27
- package/dist/esm/middlewares/selector/types.js +1 -1
- package/dist/esm/middlewares/selector/util.d.ts +22 -32
- package/dist/esm/middlewares/selector/util.js +226 -243
- package/dist/esm/middlewares/text-editor/dom.d.ts +5 -0
- package/dist/esm/middlewares/text-editor/dom.js +135 -0
- package/dist/esm/middlewares/text-editor/index.d.ts +5 -20
- package/dist/esm/middlewares/text-editor/index.js +201 -207
- package/dist/esm/middlewares/text-editor/static.d.ts +10 -0
- package/dist/esm/middlewares/text-editor/static.js +17 -0
- package/dist/esm/middlewares/text-editor/types.d.ts +21 -0
- package/dist/esm/middlewares/text-editor/types.js +1 -0
- package/dist/esm/record.d.ts +5 -5
- package/dist/esm/record.js +14 -14
- package/dist/esm/{config.d.ts → static.d.ts} +16 -0
- package/dist/esm/{config.js → static.js} +18 -2
- package/dist/index.global.js +8934 -5646
- package/dist/index.global.min.js +1 -1
- package/package.json +4 -4
- package/dist/esm/middlewares/info/config.d.ts +0 -5
- package/dist/esm/middlewares/layout-selector/config.d.ts +0 -11
- package/dist/esm/middlewares/layout-selector/config.js +0 -12
- package/dist/esm/middlewares/ruler/config.d.ts +0 -7
- package/dist/esm/middlewares/scroller/config.d.ts +0 -10
- package/dist/esm/middlewares/scroller/config.js +0 -16
- package/dist/esm/middlewares/selector/config.d.ts +0 -30
- package/dist/esm/middlewares/selector/config.js +0 -38
- package/dist/esm/middlewares/selector/draw-auxiliary.js +0 -12
- package/dist/esm/middlewares/selector/draw-debug.d.ts +0 -5
- package/dist/esm/middlewares/selector/draw-debug.js +0 -30
- package/dist/esm/middlewares/selector/draw-wrapper.d.ts +0 -37
- package/dist/esm/middlewares/selector/draw-wrapper.js +0 -139
- package/dist/esm/middlewares/selector/pattern/icon-rotate.d.ts +0 -4
- package/dist/esm/middlewares/selector/pattern/icon-rotate.js +0 -88
- package/dist/esm/middlewares/selector/pattern/index.d.ts +0 -8
- package/dist/esm/middlewares/selector/pattern/index.js +0 -38
- /package/dist/esm/middlewares/{selector/draw-auxiliary.d.ts → path-creator/types.js} +0 -0
package/dist/index.global.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var iDrawCore=function(e){"use strict";var t,i,o,n,r,l,a,s,h,c,d,u,f,g,v,m,y,p,w,x,S,b,A,I,M,z,R,C,E,T,P,L,O,k,W,D,j,Y,N,B,F,G,V,X,H,Z,Q,U,$,J,K,q,_,ee,te,ie,oe,ne,re,le,ae,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,t){let i=0;for(let t=0;t<e.length;t++)i+=e.charCodeAt(t);return(i+t).toString(16).substring(0,4)}function ze(e,t){const i=e.length,o=function(e){let t=0;for(let i=0;i<e.length;i++)t+=e.charCodeAt(i);return t}(t),n=Math.floor(i/2),r=e.substring(0,4).padStart(4,"0"),l=e.substring(0,4).padStart(4,"0");return`@assets/${Me(i.toString(16).padStart(4,r),o).padStart(4,"0")}${Me(e.substring(n-4,n).padStart(4,r),o).padStart(4,"0")}-${Me(e.substring(n-8,n-4).padStart(4,r),o).padStart(4,"0")}-${Me(e.substring(n-12,n-8).padStart(4,r),o).padStart(4,"0")}-${Me(e.substring(n-16,n-12).padStart(4,l),o).padStart(4,"0")}-${Me(e.substring(n,n+4).padStart(4,l),o).padStart(4,"0")}${Me(e.substring(n+4,n+8).padStart(4,l),o).padStart(4,"0")}${Me(l.padStart(4,r).padStart(4,l),o)}`}function Re(e){return/^@assets\/[0-9a-z-]{0,}$/.test(`${e}`)}function Ce(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 Ee(e){return(Object.prototype.toString.call(e)||"").replace(/(\[object|\])/gi,"").trim()}const Te={type(e,t){const i=Ee(e);return!0===t?i.toLocaleLowerCase():i},array:e=>"Array"===Ee(e),json:e=>"Object"===Ee(e),function:e=>"Function"===Ee(e),asyncFunction:e=>"AsyncFunction"===Ee(e),boolean:e=>"Boolean"===Ee(e),string:e=>"String"===Ee(e),number:e=>"Number"===Ee(e),undefined:e=>"Undefined"===Ee(e),null:e=>"Null"===Ee(e),promise:e=>"Promise"===Ee(e)};var Pe=function(e,t,i,o){return new(i||(i=Promise))((function(n,r){function l(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(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(l,a)}s((o=o.apply(e,t||[])).next())}))};const{Image:Le}=window;function Oe(e){return new Promise(((t,i)=>{const o=new Le;o.crossOrigin="anonymous",o.onload=function(){t(o)},o.onabort=i,o.onerror=i,o.src=e}))}function ke(e){return Pe(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 Oe(t)}))}function We(e,t){return Pe(this,void 0,void 0,(function*(){e=e.replace(/\&/gi,"&");const i=yield function(e,t){const{width:i,height:o}=t;return new Promise(((t,n)=>{const r=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"}),l=new FileReader;l.readAsDataURL(r),l.onload=function(e){var i;const o=null===(i=null==e?void 0:e.target)||void 0===i?void 0:i.result;t(o)},l.onerror=function(e){n(e)}}))}(e,t);return yield Oe(i)}))}function De(e){return"number"==typeof e&&e>=0}function je(e){return"number"==typeof e&&(e>0||e<=0)}function Ye(e){return je(e)}function Ne(e){return je(e)}function Be(e){return De(e)}function Fe(e){return De(e)}function Ge(e){return"string"==typeof e&&/^(http:\/\/|https:\/\/|\.\/|\/)/.test(`${e}`)}function Ve(e){return"string"==typeof e&&/^(data:image\/)/.test(`${e}`)}function Xe(e){return["rect","circle","text","image","svg","html","group"].includes(e)}const He={positiveNum:De,data:function(e){return!!(Array(null==e?void 0:e.elements)&&(null==e?void 0:e.elements.length)>=0)},element:function(e){return!!e&&(Xe(null==e?void 0:e.type)&&Ye(null==e?void 0:e.x)&&Ne(null==e?void 0:e.y)&&Be(null==e?void 0:e.w)&&Fe(null==e?void 0:e.h))},layout:function(e){return!!e&&(Ye(null==e?void 0:e.x)&&Ne(null==e?void 0:e.y)&&Be(null==e?void 0:e.w)&&Fe(null==e?void 0:e.h))},type:Xe,x:Ye,y:Ne,w:Be,h:Fe,angle:function(e){return"number"==typeof e&&e>=-360&&e<=360},number:je,numberStr:function(e){return/^(-?\d+(?:\.\d+)?)$/.test(`${e}`)},borderWidth:function(e){return De(e)||Array.isArray(e)&&De(e[0])&&De(e[1])&&De(e[2])&&De(e[3])},borderRadius:function(e){return De(e)||Array.isArray(e)&&De(e[0])&&De(e[1])&&De(e[2])&&De(e[3])},color:function(e){return be(e)},imageSrc:function(e){return Ve(e)||Ge(e)},imageURL:Ge,imageBase64:Ve,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 je(e)&&e>0},lineHeight:function(e){return je(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 je(e)&&e>0}};var Ze,Qe,Ue=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},$e=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 Je{constructor(e,t){Ze.set(this,void 0),Qe.set(this,void 0),Ue(this,Ze,e,"f"),Ue(this,Qe,Object.assign({devicePixelRatio:1,offscreenCanvas:null},t),"f"),this.$resetFont()}$undoPixelRatio(e){return e/$e(this,Qe,"f").devicePixelRatio}$doPixelRatio(e){return $e(this,Qe,"f").devicePixelRatio*e}$getContext(){return $e(this,Ze,"f")}$setContext(e){Ue(this,Ze,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"}`),$e(this,Ze,"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 $e(this,Qe,"f").offscreenCanvas}$resize(e){const{width:t,height:i,devicePixelRatio:o,resetStyle:n}=e,{canvas:r}=$e(this,Ze,"f");r.width=t*o,r.height=i*o,Ue(this,Qe,Object.assign(Object.assign({},$e(this,Qe,"f")),{devicePixelRatio:o}),"f"),!0===n&&(r.style.width=`${t}px`,r.style.height=`${i}px`)}$getSize(){const{devicePixelRatio:e}=$e(this,Qe,"f"),{width:t,height:i}=$e(this,Ze,"f").canvas;return{width:t/e,height:i/e,devicePixelRatio:e}}get canvas(){return $e(this,Ze,"f").canvas}get fillStyle(){return $e(this,Ze,"f").fillStyle}set fillStyle(e){$e(this,Ze,"f").fillStyle=e}get strokeStyle(){return $e(this,Ze,"f").strokeStyle}set strokeStyle(e){$e(this,Ze,"f").strokeStyle=e}get lineWidth(){return this.$undoPixelRatio($e(this,Ze,"f").lineWidth)}set lineWidth(e){$e(this,Ze,"f").lineWidth=this.$doPixelRatio(e)}get textAlign(){return $e(this,Ze,"f").textAlign}set textAlign(e){$e(this,Ze,"f").textAlign=e}get textBaseline(){return $e(this,Ze,"f").textBaseline}set textBaseline(e){$e(this,Ze,"f").textBaseline=e}get globalAlpha(){return $e(this,Ze,"f").globalAlpha}set globalAlpha(e){$e(this,Ze,"f").globalAlpha=e}get shadowColor(){return $e(this,Ze,"f").shadowColor}set shadowColor(e){$e(this,Ze,"f").shadowColor=e}get shadowOffsetX(){return this.$undoPixelRatio($e(this,Ze,"f").shadowOffsetX)}set shadowOffsetX(e){$e(this,Ze,"f").shadowOffsetX=this.$doPixelRatio(e)}get shadowOffsetY(){return this.$undoPixelRatio($e(this,Ze,"f").shadowOffsetY)}set shadowOffsetY(e){$e(this,Ze,"f").shadowOffsetY=this.$doPixelRatio(e)}get shadowBlur(){return this.$undoPixelRatio($e(this,Ze,"f").shadowBlur)}set shadowBlur(e){$e(this,Ze,"f").shadowBlur=this.$doPixelRatio(e)}get lineCap(){return $e(this,Ze,"f").lineCap}set lineCap(e){$e(this,Ze,"f").lineCap=e}get globalCompositeOperation(){return $e(this,Ze,"f").globalCompositeOperation}set globalCompositeOperation(e){$e(this,Ze,"f").globalCompositeOperation=e}fill(...e){return $e(this,Ze,"f").fill(...e)}arc(e,t,i,o,n,r){return $e(this,Ze,"f").arc(this.$doPixelRatio(e),this.$doPixelRatio(t),this.$doPixelRatio(i),o,n,r)}rect(e,t,i,o){return $e(this,Ze,"f").rect(this.$doPixelRatio(e),this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o))}fillRect(e,t,i,o){return $e(this,Ze,"f").fillRect(this.$doPixelRatio(e),this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o))}clearRect(e,t,i,o){return $e(this,Ze,"f").clearRect(this.$doPixelRatio(e),this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o))}beginPath(){return $e(this,Ze,"f").beginPath()}closePath(){return $e(this,Ze,"f").closePath()}lineTo(e,t){return $e(this,Ze,"f").lineTo(this.$doPixelRatio(e),this.$doPixelRatio(t))}moveTo(e,t){return $e(this,Ze,"f").moveTo(this.$doPixelRatio(e),this.$doPixelRatio(t))}arcTo(e,t,i,o,n){return $e(this,Ze,"f").arcTo(this.$doPixelRatio(e),this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o),this.$doPixelRatio(n))}bezierCurveTo(e,t,i,o,n,r){return $e(this,Ze,"f").bezierCurveTo(this.$doPixelRatio(e),this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o),this.$doPixelRatio(n),this.$doPixelRatio(r))}quadraticCurveTo(e,t,i,o){return $e(this,Ze,"f").quadraticCurveTo(this.$doPixelRatio(e),this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o))}getLineDash(){return $e(this,Ze,"f").getLineDash()}setLineDash(e){const t=e.map((e=>this.$doPixelRatio(e)));return $e(this,Ze,"f").setLineDash(t)}stroke(e){return e?$e(this,Ze,"f").stroke(e):$e(this,Ze,"f").stroke()}translate(e,t){return $e(this,Ze,"f").translate(this.$doPixelRatio(e),this.$doPixelRatio(t))}rotate(e){return $e(this,Ze,"f").rotate(e)}drawImage(...e){const t=e[0],i=e[1],o=e[2],n=e[3],r=e[4],l=e[e.length-4],a=e[e.length-3],s=e[e.length-2],h=e[e.length-1];return 9===e.length?$e(this,Ze,"f").drawImage(t,this.$doPixelRatio(i),this.$doPixelRatio(o),this.$doPixelRatio(n),this.$doPixelRatio(r),this.$doPixelRatio(l),this.$doPixelRatio(a),this.$doPixelRatio(s),this.$doPixelRatio(h)):$e(this,Ze,"f").drawImage(t,this.$doPixelRatio(l),this.$doPixelRatio(a),this.$doPixelRatio(s),this.$doPixelRatio(h))}createPattern(e,t){return $e(this,Ze,"f").createPattern(e,t)}measureText(e){return $e(this,Ze,"f").measureText(e)}fillText(e,t,i,o){return void 0!==o?$e(this,Ze,"f").fillText(e,this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o)):$e(this,Ze,"f").fillText(e,this.$doPixelRatio(t),this.$doPixelRatio(i))}strokeText(e,t,i,o){return void 0!==o?$e(this,Ze,"f").strokeText(e,this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o)):$e(this,Ze,"f").strokeText(e,this.$doPixelRatio(t),this.$doPixelRatio(i))}save(){$e(this,Ze,"f").save()}restore(){$e(this,Ze,"f").restore()}scale(e,t){$e(this,Ze,"f").scale(e,t)}circle(e,t,i,o,n,r,l,a){$e(this,Ze,"f").ellipse(this.$doPixelRatio(e),this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o),n,r,l,a)}isPointInPath(e,t){return $e(this,Ze,"f").isPointInPath(this.$doPixelRatio(e),this.$doPixelRatio(t))}clip(...e){return $e(this,Ze,"f").clip(...e)}setTransform(e,t,i,o,n,r){return $e(this,Ze,"f").setTransform(e,t,i,o,n,r)}getTransform(){return $e(this,Ze,"f").getTransform()}createLinearGradient(e,t,i,o){return $e(this,Ze,"f").createLinearGradient(this.$doPixelRatio(e),this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o))}createRadialGradient(e,t,i,o,n,r){return $e(this,Ze,"f").createRadialGradient(this.$doPixelRatio(e),this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o),this.$doPixelRatio(n),this.$doPixelRatio(r))}createConicGradient(e,t,i){return $e(this,Ze,"f").createConicGradient(e,this.$doPixelRatio(t),this.$doPixelRatio(i))}}function Ke(e){const{width:t,height:i,devicePixelRatio:o}=e,n=new OffscreenCanvas(t*o,i*o),r=n.getContext("2d").canvas.getContext("2d");return new Je(r,{devicePixelRatio:o,offscreenCanvas:n})}function qe(e,t){const{width:i,height:o,devicePixelRatio:n}=t,r={width:i,height:o,devicePixelRatio:n},l=e.getContext("2d"),a=Ke(r),s=Ke(r),h=Ke(r),c=function(e){const{width:t,height:i,ctx:o,devicePixelRatio:n}=e;let r=o;if(!r){const e=document.createElement("canvas");e.width=t*n,e.height=i*n,r=e.getContext("2d")}return new Je(r,e)}(Object.assign({ctx:l},r)),d=Ke(r);return{underlayContext:h,viewContext:a,overlayContext:s,boardContext:c,tempContext:d,drawView:()=>{const{width:e,height:t}=a.$getSize();c.clearRect(0,0,e,t),c.drawImage(h.canvas,0,0,e,t),c.drawImage(a.canvas,0,0,e,t),c.drawImage(s.canvas,0,0,e,t),h.clearRect(0,0,e,t),a.clearRect(0,0,e,t),s.clearRect(0,0,e,t)}}}Ze=new WeakMap,Qe=new WeakMap;var _e,et=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 tt{constructor(){_e.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,_e,new Map,"f")}on(e,t){if(et(this,_e,"f").has(e)){const i=et(this,_e,"f").get(e)||[];null==i||i.push(t),et(this,_e,"f").set(e,i)}else et(this,_e,"f").set(e,[t])}off(e,t){if(et(this,_e,"f").has(e)){const i=et(this,_e,"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}et(this,_e,"f").set(e,i||[])}}trigger(e,t){const i=et(this,_e,"f").get(e);return!!Array.isArray(i)&&(i.forEach((e=>{e(t)})),!0)}has(e){if(et(this,_e,"f").has(e)){const t=et(this,_e,"f").get(e);if(Array.isArray(t)&&t.length>0)return!0}return!1}destroy(){this.clear()}clear(){et(this,_e,"f").clear()}}function it(e,t){return{x:e.x+(t.x-e.x)/2,y:e.y+(t.y-e.y)/2}}_e=new WeakMap;var ot,nt,rt,lt,at,st=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},ht=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 ct{constructor(e){ot.add(this),nt.set(this,void 0),rt.set(this,void 0),lt.set(this,void 0),st(this,rt,Ce(e.defaultStorage),"f"),st(this,nt,ht(this,ot,"m",at).call(this),"f"),st(this,lt,e.defaultStatic||{},"f")}set(e,t){ht(this,nt,"f")[e]=t}get(e){return ht(this,nt,"f")[e]}setStatic(e,t){ht(this,lt,"f")[e]=t}getStatic(e){return ht(this,lt,"f")[e]}getSnapshot(e){return!0===(null==e?void 0:e.deepClone)?Ce(ht(this,nt,"f")):Object.assign({},ht(this,nt,"f"))}clear(){st(this,nt,ht(this,ot,"m",at).call(this),"f")}destroy(){st(this,nt,null,"f"),st(this,lt,null,"f")}}function dt(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 ut(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 ft(e){return e/180*Math.PI}function gt(e,t,i,o){const n=ft(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 vt(e,t,i){const o=mt(t);gt(e,t.angle||0,o,(()=>{i(e)}))}function mt(e){return{x:e.x+e.w/2,y:e.y+e.h/2}}function yt(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 mt({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 pt(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 wt(e,t,i){let o=pt(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 r=0,l=0;return 0===o?(r=0,l=0-n):o>0&&o<Math.PI/2?(r=Math.sin(o)*n,l=0-Math.cos(o)*n):o===Math.PI/2?(r=n,l=0):o>Math.PI/2&&o<Math.PI?(r=Math.sin(Math.PI-o)*n,l=Math.cos(Math.PI-o)*n):o===Math.PI?(r=0,l=n):o>Math.PI&&o<1.5*Math.PI?(r=0-Math.sin(o-Math.PI)*n,l=Math.cos(o-Math.PI)*n):o===1.5*Math.PI?(r=0-n,l=0):o>1.5*Math.PI&&o<2*Math.PI?(r=0-Math.sin(2*Math.PI-o)*n,l=0-Math.cos(2*Math.PI-o)*n):o===2*Math.PI&&(r=0,l=0-n),r+=e.x,l+=e.y,{x:r,y:l}}function xt(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:r,h:l,angle:a=0}=e,s=wt(mt({x:t,y:n,w:r,h:l}),{x:i,y:o},ft(a));i=s.x,o=s.y})),{x:i,y:o}}return e}function St(e,t,i){const{x:o,y:n,w:r,h:l}=e;let a={x:o,y:n},s={x:o+r,y:n},h={x:o+r,y:n+l},c={x:o,y:n+l};if(i&&(i>0||i<0)){const e=ft(It(i));a=wt(t,a,e),s=wt(t,s,e),h=wt(t,h,e),c=wt(t,c,e)}return[a,s,h,c]}function bt(e){const{angle:t=0}=e;return St(e,mt(e),t)}function At(e,t,i){return[wt(e,{x:t[0].x,y:t[0].y},i),wt(e,{x:t[1].x,y:t[1].y},i),wt(e,{x:t[2].x,y:t[2].y},i),wt(e,{x:t[3].x,y:t[3].y},i)]}function It(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 Mt(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=Mt(null===(o=null==e?void 0:e.detail)||void 0===o?void 0:o.children))}))}return t}function zt(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=bt(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),r=Math.max(t.x+t.w,i.x+i.w),l=Math.max(t.y+t.h,i.y+i.h);i.x=o,i.y=n,i.w=Math.abs(r-o),i.h=Math.abs(l-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 Rt(e,t){var i;const o=[];let n=e;if(t.length>1)for(let e=0;e<t.length-1;e++){const r=n[t[e]];if("group"!==(null==r?void 0:r.type)||!Array.isArray(null===(i=null==r?void 0:r.detail)||void 0===i?void 0:i.children))return null;o.push(r),n=r.detail.children}return o}function Ct(e){const{x:t,y:i,w:o,h:n,angle:r}=e;return{x:t,y:i,w:o,h:n,angle:r}}function Et(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"===(null==n?void 0:n.type))o=n.detail.children;else{if(t!==e.length-1)break;i=n}}return i}function Tt(e,t){const i=[];let o=!1;const n=t=>{var r;for(let l=0;l<t.length&&!0!==o;l++){i.push(l);const a=t[l];if(a.uuid===e){o=!0;break}if("group"===a.type&&n((null===(r=null==a?void 0:a.detail)||void 0===r?void 0:r.children)||[]),o)break;i.pop()}};return n(t),i}function Pt(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 Lt(e){const{x:t,y:i,w:o,h:n,angle:r=0}=e;return 0===r?Pt(e):St(e,mt({x:t,y:i,w:o,h:n}),r)}function Ot(e){const t=[];let i=0,o=0;const n=[],r=[...e];for(let e=0;e<r.length;e++){const{x:l,y:a,w:s,h:h,angle:c=0}=r[e];let d;if(i+=l,o+=a,0===e){const e={x:i,y:o,w:s,h:h};d=Lt({x:l,y:a,w:s,h:h,angle:c}),n.push({center:mt(e),angle:c,radian:ft(c)})}else{d=Pt({x:i,y:o,w:s,h:h});for(let e=0;e<n.length;e++){const{center:t,radian:i}=n[e];d=At(t,d,i)}const e=yt(d);if(c>0||c<0){d=At(e,d,ft(c))}n.push({center:e,angle:c,radian:ft(c)})}t.push(d)}return t}function kt(e,t){const i=function(e,t){const{groupQueue:i}=t;return i.length>0?Ot([...i,e]):[Lt(e)]}(e,t);return i.pop()||null}function Wt(e,t){const{viewScaleInfo:i}=t,{x:o,y:n,w:r,h:l,angle:a}=e,{scale:s,offsetTop:h,offsetLeft:c}=i;return{x:o*s+c,y:n*s+h,w:r*s,h:l*s,angle:a}}function Dt(e,t){const{viewScaleInfo:i}=t,{x:o,y:n}=e,{scale:r,offsetTop:l,offsetLeft:a}=i;return{x:o*r+a,y:n*r+l}}function jt(e,t){return[Dt(e[0],t),Dt(e[1],t),Dt(e[2],t),Dt(e[3],t)]}function Yt(e,t){const{context2d:i,element:o,viewScaleInfo:n}=t,{angle:r=0}=o,{x:l,y:a,w:s,h:h}=Wt(o,{viewScaleInfo:n}),c=bt({x:l,y:a,w:s,h:h,angle:r});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 Nt(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],r=Math.min(...o),l=Math.max(...o),a=Math.min(...n),s=Math.max(...n);return e.x>r&&e.x<l&&e.y>a&&e.y<s}function Bt(e,t){const{groupQueue:i}=t,o=kt(e,{groupQueue:i}),n=it(o[0],o[1]),r=it(o[1],o[2]),l=it(o[2],o[3]),a=it(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:r,left:a,bottom:l}}function Ft(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),r={x:e.center.x,y:e.center.y},l={x:o,y:n},a={x:t,y:n},s={x:t,y:i},h={x:o,y:i},c=it(l,a),d=it(h,s),u=it(l,h);return{center:r,topLeft:l,topRight:a,bottomLeft:h,bottomRight:s,top:c,right:it(a,s),left:u,bottom:d}}function Gt(e,t){const{x:i,y:o}=e,{size:n,angle:r}=t;return{x:i-n/2,y:o-n/2,w:n,h:n,angle:r}}function Vt(e,t){const{groupQueue:i,controllerSize:o,viewScaleInfo:n,rotateControllerSize:r,rotateControllerPosition:l}=t,a=(o&&o>0?o:8)/n.scale,{x:s,y:h,w:c,h:d,angle:u=0}=e,f=r,g=l,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=kt(e,{groupQueue:i}),p=kt({x:s,y:h-(g+f/2)/n.scale,h:d+(2*g+f)/n.scale,w:c,angle:u},{groupQueue:[...i]}),w=it(y[0],y[1]),x=it(y[1],y[2]),S=it(y[2],y[3]),b=it(y[3],y[0]),A=y[0],I=y[1],M=y[2],z=y[3],R=Gt(w,{size:a,angle:m}),C=Gt(x,{size:a,angle:m}),E=Gt(S,{size:a,angle:m}),T=Gt(b,{size:a,angle:m}),P=Gt(A,{size:a,angle:m}),L=Gt(I,{size:a,angle:m}),O=Gt(z,{size:a,angle:m}),k=Gt(M,{size:a,angle:m}),W=Lt(P),D=Lt(L),j=Lt(O),Y=Lt(k),N=[W[1],D[0],D[3],W[2]],B=[D[3],D[2],Y[1],Y[0]],F=[j[1],Y[0],Y[3],j[2]],G=[W[3],W[2],j[1],j[0]],V=Lt(R),X=Lt(C),H=Lt(E),Z=Lt(T),Q=it(p[0],p[1]),U=Lt(Gt(Q,{size:1.1*r/n.scale,angle:m}));return{originalElementCenter:mt(e),originalElementSize:Object.assign({},e),elementWrapper:y,left:{type:"left",vertexes:G,center:b,size:a},right:{type:"right",vertexes:B,center:x,size:a},top:{type:"top",vertexes:N,center:w,size:a},bottom:{type:"bottom",vertexes:F,center:S,size:a},topLeft:{type:"top-left",vertexes:W,center:A,size:a},topRight:{type:"top-right",vertexes:D,center:I,size:a},bottomLeft:{type:"bottom-left",vertexes:j,center:z,size:a},bottomRight:{type:"bottom-right",vertexes:Y,center:M,size:a},leftMiddle:{type:"left-middle",vertexes:Z,center:b,size:a},rightMiddle:{type:"right-middle",vertexes:X,center:x,size:a},topMiddle:{type:"top-middle",vertexes:V,center:w,size:a},bottomMiddle:{type:"bottom-middle",vertexes:H,center:S,size:a},rotate:{type:"rotate",vertexes:U,center:Q,size:r}}}function Xt(e,t){const{controllerSize:i,viewScaleInfo:o}=t,n=i&&i>0?i:8,{x:r,y:l,w:a,h:s}=Wt(e,{viewScaleInfo:o}),h=mt({x:r,y:l,w:a,h:s}),c={x:h.x,y:l},d={x:r+a,y:h.y},u={x:h.x,y:l+s},f={x:r,y:h.y},g={x:r,y:l},v={x:r+a,y:l},m={x:r+a,y:l+s},y={x:r,y:l+s},p=Gt(c,{size:n,angle:0}),w=Gt(d,{size:n,angle:0}),x=Gt(u,{size:n,angle:0}),S=Gt(f,{size:n,angle:0}),b=Gt(g,{size:n,angle:0}),A=Gt(v,{size:n,angle:0}),I=Gt(y,{size:n,angle:0}),M=Gt(m,{size:n,angle:0}),z=Lt(b),R=Lt(A),C=Lt(I),E=Lt(M),T=[z[1],R[0],R[3],z[2]],P=[R[3],R[2],E[1],E[0]],L=[C[1],E[0],E[3],C[2]],O=[z[3],z[2],C[1],C[0]],k=Lt(p),W=Lt(w),D=Lt(x);return{left:{type:"left",vertexes:O,center:f,size:n},right:{type:"right",vertexes:P,center:d,size:n},top:{type:"top",vertexes:T,center:c,size:n},bottom:{type:"bottom",vertexes:L,center:u,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:y,size:n},bottomRight:{type:"bottom-right",vertexes:E,center:m,size:n},leftMiddle:{type:"left-middle",vertexes:Lt(S),center:f,size:n},rightMiddle:{type:"right-middle",vertexes:W,center:d,size:n},topMiddle:{type:"top-middle",vertexes:k,center:c,size:n},bottomMiddle:{type:"bottom-middle",vertexes:D,center:u,size:n}}}function Ht(e){let t="";return e.forEach((e=>{t+=e.type+e.params.join(" ")})),t}function Zt(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))}nt=new WeakMap,rt=new WeakMap,lt=new WeakMap,ot=new WeakSet,at=function(){return Ce(ht(this,rt,"f"))};const Qt="Text Element";const Ut={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 $t(e,t){const{viewScaleInfo:i}=t,{scale:o}=i;let{borderRadius:n}=e.detail;const{borderDash:r}=e.detail,l=Array.isArray(r)&&r.length>0,{boxSizing:a=Ut.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"!==a||l?"content-box"===a?(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}}function Jt(e,t="",i={},o){return Object.keys(e).forEach((n=>{var r;const l=t?`${t}${function(e){return/^\d+$/.test(e)&&!isNaN(Number(e))}(n)?`[${n}]`:`.${n}`}`:n;if(!(null===(r=null==o?void 0:o.ignorePaths)||void 0===r?void 0:r.includes(l))){const t=e[n];!function(e){return"object"==typeof e&&null!==e&&!(e instanceof Date)||Array.isArray(e)}(t)?i[l]=t:Jt(t,(Array.isArray(t),l),i,o)}})),i}function Kt(e,t){return"object"!=typeof e||null===e?{"":e}:Jt(e,"",{},t)}function qt(e){return Kt(e,{ignorePaths:["detail.children"]})}function _t(e){return Kt(e)}function ei(e){return Kt(e)}function ti(e){return Array.isArray(e)?[...e]:e.split(/\.|\[|\]/).filter((e=>""!==e))}function ii(e,t,i){if(!t)return;const o=ti(t);let n=e;for(const e of o){if(null==n)return i;n=n[e]}return void 0!==n?n:i}function oi(e,t,i){const o=ti(t);if(0===o.length)return e;let n=e;if(n)for(let e=0;e<o.length;e++){const t=o[e];if(e===o.length-1){n[t]=i;break}if(n&&(void 0===(null==n?void 0:n[t])||"object"!=typeof(null==n?void 0:n[t])||null===(null==n?void 0:n[t]))){const i=o[e+1],r=/^\d+$/.test(i);n[t]=r?[]:{}}n=null==n?void 0:n[t]}return e}function ni(e,t){const i=ti(t);if(0===i.length)return e;let o=e;if(o)for(let e=0;e<i.length;e++){const t=i[e];if(e===i.length-1){delete o[t];break}if(o&&(void 0===(null==o?void 0:o[t])||"object"!=typeof(null==o?void 0:o[t])||null===(null==o?void 0:o[t]))){const n=i[e+1],r=/^\d+$/.test(n);o[t]=r?[]:{}}o=null==o?void 0:o[t]}return e}const ri=e=>Zt(e,{decimalPlaces:4});function li(e,t){const i={detail:{}},o={detail:{}},n={type:"modifyElement",time:Date.now(),content:{method:"modifyElement",uuid:e.uuid,before:null,after:null}},{detail:r}=e,{xRatio:l,yRatio:a,maxRatio:s}=t,h=(l+a)/2,{borderWidth:c,borderRadius:d,borderDash:u,shadowOffsetX:f,shadowOffsetY:g,shadowBlur:v}=r;if("number"==typeof c)r.borderWidth=ri(c*h),i.detail.borderWidth=c,o.detail.borderWidth=r.borderWidth;else if(Array.isArray(r.borderWidth)){const e=c;r.borderWidth=[ri(e[0]*a),ri(e[1]*l),ri(e[2]*a),ri(e[3]*l)],i.detail.borderWidth=[...e],o.detail.borderWidth=[...r.borderWidth]}if("number"==typeof d)r.borderRadius=ri(d*h),i.detail.borderRadius=d,o.detail.borderRadius=r.borderRadius;else if(Array.isArray(r.borderRadius)){const e=d;r.borderRadius=[e[0]*l,e[1]*l,e[2]*a,e[3]*a],i.detail.borderRadius=[...e],o.detail.borderRadius=[...r.borderRadius]}return Array.isArray(u)&&(u.forEach(((e,t)=>{r.borderDash[t]=ri(e*s)})),i.detail.borderDash=[...u],o.detail.borderDash=[...r.borderDash]),"number"==typeof f&&(r.shadowOffsetX=ri(f*s),i.detail.shadowOffsetX=f,o.detail.shadowOffsetX=r.shadowOffsetX),"number"==typeof g&&(r.shadowOffsetY=ri(g*s),i.detail.shadowOffsetY=g,o.detail.shadowOffsetY=r.shadowOffsetY),"number"==typeof v&&(r.shadowBlur=ri(v*s),i.detail.shadowBlur=v,o.detail.shadowBlur=r.shadowBlur),n.content.before=qt(i),n.content.after=qt(o),n}function ai(e,t,i){const{type:o,uuid:n}=e,r=function(e,t){const{xRatio:i,yRatio:o}=t,{uuid:n,x:r,y:l,w:a,h:s}=e;e.x=ri(r*i),e.y=ri(l*o),e.w=ri(a*i),e.h=ri(s*o);const h={type:"modifyElement",time:Date.now(),content:{method:"modifyElement",uuid:n,before:{x:r,y:l,w:a,h:s},after:{x:e.x,y:e.y,w:e.w,h:e.h}}},c=li(e,t);return h.content.before=Object.assign(Object.assign({},h.content.before),c.content.before),h.content.after=Object.assign(Object.assign({},h.content.after),c.content.after),h}(e,t),l=Object.assign(Object.assign({},r.content.before),{uuid:n}),a=Object.assign(Object.assign({},r.content.after),{uuid:n});if(null==i||i.content.before.push(l),null==i||i.content.after.push(a),"circle"===o);else if("text"===o){const i=function(e,t){const{minRatio:i,maxRatio:o}=t,{fontSize:n,lineHeight:r}=e.detail,l=(i+o)/2,a={},s={};return n&&n>0&&(e.detail.fontSize=ri(n*l),a["detail.fontSize"]=n,s["detail.fontSize"]=e.detail.fontSize),r&&r>0&&(e.detail.lineHeight=ri(r*l),a["detail.lineHeight"]=r,s["detail.lineHeight"]=e.detail.lineHeight),{type:"modifyElement",time:Date.now(),content:{method:"modifyElement",uuid:e.uuid,before:a,after:s}}}(e,t);Object.keys(i.content.before||{}).forEach((e=>{var t;l[e]=null===(t=i.content.before)||void 0===t?void 0:t[e]})),Object.keys(i.content.after||{}).forEach((e=>{var t;a[e]=null===(t=i.content.after)||void 0===t?void 0:t[e]}))}else"image"===o||"svg"===o||"html"===o||"path"===o||"group"===o&&Array.isArray(e.detail.children)&&e.detail.children.forEach((e=>{ai(e,t,i)}))}function si(e,t,i){const o={type:"resizeElements",time:Date.now(),content:{method:"modifyElements",before:[],after:[]}},n=e.uuid,r=e.x,l=e.y,a=e.w,s=e.h,h=Te.number(t.x)?t.x:e.x,c=Te.number(t.y)?t.y:e.y,d=(t.w&&t.w>0?t.w:e.w)||0,u=(t.h&&t.h>0?t.h:e.h)||0,f={uuid:n,x:r,y:l,w:a,h:s},g={uuid:n,x:h,y:c,w:d,h:u};if("deepResize"===(null==i?void 0:i.resizeEffect)){o.content.before.push(f),o.content.after.push(g);const t=d/e.w,i=u/e.h;if(t===i&&1===t)return o;const n=Math.min(t,i),r=Math.max(t,i);e.w=d,e.h=u;const l={xRatio:t,yRatio:i,minRatio:n,maxRatio:r};"group"===e.type&&Array.isArray(e.detail.children)&&e.detail.children.forEach((e=>{ai(e,l,o)}));const a=li(e,l);return Object.keys(a.content.before||{}).forEach((e=>{var t;f[e]=null===(t=a.content.before)||void 0===t?void 0:t[e]})),Object.keys(a.content.after||{}).forEach((e=>{var t;g[e]=null===(t=a.content.after)||void 0===t?void 0:t[e]})),o}if("fixed"===(null==i?void 0:i.resizeEffect)){o.content.before.push(f),o.content.after.push(g);const t=h-e.x,i=c-e.y,n=d-e.w;return function(e,t,i){if("group"!==e.type||!Array.isArray(e.detail.children))return;const{moveX:o,moveY:n,moveH:r,moveW:l}=t;let a=0,s=0,h=!1;0===o&&0===n||0===r&&0===l||(h=!0,a=-o,s=-n),!0===h&&e.detail.children.forEach((e=>{const{uuid:t,x:o,y:n}=e,r=o+a,l=n+s,h={uuid:t,x:o,y:n},c={uuid:t,x:r,y:l};e.x=r,e.y=l,null==i||i.content.before.push(h),null==i||i.content.after.push(c)}))}(e,{moveX:t,moveY:i,moveH:u-e.h,moveW:n},o),e.w=d,e.h=u,e.x=h,e.y=c,o}return e.w=d,e.h=u,e.x=h,e.y=c,o.content.before.push(f),o.content.after.push(g),o}function hi(e,t,i){const o=function(e,t){let i=0,o=0,n=200,r=200;if(t){const{viewScaleInfo:l,viewSizeInfo:a}=t,{scale:s,offsetLeft:h,offsetTop:c}=l,{width:d,height:u}=a,f=d/4,g=u/4;n=200>=f?f/s:200/s,r=200>=g?g/s:200/s,["circle","svg","image"].includes(e)?n=r=Math.max(n,r):"text"===e&&(r=n/12*2),i=(0-h+d/2-n*s/2)/s,o=(0-c+u/2-r*s/2)/s}return{x:i,y:o,w:n,h:r}}(e,i);let n={};"rect"===e?n={background:"#D9D9D9"}:"circle"===e?n={background:"#D9D9D9",radius:0}:"text"===e?n=function(e){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"};return{text:Qt,color:t.color,fontFamily:t.fontFamily,fontWeight:t.fontWeight,fontSize:e.w/12,textAlign:"center",verticalAlign:"middle"}}(o):"svg"===e?n={svg:'<svg t="1701004189871" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" width="200" height="200"><path d="M908.1 353.1l-253.9-36.9L540.7 86.1c-3.1-6.3-8.2-11.4-14.5-14.5-15.8-7.8-35-1.3-42.9 14.5L369.8 316.2l-253.9 36.9c-7 1-13.4 4.3-18.3 9.3-12.3 12.7-12.1 32.9 0.6 45.3l183.7 179.1-43.4 252.9c-1.2 6.9-0.1 14.1 3.2 20.3 8.2 15.6 27.6 21.7 43.2 13.4L512 754l227.1 119.4c6.2 3.3 13.4 4.4 20.3 3.2 17.4-3 29.1-19.5 26.1-36.9l-43.4-252.9 183.7-179.1c5-4.9 8.3-11.3 9.3-18.3 2.7-17.5-9.5-33.7-27-36.3zM664.8 561.6l36.1 210.3L512 672.7 323.1 772l36.1-210.3-152.8-149L417.6 382 512 190.7 606.4 382l211.2 30.7-152.8 148.9z" fill="#2c2c2c"></path></svg>'}:"image"===e?n={src:"data:image/svg+xml;base64,PHN2ZyAgIHZpZXdCb3g9IjAgMCAxMDI0IDEwMjQiIHZlcnNpb249IjEuMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiAgd2lkdGg9IjIwMCIgaGVpZ2h0PSIyMDAiPjxwYXRoIGQ9Ik05MjggMTYwSDk2Yy0xNy43IDAtMzIgMTQuMy0zMiAzMnY2NDBjMCAxNy43IDE0LjMgMzIgMzIgMzJoODMyYzE3LjcgMCAzMi0xNC4zIDMyLTMyVjE5MmMwLTE3LjctMTQuMy0zMi0zMi0zMnogbS00MCA2MzJIMTM2di0zOS45bDEzOC41LTE2NC4zIDE1MC4xIDE3OEw2NTguMSA0ODkgODg4IDc2MS42Vjc5MnogbTAtMTI5LjhMNjY0LjIgMzk2LjhjLTMuMi0zLjgtOS0zLjgtMTIuMiAwTDQyNC42IDY2Ni40bC0xNDQtMTcwLjdjLTMuMi0zLjgtOS0zLjgtMTIuMiAwTDEzNiA2NTIuN1YyMzJoNzUydjQzMC4yeiIgIGZpbGw9IiM1MTUxNTEiPjwvcGF0aD48cGF0aCBkPSJNMzA0IDQ1NmM0OC42IDAgODgtMzkuNCA4OC04OHMtMzkuNC04OC04OC04OC04OCAzOS40LTg4IDg4IDM5LjQgODggODggODh6IG0wLTExNmMxNS41IDAgMjggMTIuNSAyOCAyOHMtMTIuNSAyOC0yOCAyOC0yOC0xMi41LTI4LTI4IDEyLjUtMjggMjgtMjh6IiAgZmlsbD0iIzUxNTE1MSI+PC9wYXRoPjwvc3ZnPg=="}:"group"===e&&(n={children:[],background:"#D9D9D9",overflow:"hidden"});return Object.assign(Object.assign(Object.assign({uuid:Ie()},o),t),{type:e,detail:Object.assign(Object.assign({},n),t.detail||{})})}function ci(e,t,i){let o=!1;if(1===t.length){const n=t[0];i.splice(n,0,e),o=!0}else if(t.length>1){let n=i;for(let i=0;i<t.length;i++){const r=n[t[i]];if(i===t.length-1){const r=t[i];n.splice(r,0,e),o=!0}else{if(!(i<t.length-1&&"group"===r.type))break;n=r.detail.children}}}return o}function di(e,t){let i=!1;if(1===e.length){const o=e[0];t.splice(o,1),i=!0}else if(e.length>1){let o=t;for(let t=0;t<e.length;t++){const n=o[e[t]];if(t===e.length-1){const n=e[t];o.splice(n,1),i=!0}else{if(!(t<e.length-1&&"group"===n.type))break;o=n.detail.children}}}return i}function ui(e,t,i){const o=qt(t),n=["uuid","type"],r=Object.keys(o);if(r.forEach((t=>{if(!n.includes(t)){const i=o[t];ni(e,t),void 0!==i&&oi(e,t,i)}})),!0===(null==i?void 0:i.strict)){const t=qt(e);Object.keys(t).forEach((t=>{n.includes(t)||r.includes(t)||ni(e,t)}))}return e}function fi(e,t,i){var o,n,r;let l=null;for(let a=0;a<i.length;a++){const s=i[a];if(s.uuid===e){"group"===s.type&&(null===(o=s.operations)||void 0===o?void 0:o.resizeEffect)&&si(s,Object.assign({},t),{resizeEffect:null===(n=s.operations)||void 0===n?void 0:n.resizeEffect}),ui(s,t),l=s;break}"group"===s.type&&(l=fi(e,t,(null===(r=null==s?void 0:s.detail)||void 0===r?void 0:r.children)||[]))}return l}function gi(e,t,i,o){var n,r;const l=Et(e,i);return l&&("group"===l.type&&(null===(n=l.operations)||void 0===n?void 0:n.resizeEffect)&&si(l,Object.assign({},t),{resizeEffect:null===(r=l.operations)||void 0===r?void 0:r.resizeEffect}),ui(l,t,o)),l}const vi=["-apple-system",'"system-ui"',' "Segoe UI"'," Roboto",'"Helvetica Neue"',"Arial",'"Noto Sans"'," sans-serif"];function mi(e){return[e,...vi].join(", ")}function yi(e,t,i){if("string"==typeof t)return t;const{viewElementSize:o,viewScaleInfo:n,opacity:r=1}=i,{x:l,y:a}=o,{scale:s}=n;if("linear-gradient"===(null==t?void 0:t.type)){const{start:i,end:o,stops:n}=t,h={x:l+i.x*s,y:a+i.y*s},c={x:l+o.x*s,y:a+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,r))})),d}if("radial-gradient"===(null==t?void 0:t.type)){const{inner:i,outer:o,stops:n}=t,h={x:l+i.x*s,y:a+i.y*s,radius:i.radius*s},c={x:l+o.x*s,y:a+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,r))})),d}return"#000000"}const pi={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 wi(e){var t,i,o,n;let r=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&&(r=null===(n=null==e?void 0:e.detail)||void 0===n?void 0:n.opacity),r}function xi(e,t,i){const{pattern:o,renderContent:n,originElem:r,calcElemSize:l,viewScaleInfo:a,viewSizeInfo:s}=i||{},{parentOpacity:h}=i,c=wi(r)*h,{clipPath:d,clipPathStrokeColor:u,clipPathStrokeWidth:f}=r.detail,g=()=>{e.globalAlpha=c,Si(e,t,{pattern:o,viewScaleInfo:a,viewSizeInfo:s}),null==n||n(),bi(e,t,{viewScaleInfo:a}),e.globalAlpha=h};d?(function(e,t,i){const{renderContent:o,originElem:n,calcElemSize:r,viewSizeInfo:l}=i,a=l.devicePixelRatio,{clipPath:s}=(null==n?void 0:n.detail)||{};if(s&&r&&s.commands){const{x:i,y:n,w:l,h:h}=r,{originW:c,originH:d,originX:u,originY:f}=s,g=l/c,v=h/d,m=i-u*g,y=n-f*v;e.save(),e.translate(m,y),e.scale(a*g,a*v);const p=Ht(s.commands||[]),w=new Path2D(p);e.clip(w,"nonzero"),e.translate(0-m,0-y),e.setTransform(1,0,0,1,0,0),vt(e,Object.assign({},t),(()=>{null==o||o()})),e.restore()}else null==o||o()}(e,t,{originElem:r,calcElemSize:l,viewSizeInfo:s,renderContent:()=>{g()}}),"number"==typeof f&&f>0&&u&&function(e,t,i){const{renderContent:o,originElem:n,calcElemSize:r,viewSizeInfo:l,parentOpacity:a}=i,s=l.devicePixelRatio,{clipPath:h,clipPathStrokeColor:c,clipPathStrokeWidth:d}=(null==n?void 0:n.detail)||{};if(h&&r&&h.commands&&"number"==typeof d&&d>0&&c){const{x:i,y:n,w:l,h:u}=r,{originW:f,originH:g,originX:v,originY:m}=h,y=l/f,p=u/g,w=i-v*y,x=n-m*p;e.save(),e.globalAlpha=a,e.translate(w,x),e.scale(s*y,s*p);const S=Ht(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),vt(e,Object.assign({},t),(()=>{null==o||o()})),e.restore()}else null==o||o()}(e,t,{originElem:r,calcElemSize:l,viewSizeInfo:s,parentOpacity:h})):g()}function Si(e,t,i){var o,n;const{pattern:r,viewScaleInfo:l,viewSizeInfo:a}=i,s=[];if(t.detail.background||r){const{x:i,y:a,w:h,h:c,radiusList:d}=$t(t,{viewScaleInfo:l});if(e.beginPath(),e.moveTo(i+d[0],a),e.arcTo(i+h,a,i+h,a+c,d[1]),e.arcTo(i+h,a+c,i,a+c,d[2]),e.arcTo(i,a+c,i,a,d[3]),e.arcTo(i,a,i+h,a,d[0]),e.closePath(),"string"==typeof r)e.fillStyle=r;else if(["CanvasPattern"].includes(Te.type(r)))e.fillStyle=r;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=yi(e,t.detail.background,{viewElementSize:{x:i,y:a,w:h,h:c},viewScaleInfo:l,opacity:e.globalAlpha});e.fillStyle=o}else if("radial-gradient"===(null===(n=t.detail.background)||void 0===n?void 0:n.type)){const o=yi(e,t.detail.background,{viewElementSize:{x:i,y:a,w:h,h:c},viewScaleInfo:l,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]+a):"rotate"===o.method?e.rotate(...o.args):"scale"===o.method&&e.scale(...o.args)}}e.fill("nonzero"),s&&s.length>0&&e.setTransform(1,0,0,1,0,0)}}function bi(e,t,i){if(0===t.detail.borderWidth)return;if(!be(t.detail.borderColor))return;const{viewScaleInfo:o}=i,{scale:n}=o;let r=pi.borderColor;!0===be(t.detail.borderColor)&&(r=t.detail.borderColor);const{borderDash:l,borderWidth:a,borderRadius:s,boxSizing:h=pi.boxSizing}=t.detail;let c=[];Array.isArray(l)&&l.length>0&&(c=l.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 a&&(u=a||1),u*=n,e.strokeStyle=r;let f=0,g=0,v=0,m=0;if(Array.isArray(a)&&(f=(a[0]||0)*n,g=(a[1]||0)*n,v=(a[2]||0)*n,m=(a[3]||0)*n),m||g||f||v){e.lineCap="butt";let{x:i,y:o,w:n,h:r}=t;"border-box"===h?(i+=m/2,o+=f/2,n=n-m/2-g/2,r=r-f/2-v/2):"content-box"===h?(i-=m/2,o-=f/2,n=n+m/2+g/2,r=r+f/2+v/2):(i=t.x,o=t.y,n=t.w,r=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+r+v/2),e.closePath(),e.stroke()),v&&(e.beginPath(),e.lineWidth=v,e.moveTo(i-m/2,o+r),e.lineTo(i+n+g/2,o+r),e.closePath(),e.stroke()),m&&(e.beginPath(),e.lineWidth=m,e.moveTo(i,o-f/2),e.lineTo(i,o+r+v/2),e.closePath(),e.stroke())}else{let{x:i,y:o,w:n,h:r}=t;"border-box"===h?(i=t.x+u/2,o=t.y+u/2,n=t.w-u,r=t.h-u):"content-box"===h?(i=t.x-u/2,o=t.y-u/2,n=t.w+u,r=t.h+u):(i=t.x,o=t.y,n=t.w,r=t.h),n=Math.max(n,1),r=Math.max(r,1),d=d.map((e=>Math.min(e,n/2,r/2))),e.setLineDash(c),e.lineWidth=u,e.beginPath(),e.moveTo(i+d[0],o),e.arcTo(i+n,o,i+n,o+r,d[1]),e.arcTo(i+n,o+r,i,o+r,d[2]),e.arcTo(i,o+r,i,o,d[3]),e.arcTo(i,o,i+n,o,d[0]),e.closePath(),e.stroke()}e.setLineDash([])}function Ai(e,t,i){const{detail:o}=t,{viewScaleInfo:n,renderContent:r}=i,{shadowColor:l,shadowOffsetX:a,shadowOffsetY:s,shadowBlur:h}=o;He.number(h)?(e.save(),e.shadowColor=l||pi.shadowColor,e.shadowOffsetX=(a||0)*n.scale,e.shadowOffsetY=(s||0)*n.scale,e.shadowBlur=(h||0)*n.scale,r(),e.restore()):(e.save(),e.shadowColor="transparent",e.shadowOffsetX=0,e.shadowOffsetY=0,e.shadowBlur=0,r(),e.restore())}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,i){var o,n;const{detail:r}=t,{originX:l,originY:a,originW:s,originH:h,fillRule:c}=r,{viewScaleInfo:d,viewSizeInfo:u,parentOpacity:f}=i,{x:g,y:v,w:m,h:y,angle:p}=Wt(t,{viewScaleInfo:d})||t,w=m/s,x=y/h,S=g-l*w,b=v-a*x,A=t.detail,{clipPath:I,clipPathStrokeColor:M,clipPathStrokeWidth:z}=A,R=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,E=Object.assign(Object.assign({},t),{x:g,y:v,w:m,h:y,angle:p});let T=Object.assign({},E);T.detail=R;let P=Object.assign({},t);P.detail=R,r.fill&&"string"!==r.fill&&(null===(n=null===(o=r.fill)||void 0===o?void 0:o.type)||void 0===n?void 0:n.includes("gradient"))&&(T=Object.assign(Object.assign({},E),{detail:Object.assign(Object.assign({},E.detail),{background:r.fill,clipPath:{commands:r.commands,originX:l,originY:a,originW:s,originH:h}})}),P.detail=Object.assign({},T.detail)),vt(e,{x:g,y:v,w:m,h:y,angle:p},(()=>{xi(e,T,{originElem:P,calcElemSize:{x:g,y:v,w:m,h:y,angle:p},viewScaleInfo:d,viewSizeInfo:u,parentOpacity:f,renderContent:()=>{Ai(e,E,{viewScaleInfo:d,renderContent:()=>{e.save(),e.translate(S,b),e.scale(C*w/d.scale,C*x/d.scale);const t=Ht(r.commands||[]),i=new Path2D(t);r.fill&&("string"==typeof r.fill?e.fillStyle=r.fill:e.fillStyle="transparent"),r.fill&&e.fill(i,c||"nonzero"),r.stroke&&0!==r.strokeWidth&&(e.strokeStyle=r.stroke,e.lineWidth=(r.strokeWidth||1)/u.devicePixelRatio,e.lineCap=r.strokeLineCap||"square",e.stroke(i)),e.translate(-S,-b),e.restore()}})}})}))}function zi(e,t,i){var o,n,r;if(!0===(null===(o=null==t?void 0:t.operations)||void 0===o?void 0:o.invisible))return;const{w:l,h:a}=t,{scale:s}=i.viewScaleInfo;if(s<1&&(l*s<.4||a*s<.4)||0===i.parentOpacity)return;const{overrideElementMap:h}=i;if(!(null===(r=null===(n=null==h?void 0:h[t.uuid])||void 0===n?void 0:n.operations)||void 0===r?void 0:r.invisible))try{switch(t.type){case"rect":!function(e,t,i){const{viewScaleInfo:o,viewSizeInfo:n,parentOpacity:r}=i,{x:l,y:a,w:s,h:h,angle:c}=Wt(t,{viewScaleInfo:o})||t,d=Object.assign(Object.assign({},t),{x:l,y:a,w:s,h:h,angle:c});vt(e,{x:l,y:a,w:s,h:h,angle:c},(()=>{Ai(e,d,{viewScaleInfo:o,renderContent:()=>{xi(e,d,{originElem:t,calcElemSize:{x:l,y:a,w:s,h:h,angle:c},viewScaleInfo:o,viewSizeInfo:n,parentOpacity:r,renderContent:()=>{}})}})}))}(e,t,i);break;case"circle":!function(e,t,i){const{detail:o,angle:n}=t,{viewScaleInfo:r,viewSizeInfo:l,parentOpacity:a}=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*=r.scale;const{x:g,y:v,w:m,h:y}=Wt({x:t.x,y:t.y,w:t.w,h:t.h},{viewScaleInfo:r})||t,p=Object.assign(Object.assign({},t),{x:g,y:v,w:m,h:y,angle:n});vt(e,{x:g,y:v,w:m,h:y,angle:n},(()=>{Ai(e,p,{viewScaleInfo:r,renderContent:()=>{let t=m/2,i=y/2;const o=g+t,n=v+i,l=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=wi(p)*a;e.globalAlpha=c,e.beginPath();const w=yi(e,s,{viewElementSize:{x:g,y:v,w:m,h:y},viewScaleInfo:r,opacity:e.globalAlpha});if(e.fillStyle=w,e.circle(o,n,l,d,0,0,2*Math.PI),e.closePath(),e.fill("nonzero"),e.globalAlpha=a,"number"==typeof f&&f>0){const l=f/2+t,a=f/2+i;if(e.beginPath(),u){const t=u.map((e=>e*r.scale));e.setLineDash(t)}e.strokeStyle=h,e.lineWidth=f,e.circle(o,n,l,a,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:r,calculator:l}=i,{x:a,y:s,w:h,h:c,angle:d}=Wt(t,{viewScaleInfo:o})||t,u=Object.assign(Object.assign({},t),{x:a,y:s,w:h,h:c,angle:d});vt(e,{x:a,y:s,w:h,h:c,angle:d},(()=>{var f,g;Ai(e,u,{viewScaleInfo:o,renderContent:()=>{xi(e,u,{originElem:t,calcElemSize:{x:a,y:s,w:h,h:c,angle:d},viewScaleInfo:o,viewSizeInfo:n,parentOpacity:r})}});{const n=Object.assign(Object.assign({},Ii),t.detail),r=(n.fontSize||Ii.fontSize)*o.scale;if(r<2)return;const{parentOpacity:h}=i,c=wi(t)*h;e.globalAlpha=c,e.fillStyle=t.detail.color||Ii.color,e.textBaseline="top",e.$setFont({fontWeight:n.fontWeight,fontSize:r,fontFamily:mi(n.fontFamily)});{const i=l.getVirtualFlatItem(t.uuid);Array.isArray(null==i?void 0:i.textLines)&&(null===(f=null==i?void 0:i.textLines)||void 0===f?void 0:f.length)>0&&(void 0!==n.textShadowColor&&be(n.textShadowColor)&&(e.shadowColor=n.textShadowColor),void 0!==n.textShadowOffsetX&&He.number(n.textShadowOffsetX)&&(e.shadowOffsetX=n.textShadowOffsetX),void 0!==n.textShadowOffsetY&&He.number(n.textShadowOffsetY)&&(e.shadowOffsetY=n.textShadowOffsetY),void 0!==n.textShadowBlur&&He.number(n.textShadowBlur)&&(e.shadowBlur=n.textShadowBlur),null===(g=null==i?void 0:i.textLines)||void 0===g||g.forEach((t=>{e.fillText(t.text,a+t.x*o.scale,s+t.y*o.scale)})))}e.globalAlpha=h}}))}(e,t,i);break;case"image":!function(e,t,i){const o=i.loader.getContent(t),{viewScaleInfo:n,viewSizeInfo:r,parentOpacity:l}=i,{x:a,y:s,w:h,h:c,angle:d}=Wt(t,{viewScaleInfo:n})||t,u=Object.assign(Object.assign({},t),{x:a,y:s,w:h,h:c,angle:d});vt(e,{x:a,y:s,w:h,h:c,angle:d},(()=>{Ai(e,u,{viewScaleInfo:n,renderContent:()=>{xi(e,u,{originElem:t,calcElemSize:{x:a,y:s,w:h,h:c,angle:d},viewScaleInfo:n,viewSizeInfo:r,parentOpacity:l,renderContent:()=>{if(o||i.loader.isDestroyed()||i.loader.load(t,i.elementAssets||{}),"image"===t.type&&o){e.globalAlpha=wi(t)*l;const{x:i,y:r,w:a,h:s,radiusList:h}=$t(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],r),e.arcTo(i+a,r,i+a,r+s,h[1]),e.arcTo(i+a,r+s,i,r+s,h[2]),e.arcTo(i,r+s,i,r,h[3]),e.arcTo(i,r,i+a,r,h[0]),e.closePath(),e.fill("nonzero"),e.clip("nonzero"),d&&g&&f){let n=0,l=0,h=v,c=m;const u=i,f=r,g=a,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,l=(i-t.h)/2/e,h=t.w/e,c=t.h/e}else if("tile"===d)n=0,l=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,l=(m-t.h/e)/2,h=t.w/e,c=t.h/e}e.drawImage(o,n,l,h,c,u,f,g,y)}else e.drawImage(o,i,r,a,s);e.globalAlpha=l,e.restore()}}})}})}))}(e,t,i);break;case"svg":!function(e,t,i){const o=i.loader.getContent(t),{viewScaleInfo:n,parentOpacity:r}=i,{x:l,y:a,w:s,h:h,angle:c}=Wt(t,{viewScaleInfo:n})||t;vt(e,{x:l,y:a,w:s,h:h,angle:c},(()=>{o||i.loader.isDestroyed()||i.loader.load(t,i.elementAssets||{}),"svg"===t.type&&o&&(e.globalAlpha=wi(t)*r,e.drawImage(o,l,a,s,h),e.globalAlpha=r)}))}(e,t,i);break;case"html":!function(e,t,i){const o=i.loader.getContent(t),{viewScaleInfo:n,parentOpacity:r}=i,{x:l,y:a,w:s,h:h,angle:c}=Wt(t,{viewScaleInfo:n})||t;vt(e,{x:l,y:a,w:s,h:h,angle:c},(()=>{o||i.loader.isDestroyed()||i.loader.load(t,i.elementAssets||{}),"html"===t.type&&o&&(e.globalAlpha=wi(t)*r,e.drawImage(o,l,a,s,h),e.globalAlpha=r)}))}(e,t,i);break;case"path":Mi(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:r}=i,{x:l,y:a,w:s,h:h,angle:c}=Wt({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:l,y:a,w:s,h:h,angle:c});vt(e,{x:l,y:a,w:s,h:h,angle:c},(()=>{e.globalAlpha=wi(t)*r,Ai(e,d,{viewScaleInfo:o,renderContent:()=>{xi(e,d,{originElem:t,calcElemSize:{x:l,y:a,w:s,h:h,angle:c},viewScaleInfo:o,viewSizeInfo:n,parentOpacity:r,renderContent:()=>{const{x:n,y:l,w:a,h:s,radiusList:h}=$t(d,{viewScaleInfo:o});if("hidden"===t.detail.overflow&&(e.save(),e.fillStyle="transparent",e.beginPath(),e.moveTo(n+h[0],l),e.arcTo(n+a,l,n+a,l+s,h[1]),e.arcTo(n+a,l+s,n,l+s,h[2]),e.arcTo(n,l+s,n,l,h[3]),e.arcTo(n,l,n+a,l,h[0]),e.closePath(),e.fill("nonzero"),e.clip("nonzero")),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:l}=i;for(let o=0;o<t.detail.children.length;o++){let a=t.detail.children[o];if(a=Object.assign(Object.assign({},a),{x:n.x+a.x,y:n.y+a.y}),!0===i.forceDrawAll||(null==l?void 0:l.needRender(a)))try{zi(e,a,Object.assign(Object.assign({},i),{parentOpacity:r*wi(t)}))}catch(e){console.error(e)}}}"hidden"===t.detail.overflow&&e.restore()}})}}),e.globalAlpha=r}))}(e,t,Object.assign(Object.assign({},i),{elementAssets:o}));break}}}catch(e){console.error(e)}}const Ri={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 Ci(e,t,i){var o;const{elements:n=[]}=t,{parentOpacity:r}=i;for(let t=0;t<n.length;t++){const l=n[t],a=Object.assign(Object.assign({},l),{detail:Object.assign(Object.assign({},Ri),null==l?void 0:l.detail)});if(!0===i.forceDrawAll||(null===(o=i.calculator)||void 0===o?void 0:o.needRender(a)))try{zi(e,a,Object.assign(Object.assign({},i),{parentOpacity:r}))}catch(e){console.error(e)}}}var Ei,Ti,Pi,Li,Oi,ki,Wi,Di,ji,Yi,Ni,Bi,Fi=function(e,t,i,o){return new(i||(i=Promise))((function(n,r){function l(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(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(l,a)}s((o=o.apply(e,t||[])).next())}))},Gi=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)},Vi=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 Xi=["image","svg","html"],Hi=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?Re(n)?n:ze(n,e.uuid):ze(`${Ie()}-${e.uuid}-${Ie()}-${Ie()}`,e.uuid)};class Zi extends tt{constructor(){super(),Ei.add(this),Ti.set(this,{}),Pi.set(this,{}),Li.set(this,{}),Oi.set(this,!1),Gi(this,Ei,"m",ki).call(this,"image",((e,t)=>Fi(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 Oe(o);return{uuid:e.uuid,lastModified:Date.now(),content:n}})))),Gi(this,Ei,"m",ki).call(this,"html",((e,t)=>Fi(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}})))),Gi(this,Ei,"m",ki).call(this,"svg",((e,t)=>Fi(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 ke(o);return{uuid:e.uuid,lastModified:Date.now(),content:n}}))))}isDestroyed(){return Gi(this,Oi,"f")}reset(){!0!==Gi(this,Oi,"f")&&(Vi(this,Pi,{},"f"),Vi(this,Li,{},"f"))}resetElementAsset(e){var t,i,o;if(Xi.includes(e.type)){let n=null,r=null;"image"===e.type&&"string"==typeof(null===(t=null==e?void 0:e.detail)||void 0===t?void 0:t.src)?r=e.detail.src:"svg"===e.type&&"string"==typeof(null===(i=null==e?void 0:e.detail)||void 0===i?void 0:i.svg)?r=e.detail.svg:"html"===e.type&&"string"==typeof(null===(o=null==e?void 0:e.detail)||void 0===o?void 0:o.html)&&(r=e.detail.html),"string"==typeof r&&(this.load(e,{}),Re(r)?n=r:e.uuid&&(n=ze(r,e.uuid))),n&&Re(n)&&(delete Gi(this,Li,"f")[n],delete Gi(this,Pi,"f")[n])}}destroy(){Vi(this,Oi,!0,"f"),this.clear(),Vi(this,Ti,null,"f"),Vi(this,Pi,null,"f"),Vi(this,Li,null,"f")}load(e,t){!0!==Gi(this,Oi,"f")&&(Gi(this,Ei,"m",Bi).call(this,e)||Xi.includes(e.type)&&Gi(this,Ei,"m",Ni).call(this,e,t))}getContent(e){var t,i;const o=Hi(e);return(null===(i=null===(t=Gi(this,Li,"f"))||void 0===t?void 0:t[o])||void 0===i?void 0:i.content)||null}getLoadItemMap(){return Gi(this,Li,"f")}setLoadItemMap(e){Vi(this,Li,e,"f")}}Ti=new WeakMap,Pi=new WeakMap,Li=new WeakMap,Oi=new WeakMap,Ei=new WeakSet,ki=function(e,t){Gi(this,Ti,"f")[e]=t},Wi=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},Di=function(e){return{element:e,status:"null",content:null,error:null,startTime:-1,endTime:-1,source:Gi(this,Ei,"m",Wi).call(this,e)}},ji=function(e){const t=Hi(e.element),i=Gi(this,Li,"f")[t];Gi(this,Oi,"f")||(i?i.startTime<e.startTime&&(Gi(this,Li,"f")[t]=e,this.trigger("load",Object.assign(Object.assign({},e),{countTime:e.endTime-e.startTime}))):(Gi(this,Li,"f")[t]=e,this.trigger("load",Object.assign(Object.assign({},e),{countTime:e.endTime-e.startTime}))))},Yi=function(e){var t;const i=Hi(e.element),o=null===(t=Gi(this,Li,"f"))||void 0===t?void 0:t[i];Gi(this,Oi,"f")||(o?o.startTime<e.startTime&&(Gi(this,Li,"f")[i]=e,this.trigger("error",Object.assign(Object.assign({},e),{countTime:e.endTime-e.startTime}))):(Gi(this,Li,"f")[i]=e,this.trigger("error",Object.assign(Object.assign({},e),{countTime:e.endTime-e.startTime}))))},Ni=function(e,t){const i=Gi(this,Ei,"m",Di).call(this,e),o=Hi(e);if(Gi(this,Pi,"f")[o])return;Gi(this,Pi,"f")[o]=i;const n=Gi(this,Ti,"f")[e.type];"function"!=typeof n||Gi(this,Oi,"f")||(i.startTime=Date.now(),n(e,t).then((e=>{Gi(this,Oi,"f")||(i.content=e.content,i.endTime=Date.now(),i.status="load",Gi(this,Ei,"m",ji).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,Gi(this,Ei,"m",Yi).call(this,i)})))},Bi=function(e){var t;const i=Hi(e),o=null===(t=Gi(this,Pi,"f"))||void 0===t?void 0:t[i];return!(!o||"error"!==o.status||!o.source||o.source!==Gi(this,Ei,"m",Wi).call(this,e))};const Qi={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 Ui(e,t){const{w:i,h:o}=e,n=t.tempContext,r=[],l=Object.assign(Object.assign({},Qi),e.detail),a=l.fontSize||Qi.fontSize,s=a;if(s<2)return{};const h=l.lineHeight||a;n.textBaseline="top",n.$setFont({fontWeight:l.fontWeight,fontSize:s,fontFamily:mi(l.fontFamily)});let c=l.text.replace(/\r\n/gi,"\n");"lowercase"===l.textTransform?c=c.toLowerCase():"uppercase"===l.textTransform&&(c=c.toUpperCase());const d=h,u=c.split("\n");let f=0;u.forEach(((e,t)=>{if("maxContent"===l.minInlineSize)r.push({x:0,y:0,text:e,width:n.$undoPixelRatio(n.measureText(e).width)});else{let h="",c="",g=e.split(c);if("normal"===l.wordBreak){c=" ";const t=e.split(c);g=[],t.forEach(((e,i)=>{g.push(e),i<t.length-1&&g.push(c)}))}if(1===g.length&&"visible"===l.overflow)r.push({x:0,y:0,text:g[0],width:n.$undoPixelRatio(n.measureText(g[0]).width)});else if(g.length>0){for(let e=0;e<g.length&&(a=n.$doPixelRatio(i),s=n.measureText(h+g[e]).width,a>=s?h+=g[e]||"":(r.push({x:0,y:0,text:h,width:n.$undoPixelRatio(n.measureText(h).width)}),h=g[e]||"",f++),!((f+1)*d>o&&"hidden"===l.overflow));e++)if(g.length-1===e&&(f+1)*d<=o){r.push({x:0,y:0,text:h,width:n.$undoPixelRatio(n.measureText(h).width)}),t<u.length-1&&f++;break}}else r.push({x:0,y:0,text:"",width:0})}var a,s}));let g=0,v=0;d>s&&(v=(d-s)/2),r.length*d<o&&("top"===l.verticalAlign?g=0:"bottom"===l.verticalAlign?g+=o-r.length*d:g+=(o-r.length*d)/2);{const e=0+g;r.forEach(((t,o)=>{let n=0;"center"===l.textAlign?n=0+(i-t.width)/2:"right"===l.textAlign&&(n=i-t.width+0),r[o].x=n,r[o].y=e+d*o+v}))}return{textLines:r}}function $i(e,t){let i={};return"text"===e.type&&(i=Ui(e,t)),i}function Ji(e,t){const{viewScaleInfo:i,viewSizeInfo:o,tempContext:n}=t,r=function(e,t){const i={},o=[],n=r=>{const l={type:r.type,isVisibleInView:!0,position:[...o]};let a=null;a=Bt(r,{groupQueue:Rt(e,o)||[]});const s=Object.assign(Object.assign(Object.assign({},l),{originRectInfo:a,rangeRectInfo:He.angle(r.angle)?Ft(a):a}),$i(r,t));i[r.uuid]=s,"group"===r.type&&r.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 Ki(r,{viewScaleInfo:i,viewSizeInfo:o})}function Ki(e,t){const i=function(e){const{viewScaleInfo:t,viewSizeInfo:i}=e,{scale:o,offsetTop:n,offsetLeft:r}=t,{width:l,height:a}=i,s=0-r/o,h=0-n/o,c=l/o,d=a/o,u=mt({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 r=e[t];r.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),r=Math.max(e.topLeft.y,e.topRight.y,e.bottomLeft.y,e.bottomRight.y),l=Math.min(t.topLeft.x,t.topRight.x,t.bottomLeft.x,t.bottomRight.x),a=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<=a&&o>=l&&n<=h&&r>=s||a<=r&&a>=r&&a<=r&&a>=r}(r.rangeRectInfo,i),r.isVisibleInView?o++:n++})),{virtualFlatItemMap:e,visibleCount:o,invisibleCount:n}}var qi,_i,eo=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},to=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 io{constructor(e){qi.set(this,void 0),_i.set(this,void 0),eo(this,qi,e,"f"),eo(this,_i,new ct({defaultStorage:{virtualFlatItemMap:{},visibleCount:0,invisibleCount:0}}),"f")}toGridNum(e,t){return!0===(null==t?void 0:t.ignore)?e:Math.round(e)}destroy(){eo(this,qi,null,"f")}needRender(e){const t=to(this,_i,"f").get("virtualFlatItemMap")[e.uuid];return!t||t.isVisibleInView}getPointElement(e,t){const i=to(this,qi,"f").tempContext;return function(e,t){var i,o,n;const{context2d:r,data:l,viewScaleInfo:a,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,l=0,s=0;for(let e=0;e<=t;e++)n+=h[e].x,l+=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(Yt(e,{context2d:r,element:{x:n+u.x,y:l+u.y,w:u.w,h:u.h,angle:s+(u.angle||0)},viewScaleInfo:a})){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=l.elements.length-1;t>=0;t--){const i=l.elements[t];if(!0!==(null===(n=null==i?void 0:i.operations)||void 0===n?void 0:n.invisible)&&Yt(e,{context2d:r,element:i,viewScaleInfo:a})){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}=Ji(e.elements,Object.assign(Object.assign({},t),{tempContext:to(this,qi,"f").tempContext}));to(this,_i,"f").set("virtualFlatItemMap",i),to(this,_i,"f").set("invisibleCount",o),to(this,_i,"f").set("visibleCount",n)}}updateVisiableStatus(e){const{virtualFlatItemMap:t,invisibleCount:i,visibleCount:o}=Ki(to(this,_i,"f").get("virtualFlatItemMap"),e);to(this,_i,"f").set("virtualFlatItemMap",t),to(this,_i,"f").set("invisibleCount",i),to(this,_i,"f").set("visibleCount",o)}calcViewRectInfoFromOrigin(e,t){const i=to(this,_i,"f").get("virtualFlatItemMap")[e];if(!(null==i?void 0:i.originRectInfo))return null;const{checkVisible:o,viewScaleInfo:n,viewSizeInfo:r}=t,{center:l,left:a,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:Dt(l,v),left:Dt(a,v),right:Dt(s,v),bottom:Dt(h,v),top:Dt(c,v),topLeft:Dt(d,v),topRight:Dt(u,v),bottomLeft:Dt(f,v),bottomRight:Dt(g,v)}}calcViewRectInfoFromRange(e,t){const i=to(this,_i,"f").get("virtualFlatItemMap")[e];if(!(null==i?void 0:i.originRectInfo))return null;const{checkVisible:o,viewScaleInfo:n,viewSizeInfo:r}=t,{center:l,left:a,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:Dt(l,v),left:Dt(a,v),right:Dt(s,v),bottom:Dt(h,v),top:Dt(c,v),topLeft:Dt(d,v),topRight:Dt(u,v),bottomLeft:Dt(f,v),bottomRight:Dt(g,v)}}modifyText(e){const t=to(this,_i,"f").get("virtualFlatItemMap"),i=t[e.uuid];if(e&&"text"===e.type){const o=Object.assign(Object.assign({},i),Ui(e,{tempContext:to(this,qi,"f").tempContext}));t[e.uuid]=o,to(this,_i,"f").set("virtualFlatItemMap",t)}}modifyVirtualFlatItemMap(e,t){const{modifyInfo:i,viewScaleInfo:o,viewSizeInfo:n}=t,{type:r,content:l}=i,a=e.elements,s=to(this,_i,"f").get("virtualFlatItemMap");if("deleteElement"===r){const{element:e}=l,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]})),to(this,_i,"f").set("virtualFlatItemMap",s)}else if("addElement"===r||"updateElement"===r){const{position:t}=l,i=Et(t,e.elements),h=Rt(a,t);if(i)if("updateElement"===r&&"group"===i.type)this.resetVirtualFlatItemMap(e,{viewScaleInfo:o,viewSizeInfo:n});else{const e=Bt(i,{groupQueue:h||[]}),l=Object.assign({type:i.type,originRectInfo:e,rangeRectInfo:He.angle(i.angle)?Ft(e):e,isVisibleInView:!0,position:[...t]},$i(i,{tempContext:to(this,qi,"f").tempContext}));s[i.uuid]=l,to(this,_i,"f").set("virtualFlatItemMap",s),"updateElement"===r&&this.updateVisiableStatus({viewScaleInfo:o,viewSizeInfo:n})}}else"moveElement"===r&&this.resetVirtualFlatItemMap(e,{viewScaleInfo:o,viewSizeInfo:n})}getVirtualFlatItem(e){return to(this,_i,"f").get("virtualFlatItemMap")[e]||null}}qi=new WeakMap,_i=new WeakMap;var oo,no,ro,lo,ao,so,ho=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},co=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 uo extends tt{constructor(e){super(),oo.add(this),no.set(this,void 0),ro.set(this,new Zi),lo.set(this,void 0),ao.set(this,!1),ho(this,no,e,"f"),ho(this,lo,new io({tempContext:e.tempContext}),"f"),co(this,oo,"m",so).call(this)}isDestroyed(){return co(this,ao,"f")}destroy(){this.clear(),ho(this,no,null,"f"),co(this,ro,"f").destroy(),ho(this,ro,null,"f"),ho(this,ao,!0,"f")}updateOptions(e){ho(this,no,e,"f")}drawData(e,t){const i=co(this,ro,"f"),o=co(this,lo,"f"),{sharer:n}=co(this,no,"f"),r=co(this,no,"f").viewContext;r.clearRect(0,0,r.canvas.width,r.canvas.height);const l={x:0,y:0,w:t.viewSizeInfo.width,h:t.viewSizeInfo.height};!0===t.forceDrawAll&&co(this,lo,"f").resetVirtualFlatItemMap(e,{viewScaleInfo:t.viewScaleInfo,viewSizeInfo:t.viewSizeInfo});const a=Object.assign({loader:i,calculator:o,parentElementSize:l,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:r}=o;e.globalAlpha=1,e.fillStyle=t.background,e.fillRect(0,0,n,r)}}(r,e.global,a),e.layout?function(e,t,i,o){const{viewScaleInfo:n,viewSizeInfo:r,parentOpacity:l}=i,a=Object.assign({uuid:"layout",type:"group"},t),{x:s,y:h,w:c,h:d}=Wt(a,{viewScaleInfo:n})||a,u=Object.assign(Object.assign({},a),{x:s,y:h,w:c,h:d,angle:0});if(e.globalAlpha=1,Ai(e,u,{viewScaleInfo:n,renderContent:()=>{Si(e,u,{viewScaleInfo:n,viewSizeInfo:r})}}),"hidden"===t.detail.overflow){const{viewScaleInfo:o,viewSizeInfo:n}=i,r=Object.assign({uuid:"layout",type:"group"},t),l=Wt(r,{viewScaleInfo:o})||r,a=Object.assign(Object.assign({},r),l),{x:s,y:h,w:c,h:d,radiusList:u}=$t(a,{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("nonzero"),e.clip("nonzero")}o(e),"hidden"===t.detail.overflow&&e.restore(),bi(e,u,{viewScaleInfo:n}),e.globalAlpha=l}(r,e.layout,a,(()=>{Ci(r,e,a)})):Ci(r,e,a)}scale(e){const{sharer:t}=co(this,no,"f");if(!t)return;const{data:i,offsetTop:o,offsetBottom:n,offsetLeft:r,offsetRight:l,width:a,height:s,contextHeight:h,contextWidth:c,devicePixelRatio:d}=t.getActiveStoreSnapshot();i&&this.drawData(i,{viewScaleInfo:{scale:e,offsetTop:o,offsetBottom:n,offsetLeft:r,offsetRight:l},viewSizeInfo:{width:a,height:s,contextHeight:h,contextWidth:c,devicePixelRatio:d}})}setLoadItemMap(e){co(this,ro,"f").setLoadItemMap(e)}getLoadItemMap(){return co(this,ro,"f").getLoadItemMap()}getLoader(){return co(this,ro,"f")}getCalculator(){return co(this,lo,"f")}}function fo(e){return e>0||e<0||0===e}no=new WeakMap,ro=new WeakMap,lo=new WeakMap,ao=new WeakMap,oo=new WeakSet,so=function(){const e=co(this,ro,"f");e.on("load",(e=>{this.trigger("load",e)})),e.on("error",(e=>{console.error(e)}))};class go extends tt{constructor(e){super(),we(this,n),we(this,t),we(this,i),we(this,o,!1),we(this,l,(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,a,(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(),r=pe(this,i).get("prevClickPoint");r&&o-r.t<=500&&Math.abs(r.x-t.x)<=5&&Math.abs(r.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 ct({defaultStorage:{hasPointDown:!1,prevClickPoint:null,inCanvas:!0}});xe(this,i,y),xe(this,t,e),Se(this,n,r).call(this)}onEvents(){if(!0===pe(this,t).disabled)return;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,l),{passive:!1}),i.addEventListener("click",pe(this,s)),i.addEventListener("contextmenu",pe(this,a))}offEvents(){if(!0===pe(this,t).disabled)return;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,l)),e.removeEventListener("click",pe(this,s)),e.removeEventListener("contextmenu",pe(this,a))}destroy(){this.offEvents(),pe(this,i).destroy(),xe(this,o,!0)}}t=new WeakMap,i=new WeakMap,o=new WeakMap,n=new WeakSet,r=function(){this.onEvents()},l=new WeakMap,a=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!!(fo(e.x)&&fo(e.y)&&e.x<=o&&e.y<=n)};const vo={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 mo{constructor(){we(this,y),we(this,p);const e=new ct({defaultStorage:vo}),t=new ct({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:r}=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",r)}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:yo}=window;class po extends tt{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:r,moveY:l}=function(e){const{scale:t,point:i,viewScaleInfo:o}=e,{offsetLeft:n,offsetTop:r}=o,l=t/o.scale,a=i.x,s=i.y;return{moveX:a-a*l+(n*l-n),moveY:s-s*l+(r*l-r)}}({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:r,moveY:l}}scroll(e){const{sharer:t}=pe(this,w),i=t.getActiveViewScaleInfo(),{moveX:o,moveY:n,ignoreUpdateVisibleStatus:r}=e,l=function(e){const{moveX:t=0,moveY:i=0,viewScaleInfo:o,viewSizeInfo:n}=e,{scale:r}=o,{width:l,height:a,contextWidth:s,contextHeight:h}=n;let c=o.offsetLeft,d=o.offsetRight,u=o.offsetTop,f=o.offsetBottom;return c+=t,u+=i,d=l-(s*r+c),f=a-(h*r+u),{scale:r,offsetTop:u,offsetLeft:c,offsetRight:d,offsetBottom:f}}({moveX:o,moveY:n,viewScaleInfo:i,viewSizeInfo:t.getActiveViewSizeInfo()});return t.setActiveViewScaleInfo(l),r||pe(this,w).calculator.updateVisiableStatus({viewScaleInfo:t.getActiveViewScaleInfo(),viewSizeInfo:t.getActiveViewSizeInfo()}),l}updateViewScaleInfo(e){const{sharer:t}=pe(this,w),i=function(e,t){const{scale:i,offsetX:o,offsetY:n}=e,{viewSizeInfo:r}=t,{width:l,height:a,contextWidth:s,contextHeight:h}=r,c=0-o*i,d=0-n*i;return{scale:i,offsetLeft:c,offsetTop:d,offsetRight:l-(s*i+c/i),offsetBottom:a-(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:r,devicePixelRatio:l}=o,{underlayContext:a,boardContext:s,overlayContext:h,viewContext:c}=pe(this,w).boardContent;return s.canvas.width=n*l,s.canvas.height=r*l,s.canvas.style.width=`${n}px`,s.canvas.style.height=`${r}px`,a.canvas.width=n*l,a.canvas.height=r*l,h.canvas.width=n*l,h.canvas.height=r*l,c.canvas.width=n*l,c.canvas.height=r*l,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:r,offsetTop:l,offsetBottom:a,offsetLeft:s,offsetRight:h,width:c,height:d,contextHeight:u,contextWidth:f,devicePixelRatio:g}=e.activeStore,v={scale:r,offsetTop:l,offsetBottom:a,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?"DRAWING"===pe(this,S)&&yo((()=>{Se(this,b,I).call(this)})):xe(this,S,"COMPLETE")};class wo{constructor(e){we(this,W),we(this,M),we(this,z,new Map),we(this,R,[]),we(this,C),we(this,E),we(this,T),we(this,P),we(this,L),we(this,O,new tt),we(this,k,!1);const{boardContent:t}=e,i=new mo,o=new go({boardContent:t,sharer:i,disabled:null==e?void 0:e.disableWatcher}),n=new uo({viewContext:t.viewContext,tempContext:t.tempContext,sharer:i}),r=n.getCalculator();xe(this,M,e),xe(this,T,i),xe(this,C,o),xe(this,E,n),xe(this,L,r),xe(this,P,new po({boardContent:e.boardContent,sharer:i,renderer:n,calculator:pe(this,L),beforeDrawFrame:e=>{Se(this,W,J).call(this,e)},afterDrawFrame:e=>{Se(this,W,K).call(this,e)}})),Se(this,W,D).call(this),Se(this,W,q).call(this)}isDestroyed(){return pe(this,k)}destroy(){pe(this,C).destroy(),pe(this,E).destroy(),pe(this,L).destroy(),pe(this,O).destroy(),xe(this,k,!0)}getSharer(){return pe(this,T)}getViewer(){return pe(this,P)}getRenderer(){return pe(this,E)}setData(e){const t=pe(this,T);pe(this,T).setActiveStorage("data",e);const i=t.getActiveViewSizeInfo(),o=t.getActiveViewScaleInfo(),n=zt(e.elements,{viewWidth:i.width,viewHeight:i.height,extend:!0});pe(this,P).resetVirtualFlatItemMap(e,{viewSizeInfo:i,viewScaleInfo:o}),pe(this,P).drawFrame();const r={...i,...n};return pe(this,T).setActiveViewSizeInfo(r),{viewSizeInfo:r}}getData(){const{data:e}=pe(this,T).getActiveStoreSnapshot();return e}use(e,t){var i,o,n;if(pe(this,z).has(e)){const t=pe(this,z).get(e);return void(t&&"enable"!==t.status&&(t.status="enable",null==(o=(i=t.middlewareObject).use)||o.call(i),Se(this,W,q).call(this)))}const{boardContent:r,container:l}=pe(this,M),a=e({boardContent:r,sharer:pe(this,T),viewer:pe(this,P),calculator:pe(this,L),eventHub:pe(this,O),container:l},t);null==(n=a.use)||n.call(a),pe(this,z).set(e,{status:"enable",middlewareObject:a,config:t}),Se(this,W,q).call(this)}disuse(e){var t,i;if(pe(this,z).has(e)){const o=pe(this,z).get(e);o&&(null==(i=(t=o.middlewareObject).disuse)||i.call(t),o.status="disable"),pe(this,z).delete(e),Se(this,W,q).call(this)}}resetMiddlewareConfig(e,t){var i,o;if(pe(this,z).has(e)){const n=pe(this,z).get(e);n&&(null==(o=(i=n.middlewareObject).resetConfig)||o.call(i,t))}}scale(e){const t=pe(this,P),{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,P).scroll(e)}updateViewScaleInfo(e){return pe(this,P).updateViewScaleInfo(e)}resize(e,t){const i=pe(this,P).resize(e,t),{width:o,height:n,devicePixelRatio:r}=e,{boardContent:l}=pe(this,M);l.viewContext.$resize({width:o,height:n,devicePixelRatio:r}),l.overlayContext.$resize({width:o,height:n,devicePixelRatio:r}),l.boardContext.$resize({width:o,height:n,devicePixelRatio:r}),l.underlayContext.$resize({width:o,height:n,devicePixelRatio:r}),pe(this,P).drawFrame(),pe(this,C).trigger("resize",i),pe(this,T).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,W,$).call(this)}getEventHub(){return pe(this,O)}onWatcherEvents(){!0!==pe(this,M).disableWatcher&&pe(this,C).onEvents()}offWatcherEvents(){!0!==pe(this,M).disableWatcher&&pe(this,C).offEvents()}}M=new WeakMap,z=new WeakMap,R=new WeakMap,C=new WeakMap,E=new WeakMap,T=new WeakMap,P=new WeakMap,L=new WeakMap,O=new WeakMap,k=new WeakMap,W=new WeakSet,D=function(){!0!==pe(this,M).disableWatcher&&(pe(this,C).on("pointStart",Se(this,W,j).bind(this)),pe(this,C).on("pointEnd",Se(this,W,Y).bind(this)),pe(this,C).on("pointMove",Se(this,W,N).bind(this)),pe(this,C).on("pointLeave",Se(this,W,B).bind(this)),pe(this,C).on("hover",Se(this,W,F).bind(this)),pe(this,C).on("wheel",Se(this,W,X).bind(this)),pe(this,C).on("wheelScale",Se(this,W,H).bind(this)),pe(this,C).on("scrollX",Se(this,W,Z).bind(this)),pe(this,C).on("scrollY",Se(this,W,Q).bind(this)),pe(this,C).on("resize",Se(this,W,U).bind(this)),pe(this,C).on("doubleClick",Se(this,W,G).bind(this)),pe(this,C).on("contextMenu",Se(this,W,V).bind(this))),pe(this,E).on("load",(()=>{pe(this,O).trigger("loadResource")}))},j=function(e){var t;for(let i=0;i<pe(this,R).length;i++){const o=pe(this,R)[i];if(!1===(null==(t=null==o?void 0:o.pointStart)?void 0:t.call(o,e)))return}},Y=function(e){var t;for(let i=0;i<pe(this,R).length;i++){const o=pe(this,R)[i];if(!1===(null==(t=null==o?void 0:o.pointEnd)?void 0:t.call(o,e)))return}},N=function(e){var t;for(let i=0;i<pe(this,R).length;i++){const o=pe(this,R)[i];if(!1===(null==(t=null==o?void 0:o.pointMove)?void 0:t.call(o,e)))return}},B=function(e){var t;for(let i=0;i<pe(this,R).length;i++){const o=pe(this,R)[i];if(!1===(null==(t=null==o?void 0:o.pointLeave)?void 0:t.call(o,e)))return}},F=function(e){var t;for(let i=0;i<pe(this,R).length;i++){const o=pe(this,R)[i];if(!1===(null==(t=null==o?void 0:o.hover)?void 0:t.call(o,e)))return}},G=function(e){var t;for(let i=0;i<pe(this,R).length;i++){const o=pe(this,R)[i];if(!1===(null==(t=null==o?void 0:o.doubleClick)?void 0:t.call(o,e)))return}},V=function(e){var t;for(let i=0;i<pe(this,R).length;i++){const o=pe(this,R)[i];if(!1===(null==(t=null==o?void 0:o.contextMenu)?void 0:t.call(o,e)))return}},X=function(e){var t;for(let i=0;i<pe(this,R).length;i++){const o=pe(this,R)[i];if(!1===(null==(t=null==o?void 0:o.wheel)?void 0:t.call(o,e)))return}},H=function(e){var t;for(let i=0;i<pe(this,R).length;i++){const o=pe(this,R)[i];if(!1===(null==(t=null==o?void 0:o.wheelScale)?void 0:t.call(o,e)))return}},Z=function(e){var t;for(let i=0;i<pe(this,R).length;i++){const o=pe(this,R)[i];if(!1===(null==(t=null==o?void 0:o.scrollX)?void 0:t.call(o,e)))return}},Q=function(e){var t;for(let i=0;i<pe(this,R).length;i++){const o=pe(this,R)[i];if(!1===(null==(t=null==o?void 0:o.scrollY)?void 0:t.call(o,e)))return}},U=function(e){var t;for(let i=0;i<pe(this,R).length;i++){const o=pe(this,R)[i];if(!1===(null==(t=null==o?void 0:o.resize)?void 0:t.call(o,e)))return}},$=function(e){var t;for(let i=0;i<pe(this,R).length;i++){const o=pe(this,R)[i];if(!1===(null==(t=null==o?void 0:o.clear)?void 0:t.call(o,e)))return}},J=function(e){var t;for(let i=0;i<pe(this,R).length;i++){const o=pe(this,R)[i];if(!1===(null==(t=null==o?void 0:o.beforeDrawFrame)?void 0:t.call(o,e)))return}},K=function(e){var t;for(let i=0;i<pe(this,R).length;i++){const o=pe(this,R)[i];if(!1===(null==(t=null==o?void 0:o.afterDrawFrame)?void 0:t.call(o,e)))return}},q=function(){const e=[];for(const[t,i]of pe(this,z))"enable"===(null==i?void 0:i.status)&&(null==i?void 0:i.middlewareObject)&&e.push(i.middlewareObject);xe(this,R,e)};const xo="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAApCAYAAABHomvIAAAACXBIWXMAAAsTAAALEwEAmpwYAAAF92lUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQiPz4gPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iQWRvYmUgWE1QIENvcmUgNi4wLWMwMDYgNzkuMTY0NzUzLCAyMDIxLzAyLzE1LTExOjUyOjEzICAgICAgICAiPiA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPiA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtbG5zOmRjPSJodHRwOi8vcHVybC5vcmcvZGMvZWxlbWVudHMvMS4xLyIgeG1sbnM6cGhvdG9zaG9wPSJodHRwOi8vbnMuYWRvYmUuY29tL3Bob3Rvc2hvcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RFdnQ9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZUV2ZW50IyIgeG1wOkNyZWF0b3JUb29sPSJBZG9iZSBQaG90b3Nob3AgMjIuMyAo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ry8POnWyePx6H4JR0vhktVkHGOXQI20SkpKLLcOhmGsA5YCaZiVLS5XoADi9XpdkznDMERhnE0fCgUHZhvOW+CO4/8A5hR7wFxjD5hr7AFzjZyBlmVlrOYdYaS1HUUuQA/gWV9fd51URDyqn1c1j6MVFGjoidfW1oq2ABrYj0V82OmVzwHNajVdB88C5wOKTdM87NaxsrKyQsFKHC2BnTDo+/TWt8Bd5INeVC44NDT0xXYZdXNz8w/AaeyS8yjwCPdzQu92ht2m/OUjIyOfS1pkAoqItLS0fA+8D7wKPA0cxs6qC1O4T0xMfKYnb21tnXEDNjc3z+nXbW1t3wFvYz9dCAL7KUThHovFPtGTNjU1jQFSX18/lg68cuXKLUAaGxs3vkB7e/u3wHHgCQpUdnpTqdQvesJgMDisUVevXh3Xry9fvnxTv66qqprQ/cfHx/vVNj/J/couv0DAv7q6+pMDeYPNSalkwkUikX7s4ukl4FHgAODPN1CXnPsWFxd/dCAjW+GGhoZCwAfYpeczwMPAPjVW3gv3IvXN98disZ8dyBGNCwQC4/r94eHhfuy6+JS6zATUCeJXY+W9cNfIUuDAwsLCr05kIBDYeBQ8Ojr6h8Lpx25BtbWlGpfv62BG5PLy8m+SFpOTk38C76mVe84NVyhgOvLgysrK7xoXjUb/Uqt2XG1rEDiYCbcd0MgwsWtk+J1EI03An0wmw5Zlefx+/2n1eRKIO5r+rWTTpFsZ/gWFrGMmeObuqwAAAABJRU5ErkJggg==",So="selectInGroup",bo={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:So,SNAP_TO_GRID:So},Ao={};Object.keys(bo).forEach((e=>{Object.defineProperty(Ao,e,{value:bo[e],writable:!1})}));class Io{constructor(e,t){we(this,ne),we(this,_),we(this,ee),we(this,te,null),we(this,ie,null),we(this,oe,{auto:"data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6ODhUVFWUt7Js2bdLAwMBYLdAt6VNJlyV9IumLsRkOHjyo2tparVixQrdvp2Xmn00YrJI0R05VBRV+GjAiqcoUxA8lnfI1HD16dJz6WLVqla5fvz4tFdPZ2anm5uas8s3Nzf7zp5J+LmmNpFcl5U8GmCupWFKtpO9K+qWkG76W3bt3j4OMRqNqaWnRhQsXNDQ0lAWVTCZ169YtHThwQFVVVePKtrS0+Kw3pgsYso+Vkuol7ZD0W0ldvsHW1tZJZXxtba0aGxvV1NSkdevWaenSpYpGoxPmXb9+vXp6ejzgx5J+ZiGeLSk8GaD34ky5Hd23JP1I0h8kPQmGu7y8/L/aNEUiEe3fv1/Dw8Pp6Es6KqlZ0puSXpHbVU4KiPVglqQFkr4j6aeSfi/pvq/13r172rVrlyorK6cFFo1GtXnzZl25ciU4Ch5J+qOkH0v6tqTXzDk5EwGGlNFjOWQOd8px4vUN4E3cpn2pz/jgwQPef/99Ll68yJ07d+jt7WVwcJBIJEJJSQlz586loaGBTZs2UVdXF5w0OoDLwFWcbPsct6r04+bRLHEYCoWyAD1kBDfHleHmsxrccccS3NFHNV/eenBy6iZwCycMOnHz5wBuDh2nyyY6H0zhFmoF7vtxk+l9q3ieQfrDo8msF7cy3cN56g7ZWnKcep7IxnrQmz+wHKu2K3EKJWbPpWSUTQ4ZtRJc23sC6ZGB9ZM52JwcboIQjzUvZvNxYfeHlyVkZFcBbux6wKA6ShjoM5yM8uH0Xpuy8ekAQuZc2W8P8nEei9p9mMmPgAfJHO0O27e0lHppw9MEDJo//A4eoE91iB48SJ80lFMB/t/+V/sPGZfTmtMFR4EAAAAASUVORK5CYII="}),xe(this,ee,e),xe(this,_,t.eventHub),Se(this,ne,re).call(this),Se(this,ne,le).call(this)}}function Mo(e){const{modifiedElement:t,beforeElement:i}=e,{uuid:o,...n}=t,r=qt(n);let l={};Object.keys(r).forEach((e=>{let t=ii(i,e);void 0===t&&/(borderRadius|borderWidth)\[[0-9]{1,}\]$/.test(e)&&(e=e.replace(/\[[0-9]{1,}\]$/,""),t=ii(i,e)),l[e]=t})),l=qt(l);return{type:"modifyElement",time:Date.now(),content:{method:"modifyElement",uuid:o,before:l,after:r}}}_=new WeakMap,ee=new WeakMap,te=new WeakMap,ie=new WeakMap,oe=new WeakMap,ne=new WeakSet,re=function(){const e=pe(this,_);Se(this,ne,ae).call(this,"default"),e.on(Ao.CURSOR,(e=>{var t;"over-element"!==e.type&&e.type?"resize-rotate"===e.type?Se(this,ne,ae).call(this,"rotate"):"string"==typeof e.type&&(null==(t=e.type)?void 0:t.startsWith("resize-"))?Se(this,ne,se).call(this,e):"drag-default"===e.type?Se(this,ne,ae).call(this,"drag-default"):"drag-active"===e.type?Se(this,ne,ae).call(this,"drag-active"):Se(this,ne,ae).call(this,"auto"):Se(this,ne,ae).call(this,"auto")}))},le=function(){Oe(xo).then((e=>{xe(this,ie,e)})).catch((e=>{console.error(e)}))},ae=function(e){if(pe(this,te)===e)return;xe(this,te,e);const t=pe(this,oe)[pe(this,te)]||pe(this,oe).auto;let i=0,o=0;(e.startsWith("rotate-")&&pe(this,oe)[pe(this,te)]||"rotate"===e)&&(i=10,o=10),pe(this,ee).style.cursor="default"===e?"default":`image-set(url(${t})2x) ${i} ${o}, auto`},se=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+=It((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+=It(e.angle||0)})),i=It(i);const o=Se(this,ne,he).call(this,i);Se(this,ne,ae).call(this,o)},he=function(e){const t=`rotate-${e}`;if(!pe(this,oe)[t]){const i=pe(this,ie);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 a=o.getContext("2d"),s=ft(e);a.translate(l.x,l.y),a.rotate(s),a.translate(-l.x,-l.y),a.drawImage(i,0,0,n,r),a.translate(l.x,l.y),a.rotate(-s),a.translate(-l.x,-l.y);const h=o.toDataURL("image/png");pe(this,oe)[t]=h}}return t};const zo="SELECT",Ro=Symbol(`${zo}_actionType`),Co=Symbol(`${zo}_resizeType`),Eo=Symbol(`${zo}_areaStart`),To=Symbol(`${zo}_areaEnd`),Po=Symbol(`${zo}_hoverElement`),Lo=Symbol(`${zo}_hoverElementVertexes`),Oo=Symbol(`${zo}_selectedElementList`),ko=Symbol(`${zo}_selectedElementListVertexes`),Wo=Symbol(`${zo}_selectedElementController`),Do=Symbol(`${zo}_selectedElementPosition`),jo=Symbol(`${zo}_groupQueue`),Yo=Symbol(`${zo}_groupQueueVertexesList`),No=Symbol(`${zo}_isMoving`),Bo=Symbol(`${zo}_enableSelectInGroup`),Fo=Symbol(`${zo}_enableSnapToGrid`),Go={activeColor:"#1973ba",activeAreaColor:"#1976d21c",lockedColor:"#5b5959b5",referenceColor:"#f7276e"};function Vo(e,t,i){const{borderColor:o,borderWidth:n,background:r,lineDash:l}=i;e.setLineDash([]),e.lineWidth=n,e.strokeStyle=o,e.fillStyle=r,e.setLineDash(l),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("nonzero")}function Xo(e,t,i,o){const{borderColor:n,borderWidth:r,lineDash:l}=o;e.setLineDash([]),e.lineWidth=r,e.strokeStyle=n,e.setLineDash(l),e.beginPath(),e.moveTo(t.x,t.y),e.lineTo(i.x,i.y),e.closePath(),e.stroke()}function Ho(e,t,i){const{borderColor:o,borderWidth:n,lineDash:r}=i;e.setLineDash([]),e.lineWidth=n,e.strokeStyle=o,e.setLineDash(r),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:r,lineDash:l}=i,a=t.x-o/2,s=t.x+o/2,h=t.y-o/2,c=t.y+o/2;Ho(e,[{x:a,y:h},{x:s,y:h},{x:s,y:c},{x:a,y:c}],{borderColor:n,borderWidth:r,lineDash:l})}function Qo(e,t,i){if(!t)return;const{style:o}=i,{activeColor:n}=o,r={borderColor:n,borderWidth:1,background:"transparent",lineDash:[]};Vo(e,jt(t,i),r)}function Uo(e,t,i){if(!t)return;const{style:o}=i,{lockedColor:n}=o,r={borderColor:n,borderWidth:1,background:"transparent",lineDash:[]};Vo(e,jt(t,i),r);const{controller:l}=i;if(l){const{topLeft:t,topRight:o,bottomLeft:n,bottomRight:a,topMiddle:s,bottomMiddle:h,leftMiddle:c,rightMiddle:d}=l,u={...r,borderWidth:1};Ho(e,jt(s.vertexes,i),u),Ho(e,jt(h.vertexes,i),u),Ho(e,jt(c.vertexes,i),u),Ho(e,jt(d.vertexes,i),u),Ho(e,jt(t.vertexes,i),u),Ho(e,jt(o.vertexes,i),u),Ho(e,jt(n.vertexes,i),u),Ho(e,jt(a.vertexes,i),u)}}function $o(e,t,i){var o;if(!t)return;const{hideControllers:n,style:r,rotateControllerPattern:l,viewSizeInfo:a,element:s}=i,{devicePixelRatio:h=1}=a,{activeColor:c}=r,{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(Vo(e,jt(d,i),y),!n&&(Vo(e,jt(u.vertexes,i),p),Vo(e,jt(f.vertexes,i),p),Vo(e,jt(g.vertexes,i),p),Vo(e,jt(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,r=t,l=o/2,a=l,s=l;a>=0&&s>=0&&(e.beginPath(),e.fillStyle=n,e.circle(r.x,r.y,a,s,0,0,2*Math.PI),e.closePath(),e.fill("nonzero"))}(e,Dt(m.center,i),{...p,size:m.size});const t=Dt(m.center,i);e.drawImage(l.canvas,0,0,l.canvas.width/h,l.canvas.height/h,t.x-m.size/2,t.y-m.size/2,m.size,m.size)}}function Jo(e,t){const{xLines:i,yLines:o,style:n}=t,{referenceColor:r}=n,l={borderColor:r,borderWidth:1,lineDash:[]},a={...l,size:6};i&&i.forEach((t=>{t.forEach(((i,o)=>{Zo(e,i,a),t[o+1]&&Xo(e,t[o],t[o+1],l)}))})),o&&o.forEach((t=>{t.forEach(((i,o)=>{Zo(e,i,a),t[o+1]&&Xo(e,t[o],t[o+1],l)}))}))}function Ko(e){return e*Math.PI/180}function qo(e,t){return Math.sqrt(e*e+t*t)}function _o(e,t){return t>0?Math.abs(e):0-Math.abs(e)}function en(e,t){const{ctx:i,viewScaleInfo:o,vertexes:n}=t,r=Dt(n[0],{viewScaleInfo:o}),l=Dt(n[1],{viewScaleInfo:o}),a=Dt(n[2],{viewScaleInfo:o}),s=Dt(n[3],{viewScaleInfo:o});return i.beginPath(),i.moveTo(r.x,r.y),i.lineTo(l.x,l.y),i.lineTo(a.x,a.y),i.lineTo(s.x,s.y),i.lineTo(r.x,r.y),i.closePath(),!!i.isPointInPath(e.x,e.y)}function tn(e,t){const{ctx:i,viewScaleInfo:o,viewSizeInfo:n,groupQueue:r}=t;if(!(r&&(null==r?void 0:r.length)>0))return!1;const l=Ot(r),a=l[l.length-1];return!!a&&en(e,{ctx:i,vertexes:a,viewScaleInfo:o})}function on(e,t){var i,o,n,r,l;const a={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:r,bottom:l,topLeft:h,topRight:c,bottomLeft:f,bottomRight:g,rotate:y}=m,p=[t,n,r,l,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(en(e,{ctx:s,vertexes:i.vertexes,viewScaleInfo:u})){if(a.type=`resize-${i.type}`,d&&(null==d?void 0:d.length)>0)return a.groupQueue=v||[],a.elements=[d[0]],a;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==(r=null==t?void 0:t.detail)?void 0:r.children))for(let i=t.detail.children.length-1;i>=0;i--){const o=t.detail.children[i],n=kt(o,{groupQueue:v});if(n&&en(e,{ctx:s,vertexes:n,viewScaleInfo:u}))return a.type||(a.type="over-element"),a.groupQueue=v,a.elements=[o],a}return a}if(null!==a.type)return a;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 a.type="list-area",a.elements=d,a}if(h){const{index:t,element:i}=c.getPointElement(e,{data:h,viewScaleInfo:u,viewSizeInfo:f});if(t>=0&&i&&!0!==(null==(l=null==i?void 0:i.operations)?void 0:l.invisible))return a.elements=[i],a.type="over-element",a}return a}function nn(e,t){const{x:i,y:o,w:n,h:r,angle:l=0}=e,{center:a,start:s,end:h,viewScaleInfo:c}=t,d=Dt(a,{viewScaleInfo:c}),u=It(l),f=function(e,t,i){const o=pt(e,t),n=pt(e,i);return null!==n&&null!==o?n-o:0}(d,s,h);return{x:i,y:o,w:n,h:r,angle:It(u+f/Math.PI*180)}}function rn(e,t){var i;if(!Array.isArray(e))return null;const o={x:0,y:0,w:0,h:0},{viewScaleInfo:n}=t;let r=null;for(let t=0;t<e.length;t++){const l=e[t];if(null==(i=null==l?void 0:l.operations)?void 0:i.invisible)continue;const a=Wt(l,{viewScaleInfo:n});if(a.angle&&(a.angle>0||a.angle<0)){const e=bt(a);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];a.x=Math.min(...t),a.y=Math.min(...i),a.w=Math.abs(Math.max(...t)-Math.min(...t)),a.h=Math.abs(Math.max(...i)-Math.min(...i))}}if(r){const e=Math.min(a.x,o.x),t=Math.min(a.y,o.y),i=Math.max(a.x+a.w,o.x+o.w),n=Math.max(a.y+a.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=a.x,o.y=a.y,o.w=a.w,o.h=a.h;r=a}return o}function ln(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 an=(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]},sn=(e,t)=>Math.abs(e-t)<1e-5;function hn(e,t){var i,o;const{data:n,groupQueue:r,calculator:l,viewScaleInfo:a,viewSizeInfo:s}=t;let h=n.elements||[];(null==r?void 0:r.length)>0&&(h=(null==(o=null==(i=r[r.length-1])?void 0:i.detail)?void 0:o.children)||[]);const c=[];h.forEach((t=>{if(t.uuid!==e){const e=l.calcViewRectInfoFromRange(t.uuid,{checkVisible:!0,viewScaleInfo:a,viewSizeInfo:s});e&&c.push(e)}}));const d=l.calcViewRectInfoFromRange(e,{viewScaleInfo:a,viewSizeInfo:s});if(!d)return null;const u={},f={},g=[],v=[];let m=[],y=[];const p=ln(d);c.forEach((e=>{const t=ln(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,z=null;if(m.length>0){S=an(m,p.minX),b=an(m,p.midX),A=an(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/a.scale&&(sn(o,e)?w=S-p.minX:sn(o,t)?w=b-p.midX:sn(o,i)&&(w=A-p.maxX))}if(y.length>0){I=an(y,p.minY),M=an(y,p.midY),z=an(y,p.maxY);const e=Math.abs(I-p.minY),t=Math.abs(M-p.midY),i=Math.abs(z-p.maxY),o=Math.min(e,t,i);o<=2/a.scale&&(sn(o,e)?x=I-p.minY:sn(o,t)?x=M-p.midY:sn(o,i)&&(x=z-p.maxY))}const R={...p};if(null!==w&&(R.minX+=w,R.midX+=w,R.maxX+=w),null!==x&&(R.minY+=x,R.midY+=x,R.maxY+=x),He.x(w)&&null!==w&&null!==S&&null!==b&&null!==A){if(sn(w,S-p.minX)){const e={x:S,yList:[]};e.yList.push(R.minY),e.yList.push(R.maxY),e.yList.push(...(null==f?void 0:f[S])||[]),g.push(e)}if(sn(w,b-p.minX)){const e={x:b,yList:[]};e.yList.push(R.minY),e.yList.push(R.maxY),e.yList.push(...(null==f?void 0:f[b])||[]),g.push(e)}if(sn(w,A-p.minX)){const e={x:A,yList:[]};e.yList.push(R.minY),e.yList.push(R.maxY),e.yList.push(...(null==f?void 0:f[A])||[]),g.push(e)}}if(He.y(x)&&null!==x&&null!==I&&null!==M&&null!==z){if(sn(x,I-p.minY)){const e={y:I,xList:[]};e.xList.push(R.minX),e.xList.push(R.maxX),e.xList.push(...(null==u?void 0:u[I])||[]),v.push(e)}if(sn(x,M-p.midY)){const e={y:M,xList:[]};e.xList.push(R.minX),e.xList.push(R.maxX),e.xList.push(...(null==u?void 0:u[I])||[]),v.push(e)}if(sn(x,z-p.maxY)){const e={y:z,xList:[]};e.xList.push(R.minX),e.xList.push(R.maxX),e.xList.push(...(null==u?void 0:u[z])||[]),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 E=[];return(null==v?void 0:v.length)>0&&v.forEach(((e,t)=>{E.push([]),e.xList.forEach((i=>{E[t].push({x:i,y:e.y})}))})),{offsetX:w,offsetY:x,yLines:C,xLines:E}}const cn="LAYOUT_SELECT",dn=Symbol(`${cn}_layoutActionType`),un=Symbol(`${cn}_layoutControlType`),fn=Symbol(`${cn}_layoutController`),gn=Symbol(`${cn}_layoutIsHoverContent`),vn=Symbol(`${cn}_layoutIsHoverController`),mn=Symbol(`${cn}_layoutIsSelected`),yn=Symbol(`${cn}_layoutIsSelected`),pn={activeColor:"#b331c9"};function wn(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("nonzero"),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 xn(e,t){const{start:i,end:o,style:n}=t,{activeColor:r}=n,l=r;e.setLineDash([]),e.strokeStyle=l,e.lineWidth=2,e.beginPath(),e.moveTo(i.x,i.y),e.lineTo(o.x,o.y),e.closePath(),e.stroke()}function Sn(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:r}=o,l=Ke({width:n,height:r,devicePixelRatio:i});return zi(l,o,{loader:void 0,viewScaleInfo:{scale:1,offsetTop:0,offsetBottom:0,offsetLeft:0,offsetRight:0},viewSizeInfo:{width:n,height:r,devicePixelRatio:i,contextWidth:n,contextHeight:r},parentElementSize:{x:0,y:0,w:n,h:r},parentOpacity:1}),{context2d:l,fill:t}}const bn="monospace";const An="@middleware/internal-event/show-info-angle",In={textBackground:"#1973bac6",textColor:"#ffffff"},Mn=10,zn="SCROLL",Rn=Symbol(`${zn}_xThumbRect`),Cn=Symbol(`${zn}_yThumbRect`),En=Symbol(`${zn}_hoverXThumbRect`),Tn=Symbol(`${zn}_hoverYThumbRect`),Pn=Symbol(`${zn}_prevPoint`),Ln=Symbol(`${zn}_activePoint`),On=Symbol(`${zn}_activeThumbType`),kn={thumbBackground:"#0000003A",thumbBorderColor:"#0000008A",hoverThumbBackground:"#0000005F",hoverThumbBorderColor:"#000000EE",activeThumbBackground:"#0000005E",activeThumbBorderColor:"#000000F0"};function Wn(e,t,i){const o=e,{x:n,y:r,w:l,h:a}=i;return o.beginPath(),o.rect(n,r,l,a),o.closePath(),!!o.isPointInPath(t.x,t.y)}function Dn(e,t){let{x:i,y:o,h:n,w:r}=t;const{background:l,borderColor:a}=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+r/4+0,r/=2);let h=t.r;h=Math.min(h,r/2,n/2),(r<2*h||n<2*h)&&(h=0),e.globalAlpha=1,e.beginPath(),e.moveTo(i+h,o),e.arcTo(i+r,o,i+r,o+n,h),e.arcTo(i+r,o+n,i,o+n,h),e.arcTo(i,o+n,i,o,h),e.arcTo(i,o,i+r,o,h),e.closePath(),e.fillStyle=l,e.fill("nonzero"),e.beginPath(),e.lineWidth=1,e.strokeStyle=a,e.setLineDash([]),e.moveTo(i+h,o),e.arcTo(i+r,o,i+r,o+n,h),e.arcTo(i+r,o+n,i,o+n,h),e.arcTo(i,o+n,i,o,h),e.arcTo(i,o,i+r,o,h),e.closePath(),e.stroke()}e.restore()}function jn(e,t){const i=e,{viewScaleInfo:o,viewSizeInfo:n,scrollInfo:r,style:l}=t,{activeThumbType:a,prevPoint:s,activePoint:h,hoverXThumb:c,hoverYThumb:d}=r,u=function(e){const{viewScaleInfo:t,viewSizeInfo:i,hoverXThumb:o,hoverYThumb:n,style:r}=e,{width:l,height:a}=i,{offsetTop:s,offsetBottom:h,offsetLeft:c,offsetRight:d}=t,u=16,{thumbBackground:f,thumbBorderColor:g,hoverThumbBackground:v,hoverThumbBorderColor:m}=r;let y=0,p=0;y=Math.max(40,l-32-(Math.abs(c)+Math.abs(d))),y>=l&&(y=l),p=Math.max(40,a-32-(Math.abs(s)+Math.abs(h))),p>=a&&(p=a);let w=16;c>0?w=16:d>0?w=l-y-u:c<=0&&y>0&&(0!==c||0!==d)&&(w=16+(l-y)*Math.abs(c)/(Math.abs(c)+Math.abs(d)),w=Math.min(Math.max(0,w-16),l-y));let x=16;return s>0?x=16:h>0?x=a-p-u:s<=0&&p>0&&(0!==s||0!==h)&&(x=16+(a-p)*Math.abs(s)/(Math.abs(s)+Math.abs(h)),x=Math.min(Math.max(0,x-16),a-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:a-u,w:y,h:u},yThumbRect:{x:l-u,y:x,w:u,h:p}}}({viewScaleInfo:o,viewSizeInfo:n,hoverXThumb:c,hoverYThumb:d,style:l});let f={...u.xThumbRect},g={...u.yThumbRect};return a&&s&&h&&("X"===a&&r.xThumbRect?(f={...r.xThumbRect},f.x=f.x+(h.x-s.x)):"Y"===a&&r.yThumbRect&&(g={...r.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 Yn(e,t){const{snapshot:i,style:o}=t,n=ut(i),r=dt(i),l=function(e){const{sharedStore:t}=e;return{activePoint:t[Ln]||null,prevPoint:t[Pn]||null,activeThumbType:t[On]||null,xThumbRect:t[Rn]||null,yThumbRect:t[Cn]||null,hoverXThumb:t[En],hoverYThumb:t[Tn]}}(i),{xThumbRect:a,yThumbRect:s}=jn(e,{viewSizeInfo:n,viewScaleInfo:r,scrollInfo:l,style:o});return{xThumbRect:a,yThumbRect:s}}const Nn=16,Bn="monospace",Fn={background:"#FFFFFFA8",borderColor:"#00000080",scaleColor:"#000000",textColor:"#00000080",gridColor:"#AAAAAA20",gridPrimaryColor:"#AAAAAA40",selectedAreaColor:"#19609780"},Gn=[1,2,5,10,20,50,100,200,500];function Vn(e){const{scale:t,viewLength:i,viewOffset:o}=e,n=[];let r=10;r=Zt(r/t,{decimalPlaces:0}),r=function(e){e=Math.max(Gn[0],Math.min(e,Gn[Gn.length-1]));for(let t=0;t<Gn.length-1;t++){const i=Gn[t],o=Gn[t+1];if(!(e>o))return e===i||e===o?e:e<=(i+o)/2?i:o}return e}(r);const l=10*r,a=5*r;let s=0;const h=r*t,c=0-o,d=c%h,u=(c-d+h)/t,f=h-d+0;for(;f+s*h<i;){const e=Zt(u+s*r,{decimalPlaces:0}),t={num:e,position:Zt(f+s*h,{decimalPlaces:0}),showNum:e%l==0,isKeyNum:e%l==0,isSubKeyNum:e%a==0};n.push(t),s++}return{list:n,rulerUnit:r}}const Xn={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"},Hn=Symbol("DRAG_prevPoint");return ce=new WeakMap,de=new WeakMap,ue=new WeakMap,fe=new WeakSet,ge=function(){pe(this,ue).style.position="relative"},ve=function(e){Mt((null==e?void 0:e.elements)||[]),pe(this,ce).setData(e)},e.Board=wo,e.Calculator=io,e.Core=class{constructor(e,t){we(this,fe),we(this,ce),we(this,de),we(this,ue);const{devicePixelRatio:i=1,width:o,height:n,disableWatcher:r=!1}=t;xe(this,ue,e);const l=document.createElement("canvas");l.setAttribute("tabindex","0"),xe(this,de,l),Se(this,fe,ge).call(this),e.appendChild(l);const a=qe(l,{width:o,height:n,devicePixelRatio:i}),s=new wo({boardContent:a,container:e,disableWatcher:r}),h=s.getSharer();h.setActiveViewSizeInfo({width:o,height:n,devicePixelRatio:i,contextWidth:o,contextHeight:n}),xe(this,ce,s),this.resize(h.getActiveViewSizeInfo());const c=s.getEventHub();new Io(e,{eventHub:c})}isDestroyed(){return pe(this,ce).isDestroyed()}destroy(){pe(this,ce).destroy(),pe(this,de).remove()}use(e,t){pe(this,ce).use(e,t)}disuse(e){pe(this,ce).disuse(e)}resetMiddlewareConfig(e,t){pe(this,ce).resetMiddlewareConfig(e,t)}setData(e){pe(this,ce).getRenderer().getLoader().reset(),Se(this,fe,ve).call(this,e)}getData(){return pe(this,ce).getData()}scale(e){pe(this,ce).scale(e);pe(this,ce).getViewer().drawFrame()}resize(e){const t=pe(this,ce),i=t.getSharer().getActiveViewSizeInfo();t.resize({...i,...e})}clear(){pe(this,ce).clear()}on(e,t){pe(this,ce).getEventHub().on(e,t)}off(e,t){pe(this,ce).getEventHub().off(e,t)}trigger(e,t){pe(this,ce).getEventHub().trigger(e,t)}getViewInfo(){const e=pe(this,ce).getSharer();return{viewSizeInfo:e.getActiveViewSizeInfo(),viewScaleInfo:e.getActiveViewScaleInfo()}}refresh(){pe(this,ce).getViewer().drawFrame()}forceRender(){const e=pe(this,ce).getRenderer(),t=e.getCalculator(),i=e.getLoader(),o=this.getData();if(o){const{viewScaleInfo:e,viewSizeInfo:i}=this.getViewInfo();t.resetVirtualFlatItemMap(o,{viewScaleInfo:e,viewSizeInfo:i})}i.reset(),this.refresh()}setViewScale(e){pe(this,ce).updateViewScaleInfo(e)}getLoadItemMap(){return pe(this,ce).getRenderer().getLoadItemMap()}onBoardWatcherEvents(){pe(this,ce).onWatcherEvents()}offBoardWatcherEvents(){pe(this,ce).offWatcherEvents()}createElement(e,t,i){const{viewScaleInfo:o,viewSizeInfo:n}=this.getViewInfo();return hi(e,t||{},!0===(null==i?void 0:i.viewCenter)?{viewScaleInfo:o,viewSizeInfo:n}:void 0)}updateElement(e){const t=this.getData()||{elements:[]},i=e.uuid,o=Tt(i,t.elements),n=Et(o,t.elements);if(!n)return null;const r=qt(n),l=qt(gi(o,e,t.elements,{strict:!0}));pe(this,ce).getRenderer().getLoader().resetElementAsset(e),Se(this,fe,ve).call(this,t),this.refresh();return{type:"updateElement",time:Date.now(),content:{method:"updateElement",uuid:i,before:r,after:l}}}modifyElement(e){const{uuid:t,...i}=e,o=this.getData()||{elements:[]},n=Tt(t,o.elements),r=Et(n,o.elements);if(!r)return null;const l=Mo({modifiedElement:e,beforeElement:r});gi(n,i,o.elements);return pe(this,ce).getRenderer().getLoader().resetElementAsset({...e,type:r.type}),Se(this,fe,ve).call(this,o),this.refresh(),l}modifyElements(e){const t=this.getData()||{elements:[]};let i=null;const o=[],n=[];return e.forEach((e=>{const{uuid:i,...r}=e,l=Tt(i,t.elements),a=Et(l,t.elements);if(!a)return null;const s=Mo({modifiedElement:e,beforeElement:a});s.content&&(o.push({...s.content.before,uuid:i}),n.push({...s.content.after,uuid:i})),gi(l,r,t.elements)})),i={type:"modifyElements",time:Date.now(),content:{method:"modifyElements",before:o,after:n}},Se(this,fe,ve).call(this,t),this.refresh(),i}addElement(e,t){var i;const o=this.getData()||{elements:[]};if(t&&(null==(i=null==t?void 0:t.position)?void 0:i.length)){if(null==t?void 0:t.position){ci(e,[...(null==t?void 0:t.position)||[]],o.elements)}}else o.elements.push(e);const n=Tt(e.uuid,o.elements),r={type:"addElement",time:Date.now(),content:{method:"addElement",uuid:e.uuid,position:n,element:Ce(e)}};return Se(this,fe,ve).call(this,o),this.refresh(),r}deleteElement(e){const t=this.getData()||{elements:[]},i=Tt(e,t.elements),o=Et(i,t.elements),n={type:"deleteElement",time:Date.now(),content:{method:"deleteElement",uuid:e,position:i,element:o?Ce(o):null}};if(o){pe(this,ce).getRenderer().getLoader().resetElementAsset(o)}return function(e,t){di(Tt(e,t),t)}(e,t.elements),Se(this,fe,ve).call(this,t),this.refresh(),n}moveElement(e,t){const i=this.getData()||{elements:[]},o=Tt(e,i.elements),n={type:"moveElement",time:Date.now(),content:{method:"moveElement",uuid:e,from:[...o],to:[...t]}},{elements:r}=function(e,t){const i=[...t.from],o=[...t.to];if(0===i.length||0===o.length)return{elements:e,from:i,to:o};if(i.length<=o.length)for(let t=0;t<i.length;t++)if(o[t]!==i[t]);else if(t===i.length-1)return{elements:e,from:i,to:o};const n=Et(i,e);if(n){if(!ci(n,o,e))return{elements:e,from:i,to:o};let t=-1,r=!1;if(i.length>=1&&o.length>=1){if(i.length<=o.length)if(1===i.length)i[0]<o[0]&&(r=!0);else for(let e=0;e<i.length&&i[e]===o[e];e++)if(i.length===i.length-1){r=!0;break}if(i.length>=o.length)if(1===o.length)o[0]<i[0]&&(r=!0);else for(let e=0;e<o.length&&(e===o.length-1&&o[e]<i[e]&&(r=!0),i[e]===o[e]);e++);}if(!0===r)for(let e=0;e<i.length&&o[e]>=0;e++)o[e]!==i[e]&&o[e]<i[e]&&e==o.length-1&&(t=e);t>=0&&(i[t]=i[t]+1),di(i,e)}return{elements:e,from:i,to:o}}(i.elements,{from:o,to:t});return i.elements=r,Se(this,fe,ve).call(this,i),this.refresh(),n}modifyLayout(e){const t=this.getData()||{elements:[]},i={type:"modifyLayout",time:Date.now(),content:{method:"modifyLayout",before:null,after:null}};if(null===e)return t.layout?(i.content.before=_t(t.layout),delete t.layout,Se(this,fe,ve).call(this,t),this.refresh(),i):i;const o=t.layout;let n={};const r=_t(e);return t.layout?(Object.keys(r).forEach((e=>{let t=ii(o,e);void 0===t&&/(borderRadius|borderWidth)\[[0-9]{1,}\]$/.test(e)&&(e=e.replace(/\[[0-9]{1,}\]$/,""),t=ii(o,e)),n[e]=t})),n=_t(n),i.content.before=n):t.layout={},i.content.after=r,function(e,t){const i=_t(t),o=[];Object.keys(i).forEach((t=>{if(!o.includes(t)){const o=i[t];ni(e,t),void 0!==o&&oi(e,t,o)}}))}(t.layout,e),Se(this,fe,ve).call(this,t),this.refresh(),i}modifyGlobal(e){const t=this.getData()||{elements:[]},i={type:"modifyGlobal",time:Date.now(),content:{method:"modifyGlobal",before:null,after:null}};if(null===e)return t.global?(i.content.before=ei(t.global),delete t.global,Se(this,fe,ve).call(this,t),this.refresh(),i):i;const o=t.global;let n={};const r=ei(e);return t.global?(Object.keys(r).forEach((e=>{n[e]=ii(o,e)})),n=ei(n),i.content.before=n):t.global={},i.content.after=r,function(e,t){const i=ei(t),o=[];Object.keys(i).forEach((t=>{if(!o.includes(t)){const o=i[t];ni(e,t),void 0!==o&&oi(e,t,o)}}))}(t.global,e),Se(this,fe,ve).call(this,t),this.refresh(),i}},e.MiddlewareDragger=e=>{const{eventHub:t,sharer:i,viewer:o}=e;let n=!1;return{name:"@middleware/dragger",hover(){!0!==n&&t.trigger(Ao.CURSOR,{type:"drag-default"})},pointStart(e){const{point:o}=e;i.setSharedStorage(Hn,o),n=!0,t.trigger(Ao.CURSOR,{type:"drag-active"})},pointMove(e){const{point:t}=e,n=i.getSharedStorage(Hn);if(t&&n){const e=t.x-n.x,i=t.y-n.y;o.scroll({moveX:e,moveY:i}),o.drawFrame()}i.setSharedStorage(Hn,t)},pointEnd(){n=!1,i.setSharedStorage(Hn,null),t.trigger(Ao.CURSOR,{type:"drag-default"})}}},e.MiddlewareInfo=(e,t)=>{const{boardContent:i,calculator:o,eventHub:n}=e,{overlayContext:r}=i;let l={...In,...t},a=!0;const s=({show:e})=>{a=e};return{name:"@middleware/info",use(){n.on(An,s)},disuse(){n.off(An,s)},resetConfig(e){l={...l,...e}},beforeDrawFrame({snapshot:e}){var t;const{textBackground:i,textColor:n}=l,s={textBackground:i,textColor:n},{sharedStore:h}=e,c=h[Oo],d=h[Ro],u=h[jo]||[];if(1===c.length){const i=c[0];if(i&&["select","drag","resize"].includes(d)){const n=dt(e),l=ut(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:l},y=o.calcViewRectInfoFromOrigin(i.uuid,m);let p=0;v.forEach((e=>{p+=e.angle||0}));const w=ft(It(0-p));if(y){const e=null==y?void 0:y.center,o={topLeft:wt(e,y.topLeft,w),topRight:wt(e,y.topRight,w),bottomRight:wt(e,y.bottomRight,w),bottomLeft:wt(e,y.bottomLeft,w),center:wt(e,y.center,w),top:wt(e,y.top,w),right:wt(e,y.right,w),bottom:wt(e,y.bottom,w),left:wt(e,y.left,w)},n=Zt(i.x,{decimalPlaces:2}),l=Zt(i.y,{decimalPlaces:2}),h=Zt(i.w,{decimalPlaces:2}),c=Zt(i.h,{decimalPlaces:2}),d=`${Zt(n,{decimalPlaces:0})},${Zt(l,{decimalPlaces:0})}`,u=`${Zt(h,{decimalPlaces:0})}x${Zt(c,{decimalPlaces:0})}`,f=`${Zt(i.angle||0,{decimalPlaces:0})}°`;!function(e,t){const{point:i,rotateCenter:o,angle:n,text:r,style:l,fontSize:a,lineHeight:s}=t,{textColor:h,textBackground:c}=l;gt(e,n,o,(()=>{e.$setFont({fontWeight:"300",fontSize:a,fontFamily:bn});const t=(s-a)/2,o=e.$undoPixelRatio(e.measureText(r).width),n={x:i.x-o/2-t,y:i.y},l={x:n.x+o+2*t,y:n.y+a+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(l.x,n.y),e.lineTo(l.x,l.y),e.lineTo(n.x,l.y),e.closePath(),e.fill("nonzero"),e.fillStyle=h,e.textBaseline="top",e.fillText(r,d.x,d.y+t)}))}(r,{point:{x:o.bottom.x,y:o.bottom.y+Mn},rotateCenter:o.center,angle:p,text:u,fontSize:Mn,lineHeight:16,style:s}),function(e,t){const{point:i,rotateCenter:o,angle:n,text:r,style:l,fontSize:a,lineHeight:s}=t,{textBackground:h,textColor:c}=l;gt(e,n,o,(()=>{e.$setFont({fontWeight:"300",fontSize:a,fontFamily:bn});const t=(s-a)/2,o=e.$undoPixelRatio(e.measureText(r).width),n={x:i.x,y:i.y},l={x:n.x+o+2*t,y:n.y+a+t},d={x:i.x+t,y:i.y};e.setLineDash([]),e.fillStyle=h,e.beginPath(),e.moveTo(n.x,n.y),e.lineTo(l.x,n.y),e.lineTo(l.x,l.y),e.lineTo(n.x,l.y),e.closePath(),e.fill("nonzero"),e.fillStyle=c,e.textBaseline="top",e.fillText(r,d.x,d.y+t)}))}(r,{point:{x:o.topLeft.x,y:o.topLeft.y-20},rotateCenter:o.center,angle:p,text:d,fontSize:Mn,lineHeight:16,style:s}),a&&!1!==(null==(t=i.operations)?void 0:t.rotatable)&&function(e,t){const{point:i,rotateCenter:o,angle:n,text:r,style:l,fontSize:a,lineHeight:s}=t,{textBackground:h,textColor:c}=l;gt(e,n,o,(()=>{e.$setFont({fontWeight:"300",fontSize:a,fontFamily:bn});const t=(s-a)/2,o=e.$undoPixelRatio(e.measureText(r).width),n={x:i.x,y:i.y},l={x:n.x+o+2*t,y:n.y+a+t},d={x:i.x+t,y:i.y};e.setLineDash([]),e.fillStyle=h,e.beginPath(),e.moveTo(n.x,n.y),e.lineTo(l.x,n.y),e.lineTo(l.x,l.y),e.lineTo(n.x,l.y),e.closePath(),e.fill("nonzero"),e.fillStyle=c,e.textBaseline="top",e.fillText(r,d.x,d.y+t)}))}(r,{point:{x:o.top.x+Mn+4,y:o.top.y-20-18},rotateCenter:o.center,angle:p,text:f,fontSize:Mn,lineHeight:16,style:s})}}}}}},e.MiddlewareLayoutSelector=(e,t)=>{const{sharer:i,boardContent:o,calculator:n,viewer:r,eventHub:l}=e,{overlayContext:a}=o;let s={...pn,...t},h=null,c=null,d=null,u=null;const f=()=>{h=null,i.setSharedStorage(dn,null),i.setSharedStorage(un,null),i.setSharedStorage(fn,null),i.setSharedStorage(gn,null),i.setSharedStorage(vn,null),i.setSharedStorage(mn,null),i.setSharedStorage(yn,null),c=null,d=null},g=()=>{const e=i.getSharedStorage(Ro);return!(!e||"area"===e)&&(f(),!0)},v=()=>{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},m=e=>{const t=v();if(t){const{x:o,y:n,w:r,h:l}=t;return function(e,t){return Nt(e,Lt(t))}(e,Wt({x:o-5,y:n-5,w:r+10,h:l+10},{viewScaleInfo:i.getActiveViewScaleInfo()}))}return!1},y=()=>{const e=i.getActiveViewScaleInfo(),t=v();if(t){const o=Xt(t,{viewScaleInfo:e,controllerSize:10});i.setSharedStorage(fn,o)}else i.setSharedStorage(fn,null)},p=e=>{const t=i.getActiveStorage("data"),o=i.getSharedStorage(fn);let n=null;if(o&&(null==t?void 0:t.layout)&&(null==e?void 0:e.point)){let t=null;if(o){const{topLeft:r,top:a,topRight:s,right:h,bottomRight:c,bottom:d,bottomLeft:u,left:f}=o,g=[r,a,s,h,c,d,u,f];for(let i=0;i<g.length;i++){const o=g[i];if(Nt(e.point,o.vertexes)){t=`${o.type}`;break}}t&&(i.setSharedStorage(un,t),l.trigger(Ao.CLEAR_SELECT),n=t)}}return n?i.setSharedStorage(vn,!0):i.setSharedStorage(vn,!1),n},w=e=>{!0!==i.getSharedStorage(yn)&&l.trigger(Ao.CURSOR,{type:e?`resize-${e}`:e,groupQueue:[],element:v()})};return{name:"@middleware/layout-selector",use:()=>{f(),y()},resetConfig(e){s={...s,...e}},hover:e=>{if(!0!==i.getSharedStorage(yn)&&!g()){if(m(e.point)?i.setSharedStorage(gn,!0):(i.setSharedStorage(gn,!1),!0===c&&(r.drawFrame(),c=!1)),!0===i.getSharedStorage(mn)){const t=i.getSharedStorage(dn),o=i.getActiveStorage("data");if(null==o?void 0:o.layout)if("resize"!==t){y();const t=p(e);t?w(t):(w(),i.setSharedStorage(dn,null))}else{const t=p(e);w(t)}return!0!==i.getSharedStorage(vn)&&void 0}return i.getSharedStorage(gn)&&!c&&r.drawFrame(),c=i.getSharedStorage(gn),!0!==i.getSharedStorage(vn)&&void 0}},pointStart:e=>{if(g())return;m(e.point)?i.setSharedStorage(mn,!0):(!0===d&&(f(),r.drawFrame()),i.setSharedStorage(mn,!1));const t=i.getActiveStorage("data");u=(null==t?void 0:t.layout)?Ct(t.layout):null,y();const o=p(e);return h=e.point,o&&i.setSharedStorage(dn,"resize"),!0!==i.getSharedStorage(mn)||d||(r.drawFrame(),l.trigger(Ao.SELECT_LAYOUT)),d=i.getSharedStorage(mn),!0!==i.getSharedStorage(vn)&&void 0},pointMove:e=>{if(!i.getSharedStorage(mn)&&g())return;const t=i.getSharedStorage(dn),o=i.getSharedStorage(un),l=i.getActiveStorage("data");if("resize"===t&&o&&(null==l?void 0:l.layout)){if(h){i.setSharedStorage(yn,!0);const t=i.getActiveStorage("scale"),a=e.point.x-h.x,s=e.point.y-h.y,c=a/t,d=s/t,{x:u,y:f,w:g,h:v,operations:m={}}=l.layout,{position:y="absolute"}=m;"top"===o?"relative"===y?(l.layout.h=n.toGridNum(v-d),r.scroll({moveY:s})):(l.layout.y=n.toGridNum(f+d),l.layout.h=n.toGridNum(v-d)):"right"===o?l.layout.w=n.toGridNum(g+c):"bottom"===o?l.layout.h=n.toGridNum(v+d):"left"===o?"relative"===y?(l.layout.w=n.toGridNum(g-c),r.scroll({moveX:a})):(l.layout.x=n.toGridNum(u+c),l.layout.w=n.toGridNum(g-c)):"top-left"===o?"relative"===y?(l.layout.w=n.toGridNum(g-c),l.layout.h=n.toGridNum(v-d),r.scroll({moveX:a,moveY:s})):(l.layout.x=n.toGridNum(u+c),l.layout.y=n.toGridNum(f+d),l.layout.w=n.toGridNum(g-c),l.layout.h=n.toGridNum(v-d)):"top-right"===o?"relative"===y?(r.scroll({moveY:s}),l.layout.w=n.toGridNum(g+c),l.layout.h=n.toGridNum(v-d)):(l.layout.y=n.toGridNum(f+d),l.layout.w=n.toGridNum(g+c),l.layout.h=n.toGridNum(v-d)):"bottom-right"===o?(l.layout.w=n.toGridNum(g+c),l.layout.h=n.toGridNum(v+d)):"bottom-left"===o&&("relative"===y?(r.scroll({moveX:a}),l.layout.w=n.toGridNum(g-c),l.layout.h=n.toGridNum(v+d)):(l.layout.x=n.toGridNum(u+c),l.layout.w=n.toGridNum(g-c),l.layout.h=n.toGridNum(v+d)))}return h=e.point,y(),r.drawFrame(),!1}return!["resize"].includes(t)&&void 0},pointEnd:()=>{i.setSharedStorage(yn,!1);const e=i.getSharedStorage(dn),t=i.getSharedStorage(un),o=i.getActiveStorage("data");if(o&&"resize"===e&&t){let e;u&&(e={type:"modifyLayout",time:Date.now(),content:{method:"modifyLayout",before:_t(u),after:_t(Ct(o.layout))}}),l.trigger(Ao.CHANGE,{type:"resizeLayout",data:o,modifyRecord:e})}if(u=null,i.setSharedStorage(dn,null),i.setSharedStorage(un,null),!0===i.getSharedStorage(vn))return!1},beforeDrawFrame:({snapshot:e})=>{var t;if(g())return;const{activeColor:i}=s,o={activeColor:i},{sharedStore:n,activeStore:r}=e,l=n[dn],h=n[gn],c=n[mn];if(null==(t=r.data)?void 0:t.layout){const{x:t,y:i,w:n,h:s}=r.data.layout,d=dt(e),u={x:t,y:i,w:n,h:s},f=Xt(u,{viewScaleInfo:d,controllerSize:10});if(!0===h){const e=Wt(u,{viewScaleInfo:d});!function(e,t){const{layoutSize:i,style:o}=t,{activeColor:n}=o,{x:r,y:l,w:a,h:s}=i;e.setLineDash([]),e.strokeStyle=n,e.lineWidth=1,e.beginPath(),e.moveTo(r,l),e.lineTo(r+a,l),e.lineTo(r+a,l+s),e.lineTo(r,l+s),e.lineTo(r,l),e.closePath(),e.stroke()}(a,{layoutSize:e,style:o})}(l&&["resize"].includes(l)||!0===c)&&function(e,t){const{controller:i,style:o}=t,{topLeft:n,topRight:r,bottomLeft:l,bottomRight:a,topMiddle:s,rightMiddle:h,bottomMiddle:c,leftMiddle:d}=i;xn(e,{start:n.center,end:r.center,centerVertexes:s.vertexes,style:o}),xn(e,{start:r.center,end:a.center,centerVertexes:h.vertexes,style:o}),xn(e,{start:a.center,end:l.center,centerVertexes:c.vertexes,style:o}),xn(e,{start:l.center,end:n.center,centerVertexes:d.vertexes,style:o}),wn(e,n.vertexes,o),wn(e,r.vertexes,o),wn(e,a.vertexes,o),wn(e,l.vertexes,o)}(a,{controller:f,style:o})}},scrollX:()=>{f()},scrollY:()=>{f()},wheelScale:()=>{f()}}},e.MiddlewarePointer=e=>{const{boardContent:t,eventHub:i,sharer:o}=e,n=t.boardContext.canvas,r=e.container||document.body,l=`idraw-middleware-pointer-${Math.random().toString(26).substring(2)}`;let a=document.createElement("div");return{name:"@middleware/pointer",use(){a.setAttribute("id",l),a.style.position="fixed",a.style.top="0",a.style.bottom="unset",a.style.left="0",a.style.right="unset",r.appendChild(a)},disuse(){r.removeChild(a),a.remove(),a=null},contextMenu(e){const{point:t}=e,{left:r,top:l}=(()=>{const e=n.getBoundingClientRect(),{left:t,top:i,width:o,height:r}=e;return{left:t,top:i,width:o,height:r}})();a.style.left=`${r+t.x}px`,a.style.top=`${l+t.y}px`;const s=o.getSharedStorage(Oo);i.trigger(Ao.CONTEXT_MENU,{pointerContainer:a,selectedElements:s||[]})}}},e.MiddlewareRuler=(e,t)=>{const{boardContent:i,viewer:o,eventHub:n,calculator:r}=e,{overlayContext:l,underlayContext:a}=i;let s={...Fn,...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(Ao.RULER,d)},disuse(){n.off(Ao.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=dt(e),i=ut(e);!function(e,t){const{viewSizeInfo:i,style:o}=t,{width:n,height:r}=i,{background:l,borderColor:a}=o;e.beginPath();const s=-1;e.moveTo(s,s),e.lineTo(n+1,s),e.lineTo(n+1,Nn),e.lineTo(Nn,Nn),e.lineTo(Nn,r+1),e.lineTo(s,r+1),e.lineTo(s,s),e.closePath(),e.fillStyle=l,e.fill("nonzero"),e.lineWidth=1,e.setLineDash([]),e.strokeStyle=a,e.stroke()}(l,{viewSizeInfo:i,style:g}),function(e,t){const{snapshot:i,calculator:o,style:n}=t,{sharedStore:r}=i,{selectedAreaColor:l}=n,a=r[Oo],s=r[Ro];if(["select","drag","drag-list","drag-list-end"].includes(s)&&a.length>0){const t=dt(i),n=ut(i),r=[],s=[],h=[],c=[],d=[];if(a.forEach((e=>{const i=o.calcViewRectInfoFromRange(e.uuid,{viewScaleInfo:t,viewSizeInfo:n});i&&(r.push(i),s.push(i.left.x),h.push(i.right.x),c.push(i.top.y),d.push(i.bottom.y))})),!(r.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,Nn),e.lineTo(u,Nn),e.fillStyle=l,e.closePath(),e.fill("nonzero"),e.beginPath(),e.moveTo(0,g),e.lineTo(Nn,g),e.lineTo(Nn,v),e.lineTo(0,v),e.fillStyle=l,e.closePath(),e.fill("nonzero")}}(l,{snapshot:e,calculator:r,style:g});const{list:o,rulerUnit:n}=function(e){const{viewScaleInfo:t,viewSizeInfo:i}=e,{scale:o,offsetLeft:n}=t,{width:r}=i;return Vn({scale:o,viewLength:r,viewOffset:n})}({viewScaleInfo:t,viewSizeInfo:i});!function(e,t){const{scaleList:i,style:o}=t,{scaleColor:n,textColor:r}=o;for(let t=0;t<i.length;t++){const o=i[t];o.position<Nn||(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=r,e.textBaseline="top",e.$setFont({fontWeight:100,fontSize:10,fontFamily:Bn}),e.fillText(`${o.num}`,o.position+3.2,3.2)))}}(l,{scaleList:o,style:g});const{list:s}=function(e){const{viewScaleInfo:t,viewSizeInfo:i}=e,{scale:o,offsetTop:n}=t,{height:r}=i;return Vn({scale:o,viewLength:r,viewOffset:n})}({viewScaleInfo:t,viewSizeInfo:i});if(function(e,t){const{scaleList:i,style:o}=t,{scaleColor:n,textColor:r}=o,l=3.2;for(let t=0;t<i.length;t++){const o=i[t];if(!(o.position<Nn)&&(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=l,i=o.position+l,n=`${o.num}`;gt(e,-90,{x:t,y:i},(()=>{e.fillStyle=r,e.textBaseline="top",e.$setFont({fontWeight:100,fontSize:10,fontFamily:Bn}),e.fillText(n,13.2,o.position+l)}))}}}(l,{scaleList:s,style:g}),!0===c){!function(e,t){const{xList:i,yList:o,viewSizeInfo:n,style:r}=t,{width:l,height:a}=n,{gridColor:s,gridPrimaryColor:h}=r;for(let t=0;t<i.length;t++){const o=i[t];e.beginPath(),e.moveTo(o.position,0),e.lineTo(o.position,a),!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(l,i.position),!0===i.isKeyNum||!0===i.isSubKeyNum?e.strokeStyle=h:e.strokeStyle=s,e.lineWidth=1,e.closePath(),e.stroke()}}(1===n?l:a,{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:r}=e,{scale:l}=i.getActiveViewScaleInfo();let a=l;if(n<0?a=1.1*l:n>0&&(a=.9*l),a<.05||a>50)return;const{moveX:s,moveY:h}=t.scale({scale:a,point:r});t.scroll({moveX:s,moveY:h}),t.drawFrame();const c=Zt(l);o.trigger(Ao.SCALE,{scale:c})}}},e.MiddlewareScroller=(e,t)=>{const{viewer:i,boardContent:o,sharer:n,eventHub:r}=e,{overlayContext:l}=o;n.setSharedStorage(Rn,null),n.setSharedStorage(Cn,null);let a=!1,s={...kn,...t};const h=()=>{n.setSharedStorage(Pn,null),n.setSharedStorage(Ln,null),n.setSharedStorage(On,null),n.setSharedStorage(En,null),n.setSharedStorage(Tn,null),a=!1};h();const c=e=>function(e,t,i){let o=null;const{xThumbRect:n,yThumbRect:r}=i;return n&&Wn(e,t,n)?o="X":r&&Wn(e,t,r)&&(o="Y"),o}(l,e,{xThumbRect:n.getSharedStorage(Rn),yThumbRect:n.getSharedStorage(Cn)});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===a)return!1;const{point:t}=e,i=c(t);if("X"===i||"Y"===i)return"X"===i?(n.setSharedStorage(En,!0),n.setSharedStorage(Tn,!1)):(n.setSharedStorage(En,!1),n.setSharedStorage(Tn,!0)),r.trigger(Ao.CURSOR,{type:"default"}),!1;n.setSharedStorage(En,!1),n.setSharedStorage(Tn,!1)},pointStart:e=>{const{point:t}=e,i=c(t);if("X"===i||"Y"===i)return a=!0,n.setSharedStorage(On,i),n.setSharedStorage(Pn,t),!1},pointMove:e=>{const{point:t}=e,o=n.getSharedStorage(On);if("X"===o||"Y"===o)return n.setSharedStorage(Ln,t),"X"===o?(e=>{const t=n.getSharedStorage(Pn);if(t){const{offsetLeft:o,offsetRight:r}=n.getActiveViewScaleInfo(),{width:l}=n.getActiveViewSizeInfo(),a=-(e.x-t.x)*(l+Math.abs(o)+Math.abs(r))/l;i.scroll({moveX:a}),i.drawFrame()}})(t):"Y"===o&&(e=>{const t=n.getSharedStorage(Pn);if(t){const{offsetTop:o,offsetBottom:r}=n.getActiveViewScaleInfo(),{height:l}=n.getActiveViewSizeInfo(),a=-(e.y-t.y)*(l+Math.abs(o)+Math.abs(r))/l;i.scroll({moveY:a}),i.drawFrame()}})(t),n.setSharedStorage(Pn,t),!1},pointEnd:()=>{a=!1;const e=n.getSharedStorage(On);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:r,activeThumbBackground:a,activeThumbBorderColor:h}=s,c={thumbBackground:t,thumbBorderColor:i,hoverThumbBackground:o,hoverThumbBorderColor:r,activeThumbBackground:a,activeThumbBorderColor:h},{xThumbRect:d,yThumbRect:u}=Yn(l,{snapshot:e,style:c});n.setSharedStorage(Rn,d),n.setSharedStorage(Cn,u)}}},e.MiddlewareSelector=(e,t)=>{let i={...Go,...t};const{viewer:o,sharer:n,boardContent:r,calculator:l,eventHub:a}=e,{overlayContext:s}=r;let h=null,c=[],d=null,u=null,f=null,g=null,v=Sn({fill:i.activeColor,devicePixelRatio:n.getActiveViewSizeInfo().devicePixelRatio}),m=null,y=null;n.setSharedStorage(Ro,null),n.setSharedStorage(Fo,!0);const p=()=>n.getSharedStorage(Oo),w=e=>{let t=n.getSharedStorage(jo);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=Ot(t);return n.setSharedStorage(jo,t),n.setSharedStorage(Yo,i),t.length>0},x=e=>{n.setSharedStorage(Po,e);let t=null;e&&(t=kt(e,{groupQueue:n.getSharedStorage(jo)})),n.setSharedStorage(Lo,t)},S=()=>{const e=n.getSharedStorage(Oo);if(1===e.length){const t=Vt(e[0],{groupQueue:n.getSharedStorage(jo),controllerSize:10,viewScaleInfo:n.getActiveViewScaleInfo(),rotateControllerPosition:22,rotateControllerSize:20});n.setSharedStorage(Wo,t)}},b=(e,t)=>{var i;if(n.setSharedStorage(Oo,e),1===e.length?(S(),n.setSharedStorage(Do,Tt(e[0].uuid,(null==(i=n.getActiveStorage("data"))?void 0:i.elements)||[]))):(n.setSharedStorage(Wo,null),n.setSharedStorage(Do,[])),!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 r=t=>{var l;for(let a=0;a<t.length&&!0!==n;a++){i.push(a);const s=t[a];if(e.includes(s.uuid)){if(o[s.uuid]=[...i],Object.keys(o).length===e.length){n=!0;break}}else"group"===s.type&&r((null===(l=null==s?void 0:s.detail)||void 0===l?void 0:l.children)||[]);if(n)break;i.pop()}};return r(t),o}(t,(null==i?void 0:i.elements)||[]);a.trigger(Ao.SELECT,{type:"clickCanvas",uuids:t,positions:e.map((e=>[...o[e.uuid]]))})}},A=()=>({ctx:s,calculator:l,data:n.getActiveStorage("data"),selectedElements:p(),viewScaleInfo:n.getActiveViewScaleInfo(),viewSizeInfo:n.getActiveViewSizeInfo(),groupQueue:n.getSharedStorage(jo),areaSize:null,selectedElementController:n.getSharedStorage(Wo),selectedElementPosition:n.getSharedStorage(Do)}),I=()=>{m=null,y=null,n.setSharedStorage(Ro,null),n.setSharedStorage(Co,null),n.setSharedStorage(Eo,null),n.setSharedStorage(To,null),n.setSharedStorage(jo,[]),n.setSharedStorage(Yo,[]),n.setSharedStorage(Po,null),n.setSharedStorage(Lo,null),n.setSharedStorage(Oo,[]),n.setSharedStorage(ko,null),n.setSharedStorage(Wo,null),n.setSharedStorage(Do,[]),n.setSharedStorage(No,null)};I();const M=({uuids:e=[],positions:t})=>{let i=[];const r=n.getSharedStorage(Ro),l=n.getActiveStorage("data");i=t&&Array.isArray(t)?function(e,t){const i=[];return e.forEach((e=>{const o=Et(e,t);o&&i.push(o)})),i}(t,(null==l?void 0:l.elements)||[]):function(e,t){const i=[];return function t(o){var n;for(let r=0;r<o.length;r++){const l=o[r];e.includes(l.uuid)?i.push(l):"group"===l.type&&t((null===(n=null==l?void 0:l.detail)||void 0===n?void 0:n.children)||[])}}(t),i}(e,(null==l?void 0:l.elements)||[]);let a=!1;if(r||1!==i.length?"select"===r&&1===i.length&&(a=!0):(n.setSharedStorage(Ro,"select"),a=!0),a){const e=function(e,t){const i=[];return function e(t,o){var n;let r=null;for(let l=0;l<o.length;l++){const a=o[l];if(a.uuid===t){r=a;break}if(!r&&"group"===a.type){i.push(a);const o=e(t,(null===(n=null==a?void 0:a.detail)||void 0===n?void 0:n.children)||[]);if((null==o?void 0:o.uuid)===t){r=o;break}i.pop()}}return r}(e,t),i}(i[0].uuid,(null==l?void 0:l.elements)||[]);n.setSharedStorage(jo,e),b(i),c=[{...Ct(i[0]),uuid:i[0].uuid}],o.drawFrame()}},z=()=>{I(),o.drawFrame()},R=e=>{n.setSharedStorage(Fo,!!e.enable)},C=e=>{n.setSharedStorage(Bo,!!e.enable)};return{name:"@middleware/selector",use(){a.on(Ao.SELECT,M),a.on(Ao.CLEAR_SELECT,z),a.on(Ao.SELECT_IN_GROUP,C),a.on(Ao.SNAP_TO_GRID,R)},disuse(){a.off(Ao.SELECT,M),a.off(Ao.CLEAR_SELECT,z),a.off(Ao.SELECT_IN_GROUP,C),a.off(Ao.SNAP_TO_GRID,R),I(),i=null},resetConfig(e){i={...i,...e}},hover:e=>{var t,i,r,l,h;const c=n.getSharedStorage(mn);if(!0===n.getSharedStorage(yn))return;const d=n.getSharedStorage(Co),u=n.getSharedStorage(Ro),g=n.getSharedStorage(jo),v=e=>{if(!0===c)return;const t=e.type;null===f&&a.trigger(Ao.CURSOR,{type:t,groupQueue:e.groupQueue,element:e.elements[0]})};if((null==g?void 0:g.length)>0){if(!tn(e.point,{ctx:s,viewScaleInfo:n.getActiveViewScaleInfo(),viewSizeInfo:n.getActiveViewSizeInfo(),groupQueue:n.getSharedStorage(jo)}))return x(null),void o.drawFrame();const i=on(e.point,A());return v(i),d||["area","drag","drag-list"].includes(u)?(x(null),void o.drawFrame()):1===(null==(t=null==i?void 0:i.elements)?void 0:t.length)?(x(i.elements[0]),void o.drawFrame()):(x(null),void o.drawFrame())}if(d||["area","drag","drag-list"].includes(u))return void x(null);if("drag"===u)return void x(null);const m=p(),y=n.getActiveViewScaleInfo();n.getActiveViewSizeInfo();const w=on(e.point,{...A(),areaSize:rn(m,{viewScaleInfo:y})});if(v(w),null!==w.type){if(!("over-element"===w.type&&"select"===n.getSharedStorage(Ro)&&1===w.elements.length&&w.elements[0].uuid===(null==(r=null==(i=p())?void 0:i[0])?void 0:r.uuid)||"over-element"===w.type&&null===n.getSharedStorage(Ro)&&1===w.elements.length&&w.elements[0].uuid===(null==(l=n.getSharedStorage(Po))?void 0:l.uuid)))return"over-element"===w.type&&1===(null==(h=null==w?void 0:w.elements)?void 0:h.length)?(x(w.elements[0]),void o.drawFrame()):n.getSharedStorage(Po)?(x(null),void o.drawFrame()):void 0}else(n.getSharedStorage(Po)||n.getSharedStorage(Lo))&&(n.setSharedStorage(Po,null),n.setSharedStorage(Lo,null),o.drawFrame())},pointStart:e=>{var t,i,r,l,a,f,g,v,w,S,M,z;h=e.point,d=e.point,m=null,y=null,n.setSharedStorage(Ro,null),n.setSharedStorage(Co,null),n.setSharedStorage(Eo,null),n.setSharedStorage(To,null),n.setSharedStorage(Po,null);const R=n.getSharedStorage(jo);if((null==R?void 0:R.length)>0){if(tn(e.point,{ctx:s,viewScaleInfo:n.getActiveViewScaleInfo(),viewSizeInfo:n.getActiveViewSizeInfo(),groupQueue:R})){const o=on(e.point,A()),s=1===(null==(t=null==o?void 0:o.elements)?void 0:t.length)&&!0===(null==(r=null==(i=o.elements[0])?void 0:i.operations)?void 0:r.locked);x(null),1===(null==(l=null==o?void 0:o.elements)?void 0:l.length)&&(u=Ct(null==o?void 0:o.elements[0])),!0===s?I():"over-element"===o.type&&1===(null==(a=null==o?void 0:o.elements)?void 0:a.length)?(b([o.elements[0]],{triggerEvent:!0}),n.setSharedStorage(Ro,"drag"),c=[{...Ct(null==o?void 0:o.elements[0]),uuid:null==o?void 0:o.elements[0].uuid}]):(null==(f=o.type)?void 0:f.startsWith("resize-"))?(n.setSharedStorage(Co,o.type),n.setSharedStorage(Ro,"resize")):b([],{triggerEvent:!0})}else I();return void o.drawFrame()}const C=rn(p(),{viewScaleInfo:n.getActiveViewScaleInfo(),viewSizeInfo:n.getActiveViewSizeInfo()}),E=on(e.point,{...A(),areaSize:C,groupQueue:[]}),T=1===(null==(g=null==E?void 0:E.elements)?void 0:g.length)&&!0===(null==(w=null==(v=E.elements[0])?void 0:v.operations)?void 0:w.locked);x(null),1===(null==(S=null==E?void 0:E.elements)?void 0:S.length)&&(u=Ct(null==E?void 0:E.elements[0])),!0===T?(I(),n.setSharedStorage(Ro,"area"),n.setSharedStorage(Eo,e.point),b([],{triggerEvent:!0})):"list-area"===E.type?n.setSharedStorage(Ro,"drag-list"):"over-element"===E.type&&1===(null==(M=null==E?void 0:E.elements)?void 0:M.length)?(b([E.elements[0]],{triggerEvent:!0}),n.setSharedStorage(Ro,"drag"),c=[{...Ct(null==E?void 0:E.elements[0]),uuid:null==E?void 0:E.elements[0].uuid}]):(null==(z=E.type)?void 0:z.startsWith("resize-"))?(n.setSharedStorage(Co,E.type),n.setSharedStorage(Ro,"resize")):(I(),n.setSharedStorage(Ro,"area"),n.setSharedStorage(Eo,e.point),b([],{triggerEvent:!0})),o.drawFrame()},pointMove:e=>{var t,i,r;n.setSharedStorage(No,!0);const s=n.getActiveStorage("data"),c=p(),v=n.getActiveStorage("scale")||1,w=n.getActiveViewScaleInfo(),x=n.getActiveViewSizeInfo(),S=h,A=d,I=e.point,M=n.getSharedStorage(Co),z=n.getSharedStorage(Ro),R=n.getSharedStorage(jo),C=n.getSharedStorage(Fo);if("drag"===z){if(g=!0,f="drag",a.trigger(An,{show:!1}),s&&1===(null==c?void 0:c.length)&&u&&A&&I&&!0!==(null==(i=null==(t=c[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 r=[];if(i.forEach((e=>{const{x:t,y:i,w:o,h:n,angle:l=0}=e;r.push({x:t,y:i,w:o,h:n,angle:0-l})})),(null==i?void 0:i.length)>0){const i=xt(e,r),l=xt(t,r);o=l.x-i.x,n=l.y-i.y}return{moveX:o,moveY:n}}(A,I,R);let i=l.toGridNum(e/v),o=l.toGridNum(t/v);if(!0===C){const e=hn(c[0].uuid,{calculator:l,data:s,groupQueue:R,viewScaleInfo:w,viewSizeInfo:x});try{e&&(He.x(e.offsetX)&&null!==e.offsetX&&(i=l.toGridNum(i+e.offsetX)),He.y(e.offsetY)&&null!==e.offsetY&&(o=l.toGridNum(o+e.offsetY)))}catch(e){console.error(e)}}c[0].x=l.toGridNum(u.x+i),c[0].y=l.toGridNum(u.y+o),b([c[0]]),l.modifyVirtualFlatItemMap(s,{modifyInfo:{type:"updateElement",content:{element:c[0],position:n.getSharedStorage(Do)||[]}},viewSizeInfo:x,viewScaleInfo:w})}o.drawFrame()}else if("drag-list"===z){if(g=!0,f="drag-list",s&&A&&S&&I&&(null==c?void 0:c.length)>1){const e=(I.x-S.x)/v,t=(I.y-S.y)/v;c.forEach((i=>{var o;i&&!0!==(null==(o=null==i?void 0:i.operations)?void 0:o.locked)&&(i.x=l.toGridNum(i.x+e),i.y=l.toGridNum(i.y+t),l.modifyVirtualFlatItemMap(s,{modifyInfo:{type:"updateElement",content:{element:i,position:Tt(i.uuid,s.elements)||[]}},viewSizeInfo:x,viewScaleInfo:w}))})),n.setActiveStorage("data",s)}o.drawFrame()}else if("resize"===z){if(s&&1===(null==c?void 0:c.length)&&A&&u&&(null==M?void 0:M.startsWith("resize-"))){g=!0,f="resize";const e=[];R.forEach((t=>{const{x:i,y:o,w:n,h:r,angle:l=0}=t;e.push({x:i,y:o,w:n,h:r,angle:0-l})}));let t=A,i=I;if(R.length>0&&(t=xt(A,e),i=xt(I,e)),"resize-rotate"===M){const e=n.getSharedStorage(Wo),t=yt([e.topLeft.center,e.topRight.center,e.bottomLeft.center,e.bottomRight.center]),i=nn(u,{center:t,viewScaleInfo:w,start:A,end:I});c[0].angle=l.toGridNum(i.angle||0)}else{const e=function(e,t){var i,o,n,r,l,a,s,h,c;let{x:d,y:u,w:f,h:g,angle:v=0}=e;const m=mt({x:d,y:u,w:f,h:g});v=It(v);const y=ft(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},z={x:I.x,y:m.y},R={...M},C={...z},E={x:m.x,y:A.y},T={x:m.x,y:I.y},P={...E},L={...T},O=(C.x-R.x)/b,k=(C.y-R.y)/b,W=qo(O,k),D=(L.x-P.x)/b,j=(L.y-P.y)/b,Y=qo(D,j);(v>0||v<0)&&(A=wt(m,w,0-y),I=wt(m,x,0-y),M={x:A.x,y:m.y},z={x:I.x,y:m.y},R=wt(m,M,y),C=wt(m,z,y),E={x:m.x,y:A.y},T={x:m.x,y:I.y},P=wt(m,E,y),L=wt(m,T,y),O=(C.x-R.x)/b,k=(C.y-R.y)/b,W=qo(O,k),W=_o(W,k),D=(L.x-P.x)/b,j=(L.y-P.y)/b,Y=qo(D,j),Y=_o(Y,j));let N=(x.x-w.x)/b,B=(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(N),Math.abs(B));N=(N>=0?1:-1)*t,B=(B>=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(O),Math.abs(k));O=(O>=0?1:-1)*o,k=(k>=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(N);N=(N>=0?1:-1)*t;const i=t/e.w*e.h;"resize-top-left"===S||"resize-bottom-right"===S?B=N>0?i:-i:"resize-top-right"!==S&&"resize-bottom-left"!==S||(B=N>0?-i:i)}W=Math.abs(W),Y=W/e.w*e.h}switch(S){case"resize-top":if(0===v)g-B>0&&(u+=B,g-=B,!0===(null==(o=e.operations)?void 0:o.limitRatio)&&(d+=B/e.h*e.w/2,f-=B/e.h*e.w));else if(v>0||v<0){let t=m.x,i=m.y;if(v<90){Y=0-_o(Y,j);const e=Ko(v),o=Y/2;t+=o*Math.sin(e),i-=o*Math.cos(e)}else if(v<180){Y=_o(Y,D);const e=Ko(v-90),o=Y/2;t+=o*Math.cos(e),i+=o*Math.sin(e)}else if(v<270){Y=_o(Y,j);const e=Ko(v-180),o=Y/2;t-=o*Math.sin(e),i+=o*Math.cos(e)}else if(v<360){Y=0-_o(Y,D);const e=Ko(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+B>0&&(g+=B,!0===(null==(r=e.operations)?void 0:r.limitRatio)&&(d-=B/e.h*e.w/2,f+=B/e.h*e.w));else if(v>0||v<0){let t=m.x,i=m.y;if(v<90){Y=_o(Y,j);const e=Ko(v),o=Y/2;t-=o*Math.sin(e),i+=o*Math.cos(e)}else if(v<180){Y=0-_o(Y,D);const e=Ko(v-90),o=Y/2;t-=o*Math.cos(e),i-=o*Math.sin(e)}else if(v<270){Y=_o(Y,D);const e=Ko(v-180),o=Y/2;t+=o*Math.sin(e),i-=o*Math.cos(e)}else if(v<360){Y=_o(Y,D);const e=Ko(v-270),o=Y/2;t+=o*Math.cos(e),i+=o*Math.sin(e)}g+Y>0&&(!0===(null==(l=e.operations)?void 0:l.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-N>0&&(d+=N,f-=N,!0===(null==(a=e.operations)?void 0:a.limitRatio)&&(g-=N/e.w*e.h,u+=N/e.w*e.h/2));else if(v>0||v<0){let t=m.x,i=m.y;if(v<90){W=0-_o(W,O);const e=Ko(v),o=W/2;t-=o*Math.cos(e),i-=o*Math.sin(e)}else if(v<180){W=_o(W,O);const e=Ko(v-90),o=W/2;t+=o*Math.sin(e),i-=o*Math.cos(e)}else if(v<270){W=_o(W,k);const e=Ko(v-180),o=W/2;t+=o*Math.cos(e),i+=o*Math.sin(e)}else if(v<360){W=_o(W,k);const e=Ko(v-270),o=W/2;t-=o*Math.sin(e),i+=o*Math.cos(e)}f+W>0&&(!0===(null==(s=e.operations)?void 0:s.limitRatio)&&(g+=W/e.w*e.h),f+=W,d=t-f/2,u=i-g/2)}break;case"resize-right":if(0===v)e.w+N>0&&(f+=N,!0===(null==(h=e.operations)?void 0:h.limitRatio)&&(u-=N*e.h/e.w/2,g+=N*e.h/e.w));else if(v>0||v<0){let t=m.x,i=m.y;if(v<90){W=_o(W,k);const e=Ko(v),o=W/2;t+=o*Math.cos(e),i+=o*Math.sin(e)}else if(v<180){W=_o(W,B);const e=Ko(v-90),o=W/2;t-=o*Math.sin(e),i+=o*Math.cos(e)}else if(v<270){W=_o(W,B);const e=Ko(v-180),o=W/2;t+=o*Math.cos(e),i+=o*Math.sin(e),W=0-W}else if(v<360){W=_o(W,N);const e=Ko(v-270),o=W/2;t+=o*Math.sin(e),i-=o*Math.cos(e)}f+W>0&&(!0===(null==(c=e.operations)?void 0:c.limitRatio)&&(g+=W/e.w*e.h),f+=W,d=t-f/2,u=i-g/2)}break;case"resize-top-left":if(0===v)f-N>0&&(d+=N,f-=N),g-B>0&&(u+=B,g-=B);else if(v>0||v<0){let e=m.x,t=m.y;if(v<90){Y=0-_o(Y,j),W=0-_o(W,p?0-Y:O);const i=Y/2;e+=i*Math.sin(y),t-=i*Math.cos(y);const o=W/2;e-=o*Math.cos(y),t-=o*Math.sin(y)}else if(v<180){Y=_o(Y,D),W=_o(W,p?Y:O);const i=Ko(v-90),o=Y/2;e+=o*Math.cos(i),t+=o*Math.sin(i);const n=W/2;e+=n*Math.sin(i),t-=n*Math.cos(i)}else if(v<270){Y=_o(Y,j),W=_o(W,p?Y:k);const i=Ko(v-180),o=Y/2;e-=o*Math.sin(i),t+=o*Math.cos(i);const n=W/2;e+=n*Math.cos(i),t+=n*Math.sin(i)}else if(v<360){Y=0-_o(Y,D),W=_o(W,p?Y:k);const i=Ko(v-270),o=Y/2;e-=o*Math.cos(i),t-=o*Math.sin(i);const n=W/2;e-=n*Math.sin(i),t+=n*Math.cos(i)}g+Y>0&&(g+=Y),f+W>0&&(f+=W),d=e-f/2,u=t-g/2}break;case"resize-top-right":if(0===v)f+N>0&&(f+=N),g-B>0&&(u+=B,g-=B);else if(v>0||v<0){let e=m.x,t=m.y;if(v<90){Y=0-_o(Y,j),W=_o(W,p?Y:k);const i=Ko(v),o=Y/2;e+=o*Math.sin(i),t-=o*Math.cos(i);const n=W/2;e+=n*Math.cos(i),t+=n*Math.sin(i)}else if(v<180){Y=_o(Y,D),W=_o(W,p?Y:k);const i=Ko(v-90),o=Y/2;e+=o*Math.cos(i),t+=o*Math.sin(i);const n=W/2;e-=n*Math.sin(i),t+=n*Math.cos(i)}else if(v<270){const i=Ko(v-180);Y=_o(Y,j),W=_o(W,p?Y:0-O);const o=Y/2;e-=o*Math.sin(i),t+=o*Math.cos(i);const n=W/2;e-=n*Math.cos(i),t-=n*Math.sin(i)}else if(v<360){Y=0-_o(Y,D),W=_o(W,p?Y:O);const i=Ko(v-270),o=Y/2;e-=o*Math.cos(i),t-=o*Math.sin(i);const n=W/2;e+=n*Math.sin(i),t-=n*Math.cos(i)}g+Y>0&&(g+=Y),f+W>0&&(f+=W),d=e-f/2,u=t-g/2}break;case"resize-bottom-left":if(0===v)e.h+B>0&&(g+=B),e.w-N>0&&(d+=N,f-=N);else if(v>0||v<0){let e=m.x,t=m.y;if(v<90){Y=_o(Y,j),W=0-_o(W,p?0-Y:O);const i=Ko(v),o=Y/2;e-=o*Math.sin(i),t+=o*Math.cos(i);const n=W/2;e-=n*Math.cos(i),t-=n*Math.sin(i)}else if(v<180){Y=0-_o(Y,D),W=_o(W,p?Y:O);const i=Ko(v-90),o=Y/2;e-=o*Math.cos(i),t-=o*Math.sin(i);const n=W/2;e+=n*Math.sin(i),t-=n*Math.cos(i)}else if(v<270){Y=_o(Y,D),W=_o(W,p?Y:k);const i=Ko(v-180),o=Y/2;e+=o*Math.sin(i),t-=o*Math.cos(i);const n=W/2;e+=n*Math.cos(i),t+=n*Math.sin(i)}else if(v<360){Y=_o(Y,D),W=_o(W,p?Y:k);const i=Ko(v-270),o=Y/2;e+=o*Math.cos(i),t+=o*Math.sin(i);const n=W/2;e-=n*Math.sin(i),t+=n*Math.cos(i)}g+Y>0&&(g+=Y),f+W>0&&(f+=W),d=e-f/2,u=t-g/2}break;case"resize-bottom-right":if(0===v)e.h+B>0&&(g+=B),e.w+N>0&&(f+=N);else if(v>0||v<0){let e=m.x,t=m.y;if(v<90){Y=_o(Y,j),W=_o(W,p?Y:k);const i=Ko(v),o=Y/2;e-=o*Math.sin(i),t+=o*Math.cos(i);const n=W/2;e+=n*Math.cos(i),t+=n*Math.sin(i)}else if(v<180){Y=0-_o(Y,D),W=_o(W,p?Y:B);const i=Ko(v-90),o=Y/2;e-=o*Math.cos(i),t-=o*Math.sin(i);const n=W/2;e-=n*Math.sin(i),t+=n*Math.cos(i)}else if(v<270){Y=_o(Y,D),W=_o(W,p?Y:0-k);const i=Ko(v-180),o=Y/2;e+=o*Math.sin(i),t-=o*Math.cos(i);const n=W/2;e-=n*Math.cos(i),t-=n*Math.sin(i)}else if(v<360){Y=_o(Y,D),W=_o(W,p?Y:O);const i=Ko(v-270),o=Y/2;e+=o*Math.cos(i),t+=o*Math.sin(i);const n=W/2;e+=n*Math.sin(i),t-=n*Math.cos(i)}g+Y>0&&(g+=Y),f+W>0&&(f+=W),d=e-f/2,u=t-g/2}}return{x:d,y:u,w:f,h:g,angle:e.angle}}({...u,operations:c[0].operations},{scale:v,start:t,end:i,resizeType:M}),o={ignore:!!u.angle},n=l.toGridNum(e.x,o),a=l.toGridNum(e.y,o),s=l.toGridNum(e.w,o),h=l.toGridNum(e.h,o);"group"===c[0].type?(y=si(c[0],{x:n,y:a,w:s,h:h},{resizeEffect:null==(r=c[0].operations)?void 0:r.resizeEffect}),m||(m=y),c[0].x=n,c[0].y=a):(c[0].x=n,c[0].y=a,c[0].w=s,c[0].h=h)}b([c[0]]),l.modifyVirtualFlatItemMap(s,{modifyInfo:{type:"updateElement",content:{element:c[0],position:n.getSharedStorage(Do)||[]}},viewSizeInfo:x,viewScaleInfo:w}),o.drawFrame()}}else"area"===z&&(f="area",n.setSharedStorage(To,e.point),o.drawFrame());h=e.point},pointEnd(e){f=null,n.setSharedStorage(No,!1);const t=n.getActiveStorage("data"),i=n.getSharedStorage(Oo),r=n.getSharedStorage(Po),s=n.getSharedStorage(Co),v=n.getSharedStorage(Ro),p=n.getActiveViewSizeInfo();let w=!1;if(h=null,d=null,u=null,"drag"===v&&a.trigger(An,{show:!0}),"resize"===v&&s)n.setSharedStorage(Co,null),w=!0;else if("area"===v){if(n.setSharedStorage(Ro,null),t){const e=n.getSharedStorage(Eo),i=n.getSharedStorage(To);if(e&&i){const{elements:o}=function(e,t){var i;const o=[],n=[],r=[],{viewScaleInfo:l,start:a,end:s}=t;if(!(Array.isArray(e.elements)&&a&&s))return{indexes:o,uuids:n,elements:r};const h=Math.min(a.x,s.x),c=Math.max(a.x,s.x),d=Math.min(a.y,s.y),u=Math.max(a.y,s.y);for(let t=0;t<e.elements.length;t++){const a=e.elements[t];if(!0===(null==(i=null==a?void 0:a.operations)?void 0:i.locked))continue;const s=Wt(a,{viewScaleInfo:l}),f=mt(s);if(f.x>=h&&f.x<=c&&f.y>=d&&f.y<=u&&(o.push(t),n.push(a.uuid),r.push(a),s.angle&&(s.angle>0||s.angle<0))){const e=bt(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:r}}(t,{start:e,end:i,viewScaleInfo:n.getActiveViewScaleInfo(),viewSizeInfo:n.getActiveViewSizeInfo()});o.length>0&&(n.setSharedStorage(Ro,"drag-list"),b(o,{triggerEvent:!0}),w=!0)}}}else if("drag-list"===v)n.setSharedStorage(Ro,"drag-list-end"),w=!0;else if(t){l.getPointElement(e.point,{data:t,viewScaleInfo:n.getActiveViewScaleInfo(),viewSizeInfo:n.getActiveViewSizeInfo()}).element?(n.setSharedStorage(Ro,"select"),w=!0):n.setSharedStorage(Ro,null)}null===n.getSharedStorage(Ro)&&(I(),w=!0);(()=>{if(w){if(t&&Array.isArray(null==t?void 0:t.elements)&&["drag","drag-list"].includes(v)){const e=function(e,t,i){const o=zt(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,p,{extend:!0});n.setActiveStorage("contextHeight",e.contextSize.contextHeight),n.setActiveStorage("contextWidth",e.contextSize.contextWidth)}if(t&&["drag","drag-list","drag-list-end","resize"].includes(v)){let e="resizeElement";if(g){let o=null;if(Array.isArray(c)&&c.length){const e=c[0];1===i.length?(o={type:"resizeElement",time:0,content:{method:"modifyElement",uuid:e.uuid,before:qt(e),after:qt(Ct(i[0]))}},"group"===i[0].type&&m&&y&&(o={...y,content:{...y.content,before:m.content.before}})):i.length>1&&(o={type:"resizeElements",time:0,content:{method:"modifyElements",before:c.map((e=>({...qt(e),uuid:e.uuid}))),after:i.map((e=>({...qt(Ct(e)),uuid:e.uuid})))}})}a.trigger(Ao.CHANGE,{data:t,type:e,selectedElements:i,hoverElement:r,modifyRecord:o}),g=!1}}o.drawFrame()}})()},pointLeave(){f=null,n.setSharedStorage(Co,null),a.trigger(Ao.CURSOR,{type:"default"})},doubleClick(e){var t,i,r,l,s,h,c,d;if(!1===n.getSharedStorage(Bo))return;const u=on(e.point,A());if(n.setSharedStorage(Wo,null),n.setSharedStorage(Oo,[]),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==(r=u.elements[0])?void 0:r.type)){if(!0===w(u.elements[0]))return n.setSharedStorage(Ro,null),void o.drawFrame()}else 1!==u.elements.length||"text"!==(null==(l=u.elements[0])?void 0:l.type)||(null==(h=null==(s=u.elements[0])?void 0:s.operations)?void 0:h.invisible)||a.trigger(Ao.TEXT_EDIT,{element:u.elements[0],groupQueue:n.getSharedStorage(jo)||[],position:Tt(null==(c=u.elements[0])?void 0:c.uuid,(null==(d=n.getActiveStorage("data"))?void 0:d.elements)||[]),viewScaleInfo:n.getActiveViewScaleInfo()});n.setSharedStorage(Ro,null)}},wheel(){S()},wheelScale(){S()},contextMenu:e=>{var t,i,r,l,a,h,c,d;const u=n.getSharedStorage(jo);if((null==u?void 0:u.length)>0){if(tn(e.point,{ctx:s,viewScaleInfo:n.getActiveViewScaleInfo(),viewSizeInfo:n.getActiveViewSizeInfo(),groupQueue:u})){const n=on(e.point,A());1===(null==(t=null==n?void 0:n.elements)?void 0:t.length)&&!0!==(null==(r=null==(i=n.elements[0])?void 0:i.operations)?void 0:r.locked)?(I(),b([n.elements[0]],{triggerEvent:!0}),o.drawFrame()):(null==(l=null==n?void 0:n.elements)?void 0:l.length)||I()}return}const f=rn(p(),{viewScaleInfo:n.getActiveViewScaleInfo(),viewSizeInfo:n.getActiveViewSizeInfo()}),g=on(e.point,{...A(),areaSize:f,groupQueue:[]});if(1===(null==(a=null==g?void 0:g.elements)?void 0:a.length)&&!0!==(null==(c=null==(h=g.elements[0])?void 0:h.operations)?void 0:c.locked))return I(),b([g.elements[0]],{triggerEvent:!0}),void o.drawFrame();(null==(d=null==g?void 0:g.elements)?void 0:d.length)||I()},beforeDrawFrame({snapshot:t}){var o;const{activeColor:n,activeAreaColor:r,lockedColor:a,referenceColor:h}=i,c={activeColor:n,activeAreaColor:r,lockedColor:a,referenceColor:h},{activeStore:d,sharedStore:u}=t,{scale:f,offsetLeft:g,offsetTop:m,offsetRight:y,offsetBottom:w,width:x,height:S,contextHeight:b,contextWidth:A,devicePixelRatio:I}=d;v.fill!==n&&(v=Sn({fill:i.activeColor,devicePixelRatio:I}));const M=e.sharer,z={scale:f,offsetLeft:g,offsetTop:m,offsetRight:y,offsetBottom:w},R={width:x,height:S,contextHeight:b,contextWidth:A,devicePixelRatio:I},C=u[Oo],E=C[0],T=u[Po],P=u[Lo],L=u[Ro],O=u[Eo],k=u[To],W=u[jo],D=u[Yo],j=u[No],Y=u[Fo],N={calculator:l,viewScaleInfo:z,viewSizeInfo:R,style:c};let B=u[Wo];var F,G;B&&1===C.length&&E&&(F=E,G=B.originalElementSize,(F.x!==G.x||F.y!==G.y||F.h!==G.h||F.w!==G.w||It(F.angle||0)!==It(G.angle||0))&&(B=Vt(E,{groupQueue:W||[],controllerSize:10,viewScaleInfo:z,rotateControllerPosition:22,rotateControllerSize:20}),M.setSharedStorage(Wo,B)));const V=!!(null==(o=null==T?void 0:T.operations)?void 0:o.locked);if((null==W?void 0:W.length)>0){if(function(e,t,i){const{style:o}=i,{activeColor:n}=o;for(let o=0;o<t.length;o++){const r={borderColor:n,borderWidth:2,background:"transparent",lineDash:[4,4]};Vo(e,jt(t[o],i),r)}}(s,D,N),T&&"drag"!==L&&(V?Uo(s,P,{...N,controller:B,style:c}):Qo(s,P,N)),E&&["select","drag","resize"].includes(L)&&($o(s,B,{...N,element:E,hideControllers:!!j&&"drag"===L,rotateControllerPattern:v.context2d,style:c}),"drag"===L&&!0===Y)){const e=hn(E.uuid,{calculator:l,data:d.data,groupQueue:W,viewScaleInfo:z,viewSizeInfo:R});if(e){const{offsetX:t,offsetY:i,xLines:o,yLines:n}=e;0!==t&&0!==i||Jo(s,{xLines:o,yLines:n,style:c})}}}else if(T&&"drag"!==L&&(V?Uo(s,P,{...N,controller:B,style:c}):Qo(s,P,N)),E&&["select","drag","resize"].includes(L)){if($o(s,B,{...N,element:E,hideControllers:!!j&&"drag"===L,rotateControllerPattern:v.context2d,style:c}),"drag"===L&&!0===Y){const e=hn(E.uuid,{calculator:l,data:d.data,groupQueue:W,viewScaleInfo:z,viewSizeInfo:R});if(e){const{offsetX:t,offsetY:i,xLines:o,yLines:n}=e;0!==t&&0!==i||Jo(s,{xLines:o,yLines:n,style:c})}}}else if("area"===L&&O&&k)!function(e,t){const{start:i,end:o,style:n}=t,{activeColor:r,activeAreaColor:l}=n;e.setLineDash([]),e.lineWidth=1,e.strokeStyle=r,e.fillStyle=l,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("nonzero")}(s,{start:O,end:k,style:c});else if(["drag-list","drag-list-end"].includes(L)){const e=rn(p(),{viewScaleInfo:M.getActiveViewScaleInfo(),viewSizeInfo:M.getActiveViewSizeInfo()});e&&function(e,t){const{areaSize:i,style:o}=t,{activeColor:n,activeAreaColor:r}=o,{x:l,y:a,w:s,h:h}=i;e.setLineDash([]),e.lineWidth=1,e.strokeStyle=n,e.fillStyle=r,e.beginPath(),e.moveTo(l,a),e.lineTo(l+s,a),e.lineTo(l+s,a+h),e.lineTo(l,a+h),e.closePath(),e.stroke(),e.fill("nonzero")}(s,{areaSize:e,style:c})}}}},e.MiddlewareTextEditor=e=>{const{eventHub:t,boardContent:i,viewer:o,sharer:n,calculator:r}=e,l=i.boardContext.canvas,a=e.container||document.body;let s=document.createElement("div");s.setAttribute("contenteditable","true");let h=document.createElement("div"),c=document.createElement("div"),d=null,u=[],f="";const g=`idraw-middleware-text-editor-${Math.random().toString(26).substring(2)}`;c.setAttribute("id",g),h.appendChild(s),h.style.position="absolute",c.appendChild(h),c.style.position="fixed",c.style.top="0",c.style.bottom="0",c.style.left="0",c.style.right="0",c.style.display="none",a.appendChild(c);const v=()=>{if(null==d?void 0:d.uuid){const e=n.getActiveOverrideElemenentMap();e&&delete e[d.uuid],n.setActiveOverrideElemenentMap(e),o.drawFrame()}c.style.display="none",d=null,u=[]},m=e=>{const{size:t,parent:i}=e,o=document.createElement("div"),{x:n,y:r,w:l,h:a}=t,s=It(t.angle||0);return o.style.position="absolute",o.style.left=`${n}px`,o.style.top=`${r}px`,o.style.width=`${l}px`,o.style.height=`${a}px`,o.style.transform=`rotate(${s}deg)`,i.appendChild(o),o},y=e=>{const{viewScaleInfo:t,element:i,groupQueue:o}=e,{scale:n,offsetTop:r,offsetLeft:l}=t;h.children&&Array.from(h.children).forEach((e=>{e.remove()}));let a=h;for(let e=0;e<o.length;e++){const t=o[e],{x:i,y:s,w:h,h:c}=t,d={x:i*n,y:s*n,w:h*n,h:c*n,angle:It(t.angle||0)};0===e&&(d.x+=l,d.y+=r),a=m({size:d,parent:a})}const c={...Xn,...i.detail};let d=i.x*n+l,u=i.y*n+r,f=i.w*n,g=i.h*n;o.length>0&&(d=i.x*n,u=i.y*n,f=i.w*n,g=i.h*n);let v="center",y="center";"left"===c.textAlign?v="start":"right"===c.textAlign&&(v="end"),"top"===c.verticalAlign?y="start":"bottom"===c.verticalAlign&&(y="end"),s.style.display="inline-flex",s.style.justifyContent=v,s.style.alignItems=y,s.style.position="absolute",s.style.left=d-1+"px",s.style.top=u-1+"px",s.style.width=`${f+2}px`,s.style.height=`${g+2}px`,s.style.transform=`rotate(${It(i.angle||0)}deg)`,s.style.boxSizing="border-box",s.style.border="1px solid #1973ba",s.style.resize="none",s.style.overflow="hidden",s.style.wordBreak="break-all",s.style.borderRadius=("number"==typeof c.borderRadius?c.borderRadius:0)*n+"px",s.style.background=`${c.background||"transparent"}`,s.style.color=`${c.color||"#333333"}`,s.style.fontSize=c.fontSize*n+"px",s.style.lineHeight=(c.lineHeight||c.fontSize)*n+"px",s.style.fontFamily=mi(c.fontFamily),s.style.fontWeight=`${c.fontWeight}`,s.style.padding="0",s.style.margin="0",s.style.outline="none",s.innerText=c.text||"",a.appendChild(s)},p=()=>{const{left:e,top:t,width:i,height:o}=(()=>{const e=l.getBoundingClientRect(),{left:t,top:i,width:o,height:n}=e;return{left:t,top:i,width:o,height:n}})();h.style.position="absolute",h.style.overflow="hidden",h.style.top=`${t}px`,h.style.left=`${e}px`,h.style.width=`${i}px`,h.style.height=`${o}px`},w=()=>{v()},x=e=>{e.stopPropagation()},S=()=>{d&&u&&(d.detail.text=s.innerText||"",t.trigger(Ao.TEXT_CHANGE,{element:{uuid:d.uuid,detail:{text:d.detail.text}},position:[...u||[]]}),r.modifyText(d),o.drawFrame())},b=()=>{if(d&&u){d.detail.text=s.innerText||"",t.trigger(Ao.TEXT_CHANGE,{element:{uuid:d.uuid,detail:{text:d.detail.text}},position:[...u]});const e=n.getActiveStorage("data")||{elements:[]},i={detail:{text:d.detail.text}};fi(d.uuid,i,e.elements),t.trigger(Ao.CHANGE,{selectedElements:[{...d,detail:{...d.detail,...i.detail}}],data:e,type:"modifyElement",modifyRecord:{type:"modifyElement",time:Date.now(),content:{method:"modifyElement",uuid:d.uuid,before:{"detail.text":f},after:{"detail.text":d.detail.text}}}}),r.modifyText(d),o.drawFrame()}v()},A=e=>{e.stopPropagation()},I=e=>{e.stopPropagation()},M=e=>{e.stopPropagation()},z=e=>{e.stopPropagation(),e.preventDefault()};c.addEventListener("click",w),s.addEventListener("click",x),s.addEventListener("input",S),s.addEventListener("blur",b),s.addEventListener("keydown",A),s.addEventListener("keypress",I),s.addEventListener("keyup",M),s.addEventListener("wheel",z);const R=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)&&(d=e.element,u=e.position),(e=>{p(),y(e),c.style.display="block",f="",(null==d?void 0:d.uuid)&&(n.setActiveOverrideElemenentMap({[d.uuid]:{operations:{invisible:!0}}}),f=d.detail.text||"",o.drawFrame())})(e)};return{name:"@middleware/text-editor",use(){t.on(Ao.TEXT_EDIT,R)},disuse(){t.off(Ao.TEXT_EDIT,R),c.removeEventListener("click",w),s.removeEventListener("click",x),s.removeEventListener("input",S),s.removeEventListener("blur",b),s.removeEventListener("keydown",A),s.removeEventListener("keypress",I),s.removeEventListener("keyup",M),s.removeEventListener("wheel",z),h.removeChild(s),c.removeChild(h),a.removeChild(c),s.remove(),h.remove(),c=null,s=null,h=null,c=null,d=null,u=null,f=null}}},e.Sharer=mo,e.coreEventKeys=Ao,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),e}({});
|
|
1
|
+
var iDrawCore=function(e){"use strict";const t="selectInGroup",i={CURSOR:"cursor",CHANGE:"change",CHANGING:"changing",RULER:"ruler",SCALE:"scale",CREATE:"create",CLEAR_CREATE:"clearCreate",SELECT_LAYOUT:"selectLayout",SELECT:"select",CLEAR_SELECT:"clearSelect",TEXT_EDIT:"textEdit",TEXT_CHANGE:"textChange",CONTEXT_MENU:"contextMenu",SELECT_IN_GROUP:t,SNAP_TO_GRID:t,PATH_EDIT:"pathEdit",CLEAR_PATH_EDIT:"clearPathEdit",PATH_CREATE:"pathCreate",CLEAR_PATH_CREATE:"clearPathCreate",MODE_CHANGE:"modeChange"},o={};function r(e,t){if(1===t)return e;let i=1;const o=/^#[0-9a-f]{6,6}$/i;let r=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")),r=e.substring(0,7)),i*=t,o.test(r)&&i>0&&i<1){const e=Math.max(0,Math.min(255,Math.ceil(256*i)));r=`${r.toUpperCase()}${e.toString(16).toUpperCase()}`}return r}function a(e){return(65536*(1+Math.random())|0).toString(16).substring(1)}function n(){return`${a()}${a()}-${a()}-${a()}-${a()}-${a()}${a()}${a()}`}function s(e,t){let i=0;for(let t=0;t<e.length;t++)i+=e.charCodeAt(t);return(i+t).toString(16).substring(0,4)}function l(e,t){const i=e.length,o=function(e){let t=0;for(let i=0;i<e.length;i++)t+=e.charCodeAt(i);return t}(t),r=Math.floor(i/2),a=e.substring(0,4).padStart(4,"0"),n=e.substring(0,4).padStart(4,"0");return`@assets/${s(i.toString(16).padStart(4,a),o).padStart(4,"0")}${s(e.substring(r-4,r).padStart(4,a),o).padStart(4,"0")}-${s(e.substring(r-8,r-4).padStart(4,a),o).padStart(4,"0")}-${s(e.substring(r-12,r-8).padStart(4,a),o).padStart(4,"0")}-${s(e.substring(r-16,r-12).padStart(4,n),o).padStart(4,"0")}-${s(e.substring(r,r+4).padStart(4,n),o).padStart(4,"0")}${s(e.substring(r+4,r+8).padStart(4,n),o).padStart(4,"0")}${s(n.padStart(4,a).padStart(4,n),o)}`}function h(e){return/^@assets\/[0-9a-z-]{0,}$/.test(`${e}`)}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 d(e){return(Object.prototype.toString.call(e)||"").replace(/(\[object|\])/gi,"").trim()}Object.keys(i).forEach(e=>{Object.defineProperty(o,e,{value:i[e],writable:!1})});const u={type(e,t){const i=d(e);return!0===t?i.toLocaleLowerCase():i},array:e=>"Array"===d(e),json:e=>"Object"===d(e),function:e=>"Function"===d(e),asyncFunction:e=>"AsyncFunction"===d(e),boolean:e=>"Boolean"===d(e),string:e=>"String"===d(e),number:e=>"Number"===d(e),undefined:e=>"Undefined"===d(e),null:e=>"Null"===d(e),promise:e=>"Promise"===d(e)};const{Image:f}=window;function g(e){return new Promise((t,i)=>{const o=new f;o.crossOrigin="anonymous",o.onload=function(){t(o)},o.onabort=i,o.onerror=i,o.src=e})}async function m(e){const t=await(i=e,new Promise((e,t)=>{const o=new Blob([i],{type:"image/svg+xml;charset=utf-8"}),r=new FileReader;r.readAsDataURL(o),r.onload=function(t){const i=t?.target?.result;e(i)},r.onerror=function(e){t(e)}}));var i;return await g(t)}async function p(e,t){e=e.replace(/&/gi,"&");const i=await function(e,t){const{width:i,height:o}=t;return new Promise((t,r)=>{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"}),n=new FileReader;n.readAsDataURL(a),n.onload=function(e){const i=e?.target?.result;t(i)},n.onerror=function(e){r(e)}})}(e,t);return await g(i)}function y(e){return"number"==typeof e&&e>=0}function x(e){return"number"==typeof e&&(e>0||e<=0)}function v(e){return x(e)}function w(e){return x(e)}function S(e){return y(e)}function b(e){return y(e)}function A(e){return"string"==typeof e&&/^(http:\/\/|https:\/\/|\.\/|\/)/.test(`${e}`)}function M(e){return"string"==typeof e&&/^(data:image\/)/.test(`${e}`)}function I(e){return["rect","circle","text","image","svgCode","foreignObject","group"].includes(e)}const C={positiveNum:y,data:function(e){return!!(Array(e?.materials)&&e?.materials.length>=0)},material:function(e){return!!e&&(I(e?.type)&&v(e?.x)&&w(e?.y)&&S(e?.w)&&b(e?.h))},layout:function(e){return!!e&&(v(e?.x)&&w(e?.y)&&S(e?.w)&&b(e?.h))},type:I,x:v,y:w,width:S,height:b,angle:function(e){return"number"==typeof e&&e>=-360&&e<=360},number:x,numberStr:function(e){return/^(-?\d+(?:\.\d+)?)$/.test(`${e}`)},strokeWidth:function(e){return y(e)||Array.isArray(e)&&y(e[0])&&y(e[1])&&y(e[2])&&y(e[3])},cornerRadius:function(e){return y(e)||Array.isArray(e)&&y(e[0])&&y(e[1])&&y(e[2])&&y(e[3])},color:function(e){return"string"==typeof(t=e)&&(/^#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(t)||/^[a-z]{1,}$/i.test(t));var t},imageSrc:function(e){return M(e)||A(e)},imageURL:A,imageBase64:M,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 x(e)&&e>0},lineHeight:function(e){return x(e)&&e>0},textAlign:function(e){return["center","left","right"].includes(e)},fontFamily:function(e){return"string"==typeof e&&e.length>0},fontWeight:function(e){return["bold"].includes(e)}};class R{#e;#t;constructor(e,t){this.#e=e,this.#t={devicePixelRatio:1,offscreenCanvas:null,...t},this.$resetFont()}$undoPixelRatio(e){return e/this.#t.devicePixelRatio}$doPixelRatio(e){return this.#t.devicePixelRatio*e}$getContext(){return this.#e}$setContext(e){this.#e=e}$setFont(e){const t=[];e.fontWeight&&t.push(`${e.fontWeight}`),t.push(`${this.$doPixelRatio(e.fontSize||12)}px`),t.push(`${e.fontFamily||"sans-serif"}`),this.#e.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 this.#t.offscreenCanvas}$resize(e){const{width:t,height:i,devicePixelRatio:o,resetStyle:r}=e,{canvas:a}=this.#e;a.width=t*o,a.height=i*o,this.#t={...this.#t,devicePixelRatio:o},!0===r&&(a.style.width=`${t}px`,a.style.height=`${i}px`)}$getSize(){const{devicePixelRatio:e}=this.#t,{width:t,height:i}=this.#e.canvas;return{width:t/e,height:i/e,devicePixelRatio:e}}get canvas(){return this.#e.canvas}get fillStyle(){return this.#e.fillStyle}set fillStyle(e){this.#e.fillStyle=e}get strokeStyle(){return this.#e.strokeStyle}set strokeStyle(e){this.#e.strokeStyle=e}get lineWidth(){return this.$undoPixelRatio(this.#e.lineWidth)}set lineWidth(e){this.#e.lineWidth=this.$doPixelRatio(e)}get textAlign(){return this.#e.textAlign}set textAlign(e){this.#e.textAlign=e}get textBaseline(){return this.#e.textBaseline}set textBaseline(e){this.#e.textBaseline=e}get globalAlpha(){return this.#e.globalAlpha}set globalAlpha(e){this.#e.globalAlpha=e}get shadowColor(){return this.#e.shadowColor}set shadowColor(e){this.#e.shadowColor=e}get shadowOffsetX(){return this.$undoPixelRatio(this.#e.shadowOffsetX)}set shadowOffsetX(e){this.#e.shadowOffsetX=this.$doPixelRatio(e)}get shadowOffsetY(){return this.$undoPixelRatio(this.#e.shadowOffsetY)}set shadowOffsetY(e){this.#e.shadowOffsetY=this.$doPixelRatio(e)}get shadowBlur(){return this.$undoPixelRatio(this.#e.shadowBlur)}set shadowBlur(e){this.#e.shadowBlur=this.$doPixelRatio(e)}get lineCap(){return this.#e.lineCap}set lineCap(e){this.#e.lineCap=e}get lineJoin(){return this.#e.lineJoin}set lineJoin(e){this.#e.lineJoin=e}get lineDashOffset(){return this.#e.lineDashOffset}set lineDashOffset(e){this.#e.lineDashOffset=e}get miterLimit(){return this.#e.miterLimit}set miterLimit(e){this.#e.miterLimit=e}get globalCompositeOperation(){return this.#e.globalCompositeOperation}set globalCompositeOperation(e){this.#e.globalCompositeOperation=e}fill(...e){return this.#e.fill(...e)}arc(e,t,i,o,r,a){return this.#e.arc(this.$doPixelRatio(e),this.$doPixelRatio(t),this.$doPixelRatio(i),o,r,a)}rect(e,t,i,o){return this.#e.rect(this.$doPixelRatio(e),this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o))}fillRect(e,t,i,o){return this.#e.fillRect(this.$doPixelRatio(e),this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o))}clearRect(e,t,i,o){return this.#e.clearRect(this.$doPixelRatio(e),this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o))}beginPath(){return this.#e.beginPath()}closePath(){return this.#e.closePath()}lineTo(e,t){return this.#e.lineTo(this.$doPixelRatio(e),this.$doPixelRatio(t))}moveTo(e,t){return this.#e.moveTo(this.$doPixelRatio(e),this.$doPixelRatio(t))}arcTo(e,t,i,o,r){return this.#e.arcTo(this.$doPixelRatio(e),this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o),this.$doPixelRatio(r))}bezierCurveTo(e,t,i,o,r,a){return this.#e.bezierCurveTo(this.$doPixelRatio(e),this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o),this.$doPixelRatio(r),this.$doPixelRatio(a))}quadraticCurveTo(e,t,i,o){return this.#e.quadraticCurveTo(this.$doPixelRatio(e),this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o))}getLineDash(){return this.#e.getLineDash()}setLineDash(e){const t=e.map(e=>this.$doPixelRatio(e));return this.#e.setLineDash(t)}stroke(e){return e?this.#e.stroke(e):this.#e.stroke()}translate(e,t){return this.#e.translate(this.$doPixelRatio(e),this.$doPixelRatio(t))}rotate(e){return this.#e.rotate(e)}drawImage(...e){const t=e[0],i=e[1],o=e[2],r=e[3],a=e[4],n=e[e.length-4],s=e[e.length-3],l=e[e.length-2],h=e[e.length-1];return 9===e.length?this.#e.drawImage(t,this.$doPixelRatio(i),this.$doPixelRatio(o),this.$doPixelRatio(r),this.$doPixelRatio(a),this.$doPixelRatio(n),this.$doPixelRatio(s),this.$doPixelRatio(l),this.$doPixelRatio(h)):this.#e.drawImage(t,this.$doPixelRatio(n),this.$doPixelRatio(s),this.$doPixelRatio(l),this.$doPixelRatio(h))}createPattern(e,t){return this.#e.createPattern(e,t)}measureText(e){return this.#e.measureText(e)}fillText(e,t,i,o){return void 0!==o?this.#e.fillText(e,this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o)):this.#e.fillText(e,this.$doPixelRatio(t),this.$doPixelRatio(i))}strokeText(e,t,i,o){return void 0!==o?this.#e.strokeText(e,this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o)):this.#e.strokeText(e,this.$doPixelRatio(t),this.$doPixelRatio(i))}save(){this.#e.save()}restore(){this.#e.restore()}scale(e,t){this.#e.scale(e,t)}circle(e,t,i,o,r,a,n,s){this.#e.ellipse(this.$doPixelRatio(e),this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o),r,a,n,s)}ellipse(e,t,i,o,r,a,n,s){this.#e.ellipse(this.$doPixelRatio(e),this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o),r,a,n,s)}isPointInPath(e,t){return this.#e.isPointInPath(this.$doPixelRatio(e),this.$doPixelRatio(t))}clip(...e){return this.#e.clip(...e)}setTransform(e,t,i,o,r,a){return this.#e.setTransform(e,t,i,o,r,a)}getTransform(){return this.#e.getTransform()}createLinearGradient(e,t,i,o){return this.#e.createLinearGradient(this.$doPixelRatio(e),this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o))}createRadialGradient(e,t,i,o,r,a){return this.#e.createRadialGradient(this.$doPixelRatio(e),this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o),this.$doPixelRatio(r),this.$doPixelRatio(a))}createConicGradient(e,t,i){return this.#e.createConicGradient(e,this.$doPixelRatio(t),this.$doPixelRatio(i))}}function E(e){const{width:t,height:i,devicePixelRatio:o}=e,r=new OffscreenCanvas(t*o,i*o),a=r.getContext("2d").canvas.getContext("2d");return new R(a,{devicePixelRatio:o,offscreenCanvas:r})}function z(e,t){const{width:i,height:o,devicePixelRatio:r}=t,a={width:i,height:o,devicePixelRatio:r},n=e.getContext("2d"),s=E(a),l=E(a),h=E(a),c=function(e){const{width:t,height:i,ctx:o,devicePixelRatio:r}=e;let a=o;if(!a){const e=document.createElement("canvas");e.width=t*r,e.height=i*r,a=e.getContext("2d")}return new R(a,e)}({ctx:n,...a}),d=E(a);return{underlayContext:h,viewContext:s,overlayContext:l,boardContext:c,tempContext:d,drawView:()=>{const{width:e,height:t}=s.$getSize();c.clearRect(0,0,e,t),c.drawImage(h.canvas,0,0,e,t),c.drawImage(s.canvas,0,0,e,t),c.drawImage(l.canvas,0,0,e,t),h.clearRect(0,0,e,t),s.clearRect(0,0,e,t),l.clearRect(0,0,e,t)}}}class L{#i;constructor(){this.#i=new Map}on(e,t){if(this.#i.has(e)){const i=this.#i.get(e)||[];i?.push(t),this.#i.set(e,i)}else this.#i.set(e,[t])}off(e,t){if(this.#i.has(e)){const i=this.#i.get(e);if(Array.isArray(i))for(let e=0;e<i?.length;e++)if(i[e]===t){i.splice(e,1);break}this.#i.set(e,i||[])}}trigger(e,t){const i=this.#i.get(e);return!!Array.isArray(i)&&(i.forEach(e=>{e(t)}),!0)}has(e){if(this.#i.has(e)){const t=this.#i.get(e);if(Array.isArray(t)&&t.length>0)return!0}return!1}destroy(){this.clear()}clear(){this.#i.clear()}}function B(e,t){return{x:e.x+(t.x-e.x)/2,y:e.y+(t.y-e.y)/2}}class k{#o;#r;#a;constructor(e){this.#r=c(e.defaultStorage),this.#o=this.#n(),this.#a=e.defaultStatic||{}}set(e,t){this.#o[e]=t}get(e){return this.#o[e]}setStatic(e,t){this.#a[e]=t}getStatic(e){return this.#a[e]}getSnapshot(e){return!0===e?.deepClone?c(this.#o):{...this.#o}}clear(){this.#o=this.#n()}destroy(){this.#o=null,this.#a=null}#n(){return c(this.#r)}}function P(e){const{activeStore:t}=e;return{scale:t?.scale,offsetTop:t?.offsetTop,offsetBottom:t?.offsetBottom,offsetLeft:t?.offsetLeft,offsetRight:t?.offsetRight}}function T(e){const{activeStore:t}=e;return{devicePixelRatio:t.devicePixelRatio,width:t?.width,height:t?.height,contextWidth:t?.contextWidth,contextHeight:t?.contextHeight}}function N(e,t){const i={};return e&&t.forEach(t=>{const o=e?.[t];"string"!=typeof o&&"number"!=typeof o||(i[t]=o)}),i}function D(e){return e/180*Math.PI}function $(e,t,i,o){const r=D(t||0);i&&(r>0||r<0)&&(e.translate(i.x,i.y),e.rotate(r),e.translate(-i.x,-i.y)),o(e),i&&(r>0||r<0)&&(e.translate(i.x,i.y),e.rotate(-r),e.translate(-i.x,-i.y))}function H(e){return{x:e.x+e.width/2,y:e.y+e.height/2}}function W(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 H({x:t,y:i,width:Math.max(e[0].x,e[1].x,e[2].x,e[3].x)-t,height:Math.max(e[0].y,e[1].y,e[2].y,e[3].y)-i})}function O(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 V(e,t,i){let o=O(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 r=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,n=0;return 0===o?(a=0,n=0-r):o>0&&o<Math.PI/2?(a=Math.sin(o)*r,n=0-Math.cos(o)*r):o===Math.PI/2?(a=r,n=0):o>Math.PI/2&&o<Math.PI?(a=Math.sin(Math.PI-o)*r,n=Math.cos(Math.PI-o)*r):o===Math.PI?(a=0,n=r):o>Math.PI&&o<1.5*Math.PI?(a=0-Math.sin(o-Math.PI)*r,n=Math.cos(o-Math.PI)*r):o===1.5*Math.PI?(a=0-r,n=0):o>1.5*Math.PI&&o<2*Math.PI?(a=0-Math.sin(2*Math.PI-o)*r,n=0-Math.cos(2*Math.PI-o)*r):o===2*Math.PI&&(a=0,n=0-r),a+=e.x,n+=e.y,{x:a,y:n}}function Y(e,t){if(t?.length>0){let i=e.x,o=e.y;return t.forEach(e=>{const{x:t,y:r,width:a,height:n,angle:s=0}=e,l=V(H({x:t,y:r,width:a,height:n}),{x:i,y:o},D(s));i=l.x,o=l.y}),{x:i,y:o}}return e}function j(e,t,i){const{x:o,y:r,width:a,height:n}=e;let s={x:o,y:r},l={x:o+a,y:r},h={x:o+a,y:r+n},c={x:o,y:r+n};if(i&&(i>0||i<0)){const e=D(X(i));s=V(t,s,e),l=V(t,l,e),h=V(t,h,e),c=V(t,c,e)}return[s,l,h,c]}function G(e){const{angle:t=0}=e;return j(e,H(e),t)}function F(e,t,i){return[V(e,{x:t[0].x,y:t[0].y},i),V(e,{x:t[1].x,y:t[1].y},i),V(e,{x:t[2].x,y:t[2].y},i),V(e,{x:t[3].x,y:t[3].y},i)]}function X(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 Q(e){let t=!0;if(Array.isArray(e)){const i=[];e.forEach(e=>{"string"==typeof e.id&&e.id?i.includes(e.id)?(t=!1,console.warn(`Duplicate ids: ${e.id}`)):i.push(e.id):(t=!1,console.warn("Material missing id",e)),"group"===e.type&&(t=Q(e?.children))})}return t}function U(e,t){const i={x:0,y:0,width:0,height:0};e.forEach(e=>{const t={x:e.x,y:e.y,width:e.width,height:e.height,angle:e.angle};if(t.angle&&(t.angle>0||t.angle<0)){const e=G(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.width=Math.abs(Math.max(...i)-Math.min(...i)),t.height=Math.abs(Math.max(...o)-Math.min(...o))}}const o=Math.min(t.x,i.x),r=Math.min(t.y,i.y),a=Math.max(t.x+t.width,i.x+i.width),n=Math.max(t.y+t.height,i.y+i.height);i.x=o,i.y=r,i.width=Math.abs(a-o),i.height=Math.abs(n-r)}),t?.extend&&(i.x=Math.min(i.x,0),i.y=Math.min(i.y,0));const o={contextWidth:i.width,contextHeight:i.height};return t?.viewWidth&&t?.viewHeight&&t?.viewWidth>0&&t?.viewHeight>0&&(t.viewWidth>i.x+i.width&&(o.contextWidth=t.viewWidth-i.x),t.viewHeight>i.y+i.height&&(o.contextHeight=t.viewHeight-i.y)),o}function Z(e,t){const i=[];let o=null;const r=[];return function e(t,a){let n=null;for(let s=0;s<a.length;s++){const l=a[s];if(r.push(s),l.id===t){n=l,o=l;break}if(!n&&"group"===l.type){i.push(l);const o=e(t,l?.children||[]);if(o?.id===t){n=o;break}i.pop(),r.pop()}}return n}(e,t),{groupQueue:i,material:o,position:r}}function J(e,t){const i=[];let o=e;if(t.length>1)for(let e=0;e<t.length-1;e++){const r=o[t[e]];if("group"!==r?.type||!Array.isArray(r?.children))return null;i.push(r),o=r.children}return i}function K(e){const{id:t,x:i,y:o,width:r,height:a,angle:n=0}=e;return{id:t,x:i,y:o,width:r,height:a,angle:n}}function q(e,t){let i=null,o=t;for(let t=0;t<e.length;t++){const r=o[e[t]];if(t<e.length-1&&"group"===r?.type)o=r.children;else{if(t!==e.length-1)break;i=r}}return i}function _(e,t){const i=[];let o=!1;const r=t=>{for(let a=0;a<t.length&&!0!==o;a++){i.push(a);const n=t[a];if(n.id===e){o=!0;break}if("group"===n.type&&r(n?.children||[]),o)break;i.pop()}};return r(t),i}function ee(e){const{x:t,y:i,height:o,width:r}=e;return[{x:t,y:i},{x:t+r,y:i},{x:t+r,y:i+o},{x:t,y:i+o}]}function te(e){const{x:t,y:i,width:o,height:r,angle:a=0}=e;return 0===a?ee(e):j(e,H({x:t,y:i,width:o,height:r}),a)}function ie(e,t){const{groupQueue:i}=t;if(!(i.length>0))return[te(e)];const o=function(e){const t=[];let i=0,o=0;const r=[],a=[...e];for(let e=0;e<a.length;e++){const{x:n,y:s,width:l,height:h,angle:c=0}=a[e];let d;if(i+=n,o+=s,0===e){const e={x:i,y:o,width:l,height:h};d=te({x:n,y:s,width:l,height:h,angle:c}),r.push({center:H(e),angle:c,radian:D(c)})}else{d=ee({x:i,y:o,width:l,height:h});for(let e=0;e<r.length;e++){const{center:t,radian:i}=r[e];d=F(t,d,i)}const e=W(d);(c>0||c<0)&&(d=F(e,d,D(c))),r.push({center:e,angle:c,radian:D(c)})}t.push(d)}return t}([...i,e]);return o}function oe(e,t){return ie(e,t).pop()||null}function re(e,t){const{viewScaleInfo:i}=t,{id:o,x:r,y:a,width:n,height:s,angle:l}=e,{scale:h=1,offsetTop:c=0,offsetLeft:d=0}=i;return{id:o,x:r*h+d,y:a*h+c,width:n*h,height:s*h,angle:l}}function ae(e,t){const{viewScaleInfo:i}=t,{x:o,y:r}=e,{scale:a,offsetTop:n,offsetLeft:s}=i;return{x:o*a+s,y:r*a+n}}function ne(e,t){const{viewScaleInfo:i}=t,{x:o,y:r}=e,{scale:a,offsetTop:n,offsetLeft:s}=i;return{x:(o-s)/a,y:(r-n)/a}}function se(e,t){const{context2d:i,material:o,viewScaleInfo:r}=t,{angle:a=0}=o,{x:n,y:s,width:l,height:h}=re(o,{viewScaleInfo:r}),c=G({x:n,y:s,width:l,height: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){return function(e,t){const i=[t[0].x,t[1].x,t[2].x,t[3].x],o=[t[0].y,t[1].y,t[2].y,t[3].y],r=Math.min(...i),a=Math.max(...i),n=Math.min(...o),s=Math.max(...o);if(e.x>r&&e.x<a&&e.y>n&&e.y<s)return!0;return!1}(e,te(t))}function he(e,t){const{groupQueue:i}=t,o=oe(e,{groupQueue:i}),r=B(o[0],o[1]),a=B(o[1],o[2]),n=B(o[2],o[3]),s=B(o[3],o[0]),l=o[0],h=o[1],c=o[2],d=o[3],u=Math.max(l.x,h.x,c.x,d.x),f=Math.max(l.y,h.y,c.y,d.y);return{center:{x:(u+Math.min(l.x,h.x,c.x,d.x))/2,y:(f+Math.min(l.y,h.y,c.y,d.y))/2},topLeft:l,topRight:h,bottomLeft:d,bottomRight:c,top:r,right:a,left:s,bottom:n}}function ce(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),r=Math.min(e.topLeft.y,e.topRight.y,e.bottomRight.y,e.bottomLeft.y),a={x:e.center.x,y:e.center.y},n={x:o,y:r},s={x:t,y:r},l={x:t,y:i},h={x:o,y:i},c=B(n,s),d=B(h,l),u=B(n,h);return{center:a,topLeft:n,topRight:s,bottomLeft:h,bottomRight:l,top:c,right:B(s,l),left:u,bottom:d}}function de(e){let t="";return e.forEach(e=>{t+=e.type+e.params?.join?.(" ")}),t}function ue(e,t){let i=2;return void 0!==t?.decimalPlaces&&t?.decimalPlaces>=0&&(i=t.decimalPlaces),parseFloat(e.toFixed(i))}const fe="Text",ge="#787878",me=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(`<svg viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" width="200" height="200" fill="${ge}"><path d="M928 160H96c-17.7 0-32 14.3-32 32v640c0 17.7 14.3 32 32 32h832c17.7 0 32-14.3 32-32V192c0-17.7-14.3-32-32-32zM338 304c35.3 0 64 28.7 64 64s-28.7 64-64 64-64-28.7-64-64 28.7-64 64-64z m513.9 437.1c-1.4 1.2-3.3 1.9-5.2 1.9H177.2c-4.4 0-8-3.6-8-8 0-1.9 0.7-3.7 1.9-5.2l170.3-202c2.8-3.4 7.9-3.8 11.3-1 0.3 0.3 0.7 0.6 1 1l99.4 118 158.1-187.5c2.8-3.4 7.9-3.8 11.3-1 0.3 0.3 0.7 0.6 1 1l229.6 271.6c2.6 3.3 2.2 8.4-1.2 11.2z" ></path></svg>`)}`;function pe(){return{opacity:1,display:"inline",visibility:"visible",overflow:"visible",fill:ge,fillOpacity:1,fillRule:"nonzero",stroke:"#525252",strokeWidth:0,strokeOpacity:1,strokeLinecap:"butt",strokeLinejoin:"miter",strokeDasharray:[],strokeDashoffset:0,strokeMiterlimit:0,text:fe,fontSize:12,fontFamily:"system-ui",fontWeight:"normal",fontStyle:"normal",textAnchor:"start",textDecoration:"none",letterSpacing:"normal",wordSpacing:"normal",writingMode:"horizontal-tb",textAlign:"left",verticalAlign:"top",href:me}}function ye(e,t="",i={},o){return Object.keys(e).forEach(r=>{const a=t?`${t}${function(e){return/^\d+$/.test(e)&&!isNaN(Number(e))}(r)?`[${r}]`:`.${r}`}`:r;if(!o?.ignorePaths?.includes(a)){const t=e[r];!function(e){return"object"==typeof e&&null!==e&&!(e instanceof Date)||Array.isArray(e)}(t)?i[a]=t:ye(t,(Array.isArray(t),a),i,o)}}),i}function xe(e,t){return"object"!=typeof e||null===e?{"":e}:ye(e,"",{},t)}function ve(e){return xe(e,{ignorePaths:["children"]})}function we(e){return xe(e)}function Se(e){return xe(e)}function be(e){return Array.isArray(e)?[...e]:e.split(/\.|\[|\]/).filter(e=>""!==e)}function Ae(e,t,i){if(!t)return;const o=be(t);let r=e;for(const e of o){if(null==r)return i;r=r[e]}return void 0!==r?r:i}function Me(e,t,i){const o=be(t);if(0===o.length)return e;let r=e;if(r)for(let e=0;e<o.length;e++){const t=o[e];if(e===o.length-1){r[t]=i;break}if(r&&(void 0===r?.[t]||"object"!=typeof r?.[t]||null===r?.[t])){const i=o[e+1],a=/^\d+$/.test(i);r[t]=a?[]:{}}r=r?.[t]}return e}function Ie(e,t){const i=be(t);if(0===i.length)return e;let o=e;if(o)for(let e=0;e<i.length;e++){const t=i[e];if(e===i.length-1){delete o[t];break}if(o&&(void 0===o?.[t]||"object"!=typeof o?.[t]||null===o?.[t])){const r=i[e+1],a=/^\d+$/.test(r);o[t]=a?[]:{}}o=o?.[t]}return e}const Ce=e=>ue(e,{decimalPlaces:4});function Re(e,t){const i={},o={},r={type:"modifyMaterial",time:Date.now(),content:{method:"modifyMaterial",id:e.id,before:null,after:null}},{xRatio:a,yRatio:n,maxRatio:s}=t,l=(a+n)/2,{strokeWidth:h,cornerRadius:c,strokeDasharray:d,shadowOffsetX:u,shadowOffsetY:f,shadowBlur:g}=e;if("number"==typeof h)e.strokeWidth=Ce(h*l),i.strokeWidth=h,o.strokeWidth=e.strokeWidth;else if(Array.isArray(e.strokeWidth)){const t=h;e.strokeWidth=[Ce(t[0]*n),Ce(t[1]*a),Ce(t[2]*n),Ce(t[3]*a)],i.strokeWidth=[...t],o.strokeWidth=[...h]}if("number"==typeof c)e.cornerRadius=Ce(c*l),i.cornerRadius=c,o.cornerRadius=e.cornerRadius;else if(Array.isArray(e.cornerRadius)){const t=c;e.cornerRadius=[t[0]*a,t[1]*a,t[2]*n,t[3]*n],i.cornerRadius=[...t],o.cornerRadius=[...c]}return Array.isArray(d)&&(d.forEach((t,i)=>{e.strokeDasharray[i]=Ce(t*s)}),i.strokeDasharray=[...d],o.strokeDasharray=[...e.strokeDasharray]),"number"==typeof u&&(e.shadowOffsetX=Ce(u*s),i.shadowOffsetX=u,o.shadowOffsetX=e.shadowOffsetX),"number"==typeof f&&(e.shadowOffsetY=Ce(f*s),i.shadowOffsetY=f,o.shadowOffsetY=e.shadowOffsetY),"number"==typeof g&&(e.shadowBlur=Ce(g*s),i.shadowBlur=g,o.shadowBlur=e.shadowBlur),r.content.before=ve(i),r.content.after=ve(o),r}function Ee(e,t,i){const{type:o,id:r}=e,a=function(e,t){const{xRatio:i,yRatio:o}=t,{id:r,x:a,y:n,width:s,height:l}=e;e.x=Ce(a*i),e.y=Ce(n*o),e.width=Ce(s*i),e.height=Ce(l*o);const h={type:"modifyMaterial",time:Date.now(),content:{method:"modifyMaterial",id:r,before:{x:a,y:n,width:s,height:l},after:{x:e.x,y:e.y,width:e.width,height:e.height}}},c=Re(e,t);return h.content.before={...h.content.before,...c.content.before},h.content.after={...h.content.after,...c.content.after},h}(e,t),n={...a.content.before,id:r},s={...a.content.after,id:r};if(i?.content.before.push(n),i?.content.after.push(s),"circle"===o);else if("text"===o){const i=function(e,t){const{minRatio:i,maxRatio:o}=t,{fontSize:r,lineHeight:a}=e,n=(i+o)/2,s={},l={};return r&&r>0&&(e.fontSize=Ce(r*n),s.fontSize=r,l.fontSize=e.fontSize),a&&a>0&&(e.lineHeight=Ce(a*n),s.lineHeight=a,l.lineHeight=e.lineHeight),{type:"modifyMaterial",time:Date.now(),content:{method:"modifyMaterial",id:e.id,before:s,after:l}}}(e,t);Object.keys(i.content.before||{}).forEach(e=>{n[e]=i.content.before?.[e]}),Object.keys(i.content.after||{}).forEach(e=>{s[e]=i.content.after?.[e]})}else"image"===o||"svgCode"===o||"foreignObject"===o||"path"===o||"group"===o&&Array.isArray(e.children)&&e.children.forEach(e=>{Ee(e,t,i)})}function ze(e,t,i){const o={type:"resizeMaterials",time:Date.now(),content:{method:"modifyMaterials",before:[],after:[]}},r=e.id,a=e.x,n=e.y,s=e.width,l=e.height,h=u.number(t.x)?t.x:e.x,c=u.number(t.y)?t.y:e.y,d=(t.width&&t.width>0?t.width:e.width)||0,f=(t.height&&t.height>0?t.height:e.height)||0,g={id:r,x:a,y:n,width:s,height:l},m={id:r,x:h,y:c,width:d,height:f};if("deepResize"===i?.resizeEffect){o.content.before.push(g),o.content.after.push(m);const t=d/e.width,i=f/e.height;if(t===i&&1===t)return o;const r=Math.min(t,i),a=Math.max(t,i);e.width=d,e.height=f;const n={xRatio:t,yRatio:i,minRatio:r,maxRatio:a};"group"===e.type&&Array.isArray(e.children)&&e.children.forEach(e=>{Ee(e,n,o)});const s=Re(e,n);return Object.keys(s.content.before||{}).forEach(e=>{g[e]=s.content.before?.[e]}),Object.keys(s.content.after||{}).forEach(e=>{m[e]=s.content.after?.[e]}),o}if("fixed"===i?.resizeEffect){o.content.before.push(g),o.content.after.push(m);const t=h-e.x,i=c-e.y,r=d-e.width;return function(e,t,i){if("group"!==e.type||!Array.isArray(e.children))return;const{moveX:o,moveY:r,moveH:a,moveW:n}=t;let s=0,l=0,h=!1;0===o&&0===r||0===a&&0===n||(h=!0,s=-o,l=-r),!0===h&&e.children.forEach(e=>{const{id:t,x:o,y:r}=e,a=o+s,n=r+l,h={id:t,x:o,y:r},c={id:t,x:a,y:n};e.x=a,e.y=n,i?.content.before.push(h),i?.content.after.push(c)})}(e,{moveX:t,moveY:i,moveH:f-e.height,moveW:r},o),e.width=d,e.height=f,e.x=h,e.y=c,o}return e.width=d,e.height=f,e.x=h,e.y=c,o.content.before.push(g),o.content.after.push(m),o}function Le(e,t,i){const o=function(e,t){let i=0,o=0,r=200,a=200;if(t){const{viewScaleInfo:n,viewSizeInfo:s}=t,{scale:l,offsetLeft:h,offsetTop:c}=n,{width:d,height:u}=s,f=d/4,g=u/4;r=200>=f?f/l:200/l,a=200>=g?g/l:200/l,["circle","svgCode","image"].includes(e)?r=a=Math.max(r,a):"text"===e&&(a=r/4*2),i=(0-h+d/2-r*l/2)/l,o=(0-c+u/2-a*l/2)/l}return{x:i,y:o,width:r,height:a}}(e,i);let r={};if("rect"===e)r={fill:pe().fill};else if("circle"===e)r={fill:pe().fill,cx:200,cy:200,r:100};else if("text"===e)r=function(e){const t=pe();return{text:fe,fill:t.fill,fontFamily:t.fontFamily,fontWeight:t.fontWeight,fontSize:e.width/4,textAlign:"center",verticalAlign:"middle"}}(o);else if("svgCode"===e)r={code:`<svg t="1701004189871" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" width="200" height="200"><path d="M908.1 353.1l-253.9-36.9L540.7 86.1c-3.1-6.3-8.2-11.4-14.5-14.5-15.8-7.8-35-1.3-42.9 14.5L369.8 316.2l-253.9 36.9c-7 1-13.4 4.3-18.3 9.3-12.3 12.7-12.1 32.9 0.6 45.3l183.7 179.1-43.4 252.9c-1.2 6.9-0.1 14.1 3.2 20.3 8.2 15.6 27.6 21.7 43.2 13.4L512 754l227.1 119.4c6.2 3.3 13.4 4.4 20.3 3.2 17.4-3 29.1-19.5 26.1-36.9l-43.4-252.9 183.7-179.1c5-4.9 8.3-11.3 9.3-18.3 2.7-17.5-9.5-33.7-27-36.3zM664.8 561.6l36.1 210.3L512 672.7 323.1 772l36.1-210.3-152.8-149L417.6 382 512 190.7 606.4 382l211.2 30.7-152.8 148.9z" fill="${ge}"></path></svg>`};else if("image"===e)r={href:me};else if("group"===e){r={children:[],fill:pe().fill,overflow:"hidden"};const e=t;Array.isArray(e.children)&&e.children.length>0&&(r.children=[...e.children])}return{id:n(),type:e,...o,...r,...t}}function Be(e,t,i){let o=!1;if(1===t.length){const r=t[0];i.splice(r,0,e),o=!0}else if(t.length>1){let r=i;for(let i=0;i<t.length;i++){const a=r[t[i]];if(i===t.length-1){const a=t[i];r.splice(a,0,e),o=!0}else{if(!(i<t.length-1&&"group"===a.type))break;r=a.children}}}return o}function ke(e,t){let i=!1;if(1===e.length){const o=e[0];t.splice(o,1),i=!0}else if(e.length>1){let o=t;for(let t=0;t<e.length;t++){const r=o[e[t]];if(t===e.length-1){const r=e[t];o.splice(r,1),i=!0}else{if(!(t<e.length-1&&"group"===r.type))break;o=r.children}}}return i}function Pe(e,t,i){const o=ve(t),r=["id","type"],a=Object.keys(o);if(a.forEach(t=>{if(!r.includes(t)){const i=o[t];Ie(e,t),void 0!==i&&Me(e,t,i)}}),!0===i?.onlyUpdateContent){const t=ve(e);Object.keys(t).forEach(t=>{r.includes(t)||a.includes(t)||Ie(e,t)})}return e.fill&&(e.fill=function(e){if(Array.isArray(e?.stops)){const t=[],i=e?.stops;for(let e=i.length-1;e>=0;e--){const o=i[e];o.color&&o.offset>=0||t.push(e)}t.forEach(e=>{i.splice(e,1)})}return e}(e.fill)),e}function Te(e,t,i){let o=null;for(let r=0;r<i.length;r++){const a=i[r];if(a.id===e){"group"===a.type&&a.operations?.resizeEffect&&ze(a,{...t},{resizeEffect:a.operations?.resizeEffect}),Pe(a,t),o=a;break}"group"===a.type&&(o=Te(e,t,a?.children||[]))}return o}function Ne(e,t,i,o){const r=q(e,i);return r&&("group"===r.type&&r.operations?.resizeEffect&&ze(r,{...t},{resizeEffect:r.operations?.resizeEffect}),Pe(r,t,o)),r}const De=["-apple-system",'"system-ui"',' "Segoe UI"'," Roboto",'"Helvetica Neue"',"Arial",'"Noto Sans"'," sans-serif"];function $e(e){return[e,...De].join(", ")}function He(e,t,i){let o=t.x-e.x,r=t.y-e.y;const a=[];if(i.forEach(e=>{const{x:t,y:i,width:o,height:r,angle:n=0}=e;a.push({x:t,y:i,width:o,height:r,angle:0-n})}),i?.length>0){const i=Y(e,a),n=Y(t,a);o=n.x-i.x,r=n.y-i.y}return{moveX:o,moveY:r}}function We(e,t,i,o,r,a,n,s){const l=[];l.push({x:e,y:t}),l.push({x:n,y:s});const h=Ye(3*(3*i-e-3*r+n),6*(e-2*i+r),3*(i-e));for(const c of h)if(c>0&&c<1){const h=je(c,e,i,r,n),d=je(c,t,o,a,s);l.push({x:h,y:d})}const c=Ye(3*(3*o-t-3*a+s),6*(t-2*o+a),3*(o-t));for(const h of c)if(h>0&&h<1){const c=je(h,e,i,r,n),d=je(h,t,o,a,s);l.push({x:c,y:d})}return l}function Oe(e,t,i,o,r,a){const n=[];n.push({x:e,y:t}),n.push({x:r,y:a});const s=e-2*i+r;if(0!==s){const l=-(2*(i-e))/(2*s);if(l>0&&l<1){const s=Ge(l,e,i,r),h=Ge(l,t,o,a);n.push({x:s,y:h})}}const l=t-2*o+a;if(0!==l){const s=-(2*(o-t))/(2*l);if(s>0&&s<1){const l=Ge(s,e,i,r),h=Ge(s,t,o,a);n.push({x:l,y:h})}}return n}function Ve(e,t,i,o,r,a,n,s,l){const h=[],c=r*Math.PI/180,d=Math.cos(c),u=Math.sin(c),f=(e+s)/2,g=(t+l)/2,m=(e-s)/2,p=(t-l)/2,y=d*m+u*p,x=-u*m+d*p;let v=i,w=o;const S=y*y,b=x*x,A=S/(i*i)+b/(o*o);A>1&&(v=Math.sqrt(A)*i,w=Math.sqrt(A)*o);const M=a===n?-1:1,I=Math.max(0,v*v*w*w-v*v*b-w*w*S),C=v*v*b+w*w*S;let R=M*Math.sqrt(I/C);isNaN(R)&&(R=0);const E=R*(v*x/w),z=R*(-w*y/v),L=d*E-u*z+f,B=u*E+d*z+g,k=Math.atan2((x-z)/w,(y-E)/v);let P=Math.atan2((-x-z)/w,(-y-E)/v)-k;0===n&&P>0?P-=2*Math.PI:1===n&&P<0&&(P+=2*Math.PI);for(let e=0;e<=100;e++){const t=k+e/100*P,i=L+v*Math.cos(t)*d-w*Math.sin(t)*u,o=B+v*Math.cos(t)*u+w*Math.sin(t)*d;h.push({x:i,y:o})}return h}function Ye(e,t,i){const o=[];if(0===e){if(0!==t){const e=-i/t;e>=0&&e<=1&&o.push(e)}return o}const r=t*t-4*e*i;if(r>0){const i=Math.sqrt(r),a=(-t+i)/(2*e),n=(-t-i)/(2*e);a>=0&&a<=1&&o.push(a),n>=0&&n<=1&&o.push(n)}else if(0===r){const i=-t/(2*e);i>=0&&i<=1&&o.push(i)}return o}function je(e,t,i,o,r){const a=1-e;return a*a*a*t+3*a*a*e*i+3*a*e*e*o+e*e*e*r}function Ge(e,t,i,o){const r=1-e;return r*r*t+2*r*e*i+e*e*o}const Fe=()=>Math.random().toString(36).substring(2);function Xe(){return`${Fe()}${Fe()}`.substring(0,16)}function Qe(e,t,i){const o=[];return e.forEach(e=>{const r=function(e,t,i){const{type:o}=e,r=[...e.params],a=e.id;let n={id:a};if(e.start&&e.end){const o={...e.start},r={...e.end};o.x+=t,o.y+=i,r.x+=t,r.y+=i,n={id:a,start:o,end:r}}switch(o){case"M":case"L":case"T":return r[0]+=t,r[1]+=i,{type:o,params:r,...n};case"H":return r[0]+=t,{type:o,params:r,...n};case"V":return r[0]+=i,{type:o,params:r,...n};case"C":return r[0]+=t,r[1]+=i,r[2]+=t,r[3]+=i,r[4]+=t,r[5]+=i,{type:o,params:r,...n};case"S":case"Q":return r[0]+=t,r[1]+=i,r[2]+=t,r[3]+=i,{type:o,params:r,...n};case"A":return r[5]+=t,r[6]+=i,{type:o,params:r,...n};default:return{type:o,params:r,...n}}}(e,t,i);o.push(r)}),o}function Ue(e,t,i){return e.map(e=>{const{id:o,type:r,params:a}=e,n=[];let s={id:o};if(e.start&&e.end){const r={...e.start},a={...e.end};r.x*=t,r.y*=i,a.x*=t,a.y*=i,s={id:o,start:r,end:a}}switch(r.toUpperCase()){case"M":case"L":case"T":for(let e=0;e<a.length;e+=2)n.push(a[e]*t,a[e+1]*i);break;case"C":for(let e=0;e<a.length;e+=6)n.push(a[e]*t,a[e+1]*i,a[e+2]*t,a[e+3]*i,a[e+4]*t,a[e+5]*i);break;case"S":for(let e=0;e<a.length;e+=4)n.push(a[e]*t,a[e+1]*i,a[e+2]*t,a[e+3]*i);break;case"Q":for(let e=0;e<a.length;e+=4)n.push(a[e]*t,a[e+1]*i,a[e+2]*t,a[e+3]*i);break;case"H":a.forEach(e=>n.push(e*t));break;case"V":a.forEach(e=>n.push(e*i));break;case"A":for(let e=0;e<a.length;e+=7)n.push(a[e]*t,a[e+1]*i,a[e+2],a[e+3],a[e+4],a[e+5]*t,a[e+6]*i);break;case"M":case"L":case"C":case"S":case"Q":case"T":case"A":case"H":case"V":for(let e=0;e<a.length;e++){const o="a"===r&&(e%7==0||e%7==5)||"h"===r||"v"!==r&&e%2==0;n.push(a[e]*(o?t:i))}break;default:return{type:r,params:[...a],...s}}return{type:r,params:n,...s}})}function Ze(e){const t=[];let i={x:0,y:0},o={x:0,y:0},r=null;for(const a of e){const e=a.type,n=a.params,s=e===e.toLowerCase(),l=e.toUpperCase(),h=a.id;switch(l){case"M":{const[e,a]=n,l=s?{x:i.x+e,y:i.y+a}:{x:e,y:a};t.push({id:h,type:"M",params:[l.x,l.y],start:{x:e,y:a},end:{x:e,y:a}}),i=l,o=l,r=null;break}case"L":{const[e,o]=n,a=s?{x:i.x+e,y:i.y+o}:{x:e,y:o};t.push({id:h,type:"L",params:[a.x,a.y],start:{...i},end:{...a}}),i=a,r=null;break}case"H":{const[e]=n,o=s?{x:i.x+e,y:i.y}:{x:e,y:i.y};t.push({id:h,type:"L",params:[o.x,o.y],start:{...i},end:{...o}}),i=o,r=null;break}case"V":{const[e]=n,o=s?{x:i.x,y:i.y+e}:{x:i.x,y:e};t.push({id:h,type:"L",params:[o.x,o.y],start:{...i},end:{...o}}),i=o,r=null;break}case"C":{const[e,o,a,l,c,d]=n,u=s?{x:i.x+e,y:i.y+o}:{x:e,y:o},f=s?{x:i.x+a,y:i.y+l}:{x:a,y:l},g=s?{x:i.x+c,y:i.y+d}:{x:c,y:d};t.push({id:h,type:"C",params:[u.x,u.y,f.x,f.y,g.x,g.y],start:{...i},end:{...g}}),i=g,r=f;break}case"S":{const[e,o,a,l]=n,c=r?{x:2*i.x-r.x,y:2*i.y-r.y}:i,d=s?{x:i.x+e,y:i.y+o}:{x:e,y:o},u=s?{x:i.x+a,y:i.y+l}:{x:a,y:l};t.push({id:h,type:"C",params:[c.x,c.y,d.x,d.y,u.x,u.y],start:{...i},end:{...u}}),i=u,r=d;break}case"Q":{const[e,o,a,l]=n,c=s?{x:i.x+e,y:i.y+o}:{x:e,y:o},d=s?{x:i.x+a,y:i.y+l}:{x:a,y:l};t.push({id:h,type:"C",params:[i.x+2/3*(c.x-i.x),i.y+2/3*(c.y-i.y),d.x+2/3*(c.x-d.x),d.y+2/3*(c.y-d.y),d.x,d.y],start:{...i},end:{...d}}),i=d,r=c;break}case"T":{const[e,o]=n,a=s?{x:i.x+e,y:i.y+o}:{x:e,y:o},l=r?{x:2*i.x-r.x,y:2*i.y-r.y}:i;t.push({id:h,type:"C",params:[i.x+2/3*(l.x-i.x),i.y+2/3*(l.y-i.y),a.x+2/3*(l.x-a.x),a.y+2/3*(l.y-a.y),a.x,a.y],start:{...i},end:{...a}}),i=a,r=l;break}case"A":{const[e,o,a,l,c,d,u]=n,f=s?{x:i.x+d,y:i.y+u}:{x:d,y:u};t.push({id:h,type:"A",params:[e,o,a,l,c,f.x,f.y],start:{...i},end:{...f}}),i=f,r=null;break}case"Z":t.push({id:h,type:"Z",params:[],start:{...i},end:{...o}}),i=o,r=null;break;default:throw new Error(`Unsupported command: ${e}`)}}return t}function Je(e,t){const i=t.x,o=t.y,r=e.x+(i-e.x)/3,a=e.y+(o-e.y)/3,n=e.x+2*(i-e.x)/3,s=e.y+2*(o-e.y)/3;return{id:Xe(),type:"C",params:[r,a,n,s,i,o]}}function Ke(e){let{x:t,y:i,width:o,height:r,...a}=e;const{commands:n}=a,s=function(e){let t=1/0,i=1/0,o=-1/0,r=-1/0,a={x:0,y:0},n={x:0,y:0},s=null;const l=e=>{t=Math.min(t,e.x),i=Math.min(i,e.y),o=Math.max(o,e.x),r=Math.max(r,e.y)};for(const t of e){const{type:e,params:i}=t,o=e===e.toLowerCase();switch(e.toLowerCase()){case"m":if(i.length>=2)for(let e=0;e<i.length;e+=2){let t=i[e],r=i[e+1];o&&(t+=a.x,r+=a.y),0===e&&(n={x:t,y:r}),a={x:t,y:r},l(a)}s=null;break;case"l":if(i.length>=2)for(let e=0;e<i.length;e+=2){let t=i[e],r=i[e+1];o&&(t+=a.x,r+=a.y),a={x:t,y:r},l(a)}s=null;break;case"h":for(let e=0;e<i.length;e++){let t=i[e];o&&(t+=a.x),a={x:t,y:a.y},l(a)}s=null;break;case"v":for(let e=0;e<i.length;e++){let t=i[e];o&&(t+=a.y),a={x:a.x,y:t},l(a)}s=null;break;case"c":if(i.length>=6)for(let e=0;e<i.length;e+=6){let t=i[e],r=i[e+1],n=i[e+2],h=i[e+3],c=i[e+4],d=i[e+5];o&&(t+=a.x,r+=a.y,n+=a.x,h+=a.y,c+=a.x,d+=a.y),s={x:n,y:h},We(a.x,a.y,t,r,n,h,c,d).forEach(l),l({x:c,y:d}),a={x:c,y:d}}break;case"s":if(i.length>=4)for(let e=0;e<i.length;e+=4){let t=i[e],r=i[e+1],n=i[e+2],h=i[e+3];const c=s?2*a.x-s.x:a.x,d=s?2*a.y-s.y:a.y;o&&(t+=a.x,r+=a.y,n+=a.x,h+=a.y),s={x:t,y:r},We(a.x,a.y,c,d,t,r,n,h).forEach(l),l({x:n,y:h}),a={x:n,y:h}}break;case"q":if(i.length>=4)for(let e=0;e<i.length;e+=4){let t=i[e],r=i[e+1],n=i[e+2],h=i[e+3];o&&(t+=a.x,r+=a.y,n+=a.x,h+=a.y),s={x:t,y:r},Oe(a.x,a.y,t,r,n,h).forEach(l),l({x:n,y:h}),a={x:n,y:h}}break;case"t":if(i.length>=2)for(let e=0;e<i.length;e+=2){let t=i[e],r=i[e+1];const n=s?2*a.x-s.x:a.x,h=s?2*a.y-s.y:a.y;o&&(t+=a.x,r+=a.y),s={x:n,y:h},Oe(a.x,a.y,n,h,t,r).forEach(l),l({x:t,y:r}),a={x:t,y:r}}break;case"a":if(i.length>=7)for(let e=0;e<i.length;e+=7){const t=Math.abs(i[e]),r=Math.abs(i[e+1]),n=i[e+2],h=i[e+3],c=i[e+4];let d=i[e+5],u=i[e+6];o&&(d+=a.x,u+=a.y),Ve(a.x,a.y,t,r,n,h,c,d,u).forEach(l),a={x:d,y:u},s=null}break;case"z":a={...n},l(a),s=null}}return t===1/0&&(t=i=o=r=0),{minX:t,minY:i,maxX:o,maxY:r,width:o-t,height:r-i,start:{x:t,y:i},end:{x:o,y:r}}}(n),{minX:l,minY:h,maxX:c,maxY:d}=s;return t+=l,i+=h,o=Math.abs(c-l),r=Math.abs(d-h),0===l&&0===h||(a.commands=Qe(n,0-l,0-h)),{...e,x:t,y:i,width:o,height:r,...a}}const qe={className:"class"},_e=["width","height","left","right","top","bottom","margin","marginLeft","marginRight","marginTop","marginBottom","padding","paddingLeft","paddingRight","paddingTop","paddingBottom"];function et(e,t){t.forEach(t=>{if(!t)return;t.trim().split(" ").forEach(t=>{t&&!e.classList.contains(t)&&e.classList.add(t)})})}function tt(e,t){t.forEach(t=>{t&&e.classList.contains(t)&&e.classList.remove(t)})}function it(e,t){return Object.keys(t).forEach(i=>{const o=t[i];e.style[i]=((e,t)=>"number"==typeof t&&_e.includes(e)?`${t}px`:t)(i,o)}),e}function ot(e,t,i){const{children:o,...r}=t||{},a=i||o;return function(e,t){Object.entries(t).forEach(([t,i])=>{const o=qe[t]?qe[t]:t,r=o.replace(/([A-Z])/g,"-$1").toLowerCase(),a=i;if("style"===o)u.json(i)?it(e,i):"string"==typeof i&&e.setAttribute(r,i);else if("class"===o&&"string"==typeof i)et(e,i.split(" "));else{let t=a;null==t&&(t=""),e.setAttribute(r,String(t))}})}(e,r||{}),Array.isArray(a)?a?.forEach(t=>{(t instanceof Element||"string"==typeof t)&&e.append(t)}):(a instanceof Element||"string"==typeof a)&&e.append(a),e}function rt(e,t,i){return ot(document.createElement(e),t,i)}function at(e){const t=function(e){return e.replace(/<(script|iframe|object|embed)\b[^<]*(?:(?!<\/\1>)<[^<]*)*<\/\1>/gi,"")}(e),i=document.createElement("template");i.innerHTML=t.trim();return i.content.firstElementChild}function nt(e){const t=e.getBoundingClientRect(),i=window.pageXOffset||document.documentElement.scrollLeft,o=window.pageYOffset||document.documentElement.scrollTop;return{pageX:t.left+i,pageY:t.top+o,width:t.width,height:t.height}}const st=(e,t,i)=>{let o=e;const r=Object.keys(i),a=()=>{if(!o)return!1;for(let e=0;e<r.length;e++){const t=r[e],a=i[t];if("string"==typeof t&&t&&"string"==typeof a&&a){if("className"===t&&o?.classList.contains(a))continue;if(o.getAttribute(t)===a)continue;return!1}if("string"==typeof t&&t&&"boolean"==typeof a){if(o.hasAttribute(t)&&!0===a)continue;return!1}}return!0};for(;o;){if(a())return o;if(t===o)return null;if(!t.contains(o))return null;o=o.parentElement}return null};function lt(e,t){const{$root:i,rootClassName:o}=t;if(!i)return!1;const r=e.target;return!!st(r,i,{className:o})}const ht=["width","height","left","right","top","bottom","margin","marginLeft","marginRight","marginTop","marginBottom","padding","paddingLeft","paddingRight","paddingTop","paddingBottom"],ct=(e,t)=>ht.includes(e)?`${t}px`:t;function dt(e){return e.replace(/[A-Z]/g,e=>"-"+e.toLowerCase())}function ut(e,t){const i=[],o=[];for(const r in e){let a=e[r];if("number"==typeof a&&(a=ct(r,a)),r.startsWith("@"))o.push(`${r} { ${ut(a,t)} }`);else if(r.startsWith("&")||r.startsWith(".")||r.startsWith("#")){const e=r.startsWith("&")?r.replace("&",t):`${t} ${r}`;o.push(ut(a,e))}else i.push(`${dt(r)}: ${a};`)}return[i.length?`${t} { ${i.join(" ")} }`:"",...o].filter(Boolean).join("\n")}const ft="data-idraw-style-id",gt={};function mt(e){const{styles:t,rootClassName:i,type:o}=e,r=ut(t,`.${i}`);if("element"===o){const e=document.createElement("style");e.setAttribute(ft,i),e.textContent=r;(document.head||document.body).appendChild(e)}else{const e=new CSSStyleSheet;e.replaceSync(r),gt[i]=e,document.adoptedStyleSheets=[...document.adoptedStyleSheets,e]}}function pt(e){const{rootClassName:t,type:i}=e;if("element"===i){const e=document.querySelector(`[${ft}="${t}"]`);e?.remove()}else if(gt[t]){const e=gt[t],i=document.adoptedStyleSheets.filter(t=>t!==e);document.adoptedStyleSheets=i}}const yt="data-idraw-valid-watch";function xt(e,t,i){if("string"==typeof t)return t;const{viewMaterialSize:o,viewScaleInfo:a,opacity:n=1}=i,{x:s,y:l}=o,{scale:h}=a;if("linear-gradient"===t?.type){const{start:i,end:o,stops:a}=t,c={x:s+i.x*h,y:l+i.y*h},d={x:s+o.x*h,y:l+o.y*h},u=e.createLinearGradient(c.x,c.y,d.x,d.y);return a.forEach(e=>{e.offset>=0&&e.color&&u.addColorStop(e.offset,r(e.color,n))}),u}if("radial-gradient"===t?.type){const{inner:i,outer:o,stops:a}=t,c={x:s+i.x*h,y:l+i.y*h,radius:i.radius*h},d={x:s+o.x*h,y:l+o.y*h,radius:o.radius*h},u=e.createRadialGradient(c.x,c.y,c.radius,d.x,d.y,d.radius);return a.forEach(e=>{u.addColorStop(e.offset,r(e.color,n))}),u}return"#000000"}let vt=pe();function wt(e,t,i){const{viewScaleInfo:o,viewSizeInfo:r,calculator:a}=i,{opacity:n,fill:s,fillOpacity:l,fillRule:h,stroke:c,strokeWidth:d,strokeOpacity:u,strokeLinecap:f,strokeLinejoin:g,strokeDasharray:m,strokeDashoffset:p,strokeMiterlimit:y}={...vt,...t},{scale:x,offsetLeft:v,offsetTop:w}=o,{devicePixelRatio:S}=r,b=a.getVirtualItem(t.id),{commands:A,worldCenter:M}=b,{width:I,height:R}=t;let E=A;E=Ue(E,x,x),E=Qe(E,(v+(M.x-I/2)*x)*S,(w+(M.y-R/2)*x)*S);const z=e.globalAlpha,L=de(E),B=new Path2D(L);!function(e,t,i){const{...o}=t,{viewScaleInfo:r,viewSizeInfo:a,tempContext:n,path2d:s}=i,{width:l,height:h}=a,{shadowColor:c,shadowOffsetX:d,shadowOffsetY:u,shadowBlur:f}=o;C.number(f)&&c&&(n.clearRect(0,0,n.canvas.width,n.canvas.height),n.save(),n.shadowColor=c,n.shadowOffsetX=(d||0)*r.scale,n.shadowOffsetY=(u||0)*r.scale,n.shadowBlur=(f||0)*r.scale,n.fillStyle="#ffffff",n.fill(s),n.restore(),n.save(),n.globalCompositeOperation="destination-out",n.fillStyle="#ffffff",n.fill(s),n.restore(),e.drawImage(n.canvas,0,0,l,h),n.clearRect(0,0,n.canvas.width,n.canvas.height))}(e,t,{...i,path2d:B}),St(e,t,{path2d:B,viewScaleInfo:o,viewSizeInfo:r,calculator:a,renderContent:()=>{if(s){const i=re(t,{viewScaleInfo:o});"number"==typeof l&&l>0&&(e.globalAlpha=z*l*n),e.fillStyle=xt(e,s,{viewMaterialSize:i,viewScaleInfo:o,opacity:t.opacity||1}),e.fill(B,h),e.globalAlpha=z}if("number"==typeof d&&d>0){if("number"==typeof u&&u>0&&(e.globalAlpha=z*u*n),e.lineCap=f,e.lineJoin=g,e.lineDashOffset=p,e.miterLimit=y,Array.isArray(m)){const t=m.map(e=>x*e);e.setLineDash(t)}e.lineWidth=d*x,e.strokeStyle=c,e.stroke(B),e.setLineDash([]),e.lineCap=vt.strokeLinecap,e.lineJoin=vt.strokeLinejoin,e.lineDashOffset=vt.strokeDashoffset,e.miterLimit=vt.strokeMiterlimit,e.globalAlpha=z}}})}function St(e,t,i){const{renderContent:o,calculator:r,viewScaleInfo:a,viewSizeInfo:n}=i;if("hidden"===t.overflow){let s=i.path2d;if(!s){const{scale:e,offsetLeft:i,offsetTop:o}=a,{devicePixelRatio:l}=n,h=r.getVirtualItem(t.id),{commands:c,worldCenter:d}=h,{width:u,height:f}=t;let g=c;g=Ue(g,e,e),g=Qe(g,(i+(d.x-u/2)*e)*l,(o+(d.y-f/2)*e)*l);const m=de(g);s=new Path2D(m)}e.save(),e.clip(s,"nonzero"),o?.(),e.restore()}else o?.()}function bt(e,t,i,o){const{viewScaleInfo:r,calculator:a}=i,n=a?.getVirtualItem(t.id);if(n){const{worldAngle:i,worldCenter:a}=n,s=ae(a,{viewScaleInfo:r}),{scale:l}=r;$(e,i,s,()=>{const e=t.width*l,i=t.height*l,r={x:s.x-e/2,y:s.y-i/2,width:e,height:i};o({viewWorldCenter:s,viewWorldSize:r})})}}vt=function(e,t){const i={...e};for(const e of t)delete i[e];return i}(vt,["fill"]);const At=pe();function Mt(e,t,i){if(!0===t?.operations?.invisible)return;const{width:o,height:r}=t,{scale:a}=i.viewScaleInfo;if(a<1&&(o*a<.4||r*a<.4)||0===i.parentOpacity)return;const{overrideMaterialMap:n}=i;if(!n?.[t.id]?.operations?.invisible)try{switch(t.type){case"rect":case"circle":case"ellipse":case"path":!function(e,t,i){bt(e,t,i,()=>{wt(e,t,i)})}(e,t,i);break;case"text":!function(e,t,i){const{viewScaleInfo:o,viewSizeInfo:r,calculator:a}=i,n=re(t,{viewScaleInfo:o})||t,{scale:s}=o;bt(e,t,i,({viewWorldSize:i})=>{{const l={...At,...t},{x:h,y:c}=i,d=(l.fontSize||At.fontSize)*o.scale,{opacity:u,fill:f,fillOpacity:g,stroke:m,strokeWidth:p,strokeOpacity:y,strokeLinecap:x,strokeLinejoin:v,strokeDasharray:w,strokeDashoffset:S,strokeMiterlimit:b}=l;if(d<2)return;const A=e.globalAlpha,M=a.getVirtualItem(t.id);e.textBaseline="top",e.$setFont({fontWeight:l.fontWeight,fontSize:d,fontFamily:$e(l.fontFamily)}),St(e,t,{viewScaleInfo:o,viewSizeInfo:r,calculator:a,renderContent:()=>{if(f&&("number"==typeof g&&g>0&&(e.globalAlpha=A*g*u),e.fillStyle=xt(e,f,{viewMaterialSize:n,viewScaleInfo:o,opacity:t.opacity||1}),Array.isArray(M?.textLines)&&M?.textLines?.length>0&&M?.textLines?.forEach(t=>{e.fillText(t.text,h+t.x*o.scale,c+t.y*o.scale)}),e.globalAlpha=A),"number"==typeof p&&p>0){if("number"==typeof y&&y>0&&(e.globalAlpha=A*y*u),e.lineCap=x,e.lineJoin=v,e.lineDashOffset=S,e.miterLimit=b,Array.isArray(w)){const t=w.map(e=>s*e);e.setLineDash(t)}e.lineWidth=p*s,e.strokeStyle=m,M?.textLines?.forEach(t=>{e.strokeText(t.text,h+t.x*o.scale,c+t.y*o.scale)}),e.setLineDash([]),e.lineCap=At.strokeLinecap,e.lineJoin=At.strokeLinejoin,e.lineDashOffset=At.strokeDashoffset,e.miterLimit=At.strokeMiterlimit,e.globalAlpha=A}}})}})}(e,t,i);break;case"image":!function(e,t,i){const o=i.loader.getContent(t),{viewScaleInfo:r,parentOpacity:a}=i,{x:n,y:s,width:l,height:h,angle:c}=re(t,{viewScaleInfo:r})||t,d={...t,x:n,y:s,width:l,height:h,angle:c};bt(e,t,i,()=>{if(o||i.loader.isDestroyed()||i.loader.load(t,i.materialAssets||{}),"image"===t.type&&o){e.globalAlpha=function(e){let t=1;return void 0!==e?.opacity&&e?.opacity>=0&&e?.opacity<=1&&(t=e?.opacity),t}(t)*a;const{x:i,y:r,width:n,height:s}=d,l=[0,0,0,0],h=t,{scaleMode:c,originW:u=0,originH:f=0}=h,g=e.$undoPixelRatio(u),m=e.$undoPixelRatio(f);if(e.save(),e.fillStyle="transparent",e.beginPath(),e.moveTo(i+l[0],r),e.arcTo(i+n,r,i+n,r+s,l[1]),e.arcTo(i+n,r+s,i,r+s,l[2]),e.arcTo(i,r+s,i,r,l[3]),e.arcTo(i,r,i+n,r,l[0]),e.closePath(),e.fill("nonzero"),e.clip("nonzero"),c&&f&&u){let a=0,l=0,h=g,d=m;const u=i,f=r,p=n,y=s;if(g>t.width||m>t.height)if("fill"===c){const e=Math.max(t.width/g,t.height/m),i=m*e;a=(g*e-t.width)/2/e,l=(i-t.height)/2/e,h=t.width/e,d=t.height/e}else if("tile"===c)a=0,l=0,h=t.width,d=t.height;else if("fit"===c){const e=Math.min(t.width/g,t.height/m);a=(g-t.width/e)/2,l=(m-t.height/e)/2,h=t.width/e,d=t.height/e}e.drawImage(o,a,l,h,d,u,f,p,y)}else e.drawImage(o,i,r,n,s);e.globalAlpha=a,e.restore()}})}(e,t,i);break;case"svgCode":!function(e,t,i){const o=i.loader.getContent(t),{viewScaleInfo:r}=i,{x:a,y:n,width:s,height:l}=re(t,{viewScaleInfo:r})||t;bt(e,t,i,()=>{o||i.loader.isDestroyed()||i.loader.load(t,i.materialAssets||{}),"svgCode"===t.type&&o&&e.drawImage(o,a,n,s,l)})}(e,t,i);break;case"foreignObject":!function(e,t,i){const o=i.loader.getContent(t),{viewScaleInfo:r}=i,{x:a,y:n,width:s,height:l}=re(t,{viewScaleInfo:r})||t;bt(e,t,i,()=>{o||i.loader.isDestroyed()||i.loader.load(t,i.materialAssets||{}),"foreignObject"===t.type&&o&&e.drawImage(o,a,n,s,l)})}(e,t,i);break;case"group":{const o={...i.materialAssets||{},...t.assets||{}};!function(e,t,i){if(bt(e,t,i,()=>{wt(e,t,i)}),Array.isArray(t.children)){const{parentMaterialSize:o}=i,r={x:o.x+t.x,y:o.y+t.y,width:t.width||o.width,height:t.height||o.height,angle:t.angle},{calculator:a}=i;for(let o=0;o<t.children.length;o++){let n=t.children[o];if(n={...n,x:r.x+n.x,y:r.y+n.y},!0===i.forceDrawAll||a?.needRender(n))try{Mt(e,n,i)}catch(e){console.error(e)}}}}(e,t,{...i,materialAssets:o});break}}}catch(e){console.error(e)}}const It=pe();function Ct(e,t,i){const{materials:o=[]}=t,{parentOpacity:r}=i;for(let t=0;t<o.length;t++){const a=o[t],n={...a,attributes:{...It,...a}};if(!0===i.forceDrawAll||i.calculator?.needRender(n))try{Mt(e,n,{...i,parentOpacity:r})}catch(e){console.error(e)}}}const Rt=["image","svgCode","foreignObject"],Et=e=>{let t=null;return"image"===e.type?t=e?.href||null:"svgCode"===e.type?t=e?.code||null:"foreignObject"===e.type&&(t=e?.content||null),"string"==typeof t&&t?h(t)?t:l(t,e.id):l(`${n()}-${e.id}-${n()}-${n()}`,e.id)};class zt extends L{#s={};#l={};#h={};#c=!1;constructor(){super(),this.#d("image",async(e,t)=>{const i=t[e.href]?.value||e.href,o=await g(i);return{id:e.id,lastModified:Date.now(),content:o}}),this.#d("foreignObject",async(e,t)=>{const i=t[e.content]?.value||e.content,o=await p(i,{width:e.originW||e.width,height:e.originH||e.height});return{id:e.id,lastModified:Date.now(),content:o}}),this.#d("svgCode",async(e,t)=>{const i=t[e.code]?.value||e.code,o=await m(i);return{id:e.id,lastModified:Date.now(),content:o}})}isDestroyed(){return this.#c}reset(){!0!==this.#c&&(this.#l={},this.#h={})}resetMaterialAsset(e){if(Rt.includes(e.type)){let t=null,i=null;"image"===e.type&&"string"==typeof e?.href?i=e.href:"svgCode"===e.type&&"string"==typeof e?.code?i=e.code:"foreignObject"===e.type&&"string"==typeof e?.content&&(i=e.content),"string"==typeof i&&(this.load(e,{}),h(i)?t=i:e.id&&(t=l(i,e.id))),t&&h(t)&&(delete this.#h[t],delete this.#l[t])}}destroy(){this.#c=!0,this.clear(),this.#s=null,this.#l=null,this.#h=null}#d(e,t){this.#s[e]=t}#u(e){let t=null;return"image"===e.type?t=e?.href||null:"svgCode"===e.type?t=e?.code||null:"foreignObject"===e.type&&(t=e?.content||null),t}#f(e){return{material:e,status:"null",content:null,error:null,startTime:-1,endTime:-1,source:this.#u(e)}}#g(e){const t=Et(e.material),i=this.#h[t];this.#c||(i?i.startTime<e.startTime&&(this.#h[t]=e,this.trigger("load",{...e,countTime:e.endTime-e.startTime})):(this.#h[t]=e,this.trigger("load",{...e,countTime:e.endTime-e.startTime})))}#m(e){const t=Et(e.material),i=this.#h?.[t];this.#c||(i?i.startTime<e.startTime&&(this.#h[t]=e,this.trigger("error",{...e,countTime:e.endTime-e.startTime})):(this.#h[t]=e,this.trigger("error",{...e,countTime:e.endTime-e.startTime})))}#p(e,t){const i=this.#f(e),o=Et(e);if(this.#l[o])return;this.#l[o]=i;const r=this.#s[e.type];"function"!=typeof r||this.#c||(i.startTime=Date.now(),r(e,t).then(e=>{this.#c||(i.content=e.content,i.endTime=Date.now(),i.status="load",this.#g(i))}).catch(t=>{console.warn(`Load material source "${i.source}" fail`,t,e),i.endTime=Date.now(),i.status="error",i.error=t,this.#m(i)}))}#y(e){const t=Et(e),i=this.#l?.[t];return!(!i||"error"!==i.status||!i.source||i.source!==this.#u(e))}load(e,t){!0!==this.#c&&(this.#y(e)||Rt.includes(e.type)&&this.#p(e,t))}getContent(e){const t=Et(e);return this.#h?.[t]?.content||null}getLoadItemMap(){return this.#h}setLoadItemMap(e){this.#h=e}}function Lt(e,t){const i=t.width/2,o=t.height/2,r=e.x-i,a=e.y-o;let n=r,s=a;if("number"==typeof t.angle&&0!==t.angle){const e=t.angle*Math.PI/180,i=Math.cos(e),o=Math.sin(e);n=r*i-a*o,s=r*o+a*i}const l=s+o;return{x:n+i+t.x,y:l+t.y}}function Bt(e,t){const{groupQueue:i=[]}=t;let o=e.angle||0;i.forEach(e=>{o+=e.angle||0});return{worldCenter:function(e,t){if(!(t=[...t].reverse())||0===t.length)return{x:e.x+e.width/2,y:e.y+e.height/2};let i=e.x+e.width/2,o=e.y+e.height/2;for(let e=0;e<t.length;e++){const r=Lt({x:i,y:o},t[e]);i=r.x,o=r.y}return{x:i,y:o}}(e,i),worldAngle:X(o)}}function kt(e,t){const{dpr:i}=t;let{width:o,height:r,rx:a=0,ry:n=0}=e;const{cornerRadius:s}=e;r*=i,o*=i;const l=[];let h=0,c=0,d=0,u=0,f=0,g=0,m=0,p=0;if("number"==typeof a&&"number"==typeof n)a*=i,n*=i,h=a,c=a,d=a,u=a,f=n,g=n,m=n,p=n;else if(Array.isArray(s)&&4===s.length){const e=s.map(e=>e*i);h=e[0]||0,c=e[1]||0,d=e[2]||0,u=e[3]||0,f=e[0]||0,g=e[1]||0,m=e[2]||0,p=e[3]||0}else if("number"==typeof s){const e=s*i;h=e,c=e,d=e,u=e,f=e,g=e,m=e,p=e}const y=0+o,x=0+r;l.push({id:Xe(),type:"M",params:[0+h,0]}),c>0||g>0?(l.push({id:Xe(),type:"L",params:[y-c,0]}),l.push({id:Xe(),type:"A",params:[c,g,0,0,1,y,0+g]})):l.push({id:Xe(),type:"L",params:[y,0]}),d>0||m>0?(l.push({id:Xe(),type:"L",params:[y,x-m]}),l.push({id:Xe(),type:"A",params:[d,m,0,0,1,y-d,x]})):l.push({id:Xe(),type:"L",params:[y,x]}),u>0||p>0?(l.push({id:Xe(),type:"L",params:[0+u,x]}),l.push({id:Xe(),type:"A",params:[u,p,0,0,1,0,x-p]})):l.push({id:Xe(),type:"L",params:[0,x]}),h>0||f>0?(l.push({id:Xe(),type:"L",params:[0,0+f]}),l.push({id:Xe(),type:"A",params:[h,f,0,0,1,0+h,0]})):l.push({id:Xe(),type:"L",params:[0,0]}),l.push({id:Xe(),type:"Z",params:[]});return{...Bt(e,t),commands:l}}const Pt=pe();function Tt(e,t,i){return e>=t}function Nt(e,t){let i=null;switch(e.type){case"rect":case"group":i=kt(e,t);break;case"circle":i=function(e,t){const{dpr:i}=t,{width:o,height:r}=e;let{r:a}=e;const n=o/2*i,s=r/2*i;a*=i;const l=.55228475*a,h=[{type:"M",params:[n+a,s]},{type:"C",params:[n+a,s-l,n+l,s-a,n,s-a]},{type:"C",params:[n-l,s-a,n-a,s-l,n-a,s]},{type:"C",params:[n-a,s+l,n-l,s+a,n,s+a]},{type:"C",params:[n+l,s+a,n+a,s+l,n+a,s]},{type:"Z",params:[]}];return{...Bt(e,t),commands:h}}(e,t);break;case"ellipse":i=function(e,t){const{dpr:i}=t,{width:o,height:r}=e;let{rx:a,ry:n}=e;const s=o/2*i,l=r/2*i;a*=i,n*=i;const h=.55228475*a,c=.55228475*n,d=[{type:"M",params:[s+a,l]},{type:"C",params:[s+a,l-c,s+h,l-n,s,l-n]},{type:"C",params:[s-h,l-n,s-a,l-c,s-a,l]},{type:"C",params:[s-a,l+c,s-h,l+n,s,l+n]},{type:"C",params:[s+h,l+n,s+a,l+c,s+a,l]},{type:"Z",params:[]}];return{...Bt(e,t),commands:d}}(e,t);break;case"text":i=function(e,t){const{width:i,height:o}=e,r=t.tempContext,a=[],n={...Pt,...e},s=n.fontSize||Pt.fontSize,l=s,h=kt(e,t);if(l<2)return{...h,textLines:[]};const c=n.lineHeight||s;r.textBaseline="top",r.$setFont({fontWeight:n.fontWeight,fontSize:l,fontFamily:$e(n.fontFamily)});let d=n.text.replace(/\r\n/gi,"\n");"lowercase"===n.textTransform?d=d.toLowerCase():"uppercase"===n.textTransform&&(d=d.toUpperCase());const u=c,f=d.split("\n");let g=0;f.forEach((e,t)=>{if("maxContent"===n.minInlineSize){const t=r.measureText(e);a.push({x:0,y:0,text:e,width:r.$undoPixelRatio(t.width)})}else{let s="",l="",h=e.split(l);if("normal"===n.wordBreak){l=" ";const t=e.split(l);h=[],t.forEach((e,i)=>{h.push(e),i<t.length-1&&h.push(l)})}if(1===h.length&&"hidden"!==n.overflow)a.push({x:0,y:0,text:h[0],width:r.$undoPixelRatio(r.measureText(h[0]).width)});else if(h.length>0){for(let e=0;e<h.length;e++){if(Tt(r.$doPixelRatio(i),r.measureText(s+h[e]).width)?s+=h[e]||"":(a.push({x:0,y:0,text:s,width:r.$undoPixelRatio(r.measureText(s).width)}),s=h[e]||"",g++),g*u>=o&&"hidden"===n.overflow){s="";break}if(h.length-1===e&&(g+1)*u<=o){a.push({x:0,y:0,text:s,width:r.$undoPixelRatio(r.measureText(s).width)}),s="",t<f.length-1&&g++;break}}s&&(a.push({x:0,y:0,text:s,width:r.$undoPixelRatio(r.measureText(s).width)}),s="")}else a.push({x:0,y:0,text:"",width:0})}});let m=0,p=0;u>l&&(p=(u-l)/2),a.length*u<o&&("top"===n.verticalAlign?m=0:"bottom"===n.verticalAlign?m+=o-a.length*u:m+=(o-a.length*u)/2);{const e=0+m;a.forEach((t,o)=>{let r=0;"center"===n.textAlign?r=0+(i-t.width)/2:"right"===n.textAlign&&(r=i-t.width+0),a[o].x=r,a[o].y=e+u*o+p})}return{...h,textLines:a}}(e,t);break;case"path":i=function(e,t){const{dpr:i}=t,o={...Bt(e,t),anchorCommands:[]},r=Ze(e.commands||[]);return o.anchorCommands=r,o.commands=Ue(e.commands,i,i),o}(e,t);break;default:i=Bt(e,t)}return i}function Dt(e,t){const{viewScaleInfo:i,viewSizeInfo:o,tempContext:r}=t,a=function(e,t){const i={},o=[],r=a=>{const n={type:a.type,isVisibleInView:!0,position:[...o]};let s=null;const l=J(e,o);s=he(a,{groupQueue:l||[]});const h={...n,boundingInfo:s,rangeBoundingInfo:C.angle(a.angle)?ce(s):s,...Nt(a,{...t,groupQueue:l||[]})};i[a.id]=h,"group"===a.type&&a.children.forEach((e,t)=>{o.push(t),r(e),o.pop()})};return e.forEach((e,t)=>{o.push(t),r(e),o.pop()}),i}(e,{tempContext:r,dpr:o.devicePixelRatio});return $t(a,{viewScaleInfo:i,viewSizeInfo:o})}function $t(e,t){const i=function(e){const{viewScaleInfo:t,viewSizeInfo:i}=e,{scale:o,offsetTop:r,offsetLeft:a}=t,{width:n,height:s}=i,l=0-a/o,h=0-r/o,c=n/o,d=s/o,u=H({x:l,y:h,width:n,height:s}),f={x:l,y:h},g={x:l+c,y:h},m={x:l,y:h+d},p={x:l+c,y:h+d},y={x:l,y:u.y},x={x:u.x,y:h},v={x:l+c,y:u.y},w={x:u.x,y:h+d};return{center:u,topLeft:f,topRight:g,bottomLeft:m,bottomRight:p,left:y,top:x,right:v,bottom:w}}(t);let o=0,r=0;return Object.keys(e).forEach(t=>{const a=e[t];a.isVisibleInView=function(e,t){const i=e.center.x,o=e.center.y,r=Math.min(e.topLeft.x,e.topRight.x,e.bottomLeft.x,e.bottomRight.x),a=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),s=Math.max(e.topLeft.y,e.topRight.y,e.bottomLeft.y,e.bottomRight.y),l=Math.abs(a-r),h=Math.abs(s-n),c=Math.min(t.topLeft.x,t.topRight.x,t.bottomLeft.x,t.bottomRight.x)-l,d=Math.max(t.topLeft.x,t.topRight.x,t.bottomLeft.x,t.bottomRight.x)+l,u=Math.min(t.topLeft.y,t.topRight.y,t.bottomLeft.y,t.bottomRight.y)-h,f=Math.max(t.topLeft.y,t.topRight.y,t.bottomLeft.y,t.bottomRight.y)+h;return i>=c&&i<=d&&o>=u&&o<=f}(a.rangeBoundingInfo,i),a.isVisibleInView?o++:r++}),{virtualItemMap:e,visibleCount:o,invisibleCount:r}}class Ht{#t;#x;constructor(e){this.#t=e,this.#x=new k({defaultStorage:{virtualItemMap:{},visibleCount:0,invisibleCount:0}})}toGridNum(e,t){return!0===t?.ignore?e:Math.round(e)}destroy(){this.#t=null}needRender(e){const t=this.#x.get("virtualItemMap")[e.id];return!t||t.isVisibleInView}forceVisiable(e){const t=this.#x.get("virtualItemMap")[e];t&&(t.isVisibleInView=!0)}getPointMaterial(e,t){return function(e,t){const{context2d:i,data:o,viewScaleInfo:r,groupQueue:a}=t,n={index:-1,material:null,groupQueueIndex:-1};if(a&&Array.isArray(a)&&a?.length>0)for(let t=a.length-1;t>=0;t--){let o=0,s=0,l=0;for(let e=0;e<=t;e++)o+=a[e].x,s+=a[e].y,l+=a[e].angle||0;const h=a[t];if(h&&"group"===h.type&&Array.isArray(h?.children))for(let c=0;c<h.children.length;c++){const d=h.children[c];if(!0!==d?.operations?.invisible){if(!d)break;if(se(e,{context2d:i,material:{x:o+d.x,y:s+d.y,width:d.width,height:d.height,angle:l+(d.angle||0)},viewScaleInfo:r})){n.material=d,(t<a.length-1||"group"!==d.type)&&(n.groupQueueIndex=t);break}}}if(n.material)break}if(n.material)return n;for(let t=o.materials.length-1;t>=0;t--){const a=o.materials[t];if(!0!==a?.operations?.invisible&&se(e,{context2d:i,material:a,viewScaleInfo:r})){n.index=t,n.material=a;break}}return n}(e,{...t,context2d:this.#t.tempContext})}resetVirtualItemMap(e,t){if(e){const{virtualItemMap:i,invisibleCount:o,visibleCount:r}=Dt(e.materials,{...t,tempContext:this.#t.tempContext});this.#x.set("virtualItemMap",i),this.#x.set("invisibleCount",o),this.#x.set("visibleCount",r)}}updateVisiableStatus(e){const{virtualItemMap:t,invisibleCount:i,visibleCount:o}=$t(this.#x.get("virtualItemMap"),e);this.#x.set("virtualItemMap",t),this.#x.set("invisibleCount",i),this.#x.set("visibleCount",o)}calcViewBoundingInfoFromOrigin(e,t){const i=this.#x.get("virtualItemMap")[e];if(!i?.boundingInfo)return null;const{checkVisible:o,viewScaleInfo:r,viewSizeInfo:a}=t,{center:n,left:s,right:l,bottom:h,top:c,topLeft:d,topRight:u,bottomLeft:f,bottomRight:g}=i.boundingInfo;if(!0===o&&!1===i.isVisibleInView)return null;const m={viewScaleInfo:r};return{center:ae(n,m),left:ae(s,m),right:ae(l,m),bottom:ae(h,m),top:ae(c,m),topLeft:ae(d,m),topRight:ae(u,m),bottomLeft:ae(f,m),bottomRight:ae(g,m)}}calcViewBoundingInfoFromRange(e,t){const i=this.#x.get("virtualItemMap")[e];if(!i?.boundingInfo)return null;const{checkVisible:o,viewScaleInfo:r,viewSizeInfo:a}=t,{center:n,left:s,right:l,bottom:h,top:c,topLeft:d,topRight:u,bottomLeft:f,bottomRight:g}=i.rangeBoundingInfo;if(!0===o&&!1===i.isVisibleInView)return null;const m={viewScaleInfo:r};return{center:ae(n,m),left:ae(s,m),right:ae(l,m),bottom:ae(h,m),top:ae(c,m),topLeft:ae(d,m),topRight:ae(u,m),bottomLeft:ae(f,m),bottomRight:ae(g,m)}}modifyVirtualAttributes(e,t){const{viewSizeInfo:i,groupQueue:o}=t,r=this.#x.get("virtualItemMap"),a=r[e.id],n=Nt(e,{tempContext:this.#t.tempContext,dpr:i.devicePixelRatio,groupQueue:o});if(n){const t=he(e,{groupQueue:o}),i={...a,...n,boundingInfo:t,rangeBoundingInfo:C.angle(e.angle)?ce(t):t};r[e.id]=i,this.#x.set("virtualItemMap",r)}}modifyVirtualItemMap(e,t){const{modifyInfo:i,viewScaleInfo:o,viewSizeInfo:r}=t,{type:a,content:n}=i,s=e.materials,l=this.#x.get("virtualItemMap");if("deleteMaterial"===a){const{material:e}=n,t=[],i=e=>{t.push(e.id),"group"===e.type&&Array.isArray(e.children)&&e.children.forEach(e=>{i(e)})};i(e),t.forEach(e=>{delete l[e]}),this.#x.set("virtualItemMap",l)}else if("addMaterial"===a||"updateMaterial"===a){const{position:t}=n,i=q(t,e.materials),h=J(s,t);if(i)if("updateMaterial"===a&&"group"===i.type)this.resetVirtualItemMap(e,{viewScaleInfo:o,viewSizeInfo:r});else{const e=he(i,{groupQueue:h||[]}),n={type:i.type,boundingInfo:e,rangeBoundingInfo:C.angle(i.angle)?ce(e):e,isVisibleInView:!0,position:[...t],...Nt(i,{tempContext:this.#t.tempContext,dpr:r.devicePixelRatio,groupQueue:h||[]})};l[i.id]=n,this.#x.set("virtualItemMap",l),"updateMaterial"===a&&this.updateVisiableStatus({viewScaleInfo:o,viewSizeInfo:r})}}else"moveMaterial"===a&&this.resetVirtualItemMap(e,{viewScaleInfo:o,viewSizeInfo:r})}getVirtualItem(e){return this.#x.get("virtualItemMap")[e]||null}}class Wt extends L{#t;#v=new zt;#w;#c=!1;constructor(e){super(),this.#t=e,this.#w=new Ht({tempContext:e.tempContext}),this.#S()}isDestroyed(){return this.#c}destroy(){this.clear(),this.#t=null,this.#v.destroy(),this.#v=null,this.#c=!0}#S(){const e=this.#v;e.on("load",e=>{this.trigger("load",e)}),e.on("error",e=>{console.error(e)})}updateOptions(e){this.#t=e}drawData(e,t){const i=this.#v,o=this.#w,{sharer:r}=this.#t,a=this.#t.viewContext;a.clearRect(0,0,a.canvas.width,a.canvas.height);const n={x:0,y:0,width:t.viewSizeInfo.width,height:t.viewSizeInfo.height};!0===t.forceDrawAll&&this.#w.resetVirtualItemMap(e,{viewScaleInfo:t.viewScaleInfo,viewSizeInfo:t.viewSizeInfo});const s={loader:i,calculator:o,parentMaterialSize:n,materialAssets:e.assets,parentOpacity:1,overrideMaterialMap:r?.getActiveOverrideMaterialMap(),tempContext:this.#t.tempContext,...t};!function(e,t,i){if("string"==typeof t?.fill){const{viewSizeInfo:o}=i,{width:r,height:a}=o;e.globalAlpha=1,e.fillStyle=t.fill,e.fillRect(0,0,r,a)}}(a,e.global,s),e.layout?function(e,t,i,o){const{parentOpacity:r}=i;e.globalAlpha=1;const{viewScaleInfo:a}=i,n={id:"layout",type:"group",...t},s=re(n,{viewScaleInfo:a})||n,l={...n,...s},{x:h,y:c,width:d,height:u,fill:f}=l,g=[0,0,0,0];e.save(),e.fillStyle=xt(e,f,{viewMaterialSize:s,viewScaleInfo:a,opacity:n.opacity||1}),e.beginPath(),e.moveTo(h+g[0],c),e.arcTo(h+d,c,h+d,c+u,g[1]),e.arcTo(h+d,c+u,h,c+u,g[2]),e.arcTo(h,c+u,h,c,g[3]),e.arcTo(h,c,h+d,c,g[0]),e.closePath(),e.fill("nonzero"),"hidden"===t.overflow&&e.clip("nonzero"),o(e),"hidden"===t.overflow&&e.restore(),e.globalAlpha=r}(a,e.layout,s,()=>{Ct(a,e,s)}):Ct(a,e,s)}scale(e){const{sharer:t}=this.#t;if(!t)return;const{data:i,offsetTop:o,offsetBottom:r,offsetLeft:a,offsetRight:n,width:s,height:l,contextHeight:h,contextWidth:c,devicePixelRatio:d}=t.getActiveStoreSnapshot();i&&this.drawData(i,{viewScaleInfo:{scale:e,offsetTop:o,offsetBottom:r,offsetLeft:a,offsetRight:n},viewSizeInfo:{width:s,height:l,contextHeight:h,contextWidth:c,devicePixelRatio:d}})}setLoadItemMap(e){this.#v.setLoadItemMap(e)}getLoadItemMap(){return this.#v.getLoadItemMap()}getLoader(){return this.#v}getCalculator(){return this.#w}}function Ot(e){return e>0||e<0||0===e}class Vt extends L{#t;#x;#c=!1;constructor(e){super();const t=new k({defaultStorage:{hasPointDown:!1,inCanvas:!0}});this.#x=t,this.#t=e,this.#S()}#S(){this.onEvents()}onEvents(){if(!0===this.#t.disabled)return;if(this.#c)return;const e=window,t=this.#t?.container||this.#t.boardContent.boardContext.canvas;e.addEventListener("mousemove",this.#b),e.addEventListener("mouseup",this.#A),t.addEventListener("mousemove",this.#M),t.addEventListener("mousedown",this.#I),t.addEventListener("wheel",this.#C,{passive:!1}),t.addEventListener("click",this.#R),t.addEventListener("contextmenu",this.#E),t.addEventListener("dblclick",this.#z)}offEvents(){if(!0===this.#t.disabled)return;const e=window,t=this.#t?.container||this.#L();e.removeEventListener("mousemove",this.#b),e.removeEventListener("mouseup",this.#A),t.removeEventListener("mousemove",this.#M),t.removeEventListener("mousedown",this.#I),t.removeEventListener("wheel",this.#C),t.removeEventListener("click",this.#R),t.removeEventListener("contextmenu",this.#E),t.removeEventListener("dblclick",this.#z)}destroy(){this.offEvents(),this.#x.destroy(),this.#c=!0}#L(){return this.#t.boardContent.boardContext.canvas}#C=e=>{const t=e;if(!this.#B(e))return;const i=this.#k(e);if(!this.#P(i))return;e.preventDefault(),e.stopPropagation();const o=e.deltaX>0||e.deltaX<0?e.deltaX:0,r=e.deltaY>0||e.deltaY<0?e.deltaY:0;!0===e.ctrlKey&&this.has("wheelScale")?this.trigger("wheelScale",{deltaX:o,deltaY:r,point:i,nativeEvent:t}):this.has("wheel")&&this.trigger("wheel",{deltaX:o,deltaY:r,point:i,nativeEvent:t})};#E=e=>{const t=e;if(2!==e.button)return;if(!this.#B(e))return;e.preventDefault();const i=this.#k(e);this.#P(i)&&this.trigger("contextMenu",{point:i,nativeEvent:t})};#R=e=>{const t=e;if(!this.#B(e))return;e.preventDefault();const i=this.#k(e);this.#P(i)&&this.trigger("click",{point:i,nativeEvent:t})};#z=e=>{const t=e;if(!this.#B(e))return;e.preventDefault();const i=this.#k(e);this.#P(i)&&this.trigger("doubleClick",{point:i,nativeEvent:t})};#T=e=>{const t=e;this.#x.set("hasPointDown",!1),e.preventDefault();const i=this.#k(e);this.trigger("pointLeave",{point:i,nativeEvent:t})};#A=e=>{const t=e;if(this.#x.set("hasPointDown",!1),!this.#B(e))return;e.preventDefault();const i=this.#k(e);this.trigger("pointEnd",{point:i,nativeEvent:t})};#b=e=>{const t=e;if(!this.#B(e))return;e.preventDefault(),e.stopPropagation();const i=this.#k(e);this.#P(i)?!0===this.#x.get("hasPointDown")&&this.trigger("pointMove",{point:i,nativeEvent:t}):this.#x.get("hasPointDown")&&(this.trigger("pointLeave",{point:i,nativeEvent:t}),this.#x.set("hasPointDown",!1))};#I=e=>{const t=e;if(0!==e.button)return;if(!this.#B(e))return;e.preventDefault();const i=this.#k(e);this.#P(i)&&(this.#x.set("hasPointDown",!0),this.trigger("pointStart",{point:i,nativeEvent:t}))};#M=e=>{const t=e;if(!this.#B(e))return void(!0===this.#x.get("inCanvas")&&(this.#x.set("inCanvas",!1),this.#T(e)));this.#x.set("inCanvas",!0),e.preventDefault();const i=this.#k(e);this.#P(i)&&this.trigger("hover",{point:i,nativeEvent:t})};#B(e){const t=e.target;if("true"===t.getAttribute(yt))return!0;if(t!==this.#L())return!1;const i=nt(this.#t.boardContent.boardContext.canvas);return e.pageX>=i.pageX&&e.pageX<=i.pageX+i.width&&e.pageY>=i.pageY&&e.pageY<=i.pageY+i.height}#k(e){const t=this.#t.boardContent.boardContext.canvas.getBoundingClientRect();return{x:e.clientX-t.left,y:e.clientY-t.top,t:Date.now()}}#P(e){const t=this.#t.sharer.getActiveViewSizeInfo(),{width:i,height:o}=t;return!!(Ot(e.x)&&Ot(e.y)&&e.x<=i&&e.y<=o)}}const Yt={width:0,height:0,devicePixelRatio:1,contextWidth:0,contextHeight:0,data:{materials:[]},scale:1,offsetLeft:0,offsetRight:0,offsetTop:0,offsetBottom:0,overrideMaterialMap:null};class jt{#N;#D;constructor(){const e=new k({defaultStorage:Yt}),t=new k({defaultStorage:{}});this.#N=e,this.#D=t}getActiveStorage(e){return this.#N.get(e)}setActiveStorage(e,t){return this.#N.set(e,t)}getActiveStoreSnapshot(e){return this.#N.getSnapshot(e)}getSharedStorage(e){return this.#D.get(e)}setSharedStorage(e,t){return this.#D.set(e,t)}getSharedStoreSnapshot(e){return this.#D.getSnapshot(e)}getActiveViewScaleInfo(){return{scale:this.#N.get("scale"),offsetTop:this.#N.get("offsetTop"),offsetBottom:this.#N.get("offsetBottom"),offsetLeft:this.#N.get("offsetLeft"),offsetRight:this.#N.get("offsetRight")}}setActiveViewScaleInfo(e){const{scale:t,offsetTop:i,offsetBottom:o,offsetLeft:r,offsetRight:a}=e;this.#N.set("scale",t),this.#N.set("offsetTop",i),this.#N.set("offsetBottom",o),this.#N.set("offsetLeft",r),this.#N.set("offsetRight",a)}setActiveViewSizeInfo(e){this.#N.set("width",e.width),this.#N.set("height",e.height),this.#N.set("devicePixelRatio",e.devicePixelRatio),this.#N.set("contextWidth",e.contextWidth),this.#N.set("contextHeight",e.contextHeight)}getActiveViewSizeInfo(){return{width:this.#N.get("width"),height:this.#N.get("height"),devicePixelRatio:this.#N.get("devicePixelRatio"),contextWidth:this.#N.get("contextWidth"),contextHeight:this.#N.get("contextHeight")}}getActiveOverrideMaterialMap(){return this.#N.get("overrideMaterialMap")}setActiveOverrideMaterialMap(e){this.#N.set("overrideMaterialMap",e)}}const{requestAnimationFrame:Gt}=window;class Ft extends L{#t;#$=[];#H="FREE";constructor(e){super(),this.#t=e,this.#S()}#S(){const{renderer:e}=this.#t;e.on("load",()=>{this.drawFrame()})}#W(){if("DRAWING"===this.#H||0===this.#$.length)return;this.#H="DRAWING";const e=this.#$.shift(),{renderer:t,boardContent:i,beforeDrawFrame:o,afterDrawFrame:r}=this.#t;if(e){const{scale:a,offsetTop:n,offsetBottom:s,offsetLeft:l,offsetRight:h,width:c,height:d,contextHeight:u,contextWidth:f,devicePixelRatio:g}=e.activeStore,m={scale:a,offsetTop:n,offsetBottom:s,offsetLeft:l,offsetRight:h},p={width:c,height:d,contextHeight:u,contextWidth:f,devicePixelRatio:g};e?.activeStore.data&&t.drawData(e.activeStore.data,{viewScaleInfo:m,viewSizeInfo:p}),o({snapshot:e}),i.drawView(),r({snapshot:e})}0!==this.#$.length?"DRAWING"===this.#H&&Gt(()=>{this.#W()}):this.#H="COMPLETE"}resetVirtualItemMap(e,t){e&&this.#t.calculator.resetVirtualItemMap(e,t)}drawFrame(){const{sharer:e}=this.#t,t=e.getActiveStoreSnapshot(),i=e.getSharedStoreSnapshot();this.#$.push({activeStore:t,sharedStore:i}),this.#W()}scale(e){const{scale:t,point:i,ignoreUpdateVisibleStatus:o}=e,{sharer:r}=this.#t,{moveX:a,moveY:n}=function(e){const{scale:t,point:i,viewScaleInfo:o}=e,{offsetLeft:r,offsetTop:a}=o,n=t/o.scale,s=i.x,l=i.y;return{moveX:s-s*n+(r*n-r),moveY:l-l*n+(a*n-a)}}({scale:t,point:i,viewScaleInfo:r.getActiveViewScaleInfo(),viewSizeInfo:r.getActiveViewSizeInfo()});return r.setActiveStorage("scale",t),o||this.#t.calculator.updateVisiableStatus({viewScaleInfo:r.getActiveViewScaleInfo(),viewSizeInfo:r.getActiveViewSizeInfo()}),{moveX:a,moveY:n}}scroll(e){const{sharer:t}=this.#t,i=t.getActiveViewScaleInfo(),{moveX:o,moveY:r,ignoreUpdateVisibleStatus:a}=e,n=function(e){const{moveX:t=0,moveY:i=0,viewScaleInfo:o,viewSizeInfo:r}=e,{scale:a}=o,{width:n,height:s,contextWidth:l,contextHeight:h}=r;let c=o.offsetLeft,d=o.offsetRight,u=o.offsetTop,f=o.offsetBottom;return c+=t,u+=i,d=n-(l*a+c),f=s-(h*a+u),{scale:a,offsetTop:u,offsetLeft:c,offsetRight:d,offsetBottom:f}}({moveX:o,moveY:r,viewScaleInfo:i,viewSizeInfo:t.getActiveViewSizeInfo()});return t.setActiveViewScaleInfo(n),a||this.#t.calculator.updateVisiableStatus({viewScaleInfo:t.getActiveViewScaleInfo(),viewSizeInfo:t.getActiveViewSizeInfo()}),n}updateViewScaleInfo(e){const{sharer:t}=this.#t,i=function(e,t){const{scale:i,offsetX:o,offsetY:r}=e,{viewSizeInfo:a}=t,{width:n,height:s,contextWidth:l,contextHeight:h}=a,c=0-o*i,d=0-r*i;return{scale:i,offsetLeft:c,offsetTop:d,offsetRight:n-(l*i+c/i),offsetBottom:s-(h*i+d/i)}}(e,{viewSizeInfo:t.getActiveViewSizeInfo()});return t.setActiveViewScaleInfo(i),this.#t.calculator.updateVisiableStatus({viewScaleInfo:t.getActiveViewScaleInfo(),viewSizeInfo:t.getActiveViewSizeInfo()}),i}resize(e={},t){const{sharer:i}=this.#t,o={...i.getActiveViewSizeInfo(),...e},{width:r,height:a,devicePixelRatio:n}=o,{underlayContext:s,boardContext:l,overlayContext:h,viewContext:c}=this.#t.boardContent;return l.canvas.width=r*n,l.canvas.height=a*n,l.canvas.style.width=`${r}px`,l.canvas.style.height=`${a}px`,s.canvas.width=r*n,s.canvas.height=a*n,h.canvas.width=r*n,h.canvas.height=a*n,c.canvas.width=r*n,c.canvas.height=a*n,i.setActiveViewSizeInfo(o),t?.ignoreUpdateVisibleStatus||this.#t.calculator.updateVisiableStatus({viewScaleInfo:i.getActiveViewScaleInfo(),viewSizeInfo:i.getActiveViewSizeInfo()}),o}}class Xt{#t;#O=new Map;#V=[];#Y;#j;#G;#F;#w;#X=new L;#c=!1;constructor(e){const{boardContent:t,container:i}=e,o=new jt,r=new Vt({boardContent:t,sharer:o,disabled:e?.disableWatcher,container:i}),a=new Wt({viewContext:t.viewContext,tempContext:t.tempContext,sharer:o}),n=a.getCalculator();this.#t=e,this.#G=o,this.#Y=r,this.#j=a,this.#w=n,this.#F=new Ft({boardContent:e.boardContent,sharer:o,renderer:a,calculator:this.#w,beforeDrawFrame:e=>{this.#Q(e)},afterDrawFrame:e=>{this.#U(e)}}),this.#S(),this.#Z()}isDestroyed(){return this.#c}destroy(){this.#Y.destroy(),this.#j.destroy(),this.#w.destroy(),this.#X.destroy(),this.#c=!0}#S(){!0!==this.#t.disableWatcher&&(this.#Y.on("pointStart",this.#J.bind(this)),this.#Y.on("pointEnd",this.#K.bind(this)),this.#Y.on("pointMove",this.#q.bind(this)),this.#Y.on("pointLeave",this.#_.bind(this)),this.#Y.on("hover",this.#ee.bind(this)),this.#Y.on("wheel",this.#te.bind(this)),this.#Y.on("wheelScale",this.#ie.bind(this)),this.#Y.on("scrollX",this.#oe.bind(this)),this.#Y.on("scrollY",this.#re.bind(this)),this.#Y.on("resize",this.#ae.bind(this)),this.#Y.on("click",this.#ne.bind(this)),this.#Y.on("doubleClick",this.#se.bind(this)),this.#Y.on("contextMenu",this.#le.bind(this))),this.#j.on("load",()=>{this.#X.trigger("loadResource")})}#J(e){for(let t=0;t<this.#V.length;t++){const i=this.#V[t],o=i?.pointStart?.(e);if(!1===o)return}}#K(e){for(let t=0;t<this.#V.length;t++){const i=this.#V[t],o=i?.pointEnd?.(e);if(!1===o)return}}#q(e){for(let t=0;t<this.#V.length;t++){const i=this.#V[t],o=i?.pointMove?.(e);if(!1===o)return}}#_(e){for(let t=0;t<this.#V.length;t++){const i=this.#V[t],o=i?.pointLeave?.(e);if(!1===o)return}}#ee(e){for(let t=0;t<this.#V.length;t++){const i=this.#V[t],o=i?.hover?.(e);if(!1===o)return}}#ne(e){for(let t=0;t<this.#V.length;t++){const i=this.#V[t],o=i?.click?.(e);if(!1===o)return}}#se(e){for(let t=0;t<this.#V.length;t++){const i=this.#V[t],o=i?.doubleClick?.(e);if(!1===o)return}}#le(e){for(let t=0;t<this.#V.length;t++){const i=this.#V[t],o=i?.contextMenu?.(e);if(!1===o)return}}#te(e){for(let t=0;t<this.#V.length;t++){const i=this.#V[t],o=i?.wheel?.(e);if(!1===o)return}}#ie(e){for(let t=0;t<this.#V.length;t++){const i=this.#V[t],o=i?.wheelScale?.(e);if(!1===o)return}}#oe(e){for(let t=0;t<this.#V.length;t++){const i=this.#V[t],o=i?.scrollX?.(e);if(!1===o)return}}#re(e){for(let t=0;t<this.#V.length;t++){const i=this.#V[t],o=i?.scrollY?.(e);if(!1===o)return}}#ae(e){for(let t=0;t<this.#V.length;t++){const i=this.#V[t],o=i?.resize?.(e);if(!1===o)return}}#he(e){for(let t=0;t<this.#V.length;t++){const i=this.#V[t],o=i?.clear?.(e);if(!1===o)return}}#Q(e){for(let t=0;t<this.#V.length;t++){const i=this.#V[t],o=i?.beforeDrawFrame?.(e);if(!1===o)return}}#U(e){for(let t=0;t<this.#V.length;t++){const i=this.#V[t],o=i?.afterDrawFrame?.(e);if(!1===o)return}}#Z(){const e=[];for(const[t,i]of this.#O)"enable"===i?.status&&i?.middlewareObject&&e.push(i.middlewareObject);this.#V=e}getSharer(){return this.#G}getViewer(){return this.#F}getRenderer(){return this.#j}setData(e){const t=this.#G;this.#G.setActiveStorage("data",e);const i=t.getActiveViewSizeInfo(),o=t.getActiveViewScaleInfo(),r=U(e.materials,{viewWidth:i.width,viewHeight:i.height,extend:!0});this.#F.resetVirtualItemMap(e,{viewSizeInfo:i,viewScaleInfo:o}),this.#F.drawFrame();const a={...i,...r};return this.#G.setActiveViewSizeInfo(a),{viewSizeInfo:a}}getData(){const{data:e}=this.#G.getActiveStoreSnapshot();return e}use(e,t){if(this.#O.has(e)){const t=this.#O.get(e);return void(t&&"enable"!==t.status&&(t.status="enable",t.middlewareObject.use?.(),this.#Z()))}const{boardContent:i,container:o}=this.#t,r=e({boardContent:i,sharer:this.#G,viewer:this.#F,calculator:this.#w,eventHub:this.#X,container:o},t);r.use?.(),this.#O.set(e,{status:"enable",middlewareObject:r,config:t}),this.#Z()}disuse(e){if(this.#O.has(e)){const t=this.#O.get(e);t&&(t.middlewareObject.disuse?.(),t.status="disable"),this.#O.delete(e),this.#Z()}}resetMiddlewareConfig(e,t){if(this.#O.has(e)){const i=this.#O.get(e);i&&i.middlewareObject.resetConfig?.(t)}}scale(e){const t=this.#F,{ignoreUpdateVisibleStatus:i}=e,{moveX:o,moveY:r}=t.scale({...e,ignoreUpdateVisibleStatus:!0});t.scroll({moveX:o,moveY:r,ignoreUpdateVisibleStatus:i})}scroll(e){return this.#F.scroll(e)}updateViewScaleInfo(e){return this.#F.updateViewScaleInfo(e)}resize(e,t){const i=this.#F.resize(e,t),{width:o,height:r,devicePixelRatio:a}=e,{boardContent:n}=this.#t;n.viewContext.$resize({width:o,height:r,devicePixelRatio:a}),n.overlayContext.$resize({width:o,height:r,devicePixelRatio:a}),n.boardContext.$resize({width:o,height:r,devicePixelRatio:a}),n.underlayContext.$resize({width:o,height:r,devicePixelRatio:a}),this.#F.drawFrame(),this.#Y.trigger("resize",i),this.#G.setActiveViewSizeInfo(e)}clear(){const{boardContent:e}=this.#t,{underlayContext:t,overlayContext:i,viewContext:o,boardContext:r}=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),r.clearRect(0,0,r.canvas.width,r.canvas.height),this.#he()}getEventHub(){return this.#X}onWatcherEvents(){!0!==this.#t.disableWatcher&&this.#Y.onEvents()}offWatcherEvents(){!0!==this.#t.disableWatcher&&this.#Y.offEvents()}}const Qt="CREATOR",Ut=Symbol(`${Qt}_startPoint`),Zt=Symbol(`${Qt}_endPoint`),Jt=Symbol(`${Qt}_activeMaterialType`),Kt="idraw-middleware-creator",qt={zIndex:2,creationAreaBorderColor:"#1973ba"},_t={selectAfterCreated:!0},ei={creationAreaBox:`${Kt}-creationAreaBox`,creative:`${Kt}-creative`};function ti(e){return N(e,["zIndex","creationAreaBorderColor"])}function ii(e){!function(e,t){if(!e)return;const{className:i}=t;Array.from(e.getElementsByClassName(i)).forEach(e=>{e.remove()})}(e,{className:ei.creationAreaBox})}function oi(e,t){if(!e)return;const{start:i,end:o}=t;if(i&&o){const t=function(e){const t=e.getElementsByClassName(ei.creationAreaBox);if(t[0])return t[0];const i=rt("div",{[yt]:"true",className:ei.creationAreaBox});return ot(e,{},[i]),i}(e);it(t,{left:Math.min(i.x,o.x),top:Math.min(i.y,o.y),width:Math.abs(o.x-i.x),height:Math.abs(o.y-i.y)})}else ii(e)}function ri(e){const{start:t,end:i,viewScaleInfo:o,calculator:r}=e,a=ne(t,{viewScaleInfo:o}),n=ne(i,{viewScaleInfo:o});return{x:r.toGridNum(Math.min(a.x,n.x)),y:r.toGridNum(Math.min(a.y,n.y)),width:r.toGridNum(Math.abs(n.x-a.x)),height:r.toGridNum(Math.abs(n.y-a.y))}}function ai(e,t,i){"continuous"===i?e.trigger(o.CHANGING,t):"all"===i?(e.trigger(o.CHANGING,t),e.trigger(o.CHANGE,t)):e.trigger(o.CHANGE,t)}const ni="SELECTOR",si="idraw-middleware-selector",li="data-idraw-box-type",hi="data-idraw-material-id",ci="data-idraw-handler-type",di="box-group",ui="box-material",fi={materialBox:`${si}-materialBox`,groupBox:`${si}-groupBox`,nestedBox:`${si}-nestedBox`,nestedTargetBox:`${si}-nestedTargetBox`,hoverBox:`${si}-hoverBox`,hoverTargetBox:`${si}-hoverTargetBox`,lockedBox:`${si}-lockedBox`,lockedTargetBox:`${si}-lockedTargetBox`,selectedBox:`${si}-selectedBox`,selectedTargetBox:`${si}-selectedTargetBox`,hideHandler:`${si}-hideHandler`,edgeHandler:`${si}-edgeHandler`,edgeTopHandler:`${si}-edgeTopHandler`,edgeRightHandler:`${si}-edgeRightandler`,edgeBottomHandler:`${si}-edgeBottomHandler`,edgeLeftHandler:`${si}-edgeLeftHandler`,cornerHandler:`${si}-cornerHandler`,cornerTopLeftHandler:`${si}-cornerTopLeftHandler`,cornerTopRightHandler:`${si}-cornerTopRightHandler`,cornerBottomLeftHandler:`${si}-cornerBottomLeftHandler`,cornerBottomRightHandler:`${si}-cornerBottomRightHandler`,rotateHandler:`${si}-rotateHandler`,selectionAreaBox:`${si}-selectionAreaBox`},gi=Symbol(`${ni}_prevPoint`),mi=Symbol(`${ni}_pointStartMaterialSizeList`),pi=Symbol(`${ni}_moveOriginalStartPoint`),yi=Symbol(`${ni}_moveOriginalStartMaterialSize`),xi=Symbol(`${ni}_inBusyMode`),vi=Symbol(`${ni}_hasChangedData`),wi=Symbol(`${ni}_startResizeGroupRecord`),Si=Symbol(`${ni}_endResizeGroupRecord`),bi=Symbol(`${ni}_actionType`),Ai=Symbol(`${ni}_resizeType`),Mi=Symbol(`${ni}_areaStart`),Ii=Symbol(`${ni}_areaEnd`),Ci=Symbol(`${ni}_hoverMaterial`),Ri=Symbol(`${ni}_selectedMaterialList`),Ei=Symbol(`${ni}_selectedMaterialListVertexes`),zi=Symbol(`${ni}_selectedMaterialPosition`),Li=Symbol(`${ni}_groupQueue`),Bi=Symbol(`${ni}_isMoving`),ki=Symbol(`${ni}_enableSelectInGroup`),Pi=Symbol(`${ni}_enableSnapToGrid`),Ti={zIndex:1,activeColor:"#1973ba",handlerBorderColor:"#1973ba",handlerBackground:"#ffffff",handlerHoverBackground:"#aad4f6",handlerActiveBackground:"#63b8f8",selectionAreaBorderColor:"#1973ba",selectionAreaBackground:"#1973ba3f",lockedColor:"#5b5959b5",referenceColor:"#f7276e"};function Ni(e){return e*Math.PI/180}function Di(e,t){return Math.sqrt(e*e+t*t)}function $i(e,t){return t>0?Math.abs(e):0-Math.abs(e)}function Hi(e,t){const{ctx:i,viewScaleInfo:o,vertexes:r}=t,a=ae(r[0],{viewScaleInfo:o}),n=ae(r[1],{viewScaleInfo:o}),s=ae(r[2],{viewScaleInfo:o}),l=ae(r[3],{viewScaleInfo:o});return i.beginPath(),i.moveTo(a.x,a.y),i.lineTo(n.x,n.y),i.lineTo(s.x,s.y),i.lineTo(l.x,l.y),i.lineTo(a.x,a.y),i.closePath(),!!i.isPointInPath(e.x,e.y)}function Wi(e,t){const i={type:null,materials:[],materialVertexesList:[],groupQueue:[]},{ctx:o,data:r,calculator:a,selectedMaterials:n,viewScaleInfo:s,viewSizeInfo:l,areaSize:h,groupQueue:c,nativeEvent:d}=t,u=d.target;if(n&&1===n?.length&&u){const e=u;if(e?.hasAttribute(ci)){const t=e.getAttribute(ci);if("string"==typeof t)return i.type=`resize-${t}`,i.groupQueue=c||[],i.materials=[n[0]],i}}if(c&&Array.isArray(c)&&c.length>0){const t=c[c.length-1];if(t?.children&&Array.isArray(t?.children))for(let r=t.children.length-1;r>=0;r--){const a=t.children[r],n=oe(a,{groupQueue:c});if(n&&Hi(e,{ctx:o,vertexes:n,viewScaleInfo:s}))return i.type||(i.type="over-material"),i.groupQueue=c,i.materials=[a],i}return i}if(null!==i.type)return i;if(h&&Array.isArray(n)&&n?.length>1){const{x:t,y:o,width:r,height:a}=h;if(e.x>=t&&e.x<=t+r&&e.y>=o&&e.y<=o+a)return i.type="list-area",i.materials=n,i}if(r){const{index:t,material:o}=a.getPointMaterial(e,{data:r,viewScaleInfo:s,viewSizeInfo:l});if(t>=0&&o&&!0!==o?.operations?.invisible)return i.materials=[o],i.type="over-material",i}return i}function Oi(e,t){const{x:i,y:o,width:r,height:a,angle:n=0}=e,{center:s,start:l,end:h,viewScaleInfo:c,calculator:d}=t,u=ae(s,{viewScaleInfo:c}),f=X(n),g=function(e,t,i){const o=O(e,t),r=O(e,i);return null!==r&&null!==o?r-o:0}(u,l,h),m=X(f+g/Math.PI*180);return{x:d.toGridNum(i),y:d.toGridNum(o),width:d.toGridNum(r),height:d.toGridNum(a),angle:d.toGridNum(m)}}function Vi(e,t){if(!Array.isArray(e))return null;const i={x:0,y:0,width:0,height:0},{viewScaleInfo:o}=t;let r=null;for(let t=0;t<e.length;t++){const a=e[t];if(a?.operations?.invisible)continue;const n=re(a,{viewScaleInfo:o});if(n.angle&&(n.angle>0||n.angle<0)){const e=G(n);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];n.x=Math.min(...t),n.y=Math.min(...i),n.width=Math.abs(Math.max(...t)-Math.min(...t)),n.height=Math.abs(Math.max(...i)-Math.min(...i))}}if(r){const e=Math.min(n.x,i.x),t=Math.min(n.y,i.y),o=Math.max(n.x+n.width,i.x+i.width),r=Math.max(n.y+n.height,i.y+i.height);i.x=e,i.y=t,i.width=Math.abs(o-e),i.height=Math.abs(r-t)}else i.x=n.x,i.y=n.y,i.width=n.width,i.height=n.height;r=n}return i}function Yi(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 ji=(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 r=Math.floor((i+o)/2);if(e[r]===t)return e[r];e[r]<t?i=r+1:o=r-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]},Gi=(e,t)=>Math.abs(e-t)<1e-5;function Fi(e,t){const{data:i,groupQueue:o,calculator:r,viewScaleInfo:a,viewSizeInfo:n}=t;let s=i.materials||[];o?.length>0&&(s=o[o.length-1]?.children||[]);const l=[];s.forEach(t=>{if(t.id!==e){const e=r.calcViewBoundingInfoFromRange(t.id,{checkVisible:!0,viewScaleInfo:a,viewSizeInfo:n});e&&l.push(e)}});const h=r.calcViewBoundingInfoFromRange(e,{viewScaleInfo:a,viewSizeInfo:n});if(!h)return null;const c={},d={},u=[],f=[];let g=[],m=[];const p=Yi(h);l.forEach(e=>{const t=Yi(e);c[t.minX]||(c[t.minX]=[]),c[t.midX]||(c[t.midX]=[]),c[t.maxX]||(c[t.maxX]=[]),d[t.minY]||(d[t.minY]=[]),d[t.midY]||(d[t.midY]=[]),d[t.maxY]||(d[t.maxY]=[]),c[t.minX]=[t.minY,t.midY,t.maxY],c[t.midX]=[t.minY,t.midY,t.maxY],c[t.maxX]=[t.minY,t.midY,t.maxY],g.push(t.minX),g.push(t.midX),g.push(t.maxX),d[t.minY]=[t.minX,t.midX,t.maxX],d[t.midY]=[t.minX,t.midX,t.maxX],d[t.maxY]=[t.minX,t.midX,t.maxX],m.push(t.minY),m.push(t.midY),m.push(t.maxY)}),g=g.sort((e,t)=>e-t),m=m.sort((e,t)=>e-t);let y=null,x=null,v=null,w=null,S=null,b=null,A=null,M=null;if(g.length>0){v=ji(g,p.minX),w=ji(g,p.midX),S=ji(g,p.maxX);const e=Math.abs(v-p.minX),t=Math.abs(w-p.midX),i=Math.abs(S-p.maxX),o=Math.min(e,t,i);o<=2/a.scale&&(Gi(o,e)?y=v-p.minX:Gi(o,t)?y=w-p.midX:Gi(o,i)&&(y=S-p.maxX))}if(m.length>0){b=ji(m,p.minY),A=ji(m,p.midY),M=ji(m,p.maxY);const e=Math.abs(b-p.minY),t=Math.abs(A-p.midY),i=Math.abs(M-p.maxY),o=Math.min(e,t,i);o<=2/a.scale&&(Gi(o,e)?x=b-p.minY:Gi(o,t)?x=A-p.midY:Gi(o,i)&&(x=M-p.maxY))}const I={...p};if(null!==y&&(I.minX+=y,I.midX+=y,I.maxX+=y),null!==x&&(I.minY+=x,I.midY+=x,I.maxY+=x),C.x(y)&&null!==y&&null!==v&&null!==w&&null!==S){if(Gi(y,v-p.minX)){const e={x:v,yList:[]};e.yList.push(I.minY),e.yList.push(I.maxY),e.yList.push(...d?.[v]||[]),u.push(e)}if(Gi(y,w-p.minX)){const e={x:w,yList:[]};e.yList.push(I.minY),e.yList.push(I.maxY),e.yList.push(...d?.[w]||[]),u.push(e)}if(Gi(y,S-p.minX)){const e={x:S,yList:[]};e.yList.push(I.minY),e.yList.push(I.maxY),e.yList.push(...d?.[S]||[]),u.push(e)}}if(C.y(x)&&null!==x&&null!==b&&null!==A&&null!==M){if(Gi(x,b-p.minY)){const e={y:b,xList:[]};e.xList.push(I.minX),e.xList.push(I.maxX),e.xList.push(...c?.[b]||[]),f.push(e)}if(Gi(x,A-p.midY)){const e={y:A,xList:[]};e.xList.push(I.minX),e.xList.push(I.maxX),e.xList.push(...c?.[b]||[]),f.push(e)}if(Gi(x,M-p.maxY)){const e={y:M,xList:[]};e.xList.push(I.minX),e.xList.push(I.maxX),e.xList.push(...c?.[M]||[]),f.push(e)}}const R=[];u?.length>0&&u.forEach((e,t)=>{R.push([]),e.yList.forEach(i=>{R[t].push({x:e.x,y:i})})});const E=[];return f?.length>0&&f.forEach((e,t)=>{E.push([]),e.xList.forEach(i=>{E[t].push({x:i,y:e.y})})}),{offsetX:y,offsetY:x,yLines:R,xLines:E}}const Xi="LAYOUT_SELECTOR",Qi=Symbol(`${Xi}_layoutActionType`),Ui=Symbol(`${Xi}_layoutControlType`),Zi=Symbol(`${Xi}_layoutIsHoverContent`),Ji=Symbol(`${Xi}_layoutIsHoverController`),Ki=Symbol(`${Xi}_layoutIsSelected`),qi=Symbol(`${Xi}_layoutIsSelected`),_i="idraw-middleware-layout-selector",eo="data-idraw-handler-type",to=1.5,io={zIndex:2,activeColor:"#b331c9",handlerBorderColor:"#b331c9",handlerBackground:"#ffffff",handlerHoverBackground:"#bb8fc3",handlerActiveBackground:"#b467c2"},oo={hover:`${_i}-hover`,edgeHandler:`${_i}-edgeHandler`,edgeTopHandler:`${_i}-edgeTopHandler`,edgeRightHandler:`${_i}-edgeRightandler`,edgeBottomHandler:`${_i}-edgeBottomHandler`,edgeLeftHandler:`${_i}-edgeLeftHandler`,cornerHandler:`${_i}-cornerHandler`,cornerTopLeftHandler:`${_i}-cornerTopLeftHandler`,cornerTopRightHandler:`${_i}-cornerTopRightHandler`,cornerBottomLeftHandler:`${_i}-cornerBottomLeftHandler`,cornerBottomRightHandler:`${_i}-cornerBottomRightHandler`};function ro(e,t){const{rootClassName:i}=t,o=e.getElementsByClassName(i);Array.from(o).forEach(e=>{e.remove()})}function ao(e,t){const{layout:i}=t;i?function(e,t){const i=e.querySelectorAll(`[${eo}]`),{rootClassName:o,layout:r,viewScaleInfo:a}=t;if(!r)return;const n=re(r,{viewScaleInfo:a}),{x:s,y:l,height:h,width:c}=n,d={left:s,top:l,height:h},u={left:s,top:l,width:c},f={left:s+c,top:l,height:h},g={left:s,top:l+h,width:c},m={left:s,top:l},p={left:s+c,top:l},y={left:s,top:l+h},x={left:s+c,top:l+h};if(i.length>0){const t=e.getElementsByClassName(oo.edgeLeftHandler)[0],i=e.getElementsByClassName(oo.edgeRightHandler)[0],o=e.getElementsByClassName(oo.edgeTopHandler)[0],r=e.getElementsByClassName(oo.edgeBottomHandler)[0],a=e.getElementsByClassName(oo.cornerTopLeftHandler)[0],n=e.getElementsByClassName(oo.cornerTopRightHandler)[0],s=e.getElementsByClassName(oo.cornerBottomLeftHandler)[0],l=e.getElementsByClassName(oo.cornerBottomRightHandler)[0];it(t,d),it(i,f),it(o,u),it(r,g),it(a,m),it(n,p),it(s,y),it(l,x)}else{const t=rt,i={[yt]:"true"};ot(e,{},[t("div",{[eo]:"left",...i,className:`${o} ${oo.edgeHandler} ${oo.edgeLeftHandler}`,style:d}),t("div",{[eo]:"top",...i,className:`${o} ${oo.edgeHandler} ${oo.edgeTopHandler}`,style:u}),t("div",{[eo]:"right",...i,className:`${o} ${oo.edgeHandler} ${oo.edgeRightHandler}`,style:f}),t("div",{[eo]:"bottom",...i,className:`${o} ${oo.edgeHandler} ${oo.edgeBottomHandler}`,style:g}),t("div",{[eo]:"top-left",...i,className:`${o} ${oo.cornerHandler} ${oo.cornerTopLeftHandler}`,style:m}),t("div",{[eo]:"top-right",...i,className:`${o} ${oo.cornerHandler} ${oo.cornerTopRightHandler}`,style:p}),t("div",{[eo]:"bottom-left",...i,className:`${o} ${oo.cornerHandler} ${oo.cornerBottomLeftHandler}`,style:y}),t("div",{[eo]:"bottom-right",...i,className:`${o} ${oo.cornerHandler} ${oo.cornerBottomRightHandler}`,style:x})])}Array.from(e.querySelectorAll(`[${eo}]`)).forEach(e=>{tt(e,[oo.hover])})}(e,t):ro(e,t)}const no="monospace";const so="@middleware/internal-event/show-info-angle",lo={textBackground:"#1973bac6",textColor:"#ffffff"};function ho(e){return N(e,["textBackground","textColor"])}const co=10;function uo(e){const{material:t,groupQueue:i,viewScaleInfo:o}=e;let r=t?K(t):null;const a=i.map(e=>K(e));if(Array.isArray(a)&&a.length>0){r=r?re(r,{viewScaleInfo:{scale:o.scale}}):null,a[0]=re(a[0],{viewScaleInfo:o});for(let e=1;e<a.length;e++)a[e]=re(a[e],{viewScaleInfo:{scale:o.scale}})}else r=r?re(r,{viewScaleInfo:o}):null;return{viewMaterialSize:r,viewGroupSizeQueue:a}}function fo(e,t){if(!e)return null;const{className:i,targetClassName:o,viewMaterialSize:r,viewGroupSizeQueue:a}=t,n=function(e){const{viewMaterialSize:t,viewGroupSizeQueue:i,className:o,targetClassName:r}=e;let a=null;t&&(a=rt("div",{[li]:ui,[yt]:"true",[hi]:t.id,className:fi.materialBox,style:{display:"block",position:"absolute",top:t.y,left:t.x,width:t.width,height:t.height,transform:`rotate(${t.angle||0}deg)`}}),et(a,[r]));let n=a;for(let e=i.length-1;e>=0;e--){const t=i[e],o=[];n&&o.push(n),n=rt("div",{[li]:di,[yt]:"true",[hi]:t.id,className:`${fi.materialBox} ${fi.groupBox}`,style:{position:"absolute",top:t.y,left:t.x,width:t.width,height:t.height,transform:`rotate(${t.angle||0}deg)`}},o)}return n&&et(n,[o]),n}({viewMaterialSize:r,viewGroupSizeQueue:a,className:i,targetClassName:o});return n&&ot(e,{},[n]),n}function go(e,t){if(!e)return null;const{className:i,targetClassName:o,renderTargetInner:r,destoryTargetInner:a,afterRender:n}=t,s=e.getElementsByClassName(i),{viewMaterialSize:l,viewGroupSizeQueue:h}=uo(t),c=()=>{Array.from(s).forEach(e=>{e.remove()})};if(l||h.length||c(),1===s.length){const e=s[0];if(et(e,[i]),h.length>0){let e=0,t=s[0],i=t.parentElement;for(;e<h.length;){const r=h[e];if(t?(tt(t,[o]),ot(t,{[li]:di,[yt]:"true",[hi]:r.id,style:{position:"absolute",top:r.y,left:r.x,width:r.width,height:r.height,transform:`rotate(${r.angle||0}deg)`}})):(t=rt("div",{[li]:di,[yt]:"true",[hi]:r.id,className:`${fi.materialBox} ${fi.groupBox}`,style:{position:"absolute",top:r.y,left:r.x,width:r.width,height:r.height,transform:`rotate(${r.angle||0}deg)`}}),i?.appendChild(t)),i=t,e+1===h.length)break;t=t?.children?.[0],e++}if(l){let e=t?.children?.[0];e||(e=rt("div"),i?.appendChild(e)),ot(e,{[li]:ui,[yt]:"true",[hi]:l.id,style:{display:"block",position:"absolute",top:l.y,left:l.x,width:l.width,height:l.height,transform:`rotate(${l.angle||0}deg)`}}),r?.(e)}else a?.(t)}else l?(a?.(e),ot(e,{[li]:ui,[yt]:"true",[hi]:l.id,style:{display:"block",position:"absolute",top:l.y,left:l.x,width:l.width,height:l.height,transform:`rotate(${l.angle||0}deg)`}}),et(e,[o]),r?.(e)):c();return n?.({$rootBox:e,viewGroupSizeQueue:h,viewMaterialSize:l}),e}{c();const t=fo(e,{viewMaterialSize:l,viewGroupSizeQueue:h,className:i,targetClassName:o});et(t,[o]),r?.(t),n?.({$rootBox:t,viewGroupSizeQueue:h,viewMaterialSize:l})}}function mo(e,t){if(!e)return;const{className:i}=t;Array.from(e.getElementsByClassName(i)).forEach(e=>{e.remove()})}function po(e,t){const{groupQueue:i}=t;Array.isArray(i)&&i.length?go(e,{...t,className:fi.nestedBox,targetClassName:fi.nestedTargetBox}):function(e){mo(e,{className:fi.nestedBox})}(e)}function yo(e){return mo(e,{className:fi.hoverBox})}function xo(e){return mo(e,{className:fi.lockedBox})}function vo(e,t){xo(e),function(e,t){if(!e)return null;const{className:i,targetClassName:o}=t,{viewMaterialSize:r,viewGroupSizeQueue:a}=uo(t);fo(e,{viewMaterialSize:r,viewGroupSizeQueue:a,className:i,targetClassName:o})}(e,{...t,className:fi.lockedBox,targetClassName:fi.lockedTargetBox})}function wo(e){if(e.querySelectorAll(`[${ci}]`).length>0)return;const t=rt,i={[yt]:"true"};ot(e,{},[t("div",{[ci]:"left",...i,className:`${fi.edgeHandler} ${fi.edgeLeftHandler}`}),t("div",{[ci]:"top",...i,className:`${fi.edgeHandler} ${fi.edgeTopHandler}`}),t("div",{[ci]:"right",...i,className:`${fi.edgeHandler} ${fi.edgeRightHandler}`}),t("div",{[ci]:"bottom",...i,className:`${fi.edgeHandler} ${fi.edgeBottomHandler}`}),t("div",{[ci]:"top-left",...i,className:`${fi.cornerHandler} ${fi.cornerTopLeftHandler}`}),t("div",{[ci]:"top-right",...i,className:`${fi.cornerHandler} ${fi.cornerTopRightHandler}`}),t("div",{[ci]:"bottom-left",...i,className:`${fi.cornerHandler} ${fi.cornerBottomLeftHandler}`}),t("div",{[ci]:"bottom-right",...i,className:`${fi.cornerHandler} ${fi.cornerBottomRightHandler}`}),t("div",{[ci]:"rotate",...i,className:fi.rotateHandler})])}function So(e,t){const{material:i}=t;i?go(e,{...t,className:fi.selectedBox,targetClassName:fi.selectedTargetBox,renderTargetInner:wo,destoryTargetInner:e=>e.innerHTML="",afterRender:({$rootBox:e,viewMaterialSize:t})=>{if(t&&e){const{width:i,height:o}=t;Math.min(i,o)>40?tt(e,[fi.hideHandler]):et(e,[fi.hideHandler])}}}):function(e){mo(e,{className:fi.selectedBox})}(e)}function bo(e,t){if(!e)return;const{areaStart:i,areaEnd:o,selectedMaterials:r,viewScaleInfo:a}=t;let n=null,s=null,l=!1;if(r.length>1||1===r.length&&i&&o){const e=function(e){const t={x:0,y:0,width:0,height:0};let i=null;for(let o=0;o<e.length;o++){const r=e[o];if(r?.operations?.invisible)continue;const a={x:r.x,y:r.y,width:r.width,height:r.height,angle:r.angle||0};if(a.angle&&(a.angle>0||a.angle<0)){const e=G(a);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];a.x=Math.min(...t),a.y=Math.min(...i),a.width=Math.abs(Math.max(...t)-Math.min(...t)),a.height=Math.abs(Math.max(...i)-Math.min(...i))}}if(i){const e=Math.min(a.x,t.x),i=Math.min(a.y,t.y),o=Math.max(a.x+a.width,t.x+t.width),r=Math.max(a.y+a.height,t.y+t.height);t.x=e,t.y=i,t.width=Math.abs(o-e),t.height=Math.abs(r-i)}else t.x=a.x,t.y=a.y,t.width=a.width,t.height=a.height;i=a}return{x:Math.floor(t.x),y:Math.floor(t.y),width:Math.ceil(t.width),height:Math.ceil(t.height)}}(r),{x:t,y:i,width:o,height:a}=e;n={x:t,y:i},s={x:t+o,y:i+a},l=!0}else i&&o&&(n={...i},s={...o});if(n&&s){const t=function(e){const t=e.getElementsByClassName(fi.selectionAreaBox);if(t[0])return t[0];const i=rt("div",{[yt]:"true",className:fi.selectionAreaBox});return ot(e,{},[i]),i}(e);l&&(n=ae(n,{viewScaleInfo:a}),s=ae(s,{viewScaleInfo:a})),it(t,{left:Math.min(n.x,s.x),top:Math.min(n.y,s.y),width:Math.abs(s.x-n.x),height:Math.abs(s.y-n.y)})}else!function(e){mo(e,{className:fi.selectionAreaBox})}(e)}function Ao(e,t){const{groupQueue:i,$root:o}=t;if(!(i&&i?.length>0&&o))return!1;const r=i[i.length-1].id,a=e.target;if("string"==typeof r&&r){if(a?.getAttribute(li)===di&&a?.getAttribute(hi)===r)return!0;const e=st(a,o,{[li]:di});if(e?.getAttribute(li)===di&&e?.getAttribute(hi)===r)return!0}return!1}function Mo(e){return N(e,["zIndex","activeColor","handlerBorderColor","handlerBackground","handlerHoverBackground","handlerActiveBackground","selectionAreaBackground","selectionAreaBorderColor","lockedColor","referenceColor"])}const Io=(e,t)=>{const{x:i,y:o,width:r,height:a}=t,n=e.width,s=e.height;if(e.x=i,e.y=o,e.width=r,e.height=a,"circle"===e.type)e.cx=i+r/2,e.cy=o+a/2,e.r=Math.min(r,a)/2;else if("ellipse"===e.type)e.cx=i+r/2,e.cy=o+a/2,e.rx=r/2,e.ry=a/2;else if("path"===e.type){const t=r/n,i=a/s,o=e;o.commands=Ue(o.commands,t,i)}};function Co(e,t,i,o){const{stroke:r,strokeWidth:a,lineDash:n}=o;e.setLineDash([]),e.lineWidth=a,e.strokeStyle=r,e.setLineDash(n),e.beginPath(),e.moveTo(t.x,t.y),e.lineTo(i.x,i.y),e.closePath(),e.stroke()}function Ro(e,t,i){const{size:o,stroke:r,strokeWidth:a,lineDash:n}=i,s=t.x-o/2,l=t.x+o/2,h=t.y-o/2,c=t.y+o/2;!function(e,t,i){const{stroke:o,strokeWidth:r,lineDash:a}=i;e.setLineDash([]),e.lineWidth=r,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()}(e,[{x:s,y:h},{x:l,y:h},{x:l,y:c},{x:s,y:c}],{stroke:r,strokeWidth:a,lineDash:n})}function Eo(e,t){const{xLines:i,yLines:o,styles:r}=t,{referenceColor:a}=r,n={stroke:a,strokeWidth:1,lineDash:[]},s={...n,size:6};i&&i.forEach(t=>{t.forEach((i,o)=>{Ro(e,i,s),t[o+1]&&Co(e,t[o],t[o+1],n)})}),o&&o.forEach(t=>{t.forEach((i,o)=>{Ro(e,i,s),t[o+1]&&Co(e,t[o],t[o+1],n)})})}function zo({$root:e,styles:t,snapshot:i,sharer:o,calculator:r,boardContent:a}){const{activeStore:n,sharedStore:s}=i,{overlayContext:l}=a,{scale:h,offsetLeft:c,offsetTop:d,offsetRight:u,offsetBottom:f,width:g,height:m,contextHeight:p,contextWidth:y,devicePixelRatio:x}=n,v={scale:h,offsetLeft:c,offsetTop:d,offsetRight:u,offsetBottom:f},w={width:g,height:m,contextHeight:p,contextWidth:y,devicePixelRatio:x},S=s[Ri],b=S[0],A=s[Ci],M=s[bi],I=s[Mi],C=s[Ii],R=s[Li],E=s[Pi],z=!!A?.operations?.locked,L={material:null,groupQueue:R||[],viewScaleInfo:v,viewSizeInfo:w,calculator:r};if(po(e,L),yo(e),xo(e),A&&A?.id!==S[0]?.id&&(L.material=A,z?vo(e,L):function(e,t){yo(e),go(e,{...t,className:fi.hoverBox,targetClassName:fi.hoverTargetBox})}(e,L)),So(e,{...L,material:1===S.length?S[0]:null}),bo(e,{...L,areaStart:I,areaEnd:C,selectedMaterials:S}),R?.length>0){if(b&&["select","drag","resize"].includes(M)&&"drag"===M&&!0===E){const e=Fi(b.id,{calculator:r,data:n.data,groupQueue:R,viewScaleInfo:v,viewSizeInfo:w});if(e){const{offsetX:i,offsetY:o,xLines:r,yLines:a}=e;0!==i&&0!==o||Eo(l,{xLines:r,yLines:a,styles:t})}}}else if(b&&["select","drag","resize"].includes(M)){if("drag"===M&&!0===E){const e=Fi(b.id,{calculator:r,data:n.data,groupQueue:R,viewScaleInfo:v,viewSizeInfo:w});if(e){const{offsetX:i,offsetY:o,xLines:r,yLines:a}=e;0!==i&&0!==o||Eo(l,{xLines:r,yLines:a,styles:t})}}}else"area"===M&&I&&C||["drag-list","drag-list-end"].includes(M)&&Vi(o.getSharedStorage(Ri),{viewScaleInfo:o.getActiveViewScaleInfo(),viewSizeInfo:o.getActiveViewSizeInfo()})}const Lo="SCROLL",Bo=Symbol(`${Lo}_xThumbStyle`),ko=Symbol(`${Lo}_yThumbStyle`),Po=Symbol(`${Lo}_prevPoint`),To=Symbol(`${Lo}_activePoint`),No=Symbol(`${Lo}_activeThumbType`),Do="idraw-middleware-scroller",$o=16,Ho=40,Wo="data-idraw-thumb-type",Oo={zIndex:2,thumbBackground:"#0000003A",thumbBorderColor:"#0000008A",hoverThumbBackground:"#0000005F",hoverThumbBorderColor:"#000000EE",activeThumbBackground:"#0000005E",activeThumbBorderColor:"#000000F0"},Vo={horizontal:`${Do}-horizontal`,vertical:`${Do}-vertical`,thumb:`${Do}-thumb`};function Yo(e){return N(e,["zIndex","thumbBackground","thumbBorderColor","hoverThumbBackground","hoverThumbBorderColor","activeThumbBackground","activeThumbBorderColor"])}function jo(e){const t=e.target;return!!(t?.classList?.contains(Vo.thumb)||t?.classList?.contains(Vo.horizontal)||t?.classList?.contains(Vo.vertical))}function Go(e){const{xThumbStyle:t,yThumbStyle:i,$horizontal:o,$vertical:r}=e;if(o&&t){const e=o.getElementsByClassName(Vo.thumb)[0];e&&it(e,t)}if(r&&i){const e=r.getElementsByClassName(Vo.thumb)[0];e&&it(e,i)}}function Fo(e){const t=e?.target;return t?.classList?.contains(Vo.thumb)&&t.hasAttribute(Wo)?t.getAttribute(Wo):null}const Xo=16,Qo="monospace",Uo={background:"#FFFFFFA8",stroke:"#00000080",scaleColor:"#000000",textColor:"#00000080",gridColor:"#AAAAAA20",gridPrimaryColor:"#AAAAAA40",selectedAreaColor:"#19609780"};function Zo(e){return N(e,["background","stroke","scaleColor","textColor","gridColor","gridPrimaryColor","selectedAreaColor"])}const Jo=[1,2,5,10,20,50,100,200,500];function Ko(e){const{scale:t,viewLength:i,viewOffset:o}=e,r=[];let a=10;a=ue(a/t,{decimalPlaces:0}),a=function(e){e=Math.max(Jo[0],Math.min(e,Jo[Jo.length-1]));for(let t=0;t<Jo.length-1;t++){const i=Jo[t],o=Jo[t+1];if(!(e>o))return e===i||e===o?e:e<=(i+o)/2?i:o}return e}(a);const n=10*a,s=5*a;let l=0;const h=a*t,c=0-o,d=c%h,u=(c-d+h)/t,f=h-d+0;for(;f+l*h<i;){const e=ue(u+l*a,{decimalPlaces:0}),t={num:e,position:ue(f+l*h,{decimalPlaces:0}),showNum:e%n===0,isKeyNum:e%n===0,isSubKeyNum:e%s===0};r.push(t),l++}return{list:r,rulerUnit:a}}const qo="idraw-middleware-text-editor",_o={zIndex:1,boxBorderColor:"#0c8ce9"},er={textarea:`${qo}-textarea`,hide:`${qo}-hide`,canvasWrapper:`${qo}-canvas-wrapper`};function tr(e){return N(e,["zIndex","boxBorderColor"])}const ir=pe();const or=e=>{const{size:t,parent:i}=e,o=document.createElement("div"),{x:r,y:a,width:n,height:s}=t;return it(o,{position:"absolute",left:`${r}px`,top:`${a}px`,width:`${n}px`,height:`${s}px`,transform:`rotate(${X(t.angle||0)}deg)`}),i.appendChild(o),o},rr=Symbol("DRAG_prevPoint"),ar="idraw-middleware-path-creator",nr={hide:`${ar}-hide`,anchor:`${ar}-anchor`,director:`${ar}-director`,directorLines:`${ar}-director-lines`,pathLine:`${ar}-path-line`,selected:`${ar}-selected`},sr="data-uuid",lr="data-x",hr="data-y",cr="data-w",dr="data-h",ur="data-angle",fr="data-type",gr="data-helper-type",mr="data-anchor-cmd-type",pr="data-anchor-index",yr="data-anchor-id",xr="data-director-from-anchor-id",vr="data-director-control-type",wr="data-director-opened-by-anchor-id",Sr="material",br="anchor",Ar="director",Mr="director-line",Ir="path-preview",Cr="path-definition",Rr={zIndex:2,anchorSize:8,anchorSelectedSize:12,anchorBorderWidth:2,anchorBorderColor:"#0c8ce9",anchorBackground:"#ffffff",anchorHoverBorderColor:"#1671b8",anchorHoverBackground:"#cfe4f4",anchorActiveBorderColor:"#0d548c",anchorActiveBackground:"#88c0ec",directorSize:10,directorBorderWidth:2,directorBorderColor:"#7315d1ff",directorBackground:"#ffffff",directorHoverBorderColor:"#4716b8ff",directorHoverBackground:"#ebcff4ff",directorActiveBorderColor:"#510d8cff",directorActiveBackground:"#c988ecff",directorLineColor:"#7315d1ff",helperStrokeColor:"#0c8ce9",helperStrokeWidth:1};function Er(e){return N(e,["zIndex","anchorSize","anchorSelectedSize","anchorBorderWidth","anchorBorderColor","anchorBackground","anchorHoverBorderColor","anchorHoverBackground","anchorActiveBorderColor","anchorActiveBackground","directorSize","directorBorderWidth","directorBorderColor","directorBackground","directorHoverBorderColor","directorHoverBackground","directorActiveBorderColor","directorActiveBackground","directorLineColor","helperStrokeColor","helperStrokeWidth"])}const zr=(e,t)=>{const{size:i,parent:o}=e,{x:r,y:a,width:n,height:s}=i,l=X(i.angle||0),h=rt("div",{[yt]:"true",style:{position:"absolute",left:r,top:a,width:n,height:s,transform:`rotate(${l}deg)`},...t});return o.appendChild(h),h},Lr=e=>({id:e.getAttribute(sr)||"",type:e.getAttribute(fr)||"",x:parseFloat(e.getAttribute(lr)||"0"),y:parseFloat(e.getAttribute(hr)||"0"),w:parseFloat(e.getAttribute(cr)||"0"),h:parseFloat(e.getAttribute(dr)||"0"),angle:parseFloat(e.getAttribute(ur)||"0")}),Br=e=>{const{x:t,y:i,size:o,borderWidth:r}=e;return{left:t-o/2-r,top:i-o/2-r}},kr=e=>{const{x:t,y:i,size:o,borderWidth:r}=e;return{left:t-o/2-r,top:i-o/2-r}},Pr=e=>({type:e.getAttribute(vr),fromAnchorId:e.getAttribute(xr)||"",openedAnchorId:e.getAttribute(wr)||""}),Tr=e=>{const t=e.querySelectorAll(`[${gr}="${Mr}"]`);Array.from(t).forEach(e=>{e?.remove()})},Nr=(e,t)=>{const i=e.querySelector(`[${gr}="${Sr}"]`),o=e.querySelector(`[${gr}="${Ir}"]`);if(!i||!o)return;Tr(e);const{currentDirector:r,prevDirector:a,styles:n}=t;if(a||r){const e=((e,t)=>{const{styles:i}=t,o=`\n <svg\n width="100%"\n height="100%"\n overflow="visible"\n xmlns="http://www.w3.org/2000/svg" \n ${yt}="true"\n >\n ${e.map(e=>{if(!e)return"";const{anchorPoint:t,directPoint:o}=e,r=t.x,a=t.y;return`<line \n x1="${r}" \n x2="${o.x}" \n y1="${a}" \n y2="${o.y}" \n stroke="${i.directorLineColor}" \n stroke-width="2" \n ${yt}="true"\n />`}).join("")}\n </svg>\n `;return rt("div",{width:"100%",height:"100%",className:nr.directorLines,[gr]:Mr,[yt]:"true"},[at(o)])})([a,r],{styles:n});i.firstElementChild&&i.insertBefore(e,o)}},Dr=e=>{if(!e)return;const t=e.querySelectorAll(`[${gr}="${Ar}"]`);Array.from(t).forEach(e=>{e?.remove()}),Tr(e)},$r=(e,t)=>{const{selectedAnchorId:i,prevDirector:o,currentDirector:r,styles:a}=t,n=[];o&&n.push(o),r&&n.push(r);const s=Array.from(e.querySelectorAll(`[${gr}="${Ar}"]`));let l=!1;if(n.length===s.length)for(let e=0;e<s.length;e++){const t=s[e],o=n[e],r=Pr(s[e]);if(r.openedAnchorId!==i||r.fromAnchorId!==o.anchorId){l=!0;break}it(t,kr({x:o.directPoint.x,y:o.directPoint.y,size:a.directorSize,borderWidth:a.directorBorderWidth}))}else l=!0;l&&Hr(e,{prevDirector:o,currentDirector:r,styles:a})},Hr=(e,t)=>{if(!e)return;const i=e.querySelector(`[${gr}="${Sr}"]`);if(!i)return;Dr(e),Nr(e,t);const{currentDirector:o,prevDirector:r,styles:a}=t;if(r){const e=rt("div",{[gr]:Ar,[vr]:"curve-ctrl2",[xr]:r.anchorId,[wr]:r.openedByAnchorId,[yt]:"true",className:nr.director,style:{...kr({x:r.directPoint.x,y:r.directPoint.y,size:a.directorSize,borderWidth:a.directorBorderWidth})}});i.appendChild(e)}if(o){const e=rt("div",{[gr]:Ar,[vr]:"curve-ctrl1",[xr]:o.anchorId,[wr]:o.openedByAnchorId,[yt]:"true",className:nr.director,style:{...kr({x:o.directPoint.x,y:o.directPoint.y,size:a.directorSize,borderWidth:a.directorBorderWidth})}});i.appendChild(e)}},Wr=(e,t)=>{if(!e)return;const i=e.querySelector(`[${gr}="${Sr}"]`);if(!i)return;const o=rt("div",{className:nr.pathLine,[gr]:Ir,[yt]:"true"});i.firstElementChild&&i.insertBefore(o,i.firstElementChild),Vr(e,t)},Or=(e,t)=>{const i=e.querySelector(`[${gr}="${Ir}"]`);if(!i)return;const o=i.querySelector(`[${gr}="${Cr}"]`);if(o){const{anchorCommands:e}=t;ot(o,{d:de(e)})}else Vr(e,t)},Vr=(e,t)=>{const i=e.querySelector(`[${gr}="${Ir}"]`);if(!i)return;i?.children&&Array.from(i.children).forEach(e=>{e.remove()});const{anchorCommands:o,styles:r}=t;ot(i,{},[at(`\n <svg \n width="100%" \n height="100%" \n overflow="visible" \n fill="transparent"\n ${yt}="true"\n >\n <path \n ${gr}="${Cr}" \n d="${de(o)}" \n stroke="${r.helperStrokeColor}"\n stroke-width="${r.helperStrokeWidth}"\n ${yt}="true"\n />\n </svg>\n `)])};function Yr(e,t){const{pageX:i,pageY:o}=e,r=t.getBoundingClientRect(),a=window.scrollX||document.documentElement.scrollLeft,n=window.scrollY||document.documentElement.scrollTop;return{x:i-(r.left+a),y:o-(r.top+n)}}function jr(e,t){const{calculator:i}=t,{id:o}=e;return[...i.getVirtualItem(o).anchorCommands||[]]}const Gr="idraw-middleware-path-creator",Fr={hide:`${Gr}-hide`,anchor:`${Gr}-anchor`,selected:`${Gr}-selected`},Xr="data-x",Qr="data-y",Ur="data-helper-type",Zr="data-anchor-cmd-type",Jr="data-anchor-index",Kr="data-anchor-id",qr="anchor",_r={anchorSize:8,anchorBorderWidth:2,anchorBorderColor:"#157ed1",anchorBackground:"#ffffff",anchorHoverBorderColor:"#1671b8",anchorHoverBackground:"#cfe4f4",anchorActiveBorderColor:"#0d548c",anchorActiveBackground:"#88c0ec",defaultStroke:"#a0a0a0",defaultStrokeWidth:2};function ea(e){return N(e,["anchorSize","anchorBorderWidth","anchorBorderColor","anchorBackground","anchorHoverBorderColor","anchorHoverBackground","anchorActiveBorderColor","anchorActiveBackground","defaultStroke","defaultStrokeWidth"])}const ta=e=>{const{x:t,y:i,size:o,borderWidth:r}=e;return{left:t-o/2-r,top:i-o/2-r}};function ia(e,t){const{point:i,viewScaleInfo:o,styles:r}=t,a=Array.from(e.querySelectorAll(`[${Ur}="${qr}"]`)),n=a.length,s=Xe(),l=function(e){const{id:t,index:i,point:o,commandType:r,viewScaleInfo:a,styles:n}=e,s=ae(o,{viewScaleInfo:a});return rt("div",{[Ur]:qr,[Zr]:r,[Jr]:i,[Kr]:t,[yt]:"true",[Xr]:o.x,[Qr]:o.y,className:Fr.anchor,style:{...ta({x:s.x,y:s.y,size:n.anchorSize,borderWidth:n.anchorBorderWidth}),display:"block"}})}({index:n,id:s,point:i,styles:r,viewScaleInfo:o,commandType:0===n?"M":"C"});if(0===n)e.appendChild(l);else{a[a.length-1].after(l)}return{id:s}}function oa(e,t){const{viewScaleInfo:i,styles:o}=t;Array.from(e.querySelectorAll(`[${Ur}="${qr}"]`)).forEach(e=>{const t={id:(r=e).getAttribute(Kr)||"",type:r.getAttribute(Ur)||"",x:parseFloat(r.getAttribute(Xr)||"0"),y:parseFloat(r.getAttribute(Qr)||"0")};var r;const a=ae({x:t.x,y:t.y},{viewScaleInfo:i});it(e,ta({...a,size:o.anchorSize,borderWidth:o.anchorBorderWidth}))})}const ra="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAApCAYAAABHomvIAAAACXBIWXMAAAsTAAALEwEAmpwYAAAF92lUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQiPz4gPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iQWRvYmUgWE1QIENvcmUgNi4wLWMwMDYgNzkuMTY0NzUzLCAyMDIxLzAyLzE1LTExOjUyOjEzICAgICAgICAiPiA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC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LcFZXbDQAVlAM8ChU3+RYgI1bOUDkNwpHvZSGI6xoylCeV/vyFZp1BaBQtnZQbxYOirwop9hWztlBJKKKg/QkIURtjam0oBi4U+r5HrihEsIRUmNjo1vhEomEzCvRbcprSthPsiB1sYuLi8cYP56ZmdGurq4IzYVQRf/F8XxGFWi+D2HKOQmboO+hUH2+srLyGyqmDjYsgNgcGRl5CCY+wfu3oVzrY2EXDivMc4NaPAMQrSxIhwQif4oK9z+en5F3CriecA7U/E2rB4AcxQcKBI/udwR5SStFKKuuayagLFqPyOeVnGmOkCOVY6crx5KMNSX0L5QSqWyOutbVvRQXk/wiE0qeA2qKq4lnbJY2AAAAAElFTkSuQmCC"};#ge={};constructor(e,t){this.#ce=e,this.#X=t.eventHub,this.#S(),this.#me(),Object.keys(this.#fe).forEach(e=>{const t=`${aa}-${e}`;this.#ge[e]=t;const i=this.#fe[e];this.#pe(e,t,i)})}#pe(e,t,i){const{offsetX:o,offsetY:r}=this.#ye(e);mt({rootClassName:t,type:"element",styles:{cursor:`image-set(url(${i})2x) ${o} ${r}, auto`}})}#S(){const e=this.#X;this.#xe("default"),e.on(o.CURSOR,e=>{"over-material"!==e.type&&e.type?"resize-rotate"===e.type?this.#xe("rotate"):"string"==typeof e.type&&e.type?.startsWith("resize-")?this.#ve(e):"drag-default"===e.type?this.#xe("drag-default"):"drag-active"===e.type?this.#xe("drag-active"):"pen"===e.type?this.#xe("pen"):"plus"===e.type?this.#xe("plus"):this.#xe("auto"):this.#xe("auto")})}#me(){g(ra).then(e=>{this.#ue=e}).catch(e=>{console.error(e)})}#ye(e){let t=0,i=0;return e.startsWith("rotate-")&&this.#fe[e]||"rotate"===e?(t=10,i=10):"plus"===e&&(t=5,i=3),{offsetX:t,offsetY:i}}#xe(e){if(this.#de===e)return;this.#de=e;const t=this.#ce,i=this.#ge[e]||this.#ge.auto;tt(t,Object.keys(this.#ge).map(e=>this.#ge[e])),et(t,[i])}#ve(e){let t=0;"resize-top"===e.type?t+=0:"resize-top-right"===e.type?t+=45:"resize-right"===e.type?t+=90:"resize-bottom-right"===e.type?t+=135:"resize-bottom"===e.type?t+=180:"resize-bottom-left"===e.type?t+=225:"resize-left"===e.type?t+=270:"resize-top-left"===e.type&&(t+=315),t+=X(e?.material?.angle||0),Array.isArray(e.groupQueue)&&e.groupQueue.length>0&&e.groupQueue.forEach(e=>{t+=X(e.angle||0)}),t=X(t);const i=this.#we(t);this.#xe(i)}#we(e){const t=`rotate-${e}`;if(!this.#fe[t]){const i=this.#ue;if(i){const o=document.createElement("canvas"),r=i.width,a=i.height,n={x:r/2,y:a/2};o.width=r,o.height=a;const s=o.getContext("2d"),l=D(e);s.translate(n.x,n.y),s.rotate(l),s.translate(-n.x,-n.y),s.drawImage(i,0,0,r,a),s.translate(n.x,n.y),s.rotate(-l),s.translate(-n.x,-n.y);const h=o.toDataURL("image/png");this.#fe[t]=h;const c=`${aa}-${t}`;this.#ge[t]=c,this.#pe(t,c,h)}}return t}}function sa(e){const{modifiedMaterial:t,beforeMaterial:i}=e,{id:o,...r}=t,a=ve(r);let n={};Object.keys(a).forEach(e=>{let t=Ae(i,e);void 0===t&&/(cornerRadius|strokeWidth)\[[0-9]{1,}\]$/.test(e)&&(e=e.replace(/\[[0-9]{1,}\]$/,""),t=Ae(i,e)),n[e]=t}),n=ve(n);return{type:"modifyMaterial",time:Date.now(),content:{method:"modifyMaterial",id:o,before:n,after:a}}}return e.Board=Xt,e.Calculator=Ht,e.Core=class{#Se;#be;#ce;constructor(e,t){const{devicePixelRatio:i=1,width:o,height:r,disableWatcher:a=!1}=t;it(e,{width:o,height:r}),this.#ce=e;const n=document.createElement("canvas");n.setAttribute("tabindex","0"),it(n,{margin:0,padding:0}),this.#be=n,this.#Ae(),e.appendChild(n);const s=z(n,{width:o,height:r,devicePixelRatio:i}),l=new Xt({boardContent:s,container:e,disableWatcher:a}),h=l.getSharer();h.setActiveViewSizeInfo({width:o,height:r,devicePixelRatio:i,contextWidth:o,contextHeight:r}),this.#Se=l,this.resize(h.getActiveViewSizeInfo());const c=l.getEventHub();new na(e,{eventHub:c})}isDestroyed(){return this.#Se.isDestroyed()}destroy(){this.#Se.destroy(),this.#be.remove()}#Ae(){it(this.#ce,{position:"relative",margin:"0px",padding:"0px",overflow:"hidden"})}use(e,t){this.#Se.use(e,t)}disuse(e){this.#Se.disuse(e)}resetMiddlewareConfig(e,t){this.#Se.resetMiddlewareConfig(e,t)}#Me(e){Q(e?.materials||[]),this.#Se.setData(e)}setData(e){this.#Se.getRenderer().getLoader().reset(),this.#Me(e)}getData(){return this.#Se.getData()}scale(e){this.#Se.scale(e);this.#Se.getViewer().drawFrame()}resize(e){const t=this.#Se,i=this.#ce,o={...t.getSharer().getActiveViewSizeInfo(),...e},{width:r,height:a}=o;it(i,{width:r,height:a}),t.resize(o)}clear(){this.#Se.clear()}on(e,t){this.#Se.getEventHub().on(e,t)}off(e,t){this.#Se.getEventHub().off(e,t)}trigger(e,t){this.#Se.getEventHub().trigger(e,t)}getViewInfo(){const e=this.#Se.getSharer();return{viewSizeInfo:e.getActiveViewSizeInfo(),viewScaleInfo:e.getActiveViewScaleInfo()}}refresh(){this.#Se.getViewer().drawFrame()}forceRender(){const e=this.#Se.getRenderer(),t=e.getCalculator(),i=e.getLoader(),o=this.getData();if(o){const{viewScaleInfo:e,viewSizeInfo:i}=this.getViewInfo();t.resetVirtualItemMap(o,{viewScaleInfo:e,viewSizeInfo:i})}i.reset(),this.refresh()}setViewScale(e){this.#Se.updateViewScaleInfo(e)}getLoadItemMap(){return this.#Se.getRenderer().getLoadItemMap()}onBoardWatcherEvents(){this.#Se.onWatcherEvents()}offBoardWatcherEvents(){this.#Se.offWatcherEvents()}createMaterial(e,t,i){const{viewScaleInfo:o,viewSizeInfo:r}=this.getViewInfo();return Le(e,t||{},!0===i?.viewCenter?{viewScaleInfo:o,viewSizeInfo:r}:void 0)}updateMaterial(e){const t=this.getData()||{materials:[]},i=e.id,o=_(i,t.materials),r=q(o,t.materials);if(!r)return null;const a=ve(r),n=ve(Ne(o,e,t.materials,{onlyUpdateContent:!0}));this.#Se.getRenderer().getLoader().resetMaterialAsset(e),this.#Me(t),this.refresh();return{type:"updateMaterial",time:Date.now(),content:{method:"updateMaterial",id:i,before:a,after:n}}}modifyMaterial(e){const{id:t,...i}=e,o=this.getData()||{materials:[]},r=_(t,o.materials),a=q(r,o.materials);if(!a)return null;const n=sa({modifiedMaterial:e,beforeMaterial:a});Ne(r,i,o.materials);return this.#Se.getRenderer().getLoader().resetMaterialAsset({...e,type:a.type}),this.#Me(o),this.refresh(),n}modifyMaterials(e){const t=this.getData()||{materials:[]};let i=null;const o=[],r=[];return e.forEach(e=>{const{id:i,...a}=e,n=_(i,t.materials),s=q(n,t.materials);if(!s)return null;const l=sa({modifiedMaterial:e,beforeMaterial:s});l.content&&(o.push({...l.content.before,id:i}),r.push({...l.content.after,id:i})),Ne(n,a,t.materials)}),i={type:"modifyMaterials",time:Date.now(),content:{method:"modifyMaterials",before:o,after:r}},this.#Me(t),this.refresh(),i}addMaterial(e,t){const i=this.getData()||{materials:[]};if(t&&t?.position?.length){if(t?.position){Be(e,[...t?.position||[]],i.materials)}}else i.materials.push(e);const o=_(e.id,i.materials),r={type:"addMaterial",time:Date.now(),content:{method:"addMaterial",id:e.id,position:o,material:c(e)}};return this.#Me(i),this.refresh(),r}deleteMaterial(e){const t=this.getData()||{materials:[]},i=_(e,t.materials),o=q(i,t.materials),r={type:"deleteMaterial",time:Date.now(),content:{method:"deleteMaterial",id:e,position:i,material:o?c(o):null}};if(o){this.#Se.getRenderer().getLoader().resetMaterialAsset(o)}return function(e,t){ke(_(e,t),t)}(e,t.materials),this.#Me(t),this.refresh(),r}moveMaterial(e,t){const i=this.getData()||{materials:[]},o=_(e,i.materials),r={type:"moveMaterial",time:Date.now(),content:{method:"moveMaterial",id:e,from:[...o],to:[...t]}},{materials:a}=function(e,t){const i=[...t.from],o=[...t.to];if(0===i.length||0===o.length)return{materials:e,from:i,to:o};if(i.length<=o.length)for(let t=0;t<i.length;t++)if(o[t]!==i[t]);else if(t===i.length-1)return{materials:e,from:i,to:o};const r=q(i,e);if(r){if(!Be(r,o,e))return{materials:e,from:i,to:o};let t=-1,a=!1;if(i.length>=1&&o.length>=1){if(i.length<=o.length)if(1===i.length)i[0]<o[0]&&(a=!0);else for(let e=0;e<i.length&&i[e]===o[e];e++)if(i.length===i.length-1){a=!0;break}if(i.length>=o.length)if(1===o.length)o[0]<i[0]&&(a=!0);else for(let e=0;e<o.length&&(e===o.length-1&&o[e]<i[e]&&(a=!0),i[e]===o[e]);e++);}if(!0===a)for(let e=0;e<i.length&&o[e]>=0;e++)o[e]!==i[e]&&o[e]<i[e]&&e==o.length-1&&(t=e);t>=0&&(i[t]=i[t]+1),ke(i,e)}return{materials:e,from:i,to:o}}(i.materials,{from:o,to:t});return i.materials=a,this.#Me(i),this.refresh(),r}modifyLayout(e){const t=this.getData()||{materials:[]},i={type:"modifyLayout",time:Date.now(),content:{method:"modifyLayout",before:null,after:null}};if(null===e)return t.layout?(i.content.before=we(t.layout),delete t.layout,this.#Me(t),this.refresh(),i):i;const o=t.layout;let r={};const a=we(e);return t.layout?(Object.keys(a).forEach(e=>{let t=Ae(o,e);void 0===t&&/(cornerRadius|strokeWidth)\[[0-9]{1,}\]$/.test(e)&&(e=e.replace(/\[[0-9]{1,}\]$/,""),t=Ae(o,e)),r[e]=t}),r=we(r),i.content.before=r):t.layout={},i.content.after=a,function(e,t){const i=we(t),o=[];Object.keys(i).forEach(t=>{if(!o.includes(t)){const o=i[t];Ie(e,t),void 0!==o&&Me(e,t,o)}})}(t.layout,e),this.#Me(t),this.refresh(),i}modifyGlobal(e){const t=this.getData()||{materials:[]},i={type:"modifyGlobal",time:Date.now(),content:{method:"modifyGlobal",before:null,after:null}};if(null===e)return t.global?(i.content.before=Se(t.global),delete t.global,this.#Me(t),this.refresh(),i):i;const o=t.global;let r={};const a=Se(e);return t.global?(Object.keys(a).forEach(e=>{r[e]=Ae(o,e)}),r=Se(r),i.content.before=r):t.global={},i.content.after=a,function(e,t){const i=Se(t),o=[];Object.keys(i).forEach(t=>{if(!o.includes(t)){const o=i[t];Ie(e,t),void 0!==o&&Me(e,t,o)}})}(t.global,e),this.#Me(t),this.refresh(),i}},e.MiddlewareCreator=(e,t)=>{const{sharer:i,viewer:r,calculator:a,eventHub:n}=e;let s={...qt,..._t,...t};const l=ti(s),h=`${Kt}-${Xe()}`;let d=null,u=null;const f=()=>{i.setSharedStorage(Ut,null),i.setSharedStorage(Zt,null),u=null};f();let g=!1;const m=({type:e})=>{g=!0,d&&(n.trigger(o.CURSOR,{type:"plus"}),i.setSharedStorage(Jt,e),et(d,[ei.creative]),n.trigger(o.CLEAR_SELECT))},p=()=>{n.trigger(o.CURSOR,{type:"auto"}),g=!1,d&&tt(d,[ei.creative])};return{name:"@middleware/creator",use(){!function(e,t){const i=e=>`.${e}`;mt({styles:{display:"none",zIndex:t.zIndex,position:"absolute",background:"transparent",top:0,bottom:0,left:0,right:0,overflow:"hidden",[`&${i(ei.creative)}`]:{display:"block"},[i(ei.creationAreaBox)]:{position:"absolute",outline:`1.5px solid ${t.creationAreaBorderColor}`,background:"#0000ff1f"}},rootClassName:e,type:"element"})}(h,l),d=function(e){const{rootClassName:t,$container:i}=e,o=rt("div",{className:t,[yt]:"true"},[]);return i.appendChild(o),o}({rootClassName:h,$container:e.container}),n.on(o.CREATE,m),n.on(o.CLEAR_CREATE,p)},disuse(){!function(e){pt({rootClassName:e,type:"element"})}(h),d?.remove(),d=null,n.trigger(o.CURSOR,{type:"auto"}),n.off(o.CREATE,m),n.off(o.CLEAR_CREATE,p)},resetConfig(e){s={...s,...e}},pointStart:e=>{f(),g&&i.setSharedStorage(Ut,e.point)},pointMove:e=>{if(!g)return;i.setSharedStorage(Zt,e.point);const t=i.getSharedStorage(Jt),o=i.getSharedStorage(Ut),n=i.getSharedStorage(Zt),s=i.getActiveViewScaleInfo(),l=i.getActiveViewSizeInfo(),h=i.getActiveStorage("data");u&&o&&n?(u=function(e,t){const i=ri(t),{type:o}=e,r={...e,...i};return"circle"===o?r.r=Math.min(i.width,i.height)/2:"ellipse"===o?(r.rx=i.width/2,r.ry=i.height/2):"text"===o&&(r.fontSize=Math.min(i.width,i.height)),r}(u,{start:o,end:n,viewScaleInfo:s,calculator:a}),Te(u.id,u,h.materials),a.modifyVirtualAttributes(u,{viewScaleInfo:s,viewSizeInfo:l,groupQueue:[]})):t&&o&&n&&(u=function(e,t){const{fill:i,text:o,href:r}=pe(),a={fill:i};return"circle"===e?a.r=1:"ellipse"===e?(a.rx=1,a.ry=1):"text"===e?(a.text=o,a.fontSize=1):"image"===e?a.href=r:"group"===e&&(a.children=[]),{id:Xe(),type:e,...a,...ri(t)}}(t,{start:o,end:n,viewScaleInfo:s,calculator:a}),h.materials.push(u),a.resetVirtualItemMap(h,{viewScaleInfo:s,viewSizeInfo:l})),r.drawFrame()},pointEnd:()=>{if(g){if(u){const e=i.getActiveStorage("data"),t={type:"addMaterial",time:Date.now(),content:{method:"addMaterial",id:u.id,position:[e.materials?.length],material:c(u)}};ai(n,{data:e,type:"addMaterial",modifyRecord:t},"all")}if(!0===s.selectAfterCreated&&u?.id){const e=u.id;n.trigger(o.SELECT,{ids:[e],type:"selectMaterial"})}s.afterCreated?.(),ii(d),p(),f()}},beforeDrawFrame(){const e=i.getSharedStorage(Ut),t=i.getSharedStorage(Zt);e&&t?oi(d,{start:e,end:t}):ii(d)}}},e.MiddlewareDragger=e=>{const{eventHub:t,sharer:i,viewer:r}=e;let a=!1;return{name:"@middleware/dragger",hover(){!0!==a&&t.trigger(o.CURSOR,{type:"drag-default"})},pointStart(e){const{point:r}=e;i.setSharedStorage(rr,r),a=!0,t.trigger(o.CURSOR,{type:"drag-active"})},pointMove(e){const{point:t}=e,o=i.getSharedStorage(rr);if(t&&o){const e=t.x-o.x,i=t.y-o.y;r.scroll({moveX:e,moveY:i}),r.drawFrame()}i.setSharedStorage(rr,t)},pointEnd(){a=!1,i.setSharedStorage(rr,null),t.trigger(o.CURSOR,{type:"drag-default"})}}},e.MiddlewareInfo=(e,t)=>{const{boardContent:i,calculator:o,eventHub:r}=e,{overlayContext:a}=i;let s={...lo,...t};const l=ho(s);let h=!0;const c=({show:e})=>{h=e};return{name:"@middleware/info",use(){r.on(so,c)},disuse(){r.off(so,c)},resetConfig(e){s={...s,...e}},beforeDrawFrame({snapshot:e}){const{sharedStore:t}=e,i=t[Ri],r=t[bi],s=t[Li]||[];if(1===i?.length){const t=i[0];if(t&&["select","drag","resize"].includes(r)){const i=P(e),r=T(e),{x:c,y:d,width:u,height:f,angle:g}=t,m=[...s,{id:n(),x:c,y:d,width:u,height:f,angle:g,type:"group",children:[]}],p={viewScaleInfo:i,viewSizeInfo:r},y=o.calcViewBoundingInfoFromOrigin(t.id,p);let x=0;m.forEach(e=>{x+=e.angle||0});const v=D(X(0-x));if(y){const e=y?.center,i={topLeft:V(e,y.topLeft,v),topRight:V(e,y.topRight,v),bottomRight:V(e,y.bottomRight,v),bottomLeft:V(e,y.bottomLeft,v),center:V(e,y.center,v),top:V(e,y.top,v),right:V(e,y.right,v),bottom:V(e,y.bottom,v),left:V(e,y.left,v)},o=ue(t.x,{decimalPlaces:2}),r=ue(t.y,{decimalPlaces:2}),n=ue(t.width,{decimalPlaces:2}),s=ue(t.height,{decimalPlaces:2}),c=`${ue(o,{decimalPlaces:0})},${ue(r,{decimalPlaces:0})}`,d=`${ue(n,{decimalPlaces:0})}x${ue(s,{decimalPlaces:0})}`,u=`${ue(X(t.angle||0),{decimalPlaces:0})}°`;!function(e,t){const{point:i,rotateCenter:o,angle:r,text:a,styles:n,fontSize:s,lineHeight:l}=t,{textColor:h,textBackground:c}=n;$(e,r,o,()=>{e.$setFont({fontWeight:"300",fontSize:s,fontFamily:no});const t=(l-s)/2,o=e.$undoPixelRatio(e.measureText(a).width),r={x:i.x-o/2-t,y:i.y},n={x:r.x+o+2*t,y:r.y+s+t},d={x:i.x-o/2,y:i.y};e.setLineDash([]),e.fillStyle=c,e.beginPath(),e.moveTo(r.x,r.y),e.lineTo(n.x,r.y),e.lineTo(n.x,n.y),e.lineTo(r.x,n.y),e.closePath(),e.fill("nonzero"),e.fillStyle=h,e.textBaseline="top",e.fillText(a,d.x,d.y+t)})}(a,{point:{x:i.bottom.x,y:i.bottom.y+co},rotateCenter:i.center,angle:x,text:d,fontSize:co,lineHeight:16,styles:l}),function(e,t){const{point:i,rotateCenter:o,angle:r,text:a,styles:n,fontSize:s,lineHeight:l}=t,{textBackground:h,textColor:c}=n;$(e,r,o,()=>{e.$setFont({fontWeight:"300",fontSize:s,fontFamily:no});const t=(l-s)/2,o=e.$undoPixelRatio(e.measureText(a).width),r={x:i.x,y:i.y},n={x:r.x+o+2*t,y:r.y+s+t},d={x:i.x+t,y:i.y};e.setLineDash([]),e.fillStyle=h,e.beginPath(),e.moveTo(r.x,r.y),e.lineTo(n.x,r.y),e.lineTo(n.x,n.y),e.lineTo(r.x,n.y),e.closePath(),e.fill("nonzero"),e.fillStyle=c,e.textBaseline="top",e.fillText(a,d.x,d.y+t)})}(a,{point:{x:i.topLeft.x,y:i.topLeft.y-20},rotateCenter:i.center,angle:x,text:c,fontSize:co,lineHeight:16,styles:l}),h&&!1!==t.operations?.rotatable&&function(e,t){const{point:i,rotateCenter:o,angle:r,text:a,styles:n,fontSize:s,lineHeight:l}=t,{textBackground:h,textColor:c}=n;$(e,r,o,()=>{e.$setFont({fontWeight:"300",fontSize:s,fontFamily:no});const t=(l-s)/2,o=e.$undoPixelRatio(e.measureText(a).width),r={x:i.x,y:i.y},n={x:r.x+o+2*t,y:r.y+s+t},d={x:i.x+t,y:i.y};e.setLineDash([]),e.fillStyle=h,e.beginPath(),e.moveTo(r.x,r.y),e.lineTo(n.x,r.y),e.lineTo(n.x,n.y),e.lineTo(r.x,n.y),e.closePath(),e.fill("nonzero"),e.fillStyle=c,e.textBaseline="top",e.fillText(a,d.x,d.y+t)})}(a,{point:{x:i.top.x+co+4,y:i.top.y-20-18},rotateCenter:i.center,angle:x,text:u,fontSize:co,lineHeight:16,styles:l})}}}}}},e.MiddlewareLayoutSelector=(e,t)=>{const{sharer:i,calculator:r,viewer:a,eventHub:n}=e;let s={...io,...t};const l=function(e){return N(e,["zIndex","activeColor","handlerBorderColor","handlerBackground","handlerHoverBackground","handlerActiveBackground"])}(s),h=`${_i}-${Xe()}`;let c=null,d=null,u=null,f=null;const g=()=>{c=null,i.setSharedStorage(Qi,null),i.setSharedStorage(Ui,null),i.setSharedStorage(Zi,null),i.setSharedStorage(Ji,null),i.setSharedStorage(Ki,null),i.setSharedStorage(qi,null),d=null,u=null},m=()=>{const e=i.getSharedStorage(bi);return!(!e||"area"===e)&&(g(),!0)},p=()=>{const e=i.getActiveStorage("data");if(e?.layout){const{x:t,y:i,width:o,height:r}=e.layout;return{x:t,y:i,width:o,height:r}}return null},y=e=>{const t=p();if(t){const{x:o,y:r,width:a,height:n}=t;return le(e,re({x:o-5,y:r-5,width:a+10,height:n+10},{viewScaleInfo:i.getActiveViewScaleInfo()}))}return!1},x=e=>{const t=i.getActiveStorage("data"),r=e.nativeEvent.target;let a=null;if(r?.hasAttribute(eo)&&t?.layout&&e?.point){i.setSharedStorage(Ui,null);const e=r.getAttribute(eo);e&&(i.setSharedStorage(Ui,e),n.trigger(o.CLEAR_SELECT),a=e)}return a?i.setSharedStorage(Ji,!0):i.setSharedStorage(Ji,!1),a},v=e=>{!0!==i.getSharedStorage(qi)&&n.trigger(o.CURSOR,{type:e?`resize-${e}`:e,groupQueue:[],material:p()})};return{name:"@middleware/layout-selector",use:()=>{g(),function(e,t){const i=e=>`.${e}`;mt({styles:{zIndex:t.zIndex,position:"absolute",background:"transparent",[`&${i(oo.hover)}`]:{[`&${i(oo.cornerHandler)}`]:{display:"none"},[`&${i(oo.edgeHandler)}`]:{width:"1px",height:"1px",[`&${i(oo.edgeLeftHandler)}`]:{width:"1px"},[`&${i(oo.edgeRightHandler)}`]:{width:"1px"},[`&${i(oo.edgeTopHandler)}`]:{height:"1px"},[`&${i(oo.edgeBottomHandler)}`]:{height:"1px"}}},[`&${i(oo.cornerHandler)}`]:{outline:`1.5px solid ${t.handlerBorderColor}`,background:t.handlerBackground,width:"10px",height:"10px",top:"unset",bottom:"unset",left:"unset",right:"unset","&:hover":{background:t.handlerHoverBackground},"&:active":{background:t.handlerActiveBackground},[`&${i(oo.cornerTopLeftHandler)}`]:{transform:"translate(-50%, -50%)"},[`&${i(oo.cornerTopRightHandler)}`]:{transform:"translate(-50%, -50%)"},[`&${i(oo.cornerBottomLeftHandler)}`]:{transform:"translate(-50%, -50%)"},[`&${i(oo.cornerBottomRightHandler)}`]:{transform:"translate(-50%, -50%)"}},[`&${i(oo.edgeHandler)}`]:{width:"10px",height:"10px","&:after":{position:"absolute",content:'""',background:t.handlerBorderColor},[`&${i(oo.edgeLeftHandler)}`]:{width:"10px",transform:"translateX(-50%)","&:after":{top:0,bottom:0,left:"50%",right:"unset",width:to}},[`&${i(oo.edgeRightHandler)}`]:{width:"10px",transform:"translateX(-50%)","&:after":{top:0,bottom:0,left:"50%",right:"unset",width:to}},[`&${i(oo.edgeTopHandler)}`]:{height:"10px",transform:"translateY(-50%)","&:after":{left:0,right:0,top:"50%",bottom:"unset",height:to}},[`&${i(oo.edgeBottomHandler)}`]:{height:"10px",transform:"translateY(-50%)","&:after":{left:0,right:0,top:"50%",bottom:"unset",height:to}}}},rootClassName:e,type:"element"})}(h,l)},disuse:()=>{g(),function(e){pt({rootClassName:e,type:"element"})}(h)},resetConfig(e){s={...s,...e}},hover:e=>{if(!0===i.getSharedStorage(qi))return;y(e.point)?i.setSharedStorage(Zi,!0):(i.setSharedStorage(Zi,!1),!0===d&&(a.drawFrame(),d=!1));const t=i.getSharedStorage(Qi),o=i.getActiveStorage("data");if(o?.layout)if("resize"!==t){const t=x(e);t?v(t):(v(),i.setSharedStorage(Qi,null))}else{const t=x(e);v(t)}},pointStart:t=>{y(t.point)?i.setSharedStorage(Ki,!0):(!0===u&&(e.container&&ro(e.container,{rootClassName:h}),g(),a.drawFrame()),i.setSharedStorage(Ki,!1));const r=i.getActiveStorage("data");f=r?.layout?K(r.layout):null;const s=x(t);if(c=t.point,s&&i.setSharedStorage(Qi,"resize"),!0!==i.getSharedStorage(Ki)||u||(a.drawFrame(),n.trigger(o.SELECT_LAYOUT)),u=i.getSharedStorage(Ki),!0===i.getSharedStorage(Ji))return!1},pointMove:e=>{if(!i.getSharedStorage(Ki)&&m())return;const t=i.getSharedStorage(Qi),o=i.getSharedStorage(Ui),n=i.getActiveStorage("data");if("resize"===t&&o&&n?.layout){if(c){i.setSharedStorage(qi,!0);const t=i.getActiveStorage("scale"),s=e.point.x-c.x,l=e.point.y-c.y,h=s/t,d=l/t,{x:u,y:f,width:g,height:m,operations:p={}}=n.layout,{position:y="absolute"}=p;"top"===o?"relative"===y?(n.layout.height=r.toGridNum(m-d),a.scroll({moveY:l})):(n.layout.y=r.toGridNum(f+d),n.layout.height=r.toGridNum(m-d)):"right"===o?n.layout.width=r.toGridNum(g+h):"bottom"===o?n.layout.height=r.toGridNum(m+d):"left"===o?"relative"===y?(n.layout.width=r.toGridNum(g-h),a.scroll({moveX:s})):(n.layout.x=r.toGridNum(u+h),n.layout.width=r.toGridNum(g-h)):"top-left"===o?"relative"===y?(n.layout.width=r.toGridNum(g-h),n.layout.height=r.toGridNum(m-d),a.scroll({moveX:s,moveY:l})):(n.layout.x=r.toGridNum(u+h),n.layout.y=r.toGridNum(f+d),n.layout.width=r.toGridNum(g-h),n.layout.height=r.toGridNum(m-d)):"top-right"===o?"relative"===y?(a.scroll({moveY:l}),n.layout.width=r.toGridNum(g+h),n.layout.height=r.toGridNum(m-d)):(n.layout.y=r.toGridNum(f+d),n.layout.width=r.toGridNum(g+h),n.layout.height=r.toGridNum(m-d)):"bottom-right"===o?(n.layout.width=r.toGridNum(g+h),n.layout.height=r.toGridNum(m+d)):"bottom-left"===o&&("relative"===y?(a.scroll({moveX:s}),n.layout.width=r.toGridNum(g-h),n.layout.height=r.toGridNum(m+d)):(n.layout.x=r.toGridNum(u+h),n.layout.width=r.toGridNum(g-h),n.layout.height=r.toGridNum(m+d)))}return c=e.point,a.drawFrame(),!1}return!["resize"].includes(t)&&void 0},pointEnd:()=>{i.setSharedStorage(qi,!1);const e=i.getSharedStorage(Qi),t=i.getSharedStorage(Ui),o=i.getActiveStorage("data");if(o&&"resize"===e&&t){let e;f&&(e={type:"modifyLayout",time:Date.now(),content:{method:"modifyLayout",before:we(f),after:we(K(o.layout))}}),ai(n,{type:"resizeLayout",data:o,modifyRecord:e})}if(f=null,i.setSharedStorage(Qi,null),i.setSharedStorage(Ui,null),!0===i.getSharedStorage(Ji))return!1},beforeDrawFrame:({snapshot:t})=>{if(m())return;const{activeStore:o}=t,r=i.getActiveViewScaleInfo();e.container&&o.data?.layout&&ao(e.container,{rootClassName:h,viewScaleInfo:r,layout:o.data?.layout})}}},e.MiddlewarePathCreator=(e,t)=>{const i={..._r,...t},{defaultStrokeWidth:r,defaultStroke:a}=i,s=ea(i),l=`${Gr}-${Xe()}`,{viewer:h,eventHub:d,sharer:u,calculator:f}=e,g=e.container,m=l;let p=null,y=-1,x=null,v=null;const w=()=>{!function(e){if(!e)return;Array.from(e.children).forEach(e=>{e.remove()})}(p),v=null,x=null,y=-1},S=()=>{if(!x)return;x=Ke(x);const e=u.getActiveStorage("data");Te(x.id,{x:x.x,y:x.y,width:x.width,height:x.height,commands:x.commands},e.materials),f.modifyVirtualAttributes(x,{viewScaleInfo:u.getActiveViewScaleInfo(),viewSizeInfo:u.getActiveViewSizeInfo(),groupQueue:[]}),f.forceVisiable(x.id),h.drawFrame()},b=e=>{const t=e.target;if(t.getAttribute(Ur)===qr){const e=function(e){const t=e.getAttribute(Jr);return"string"==typeof t?parseInt(t):t}(t);return void(0===e&&y>1&&x&&(x.commands.push({id:Xe(),type:"Z",params:[]}),S(),w()))}const i=nt(p),o={x:e.pageX-i.pageX,y:e.pageY-i.pageY},l=u.getActiveViewScaleInfo(),g=u.getActiveViewSizeInfo(),m=ne(o,{viewScaleInfo:l}),{id:b}=ia(p,{point:m,viewScaleInfo:l,styles:s});y<0||!x?(y=0,x={id:n(),type:"path",x:0,y:0,width:g.width,height:g.height,strokeWidth:r,stroke:a,commands:[{id:b,type:"M",params:[m.x,m.y]}]}):(y++,x.commands.push({...Je(v,m),id:b})),v=m,(()=>{if(!x)return;const e=u.getActiveStorage("data");if(y>0)Te(x.id,{x:x.x,y:x.y,width:x.width,height:x.height,commands:x.commands},e.materials);else{e.materials.push(x);const t={type:"addMaterial",time:Date.now(),content:{method:"addMaterial",id:x.id,position:[e.materials?.length],material:c(x)}};ai(d,{data:e,type:"addMaterial",modifyRecord:t})}f.modifyVirtualAttributes(x,{viewScaleInfo:u.getActiveViewScaleInfo(),viewSizeInfo:u.getActiveViewSizeInfo(),groupQueue:[]}),f.forceVisiable(x.id),h.drawFrame()})()},A=()=>{},M=()=>{window.removeEventListener("mousemove",A)},I=()=>{window.removeEventListener("mousemove",A)},C=()=>{p?.removeEventListener("mousedown",b),window.removeEventListener("mouseup",M),window.removeEventListener("mouseleave",I)},R=()=>{g&&(p=function(e,t){const{id:i,rootClassName:o}=t;if(!e)return;const r=rt("div",{id:i,className:[Fr.hide,o].join(" "),[yt]:"true"});return e.contains(r)||e.appendChild(r),r}(g,{id:m,rootClassName:l}),g.contains(p)||g.appendChild(p))},E=()=>{p?.addEventListener("mousedown",b),window.addEventListener("mouseup",M),window.addEventListener("mouseleave",I),h.drawFrame()},z=()=>{S(),C(),w()};return{name:"@middleware/pen-create",use(){!function(e,t){mt({styles:{display:"flex",position:"absolute",top:0,left:0,right:0,bottom:0,overflow:"hidden",justifyContent:"center",alignItems:"center",[`.${Fr.anchor}`]:{position:"absolute",width:t.anchorSize,height:t.anchorSize,background:t.anchorBackground,border:`${t.anchorBorderWidth}px solid ${t.anchorBorderColor}`,borderRadius:"50%",overflow:"hidden","&:hover":{borderColor:t.anchorHoverBorderColor,background:t.anchorHoverBackground},"&:active":{borderColor:t.anchorActiveBorderColor,background:t.anchorActiveBackground},[`&.${Fr.selected}`]:{borderColor:t.anchorActiveBorderColor,background:t.anchorActiveBackground}}},rootClassName:e,type:"element"})}(l,s),d.on(o.PATH_CREATE,E),d.on(o.CLEAR_PATH_CREATE,z),R()},disuse(){!function(e){pt({rootClassName:e,type:"element"})}(l),d.off(o.PATH_CREATE,E),d.off(o.CLEAR_PATH_CREATE,z),w(),h.drawFrame(),C(),p?.remove(),p=null},beforeDrawFrame(){oa(p,{viewScaleInfo:u.getActiveViewScaleInfo(),styles:s})},hover:()=>(d.trigger(o.CURSOR,{type:"pen"}),!1)}},e.MiddlewarePathEditor=(e,t)=>{const{viewer:i,eventHub:r,sharer:a,calculator:n}=e,s={...Rr,...t},{afterClickAway:l}=s,h=`${ar}-${Xe()}`,c=Er(s),d=e.container,u=`idraw-middleware-path-editor-${Xe()}`;let f=null,g=!1,m=!1,p=null,y=null,x=null,v=null,w=null,S=null,b=null,A=null,M=null,I=null;const C=()=>{R(),S=null,b=null,A=null},R=()=>{M=null,I=null},E=()=>{if(!f)return;Array.from(f.getElementsByClassName(nr.selected)).forEach(e=>{tt(e,[nr.selected])})},z=()=>{p=null,v=null,w=null},L=e=>{const t=e.target,o=t?.getAttribute(gr);if(o===br&&y){e.stopPropagation(),e.preventDefault(),C(),w=K(y);const o=Yr(e,f);v=o,p="dragging-anchor",S=t,b=(e=>{const t=e.getAttribute(yr)||"";return{index:parseFloat(e.getAttribute(pr)||"0"),id:t}})(t),A=jr(y,{calculator:n}),window.addEventListener("mousemove",B),et(S,[nr.selected]),i.drawFrame()}else if(o===Ar&&y){e.stopPropagation(),e.preventDefault(),R(),w=K(y);const o=Yr(e,f);v=o,p="dragging-director",M=t,I=Pr(t),A=jr(y,{calculator:n}),window.addEventListener("mousemove",B),et(M,[nr.selected]),i.drawFrame()}else H(),l?.()},B=e=>{if(v&&y&&w&&A){const t=Yr(e,f),o=[...x||[],{...w,type:"group",id:y.id,angle:y.angle,children:[]}],{moveX:r,moveY:s}=He(v,t,o),l=a.getActiveStorage("scale")||1,h=n.toGridNum(r/l),c=n.toGridNum(s/l),d=[...A];if(S&&b&&"dragging-anchor"===p){const e=function(e,t){const i=[],{index:o,moveX:r,moveY:a}=t;e.forEach(e=>{const{id:t,type:o,params:r}=e,a={id:t,type:o,params:[...r]};i.push(a)});const n=i[o],s=i[o-1];if(!s||!n)return Ze(i);switch("M"===n.type&&(n.params[0]+=r,n.params[1]+=a),"C"===n.type&&(n.params[0]+=r,n.params[1]+=a),s.type){case"M":case"L":case"Z":s.params[0]+=r,s.params[1]+=a;break;case"A":s.params[5]+=r,s.params[6]+=a;break;case"C":s.params[2]+=r,s.params[3]+=a,s.params[4]+=r,s.params[5]+=a}return Ze(i)}(d,{index:b.index,moveX:h,moveY:c}),t=a.getActiveStorage("data"),o=e.map(({id:e,type:t,params:i})=>({id:e,type:t,params:i}));Te(y.id,{commands:o},t.materials),y.commands=o,n.modifyVirtualAttributes(y,{viewScaleInfo:a.getActiveViewScaleInfo(),viewSizeInfo:a.getActiveViewSizeInfo(),groupQueue:x||[]}),i.drawFrame()}else if(M&&I&&"dragging-director"===p){const{type:e,fromAnchorId:t}=I,o=d.findIndex(e=>e.id===t),r=function(e,t){const i=[],{index:o,type:r,moveX:a,moveY:n}=t;e.forEach(e=>{const{id:t,type:o,params:r}=e,a={id:t,type:o,params:[...r]};i.push(a)});const s=i[o];return"C"===s.type&&("curve-ctrl1"===r?(s.params[0]+=a,s.params[1]+=n):"curve-ctrl2"===r&&(s.params[2]+=a,s.params[3]+=n)),Ze(i)}(d,{type:e,index:o,moveX:h,moveY:c}),s=a.getActiveStorage("data")||{materials:[]},l=r.map(({id:e,type:t,params:i})=>({id:e,type:t,params:i}));Te(y.id,{commands:l},s.materials),y.commands=l,n.modifyVirtualAttributes(y,{viewScaleInfo:a.getActiveViewScaleInfo(),viewSizeInfo:a.getActiveViewSizeInfo(),groupQueue:x||[]}),i.drawFrame()}}},k=()=>{if(!y)return;y=Ke(y);const e=a.getActiveStorage("data")||{materials:[]};Te(y.id,{x:y.x,y:y.y,width:y.width,height:y.height,commands:y.commands},e.materials),n.modifyVirtualAttributes(y,{viewScaleInfo:a.getActiveViewScaleInfo(),viewSizeInfo:a.getActiveViewSizeInfo(),groupQueue:x||[]}),i.drawFrame()},P=()=>{window.removeEventListener("mousemove",B),k(),E(),z()},T=()=>{window.removeEventListener("mousemove",B),k(),E(),z()},N=()=>{d&&(f=function(e,t){const{id:i,rootClassName:o}=t;if(!e)return;const r=rt("div",{id:i,className:[nr.hide,o].join(" "),[yt]:"true"});return e.contains(r)||e.appendChild(r),r}(d,{id:u,rootClassName:h}),d.contains(f)||d.appendChild(f),g=!0)},D=()=>{f?.removeEventListener("mousedown",L),window.removeEventListener("mouseup",P),window.removeEventListener("mouseleave",T),m=!1,f?.remove(),f=null,g=!1},$=e=>{N();const{id:t}=e;if("string"==typeof t&&t){const e=a.getActiveStorage("data"),{groupQueue:o,material:r}=Z(t,e.materials);if("path"===r?.type){y=r,x=[...o],((e,t)=>{const{material:i,calculator:o,viewScaleInfo:r,groupQueue:a,styles:n}=t;if(!e||!i)return;const{scale:s,offsetTop:l,offsetLeft:h}=r;e?.children&&Array.from(e.children).forEach(e=>{e.remove()}),tt(e,[nr.hide]);let c=e;for(let e=0;e<a.length;e++){const t=a[e],{x:i,y:o,width:r,height:n}=t,d={x:i*s,y:o*s,width:r*s,height:n*s,angle:X(t.angle||0)};0===e&&(d.x+=h,d.y+=l),c=zr({size:d,parent:c},{[sr]:t.id,[lr]:t.x,[hr]:t.y,[cr]:t.width,[dr]:t.height,[ur]:t.angle,[fr]:t.type,[gr]:"group"})}let d=i.x*s+h,u=i.y*s+l,f=i.width*s,g=i.height*s;a.length>0&&(d=i.x*s,u=i.y*s,f=i.width*s,g=i.height*s);const m=rt("div",{[sr]:i.id,[lr]:i.x,[hr]:i.y,[cr]:i.width,[dr]:i.height,[ur]:i.angle,[fr]:i.type,[gr]:Sr,[yt]:"true",style:{display:"inline-flex",flexDirection:"column",position:"absolute",left:d,top:u,width:f,height:g,transform:`rotate(${X(i.angle||0)}deg)`,boxSizing:"border-box",overflow:"visible",padding:"0",margin:"0",outline:"none"}}),p=Ue(o.getVirtualItem(i.id).anchorCommands||[],s,s);p.forEach((e,t)=>{const i=rt("div",{[gr]:br,[mr]:e.type,[pr]:t,[yr]:e.id,[yt]:"true",className:nr.anchor,style:{...Br({x:e.start.x,y:e.start.y,size:n.anchorSize,borderWidth:n.anchorBorderWidth}),display:"M"===e.type?"none":"block"}});m.appendChild(i)}),c.appendChild(m),Wr(e,{anchorCommands:p,styles:n})})(f,{material:r,groupQueue:o,calculator:n,viewScaleInfo:a.getActiveViewScaleInfo(),styles:c}),m||(f?.addEventListener("mousedown",L),window.addEventListener("mouseup",P),window.addEventListener("mouseleave",T),m=!0);const e=a.getActiveOverrideMaterialMap()||{};e[r.id]={operations:{renderPathTrace:!0}},a.setActiveOverrideMaterialMap(e),i.drawFrame()}}},H=()=>{const e=a.getActiveOverrideMaterialMap()||{};delete e[y?.id],a.setActiveOverrideMaterialMap(e),y=null,z(),C(),D(),i.drawFrame()};return{name:"@middleware/pen-edit",use(){!function(e,t){mt({styles:{display:"flex",position:"absolute",zIndex:t.zIndex,top:0,left:0,right:0,bottom:0,overflow:"hidden",justifyContent:"center",alignItems:"center",[`&.${nr.hide}`]:{display:"none"},[`.${nr.anchor}`]:{position:"absolute",width:t.anchorSize,height:t.anchorSize,background:t.anchorBackground,border:`${t.anchorBorderWidth}px solid ${t.anchorBorderColor}`,borderRadius:"50%",overflow:"hidden","&:hover":{borderColor:t.anchorHoverBorderColor,background:t.anchorHoverBackground},"&:active":{borderColor:t.anchorActiveBorderColor,background:t.anchorActiveBackground},[`&.${nr.selected}`]:{borderColor:t.anchorActiveBorderColor,background:t.anchorActiveBackground}},[`.${nr.director}`]:{position:"absolute",width:t.directorSize,height:t.directorSize,background:t.directorBackground,border:`${t.directorBorderWidth}px solid ${t.directorBorderColor}`,overflow:"hidden","&:hover":{borderColor:t.directorHoverBorderColor,background:t.directorHoverBackground},"&:active":{borderColor:t.directorActiveBorderColor,background:t.directorActiveBackground},[`&.${nr.selected}`]:{borderColor:t.directorActiveBorderColor,background:t.directorActiveBackground}},[`.${nr.directorLines}`]:{position:"absolute",left:0,right:0,top:0,bottom:0}},rootClassName:e,type:"element"})}(h,c),r.on(o.PATH_EDIT,$),r.on(o.CLEAR_PATH_EDIT,H)},disuse(){!function(e){pt({rootClassName:e,type:"element"})}(h),r.off(o.PATH_EDIT,$),r.off(o.CLEAR_PATH_EDIT,H)},beforeDrawFrame(){((e,t)=>{if(!e)return;const{material:i,viewScaleInfo:o,calculator:r,selectedAnchorId:a,styles:n}=t;if(!i)return;const{scale:s,offsetTop:l,offsetLeft:h}=o;let c=e.children[0],d=0;for(;["group","material"].includes(c?.getAttribute(gr));){"material"===c?.getAttribute(gr)&&(it(c,{width:i.width,height:i.height,left:i.x,top:i.y}),ot(c,{[cr]:i.width,[dr]:i.height,[lr]:i.x,[hr]:i.y}));const{x:e,y:t,w:o,h:r,angle:a}=Lr(c),n={x:e*s,y:t*s,w:o*s,h:r*s,angle:a};if(0===d&&(n.x+=h,n.y+=l),it(c,{left:n.x,top:n.y,width:n.w,height:n.h,transform:`rotate(${n.angle}deg)`}),"material"!==c?.children?.[0]?.getAttribute(gr))break;c=c?.children?.[0],d++}const{id:u}=i,f=Ue(r.getVirtualItem(u).anchorCommands||[],s,s);if(Array.from(c.querySelectorAll(`[${gr}="${br}"]`)).forEach((e,t)=>{const i=f[t],o=e.getAttribute(yr)===a?n.anchorSelectedSize:n.anchorSize;it(e,{width:o,height:o,left:i.start.x-o/2-n.anchorBorderWidth,top:i.start.y-o/2-n.anchorBorderWidth})}),"string"==typeof a&&a){const t=f.findIndex(e=>e.id===a),i=f[t],o=f[t-1];let r=null,s=null;"C"===i.type&&(r={openedByAnchorId:a,anchorId:i.id,anchorPoint:{x:i.start.x,y:i.start.y},directPoint:{x:i.params[0],y:i.params[1]}}),"C"===o.type&&(s={openedByAnchorId:a,anchorId:o.id,anchorPoint:{x:o.end.x,y:o.end.y},directPoint:{x:o.params[2],y:o.params[3]}}),r||s?($r(e,{selectedAnchorId:a,currentDirector:r,prevDirector:s,styles:n}),Nr(e,{currentDirector:r,prevDirector:s,styles:n})):Dr(e)}Or(e,{anchorCommands:f,styles:n})})(f,{selectedAnchorId:b?.id,material:y,viewScaleInfo:a.getActiveViewScaleInfo(),calculator:n,styles:c})},hover:()=>!g,pointStart:()=>!g,pointMove:()=>!g,pointEnd:()=>!g,pointLeave:()=>!g,doubleClick:()=>!g,contextMenu:()=>!g,wheel:()=>!g,wheelScale:()=>!g,scrollX:()=>!g,scrollY:()=>!g,resize:()=>!g}},e.MiddlewarePointer=e=>{const{boardContent:t,eventHub:i,sharer:r}=e,a=t.boardContext.canvas,n=e.container||document.body,s=`idraw-middleware-pointer-${Math.random().toString(26).substring(2)}`;let l=document.createElement("div");return{name:"@middleware/pointer",use(){l.setAttribute("id",s),l.style.position="fixed",l.style.top="0",l.style.bottom="unset",l.style.left="0",l.style.right="unset",n.appendChild(l)},disuse(){n.removeChild(l),l.remove(),l=null},contextMenu(e){const{point:t}=e,{left:n,top:s}=(()=>{const e=a.getBoundingClientRect(),{left:t,top:i,width:o,height:r}=e;return{left:t,top:i,width:o,height:r}})();l.style.left=`${n+t.x}px`,l.style.top=`${s+t.y}px`;const h=r.getSharedStorage(Ri);i.trigger(o.CONTEXT_MENU,{pointerContainer:l,selectedMaterials:h||[]})}}},e.MiddlewareRuler=(e,t)=>{const{boardContent:i,viewer:r,eventHub:a,calculator:n}=e,{overlayContext:s,underlayContext:l}=i;let h={...Uo,...t},c=Zo(h),d=!0,u=!0;const f=e=>{"boolean"==typeof e?.show&&(d=e.show),"boolean"==typeof e?.showGrid&&(u=e.showGrid),"boolean"!=typeof e?.show&&"boolean"!=typeof e?.showGrid||r.drawFrame()};return{name:"@middleware/ruler",use(){a.on(o.RULER,f)},disuse(){a.off(o.RULER,f)},resetConfig(e){h={...h,...e},c=Zo(h)},beforeDrawFrame:({snapshot:e})=>{if(!0===d){const t=P(e),i=T(e);!function(e,t){const{viewSizeInfo:i,styles:o}=t,{width:r,height:a}=i,{background:n,stroke:s}=o;e.beginPath();const l=-1;e.moveTo(l,l),e.lineTo(r+1,l),e.lineTo(r+1,Xo),e.lineTo(Xo,Xo),e.lineTo(Xo,a+1),e.lineTo(l,a+1),e.lineTo(l,l),e.closePath(),e.fillStyle=n,e.fill("nonzero"),e.lineWidth=1,e.setLineDash([]),e.strokeStyle=s,e.stroke()}(s,{viewSizeInfo:i,styles:c}),function(e,t){const{snapshot:i,calculator:o,styles:r}=t,{sharedStore:a}=i,{selectedAreaColor:n}=r,s=a[Ri],l=a[bi];if(["select","drag","drag-list","drag-list-end"].includes(l)&&s.length>0){const t=P(i),r=T(i),a=[],l=[],h=[],c=[],d=[];if(s.forEach(e=>{const i=o.calcViewBoundingInfoFromRange(e.id,{viewScaleInfo:t,viewSizeInfo:r});i&&(a.push(i),l.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(...l),f=Math.max(...h),g=Math.min(...c),m=Math.max(...d);e.globalAlpha=1,e.beginPath(),e.moveTo(u,0),e.lineTo(f,0),e.lineTo(f,Xo),e.lineTo(u,Xo),e.fillStyle=n,e.closePath(),e.fill("nonzero"),e.beginPath(),e.moveTo(0,g),e.lineTo(Xo,g),e.lineTo(Xo,m),e.lineTo(0,m),e.fillStyle=n,e.closePath(),e.fill("nonzero")}}(s,{snapshot:e,calculator:n,styles:c});const{list:o,rulerUnit:r}=function(e){const{viewScaleInfo:t,viewSizeInfo:i}=e,{scale:o,offsetLeft:r}=t,{width:a}=i;return Ko({scale:o,viewLength:a,viewOffset:r})}({viewScaleInfo:t,viewSizeInfo:i});!function(e,t){const{scaleList:i,styles:o}=t,{scaleColor:r,textColor:a}=o;for(let t=0;t<i.length;t++){const o=i[t];o.position<Xo||(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=r,e.stroke(),o.isKeyNum&&(e.fillStyle=a,e.textBaseline="top",e.$setFont({fontWeight:100,fontSize:10,fontFamily:Qo}),e.fillText(`${o.num}`,o.position+3.2,3.2)))}}(s,{scaleList:o,styles:c});const{list:a}=function(e){const{viewScaleInfo:t,viewSizeInfo:i}=e,{scale:o,offsetTop:r}=t,{height:a}=i;return Ko({scale:o,viewLength:a,viewOffset:r})}({viewScaleInfo:t,viewSizeInfo:i});if(function(e,t){const{scaleList:i,styles:o}=t,{scaleColor:r,textColor:a}=o,n=3.2;for(let t=0;t<i.length;t++){const o=i[t];if(!(o.position<Xo)&&(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=r,e.lineWidth=1,e.setLineDash([]),e.stroke(),!0===o.showNum)){const t=n,i=o.position+n,r=`${o.num}`;$(e,-90,{x:t,y:i},()=>{e.fillStyle=a,e.textBaseline="top",e.$setFont({fontWeight:100,fontSize:10,fontFamily:Qo}),e.fillText(r,13.2,o.position+n)})}}}(s,{scaleList:a,styles:c}),!0===u){!function(e,t){const{xList:i,yList:o,viewSizeInfo:r,styles:a}=t,{width:n,height:s}=r,{gridColor:l,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,s),!0===o.isKeyNum||!0===o.isSubKeyNum?e.strokeStyle=h:e.strokeStyle=l,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(n,i.position),!0===i.isKeyNum||!0===i.isSubKeyNum?e.strokeStyle=h:e.strokeStyle=l,e.lineWidth=1,e.closePath(),e.stroke()}}(1===r?s:l,{xList:o,yList:a,viewSizeInfo:i,styles:c})}}}}},e.MiddlewareScaler=e=>{const{viewer:t,sharer:i,eventHub:r}=e;return{name:"@middleware/scaler",wheelScale(e){const{deltaY:a,point:n}=e,{scale:s}=i.getActiveViewScaleInfo();let l=s;if(a<0?l=1.1*s:a>0&&(l=.9*s),l<.05||l>50)return;const{moveX:h,moveY:c}=t.scale({scale:l,point:n});t.scroll({moveX:h,moveY:c}),t.drawFrame();const d=ue(s);r.trigger(o.SCALE,{scale:d})}}},e.MiddlewareScroller=(e,t)=>{const{viewer:i,sharer:r,eventHub:a}=e;let n=!1,s={...Oo,...t};const l=Yo(s),h=`${Do}-${Xe()}`;let c=null,d=null;const u=()=>{r.setSharedStorage(Po,null),r.setSharedStorage(To,null),r.setSharedStorage(No,null),n=!1};u();const f=()=>{const{xThumbStyle:e,yThumbStyle:t}=function(e){const{viewScaleInfo:t,viewSizeInfo:i}=e,{width:o,height:r}=i,{offsetTop:a,offsetBottom:n,offsetLeft:s,offsetRight:l}=t,h=16;let c=0,d=0;c=Math.max(40,o-32-(Math.abs(s)+Math.abs(l))),c>=o&&(c=o),d=Math.max(40,r-32-(Math.abs(a)+Math.abs(n))),d>=r&&(d=r);let u=16;s>0?u=16:l>0?u=o-c-h:s<=0&&c>0&&(0!==s||0!==l)&&(u=16+(o-c)*Math.abs(s)/(Math.abs(s)+Math.abs(l)),u=Math.min(Math.max(0,u-16),o-c));let f=16;return a>0?f=16:n>0?f=r-d-h:a<=0&&d>0&&(0!==a||0!==n)&&(f=16+(r-d)*Math.abs(a)/(Math.abs(a)+Math.abs(n)),f=Math.min(Math.max(0,f-16),r-d)),{xThumbStyle:{left:u,width:c},yThumbStyle:{top:f,height:d}}}({viewScaleInfo:r.getActiveViewScaleInfo(),viewSizeInfo:r.getActiveViewSizeInfo()});r.setSharedStorage(Bo,e),r.setSharedStorage(ko,t)},g=e=>{const{thumbMoveX:t,thumbMoveY:i}=e,o=r.getSharedStorage(Bo),a=r.getSharedStorage(ko),n=r.getActiveViewSizeInfo();if(o&&(t>0||t<0)){const e=n.width-32,i=$o;let a=o.left-t;a=Math.min(n.width-$o-Ho,Math.max($o,a));let s=o.width;(a+s>=e||a<=i)&&(t<0?s+=t:s-=t),s=Math.min(e,Math.max(Ho,s)),o.left=a,o.width=s,r.setSharedStorage(Bo,o)}if(a&&(i>0||i<0)){const e=n.height-32,t=$o;let o=a.top-i;o=Math.min(n.height-$o-Ho,Math.max($o,o));let s=a.height;(o+s>=e||o<=t)&&(i<0?s+=i:s-=i),s=Math.min(e,Math.max(Ho,s)),a.top=o,a.height=s,r.setSharedStorage(ko,a)}};return{name:"@middleware/scroller",use(){!function(e,t){const i=e=>`.${e}`;mt({styles:{zIndex:t.zIndex,position:"absolute",background:"transparent",[i(Vo.thumb)]:{position:"absolute",background:t.thumbBackground,border:`1px solid ${t.thumbBorderColor}`,borderRadius:"4px",boxSizing:"border-box","&:hover":{background:t.hoverThumbBackground,border:`1px solid ${t.hoverThumbBorderColor}`},"&:active":{background:t.activeThumbBackground,border:`1px solid ${t.activeThumbBorderColor}`}},[`&${i(Vo.vertical)}`]:{top:0,bottom:0,right:0,left:"unset",width:$o,overflow:"hidden",[i(Vo.thumb)]:{top:$o,bottom:"unset",left:4,right:"unset",height:Ho,width:8}},[`&${i(Vo.horizontal)}`]:{left:0,right:0,top:"unset",bottom:0,height:$o,overflow:"hidden",[i(Vo.thumb)]:{top:4,bottom:"unset",left:$o,right:"unset",height:8,width:Ho}}},rootClassName:e,type:"element"})}(h,l);const t=function(e){const{rootClassName:t,$container:i}=e,o=rt,r=o("div",{className:`${t} ${Vo.horizontal}`,[yt]:"true"},[o("div",{className:Vo.thumb,[yt]:"true",[Wo]:"X"})]),a=o("div",{className:`${t} ${Vo.vertical}`,[yt]:"true"},[o("div",{className:Vo.thumb,[yt]:"true",[Wo]:"Y"})]);return i.appendChild(r),i.appendChild(a),{$horizontal:r,$vertical:a}}({rootClassName:h,$container:e.container});c=t.$horizontal,d=t.$vertical,f(),Go({xThumbStyle:r.getSharedStorage(Bo),yThumbStyle:r.getSharedStorage(ko),$horizontal:c,$vertical:d})},disuse(){!function(e){pt({rootClassName:e,type:"element"})}(h),c?.remove(),c=null,d?.remove(),d=null},resetConfig(e){s={...s,...e}},wheel:e=>{i.scroll({moveX:0-e.deltaX,moveY:0-e.deltaY}),f(),i.drawFrame()},hover:e=>{if(!0===n)return!1;const{nativeEvent:t}=e,i=Fo(t);return"X"===i||"Y"===i?(a.trigger(o.CURSOR,{type:"default"}),!1):!jo(t)&&void 0},pointStart:e=>{const{point:t,nativeEvent:i}=e,o=Fo(i);return"X"===o||"Y"===o?(n=!0,r.setSharedStorage(No,o),r.setSharedStorage(Po,t),!1):!jo(i)&&void 0},pointMove:e=>{const{point:t,nativeEvent:o}=e,a=r.getSharedStorage(No);return"X"===a||"Y"===a?(r.setSharedStorage(To,t),"X"===a?(e=>{const t=r.getSharedStorage(Po);if(t){const{offsetLeft:o,offsetRight:a}=r.getActiveViewScaleInfo(),{width:n}=r.getActiveViewSizeInfo(),s=-(e.x-t.x),l=s*(n+Math.abs(o)+Math.abs(a))/n;i.scroll({moveX:l}),g({thumbMoveX:s,thumbMoveY:0}),i.drawFrame()}})(t):"Y"===a&&(e=>{const t=r.getSharedStorage(Po);if(t){const{offsetTop:o,offsetBottom:a}=r.getActiveViewScaleInfo(),{height:n}=r.getActiveViewSizeInfo(),s=-(e.y-t.y),l=s*(n+Math.abs(o)+Math.abs(a))/n;i.scroll({moveY:l}),g({thumbMoveX:0,thumbMoveY:s}),i.drawFrame()}})(t),r.setSharedStorage(Po,t),!1):!jo(o)&&void 0},pointEnd:()=>{n=!1;const e=r.getSharedStorage(No);if(u(),"X"===e||"Y"===e)return i.scroll({moveX:0,moveY:0}),f(),i.drawFrame(),!1},beforeDrawFrame(){Go({$horizontal:c,$vertical:d,xThumbStyle:r.getSharedStorage(Bo),yThumbStyle:r.getSharedStorage(ko)})}}},e.MiddlewareSelector=(e,t)=>{let i={...Ti,...t};const r=Mo(i),a=`${si}-${Xe()}`;let n=null;const{viewer:s,sharer:l,boardContent:h,calculator:c,eventHub:d}=e,{overlayContext:u}=h;l.setSharedStorage(bi,null),l.setSharedStorage(Pi,!0);const f=e=>{let t=l.getSharedStorage(Li);return Array.isArray(t)||(t=[]),t.length>0?!function(e,t){if("group"===t?.type&&Array.isArray(t?.children))for(let i=0;i<t.children.length;i++){const o=t.children[i];if(e.id===o.id)return!0}return!1}(e,t[t.length-1])?t=[]:t.push(e):0===t.length&&t.push(e),l.setSharedStorage(Li,t),t.length>0},g=(e,t)=>{if(l.setSharedStorage(Ri,e),1===e.length?l.setSharedStorage(zi,_(e[0].id,l.getActiveStorage("data")?.materials||[])):l.setSharedStorage(zi,[]),!0===t?.triggerEvent){const t=e.map(e=>e.id),i=l.getActiveStorage("data"),r=function(e,t){const i=[],o={};let r=!1;const a=t=>{for(let n=0;n<t.length&&!0!==r;n++){i.push(n);const s=t[n];if(e.includes(s.id)){if(o[s.id]=[...i],Object.keys(o).length===e.length){r=!0;break}}else"group"===s.type&&a(s?.children||[]);if(r)break;i.pop()}};return a(t),o}(t,i?.materials||[]);d.trigger(o.SELECT,{type:"clickCanvas",ids:t,positions:e.map(e=>[...r[e.id]])})}},m=e=>({ctx:u,calculator:c,data:l.getActiveStorage("data"),selectedMaterials:l.getSharedStorage(Ri),viewScaleInfo:l.getActiveViewScaleInfo(),viewSizeInfo:l.getActiveViewSizeInfo(),groupQueue:l.getSharedStorage(Li),areaSize:null,selectedMaterialPosition:l.getSharedStorage(zi),nativeEvent:e.nativeEvent}),p=()=>(e=>{e.setSharedStorage(wi,null),e.setSharedStorage(Si,null),e.setSharedStorage(bi,null),e.setSharedStorage(Ai,null),e.setSharedStorage(Mi,null),e.setSharedStorage(Ii,null),e.setSharedStorage(Li,[]),e.setSharedStorage(Ci,null),e.setSharedStorage(Ri,[]),e.setSharedStorage(Ei,null),e.setSharedStorage(zi,[]),e.setSharedStorage(Bi,null)})(l);p();const y=({ids:e=[],positions:t})=>{let i=[];const o=l.getSharedStorage(bi),r=l.getActiveStorage("data");i=t&&Array.isArray(t)?function(e,t){const i=[];return e.forEach(e=>{const o=q(e,t);o&&i.push(o)}),i}(t,r?.materials||[]):function(e,t){const i=[];return function t(o){for(let r=0;r<o.length;r++){const a=o[r];e.includes(a.id)?i.push(a):"group"===a.type&&t(a?.children||[])}}(t),i}(e,r?.materials||[]);let a=!1;if(o||1!==i.length?"select"===o&&1===i.length&&(a=!0):(l.setSharedStorage(bi,"select"),a=!0),a){const e=function(e,t){const{groupQueue:i}=Z(e,t);return i}(i[0].id,r?.materials||[]);l.setSharedStorage(Li,e),g(i),l.setSharedStorage(mi,[{...K(i[0]),id:i[0].id}]),s.drawFrame()}},x=()=>{p(),s.drawFrame()},v=e=>{l.setSharedStorage(Pi,!!e.enable)},w=e=>{l.setSharedStorage(ki,!!e.enable)};return{name:"@middleware/selector",use(){!function(e,t){const i=e=>`.${e}`;var o;mt({styles:{display:"flex",position:"absolute",zIndex:t.zIndex,top:0,left:0,right:0,bottom:0,overflow:"hidden",[i(fi.hoverTargetBox)]:{position:"absolute",outline:`1px solid ${t.activeColor}`},[i(fi.nestedBox)]:{position:"absolute",[`&${i(fi.groupBox)}`]:{outline:`2px dashed ${t.activeColor}`},[i(fi.groupBox)]:{outline:`2px dashed ${t.activeColor}`}},[i(fi.lockedTargetBox)]:{position:"absolute",outline:`2px solid ${t.lockedColor}`},[i(fi.selectedBox)]:{position:"absolute",[`&${i(fi.hideHandler)}`]:{[i(fi.cornerHandler)]:{display:"none"},[i(fi.edgeHandler)]:{display:"none"},[i(fi.rotateHandler)]:{display:"none"}}},[i(fi.selectedTargetBox)]:{position:"absolute",outline:`1.5px solid ${t.handlerBorderColor}`,[i(fi.cornerHandler)]:{position:"absolute",outline:`1.5px solid ${t.handlerBorderColor}`,background:t.handlerBackground,width:"10px",height:"10px","&:hover":{background:t.handlerHoverBackground},"&:active":{background:t.handlerActiveBackground},[`&${i(fi.cornerTopLeftHandler)}`]:{top:"-5px",left:"-5px"},[`&${i(fi.cornerTopRightHandler)}`]:{top:"-5px",right:"-5px"},[`&${i(fi.cornerBottomLeftHandler)}`]:{bottom:"-5px",left:"-5px"},[`&${i(fi.cornerBottomRightHandler)}`]:{bottom:"-5px",right:"-5px"}},[i(fi.rotateHandler)]:{position:"absolute",top:-40,left:"50%",transform:"translateX(-50%)",width:20,height:20,background:"#FFFFFF",borderRadius:"10px","&::after":{display:"inline-block",content:'""',position:"absolute",top:0,bottom:0,left:0,right:0,backgroundImage:`url(data:image/svg+xml,${encodeURIComponent((o=t.activeColor,`<svg viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200" fill="${o}" >\n <path d="M512 0c282.8 0 512 229.2 512 512s-229.2 512 -512 512S0 794.8 0 512 229.2 0 512 0zm309.8 253.8c0 -10.5 -6.5 -19.8 -15.7 -23.8 -9.7 -4 -21 -2 -28.2 5.6l-52.5 52c-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 -0.8 -17.3L694.3 637c-2.8 -2.4 -6.5 -3.6 -10.1 -3.6 -3.6 0.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.3L597 416.5c-7.7 7.3 -9.7 18.6 -5.6 27.9 4 9.7 13.3 16.1 23.8 16.1H796c14.1 0 25.8 -11.7 25.8 -25.8V253.8z" />\n</svg>`))})`,backgroundPosition:"center",backgroundSize:"20px"}},[i(fi.edgeHandler)]:{position:"absolute",background:"transparent",[`&${i(fi.edgeLeftHandler)}`]:{width:"10px",top:"5px",left:"-5px",bottom:"5px"},[`&${i(fi.edgeRightHandler)}`]:{width:"10px",top:"5px",right:"-5px",bottom:"5px"},[`&${i(fi.edgeTopHandler)}`]:{height:"10px",top:"-5px",left:"5px",right:"5px"},[`&${i(fi.edgeBottomHandler)}`]:{height:"10px",bottom:"-5px",left:"5px",right:"5px"}}},[i(fi.selectionAreaBox)]:{position:"absolute",outline:`1px solid ${t.selectionAreaBorderColor}`,background:t.selectionAreaBackground}},rootClassName:e,type:"element"})}(a,r),n=function(e){const{rootClassName:t,$container:i}=e,o=rt("div",{className:t,[yt]:"true"});return i.appendChild(o),o}({rootClassName:a,$container:e.container}),d.on(o.SELECT,y),d.on(o.CLEAR_SELECT,x),d.on(o.SELECT_IN_GROUP,w),d.on(o.SNAP_TO_GRID,v)},disuse(){!function(e){pt({rootClassName:e,type:"element"})}(a),d.off(o.SELECT,y),d.off(o.CLEAR_SELECT,x),d.off(o.SELECT_IN_GROUP,w),d.off(o.SNAP_TO_GRID,v),n?.remove(),p(),i=null,n=null},resetConfig(e){i={...i,...e}},hover:e=>{if(!lt(e.nativeEvent,{$root:n,rootClassName:a}))return void(l.getSharedStorage(Ci)&&(l.setSharedStorage(Ci,null),s.drawFrame()));const t=l.getSharedStorage(Ki);if(!0===l.getSharedStorage(qi))return;const i=l.getSharedStorage(Ai),r=l.getSharedStorage(bi),h=l.getSharedStorage(Li),c=e=>{if(!0===t)return;const i=e.type;null===l.getSharedStorage(xi)&&d.trigger(o.CURSOR,{type:i,groupQueue:e.groupQueue,material:e.materials[0]})};if(h?.length>0){if(!Ao(e.nativeEvent,{$root:n,groupQueue:l.getSharedStorage(Li)}))return l.setSharedStorage(Ci,null),void s.drawFrame();const t=Wi(e.point,m(e));return c(t),i||["area","drag","drag-list"].includes(r)?(l.setSharedStorage(Ci,null),void s.drawFrame()):1===t?.materials?.length?(l.setSharedStorage(Ci,t.materials[0]),void s.drawFrame()):(l.setSharedStorage(Ci,null),void s.drawFrame())}if(i||["area","drag","drag-list"].includes(r))return void l.setSharedStorage(Ci,null);if("drag"===r)return void l.setSharedStorage(Ci,null);const u=l.getSharedStorage(Ri),f=l.getActiveViewScaleInfo();l.getActiveViewSizeInfo();const g=Wi(e.point,{...m(e),areaSize:Vi(u,{viewScaleInfo:f})});if(c(g),null!==g.type){if(!("over-material"===g.type&&"select"===l.getSharedStorage(bi)&&1===g.materials.length&&g.materials[0].id===l.getSharedStorage(Ri)?.[0]?.id||"over-material"===g.type&&null===l.getSharedStorage(bi)&&1===g.materials.length&&g.materials[0].id===l.getSharedStorage(Ci)?.id))return"over-material"===g.type&&1===g?.materials?.length?(l.setSharedStorage(Ci,g.materials[0]),void s.drawFrame()):l.getSharedStorage(Ci)?(l.setSharedStorage(Ci,null),void s.drawFrame()):void 0}else l.getSharedStorage(Ci)&&(l.setSharedStorage(Ci,null),s.drawFrame())},pointStart:e=>{if(!lt(e.nativeEvent,{$root:n,rootClassName:a}))return;l.setSharedStorage(gi,e.point),l.setSharedStorage(pi,e.point),l.setSharedStorage(wi,null),l.setSharedStorage(Si,null),l.setSharedStorage(bi,null),l.setSharedStorage(Ai,null),l.setSharedStorage(Mi,null),l.setSharedStorage(Ii,null),l.setSharedStorage(Ci,null);const t=l.getSharedStorage(Li);if(t?.length>0){if(Ao(e.nativeEvent,{$root:n,groupQueue:t})){const t=Wi(e.point,m(e)),i=1===t?.materials?.length&&!0===t.materials[0]?.operations?.locked;l.setSharedStorage(Ci,null),1===t?.materials?.length&&l.setSharedStorage(yi,K(t?.materials[0])),!0===i?p():"over-material"===t.type&&1===t?.materials?.length?(g([t.materials[0]],{triggerEvent:!0}),l.setSharedStorage(bi,"drag"),l.setSharedStorage(mi,[{...K(t?.materials[0]),id:t?.materials[0].id}])):t.type?.startsWith("resize-")?(l.setSharedStorage(Ai,t.type),l.setSharedStorage(bi,"resize")):g([],{triggerEvent:!0})}else p();return void s.drawFrame()}const i=Vi(l.getSharedStorage(Ri),{viewScaleInfo:l.getActiveViewScaleInfo(),viewSizeInfo:l.getActiveViewSizeInfo()}),o=Wi(e.point,{...m(e),areaSize:i,groupQueue:[]}),r=1===o?.materials?.length&&!0===o.materials[0]?.operations?.locked;l.setSharedStorage(Ci,null),1===o?.materials?.length&&l.setSharedStorage(yi,K(o?.materials[0])),!0===r?(p(),l.setSharedStorage(Ci,o?.materials[0]),l.setSharedStorage(bi,"area"),l.setSharedStorage(Mi,e.point),g([],{triggerEvent:!0})):"list-area"===o.type?l.setSharedStorage(bi,"drag-list"):"over-material"===o.type&&1===o?.materials?.length?(g([o.materials[0]],{triggerEvent:!0}),l.setSharedStorage(bi,"drag"),l.setSharedStorage(mi,[{...K(o?.materials[0]),id:o?.materials[0].id}])):o.type?.startsWith("resize-")?(l.setSharedStorage(Ai,o.type),l.setSharedStorage(bi,"resize")):(p(),l.setSharedStorage(bi,"area"),l.setSharedStorage(Mi,e.point),g([],{triggerEvent:!0})),s.drawFrame()},pointMove:e=>{if(!lt(e.nativeEvent,{$root:n,rootClassName:a}))return;l.setSharedStorage(Bi,!0);const t=l.getActiveStorage("data"),i=l.getSharedStorage(Ri),o=l.getActiveStorage("scale")||1,r=l.getActiveViewScaleInfo(),h=l.getActiveViewSizeInfo(),u=l.getSharedStorage(gi),f=l.getSharedStorage(pi),m=e.point,p=l.getSharedStorage(Ai),y=l.getSharedStorage(bi),x=l.getSharedStorage(Li),v=l.getSharedStorage(Pi);let w="unknown";if("drag"===y){if(l.setSharedStorage(vi,!0),l.setSharedStorage(xi,"drag"),d.trigger(so,{show:!1}),t&&1===i?.length&&l.getSharedStorage(yi)&&f&&m&&!0!==i[0]?.operations?.locked){const{moveX:e,moveY:a}=He(f,m,x);let n=c.toGridNum(e/o),s=c.toGridNum(a/o);if(!0===v){const e=Fi(i[0].id,{calculator:c,data:t,groupQueue:x,viewScaleInfo:r,viewSizeInfo:h});try{e&&(C.x(e.offsetX)&&null!==e.offsetX&&(n=c.toGridNum(n+e.offsetX)),C.y(e.offsetY)&&null!==e.offsetY&&(s=c.toGridNum(s+e.offsetY)))}catch(e){console.error(e)}}const d=l.getSharedStorage(yi),u=c.toGridNum(d.x+n),p=c.toGridNum(d.y+s);Io(i[0],{x:u,y:p,width:i[0].width,height:i[0].height}),g([i[0]]),w="updateMaterial",c.modifyVirtualItemMap(t,{modifyInfo:{type:w,content:{material:i[0],position:l.getSharedStorage(zi)||[]}},viewSizeInfo:h,viewScaleInfo:r})}s.drawFrame()}else if("drag-list"===y){if(l.setSharedStorage(vi,!0),l.setSharedStorage(xi,"drag-list"),t&&f&&u&&m&&i?.length>1){const e=(m.x-u.x)/o,a=(m.y-u.y)/o;i.forEach(i=>{i&&!0!==i?.operations?.locked&&(i.x=c.toGridNum(i.x+e),i.y=c.toGridNum(i.y+a),w="updateMaterial",c.modifyVirtualItemMap(t,{modifyInfo:{type:w,content:{material:i,position:_(i.id,t.materials)||[]}},viewSizeInfo:h,viewScaleInfo:r}))}),l.setActiveStorage("data",t)}s.drawFrame()}else if("resize"===y){if(t&&1===i?.length&&f&&l.getSharedStorage(yi)&&p?.startsWith("resize-")){l.setSharedStorage(vi,!0),l.setSharedStorage(xi,"resize");const e=[];x.forEach(t=>{const{x:i,y:o,width:r,height:a,angle:n=0}=t;e.push({x:i,y:o,width:r,height:a,angle:0-n})});let a=f,n=m;if(x.length>0&&(a=Y(f,e),n=Y(m,e)),"resize-rotate"===p){const e=l.getSharedStorage(yi),t=c.getVirtualItem(i?.[0]?.id),o=t?.worldCenter,a=Oi(e,{center:o,viewScaleInfo:r,start:f,end:m,calculator:c});i[0].angle=c.toGridNum(a.angle||0)}else{const e=l.getSharedStorage(yi),t=function(e,t){let{x:i,y:o,width:r,height:a,angle:n=0}=e;const s=H({x:i,y:o,width:r,height:a});n=X(n);const l=D(n),h=!!e?.operations?.limitRatio,{start:c,end:d,resizeType:u,scale:f,calculator:g}=t;let m={...c},p={...d},y={x:m.x,y:s.y},x={x:p.x,y:s.y},v={...y},w={...x},S={x:s.x,y:m.y},b={x:s.x,y:p.y},A={...S},M={...b},I=(w.x-v.x)/f,C=(w.y-v.y)/f,R=Di(I,C),E=(M.x-A.x)/f,z=(M.y-A.y)/f,L=Di(E,z);(n>0||n<0)&&(m=V(s,c,0-l),p=V(s,d,0-l),y={x:m.x,y:s.y},x={x:p.x,y:s.y},v=V(s,y,l),w=V(s,x,l),S={x:s.x,y:m.y},b={x:s.x,y:p.y},A=V(s,S,l),M=V(s,b,l),I=(w.x-v.x)/f,C=(w.y-v.y)/f,R=Di(I,C),R=$i(R,C),E=(M.x-A.x)/f,z=(M.y-A.y)/f,L=Di(E,z),L=$i(L,z));let B=(d.x-c.x)/f,k=(d.y-c.y)/f;if(!0===h)if(["resize-top","resize-bottom","resize-left","resize-right"].includes(u)){const t=Math.max(Math.abs(B),Math.abs(k));B=(B>=0?1:-1)*t,k=(k>=0?1:-1)*t/e.width*e.height;const i=Math.max(Math.abs(E),Math.abs(z));E=(E>=0?1:-1)*i,z=(z>=0?1:-1)*i/e.width*e.height;const o=Math.max(Math.abs(I),Math.abs(C));I=(I>=0?1:-1)*o,C=(C>=0?1:-1)*o/e.width*e.height}else if(["resize-top-left","resize-top-right","resize-bottom-left","resize-bottom-right"].includes(u)){{const t=Math.abs(B);B=(B>=0?1:-1)*t;const i=t/e.width*e.height;"resize-top-left"===u||"resize-bottom-right"===u?k=B>0?i:-i:"resize-top-right"!==u&&"resize-bottom-left"!==u||(k=B>0?-i:i)}R=Math.abs(R),L=R/e.width*e.height}switch(u){case"resize-top":if(0===n)a-k>0&&(o+=k,a-=k,!0===e.operations?.limitRatio&&(i+=k/e.height*e.width/2,r-=k/e.height*e.width));else if(n>0||n<0){let t=s.x,l=s.y;if(n<90){L=0-$i(L,z);const e=Ni(n),i=L/2;t+=i*Math.sin(e),l-=i*Math.cos(e)}else if(n<180){L=$i(L,E);const e=Ni(n-90),i=L/2;t+=i*Math.cos(e),l+=i*Math.sin(e)}else if(n<270){L=$i(L,z);const e=Ni(n-180),i=L/2;t-=i*Math.sin(e),l+=i*Math.cos(e)}else if(n<360){L=0-$i(L,E);const e=Ni(n-270),i=L/2;t-=i*Math.cos(e),l-=i*Math.sin(e)}a+L>0&&(!0===e.operations?.limitRatio&&(r+=L/e.height*e.width),a+=L,i=t-r/2,o=l-a/2)}break;case"resize-bottom":if(0===n)e.height+k>0&&(a+=k,!0===e.operations?.limitRatio&&(i-=k/e.height*e.width/2,r+=k/e.height*e.width));else if(n>0||n<0){let t=s.x,l=s.y;if(n<90){L=$i(L,z);const e=Ni(n),i=L/2;t-=i*Math.sin(e),l+=i*Math.cos(e)}else if(n<180){L=0-$i(L,E);const e=Ni(n-90),i=L/2;t-=i*Math.cos(e),l-=i*Math.sin(e)}else if(n<270){L=$i(L,E);const e=Ni(n-180),i=L/2;t+=i*Math.sin(e),l-=i*Math.cos(e)}else if(n<360){L=$i(L,E);const e=Ni(n-270),i=L/2;t+=i*Math.cos(e),l+=i*Math.sin(e)}a+L>0&&(!0===e.operations?.limitRatio&&(r+=L/e.height*e.width),a+=L,i=t-r/2,o=l-a/2)}break;case"resize-left":if(0===n)e.width-B>0&&(i+=B,r-=B,!0===e.operations?.limitRatio&&(a-=B/e.width*e.height,o+=B/e.width*e.height/2));else if(n>0||n<0){let t=s.x,l=s.y;if(n<90){R=0-$i(R,I);const e=Ni(n),i=R/2;t-=i*Math.cos(e),l-=i*Math.sin(e)}else if(n<180){R=$i(R,I);const e=Ni(n-90),i=R/2;t+=i*Math.sin(e),l-=i*Math.cos(e)}else if(n<270){R=$i(R,C);const e=Ni(n-180),i=R/2;t+=i*Math.cos(e),l+=i*Math.sin(e)}else if(n<360){R=$i(R,C);const e=Ni(n-270),i=R/2;t-=i*Math.sin(e),l+=i*Math.cos(e)}r+R>0&&(!0===e.operations?.limitRatio&&(a+=R/e.width*e.height),r+=R,i=t-r/2,o=l-a/2)}break;case"resize-right":if(0===n)e.width+B>0&&(r+=B,!0===e.operations?.limitRatio&&(o-=B*e.height/e.width/2,a+=B*e.height/e.width));else if(n>0||n<0){let t=s.x,l=s.y;if(n<90){R=$i(R,C);const e=Ni(n),i=R/2;t+=i*Math.cos(e),l+=i*Math.sin(e)}else if(n<180){R=$i(R,k);const e=Ni(n-90),i=R/2;t-=i*Math.sin(e),l+=i*Math.cos(e)}else if(n<270){R=$i(R,k);const e=Ni(n-180),i=R/2;t+=i*Math.cos(e),l+=i*Math.sin(e),R=0-R}else if(n<360){R=$i(R,B);const e=Ni(n-270),i=R/2;t+=i*Math.sin(e),l-=i*Math.cos(e)}r+R>0&&(!0===e.operations?.limitRatio&&(a+=R/e.width*e.height),r+=R,i=t-r/2,o=l-a/2)}break;case"resize-top-left":if(0===n)r-B>0&&(i+=B,r-=B),a-k>0&&(o+=k,a-=k);else if(n>0||n<0){let e=s.x,t=s.y;if(n<90){L=0-$i(L,z),R=0-$i(R,h?0-L:I);const i=L/2;e+=i*Math.sin(l),t-=i*Math.cos(l);const o=R/2;e-=o*Math.cos(l),t-=o*Math.sin(l)}else if(n<180){L=$i(L,E),R=$i(R,h?L:I);const i=Ni(n-90),o=L/2;e+=o*Math.cos(i),t+=o*Math.sin(i);const r=R/2;e+=r*Math.sin(i),t-=r*Math.cos(i)}else if(n<270){L=$i(L,z),R=$i(R,h?L:C);const i=Ni(n-180),o=L/2;e-=o*Math.sin(i),t+=o*Math.cos(i);const r=R/2;e+=r*Math.cos(i),t+=r*Math.sin(i)}else if(n<360){L=0-$i(L,E),R=$i(R,h?L:C);const i=Ni(n-270),o=L/2;e-=o*Math.cos(i),t-=o*Math.sin(i);const r=R/2;e-=r*Math.sin(i),t+=r*Math.cos(i)}a+L>0&&(a+=L),r+R>0&&(r+=R),i=e-r/2,o=t-a/2}break;case"resize-top-right":if(0===n)r+B>0&&(r+=B),a-k>0&&(o+=k,a-=k);else if(n>0||n<0){let e=s.x,t=s.y;if(n<90){L=0-$i(L,z),R=$i(R,h?L:C);const i=Ni(n),o=L/2;e+=o*Math.sin(i),t-=o*Math.cos(i);const r=R/2;e+=r*Math.cos(i),t+=r*Math.sin(i)}else if(n<180){L=$i(L,E),R=$i(R,h?L:C);const i=Ni(n-90),o=L/2;e+=o*Math.cos(i),t+=o*Math.sin(i);const r=R/2;e-=r*Math.sin(i),t+=r*Math.cos(i)}else if(n<270){const i=Ni(n-180);L=$i(L,z),R=$i(R,h?L:0-I);const o=L/2;e-=o*Math.sin(i),t+=o*Math.cos(i);const r=R/2;e-=r*Math.cos(i),t-=r*Math.sin(i)}else if(n<360){L=0-$i(L,E),R=$i(R,h?L:I);const i=Ni(n-270),o=L/2;e-=o*Math.cos(i),t-=o*Math.sin(i);const r=R/2;e+=r*Math.sin(i),t-=r*Math.cos(i)}a+L>0&&(a+=L),r+R>0&&(r+=R),i=e-r/2,o=t-a/2}break;case"resize-bottom-left":if(0===n)e.height+k>0&&(a+=k),e.width-B>0&&(i+=B,r-=B);else if(n>0||n<0){let e=s.x,t=s.y;if(n<90){L=$i(L,z),R=0-$i(R,h?0-L:I);const i=Ni(n),o=L/2;e-=o*Math.sin(i),t+=o*Math.cos(i);const r=R/2;e-=r*Math.cos(i),t-=r*Math.sin(i)}else if(n<180){L=0-$i(L,E),R=$i(R,h?L:I);const i=Ni(n-90),o=L/2;e-=o*Math.cos(i),t-=o*Math.sin(i);const r=R/2;e+=r*Math.sin(i),t-=r*Math.cos(i)}else if(n<270){L=$i(L,E),R=$i(R,h?L:C);const i=Ni(n-180),o=L/2;e+=o*Math.sin(i),t-=o*Math.cos(i);const r=R/2;e+=r*Math.cos(i),t+=r*Math.sin(i)}else if(n<360){L=$i(L,E),R=$i(R,h?L:C);const i=Ni(n-270),o=L/2;e+=o*Math.cos(i),t+=o*Math.sin(i);const r=R/2;e-=r*Math.sin(i),t+=r*Math.cos(i)}a+L>0&&(a+=L),r+R>0&&(r+=R),i=e-r/2,o=t-a/2}break;case"resize-bottom-right":if(0===n)e.height+k>0&&(a+=k),e.width+B>0&&(r+=B);else if(n>0||n<0){let e=s.x,t=s.y;if(n<90){L=$i(L,z),R=$i(R,h?L:C);const i=Ni(n),o=L/2;e-=o*Math.sin(i),t+=o*Math.cos(i);const r=R/2;e+=r*Math.cos(i),t+=r*Math.sin(i)}else if(n<180){L=0-$i(L,E),R=$i(R,h?L:k);const i=Ni(n-90),o=L/2;e-=o*Math.cos(i),t-=o*Math.sin(i);const r=R/2;e-=r*Math.sin(i),t+=r*Math.cos(i)}else if(n<270){L=$i(L,E),R=$i(R,h?L:0-C);const i=Ni(n-180),o=L/2;e+=o*Math.sin(i),t-=o*Math.cos(i);const r=R/2;e-=r*Math.cos(i),t-=r*Math.sin(i)}else if(n<360){L=$i(L,E),R=$i(R,h?L:I);const i=Ni(n-270),o=L/2;e+=o*Math.cos(i),t+=o*Math.sin(i);const r=R/2;e+=r*Math.sin(i),t-=r*Math.cos(i)}a+L>0&&(a+=L),r+R>0&&(r+=R),i=e-r/2,o=t-a/2}}return{x:g.toGridNum(i),y:g.toGridNum(o),width:g.toGridNum(r),height:g.toGridNum(a),angle:g.toGridNum(e.angle||0)}}({...e,operations:i[0].operations},{scale:o,start:a,end:n,resizeType:p,calculator:c}),r={ignore:!!e.angle},s=c.toGridNum(t.x,r),h=c.toGridNum(t.y,r),d=c.toGridNum(t.width,r),u=c.toGridNum(t.height,r);"group"===i[0].type?(l.setSharedStorage(Si,ze(i[0],{x:s,y:h,width:d,height:u},{resizeEffect:i[0].operations?.resizeEffect})),l.getSharedStorage(wi)||l.setSharedStorage(wi,l.getSharedStorage(Si)),i[0].x=s,i[0].y=h):Io(i[0],{x:s,y:h,width:d,height:u})}g([i[0]]),w="updateMaterial",c.modifyVirtualItemMap(t,{modifyInfo:{type:w,content:{material:i[0],position:l.getSharedStorage(zi)||[]}},viewSizeInfo:h,viewScaleInfo:r}),s.drawFrame()}}else"area"===y&&(l.setSharedStorage(xi,"area"),l.setSharedStorage(Ii,e.point),s.drawFrame());const S=l.getSharedStorage(Ri);ai(d,{data:t,type:"updatingMaterial",selectedMaterials:S,hoverMaterial:null,modifyRecord:null},"continuous"),l.setSharedStorage(gi,e.point)},pointEnd(e){if(!lt(e.nativeEvent,{$root:n,rootClassName:a}))return;l.setSharedStorage(xi,null),l.setSharedStorage(Bi,!1);const t=l.getActiveStorage("data"),i=l.getSharedStorage(Ri),o=l.getSharedStorage(Ci),r=l.getSharedStorage(Ai),h=l.getSharedStorage(bi),u=l.getActiveViewSizeInfo();let f=!1;if(l.setSharedStorage(gi,null),l.setSharedStorage(pi,null),l.setSharedStorage(yi,null),"drag"===h&&d.trigger(so,{show:!0}),"resize"===h&&r)l.setSharedStorage(Ai,null),f=!0;else if("area"===h){if(o?.operations?.locked?l.setSharedStorage(bi,"hover"):l.setSharedStorage(bi,null),t){const e=l.getSharedStorage(Mi),i=l.getSharedStorage(Ii);if(e&&i){const{materials:o}=function(e,t){const i=[],o=[],r=[],{viewScaleInfo:a,start:n,end:s}=t;if(!(Array.isArray(e.materials)&&n&&s))return{indexes:i,ids:o,materials:r};const l=Math.min(n.x,s.x),h=Math.max(n.x,s.x),c=Math.min(n.y,s.y),d=Math.max(n.y,s.y);for(let t=0;t<e.materials.length;t++){const n=e.materials[t];if(!0===n?.operations?.locked)continue;const s=re(n,{viewScaleInfo:a}),u=H(s);if(u.x>=l&&u.x<=h&&u.y>=c&&u.y<=d&&(i.push(t),o.push(n.id),r.push(n),s.angle&&(s.angle>0||s.angle<0))){const e=G(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.width=Math.abs(Math.max(...t)-Math.min(...t)),s.height=Math.abs(Math.max(...i)-Math.min(...i))}}}return{indexes:i,ids:o,materials:r}}(t,{start:e,end:i,viewScaleInfo:l.getActiveViewScaleInfo(),viewSizeInfo:l.getActiveViewSizeInfo()});o.length>0&&(l.setSharedStorage(bi,"drag-list"),g(o,{triggerEvent:!0}),f=!0)}}}else if("drag-list"===h)l.setSharedStorage(bi,"drag-list-end"),f=!0;else if(t){c.getPointMaterial(e.point,{data:t,viewScaleInfo:l.getActiveViewScaleInfo(),viewSizeInfo:l.getActiveViewSizeInfo()}).material?(l.setSharedStorage(bi,"select"),f=!0):l.setSharedStorage(bi,null)}null===l.getSharedStorage(bi)&&(p(),f=!0);(()=>{if(f){if(t&&Array.isArray(t?.materials)&&["drag","drag-list"].includes(h)){const e=function(e,t,i){const o=U(e,{viewWidth:t.width,viewHeight:t.height,extend:i?.extend});return o.contextWidth=Math.max(o.contextWidth,t.contextWidth),o.contextHeight=Math.max(o.contextHeight,t.contextHeight),{contextSize:o}}(t.materials,u,{extend:!0});l.setActiveStorage("contextHeight",e.contextSize.contextHeight),l.setActiveStorage("contextWidth",e.contextSize.contextWidth)}if(t&&["drag","drag-list","drag-list-end","resize"].includes(h)){let e="resizeMaterial";if(l.getSharedStorage(vi)){let r=null;const a=l.getSharedStorage(mi);if(Array.isArray(a)&&a.length){const e=a[0];if(1===i.length){r={type:"resizeMaterial",time:0,content:{method:"modifyMaterial",id:e.id,before:ve(e),after:ve(K(i[0]))}};const t=l.getSharedStorage(wi),o=l.getSharedStorage(Si);"group"===i[0].type&&t&&o&&(r={...o,content:{...o.content,before:t.content.before}})}else i.length>1&&(r={type:"resizeMaterials",time:0,content:{method:"modifyMaterials",before:a.map(e=>({...ve(e),id:e.id})),after:i.map(e=>({...ve(K(e)),id:e.id}))}})}ai(d,{data:t,type:e,selectedMaterials:i,hoverMaterial:o,modifyRecord:r}),l.setSharedStorage(vi,!1)}}s.drawFrame()}})()},pointLeave(){l.setSharedStorage(xi,null),l.setSharedStorage(Ai,null),d.trigger(o.CURSOR,{type:"default"})},doubleClick(e){if(!lt(e.nativeEvent,{$root:n,rootClassName:a}))return;if(!1===l.getSharedStorage(ki))return;const t=Wi(e.point,m(e));if(l.setSharedStorage(Ri,[]),1!==t.materials.length||!0===t.materials[0]?.operations?.locked||!0===t.materials[0]?.operations?.invisible)return;const r=t.materials[0];if(i?.afterDoubleClickMaterial?.({material:r}),"group"===r?.type){if(!0===f(r))return l.setSharedStorage(bi,null),void s.drawFrame()}else"text"===r?.type&&d.trigger(o.TEXT_EDIT,{id:r.id});l.setSharedStorage(bi,null)},contextMenu:e=>{if(!lt(e.nativeEvent,{$root:n,rootClassName:a}))return;const t=l.getSharedStorage(Li);if(t?.length>0){if(Ao(e.nativeEvent,{$root:n,groupQueue:t})){const t=Wi(e.point,m(e));1===t?.materials?.length&&!0!==t.materials[0]?.operations?.locked?(p(),g([t.materials[0]],{triggerEvent:!0}),s.drawFrame()):t?.materials?.length||p()}return}const i=Vi(l.getSharedStorage(Ri),{viewScaleInfo:l.getActiveViewScaleInfo(),viewSizeInfo:l.getActiveViewSizeInfo()}),o=Wi(e.point,{...m(e),areaSize:i,groupQueue:[]});if(1===o?.materials?.length&&!0!==o.materials[0]?.operations?.locked)return p(),g([o.materials[0]],{triggerEvent:!0}),void s.drawFrame();o?.materials?.length||p()},beforeDrawFrame({snapshot:t}){zo({$root:n,styles:r,boardContent:h,snapshot:t,calculator:c,sharer:e.sharer})}}},e.MiddlewareTextEditor=(e,t)=>{const{eventHub:i,boardContent:r,viewer:a,sharer:n,calculator:s}=e,l=r.boardContext.canvas,h=e.container||document.body,c=tr({..._o,...t});let d=null,u=[],f="",g=!1;const m=`idraw-middleware-text-editor-${Math.random().toString(26).substring(2)}`,p=`${qo}-${Xe()}`;let y=null,x=null,v=null;const w=()=>{v?.remove()},S=e=>{v&&y&&(A(),((e,t,i)=>{if(!e||!t)return;const{viewScaleInfo:o,material:r,groupQueue:a}=i,{scale:n,offsetTop:s,offsetLeft:l}=o;t?.children&&Array.from(t.children).forEach(e=>{e.remove()});let h=t;for(let e=0;e<a.length;e++){const t=a[e],{x:i,y:o,width:r,height:c}=t,d={x:i*n,y:o*n,width:r*n,height:c*n,angle:X(t.angle||0)};0===e&&(d.x+=l,d.y+=s),h=or({size:d,parent:h})}const c={...ir,...r};let d=r.x*n+l,u=r.y*n+s,f=r.width*n,g=r.height*n;a.length>0&&(d=r.x*n,u=r.y*n,f=r.width*n,g=r.height*n);let m="center",p="center";"left"===c.textAlign?m="start":"right"===c.textAlign&&(m="end"),"top"===c.verticalAlign?p="start":"bottom"===c.verticalAlign&&(p="end"),it(e,{justifyContent:m,alignItems:p,transform:`rotate(${X(r.angle||0)}deg)`,left:d-1+"px",top:u-1+"px",width:`${f+2}px`,height:`${g+2}px`,cornerRadius:("number"==typeof c.cornerRadius?c.cornerRadius:0)*n+"px",color:`${c.fill||"#000000"}`,textStroke:"number"==typeof c.strokeWidth&&c.strokeWidth>0?`${c.strokeWidth}px ${c.stroke}`:"","-webkit-text-stroke":"number"==typeof c.strokeWidth&&c.strokeWidth>0?`${c.strokeWidth}px ${c.stroke}`:"",fontSize:c.fontSize*n+"px",lineHeight:(c.lineHeight||c.fontSize)*n+"px",fontFamily:$e(c.fontFamily),fontWeight:`${c.fontWeight}`,opacity:c.opacity||1}),e.innerText=c.text||"",h.appendChild(e)})(y,x,e),tt(v,[er.hide]),f="",g=!0,y.focus(),d?.id&&(n.setActiveOverrideMaterialMap({[d.id]:{operations:{invisible:!0}}}),f=d.text||"",a.drawFrame()))},b=()=>{if(d?.id){const e=n.getActiveOverrideMaterialMap();e&&delete e[d.id],n.setActiveOverrideMaterialMap(e),a.drawFrame()}v&&et(v,[er.hide]),d=null,u=[],g=!1,w()},A=()=>{if(!x)return;const{left:e,top:t,width:i,height:o}=(()=>{const e=l.getBoundingClientRect(),{left:t,top:i,width:o,height:r}=e;return{left:t,top:i,width:o,height:r}})();it(x,{position:"absolute",overflow:"hidden",top:`${t}px`,left:`${e}px`,width:`${i}px`,height:`${o}px`})},M=()=>{b()},I=e=>{e.stopPropagation(),e.preventDefault(),window?.getSelection()?.removeAllRanges()},C=e=>{2===e.attributes&&e.preventDefault()},R=()=>{if(y&&d&&u){d.text=y.innerText||"",i.trigger(o.TEXT_CHANGE,{material:{id:d.id,attributes:{text:d.text}},position:[...u||[]]});const e=s.getVirtualItem(d.id),t=n.getActiveStorage("data")||{materials:[]};s.modifyVirtualAttributes(d,{viewScaleInfo:n.getActiveViewScaleInfo(),viewSizeInfo:n.getActiveViewSizeInfo(),groupQueue:J(t.materials,e?.position||[])||[]}),a.drawFrame()}},E=()=>{if(d&&u){d.text=y?.innerText||"",i.trigger(o.TEXT_CHANGE,{material:{id:d.id,attributes:{text:d.text}},position:[...u]});const e=n.getActiveStorage("data")||{materials:[]},t={text:d.text};Te(d.id,t,e.materials),ai(i,{selectedMaterials:[{...d,...d,...t}],data:e,type:"modifyMaterial",modifyRecord:{type:"modifyMaterial",time:Date.now(),content:{method:"modifyMaterial",id:d.id,before:{"attributes.text":f},after:{"attributes.text":d.text}}}});const r=s.getVirtualItem(d.id);s.modifyVirtualAttributes(d,{viewScaleInfo:n.getActiveViewScaleInfo(),viewSizeInfo:n.getActiveViewSizeInfo(),groupQueue:J(e.materials,r?.position||[])||[]}),a.drawFrame()}b()},z=e=>{e.stopPropagation()},L=e=>{e.stopPropagation(),e.preventDefault()},B=e=>{const{id:t}=e;if("string"!=typeof t||!t)return;!0!==g&&(y=rt("div",{className:er.textarea,contenteditable:"true"}),x=rt("div",{className:er.canvasWrapper},[y]),v=rt("div",{id:m,className:p},[x]),h.appendChild(v)),v?.addEventListener("click",M),y?.addEventListener("mousedown",z),y?.addEventListener("mouseover",z),y?.addEventListener("mouseenter",z),y?.addEventListener("mouseleave",z),y?.addEventListener("dblclick",I),y?.addEventListener("selectstart",C),y?.addEventListener("click",z),y?.addEventListener("input",R),y?.addEventListener("blur",E),y?.addEventListener("keydown",z),y?.addEventListener("keypress",z),y?.addEventListener("keyup",z),y?.addEventListener("wheel",L);const i=n.getActiveStorage("data"),{material:o,groupQueue:r,position:a}=Z(t,i.materials);"text"===o?.type&&(d=o,u=a,S({material:d,groupQueue:r,viewScaleInfo:n.getActiveViewScaleInfo()}))},k=()=>{if(!0===g)return!1};return{name:"@middleware/text-editor",use(){!function(e,t){mt({type:"element",rootClassName:e,styles:{position:"fixed",top:"0",bottom:"0",left:"0",right:"0",display:"block",zIndex:t.zIndex,[`&.${er.hide}`]:{display:"none"},[`.${er.textarea}`]:{display:"inline-flex",flexDirection:"column",position:"absolute",boxSizing:"border-box",overflow:"hidden",wordBreak:"break-all",padding:"0",margin:"0",outline:"none",border:`1px solid ${t.boxBorderColor}`,background:"transparent"},[`.${er.canvasWrapper}`]:{position:"absolute"}}})}(p,c),i.on(o.TEXT_EDIT,B)},disuse(){!function(e){pt({rootClassName:e,type:"element"})}(p),i.off(o.TEXT_EDIT,B),v?.removeEventListener("click",M),y?.removeEventListener("mousedown",z),y?.removeEventListener("mouseover",z),y?.removeEventListener("mouseenter",z),y?.removeEventListener("mouseleave",z),y?.removeEventListener("dblclick",I),y?.removeEventListener("selectstart",C),y?.removeEventListener("click",z),y?.removeEventListener("input",R),y?.removeEventListener("blur",E),y?.removeEventListener("keydown",z),y?.removeEventListener("keypress",z),y?.removeEventListener("keyup",z),y?.removeEventListener("wheel",L),w(),y=null,x=null,v=null,d=null,u=null,f=null},hover:k,pointStart:k,pointMove:k,pointEnd:k,pointLeave:k,doubleClick:k,contextMenu:k,wheel:k,wheelScale:k,scrollX:k,scrollY:k,resize:k}},e.Sharer=jt,e.coreEventKeys=o,e.getMiddlewareCreatorStyles=ti,e.getMiddlewareInfoStyles=ho,e.getMiddlewarePathCreatorStyles=ea,e.getMiddlewarePathEditorStyles=Er,e.getMiddlewareRulerStyles=Zo,e.getMiddlewareScrollerStyles=Yo,e.getMiddlewareSelectorStyles=Mo,e.getMiddlewareTextEditorStyles=tr,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),e}({});
|