@idraw/util 0.4.2 → 1.0.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (96) hide show
  1. package/dist/esm/converter/data-svg.d.ts +2 -0
  2. package/dist/esm/converter/data-svg.js +19 -0
  3. package/dist/esm/converter/material-svg.d.ts +2 -0
  4. package/dist/esm/converter/material-svg.js +63 -0
  5. package/dist/esm/converter/svg-material.d.ts +2 -0
  6. package/dist/esm/converter/svg-material.js +188 -0
  7. package/dist/esm/index.d.ts +32 -21
  8. package/dist/esm/index.js +32 -21
  9. package/dist/esm/static.d.ts +1 -0
  10. package/dist/esm/static.js +1 -0
  11. package/dist/esm/tool/file.js +2 -2
  12. package/dist/esm/tool/html.js +27 -27
  13. package/dist/esm/tool/id.d.ts +1 -0
  14. package/dist/esm/tool/id.js +4 -0
  15. package/dist/esm/tool/image.js +6 -6
  16. package/dist/esm/tool/path-to-box.d.ts +3 -0
  17. package/dist/esm/tool/path-to-box.js +353 -0
  18. package/dist/esm/tool/path-to-command.d.ts +4 -0
  19. package/dist/esm/tool/path-to-command.js +392 -0
  20. package/dist/esm/tool/path.d.ts +18 -0
  21. package/dist/esm/tool/path.js +421 -0
  22. package/dist/esm/tool/svg-path.d.ts +3 -0
  23. package/dist/esm/{view → tool}/svg-path.js +4 -16
  24. package/dist/esm/tool/time.d.ts +2 -2
  25. package/dist/esm/tool/time.js +4 -4
  26. package/dist/esm/tool/uuid.d.ts +1 -1
  27. package/dist/esm/tool/uuid.js +6 -6
  28. package/dist/esm/view/box.d.ts +0 -2
  29. package/dist/esm/view/box.js +1 -173
  30. package/dist/esm/view/canvas.js +3 -3
  31. package/dist/esm/view/check.d.ts +8 -7
  32. package/dist/esm/view/check.js +34 -34
  33. package/dist/esm/view/config.d.ts +0 -9
  34. package/dist/esm/view/config.js +1 -71
  35. package/dist/esm/view/context2d.d.ts +10 -3
  36. package/dist/esm/view/context2d.js +39 -18
  37. package/dist/esm/view/controller.d.ts +5 -5
  38. package/dist/esm/view/controller.js +105 -102
  39. package/dist/esm/view/data.d.ts +2 -2
  40. package/dist/esm/view/data.js +65 -65
  41. package/dist/esm/view/dom.d.ts +23 -0
  42. package/dist/esm/view/dom.js +190 -0
  43. package/dist/esm/view/flat.d.ts +2 -2
  44. package/dist/esm/view/flat.js +53 -53
  45. package/dist/esm/view/group.d.ts +3 -3
  46. package/dist/esm/view/group.js +25 -28
  47. package/dist/esm/view/handle-material.d.ts +24 -0
  48. package/dist/esm/view/{handle-element.js → handle-material.js} +98 -75
  49. package/dist/esm/view/is.d.ts +10 -12
  50. package/dist/esm/view/is.js +15 -19
  51. package/dist/esm/view/load.d.ts +2 -2
  52. package/dist/esm/view/load.js +7 -7
  53. package/dist/esm/view/material.d.ts +40 -0
  54. package/dist/esm/view/material.js +476 -0
  55. package/dist/esm/view/middleware.d.ts +1 -0
  56. package/dist/esm/view/middleware.js +14 -2
  57. package/dist/esm/view/modify-record.d.ts +4 -4
  58. package/dist/esm/view/modify-record.js +2 -2
  59. package/dist/esm/view/parser.d.ts +2 -2
  60. package/dist/esm/view/parser.js +3 -3
  61. package/dist/esm/view/path.d.ts +2 -0
  62. package/dist/esm/view/path.js +30 -0
  63. package/dist/esm/view/point-move-material.d.ts +5 -0
  64. package/dist/esm/view/{point-move-element.js → point-move-material.js} +6 -6
  65. package/dist/esm/view/point.d.ts +3 -8
  66. package/dist/esm/view/point.js +1 -21
  67. package/dist/esm/view/position.d.ts +9 -9
  68. package/dist/esm/view/position.js +1 -1
  69. package/dist/esm/view/rect.d.ts +2 -2
  70. package/dist/esm/view/rect.js +4 -4
  71. package/dist/esm/view/resize-material.d.ts +4 -0
  72. package/dist/esm/view/resize-material.js +266 -0
  73. package/dist/esm/view/rotate.d.ts +11 -11
  74. package/dist/esm/view/rotate.js +24 -24
  75. package/dist/esm/view/static.d.ts +13 -0
  76. package/dist/esm/view/static.js +89 -0
  77. package/dist/esm/view/styles.d.ts +11 -0
  78. package/dist/esm/view/styles.js +78 -0
  79. package/dist/esm/view/vertex.d.ts +8 -8
  80. package/dist/esm/view/vertex.js +28 -28
  81. package/dist/esm/view/view-box.d.ts +2 -6
  82. package/dist/esm/view/view-box.js +8 -64
  83. package/dist/esm/view/view-calc.d.ts +23 -20
  84. package/dist/esm/view/view-calc.js +104 -93
  85. package/dist/esm/view/view-content.d.ts +2 -2
  86. package/dist/esm/view/view-content.js +34 -34
  87. package/dist/index.global.js +3144 -1548
  88. package/dist/index.global.min.js +1 -1
  89. package/package.json +1 -1
  90. package/dist/esm/view/element.d.ts +0 -35
  91. package/dist/esm/view/element.js +0 -471
  92. package/dist/esm/view/handle-element.d.ts +0 -24
  93. package/dist/esm/view/point-move-element.d.ts +0 -5
  94. package/dist/esm/view/resize-element.d.ts +0 -4
  95. package/dist/esm/view/resize-element.js +0 -255
  96. package/dist/esm/view/svg-path.d.ts +0 -10
