@idraw/util 1.0.0-alpha.1 → 1.0.0-alpha.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- var iDrawUtil=function(t){"use strict";function e(t){return"string"==typeof t&&(/^#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(t)||/^[a-z]{1,}$/i.test(t))}const n={aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",green:"#008000",greenyellow:"#adff2f",honeydew:"#f0fff0",hotpink:"#ff69b4","indianred ":"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrodyellow:"#fafad2",lightgrey:"#d3d3d3",lightgreen:"#90ee90",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370d8",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#d87093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",rebeccapurple:"#663399",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32"};function i(t){return(65536*(1+Math.random())|0).toString(16).substring(1)}function r(){return`${i()}${i()}-${i()}-${i()}-${i()}-${i()}${i()}${i()}`}function o(t,e){let n=0;for(let e=0;e<t.length;e++)n+=t.charCodeAt(e);return(n+e).toString(16).substring(0,4)}function a(t,e){const n=t.length,i=function(t){let e=0;for(let n=0;n<t.length;n++)e+=t.charCodeAt(n);return e}(e),r=Math.floor(n/2),a=t.substring(0,4).padStart(4,"0"),s=t.substring(0,4).padStart(4,"0");return`@assets/${o(n.toString(16).padStart(4,a),i).padStart(4,"0")}${o(t.substring(r-4,r).padStart(4,a),i).padStart(4,"0")}-${o(t.substring(r-8,r-4).padStart(4,a),i).padStart(4,"0")}-${o(t.substring(r-12,r-8).padStart(4,a),i).padStart(4,"0")}-${o(t.substring(r-16,r-12).padStart(4,s),i).padStart(4,"0")}-${o(t.substring(r,r+4).padStart(4,s),i).padStart(4,"0")}${o(t.substring(r+4,r+8).padStart(4,s),i).padStart(4,"0")}${o(s.padStart(4,a).padStart(4,s),i)}`}function s(t){return/^@assets\/[0-9a-z-]{0,}$/.test(`${t}`)}function c(t){return function t(e){const n=function(t){return Object.prototype.toString.call(t).replace(/[\]|\[]{1,1}/gi,"").split(" ")[1]}(e);if(["Null","Number","String","Boolean","Undefined"].indexOf(n)>=0)return e;if("Array"===n){const n=[];return e.forEach(e=>{n.push(t(e))}),n}if("Object"===n){const n={};Object.keys(e).forEach(i=>{n[i]=t(e[i])});return Object.getOwnPropertySymbols(e).forEach(i=>{n[i]=t(e[i])}),n}}(t)}function l(t){const e=c(t),n=t=>{t.id=r(),"group"===t.type&&t.children&&t.children.forEach(t=>{n(t)})};return n(e),e}function h(t){return(Object.prototype.toString.call(t)||"").replace(/(\[object|\])/gi,"").trim()}const f={type(t,e){const n=h(t);return!0===e?n.toLocaleLowerCase():n},array:t=>"Array"===h(t),json:t=>"Object"===h(t),function:t=>"Function"===h(t),asyncFunction:t=>"AsyncFunction"===h(t),boolean:t=>"Boolean"===h(t),string:t=>"String"===h(t),number:t=>"Number"===h(t),undefined:t=>"Undefined"===h(t),null:t=>"Null"===h(t),promise:t=>"Promise"===h(t)};function u(t,e){const{width:n,height:i}=e;return new Promise((e,r)=>{const o=new Blob([`\n <svg \n xmlns="http://www.w3.org/2000/svg" \n width="${n||""}" \n height = "${i||""}">\n <foreignObject width="100%" height="100%">\n <div xmlns = "http://www.w3.org/1999/xhtml">\n ${t}\n </div>\n </foreignObject>\n </svg>\n `],{type:"image/svg+xml;charset=utf-8"}),a=new FileReader;a.readAsDataURL(o),a.onload=function(t){const n=t?.target?.result;e(n)},a.onerror=function(t){r(t)}})}function d(t){return new Promise((e,n)=>{const i=new Blob([t],{type:"image/svg+xml;charset=utf-8"}),r=new FileReader;r.readAsDataURL(i),r.onload=function(t){const n=t?.target?.result;e(n)},r.onerror=function(t){n(t)}})}const{Image:y}=window;function p(t){return new Promise((e,n)=>{const i=new y;i.crossOrigin="anonymous",i.onload=function(){e(i)},i.onabort=n,i.onerror=n,i.src=t})}function g(t){return"number"==typeof t&&t>=0}function x(t){return"number"==typeof t&&(t>0||t<=0)}function m(t){return x(t)}function b(t){return x(t)}function w(t){return g(t)}function M(t){return g(t)}function v(t){return"string"==typeof t&&/^(http:\/\/|https:\/\/|\.\/|\/)/.test(`${t}`)}function P(t){return"string"==typeof t&&/^(data:image\/)/.test(`${t}`)}function R(t){return["rect","circle","text","image","svgCode","foreignObject","group"].includes(t)}const $={positiveNum:g,data:function(t){return!!(Array(t?.materials)&&t?.materials.length>=0)},material:function(t){return!!t&&(R(t?.type)&&m(t?.x)&&b(t?.y)&&w(t?.w)&&M(t?.h))},layout:function(t){return!!t&&(m(t?.x)&&b(t?.y)&&w(t?.w)&&M(t?.h))},type:R,x:m,y:b,width:w,height:M,angle:function(t){return"number"==typeof t&&t>=-360&&t<=360},number:x,numberStr:function(t){return/^(-?\d+(?:\.\d+)?)$/.test(`${t}`)},strokeWidth:function(t){return g(t)||Array.isArray(t)&&g(t[0])&&g(t[1])&&g(t[2])&&g(t[3])},cornerRadius:function(t){return g(t)||Array.isArray(t)&&g(t[0])&&g(t[1])&&g(t[2])&&g(t[3])},color:function(t){return e(t)},imageSrc:function(t){return P(t)||v(t)},imageURL:v,imageBase64:P,svg:function(t){return"string"==typeof t&&/^(<svg[\s]{1,}|<svg>)/i.test(`${t}`.trim())&&/<\/[\s]{0,}svg>$/i.test(`${t}`.trim())},html:function(t){let e=!1;if("string"==typeof t){let n=document.createElement("div");n.innerHTML=t,n.children.length>0&&(e=!0),n=null}return e},text:function(t){return"string"==typeof t},fontSize:function(t){return x(t)&&t>0},lineHeight:function(t){return x(t)&&t>0},textAlign:function(t){return["center","left","right"].includes(t)},fontFamily:function(t){return"string"==typeof t&&t.length>0},fontWeight:function(t){return["bold"].includes(t)}};function k(t={}){const{stroke:e,cornerRadius:n,strokeWidth:i}=t;return!(Object.prototype.hasOwnProperty.call(t,"stroke")&&!$.color(e))&&(!(Object.prototype.hasOwnProperty.call(t,"cornerRadius")&&!$.number(n))&&!(Object.prototype.hasOwnProperty.call(t,"strokeWidth")&&!$.number(i)))}const S={attrs:function(t){const{x:e,y:n,width:i,height:r,angle:o=0}=t;return!!($.x(e)&&$.y(n)&&$.width(i)&&$.height(r)&&$.angle(o))&&(o>=-360&&o<=360)},textDesc:function(t){const{text:e,color:n,fontSize:i,lineHeight:r,fontFamily:o,textAlign:a,fontWeight:s,background:c,strokeWidth:l,strokeColor:h}=t;return!!$.text(e)&&(!!$.color(n)&&(!!$.fontSize(i)&&(!(Object.prototype.hasOwnProperty.call(t,"background")&&!$.color(c))&&(!(Object.prototype.hasOwnProperty.call(t,"fontWeight")&&!$.fontWeight(s))&&(!(Object.prototype.hasOwnProperty.call(t,"lineHeight")&&!$.lineHeight(r))&&(!(Object.prototype.hasOwnProperty.call(t,"fontFamily")&&!$.fontFamily(o))&&(!(Object.prototype.hasOwnProperty.call(t,"textAlign")&&!$.textAlign(a))&&(!(Object.prototype.hasOwnProperty.call(t,"strokeWidth")&&!$.strokeWidth(l))&&(!(Object.prototype.hasOwnProperty.call(t,"strokeColor")&&!$.color(h))&&!!k(t))))))))))},rectDesc:function(t){const{background:e}=t;return!(Object.prototype.hasOwnProperty.call(t,"background")&&!$.color(e))&&!!k(t)},circleDesc:function(t){const{background:e,stroke:n,strokeWidth:i}=t;return!(Object.prototype.hasOwnProperty.call(t,"background")&&!$.color(e))&&(!(Object.prototype.hasOwnProperty.call(t,"stroke")&&!$.color(n))&&!(Object.prototype.hasOwnProperty.call(t,"strokeWidth")&&!$.number(i)))},imageDesc:function(t){const{href:e}=t;return!!$.imageSrc(e)},svgDesc:function(t){const{svg:e}=t;return!!$.svg(e)},htmlDesc:function(t){const{html:e}=t;return!!$.html(e)}};class C{#t;#e;constructor(t,e){this.#t=t,this.#e={devicePixelRatio:1,offscreenCanvas:null,...e},this.$resetFont()}$undoPixelRatio(t){return t/this.#e.devicePixelRatio}$doPixelRatio(t){return this.#e.devicePixelRatio*t}$getContext(){return this.#t}$setContext(t){this.#t=t}$setFont(t){const e=[];t.fontWeight&&e.push(`${t.fontWeight}`),e.push(`${this.$doPixelRatio(t.fontSize||12)}px`),e.push(`${t.fontFamily||"sans-serif"}`),this.#t.font=`${e.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.#e.offscreenCanvas}$resize(t){const{width:e,height:n,devicePixelRatio:i,resetStyle:r}=t,{canvas:o}=this.#t;o.width=e*i,o.height=n*i,this.#e={...this.#e,devicePixelRatio:i},!0===r&&(o.style.width=`${e}px`,o.style.height=`${n}px`)}$getSize(){const{devicePixelRatio:t}=this.#e,{width:e,height:n}=this.#t.canvas;return{width:e/t,height:n/t,devicePixelRatio:t}}get canvas(){return this.#t.canvas}get fillStyle(){return this.#t.fillStyle}set fillStyle(t){this.#t.fillStyle=t}get strokeStyle(){return this.#t.strokeStyle}set strokeStyle(t){this.#t.strokeStyle=t}get lineWidth(){return this.$undoPixelRatio(this.#t.lineWidth)}set lineWidth(t){this.#t.lineWidth=this.$doPixelRatio(t)}get textAlign(){return this.#t.textAlign}set textAlign(t){this.#t.textAlign=t}get textBaseline(){return this.#t.textBaseline}set textBaseline(t){this.#t.textBaseline=t}get globalAlpha(){return this.#t.globalAlpha}set globalAlpha(t){this.#t.globalAlpha=t}get shadowColor(){return this.#t.shadowColor}set shadowColor(t){this.#t.shadowColor=t}get shadowOffsetX(){return this.$undoPixelRatio(this.#t.shadowOffsetX)}set shadowOffsetX(t){this.#t.shadowOffsetX=this.$doPixelRatio(t)}get shadowOffsetY(){return this.$undoPixelRatio(this.#t.shadowOffsetY)}set shadowOffsetY(t){this.#t.shadowOffsetY=this.$doPixelRatio(t)}get shadowBlur(){return this.$undoPixelRatio(this.#t.shadowBlur)}set shadowBlur(t){this.#t.shadowBlur=this.$doPixelRatio(t)}get lineCap(){return this.#t.lineCap}set lineCap(t){this.#t.lineCap=t}get lineJoin(){return this.#t.lineJoin}set lineJoin(t){this.#t.lineJoin=t}get lineDashOffset(){return this.#t.lineDashOffset}set lineDashOffset(t){this.#t.lineDashOffset=t}get miterLimit(){return this.#t.miterLimit}set miterLimit(t){this.#t.miterLimit=t}get globalCompositeOperation(){return this.#t.globalCompositeOperation}set globalCompositeOperation(t){this.#t.globalCompositeOperation=t}fill(...t){return this.#t.fill(...t)}arc(t,e,n,i,r,o){return this.#t.arc(this.$doPixelRatio(t),this.$doPixelRatio(e),this.$doPixelRatio(n),i,r,o)}rect(t,e,n,i){return this.#t.rect(this.$doPixelRatio(t),this.$doPixelRatio(e),this.$doPixelRatio(n),this.$doPixelRatio(i))}fillRect(t,e,n,i){return this.#t.fillRect(this.$doPixelRatio(t),this.$doPixelRatio(e),this.$doPixelRatio(n),this.$doPixelRatio(i))}clearRect(t,e,n,i){return this.#t.clearRect(this.$doPixelRatio(t),this.$doPixelRatio(e),this.$doPixelRatio(n),this.$doPixelRatio(i))}beginPath(){return this.#t.beginPath()}closePath(){return this.#t.closePath()}lineTo(t,e){return this.#t.lineTo(this.$doPixelRatio(t),this.$doPixelRatio(e))}moveTo(t,e){return this.#t.moveTo(this.$doPixelRatio(t),this.$doPixelRatio(e))}arcTo(t,e,n,i,r){return this.#t.arcTo(this.$doPixelRatio(t),this.$doPixelRatio(e),this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(r))}bezierCurveTo(t,e,n,i,r,o){return this.#t.bezierCurveTo(this.$doPixelRatio(t),this.$doPixelRatio(e),this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(r),this.$doPixelRatio(o))}quadraticCurveTo(t,e,n,i){return this.#t.quadraticCurveTo(this.$doPixelRatio(t),this.$doPixelRatio(e),this.$doPixelRatio(n),this.$doPixelRatio(i))}getLineDash(){return this.#t.getLineDash()}setLineDash(t){const e=t.map(t=>this.$doPixelRatio(t));return this.#t.setLineDash(e)}stroke(t){return t?this.#t.stroke(t):this.#t.stroke()}translate(t,e){return this.#t.translate(this.$doPixelRatio(t),this.$doPixelRatio(e))}rotate(t){return this.#t.rotate(t)}drawImage(...t){const e=t[0],n=t[1],i=t[2],r=t[3],o=t[4],a=t[t.length-4],s=t[t.length-3],c=t[t.length-2],l=t[t.length-1];return 9===t.length?this.#t.drawImage(e,this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(r),this.$doPixelRatio(o),this.$doPixelRatio(a),this.$doPixelRatio(s),this.$doPixelRatio(c),this.$doPixelRatio(l)):this.#t.drawImage(e,this.$doPixelRatio(a),this.$doPixelRatio(s),this.$doPixelRatio(c),this.$doPixelRatio(l))}createPattern(t,e){return this.#t.createPattern(t,e)}measureText(t){return this.#t.measureText(t)}fillText(t,e,n,i){return void 0!==i?this.#t.fillText(t,this.$doPixelRatio(e),this.$doPixelRatio(n),this.$doPixelRatio(i)):this.#t.fillText(t,this.$doPixelRatio(e),this.$doPixelRatio(n))}strokeText(t,e,n,i){return void 0!==i?this.#t.strokeText(t,this.$doPixelRatio(e),this.$doPixelRatio(n),this.$doPixelRatio(i)):this.#t.strokeText(t,this.$doPixelRatio(e),this.$doPixelRatio(n))}save(){this.#t.save()}restore(){this.#t.restore()}scale(t,e){this.#t.scale(t,e)}circle(t,e,n,i,r,o,a,s){this.#t.ellipse(this.$doPixelRatio(t),this.$doPixelRatio(e),this.$doPixelRatio(n),this.$doPixelRatio(i),r,o,a,s)}ellipse(t,e,n,i,r,o,a,s){this.#t.ellipse(this.$doPixelRatio(t),this.$doPixelRatio(e),this.$doPixelRatio(n),this.$doPixelRatio(i),r,o,a,s)}isPointInPath(t,e){return this.#t.isPointInPath(this.$doPixelRatio(t),this.$doPixelRatio(e))}clip(...t){return this.#t.clip(...t)}setTransform(t,e,n,i,r,o){return this.#t.setTransform(t,e,n,i,r,o)}getTransform(){return this.#t.getTransform()}createLinearGradient(t,e,n,i){return this.#t.createLinearGradient(this.$doPixelRatio(t),this.$doPixelRatio(e),this.$doPixelRatio(n),this.$doPixelRatio(i))}createRadialGradient(t,e,n,i,r,o){return this.#t.createRadialGradient(this.$doPixelRatio(t),this.$doPixelRatio(e),this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(r),this.$doPixelRatio(o))}createConicGradient(t,e,n){return this.#t.createConicGradient(t,this.$doPixelRatio(e),this.$doPixelRatio(n))}}function A(t){const{width:e,height:n,ctx:i,devicePixelRatio:r}=t;let o=i;if(!o){const t=document.createElement("canvas");t.width=e*r,t.height=n*r,o=t.getContext("2d")}return new C(o,t)}function L(t){const{width:e,height:n,devicePixelRatio:i}=t,r=new OffscreenCanvas(e*i,n*i),o=r.getContext("2d").canvas.getContext("2d");return new C(o,{devicePixelRatio:i,offscreenCanvas:r})}function I(t,e){const n=(t.x-e.x)*(t.x-e.x)+(t.y-e.y)*(t.y-e.y);return 0===n?n:Math.sqrt(n)}function E(t,e){return{x:t.x+(e.x-t.x)/2,y:t.y+(e.y-t.y)/2}}const O=t=>t===t.toLowerCase();function z(t,e,n,i){const{type:r,params:o=[]}=t;return{x:O(r)?i.x+o[e]:o[e],y:O(r)?i.y+o[n]:o[n]}}function T(t,e){return{c1:{x:t.x+(e.x-t.x)/3,y:t.y+(e.y-t.y)/3},c2:{x:t.x+2*(e.x-t.x)/3,y:t.y+2*(e.y-t.y)/3},end:{...e}}}function j(t,e,n){return{c1:{x:t.x+2/3*(e.x-t.x),y:t.y+2/3*(e.y-t.y)},c2:{x:n.x+2/3*(e.x-n.x),y:n.y+2/3*(e.y-n.y)},end:{...n}}}function W(t){let e={x:0,y:0},n={x:0,y:0},i=null;const r=[],o=t=>{const o=z(t,0,1,e);e={...o},n={...o},r.push({id:te(),name:"moveTo",params:{x:o.x,y:o.y}}),i=null},a=t=>{const n=z(t,0,1,e),o=T(e,n);r.push({id:te(),name:"bezierCurveTo",params:{cp1x:o.c1.x,cp1y:o.c1.y,cp2x:o.c2.x,cp2y:o.c2.y,x:o.end.x,y:o.end.y}}),e={...n},i=o.c2},s=t=>{const n={x:O(t.type)?e.x+t.params[0]:t.params[0],y:e.y},o=T(e,n);r.push({id:te(),name:"bezierCurveTo",params:{cp1x:o.c1.x,cp1y:o.c1.y,cp2x:o.c2.x,cp2y:o.c2.y,x:o.end.x,y:o.end.y}}),e={...n},i=o.c2},c=t=>{const n=O(t.type)?e.y+t.params[0]:t.params[0],o={x:e.x,y:n},a=T(e,o);r.push({id:te(),name:"bezierCurveTo",params:{cp1x:a.c1.x,cp1y:a.c1.y,cp2x:a.c2.x,cp2y:a.c2.y,x:a.end.x,y:a.end.y}}),e={...o},i=a.c2},l=t=>{const n=z(t,0,1,e),o=z(t,2,3,e),a=z(t,4,5,e);r.push({id:te(),name:"bezierCurveTo",params:{cp1x:n.x,cp1y:n.y,cp2x:o.x,cp2y:o.y,x:a.x,y:a.y}}),e={...a},i=o},h=t=>{const n=i||e,o={x:2*e.x-n.x,y:2*e.y-n.y},a=z(t,0,1,e),s=z(t,2,3,e);r.push({id:te(),name:"bezierCurveTo",params:{cp1x:o.x,cp1y:o.y,cp2x:a.x,cp2y:a.y,x:s.x,y:s.y}}),e={...s},i=a},f=t=>{const n=z(t,0,1,e),o=z(t,2,3,e),a=j(e,n,o);r.push({id:te(),name:"bezierCurveTo",params:{cp1x:a.c1.x,cp1y:a.c1.y,cp2x:a.c2.x,cp2y:a.c2.y,x:a.end.x,y:a.end.y}}),e={...o},i=a.c2},u=t=>{const n=i?{x:2*e.x-i.x,y:2*e.y-i.y}:e,o=z(t,0,1,e),a=j(e,n,o);r.push({id:te(),name:"bezierCurveTo",params:{cp1x:a.c1.x,cp1y:a.c1.y,cp2x:a.c2.x,cp2y:a.c2.y,x:a.end.x,y:a.end.y}}),e={...o},i=a.c2},d=t=>{const[n,i,o,a,s,c,l]=t.params,h={x:O(t.type)?e.x+c:c,y:O(t.type)?e.y+l:l},f=function(t,e,n,i,r,o,a){if(n=Math.abs(n),i=Math.abs(i),Math.abs(t.x-e.x)<1e-6&&Math.abs(t.y-e.y)<1e-6)return{centerX:t.x,centerY:t.y,radiusX:n,radiusY:i,rotation:r*Math.PI/180,startRadian:0,endRadian:0,anticlockwise:0===a};if(n<1e-6||i<1e-6)return{centerX:(t.x+e.x)/2,centerY:(t.y+e.y)/2,radiusX:0,radiusY:0,rotation:0,startRadian:0,endRadian:0,anticlockwise:!1};const s=r*Math.PI/180,c=Math.cos(s),l=Math.sin(s),h=(t.x-e.x)/2,f=(t.y-e.y)/2,u=c*h+l*f,d=-l*h+c*f,y=u*u/(n*n)+d*d/(i*i);if(y>1){const t=Math.sqrt(y);n*=t,i*=t}const p=o===a?-1:1;let g=Math.sqrt(Math.abs((n*n*i*i-n*n*d*d-i*i*u*u)/(n*n*d*d+i*i*u*u)));isNaN(g)&&(g=0);const x=p*g*(n*d)/i,m=p*g*(-i*u)/n,b=c*x-l*m+(t.x+e.x)/2,w=l*x+c*m+(t.y+e.y)/2,M=(u-x)/n,v=(d-m)/i,P=(-u-x)/n,R=(-d-m)/i,$=Math.atan2(v,M);let k=Math.atan2(R,P)-$;return 0===a&&k>0?k-=2*Math.PI:1===a&&k<0&&(k+=2*Math.PI),{centerX:b,centerY:w,radiusX:n,radiusY:i,rotation:s,startRadian:$,endRadian:$+k,anticlockwise:0===a}}(e,h,n,i,o*Math.PI/180,a,s);r.push({id:te(),name:"ellipse",params:f}),e={...h}},y=t=>{if(e.x!==n.x||e.y!==n.y){const t=T(e,n);r.push({id:te(),name:"bezierCurveTo",params:{cp1x:t.c1.x,cp1y:t.c1.y,cp2x:t.c2.x,cp2y:t.c2.y,x:t.end.x,y:t.end.y}})}r.push({id:te(),name:"closePath",params:null}),e={...n},i=null};r.push({id:te(),name:"beginPath",params:null});for(const e of t){const{id:t,type:n,params:i=[]}=e,r={type:n,params:i};switch(r.type.toUpperCase()){case"M":o(r);break;case"L":a(r);break;case"H":s(r);break;case"V":c(r);break;case"C":l(r);break;case"S":h(r);break;case"Q":f(r);break;case"T":u(r);break;case"A":d(r);break;case"Z":y()}}return r}function D(t){const{centerX:e,centerY:n,radiusX:i,radiusY:r,rotation:o,startRadian:a,endRadian:s,anticlockwise:c}=t,l=function(t,e,n,i,r,o){const a=Math.cos(r),s=Math.sin(r),c=t+n*Math.cos(o)*a-i*Math.sin(o)*s,l=e+n*Math.cos(o)*s+i*Math.sin(o)*a;return{x:c,y:l}}(e,n,i,r,o,s);let h=s-a;c?h>0&&(h-=2*Math.PI):h<0&&(h+=2*Math.PI);const f=Math.abs(h)>Math.PI?1:0,u=c?0:1;return{rx:i,ry:r,xAxisRotation:180*o/Math.PI,largeArcFlag:f,sweepFlag:u,endPoint:l}}function F(t){return t/180*Math.PI}function V(t,e,n,i){const r=F(e||0);n&&(r>0||r<0)&&(t.translate(n.x,n.y),t.rotate(r),t.translate(-n.x,-n.y)),i(t),n&&(r>0||r<0)&&(t.translate(n.x,n.y),t.rotate(-r),t.translate(-n.x,-n.y))}function B(t){return{x:t.x+t.width/2,y:t.y+t.height/2}}function H(t){const e=Math.min(t[0].x,t[1].x,t[2].x,t[3].x),n=Math.min(t[0].y,t[1].y,t[2].y,t[3].y);return B({x:e,y:n,width:Math.max(t[0].x,t[1].x,t[2].x,t[3].x)-e,height:Math.max(t[0].y,t[1].y,t[2].y,t[3].y)-n})}function N(t,e){const n=e.x-t.x,i=e.y-t.y;if(0===n){if(i<0)return 0;if(i>0)return Math.PI}else if(0===i){if(n<0)return 3*Math.PI/2;if(n>0)return Math.PI/2}return n>0&&i<0?Math.atan(Math.abs(n)/Math.abs(i)):n>0&&i>0?Math.PI-Math.atan(Math.abs(n)/Math.abs(i)):n<0&&i>0?Math.PI+Math.atan(Math.abs(n)/Math.abs(i)):n<0&&i<0?2*Math.PI-Math.atan(Math.abs(n)/Math.abs(i)):0}function X(t,e,n){let i=N(t,e)+n;i>2*Math.PI?i-=2*Math.PI:i<0-2*Math.PI&&(i+=2*Math.PI),i<0&&(i+=2*Math.PI);const r=I(t,e);let o=0,a=0;return 0===i?(o=0,a=0-r):i>0&&i<Math.PI/2?(o=Math.sin(i)*r,a=0-Math.cos(i)*r):i===Math.PI/2?(o=r,a=0):i>Math.PI/2&&i<Math.PI?(o=Math.sin(Math.PI-i)*r,a=Math.cos(Math.PI-i)*r):i===Math.PI?(o=0,a=r):i>Math.PI&&i<1.5*Math.PI?(o=0-Math.sin(i-Math.PI)*r,a=Math.cos(i-Math.PI)*r):i===1.5*Math.PI?(o=0-r,a=0):i>1.5*Math.PI&&i<2*Math.PI?(o=0-Math.sin(2*Math.PI-i)*r,a=0-Math.cos(2*Math.PI-i)*r):i===2*Math.PI&&(o=0,a=0-r),o+=t.x,a+=t.y,{x:o,y:a}}function U(t,e){if(e?.length>0){let n=t.x,i=t.y;return e.forEach(t=>{const{x:e,y:r,width:o,height:a,angle:s=0}=t,c=X(B({x:e,y:r,width:o,height:a}),{x:n,y:i},F(s));n=c.x,i=c.y}),{x:n,y:i}}return t}function Y(t,e,n){const{x:i,y:r,width:o,height:a}=t;let s={x:i,y:r},c={x:i+o,y:r},l={x:i+o,y:r+a},h={x:i,y:r+a};if(n&&(n>0||n<0)){const t=F(q(n));s=X(e,s,t),c=X(e,c,t),l=X(e,l,t),h=X(e,h,t)}return[s,c,l,h]}function G(t){const{angle:e=0}=t;return Y(t,B(t),e)}function Q(t,e,n){return[X(t,{x:e[0].x,y:e[0].y},n),X(t,{x:e[1].x,y:e[1].y},n),X(t,{x:e[2].x,y:e[2].y},n),X(t,{x:e[3].x,y:e[3].y},n)]}function q(t){if(!(t>0||t<0)||0===t||360===t)return 0;let e=t%360;return e<0?e+=360:360===t&&(e=0),e}function Z(t){const e={x:0,y:0,width:0,height:0};let n=null;for(let i=0;i<t.length;i++){const r=t[i];if(r?.operations?.invisible)continue;const o={x:r.x,y:r.y,width:r.width,height:r.height,angle:r.angle||0};if(o.angle&&(o.angle>0||o.angle<0)){const t=G(o);if(4===t.length){const e=[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];o.x=Math.min(...e),o.y=Math.min(...n),o.width=Math.abs(Math.max(...e)-Math.min(...e)),o.height=Math.abs(Math.max(...n)-Math.min(...n))}}if(n){const t=Math.min(o.x,e.x),n=Math.min(o.y,e.y),i=Math.max(o.x+o.width,e.x+e.width),r=Math.max(o.y+o.height,e.y+e.height);e.x=t,e.y=n,e.width=Math.abs(i-t),e.height=Math.abs(r-n)}else e.x=o.x,e.y=o.y,e.width=o.width,e.height=o.height;n=o}return{x:Math.floor(e.x),y:Math.floor(e.y),width:Math.ceil(e.width),height:Math.ceil(e.height)}}function J(t,e){const n={x:0,y:0,width:0,height:0};t.forEach(t=>{const e={x:t.x,y:t.y,width:t.width,height:t.height,angle:t.angle};if(e.angle&&(e.angle>0||e.angle<0)){const t=G(e);if(4===t.length){const n=[t[0].x,t[1].x,t[2].x,t[3].x],i=[t[0].y,t[1].y,t[2].y,t[3].y];e.x=Math.min(...n),e.y=Math.min(...i),e.width=Math.abs(Math.max(...n)-Math.min(...n)),e.height=Math.abs(Math.max(...i)-Math.min(...i))}}const i=Math.min(e.x,n.x),r=Math.min(e.y,n.y),o=Math.max(e.x+e.width,n.x+n.width),a=Math.max(e.y+e.height,n.y+n.height);n.x=i,n.y=r,n.width=Math.abs(o-i),n.height=Math.abs(a-r)}),e?.extend&&(n.x=Math.min(n.x,0),n.y=Math.min(n.y,0));const i={contextWidth:n.width,contextHeight:n.height};return e?.viewWidth&&e?.viewHeight&&e?.viewWidth>0&&e?.viewHeight>0&&(e.viewWidth>n.x+n.width&&(i.contextWidth=e.viewWidth-n.x),e.viewHeight>n.y+n.height&&(i.contextHeight=e.viewHeight-n.y)),i}function _(t,e){const n=[];let i=null;const r=[];return function t(e,o){let a=null;for(let s=0;s<o.length;s++){const c=o[s];if(r.push(s),c.id===e){a=c,i=c;break}if(!a&&"group"===c.type){n.push(c);const i=t(e,c?.children||[]);if(i?.id===e){a=i;break}n.pop(),r.pop()}}return a}(t,e),{groupQueue:n,material:i,position:r}}function K(t,e){let n=null,i=e;for(let e=0;e<t.length;e++){const r=i[t[e]];if(e<t.length-1&&"group"===r?.type)i=r.children;else{if(e!==t.length-1)break;n=r}}return n}function tt(t,e){const n=[];let i=!1;const r=e=>{for(let o=0;o<e.length&&!0!==i;o++){n.push(o);const a=e[o];if(a.id===t){i=!0;break}if("group"===a.type&&r(a?.children||[]),i)break;n.pop()}};return r(e),n}function et(t,e){const n=t.x,i=t.y,r=t.x+t.width,o=t.y+t.height,a=e.x,s=e.y,c=e.x+e.width,l=e.y+e.height;return n<=c&&r>=a&&i<=l&&o>=s}function nt(t){const{x:e,y:n,height:i,width:r}=t;return[{x:e,y:n},{x:e+r,y:n},{x:e+r,y:n+i},{x:e,y:n+i}]}function it(t){const{x:e,y:n,width:i,height:r,angle:o=0}=t;return 0===o?nt(t):Y(t,B({x:e,y:n,width:i,height:r}),o)}function rt(t){const e=[];let n=0,i=0;const r=[],o=[...t];for(let t=0;t<o.length;t++){const{x:a,y:s,width:c,height:l,angle:h=0}=o[t];let f;if(n+=a,i+=s,0===t){const t={x:n,y:i,width:c,height:l};f=it({x:a,y:s,width:c,height:l,angle:h}),r.push({center:B(t),angle:h,radian:F(h)})}else{f=nt({x:n,y:i,width:c,height:l});for(let t=0;t<r.length;t++){const{center:e,radian:n}=r[t];f=Q(e,f,n)}const t=H(f);if(h>0||h<0){f=Q(t,f,F(h))}r.push({center:t,angle:h,radian:F(h)})}e.push(f)}return e}function ot(t,e){const{groupQueue:n}=e;if(!(n.length>0))return[it(t)];return rt([...n,t])}function at(t,e){return ot(t,e).pop()||null}function st(t,e){const{viewScaleInfo:n}=e,{id:i,x:r,y:o,width:a,height:s,angle:c}=t,{scale:l=1,offsetTop:h=0,offsetLeft:f=0}=n;return{id:i,x:r*l+f,y:o*l+h,width:a*l,height:s*l,angle:c}}function ct(t,e){const{viewScaleInfo:n}=e,{x:i,y:r}=t,{scale:o,offsetTop:a,offsetLeft:s}=n;return{x:i*o+s,y:r*o+a}}function lt(t,e){const{context2d:n,material:i,viewScaleInfo:r}=e,{angle:o=0}=i,{x:a,y:s,width:c,height:l}=st(i,{viewScaleInfo:r}),h=G({x:a,y:s,width:c,height:l,angle:o});if(h.length>=2){n.beginPath(),n.moveTo(h[0].x,h[0].y);for(let t=1;t<h.length;t++)n.lineTo(h[t].x,h[t].y);n.closePath()}return!!n.isPointInPath(t.x,t.y)}function ht(t,e,n){const i=[e[0].x,e[1].x,e[2].x,e[3].x],r=[e[0].y,e[1].y,e[2].y,e[3].y],o=Math.min(...i),a=Math.max(...i),s=Math.min(...r),c=Math.max(...r);return t.x>o&&t.x<a&&t.y>s&&t.y<c||!0===n?.includeBorder&&(t.x===o||t.x===a||t.y===s||t.y===c)}function ft(t,e){const{groupQueue:n}=e,i=at(t,{groupQueue:n}),r=E(i[0],i[1]),o=E(i[1],i[2]),a=E(i[2],i[3]),s=E(i[3],i[0]),c=i[0],l=i[1],h=i[2],f=i[3],u=Math.max(c.x,l.x,h.x,f.x),d=Math.max(c.y,l.y,h.y,f.y);return{center:{x:(u+Math.min(c.x,l.x,h.x,f.x))/2,y:(d+Math.min(c.y,l.y,h.y,f.y))/2},topLeft:c,topRight:l,bottomLeft:f,bottomRight:h,top:r,right:o,left:s,bottom:a}}function ut(t,e){const{x:n,y:i}=t,{size:r,angle:o}=e;return{x:n-r/2,y:i-r/2,width:r,height:r,angle:o}}const dt=/([astvzqmhlc])([^astvzqmhlc]*)/gi,yt=/(-?\d+(?:\.\d+)?)/gi;function pt(t){const e=[];return t.replace(dt,(t,n,i)=>{const r=i.match(yt),o={type:n,params:r?r.map(Number):[]};return e.push(o),t}),e}const gt=/\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?(".*?"|'.*?')/g,xt=/<[a-zA-Z0-9\-\!\/](?:"[^"]*"|'[^']*'|[^'">])*>/g,mt=/^\s*$/,bt={};function wt(t){const e={type:"material",name:"",isVoid:!1,attributes:{},children:[]},n=t.match(/<\/?([^\s]+?)[/\s>]/);if(n&&(e.name=n[1],(bt[n[1]]||"/"===t.charAt(t.length-2))&&(e.isVoid=!0),e.name.startsWith("!--"))){const e=t.indexOf("--\x3e");return{type:"comment",name:null,attributes:{},children:[],isVoid:!1,comment:-1!==e?t.slice(4,e):""}}const i=new RegExp(gt);let r=null;for(;r=i.exec(t),null!==r;)if(r[0].trim())if(r[1]){const t=r[1].trim();let n=[t,""];t.indexOf("=")>-1&&(n=t.split("=")),e.attributes[n[0]]=n[1],i.lastIndex--}else r[2]&&(e.attributes[r[2]]=r[3].trim().substring(1,r[3].length-1));return e}function Mt(t,e){switch(e.type){case"text":return t+e.textContent;case"material":return t+="<"+e.name+(e.attributes?function(t){const e=[];for(const n in t)e.push(n+'="'+t[n]+'"');return e.length?" "+e.join(" "):""}(e.attributes):"")+(e.isVoid?"/>":">"),e.isVoid?t:t+e.children.reduce(Mt,"")+"</"+e.name+">";case"comment":return t+="\x3c!--"+e.comment+"--\x3e"}}function vt(t,e){let n=2;return void 0!==e?.decimalPlaces&&e?.decimalPlaces>=0&&(n=e.decimalPlaces),parseFloat(t.toFixed(n))}function Pt(t){return t[1]!=-1*t[3]||t[4]!=t[0]||t[0]*t[4]-t[3]*t[1]!=1?null:Math.acos(t[0])}const Rt="Text",$t="#787878",kt=`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="${$t}"><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 St(){return{opacity:1,display:"inline",visibility:"visible",overflow:"visible",fill:$t,fillOpacity:1,fillRule:"nonzero",stroke:"#525252",strokeWidth:0,strokeOpacity:1,strokeLinecap:"butt",strokeLinejoin:"miter",strokeDasharray:[],strokeDashoffset:0,strokeMiterlimit:0,text:Rt,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:kt}}function Ct(){return{fill:St().fill}}function At(t,e="",n={},i){return Object.keys(t).forEach(r=>{const o=e?`${e}${function(t){return/^\d+$/.test(t)&&!isNaN(Number(t))}(r)?`[${r}]`:`.${r}`}`:r;if(!i?.ignorePaths?.includes(o)){const e=t[r];!function(t){return"object"==typeof t&&null!==t&&!(t instanceof Date)||Array.isArray(t)}(e)?n[o]=e:At(e,(Array.isArray(e),o),n,i)}}),n}function Lt(t,e){return"object"!=typeof t||null===t?{"":t}:At(t,"",{},e)}function It(t){return Lt(t,{ignorePaths:["children"]})}function Et(t){return Lt(t)}function Ot(t){return Lt(t)}function zt(t){return Array.isArray(t)?[...t]:t.split(/\.|\[|\]/).filter(t=>""!==t)}function Tt(t,e,n){const i=zt(e);if(0===i.length)return t;let r=t;if(r)for(let t=0;t<i.length;t++){const e=i[t];if(t===i.length-1){r[e]=n;break}if(r&&(void 0===r?.[e]||"object"!=typeof r?.[e]||null===r?.[e])){const n=i[t+1],o=/^\d+$/.test(n);r[e]=o?[]:{}}r=r?.[e]}return t}function jt(t,e){const n=zt(e);if(0===n.length)return t;let i=t;if(i)for(let t=0;t<n.length;t++){const e=n[t];if(t===n.length-1){delete i[e];break}if(i&&(void 0===i?.[e]||"object"!=typeof i?.[e]||null===i?.[e])){const r=n[t+1],o=/^\d+$/.test(r);i[e]=o?[]:{}}i=i?.[e]}return t}const Wt=t=>vt(t,{decimalPlaces:4});function Dt(t,e){const n={},i={},r={type:"modifyMaterial",time:Date.now(),content:{method:"modifyMaterial",id:t.id,before:null,after:null}},{xRatio:o,yRatio:a,maxRatio:s}=e,c=(o+a)/2,{strokeWidth:l,cornerRadius:h,strokeDasharray:f,shadowOffsetX:u,shadowOffsetY:d,shadowBlur:y}=t;if("number"==typeof l)t.strokeWidth=Wt(l*c),n.strokeWidth=l,i.strokeWidth=t.strokeWidth;else if(Array.isArray(t.strokeWidth)){const e=l;t.strokeWidth=[Wt(e[0]*a),Wt(e[1]*o),Wt(e[2]*a),Wt(e[3]*o)],n.strokeWidth=[...e],i.strokeWidth=[...l]}if("number"==typeof h)t.cornerRadius=Wt(h*c),n.cornerRadius=h,i.cornerRadius=t.cornerRadius;else if(Array.isArray(t.cornerRadius)){const e=h;t.cornerRadius=[e[0]*o,e[1]*o,e[2]*a,e[3]*a],n.cornerRadius=[...e],i.cornerRadius=[...h]}return Array.isArray(f)&&(f.forEach((e,n)=>{t.strokeDasharray[n]=Wt(e*s)}),n.strokeDasharray=[...f],i.strokeDasharray=[...t.strokeDasharray]),"number"==typeof u&&(t.shadowOffsetX=Wt(u*s),n.shadowOffsetX=u,i.shadowOffsetX=t.shadowOffsetX),"number"==typeof d&&(t.shadowOffsetY=Wt(d*s),n.shadowOffsetY=d,i.shadowOffsetY=t.shadowOffsetY),"number"==typeof y&&(t.shadowBlur=Wt(y*s),n.shadowBlur=y,i.shadowBlur=t.shadowBlur),r.content.before=It(n),r.content.after=It(i),r}function Ft(t,e,n){const{type:i,id:r}=t,o=function(t,e){const{xRatio:n,yRatio:i}=e,{id:r,x:o,y:a,width:s,height:c}=t;t.x=Wt(o*n),t.y=Wt(a*i),t.width=Wt(s*n),t.height=Wt(c*i);const l={type:"modifyMaterial",time:Date.now(),content:{method:"modifyMaterial",id:r,before:{x:o,y:a,width:s,height:c},after:{x:t.x,y:t.y,width:t.width,height:t.height}}},h=Dt(t,e);return l.content.before={...l.content.before,...h.content.before},l.content.after={...l.content.after,...h.content.after},l}(t,e),a={...o.content.before,id:r},s={...o.content.after,id:r};if(n?.content.before.push(a),n?.content.after.push(s),"circle"===i);else if("text"===i){const n=function(t,e){const{minRatio:n,maxRatio:i}=e,{fontSize:r,lineHeight:o}=t,a=(n+i)/2,s={},c={};return r&&r>0&&(t.fontSize=Wt(r*a),s.fontSize=r,c.fontSize=t.fontSize),o&&o>0&&(t.lineHeight=Wt(o*a),s.lineHeight=o,c.lineHeight=t.lineHeight),{type:"modifyMaterial",time:Date.now(),content:{method:"modifyMaterial",id:t.id,before:s,after:c}}}(t,e);Object.keys(n.content.before||{}).forEach(t=>{a[t]=n.content.before?.[t]}),Object.keys(n.content.after||{}).forEach(t=>{s[t]=n.content.after?.[t]})}else"image"===i||"svgCode"===i||"foreignObject"===i||"path"===i||"group"===i&&Array.isArray(t.children)&&t.children.forEach(t=>{Ft(t,e,n)})}function Vt(t,e,n){const i={type:"resizeMaterials",time:Date.now(),content:{method:"modifyMaterials",before:[],after:[]}},r=t.id,o=t.x,a=t.y,s=t.width,c=t.height,l=f.number(e.x)?e.x:t.x,h=f.number(e.y)?e.y:t.y,u=(e.width&&e.width>0?e.width:t.width)||0,d=(e.height&&e.height>0?e.height:t.height)||0,y={id:r,x:o,y:a,width:s,height:c},p={id:r,x:l,y:h,width:u,height:d};if("deepResize"===n?.resizeEffect){i.content.before.push(y),i.content.after.push(p);const e=u/t.width,n=d/t.height;if(e===n&&1===e)return i;const r=Math.min(e,n),o=Math.max(e,n);t.width=u,t.height=d;const a={xRatio:e,yRatio:n,minRatio:r,maxRatio:o};"group"===t.type&&Array.isArray(t.children)&&t.children.forEach(t=>{Ft(t,a,i)});const s=Dt(t,a);return Object.keys(s.content.before||{}).forEach(t=>{y[t]=s.content.before?.[t]}),Object.keys(s.content.after||{}).forEach(t=>{p[t]=s.content.after?.[t]}),i}if("fixed"===n?.resizeEffect){i.content.before.push(y),i.content.after.push(p);const e=l-t.x,n=h-t.y,r=u-t.width;return function(t,e,n){if("group"!==t.type||!Array.isArray(t.children))return;const{moveX:i,moveY:r,moveH:o,moveW:a}=e;let s=0,c=0,l=!1;0===i&&0===r||0===o&&0===a||(l=!0,s=-i,c=-r),!0===l&&t.children.forEach(t=>{const{id:e,x:i,y:r}=t,o=i+s,a=r+c,l={id:e,x:i,y:r},h={id:e,x:o,y:a};t.x=o,t.y=a,n?.content.before.push(l),n?.content.after.push(h)})}(t,{moveX:e,moveY:n,moveH:d-t.height,moveW:r},i),t.width=u,t.height=d,t.x=l,t.y=h,i}return t.width=u,t.height=d,t.x=l,t.y=h,i.content.before.push(y),i.content.after.push(p),i}function Bt(t,e,n){let i=!1;if(1===e.length){const r=e[0];n.splice(r,0,t),i=!0}else if(e.length>1){let r=n;for(let n=0;n<e.length;n++){const o=r[e[n]];if(n===e.length-1){const o=e[n];r.splice(o,0,t),i=!0}else{if(!(n<e.length-1&&"group"===o.type))break;r=o.children}}}return i}function Ht(t,e){let n=!1;if(1===t.length){const i=t[0];e.splice(i,1),n=!0}else if(t.length>1){let i=e;for(let e=0;e<t.length;e++){const r=i[t[e]];if(e===t.length-1){const r=t[e];i.splice(r,1),n=!0}else{if(!(e<t.length-1&&"group"===r.type))break;i=r.children}}}return n}function Nt(t,e,n){const i=It(e),r=["id","type"],o=Object.keys(i);if(o.forEach(e=>{if(!r.includes(e)){const n=i[e];jt(t,e),void 0!==n&&Tt(t,e,n)}}),!0===n?.onlyUpdateContent){const e=It(t);Object.keys(e).forEach(e=>{r.includes(e)||o.includes(e)||jt(t,e)})}return t.fill&&(t.fill=function(t){if(Array.isArray(t?.stops)){const e=[],n=t?.stops;for(let t=n.length-1;t>=0;t--){const i=n[t];i.color&&i.offset>=0||e.push(t)}e.forEach(t=>{n.splice(t,1)})}return t}(t.fill)),t}const Xt=["-apple-system",'"system-ui"',' "Segoe UI"'," Roboto",'"Helvetica Neue"',"Arial",'"Noto Sans"'," sans-serif"];function Ut(t){const e=[...t.from],n=[...t.to];if(0===e.length||0===n.length)return null;if(e.length<=n.length)for(let t=0;t<e.length;t++)if(n[t]!==e[t]);else if(t===e.length-1)return null;let i=null;if(e.length>=1&&n.length>=1){if(e.length<=n.length)if(1===e.length)e[0]<n[0]&&(i="up-down");else for(let t=0;t<e.length&&e[t]===n[t];t++)if(e.length===e.length-1){i="up-down";break}if(e.length>=n.length)if(1===n.length)n[0]<e[0]&&(i="down-up");else for(let t=0;t<n.length&&(t===n.length-1&&n[t]<e[t]&&(i="down-up"),e[t]===n[t]);t++);}const r=e.length-1,o=n.length-1;return"up-down"===i&&r>=0?n[r]-=1:"down-up"===i&&o>=0&&(e[o]+=1),{from:e,to:n}}function Yt(t){let e=1/0,n=1/0,i=-1/0,r=-1/0,o={x:0,y:0},a={x:0,y:0},s=null;const c=t=>{e=Math.min(e,t.x),n=Math.min(n,t.y),i=Math.max(i,t.x),r=Math.max(r,t.y)};for(const e of t){const{type:t,params:n}=e,i=t===t.toLowerCase();switch(t.toLowerCase()){case"m":if(n.length>=2)for(let t=0;t<n.length;t+=2){let e=n[t],r=n[t+1];i&&(e+=o.x,r+=o.y),0===t&&(a={x:e,y:r}),o={x:e,y:r},c(o)}s=null;break;case"l":if(n.length>=2)for(let t=0;t<n.length;t+=2){let e=n[t],r=n[t+1];i&&(e+=o.x,r+=o.y),o={x:e,y:r},c(o)}s=null;break;case"h":for(let t=0;t<n.length;t++){let e=n[t];i&&(e+=o.x),o={x:e,y:o.y},c(o)}s=null;break;case"v":for(let t=0;t<n.length;t++){let e=n[t];i&&(e+=o.y),o={x:o.x,y:e},c(o)}s=null;break;case"c":if(n.length>=6)for(let t=0;t<n.length;t+=6){let e=n[t],r=n[t+1],a=n[t+2],l=n[t+3],h=n[t+4],f=n[t+5];i&&(e+=o.x,r+=o.y,a+=o.x,l+=o.y,h+=o.x,f+=o.y),s={x:a,y:l};Gt(o.x,o.y,e,r,a,l,h,f).forEach(c),c({x:h,y:f}),o={x:h,y:f}}break;case"s":if(n.length>=4)for(let t=0;t<n.length;t+=4){let e=n[t],r=n[t+1],a=n[t+2],l=n[t+3];const h=s?2*o.x-s.x:o.x,f=s?2*o.y-s.y:o.y;i&&(e+=o.x,r+=o.y,a+=o.x,l+=o.y),s={x:e,y:r};Gt(o.x,o.y,h,f,e,r,a,l).forEach(c),c({x:a,y:l}),o={x:a,y:l}}break;case"q":if(n.length>=4)for(let t=0;t<n.length;t+=4){let e=n[t],r=n[t+1],a=n[t+2],l=n[t+3];i&&(e+=o.x,r+=o.y,a+=o.x,l+=o.y),s={x:e,y:r};Qt(o.x,o.y,e,r,a,l).forEach(c),c({x:a,y:l}),o={x:a,y:l}}break;case"t":if(n.length>=2)for(let t=0;t<n.length;t+=2){let e=n[t],r=n[t+1];const a=s?2*o.x-s.x:o.x,l=s?2*o.y-s.y:o.y;i&&(e+=o.x,r+=o.y),s={x:a,y:l};Qt(o.x,o.y,a,l,e,r).forEach(c),c({x:e,y:r}),o={x:e,y:r}}break;case"a":if(n.length>=7)for(let t=0;t<n.length;t+=7){const e=Math.abs(n[t]),r=Math.abs(n[t+1]),a=n[t+2],l=n[t+3],h=n[t+4];let f=n[t+5],u=n[t+6];i&&(f+=o.x,u+=o.y);qt(o.x,o.y,e,r,a,l,h,f,u).forEach(c),o={x:f,y:u},s=null}break;case"z":o={...a},c(o),s=null}}e===1/0&&(e=n=i=r=0);return{minX:e,minY:n,maxX:i,maxY:r,width:i-e,height:r-n,start:{x:e,y:n},end:{x:i,y:r}}}function Gt(t,e,n,i,r,o,a,s){const c=[];c.push({x:t,y:e}),c.push({x:a,y:s});const l=Zt(3*(3*n-t-3*r+a),6*(t-2*n+r),3*(n-t));for(const h of l)if(h>0&&h<1){const l=Jt(h,t,n,r,a),f=Jt(h,e,i,o,s);c.push({x:l,y:f})}const h=Zt(3*(3*i-e-3*o+s),6*(e-2*i+o),3*(i-e));for(const l of h)if(l>0&&l<1){const h=Jt(l,t,n,r,a),f=Jt(l,e,i,o,s);c.push({x:h,y:f})}return c}function Qt(t,e,n,i,r,o){const a=[];a.push({x:t,y:e}),a.push({x:r,y:o});const s=t-2*n+r;if(0!==s){const c=-(2*(n-t))/(2*s);if(c>0&&c<1){const s=_t(c,t,n,r),l=_t(c,e,i,o);a.push({x:s,y:l})}}const c=e-2*i+o;if(0!==c){const s=-(2*(i-e))/(2*c);if(s>0&&s<1){const c=_t(s,t,n,r),l=_t(s,e,i,o);a.push({x:c,y:l})}}return a}function qt(t,e,n,i,r,o,a,s,c){const l=[],h=r*Math.PI/180,f=Math.cos(h),u=Math.sin(h),d=(t+s)/2,y=(e+c)/2,p=(t-s)/2,g=(e-c)/2,x=f*p+u*g,m=-u*p+f*g;let b=n,w=i;const M=x*x,v=m*m,P=M/(n*n)+v/(i*i);P>1&&(b=Math.sqrt(P)*n,w=Math.sqrt(P)*i);const R=o===a?-1:1,$=Math.max(0,b*b*w*w-b*b*v-w*w*M),k=b*b*v+w*w*M;let S=R*Math.sqrt($/k);isNaN(S)&&(S=0);const C=S*(b*m/w),A=S*(-w*x/b),L=f*C-u*A+d,I=u*C+f*A+y,E=Math.atan2((m-A)/w,(x-C)/b);let O=Math.atan2((-m-A)/w,(-x-C)/b)-E;0===a&&O>0?O-=2*Math.PI:1===a&&O<0&&(O+=2*Math.PI);for(let t=0;t<=100;t++){const e=E+t/100*O,n=L+b*Math.cos(e)*f-w*Math.sin(e)*u,i=I+b*Math.cos(e)*u+w*Math.sin(e)*f;l.push({x:n,y:i})}return l}function Zt(t,e,n){const i=[];if(0===t){if(0!==e){const t=-n/e;t>=0&&t<=1&&i.push(t)}return i}const r=e*e-4*t*n;if(r>0){const n=Math.sqrt(r),o=(-e+n)/(2*t),a=(-e-n)/(2*t);o>=0&&o<=1&&i.push(o),a>=0&&a<=1&&i.push(a)}else if(0===r){const n=-e/(2*t);n>=0&&n<=1&&i.push(n)}return i}function Jt(t,e,n,i,r){const o=1-t;return o*o*o*e+3*o*o*t*n+3*o*t*t*i+t*t*t*r}function _t(t,e,n,i){const r=1-t;return r*r*e+2*r*t*n+t*t*i}const Kt=()=>Math.random().toString(36).substring(2);function te(){return`${Kt()}${Kt()}`.substring(0,16)}function ee(t,e,n){const{type:i}=t,r=[...t.params],o=t.id;let a={id:o};if(t.start&&t.end){const i={...t.start},r={...t.end};i.x+=e,i.y+=n,r.x+=e,r.y+=n,a={id:o,start:i,end:r}}switch(i){case"M":case"L":case"T":return r[0]+=e,r[1]+=n,{type:i,params:r,...a};case"H":return r[0]+=e,{type:i,params:r,...a};case"V":return r[0]+=n,{type:i,params:r,...a};case"C":return r[0]+=e,r[1]+=n,r[2]+=e,r[3]+=n,r[4]+=e,r[5]+=n,{type:i,params:r,...a};case"S":case"Q":return r[0]+=e,r[1]+=n,r[2]+=e,r[3]+=n,{type:i,params:r,...a};case"A":return r[5]+=e,r[6]+=n,{type:i,params:r,...a};default:return{type:i,params:r,...a}}}function ne(t,e,n){const i=[];return t.forEach(t=>{const r=ee(t,e,n);i.push(r)}),i}function ie(t){const e=[];let n={x:0,y:0},i={x:0,y:0},r=null;for(const o of t){const t=o.type,a=o.params,s=t===t.toLowerCase(),c=t.toUpperCase(),l=o.id;switch(c){case"M":{const[t,o]=a,c=s?{x:n.x+t,y:n.y+o}:{x:t,y:o};e.push({id:l,type:"M",params:[c.x,c.y],start:{x:t,y:o},end:{x:t,y:o}}),n=c,i=c,r=null;break}case"L":{const[t,i]=a,o=s?{x:n.x+t,y:n.y+i}:{x:t,y:i};e.push({id:l,type:"L",params:[o.x,o.y],start:{...n},end:{...o}}),n=o,r=null;break}case"H":{const[t]=a,i=s?{x:n.x+t,y:n.y}:{x:t,y:n.y};e.push({id:l,type:"L",params:[i.x,i.y],start:{...n},end:{...i}}),n=i,r=null;break}case"V":{const[t]=a,i=s?{x:n.x,y:n.y+t}:{x:n.x,y:t};e.push({id:l,type:"L",params:[i.x,i.y],start:{...n},end:{...i}}),n=i,r=null;break}case"C":{const[t,i,o,c,h,f]=a,u=s?{x:n.x+t,y:n.y+i}:{x:t,y:i},d=s?{x:n.x+o,y:n.y+c}:{x:o,y:c},y=s?{x:n.x+h,y:n.y+f}:{x:h,y:f};e.push({id:l,type:"C",params:[u.x,u.y,d.x,d.y,y.x,y.y],start:{...n},end:{...y}}),n=y,r=d;break}case"S":{const[t,i,o,c]=a,h=r?{x:2*n.x-r.x,y:2*n.y-r.y}:n,f=s?{x:n.x+t,y:n.y+i}:{x:t,y:i},u=s?{x:n.x+o,y:n.y+c}:{x:o,y:c};e.push({id:l,type:"C",params:[h.x,h.y,f.x,f.y,u.x,u.y],start:{...n},end:{...u}}),n=u,r=f;break}case"Q":{const[t,i,o,c]=a,h=s?{x:n.x+t,y:n.y+i}:{x:t,y:i},f=s?{x:n.x+o,y:n.y+c}:{x:o,y:c};e.push({id:l,type:"C",params:[n.x+2/3*(h.x-n.x),n.y+2/3*(h.y-n.y),f.x+2/3*(h.x-f.x),f.y+2/3*(h.y-f.y),f.x,f.y],start:{...n},end:{...f}}),n=f,r=h;break}case"T":{const[t,i]=a,o=s?{x:n.x+t,y:n.y+i}:{x:t,y:i},c=r?{x:2*n.x-r.x,y:2*n.y-r.y}:n;e.push({id:l,type:"C",params:[n.x+2/3*(c.x-n.x),n.y+2/3*(c.y-n.y),o.x+2/3*(c.x-o.x),o.y+2/3*(c.y-o.y),o.x,o.y],start:{...n},end:{...o}}),n=o,r=c;break}case"A":{const[t,i,o,c,h,f,u]=a,d=s?{x:n.x+f,y:n.y+u}:{x:f,y:u};e.push({id:l,type:"A",params:[t,i,o,c,h,d.x,d.y],start:{...n},end:{...d}}),n=d,r=null;break}case"Z":e.push({id:l,type:"Z",params:[],start:{...n},end:{...i}}),n=i,r=null;break;default:throw new Error(`Unsupported command: ${t}`)}}return e}const re={className:"class"},oe=["width","height","left","right","top","bottom","margin","marginLeft","marginRight","marginTop","marginBottom","padding","paddingLeft","paddingRight","paddingTop","paddingBottom"];function ae(t,e){e.forEach(e=>{if(!e)return;e.trim().split(" ").forEach(e=>{e&&!t.classList.contains(e)&&t.classList.add(e)})})}function se(t,e){return Object.keys(e).forEach(n=>{const i=e[n];t.style[n]=((t,e)=>"number"==typeof e&&oe.includes(t)?`${e}px`:e)(n,i)}),t}function ce(t,e,n){const{children:i,...r}=e||{},o=n||i;return function(t,e){Object.entries(e).forEach(([e,n])=>{const i=re[e]?re[e]:e,r=i.replace(/([A-Z])/g,"-$1").toLowerCase(),o=n;if("style"===i)f.json(n)?se(t,n):"string"==typeof n&&t.setAttribute(r,n);else if("class"===i&&"string"==typeof n)ae(t,n.split(" "));else{let e=o;null==e&&(e=""),t.setAttribute(r,String(e))}})}(t,r||{}),Array.isArray(o)?o?.forEach(e=>{(e instanceof Element||"string"==typeof e)&&t.append(e)}):(o instanceof Element||"string"==typeof o)&&t.append(o),t}function le(t){return t.replace(/<(script|iframe|object|embed)\b[^<]*(?:(?!<\/\1>)<[^<]*)*<\/\1>/gi,"")}const he=(t,e,n)=>{let i=t;const r=Object.keys(n),o=()=>{if(!i)return!1;for(let t=0;t<r.length;t++){const e=r[t],o=n[e];if("string"==typeof e&&e&&"string"==typeof o&&o){if("className"===e&&i?.classList.contains(o))continue;if(i.getAttribute(e)===o)continue;return!1}if("string"==typeof e&&e&&"boolean"==typeof o){if(i.hasAttribute(e)&&!0===o)continue;return!1}}return!0};for(;i;){if(o())return i;if(e===i)return null;if(!e.contains(i))return null;i=i.parentElement}return null};const fe=["width","height","left","right","top","bottom","margin","marginLeft","marginRight","marginTop","marginBottom","padding","paddingLeft","paddingRight","paddingTop","paddingBottom"],ue=(t,e)=>fe.includes(t)?`${e}px`:e;function de(t){return t.replace(/[A-Z]/g,t=>"-"+t.toLowerCase())}function ye(t,e){const n=[],i=[];for(const r in t){let o=t[r];if("number"==typeof o&&(o=ue(r,o)),r.startsWith("@"))i.push(`${r} { ${ye(o,e)} }`);else if(r.startsWith("&")||r.startsWith(".")||r.startsWith("#")){const t=r.startsWith("&")?r.replace("&",e):`${e} ${r}`;i.push(ye(o,t))}else n.push(`${de(r)}: ${o};`)}return[n.length?`${e} { ${n.join(" ")} }`:"",...i].filter(Boolean).join("\n")}const pe="data-idraw-style-id",ge={};function xe(t){const e=/([\w-]+)|\[(\d+)\]/g,n=[];let i;for(;null!==(i=e.exec(t));){const t=i[1]||i[2];t&&n.push(t)}return n}function me(t,e,n){let i=t;for(let t=0;t<e.length;t++){const r=e[t],o=be(r),a=t===e.length-1;try{o?we(i,r):Me(i,r)}catch(n){throw new Error(`Structure conflict at path '${e.slice(0,t+1).join(".")}': ${n.message}`)}a?Pe(i,r,n):i=ve(i,r,e[t+1])}}function be(t){return/^\d+$/.test(t)}function we(t,e){if(!Array.isArray(t))throw new Error("Expected array but found "+typeof t);const n=Number(e);n>t.length&&(t.length=n+1)}function Me(t,e){if(Array.isArray(t))throw new Error(`Cannot create object property '${e}' on array`);if("object"!=typeof t||null===t)throw new Error(`Invalid structure for property '${e}'`)}function ve(t,e,n){const i=!!n&&be(n);if(Array.isArray(t)){const n=Number(e);return t[n]||(t[n]=i?[]:{}),t[n]}return t[e]||(t[e]=i?[]:{}),t[e]}function Pe(t,e,n){if(Array.isArray(t)){const i=Number(e);i>=t.length&&(t.length=i+1),t[i]=n}else t[e]=n}const Re={svg:"group",g:"group"},$e=["x","y","width","height","angle","id","name","transform","opacity","display","visibility","overflow","fill","fillOpacity","fillRule","stroke","strokeWidth","strokeOpacity","strokeLinecap","strokeLinejoin","strokeDasharray","strokeDashoffset","strokeMiterlimit","fontSize","fontFamily","fontWeight","fontStyle","textAnchor","textDecoration","letterSpacing","wordSpacing","writingMode","textAlign","verticalAlign","cornerRadius","commands","children","rx","ry","cx","cy","r"],ke=["strokeDasharray"],Se=["x","y","width","height","opacity","fillOpacity","strokeWidth","strokeOpacity","strokeDashoffset","fontSize","fontWeight","rx","ry","cx","cy","r"];function Ce(t){return t.replace(/-([a-z])/g,(t,e)=>e.toUpperCase())}function Ae(t,e,n){t[e]=function(t,e){return Se.includes(t)&&/^[0-9.]{0,}$/.test(e)?parseFloat(e):ke.includes(t)?e.match(/[0-9.]{0,}/g)?.filter(t=>!!t).map(t=>parseFloat(t)):e}(e,n)}function Le(t,e){for(let n=0;n<t.attributes.length;n++){const i=t.attributes[n],r=Ce(i.name);$e.includes(r)&&Ae(e,r,i.value)}e.id||(e.id=r());const n=t.getAttribute("style");n&&function(t,e){const n=t.split(";");for(const t of n){const[n,i]=t.split(":").map(t=>t.trim());n&&i&&Ae(e,Ce(n),i)}}(n,e),function(t,e){const n=t.getAttribute("transform");n&&Ae(e,"transform",n)}(t,e)}function Ie(t){const e=t.tagName,n={type:Re[e]||e,children:[]};if("svg"===e){const e=(t.getAttribute("viewBox")||"").split(" "),i=[];e.length&&e.forEach(t=>{const e=parseFloat(t);(e>=0||e<0)&&i.push(e)}),i.length>=4&&(n.x=i[0],n.y=i[1],n.width=i[2],n.height=i[3])}Le(t,n);const i=function(t){let e="";for(const n of Array.from(t.childNodes))n.nodeType===Node.TEXT_NODE&&(e+=n.textContent?.trim()||"");return e}(t);i&&(n.text=i),n.children=[];for(let e=0;e<t.children.length;e++){const i=Ie(t.children[e]);i&&n.children.push(i)}return n}function Ee(t){return ze(t)}const Oe={group:"g"};function ze(t,e="",n=0){const i=Oe[t.type]||t.type,r=function(t){const e=["type","children","textContent"],n=[];for(const i in t){if(e.includes(i))continue;const r=t[i];if(null!=r){const t=Te(i);n.push(`${t}="${je(String(r))}"`)}}return n.length>0?" "+n.join(" "):""}(t),o=t.children||[],a=t.text||"";if(["circle","rect","path","line","polygon","polyline","ellipse","use"].includes(i)&&0===o.length&&!a)return`${e}<${i}${r} />`;let s=`${e}<${i}${r}`;if(0!==o.length||a){if(s+=">",a&&(s+=a.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")),o.length>0){const t=e+" ";s+="\n",s+=o.map(e=>ze(e,t,n+1)).join("\n"),s+=`\n${e}`}s+=`</${i}>`}else s+=`></${i}>`;return s}function Te(t){return t.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g,"$1-$2").toLowerCase()}function je(t){return t.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/'/g,"&apos;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}return t.ATTR_VALID_WATCH="data-idraw-valid-watch",t.Context2D=C,t.EventEmitter=class{#n;constructor(){this.#n=new Map}on(t,e){if(this.#n.has(t)){const n=this.#n.get(t)||[];n?.push(e),this.#n.set(t,n)}else this.#n.set(t,[e])}off(t,e){if(this.#n.has(t)){const n=this.#n.get(t);if(Array.isArray(n))for(let t=0;t<n?.length;t++)if(n[t]===e){n.splice(t,1);break}this.#n.set(t,n||[])}}trigger(t,e){const n=this.#n.get(t);return!!Array.isArray(n)&&(n.forEach(t=>{t(e)}),!0)}has(t){if(this.#n.has(t)){const e=this.#n.get(t);if(Array.isArray(e)&&e.length>0)return!0}return!1}destroy(){this.clear()}clear(){this.#n.clear()}},t.Store=class{#i;#r;#o;constructor(t){this.#r=c(t.defaultStorage),this.#i=this.#a(),this.#o=t.defaultStatic||{}}set(t,e){this.#i[t]=e}get(t){return this.#i[t]}setStatic(t,e){this.#o[t]=e}getStatic(t){return this.#o[t]}getSnapshot(t){return!0===t?.deepClone?c(this.#i):{...this.#i}}clear(){this.#i=this.#a()}destroy(){this.#i=null,this.#o=null}#a(){return c(this.#r)}},t.addClassName=ae,t.assembleHTMLElement=ce,t.boundingInfoToRangeBoundingInfo=function(t){const e=Math.max(t.topLeft.x,t.topRight.x,t.bottomRight.x,t.bottomLeft.x),n=Math.max(t.topLeft.y,t.topRight.y,t.bottomRight.y,t.bottomLeft.y),i=Math.min(t.topLeft.x,t.topRight.x,t.bottomRight.x,t.bottomLeft.x),r=Math.min(t.topLeft.y,t.topRight.y,t.bottomRight.y,t.bottomLeft.y),o={x:t.center.x,y:t.center.y},a={x:i,y:r},s={x:e,y:r},c={x:e,y:n},l={x:i,y:n},h=E(a,s),f=E(l,c),u=E(a,l);return{center:o,topLeft:a,topRight:s,bottomLeft:l,bottomRight:c,top:h,right:E(s,c),left:u,bottom:f}},t.bubbleHTMLElement=he,t.calcDistance=I,t.calcLayoutSizeController=function(t,e){const{controllerSize:n,viewScaleInfo:i}=e,r=n&&n>0?n:8,{x:o,y:a,width:s,height:c}=st(t,{viewScaleInfo:i}),l=B({x:o,y:a,width:s,height:c}),h={x:l.x,y:a},f={x:o+s,y:l.y},u={x:l.x,y:a+c},d={x:o,y:l.y},y={x:o,y:a},p={x:o+s,y:a},g={x:o+s,y:a+c},x={x:o,y:a+c},m=ut(h,{size:r,angle:0}),b=ut(f,{size:r,angle:0}),w=ut(u,{size:r,angle:0}),M=ut(d,{size:r,angle:0}),v=ut(y,{size:r,angle:0}),P=ut(p,{size:r,angle:0}),R=ut(x,{size:r,angle:0}),$=ut(g,{size:r,angle:0}),k=it(v),S=it(P),C=it(R),A=it($),L=[k[1],S[0],S[3],k[2]],I=[S[3],S[2],A[1],A[0]],E=[C[1],A[0],A[3],C[2]],O=[k[3],k[2],C[1],C[0]],z=it(m),T=it(b),j=it(w);return{left:{type:"left",vertexes:O,center:d,size:r},right:{type:"right",vertexes:I,center:f,size:r},top:{type:"top",vertexes:L,center:h,size:r},bottom:{type:"bottom",vertexes:E,center:u,size:r},topLeft:{type:"top-left",vertexes:k,center:y,size:r},topRight:{type:"top-right",vertexes:S,center:p,size:r},bottomLeft:{type:"bottom-left",vertexes:C,center:x,size:r},bottomRight:{type:"bottom-right",vertexes:A,center:g,size:r},leftMiddle:{type:"left-middle",vertexes:it(M),center:d,size:r},rightMiddle:{type:"right-middle",vertexes:T,center:f,size:r},topMiddle:{type:"top-middle",vertexes:z,center:h,size:r},bottomMiddle:{type:"bottom-middle",vertexes:j,center:u,size:r}}},t.calcMaterialBoundingInfo=ft,t.calcMaterialCenter=B,t.calcMaterialCenterFromVertexes=H,t.calcMaterialListSize=Z,t.calcMaterialQueueVertexesQueueInGroup=rt,t.calcMaterialSizeController=function(t,e){const{groupQueue:n,controllerSize:i,viewScaleInfo:o,rotateControllerSize:a,rotateControllerPosition:s}=e,c=(i&&i>0?i:8)/o.scale,{x:l,y:h,width:f,height:u,angle:d=0}=t,y=a,p=s,g=[{id:r(),x:l,y:h,width:f,height:u,angle:d,type:"group",children:[]},...n];let x=0;g.forEach(({angle:t=0})=>{x+=t});const m=at(t,{groupQueue:n}),b=at({x:l,y:h-(p+y/2)/o.scale,height:u+(2*p+y)/o.scale,width:f,angle:d},{groupQueue:[...n]}),w=E(m[0],m[1]),M=E(m[1],m[2]),v=E(m[2],m[3]),P=E(m[3],m[0]),R=m[0],$=m[1],k=m[2],S=m[3],C=ut(w,{size:c,angle:x}),A=ut(M,{size:c,angle:x}),L=ut(v,{size:c,angle:x}),I=ut(P,{size:c,angle:x}),O=ut(R,{size:c,angle:x}),z=ut($,{size:c,angle:x}),T=ut(S,{size:c,angle:x}),j=ut(k,{size:c,angle:x}),W=it(O),D=it(z),F=it(T),V=it(j),H=[W[1],D[0],D[3],W[2]],N=[D[3],D[2],V[1],V[0]],X=[F[1],V[0],V[3],F[2]],U=[W[3],W[2],F[1],F[0]],Y=it(C),G=it(A),Q=it(L),q=it(I),Z=E(b[0],b[1]),J=it(ut(Z,{size:1.1*a/o.scale,angle:x}));return{originalMaterialCenter:B(t),originalMaterialSize:{...t},materialWrapper:m,left:{type:"left",vertexes:U,center:P,size:c},right:{type:"right",vertexes:N,center:M,size:c},top:{type:"top",vertexes:H,center:w,size:c},bottom:{type:"bottom",vertexes:X,center:v,size:c},topLeft:{type:"top-left",vertexes:W,center:R,size:c},topRight:{type:"top-right",vertexes:D,center:$,size:c},bottomLeft:{type:"bottom-left",vertexes:F,center:S,size:c},bottomRight:{type:"bottom-right",vertexes:V,center:k,size:c},leftMiddle:{type:"left-middle",vertexes:q,center:P,size:c},rightMiddle:{type:"right-middle",vertexes:G,center:M,size:c},topMiddle:{type:"top-middle",vertexes:Y,center:w,size:c},bottomMiddle:{type:"bottom-middle",vertexes:Q,center:v,size:c},rotate:{type:"rotate",vertexes:J,center:Z,size:a}}},t.calcMaterialVertexesInGroup=at,t.calcMaterialVertexesQueueInGroup=ot,t.calcMaterialViewBoundingInfo=function(t,e){const{groupQueue:n,viewScaleInfo:i,range:r}=e,o=ft(t,{groupQueue:n}),{center:a,top:s,bottom:c,left:l,right:h,topLeft:f,topRight:u,bottomLeft:d,bottomRight:y}=o,p={center:ct(a,{viewScaleInfo:i}),topLeft:ct(f,{viewScaleInfo:i}),topRight:ct(u,{viewScaleInfo:i}),bottomLeft:ct(d,{viewScaleInfo:i}),bottomRight:ct(y,{viewScaleInfo:i}),top:ct(s,{viewScaleInfo:i}),right:ct(h,{viewScaleInfo:i}),left:ct(l,{viewScaleInfo:i}),bottom:ct(c,{viewScaleInfo:i})};if(!0===r){const t=Math.max(p.topLeft.x,p.topRight.x,p.bottomRight.x,p.bottomLeft.x),e=Math.max(p.topLeft.y,p.topRight.y,p.bottomRight.y,p.bottomLeft.y),n=Math.min(p.topLeft.x,p.topRight.x,p.bottomRight.x,p.bottomLeft.x),i=Math.min(p.topLeft.y,p.topRight.y,p.bottomRight.y,p.bottomLeft.y),r={x:p.center.x,y:p.center.y},o={x:n,y:i},a={x:t,y:i},s={x:t,y:e},c={x:n,y:e},l=E(o,a),h=E(c,s),f=E(o,c);return{center:r,topLeft:o,topRight:a,bottomLeft:c,bottomRight:s,top:l,right:E(a,s),left:f,bottom:h}}return p},t.calcMaterialsContextSize=J,t.calcMaterialsViewInfo=function(t,e,n){const i=J(t,{viewWidth:e.width,viewHeight:e.height,extend:n?.extend});return!0===n?.extend&&(i.contextWidth=Math.max(i.contextWidth,e.contextWidth),i.contextHeight=Math.max(i.contextHeight,e.contextHeight)),{contextSize:i}},t.calcPathCommondsBoundingBox=Yt,t.calcPointFromView=function(t,e){const{viewScaleInfo:n}=e,{x:i,y:r}=t,{scale:o,offsetTop:a,offsetLeft:s}=n;return{x:(i-s)/o,y:(r-a)/o}},t.calcPointMoveMaterialInGroup=function(t,e,n){let i=e.x-t.x,r=e.y-t.y;const o=[];if(n.forEach(t=>{const{x:e,y:n,width:i,height:r,angle:a=0}=t;o.push({x:e,y:n,width:i,height:r,angle:0-a})}),n?.length>0){const n=U(t,o),a=U(e,o);i=a.x-n.x,r=a.y-n.y}return{moveX:i,moveY:r}},t.calcRadian=function(t,e,n){const i=N(t,e),r=N(t,n);return null!==r&&null!==i?r-i:0},t.calcResultMovePosition=Ut,t.calcRevertMovePosition=function(t){const e=Ut(t);return e?{from:[...e.to],to:[...e.from]}:e},t.calcSVGPathBoundingBox=function(t){return Yt(pt(t))},t.calcViewCenter=function(t){let e=0,n=0;if(t){const{viewScaleInfo:i,viewSizeInfo:r}=t,{offsetLeft:o,offsetTop:a,scale:s}=i,{width:c,height:l}=r;e=0-o+c/s/2,n=0-a+l/s/2}return{x:e,y:n}},t.calcViewCenterContent=function(t,e){let n=0,i=0,r=1,o=t?.materials?.[0]?.x||0,a=t?.materials?.[0]?.y||0,s=t?.materials?.[0]?.width||0,c=t?.materials?.[0]?.height||0;const{width:l,height:h}=e.viewSizeInfo;if($.layout(t.layout)&&"hidden"===t.layout?.overflow?(o=t.layout.x,a=t.layout.y,s=t.layout.width||0,c=t.layout.height||0):t.materials.forEach(t=>{const e={x:t.x,y:t.y,width:t.width,height:t.height,angle:t.angle};if(e.angle&&(e.angle>0||e.angle<0)){const t=G(e);if(4===t.length){const n=[t[0].x,t[1].x,t[2].x,t[3].x],i=[t[0].y,t[1].y,t[2].y,t[3].y];e.x=Math.min(...n),e.y=Math.min(...i),e.width=Math.abs(Math.max(...n)-Math.min(...n)),e.height=Math.abs(Math.max(...i)-Math.min(...i))}}const n=Math.min(e.x,o),i=Math.min(e.y,a),r=Math.max(e.x+e.width,o+s),l=Math.max(e.y+e.height,a+c);o=n,a=i,s=Math.abs(r-n),c=Math.abs(l-i)}),t?.layout&&$.layout(t.layout)){const{x:e,y:n,width:i,height:r}=t.layout;"hidden"===t.layout?.overflow?(o=Math.min(o,e),a=Math.min(a,n),s=Math.min(s,i),c=Math.min(c,r)):(o=Math.min(o,e),a=Math.min(a,n),s=Math.max(s,i),c=Math.max(c,r))}if(s>0&&c>0){const t=vt(l/s,{decimalPlaces:4}),e=vt(h/c,{decimalPlaces:4});r=Math.min(t,e,1),n=(s*r-l)/2/r+o,i=(c*r-h)/2/r+a}return{offsetX:vt(n,{decimalPlaces:0}),offsetY:vt(i,{decimalPlaces:0}),scale:r}},t.calcViewMaterialSize=st,t.calcViewPoint=ct,t.calcViewScaleInfo=function(t,e){const{scale:n,offsetX:i,offsetY:r}=t,{viewSizeInfo:o}=e,{width:a,height:s,contextWidth:c,contextHeight:l}=o,h=0-i*n,f=0-r*n;return{scale:n,offsetLeft:h,offsetTop:f,offsetRight:a-(c*n+h/n),offsetBottom:s-(l*n+f/n)}},t.calcViewVertexes=function(t,e){return[ct(t[0],e),ct(t[1],e),ct(t[2],e),ct(t[3],e)]},t.calcVisiableViewSize=function(t){const e=Z(t.materials);return t.layout&&("hidden"===t.layout?.overflow?(e.x=t.layout.x,e.y=t.layout.y,e.width=t.layout.width,e.height=t.layout.height):(e.x=Math.min(e.x,t.layout.x),e.y=Math.min(e.y,t.layout.y),e.width=Math.max(e.width,t.layout.width),e.height=Math.max(e.height,t.layout.height))),e},t.check=S,t.checkRectIntersect=et,t.colorNameToHex=function(t){const e=t.toLowerCase(),i=n[e];return"string"==typeof i?i:null},t.colorToCSS=function(t){let e="transparent";if("string"==typeof t)e=t;else if(1===t?.stops.length)e=t.stops[0].color;else if("linear-gradient"===t?.type){const n=[];"number"==typeof t.angle?n.push(`${t.angle}deg`):n.push("180deg"),Array.isArray(t.stops)&&t.stops.forEach(t=>{n.push(`${t.color} ${100*t.offset}%`)}),e=`linear-gradient(${n.join(", ")})`}else if("radial-gradient"===t?.type){const n=[];Array.isArray(t.stops)&&t.stops.forEach(t=>{n.push(`${t.color} ${100*t.offset}%`)}),e=`radial-gradient(circle, ${n.join(", ")})`}return e},t.colorToLinearGradientCSS=function(t){let e="transparent";if("string"==typeof t)e=t;else if("radial-gradient"===t?.type||"linear-gradient"===t?.type){const n=[];Array.isArray(t.stops)&&t.stops.length>0&&(t.stops.forEach((e,i)=>{n.push(`${e.color} ${100*e.offset}%`),i===t.stops.length-1&&e.offset<1&&n.push(`${e.color} ${100*e.offset}%`)}),e=`linear-gradient(90deg, ${n.join(", ")})`)}return e},t.compose=function(t){return function(e,n){return function i(r){let o=t[r];r===t.length&&n&&(o=n);if(!o)return Promise.resolve();try{return Promise.resolve(o(e,i.bind(null,r+1)))}catch(t){return Promise.reject(t)}}(0)}},t.compressImage=function(t,e){let n=.5;const i=e?.type||"image/png";return e?.radio&&e?.radio>0&&e?.radio<=1&&(n=e?.radio),new Promise((e,r)=>{const o=new Image;o.addEventListener("load",()=>{const{width:t,height:r}=o,a=t*n,s=r*n;let c=document.createElement("canvas");c.width=a,c.height=s;c.getContext("2d").drawImage(o,0,0,a,s);const l=c.toDataURL(i);c=null,e(l)}),o.addEventListener("error",t=>{r(t)}),o.src=t})},t.convertContext2DCommandsToSVGPath=function(t){const e=[];return t.forEach(t=>{if("moveTo"===t.name)e.push(`M ${t.params.x}, ${t.params.y}`);else if("bezierCurveTo"===t.name)e.push(`C ${t.params.cp1x},${t.params.cp1y} ${t.params.cp2x},${t.params.cp2y} ${t.params.x},${t.params.y}`);else if("ellipse"===t.name){const n=D(t.params),{rx:i,ry:r,xAxisRotation:o,largeArcFlag:a,sweepFlag:s,endPoint:c}=n;e.push(`A ${i} ${r} ${o} ${a} ${s} ${c.x} ${c.y}`)}else"beginPath"===t.name?e.push(""):"closePath"===t.name&&e.push("Z")}),e.join(" ")},t.convertLineToExactCurveCommand=function(t,e){const n=e.x,i=e.y,r=t.x+(n-t.x)/3,o=t.y+(i-t.y)/3,a=t.x+2*(n-t.x)/3,s=t.y+2*(i-t.y)/3;return{id:te(),type:"C",params:[r,o,a,s,n,i]}},t.convertPathCommandsToACLMZ=ie,t.convertPathCommandsToContext2DCommands=W,t.convertPathCommandsToStr=function(t){let e="";return t.forEach(t=>{e+=t.type+t.params?.join?.(" ")}),e},t.convertSVGPathToContext2DCommands=function(t){return W(pt(t))},t.createAssetId=a,t.createBoardContent=function(t,e){const{width:n,height:i,devicePixelRatio:r}=e,o={width:n,height:i,devicePixelRatio:r},a=t.getContext("2d"),s=L(o),c=L(o),l=L(o),h=A({ctx:a,...o}),f=L(o);return{underlayContext:l,viewContext:s,overlayContext:c,boardContext:h,tempContext:f,drawView:()=>{const{width:t,height:e}=s.$getSize();h.clearRect(0,0,t,e),h.drawImage(l.canvas,0,0,t,e),h.drawImage(s.canvas,0,0,t,e),h.drawImage(c.canvas,0,0,t,e),l.clearRect(0,0,t,e),s.clearRect(0,0,t,e),c.clearRect(0,0,t,e)}}},t.createContext2D=A,t.createHTMLElement=function(t,e,n){return ce(document.createElement(t),e,n)},t.createId=te,t.createMaterial=function(t,e,n){const i=function(t,e){let n=0,i=0,r=200,o=200;if(e){const{viewScaleInfo:a,viewSizeInfo:s}=e,{scale:c,offsetLeft:l,offsetTop:h}=a,{width:f,height:u}=s,d=f/4,y=u/4;r=200>=d?d/c:200/c,o=200>=y?y/c:200/c,["circle","svgCode","image"].includes(t)?r=o=Math.max(r,o):"text"===t&&(o=r/4*2),n=(0-l+f/2-r*c/2)/c,i=(0-h+u/2-o*c/2)/c}return{x:n,y:i,width:r,height:o}}(t,n);let o={};if("rect"===t)o=Ct();else if("circle"===t)o={fill:St().fill,cx:200,cy:200,r:100};else if("text"===t)o=function(t){const e=St();return{text:Rt,fill:e.fill,fontFamily:e.fontFamily,fontWeight:e.fontWeight,fontSize:t.width/4,textAlign:"center",verticalAlign:"middle"}}(i);else if("svgCode"===t)o={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="${$t}"></path></svg>`};else if("image"===t)o={href:kt};else if("group"===t){o={children:[],fill:St().fill,overflow:"hidden"};const t=e;Array.isArray(t.children)&&t.children.length>0&&(o.children=[...t.children])}return{id:r(),type:t,...i,...o,...e}},t.createOffscreenContext2D=L,t.createUUID=r,t.dataToSVG=function(t){const{layout:e,materials:n}=t,i=Z(t.materials);let{x:r,y:o,width:a,height:s}=i;e&&(r=e.x,o=e.y,a=e.width,s=e.height);let c=`<svg viewBox="0 0 ${a} ${s}">`;return n.forEach(t=>{c+=Ee({...t,x:t.x-r,y:t.y-o})}),c+="</svg>",c},t.debounce=function(t,e){let n=-1;return function(...i){n>=0&&window.clearTimeout(n),n=setTimeout(()=>{t(...i),n=-1},e)}},t.deepClone=c,t.deepCloneData=function(t){const{materials:e,...n}=t;return{...c(n),materials:e.map(t=>l(t))}},t.deepCloneMaterial=l,t.delay=function(t){return new Promise(e=>{setTimeout(()=>{e()},t)})},t.deleteMaterialInList=function(t,e){return Ht(tt(t,e),e)},t.deleteMaterialInListByPosition=Ht,t.downloadFileFromText=function(t,e){const{fileName:n}=e,i=function(t){const e=(new TextEncoder).encode(t),n=new Blob([e],{type:"text/plain;charset=utf-8"});return window.URL.createObjectURL(n)}(t);let r=document.createElement("a");r.href=i,r.download=n,r.click(),r=null},t.downloadImageFromCanvas=function(t,e){const{fileName:n,type:i="image/jpeg"}=e,r=t.toDataURL(i);let o=document.createElement("a");o.href=r,o.download=n,o.click(),o=null},t.enhanceFontFamliy=function(t){return[t,...Xt].join(", ")},t.filterCompactData=function(t,e){const n=t.assets||{},i=c(t),r=e?.loadItemMap||{},o=t=>{t.forEach(t=>{if("image"===t.type&&t.href){const e=t.href;if(s(e)&&!n[e]&&r[e]&&"string"==typeof r[e]?.source)n[e]={type:"image",value:r[e].source};else if(!n[e]){const i=a(e,t.id);n[i]||(n[i]={type:"image",value:e}),t.href=i}}else if("svgCode"===t.type){const e=t.code;if(s(e)&&!n[e]&&r[e]&&"string"==typeof r[e]?.source)n[e]={type:"svgCode",value:r[e].source};else if(!n[e]){const i=a(e,t.id);n[i]||(n[i]={type:"svgCode",value:e}),t.code=i}}else if("foreignObject"===t.type){const e=t.content;if(s(e)&&!n[e]&&r[e]&&"string"==typeof r[e]?.source)n[e]={type:"foreignObject",value:r[e].source};else if(!n[e]){const i=a(e,t.id);n[i]||(n[i]={type:"foreignObject",value:e}),t.content=i}}else if("group"===t.type&&Array.isArray(t.children)){const e=t.assets||{};Object.keys(e).forEach(t=>{n[t]||(n[t]=e[t])}),delete t.assets,o(t.children)}})};return o(i.materials),i.assets=n,i},t.filterMaterialAsset=function(t){let e=null,n=null,i=null;return"image"===t.type?i=t.href:"svgCode"===t.type?i=t.code:"foreignObject"===t.type&&(i=t.content),"string"!=typeof i||s(i)||(e=a(i,t.id),n={type:t.type,value:i},"image"===t.type?t.href=e:"svgCode"===t.type?t.code=e:"foreignObject"===t.type&&(t.content=e)),{material:t,assetId:e,assetItem:n}},t.findMaterialFromList=function t(e,n){let i=null;for(let r=0;r<n.length;r++){const o=n[r];if(o.id===e){i=o;break}if(!i&&"group"===o.type){const n=t(e,o?.children||[]);if(n?.id===e){i=n;break}}}return i},t.findMaterialFromListByPosition=K,t.findMaterialQueueFromListByPosition=function(t,e){const n=[];let i=e;for(let e=0;e<t.length;e++){const r=i[t[e]];if(!r)break;if(n.push(r),!(e<t.length-1&&"group"===r.type))break;i=r.children}return n},t.findMaterialsFromList=function(t,e){const n=[];return function e(i){for(let r=0;r<i.length;r++){const o=i[r];t.includes(o.id)?n.push(o):"group"===o.type&&e(o?.children||[])}}(e),n},t.findMaterialsFromListByPositions=function(t,e){const n=[];return t.forEach(t=>{const i=K(t,e);i&&n.push(i)}),n},t.flatMaterialList=function(t){const e=[],n=[],i=t=>{if(!function(t){if(["rect","circle"].includes(t.type)){const e=t;if(!e.fill&&!e.strokeWidth)return!1;if("transparent"===e.fill&&!e.strokeWidth)return!1}if(["group"].includes(t.type)){const e=t,{children:n}=e;if(!(n.length>0||e.fill||e.strokeWidth))return!1;if(!(n.length>0||"transparent"!==e.fill||e.strokeWidth))return!1}if("text"===t.type&&!t.text)return!1;if("image"===t.type&&!t.href)return!1;if("foreignObject"===t.type&&!t.content)return!1;if("svgCode"===t.type&&!t.code)return!1;if("path"===t.type){const e=t;if(!(e?.commands?.length>0))return!1}return!0}(t))return;const i=function(t,e){const{groupQueue:n}=e;let{x:i,y:r}=t;const{width:o,height:a,angle:s=0}=t;let c=0;if(n.forEach(t=>{i+=t.x,r+=t.y,c+=t.angle||0}),c=q(c),0===c)return{x:i,y:r,width:o,height:a,angle:s};c+=t.angle||0,c=q(c);const l=at(t,{groupQueue:n}),h=X(H(l),l[0],F(0-c));return i=h.x,r=h.y,{x:i,y:r,width:o,height:a,angle:c}}(t,{groupQueue:n}),r={...t,...i};e.push(r)},r=t=>{if(!0!==t?.operations?.invisible)if("group"===t.type){const e=t,{children:o,...a}=e;i({...t,attributes:{...a,children:[]}}),n.push(t),o.forEach(t=>{r(t)}),n.pop()}else i(t)};for(let e=0;e<t.length;e++){const n=t[e];r(n)}return e},t.flatObject=Lt,t.formatNumber=vt,t.generateHTML=function(t){return t.reduce(function(t,e){return t+Mt("",e)},"")},t.get=function(t,e,n){if(!e)return;const i=zt(e);let r=t;for(const t of i){if(null==r)return n;r=r[t]}return void 0!==r?r:n},t.getCenterFromTwoPoints=E,t.getDefaultMaterialAttributes=St,t.getDefaultMaterialRectAttributes=Ct,t.getGroupQueueByMaterialPosition=function(t,e){const n=[];let i=t;if(e.length>1)for(let t=0;t<e.length-1;t++){const r=i[e[t]];if("group"!==r?.type||!Array.isArray(r?.children))return null;n.push(r),i=r.children}return n},t.getGroupQueueFromList=function(t,e){const{groupQueue:n}=_(t,e);return n},t.getHTMLElementRectInPage=function(t){const e=t.getBoundingClientRect(),n=window.pageXOffset||document.documentElement.scrollLeft,i=window.pageYOffset||document.documentElement.scrollTop;return{pageX:e.left+n,pageY:e.top+i,width:e.width,height:e.height}},t.getMaterialAndGroupQueueFromList=_,t.getMaterialPositionFromList=tt,t.getMaterialPositionMapFromList=function(t,e){const n=[],i={};let r=!1;const o=e=>{for(let a=0;a<e.length&&!0!==r;a++){n.push(a);const s=e[a];if(t.includes(s.id)){if(i[s.id]=[...n],Object.keys(i).length===t.length){r=!0;break}}else"group"===s.type&&o(s?.children||[]);if(r)break;n.pop()}};return o(e),i},t.getMaterialRotateVertexes=Y,t.getMaterialSize=function(t){const{id:e,x:n,y:i,width:r,height:o,angle:a=0}=t;return{id:e,x:n,y:i,width:r,height:o,angle:a}},t.getMaterialVertexes=nt,t.getMaterialsAssetIds=function(t){const e=[],n=t=>{t.forEach(t=>{"image"===t.type&&s(t.href)?e.push(t.href):"svgCode"===t.type&&s(t.code)?e.push(t.code):"foreignObject"===t.type&&t.content?e.push(t.content):"group"===t.type&&Array.isArray(t.children)&&n(t.children)})};return n(t),e},t.getMiddlewareValidStyles=function(t,e){const n={};return t&&e.forEach(e=>{const i=t?.[e];"string"!=typeof i&&"number"!=typeof i||(n[e]=i)}),n},t.getSelectedMaterialUUIDs=function(t,e){let n=[];return Array.isArray(t?.materials)&&t?.materials?.length>0&&Array.isArray(e)&&e.length>0&&e.forEach(e=>{"number"==typeof e?t?.materials?.[e]&&n.push(t.materials[e].id):"string"==typeof e&&(n=n.concat(function(t,e){const n=[];if("string"==typeof e&&/^\d+(\.\d+)*$/.test(e)){const i=e.split(".");let r=t;for(;i.length>0;){const t=i.shift();if("string"==typeof t){const e=r[parseInt(t)];e&&0===i.length?n.push(e.id):"group"===e.type&&i.length>0&&(r=e?.children||[])}break}}return n}(t.materials,e)))}),n},t.getViewPointAtMaterial=function(t,e){const{context2d:n,data:i,viewScaleInfo:r,viewSizeInfo:o,groupQueue:a}=e,s={index:-1,material:null,groupQueueIndex:-1};if(a&&Array.isArray(a)&&a?.length>0)for(let e=a.length-1;e>=0;e--){let i=0,o=0,c=0;for(let t=0;t<=e;t++)i+=a[t].x,o+=a[t].y,c+=a[t].angle||0;const l=a[e];if(l&&"group"===l.type&&Array.isArray(l?.children))for(let h=0;h<l.children.length;h++){const f=l.children[h];if(!0!==f?.operations?.invisible){if(!f)break;if(lt(t,{context2d:n,material:{x:i+f.x,y:o+f.y,width:f.width,height:f.height,angle:c+(f.angle||0)},viewScaleInfo:r})){s.material=f,(e<a.length-1||"group"!==f.type)&&(s.groupQueueIndex=e);break}}}if(s.material)break}if(s.material)return s;for(let e=i.materials.length-1;e>=0;e--){const o=i.materials[e];if(!0!==o?.operations?.invisible&&lt(t,{context2d:n,material:o,viewScaleInfo:r})){s.index=e,s.material=o;break}}return s},t.getViewScaleInfoFromSnapshot=function(t){const{activeStore:e}=t;return{scale:e?.scale,offsetTop:e?.offsetTop,offsetBottom:e?.offsetBottom,offsetLeft:e?.offsetLeft,offsetRight:e?.offsetRight}},t.getViewSizeInfoFromSnapshot=function(t){const{activeStore:e}=t;return{devicePixelRatio:e.devicePixelRatio,width:e?.width,height:e?.height,contextWidth:e?.contextWidth,contextHeight:e?.contextHeight}},t.groupMaterialsByPosition=function(t,e){if(e.length>1){let n=!0;const i=[];for(let t=1;t<e.length;t++){const r=e[t-1],o=e[t];if(!(r.length>0&&o.length>0)){n=!1;break}if(r.length!==o.length){n=!1;break}const a=[...r],s=[...o],c=a.pop(),l=s.pop();1===t&&"number"==typeof c&&c>=0&&i.push(c),"number"==typeof l&&l>=0&&i.push(l)}if(!0!==n)return console.error("[idraw]: The grouped materials are not siblings!"),t;i.sort((t,e)=>t-e);const o=[...e[0]].splice(0,e[0].length-1),a=[],s=[...o,i[0]];for(let e=0;e<i.length;e++){const n=K([...o,i[e]],t);n&&a.push(n)}const c=Z(a);for(let t=0;t<a.length;t++){const e=a[t];e&&(e.x-=c.x,e.y-=c.y)}for(let e=i.length-1;e>=0;e--){Ht([...o,i[e]],t)}Bt({name:"Group",id:r(),type:"group",...c,children:a},s,t)}return t},t.injectStyles=function(t){const{styles:e,rootClassName:n,type:i}=t,r=ye(e,`.${n}`);if("element"===i){const t=document.createElement("style");t.setAttribute(pe,n),t.textContent=r;(document.head||document.body).appendChild(t)}else{const t=new CSSStyleSheet;t.replaceSync(r),ge[n]=t,document.adoptedStyleSheets=[...document.adoptedStyleSheets,t]}},t.insertMaterialToListByPosition=Bt,t.is=$,t.isAssetId=s,t.isColorStr=e,t.isMaterialInView=function(t,e){const{viewSizeInfo:n,viewScaleInfo:i}=e,{width:r,height:o}=n,{angle:a}=t,{x:s,y:c,width:l,height:h}=st(t,{viewScaleInfo:i}),f=G({x:s,y:c,width:l,height:h,angle:a}),u={x:0,y:0,width:r,height:o},d=Math.min(f[0].x,f[1].x,f[2].x,f[3].x),y=Math.min(f[0].y,f[1].y,f[2].y,f[3].y);return et(u,{x:d,y:y,width:Math.max(f[0].x,f[1].x,f[2].x,f[3].x)-d,height:Math.max(f[0].y,f[1].y,f[2].y,f[3].y)-y})},t.isPointInMiddlewareElement=function(t,e){const{$root:n,rootClassName:i}=e;if(!n)return!1;const r=t.target;return!!he(r,n,{className:i})},t.isResourceMaterial=function(t){return["image","svgCode","foreignObject"].includes(t?.type)},t.isSameMaterialSize=function(t,e){return t.x===e.x&&t.y===e.y&&t.height===e.height&&t.width===e.width&&q(t.angle||0)===q(e.angle||0)},t.isViewPointInMaterial=lt,t.isViewPointInMaterialSize=function(t,e,n){return ht(t,it(e),n)},t.isViewPointInVertexes=ht,t.istype=f,t.limitAngle=q,t.loadForeignObject=async function(t,e){t=t.replace(/&/gi,"&amp;");const n=await u(t,e);return await p(n)},t.loadImage=p,t.loadSVGCode=async function(t){const e=await d(t);return await p(e)},t.materialToSVG=Ee,t.matrixToAngle=function(t){const e=Pt(t);if("number"==typeof e){return 180*e/Math.PI}return e},t.matrixToRadian=Pt,t.merge=function t(e,n){const i=e;for(const e in n)Object.prototype.hasOwnProperty.call(n,e)&&("object"==typeof n[e]&&null!==n[e]&&"object"==typeof i[e]&&null!==i[e]?i[e]=t(i[e],n[e]):i[e]=n[e]);return e},t.mergeGlobal=function(t,e,n){const i=Ot(e),r=[],o=Object.keys(i);if(o.forEach(e=>{if(!r.includes(e)){const n=i[e];jt(t,e),void 0!==n&&Tt(t,e,n)}}),!0===n?.strict){const e=Ot(t);Object.keys(e).forEach(e=>{r.includes(e)||o.includes(e)||jt(t,e)})}return t},t.mergeHexColorAlpha=function(t,e){if(1===e)return t;let n=1;const i=/^#[0-9a-f]{6,6}$/i;let r=t;if(i.test(t)?n=parseInt(t.substring(5,7).replace(/^#/,"0x")):/^#[0-9a-f]{8,8}$/i.test(t)&&(n=parseInt(t.substring(7,9).replace(/^#/,"0x")),r=t.substring(0,7)),n*=e,i.test(r)&&n>0&&n<1){const t=Math.max(0,Math.min(255,Math.ceil(256*n)));r=`${r.toUpperCase()}${t.toString(16).toUpperCase()}`}return r},t.mergeLayout=function(t,e,n){const i=Et(e),r=[],o=Object.keys(i);if(o.forEach(e=>{if(!r.includes(e)){const n=i[e];jt(t,e),void 0!==n&&Tt(t,e,n)}}),!0===n?.strict){const e=Et(t);Object.keys(e).forEach(e=>{r.includes(e)||o.includes(e)||jt(t,e)})}return t},t.mergeMaterial=Nt,t.mergeMaterialAsset=function(t,e){const n=t;let i=null,r=null;return"image"===n.type?i=n.href:"svgCode"===n.type?i=n.code:"foreignObject"===n.type&&(i=n.content),i&&i?.startsWith("@assets/")&&(r=e[i]),r?.type===n.type&&"string"==typeof r?.value&&r?.value&&("image"===n.type?n.href=r.value:"svgCode"===n.type?n.code=r.value:"foreignObject"===n.type&&(n.content=r.value)),n},t.moveCurveCtrlInAnchorCommands=function(t,e){const n=[],{index:i,type:r,moveX:o,moveY:a}=e;t.forEach(t=>{const{id:e,type:i,params:r}=t,o={id:e,type:i,params:[...r]};n.push(o)});const s=n[i];return"C"===s.type&&("curve-ctrl1"===r?(s.params[0]+=o,s.params[1]+=a):"curve-ctrl2"===r&&(s.params[2]+=o,s.params[3]+=a)),ie(n)},t.moveInAnchorCommands=function(t,e){const n=[],{index:i,moveX:r,moveY:o}=e;t.forEach(t=>{const{id:e,type:i,params:r}=t,o={id:e,type:i,params:[...r]};n.push(o)});const a=n[i],s=n[i-1];if("start"===e.type){if(!s||!a)return ie(n);switch("M"===a.type&&(a.params[0]+=r,a.params[1]+=o),"C"===a.type&&(a.params[0]+=r,a.params[1]+=o),s.type){case"M":case"L":case"Z":s.params[0]+=r,s.params[1]+=o;break;case"A":s.params[5]+=r,s.params[6]+=o;break;case"C":s.params[2]+=r,s.params[3]+=o,s.params[4]+=r,s.params[5]+=o}}return ie(n)},t.moveMaterialPosition=function(t,e){const n=[...e.from],i=[...e.to];if(0===n.length||0===i.length)return{materials:t,from:n,to:i};if(n.length<=i.length)for(let e=0;e<n.length;e++)if(i[e]!==n[e]);else if(e===n.length-1)return{materials:t,from:n,to:i};const r=K(n,t);if(r){if(!Bt(r,i,t))return{materials:t,from:n,to:i};let e=-1,o=!1;if(n.length>=1&&i.length>=1){if(n.length<=i.length)if(1===n.length)n[0]<i[0]&&(o=!0);else for(let t=0;t<n.length&&n[t]===i[t];t++)if(n.length===n.length-1){o=!0;break}if(n.length>=i.length)if(1===i.length)i[0]<n[0]&&(o=!0);else for(let t=0;t<i.length&&(t===i.length-1&&i[t]<n[t]&&(o=!0),n[t]===i[t]);t++);}if(!0===o)for(let t=0;t<n.length&&i[t]>=0;t++)i[t]!==n[t]&&i[t]<n[t]&&t==i.length-1&&(e=t);e>=0&&(n[e]=n[e]+1),Ht(n,t)}return{materials:t,from:n,to:i}},t.omit=function(t,e){const n={...t};for(const t of e)delete n[t];return n},t.parseAngleToRadian=F,t.parseFileToBase64=function(t){return new Promise(function(e,n){let i=new FileReader;i.addEventListener("load",function(){e(i.result),i=null}),i.addEventListener("error",function(t){n(t),i=null}),i.addEventListener("abort",function(){n(new Error("abort")),i=null}),i.readAsDataURL(t)})},t.parseFileToText=function(t){return new Promise(function(e,n){let i=new FileReader;i.addEventListener("load",function(){e(i.result),i=null}),i.addEventListener("error",function(t){n(t),i=null}),i.addEventListener("abort",function(){n(new Error("abort")),i=null}),i.readAsText(t)})},t.parseHTML=function(t){const e=[],n=[];let i,r=-1;return t.replace(xt,(o,a)=>{const s="/"!==o.charAt(1),c=o.startsWith("\x3c!--"),l=a+o.length,h=t.charAt(l);let f;if(c){const t=wt(o);return r<0?(e.push(t),o):(f=n[r],f.children.push(t),o)}if(s){if(r++,i=wt(o),!i.isVoid&&h&&"<"!==h){const e=t.slice(l,t.indexOf("<",l));e.trim()&&i.children.push({type:"text",name:null,attributes:{},children:[],isVoid:!1,textContent:e.trim()})}0===r&&e.push(i),f=n[r-1],f&&f.children.push(i),n[r]=i}if((!s||!Array.isArray(i)&&i.isVoid)&&(r>-1&&!Array.isArray(i)&&(i.isVoid||i.name===o.slice(2,-1))&&(r--,i=-1===r?e:n[r]),"<"!==h&&h)){f=-1===r?e:n[r].children;const i=t.indexOf("<",l);let o=t.slice(l,-1===i?void 0:i);mt.test(o)&&(o=" "),(i>-1&&r+f.length>=0||" "!==o)&&o.trim()&&f.push({type:"text",name:null,attributes:{},children:[],isVoid:!1,textContent:o.trim()})}return o}),e},t.parseHTMLStr=function(t){const e=le(t),n=document.createElement("template");return n.innerHTML=e.trim(),n.content.firstElementChild},t.parseRadianToAngle=function(t){return t/Math.PI*180},t.parseSVGCodeToDataURL=d,t.parseSVGPath=pt,t.parseStyles=ye,t.parseXMLToDataURL=u,t.pickFile=function(t){const{accept:e,success:n,error:i}=t;let r=document.createElement("input");r.type="file",e&&(r.accept=e),r.addEventListener("change",function(){const t=r.files?.[0];n({file:t}),r=null}),r.addEventListener("error",function(t){"function"==typeof i&&i(t),r=null}),r.click()},t.refinePathMaterial=function(t){let{x:e,y:n,width:i,height:r,...o}=t;const{commands:a}=o,s=Yt(a),{minX:c,minY:l,maxX:h,maxY:f}=s;return e+=c,n+=l,i=Math.abs(h-c),r=Math.abs(f-l),0===c&&0===l||(o.commands=ne(a,0-c,0-l)),{...t,x:e,y:n,width:i,height:r,...o}},t.removeClassName=function(t,e){e.forEach(e=>{e&&t.classList.contains(e)&&t.classList.remove(e)})},t.removeStyles=function(t){const{rootClassName:e,type:n}=t;if("element"===n){const t=document.querySelector(`[${pe}="${e}"]`);t?.remove()}else if(ge[e]){const t=ge[e],n=document.adoptedStyleSheets.filter(e=>e!==t);document.adoptedStyleSheets=n}},t.resizeEffectGroupMaterial=Vt,t.rotateByCenter=V,t.rotateMaterial=function(t,e,n){const i=B(e);V(t,e.angle||0,i,()=>{n(t)})},t.rotateMaterialVertexes=G,t.rotatePoint=X,t.rotatePointInGroup=U,t.rotateVertexes=Q,t.sanitizeHTMLStr=le,t.scalePathCommands=function(t,e,n){return t.map(t=>{const{id:i,type:r,params:o}=t,a=[];let s={id:i};if(t.start&&t.end){const r={...t.start},o={...t.end};r.x*=e,r.y*=n,o.x*=e,o.y*=n,s={id:i,start:r,end:o}}switch(r.toUpperCase()){case"M":case"L":case"T":for(let t=0;t<o.length;t+=2)a.push(o[t]*e,o[t+1]*n);break;case"C":for(let t=0;t<o.length;t+=6)a.push(o[t]*e,o[t+1]*n,o[t+2]*e,o[t+3]*n,o[t+4]*e,o[t+5]*n);break;case"S":for(let t=0;t<o.length;t+=4)a.push(o[t]*e,o[t+1]*n,o[t+2]*e,o[t+3]*n);break;case"Q":for(let t=0;t<o.length;t+=4)a.push(o[t]*e,o[t+1]*n,o[t+2]*e,o[t+3]*n);break;case"H":o.forEach(t=>a.push(t*e));break;case"V":o.forEach(t=>a.push(t*n));break;case"A":for(let t=0;t<o.length;t+=7)a.push(o[t]*e,o[t+1]*n,o[t+2],o[t+3],o[t+4],o[t+5]*e,o[t+6]*n);break;case"M":case"L":case"C":case"S":case"Q":case"T":case"A":case"H":case"V":for(let t=0;t<o.length;t++){const i="a"===r&&(t%7==0||t%7==5)||"h"===r||"v"!==r&&t%2==0;a.push(o[t]*(i?e:n))}break;default:return{type:r,params:[...o],...s}}return{type:r,params:a,...s}})},t.set=Tt,t.setHTMLCSSProps=se,t.shiftPathCommand=ee,t.shiftPathCommands=ne,t.sortDataAsserts=function(t,e){const n=t.assets||{};let i=t;!0===e?.clone&&(i=c(t));const r=t=>{t.forEach(t=>{if("image"===t.type&&t.href){const e=t.href,i=a(e,t.id);n[i]||(n[i]={type:"image",value:e}),t.href=i}else if("svgCode"===t.type){const e=t.code,i=a(e,t.id);n[i]||(n[i]={type:"svgCode",value:e}),t.code=i}else if("foreignObject"===t.type){const e=t.content,i=a(e,t.id);n[i]||(n[i]={type:"foreignObject",value:e}),t.content=i}else if("group"===t.type&&Array.isArray(t.children)){const e=t.assets||{};Object.keys(e).forEach(t=>{n[t]||(n[t]=e[t])}),delete t.assets,r(t.children)}})};return r(i.materials),i.assets=n,i},t.svgToMaterial=function(t){const e=new DOMParser,n=t.replace(/<\?xml[^>]*\?>/g,"").replace(/<!DOCTYPE[^>]*>/g,"").trim(),i=e.parseFromString(n,"image/svg+xml"),r=i.getElementsByTagName("parsererror")[0];if(r)throw new Error(`SVG parsing error: ${r.textContent}`);const o=i.documentElement;if("svg"!==o.tagName.toLowerCase())throw new Error("Input is not a valid SVG document");return Ie(o)},t.throttle=function(t,e){let n=-1;return function(...i){n>=0||(n=setTimeout(()=>{t(...i),n=-1},e))}},t.toColorHexNum=function(t){return parseInt(t.replace(/^#/,"0x"))},t.toColorHexStr=function(t){return"#"+t.toString(16)},t.toFlattenGlobal=Ot,t.toFlattenLayout=Et,t.toFlattenMaterial=It,t.toPath=zt,t.unflatObject=function(t){const e={};for(const[n,i]of Object.entries(t)){me(e,xe(n),i)}return e},t.ungroupMaterialsByPosition=function(t,e){const n=K(e,t);n&&"group"===n?.type&&Array.isArray(n?.children)||console.error("[idraw]: The ungrouped material is not a group material!");const i=[...e].splice(0,e.length-1),r=e[e.length-1],{x:o,y:a}=n;return Ht(e,t),n.children.forEach((e,n)=>{e.x+=o,e.y+=a;Bt(e,[...i,r+n],t)}),t},t.updateMaterialInList=function t(e,n,i){let r=null;for(let o=0;o<i.length;o++){const a=i[o];if(a.id===e){"group"===a.type&&a.operations?.resizeEffect&&Vt(a,{...n},{resizeEffect:a.operations?.resizeEffect}),Nt(a,n),r=a;break}"group"===a.type&&(r=t(e,n,a?.children||[]))}return r},t.updateMaterialInListByPosition=function(t,e,n,i){const r=K(t,n);return r&&("group"===r.type&&r.operations?.resizeEffect&&Vt(r,{...e},{resizeEffect:r.operations?.resizeEffect}),Nt(r,e,i)),r},t.validateMaterials=function t(e){let n=!0;if(Array.isArray(e)){const i=[];e.forEach(e=>{"string"==typeof e.id&&e.id?i.includes(e.id)?(n=!1,console.warn(`Duplicate ids: ${e.id}`)):i.push(e.id):(n=!1,console.warn("Material missing id",e)),"group"===e.type&&(n=t(e?.children))})}return n},t.viewScale=function(t){const{scale:e,point:n,viewScaleInfo:i}=t,{offsetLeft:r,offsetTop:o}=i,a=e/i.scale,s=n.x,c=n.y;return{moveX:s-s*a+(r*a-r),moveY:c-c*a+(o*a-o)}},t.viewScroll=function(t){const{moveX:e=0,moveY:n=0,viewScaleInfo:i,viewSizeInfo:r}=t,{scale:o}=i,{width:a,height:s,contextWidth:c,contextHeight:l}=r;let h=i.offsetLeft,f=i.offsetRight,u=i.offsetTop,d=i.offsetBottom;return h+=e,u+=n,f=a-(c*o+h),d=s-(l*o+u),{scale:o,offsetTop:u,offsetLeft:h,offsetRight:f,offsetBottom:d}},Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),t}({});
1
+ var iDrawUtil=function(t){function e(t){return"string"==typeof t&&(/^#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(t)||/^[a-z]{1,}$/i.test(t))}Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});var n={aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",green:"#008000",greenyellow:"#adff2f",honeydew:"#f0fff0",hotpink:"#ff69b4","indianred ":"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrodyellow:"#fafad2",lightgrey:"#d3d3d3",lightgreen:"#90ee90",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370d8",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#d87093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",rebeccapurple:"#663399",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32"};function i(t){return(65536*(1+Math.random())|0).toString(t||16).substring(1)}function r(){return`${i()}${i()}-${i()}-${i()}-${i()}-${i()}${i()}${i()}`}function o(t,e){let n=0;for(let e=0;e<t.length;e++)n+=t.charCodeAt(e);return(n+e).toString(16).substring(0,4)}function a(t,e){const n=t.length,i=function(t){let e=0;for(let n=0;n<t.length;n++)e+=t.charCodeAt(n);return e}(e),r=Math.floor(n/2),a=t.substring(0,4).padStart(4,"0"),s=t.substring(0,4).padStart(4,"0");return`@assets/${o(n.toString(16).padStart(4,a),i).padStart(4,"0")}${o(t.substring(r-4,r).padStart(4,a),i).padStart(4,"0")}-${o(t.substring(r-8,r-4).padStart(4,a),i).padStart(4,"0")}-${o(t.substring(r-12,r-8).padStart(4,a),i).padStart(4,"0")}-${o(t.substring(r-16,r-12).padStart(4,s),i).padStart(4,"0")}-${o(t.substring(r,r+4).padStart(4,s),i).padStart(4,"0")}${o(t.substring(r+4,r+8).padStart(4,s),i).padStart(4,"0")}${o(s.padStart(4,a).padStart(4,s),i)}`}function s(t){return/^@assets\/[0-9a-z-]{0,}$/.test(`${t}`)}function c(t){return function t(e){const n=function(t){return Object.prototype.toString.call(t).replace(/[\]|\[]{1,1}/gi,"").split(" ")[1]}(e);if(["Null","Number","String","Boolean","Undefined"].indexOf(n)>=0)return e;if("Array"===n){const n=[];return e.forEach(e=>{n.push(t(e))}),n}if("Object"===n){const n={};return Object.keys(e).forEach(i=>{n[i]=t(e[i])}),Object.getOwnPropertySymbols(e).forEach(i=>{n[i]=t(e[i])}),n}}(t)}function l(t){const e=c(t),n=t=>{t.id=r(),"group"===t.type&&t.children&&t.children.forEach(t=>{n(t)})};return n(e),e}function h(t){return(Object.prototype.toString.call(t)||"").replace(/(\[object|\])/gi,"").trim()}var f={type(t,e){const n=h(t);return!0===e?n.toLocaleLowerCase():n},array:t=>"Array"===h(t),json:t=>"Object"===h(t),function:t=>"Function"===h(t),asyncFunction:t=>"AsyncFunction"===h(t),boolean:t=>"Boolean"===h(t),string:t=>"String"===h(t),number:t=>"Number"===h(t),undefined:t=>"Undefined"===h(t),null:t=>"Null"===h(t),promise:t=>"Promise"===h(t)};function u(t,e){const{width:n,height:i}=e;return new Promise((e,r)=>{const o=new Blob([`\n <svg \n xmlns="http://www.w3.org/2000/svg" \n width="${n||""}" \n height = "${i||""}">\n <foreignObject width="100%" height="100%">\n <div xmlns = "http://www.w3.org/1999/xhtml">\n ${t}\n </div>\n </foreignObject>\n </svg>\n `],{type:"image/svg+xml;charset=utf-8"}),a=new FileReader;a.readAsDataURL(o),a.onload=function(t){const n=t?.target?.result;e(n)},a.onerror=function(t){r(t)}})}function d(t){return new Promise((e,n)=>{const i=new Blob([t],{type:"image/svg+xml;charset=utf-8"}),r=new FileReader;r.readAsDataURL(i),r.onload=function(t){const n=t?.target?.result;e(n)},r.onerror=function(t){n(t)}})}var{Image:y}=window;function p(t){return new Promise((e,n)=>{const i=new y;i.crossOrigin="anonymous",i.onload=function(){e(i)},i.onabort=n,i.onerror=n,i.src=t})}function g(t){return"number"==typeof t&&t>=0}function x(t){return"number"==typeof t&&(t>0||t<=0)}function m(t){return x(t)}function b(t){return x(t)}function w(t){return g(t)}function v(t){return g(t)}function M(t){return"string"==typeof t&&/^(http:\/\/|https:\/\/|\.\/|\/)/.test(`${t}`)}function P(t){return"string"==typeof t&&/^(data:image\/)/.test(`${t}`)}function R(t){return["rect","circle","text","image","svgCode","foreignObject","group"].includes(t)}var $={positiveNum:g,data:function(t){return!!(Array(t?.materials)&&t?.materials.length>=0)},material:function(t){return!!t&&(R(t?.type)&&m(t?.x)&&b(t?.y)&&w(t?.w)&&v(t?.h))},layout:function(t){return!!t&&(m(t?.x)&&b(t?.y)&&w(t?.w)&&v(t?.h))},type:R,x:m,y:b,width:w,height:v,angle:function(t){return"number"==typeof t&&t>=-360&&t<=360},number:x,numberStr:function(t){return/^(-?\d+(?:\.\d+)?)$/.test(`${t}`)},strokeWidth:function(t){return g(t)||Array.isArray(t)&&g(t[0])&&g(t[1])&&g(t[2])&&g(t[3])},cornerRadius:function(t){return g(t)||Array.isArray(t)&&g(t[0])&&g(t[1])&&g(t[2])&&g(t[3])},color:function(t){return e(t)},imageSrc:function(t){return P(t)||M(t)},imageURL:M,imageBase64:P,svg:function(t){return"string"==typeof t&&/^(<svg[\s]{1,}|<svg>)/i.test(`${t}`.trim())&&/<\/[\s]{0,}svg>$/i.test(`${t}`.trim())},html:function(t){let e=!1;if("string"==typeof t){let n=document.createElement("div");n.innerHTML=t,n.children.length>0&&(e=!0),n=null}return e},text:function(t){return"string"==typeof t},fontSize:function(t){return x(t)&&t>0},lineHeight:function(t){return x(t)&&t>0},textAlign:function(t){return["center","left","right"].includes(t)},fontFamily:function(t){return"string"==typeof t&&t.length>0},fontWeight:function(t){return["bold"].includes(t)}};function k(t={}){const{stroke:e,cornerRadius:n,strokeWidth:i}=t;return!(Object.prototype.hasOwnProperty.call(t,"stroke")&&!$.color(e))&&(!(Object.prototype.hasOwnProperty.call(t,"cornerRadius")&&!$.number(n))&&!(Object.prototype.hasOwnProperty.call(t,"strokeWidth")&&!$.number(i)))}var S={attrs:function(t){const{x:e,y:n,width:i,height:r,angle:o=0}=t;return!!($.x(e)&&$.y(n)&&$.width(i)&&$.height(r)&&$.angle(o))&&(o>=-360&&o<=360)},textDesc:function(t){const{text:e,color:n,fontSize:i,lineHeight:r,fontFamily:o,textAlign:a,fontWeight:s,background:c,strokeWidth:l,strokeColor:h}=t;return!!$.text(e)&&(!!$.color(n)&&(!!$.fontSize(i)&&(!(Object.prototype.hasOwnProperty.call(t,"background")&&!$.color(c))&&(!(Object.prototype.hasOwnProperty.call(t,"fontWeight")&&!$.fontWeight(s))&&(!(Object.prototype.hasOwnProperty.call(t,"lineHeight")&&!$.lineHeight(r))&&(!(Object.prototype.hasOwnProperty.call(t,"fontFamily")&&!$.fontFamily(o))&&(!(Object.prototype.hasOwnProperty.call(t,"textAlign")&&!$.textAlign(a))&&(!(Object.prototype.hasOwnProperty.call(t,"strokeWidth")&&!$.strokeWidth(l))&&(!(Object.prototype.hasOwnProperty.call(t,"strokeColor")&&!$.color(h))&&!!k(t))))))))))},rectDesc:function(t){const{background:e}=t;return!(Object.prototype.hasOwnProperty.call(t,"background")&&!$.color(e))&&!!k(t)},circleDesc:function(t){const{background:e,stroke:n,strokeWidth:i}=t;return!(Object.prototype.hasOwnProperty.call(t,"background")&&!$.color(e))&&(!(Object.prototype.hasOwnProperty.call(t,"stroke")&&!$.color(n))&&!(Object.prototype.hasOwnProperty.call(t,"strokeWidth")&&!$.number(i)))},imageDesc:function(t){const{href:e}=t;return!!$.imageSrc(e)},svgDesc:function(t){const{svg:e}=t;return!!$.svg(e)},htmlDesc:function(t){const{html:e}=t;return!!$.html(e)}},C=class{#t;#e;constructor(t,e){this.#t=t,this.#e={devicePixelRatio:1,offscreenCanvas:null,...e},this.$resetFont()}$undoPixelRatio(t){return t/this.#e.devicePixelRatio}$doPixelRatio(t){return this.#e.devicePixelRatio*t}$getContext(){return this.#t}$setContext(t){this.#t=t}$setFont(t){const e=[];t.fontWeight&&e.push(`${t.fontWeight}`),e.push(`${this.$doPixelRatio(t.fontSize||12)}px`),e.push(`${t.fontFamily||"sans-serif"}`),this.#t.font=`${e.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.#e.offscreenCanvas}$resize(t){const{width:e,height:n,devicePixelRatio:i,resetStyle:r}=t,{canvas:o}=this.#t;o.width=e*i,o.height=n*i,this.#e={...this.#e,devicePixelRatio:i},!0===r&&(o.style.width=`${e}px`,o.style.height=`${n}px`)}$getSize(){const{devicePixelRatio:t}=this.#e,{width:e,height:n}=this.#t.canvas;return{width:e/t,height:n/t,devicePixelRatio:t}}get canvas(){return this.#t.canvas}get fillStyle(){return this.#t.fillStyle}set fillStyle(t){this.#t.fillStyle=t}get strokeStyle(){return this.#t.strokeStyle}set strokeStyle(t){this.#t.strokeStyle=t}get lineWidth(){return this.$undoPixelRatio(this.#t.lineWidth)}set lineWidth(t){this.#t.lineWidth=this.$doPixelRatio(t)}get textAlign(){return this.#t.textAlign}set textAlign(t){this.#t.textAlign=t}get textBaseline(){return this.#t.textBaseline}set textBaseline(t){this.#t.textBaseline=t}get globalAlpha(){return this.#t.globalAlpha}set globalAlpha(t){this.#t.globalAlpha=t}get shadowColor(){return this.#t.shadowColor}set shadowColor(t){this.#t.shadowColor=t}get shadowOffsetX(){return this.$undoPixelRatio(this.#t.shadowOffsetX)}set shadowOffsetX(t){this.#t.shadowOffsetX=this.$doPixelRatio(t)}get shadowOffsetY(){return this.$undoPixelRatio(this.#t.shadowOffsetY)}set shadowOffsetY(t){this.#t.shadowOffsetY=this.$doPixelRatio(t)}get shadowBlur(){return this.$undoPixelRatio(this.#t.shadowBlur)}set shadowBlur(t){this.#t.shadowBlur=this.$doPixelRatio(t)}get lineCap(){return this.#t.lineCap}set lineCap(t){this.#t.lineCap=t}get lineJoin(){return this.#t.lineJoin}set lineJoin(t){this.#t.lineJoin=t}get lineDashOffset(){return this.#t.lineDashOffset}set lineDashOffset(t){this.#t.lineDashOffset=t}get miterLimit(){return this.#t.miterLimit}set miterLimit(t){this.#t.miterLimit=t}get globalCompositeOperation(){return this.#t.globalCompositeOperation}set globalCompositeOperation(t){this.#t.globalCompositeOperation=t}fill(...t){return this.#t.fill(...t)}arc(t,e,n,i,r,o){return this.#t.arc(this.$doPixelRatio(t),this.$doPixelRatio(e),this.$doPixelRatio(n),i,r,o)}rect(t,e,n,i){return this.#t.rect(this.$doPixelRatio(t),this.$doPixelRatio(e),this.$doPixelRatio(n),this.$doPixelRatio(i))}fillRect(t,e,n,i){return this.#t.fillRect(this.$doPixelRatio(t),this.$doPixelRatio(e),this.$doPixelRatio(n),this.$doPixelRatio(i))}clearRect(t,e,n,i){return this.#t.clearRect(this.$doPixelRatio(t),this.$doPixelRatio(e),this.$doPixelRatio(n),this.$doPixelRatio(i))}beginPath(){return this.#t.beginPath()}closePath(){return this.#t.closePath()}lineTo(t,e){return this.#t.lineTo(this.$doPixelRatio(t),this.$doPixelRatio(e))}moveTo(t,e){return this.#t.moveTo(this.$doPixelRatio(t),this.$doPixelRatio(e))}arcTo(t,e,n,i,r){return this.#t.arcTo(this.$doPixelRatio(t),this.$doPixelRatio(e),this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(r))}bezierCurveTo(t,e,n,i,r,o){return this.#t.bezierCurveTo(this.$doPixelRatio(t),this.$doPixelRatio(e),this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(r),this.$doPixelRatio(o))}quadraticCurveTo(t,e,n,i){return this.#t.quadraticCurveTo(this.$doPixelRatio(t),this.$doPixelRatio(e),this.$doPixelRatio(n),this.$doPixelRatio(i))}getLineDash(){return this.#t.getLineDash()}setLineDash(t){const e=t.map(t=>this.$doPixelRatio(t));return this.#t.setLineDash(e)}stroke(t){return t?this.#t.stroke(t):this.#t.stroke()}translate(t,e){return this.#t.translate(this.$doPixelRatio(t),this.$doPixelRatio(e))}rotate(t){return this.#t.rotate(t)}drawImage(...t){const e=t[0],n=t[1],i=t[2],r=t[3],o=t[4],a=t[t.length-4],s=t[t.length-3],c=t[t.length-2],l=t[t.length-1];return 9===t.length?this.#t.drawImage(e,this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(r),this.$doPixelRatio(o),this.$doPixelRatio(a),this.$doPixelRatio(s),this.$doPixelRatio(c),this.$doPixelRatio(l)):this.#t.drawImage(e,this.$doPixelRatio(a),this.$doPixelRatio(s),this.$doPixelRatio(c),this.$doPixelRatio(l))}createPattern(t,e){return this.#t.createPattern(t,e)}measureText(t){return this.#t.measureText(t)}fillText(t,e,n,i){return void 0!==i?this.#t.fillText(t,this.$doPixelRatio(e),this.$doPixelRatio(n),this.$doPixelRatio(i)):this.#t.fillText(t,this.$doPixelRatio(e),this.$doPixelRatio(n))}strokeText(t,e,n,i){return void 0!==i?this.#t.strokeText(t,this.$doPixelRatio(e),this.$doPixelRatio(n),this.$doPixelRatio(i)):this.#t.strokeText(t,this.$doPixelRatio(e),this.$doPixelRatio(n))}save(){this.#t.save()}restore(){this.#t.restore()}scale(t,e){this.#t.scale(t,e)}circle(t,e,n,i,r,o,a,s){this.#t.ellipse(this.$doPixelRatio(t),this.$doPixelRatio(e),this.$doPixelRatio(n),this.$doPixelRatio(i),r,o,a,s)}ellipse(t,e,n,i,r,o,a,s){this.#t.ellipse(this.$doPixelRatio(t),this.$doPixelRatio(e),this.$doPixelRatio(n),this.$doPixelRatio(i),r,o,a,s)}isPointInPath(t,e){return this.#t.isPointInPath(this.$doPixelRatio(t),this.$doPixelRatio(e))}clip(...t){return this.#t.clip(...t)}setTransform(t,e,n,i,r,o){return this.#t.setTransform(t,e,n,i,r,o)}getTransform(){return this.#t.getTransform()}createLinearGradient(t,e,n,i){return this.#t.createLinearGradient(this.$doPixelRatio(t),this.$doPixelRatio(e),this.$doPixelRatio(n),this.$doPixelRatio(i))}createRadialGradient(t,e,n,i,r,o){return this.#t.createRadialGradient(this.$doPixelRatio(t),this.$doPixelRatio(e),this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(r),this.$doPixelRatio(o))}createConicGradient(t,e,n){return this.#t.createConicGradient(t,this.$doPixelRatio(e),this.$doPixelRatio(n))}};function A(t){const{width:e,height:n,ctx:i,devicePixelRatio:r}=t;let o=i;if(!o){const t=document.createElement("canvas");t.width=e*r,t.height=n*r,o=t.getContext("2d")}return new C(o,t)}function L(t){const{width:e,height:n,devicePixelRatio:i}=t,r=new OffscreenCanvas(e*i,n*i);return new C(r.getContext("2d").canvas.getContext("2d"),{devicePixelRatio:i,offscreenCanvas:r})}function I(t,e){const n=(t.x-e.x)*(t.x-e.x)+(t.y-e.y)*(t.y-e.y);return 0===n?n:Math.sqrt(n)}function z(t,e){return{x:t.x+(e.x-t.x)/2,y:t.y+(e.y-t.y)/2}}var E=t=>t===t.toLowerCase();function O(t,e,n,i){const{type:r,params:o=[]}=t;return{x:E(r)?i.x+o[e]:o[e],y:E(r)?i.y+o[n]:o[n]}}function T(t,e){return{c1:{x:t.x+(e.x-t.x)/3,y:t.y+(e.y-t.y)/3},c2:{x:t.x+2*(e.x-t.x)/3,y:t.y+2*(e.y-t.y)/3},end:{...e}}}function j(t,e,n){return{c1:{x:t.x+2/3*(e.x-t.x),y:t.y+2/3*(e.y-t.y)},c2:{x:n.x+2/3*(e.x-n.x),y:n.y+2/3*(e.y-n.y)},end:{...n}}}function W(t){let e={x:0,y:0},n={x:0,y:0},i=null;const r=[],o=t=>{const o=O(t,0,1,e);e={...o},n={...o},r.push({id:te(),name:"moveTo",params:{x:o.x,y:o.y}}),i=null},a=t=>{const n=O(t,0,1,e),o=T(e,n);r.push({id:te(),name:"bezierCurveTo",params:{cp1x:o.c1.x,cp1y:o.c1.y,cp2x:o.c2.x,cp2y:o.c2.y,x:o.end.x,y:o.end.y}}),e={...n},i=o.c2},s=t=>{const n={x:E(t.type)?e.x+t.params[0]:t.params[0],y:e.y},o=T(e,n);r.push({id:te(),name:"bezierCurveTo",params:{cp1x:o.c1.x,cp1y:o.c1.y,cp2x:o.c2.x,cp2y:o.c2.y,x:o.end.x,y:o.end.y}}),e={...n},i=o.c2},c=t=>{const n=E(t.type)?e.y+t.params[0]:t.params[0],o={x:e.x,y:n},a=T(e,o);r.push({id:te(),name:"bezierCurveTo",params:{cp1x:a.c1.x,cp1y:a.c1.y,cp2x:a.c2.x,cp2y:a.c2.y,x:a.end.x,y:a.end.y}}),e={...o},i=a.c2},l=t=>{const n=O(t,0,1,e),o=O(t,2,3,e),a=O(t,4,5,e);r.push({id:te(),name:"bezierCurveTo",params:{cp1x:n.x,cp1y:n.y,cp2x:o.x,cp2y:o.y,x:a.x,y:a.y}}),e={...a},i=o},h=t=>{const n=i||e,o={x:2*e.x-n.x,y:2*e.y-n.y},a=O(t,0,1,e),s=O(t,2,3,e);r.push({id:te(),name:"bezierCurveTo",params:{cp1x:o.x,cp1y:o.y,cp2x:a.x,cp2y:a.y,x:s.x,y:s.y}}),e={...s},i=a},f=t=>{const n=O(t,0,1,e),o=O(t,2,3,e),a=j(e,n,o);r.push({id:te(),name:"bezierCurveTo",params:{cp1x:a.c1.x,cp1y:a.c1.y,cp2x:a.c2.x,cp2y:a.c2.y,x:a.end.x,y:a.end.y}}),e={...o},i=a.c2},u=t=>{const n=i?{x:2*e.x-i.x,y:2*e.y-i.y}:e,o=O(t,0,1,e),a=j(e,n,o);r.push({id:te(),name:"bezierCurveTo",params:{cp1x:a.c1.x,cp1y:a.c1.y,cp2x:a.c2.x,cp2y:a.c2.y,x:a.end.x,y:a.end.y}}),e={...o},i=a.c2},d=t=>{const[n,i,o,a,s,c,l]=t.params,h={x:E(t.type)?e.x+c:c,y:E(t.type)?e.y+l:l},f=function(t,e,n,i,r,o,a){if(n=Math.abs(n),i=Math.abs(i),Math.abs(t.x-e.x)<1e-6&&Math.abs(t.y-e.y)<1e-6)return{centerX:t.x,centerY:t.y,radiusX:n,radiusY:i,rotation:r*Math.PI/180,startRadian:0,endRadian:0,anticlockwise:0===a};if(n<1e-6||i<1e-6)return{centerX:(t.x+e.x)/2,centerY:(t.y+e.y)/2,radiusX:0,radiusY:0,rotation:0,startRadian:0,endRadian:0,anticlockwise:!1};const s=r*Math.PI/180,c=Math.cos(s),l=Math.sin(s),h=(t.x-e.x)/2,f=(t.y-e.y)/2,u=c*h+l*f,d=-l*h+c*f,y=u*u/(n*n)+d*d/(i*i);if(y>1){const t=Math.sqrt(y);n*=t,i*=t}const p=o===a?-1:1;let g=Math.sqrt(Math.abs((n*n*i*i-n*n*d*d-i*i*u*u)/(n*n*d*d+i*i*u*u)));isNaN(g)&&(g=0);const x=p*g*(n*d)/i,m=p*g*(-i*u)/n,b=c*x-l*m+(t.x+e.x)/2,w=l*x+c*m+(t.y+e.y)/2,v=(u-x)/n,M=(d-m)/i,P=(-u-x)/n,R=(-d-m)/i,$=Math.atan2(M,v);let k=Math.atan2(R,P)-$;return 0===a&&k>0?k-=2*Math.PI:1===a&&k<0&&(k+=2*Math.PI),{centerX:b,centerY:w,radiusX:n,radiusY:i,rotation:s,startRadian:$,endRadian:$+k,anticlockwise:0===a}}(e,h,n,i,o*Math.PI/180,a,s);r.push({id:te(),name:"ellipse",params:f}),e={...h}},y=t=>{if(e.x!==n.x||e.y!==n.y){const t=T(e,n);r.push({id:te(),name:"bezierCurveTo",params:{cp1x:t.c1.x,cp1y:t.c1.y,cp2x:t.c2.x,cp2y:t.c2.y,x:t.end.x,y:t.end.y}})}r.push({id:te(),name:"closePath",params:null}),e={...n},i=null};r.push({id:te(),name:"beginPath",params:null});for(const e of t){const{id:t,type:n,params:i=[]}=e,r={id:t,type:n,params:i};switch(r.type.toUpperCase()){case"M":o(r);break;case"L":a(r);break;case"H":s(r);break;case"V":c(r);break;case"C":l(r);break;case"S":h(r);break;case"Q":f(r);break;case"T":u(r);break;case"A":d(r);break;case"Z":y()}}return r}function D(t){const{centerX:e,centerY:n,radiusX:i,radiusY:r,rotation:o,startRadian:a,endRadian:s,anticlockwise:c}=t,l=function(t,e,n,i,r,o){const a=Math.cos(r),s=Math.sin(r);return{x:t+n*Math.cos(o)*a-i*Math.sin(o)*s,y:e+n*Math.cos(o)*s+i*Math.sin(o)*a}}(e,n,i,r,o,s);let h=s-a;c?h>0&&(h-=2*Math.PI):h<0&&(h+=2*Math.PI);const f=Math.abs(h)>Math.PI?1:0,u=c?0:1;return{rx:i,ry:r,xAxisRotation:180*o/Math.PI,largeArcFlag:f,sweepFlag:u,endPoint:l}}function F(t){return t/180*Math.PI}function V(t,e,n,i){const r=F(e||0);n&&(r>0||r<0)&&(t.translate(n.x,n.y),t.rotate(r),t.translate(-n.x,-n.y)),i(t),n&&(r>0||r<0)&&(t.translate(n.x,n.y),t.rotate(-r),t.translate(-n.x,-n.y))}function B(t){return{x:t.x+t.width/2,y:t.y+t.height/2}}function H(t){const e=Math.min(t[0].x,t[1].x,t[2].x,t[3].x),n=Math.min(t[0].y,t[1].y,t[2].y,t[3].y);return B({x:e,y:n,width:Math.max(t[0].x,t[1].x,t[2].x,t[3].x)-e,height:Math.max(t[0].y,t[1].y,t[2].y,t[3].y)-n})}function N(t,e){const n=e.x-t.x,i=e.y-t.y;if(0===n){if(i<0)return 0;if(i>0)return Math.PI}else if(0===i){if(n<0)return 3*Math.PI/2;if(n>0)return Math.PI/2}return n>0&&i<0?Math.atan(Math.abs(n)/Math.abs(i)):n>0&&i>0?Math.PI-Math.atan(Math.abs(n)/Math.abs(i)):n<0&&i>0?Math.PI+Math.atan(Math.abs(n)/Math.abs(i)):n<0&&i<0?2*Math.PI-Math.atan(Math.abs(n)/Math.abs(i)):0}function X(t,e,n){let i=N(t,e)+n;i>2*Math.PI?i-=2*Math.PI:i<0-2*Math.PI&&(i+=2*Math.PI),i<0&&(i+=2*Math.PI);const r=I(t,e);let o=0,a=0;return 0===i?(o=0,a=0-r):i>0&&i<Math.PI/2?(o=Math.sin(i)*r,a=0-Math.cos(i)*r):i===Math.PI/2?(o=r,a=0):i>Math.PI/2&&i<Math.PI?(o=Math.sin(Math.PI-i)*r,a=Math.cos(Math.PI-i)*r):i===Math.PI?(o=0,a=r):i>Math.PI&&i<1.5*Math.PI?(o=0-Math.sin(i-Math.PI)*r,a=Math.cos(i-Math.PI)*r):i===1.5*Math.PI?(o=0-r,a=0):i>1.5*Math.PI&&i<2*Math.PI?(o=0-Math.sin(2*Math.PI-i)*r,a=0-Math.cos(2*Math.PI-i)*r):i===2*Math.PI&&(o=0,a=0-r),o+=t.x,a+=t.y,{x:o,y:a}}function U(t,e){if(e?.length>0){let n=t.x,i=t.y;return e.forEach(t=>{const{x:e,y:r,width:o,height:a,angle:s=0}=t,c=X(B({x:e,y:r,width:o,height:a,angle:s}),{x:n,y:i},F(s));n=c.x,i=c.y}),{x:n,y:i}}return t}function Y(t,e,n){const{x:i,y:r,width:o,height:a}=t;let s={x:i,y:r},c={x:i+o,y:r},l={x:i+o,y:r+a},h={x:i,y:r+a};if(n&&(n>0||n<0)){const t=F(q(n));s=X(e,s,t),c=X(e,c,t),l=X(e,l,t),h=X(e,h,t)}return[s,c,l,h]}function G(t){const{angle:e=0}=t;return Y(t,B(t),e)}function Q(t,e,n){return[X(t,{x:e[0].x,y:e[0].y},n),X(t,{x:e[1].x,y:e[1].y},n),X(t,{x:e[2].x,y:e[2].y},n),X(t,{x:e[3].x,y:e[3].y},n)]}function q(t){if(!(t>0||t<0)||0===t||360===t)return 0;let e=t%360;return e<0?e+=360:360===t&&(e=0),e}function Z(t){const e={x:0,y:0,width:0,height:0};let n=null;for(let i=0;i<t.length;i++){const r=t[i];if(r?.operations?.invisible)continue;const o={x:r.x,y:r.y,width:r.width,height:r.height,angle:r.angle||0};if(o.angle&&(o.angle>0||o.angle<0)){const t=G(o);if(4===t.length){const e=[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];o.x=Math.min(...e),o.y=Math.min(...n),o.width=Math.abs(Math.max(...e)-Math.min(...e)),o.height=Math.abs(Math.max(...n)-Math.min(...n))}}if(n){const t=Math.min(o.x,e.x),n=Math.min(o.y,e.y),i=Math.max(o.x+o.width,e.x+e.width),r=Math.max(o.y+o.height,e.y+e.height);e.x=t,e.y=n,e.width=Math.abs(i-t),e.height=Math.abs(r-n)}else e.x=o.x,e.y=o.y,e.width=o.width,e.height=o.height;n=o}return{x:Math.floor(e.x),y:Math.floor(e.y),width:Math.ceil(e.width),height:Math.ceil(e.height)}}function J(t,e){const n={x:0,y:0,width:0,height:0};t.forEach(t=>{const e={x:t.x,y:t.y,width:t.width,height:t.height,angle:t.angle};if(e.angle&&(e.angle>0||e.angle<0)){const t=G(e);if(4===t.length){const n=[t[0].x,t[1].x,t[2].x,t[3].x],i=[t[0].y,t[1].y,t[2].y,t[3].y];e.x=Math.min(...n),e.y=Math.min(...i),e.width=Math.abs(Math.max(...n)-Math.min(...n)),e.height=Math.abs(Math.max(...i)-Math.min(...i))}}const i=Math.min(e.x,n.x),r=Math.min(e.y,n.y),o=Math.max(e.x+e.width,n.x+n.width),a=Math.max(e.y+e.height,n.y+n.height);n.x=i,n.y=r,n.width=Math.abs(o-i),n.height=Math.abs(a-r)}),e?.extend&&(n.x=Math.min(n.x,0),n.y=Math.min(n.y,0));const i={contextWidth:n.width,contextHeight:n.height};return e?.viewWidth&&e?.viewHeight&&e?.viewWidth>0&&e?.viewHeight>0&&(e.viewWidth>n.x+n.width&&(i.contextWidth=e.viewWidth-n.x),e.viewHeight>n.y+n.height&&(i.contextHeight=e.viewHeight-n.y)),i}function _(t,e){const n=[];let i=null;const r=[];return function t(e,o){let a=null;for(let s=0;s<o.length;s++){const c=o[s];if(r.push(s),c.id===e){a=c,i=c;break}if(!a&&"group"===c.type){n.push(c);const i=t(e,c?.children||[]);if(i?.id===e){a=i;break}n.pop(),r.pop()}}return a}(t,e),{groupQueue:n,material:i,position:r}}function K(t,e){let n=null,i=e;for(let e=0;e<t.length;e++){const r=i[t[e]];if(e<t.length-1&&"group"===r?.type)i=r.children;else{if(e!==t.length-1)break;n=r}}return n}function tt(t,e){const n=[];let i=!1;const r=e=>{for(let o=0;o<e.length&&!0!==i;o++){n.push(o);const a=e[o];if(a.id===t){i=!0;break}if("group"===a.type&&r(a?.children||[]),i)break;n.pop()}};return r(e),n}function et(t,e){const n=t.x,i=t.y,r=t.x+t.width,o=t.y+t.height,a=e.x,s=e.y,c=e.x+e.width,l=e.y+e.height;return n<=c&&r>=a&&i<=l&&o>=s}function nt(t){const{x:e,y:n,height:i,width:r}=t;return[{x:e,y:n},{x:e+r,y:n},{x:e+r,y:n+i},{x:e,y:n+i}]}function it(t){const{x:e,y:n,width:i,height:r,angle:o=0}=t;return 0===o?nt(t):Y(t,B({x:e,y:n,width:i,height:r,angle:o}),o)}function rt(t){const e=[];let n=0,i=0;const r=[],o=[...t];for(let t=0;t<o.length;t++){const{x:a,y:s,width:c,height:l,angle:h=0}=o[t];let f;if(n+=a,i+=s,0===t){const t={x:n,y:i,width:c,height:l,angle:h};f=it({x:a,y:s,width:c,height:l,angle:h}),r.push({center:B(t),angle:h,radian:F(h)})}else{f=nt({x:n,y:i,width:c,height:l,angle:h});for(let t=0;t<r.length;t++){const{center:e,radian:n}=r[t];f=Q(e,f,n)}const t=H(f);if(h>0||h<0){f=Q(t,f,F(h))}r.push({center:t,angle:h,radian:F(h)})}e.push(f)}return e}function ot(t,e){const{groupQueue:n}=e;return n.length>0?rt([...n,t]):[it(t)]}function at(t,e){return ot(t,e).pop()||null}function st(t,e){const{viewScaleInfo:n}=e,{id:i,x:r,y:o,width:a,height:s,angle:c}=t,{scale:l=1,offsetTop:h=0,offsetLeft:f=0}=n;return{id:i,x:r*l+f,y:o*l+h,width:a*l,height:s*l,angle:c}}function ct(t,e){const{viewScaleInfo:n}=e,{x:i,y:r}=t,{scale:o,offsetTop:a,offsetLeft:s}=n;return{x:i*o+s,y:r*o+a}}function lt(t,e){const{context2d:n,material:i,viewScaleInfo:r}=e,{angle:o=0}=i,{x:a,y:s,width:c,height:l}=st(i,{viewScaleInfo:r}),h=G({x:a,y:s,width:c,height:l,angle:o});if(h.length>=2){n.beginPath(),n.moveTo(h[0].x,h[0].y);for(let t=1;t<h.length;t++)n.lineTo(h[t].x,h[t].y);n.closePath()}return!!n.isPointInPath(t.x,t.y)}function ht(t,e,n){const i=[e[0].x,e[1].x,e[2].x,e[3].x],r=[e[0].y,e[1].y,e[2].y,e[3].y],o=Math.min(...i),a=Math.max(...i),s=Math.min(...r),c=Math.max(...r);return t.x>o&&t.x<a&&t.y>s&&t.y<c||!0===n?.includeBorder&&(t.x===o||t.x===a||t.y===s||t.y===c)}function ft(t,e){const{groupQueue:n}=e,i=at(t,{groupQueue:n}),r=z(i[0],i[1]),o=z(i[1],i[2]),a=z(i[2],i[3]),s=z(i[3],i[0]),c=i[0],l=i[1],h=i[2],f=i[3],u=Math.max(c.x,l.x,h.x,f.x),d=Math.max(c.y,l.y,h.y,f.y);return{center:{x:(u+Math.min(c.x,l.x,h.x,f.x))/2,y:(d+Math.min(c.y,l.y,h.y,f.y))/2},topLeft:c,topRight:l,bottomLeft:f,bottomRight:h,top:r,right:o,left:s,bottom:a}}function ut(t,e){const{x:n,y:i}=t,{size:r,angle:o}=e;return{x:n-r/2,y:i-r/2,width:r,height:r,angle:o}}var dt=/([astvzqmhlc])([^astvzqmhlc]*)/gi,yt=/(-?\d+(?:\.\d+)?)/gi;function pt(t){const e=[];return t.replace(dt,(t,n,i)=>{const r=i.match(yt),o={type:n,params:r?r.map(Number):[]};return e.push(o),t}),e}var gt=/\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?(".*?"|'.*?')/g,xt=/<[a-zA-Z0-9\-\!\/](?:"[^"]*"|'[^']*'|[^'">])*>/g,mt=/^\s*$/,bt={};function wt(t){const e={type:"material",name:"",isVoid:!1,attributes:{},children:[]},n=t.match(/<\/?([^\s]+?)[/\s>]/);if(n&&(e.name=n[1],(bt[n[1]]||"/"===t.charAt(t.length-2))&&(e.isVoid=!0),e.name.startsWith("!--"))){const e=t.indexOf("--\x3e");return{type:"comment",name:null,attributes:{},children:[],isVoid:!1,comment:-1!==e?t.slice(4,e):""}}const i=new RegExp(gt);let r=null;for(;r=i.exec(t),null!==r;)if(r[0].trim())if(r[1]){const t=r[1].trim();let n=[t,""];t.indexOf("=")>-1&&(n=t.split("=")),e.attributes[n[0]]=n[1],i.lastIndex--}else r[2]&&(e.attributes[r[2]]=r[3].trim().substring(1,r[3].length-1));return e}function vt(t,e){switch(e.type){case"text":return t+e.textContent;case"material":return t+="<"+e.name+(e.attributes?function(t){const e=[];for(const n in t)e.push(n+"=\""+t[n]+"\"");return e.length?" "+e.join(" "):""}(e.attributes):"")+(e.isVoid?"/>":">"),e.isVoid?t:t+e.children.reduce(vt,"")+"</"+e.name+">";case"comment":return t+="\x3c!--"+e.comment+"--\x3e"}}function Mt(t,e){let n=2;return void 0!==e?.decimalPlaces&&e?.decimalPlaces>=0&&(n=e.decimalPlaces),parseFloat(t.toFixed(n))}function Pt(t){return t[1]!=-1*t[3]||t[4]!=t[0]||t[0]*t[4]-t[3]*t[1]!=1?null:Math.acos(t[0])}var Rt="Text",$t="#787878",kt=`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="${$t}"><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 St(){return{opacity:1,display:"inline",visibility:"visible",overflow:"visible",fill:$t,fillOpacity:1,fillRule:"nonzero",stroke:"#525252",strokeWidth:0,strokeOpacity:1,strokeLinecap:"butt",strokeLinejoin:"miter",strokeDasharray:[],strokeDashoffset:0,strokeMiterlimit:0,text:Rt,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:kt}}function Ct(){return{fill:St().fill}}function At(t,e="",n={},i){return Object.keys(t).forEach(r=>{const o=e?`${e}${function(t){return/^\d+$/.test(t)&&!isNaN(Number(t))}(r)?`[${r}]`:`.${r}`}`:r;if(!i?.ignorePaths?.includes(o)){const e=t[r];!function(t){return"object"==typeof t&&null!==t&&!(t instanceof Date)||Array.isArray(t)}(e)?n[o]=e:At(e,(Array.isArray(e),o),n,i)}}),n}function Lt(t,e){return"object"!=typeof t||null===t?{"":t}:At(t,"",{},e)}function It(t){return Lt(t,{ignorePaths:["children"]})}function zt(t){return Lt(t)}function Et(t){return Lt(t)}function Ot(t){return Array.isArray(t)?[...t]:t.split(/\.|\[|\]/).filter(t=>""!==t)}function Tt(t,e,n){const i=Ot(e);if(0===i.length)return t;let r=t;if(r)for(let t=0;t<i.length;t++){const e=i[t];if(t===i.length-1){r[e]=n;break}if(r&&(void 0===r?.[e]||"object"!=typeof r?.[e]||null===r?.[e])){const n=i[t+1],o=/^\d+$/.test(n);r[e]=o?[]:{}}r=r?.[e]}return t}function jt(t,e){const n=Ot(e);if(0===n.length)return t;let i=t;if(i)for(let t=0;t<n.length;t++){const e=n[t];if(t===n.length-1){delete i[e];break}if(i&&(void 0===i?.[e]||"object"!=typeof i?.[e]||null===i?.[e])){const r=n[t+1],o=/^\d+$/.test(r);i[e]=o?[]:{}}i=i?.[e]}return t}var Wt=t=>Mt(t,{decimalPlaces:4});function Dt(t,e){const n={},i={},r={type:"modifyMaterial",time:Date.now(),content:{method:"modifyMaterial",id:t.id,before:null,after:null}},{xRatio:o,yRatio:a,maxRatio:s}=e,c=(o+a)/2,{strokeWidth:l,cornerRadius:h,strokeDasharray:f,shadowOffsetX:u,shadowOffsetY:d,shadowBlur:y}=t;if("number"==typeof l)t.strokeWidth=Wt(l*c),n.strokeWidth=l,i.strokeWidth=t.strokeWidth;else if(Array.isArray(t.strokeWidth)){const e=l;t.strokeWidth=[Wt(e[0]*a),Wt(e[1]*o),Wt(e[2]*a),Wt(e[3]*o)],n.strokeWidth=[...e],i.strokeWidth=[...l]}if("number"==typeof h)t.cornerRadius=Wt(h*c),n.cornerRadius=h,i.cornerRadius=t.cornerRadius;else if(Array.isArray(t.cornerRadius)){const e=h;t.cornerRadius=[e[0]*o,e[1]*o,e[2]*a,e[3]*a],n.cornerRadius=[...e],i.cornerRadius=[...h]}return Array.isArray(f)&&(f.forEach((e,n)=>{t.strokeDasharray[n]=Wt(e*s)}),n.strokeDasharray=[...f],i.strokeDasharray=[...t.strokeDasharray]),"number"==typeof u&&(t.shadowOffsetX=Wt(u*s),n.shadowOffsetX=u,i.shadowOffsetX=t.shadowOffsetX),"number"==typeof d&&(t.shadowOffsetY=Wt(d*s),n.shadowOffsetY=d,i.shadowOffsetY=t.shadowOffsetY),"number"==typeof y&&(t.shadowBlur=Wt(y*s),n.shadowBlur=y,i.shadowBlur=t.shadowBlur),r.content.before=It(n),r.content.after=It(i),r}function Ft(t,e,n){const{type:i,id:r}=t,o=function(t,e){const{xRatio:n,yRatio:i}=e,{id:r,x:o,y:a,width:s,height:c}=t;t.x=Wt(o*n),t.y=Wt(a*i),t.width=Wt(s*n),t.height=Wt(c*i);const l={type:"modifyMaterial",time:Date.now(),content:{method:"modifyMaterial",id:r,before:{x:o,y:a,width:s,height:c},after:{x:t.x,y:t.y,width:t.width,height:t.height}}},h=Dt(t,e);return l.content.before={...l.content.before,...h.content.before},l.content.after={...l.content.after,...h.content.after},l}(t,e),a={...o.content.before,id:r},s={...o.content.after,id:r};if(n?.content.before.push(a),n?.content.after.push(s),"circle"===i);else if("text"===i){const n=function(t,e){const{minRatio:n,maxRatio:i}=e,{fontSize:r,lineHeight:o}=t,a=(n+i)/2,s={},c={};return r&&r>0&&(t.fontSize=Wt(r*a),s.fontSize=r,c.fontSize=t.fontSize),o&&o>0&&(t.lineHeight=Wt(o*a),s.lineHeight=o,c.lineHeight=t.lineHeight),{type:"modifyMaterial",time:Date.now(),content:{method:"modifyMaterial",id:t.id,before:s,after:c}}}(t,e);Object.keys(n.content.before||{}).forEach(t=>{a[t]=n.content.before?.[t]}),Object.keys(n.content.after||{}).forEach(t=>{s[t]=n.content.after?.[t]})}else"image"===i||"svgCode"===i||"foreignObject"===i||"path"===i||"group"===i&&Array.isArray(t.children)&&t.children.forEach(t=>{Ft(t,e,n)})}function Vt(t,e,n){const i={type:"resizeMaterials",time:Date.now(),content:{method:"modifyMaterials",before:[],after:[]}},r=t.id,o=t.x,a=t.y,s=t.width,c=t.height,l=f.number(e.x)?e.x:t.x,h=f.number(e.y)?e.y:t.y,u=(e.width&&e.width>0?e.width:t.width)||0,d=(e.height&&e.height>0?e.height:t.height)||0,y={id:r,x:o,y:a,width:s,height:c},p={id:r,x:l,y:h,width:u,height:d};if("deepResize"===n?.resizeEffect){i.content.before.push(y),i.content.after.push(p);const e=u/t.width,n=d/t.height;if(e===n&&1===e)return i;const r=Math.min(e,n),o=Math.max(e,n);t.width=u,t.height=d;const a={xRatio:e,yRatio:n,minRatio:r,maxRatio:o};"group"===t.type&&Array.isArray(t.children)&&t.children.forEach(t=>{Ft(t,a,i)});const s=Dt(t,a);return Object.keys(s.content.before||{}).forEach(t=>{y[t]=s.content.before?.[t]}),Object.keys(s.content.after||{}).forEach(t=>{p[t]=s.content.after?.[t]}),i}if("fixed"===n?.resizeEffect){i.content.before.push(y),i.content.after.push(p);const e=l-t.x,n=h-t.y,r=u-t.width;return function(t,e,n){if("group"!==t.type||!Array.isArray(t.children))return;const{moveX:i,moveY:r,moveH:o,moveW:a}=e;let s=0,c=0,l=!1;0===i&&0===r||0===o&&0===a||(l=!0,s=-i,c=-r),!0===l&&t.children.forEach(t=>{const{id:e,x:i,y:r}=t,o=i+s,a=r+c,l={id:e,x:i,y:r},h={id:e,x:o,y:a};t.x=o,t.y=a,n?.content.before.push(l),n?.content.after.push(h)})}(t,{moveX:e,moveY:n,moveH:d-t.height,moveW:r},i),t.width=u,t.height=d,t.x=l,t.y=h,i}return t.width=u,t.height=d,t.x=l,t.y=h,i.content.before.push(y),i.content.after.push(p),i}function Bt(t,e,n){let i=!1;if(1===e.length){const r=e[0];n.splice(r,0,t),i=!0}else if(e.length>1){let r=n;for(let n=0;n<e.length;n++){const o=r[e[n]];if(n===e.length-1){const o=e[n];r.splice(o,0,t),i=!0}else{if(!(n<e.length-1&&"group"===o.type))break;r=o.children}}}return i}function Ht(t,e){let n=!1;if(1===t.length){const i=t[0];e.splice(i,1),n=!0}else if(t.length>1){let i=e;for(let e=0;e<t.length;e++){const r=i[t[e]];if(e===t.length-1){const r=t[e];i.splice(r,1),n=!0}else{if(!(e<t.length-1&&"group"===r.type))break;i=r.children}}}return n}function Nt(t,e,n){const i=It(e),r=["id","type"],o=Object.keys(i);if(o.forEach(e=>{if(!r.includes(e)){const n=i[e];jt(t,e),void 0!==n&&Tt(t,e,n)}}),!0===n?.onlyUpdateContent){const e=It(t);Object.keys(e).forEach(e=>{r.includes(e)||o.includes(e)||jt(t,e)})}return t.fill&&(t.fill=function(t){if(Array.isArray(t?.stops)){const e=[],n=t?.stops;for(let t=n.length-1;t>=0;t--){const i=n[t];i.color&&i.offset>=0||e.push(t)}e.forEach(t=>{n.splice(t,1)})}return t}(t.fill)),t}var Xt=["-apple-system","\"system-ui\""," \"Segoe UI\""," Roboto","\"Helvetica Neue\"","Arial","\"Noto Sans\""," sans-serif"];function Ut(t){const e=[...t.from],n=[...t.to];if(0===e.length||0===n.length)return null;if(e.length<=n.length)for(let t=0;t<e.length;t++)if(n[t]===e[t]){if(t===e.length-1)return null;continue}let i=null;if(e.length>=1&&n.length>=1){if(e.length<=n.length)if(1===e.length)e[0]<n[0]&&(i="up-down");else for(let t=0;t<e.length&&e[t]===n[t];t++)if(e.length===e.length-1){i="up-down";break}if(e.length>=n.length)if(1===n.length)n[0]<e[0]&&(i="down-up");else for(let t=0;t<n.length&&(t===n.length-1&&n[t]<e[t]&&(i="down-up"),e[t]===n[t]);t++);}const r=e.length-1,o=n.length-1;return"up-down"===i&&r>=0?n[r]-=1:"down-up"===i&&o>=0&&(e[o]+=1),{from:e,to:n}}function Yt(t){let e=1/0,n=1/0,i=-1/0,r=-1/0,o={x:0,y:0},a={x:0,y:0},s=null;const c=t=>{e=Math.min(e,t.x),n=Math.min(n,t.y),i=Math.max(i,t.x),r=Math.max(r,t.y)};for(const e of t){const{type:t,params:n}=e,i=t===t.toLowerCase();switch(t.toLowerCase()){case"m":if(n.length>=2)for(let t=0;t<n.length;t+=2){let e=n[t],r=n[t+1];i&&(e+=o.x,r+=o.y),0===t&&(a={x:e,y:r}),o={x:e,y:r},c(o)}s=null;break;case"l":if(n.length>=2)for(let t=0;t<n.length;t+=2){let e=n[t],r=n[t+1];i&&(e+=o.x,r+=o.y),o={x:e,y:r},c(o)}s=null;break;case"h":for(let t=0;t<n.length;t++){let e=n[t];i&&(e+=o.x),o={x:e,y:o.y},c(o)}s=null;break;case"v":for(let t=0;t<n.length;t++){let e=n[t];i&&(e+=o.y),o={x:o.x,y:e},c(o)}s=null;break;case"c":if(n.length>=6)for(let t=0;t<n.length;t+=6){let e=n[t],r=n[t+1],a=n[t+2],l=n[t+3],h=n[t+4],f=n[t+5];i&&(e+=o.x,r+=o.y,a+=o.x,l+=o.y,h+=o.x,f+=o.y),s={x:a,y:l},Gt(o.x,o.y,e,r,a,l,h,f).forEach(c),c({x:h,y:f}),o={x:h,y:f}}break;case"s":if(n.length>=4)for(let t=0;t<n.length;t+=4){let e=n[t],r=n[t+1],a=n[t+2],l=n[t+3];const h=s?2*o.x-s.x:o.x,f=s?2*o.y-s.y:o.y;i&&(e+=o.x,r+=o.y,a+=o.x,l+=o.y),s={x:e,y:r},Gt(o.x,o.y,h,f,e,r,a,l).forEach(c),c({x:a,y:l}),o={x:a,y:l}}break;case"q":if(n.length>=4)for(let t=0;t<n.length;t+=4){let e=n[t],r=n[t+1],a=n[t+2],l=n[t+3];i&&(e+=o.x,r+=o.y,a+=o.x,l+=o.y),s={x:e,y:r},Qt(o.x,o.y,e,r,a,l).forEach(c),c({x:a,y:l}),o={x:a,y:l}}break;case"t":if(n.length>=2)for(let t=0;t<n.length;t+=2){let e=n[t],r=n[t+1];const a=s?2*o.x-s.x:o.x,l=s?2*o.y-s.y:o.y;i&&(e+=o.x,r+=o.y),s={x:a,y:l},Qt(o.x,o.y,a,l,e,r).forEach(c),c({x:e,y:r}),o={x:e,y:r}}break;case"a":if(n.length>=7)for(let t=0;t<n.length;t+=7){const e=Math.abs(n[t]),r=Math.abs(n[t+1]),a=n[t+2],l=n[t+3],h=n[t+4];let f=n[t+5],u=n[t+6];i&&(f+=o.x,u+=o.y),qt(o.x,o.y,e,r,a,l,h,f,u).forEach(c),o={x:f,y:u},s=null}break;case"z":o={...a},c(o),s=null}}e===1/0&&(e=n=i=r=0);return{minX:e,minY:n,maxX:i,maxY:r,width:i-e,height:r-n,start:{x:e,y:n},end:{x:i,y:r}}}function Gt(t,e,n,i,r,o,a,s){const c=[];c.push({x:t,y:e}),c.push({x:a,y:s});const l=Zt(3*(3*n-t-3*r+a),6*(t-2*n+r),3*(n-t));for(const h of l)if(h>0&&h<1){const l=Jt(h,t,n,r,a),f=Jt(h,e,i,o,s);c.push({x:l,y:f})}const h=Zt(3*(3*i-e-3*o+s),6*(e-2*i+o),3*(i-e));for(const l of h)if(l>0&&l<1){const h=Jt(l,t,n,r,a),f=Jt(l,e,i,o,s);c.push({x:h,y:f})}return c}function Qt(t,e,n,i,r,o){const a=[];a.push({x:t,y:e}),a.push({x:r,y:o});const s=t-2*n+r;if(0!==s){const c=-(2*(n-t))/(2*s);if(c>0&&c<1){const s=_t(c,t,n,r),l=_t(c,e,i,o);a.push({x:s,y:l})}}const c=e-2*i+o;if(0!==c){const s=-(2*(i-e))/(2*c);if(s>0&&s<1){const c=_t(s,t,n,r),l=_t(s,e,i,o);a.push({x:c,y:l})}}return a}function qt(t,e,n,i,r,o,a,s,c){const l=[],h=r*Math.PI/180,f=Math.cos(h),u=Math.sin(h),d=(t+s)/2,y=(e+c)/2,p=(t-s)/2,g=(e-c)/2,x=f*p+u*g,m=-u*p+f*g;let b=n,w=i;const v=x*x,M=m*m,P=v/(n*n)+M/(i*i);P>1&&(b=Math.sqrt(P)*n,w=Math.sqrt(P)*i);const R=o===a?-1:1,$=Math.max(0,b*b*w*w-b*b*M-w*w*v),k=b*b*M+w*w*v;let S=R*Math.sqrt($/k);isNaN(S)&&(S=0);const C=S*(b*m/w),A=S*(-w*x/b),L=f*C-u*A+d,I=u*C+f*A+y,z=Math.atan2((m-A)/w,(x-C)/b);let E=Math.atan2((-m-A)/w,(-x-C)/b)-z;0===a&&E>0?E-=2*Math.PI:1===a&&E<0&&(E+=2*Math.PI);for(let t=0;t<=100;t++){const e=z+t/100*E,n=L+b*Math.cos(e)*f-w*Math.sin(e)*u,i=I+b*Math.cos(e)*u+w*Math.sin(e)*f;l.push({x:n,y:i})}return l}function Zt(t,e,n){const i=[];if(0===t){if(0!==e){const t=-n/e;t>=0&&t<=1&&i.push(t)}return i}const r=e*e-4*t*n;if(r>0){const n=Math.sqrt(r),o=(-e+n)/(2*t),a=(-e-n)/(2*t);o>=0&&o<=1&&i.push(o),a>=0&&a<=1&&i.push(a)}else if(0===r){const n=-e/(2*t);n>=0&&n<=1&&i.push(n)}return i}function Jt(t,e,n,i,r){const o=1-t;return o*o*o*e+3*o*o*t*n+3*o*t*t*i+t*t*t*r}function _t(t,e,n,i){const r=1-t;return r*r*e+2*r*t*n+t*t*i}var Kt=()=>Math.random().toString(36).substring(2);function te(){return`${Kt()}${Kt()}`.substring(0,16)}function ee(t,e,n){const{type:i}=t,r=[...t.params],o=t.id;let a={id:o};if(t.start&&t.end){const i={...t.start},r={...t.end};i.x+=e,i.y+=n,r.x+=e,r.y+=n,a={id:o,start:i,end:r}}switch(i){case"M":case"L":case"T":return r[0]+=e,r[1]+=n,{type:i,params:r,...a};case"H":return r[0]+=e,{type:i,params:r,...a};case"V":return r[0]+=n,{type:i,params:r,...a};case"C":return r[0]+=e,r[1]+=n,r[2]+=e,r[3]+=n,r[4]+=e,r[5]+=n,{type:i,params:r,...a};case"S":case"Q":return r[0]+=e,r[1]+=n,r[2]+=e,r[3]+=n,{type:i,params:r,...a};case"A":return r[5]+=e,r[6]+=n,{type:i,params:r,...a};default:return{type:i,params:r,...a}}}function ne(t,e,n){const i=[];return t.forEach(t=>{const r=ee(t,e,n);i.push(r)}),i}function ie(t){const e=[];let n={x:0,y:0},i={x:0,y:0},r=null;for(const o of t){const t=o.type,a=o.params,s=t===t.toLowerCase(),c=t.toUpperCase(),l=o.id;switch(c){case"M":{const[t,o]=a,c=s?{x:n.x+t,y:n.y+o}:{x:t,y:o};e.push({id:l,type:"M",params:[c.x,c.y],start:{x:t,y:o},end:{x:t,y:o}}),n=c,i=c,r=null;break}case"L":{const[t,i]=a,o=s?{x:n.x+t,y:n.y+i}:{x:t,y:i};e.push({id:l,type:"L",params:[o.x,o.y],start:{...n},end:{...o}}),n=o,r=null;break}case"H":{const[t]=a,i=s?{x:n.x+t,y:n.y}:{x:t,y:n.y};e.push({id:l,type:"L",params:[i.x,i.y],start:{...n},end:{...i}}),n=i,r=null;break}case"V":{const[t]=a,i=s?{x:n.x,y:n.y+t}:{x:n.x,y:t};e.push({id:l,type:"L",params:[i.x,i.y],start:{...n},end:{...i}}),n=i,r=null;break}case"C":{const[t,i,o,c,h,f]=a,u=s?{x:n.x+t,y:n.y+i}:{x:t,y:i},d=s?{x:n.x+o,y:n.y+c}:{x:o,y:c},y=s?{x:n.x+h,y:n.y+f}:{x:h,y:f};e.push({id:l,type:"C",params:[u.x,u.y,d.x,d.y,y.x,y.y],start:{...n},end:{...y}}),n=y,r=d;break}case"S":{const[t,i,o,c]=a,h=r?{x:2*n.x-r.x,y:2*n.y-r.y}:n,f=s?{x:n.x+t,y:n.y+i}:{x:t,y:i},u=s?{x:n.x+o,y:n.y+c}:{x:o,y:c};e.push({id:l,type:"C",params:[h.x,h.y,f.x,f.y,u.x,u.y],start:{...n},end:{...u}}),n=u,r=f;break}case"Q":{const[t,i,o,c]=a,h=s?{x:n.x+t,y:n.y+i}:{x:t,y:i},f=s?{x:n.x+o,y:n.y+c}:{x:o,y:c};e.push({id:l,type:"C",params:[n.x+2/3*(h.x-n.x),n.y+2/3*(h.y-n.y),f.x+2/3*(h.x-f.x),f.y+2/3*(h.y-f.y),f.x,f.y],start:{...n},end:{...f}}),n=f,r=h;break}case"T":{const[t,i]=a,o=s?{x:n.x+t,y:n.y+i}:{x:t,y:i},c=r?{x:2*n.x-r.x,y:2*n.y-r.y}:n;e.push({id:l,type:"C",params:[n.x+2/3*(c.x-n.x),n.y+2/3*(c.y-n.y),o.x+2/3*(c.x-o.x),o.y+2/3*(c.y-o.y),o.x,o.y],start:{...n},end:{...o}}),n=o,r=c;break}case"A":{const[t,i,o,c,h,f,u]=a,d=s?{x:n.x+f,y:n.y+u}:{x:f,y:u};e.push({id:l,type:"A",params:[t,i,o,c,h,d.x,d.y],start:{...n},end:{...d}}),n=d,r=null;break}case"Z":e.push({id:l,type:"Z",params:[],start:{...n},end:{...i}}),n=i,r=null;break;default:throw new Error(`Unsupported command: ${t}`)}}return e}var re={className:"class"},oe=["width","height","left","right","top","bottom","margin","marginLeft","marginRight","marginTop","marginBottom","padding","paddingLeft","paddingRight","paddingTop","paddingBottom"];function ae(t,e){e.forEach(e=>{e&&e.trim().split(" ").forEach(e=>{e&&!t.classList.contains(e)&&t.classList.add(e)})})}function se(t,e){return Object.keys(e).forEach(n=>{const i=e[n];t.style[n]=((t,e)=>"number"==typeof e&&oe.includes(t)?`${e}px`:e)(n,i)}),t}function ce(t,e,n){const{children:i,...r}=e||{},o=n||i;return function(t,e){Object.entries(e).forEach(([e,n])=>{const i=re[e]?re[e]:e,r=i.replace(/([A-Z])/g,"-$1").toLowerCase(),o=n;if("style"===i)f.json(n)?se(t,n):"string"==typeof n&&t.setAttribute(r,n);else if("class"===i&&"string"==typeof n)ae(t,n.split(" "));else{let e=o;null==e&&(e=""),t.setAttribute(r,String(e))}})}(t,r||{}),Array.isArray(o)?o?.forEach(e=>{(e instanceof Element||"string"==typeof e)&&t.append(e)}):(o instanceof Element||"string"==typeof o)&&t.append(o),t}function le(t){return t.replace(/<(script|iframe|object|embed)\b[^<]*(?:(?!<\/\1>)<[^<]*)*<\/\1>/gi,"")}var he=(t,e,n)=>{let i=t;const r=Object.keys(n),o=()=>{if(!i)return!1;for(let t=0;t<r.length;t++){const e=r[t],o=n[e];if("string"==typeof e&&e&&"string"==typeof o&&o){if("className"===e&&i?.classList.contains(o))continue;if(i.getAttribute(e)===o)continue;return!1}if("string"==typeof e&&e&&"boolean"==typeof o){if(i.hasAttribute(e)&&!0===o)continue;return!1}}return!0};for(;i;){if(o())return i;if(e===i)return null;if(!e.contains(i))return null;i=i.parentElement}return null};var fe=["width","height","left","right","top","bottom","margin","marginLeft","marginRight","marginTop","marginBottom","padding","paddingLeft","paddingRight","paddingTop","paddingBottom"],ue=(t,e)=>fe.includes(t)?`${e}px`:e;function de(t){return t.replace(/[A-Z]/g,t=>"-"+t.toLowerCase())}function ye(t,e){const n=[],i=[];for(const r in t){let o=t[r];if("number"==typeof o&&(o=ue(r,o)),r.startsWith("@"))i.push(`${r} { ${ye(o,e)} }`);else if(r.startsWith("&")||r.startsWith(".")||r.startsWith("#")){const t=r.startsWith("&")?r.replace("&",e):`${e} ${r}`;i.push(ye(o,t))}else n.push(`${de(r)}: ${o};`)}return[n.length?`${e} { ${n.join(" ")} }`:"",...i].filter(Boolean).join("\n")}var pe="data-idraw-style-id",ge={};function xe(t){const e=/([\w-]+)|\[(\d+)\]/g,n=[];let i;for(;null!==(i=e.exec(t));){const t=i[1]||i[2];t&&n.push(t)}return n}function me(t,e,n){let i=t;for(let t=0;t<e.length;t++){const r=e[t],o=be(r),a=t===e.length-1;try{o?we(i,r):ve(i,r)}catch(n){throw new Error(`Structure conflict at path '${e.slice(0,t+1).join(".")}': ${n.message}`)}a?Pe(i,r,n):i=Me(i,r,e[t+1])}}function be(t){return/^\d+$/.test(t)}function we(t,e){if(!Array.isArray(t))throw new Error("Expected array but found "+typeof t);const n=Number(e);n>t.length&&(t.length=n+1)}function ve(t,e){if(Array.isArray(t))throw new Error(`Cannot create object property '${e}' on array`);if("object"!=typeof t||null===t)throw new Error(`Invalid structure for property '${e}'`)}function Me(t,e,n){const i=!!n&&be(n);if(Array.isArray(t)){const n=Number(e);return t[n]||(t[n]=i?[]:{}),t[n]}return t[e]||(t[e]=i?[]:{}),t[e]}function Pe(t,e,n){if(Array.isArray(t)){const i=Number(e);i>=t.length&&(t.length=i+1),t[i]=n}else t[e]=n}var Re={svg:"group",g:"group"},$e=["x","y","width","height","angle","id","name","transform","opacity","display","visibility","overflow","fill","fillOpacity","fillRule","stroke","strokeWidth","strokeOpacity","strokeLinecap","strokeLinejoin","strokeDasharray","strokeDashoffset","strokeMiterlimit","fontSize","fontFamily","fontWeight","fontStyle","textAnchor","textDecoration","letterSpacing","wordSpacing","writingMode","textAlign","verticalAlign","cornerRadius","commands","children","rx","ry","cx","cy","r"],ke=["strokeDasharray"],Se=["x","y","width","height","opacity","fillOpacity","strokeWidth","strokeOpacity","strokeDashoffset","fontSize","fontWeight","rx","ry","cx","cy","r"];function Ce(t){return t.replace(/-([a-z])/g,(t,e)=>e.toUpperCase())}function Ae(t,e,n){t[e]=function(t,e){return Se.includes(t)&&/^[0-9.]{0,}$/.test(e)?parseFloat(e):ke.includes(t)?e.match(/[0-9.]{0,}/g)?.filter(t=>!!t).map(t=>parseFloat(t)):e}(e,n)}function Le(t,e){for(let n=0;n<t.attributes.length;n++){const i=t.attributes[n],r=Ce(i.name);$e.includes(r)&&Ae(e,r,i.value)}e.id||(e.id=r());const n=t.getAttribute("style");n&&function(t,e){const n=t.split(";");for(const t of n){const[n,i]=t.split(":").map(t=>t.trim());n&&i&&Ae(e,Ce(n),i)}}(n,e),function(t,e){const n=t.getAttribute("transform");n&&Ae(e,"transform",n)}(t,e)}function Ie(t){const e=t.tagName,n={type:Re[e]||e,children:[]};if("svg"===e){const e=(t.getAttribute("viewBox")||"").split(" "),i=[];e.length&&e.forEach(t=>{const e=parseFloat(t);(e>=0||e<0)&&i.push(e)}),i.length>=4&&(n.x=i[0],n.y=i[1],n.width=i[2],n.height=i[3])}Le(t,n);const i=function(t){let e="";for(const n of Array.from(t.childNodes))n.nodeType===Node.TEXT_NODE&&(e+=n.textContent?.trim()||"");return e}(t);i&&(n.text=i),n.children=[];for(let e=0;e<t.children.length;e++){const i=Ie(t.children[e]);i&&n.children.push(i)}return n}function ze(t){return Oe(t)}var Ee={group:"g"};function Oe(t,e="",n=0){const i=Ee[t.type]||t.type,r=function(t){const e=["type","children","textContent"],n=[];for(const i in t){if(e.includes(i))continue;const r=t[i];if(null!=r){const t=Te(i);n.push(`${t}="${je(String(r))}"`)}}return n.length>0?" "+n.join(" "):""}(t),o=t.children||[],a=t.text||"";if(["circle","rect","path","line","polygon","polyline","ellipse","use"].includes(i)&&0===o.length&&!a)return`${e}<${i}${r} />`;let s=`${e}<${i}${r}`;if(0!==o.length||a){if(s+=">",a&&(s+=function(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}(a)),o.length>0){const t=e+" ";s+="\n",s+=o.map(e=>Oe(e,t,n+1)).join("\n"),s+=`\n${e}`}s+=`</${i}>`}else s+=`></${i}>`;return s}function Te(t){return t.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g,"$1-$2").toLowerCase()}function je(t){return t.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/'/g,"&apos;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}return t.ATTR_VALID_WATCH="data-idraw-valid-watch",t.Context2D=C,t.EventEmitter=class{#n;constructor(){this.#n=new Map}on(t,e){if(this.#n.has(t)){const n=this.#n.get(t)||[];n?.push(e),this.#n.set(t,n)}else this.#n.set(t,[e])}off(t,e){if(this.#n.has(t)){const n=this.#n.get(t);if(Array.isArray(n))for(let t=0;t<n?.length;t++)if(n[t]===e){n.splice(t,1);break}this.#n.set(t,n||[])}}trigger(t,e){const n=this.#n.get(t);return!!Array.isArray(n)&&(n.forEach(t=>{t(e)}),!0)}has(t){if(this.#n.has(t)){const e=this.#n.get(t);if(Array.isArray(e)&&e.length>0)return!0}return!1}destroy(){this.clear()}clear(){this.#n.clear()}},t.Store=class{#i;#r;#o;constructor(t){this.#r=c(t.defaultStorage),this.#i=this.#a(),this.#o=t.defaultStatic||{}}set(t,e){this.#i[t]=e}get(t){return this.#i[t]}setStatic(t,e){this.#o[t]=e}getStatic(t){return this.#o[t]}getSnapshot(t){return!0===t?.deepClone?c(this.#i):{...this.#i}}clear(){this.#i=this.#a()}destroy(){this.#i=null,this.#o=null}#a(){return c(this.#r)}},t.addClassName=ae,t.assembleHTMLElement=ce,t.boundingInfoToRangeBoundingInfo=function(t){const e=Math.max(t.topLeft.x,t.topRight.x,t.bottomRight.x,t.bottomLeft.x),n=Math.max(t.topLeft.y,t.topRight.y,t.bottomRight.y,t.bottomLeft.y),i=Math.min(t.topLeft.x,t.topRight.x,t.bottomRight.x,t.bottomLeft.x),r=Math.min(t.topLeft.y,t.topRight.y,t.bottomRight.y,t.bottomLeft.y),o={x:t.center.x,y:t.center.y},a={x:i,y:r},s={x:e,y:r},c={x:e,y:n},l={x:i,y:n},h=z(a,s),f=z(l,c),u=z(a,l);return{center:o,topLeft:a,topRight:s,bottomLeft:l,bottomRight:c,top:h,right:z(s,c),left:u,bottom:f}},t.bubbleHTMLElement=he,t.calcDistance=I,t.calcLayoutSizeController=function(t,e){const{controllerSize:n,viewScaleInfo:i}=e,r=n&&n>0?n:8,{x:o,y:a,width:s,height:c}=st(t,{viewScaleInfo:i}),l=B({x:o,y:a,width:s,height:c}),h={x:l.x,y:a},f={x:o+s,y:l.y},u={x:l.x,y:a+c},d={x:o,y:l.y},y={x:o,y:a},p={x:o+s,y:a},g={x:o+s,y:a+c},x={x:o,y:a+c},m=ut(h,{size:r,angle:0}),b=ut(f,{size:r,angle:0}),w=ut(u,{size:r,angle:0}),v=ut(d,{size:r,angle:0}),M=ut(y,{size:r,angle:0}),P=ut(p,{size:r,angle:0}),R=ut(x,{size:r,angle:0}),$=ut(g,{size:r,angle:0}),k=it(M),S=it(P),C=it(R),A=it($),L=[k[1],S[0],S[3],k[2]],I=[S[3],S[2],A[1],A[0]],z=[C[1],A[0],A[3],C[2]],E=[k[3],k[2],C[1],C[0]],O=it(m),T=it(b),j=it(w);return{left:{type:"left",vertexes:E,center:d,size:r},right:{type:"right",vertexes:I,center:f,size:r},top:{type:"top",vertexes:L,center:h,size:r},bottom:{type:"bottom",vertexes:z,center:u,size:r},topLeft:{type:"top-left",vertexes:k,center:y,size:r},topRight:{type:"top-right",vertexes:S,center:p,size:r},bottomLeft:{type:"bottom-left",vertexes:C,center:x,size:r},bottomRight:{type:"bottom-right",vertexes:A,center:g,size:r},leftMiddle:{type:"left-middle",vertexes:it(v),center:d,size:r},rightMiddle:{type:"right-middle",vertexes:T,center:f,size:r},topMiddle:{type:"top-middle",vertexes:O,center:h,size:r},bottomMiddle:{type:"bottom-middle",vertexes:j,center:u,size:r}}},t.calcMaterialBoundingInfo=ft,t.calcMaterialCenter=B,t.calcMaterialCenterFromVertexes=H,t.calcMaterialListSize=Z,t.calcMaterialQueueVertexesQueueInGroup=rt,t.calcMaterialSizeController=function(t,e){const{groupQueue:n,controllerSize:i,viewScaleInfo:o,rotateControllerSize:a,rotateControllerPosition:s}=e,c=(i&&i>0?i:8)/o.scale,{x:l,y:h,width:f,height:u,angle:d=0}=t,y=a,p=s,g=[{id:r(),x:l,y:h,width:f,height:u,angle:d,type:"group",children:[]},...n];let x=0;g.forEach(({angle:t=0})=>{x+=t});const m=at(t,{groupQueue:n}),b=at({x:l,y:h-(p+y/2)/o.scale,height:u+(2*p+y)/o.scale,width:f,angle:d},{groupQueue:[...n]}),w=z(m[0],m[1]),v=z(m[1],m[2]),M=z(m[2],m[3]),P=z(m[3],m[0]),R=m[0],$=m[1],k=m[2],S=m[3],C=ut(w,{size:c,angle:x}),A=ut(v,{size:c,angle:x}),L=ut(M,{size:c,angle:x}),I=ut(P,{size:c,angle:x}),E=ut(R,{size:c,angle:x}),O=ut($,{size:c,angle:x}),T=ut(S,{size:c,angle:x}),j=ut(k,{size:c,angle:x}),W=it(E),D=it(O),F=it(T),V=it(j),H=[W[1],D[0],D[3],W[2]],N=[D[3],D[2],V[1],V[0]],X=[F[1],V[0],V[3],F[2]],U=[W[3],W[2],F[1],F[0]],Y=it(C),G=it(A),Q=it(L),q=it(I),Z=z(b[0],b[1]),J=it(ut(Z,{size:1.1*a/o.scale,angle:x}));return{originalMaterialCenter:B(t),originalMaterialSize:{...t},materialWrapper:m,left:{type:"left",vertexes:U,center:P,size:c},right:{type:"right",vertexes:N,center:v,size:c},top:{type:"top",vertexes:H,center:w,size:c},bottom:{type:"bottom",vertexes:X,center:M,size:c},topLeft:{type:"top-left",vertexes:W,center:R,size:c},topRight:{type:"top-right",vertexes:D,center:$,size:c},bottomLeft:{type:"bottom-left",vertexes:F,center:S,size:c},bottomRight:{type:"bottom-right",vertexes:V,center:k,size:c},leftMiddle:{type:"left-middle",vertexes:q,center:P,size:c},rightMiddle:{type:"right-middle",vertexes:G,center:v,size:c},topMiddle:{type:"top-middle",vertexes:Y,center:w,size:c},bottomMiddle:{type:"bottom-middle",vertexes:Q,center:M,size:c},rotate:{type:"rotate",vertexes:J,center:Z,size:a}}},t.calcMaterialVertexesInGroup=at,t.calcMaterialVertexesQueueInGroup=ot,t.calcMaterialViewBoundingInfo=function(t,e){const{groupQueue:n,viewScaleInfo:i,range:r}=e,{center:o,top:a,bottom:s,left:c,right:l,topLeft:h,topRight:f,bottomLeft:u,bottomRight:d}=ft(t,{groupQueue:n}),y={center:ct(o,{viewScaleInfo:i}),topLeft:ct(h,{viewScaleInfo:i}),topRight:ct(f,{viewScaleInfo:i}),bottomLeft:ct(u,{viewScaleInfo:i}),bottomRight:ct(d,{viewScaleInfo:i}),top:ct(a,{viewScaleInfo:i}),right:ct(l,{viewScaleInfo:i}),left:ct(c,{viewScaleInfo:i}),bottom:ct(s,{viewScaleInfo:i})};if(!0===r){const t=Math.max(y.topLeft.x,y.topRight.x,y.bottomRight.x,y.bottomLeft.x),e=Math.max(y.topLeft.y,y.topRight.y,y.bottomRight.y,y.bottomLeft.y),n=Math.min(y.topLeft.x,y.topRight.x,y.bottomRight.x,y.bottomLeft.x),i=Math.min(y.topLeft.y,y.topRight.y,y.bottomRight.y,y.bottomLeft.y),r={x:y.center.x,y:y.center.y},o={x:n,y:i},a={x:t,y:i},s={x:t,y:e},c={x:n,y:e},l=z(o,a),h=z(c,s),f=z(o,c);return{center:r,topLeft:o,topRight:a,bottomLeft:c,bottomRight:s,top:l,right:z(a,s),left:f,bottom:h}}return y},t.calcMaterialsContextSize=J,t.calcMaterialsViewInfo=function(t,e,n){const i=J(t,{viewWidth:e.width,viewHeight:e.height,extend:n?.extend});return!0===n?.extend&&(i.contextWidth=Math.max(i.contextWidth,e.contextWidth),i.contextHeight=Math.max(i.contextHeight,e.contextHeight)),{contextSize:i}},t.calcPathCommondsBoundingBox=Yt,t.calcPointFromView=function(t,e){const{viewScaleInfo:n}=e,{x:i,y:r}=t,{scale:o,offsetTop:a,offsetLeft:s}=n;return{x:(i-s)/o,y:(r-a)/o}},t.calcPointMoveMaterialInGroup=function(t,e,n){let i=e.x-t.x,r=e.y-t.y;const o=[];if(n.forEach(t=>{const{x:e,y:n,width:i,height:r,angle:a=0}=t;o.push({x:e,y:n,width:i,height:r,angle:0-a})}),n?.length>0){const n=U(t,o),a=U(e,o);i=a.x-n.x,r=a.y-n.y}return{moveX:i,moveY:r}},t.calcRadian=function(t,e,n){const i=N(t,e),r=N(t,n);return null!==r&&null!==i?r-i:0},t.calcResultMovePosition=Ut,t.calcRevertMovePosition=function(t){const e=Ut(t);return e?{from:[...e.to],to:[...e.from]}:e},t.calcSVGPathBoundingBox=function(t){return Yt(pt(t))},t.calcViewCenter=function(t){let e=0,n=0;if(t){const{viewScaleInfo:i,viewSizeInfo:r}=t,{offsetLeft:o,offsetTop:a,scale:s}=i,{width:c,height:l}=r;e=0-o+c/s/2,n=0-a+l/s/2}return{x:e,y:n}},t.calcViewCenterContent=function(t,e){let n=0,i=0,r=1,o=t?.materials?.[0]?.x||0,a=t?.materials?.[0]?.y||0,s=t?.materials?.[0]?.width||0,c=t?.materials?.[0]?.height||0;const{width:l,height:h}=e.viewSizeInfo;if($.layout(t.layout)&&"hidden"===t.layout?.overflow?(o=t.layout.x,a=t.layout.y,s=t.layout.width||0,c=t.layout.height||0):t.materials.forEach(t=>{const e={x:t.x,y:t.y,width:t.width,height:t.height,angle:t.angle};if(e.angle&&(e.angle>0||e.angle<0)){const t=G(e);if(4===t.length){const n=[t[0].x,t[1].x,t[2].x,t[3].x],i=[t[0].y,t[1].y,t[2].y,t[3].y];e.x=Math.min(...n),e.y=Math.min(...i),e.width=Math.abs(Math.max(...n)-Math.min(...n)),e.height=Math.abs(Math.max(...i)-Math.min(...i))}}const n=Math.min(e.x,o),i=Math.min(e.y,a),r=Math.max(e.x+e.width,o+s),l=Math.max(e.y+e.height,a+c);o=n,a=i,s=Math.abs(r-n),c=Math.abs(l-i)}),t?.layout&&$.layout(t.layout)){const{x:e,y:n,width:i,height:r}=t.layout;"hidden"===t.layout?.overflow?(o=Math.min(o,e),a=Math.min(a,n),s=Math.min(s,i),c=Math.min(c,r)):(o=Math.min(o,e),a=Math.min(a,n),s=Math.max(s,i),c=Math.max(c,r))}if(s>0&&c>0){const t=Mt(l/s,{decimalPlaces:4}),e=Mt(h/c,{decimalPlaces:4});r=Math.min(t,e,1),n=(s*r-l)/2/r+o,i=(c*r-h)/2/r+a}return{offsetX:Mt(n,{decimalPlaces:0}),offsetY:Mt(i,{decimalPlaces:0}),scale:r}},t.calcViewMaterialSize=st,t.calcViewPoint=ct,t.calcViewScaleInfo=function(t,e){const{scale:n,offsetX:i,offsetY:r}=t,{viewSizeInfo:o}=e,{width:a,height:s,contextWidth:c,contextHeight:l}=o,h=0-i*n,f=0-r*n;return{scale:n,offsetLeft:h,offsetTop:f,offsetRight:a-(c*n+h/n),offsetBottom:s-(l*n+f/n)}},t.calcViewVertexes=function(t,e){return[ct(t[0],e),ct(t[1],e),ct(t[2],e),ct(t[3],e)]},t.calcVisiableViewSize=function(t){const e=Z(t.materials);return t.layout&&("hidden"===t.layout?.overflow?(e.x=t.layout.x,e.y=t.layout.y,e.width=t.layout.width,e.height=t.layout.height):(e.x=Math.min(e.x,t.layout.x),e.y=Math.min(e.y,t.layout.y),e.width=Math.max(e.width,t.layout.width),e.height=Math.max(e.height,t.layout.height))),e},t.check=S,t.checkRectIntersect=et,t.colorNameToHex=function(t){const e=n[t.toLowerCase()];return"string"==typeof e?e:null},t.colorToCSS=function(t){let e="transparent";if("string"==typeof t)e=t;else if(1===t?.stops.length)e=t.stops[0].color;else if("linear-gradient"===t?.type){const n=[];"number"==typeof t.angle?n.push(`${t.angle}deg`):n.push("180deg"),Array.isArray(t.stops)&&t.stops.forEach(t=>{n.push(`${t.color} ${100*t.offset}%`)}),e=`linear-gradient(${n.join(", ")})`}else if("radial-gradient"===t?.type){const n=[];Array.isArray(t.stops)&&t.stops.forEach(t=>{n.push(`${t.color} ${100*t.offset}%`)}),e=`radial-gradient(circle, ${n.join(", ")})`}return e},t.colorToLinearGradientCSS=function(t){let e="transparent";if("string"==typeof t)e=t;else if("radial-gradient"===t?.type||"linear-gradient"===t?.type){const n=[];Array.isArray(t.stops)&&t.stops.length>0&&(t.stops.forEach((e,i)=>{n.push(`${e.color} ${100*e.offset}%`),i===t.stops.length-1&&e.offset<1&&n.push(`${e.color} ${100*e.offset}%`)}),e=`linear-gradient(90deg, ${n.join(", ")})`)}return e},t.compose=function(t){return function(e,n){return function i(r){let o=t[r];r===t.length&&n&&(o=n);if(!o)return Promise.resolve();try{return Promise.resolve(o(e,i.bind(null,r+1)))}catch(t){return Promise.reject(t)}}(0)}},t.compressImage=function(t,e){let n=.5;const i=e?.type||"image/png";return e?.radio&&e?.radio>0&&e?.radio<=1&&(n=e?.radio),new Promise((e,r)=>{const o=new Image;o.addEventListener("load",()=>{const{width:t,height:r}=o,a=t*n,s=r*n;let c=document.createElement("canvas");c.width=a,c.height=s,c.getContext("2d").drawImage(o,0,0,a,s);const l=c.toDataURL(i);c=null,e(l)}),o.addEventListener("error",t=>{r(t)}),o.src=t})},t.convertContext2DCommandsToSVGPath=function(t){const e=[];return t.forEach(t=>{if("moveTo"===t.name)e.push(`M ${t.params.x}, ${t.params.y}`);else if("bezierCurveTo"===t.name)e.push(`C ${t.params.cp1x},${t.params.cp1y} ${t.params.cp2x},${t.params.cp2y} ${t.params.x},${t.params.y}`);else if("ellipse"===t.name){const{rx:n,ry:i,xAxisRotation:r,largeArcFlag:o,sweepFlag:a,endPoint:s}=D(t.params);e.push(`A ${n} ${i} ${r} ${o} ${a} ${s.x} ${s.y}`)}else"beginPath"===t.name?e.push(""):"closePath"===t.name&&e.push("Z")}),e.join(" ")},t.convertLineToExactCurveCommand=function(t,e){const n=e.x,i=e.y,r=t.x+(n-t.x)/3,o=t.y+(i-t.y)/3,a=t.x+2*(n-t.x)/3,s=t.y+2*(i-t.y)/3;return{id:te(),type:"C",params:[r,o,a,s,n,i]}},t.convertPathCommandsToACLMZ=ie,t.convertPathCommandsToContext2DCommands=W,t.convertPathCommandsToStr=function(t){let e="";return t.forEach(t=>{e+=t.type+t.params?.join?.(" ")}),e},t.convertSVGPathToContext2DCommands=function(t){return W(pt(t))},t.createAssetId=a,t.createBoardContent=function(t,e){const{width:n,height:i,devicePixelRatio:r}=e,o={width:n,height:i,devicePixelRatio:r},a=t.getContext("2d"),s=L(o),c=L(o),l=L(o),h=A({ctx:a,...o}),f=L(o);return{underlayContext:l,viewContext:s,overlayContext:c,boardContext:h,tempContext:f,drawView:()=>{const{width:t,height:e}=s.$getSize();h.clearRect(0,0,t,e),h.drawImage(l.canvas,0,0,t,e),h.drawImage(s.canvas,0,0,t,e),h.drawImage(c.canvas,0,0,t,e),l.clearRect(0,0,t,e),s.clearRect(0,0,t,e),c.clearRect(0,0,t,e)}}},t.createContext2D=A,t.createHTMLElement=function(t,e,n){return ce(document.createElement(t),e,n)},t.createId=te,t.createMaterial=function(t,e,n){const i=function(t,e){let n=0,i=0,r=200,o=200;if(e){const{viewScaleInfo:a,viewSizeInfo:s}=e,{scale:c,offsetLeft:l,offsetTop:h}=a,{width:f,height:u}=s,d=f/4,y=u/4;r=200>=d?d/c:200/c,o=200>=y?y/c:200/c,["circle","svgCode","image"].includes(t)?r=o=Math.max(r,o):"text"===t&&(o=r/4*2),n=(0-l+f/2-r*c/2)/c,i=(0-h+u/2-o*c/2)/c}return{x:n,y:i,width:r,height:o}}(t,n);let o={};if("rect"===t)o=Ct();else if("circle"===t)o={fill:St().fill,cx:200,cy:200,r:100};else if("text"===t)o=function(t){const e=St();return{text:Rt,fill:e.fill,fontFamily:e.fontFamily,fontWeight:e.fontWeight,fontSize:t.width/4,textAlign:"center",verticalAlign:"middle"}}(i);else if("svgCode"===t)o={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="${$t}"></path></svg>`};else if("image"===t)o={href:kt};else if("group"===t){o={children:[],fill:St().fill,overflow:"hidden"};const t=e;Array.isArray(t.children)&&t.children.length>0&&(o.children=[...t.children])}return{id:r(),type:t,...i,...o,...e}},t.createOffscreenContext2D=L,t.createUUID=r,t.dataToSVG=function(t){const{layout:e,materials:n}=t;let{x:i,y:r,width:o,height:a}=Z(t.materials);e&&(i=e.x,r=e.y,o=e.width,a=e.height);let s=`<svg viewBox="0 0 ${o} ${a}">`;return n.forEach(t=>{s+=ze({...t,x:t.x-i,y:t.y-r})}),s+="</svg>",s},t.debounce=function(t,e){let n=-1;return function(...i){n>=0&&window.clearTimeout(n),n=setTimeout(()=>{t(...i),n=-1},e)}},t.deepClone=c,t.deepCloneData=function(t){const{materials:e,...n}=t;return{...c(n),materials:e.map(t=>l(t))}},t.deepCloneMaterial=l,t.delay=function(t){return new Promise(e=>{setTimeout(()=>{e()},t)})},t.deleteMaterialInList=function(t,e){return Ht(tt(t,e),e)},t.deleteMaterialInListByPosition=Ht,t.downloadFileFromText=function(t,e){const{fileName:n}=e,i=function(t){const e=(new TextEncoder).encode(t),n=new Blob([e],{type:"text/plain;charset=utf-8"});return window.URL.createObjectURL(n)}(t);let r=document.createElement("a");r.href=i,r.download=n,r.click(),r=null},t.downloadImageFromCanvas=function(t,e){const{fileName:n,type:i="image/jpeg"}=e,r=t.toDataURL(i);let o=document.createElement("a");o.href=r,o.download=n,o.click(),o=null},t.enhanceFontFamliy=function(t){return[t,...Xt].join(", ")},t.filterCompactData=function(t,e){const n=t.assets||{},i=c(t),r=e?.loadItemMap||{},o=t=>{t.forEach(t=>{if("image"===t.type&&t.href){const e=t.href;if(s(e)&&!n[e]&&r[e]&&"string"==typeof r[e]?.source)n[e]={type:"image",value:r[e].source};else if(!n[e]){const i=a(e,t.id);n[i]||(n[i]={type:"image",value:e}),t.href=i}}else if("svgCode"===t.type){const e=t.code;if(s(e)&&!n[e]&&r[e]&&"string"==typeof r[e]?.source)n[e]={type:"svgCode",value:r[e].source};else if(!n[e]){const i=a(e,t.id);n[i]||(n[i]={type:"svgCode",value:e}),t.code=i}}else if("foreignObject"===t.type){const e=t.content;if(s(e)&&!n[e]&&r[e]&&"string"==typeof r[e]?.source)n[e]={type:"foreignObject",value:r[e].source};else if(!n[e]){const i=a(e,t.id);n[i]||(n[i]={type:"foreignObject",value:e}),t.content=i}}else if("group"===t.type&&Array.isArray(t.children)){const e=t.assets||{};Object.keys(e).forEach(t=>{n[t]||(n[t]=e[t])}),delete t.assets,o(t.children)}})};return o(i.materials),i.assets=n,i},t.filterMaterialAsset=function(t){let e=null,n=null,i=null;return"image"===t.type?i=t.href:"svgCode"===t.type?i=t.code:"foreignObject"===t.type&&(i=t.content),"string"!=typeof i||s(i)||(e=a(i,t.id),n={type:t.type,value:i},"image"===t.type?t.href=e:"svgCode"===t.type?t.code=e:"foreignObject"===t.type&&(t.content=e)),{material:t,assetId:e,assetItem:n}},t.findMaterialFromList=function t(e,n){let i=null;for(let r=0;r<n.length;r++){const o=n[r];if(o.id===e){i=o;break}if(!i&&"group"===o.type){const n=t(e,o?.children||[]);if(n?.id===e){i=n;break}}}return i},t.findMaterialFromListByPosition=K,t.findMaterialQueueFromListByPosition=function(t,e){const n=[];let i=e;for(let e=0;e<t.length;e++){const r=i[t[e]];if(!r)break;if(n.push(r),!(e<t.length-1&&"group"===r.type))break;i=r.children}return n},t.findMaterialsFromList=function(t,e){const n=[];return function e(i){for(let r=0;r<i.length;r++){const o=i[r];t.includes(o.id)?n.push(o):"group"===o.type&&e(o?.children||[])}}(e),n},t.findMaterialsFromListByPositions=function(t,e){const n=[];return t.forEach(t=>{const i=K(t,e);i&&n.push(i)}),n},t.flatMaterialList=function(t){const e=[],n=[],i=t=>{if(!function(t){if(["rect","circle"].includes(t.type)){const e=t;if(!e.fill&&!e.strokeWidth)return!1;if("transparent"===e.fill&&!e.strokeWidth)return!1}if(["group"].includes(t.type)){const e=t,{children:n}=e;if(!(n.length>0||e.fill||e.strokeWidth))return!1;if(!(n.length>0||"transparent"!==e.fill||e.strokeWidth))return!1}return!("text"===t.type&&!t.text||"image"===t.type&&!t.href||"foreignObject"===t.type&&!t.content||"svgCode"===t.type&&!t.code||!("path"!==t.type||t?.commands?.length>0))}(t))return;const i=function(t,e){const{groupQueue:n}=e;let{x:i,y:r}=t;const{width:o,height:a,angle:s=0}=t;let c=0;if(n.forEach(t=>{i+=t.x,r+=t.y,c+=t.angle||0}),c=q(c),0===c)return{x:i,y:r,width:o,height:a,angle:s};c+=t.angle||0,c=q(c);const l=at(t,{groupQueue:n}),h=X(H(l),l[0],F(0-c));return i=h.x,r=h.y,{x:i,y:r,width:o,height:a,angle:c}}(t,{groupQueue:n}),r={...t,...i};e.push(r)},r=t=>{if(!0!==t?.operations?.invisible)if("group"===t.type){const{children:e,...o}=t;i({...t,attributes:{...o,children:[]}}),n.push(t),e.forEach(t=>{r(t)}),n.pop()}else i(t)};for(let e=0;e<t.length;e++){const n=t[e];r(n)}return e},t.flatObject=Lt,t.formatNumber=Mt,t.generateHTML=function(t){return t.reduce(function(t,e){return t+vt("",e)},"")},t.get=function(t,e,n){if(!e)return;const i=Ot(e);let r=t;for(const t of i){if(null==r)return n;r=r[t]}return void 0!==r?r:n},t.getCenterFromTwoPoints=z,t.getDefaultMaterialAttributes=St,t.getDefaultMaterialRectAttributes=Ct,t.getGroupQueueByMaterialPosition=function(t,e){const n=[];let i=t;if(e.length>1)for(let t=0;t<e.length-1;t++){const r=i[e[t]];if("group"!==r?.type||!Array.isArray(r?.children))return null;n.push(r),i=r.children}return n},t.getGroupQueueFromList=function(t,e){const{groupQueue:n}=_(t,e);return n},t.getHTMLElementRectInPage=function(t){const e=t.getBoundingClientRect(),n=window.pageXOffset||document.documentElement.scrollLeft,i=window.pageYOffset||document.documentElement.scrollTop;return{pageX:e.left+n,pageY:e.top+i,width:e.width,height:e.height}},t.getMaterialAndGroupQueueFromList=_,t.getMaterialPositionFromList=tt,t.getMaterialPositionMapFromList=function(t,e){const n=[],i={};let r=!1;const o=e=>{for(let a=0;a<e.length&&!0!==r;a++){n.push(a);const s=e[a];if(t.includes(s.id)){if(i[s.id]=[...n],Object.keys(i).length===t.length){r=!0;break}}else"group"===s.type&&o(s?.children||[]);if(r)break;n.pop()}};return o(e),i},t.getMaterialRotateVertexes=Y,t.getMaterialSize=function(t){const{id:e,x:n,y:i,width:r,height:o,angle:a=0}=t;return{id:e,x:n,y:i,width:r,height:o,angle:a}},t.getMaterialVertexes=nt,t.getMaterialsAssetIds=function(t){const e=[],n=t=>{t.forEach(t=>{"image"===t.type&&s(t.href)?e.push(t.href):"svgCode"===t.type&&s(t.code)?e.push(t.code):"foreignObject"===t.type&&t.content?e.push(t.content):"group"===t.type&&Array.isArray(t.children)&&n(t.children)})};return n(t),e},t.getMiddlewareValidStyles=function(t,e){const n={};return t&&e.forEach(e=>{const i=t?.[e];"string"!=typeof i&&"number"!=typeof i||(n[e]=i)}),n},t.getSelectedMaterialUUIDs=function(t,e){let n=[];return Array.isArray(t?.materials)&&t?.materials?.length>0&&Array.isArray(e)&&e.length>0&&e.forEach(e=>{"number"==typeof e?t?.materials?.[e]&&n.push(t.materials[e].id):"string"==typeof e&&(n=n.concat(function(t,e){const n=[];if("string"==typeof e&&/^\d+(\.\d+)*$/.test(e)){const i=e.split(".");let r=t;for(;i.length>0;){const t=i.shift();if("string"==typeof t){const e=r[parseInt(t)];e&&0===i.length?n.push(e.id):"group"===e.type&&i.length>0&&(r=e?.children||[])}break}}return n}(t.materials,e)))}),n},t.getViewPointAtMaterial=function(t,e){const{context2d:n,data:i,viewScaleInfo:r,viewSizeInfo:o,groupQueue:a}=e,s={index:-1,material:null,groupQueueIndex:-1};if(a&&Array.isArray(a)&&a?.length>0)for(let e=a.length-1;e>=0;e--){let i=0,c=0,l=0;for(let t=0;t<=e;t++)i+=a[t].x,c+=a[t].y,l+=a[t].angle||0;const h=a[e];if(h&&"group"===h.type&&Array.isArray(h?.children))for(let f=0;f<h.children.length;f++){const u=h.children[f];if(!0!==u?.operations?.invisible){if(!u)break;if(lt(t,{context2d:n,material:{x:i+u.x,y:c+u.y,width:u.width,height:u.height,angle:l+(u.angle||0)},viewScaleInfo:r,viewSizeInfo:o})){s.material=u,(e<a.length-1||"group"!==u.type)&&(s.groupQueueIndex=e);break}}}if(s.material)break}if(s.material)return s;for(let e=i.materials.length-1;e>=0;e--){const a=i.materials[e];if(!0!==a?.operations?.invisible&&lt(t,{context2d:n,material:a,viewScaleInfo:r,viewSizeInfo:o})){s.index=e,s.material=a;break}}return s},t.getViewScaleInfoFromSnapshot=function(t){const{activeStore:e}=t;return{scale:e?.scale,offsetTop:e?.offsetTop,offsetBottom:e?.offsetBottom,offsetLeft:e?.offsetLeft,offsetRight:e?.offsetRight}},t.getViewSizeInfoFromSnapshot=function(t){const{activeStore:e}=t;return{devicePixelRatio:e.devicePixelRatio,width:e?.width,height:e?.height,contextWidth:e?.contextWidth,contextHeight:e?.contextHeight}},t.groupMaterialsByPosition=function(t,e){if(e.length>1){let n=!0;const i=[];for(let t=1;t<e.length;t++){const r=e[t-1],o=e[t];if(!(r.length>0&&o.length>0)){n=!1;break}if(r.length!==o.length){n=!1;break}const a=[...r],s=[...o],c=a.pop(),l=s.pop();1===t&&"number"==typeof c&&c>=0&&i.push(c),"number"==typeof l&&l>=0&&i.push(l)}if(!0!==n)return console.error("[idraw]: The grouped materials are not siblings!"),t;i.sort((t,e)=>t-e);const o=[...e[0]].splice(0,e[0].length-1),a=[],s=[...o,i[0]];for(let e=0;e<i.length;e++){const n=K([...o,i[e]],t);n&&a.push(n)}const c=Z(a);for(let t=0;t<a.length;t++){const e=a[t];e&&(e.x-=c.x,e.y-=c.y)}for(let e=i.length-1;e>=0;e--)Ht([...o,i[e]],t);Bt({name:"Group",id:r(),type:"group",...c,children:a},s,t)}return t},t.injectStyles=function(t){const{styles:e,rootClassName:n,type:i}=t,r=ye(e,`.${n}`);if("element"===i){const t=document.createElement("style");t.setAttribute(pe,n),t.textContent=r,(document.head||document.body).appendChild(t)}else{const t=new CSSStyleSheet;t.replaceSync(r),ge[n]=t,document.adoptedStyleSheets=[...document.adoptedStyleSheets,t]}},t.insertMaterialToListByPosition=Bt,t.is=$,t.isAssetId=s,t.isColorStr=e,t.isMaterialInView=function(t,e){const{viewSizeInfo:n,viewScaleInfo:i}=e,{width:r,height:o}=n,{angle:a}=t,{x:s,y:c,width:l,height:h}=st(t,{viewScaleInfo:i}),f=G({x:s,y:c,width:l,height:h,angle:a}),u={x:0,y:0,width:r,height:o},d=Math.min(f[0].x,f[1].x,f[2].x,f[3].x),y=Math.min(f[0].y,f[1].y,f[2].y,f[3].y);return et(u,{x:d,y:y,width:Math.max(f[0].x,f[1].x,f[2].x,f[3].x)-d,height:Math.max(f[0].y,f[1].y,f[2].y,f[3].y)-y})},t.isPointInMiddlewareElement=function(t,e){const{$root:n,rootClassName:i}=e;if(!n)return!1;const r=t.target;return!!he(r,n,{className:i})},t.isResourceMaterial=function(t){return["image","svgCode","foreignObject"].includes(t?.type)},t.isSameMaterialSize=function(t,e){return t.x===e.x&&t.y===e.y&&t.height===e.height&&t.width===e.width&&q(t.angle||0)===q(e.angle||0)},t.isViewPointInMaterial=lt,t.isViewPointInMaterialSize=function(t,e,n){return ht(t,it(e),n)},t.isViewPointInVertexes=ht,t.istype=f,t.limitAngle=q,t.loadForeignObject=async function(t,e){return t=t.replace(/&/gi,"&amp;"),await p(await u(t,e))},t.loadImage=p,t.loadSVGCode=async function(t){return await p(await d(t))},t.materialToSVG=ze,t.matrixToAngle=function(t){const e=Pt(t);return"number"==typeof e?180*e/Math.PI:e},t.matrixToRadian=Pt,t.merge=function t(e,n){const i=e;for(const e in n)Object.prototype.hasOwnProperty.call(n,e)&&("object"==typeof n[e]&&null!==n[e]&&"object"==typeof i[e]&&null!==i[e]?i[e]=t(i[e],n[e]):i[e]=n[e]);return e},t.mergeGlobal=function(t,e,n){const i=Et(e),r=[],o=Object.keys(i);if(o.forEach(e=>{if(!r.includes(e)){const n=i[e];jt(t,e),void 0!==n&&Tt(t,e,n)}}),!0===n?.strict){const e=Et(t);Object.keys(e).forEach(e=>{r.includes(e)||o.includes(e)||jt(t,e)})}return t},t.mergeHexColorAlpha=function(t,e){if(1===e)return t;let n=1;const i=/^#[0-9a-f]{6,6}$/i;let r=t;if(i.test(t)?n=parseInt(t.substring(5,7).replace(/^#/,"0x")):/^#[0-9a-f]{8,8}$/i.test(t)&&(n=parseInt(t.substring(7,9).replace(/^#/,"0x")),r=t.substring(0,7)),n*=e,i.test(r)&&n>0&&n<1){const t=Math.max(0,Math.min(255,Math.ceil(256*n)));r=`${r.toUpperCase()}${t.toString(16).toUpperCase()}`}return r},t.mergeLayout=function(t,e,n){const i=zt(e),r=[],o=Object.keys(i);if(o.forEach(e=>{if(!r.includes(e)){const n=i[e];jt(t,e),void 0!==n&&Tt(t,e,n)}}),!0===n?.strict){const e=zt(t);Object.keys(e).forEach(e=>{r.includes(e)||o.includes(e)||jt(t,e)})}return t},t.mergeMaterial=Nt,t.mergeMaterialAsset=function(t,e){const n=t;let i=null,r=null;return"image"===n.type?i=n.href:"svgCode"===n.type?i=n.code:"foreignObject"===n.type&&(i=n.content),i&&i?.startsWith("@assets/")&&(r=e[i]),r?.type===n.type&&"string"==typeof r?.value&&r?.value&&("image"===n.type?n.href=r.value:"svgCode"===n.type?n.code=r.value:"foreignObject"===n.type&&(n.content=r.value)),n},t.moveCurveCtrlInAnchorCommands=function(t,e){const n=[],{index:i,type:r,moveX:o,moveY:a}=e;t.forEach(t=>{const{id:e,type:i,params:r}=t,o={id:e,type:i,params:[...r]};n.push(o)});const s=n[i];return"C"===s.type&&("curve-ctrl1"===r?(s.params[0]+=o,s.params[1]+=a):"curve-ctrl2"===r&&(s.params[2]+=o,s.params[3]+=a)),ie(n)},t.moveInAnchorCommands=function(t,e){const n=[],{index:i,moveX:r,moveY:o}=e;t.forEach(t=>{const{id:e,type:i,params:r}=t,o={id:e,type:i,params:[...r]};n.push(o)});const a=n[i],s=n[i-1];if("start"===e.type){if(!s||!a)return ie(n);switch("M"===a.type&&(a.params[0]+=r,a.params[1]+=o),"C"===a.type&&(a.params[0]+=r,a.params[1]+=o),s.type){case"M":case"L":case"Z":s.params[0]+=r,s.params[1]+=o;break;case"A":s.params[5]+=r,s.params[6]+=o;break;case"C":s.params[2]+=r,s.params[3]+=o,s.params[4]+=r,s.params[5]+=o}}return ie(n)},t.moveMaterialPosition=function(t,e){const n=[...e.from],i=[...e.to];if(0===n.length||0===i.length)return{materials:t,from:n,to:i};if(n.length<=i.length)for(let e=0;e<n.length;e++)if(i[e]===n[e]){if(e===n.length-1)return{materials:t,from:n,to:i};continue}const r=K(n,t);if(r){if(!Bt(r,i,t))return{materials:t,from:n,to:i};let e=-1;const o="down";let a=!1;if(n.length>=1&&i.length>=1){if(n.length<=i.length)if(1===n.length)n[0]<i[0]&&(a=!0);else for(let t=0;t<n.length&&n[t]===i[t];t++)if(n.length===n.length-1){a=!0;break}if(n.length>=i.length)if(1===i.length)i[0]<n[0]&&(a=!0);else for(let t=0;t<i.length&&(t===i.length-1&&i[t]<n[t]&&(a=!0),n[t]===i[t]);t++);}if(!0===a)for(let t=0;t<n.length&&i[t]>=0;t++)i[t]!==n[t]&&i[t]<n[t]&&t==i.length-1&&(e=t);e>=0&&"down"===o&&(n[e]=n[e]+1),Ht(n,t)}return{materials:t,from:n,to:i}},t.omit=function(t,e){const n={...t};for(const t of e)delete n[t];return n},t.parseAngleToRadian=F,t.parseFileToBase64=function(t){return new Promise(function(e,n){let i=new FileReader;i.addEventListener("load",function(){e(i.result),i=null}),i.addEventListener("error",function(t){n(t),i=null}),i.addEventListener("abort",function(){n(new Error("abort")),i=null}),i.readAsDataURL(t)})},t.parseFileToText=function(t){return new Promise(function(e,n){let i=new FileReader;i.addEventListener("load",function(){e(i.result),i=null}),i.addEventListener("error",function(t){n(t),i=null}),i.addEventListener("abort",function(){n(new Error("abort")),i=null}),i.readAsText(t)})},t.parseHTML=function(t){const e=[],n=[];let i,r=-1,o=!1;return t.replace(xt,(a,s)=>{if(o&&!Array.isArray(i)){if(a!=="</"+i.name+">")return a;o=!1}const c="/"!==a.charAt(1),l=a.startsWith("\x3c!--"),h=s+a.length,f=t.charAt(h);let u;if(l){const t=wt(a);return r<0?(e.push(t),a):(u=n[r],u.children.push(t),a)}if(c){if(r++,i=wt(a),!i.isVoid&&!o&&f&&"<"!==f){const e=t.slice(h,t.indexOf("<",h));e.trim()&&i.children.push({type:"text",name:null,attributes:{},children:[],isVoid:!1,textContent:e.trim()})}0===r&&e.push(i),u=n[r-1],u&&u.children.push(i),n[r]=i}if((!c||!Array.isArray(i)&&i.isVoid)&&(r>-1&&!Array.isArray(i)&&(i.isVoid||i.name===a.slice(2,-1))&&(r--,i=-1===r?e:n[r]),!o&&"<"!==f&&f)){u=-1===r?e:n[r].children;const i=t.indexOf("<",h);let o=t.slice(h,-1===i?void 0:i);mt.test(o)&&(o=" "),(i>-1&&r+u.length>=0||" "!==o)&&o.trim()&&u.push({type:"text",name:null,attributes:{},children:[],isVoid:!1,textContent:o.trim()})}return a}),e},t.parseHTMLStr=function(t){const e=le(t),n=document.createElement("template");return n.innerHTML=e.trim(),n.content.firstElementChild},t.parseRadianToAngle=function(t){return t/Math.PI*180},t.parseSVGCodeToDataURL=d,t.parseSVGPath=pt,t.parseStyles=ye,t.parseXMLToDataURL=u,t.pickFile=function(t){const{accept:e,success:n,error:i}=t;let r=document.createElement("input");r.type="file",e&&(r.accept=e),r.addEventListener("change",function(){const t=r.files?.[0];n({file:t}),r=null}),r.addEventListener("error",function(t){"function"==typeof i&&i(t),r=null}),r.click()},t.refinePathMaterial=function(t){let{x:e,y:n,width:i,height:r,...o}=t;const{commands:a}=o,{minX:s,minY:c,maxX:l,maxY:h}=Yt(a);return e+=s,n+=c,i=Math.abs(l-s),r=Math.abs(h-c),0===s&&0===c||(o.commands=ne(a,0-s,0-c)),{...t,x:e,y:n,width:i,height:r,...o}},t.removeClassName=function(t,e){e.forEach(e=>{e&&t.classList.contains(e)&&t.classList.remove(e)})},t.removeStyles=function(t){const{rootClassName:e,type:n}=t;if("element"===n)document.querySelector(`[${pe}="${e}"]`)?.remove();else if(ge[e]){const t=ge[e],n=document.adoptedStyleSheets.filter(e=>e!==t);document.adoptedStyleSheets=n}},t.resizeEffectGroupMaterial=Vt,t.rotateByCenter=V,t.rotateMaterial=function(t,e,n){const i=B(e);V(t,e.angle||0,i,()=>{n(t)})},t.rotateMaterialVertexes=G,t.rotatePoint=X,t.rotatePointInGroup=U,t.rotateVertexes=Q,t.sanitizeHTMLStr=le,t.scalePathCommands=function(t,e,n){return t.map(t=>{const{id:i,type:r,params:o}=t,a=[];let s={id:i};if(t.start&&t.end){const r={...t.start},o={...t.end};r.x*=e,r.y*=n,o.x*=e,o.y*=n,s={id:i,start:r,end:o}}switch(r.toUpperCase()){case"M":case"L":case"T":for(let t=0;t<o.length;t+=2)a.push(o[t]*e,o[t+1]*n);break;case"C":for(let t=0;t<o.length;t+=6)a.push(o[t]*e,o[t+1]*n,o[t+2]*e,o[t+3]*n,o[t+4]*e,o[t+5]*n);break;case"S":for(let t=0;t<o.length;t+=4)a.push(o[t]*e,o[t+1]*n,o[t+2]*e,o[t+3]*n);break;case"Q":for(let t=0;t<o.length;t+=4)a.push(o[t]*e,o[t+1]*n,o[t+2]*e,o[t+3]*n);break;case"H":o.forEach(t=>a.push(t*e));break;case"V":o.forEach(t=>a.push(t*n));break;case"A":for(let t=0;t<o.length;t+=7)a.push(o[t]*e,o[t+1]*n,o[t+2],o[t+3],o[t+4],o[t+5]*e,o[t+6]*n);break;case"M":case"L":case"C":case"S":case"Q":case"T":case"A":case"H":case"V":for(let t=0;t<o.length;t++){const i="a"===r&&(t%7==0||t%7==5)||"h"===r||"v"!==r&&t%2==0;a.push(o[t]*(i?e:n))}break;default:return{type:r,params:[...o],...s}}return{type:r,params:a,...s}})},t.set=Tt,t.setHTMLCSSProps=se,t.shiftPathCommand=ee,t.shiftPathCommands=ne,t.sortDataAsserts=function(t,e){const n=t.assets||{};let i=t;!0===e?.clone&&(i=c(t));const r=t=>{t.forEach(t=>{if("image"===t.type&&t.href){const e=t.href,i=a(e,t.id);n[i]||(n[i]={type:"image",value:e}),t.href=i}else if("svgCode"===t.type){const e=t.code,i=a(e,t.id);n[i]||(n[i]={type:"svgCode",value:e}),t.code=i}else if("foreignObject"===t.type){const e=t.content,i=a(e,t.id);n[i]||(n[i]={type:"foreignObject",value:e}),t.content=i}else if("group"===t.type&&Array.isArray(t.children)){const e=t.assets||{};Object.keys(e).forEach(t=>{n[t]||(n[t]=e[t])}),delete t.assets,r(t.children)}})};return r(i.materials),i.assets=n,i},t.svgToMaterial=function(t){const e=new DOMParser,n=t.replace(/<\?xml[^>]*\?>/g,"").replace(/<!DOCTYPE[^>]*>/g,"").trim(),i=e.parseFromString(n,"image/svg+xml"),r=i.getElementsByTagName("parsererror")[0];if(r)throw new Error(`SVG parsing error: ${r.textContent}`);const o=i.documentElement;if("svg"!==o.tagName.toLowerCase())throw new Error("Input is not a valid SVG document");return Ie(o)},t.throttle=function(t,e){let n=-1;return function(...i){n>=0||(n=setTimeout(()=>{t(...i),n=-1},e))}},t.toColorHexNum=function(t){return parseInt(t.replace(/^#/,"0x"))},t.toColorHexStr=function(t){return"#"+t.toString(16)},t.toFlattenGlobal=Et,t.toFlattenLayout=zt,t.toFlattenMaterial=It,t.toPath=Ot,t.unflatObject=function(t){const e={};for(const[n,i]of Object.entries(t))me(e,xe(n),i);return e},t.ungroupMaterialsByPosition=function(t,e){const n=K(e,t);n&&"group"===n?.type&&Array.isArray(n?.children)||console.error("[idraw]: The ungrouped material is not a group material!");const i=[...e].splice(0,e.length-1),r=e[e.length-1],{x:o,y:a}=n;return Ht(e,t),n.children.forEach((e,n)=>{e.x+=o,e.y+=a,Bt(e,[...i,r+n],t)}),t},t.updateMaterialInList=function t(e,n,i){let r=null;for(let o=0;o<i.length;o++){const a=i[o];if(a.id===e){"group"===a.type&&a.operations?.resizeEffect&&Vt(a,{...n},{resizeEffect:a.operations?.resizeEffect}),Nt(a,n),r=a;break}"group"===a.type&&(r=t(e,n,a?.children||[]))}return r},t.updateMaterialInListByPosition=function(t,e,n,i){const r=K(t,n);return r&&("group"===r.type&&r.operations?.resizeEffect&&Vt(r,{...e},{resizeEffect:r.operations?.resizeEffect}),Nt(r,e,i)),r},t.validateMaterials=function t(e){let n=!0;if(Array.isArray(e)){const i=[];e.forEach(e=>{"string"==typeof e.id&&e.id?i.includes(e.id)?(n=!1,console.warn(`Duplicate ids: ${e.id}`)):i.push(e.id):(n=!1,console.warn("Material missing id",e)),"group"===e.type&&(n=t(e?.children))})}return n},t.viewScale=function(t){const{scale:e,point:n,viewScaleInfo:i}=t,{offsetLeft:r,offsetTop:o}=i,a=e/i.scale,s=n.x,c=n.y;return{moveX:s-s*a+(r*a-r),moveY:c-c*a+(o*a-o)}},t.viewScroll=function(t){const{moveX:e=0,moveY:n=0,viewScaleInfo:i,viewSizeInfo:r}=t,{scale:o}=i,{width:a,height:s,contextWidth:c,contextHeight:l}=r;let h=i.offsetLeft,f=i.offsetRight,u=i.offsetTop,d=i.offsetBottom;return h+=e,u+=n,f=a-(c*o+h),d=s-(l*o+u),{scale:o,offsetTop:u,offsetLeft:h,offsetRight:f,offsetBottom:d}},t}({});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@idraw/util",
3
- "version": "1.0.0-alpha.1",
3
+ "version": "1.0.0-alpha.3",
4
4
  "description": "",
5
5
  "main": "dist/esm/index.js",
6
6
  "module": "dist/esm/index.js",