@idraw/util 0.4.0-alpha.3 → 0.4.0-alpha.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- var iDrawUtil=function(t){"use strict";function e(t){return"string"==typeof t&&(/^\#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(t)||/^[a-z]{1,}$/i.test(t))}const n={aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",green:"#008000",greenyellow:"#adff2f",honeydew:"#f0fff0",hotpink:"#ff69b4","indianred ":"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrodyellow:"#fafad2",lightgrey:"#d3d3d3",lightgreen:"#90ee90",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370d8",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#d87093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",rebeccapurple:"#663399",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32"};function i(){function t(){return(65536*(1+Math.random())|0).toString(16).substring(1)}return`${t()}${t()}-${t()}-${t()}-${t()}-${t()}${t()}${t()}`}function o(t){let e=0;for(let n=0;n<t.length;n++)e+=t.charCodeAt(n)*t.charCodeAt(n)*n*n;return e.toString(16).substring(0,4)}function r(t){const e=t.length,n=Math.floor(e/2),i=t.substring(0,4).padEnd(4,"0"),r=t.substring(0,4).padEnd(4,"0");return`@assets/${o(e.toString(16).padEnd(4,i))}${o(t.substring(n-4,n).padEnd(4,i)).padEnd(4,"f")}-${o(t.substring(n-8,n-4).padEnd(4,i)).padEnd(4,"f")}-${o(t.substring(n-12,n-8).padEnd(4,i)).padEnd(4,"f")}-${o(t.substring(n-16,n-12).padEnd(4,r)).padEnd(4,"f")}-${o(t.substring(n,n+4).padEnd(4,r)).padEnd(4,"f")}${o(t.substring(n+4,n+8).padEnd(4,r)).padEnd(4,"f")}${o(r.padEnd(4,i).padEnd(4,r))}`}function a(t){return/^@assets\/[0-9a-z]{8,8}\-[0-9a-z]{4,4}\-[0-9a-z]{4,4}\-[0-9a-z]{4,4}\-[0-9a-z]{12,12}$/.test(`${t}`)}function s(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){return(Object.prototype.toString.call(t)||"").replace(/(\[object|\])/gi,"").trim()}const c={type(t,e){const n=l(t);return!0===e?n.toLocaleLowerCase():n},array:t=>"Array"===l(t),json:t=>"Object"===l(t),function:t=>"Function"===l(t),asyncFunction:t=>"AsyncFunction"===l(t),string:t=>"String"===l(t),number:t=>"Number"===l(t),undefined:t=>"Undefined"===l(t),null:t=>"Null"===l(t),promise:t=>"Promise"===l(t)};const{Image:u}=window;function h(t){return new Promise(((e,n)=>{const i=new u;i.crossOrigin="anonymous",i.onload=function(){e(i)},i.onabort=n,i.onerror=n,i.src=t}))}function f(t){return"number"==typeof t&&(t>0||t<=0)}function d(t){return"number"==typeof t&&t>=0}function x(t){return"string"==typeof t&&/^(http:\/\/|https:\/\/|\.\/|\/)/.test(`${t}`)}function g(t){return"string"==typeof t&&/^(data:image\/)/.test(`${t}`)}const m={x:function(t){return f(t)},y:function(t){return f(t)},w:d,h:function(t){return"number"==typeof t&&t>=0},angle:function(t){return"number"==typeof t&&t>=-360&&t<=360},number:f,numberStr:function(t){return/^(-?\d+(?:\.\d+)?)$/.test(`${t}`)},borderWidth:function(t){return d(t)},borderRadius:function(t){return f(t)&&t>=0},color:function(t){return e(t)},imageSrc:function(t){return g(t)||x(t)},imageURL:x,imageBase64:g,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 f(t)&&t>0},lineHeight:function(t){return f(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 f(t)&&t>0}};function y(t={}){const{borderColor:e,borderRadius:n,borderWidth:i}=t;return!(t.hasOwnProperty("borderColor")&&!m.color(e))&&(!(t.hasOwnProperty("borderRadius")&&!m.number(n))&&!(t.hasOwnProperty("borderWidth")&&!m.number(i)))}const p={attrs:function(t){const{x:e,y:n,w:i,h:o,angle:r}=t;return!!(m.x(e)&&m.y(n)&&m.w(i)&&m.h(o)&&m.angle(r))&&(r>=-360&&r<=360)},textDesc:function(t){const{text:e,color:n,fontSize:i,lineHeight:o,fontFamily:r,textAlign:a,fontWeight:s,background:l,strokeWidth:c,strokeColor:u}=t;return!!m.text(e)&&(!!m.color(n)&&(!!m.fontSize(i)&&(!(t.hasOwnProperty("background")&&!m.color(l))&&(!(t.hasOwnProperty("fontWeight")&&!m.fontWeight(s))&&(!(t.hasOwnProperty("lineHeight")&&!m.lineHeight(o))&&(!(t.hasOwnProperty("fontFamily")&&!m.fontFamily(r))&&(!(t.hasOwnProperty("textAlign")&&!m.textAlign(a))&&(!(t.hasOwnProperty("strokeWidth")&&!m.strokeWidth(c))&&(!(t.hasOwnProperty("strokeColor")&&!m.color(u))&&!!y(t))))))))))},rectDesc:function(t){const{background:e}=t;return!(t.hasOwnProperty("background")&&!m.color(e))&&!!y(t)},circleDesc:function(t){const{background:e,borderColor:n,borderWidth:i}=t;return!(t.hasOwnProperty("background")&&!m.color(e))&&(!(t.hasOwnProperty("borderColor")&&!m.color(n))&&!(t.hasOwnProperty("borderWidth")&&!m.number(i)))},imageDesc:function(t){const{src:e}=t;return!!m.imageSrc(e)},svgDesc:function(t){const{svg:e}=t;return!!m.svg(e)},htmlDesc:function(t){const{html:e}=t;return!!m.html(e)}};class v{constructor(t,e){this._devicePixelRatio=1;const{devicePixelRatio:n=1}=e;this._ctx=t,this._devicePixelRatio=n}$undoPixelRatio(t){return t/this._devicePixelRatio}$doPixelRatio(t){return this._devicePixelRatio*t}$getContext(){return this._ctx}$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._ctx.font=`${e.join(" ")}`}$resize(t){const{width:e,height:n,devicePixelRatio:i}=t,{canvas:o}=this._ctx;o.width=e*i,o.height=n*i,this._devicePixelRatio=i}get canvas(){return this._ctx.canvas}get fillStyle(){return this._ctx.fillStyle}set fillStyle(t){this._ctx.fillStyle=t}get strokeStyle(){return this._ctx.strokeStyle}set strokeStyle(t){this._ctx.strokeStyle=t}get lineWidth(){return this.$undoPixelRatio(this._ctx.lineWidth)}set lineWidth(t){this._ctx.lineWidth=this.$doPixelRatio(t)}get textAlign(){return this._ctx.textAlign}set textAlign(t){this._ctx.textAlign=t}get textBaseline(){return this._ctx.textBaseline}set textBaseline(t){this._ctx.textBaseline=t}get globalAlpha(){return this._ctx.globalAlpha}set globalAlpha(t){this._ctx.globalAlpha=t}get shadowColor(){return this._ctx.shadowColor}set shadowColor(t){this._ctx.shadowColor=t}get shadowOffsetX(){return this.$undoPixelRatio(this._ctx.shadowOffsetX)}set shadowOffsetX(t){this._ctx.shadowOffsetX=this.$doPixelRatio(t)}get shadowOffsetY(){return this.$undoPixelRatio(this._ctx.shadowOffsetY)}set shadowOffsetY(t){this._ctx.shadowOffsetY=this.$doPixelRatio(t)}get shadowBlur(){return this.$undoPixelRatio(this._ctx.shadowBlur)}set shadowBlur(t){this._ctx.shadowBlur=this.$doPixelRatio(t)}get lineCap(){return this._ctx.lineCap}set lineCap(t){this._ctx.lineCap=t}get globalCompositeOperation(){return this._ctx.globalCompositeOperation}set globalCompositeOperation(t){this._ctx.globalCompositeOperation=t}fill(...t){return this._ctx.fill(...t)}arc(t,e,n,i,o,r){return this._ctx.arc(this.$doPixelRatio(t),this.$doPixelRatio(e),this.$doPixelRatio(n),i,o,r)}rect(t,e,n,i){return this._ctx.rect(this.$doPixelRatio(t),this.$doPixelRatio(e),this.$doPixelRatio(n),this.$doPixelRatio(i))}fillRect(t,e,n,i){return this._ctx.fillRect(this.$doPixelRatio(t),this.$doPixelRatio(e),this.$doPixelRatio(n),this.$doPixelRatio(i))}clearRect(t,e,n,i){return this._ctx.clearRect(this.$doPixelRatio(t),this.$doPixelRatio(e),this.$doPixelRatio(n),this.$doPixelRatio(i))}beginPath(){return this._ctx.beginPath()}closePath(){return this._ctx.closePath()}lineTo(t,e){return this._ctx.lineTo(this.$doPixelRatio(t),this.$doPixelRatio(e))}moveTo(t,e){return this._ctx.moveTo(this.$doPixelRatio(t),this.$doPixelRatio(e))}arcTo(t,e,n,i,o){return this._ctx.arcTo(this.$doPixelRatio(t),this.$doPixelRatio(e),this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(o))}getLineDash(){return this._ctx.getLineDash()}setLineDash(t){return this._ctx.setLineDash(t.map((t=>this.$doPixelRatio(t))))}stroke(t){return t?this._ctx.stroke(t):this._ctx.stroke()}translate(t,e){return this._ctx.translate(this.$doPixelRatio(t),this.$doPixelRatio(e))}rotate(t){return this._ctx.rotate(t)}drawImage(...t){const e=t[0],n=t[1],i=t[2],o=t[3],r=t[4],a=t[t.length-4],s=t[t.length-3],l=t[t.length-2],c=t[t.length-1];return 9===t.length?this._ctx.drawImage(e,this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(o),this.$doPixelRatio(r),this.$doPixelRatio(a),this.$doPixelRatio(s),this.$doPixelRatio(l),this.$doPixelRatio(c)):this._ctx.drawImage(e,this.$doPixelRatio(a),this.$doPixelRatio(s),this.$doPixelRatio(l),this.$doPixelRatio(c))}createPattern(t,e){return this._ctx.createPattern(t,e)}measureText(t){return this._ctx.measureText(t)}fillText(t,e,n,i){return void 0!==i?this._ctx.fillText(t,this.$doPixelRatio(e),this.$doPixelRatio(n),this.$doPixelRatio(i)):this._ctx.fillText(t,this.$doPixelRatio(e),this.$doPixelRatio(n))}strokeText(t,e,n,i){return void 0!==i?this._ctx.strokeText(t,this.$doPixelRatio(e),this.$doPixelRatio(n),this.$doPixelRatio(i)):this._ctx.strokeText(t,this.$doPixelRatio(e),this.$doPixelRatio(n))}save(){this._ctx.save()}restore(){this._ctx.restore()}scale(t,e){this._ctx.scale(t,e)}circle(t,e,n,i,o,r,a,s){this._ctx.ellipse(this.$doPixelRatio(t),this.$doPixelRatio(e),this.$doPixelRatio(n),this.$doPixelRatio(i),o,r,a,s)}isPointInPath(t,e){return this._ctx.isPointInPath(this.$doPixelRatio(t),this.$doPixelRatio(e))}clip(...t){return this._ctx.clip(...t)}setTransform(t,e,n,i,o,r){return this._ctx.setTransform(t,e,n,i,o,r)}getTransform(){return this._ctx.getTransform()}createLinearGradient(t,e,n,i){return this._ctx.createLinearGradient(this.$doPixelRatio(t),this.$doPixelRatio(e),this.$doPixelRatio(n),this.$doPixelRatio(i))}createRadialGradient(t,e,n,i,o,r){return this._ctx.createRadialGradient(this.$doPixelRatio(t),this.$doPixelRatio(e),this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(o),this.$doPixelRatio(r))}createConicGradient(t,e,n){return this._ctx.createConicGradient(t,this.$doPixelRatio(e),this.$doPixelRatio(n))}}function w(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 v(r,t)}function b(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 P(t,e){return t.x===e.x&&t.y===e.y&&t.t===e.t}function $(t){return t>=0||t<0}function R(t){return $(t.x)&&$(t.y)&&t.t>0}function _(t,e){return{x:t.x+(e.x-t.x)/2,y:t.y+(e.y-t.y)/2}}function M(t){return t/180*Math.PI}function I(t){return{x:t.x+t.w/2,y:t.y+t.h/2}}function S(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 I({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 k(t,e,n){const i=function(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}(t,e);let o=i+n;o>2*Math.PI?o-=2*Math.PI:o<0-2*Math.PI&&(o+=2*Math.PI),o<0&&(o+=2*Math.PI);const r=b(t,e);let a=0,s=0;return 0===o?(a=0,s=0-r):o>0&&o<Math.PI/2?(a=Math.sin(o)*r,s=0-Math.cos(o)*r):o===Math.PI/2?(a=r,s=0):o>Math.PI/2&&o<Math.PI?(a=Math.sin(Math.PI-o)*r,s=Math.cos(Math.PI-o)*r):o===Math.PI?(a=0,s=r):o>Math.PI&&o<1.5*Math.PI?(a=0-Math.sin(o-Math.PI)*r,s=Math.cos(o-Math.PI)*r):o===1.5*Math.PI?(a=0-r,s=0):o>1.5*Math.PI&&o<2*Math.PI?(a=0-Math.sin(2*Math.PI-o)*r,s=0-Math.cos(2*Math.PI-o)*r):o===2*Math.PI&&(a=0,s=0-r),a+=t.x,s+=t.y,{x:a,y:s}}function E(t,e,n){const{x:i,y:o,w:r,h:a}=t;let s={x:i,y:o},l={x:i+r,y:o},c={x:i+r,y:o+a},u={x:i,y:o+a};if(n&&(n>0||n<0)){const t=M(O(n));s=k(e,s,t),l=k(e,l,t),c=k(e,c,t),u=k(e,u,t)}return[s,l,c,u]}function A(t){const{angle:e=0}=t;return E(t,I(t),e)}function C(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 O(t){if(!(t>0||t<0)||0===t)return 0;let e=t%360;return e<0&&(e+=360),e}function T(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=A(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),a=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(a-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 z(t,e){const n=Object.keys(e);for(let i=0;i<n.length;i++){const o=n[i];["x","y","w","h","angle","name"].includes(o)?t[o]=e[o]:["detail","operations"].includes(o)&&(istype.json(e[o])&&istype.json(t[o])||istype.array(e[o])&&istype.array(t[o]))&&(t[o]={...t[o],...e[o]})}return t}function W(t,e){const n=t.x,i=t.y,o=t.x+t.w,r=t.y+t.h,a=e.x,s=e.y,l=e.x+e.w,c=e.y+e.h;return n<=l&&o>=a&&i<=c&&r>=s}function L(t,e){const{viewScaleInfo:n}=e,{x:i,y:o,w:r,h:a,angle:s}=t,{scale:l,offsetTop:c,offsetLeft:u}=n;return{x:i*l+u,y:o*l+c,w:r*l,h:a*l,angle:s}}function V(t,e){const{viewScaleInfo:n}=e,{x:i,y:o}=t,{scale:r,offsetTop:a,offsetLeft:s}=n;return{x:i*r+s,y:o*r+a}}function D(t,e){const{context2d:n,element:i,viewScaleInfo:o,viewSizeInfo:r}=e,{angle:a=0}=i,{x:s,y:l,w:c,h:u}=L(i,{viewScaleInfo:o,viewSizeInfo:r}),h=A({x:s,y:l,w:c,h:u,angle:a});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 H(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 j(t){const{x:e,y:n,w:i,h:o,angle:r=0}=t;return 0===r?H(t):E(t,I({x:e,y:n,w:i,h:o,angle:r}),r)}function F(t){const e=[];let n=0,i=0;const o=[],r=[...t];for(let t=0;t<r.length;t++){const{x:a,y:s,w:l,h:c,angle:u=0}=r[t];let h;if(n+=a,i+=s,0===t){const t={x:n,y:i,w:l,h:c,angle:u};h=j({x:a,y:s,w:l,h:c,angle:u}),o.push({center:I(t),angle:u,radian:M(u)})}else{h=H({x:n,y:i,w:l,h:c,angle:u});for(let t=0;t<o.length;t++){const{center:e,radian:n}=o[t];h=C(e,h,n)}const t=S(h);if(u>0||u<0){h=C(t,h,M(u))}o.push({center:t,angle:u,radian:M(u)})}e.push(h)}return e}function B(t,e){const{groupQueue:n}=e;if(!(n.length>0))return[j(t)];return F([...n,t])}function q(t,e){return B(t,e).pop()||null}function G(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}}const U=/([astvzqmhlc])([^astvzqmhlc]*)/gi,Q=/(-?\d+(?:\.\d+)?)/gi;const N=/\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?(".*?"|'.*?')/g,X=/<[a-zA-Z0-9\-\!\/](?:"[^"]*"|'[^']*'|[^'">])*>/g,Y=/^\s*$/,Z={};function J(t){const e={type:"element",name:"",isVoid:!1,attributes:{},children:[]},n=t.match(/<\/?([^\s]+?)[/\s>]/);if(n&&(e.name=n[1],(Z[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(N);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 K(t,e){switch(e.type){case"text":return t+e.textContent;case"element":return t+="<"+e.name+(e.attributes?function(t){const e=[];for(let n in t)e.push(n+'="'+t[n]+'"');return e.length?" "+e.join(" "):""}(e.attributes):"")+(e.isVoid?"/>":">"),e.isVoid?t:t+e.children.reduce(K,"")+"</"+e.name+">";case"comment":return t+="\x3c!--"+e.comment+"--\x3e"}}return t.Context2D=v,t.EventEmitter=class{constructor(){this._listeners=new Map}on(t,e){if(this._listeners.has(t)){const n=this._listeners.get(t)||[];null==n||n.push(e),this._listeners.set(t,n)}else this._listeners.set(t,[e])}off(t,e){if(this._listeners.has(t)){const n=this._listeners.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}this._listeners.set(t,n||[])}}trigger(t,e){const n=this._listeners.get(t);return!!Array.isArray(n)&&(n.forEach((t=>{t(e)})),!0)}has(t){if(this._listeners.has(t)){const e=this._listeners.get(t);if(Array.isArray(e)&&e.length>0)return!0}return!1}},t.Store=class{constructor(t){this._backUpDefaultStorage=s(t.defaultStorage),this._temp=this._createTempStorage()}set(t,e){this._temp[t]=e}get(t){return this._temp[t]}getSnapshot(){return s(this._temp)}clear(){this._temp=this._createTempStorage()}_createTempStorage(){return s(this._backUpDefaultStorage)}},t.calcDistance=b,t.calcElementCenter=I,t.calcElementCenterFromVertexes=S,t.calcElementQueueVertexesQueueInGroup=F,t.calcElementSizeController=function(t,e){const{groupQueue:n,controllerSize:o,viewScaleInfo:r}=e,a=(o&&o>0?o:8)/r.scale,{x:s,y:l,w:c,h:u,angle:h=0}=t,f=[{uuid:i(),x:s,y:l,w:c,h:u,angle:h,type:"group",detail:{children:[]}},...n];let d=0;f.forEach((({angle:t=0})=>{d+=t}));const x=q(t,{groupQueue:n}),g=_(x[0],x[1]),m=_(x[1],x[2]),y=_(x[2],x[3]),p=_(x[3],x[0]),v=x[0],w=x[1],b=x[2],P=x[3],$=G(g,{size:a,angle:d}),R=G(m,{size:a,angle:d}),M=G(y,{size:a,angle:d}),I=G(p,{size:a,angle:d}),S=G(v,{size:a,angle:d}),k=G(w,{size:a,angle:d}),E=G(P,{size:a,angle:d}),A=G(b,{size:a,angle:d});return{elementWrapper:x,left:{type:"left",vertexes:j(I),center:p},right:{type:"right",vertexes:j(R),center:m},top:{type:"top",vertexes:j($),center:g},bottom:{type:"bottom",vertexes:j(M),center:y},topLeft:{type:"top-left",vertexes:j(S),center:v},topRight:{type:"top-right",vertexes:j(k),center:w},bottomLeft:{type:"bottom-left",vertexes:j(E),center:P},bottomRight:{type:"bottom-right",vertexes:j(A),center:b}}},t.calcElementVertexesInGroup=q,t.calcElementVertexesQueueInGroup=B,t.calcElementsContextSize=T,t.calcElementsViewInfo=function(t,e,n){const i=T(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.calcSpeed=function(t,e){return b(t,e)/Math.abs(e.t-t.t)},t.calcViewElementSize=L,t.calcViewPointSize=V,t.calcViewVertexes=function(t,e){return[V(t[0],e),V(t[1],e),V(t[2],e),V(t[3],e)]},t.check=p,t.checkRectIntersect=W,t.colorNameToHex=function(t){const e=t.toLowerCase(),i=n[e];return"string"==typeof i?i:null},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,a=t*n,s=o*n;let l=document.createElement("canvas");l.width=a,l.height=s;l.getContext("2d").drawImage(r,0,0,a,s);const c=l.toDataURL(i);l=null,e(c)})),r.addEventListener("error",(t=>{o(t)})),r.src=t}))},t.createAssetId=r,t.createBoardContexts=function(t,e){const n={width:t.canvas.width,height:t.canvas.height,devicePixelRatio:(null==e?void 0:e.devicePixelRatio)||1};return{viewContext:w(n),helperContext:w(n),boardContext:w({ctx:t,...n})}},t.createContext2D=w,t.createOffscreenContext2D=function(t){const{width:e,height:n}=t;return new OffscreenCanvas(e,n).getContext("2d").canvas.getContext("2d")},t.createUUID=i,t.deepClone=s,t.delay=function(t){return new Promise((e=>{setTimeout((()=>{e()}),t)}))},t.downloadImageFromCanvas=function(t,e){const{filename:n,type:i="image/jpeg"}=e,o=t.toDataURL(i),r=document.createElement("a");r.href=o,r.download=n;const a=document.createEvent("MouseEvents");a.initEvent("click",!0,!1),r.dispatchEvent(a)},t.equalPoint=P,t.equalTouchPoint=function(t,e){return!0===P(t,e)&&t.f===e.f},t.findElementFromList=function t(e,n){var i;let o=null;for(let r=0;r<n.length;r++){const a=n[r];if(a.uuid===e){o=a;break}if(!o&&"group"===a.type){const n=t(e,(null==(i=null==a?void 0:a.detail)?void 0:i.children)||[]);if((null==n?void 0:n.uuid)===e){o=n;break}}}return o},t.findElementsFromList=function(t,e){const n=[];return function e(i){var o;for(let r=0;r<i.length;r++){const a=i[r];t.includes(a.uuid)?n.push(a):"group"===a.type&&e((null==(o=null==a?void 0:a.detail)?void 0:o.children)||[])}}(e),n},t.formatNumber=function(t,e){const n=(null==e?void 0:e.decimalPlaces)||2;return parseFloat(t.toFixed(n))},t.generateHTML=function(t){return t.reduce((function(t,e){return t+K("",e)}),"")},t.generateSVGPath=function(t){let e="";return t.forEach((t=>{e+=t.type+t.params.join(" ")})),e},t.getCenterFromTwoPoints=_,t.getElemenetsAssetIds=function(t){const e=[],n=t=>{t.forEach((t=>{"image"===t.type&&a(t.detail.src)?e.push(t.detail.src):"svg"===t.type&&a(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.getElementRotateVertexes=E,t.getElementVertexes=H,t.getGroupQueueFromList=function(t,e){const n=[];return function t(e,i){var o;let r=null;for(let a=0;a<i.length;a++){const s=i[a];if(s.uuid===e){r=s;break}if(!r&&"group"===s.type){n.push(s);const i=t(e,(null==(o=null==s?void 0:s.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:a,viewScaleInfo:s,viewSizeInfo:l,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,a=0,h=0;for(let t=0;t<=e;t++)o+=c[t].x,a+=c[t].y,h+=c[t].angle||0;const f=c[e];if(f&&"group"===f.type&&Array.isArray(null==(n=f.detail)?void 0:n.children))for(let n=0;n<f.detail.children.length;n++){const d=f.detail.children[n];if(!0!==(null==(i=null==d?void 0:d.operations)?void 0:i.invisible)){if(!d)break;if(D(t,{context2d:r,element:{x:o+d.x,y:a+d.y,w:d.w,h:d.h,angle:h+(d.angle||0)},viewScaleInfo:s,viewSizeInfo:l})){u.element=d,(e<c.length-1||"group"!==d.type)&&(u.groupQueueIndex=e);break}}}if(u.element)break}if(u.element)return u;for(let e=a.elements.length-1;e>=0;e--){const n=a.elements[e];if(!0!==(null==(o=null==n?void 0:n.operations)?void 0:o.invisible)&&D(t,{context2d:r,element:n,viewScaleInfo:s,viewSizeInfo:l})){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.is=m,t.isAssetId=a,t.isColorStr=e,t.isElementInView=function(t,e){const{viewSizeInfo:n,viewScaleInfo:i}=e,{width:o,height:r}=n,{angle:a}=t,{x:s,y:l,w:c,h:u}=L(t,{viewScaleInfo:i,viewSizeInfo:n}),h=A({x:s,y:l,w:c,h:u,angle:a}),f={x:0,y:0,w:o,h:r},d=Math.min(h[0].x,h[1].x,h[2].x,h[3].x),x=Math.min(h[0].y,h[1].y,h[2].y,h[3].y);return W(f,{x:d,y:x,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)-x})},t.isViewPointInElement=D,t.istype=c,t.limitAngle=O,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"}),a=new FileReader;a.readAsDataURL(r),a.onload=function(t){var n;const i=null==(n=null==t?void 0:t.target)?void 0:n.result;e(i)},a.onerror=function(t){o(t)}}))}(t,e);return await h(n)},t.loadImage=h,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 h(e)},t.parseAngleToRadian=M,t.parseHTML=function(t){const e=[],n=[];let i,o=-1;return t.replace(X,((r,a)=>{const s="/"!==r.charAt(1),l=r.startsWith("\x3c!--"),c=a+r.length,u=t.charAt(c);let h;if(l){const t=J(r);return o<0?(e.push(t),r):(h=n[o],h.children.push(t),r)}if(s){if(o++,i=J(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((!s||!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);Y.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(U,((t,n,i)=>{const o=i.match(Q),r={type:n,params:o?o.map(Number):[]};return e.push(r),t})),e},t.rotateElement=function(t,e,n){const i=I(e),o=M(e.angle||0);i&&(o>0||o<0)&&(t.translate(i.x,i.y),t.rotate(o),t.translate(-i.x,-i.y)),n(t),i&&(o>0||o<0)&&(t.translate(i.x,i.y),t.rotate(-o),t.translate(-i.x,-i.y))},t.rotateElementVertexes=A,t.rotatePoint=k,t.rotatePointInGroup=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:a,angle:s=0}=t,l=k(I({x:e,y:o,w:r,h:a,angle:s}),{x:n,y:i},M(s));n=l.x,i=l.y})),{x:n,y:i}}return t},t.rotateVertexes=C,t.sortDataAsserts=function(t,e){const n=t.assets||{};let i=t;!0===(null==e?void 0:e.clone)&&(i=s(t));const o=t=>{t.forEach((t=>{if("image"===t.type&&t.detail.src){const e=t.detail.src,i=r(e);n[i]||(n[i]={type:"image",value:e}),t.detail.src=i}else if("svg"===t.type){const e=t.detail.svg,i=r(e);n[i]||(n[i]={type:"svg",value:e}),t.detail.svg=i}else if("html"===t.type){const e=t.detail.html,i=r(e);n[i]||(n[i]={type:"svg",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.updateElementInList=function t(e,n,i){var o;for(let r=0;r<i.length;r++){const a=i[r];if(a.uuid===e){z(a,n);break}"group"===a.type&&t(e,n,(null==(o=null==a?void 0:a.detail)?void 0:o.children)||[])}return i},t.vaildPoint=R,t.vaildTouchPoint=function(t){return!0===R(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,a=e/i.scale,s=n.x,l=n.y;return{moveX:s-s*a+(o*a-o),moveY:l-l*a+(r*a-r)}},t.viewScroll=function(t){const{moveX:e=0,moveY:n=0,viewScaleInfo:i,viewSizeInfo:o}=t,{scale:r}=i,{width:a,height:s,contextWidth:l,contextHeight:c}=o;let u=i.offsetLeft,h=i.offsetRight,f=i.offsetTop,d=i.offsetBottom;return u+=e,f+=n,h=a-(l*r+u),d=s-(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(){function t(){return(65536*(1+Math.random())|0).toString(16).substring(1)}return`${t()}${t()}-${t()}-${t()}-${t()}-${t()}${t()}${t()}`}function o(t){let e=0;for(let n=0;n<t.length;n++)e+=t.charCodeAt(n)*t.charCodeAt(n)*n*n;return e.toString(16).substring(0,4)}function r(t){const e=t.length,n=Math.floor(e/2),i=t.substring(0,4).padEnd(4,"0"),r=t.substring(0,4).padEnd(4,"0");return`@assets/${o(e.toString(16).padEnd(4,i))}${o(t.substring(n-4,n).padEnd(4,i)).padEnd(4,"f")}-${o(t.substring(n-8,n-4).padEnd(4,i)).padEnd(4,"f")}-${o(t.substring(n-12,n-8).padEnd(4,i)).padEnd(4,"f")}-${o(t.substring(n-16,n-12).padEnd(4,r)).padEnd(4,"f")}-${o(t.substring(n,n+4).padEnd(4,r)).padEnd(4,"f")}${o(t.substring(n+4,n+8).padEnd(4,r)).padEnd(4,"f")}${o(r.padEnd(4,i).padEnd(4,r))}`}function a(t){return/^@assets\/[0-9a-z]{8,8}\-[0-9a-z]{4,4}\-[0-9a-z]{4,4}\-[0-9a-z]{4,4}\-[0-9a-z]{12,12}$/.test(`${t}`)}function l(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 s(t){return(Object.prototype.toString.call(t)||"").replace(/(\[object|\])/gi,"").trim()}const c={type(t,e){const n=s(t);return!0===e?n.toLocaleLowerCase():n},array:t=>"Array"===s(t),json:t=>"Object"===s(t),function:t=>"Function"===s(t),asyncFunction:t=>"AsyncFunction"===s(t),string:t=>"String"===s(t),number:t=>"Number"===s(t),undefined:t=>"Undefined"===s(t),null:t=>"Null"===s(t),promise:t=>"Promise"===s(t)};const{Image:u}=window;function h(t){return new Promise(((e,n)=>{const i=new u;i.crossOrigin="anonymous",i.onload=function(){e(i)},i.onabort=n,i.onerror=n,i.src=t}))}function d(t){return"number"==typeof t&&(t>0||t<=0)}function f(t){return"number"==typeof t&&t>=0}function g(t){return"string"==typeof t&&/^(http:\/\/|https:\/\/|\.\/|\/)/.test(`${t}`)}function x(t){return"string"==typeof t&&/^(data:image\/)/.test(`${t}`)}const p={x:function(t){return d(t)},y:function(t){return d(t)},w:f,h:function(t){return"number"==typeof t&&t>=0},angle:function(t){return"number"==typeof t&&t>=-360&&t<=360},number:d,numberStr:function(t){return/^(-?\d+(?:\.\d+)?)$/.test(`${t}`)},borderWidth:function(t){return f(t)},borderRadius:function(t){return d(t)&&t>=0},color:function(t){return e(t)},imageSrc:function(t){return x(t)||g(t)},imageURL:g,imageBase64:x,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 d(t)&&t>0},lineHeight:function(t){return d(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 d(t)&&t>0}};function y(t={}){const{borderColor:e,borderRadius:n,borderWidth:i}=t;return!(t.hasOwnProperty("borderColor")&&!p.color(e))&&(!(t.hasOwnProperty("borderRadius")&&!p.number(n))&&!(t.hasOwnProperty("borderWidth")&&!p.number(i)))}const m={attrs:function(t){const{x:e,y:n,w:i,h:o,angle:r}=t;return!!(p.x(e)&&p.y(n)&&p.w(i)&&p.h(o)&&p.angle(r))&&(r>=-360&&r<=360)},textDesc:function(t){const{text:e,color:n,fontSize:i,lineHeight:o,fontFamily:r,textAlign:a,fontWeight:l,background:s,strokeWidth:c,strokeColor:u}=t;return!!p.text(e)&&(!!p.color(n)&&(!!p.fontSize(i)&&(!(t.hasOwnProperty("background")&&!p.color(s))&&(!(t.hasOwnProperty("fontWeight")&&!p.fontWeight(l))&&(!(t.hasOwnProperty("lineHeight")&&!p.lineHeight(o))&&(!(t.hasOwnProperty("fontFamily")&&!p.fontFamily(r))&&(!(t.hasOwnProperty("textAlign")&&!p.textAlign(a))&&(!(t.hasOwnProperty("strokeWidth")&&!p.strokeWidth(c))&&(!(t.hasOwnProperty("strokeColor")&&!p.color(u))&&!!y(t))))))))))},rectDesc:function(t){const{background:e}=t;return!(t.hasOwnProperty("background")&&!p.color(e))&&!!y(t)},circleDesc:function(t){const{background:e,borderColor:n,borderWidth:i}=t;return!(t.hasOwnProperty("background")&&!p.color(e))&&(!(t.hasOwnProperty("borderColor")&&!p.color(n))&&!(t.hasOwnProperty("borderWidth")&&!p.number(i)))},imageDesc:function(t){const{src:e}=t;return!!p.imageSrc(e)},svgDesc:function(t){const{svg:e}=t;return!!p.svg(e)},htmlDesc:function(t){const{html:e}=t;return!!p.html(e)}};class v{constructor(t,e){this._devicePixelRatio=1;const{devicePixelRatio:n=1}=e;this._ctx=t,this._devicePixelRatio=n}$undoPixelRatio(t){return t/this._devicePixelRatio}$doPixelRatio(t){return this._devicePixelRatio*t}$getContext(){return this._ctx}$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._ctx.font=`${e.join(" ")}`}$resize(t){const{width:e,height:n,devicePixelRatio:i}=t,{canvas:o}=this._ctx;o.width=e*i,o.height=n*i,this._devicePixelRatio=i}get canvas(){return this._ctx.canvas}get fillStyle(){return this._ctx.fillStyle}set fillStyle(t){this._ctx.fillStyle=t}get strokeStyle(){return this._ctx.strokeStyle}set strokeStyle(t){this._ctx.strokeStyle=t}get lineWidth(){return this.$undoPixelRatio(this._ctx.lineWidth)}set lineWidth(t){this._ctx.lineWidth=this.$doPixelRatio(t)}get textAlign(){return this._ctx.textAlign}set textAlign(t){this._ctx.textAlign=t}get textBaseline(){return this._ctx.textBaseline}set textBaseline(t){this._ctx.textBaseline=t}get globalAlpha(){return this._ctx.globalAlpha}set globalAlpha(t){this._ctx.globalAlpha=t}get shadowColor(){return this._ctx.shadowColor}set shadowColor(t){this._ctx.shadowColor=t}get shadowOffsetX(){return this.$undoPixelRatio(this._ctx.shadowOffsetX)}set shadowOffsetX(t){this._ctx.shadowOffsetX=this.$doPixelRatio(t)}get shadowOffsetY(){return this.$undoPixelRatio(this._ctx.shadowOffsetY)}set shadowOffsetY(t){this._ctx.shadowOffsetY=this.$doPixelRatio(t)}get shadowBlur(){return this.$undoPixelRatio(this._ctx.shadowBlur)}set shadowBlur(t){this._ctx.shadowBlur=this.$doPixelRatio(t)}get lineCap(){return this._ctx.lineCap}set lineCap(t){this._ctx.lineCap=t}get globalCompositeOperation(){return this._ctx.globalCompositeOperation}set globalCompositeOperation(t){this._ctx.globalCompositeOperation=t}fill(...t){return this._ctx.fill(...t)}arc(t,e,n,i,o,r){return this._ctx.arc(this.$doPixelRatio(t),this.$doPixelRatio(e),this.$doPixelRatio(n),i,o,r)}rect(t,e,n,i){return this._ctx.rect(this.$doPixelRatio(t),this.$doPixelRatio(e),this.$doPixelRatio(n),this.$doPixelRatio(i))}fillRect(t,e,n,i){return this._ctx.fillRect(this.$doPixelRatio(t),this.$doPixelRatio(e),this.$doPixelRatio(n),this.$doPixelRatio(i))}clearRect(t,e,n,i){return this._ctx.clearRect(this.$doPixelRatio(t),this.$doPixelRatio(e),this.$doPixelRatio(n),this.$doPixelRatio(i))}beginPath(){return this._ctx.beginPath()}closePath(){return this._ctx.closePath()}lineTo(t,e){return this._ctx.lineTo(this.$doPixelRatio(t),this.$doPixelRatio(e))}moveTo(t,e){return this._ctx.moveTo(this.$doPixelRatio(t),this.$doPixelRatio(e))}arcTo(t,e,n,i,o){return this._ctx.arcTo(this.$doPixelRatio(t),this.$doPixelRatio(e),this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(o))}getLineDash(){return this._ctx.getLineDash()}setLineDash(t){const e=t.map((t=>this.$doPixelRatio(t)));return this._ctx.setLineDash(e)}stroke(t){return t?this._ctx.stroke(t):this._ctx.stroke()}translate(t,e){return this._ctx.translate(this.$doPixelRatio(t),this.$doPixelRatio(e))}rotate(t){return this._ctx.rotate(t)}drawImage(...t){const e=t[0],n=t[1],i=t[2],o=t[3],r=t[4],a=t[t.length-4],l=t[t.length-3],s=t[t.length-2],c=t[t.length-1];return 9===t.length?this._ctx.drawImage(e,this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(o),this.$doPixelRatio(r),this.$doPixelRatio(a),this.$doPixelRatio(l),this.$doPixelRatio(s),this.$doPixelRatio(c)):this._ctx.drawImage(e,this.$doPixelRatio(a),this.$doPixelRatio(l),this.$doPixelRatio(s),this.$doPixelRatio(c))}createPattern(t,e){return this._ctx.createPattern(t,e)}measureText(t){return this._ctx.measureText(t)}fillText(t,e,n,i){return void 0!==i?this._ctx.fillText(t,this.$doPixelRatio(e),this.$doPixelRatio(n),this.$doPixelRatio(i)):this._ctx.fillText(t,this.$doPixelRatio(e),this.$doPixelRatio(n))}strokeText(t,e,n,i){return void 0!==i?this._ctx.strokeText(t,this.$doPixelRatio(e),this.$doPixelRatio(n),this.$doPixelRatio(i)):this._ctx.strokeText(t,this.$doPixelRatio(e),this.$doPixelRatio(n))}save(){this._ctx.save()}restore(){this._ctx.restore()}scale(t,e){this._ctx.scale(t,e)}circle(t,e,n,i,o,r,a,l){this._ctx.ellipse(this.$doPixelRatio(t),this.$doPixelRatio(e),this.$doPixelRatio(n),this.$doPixelRatio(i),o,r,a,l)}isPointInPath(t,e){return this._ctx.isPointInPath(this.$doPixelRatio(t),this.$doPixelRatio(e))}clip(...t){return this._ctx.clip(...t)}setTransform(t,e,n,i,o,r){return this._ctx.setTransform(t,e,n,i,o,r)}getTransform(){return this._ctx.getTransform()}createLinearGradient(t,e,n,i){return this._ctx.createLinearGradient(this.$doPixelRatio(t),this.$doPixelRatio(e),this.$doPixelRatio(n),this.$doPixelRatio(i))}createRadialGradient(t,e,n,i,o,r){return this._ctx.createRadialGradient(this.$doPixelRatio(t),this.$doPixelRatio(e),this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(o),this.$doPixelRatio(r))}createConicGradient(t,e,n){return this._ctx.createConicGradient(t,this.$doPixelRatio(e),this.$doPixelRatio(n))}}function b(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 v(r,t)}function w(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 P(t,e){return t.x===e.x&&t.y===e.y&&t.t===e.t}function $(t){return t>=0||t<0}function R(t){return $(t.x)&&$(t.y)&&t.t>0}function M(t,e){return{x:t.x+(e.x-t.x)/2,y:t.y+(e.y-t.y)/2}}function _(t){return t/180*Math.PI}function I(t,e,n,i){const o=_(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 S(t){return{x:t.x+t.w/2,y:t.y+t.h/2}}function E(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 S({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 k(t,e,n){const i=function(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}(t,e);let o=i+n;o>2*Math.PI?o-=2*Math.PI:o<0-2*Math.PI&&(o+=2*Math.PI),o<0&&(o+=2*Math.PI);const r=w(t,e);let a=0,l=0;return 0===o?(a=0,l=0-r):o>0&&o<Math.PI/2?(a=Math.sin(o)*r,l=0-Math.cos(o)*r):o===Math.PI/2?(a=r,l=0):o>Math.PI/2&&o<Math.PI?(a=Math.sin(Math.PI-o)*r,l=Math.cos(Math.PI-o)*r):o===Math.PI?(a=0,l=r):o>Math.PI&&o<1.5*Math.PI?(a=0-Math.sin(o-Math.PI)*r,l=Math.cos(o-Math.PI)*r):o===1.5*Math.PI?(a=0-r,l=0):o>1.5*Math.PI&&o<2*Math.PI?(a=0-Math.sin(2*Math.PI-o)*r,l=0-Math.cos(2*Math.PI-o)*r):o===2*Math.PI&&(a=0,l=0-r),a+=t.x,l+=t.y,{x:a,y:l}}function A(t,e,n){const{x:i,y:o,w:r,h:a}=t;let l={x:i,y:o},s={x:i+r,y:o},c={x:i+r,y:o+a},u={x:i,y:o+a};if(n&&(n>0||n<0)){const t=_(T(n));l=k(e,l,t),s=k(e,s,t),c=k(e,c,t),u=k(e,u,t)}return[l,s,c,u]}function C(t){const{angle:e=0}=t;return A(t,S(t),e)}function O(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 T(t){if(!(t>0||t<0)||0===t)return 0;let e=t%360;return e<0&&(e+=360),e}function L(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=C(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),a=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(a-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 z(t,e){var n;const i=Object.keys(e);for(let o=0;o<i.length;o++){const r=i[o];["x","y","w","h","angle","name"].includes(r)?t[r]=e[r]:["detail","operations"].includes(r)&&(c.json(e[r])?((null==t?void 0:t.hasOwnProperty(r))||(t[r]={}),c.json(t[r])&&(t[r]={...t[r],...e[r]})):c.array(e[r])&&((null==t?void 0:t.hasOwnProperty(r))||(t[r]=[]),c.array(t[r])&&(null==(n=null==e?void 0:e[r])||n.forEach(((e,n)=>{t[r][n]=e})),t[r]=[...t[r],...e[r]])))}return t}function W(t,e){const n=t.x,i=t.y,o=t.x+t.w,r=t.y+t.h,a=e.x,l=e.y,s=e.x+e.w,c=e.y+e.h;return n<=s&&o>=a&&i<=c&&r>=l}function V(t,e){const{viewScaleInfo:n}=e,{x:i,y:o,w:r,h:a,angle:l}=t,{scale:s,offsetTop:c,offsetLeft:u}=n;return{x:i*s+u,y:o*s+c,w:r*s,h:a*s,angle:l}}function D(t,e){const{viewScaleInfo:n}=e,{x:i,y:o}=t,{scale:r,offsetTop:a,offsetLeft:l}=n;return{x:i*r+l,y:o*r+a}}function F(t,e){const{context2d:n,element:i,viewScaleInfo:o,viewSizeInfo:r}=e,{angle:a=0}=i,{x:l,y:s,w:c,h:u}=V(i,{viewScaleInfo:o,viewSizeInfo:r}),h=C({x:l,y:s,w:c,h:u,angle:a});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 H(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 j(t){const{x:e,y:n,w:i,h:o,angle:r=0}=t;return 0===r?H(t):A(t,S({x:e,y:n,w:i,h:o,angle:r}),r)}function B(t){const e=[];let n=0,i=0;const o=[],r=[...t];for(let t=0;t<r.length;t++){const{x:a,y:l,w:s,h:c,angle:u=0}=r[t];let h;if(n+=a,i+=l,0===t){const t={x:n,y:i,w:s,h:c,angle:u};h=j({x:a,y:l,w:s,h:c,angle:u}),o.push({center:S(t),angle:u,radian:_(u)})}else{h=H({x:n,y:i,w:s,h:c,angle:u});for(let t=0;t<o.length;t++){const{center:e,radian:n}=o[t];h=O(e,h,n)}const t=E(h);if(u>0||u<0){h=O(t,h,_(u))}o.push({center:t,angle:u,radian:_(u)})}e.push(h)}return e}function U(t,e){const{groupQueue:n}=e;if(!(n.length>0))return[j(t)];return B([...n,t])}function G(t,e){return U(t,e).pop()||null}function q(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}}const Q=/([astvzqmhlc])([^astvzqmhlc]*)/gi,N=/(-?\d+(?:\.\d+)?)/gi;const X=/\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?(".*?"|'.*?')/g,Y=/<[a-zA-Z0-9\-\!\/](?:"[^"]*"|'[^']*'|[^'">])*>/g,Z=/^\s*$/,J={};function K(t){const e={type:"element",name:"",isVoid:!1,attributes:{},children:[]},n=t.match(/<\/?([^\s]+?)[/\s>]/);if(n&&(e.name=n[1],(J[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(X);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 tt(t,e){switch(e.type){case"text":return t+e.textContent;case"element":return t+="<"+e.name+(e.attributes?function(t){const e=[];for(let n in t)e.push(n+'="'+t[n]+'"');return e.length?" "+e.join(" "):""}(e.attributes):"")+(e.isVoid?"/>":">"),e.isVoid?t:t+e.children.reduce(tt,"")+"</"+e.name+">";case"comment":return t+="\x3c!--"+e.comment+"--\x3e"}}function et(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])}function nt(){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,lineHeight:20,fontFamily:"sans-serif",fontWeight:400}}const it={boxSizing:"border-box",borderWidth:0,borderColor:"#000000",shadowColor:"#000000",borderRadius:0,borderDash:[],shadowOffsetX:0,shadowOffsetY:0,shadowBlur:0,opacity:1,color:"#000000",textAlign:"left",verticalAlign:"top",fontSize:16,lineHeight:20,fontFamily:"sans-serif",fontWeight:400};return t.Context2D=v,t.EventEmitter=class{constructor(){this._listeners=new Map}on(t,e){if(this._listeners.has(t)){const n=this._listeners.get(t)||[];null==n||n.push(e),this._listeners.set(t,n)}else this._listeners.set(t,[e])}off(t,e){if(this._listeners.has(t)){const n=this._listeners.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}this._listeners.set(t,n||[])}}trigger(t,e){const n=this._listeners.get(t);return!!Array.isArray(n)&&(n.forEach((t=>{t(e)})),!0)}has(t){if(this._listeners.has(t)){const e=this._listeners.get(t);if(Array.isArray(e)&&e.length>0)return!0}return!1}},t.Store=class{constructor(t){this._backUpDefaultStorage=l(t.defaultStorage),this._temp=this._createTempStorage()}set(t,e){this._temp[t]=e}get(t){return this._temp[t]}getSnapshot(){return l(this._temp)}clear(){this._temp=this._createTempStorage()}_createTempStorage(){return l(this._backUpDefaultStorage)}},t.calcDistance=w,t.calcElementCenter=S,t.calcElementCenterFromVertexes=E,t.calcElementQueueVertexesQueueInGroup=B,t.calcElementSizeController=function(t,e){const{groupQueue:n,controllerSize:o,viewScaleInfo:r}=e,a=(o&&o>0?o:8)/r.scale,{x:l,y:s,w:c,h:u,angle:h=0}=t,d=[{uuid:i(),x:l,y:s,w:c,h:u,angle:h,type:"group",detail:{children:[]}},...n];let f=0;d.forEach((({angle:t=0})=>{f+=t}));const g=G(t,{groupQueue:n}),x=M(g[0],g[1]),p=M(g[1],g[2]),y=M(g[2],g[3]),m=M(g[3],g[0]),v=g[0],b=g[1],w=g[2],P=g[3],$=q(v,{size:a,angle:f}),R=q(b,{size:a,angle:f}),_=q(P,{size:a,angle:f}),I=q(w,{size:a,angle:f}),S=j($),E=j(R),k=j(_),A=j(I),C=[S[1],E[0],E[3],S[2]],O=[E[3],E[2],A[1],A[0]],T=[k[1],A[0],A[3],k[2]];return{elementWrapper:g,left:{type:"left",vertexes:[S[3],S[2],k[1],k[0]],center:m},right:{type:"right",vertexes:O,center:p},top:{type:"top",vertexes:C,center:x},bottom:{type:"bottom",vertexes:T,center:y},topLeft:{type:"top-left",vertexes:S,center:v},topRight:{type:"top-right",vertexes:E,center:b},bottomLeft:{type:"bottom-left",vertexes:k,center:P},bottomRight:{type:"bottom-right",vertexes:A,center:w}}},t.calcElementVertexesInGroup=G,t.calcElementVertexesQueueInGroup=U,t.calcElementsContextSize=L,t.calcElementsViewInfo=function(t,e,n){const i=L(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.calcSpeed=function(t,e){return w(t,e)/Math.abs(e.t-t.t)},t.calcViewBoxSize=function(t,e){const{viewScaleInfo:n}=e,{scale:i}=n;let{borderRadius:o,boxSizing:r=it.boxSizing,borderWidth:a}=t.detail;"number"!=typeof a&&(o=0);let{x:l,y:s,w:c,h:u}=t,h=[0,0,0,0];if("number"==typeof o){const t=o*i;h=[t,t,t,t]}else Array.isArray(o)&&4===(null==o?void 0:o.length)&&(h=[o[0]*i,o[1]*i,o[2]*i,o[3]*i]);let d=0;return"number"==typeof a&&(d=(a||1)*i),"border-box"===r?(l=t.x+d/2,s=t.y+d/2,c=t.w-d,u=t.h-d):"content-box"===r?(l=t.x-d/2,s=t.y-d/2,c=t.w+d,u=t.h+d):(l=t.x,s=t.y,c=t.w,u=t.h),{x:l,y:s,w:c,h:u,radiusList:h}},t.calcViewElementSize=V,t.calcViewPointSize=D,t.calcViewVertexes=function(t,e){return[D(t[0],e),D(t[1],e),D(t[2],e),D(t[3],e)]},t.check=m,t.checkRectIntersect=W,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("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,a=t*n,l=o*n;let s=document.createElement("canvas");s.width=a,s.height=l;s.getContext("2d").drawImage(r,0,0,a,l);const c=s.toDataURL(i);s=null,e(c)})),r.addEventListener("error",(t=>{o(t)})),r.src=t}))},t.createAssetId=r,t.createBoardContexts=function(t,e){const n={width:t.canvas.width,height:t.canvas.height,devicePixelRatio:(null==e?void 0:e.devicePixelRatio)||1},i=b(n),o=b(n);return{underContext:b(n),viewContext:i,helperContext:o,boardContext:b({ctx:t,...n})}},t.createContext2D=b,t.createOffscreenContext2D=function(t){const{width:e,height:n}=t;return new OffscreenCanvas(e,n).getContext("2d").canvas.getContext("2d")},t.createUUID=i,t.deepClone=l,t.delay=function(t){return new Promise((e=>{setTimeout((()=>{e()}),t)}))},t.downloadImageFromCanvas=function(t,e){const{filename:n,type:i="image/jpeg"}=e,o=t.toDataURL(i),r=document.createElement("a");r.href=o,r.download=n;const a=document.createEvent("MouseEvents");a.initEvent("click",!0,!1),r.dispatchEvent(a)},t.equalPoint=P,t.equalTouchPoint=function(t,e){return!0===P(t,e)&&t.f===e.f},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||a(i)||(e=r(i),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 a=n[r];if(a.uuid===e){o=a;break}if(!o&&"group"===a.type){const n=t(e,(null==(i=null==a?void 0:a.detail)?void 0:i.children)||[]);if((null==n?void 0:n.uuid)===e){o=n;break}}}return o},t.findElementsFromList=function(t,e){const n=[];return function e(i){var o;for(let r=0;r<i.length;r++){const a=i[r];t.includes(a.uuid)?n.push(a):"group"===a.type&&e((null==(o=null==a?void 0:a.detail)?void 0:o.children)||[])}}(e),n},t.formatNumber=function(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))},t.generateHTML=function(t){return t.reduce((function(t,e){return t+tt("",e)}),"")},t.generateSVGPath=function(t){let e="";return t.forEach((t=>{e+=t.type+t.params.join(" ")})),e},t.getCenterFromTwoPoints=M,t.getDefaultElementDetailConfig=nt,t.getElemenetsAssetIds=function(t){const e=[],n=t=>{t.forEach((t=>{"image"===t.type&&a(t.detail.src)?e.push(t.detail.src):"svg"===t.type&&a(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.getElementRotateVertexes=A,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=H,t.getGroupQueueFromList=function(t,e){const n=[];return function t(e,i){var o;let r=null;for(let a=0;a<i.length;a++){const l=i[a];if(l.uuid===e){r=l;break}if(!r&&"group"===l.type){n.push(l);const i=t(e,(null==(o=null==l?void 0:l.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:a,viewScaleInfo:l,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,a=0,h=0;for(let t=0;t<=e;t++)o+=c[t].x,a+=c[t].y,h+=c[t].angle||0;const d=c[e];if(d&&"group"===d.type&&Array.isArray(null==(n=d.detail)?void 0:n.children))for(let n=0;n<d.detail.children.length;n++){const f=d.detail.children[n];if(!0!==(null==(i=null==f?void 0:f.operations)?void 0:i.invisible)){if(!f)break;if(F(t,{context2d:r,element:{x:o+f.x,y:a+f.y,w:f.w,h:f.h,angle:h+(f.angle||0)},viewScaleInfo:l,viewSizeInfo:s})){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=a.elements.length-1;e>=0;e--){const n=a.elements[e];if(!0!==(null==(o=null==n?void 0:n.operations)?void 0:o.invisible)&&F(t,{context2d:r,element:n,viewScaleInfo:l,viewSizeInfo:s})){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.is=p,t.isAssetId=a,t.isColorStr=e,t.isElementInView=function(t,e){const{viewSizeInfo:n,viewScaleInfo:i}=e,{width:o,height:r}=n,{angle:a}=t,{x:l,y:s,w:c,h:u}=V(t,{viewScaleInfo:i,viewSizeInfo:n}),h=C({x:l,y:s,w:c,h:u,angle:a}),d={x:0,y:0,w:o,h:r},f=Math.min(h[0].x,h[1].x,h[2].x,h[3].x),g=Math.min(h[0].y,h[1].y,h[2].y,h[3].y);return W(d,{x:f,y:g,w:Math.max(h[0].x,h[1].x,h[2].x,h[3].x)-f,h:Math.max(h[0].y,h[1].y,h[2].y,h[3].y)-g})},t.isResourceElement=function(t){return["image","svg","html"].includes(null==t?void 0:t.type)},t.isViewPointInElement=F,t.istype=c,t.limitAngle=T,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"}),a=new FileReader;a.readAsDataURL(r),a.onload=function(t){var n;const i=null==(n=null==t?void 0:t.target)?void 0:n.result;e(i)},a.onerror=function(t){o(t)}}))}(t,e);return await h(n)},t.loadImage=h,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 h(e)},t.matrixToAngle=function(t){const e=et(t);if("number"==typeof e){return 180*e/Math.PI}return e},t.matrixToRadian=et,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.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.parseAngleToRadian=_,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(Y,((r,a)=>{const l="/"!==r.charAt(1),s=r.startsWith("\x3c!--"),c=a+r.length,u=t.charAt(c);let h;if(s){const t=K(r);return o<0?(e.push(t),r):(h=n[o],h.children.push(t),r)}if(l){if(o++,i=K(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((!l||!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);Z.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(Q,((t,n,i)=>{const o=i.match(N),r={type:n,params:o?o.map(Number):[]};return e.push(r),t})),e},t.pickFile=function(t){const{success:e,error:n}=t;let i=document.createElement("input");i.type="file",i.addEventListener("change",(function(){var t;const n=null==(t=i.files)?void 0:t[0];e({file:n}),i=null})),i.addEventListener("error",(function(t){"function"==typeof n&&n(t),i=null})),i.click()},t.rotateByCenter=I,t.rotateElement=function(t,e,n){const i=S(e);I(t,e.angle||0,i,(()=>{n(t)}))},t.rotateElementVertexes=C,t.rotatePoint=k,t.rotatePointInGroup=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:a,angle:l=0}=t,s=k(S({x:e,y:o,w:r,h:a,angle:l}),{x:n,y:i},_(l));n=s.x,i=s.y})),{x:n,y:i}}return t},t.rotateVertexes=O,t.sortDataAsserts=function(t,e){const n=t.assets||{};let i=t;!0===(null==e?void 0:e.clone)&&(i=l(t));const o=t=>{t.forEach((t=>{if("image"===t.type&&t.detail.src){const e=t.detail.src,i=r(e);n[i]||(n[i]={type:"image",value:e}),t.detail.src=i}else if("svg"===t.type){const e=t.detail.svg,i=r(e);n[i]||(n[i]={type:"svg",value:e}),t.detail.svg=i}else if("html"===t.type){const e=t.detail.html,i=r(e);n[i]||(n[i]={type:"svg",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.updateElementInList=function t(e,n,i){var o;let r=null;for(let a=0;a<i.length;a++){const l=i[a];if(l.uuid===e){z(l,n),r=l;break}"group"===l.type&&(r=t(e,n,(null==(o=null==l?void 0:l.detail)?void 0:o.children)||[]))}return r},t.vaildPoint=R,t.vaildTouchPoint=function(t){return!0===R(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,a=e/i.scale,l=n.x,s=n.y;return{moveX:l-l*a+(o*a-o),moveY:s-s*a+(r*a-r)}},t.viewScroll=function(t){const{moveX:e=0,moveY:n=0,viewScaleInfo:i,viewSizeInfo:o}=t,{scale:r}=i,{width:a,height:l,contextWidth:s,contextHeight:c}=o;let u=i.offsetLeft,h=i.offsetRight,d=i.offsetTop,f=i.offsetBottom;return u+=e,d+=n,h=a-(s*r+u),f=l-(c*r+d),{scale:r,offsetTop:d,offsetLeft:u,offsetRight:h,offsetBottom:f}},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.0-alpha.3",
3
+ "version": "0.4.0-alpha.4",
4
4
  "description": "",
5
5
  "main": "dist/esm/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -27,4 +27,4 @@
27
27
  "access": "public",
28
28
  "provenance": true
29
29
  }
30
- }
30
+ }