import{I as Ot,K as px,E as Ca}from"./index.c787b0a9.js";function Wa(e,t){var i=t||new Path2D,a=e.calculative.borderRadius||0,r=a,n=e.calculative.worldRect,o=n.x,s=n.y,h=n.width,l=n.height,c=n.ex,f=n.ey;a<1&&(a=h*a,r=l*r);var v=at.x-i&&e.xt.y-i&&e.y0&&a>0?r=180-r:i<0&&a>0?r+=180:i<0&&a<0&&(r=360-r),r}function ws(e,t){var i=e.x-t.x,a=e.y-t.y;return Math.sqrt(i*i+a*a)}function Rx(e,t){var i=Pe.None;if(!t)return i;var a=e.x-t.x,r=e.y-t.y;return Math.abs(a)>Math.abs(r)?a>0?i=Pe.Right:i=Pe.Left:r>0?i=Pe.Bottom:i=Pe.Up,i}function wn(e,t,i){!e||(e.x+=t,e.y+=i,e.next&&(e.next.x+=t,e.next.y+=i),e.prev&&(e.prev.x+=t,e.prev.y+=i))}function id(e,t){return e.anchorId===t.anchorId&&e.connectTo===t.connectTo}function Do(e,t,i){var a=Math.sqrt((e.x-t.x)*(e.x-t.x)+(e.y-t.y)*(e.y-t.y))/i.data.scale;t.rotate===0?e.x>>0,1)},emit:function(t,i){(e.get(t)||[]).slice().map(function(a){a(i)}),(e.get("*")||[]).slice().map(function(a){a(t,i)})}}}var $r;(function(e){e[e.None=-1]="None",e[e.Document=0]="Document",e[e.Canvas=1]="Canvas"})($r||($r={}));var Xx={fontFamily:'"Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial',fontSize:12,lineHeight:1.5,textAlign:"center",textBaseline:"middle",color:"#222222",activeColor:"#278df8",hoverColor:"rgba(39,141,248,0.50)",anchorColor:"#278DF8",hoverAnchorColor:"#FF4101",anchorRadius:4,anchorBackground:"#fff",dockColor:"rgba(39,141,248,0.50)",dockPenColor:"#1890FF",dragColor:"#1890ff",rotateCursor:"rotate.cur",rightCursor:"right.cur",downCursor:"down.cur",hoverCursor:"pointer",minScale:.1,maxScale:10,keydown:$r.Document,gridSize:20,gridColor:"#e2e2e2",ruleColor:"#888888",drawingLineName:"curve",interval:30,animateInterval:30,autoPolyline:!0,autoAnchor:!0,autoAlignGrid:!1,animateColor:"#30EEDC",ruleLineColor:"#FF4101",shadowOffsetX:0,shadowOffsetY:0,shadowBlur:64,shadowColor:"#00000014",globalAlpha:1,defaultAnchors:[{x:.5,y:0},{x:1,y:.5},{x:.5,y:1},{x:0,y:.5}],measureTextWidth:!0,moveConnectedLine:!0,mouseRightActive:!0,disableClipboard:!1,drawingLineLength:0,disableTouchPadScale:!1,cdn:"",polylineSpace:10,domShapes:[],containerShapes:["table"],textFlip:!0,textRotate:!0,unavailableKeys:[],diagramOptions:{},svgPathStroke:!0},Zx={dark:{color:"#bdc7db",background:"#1e2430",parentBackground:"#080b0f",ruleColor:"#222E47",ruleOptions:{background:"#121924",textColor:"#6E7B91"}},light:{color:"#222222",background:"#FFFFFF",parentBackground:"#F0F1F2",ruleColor:"#C8D0E1",ruleOptions:{background:"#F7F8FA",textColor:"#C8D0E1"}}},ss=globalThis&&globalThis.__assign||function(){return ss=Object.assign||function(e){for(var t,i=1,a=arguments.length;i=e.length&&(e=void 0),{value:e&&e[a++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},we;(function(e){e[e.Add=0]="Add",e[e.Update=1]="Update",e[e.Delete=2]="Delete",e[e.Replace=3]="Replace"})(we||(we={}));var Jx=function(){return{data:{x:0,y:0,scale:1,pens:[],origin:{x:0,y:0},center:{x:0,y:0},paths:{},theme:"light"},histories:[],pens:{},path2dMap:new WeakMap,animateMap:new WeakMap,active:[],animates:new Set,options:ss({},Xx),theme:ss({},Zx),emitter:Gx(),bindDatas:{},bind:{},pensNetwork:{},cacheDatas:[],messageEvents:{},templatePens:{},globalTriggers:{}}},e2=function(e){return e===void 0&&(e="default"),ke[e]||(ke[e]=Jx(),ke[e].id=e),ke[e]},t2=function(e,t){var i,a,r=e.data.template===t;if(r)try{for(var n=Qx(e.data.pens),o=n.next();!o.done;o=n.next()){var s=o.value;s.canvasLayer===Ne.CanvasTemplate&&(e.templatePens[s.id]=s)}}catch(h){i={error:h}}finally{try{o&&!o.done&&(a=n.return)&&a.call(n)}finally{if(i)throw i.error}}e.lastScale=e.data.scale,e.data={x:0,y:0,scale:1,pens:[],origin:{x:0,y:0},center:{x:0,y:0},paths:{},template:r?t:null},e.sameTemplate=r,e.pens={},e.histories=[],e.historyIndex=null,e.path2dMap=new WeakMap,e.animateMap=new WeakMap,e.bindDatas={},e.bind={},e.pensNetwork={},e.active=[],e.hover=void 0,e.lastHover=void 0,e.animates.clear()},rd=globalThis&&globalThis.__values||function(e){var t=typeof Symbol=="function"&&Symbol.iterator,i=t&&e[t],a=0;if(i)return i.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&a>=e.length&&(e=void 0),{value:e&&e[a++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},i2=globalThis&&globalThis.__read||function(e,t){var i=typeof Symbol=="function"&&e[Symbol.iterator];if(!i)return e;var a=i.call(e),r,n=[],o;try{for(;(t===void 0||t-- >0)&&!(r=a.next()).done;)n.push(r.value)}catch(s){o={error:s}}finally{try{r&&!r.done&&(i=a.return)&&i.call(a)}finally{if(o)throw o.error}}return n},r2=globalThis&&globalThis.__spreadArray||function(e,t,i){if(i||arguments.length===2)for(var a=0,r=t.length,n;a1?l:1;switch(e.whiteSpace){case"nowrap":if(e.ellipsis!==!1){var f=ad(t.split(""),e);f[0]&&(o.push(f[0]),f.length>1&&Gl(o))}else o.push(t);break;case"pre-line":o=t.split(/[\n]/g),e.ellipsis!==!1&&o.length>c&&(o=o.slice(0,c),Gl(o));break;case"break-all":default:var v=t.split(/[\n]/g),g=0;try{e:for(var y=rd(v),p=y.next();!p.done;p=y.next()){var m=p.value,b=e.whiteSpace==="break-all"?m.split(""):Xv(m),x=ad(b,e);if(x.length===0&&(x=[""]),e.ellipsis!=!1)try{for(var _=(r=void 0,rd(x)),k=_.next();!k.done;k=_.next()){var I=k.value;if(g++,g>c){Gl(o);break e}else o.push(I)}}catch(M){r={error:M}}finally{try{k&&!k.done&&(n=_.return)&&n.call(_)}finally{if(r)throw r.error}}else o.push.apply(o,r2([],i2(x),!1))}}catch(M){i={error:M}}finally{try{p&&!p.done&&(a=y.return)&&a.call(y)}finally{if(i)throw i.error}}break}var P=e.calculative.keepDecimal;return P!=null&&o.forEach(function(M,L){var U=Number(M);isNaN(U)||(o[L]=U.toFixed(P))}),e.calculative.textLines=o,o}function Xv(e){e===void 0&&(e="");for(var t=[],i="",a=0;a126?(i&&(t.push(i),i=""),t.push(e[a])):i+=e[a]}return i&&t.push(i),t}function ad(e,t){var i=t.calculative.canvas,a=i.offscreen.getContext("2d"),r=t.calculative,n=r.fontStyle,o=r.fontWeight,s=r.fontSize,h=r.fontFamily,l=r.lineHeight;a.save();for(var c=[],f=e[0]||"",v=1;vc&&(c=f)}a.restore();var x=t.length*s*l;e.textAlign==="left"||(e.textAlign==="right"?e.x=e.x-(c-e.width):e.x=e.x-(c-e.width)/2),e.textBaseline==="top"||(e.textBaseline==="bottom"?e.y=e.y-(x-e.height):e.y=e.y-(x-e.height)/2),e.height=x+2,e.width=c+2,e.calculative.canvas.updatePenRect(e),e.calculative.canvas.calcActiveRect()}function ce(e,t){if(t===void 0&&(t=!1),Array.isArray(e)){var i=[];return e.forEach(function(n){i.push(ce(n,t))}),i}else if(typeof e=="object"){if(e===null)return null;if(e.constructor===RegExp)return e;var a={};for(var r in e)if(!(["canvas","lastFrame"].includes(r)||e[r]instanceof HTMLImageElement||e[r]instanceof HTMLMediaElement)){{if(r==="calculative"&&!t)continue;if(r==="singleton"){t?a[r]={}:a[r]=e[r];continue}}a[r]=ce(e[r],t)}return a}return e}var oi={};function Zv(e,t,i){if(!!oi[t.fromArrow]){var a=lt(t),r=a.x,n=a.y,o={x:r,y:n};if(o.step=(t.fromArrowSize||10)*i.data.scale,a.next)o.rotate=gi(a.next,a)+90;else{var s=t.calculative.worldAnchors[1];if(!s)return;s.prev?o.rotate=gi(s.prev,a)+90:o.rotate=gi(s,a)+90}e.save(),e.beginPath(),e.setLineDash([]);var h=t.fromArrowColor||t.calculative.color;h&&(e.strokeStyle=h),oi[t.fromArrow](e,t,i,o),e.restore()}}function Qv(e,t,i){if(!(!oi[t.toArrow]||t.calculative.worldAnchors.length<2)){e.save();var a=We(t),r=a.x,n=a.y,o={x:r,y:n};if(o.step=(t.toArrowSize||10)*i.data.scale,a.prev)o.rotate=gi(a.prev,a)+90;else{var s=t.calculative.worldAnchors[t.calculative.worldAnchors.length-2];s.next?o.rotate=gi(s.next,a)+90:o.rotate=gi(s,a)+90}e.beginPath(),e.setLineDash([]);var h=t.toArrowColor||t.calculative.color;h&&(e.strokeStyle=h),oi[t.toArrow](e,t,i,o),e.restore()}}oi.triangleSolid=function(e,t,i,a){e.save(),e.translate(a.x,a.y),e.rotate(a.rotate*Math.PI/180),e.translate(-a.x,-a.y);var r=a.x-a.step;e.moveTo(r,a.y-a.step/4),e.lineTo(a.x,a.y),e.lineTo(r,a.y+a.step/4),e.closePath(),e.stroke(),e.fillStyle=e.strokeStyle,e.fill(),e.restore()};oi.triangle=function(e,t,i,a){e.save(),e.lineWidth<2&&(e.lineWidth=2),e.translate(a.x,a.y),e.rotate(a.rotate*Math.PI/180),e.translate(-a.x,-a.y);var r=a.x-a.step;e.moveTo(r,a.y-a.step/4),e.lineTo(a.x,a.y),e.lineTo(r,a.y+a.step/4),e.closePath(),e.stroke(),e.fillStyle=i.data.background||"#ffffff",e.fill(),e.restore()};oi.circleSolid=function(e,t,i,a){e.save(),e.translate(a.x,a.y),e.rotate(a.rotate*Math.PI/180),e.translate(-a.x,-a.y);var r=a.step/2;e.arc(a.x-r,a.y,r,0,2*Math.PI),e.stroke(),e.fillStyle=e.strokeStyle,e.fill(),e.restore()};oi.circle=function(e,t,i,a){e.save(),e.translate(a.x,a.y),e.rotate(a.rotate*Math.PI/180),e.translate(-a.x,-a.y);var r=a.step/2;e.arc(a.x-r,a.y,r,0,2*Math.PI),e.stroke(),e.fillStyle=i.data.background||"#ffffff",e.fill(),e.restore()};oi.diamondSolid=function(e,t,i,a){e.save(),e.translate(a.x,a.y),e.rotate(a.rotate*Math.PI/180),e.translate(-a.x,-a.y);var r=a.x-a.step,n=a.step/2;e.moveTo(r,a.y),e.lineTo(r+n,a.y-n/2),e.lineTo(a.x,a.y),e.lineTo(r+n,a.y+n/2),e.closePath(),e.stroke(),e.fillStyle=e.strokeStyle,e.fill(),e.restore()};oi.diamond=function(e,t,i,a){e.save(),e.translate(a.x,a.y),e.rotate(a.rotate*Math.PI/180),e.translate(-a.x,-a.y);var r=a.x-a.step,n=a.step/2;e.moveTo(r,a.y),e.lineTo(r+n,a.y-n/2),e.lineTo(a.x,a.y),e.lineTo(r+n,a.y+n/2),e.closePath(),e.stroke(),e.fillStyle=i.data.background||"#ffffff",e.fill(),e.restore()};oi.line=function(e,t,i,a){e.save(),e.translate(a.x,a.y),e.rotate(a.rotate*Math.PI/180),e.translate(-a.x,-a.y);var r=a.x-a.step;e.moveTo(r,a.y-a.step/3),e.lineTo(a.x,a.y),e.lineTo(r,a.y+a.step/3),e.stroke(),e.restore()};oi.lineUp=function(e,t,i,a){e.save(),e.translate(a.x,a.y),e.rotate(a.rotate*Math.PI/180),e.translate(-a.x,-a.y);var r=a.x-a.step;e.moveTo(r,a.y-a.step/3),e.lineTo(a.x,a.y),e.stroke(),e.restore()};oi.lineDown=function(e,t,i,a){e.save(),e.translate(a.x,a.y),e.rotate(a.rotate*Math.PI/180),e.translate(-a.x,-a.y);var r=a.x-a.step;e.moveTo(r,a.y+a.step/3),e.lineTo(a.x,a.y),e.stroke(),e.restore()};var o2=globalThis&&globalThis.__read||function(e,t){var i=typeof Symbol=="function"&&e[Symbol.iterator];if(!i)return e;var a=i.call(e),r,n=[],o;try{for(;(t===void 0||t-- >0)&&!(r=a.next()).done;)n.push(r.value)}catch(s){o={error:s}}finally{try{r&&!r.done&&(i=a.return)&&i.call(a)}finally{if(o)throw o.error}}return n};function Dc(e){var t=parseInt,i=Math.round,a=e.length,r={};if(a>9){var n=o2(e=e.split(","),4),o=n[0],s=n[1],h=n[2],l=n[3];if(a=e.length,a<3||a>4)return null;r.r=t(o[3]=="a"?o.slice(5):o.slice(4)),r.g=t(s),r.b=t(h),r.a=l?parseFloat(l):-1}else{if(a==8||a==6||a<4)return null;a<6&&(e="#"+e[1]+e[1]+e[2]+e[2]+e[3]+e[3]+(a>4?e[4]+e[4]:"")),e=t(e.slice(1),16),a==9||a==5?(r.r=e>>24&255,r.g=e>>16&255,r.b=e>>8&255,r.a=i((e&255)/.255)/1e3):(r.r=e>>16,r.g=e>>8&255,r.b=e&255,r.a=-1)}return r}function Ft(e,t,i,a){var r,n,o,s,h,l,c,f=Math.round,v=typeof i=="string";return typeof e!="number"||e<-1||e>1||typeof t!="string"||t[0]!="r"&&t[0]!="#"||i&&!v||(c=t.length>9,c=v?i.length>9?!0:i=="c"?!c:!1:c,h=Dc(t),s=e<0,l=i&&i!="c"?Dc(i):s?{r:0,g:0,b:0,a:-1}:{r:255,g:255,b:255,a:-1},e=s?e*-1:e,s=1-e,!h||!l)?null:(a?(r=f(s*h.r+e*l.r),n=f(s*h.g+e*l.g),o=f(s*h.b+e*l.b)):(r=f(Math.pow(s*Math.pow(h.r,2)+e*Math.pow(l.r,2),.5)),n=f(Math.pow(s*Math.pow(h.g,2)+e*Math.pow(l.g,2),.5)),o=f(Math.pow(s*Math.pow(h.b,2)+e*Math.pow(l.b,2),.5))),v=h.a,l=l.a,h=v>=0||l>=0,v=h?v<0?l:l<0?v:v*s+l*e:0,c?"rgb"+(h?"a(":"(")+r+","+n+","+o+(h?","+f(v*1e3)/1e3:"")+")":"#"+(4294967296+r*16777216+n*65536+o*256+(h?f(v*255):0)).toString(16).slice(1,h?void 0:-2))}globalThis.pSBC=Ft;function ls(e,t){var i=Dc(e)||{r:0,g:0,b:0};return i.a<0?"rgba("+i.r+","+i.g+","+i.b+","+t+")":"rgba("+i.r+","+i.g+","+i.b+","+(t+i.a)+")"}var bn=globalThis&&globalThis.__read||function(e,t){var i=typeof Symbol=="function"&&e[Symbol.iterator];if(!i)return e;var a=i.call(e),r,n=[],o;try{for(;(t===void 0||t-- >0)&&!(r=a.next()).done;)n.push(r.value)}catch(s){o={error:s}}finally{try{r&&!r.done&&(i=a.return)&&i.call(a)}finally{if(o)throw o.error}}return n},s2=globalThis&&globalThis.__values||function(e){var t=typeof Symbol=="function"&&Symbol.iterator,i=t&&e[t],a=0;if(i)return i.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&a>=e.length&&(e=void 0),{value:e&&e[a++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};function Mo(e,t){if(isNaN(e)){console.warn("realValue not number");return}if(typeof t!="string"){console.warn("collection must be string");return}var i=bn([t[0],t[t.length-1]],2),a=i[0],r=i[1];if(!["[","("].includes(a)){console.warn('collection must start with "[" or "("');return}if(!["]",")"].includes(r)){console.warn('collection must end with "]" or ")"');return}var n=t.substring(1,t.length-1).split(",");if(n.length!==2){console.warn("collection must have 2 numbers");return}var o=bn([+n[0],+n[1]],2),s=o[0],h=o[1];if(s>=h){console.warn("startNum must less than endNum");return}var l=e>s||a==="["&&e===s;if(!l)return!1;var c=e=m){console.warn("startNum must less than endNum");return}if(e>=p&&e<=m)return!0}else if(e==c)return!0}}catch(b){i={error:b}}finally{try{l&&!l.done&&(a=h.return)&&a.call(h)}finally{if(i)throw i.error}}return!1}function Me(){return((1+Math.random())*4294967296|0).toString(16).substring(1)}var ar=function(e){var t=0,i=0,a=0,r=0;if(typeof e=="number")t=i=a=r=e;else if(typeof e=="string"){var n=parseInt(e,10);t=i=a=r=n}else Array.isArray(e)&&(t=e[0],a=Xl(e[1])?e[0]:e[1],r=Xl(e[2])?e[0]:e[2],i=Xl(e[3])?a:e[3]);return[t,a,r,i]};function Xl(e){return e==null}var Jv=globalThis&&globalThis.__awaiter||function(e,t,i,a){function r(n){return n instanceof i?n:new i(function(o){o(n)})}return new(i||(i=Promise))(function(n,o){function s(c){try{l(a.next(c))}catch(f){o(f)}}function h(c){try{l(a.throw(c))}catch(f){o(f)}}function l(c){c.done?n(c.value):r(c.value).then(s,h)}l((a=a.apply(e,t||[])).next())})},eg=globalThis&&globalThis.__generator||function(e,t){var i={label:0,sent:function(){if(n[0]&1)throw n[1];return n[1]},trys:[],ops:[]},a,r,n,o;return o={next:s(0),throw:s(1),return:s(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function s(l){return function(c){return h([l,c])}}function h(l){if(a)throw new TypeError("Generator is already executing.");for(;i;)try{if(a=1,r&&(n=l[0]&2?r.return:l[0]?r.throw||((n=r.return)&&n.call(r),0):r.next)&&!(n=n.call(r,l[1])).done)return n;switch(r=0,n&&(l=[l[0]&2,n.value]),l[0]){case 0:case 1:n=l;break;case 4:return i.label++,{value:l[1],done:!1};case 5:i.label++,r=l[1],l=[0];continue;case 7:l=i.ops.pop(),i.trys.pop();continue;default:if(n=i.trys,!(n=n.length>0&&n[n.length-1])&&(l[0]===6||l[0]===2)){i=0;continue}if(l[0]===3&&(!n||l[1]>n[0]&&l[1]0)&&!(r=a.next()).done;)n.push(r.value)}catch(s){o={error:s}}finally{try{r&&!r.done&&(i=a.return)&&i.call(a)}finally{if(o)throw o.error}}return n},v2=globalThis&&globalThis.__spreadArray||function(e,t,i){if(i||arguments.length===2)for(var a=0,r=t.length,n;a=e.length&&(e=void 0),{value:e&&e[a++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};function g2(e,t){if(!e||!t)return!1;for(var i=ri(e);i;){if(i.id===t.id)return!0;i=ri(i)}return!1}function ri(e,t){if(!(!e||!e.parentId||!e.calculative)){var i=e.calculative.canvas.store,a=i.pens[e.parentId];return t&&ri(a,t)||a}}function Er(e,t){if(!e||!e.children)return[];var i=[];return e.children.forEach(function(a){var r=t.pens[a];r&&(i.push(r),i.push.apply(i,v2([],d2(Er(r,t)),!1)))}),i}function y2(e,t){var i=t.calculative,a=i.worldRect,r=i.gradientFromColor,n=i.gradientToColor,o=i.gradientAngle;return tg(e,a,r,n,o)}function m2(e,t){var i=t.calculative,a=i.worldRect,r=i.gradientFromColor,n=i.gradientToColor,o=i.gradientRadius;if(!(!r||!n)){var s=a.width,h=a.height,l=a.center,c=l.x,f=l.y,v=s;va&&r<180-a||r>180+a&&r<360-a||r<0?(r>270?r=360-r:r>180?r=r-180:r>90&&(r=180-r),n=Math.abs(i/Math.sin(r/180*Math.PI)/2)):(r>270?r=360-r:r>180?r=r-180:r>90&&(r=180-r),n=Math.abs(t/Math.cos(r/180*Math.PI)/2)),n}function sa(e){if(typeof e=="string"&&e.startsWith("linear-gradient")){var t=e.slice(16,-2).split("deg,");if(t.length>1){var i=t[1].split("%,"),a=[];return i.forEach(function(r){if(/rgba?/.test(r)){var n=r.split(") ");a.push({color:E2(n[0]+")"),i:parseFloat(n[1])/100})}else{var o=r.split(" ");o.length>2?a.push({color:o[1],i:parseFloat(o[2])/100}):a.push({color:o[0],i:parseFloat(o[1])/100})}}),{angle:parseFloat(t[0]),colors:a}}else return{angle:parseFloat(t[0]),colors:[]}}else return{angle:0,colors:[]}}function E2(e){if(/rgba?/.test(e)){var t=e.split(",");if(t.length<3)return"";e="#";for(var i=0,a=void 0;a=t[i++];)if(i<4)a=parseInt(a.replace(/[^\d]/gi,""),10).toString(16),e+=a.length==1?"0"+a:a;else{a=a.replace(")","");var r=parseInt(a*255+""),n=r.toString(16);n=n.length===2?n:"0"+n,e+=n}e=e.toUpperCase()}return e}function k2(e,t){var i=t.calculative.worldRect,a=i.x,r=i.y,n=i.ex,o=i.width,s=i.height,h=i.center,l=[{x:n,y:r+s/2},{x:a,y:r+s/2}],c=sa(t.calculative.lineGradientColors),f=c.angle,v=c.colors,g=ru(f,o,s);return l.forEach(function(y){Ge(y,f,h)}),bs(e,l,v,g)}function bs(e,t,i,a){var r=p2(t[0].x,t[0].y,t[1].x,t[1].y,a),n=e.createLinearGradient(r[0],r[1],r[2],r[3]);return i.forEach(function(o){n.addColorStop(o.i,o.color)}),n}function qr(e,t,i){var a=[];t.calculative.gradientColorStop?a=t.calculative.gradientColorStop:(a=sa(t.calculative.lineGradientColors).colors,t.calculative.gradientColorStop=a),e.strokeStyle=bs(e,i,a,t.calculative.lineWidth/2),e.beginPath(),e.moveTo(i[0].x,i[0].y),e.lineTo(i[1].x,i[1].y),e.stroke()}function C2(e,t){for(var i=t.calculative.worldAnchors,a=t.calculative.lineWidth*(t.calculative.gradientSmooth||t.calculative.lineSmooth||0),r=0;r0){var n=i[r-1].curvePoints;n?Oo(e,t,a,n[n.length-1],i[r],i[r].curvePoints[0]):Oo(e,t,a,i[r-1],i[r],i[r].curvePoints[0]);var o=nr(a,i[r],i[r].curvePoints[0]);qr(e,t,[o,i[r].curvePoints[1]])}else qr(e,t,[i[r],i[r].curvePoints[0]]),qr(e,t,[i[r].curvePoints[0],i[r].curvePoints[1]]);for(var s=i[r].curvePoints.length-1,h=1;h0&&r0&&r0&&r0&&r0?s=t.calculative.iconSize:a.width>a.height?s=a.height:s=a.width,e.font=Lr({fontSize:s,fontWeight:o,fontFamily:h}),e.fillStyle=t.calculative.iconColor||Ir(t,i),t.calculative.iconRotate&&(e.translate(a.center.x,a.center.y),e.rotate(t.calculative.iconRotate*Math.PI/180),e.translate(-a.center.x,-a.center.y)),e.beginPath(),e.fillText(t.calculative.icon,r,n),e.restore()}function Lr(e){var t=e===void 0?{}:e,i=t.fontStyle,a=i===void 0?"normal":i,r=t.textDecoration,n=r===void 0?"normal":r,o=t.fontWeight,s=o===void 0?"normal":o,h=t.fontSize,l=h===void 0?12:h,c=t.fontFamily,f=c===void 0?"Arial":c,v=t.lineHeight,g=v===void 0?1:v;return a+" "+n+" "+s+" "+l+"px/"+g+" "+f}function Qr(e,t){var i=t.calculative.worldRect||{},a=i.x,r=i.ex,n=i.y,o=i.ey;t.calculative.flipX&&(e.translate(a+r+.5,.5),e.scale(-1,1)),t.calculative.flipY&&(e.translate(.5,n+o+.5),e.scale(1,-1))}function or(e,t,i){i===void 0&&(i=!1);var a=t.calculative.worldRect.center,r=a.x,n=a.y;e.translate(r,n);var o=t.calculative.rotate*Math.PI/180;i||(t.calculative.flipX&&(o*=-1),t.calculative.flipY&&(o*=-1)),e.rotate(o),e.translate(-r,-n)}function jr(e,t,i){var a,r;e.save(),e.translate(.5,.5),e.beginPath();var n=t.calculative.canvas.store,o=t.textFlip||n.options.textFlip,s=t.textRotate||n.options.textRotate;(!o||!s)&&e.save(),Qr(e,t),t.calculative.rotate&&t.name!=="line"&&or(e,t),(t.calculative.lineWidth>1||i)&&(e.lineWidth=t.calculative.lineWidth),j2(e,n,t);var h,l=!1,c=void 0;t.calculative.disabled?(c=t.disabledColor||n.options.disabledColor||Ft(.4,t.calculative.color||us(n)),h=t.disabledBackground||n.options.disabledBackground||Ft(.4,t.calculative.background||n.data.penBackground)):t.calculative.hover?(c=t.hoverColor||n.options.hoverColor,h=t.hoverBackground||n.options.hoverBackground):t.calculative.active?(c=t.activeColor||n.options.activeColor,h=t.activeBackground||n.options.activeBackground):t.calculative.isDock&&(t.type===Ye.Line?c=n.options.dockPenColor:h=ls(n.options.dockPenColor,.2));var f=t.calculative.strokeImg;if(t.calculative.strokeImage&&f)e.strokeStyle=c||e.createPattern(f,"repeat");else{var v=void 0;t.calculative.strokeType?t.calculative.lineGradientColors?t.name==="line"?l=!0:t.calculative.lineGradient?v=t.calculative.lineGradient:(v=k2(e,t),t.calculative.lineGradient=v):v=P2(e,t):v=t.calculative.color||us(n),e.strokeStyle=c||v}var g=t.calculative.backgroundImg;if(t.calculative.backgroundImage&&g)e.fillStyle=h||e.createPattern(g,"repeat"),h=!0;else{var y=void 0;t.calculative.bkType===qa.Linear?t.calculative.gradientColors?t.calculative.gradient?y=t.calculative.gradient:(y=b2(e,t),t.calculative.gradient=y):y=y2(e,t):t.calculative.bkType===qa.Radial?t.calculative.gradientColors?t.calculative.radialGradient?y=t.calculative.radialGradient:(y=w2(e,t),t.calculative.radialGradient=y):y=m2(e,t):y=t.calculative.background||n.data.penBackground,e.fillStyle=h||y,h=!!y}if(ng(e,t),og(e,t),Jr(e,t),t.calculative.lineDash&&e.setLineDash(t.calculative.lineDash.map(function(x){return x*t.calculative.canvas.store.data.scale})),t.calculative.lineDashOffset&&(e.lineDashOffset=t.calculative.lineDashOffset),t.calculative.shadowColor&&(e.shadowColor=t.calculative.shadowColor,e.shadowOffsetX=t.calculative.shadowOffsetX,e.shadowOffsetY=t.calculative.shadowOffsetY,e.shadowBlur=t.calculative.shadowBlur),l?(C2(e,t),M2(!0,e,t,n)):(sg(!0,e,t,n,h),fg(e,t)),!(t.image&&t.calculative.img)&&t.calculative.icon&&ag(e,t),(!o||!s)&&e.restore(),o&&!s&&Qr(e,t),!o&&s&&t.calculative.rotate&&t.name!=="line"&&or(e,t,!0),ig(e,t),t.type===Ye.Line&&t.fillTexts)try{for(var p=Tn(t.fillTexts),m=p.next();!m.done;m=p.next()){var b=m.value;rg(e,t,b)}}catch(x){a={error:x}}finally{try{m&&!m.done&&(r=p.return)&&r.call(p)}finally{if(a)throw a.error}}e.restore()}function ng(e,t){var i=t.lineCap||(t.type?"round":"square");i?e.lineCap=i:t.type&&(e.lineCap="round")}function og(e,t){var i=t.lineJoin;i?e.lineJoin=i:t.type&&(e.lineJoin="round")}function cs(e,t,i,a){var r,n,o,s;e.save(),i&&e.translate(-i.x,-i.y),(s=(o=e).setAttrs)===null||s===void 0||s.call(o,t);var h=t.calculative.canvas.store,l=t.textFlip||h.options.textFlip,c=t.textRotate||h.options.textRotate;e.beginPath(),(!l||!c)&&e.save(),t.calculative.flipX&&(e.translate(t.calculative.worldRect.x+t.calculative.worldRect.ex,0),e.scale(-1,1)),t.calculative.flipY&&(e.translate(0,t.calculative.worldRect.y+t.calculative.worldRect.ey),e.scale(1,-1)),t.calculative.rotate&&t.name!=="line"&&or(e,t),(t.calculative.lineWidth>1||a)&&(e.lineWidth=t.calculative.lineWidth);var f;if(t.calculative.hover?(e.strokeStyle=t.hoverColor||h.options.hoverColor,e.fillStyle=t.hoverBackground||h.options.hoverBackground,f=t.hoverBackground||h.options.hoverBackground):t.calculative.active?(e.strokeStyle=t.activeColor||h.options.activeColor,e.fillStyle=t.activeBackground||h.options.activeBackground,f=t.activeBackground||h.options.activeBackground):(t.strokeImage?t.calculative.strokeImg&&(e.strokeStyle=e.createPattern(t.calculative.strokeImg,"repeat"),f=!0):e.strokeStyle=t.calculative.color||us(h),t.backgroundImage?t.calculative.backgroundImg&&(e.fillStyle=e.createPattern(t.calculative.backgroundImg,"repeat"),f=!0):(e.fillStyle=t.background,f=!!t.background)),ng(e,t),og(e,t),Jr(e,t),t.calculative.lineDash&&e.setLineDash(t.calculative.lineDash),t.calculative.lineDashOffset&&(e.lineDashOffset=t.calculative.lineDashOffset),t.calculative.shadowColor&&(e.shadowColor=t.calculative.shadowColor,e.shadowOffsetX=t.calculative.shadowOffsetX,e.shadowOffsetY=t.calculative.shadowOffsetY,e.shadowBlur=t.calculative.shadowBlur),sg(!1,e,t,h,f),fg(e,t),t.calculative.img?(e.save(),e.shadowColor="",e.shadowBlur=0,e.shadowOffsetX=0,e.shadowOffsetY=0,Fa(e,t),e.restore()):t.calculative.icon&&ag(e,t),(!l||!c)&&e.restore(),l&&!c&&(t.calculative.flipX&&(e.translate(t.calculative.worldRect.x+t.calculative.worldRect.ex,0),e.scale(-1,1)),t.calculative.flipY&&(e.translate(0,t.calculative.worldRect.y+t.calculative.worldRect.ey),e.scale(1,-1))),!l&&c&&t.calculative.rotate&&t.name!=="line"&&or(e,t,!0),ig(e,t),t.type===Ye.Line&&t.fillTexts)try{for(var v=Tn(t.fillTexts),g=v.next();!g.done;g=v.next()){var y=g.value;rg(e,t,y)}}catch(p){r={error:p}}finally{try{g&&!g.done&&(n=v.return)&&n.call(v)}finally{if(r)throw r.error}}e.restore()}function sg(e,t,i,a,r){e===void 0&&(e=!0);var n=e?a.path2dMap.get(i):ke.path2dDraws[i.name];if(n){if(i.type===Ye.Line&&i.borderWidth){t.save(),t.beginPath();var o=i.calculative.lineWidth+i.calculative.borderWidth;t.lineWidth=o,t.strokeStyle=i.borderColor,n instanceof Path2D?(r&&t.fill(n),o&&t.stroke(n)):(n(i,t),r&&t.fill(),o&&t.stroke()),t.restore()}n instanceof Path2D?i.type?i.close&&r&&t.fill(n):r&&t.fill(n):(t.save(),n(i,t),r&&t.fill(),t.restore());var s=i.calculative.progress;if(s!=null){t.save();var h=i.calculative.worldRect,l=h.ex,c=h.x,f=h.y,v=h.width,g=h.height,y=h.ey,p=null;if(i.verticalProgress?p=i.reverseProgress?t.createLinearGradient(c,f,c,f+g*s):t.createLinearGradient(c,y,c,f+g*(1-s)):p=i.reverseProgress?t.createLinearGradient(l,f,c+v*(1-s),f):t.createLinearGradient(c,f,c+v*s,f),i.calculative.progressGradientColors){var m=sa(i.calculative.progressGradientColors).colors;m.forEach(function(_){p.addColorStop(_.i,_.color)})}else{var b=i.calculative.progressColor||i.calculative.color||a.options.activeColor;p.addColorStop(0,b),p.addColorStop(1,b)}p.addColorStop(1,"transparent"),t.fillStyle=p,n instanceof Path2D?t.fill(n):(n(i,t),t.fill()),t.restore()}if(i.calculative.lineWidth&&(n instanceof Path2D?(a.options.svgPathStroke||i.name!=="svgPath")&&t.stroke(n):(n(i,t),t.stroke())),i.type){if(i.calculative.animatePos){if(t.save(),lg(t,i,a),i.lineAnimateType===ai.Arrow||i.lineAnimateType===ai.WaterDrop){var x=_g(i,t);x instanceof Path2D?(t.stroke(x),t.fill(x)):(t.stroke(),t.fill())}else n instanceof Path2D?t.stroke(n):(n(i,t),t.stroke());t.restore()}i.fromArrow&&Zv(t,i,a),i.toArrow&&Qv(t,i,a),i.calculative.active&&!i.calculative.pencil&&!a.options.disableAnchor&&!a.data.locked&&cg(t,i)}}}function M2(e,t,i,a){e===void 0&&(e=!0);var r=e?a.path2dMap.get(i):ke.path2dDraws[i.name];if(r&&i.type){if(i.calculative.animatePos){if(t.save(),lg(t,i,a),t.beginPath(),r instanceof Path2D)if(i.lineName==="polyline"||i.lineName==="line")if(i.lineAnimateType===ai.Arrow||i.lineAnimateType===ai.WaterDrop){var n=_g(i);t.stroke(n),t.fill(n)}else i.calculative.gradientSmooth||i.calculative.lineSmooth?(i.calculative.gradientAnimatePath||(i.calculative.gradientAnimatePath=au(i)),i.calculative.gradientAnimatePath instanceof Path2D&&t.stroke(i.calculative.gradientAnimatePath)):t.stroke(r);else t.stroke(r);else r(i,t),t.stroke();t.restore()}i.fromArrow&&Zv(t,i,a),i.toArrow&&Qv(t,i,a),i.calculative.active&&!i.calculative.pencil&&!a.options.disableAnchor&&!a.data.locked&&cg(t,i)}}function lg(e,t,i){e.strokeStyle=t.animateColor||i.options.animateColor,t.animateShadow&&(e.shadowBlur=t.animateShadowBlur||t.animateLineWidth||6,e.shadowColor=t.animateShadowColor||t.animateColor||i.options.animateColor),t.calculative.animateLineWidth&&(e.lineWidth=t.calculative.animateLineWidth*i.data.scale);var a=0;switch(t.lineAnimateType){case ai.Beads:t.animateReverse?e.lineDashOffset=t.calculative.animatePos:e.lineDashOffset=t.length-t.calculative.animatePos,a=t.calculative.lineWidth||5,a<5&&(a=5);var r=t.animateLineDash&&t.animateLineDash.map(function(n){return n*a/5});e.setLineDash(r||[a,a*2]);break;case ai.Dot:t.animateReverse?e.lineDashOffset=t.calculative.animatePos:e.lineDashOffset=t.length-t.calculative.animatePos,a=t.calculative.animateDotSize||t.calculative.lineWidth*2||6,a<6&&(a=6),a>40&&(a=40),e.lineWidth=(t.calculative.animateLineWidth||a)*i.data.scale,e.setLineDash([.1,t.length]);break;case ai.Arrow:e.fillStyle=t.animateColor||i.options.animateColor,e.lineWidth=1;break;case ai.WaterDrop:e.fillStyle=t.animateColor||i.options.animateColor,e.lineWidth=1;break;default:t.animateReverse?(e.lineDashOffset=Number.EPSILON,e.setLineDash([0,t.length-t.calculative.animatePos+1,t.calculative.animatePos])):e.setLineDash([t.calculative.animatePos,t.length+.01-t.calculative.animatePos]);break}}function us(e){var t=e.data,i=e.options;return t.color||i.color}function cg(e,t){var i=t.calculative.canvas.store;e.save(),e.lineWidth=1,e.fillStyle=t.activeColor||i.options.activeColor,t.calculative.worldAnchors.forEach(function(a){!a.hidden&&!a.isTemp&&B2(e,a,t)}),e.restore()}function B2(e,t,i){if(!!t){var a=i.calculative.canvas.store.activeAnchor===i.calculative.activeAnchor&&i.calculative.activeAnchor===t,r=3;i.calculative.lineWidth>3&&(r=i.calculative.lineWidth),i.anchorRadius&&(r=i.anchorRadius),t.radius&&(r=t.radius),a?(t.prev&&(e.save(),e.strokeStyle="#4dffff",e.beginPath(),e.moveTo(t.prev.x,t.prev.y),e.lineTo(t.x,t.y),e.stroke(),e.restore(),e.save(),e.fillStyle="#ffffff",e.beginPath(),e.arc(t.prev.x,t.prev.y,r,0,Math.PI*2),e.fill(),e.stroke(),e.restore()),t.next&&(e.save(),e.strokeStyle="#4dffff",e.beginPath(),e.moveTo(t.x,t.y),e.lineTo(t.next.x,t.next.y),e.stroke(),e.restore(),e.save(),e.fillStyle="#ffffff",e.beginPath(),e.arc(t.next.x,t.next.y,r,0,Math.PI*2),e.fill(),e.stroke(),e.restore(),e.beginPath(),e.arc(t.x,t.y,r,0,Math.PI*2),e.fill(),e.stroke()),e.beginPath(),e.arc(t.x,t.y,r,0,Math.PI*2),e.fill(),e.stroke()):(e.save(),e.fillStyle="#ffffff",e.beginPath(),e.arc(t.x,t.y,r,0,Math.PI*2),e.fill(),e.stroke(),e.restore())}}function ug(e){var t=e.calculative.canvas.store,i={x:e.x,y:e.y};if(!e.parentId||e.parentId&&!t.pens[e.parentId])e.parentId=void 0,i.width=e.width,i.height=e.height,i.rotate=e.rotate,ot(i),tt(i);else{var a=t.pens[e.parentId],r=a.calculative.worldRect;r||(r=ug(a)),i.x=r.x+r.width*e.x,i.y=r.y+r.height*e.y,i.width=r.width*e.width,i.height=r.height*e.height,a.flipX&&(i.x=r.width-(i.x-r.x+i.width)+r.x),a.flipY&&(i.y=r.height-(i.y-r.y+i.height)+r.y),ot(i),i.rotate=r.rotate+e.rotate,tt(i)}return e.calculative.worldRect=i,nu(e,i),i}function nu(e,t){!e.paddingTop&&(e.calculative.paddingTop=0),!e.paddingBottom&&(e.calculative.paddingBottom=0),!e.paddingLeft&&(e.calculative.paddingLeft=0),!e.paddingRight&&(e.calculative.paddingRight=0),Math.abs(e.calculative.paddingTop)<1&&(e.calculative.paddingTop*=t.height),Math.abs(e.calculative.paddingBottom)<1&&(e.calculative.paddingBottom*=t.height),Math.abs(e.calculative.paddingLeft)<1&&(e.calculative.paddingLeft*=t.width),Math.abs(e.calculative.paddingRight)<1&&(e.calculative.paddingRight*=t.width)}function Yo(e){var t=e.calculative.worldRect;if(!e.parentId){Object.assign(e,t);return}var i=e.calculative.canvas.store,a=i.pens[e.parentId].calculative.worldRect;Object.assign(e,Xo(t,a))}function _n(e){var t=e.calculative.canvas.store,i=[];if(e.anchors){var a=ce(e.anchors);e.flipX&&a.forEach(function(l){l.x=.5-(l.x-.5)}),e.flipY&&a.forEach(function(l){l.y=.5-(l.y-.5)}),a.forEach(function(l){i.push(O2(e,l))})}if(!i.length&&!e.type&&!e.calculative.canvas.parent.isCombine(e)){var r=e.calculative.worldRect,n=r.x,o=r.y,s=r.width,h=r.height;i=t.options.defaultAnchors.map(function(l,c){return{id:""+c,penId:e.id,x:n+s*l.x,y:o+h*l.y}})}e.calculative.rotate&&i.forEach(function(l){Ge(l,e.calculative.rotate,e.calculative.worldRect.center)}),(!e.type||e.anchors)&&(e.calculative.worldAnchors=i),e.calculative.activeAnchor&&i.length&&(e.calculative.activeAnchor=i.find(function(l){l.id,e.calculative.activeAnchor.id})),e.calculative.gradientAnimatePath=void 0}function O2(e,t){var i=Mc({},t),a=e.calculative.worldRect,r=a.x,n=a.y,o=a.width,s=a.height;return i.x=r+o*t.x,i.y=n+s*t.y,t.prev&&(i.prev={penId:e.id,connectTo:t.prev.connectTo,x:r+o*t.prev.x,y:n+s*t.prev.y}),t.next&&(i.next={penId:e.id,connectTo:t.next.connectTo,x:r+o*t.next.x,y:n+s*t.next.y}),i}function sd(e,t){var i=t.calculative,a=i.paddingTop,r=i.paddingBottom,n=i.paddingLeft,o=i.paddingRight,s=n,h=a,l=t.calculative.worldRect.width-n-o,c=t.calculative.worldRect.height-a-r,f=t.calculative.iconLeft,v=t.calculative.iconTop;f&&Math.abs(f)<1&&(f=t.calculative.worldRect.width*f),v&&Math.abs(v)<1&&(v=t.calculative.worldRect.height*v),s+=f||0,h+=v||0,l-=f||0,c-=v||0;var g=t.calculative.iconRotate||0;if(t.parentId){var y=e[t.parentId].calculative;y&&(g+=y.rotate,g%=360)}s=t.calculative.worldRect.x+s,h=t.calculative.worldRect.y+h,t.calculative.worldIconRect={x:s,y:h,width:l,height:c,rotate:g},ot(t.calculative.worldIconRect),tt(t.calculative.worldIconRect)}function Aa(e,t,i){ds(e.calculative.worldRect,t,i),e.calculative.initRect&&ds(e.calculative.initRect,t,i),e.calculative.x&&os(e.calculative,t,i),e.type&&_n(e)}function N2(e,t){e.anchors||(e.anchors=[]),e.calculative.worldAnchors||(e.calculative.worldAnchors=[]);var i={id:t.id,penId:e.id,x:t.x,y:t.y};if(e.calculative.worldAnchors.push(i),e.calculative.worldRect){e.rotate%360&&Ge(t,-e.rotate,e.calculative.worldRect.center);var a={id:t.id,penId:e.id,x:(t.x-e.calculative.worldRect.x)/e.calculative.worldRect.width,y:(t.y-e.calculative.worldRect.y)/e.calculative.worldRect.height};e.anchors.push(a)}return i}function F2(e,t,i){e.anchors||(e.anchors=[]),e.calculative.worldAnchors||(e.calculative.worldAnchors=[]);var a=FE(e,t,i);return e.calculative.worldAnchors.splice(i+1,0,a),e.anchors.splice(i+1,0,xn(a,e.calculative.worldRect)),e.calculative.activeAnchor=a,a}function z2(e,t){if(!(!e||!e.calculative.worldAnchors)){var i=e.calculative.worldAnchors.findIndex(function(a){return a.id===t.id});i>-1&&e.calculative.worldAnchors.splice(i,1),i=e.anchors.findIndex(function(a){return a.id===t.id}),i>-1&&e.anchors.splice(i,1)}}function ja(e,t){if(!t||!t.calculative||!t.calculative.worldRect.center)return Pe.None;if(e.anchorId){var i=t.anchors.filter(function(a){return a.id===e.anchorId});if(i.length&&i[0].direction>-1)return i[0].direction}return Rx(e,t.calculative.worldRect.center)}function Ma(e,t){var i=1/0,a;return e.calculative.worldAnchors.forEach(function(r){var n=ws(t,r);i>n&&(i=n,a=r)}),a}function ld(e,t,i){e.x+=t,e.y+=i,e.anchors&&e.anchors.forEach(function(a){wn(a,t,i)}),e.calculative.worldAnchors&&e.calculative.worldAnchors.forEach(function(a){wn(a,t,i)})}function ou(e){if(e&&e.calculative&&e.calculative.worldAnchors.length){var t=We(e);if(!e.anchors||!e.anchors.length)for(;e.calculative.worldAnchors.length&&t!==e.calculative.activeAnchor;)e.calculative.worldAnchors.pop(),t=We(e);else t===e.calculative.activeAnchor?e.calculative.worldAnchors=[e.calculative.worldAnchors[0]]:e.calculative.worldAnchors[0]===e.calculative.activeAnchor&&(e.calculative.worldAnchors=[e.calculative.worldAnchors[e.calculative.worldAnchors.length-1]])}}function _t(e,t,i,a){var r,n,o,s,h,l;if(!(!e||!t||!i||!a||t.twoWay===At.DisableConnected||t.twoWay===At.Disable||a.twoWay===At.DisableConnectTo||a.twoWay===At.Disable)){if(t.twoWay===At.In){if(i.calculative.worldAnchors.length===1)return;var c=We(i);if(a.id!==c.id)return}if(t.twoWay===At.Out){var f=lt(i);if(a.id!==f.id)return}if(!(a.connectTo===e.id&&a.anchorId===t.id)){if(a.connectTo){var v=e.calculative.canvas.store.pens[a.connectTo];Ba(v,Kr(v,a.anchorId),i,a)}e.connectedLines||(e.connectedLines=[]);var g=e.connectedLines.findIndex(function(m){return m.lineId===i.id&&m.lineAnchor===a.id&&m.anchor===t.id});g<0&&e.connectedLines.push({lineId:i.id,lineAnchor:a.id,anchor:t.id}),a.connectTo=e.id,a.anchorId=t.id,e.type&&_t(i,a,e,t),e.calculative.canvas.store.emitter.emit("connectLine",{line:i,lineAnchor:a,pen:e,anchor:t});var y=((r=i.calculative.worldAnchors)===null||r===void 0?void 0:r.length)>=2?(n=i.calculative.worldAnchors)===null||n===void 0?void 0:n[0].connectTo:void 0,p=((o=i.calculative.worldAnchors)===null||o===void 0?void 0:o.length)>=2?(h=i.calculative.canvas.store.pens[(s=i.calculative.worldAnchors)===null||s===void 0?void 0:s[0].connectTo])===null||h===void 0?void 0:h.anchors.find(function(m){var b;return m.id===((b=i.calculative.worldAnchors)===null||b===void 0?void 0:b[0].anchorId)}):void 0;return(l=e.onConnectLine)===null||l===void 0||l.call(e,e,{line:i,lineAnchor:a,pen:e,anchor:t,fromPen:y,fromAnchor:p}),!0}}}function Ba(e,t,i,a){if(!(!e||!t||!i||!a)&&!(!e.connectedLines||!e.connectedLines.length))return i.lastConnected||(i.lastConnected={}),i.lastConnected[e.id]||(i.lastConnected[e.id]=ce(e.connectedLines)),e.connectedLines.forEach(function(r,n,o){(r.lineId===i.id||r.lineId===i.id)&&r.lineAnchor===a.id&&r.anchor===t.id&&o.splice(n,1)}),a.connectTo=void 0,a.anchorId=void 0,e.type&&t.connectTo===i.id&&t.anchorId===a.id&&Ba(i,a,e,t),e.calculative.canvas.store.emitter.emit("disconnectLine",{line:i,lineAnchor:a,pen:e,anchor:t}),!0}function Kr(e,t){var i;if(!(!e||!t))return(i=e.calculative.worldAnchors)===null||i===void 0?void 0:i.find(function(a){return a.id===t})}function lt(e){if(!(!e||!e.calculative.worldAnchors))return e.calculative.worldAnchors[0]}function We(e){if(!(!e||!e.calculative.worldAnchors))return e.calculative.worldAnchors[e.calculative.worldAnchors.length-1]}function H2(e,t){var i,a,r,n,o;if(e.calculative.start===0||!e.frames||!e.frames.length)return e.calculative.start=void 0,0;if(!e.calculative.duration){e.calculative.duration=0;try{for(var s=Tn(e.frames),h=s.next();!h.done;h=s.next()){var l=h.value;e.calculative.duration+=l.duration;for(var c in l)c!=="duration"&&!e[c]&&c==="scale"&&(e[c]=1)}}catch(P){i={error:P}}finally{try{h&&!h.done&&(a=s.return)&&a.call(s)}finally{if(i)throw i.error}}}if(e.animateCycle||(e.animateCycle=1/0),!e.calculative.start)e.calculative.start=t,e.calculative.frameIndex=0,e.calculative.frameStart=e.calculative.start,e.calculative.frameDuration=e.frames[0].duration,e.calculative.frameEnd=e.calculative.frameStart+e.calculative.frameDuration,e.calculative.cycleIndex=1,e.calculative.x=e.calculative.worldRect.x,e.calculative.y=e.calculative.worldRect.y,e.calculative.initRect=ce(e.calculative.worldRect),e.calculative.initRect.rotate=e.calculative.rotate||0,cd(e);else{var f=0,v=Math.ceil((t-e.calculative.start)/e.calculative.duration);if(v>e.animateCycle)return e.currentAnimation=void 0,e.calculative.start=void 0,ud(e,1),0;var g=(t-e.calculative.start)%e.calculative.duration,y=0;try{for(var p=Tn(e.frames),m=p.next();!m.done;m=p.next()){var b=m.value;if(y+=b.duration,g>y)++f;else break}}catch(P){r={error:P}}finally{try{m&&!m.done&&(n=p.return)&&n.call(p)}finally{if(r)throw r.error}}if(!e.frames[f])return!0;e.calculative.frameDuration=e.frames[f].duration,e.calculative.frameStart=e.calculative.start+e.calculative.duration*(v-1),e.calculative.frameEnd=e.calculative.frameStart+e.calculative.frameDuration;var x=f!==e.calculative.frameIndex,_=v>e.calculative.cycleIndex;if(x&&(e.calculative.frameIndex=f),_&&(e.calculative.cycleIndex=v),x||_)if(e.calculative.x=e.calculative.initRect.x,e.calculative.y=e.calculative.initRect.y,!((o=e.children)===null||o===void 0)&&o.length?e.calculative.canvas.rotatePen(e,(e.calculative.initRect.rotate||0)-e.calculative.rotate,e.calculative.initRect):e.calculative.rotate=e.calculative.initRect.rotate||0,f>0){e.prevFrame={};var k=e.frames[f-1];for(var c in k)e.prevFrame[c]=k[c];Object.assign(e.prevFrame,{rotate:k.rotate||0,x:k.x||0,y:k.y||0,scale:k.scale||1})}else cd(e)}var I=(t-e.calculative.frameStart)/e.calculative.frameDuration%1;return ud(e,I),!0}function cd(e){e.prevFrame={};for(var t in e)(typeof e[t]!="object"||t==="lineDash")&&(e.prevFrame[t]=e[t]);e.prevFrame.rotate=0,e.prevFrame.x=0,e.prevFrame.y=0,e.prevFrame.scale=1}function ud(e,t){var i;if(!(t<0)){t>1&&(t=1);var a=e.frames[e.calculative.frameIndex];for(var r in a)if(r!=="duration"){if(r==="scale"){e.calculative.worldRect=ce(e.calculative.initRect),ds(e.calculative.worldRect,e.prevFrame.scale,e.calculative.worldRect.center);var n=e.prevFrame.scale+(a[r]-e.prevFrame.scale)*t;ds(e.calculative.worldRect,n/e.prevFrame.scale,e.calculative.worldRect.center),e.calculative.patchFlags=!0}else if(r==="x"){var o=Ql(e,r,e.calculative.frameIndex);e.calculative.worldRect.x=e.calculative.initRect.x+o,e.calculative.worldRect.ex=e.calculative.initRect.ex+o,Yr(e.calculative.worldRect,a[r]*t*e.calculative.canvas.store.data.scale,0),e.calculative.patchFlags=!0}else if(r==="y"){var o=Ql(e,r,e.calculative.frameIndex);e.calculative.worldRect.y=e.calculative.initRect.y+o,e.calculative.worldRect.ey=e.calculative.initRect.ey+o,Yr(e.calculative.worldRect,0,a[r]*t*e.calculative.canvas.store.data.scale),e.calculative.patchFlags=!0}else if(r==="rotate"){e.prevFrame[r]>=360&&(e.prevFrame[r]%=360);var o=Ql(e,r,e.calculative.frameIndex),s=(e.calculative.initRect.rotate+o+a[r]*t)%360-(e.calculative.rotate||0);!((i=e.children)===null||i===void 0)&&i.length?e.calculative.canvas.rotatePen(e,s,e.calculative.initRect):e.calculative.rotate=(e.calculative.initRect.rotate+o+a[r]*t)%360,e.calculative.patchFlags=!0}else if(r==="image")e.image=a.image,e.calculative.image=void 0,e.calculative.canvas.loadImage(e),e.canvasLayer===Ne.CanvasImageBottom?e.calculative.canvas.canvasImageBottom.init():e.canvasLayer===Ne.CanvasImage&&e.calculative.canvas.canvasImage.init();else if(U2(a[r],r,e)){e.prevFrame[r]==null&&(r==="globalAlpha"?e.prevFrame[r]=1:e.prevFrame[r]=0);var h=e.prevFrame[r]+(a[r]-e.prevFrame[r])*t;e.calculative[r]=Math.round(h*100)/100}else{r==="visible"&&e.calculative.image&&(e.canvasLayer===Ne.CanvasImageBottom?e.calculative.canvas.canvasImageBottom.init():e.canvasLayer===Ne.CanvasImage&&e.calculative.canvas.canvasImage.init()),e.calculative[r]=a[r];var l={};l[r]=a[r],su(e,l)}r==="text"&&Nn(e)}}}function U2(e,t,i){var a=["strokeType","bkType","showChild"];return typeof e=="number"&&i.linear!==!1&&!a.includes(t)}function W2(e,t){if(e.calculative.start===0)return e.calculative.start=void 0,0;if(e.animateCycle||(e.animateCycle=1/0),e.animateSpan||(e.animateSpan=1),e.calculative.animatePos+=e.animateSpan*(e.calculative.canvas.store.data.scale||1),!e.calculative.start)e.calculative.start=Date.now(),e.calculative.animatePos=e.animateSpan*(e.calculative.canvas.store.data.scale||1),e.calculative.cycleIndex=1;else if(e.calculative.animatePos>e.length){if(++e.calculative.cycleIndex,e.calculative.cycleIndex>e.animateCycle)return e.currentAnimation=void 0,e.calculative.start=void 0,0;e.calculative.animatePos=e.animateSpan}return!0}function La(e,t){if(t===void 0&&(t=!0),!!e.children){var i=e.calculative.canvas.store;e.children.forEach(function(a){var r=i.pens[a];r&&(r.calculative.active=t,La(r,t))})}}function yn(e,t){if(t===void 0&&(t=!0),!!e){var i=e.calculative.canvas.store;e.calculative.hover=t,e.children&&e.children.forEach(function(a){var r,n;((r=i.pens[a])===null||r===void 0?void 0:r.hoverColor)==null&&((n=i.pens[a])===null||n===void 0?void 0:n.hoverBackground)==null&&yn(i.pens[a],t)})}}function Ai(e,t){if(!!t){var i=e.calculative.canvas.store,a=e.calculative.worldRect;t.style.opacity=e.globalAlpha+"",t.style.position="absolute",t.style.outline="none",t.style.left=a.x+i.data.x+"px",t.style.top=a.y+i.data.y+"px",t.style.width=a.width+"px",t.style.height=a.height+"px",t.style.display=e.calculative.inView!=!1?e.calculative.cssDisplay||"inline":"none",!e.calculative.rotate&&(e.calculative.rotate=0),t.style.transform="rotate("+e.calculative.rotate+"deg)",e.calculative.rotate||(e.calculative.flipX&&(t.style.transform="rotateY(180deg)"),e.calculative.flipY&&(t.style.transform="rotateX(180deg)"),e.calculative.flipX&&e.calculative.flipY&&(t.style.transform="rotateZ(180deg)")),t.style.zIndex=e.calculative.zIndex!==void 0?e.calculative.zIndex+"":"5",e.calculative.zIndex>e.calculative.canvas.maxZindex&&(e.calculative.canvas.maxZindex=e.calculative.zIndex),e.locked===ze.DisableEdit||e.locked===ze.DisableMove||i.data.locked?(t.style.userSelect="initial",t.style.pointerEvents="initial",e.name==="gif"&&(t.style.userSelect="none",t.style.pointerEvents="none")):(t.style.userSelect="none",t.style.pointerEvents="none")}}function Zl(e){return e.every(function(t){return t.locked})}function hd(e){return e.every(function(t){return t.disableRotate})}function hg(e,t,i){var a;e.type?(e.calculative.worldAnchors.forEach(function(r){Ge(r,t,i.center)}),q2(e),Yo(e)):(e.calculative.rotate?e.calculative.rotate+=t:e.calculative.rotate=t,Ge(e.calculative.worldRect.center,t,i.center),e.parentId&&(e.calculative.worldRect.x=e.calculative.worldRect.center.x-e.calculative.worldRect.width/2,e.calculative.worldRect.y=e.calculative.worldRect.center.y-e.calculative.worldRect.height/2,e.x=(e.calculative.worldRect.x-i.x)/i.width,e.y=(e.calculative.worldRect.y-i.y)/i.height)),(a=e.children)===null||a===void 0||a.forEach(function(r){var n=e.calculative.canvas.store.pens[r];hg(n,t,i)})}function q2(e){var t;if(!!(!((t=e.calculative.worldAnchors)===null||t===void 0)&&t.length)&&!(!isFinite(e.x)||!isFinite(e.x))&&!(e.x==null||e.y==null)){var i=Hc(e);e.parentId||Object.assign(e,i);var a=e.calculative.canvas.store.options,r=a.fontSize,n=a.lineHeight;e.fontSize||(e.fontSize=r,e.calculative.fontSize=e.fontSize*e.calculative.canvas.store.data.scale),e.lineHeight||(e.lineHeight=n,e.calculative.lineHeight=e.lineHeight),tt(i),e.calculative.worldRect=i,nu(e,i),Ni(e),e.calculative.worldAnchors&&(e.anchors=e.calculative.worldAnchors.map(function(o){return xn(o,e.calculative.worldRect)}))}}function fd(e){return e.every(function(t){return t.disableSize})}function Ql(e,t,i){if(!e.frames||!t)return 0;for(var a=0,r=0;r=e.length&&(e=void 0),{value:e&&e[a++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},Bc=globalThis&&globalThis.__read||function(e,t){var i=typeof Symbol=="function"&&e[Symbol.iterator];if(!i)return e;var a=i.call(e),r,n=[],o;try{for(;(t===void 0||t-- >0)&&!(r=a.next()).done;)n.push(r.value)}catch(s){o={error:s}}finally{try{r&&!r.done&&(i=a.return)&&i.call(a)}finally{if(o)throw o.error}}return n},Go=globalThis&&globalThis.__spreadArray||function(e,t,i){if(i||arguments.length===2)for(var a=0,r=t.length,n;a0&&x0&&_=e.length&&(e=void 0),{value:e&&e[a++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};function vd(e){var t,i;if(e.id=Me(),Array.isArray(e.anchors))try{for(var a=$2(e.anchors),r=a.next();!r.done;r=a.next()){var n=r.value;e.type&&(n.id=Me()),n.penId=e.id,n.prev&&(e.type&&(n.prev.id=Me()),n.prev.penId=e.id),n.next&&(e.type&&(n.next.id=Me()),n.next.penId=e.id)}}catch(o){t={error:o}}finally{try{r&&!r.done&&(i=a.return)&&i.call(a)}finally{if(t)throw t.error}}}var gd=globalThis&&globalThis.__read||function(e,t){var i=typeof Symbol=="function"&&e[Symbol.iterator];if(!i)return e;var a=i.call(e),r,n=[],o;try{for(;(t===void 0||t-- >0)&&!(r=a.next()).done;)n.push(r.value)}catch(s){o={error:s}}finally{try{r&&!r.done&&(i=a.return)&&i.call(a)}finally{if(o)throw o.error}}return n},yd=globalThis&&globalThis.__spreadArray||function(e,t,i){if(i||arguments.length===2)for(var a=0,r=t.length,n;a=e.length&&(e=void 0),{value:e&&e[a++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},Z2=globalThis&&globalThis.__read||function(e,t){var i=typeof Symbol=="function"&&e[Symbol.iterator];if(!i)return e;var a=i.call(e),r,n=[],o;try{for(;(t===void 0||t-- >0)&&!(r=a.next()).done;)n.push(r.value)}catch(s){o={error:s}}finally{try{r&&!r.done&&(i=a.return)&&i.call(a)}finally{if(o)throw o.error}}return n},Q2=globalThis&&globalThis.__spreadArray||function(e,t,i){if(i||arguments.length===2)for(var a=0,r=t.length,n;at.x&&e.xt.y&&e.y=a-i&&e.x<=n+i&&e.y>=r-i&&e.y<=o+i}function tt(e){e.center||(e.center={}),e.center.x=e.x+e.width/2,e.center.y=e.y+e.height/2}function ot(e){e.ex=e.x+e.width,e.ey=e.y+e.height}function J2(e,t){var i,a;if(t.length<3)return!1;var r=!1,n=t[t.length-1];try{for(var o=gg(t),s=o.next();!s.done;s=o.next()){var h=s.value;n.y>e.y!=h.y>e.y&&h.x+(e.y-h.y)*(n.x-h.x)/(n.y-h.y)>e.x&&(r=!r),n=h}}catch(l){i={error:l}}finally{try{s&&!s.done&&(a=o.return)&&a.call(o)}finally{if(i)throw i.error}}return r}function Hi(e){var t=[];e.forEach(function(a){if(!a.isRuleLine){var r=a.calculative.worldRect;if(r){var n=sr(r);t.push.apply(t,Q2([],Z2(n),!1))}}});var i=Fn(t);return tt(i),i}function sr(e){var t=[{x:e.x,y:e.y},{x:e.ex,y:e.y},{x:e.ex,y:e.ey},{x:e.x,y:e.ey}];return e.rotate&&(e.center||tt(e),t.forEach(function(i){Ge(i,e.rotate,e.center)})),t}function Fn(e){var t=1/0,i=1/0,a=-1/0,r=-1/0;return e==null||e.forEach(function(n){!isFinite(n.x)||!isFinite(n.y)||(t=Math.min(t,n.x),i=Math.min(i,n.y),a=Math.max(a,n.x),r=Math.max(r,n.y))}),{x:t,y:i,ex:a,ey:r,width:a-t,height:r-i}}function fs(e,t,i){return e.rotate&&(e=Fn(sr(e))),i?e.x>t.x&&e.ext.y&&e.eyt.ex||e.ext.ey)}function eE(e,t){return(t.x>e.ex||t.exe.ey||t.eye.y!=h>e.y&&e.x<(s-n)*(e.y-o)/(h-o)+n;l&&(i=!i)}return i}var nE=globalThis&&globalThis.__read||function(e,t){var i=typeof Symbol=="function"&&e[Symbol.iterator];if(!i)return e;var a=i.call(e),r,n=[],o;try{for(;(t===void 0||t-- >0)&&!(r=a.next()).done;)n.push(r.value)}catch(s){o={error:s}}finally{try{r&&!r.done&&(i=a.return)&&i.call(a)}finally{if(o)throw o.error}}return n},oE=globalThis&&globalThis.__spreadArray||function(e,t,i){if(i||arguments.length===2)for(var a=0,r=t.length,n;a=e.length&&(e=void 0),{value:e&&e[a++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},lE=/^[\t\n\f\r ]*([MLHVZCSQTAmlhvzcsqta])[\t\n\f\r ]*/,pd=/^[01]/,Ze=/^[+-]?(([0-9]*\.[0-9]+)|([0-9]+\.)|([0-9]+))([eE][+-]?[0-9]+)?/,cE=/^(([\t\n\f\r ]+,?[\t\n\f\r ]*)|(,[\t\n\f\r ]*))/,uE={M:[Ze,Ze],L:[Ze,Ze],H:[Ze],V:[Ze],Z:[],C:[Ze,Ze,Ze,Ze,Ze,Ze],S:[Ze,Ze,Ze,Ze],Q:[Ze,Ze,Ze,Ze],T:[Ze,Ze],A:[Ze,Ze,Ze,pd,pd,Ze,Ze]};function hE(e){for(var t=0,i=[];ta&&(a=o)):(or&&(r=o))})}),--t,--i,{x:t,y:i,ex:a,ey:r,width:a-t+1,height:r-i+1}}function fE(e,t,i){i==null&&(i=t),e.commands.forEach(function(a,r){if(!(a.relative&&r))switch(a.key){case"A":case"a":a.values[5]+=t,a.values[6]+=i;break;case"V":case"v":a.values[0]+=i;break;default:a.values.forEach(function(n,o){a.values[o]=n+(o%2===0?t:i)});break}})}function dE(e,t,i){i==null&&(i=t),e.commands.forEach(function(a){switch(a.key){case"A":case"a":var r=a.values[0],n=a.values[1],o=Math.PI*a.values[2]/180,s=Math.cos(o),h=Math.sin(o),l=n*n*i*i*s*s+r*r*i*i*h*h,c=2*t*i*s*h*(n*n-r*r),f=r*r*t*t*s*s+n*n*t*t*h*h,v=-(r*r*n*n*t*t*i*i),g=c*c-4*l*f,y=Math.sqrt((l-f)*(l-f)+c*c);a.values[2]=c!==0?Math.atan((f-l-y)/c)*180/Math.PI:l=0?a.values[4]:1-a.values[4];break;case"V":case"v":a.values[0]*=i;break;default:a.values.forEach(function(p,m){a.values[m]=p*(m%2===0?t:i)});break}})}function vE(e){var t="";return e.commands.forEach(function(i){t+=i.key+" ",i.values.forEach(function(a){t+=a+" "})}),t}function gE(e,t,i){for(var a,r,n=uE[e.toUpperCase()],o=[];i<=t.length;){var s={key:e,values:[]};try{for(var h=(a=void 0,sE(n)),l=h.next();!l.done;l=h.next()){var c=l.value,f=t.slice(i).match(c);if(f!==null){s.values.push(+f[0]),i+=f[0].length;var v=t.slice(i).match(cE);v!==null&&(i+=v[0].length)}else{if(s.values.length===0)return{cursor:i,commands:o};throw new Error("malformed path (first error at "+i+")")}}}catch(g){a={error:g}}finally{try{l&&!l.done&&(r=h.return)&&r.call(h)}finally{if(a)throw a.error}}if(s.relative=s.key.toUpperCase()!==s.key,o.push(s),n.length===0)return{cursor:i,commands:o};e==="m"&&(e="l"),e==="M"&&(e="L")}throw new Error("malformed path (first error at "+i+")")}function yE(e,t){for(var i=[],a=e.relative&&t?{x:t.worldPoints[t.worldPoints.length-2],y:t.worldPoints[t.worldPoints.length-1]}:{x:0,y:0},r=0;r0)&&!(r=a.next()).done;)n.push(r.value)}catch(s){o={error:s}}finally{try{r&&!r.done&&(i=a.return)&&i.call(a)}finally{if(o)throw o.error}}return n},CE=globalThis&&globalThis.__spreadArray||function(e,t,i){if(i||arguments.length===2)for(var a=0,r=t.length,n;an?n:r,h=o.x,l=o.y,c=l-s/2,f=l-s/4,v=-(f-l)*Math.sin(Math.PI/180*324)+h,g=(f-l)*Math.cos(Math.PI/180*324)+l;i.moveTo(v,g);for(var y=0;y<5;++y)i.lineTo(-(c-l)*Math.sin(Math.PI/180*72*y)+h,(c-l)*Math.cos(Math.PI/180*72*y)+l),i.lineTo((v-h)*Math.cos(Math.PI/180*72*(y+1))-(g-l)*Math.sin(Math.PI/180*72*(y+1))+h,(v-h)*Math.sin(Math.PI/180*72*(y+1))+(g-l)*Math.cos(Math.PI/180*72*(y+1))+l);if(i.closePath(),i instanceof Path2D)return i}function yg(e){for(var t=e.width,i=e.height,a=t>i?i:t,r=[],n=0;n<5;++n)r.push({flag:1,id:String(n),penId:e.id,x:.5+a/2*Math.sin(Math.PI/180*72*n)/t,y:-a/2*Math.cos(Math.PI/180*72*n)/i+.5});e.anchors=r}function SE(e){var t,i=e.anchors.filter(function(a){return a.flag!==1});yg(e),e.anchors=(t=e.anchors).concat.apply(t,CE([],kE(i),!1))}function TE(e,t){var i=t||new Path2D,a=e.calculative.worldRect,r=a.x,n=a.y,o=a.width,s=a.height;if(i.moveTo(r+o/4,n),i.lineTo(r+o*3/4,n),i.lineTo(r+o,n+s/2),i.lineTo(r+o*3/4,n+s),i.lineTo(r+o*1/4,n+s),i.lineTo(r,n+s/2),i.lineTo(r+o/4,n),i.closePath(),i instanceof Path2D)return i}function RE(e,t){var i=t||new Path2D,a=e.calculative.worldRect,r=a.x,n=a.y,o=a.width,s=a.height;if(i.moveTo(r,n+s/2),i.lineTo(r+s/2,n),i.lineTo(r+s/2,n+s/3),i.lineTo(r+o,n+s/3),i.lineTo(r+o,n+s*2/3),i.lineTo(r+s/2,n+s*2/3),i.lineTo(r+s/2,n+s*2/3),i.lineTo(r+s/2,n+s),i.closePath(),i instanceof Path2D)return i}function PE(e,t){var i=t||new Path2D,a=e.calculative.worldRect,r=a.x,n=a.y,o=a.width,s=a.height;if(i.moveTo(r,n+s/3),i.lineTo(r+(o-s/2),n+s/3),i.lineTo(r+(o-s/2),n),i.lineTo(r+o,n+s/2),i.lineTo(r+(o-s/2),n+s),i.lineTo(r+(o-s/2),n+s*2/3),i.lineTo(r,n+s*2/3),i.closePath(),i instanceof Path2D)return i}function IE(e,t){var i=t||new Path2D,a=e.calculative.worldRect,r=a.x,n=a.y,o=a.width,s=a.height;if(i.moveTo(r,n+s/2),i.lineTo(r+s/2,n),i.lineTo(r+s/2,n+s/3),i.lineTo(r+(o-s/2),n+s/3),i.lineTo(r+(o-s/2),n),i.lineTo(r+o,n+s/2),i.lineTo(r+(o-s/2),n+s),i.lineTo(r+(o-s/2),n+s*2/3),i.lineTo(r+s/2,n+s*2/3),i.lineTo(r+s/2,n+s),i.closePath(),i instanceof Path2D)return i}function LE(e,t){var i=t||new Path2D,a=e.calculative.worldRect,r=a.x,n=a.y,o=a.width,s=a.height,h=a.ey;if(i.moveTo(r,n),i.lineTo(r+o,n),i.lineTo(r+o,n+s*3/4),i.lineTo(r+o*8/16,n+s*3/4),i.lineTo(r+o/4,h),i.lineTo(r+o*5/16,n+s*3/4),i.lineTo(r,n+s*3/4),i.closePath(),i instanceof Path2D)return i}function DE(e,t){var i=t||new Path2D,a=e.calculative.worldRect,r=a.x,n=a.y,o=a.width,s=a.height;if(i.moveTo(r+o/5,n+s*13/16),i.bezierCurveTo(r-o/15,n+s*13/16,r-o/15,n+s*7/16,r+o/5,n+s*7/16),i.bezierCurveTo(r+o/5,n,r+o*4/5,n,r+o*4/5,n+s*7/16),i.bezierCurveTo(r+o*16/15,n+s*7/16,r+o*16/15,n+s*13/16,r+o*4/5,n+s*13/16),i.closePath(),i instanceof Path2D)return i}function ME(e,t){var i=t||new Path2D,a=e.calculative.worldRect,r=a.x,n=a.y,o=a.width,s=a.ex,h=a.ey,l=o/6;if(i.moveTo(r,n),i.lineTo(s-l,n),i.lineTo(s,n+l),i.lineTo(s,h),i.lineTo(r,h),i.closePath(),i.moveTo(s-l,n),i.lineTo(s-l,n+l),i.lineTo(s,n+l),i.closePath(),i instanceof Path2D)return i}function BE(e,t){var i=t.calculative.worldRect,a=i.x,r=i.y,n=i.width,o=i.ex,s=i.ey,h=n*.25,l=t.z;l>1?h=l:l>0&&(h=n*l);var c={x:a,y:r+h},f={x:o-h,y:r+h},v={x:o-h,y:s},g={x:a,y:s};Jl(e,[c,f,v,g],t.backgroundFront||t.background,t.color),Jl(e,[c,{x:a+h,y:r},{x:o,y:r},f],t.backgroundUp||t.background,t.color),Jl(e,[f,{x:o,y:r},{x:o,y:s-h},v],t.backgroundRight||t.background,t.color)}function Jl(e,t,i,a){i===void 0&&(i=""),a===void 0&&(a=""),e.save(),i&&(e.fillStyle=i),a&&(e.strokeStyle=a),e.beginPath();for(var r=0;ra.x?s=Pe.Right:s=Pe.Left),a.next={id:Me(),penId:t.id,x:a.x,y:a.y,prevNextType:2},r.prev={id:Me(),penId:t.id,x:r.x,y:r.y,prevNextType:2},s){case Pe.Up:a.next.y-=n,r.prev.y=a.y;break;case Pe.Bottom:a.next.y+=n,r.prev.y=a.y;break;case Pe.Left:a.next.x-=n,r.prev.x=a.x;break;default:a.next.x+=n,r.prev.x=a.x;break}}}}var _d=globalThis&&globalThis.__read||function(e,t){var i=typeof Symbol=="function"&&e[Symbol.iterator];if(!i)return e;var a=i.call(e),r,n=[],o;try{for(;(t===void 0||t-- >0)&&!(r=a.next()).done;)n.push(r.value)}catch(s){o={error:s}}finally{try{r&&!r.done&&(i=a.return)&&i.call(a)}finally{if(o)throw o.error}}return n},xd=globalThis&&globalThis.__spreadArray||function(e,t,i){if(i||arguments.length===2)for(var a=0,r=t.length,n;a=e.length&&(e=void 0),{value:e&&e[a++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};function HE(e,t){var i=t||new Path2D;if((e.lineName==="line"||e.lineName==="polyline")&&e.calculative.lineSmooth){var a=au(e);if(i.addPath(a),i instanceof Path2D)return i}var r=e.calculative.worldAnchors;if(r.length>1){var n;r.forEach(function(o){n?Ed(i,n,o):o.start=!0,n=o}),e.close&&Ed(i,n,r[0])}if(i instanceof Path2D)return i}function UE(e,t,i){var a;if(t.calculative.worldAnchors||(t.calculative.worldAnchors=[]),!(t.calculative.worldAnchors.length<2||((a=t.anchors)===null||a===void 0?void 0:a.length)>1)){var r=lt(t),n=We(t);!r||!n||!n.id||r===n||(r.next=void 0,ou(t),n.prev=void 0,t.calculative.worldAnchors.push(n))}}function Ed(e,t,i){!i||i.isTemp||(t.start&&e.moveTo(t.x,t.y),t.next?i.prev?e.bezierCurveTo(t.next.x,t.next.y,i.prev.x,i.prev.y,i.x,i.y):e.quadraticCurveTo(t.next.x,t.next.y,i.x,i.y):i.prev?e.quadraticCurveTo(i.prev.x,i.prev.y,i.x,i.y):e.lineTo(i.x,i.y))}function Hc(e){return Uc(e),Fn(wg(e))}function wg(e){var t=[],i;return e.calculative.worldAnchors.forEach(function(a){t.push(a),i&&t.push.apply(t,xd([],_d(kd(i,a,e)),!1)),i=a}),e.close&&e.calculative.worldAnchors.length>1&&t.push.apply(t,xd([],_d(kd(i,e.calculative.worldAnchors[0],e)),!1)),t}function vs(e){return e!=null&&e.lineWidth?e.lineWidth/2+4:4}function kd(e,t,i){var a=[];if(!t)return a;var r=.02;if(e.lineLength){var n=vs(i);r=n/e.lineLength}if(e.next)if(t.prev)for(var o=r;o<1;o+=r)a.push(mg(o,e,e.next,t.prev,t));else for(var o=r;o<1;o+=r)a.push(zc(o,e,e.next,t));else if(t.prev)for(var o=r;o<1;o+=r)a.push(zc(o,e,t.prev,t));else a.push({x:t.x,y:t.y});return a.length>1&&(e.curvePoints=a),a}function WE(e,t){var i,a,r=vs(t),n=0,o,s;try{for(var h=pg(t.calculative.worldAnchors),l=h.next();!l.done;l=h.next()){var c=l.value;if(o){if(s=Cd(e,o,c,r),s)return{i:n,point:s};++n}o=c}}catch(f){i={error:f}}finally{try{l&&!l.done&&(a=h.return)&&a.call(h)}finally{if(i)throw i.error}}if(t.close&&t.calculative.worldAnchors.length>1&&(s=Cd(e,o,t.calculative.worldAnchors[0],r)))return{i:n,point:s}}function Cd(e,t,i,a){var r,n;if(a===void 0&&(a=4),!t.next&&!i.prev){var o=t.x,s=t.y,h=i.x,l=i.y,c=Math.min(o,h),f=Math.max(o,h),v=Math.min(s,l),g=Math.max(s,l);return e.x>=c-a&&e.x<=f+a&&e.y>=v-a&&e.y<=g+a?qE(e,t,i,a):void 0}else if(t.curvePoints)try{for(var y=pg(t.curvePoints),p=y.next();!p.done;p=y.next()){var m=p.value;if(Ia(e,m,a))return m}}catch(b){r={error:b}}finally{try{p&&!p.done&&(n=y.return)&&n.call(y)}finally{if(r)throw r.error}}}function qE(e,t,i,a){if(a===void 0&&(a=4),t.x===i.x){var r=Math.abs(e.x-t.x);if(r<=a)return{x:t.x,y:e.y}}else{var n=(t.y-i.y)/(t.x-i.x),o=t.y-n*t.x,r=Math.abs((n*e.x+o-e.y)/Math.sqrt(n*n+1));if(r<=a){var s=e.x+n*e.y,h=(s-n*o)/(n*n+1);return{x:h,y:n*h+o}}}}function Ad(e,t,i,a){if(!t&&!i)return Math.sqrt(Math.pow(Math.abs(e.x-a.x),2)+Math.pow(Math.abs(e.y-a.y),2))||0;var r=document.createElementNS("http://www.w3.org/2000/svg","path");return t&&i?r.setAttribute("d","M"+e.x+" "+e.y+" C"+t.x+" "+t.y+" "+i.x+" "+i.y+" "+a.x+" "+a.y):t?r.setAttribute("d","M"+e.x+" "+e.y+" Q"+t.x+" "+t.y+" "+a.x+" "+a.y):r.setAttribute("d","M"+e.x+" "+e.y+" Q"+i.x+" "+i.y+" "+a.x+" "+a.y),r.getTotalLength()||0}function Uc(e){if(e.calculative.worldAnchors.length<2)return 0;var t=0,i;if(e.calculative.worldAnchors.forEach(function(r){i&&(i.lineLength=Ad(i,i.next,r.prev,r),t+=i.lineLength),i=r}),e.close){var a=lt(e);i.lineLength=Ad(i,i.next,a.prev,a),t+=i.lineLength}return e.calculative.animatePos&&(e.calculative.animatePos=t/e.length*e.calculative.animatePos),e.length=t,t}function jE(e,t){for(var i=e.calculative.worldAnchors,a=0;a=0&&f*l+v*c+g<=0||f*s+v*h+g<=0&&f*l+v*c+g>=0||f*s+v*c+g>=0&&f*l+v*h+g<=0||f*s+v*c+g<=0&&f*l+v*h+g>=0){if(s>l){var y=s;s=l,l=y}if(hl&&n>l||r>h&&o>h||r0)&&!(r=a.next()).done;)n.push(r.value)}catch(s){o={error:s}}finally{try{r&&!r.done&&(i=a.return)&&i.call(a)}finally{if(o)throw o.error}}return n},dn=globalThis&&globalThis.__spreadArray||function(e,t,i){if(i||arguments.length===2)for(var a=0,r=t.length,n;ay.y&&r.yy.y))){p=g;var m=Vt;r.xe.y)r=e.x+(t.x-e.x)/2,a.push({x:r,y:e.y},{x:r,y:t.y});else{var o=(e.y+t.y)/2;a.push({x:e.x,y:o},{x:t.x,y:o})}break;case Pe.Right:r=t.x,n=e.y,t.xe.x&&t.ye.y-Vt)r=e.x+(t.x-e.x)/2,a.push({x:r,y:e.y},{x:r,y:t.y});else{var o=(e.y+t.y+Vt)/2;a.push({x:e.x,y:o},{x:t.x,y:o})}break}return a}function YE(e,t,i){if(e.x===t.x||e.y===t.y)return[];var a=[],r,n;switch(i){case Pe.Up:r=e.x,n=t.y,t.x>e.x&&t.y>e.y&&(r=t.x,n=e.y),a.push({x:r,y:n});break;case Pe.Bottom:r=e.x,n=t.y,t.x>e.x&&t.ye.y&&(r=e.x,n=t.y),a.push({x:r,y:n});break;case Pe.Bottom:e.y>t.y?(r=t.x,n=e.y):(r=e.x,n=t.y),a.push({x:r,y:n});break;case Pe.Left:r=t.x,n=e.y,t.x>e.x&&t.y>e.y&&(r=e.x,n=t.y),a.push({x:r,y:n});break;default:if(r=e.x,t.ye.y&&(r=t.x,n=e.y),a.push({x:r,y:n});break;case Pe.Bottom:r=e.x,n=t.y,t.xe.x)r=t.x,n=e.y+(t.y-e.y)/2,a.push({x:e.x,y:n},{x:t.x,y:n});else{var o=(e.x+t.x)/2;a.push({x:o,y:e.y},{x:o,y:t.y})}break;case Pe.Left:t.x>e.x?a.push({x:e.x,y:t.y}):a.push({x:t.x,y:e.y});break;default:if(r=e.x,n=t.y,t.xMath.abs(i.y-t.y));var r=e.calculative.worldAnchors.findIndex(function(o){return o.id==t.id});if(r>1){var n=e.calculative.worldAnchors[r-1];if(n.x===t.x&&n.y!==t.y)return a.push({x:i.x,y:t.y}),a;if(n.y===t.y&&n.x!==t.x)return a.push({x:t.x,y:i.y}),a}return e.calculative.worldAnchors.length&&(i.isTemp=void 0,e.calculative.drawlineH?(a.push({x:i.x,y:t.y}),Math.abs(i.y-t.y)-1;c--)if(o=e.anchors[c],l==null&&(l=o.y===h.y),l===!0)if(o.y===h.y)e.calculative.worldAnchors[c].y=i.y;else break;else if(o.x===h.x)e.calculative.worldAnchors[c].x=i.x;else break;l=void 0;for(var c=a+1;c-1;c--)if(o=e.anchors[c],l==null&&(l=o.x===h.x),l===!0)if(o.x===h.x)e.calculative.worldAnchors[c].x=i.x;else break;else if(o.y===h.y)e.calculative.worldAnchors[c].y=i.y;else break;l=void 0;for(var c=a+1;c0)&&!(r=a.next()).done;)n.push(r.value)}catch(s){o={error:s}}finally{try{r&&!r.done&&(i=a.return)&&i.call(a)}finally{if(o)throw o.error}}return n},Rd=globalThis&&globalThis.__spreadArray||function(e,t,i){if(i||arguments.length===2)for(var a=0,r=t.length,n;a1?(l=p.x-y.x,c=p.y-y.y):m>0?(l=p.x-(s+f*m),c=p.y-(h+v*m)):(l=p.x-s,c=p.y-h)):(l=p.x-s,c=p.y-h),b=l*l+c*c,b>n&&(o=_,n=b);return n>t&&(o-i>1&&r.push.apply(r,Rd([],Td(Wc(e,t,i,o)),!1)),r.push({id:e[o].id,penId:e[o].penId,x:e[o].x,y:e[o].y}),a-o>1&&r.push.apply(r,Rd([],Td(Wc(e,t,o,a)),!1))),r}function JE(e,t,i){if(t===void 0&&(t=.8),i===void 0&&(i=!1),e.length<3)return e;var a,r,n,o,s,h,l,c,f,v,g,y,p,m,b,x=function(I,P,M,L){return o=Math.sqrt(I*I+P*P),o>0?(y=I/o,m=P/o):(y=1,m=0),s=Math.sqrt(M*M+L*L),s>0?(p=M/s,b=L/s):(p=1,b=0),Math.acos(y*p+m*b)};v=[],g=e.length,a=e[0],e[g-1],v.push(Vr({},e[0]));for(var _=0;_1)for(var c=void 0,f=0,v=0;vo)&&m>h+o&&b-m>h&&(e.lineAnimateType===ai.Arrow?tk(i,p,n,y,l,o):e.lineAnimateType===ai.WaterDrop&&ik(i,p,e.animateReverse,y,l,o)),p.x+=s*Math.cos(y*Math.PI/180),p.y-=s*Math.sin(y*Math.PI/180),m=Math.sqrt(Math.pow(p.x-c.x,2)+Math.pow(p.y-c.y,2))}c=g}if(i instanceof Path2D)return i}function ek(e,t){var i=t.x-e.x,a=t.y-e.y,r=Math.atan(a/i)*180/Math.PI;return t.x>=e.x?r=-r:r=180-r,r}function kr(e,t,i){var a=(180-i)*Math.PI/180;return{x:(e.x-t.x)*Math.cos(a)-(e.y-t.y)*Math.sin(a)+t.x,y:(e.x-t.x)*Math.sin(a)+(e.y-t.y)*Math.cos(a)+t.y}}function tk(e,t,i,a,r,n){var o=kr({x:t.x+i,y:t.y+.57*i},{x:t.x,y:t.y},a),s=kr({x:t.x+i,y:t.y-.57*i},{x:t.x,y:t.y},a),h=kr({x:t.x+i,y:t.y+r/2},{x:t.x,y:t.y},a),l=kr({x:t.x+n,y:t.y+r/2},{x:t.x,y:t.y},a),c=kr({x:t.x+i,y:t.y-r/2},{x:t.x,y:t.y},a),f=kr({x:t.x+n,y:t.y-r/2},{x:t.x,y:t.y},a);e.moveTo(o.x,o.y),e.lineTo(t.x,t.y),e.lineTo(s.x,s.y),e.lineTo(c.x,c.y),e.lineTo(f.x,f.y),e.lineTo(l.x,l.y),e.lineTo(h.x,h.y),e.lineTo(o.x,o.y)}function ik(e,t,i,a,r,n){var o=r/2;i&&(o=-r/2);var s=kr({x:t.x,y:t.y+o},{x:t.x,y:t.y},a),h=kr({x:t.x+n,y:t.y},{x:t.x,y:t.y},a),l=Math.PI/2;i&&(l=-Math.PI/2),e.moveTo(t.x,t.y),e.arc(t.x,t.y,r/2,-l-a/180*Math.PI,l-a/180*Math.PI,!1),e.lineTo(h.x,h.y),e.lineTo(s.x,s.y)}globalThis&&globalThis.__awaiter;globalThis&&globalThis.__generator;function rk(e){var t;e.onDestroy||(e.onDestroy=ak,e.onMove=zo,e.onResize=zo,e.onRotate=zo,e.onValue=zo,e.onMouseMove=ok,e.onBeforeValue=nk,e.onRenderPenRaw=lk),e.calculative.singleton||(e.calculative.singleton={});var i=e.calculative.worldRect;if(!e.calculative.singleton.div){var a=document.createElement("div");a.style.position="absolute",a.style.outline="none",a.style.left="-9999px",a.style.top="-9999px",a.style.width=i.width+"px",a.style.height=i.height+"px",document.body.appendChild(a),(t=e.calculative.canvas.externalElements)===null||t===void 0||t.parentElement.appendChild(a),Ai(e,a),e.calculative.singleton.div=a;var r=document.createElement("iframe");r.style.width="100%",r.style.height="100%",r.scrolling=e.scrolling||"no",r.frameBorder="0",r.src=e.iframe,e.calculative.iframe=e.iframe,a.appendChild(r),Eg(e),r.onload=function(){r.setAttribute("document.domain","")}}return e.calculative.patchFlags&&Ai(e,e.calculative.singleton.div),e.onRenderPenRaw(e),new Path2D}function ak(e){e.calculative.singleton&&e.calculative.singleton.div&&(e.calculative.singleton.div.remove(),delete e.calculative.singleton.div)}function zo(e){e.calculative.singleton.div&&Ai(e,e.calculative.singleton.div)}function nk(e,t){if(t.iframe&&e.calculative.singleton.div&&(e.calculative.singleton.div.children[0].src=t.iframe,e.calculative.iframe=t.iframe),t.operationalRect||t["operationalRect.x"]!==void 0||t["operationalRect.y"]!==void 0||t["operationalRect.width"]!==void 0||t["operationalRect.height"]!==void 0){e.operationalRect||(e.operationalRect={});var i=ce(t);if(i.operationalRect||(i.operationalRect={}),i["operationalRect.x"]!==void 0&&(i.operationalRect.x=i["operationalRect.x"]),i["operationalRect.y"]!==void 0&&(i.operationalRect.y=i["operationalRect.y"]),i["operationalRect.width"]!==void 0&&(i.operationalRect.width=i["operationalRect.width"]),i["operationalRect.height"]!==void 0&&(i.operationalRect.height=i["operationalRect.height"]),Object.assign(e.operationalRect,i.operationalRect),e.calculative.singleton.div){var a=e.calculative.singleton.div.children.length;a===1?Eg(e):(e.calculative.singleton.div.children[1].style.height=e.operationalRect.y*100+"%",e.calculative.singleton.div.children[1].style.left=e.operationalRect.x*100+"%",e.calculative.singleton.div.children[1].style.width=e.operationalRect.width*100+"%",e.calculative.singleton.div.children[2].style.width=(1-e.operationalRect.x-e.operationalRect.width)*100+"%",e.calculative.singleton.div.children[3].style.height=(1-e.operationalRect.y-e.operationalRect.height)*100+"%",e.calculative.singleton.div.children[3].style.left=e.operationalRect.x*100+"%",e.calculative.singleton.div.children[3].style.width=e.operationalRect.width*100+"%",e.calculative.singleton.div.children[4].style.width=e.operationalRect.x*100+"%")}}if(t.blur!==void 0)for(var r=1;r<5;r++)e.calculative.singleton.div.children[r].style["backdrop-filter"]="blur("+(t.blur||2)+"px)";if(t.blurBackground!==void 0)for(var r=1;r<5;r++)e.calculative.singleton.div.children[r].style.backgroundColor=t.blurBackground;return t}function ok(e,t){if(!(!e.calculative.canvas.store.data.locked&&!e.locked)&&xg(e.operationalRect)&&e.calculative.zIndex<5&&t.x>e.x+e.width*e.operationalRect.x&&t.xe.y+e.height*e.operationalRect.y&&t.y',''];function ck(e){var t;if(e.onDestroy||(e.onDestroy=uk,e.onMove=ec,e.onResize=ec,e.onRotate=ec,e.onClick=Pd,e.onValue=fk,e.onChangeId=hk),$t[e.id])e.video&&e.calculative.media&&e.video!==e.calculative.video?(console.warn("video \u66F4\u6539, \u6B64\u5904\u662F\u5426\u6267\u884C\uFF1F"),e.calculative.media.src=e.video,e.autoPlay&&(e.calculative.media.muted=!0,e.calculative.media.autoplay=!0),e.calculative.media.loop=e.playLoop,e.calculative.video=e.video):e.audio&&e.calculative.media&&e.audio!==e.calculative.audio&&(e.calculative.media.src=e.audio,e.autoPlay&&(e.calculative.media.muted=!0,e.calculative.media.autoplay=!0),e.calculative.media.loop=e.playLoop,e.calculative.audio=e.audio);else{var i=document.createElement("div"),a=document.createElement("div");a.style.position="absolute",a.style.outline="none",a.style.left="0",a.style.bottom="0",a.style.width="0",a.style.height="2px",a.style.background="#52c41a",a.style.zIndex="1",e.hideProgress&&(a.style.display="none");var r=document.createElement("div");r.innerHTML=Zo[1],r.style.position="absolute",r.style.right="0",r.style.bottom="0",r.style.width="20px",r.style.height="20px",r.style.fill="hsla(0, 0%, 100%, .8)",r.style.zIndex="1",r.style.display="none",i.appendChild(a),i.appendChild(r),r.onclick=function(o){o.stopPropagation(),e.calculative.media.muted?(r.innerHTML=Zo[0],e.calculative.media.muted=!1):(r.innerHTML=Zo[1],e.calculative.media.muted=!0)},e.calculative.singleton||(e.calculative.singleton={}),e.calculative.singleton.muted=r,i.onmouseenter=function(o){r.style.display="block"},i.onmouseleave=function(o){r.style.display="none"},i.onclick=function(o){o.stopPropagation(),Pd(e)};var n;e.video?(n=document.createElement("video"),n.src=e.video):e.audio&&(n=document.createElement("audio"),n.src=e.audio),n.loop=e.playLoop,n.ontimeupdate=function(){kg(a,n,e.calculative.worldRect.width)},n.onended=function(){e.calculative.onended&&e.calculative.onended(e)},e.calculative.media=n,n.style.position="absolute",n.style.outline="none",n.style.left="0",n.style.top="0",n.style.width="100%",n.style.height="100%",i.appendChild(n),$t[e.id]=i,(t=e.calculative.canvas.externalElements)===null||t===void 0||t.parentElement.appendChild(i),Ai(e,i),e.autoPlay&&(n.autoplay=!0,n.muted=!0)}return e.calculative.patchFlags&&Ai(e,$t[e.id]),new Path2D}function uk(e){$t[e.id].onclick=null,$t[e.id].remove(),$t[e.id]=void 0}function ec(e){Ai(e,$t[e.id]);var t=$t[e.id].children[0],i=$t[e.id].children[1];kg(t,i,e.calculative.worldRect.width)}function Pd(e){e.calculative.media&&(e.calculative.media.muted=!1,e.calculative.singleton.muted.innerHTML=Zo[0],e.calculative.media.paused?e.calculative.media.play():e.calculative.media.pause())}function kg(e,t,i){e.style.width=t.currentTime/t.duration*i+"px"}function hk(e,t,i){!$t[t]||($t[i]=$t[t],delete $t[t])}function fk(e){var t=$t[e.id];if(!!t){Ai(e,t);var i=e.calculative.media.getAttribute("src");e.video?i!==e.video&&(e.calculative.media.src=e.video):e.audio&&i!==e.audio&&(e.calculative.media.src=e.audio),e.autoPlay&&(e.calculative.media.muted=!0,e.calculative.media.autoplay=!0),e.calculative.media.loop=e.playLoop}}var vt={};function dk(e){e.onDestroy||(e.onDestroy=vk,e.onMove=Id,e.onResize=gk,e.onRotate=Id,e.onValue=yk,e.onChangeId=mk);var t=new Path2D;if(!!e.image){if(!vt[e.id]){var i=new Image;i.crossOrigin="anonymous",i.src=e.image,e.calculative.canvas.parent.store.options.cdn&&!(e.image.startsWith("http")||e.image.startsWith("//")||e.image.startsWith("data:image"))&&(i.src=e.calculative.canvas.parent.store.options.cdn+e.image),vt[e.id]=i,i.onload=function(){var a;vt[e.id]===i&&(e.calculative.img=i,e.calculative.imgNaturalWidth=i.naturalWidth||e.iconWidth,e.calculative.imgNaturalHeight=i.naturalHeight||e.iconHeight,(a=e.calculative.canvas.externalElements)===null||a===void 0||a.parentElement.appendChild(i),Pn(e,i))}}return e.calculative.patchFlags&&vt[e.id]&&Pn(e,vt[e.id]),t}}function vk(e){vt[e.id]&&(vt[e.id].remove(),vt[e.id]=void 0)}function Id(e){!vt[e.id]||Pn(e,vt[e.id])}function gk(e){!vt[e.id]||Pn(e,vt[e.id])}function yk(e){!vt[e.id]||(Pn(e,vt[e.id]),vt[e.id].getAttribute("src")!==e.image&&(vt[e.id].src=e.image))}function mk(e,t,i){!vt[t]||(vt[i]=vt[t],delete vt[t])}function Pn(e,t){t.style.objectFit=e.imageRatio?"contain":"fill",Ai(e,t)}var pk=globalThis&&globalThis.__read||function(e,t){var i=typeof Symbol=="function"&&e[Symbol.iterator];if(!i)return e;var a=i.call(e),r,n=[],o;try{for(;(t===void 0||t-- >0)&&!(r=a.next()).done;)n.push(r.value)}catch(s){o={error:s}}finally{try{r&&!r.done&&(i=a.return)&&i.call(a)}finally{if(o)throw o.error}}return n},wk=globalThis&&globalThis.__spreadArray||function(e,t,i){if(i||arguments.length===2)for(var a=0,r=t.length,n;ai+r-o&&(c=Uo(i+r-o,c+o,l,o,-1)),t.push({id:String(t.length),flag:1,penId:e.id,x:(l-i)/r,y:(c-a)/n})}for(var f=3,h=0;ha+n-o&&(l=Ho(l-o,a+n-o,c,o)),t.push({id:String(t.length),flag:1,penId:e.id,x:(l-i)/r,y:(c-a)/n})}for(var v=5,h=0;hi+r-o&&(c=Uo(i+r-o,c-o,l,o)),t.push({id:String(t.length),flag:1,penId:e.id,x:(l-i)/r,y:(c-a)/n})}for(var g=3,h=0;ha+n-o&&(l=Ho(l+o,a+n-o,c,o,-1)),t.push({id:String(t.length),flag:1,penId:e.id,x:(l-i)/r,y:(c-a)/n})}e.anchors=t}function xk(e){var t=e.calculative.borderRadius||0,i=e.calculative.borderRadius||0,a=e.width,r=e.height;e.calculative.borderRadius<1&&(t=a*e.calculative.borderRadius,i=r*e.calculative.borderRadius);var n=t0?(this.arrowUp.style.borderBottomColor="transparent",this.arrowDown.style.borderTopColor="#777777"):(s+=r.height+n.height+5,this.arrowUp.style.borderBottomColor="#777777",this.arrowDown.style.borderTopColor="transparent"),this.x=o,this.y=s,this.box.style.left=this.x+"px",this.box.style.top=this.y+"px"},e.prototype.hide=function(){this.currentPen=null,this.x=-9999,this.box.style.left="-9999px"},e.prototype.translate=function(t,i){this.x<-1e3||(this.x+=t,this.y+=i,this.box.style.left=this.x+"px",this.box.style.top=this.y+"px")},e.prototype.destroy=function(){this.box.onmouseleave=null},e}(),Sg=function(){function e(t){var i=this;this.parent=t,this.onMouseDownH=function(o){o.preventDefault(),o.stopPropagation(),i.isDownH=o.x,i.x=i.parent.store.data.x||0,i.lastScrollX=i.scrollX},this.onMouseDownV=function(o){o.preventDefault(),o.stopPropagation(),i.isDownV=o.y,i.y=i.parent.store.data.y||0,i.lastScrollY=i.scrollY},this.onMouseMove=function(o){if(i.isDownH){var s=o.x-i.isDownH;i.scrollX=i.lastScrollX+s,i.h.style.left=i.scrollX+"px",i.parent.store.data.x=i.x-s*i.rect.width/i.parent.parentElement.clientWidth}if(i.isDownV){var h=o.y-i.isDownV;if(i.pageMode&&i.canMouseMove(h))return;i.scrollY=i.lastScrollY+h,i.v.style.top=i.scrollY+"px",i.parent.store.data.y=i.y-h*i.rect.height/i.parent.parentElement.clientHeight}(i.isDownH||i.isDownV)&&(i.parent.onMovePens(),i.parent.canvasTemplate.init(),i.parent.canvasImage.init(),i.parent.canvasImageBottom.init(),i.parent.render())},this.onMouseUp=function(o){!i.isDownH&&!i.isDownV||(i.isDownH=void 0,i.isDownV=void 0,i.scrollX<20?(i.scrollX=20,i.h.style.left=i.scrollX+"px"):i.scrollX>i.parent.parentElement.clientWidth-i.hSize-20&&(i.scrollX=i.parent.parentElement.clientWidth-i.hSize-20,i.h.style.left=i.scrollX+"px"),i.scrollY<20?(i.scrollY=20,i.v.style.top=i.scrollY+"px"):i.scrollY>i.parent.parentElement.clientHeight-i.vSize-20&&(i.scrollY=i.parent.parentElement.clientHeight-i.vSize-20,i.v.style.top=i.scrollY+"px"),i.resize())},this.h=document.createElement("div"),this.v=document.createElement("div"),this.parent.externalElements.appendChild(this.h),this.parent.externalElements.appendChild(this.v),this.h.className="meta2d-scroll h",this.h.onmousedown=this.onMouseDownH,this.v.className="meta2d-scroll v",this.v.onmousedown=this.onMouseDownV,document.addEventListener("mousemove",this.onMouseMove),document.addEventListener("mouseup",this.onMouseUp);for(var a,r=0;r=0||t>0&&i.ey-this.parent.height+this.parent.store.data.y<=0},e.prototype.changeMode=function(){this.pageMode=!0,this.h.style.display="none";var t=this.parent.parent.getRect();t.height0?this.rect.width+=this.parent.store.data.x+(this.rect.x>0?0:this.rect.x):this.rect.width-=this.parent.store.data.x+(this.rect.x>0?0:this.rect.x),this.parent.store.data.y>0?this.rect.height+=this.parent.store.data.y+(this.rect.y>0?0:this.rect.y):this.rect.height-=this.parent.store.data.y+(this.rect.y>0?0:this.rect.y),this.rect.width<1400&&(this.rect.width=1400),this.rect.height<900&&(this.rect.height=900),this.hSize=1e3*this.parent.parentElement.clientWidth/this.rect.width/3,this.vSize=1e3*this.parent.parentElement.clientHeight/this.rect.height/3,this.h.style.width=this.hSize+"px",this.v.style.height=this.vSize+"px"},e.prototype.show=function(){this.isShow=!0,this.h.style.display="block",this.v.style.display="block",document.addEventListener("mousemove",this.onMouseMove),document.addEventListener("mouseup",this.onMouseUp)},e.prototype.hide=function(){this.isShow=!1,this.h.style.display="none",this.v.style.display="none",this.destroy()},e.prototype.translate=function(t,i){t&&(this.scrollX-=t*this.parent.parentElement.clientWidth/this.rect.width,this.h.style.left=this.scrollX+"px"),i&&(this.scrollY-=i*this.parent.parentElement.clientHeight/this.rect.height,this.v.style.top=this.scrollY+"px")},e.prototype.wheel=function(t){var i=10;t&&(i=-10),!(this.pageMode&&this.canMouseMove(i))&&(this.scrollY+=i,this.v.style.top=this.scrollY+"px",this.parent.store.data.y-=i*this.rect.height/this.parent.parentElement.clientHeight,this.parent.onMovePens(),this.parent.canvasTemplate.init(),this.parent.canvasImage.init(),this.parent.canvasImageBottom.init(),this.parent.render())},e.prototype.destroy=function(){document.removeEventListener("mousemove",this.onMouseMove),document.removeEventListener("mouseup",this.onMouseUp)},e}(),vn=globalThis&&globalThis.__values||function(e){var t=typeof Symbol=="function"&&Symbol.iterator,i=t&&e[t],a=0;if(i)return i.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&a>=e.length&&(e=void 0),{value:e&&e[a++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},Ld=function(){function e(t,i,a){this.parentElement=t,this.store=i,this.isBottom=a,this.canvas=document.createElement("canvas"),this.otherOffsreen=Rr(),this.offscreen=Rr(),this.animateOffsScreen=Rr(),t.appendChild(this.canvas),this.canvas.style.backgroundRepeat="no-repeat",this.canvas.style.backgroundSize="100% 100%",this.canvas.style.position="absolute",this.canvas.style.top="0",this.canvas.style.left="0"}return e.prototype.resize=function(t,i){this.canvas.style.width=t+"px",this.canvas.style.height=i+"px",t=t*this.store.dpiRatio|0,i=i*this.store.dpiRatio|0,this.canvas.width=t,this.canvas.height=i,this.otherOffsreen.width=t,this.otherOffsreen.height=i,this.offscreen.width=t,this.offscreen.height=i,this.animateOffsScreen.width=t,this.animateOffsScreen.height=i,this.otherOffsreen.getContext("2d").scale(this.store.dpiRatio,this.store.dpiRatio),this.otherOffsreen.getContext("2d").textBaseline="middle",this.offscreen.getContext("2d").scale(this.store.dpiRatio,this.store.dpiRatio),this.offscreen.getContext("2d").textBaseline="middle",this.animateOffsScreen.getContext("2d").scale(this.store.dpiRatio,this.store.dpiRatio),this.animateOffsScreen.getContext("2d").textBaseline="middle",this.init()},e.prototype.init=function(){var t,i;this.offscreen.getContext("2d").clearRect(0,0,this.canvas.width,this.canvas.height),this.animateOffsScreen.getContext("2d").clearRect(0,0,this.canvas.width,this.canvas.height);try{for(var a=vn(this.store.data.pens),r=a.next();!r.done;r=a.next()){var n=r.value;this.hasImage(n)&&(n.calculative.imageDrawed=!1)}}catch(o){t={error:o}}finally{try{r&&!r.done&&(i=a.return)&&i.call(a)}finally{if(t)throw t.error}}this.isBottom?this.store.patchFlagsBackground=!0:this.store.patchFlagsTop=!0},e.prototype.clear=function(){this.otherOffsreen.getContext("2d").clearRect(0,0,this.otherOffsreen.width,this.otherOffsreen.height),this.offscreen.getContext("2d").clearRect(0,0,this.canvas.width,this.canvas.height),this.animateOffsScreen.getContext("2d").clearRect(0,0,this.canvas.width,this.canvas.height),this.canvas.getContext("2d").clearRect(0,0,this.canvas.width,this.canvas.height)},e.prototype.hasImage=function(t){return t.calculative.hasImage=t.calculative&&t.calculative.inView&&(this.isBottom&&t.canvasLayer===Ne.CanvasImageBottom||!this.isBottom&&t.canvasLayer===Ne.CanvasImage)&&t.image&&t.calculative.img&&t.name!=="gif",t.calculative.hasImage},e.prototype.render=function(){var t,i,a,r,n,o,s,h,l=!1,c=!1;try{for(var f=vn(this.store.data.pens),v=f.next();!v.done;v=f.next()){var g=v.value;this.hasImage(g)&&(this.store.animates.has(g)?c=!0:g.calculative.imageDrawed||(l=!0),g.parentId&&this.store.animates.has(ri(g,!0))&&(c=!0))}}catch(U){t={error:U}}finally{try{v&&!v.done&&(i=f.return)&&i.call(f)}finally{if(t)throw t.error}}var y=this.store.patchFlagsBackground,p=this.store.patchFlagsTop;if(p&&!this.isBottom){var m=this.otherOffsreen.getContext("2d");m.clearRect(0,0,this.canvas.width,this.canvas.height),this.renderRule(m)}var b=this.store.patchFlagsLast;if(b){var m=this.offscreen.getContext("2d");m.clearRect(0,0,this.canvas.width,this.canvas.height)}if(l){var m=this.offscreen.getContext("2d");m.save(),m.clearRect(0,0,this.canvas.width,this.canvas.height),m.translate(this.store.data.x,this.store.data.y);try{for(var x=vn(this.store.data.pens),_=x.next();!_.done;_=x.next()){var g=_.value;!g.calculative.hasImage||this.store.animates.has(g)||this.store.animates.has(ri(g,!0))||g.canvasLayer!==Ne.CanvasTemplate&&(g.calculative.imageDrawed=!0,m.save(),Qr(m,g),g.calculative.rotate&&or(m,g),Jr(m,g),Fa(m,g),m.restore())}}catch($){a={error:$}}finally{try{_&&!_.done&&(r=x.return)&&r.call(x)}finally{if(a)throw a.error}}m.restore()}if(c){var m=this.animateOffsScreen.getContext("2d");m.save(),m.clearRect(0,0,this.canvas.width,this.canvas.height),m.translate(this.store.data.x,this.store.data.y);try{for(var k=vn(this.store.animates),I=k.next();!I.done;I=k.next()){var g=I.value;!g.calculative.hasImage||g.canvasLayer!==Ne.CanvasTemplate&&(g.calculative.imageDrawed=!0,m.save(),Qr(m,g),g.calculative.rotate&&or(m,g),Jr(m,g),Fa(m,g),m.restore())}}catch($){n={error:$}}finally{try{I&&!I.done&&(o=k.return)&&o.call(k)}finally{if(n)throw n.error}}try{for(var P=vn(this.store.data.pens),M=P.next();!M.done;M=P.next()){var g=M.value;!g.calculative.hasImage||!g.parentId||g.canvasLayer!==Ne.CanvasTemplate&&this.store.animates.has(ri(g,!0))&&(g.calculative.imageDrawed=!0,m.save(),Qr(m,g),g.calculative.rotate&&or(m,g),Jr(m,g),Fa(m,g),m.restore())}}catch($){s={error:$}}finally{try{M&&!M.done&&(h=P.return)&&h.call(P)}finally{if(s)throw s.error}}m.restore()}if(l||c||y&&this.isBottom||p&&!this.isBottom){var L=this.canvas.getContext("2d");L.clearRect(0,0,this.canvas.width,this.canvas.height),this.isBottom&&(this.store.patchFlagsBackground=!1),L.drawImage(this.offscreen,0,0,this.canvas.width,this.canvas.height),L.drawImage(this.animateOffsScreen,0,0,this.canvas.width,this.canvas.height),this.isBottom||(L.drawImage(this.otherOffsreen,0,0,this.canvas.width,this.canvas.height),this.store.patchFlagsTop=!1)}},e.prototype.renderRule=function(t){var i,a,r,n,o,s,h,l,c=this.store,f=c.data,v=c.options,g=f.rule,y=f.ruleColor,p=f.scale,m=f.origin;if(!!(g!=null?g:v.rule)){var b=p*10;t.save();var x=y||v.ruleColor;t.strokeStyle=ls(x,.7);var _=m.x+f.x,k=m.y+f.y,I=this.canvas,P=I.width,M=I.height,L=((i=v.ruleOptions)===null||i===void 0?void 0:i.height)||20;!((a=v.ruleOptions)===null||a===void 0)&&a.background&&(t.beginPath(),t.fillStyle=(r=v.ruleOptions)===null||r===void 0?void 0:r.background,t.rect(0,0,P,L),t.fill(),t.rect(0,0,L,M),t.fill()),!((n=v.ruleOptions)===null||n===void 0)&&n.underline&&(t.beginPath(),t.fillStyle=ls(x,.7),t.moveTo(0,L),t.lineTo(P,L),t.stroke(),t.moveTo(L,0),t.lineTo(L,M),t.stroke());var U=L/4;((o=v.ruleOptions)===null||o===void 0?void 0:o.baseline)==="bottom"&&(U=L*3/4),t.beginPath(),t.lineWidth=L/2,t.lineDashOffset=-_%b,t.setLineDash([1,b-1]),t.moveTo(0,U),t.lineTo(P,U),t.stroke(),t.beginPath(),t.lineDashOffset=-k%b,t.moveTo(U,0),t.lineTo(U,M),t.stroke(),t.strokeStyle=x,t.beginPath(),t.lineWidth=L,t.lineDashOffset=-_%(b*10),t.setLineDash([1,b*10-1]),t.moveTo(0,L/2),t.lineTo(P,L/2),t.stroke(),t.beginPath(),t.lineDashOffset=-k%(b*10),t.moveTo(L/2,0),t.lineTo(L/2,M),t.stroke(),t.beginPath(),t.fillStyle=((s=v.ruleOptions)===null||s===void 0?void 0:s.textColor)||t.strokeStyle;var $=0-Math.floor(_/b/10)*100,S=((h=v.ruleOptions)===null||h===void 0?void 0:h.textTop)||16,T=((l=v.ruleOptions)===null||l===void 0?void 0:l.textLeft)||4;_<0&&($-=100);for(var R=_%(b*10);R `;var r=document.createElement("div");this.iframe=document.createElement("iframe"),this.iframe.setAttribute("frameborder","0"),this.box.className="meta2d-dialog_mask",this.dialog.className="meta2d-dialog",r.className="meta2d-dialog_body",a.className="meta2d-dialog_header",this.title.className="meta2d-dialog-content",this.close.className="meta2d-dialog-close",a.appendChild(this.title),a.appendChild(this.close),r.appendChild(this.iframe),this.dialog.appendChild(a),this.dialog.appendChild(r),this.box.appendChild(this.dialog),t.appendChild(this.box),this.dialog.onclick=function(h){h.stopPropagation()},this.box.onclick=function(){i.hide()},this.close.onclick=function(){i.hide()};for(var n,o=0;o=e.length&&(e=void 0),{value:e&&e[a++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},Lk=function(){function e(t,i){this.parentElement=t,this.store=i,this.canvas=document.createElement("canvas"),this.offscreen=Rr(),this.bgOffscreen=Rr(),t.appendChild(this.canvas),this.canvas.style.backgroundRepeat="no-repeat",this.canvas.style.backgroundSize="100% 100%",this.canvas.style.position="absolute",this.canvas.style.top="0",this.canvas.style.left="0"}return e.prototype.resize=function(t,i){this.canvas.style.width=t+"px",this.canvas.style.height=i+"px",t=t*this.store.dpiRatio|0,i=i*this.store.dpiRatio|0,this.canvas.width=t,this.canvas.height=i,this.bgOffscreen.width=t,this.bgOffscreen.height=i,this.offscreen.width=t,this.offscreen.height=i,this.bgOffscreen.getContext("2d").scale(this.store.dpiRatio,this.store.dpiRatio),this.bgOffscreen.getContext("2d").textBaseline="middle",this.offscreen.getContext("2d").scale(this.store.dpiRatio,this.store.dpiRatio),this.offscreen.getContext("2d").textBaseline="middle",this.init()},e.prototype.init=function(){this.bgOffscreen.getContext("2d").clearRect(0,0,this.canvas.width,this.canvas.height),this.offscreen.getContext("2d").clearRect(0,0,this.canvas.width,this.canvas.height),this.patchFlags=!0,this.bgPatchFlags=!0},e.prototype.hidden=function(){this.canvas.style.display="none"},e.prototype.show=function(){this.canvas.style.display="block"},e.prototype.clear=function(){this.bgOffscreen.getContext("2d").clearRect(0,0,this.canvas.width,this.canvas.height),this.offscreen.getContext("2d").clearRect(0,0,this.canvas.width,this.canvas.height),this.canvas.getContext("2d").clearRect(0,0,this.canvas.width,this.canvas.height),this.bgPatchFlags=!0,this.patchFlags=!0},e.prototype.render=function(){var t,i,a;if(this.bgPatchFlags){var r=this.bgOffscreen.getContext("2d");r.clearRect(0,0,this.canvas.width,this.canvas.height);var n=this.store.data.width||this.store.options.width,o=this.store.data.height||this.store.options.height,s=this.store.data.x||this.store.options.x||0,h=this.store.data.y||this.store.options.y||0,l=this.store.data.background||this.store.options.background;l&&(r.save(),r.fillStyle=l,n&&o?(r.globalAlpha=(a=this.store.data.globalAlpha)!==null&&a!==void 0?a:this.store.options.globalAlpha,r.shadowOffsetX=this.store.options.shadowOffsetX,r.shadowOffsetY=this.store.options.shadowOffsetY,r.shadowBlur=this.store.options.shadowBlur,r.shadowColor=this.store.options.shadowColor,r.fillRect(this.store.data.origin.x+s,this.store.data.origin.y+h,n*this.store.data.scale,o*this.store.data.scale)):r.fillRect(0,0,this.canvas.width,this.canvas.height),r.restore()),n&&o&&this.store.bkImg&&(r.save(),r.drawImage(this.store.bkImg,this.store.data.origin.x+s,this.store.data.origin.y+h,n*this.store.data.scale,o*this.store.data.scale),r.restore()),this.renderGrid(r)}if(this.patchFlags){var r=this.offscreen.getContext("2d");r.save(),r.clearRect(0,0,this.canvas.width,this.canvas.height),r.translate(this.store.data.x,this.store.data.y);try{for(var c=Ik(this.store.data.pens),f=c.next();!f.done;f=c.next()){var v=f.value;!isFinite(v.x)||v.canvasLayer===Ne.CanvasTemplate&&v.calculative.inView&&(jr(r,v),v.image&&v.name!=="gif"&&v.calculative.img&&(r.save(),Qr(r,v),v.calculative.rotate&&or(r,v),Jr(r,v),Fa(r,v),r.restore()))}}catch(p){t={error:p}}finally{try{f&&!f.done&&(i=c.return)&&i.call(c)}finally{if(t)throw t.error}}r.restore()}if(this.patchFlags||this.bgPatchFlags){var g=this.canvas.getContext("2d");g.clearRect(0,0,this.canvas.width,this.canvas.height),g.drawImage(this.bgOffscreen,0,0,this.canvas.width,this.canvas.height),g.drawImage(this.offscreen,0,0,this.canvas.width,this.canvas.height),this.patchFlags=!1,this.bgPatchFlags=!1}},e.prototype.renderGrid=function(t){var i=this.store,a=i.data,r=i.options,n=a.grid,o=a.gridRotate,s=a.gridColor,h=a.gridSize,l=a.scale,c=a.origin;if(!!(n!=null?n:r.grid)){t.save();var f=(a.width||r.width)*l,v=(a.height||r.height)*l,g=(a.x||r.x||0)+c.x,y=(a.y||r.y||0)+c.y;o&&(t.translate(f/2,v/2),t.rotate(o*Math.PI/180),t.translate(-f/2,-v/2)),t.lineWidth=1,t.strokeStyle=s||r.gridColor,t.beginPath();var p=(h||r.gridSize)*l;if(!f||!v){for(var m=this.store.dpiRatio,b=this.canvas.width/m,x=this.canvas.height/m,_=g/p,k=y/p,I=p*10,P=g-Math.ceil(_)*p,M=y-Math.ceil(k)*p,L=b+P+I,U=x+M+I,$=P;$<=L;$+=p)t.moveTo($,M),t.lineTo($,x+M+I);for(var $=M;$<=U;$+=p)t.moveTo(P,$),t.lineTo(b+P+I,$)}else{for(var L=f+g,U=v+y,$=g;$<=L;$+=p)t.moveTo($,y),t.lineTo($,v+y);for(var $=y;$<=U;$+=p)t.moveTo(g,$),t.lineTo(f+g,$)}t.stroke(),t.restore()}},e}(),Lt=globalThis&&globalThis.__assign||function(){return Lt=Object.assign||function(e){for(var t,i=1,a=arguments.length;i0&&n[n.length-1])&&(l[0]===6||l[0]===2)){i=0;continue}if(l[0]===3&&(!n||l[1]>n[0]&&l[1]0)&&!(r=a.next()).done;)n.push(r.value)}catch(s){o={error:s}}finally{try{r&&!r.done&&(i=a.return)&&i.call(a)}finally{if(o)throw o.error}}return n},Di=globalThis&&globalThis.__spreadArray||function(e,t,i){if(i||arguments.length===2)for(var a=0,r=t.length,n;a=e.length&&(e=void 0),{value:e&&e[a++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},Mi="-moving",Dd=function(){function e(t,i,a){var r=this;this.parent=t,this.parentElement=i,this.store=a,this.canvas=document.createElement("canvas"),this.offscreen=Rr(),this.externalElements=document.createElement("div"),this.lastRotate=0,this.hoverType=be.None,this.resizeIndex=0,this.lastOffsetX=0,this.lastOffsetY=0,this.drawLineFns=Di([],Li(Tx),!1),this.patchFlagsLines=new Set,this.lastMouseTime=0,this.hoverTimer=0,this.patchFlags=!1,this.lastRender=0,this.touchStart=0,this.lastAnimateRender=0,this.animateRendering=!1,this.pointSize=8,this.pasteOffset=!0,this.opening=!1,this.maxZindex=5,this.canMoveLine=!1,this.inputParent=document.createElement("div"),this.inputDiv=document.createElement("div"),this.inputRight=document.createElement("div"),this.dropdown=document.createElement("ul"),this.mousePos={x:0,y:0},this.autoPolylineFlag=!1,this.stopPropagation=function(n){n.stopPropagation()},this.curve=NE,this.polyline=VE,this.mind=zE,this.line=UE,this.onCopy=function(n){r.store.options.disableClipboard||n.target!==r.externalElements&&n.target!==document.body&&n.target.offsetParent!==r.externalElements||r.copy()},this.onCut=function(n){r.store.options.disableClipboard||n.target!==r.externalElements&&n.target!==document.body&&n.target.offsetParent!==r.externalElements||r.cut()},this.onPaste=function(n){if(!(r.store.data.locked||r.store.options.disableClipboard)&&!(n.target!==r.externalElements&&n.target!==document.body&&n.target.offsetParent!==r.externalElements)){var o;if(navigator.clipboard&&n.clipboardData){var s=n.clipboardData.items;if(s){for(var h=0;h100&&r.store.options.scroll&&r.scroll){r.scroll.wheel(n.deltaY<0);return}if(!r.store.options.disableTouchPadScale){var s=.015,h=/mac os /i.test(navigator.userAgent);if(h)n.ctrlKey?n.deltaY>0&&(s*=-1):s*=n.wheelDeltaY/240;else{var l=.2;n.deltaY.toString().indexOf(".")!==-1&&(l=.01),n.deltaY>0?s=-l:s=l}var c=n.offsetX,f=n.offsetY;r.scale(r.store.data.scale+s,{x:c,y:f}),r.externalElements.focus()}}}},this.onkeydown=function(n){var o,s,h;if(r.store.data.locked>=ze.DisableEdit&&n.target.tagName!=="INPUT"&&n.target.tagName!=="TEXTAREA"&&!n.target.dataset.meta2dIgnore&&r.store.active.forEach(function(m){var b;(b=m.onKeyDown)===null||b===void 0||b.call(m,m,n.key)}),!(r.store.data.locked>=ze.DisableEdit||n.target.tagName==="INPUT"||n.target.tagName==="TEXTAREA"||n.target.dataset.meta2dIgnore)&&!r.store.options.unavailableKeys.includes(n.key)){r.keyOptions||(r.keyOptions={}),r.keyOptions.altKey=n.altKey,r.keyOptions.shiftKey=n.shiftKey,r.keyOptions.ctrlKey=n.ctrlKey,r.keyOptions.metaKey=n.metaKey;var l=10,c=10,f=null;if(r.store.options.strictScope){var v=r.store.data.width||r.store.options.width,g=r.store.data.height||r.store.options.height;v&&g&&(f={x:r.store.data.origin.x,y:r.store.data.origin.y,width:v*r.store.data.scale,height:g*r.store.data.scale})}switch(n.key){case" ":r.hotkeyType=Ke.Translate;break;case"Control":r.drawingLine?r.drawingLine.calculative.drawlineH=!r.drawingLine.calculative.drawlineH:r.hotkeyType||(r.patchFlags=!0,r.hotkeyType=Ke.Select);break;case"Meta":break;case"Shift":r.store.active.length===1&&r.store.active[0].type&&r.store.activeAnchor?r.toggleAnchorHand():r.hotkeyType||(r.patchFlags=!0,r.store.options.resizeMode||(r.hotkeyType=Ke.Resize));break;case"Alt":if(!n.ctrlKey&&!n.shiftKey&&r.drawingLine){var y=We(r.drawingLine);y!==r.drawingLine.calculative.activeAnchor?(ou(r.drawingLine),r.drawingLine.calculative.worldAnchors.push(y)):r.drawingLine.calculative.worldAnchors.push({x:y.x,y:y.y});var p=r.drawLineFns.indexOf(r.drawingLineName);r.drawingLineName=r.drawLineFns[(p+1)%r.drawLineFns.length],r.drawingLine.lineName=r.drawingLineName,r.drawline(),r.patchFlags=!0}n.preventDefault();break;case"a":case"A":n.ctrlKey||n.metaKey?(r.active(r.store.data.pens.filter(function(m){return!m.parentId&&m.locked!==ze.Disable})),n.preventDefault()):r.toggleAnchorMode();break;case"Delete":case"Backspace":!r.store.data.locked&&r.delete();break;case"ArrowLeft":if(r.movingAnchor){r.translateAnchor(-1,0);break}if(l=-1,n.shiftKey&&(l=-5),(n.ctrlKey||n.metaKey)&&(l=-10),l=l*r.store.data.scale,r.store.activeAnchor&&r.store.active&&r.store.active.length===1&&r.store.active[0].type){r.moveLineAnchor({x:r.store.activeAnchor.x+l,y:r.store.activeAnchor.y},{});break}f&&r.activeRect.x+lf.x+f.width&&(l=f.x+f.width-(r.activeRect.x+r.activeRect.width)),r.translatePens(r.store.active,l,0);break;case"ArrowDown":if(r.movingAnchor){r.translateAnchor(0,1);break}if(c=1,n.shiftKey&&(c=5),(n.ctrlKey||n.metaKey)&&(c=10),c=c*r.store.data.scale,f&&r.activeRect.y+r.activeRect.height+c>f.y+f.height&&(c=f.y+f.height-(r.activeRect.y+r.activeRect.height)),r.store.activeAnchor&&r.store.active&&r.store.active.length===1&&r.store.active[0].type){r.moveLineAnchor({x:r.store.activeAnchor.x,y:r.store.activeAnchor.y+c},{});break}r.translatePens(r.store.active,0,c);break;case"d":case"D":!((o=r.store.active[0])===null||o===void 0)&&o.locked||r.removeAnchorHand();break;case"h":case"H":!((s=r.store.active[0])===null||s===void 0)&&s.locked||r.addAnchorHand();break;case"m":case"M":r.toggleMagnifier();break;case"g":case"G":r.hoverType===be.NodeAnchor&&(r.movingAnchor=r.store.hoverAnchor,r.externalElements.style.cursor="move");break;case"s":case"S":!r.store.data.locked&&r.hoverType===be.LineAnchor&&r.store.hover===r.store.active[0]&&r.splitLine(r.store.active[0],r.store.hoverAnchor),(n.ctrlKey||n.metaKey)&&r.store.emitter.emit("save",{event:n});break;case"c":case"C":(n.ctrlKey||n.metaKey)&&r.store.options.disableClipboard&&r.copy();break;case"x":case"X":(n.ctrlKey||n.metaKey)&&r.store.options.disableClipboard&&r.cut();break;case"\u221A":case"v":case"V":!n.ctrlKey&&!n.metaKey&&(r.pencil&&r.stopPencil(),r.drawingLineName?(r.finishDrawline(),r.drawingLineName=""):r.drawingLineName=r.store.options.drawingLineName),!r.store.data.locked&&(n.ctrlKey||n.metaKey)&&(r.store.options.disableClipboard||!r.store.options.disableClipboard&&n.altKey)&&r.paste();break;case"b":case"B":r.drawingLineName&&(r.finishDrawline(),r.drawingLineName=""),r.pencil?r.stopPencil():r.drawingPencil();break;case"y":case"Y":(n.ctrlKey||n.metaKey)&&r.redo();break;case"z":case"Z":n.ctrlKey||n.metaKey?r.undo():n.shiftKey&&r.redo();break;case"Enter":r.drawingLineName&&(r.finishDrawline(!0),r.store.active[0].anchors[0].connectTo?r.drawingLineName="":r.drawingLineName=r.store.options.drawingLineName),r.store.active&&(r.store.active.forEach(function(m){m.type?(m.close=!m.close,m.close&&wg(m),r.store.path2dMap.set(m,ke.path2dDraws.line(m)),Uc(m)):m.calculative.focus=!m.calculative.focus}),r.render());break;case"Escape":r.drawingLineName&&r.finishDrawline(),r.drawingLineName=void 0,r.stopPencil(),r.movingPens&&(r.getAllByPens(r.movingPens).forEach(function(m){r.store.pens[m.id]=void 0}),r.movingPens=void 0,r.mouseDown=void 0,r.clearDock(),(h=r.store.active)===null||h===void 0||h.forEach(function(m){r.updateLines(m)}),r.calcActiveRect(),r.patchFlags=!0),r.hotkeyType=Ke.None,r.movingAnchor=void 0,r.magnifierCanvas.magnifier&&(r.magnifierCanvas.magnifier=!1,r.patchFlags=!0);break;case"E":case"e":r.store.options.disableAnchor=!r.store.options.disableAnchor,r.store.emitter.emit("disableAnchor",r.store.options.disableAnchor);break;case"=":(n.ctrlKey||n.metaKey)&&(r.scale(r.store.data.scale+.1),n.preventDefault(),n.stopPropagation());break;case"-":(n.ctrlKey||n.metaKey)&&(r.scale(r.store.data.scale-.1),n.preventDefault(),n.stopPropagation());break;case"l":case"L":r.canMoveLine=!0;break;case"[":r.parent.down();break;case"]":r.parent.up();break;case"{":r.parent.bottom();break;case"}":r.parent.top();break}r.render(!1)}},this.onkeyup=function(n){switch(n.key){case"l":case"L":r.canMoveLine=!1;break}r.hotkeyType&&r.render(),r.hotkeyType=0&&g<0||v<=0&&g>0)&&(y>=0&&p<0||y<=0&&p>0)?r.touchScaling=!0:r.touchMoving=!0}if(r.touchScaling){if(r.store.options.disableScale)return;var m=Math.hypot(h[0].pageX-h[1].pageX,h[0].pageY-h[1].pageY)/r.initTouchDis;r.scale(r.initScale*m,ce(r.touchCenter))}if(r.touchMoving){if(r.store.data.locked>=ze.DisableMove&&r.store.data.locked!==ze.DisableScale||r.store.options.disableScale)return;if(r.lastOffsetX){var m=r.store.data.scale;r.translate((c-r.lastOffsetX)/m,(f-r.lastOffsetY)/m)}r.lastOffsetX=c,r.lastOffsetY=f}}}}},this.ontouchend=function(n){if(r.store.data.locked!==ze.Disable){r.touchCenter=void 0,r.touchScaling=void 0,r.touchMoving=void 0,r.startTouches=void 0,r.lastOffsetX=0,r.lastOffsetY=0;var o=n.changedTouches[0].pageX-r.clientRect.x,s=n.changedTouches[0].pageY-r.clientRect.y;r.onMouseUp({x:o,y:s,clientX:n.changedTouches[0].clientX,clientY:n.changedTouches[0].clientY,pageX:n.changedTouches[0].pageX,pageY:n.changedTouches[0].pageY,ctrlKey:n.ctrlKey||n.metaKey,shiftKey:n.shiftKey,altKey:n.altKey,buttons:1}),setTimeout(function(){r.render()},20)}},this.onGesturestart=function(n){n.preventDefault()},this.onMouseDown=function(n){var o,s,h;if(n.buttons===2&&!r.drawingLine&&(r.mouseRight=tr.Down),r.hideInput(),r.store.data.locked===ze.Disable||n.buttons!==1&&n.buttons!==2){r.hoverType=be.None;return}if(!r.magnifierCanvas.magnifier){if(r.calibrateMouse(n),r.mousePos.x=n.x,r.mousePos.y=n.y,r.mouseDown=n,r.lastMouseTime=performance.now(),r.hotkeyType===Ke.AddAnchor){r.setAnchor(r.store.pointAt);return}if(!r.store.options.autoAnchor&&!r.drawingLine&&n.shiftKey&&n.ctrlKey&&n.altKey){r.setAnchor(r.store.pointAt),r.drawingLineName=r.store.options.drawingLineName;var l=r.store.activeAnchor;if(!l)return;var c={id:Me(),x:l.x,y:l.y};r.drawingLine=r.createDrawingLine(c);var f=lt(r.drawingLine);r.drawingLine.calculative.activeAnchor=f,_t(r.store.hover,l,r.drawingLine,c),r.drawline();return}if(!(r.hotkeyType===Ke.Translate||r.mouseRight===tr.Down&&!r.store.options.mouseRightActive)){if(r.drawingLine){if(r.store.hoverAnchor){var v=We(r.drawingLine);r.store.hoverAnchor.type===ir.Line?Do(v,r.store.hoverAnchor,r.store):(v.x=r.store.hoverAnchor.x,v.y=r.store.hoverAnchor.y),_t(r.store.hover,r.store.hoverAnchor,r.drawingLine,v),r.drawline(),r.finishDrawline(!0);return}if(!r.store.options.autoAnchor&&n.shiftKey&&n.altKey&&n.ctrlKey){r.setAnchor(r.store.pointAt);var g=We(r.drawingLine),l=r.store.activeAnchor;if(!l)return;g.x=l.x,g.y=l.y,_t(r.store.hover,l,r.drawingLine,g),r.drawline(),r.finishDrawline(!0);return}if(n.buttons===2||r.drawingLineName==="mind"&&((o=r.drawingLine)===null||o===void 0?void 0:o.calculative.worldAnchors.length)>1||r.store.options.drawingLineLength&&((s=r.drawingLine)===null||s===void 0?void 0:s.calculative.worldAnchors.length)>r.store.options.drawingLineLength){r.finishDrawline(!0),((h=r.store.active[0])===null||h===void 0?void 0:h.anchors[0].connectTo)||r.store.active.length==0?r.drawingLineName="":r.drawingLineName=r.store.options.drawingLineName;return}if(r.store.options.autoAnchor&&r.hoverType===be.Node){var y=We(r.drawingLine),l=Ma(r.store.hover,n);y.x=l.x,y.y=l.y,r.drawingLine.autoTo=!0,_t(r.store.hover,l,r.drawingLine,y),r.drawline(),r.finishDrawline(!0);return}var p=We(r.drawingLine);p.isTemp?(r.drawingLine.calculative.activeAnchor=r.drawingLine.calculative.worldAnchors[r.drawingLine.calculative.worldAnchors.length-2],p.isTemp=void 0):(r.drawingLine.calculative.activeAnchor=p,r.drawingLine.calculative.worldAnchors.push({x:p.x,y:p.y,penId:p.penId})),r.drawingLine.calculative.drawlineH=void 0,r.drawingLineName!=="polyline"&&r.drawline()}if(r.drawingLineName){if(r.hoverType===be.Node)if(r.store.options.autoAnchor){r.inactive(!0);var l=Ma(r.store.hover,n);r.store.hoverAnchor=l;var c={id:Me(),x:l.x,y:l.y};r.drawingLine=r.createDrawingLine(c),r.drawingLine.autoFrom=!0,_t(r.store.hover,l,r.drawingLine,c)}else r.inactive(),r.hoverType=be.None;else if(r.hoverType===be.NodeAnchor){r.drawingLineName=r.store.options.drawingLineName;var c={id:Me(),x:r.store.hoverAnchor.x,y:r.store.hoverAnchor.y};r.drawingLine=r.createDrawingLine(c),r.drawingLine.calculative.activeAnchor=c,_t(r.store.hover,r.store.hoverAnchor,r.drawingLine,c)}else if(!r.drawingLine&&r.drawingLineName!=="curve"){r.inactive(!0);var c={id:Me(),x:n.x,y:n.y};r.drawingLine=r.createDrawingLine(c),r.drawingLine.calculative.activeAnchor=c}}else if(r.pencil){r.inactive(!0);var m=Me(),c={x:n.x,y:n.y,id:Me(),penId:m};r.pencilLine=r.getInitPencilLine(c)}else{switch(r.hoverType){case be.None:(r.store.data.rule||r.store.options.rule)&&!r.store.options.disableRuleLine&&r.addRuleLine(n),r.store.options.resizeMode&&(r.hotkeyType=Ke.None),r.inactive();break;case be.Node:case be.Line:if(r.store.hover){var b=ri(r.store.hover,!0)||r.store.hover;n.ctrlKey&&!n.shiftKey?(b.calculative.active?r.willInactivePen=b:(b.calculative.active=!0,La(b),r.store.active.push(b),r.store.emitter.emit("active",r.store.active)),r.patchFlags=!0):n.ctrlKey&&n.shiftKey&&r.store.hover.parentId?r.active([r.store.hover]):b.calculative.active||(r.active([b]),r.store.options.resizeMode&&(r.hotkeyType=Ke.Resize)),r.calcActiveRect()}break;case be.LineAnchor:r.store.activeAnchor=r.store.hoverAnchor,r.store.hover.calculative.activeAnchor=r.store.hoverAnchor,r.active([r.store.hover]);break;case be.LineAnchorPrev:case be.LineAnchorNext:r.store.activeAnchor&&(r.prevAnchor=Lt({},r.store.activeAnchor.prev),r.nextAnchor=Lt({},r.store.activeAnchor.next));break;case be.Resize:r.activeInitPos=[],r.store.active.forEach(function(x){r.activeInitPos.push({x:(x.calculative.worldRect.x-r.activeRect.x)/r.activeRect.width,y:(x.calculative.worldRect.y-r.activeRect.y)/r.activeRect.height})});break}r.store.emitter.emit("mousedown",{x:n.x,y:n.y,pen:r.store.hover})}r.render()}}},this.onMouseMove=function(n){var o,s,h,l,c,f,v;if(r.store.data.locked===ze.Disable){r.hoverType=be.None;return}if(r.mouseDown&&!r.mouseDown.restore&&n.buttons!==1&&n.buttons!==2){r.onMouseUp(n);return}if(r.lastMouseTime){var g=performance.now();if(g-r.lastMouseTime<50){r.lastMouseTime=0;return}r.lastMouseTime=0}if(r.calibrateMouse(n),r.mousePos.x=n.x,r.mousePos.y=n.y,r.magnifierCanvas.magnifier){r.render();return}if(r.mouseDown&&!r.store.options.disableTranslate){if(r.mouseRight===tr.Down&&(r.mouseRight=tr.Translate),r.store.data.locked===ze.DisableEdit||r.store.data.locked===ze.DisableScale||r.hotkeyType===Ke.Translate||r.mouseRight===tr.Translate){var y=r.store.data.scale,p=(n.x-r.mouseDown.x)/y,m=(n.y-r.mouseDown.y)/y;n.shiftKey&&!n.ctrlKey&&(m=0),n.ctrlKey&&(p=0),r.translate(p,m);return}if(r.store.data.locked)return;if(!r.drawingLine&&!r.pencil){if(!r.drawingLineName&&!r.movingAnchor){if(r.hoverType===be.NodeAnchor){if(!r.store.hoverAnchor)return;r.drawingLineName=r.store.options.drawingLineName;var b={id:Me(),x:r.store.hoverAnchor.x,y:r.store.hoverAnchor.y};r.drawingLine=r.createDrawingLine(b),r.drawingLine.calculative.activeAnchor=b,_t(r.store.hover,r.store.hoverAnchor,r.drawingLine,b),r.drawline();return}}else if(r.drawingLineName&&r.hoverType===be.None){var b={id:Me(),x:n.x,y:n.y};r.drawingLine=r.createDrawingLine(b),r.drawingLine.calculative.activeAnchor=b,r.drawline();return}if(n.buttons===1&&!r.hoverType&&!r.hotkeyType){r.dragRect={x:Math.min(r.mouseDown.x,n.x),y:Math.min(r.mouseDown.y,n.y),ex:Math.max(r.mouseDown.x,n.x),ey:Math.max(r.mouseDown.y,n.y),width:Math.abs(n.x-r.mouseDown.x),height:Math.abs(n.y-r.mouseDown.y)},r.render();return}if(r.movingAnchor){var p=n.x-r.movingAnchor.x,m=n.y-r.movingAnchor.y;r.translateAnchor(p,m),r.render();return}else if(!(!((o=r.store.active[0])===null||o===void 0)&&o.locked)){var b={x:n.x,y:n.y};if(r.hoverType===be.LineAnchor){(r.dockInAnchor(n)||((s=r.store.active[0])===null||s===void 0?void 0:s.lineName)==="line")&&!r.store.options.disableDock&&!r.store.options.disableLineDock&&(r.clearDock(),r.dock=dd(r.store,b,r.store.activeAnchor),!((h=r.dock)===null||h===void 0)&&h.xDock&&(b.x+=r.dock.xDock.step),!((l=r.dock)===null||l===void 0)&&l.yDock&&(b.y+=r.dock.yDock.step)),r.moveLineAnchor(b,n);return}if(r.hoverType===be.LineAnchorPrev){r.moveLineAnchorPrev(n);return}if(r.hoverType===be.LineAnchorNext){r.moveLineAnchorNext(n);return}}if(r.hoverType===be.Rotate){r.rotatePens({x:n.x,y:n.y});return}if(r.hoverType===be.Resize){r.resizePens(n);return}if(r.hoverType===be.Node||r.hoverType===be.Line){var p=n.x-r.mouseDown.x,m=n.y-r.mouseDown.y,x=20;if(n.ctrlKey&&!n.shiftKey&&(Math.abs(p)>=x||Math.abs(m)>=x)&&(r.willInactivePen=void 0),r.store.active.length===1){var _=r.store.active[0];if((_.locked===void 0||_.locked1&&(k=We(r.drawingLine)),k?(k.prev=void 0,k.next=void 0,k.id||(k.id=Me()),k.x=b.x,k.y=b.y,k.connectTo=void 0):(k=Lt({},b),r.drawingLine.calculative.worldAnchors.push(k)),(r.hoverType===be.NodeAnchor||r.hoverType===be.LineAnchor)&&(r.store.hoverAnchor.type!==ir.Line&&(k.x=r.store.hoverAnchor.x,k.y=r.store.hoverAnchor.y),k.connectTo=r.store.hoverAnchor.penId,r.drawingLineName==="polyline"&&(k.isTemp=!1)),r.drawingLineName==="line"){if(n.ctrlKey&&!n.shiftKey)k.x=r.drawingLine.calculative.worldAnchors[r.drawingLine.calculative.worldAnchors.length-2].x;else if(n.shiftKey&&!n.ctrlKey)k.y=r.drawingLine.calculative.worldAnchors[r.drawingLine.calculative.worldAnchors.length-2].y;else if(n.shiftKey&&n.ctrlKey){var I=r.drawingLine.calculative.worldAnchors[r.drawingLine.calculative.worldAnchors.length-2];r.getSpecialAngle(k,I)}}r.drawline()}}globalThis.debug&&console.time("hover");var P=performance.now();P-r.hoverTimer>50&&(r.hoverTimer=P,r.getHover(n)),globalThis.debug&&console.timeEnd("hover"),r.hotkeyType===Ke.AddAnchor&&(r.patchFlags=!0),r.render(!1)},this.onMouseUp=function(n){var o,s;if(r.store.data.locked===ze.Disable){r.hoverType=be.None;return}if(!!r.mouseDown){if(r.mouseRight===tr.Down&&(r.store.hover&&r.store.hover.calculative.focus?r.store.hover.onContextmenu&&r.store.hover.onContextmenu(r.store.hover,n):r.store.emitter.emit("contextmenu",{e:n,clientRect:r.clientRect,pen:r.store.hover})),r.mouseRight=tr.None,r.calibrateMouse(n),r.mousePos.x=n.x,r.mousePos.y=n.y,r.pencil&&r.finishPencil(),r.drawingLine){if(r.store.hoverAnchor){var h=We(r.drawingLine);r.store.hoverAnchor.type===ir.Line?Do(h,r.store.hoverAnchor,r.store):(h.x=r.store.hoverAnchor.x,h.y=r.store.hoverAnchor.y),_t(r.store.hover,r.store.hoverAnchor,r.drawingLine,h),r.drawline(),r.finishDrawline(!0);return}if(r.store.options.autoAnchor&&r.hoverType===be.Node){var h=We(r.drawingLine),l=Ma(r.store.hover,n);h.x=l.x,h.y=l.y,r.drawingLine.autoTo=!0,_t(r.store.hover,l,r.drawingLine,h),r.drawline(),r.finishDrawline(!0);return}}if(r.hoverType===be.LineAnchor&&r.store.hover&&r.store.active[0]&&r.store.active[0].name==="line"&&r.store.active[0]!==r.store.hover){var c=r.store.active[0],f=lt(c),h=We(c);if(r.store.hoverAnchor){var v=r.store.hover,g=lt(v)===r.store.hoverAnchor,y=We(v)===r.store.hoverAnchor,p=f===r.store.activeAnchor,m=h===r.store.activeAnchor;if((n.ctrlKey||n.altKey)&&v.type===Ye.Line&&(g||y)&&(p||m)){var b=v.calculative.worldAnchors.map(function(I){return Lt(Lt({},I),{penId:c.id})});g?b.shift():y&&b.pop(),(g&&p||y&&m)&&b.reverse(),p?(c.calculative.worldAnchors[0].connectTo=void 0,(o=c.calculative.worldAnchors).unshift.apply(o,Di([],Li(b),!1))):m&&(c.calculative.worldAnchors[c.calculative.worldAnchors.length-1].connectTo=void 0,(s=c.calculative.worldAnchors).push.apply(s,Di([],Li(b),!1))),r.delete([v]),r.render()}else r.store.activeAnchor&&(r.store.hoverAnchor.type===ir.Line?Do(r.store.activeAnchor,r.store.hoverAnchor,r.store):(r.store.activeAnchor.x=r.store.hoverAnchor.x,r.store.activeAnchor.y=r.store.hoverAnchor.y),_t(r.store.hover,r.store.hoverAnchor,c,r.store.activeAnchor));r[c.lineName]&&c.lineName!=="polyline"&&r[c.lineName](r.store,c),r.store.path2dMap.set(c,ke.path2dDraws.line(c)),r.initLineRect(c)}else f===r.store.activeAnchor&&c.autoFrom?r.calcAutoAnchor(c,f,r.store.hover):h===r.store.activeAnchor&&c.autoTo&&r.calcAutoAnchor(c,h,r.store.hover)}if(r.addCaches&&r.addCaches.length){if(!r.store.data.locked){if(r.dragRect&&r.addCaches.length===1){var x=r.addCaches[0];x.width=r.dragRect.width/r.store.data.scale,x.height=r.dragRect.height/r.store.data.scale,n.x=(r.dragRect.x+r.dragRect.ex)/2,n.y=(r.dragRect.y+r.dragRect.ey)/2}r.dropPens(r.addCaches,n)}r.addCaches=void 0}if(r.hoverType===be.Rotate&&(r.getSizeCPs(),r.store.active.forEach(function(k){k.rotate=k.calculative.rotate})),r.patchFlagsLines.forEach(function(k){k.type&&r.initLineRect(k)}),r.patchFlagsLines.clear(),r.dragRect){var _=r.store.data.pens.filter(function(k){if(k.visible===!1||k.locked>=ze.DisableMove||k.parentId||k.isRuleLine)return!1;if(fs(k.calculative.worldRect,r.dragRect,r.store.options.dragAllIn))return k.type===Ye.Line&&!r.store.options.dragAllIn?jE(k,r.dragRect):!0});r.active(_)}n.button!==2&&(ws(r.mouseDown,n)<2&&(r.store.hover&&r.store.hover.input&&r.showInput(r.store.hover),r.store.emitter.emit("click",{x:n.x,y:n.y,pen:r.store.hover})),r.store.emitter.emit("mouseup",{x:n.x,y:n.y,pen:r.store.hover})),r.willInactivePen&&(r.willInactivePen.calculative.active=void 0,La(r.willInactivePen,!1),r.store.active.splice(r.store.active.findIndex(function(k){return k===r.willInactivePen}),1),r.calcActiveRect(),r.willInactivePen=void 0,r.store.emitter.emit("inactive",[r.willInactivePen]),r.render()),r.movingPens&&(n.altKey&&!n.shiftKey?r.copyMovedPens():r.movedActivePens(n.ctrlKey&&n.shiftKey),r.getAllByPens(r.movingPens).forEach(function(k){r.store.pens[k.id]=void 0}),r.movingPens=void 0),r.store.active&&r.store.active[0]&&(r.store.active[0].calculative.h=void 0),r.mouseDown=void 0,r.lastOffsetX=0,r.lastOffsetY=0,r.clearDock(),r.dragRect=void 0,r.initActiveRect=void 0,r.render()}},this.clearDock=function(){var n,o,s,h,l=(o=(n=r.dock)===null||n===void 0?void 0:n.xDock)===null||o===void 0?void 0:o.penId,c=(h=(s=r.dock)===null||s===void 0?void 0:s.yDock)===null||h===void 0?void 0:h.penId,f=r.store.pens[l];f&&(f.calculative.isDock=!1);var v=r.store.pens[c];v&&(v.calculative.isDock=!1),r.dock=void 0},this.onResize=function(){r.timer&&clearTimeout(r.timer),r.timer=setTimeout(function(){r.resize(),r.timer=void 0},100)},this.onScroll=function(){r.timer&&clearTimeout(r.timer),r.timer=setTimeout(function(){r.clientRect=r.canvas.getBoundingClientRect(),r.timer=void 0},100)},this.calibrateMouse=function(n){return n.x-=r.store.data.x,n.y-=r.store.data.y,n},this.getContainerHover=function(n){var o;if(!r.dragRect){var s=r.store.data.pens.filter(function(c){var f;return c.container||((f=r.store.options.containerShapes)===null||f===void 0?void 0:f.includes(c.name))});if(s.length)for(var h=s.length-1;h>=0;--h){var l=s[h];l.visible==!1||l.calculative.inView==!1||l.locked===ze.Disable||l.calculative.active||Da(n,l.calculative.worldRect)&&((o=l==null?void 0:l.onMouseMove)===null||o===void 0||o.call(l,l,n))}}},this.getHover=function(n){var o,s;if(!r.dragRect){var h=be.None;r.store.hover=void 0,r.store.hoverAnchor=void 0,r.title.hide(),r.store.pointAt=void 0,r.store.pointAtIndex=void 0;var l=r.store.active.length===1&&r.store.active[0].type;if(!r.drawingLineName&&r.hotkeyType!==Ke.AddAnchor&&r.activeRect&&!l&&!r.store.data.locked){var c=Zl(r.store.active),f=hd(r.store.active)||r.store.options.disableRotate,v=fd(r.store.active)||r.store.options.disableSize;if(!c&&!f){var g={x:r.activeRect.center.x,y:r.activeRect.y-30};r.activeRect.rotate&&Ge(g,r.activeRect.rotate,r.activeRect.center),!r.hotkeyType&&Ia(n,g,r.pointSize)&&(h=be.Rotate,r.externalElements.style.cursor='url("'+r.store.options.rotateCursor+'"), auto')}if(!c&&!v)for(var y=0;y<8;y++){var p=y<4,m=r.hotkeyType===Ke.Resize||p&&!r.hotkeyType;if(m&&Ia(n,r.sizeCPs[y],r.pointSize)){var b=p?ed:td,x=0;Math.abs(r.activeRect.rotate%90-45)<25?(b=p?td:ed,x=Math.round((r.activeRect.rotate-45)/90)+(p?0:1)):x=Math.round(r.activeRect.rotate/90),h=be.Resize,r.resizeIndex=y,r.externalElements.style.cursor=b[(y+x)%4];break}}}h===be.None&&(h=r.inPens(n,r.store.data.pens)),!h&&!l&&Da(n,r.activeRect)&&(h=be.Node,r.externalElements.style.cursor="move"),r.hoverType=h,h===be.None&&(r.drawingLineName||r.pencil?r.externalElements.style.cursor="crosshair":r.mouseDown||(r.externalElements.style.cursor="default"),r.store.hover=void 0),r.store.lastHover!==r.store.hover&&(r.patchFlags=!0,r.store.lastHover&&(r.store.lastHover.calculative.hover=!1,yn(ri(r.store.lastHover,!0)||r.store.lastHover,!1),r.store.emitter.emit("leave",r.store.lastHover),r.tooltip.hide()),r.store.hover&&(r.store.hover.calculative.hover=!0,yn(ri(r.store.hover,!0)||r.store.hover),r.store.emitter.emit("enter",r.store.hover),r.tooltip.show(r.store.hover,n)),r.store.lastHover=r.store.hover),(s=(o=r.store.hover)===null||o===void 0?void 0:o.onMouseMove)===null||s===void 0||s.call(o,r.store.hover,r.mousePos)}},this.inPens=function(n,o){var s,h=be.None,l=function(v){var g,y,p,m,b=o[v];if(b.visible==!1||b.calculative.inView==!1||b.locked===ze.Disable)return"continue";var x=vs(b);if(!b.calculative.active&&!ea(n,b.calculative.worldRect,x)&&!Da(n,b.calculative.worldRect))return"continue";if(!r.store.data.locked&&r.hotkeyType!==Ke.Resize&&b.calculative.worldAnchors)try{for(var _=(g=void 0,at(b.calculative.worldAnchors)),k=_.next();!k.done;k=_.next()){var I=k.value;if(h=r.inAnchor(n,b,I),h){var P=ce(I);return Object.assign(P,n),r.title.show(P,b),"break-outer"}}}catch(ee){g={error:ee}}finally{try{k&&!k.done&&(y=_.return)&&y.call(_)}finally{if(g)throw g.error}}if(b.type){if(b.isRuleLine){var M=((s=r.store.options.ruleOptions)===null||s===void 0?void 0:s.height)||20;if(n.x+r.store.data.x>M&&n.y+r.store.data.y>M)return"break"}var L=WE(n,b);if(L)return!r.store.data.locked&&!b.locked?r.hotkeyType===Ke.AddAnchor?r.externalElements.style.cursor="pointer":r.externalElements.style.cursor="move":r.externalElements.style.cursor=r.store.options.hoverCursor,b.calculative.disabled&&(r.externalElements.style.cursor="not-allowed"),r.store.hover=b,r.store.pointAt=L.point,r.store.pointAtIndex=L.i,r.initTemplateCanvas([r.store.hover]),h=be.Line,"break"}else{if(b.children){var U=[];if(b.children.forEach(function(ee){r.store.pens[ee]&&U.push(r.store.pens[ee])}),h=r.inPens(n,U),h)return"break"}var $=!1;if(b.name==="line"?$=ea(n,b.calculative.worldRect,b.lineWidth):$=Da(n,b.calculative.worldRect),$){if(b.type===Ye.Node&&b.name==="line"){var S=aE(n,b.calculative.worldAnchors);if(!S)return"continue"}if(!r.store.data.locked&&!b.locked?r.hotkeyType===Ke.AddAnchor?r.externalElements.style.cursor="pointer":r.externalElements.style.cursor="move":r.externalElements.style.cursor=r.store.options.hoverCursor,b.calculative.disabled&&(r.externalElements.style.cursor="not-allowed"),r.store.hover=b,r.initTemplateCanvas([r.store.hover]),h=be.Node,r.store.pointAt=n,!n.ctrlKey){var T=r.store.hover.calculative.worldRect,R=T.x,O=T.y,K=T.ex,G=T.ey,ae=T.rotate,V=T.center;if(ae){var F=[{x:R,y:O},{x:K,y:O},{x:K,y:G},{x:R,y:G}];F.forEach(function(ee){Ge(ee,ae,V)});var q=F[F.length-1];try{for(var Y=(p=void 0,at(F)),W=Y.next();!W.done;W=Y.next()){var J=W.value;if(q.y>n.y!=J.y>n.y){var re=J.x+(n.y-J.y)*(q.x-J.x)/(q.y-J.y);Math.abs(re-r.store.pointAt.x)<10&&(r.store.pointAt.x=re)}q=J}}catch(ee){p={error:ee}}finally{try{W&&!W.done&&(m=Y.return)&&m.call(Y)}finally{if(p)throw p.error}}}else r.store.pointAt.x-10K&&(r.store.pointAt.x=K),r.store.pointAt.y-10G&&(r.store.pointAt.y=G)}return"break"}}};e:for(var c=o.length-1;c>=0;--c){var f=l(c);if(f==="break")break;switch(f){case"break-outer":break e}}return h},this.dockInAnchor=function(n){var o,s,h,l;r.store.hover=void 0;for(var c=r.store.data.pens.length-1;c>=0;--c){var f=r.store.data.pens[c];if(!(f.visible==!1||f.locked===ze.Disable||f===r.store.active[0])){var v=vs(f);if(v+=2*r.store.options.anchorRadius,!!ea(n,f.calculative.worldRect,v)&&(r.store.hover=f,r.hotkeyType!==Ke.Resize&&f.calculative.worldAnchors))try{for(var g=(o=void 0,at(f.calculative.worldAnchors)),y=g.next();!y.done;y=g.next()){var p=y.value;if(p.twoWay===At.In){var m=We(r.store.active[0]);if(r.store.activeAnchor.id!==m.id)continue}if(p.twoWay===At.Out){var b=lt(r.store.active[0]);if(r.store.activeAnchor.id!==b.id)continue}if(!(p.twoWay===At.DisableConnected||p.twoWay===At.Disable||((h=r.store.activeAnchor)===null||h===void 0?void 0:h.twoWay)===At.DisableConnectTo||((l=r.store.activeAnchor)===null||l===void 0?void 0:l.twoWay)===At.Disable)&&(r.title.hide(),r.inAnchor(n,f,p))){var x=ce(p);return Object.assign(x,n),r.title.show(x,f),!0}}}catch(_){o={error:_}}finally{try{y&&!y.done&&(s=g.return)&&s.call(g)}finally{if(o)throw o.error}}}}},this.render=function(n){if(n&&(r.opening=!1),!r.opening){var o;if(n==null||n===!0||n===1/0?(o=performance.now(),r.patchFlags=!0):n>1?o=n:o=performance.now(),!!r.patchFlags){if(o-r.lastRenderze.DisableEdit)){if(s===r.store.hoverAnchor){n.save();var h=r.store.hover.hoverAnchorColor||r.store.options.hoverAnchorColor;n.strokeStyle=h,n.fillStyle=h}n.beginPath();var l=s.radius||r.store.hover.anchorRadius||r.store.options.anchorRadius;if(r.store.hover.type&&!s.radius&&!r.store.hover.anchorRadius&&(l=3,r.store.hover.calculative.lineWidth>3&&(l=r.store.hover.calculative.lineWidth)),s.type===ir.Line){var c=r.store.pens[s.penId].rotate||0;r.store.pens[s.penId].calculative.flipX&&(c*=-1),r.store.pens[s.penId].calculative.flipY&&(c*=-1);var f=s.rotate+c;r.store.pens[s.penId].calculative.flipX&&(f*=-1),r.store.pens[s.penId].calculative.flipY&&(f*=-1),n.save(),n.translate(s.x,s.y),n.rotate(f*Math.PI/180),n.translate(-s.x,-s.y),n.rect(s.x-s.length*r.store.data.scale/2,s.y-l,s.length*r.store.data.scale,l*2),n.restore()}else n.arc(s.x,s.y,l,0,Math.PI*2);if(r.store.hover.type&&r.store.hoverAnchor===s?(n.save(),n.strokeStyle=r.store.hover.activeColor||r.store.options.activeColor,n.fillStyle=n.strokeStyle):(s.color||s.background)&&(n.save(),n.strokeStyle=s.color,n.fillStyle=s.background),n.fill(),n.stroke(),s===r.store.hoverAnchor&&n.restore(),(r.store.hover.type&&r.store.hoverAnchor===s||s.color||s.background)&&n.restore(),!r.store.hover.parentId&&r.store.hover.children&&r.store.hover.children.length>0&&s===r.store.hoverAnchor){n.save(),n.beginPath(),n.lineWidth=3;var h=r.store.hover.hoverAnchorColor||r.store.options.hoverAnchorColor;globalThis.pSBC&&(n.strokeStyle=globalThis.pSBC(.5,h)),n.arc(s.x,s.y,l+1.5,0,Math.PI*2),n.stroke(),n.restore()}}}))}r.hotkeyType!==Ke.AddAnchor&&!r.movingPens&&r.activeRect&&!(r.store.active.length===1&&r.store.active[0].type)&&!Zl(r.store.active)&&!fd(r.store.active)&&!r.store.options.disableSize&&(n.strokeStyle=r.store.options.activeColor,n.fillStyle="#ffffff",r.sizeCPs.forEach(function(s,h){r.activeRect.rotate&&(n.save(),n.translate(s.x,s.y),n.rotate(r.activeRect.rotate*Math.PI/180),n.translate(-s.x,-s.y)),(h<4||r.hotkeyType===Ke.Resize)&&(n.beginPath(),n.fillRect(s.x-4.5,s.y-4.5,8,8),n.strokeRect(s.x-5.5,s.y-5.5,10,10)),r.activeRect.rotate&&n.restore()})),!r.store.data.locked&&r.dragRect&&(n.save(),n.fillStyle=ls(r.store.options.dragColor,.2),n.strokeStyle=r.store.options.dragColor,n.beginPath(),n.strokeRect(r.dragRect.x,r.dragRect.y,r.dragRect.width,r.dragRect.height),n.fillRect(r.dragRect.x,r.dragRect.y,r.dragRect.width,r.dragRect.height),n.restore()),r.dock&&(n.strokeStyle=r.store.options.dockColor,r.dock.xDock&&(n.beginPath(),n.moveTo(r.dock.xDock.x,r.dock.xDock.y),n.lineTo(r.dock.xDock.x,r.dock.xDock.prev.y),n.stroke()),r.dock.yDock&&(n.beginPath(),n.moveTo(r.dock.yDock.x,r.dock.yDock.y),n.lineTo(r.dock.yDock.prev.x,r.dock.yDock.y),n.stroke())),n.restore()}},this.pastePen=function(n,o){var s,h,l=n.id;if(vd(n),n.parentId=o,n.type===Ye.Line?r.changeNodeConnectedLine(l,n,r.store.clipboard.pens):r.changeLineAnchors(l,n,r.store.clipboard.pens),!n.parentId){var c=r.getPenRect(n,r.store.clipboard.origin,r.store.clipboard.scale),f=r.getPenRect(r.store.clipboard.initRect,r.store.clipboard.origin,r.store.clipboard.scale),v=r.store.data,g=v.origin,y=v.scale;n.x=g.x+c.x*y,n.y=g.y+c.y*y,n.width=c.width*y,n.height=c.height*y,f.x=g.x+f.x*y,f.y=g.y+f.y*y,tt(f),r.store.clipboard.pos&&(n.x-=f.center.x-r.store.clipboard.pos.x,n.y-=f.center.y-r.store.clipboard.pos.y),r.keyOptions&&r.keyOptions.altKey&&(r.keyOptions.ctrlKey||r.keyOptions.metaKey)?(n.x=-r.store.data.x+r.width/2-n.width/2,n.y=-r.store.data.y+r.height/2-n.height/2):r.keyOptions&&r.keyOptions.shiftKey&&(r.keyOptions.ctrlKey||r.keyOptions.metaKey)||(n.x+=r.store.clipboard.offset*r.store.data.scale,n.y+=r.store.clipboard.offset*r.store.data.scale)}r.makePen(n);var p=[];if(Array.isArray(n.children)){var m=function(k){var I=r.store.clipboard.pens.find(function(P){return P.id===k});I&&p.push(r.pastePen(I,n.id).id)};try{for(var b=at(n.children),x=b.next();!x.done;x=b.next()){var _=x.value;m(_)}}catch(k){s={error:k}}finally{try{x&&!x.done&&(h=b.return)&&h.call(b)}finally{if(s)throw s.error}}}return n.children=p,Cr(n,!0),n},this.ondblclick=function(n){r.store.hover&&(!r.store.data.locked||r.store.hover.dbInput)&&!r.store.options.disableInput&&(r.store.hover.onShowInput?r.store.hover.onShowInput(r.store.hover,n):r.showInput(r.store.hover)),r.store.emitter.emit("dblclick",{x:n.x,y:n.y,pen:r.store.hover})},this.showInput=function(n,o,s){if(s===void 0&&(s="transparent"),!(!window||!r.store.hover||r.store.hover.locked||r.store.hover.externElement||r.store.hover.disableInput||r.store.hover.disabled)){if(r.inputDiv.dataset.penId===n.id){r.inputDiv.dataset.isInput="true",r.inputDiv.contentEditable="true",r.inputDiv.focus();var h=window.getSelection();h.selectAllChildren(r.inputDiv),h.collapseToEnd(),r.inputDiv.scrollTop=r.inputDiv.scrollHeight,r.inputDiv.scrollLeft=r.inputDiv.scrollWidth;return}!o&&!n.dbInput?r.setInputStyle(n):(r.inputDiv.style.width="100%",r.inputDiv.style.height="100%");var l=o||n.calculative.worldTextRect,c=n.calculative.tempText===void 0?n.text+""||"":n.calculative.tempText,f=c.replace(/\x20/g," ").split(/[\s\n]/),v=(f.join("
")+"
").replace("","").replace(/\\<\/div\>/g,"

");r.inputDiv.innerHTML=v,r.inputParent.style.left=l.x+r.store.data.x-(n.textLeft||0)+"px",r.inputParent.style.top=l.y+r.store.data.y-(n.textTop||0)+"px";var g=l.width+(n.textLeft||0);r.inputParent.style.width=(g<0?12:g)+"px",r.inputParent.style.height=l.height+(n.textTop||0)+"px",r.inputParent.style.zIndex="9999",r.inputParent.style.background=s,n.rotate%360?r.inputParent.style.transform="rotate("+n.rotate+"deg)":r.inputParent.style.transform=null,r.inputParent.style.display="flex",r.inputDiv.dataset.penId=n.id,r.inputDiv.contentEditable=n.disableInput==null?"true":n.disableInput.toString(),n.dropdownList&&r.dropdown.style.display!=="block"?(r.store.data.locked||(r.inputRight.style.display="none"),r.setDropdownList()):r.inputRight.style.display="none",r.inputDiv.contentEditable="true",r.inputDiv.focus();var y=window.getSelection();y.selectAllChildren(r.inputDiv),y.collapseToEnd(),r.inputDiv.scrollTop=r.inputDiv.scrollHeight,r.inputDiv.scrollLeft=r.inputDiv.scrollWidth,n.calculative.text=void 0,r.initTemplateCanvas([n]),r.render()}},this.setInputStyle=function(n){n.text||(n.text="");for(var o,s=0;s1?n.textLeft*c:n.textLeft*c/f)+"px;"),n.textTop&&(h+="margin-top:"+(f>1?n.textTop*c:n.textTop*c/f)+"px;"),n.lineHeight&&(h+="line-height:"+(f>1?n.fontSize*n.lineHeight*f:n.fontSize*n.lineHeight*c)+"px;"),n.textHeight)h+="height:"+(f>1?n.textHeight*c*f:n.textHeight*c)+"px;";else{var y=n.calculative.worldRect.height/f-(n.textTop||0);y<0&&(y=0);var p=n.fontSize*f<12?y*c:y*f*c;p-1?n.textWidth*n.calculative.worldRect.width:n.textWidth,n.whiteSpace!=="pre-line"&&(m1?m*c*f:m*c)+"px;");else if(n.whiteSpace===void 0||n.whiteSpace==="break-all"){var y=(n.calculative.worldTextRect.width||12)/f;y<0&&(y=0),h+="width:"+(n.fontSize*f<12?y*c:y*f)+"px;"}if(n.whiteSpace&&(n.whiteSpace==="pre-line"?h+="white-space:pre;":(h+="white-space:"+n.whiteSpace+";",n.whiteSpace==="nowrap"&&(l+="display:contents;"))),n.whiteSpace!=="nowrap"){var b=n.fontSize*1.2*n.text.length,x=(m||n.calculative.worldRect.width/f)*Math.floor(n.calculative.worldRect.height/f/(n.lineHeight*n.fontSize));b>x&&(h+="justify-content: start;")}o.deleteRule(0),o.deleteRule(0),o.insertRule(`.meta2d-input .input-div{ resize:none;border:none;outline:none;background:transparent;position:absolute;flex-grow:1;height:100%;width: 100%;position:absolute;left:0;top:0;display:flex;flex-direction: column;cursor: text;`+h+"}"),o.insertRule(".input-div div{"+l+"}")},this.hideInput=function(){if(r.inputParent.style.display==="flex"){r.inputParent.style.display="none";var n=r.store.pens[r.inputDiv.dataset.penId];if(!n)return;if(n.calculative.text=n.text,r.inputDiv.dataset.value=r.inputDiv.innerHTML.replace(/\/g,` `).replace(/\<\/div\>/g,"").replace(/\/g,"").replace(/ /g," ").replace(/(<([^>]+)>)/gi,""),r.inputDiv.dataset.value=r.convertSpecialCharacter(r.inputDiv.dataset.value),n.onInput)n.onInput(n,r.inputDiv.dataset.value);else if(n.text!==r.inputDiv.dataset.value){var o=[ce(n,!0)];n.text=r.inputDiv.dataset.value,n.calculative.text=n.text,r.inputDiv.dataset.penId=void 0,n.name==="text"&&n.textAutoAdjust&&n2(n),Ni(n),r.patchFlags=!0,r.pushHistory({type:we.Update,pens:[ce(n,!0)],initPens:o}),r.store.emitter.emit("valueUpdate",n)}else n.text===r.inputDiv.dataset.value&&n.calculative.textLines.length==0&&Ni(n);r.initTemplateCanvas([n])}r.inputDiv.dataset.penId=void 0,r.dropdown.style.display="none",r.inputDiv.dataset.isInput="false",r.inputDiv.contentEditable="false",r.render()},this.setDropdownList=function(n){var o,s;r.clearDropdownList();var h=r.store.pens[r.inputDiv.dataset.penId];if(!(!r.store.data.locked&&!["table"].includes(h.name))){if(r.dropdown.style.display="block",r.inputRight.style.display="block",setTimeout(function(){r.inputRight.style.transform="rotate(315deg)",r.inputRight.style.zoom=r.store.data.scale}),!h||!h.dropdownList){r.dropdown.style.display="none",r.inputRight.style.display="none",r.inputRight.style.transform="rotate(135deg)";return}if(!h.dropdownList.length){var l=document.createElement("div");l.innerText="None",l.style.padding="5px 12px",l.style.color="#ddd",r.dropdown.appendChild(l);return}var c=r.inputDiv.innerHTML.replace(/\/g,` `).replace(/\<\/div\>/g,"").replace(/\/g,""),f=0;try{for(var v=at(h.dropdownList),g=v.next();!g.done;g=v.next()){var y=g.value,p=typeof y=="string"?y:y.text;n&&c?p.includes(c)&&r.dropdownAppendOption(p,f):r.dropdownAppendOption(p,f),++f}}catch(m){o={error:m}}finally{try{g&&!g.done&&(s=v.return)&&s.call(v)}finally{if(o)throw o.error}}if(!r.dropdown.hasChildNodes()){var l=document.createElement("div");l.innerText="None",l.style.padding="5px 12px",l.style.color="#ddd",r.dropdown.appendChild(l)}}},this.selectDropdown=function(n){var o=n.target,s=r.store.pens[r.inputDiv.dataset.penId];if(!(!o||!s||!s.dropdownList)){var h=+o.dataset.i,l=s.dropdownList[h];if(!!l){var c=[ce(s,!0)];typeof l=="object"?(r.updateValue(s,Lt({},l)),s.calculative.text=void 0,r.calcActiveRect()):s.text=l+"",r.inputDiv.innerText=s.text,r.hideInput(),r.pushHistory({type:we.Update,pens:[ce(s,!0)],initPens:c}),r.render(),r.store.emitter.emit("valueUpdate",s)}}},this.canvasTemplate=new Lk(i,a),this.canvasTemplate.canvas.style.zIndex="1",this.canvasImageBottom=new Ld(i,a,!0),this.canvasImageBottom.canvas.style.zIndex="2",i.appendChild(this.canvas),this.canvas.style.position="absolute",this.canvas.style.backgroundRepeat="no-repeat",this.canvas.style.backgroundSize="100% 100%",this.canvas.style.zIndex="3",this.canvasImage=new Ld(i,a),this.canvasImage.canvas.style.zIndex="4",this.magnifierCanvas=new Tk(this,i,a),this.magnifierCanvas.canvas.style.zIndex="5",this.externalElements.style.position="absolute",this.externalElements.style.left="0",this.externalElements.style.top="0",this.externalElements.style.outline="none",this.externalElements.style.background="transparent",this.externalElements.style.zIndex="5",i.style.position="relative",i.appendChild(this.externalElements),this.createInput(),this.tooltip=new Sk(i,a),this.tooltip.box.onmouseleave=function(n){r.patchFlags=!0,r.store.lastHover&&(r.store.lastHover.calculative.hover=!1);var o=r.store.data.pens.find(function(s){return s.calculative.hover===!0});yn(o,!1)},this.dialog=new Rk(i),this.title=new Pk(i),this.store.options.scroll&&(this.scroll=new Sg(this)),this.store.dpiRatio=globalThis.devicePixelRatio||1,this.store.dpiRatio<1?this.store.dpiRatio=1:this.store.dpiRatio>1&&this.store.dpiRatio<1.5&&(this.store.dpiRatio=1.5),this.clientRect=this.externalElements.getBoundingClientRect(),this.listen(),window==null||window.addEventListener("resize",this.onResize),window==null||window.addEventListener("scroll",this.onScroll)}return e.prototype.listen=function(){var t=this;switch(this.externalElements.addEventListener("gesturestart",this.onGesturestart),this.externalElements.ondragover=function(i){return i.preventDefault()},this.externalElements.ondrop=this.ondrop,this.externalElements.oncontextmenu=function(i){return i.preventDefault()},this.store.options.interval=50,this.externalElements.ontouchstart=this.ontouchstart,this.externalElements.ontouchmove=this.ontouchmove,this.externalElements.ontouchend=this.ontouchend,this.externalElements.onmousedown=function(i){t.onMouseDown({x:i.offsetX,y:i.offsetY,clientX:i.clientX,clientY:i.clientY,pageX:i.pageX,pageY:i.pageY,ctrlKey:i.ctrlKey||i.metaKey,shiftKey:i.shiftKey,altKey:i.altKey,buttons:i.buttons})},this.externalElements.onmousemove=function(i){i.target===t.externalElements&&t.onMouseMove({x:i.offsetX,y:i.offsetY,clientX:i.clientX,clientY:i.clientY,pageX:i.pageX,pageY:i.pageY,ctrlKey:i.ctrlKey||i.metaKey,shiftKey:i.shiftKey,altKey:i.altKey,buttons:i.buttons})},this.externalElements.onmouseup=function(i){t.onMouseUp({x:i.offsetX,y:i.offsetY,clientX:i.clientX,clientY:i.clientY,pageX:i.pageX,pageY:i.pageY,ctrlKey:i.ctrlKey||i.metaKey,shiftKey:i.shiftKey,altKey:i.altKey,buttons:i.buttons,button:i.button})},this.externalElements.onmouseleave=function(i){t.store.data.pens.forEach(function(a){a.calculative.hover&&(a.calculative.hover=!1)}),t.store.hover&&(t.store.hover.calculative.hover=!1,t.store.hover=void 0),t.render(),i.toElement!==t.tooltip.box&&i.toElement!==t.tooltip.arrowUp&&i.toElement!==t.tooltip.arrowDown&&(t.tooltip.hide(),t.store.lastHover=void 0)},this.externalElements.ondblclick=this.ondblclick,this.externalElements.tabIndex=0,this.externalElements.onblur=function(){t.mouseDown=void 0},this.externalElements.onwheel=this.onwheel,document.addEventListener("copy",this.onCopy),document.addEventListener("cut",this.onCut),document.addEventListener("paste",this.onPaste),this.store.options.keydown){case $r.Document:document.addEventListener("keydown",this.onkeydown),document.addEventListener("keyup",this.onkeyup);break;case $r.Canvas:this.externalElements.addEventListener("keydown",this.onkeydown),this.externalElements.addEventListener("keyup",this.onkeyup);break}},e.prototype.splitLine=function(t,i){var a=t.calculative.worldAnchors,r=a.findIndex(function(c){return c===i});if(![-1,0,a.length-1].includes(r)){var n=ce(t,!0),o=ce(t,!0),s=Me();o.id=s,o.calculative.canvas=this,o.calculative.active=!1,o.calculative.hover=!1;var h=ce(a.slice(0,r+1)),l=ce(a.slice(r)).map(function(c){return c.penId=s,c});t.calculative.worldAnchors=h,o.calculative.worldAnchors=l,this.initLineRect(t),this.initLineRect(o),this.store.data.pens.push(o),this.store.pens[s]=o,this.pushHistory({type:we.Add,pens:[ce(o,!0)],step:2}),this.pushHistory({type:we.Update,initPens:[n],pens:[ce(t,!0)],step:2})}},e.prototype.translateAnchor=function(t,i){var a=this;this.movingAnchor.x+=t,this.movingAnchor.y+=i;var r=this.movingAnchor.penId;if(r){var n=this.store.pens[r],o=n.calculative.worldRect;this.movingAnchor.xo.ex&&(this.movingAnchor.x=o.ex),this.movingAnchor.yo.ey&&(this.movingAnchor.y=o.ey);var s=xn(this.movingAnchor,o),h=n.anchors.findIndex(function(l){return l.id===a.movingAnchor.id});n.anchors[h]=s,this.patchFlags=!0}},e.prototype.fileToPen=function(t,i){return Ei(this,void 0,void 0,function(){var a;return ki(this,function(r){switch(r.label){case 0:return a="",this.store.options.uploadFn?[4,this.store.options.uploadFn(t)]:[3,2];case 1:return a=r.sent(),[3,6];case 2:return this.store.options.uploadUrl?[4,c2(t,this.store.options.uploadUrl,this.store.options.uploadParams,this.store.options.uploadHeaders)]:[3,4];case 3:return a=r.sent(),[3,6];case 4:return[4,l2(t)];case 5:a=r.sent(),r.label=6;case 6:return[2,new Promise(function(n,o){var s=new Image;s.onload=function(){ke.htmlElements[a]=s,n({width:s.width,height:s.height,name:i?"gif":"image",image:a})},s.onerror=function(h){o(h)},s.crossOrigin="anonymous",s.src=a})]}})})},e.prototype.dropPens=function(t,i){var a;return Ei(this,void 0,void 0,function(){var r,n,x,o,s,x,h,l,x,c,f,x,v,g,y,p,m,b,x,_,k,I,P,M,L,U,$,S,T,R,O=this;return ki(this,function(K){switch(K.label){case 0:this.randomIdObj={};try{for(r=at(t),n=r.next();!n.done;n=r.next())x=n.value,!x.parentId&&this.randomCombineId(x,t)}catch(G){k={error:G}}finally{try{n&&!n.done&&(I=r.return)&&I.call(r)}finally{if(k)throw k.error}}if(Object.keys(this.randomIdObj).length!==0)try{for(o=at(t),s=o.next();!s.done;s=o.next())x=s.value,x.type?(x.anchors[0].connectTo=this.randomIdObj[x.anchors[0].connectTo],x.anchors[x.anchors.length-1].connectTo=this.randomIdObj[x.anchors[x.anchors.length-1].connectTo]):(a=x.connectedLines)===null||a===void 0||a.forEach(function(G){G.lineAnchor=O.randomIdObj[G.lineAnchor],G.lineId=O.randomIdObj[G.lineId]})}catch(G){P={error:G}}finally{try{s&&!s.done&&(M=o.return)&&M.call(o)}finally{if(P)throw P.error}}try{for(h=at(t),l=h.next();!l.done;l=h.next())x=l.value,x.id||(x.id=Me()),!x.calculative&&(x.calculative={canvas:this}),this.store.pens[x.id]=x}catch(G){L={error:G}}finally{try{l&&!l.done&&(U=h.return)&&U.call(h)}finally{if(L)throw L.error}}try{for(c=at(t),f=c.next();!f.done;f=c.next())x=f.value,x.parentId||(x.width*=this.store.data.scale,x.height*=this.store.data.scale,x.x=i.x-x.width/2,x.y=i.y-x.height/2,x.tags&&x.tags.includes("meta3d")&&(x.x=this.store.data.origin.x,x.y=this.store.data.origin.y))}catch(G){$={error:G}}finally{try{f&&!f.done&&(S=c.return)&&S.call(c)}finally{if($)throw $.error}}if(v=this.store.data.width||this.store.options.width,g=this.store.data.height||this.store.options.height,v&&g){y={x:this.store.data.origin.x,y:this.store.data.origin.y,width:v*this.store.data.scale,height:g*this.store.data.scale},p=!0;try{for(m=at(t),b=m.next();!b.done;b=m.next())if(x=b.value,!x.parentId&&(_=[{x:x.x,y:x.y},{x:x.x+x.width,y:x.y},{x:x.x,y:x.y+x.height},{x:x.x+x.width,y:x.y+x.height},{x:x.x+x.width/2,y:x.y+x.height/2}],x.x===y.x&&x.y===y.y&&x.width===y.width&&x.height===y.height||_.some(function(G){return Da(G,y)}))){p=!1,this.store.options.strictScope&&(x.xy.x+y.width&&(x.x=y.x+y.width-x.width),x.y+x.height>y.y+y.height&&(x.y=y.y+y.height-x.height));break}}catch(G){T={error:G}}finally{try{b&&!b.done&&(R=m.return)&&R.call(m)}finally{if(T)throw T.error}}if(p)return console.info("\u753B\u7B14\u5728\u5927\u5C4F\u8303\u56F4\u5916"),[2]}return[4,this.addPens(t,!0)];case 1:return K.sent(),this.active(t.filter(function(G){return!G.parentId})),this.render(),this.externalElements.focus(),[2]}})})},e.prototype.randomCombineId=function(t,i,a){var r,n,o=null;t.type?(t.anchors[0].connectTo||t.anchors[t.anchors.length-1].connectTo)&&(o=[t.id,t.anchors[0].id,t.anchors[t.anchors.length-1].id]):t.connectedLines&&t.connectedLines.length&&(o=[t.id]),vd(t),o&&(o.length===1?this.randomIdObj[o[0]]=t.id:(this.randomIdObj[o[0]]=t.id,this.randomIdObj[o[1]]=t.anchors[0].id,this.randomIdObj[o[2]]=t.anchors[t.anchors.length-1].id)),t.parentId=a;var s=[];if(Array.isArray(t.children)){var h=function(g){var y=i.find(function(p){return p.id===g});y&&s.push(l.randomCombineId(y,i,t.id).id)},l=this;try{for(var c=at(t.children),f=c.next();!f.done;f=c.next()){var v=f.value;h(v)}}catch(g){r={error:g}}finally{try{f&&!f.done&&(n=c.return)&&n.call(c)}finally{if(r)throw r.error}}}return t.children=s,t},e.prototype.addPens=function(t,i){return Ei(this,void 0,void 0,function(){var a,r,n,o,s,h,l;return ki(this,function(c){switch(c.label){case 0:return a=this.beforeAddPens,a?[4,this.beforeAddPens(t)]:[3,2];case 1:a=c.sent()!=!0,c.label=2;case 2:if(a)return[2,[]];r=[];try{for(n=at(t),o=n.next();!o.done;o=n.next())s=o.value,!(this.beforeAddPen&&this.beforeAddPen(s)!=!0)&&(this.makePen(s),r.push(s))}catch(f){h={error:f}}finally{try{o&&!o.done&&(l=n.return)&&l.call(n)}finally{if(h)throw h.error}}return this.render(),this.store.emitter.emit("add",r),i&&this.pushHistory({type:we.Add,pens:ce(r,!0)}),[2,r]}})})},e.prototype.getInitPencilLine=function(t){var i=this.store,a=i.data,r=i.options,n=a.scale,o=a.lineWidth||1;return{id:t.penId,name:"line",x:t.x,y:t.y,type:Ye.Line,calculative:{canvas:this,pencil:!0,active:!0,worldAnchors:[t],lineWidth:o*n},fromArrow:a.fromArrow||r.fromArrow,toArrow:a.toArrow||r.toArrow,lineWidth:o}},e.prototype.createDrawingLine=function(t){this.inactive();var i=this.store,a=i.data,r=i.options,n=a.scale,o=a.lineWidth||1;return t.penId=Me(),{id:t.penId,name:"line",lineName:this.drawingLineName,x:t.x,y:t.y,type:Ye.Line,calculative:{canvas:this,active:!0,worldAnchors:[t],lineWidth:o*n},fromArrow:a.fromArrow||r.fromArrow,toArrow:a.toArrow||r.toArrow,lineWidth:o}},e.prototype.addRuleLine=function(t){var i=this.store.data,a=i.x,r=i.y,n=i.scale,o=i.origin,s=t.x+a,h=t.y+r,l=t.x,c=t.y,f=0,v=0,g=0,y=0;if(s<=h&&s<20)l=-a,f=this.width,g=1,t.ctrlKey||(c=Math.round((c-o.y)/(n*10))*(n*10)+o.y);else if(h0?a-=180:a+=180)):i.y>t.y?a=90:i.yze.DisableEdit||!(i.type&&i.calculative.active)&&this.store.options.disableAnchor||i.disableAnchor)return be.None;if((this.mouseDown||this.drawingLine)&&i.name==="line"&&a.connectTo){var n=this.findOne(a.connectTo);if((n==null?void 0:n.calculative)&&!(n!=null&&n.calculative.active)){i=n;var o=n.calculative.worldAnchors.find(function(h){return h.id===a.anchorId});o&&(a=o)}}if(a.twoWay===At.Disable&&i.name!=="line")return be.None;if(i.name==="line"&&a.connectTo){var s=(r=this.findOne(a.connectTo))===null||r===void 0?void 0:r.anchors.find(function(h){return h.id===a.anchorId});if(s&&s.twoWay)return be.None}if(this.drawingLine){if(a.twoWay===At.Out)return be.None}else if(!(this.mouseDown&&this.hoverType===be.LineAnchor)){if(a.twoWay===At.In)return be.None}if(Ia(t,a,this.pointSize,a.penId?this.store.pens[a.penId]:void 0))return a!==this.store.hoverAnchor&&(this.patchFlags=!0),this.store.hoverAnchor=a,this.store.hover=i,i.type?a.connectTo&&!i.calculative.active&&(this.store.hover=this.store.pens[a.connectTo],this.store.hover)?(this.store.hoverAnchor=this.store.hover.calculative.worldAnchors.find(function(h){return h.id===a.anchorId}),this.store.hoverAnchor?(this.externalElements.style.cursor="crosshair",be.NodeAnchor):be.None):(this.hotkeyType===Ke.AddAnchor?this.externalElements.style.cursor="vertical-text":this.externalElements.style.cursor="pointer",be.LineAnchor):(this.hotkeyType===Ke.AddAnchor?this.externalElements.style.cursor="vertical-text":this.externalElements.style.cursor="crosshair",be.NodeAnchor);if(!this.mouseDown&&i.type){if(i.calculative.active&&a.prev&&Ia(t,a.prev,this.pointSize))return this.store.hoverAnchor=a,this.store.hover=i,this.externalElements.style.cursor="pointer",be.LineAnchorPrev;if(i.calculative.active&&a.next&&Ia(t,a.next,this.pointSize))return this.store.hoverAnchor=a,this.store.hover=i,this.externalElements.style.cursor="pointer",be.LineAnchorNext}return be.None},e.prototype.resize=function(t,i){var a,r;t=t||this.parentElement.clientWidth,i=i||this.parentElement.clientHeight,this.width=t,this.height=i,this.canvasRect={x:0,y:0,width:t,height:i},ot(this.canvasRect),this.canvas.style.width=t+"px",this.canvas.style.height=i+"px",this.externalElements.style.width=t+"px",this.externalElements.style.height=i+"px",this.canvasTemplate.resize(t,i),this.canvasImage.resize(t,i),this.canvasImageBottom.resize(t,i),this.magnifierCanvas.resize(t,i),t=t*this.store.dpiRatio|0,i=i*this.store.dpiRatio|0,this.canvas.width=t,this.canvas.height=i,this.offscreen.width=t,this.offscreen.height=i,this.clientRect=this.externalElements.getBoundingClientRect(),this.canvas.getContext("2d").scale(this.store.dpiRatio,this.store.dpiRatio),this.offscreen.getContext("2d").scale(this.store.dpiRatio,this.store.dpiRatio),this.offscreen.getContext("2d").textBaseline="middle";try{for(var n=at(this.store.data.pens),o=n.next();!o.done;o=n.next()){var s=o.value;s.isRuleLine&&(s.width?s.height||(s.width=this.width):s.height=this.height),Cr(s)}}catch(h){a={error:h}}finally{try{o&&!o.done&&(r=n.return)&&r.call(n)}finally{if(a)throw a.error}}this.render()},e.prototype.clearCanvas=function(){this.activeRect=void 0,this.sizeCPs=void 0,this.canvas.getContext("2d").clearRect(0,0,this.canvas.width,this.canvas.height),this.offscreen.getContext("2d").clearRect(0,0,this.offscreen.width,this.offscreen.height),this.store.data.template||this.canvasTemplate.clear(),this.canvasImage.clear(),this.canvasImageBottom.clear()},e.prototype.addPen=function(t,i,a){return Ei(this,void 0,void 0,function(){var r;return ki(this,function(n){switch(n.label){case 0:return r=this.beforeAddPens,r?[4,this.beforeAddPens([t])]:[3,2];case 1:r=n.sent()!=!0,n.label=2;case 2:return r?[2]:this.beforeAddPen&&this.beforeAddPen(t)!=!0?[2]:(this.makePen(t),this.active([t]),this.render(),a&&this.store.emitter.emit("add",[t]),i&&this.pushHistory({type:we.Add,pens:[t]}),[2,t])}})})},e.prototype.pushHistory=function(t){var i=this,a;if(!this.store.data.locked){var r=this.store.data,n=r.origin,o=r.scale;t.origin=ce(n),t.scale=o,t.type!==we.Update&&t.pens&&t.pens.forEach(function(s){s.calculative&&(s.calculative.layer=i.store.data.pens.findIndex(function(h){return h.id===s.id}))}),this.store.historyIndex1;){var a=this.store.histories[this.store.historyIndex--];this.doEditAction(a,!0),i--}(t.type==we.Add||t.type==we.Delete||t.type==we.Update)&&this.activeHistory()}},e.prototype.redo=function(){if(!(this.store.data.locked||this.store.historyIndex==null||this.store.historyIndex>this.store.histories.length-2)){var t=this.store.histories[++this.store.historyIndex];this.doEditAction(t,!1);for(var i=t.step;i>1;){var a=this.store.histories[++this.store.historyIndex];this.doEditAction(a,!1),i--}(t.type==we.Add||t.type==we.Delete||t.type==we.Update)&&this.activeHistory()}},e.prototype.activeHistory=function(){var t=this,i=this.store.histories[this.store.historyIndex+1],a=[];if(i&&i.type===we.Update){i.pens.forEach(function(n){a.push(t.store.pens[n.id])}),this.active(a);return}var r=this.store.histories[this.store.historyIndex];r&&(r.type===we.Add||r.type===we.Delete)&&(r.pens.forEach(function(n){a.push(t.store.pens[n.id])}),this.active(a))},e.prototype.doEditAction=function(t,i){var a=this;switch(this.inactive(),this.store.hoverAnchor=void 0,this.store.hover=void 0,t.type){case we.Add:t.pens.forEach(function(h){var l,c=ce(h,!0),f=a.store.data.pens.findIndex(function(v){return v.id===c.id});f>-1&&((l=c.onDestroy)===null||l===void 0||l.call(c,a.store.pens[c.id]),a.store.data.pens.splice(f,1),a.store.pens[c.id]=void 0,c.calculative||(c.calculative={}),c.calculative.canvas=a,a.store.animates.delete(c),a.store.animateMap.delete(c))}),t.type=we.Delete;break;case we.Update:var r=i?t.initPens:t.pens,n=i?t.pens:t.initPens;r.forEach(function(h){var l=ce(h,!0),c=a.store.data.pens.findIndex(function(p){return p.id===l.id});if(c>-1){if(l.calculative=a.store.data.pens[c].calculative,a.store.data.pens[c].type&&a.store.data.pens[c].lastConnected)for(var f in a.store.data.pens[c].lastConnected)a.store.pens[f].connectedLines=a.store.data.pens[c].lastConnected[f];a.store.data.pens[c]=l,a.store.pens[l.id]=l;for(var v in l)(typeof l[v]!="object"||v==="lineDash")&&(l.calculative[v]=l[v]);l.calculative.image=void 0;var g=a.getPenRect(l,t.origin,t.scale);if(a.setPenRect(l,g,!1),a.updateLines(l,!0),l.calculative.canvas.parent.isCombine(l)){var y=n.find(function(p){return p.id===l.id});$v.forEach(function(p){var m;l[p]!==y[p]&&a.parent.setValue((m={id:l.id},m[p]=l[p],m),{render:!0,doEvent:!1})})}}});break;case we.Delete:t.pens.reverse().forEach(function(h){var l,c,f=ce(h,!0);if(f.calculative||(f.calculative={}),a.store.data.pens.splice(((l=f.calculative)===null||l===void 0?void 0:l.layer)!==-1?(c=f.calculative)===null||c===void 0?void 0:c.layer:a.store.data.pens.length,0,f),a.store.pens[f.id]=f,f.type&&f.lastConnected)for(var v in f.lastConnected)a.store.pens[v].connectedLines=f.lastConnected[v];f.calculative.canvas=a}),t.pens.reverse().forEach(function(h){var l=a.store.pens[h.id],c=a.getPenRect(l,t.origin,t.scale);a.setPenRect(l,c,!1),l.calculative.image=void 0,l.calculative.backgroundImage=void 0,l.calculative.strokeImage=void 0,a.loadImage(l)}),t.type=we.Add;break;case we.Replace:{var o=i?t.initPens:t.pens,s=i?t.pens:t.initPens;s.forEach(function(h){var l,c=ce(h,!0),f=a.store.data.pens.findIndex(function(g){return g.id===c.id});if(f>-1){(l=c.onDestroy)===null||l===void 0||l.call(c,a.store.data.pens.find(function(g){return g.id===c.id}));var v=a.store.data.pens.findIndex(function(g){return g.id===c.id});a.store.data.pens.splice(v,1),a.store.pens[c.id]=void 0,c.calculative||(c.calculative={}),c.calculative.canvas=a,a.store.animates.delete(c),a.store.animateMap.delete(c)}}),o.reverse().forEach(function(h){var l,c,f=ce(h,!0);if(f.calculative||(f.calculative={}),a.store.data.pens.splice(((l=f.calculative)===null||l===void 0?void 0:l.layer)!==-1?(c=f.calculative)===null||c===void 0?void 0:c.layer:a.store.data.pens.length,0,f),a.store.pens[f.id]=f,f.type&&f.lastConnected)for(var v in f.lastConnected)a.store.pens[v].connectedLines=f.lastConnected[v];f.calculative.canvas=a}),o.reverse().forEach(function(h){var l=a.store.data.pens.find(function(f){return f.id===h.id}),c=a.getPenRect(l,t.origin,t.scale);a.setPenRect(l,c,!1),l.calculative.image=void 0,l.calculative.backgroundImage=void 0,l.calculative.strokeImage=void 0,a.loadImage(l)}),t.type=we.Replace;break}}if(t.type===we.Update){var r=Di(Di([],Li(t.pens),!1),Li(t.initPens),!1);this.initImageCanvas(r),this.initTemplateCanvas(r)}else this.initImageCanvas(t.pens),this.initTemplateCanvas(t.pens);this.parent.onSizeUpdate(),this.render(),this.store.emitter.emit(i?"undo":"redo",t)},e.prototype.makePen=function(t){var i=this,a;if(t.id||(t.id=Me()),Math.abs(this.store.lastScale-this.store.data.scale)<1e-4&&this.store.sameTemplate&&this.store.templatePens[t.id]&&t.canvasLayer===Ne.CanvasTemplate){t=this.store.templatePens[t.id],this.store.data.pens.push(t),this.updatePenRect(t);return}if(this.store.data.pens.push(t),this.store.pens[t.id]=t,t.path){!t.pathId&&(t.pathId=Me());var r=this.store.data.paths;!r[t.pathId]&&(r[t.pathId]=t.path),t.path=void 0}t.lineWidth==null&&(t.lineWidth=1);var n=this.store.options,o=n.fontSize,s=n.lineHeight;t.fontSize||(t.fontSize=o),t.lineHeight||(t.lineHeight=s),t.image&&t.name!=="gif"&&t.canvasLayer===void 0&&(t.isBottom?t.canvasLayer=Ne.CanvasImageBottom:t.canvasLayer=Ne.CanvasImage,delete t.isBottom),t.template&&(t.canvasLayer=Ne.CanvasTemplate),t.calculative={canvas:this,singleton:(a=t.calculative)===null||a===void 0?void 0:a.singleton},(t.video||t.audio)&&(t.calculative.onended=function(l){i.nextAnimate(l)});for(var h in t)(typeof t[h]!="object"||h==="lineDash")&&(t.calculative[h]=t[h]);t.calculative.image=void 0,t.calculative.backgroundImage=void 0,t.calculative.strokeImage=void 0,!t.anchors&&ke.anchors[t.name]&&(t.anchors||(t.anchors=[]),ke.anchors[t.name](t)),this.updatePenRect(t),!t.anchors&&t.calculative.worldAnchors&&(t.anchors=t.calculative.worldAnchors.map(function(l){return xn(l,t.calculative.worldRect)})),!t.rotate&&(t.rotate=0),this.loadImage(t),this.parent.penNetwork(t)},e.prototype.drawline=function(t){var i;!this.drawingLine||((i=this[this.drawingLineName])===null||i===void 0||i.call(this,this.store,this.drawingLine,t),this.store.path2dMap.set(this.drawingLine,ke.path2dDraws.line(this.drawingLine)),this.patchFlags=!0)},e.prototype.initLineRect=function(t){var i;if(!!t){if(!(!((i=t.calculative.worldAnchors)===null||i===void 0)&&i.length)){this._del([t]);return}if(!(!isFinite(t.x)||!isFinite(t.x))&&!(t.x==null||t.y==null)){var a=Hc(t);t.parentId||Object.assign(t,a);var r=this.store.options,n=r.fontSize,o=r.lineHeight;t.fontSize||(t.fontSize=n,t.calculative.fontSize=t.fontSize*this.store.data.scale),t.lineHeight||(t.lineHeight=o,t.calculative.lineHeight=t.lineHeight),tt(a),t.calculative.worldRect=a,nu(t,a),Ni(t),Cr(t),t.calculative&&(t.calculative.gradientAnimatePath=void 0),this.store.path2dMap.set(t,ke.path2dDraws[t.name](t)),t.calculative.worldAnchors&&(t.anchors=t.calculative.worldAnchors.map(function(s){return xn(s,t.calculative.worldRect)}))}}},e.prototype.drawingPencil=function(){Tg(this.store),this.pencil=!0,this.externalElements.style.cursor="crosshair"},e.prototype.stopPencil=function(){this.pencil=!1,this.pencilLine=void 0,this.externalElements.style.cursor="default"},e.prototype.finishDrawline=function(t){return Ei(this,void 0,void 0,function(){var i,a,r,n,o,s,h=this;return ki(this,function(l){switch(l.label){case 0:if(!this.drawingLine)return[2];if(i=lt(this.drawingLine),a=We(this.drawingLine),a.isTemp&&(this.drawingLine.calculative.worldAnchors.pop(),a=We(this.drawingLine)),!t&&(!a.connectTo&&this.drawingLine.calculative.worldAnchors.pop(),lt(this.drawingLine)===this.drawingLine.calculative.activeAnchor))return this.drawingLine=void 0,this.render(),[2];if(!i.connectTo||!a.connectTo){if(this.store.options.disableEmptyLine)return i.connectTo&&(this.store.pens[i.connectTo].connectedLines=this.store.pens[i.connectTo].connectedLines.filter(function(c){return c.lineId!==h.drawingLine.id})),this.drawingLine=void 0,this.render(),[2]}else if(this.store.options.disableRepeatLine&&(r=this.store.data.pens.find(function(c){if(c.type){var f=lt(c),v=We(c);return id(f,i)&&id(v,a)}}),r))return this.drawingLine=void 0,this.render(),[2];return n=Hc(this.drawingLine),Object.assign(this.drawingLine,n),this.drawingLine.calculative.worldRect=n,this.drawingLine.calculative.activeAnchor=We(this.drawingLine),this.store.activeAnchor=this.drawingLine.calculative.activeAnchor,s=!this.beforeAddPens,s?[3,2]:[4,this.beforeAddPens([this.drawingLine])];case 1:s=l.sent(),l.label=2;case 2:return o=s&&(!this.beforeAddPen||this.beforeAddPen(this.drawingLine)),o&&(this.initLineRect(this.drawingLine),this.store.data.pens.push(this.drawingLine),this.store.pens[this.drawingLine.id]=this.drawingLine,this.store.emitter.emit("add",[this.drawingLine]),this.active([this.drawingLine]),this.pushHistory({type:we.Add,pens:ce([this.drawingLine],!0)})),this.store.path2dMap.set(this.drawingLine,ke.path2dDraws[this.drawingLine.name](this.drawingLine)),this.drawingLine=void 0,this.drawingLineName=void 0,this.render(),[2]}})})},e.prototype.finishPencil=function(){return Ei(this,void 0,void 0,function(){var t,i,a,r;return ki(this,function(n){switch(n.label){case 0:return this.pencilLine?(t=Wc(this.pencilLine.calculative.worldAnchors,10,0,this.pencilLine.calculative.worldAnchors.length-1),i=lt(this.pencilLine),t.unshift({id:i.id,penId:i.penId,x:i.x,y:i.y}),i=We(this.pencilLine),t.push({id:i.id,penId:i.penId,x:i.x,y:i.y}),this.pencilLine.calculative.worldAnchors=JE(t),this.pencilLine.calculative.worldAnchors.length>1?(this.pencilLine.calculative.pencil=!1,this.store.path2dMap.set(this.pencilLine,ke.path2dDraws[this.pencilLine.name](this.pencilLine)),r=!this.beforeAddPens,r?[3,2]:[4,this.beforeAddPens([this.pencilLine])]):[3,3]):[3,4];case 1:r=n.sent(),n.label=2;case 2:a=r&&(!this.beforeAddPen||this.beforeAddPen(this.pencilLine)),a&&(this.initLineRect(this.pencilLine),this.store.data.pens.push(this.pencilLine),this.store.pens[this.pencilLine.id]=this.pencilLine,this.store.emitter.emit("add",[this.pencilLine]),this.active([this.pencilLine]),this.pushHistory({type:we.Add,pens:ce([this.pencilLine],!0)})),n.label=3;case 3:this.pencilLine=void 0,this.render(),n.label=4;case 4:return[2]}})})},e.prototype.firefoxLoadSvg=function(t){var i=this,a=new Image,r=new XMLHttpRequest;r.open("GET",t.image,!0),r.onload=function(){var n=new DOMParser,o=n.parseFromString(r.responseText,"text/xml"),s=o.getElementsByTagName("svg")[0],h=t.calculative.worldRect,l=h.width,c=h.height;s.setAttribute("width",l+"px"),s.setAttribute("height",c+"px");var f=btoa(unescape(encodeURIComponent(new XMLSerializer().serializeToString(s)))),v="data:image/svg+xml;base64,"+f;a.src=v,a.onload=function(){t.calculative.img=a,t.calculative.imgNaturalWidth=a.naturalWidth||t.iconWidth,t.calculative.imgNaturalHeight=a.naturalHeight||t.iconHeight,ke.htmlElements[t.image]=a,i.imageLoaded(),t.canvasLayer===Ne.CanvasTemplate&&i.templateImageLoaded()}},r.send()},e.prototype.loadImage=function(t){var i=this;if(t.image!==t.calculative.image||!t.calculative.img){if(t.calculative.img=void 0,t.image)if(ke.htmlElements[t.image]){var a=ke.htmlElements[t.image];t.calculative.img=a,t.calculative.imgNaturalWidth=a.naturalWidth||t.iconWidth,t.calculative.imgNaturalHeight=a.naturalHeight||t.iconHeight,this.imageLoaded(),t.canvasLayer===Ne.CanvasTemplate&&this.templateImageLoaded()}else if(navigator.userAgent.includes("Firefox")&&t.image.endsWith(".svg"))this.firefoxLoadSvg(t);else{var r=new Image;r.crossOrigin=t.crossOrigin==="undefined"?void 0:t.crossOrigin||"anonymous",r.src=t.image,this.store.options.cdn&&!(t.image.startsWith("http")||t.image.startsWith("//")||t.image.startsWith("data:image"))&&(r.src=this.store.options.cdn+t.image),r.onload=function(){t.calculative.img=r,t.calculative.imgNaturalWidth=r.naturalWidth||t.iconWidth,t.calculative.imgNaturalHeight=r.naturalHeight||t.iconHeight,ke.htmlElements[t.image]=r,i.imageLoaded(),t.canvasLayer===Ne.CanvasTemplate&&i.templateImageLoaded()}}t.calculative.image=t.image}if(t.backgroundImage!==t.calculative.backgroundImage){if(t.calculative.backgroundImg=void 0,t.backgroundImage)if(ke.htmlElements[t.backgroundImage]){var a=ke.htmlElements[t.backgroundImage];t.calculative.backgroundImg=a}else{var n=new Image;n.crossOrigin="anonymous",n.src=t.backgroundImage,this.store.options.cdn&&!(t.backgroundImage.startsWith("http")||t.backgroundImage.startsWith("//")||t.backgroundImage.startsWith("data:image"))&&(n.src=this.store.options.cdn+t.backgroundImage),n.onload=function(){t.calculative.backgroundImg=n,ke.htmlElements[t.backgroundImage]=n,i.imageLoaded(),t.canvasLayer===Ne.CanvasTemplate&&i.templateImageLoaded()}}t.calculative.backgroundImage=t.backgroundImage}if(t.strokeImage!==t.calculative.strokeImage){if(t.calculative.strokeImg=void 0,t.strokeImage)if(ke.htmlElements[t.strokeImage]){var a=ke.htmlElements[t.strokeImage];t.calculative.strokeImg=a}else{var o=new Image;o.crossOrigin="anonymous",o.src=t.strokeImage,this.store.options.cdn&&!(t.strokeImage.startsWith("http")||t.strokeImage.startsWith("//")||t.strokeImage.startsWith("data:image"))&&(o.src=this.store.options.cdn+t.strokeImage),o.onload=function(){t.calculative.strokeImg=o,ke.htmlElements[t.strokeImage]=o,i.imageLoaded(),t.canvasLayer===Ne.CanvasTemplate&&t.name!=="gif"&&i.templateImageLoaded()}}t.calculative.strokeImage=t.strokeImage}},e.prototype.imageLoaded=function(){var t=this;this.imageTimer&&clearTimeout(this.imageTimer),this.imageTimer=setTimeout(function(){t.canvasImage.init(),t.canvasImageBottom.init(),t.render()},100)},e.prototype.templateImageLoaded=function(){var t=this;this.templateImageTimer&&clearTimeout(this.templateImageTimer),this.templateImageTimer=setTimeout(function(){t.canvasTemplate.init(),t.render()},100)},e.prototype.setCalculativeByScale=function(t){var i=this.store.data.scale;t.calculative.lineWidth=t.lineWidth*i,t.calculative.fontSize=t.fontSize*i,t.fontSize<1&&(t.calculative.fontSize=t.fontSize*t.calculative.worldRect.height),t.calculative.iconSize=t.iconSize*i,t.calculative.iconWidth=t.iconWidth*i,t.calculative.iconHeight=t.iconHeight*i,t.calculative.iconLeft=t.iconLeft<1&&t.iconLeft>-1?t.iconLeft:t.iconLeft*i,t.calculative.iconTop=t.iconTop<1&&t.iconTop>-1?t.iconTop:t.iconTop*i,t.calculative.textWidth=t.textWidth<1&&t.textWidth>-1?t.textWidth:t.textWidth*i,t.calculative.textHeight=t.textHeight<1&&t.textHeight>-1?t.textHeight:t.textHeight*i,t.calculative.textLeft=t.textLeft<1&&t.textLeft>-1?t.textLeft:t.textLeft*i,t.calculative.textTop=t.textTop<1&&t.textTop>-1?t.textTop:t.textTop*i,t.type===Ye.Line&&t.borderWidth&&(t.calculative.borderWidth=t.borderWidth*i)},e.prototype.updatePenRect=function(t,i){var a=this,r=i===void 0?{}:i,n=r.worldRectIsReady,o=r.playingAnimate;n?Yo(t):ug(t),o||this.setCalculativeByScale(t),_n(t),sd(this.store.pens,t),Ni(t),Cr(t),ke.path2dDraws[t.name]&&this.store.path2dMap.set(t,ke.path2dDraws[t.name](t)),t.calculative.patchFlags=!0,this.patchFlags=!0,t.children&&t.children.forEach(function(s){var h=a.store.pens[s];h&&a.updatePenRect(h,{worldRectIsReady:!1})}),t.type&&this.initLineRect(t),t.calculative.gradientTimer&&clearTimeout(t.calculative.gradientTimer),t.calculative.gradientTimer=setTimeout(function(){t.calculative.lineGradient&&(t.calculative.lineGradient=null),t.calculative.gradient&&(t.calculative.gradient=null),t.calculative.radialGradient&&(t.calculative.radialGradient=null),a.patchFlags=!0,t.calculative.gradientTimer=void 0},50)},e.prototype.translate=function(t,i){if(t===void 0&&(t=0),i===void 0&&(i=0),this.store.data.x+=t*this.store.data.scale,this.store.data.y+=i*this.store.data.scale,this.store.data.x=Math.round(this.store.data.x),this.store.data.y=Math.round(this.store.data.y),this.store.options.padding){var a=ar(this.store.options.padding),r=this.store.data.width||this.store.options.width,n=this.store.data.height||this.store.options.height;this.width<(r+a[1]+a[3])*this.store.data.scale&&(this.store.data.x+this.store.data.origin.x>a[3]*this.store.data.scale&&(this.store.data.x=a[3]*this.store.data.scale-this.store.data.origin.x),this.store.data.x+this.store.data.origin.x+r*this.store.data.scalea[0]*this.store.data.scale&&(this.store.data.y=a[0]*this.store.data.scale-this.store.data.origin.y),this.store.data.y+this.store.data.origin.y+n*this.store.data.scale=n&&t<=o){this.calibrateMouse(i);var s=t/this.store.data.scale;this.store.data.scale=t,this.store.data.center=i,!((r=this.store.clipboard)===null||r===void 0)&&r.pos&&os(this.store.clipboard.pos,s,i),os(this.store.data.origin,s,i),this.store.data.pens.forEach(function(l){if(!l.parentId){if(Aa(l,s,i),l.onScale&&l.onScale(l),l.isRuleLine){var c=1/s,f=l.calculative.worldRect.center;l.width&&l.height||Aa(l,c,f)}a.updatePenRect(l,{worldRectIsReady:!0}),a.execPenResize(l)}}),this.onMovePens(),this.calcActiveRect(),this.canvasTemplate.init(),this.canvasImage.init(),this.canvasImageBottom.init();var h=this.parent.map;h&&h.isShow&&h.setView(),this.render(),this.store.emitter.emit("scale",this.store.data.scale)}},e.prototype.templateScale=function(t,i){var a=this;i===void 0&&(i={x:0,y:0});var r=this.store.options,n=r.minScale,o=r.maxScale;if(t>=n&&t<=o){var s=t/this.store.data.scale;this.store.data.scale=t,this.store.data.center={x:0,y:0},this.store.data.origin={x:0,y:0},this.store.data.pens.forEach(function(h){if(!h.parentId){if(Aa(h,s,i),h.onScale&&h.onScale(h),h.isRuleLine){var l=s>1?1:1/s/s,c=h.calculative.worldRect.center;h.width&&h.height||Aa(h,l,c)}a.execPenResize(h)}}),this.calcActiveRect()}},e.prototype.rotatePens=function(t){var i,a,r=this;this.initPens||(this.initPens=ce(this.getAllByPens(this.store.active))),this.activeRect.rotate=gi(t,this.activeRect.center),this.activeRect.rotate%90<10&&(this.activeRect.rotate-=this.activeRect.rotate%90),this.activeRect.rotate%90>80&&(this.activeRect.rotate+=90-this.activeRect.rotate%90),this.store.active.length===1&&(this.lastRotate=this.store.active[0].rotate||0);var n=this.activeRect.rotate-this.lastRotate;try{for(var o=at(this.store.active),s=o.next();!s.done;s=o.next()){var h=s.value;if(h.parentId)return;this.rotatePen(h,n,this.activeRect),h.onRotate&&h.onRotate(h),this.updateLines(h)}}catch(l){i={error:l}}finally{try{s&&!s.done&&(a=o.return)&&a.call(o)}finally{if(i)throw i.error}}this.lastRotate=this.activeRect.rotate,this.getSizeCPs(),this.initImageCanvas(this.store.active),this.initTemplateCanvas(this.store.active),this.render(),this.store.emitter.emit("rotatePens",this.store.active),this.timer&&clearTimeout(this.timer),this.timer=setTimeout(function(){r.timer=void 0,r.pushHistory({type:we.Update,pens:ce(r.getAllByPens(r.store.active)),initPens:r.initPens}),r.initPens=void 0},200)},e.prototype.resizePens=function(t){var i=this;if(this.initPens||(this.initPens=ce(this.store.active,!0)),!this.initActiveRect){this.initActiveRect=ce(this.activeRect);return}var a={x:this.mouseDown.x,y:this.mouseDown.y},r={x:t.x,y:t.y},n=r.x-a.x,o=r.y-a.y,s=ce(this.initActiveRect);if(md(s,n,o,this.resizeIndex),tt(s),!this.store.options.disableDock){this.clearDock();var h=this.customResizeDock||V2;this.dock=h(this.store,s,this.store.active,this.resizeIndex);var l=this.dock,c=l.xDock,f=l.yDock;if(c){n+=c.step;var v=this.store.pens[c.penId];v.calculative.isDock=!0}if(f){o+=f.step;var v=this.store.pens[f.penId];v.calculative.isDock=!0}}var g=this.activeRect.width,y=this.activeRect.height,p=n-this.lastOffsetX,m=o-this.lastOffsetY;if(this.lastOffsetX=n,this.lastOffsetY=o,t.ctrlKey||this.initPens.length===1&&this.initPens[0].ratio){var b=[1,3].includes(this.resizeIndex)?-1:1;m=b*(p*y)/g}if(this.activeRect.ratio=this.initPens[0].ratio,md(this.activeRect,p,m,this.resizeIndex),this.store.options.strictScope){var x=this.store.data.width||this.store.options.width,_=this.store.data.height||this.store.options.height;if(x&&_){var k={x:this.store.data.origin.x,y:this.store.data.origin.y,width:x*this.store.data.scale,height:_*this.store.data.scale};this.activeRect.xk.x+k.width&&(this.activeRect.width=this.activeRect.width-(this.activeRect.x+this.activeRect.width-(k.x+k.width)),this.activeRect.x=k.x+k.width-this.activeRect.width,this.activeRect.ex=this.activeRect.x+this.activeRect.width),this.activeRect.y+this.activeRect.height>k.y+k.height&&(this.activeRect.height=this.activeRect.height-(this.activeRect.y+this.activeRect.height-(k.y+k.height)),this.activeRect.y=k.y+k.height-this.activeRect.height,this.activeRect.ey=this.activeRect.y+this.activeRect.height)}}tt(this.activeRect);var I=this.activeRect.width/g,P=this.activeRect.height/y;this.store.active.forEach(function(M,L){M.calculative.worldRect.x=i.activeInitPos[L].x*i.activeRect.width+i.activeRect.x,M.calculative.worldRect.y=i.activeInitPos[L].y*i.activeRect.height+i.activeRect.y,M.calculative.worldRect.width*=I,M.calculative.iconWidth&&(M.calculative.iconWidth*=I),M.calculative.worldRect.height*=P,M.calculative.iconHeight&&(M.calculative.iconHeight*=P),ot(M.calculative.worldRect),tt(M.calculative.worldRect),i.updatePenRect(M,{worldRectIsReady:!0}),i.execPenResize(M),i.updateLines(M)}),this.getSizeCPs(),this.initImageCanvas(this.store.active),this.initTemplateCanvas(this.store.active),this.render(),this.store.emitter.emit("resizePens",this.store.active),this.timer&&clearTimeout(this.timer),this.timer=setTimeout(function(){i.timer=void 0,i.pushHistory({type:we.Update,pens:ce(i.store.active,!0),initPens:i.initPens}),i.initPens=void 0},200)},e.prototype.movePens=function(t){var i,a;if(!(!this.activeRect||this.store.data.locked)){if(!this.initActiveRect){this.initActiveRect=ce(this.activeRect);return}if(!(!this.store.options.moveConnectedLine&&!this.canMoveLine&&this.store.active.length===1&&(((i=this.store.active[0].anchors[0])===null||i===void 0?void 0:i.connectTo)||((a=this.store.active[0].anchors[this.store.active[0].anchors.length-1])===null||a===void 0?void 0:a.connectTo)))&&(this.movingPens||(this.initMovingPens(),this.store.active.forEach(function(b){yn(b,!1)}),this.store.hover=void 0),!!this.mouseDown)){var r=t.x-this.mouseDown.x,n=t.y-this.mouseDown.y;t.shiftKey&&!t.ctrlKey&&(n=0),t.ctrlKey&&(r=0);var o=ce(this.initActiveRect);Yr(o,r,n);var s=!1;if(this.store.options.strictScope){var h=this.store.data.width||this.store.options.width,l=this.store.data.height||this.store.options.height;if(h&&l){var c={x:this.store.data.origin.x,y:this.store.data.origin.y,width:h*this.store.data.scale,height:l*this.store.data.scale};o.xc.x+c.width&&(o.x=c.x+c.width-o.width,s=!0),o.y+o.height>c.y+c.height&&(o.y=c.y+c.height-o.height,s=!0)}}var f={x:o.x-this.activeRect.x,y:o.y-this.activeRect.y};if(!this.store.options.disableDock&&!s){this.clearDock();var v=this.customMoveDock||K2;this.dock=v(this.store,o,this.movingPens,f);var g=this.dock,y=g.xDock,p=g.yDock,m=void 0;y&&(f.x+=y.step,m=this.store.pens[y.penId],m.calculative.isDock=!0),p&&(f.y+=p.step,m=this.store.pens[p.penId],m.calculative.isDock=!0)}this.translatePens(this.movingPens,f.x,f.y,!0)}}},e.prototype.changeIdsByMoving=function(t,i){t.id+=Mi,t.parentId&&i.find(function(a){return a.id===t.parentId})&&(t.parentId+=Mi),t.children&&(t.children=t.children.map(function(a){return a+Mi})),t.connectedLines&&(t.connectedLines=t.connectedLines.map(function(a){return i.find(function(r){return r.id===a.lineId})&&(a.lineId+=Mi),a})),t.type&&t.calculative.worldAnchors&&(t.calculative.worldAnchors=t.calculative.worldAnchors.map(function(a){return a.connectTo&&i.find(function(r){return r.id===a.connectTo})&&(a.connectTo+=Mi),a}))},e.prototype.initMovingPens=function(){var t=this,i,a;if(!this.store.options.moveConnectedLine&&!this.canMoveLine)for(var r=0;r0&&c.forEach(function(x){var _=a.store.pens[x.lineId];Ba(a.store.pens[a.store.activeAnchor.penId],a.store.activeAnchor,_,Kr(_,x.lineAnchor))});var f=this.store.active[0];lt(f);var v=We(f);if(f.lineName==="polyline"&&!i.shiftKey)QE(f,this.store.activeAnchor,t);else{var g=0,y=0;if(f.lineName==="line"){var p=f.calculative.worldAnchors.findIndex(function(x){return x.id===a.store.activeAnchor.id});p===0&&(p=2);var m=f.calculative.worldAnchors[p-1];if(i.ctrlKey&&i.shiftKey){var b=ce(t);this.getSpecialAngle(b,m),g=b.x-this.store.activeAnchor.x,y=b.y-this.store.activeAnchor.y}else if(!i.ctrlKey&&i.shiftKey){var b={x:t.x,y:m.y};g=b.x-this.store.activeAnchor.x,y=b.y-this.store.activeAnchor.y}else if(i.ctrlKey&&!i.shiftKey){var b={x:m.x,y:t.y};g=b.x-this.store.activeAnchor.x,y=b.y-this.store.activeAnchor.y}else g=t.x-this.store.activeAnchor.x,y=t.y-this.store.activeAnchor.y}else!i.ctrlKey&&i.shiftKey?(g=t.x-this.store.activeAnchor.x,y=0):i.ctrlKey&&!i.shiftKey?(g=0,y=t.y-this.store.activeAnchor.y):(g=t.x-this.store.activeAnchor.x,y=t.y-this.store.activeAnchor.y);wn(this.store.activeAnchor,g,y),this.store.hover&&this.store.hoverAnchor&&this.store.hoverAnchor.penId!==this.store.activeAnchor.penId&&(this.store.hoverAnchor.type===ir.Line?(g=t.x-this.store.activeAnchor.x,y=t.y-this.store.activeAnchor.y,Do(this.store.activeAnchor,this.store.hoverAnchor,this.store)):(g=this.store.hoverAnchor.x-this.store.activeAnchor.x,y=this.store.hoverAnchor.y-this.store.activeAnchor.y),wn(this.store.activeAnchor,g,y),v.prev=void 0,f.lineName!=="polyline"&&((s=this[f.lineName])===null||s===void 0||s.call(this,this.store,f)))}this.patchFlagsLines.add(f),this.store.path2dMap.set(f,ke.path2dDraws[f.name](f)),this.render(),this.store.active[0].calculative&&(this.store.active[0].calculative.gradientAnimatePath=void 0),this.store.emitter.emit("moveLineAnchor",{pen:this.store.active[0],anchor:this.store.activeAnchor}),this.timer&&clearTimeout(this.timer),this.timer=setTimeout(function(){a.timer=void 0,a.pushHistory({type:we.Update,pens:ce(a.store.active,!0),initPens:a.initPens}),a.initPens=void 0},500)}},e.prototype.moveLineAnchorPrev=function(t){var i=this;if(!(!this.activeRect||this.store.data.locked||!this.store.activeAnchor)){if(this.initPens||(this.initPens=ce(this.store.active,!0)),this.store.activeAnchor.prev.x=t.x,this.store.activeAnchor.prev.y=t.y,this.store.activeAnchor.next){if(!this.store.activeAnchor.prevNextType)this.store.activeAnchor.next.x=t.x,this.store.activeAnchor.next.y=t.y,Ge(this.store.activeAnchor.next,180,this.store.activeAnchor);else if(this.store.activeAnchor.prevNextType===Zr.Bilateral&&this.prevAnchor){var a=gi(t,this.store.activeAnchor),r=gi(this.prevAnchor,this.store.activeAnchor);this.store.activeAnchor.next.x=this.nextAnchor.x,this.store.activeAnchor.next.y=this.nextAnchor.y,Ge(this.store.activeAnchor.next,a-r,this.store.activeAnchor)}}var n=this.store.active[0];this.patchFlagsLines.add(n),this.store.path2dMap.set(n,ke.path2dDraws[n.name](n)),this.render(),this.timer&&clearTimeout(this.timer),this.timer=setTimeout(function(){i.timer=void 0,i.pushHistory({type:we.Update,pens:ce(i.store.active,!0),initPens:i.initPens}),i.initPens=void 0},200)}},e.prototype.moveLineAnchorNext=function(t){var i=this;if(!(!this.activeRect||this.store.data.locked||!this.store.activeAnchor)){if(this.initPens||(this.initPens=ce(this.store.active,!0)),this.store.activeAnchor.next.x=t.x,this.store.activeAnchor.next.y=t.y,this.store.activeAnchor.prev){if(!this.store.activeAnchor.prevNextType)this.store.activeAnchor.prev.x=t.x,this.store.activeAnchor.prev.y=t.y,Ge(this.store.activeAnchor.prev,180,this.store.activeAnchor);else if(this.store.activeAnchor.prevNextType===Zr.Bilateral&&this.nextAnchor){var a=gi(t,this.store.activeAnchor),r=gi(this.nextAnchor,this.store.activeAnchor);this.store.activeAnchor.prev.x=this.prevAnchor.x,this.store.activeAnchor.prev.y=this.prevAnchor.y,Ge(this.store.activeAnchor.prev,a-r,this.store.activeAnchor)}}var n=this.store.active[0];this.patchFlagsLines.add(n),this.store.path2dMap.set(n,ke.path2dDraws[n.name](n)),this.render(),this.timer&&clearTimeout(this.timer),this.timer=setTimeout(function(){i.timer=void 0,i.pushHistory({type:we.Update,pens:ce(i.store.active,!0),initPens:i.initPens}),i.initPens=void 0},200)}},e.prototype.setAnchor=function(t){var i;return Ei(this,void 0,void 0,function(){var a,r,n,o,s,s;return ki(this,function(h){switch(h.label){case 0:return a=[ce(this.store.hover,!0)],r=this.store.hover,this.store.hoverAnchor?(n=this.beforeRemoveAnchor,n?[4,this.beforeRemoveAnchor(r,this.store.hoverAnchor)]:[3,2]):[3,3];case 1:n=!h.sent(),h.label=2;case 2:return n?[2]:(r.type===Ye.Line&&((i=r.calculative.worldAnchors)===null||i===void 0?void 0:i.length)<=2?this.delete([r]):(z2(r,this.store.hoverAnchor),r.type===Ye.Line&&this.initLineRect(r)),this.store.hoverAnchor=void 0,this.store.activeAnchor=void 0,this.externalElements.style.cursor="default",[3,6]);case 3:return r?(o=this.beforeAddAnchor,o?[4,this.beforeAddAnchor(r,this.store.pointAt)]:[3,5]):[3,6];case 4:o=!h.sent(),h.label=5;case 5:if(o)return[2];r.type===Ye.Line?(this.store.activeAnchor=F2(r,this.store.pointAt,this.store.pointAtIndex),this.initLineRect(r),s={x:t.x,y:t.y},this.getHover(s)):(s={id:Me(),x:t.x,y:t.y},this.store.activeAnchor=N2(r,s)),h.label=6;case 6:return this.hotkeyType=Ke.None,this.render(),r&&this.pushHistory({type:we.Update,pens:[ce(r,!0)],initPens:a}),[2]}})})},e.prototype.checkDisconnect=function(t,i){var a=this;if(t.id.indexOf(Mi)>0){var r=t.id;t=this.store.pens[r.replace(Mi,"")]}t.anchors.forEach(function(n){if(n.connectTo&&!i.find(function(s){return s.id===n.connectTo||s.id===n.connectTo+Mi})){var o=a.store.pens[n.connectTo];if(!o||o.type)return;Ba(o,Kr(o,n.anchorId),t,n)}})},e.prototype.translatePens=function(t,i,a,r){var n=this;if(t===void 0&&(t=this.store.active),!(!t||!t.length)){var o=t.some(function(l){if(l.locked>=ze.DisableMove)return!0});if(!o){var s=!r&&ce(t,!0);this.activeRect&&Yr(this.activeRect,i,a);var h=this.getAllByPens(t);t.forEach(function(l){var c,f;if(!(l.locked>=ze.DisableMove)){if(l.type===Ye.Line){if(!n.store.options.moveConnectedLine&&!n.canMoveLine||l.isRuleLine)return;ld(l,i,a),n.checkDisconnect(l,h),n.store.path2dMap.set(l,ke.path2dDraws[l.name](l)),r||(n.initLineRect(l),(c=l.connectedLines)===null||c===void 0||c.forEach(function(v){var g=n.store.pens[v.lineId];n.initLineRect(g)}))}else Yr(l.calculative.worldRect,i,a),n.updatePenRect(l,{worldRectIsReady:!0}),l.calculative.x=l.x,l.calculative.y=l.y,l.calculative.initRect&&(l.calculative.initRect.x=l.calculative.x,l.calculative.initRect.y=l.calculative.y,l.calculative.initRect.ex=l.calculative.x+l.calculative.width,l.calculative.initRect.ey=l.calculative.y+l.calculative.height);n.updateLines(l),(f=l.onMove)===null||f===void 0||f.call(l,l)}}),this.activeRect&&this.getSizeCPs(),this.render(),this.tooltip.translate(i,a),r||(this.pushHistory({type:we.Update,pens:ce(t,!0),initPens:s}),this.initImageCanvas(t),this.initTemplateCanvas(t),this.store.emitter.emit("translatePens",t)),this.store.emitter.emit("translatingPens",t)}}},e.prototype.templateTranslatePens=function(t,i,a){var r=this;if(t===void 0&&(t=this.store.active),!(!t||!t.length)){var n=this.getAllByPens(t);t.forEach(function(o){var s;if(o.type===Ye.Line){if(!r.store.options.moveConnectedLine&&!r.canMoveLine)return;ld(o,i,a),r.checkDisconnect(o,n),r.store.path2dMap.set(o,ke.path2dDraws[o.name](o))}else Yr(o.calculative.worldRect,i,a),r.updatePenRect(o,{worldRectIsReady:!0}),o.calculative.x=o.x,o.calculative.y=o.y,o.calculative.initRect&&(o.calculative.initRect.x=o.calculative.x,o.calculative.initRect.y=o.calculative.y,o.calculative.initRect.ex=o.calculative.x+o.calculative.width,o.calculative.initRect.ey=o.calculative.y+o.calculative.height);(s=o.onMove)===null||s===void 0||s.call(o,o)})}},e.prototype.calcAutoAnchor=function(t,i,a,r){var n=lt(t),o=We(t),s=Ma(a,i===n?o:n);!s||(i.x=s.x,i.y=s.y,i.prev=void 0,i.next=void 0,r?r.anchor=s.id:_t(a,s,t,i),this[t.lineName]&&this[t.lineName](this.store,t),this.store.path2dMap.set(t,ke.path2dDraws.line(t)),this.initLineRect(t))},e.prototype.restoreNodeAnimate=function(t){var i,a;if(t.calculative.initRect){if(t.keepAnimateState)for(var r in t)t.calculative[r]!==void 0&&r!=="x"&&r!=="y"&&r!=="width"&&r!=="height"&&r!=="initRect"&&(typeof t[r]!="object"||r==="lineDash")&&(r==="fontSize"||r==="lineWidth"?t[r]=t.calculative[r]/t.calculative.canvas.store.data.scale:t[r]=t.calculative[r]);else{var n=t.calculative.initRect.rotate-t.calculative.rotate;for(var r in t)r!=="x"&&r!=="y"&&r!=="width"&&r!=="height"&&r!=="initRect"&&r!=="rotate"&&(typeof t[r]!="object"||r==="lineDash")&&(t.calculative[r]=t[r]);!((i=t.children)===null||i===void 0)&&i.length?n&&hg(t,n,t.calculative.worldRect):t.calculative.rotate=t.rotate;var o=ce(this.store.animateMap.get(t));o&&(o.id=t.id,this.parent.setValue(o,{doEvent:!1,render:!0,history:!1})),t.calculative.worldRect=t.calculative.initRect}this.updatePenRect(t,{worldRectIsReady:!0}),this.updateLines(t),t.image&&t.name!=="gif"&&(this.canvasImage.init(),this.canvasImageBottom.init()),t.calculative.text!==t.text&&(t.calculative.text=t.text,Nn(t)),!((a=this.store.active)===null||a===void 0)&&a.length&&this.calcActiveRect(),t.calculative.initRect=void 0}},e.prototype.updateLines=function(t,i){var a=this,r;(r=t.children)===null||r===void 0||r.forEach(function(n){var o=a.store.pens[n];o&&a.updateLines(o,i)}),t.connectedLines&&t.connectedLines.forEach(function(n){var o=a.store.pens[n.lineId];if(!(!o||o.calculative.active)){var s=Kr(o,n.lineAnchor);if(!!s){if(o.autoFrom){var h=lt(o);h.id===s.id&&a.calcAutoAnchor(o,h,t,n)}if(o.autoTo){var l=We(o);l.id===s.id&&a.calcAutoAnchor(o,l,t,n)}var c=Kr(t,n.anchor);if(!!c){var f=t.rotate;t.flipX&&(f*=-1),t.flipY&&(f*=-1);var v=s.distance*a.store.data.scale*Math.cos((f+c.rotate)/180*Math.PI)||0,g=s.distance*a.store.data.scale*Math.sin((f+c.rotate)/180*Math.PI)||0;if(t.flipX&&(v=-v),t.flipY&&(g=-g),wn(s,c.x-s.x+v,c.y-s.y+g),a.store.options.autoPolyline&&!a.autoPolylineFlag&&o.autoPolyline!==!1&&o.lineName==="polyline"){var h=lt(o),l=We(o),y=!1;h.id===s.id?(h=s,y=!0):l.id===s.id&&(l=s,y=!0),y&&(o.calculative.worldAnchors=[h,l],o.calculative.activeAnchor=h,a.polyline(a.store,o,l),a.initLineRect(o))}a.store.path2dMap.set(o,ke.path2dDraws[o.name](o)),a.patchFlagsLines.add(o),o.calculative.gradientSmooth&&(o.calculative.gradientAnimatePath=au(o)),i&&Uc(o)}}}})},e.prototype.calcActiveRect=function(){var t=this.store.active.filter(function(i){return(!i.locked||i.locked-1})),a&&(a.forEach(function(r){var n,o,s,h,l;if(r.calculative.pause){var c=Date.now()-r.calculative.pause;r.calculative.pause=void 0,r.calculative.frameStart+=c,r.calculative.frameEnd+=c}else if(r.name==="video")r.calculative.media.currentTime=0,(n=r.calculative.media)===null||n===void 0||n.play(),(o=r.onStartVideo)===null||o===void 0||o.call(r,r);else if(r.type||((s=r.frames)===null||s===void 0?void 0:s.length)||r.animations&&r.animations.length){if(r.type){if(!((l=r.animations)===null||l===void 0)&&l.length){var g=ce(r.animations[0]);delete g.name,g.currentAnimation=0,i.parent.setValue(Lt({id:r.id},g),{doEvent:!1,history:!1})}}else{if(!r.frames&&r.animations&&r.animations.length){var f=(h=r.animations)===null||h===void 0?void 0:h.findIndex(function(y){return y.autoPlay}),v=f===-1?0:f,g=ce(r.animations[v]);delete g.name,g.currentAnimation=v,!r.type&&g.frames&&(g.showDuration=i.parent.calcAnimateDuration(g)),i.parent.setValue(Lt({id:r.id},g),{doEvent:!1,history:!1})}i.store.animateMap.set(r,i.getFrameProps(r))}i.store.animates.add(r)}}),this.animate())}},e.prototype.getFrameProps=function(t){var i={};return t.frames&&t.frames.forEach(function(a){for(var r in a)!["duration","x","y","width","height","rotate"].includes(r)&&!i[r]&&(i[r]=t[r])}),i},e.prototype.animate=function(){var t=this;this.animateRendering||requestAnimationFrame(function(){var i,a,r=Date.now();if(r-t.lastAnimateRender0&&t.animate();return}t.lastAnimateRender=r,t.animateRendering=!0;var n=[],o=!1,s=function(f){if(f.calculative.pause)return"continue";if(f.calculative.active&&!f.type&&!t.movingPens&&(o=!0),!f.type)H2(f,r)?f.calculative.patchFlags&&(tt(f.calculative.worldRect),t.updatePenRect(f,{worldRectIsReady:!0,playingAnimate:!0})):(requestAnimationFrame(function(){t.restoreNodeAnimate(f)}),n.push(f),t.nextAnimate(f)),t.updateLines(f,!0);else if(!W2(f)){if(f.keepAnimateState){for(var v in f)f.calculative[v]!==void 0&&v!=="length"&&(typeof f[v]!="object"||v==="lineDash")&&(v==="lineWidth"?f[v]=f.calculative[v]/f.calculative.canvas.store.data.scale:f[v]=f.calculative[v]);Yo(f)}else for(var v in f)(typeof f[v]!="object"||v==="lineDash")&&(v==="lineWidth"?f.calculative[v]=f[v]*f.calculative.canvas.store.data.scale:f.calculative[v]=f[v]);n.push(f),t.nextAnimate(f)}t.patchFlags=!0};try{for(var h=at(t.store.animates),l=h.next();!l.done;l=h.next()){var c=l.value;s(c)}}catch(f){i={error:f}}finally{try{l&&!l.done&&(a=h.return)&&a.call(h)}finally{if(i)throw i.error}}o&&t.calcActiveRect(),n.forEach(function(f){t.store.animates.delete(f)}),t.render(!1),t.animateRendering=!1,t.animate()})},Object.defineProperty(e.prototype,"clipboardName",{get:function(){return"meta2d-clipboard"},enumerable:!1,configurable:!0}),e.prototype.copy=function(t,i){return i===void 0&&(i=!0),Ei(this,void 0,void 0,function(){var a,r,n,o,s,h,l=this;return ki(this,function(c){switch(c.label){case 0:if(a=Me(),r=this.store.data,n=r.origin,o=r.scale,this.store.clipboard=void 0,localStorage.removeItem(this.clipboardName),sessionStorage.setItem("page",a),s=this.getAllByPens(ce(t||this.store.active,!0)),s.forEach(function(f){f.copyIndex=l.store.data.pens.findIndex(function(v){return v.id===f.id}),f.pathId&&(f.path=l.store.data.paths[f.pathId])}),s.sort(function(f,v){return f.copyIndex-v.copyIndex}),s.forEach(function(f){delete f.copyIndex}),h={meta2d:!0,pens:s,origin:ce(n),scale:o,page:a,initRect:ce(this.activeRect),offset:10},!(navigator.clipboard&&!this.store.options.disableClipboard&&!navigator.userAgent.includes("Firefox")))return[3,5];c.label=1;case 1:return c.trys.push([1,3,,4]),[4,navigator.clipboard.writeText(JSON.stringify(h))];case 2:return c.sent(),[3,4];case 3:return c.sent(),localStorage.setItem(this.clipboardName,JSON.stringify(h)),[3,4];case 4:return[3,6];case 5:localStorage.setItem(this.clipboardName,JSON.stringify(h)),c.label=6;case 6:return i&&this.store.emitter.emit("copy",h.pens),[2]}})})},e.prototype.cut=function(t){this.copy(t,!1),this.delete(t),this.store.emitter.emit("cut",t)},e.prototype.paste=function(){var t;return Ei(this,void 0,void 0,function(){var i,a,r,n,o,s,h,l,c,f,v,g;return ki(this,function(y){switch(y.label){case 0:if(!(navigator.clipboard&&!this.store.options.disableClipboard&&!navigator.userAgent.includes("Firefox")))return[3,5];y.label=1;case 1:return y.trys.push([1,3,,4]),[4,(t=navigator.clipboard)===null||t===void 0?void 0:t.readText()];case 2:return i=y.sent(),[3,4];case 3:return y.sent(),i=localStorage.getItem(this.clipboardName),[3,4];case 4:return[3,6];case 5:i=localStorage.getItem(this.clipboardName),y.label=6;case 6:if(i){try{a=JSON.parse(i)}catch(p){return console.warn("\u526A\u5207\u677F\u6570\u636E\u4E0D\u662Fjson",p.message),[2]}if(!a||!a.meta2d)return[2]}else return[2];return r=this.beforeAddPens,r?[4,this.beforeAddPens(a.pens)]:[3,8];case 7:r=y.sent()!=!0,y.label=8;case 8:if(r)return[2];this.store.clipboard&&(n=this.store.clipboard.offset+10,o=this.store.clipboard.pos),this.store.clipboard=ce(a),s=sessionStorage.getItem("page"),s!==a.page?(this.store.clipboard.pos={x:this.mousePos.x,y:this.mousePos.y},this.store.clipboard.offset=0):this.pasteOffset?(n&&(this.store.clipboard.offset=n),o&&(this.store.clipboard.pos=o)):(this.store.clipboard.offset=0,this.pasteOffset=!0),h=this.store.clipboard.pens.filter(function(p){return!p.parentId});try{for(l=at(h),c=l.next();!c.done;c=l.next())f=c.value,this.pastePen(f,void 0)}catch(p){v={error:p}}finally{try{c&&!c.done&&(g=l.return)&&g.call(l)}finally{if(v)throw v.error}}return sessionStorage.setItem("page",a.page),this.active(h),this.pushHistory({type:we.Add,pens:this.store.clipboard.pens}),this.render(),this.store.emitter.emit("add",this.store.clipboard.pens),this.store.emitter.emit("paste",this.store.clipboard.pens),[2]}})})},e.prototype.getAllByPens=function(t){var i,a,r=[];try{for(var n=at(t),o=n.next();!o.done;o=n.next()){var s=o.value;r.push.apply(r,Di([],Li(ce(Er(s,this.store),!0)),!1))}}catch(h){i={error:h}}finally{try{o&&!o.done&&(a=n.return)&&a.call(n)}finally{if(i)throw i.error}}return r.concat(t)},e.prototype.changeLineAnchors=function(t,i,a){if(!!Array.isArray(i.connectedLines))for(var r=function(s){var h=i.connectedLines[s].lineId,l=a.find(function(v){return v.id===h});if(l){var c=l.anchors[0],f=l.anchors[l.anchors.length-1];c.connectTo===t&&(c.connectTo=i.id),f.connectTo===t&&(f.connectTo=i.id)}else i.connectedLines.splice(s,1),s--;n=s},n,o=0;o-1){var n=this.store.pens[t.id];n.calculative.active=void 0,i.push(n)}t.children&&t.children.forEach(function(o){a.getDelPens(a.store.pens[o],i)})}},e.prototype.getLockedParent=function(t){if(!t.parentId)return!1;var i=ri(t);if(i.locked)return i;this.getLockedParent(i)},e.prototype.delForce=function(t){var i=this,a;if(!!t){var r=this.store.data.pens.findIndex(function(n){return n.id===t.id});r>-1&&(this.delConnectedLines(this.store.data.pens[r]),this.store.data.pens.splice(r,1),this.store.pens[t.id]=void 0,delete this.store.pens[t.id]),this.store.animates.delete(t),this.store.animateMap.delete(t),t.children&&t.children.forEach(function(n){i.delForce(i.store.pens[n])}),(a=t.onDestroy)===null||a===void 0||a.call(t,t)}},e.prototype.delConnectedLines=function(t){var i=this,a;if(t.connectedLines)for(var r=function(s){var h=t.connectedLines[s],l=h.lineId,c=h.lineAnchor,f=n.store.pens[l];if(f){var v=f.anchors.find(function(g){return g.id===c});(v==null?void 0:v.connectTo)===t.id&&(v.connectTo=void 0,v.anchorId=void 0,v.prev&&(v.prev.connectTo=void 0),v.next&&(v.next.connectTo=void 0)),v=Kr(f,c),v&&(v.connectTo=void 0,v.anchorId=void 0,v.prev&&(v.prev.connectTo=void 0),v.next&&(v.next.connectTo=void 0))}},n=this,o=0;o",nbsp:" ",amp:"&",quot:'"'};return t.replace(/&(lt|gt|nbsp|amp|quot);/gi,function(a,r){return i[r]})},e.prototype.createInput=function(){var t=this;this.inputParent.classList.add("meta2d-input"),this.inputRight.classList.add("right"),this.inputDiv.classList.add("input-div"),this.inputParent.appendChild(this.inputDiv),this.inputParent.appendChild(this.inputRight),this.dropdown.onmouseleave=function(){t.store.hover=null},this.inputParent.appendChild(this.dropdown),this.externalElements.appendChild(this.inputParent),this.inputParent.onmousedown=this.stopPropagation,this.inputDiv.onmousedown=this.stopPropagation,this.inputDiv.contentEditable="false",this.inputRight.onmousedown=this.stopPropagation,this.dropdown.onmousedown=this.stopPropagation,this.inputRight.style.transform="rotate(135deg)";for(var i,a=0;a'}}else if(n.target.innerText)t.inputDiv.style.paddingTop="";else{var s=window.getComputedStyle(t.inputDiv,null);s.justifyContent==="center"&&(t.inputDiv.style.paddingTop=" "+(t.inputDiv.offsetHeight/2-parseFloat(s.lineHeight)/2)+"px")}},this.inputDiv.onblur=function(){setTimeout(function(){t.hideInput()},300)},this.inputDiv.oninput=function(n){var o=t.store.pens[t.inputDiv.dataset.penId];if(o.inputType==="number"){var s=n.target.innerText,h=s.replace(/[^0-9]/g,"");s!==h&&(n.preventDefault(),n.target.innerText=h)}if(navigator.userAgent.includes("Firefox")){if(!n.target.innerText.trim()){var l=t.inputDiv.offsetWidth/2,c=window.getComputedStyle(t.inputDiv,null);c.textAlign!=="center"&&(l=0),t.inputDiv.innerHTML='
'}}else if(n.target.innerText)t.inputDiv.style.paddingTop="";else{var c=window.getComputedStyle(t.inputDiv,null);c.justifyContent==="center"&&(t.inputDiv.style.paddingTop=" "+(t.inputDiv.offsetHeight/2-parseFloat(c.lineHeight)/2)+"px")}},this.inputDiv.onclick=function(n){n.stopPropagation();var o=t.store.pens[t.inputDiv.dataset.penId];t.dropdown.style.display==="block"?(t.dropdown.style.display="none",t.inputRight.style.transform="rotate(135deg)"):(o==null?void 0:o.dropdownList)&&t.store.data.locked&&(t.dropdown.style.display="block",t.inputRight.style.transform="rotate(315deg)"),t.store.emitter.emit("clickInput",o)},this.inputDiv.onkeyup=function(n){t.setDropdownList(!0);var o=t.store.pens[t.inputDiv.dataset.penId];t.store.emitter.emit("input",{pen:o,text:n.key}),n.stopPropagation()},this.inputDiv.onkeydown=function(n){n.stopPropagation()},this.inputDiv.onmousedown=this.stopPropagation,this.inputDiv.onwheel=function(n){n.stopPropagation()},this.inputDiv.onpaste=function(n){n.preventDefault();var o="";n.clipboardData&&n.clipboardData.getData&&(o=n.clipboardData.getData("text/plain")),document.execCommand("insertHTML",!1,o)}},e.prototype.clearDropdownList=function(){if(this.dropdown.hasChildNodes())for(var t=0;t-1})},e.prototype.findOne=function(t){return this.store.data.pens.find(function(i){return i.id==t||i.tags&&i.tags.indexOf(t)>-1})},e.prototype.changePenId=function(t,i){var a=this,r,n,o,s,h;if(t!==i){var l=this.store.pens[t];if(!!l&&!this.store.pens[i]){if(l.id=i,this.store.pens[i]=this.store.pens[t],(r=l.onChangeId)===null||r===void 0||r.call(l,l,t,i),delete this.store.pens[t],l.parentId){var c=this.store.pens[l.parentId],f=(n=c.children)===null||n===void 0?void 0:n.findIndex(function(v){return v===t});f!==-1&&((o=c.children)===null||o===void 0||o.splice(f,1,i))}(s=l.children)===null||s===void 0||s.forEach(function(v){var g=a.store.pens[v];g.parentId=i}),l.type===Ye.Line?this.changeNodeConnectedLine(t,l,this.store.data.pens):(this.changeLineAnchors(t,l,this.store.data.pens),(h=l.connectedLines)===null||h===void 0||h.forEach(function(v){var g=v.lineId,y=a.store.pens[g];_n(y)}))}}},e.prototype.updateValue=function(t,i){var a,r,n,o,s,h,l=this.getPenRect(t),c=t.name;Object.assign(t,i);var f=c!==t.name;i.newId&&this.changePenId(t.id,i.newId);var v=!1,g=!1,y=!1,p=!1,m=!1,b=!1,x=void 0,_=!1;for(var k in i)k.indexOf(".")===-1?(k==="rotate"?x=t.calculative.rotate||0:k==="canvasLayer"||k==="isBottom"||k==="showChild"?b=!0:k==="image"&&(_=!0),(typeof t[k]!="object"||k==="lineDash")&&(t.calculative[k]=i[k]),xx.includes(k)&&(g=!0),["name","borderRadius","lineSmooth"].includes(k)&&(v=!0),Ex.includes(k)&&(m=!0),kx.includes(k)&&(y=!0),Cx.includes(k)&&(p=!0)):(delete t[k],f2(t,k,i[k])),k.split(".")[0]==="anchors"&&_n(t);if(this.setCalculativeByScale(t),f&&((a=t.onDestroy)===null||a===void 0||a.call(t,t),Sx(t)),m){var I={x:(r=i.x)!==null&&r!==void 0?r:l.x,y:(n=i.y)!==null&&n!==void 0?n:l.y,width:(o=i.width)!==null&&o!==void 0?o:l.width,height:(s=i.height)!==null&&s!==void 0?s:l.height};this.setPenRect(t,I,!1),this.updateLines(t,!0),this.store.active&&this.store.active.length&&t.id===this.store.active[0].id&&this.calcActiveRect()}else y?this.updatePenRect(t):(g&&Ni(t),p&&sd(this.store.pens,t),v&&ke.path2dDraws[t.name]&&this.store.path2dMap.set(t,ke.path2dDraws[t.name](t)));if(x!==void 0){var P=t.calculative.rotate;t.calculative.rotate=x,this.rotatePen(t,P-x,t.calculative.worldRect)}(i.image||i.backgroundImage||i.strokeImage)&&(t.calculative.image=void 0,t.calculative.backgroundImage=void 0,t.calculative.strokeImage=void 0,this.loadImage(t)),i.lineGradientColors&&(t.calculative.lineGradient=void 0,t.calculative.gradientColorStop=void 0),i.gradientColors&&(t.calculative.gradient=void 0,t.calculative.radialGradient=void 0),i.gradientRadius&&(t.calculative.gradient=void 0,t.calculative.radialGradient=void 0),i.animateLineWidth&&(t.calculative.gradientAnimatePath=void 0),i.gradientSmooth&&(t.calculative.gradientAnimatePath=void 0),b?(this.canvasImage.init(),this.canvasImageBottom.init()):_&&(t.canvasLayer===void 0&&(t.canvasLayer=Ne.CanvasImageBottom,t.calculative.canvasLayer=Ne.CanvasImageBottom),t.canvasLayer===Ne.CanvasImageBottom?this.canvasImageBottom.init():t.canvasLayer===Ne.CanvasImage&&this.canvasImage.init()),(i.canvasLayer!==void 0||t.canvasLayer===Ne.CanvasTemplate)&&this.initTemplateCanvas([t]),i.zIndex!==void 0&&!((h=t.calculative.singleton)===null||h===void 0)&&h.div&&Ai(t,t.calculative.singleton.div)},e.prototype.execPenResize=function(t){var i=this,a,r;(a=t.onResize)===null||a===void 0||a.call(t,t),(r=t.children)===null||r===void 0||r.forEach(function(n){var o=i.store.pens[n];o&&i.execPenResize(o)})},e.prototype.setPenRect=function(t,i,a){if(a===void 0&&(a=!0),t.parentId)Object.assign(t,i);else{var r=this.store.data,n=r.origin,o=r.scale;t.x=n.x+i.x*o,t.y=n.y+i.y*o,t.width=i.width*o,t.height=i.height*o}this.updatePenRect(t),this.execPenResize(t),a&&this.render()},e.prototype.getPenRect=function(t,i,a){if(i===void 0&&(i=this.store.data.origin),a===void 0&&(a=this.store.data.scale),!!t)return t.parentId?{x:t.x,y:t.y,width:t.width,height:t.height}:{x:(t.x-i.x)/a,y:(t.y-i.y)/a,width:t.width/a,height:t.height/a}},e.prototype.toPng=function(t,i,a,r){var n,o;t===void 0&&(t=2),a===void 0&&(a=!1);var s=Hi(this.store.data.pens),h=this.store.data.scale;if(!isFinite(s.width))throw new Error("can not to png, because width is not finite");var l=ce(s),c=this.store.data,f=a&&!c.background&&this.store.bkImg,v=!1,g=!1;if(f){if(s.x+=c.x,s.y+=c.y,ot(s),fs(s,this.canvasRect,!0))Object.assign(s,this.canvasRect);else{var y=Fn(Di(Di([],Li(sr(s)),!1),Li(sr(this.canvasRect)),!1));Object.assign(s,y)}v=s.x===0,g=s.y===0}var p=this.store.data.width||this.store.options.width,m=this.store.data.height||this.store.options.height,b=!1;p&&m&&!this.store.data.component&&(b=!0),b&&(s.x=this.store.data.origin.x,s.y=this.store.data.origin.y,s.width=p*this.store.data.scale,s.height=m*this.store.data.scale);var x=ce(s),_=ar(t);s.x-=_[3]*h,s.y-=_[0]*h,s.width+=(_[3]+_[1])*h,s.height+=(_[0]+_[2])*h;var k=(r||1920)/s.width;s.width*=k,s.height*=k,ot(s);var I=document.createElement("canvas");if(I.width=s.width,I.height=s.height,I.width>32767||I.height>32767||!navigator.userAgent.includes("Firefox")&&I.height*I.width>268435456||navigator.userAgent.includes("Firefox")&&I.height*I.width>472907776)throw new Error("can not to png, because the size exceeds the browser limit");var P=I.getContext("2d");P.textBaseline="middle",P.scale(k,k);var M=this.store.data.background||this.store.options.background;if(M&&(P.save(),P.fillStyle=M,b?P.fillRect(0,0,x.width+(_[1]+_[3])*h,x.height+(_[0]+_[2])*h):P.fillRect(0,0,l.width+(_[3]+_[1])*h,l.height+(_[0]+_[2])*h),P.restore()),f)if(b)P.drawImage(this.store.bkImg,_[3]*h||0,_[0]*h||0,x.width,x.height);else{var L=s.x<0?-s.x:0,U=s.y<0?-s.y:0;P.drawImage(this.store.bkImg,L,U,this.canvasRect.width,this.canvasRect.height)}f?b?P.translate(-l.x+_[3]*h||0,-l.y+_[0]*h||0):P.translate((v?c.x:-l.x)+_[3]*h||0,(g?c.y:-l.y)+_[0]*h||0):P.translate(-s.x,-s.y);try{for(var $=at(this.store.data.pens),S=$.next();!S.done;S=$.next()){var T=S.value;if(!(!hs(T,this.store)||T.visible==!1)){var R=T.calculative.active;T.calculative.active=!1,T.calculative.img?cs(P,T):jr(P,T,!0),T.calculative.active=R}}}catch(O){n={error:O}}finally{try{S&&!S.done&&(o=$.return)&&o.call($)}finally{if(n)throw n.error}}if(i){I.toBlob(i);return}return I.toDataURL()},e.prototype.activeToPng=function(t){return t===void 0&&(t=2),this.pensToPng(this.store.active,t)},e.prototype.pensToPng=function(t,i){var a,r;if(t===void 0&&(t=this.store.active),i===void 0&&(i=2),t.length!==0){var n=this.getAllByPens(t),o=n.map(function(m){return m.id}),s=Hi(n);if(!isFinite(s.width))throw new Error("can not to png, because width is not finite");var h=ce(s),l=ar(i);s.x-=l[3],s.y-=l[0],s.width+=l[3]+l[1],s.height+=l[0]+l[2],ot(s);var c=document.createElement("canvas");if(c.width=s.width,c.height=s.height,c.width>32767||c.height>32767||!navigator.userAgent.includes("Firefox")&&c.height*c.width>268435456||navigator.userAgent.includes("Firefox")&&c.height*c.width>472907776)throw new Error("can not to png, because the size exceeds the browser limit");var f=c.getContext("2d");f.textBaseline="middle",f.translate(-h.x,-h.y);try{for(var v=at(this.store.data.pens),g=v.next();!g.done;g=v.next()){var y=g.value;if(o.includes(y.id)){if(!hs(y,this.store)||y.visible==!1)continue;var p=y.calculative.active;y.calculative.active=!1,y.calculative.img?cs(f,y):jr(f,y),y.calculative.active=p}}}catch(m){a={error:m}}finally{try{g&&!g.done&&(r=v.return)&&r.call(v)}finally{if(a)throw a.error}}return c.toDataURL()}},e.prototype.toggleAnchorMode=function(){var t;if(this.hotkeyType)this.hotkeyType===Ke.AddAnchor&&(this.hotkeyType=Ke.None,this.store.hoverAnchor?this.externalElements.style.cursor="vertical-text":this.store.hover&&(this.externalElements.style.cursor="move"));else{if(this.store.options.disableAnchor||((t=this.store.hover)===null||t===void 0?void 0:t.disableAnchor))return;this.hotkeyType=Ke.AddAnchor,this.store.hover&&(this.externalElements.style.cursor="pointer")}this.patchFlags=!0},e.prototype.addAnchorHand=function(){if(this.store.activeAnchor&&this.store.active&&this.store.active.length===1&&this.store.active[0].type){var t=[ce(this.store.active[0],!0)];this.store.activeAnchor.prev?this.store.activeAnchor.next||(this.store.activeAnchor.next=Lt({},this.store.activeAnchor.prev),Ge(this.store.activeAnchor.next,180,this.store.activeAnchor),this.initLineRect(this.store.active[0]),this.patchFlags=!0):(this.store.activeAnchor.next||(this.store.activeAnchor.next={penId:this.store.activeAnchor.penId,x:this.store.activeAnchor.x+50,y:this.store.activeAnchor.y}),this.store.activeAnchor.prev=Lt({},this.store.activeAnchor.next),Ge(this.store.activeAnchor.prev,180,this.store.activeAnchor),this.initLineRect(this.store.active[0]),this.patchFlags=!0),this.pushHistory({type:we.Update,pens:[ce(this.store.active[0],!0)],initPens:t})}},e.prototype.removeAnchorHand=function(){if(this.store.activeAnchor&&this.store.active&&this.store.active.length===1&&this.store.active[0].type){var t=[ce(this.store.active[0],!0)];this.hoverType===be.LineAnchorPrev?(this.store.activeAnchor.prev=void 0,this.initLineRect(this.store.active[0]),this.patchFlags=!0):this.hoverType===be.LineAnchorNext?(this.store.activeAnchor.next=void 0,this.initLineRect(this.store.active[0]),this.patchFlags=!0):(this.store.activeAnchor.prev=void 0,this.store.activeAnchor.next=void 0,this.initLineRect(this.store.active[0]),this.patchFlags=!0),this.pushHistory({type:we.Update,pens:[ce(this.store.active[0])],initPens:t})}},e.prototype.toggleAnchorHand=function(){this.store.active.length===1&&this.store.active[0].type&&this.store.activeAnchor&&(this.store.activeAnchor.prevNextType||(this.store.activeAnchor.prevNextType=Zr.Mirror),this.store.activeAnchor.prevNextType=(this.store.activeAnchor.prevNextType+1)%3)},e.prototype.gotoView=function(t,i){var a=Hi(this.store.data.pens);if(!isFinite(a.width))throw new Error("can not move view, because width is not finite");this.store.data.x=this.canvas.clientWidth/2-t*a.width-a.x,this.store.data.y=this.canvas.clientHeight/2-i*a.height-a.y,this.onMovePens(),this.canvasTemplate.init(),this.canvasImage.init(),this.canvasImageBottom.init(),this.render()},e.prototype.showMagnifier=function(){this.magnifierCanvas.magnifier=!0,this.externalElements.style.cursor="default",this.render()},e.prototype.hideMagnifier=function(){this.magnifierCanvas.magnifier=!1,this.externalElements.style.cursor="default",this.render()},e.prototype.toggleMagnifier=function(){this.magnifierCanvas.magnifier=!this.magnifierCanvas.magnifier,this.magnifierCanvas.magnifier&&(this.externalElements.style.cursor="default"),this.render()},e.prototype.destroy=function(){var t,i,a;switch(this.scroll&&this.scroll.destroy(),(t=this.tooltip)===null||t===void 0||t.destroy(),(i=this.dialog)===null||i===void 0||i.destroy(),(a=this.title)===null||a===void 0||a.destroy(),this.externalElements.removeEventListener("gesturestart",this.onGesturestart),this.externalElements.ondragover=function(r){return r.preventDefault()},this.externalElements.ondrop=void 0,this.externalElements.ontouchstart=void 0,this.externalElements.ontouchmove=void 0,this.externalElements.ontouchend=void 0,this.externalElements.onmousedown=void 0,this.externalElements.onmousemove=void 0,this.externalElements.onmouseup=void 0,this.externalElements.onmouseleave=void 0,this.externalElements.ondblclick=void 0,this.store.options.keydown){case $r.Document:document.removeEventListener("keydown",this.onkeydown),document.removeEventListener("keyup",this.onkeyup);break;case $r.Canvas:this.externalElements.removeEventListener("keydown",this.onkeydown),this.externalElements.removeEventListener("keyup",this.onkeyup);break}document.removeEventListener("copy",this.onCopy),document.removeEventListener("cut",this.onCut),document.removeEventListener("paste",this.onPaste),window&&window.removeEventListener("resize",this.onResize),window&&window.removeEventListener("scroll",this.onScroll)},e}(),dt;(function(e){e[e.Link=0]="Link",e[e.SetProps=1]="SetProps",e[e.StartAnimate=2]="StartAnimate",e[e.PauseAnimate=3]="PauseAnimate",e[e.StopAnimate=4]="StopAnimate",e[e.JS=5]="JS",e[e.GlobalFn=6]="GlobalFn",e[e.Emit=7]="Emit",e[e.StartVideo=8]="StartVideo",e[e.PauseVideo=9]="PauseVideo",e[e.StopVideo=10]="StopVideo",e[e.SendPropData=11]="SendPropData",e[e.SendVarData=12]="SendVarData",e[e.Navigator=13]="Navigator",e[e.Dialog=14]="Dialog",e[e.SendData=15]="SendData",e[e.PostMessage=16]="PostMessage",e[e.PostMessageToParent=17]="PostMessageToParent"})(dt||(dt={}));var Dk=function(){function e(t){var i=this;this.parent=t,this.boxWidth=320,this.boxHeight=180,this.ratio=this.boxWidth/this.boxHeight,this.padding=5,this.onMouseDown=function(o){o.preventDefault(),o.stopPropagation(),i.isDown=!0},this.onMouseMove=function(o){if(o.preventDefault(),o.stopPropagation(),i.isDown)try{i.parent.gotoView(o.offsetX/i.box.clientWidth,o.offsetY/i.box.clientHeight)}catch(s){console.warn(s.message),i.isDown=!1}},this.onMouseUp=function(o){o.preventDefault(),o.stopPropagation();try{i.parent.gotoView(o.offsetX/i.box.clientWidth,o.offsetY/i.box.clientHeight)}catch(s){console.warn(s.message)}finally{i.isDown=!1}},this.box=document.createElement("div"),this.img=new Image,this.view=document.createElement("div"),this.box.appendChild(this.img),this.box.appendChild(this.view),this.parent.externalElements.appendChild(this.box),this.box.className="meta2d-map",this.box.onmousedown=this.onMouseDown,this.box.onmousemove=this.onMouseMove,this.box.onmouseup=this.onMouseUp;for(var a,r=0;rthis.ratio){var r=i.width/this.ratio;i.y-=(r-i.height)/2,i.height=r,ot(i)}else{var n=i.height*this.ratio;i.x-=(n-i.width)/2,i.width=n,ot(i)}var o=this.parent.canvasRect,s=0,h=0;if(i.x<0)s=-i.x/i.width;else if(i.x+i.width>o.width){var l=0;o.width>i.width&&(l=o.width-i.width),s=(-i.x+l)/i.width}if(i.y<0)h=-i.y/i.height;else if(i.y+i.height>o.height){var l=0;o.height>i.height&&(l=o.height-i.height),h=(-i.y+l)/i.height}var c=o.width>i.width?1:o.width/i.width,f=o.height>i.height?1:o.height/i.height;this.view.style.left=this.padding+s*this.boxWidth+"px",this.view.style.width=c*this.boxWidth+"px",this.view.style.top=this.padding+h*this.boxHeight+"px",this.view.style.height=f*this.boxHeight+"px"}},e}();function Wo(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var Qo={exports:{}};(function(e,t){(function(i){e.exports=i()})(function(){return function(){return function i(a,r,n){function o(l,c){if(!r[l]){if(!a[l]){var f=typeof Wo=="function"&&Wo;if(!c&&f)return f(l,!0);if(s)return s(l,!0);var v=new Error("Cannot find module '"+l+"'");throw v.code="MODULE_NOT_FOUND",v}var g=r[l]={exports:{}};a[l][0].call(g.exports,function(y){return o(a[l][1][y]||y)},g,g.exports,i,a,r,n)}return r[l].exports}for(var s=typeof Wo=="function"&&Wo,h=0;h0&&(O.topicAliasMaximum>65535?_("MqttClient :: options.topicAliasMaximum is out of range"):this.topicAliasRecv=new l(O.topicAliasMaximum)),this.on("connect",function(){const ae=this.queue;_("connect :: sending queued packets"),function V(){const F=ae.shift();_("deliver :: entry %o",F);let q=null;if(!F)return void G._resubscribe();q=F.packet,_("deliver :: call _sendPacket for %o",q);let Y=!0;q.messageId&&q.messageId!==0&&(G.messageIdProvider.register(q.messageId)||(Y=!1)),Y?G._sendPacket(q,function(W){F.cb&&F.cb(W),V()}):(_("messageId: %d has already used. The message is skipped and removed.",q.messageId),V())}()}),this.on("close",function(){_("close :: connected set to `false`"),this.connected=!1,_("close :: clearing connackTimer"),clearTimeout(this.connackTimer),_("close :: clearing ping timer"),G.pingTimer!==null&&(G.pingTimer.clear(),G.pingTimer=null),this.topicAliasRecv&&this.topicAliasRecv.clear(),_("close :: calling _setupReconnect"),this._setupReconnect()}),s.call(this),_("MqttClient :: setting up stream"),this._setupStream()}y(T,s),T.prototype._setupStream=function(){const R=this,O=new g,K=f.parser(this.options);let G=null;const ae=[];function V(){if(ae.length)k(F);else{const Y=G;G=null,Y()}}function F(){_("work :: getting next packet in queue");const Y=ae.shift();if(Y)_("work :: packet pulled from queue"),R._handlePacket(Y,V);else{_("work :: no packets in queue");const W=G;G=null,_("work :: done flag is %s",!!W),W&&W()}}_("_setupStream :: calling method to clear reconnect"),this._clearReconnect(),_("_setupStream :: using streamBuilder provided to client to create stream"),this.stream=this.streamBuilder(this),K.on("packet",function(Y){_("parser :: on packet push to packets array."),ae.push(Y)}),O._write=function(Y,W,J){G=J,_("writable stream :: parsing buffer"),K.parse(Y),F()},_("_setupStream :: pipe stream to writable stream"),this.stream.pipe(O),this.stream.on("error",function(Y){_("streamErrorHandler :: error",Y.message),Y.code?(_("streamErrorHandler :: emitting error"),R.emit("error",Y)):S(Y)}),this.stream.on("close",function(){var Y;_("(%s)stream :: on close",R.options.clientId),(Y=R.outgoing)&&(_("flushVolatile :: deleting volatile messages from the queue and setting their callbacks as error function"),Object.keys(Y).forEach(function(W){Y[W].volatile&&typeof Y[W].cb=="function"&&(Y[W].cb(new Error("Connection closed")),delete Y[W])})),_("stream: emit close to MqttClient"),R.emit("close")}),_("_setupStream: sending packet `connect`");const q=Object.create(this.options);if(q.cmd="connect",this.topicAliasRecv&&(q.properties||(q.properties={}),this.topicAliasRecv&&(q.properties.topicAliasMaximum=this.topicAliasRecv.max)),U(this,q),K.on("error",this.emit.bind(this,"error")),this.options.properties){if(!this.options.properties.authenticationMethod&&this.options.properties.authenticationData)return R.end(()=>this.emit("error",new Error("Packet has no Authentication Method"))),this;this.options.properties.authenticationMethod&&this.options.authPacket&&typeof this.options.authPacket=="object"&&U(this,x({cmd:"auth",reasonCode:0},this.options.authPacket))}this.stream.setMaxListeners(1e3),clearTimeout(this.connackTimer),this.connackTimer=setTimeout(function(){_("!!connectTimeout hit!! Calling _cleanUp with force `true`"),R._cleanUp(!0)},this.options.connectTimeout)},T.prototype._handlePacket=function(R,O){const K=this.options;if(K.protocolVersion===5&&K.properties&&K.properties.maximumPacketSize&&K.properties.maximumPacketSize0||!F())&&this._storeProcessingQueue.push({invoke:F,cbStorePut:K.cbStorePut,callback:G}),this},T.prototype.subscribe=function(){const R=this,O=new Array(arguments.length);for(let re=0;re0){const se={qos:le.qos};q===5&&(se.nl=le.nl||!1,se.rap=le.rap||!1,se.rh=le.rh||0,se.properties=le.properties),R._resubscribeTopics[le.topic]=se,he.push(le.topic)}}),R.messageIdToTopic[ee.messageId]=he}return R.outgoing[ee.messageId]={volatile:!0,cb:function(he,le){if(!he){const se=le.granted;for(let E=0;E0||!J())&&this._storeProcessingQueue.push({invoke:J,callback:V}),this},T.prototype.unsubscribe=function(){const R=this,O=new Array(arguments.length);for(let q=0;q0||!F())&&this._storeProcessingQueue.push({invoke:F,callback:G}),this},T.prototype.end=function(R,O,K){const G=this;function ae(){_("end :: (%s) :: finish :: calling _cleanUp with force %s",G.options.clientId,R),G._cleanUp(R,()=>{_("end :: finish :: calling process.nextTick on closeStores"),k(function(){_("end :: closeStores: closing incoming and outgoing stores"),G.disconnected=!0,G.incomingStore.close(function(V){G.outgoingStore.close(function(F){if(_("end :: closeStores: emitting end"),G.emit("end"),K){const q=V||F;_("end :: closeStores: invoking callback with args"),K(q)}})}),G._deferredReconnect&&G._deferredReconnect()}.bind(G))},O)}return _("end :: (%s)",this.options.clientId),R!=null&&typeof R=="boolean"||(K=O||S,O=R,R=!1,typeof O!="object"&&(K=O,O=null,typeof K!="function"&&(K=S))),typeof O!="object"&&(K=O,O=null),_("end :: cb? %s",!!K),K=K||S,this.disconnecting?(K(),this):(this._clearReconnect(),this.disconnecting=!0,!R&&Object.keys(this.outgoing).length>0?(_("end :: (%s) :: calling finish in 10ms once outgoing is empty",G.options.clientId),this.once("outgoingEmpty",setTimeout.bind(null,ae,10))):(_("end :: (%s) :: immediately calling finish",G.options.clientId),ae()),this)},T.prototype.removeOutgoingMessage=function(R){const O=this.outgoing[R]?this.outgoing[R].cb:null;return delete this.outgoing[R],this.outgoingStore.del({messageId:R},function(){O(new Error("Message removed"))}),this},T.prototype.reconnect=function(R){_("client reconnect");const O=this,K=function(){R?(O.options.incomingStore=R.incomingStore,O.options.outgoingStore=R.outgoingStore):(O.options.incomingStore=null,O.options.outgoingStore=null),O.incomingStore=O.options.incomingStore||new h,O.outgoingStore=O.options.outgoingStore||new h,O.disconnecting=!1,O.disconnected=!1,O._deferredReconnect=null,O._reconnect()};return this.disconnecting&&!this.disconnected?this._deferredReconnect=K:K(),this},T.prototype._reconnect=function(){_("_reconnect: emitting reconnect to client"),this.emit("reconnect"),this.connected?(this.end(()=>{this._setupStream()}),_("client already connected. disconnecting first.")):(_("_reconnect: calling _setupStream"),this._setupStream())},T.prototype._setupReconnect=function(){const R=this;!R.disconnecting&&!R.reconnectTimer&&R.options.reconnectPeriod>0?(this.reconnecting||(_("_setupReconnect :: emit `offline` state"),this.emit("offline"),_("_setupReconnect :: set `reconnecting` to `true`"),this.reconnecting=!0),_("_setupReconnect :: setting reconnectTimer for %d ms",R.options.reconnectPeriod),R.reconnectTimer=setInterval(function(){_("reconnectTimer :: reconnect triggered!"),R._reconnect()},R.options.reconnectPeriod)):_("_setupReconnect :: doing nothing...")},T.prototype._clearReconnect=function(){_("_clearReconnect : clearing reconnect timer"),this.reconnectTimer&&(clearInterval(this.reconnectTimer),this.reconnectTimer=null)},T.prototype._cleanUp=function(R,O){const K=arguments[2];if(O&&(_("_cleanUp :: done callback provided for on stream close"),this.stream.on("close",O)),_("_cleanUp :: forced? %s",R),R)this.options.reconnectPeriod===0&&this.options.clean&&(G=this.outgoing)&&(_("flush: queue exists? %b",!!G),Object.keys(G).forEach(function(ae){typeof G[ae].cb=="function"&&(G[ae].cb(new Error("Connection closed")),delete G[ae])})),_("_cleanUp :: (%s) :: destroying stream",this.options.clientId),this.stream.destroy();else{const ae=x({cmd:"disconnect"},K);_("_cleanUp :: (%s) :: call _sendPacket with disconnect packet",this.options.clientId),this._sendPacket(ae,I.bind(null,this.stream.end.bind(this.stream)))}var G;this.disconnecting||(_("_cleanUp :: client not disconnecting. Clearing and resetting reconnect."),this._clearReconnect(),this._setupReconnect()),this.pingTimer!==null&&(_("_cleanUp :: clearing pingTimer"),this.pingTimer.clear(),this.pingTimer=null),O&&!this.connected&&(_("_cleanUp :: (%s) :: removing stream `done` callback `close` listener",this.options.clientId),this.stream.removeListener("close",O),O())},T.prototype._sendPacket=function(R,O,K){_("_sendPacket :: (%s) :: start",this.options.clientId),K=K||S,O=O||S;const G=function(ae,V){if(ae.options.protocolVersion===5&&V.cmd==="publish"){let F;V.properties&&(F=V.properties.topicAlias);const q=V.topic.toString();if(ae.topicAliasSend)if(F){if(q.length!==0&&(_("applyTopicAlias :: register topic: %s - alias: %d",q,F),!ae.topicAliasSend.put(q,F)))return _("applyTopicAlias :: error out of range. topic: %s - alias: %d",q,F),new Error("Sending Topic Alias out of range")}else q.length!==0&&(ae.options.autoAssignTopicAlias?(F=ae.topicAliasSend.getAliasByTopic(q))?(V.topic="",V.properties={...V.properties,topicAlias:F},_("applyTopicAlias :: auto assign(use) topic: %s - alias: %d",q,F)):(F=ae.topicAliasSend.getLruAlias(),ae.topicAliasSend.put(q,F),V.properties={...V.properties,topicAlias:F},_("applyTopicAlias :: auto assign topic: %s - alias: %d",q,F)):ae.options.autoUseTopicAlias&&(F=ae.topicAliasSend.getAliasByTopic(q))&&(V.topic="",V.properties={...V.properties,topicAlias:F},_("applyTopicAlias :: auto use topic: %s - alias: %d",q,F)));else if(F)return _("applyTopicAlias :: error out of range. topic: %s - alias: %d",q,F),new Error("Sending Topic Alias out of range")}}(this,R);if(G)O(G);else{if(!this.connected)return R.cmd==="auth"?(this._shiftPingInterval(),void U(this,R,O)):(_("_sendPacket :: client not connected. Storing packet offline."),void this._storePacket(R,O,K));switch(this._shiftPingInterval(),R.cmd){case"publish":break;case"pubrel":return void $(this,R,O,K);default:return void U(this,R,O)}switch(R.qos){case 2:case 1:$(this,R,O,K);break;case 0:default:U(this,R,O)}_("_sendPacket :: (%s) :: end",this.options.clientId)}},T.prototype._storePacket=function(R,O,K){_("_storePacket :: packet: %o",R),_("_storePacket :: cb? %s",!!O),K=K||S;let G=R;if(G.cmd==="publish"){const ae=L(this,G=m(R));if(ae)return O&&O(ae)}(G.qos||0)===0&&this.queueQoSZero||G.cmd!=="publish"?this.queue.push({packet:G,cb:O}):G.qos>0?(O=this.outgoing[G.messageId]?this.outgoing[G.messageId].cb:null,this.outgoingStore.put(G,function(ae){if(ae)return O&&O(ae);K()})):O&&O(new Error("No connection to broker"))},T.prototype._setupPingTimer=function(){_("_setupPingTimer :: keepalive %d (seconds)",this.options.keepalive);const R=this;!this.pingTimer&&this.options.keepalive&&(this.pingResp=!0,this.pingTimer=p(function(){R._checkPing()},1e3*this.options.keepalive))},T.prototype._shiftPingInterval=function(){this.pingTimer&&this.options.keepalive&&this.options.reschedulePings&&this.pingTimer.reschedule(1e3*this.options.keepalive)},T.prototype._checkPing=function(){_("_checkPing :: checking ping..."),this.pingResp?(_("_checkPing :: ping response received. Clearing flag and sending `pingreq`"),this.pingResp=!1,this._sendPacket({cmd:"pingreq"})):(_("_checkPing :: calling _cleanUp with force true"),this._cleanUp(!0))},T.prototype._handlePingresp=function(){this.pingResp=!0},T.prototype._handleConnack=function(R){_("_handleConnack");const O=this.options,K=O.protocolVersion===5?R.reasonCode:R.returnCode;if(clearTimeout(this.connackTimer),delete this.topicAliasSend,R.properties){if(R.properties.topicAliasMaximum){if(R.properties.topicAliasMaximum>65535)return void this.emit("error",new Error("topicAliasMaximum from broker is out of range"));R.properties.topicAliasMaximum>0&&(this.topicAliasSend=new c(R.properties.topicAliasMaximum))}R.properties.serverKeepAlive&&O.keepalive&&(O.keepalive=R.properties.serverKeepAlive,this._shiftPingInterval()),R.properties.maximumPacketSize&&(O.properties||(O.properties={}),O.properties.maximumPacketSize=R.properties.maximumPacketSize)}if(K===0)this.reconnecting=!1,this._onConnect(R);else if(K>0){const G=new Error("Connection refused: "+M[K]);G.code=K,this.emit("error",G)}},T.prototype._handleAuth=function(R){const O=this.options.protocolVersion,K=O===5?R.reasonCode:R.returnCode;if(O!==5){const ae=new Error("Protocol error: Auth packets are only supported in MQTT 5. Your version:"+O);return ae.code=K,void this.emit("error",ae)}const G=this;this.handleAuth(R,function(ae,V){if(ae)G.emit("error",ae);else if(K===24)G.reconnecting=!1,G._sendPacket(V);else{const F=new Error("Connection refused: "+M[K]);ae.code=K,G.emit("error",F)}})},T.prototype.handleAuth=function(R,O){O()},T.prototype._handlePublish=function(R,O){_("_handlePublish: packet %o",R),O=O!==void 0?O:S;let K=R.topic.toString();const G=R.payload,ae=R.qos,V=R.messageId,F=this,q=this.options,Y=[0,16,128,131,135,144,145,151,153];if(this.options.protocolVersion===5){let W;if(R.properties&&(W=R.properties.topicAlias),W!==void 0)if(K.length===0){if(!(W>0&&W<=65535))return _("_handlePublish :: topic alias out of range. alias: %d",W),void this.emit("error",new Error("Received Topic Alias is out of range"));{const J=this.topicAliasRecv.getTopicByAlias(W);if(!J)return _("_handlePublish :: unregistered topic alias. alias: %d",W),void this.emit("error",new Error("Received unregistered Topic Alias"));_("_handlePublish :: topic complemented by alias. topic: %s - alias: %d",K=J,W)}}else{if(!this.topicAliasRecv.put(K,W))return _("_handlePublish :: topic alias out of range. alias: %d",W),void this.emit("error",new Error("Received Topic Alias is out of range"));_("_handlePublish :: registered topic: %s - alias: %d",K,W)}}switch(_("_handlePublish: qos %d",ae),ae){case 2:q.customHandleAcks(K,G,R,function(W,J){return W instanceof Error||(J=W,W=null),W?F.emit("error",W):Y.indexOf(J)===-1?F.emit("error",new Error("Wrong reason code for pubrec")):void(J?F._sendPacket({cmd:"pubrec",messageId:V,reasonCode:J},O):F.incomingStore.put(R,function(){F._sendPacket({cmd:"pubrec",messageId:V},O)}))});break;case 1:q.customHandleAcks(K,G,R,function(W,J){return W instanceof Error||(J=W,W=null),W?F.emit("error",W):Y.indexOf(J)===-1?F.emit("error",new Error("Wrong reason code for puback")):(J||F.emit("message",K,G,R),void F.handleMessage(R,function(re){if(re)return O&&O(re);F._sendPacket({cmd:"puback",messageId:V,reasonCode:J},O)}))});break;case 0:this.emit("message",K,G,R),this.handleMessage(R,O);break;default:_("_handlePublish: unknown QoS. Doing nothing.")}},T.prototype.handleMessage=function(R,O){O()},T.prototype._handleAck=function(R){const O=R.messageId,K=R.cmd;let G=null;const ae=this.outgoing[O]?this.outgoing[O].cb:null,V=this;let F;if(ae){switch(_("_handleAck :: packet type",K),K){case"pubcomp":case"puback":{const q=R.reasonCode;q&&q>0&&q!==16&&((F=new Error("Publish error: "+M[q])).code=q,ae(F,R)),delete this.outgoing[O],this.outgoingStore.del(R,ae),this.messageIdProvider.deallocate(O),this._invokeStoreProcessingQueue();break}case"pubrec":{G={cmd:"pubrel",qos:2,messageId:O};const q=R.reasonCode;q&&q>0&&q!==16?((F=new Error("Publish error: "+M[q])).code=q,ae(F,R)):this._sendPacket(G);break}case"suback":delete this.outgoing[O],this.messageIdProvider.deallocate(O);for(let q=0;q0)if(this.options.resubscribe)if(this.options.protocolVersion===5){_("_resubscribe: protocolVersion 5");for(let O=0;O0){const R=this._storeProcessingQueue[0];if(R&&R.invoke())return this._storeProcessingQueue.shift(),!0}return!1},T.prototype._invokeAllStoreProcessingQueue=function(){for(;this._invokeStoreProcessingQueue(););},T.prototype._flushStoreProcessingQueue=function(){for(const R of this._storeProcessingQueue)R.cbStorePut&&R.cbStorePut(new Error("Connection closed")),R.callback&&R.callback(new Error("Connection closed"));this._storeProcessingQueue.splice(0)},a.exports=T}).call(this)}).call(this,i("_process"),typeof Ot<"u"?Ot:typeof self<"u"?self:typeof window<"u"?window:{})},{"./default-message-id-provider":7,"./store":8,"./topic-alias-recv":9,"./topic-alias-send":10,"./validations":11,_process:50,debug:18,events:22,inherits:24,"mqtt-packet":40,"readable-stream":69,reinterval:70,"rfdc/default":71,xtend:81}],2:[function(i,a,r){const{Buffer:n}=i("buffer"),o=i("readable-stream").Transform,s=i("duplexify");let h,l,c,f=!1;a.exports=function(v,g){if(g.hostname=g.hostname||g.host,!g.hostname)throw new Error("Could not determine host. Specify host manually.");const y=g.protocolId==="MQIsdp"&&g.protocolVersion===3?"mqttv3.1":"mqtt";(function(m){m.hostname||(m.hostname="localhost"),m.path||(m.path="/"),m.wsOptions||(m.wsOptions={})})(g);const p=function(m,b){const x=m.protocol==="alis"?"wss":"ws";let _=x+"://"+m.hostname+m.path;return m.port&&m.port!==80&&m.port!==443&&(_=x+"://"+m.hostname+":"+m.port+m.path),typeof m.transformWsUrl=="function"&&(_=m.transformWsUrl(_,m,b)),_}(g,v);return(h=g.my).connectSocket({url:p,protocols:y}),l=function(){const m=new o;return m._write=function(b,x,_){h.sendSocketMessage({data:b.buffer,success:function(){_()},fail:function(){_(new Error)}})},m._flush=function(b){h.closeSocket({success:function(){b()}})},m}(),c=s.obj(),f||(f=!0,h.onSocketOpen(function(){c.setReadable(l),c.setWritable(l),c.emit("connect")}),h.onSocketMessage(function(m){if(typeof m.data=="string"){const b=n.from(m.data,"base64");l.push(b)}else{const b=new FileReader;b.addEventListener("load",function(){let x=b.result;x=x instanceof ArrayBuffer?n.from(x):n.from(x,"utf8"),l.push(x)}),b.readAsArrayBuffer(m.data)}}),h.onSocketClose(function(){c.end(),c.destroy()}),h.onSocketError(function(m){c.destroy(m)})),c}},{buffer:17,duplexify:20,"readable-stream":69}],3:[function(i,a,r){const n=i("net"),o=i("debug")("mqttjs:tcp");a.exports=function(s,h){h.port=h.port||1883,h.hostname=h.hostname||h.host||"localhost";const l=h.port,c=h.hostname;return o("port %d and host %s",l,c),n.createConnection(l,c)}},{debug:18,net:16}],4:[function(i,a,r){const n=i("tls"),o=i("net"),s=i("debug")("mqttjs:tls");a.exports=function(h,l){l.port=l.port||8883,l.host=l.hostname||l.host||"localhost",o.isIP(l.host)===0&&(l.servername=l.host),l.rejectUnauthorized=l.rejectUnauthorized!==!1,delete l.path,s("port %d host %s rejectUnauthorized %b",l.port,l.host,l.rejectUnauthorized);const c=n.connect(l);function f(v){l.rejectUnauthorized&&h.emit("error",v),c.end()}return c.on("secureConnect",function(){l.rejectUnauthorized&&!c.authorized?c.emit("error",new Error("TLS not authorized")):c.removeListener("error",f)}),c.on("error",f),c}},{debug:18,net:16,tls:16}],5:[function(i,a,r){(function(n){(function(){const{Buffer:o}=i("buffer"),s=i("ws"),h=i("debug")("mqttjs:ws"),l=i("duplexify"),c=i("readable-stream").Transform,f=["rejectUnauthorized","ca","cert","key","pfx","passphrase"],v=n!==void 0&&n.title==="browser"||typeof __webpack_require__=="function";function g(p,m){let b=p.protocol+"://"+p.hostname+":"+p.port+p.path;return typeof p.transformWsUrl=="function"&&(b=p.transformWsUrl(b,p,m)),b}function y(p){const m=p;return p.hostname||(m.hostname="localhost"),p.port||(p.protocol==="wss"?m.port=443:m.port=80),p.path||(m.path="/"),p.wsOptions||(m.wsOptions={}),v||p.protocol!=="wss"||f.forEach(function(b){Object.prototype.hasOwnProperty.call(p,b)&&!Object.prototype.hasOwnProperty.call(p.wsOptions,b)&&(m.wsOptions[b]=p[b])}),m}a.exports=v?function(p,m){let b;h("browserStreamBuilder");const x=function(R){const O=y(R);if(O.hostname||(O.hostname=O.host),!O.hostname){if(typeof document>"u")throw new Error("Could not determine host. Specify host manually.");const K=new URL(document.URL);O.hostname=K.hostname,O.port||(O.port=K.port)}return O.objectMode===void 0&&(O.objectMode=!(O.binary===!0||O.binary===void 0)),O}(m).browserBufferSize||524288,_=m.browserBufferTimeout||1e3,k=!m.objectMode,I=function(R,O){const K=O.protocolId==="MQIsdp"&&O.protocolVersion===3?"mqttv3.1":"mqtt",G=g(O,R),ae=new WebSocket(G,[K]);return ae.binaryType="arraybuffer",ae}(p,m),P=function(R,O,K){const G=new c({objectModeMode:R.objectMode});return G._write=O,G._flush=K,G}(m,function R(O,K,G){I.bufferedAmount>x&&setTimeout(R,_,O,K,G),k&&typeof O=="string"&&(O=o.from(O,"utf8"));try{I.send(O)}catch(ae){return G(ae)}G()},function(R){I.close(),R()});m.objectMode||(P._writev=T),P.on("close",()=>{I.close()});const M=I.addEventListener!==void 0;function L(){b.setReadable(P),b.setWritable(P),b.emit("connect")}function U(){b.end(),b.destroy()}function $(R){b.destroy(R)}function S(R){let O=R.data;O=O instanceof ArrayBuffer?o.from(O):o.from(O,"utf8"),P.push(O)}function T(R,O){const K=new Array(R.length);for(let G=0;G{k.destroy()}),k}}).call(this)}).call(this,i("_process"))},{_process:50,buffer:17,debug:18,duplexify:20,"readable-stream":69,ws:80}],6:[function(i,a,r){const{Buffer:n}=i("buffer"),o=i("readable-stream").Transform,s=i("duplexify");let h,l,c;a.exports=function(f,v){if(v.hostname=v.hostname||v.host,!v.hostname)throw new Error("Could not determine host. Specify host manually.");const g=v.protocolId==="MQIsdp"&&v.protocolVersion===3?"mqttv3.1":"mqtt";(function(m){m.hostname||(m.hostname="localhost"),m.path||(m.path="/"),m.wsOptions||(m.wsOptions={})})(v);const y=function(m,b){const x=m.protocol==="wxs"?"wss":"ws";let _=x+"://"+m.hostname+m.path;return m.port&&m.port!==80&&m.port!==443&&(_=x+"://"+m.hostname+":"+m.port+m.path),typeof m.transformWsUrl=="function"&&(_=m.transformWsUrl(_,m,b)),_}(v,f);h=wx.connectSocket({url:y,protocols:[g]}),l=function(){const m=new o;return m._write=function(b,x,_){h.send({data:b.buffer,success:function(){_()},fail:function(k){_(new Error(k))}})},m._flush=function(b){h.close({success:function(){b()}})},m}(),(c=s.obj())._destroy=function(m,b){h.close({success:function(){b&&b(m)}})};const p=c.destroy;return c.destroy=function(){c.destroy=p;const m=this;setTimeout(function(){h.close({fail:function(){m._destroy(new Error)}})},0)}.bind(c),h.onOpen(function(){c.setReadable(l),c.setWritable(l),c.emit("connect")}),h.onMessage(function(m){let b=m.data;b=b instanceof ArrayBuffer?n.from(b):n.from(b,"utf8"),l.push(b)}),h.onClose(function(){c.end(),c.destroy()}),h.onError(function(m){c.destroy(new Error(m.errMsg))}),c}},{buffer:17,duplexify:20,"readable-stream":69}],7:[function(i,a,r){function n(){if(!(this instanceof n))return new n;this.nextId=Math.max(1,Math.floor(65535*Math.random()))}n.prototype.allocate=function(){const o=this.nextId++;return this.nextId===65536&&(this.nextId=1),o},n.prototype.getLastAllocated=function(){return this.nextId===1?65535:this.nextId-1},n.prototype.register=function(o){return!0},n.prototype.deallocate=function(o){},n.prototype.clear=function(){},a.exports=n},{}],8:[function(i,a,r){const n=i("xtend"),o=i("readable-stream").Readable,s={objectMode:!0},h={clean:!0};function l(c){if(!(this instanceof l))return new l(c);this.options=c||{},this.options=n(h,c),this._inflights=new Map}l.prototype.put=function(c,f){return this._inflights.set(c.messageId,c),f&&f(),this},l.prototype.createStream=function(){const c=new o(s),f=[];let v=!1,g=0;return this._inflights.forEach(function(y,p){f.push(y)}),c._read=function(){!v&&gthis.max)&&(this.aliasToTopic[s]=o,this.length=Object.keys(this.aliasToTopic).length,!0)},n.prototype.getTopicByAlias=function(o){return this.aliasToTopic[o]},n.prototype.clear=function(){this.aliasToTopic={}},a.exports=n},{}],10:[function(i,a,r){const n=i("lru-cache"),o=i("number-allocator").NumberAllocator;function s(h){if(!(this instanceof s))return new s(h);h>0&&(this.aliasToTopic=new n({max:h}),this.topicToAlias={},this.numberAllocator=new o(1,h),this.max=h,this.length=0)}s.prototype.put=function(h,l){if(l===0||l>this.max)return!1;const c=this.aliasToTopic.get(l);return c&&delete this.topicToAlias[c],this.aliasToTopic.set(l,h),this.topicToAlias[h]=l,this.numberAllocator.use(l),this.length=this.aliasToTopic.length,!0},s.prototype.getTopicByAlias=function(h){return this.aliasToTopic.get(h)},s.prototype.getAliasByTopic=function(h){const l=this.topicToAlias[h];return l!==void 0&&this.aliasToTopic.get(l),l},s.prototype.clear=function(){this.aliasToTopic.reset(),this.topicToAlias={},this.numberAllocator.clear(),this.length=0},s.prototype.getLruAlias=function(){return this.numberAllocator.firstVacant()||this.aliasToTopic.keys()[this.aliasToTopic.length-1]},a.exports=s},{"lru-cache":37,"number-allocator":46}],11:[function(i,a,r){function n(o){const s=o.split("/");for(let h=0;h0?b-4:b;for(p=0;p>16&255,_[k++]=y>>8&255,_[k++]=255&y;return x===2&&(y=o[g.charCodeAt(p)]<<2|o[g.charCodeAt(p+1)]>>4,_[k++]=255&y),x===1&&(y=o[g.charCodeAt(p)]<<10|o[g.charCodeAt(p+1)]<<4|o[g.charCodeAt(p+2)]>>2,_[k++]=y>>8&255,_[k++]=255&y),_},r.fromByteArray=function(g){for(var y,p=g.length,m=p%3,b=[],x=0,_=p-m;x<_;x+=16383)b.push(v(g,x,x+16383>_?_:x+16383));return m===1?(y=g[p-1],b.push(n[y>>2]+n[y<<4&63]+"==")):m===2&&(y=(g[p-2]<<8)+g[p-1],b.push(n[y>>10]+n[y>>4&63]+n[y<<2&63]+"=")),b.join("")};for(var n=[],o=[],s=typeof Uint8Array<"u"?Uint8Array:Array,h="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",l=0,c=h.length;l0)throw new Error("Invalid string. Length must be a multiple of 4");var p=g.indexOf("=");return p===-1&&(p=y),[p,p===y?0:4-p%4]}function v(g,y,p){for(var m,b,x=[],_=y;_>18&63]+n[b>>12&63]+n[b>>6&63]+n[63&b]);return x.join("")}o["-".charCodeAt(0)]=62,o["_".charCodeAt(0)]=63},{}],14:[function(i,a,r){const{Buffer:n}=i("buffer"),o=Symbol.for("BufferList");function s(h){if(!(this instanceof s))return new s(h);s._init.call(this,h)}s._init=function(h){Object.defineProperty(this,o,{value:!0}),this._bufs=[],this.length=0,h&&this.append(h)},s.prototype._new=function(h){return new s(h)},s.prototype._offset=function(h){if(h===0)return[0,0];let l=0;for(let c=0;cthis.length||h<0)return;const l=this._offset(h);return this._bufs[l[0]][l[1]]},s.prototype.slice=function(h,l){return typeof h=="number"&&h<0&&(h+=this.length),typeof l=="number"&&l<0&&(l+=this.length),this.copy(null,0,h,l)},s.prototype.copy=function(h,l,c,f){if((typeof c!="number"||c<0)&&(c=0),(typeof f!="number"||f>this.length)&&(f=this.length),c>=this.length||f<=0)return h||n.alloc(0);const v=!!h,g=this._offset(c),y=f-c;let p=y,m=v&&l||0,b=g[1];if(c===0&&f===this.length){if(!v)return this._bufs.length===1?this._bufs[0]:n.concat(this._bufs,this.length);for(let x=0;x_)){this._bufs[x].copy(h,m,b,b+p),m+=_;break}this._bufs[x].copy(h,m,b),m+=_,p-=_,b&&(b=0)}return h.length>m?h.slice(0,m):h},s.prototype.shallowSlice=function(h,l){if(h=h||0,l=typeof l!="number"?this.length:l,h<0&&(h+=this.length),l<0&&(l+=this.length),h===l)return this._new();const c=this._offset(h),f=this._offset(l),v=this._bufs.slice(c[0],f[0]+1);return f[1]===0?v.pop():v[v.length-1]=v[v.length-1].slice(0,f[1]),c[1]!==0&&(v[0]=v[0].slice(c[1])),this._new(v)},s.prototype.toString=function(h,l,c){return this.slice(l,c).toString(h)},s.prototype.consume=function(h){if(h=Math.trunc(h),Number.isNaN(h)||h<=0)return this;for(;this._bufs.length;){if(!(h>=this._bufs[0].length)){this._bufs[0]=this._bufs[0].slice(h),this.length-=h;break}h-=this._bufs[0].length,this.length-=this._bufs[0].length,this._bufs.shift()}return this},s.prototype.duplicate=function(){const h=this._new();for(let l=0;lthis.length?this.length:l;const f=this._offset(l);let v=f[0],g=f[1];for(;v=h.length){const p=y.indexOf(h,g);if(p!==-1)return this._reverseOffset([v,p]);g=y.length-h.length+1}else{const p=this._reverseOffset([v,g]);if(this._match(p,h))return p;g++}g=0}return-1},s.prototype._match=function(h,l){if(this.length-hh)throw new RangeError('The value "'+E+'" is invalid for option "size"');var C=new Uint8Array(E);return C.__proto__=c.prototype,C}function c(E,C,D){if(typeof E=="number"){if(typeof C=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return g(E)}return f(E,C,D)}function f(E,C,D){if(typeof E=="string")return function(Q,ne){if(typeof ne=="string"&&ne!==""||(ne="utf8"),!c.isEncoding(ne))throw new TypeError("Unknown encoding: "+ne);var ye=0|m(Q,ne),ge=l(ye),xe=ge.write(Q,ne);return xe!==ye&&(ge=ge.slice(0,xe)),ge}(E,C);if(ArrayBuffer.isView(E))return y(E);if(E==null)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof E);if(le(E,ArrayBuffer)||E&&le(E.buffer,ArrayBuffer))return function(Q,ne,ye){if(ne<0||Q.byteLength=h)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+h.toString(16)+" bytes");return 0|E}function m(E,C){if(c.isBuffer(E))return E.length;if(ArrayBuffer.isView(E)||le(E,ArrayBuffer))return E.byteLength;if(typeof E!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof E);var D=E.length,H=arguments.length>2&&arguments[2]===!0;if(!H&&D===0)return 0;for(var X=!1;;)switch(C){case"ascii":case"latin1":case"binary":return D;case"utf8":case"utf-8":return re(E).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*D;case"hex":return D>>>1;case"base64":return ee(E).length;default:if(X)return H?-1:re(E).length;C=(""+C).toLowerCase(),X=!0}}function b(E,C,D){var H=E[C];E[C]=E[D],E[D]=H}function x(E,C,D,H,X){if(E.length===0)return-1;if(typeof D=="string"?(H=D,D=0):D>2147483647?D=2147483647:D<-2147483648&&(D=-2147483648),se(D=+D)&&(D=X?0:E.length-1),D<0&&(D=E.length+D),D>=E.length){if(X)return-1;D=E.length-1}else if(D<0){if(!X)return-1;D=0}if(typeof C=="string"&&(C=c.from(C,H)),c.isBuffer(C))return C.length===0?-1:_(E,C,D,H,X);if(typeof C=="number")return C&=255,typeof Uint8Array.prototype.indexOf=="function"?X?Uint8Array.prototype.indexOf.call(E,C,D):Uint8Array.prototype.lastIndexOf.call(E,C,D):_(E,[C],D,H,X);throw new TypeError("val must be string, number or Buffer")}function _(E,C,D,H,X){var Q,ne=1,ye=E.length,ge=C.length;if(H!==void 0&&((H=String(H).toLowerCase())==="ucs2"||H==="ucs-2"||H==="utf16le"||H==="utf-16le")){if(E.length<2||C.length<2)return-1;ne=2,ye/=2,ge/=2,D/=2}function xe(Et,qe){return ne===1?Et[qe]:Et.readUInt16BE(qe*ne)}if(X){var Se=-1;for(Q=D;Qye&&(D=ye-ge),Q=D;Q>=0;Q--){for(var xt=!0,it=0;itX&&(H=X):H=X;var Q=C.length;H>Q/2&&(H=Q/2);for(var ne=0;ne>8,ge=ne%256,xe.push(ge),xe.push(ye);return xe}(C,E.length-D),E,D,H)}function $(E,C,D){return C===0&&D===E.length?o.fromByteArray(E):o.fromByteArray(E.slice(C,D))}function S(E,C,D){D=Math.min(E.length,D);for(var H=[],X=C;X239?4:xe>223?3:xe>191?2:1;if(X+xt<=D)switch(xt){case 1:xe<128&&(Se=xe);break;case 2:(192&(Q=E[X+1]))==128&&(ge=(31&xe)<<6|63&Q)>127&&(Se=ge);break;case 3:Q=E[X+1],ne=E[X+2],(192&Q)==128&&(192&ne)==128&&(ge=(15&xe)<<12|(63&Q)<<6|63&ne)>2047&&(ge<55296||ge>57343)&&(Se=ge);break;case 4:Q=E[X+1],ne=E[X+2],ye=E[X+3],(192&Q)==128&&(192&ne)==128&&(192&ye)==128&&(ge=(15&xe)<<18|(63&Q)<<12|(63&ne)<<6|63&ye)>65535&&ge<1114112&&(Se=ge)}Se===null?(Se=65533,xt=1):Se>65535&&(Se-=65536,H.push(Se>>>10&1023|55296),Se=56320|1023&Se),H.push(Se),X+=xt}return function(it){var Et=it.length;if(Et<=T)return String.fromCharCode.apply(String,it);for(var qe="",Qe=0;Qe"u"||typeof console.error!="function"||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(c.prototype,"parent",{enumerable:!0,get:function(){if(c.isBuffer(this))return this.buffer}}),Object.defineProperty(c.prototype,"offset",{enumerable:!0,get:function(){if(c.isBuffer(this))return this.byteOffset}}),typeof Symbol<"u"&&Symbol.species!=null&&c[Symbol.species]===c&&Object.defineProperty(c,Symbol.species,{value:null,configurable:!0,enumerable:!1,writable:!1}),c.poolSize=8192,c.from=function(E,C,D){return f(E,C,D)},c.prototype.__proto__=Uint8Array.prototype,c.__proto__=Uint8Array,c.alloc=function(E,C,D){return function(H,X,Q){return v(H),H<=0?l(H):X!==void 0?typeof Q=="string"?l(H).fill(X,Q):l(H).fill(X):l(H)}(E,C,D)},c.allocUnsafe=function(E){return g(E)},c.allocUnsafeSlow=function(E){return g(E)},c.isBuffer=function(E){return E!=null&&E._isBuffer===!0&&E!==c.prototype},c.compare=function(E,C){if(le(E,Uint8Array)&&(E=c.from(E,E.offset,E.byteLength)),le(C,Uint8Array)&&(C=c.from(C,C.offset,C.byteLength)),!c.isBuffer(E)||!c.isBuffer(C))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(E===C)return 0;for(var D=E.length,H=C.length,X=0,Q=Math.min(D,H);Xthis.length||((H===void 0||H>this.length)&&(H=this.length),H<=0)||(H>>>=0)<=(D>>>=0))return"";for(C||(C="utf8");;)switch(C){case"hex":return K(this,D,H);case"utf8":case"utf-8":return S(this,D,H);case"ascii":return R(this,D,H);case"latin1":case"binary":return O(this,D,H);case"base64":return $(this,D,H);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return G(this,D,H);default:if(X)throw new TypeError("Unknown encoding: "+C);C=(C+"").toLowerCase(),X=!0}}.apply(this,arguments)},c.prototype.toLocaleString=c.prototype.toString,c.prototype.equals=function(E){if(!c.isBuffer(E))throw new TypeError("Argument must be a Buffer");return this===E||c.compare(this,E)===0},c.prototype.inspect=function(){var E="",C=r.INSPECT_MAX_BYTES;return E=this.toString("hex",0,C).replace(/(.{2})/g,"$1 ").trim(),this.length>C&&(E+=" ... "),""},c.prototype.compare=function(E,C,D,H,X){if(le(E,Uint8Array)&&(E=c.from(E,E.offset,E.byteLength)),!c.isBuffer(E))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof E);if(C===void 0&&(C=0),D===void 0&&(D=E?E.length:0),H===void 0&&(H=0),X===void 0&&(X=this.length),C<0||D>E.length||H<0||X>this.length)throw new RangeError("out of range index");if(H>=X&&C>=D)return 0;if(H>=X)return-1;if(C>=D)return 1;if(C>>>=0,D>>>=0,H>>>=0,X>>>=0,this===E)return 0;for(var Q=X-H,ne=D-C,ye=Math.min(Q,ne),ge=this.slice(H,X),xe=E.slice(C,D),Se=0;Se>>=0,isFinite(D)?(D>>>=0,H===void 0&&(H="utf8")):(H=D,D=void 0)}var X=this.length-C;if((D===void 0||D>X)&&(D=X),E.length>0&&(D<0||C<0)||C>this.length)throw new RangeError("Attempt to write outside buffer bounds");H||(H="utf8");for(var Q=!1;;)switch(H){case"hex":return k(this,E,C,D);case"utf8":case"utf-8":return I(this,E,C,D);case"ascii":return P(this,E,C,D);case"latin1":case"binary":return M(this,E,C,D);case"base64":return L(this,E,C,D);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return U(this,E,C,D);default:if(Q)throw new TypeError("Unknown encoding: "+H);H=(""+H).toLowerCase(),Q=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var T=4096;function R(E,C,D){var H="";D=Math.min(E.length,D);for(var X=C;XH)&&(D=H);for(var X="",Q=C;QD)throw new RangeError("Trying to access beyond buffer length")}function V(E,C,D,H,X,Q){if(!c.isBuffer(E))throw new TypeError('"buffer" argument must be a Buffer instance');if(C>X||CE.length)throw new RangeError("Index out of range")}function F(E,C,D,H,X,Q){if(D+H>E.length)throw new RangeError("Index out of range");if(D<0)throw new RangeError("Index out of range")}function q(E,C,D,H,X){return C=+C,D>>>=0,X||F(E,0,D,4),s.write(E,C,D,H,23,4),D+4}function Y(E,C,D,H,X){return C=+C,D>>>=0,X||F(E,0,D,8),s.write(E,C,D,H,52,8),D+8}c.prototype.slice=function(E,C){var D=this.length;E=~~E,C=C===void 0?D:~~C,E<0?(E+=D)<0&&(E=0):E>D&&(E=D),C<0?(C+=D)<0&&(C=0):C>D&&(C=D),C>>=0,C>>>=0,D||ae(E,C,this.length);for(var H=this[E],X=1,Q=0;++Q>>=0,C>>>=0,D||ae(E,C,this.length);for(var H=this[E+--C],X=1;C>0&&(X*=256);)H+=this[E+--C]*X;return H},c.prototype.readUInt8=function(E,C){return E>>>=0,C||ae(E,1,this.length),this[E]},c.prototype.readUInt16LE=function(E,C){return E>>>=0,C||ae(E,2,this.length),this[E]|this[E+1]<<8},c.prototype.readUInt16BE=function(E,C){return E>>>=0,C||ae(E,2,this.length),this[E]<<8|this[E+1]},c.prototype.readUInt32LE=function(E,C){return E>>>=0,C||ae(E,4,this.length),(this[E]|this[E+1]<<8|this[E+2]<<16)+16777216*this[E+3]},c.prototype.readUInt32BE=function(E,C){return E>>>=0,C||ae(E,4,this.length),16777216*this[E]+(this[E+1]<<16|this[E+2]<<8|this[E+3])},c.prototype.readIntLE=function(E,C,D){E>>>=0,C>>>=0,D||ae(E,C,this.length);for(var H=this[E],X=1,Q=0;++Q=(X*=128)&&(H-=Math.pow(2,8*C)),H},c.prototype.readIntBE=function(E,C,D){E>>>=0,C>>>=0,D||ae(E,C,this.length);for(var H=C,X=1,Q=this[E+--H];H>0&&(X*=256);)Q+=this[E+--H]*X;return Q>=(X*=128)&&(Q-=Math.pow(2,8*C)),Q},c.prototype.readInt8=function(E,C){return E>>>=0,C||ae(E,1,this.length),128&this[E]?-1*(255-this[E]+1):this[E]},c.prototype.readInt16LE=function(E,C){E>>>=0,C||ae(E,2,this.length);var D=this[E]|this[E+1]<<8;return 32768&D?4294901760|D:D},c.prototype.readInt16BE=function(E,C){E>>>=0,C||ae(E,2,this.length);var D=this[E+1]|this[E]<<8;return 32768&D?4294901760|D:D},c.prototype.readInt32LE=function(E,C){return E>>>=0,C||ae(E,4,this.length),this[E]|this[E+1]<<8|this[E+2]<<16|this[E+3]<<24},c.prototype.readInt32BE=function(E,C){return E>>>=0,C||ae(E,4,this.length),this[E]<<24|this[E+1]<<16|this[E+2]<<8|this[E+3]},c.prototype.readFloatLE=function(E,C){return E>>>=0,C||ae(E,4,this.length),s.read(this,E,!0,23,4)},c.prototype.readFloatBE=function(E,C){return E>>>=0,C||ae(E,4,this.length),s.read(this,E,!1,23,4)},c.prototype.readDoubleLE=function(E,C){return E>>>=0,C||ae(E,8,this.length),s.read(this,E,!0,52,8)},c.prototype.readDoubleBE=function(E,C){return E>>>=0,C||ae(E,8,this.length),s.read(this,E,!1,52,8)},c.prototype.writeUIntLE=function(E,C,D,H){E=+E,C>>>=0,D>>>=0,H||V(this,E,C,D,Math.pow(2,8*D)-1,0);var X=1,Q=0;for(this[C]=255&E;++Q>>=0,D>>>=0,H||V(this,E,C,D,Math.pow(2,8*D)-1,0);var X=D-1,Q=1;for(this[C+X]=255&E;--X>=0&&(Q*=256);)this[C+X]=E/Q&255;return C+D},c.prototype.writeUInt8=function(E,C,D){return E=+E,C>>>=0,D||V(this,E,C,1,255,0),this[C]=255&E,C+1},c.prototype.writeUInt16LE=function(E,C,D){return E=+E,C>>>=0,D||V(this,E,C,2,65535,0),this[C]=255&E,this[C+1]=E>>>8,C+2},c.prototype.writeUInt16BE=function(E,C,D){return E=+E,C>>>=0,D||V(this,E,C,2,65535,0),this[C]=E>>>8,this[C+1]=255&E,C+2},c.prototype.writeUInt32LE=function(E,C,D){return E=+E,C>>>=0,D||V(this,E,C,4,4294967295,0),this[C+3]=E>>>24,this[C+2]=E>>>16,this[C+1]=E>>>8,this[C]=255&E,C+4},c.prototype.writeUInt32BE=function(E,C,D){return E=+E,C>>>=0,D||V(this,E,C,4,4294967295,0),this[C]=E>>>24,this[C+1]=E>>>16,this[C+2]=E>>>8,this[C+3]=255&E,C+4},c.prototype.writeIntLE=function(E,C,D,H){if(E=+E,C>>>=0,!H){var X=Math.pow(2,8*D-1);V(this,E,C,D,X-1,-X)}var Q=0,ne=1,ye=0;for(this[C]=255&E;++Q>0)-ye&255;return C+D},c.prototype.writeIntBE=function(E,C,D,H){if(E=+E,C>>>=0,!H){var X=Math.pow(2,8*D-1);V(this,E,C,D,X-1,-X)}var Q=D-1,ne=1,ye=0;for(this[C+Q]=255&E;--Q>=0&&(ne*=256);)E<0&&ye===0&&this[C+Q+1]!==0&&(ye=1),this[C+Q]=(E/ne>>0)-ye&255;return C+D},c.prototype.writeInt8=function(E,C,D){return E=+E,C>>>=0,D||V(this,E,C,1,127,-128),E<0&&(E=255+E+1),this[C]=255&E,C+1},c.prototype.writeInt16LE=function(E,C,D){return E=+E,C>>>=0,D||V(this,E,C,2,32767,-32768),this[C]=255&E,this[C+1]=E>>>8,C+2},c.prototype.writeInt16BE=function(E,C,D){return E=+E,C>>>=0,D||V(this,E,C,2,32767,-32768),this[C]=E>>>8,this[C+1]=255&E,C+2},c.prototype.writeInt32LE=function(E,C,D){return E=+E,C>>>=0,D||V(this,E,C,4,2147483647,-2147483648),this[C]=255&E,this[C+1]=E>>>8,this[C+2]=E>>>16,this[C+3]=E>>>24,C+4},c.prototype.writeInt32BE=function(E,C,D){return E=+E,C>>>=0,D||V(this,E,C,4,2147483647,-2147483648),E<0&&(E=4294967295+E+1),this[C]=E>>>24,this[C+1]=E>>>16,this[C+2]=E>>>8,this[C+3]=255&E,C+4},c.prototype.writeFloatLE=function(E,C,D){return q(this,E,C,!0,D)},c.prototype.writeFloatBE=function(E,C,D){return q(this,E,C,!1,D)},c.prototype.writeDoubleLE=function(E,C,D){return Y(this,E,C,!0,D)},c.prototype.writeDoubleBE=function(E,C,D){return Y(this,E,C,!1,D)},c.prototype.copy=function(E,C,D,H){if(!c.isBuffer(E))throw new TypeError("argument should be a Buffer");if(D||(D=0),H||H===0||(H=this.length),C>=E.length&&(C=E.length),C||(C=0),H>0&&H=this.length)throw new RangeError("Index out of range");if(H<0)throw new RangeError("sourceEnd out of bounds");H>this.length&&(H=this.length),E.length-C=0;--Q)E[Q+C]=this[Q+D];else Uint8Array.prototype.set.call(E,this.subarray(D,H),C);return X},c.prototype.fill=function(E,C,D,H){if(typeof E=="string"){if(typeof C=="string"?(H=C,C=0,D=this.length):typeof D=="string"&&(H=D,D=this.length),H!==void 0&&typeof H!="string")throw new TypeError("encoding must be a string");if(typeof H=="string"&&!c.isEncoding(H))throw new TypeError("Unknown encoding: "+H);if(E.length===1){var X=E.charCodeAt(0);(H==="utf8"&&X<128||H==="latin1")&&(E=X)}}else typeof E=="number"&&(E&=255);if(C<0||this.length>>=0,D=D===void 0?this.length:D>>>0,E||(E=0),typeof E=="number")for(Q=C;Q55295&&D<57344){if(!X){if(D>56319){(C-=3)>-1&&Q.push(239,191,189);continue}if(ne+1===H){(C-=3)>-1&&Q.push(239,191,189);continue}X=D;continue}if(D<56320){(C-=3)>-1&&Q.push(239,191,189),X=D;continue}D=65536+(X-55296<<10|D-56320)}else X&&(C-=3)>-1&&Q.push(239,191,189);if(X=null,D<128){if((C-=1)<0)break;Q.push(D)}else if(D<2048){if((C-=2)<0)break;Q.push(D>>6|192,63&D|128)}else if(D<65536){if((C-=3)<0)break;Q.push(D>>12|224,D>>6&63|128,63&D|128)}else{if(!(D<1114112))throw new Error("Invalid code point");if((C-=4)<0)break;Q.push(D>>18|240,D>>12&63|128,D>>6&63|128,63&D|128)}}return Q}function ee(E){return o.toByteArray(function(C){if((C=(C=C.split("=")[0]).trim().replace(W,"")).length<2)return"";for(;C.length%4!=0;)C+="=";return C}(E))}function he(E,C,D,H){for(var X=0;X=C.length||X>=E.length);++X)C[X+D]=E[X];return X}function le(E,C){return E instanceof C||E!=null&&E.constructor!=null&&E.constructor.name!=null&&E.constructor.name===C.name}function se(E){return E!=E}}).call(this)}).call(this,i("buffer").Buffer)},{"base64-js":13,buffer:17,ieee754:23}],18:[function(i,a,r){(function(n){(function(){r.formatArgs=function(s){if(s[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+s[0]+(this.useColors?"%c ":" ")+"+"+a.exports.humanize(this.diff),!this.useColors)return;const h="color: "+this.color;s.splice(1,0,h,"color: inherit");let l=0,c=0;s[0].replace(/%[a-zA-Z%]/g,f=>{f!=="%%"&&f==="%c"&&(c=++l)}),s.splice(c,0,h)},r.save=function(s){try{s?r.storage.setItem("debug",s):r.storage.removeItem("debug")}catch{}},r.load=function(){let s;try{s=r.storage.getItem("debug")}catch{}return!s&&n!==void 0&&"env"in n&&(s=n.env.DEBUG),s},r.useColors=function(){return typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs)?!0:typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)?!1:typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},r.storage=function(){try{return localStorage}catch{}}(),r.destroy=(()=>{let s=!1;return()=>{s||(s=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),r.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],r.log=console.debug||console.log||(()=>{}),a.exports=i("./common")(r);const{formatters:o}=a.exports;o.j=function(s){try{return JSON.stringify(s)}catch(h){return"[UnexpectedJSONParseError]: "+h.message}}}).call(this)}).call(this,i("_process"))},{"./common":19,_process:50}],19:[function(i,a,r){a.exports=function(n){function o(l){let c,f,v,g=null;function y(...p){if(!y.enabled)return;const m=y,b=Number(new Date),x=b-(c||b);m.diff=x,m.prev=c,m.curr=b,c=b,p[0]=o.coerce(p[0]),typeof p[0]!="string"&&p.unshift("%O");let _=0;p[0]=p[0].replace(/%([a-zA-Z%])/g,(k,I)=>{if(k==="%%")return"%";_++;const P=o.formatters[I];if(typeof P=="function"){const M=p[_];k=P.call(m,M),p.splice(_,1),_--}return k}),o.formatArgs.call(m,p),(m.log||o.log).apply(m,p)}return y.namespace=l,y.useColors=o.useColors(),y.color=o.selectColor(l),y.extend=s,y.destroy=o.destroy,Object.defineProperty(y,"enabled",{enumerable:!0,configurable:!1,get:()=>g!==null?g:(f!==o.namespaces&&(f=o.namespaces,v=o.enabled(l)),v),set:p=>{g=p}}),typeof o.init=="function"&&o.init(y),y}function s(l,c){const f=o(this.namespace+(c===void 0?":":c)+l);return f.log=this.log,f}function h(l){return l.toString().substring(2,l.toString().length-2).replace(/\.\*\?$/,"*")}return o.debug=o,o.default=o,o.coerce=function(l){return l instanceof Error?l.stack||l.message:l},o.disable=function(){const l=[...o.names.map(h),...o.skips.map(h).map(c=>"-"+c)].join(",");return o.enable(""),l},o.enable=function(l){let c;o.save(l),o.namespaces=l,o.names=[],o.skips=[];const f=(typeof l=="string"?l:"").split(/[\s,]+/),v=f.length;for(c=0;c{o[l]=n[l]}),o.names=[],o.skips=[],o.formatters={},o.selectColor=function(l){let c=0;for(let f=0;f0&&U.length>M){U.warned=!0;var $=new Error("Possible EventEmitter memory leak detected. "+U.length+' "'+String(k)+'" listeners added. Use emitter.setMaxListeners() to increase limit.');$.name="MaxListenersExceededWarning",$.emitter=_,$.type=k,$.count=U.length,typeof console=="object"&&console.warn&&console.warn("%s: %s",$.name,$.message)}}else U=L[k]=I,++_._eventsCount;return _}function y(){if(!this.fired)switch(this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length){case 0:return this.listener.call(this.target);case 1:return this.listener.call(this.target,arguments[0]);case 2:return this.listener.call(this.target,arguments[0],arguments[1]);case 3:return this.listener.call(this.target,arguments[0],arguments[1],arguments[2]);default:for(var _=new Array(arguments.length),k=0;k<_.length;++k)_[k]=arguments[k];this.listener.apply(this.target,_)}}function p(_,k,I){var P={fired:!1,wrapFn:void 0,target:_,type:k,listener:I},M=s.call(y,P);return M.listener=I,P.wrapFn=M,M}function m(_,k,I){var P=_._events;if(!P)return[];var M=P[k];return M?typeof M=="function"?I?[M.listener||M]:[M]:I?function(L){for(var U=new Array(L.length),$=0;$1&&(k=arguments[1]),k instanceof Error)throw k;var S=new Error('Unhandled "error" event. ('+k+")");throw S.context=k,S}if(!(I=U[_]))return!1;var T=typeof I=="function";switch(P=arguments.length){case 1:(function(R,O,K){if(O)R.call(K);else for(var G=R.length,ae=x(R,G),V=0;V=0;L--)if(I[L]===k||I[L].listener===k){U=I[L].listener,M=L;break}if(M<0)return this;M===0?I.shift():function($,S){for(var T=S,R=T+1,O=$.length;R=0;P--)this.removeListener(_,k[P]);return this},h.prototype.listeners=function(_){return m(this,_,!0)},h.prototype.rawListeners=function(_){return m(this,_,!1)},h.listenerCount=function(_,k){return typeof _.listenerCount=="function"?_.listenerCount(k):b.call(_,k)},h.prototype.listenerCount=b,h.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]}},{}],23:[function(i,a,r){r.read=function(n,o,s,h,l){var c,f,v=8*l-h-1,g=(1<>1,p=-7,m=s?l-1:0,b=s?-1:1,x=n[o+m];for(m+=b,c=x&(1<<-p)-1,x>>=-p,p+=v;p>0;c=256*c+n[o+m],m+=b,p-=8);for(f=c&(1<<-p)-1,c>>=-p,p+=h;p>0;f=256*f+n[o+m],m+=b,p-=8);if(c===0)c=1-y;else{if(c===g)return f?NaN:1/0*(x?-1:1);f+=Math.pow(2,h),c-=y}return(x?-1:1)*f*Math.pow(2,c-h)},r.write=function(n,o,s,h,l,c){var f,v,g,y=8*c-l-1,p=(1<>1,b=l===23?Math.pow(2,-24)-Math.pow(2,-77):0,x=h?0:c-1,_=h?1:-1,k=o<0||o===0&&1/o<0?1:0;for(o=Math.abs(o),isNaN(o)||o===1/0?(v=isNaN(o)?1:0,f=p):(f=Math.floor(Math.log(o)/Math.LN2),o*(g=Math.pow(2,-f))<1&&(f--,g*=2),(o+=f+m>=1?b/g:b*Math.pow(2,1-m))*g>=2&&(f++,g/=2),f+m>=p?(v=0,f=p):f+m>=1?(v=(o*g-1)*Math.pow(2,l),f+=m):(v=o*Math.pow(2,m-1)*Math.pow(2,l),f=0));l>=8;n[s+x]=255&v,x+=_,v/=256,l-=8);for(f=f<0;n[s+x]=255&f,x+=_,f/=256,y-=8);n[s+x-_]|=128*k}},{}],24:[function(i,a,r){typeof Object.create=="function"?a.exports=function(n,o){o&&(n.super_=o,n.prototype=Object.create(o.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}))}:a.exports=function(n,o){if(o){n.super_=o;var s=function(){};s.prototype=o.prototype,n.prototype=new s,n.prototype.constructor=n}}},{}],25:[function(i,a,r){Object.defineProperty(r,"__esModule",{value:!0});var n=function(){function o(s,h){this.color=!0,this.key=void 0,this.value=void 0,this.parent=void 0,this.brother=void 0,this.leftChild=void 0,this.rightChild=void 0,this.key=s,this.value=h}return o.prototype.rotateLeft=function(){var s=this.parent,h=this.brother,l=this.leftChild,c=this.rightChild;if(!c)throw new Error("unknown error");var f=c.leftChild,v=c.rightChild;return s&&(s.leftChild===this?s.leftChild=c:s.rightChild===this&&(s.rightChild=c)),c.parent=s,c.brother=h,c.leftChild=this,c.rightChild=v,h&&(h.brother=c),this.parent=c,this.brother=v,this.leftChild=l,this.rightChild=f,v&&(v.parent=c,v.brother=this),l&&(l.parent=this,l.brother=f),f&&(f.parent=this,f.brother=l),c},o.prototype.rotateRight=function(){var s=this.parent,h=this.brother,l=this.leftChild;if(!l)throw new Error("unknown error");var c=this.rightChild,f=l.leftChild,v=l.rightChild;return s&&(s.leftChild===this?s.leftChild=l:s.rightChild===this&&(s.rightChild=l)),l.parent=s,l.brother=h,l.leftChild=f,l.rightChild=this,h&&(h.brother=l),f&&(f.parent=l,f.brother=this),this.parent=l,this.brother=f,this.leftChild=v,this.rightChild=c,v&&(v.parent=this,v.brother=c),c&&(c.parent=this,c.brother=v),l},o.prototype.remove=function(){if(this.leftChild||this.rightChild)throw new Error("can only remove leaf node");this.parent&&(this===this.parent.leftChild?this.parent.leftChild=void 0:this===this.parent.rightChild&&(this.parent.rightChild=void 0)),this.brother&&(this.brother.brother=void 0),this.key=void 0,this.value=void 0,this.parent=void 0,this.brother=void 0},o.TreeNodeColorType={red:!0,black:!1},o}();Object.freeze(n),r.default=n},{}],26:[function(i,a,r){var n=this&&this.__generator||function(s,h){var l,c,f,v,g={label:0,sent:function(){if(1&f[0])throw f[1];return f[1]},trys:[],ops:[]};return v={next:y(0),throw:y(1),return:y(2)},typeof Symbol=="function"&&(v[Symbol.iterator]=function(){return this}),v;function y(p){return function(m){return function(b){if(l)throw new TypeError("Generator is already executing.");for(;g;)try{if(l=1,c&&(f=2&b[0]?c.return:b[0]?c.throw||((f=c.return)&&f.call(c),0):c.next)&&!(f=f.call(c,b[1])).done)return f;switch(c=0,f&&(b=[2&b[0],f.value]),b[0]){case 0:case 1:f=b;break;case 4:return g.label++,{value:b[1],done:!1};case 5:g.label++,c=b[1],b=[0];continue;case 7:b=g.ops.pop(),g.trys.pop();continue;default:if(!(f=(f=g.trys).length>0&&f[f.length-1])&&(b[0]===6||b[0]===2)){g=0;continue}if(b[0]===3&&(!f||b[1]>f[0]&&b[1]I)throw new Error("pos should more than 0 and less than queue's size");return{curNodeBucketIndex:Math.floor(k/o.bucketSize),curNodePointerIndex:k%o.bucketSize}};this.getElementByPos=function(x){var _=m(x),k=_.curNodeBucketIndex,I=_.curNodePointerIndex;return l[k][I]},this.eraseElementByPos=function(x){var _=this;if(x<0||x>p)throw new Error("pos should more than 0 and less than queue's size");if(x===0)this.popFront();else if(x===this.size())this.popBack();else{for(var k=[],I=x+1;I0?--g:c0&&--p)},this.setElementByPos=function(x,_){var k=m(x),I=k.curNodeBucketIndex,P=k.curNodePointerIndex;l[I][P]=_},this.insert=function(x,_,k){var I=this;if(k===void 0&&(k=1),x===0)for(;k--;)this.pushFront(_);else if(x===this.size())for(;k--;)this.pushBack(_);else{for(var P=[],M=x;M0?--f:c>0&&(--c,f=o.bucketSize-1)),++p,l[c][f]=x},this.popFront=function(){this.empty()||(this.size()!==1&&(f0&&--p)},this.shrinkToFit=function(){var x=this,_=[];this.forEach(function(M){_.push(M)});var k=_.length;l=[];for(var I=Math.ceil(k/o.bucketSize),P=0;P0&&y[y.length-1])&&(k[0]===6||k[0]===2)){m=0;continue}if(k[0]===3&&(!y||k[1]>y[0]&&k[1]=c.length&&(c=void 0),{value:c&&c[g++],done:!c}}};throw new TypeError(f?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(r,"__esModule",{value:!0});var s=i("../LinkList/LinkList"),h=i("../Map/Map");function l(c,f,v){var g=this;if(c===void 0&&(c=[]),f===void 0&&(f=l.initSize),v=v||function(b){var x,_,k=0,I="";if(typeof b=="number")k=((k=Math.floor(b))<<5)-k,k&=k;else{I=typeof b!="string"?JSON.stringify(b):b;try{for(var P=o(I),M=P.next();!M.done;M=P.next())k=(k<<5)-k+M.value.charCodeAt(0),k&=k}catch(L){x={error:L}}finally{try{M&&!M.done&&(_=P.return)&&_.call(P)}finally{if(x)throw x.error}}}return k^=k>>>16},(f&f-1)!=0)throw new Error("initBucketNum must be 2 to the power of n");var y=0,p=[],m=Math.max(l.initSize,Math.min(l.maxSize,f));this.size=function(){return y},this.empty=function(){return y===0},this.clear=function(){y=0,m=f,p=[]},this.forEach=function(b){var x=0;p.forEach(function(_){_.forEach(function(k){b(k,x++)})})},this.setElement=function(b,x){var _,k;if(b==null)throw new Error("to avoid some unnecessary errors, we don't suggest you insert null or undefined here");if(x!=null){var I=v(b)&m-1;if(p[I]){var P=p[I].size();if(p[I]instanceof s.default){try{for(var M=o(p[I]),L=M.next();!L.done;L=M.next()){var U=L.value;if(U.key===b)return void(U.value=x)}}catch(S){_={error:S}}finally{try{L&&!L.done&&(k=M.return)&&k.call(M)}finally{if(_)throw _.error}}p[I].pushBack({key:b,value:x}),p[I].size()>=l.treeifyThreshold&&(p[I]=new h.default(p[I]))}else p[I].setElement(b,x);var $=p[I].size();y+=$-P}else++y,p[I]=new s.default([{key:b,value:x}]);y>m*l.sigma&&function(S){if(!(S>=l.maxSize)){m=2*S;var T=[];p.forEach(function(R,O){if(!R.empty()){if(R instanceof s.default&&R.size()===1){var K=R.front(),G=K.key,ae=K.value;T[v(G)&m-1]=new s.default([{key:G,value:ae}])}else if(R instanceof h.default){var V=new s.default,F=new s.default;R.forEach(function(W){(v(W.key)&S)==0?V.pushBack(W):F.pushBack(W)}),V.size()>l.untreeifyThreshold?T[O]=new h.default(V):V.size()&&(T[O]=V),F.size()>l.untreeifyThreshold?T[O+S]=new h.default(F):F.size()&&(T[O+S]=F)}else{var q=new s.default,Y=new s.default;R.forEach(function(W){(v(W.key)&S)==0?q.pushBack(W):Y.pushBack(W)}),q.size()&&(T[O]=q),Y.size()&&(T[O+S]=Y)}p[O].clear()}}),p=T}}.call(this,m)}else this.eraseElementByKey(b)},this.getElementByKey=function(b){var x,_,k=v(b)&m-1;if(p[k]){if(p[k]instanceof h.default)return p[k].getElementByKey(b);try{for(var I=o(p[k]),P=I.next();!P.done;P=I.next()){var M=P.value;if(M.key===b)return M.value}}catch(L){x={error:L}}finally{try{P&&!P.done&&(_=I.return)&&_.call(I)}finally{if(x)throw x.error}}}},this.eraseElementByKey=function(b){var x,_,k=v(b)&m-1;if(p[k]){var I=p[k].size();if(p[k]instanceof h.default)p[k].eraseElementByKey(b),p[k].size()<=l.untreeifyThreshold&&(p[k]=new s.default(p[k]));else{var P=-1;try{for(var M=o(p[k]),L=M.next();!L.done;L=M.next())if(++P,L.value.key===b){p[k].eraseElementByPos(P);break}}catch($){x={error:$}}finally{try{L&&!L.done&&(_=M.return)&&_.call(M)}finally{if(x)throw x.error}}}var U=p[k].size();y+=U-I}},this.find=function(b){var x,_,k=v(b)&m-1;if(!p[k])return!1;if(p[k]instanceof h.default)return p[k].find(b);try{for(var I=o(p[k]),P=I.next();!P.done;P=I.next())if(P.value.key===b)return!0}catch(M){x={error:M}}finally{try{P&&!P.done&&(_=I.return)&&_.call(I)}finally{if(x)throw x.error}}return!1},this[Symbol.iterator]=function(){return function(){var b,x,_,k,I,P;return n(this,function(M){switch(M.label){case 0:b=0,M.label=1;case 1:if(!(b=m)return[3,10];M.label=2;case 2:M.trys.push([2,7,8,9]),I=void 0,x=o(p[b]),_=x.next(),M.label=3;case 3:return _.done?[3,6]:[4,_.value];case 4:M.sent(),M.label=5;case 5:return _=x.next(),[3,3];case 6:return[3,9];case 7:return k=M.sent(),I={error:k},[3,9];case 8:try{_&&!_.done&&(P=x.return)&&P.call(x)}finally{if(I)throw I.error}return[7];case 9:return++b,[3,1];case 10:return[2]}})}()},c.forEach(function(b){var x=b.key,_=b.value;return g.setElement(x,_)}),Object.freeze(this)}l.initSize=16,l.maxSize=1<<30,l.sigma=.75,l.treeifyThreshold=8,l.untreeifyThreshold=6,l.minTreeifySize=64,Object.freeze(l),r.default=l},{"../LinkList/LinkList":29,"../Map/Map":30}],28:[function(i,a,r){var n=this&&this.__generator||function(c,f){var v,g,y,p,m={label:0,sent:function(){if(1&y[0])throw y[1];return y[1]},trys:[],ops:[]};return p={next:b(0),throw:b(1),return:b(2)},typeof Symbol=="function"&&(p[Symbol.iterator]=function(){return this}),p;function b(x){return function(_){return function(k){if(v)throw new TypeError("Generator is already executing.");for(;m;)try{if(v=1,g&&(y=2&k[0]?g.return:k[0]?g.throw||((y=g.return)&&y.call(g),0):g.next)&&!(y=y.call(g,k[1])).done)return y;switch(g=0,y&&(k=[2&k[0],y.value]),k[0]){case 0:case 1:y=k;break;case 4:return m.label++,{value:k[1],done:!1};case 5:m.label++,g=k[1],k=[0];continue;case 7:k=m.ops.pop(),m.trys.pop();continue;default:if(!(y=(y=m.trys).length>0&&y[y.length-1])&&(k[0]===6||k[0]===2)){m=0;continue}if(k[0]===3&&(!y||k[1]>y[0]&&k[1]=c.length&&(c=void 0),{value:c&&c[g++],done:!c}}};throw new TypeError(f?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(r,"__esModule",{value:!0});var s=i("../Set/Set"),h=i("../LinkList/LinkList");function l(c,f,v){var g=this;if(c===void 0&&(c=[]),f===void 0&&(f=l.initSize),v=v||function(b){var x=0,_="";if(typeof b=="number")x=((x=Math.floor(b))<<5)-x,x&=x;else{_=typeof b!="string"?JSON.stringify(b):b;for(var k=0;k<_.length;k++)x=(x<<5)-x+_.charCodeAt(k),x&=x}return x^=x>>>16},(f&f-1)!=0)throw new Error("initBucketNum must be 2 to the power of n");var y=0,p=[],m=Math.max(l.initSize,Math.min(l.maxSize,f));this.size=function(){return y},this.empty=function(){return y===0},this.clear=function(){y=0,m=f,p=[]},this.forEach=function(b){var x=0;p.forEach(function(_){_.forEach(function(k){b(k,x++)})})},this.insert=function(b){if(b==null)throw new Error("to avoid some unnecessary errors, we don't suggest you insert null or undefined here");var x=v(b)&m-1;if(p[x]){var _=p[x].size();if(p[x]instanceof h.default){if(p[x].find(b))return;p[x].pushBack(b),p[x].size()>=l.treeifyThreshold&&(p[x]=new s.default(p[x]))}else p[x].insert(b);var k=p[x].size();y+=k-_}else p[x]=new h.default([b]),++y;y>m*l.sigma&&function(I){if(!(I>=l.maxSize)){m=2*I;var P=[];p.forEach(function(M,L){if(!M.empty()){if(M instanceof h.default&&M.size()===1){var U=M.front();if(U===void 0)throw new Error("unknown error");P[v(U)&m-1]=new h.default([U])}else if(M instanceof s.default){var $=new h.default,S=new h.default;M.forEach(function(O){(v(O)&I)==0?$.pushBack(O):S.pushBack(O)}),$.size()>l.untreeifyThreshold?P[L]=new s.default($):$.size()&&(P[L]=$),S.size()>l.untreeifyThreshold?P[L+I]=new s.default(S):S.size()&&(P[L+I]=S)}else{var T=new h.default,R=new h.default;M.forEach(function(O){(v(O)&I)==0?T.pushBack(O):R.pushBack(O)}),T.size()&&(P[L]=T),R.size()&&(P[L+I]=R)}p[L].clear()}}),p=P}}.call(this,m)},this.eraseElementByValue=function(b){var x=v(b)&m-1;if(p[x]){var _=p[x].size();p[x].eraseElementByValue(b),p[x]instanceof s.default&&p[x].size()<=l.untreeifyThreshold&&(p[x]=new h.default(p[x]));var k=p[x].size();y+=k-_}},this.find=function(b){var x=v(b)&m-1;return!!p[x]&&p[x].find(b)},this[Symbol.iterator]=function(){return function(){var b,x,_,k,I,P;return n(this,function(M){switch(M.label){case 0:b=0,M.label=1;case 1:if(!(b=m)return[3,10];M.label=2;case 2:M.trys.push([2,7,8,9]),I=void 0,x=o(p[b]),_=x.next(),M.label=3;case 3:return _.done?[3,6]:[4,_.value];case 4:M.sent(),M.label=5;case 5:return _=x.next(),[3,3];case 6:return[3,9];case 7:return k=M.sent(),I={error:k},[3,9];case 8:try{_&&!_.done&&(P=x.return)&&P.call(x)}finally{if(I)throw I.error}return[7];case 9:return++b,[3,1];case 10:return[2]}})}()},c.forEach(function(b){return g.insert(b)}),Object.freeze(this)}l.initSize=16,l.maxSize=1<<30,l.sigma=.75,l.treeifyThreshold=8,l.untreeifyThreshold=6,l.minTreeifySize=64,Object.freeze(l),r.default=l},{"../LinkList/LinkList":29,"../Set/Set":33}],29:[function(i,a,r){var n=this&&this.__generator||function(h,l){var c,f,v,g,y={label:0,sent:function(){if(1&v[0])throw v[1];return v[1]},trys:[],ops:[]};return g={next:p(0),throw:p(1),return:p(2)},typeof Symbol=="function"&&(g[Symbol.iterator]=function(){return this}),g;function p(m){return function(b){return function(x){if(c)throw new TypeError("Generator is already executing.");for(;y;)try{if(c=1,f&&(v=2&x[0]?f.return:x[0]?f.throw||((v=f.return)&&v.call(f),0):f.next)&&!(v=v.call(f,x[1])).done)return v;switch(f=0,v&&(x=[2&x[0],v.value]),x[0]){case 0:case 1:v=x;break;case 4:return y.label++,{value:x[1],done:!1};case 5:y.label++,f=x[1],x=[0];continue;case 7:x=y.ops.pop(),y.trys.pop();continue;default:if(!(v=(v=y.trys).length>0&&v[v.length-1])&&(x[0]===6||x[0]===2)){y=0;continue}if(x[0]===3&&(!v||x[1]>v[0]&&x[1]=c)throw new Error("pos must more then 0 and less then the list length");for(var y=f;g--&&y;)y=y.next;if(!y||y.value===void 0)throw new Error("unknown error");return y.value},this.eraseElementByPos=function(g){if(g<0||g>=c)throw new Error("erase pos must more then 0 and less then the list length");if(g===0)this.popFront();else if(g===c-1)this.popBack();else{for(var y=f;g--;){if(!(y!=null&&y.next))throw new Error("unknown error");y=y.next}if(!y||!y.pre||!y.next)throw new Error("unknown error");var p=y.pre,m=y.next;m.pre=p,p.next=m,c>0&&--c}},this.eraseElementByValue=function(g){for(;f&&f.value===g;)this.popFront();for(;v&&v.value===g;)this.popBack();if(f)for(var y=f;y;){if(y.value===g){var p=y.pre,m=y.next;m&&(m.pre=p),p&&(p.next=m),c>0&&--c}y=y.next}},this.pushBack=function(g){if(g==null)throw new Error("you can't push null or undefined here");++c;var y=new o(g);v?(v.next=y,y.pre=v,v=y):f=v=y},this.popBack=function(){v&&(c>0&&--c,v&&(f===v?f=v=void 0:(v=v.pre)&&(v.next=void 0)))},this.setElementByPos=function(g,y){if(y==null)throw new Error("you can't set null or undefined here");if(g<0||g>=c)throw new Error("pos must more then 0 and less then the list length");for(var p=f;g--;){if(!p)throw new Error("unknown error");p=p.next}p&&(p.value=y)},this.insert=function(g,y,p){if(p===void 0&&(p=1),y==null)throw new Error("you can't insert null or undefined here");if(g<0||g>c)throw new Error("insert pos must more then 0 and less then or equal to the list length");if(p<0)throw new Error("insert size must more than 0");if(g===0)for(;p--;)this.pushFront(y);else if(g===c)for(;p--;)this.pushBack(y);else{for(var m=f,b=1;b0&&--c;g.next=y.next,g.next&&(g.next.pre=g),g=g.next}},this.sort=function(g){var y=[];this.forEach(function(m){y.push(m)}),y.sort(g);var p=f;y.forEach(function(m){p&&(p.value=m,p=p.next)})},this.pushFront=function(g){if(g==null)throw new Error("you can't push null or undefined here");++c;var y=new o(g);f?(y.next=f,f.pre=y,f=y):f=v=y},this.popFront=function(){f&&(c>0&&--c,f&&(f===v?f=v=void 0:(f=f.next)&&(f.pre=void 0)))},this.merge=function(g){var y=this,p=f;g.forEach(function(m){for(;p&&p.value!==void 0&&p.value<=m;)p=p.next;if(p===void 0)y.pushBack(m),p=v;else if(p===f)y.pushFront(m),p=f;else{++c;var b=p.pre;b&&(b.next=new o(m),b.next.pre=b,b.next.next=p,p&&(p.pre=b.next))}})},this[Symbol.iterator]=function(){return function(){var g;return n(this,function(y){switch(y.label){case 0:g=f,y.label=1;case 1:if(g===void 0)return[3,3];if(!g.value)throw new Error("unknown error");return[4,g.value];case 2:return y.sent(),g=g.next,[3,1];case 3:return[2]}})}()},h.forEach(function(g){return l.pushBack(g)}),Object.freeze(this)}Object.freeze(s),r.default=s},{}],30:[function(i,a,r){var n=this&&this.__generator||function(l,c){var f,v,g,y,p={label:0,sent:function(){if(1&g[0])throw g[1];return g[1]},trys:[],ops:[]};return y={next:m(0),throw:m(1),return:m(2)},typeof Symbol=="function"&&(y[Symbol.iterator]=function(){return this}),y;function m(b){return function(x){return function(_){if(f)throw new TypeError("Generator is already executing.");for(;p;)try{if(f=1,v&&(g=2&_[0]?v.return:_[0]?v.throw||((g=v.return)&&g.call(v),0):v.next)&&!(g=g.call(v,_[1])).done)return g;switch(v=0,g&&(_=[2&_[0],g.value]),_[0]){case 0:case 1:g=_;break;case 4:return p.label++,{value:_[1],done:!1};case 5:p.label++,v=_[1],_=[0];continue;case 7:_=p.ops.pop(),p.trys.pop();continue;default:if(!(g=(g=p.trys).length>0&&g[g.length-1])&&(_[0]===6||_[0]===2)){p=0;continue}if(_[0]===3&&(!g||_[1]>g[0]&&_[1]=l.length&&(l=void 0),{value:l&&l[v++],done:!l}}};throw new TypeError(c?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(r,"__esModule",{value:!0});var s=i("../Base/TreeNode");function h(l,c){var f=this;l===void 0&&(l=[]),c=c||function(S,T){return ST?1:0};var v=0,g=new s.default;g.color=s.default.TreeNodeColorType.black,this.size=function(){return v},this.empty=function(){return v===0},this.clear=function(){v=0,g.key=g.value=void 0,g.leftChild=g.rightChild=g.brother=void 0};var y=function(S){if(!S||S.key===void 0)throw new Error("unknown error");return S.leftChild?y(S.leftChild):S},p=function(S){if(!S||S.key===void 0)throw new Error("unknown error");return S.rightChild?p(S.rightChild):S};this.front=function(){if(!this.empty()){var S=y(g);if(S.key===void 0||S.value===void 0)throw new Error("unknown error");return{key:S.key,value:S.value}}},this.back=function(){if(!this.empty()){var S=p(g);if(S.key===void 0||S.value===void 0)throw new Error("unknown error");return{key:S.key,value:S.value}}},this.forEach=function(S){var T,R,O=0;try{for(var K=o(this),G=K.next();!G.done;G=K.next())S(G.value,O++)}catch(ae){T={error:ae}}finally{try{G&&!G.done&&(R=K.return)&&R.call(K)}finally{if(T)throw T.error}}},this.getElementByPos=function(S){var T,R;if(S<0||S>=this.size())throw new Error("pos must more than 0 and less than set's size");var O=0;try{for(var K=o(this),G=K.next();!G.done;G=K.next()){var ae=G.value;if(O===S)return ae;++O}}catch(V){T={error:V}}finally{try{G&&!G.done&&(R=K.return)&&R.call(K)}finally{if(T)throw T.error}}throw new Error("unknown Error")};var m=function(S,T){if(S&&S.key!==void 0&&S.value!==void 0){var R=c(S.key,T);return R===0?{key:S.key,value:S.value}:R<0?m(S.rightChild,T):m(S.leftChild,T)||{key:S.key,value:S.value}}};this.lowerBound=function(S){return m(g,S)};var b=function(S,T){if(S&&S.key!==void 0&&S.value!==void 0)return c(S.key,T)<=0?b(S.rightChild,T):b(S.leftChild,T)||{key:S.key,value:S.value}};this.upperBound=function(S){return b(g,S)};var x=function(S,T){if(S&&S.key!==void 0&&S.value!==void 0){var R=c(S.key,T);return R===0?{key:S.key,value:S.value}:R>0?x(S.leftChild,T):x(S.rightChild,T)||{key:S.key,value:S.value}}};this.reverseLowerBound=function(S){return x(g,S)};var _=function(S,T){if(S&&S.key!==void 0&&S.value!==void 0)return c(S.key,T)>=0?_(S.leftChild,T):_(S.rightChild,T)||{key:S.key,value:S.value}};this.reverseUpperBound=function(S){return _(g,S)};var k=function(S){var T=S.parent;if(!T){if(S===g)return;throw new Error("unknown error")}if(S.color!==s.default.TreeNodeColorType.red){var R=S.brother;if(!R)throw new Error("unknown error");if(S===T.leftChild)if(R.color===s.default.TreeNodeColorType.red){R.color=s.default.TreeNodeColorType.black,T.color=s.default.TreeNodeColorType.red;var O=T.rotateLeft();g===T&&(g=O),k(S)}else R.color===s.default.TreeNodeColorType.black&&(R.rightChild&&R.rightChild.color===s.default.TreeNodeColorType.red?(R.color=T.color,T.color=s.default.TreeNodeColorType.black,R.rightChild&&(R.rightChild.color=s.default.TreeNodeColorType.black),O=T.rotateLeft(),g===T&&(g=O),S.color=s.default.TreeNodeColorType.black):R.rightChild&&R.rightChild.color!==s.default.TreeNodeColorType.black||!R.leftChild||R.leftChild.color!==s.default.TreeNodeColorType.red?R.leftChild&&R.leftChild.color!==s.default.TreeNodeColorType.black||R.rightChild&&R.rightChild.color!==s.default.TreeNodeColorType.black||(R.color=s.default.TreeNodeColorType.red,k(T)):(R.color=s.default.TreeNodeColorType.red,R.leftChild&&(R.leftChild.color=s.default.TreeNodeColorType.black),O=R.rotateRight(),g===R&&(g=O),k(S)));else S===T.rightChild&&(R.color===s.default.TreeNodeColorType.red?(R.color=s.default.TreeNodeColorType.black,T.color=s.default.TreeNodeColorType.red,O=T.rotateRight(),g===T&&(g=O),k(S)):R.color===s.default.TreeNodeColorType.black&&(R.leftChild&&R.leftChild.color===s.default.TreeNodeColorType.red?(R.color=T.color,T.color=s.default.TreeNodeColorType.black,R.leftChild&&(R.leftChild.color=s.default.TreeNodeColorType.black),O=T.rotateRight(),g===T&&(g=O),S.color=s.default.TreeNodeColorType.black):R.leftChild&&R.leftChild.color!==s.default.TreeNodeColorType.black||!R.rightChild||R.rightChild.color!==s.default.TreeNodeColorType.red?R.leftChild&&R.leftChild.color!==s.default.TreeNodeColorType.black||R.rightChild&&R.rightChild.color!==s.default.TreeNodeColorType.black||(R.color=s.default.TreeNodeColorType.red,k(T)):(R.color=s.default.TreeNodeColorType.red,R.rightChild&&(R.rightChild.color=s.default.TreeNodeColorType.black),O=R.rotateLeft(),g===R&&(g=O),k(S))))}else S.color=s.default.TreeNodeColorType.black},I=function(S){for(var T=S;T.leftChild||T.rightChild;){if(T.rightChild){T=y(T.rightChild);var R=S.key;S.key=T.key,T.key=R;var O=S.value;S.value=T.value,T.value=O,S=T}T.leftChild&&(T=p(T.leftChild),R=S.key,S.key=T.key,T.key=R,O=S.value,S.value=T.value,T.value=O,S=T)}k(T),T&&T.remove(),--v,g.color=s.default.TreeNodeColorType.black},P=function(S,T){return!(!S||S.key===void 0)&&(!!P(S.leftChild,T)||!!T(S)||P(S.rightChild,T))};this.eraseElementByPos=function(S){if(S<0||S>=v)throw new Error("pos must more than 0 and less than set's size");var T=0;P(g,function(R){return S===T?(I(R),!0):(++T,!1)})},this.eraseElementByKey=function(S){if(!this.empty()){var T=U(g,S);T!==void 0&&T.key!==void 0&&c(T.key,S)===0&&I(T)}};var M=function(S,T){if(!S||S.key===void 0)throw new Error("unknown error");var R=c(T,S.key);return R<0?S.leftChild?M(S.leftChild,T):(S.leftChild=new s.default,S.leftChild.parent=S,S.leftChild.brother=S.rightChild,S.rightChild&&(S.rightChild.brother=S.leftChild),S.leftChild):R>0?S.rightChild?M(S.rightChild,T):(S.rightChild=new s.default,S.rightChild.parent=S,S.rightChild.brother=S.leftChild,S.leftChild&&(S.leftChild.brother=S.rightChild),S.rightChild):S},L=function(S){var T=S.parent;if(!T){if(S===g)return;throw new Error("unknown error")}if(T.color!==s.default.TreeNodeColorType.black&&T.color===s.default.TreeNodeColorType.red){var R=T.brother,O=T.parent;if(!O)throw new Error("unknown error");if(R&&R.color===s.default.TreeNodeColorType.red)R.color=T.color=s.default.TreeNodeColorType.black,O.color=s.default.TreeNodeColorType.red,L(O);else if(!R||R.color===s.default.TreeNodeColorType.black)if(T===O.leftChild)if(S===T.leftChild){T.color=s.default.TreeNodeColorType.black,O.color=s.default.TreeNodeColorType.red;var K=O.rotateRight();O===g&&(g=K)}else S===T.rightChild&&(K=T.rotateLeft(),O===g&&(g=K),L(T));else T===O.rightChild&&(S===T.leftChild?(K=T.rotateRight(),O===g&&(g=K),L(T)):S===T.rightChild&&(T.color=s.default.TreeNodeColorType.black,O.color=s.default.TreeNodeColorType.red,K=O.rotateLeft(),O===g&&(g=K)))}};this.setElement=function(S,T){if(S==null)throw new Error("to avoid some unnecessary errors, we don't suggest you insert null or undefined here");if(T!=null){if(this.empty())return++v,g.key=S,g.value=T,void(g.color=s.default.TreeNodeColorType.black);var R=M(g,S);R.key===void 0||c(R.key,S)!==0?(++v,R.key=S,R.value=T,L(R),g.color=s.default.TreeNodeColorType.black):R.value=T}else this.eraseElementByKey(S)};var U=function(S,T){if(S&&S.key!==void 0){var R=c(T,S.key);return R<0?U(S.leftChild,T):R>0?U(S.rightChild,T):S}};this.find=function(S){return!!U(g,S)},this.getElementByKey=function(S){var T=U(g,S);if((T==null?void 0:T.key)===void 0||(T==null?void 0:T.value)===void 0)throw new Error("unknown error");return T.value},this.union=function(S){var T=this;S.forEach(function(R){var O=R.key,K=R.value;return T.setElement(O,K)})},this.getHeight=function(){if(this.empty())return 0;var S=function(T){return T?Math.max(S(T.leftChild),S(T.rightChild))+1:1};return S(g)};var $=function(S){return n(this,function(T){switch(T.label){case 0:return S&&S.key!==void 0&&S.value!==void 0?[5,o($(S.leftChild))]:[2];case 1:return T.sent(),[4,{key:S.key,value:S.value}];case 2:return T.sent(),[5,o($(S.rightChild))];case 3:return T.sent(),[2]}})};this[Symbol.iterator]=function(){return $(g)},l.forEach(function(S){var T=S.key,R=S.value;return f.setElement(T,R)}),Object.freeze(this)}Object.freeze(h),r.default=h},{"../Base/TreeNode":25}],31:[function(i,a,r){function n(o,s){o===void 0&&(o=[]),s=s||function(v,g){return v>g?-1:v=l)throw new Error("unknown error");if(g<0||g>=l)throw new Error("unknown error");var y=h[v];h[v]=h[g],h[g]=y},f=function(v){if(v<0||v>=l)throw new Error("unknown error");var g=2*v+1,y=2*v+2;g0&&c(v,g),y0&&c(v,y)};(function(){for(var v=Math.floor((l-1)/2);v>=0;--v)for(var g=v,y=2*g+1;y0&&(m=p),s(h[g],h[m])<=0)break;c(g,m),y=2*(g=m)+1}})(),this.size=function(){return l},this.empty=function(){return l===0},this.clear=function(){l=0,h.length=0},this.push=function(v){if(h.push(v),++l!==1)for(var g=l-1;g>0;){var y=Math.floor((g-1)/2);if(s(h[y],v)<=0)break;f(y),g=y}},this.pop=function(){if(!this.empty())if(this.size()!==1){var v=h[l-1];--l;for(var g=0;g=this.size())break;var m=y;if(p0&&(m=p),s(h[m],v)>=0)break;h[g]=h[m],g=m}h[g]=v}else--l},this.top=function(){return h[0]},Object.freeze(this)}Object.defineProperty(r,"__esModule",{value:!0}),Object.freeze(n),r.default=n},{}],32:[function(i,a,r){Object.defineProperty(r,"__esModule",{value:!0});var n=i("../LinkList/LinkList");function o(s){s===void 0&&(s=[]);var h=new n.default(s);this.size=function(){return h.size()},this.empty=function(){return h.empty()},this.clear=function(){h.clear()},this.push=function(l){h.pushBack(l)},this.pop=function(){h.popFront()},this.front=function(){return h.front()},Object.freeze(this)}Object.freeze(o),r.default=o},{"../LinkList/LinkList":29}],33:[function(i,a,r){var n=this&&this.__generator||function(l,c){var f,v,g,y,p={label:0,sent:function(){if(1&g[0])throw g[1];return g[1]},trys:[],ops:[]};return y={next:m(0),throw:m(1),return:m(2)},typeof Symbol=="function"&&(y[Symbol.iterator]=function(){return this}),y;function m(b){return function(x){return function(_){if(f)throw new TypeError("Generator is already executing.");for(;p;)try{if(f=1,v&&(g=2&_[0]?v.return:_[0]?v.throw||((g=v.return)&&g.call(v),0):v.next)&&!(g=g.call(v,_[1])).done)return g;switch(v=0,g&&(_=[2&_[0],g.value]),_[0]){case 0:case 1:g=_;break;case 4:return p.label++,{value:_[1],done:!1};case 5:p.label++,v=_[1],_=[0];continue;case 7:_=p.ops.pop(),p.trys.pop();continue;default:if(!(g=(g=p.trys).length>0&&g[g.length-1])&&(_[0]===6||_[0]===2)){p=0;continue}if(_[0]===3&&(!g||_[1]>g[0]&&_[1]=l.length&&(l=void 0),{value:l&&l[v++],done:!l}}};throw new TypeError(c?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(r,"__esModule",{value:!0});var s=i("../Base/TreeNode");function h(l,c){var f=this;l===void 0&&(l=[]),c=c||function(S,T){return ST?1:0};var v=0,g=new s.default;g.color=s.default.TreeNodeColorType.black,this.size=function(){return v},this.empty=function(){return v===0},this.clear=function(){v=0,g.key=void 0,g.leftChild=g.rightChild=g.brother=g.parent=void 0,g.color=s.default.TreeNodeColorType.black};var y=function(S){if(!S||S.key===void 0)throw new Error("unknown error");return S.leftChild?y(S.leftChild):S},p=function(S){if(!S||S.key===void 0)throw new Error("unknown error");return S.rightChild?p(S.rightChild):S};this.front=function(){if(!this.empty())return y(g).key},this.back=function(){if(!this.empty())return p(g).key},this.forEach=function(S){var T,R,O=0;try{for(var K=o(this),G=K.next();!G.done;G=K.next())S(G.value,O++)}catch(ae){T={error:ae}}finally{try{G&&!G.done&&(R=K.return)&&R.call(K)}finally{if(T)throw T.error}}},this.getElementByPos=function(S){var T,R;if(S<0||S>=this.size())throw new Error("pos must more than 0 and less than set's size");var O=0;try{for(var K=o(this),G=K.next();!G.done;G=K.next()){var ae=G.value;if(O===S)return ae;++O}}catch(V){T={error:V}}finally{try{G&&!G.done&&(R=K.return)&&R.call(K)}finally{if(T)throw T.error}}throw new Error("unknown error")};var m=function(S){var T=S.parent;if(!T){if(S===g)return;throw new Error("unknown error")}if(S.color!==s.default.TreeNodeColorType.red){var R=S.brother;if(!R)throw new Error("unknown error");if(S===T.leftChild)if(R.color===s.default.TreeNodeColorType.red){R.color=s.default.TreeNodeColorType.black,T.color=s.default.TreeNodeColorType.red;var O=T.rotateLeft();g===T&&(g=O),m(S)}else R.color===s.default.TreeNodeColorType.black&&(R.rightChild&&R.rightChild.color===s.default.TreeNodeColorType.red?(R.color=T.color,T.color=s.default.TreeNodeColorType.black,R.rightChild&&(R.rightChild.color=s.default.TreeNodeColorType.black),O=T.rotateLeft(),g===T&&(g=O),S.color=s.default.TreeNodeColorType.black):R.rightChild&&R.rightChild.color!==s.default.TreeNodeColorType.black||!R.leftChild||R.leftChild.color!==s.default.TreeNodeColorType.red?R.leftChild&&R.leftChild.color!==s.default.TreeNodeColorType.black||R.rightChild&&R.rightChild.color!==s.default.TreeNodeColorType.black||(R.color=s.default.TreeNodeColorType.red,m(T)):(R.color=s.default.TreeNodeColorType.red,R.leftChild&&(R.leftChild.color=s.default.TreeNodeColorType.black),O=R.rotateRight(),g===R&&(g=O),m(S)));else S===T.rightChild&&(R.color===s.default.TreeNodeColorType.red?(R.color=s.default.TreeNodeColorType.black,T.color=s.default.TreeNodeColorType.red,O=T.rotateRight(),g===T&&(g=O),m(S)):R.color===s.default.TreeNodeColorType.black&&(R.leftChild&&R.leftChild.color===s.default.TreeNodeColorType.red?(R.color=T.color,T.color=s.default.TreeNodeColorType.black,R.leftChild&&(R.leftChild.color=s.default.TreeNodeColorType.black),O=T.rotateRight(),g===T&&(g=O),S.color=s.default.TreeNodeColorType.black):R.leftChild&&R.leftChild.color!==s.default.TreeNodeColorType.black||!R.rightChild||R.rightChild.color!==s.default.TreeNodeColorType.red?R.leftChild&&R.leftChild.color!==s.default.TreeNodeColorType.black||R.rightChild&&R.rightChild.color!==s.default.TreeNodeColorType.black||(R.color=s.default.TreeNodeColorType.red,m(T)):(R.color=s.default.TreeNodeColorType.red,R.rightChild&&(R.rightChild.color=s.default.TreeNodeColorType.black),O=R.rotateLeft(),g===R&&(g=O),m(S))))}else S.color=s.default.TreeNodeColorType.black},b=function(S){for(var T=S;T.leftChild||T.rightChild;){if(T.rightChild){T=y(T.rightChild);var R=S.key;S.key=T.key,T.key=R,S=T}T.leftChild&&(T=p(T.leftChild),R=S.key,S.key=T.key,T.key=R,S=T)}m(T),T&&T.remove(),--v,g.color=s.default.TreeNodeColorType.black},x=function(S,T){return!(!S||S.key===void 0)&&(!!x(S.leftChild,T)||!!T(S)||x(S.rightChild,T))};this.eraseElementByPos=function(S){if(S<0||S>=v)throw new Error("pos must more than 0 and less than set's size");var T=0;x(g,function(R){return S===T?(b(R),!0):(++T,!1)})},this.eraseElementByValue=function(S){if(!this.empty()){var T=I(g,S);T!==void 0&&T.key!==void 0&&c(T.key,S)===0&&b(T)}};var _=function(S,T){if(!S||S.key===void 0)throw new Error("unknown error");var R=c(T,S.key);return R<0?S.leftChild?_(S.leftChild,T):(S.leftChild=new s.default,S.leftChild.parent=S,S.leftChild.brother=S.rightChild,S.rightChild&&(S.rightChild.brother=S.leftChild),S.leftChild):R>0?S.rightChild?_(S.rightChild,T):(S.rightChild=new s.default,S.rightChild.parent=S,S.rightChild.brother=S.leftChild,S.leftChild&&(S.leftChild.brother=S.rightChild),S.rightChild):S},k=function(S){var T=S.parent;if(!T){if(S===g)return;throw new Error("unknown error")}if(T.color!==s.default.TreeNodeColorType.black&&T.color===s.default.TreeNodeColorType.red){var R=T.brother,O=T.parent;if(!O)throw new Error("unknown error");if(R&&R.color===s.default.TreeNodeColorType.red)R.color=T.color=s.default.TreeNodeColorType.black,O.color=s.default.TreeNodeColorType.red,k(O);else if(!R||R.color===s.default.TreeNodeColorType.black)if(T===O.leftChild)if(S===T.leftChild){T.color=s.default.TreeNodeColorType.black,O.color=s.default.TreeNodeColorType.red;var K=O.rotateRight();O===g&&(g=K)}else S===T.rightChild&&(K=T.rotateLeft(),O===g&&(g=K),k(T));else T===O.rightChild&&(S===T.leftChild?(K=T.rotateRight(),O===g&&(g=K),k(T)):S===T.rightChild&&(T.color=s.default.TreeNodeColorType.black,O.color=s.default.TreeNodeColorType.red,K=O.rotateLeft(),O===g&&(g=K)))}};this.insert=function(S){if(S==null)throw new Error("to avoid some unnecessary errors, we don't suggest you insert null or undefined here");if(this.empty())return++v,g.key=S,void(g.color=s.default.TreeNodeColorType.black);var T=_(g,S);T.key!==void 0&&c(T.key,S)===0||(++v,T.key=S,k(T),g.color=s.default.TreeNodeColorType.black)};var I=function(S,T){if(S&&S.key!==void 0){var R=c(T,S.key);return R<0?I(S.leftChild,T):R>0?I(S.rightChild,T):S}};this.find=function(S){var T=I(g,S);return T!==void 0&&T.key!==void 0&&c(T.key,S)===0};var P=function(S,T){if(S&&S.key!==void 0){var R=c(S.key,T);if(R===0)return S.key;if(R<0)return P(S.rightChild,T);var O=P(S.leftChild,T);return O!==void 0?O:S.key}};this.lowerBound=function(S){return P(g,S)};var M=function(S,T){if(S&&S.key!==void 0){if(c(S.key,T)<=0)return M(S.rightChild,T);var R=M(S.leftChild,T);return R!==void 0?R:S.key}};this.upperBound=function(S){return M(g,S)};var L=function(S,T){if(S&&S.key!==void 0){var R=c(S.key,T);if(R===0)return S.key;if(R>0)return L(S.leftChild,T);var O=L(S.rightChild,T);return O!==void 0?O:S.key}};this.reverseLowerBound=function(S){return L(g,S)};var U=function(S,T){if(S&&S.key!==void 0){if(c(S.key,T)>=0)return U(S.leftChild,T);var R=U(S.rightChild,T);return R!==void 0?R:S.key}};this.reverseUpperBound=function(S){return U(g,S)},this.union=function(S){var T=this;S.forEach(function(R){return T.insert(R)})},this.getHeight=function(){if(this.empty())return 0;var S=function(T){return T?Math.max(S(T.leftChild),S(T.rightChild))+1:1};return S(g)};var $=function(S){return n(this,function(T){switch(T.label){case 0:return S&&S.key!==void 0?[5,o($(S.leftChild))]:[2];case 1:return T.sent(),[4,S.key];case 2:return T.sent(),[5,o($(S.rightChild))];case 3:return T.sent(),[2]}})};this[Symbol.iterator]=function(){return $(g)},l.forEach(function(S){return f.insert(S)}),Object.freeze(this)}Object.freeze(h),r.default=h},{"../Base/TreeNode":25}],34:[function(i,a,r){function n(o){var s=this;o===void 0&&(o=[]);var h=0,l=[];this.size=function(){return h},this.empty=function(){return h===0},this.clear=function(){h=0,l.length=0},this.push=function(c){l.push(c),++h},this.pop=function(){l.pop(),h>0&&--h},this.top=function(){return l[h-1]},o.forEach(function(c){return s.push(c)}),Object.freeze(this)}Object.defineProperty(r,"__esModule",{value:!0}),Object.freeze(n),r.default=n},{}],35:[function(i,a,r){var n=this&&this.__generator||function(c,f){var v,g,y,p,m={label:0,sent:function(){if(1&y[0])throw y[1];return y[1]},trys:[],ops:[]};return p={next:b(0),throw:b(1),return:b(2)},typeof Symbol=="function"&&(p[Symbol.iterator]=function(){return this}),p;function b(x){return function(_){return function(k){if(v)throw new TypeError("Generator is already executing.");for(;m;)try{if(v=1,g&&(y=2&k[0]?g.return:k[0]?g.throw||((y=g.return)&&y.call(g),0):g.next)&&!(y=y.call(g,k[1])).done)return y;switch(g=0,y&&(k=[2&k[0],y.value]),k[0]){case 0:case 1:y=k;break;case 4:return m.label++,{value:k[1],done:!1};case 5:m.label++,g=k[1],k=[0];continue;case 7:k=m.ops.pop(),m.trys.pop();continue;default:if(!(y=(y=m.trys).length>0&&y[y.length-1])&&(k[0]===6||k[0]===2)){m=0;continue}if(k[0]===3&&(!y||k[1]>y[0]&&k[1]0)&&!(g=p.next()).done;)m.push(g.value)}catch(b){y={error:b}}finally{try{g&&!g.done&&(v=p.return)&&v.call(p)}finally{if(y)throw y.error}}return m},s=this&&this.__spreadArray||function(c,f,v){if(v||arguments.length===2)for(var g,y=0,p=f.length;y=c.length&&(c=void 0),{value:c&&c[g++],done:!c}}};throw new TypeError(f?"Object is not iterable.":"Symbol.iterator is not defined.")};function l(c){var f=this;c===void 0&&(c=[]);var v=0,g=[];this.size=function(){return v},this.empty=function(){return v===0},this.clear=function(){v=0,g.length=0},this.front=function(){if(!this.empty())return g[0]},this.back=function(){if(!this.empty())return g[v-1]},this.forEach=function(y){g.forEach(y)},this.getElementByPos=function(y){if(y<0||y>=v)throw new Error("pos must more than 0 and less than vector's size");return g[y]},this.eraseElementByPos=function(y){if(y<0||y>=v)throw new Error("pos must more than 0 and less than vector's size");for(var p=y;pm;)this.popBack()},this.pushBack=function(y){g.push(y),++v},this.popBack=function(){g.pop(),v>0&&--v},this.setElementByPos=function(y,p){if(y<0||y>=v)throw new Error("pos must more than 0 and less than vector's size");g[y]=p},this.insert=function(y,p,m){if(m===void 0&&(m=1),y<0||y>v)throw new Error("pos must more than 0 and less than or equal to vector's size");g.splice.apply(g,s([y,0],o(new Array(m).fill(p)),!1)),v+=m},this.find=function(y){return g.includes(y)},this.reverse=function(){g.reverse()},this.unique=function(){var y,p=[];this.forEach(function(b,x){x!==0&&b===y||(p.push(b),y=b)}),p.forEach(function(b,x){g[x]=b});for(var m=p.length;v>m;)this.popBack()},this.sort=function(y){g.sort(y)},this[Symbol.iterator]=function(){return function(){return n(this,function(y){switch(y.label){case 0:return[5,h(g)];case 1:return[2,y.sent()]}})}()},c.forEach(function(y){return f.pushBack(y)}),Object.freeze(this)}Object.defineProperty(r,"__esModule",{value:!0}),Object.freeze(l),r.default=l},{}],36:[function(i,a,r){Object.defineProperty(r,"__esModule",{value:!0}),r.HashMap=r.HashSet=r.Map=r.Set=r.PriorityQueue=r.Deque=r.LinkList=r.Queue=r.Stack=r.Vector=void 0;var n=i("./Vector/Vector");r.Vector=n.default;var o=i("./Stack/Stack");r.Stack=o.default;var s=i("./Queue/Queue");r.Queue=s.default;var h=i("./LinkList/LinkList");r.LinkList=h.default;var l=i("./Deque/Deque");r.Deque=l.default;var c=i("./PriorityQueue/PriorityQueue");r.PriorityQueue=c.default;var f=i("./Set/Set");r.Set=f.default;var v=i("./Map/Map");r.Map=v.default;var g=i("./HashSet/HashSet");r.HashSet=g.default;var y=i("./HashMap/HashMap");r.HashMap=y.default},{"./Deque/Deque":26,"./HashMap/HashMap":27,"./HashSet/HashSet":28,"./LinkList/LinkList":29,"./Map/Map":30,"./PriorityQueue/PriorityQueue":31,"./Queue/Queue":32,"./Set/Set":33,"./Stack/Stack":34,"./Vector/Vector":35}],37:[function(i,a,r){const n=i("yallist"),o=Symbol("max"),s=Symbol("length"),h=Symbol("lengthCalculator"),l=Symbol("allowStale"),c=Symbol("maxAge"),f=Symbol("dispose"),v=Symbol("noDisposeOnSet"),g=Symbol("lruList"),y=Symbol("cache"),p=Symbol("updateAgeOnGet"),m=()=>1,b=(M,L,U)=>{const $=M[y].get(L);if($){const S=$.value;if(x(M,S)){if(k(M,$),!M[l])return}else U&&(M[p]&&($.value.now=Date.now()),M[g].unshiftNode($));return S.value}},x=(M,L)=>{if(!L||!L.maxAge&&!M[c])return!1;const U=Date.now()-L.now;return L.maxAge?U>L.maxAge:M[c]&&U>M[c]},_=M=>{if(M[s]>M[o])for(let L=M[g].tail;M[s]>M[o]&&L!==null;){const U=L.prev;k(M,L),L=U}},k=(M,L)=>{if(L){const U=L.value;M[f]&&M[f](U.key,U.value),M[s]-=U.length,M[y].delete(U.key),M[g].removeNode(L)}};class I{constructor(L,U,$,S,T){this.key=L,this.value=U,this.length=$,this.now=S,this.maxAge=T||0}}const P=(M,L,U,$)=>{let S=U.value;x(M,S)&&(k(M,U),M[l]||(S=void 0)),S&&L.call($,S.value,S.key,M)};a.exports=class{constructor(M){if(typeof M=="number"&&(M={max:M}),M||(M={}),M.max&&(typeof M.max!="number"||M.max<0))throw new TypeError("max must be a non-negative number");this[o]=M.max||1/0;const L=M.length||m;if(this[h]=typeof L!="function"?m:L,this[l]=M.stale||!1,M.maxAge&&typeof M.maxAge!="number")throw new TypeError("maxAge must be a number");this[c]=M.maxAge||0,this[f]=M.dispose,this[v]=M.noDisposeOnSet||!1,this[p]=M.updateAgeOnGet||!1,this.reset()}set max(M){if(typeof M!="number"||M<0)throw new TypeError("max must be a non-negative number");this[o]=M||1/0,_(this)}get max(){return this[o]}set allowStale(M){this[l]=!!M}get allowStale(){return this[l]}set maxAge(M){if(typeof M!="number")throw new TypeError("maxAge must be a non-negative number");this[c]=M,_(this)}get maxAge(){return this[c]}set lengthCalculator(M){typeof M!="function"&&(M=m),M!==this[h]&&(this[h]=M,this[s]=0,this[g].forEach(L=>{L.length=this[h](L.value,L.key),this[s]+=L.length})),_(this)}get lengthCalculator(){return this[h]}get length(){return this[s]}get itemCount(){return this[g].length}rforEach(M,L){L=L||this;for(let U=this[g].tail;U!==null;){const $=U.prev;P(this,M,U,L),U=$}}forEach(M,L){L=L||this;for(let U=this[g].head;U!==null;){const $=U.next;P(this,M,U,L),U=$}}keys(){return this[g].toArray().map(M=>M.key)}values(){return this[g].toArray().map(M=>M.value)}reset(){this[f]&&this[g]&&this[g].length&&this[g].forEach(M=>this[f](M.key,M.value)),this[y]=new Map,this[g]=new n,this[s]=0}dump(){return this[g].map(M=>!x(this,M)&&{k:M.key,v:M.value,e:M.now+(M.maxAge||0)}).toArray().filter(M=>M)}dumpLru(){return this[g]}set(M,L,U){if((U=U||this[c])&&typeof U!="number")throw new TypeError("maxAge must be a number");const $=U?Date.now():0,S=this[h](L,M);if(this[y].has(M)){if(S>this[o])return k(this,this[y].get(M)),!1;const R=this[y].get(M).value;return this[f]&&(this[v]||this[f](M,R.value)),R.now=$,R.maxAge=U,R.value=L,this[s]+=S-R.length,R.length=S,this.get(M),_(this),!0}const T=new I(M,L,S,$,U);return T.length>this[o]?(this[f]&&this[f](M,L),!1):(this[s]+=T.length,this[g].unshift(T),this[y].set(M,this[g].head),_(this),!0)}has(M){if(!this[y].has(M))return!1;const L=this[y].get(M).value;return!x(this,L)}get(M){return b(this,M,!0)}peek(M){return b(this,M,!1)}pop(){const M=this[g].tail;return M?(k(this,M),M.value):null}del(M){k(this,this[y].get(M))}load(M){this.reset();const L=Date.now();for(let U=M.length-1;U>=0;U--){const $=M[U],S=$.e||0;if(S===0)this.set($.k,$.v);else{const T=S-L;T>0&&this.set($.k,$.v,T)}}}prune(){this[y].forEach((M,L)=>b(this,L,!1))}}},{yallist:83}],38:[function(i,a,r){(function(n){(function(){const o=a.exports;o.types={0:"reserved",1:"connect",2:"connack",3:"publish",4:"puback",5:"pubrec",6:"pubrel",7:"pubcomp",8:"subscribe",9:"suback",10:"unsubscribe",11:"unsuback",12:"pingreq",13:"pingresp",14:"disconnect",15:"auth"},o.codes={};for(const h in o.types){const l=o.types[h];o.codes[l]=h}o.CMD_SHIFT=4,o.CMD_MASK=240,o.DUP_MASK=8,o.QOS_MASK=3,o.QOS_SHIFT=1,o.RETAIN_MASK=1,o.VARBYTEINT_MASK=127,o.VARBYTEINT_FIN_MASK=128,o.VARBYTEINT_MAX=268435455,o.SESSIONPRESENT_MASK=1,o.SESSIONPRESENT_HEADER=n.from([o.SESSIONPRESENT_MASK]),o.CONNACK_HEADER=n.from([o.codes.connack<[0,1].map(c=>[0,1].map(f=>{const v=n.alloc(1);return v.writeUInt8(o.codes[h]<n.from([h])),o.EMPTY={pingreq:n.from([o.codes.pingreq<<4,0]),pingresp:n.from([o.codes.pingresp<<4,0]),disconnect:n.from([o.codes.disconnect<<4,0])}}).call(this)}).call(this,i("buffer").Buffer)},{buffer:17}],39:[function(i,a,r){(function(n){(function(){const o=i("./writeToStream"),s=i("events");class h extends s{constructor(){super(),this._array=new Array(20),this._i=0}write(c){return this._array[this._i++]=c,!0}concat(){let c=0;const f=new Array(this._array.length),v=this._array;let g,y=0;for(g=0;g>8,0),f.writeUInt8(255&c,1),f}a.exports={cache:s,generateCache:function(){for(let c=0;c<65536;c++)s[c]=l(c)},generateNumber:l,genBufVariableByteInt:function(c){let f=0,v=0;const g=n.allocUnsafe(4);do f=c%128|0,(c=c/128|0)>0&&(f|=128),g.writeUInt8(f,v++);while(c>0&&v<4);return c>0&&(v=0),h?g.subarray(0,v):g.slice(0,v)},generate4ByteBuffer:function(c){const f=n.allocUnsafe(4);return f.writeUInt32BE(c,0),f}}}).call(this)}).call(this,i("buffer").Buffer)},{buffer:17}],42:[function(i,a,r){a.exports=class{constructor(){this.cmd=null,this.retain=!1,this.qos=0,this.dup=!1,this.length=-1,this.topic=null,this.payload=null}}},{}],43:[function(i,a,r){const n=i("bl"),o=i("events"),s=i("./packet"),h=i("./constants"),l=i("debug")("mqtt-packet:parser");class c extends o{constructor(){super(),this.parser=this.constructor.parser}static parser(v){return this instanceof c?(this.settings=v||{},this._states=["_parseHeader","_parseLength","_parsePayload","_newPacket"],this._resetState(),this):new c().parser(v)}_resetState(){l("_resetState: resetting packet, error, _list, and _stateCounter"),this.packet=new s,this.error=null,this._list=n(),this._stateCounter=0}parse(v){for(this.error&&this._resetState(),this._list.append(v),l("parse: current state: %s",this._states[this._stateCounter]);(this.packet.length!==-1||this._list.length>0)&&this[this._states[this._stateCounter]]()&&!this.error;)this._stateCounter++,l("parse: state complete. _stateCounter is now: %d",this._stateCounter),l("parse: packet.length: %d, buffer list length: %d",this.packet.length,this._list.length),this._stateCounter>=this._states.length&&(this._stateCounter=0);return l("parse: exited while loop. packet: %d, buffer list length: %d",this.packet.length,this._list.length),this._list.length}_parseHeader(){const v=this._list.readUInt8(0);return this.packet.cmd=h.types[v>>h.CMD_SHIFT],this.packet.retain=(v&h.RETAIN_MASK)!=0,this.packet.qos=v>>h.QOS_SHIFT&h.QOS_MASK,this.packet.dup=(v&h.DUP_MASK)!=0,l("_parseHeader: packet: %o",this.packet),this._list.consume(1),!0}_parseLength(){const v=this._parseVarByteNum(!0);return v&&(this.packet.length=v.value,this._list.consume(v.bytes)),l("_parseLength %d",v.value),!!v}_parsePayload(){l("_parsePayload: payload %O",this._list);let v=!1;if(this.packet.length===0||this._list.length>=this.packet.length){switch(this._pos=0,this.packet.cmd){case"connect":this._parseConnect();break;case"connack":this._parseConnack();break;case"publish":this._parsePublish();break;case"puback":case"pubrec":case"pubrel":case"pubcomp":this._parseConfirmation();break;case"subscribe":this._parseSubscribe();break;case"suback":this._parseSuback();break;case"unsubscribe":this._parseUnsubscribe();break;case"unsuback":this._parseUnsuback();break;case"pingreq":case"pingresp":break;case"disconnect":this._parseDisconnect();break;case"auth":this._parseAuth();break;default:this._emitError(new Error("Not supported"))}v=!0}return l("_parsePayload complete result: %s",v),v}_parseConnect(){let v,g,y,p;l("_parseConnect");const m={},b=this.packet,x=this._parseString();if(x===null)return this._emitError(new Error("Cannot parse protocolId"));if(x!=="MQTT"&&x!=="MQIsdp")return this._emitError(new Error("Invalid protocolId"));if(b.protocolId=x,this._pos>=this._list.length)return this._emitError(new Error("Packet too short"));if(b.protocolVersion=this._list.readUInt8(this._pos),b.protocolVersion>=128&&(b.bridgeMode=!0,b.protocolVersion=b.protocolVersion-128),b.protocolVersion!==3&&b.protocolVersion!==4&&b.protocolVersion!==5)return this._emitError(new Error("Invalid protocol version"));if(this._pos++,this._pos>=this._list.length)return this._emitError(new Error("Packet too short"));if(m.username=this._list.readUInt8(this._pos)&h.USERNAME_MASK,m.password=this._list.readUInt8(this._pos)&h.PASSWORD_MASK,m.will=this._list.readUInt8(this._pos)&h.WILL_FLAG_MASK,m.will&&(b.will={},b.will.retain=(this._list.readUInt8(this._pos)&h.WILL_RETAIN_MASK)!=0,b.will.qos=(this._list.readUInt8(this._pos)&h.WILL_QOS_MASK)>>h.WILL_QOS_SHIFT),b.clean=(this._list.readUInt8(this._pos)&h.CLEAN_SESSION_MASK)!=0,this._pos++,b.keepalive=this._parseNum(),b.keepalive===-1)return this._emitError(new Error("Packet too short"));if(b.protocolVersion===5){const k=this._parseProperties();Object.getOwnPropertyNames(k).length&&(b.properties=k)}const _=this._parseString();if(_===null)return this._emitError(new Error("Packet too short"));if(b.clientId=_,l("_parseConnect: packet.clientId: %s",b.clientId),m.will){if(b.protocolVersion===5){const k=this._parseProperties();Object.getOwnPropertyNames(k).length&&(b.will.properties=k)}if((v=this._parseString())===null)return this._emitError(new Error("Cannot parse will topic"));if(b.will.topic=v,l("_parseConnect: packet.will.topic: %s",b.will.topic),(g=this._parseBuffer())===null)return this._emitError(new Error("Cannot parse will payload"));b.will.payload=g,l("_parseConnect: packet.will.paylaod: %s",b.will.payload)}if(m.username){if((p=this._parseString())===null)return this._emitError(new Error("Cannot parse username"));b.username=p,l("_parseConnect: packet.username: %s",b.username)}if(m.password){if((y=this._parseBuffer())===null)return this._emitError(new Error("Cannot parse password"));b.password=y}return this.settings=b,l("_parseConnect: complete"),b}_parseConnack(){l("_parseConnack");const v=this.packet;if(this._list.length<1)return null;if(v.sessionPresent=!!(this._list.readUInt8(this._pos++)&h.SESSIONPRESENT_MASK),this.settings.protocolVersion===5)this._list.length>=2?v.reasonCode=this._list.readUInt8(this._pos++):v.reasonCode=0;else{if(this._list.length<2)return null;v.returnCode=this._list.readUInt8(this._pos++)}if(v.returnCode===-1||v.reasonCode===-1)return this._emitError(new Error("Cannot parse return code"));if(this.settings.protocolVersion===5){const g=this._parseProperties();Object.getOwnPropertyNames(g).length&&(v.properties=g)}l("_parseConnack: complete")}_parsePublish(){l("_parsePublish");const v=this.packet;if(v.topic=this._parseString(),v.topic===null)return this._emitError(new Error("Cannot parse topic"));if(!(v.qos>0)||this._parseMessageId()){if(this.settings.protocolVersion===5){const g=this._parseProperties();Object.getOwnPropertyNames(g).length&&(v.properties=g)}v.payload=this._list.slice(this._pos,v.length),l("_parsePublish: payload from buffer list: %o",v.payload)}}_parseSubscribe(){l("_parseSubscribe");const v=this.packet;let g,y,p,m,b,x,_;if(v.qos!==1)return this._emitError(new Error("Wrong subscribe header"));if(v.subscriptions=[],this._parseMessageId()){if(this.settings.protocolVersion===5){const k=this._parseProperties();Object.getOwnPropertyNames(k).length&&(v.properties=k)}for(;this._pos=v.length)return this._emitError(new Error("Malformed Subscribe Payload"));p=(y=this._parseByte())&h.SUBSCRIBE_OPTIONS_QOS_MASK,x=(y>>h.SUBSCRIBE_OPTIONS_NL_SHIFT&h.SUBSCRIBE_OPTIONS_NL_MASK)!=0,b=(y>>h.SUBSCRIBE_OPTIONS_RAP_SHIFT&h.SUBSCRIBE_OPTIONS_RAP_MASK)!=0,m=y>>h.SUBSCRIBE_OPTIONS_RH_SHIFT&h.SUBSCRIBE_OPTIONS_RH_MASK,_={topic:g,qos:p},this.settings.protocolVersion===5?(_.nl=x,_.rap=b,_.rh=m):this.settings.bridgeMode&&(_.rh=0,_.rap=!0,_.nl=!0),l("_parseSubscribe: push subscription `%s` to subscription",_),v.subscriptions.push(_)}}}_parseSuback(){l("_parseSuback");const v=this.packet;if(this.packet.granted=[],this._parseMessageId()){if(this.settings.protocolVersion===5){const g=this._parseProperties();Object.getOwnPropertyNames(g).length&&(v.properties=g)}for(;this._pos2?(v.reasonCode=this._parseByte(),l("_parseConfirmation: packet.reasonCode `%d`",v.reasonCode)):v.reasonCode=0,v.length>3)){const g=this._parseProperties();Object.getOwnPropertyNames(g).length&&(v.properties=g)}return!0}_parseDisconnect(){const v=this.packet;if(l("_parseDisconnect"),this.settings.protocolVersion===5){this._list.length>0?v.reasonCode=this._parseByte():v.reasonCode=0;const g=this._parseProperties();Object.getOwnPropertyNames(g).length&&(v.properties=g)}return l("_parseDisconnect result: true"),!0}_parseAuth(){l("_parseAuth");const v=this.packet;if(this.settings.protocolVersion!==5)return this._emitError(new Error("Not supported auth packet for this version MQTT"));v.reasonCode=this._parseByte();const g=this._parseProperties();return Object.getOwnPropertyNames(g).length&&(v.properties=g),l("_parseAuth: result: true"),!0}_parseMessageId(){const v=this.packet;return v.messageId=this._parseNum(),v.messageId===null?(this._emitError(new Error("Cannot parse messageId")),!1):(l("_parseMessageId: packet.messageId %d",v.messageId),!0)}_parseString(v){const g=this._parseNum(),y=g+this._pos;if(g===-1||y>this._list.length||y>this.packet.length)return null;const p=this._list.toString("utf8",this._pos,y);return this._pos+=g,l("_parseString: result: %s",p),p}_parseStringPair(){return l("_parseStringPair"),{name:this._parseString(),value:this._parseString()}}_parseBuffer(){const v=this._parseNum(),g=v+this._pos;if(v===-1||g>this._list.length||g>this.packet.length)return null;const y=this._list.slice(this._pos,g);return this._pos+=v,l("_parseBuffer: result: %o",y),y}_parseNum(){if(this._list.length-this._pos<2)return-1;const v=this._list.readUInt16BE(this._pos);return this._pos+=2,l("_parseNum: result: %s",v),v}_parse4ByteNum(){if(this._list.length-this._pos<4)return-1;const v=this._list.readUInt32BE(this._pos);return this._pos+=4,l("_parse4ByteNum: result: %s",v),v}_parseVarByteNum(v){l("_parseVarByteNum");let g,y=0,p=1,m=0,b=!1;const x=this._pos?this._pos:0;for(;y<4&&x+y=y&&this._emitError(new Error("Invalid variable byte integer")),x&&(this._pos+=y),l("_parseVarByteNum: result: %o",b=!!b&&(v?{bytes:y,value:m}:m)),b}_parseByte(){let v;return this._pos=4)&&(C||se))Q+=n.byteLength(C)+2;else{if(he<4)return W.emit("error",new Error("clientId must be supplied before 3.1.1")),!1;if(1*se==0)return W.emit("error",new Error("clientId must be given if cleanSession set to 0")),!1}if(typeof E!="number"||E<0||E>65535||E%1!=0)return W.emit("error",new Error("Invalid keepalive")),!1;if(Q+=2,Q+=1,he===5){var ne=T(W,X);if(!ne)return!1;Q+=ne.length}if(le){if(typeof le!="object")return W.emit("error",new Error("Invalid will")),!1;if(!le.topic||typeof le.topic!="string")return W.emit("error",new Error("Invalid will topic")),!1;if(Q+=n.byteLength(le.topic)+2,Q+=2,le.payload){if(!(le.payload.length>=0))return W.emit("error",new Error("Invalid will payload")),!1;typeof le.payload=="string"?Q+=n.byteLength(le.payload):Q+=le.payload.length}var ye={};if(he===5){if(!(ye=T(W,le.properties)))return!1;Q+=ye.length}}let ge=!1;if(D!=null){if(!ae(D))return W.emit("error",new Error("Invalid username")),!1;ge=!0,Q+=n.byteLength(D)+2}if(H!=null){if(!ge)return W.emit("error",new Error("Username is required to use password")),!1;if(!ae(H))return W.emit("error",new Error("Invalid password")),!1;Q+=G(H)+2}W.write(o.CONNECT_HEADER),P(W,Q),S(W,ee),re.bridgeMode&&(he+=128),W.write(he===131?o.VERSION131:he===132?o.VERSION132:he===4?o.VERSION4:he===5?o.VERSION5:o.VERSION3);let xe=0;return xe|=D!=null?o.USERNAME_MASK:0,xe|=H!=null?o.PASSWORD_MASK:0,xe|=le&&le.retain?o.WILL_RETAIN_MASK:0,xe|=le&&le.qos?le.qos<0&&b(W,C),X!=null&&X.write(),f("publish: payload: %o",E),W.write(E)}(V,F,q);case"puback":case"pubrec":case"pubrel":case"pubcomp":return function(Y,W,J){const re=J?J.protocolVersion:4,ee=Y||{},he=ee.cmd||"puback",le=ee.messageId,se=ee.dup&&he==="pubrel"?o.DUP_MASK:0;let E=0;const C=ee.reasonCode,D=ee.properties;let H=re===5?3:2;if(he==="pubrel"&&(E=1),typeof le!="number")return W.emit("error",new Error("Invalid messageId")),!1;let X=null;if(re===5&&typeof D=="object"){if(!(X=R(W,D,J,H)))return!1;H+=X.length}return W.write(o.ACKS[he][E][se][0]),P(W,H),b(W,le),re===5&&W.write(n.from([C])),X!==null&&X.write(),!0}(V,F,q);case"subscribe":return function(Y,W,J){f("subscribe: packet: ");const re=J?J.protocolVersion:4,ee=Y||{},he=ee.dup?o.DUP_MASK:0,le=ee.messageId,se=ee.subscriptions,E=ee.properties;let C=0;if(typeof le!="number")return W.emit("error",new Error("Invalid messageId")),!1;C+=2;let D=null;if(re===5){if(!(D=T(W,E)))return!1;C+=D.length}if(typeof se!="object"||!se.length)return W.emit("error",new Error("Invalid subscriptions")),!1;for(let X=0;X2)return W.emit("error",new Error("Invalid subscriptions - invalid Retain Handling")),!1}C+=n.byteLength(Q)+2+1}f("subscribe: writing to stream: %o",o.SUBSCRIBE_HEADER),W.write(o.SUBSCRIBE_HEADER[1][he?1:0][0]),P(W,C),b(W,le),D!==null&&D.write();let H=!0;for(const X of se){const Q=X.topic,ne=X.qos,ye=+X.nl,ge=+X.rap,xe=X.rh;let Se;M(W,Q),Se=o.SUBSCRIBE_OPTIONS_QOS[ne],re===5&&(Se|=ye?o.SUBSCRIBE_OPTIONS_NL:0,Se|=ge?o.SUBSCRIBE_OPTIONS_RAP:0,Se|=xe?o.SUBSCRIBE_OPTIONS_RH[xe]:0),H=W.write(n.from([Se]))}return H}(V,F,q);case"suback":return function(Y,W,J){const re=J?J.protocolVersion:4,ee=Y||{},he=ee.messageId,le=ee.granted,se=ee.properties;let E=0;if(typeof he!="number")return W.emit("error",new Error("Invalid messageId")),!1;if(E+=2,typeof le!="object"||!le.length)return W.emit("error",new Error("Invalid qos vector")),!1;for(let D=0;Db===U,set(V){V?(v&&Object.keys(v).length!==0||(x=!0),b=U):(x=!1,b=$)}});const I={};function P(V,F){if(F>o.VARBYTEINT_MAX)return V.emit("error",new Error(`Invalid variable byte integer: ${F}`)),!1;let q=I[F];return q||(q=p(F),F<16384&&(I[F]=q)),f("writeVarByteInt: writing to stream: %o",q),V.write(q)}function M(V,F){const q=n.byteLength(F);return b(V,q),f("writeString: %s",F),V.write(F,"utf8")}function L(V,F,q){M(V,F),M(V,q)}function U(V,F){return f("writeNumberCached: number: %d",F),f("writeNumberCached: %o",v[F]),V.write(v[F])}function $(V,F){const q=g(F);return f("writeNumberGenerated: %o",q),V.write(q)}function S(V,F){typeof F=="string"?M(V,F):F?(b(V,F.length),V.write(F)):b(V,0)}function T(V,F){if(typeof F!="object"||F.length!=null)return{length:1,write(){K(V,{},0)}};let q=0;function Y(W,J){let re=0;switch(o.propertiesTypes[W]){case"byte":if(typeof J!="boolean")return V.emit("error",new Error(`Invalid ${W}: ${J}`)),!1;re+=2;break;case"int8":if(typeof J!="number"||J<0||J>255)return V.emit("error",new Error(`Invalid ${W}: ${J}`)),!1;re+=2;break;case"binary":if(J&&J===null)return V.emit("error",new Error(`Invalid ${W}: ${J}`)),!1;re+=1+n.byteLength(J)+2;break;case"int16":if(typeof J!="number"||J<0||J>65535)return V.emit("error",new Error(`Invalid ${W}: ${J}`)),!1;re+=3;break;case"int32":if(typeof J!="number"||J<0||J>4294967295)return V.emit("error",new Error(`Invalid ${W}: ${J}`)),!1;re+=5;break;case"var":if(typeof J!="number"||J<0||J>268435455)return V.emit("error",new Error(`Invalid ${W}: ${J}`)),!1;re+=1+n.byteLength(p(J));break;case"string":if(typeof J!="string")return V.emit("error",new Error(`Invalid ${W}: ${J}`)),!1;re+=3+n.byteLength(J.toString());break;case"pair":if(typeof J!="object")return V.emit("error",new Error(`Invalid ${W}: ${J}`)),!1;re+=Object.getOwnPropertyNames(J).reduce((ee,he)=>{const le=J[he];return Array.isArray(le)?ee+=le.reduce((se,E)=>se+=3+n.byteLength(he.toString())+2+n.byteLength(E.toString()),0):ee+=3+n.byteLength(he.toString())+2+n.byteLength(J[he].toString()),ee},0);break;default:return V.emit("error",new Error(`Invalid property ${W}: ${J}`)),!1}return re}if(F)for(const W in F){let J=0,re=0;const ee=F[W];if(Array.isArray(ee))for(let he=0;heJ;){const ee=W.shift();if(!ee||!F[ee])return!1;delete F[ee],re=T(V,F)}return re}function O(V,F,q){switch(o.propertiesTypes[F]){case"byte":V.write(n.from([o.properties[F]])),V.write(n.from([+q]));break;case"int8":V.write(n.from([o.properties[F]])),V.write(n.from([q]));break;case"binary":V.write(n.from([o.properties[F]])),S(V,q);break;case"int16":V.write(n.from([o.properties[F]])),b(V,q);break;case"int32":V.write(n.from([o.properties[F]])),function(Y,W){const J=m(W);f("write4ByteNumber: %o",J),Y.write(J)}(V,q);break;case"var":V.write(n.from([o.properties[F]])),P(V,q);break;case"string":V.write(n.from([o.properties[F]])),M(V,q);break;case"pair":Object.getOwnPropertyNames(q).forEach(Y=>{const W=q[Y];Array.isArray(W)?W.forEach(J=>{V.write(n.from([o.properties[F]])),L(V,Y.toString(),J.toString())}):(V.write(n.from([o.properties[F]])),L(V,Y.toString(),W.toString()))});break;default:return V.emit("error",new Error(`Invalid property ${F} value: ${q}`)),!1}}function K(V,F,q){P(V,q);for(const Y in F)if(Object.prototype.hasOwnProperty.call(F,Y)&&F[Y]!==null){const W=F[Y];if(Array.isArray(W))for(let J=0;J=1.5*y;return Math.round(v/y)+" "+p+(m?"s":"")}a.exports=function(v,g){g=g||{};var y=typeof v;if(y==="string"&&v.length>0)return function(p){if(!((p=String(p)).length>100)){var m=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(p);if(!!m){var b=parseFloat(m[1]);switch((m[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return b*c;case"weeks":case"week":case"w":return b*l;case"days":case"day":case"d":return b*h;case"hours":case"hour":case"hrs":case"hr":case"h":return b*s;case"minutes":case"minute":case"mins":case"min":case"m":return b*o;case"seconds":case"second":case"secs":case"sec":case"s":return b*n;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return b;default:return}}}}(v);if(y==="number"&&isFinite(v))return g.long?function(p){var m=Math.abs(p);return m>=h?f(p,m,h,"day"):m>=s?f(p,m,s,"hour"):m>=o?f(p,m,o,"minute"):m>=n?f(p,m,n,"second"):p+" ms"}(v):function(p){var m=Math.abs(p);return m>=h?Math.round(p/h)+"d":m>=s?Math.round(p/s)+"h":m>=o?Math.round(p/o)+"m":m>=n?Math.round(p/n)+"s":p+"ms"}(v);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(v))}},{}],46:[function(i,a,r){const n=i("./lib/number-allocator.js");a.exports.NumberAllocator=n},{"./lib/number-allocator.js":47}],47:[function(i,a,r){const n=i("js-sdsl").Set,o=i("debug")("number-allocator:trace"),s=i("debug")("number-allocator:error");function h(c,f){this.low=c,this.high=f}function l(c,f){if(!(this instanceof l))return new l(c,f);this.min=c,this.max=f,this.ss=new n([],(v,g)=>v.compare(g)),o("Create"),this.clear()}h.prototype.equals=function(c){return this.low===c.low&&this.high===c.high},h.prototype.compare=function(c){return this.lowc)return!1;if(v.low===c)return++v.low,o("use():"+c),!0;if(v.high===c)return--v.high,o("use():"+c),!0;const g=v.low;return v.low=c+1,this.ss.insert(new h(g,c-1)),o("use():"+c),!0}return o("use():failed"),!1},l.prototype.free=function(c){if(cthis.max)return void s("free():"+c+" is out of range");const f=new h(c,c),v=this.ss.lowerBound(f);if(v){if(v.low<=c&&c<=v.high)return void s("free():"+c+" has already been vacant");if(v===this.ss.front())c+1===v.low?--v.low:this.ss.insert(f);else{const g=this.ss.reverseLowerBound(f);g.high+1===c?c+1===v.low?(this.ss.eraseElementByValue(g),v.low=g.low):g.high=c:c+1===v.low?v.low=c:this.ss.insert(f)}}else{if(v===this.ss.front())return void this.ss.insert(f);const g=this.ss.reverseLowerBound(f);g.high+1===c?g.high=c:this.ss.insert(f)}o("free():"+c)},l.prototype.clear=function(){o("clear()"),this.ss.clear(),this.ss.insert(new h(this.min,this.max))},l.prototype.intervalCount=function(){return this.ss.size()},l.prototype.dump=function(){console.log("length:"+this.ss.size());for(const c of this.ss)console.log(c)},a.exports=l},{debug:18,"js-sdsl":36}],48:[function(i,a,r){var n=i("wrappy");function o(h){var l=function(){return l.called?l.value:(l.called=!0,l.value=h.apply(this,arguments))};return l.called=!1,l}function s(h){var l=function(){if(l.called)throw new Error(l.onceError);return l.called=!0,l.value=h.apply(this,arguments)},c=h.name||"Function wrapped with `once`";return l.onceError=c+" shouldn't be called more than once",l.called=!1,l}a.exports=n(o),a.exports.strict=n(s),o.proto=o(function(){Object.defineProperty(Function.prototype,"once",{value:function(){return o(this)},configurable:!0}),Object.defineProperty(Function.prototype,"onceStrict",{value:function(){return s(this)},configurable:!0})})},{wrappy:79}],49:[function(i,a,r){(function(n){(function(){n===void 0||!n.version||n.version.indexOf("v0.")===0||n.version.indexOf("v1.")===0&&n.version.indexOf("v1.8.")!==0?a.exports={nextTick:function(o,s,h,l){if(typeof o!="function")throw new TypeError('"callback" argument must be a function');var c,f,v=arguments.length;switch(v){case 0:case 1:return n.nextTick(o);case 2:return n.nextTick(function(){o.call(null,s)});case 3:return n.nextTick(function(){o.call(null,s,h)});case 4:return n.nextTick(function(){o.call(null,s,h,l)});default:for(c=new Array(v-1),f=0;f1)for(var I=1;I= 0x80 (not a basic code point)","invalid-input":"Invalid input"},U=g-y,$=Math.floor,S=String.fromCharCode;function T(Y){throw new RangeError(L[Y])}function R(Y,W){for(var J=Y.length,re=[];J--;)re[J]=W(Y[J]);return re}function O(Y,W){var J=Y.split("@"),re="";return J.length>1&&(re=J[0]+"@",Y=J[1]),re+R((Y=Y.replace(M,".")).split("."),W).join(".")}function K(Y){for(var W,J,re=[],ee=0,he=Y.length;ee=55296&&W<=56319&&ee65535&&(J+=S((W-=65536)>>>10&1023|55296),W=56320|1023&W),J+=S(W)}).join("")}function ae(Y,W){return Y+22+75*(Y<26)-((W!=0)<<5)}function V(Y,W,J){var re=0;for(Y=J?$(Y/b):Y>>1,Y+=$(Y/W);Y>U*p>>1;re+=g)Y=$(Y/U);return $(re+(U+1)*Y/(Y+m))}function F(Y){var W,J,re,ee,he,le,se,E,C,D,H,X=[],Q=Y.length,ne=0,ye=_,ge=x;for((J=Y.lastIndexOf(k))<0&&(J=0),re=0;re=128&&T("not-basic"),X.push(Y.charCodeAt(re));for(ee=J>0?J+1:0;ee=Q&&T("invalid-input"),((E=(H=Y.charCodeAt(ee++))-48<10?H-22:H-65<26?H-65:H-97<26?H-97:g)>=g||E>$((v-ne)/le))&&T("overflow"),ne+=E*le,!(E<(C=se<=ge?y:se>=ge+p?p:se-ge));se+=g)le>$(v/(D=g-C))&&T("overflow"),le*=D;ge=V(ne-he,W=X.length+1,he==0),$(ne/W)>v-ye&&T("overflow"),ye+=$(ne/W),ne%=W,X.splice(ne++,0,ye)}return G(X)}function q(Y){var W,J,re,ee,he,le,se,E,C,D,H,X,Q,ne,ye,ge=[];for(X=(Y=K(Y)).length,W=_,J=0,he=x,le=0;le=W&&H$((v-J)/(Q=re+1))&&T("overflow"),J+=(se-W)*Q,W=se,le=0;lev&&T("overflow"),H==W){for(E=J,C=g;!(E<(D=C<=he?y:C>=he+p?p:C-he));C+=g)ye=E-D,ne=g-D,ge.push(S(ae(D+ye%ne,0))),E=$(ye/ne);ge.push(S(ae(E,0))),he=V(J,Q,re==ee),J=0,++re}++J,++W}return ge.join("")}if(c={version:"1.4.1",ucs2:{decode:K,encode:G},decode:F,encode:q,toASCII:function(Y){return O(Y,function(W){return P.test(W)?"xn--"+q(W):W})},toUnicode:function(Y){return O(Y,function(W){return I.test(W)?F(W.slice(4).toLowerCase()):W})}},s&&h)if(a.exports==s)h.exports=c;else for(f in c)c.hasOwnProperty(f)&&(s[f]=c[f]);else o.punycode=c})(this)}).call(this)}).call(this,typeof Ot<"u"?Ot:typeof self<"u"?self:typeof window<"u"?window:{})},{}],52:[function(i,a,r){function n(s,h){return Object.prototype.hasOwnProperty.call(s,h)}a.exports=function(s,h,l,c){h=h||"&",l=l||"=";var f={};if(typeof s!="string"||s.length===0)return f;var v=/\+/g;s=s.split(h);var g=1e3;c&&typeof c.maxKeys=="number"&&(g=c.maxKeys);var y=s.length;g>0&&y>g&&(y=g);for(var p=0;p=0?(m=k.substr(0,I),b=k.substr(I+1)):(m=k,b=""),x=decodeURIComponent(m),_=decodeURIComponent(b),n(f,x)?o(f[x])?f[x].push(_):f[x]=[f[x],_]:f[x]=_}return f};var o=Array.isArray||function(s){return Object.prototype.toString.call(s)==="[object Array]"}},{}],53:[function(i,a,r){var n=function(l){switch(typeof l){case"string":return l;case"boolean":return l?"true":"false";case"number":return isFinite(l)?l:"";default:return""}};a.exports=function(l,c,f,v){return c=c||"&",f=f||"=",l===null&&(l=void 0),typeof l=="object"?s(h(l),function(g){var y=encodeURIComponent(n(g))+f;return o(l[g])?s(l[g],function(p){return y+encodeURIComponent(n(p))}).join(c):y+encodeURIComponent(n(l[g]))}).join(c):v?encodeURIComponent(n(v))+f+encodeURIComponent(n(l)):""};var o=Array.isArray||function(l){return Object.prototype.toString.call(l)==="[object Array]"};function s(l,c){if(l.map)return l.map(c);for(var f=[],v=0;v2?"one of ".concat(l," ").concat(h.slice(0,c-1).join(", "),", or ")+h[c-1]:c===2?"one of ".concat(l," ").concat(h[0]," or ").concat(h[1]):"of ".concat(l," ").concat(h[0])}return"of ".concat(l," ").concat(String(h))}o("ERR_INVALID_OPT_VALUE",function(h,l){return'The value "'+l+'" is invalid for option "'+h+'"'},TypeError),o("ERR_INVALID_ARG_TYPE",function(h,l,c){var f,v,g;if(typeof l=="string"&&(v="not ",l.substr(0,v.length)===v)?(f="must not be",l=l.replace(/^not /,"")):f="must be",function(p,m,b){return(b===void 0||b>p.length)&&(b=p.length),p.substring(b-m.length,b)===m}(h," argument"))g="The ".concat(h," ").concat(f," ").concat(s(l,"type"));else{var y=function(p,m,b){return typeof b!="number"&&(b=0),!(b+m.length>p.length)&&p.indexOf(m,b)!==-1}(h,".")?"property":"argument";g='The "'.concat(h,'" ').concat(y," ").concat(f," ").concat(s(l,"type"))}return g+=". Received type ".concat(typeof c)},TypeError),o("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),o("ERR_METHOD_NOT_IMPLEMENTED",function(h){return"The "+h+" method is not implemented"}),o("ERR_STREAM_PREMATURE_CLOSE","Premature close"),o("ERR_STREAM_DESTROYED",function(h){return"Cannot call "+h+" after a stream was destroyed"}),o("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),o("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),o("ERR_STREAM_WRITE_AFTER_END","write after end"),o("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),o("ERR_UNKNOWN_ENCODING",function(h){return"Unknown encoding: "+h},TypeError),o("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),a.exports.codes=n},{}],56:[function(i,a,r){(function(n){(function(){var o=Object.keys||function(p){var m=[];for(var b in p)m.push(b);return m};a.exports=v;var s=i("./_stream_readable"),h=i("./_stream_writable");i("inherits")(v,s);for(var l=o(h.prototype),c=0;c0)if(typeof C=="string"||ne.objectMode||Object.getPrototypeOf(C)===c.prototype||(C=function(ye){return c.from(ye)}(C)),H)ne.endEmitted?U(E,new L):O(E,ne,C,!0);else if(ne.ended)U(E,new P);else{if(ne.destroyed)return!1;ne.reading=!1,ne.decoder&&!D?(C=ne.decoder.write(C),ne.objectMode||C.length!==0?O(E,ne,C,!1):F(E,ne)):O(E,ne,C,!1)}else H||(ne.reading=!1,F(E,ne));return!ne.ended&&(ne.lengthC.highWaterMark&&(C.highWaterMark=function(D){return D>=K?D=K:(D--,D|=D>>>1,D|=D>>>2,D|=D>>>4,D|=D>>>8,D|=D>>>16,D++),D}(E)),E<=C.length?E:C.ended?C.length:(C.needReadable=!0,0))}function ae(E){var C=E._readableState;v("emitReadable",C.needReadable,C.emittedReadable),C.needReadable=!1,C.emittedReadable||(v("emitReadable",C.flowing),C.emittedReadable=!0,n.nextTick(V,E))}function V(E){var C=E._readableState;v("emitReadable_",C.destroyed,C.length,C.ended),C.destroyed||!C.length&&!C.ended||(E.emit("readable"),C.emittedReadable=!1),C.needReadable=!C.flowing&&!C.ended&&C.length<=C.highWaterMark,re(E)}function F(E,C){C.readingMore||(C.readingMore=!0,n.nextTick(q,E,C))}function q(E,C){for(;!C.reading&&!C.ended&&(C.length0,C.resumeScheduled&&!C.paused?C.flowing=!0:E.listenerCount("data")>0&&E.resume()}function W(E){v("readable nexttick read 0"),E.read(0)}function J(E,C){v("resume",C.reading),C.reading||E.read(0),C.resumeScheduled=!1,E.emit("resume"),re(E),C.flowing&&!C.reading&&E.read(0)}function re(E){var C=E._readableState;for(v("flow",C.flowing);C.flowing&&E.read()!==null;);}function ee(E,C){return C.length===0?null:(C.objectMode?D=C.buffer.shift():!E||E>=C.length?(D=C.decoder?C.buffer.join(""):C.buffer.length===1?C.buffer.first():C.buffer.concat(C.length),C.buffer.clear()):D=C.buffer.consume(E,C.decoder),D);var D}function he(E){var C=E._readableState;v("endReadable",C.endEmitted),C.endEmitted||(C.ended=!0,n.nextTick(le,C,E))}function le(E,C){if(v("endReadableNT",E.endEmitted,E.length),!E.endEmitted&&E.length===0&&(E.endEmitted=!0,C.readable=!1,C.emit("end"),E.autoDestroy)){var D=C._writableState;(!D||D.autoDestroy&&D.finished)&&C.destroy()}}function se(E,C){for(var D=0,H=E.length;D=C.highWaterMark:C.length>0)||C.ended))return v("read: emitReadable",C.length,C.ended),C.length===0&&C.ended?he(this):ae(this),null;if((E=G(E,C))===0&&C.ended)return C.length===0&&he(this),null;var H,X=C.needReadable;return v("need readable",X),(C.length===0||C.length-E0?ee(E,C):null)===null?(C.needReadable=C.length<=C.highWaterMark,E=0):(C.length-=E,C.awaitDrain=0),C.length===0&&(C.ended||(C.needReadable=!0),D!==E&&C.ended&&he(this)),H!==null&&this.emit("data",H),H},T.prototype._read=function(E){U(this,new M("_read()"))},T.prototype.pipe=function(E,C){var D=this,H=this._readableState;switch(H.pipesCount){case 0:H.pipes=E;break;case 1:H.pipes=[H.pipes,E];break;default:H.pipes.push(E)}H.pipesCount+=1,v("pipe count=%d opts=%j",H.pipesCount,C);var X=(!C||C.end!==!1)&&E!==n.stdout&&E!==n.stderr?ne:Et;function Q(qe,Qe){v("onunpipe"),qe===D&&Qe&&Qe.hasUnpiped===!1&&(Qe.hasUnpiped=!0,v("cleanup"),E.removeListener("close",xt),E.removeListener("finish",it),E.removeListener("drain",ye),E.removeListener("error",Se),E.removeListener("unpipe",Q),D.removeListener("end",ne),D.removeListener("end",Et),D.removeListener("data",xe),ge=!0,!H.awaitDrain||E._writableState&&!E._writableState.needDrain||ye())}function ne(){v("onend"),E.end()}H.endEmitted?n.nextTick(X):D.once("end",X),E.on("unpipe",Q);var ye=function(qe){return function(){var Qe=qe._readableState;v("pipeOnDrain",Qe.awaitDrain),Qe.awaitDrain&&Qe.awaitDrain--,Qe.awaitDrain===0&&h(qe,"data")&&(Qe.flowing=!0,re(qe))}}(D);E.on("drain",ye);var ge=!1;function xe(qe){v("ondata");var Qe=E.write(qe);v("dest.write",Qe),Qe===!1&&((H.pipesCount===1&&H.pipes===E||H.pipesCount>1&&se(H.pipes,E)!==-1)&&!ge&&(v("false write response, pause",H.awaitDrain),H.awaitDrain++),D.pause())}function Se(qe){v("onerror",qe),Et(),E.removeListener("error",Se),h(E,"error")===0&&U(E,qe)}function xt(){E.removeListener("finish",it),Et()}function it(){v("onfinish"),E.removeListener("close",xt),Et()}function Et(){v("unpipe"),D.unpipe(E)}return D.on("data",xe),function(qe,Qe,Ti){if(typeof qe.prependListener=="function")return qe.prependListener(Qe,Ti);qe._events&&qe._events[Qe]?Array.isArray(qe._events[Qe])?qe._events[Qe].unshift(Ti):qe._events[Qe]=[Ti,qe._events[Qe]]:qe.on(Qe,Ti)}(E,"error",Se),E.once("close",xt),E.once("finish",it),E.emit("pipe",D),H.flowing||(v("pipe resume"),D.resume()),E},T.prototype.unpipe=function(E){var C=this._readableState,D={hasUnpiped:!1};if(C.pipesCount===0)return this;if(C.pipesCount===1)return E&&E!==C.pipes?this:(E||(E=C.pipes),C.pipes=null,C.pipesCount=0,C.flowing=!1,E&&E.emit("unpipe",this,D),this);if(!E){var H=C.pipes,X=C.pipesCount;C.pipes=null,C.pipesCount=0,C.flowing=!1;for(var Q=0;Q0,H.flowing!==!1&&this.resume()):E==="readable"&&(H.endEmitted||H.readableListening||(H.readableListening=H.needReadable=!0,H.flowing=!1,H.emittedReadable=!1,v("on readable",H.length,H.reading),H.length?ae(this):H.reading||n.nextTick(W,this))),D},T.prototype.addListener=T.prototype.on,T.prototype.removeListener=function(E,C){var D=l.prototype.removeListener.call(this,E,C);return E==="readable"&&n.nextTick(Y,this),D},T.prototype.removeAllListeners=function(E){var C=l.prototype.removeAllListeners.apply(this,arguments);return E!=="readable"&&E!==void 0||n.nextTick(Y,this),C},T.prototype.resume=function(){var E=this._readableState;return E.flowing||(v("resume"),E.flowing=!E.readableListening,function(C,D){D.resumeScheduled||(D.resumeScheduled=!0,n.nextTick(J,C,D))}(this,E)),E.paused=!1,this},T.prototype.pause=function(){return v("call pause flowing=%j",this._readableState.flowing),this._readableState.flowing!==!1&&(v("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this},T.prototype.wrap=function(E){var C=this,D=this._readableState,H=!1;for(var X in E.on("end",function(){if(v("wrapped end"),D.decoder&&!D.ended){var ne=D.decoder.end();ne&&ne.length&&C.push(ne)}C.push(null)}),E.on("data",function(ne){v("wrapped data"),D.decoder&&(ne=D.decoder.write(ne)),(!D.objectMode||ne!=null)&&(D.objectMode||ne&&ne.length)&&(C.push(ne)||(H=!0,E.pause()))}),E)this[X]===void 0&&typeof E[X]=="function"&&(this[X]=function(ne){return function(){return E[ne].apply(E,arguments)}}(X));for(var Q=0;Q<$.length;Q++)E.on($[Q],this.emit.bind(this,$[Q]));return this._read=function(ne){v("wrapped _read",ne),H&&(H=!1,E.resume())},this},typeof Symbol=="function"&&(T.prototype[Symbol.asyncIterator]=function(){return p===void 0&&(p=i("./internal/streams/async_iterator")),p(this)}),Object.defineProperty(T.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),Object.defineProperty(T.prototype,"readableBuffer",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}}),Object.defineProperty(T.prototype,"readableFlowing",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(E){this._readableState&&(this._readableState.flowing=E)}}),T._fromList=ee,Object.defineProperty(T.prototype,"readableLength",{enumerable:!1,get:function(){return this._readableState.length}}),typeof Symbol=="function"&&(T.from=function(E,C){return m===void 0&&(m=i("./internal/streams/from")),m(T,E,C)})}).call(this)}).call(this,i("_process"),typeof Ot<"u"?Ot:typeof self<"u"?self:typeof window<"u"?window:{})},{"../errors":55,"./_stream_duplex":56,"./internal/streams/async_iterator":61,"./internal/streams/buffer_list":62,"./internal/streams/destroy":63,"./internal/streams/from":65,"./internal/streams/state":67,"./internal/streams/stream":68,_process:50,buffer:17,events:22,inherits:24,"string_decoder/":75,util:16}],59:[function(i,a,r){a.exports=f;var n=i("../errors").codes,o=n.ERR_METHOD_NOT_IMPLEMENTED,s=n.ERR_MULTIPLE_CALLBACK,h=n.ERR_TRANSFORM_ALREADY_TRANSFORMING,l=n.ERR_TRANSFORM_WITH_LENGTH_0,c=i("./_stream_duplex");function f(y){if(!(this instanceof f))return new f(y);c.call(this,y),this._transformState={afterTransform:function(p,m){var b=this._transformState;b.transforming=!1;var x=b.writecb;if(x===null)return this.emit("error",new s);b.writechunk=null,b.writecb=null,m!=null&&this.push(m),x(p);var _=this._readableState;_.reading=!1,(_.needReadable||_.length<_.highWaterMark)&&this._read(_.highWaterMark)}.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,y&&(typeof y.transform=="function"&&(this._transform=y.transform),typeof y.flush=="function"&&(this._flush=y.flush)),this.on("prefinish",v)}function v(){var y=this;typeof this._flush!="function"||this._readableState.destroyed?g(this,null,null):this._flush(function(p,m){g(y,p,m)})}function g(y,p,m){if(p)return y.emit("error",p);if(m!=null&&y.push(m),y._writableState.length)throw new l;if(y._transformState.transforming)throw new h;return y.push(null)}i("inherits")(f,c),f.prototype.push=function(y,p){return this._transformState.needTransform=!1,c.prototype.push.call(this,y,p)},f.prototype._transform=function(y,p,m){m(new o("_transform()"))},f.prototype._write=function(y,p,m){var b=this._transformState;if(b.writecb=m,b.writechunk=y,b.writeencoding=p,!b.transforming){var x=this._readableState;(b.needTransform||x.needReadable||x.length-1))throw new L(F);return this._writableState.defaultEncoding=F,this},Object.defineProperty(T.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(T.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),T.prototype._write=function(F,q,Y){Y(new x("_write()"))},T.prototype._writev=null,T.prototype.end=function(F,q,Y){var W=this._writableState;return typeof F=="function"?(Y=F,F=null,q=null):typeof q=="function"&&(Y=q,q=null),F!=null&&this.write(F,q),W.corked&&(W.corked=1,this.uncork()),W.ending||function(J,re,ee){re.ending=!0,V(J,re),ee&&(re.finished?n.nextTick(ee):J.once("finish",ee)),re.ended=!0,J.writable=!1}(this,W,Y),this},Object.defineProperty(T.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(T.prototype,"destroyed",{enumerable:!1,get:function(){return this._writableState!==void 0&&this._writableState.destroyed},set:function(F){this._writableState&&(this._writableState.destroyed=F)}}),T.prototype.destroy=y.destroy,T.prototype._undestroy=y.undestroy,T.prototype._destroy=function(F,q){q(F)}}).call(this)}).call(this,i("_process"),typeof Ot<"u"?Ot:typeof self<"u"?self:typeof window<"u"?window:{})},{"../errors":55,"./_stream_duplex":56,"./internal/streams/destroy":63,"./internal/streams/state":67,"./internal/streams/stream":68,_process:50,buffer:17,inherits:24,"util-deprecate":78}],61:[function(i,a,r){(function(n){(function(){var o;function s(k,I,P){return I in k?Object.defineProperty(k,I,{value:P,enumerable:!0,configurable:!0,writable:!0}):k[I]=P,k}var h=i("./end-of-stream"),l=Symbol("lastResolve"),c=Symbol("lastReject"),f=Symbol("error"),v=Symbol("ended"),g=Symbol("lastPromise"),y=Symbol("handlePromise"),p=Symbol("stream");function m(k,I){return{value:k,done:I}}function b(k){var I=k[l];if(I!==null){var P=k[p].read();P!==null&&(k[g]=null,k[l]=null,k[c]=null,I(m(P,!1)))}}var x=Object.getPrototypeOf(function(){}),_=Object.setPrototypeOf((s(o={get stream(){return this[p]},next:function(){var k=this,I=this[f];if(I!==null)return Promise.reject(I);if(this[v])return Promise.resolve(m(void 0,!0));if(this[p].destroyed)return new Promise(function(U,$){n.nextTick(function(){k[f]?$(k[f]):U(m(void 0,!0))})});var P,M=this[g];if(M)P=new Promise(function(U,$){return function(S,T){U.then(function(){$[v]?S(m(void 0,!0)):$[y](S,T)},T)}}(M,this));else{var L=this[p].read();if(L!==null)return Promise.resolve(m(L,!1));P=new Promise(this[y])}return this[g]=P,P}},Symbol.asyncIterator,function(){return this}),s(o,"return",function(){var k=this;return new Promise(function(I,P){k[p].destroy(null,function(M){M?P(M):I(m(void 0,!0))})})}),o),x);a.exports=function(k){var I,P=Object.create(_,(s(I={},p,{value:k,writable:!0}),s(I,l,{value:null,writable:!0}),s(I,c,{value:null,writable:!0}),s(I,f,{value:null,writable:!0}),s(I,v,{value:k._readableState.endEmitted,writable:!0}),s(I,y,{value:function(M,L){var U=P[p].read();U?(P[g]=null,P[l]=null,P[c]=null,M(m(U,!1))):(P[l]=M,P[c]=L)},writable:!0}),I));return P[g]=null,h(k,function(M){if(M&&M.code!=="ERR_STREAM_PREMATURE_CLOSE"){var L=P[c];return L!==null&&(P[g]=null,P[l]=null,P[c]=null,L(M)),void(P[f]=M)}var U=P[l];U!==null&&(P[g]=null,P[l]=null,P[c]=null,U(m(void 0,!0))),P[v]=!0}),k.on("readable",function(M){n.nextTick(b,M)}.bind(null,P)),P}}).call(this)}).call(this,i("_process"))},{"./end-of-stream":64,_process:50}],62:[function(i,a,r){function n(f,v){var g=Object.keys(f);if(Object.getOwnPropertySymbols){var y=Object.getOwnPropertySymbols(f);v&&(y=y.filter(function(p){return Object.getOwnPropertyDescriptor(f,p).enumerable})),g.push.apply(g,y)}return g}function o(f,v,g){return v in f?Object.defineProperty(f,v,{value:g,enumerable:!0,configurable:!0,writable:!0}):f[v]=g,f}function s(f,v){for(var g=0;g0?this.tail.next=p:this.head=p,this.tail=p,++this.length}},{key:"unshift",value:function(y){var p={data:y,next:this.head};this.length===0&&(this.tail=p),this.head=p,++this.length}},{key:"shift",value:function(){if(this.length!==0){var y=this.head.data;return this.length===1?this.head=this.tail=null:this.head=this.head.next,--this.length,y}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(y){if(this.length===0)return"";for(var p=this.head,m=""+p.data;p=p.next;)m+=y+p.data;return m}},{key:"concat",value:function(y){if(this.length===0)return h.alloc(0);for(var p,m,b,x=h.allocUnsafe(y>>>0),_=this.head,k=0;_;)p=_.data,m=x,b=k,h.prototype.copy.call(p,m,b),k+=_.data.length,_=_.next;return x}},{key:"consume",value:function(y,p){var m;return yx.length?x.length:y;if(_===x.length?b+=x:b+=x.slice(0,y),(y-=_)===0){_===x.length?(++m,p.next?this.head=p.next:this.head=this.tail=null):(this.head=p,p.data=x.slice(_));break}++m}return this.length-=m,b}},{key:"_getBuffer",value:function(y){var p=h.allocUnsafe(y),m=this.head,b=1;for(m.data.copy(p),y-=m.data.length;m=m.next;){var x=m.data,_=y>x.length?x.length:y;if(x.copy(p,p.length-y,0,_),(y-=_)===0){_===x.length?(++b,m.next?this.head=m.next:this.head=this.tail=null):(this.head=m,m.data=x.slice(_));break}++b}return this.length-=b,p}},{key:c,value:function(y,p){return l(this,function(m){for(var b=1;b0,function(I){p||(p=I),I&&b.forEach(c),k||(b.forEach(c),m(p))})});return g.reduce(f)}},{"../../../errors":55,"./end-of-stream":64}],67:[function(i,a,r){var n=i("../../../errors").codes.ERR_INVALID_OPT_VALUE;a.exports={getHighWaterMark:function(o,s,h,l){var c=function(f,v,g){return f.highWaterMark!=null?f.highWaterMark:v?f[g]:null}(s,l,h);if(c!=null){if(!isFinite(c)||Math.floor(c)!==c||c<0)throw new n(l?h:"highWaterMark",c);return Math.floor(c)}return o.objectMode?16:16384}}},{"../../../errors":55}],68:[function(i,a,r){a.exports=i("events").EventEmitter},{events:22}],69:[function(i,a,r){(r=a.exports=i("./lib/_stream_readable.js")).Stream=r,r.Readable=r,r.Writable=i("./lib/_stream_writable.js"),r.Duplex=i("./lib/_stream_duplex.js"),r.Transform=i("./lib/_stream_transform.js"),r.PassThrough=i("./lib/_stream_passthrough.js"),r.finished=i("./lib/internal/streams/end-of-stream.js"),r.pipeline=i("./lib/internal/streams/pipeline.js")},{"./lib/_stream_duplex.js":56,"./lib/_stream_passthrough.js":57,"./lib/_stream_readable.js":58,"./lib/_stream_transform.js":59,"./lib/_stream_writable.js":60,"./lib/internal/streams/end-of-stream.js":64,"./lib/internal/streams/pipeline.js":66}],70:[function(i,a,r){a.exports=function(){if(typeof arguments[0]!="function")throw new Error("callback needed");if(typeof arguments[1]!="number")throw new Error("interval needed");var n;if(arguments.length>0){n=new Array(arguments.length-2);for(var o=0;o>5==6?2:m>>4==14?3:m>>3==30?4:m>>6==2?-1:-2}function l(m){var b=this.lastTotal-this.lastNeed,x=function(_,k,I){if((192&k[0])!=128)return _.lastNeed=0,"\uFFFD";if(_.lastNeed>1&&k.length>1){if((192&k[1])!=128)return _.lastNeed=1,"\uFFFD";if(_.lastNeed>2&&k.length>2&&(192&k[2])!=128)return _.lastNeed=2,"\uFFFD"}}(this,m);return x!==void 0?x:this.lastNeed<=m.length?(m.copy(this.lastChar,b,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(m.copy(this.lastChar,b,0,m.length),void(this.lastNeed-=m.length))}function c(m,b){if((m.length-b)%2==0){var x=m.toString("utf16le",b);if(x){var _=x.charCodeAt(x.length-1);if(_>=55296&&_<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=m[m.length-2],this.lastChar[1]=m[m.length-1],x.slice(0,-1)}return x}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=m[m.length-1],m.toString("utf16le",b,m.length-1)}function f(m){var b=m&&m.length?this.write(m):"";if(this.lastNeed){var x=this.lastTotal-this.lastNeed;return b+this.lastChar.toString("utf16le",0,x)}return b}function v(m,b){var x=(m.length-b)%3;return x===0?m.toString("base64",b):(this.lastNeed=3-x,this.lastTotal=3,x===1?this.lastChar[0]=m[m.length-1]:(this.lastChar[0]=m[m.length-2],this.lastChar[1]=m[m.length-1]),m.toString("base64",b,m.length-x))}function g(m){var b=m&&m.length?this.write(m):"";return this.lastNeed?b+this.lastChar.toString("base64",0,3-this.lastNeed):b}function y(m){return m.toString(this.encoding)}function p(m){return m&&m.length?this.write(m):""}r.StringDecoder=s,s.prototype.write=function(m){if(m.length===0)return"";var b,x;if(this.lastNeed){if((b=this.fillLast(m))===void 0)return"";x=this.lastNeed,this.lastNeed=0}else x=0;return x=0?(L>0&&(k.lastNeed=L-1),L):--M=0?(L>0&&(k.lastNeed=L-2),L):--M=0?(L>0&&(L===2?L=0:k.lastNeed=L-3),L):0}(this,m,b);if(!this.lastNeed)return m.toString("utf8",b);this.lastTotal=x;var _=m.length-(x-this.lastNeed);return m.copy(this.lastChar,0,_),m.toString("utf8",b,_)},s.prototype.fillLast=function(m){if(this.lastNeed<=m.length)return m.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);m.copy(this.lastChar,this.lastTotal-this.lastNeed,0,m.length),this.lastNeed-=m.length}},{"safe-buffer":73}],76:[function(i,a,r){var n=i("punycode"),o=i("./util");function s(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}r.parse=I,r.resolve=function(P,M){return I(P,!1,!0).resolve(M)},r.resolveObject=function(P,M){return P?I(P,!1,!0).resolveObject(M):M},r.format=function(P){return o.isString(P)&&(P=I(P)),P instanceof s?P.format():s.prototype.format.call(P)},r.Url=s;var h=/^([a-z0-9.+-]+:)/i,l=/:[0-9]*$/,c=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,f=["{","}","|","\\","^","`"].concat(["<",">",'"',"`"," ","\r",` `," "]),v=["'"].concat(f),g=["%","/","?",";","#"].concat(v),y=["/","?","#"],p=/^[+a-z0-9A-Z_-]{0,63}$/,m=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,b={javascript:!0,"javascript:":!0},x={javascript:!0,"javascript:":!0},_={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},k=i("querystring");function I(P,M,L){if(P&&o.isObject(P)&&P instanceof s)return P;var U=new s;return U.parse(P,M,L),U}s.prototype.parse=function(P,M,L){if(!o.isString(P))throw new TypeError("Parameter 'url' must be a string, not "+typeof P);var U=P.indexOf("?"),$=U!==-1&&U127?he+="x":he+=ee[le];if(!he.match(p)){var E=J.slice(0,q),C=J.slice(q+1),D=ee.match(m);D&&(E.push(D[1]),C.unshift(D[2])),C.length&&(T="/"+C.join(".")+T),this.hostname=E.join(".");break}}}this.hostname.length>255?this.hostname="":this.hostname=this.hostname.toLowerCase(),W||(this.hostname=n.toASCII(this.hostname));var H=this.port?":"+this.port:"",X=this.hostname||"";this.host=X+H,this.href+=this.host,W&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),T[0]!=="/"&&(T="/"+T))}if(!b[K])for(q=0,re=v.length;q0)&&L.host.split("@"))&&(L.auth=D.shift(),L.host=L.hostname=D.shift())),L.search=P.search,L.query=P.query,o.isNull(L.pathname)&&o.isNull(L.search)||(L.path=(L.pathname?L.pathname:"")+(L.search?L.search:"")),L.href=L.format(),L;if(!ee.length)return L.pathname=null,L.search?L.path="/"+L.search:L.path=null,L.href=L.format(),L;for(var le=ee.slice(-1)[0],se=(L.host||P.host||ee.length>1)&&(le==="."||le==="..")||le==="",E=0,C=ee.length;C>=0;C--)(le=ee[C])==="."?ee.splice(C,1):le===".."?(ee.splice(C,1),E++):E&&(ee.splice(C,1),E--);if(!J&&!re)for(;E--;E)ee.unshift("..");!J||ee[0]===""||ee[0]&&ee[0].charAt(0)==="/"||ee.unshift(""),se&&ee.join("/").substr(-1)!=="/"&&ee.push("");var D,H=ee[0]===""||ee[0]&&ee[0].charAt(0)==="/";return he&&(L.hostname=L.host=H?"":ee.length?ee.shift():"",(D=!!(L.host&&L.host.indexOf("@")>0)&&L.host.split("@"))&&(L.auth=D.shift(),L.host=L.hostname=D.shift())),(J=J||L.host&&ee.length)&&!H&&ee.unshift(""),ee.length?L.pathname=ee.join("/"):(L.pathname=null,L.path=null),o.isNull(L.pathname)&&o.isNull(L.search)||(L.path=(L.pathname?L.pathname:"")+(L.search?L.search:"")),L.auth=P.auth||L.auth,L.slashes=L.slashes||P.slashes,L.href=L.format(),L},s.prototype.parseHost=function(){var P=this.host,M=l.exec(P);M&&((M=M[0])!==":"&&(this.port=M.substr(1)),P=P.substr(0,P.length-M.length)),P&&(this.hostname=P)}},{"./util":77,punycode:51,querystring:54}],77:[function(i,a,r){a.exports={isString:function(n){return typeof n=="string"},isObject:function(n){return typeof n=="object"&&n!==null},isNull:function(n){return n===null},isNullOrUndefined:function(n){return n==null}}},{}],78:[function(i,a,r){(function(n){(function(){function o(s){try{if(!n.localStorage)return!1}catch{return!1}var h=n.localStorage[s];return h!=null&&String(h).toLowerCase()==="true"}a.exports=function(s,h){if(o("noDeprecation"))return s;var l=!1;return function(){if(!l){if(o("throwDeprecation"))throw new Error(h);o("traceDeprecation")?console.trace(h):console.warn(h),l=!0}return s.apply(this,arguments)}}}).call(this)}).call(this,typeof Ot<"u"?Ot:typeof self<"u"?self:typeof window<"u"?window:{})},{}],79:[function(i,a,r){a.exports=function n(o,s){if(o&&s)return n(o)(s);if(typeof o!="function")throw new TypeError("need wrapper function");return Object.keys(o).forEach(function(l){h[l]=o[l]}),h;function h(){for(var l=new Array(arguments.length),c=0;c0)for(var v=0,g=arguments.length;v1)v=f;else{if(!this.head)throw new TypeError("Reduce of empty list with no initial value");g=this.head.next,v=this.head.value}for(var y=0;g!==null;y++)v=c(v,g.value,y),g=g.next;return v},n.prototype.reduceReverse=function(c,f){var v,g=this.tail;if(arguments.length>1)v=f;else{if(!this.tail)throw new TypeError("Reduce of empty list with no initial value");g=this.tail.prev,v=this.tail.value}for(var y=this.length-1;g!==null;y--)v=c(v,g.value,y),g=g.prev;return v},n.prototype.toArray=function(){for(var c=new Array(this.length),f=0,v=this.head;v!==null;f++)c[f]=v.value,v=v.next;return c},n.prototype.toArrayReverse=function(){for(var c=new Array(this.length),f=0,v=this.tail;v!==null;f++)c[f]=v.value,v=v.prev;return c},n.prototype.slice=function(c,f){(f=f||this.length)<0&&(f+=this.length),(c=c||0)<0&&(c+=this.length);var v=new n;if(fthis.length&&(f=this.length);for(var g=0,y=this.head;y!==null&&gthis.length&&(f=this.length);for(var g=this.length,y=this.tail;y!==null&&g>f;g--)y=y.prev;for(;y!==null&&g>c;g--,y=y.prev)v.push(y.value);return v},n.prototype.splice=function(c,f,...v){c>this.length&&(c=this.length-1),c<0&&(c=this.length+c);for(var g=0,y=this.head;y!==null&&g0&&n[n.length-1])&&(l[0]===6||l[0]===2)){i=0;continue}if(l[0]===3&&(!n||l[1]>n[0]&&l[1]=e.length&&(e=void 0),{value:e&&e[a++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},qt=globalThis&&globalThis.__read||function(e,t){var i=typeof Symbol=="function"&&e[Symbol.iterator];if(!i)return e;var a=i.call(e),r,n=[],o;try{for(;(t===void 0||t-- >0)&&!(r=a.next()).done;)n.push(r.value)}catch(s){o={error:s}}finally{try{r&&!r.done&&(i=a.return)&&i.call(a)}finally{if(o)throw o.error}}return n},bt=globalThis&&globalThis.__spreadArray||function(e,t,i){if(i||arguments.length===2)for(var a=0,r=t.length,n;a":_=r[L]>+U;break;case">=":_=r[L]>=+U;break;case"<":_=r[L]<+U;break;case"<=":_=r[L]<=+U;break;case"=":case"==":_=r[L]==U;break;case"!=":_=r[L]!=U;break;case"[)":_=Mo(+r[L],U);break;case"![)":_=!Mo(+r[L],U);break;case"[]":_=Bo(r[L],U);break;case"![]":_=!Bo(r[L],U);break}}_&&g.push(m)}}),v?(s=r.events)===null||s===void 0||s.forEach(function(p,m){g.includes(m)&&a.events[p.action](r,p)}):(h=r.events)===null||h===void 0||h.forEach(function(p,m){g.includes(m)&&p.actions.forEach(function(b){a.events[b.action]&&a.events[b.action](r,b)})}),n==="valueUpdate"){(l=r.realTimes)===null||l===void 0||l.forEach(function(p){var m,b,x=[];(m=p.triggers)===null||m===void 0||m.forEach(function(_,k){var I=!1;_.conditionType==="and"?I=_.conditions.every(function(P){return a.judgeCondition(r,p.key,P)}):_.conditionType==="or"&&(I=_.conditions.some(function(P){return a.judgeCondition(r,p.key,P)})),I&&x.push(k)}),(b=p.triggers)===null||b===void 0||b.forEach(function(_,k){var I;x.includes(k)&&((I=_.actions)===null||I===void 0||I.forEach(function(P){a.events[P.action](r,P)}))})});var y=[];(c=a.store.globalTriggers[r.id])===null||c===void 0||c.forEach(function(p,m){var b=!1;p.conditionType==="and"?b=p.conditions.every(function(x){return a.judgeCondition(a.store.pens[x.source],x.key,x)}):p.conditionType==="or"&&(b=p.conditions.some(function(x){return a.judgeCondition(a.store.pens[x.source],x.key,x)})),b&&y.push(m)}),(f=a.store.globalTriggers[r.id])===null||f===void 0||f.forEach(function(p,m){var b;y.includes(m)&&((b=p.actions)===null||b===void 0||b.forEach(function(x){a.events[x.action](r,x)}))})}a.doEvent(a.store.pens[r.parentId],n)}},this.renderPenRaw=cs,this.setElemPosition=Ai,this.setLifeCycleFunc=G2,this.store=e2(Me()),this.setOptions(i),this.setDatabyOptions(i),this.init(t),this.register(Ck()),this.registerCanvasDraw({cube:BE}),this.registerAnchors(Ak()),globalThis.meta2d=this,this.initEventFns(),this.store.emitter.on("*",this.onEvent)}return Object.defineProperty(e.prototype,"beforeAddPen",{get:function(){return this.canvas.beforeAddPen},set:function(t){this.canvas.beforeAddPen=t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"beforeAddPens",{get:function(){return this.canvas.beforeAddPens},set:function(t){this.canvas.beforeAddPens=t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"beforeAddAnchor",{get:function(){return this.canvas.beforeAddAnchor},set:function(t){this.canvas.beforeAddAnchor=t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"beforeRemovePens",{get:function(){return this.canvas.beforeRemovePens},set:function(t){this.canvas.beforeRemovePens=t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"beforeRemoveAnchor",{get:function(){return this.canvas.beforeRemoveAnchor},set:function(t){this.canvas.beforeRemoveAnchor=t},enumerable:!1,configurable:!0}),e.prototype.setOptions=function(t){var i;t===void 0&&(t={}),(t.grid!==void 0||t.gridColor!==void 0||t.gridSize!==void 0)&&this.canvas&&(this.canvas.canvasTemplate.bgPatchFlags=!0),(t.rule!==void 0||t.ruleColor!==void 0||t.ruleOptions!==void 0)&&(this.store.patchFlagsTop=!0,t.ruleOptions&&!((i=this.store.options)===null||i===void 0)&&i.ruleOptions&&(Object.assign(this.store.options.ruleOptions,t.ruleOptions),t.ruleOptions=this.store.options.ruleOptions)),t.background!==void 0&&this.canvas&&(this.canvas.canvasTemplate.bgPatchFlags=!0),t.resizeMode!==void 0&&(t.resizeMode||(this.canvas.hotkeyType=Ke.None)),(t.width!==void 0||t.height!==void 0)&&this.canvas&&(this.canvas.canvasTemplate.bgPatchFlags=!0),this.store.options=Object.assign(this.store.options,t),this.canvas&&t.scroll!==void 0&&(t.scroll?(!this.canvas.scroll&&(this.canvas.scroll=new Sg(this.canvas)),this.canvas.scroll.show()):this.canvas.scroll&&this.canvas.scroll.hide())},e.prototype.getOptions=function(){return this.store.options},e.prototype.setTheme=function(t){this.store.data.theme=t,this.setBackgroundColor(this.store.theme[t].background),this.canvas.parentElement.style.background=this.store.theme[t].parentBackground,this.store.data.color=this.store.theme[t].color,this.setOptions({ruleColor:this.store.theme[t].ruleColor,ruleOptions:this.store.theme[t].ruleOptions}),this.render()},e.prototype.setDatabyOptions=function(t){t===void 0&&(t={});var i=t.color,a=t.activeColor,r=t.activeBackground,n=t.grid,o=t.gridColor,s=t.gridSize,h=t.fromArrow,l=t.toArrow,c=t.rule,f=t.ruleColor,v=t.textColor;this.setRule({rule:c,ruleColor:f}),this.setGrid({grid:n,gridColor:o,gridSize:s}),this.store.data=Object.assign(this.store.data,{textColor:v,color:i,activeColor:a,activeBackground:r,fromArrow:h,toArrow:l})},e.prototype.init=function(t){typeof t=="string"?this.canvas=new Dd(this,document.getElementById(t),this.store):this.canvas=new Dd(this,t,this.store),this.resize(),this.canvas.listen()},e.prototype.initEventFns=function(){var t=this;this.events[dt.Link]=function(i,a){var r;if(window&&a.value&&typeof a.value=="string"){window.open(a.value,(r=a.params)!==null&&r!==void 0?r:"_blank");return}console.warn("[meta2d] Link param is not a string")},this.events[dt.SetProps]=function(i,a){var r=a.value;if(r&&typeof r=="object"){var n=a.params?t.find(a.params):t.find(i.id);n.forEach(function(o){r.hasOwnProperty("visible")&&o.visible!==r.visible&&t.setVisible(o,r.visible),t.setValue(jt({id:o.id},r),{render:!1,doEvent:!1})}),t.render();return}console.warn("[meta2d] SetProps value is not an object")},this.events[dt.StartAnimate]=function(i,a){var r=i;if(a.value&&(r=t.findOne(a.value)),!(t.store.animates.has(r)&&!r.calculative.pause)){if(a.targetType&&a.params){t.startAnimate(a.value||[i],a.params);return}if(!a.value||typeof a.value=="string"){t.startAnimate(a.value||[i]);return}console.warn("[meta2d] StartAnimate value is not a string")}},this.events[dt.PauseAnimate]=function(i,a){if(!a.value||typeof a.value=="string"){t.pauseAnimate(a.value||[i]);return}console.warn("[meta2d] PauseAnimate value is not a string")},this.events[dt.StopAnimate]=function(i,a){if(!a.value||typeof a.value=="string"){if(a.value){var r=t.findOne(a.value);if(!t.store.animates.has(r))return}else if(!t.store.animates.has(i))return;t.stopAnimate(a.value||[i]);return}console.warn("[meta2d] StopAnimate event value is not a string")},this.events[dt.StartVideo]=function(i,a){if(!a.value||typeof a.value=="string"){t.startVideo(a.value||[i]);return}console.warn("[meta2d] StartVideo value is not a string")},this.events[dt.PauseVideo]=function(i,a){if(!a.value||typeof a.value=="string"){t.pauseVideo(a.value||[i]);return}console.warn("[meta2d] PauseVideo value is not a string")},this.events[dt.StopVideo]=function(i,a){if(!a.value||typeof a.value=="string"){t.stopVideo(a.value||[i]);return}console.warn("[meta2d] StopVideo event value is not a string")},this.events[dt.JS]=function(i,a){var r;if(a.value&&!a.fn)try{if(typeof a.value!="string")throw new Error("[meta2d] Function value must be string");var n=a.value;a.fn=new Function("pen","params","context",n)}catch(o){console.error("[meta2d]: Error on make a function:",o)}(r=a.fn)===null||r===void 0||r.call(a,i,a.params,{meta2d:t,eventName:a.name})},this.events[dt.GlobalFn]=function(i,a){if(typeof a.value!="string"){console.warn("[meta2d] GlobalFn value must be a string");return}globalThis[a.value]&&globalThis[a.value](i,a.params)},this.events[dt.Emit]=function(i,a){if(typeof a.value!="string"){console.warn("[meta2d] Emit value must be a string");return}t.store.emitter.emit(a.value,{pen:i,params:a.params,eventName:a.name})},this.events[dt.SendPropData]=function(i,a){var r=ce(a.value);if(r&&typeof r=="object"){var n=a.params?t.findOne(a.params):i;for(var o in r)(r[o]===void 0||r[o]==="")&&(r[o]=n[o]);r.id=n.id,t.doSendDataEvent(r,a.extend);return}console.warn("[meta2d] SendPropData value is not an object")},this.events[dt.SendVarData]=function(i,a){var r=ce(a.value);if(r&&typeof r=="object"){var n=a.params?t.findOne(a.params):i,o=[],s=function(l){var c={dataId:l,value:r[l]};if(!c.value){var f=n.form.find(function(v){return v.dataIds&&v.dataIds.dataId===c.dataId});f&&(c.value=n[f.key])}o.push(c)};for(var h in r)s(h);t.doSendDataEvent(o,a.extend);return}console.warn("[meta2d] SendVarData value is not an object")},this.events[dt.Navigator]=function(i,a){a.value&&typeof a.value=="string"&&t.navigatorTo(a.value)},this.events[dt.Dialog]=function(i,a){a.params&&typeof a.params=="string"&&a.value&&typeof a.value=="string"&&t.canvas.dialog.show(a.value,a.params)},this.events[dt.SendData]=function(i,a){var r=ce(a.value);if(r&&typeof r=="object"&&a.targetType==="id"){var n=a.params?t.findOne(a.params):i;for(var o in r)(r[o]===void 0||r[o]==="")&&(r[o]=n[o]);r.id=n.id,t.sendDataToNetWork(r,a.network);return}},this.events[dt.PostMessage]=function(i,a){if(typeof a.value!="string"){console.warn("[meta2d] Emit value must be a string");return}var r=a.params?t.findOne(a.params):i;if(r.name!=="iframe"||!r.iframe){console.warn("\u4E0D\u662F\u5D4C\u5165\u9875\u9762");return}var n=nd(r.iframe.split("?")[1]);r.calculative.singleton.div.children[0].contentWindow.postMessage(JSON.stringify({name:a.value,id:n.id}),"*")},this.events[dt.PostMessageToParent]=function(i,a){if(typeof a.value!="string"){console.warn("[meta2d] Emit value must be a string");return}window.parent.postMessage(JSON.stringify(a.value),"*")}},e.prototype.navigatorTo=function(t){if(!!t){var i=window.location.href,a=i.split("id=");if(a.length>1){var r=a[1].indexOf("&");r===-1?window.location.href=a[0]+"id="+t:window.location.href=a[0]+"id="+t+a[1].slice(r)}}},e.prototype.doSendDataEvent=function(t,i){var a=this,r=JSON.stringify(t);this.mqttClient&&this.mqttClient.connected&&(i?i.split(",").forEach(function(n){a.mqttClient.publish(n,r)}):this.store.data.mqttTopics&&this.store.data.mqttTopics.split(",").forEach(function(n){a.mqttClient.publish(n,r)})),this.websocket&&this.websocket.readyState===1&&this.websocket.send(r),(this.store.data.https||this.store.data.http)&&this.sendDatabyHttp(r),this.store.emitter.emit("sendData",r)},e.prototype.sendDataToNetWork=function(t,i){return Pt(this,void 0,void 0,function(){var a,r,n,o,s,h,l,c,f;return It(this,function(v){switch(v.label){case 0:if(a=ce(i),a.data&&(Object.assign(a,a.data),delete a.data),!a.url)return[2];if(a.protocol!=="http")return[3,2];if(typeof a.headers=="object")for(r in a.headers)n=a.headers[r].match(new RegExp("(?<=\\$\\{).*?(?=\\})","g")),n&&(a.headers[r]=a.headers[r].replace("${"+n[0]+"}",this.getDynamicParam(n[0])));return o=void 0,a.method==="GET"&&(o="?"+Object.keys(t).map(function(g){return g+"="+t[g]}).join("&")),[4,fetch(a.url+(o||""),{headers:a.headers||{},method:a.method,body:a.method==="POST"?JSON.stringify(t):void 0})];case 1:return s=v.sent(),s.ok&&console.info("http\u6D88\u606F\u53D1\u9001\u6210\u529F"),[3,3];case 2:a.protocol==="mqtt"?(h=this.mqttClients.filter(function(g){return g.options.href===a.url}),h&&h.length?h[0].connected&&a.topics.split(",").forEach(function(g){h[0].publish(g,t)}):(l=Qo.exports.connect(a.url,a.options),l.on("connect",function(){console.info("mqtt\u8FDE\u63A5\u6210\u529F"),a.topics.split(",").forEach(function(g){l.publish(g,t),l==null||l.end()})}))):a.protocol==="websocket"&&(c=this.websockets.filter(function(g){return g.url===a.url}),c&&c.length?c[0].readyState===1&&c[0].send(t):(f=new WebSocket(a.url,a.protocols||void 0),f.onopen=function(){console.info("websocket\u8FDE\u63A5\u6210\u529F"),f.send(t),setTimeout(function(){f.close()},100)})),v.label=3;case 3:return[2]}})})},e.prototype.resize=function(t,i){this.canvas.resize(t,i),this.render(),this.store.emitter.emit("resize",{width:t,height:i}),this.canvas.scroll&&this.canvas.scroll.isShow&&this.canvas.scroll.init()},e.prototype.addPen=function(t,i,a){return a===void 0&&(a=!0),Pt(this,void 0,void 0,function(){return It(this,function(r){switch(r.label){case 0:return[4,this.canvas.addPen(t,i,a)];case 1:return[2,r.sent()]}})})},e.prototype.addPens=function(t,i){return Pt(this,void 0,void 0,function(){return It(this,function(a){switch(a.label){case 0:return[4,this.canvas.addPens(t,i)];case 1:return[2,a.sent()]}})})},e.prototype.render=function(t){var i;(i=this.canvas)===null||i===void 0||i.render(t)},e.prototype.setBackgroundImage=function(t,i){var a,r,n,o;return Pt(this,void 0,void 0,function(){function s(v){return Pt(this,void 0,void 0,function(){return It(this,function(g){return[2,new Promise(function(y){var p=new Image;p.src=v,h.store.options.cdn&&!(v.startsWith("http")||v.startsWith("//")||v.startsWith("data:image"))&&(p.src=h.store.options.cdn+v),p.crossOrigin="anonymous",p.onload=function(){y(p)}})]})})}var h,l,c,f;return It(this,function(v){switch(v.label){case 0:return h=this,this.store.data.bkImage=t,l=(i==null?void 0:i.width)||((a=this.store.data)===null||a===void 0?void 0:a.width)||((r=this.store.options)===null||r===void 0?void 0:r.width),c=(i==null?void 0:i.height)||((n=this.store.data)===null||n===void 0?void 0:n.height)||((o=this.store.options)===null||o===void 0?void 0:o.height),l&&c?(this.canvas.canvasTemplate.canvas.style.backgroundImage=null,this.canvas&&(this.canvas.canvasTemplate.bgPatchFlags=!0)):this.canvas.canvasTemplate.canvas.style.backgroundImage=t?"url('"+t+"')":"",t?[4,s(t)]:[3,2];case 1:return f=v.sent(),this.store.bkImg=f,l&&c&&this.canvas&&(this.canvas.canvasTemplate.init(),this.render()),[3,3];case 2:this.store.bkImg=null,v.label=3;case 3:return[2]}})})},e.prototype.setBackgroundColor=function(t){t===void 0&&(t=this.store.data.background),this.store.data.background=t,this.canvas&&(this.canvas.canvasTemplate.bgPatchFlags=!0)},e.prototype.setGrid=function(t){var i=t===void 0?{}:t,a=i.grid,r=a===void 0?this.store.data.grid:a,n=i.gridColor,o=n===void 0?this.store.data.gridColor:n,s=i.gridSize,h=s===void 0?this.store.data.gridSize:s,l=i.gridRotate,c=l===void 0?this.store.data.gridRotate:l;this.store.data.grid=r,this.store.data.gridColor=o,this.store.data.gridSize=h,this.store.data.gridRotate=c,this.canvas&&(this.canvas.canvasTemplate.bgPatchFlags=!0)},e.prototype.setRule=function(t){var i=t===void 0?{}:t,a=i.rule,r=a===void 0?this.store.data.rule:a,n=i.ruleColor,o=n===void 0?this.store.data.ruleColor:n;this.store.data.rule=r,this.store.data.ruleColor=o,this.store.patchFlagsTop=!0},e.prototype.open=function(t,i){var a,r,n,o,s,h,l,c,f=this;if(i===void 0&&(i=!0),this.clear(!1,t==null?void 0:t.template),this.canvas.autoPolylineFlag=!0,t){this.setBackgroundImage(t.bkImage,t),Object.assign(this.store.data,t),this.store.data.pens=[];try{for(var v=wt(t.pens),g=v.next();!g.done;g=v.next()){var y=g.value;y.id||(y.id=Me()),!y.calculative&&(y.calculative={canvas:this.canvas}),this.store.pens[y.id]=y}}catch(P){a={error:P}}finally{try{g&&!g.done&&(r=v.return)&&r.call(v)}finally{if(a)throw a.error}}try{for(var p=wt(t.pens),m=p.next();!m.done;m=p.next()){var y=m.value;this.canvas.makePen(y)}}catch(P){n={error:P}}finally{try{m&&!m.done&&(o=p.return)&&o.call(p)}finally{if(n)throw n.error}}try{for(var b=wt(t.pens),x=b.next();!x.done;x=b.next()){var y=x.value;this.canvas.updateLines(y)}}catch(P){s={error:P}}finally{try{x&&!x.done&&(h=b.return)&&h.call(b)}finally{if(s)throw s.error}}}if(this.canvas.patchFlagsLines.forEach(function(P){P.type&&f.canvas.initLineRect(P)}),this.store.data.template||(this.store.data.template=Me()),i||(this.canvas.opening=!0),this.initBindDatas(),this.initBinds(),this.initMessageEvents(),this.initGlobalTriggers(),this.render(),this.listenSocket(),this.connectSocket(),this.connectNetwork(),this.startAnimate(),this.startVideo(),this.doInitJS(),this.store.data.iconUrls)try{for(var _=wt(this.store.data.iconUrls),k=_.next();!k.done;k=_.next()){var I=k.value;u2(I,function(){f.render()})}}catch(P){l={error:P}}finally{try{k&&!k.done&&(c=_.return)&&c.call(_)}finally{if(l)throw l.error}}this.canvas.autoPolylineFlag=!1,this.store.emitter.emit("opened"),this.canvas.scroll&&this.canvas.scroll.isShow&&this.canvas.scroll.init()},e.prototype.cacheData=function(t){if(t&&this.store.options.cacheLength){var i=this.store.cacheDatas.findIndex(function(r){return r.data&&r.data._id===t});if(i===-1)this.store.cacheDatas.push({data:ce(this.store.data,!0)}),this.store.cacheDatas.length>this.store.options.cacheLength&&this.store.cacheDatas.shift();else{var a=this.store.cacheDatas.splice(i,1)[0];this.store.cacheDatas.push(a)}}},e.prototype.loadCacheData=function(t){var i=this,a=this.store.cacheDatas.findIndex(function(r){return r.data&&r.data._id===t});a!==-1&&(this.store.data=this.store.cacheDatas[a].data,this.setBackgroundImage(this.store.data.bkImage),this.store.pens={},this.store.data.pens.forEach(function(r){r.calculative.canvas=i.canvas,i.store.pens[r.id]=r,ke.path2dDraws[r.name]&&i.store.path2dMap.set(r,ke.path2dDraws[r.name](r)),r.type&&i.store.path2dMap.set(r,ke.path2dDraws[r.name](r)),r.image&&(r.calculative.imageDrawed=!1,i.canvas.loadImage(r))}),this.render())},e.prototype.initBindDatas=function(){var t=this;this.store.bindDatas={},this.store.data.pens.forEach(function(i){var a;(a=i.form)===null||a===void 0||a.forEach(function(r){var n;r.dataIds&&(Array.isArray(r.dataIds)?n=r.dataIds:n=[r.dataIds]),n==null||n.forEach(function(o){t.store.bindDatas[o.dataId]||(t.store.bindDatas[o.dataId]=[]),t.store.bindDatas[o.dataId].push({id:i.id,formItem:r})})})})},e.prototype.initBinds=function(){var t=this;this.store.bind={},this.store.data.pens.forEach(function(i){var a;(a=i.realTimes)===null||a===void 0||a.forEach(function(r){r.bind&&r.bind.id&&(t.store.bind[r.bind.id]||(t.store.bind[r.bind.id]=[]),t.store.bind[r.bind.id].push({id:i.id,key:r.key}))})})},e.prototype.connectSocket=function(){this.connectWebsocket(),this.connectMqtt(),this.connectHttp()},e.prototype.doInitJS=function(){var t=this.store.data.initJs;if(t&&t.trim())try{var i=new Function("context",t);i({meta2d:this})}catch(a){console.warn("initJs error",a)}},e.prototype.drawLine=function(t){t&&Tg(this.store),this.canvas.drawingLineName=t},e.prototype.alignPenToGrid=function(t){this.canvas.alignPenToGrid(t)},e.prototype.drawingPencil=function(){this.canvas.drawingPencil()},e.prototype.stopPencil=function(){this.canvas.stopPencil()},e.prototype.lock=function(t){this.store.data.locked=t,this.finishDrawLine(!0),this.canvas.drawingLineName="",this.stopPencil(),this.store.data.pens.forEach(function(i){i.externElement===!0&&i.onMove&&i.onMove(i)}),t>0&&this.initMessageEvents()},e.prototype.finishDrawLine=function(t){return Pt(this,void 0,void 0,function(){return It(this,function(i){switch(i.label){case 0:return[4,this.canvas.finishDrawline(t)];case 1:return i.sent(),[2]}})})},e.prototype.finishPencil=function(){return Pt(this,void 0,void 0,function(){return It(this,function(t){switch(t.label){case 0:return[4,this.canvas.finishPencil()];case 1:return t.sent(),[2]}})})},e.prototype.updateLineType=function(t,i){if(!(!t||t.name!="line"||!i||!this.canvas[i])){t.lineName=i;var a=lt(t),r=We(t);a.prev=void 0,a.next=void 0,r.prev=void 0,r.next=void 0,t.calculative.worldAnchors=[a,r],t.calculative.activeAnchor=a,this.canvas[i](this.store,t,r),t.lineName==="curve"&&(a.prev={penId:a.penId,x:a.x-50,y:a.y},a.next={penId:a.penId,x:a.x+50,y:a.y},r.prev={penId:r.penId,x:r.x-50,y:r.y},r.next={penId:r.penId,x:r.x+50,y:r.y}),t.calculative.activeAnchor=void 0,this.canvas.initLineRect(t),this.render()}},e.prototype.addDrawLineFn=function(t,i){this.canvas[t]=i,this.canvas.drawLineFns.push(t)},e.prototype.removeDrawLineFn=function(t){var i=this.canvas.drawLineFns.indexOf(t);i>-1&&this.canvas.drawLineFns.splice(i,1)},e.prototype.showMagnifier=function(){this.canvas.showMagnifier()},e.prototype.hideMagnifier=function(){this.canvas.hideMagnifier()},e.prototype.toggleMagnifier=function(){this.canvas.toggleMagnifier()},e.prototype.clear=function(t,i){var a,r,n;t===void 0&&(t=!0);try{for(var o=wt(this.store.data.pens),s=o.next();!s.done;s=o.next()){var h=s.value;(n=h.onDestroy)===null||n===void 0||n.call(h,h)}}catch(l){a={error:l}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(a)throw a.error}}t2(this.store,i),this.hideInput(),this.canvas.tooltip.hide(),this.map&&this.map.isShow&&(this.map.show(),this.map.setView()),this.canvas.clearCanvas(),sessionStorage.removeItem("page"),this.store.clipboard=void 0,this.store.sameTemplate||(this.canvas.canvasTemplate.bgPatchFlags=!0),this.store.patchFlagsBackground=!0,this.store.patchFlagsTop=!0,this.setBackgroundImage(void 0),t&&this.render()},e.prototype.emit=function(t,i){this.store.emitter.emit(t,i)},e.prototype.on=function(t,i){return this.store.emitter.on(t,i),this},e.prototype.off=function(t,i){return this.store.emitter.off(t,i),this},e.prototype.registerMoveDock=function(t){this.canvas.customMoveDock=t},e.prototype.registerResizeDock=function(t){this.canvas.customResizeDock=t},e.prototype.find=function(t){return this.canvas.find(t)},e.prototype.findOne=function(t){return this.canvas.findOne(t)},e.prototype.getPenRect=function(t){return this.canvas.getPenRect(t)},e.prototype.setPenRect=function(t,i,a){a===void 0&&(a=!0),this.canvas.setPenRect(t,i,a)},e.prototype.startAnimate=function(t,i){var a=this;this.stopAnimate(t);var r;t?typeof t=="string"?r=this.find(t):r=t:r=this.store.data.pens.filter(function(n){return(n.type||n.frames)&&n.autoPlay||n.animations&&n.animations.length&&n.animations.findIndex(function(o){return o.autoPlay})!==-1}),r.length&&(r.forEach(function(n){var o,s;if(n.calculative.pause){var h=Date.now()-n.calculative.pause;n.calculative.pause=void 0,n.calculative.frameStart+=h,n.calculative.frameEnd+=h}else{var l=-1;if(i!==void 0&&n.animations){if(typeof i=="string"){if(l=n.animations.findIndex(function(f){return f.name===i}),l===-1)return}else if(typeof i=="number")if(n.animations.length>i)l=i;else return}else i===void 0&&(l=(o=n.animations)===null||o===void 0?void 0:o.findIndex(function(f){return f.autoPlay}),l===-1&&((s=n.animations)===null||s===void 0?void 0:s.length)&&(l=0));if(l!==-1&&l!==void 0){var c=ce(n.animations[l]);delete c.name,c.currentAnimation=l,!n.type&&c.frames&&(c.showDuration=a.calcAnimateDuration(c)),a.setValue(jt({id:n.id},c),{doEvent:!1,history:!1})}a.store.animates.add(n),n.type||a.store.animateMap.set(n,n.calculative.canvas.getFrameProps(n))}}),this.initImageCanvas(r),this.canvas.animate())},e.prototype.pauseAnimate=function(t){var i=[];t?typeof t=="string"?i=this.find(t):i=t:this.store.animates.forEach(function(a){i.push(a)}),i.forEach(function(a){a.calculative.pause||(a.calculative.pause=Date.now())})},e.prototype.stopAnimate=function(t){var i=this,a=[];t?typeof t=="string"?a=this.find(t):a=t:this.store.animates.forEach(function(r){a.push(r)}),a.forEach(function(r){r.currentAnimation=void 0,r.calculative.pause=void 0,r.calculative.start=void 0,r.calculative.duration=void 0,r.calculative.animatePos=0,i.store.animates.delete(r),i.canvas.restoreNodeAnimate(r),i.canvas.updateLines(r),i.store.animateMap.delete(r)}),this.initImageCanvas(a),setTimeout(function(){var r;(r=i.canvas)===null||r===void 0||r.calcActiveRect(),i.render()},20)},e.prototype.startVideo=function(t){var i;t?typeof t=="string"?i=this.find(t):i=t:i=this.store.data.pens.filter(function(a){return(a.video||a.audio)&&a.autoPlay}),i.forEach(function(a){var r,n;(r=a.calculative.media)===null||r===void 0||r.play(),(n=a.onStartVideo)===null||n===void 0||n.call(a,a)})},e.prototype.pauseVideo=function(t){var i=[];t?typeof t=="string"?i=this.find(t):i=t:i=this.store.data.pens.filter(function(a){return(a.video||a.audio)&&a.autoPlay}),i.forEach(function(a){var r,n;(r=a.calculative.media)===null||r===void 0||r.pause(),(n=a.onPauseVideo)===null||n===void 0||n.call(a,a)})},e.prototype.stopVideo=function(t){var i=[];t?typeof t=="string"?i=this.find(t):i=t:i=this.store.data.pens.filter(function(a){return(a.video||a.audio)&&a.autoPlay}),i.forEach(function(a){var r;a.calculative.media&&(a.calculative.media.currentTime=0,a.calculative.media.pause()),(r=a.onStopVideo)===null||r===void 0||r.call(a,a)})},e.prototype.calcAnimateDuration=function(t){return t.frames.reduce(function(i,a){return i+a.duration},0)},e.prototype.combine=function(t,i){var a=this;if(t===void 0&&(t=this.store.active),!(!t||!t.length)){var r=ce(t);if(t.length===1&&t[0].type){t[0].type=Ye.Node,this.canvas.active(t),this.pushHistory({type:we.Update,initPens:r,pens:ce(t,!0)}),this.render();return}var n=Hi(t),o=jt(jt({id:Me(),name:"combine"},n),{children:[],showChild:i});this.canvas.makePen(o);var s=ce(o),h=1/0;t.forEach(function(l){var c,f=a.store.data.pens.findIndex(function(g){return g.id===l.id});if(f0)},e.prototype.active=function(t,i){i===void 0&&(i=!0),this.canvas.active(t,i)},e.prototype.inactive=function(){this.canvas.inactive()},e.prototype.activeAll=function(){this.canvas.active(this.store.data.pens.filter(function(t){return!t.parentId&&t.locked!==ze.Disable})),this.render()},e.prototype.delete=function(t,i,a){i===void 0&&(i=!1),a===void 0&&(a=!0),this.canvas.delete(t,i,a)},e.prototype.scale=function(t,i){i===void 0&&(i={x:0,y:0}),this.canvas.scale(t,i)},e.prototype.translate=function(t,i){this.canvas.translate(t,i)},e.prototype.translatePens=function(t,i,a){this.canvas.translatePens(t,i,a)},e.prototype.getParent=function(t,i){return ri(t,i)},e.prototype.data=function(){var t=ce(this.store.data),i=this.store.data,a=i.pens,r=i.paths;t.version=Yv.version,t.paths={};var n=function(s){Object.prototype.hasOwnProperty.call(r,s)&&a.find(function(h){return h.pathId===s})&&(t.paths[s]=r[s])};for(var o in r)n(o);return t.dataPoints=bt(bt([],qt(Object.keys(this.store.bind)),!1),qt(Object.keys(this.store.bindDatas)),!1),t},e.prototype.copy=function(t){this.canvas.copy(t)},e.prototype.cut=function(t){this.canvas.cut(t)},e.prototype.paste=function(){this.canvas.paste()},e.prototype.undo=function(){this.canvas.undo()},e.prototype.redo=function(){this.canvas.redo()},e.prototype.listenSocket=function(){try{var t=void 0,i=this.store.data.socketCbJs;if(i&&(t=new Function("e","context",i)),!t)return this.socketFn=null,!1;this.socketFn=t}catch(a){return console.error("Create the function for socket:",a),!1}return!0},e.prototype.connectWebsocket=function(t){var i=this;this.closeWebsocket(),t&&(this.store.data.websocket=t),this.store.data.websocket&&(this.websocket=new WebSocket(this.store.data.websocket,this.store.data.websocketProtocols||void 0),this.websocket.onmessage=function(a){i.socketCallback(a.data,{type:"websocket",url:i.store.data.websocket})},this.websocket.onclose=function(){console.info("Canvas websocket closed and reconneting..."),i.connectWebsocket()})},e.prototype.closeWebsocket=function(){this.websocket&&(this.websocket.onclose=void 0,this.websocket.close(),this.websocket=void 0)},e.prototype.connectMqtt=function(t){var i=this;this.closeMqtt(),t&&(this.store.data.mqtt=t.mqtt,this.store.data.mqttTopics=t.mqttTopics,this.store.data.mqttOptions=t.mqttOptions),this.store.data.mqtt&&(this.store.data.mqttOptions.clientId&&!this.store.data.mqttOptions.customClientId&&(this.store.data.mqttOptions.clientId=Me()),this.mqttClient=Qo.exports.connect(this.store.data.mqtt,this.store.data.mqttOptions),this.mqttClient.on("message",function(a,r){i.socketCallback(r.toString(),{topic:a,type:"mqtt",url:i.store.data.mqtt})}),this.store.data.mqttTopics&&this.mqttClient.subscribe(this.store.data.mqttTopics.split(",")))},e.prototype.closeMqtt=function(){var t;(t=this.mqttClient)===null||t===void 0||t.end()},e.prototype.connectHttp=function(){var t=this;this.closeHttp();var i=this.store.data.https;if(i)this.store.data.cancelFirstConnect||i.forEach(function(s){return Pt(t,void 0,void 0,function(){return It(this,function(h){return this.oldRequestHttp(s),[2]})})}),i.forEach(function(s,h){s.http&&(t.httpTimerList[h]=setInterval(function(){return Pt(t,void 0,void 0,function(){return It(this,function(l){return this.oldRequestHttp(s),[2]})})},s.httpTimeInterval||1e3))});else{var a=this.store.data,r=a.http,n=a.httpTimeInterval,o=a.httpHeaders;r&&(this.httpTimer=setInterval(function(){return Pt(t,void 0,void 0,function(){var s,h;return It(this,function(l){switch(l.label){case 0:return[4,fetch(r,{headers:o})];case 1:return s=l.sent(),s.ok?[4,s.text()]:[3,3];case 2:h=l.sent(),this.socketCallback(h,{type:"http",url:r}),l.label=3;case 3:return[2]}})})},n||1e3))}},e.prototype.oldRequestHttp=function(t){return Pt(this,void 0,void 0,function(){var i,a,r;return It(this,function(n){switch(n.label){case 0:return i=ce(t),i.http?[4,fetch(i.http,{headers:i.httpHeaders,method:i.method||"GET",body:i.method==="POST"?JSON.stringify(i.body):void 0})]:[3,3];case 1:return a=n.sent(),a.ok?[4,a.text()]:[3,3];case 2:r=n.sent(),this.socketCallback(r,{type:"http",url:i.http}),n.label=3;case 3:return[2]}})})},e.prototype.sendDatabyHttp=function(t){return Pt(this,void 0,void 0,function(){var i,a,r,n,o,s=this;return It(this,function(h){switch(h.label){case 0:return i=this.store.data.https,i?(i.forEach(function(l){return Pt(s,void 0,void 0,function(){var c;return It(this,function(f){switch(f.label){case 0:return l.http?[4,fetch(l.http,{method:"post",body:t,headers:l.httpHeaders})]:[3,2];case 1:c=f.sent(),c.ok&&console.info("http\u6D88\u606F\u53D1\u9001\u6210\u529F"),f.label=2;case 2:return[2]}})})}),[3,3]):[3,1];case 1:return a=this.store.data,r=a.http,n=a.httpHeaders,r?[4,fetch(r,{method:"post",body:t,headers:n})]:[3,3];case 2:o=h.sent(),o.ok&&console.info("http\u6D88\u606F\u53D1\u9001\u6210\u529F"),h.label=3;case 3:return[2]}})})},e.prototype.closeHttp=function(){clearInterval(this.httpTimer),this.httpTimer=void 0,this.httpTimerList&&this.httpTimerList.forEach(function(t){clearInterval(t),t=void 0})},e.prototype.connectNetwork=function(){var t=this;this.closeNetwork();var i=this.store.data.networks,a=[];if(i){var r=0;this.mqttClients=[];var n=0;this.websockets=[],i.forEach(function(o){o.type==="subscribe"&&(o.protocol==="mqtt"?(o.options.clientId&&!o.options.customClientId&&(o.options.clientId=Me()),t.mqttClients[r]=Qo.exports.connect(o.url,o.options),t.mqttClients[r].on("message",function(s,h){t.socketCallback(h.toString(),{topic:s,type:"mqtt",url:o.url})}),o.topics&&t.mqttClients[r].subscribe(o.topics.split(",")),r+=1):o.protocol==="websocket"?(t.websockets[n]=new WebSocket(o.url,o.protocols||void 0),t.websockets[n].onmessage=function(s){t.socketCallback(s.data,{type:"websocket",url:o.url})},n+=1):o.protocol==="http"&&a.push({url:o.url,interval:o.interval,headers:o.headers||void 0,method:o.method,body:o.body}))})}this.onNetworkConnect(a)},e.prototype.randomString=function(t){t=t||32;for(var i="ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678",a=i.length,r="",n=0;n":c=v>+f;break;case">=":c=v>=+f;break;case"<":c=v<+f;break;case"<=":c=v<=+f;break;case"=":case"==":c=v==f;break;case"!=":c=v!=f;break;case"[)":c=Mo(+v,f);break;case"![)":c=!Mo(+v,f);break;case"[]":c=Bo(v,f);break;case"![]":c=!Bo(v,f);break}}return c},e.prototype.pushChildren=function(t,i){var a=this,r=[ce(t,!0)],n=[];t.children||(t.children=[]);var o=[];i.forEach(function(h){var l,c=ce(h,!0);if((!h.id||!a.store.pens[h.id])&&(a.canvas.makePen(h),c=null),h.parentId){var f=a.store.pens[h.parentId],v=f.children.findIndex(function(y){return y===h.id});r.push(ce(f,!0)),f.children.splice(v,1),o.push(ce(f,!0))}t.children.push(h.id),h.parentId=t.id;var g=Xo(h.calculative.worldRect,t.calculative.worldRect);Object.assign(h,g),h.locked=(l=h.lockedOnCombine)!==null&&l!==void 0?l:ze.DisableMove,c?(r.push(c),o.push(ce(h,!0))):n.push(ce(h,!0))}),o.push(ce(t,!0));var s=1;n.length&&(s=2,this.pushHistory({type:we.Add,pens:n,step:s})),this.pushHistory({type:we.Update,initPens:r,pens:o,step:s})},e.prototype.toPng=function(t,i,a,r){return a===void 0&&(a=!1),this.canvas.toPng(t,i,a,r)},e.prototype.activeToPng=function(t){return this.canvas.activeToPng(t)},e.prototype.pensToPng=function(t,i){return t===void 0&&(t=this.store.active),this.canvas.pensToPng(t,i)},e.prototype.downloadPng=function(t,i,a){var r,n,o=this,s;try{for(var h=wt(this.store.data.pens),l=h.next();!l.done;l=h.next()){var c=l.value;(c.calculative.img||["iframe"].includes(c.name))&&((s=c.onRenderPenRaw)===null||s===void 0||s.call(c,c))}}catch(f){r={error:f}}finally{try{l&&!l.done&&(n=h.return)&&n.call(h)}finally{if(r)throw r.error}}setTimeout(function(){var f=document.createElement("a");f.setAttribute("download",(t||o.store.data.name||"le5le.meta2d")+".png"),f.setAttribute("href",o.toPng(i,void 0,!0,a));var v=document.createEvent("MouseEvents");v.initEvent("click",!0,!0),f.dispatchEvent(v)},1e3)},e.prototype.downloadSvg=function(){var t,i;if(!window.C2S)throw console.error("\u8BF7\u5148\u52A0\u8F7D\u4E50\u543E\u4E50\u5B98\u7F51\u4E0B\u7684canvas2svg.js","https://assets.le5lecdn.com/2d/canvas2svg.js"),new Error("\u8BF7\u5148\u52A0\u8F7D\u4E50\u543E\u4E50\u5B98\u7F51\u4E0B\u7684canvas2svg.js");var a=this.getRect();a.x-=10,a.y-=10;var r=new window.C2S(a.width+20,a.height+20);r.textBaseline="middle";try{for(var n=wt(this.store.data.pens),o=n.next();!o.done;o=n.next()){var s=o.value;s.visible==!1||!hs(s,this.store)||cs(r,s,a,!0)}}catch(y){t={error:y}}finally{try{o&&!o.done&&(i=n.return)&&i.call(n)}finally{if(t)throw t.error}}var h=r.getSerializedSvg();this.store.data.background?(h=h.replace("{{bk}}",""),h=h.replace("{{bkRect}}",'')):(h=h.replace("{{bk}}",""),h=h.replace("{{bkRect}}","")),h=h.replace(/--le5le--/g,"&#x");var l=window.URL,c=new Blob([h]),f=l.createObjectURL(c),v=document.createElement("a");v.setAttribute("download",(this.store.data.name||"le5le.meta2d")+".svg"),v.setAttribute("href",f);var g=document.createEvent("MouseEvents");g.initEvent("click",!0,!0),v.dispatchEvent(g)},e.prototype.getRect=function(t){return t===void 0&&(t=this.store.data.pens),Hi(t)},e.prototype.hiddenTemplate=function(){this.canvas.canvasTemplate.hidden()},e.prototype.showTemplate=function(){this.canvas.canvasTemplate.show()},e.prototype.lockTemplate=function(t){this.store.data.pens.forEach(function(i){i.canvasLayer===Ne.CanvasTemplate&&(i.locked=t)})},e.prototype.fitView=function(t,i){if(t===void 0&&(t=!0),i===void 0&&(i=10),!!this.hasView()){var a=this.canvas.canvas,r=a.offsetWidth,n=a.offsetHeight;this.resize(r,n);var o=ar(i),s=this.getRect(),h=(r-o[1]-o[3])/s.width,l=(n-o[0]-o[2])/s.height,c=h;t?c=h>l?l:h:c=h>l?h:l,this.scale(c*this.store.data.scale),this.centerView()}},e.prototype.trimPens=function(){var t=this.store.data.pens.filter(function(i){return i.name==="line"&&i.anchors.length<2});this.delete(t)},e.prototype.fitTemplateView=function(t,i){var a=this;if(t===void 0&&(t=!0),i===void 0&&(i=10),!!this.hasView()){var r=this.canvas.canvas,n=r.offsetWidth,o=r.offsetHeight,s=ar(i),h=this.getRect(),l=(n-s[1]-s[3])/h.width,c=(o-s[0]-s[2])/h.height,f=l;t?f=l>c?c:l:f=l>c?l:c,this.canvas.templateScale(f*this.store.data.scale);var v=this.getRect(),g=this.store.data.pens.filter(function(y){return!y.parentId});this.canvas.templateTranslatePens(g,-v.x,-v.y),this.store.data.pens.forEach(function(y){y.type?a.canvas.initLineRect(y):a.canvas.updateLines(y)}),this.centerView()}},e.prototype.fitSizeView=function(t,i){t===void 0&&(t=!0),i===void 0&&(i=10);var a=this.canvas.canvas,r=a.offsetWidth,n=a.offsetHeight;this.resize(r,n);var o=ar(i),s=(this.store.data.width||this.store.options.width)*this.store.data.scale,h=(this.store.data.height||this.store.options.height)*this.store.data.scale,l=(r-o[1]-o[3])/s,c=(n-o[0]-o[2])/h,f=l;t==="width"?f=l:t==="height"?f=c:t?f=l>c?c:l:f=l>c?l:c,this.scale(f*this.store.data.scale),this.centerSizeView()},e.prototype.centerSizeView=function(){var t=this.getViewCenter(),i=this.store.data.width||this.store.options.width,a=this.store.data.height||this.store.options.height,r={x:0,y:0,width:i,height:a};tt(r);var n=r.center,o=this.store.data,s=o.scale,h=o.origin,l=o.x,c=o.y;this.translate((t.x-h.x)/s-n.x-l/s,(t.y-h.y)/s-n.y-c/s);var f=this.canvas.canvas,v=(f.scrollWidth-f.offsetWidth)/2,g=(f.scrollHeight-f.offsetHeight)/2;f.scrollTo(v,g)},e.prototype.scrollView=function(t,i){if(t===void 0&&(t=10),i===void 0&&(i=!1),!!this.hasView()&&!!this.canvas.scroll){var a=this.canvas.canvas,r=a.offsetWidth,n=a.offsetHeight;this.resize(r,n);var o=ar(t),s=this.getRect(),h=(r-o[1]-o[3])/s.width;this.scale(h*this.store.data.scale),this.topView(o[0]),i&&this.canvas.scroll.changeMode()}},e.prototype.screenView=function(t,i){if(t===void 0&&(t=10),i===void 0&&(i=!0),!!this.hasView()){var a=this.canvas.canvas,r=a.offsetWidth,n=a.offsetHeight;this.resize(r,n);var o=ar(t),s=this.getRect(),h=(r-o[1]-o[3])/s.width;i||(h=(n-o[0]-o[2])/s.height),this.scale(h*this.store.data.scale),this.topView(o[0])}},e.prototype.topView=function(t){if(t===void 0&&(t=10),!!this.hasView()){var i=this.getRect(),a=this.getViewCenter(),r=this.getPenRect(i);tt(r);var n=r.center,o=this.store.data,s=o.scale,h=o.origin,l=o.x,c=o.y;this.translate((a.x-h.x)/s-n.x-l/s,(t-h.y)/s-r.y-c/s);var f=this.canvas.canvas,v=(f.scrollWidth-f.offsetWidth)/2,g=(f.scrollHeight-f.offsetHeight)/2;f.scrollTo(v,g)}},e.prototype.centerView=function(){if(!!this.hasView()){var t=this.getRect(),i=this.getViewCenter(),a=this.getPenRect(t);tt(a);var r=a.center,n=this.store.data,o=n.scale,s=n.origin,h=n.x,l=n.y;this.translate((i.x-s.x)/o-r.x-h/o,(i.y-s.y)/o-r.y-l/o);var c=this.canvas.canvas,f=(c.scrollWidth-c.offsetWidth)/2,v=(c.scrollHeight-c.offsetHeight)/2;c.scrollTo(f,v)}},e.prototype.hasView=function(){return!!this.store.data.pens.filter(function(t){return!t.isRuleLine}).length},e.prototype.getViewCenter=function(){var t=this.canvas,i=t.width,a=t.height;return{x:i/2,y:a/2}},e.prototype.beSameByFirst=function(t,i){t===void 0&&(t=this.store.data.pens);for(var a=ce(t),r=t[0],n=this.getPenRect(r),o=n.width,s=n.height,h=1;h0){var r=i[0];hn.forEach(function(o){a[o]=r[o]||t.store.options.defaultFormat[o]||t.store.options[o]})}else{var n={};hn.forEach(function(o){n[o]=t.store.options.defaultFormat[o]||t.store.options[o]||void 0})}localStorage.setItem("meta2d-formatPainter",JSON.stringify(a))},e.prototype.formatPainter=function(){for(var t=this.store.active,i=ce(t),a=JSON.parse(localStorage.getItem("meta2d-formatPainter")),r=0;rs&&(s=f.height)});var h=n.x,l=n.y;t.forEach(function(c,f){var v=r.getPenRect(c);if(v.x=h,v.y=l+s/2-v.height/2,r.setValue(jt({id:c.id},v),{render:!1,doEvent:!1}),f!==t.length-1){var g=h+v.width-n.x,y=r.getPenRect(t[f+1]);Math.round(i-g)>=Math.round(y.width+a)?h+=v.width+a:(h=n.x,l+=s+a)}}),this.initImageCanvas(t),this.initTemplateCanvas(t),this.render(),this.pushHistory({type:we.Update,initPens:o,pens:t})},e.prototype.gotoView=function(t){var i=this.getViewCenter(),a=i.x-t.calculative.worldRect.x-t.calculative.worldRect.width/2,r=i.y-t.calculative.worldRect.y-t.calculative.worldRect.height/2;this.canvas.scroll&&this.canvas.scroll.isShow&&this.canvas.scroll.translate(a-this.store.data.x,r-this.store.data.y),this.store.data.x=a,this.store.data.y=r,this.canvas.canvasImage.init(),this.canvas.canvasImageBottom.init(),this.render()},e.prototype.showMap=function(){this.map||(this.map=new Dk(this.canvas)),this.map.show()},e.prototype.hideMap=function(){this.map.hide()},e.prototype.onSizeUpdate=function(){var t=this;this.mapTimer&&(clearTimeout(this.mapTimer),this.mapTimer=void 0),this.mapTimer=setTimeout(function(){t.map&&t.map.isShow&&t.map.show(),t.canvas.scroll&&t.canvas.scroll.isShow&&t.canvas.scroll.resize()},500)},e.prototype.toggleAnchorMode=function(){this.canvas.toggleAnchorMode()},e.prototype.addAnchorHand=function(){this.canvas.addAnchorHand()},e.prototype.removeAnchorHand=function(){this.canvas.removeAnchorHand()},e.prototype.toggleAnchorHand=function(){this.canvas.toggleAnchorHand()},e.prototype.top=function(t){var i,a,r=this;t||(t=this.store.active),Array.isArray(t)||(t=[t]);var n=function(c){var f=o.store.data.pens,v=bt(bt([],qt(Er(c,o.store)),!1),[c],!1).map(function(y){return y.id}),g=f.filter(function(y){return v.includes(y.id)});g.forEach(function(y){var p=f.findIndex(function(m){return m.id===y.id});p>-1&&(f.push(f[p]),f.splice(p,1),r.initTemplateCanvas([y]),r.initImageCanvas([y])),r.specificLayerMove(y,"top")})},o=this;try{for(var s=wt(t),h=s.next();!h.done;h=s.next()){var l=h.value;n(l)}}catch(c){i={error:c}}finally{try{h&&!h.done&&(a=s.return)&&a.call(s)}finally{if(i)throw i.error}}this.store.emitter.emit("layer",{type:"top",pens:t})},e.prototype.initImageCanvas=function(t){this.canvas.initImageCanvas(t)},e.prototype.initTemplateCanvas=function(t){this.canvas.initTemplateCanvas(t)},e.prototype.bottom=function(t){var i,a;t||(t=this.store.active),Array.isArray(t)||(t=[t]);var r=function(l){for(var c=n.store.data.pens,f=bt(bt([],qt(Er(l,n.store)),!1),[l],!1).map(function(p){return p.id}),v=c.filter(function(p){return f.includes(p.id)}),g=function(p){var m=v[p],b=c.findIndex(function(x){return x.id===m.id});b>-1&&(c.unshift(c[b]),c.splice(b+1,1),n.initTemplateCanvas([m]),n.initImageCanvas([m])),n.specificLayerMove(m,"bottom")},y=v.length-1;y>=0;y--)g(y)},n=this;try{for(var o=wt(t),s=o.next();!s.done;s=o.next()){var h=s.value;r(h)}}catch(l){i={error:l}}finally{try{s&&!s.done&&(a=o.return)&&a.call(o)}finally{if(i)throw i.error}}this.store.emitter.emit("layer",{type:"bottom",pens:t})},e.prototype.upByArea=function(t){var i,a,r,n=this,o=this.store.data.pens.findIndex(function(b){return b.id===t.id});if(o===-1){console.warn("upByArea: pen not in canvas");return}var s=bt([t],qt(Er(t,this.store)),!1),h=s.map(function(b){return n.store.data.pens.findIndex(function(x){return x.id===b.id})});h.includes(-1)&&(console.warn("upByArea: pen children not in canvas"),h=h.filter(function(b){return b!==-1}));var l=Math.min.apply(Math,bt([],qt(h),!1)),c=t.calculative.worldRect,f=this.store.data.pens.findIndex(function(b,x){if(x<=l||b.id===t.id||g2(b,t))return!1;var _=b.calculative.worldRect;return fs(c,_)});if(f===-1){this.up(t);return}(i=this.store.data.pens).splice.apply(i,bt([f+1,0],qt(s),!1));var v=function(b){var x=g.store.data.pens.findIndex(function(_){return _.id===b.id});x>-1&&g.store.data.pens.splice(x,1)},g=this;try{for(var y=wt(s),p=y.next();!p.done;p=y.next()){var m=p.value;v(m)}}catch(b){a={error:b}}finally{try{p&&!p.done&&(r=y.return)&&r.call(y)}finally{if(a)throw a.error}}this.initImageCanvas([t])},e.prototype.specificLayerMove=function(t,i){var a;if(t.image&&t.name!=="gif"){var r=Ne.CanvasImageBottom;i==="top"?r=Ne.CanvasImage:(i==="up"||i==="down")&&(r=Ne.CanvasMain),this.setValue({id:t.id,canvasLayer:r},{render:!1,doEvent:!1,history:!1})}else if(t.externElement||t.name==="gif"){var n=1;i==="top"?(t.calculative.canvas.maxZindex+=1,n=t.calculative.canvas.maxZindex):i==="up"?n=t.calculative.zIndex===void 0?6:t.calculative.zIndex+1:i==="down"&&(n=t.calculative.zIndex===void 0?3:t.calculative.zIndex-1,n<1&&(n=1)),this.setValue({id:t.id,zIndex:n},{render:!1,doEvent:!1,history:!1}),!((a=t.calculative.singleton)===null||a===void 0)&&a.div&&Ai(t,t.calculative.singleton.div)}},e.prototype.up=function(t){var i,a,r=this;t||(t=this.store.active),Array.isArray(t)||(t=[t]);var n=function(c){var f=o.store.data.pens;if(c.children&&c.children.length){for(var v=bt(bt([],qt(Er(c,o.store)),!1),[c],!1),g=[],y=function(x){var _=f[x];v.findIndex(function(k){return k.id===_.id})!==-1&&(_.temIndex=x,g.push(_))},p=0;p-1&&p!==f.length-1&&(f.splice(p+2,0,f[p]),f.splice(p,1),o.initTemplateCanvas([c]),o.initImageCanvas([c])),o.specificLayerMove(c,"up")}},o=this;try{for(var s=wt(t),h=s.next();!h.done;h=s.next()){var l=h.value;n(l)}}catch(c){i={error:c}}finally{try{h&&!h.done&&(a=s.return)&&a.call(s)}finally{if(i)throw i.error}}this.store.emitter.emit("layer",{type:"up",pens:t})},e.prototype.down=function(t){var i,a,r=this;t||(t=this.store.active),Array.isArray(t)||(t=[t]);var n=function(c){var f=o.store.data.pens;if(c.children&&c.children.length){for(var v=bt(bt([],qt(Er(c,o.store)),!1),[c],!1),g=[],y=function(x){var _=f[x];v.findIndex(function(k){return k.id===_.id})!==-1&&(_.temIndex=x,g.push(_))},p=0;p-1&&p!==0&&(f.splice(p-1,0,f[p]),f.splice(p+1,1),o.initTemplateCanvas([c]),o.initImageCanvas([c])),o.specificLayerMove(c,"down")}},o=this;try{for(var s=wt(t),h=s.next();!h.done;h=s.next()){var l=h.value;n(l)}}catch(c){i={error:c}}finally{try{h&&!h.done&&(a=s.return)&&a.call(s)}finally{if(i)throw i.error}}this.store.emitter.emit("layer",{type:"down",pens:t})},e.prototype.setLayer=function(t,i,a){a===void 0&&(a=this.store.data.pens);var r=a.findIndex(function(n){return n.id===t.id});r>-1&&(r>i?(a.splice(i,0,a[r]),a.splice(r+1,1)):rt.anchors.length&&(a=t.anchors.length),a<0&&(a=0),a==0&&t.anchors[0].connectTo||a==t.anchors.length&&t.anchors[a-1].connectTo)){console.warn("\u7AEF\u70B9\u5B58\u5728\u8FDE\u63A5\u5173\u7CFB");return}var r=null,n=null;i.x<=1&&i.x>=0&&i.y<=1&&i.y>=0?(n={id:i.id||Me(),penId:t.id,x:t.calculative.worldRect.x+t.calculative.worldRect.width*i.x,y:t.calculative.worldRect.y+t.calculative.worldRect.height*i.y},t.calculative.worldRect&&t.rotate%360&&Ge(n,t.rotate,t.calculative.worldRect.center),r={id:n.id,penId:t.id,x:i.x,y:i.y}):(n={id:i.id||Me(),penId:t.id,x:i.x,y:i.y},t.calculative.worldRect&&(t.rotate%360&&Ge(i,-t.rotate,t.calculative.worldRect.center),r={id:n.id,penId:t.id,x:(i.x-t.calculative.worldRect.x)/t.calculative.worldRect.width,y:(i.y-t.calculative.worldRect.y)/t.calculative.worldRect.height})),t.type===Ye.Line?(t.calculative.worldAnchors.splice(a,0,n),t.anchors.splice(a,0,r),this.canvas.updateLines(t),this.canvas.initLineRect(t),this.render()):(t.calculative.worldAnchors.push(n),t.anchors.push(r))}},e.prototype.connectLine=function(t,i,a,r,n){if(n===void 0&&(n=!0),!a){var o=i.calculative.worldRect;a=Ma(t,{x:o.x+o.width/2,y:o.y+o.height/2})}if(!r){var o=t.calculative.worldRect;r=Ma(i,{x:o.x+o.width/2,y:o.y+o.height/2})}var s=Math.abs(a.x-r.x),h=Math.abs(a.y-r.y),l={height:h,lineName:"line",lineWidth:1,name:"line",type:1,width:s,x:Math.min(a.x,r.x),y:Math.min(a.y,r.y),anchors:[{x:a.x>r.x?1:0,y:a.y>r.y?1:0,id:Me()},{x:a.x>r.x?0:1,y:a.x>r.x?0:1,id:Me()}]};return this.addPens([l]),_t(t,a,l,l.calculative.worldAnchors[0]),_t(i,r,l,l.calculative.worldAnchors[1]),l.calculative.active=!1,this.canvas.updateLines(l),this.canvas.updateLines(t),this.canvas.updateLines(i),this.canvas.initLineRect(l),n&&this.render(),l},e.prototype.toComponent=function(t,i,a){if(t===void 0&&(t=this.store.data.pens),t.length===1){var r=ce(t[0]);return r.type=Ye.Node,r.id=void 0,[r]}var n=ce(t,!0),o=Hi(n),s=jt(jt({id:Me(),name:"combine"},o),{children:[],showChild:i});a&&(s.anchors=[{id:"0",penId:s.id,x:.5,y:0},{id:"1",penId:s.id,x:1,y:.5},{id:"2",penId:s.id,x:.5,y:1},{id:"3",penId:s.id,x:0,y:.5}]);var h=n.filter(function(f){return!f.parentId}),l=n.find(function(f){return f.width===o.width&&f.height===o.height}),c=l&&i===void 0;return h.length===1?s=h[0]:c&&(l.children||(l.children=[]),s=l),n.forEach(function(f){var v;if(!(f===s||f.parentId===s.id)&&!f.parentId){s.children.push(f.id),f.parentId=s.id;var g=Xo(f.calculative.worldRect,o);Object.assign(f,g),f.locked=(v=f.lockedOnCombine)!==null&&v!==void 0?v:ze.DisableMove}}),c||h.length===1?ce(n):ce(bt([s],qt(n),!1))},e.prototype.installPenPlugins=function(t,i){var a=this;if(!(!t.tag&&!t.name&&!t.id)){var r;t.id?r="id":t.tag?r="tag":t.name&&(r="name"),i.forEach(function(n){var o,s,h=n.plugin,l=n.options;if(!!h&&X2(h)&&r)if(h.install(t,l),!a.penPluginMap.has(h))a.penPluginMap.set(h,[(o={},o[r]=t[r],o.option=l,o)]);else{var c=a.penPluginMap.get(h).find(function(f){return f[r]===t[r]});c?c.option=l:a.penPluginMap.get(h).push((s={},s[r]=t[r],s.option=l,s))}})}},e.prototype.uninstallPenPlugins=function(t,i){var a=this,r;t.id?r="id":t.tag?r="tag":t.name&&(r="name"),r&&i.forEach(function(n){var o=n.plugin;o.uninstall(t,n.options);var s=a.penPluginMap.get(o),h=s.findIndex(function(l){return l[r]===t[r]});h!==-1&&(s.splice(h,1),s.length===0&&a.penPluginMap.delete(o))})},e.prototype.setVisible=function(t,i,a){var r,n;if(a===void 0&&(a=!0),this.onSizeUpdate(),this.setValue({id:t.id,visible:i},{render:!1,doEvent:!1}),t.children)try{for(var o=wt(t.children),s=o.next();!s.done;s=o.next()){var h=s.value,l=this.store.pens[h];l&&this.setVisible(l,i,!1)}}catch(f){r={error:f}}finally{try{s&&!s.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}var c=Er(t,this.store);this.initImageCanvas(c),a&&this.render()},e.prototype.clearHover=function(){this.canvas.clearHover()},e.prototype.closeSocket=function(){this.closeWebsocket(),this.closeMqtt(),this.closeHttp()},e.prototype.destroy=function(t){if(this.clear(!1),this.closeSocket(),this.closeNetwork(),this.store.emitter.all.clear(),this.canvas.destroy(),this.canvas=void 0,ke[this.store.id]=void 0,!t){for(var i in ke)delete ke[i];ke.path2dDraws={},ke.canvasDraws={},ke.anchors={},ke.htmlElements={}}},e}();function Mk(e,t){var i=t||new Path2D,a=e.calculative.worldRect,r=a.x,n=a.y,o=a.width,s=a.ey,h=o/4;if(i.moveTo(r+h,n),i.lineTo(r,n),i.lineTo(r,s),i.lineTo(r+h,s),i instanceof Path2D)return i}function Bk(e,t){var i=t||new Path2D,a=e.calculative.worldRect,r=a.x,n=a.y,o=a.width,s=a.ex,h=a.ey,l=e.offsetX,c=o/7;if(l>1?c=l:l>0&&(c=o*l),i.moveTo(r+c,n),i.lineTo(s,n),i.lineTo(r+o-c,h),i.lineTo(r,h),i.closePath(),i instanceof Path2D)return i}function Ok(e,t){var i=t||new Path2D,a=e.calculative.worldRect,r=a.x,n=a.y,o=a.width,s=a.height,h=a.ex,l=a.ey,c=o/8;if(i.moveTo(r+c,n),i.lineTo(h-c,n),i.bezierCurveTo(h+c/3,n,h+c/3,l,h-c,l),i.lineTo(r+c,l),i.lineTo(r,n+s/2),i.closePath(),i instanceof Path2D)return i}function Nk(e,t){var i=t||new Path2D,a=e.calculative.worldRect,r=a.x,n=a.y,o=a.width,s=a.height,h=a.ex,l=a.center,c=l.x,f=n+s*6/7,v=s/6;if(i.moveTo(r,n),i.lineTo(h,n),i.lineTo(h,f),i.bezierCurveTo(h-20,f-v,c+o/5,f-v,c,f),i.bezierCurveTo(c-o/5,f+v,r,f+v,r,f),i.closePath(),i instanceof Path2D)return i}function Fk(e,t){var i=t||new Path2D,a=e.calculative.worldRect,r=a.x,n=a.y,o=a.width,s=a.ex,h=a.ey,l=o/10;if(i.moveTo(r+l*2,n),i.bezierCurveTo(r-l*2/3,n,r-l*2/3,h,r+l*2,h),i.lineTo(s,h),i.bezierCurveTo(s-l,h,s-l,n,s,n),i.closePath(),i instanceof Path2D)return i}function zk(e,t){var i=t||new Path2D,a=e.calculative.worldRect,r=a.x,n=a.y,o=a.width,s=a.ex,h=a.ey;i.moveTo(r,n),i.lineTo(s,n),i.lineTo(s,h),i.lineTo(r,h),i.closePath();var l=o/7;if(i.moveTo(r,n+l),i.lineTo(s,n+l),i.moveTo(r+l,n),i.lineTo(r+l,h),i instanceof Path2D)return i}function Hk(e,t){var i=t||new Path2D,a=e.calculative.worldRect,r=a.x,n=a.y,o=a.height,s=a.ex,h=a.ey,l=o/4;if(i.moveTo(r,n+l),i.lineTo(s,n),i.lineTo(s,h),i.lineTo(r,h),i.closePath(),i instanceof Path2D)return i}function Uk(e,t){var i=t||new Path2D,a=e.calculative.worldRect,r=a.x,n=a.y,o=a.ex,s=a.ey;if(i.moveTo(r,n),i.lineTo(o,n),i.moveTo(r,s),i.lineTo(o,s),i instanceof Path2D)return i}function Wk(e,t){var i=t||new Path2D,a=e.calculative.worldRect,r=a.x,n=a.y,o=a.width,s=a.height,h=a.ex,l=a.ey;if(i.ellipse(r+o/2,n+s/2,o/2,s/2,0,0,Math.PI*2),i.moveTo(r+o/2,l),i.lineTo(h,l),i.closePath(),i instanceof Path2D)return i}function qk(e,t){var i=t||new Path2D,a=e.calculative.worldRect,r=a.x,n=a.y,o=a.width,s=a.ex,h=a.ey,l=o/7;if(i.moveTo(r,n),i.lineTo(s,n),i.lineTo(s,h),i.lineTo(r,h),i.closePath(),i.moveTo(r+l,n),i.lineTo(r+l,h),i.moveTo(s-l,n),i.lineTo(s-l,h),i instanceof Path2D)return i}function jk(e,t){var i=t||new Path2D,a=e.calculative.worldRect,r=a.x,n=a.y,o=a.height,s=a.ex,h=a.ey,l=o/7;if(i.moveTo(r,n+l),i.bezierCurveTo(r,n-l/2|0,s,n-l/2|0,s,n+l),i.lineTo(s,h-l),i.bezierCurveTo(s,h+l/2|0,r,h+l/2|0,r,h-l),i.closePath(),i.moveTo(r,h-l),i.bezierCurveTo(r,h-l*2|0,s,h-l*2|0,s,h-l),i instanceof Path2D)return i}function DT(){return{flowComment:Mk,flowData:Bk,flowDb:jk,flowDisplay:Ok,flowDocument:Nk,flowExternStorage:Fk,flowInternalStorage:zk,flowManually:Hk,flowParallel:Uk,flowQueue:Wk,flowSubprocess:qk}}globalThis&&globalThis.__values;var gs;(function(e){e[e.Add=0]="Add",e[e.Replace=1]="Replace",e[e.ReplaceAll=2]="ReplaceAll"})(gs||(gs={}));function Rg(e,t){var i=t.calculative.worldRect.height*14/16,a=e.match(/[\u4e00-\u9fa5]/g)||"",r=a.length,n=(e.length-r)*i*.6+r*i;return n}function Pg(e){if(e.direction=="horizontal"){var t=[],i=0,a=e.height;e.checkboxHeight=a,e.options.forEach(function(s,h){t.push(h*(40+a)+i),i+=Rg(s.text,e)}),e.optionPos=t;var r=t.length*(40+a)+i;e.checkboxWidth=r,e.width=r,e.calculative.width=r,e.calculative.worldRect={x:e.x,y:e.y,height:e.height,width:e.width,center:{x:e.x+e.width/2,y:e.y+e.height/2}},ot(e.calculative.worldRect)}else if(e.direction=="vertical"){e.optionInterval==null&&(e.optionInterval=20),e.optionHeight||(e.optionHeight=20);var n=[];e.options.forEach(function(s,h){n.push(h*(e.optionInterval+e.optionHeight))}),e.optionPos=n;var o=n[n.length-1]+e.optionHeight;e.checkboxHeight=o,e.width||(e.height=o,e.calculative.height=o,e.calculative.worldRect={x:e.x,y:e.y,height:e.height,width:e.width,center:{x:e.x+e.width/2,y:e.y+e.height/2}},ot(e.calculative.worldRect))}}globalThis&&globalThis.__values;function Kk(e,t){t.onClick||(t.onClick=Vk);var i=t.calculative.worldRect.x,a=t.calculative.worldRect.y,r=t.calculative.worldRect.width,n=t.calculative.worldRect.height;r2?n/2-2:1,0,Math.PI*2),e.fill()):(e.fillStyle=t.offColor,(t.disabled||t.disable)&&(e.fillStyle=t.disableOffColor||Ft(.6,t.offColor)),e.fill(),e.closePath(),e.beginPath(),e.fillStyle="#ffffff",e.moveTo(i+n,a+n/2),e.arc(i+n/2,a+n/2,n/2>2?n/2-2:1,0,Math.PI*2),e.fill()),e.closePath()}function Vk(e){e.disabled||e.disable||(e.checked=!e.checked,e.calculative.canvas.store.emitter.emit("valueUpdate",e),e.calculative.canvas.render())}function $k(e,t){t.onAdd||(t.onAdd=mn,t.onResize=mn,t.onMove=mn,t.onMouseMove=Yk,t.onMouseDown=Ig,t.onValue=Gk,t.onBeforeValue=Xk),t.calculative.barRect||mn(t),t.calculative.canvas.store.data;var i=t.calculative.canvas.store.options,a=t.background;t.disabled&&(a=t.disabledBackground||Ft(.6,a)),e.fillStyle=a,e.beginPath();var r=t.calculative.worldRect.x+t.calculative.barRect.x,n=t.calculative.worldRect.y+t.calculative.barRect.y,o=t.calculative.barRect.width,s=t.calculative.barRect.height,h=s/2;e.moveTo(r+h,n),e.arcTo(r+o,n,r+o,n+s,h),e.arcTo(r+o,n+s,r,n+s,h),e.arcTo(r,n+s,t.x,t.y,h),e.arcTo(r,n,r+o,n,h),e.fill();var l=t.activeColor||i.activeColor;t.disabled&&(l=t.disabledColor||Ft(.6,l)),e.fillStyle=l,e.beginPath(),o=t.calculative.ballRect.x,e.moveTo(r+h,n),e.arcTo(r+o,n,r+o,n+s,h),e.arcTo(r+o,n+s,r,n+s,h),e.arcTo(r,n+s,t.x,t.y,h),e.arcTo(r,n,r+o,n,h),e.fill(),e.fillStyle=t.btnBackground||"#fff",e.strokeStyle=l,e.lineWidth=2,e.beginPath(),r=t.calculative.worldRect.x+t.calculative.ballRect.x,n=t.calculative.worldRect.y+t.calculative.ballRect.y+t.calculative.ballRect.height/2,e.lineWidth=t.calculative.ballRect.width/10,e.arc(r,n,t.calculative.ballRect.width/2,0,Math.PI*2),e.fill(),e.stroke()}function mn(e){if(e._textWidth||(e._textWidth=e.textWidth||50,e._fontSize=e.fontSize||12),e.textWidth=e.calculative.worldRect.width,e.calculative.textWidth=e.textWidth,e.unit||(e.unit="%"),e.sliderWidth||(e.sliderWidth=e.width),e.sliderHeight||(e.sliderHeight=e.height),!!e.calculative.worldRect){var t=e.calculative.worldRect.width/e.sliderWidth,i=e.calculative.worldRect.height/e.sliderHeight,a=Math.min(t,i);e.fontSize=e._fontSize*a;var r=e.calculative.worldRect.width-e._textWidth*a;e.textLeft=r+10*a,e.calculative.textLeft=e.textLeft,e.calculative.barRect={x:0,y:(e.calculative.worldRect.height-e.barHeight*i)/2,width:r,height:e.barHeight*i},ot(e.calculative.barRect),cu(e)}}function cu(e){var t=e.calculative.barRect.height*3.5,i=e.calculative.barRect.width*e.value/100;e.calculative.ballRect={x:i,y:(e.calculative.worldRect.height-t)/2,width:t,height:t},ot(e.calculative.ballRect),e.calculative.text=e.value+e.unit,Ni(e)}function Ig(e,t){if(!e.disabled){var i=t.x-e.calculative.worldRect.x;if(!(i>e.calculative.barRect.width)){var a=Math.round(i/e.calculative.barRect.width*100);ae.max||a<0||a>100||(e.value=a,cu(e),e.calculative.text=e.value+e.unit,Ni(e),e.calculative.canvas.store.emitter.emit("valueUpdate",e),e.calculative.canvas.render())}}}function Yk(e,t){e.calculative.canvas.mouseDown&&Ig(e,t)}function Gk(e){e.calculative.isUpdateData&&(delete e.calculative.isUpdateData,mn(e)),cu(e)}function Xk(e,t){return e.calculative.isUpdateData=!1,(t.textWidth||t.barHeight)&&(t.textWidth&&(e._textWidth=0),e.calculative.isUpdateData=!0),t}function Zk(e,t){t.onMouseDown||(t.onMouseDown=Qk);var i=t.calculative.worldRect.x,a=t.calculative.worldRect.y,r=t.calculative.worldRect.height;t.calculative.worldRect.width;var n=t.calculative,o=n.fontStyle,s=n.fontWeight,h=n.fontSize,l=n.fontFamily,c=n.lineHeight,f=2;e.beginPath(),e.moveTo(i,a),e.arcTo(i+r,a,i+r,a+r,f),e.arcTo(i+r,a+r,i,a+r,f),e.arcTo(i,a+r,i,a,f),e.arcTo(i,a,i+r,a,f),e.strokeStyle="#d9d9d9",e.fillStyle="#ffffff00",t.checked&&(e.fillStyle=t.background||"#1890ff",e.strokeStyle=t.background||"#1890ff"),(t.isForbidden||t.disabled)&&(e.fillStyle=t.disabledBackground||Ft(.6,t.background)||"#ebebeb",e.strokeStyle=t.disabledColor||Ft(.6,t.color)||"#d9d9d9"),e.closePath(),e.fill(),e.stroke(),e.save(),t.checked&&(e.beginPath(),e.lineWidth=r/10,e.strokeStyle="#ffffff",e.moveTo(i+102/506*r,a+r/2),e.lineTo(i+220/506*r,a+346/460*r),e.lineTo(i+404/506*r,a+142/460*r),e.stroke()),e.restore(),e.save(),e.fillStyle=t.disabled||t.isForbidden?t.disabledTextColor||Ft(.6,t.textColor||t.color)||"#00000040":Ir(t,t.calculative.canvas.parent.store)||"#000000d9",e.textAlign="start",e.textBaseline="middle",e.font=Lr({fontStyle:o,fontWeight:s,fontFamily:l||t.calculative.canvas.parent.store.options.fontFamily,fontSize:h,lineHeight:c}),e.fillText(t.value+"",i+r+10,a+r/2),e.restore()}function Qk(e,t){e.isForbidden||(e.checked=!e.checked,e.calculative.canvas.store.emitter.emit("valueUpdate",e),e.calculative.canvas.render())}function Jk(e,t){t.onAdd||(t.onAdd=eC,t.optionPos||(t.onAdd(t),t.calculative.canvas.parent.active([t])),t.onMouseDown=tC,t.onValue=iC);var i=t.calculative.worldRect.x,a=t.calculative.worldRect.y,r=t.calculative.worldRect.height,n=t.calculative.worldRect.width;if(!!t.optionPos){var o=t.calculative,s=o.fontStyle,h=o.fontWeight;o.fontSize;var l=o.fontFamily,c=o.lineHeight;if(t.direction=="horizontal")for(var f=0;fe.calculative.worldRect.x+e.optionPos[i]*e.calculative.worldRect.width/e.checkboxWidth&&t.xe.calculative.worldRect.y+e.optionPos[i]*a&&t.y0)&&!(r=a.next()).done;)n.push(r.value)}catch(s){o={error:s}}finally{try{r&&!r.done&&(i=a.return)&&i.call(a)}finally{if(o)throw o.error}}return n},aC=globalThis&&globalThis.__spreadArray||function(e,t,i){if(i||arguments.length===2)for(var a=0,r=t.length,n;a=e.length&&(e=void 0),{value:e&&e[a++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},Kt=4,ta=20;function Md(e,t){t.onAdd||(t.onAdd=Lg,(!t.rowPos||!t.colPos||!t.calculative.maxOffsetY)&&t.onAdd(t),t.onMouseMove=dC,t.onMouseLeave=vC,t.onMouseDown=gC,t.onShowInput=hC,t.onInput=fC,t.onValue=EC,t.onBeforeValue=kC,t.onMouseEnter=RC,t.onWheel=CC,t.onDestroy=SC,t.onContextmenu=PC,t.onResize=IC,t.onMove=LC),t.data.length!==t.rowPos.length&&(t.initWorldRect=null,t.calculative.isUpdateData=!0,t.onValue(t)),t.data[0].length!==t.colPos.length&&(t.initWorldRect=null,t.calculative.isUpdateData=!0,t.onValue(t));var i=t.calculative.canvas.store.data,a=t.calculative.canvas.store.options;if(t.colHeaders=t.colHeaders===void 0?t.hasHeader:t.colHeaders,t.color=t.color||i.color||a.color,t.textColor=t.textColor||t.color||i.textColor||a.textColor,t.activeColor=t.activeColor||a.activeColor,t.hoverColor=t.hoverColor||a.hoverColor,t.activeBackground=t.activeBackground||a.activeBackground,t.hoverBackground=t.hoverBackground||a.hoverBackground,!t.colHeaders){e.save(),e.beginPath();var r=t.calculative.worldRect,n=r.x,o=r.y,s=r.width,h=r.height;e.fillStyle="#fff0",e.rect(n-1,o-1,s+2,h+2),e.fill(),e.clip()}sC(e,t),uC(e,t),cC(e,t),e.restore(),nC(e,t),lC(e,t),t.isFirstTime=!1}function nC(e,t){if(!!t.calculative.hover&&!!t.calculative.hoverCell&&!t.calculative.isInput&&!!t.calculative.isHover){var i=t.calculative.worldRect,a=t.calculative.canvas.mousePos;if(!(a.x>i.x&&a.xi.y&&a.yt.calculative.worldRect.height)return"continue"}else if(_<0||_>t.calculative.worldRect.height)return"continue";var k=(i=t.mergeCells)===null||i===void 0?void 0:i.filter(function(U){return U.row<=b&&b=t.colPos.length&&(P=t.colPos.length-1);var M=t.colPos[k[I].col-1]*t.calculative.worldRect.width/t.tableWidth,L=t.colPos[P]*t.calculative.worldRect.width/t.tableWidth;e.lineTo(t.calculative.worldRect.x+M,t.calculative.worldRect.y+_),e.moveTo(t.calculative.worldRect.x+L,t.calculative.worldRect.y+_)}e.lineTo(t.calculative.worldRect.ex,t.calculative.worldRect.y+_)}else e.moveTo(t.calculative.worldRect.x,t.calculative.worldRect.y+_),e.lineTo(t.calculative.worldRect.ex,t.calculative.worldRect.y+_);e.stroke()},p=0;p=t.rowPos.length&&(M=t.rowPos.length-1);var L=t.rowPos[k[P].row-1]*t.calculative.worldRect.height/t.tableHeight-t.offsetY*t.calculative.canvas.store.data.scale,U=t.rowPos[M]*t.calculative.worldRect.height/t.tableHeight-t.offsetY*t.calculative.canvas.store.data.scale;L>t.calculative.worldRect.height&&(L=t.calculative.worldRect.height),L>=0&&e.lineTo(t.calculative.worldRect.x+I,t.calculative.worldRect.y+L),U>t.calculative.worldRect.height&&(U=t.calculative.worldRect.height),U>=0&&e.moveTo(t.calculative.worldRect.x+I,t.calculative.worldRect.y+U)}e.lineTo(t.calculative.worldRect.x+I,t.calculative.worldRect.ey)}else{var $=b*t.calculative.worldRect.width/t.tableWidth;e.moveTo(t.calculative.worldRect.x+$,t.calculative.worldRect.y),e.lineTo(t.calculative.worldRect.x+$,t.calculative.worldRect.ey)}e.stroke()}})}e.restore()}}function lC(e,t){if(t.calculative.activeCol!==void 0){e.save(),e.beginPath(),e.strokeStyle=t.activeColor,e.fillStyle="#278df833";var i=wC(t,t.calculative.activeCol);e.rect(i.x,t.calculative.worldRect.y,i.width,t.calculative.worldRect.height),e.fill(),e.stroke(),e.restore()}}function cC(e,t){if(t.calculative.mergeCell){e.save(),e.beginPath(),e.strokeStyle=t.activeColor,e.fillStyle="#278df833";var i=_C(t,t.calculative.mergeCell);e.rect(i.x,i.y,i.width,i.height),e.fill(),e.stroke(),e.restore()}}function uC(e,t){var i,a,r,n,o;if(!!t.colPos){t.calculative.texts||(t.calculative.texts=[]),t.calculative.canvas.store.data.scale;for(var s=1,h=function(c){if(t.colHeaders&&c===1){e.save(),e.beginPath();var f=t.calculative.worldRect,v=f.x,g=f.y,y=f.width,p=f.height;e.fillStyle="#fff0",e.rect(v-1,g+t.rowPos[0]*t.calculative.worldRect.height/t.tableHeight-1,y+2,p-t.rowPos[0]*t.calculative.worldRect.height/t.tableHeight+2),e.fill(),e.clip()}var m=t.calculative.worldRect.height/t.tableHeight;if(c>0&&t.offsetY*t.calculative.canvas.store.data.scale>t.rowPos[c]*m)return c>=t.calculative.startIndex&&(t.calculative.startIndex=c+1),"continue";if(t.rowPos[c-1]*m-t.offsetY*t.calculative.canvas.store.data.scale>t.calculative.worldRect.height)return ct.calculative.worldRect.height+t.calculative.worldRect.y||(O&&(e.save(),e.beginPath(),e.fillStyle=O,e.fillRect(F.x,F.y,F.width+.25*t.calculative.canvas.store.data.scale,F.height),e.restore()),V&&(e.save(),e.beginPath(),e.strokeStyle=V,e.strokeRect(F.x,F.y,F.width,F.height),e.restore()),$))return"continue";t.calculative.worldTextRect=F;var q=t.calculative.texts[c];if(t.calculative.texts[c]||(q=[],t.calculative.texts[c]=q),q[P]==null){if(typeof L=="object")if(c===0)q[P]=L.text;else{var Y=t.styles&&t.styles.filter(function(se){return se.col===P&&se.row===void 0&&se.pens});if(Y.length>0){if(q[P]="",t.isFirstTime){t.maxNum&&t.colHeaders&&c>=t.maxNum&&(L.visible=!1);var W=JSON.parse(JSON.stringify(Y[0].pens));W.forEach(function(se){Object.assign(se,{row:c,col:P},L),se.activeBackground=se.background,se.hoverBackground=se.background,se.activeColor=se.color,se.hoverColor=se.color,se.activeTextColor=se.textColor,se.hoverTextColor=se.textColor,se.height*=t.calculative.canvas.store.data.scale,se.width*=t.calculative.canvas.store.data.scale}),xC(t,F,W),t.calculative.canvas.parent.pushChildren(t,W)}return"continue"}}else L===void 0?q[P]="":q[P]=L.text||L+"";if(!q[P])return"continue";q[P]=Nn(t,q[P])}if(!q[P])return"continue";e.save(),e.beginPath(),e.fillStyle=R,e.textAlign="center",e.textBaseline="middle",e.font=(ae||t.calculative.fontStyle||"")+" normal "+(G||t.calculative.fontWeight||"")+" "+(K||t.calculative.fontSize||12)*s+"px "+t.calculative.fontFamily;var J=t.colStyle&&((o=t.colStyle[P])===null||o===void 0?void 0:o.textAlign);if(J&&(e.textAlign=J),q[P].length===1)J==="left"?e.fillText(q[P][0],F.x,F.y+F.height/2):J==="right"?e.fillText(q[P][0],F.x+F.width,F.y+F.height/2):e.fillText(q[P][0],F.x+F.width/2,F.y+F.height/2);else{var re=.55,ee=(K||t.calculative.fontSize)*t.calculative.lineHeight*s,he=q[P].length*ee,le=(F.height-he)/2;J==="left"?q[P].forEach(function(se,E){e.fillText(se,F.x,F.y+le+(E+re)*ee)}):J==="right"?q[P].forEach(function(se,E){e.fillText(se,F.x+F.width,F.y+le+(E+re)*ee)}):q[P].forEach(function(se,E){e.fillText(se,F.x+F.width/2,F.y+le+(E+re)*ee)})}e.restore()},_=0;_e.colPos[e.calculative.hoverCell.lineCol]-Kt*2){for(var n=e.calculative.hoverCell.lineCol;ne.rowPos[e.calculative.hoverCell.lineRow]-Kt*2){for(var n=e.calculative.hoverCell.lineRow;n=e.calculative.worldRect.x+h+Kt&&(o.col=s),s!==0&&t.xe.calculative.worldRect.x+h-Kt&&(o.lineCol=s)}var l=e.calculative.startIndex||0,c=e.calculative.endIndex||e.rowPos.length;if(e.colHeaders&&t.y=e.calculative.worldRect.y+f-e.offsetY*e.calculative.canvas.store.data.scale+Kt&&(o.row=s),s!==0&&t.ye.calculative.worldRect.y+f-e.offsetY*e.calculative.canvas.store.data.scale-Kt&&se.calculative.worldRect.y+e.rowPos[s]*n-e.offsetY*e.calculative.canvas.store.data.scale&&(o.allRow=s+1)}}if(t.ye.calculative.worldRect.x+e.colPos[s]*r&&(o.allCol=s+1)}if(o.lineCol!==void 0){var v=[];o.row!==void 0&&(v=(i=e.mergeCells)===null||i===void 0?void 0:i.filter(function(g){return g.col=g.row&&o.row=g.row&&o.lineRowt&&h.col<=i&&h.col+h.colspan>i}),n=void 0;r!=null&&r.length&&((t!==r[0].row||i!==r[0].col)&&(n={row:r[0].row,col:r[0].col}),t=r[0].row,i=r[0].col);var o=e.data[t],s=e.styles&&e.styles.filter(function(h){return h.row===t&&h.col===i});if(Array.isArray(o))return{value:o[i],style:(s==null?void 0:s.length)>0?s[0]:{},mergeCell:n};if(!o.data||!Array.isArray(o.data))return}}function yC(e,t){if(!(!e.data||!Array.isArray(e.data))){var i=e.data[t],a=e.styles&&e.styles.filter(function(r){return r.row===t&&!r.col});if(Array.isArray(i))return{value:i,style:(a==null?void 0:a.length)>0?a[0]:{}};if(!i.data||!Array.isArray(i.data))return}}function mC(e){var t=ce(e.calculative.hoverCell);t.col||(t.col=t.lineCol||0),t.row||(t.row=t.lineRow);var i=Bg([Oa(Oa({},e.calculative.activeCell),{rowspan:1,colspan:1}),Oa(Oa({},t),{rowspan:1,colspan:1})]);return e.mergeCells&&(i=Mg(e,i)),i}function Mg(e,t){var i,a=(i=e.mergeCells)===null||i===void 0?void 0:i.filter(function(r){return pC(r,t)});return a!=null&&a.length?Mg(e,Bg(aC([t],rC(a),!1))):t}function pC(e,t){return!(e.row+e.rowspan<=t.row||e.row>=t.row+t.rowspan||e.col+e.colspan<=t.col||e.col>=t.col+t.colspan||In(e,t))}function In(e,t){return e.row>=t.row&&e.row+e.rowspan<=t.row+t.rowspan&&e.col>=t.col&&e.col+e.colspan<=t.col+t.colspan}function Bg(e){var t=e[0].col,i=e[0].row,a=e[0].col+e[0].colspan,r=e[0].row+e[0].rowspan;return e.forEach(function(n){t=Math.min(t,n.col),i=Math.min(i,n.row),a=Math.max(a,n.col+n.colspan),r=Math.max(r,n.row+n.rowspan)}),{col:t,row:i,colspan:a-t,rowspan:r-i}}function Og(e,t,i,a){if(!(!e.data||!Array.isArray(e.data))){e.isFirstTime=!1,e.calculative.texts=void 0;var r=e.data[t];!r||(r[i]instanceof Object?r[i].text=a:r[i]=a,e.calculative.canvas.store.emitter.emit("valueUpdate",e))}}function Kc(e,t,i){var a,r=e.calculative.worldRect.width/e.tableWidth,n=e.calculative.worldRect.height/e.tableHeight,o=(a=e.mergeCells)===null||a===void 0?void 0:a.filter(function(g){return g.col<=i&&g.row<=t&&g.col+g.colspan>i&&g.row+g.rowspan>t}),s=0,h=0;if(i>-1?h=e.colPos[i]*r:i===-1&&(e.rowHeaders?h=ta*r:h=0),i>0&&(s=e.colPos[i-1]*r),i===0&&e.rowHeaders&&(s=ta*r),o!=null&&o.length){o[0].col<1?e.rowHeaders?s=ta*r:s=0:s=e.colPos[o[0].col-1]*r;var l=o[0].col+o[0].colspan-1;l>=e.colPos.length&&(l=e.colPos.length-1),h=e.colPos[l]*r}var c=0,f=e.rowPos[t]*n;if(t>0&&(c=e.rowPos[t-1]*n),o!=null&&o.length){c=e.rowPos[o[0].row-1]*n;var l=o[0].row+o[0].rowspan-1;l>=e.rowPos.length&&(l=e.rowPos.length-1),f=e.rowPos[l]*n}var v=e.offsetY*e.calculative.canvas.store.data.scale;return t===0&&e.colHeaders&&(v=0),{x:e.calculative.worldRect.x+s,y:e.calculative.worldRect.y+c-v,ex:e.calculative.worldRect.x+h,ey:e.calculative.worldRect.y+f-v,width:h-s,height:f-c}}function wC(e,t){var i=e.calculative.worldRect.width/e.tableWidth,a=0;e.rowHeaders&&(a=ta*i);var r=e.colPos[t]*i;return t>0&&(a=e.colPos[t-1]*i),{x:e.calculative.worldRect.x+a,y:e.calculative.worldRect.y,ex:e.calculative.worldRect.x+r,ey:e.calculative.worldRect.ey,width:r-a,height:e.calculative.worldRect.height}}function bC(e,t){var i=e.calculative.worldRect.height/e.tableHeight,a=0,r=e.rowPos[t]*i;t>0&&(a=e.rowPos[t-1]*i);var n=e.offsetY*e.calculative.canvas.store.data.scale;return t===0&&e.colHeaders&&(n=0),{x:e.calculative.worldRect.x,y:e.calculative.worldRect.y+a-n,ex:e.calculative.worldRect.ex,ey:e.calculative.worldRect.y+r-n,width:e.calculative.worldRect.width,height:r-a}}function _C(e,t){var i=e.calculative.worldRect.width/e.tableWidth,a=e.calculative.worldRect.height/e.tableHeight,r=e.colPos[t.col-1]*i;t.col===0&&(r=0,e.rowHeaders&&(r=ta*i));var n=e.colPos[t.col+t.colspan-1]*i,o=e.rowPos[t.row-1]*a,s=e.rowPos[t.row+t.rowspan-1]*a,h=e.offsetY*e.calculative.canvas.store.data.scale;return{x:e.calculative.worldRect.x+r,y:e.calculative.worldRect.y+o-h,ex:e.calculative.worldRect.x+n,ey:e.calculative.worldRect.y+s-h,width:n-r,height:s-o}}function xC(e,t,i){var a,r,n,o,s=e.calculative.worldRect.width/e.tableWidth,h=e.calculative.worldRect.height/e.tableHeight,l=1,c=1;e.initWorldRect&&(e.calculative.worldRect.width!==e.initWorldRect.width&&(l=e.calculative.worldRect.width/e.initWorldRect.width),e.calculative.worldRect.height!==e.initWorldRect.height&&(c=e.calculative.worldRect.height/e.initWorldRect.height));var f=0,v=0,g=0,y=e.calculative.canvas.store.data.scale;if(i.length>1){try{for(var p=qc(i),m=p.next();!m.done;m=p.next()){var b=m.value;v+b.width*s+20*y*s0?r=4:r=-4,ys(e,r),(a=(i=e.calculative.singleton)===null||i===void 0?void 0:i.tableScroll)===null||a===void 0||a.updataScrollHTop()}}function ys(e,t){var i;e.calculative.startIndex=0,e.calculative.endIndex=e.data.length,e.offsetY||(e.offsetY=0),e.offsetY+=t;var a=e.calculative.worldRect.height/e.initWorldRect.height;e.offsetY>e.calculative.maxOffsetY*a&&(e.offsetY=e.calculative.maxOffsetY*a),e.offsetY<0&&(e.offsetY=0),(i=e.children)===null||i===void 0||i.forEach(function(r){var n=e.calculative.canvas.store.pens[r];AC(e,n)}),e.calculative.canvas.render()}function AC(e,t){if(!!t){t.oldY||(t.oldY=t.y);var i=t.calculative.worldRect;i.y,i.height;var a=e.calculative.worldRect;a.y,a.height;var r=e.calculative.canvas.store.data.scale;e.calculative.worldRect.height/e.tableHeight;var n=e.rowHeight;t.y=t.oldY-e.offsetY*r/e.calculative.worldRect.height;var o=n*(e.initScale||1)/e.tableHeight*e.maxNum;if(e.calculative.canvas.updatePenRect(t),e.colHeaders)if(t.y1){if(t.calculative.visible=!1,t.visible=!1,t.y+t.height/2>1){t.oldY-=o;var s=t.row-e.maxNum;if(!e.data[s])return;var h=ce(e.data[s][t.col]);h.background&&(h.activeBackground=h.background,h.hoverBackground=h.background),h.color&&(h.hoverColor=h.color,h.activeColor=h.color),h.textColor&&(h.activeTextColor=h.textColor,h.hoverTextColor=h.textColor),Object.assign(t,h,{row:s}),Object.assign(t.calculative,h,{row:s})}}else t.visible=!0,t.calculative.visible=!0;else if(t.y<0){if(t.calculative.visible=!1,t.visible=!1,t.y<-n/e.tableHeight/2){t.oldY+=o;var s=t.row+e.maxNum;if(!e.data[s])return;var h=ce(e.data[s][t.col]);h.background&&(h.activeBackground=h.background,h.hoverBackground=h.background),h.color&&(h.hoverColor=h.color,h.activeColor=h.color),h.textColor&&(h.activeTextColor=h.textColor,h.hoverTextColor=h.textColor),Object.assign(t,h,{row:s}),Object.assign(t.calculative,h,{row:s})}}else if(t.y+t.height>1){if(t.calculative.visible=!1,t.visible=!1,t.y+t.height/2>1){t.oldY-=o;var s=t.row-e.maxNum;if(!e.data[s])return;var h=ce(e.data[s][t.col]);h.background&&(h.activeBackground=h.background,h.hoverBackground=h.background),h.color&&(h.hoverColor=h.color,h.activeColor=h.color),h.textColor&&(h.activeTextColor=h.textColor,h.hoverTextColor=h.textColor),Object.assign(t,h,{row:s}),Object.assign(t.calculative,h,{row:s})}}else t.calculative.visible=!0,t.visible=!0}}function SC(e){var t,i,a,r;(i=(t=e.calculative.singleton)===null||t===void 0?void 0:t.tableScroll)===null||i===void 0||i.destroy(),(r=(a=e.calculative.singleton)===null||a===void 0?void 0:a.tableContextMenu)===null||r===void 0||r.destroy(),uu(e)}function uu(e){e.interval&&(globalThis.clearInterval(e.interval),e.interval=null)}function hu(e){if(e.maxNum&&e.swiper){if(e.interval)return;e.interval=globalThis.setInterval(function(){e.offsetY>=e.calculative.maxOffsetY?(e.offsetY=0,TC(e)):e.offsetY%e.rowHeight?ys(e,1):(e.calculative.stap||(e.calculative.stap=0),e.calculative.stap+=1,e.calculative.stap==12&&(e.calculative.stap=0,ys(e,1)))},50)}}function TC(e){var t;(t=e.children)===null||t===void 0||t.forEach(function(i){var a=e.rowHeight,r=e.calculative.canvas.store.pens[i];if(!!r){var n=a*(e.initScale||1)/e.tableHeight*e.maxNum;r.oldY-=n;var o=r.row-e.maxNum;if(!!e.data[o]){var s=ce(e.data[o][r.col]);s.background&&(s.activeBackground=s.background,s.hoverBackground=s.background),s.color&&(s.hoverColor=s.color,s.activeColor=s.color),s.textColor&&(s.activeTextColor=s.textColor,s.hoverTextColor=s.textColor),r.calculative.visible=!0,r.visible=!0,Object.assign(r,s,{row:o}),Object.assign(r.calculative,s,{row:o})}}}),e.calculative.canvas.render()}function RC(e){uu(e),e.maxNum&&(e.locked||e.calculative.canvas.store.data.locked)&&(e.calculative.singleton||(e.calculative.singleton={}),e.calculative.singleton.tableScroll||(e.calculative.singleton.tableScroll=new BC(e)),e.calculative.singleton.tableScroll.showScroll())}function PC(e,t){e.calculative.singleton||(e.calculative.singleton={}),e.calculative.singleton.tableContextMenu||(e.calculative.singleton.tableContextMenu=new MC(e)),e.calculative.mergeCell!==void 0&&e.calculative.singleton.tableContextMenu.updateMenu("merge",t),e.calculative.activeRow!==void 0&&e.calculative.singleton.tableContextMenu.updateMenu("row",t),e.calculative.activeCol!==void 0&&e.calculative.singleton.tableContextMenu.updateMenu("col",t)}function IC(e){var t,i;(i=(t=e.calculative.singleton)===null||t===void 0?void 0:t.tableScroll)===null||i===void 0||i.updataScroll()}function LC(e){var t,i;(i=(t=e.calculative.singleton)===null||t===void 0?void 0:t.tableScroll)===null||i===void 0||i.updataScroll()}var DC={col:[{name:"\u5DE6\u63D2\u5165\u5217",key:"insertColLeft",disabled:!1},{name:"\u53F3\u63D2\u5165\u5217",key:"insertColRight",disabled:!1},{name:"\u5220\u9664\u5217",key:"deleteCol"},{name:"\u6E05\u7A7A\u5217",key:"clearCol"}],row:[{name:"\u4E0A\u63D2\u5165\u884C",key:"insertRowAbove",disabled:!1},{name:"\u4E0B\u63D2\u5165\u884C",key:"insertRowBelow",disabled:!1},{name:"\u5220\u9664\u884C",key:"deleteRow"},{name:"\u6E05\u7A7A\u884C",key:"clearRow"}],merge:[{name:"\u6E05\u7A7A\u5355\u5143\u683C",key:"clearCells"},{name:"\u53D6\u6D88\u5408\u5E76",key:"cancelMerge"},{name:"\u5408\u5E76",key:"mergeCell"}]},MC=function(){function e(t){var i=this;this.insertColLeft=function(a){var r,n,o;i.pen.data.forEach(function(l){l.splice(a,0,"")});var s=i.pen.colWidth;a!==0&&(s=i.pen.colPos[a-1]+i.pen.colWidth),i.pen.colPos.splice(a,0,s);for(var h=a+1;h=a&&(l.col+=1)}),i.pen.calculative.activeCol+=1,!((n=i.pen.mergeCells)===null||n===void 0)&&n.length&&((o=i.pen.mergeCells)===null||o===void 0||o.forEach(function(l){l.col=a&&(l.col+=1)})),i.pen.calculative.texts=void 0,i.pen.calculative.canvas.render()},this.insertColRight=function(a){var r,n,o;i.pen.data.forEach(function(h){h.splice(a+1,0,"")}),i.pen.colPos.splice(a+1,0,i.pen.colPos[a]+i.pen.colWidth);for(var s=a+2;s=a&&(h.col+=1)}),!((n=i.pen.mergeCells)===null||n===void 0)&&n.length&&((o=i.pen.mergeCells)===null||o===void 0||o.forEach(function(h){h.col=a+1&&(h.col+=1)})),i.pen.calculative.texts=void 0,i.pen.calculative.canvas.render()},this.deleteCol=function(a){var r,n,o;i.pen.data.forEach(function(c){c.splice(a,1)});var s=i.pen.colPos[a]-i.pen.colPos[a-1];a===0&&(s=i.pen.colPos[a]),i.pen.colPos.splice(a,1);for(var h=a;h=a&&(c.col-=1)}),!((n=i.pen.mergeCells)===null||n===void 0)&&n.length)for(var h=0;h<((o=i.pen.mergeCells)===null||o===void 0?void 0:o.length);h++){var l=i.pen.mergeCells[h];l.col<=a&&aa&&(l.col-=1),(l.colspan<1||l.colspan===1&&l.rowspan===1)&&(i.pen.mergeCells.splice(h,1),h--)}i.pen.calculative.texts=void 0,i.pen.calculative.canvas.render()},this.clearCol=function(a){i.pen.data.forEach(function(r){r[a]=""}),i.pen.calculative.texts=void 0,i.pen.calculative.canvas.render()},this.insertRowAbove=function(a){for(var r,n=[],o=0;o=a&&(s.row+=1)}),i.pen.calculative.texts=void 0,i.pen.calculative.canvas.render()},this.insertRowBelow=function(a){for(var r,n=[],o=0;o=a+1&&(h.row+=1)}),i.pen.calculative.texts=void 0,i.pen.calculative.canvas.render()},this.deleteRow=function(a){var r;i.pen.data.splice(a,1),i.pen.rowPos.splice(a,1);for(var n=a;na&&(o.row-=1),(o.rowspan<1||o.colspan===1&&o.rowspan===1)&&(i.pen.mergeCells.splice(n,1),n--)}i.pen.calculative.texts=void 0,i.pen.calculative.canvas.render()},this.clearRow=function(a){for(var r=0;r1||r.rowspan>1){for(var o=0;o<((a=i.pen.mergeCells)===null||a===void 0?void 0:a.length);o++)In(i.pen.mergeCells[o],r)&&(i.pen.mergeCells.splice(o,1),o--);i.pen.mergeCells||(i.pen.mergeCells=[]),i.pen.mergeCells.push(ce(r)),i.pen.calculative.canvas.render()}}},this.pen=t,this.options=DC,this.init()}return e.prototype.init=function(){var t=this,i;this.menu=document.createElement("ul"),this.menu.style.position="absolute",this.menu.style.zIndex="999",this.menu.style.backgroundColor="#fff",this.menu.style.listStyleType="none",this.menu.style.border="1px solid #ccc",this.menu.style.display="none",document.body.appendChild(this.menu),(i=this.pen.calculative.canvas.externalElements)===null||i===void 0||i.parentElement.appendChild(this.menu),this.pen.calculative.singleton||(this.pen.calculative.singleton={});for(var a in this.options)this.options[a].forEach(function(r){t.pen[r.key]=t[r.key]})},e.prototype.updateMenu=function(t,i){this.key!==t&&(this.key=t,this.setMenuList()),this.menu.style.display="block",this.menu.style.left=i.x+"px",this.menu.style.top=i.y+"px"},e.prototype.setMenuList=function(){for(var t=this;this.menu.firstChild;)this.menu.removeChild(this.menu.firstChild);for(var i=function(n){var o=document.createElement("li");o.style.width="100px",o.style.height="26px",o.style.color="#373737",o.style.paddingLeft="12px",o.style.lineHeight="26px",o.style.cursor="pointer",o.innerText=a.options[a.key][n].name,o.onclick=function(){["row","col"].includes(t.key)?t.pen[t.options[t.key][n].key](t.pen.calculative[t.key==="row"?"activeRow":"activeCol"]):t.pen[t.options[t.key][n].key](),t.menu.style.display="none"},o.onmouseover=function(){o.style.backgroundColor="#f5f5f5"},o.onmouseleave=function(){o.style.backgroundColor=""},a.menu.appendChild(o)},a=this,r=0;r-1&&(t.data.pens.splice(a,1),t.pens[i]=void 0)}),e.children=void 0}function UC(e,t){e.onDestroy||(e.onDestroy=qC,e.onAdd=WC);var i=t||new Path2D,a=e.calculative.worldRect,r=a.x,n=a.y,o=a.width,s=a.height,h=a.ex,l=e.calculative.borderRadius||0,c=l;l<1&&(l=o*l,c=s*c);var f=l-1&&(t.data.pens.splice(a,1),t.pens[i]=void 0)}),e.children=[]}function OT(){return{interfaceClass:FC,simpleClass:UC}}function jC(e,t){var i=t||new Path2D,a=e.calculative.worldRect,r=a.x,n=a.y,o=a.width,s=a.height;if(i.rect(r,n,o,s),i.closePath(),i instanceof Path2D)return i}function KC(e,t){var i,a=(i=t.headHeight)!==null&&i!==void 0?i:50,r=t.calculative.worldRect,n=r.x,o=r.y,s=r.width,h=r.height,l=r.ey,c=t.calculative.borderRadius||0,f=c;t.calculative.borderRadius<1&&(c*=s,f*=h);var v=c"u"}function XC(e){return e!==null&&!Vc(e)&&e.constructor!==null&&!Vc(e.constructor)&&typeof e.constructor.isBuffer=="function"&&e.constructor.isBuffer(e)}function zg(e){return Dr.call(e)==="[object ArrayBuffer]"}function ZC(e){return Dr.call(e)==="[object FormData]"}function QC(e){var t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&zg(e.buffer),t}function JC(e){return typeof e=="string"}function eA(e){return typeof e=="number"}function Hg(e){return e!==null&&typeof e=="object"}function Jo(e){if(Dr.call(e)!=="[object Object]")return!1;var t=Object.getPrototypeOf(e);return t===null||t===Object.prototype}function tA(e){return Dr.call(e)==="[object Date]"}function iA(e){return Dr.call(e)==="[object File]"}function rA(e){return Dr.call(e)==="[object Blob]"}function Ug(e){return Dr.call(e)==="[object Function]"}function aA(e){return Hg(e)&&Ug(e.pipe)}function nA(e){return Dr.call(e)==="[object URLSearchParams]"}function oA(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}function sA(){return typeof navigator<"u"&&(navigator.product==="ReactNative"||navigator.product==="NativeScript"||navigator.product==="NS")?!1:typeof window<"u"&&typeof document<"u"}function vu(e,t){if(!(e===null||typeof e>"u"))if(typeof e!="object"&&(e=[e]),du(e))for(var i=0,a=e.length;i"u"||(Sa.isArray(h)?l=l+"[]":h=[h],Sa.forEach(h,function(f){Sa.isDate(f)?f=f.toISOString():Sa.isObject(f)&&(f=JSON.stringify(f)),n.push(Bd(l)+"="+Bd(f))}))}),r=n.join("&")}if(r){var o=t.indexOf("#");o!==-1&&(t=t.slice(0,o)),t+=(t.indexOf("?")===-1?"?":"&")+r}return t},uA=Gt;function _s(){this.handlers=[]}_s.prototype.use=function(t,i,a){return this.handlers.push({fulfilled:t,rejected:i,synchronous:a?a.synchronous:!1,runWhen:a?a.runWhen:null}),this.handlers.length-1};_s.prototype.eject=function(t){this.handlers[t]&&(this.handlers[t]=null)};_s.prototype.forEach=function(t){uA.forEach(this.handlers,function(a){a!==null&&t(a)})};var hA=_s,fA=Gt,dA=function(t,i){fA.forEach(t,function(r,n){n!==i&&n.toUpperCase()===i.toUpperCase()&&(t[i]=r,delete t[n])})},qg=function(t,i,a,r,n){return t.config=i,a&&(t.code=a),t.request=r,t.response=n,t.isAxiosError=!0,t.toJSON=function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code,status:this.response&&this.response.status?this.response.status:null}},t},tc,Od;function jg(){if(Od)return tc;Od=1;var e=qg;return tc=function(i,a,r,n,o){var s=new Error(i);return e(s,a,r,n,o)},tc}var ic,Nd;function vA(){if(Nd)return ic;Nd=1;var e=jg();return ic=function(i,a,r){var n=r.config.validateStatus;!r.status||!n||n(r.status)?i(r):a(e("Request failed with status code "+r.status,r.config,null,r.request,r))},ic}var rc,Fd;function gA(){if(Fd)return rc;Fd=1;var e=Gt;return rc=e.isStandardBrowserEnv()?function(){return{write:function(a,r,n,o,s,h){var l=[];l.push(a+"="+encodeURIComponent(r)),e.isNumber(n)&&l.push("expires="+new Date(n).toGMTString()),e.isString(o)&&l.push("path="+o),e.isString(s)&&l.push("domain="+s),h===!0&&l.push("secure"),document.cookie=l.join("; ")},read:function(a){var r=document.cookie.match(new RegExp("(^|;\\s*)("+a+")=([^;]*)"));return r?decodeURIComponent(r[3]):null},remove:function(a){this.write(a,"",Date.now()-864e5)}}}():function(){return{write:function(){},read:function(){return null},remove:function(){}}}(),rc}var ac,zd;function yA(){return zd||(zd=1,ac=function(t){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t)}),ac}var nc,Hd;function mA(){return Hd||(Hd=1,nc=function(t,i){return i?t.replace(/\/+$/,"")+"/"+i.replace(/^\/+/,""):t}),nc}var oc,Ud;function pA(){if(Ud)return oc;Ud=1;var e=yA(),t=mA();return oc=function(a,r){return a&&!e(r)?t(a,r):r},oc}var sc,Wd;function wA(){if(Wd)return sc;Wd=1;var e=Gt,t=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"];return sc=function(a){var r={},n,o,s;return a&&e.forEach(a.split(` `),function(l){if(s=l.indexOf(":"),n=e.trim(l.substr(0,s)).toLowerCase(),o=e.trim(l.substr(s+1)),n){if(r[n]&&t.indexOf(n)>=0)return;n==="set-cookie"?r[n]=(r[n]?r[n]:[]).concat([o]):r[n]=r[n]?r[n]+", "+o:o}}),r},sc}var lc,qd;function bA(){if(qd)return lc;qd=1;var e=Gt;return lc=e.isStandardBrowserEnv()?function(){var i=/(msie|trident)/i.test(navigator.userAgent),a=document.createElement("a"),r;function n(o){var s=o;return i&&(a.setAttribute("href",s),s=a.href),a.setAttribute("href",s),{href:a.href,protocol:a.protocol?a.protocol.replace(/:$/,""):"",host:a.host,search:a.search?a.search.replace(/^\?/,""):"",hash:a.hash?a.hash.replace(/^#/,""):"",hostname:a.hostname,port:a.port,pathname:a.pathname.charAt(0)==="/"?a.pathname:"/"+a.pathname}}return r=n(window.location.href),function(s){var h=e.isString(s)?n(s):s;return h.protocol===r.protocol&&h.host===r.host}}():function(){return function(){return!0}}(),lc}var cc,jd;function xs(){if(jd)return cc;jd=1;function e(t){this.message=t}return e.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},e.prototype.__CANCEL__=!0,cc=e,cc}var uc,Kd;function Vd(){if(Kd)return uc;Kd=1;var e=Gt,t=vA(),i=gA(),a=Wg,r=pA(),n=wA(),o=bA(),s=jg(),h=Es(),l=xs();return uc=function(f){return new Promise(function(g,y){var p=f.data,m=f.headers,b=f.responseType,x;function _(){f.cancelToken&&f.cancelToken.unsubscribe(x),f.signal&&f.signal.removeEventListener("abort",x)}e.isFormData(p)&&delete m["Content-Type"];var k=new XMLHttpRequest;if(f.auth){var I=f.auth.username||"",P=f.auth.password?unescape(encodeURIComponent(f.auth.password)):"";m.Authorization="Basic "+btoa(I+":"+P)}var M=r(f.baseURL,f.url);k.open(f.method.toUpperCase(),a(M,f.params,f.paramsSerializer),!0),k.timeout=f.timeout;function L(){if(!!k){var $="getAllResponseHeaders"in k?n(k.getAllResponseHeaders()):null,S=!b||b==="text"||b==="json"?k.responseText:k.response,T={data:S,status:k.status,statusText:k.statusText,headers:$,config:f,request:k};t(function(O){g(O),_()},function(O){y(O),_()},T),k=null}}if("onloadend"in k?k.onloadend=L:k.onreadystatechange=function(){!k||k.readyState!==4||k.status===0&&!(k.responseURL&&k.responseURL.indexOf("file:")===0)||setTimeout(L)},k.onabort=function(){!k||(y(s("Request aborted",f,"ECONNABORTED",k)),k=null)},k.onerror=function(){y(s("Network Error",f,null,k)),k=null},k.ontimeout=function(){var S=f.timeout?"timeout of "+f.timeout+"ms exceeded":"timeout exceeded",T=f.transitional||h.transitional;f.timeoutErrorMessage&&(S=f.timeoutErrorMessage),y(s(S,f,T.clarifyTimeoutError?"ETIMEDOUT":"ECONNABORTED",k)),k=null},e.isStandardBrowserEnv()){var U=(f.withCredentials||o(M))&&f.xsrfCookieName?i.read(f.xsrfCookieName):void 0;U&&(m[f.xsrfHeaderName]=U)}"setRequestHeader"in k&&e.forEach(m,function(S,T){typeof p>"u"&&T.toLowerCase()==="content-type"?delete m[T]:k.setRequestHeader(T,S)}),e.isUndefined(f.withCredentials)||(k.withCredentials=!!f.withCredentials),b&&b!=="json"&&(k.responseType=f.responseType),typeof f.onDownloadProgress=="function"&&k.addEventListener("progress",f.onDownloadProgress),typeof f.onUploadProgress=="function"&&k.upload&&k.upload.addEventListener("progress",f.onUploadProgress),(f.cancelToken||f.signal)&&(x=function($){!k||(y(!$||$&&$.type?new l("canceled"):$),k.abort(),k=null)},f.cancelToken&&f.cancelToken.subscribe(x),f.signal&&(f.signal.aborted?x():f.signal.addEventListener("abort",x))),p||(p=null),k.send(p)})},uc}var hc,$d;function Es(){if($d)return hc;$d=1;var e=Gt,t=dA,i=qg,a={"Content-Type":"application/x-www-form-urlencoded"};function r(h,l){!e.isUndefined(h)&&e.isUndefined(h["Content-Type"])&&(h["Content-Type"]=l)}function n(){var h;return(typeof XMLHttpRequest<"u"||typeof process<"u"&&Object.prototype.toString.call(process)==="[object process]")&&(h=Vd()),h}function o(h,l,c){if(e.isString(h))try{return(l||JSON.parse)(h),e.trim(h)}catch(f){if(f.name!=="SyntaxError")throw f}return(c||JSON.stringify)(h)}var s={transitional:{silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},adapter:n(),transformRequest:[function(l,c){return t(c,"Accept"),t(c,"Content-Type"),e.isFormData(l)||e.isArrayBuffer(l)||e.isBuffer(l)||e.isStream(l)||e.isFile(l)||e.isBlob(l)?l:e.isArrayBufferView(l)?l.buffer:e.isURLSearchParams(l)?(r(c,"application/x-www-form-urlencoded;charset=utf-8"),l.toString()):e.isObject(l)||c&&c["Content-Type"]==="application/json"?(r(c,"application/json"),o(l)):l}],transformResponse:[function(l){var c=this.transitional||s.transitional,f=c&&c.silentJSONParsing,v=c&&c.forcedJSONParsing,g=!f&&this.responseType==="json";if(g||v&&e.isString(l)&&l.length)try{return JSON.parse(l)}catch(y){if(g)throw y.name==="SyntaxError"?i(y,this,"E_JSON_PARSE"):y}return l}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,validateStatus:function(l){return l>=200&&l<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};return e.forEach(["delete","get","head"],function(l){s.headers[l]={}}),e.forEach(["post","put","patch"],function(l){s.headers[l]=e.merge(a)}),hc=s,hc}var _A=Gt,xA=Es(),EA=function(t,i,a){var r=this||xA;return _A.forEach(a,function(o){t=o.call(r,t,i)}),t},fc,Yd;function Kg(){return Yd||(Yd=1,fc=function(t){return!!(t&&t.__CANCEL__)}),fc}var Gd=Gt,dc=EA,kA=Kg(),CA=Es(),AA=xs();function vc(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new AA("canceled")}var SA=function(t){vc(t),t.headers=t.headers||{},t.data=dc.call(t,t.data,t.headers,t.transformRequest),t.headers=Gd.merge(t.headers.common||{},t.headers[t.method]||{},t.headers),Gd.forEach(["delete","get","head","post","put","patch","common"],function(r){delete t.headers[r]});var i=t.adapter||CA.adapter;return i(t).then(function(r){return vc(t),r.data=dc.call(t,r.data,r.headers,t.transformResponse),r},function(r){return kA(r)||(vc(t),r&&r.response&&(r.response.data=dc.call(t,r.response.data,r.response.headers,t.transformResponse))),Promise.reject(r)})},ii=Gt,Vg=function(t,i){i=i||{};var a={};function r(c,f){return ii.isPlainObject(c)&&ii.isPlainObject(f)?ii.merge(c,f):ii.isPlainObject(f)?ii.merge({},f):ii.isArray(f)?f.slice():f}function n(c){if(ii.isUndefined(i[c])){if(!ii.isUndefined(t[c]))return r(void 0,t[c])}else return r(t[c],i[c])}function o(c){if(!ii.isUndefined(i[c]))return r(void 0,i[c])}function s(c){if(ii.isUndefined(i[c])){if(!ii.isUndefined(t[c]))return r(void 0,t[c])}else return r(void 0,i[c])}function h(c){if(c in i)return r(t[c],i[c]);if(c in t)return r(void 0,t[c])}var l={url:o,method:o,data:o,baseURL:s,transformRequest:s,transformResponse:s,paramsSerializer:s,timeout:s,timeoutMessage:s,withCredentials:s,adapter:s,responseType:s,xsrfCookieName:s,xsrfHeaderName:s,onUploadProgress:s,onDownloadProgress:s,decompress:s,maxContentLength:s,maxBodyLength:s,transport:s,httpAgent:s,httpsAgent:s,cancelToken:s,socketPath:s,responseEncoding:s,validateStatus:h};return ii.forEach(Object.keys(t).concat(Object.keys(i)),function(f){var v=l[f]||n,g=v(f);ii.isUndefined(g)&&v!==h||(a[f]=g)}),a},gc,Xd;function $g(){return Xd||(Xd=1,gc={version:"0.25.0"}),gc}var TA=$g().version,gu={};["object","boolean","number","function","string","symbol"].forEach(function(e,t){gu[e]=function(a){return typeof a===e||"a"+(t<1?"n ":" ")+e}});var Zd={};gu.transitional=function(t,i,a){function r(n,o){return"[Axios v"+TA+"] Transitional option '"+n+"'"+o+(a?". "+a:"")}return function(n,o,s){if(t===!1)throw new Error(r(o," has been removed"+(i?" in "+i:"")));return i&&!Zd[o]&&(Zd[o]=!0,console.warn(r(o," has been deprecated since v"+i+" and will be removed in the near future"))),t?t(n,o,s):!0}};function RA(e,t,i){if(typeof e!="object")throw new TypeError("options must be an object");for(var a=Object.keys(e),r=a.length;r-- >0;){var n=a[r],o=t[n];if(o){var s=e[n],h=s===void 0||o(s,n,e);if(h!==!0)throw new TypeError("option "+n+" must be "+h);continue}if(i!==!0)throw Error("Unknown option "+n)}}var PA={assertOptions:RA,validators:gu},Yg=Gt,IA=Wg,Qd=hA,Jd=SA,ks=Vg,Gg=PA,Ta=Gg.validators;function zn(e){this.defaults=e,this.interceptors={request:new Qd,response:new Qd}}zn.prototype.request=function(t,i){if(typeof t=="string"?(i=i||{},i.url=t):i=t||{},!i.url)throw new Error("Provided config url is not valid");i=ks(this.defaults,i),i.method?i.method=i.method.toLowerCase():this.defaults.method?i.method=this.defaults.method.toLowerCase():i.method="get";var a=i.transitional;a!==void 0&&Gg.assertOptions(a,{silentJSONParsing:Ta.transitional(Ta.boolean),forcedJSONParsing:Ta.transitional(Ta.boolean),clarifyTimeoutError:Ta.transitional(Ta.boolean)},!1);var r=[],n=!0;this.interceptors.request.forEach(function(g){typeof g.runWhen=="function"&&g.runWhen(i)===!1||(n=n&&g.synchronous,r.unshift(g.fulfilled,g.rejected))});var o=[];this.interceptors.response.forEach(function(g){o.push(g.fulfilled,g.rejected)});var s;if(!n){var h=[Jd,void 0];for(Array.prototype.unshift.apply(h,r),h=h.concat(o),s=Promise.resolve(i);h.length;)s=s.then(h.shift(),h.shift());return s}for(var l=i;r.length;){var c=r.shift(),f=r.shift();try{l=c(l)}catch(v){f(v);break}}try{s=Jd(l)}catch(v){return Promise.reject(v)}for(;o.length;)s=s.then(o.shift(),o.shift());return s};zn.prototype.getUri=function(t){if(!t.url)throw new Error("Provided config url is not valid");return t=ks(this.defaults,t),IA(t.url,t.params,t.paramsSerializer).replace(/^\?/,"")};Yg.forEach(["delete","get","head","options"],function(t){zn.prototype[t]=function(i,a){return this.request(ks(a||{},{method:t,url:i,data:(a||{}).data}))}});Yg.forEach(["post","put","patch"],function(t){zn.prototype[t]=function(i,a,r){return this.request(ks(r||{},{method:t,url:i,data:a}))}});var LA=zn,yc,ev;function DA(){if(ev)return yc;ev=1;var e=xs();function t(i){if(typeof i!="function")throw new TypeError("executor must be a function.");var a;this.promise=new Promise(function(o){a=o});var r=this;this.promise.then(function(n){if(!!r._listeners){var o,s=r._listeners.length;for(o=0;o{const t=localStorage.getItem("token");return t&&(e.headers.Authorization="Bearer "+t),e});lr.interceptors.response.use(e=>{var t,i,a;return e.data&&e.data.code===0?Promise.resolve((t=e.data)==null?void 0:t.data):e.data&&e.data.code===401?(setTimeout(()=>{window.location.href="/"},1e3),Ca.error((i=e.data)==null?void 0:i.message)):(Ca.error((a=e.data)==null?void 0:a.message),Promise.reject(e.data))},e=>{var t,i;return av?!1:e.response?(Ca.closeAll(),Ca.error(((t=e.response.data)==null?void 0:t.msg)||"\u767B\u5F55\u5931\u6548\uFF0C\u7A0D\u540E\u91CD\u65B0\u767B\u5F55"),((i=e.response.data)==null?void 0:i.code)===401&&(localStorage.removeItem("token"),setTimeout(()=>{window.location.href="/"},1e3)),Promise.reject(e)):(av=!0,Ca.closeAll(),Ca.error("\u8BF7\u6C42\u51FA\u9519\uFF01\uFF01\uFF01"),Promise.reject(e))});function Qi(e,t){return lr.post(e,t)}function wc(e,t){return lr({url:e,method:"delete",data:t})}function Ji(e,t){return lr.get(e,{params:t})}function zA(e,t){return lr.put(e,t)}const KT={tokenRefresh:()=>Qi("/tokenRefresh",{appId:0}),login:()=>Qi("/jwt/login",{username:"hxy",password:"hxy123"}),folder:()=>Ji("/configure/folder/list"),folderData:e=>Ji("/configure/diagram/getInfoByFolderId",{folderId:e}),folderAdd:(e,t)=>Qi("/configure/folder/add",{name:e,types:t}),folderEdit:(e,t,i)=>Qi("/configure/folder/edit",{name:e,types:t,id:i}),folderDel:e=>wc("/configure/folder/del",{id:e}),topologyAdd:e=>Qi("/configure/diagram/add",e),topologyEdit:e=>Qi("/configure/diagram/edit",e),topologyDel:e=>wc("/configure/diagram/del",{id:e}),topology:e=>Ji("/configure/diagram/getInfoById",{id:e}),topologyName:e=>Ji("/configure/diagram/getInfoByName",{name:e}),deviceList:()=>Ji("/product/device/list"),functionList:e=>Ji("/product/tsl/function/all",e),devicePoint:e=>Ji(`/configure/devicePoint/${e}`),do:e=>Qi("/product/function/do",e),uploadImg:e=>Qi("/common/singleImg",e),drawer:{pointAdd:e=>Qi("/configure/point/add",e),pointDel:e=>wc("/configure/point/del",{id:e}),pointEdit:e=>zA("/configure/point/edit",e),getEchartInfo:e=>Ji("/configure/point/getEchartInfo",e),getInfoByDiagramIdAndPointId:e=>Ji("/configure/point/getInfoByDiagramIdAndPointId",e)}};var cr={};(function(e){var t=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";function i(n,o){return Object.prototype.hasOwnProperty.call(n,o)}e.assign=function(n){for(var o=Array.prototype.slice.call(arguments,1);o.length;){var s=o.shift();if(!!s){if(typeof s!="object")throw new TypeError(s+"must be non-object");for(var h in s)i(s,h)&&(n[h]=s[h])}}return n},e.shrinkBuf=function(n,o){return n.length===o?n:n.subarray?n.subarray(0,o):(n.length=o,n)};var a={arraySet:function(n,o,s,h,l){if(o.subarray&&n.subarray){n.set(o.subarray(s,s+h),l);return}for(var c=0;c=0;)e[t]=0}var qA=0,Zg=1,jA=2,KA=3,VA=258,yu=29,Un=256,Ln=Un+1+yu,za=30,mu=19,Qg=2*Ln+1,Gr=15,bc=16,$A=7,pu=256,Jg=16,ey=17,ty=18,Yc=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],ts=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],YA=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],iy=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],GA=512,rr=new Array((Ln+2)*2);Va(rr);var En=new Array(za*2);Va(En);var Dn=new Array(GA);Va(Dn);var Mn=new Array(VA-KA+1);Va(Mn);var wu=new Array(yu);Va(wu);var ms=new Array(za);Va(ms);function _c(e,t,i,a,r){this.static_tree=e,this.extra_bits=t,this.extra_base=i,this.elems=a,this.max_length=r,this.has_stree=e&&e.length}var ry,ay,ny;function xc(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}function oy(e){return e<256?Dn[e]:Dn[256+(e>>>7)]}function Bn(e,t){e.pending_buf[e.pending++]=t&255,e.pending_buf[e.pending++]=t>>>8&255}function Yt(e,t,i){e.bi_valid>bc-i?(e.bi_buf|=t<>bc-e.bi_valid,e.bi_valid+=i-bc):(e.bi_buf|=t<>>=1,i<<=1;while(--t>0);return i>>>1}function XA(e){e.bi_valid===16?(Bn(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=e.bi_buf&255,e.bi_buf>>=8,e.bi_valid-=8)}function ZA(e,t){var i=t.dyn_tree,a=t.max_code,r=t.stat_desc.static_tree,n=t.stat_desc.has_stree,o=t.stat_desc.extra_bits,s=t.stat_desc.extra_base,h=t.stat_desc.max_length,l,c,f,v,g,y,p=0;for(v=0;v<=Gr;v++)e.bl_count[v]=0;for(i[e.heap[e.heap_max]*2+1]=0,l=e.heap_max+1;lh&&(v=h,p++),i[c*2+1]=v,!(c>a)&&(e.bl_count[v]++,g=0,c>=s&&(g=o[c-s]),y=i[c*2],e.opt_len+=y*(v+g),n&&(e.static_len+=y*(r[c*2+1]+g)));if(p!==0){do{for(v=h-1;e.bl_count[v]===0;)v--;e.bl_count[v]--,e.bl_count[v+1]+=2,e.bl_count[h]--,p-=2}while(p>0);for(v=h;v!==0;v--)for(c=e.bl_count[v];c!==0;)f=e.heap[--l],!(f>a)&&(i[f*2+1]!==v&&(e.opt_len+=(v-i[f*2+1])*i[f*2],i[f*2+1]=v),c--)}}function ly(e,t,i){var a=new Array(Gr+1),r=0,n,o;for(n=1;n<=Gr;n++)a[n]=r=r+i[n-1]<<1;for(o=0;o<=t;o++){var s=e[o*2+1];s!==0&&(e[o*2]=sy(a[s]++,s))}}function QA(){var e,t,i,a,r,n=new Array(Gr+1);for(i=0,a=0;a>=7;a8?Bn(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0}function JA(e,t,i,a){uy(e),a&&(Bn(e,i),Bn(e,~i)),HA.arraySet(e.pending_buf,e.window,t,i,e.pending),e.pending+=i}function sv(e,t,i,a){var r=t*2,n=i*2;return e[r]>1;o>=1;o--)Ec(e,i,o);l=n;do o=e.heap[1],e.heap[1]=e.heap[e.heap_len--],Ec(e,i,1),s=e.heap[1],e.heap[--e.heap_max]=o,e.heap[--e.heap_max]=s,i[l*2]=i[o*2]+i[s*2],e.depth[l]=(e.depth[o]>=e.depth[s]?e.depth[o]:e.depth[s])+1,i[o*2+1]=i[s*2+1]=l,e.heap[1]=l++,Ec(e,i,1);while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],ZA(e,t),ly(i,h,e.bl_count)}function cv(e,t,i){var a,r=-1,n,o=t[0*2+1],s=0,h=7,l=4;for(o===0&&(h=138,l=3),t[(i+1)*2+1]=65535,a=0;a<=i;a++)n=o,o=t[(a+1)*2+1],!(++s=3&&e.bl_tree[iy[t]*2+1]===0;t--);return e.opt_len+=3*(t+1)+5+5+4,t}function tS(e,t,i,a){var r;for(Yt(e,t-257,5),Yt(e,i-1,5),Yt(e,a-4,4),r=0;r>>=1)if(t&1&&e.dyn_ltree[i*2]!==0)return nv;if(e.dyn_ltree[9*2]!==0||e.dyn_ltree[10*2]!==0||e.dyn_ltree[13*2]!==0)return ov;for(i=32;i0?(e.strm.data_type===WA&&(e.strm.data_type=iS(e)),Gc(e,e.l_desc),Gc(e,e.d_desc),o=eS(e),r=e.opt_len+3+7>>>3,n=e.static_len+3+7>>>3,n<=r&&(r=n)):r=n=i+5,i+4<=r&&t!==-1?hy(e,t,i,a):e.strategy===UA||n===r?(Yt(e,(Zg<<1)+(a?1:0),3),lv(e,rr,En)):(Yt(e,(jA<<1)+(a?1:0),3),tS(e,e.l_desc.max_code+1,e.d_desc.max_code+1,o+1),lv(e,e.dyn_ltree,e.dyn_dtree)),cy(e),a&&uy(e)}function oS(e,t,i){return e.pending_buf[e.d_buf+e.last_lit*2]=t>>>8&255,e.pending_buf[e.d_buf+e.last_lit*2+1]=t&255,e.pending_buf[e.l_buf+e.last_lit]=i&255,e.last_lit++,t===0?e.dyn_ltree[i*2]++:(e.matches++,t--,e.dyn_ltree[(Mn[i]+Un+1)*2]++,e.dyn_dtree[oy(t)*2]++),e.last_lit===e.lit_bufsize-1}Ka._tr_init=rS;Ka._tr_stored_block=hy;Ka._tr_flush_block=nS;Ka._tr_tally=oS;Ka._tr_align=aS;function sS(e,t,i,a){for(var r=e&65535|0,n=e>>>16&65535|0,o=0;i!==0;){o=i>2e3?2e3:i,i-=o;do r=r+t[a++]|0,n=n+r|0;while(--o);r%=65521,n%=65521}return r|n<<16|0}var fy=sS;function lS(){for(var e,t=[],i=0;i<256;i++){e=i;for(var a=0;a<8;a++)e=e&1?3988292384^e>>>1:e>>>1;t[i]=e}return t}var cS=lS();function uS(e,t,i,a){var r=cS,n=a+i;e^=-1;for(var o=a;o>>8^r[(e^t[o])&255];return e^-1}var dy=uS,bu={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},Nt=cr,yi=Ka,vy=fy,_r=dy,hS=bu,la=0,fS=1,dS=3,Pr=4,fv=5,zi=0,dv=1,mi=-2,vS=-3,kc=-5,gS=-1,yS=1,qo=2,mS=3,pS=4,wS=0,bS=2,Cs=8,_S=9,xS=15,ES=8,kS=29,CS=256,Xc=CS+1+kS,AS=30,SS=19,TS=2*Xc+1,RS=15,He=3,Sr=258,Ci=Sr+He+1,PS=32,As=42,Zc=69,is=73,rs=91,as=103,Xr=113,pn=666,mt=1,Wn=2,ia=3,$a=4,IS=3;function Tr(e,t){return e.msg=hS[t],t}function vv(e){return(e<<1)-(e>4?9:0)}function Ar(e){for(var t=e.length;--t>=0;)e[t]=0}function xr(e){var t=e.state,i=t.pending;i>e.avail_out&&(i=e.avail_out),i!==0&&(Nt.arraySet(e.output,t.pending_buf,t.pending_out,i,e.next_out),e.next_out+=i,t.pending_out+=i,e.total_out+=i,e.avail_out-=i,t.pending-=i,t.pending===0&&(t.pending_out=0))}function St(e,t){yi._tr_flush_block(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,xr(e.strm)}function Ue(e,t){e.pending_buf[e.pending++]=t}function gn(e,t){e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=t&255}function LS(e,t,i,a){var r=e.avail_in;return r>a&&(r=a),r===0?0:(e.avail_in-=r,Nt.arraySet(t,e.input,e.next_in,r,i),e.state.wrap===1?e.adler=vy(e.adler,t,r,i):e.state.wrap===2&&(e.adler=_r(e.adler,t,r,i)),e.next_in+=r,e.total_in+=r,r)}function gy(e,t){var i=e.max_chain_length,a=e.strstart,r,n,o=e.prev_length,s=e.nice_match,h=e.strstart>e.w_size-Ci?e.strstart-(e.w_size-Ci):0,l=e.window,c=e.w_mask,f=e.prev,v=e.strstart+Sr,g=l[a+o-1],y=l[a+o];e.prev_length>=e.good_match&&(i>>=2),s>e.lookahead&&(s=e.lookahead);do if(r=t,!(l[r+o]!==y||l[r+o-1]!==g||l[r]!==l[a]||l[++r]!==l[a+1])){a+=2,r++;do;while(l[++a]===l[++r]&&l[++a]===l[++r]&&l[++a]===l[++r]&&l[++a]===l[++r]&&l[++a]===l[++r]&&l[++a]===l[++r]&&l[++a]===l[++r]&&l[++a]===l[++r]&&ao){if(e.match_start=t,o=n,n>=s)break;g=l[a+o-1],y=l[a+o]}}while((t=f[t&c])>h&&--i!==0);return o<=e.lookahead?o:e.lookahead}function ra(e){var t=e.w_size,i,a,r,n,o;do{if(n=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-Ci)){Nt.arraySet(e.window,e.window,t,t,0),e.match_start-=t,e.strstart-=t,e.block_start-=t,a=e.hash_size,i=a;do r=e.head[--i],e.head[i]=r>=t?r-t:0;while(--a);a=t,i=a;do r=e.prev[--i],e.prev[i]=r>=t?r-t:0;while(--a);n+=t}if(e.strm.avail_in===0)break;if(a=LS(e.strm,e.window,e.strstart+e.lookahead,n),e.lookahead+=a,e.lookahead+e.insert>=He)for(o=e.strstart-e.insert,e.ins_h=e.window[o],e.ins_h=(e.ins_h<e.pending_buf_size-5&&(i=e.pending_buf_size-5);;){if(e.lookahead<=1){if(ra(e),e.lookahead===0&&t===la)return mt;if(e.lookahead===0)break}e.strstart+=e.lookahead,e.lookahead=0;var a=e.block_start+i;if((e.strstart===0||e.strstart>=a)&&(e.lookahead=e.strstart-a,e.strstart=a,St(e,!1),e.strm.avail_out===0)||e.strstart-e.block_start>=e.w_size-Ci&&(St(e,!1),e.strm.avail_out===0))return mt}return e.insert=0,t===Pr?(St(e,!0),e.strm.avail_out===0?ia:$a):(e.strstart>e.block_start&&(St(e,!1),e.strm.avail_out===0),mt)}function Cc(e,t){for(var i,a;;){if(e.lookahead=He&&(e.ins_h=(e.ins_h<=He)if(a=yi._tr_tally(e,e.strstart-e.match_start,e.match_length-He),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=He){e.match_length--;do e.strstart++,e.ins_h=(e.ins_h<=He&&(e.ins_h=(e.ins_h<4096)&&(e.match_length=He-1)),e.prev_length>=He&&e.match_length<=e.prev_length){r=e.strstart+e.lookahead-He,a=yi._tr_tally(e,e.strstart-1-e.prev_match,e.prev_length-He),e.lookahead-=e.prev_length-1,e.prev_length-=2;do++e.strstart<=r&&(e.ins_h=(e.ins_h<=He&&e.strstart>0&&(r=e.strstart-1,a=o[r],a===o[++r]&&a===o[++r]&&a===o[++r])){n=e.strstart+Sr;do;while(a===o[++r]&&a===o[++r]&&a===o[++r]&&a===o[++r]&&a===o[++r]&&a===o[++r]&&a===o[++r]&&a===o[++r]&&re.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=He?(i=yi._tr_tally(e,1,e.match_length-He),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(i=yi._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),i&&(St(e,!1),e.strm.avail_out===0))return mt}return e.insert=0,t===Pr?(St(e,!0),e.strm.avail_out===0?ia:$a):e.last_lit&&(St(e,!1),e.strm.avail_out===0)?mt:Wn}function BS(e,t){for(var i;;){if(e.lookahead===0&&(ra(e),e.lookahead===0)){if(t===la)return mt;break}if(e.match_length=0,i=yi._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,i&&(St(e,!1),e.strm.avail_out===0))return mt}return e.insert=0,t===Pr?(St(e,!0),e.strm.avail_out===0?ia:$a):e.last_lit&&(St(e,!1),e.strm.avail_out===0)?mt:Wn}function Bi(e,t,i,a,r){this.good_length=e,this.max_lazy=t,this.nice_length=i,this.max_chain=a,this.func=r}var Na;Na=[new Bi(0,0,0,0,DS),new Bi(4,4,8,4,Cc),new Bi(4,5,16,8,Cc),new Bi(4,6,32,32,Cc),new Bi(4,4,16,16,Ra),new Bi(8,16,32,32,Ra),new Bi(8,16,128,128,Ra),new Bi(8,32,128,256,Ra),new Bi(32,128,258,1024,Ra),new Bi(32,258,258,4096,Ra)];function OS(e){e.window_size=2*e.w_size,Ar(e.head),e.max_lazy_match=Na[e.level].max_lazy,e.good_match=Na[e.level].good_length,e.nice_match=Na[e.level].nice_length,e.max_chain_length=Na[e.level].max_chain,e.strstart=0,e.block_start=0,e.lookahead=0,e.insert=0,e.match_length=e.prev_length=He-1,e.match_available=0,e.ins_h=0}function NS(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=Cs,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Nt.Buf16(TS*2),this.dyn_dtree=new Nt.Buf16((2*AS+1)*2),this.bl_tree=new Nt.Buf16((2*SS+1)*2),Ar(this.dyn_ltree),Ar(this.dyn_dtree),Ar(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Nt.Buf16(RS+1),this.heap=new Nt.Buf16(2*Xc+1),Ar(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Nt.Buf16(2*Xc+1),Ar(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function yy(e){var t;return!e||!e.state?Tr(e,mi):(e.total_in=e.total_out=0,e.data_type=bS,t=e.state,t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=t.wrap?As:Xr,e.adler=t.wrap===2?0:1,t.last_flush=la,yi._tr_init(t),zi)}function my(e){var t=yy(e);return t===zi&&OS(e.state),t}function FS(e,t){return!e||!e.state||e.state.wrap!==2?mi:(e.state.gzhead=t,zi)}function py(e,t,i,a,r,n){if(!e)return mi;var o=1;if(t===gS&&(t=6),a<0?(o=0,a=-a):a>15&&(o=2,a-=16),r<1||r>_S||i!==Cs||a<8||a>15||t<0||t>9||n<0||n>pS)return Tr(e,mi);a===8&&(a=9);var s=new NS;return e.state=s,s.strm=e,s.wrap=o,s.gzhead=null,s.w_bits=a,s.w_size=1<fv||t<0)return e?Tr(e,mi):mi;if(a=e.state,!e.output||!e.input&&e.avail_in!==0||a.status===pn&&t!==Pr)return Tr(e,e.avail_out===0?kc:mi);if(a.strm=e,i=a.last_flush,a.last_flush=t,a.status===As)if(a.wrap===2)e.adler=0,Ue(a,31),Ue(a,139),Ue(a,8),a.gzhead?(Ue(a,(a.gzhead.text?1:0)+(a.gzhead.hcrc?2:0)+(a.gzhead.extra?4:0)+(a.gzhead.name?8:0)+(a.gzhead.comment?16:0)),Ue(a,a.gzhead.time&255),Ue(a,a.gzhead.time>>8&255),Ue(a,a.gzhead.time>>16&255),Ue(a,a.gzhead.time>>24&255),Ue(a,a.level===9?2:a.strategy>=qo||a.level<2?4:0),Ue(a,a.gzhead.os&255),a.gzhead.extra&&a.gzhead.extra.length&&(Ue(a,a.gzhead.extra.length&255),Ue(a,a.gzhead.extra.length>>8&255)),a.gzhead.hcrc&&(e.adler=_r(e.adler,a.pending_buf,a.pending,0)),a.gzindex=0,a.status=Zc):(Ue(a,0),Ue(a,0),Ue(a,0),Ue(a,0),Ue(a,0),Ue(a,a.level===9?2:a.strategy>=qo||a.level<2?4:0),Ue(a,IS),a.status=Xr);else{var o=Cs+(a.w_bits-8<<4)<<8,s=-1;a.strategy>=qo||a.level<2?s=0:a.level<6?s=1:a.level===6?s=2:s=3,o|=s<<6,a.strstart!==0&&(o|=PS),o+=31-o%31,a.status=Xr,gn(a,o),a.strstart!==0&&(gn(a,e.adler>>>16),gn(a,e.adler&65535)),e.adler=1}if(a.status===Zc)if(a.gzhead.extra){for(r=a.pending;a.gzindex<(a.gzhead.extra.length&65535)&&!(a.pending===a.pending_buf_size&&(a.gzhead.hcrc&&a.pending>r&&(e.adler=_r(e.adler,a.pending_buf,a.pending-r,r)),xr(e),r=a.pending,a.pending===a.pending_buf_size));)Ue(a,a.gzhead.extra[a.gzindex]&255),a.gzindex++;a.gzhead.hcrc&&a.pending>r&&(e.adler=_r(e.adler,a.pending_buf,a.pending-r,r)),a.gzindex===a.gzhead.extra.length&&(a.gzindex=0,a.status=is)}else a.status=is;if(a.status===is)if(a.gzhead.name){r=a.pending;do{if(a.pending===a.pending_buf_size&&(a.gzhead.hcrc&&a.pending>r&&(e.adler=_r(e.adler,a.pending_buf,a.pending-r,r)),xr(e),r=a.pending,a.pending===a.pending_buf_size)){n=1;break}a.gzindexr&&(e.adler=_r(e.adler,a.pending_buf,a.pending-r,r)),n===0&&(a.gzindex=0,a.status=rs)}else a.status=rs;if(a.status===rs)if(a.gzhead.comment){r=a.pending;do{if(a.pending===a.pending_buf_size&&(a.gzhead.hcrc&&a.pending>r&&(e.adler=_r(e.adler,a.pending_buf,a.pending-r,r)),xr(e),r=a.pending,a.pending===a.pending_buf_size)){n=1;break}a.gzindexr&&(e.adler=_r(e.adler,a.pending_buf,a.pending-r,r)),n===0&&(a.status=as)}else a.status=as;if(a.status===as&&(a.gzhead.hcrc?(a.pending+2>a.pending_buf_size&&xr(e),a.pending+2<=a.pending_buf_size&&(Ue(a,e.adler&255),Ue(a,e.adler>>8&255),e.adler=0,a.status=Xr)):a.status=Xr),a.pending!==0){if(xr(e),e.avail_out===0)return a.last_flush=-1,zi}else if(e.avail_in===0&&vv(t)<=vv(i)&&t!==Pr)return Tr(e,kc);if(a.status===pn&&e.avail_in!==0)return Tr(e,kc);if(e.avail_in!==0||a.lookahead!==0||t!==la&&a.status!==pn){var h=a.strategy===qo?BS(a,t):a.strategy===mS?MS(a,t):Na[a.level].func(a,t);if((h===ia||h===$a)&&(a.status=pn),h===mt||h===ia)return e.avail_out===0&&(a.last_flush=-1),zi;if(h===Wn&&(t===fS?yi._tr_align(a):t!==fv&&(yi._tr_stored_block(a,0,0,!1),t===dS&&(Ar(a.head),a.lookahead===0&&(a.strstart=0,a.block_start=0,a.insert=0))),xr(e),e.avail_out===0))return a.last_flush=-1,zi}return t!==Pr?zi:a.wrap<=0?dv:(a.wrap===2?(Ue(a,e.adler&255),Ue(a,e.adler>>8&255),Ue(a,e.adler>>16&255),Ue(a,e.adler>>24&255),Ue(a,e.total_in&255),Ue(a,e.total_in>>8&255),Ue(a,e.total_in>>16&255),Ue(a,e.total_in>>24&255)):(gn(a,e.adler>>>16),gn(a,e.adler&65535)),xr(e),a.wrap>0&&(a.wrap=-a.wrap),a.pending!==0?zi:dv)}function US(e){var t;return!e||!e.state?mi:(t=e.state.status,t!==As&&t!==Zc&&t!==is&&t!==rs&&t!==as&&t!==Xr&&t!==pn?Tr(e,mi):(e.state=null,t===Xr?Tr(e,vS):zi))}function WS(e,t){var i=t.length,a,r,n,o,s,h,l,c;if(!e||!e.state||(a=e.state,o=a.wrap,o===2||o===1&&a.status!==As||a.lookahead))return mi;for(o===1&&(e.adler=vy(e.adler,t,i,0)),a.wrap=0,i>=a.w_size&&(o===0&&(Ar(a.head),a.strstart=0,a.block_start=0,a.insert=0),c=new Nt.Buf8(a.w_size),Nt.arraySet(c,t,i-a.w_size,a.w_size,0),t=c,i=a.w_size),s=e.avail_in,h=e.next_in,l=e.input,e.avail_in=i,e.next_in=0,e.input=t,ra(a);a.lookahead>=He;){r=a.strstart,n=a.lookahead-(He-1);do a.ins_h=(a.ins_h<=252?6:br>=248?5:br>=240?4:br>=224?3:br>=192?2:1;On[254]=On[254]=1;ca.string2buf=function(e){var t,i,a,r,n,o=e.length,s=0;for(r=0;r>>6,t[n++]=128|i&63):i<65536?(t[n++]=224|i>>>12,t[n++]=128|i>>>6&63,t[n++]=128|i&63):(t[n++]=240|i>>>18,t[n++]=128|i>>>12&63,t[n++]=128|i>>>6&63,t[n++]=128|i&63);return t};function _y(e,t){if(t<65534&&(e.subarray&&by||!e.subarray&&wy))return String.fromCharCode.apply(null,Ss.shrinkBuf(e,t));for(var i="",a=0;a4){s[a++]=65533,i+=n-1;continue}for(r&=n===2?31:n===3?15:7;n>1&&i1){s[a++]=65533;continue}r<65536?s[a++]=r:(r-=65536,s[a++]=55296|r>>10&1023,s[a++]=56320|r&1023)}return _y(s,a)};ca.utf8border=function(e,t){var i;for(t=t||e.length,t>e.length&&(t=e.length),i=t-1;i>=0&&(e[i]&192)===128;)i--;return i<0||i===0?t:i+On[e[i]]>t?i:t};function qS(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}var xy=qS,kn=Wi,Cn=cr,Qc=ca,Jc=bu,jS=xy,Ey=Object.prototype.toString,KS=0,Ac=4,Ha=0,gv=1,yv=2,VS=-1,$S=0,YS=8;function aa(e){if(!(this instanceof aa))return new aa(e);this.options=Cn.assign({level:VS,method:YS,chunkSize:16384,windowBits:15,memLevel:8,strategy:$S,to:""},e||{});var t=this.options;t.raw&&t.windowBits>0?t.windowBits=-t.windowBits:t.gzip&&t.windowBits>0&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new jS,this.strm.avail_out=0;var i=kn.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(i!==Ha)throw new Error(Jc[i]);if(t.header&&kn.deflateSetHeader(this.strm,t.header),t.dictionary){var a;if(typeof t.dictionary=="string"?a=Qc.string2buf(t.dictionary):Ey.call(t.dictionary)==="[object ArrayBuffer]"?a=new Uint8Array(t.dictionary):a=t.dictionary,i=kn.deflateSetDictionary(this.strm,a),i!==Ha)throw new Error(Jc[i]);this._dict_set=!0}}aa.prototype.push=function(e,t){var i=this.strm,a=this.options.chunkSize,r,n;if(this.ended)return!1;n=t===~~t?t:t===!0?Ac:KS,typeof e=="string"?i.input=Qc.string2buf(e):Ey.call(e)==="[object ArrayBuffer]"?i.input=new Uint8Array(e):i.input=e,i.next_in=0,i.avail_in=i.input.length;do{if(i.avail_out===0&&(i.output=new Cn.Buf8(a),i.next_out=0,i.avail_out=a),r=kn.deflate(i,n),r!==gv&&r!==Ha)return this.onEnd(r),this.ended=!0,!1;(i.avail_out===0||i.avail_in===0&&(n===Ac||n===yv))&&(this.options.to==="string"?this.onData(Qc.buf2binstring(Cn.shrinkBuf(i.output,i.next_out))):this.onData(Cn.shrinkBuf(i.output,i.next_out)))}while((i.avail_in>0||i.avail_out===0)&&r!==gv);return n===Ac?(r=kn.deflateEnd(this.strm),this.onEnd(r),this.ended=!0,r===Ha):(n===yv&&(this.onEnd(Ha),i.avail_out=0),!0)};aa.prototype.onData=function(e){this.chunks.push(e)};aa.prototype.onEnd=function(e){e===Ha&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=Cn.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};function _u(e,t){var i=new aa(t);if(i.push(e,!0),i.err)throw i.msg||Jc[i.err];return i.result}function GS(e,t){return t=t||{},t.raw=!0,_u(e,t)}function XS(e,t){return t=t||{},t.gzip=!0,_u(e,t)}Hn.Deflate=aa;Hn.deflate=_u;Hn.deflateRaw=GS;Hn.gzip=XS;var qn={},Si={},jo=30,ZS=12,QS=function(t,i){var a,r,n,o,s,h,l,c,f,v,g,y,p,m,b,x,_,k,I,P,M,L,U,$,S;a=t.state,r=t.next_in,$=t.input,n=r+(t.avail_in-5),o=t.next_out,S=t.output,s=o-(i-t.avail_out),h=o+(t.avail_out-257),l=a.dmax,c=a.wsize,f=a.whave,v=a.wnext,g=a.window,y=a.hold,p=a.bits,m=a.lencode,b=a.distcode,x=(1<>>24,y>>>=I,p-=I,I=k>>>16&255,I===0)S[o++]=k&65535;else if(I&16){P=k&65535,I&=15,I&&(p>>=I,p-=I),p<15&&(y+=$[r++]<>>24,y>>>=I,p-=I,I=k>>>16&255,I&16){if(M=k&65535,I&=15,pl){t.msg="invalid distance too far back",a.mode=jo;break e}if(y>>>=I,p-=I,I=o-s,M>I){if(I=M-I,I>f&&a.sane){t.msg="invalid distance too far back",a.mode=jo;break e}if(L=0,U=g,v===0){if(L+=c-I,I2;)S[o++]=U[L++],S[o++]=U[L++],S[o++]=U[L++],P-=3;P&&(S[o++]=U[L++],P>1&&(S[o++]=U[L++]))}else{L=o-M;do S[o++]=S[L++],S[o++]=S[L++],S[o++]=S[L++],P-=3;while(P>2);P&&(S[o++]=S[L++],P>1&&(S[o++]=S[L++]))}}else if((I&64)===0){k=b[(k&65535)+(y&(1<>3,r-=P,p-=P<<3,y&=(1<=1&&T[g]===0;g--);if(y>g&&(y=g),g===0)return n[o++]=1<<24|64<<16|0,n[o++]=1<<24|64<<16|0,h.bits=1,0;for(v=1;v0&&(t===bv||g!==1))return-1;for(R[1]=0,c=1;cpv||t===_v&&x>wv)return 1;for(;;){G=c-m,s[f]S?(ae=O[K+s[f]],V=U[$+s[f]]):(ae=32+64,V=0),k=1<>m)+I]=G<<24|ae<<16|V|0;while(I!==0);for(k=1<>=1;if(k!==0?(_&=k-1,_+=k):_=0,f++,--T[c]===0){if(c===g)break;c=i[a+s[f]]}if(c>y&&(_&M)!==P){for(m===0&&(m=y),L+=v,p=c-m,b=1<pv||t===_v&&x>wv)return 1;P=_&M,n[P]=y<<24|p<<16|L-o|0}}return _!==0&&(n[L+_]=c-m<<24|64<<16|0),h.bits=y,0},ni=cr,eu=fy,Oi=dy,aT=QS,An=rT,nT=0,ky=1,Cy=2,xv=4,oT=5,Ko=6,na=0,sT=1,lT=2,pi=-2,Ay=-3,Sy=-4,cT=-5,Ev=8,Ty=1,kv=2,Cv=3,Av=4,Sv=5,Tv=6,Rv=7,Pv=8,Iv=9,Lv=10,ps=11,er=12,Tc=13,Dv=14,Rc=15,Mv=16,Bv=17,Ov=18,Nv=19,Vo=20,$o=21,Fv=22,zv=23,Hv=24,Uv=25,Wv=26,Pc=27,qv=28,jv=29,nt=30,Ry=31,uT=32,hT=852,fT=592,dT=15,vT=dT;function Kv(e){return(e>>>24&255)+(e>>>8&65280)+((e&65280)<<8)+((e&255)<<24)}function gT(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new ni.Buf16(320),this.work=new ni.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function Py(e){var t;return!e||!e.state?pi:(t=e.state,e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=t.wrap&1),t.mode=Ty,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new ni.Buf32(hT),t.distcode=t.distdyn=new ni.Buf32(fT),t.sane=1,t.back=-1,na)}function Iy(e){var t;return!e||!e.state?pi:(t=e.state,t.wsize=0,t.whave=0,t.wnext=0,Py(e))}function Ly(e,t){var i,a;return!e||!e.state||(a=e.state,t<0?(i=0,t=-t):(i=(t>>4)+1,t<48&&(t&=15)),t&&(t<8||t>15))?pi:(a.window!==null&&a.wbits!==t&&(a.window=null),a.wrap=i,a.wbits=t,Iy(e))}function Dy(e,t){var i,a;return e?(a=new gT,e.state=a,a.window=null,i=Ly(e,t),i!==na&&(e.state=null),i):pi}function yT(e){return Dy(e,vT)}var Vv=!0,Ic,Lc;function mT(e){if(Vv){var t;for(Ic=new ni.Buf32(512),Lc=new ni.Buf32(32),t=0;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(An(ky,e.lens,0,288,Ic,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;An(Cy,e.lens,0,32,Lc,0,e.work,{bits:5}),Vv=!1}e.lencode=Ic,e.lenbits=9,e.distcode=Lc,e.distbits=5}function My(e,t,i,a){var r,n=e.state;return n.window===null&&(n.wsize=1<=n.wsize?(ni.arraySet(n.window,t,i-n.wsize,n.wsize,0),n.wnext=0,n.whave=n.wsize):(r=n.wsize-n.wnext,r>a&&(r=a),ni.arraySet(n.window,t,i-a,r,n.wnext),a-=r,a?(ni.arraySet(n.window,t,i-a,a,0),n.wnext=a,n.whave=n.wsize):(n.wnext+=r,n.wnext===n.wsize&&(n.wnext=0),n.whave>>8&255,i.check=Oi(i.check,U,2,0),l=0,c=0,i.mode=kv;break}if(i.flags=0,i.head&&(i.head.done=!1),!(i.wrap&1)||(((l&255)<<8)+(l>>8))%31){e.msg="incorrect header check",i.mode=nt;break}if((l&15)!==Ev){e.msg="unknown compression method",i.mode=nt;break}if(l>>>=4,c-=4,M=(l&15)+8,i.wbits===0)i.wbits=M;else if(M>i.wbits){e.msg="invalid window size",i.mode=nt;break}i.dmax=1<>8&1),i.flags&512&&(U[0]=l&255,U[1]=l>>>8&255,i.check=Oi(i.check,U,2,0)),l=0,c=0,i.mode=Cv;case Cv:for(;c<32;){if(s===0)break e;s--,l+=a[n++]<>>8&255,U[2]=l>>>16&255,U[3]=l>>>24&255,i.check=Oi(i.check,U,4,0)),l=0,c=0,i.mode=Av;case Av:for(;c<16;){if(s===0)break e;s--,l+=a[n++]<>8),i.flags&512&&(U[0]=l&255,U[1]=l>>>8&255,i.check=Oi(i.check,U,2,0)),l=0,c=0,i.mode=Sv;case Sv:if(i.flags&1024){for(;c<16;){if(s===0)break e;s--,l+=a[n++]<>>8&255,i.check=Oi(i.check,U,2,0)),l=0,c=0}else i.head&&(i.head.extra=null);i.mode=Tv;case Tv:if(i.flags&1024&&(g=i.length,g>s&&(g=s),g&&(i.head&&(M=i.head.extra_len-i.length,i.head.extra||(i.head.extra=new Array(i.head.extra_len)),ni.arraySet(i.head.extra,a,n,g,M)),i.flags&512&&(i.check=Oi(i.check,a,g,n)),s-=g,n+=g,i.length-=g),i.length))break e;i.length=0,i.mode=Rv;case Rv:if(i.flags&2048){if(s===0)break e;g=0;do M=a[n+g++],i.head&&M&&i.length<65536&&(i.head.name+=String.fromCharCode(M));while(M&&g>9&1,i.head.done=!0),e.adler=i.check=0,i.mode=er;break;case Lv:for(;c<32;){if(s===0)break e;s--,l+=a[n++]<>>=c&7,c-=c&7,i.mode=Pc;break}for(;c<3;){if(s===0)break e;s--,l+=a[n++]<>>=1,c-=1,l&3){case 0:i.mode=Dv;break;case 1:if(mT(i),i.mode=Vo,t===Ko){l>>>=2,c-=2;break e}break;case 2:i.mode=Bv;break;case 3:e.msg="invalid block type",i.mode=nt}l>>>=2,c-=2;break;case Dv:for(l>>>=c&7,c-=c&7;c<32;){if(s===0)break e;s--,l+=a[n++]<>>16^65535)){e.msg="invalid stored block lengths",i.mode=nt;break}if(i.length=l&65535,l=0,c=0,i.mode=Rc,t===Ko)break e;case Rc:i.mode=Mv;case Mv:if(g=i.length,g){if(g>s&&(g=s),g>h&&(g=h),g===0)break e;ni.arraySet(r,a,n,g,o),s-=g,n+=g,h-=g,o+=g,i.length-=g;break}i.mode=er;break;case Bv:for(;c<14;){if(s===0)break e;s--,l+=a[n++]<>>=5,c-=5,i.ndist=(l&31)+1,l>>>=5,c-=5,i.ncode=(l&15)+4,l>>>=4,c-=4,i.nlen>286||i.ndist>30){e.msg="too many length or distance symbols",i.mode=nt;break}i.have=0,i.mode=Ov;case Ov:for(;i.have>>=3,c-=3}for(;i.have<19;)i.lens[T[i.have++]]=0;if(i.lencode=i.lendyn,i.lenbits=7,$={bits:i.lenbits},L=An(nT,i.lens,0,19,i.lencode,0,i.work,$),i.lenbits=$.bits,L){e.msg="invalid code lengths set",i.mode=nt;break}i.have=0,i.mode=Nv;case Nv:for(;i.have>>24,x=m>>>16&255,_=m&65535,!(b<=c);){if(s===0)break e;s--,l+=a[n++]<>>=b,c-=b,i.lens[i.have++]=_;else{if(_===16){for(S=b+2;c>>=b,c-=b,i.have===0){e.msg="invalid bit length repeat",i.mode=nt;break}M=i.lens[i.have-1],g=3+(l&3),l>>>=2,c-=2}else if(_===17){for(S=b+3;c>>=b,c-=b,M=0,g=3+(l&7),l>>>=3,c-=3}else{for(S=b+7;c>>=b,c-=b,M=0,g=11+(l&127),l>>>=7,c-=7}if(i.have+g>i.nlen+i.ndist){e.msg="invalid bit length repeat",i.mode=nt;break}for(;g--;)i.lens[i.have++]=M}}if(i.mode===nt)break;if(i.lens[256]===0){e.msg="invalid code -- missing end-of-block",i.mode=nt;break}if(i.lenbits=9,$={bits:i.lenbits},L=An(ky,i.lens,0,i.nlen,i.lencode,0,i.work,$),i.lenbits=$.bits,L){e.msg="invalid literal/lengths set",i.mode=nt;break}if(i.distbits=6,i.distcode=i.distdyn,$={bits:i.distbits},L=An(Cy,i.lens,i.nlen,i.ndist,i.distcode,0,i.work,$),i.distbits=$.bits,L){e.msg="invalid distances set",i.mode=nt;break}if(i.mode=Vo,t===Ko)break e;case Vo:i.mode=$o;case $o:if(s>=6&&h>=258){e.next_out=o,e.avail_out=h,e.next_in=n,e.avail_in=s,i.hold=l,i.bits=c,aT(e,v),o=e.next_out,r=e.output,h=e.avail_out,n=e.next_in,a=e.input,s=e.avail_in,l=i.hold,c=i.bits,i.mode===er&&(i.back=-1);break}for(i.back=0;m=i.lencode[l&(1<>>24,x=m>>>16&255,_=m&65535,!(b<=c);){if(s===0)break e;s--,l+=a[n++]<>k)],b=m>>>24,x=m>>>16&255,_=m&65535,!(k+b<=c);){if(s===0)break e;s--,l+=a[n++]<>>=k,c-=k,i.back+=k}if(l>>>=b,c-=b,i.back+=b,i.length=_,x===0){i.mode=Wv;break}if(x&32){i.back=-1,i.mode=er;break}if(x&64){e.msg="invalid literal/length code",i.mode=nt;break}i.extra=x&15,i.mode=Fv;case Fv:if(i.extra){for(S=i.extra;c>>=i.extra,c-=i.extra,i.back+=i.extra}i.was=i.length,i.mode=zv;case zv:for(;m=i.distcode[l&(1<>>24,x=m>>>16&255,_=m&65535,!(b<=c);){if(s===0)break e;s--,l+=a[n++]<>k)],b=m>>>24,x=m>>>16&255,_=m&65535,!(k+b<=c);){if(s===0)break e;s--,l+=a[n++]<>>=k,c-=k,i.back+=k}if(l>>>=b,c-=b,i.back+=b,x&64){e.msg="invalid distance code",i.mode=nt;break}i.offset=_,i.extra=x&15,i.mode=Hv;case Hv:if(i.extra){for(S=i.extra;c>>=i.extra,c-=i.extra,i.back+=i.extra}if(i.offset>i.dmax){e.msg="invalid distance too far back",i.mode=nt;break}i.mode=Uv;case Uv:if(h===0)break e;if(g=v-h,i.offset>g){if(g=i.offset-g,g>i.whave&&i.sane){e.msg="invalid distance too far back",i.mode=nt;break}g>i.wnext?(g-=i.wnext,y=i.wsize-g):y=i.wnext-g,g>i.length&&(g=i.length),p=i.window}else p=r,y=o-i.offset,g=i.length;g>h&&(g=h),h-=g,i.length-=g;do r[o++]=p[y++];while(--g);i.length===0&&(i.mode=$o);break;case Wv:if(h===0)break e;r[o++]=i.length,h--,i.mode=$o;break;case Pc:if(i.wrap){for(;c<32;){if(s===0)break e;s--,l|=a[n++]<=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,t.windowBits===0&&(t.windowBits=-15)),t.windowBits>=0&&t.windowBits<16&&!(e&&e.windowBits)&&(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&(t.windowBits&15)===0&&(t.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new kT,this.strm.avail_out=0;var i=Ua.inflateInit2(this.strm,t.windowBits);if(i!==ft.Z_OK)throw new Error(tu[i]);if(this.header=new CT,Ua.inflateGetHeader(this.strm,this.header),t.dictionary&&(typeof t.dictionary=="string"?t.dictionary=ns.string2buf(t.dictionary):Oy.call(t.dictionary)==="[object ArrayBuffer]"&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(i=Ua.inflateSetDictionary(this.strm,t.dictionary),i!==ft.Z_OK)))throw new Error(tu[i])}oa.prototype.push=function(e,t){var i=this.strm,a=this.options.chunkSize,r=this.options.dictionary,n,o,s,h,l,c=!1;if(this.ended)return!1;o=t===~~t?t:t===!0?ft.Z_FINISH:ft.Z_NO_FLUSH,typeof e=="string"?i.input=ns.binstring2buf(e):Oy.call(e)==="[object ArrayBuffer]"?i.input=new Uint8Array(e):i.input=e,i.next_in=0,i.avail_in=i.input.length;do{if(i.avail_out===0&&(i.output=new Sn.Buf8(a),i.next_out=0,i.avail_out=a),n=Ua.inflate(i,ft.Z_NO_FLUSH),n===ft.Z_NEED_DICT&&r&&(n=Ua.inflateSetDictionary(this.strm,r)),n===ft.Z_BUF_ERROR&&c===!0&&(n=ft.Z_OK,c=!1),n!==ft.Z_STREAM_END&&n!==ft.Z_OK)return this.onEnd(n),this.ended=!0,!1;i.next_out&&(i.avail_out===0||n===ft.Z_STREAM_END||i.avail_in===0&&(o===ft.Z_FINISH||o===ft.Z_SYNC_FLUSH))&&(this.options.to==="string"?(s=ns.utf8border(i.output,i.next_out),h=i.next_out-s,l=ns.buf2string(i.output,s),i.next_out=h,i.avail_out=a-h,h&&Sn.arraySet(i.output,i.output,s,h,0),this.onData(l)):this.onData(Sn.shrinkBuf(i.output,i.next_out))),i.avail_in===0&&i.avail_out===0&&(c=!0)}while((i.avail_in>0||i.avail_out===0)&&n!==ft.Z_STREAM_END);return n===ft.Z_STREAM_END&&(o=ft.Z_FINISH),o===ft.Z_FINISH?(n=Ua.inflateEnd(this.strm),this.onEnd(n),this.ended=!0,n===ft.Z_OK):(o===ft.Z_SYNC_FLUSH&&(this.onEnd(ft.Z_OK),i.avail_out=0),!0)};oa.prototype.onData=function(e){this.chunks.push(e)};oa.prototype.onEnd=function(e){e===ft.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=Sn.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};function xu(e,t){var i=new oa(t);if(i.push(e,!0),i.err)throw i.msg||tu[i.err];return i.result}function AT(e,t){return t=t||{},t.raw=!0,xu(e,t)}qn.Inflate=oa;qn.inflate=xu;qn.inflateRaw=AT;qn.ungzip=xu;var ST=cr.assign,TT=Hn,RT=qn,PT=By,Ny={};ST(Ny,TT,RT,PT);var VT=Ny,iu={exports:{}};/** * @license * Lodash * Copyright OpenJS Foundation and other contributors * Released under MIT license * Based on Underscore.js 1.8.3 * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors */(function(e,t){(function(){var i,a="4.17.21",r=200,n="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",o="Expected a function",s="Invalid `variable` option passed into `_.template`",h="__lodash_hash_undefined__",l=500,c="__lodash_placeholder__",f=1,v=2,g=4,y=1,p=2,m=1,b=2,x=4,_=8,k=16,I=32,P=64,M=128,L=256,U=512,$=30,S="...",T=800,R=16,O=1,K=2,G=3,ae=1/0,V=9007199254740991,F=17976931348623157e292,q=0/0,Y=4294967295,W=Y-1,J=Y>>>1,re=[["ary",M],["bind",m],["bindKey",b],["curry",_],["curryRight",k],["flip",U],["partial",I],["partialRight",P],["rearg",L]],ee="[object Arguments]",he="[object Array]",le="[object AsyncFunction]",se="[object Boolean]",E="[object Date]",C="[object DOMException]",D="[object Error]",H="[object Function]",X="[object GeneratorFunction]",Q="[object Map]",ne="[object Number]",ye="[object Null]",ge="[object Object]",xe="[object Promise]",Se="[object Proxy]",xt="[object RegExp]",it="[object Set]",Et="[object String]",qe="[object Symbol]",Qe="[object Undefined]",Ti="[object WeakMap]",Fy="[object WeakSet]",Ya="[object ArrayBuffer]",ua="[object DataView]",Ts="[object Float32Array]",Rs="[object Float64Array]",Ps="[object Int8Array]",Is="[object Int16Array]",Ls="[object Int32Array]",Ds="[object Uint8Array]",Ms="[object Uint8ClampedArray]",Bs="[object Uint16Array]",Os="[object Uint32Array]",zy=/\b__p \+= '';/g,Hy=/\b(__p \+=) '' \+/g,Uy=/(__e\(.*?\)|\b__t\)) \+\n'';/g,Eu=/&(?:amp|lt|gt|quot|#39);/g,ku=/[&<>"']/g,Wy=RegExp(Eu.source),qy=RegExp(ku.source),jy=/<%-([\s\S]+?)%>/g,Ky=/<%([\s\S]+?)%>/g,Cu=/<%=([\s\S]+?)%>/g,Vy=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,$y=/^\w*$/,Yy=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Ns=/[\\^$.*+?()[\]{}|]/g,Gy=RegExp(Ns.source),Fs=/^\s+/,Xy=/\s/,Zy=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,Qy=/\{\n\/\* \[wrapped with (.+)\] \*/,Jy=/,? & /,e0=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,t0=/[()=,{}\[\]\/\s]/,i0=/\\(\\)?/g,r0=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,Au=/\w*$/,a0=/^[-+]0x[0-9a-f]+$/i,n0=/^0b[01]+$/i,o0=/^\[object .+?Constructor\]$/,s0=/^0o[0-7]+$/i,l0=/^(?:0|[1-9]\d*)$/,c0=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,jn=/($^)/,u0=/['\n\r\u2028\u2029\\]/g,Kn="\\ud800-\\udfff",h0="\\u0300-\\u036f",f0="\\ufe20-\\ufe2f",d0="\\u20d0-\\u20ff",Su=h0+f0+d0,Tu="\\u2700-\\u27bf",Ru="a-z\\xdf-\\xf6\\xf8-\\xff",v0="\\xac\\xb1\\xd7\\xf7",g0="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",y0="\\u2000-\\u206f",m0=" \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",Pu="A-Z\\xc0-\\xd6\\xd8-\\xde",Iu="\\ufe0e\\ufe0f",Lu=v0+g0+y0+m0,zs="['\u2019]",p0="["+Kn+"]",Du="["+Lu+"]",Vn="["+Su+"]",Mu="\\d+",w0="["+Tu+"]",Bu="["+Ru+"]",Ou="[^"+Kn+Lu+Mu+Tu+Ru+Pu+"]",Hs="\\ud83c[\\udffb-\\udfff]",b0="(?:"+Vn+"|"+Hs+")",Nu="[^"+Kn+"]",Us="(?:\\ud83c[\\udde6-\\uddff]){2}",Ws="[\\ud800-\\udbff][\\udc00-\\udfff]",ha="["+Pu+"]",Fu="\\u200d",zu="(?:"+Bu+"|"+Ou+")",_0="(?:"+ha+"|"+Ou+")",Hu="(?:"+zs+"(?:d|ll|m|re|s|t|ve))?",Uu="(?:"+zs+"(?:D|LL|M|RE|S|T|VE))?",Wu=b0+"?",qu="["+Iu+"]?",x0="(?:"+Fu+"(?:"+[Nu,Us,Ws].join("|")+")"+qu+Wu+")*",E0="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",k0="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",ju=qu+Wu+x0,C0="(?:"+[w0,Us,Ws].join("|")+")"+ju,A0="(?:"+[Nu+Vn+"?",Vn,Us,Ws,p0].join("|")+")",S0=RegExp(zs,"g"),T0=RegExp(Vn,"g"),qs=RegExp(Hs+"(?="+Hs+")|"+A0+ju,"g"),R0=RegExp([ha+"?"+Bu+"+"+Hu+"(?="+[Du,ha,"$"].join("|")+")",_0+"+"+Uu+"(?="+[Du,ha+zu,"$"].join("|")+")",ha+"?"+zu+"+"+Hu,ha+"+"+Uu,k0,E0,Mu,C0].join("|"),"g"),P0=RegExp("["+Fu+Kn+Su+Iu+"]"),I0=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,L0=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],D0=-1,et={};et[Ts]=et[Rs]=et[Ps]=et[Is]=et[Ls]=et[Ds]=et[Ms]=et[Bs]=et[Os]=!0,et[ee]=et[he]=et[Ya]=et[se]=et[ua]=et[E]=et[D]=et[H]=et[Q]=et[ne]=et[ge]=et[xt]=et[it]=et[Et]=et[Ti]=!1;var Je={};Je[ee]=Je[he]=Je[Ya]=Je[ua]=Je[se]=Je[E]=Je[Ts]=Je[Rs]=Je[Ps]=Je[Is]=Je[Ls]=Je[Q]=Je[ne]=Je[ge]=Je[xt]=Je[it]=Je[Et]=Je[qe]=Je[Ds]=Je[Ms]=Je[Bs]=Je[Os]=!0,Je[D]=Je[H]=Je[Ti]=!1;var M0={\u00C0:"A",\u00C1:"A",\u00C2:"A",\u00C3:"A",\u00C4:"A",\u00C5:"A",\u00E0:"a",\u00E1:"a",\u00E2:"a",\u00E3:"a",\u00E4:"a",\u00E5:"a",\u00C7:"C",\u00E7:"c",\u00D0:"D",\u00F0:"d",\u00C8:"E",\u00C9:"E",\u00CA:"E",\u00CB:"E",\u00E8:"e",\u00E9:"e",\u00EA:"e",\u00EB:"e",\u00CC:"I",\u00CD:"I",\u00CE:"I",\u00CF:"I",\u00EC:"i",\u00ED:"i",\u00EE:"i",\u00EF:"i",\u00D1:"N",\u00F1:"n",\u00D2:"O",\u00D3:"O",\u00D4:"O",\u00D5:"O",\u00D6:"O",\u00D8:"O",\u00F2:"o",\u00F3:"o",\u00F4:"o",\u00F5:"o",\u00F6:"o",\u00F8:"o",\u00D9:"U",\u00DA:"U",\u00DB:"U",\u00DC:"U",\u00F9:"u",\u00FA:"u",\u00FB:"u",\u00FC:"u",\u00DD:"Y",\u00FD:"y",\u00FF:"y",\u00C6:"Ae",\u00E6:"ae",\u00DE:"Th",\u00FE:"th",\u00DF:"ss",\u0100:"A",\u0102:"A",\u0104:"A",\u0101:"a",\u0103:"a",\u0105:"a",\u0106:"C",\u0108:"C",\u010A:"C",\u010C:"C",\u0107:"c",\u0109:"c",\u010B:"c",\u010D:"c",\u010E:"D",\u0110:"D",\u010F:"d",\u0111:"d",\u0112:"E",\u0114:"E",\u0116:"E",\u0118:"E",\u011A:"E",\u0113:"e",\u0115:"e",\u0117:"e",\u0119:"e",\u011B:"e",\u011C:"G",\u011E:"G",\u0120:"G",\u0122:"G",\u011D:"g",\u011F:"g",\u0121:"g",\u0123:"g",\u0124:"H",\u0126:"H",\u0125:"h",\u0127:"h",\u0128:"I",\u012A:"I",\u012C:"I",\u012E:"I",\u0130:"I",\u0129:"i",\u012B:"i",\u012D:"i",\u012F:"i",\u0131:"i",\u0134:"J",\u0135:"j",\u0136:"K",\u0137:"k",\u0138:"k",\u0139:"L",\u013B:"L",\u013D:"L",\u013F:"L",\u0141:"L",\u013A:"l",\u013C:"l",\u013E:"l",\u0140:"l",\u0142:"l",\u0143:"N",\u0145:"N",\u0147:"N",\u014A:"N",\u0144:"n",\u0146:"n",\u0148:"n",\u014B:"n",\u014C:"O",\u014E:"O",\u0150:"O",\u014D:"o",\u014F:"o",\u0151:"o",\u0154:"R",\u0156:"R",\u0158:"R",\u0155:"r",\u0157:"r",\u0159:"r",\u015A:"S",\u015C:"S",\u015E:"S",\u0160:"S",\u015B:"s",\u015D:"s",\u015F:"s",\u0161:"s",\u0162:"T",\u0164:"T",\u0166:"T",\u0163:"t",\u0165:"t",\u0167:"t",\u0168:"U",\u016A:"U",\u016C:"U",\u016E:"U",\u0170:"U",\u0172:"U",\u0169:"u",\u016B:"u",\u016D:"u",\u016F:"u",\u0171:"u",\u0173:"u",\u0174:"W",\u0175:"w",\u0176:"Y",\u0177:"y",\u0178:"Y",\u0179:"Z",\u017B:"Z",\u017D:"Z",\u017A:"z",\u017C:"z",\u017E:"z",\u0132:"IJ",\u0133:"ij",\u0152:"Oe",\u0153:"oe",\u0149:"'n",\u017F:"s"},B0={"&":"&","<":"<",">":">",'"':""","'":"'"},O0={"&":"&","<":"<",">":">",""":'"',"'":"'"},N0={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},F0=parseFloat,z0=parseInt,Ku=typeof Ot=="object"&&Ot&&Ot.Object===Object&&Ot,H0=typeof self=="object"&&self&&self.Object===Object&&self,kt=Ku||H0||Function("return this")(),js=t&&!t.nodeType&&t,Mr=js&&!0&&e&&!e.nodeType&&e,Vu=Mr&&Mr.exports===js,Ks=Vu&&Ku.process,si=function(){try{var te=Mr&&Mr.require&&Mr.require("util").types;return te||Ks&&Ks.binding&&Ks.binding("util")}catch{}}(),$u=si&&si.isArrayBuffer,Yu=si&&si.isDate,Gu=si&&si.isMap,Xu=si&&si.isRegExp,Zu=si&&si.isSet,Qu=si&&si.isTypedArray;function Xt(te,ue,oe){switch(oe.length){case 0:return te.call(ue);case 1:return te.call(ue,oe[0]);case 2:return te.call(ue,oe[0],oe[1]);case 3:return te.call(ue,oe[0],oe[1],oe[2])}return te.apply(ue,oe)}function U0(te,ue,oe,pe){for(var Te=-1,je=te==null?0:te.length;++Te-1}function Vs(te,ue,oe){for(var pe=-1,Te=te==null?0:te.length;++pe-1;);return oe}function oh(te,ue){for(var oe=te.length;oe--&&fa(ue,te[oe],0)>-1;);return oe}function X0(te,ue){for(var oe=te.length,pe=0;oe--;)te[oe]===ue&&++pe;return pe}var Z0=Xs(M0),Q0=Xs(B0);function J0(te){return"\\"+N0[te]}function em(te,ue){return te==null?i:te[ue]}function da(te){return P0.test(te)}function tm(te){return I0.test(te)}function im(te){for(var ue,oe=[];!(ue=te.next()).done;)oe.push(ue.value);return oe}function el(te){var ue=-1,oe=Array(te.size);return te.forEach(function(pe,Te){oe[++ue]=[Te,pe]}),oe}function sh(te,ue){return function(oe){return te(ue(oe))}}function fr(te,ue){for(var oe=-1,pe=te.length,Te=0,je=[];++oe-1}function qm(u,d){var w=this.__data__,A=uo(w,u);return A<0?(++this.size,w.push([u,d])):w[A][1]=d,this}qi.prototype.clear=zm,qi.prototype.delete=Hm,qi.prototype.get=Um,qi.prototype.has=Wm,qi.prototype.set=qm;function ji(u){var d=-1,w=u==null?0:u.length;for(this.clear();++d=d?u:d)),u}function hi(u,d,w,A,B,z){var j,Z=d&f,ie=d&v,fe=d&g;if(w&&(j=B?w(u,A,B,z):w(u)),j!==i)return j;if(!st(u))return u;var de=Re(u);if(de){if(j=$p(u),!Z)return zt(u,j)}else{var ve=Rt(u),me=ve==H||ve==X;if(pr(u))return qh(u,Z);if(ve==ge||ve==ee||me&&!B){if(j=ie||me?{}:cf(u),!Z)return ie?Op(u,np(j,u)):Bp(u,wh(j,u))}else{if(!Je[ve])return B?u:{};j=Yp(u,ve,Z)}}z||(z=new bi);var _e=z.get(u);if(_e)return _e;z.set(u,j),Ff(u)?u.forEach(function(Ae){j.add(hi(Ae,d,w,Ae,u,z))}):Of(u)&&u.forEach(function(Ae,Be){j.set(Be,hi(Ae,d,w,Be,u,z))});var Ce=fe?ie?Al:Cl:ie?Ut:pt,Le=de?i:Ce(u);return li(Le||u,function(Ae,Be){Le&&(Be=Ae,Ae=u[Be]),tn(j,Be,hi(Ae,d,w,Be,u,z))}),j}function op(u){var d=pt(u);return function(w){return bh(w,u,d)}}function bh(u,d,w){var A=w.length;if(u==null)return!A;for(u=Xe(u);A--;){var B=w[A],z=d[B],j=u[B];if(j===i&&!(B in u)||!z(j))return!1}return!0}function _h(u,d,w){if(typeof u!="function")throw new ci(o);return cn(function(){u.apply(i,w)},d)}function rn(u,d,w,A){var B=-1,z=$n,j=!0,Z=u.length,ie=[],fe=d.length;if(!Z)return ie;w&&(d=rt(d,Zt(w))),A?(z=Vs,j=!1):d.length>=r&&(z=Ga,j=!1,d=new Nr(d));e:for(;++BB?0:B+w),A=A===i||A>B?B:Ie(A),A<0&&(A+=B),A=w>A?0:Hf(A);w0&&w(Z)?d>1?Ct(Z,d-1,w,A,B):hr(B,Z):A||(B[B.length]=Z)}return B}var sl=Gh(),kh=Gh(!0);function Ri(u,d){return u&&sl(u,d,pt)}function ll(u,d){return u&&kh(u,d,pt)}function fo(u,d){return ur(d,function(w){return Gi(u[w])})}function zr(u,d){d=yr(d,u);for(var w=0,A=d.length;u!=null&&wd}function cp(u,d){return u!=null&&$e.call(u,d)}function up(u,d){return u!=null&&d in Xe(u)}function hp(u,d,w){return u>=Tt(d,w)&&u=120&&de.length>=120)?new Nr(j&&de):i}de=u[0];var ve=-1,me=Z[0];e:for(;++ve-1;)Z!==u&&ro.call(Z,ie,1),ro.call(u,ie,1);return u}function Bh(u,d){for(var w=u?d.length:0,A=w-1;w--;){var B=d[w];if(w==A||B!==z){var z=B;Yi(B)?ro.call(u,B,1):pl(u,B)}}return u}function gl(u,d){return u+oo(gh()*(d-u+1))}function kp(u,d,w,A){for(var B=-1,z=yt(no((d-u)/(w||1)),0),j=oe(z);z--;)j[A?z:++B]=u,u+=w;return j}function yl(u,d){var w="";if(!u||d<1||d>V)return w;do d%2&&(w+=u),d=oo(d/2),d&&(u+=u);while(d);return w}function De(u,d){return Dl(ff(u,d,Wt),u+"")}function Cp(u){return ph(ka(u))}function Ap(u,d){var w=ka(u);return ko(w,Fr(d,0,w.length))}function on(u,d,w,A){if(!st(u))return u;d=yr(d,u);for(var B=-1,z=d.length,j=z-1,Z=u;Z!=null&&++BB?0:B+d),w=w>B?B:w,w<0&&(w+=B),B=d>w?0:w-d>>>0,d>>>=0;for(var z=oe(B);++A>>1,j=u[z];j!==null&&!Jt(j)&&(w?j<=d:j=r){var fe=d?null:Hp(u);if(fe)return Gn(fe);j=!1,B=Ga,ie=new Nr}else ie=d?[]:Z;e:for(;++A=A?u:fi(u,d,w)}var Wh=mm||function(u){return kt.clearTimeout(u)};function qh(u,d){if(d)return u.slice();var w=u.length,A=uh?uh(w):new u.constructor(w);return u.copy(A),A}function xl(u){var d=new u.constructor(u.byteLength);return new to(d).set(new to(u)),d}function Ip(u,d){var w=d?xl(u.buffer):u.buffer;return new u.constructor(w,u.byteOffset,u.byteLength)}function Lp(u){var d=new u.constructor(u.source,Au.exec(u));return d.lastIndex=u.lastIndex,d}function Dp(u){return en?Xe(en.call(u)):{}}function jh(u,d){var w=d?xl(u.buffer):u.buffer;return new u.constructor(w,u.byteOffset,u.length)}function Kh(u,d){if(u!==d){var w=u!==i,A=u===null,B=u===u,z=Jt(u),j=d!==i,Z=d===null,ie=d===d,fe=Jt(d);if(!Z&&!fe&&!z&&u>d||z&&j&&ie&&!Z&&!fe||A&&j&&ie||!w&&ie||!B)return 1;if(!A&&!z&&!fe&&u=Z)return ie;var fe=w[A];return ie*(fe=="desc"?-1:1)}}return u.index-d.index}function Vh(u,d,w,A){for(var B=-1,z=u.length,j=w.length,Z=-1,ie=d.length,fe=yt(z-j,0),de=oe(ie+fe),ve=!A;++Z1?w[B-1]:i,j=B>2?w[2]:i;for(z=u.length>3&&typeof z=="function"?(B--,z):i,j&&Mt(w[0],w[1],j)&&(z=B<3?i:z,B=1),d=Xe(d);++A-1?B[z?d[j]:j]:i}}function Qh(u){return $i(function(d){var w=d.length,A=w,B=ui.prototype.thru;for(u&&d.reverse();A--;){var z=d[A];if(typeof z!="function")throw new ci(o);if(B&&!j&&xo(z)=="wrapper")var j=new ui([],!0)}for(A=j?A:w;++A1&&Fe.reverse(),de&&ieZ))return!1;var fe=z.get(u),de=z.get(d);if(fe&&de)return fe==d&&de==u;var ve=-1,me=!0,_e=w&p?new Nr:i;for(z.set(u,d),z.set(d,u);++ve1?"& ":"")+d[A],d=d.join(w>2?", ":" "),u.replace(Zy,`{ /* [wrapped with `+d+`] */ `)}function Xp(u){return Re(u)||Wr(u)||!!(dh&&u&&u[dh])}function Yi(u,d){var w=typeof u;return d=d==null?V:d,!!d&&(w=="number"||w!="symbol"&&l0.test(u))&&u>-1&&u%1==0&&u0){if(++d>=T)return arguments[0]}else d=0;return u.apply(i,arguments)}}function ko(u,d){var w=-1,A=u.length,B=A-1;for(d=d===i?A:d;++w1?u[d-1]:i;return w=typeof w=="function"?(u.pop(),w):i,kf(u,w)});function Cf(u){var d=N(u);return d.__chain__=!0,d}function sb(u,d){return d(u),u}function Co(u,d){return d(u)}var lb=$i(function(u){var d=u.length,w=d?u[0]:0,A=this.__wrapped__,B=function(z){return ol(z,u)};return d>1||this.__actions__.length||!(A instanceof Oe)||!Yi(w)?this.thru(B):(A=A.slice(w,+w+(d?1:0)),A.__actions__.push({func:Co,args:[B],thisArg:i}),new ui(A,this.__chain__).thru(function(z){return d&&!z.length&&z.push(i),z}))});function cb(){return Cf(this)}function ub(){return new ui(this.value(),this.__chain__)}function hb(){this.__values__===i&&(this.__values__=zf(this.value()));var u=this.__index__>=this.__values__.length,d=u?i:this.__values__[this.__index__++];return{done:u,value:d}}function fb(){return this}function db(u){for(var d,w=this;w instanceof co;){var A=pf(w);A.__index__=0,A.__values__=i,d?B.__wrapped__=A:d=A;var B=A;w=w.__wrapped__}return B.__wrapped__=u,d}function vb(){var u=this.__wrapped__;if(u instanceof Oe){var d=u;return this.__actions__.length&&(d=new Oe(this)),d=d.reverse(),d.__actions__.push({func:Co,args:[Ml],thisArg:i}),new ui(d,this.__chain__)}return this.thru(Ml)}function gb(){return Hh(this.__wrapped__,this.__actions__)}var yb=mo(function(u,d,w){$e.call(u,w)?++u[w]:Ki(u,w,1)});function mb(u,d,w){var A=Re(u)?Ju:sp;return w&&Mt(u,d,w)&&(d=i),A(u,Ee(d,3))}function pb(u,d){var w=Re(u)?ur:Eh;return w(u,Ee(d,3))}var wb=Zh(wf),bb=Zh(bf);function _b(u,d){return Ct(Ao(u,d),1)}function xb(u,d){return Ct(Ao(u,d),ae)}function Eb(u,d,w){return w=w===i?1:Ie(w),Ct(Ao(u,d),w)}function Af(u,d){var w=Re(u)?li:vr;return w(u,Ee(d,3))}function Sf(u,d){var w=Re(u)?W0:xh;return w(u,Ee(d,3))}var kb=mo(function(u,d,w){$e.call(u,w)?u[w].push(d):Ki(u,w,[d])});function Cb(u,d,w,A){u=Ht(u)?u:ka(u),w=w&&!A?Ie(w):0;var B=u.length;return w<0&&(w=yt(B+w,0)),Io(u)?w<=B&&u.indexOf(d,w)>-1:!!B&&fa(u,d,w)>-1}var Ab=De(function(u,d,w){var A=-1,B=typeof d=="function",z=Ht(u)?oe(u.length):[];return vr(u,function(j){z[++A]=B?Xt(d,j,w):an(j,d,w)}),z}),Sb=mo(function(u,d,w){Ki(u,w,d)});function Ao(u,d){var w=Re(u)?rt:Rh;return w(u,Ee(d,3))}function Tb(u,d,w,A){return u==null?[]:(Re(d)||(d=d==null?[]:[d]),w=A?i:w,Re(w)||(w=w==null?[]:[w]),Dh(u,d,w))}var Rb=mo(function(u,d,w){u[w?0:1].push(d)},function(){return[[],[]]});function Pb(u,d,w){var A=Re(u)?$s:rh,B=arguments.length<3;return A(u,Ee(d,4),w,B,vr)}function Ib(u,d,w){var A=Re(u)?q0:rh,B=arguments.length<3;return A(u,Ee(d,4),w,B,xh)}function Lb(u,d){var w=Re(u)?ur:Eh;return w(u,Ro(Ee(d,3)))}function Db(u){var d=Re(u)?ph:Cp;return d(u)}function Mb(u,d,w){(w?Mt(u,d,w):d===i)?d=1:d=Ie(d);var A=Re(u)?ip:Ap;return A(u,d)}function Bb(u){var d=Re(u)?rp:Tp;return d(u)}function Ob(u){if(u==null)return 0;if(Ht(u))return Io(u)?va(u):u.length;var d=Rt(u);return d==Q||d==it?u.size:fl(u).length}function Nb(u,d,w){var A=Re(u)?Ys:Rp;return w&&Mt(u,d,w)&&(d=i),A(u,Ee(d,3))}var Fb=De(function(u,d){if(u==null)return[];var w=d.length;return w>1&&Mt(u,d[0],d[1])?d=[]:w>2&&Mt(d[0],d[1],d[2])&&(d=[d[0]]),Dh(u,Ct(d,1),[])}),So=pm||function(){return kt.Date.now()};function zb(u,d){if(typeof d!="function")throw new ci(o);return u=Ie(u),function(){if(--u<1)return d.apply(this,arguments)}}function Tf(u,d,w){return d=w?i:d,d=u&&d==null?u.length:d,Vi(u,M,i,i,i,i,d)}function Rf(u,d){var w;if(typeof d!="function")throw new ci(o);return u=Ie(u),function(){return--u>0&&(w=d.apply(this,arguments)),u<=1&&(d=i),w}}var Ol=De(function(u,d,w){var A=m;if(w.length){var B=fr(w,xa(Ol));A|=I}return Vi(u,A,d,w,B)}),Pf=De(function(u,d,w){var A=m|b;if(w.length){var B=fr(w,xa(Pf));A|=I}return Vi(d,A,u,w,B)});function If(u,d,w){d=w?i:d;var A=Vi(u,_,i,i,i,i,i,d);return A.placeholder=If.placeholder,A}function Lf(u,d,w){d=w?i:d;var A=Vi(u,k,i,i,i,i,i,d);return A.placeholder=Lf.placeholder,A}function Df(u,d,w){var A,B,z,j,Z,ie,fe=0,de=!1,ve=!1,me=!0;if(typeof u!="function")throw new ci(o);d=vi(d)||0,st(w)&&(de=!!w.leading,ve="maxWait"in w,z=ve?yt(vi(w.maxWait)||0,d):z,me="trailing"in w?!!w.trailing:me);function _e(ht){var xi=A,Zi=B;return A=B=i,fe=ht,j=u.apply(Zi,xi),j}function Ce(ht){return fe=ht,Z=cn(Be,d),de?_e(ht):j}function Le(ht){var xi=ht-ie,Zi=ht-fe,Qf=d-xi;return ve?Tt(Qf,z-Zi):Qf}function Ae(ht){var xi=ht-ie,Zi=ht-fe;return ie===i||xi>=d||xi<0||ve&&Zi>=z}function Be(){var ht=So();if(Ae(ht))return Fe(ht);Z=cn(Be,Le(ht))}function Fe(ht){return Z=i,me&&A?_e(ht):(A=B=i,j)}function ei(){Z!==i&&Wh(Z),fe=0,A=ie=B=Z=i}function Bt(){return Z===i?j:Fe(So())}function ti(){var ht=So(),xi=Ae(ht);if(A=arguments,B=this,ie=ht,xi){if(Z===i)return Ce(ie);if(ve)return Wh(Z),Z=cn(Be,d),_e(ie)}return Z===i&&(Z=cn(Be,d)),j}return ti.cancel=ei,ti.flush=Bt,ti}var Hb=De(function(u,d){return _h(u,1,d)}),Ub=De(function(u,d,w){return _h(u,vi(d)||0,w)});function Wb(u){return Vi(u,U)}function To(u,d){if(typeof u!="function"||d!=null&&typeof d!="function")throw new ci(o);var w=function(){var A=arguments,B=d?d.apply(this,A):A[0],z=w.cache;if(z.has(B))return z.get(B);var j=u.apply(this,A);return w.cache=z.set(B,j)||z,j};return w.cache=new(To.Cache||ji),w}To.Cache=ji;function Ro(u){if(typeof u!="function")throw new ci(o);return function(){var d=arguments;switch(d.length){case 0:return!u.call(this);case 1:return!u.call(this,d[0]);case 2:return!u.call(this,d[0],d[1]);case 3:return!u.call(this,d[0],d[1],d[2])}return!u.apply(this,d)}}function qb(u){return Rf(2,u)}var jb=Pp(function(u,d){d=d.length==1&&Re(d[0])?rt(d[0],Zt(Ee())):rt(Ct(d,1),Zt(Ee()));var w=d.length;return De(function(A){for(var B=-1,z=Tt(A.length,w);++B=d}),Wr=Ah(function(){return arguments}())?Ah:function(u){return ct(u)&&$e.call(u,"callee")&&!fh.call(u,"callee")},Re=oe.isArray,n1=$u?Zt($u):dp;function Ht(u){return u!=null&&Po(u.length)&&!Gi(u)}function ut(u){return ct(u)&&Ht(u)}function o1(u){return u===!0||u===!1||ct(u)&&Dt(u)==se}var pr=bm||Yl,s1=Yu?Zt(Yu):vp;function l1(u){return ct(u)&&u.nodeType===1&&!un(u)}function c1(u){if(u==null)return!0;if(Ht(u)&&(Re(u)||typeof u=="string"||typeof u.splice=="function"||pr(u)||Ea(u)||Wr(u)))return!u.length;var d=Rt(u);if(d==Q||d==it)return!u.size;if(ln(u))return!fl(u).length;for(var w in u)if($e.call(u,w))return!1;return!0}function u1(u,d){return nn(u,d)}function h1(u,d,w){w=typeof w=="function"?w:i;var A=w?w(u,d):i;return A===i?nn(u,d,i,w):!!A}function Fl(u){if(!ct(u))return!1;var d=Dt(u);return d==D||d==C||typeof u.message=="string"&&typeof u.name=="string"&&!un(u)}function f1(u){return typeof u=="number"&&vh(u)}function Gi(u){if(!st(u))return!1;var d=Dt(u);return d==H||d==X||d==le||d==Se}function Bf(u){return typeof u=="number"&&u==Ie(u)}function Po(u){return typeof u=="number"&&u>-1&&u%1==0&&u<=V}function st(u){var d=typeof u;return u!=null&&(d=="object"||d=="function")}function ct(u){return u!=null&&typeof u=="object"}var Of=Gu?Zt(Gu):yp;function d1(u,d){return u===d||hl(u,d,Tl(d))}function v1(u,d,w){return w=typeof w=="function"?w:i,hl(u,d,Tl(d),w)}function g1(u){return Nf(u)&&u!=+u}function y1(u){if(Jp(u))throw new Te(n);return Sh(u)}function m1(u){return u===null}function p1(u){return u==null}function Nf(u){return typeof u=="number"||ct(u)&&Dt(u)==ne}function un(u){if(!ct(u)||Dt(u)!=ge)return!1;var d=io(u);if(d===null)return!0;var w=$e.call(d,"constructor")&&d.constructor;return typeof w=="function"&&w instanceof w&&Qn.call(w)==vm}var zl=Xu?Zt(Xu):mp;function w1(u){return Bf(u)&&u>=-V&&u<=V}var Ff=Zu?Zt(Zu):pp;function Io(u){return typeof u=="string"||!Re(u)&&ct(u)&&Dt(u)==Et}function Jt(u){return typeof u=="symbol"||ct(u)&&Dt(u)==qe}var Ea=Qu?Zt(Qu):wp;function b1(u){return u===i}function _1(u){return ct(u)&&Rt(u)==Ti}function x1(u){return ct(u)&&Dt(u)==Fy}var E1=_o(dl),k1=_o(function(u,d){return u<=d});function zf(u){if(!u)return[];if(Ht(u))return Io(u)?wi(u):zt(u);if(Xa&&u[Xa])return im(u[Xa]());var d=Rt(u),w=d==Q?el:d==it?Gn:ka;return w(u)}function Xi(u){if(!u)return u===0?u:0;if(u=vi(u),u===ae||u===-ae){var d=u<0?-1:1;return d*F}return u===u?u:0}function Ie(u){var d=Xi(u),w=d%1;return d===d?w?d-w:d:0}function Hf(u){return u?Fr(Ie(u),0,Y):0}function vi(u){if(typeof u=="number")return u;if(Jt(u))return q;if(st(u)){var d=typeof u.valueOf=="function"?u.valueOf():u;u=st(d)?d+"":d}if(typeof u!="string")return u===0?u:+u;u=ah(u);var w=n0.test(u);return w||s0.test(u)?z0(u.slice(2),w?2:8):a0.test(u)?q:+u}function Uf(u){return Pi(u,Ut(u))}function C1(u){return u?Fr(Ie(u),-V,V):u===0?u:0}function Ve(u){return u==null?"":Qt(u)}var A1=ba(function(u,d){if(ln(d)||Ht(d)){Pi(d,pt(d),u);return}for(var w in d)$e.call(d,w)&&tn(u,w,d[w])}),Wf=ba(function(u,d){Pi(d,Ut(d),u)}),Lo=ba(function(u,d,w,A){Pi(d,Ut(d),u,A)}),S1=ba(function(u,d,w,A){Pi(d,pt(d),u,A)}),T1=$i(ol);function R1(u,d){var w=wa(u);return d==null?w:wh(w,d)}var P1=De(function(u,d){u=Xe(u);var w=-1,A=d.length,B=A>2?d[2]:i;for(B&&Mt(d[0],d[1],B)&&(A=1);++w1),z}),Pi(u,Al(u),w),A&&(w=hi(w,f|v|g,Up));for(var B=d.length;B--;)pl(w,d[B]);return w});function Y1(u,d){return jf(u,Ro(Ee(d)))}var G1=$i(function(u,d){return u==null?{}:xp(u,d)});function jf(u,d){if(u==null)return{};var w=rt(Al(u),function(A){return[A]});return d=Ee(d),Mh(u,w,function(A,B){return d(A,B[0])})}function X1(u,d,w){d=yr(d,u);var A=-1,B=d.length;for(B||(B=1,u=i);++Ad){var A=u;u=d,d=A}if(w||u%1||d%1){var B=gh();return Tt(u+B*(d-u+F0("1e-"+((B+"").length-1))),d)}return gl(u,d)}var s_=_a(function(u,d,w){return d=d.toLowerCase(),u+(w?$f(d):d)});function $f(u){return Wl(Ve(u).toLowerCase())}function Yf(u){return u=Ve(u),u&&u.replace(c0,Z0).replace(T0,"")}function l_(u,d,w){u=Ve(u),d=Qt(d);var A=u.length;w=w===i?A:Fr(Ie(w),0,A);var B=w;return w-=d.length,w>=0&&u.slice(w,B)==d}function c_(u){return u=Ve(u),u&&qy.test(u)?u.replace(ku,Q0):u}function u_(u){return u=Ve(u),u&&Gy.test(u)?u.replace(Ns,"\\$&"):u}var h_=_a(function(u,d,w){return u+(w?"-":"")+d.toLowerCase()}),f_=_a(function(u,d,w){return u+(w?" ":"")+d.toLowerCase()}),d_=Xh("toLowerCase");function v_(u,d,w){u=Ve(u),d=Ie(d);var A=d?va(u):0;if(!d||A>=d)return u;var B=(d-A)/2;return bo(oo(B),w)+u+bo(no(B),w)}function g_(u,d,w){u=Ve(u),d=Ie(d);var A=d?va(u):0;return d&&A>>0,w?(u=Ve(u),u&&(typeof d=="string"||d!=null&&!zl(d))&&(d=Qt(d),!d&&da(u))?mr(wi(u),0,w):u.split(d,w)):[]}var x_=_a(function(u,d,w){return u+(w?" ":"")+Wl(d)});function E_(u,d,w){return u=Ve(u),w=w==null?0:Fr(Ie(w),0,u.length),d=Qt(d),u.slice(w,w+d.length)==d}function k_(u,d,w){var A=N.templateSettings;w&&Mt(u,d,w)&&(d=i),u=Ve(u),d=Lo({},d,A,af);var B=Lo({},d.imports,A.imports,af),z=pt(B),j=Js(B,z),Z,ie,fe=0,de=d.interpolate||jn,ve="__p += '",me=tl((d.escape||jn).source+"|"+de.source+"|"+(de===Cu?r0:jn).source+"|"+(d.evaluate||jn).source+"|$","g"),_e="//# sourceURL="+($e.call(d,"sourceURL")?(d.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++D0+"]")+` `;u.replace(me,function(Ae,Be,Fe,ei,Bt,ti){return Fe||(Fe=ei),ve+=u.slice(fe,ti).replace(u0,J0),Be&&(Z=!0,ve+=`' + __e(`+Be+`) + '`),Bt&&(ie=!0,ve+=`'; `+Bt+`; __p += '`),Fe&&(ve+=`' + ((__t = (`+Fe+`)) == null ? '' : __t) + '`),fe=ti+Ae.length,Ae}),ve+=`'; `;var Ce=$e.call(d,"variable")&&d.variable;if(!Ce)ve=`with (obj) { `+ve+` } `;else if(t0.test(Ce))throw new Te(s);ve=(ie?ve.replace(zy,""):ve).replace(Hy,"$1").replace(Uy,"$1;"),ve="function("+(Ce||"obj")+`) { `+(Ce?"":`obj || (obj = {}); `)+"var __t, __p = ''"+(Z?", __e = _.escape":"")+(ie?`, __j = Array.prototype.join; function print() { __p += __j.call(arguments, '') } `:`; `)+ve+`return __p }`;var Le=Xf(function(){return je(z,_e+"return "+ve).apply(i,j)});if(Le.source=ve,Fl(Le))throw Le;return Le}function C_(u){return Ve(u).toLowerCase()}function A_(u){return Ve(u).toUpperCase()}function S_(u,d,w){if(u=Ve(u),u&&(w||d===i))return ah(u);if(!u||!(d=Qt(d)))return u;var A=wi(u),B=wi(d),z=nh(A,B),j=oh(A,B)+1;return mr(A,z,j).join("")}function T_(u,d,w){if(u=Ve(u),u&&(w||d===i))return u.slice(0,lh(u)+1);if(!u||!(d=Qt(d)))return u;var A=wi(u),B=oh(A,wi(d))+1;return mr(A,0,B).join("")}function R_(u,d,w){if(u=Ve(u),u&&(w||d===i))return u.replace(Fs,"");if(!u||!(d=Qt(d)))return u;var A=wi(u),B=nh(A,wi(d));return mr(A,B).join("")}function P_(u,d){var w=$,A=S;if(st(d)){var B="separator"in d?d.separator:B;w="length"in d?Ie(d.length):w,A="omission"in d?Qt(d.omission):A}u=Ve(u);var z=u.length;if(da(u)){var j=wi(u);z=j.length}if(w>=z)return u;var Z=w-va(A);if(Z<1)return A;var ie=j?mr(j,0,Z).join(""):u.slice(0,Z);if(B===i)return ie+A;if(j&&(Z+=ie.length-Z),zl(B)){if(u.slice(Z).search(B)){var fe,de=ie;for(B.global||(B=tl(B.source,Ve(Au.exec(B))+"g")),B.lastIndex=0;fe=B.exec(de);)var ve=fe.index;ie=ie.slice(0,ve===i?Z:ve)}}else if(u.indexOf(Qt(B),Z)!=Z){var me=ie.lastIndexOf(B);me>-1&&(ie=ie.slice(0,me))}return ie+A}function I_(u){return u=Ve(u),u&&Wy.test(u)?u.replace(Eu,om):u}var L_=_a(function(u,d,w){return u+(w?" ":"")+d.toUpperCase()}),Wl=Xh("toUpperCase");function Gf(u,d,w){return u=Ve(u),d=w?i:d,d===i?tm(u)?cm(u):V0(u):u.match(d)||[]}var Xf=De(function(u,d){try{return Xt(u,i,d)}catch(w){return Fl(w)?w:new Te(w)}}),D_=$i(function(u,d){return li(d,function(w){w=Ii(w),Ki(u,w,Ol(u[w],u))}),u});function M_(u){var d=u==null?0:u.length,w=Ee();return u=d?rt(u,function(A){if(typeof A[1]!="function")throw new ci(o);return[w(A[0]),A[1]]}):[],De(function(A){for(var B=-1;++BV)return[];var w=Y,A=Tt(u,Y);d=Ee(d),u-=Y;for(var B=Qs(A,d);++w0||d<0)?new Oe(w):(u<0?w=w.takeRight(-u):u&&(w=w.drop(u)),d!==i&&(d=Ie(d),w=d<0?w.dropRight(-d):w.take(d-u)),w)},Oe.prototype.takeRightWhile=function(u){return this.reverse().takeWhile(u).reverse()},Oe.prototype.toArray=function(){return this.take(Y)},Ri(Oe.prototype,function(u,d){var w=/^(?:filter|find|map|reject)|While$/.test(d),A=/^(?:head|last)$/.test(d),B=N[A?"take"+(d=="last"?"Right":""):d],z=A||/^find/.test(d);!B||(N.prototype[d]=function(){var j=this.__wrapped__,Z=A?[1]:arguments,ie=j instanceof Oe,fe=Z[0],de=ie||Re(j),ve=function(Be){var Fe=B.apply(N,hr([Be],Z));return A&&me?Fe[0]:Fe};de&&w&&typeof fe=="function"&&fe.length!=1&&(ie=de=!1);var me=this.__chain__,_e=!!this.__actions__.length,Ce=z&&!me,Le=ie&&!_e;if(!z&&de){j=Le?j:new Oe(this);var Ae=u.apply(j,Z);return Ae.__actions__.push({func:Co,args:[ve],thisArg:i}),new ui(Ae,me)}return Ce&&Le?u.apply(this,Z):(Ae=this.thru(ve),Ce?A?Ae.value()[0]:Ae.value():Ae)})}),li(["pop","push","shift","sort","splice","unshift"],function(u){var d=Xn[u],w=/^(?:push|sort|unshift)$/.test(u)?"tap":"thru",A=/^(?:pop|shift)$/.test(u);N.prototype[u]=function(){var B=arguments;if(A&&!this.__chain__){var z=this.value();return d.apply(Re(z)?z:[],B)}return this[w](function(j){return d.apply(Re(j)?j:[],B)})}}),Ri(Oe.prototype,function(u,d){var w=N[d];if(w){var A=w.name+"";$e.call(pa,A)||(pa[A]=[]),pa[A].push({name:d,func:w})}}),pa[po(i,b).name]=[{name:"wrapper",func:i}],Oe.prototype.clone=Im,Oe.prototype.reverse=Lm,Oe.prototype.value=Dm,N.prototype.at=lb,N.prototype.chain=cb,N.prototype.commit=ub,N.prototype.next=hb,N.prototype.plant=db,N.prototype.reverse=vb,N.prototype.toJSON=N.prototype.valueOf=N.prototype.value=gb,N.prototype.first=N.prototype.head,Xa&&(N.prototype[Xa]=fb),N},ga=um();Mr?((Mr.exports=ga)._=ga,js._=ga):kt._=ga}).call(Ot)})(iu,iu.exports);const $T=iu.exports;export{LT as M,$T as _,BT as a,FT as b,OT as c,MT as d,KT as e,DT as f,jT as g,WT as h,HT as i,UT as j,qT as k,VT as p,NT as s,zT as t};