@@ -1 +1 @@
1
- var iDrawUtil=function(t){"use strict";var e,n,i,o,r,l,a,s,c=t=>{throw TypeError(t)},u=(t,e,n)=>e.has(t)||c("Cannot "+n),h=(t,e,n)=>(u(t,e,"read from private field"),n?n.call(t):e.get(t)),f=(t,e,n)=>e.has(t)?c("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,n),d=(t,e,n,i)=>(u(t,e,"write to private field"),i?i.call(t,n):e.set(t,n),n),y=(t,e,n)=>(u(t,e,"access private method"),n);function g(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 x={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 p(){function t(){return(65536*(1+Math.random())|0).toString(16).substring(1)}return`${t()}${t()}-${t()}-${t()}-${t()}-${t()}${t()}${t()}`}function m(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 b(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),o=Math.floor(n/2),r=t.substring(0,4).padStart(4,"0"),l=t.substring(0,4).padStart(4,"0");return`@assets/${m(n.toString(16).padStart(4,r),i).padStart(4,"0")}${m(t.substring(o-4,o).padStart(4,r),i).padStart(4,"0")}-${m(t.substring(o-8,o-4).padStart(4,r),i).padStart(4,"0")}-${m(t.substring(o-12,o-8).padStart(4,r),i).padStart(4,"0")}-${m(t.substring(o-16,o-12).padStart(4,l),i).padStart(4,"0")}-${m(t.substring(o,o+4).padStart(4,l),i).padStart(4,"0")}${m(t.substring(o+4,o+8).padStart(4,l),i).padStart(4,"0")}${m(l.padStart(4,r).padStart(4,l),i)}`}function v(t){return/^@assets\/[0-9a-z-]{0,}$/.test(`${t}`)}function w(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 M(t){const e=w(t),n=t=>{t.uuid=p(),"group"===t.type&&t.detail.children&&t.detail.children.forEach((t=>{n(t)}))};return n(e),e}function P(t){return(Object.prototype.toString.call(t)||"").replace(/(\[object|\])/gi,"").trim()}const R={type(t,e){const n=P(t);return!0===e?n.toLocaleLowerCase():n},array:t=>"Array"===P(t),json:t=>"Object"===P(t),function:t=>"Function"===P(t),asyncFunction:t=>"AsyncFunction"===P(t),boolean:t=>"Boolean"===P(t),string:t=>"String"===P(t),number:t=>"Number"===P(t),undefined:t=>"Undefined"===P(t),null:t=>"Null"===P(t),promise:t=>"Promise"===P(t)};const{Image:I}=window;function S(t){return new Promise(((e,n)=>{const i=new I;i.crossOrigin="anonymous",i.onload=function(){e(i)},i.onabort=n,i.onerror=n,i.src=t}))}function $(t){return"number"==typeof t&&t>=0}function E(t){return"number"==typeof t&&(t>0||t<=0)}function A(t){return E(t)}function z(t){return E(t)}function k(t){return $(t)}function O(t){return $(t)}function L(t){return"string"==typeof t&&/^(http:\/\/|https:\/\/|\.\/|\/)/.test(`${t}`)}function C(t){return"string"==typeof t&&/^(data:image\/)/.test(`${t}`)}function j(t){return["rect","circle","text","image","svg","html","group"].includes(t)}const T={positiveNum:$,data:function(t){return!!(Array(null==t?void 0:t.elements)&&(null==t?void 0:t.elements.length)>=0)},element:function(t){return!!t&&(j(null==t?void 0:t.type)&&A(null==t?void 0:t.x)&&z(null==t?void 0:t.y)&&k(null==t?void 0:t.w)&&O(null==t?void 0:t.h))},layout:function(t){return!!t&&(A(null==t?void 0:t.x)&&z(null==t?void 0:t.y)&&k(null==t?void 0:t.w)&&O(null==t?void 0:t.h))},type:j,x:A,y:z,w:k,h:O,angle:function(t){return"number"==typeof t&&t>=-360&&t<=360},number:E,numberStr:function(t){return/^(-?\d+(?:\.\d+)?)$/.test(`${t}`)},borderWidth:function(t){return $(t)||Array.isArray(t)&&$(t[0])&&$(t[1])&&$(t[2])&&$(t[3])},borderRadius:function(t){return $(t)||Array.isArray(t)&&$(t[0])&&$(t[1])&&$(t[2])&&$(t[3])},color:function(t){return g(t)},imageSrc:function(t){return C(t)||L(t)},imageURL:L,imageBase64:C,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 E(t)&&t>0},lineHeight:function(t){return E(t)&&t>0},textAlign:function(t){return["center","left","right"].includes(t)},fontFamily:function(t){return"string"==typeof t&&t.length>0},fontWeight:function(t){return["bold"].includes(t)},strokeWidth:function(t){return E(t)&&t>0}};function D(t={}){const{borderColor:e,borderRadius:n,borderWidth:i}=t;return!(Object.prototype.hasOwnProperty.call(t,"borderColor")&&!T.color(e))&&(!(Object.prototype.hasOwnProperty.call(t,"borderRadius")&&!T.number(n))&&!(Object.prototype.hasOwnProperty.call(t,"borderWidth")&&!T.number(i)))}const W={attrs:function(t){const{x:e,y:n,w:i,h:o,angle:r}=t;return!!(T.x(e)&&T.y(n)&&T.w(i)&&T.h(o)&&T.angle(r))&&(r>=-360&&r<=360)},textDesc:function(t){const{text:e,color:n,fontSize:i,lineHeight:o,fontFamily:r,textAlign:l,fontWeight:a,background:s,strokeWidth:c,strokeColor:u}=t;return!!T.text(e)&&(!!T.color(n)&&(!!T.fontSize(i)&&(!(Object.prototype.hasOwnProperty.call(t,"background")&&!T.color(s))&&(!(Object.prototype.hasOwnProperty.call(t,"fontWeight")&&!T.fontWeight(a))&&(!(Object.prototype.hasOwnProperty.call(t,"lineHeight")&&!T.lineHeight(o))&&(!(Object.prototype.hasOwnProperty.call(t,"fontFamily")&&!T.fontFamily(r))&&(!(Object.prototype.hasOwnProperty.call(t,"textAlign")&&!T.textAlign(l))&&(!(Object.prototype.hasOwnProperty.call(t,"strokeWidth")&&!T.strokeWidth(c))&&(!(Object.prototype.hasOwnProperty.call(t,"strokeColor")&&!T.color(u))&&!!D(t))))))))))},rectDesc:function(t){const{background:e}=t;return!(Object.prototype.hasOwnProperty.call(t,"background")&&!T.color(e))&&!!D(t)},circleDesc:function(t){const{background:e,borderColor:n,borderWidth:i}=t;return!(Object.prototype.hasOwnProperty.call(t,"background")&&!T.color(e))&&(!(Object.prototype.hasOwnProperty.call(t,"borderColor")&&!T.color(n))&&!(Object.prototype.hasOwnProperty.call(t,"borderWidth")&&!T.number(i)))},imageDesc:function(t){const{src:e}=t;return!!T.imageSrc(e)},svgDesc:function(t){const{svg:e}=t;return!!T.svg(e)},htmlDesc:function(t){const{html:e}=t;return!!T.html(e)}};class N{constructor(t,i){f(this,e),f(this,n),d(this,e,t),d(this,n,{devicePixelRatio:1,offscreenCanvas:null,...i}),this.$resetFont()}$undoPixelRatio(t){return t/h(this,n).devicePixelRatio}$doPixelRatio(t){return h(this,n).devicePixelRatio*t}$getContext(){return h(this,e)}$setContext(t){d(this,e,t)}$setFont(t){const n=[];t.fontWeight&&n.push(`${t.fontWeight}`),n.push(`${this.$doPixelRatio(t.fontSize||12)}px`),n.push(`${t.fontFamily||"sans-serif"}`),h(this,e).font=`${n.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 h(this,n).offscreenCanvas}$resize(t){const{width:i,height:o,devicePixelRatio:r,resetStyle:l}=t,{canvas:a}=h(this,e);a.width=i*r,a.height=o*r,d(this,n,{...h(this,n),devicePixelRatio:r}),!0===l&&(a.style.width=`${i}px`,a.style.height=`${o}px`)}$getSize(){const{devicePixelRatio:t}=h(this,n),{width:i,height:o}=h(this,e).canvas;return{width:i/t,height:o/t,devicePixelRatio:t}}get canvas(){return h(this,e).canvas}get fillStyle(){return h(this,e).fillStyle}set fillStyle(t){h(this,e).fillStyle=t}get strokeStyle(){return h(this,e).strokeStyle}set strokeStyle(t){h(this,e).strokeStyle=t}get lineWidth(){return this.$undoPixelRatio(h(this,e).lineWidth)}set lineWidth(t){h(this,e).lineWidth=this.$doPixelRatio(t)}get textAlign(){return h(this,e).textAlign}set textAlign(t){h(this,e).textAlign=t}get textBaseline(){return h(this,e).textBaseline}set textBaseline(t){h(this,e).textBaseline=t}get globalAlpha(){return h(this,e).globalAlpha}set globalAlpha(t){h(this,e).globalAlpha=t}get shadowColor(){return h(this,e).shadowColor}set shadowColor(t){h(this,e).shadowColor=t}get shadowOffsetX(){return this.$undoPixelRatio(h(this,e).shadowOffsetX)}set shadowOffsetX(t){h(this,e).shadowOffsetX=this.$doPixelRatio(t)}get shadowOffsetY(){return this.$undoPixelRatio(h(this,e).shadowOffsetY)}set shadowOffsetY(t){h(this,e).shadowOffsetY=this.$doPixelRatio(t)}get shadowBlur(){return this.$undoPixelRatio(h(this,e).shadowBlur)}set shadowBlur(t){h(this,e).shadowBlur=this.$doPixelRatio(t)}get lineCap(){return h(this,e).lineCap}set lineCap(t){h(this,e).lineCap=t}get globalCompositeOperation(){return h(this,e).globalCompositeOperation}set globalCompositeOperation(t){h(this,e).globalCompositeOperation=t}fill(...t){return h(this,e).fill(...t)}arc(t,n,i,o,r,l){return h(this,e).arc(this.$doPixelRatio(t),this.$doPixelRatio(n),this.$doPixelRatio(i),o,r,l)}rect(t,n,i,o){return h(this,e).rect(this.$doPixelRatio(t),this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(o))}fillRect(t,n,i,o){return h(this,e).fillRect(this.$doPixelRatio(t),this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(o))}clearRect(t,n,i,o){return h(this,e).clearRect(this.$doPixelRatio(t),this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(o))}beginPath(){return h(this,e).beginPath()}closePath(){return h(this,e).closePath()}lineTo(t,n){return h(this,e).lineTo(this.$doPixelRatio(t),this.$doPixelRatio(n))}moveTo(t,n){return h(this,e).moveTo(this.$doPixelRatio(t),this.$doPixelRatio(n))}arcTo(t,n,i,o,r){return h(this,e).arcTo(this.$doPixelRatio(t),this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(o),this.$doPixelRatio(r))}bezierCurveTo(t,n,i,o,r,l){return h(this,e).bezierCurveTo(this.$doPixelRatio(t),this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(o),this.$doPixelRatio(r),this.$doPixelRatio(l))}quadraticCurveTo(t,n,i,o){return h(this,e).quadraticCurveTo(this.$doPixelRatio(t),this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(o))}getLineDash(){return h(this,e).getLineDash()}setLineDash(t){const n=t.map((t=>this.$doPixelRatio(t)));return h(this,e).setLineDash(n)}stroke(t){return t?h(this,e).stroke(t):h(this,e).stroke()}translate(t,n){return h(this,e).translate(this.$doPixelRatio(t),this.$doPixelRatio(n))}rotate(t){return h(this,e).rotate(t)}drawImage(...t){const n=t[0],i=t[1],o=t[2],r=t[3],l=t[4],a=t[t.length-4],s=t[t.length-3],c=t[t.length-2],u=t[t.length-1];return 9===t.length?h(this,e).drawImage(n,this.$doPixelRatio(i),this.$doPixelRatio(o),this.$doPixelRatio(r),this.$doPixelRatio(l),this.$doPixelRatio(a),this.$doPixelRatio(s),this.$doPixelRatio(c),this.$doPixelRatio(u)):h(this,e).drawImage(n,this.$doPixelRatio(a),this.$doPixelRatio(s),this.$doPixelRatio(c),this.$doPixelRatio(u))}createPattern(t,n){return h(this,e).createPattern(t,n)}measureText(t){return h(this,e).measureText(t)}fillText(t,n,i,o){return void 0!==o?h(this,e).fillText(t,this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(o)):h(this,e).fillText(t,this.$doPixelRatio(n),this.$doPixelRatio(i))}strokeText(t,n,i,o){return void 0!==o?h(this,e).strokeText(t,this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(o)):h(this,e).strokeText(t,this.$doPixelRatio(n),this.$doPixelRatio(i))}save(){h(this,e).save()}restore(){h(this,e).restore()}scale(t,n){h(this,e).scale(t,n)}circle(t,n,i,o,r,l,a,s){h(this,e).ellipse(this.$doPixelRatio(t),this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(o),r,l,a,s)}isPointInPath(t,n){return h(this,e).isPointInPath(this.$doPixelRatio(t),this.$doPixelRatio(n))}clip(...t){return h(this,e).clip(...t)}setTransform(t,n,i,o,r,l){return h(this,e).setTransform(t,n,i,o,r,l)}getTransform(){return h(this,e).getTransform()}createLinearGradient(t,n,i,o){return h(this,e).createLinearGradient(this.$doPixelRatio(t),this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(o))}createRadialGradient(t,n,i,o,r,l){return h(this,e).createRadialGradient(this.$doPixelRatio(t),this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(o),this.$doPixelRatio(r),this.$doPixelRatio(l))}createConicGradient(t,n,i){return h(this,e).createConicGradient(t,this.$doPixelRatio(n),this.$doPixelRatio(i))}}function F(t){const{width:e,height:n,ctx:i,devicePixelRatio:o}=t;let r=i;if(!r){const t=document.createElement("canvas");t.width=e*o,t.height=n*o,r=t.getContext("2d")}return new N(r,t)}function B(t){const{width:e,height:n,devicePixelRatio:i}=t,o=new OffscreenCanvas(e*i,n*i),r=o.getContext("2d").canvas.getContext("2d");return new N(r,{devicePixelRatio:i,offscreenCanvas:o})}e=new WeakMap,n=new WeakMap;function V(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 H(t,e){return t.x===e.x&&t.y===e.y&&t.t===e.t}function G(t){return t>=0||t<0}function Q(t){return G(t.x)&&G(t.y)&&t.t>0}function Y(t,e){return{x:t.x+(e.x-t.x)/2,y:t.y+(e.y-t.y)/2}}i=new WeakMap;function U(t){return t/180*Math.PI}function X(t,e,n,i){const o=U(e||0);n&&(o>0||o<0)&&(t.translate(n.x,n.y),t.rotate(o),t.translate(-n.x,-n.y)),i(t),n&&(o>0||o<0)&&(t.translate(n.x,n.y),t.rotate(-o),t.translate(-n.x,-n.y))}function q(t){return{x:t.x+t.w/2,y:t.y+t.h/2}}function Z(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 q({x:e,y:n,w:Math.max(t[0].x,t[1].x,t[2].x,t[3].x)-e,h:Math.max(t[0].y,t[1].y,t[2].y,t[3].y)-n})}function J(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 K(t,e,n){let i=J(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 o=V(t,e);let r=0,l=0;return 0===i?(r=0,l=0-o):i>0&&i<Math.PI/2?(r=Math.sin(i)*o,l=0-Math.cos(i)*o):i===Math.PI/2?(r=o,l=0):i>Math.PI/2&&i<Math.PI?(r=Math.sin(Math.PI-i)*o,l=Math.cos(Math.PI-i)*o):i===Math.PI?(r=0,l=o):i>Math.PI&&i<1.5*Math.PI?(r=0-Math.sin(i-Math.PI)*o,l=Math.cos(i-Math.PI)*o):i===1.5*Math.PI?(r=0-o,l=0):i>1.5*Math.PI&&i<2*Math.PI?(r=0-Math.sin(2*Math.PI-i)*o,l=0-Math.cos(2*Math.PI-i)*o):i===2*Math.PI&&(r=0,l=0-o),r+=t.x,l+=t.y,{x:r,y:l}}function _(t,e){if((null==e?void 0:e.length)>0){let n=t.x,i=t.y;return e.forEach((t=>{const{x:e,y:o,w:r,h:l,angle:a=0}=t,s=K(q({x:e,y:o,w:r,h:l}),{x:n,y:i},U(a));n=s.x,i=s.y})),{x:n,y:i}}return t}function tt(t,e,n){const{x:i,y:o,w:r,h:l}=t;let a={x:i,y:o},s={x:i+r,y:o},c={x:i+r,y:o+l},u={x:i,y:o+l};if(n&&(n>0||n<0)){const t=U(it(n));a=K(e,a,t),s=K(e,s,t),c=K(e,c,t),u=K(e,u,t)}return[a,s,c,u]}function et(t){const{angle:e=0}=t;return tt(t,q(t),e)}function nt(t,e,n){return[K(t,{x:e[0].x,y:e[0].y},n),K(t,{x:e[1].x,y:e[1].y},n),K(t,{x:e[2].x,y:e[2].y},n),K(t,{x:e[3].x,y:e[3].y},n)]}function it(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 ot(t){var e;const n={x:0,y:0,w:0,h:0};let i=null;for(let o=0;o<t.length;o++){const r=t[o];if(null==(e=null==r?void 0:r.operations)?void 0:e.invisible)continue;const l={x:r.x,y:r.y,w:r.w,h:r.h,angle:r.angle||0};if(l.angle&&(l.angle>0||l.angle<0)){const t=et(l);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];l.x=Math.min(...e),l.y=Math.min(...n),l.w=Math.abs(Math.max(...e)-Math.min(...e)),l.h=Math.abs(Math.max(...n)-Math.min(...n))}}if(i){const t=Math.min(l.x,n.x),e=Math.min(l.y,n.y),i=Math.max(l.x+l.w,n.x+n.w),o=Math.max(l.y+l.h,n.y+n.h);n.x=t,n.y=e,n.w=Math.abs(i-t),n.h=Math.abs(o-e)}else n.x=l.x,n.y=l.y,n.w=l.w,n.h=l.h;i=l}return{x:Math.floor(n.x),y:Math.floor(n.y),w:Math.ceil(n.w),h:Math.ceil(n.h)}}function rt(t,e){const n={x:0,y:0,w:0,h:0};t.forEach((t=>{const e={x:t.x,y:t.y,w:t.w,h:t.h,angle:t.angle};if(e.angle&&(e.angle>0||e.angle<0)){const t=et(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.w=Math.abs(Math.max(...n)-Math.min(...n)),e.h=Math.abs(Math.max(...i)-Math.min(...i))}}const i=Math.min(e.x,n.x),o=Math.min(e.y,n.y),r=Math.max(e.x+e.w,n.x+n.w),l=Math.max(e.y+e.h,n.y+n.h);n.x=i,n.y=o,n.w=Math.abs(r-i),n.h=Math.abs(l-o)})),(null==e?void 0:e.extend)&&(n.x=Math.min(n.x,0),n.y=Math.min(n.y,0));const i={contextWidth:n.w,contextHeight:n.h};return(null==e?void 0:e.viewWidth)&&(null==e?void 0:e.viewHeight)&&(null==e?void 0:e.viewWidth)>0&&(null==e?void 0:e.viewHeight)>0&&(e.viewWidth>n.x+n.w&&(i.contextWidth=e.viewWidth-n.x),e.viewHeight>n.y+n.h&&(i.contextHeight=e.viewHeight-n.y)),i}function lt(t,e){let n=null,i=e;for(let e=0;e<t.length;e++){const o=i[t[e]];if(e<t.length-1&&"group"===(null==o?void 0:o.type))i=o.detail.children;else{if(e!==t.length-1)break;n=o}}return n}function at(t,e){const n=[];let i=!1;const o=e=>{var r;for(let l=0;l<e.length&&!0!==i;l++){n.push(l);const a=e[l];if(a.uuid===t){i=!0;break}if("group"===a.type&&o((null==(r=null==a?void 0:a.detail)?void 0:r.children)||[]),i)break;n.pop()}};return o(e),n}function st(t,e){const n=t.x,i=t.y,o=t.x+t.w,r=t.y+t.h,l=e.x,a=e.y,s=e.x+e.w,c=e.y+e.h;return n<=s&&o>=l&&i<=c&&r>=a}function ct(t){const{x:e,y:n,h:i,w:o}=t;return[{x:e,y:n},{x:e+o,y:n},{x:e+o,y:n+i},{x:e,y:n+i}]}function ut(t){const{x:e,y:n,w:i,h:o,angle:r=0}=t;return 0===r?ct(t):tt(t,q({x:e,y:n,w:i,h:o}),r)}function ht(t){const e=[];let n=0,i=0;const o=[],r=[...t];for(let t=0;t<r.length;t++){const{x:l,y:a,w:s,h:c,angle:u=0}=r[t];let h;if(n+=l,i+=a,0===t){const t={x:n,y:i,w:s,h:c};h=ut({x:l,y:a,w:s,h:c,angle:u}),o.push({center:q(t),angle:u,radian:U(u)})}else{h=ct({x:n,y:i,w:s,h:c});for(let t=0;t<o.length;t++){const{center:e,radian:n}=o[t];h=nt(e,h,n)}const t=Z(h);if(u>0||u<0){h=nt(t,h,U(u))}o.push({center:t,angle:u,radian:U(u)})}e.push(h)}return e}function ft(t,e){const{groupQueue:n}=e;if(!(n.length>0))return[ut(t)];return ht([...n,t])}function dt(t,e){return ft(t,e).pop()||null}function yt(t,e){const{viewScaleInfo:n}=e,{x:i,y:o,w:r,h:l,angle:a}=t,{scale:s,offsetTop:c,offsetLeft:u}=n;return{x:i*s+u,y:o*s+c,w:r*s,h:l*s,angle:a}}function gt(t,e){const{viewScaleInfo:n}=e,{x:i,y:o}=t,{scale:r,offsetTop:l,offsetLeft:a}=n;return{x:i*r+a,y:o*r+l}}function xt(t,e){const{context2d:n,element:i,viewScaleInfo:o}=e,{angle:r=0}=i,{x:l,y:a,w:s,h:c}=yt(i,{viewScaleInfo:o}),u=et({x:l,y:a,w:s,h:c,angle:r});if(u.length>=2){n.beginPath(),n.moveTo(u[0].x,u[0].y);for(let t=1;t<u.length;t++)n.lineTo(u[t].x,u[t].y);n.closePath()}return!!n.isPointInPath(t.x,t.y)}function pt(t,e,n){const i=[e[0].x,e[1].x,e[2].x,e[3].x],o=[e[0].y,e[1].y,e[2].y,e[3].y],r=Math.min(...i),l=Math.max(...i),a=Math.min(...o),s=Math.max(...o);return t.x>r&&t.x<l&&t.y>a&&t.y<s||!0===(null==n?void 0:n.includeBorder)&&(t.x===r||t.x===l||t.y===a||t.y===s)}function mt(t,e){const{groupQueue:n}=e,i=dt(t,{groupQueue:n}),o=Y(i[0],i[1]),r=Y(i[1],i[2]),l=Y(i[2],i[3]),a=Y(i[3],i[0]),s=i[0],c=i[1],u=i[2],h=i[3],f=Math.max(s.x,c.x,u.x,h.x),d=Math.max(s.y,c.y,u.y,h.y);return{center:{x:(f+Math.min(s.x,c.x,u.x,h.x))/2,y:(d+Math.min(s.y,c.y,u.y,h.y))/2},topLeft:s,topRight:c,bottomLeft:h,bottomRight:u,top:o,right:r,left:a,bottom:l}}function bt(t,e){const{x:n,y:i}=t,{size:o,angle:r}=e;return{x:n-o/2,y:i-o/2,w:o,h:o,angle:r}}o=new WeakMap,r=new WeakMap,l=new WeakMap,a=new WeakSet,s=function(){return w(h(this,r))};const vt=/([astvzqmhlc])([^astvzqmhlc]*)/gi,wt=/(-?\d+(?:\.\d+)?)/gi;const Mt=/\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?(".*?"|'.*?')/g,Pt=/<[a-zA-Z0-9\-\!\/](?:"[^"]*"|'[^']*'|[^'">])*>/g,Rt=/^\s*$/,It={};function St(t){const e={type:"element",name:"",isVoid:!1,attributes:{},children:[]},n=t.match(/<\/?([^\s]+?)[/\s>]/);if(n&&(e.name=n[1],(It[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(Mt);let o=null;for(;o=i.exec(t),null!==o;)if(o[0].trim())if(o[1]){const t=o[1].trim();let n=[t,""];t.indexOf("=")>-1&&(n=t.split("=")),e.attributes[n[0]]=n[1],i.lastIndex--}else o[2]&&(e.attributes[o[2]]=o[3].trim().substring(1,o[3].length-1));return e}function $t(t,e){switch(e.type){case"text":return t+e.textContent;case"element":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($t,"")+"</"+e.name+">";case"comment":return t+="\x3c!--"+e.comment+"--\x3e"}}function Et(t,e){let n=2;return void 0!==(null==e?void 0:e.decimalPlaces)&&(null==e?void 0:e.decimalPlaces)>=0&&(n=e.decimalPlaces),parseFloat(t.toFixed(n))}function At(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 zt="Text Element";function kt(){return{boxSizing:"border-box",borderWidth:0,borderColor:"#000000",shadowColor:"#000000",borderRadius:0,borderDash:[],shadowOffsetX:0,shadowOffsetY:0,shadowBlur:0,opacity:1,color:"#000000",textAlign:"left",verticalAlign:"top",fontSize:16,fontFamily:"sans-serif",fontWeight:400,minInlineSize:"auto",wordBreak:"break-all",overflow:"hidden"}}function Ot(){return{background:"#D9D9D9"}}const Lt={boxSizing:"border-box",borderWidth:0,borderColor:"#000000",shadowColor:"#000000",borderRadius:0,borderDash:[],shadowOffsetX:0,shadowOffsetY:0,shadowBlur:0,opacity:1,color:"#000000",textAlign:"left",verticalAlign:"top",fontSize:16,fontFamily:"sans-serif",fontWeight:400,minInlineSize:"auto",wordBreak:"break-all",overflow:"hidden"};function Ct(t,e="",n={},i){return Object.keys(t).forEach((o=>{var r;const l=e?`${e}${function(t){return/^\d+$/.test(t)&&!isNaN(Number(t))}(o)?`[${o}]`:`.${o}`}`:o;if(!(null==(r=null==i?void 0:i.ignorePaths)?void 0:r.includes(l))){const e=t[o];!function(t){return"object"==typeof t&&null!==t&&!(t instanceof Date)||Array.isArray(t)}(e)?n[l]=e:Ct(e,(Array.isArray(e),l),n,i)}})),n}function jt(t,e){return"object"!=typeof t||null===t?{"":t}:Ct(t,"",{},e)}function Tt(t){return jt(t,{ignorePaths:["detail.children"]})}function Dt(t){return jt(t)}function Wt(t){return jt(t)}function Nt(t){return Array.isArray(t)?[...t]:t.split(/\.|\[|\]/).filter((t=>""!==t))}function Ft(t,e,n){const i=Nt(e);if(0===i.length)return t;let o=t;if(o)for(let t=0;t<i.length;t++){const e=i[t];if(t===i.length-1){o[e]=n;break}if(o&&(void 0===(null==o?void 0:o[e])||"object"!=typeof(null==o?void 0:o[e])||null===(null==o?void 0:o[e]))){const n=i[t+1],r=/^\d+$/.test(n);o[e]=r?[]:{}}o=null==o?void 0:o[e]}return t}function Bt(t,e){const n=Nt(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===(null==i?void 0:i[e])||"object"!=typeof(null==i?void 0:i[e])||null===(null==i?void 0:i[e]))){const o=n[t+1],r=/^\d+$/.test(o);i[e]=r?[]:{}}i=null==i?void 0:i[e]}return t}const Vt=t=>Et(t,{decimalPlaces:4});function Ht(t,e){const n={detail:{}},i={detail:{}},o={type:"modifyElement",time:Date.now(),content:{method:"modifyElement",uuid:t.uuid,before:null,after:null}},{detail:r}=t,{xRatio:l,yRatio:a,maxRatio:s}=e,c=(l+a)/2,{borderWidth:u,borderRadius:h,borderDash:f,shadowOffsetX:d,shadowOffsetY:y,shadowBlur:g}=r;if("number"==typeof u)r.borderWidth=Vt(u*c),n.detail.borderWidth=u,i.detail.borderWidth=r.borderWidth;else if(Array.isArray(r.borderWidth)){const t=u;r.borderWidth=[Vt(t[0]*a),Vt(t[1]*l),Vt(t[2]*a),Vt(t[3]*l)],n.detail.borderWidth=[...t],i.detail.borderWidth=[...r.borderWidth]}if("number"==typeof h)r.borderRadius=Vt(h*c),n.detail.borderRadius=h,i.detail.borderRadius=r.borderRadius;else if(Array.isArray(r.borderRadius)){const t=h;r.borderRadius=[t[0]*l,t[1]*l,t[2]*a,t[3]*a],n.detail.borderRadius=[...t],i.detail.borderRadius=[...r.borderRadius]}return Array.isArray(f)&&(f.forEach(((t,e)=>{r.borderDash[e]=Vt(t*s)})),n.detail.borderDash=[...f],i.detail.borderDash=[...r.borderDash]),"number"==typeof d&&(r.shadowOffsetX=Vt(d*s),n.detail.shadowOffsetX=d,i.detail.shadowOffsetX=r.shadowOffsetX),"number"==typeof y&&(r.shadowOffsetY=Vt(y*s),n.detail.shadowOffsetY=y,i.detail.shadowOffsetY=r.shadowOffsetY),"number"==typeof g&&(r.shadowBlur=Vt(g*s),n.detail.shadowBlur=g,i.detail.shadowBlur=r.shadowBlur),o.content.before=Tt(n),o.content.after=Tt(i),o}function Gt(t,e,n){const{type:i,uuid:o}=t,r=function(t,e){const{xRatio:n,yRatio:i}=e,{uuid:o,x:r,y:l,w:a,h:s}=t;t.x=Vt(r*n),t.y=Vt(l*i),t.w=Vt(a*n),t.h=Vt(s*i);const c={type:"modifyElement",time:Date.now(),content:{method:"modifyElement",uuid:o,before:{x:r,y:l,w:a,h:s},after:{x:t.x,y:t.y,w:t.w,h:t.h}}},u=Ht(t,e);return c.content.before={...c.content.before,...u.content.before},c.content.after={...c.content.after,...u.content.after},c}(t,e),l={...r.content.before,uuid:o},a={...r.content.after,uuid:o};if(null==n||n.content.before.push(l),null==n||n.content.after.push(a),"circle"===i);else if("text"===i){const n=function(t,e){const{minRatio:n,maxRatio:i}=e,{fontSize:o,lineHeight:r}=t.detail,l=(n+i)/2,a={},s={};return o&&o>0&&(t.detail.fontSize=Vt(o*l),a["detail.fontSize"]=o,s["detail.fontSize"]=t.detail.fontSize),r&&r>0&&(t.detail.lineHeight=Vt(r*l),a["detail.lineHeight"]=r,s["detail.lineHeight"]=t.detail.lineHeight),{type:"modifyElement",time:Date.now(),content:{method:"modifyElement",uuid:t.uuid,before:a,after:s}}}(t,e);Object.keys(n.content.before||{}).forEach((t=>{var e;l[t]=null==(e=n.content.before)?void 0:e[t]})),Object.keys(n.content.after||{}).forEach((t=>{var e;a[t]=null==(e=n.content.after)?void 0:e[t]}))}else"image"===i||"svg"===i||"html"===i||"path"===i||"group"===i&&Array.isArray(t.detail.children)&&t.detail.children.forEach((t=>{Gt(t,e,n)}))}function Qt(t,e,n){const i={type:"resizeElements",time:Date.now(),content:{method:"modifyElements",before:[],after:[]}},o=t.uuid,r=t.x,l=t.y,a=t.w,s=t.h,c=R.number(e.x)?e.x:t.x,u=R.number(e.y)?e.y:t.y,h=(e.w&&e.w>0?e.w:t.w)||0,f=(e.h&&e.h>0?e.h:t.h)||0,d={uuid:o,x:r,y:l,w:a,h:s},y={uuid:o,x:c,y:u,w:h,h:f};if("deepResize"===(null==n?void 0:n.resizeEffect)){i.content.before.push(d),i.content.after.push(y);const e=h/t.w,n=f/t.h;if(e===n&&1===e)return i;const o=Math.min(e,n),r=Math.max(e,n);t.w=h,t.h=f;const l={xRatio:e,yRatio:n,minRatio:o,maxRatio:r};"group"===t.type&&Array.isArray(t.detail.children)&&t.detail.children.forEach((t=>{Gt(t,l,i)}));const a=Ht(t,l);return Object.keys(a.content.before||{}).forEach((t=>{var e;d[t]=null==(e=a.content.before)?void 0:e[t]})),Object.keys(a.content.after||{}).forEach((t=>{var e;y[t]=null==(e=a.content.after)?void 0:e[t]})),i}if("fixed"===(null==n?void 0:n.resizeEffect)){i.content.before.push(d),i.content.after.push(y);const e=c-t.x,n=u-t.y,o=h-t.w;return function(t,e,n){if("group"!==t.type||!Array.isArray(t.detail.children))return;const{moveX:i,moveY:o,moveH:r,moveW:l}=e;let a=0,s=0,c=!1;0===i&&0===o||0===r&&0===l||(c=!0,a=-i,s=-o),!0===c&&t.detail.children.forEach((t=>{const{uuid:e,x:i,y:o}=t,r=i+a,l=o+s,c={uuid:e,x:i,y:o},u={uuid:e,x:r,y:l};t.x=r,t.y=l,null==n||n.content.before.push(c),null==n||n.content.after.push(u)}))}(t,{moveX:e,moveY:n,moveH:f-t.h,moveW:o},i),t.w=h,t.h=f,t.x=c,t.y=u,i}return t.w=h,t.h=f,t.x=c,t.y=u,i.content.before.push(d),i.content.after.push(y),i}function Yt(t,e,n){let i=!1;if(1===e.length){const o=e[0];n.splice(o,0,t),i=!0}else if(e.length>1){let o=n;for(let n=0;n<e.length;n++){const r=o[e[n]];if(n===e.length-1){const r=e[n];o.splice(r,0,t),i=!0}else{if(!(n<e.length-1&&"group"===r.type))break;o=r.detail.children}}}return i}function Ut(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 o=i[t[e]];if(e===t.length-1){const o=t[e];i.splice(o,1),n=!0}else{if(!(e<t.length-1&&"group"===o.type))break;i=o.detail.children}}}return n}function Xt(t,e,n){const i=Tt(e),o=["uuid","type"],r=Object.keys(i);if(r.forEach((e=>{if(!o.includes(e)){const n=i[e];Bt(t,e),void 0!==n&&Ft(t,e,n)}})),!0===(null==n?void 0:n.strict)){const e=Tt(t);Object.keys(e).forEach((e=>{o.includes(e)||r.includes(e)||Bt(t,e)}))}return t}const qt=["-apple-system",'"system-ui"',' "Segoe UI"'," Roboto",'"Helvetica Neue"',"Arial",'"Noto Sans"'," sans-serif"];function Zt(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 o=e.length-1,r=n.length-1;return"up-down"===i&&o>=0?n[o]-=1:"down-up"===i&&r>=0&&(e[r]+=1),{from:e,to:n}}function Jt(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 Kt(t,e,n){let i=t;for(let t=0;t<e.length;t++){const o=e[t],r=_t(o),l=t===e.length-1;try{r?te(i,o):ee(i,o)}catch(n){throw new Error(`Structure conflict at path '${e.slice(0,t+1).join(".")}': ${n.message}`)}l?ie(i,o,n):i=ne(i,o,e[t+1])}}function _t(t){return/^\d+$/.test(t)}function te(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 ee(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 ne(t,e,n){const i=!!n&&_t(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 ie(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}return t.Context2D=N,t.EventEmitter=class{constructor(){f(this,i),d(this,i,new Map)}on(t,e){if(h(this,i).has(t)){const n=h(this,i).get(t)||[];null==n||n.push(e),h(this,i).set(t,n)}else h(this,i).set(t,[e])}off(t,e){if(h(this,i).has(t)){const n=h(this,i).get(t);if(Array.isArray(n))for(let t=0;t<(null==n?void 0:n.length);t++)if(n[t]===e){n.splice(t,1);break}h(this,i).set(t,n||[])}}trigger(t,e){const n=h(this,i).get(t);return!!Array.isArray(n)&&(n.forEach((t=>{t(e)})),!0)}has(t){if(h(this,i).has(t)){const e=h(this,i).get(t);if(Array.isArray(e)&&e.length>0)return!0}return!1}destroy(){this.clear()}clear(){h(this,i).clear()}},t.Store=class{constructor(t){f(this,a),f(this,o),f(this,r),f(this,l),d(this,r,w(t.defaultStorage)),d(this,o,y(this,a,s).call(this)),d(this,l,t.defaultStatic||{})}set(t,e){h(this,o)[t]=e}get(t){return h(this,o)[t]}setStatic(t,e){h(this,l)[t]=e}getStatic(t){return h(this,l)[t]}getSnapshot(t){return!0===(null==t?void 0:t.deepClone)?w(h(this,o)):{...h(this,o)}}clear(){d(this,o,y(this,a,s).call(this))}destroy(){d(this,o,null),d(this,l,null)}},t.calcDistance=V,t.calcElementCenter=q,t.calcElementCenterFromVertexes=Z,t.calcElementListSize=ot,t.calcElementOriginRectInfo=mt,t.calcElementQueueVertexesQueueInGroup=ht,t.calcElementSizeController=function(t,e){const{groupQueue:n,controllerSize:i,viewScaleInfo:o,rotateControllerSize:r,rotateControllerPosition:l}=e,a=(i&&i>0?i:8)/o.scale,{x:s,y:c,w:u,h:h,angle:f=0}=t,d=r,y=l,g=[{uuid:p(),x:s,y:c,w:u,h:h,angle:f,type:"group",detail:{children:[]}},...n];let x=0;g.forEach((({angle:t=0})=>{x+=t}));const m=dt(t,{groupQueue:n}),b=dt({x:s,y:c-(y+d/2)/o.scale,h:h+(2*y+d)/o.scale,w:u,angle:f},{groupQueue:[...n]}),v=Y(m[0],m[1]),w=Y(m[1],m[2]),M=Y(m[2],m[3]),P=Y(m[3],m[0]),R=m[0],I=m[1],S=m[2],$=m[3],E=bt(v,{size:a,angle:x}),A=bt(w,{size:a,angle:x}),z=bt(M,{size:a,angle:x}),k=bt(P,{size:a,angle:x}),O=bt(R,{size:a,angle:x}),L=bt(I,{size:a,angle:x}),C=bt($,{size:a,angle:x}),j=bt(S,{size:a,angle:x}),T=ut(O),D=ut(L),W=ut(C),N=ut(j),F=[T[1],D[0],D[3],T[2]],B=[D[3],D[2],N[1],N[0]],V=[W[1],N[0],N[3],W[2]],H=[T[3],T[2],W[1],W[0]],G=ut(E),Q=ut(A),U=ut(z),X=ut(k),Z=Y(b[0],b[1]),J=ut(bt(Z,{size:1.1*r/o.scale,angle:x}));return{originalElementCenter:q(t),originalElementSize:{...t},elementWrapper:m,left:{type:"left",vertexes:H,center:P,size:a},right:{type:"right",vertexes:B,center:w,size:a},top:{type:"top",vertexes:F,center:v,size:a},bottom:{type:"bottom",vertexes:V,center:M,size:a},topLeft:{type:"top-left",vertexes:T,center:R,size:a},topRight:{type:"top-right",vertexes:D,center:I,size:a},bottomLeft:{type:"bottom-left",vertexes:W,center:$,size:a},bottomRight:{type:"bottom-right",vertexes:N,center:S,size:a},leftMiddle:{type:"left-middle",vertexes:X,center:P,size:a},rightMiddle:{type:"right-middle",vertexes:Q,center:w,size:a},topMiddle:{type:"top-middle",vertexes:G,center:v,size:a},bottomMiddle:{type:"bottom-middle",vertexes:U,center:M,size:a},rotate:{type:"rotate",vertexes:J,center:Z,size:r}}},t.calcElementVertexesInGroup=dt,t.calcElementVertexesQueueInGroup=ft,t.calcElementViewRectInfo=function(t,e){const{groupQueue:n,viewScaleInfo:i,range:o}=e,r=mt(t,{groupQueue:n}),{center:l,top:a,bottom:s,left:c,right:u,topLeft:h,topRight:f,bottomLeft:d,bottomRight:y}=r,g={center:gt(l,{viewScaleInfo:i}),topLeft:gt(h,{viewScaleInfo:i}),topRight:gt(f,{viewScaleInfo:i}),bottomLeft:gt(d,{viewScaleInfo:i}),bottomRight:gt(y,{viewScaleInfo:i}),top:gt(a,{viewScaleInfo:i}),right:gt(u,{viewScaleInfo:i}),left:gt(c,{viewScaleInfo:i}),bottom:gt(s,{viewScaleInfo:i})};if(!0===o){const t=Math.max(g.topLeft.x,g.topRight.x,g.bottomRight.x,g.bottomLeft.x),e=Math.max(g.topLeft.y,g.topRight.y,g.bottomRight.y,g.bottomLeft.y),n=Math.min(g.topLeft.x,g.topRight.x,g.bottomRight.x,g.bottomLeft.x),i=Math.min(g.topLeft.y,g.topRight.y,g.bottomRight.y,g.bottomLeft.y),o={x:g.center.x,y:g.center.y},r={x:n,y:i},l={x:t,y:i},a={x:t,y:e},s={x:n,y:e},c=Y(r,l),u=Y(s,a),h=Y(r,s);return{center:o,topLeft:r,topRight:l,bottomLeft:s,bottomRight:a,top:c,right:Y(l,a),left:h,bottom:u}}return g},t.calcElementsContextSize=rt,t.calcElementsViewInfo=function(t,e,n){const i=rt(t,{viewWidth:e.width,viewHeight:e.height,extend:null==n?void 0:n.extend});return!0===(null==n?void 0:n.extend)&&(i.contextWidth=Math.max(i.contextWidth,e.contextWidth),i.contextHeight=Math.max(i.contextHeight,e.contextHeight)),{contextSize:i}},t.calcLayoutSizeController=function(t,e){const{controllerSize:n,viewScaleInfo:i}=e,o=n&&n>0?n:8,{x:r,y:l,w:a,h:s}=yt(t,{viewScaleInfo:i}),c=q({x:r,y:l,w:a,h:s}),u={x:c.x,y:l},h={x:r+a,y:c.y},f={x:c.x,y:l+s},d={x:r,y:c.y},y={x:r,y:l},g={x:r+a,y:l},x={x:r+a,y:l+s},p={x:r,y:l+s},m=bt(u,{size:o,angle:0}),b=bt(h,{size:o,angle:0}),v=bt(f,{size:o,angle:0}),w=bt(d,{size:o,angle:0}),M=bt(y,{size:o,angle:0}),P=bt(g,{size:o,angle:0}),R=bt(p,{size:o,angle:0}),I=bt(x,{size:o,angle:0}),S=ut(M),$=ut(P),E=ut(R),A=ut(I),z=[S[1],$[0],$[3],S[2]],k=[$[3],$[2],A[1],A[0]],O=[E[1],A[0],A[3],E[2]],L=[S[3],S[2],E[1],E[0]],C=ut(m),j=ut(b),T=ut(v);return{left:{type:"left",vertexes:L,center:d,size:o},right:{type:"right",vertexes:k,center:h,size:o},top:{type:"top",vertexes:z,center:u,size:o},bottom:{type:"bottom",vertexes:O,center:f,size:o},topLeft:{type:"top-left",vertexes:S,center:y,size:o},topRight:{type:"top-right",vertexes:$,center:g,size:o},bottomLeft:{type:"bottom-left",vertexes:E,center:p,size:o},bottomRight:{type:"bottom-right",vertexes:A,center:x,size:o},leftMiddle:{type:"left-middle",vertexes:ut(w),center:d,size:o},rightMiddle:{type:"right-middle",vertexes:j,center:h,size:o},topMiddle:{type:"top-middle",vertexes:C,center:u,size:o},bottomMiddle:{type:"bottom-middle",vertexes:T,center:f,size:o}}},t.calcPointMoveElementInGroup=function(t,e,n){let i=e.x-t.x,o=e.y-t.y;const r=[];if(n.forEach((t=>{const{x:e,y:n,w:i,h:o,angle:l=0}=t;r.push({x:e,y:n,w:i,h:o,angle:0-l})})),(null==n?void 0:n.length)>0){const n=_(t,r),l=_(e,r);i=l.x-n.x,o=l.y-n.y}return{moveX:i,moveY:o}},t.calcRadian=function(t,e,n){const i=J(t,e),o=J(t,n);return null!==o&&null!==i?o-i:0},t.calcResultMovePosition=Zt,t.calcRevertMovePosition=function(t){const e=Zt(t);return e?{from:[...e.to],to:[...e.from]}:e},t.calcSpeed=function(t,e){return V(t,e)/Math.abs(e.t-t.t)},t.calcViewBoxSize=function(t,e){const{viewScaleInfo:n}=e,{scale:i}=n;let{borderRadius:o}=t.detail;const{borderDash:r}=t.detail,l=Array.isArray(r)&&r.length>0,{boxSizing:a=Lt.boxSizing,borderWidth:s}=t.detail;Array.isArray(s)&&(o=0);let{x:c,y:u,w:h,h:f}=t,d=[0,0,0,0];if("number"==typeof o){const t=o*i;d=[t,t,t,t]}else Array.isArray(o)&&4===(null==o?void 0:o.length)&&(d=[o[0]*i,o[1]*i,o[2]*i,o[3]*i]);let y=0;return"number"==typeof s&&(y=(s||0)*i),"border-box"!==a||l?"content-box"===a?(c=t.x-y/2,u=t.y-y/2,h=t.w+y,f=t.h+y):(c=t.x,u=t.y,h=t.w,f=t.h):(c=t.x+y/2,u=t.y+y/2,h=t.w-y,f=t.h-y),h=Math.max(h,1),f=Math.max(f,1),d=d.map((t=>Math.min(t,h/2,f/2))),{x:c,y:u,w:h,h:f,radiusList:d}},t.calcViewCenter=function(t){let e=0,n=0;if(t){const{viewScaleInfo:i,viewSizeInfo:o}=t,{offsetLeft:r,offsetTop:l,scale:a}=i,{width:s,height:c}=o;e=0-r+s/a/2,n=0-l+c/a/2}return{x:e,y:n}},t.calcViewCenterContent=function(t,e){var n,i,o,r,l,a,s,c,u,h,f,d;let y=0,g=0,x=1,p=(null==(i=null==(n=null==t?void 0:t.elements)?void 0:n[0])?void 0:i.x)||0,m=(null==(r=null==(o=null==t?void 0:t.elements)?void 0:o[0])?void 0:r.y)||0,b=(null==(a=null==(l=null==t?void 0:t.elements)?void 0:l[0])?void 0:a.w)||0,v=(null==(c=null==(s=null==t?void 0:t.elements)?void 0:s[0])?void 0:c.h)||0;const{width:w,height:M}=e.viewSizeInfo;if(T.layout(t.layout)&&"hidden"===(null==(h=null==(u=t.layout)?void 0:u.detail)?void 0:h.overflow)?(p=t.layout.x,m=t.layout.y,b=t.layout.w||0,v=t.layout.h||0):t.elements.forEach((t=>{const e={x:t.x,y:t.y,w:t.w,h:t.h,angle:t.angle};if(e.angle&&(e.angle>0||e.angle<0)){const t=et(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.w=Math.abs(Math.max(...n)-Math.min(...n)),e.h=Math.abs(Math.max(...i)-Math.min(...i))}}const n=Math.min(e.x,p),i=Math.min(e.y,m),o=Math.max(e.x+e.w,p+b),r=Math.max(e.y+e.h,m+v);p=n,m=i,b=Math.abs(o-n),v=Math.abs(r-i)})),(null==t?void 0:t.layout)&&T.layout(t.layout)){const{x:e,y:n,w:i,h:o}=t.layout;"hidden"===(null==(d=null==(f=t.layout)?void 0:f.detail)?void 0:d.overflow)?(p=Math.min(p,e),m=Math.min(m,n),b=Math.min(b,i),v=Math.min(v,o)):(p=Math.min(p,e),m=Math.min(m,n),b=Math.max(b,i),v=Math.max(v,o))}if(b>0&&v>0){const t=Et(w/b,{decimalPlaces:4}),e=Et(M/v,{decimalPlaces:4});x=Math.min(t,e,1),y=(b*x-w)/2/x+p,g=(v*x-M)/2/x+m}return{offsetX:Et(y,{decimalPlaces:0}),offsetY:Et(g,{decimalPlaces:0}),scale:x}},t.calcViewElementSize=yt,t.calcViewPointSize=gt,t.calcViewScaleInfo=function(t,e){const{scale:n,offsetX:i,offsetY:o}=t,{viewSizeInfo:r}=e,{width:l,height:a,contextWidth:s,contextHeight:c}=r,u=0-i*n,h=0-o*n;return{scale:n,offsetLeft:u,offsetTop:h,offsetRight:l-(s*n+u/n),offsetBottom:a-(c*n+h/n)}},t.calcViewVertexes=function(t,e){return[gt(t[0],e),gt(t[1],e),gt(t[2],e),gt(t[3],e)]},t.calcVisiableViewSize=function(t){var e,n;const i=ot(t.elements);return t.layout&&("hidden"===(null==(n=null==(e=t.layout)?void 0:e.detail)?void 0:n.overflow)?(i.x=t.layout.x,i.y=t.layout.y,i.w=t.layout.w,i.h=t.layout.h):(i.x=Math.min(i.x,t.layout.x),i.y=Math.min(i.y,t.layout.y),i.w=Math.max(i.w,t.layout.w),i.h=Math.max(i.h,t.layout.h))),i},t.check=W,t.checkRectIntersect=st,t.colorNameToHex=function(t){const e=t.toLowerCase(),n=x[e];return"string"==typeof n?n:null},t.colorToCSS=function(t){let e="transparent";if("string"==typeof t)e=t;else if(1===(null==t?void 0:t.stops.length))e=t.stops[0].color;else if("linear-gradient"===(null==t?void 0: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"===(null==t?void 0: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"===(null==t?void 0:t.type)||"linear-gradient"===(null==t?void 0: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(o){let r=t[o];o===t.length&&n&&(r=n);if(!r)return Promise.resolve();try{return Promise.resolve(r(e,i.bind(null,o+1)))}catch(t){return Promise.reject(t)}}(0)}},t.compressImage=function(t,e){let n=.5;const i=(null==e?void 0:e.type)||"image/png";return(null==e?void 0:e.radio)&&(null==e?void 0:e.radio)>0&&(null==e?void 0:e.radio)<=1&&(n=null==e?void 0:e.radio),new Promise(((e,o)=>{const r=new Image;r.addEventListener("load",(()=>{const{width:t,height:o}=r,l=t*n,a=o*n;let s=document.createElement("canvas");s.width=l,s.height=a;s.getContext("2d").drawImage(r,0,0,l,a);const c=s.toDataURL(i);s=null,e(c)})),r.addEventListener("error",(t=>{o(t)})),r.src=t}))},t.createAssetId=b,t.createBoardContent=function(t,e){const{width:n,height:i,devicePixelRatio:o}=e,r={width:n,height:i,devicePixelRatio:o},l=t.getContext("2d"),a=B(r),s=B(r),c=B(r),u=F({ctx:l,...r}),h=B(r);return{underlayContext:c,viewContext:a,overlayContext:s,boardContext:u,tempContext:h,drawView:()=>{const{width:t,height:e}=a.$getSize();u.clearRect(0,0,t,e),u.drawImage(c.canvas,0,0,t,e),u.drawImage(a.canvas,0,0,t,e),u.drawImage(s.canvas,0,0,t,e),c.clearRect(0,0,t,e),a.clearRect(0,0,t,e),s.clearRect(0,0,t,e)}}},t.createContext2D=F,t.createElement=function(t,e,n){const i=function(t,e){let n=0,i=0,o=200,r=200;if(e){const{viewScaleInfo:l,viewSizeInfo:a}=e,{scale:s,offsetLeft:c,offsetTop:u}=l,{width:h,height:f}=a,d=h/4,y=f/4;o=200>=d?d/s:200/s,r=200>=y?y/s:200/s,["circle","svg","image"].includes(t)?o=r=Math.max(o,r):"text"===t&&(r=o/12*2),n=(0-c+h/2-o*s/2)/s,i=(0-u+f/2-r*s/2)/s}return{x:n,y:i,w:o,h:r}}(t,n);let o={};return"rect"===t?o={background:"#D9D9D9"}:"circle"===t?o={background:"#D9D9D9",radius:0}:"text"===t?o=function(t){const e={boxSizing:"border-box",borderWidth:0,borderColor:"#000000",shadowColor:"#000000",borderRadius:0,borderDash:[],shadowOffsetX:0,shadowOffsetY:0,shadowBlur:0,opacity:1,color:"#000000",textAlign:"left",verticalAlign:"top",fontSize:16,fontFamily:"sans-serif",fontWeight:400,minInlineSize:"auto",wordBreak:"break-all",overflow:"hidden"};return{text:zt,color:e.color,fontFamily:e.fontFamily,fontWeight:e.fontWeight,fontSize:t.w/12,textAlign:"center",verticalAlign:"middle"}}(i):"svg"===t?o={svg:'<svg t="1701004189871" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" width="200" height="200"><path d="M908.1 353.1l-253.9-36.9L540.7 86.1c-3.1-6.3-8.2-11.4-14.5-14.5-15.8-7.8-35-1.3-42.9 14.5L369.8 316.2l-253.9 36.9c-7 1-13.4 4.3-18.3 9.3-12.3 12.7-12.1 32.9 0.6 45.3l183.7 179.1-43.4 252.9c-1.2 6.9-0.1 14.1 3.2 20.3 8.2 15.6 27.6 21.7 43.2 13.4L512 754l227.1 119.4c6.2 3.3 13.4 4.4 20.3 3.2 17.4-3 29.1-19.5 26.1-36.9l-43.4-252.9 183.7-179.1c5-4.9 8.3-11.3 9.3-18.3 2.7-17.5-9.5-33.7-27-36.3zM664.8 561.6l36.1 210.3L512 672.7 323.1 772l36.1-210.3-152.8-149L417.6 382 512 190.7 606.4 382l211.2 30.7-152.8 148.9z" fill="#2c2c2c"></path></svg>'}:"image"===t?o={src:"data:image/svg+xml;base64,PHN2ZyAgIHZpZXdCb3g9IjAgMCAxMDI0IDEwMjQiIHZlcnNpb249IjEuMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiAgd2lkdGg9IjIwMCIgaGVpZ2h0PSIyMDAiPjxwYXRoIGQ9Ik05MjggMTYwSDk2Yy0xNy43IDAtMzIgMTQuMy0zMiAzMnY2NDBjMCAxNy43IDE0LjMgMzIgMzIgMzJoODMyYzE3LjcgMCAzMi0xNC4zIDMyLTMyVjE5MmMwLTE3LjctMTQuMy0zMi0zMi0zMnogbS00MCA2MzJIMTM2di0zOS45bDEzOC41LTE2NC4zIDE1MC4xIDE3OEw2NTguMSA0ODkgODg4IDc2MS42Vjc5MnogbTAtMTI5LjhMNjY0LjIgMzk2LjhjLTMuMi0zLjgtOS0zLjgtMTIuMiAwTDQyNC42IDY2Ni40bC0xNDQtMTcwLjdjLTMuMi0zLjgtOS0zLjgtMTIuMiAwTDEzNiA2NTIuN1YyMzJoNzUydjQzMC4yeiIgIGZpbGw9IiM1MTUxNTEiPjwvcGF0aD48cGF0aCBkPSJNMzA0IDQ1NmM0OC42IDAgODgtMzkuNCA4OC04OHMtMzkuNC04OC04OC04OC04OCAzOS40LTg4IDg4IDM5LjQgODggODggODh6IG0wLTExNmMxNS41IDAgMjggMTIuNSAyOCAyOHMtMTIuNSAyOC0yOCAyOC0yOC0xMi41LTI4LTI4IDEyLjUtMjggMjgtMjh6IiAgZmlsbD0iIzUxNTE1MSI+PC9wYXRoPjwvc3ZnPg=="}:"group"===t&&(o={children:[],background:"#D9D9D9",overflow:"hidden"}),{uuid:p(),...i,...e,type:t,detail:{...o,...e.detail||{}}}},t.createOffscreenContext2D=B,t.createUUID=p,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=w,t.deepCloneData=function(t){const{elements:e,...n}=t;return{...w(n),elements:e.map((t=>M(t)))}},t.deepCloneElement=M,t.delay=function(t){return new Promise((e=>{setTimeout((()=>{e()}),t)}))},t.deleteElementInList=function(t,e){return Ut(at(t,e),e)},t.deleteElementInListByPosition=Ut,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 o=document.createElement("a");o.href=i,o.download=n,o.click(),o=null},t.downloadImageFromCanvas=function(t,e){const{fileName:n,type:i="image/jpeg"}=e,o=t.toDataURL(i);let r=document.createElement("a");r.href=o,r.download=n,r.click(),r=null},t.elementToBoxInfo=function(t){const{x:e,y:n,w:i,h:o,detail:r}=t,{borderWidth:l,borderRadius:a,boxSizing:s}=r;let c=0,u=0,h=0,f=0,d=0,y=0,g=0,x=0;"number"==typeof l&&l>0?(c=l,u=l,h=l,f=l):Array.isArray(l)&&(c=T.positiveNum(l[0])?l[0]:0,u=T.positiveNum(l[1])?l[0]:0,h=T.positiveNum(l[2])?l[0]:0,f=T.positiveNum(l[3])?l[0]:0),"number"==typeof a&&a>0?(d=a,y=a,g=a,x=a):Array.isArray(a)&&(d=T.positiveNum(a[0])?a[0]:0,y=T.positiveNum(a[0])?a[0]:0,g=T.positiveNum(a[0])?a[0]:0,x=T.positiveNum(a[0])?a[0]:0);const p={x:e,y:n},m={x:e+i,y:n},b={x:e+i,y:n+o},v={x:e,y:n+o},w={x:e,y:n+d},M={x:e+d,y:n},P={x:e+i-y,y:n},R={x:e+i,y:n+y},I={x:e+i,y:n+o-x},S={x:e+i-x,y:n+o},$={x:e+g,y:n+o},E={x:e,y:n+o-g};let A={...p},z={...m},k={...b},O={...v},L={...w},C={...M},j={...P},D={...R},W={...I},N={...S},F={...$},B={...E},V={...p},H={...m},G={...b},Q={...v},Y={...w},U={...M},X={...P},q={...R},Z={...I},J={...S},K={...$},_={...E};return"border-box"===s?(V={x:V.x+f,y:V.y+c},H={x:H.x-u,y:H.y+c},G={x:G.x-u,y:G.y-h},Q={x:Q.x+f,y:Q.y-h},Y={x:Y.x+f,y:Y.y+c},U={x:U.x+f,y:U.y+c},X={x:X.x-u,y:X.y+c},q={x:q.x-u,y:q.y+c},Z={x:Z.x-u,y:Z.y-h},J={x:J.x-u,y:J.y-h},K={x:K.x+f,y:K.y-h},_={x:_.x+f,y:_.y-h}):"content-box"===s?(A={x:A.x-f,y:A.y-c},z={x:z.x+u,y:z.y-c},k={x:k.x+u,y:k.y+h},O={x:O.x-f,y:O.y+h},L={x:L.x-f,y:L.y-c},C={x:C.x-f,y:C.y-c},j={x:j.x+u,y:j.y-c},D={x:D.x+u,y:D.y-c},W={x:W.x+u,y:W.y+h},N={x:N.x+u,y:N.y+h},F={x:F.x-f,y:F.y+h},B={x:B.x-f,y:B.y+h}):(V={x:V.x+f/2,y:V.y+c/2},H={x:H.x-u/2,y:H.y+c/2},G={x:G.x-u/2,y:G.y-h/2},Q={x:Q.x+f/2,y:Q.y-h/2},Y={x:Y.x+f/2,y:Y.y+c/2},U={x:U.x+f/2,y:U.y+c/2},X={x:X.x-u/2,y:X.y+c/2},q={x:q.x-u/2,y:q.y+c/2},Z={x:Z.x-u/2,y:Z.y-h/2},J={x:J.x-u/2,y:J.y-h/2},K={x:K.x+f/2,y:K.y-h/2},_={x:_.x+f/2,y:_.y-h/2},A={x:A.x-f/2,y:A.y-c/2},z={x:z.x+u/2,y:z.y-c/2},k={x:k.x+u/2,y:k.y+h/2},O={x:O.x-f/2,y:O.y+h/2},L={x:L.x-f/2,y:L.y-c/2},C={x:C.x-f/2,y:C.y-c/2},j={x:j.x+u/2,y:j.y-c/2},D={x:D.x+u/2,y:D.y-c/2},W={x:W.x+u/2,y:W.y+h/2},N={x:N.x+u/2,y:N.y+h/2},F={x:F.x-f/2,y:F.y+h/2},B={x:B.x-f/2,y:B.y+h/2}),{btw:c,brw:u,bbw:h,blw:f,btlr:d,btrr:y,bblr:g,bbrr:x,p0:p,p1:m,p2:b,p3:v,p0s:w,p0e:M,p1s:P,p1e:R,p2s:I,p2e:S,p3s:$,p3e:E,op0:A,op1:z,op2:k,op3:O,op0s:L,op0e:C,op1s:j,op1e:D,op2s:W,op2e:N,op3s:F,op3e:B,ip0:V,ip1:H,ip2:G,ip3:Q,ip0s:Y,ip0e:U,ip1s:X,ip1e:q,ip2s:Z,ip2e:J,ip3s:K,ip3e:_}},t.enhanceFontFamliy=function(t){return[t,...qt].join(", ")},t.equalPoint=H,t.equalTouchPoint=function(t,e){return!0===H(t,e)&&t.f===e.f},t.filterCompactData=function(t,e){const n=t.assets||{},i=w(t),o=(null==e?void 0:e.loadItemMap)||{},r=t=>{t.forEach((t=>{var e,i,l;if("image"===t.type&&t.detail.src){const i=t.detail.src;if(v(i)&&!n[i]&&o[i]&&"string"==typeof(null==(e=o[i])?void 0:e.source))n[i]={type:"image",value:o[i].source};else if(!n[i]){const e=b(i,t.uuid);n[e]||(n[e]={type:"image",value:i}),t.detail.src=e}}else if("svg"===t.type){const e=t.detail.svg;if(v(e)&&!n[e]&&o[e]&&"string"==typeof(null==(i=o[e])?void 0:i.source))n[e]={type:"svg",value:o[e].source};else if(!n[e]){const i=b(e,t.uuid);n[i]||(n[i]={type:"svg",value:e}),t.detail.svg=i}}else if("html"===t.type){const e=t.detail.html;if(v(e)&&!n[e]&&o[e]&&"string"==typeof(null==(l=o[e])?void 0:l.source))n[e]={type:"html",value:o[e].source};else if(!n[e]){const i=b(e,t.uuid);n[i]||(n[i]={type:"html",value:e}),t.detail.html=i}}else if("group"===t.type&&Array.isArray(t.detail.children)){const e=t.detail.assets||{};Object.keys(e).forEach((t=>{n[t]||(n[t]=e[t])})),delete t.detail.assets,r(t.detail.children)}}))};return r(i.elements),i.assets=n,i},t.filterElementAsset=function(t){let e=null,n=null,i=null;return"image"===t.type?i=t.detail.src:"svg"===t.type?i=t.detail.svg:"html"===t.type&&(i=t.detail.html),"string"!=typeof i||v(i)||(e=b(i,t.uuid),n={type:t.type,value:i},"image"===t.type?t.detail.src=e:"svg"===t.type?t.detail.svg=e:"html"===t.type&&(t.detail.html=e)),{element:t,assetId:e,assetItem:n}},t.findElementFromList=function t(e,n){var i;let o=null;for(let r=0;r<n.length;r++){const l=n[r];if(l.uuid===e){o=l;break}if(!o&&"group"===l.type){const n=t(e,(null==(i=null==l?void 0:l.detail)?void 0:i.children)||[]);if((null==n?void 0:n.uuid)===e){o=n;break}}}return o},t.findElementFromListByPosition=lt,t.findElementQueueFromListByPosition=function(t,e){const n=[];let i=e;for(let e=0;e<t.length;e++){const o=i[t[e]];if(!o)break;if(n.push(o),!(e<t.length-1&&"group"===o.type))break;i=o.detail.children}return n},t.findElementsFromList=function(t,e){const n=[];return function e(i){var o;for(let r=0;r<i.length;r++){const l=i[r];t.includes(l.uuid)?n.push(l):"group"===l.type&&e((null==(o=null==l?void 0:l.detail)?void 0:o.children)||[])}}(e),n},t.findElementsFromListByPositions=function(t,e){const n=[];return t.forEach((t=>{const i=lt(t,e);i&&n.push(i)})),n},t.flatElementList=function(t){const e=[],n=[],i=t=>{if(!function(t){var e;if(["rect","circle"].includes(t.type)){const e=t.detail;if(!e.background&&!e.borderWidth)return!1;if("transparent"===e.background&&!e.borderWidth)return!1}if(["group"].includes(t.type)){const e=t.detail||{},{children:n}=e;if(!(n.length>0||e.background||e.borderWidth))return!1;if(!(n.length>0||"transparent"!==e.background||e.borderWidth))return!1}if("text"===t.type&&!t.detail.text)return!1;if("image"===t.type&&!t.detail.src)return!1;if("html"===t.type&&!t.detail.html)return!1;if("svg"===t.type&&!t.detail.svg)return!1;if("path"===t.type){const n=t.detail;if(!((null==(e=null==n?void 0:n.commands)?void 0:e.length)>0))return!1}return!0}(t))return;const i=function(t,e){const{groupQueue:n}=e;let{x:i,y:o}=t;const{w:r,h:l,angle:a=0}=t;let s=0;if(n.forEach((t=>{i+=t.x,o+=t.y,s+=t.angle||0})),s=it(s),0===s)return{x:i,y:o,w:r,h:l,angle:a};s+=t.angle||0,s=it(s);const c=dt(t,{groupQueue:n}),u=K(Z(c),c[0],U(0-s));return i=u.x,o=u.y,{x:i,y:o,w:r,h:l,angle:s}}(t,{groupQueue:n}),o={...t,...i};e.push(o)},o=t=>{var e;if(!0!==(null==(e=null==t?void 0:t.operations)?void 0:e.invisible))if("group"===t.type){const{detail:e}=t,{children:r,...l}=e;i({...t,detail:{...l,children:[]}}),n.push(t),r.forEach((t=>{o(t)})),n.pop()}else i(t)};for(let e=0;e<t.length;e++){const n=t[e];o(n)}return e},t.flatObject=jt,t.formatNumber=Et,t.generateHTML=function(t){return t.reduce((function(t,e){return t+$t("",e)}),"")},t.generateSVGPath=function(t){let e="";return t.forEach((t=>{e+=t.type+t.params.join(" ")})),e},t.get=function(t,e,n){if(!e)return;const i=Nt(e);let o=t;for(const t of i){if(null==o)return n;o=o[t]}return void 0!==o?o:n},t.getCenterFromTwoPoints=Y,t.getDefaultElementDetailConfig=kt,t.getDefaultElementRectDetail=Ot,t.getElemenetsAssetIds=function(t){const e=[],n=t=>{t.forEach((t=>{"image"===t.type&&v(t.detail.src)?e.push(t.detail.src):"svg"===t.type&&v(t.detail.svg)?e.push(t.detail.svg):"html"===t.type&&t.detail.html?e.push(t.detail.html):"group"===t.type&&Array.isArray(t.detail.children)&&n(t.detail.children)}))};return n(t),e},t.getElementPositionFromList=at,t.getElementPositionMapFromList=function(t,e){const n=[],i={};let o=!1;const r=e=>{var l;for(let a=0;a<e.length&&!0!==o;a++){n.push(a);const s=e[a];if(t.includes(s.uuid)){if(i[s.uuid]=[...n],Object.keys(i).length===t.length){o=!0;break}}else"group"===s.type&&r((null==(l=null==s?void 0:s.detail)?void 0:l.children)||[]);if(o)break;n.pop()}};return r(e),i},t.getElementRotateVertexes=tt,t.getElementSize=function(t){const{x:e,y:n,w:i,h:o,angle:r}=t;return{x:e,y:n,w:i,h:o,angle:r}},t.getElementVertexes=ct,t.getGroupQueueByElementPosition=function(t,e){var n;const i=[];let o=t;if(e.length>1)for(let t=0;t<e.length-1;t++){const r=o[e[t]];if("group"!==(null==r?void 0:r.type)||!Array.isArray(null==(n=null==r?void 0:r.detail)?void 0:n.children))return null;i.push(r),o=r.detail.children}return i},t.getGroupQueueFromList=function(t,e){const n=[];return function t(e,i){var o;let r=null;for(let l=0;l<i.length;l++){const a=i[l];if(a.uuid===e){r=a;break}if(!r&&"group"===a.type){n.push(a);const i=t(e,(null==(o=null==a?void 0:a.detail)?void 0:o.children)||[]);if((null==i?void 0:i.uuid)===e){r=i;break}n.pop()}}return r}(t,e),n},t.getSelectedElementUUIDs=function(t,e){var n;let i=[];return Array.isArray(null==t?void 0:t.elements)&&(null==(n=null==t?void 0:t.elements)?void 0:n.length)>0&&Array.isArray(e)&&e.length>0&&e.forEach((e=>{var n;"number"==typeof e?(null==(n=null==t?void 0:t.elements)?void 0:n[e])&&i.push(t.elements[e].uuid):"string"==typeof e&&(i=i.concat(function(t,e){var n;const i=[];if("string"==typeof e&&/^\d+(\.\d+)*$/.test(e)){const o=e.split(".");let r=t;for(;o.length>0;){const t=o.shift();if("string"==typeof t){const e=r[parseInt(t)];e&&0===o.length?i.push(e.uuid):"group"===e.type&&o.length>0&&(r=(null==(n=null==e?void 0:e.detail)?void 0:n.children)||[])}break}}return i}(t.elements,e)))})),i},t.getViewPointAtElement=function(t,e){var n,i,o;const{context2d:r,data:l,viewScaleInfo:a,viewSizeInfo:s,groupQueue:c}=e,u={index:-1,element:null,groupQueueIndex:-1};if(c&&Array.isArray(c)&&(null==c?void 0:c.length)>0)for(let e=c.length-1;e>=0;e--){let o=0,l=0,s=0;for(let t=0;t<=e;t++)o+=c[t].x,l+=c[t].y,s+=c[t].angle||0;const h=c[e];if(h&&"group"===h.type&&Array.isArray(null==(n=h.detail)?void 0:n.children))for(let n=0;n<h.detail.children.length;n++){const f=h.detail.children[n];if(!0!==(null==(i=null==f?void 0:f.operations)?void 0:i.invisible)){if(!f)break;if(xt(t,{context2d:r,element:{x:o+f.x,y:l+f.y,w:f.w,h:f.h,angle:s+(f.angle||0)},viewScaleInfo:a})){u.element=f,(e<c.length-1||"group"!==f.type)&&(u.groupQueueIndex=e);break}}}if(u.element)break}if(u.element)return u;for(let e=l.elements.length-1;e>=0;e--){const n=l.elements[e];if(!0!==(null==(o=null==n?void 0:n.operations)?void 0:o.invisible)&&xt(t,{context2d:r,element:n,viewScaleInfo:a})){u.index=e,u.element=n;break}}return u},t.getViewScaleInfoFromSnapshot=function(t){const{activeStore:e}=t;return{scale:null==e?void 0:e.scale,offsetTop:null==e?void 0:e.offsetTop,offsetBottom:null==e?void 0:e.offsetBottom,offsetLeft:null==e?void 0:e.offsetLeft,offsetRight:null==e?void 0:e.offsetRight}},t.getViewSizeInfoFromSnapshot=function(t){const{activeStore:e}=t;return{devicePixelRatio:e.devicePixelRatio,width:null==e?void 0:e.width,height:null==e?void 0:e.height,contextWidth:null==e?void 0:e.contextWidth,contextHeight:null==e?void 0:e.contextHeight}},t.groupElementsByPosition=function(t,e){if(e.length>1){let n=!0,i=[];for(let t=1;t<e.length;t++){const o=e[t-1],r=e[t];if(!(o.length>0&&r.length>0)){n=!1;break}if(o.length!==r.length){n=!1;break}const l=[...o],a=[...r],s=l.pop(),c=a.pop();1===t&&"number"==typeof s&&s>=0&&i.push(s),"number"==typeof c&&c>=0&&i.push(c)}if(!0!==n)return console.error("[idraw]: The grouped elements are not siblings!"),t;i.sort(((t,e)=>t-e));const o=[...e[0]].splice(0,e[0].length-1),r=[],l=[...o,i[0]];for(let e=0;e<i.length;e++){const n=lt([...o,i[e]],t);n&&r.push(n)}const a=ot(r);for(let t=0;t<r.length;t++){const e=r[t];e&&(e.x-=a.x,e.y-=a.y)}for(let e=i.length-1;e>=0;e--){Ut([...o,i[e]],t)}Yt({name:"Group",uuid:p(),type:"group",...a,detail:{children:r}},l,t)}return t},t.insertElementToListByPosition=Yt,t.is=T,t.isAssetId=v,t.isColorStr=g,t.isElementInView=function(t,e){const{viewSizeInfo:n,viewScaleInfo:i}=e,{width:o,height:r}=n,{angle:l}=t,{x:a,y:s,w:c,h:u}=yt(t,{viewScaleInfo:i}),h=et({x:a,y:s,w:c,h:u,angle:l}),f={x:0,y:0,w:o,h:r},d=Math.min(h[0].x,h[1].x,h[2].x,h[3].x),y=Math.min(h[0].y,h[1].y,h[2].y,h[3].y);return st(f,{x:d,y:y,w:Math.max(h[0].x,h[1].x,h[2].x,h[3].x)-d,h:Math.max(h[0].y,h[1].y,h[2].y,h[3].y)-y})},t.isResourceElement=function(t){return["image","svg","html"].includes(null==t?void 0:t.type)},t.isSameElementSize=function(t,e){return t.x===e.x&&t.y===e.y&&t.h===e.h&&t.w===e.w&&it(t.angle||0)===it(e.angle||0)},t.isViewPointInElement=xt,t.isViewPointInElementSize=function(t,e,n){return pt(t,ut(e),n)},t.isViewPointInVertexes=pt,t.istype=R,t.limitAngle=it,t.loadHTML=async function(t,e){t=t.replace(/\&/gi,"&amp;");const n=await function(t,e){const{width:n,height:i}=e;return new Promise(((e,o)=>{const r=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"}),l=new FileReader;l.readAsDataURL(r),l.onload=function(t){var n;const i=null==(n=null==t?void 0:t.target)?void 0:n.result;e(i)},l.onerror=function(t){o(t)}}))}(t,e);return await S(n)},t.loadImage=S,t.loadSVG=async function(t){const e=await function(t){return new Promise(((e,n)=>{const i=new Blob([t],{type:"image/svg+xml;charset=utf-8"}),o=new FileReader;o.readAsDataURL(i),o.onload=function(t){var n;const i=null==(n=null==t?void 0:t.target)?void 0:n.result;e(i)},o.onerror=function(t){n(t)}}))}(t);return await S(e)},t.matrixToAngle=function(t){const e=At(t);if("number"==typeof e){return 180*e/Math.PI}return e},t.matrixToRadian=At,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.mergeElement=Xt,t.mergeElementAsset=function(t,e){const n=t;let i=null,o=null;return"image"===n.type?i=n.detail.src:"svg"===n.type?i=n.detail.svg:"html"===n.type&&(i=n.detail.html),i&&(null==i?void 0:i.startsWith("@assets/"))&&(o=e[i]),(null==o?void 0:o.type)===n.type&&"string"==typeof(null==o?void 0:o.value)&&(null==o?void 0:o.value)&&("image"===n.type?n.detail.src=o.value:"svg"===n.type?n.detail.svg=o.value:"html"===n.type&&(n.detail.html=o.value)),n},t.mergeGlobal=function(t,e,n){const i=Wt(e),o=[],r=Object.keys(i);if(r.forEach((e=>{if(!o.includes(e)){const n=i[e];Bt(t,e),void 0!==n&&Ft(t,e,n)}})),!0===(null==n?void 0:n.strict)){const e=Wt(t);Object.keys(e).forEach((e=>{o.includes(e)||r.includes(e)||Bt(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 o=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")),o=t.substring(0,7)),n*=e,i.test(o)&&n>0&&n<1){const t=Math.max(0,Math.min(255,Math.ceil(256*n)));o=`${o.toUpperCase()}${t.toString(16).toUpperCase()}`}return o},t.mergeLayout=function(t,e,n){const i=Dt(e),o=[],r=Object.keys(i);if(r.forEach((e=>{if(!o.includes(e)){const n=i[e];Bt(t,e),void 0!==n&&Ft(t,e,n)}})),!0===(null==n?void 0:n.strict)){const e=Dt(t);Object.keys(e).forEach((e=>{o.includes(e)||r.includes(e)||Bt(t,e)}))}return t},t.moveElementPosition=function(t,e){const n=[...e.from],i=[...e.to];if(0===n.length||0===i.length)return{elements: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{elements:t,from:n,to:i};const o=lt(n,t);if(o){if(!Yt(o,i,t))return{elements:t,from:n,to:i};let e=-1,r=!1;if(n.length>=1&&i.length>=1){if(n.length<=i.length)if(1===n.length)n[0]<i[0]&&(r=!0);else for(let t=0;t<n.length&&n[t]===i[t];t++)if(n.length===n.length-1){r=!0;break}if(n.length>=i.length)if(1===i.length)i[0]<n[0]&&(r=!0);else for(let t=0;t<i.length&&(t===i.length-1&&i[t]<n[t]&&(r=!0),n[t]===i[t]);t++);}if(!0===r)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),Ut(n,t)}return{elements:t,from:n,to:i}},t.omit=function(t,e){const n={...t};for(const t of e)delete n[t];return n},t.originRectInfoToRangeRectInfo=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),o=Math.min(t.topLeft.y,t.topRight.y,t.bottomRight.y,t.bottomLeft.y),r={x:t.center.x,y:t.center.y},l={x:i,y:o},a={x:e,y:o},s={x:e,y:n},c={x:i,y:n},u=Y(l,a),h=Y(c,s),f=Y(l,c);return{center:r,topLeft:l,topRight:a,bottomLeft:c,bottomRight:s,top:u,right:Y(a,s),left:f,bottom:h}},t.parseAngleToRadian=U,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,o=-1;return t.replace(Pt,((r,l)=>{const a="/"!==r.charAt(1),s=r.startsWith("\x3c!--"),c=l+r.length,u=t.charAt(c);let h;if(s){const t=St(r);return o<0?(e.push(t),r):(h=n[o],h.children.push(t),r)}if(a){if(o++,i=St(r),!i.isVoid&&u&&"<"!==u){const e=t.slice(c,t.indexOf("<",c));e.trim()&&i.children.push({type:"text",name:null,attributes:{},children:[],isVoid:!1,textContent:e.trim()})}0===o&&e.push(i),h=n[o-1],h&&h.children.push(i),n[o]=i}if((!a||!Array.isArray(i)&&i.isVoid)&&(o>-1&&!Array.isArray(i)&&(i.isVoid||i.name===r.slice(2,-1))&&(o--,i=-1===o?e:n[o]),"<"!==u&&u)){h=-1===o?e:n[o].children;const i=t.indexOf("<",c);let r=t.slice(c,-1===i?void 0:i);Rt.test(r)&&(r=" "),(i>-1&&o+h.length>=0||" "!==r)&&r.trim()&&h.push({type:"text",name:null,attributes:{},children:[],isVoid:!1,textContent:r.trim()})}return r})),e},t.parseRadianToAngle=function(t){return t/Math.PI*180},t.parseSVGPath=function(t){const e=[];return t.replace(vt,((t,n,i)=>{const o=i.match(wt),r={type:n,params:o?o.map(Number):[]};return e.push(r),t})),e},t.pickFile=function(t){const{accept:e,success:n,error:i}=t;let o=document.createElement("input");o.type="file",e&&(o.accept=e),o.addEventListener("change",(function(){var t;const e=null==(t=o.files)?void 0:t[0];n({file:e}),o=null})),o.addEventListener("error",(function(t){"function"==typeof i&&i(t),o=null})),o.click()},t.resizeEffectGroupElement=Qt,t.rotateByCenter=X,t.rotateElement=function(t,e,n){const i=q(e);X(t,e.angle||0,i,(()=>{n(t)}))},t.rotateElementVertexes=et,t.rotatePoint=K,t.rotatePointInGroup=_,t.rotateVertexes=nt,t.set=Ft,t.sortDataAsserts=function(t,e){const n=t.assets||{};let i=t;!0===(null==e?void 0:e.clone)&&(i=w(t));const o=t=>{t.forEach((t=>{if("image"===t.type&&t.detail.src){const e=t.detail.src,i=b(e,t.uuid);n[i]||(n[i]={type:"image",value:e}),t.detail.src=i}else if("svg"===t.type){const e=t.detail.svg,i=b(e,t.uuid);n[i]||(n[i]={type:"svg",value:e}),t.detail.svg=i}else if("html"===t.type){const e=t.detail.html,i=b(e,t.uuid);n[i]||(n[i]={type:"html",value:e}),t.detail.html=i}else if("group"===t.type&&Array.isArray(t.detail.children)){const e=t.detail.assets||{};Object.keys(e).forEach((t=>{n[t]||(n[t]=e[t])})),delete t.detail.assets,o(t.detail.children)}}))};return o(i.elements),i.assets=n,i},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.toFlattenElement=Tt,t.toFlattenGlobal=Wt,t.toFlattenLayout=Dt,t.toPath=Nt,t.unflatObject=function(t){const e={};for(const[n,i]of Object.entries(t)){Kt(e,Jt(n),i)}return e},t.ungroupElementsByPosition=function(t,e){var n;const i=lt(e,t);i&&"group"===(null==i?void 0:i.type)&&Array.isArray(null==(n=null==i?void 0:i.detail)?void 0:n.children)||console.error("[idraw]: The ungrouped element is not a group element!");const o=[...e].splice(0,e.length-1),r=e[e.length-1],{x:l,y:a}=i;return Ut(e,t),i.detail.children.forEach(((e,n)=>{e.x+=l,e.y+=a;Yt(e,[...o,r+n],t)})),t},t.updateElementInList=function t(e,n,i){var o,r,l;let a=null;for(let s=0;s<i.length;s++){const c=i[s];if(c.uuid===e){"group"===c.type&&(null==(o=c.operations)?void 0:o.resizeEffect)&&Qt(c,{...n},{resizeEffect:null==(r=c.operations)?void 0:r.resizeEffect}),Xt(c,n),a=c;break}"group"===c.type&&(a=t(e,n,(null==(l=null==c?void 0:c.detail)?void 0:l.children)||[]))}return a},t.updateElementInListByPosition=function(t,e,n,i){var o,r;const l=lt(t,n);return l&&("group"===l.type&&(null==(o=l.operations)?void 0:o.resizeEffect)&&Qt(l,{...e},{resizeEffect:null==(r=l.operations)?void 0:r.resizeEffect}),Xt(l,e,i)),l},t.vaildPoint=Q,t.vaildTouchPoint=function(t){return!0===Q(t)&&t.f>=0},t.validateElements=function t(e){let n=!0;if(Array.isArray(e)){const i=[];e.forEach((e=>{var o;"string"==typeof e.uuid&&e.uuid?i.includes(e.uuid)?(n=!1,console.warn(`Duplicate uuids: ${e.uuid}`)):i.push(e.uuid):(n=!1,console.warn("Element missing uuid",e)),"group"===e.type&&(n=t(null==(o=null==e?void 0:e.detail)?void 0:o.children))}))}return n},t.viewScale=function(t){const{scale:e,point:n,viewScaleInfo:i}=t,{offsetLeft:o,offsetTop:r}=i,l=e/i.scale,a=n.x,s=n.y;return{moveX:a-a*l+(o*l-o),moveY:s-s*l+(r*l-r)}},t.viewScroll=function(t){const{moveX:e=0,moveY:n=0,viewScaleInfo:i,viewSizeInfo:o}=t,{scale:r}=i,{width:l,height:a,contextWidth:s,contextHeight:c}=o;let u=i.offsetLeft,h=i.offsetRight,f=i.offsetTop,d=i.offsetBottom;return u+=e,f+=n,h=l-(s*r+u),d=a-(c*r+f),{scale:r,offsetTop:f,offsetLeft:u,offsetRight:h,offsetBottom:d}},Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),t}({});
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}({});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@idraw/util",
3
- "version": "0.4.2",
3
+ "version": "1.0.0-alpha.1",
4
4
  "description": "",
5
5
  "main": "dist/esm/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -1,35 +0,0 @@
1
- import type { Data, Element, Elements, ElementType, ElementSize, ViewContextSize, ViewSizeInfo, ElementAssets, ElementAssetsItem, LoadElementType, ElementPosition } from '@idraw/types';
2
- export declare function getSelectedElementUUIDs(data: Data, indexes: Array<number | string>): string[];
3
- export declare function validateElements(elements: Array<Element<ElementType>>): boolean;
4
- export declare function calcElementListSize(list: Elements): ElementSize;
5
- export declare function calcElementsContextSize(elements: Array<Element<ElementType>>, opts?: {
6
- viewWidth: number;
7
- viewHeight: number;
8
- extend?: boolean;
9
- }): ViewContextSize;
10
- export declare function calcElementsViewInfo(elements: Array<Element<ElementType>>, prevViewSize: ViewSizeInfo, options?: {
11
- extend: boolean;
12
- }): {
13
- contextSize: ViewContextSize;
14
- };
15
- export declare function getElemenetsAssetIds(elements: Elements): string[];
16
- export declare function findElementFromList(uuid: string, list: Element<ElementType>[]): Element<ElementType> | null;
17
- export declare function findElementsFromList(uuids: string[], list: Element<ElementType>[]): Element<ElementType>[];
18
- export declare function getGroupQueueFromList(uuid: string, elements: Element<ElementType>[]): Element<'group'>[];
19
- export declare function getGroupQueueByElementPosition(elements: Element<ElementType>[], position: ElementPosition): Element<'group'>[] | null;
20
- export declare function getElementSize(elem: Element): ElementSize;
21
- export declare function mergeElementAsset<T extends Element<LoadElementType>>(element: T, assets: ElementAssets): T;
22
- export declare function filterElementAsset<T extends Element<LoadElementType>>(element: T): {
23
- element: T;
24
- assetId: string | null;
25
- assetItem: ElementAssetsItem | null;
26
- };
27
- export declare function isResourceElement(elem: Element): boolean;
28
- export declare function findElementsFromListByPositions(positions: ElementPosition[], list: Element[]): Element[];
29
- export declare function findElementFromListByPosition(position: ElementPosition, list: Element[]): Element | null;
30
- export declare function findElementQueueFromListByPosition(position: ElementPosition, list: Element[]): Element[];
31
- export declare function getElementPositionFromList(uuid: string, elements: Element<ElementType>[]): ElementPosition;
32
- export declare function getElementPositionMapFromList(uuids: string[], elements: Element<ElementType>[]): {
33
- [uuid: string]: ElementPosition;
34
- };
35
- export declare function isSameElementSize(elem1: ElementSize, elem2: ElementSize): boolean;