import{J as Ot}from"./index.244ed889.js";function La(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 os(e,t){var i=e.x-t.x,a=e.y-t.y;return Math.sqrt(i*i+a*a)}function t_(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 cn(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 vf(e,t){return e.anchorId===t.anchorId&&e.connectTo===t.connectTo}function xo(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 Hr;(function(e){e[e.None=-1]="None",e[e.Document=0]="Document",e[e.Canvas=1]="Canvas"})(Hr||(Hr={}));var x_={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:Hr.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},k_={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"}}},$o=globalThis&&globalThis.__assign||function(){return $o=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 C_=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:$o({},x_),theme:$o({},k_),emitter:__(),bindDatas:{},bind:{},pensNetwork:{},cacheDatas:[],messageEvents:{},templatePens:{},globalTriggers:{}}},A_=function(e){return e===void 0&&(e="default"),Ee[e]||(Ee[e]=C_(),Ee[e].id=e),Ee[e]},T_=function(e,t){var i,a,r=e.data.template===t;if(r)try{for(var n=E_(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()},gf=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.")},S_=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},R_=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=yf(t.split(""),e);f[0]&&(o.push(f[0]),f.length>1&&Ll(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),Ll(o));break;case"break-all":default:var v=t.split(/[\n]/g),g=0;try{e:for(var y=gf(v),p=y.next();!p.done;p=y.next()){var m=p.value,b=e.whiteSpace==="break-all"?m.split(""):Fd(m),x=yf(b,e);if(x.length===0&&(x=[""]),e.ellipsis!=!1)try{for(var _=(r=void 0,gf(x)),E=_.next();!E.done;E=_.next()){var I=E.value;if(g++,g>c){Ll(o);break e}else o.push(I)}}catch(M){r={error:M}}finally{try{E&&!E.done&&(n=_.return)&&n.call(_)}finally{if(r)throw r.error}}else o.push.apply(o,R_([],S_(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,D){var U=Number(M);isNaN(U)||(o[D]=U.toFixed(P))}),e.calculative.textLines=o,o}function Fd(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 yf(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 ai={};function zd(e,t,i){if(!!ai[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=di(a.next,a)+90;else{var s=t.calculative.worldAnchors[1];if(!s)return;s.prev?o.rotate=di(s.prev,a)+90:o.rotate=di(s,a)+90}e.save(),e.beginPath(),e.setLineDash([]);var h=t.fromArrowColor||t.calculative.color;h&&(e.strokeStyle=h),ai[t.fromArrow](e,t,i,o),e.restore()}}function Hd(e,t,i){if(!(!ai[t.toArrow]||t.calculative.worldAnchors.length<2)){e.save();var a=Ue(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=di(a.prev,a)+90;else{var s=t.calculative.worldAnchors[t.calculative.worldAnchors.length-2];s.next?o.rotate=di(s.next,a)+90:o.rotate=di(s,a)+90}e.beginPath(),e.setLineDash([]);var h=t.toArrowColor||t.calculative.color;h&&(e.strokeStyle=h),ai[t.toArrow](e,t,i,o),e.restore()}}ai.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()};ai.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()};ai.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()};ai.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()};ai.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()};ai.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()};ai.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()};ai.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()};ai.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 L_=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 Zl(e){var t=parseInt,i=Math.round,a=e.length,r={};if(a>9){var n=L_(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=Zl(t),s=e<0,l=i&&i!="c"?Zl(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 Go(e,t){var i=Zl(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 un=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},D_=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 ko(e,t){if(isNaN(e)){console.warn("realValue not number");return}if(typeof t!="string"){console.warn("collection must be string");return}var i=un([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=un([+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 Ji=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=Dl(e[1])?e[0]:e[1],r=Dl(e[2])?e[0]:e[2],i=Dl(e[3])?a:e[3]);return[t,a,r,i]};function Dl(e){return e==null}var Wd=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())})},Ud=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},H_=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 W_(e,t){if(!e||!t)return!1;for(var i=ti(e);i;){if(i.id===t.id)return!0;i=ti(i)}return!1}function ti(e,t){if(!(!e||!e.parentId||!e.calculative)){var i=e.calculative.canvas.store,a=i.pens[e.parentId];return t&&ti(a,t)||a}}function mr(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,H_([],z_(mr(r,t)),!1)))}),i}function U_(e,t){var i=t.calculative,a=i.worldRect,r=i.gradientFromColor,n=i.gradientToColor,o=i.gradientAngle;return qd(e,a,r,n,o)}function q_(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 ea(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:G_(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 G_(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 X_(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=ea(t.calculative.lineGradientColors),f=c.angle,v=c.colors,g=wc(f,o,s);return l.forEach(function(y){Ge(y,f,h)}),ss(e,l,v,g)}function ss(e,t,i,a){var r=j_(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 Or(e,t,i){var a=[];t.calculative.gradientColorStop?a=t.calculative.gradientColorStop:(a=ea(t.calculative.lineGradientColors).colors,t.calculative.gradientColorStop=a),e.strokeStyle=ss(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 Z_(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?Co(e,t,a,n[n.length-1],i[r],i[r].curvePoints[0]):Co(e,t,a,i[r-1],i[r],i[r].curvePoints[0]);var o=er(a,i[r],i[r].curvePoints[0]);Or(e,t,[o,i[r].curvePoints[1]])}else Or(e,t,[i[r],i[r].curvePoints[0]]),Or(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=Ar({fontSize:s,fontWeight:o,fontFamily:h}),e.fillStyle=t.calculative.iconColor||Cr(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 Ar(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 Kr(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 tr(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 Nr(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(),Kr(e,t),t.calculative.rotate&&t.name!=="line"&&tr(e,t),(t.calculative.lineWidth>1||i)&&(e.lineWidth=t.calculative.lineWidth),yx(e,n,t);var h,l=!1,c=void 0;t.calculative.disabled?(c=t.disabledColor||n.options.disabledColor||Ft(.4,t.calculative.color||Zo(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===$e.Line?c=n.options.dockPenColor:h=Go(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=X_(e,t),t.calculative.lineGradient=v):v=ix(e,t):v=t.calculative.color||Zo(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===Da.Linear?t.calculative.gradientColors?t.calculative.gradient?y=t.calculative.gradient:(y=V_(e,t),t.calculative.gradient=y):y=U_(e,t):t.calculative.bkType===Da.Radial?t.calculative.gradientColors?t.calculative.radialGradient?y=t.calculative.radialGradient:(y=K_(e,t),t.calculative.radialGradient=y):y=q_(e,t):y=t.calculative.background||n.data.penBackground,e.fillStyle=h||y,h=!!y}if(Yd(e,t),$d(e,t),Vr(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?(Z_(e,t),ox(!0,e,t,n)):(Gd(!0,e,t,n,h),ev(e,t)),!(t.image&&t.calculative.img)&&t.calculative.icon&&Vd(e,t),(!o||!s)&&e.restore(),o&&!s&&Kr(e,t),!o&&s&&t.calculative.rotate&&t.name!=="line"&&tr(e,t,!0),jd(e,t),t.type===$e.Line&&t.fillTexts)try{for(var p=pn(t.fillTexts),m=p.next();!m.done;m=p.next()){var b=m.value;Kd(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 Yd(e,t){var i=t.lineCap||(t.type?"round":"square");i?e.lineCap=i:t.type&&(e.lineCap="round")}function $d(e,t){var i=t.lineJoin;i?e.lineJoin=i:t.type&&(e.lineJoin="round")}function Xo(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"&&tr(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||Zo(h),t.backgroundImage?t.calculative.backgroundImg&&(e.fillStyle=e.createPattern(t.calculative.backgroundImg,"repeat"),f=!0):(e.fillStyle=t.background,f=!!t.background)),Yd(e,t),$d(e,t),Vr(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),Gd(!1,e,t,h,f),ev(e,t),t.calculative.img?(e.save(),e.shadowColor="",e.shadowBlur=0,e.shadowOffsetX=0,e.shadowOffsetY=0,Sa(e,t),e.restore()):t.calculative.icon&&Vd(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"&&tr(e,t,!0),jd(e,t),t.type===$e.Line&&t.fillTexts)try{for(var v=pn(t.fillTexts),g=v.next();!g.done;g=v.next()){var y=g.value;Kd(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 Gd(e,t,i,a,r){e===void 0&&(e=!0);var n=e?a.path2dMap.get(i):Ee.path2dDraws[i.name];if(n){if(i.type===$e.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=ea(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(),Xd(t,i,a),i.lineAnimateType===ii.Arrow||i.lineAnimateType===ii.WaterDrop){var x=cv(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&&zd(t,i,a),i.toArrow&&Hd(t,i,a),i.calculative.active&&!i.calculative.pencil&&!a.options.disableAnchor&&!a.data.locked&&Zd(t,i)}}}function ox(e,t,i,a){e===void 0&&(e=!0);var r=e?a.path2dMap.get(i):Ee.path2dDraws[i.name];if(r&&i.type){if(i.calculative.animatePos){if(t.save(),Xd(t,i,a),t.beginPath(),r instanceof Path2D)if(i.lineName==="polyline"||i.lineName==="line")if(i.lineAnimateType===ii.Arrow||i.lineAnimateType===ii.WaterDrop){var n=cv(i);t.stroke(n),t.fill(n)}else i.calculative.gradientSmooth||i.calculative.lineSmooth?(i.calculative.gradientAnimatePath||(i.calculative.gradientAnimatePath=bc(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&&zd(t,i,a),i.toArrow&&Hd(t,i,a),i.calculative.active&&!i.calculative.pencil&&!a.options.disableAnchor&&!a.data.locked&&Zd(t,i)}}function Xd(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 ii.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 ii.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 ii.Arrow:e.fillStyle=t.animateColor||i.options.animateColor,e.lineWidth=1;break;case ii.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 Zo(e){var t=e.data,i=e.options;return t.color||i.color}function Zd(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&&sx(e,a,t)}),e.restore()}function sx(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 Qd(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=Qd(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,_c(e,i),i}function _c(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 No(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,zo(t,a))}function hn(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(lx(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 lx(e,t){var i=Ql({},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 wf(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 pa(e,t,i){es(e.calculative.worldRect,t,i),e.calculative.initRect&&es(e.calculative.initRect,t,i),e.calculative.x&&Yo(e.calculative,t,i),e.type&&hn(e)}function cx(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 ux(e,t,i){e.anchors||(e.anchors=[]),e.calculative.worldAnchors||(e.calculative.worldAnchors=[]);var a=h2(e,t,i);return e.calculative.worldAnchors.splice(i+1,0,a),e.anchors.splice(i+1,0,fn(a,e.calculative.worldRect)),e.calculative.activeAnchor=a,a}function hx(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 Ma(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 t_(e,t.calculative.worldRect.center)}function Ea(e,t){var i=1/0,a;return e.calculative.worldAnchors.forEach(function(r){var n=os(t,r);i>n&&(i=n,a=r)}),a}function bf(e,t,i){e.x+=t,e.y+=i,e.anchors&&e.anchors.forEach(function(a){cn(a,t,i)}),e.calculative.worldAnchors&&e.calculative.worldAnchors.forEach(function(a){cn(a,t,i)})}function xc(e){if(e&&e.calculative&&e.calculative.worldAnchors.length){var t=Ue(e);if(!e.anchors||!e.anchors.length)for(;e.calculative.worldAnchors.length&&t!==e.calculative.activeAnchor;)e.calculative.worldAnchors.pop(),t=Ue(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=Ue(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];Ca(v,Fr(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 Ca(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&&Ca(i,a,e,t),e.calculative.canvas.store.emitter.emit("disconnectLine",{line:i,lineAnchor:a,pen:e,anchor:t}),!0}function Fr(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 Ue(e){if(!(!e||!e.calculative.worldAnchors))return e.calculative.worldAnchors[e.calculative.worldAnchors.length-1]}function fx(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=pn(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,_f(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,xf(e,1),0;var g=(t-e.calculative.start)%e.calculative.duration,y=0;try{for(var p=pn(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 E=e.frames[f-1];for(var c in E)e.prevFrame[c]=E[c];Object.assign(e.prevFrame,{rotate:E.rotate||0,x:E.x||0,y:E.y||0,scale:E.scale||1})}else _f(e)}var I=(t-e.calculative.frameStart)/e.calculative.frameDuration%1;return xf(e,I),!0}function _f(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 xf(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),es(e.calculative.worldRect,e.prevFrame.scale,e.calculative.worldRect.center);var n=e.prevFrame.scale+(a[r]-e.prevFrame.scale)*t;es(e.calculative.worldRect,n/e.prevFrame.scale,e.calculative.worldRect.center),e.calculative.patchFlags=!0}else if(r==="x"){var o=Bl(e,r,e.calculative.frameIndex);e.calculative.worldRect.x=e.calculative.initRect.x+o,e.calculative.worldRect.ex=e.calculative.initRect.ex+o,Wr(e.calculative.worldRect,a[r]*t*e.calculative.canvas.store.data.scale,0),e.calculative.patchFlags=!0}else if(r==="y"){var o=Bl(e,r,e.calculative.frameIndex);e.calculative.worldRect.y=e.calculative.initRect.y+o,e.calculative.worldRect.ey=e.calculative.initRect.ey+o,Wr(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=Bl(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(dx(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],kc(e,l)}r==="text"&&Tn(e)}}}function dx(e,t,i){var a=["strokeType","bkType","showChild"];return typeof e=="number"&&i.linear!==!1&&!a.includes(t)}function vx(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 xa(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,xa(r,t))})}}function on(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&&on(i.pens[a],t)})}}function Ei(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 Ml(e){return e.every(function(t){return t.locked})}function kf(e){return e.every(function(t){return t.disableRotate})}function Jd(e,t,i){var a;e.type?(e.calculative.worldAnchors.forEach(function(r){Ge(r,t,i.center)}),gx(e),No(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];Jd(n,t,i)})}function gx(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=ac(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,_c(e,i),Bi(e),e.calculative.worldAnchors&&(e.anchors=e.calculative.worldAnchors.map(function(o){return fn(o,e.calculative.worldRect)}))}}function Ef(e){return e.every(function(t){return t.disableSize})}function Bl(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.")},Jl=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},Fo=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 Af(e){var t,i;if(e.id=Me(),Array.isArray(e.anchors))try{for(var a=bx(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 Tf=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},Sf=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.")},Ex=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},Cx=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 Ax(e,t){var i,a;if(t.length<3)return!1;var r=!1,n=t[t.length-1];try{for(var o=rv(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 Fi(e){var t=[];e.forEach(function(a){if(!a.isRuleLine){var r=a.calculative.worldRect;if(r){var n=ir(r);t.push.apply(t,Cx([],Ex(n),!1))}}});var i=Sn(t);return tt(i),i}function ir(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 Sn(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 Jo(e,t,i){return e.rotate&&(e=Sn(ir(e))),i?e.x>t.x&&e.ext.y&&e.eyt.ex||e.ext.ey)}function Tx(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 Lx=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},Dx=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.")},Bx=/^[\t\n\f\r ]*([MLHVZCSQTAmlhvzcsqta])[\t\n\f\r ]*/,Pf=/^[01]/,Ze=/^[+-]?(([0-9]*\.[0-9]+)|([0-9]+\.)|([0-9]+))([eE][+-]?[0-9]+)?/,Ox=/^(([\t\n\f\r ]+,?[\t\n\f\r ]*)|(,[\t\n\f\r ]*))/,Nx={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,Pf,Pf,Ze,Ze]};function Fx(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 zx(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 Hx(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 Wx(e){var t="";return e.commands.forEach(function(i){t+=i.key+" ",i.values.forEach(function(a){t+=a+" "})}),t}function Ux(e,t,i){for(var a,r,n=Nx[e.toUpperCase()],o=[];i<=t.length;){var s={key:e,values:[]};try{for(var h=(a=void 0,Mx(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(Ox);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 qx(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},Qx=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 av(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 e2(e){var t,i=e.anchors.filter(function(a){return a.flag!==1});av(e),e.anchors=(t=e.anchors).concat.apply(t,Qx([],Zx(i),!1))}function t2(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 i2(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 r2(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 a2(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 n2(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 o2(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 s2(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 l2(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};Ol(e,[c,f,v,g],t.backgroundFront||t.background,t.color),Ol(e,[c,{x:a+h,y:r},{x:o,y:r},f],t.backgroundUp||t.background,t.color),Ol(e,[f,{x:o,y:r},{x:o,y:s-h},v],t.backgroundRight||t.background,t.color)}function Ol(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 Df=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},Mf=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 d2(e,t){var i=t||new Path2D;if((e.lineName==="line"||e.lineName==="polyline")&&e.calculative.lineSmooth){var a=bc(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?Bf(i,n,o):o.start=!0,n=o}),e.close&&Bf(i,n,r[0])}if(i instanceof Path2D)return i}function v2(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=Ue(t);!r||!n||!n.id||r===n||(r.next=void 0,xc(t),n.prev=void 0,t.calculative.worldAnchors.push(n))}}function Bf(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 ac(e){return nc(e),Sn(sv(e))}function sv(e){var t=[],i;return e.calculative.worldAnchors.forEach(function(a){t.push(a),i&&t.push.apply(t,Mf([],Df(Of(i,a,e)),!1)),i=a}),e.close&&e.calculative.worldAnchors.length>1&&t.push.apply(t,Mf([],Df(Of(i,e.calculative.worldAnchors[0],e)),!1)),t}function ts(e){return e!=null&&e.lineWidth?e.lineWidth/2+4:4}function Of(e,t,i){var a=[];if(!t)return a;var r=.02;if(e.lineLength){var n=ts(i);r=n/e.lineLength}if(e.next)if(t.prev)for(var o=r;o<1;o+=r)a.push(nv(o,e,e.next,t.prev,t));else for(var o=r;o<1;o+=r)a.push(rc(o,e,e.next,t));else if(t.prev)for(var o=r;o<1;o+=r)a.push(rc(o,e,t.prev,t));else a.push({x:t.x,y:t.y});return a.length>1&&(e.curvePoints=a),a}function g2(e,t){var i,a,r=ts(t),n=0,o,s;try{for(var h=ov(t.calculative.worldAnchors),l=h.next();!l.done;l=h.next()){var c=l.value;if(o){if(s=Nf(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=Nf(e,o,t.calculative.worldAnchors[0],r)))return{i:n,point:s}}function Nf(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?y2(e,t,i,a):void 0}else if(t.curvePoints)try{for(var y=ov(t.curvePoints),p=y.next();!p.done;p=y.next()){var m=p.value;if(_a(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 y2(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 Ff(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 nc(e){if(e.calculative.worldAnchors.length<2)return 0;var t=0,i;if(e.calculative.worldAnchors.forEach(function(r){i&&(i.lineLength=Ff(i,i.next,r.prev,r),t+=i.lineLength),i=r}),e.close){var a=lt(e);i.lineLength=Ff(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 m2(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},rn=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 _2(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},Wf=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,Wf([],Hf(oc(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,Wf([],Hf(oc(e,t,o,a)),!1))),r}function A2(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,D){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+D*D),s>0?(p=M/s,b=D/s):(p=1,b=0),Math.acos(y*p+m*b)};v=[],g=e.length,a=e[0],e[g-1],v.push(zr({},e[0]));for(var _=0;_1)for(var c=void 0,f=0,v=0;vo)&&m>h+o&&b-m>h&&(e.lineAnimateType===ii.Arrow?S2(i,p,n,y,l,o):e.lineAnimateType===ii.WaterDrop&&R2(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 T2(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 pr(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 S2(e,t,i,a,r,n){var o=pr({x:t.x+i,y:t.y+.57*i},{x:t.x,y:t.y},a),s=pr({x:t.x+i,y:t.y-.57*i},{x:t.x,y:t.y},a),h=pr({x:t.x+i,y:t.y+r/2},{x:t.x,y:t.y},a),l=pr({x:t.x+n,y:t.y+r/2},{x:t.x,y:t.y},a),c=pr({x:t.x+i,y:t.y-r/2},{x:t.x,y:t.y},a),f=pr({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 R2(e,t,i,a,r,n){var o=r/2;i&&(o=-r/2);var s=pr({x:t.x,y:t.y+o},{x:t.x,y:t.y},a),h=pr({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 P2(e){var t;e.onDestroy||(e.onDestroy=I2,e.onMove=So,e.onResize=So,e.onRotate=So,e.onValue=So,e.onMouseMove=D2,e.onBeforeValue=L2,e.onRenderPenRaw=B2),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),Ei(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),hv(e),r.onload=function(){r.setAttribute("document.domain","")}}return e.calculative.patchFlags&&Ei(e,e.calculative.singleton.div),e.onRenderPenRaw(e),new Path2D}function I2(e){e.calculative.singleton&&e.calculative.singleton.div&&(e.calculative.singleton.div.remove(),delete e.calculative.singleton.div)}function So(e){e.calculative.singleton.div&&Ei(e,e.calculative.singleton.div)}function L2(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?hv(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 D2(e,t){if(!(!e.calculative.canvas.store.data.locked&&!e.locked)&&uv(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 O2(e){var t;if(e.onDestroy||(e.onDestroy=N2,e.onMove=Nl,e.onResize=Nl,e.onRotate=Nl,e.onClick=Uf,e.onValue=z2,e.onChangeId=F2),Yt[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=Ho[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=Ho[0],e.calculative.media.muted=!1):(r.innerHTML=Ho[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(),Uf(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(){fv(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),Yt[e.id]=i,(t=e.calculative.canvas.externalElements)===null||t===void 0||t.parentElement.appendChild(i),Ei(e,i),e.autoPlay&&(n.autoplay=!0,n.muted=!0)}return e.calculative.patchFlags&&Ei(e,Yt[e.id]),new Path2D}function N2(e){Yt[e.id].onclick=null,Yt[e.id].remove(),Yt[e.id]=void 0}function Nl(e){Ei(e,Yt[e.id]);var t=Yt[e.id].children[0],i=Yt[e.id].children[1];fv(t,i,e.calculative.worldRect.width)}function Uf(e){e.calculative.media&&(e.calculative.media.muted=!1,e.calculative.singleton.muted.innerHTML=Ho[0],e.calculative.media.paused?e.calculative.media.play():e.calculative.media.pause())}function fv(e,t,i){e.style.width=t.currentTime/t.duration*i+"px"}function F2(e,t,i){!Yt[t]||(Yt[i]=Yt[t],delete Yt[t])}function z2(e){var t=Yt[e.id];if(!!t){Ei(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 H2(e){e.onDestroy||(e.onDestroy=W2,e.onMove=qf,e.onResize=U2,e.onRotate=qf,e.onValue=q2,e.onChangeId=j2);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),bn(e,i))}}return e.calculative.patchFlags&&vt[e.id]&&bn(e,vt[e.id]),t}}function W2(e){vt[e.id]&&(vt[e.id].remove(),vt[e.id]=void 0)}function qf(e){!vt[e.id]||bn(e,vt[e.id])}function U2(e){!vt[e.id]||bn(e,vt[e.id])}function q2(e){!vt[e.id]||(bn(e,vt[e.id]),vt[e.id].getAttribute("src")!==e.image&&(vt[e.id].src=e.image))}function j2(e,t,i){!vt[t]||(vt[i]=vt[t],delete vt[t])}function bn(e,t){t.style.objectFit=e.imageRatio?"contain":"fill",Ei(e,t)}var K2=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},V2=globalThis&&globalThis.__spreadArray||function(e,t,i){if(i||arguments.length===2)for(var a=0,r=t.length,n;ai+r-o&&(c=Po(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=Ro(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=Po(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=Ro(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 G2(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}(),gv=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}(),an=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.")},jf=function(){function e(t,i,a){this.parentElement=t,this.store=i,this.isBottom=a,this.canvas=document.createElement("canvas"),this.otherOffsreen=kr(),this.offscreen=kr(),this.animateOffsScreen=kr(),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=an(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=an(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(ti(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=an(this.store.data.pens),_=x.next();!_.done;_=x.next()){var g=_.value;!g.calculative.hasImage||this.store.animates.has(g)||this.store.animates.has(ti(g,!0))||g.canvasLayer!==Ne.CanvasTemplate&&(g.calculative.imageDrawed=!0,m.save(),Kr(m,g),g.calculative.rotate&&tr(m,g),Vr(m,g),Sa(m,g),m.restore())}}catch(G){a={error:G}}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 E=an(this.store.animates),I=E.next();!I.done;I=E.next()){var g=I.value;!g.calculative.hasImage||g.canvasLayer!==Ne.CanvasTemplate&&(g.calculative.imageDrawed=!0,m.save(),Kr(m,g),g.calculative.rotate&&tr(m,g),Vr(m,g),Sa(m,g),m.restore())}}catch(G){n={error:G}}finally{try{I&&!I.done&&(o=E.return)&&o.call(E)}finally{if(n)throw n.error}}try{for(var P=an(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(ti(g,!0))&&(g.calculative.imageDrawed=!0,m.save(),Kr(m,g),g.calculative.rotate&&tr(m,g),Vr(m,g),Sa(m,g),m.restore())}}catch(G){s={error:G}}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 D=this.canvas.getContext("2d");D.clearRect(0,0,this.canvas.width,this.canvas.height),this.isBottom&&(this.store.patchFlagsBackground=!1),D.drawImage(this.offscreen,0,0,this.canvas.width,this.canvas.height),D.drawImage(this.animateOffsScreen,0,0,this.canvas.width,this.canvas.height),this.isBottom||(D.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=Go(x,.7);var _=m.x+f.x,E=m.y+f.y,I=this.canvas,P=I.width,M=I.height,D=((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,D),t.fill(),t.rect(0,0,D,M),t.fill()),!((n=v.ruleOptions)===null||n===void 0)&&n.underline&&(t.beginPath(),t.fillStyle=Go(x,.7),t.moveTo(0,D),t.lineTo(P,D),t.stroke(),t.moveTo(D,0),t.lineTo(D,M),t.stroke());var U=D/4;((o=v.ruleOptions)===null||o===void 0?void 0:o.baseline)==="bottom"&&(U=D*3/4),t.beginPath(),t.lineWidth=D/2,t.lineDashOffset=-_%b,t.setLineDash([1,b-1]),t.moveTo(0,U),t.lineTo(P,U),t.stroke(),t.beginPath(),t.lineDashOffset=-E%b,t.moveTo(U,0),t.lineTo(U,M),t.stroke(),t.strokeStyle=x,t.beginPath(),t.lineWidth=D,t.lineDashOffset=-_%(b*10),t.setLineDash([1,b*10-1]),t.moveTo(0,D/2),t.lineTo(P,D/2),t.stroke(),t.beginPath(),t.lineDashOffset=-E%(b*10),t.moveTo(D/2,0),t.lineTo(D/2,M),t.stroke(),t.beginPath(),t.fillStyle=((s=v.ruleOptions)===null||s===void 0?void 0:s.textColor)||t.strokeStyle;var G=0-Math.floor(_/b/10)*100,T=((h=v.ruleOptions)===null||h===void 0?void 0:h.textTop)||16,S=((l=v.ruleOptions)===null||l===void 0?void 0:l.textLeft)||4;_<0&&(G-=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.")},nk=function(){function e(t,i){this.parentElement=t,this.store=i,this.canvas=document.createElement("canvas"),this.offscreen=kr(),this.bgOffscreen=kr(),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=ak(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&&(Nr(r,v),v.image&&v.name!=="gif"&&v.calculative.img&&(r.save(),Kr(r,v),v.calculative.rotate&&tr(r,v),Vr(r,v),Sa(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,E=y/p,I=p*10,P=g-Math.ceil(_)*p,M=y-Math.ceil(E)*p,D=b+P+I,U=x+M+I,G=P;G<=D;G+=p)t.moveTo(G,M),t.lineTo(G,x+M+I);for(var G=M;G<=U;G+=p)t.moveTo(P,G),t.lineTo(b+P+I,G)}else{for(var D=f+g,U=v+y,G=g;G<=D;G+=p)t.moveTo(G,y),t.lineTo(G,v+y);for(var G=y;G<=U;G+=p)t.moveTo(g,G),t.lineTo(f+g,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},Ii=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.")},Li="-moving",Kf=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=kr(),this.externalElements=document.createElement("div"),this.lastRotate=0,this.hoverType=be.None,this.resizeIndex=0,this.lastOffsetX=0,this.lastOffsetY=0,this.drawLineFns=Ii([],Pi(e_),!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=u2,this.polyline=w2,this.mind=f2,this.line=v2,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=Ue(r.drawingLine);y!==r.drawingLine.calculative.activeAnchor?(xc(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&&sv(m),r.store.path2dMap.set(m,Ee.path2dDraws.line(m)),nc(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=Xi.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===Xi.Down&&!r.store.options.mouseRightActive)){if(r.drawingLine){if(r.store.hoverAnchor){var v=Ue(r.drawingLine);r.store.hoverAnchor.type===Zi.Line?xo(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=Ue(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=Ue(r.drawingLine),l=Ea(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=Ue(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=Ea(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=ti(r.store.hover,!0)||r.store.hover;n.ctrlKey&&!n.shiftKey?(b.calculative.active?r.willInactivePen=b:(b.calculative.active=!0,xa(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===Xi.Down&&(r.mouseRight=Xi.Translate),r.store.data.locked===ze.DisableEdit||r.store.data.locked===ze.DisableScale||r.hotkeyType===Ke.Translate||r.mouseRight===Xi.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=Cf(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&&(E=Ue(r.drawingLine)),E?(E.prev=void 0,E.next=void 0,E.id||(E.id=Me()),E.x=b.x,E.y=b.y,E.connectTo=void 0):(E=Lt({},b),r.drawingLine.calculative.worldAnchors.push(E)),(r.hoverType===be.NodeAnchor||r.hoverType===be.LineAnchor)&&(r.store.hoverAnchor.type!==Zi.Line&&(E.x=r.store.hoverAnchor.x,E.y=r.store.hoverAnchor.y),E.connectTo=r.store.hoverAnchor.penId,r.drawingLineName==="polyline"&&(E.isTemp=!1)),r.drawingLineName==="line"){if(n.ctrlKey&&!n.shiftKey)E.x=r.drawingLine.calculative.worldAnchors[r.drawingLine.calculative.worldAnchors.length-2].x;else if(n.shiftKey&&!n.ctrlKey)E.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(E,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===Xi.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=Xi.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=Ue(r.drawingLine);r.store.hoverAnchor.type===Zi.Line?xo(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=Ue(r.drawingLine),l=Ea(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=Ue(c);if(r.store.hoverAnchor){var v=r.store.hover,g=lt(v)===r.store.hoverAnchor,y=Ue(v)===r.store.hoverAnchor,p=f===r.store.activeAnchor,m=h===r.store.activeAnchor;if((n.ctrlKey||n.altKey)&&v.type===$e.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,Ii([],Pi(b),!1))):m&&(c.calculative.worldAnchors[c.calculative.worldAnchors.length-1].connectTo=void 0,(s=c.calculative.worldAnchors).push.apply(s,Ii([],Pi(b),!1))),r.delete([v]),r.render()}else r.store.activeAnchor&&(r.store.hoverAnchor.type===Zi.Line?xo(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,Ee.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(E){E.rotate=E.calculative.rotate})),r.patchFlagsLines.forEach(function(E){E.type&&r.initLineRect(E)}),r.patchFlagsLines.clear(),r.dragRect){var _=r.store.data.pens.filter(function(E){if(E.visible===!1||E.locked>=ze.DisableMove||E.parentId||E.isRuleLine)return!1;if(Jo(E.calculative.worldRect,r.dragRect,r.store.options.dragAllIn))return E.type===$e.Line&&!r.store.options.dragAllIn?m2(E,r.dragRect):!0});r.active(_)}n.button!==2&&(os(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,xa(r.willInactivePen,!1),r.store.active.splice(r.store.active.findIndex(function(E){return E===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(E){r.store.pens[E.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||ka(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=Ml(r.store.active),f=kf(r.store.active)||r.store.options.disableRotate,v=Ef(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&&_a(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&&_a(n,r.sizeCPs[y],r.pointSize)){var b=p?ff:df,x=0;Math.abs(r.activeRect.rotate%90-45)<25?(b=p?df:ff,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&&ka(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,on(ti(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,on(ti(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=ts(b);if(!b.calculative.active&&!Yr(n,b.calculative.worldRect,x)&&!ka(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)),E=_.next();!E.done;E=_.next()){var I=E.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{E&&!E.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 D=g2(n,b);if(D)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=D.point,r.store.pointAtIndex=D.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 G=!1;if(b.name==="line"?G=Yr(n,b.calculative.worldRect,b.lineWidth):G=ka(n,b.calculative.worldRect),G){if(b.type===$e.Node&&b.name==="line"){var T=Ix(n,b.calculative.worldAnchors);if(!T)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 S=r.store.hover.calculative.worldRect,R=S.x,O=S.y,K=S.ex,$=S.ey,ae=S.rotate,V=S.center;if(ae){var F=[{x:R,y:O},{x:K,y:O},{x:K,y:$},{x:R,y:$}];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-10$&&(r.store.pointAt.y=$)}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=ts(f);if(v+=2*r.store.options.anchorRadius,!!Yr(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=Ue(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===Zi.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)&&!Ml(r.store.active)&&!Ef(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=Go(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(Af(n),n.parentId=o,n.type===$e.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(E){var I=r.store.clipboard.pens.find(function(P){return P.id===E});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(E){s={error:E}}finally{try{x&&!x.done&&(h=b.return)&&h.call(b)}finally{if(s)throw s.error}}}return n.children=p,wr(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&&I_(n),Bi(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&&Bi(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 nk(i,a),this.canvasTemplate.canvas.style.zIndex="1",this.canvasImageBottom=new jf(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 jf(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 ek(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});on(o,!1)},this.dialog=new ik(i),this.title=new rk(i),this.store.options.scroll&&(this.scroll=new gv(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 Hr.Document:document.addEventListener("keydown",this.onkeydown),document.addEventListener("keyup",this.onkeyup);break;case Hr.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=fn(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 _i(this,void 0,void 0,function(){var a;return xi(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,B_(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,M_(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(){Ee.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 _i(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,_,E,I,P,M,D,U,G,T,S,R,O=this;return xi(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($){E={error:$}}finally{try{n&&!n.done&&(I=r.return)&&I.call(r)}finally{if(E)throw E.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($){$.lineAnchor=O.randomIdObj[$.lineAnchor],$.lineId=O.randomIdObj[$.lineId]})}catch($){P={error:$}}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($){D={error:$}}finally{try{l&&!l.done&&(U=h.return)&&U.call(h)}finally{if(D)throw D.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:$}}finally{try{f&&!f.done&&(T=c.return)&&T.call(c)}finally{if(G)throw G.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($){return ka($,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($){S={error:$}}finally{try{b&&!b.done&&(R=m.return)&&R.call(m)}finally{if(S)throw S.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($){return!$.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]),Af(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 _i(this,void 0,void 0,function(){var a,r,n,o,s,h,l;return xi(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:$e.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:$e.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(_a(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&&_a(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&&_a(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),wr(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 _i(this,void 0,void 0,function(){var r;return xi(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});Bd.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=Ii(Ii([],Pi(t.pens),!1),Pi(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&&Ee.anchors[t.name]&&(t.anchors||(t.anchors=[]),Ee.anchors[t.name](t)),this.updatePenRect(t),!t.anchors&&t.calculative.worldAnchors&&(t.anchors=t.calculative.worldAnchors.map(function(l){return fn(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,Ee.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=ac(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,_c(t,a),Bi(t),wr(t),t.calculative&&(t.calculative.gradientAnimatePath=void 0),this.store.path2dMap.set(t,Ee.path2dDraws[t.name](t)),t.calculative.worldAnchors&&(t.anchors=t.calculative.worldAnchors.map(function(s){return fn(s,t.calculative.worldRect)}))}}},e.prototype.drawingPencil=function(){yv(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 _i(this,void 0,void 0,function(){var i,a,r,n,o,s,h=this;return xi(this,function(l){switch(l.label){case 0:if(!this.drawingLine)return[2];if(i=lt(this.drawingLine),a=Ue(this.drawingLine),a.isTemp&&(this.drawingLine.calculative.worldAnchors.pop(),a=Ue(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=Ue(c);return vf(f,i)&&vf(v,a)}}),r))return this.drawingLine=void 0,this.render(),[2];return n=ac(this.drawingLine),Object.assign(this.drawingLine,n),this.drawingLine.calculative.worldRect=n,this.drawingLine.calculative.activeAnchor=Ue(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,Ee.path2dDraws[this.drawingLine.name](this.drawingLine)),this.drawingLine=void 0,this.drawingLineName=void 0,this.render(),[2]}})})},e.prototype.finishPencil=function(){return _i(this,void 0,void 0,function(){var t,i,a,r;return xi(this,function(n){switch(n.label){case 0:return this.pencilLine?(t=oc(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=Ue(this.pencilLine),t.push({id:i.id,penId:i.penId,x:i.x,y:i.y}),this.pencilLine.calculative.worldAnchors=A2(t),this.pencilLine.calculative.worldAnchors.length>1?(this.pencilLine.calculative.pencil=!1,this.store.path2dMap.set(this.pencilLine,Ee.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,Ee.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(Ee.htmlElements[t.image]){var a=Ee.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,Ee.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(Ee.htmlElements[t.backgroundImage]){var a=Ee.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,Ee.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(Ee.htmlElements[t.strokeImage]){var a=Ee.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,Ee.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===$e.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?No(t):Qd(t),o||this.setCalculativeByScale(t),hn(t),wf(this.store.pens,t),Bi(t),wr(t),Ee.path2dDraws[t.name]&&this.store.path2dMap.set(t,Ee.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=Ji(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&&Yo(this.store.clipboard.pos,s,i),Yo(this.store.data.origin,s,i),this.store.data.pens.forEach(function(l){if(!l.parentId){if(pa(l,s,i),l.onScale&&l.onScale(l),l.isRuleLine){var c=1/s,f=l.calculative.worldRect.center;l.width&&l.height||pa(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(pa(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||pa(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=di(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(Rf(s,n,o,this.resizeIndex),tt(s),!this.store.options.disableDock){this.clearDock();var h=this.customResizeDock||px;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,Rf(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 E={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.xE.x+E.width&&(this.activeRect.width=this.activeRect.width-(this.activeRect.x+this.activeRect.width-(E.x+E.width)),this.activeRect.x=E.x+E.width-this.activeRect.width,this.activeRect.ex=this.activeRect.x+this.activeRect.width),this.activeRect.y+this.activeRect.height>E.y+E.height&&(this.activeRect.height=this.activeRect.height-(this.activeRect.y+this.activeRect.height-(E.y+E.height)),this.activeRect.y=E.y+E.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,D){M.calculative.worldRect.x=i.activeInitPos[D].x*i.activeRect.width+i.activeRect.x,M.calculative.worldRect.y=i.activeInitPos[D].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){on(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);Wr(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||mx;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+=Li,t.parentId&&i.find(function(a){return a.id===t.parentId})&&(t.parentId+=Li),t.children&&(t.children=t.children.map(function(a){return a+Li})),t.connectedLines&&(t.connectedLines=t.connectedLines.map(function(a){return i.find(function(r){return r.id===a.lineId})&&(a.lineId+=Li),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+=Li),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];Ca(a.store.pens[a.store.activeAnchor.penId],a.store.activeAnchor,_,Fr(_,x.lineAnchor))});var f=this.store.active[0];lt(f);var v=Ue(f);if(f.lineName==="polyline"&&!i.shiftKey)C2(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);cn(this.store.activeAnchor,g,y),this.store.hover&&this.store.hoverAnchor&&this.store.hoverAnchor.penId!==this.store.activeAnchor.penId&&(this.store.hoverAnchor.type===Zi.Line?(g=t.x-this.store.activeAnchor.x,y=t.y-this.store.activeAnchor.y,xo(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),cn(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,Ee.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===jr.Bilateral&&this.prevAnchor){var a=di(t,this.store.activeAnchor),r=di(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,Ee.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===jr.Bilateral&&this.nextAnchor){var a=di(t,this.store.activeAnchor),r=di(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,Ee.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 _i(this,void 0,void 0,function(){var a,r,n,o,s,s;return xi(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===$e.Line&&((i=r.calculative.worldAnchors)===null||i===void 0?void 0:i.length)<=2?this.delete([r]):(hx(r,this.store.hoverAnchor),r.type===$e.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===$e.Line?(this.store.activeAnchor=ux(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=cx(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(Li)>0){var r=t.id;t=this.store.pens[r.replace(Li,"")]}t.anchors.forEach(function(n){if(n.connectTo&&!i.find(function(s){return s.id===n.connectTo||s.id===n.connectTo+Li})){var o=a.store.pens[n.connectTo];if(!o||o.type)return;Ca(o,Fr(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&&Wr(this.activeRect,i,a);var h=this.getAllByPens(t);t.forEach(function(l){var c,f;if(!(l.locked>=ze.DisableMove)){if(l.type===$e.Line){if(!n.store.options.moveConnectedLine&&!n.canMoveLine||l.isRuleLine)return;bf(l,i,a),n.checkDisconnect(l,h),n.store.path2dMap.set(l,Ee.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 Wr(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===$e.Line){if(!r.store.options.moveConnectedLine&&!r.canMoveLine)return;bf(o,i,a),r.checkDisconnect(o,n),r.store.path2dMap.set(o,Ee.path2dDraws[o.name](o))}else Wr(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=Ue(t),s=Ea(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,Ee.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&&Jd(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,Tn(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=Fr(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=Ue(o);l.id===s.id&&a.calcAutoAnchor(o,l,t,n)}var c=Fr(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),cn(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=Ue(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,Ee.path2dDraws[o.name](o)),a.patchFlagsLines.add(o),o.calculative.gradientSmooth&&(o.calculative.gradientAnimatePath=bc(o)),i&&nc(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)fx(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(!vx(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]);No(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),_i(this,void 0,void 0,function(){var a,r,n,o,s,h,l=this;return xi(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 _i(this,void 0,void 0,function(){var i,a,r,n,o,s,h,l,c,f,v,g;return xi(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,Ii([],Pi(ce(mr(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=ti(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=Fr(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===$e.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];hn(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 E in i)E.indexOf(".")===-1?(E==="rotate"?x=t.calculative.rotate||0:E==="canvasLayer"||E==="isBottom"||E==="showChild"?b=!0:E==="image"&&(_=!0),(typeof t[E]!="object"||E==="lineDash")&&(t.calculative[E]=i[E]),$1.includes(E)&&(g=!0),["name","borderRadius","lineSmooth"].includes(E)&&(v=!0),G1.includes(E)&&(m=!0),X1.includes(E)&&(y=!0),Z1.includes(E)&&(p=!0)):(delete t[E],F_(t,E,i[E])),E.split(".")[0]==="anchors"&&hn(t);if(this.setCalculativeByScale(t),f&&((a=t.onDestroy)===null||a===void 0||a.call(t,t),J1(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&&Bi(t),p&&wf(this.store.pens,t),v&&Ee.path2dDraws[t.name]&&this.store.path2dMap.set(t,Ee.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&&Ei(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=Fi(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),Jo(s,this.canvasRect,!0))Object.assign(s,this.canvasRect);else{var y=Sn(Ii(Ii([],Pi(ir(s)),!1),Pi(ir(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),_=Ji(t);s.x-=_[3]*h,s.y-=_[0]*h,s.width+=(_[3]+_[1])*h,s.height+=(_[0]+_[2])*h;var E=(r||1920)/s.width;s.width*=E,s.height*=E,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(E,E);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 D=s.x<0?-s.x:0,U=s.y<0?-s.y:0;P.drawImage(this.store.bkImg,D,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 G=at(this.store.data.pens),T=G.next();!T.done;T=G.next()){var S=T.value;if(!(!Qo(S,this.store)||S.visible==!1)){var R=S.calculative.active;S.calculative.active=!1,S.calculative.img?Xo(P,S):Nr(P,S,!0),S.calculative.active=R}}}catch(O){n={error:O}}finally{try{T&&!T.done&&(o=G.return)&&o.call(G)}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=Fi(n);if(!isFinite(s.width))throw new Error("can not to png, because width is not finite");var h=ce(s),l=Ji(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(!Qo(y,this.store)||y.visible==!1)continue;var p=y.calculative.active;y.calculative.active=!1,y.calculative.img?Xo(f,y):Nr(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=jr.Mirror),this.store.activeAnchor.prevNextType=(this.store.activeAnchor.prevNextType+1)%3)},e.prototype.gotoView=function(t,i){var a=Fi(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 Hr.Document:document.removeEventListener("keydown",this.onkeydown),document.removeEventListener("keyup",this.onkeyup);break;case Hr.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 ok=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 Io(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 Wo={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 Io=="function"&&Io;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 Io=="function"&&Io,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 $._resubscribe();q=F.packet,_("deliver :: call _sendPacket for %o",q);let Y=!0;q.messageId&&q.messageId!==0&&($.messageIdProvider.register(q.messageId)||(Y=!1)),Y?$._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"),$.pingTimer!==null&&($.pingTimer.clear(),$.pingTimer=null),this.topicAliasRecv&&this.topicAliasRecv.clear(),_("close :: calling _setupReconnect"),this._setupReconnect()}),s.call(this),_("MqttClient :: setting up stream"),this._setupStream()}y(S,s),S.prototype._setupStream=function(){const R=this,O=new g,K=f.parser(this.options);let $=null;const ae=[];function V(){if(ae.length)E(F);else{const Y=$;$=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=$;$=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){$=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)):T(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)},S.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:$}),this},S.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 k=0;k0||!J())&&this._storeProcessingQueue.push({invoke:J,callback:V}),this},S.prototype.unsubscribe=function(){const R=this,O=new Array(arguments.length);for(let q=0;q0||!F())&&this._storeProcessingQueue.push({invoke:F,callback:$}),this},S.prototype.end=function(R,O,K){const $=this;function ae(){_("end :: (%s) :: finish :: calling _cleanUp with force %s",$.options.clientId,R),$._cleanUp(R,()=>{_("end :: finish :: calling process.nextTick on closeStores"),E(function(){_("end :: closeStores: closing incoming and outgoing stores"),$.disconnected=!0,$.incomingStore.close(function(V){$.outgoingStore.close(function(F){if(_("end :: closeStores: emitting end"),$.emit("end"),K){const q=V||F;_("end :: closeStores: invoking callback with args"),K(q)}})}),$._deferredReconnect&&$._deferredReconnect()}.bind($))},O)}return _("end :: (%s)",this.options.clientId),R!=null&&typeof R=="boolean"||(K=O||T,O=R,R=!1,typeof O!="object"&&(K=O,O=null,typeof K!="function"&&(K=T))),typeof O!="object"&&(K=O,O=null),_("end :: cb? %s",!!K),K=K||T,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",$.options.clientId),this.once("outgoingEmpty",setTimeout.bind(null,ae,10))):(_("end :: (%s) :: immediately calling finish",$.options.clientId),ae()),this)},S.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},S.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},S.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())},S.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...")},S.prototype._clearReconnect=function(){_("_clearReconnect : clearing reconnect timer"),this.reconnectTimer&&(clearInterval(this.reconnectTimer),this.reconnectTimer=null)},S.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&&($=this.outgoing)&&(_("flush: queue exists? %b",!!$),Object.keys($).forEach(function(ae){typeof $[ae].cb=="function"&&($[ae].cb(new Error("Connection closed")),delete $[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 $;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())},S.prototype._sendPacket=function(R,O,K){_("_sendPacket :: (%s) :: start",this.options.clientId),K=K||T,O=O||T;const $=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($)O($);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 G(this,R,O,K);default:return void U(this,R,O)}switch(R.qos){case 2:case 1:G(this,R,O,K);break;case 0:default:U(this,R,O)}_("_sendPacket :: (%s) :: end",this.options.clientId)}},S.prototype._storePacket=function(R,O,K){_("_storePacket :: packet: %o",R),_("_storePacket :: cb? %s",!!O),K=K||T;let $=R;if($.cmd==="publish"){const ae=D(this,$=m(R));if(ae)return O&&O(ae)}($.qos||0)===0&&this.queueQoSZero||$.cmd!=="publish"?this.queue.push({packet:$,cb:O}):$.qos>0?(O=this.outgoing[$.messageId]?this.outgoing[$.messageId].cb:null,this.outgoingStore.put($,function(ae){if(ae)return O&&O(ae);K()})):O&&O(new Error("No connection to broker"))},S.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))},S.prototype._shiftPingInterval=function(){this.pingTimer&&this.options.keepalive&&this.options.reschedulePings&&this.pingTimer.reschedule(1e3*this.options.keepalive)},S.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))},S.prototype._handlePingresp=function(){this.pingResp=!0},S.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 $=new Error("Connection refused: "+M[K]);$.code=K,this.emit("error",$)}},S.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 $=this;this.handleAuth(R,function(ae,V){if(ae)$.emit("error",ae);else if(K===24)$.reconnecting=!1,$._sendPacket(V);else{const F=new Error("Connection refused: "+M[K]);ae.code=K,$.emit("error",F)}})},S.prototype.handleAuth=function(R,O){O()},S.prototype._handlePublish=function(R,O){_("_handlePublish: packet %o",R),O=O!==void 0?O:T;let K=R.topic.toString();const $=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,$,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,$,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,$,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,$,R),this.handleMessage(R,O);break;default:_("_handlePublish: unknown QoS. Doing nothing.")}},S.prototype.handleMessage=function(R,O){O()},S.prototype._handleAck=function(R){const O=R.messageId,K=R.cmd;let $=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":{$={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($);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},S.prototype._invokeAllStoreProcessingQueue=function(){for(;this._invokeStoreProcessingQueue(););},S.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=S}).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,E=!m.objectMode,I=function(R,O){const K=O.protocolId==="MQIsdp"&&O.protocolVersion===3?"mqttv3.1":"mqtt",$=g(O,R),ae=new WebSocket($,[K]);return ae.binaryType="arraybuffer",ae}(p,m),P=function(R,O,K){const $=new c({objectModeMode:R.objectMode});return $._write=O,$._flush=K,$}(m,function R(O,K,$){I.bufferedAmount>x&&setTimeout(R,_,O,K,$),E&&typeof O=="string"&&(O=o.from(O,"utf8"));try{I.send(O)}catch(ae){return $(ae)}$()},function(R){I.close(),R()});m.objectMode||(P._writev=S),P.on("close",()=>{I.close()});const M=I.addEventListener!==void 0;function D(){b.setReadable(P),b.setWritable(P),b.emit("connect")}function U(){b.end(),b.destroy()}function G(R){b.destroy(R)}function T(R){let O=R.data;O=O instanceof ArrayBuffer?o.from(O):o.from(O,"utf8"),P.push(O)}function S(R,O){const K=new Array(R.length);for(let $=0;${E.destroy()}),E}}).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(E){_(new Error(E))}})},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,_[E++]=y>>8&255,_[E++]=255&y;return x===2&&(y=o[g.charCodeAt(p)]<<2|o[g.charCodeAt(p+1)]>>4,_[E++]=255&y),x===1&&(y=o[g.charCodeAt(p)]<<10|o[g.charCodeAt(p+1)]<<4|o[g.charCodeAt(p+2)]>>2,_[E++]=y>>8&255,_[E++]=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 "'+k+'" is invalid for option "size"');var C=new Uint8Array(k);return C.__proto__=c.prototype,C}function c(k,C,L){if(typeof k=="number"){if(typeof C=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return g(k)}return f(k,C,L)}function f(k,C,L){if(typeof k=="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}(k,C);if(ArrayBuffer.isView(k))return y(k);if(k==null)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof k);if(le(k,ArrayBuffer)||k&&le(k.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|k}function m(k,C){if(c.isBuffer(k))return k.length;if(ArrayBuffer.isView(k)||le(k,ArrayBuffer))return k.byteLength;if(typeof k!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof k);var L=k.length,H=arguments.length>2&&arguments[2]===!0;if(!H&&L===0)return 0;for(var X=!1;;)switch(C){case"ascii":case"latin1":case"binary":return L;case"utf8":case"utf-8":return re(k).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*L;case"hex":return L>>>1;case"base64":return ee(k).length;default:if(X)return H?-1:re(k).length;C=(""+C).toLowerCase(),X=!0}}function b(k,C,L){var H=k[C];k[C]=k[L],k[L]=H}function x(k,C,L,H,X){if(k.length===0)return-1;if(typeof L=="string"?(H=L,L=0):L>2147483647?L=2147483647:L<-2147483648&&(L=-2147483648),se(L=+L)&&(L=X?0:k.length-1),L<0&&(L=k.length+L),L>=k.length){if(X)return-1;L=k.length-1}else if(L<0){if(!X)return-1;L=0}if(typeof C=="string"&&(C=c.from(C,H)),c.isBuffer(C))return C.length===0?-1:_(k,C,L,H,X);if(typeof C=="number")return C&=255,typeof Uint8Array.prototype.indexOf=="function"?X?Uint8Array.prototype.indexOf.call(k,C,L):Uint8Array.prototype.lastIndexOf.call(k,C,L):_(k,[C],L,H,X);throw new TypeError("val must be string, number or Buffer")}function _(k,C,L,H,X){var Q,ne=1,ye=k.length,ge=C.length;if(H!==void 0&&((H=String(H).toLowerCase())==="ucs2"||H==="ucs-2"||H==="utf16le"||H==="utf-16le")){if(k.length<2||C.length<2)return-1;ne=2,ye/=2,ge/=2,L/=2}function xe(kt,qe){return ne===1?kt[qe]:kt.readUInt16BE(qe*ne)}if(X){var Te=-1;for(Q=L;Qye&&(L=ye-ge),Q=L;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,k.length-L),k,L,H)}function G(k,C,L){return C===0&&L===k.length?o.fromByteArray(k):o.fromByteArray(k.slice(C,L))}function T(k,C,L){L=Math.min(k.length,L);for(var H=[],X=C;X239?4:xe>223?3:xe>191?2:1;if(X+xt<=L)switch(xt){case 1:xe<128&&(Te=xe);break;case 2:(192&(Q=k[X+1]))==128&&(ge=(31&xe)<<6|63&Q)>127&&(Te=ge);break;case 3:Q=k[X+1],ne=k[X+2],(192&Q)==128&&(192&ne)==128&&(ge=(15&xe)<<12|(63&Q)<<6|63&ne)>2047&&(ge<55296||ge>57343)&&(Te=ge);break;case 4:Q=k[X+1],ne=k[X+2],ye=k[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&&(Te=ge)}Te===null?(Te=65533,xt=1):Te>65535&&(Te-=65536,H.push(Te>>>10&1023|55296),Te=56320|1023&Te),H.push(Te),X+=xt}return function(it){var kt=it.length;if(kt<=S)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(k,C,L){return f(k,C,L)},c.prototype.__proto__=Uint8Array.prototype,c.__proto__=Uint8Array,c.alloc=function(k,C,L){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)}(k,C,L)},c.allocUnsafe=function(k){return g(k)},c.allocUnsafeSlow=function(k){return g(k)},c.isBuffer=function(k){return k!=null&&k._isBuffer===!0&&k!==c.prototype},c.compare=function(k,C){if(le(k,Uint8Array)&&(k=c.from(k,k.offset,k.byteLength)),le(C,Uint8Array)&&(C=c.from(C,C.offset,C.byteLength)),!c.isBuffer(k)||!c.isBuffer(C))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(k===C)return 0;for(var L=k.length,H=C.length,X=0,Q=Math.min(L,H);Xthis.length||((H===void 0||H>this.length)&&(H=this.length),H<=0)||(H>>>=0)<=(L>>>=0))return"";for(C||(C="utf8");;)switch(C){case"hex":return K(this,L,H);case"utf8":case"utf-8":return T(this,L,H);case"ascii":return R(this,L,H);case"latin1":case"binary":return O(this,L,H);case"base64":return G(this,L,H);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return $(this,L,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(k){if(!c.isBuffer(k))throw new TypeError("Argument must be a Buffer");return this===k||c.compare(this,k)===0},c.prototype.inspect=function(){var k="",C=r.INSPECT_MAX_BYTES;return k=this.toString("hex",0,C).replace(/(.{2})/g,"$1 ").trim(),this.length>C&&(k+=" ... "),""},c.prototype.compare=function(k,C,L,H,X){if(le(k,Uint8Array)&&(k=c.from(k,k.offset,k.byteLength)),!c.isBuffer(k))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof k);if(C===void 0&&(C=0),L===void 0&&(L=k?k.length:0),H===void 0&&(H=0),X===void 0&&(X=this.length),C<0||L>k.length||H<0||X>this.length)throw new RangeError("out of range index");if(H>=X&&C>=L)return 0;if(H>=X)return-1;if(C>=L)return 1;if(C>>>=0,L>>>=0,H>>>=0,X>>>=0,this===k)return 0;for(var Q=X-H,ne=L-C,ye=Math.min(Q,ne),ge=this.slice(H,X),xe=k.slice(C,L),Te=0;Te>>=0,isFinite(L)?(L>>>=0,H===void 0&&(H="utf8")):(H=L,L=void 0)}var X=this.length-C;if((L===void 0||L>X)&&(L=X),k.length>0&&(L<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 E(this,k,C,L);case"utf8":case"utf-8":return I(this,k,C,L);case"ascii":return P(this,k,C,L);case"latin1":case"binary":return M(this,k,C,L);case"base64":return D(this,k,C,L);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return U(this,k,C,L);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 S=4096;function R(k,C,L){var H="";L=Math.min(k.length,L);for(var X=C;XH)&&(L=H);for(var X="",Q=C;QL)throw new RangeError("Trying to access beyond buffer length")}function V(k,C,L,H,X,Q){if(!c.isBuffer(k))throw new TypeError('"buffer" argument must be a Buffer instance');if(C>X||Ck.length)throw new RangeError("Index out of range")}function F(k,C,L,H,X,Q){if(L+H>k.length)throw new RangeError("Index out of range");if(L<0)throw new RangeError("Index out of range")}function q(k,C,L,H,X){return C=+C,L>>>=0,X||F(k,0,L,4),s.write(k,C,L,H,23,4),L+4}function Y(k,C,L,H,X){return C=+C,L>>>=0,X||F(k,0,L,8),s.write(k,C,L,H,52,8),L+8}c.prototype.slice=function(k,C){var L=this.length;k=~~k,C=C===void 0?L:~~C,k<0?(k+=L)<0&&(k=0):k>L&&(k=L),C<0?(C+=L)<0&&(C=0):C>L&&(C=L),C>>=0,C>>>=0,L||ae(k,C,this.length);for(var H=this[k],X=1,Q=0;++Q>>=0,C>>>=0,L||ae(k,C,this.length);for(var H=this[k+--C],X=1;C>0&&(X*=256);)H+=this[k+--C]*X;return H},c.prototype.readUInt8=function(k,C){return k>>>=0,C||ae(k,1,this.length),this[k]},c.prototype.readUInt16LE=function(k,C){return k>>>=0,C||ae(k,2,this.length),this[k]|this[k+1]<<8},c.prototype.readUInt16BE=function(k,C){return k>>>=0,C||ae(k,2,this.length),this[k]<<8|this[k+1]},c.prototype.readUInt32LE=function(k,C){return k>>>=0,C||ae(k,4,this.length),(this[k]|this[k+1]<<8|this[k+2]<<16)+16777216*this[k+3]},c.prototype.readUInt32BE=function(k,C){return k>>>=0,C||ae(k,4,this.length),16777216*this[k]+(this[k+1]<<16|this[k+2]<<8|this[k+3])},c.prototype.readIntLE=function(k,C,L){k>>>=0,C>>>=0,L||ae(k,C,this.length);for(var H=this[k],X=1,Q=0;++Q=(X*=128)&&(H-=Math.pow(2,8*C)),H},c.prototype.readIntBE=function(k,C,L){k>>>=0,C>>>=0,L||ae(k,C,this.length);for(var H=C,X=1,Q=this[k+--H];H>0&&(X*=256);)Q+=this[k+--H]*X;return Q>=(X*=128)&&(Q-=Math.pow(2,8*C)),Q},c.prototype.readInt8=function(k,C){return k>>>=0,C||ae(k,1,this.length),128&this[k]?-1*(255-this[k]+1):this[k]},c.prototype.readInt16LE=function(k,C){k>>>=0,C||ae(k,2,this.length);var L=this[k]|this[k+1]<<8;return 32768&L?4294901760|L:L},c.prototype.readInt16BE=function(k,C){k>>>=0,C||ae(k,2,this.length);var L=this[k+1]|this[k]<<8;return 32768&L?4294901760|L:L},c.prototype.readInt32LE=function(k,C){return k>>>=0,C||ae(k,4,this.length),this[k]|this[k+1]<<8|this[k+2]<<16|this[k+3]<<24},c.prototype.readInt32BE=function(k,C){return k>>>=0,C||ae(k,4,this.length),this[k]<<24|this[k+1]<<16|this[k+2]<<8|this[k+3]},c.prototype.readFloatLE=function(k,C){return k>>>=0,C||ae(k,4,this.length),s.read(this,k,!0,23,4)},c.prototype.readFloatBE=function(k,C){return k>>>=0,C||ae(k,4,this.length),s.read(this,k,!1,23,4)},c.prototype.readDoubleLE=function(k,C){return k>>>=0,C||ae(k,8,this.length),s.read(this,k,!0,52,8)},c.prototype.readDoubleBE=function(k,C){return k>>>=0,C||ae(k,8,this.length),s.read(this,k,!1,52,8)},c.prototype.writeUIntLE=function(k,C,L,H){k=+k,C>>>=0,L>>>=0,H||V(this,k,C,L,Math.pow(2,8*L)-1,0);var X=1,Q=0;for(this[C]=255&k;++Q>>=0,L>>>=0,H||V(this,k,C,L,Math.pow(2,8*L)-1,0);var X=L-1,Q=1;for(this[C+X]=255&k;--X>=0&&(Q*=256);)this[C+X]=k/Q&255;return C+L},c.prototype.writeUInt8=function(k,C,L){return k=+k,C>>>=0,L||V(this,k,C,1,255,0),this[C]=255&k,C+1},c.prototype.writeUInt16LE=function(k,C,L){return k=+k,C>>>=0,L||V(this,k,C,2,65535,0),this[C]=255&k,this[C+1]=k>>>8,C+2},c.prototype.writeUInt16BE=function(k,C,L){return k=+k,C>>>=0,L||V(this,k,C,2,65535,0),this[C]=k>>>8,this[C+1]=255&k,C+2},c.prototype.writeUInt32LE=function(k,C,L){return k=+k,C>>>=0,L||V(this,k,C,4,4294967295,0),this[C+3]=k>>>24,this[C+2]=k>>>16,this[C+1]=k>>>8,this[C]=255&k,C+4},c.prototype.writeUInt32BE=function(k,C,L){return k=+k,C>>>=0,L||V(this,k,C,4,4294967295,0),this[C]=k>>>24,this[C+1]=k>>>16,this[C+2]=k>>>8,this[C+3]=255&k,C+4},c.prototype.writeIntLE=function(k,C,L,H){if(k=+k,C>>>=0,!H){var X=Math.pow(2,8*L-1);V(this,k,C,L,X-1,-X)}var Q=0,ne=1,ye=0;for(this[C]=255&k;++Q>0)-ye&255;return C+L},c.prototype.writeIntBE=function(k,C,L,H){if(k=+k,C>>>=0,!H){var X=Math.pow(2,8*L-1);V(this,k,C,L,X-1,-X)}var Q=L-1,ne=1,ye=0;for(this[C+Q]=255&k;--Q>=0&&(ne*=256);)k<0&&ye===0&&this[C+Q+1]!==0&&(ye=1),this[C+Q]=(k/ne>>0)-ye&255;return C+L},c.prototype.writeInt8=function(k,C,L){return k=+k,C>>>=0,L||V(this,k,C,1,127,-128),k<0&&(k=255+k+1),this[C]=255&k,C+1},c.prototype.writeInt16LE=function(k,C,L){return k=+k,C>>>=0,L||V(this,k,C,2,32767,-32768),this[C]=255&k,this[C+1]=k>>>8,C+2},c.prototype.writeInt16BE=function(k,C,L){return k=+k,C>>>=0,L||V(this,k,C,2,32767,-32768),this[C]=k>>>8,this[C+1]=255&k,C+2},c.prototype.writeInt32LE=function(k,C,L){return k=+k,C>>>=0,L||V(this,k,C,4,2147483647,-2147483648),this[C]=255&k,this[C+1]=k>>>8,this[C+2]=k>>>16,this[C+3]=k>>>24,C+4},c.prototype.writeInt32BE=function(k,C,L){return k=+k,C>>>=0,L||V(this,k,C,4,2147483647,-2147483648),k<0&&(k=4294967295+k+1),this[C]=k>>>24,this[C+1]=k>>>16,this[C+2]=k>>>8,this[C+3]=255&k,C+4},c.prototype.writeFloatLE=function(k,C,L){return q(this,k,C,!0,L)},c.prototype.writeFloatBE=function(k,C,L){return q(this,k,C,!1,L)},c.prototype.writeDoubleLE=function(k,C,L){return Y(this,k,C,!0,L)},c.prototype.writeDoubleBE=function(k,C,L){return Y(this,k,C,!1,L)},c.prototype.copy=function(k,C,L,H){if(!c.isBuffer(k))throw new TypeError("argument should be a Buffer");if(L||(L=0),H||H===0||(H=this.length),C>=k.length&&(C=k.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),k.length-C=0;--Q)k[Q+C]=this[Q+L];else Uint8Array.prototype.set.call(k,this.subarray(L,H),C);return X},c.prototype.fill=function(k,C,L,H){if(typeof k=="string"){if(typeof C=="string"?(H=C,C=0,L=this.length):typeof L=="string"&&(H=L,L=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(k.length===1){var X=k.charCodeAt(0);(H==="utf8"&&X<128||H==="latin1")&&(k=X)}}else typeof k=="number"&&(k&=255);if(C<0||this.length>>=0,L=L===void 0?this.length:L>>>0,k||(k=0),typeof k=="number")for(Q=C;Q55295&&L<57344){if(!X){if(L>56319){(C-=3)>-1&&Q.push(239,191,189);continue}if(ne+1===H){(C-=3)>-1&&Q.push(239,191,189);continue}X=L;continue}if(L<56320){(C-=3)>-1&&Q.push(239,191,189),X=L;continue}L=65536+(X-55296<<10|L-56320)}else X&&(C-=3)>-1&&Q.push(239,191,189);if(X=null,L<128){if((C-=1)<0)break;Q.push(L)}else if(L<2048){if((C-=2)<0)break;Q.push(L>>6|192,63&L|128)}else if(L<65536){if((C-=3)<0)break;Q.push(L>>12|224,L>>6&63|128,63&L|128)}else{if(!(L<1114112))throw new Error("Invalid code point");if((C-=4)<0)break;Q.push(L>>18|240,L>>12&63|128,L>>6&63|128,63&L|128)}}return Q}function ee(k){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}(k))}function he(k,C,L,H){for(var X=0;X=C.length||X>=k.length);++X)C[X+L]=k[X];return X}function le(k,C){return k instanceof C||k!=null&&k.constructor!=null&&k.constructor.name!=null&&k.constructor.name===C.name}function se(k){return k!=k}}).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,(E,I)=>{if(E==="%%")return"%";_++;const P=o.formatters[I];if(typeof P=="function"){const M=p[_];E=P.call(m,M),p.splice(_,1),_--}return E}),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 G=new Error("Possible EventEmitter memory leak detected. "+U.length+' "'+String(E)+'" listeners added. Use emitter.setMaxListeners() to increase limit.');G.name="MaxListenersExceededWarning",G.emitter=_,G.type=E,G.count=U.length,typeof console=="object"&&console.warn&&console.warn("%s: %s",G.name,G.message)}}else U=D[E]=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),E=0;E<_.length;++E)_[E]=arguments[E];this.listener.apply(this.target,_)}}function p(_,E,I){var P={fired:!1,wrapFn:void 0,target:_,type:E,listener:I},M=s.call(y,P);return M.listener=I,P.wrapFn=M,M}function m(_,E,I){var P=_._events;if(!P)return[];var M=P[E];return M?typeof M=="function"?I?[M.listener||M]:[M]:I?function(D){for(var U=new Array(D.length),G=0;G1&&(E=arguments[1]),E instanceof Error)throw E;var T=new Error('Unhandled "error" event. ('+E+")");throw T.context=E,T}if(!(I=U[_]))return!1;var S=typeof I=="function";switch(P=arguments.length){case 1:(function(R,O,K){if(O)R.call(K);else for(var $=R.length,ae=x(R,$),V=0;V<$;++V)ae[V].call(K)})(I,S,this);break;case 2:(function(R,O,K,$){if(O)R.call(K,$);else for(var ae=R.length,V=x(R,ae),F=0;F=0;D--)if(I[D]===E||I[D].listener===E){U=I[D].listener,M=D;break}if(M<0)return this;M===0?I.shift():function(G,T){for(var S=T,R=S+1,O=G.length;R=0;P--)this.removeListener(_,E[P]);return this},h.prototype.listeners=function(_){return m(this,_,!0)},h.prototype.rawListeners=function(_){return m(this,_,!1)},h.listenerCount=function(_,E){return typeof _.listenerCount=="function"?_.listenerCount(E):b.call(_,E)},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,E=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*E}},{}],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(E/o.bucketSize),curNodePointerIndex:E%o.bucketSize}};this.getElementByPos=function(x){var _=m(x),E=_.curNodeBucketIndex,I=_.curNodePointerIndex;return l[E][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 E=[],I=x+1;I0?--g:c0&&--p)},this.setElementByPos=function(x,_){var E=m(x),I=E.curNodeBucketIndex,P=E.curNodePointerIndex;l[I][P]=_},this.insert=function(x,_,E){var I=this;if(E===void 0&&(E=1),x===0)for(;E--;)this.pushFront(_);else if(x===this.size())for(;E--;)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 E=_.length;l=[];for(var I=Math.ceil(E/o.bucketSize),P=0;P0&&y[y.length-1])&&(E[0]===6||E[0]===2)){m=0;continue}if(E[0]===3&&(!y||E[1]>y[0]&&E[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,_,E=0,I="";if(typeof b=="number")E=((E=Math.floor(b))<<5)-E,E&=E;else{I=typeof b!="string"?JSON.stringify(b):b;try{for(var P=o(I),M=P.next();!M.done;M=P.next())E=(E<<5)-E+M.value.charCodeAt(0),E&=E}catch(D){x={error:D}}finally{try{M&&!M.done&&(_=P.return)&&_.call(P)}finally{if(x)throw x.error}}}return E^=E>>>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(E){b(E,x++)})})},this.setElement=function(b,x){var _,E;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]),D=M.next();!D.done;D=M.next()){var U=D.value;if(U.key===b)return void(U.value=x)}}catch(T){_={error:T}}finally{try{D&&!D.done&&(E=M.return)&&E.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 G=p[I].size();y+=G-P}else++y,p[I]=new s.default([{key:b,value:x}]);y>m*l.sigma&&function(T){if(!(T>=l.maxSize)){m=2*T;var S=[];p.forEach(function(R,O){if(!R.empty()){if(R instanceof s.default&&R.size()===1){var K=R.front(),$=K.key,ae=K.value;S[v($)&m-1]=new s.default([{key:$,value:ae}])}else if(R instanceof h.default){var V=new s.default,F=new s.default;R.forEach(function(W){(v(W.key)&T)==0?V.pushBack(W):F.pushBack(W)}),V.size()>l.untreeifyThreshold?S[O]=new h.default(V):V.size()&&(S[O]=V),F.size()>l.untreeifyThreshold?S[O+T]=new h.default(F):F.size()&&(S[O+T]=F)}else{var q=new s.default,Y=new s.default;R.forEach(function(W){(v(W.key)&T)==0?q.pushBack(W):Y.pushBack(W)}),q.size()&&(S[O]=q),Y.size()&&(S[O+T]=Y)}p[O].clear()}}),p=S}}.call(this,m)}else this.eraseElementByKey(b)},this.getElementByKey=function(b){var x,_,E=v(b)&m-1;if(p[E]){if(p[E]instanceof h.default)return p[E].getElementByKey(b);try{for(var I=o(p[E]),P=I.next();!P.done;P=I.next()){var M=P.value;if(M.key===b)return M.value}}catch(D){x={error:D}}finally{try{P&&!P.done&&(_=I.return)&&_.call(I)}finally{if(x)throw x.error}}}},this.eraseElementByKey=function(b){var x,_,E=v(b)&m-1;if(p[E]){var I=p[E].size();if(p[E]instanceof h.default)p[E].eraseElementByKey(b),p[E].size()<=l.untreeifyThreshold&&(p[E]=new s.default(p[E]));else{var P=-1;try{for(var M=o(p[E]),D=M.next();!D.done;D=M.next())if(++P,D.value.key===b){p[E].eraseElementByPos(P);break}}catch(G){x={error:G}}finally{try{D&&!D.done&&(_=M.return)&&_.call(M)}finally{if(x)throw x.error}}}var U=p[E].size();y+=U-I}},this.find=function(b){var x,_,E=v(b)&m-1;if(!p[E])return!1;if(p[E]instanceof h.default)return p[E].find(b);try{for(var I=o(p[E]),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,_,E,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 E=M.sent(),I={error:E},[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(E){if(v)throw new TypeError("Generator is already executing.");for(;m;)try{if(v=1,g&&(y=2&E[0]?g.return:E[0]?g.throw||((y=g.return)&&y.call(g),0):g.next)&&!(y=y.call(g,E[1])).done)return y;switch(g=0,y&&(E=[2&E[0],y.value]),E[0]){case 0:case 1:y=E;break;case 4:return m.label++,{value:E[1],done:!1};case 5:m.label++,g=E[1],E=[0];continue;case 7:E=m.ops.pop(),m.trys.pop();continue;default:if(!(y=(y=m.trys).length>0&&y[y.length-1])&&(E[0]===6||E[0]===2)){m=0;continue}if(E[0]===3&&(!y||E[1]>y[0]&&E[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 E=0;E<_.length;E++)x=(x<<5)-x+_.charCodeAt(E),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(E){b(E,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 E=p[x].size();y+=E-_}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,D){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 G=new h.default,T=new h.default;M.forEach(function(O){(v(O)&I)==0?G.pushBack(O):T.pushBack(O)}),G.size()>l.untreeifyThreshold?P[D]=new s.default(G):G.size()&&(P[D]=G),T.size()>l.untreeifyThreshold?P[D+I]=new s.default(T):T.size()&&(P[D+I]=T)}else{var S=new h.default,R=new h.default;M.forEach(function(O){(v(O)&I)==0?S.pushBack(O):R.pushBack(O)}),S.size()&&(P[D]=S),R.size()&&(P[D+I]=R)}p[D].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 E=p[x].size();y+=E-_}},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,_,E,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 E=M.sent(),I={error:E},[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(T,S){return TS?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(T){if(!T||T.key===void 0)throw new Error("unknown error");return T.leftChild?y(T.leftChild):T},p=function(T){if(!T||T.key===void 0)throw new Error("unknown error");return T.rightChild?p(T.rightChild):T};this.front=function(){if(!this.empty()){var T=y(g);if(T.key===void 0||T.value===void 0)throw new Error("unknown error");return{key:T.key,value:T.value}}},this.back=function(){if(!this.empty()){var T=p(g);if(T.key===void 0||T.value===void 0)throw new Error("unknown error");return{key:T.key,value:T.value}}},this.forEach=function(T){var S,R,O=0;try{for(var K=o(this),$=K.next();!$.done;$=K.next())T($.value,O++)}catch(ae){S={error:ae}}finally{try{$&&!$.done&&(R=K.return)&&R.call(K)}finally{if(S)throw S.error}}},this.getElementByPos=function(T){var S,R;if(T<0||T>=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),$=K.next();!$.done;$=K.next()){var ae=$.value;if(O===T)return ae;++O}}catch(V){S={error:V}}finally{try{$&&!$.done&&(R=K.return)&&R.call(K)}finally{if(S)throw S.error}}throw new Error("unknown Error")};var m=function(T,S){if(T&&T.key!==void 0&&T.value!==void 0){var R=c(T.key,S);return R===0?{key:T.key,value:T.value}:R<0?m(T.rightChild,S):m(T.leftChild,S)||{key:T.key,value:T.value}}};this.lowerBound=function(T){return m(g,T)};var b=function(T,S){if(T&&T.key!==void 0&&T.value!==void 0)return c(T.key,S)<=0?b(T.rightChild,S):b(T.leftChild,S)||{key:T.key,value:T.value}};this.upperBound=function(T){return b(g,T)};var x=function(T,S){if(T&&T.key!==void 0&&T.value!==void 0){var R=c(T.key,S);return R===0?{key:T.key,value:T.value}:R>0?x(T.leftChild,S):x(T.rightChild,S)||{key:T.key,value:T.value}}};this.reverseLowerBound=function(T){return x(g,T)};var _=function(T,S){if(T&&T.key!==void 0&&T.value!==void 0)return c(T.key,S)>=0?_(T.leftChild,S):_(T.rightChild,S)||{key:T.key,value:T.value}};this.reverseUpperBound=function(T){return _(g,T)};var E=function(T){var S=T.parent;if(!S){if(T===g)return;throw new Error("unknown error")}if(T.color!==s.default.TreeNodeColorType.red){var R=T.brother;if(!R)throw new Error("unknown error");if(T===S.leftChild)if(R.color===s.default.TreeNodeColorType.red){R.color=s.default.TreeNodeColorType.black,S.color=s.default.TreeNodeColorType.red;var O=S.rotateLeft();g===S&&(g=O),E(T)}else R.color===s.default.TreeNodeColorType.black&&(R.rightChild&&R.rightChild.color===s.default.TreeNodeColorType.red?(R.color=S.color,S.color=s.default.TreeNodeColorType.black,R.rightChild&&(R.rightChild.color=s.default.TreeNodeColorType.black),O=S.rotateLeft(),g===S&&(g=O),T.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,E(S)):(R.color=s.default.TreeNodeColorType.red,R.leftChild&&(R.leftChild.color=s.default.TreeNodeColorType.black),O=R.rotateRight(),g===R&&(g=O),E(T)));else T===S.rightChild&&(R.color===s.default.TreeNodeColorType.red?(R.color=s.default.TreeNodeColorType.black,S.color=s.default.TreeNodeColorType.red,O=S.rotateRight(),g===S&&(g=O),E(T)):R.color===s.default.TreeNodeColorType.black&&(R.leftChild&&R.leftChild.color===s.default.TreeNodeColorType.red?(R.color=S.color,S.color=s.default.TreeNodeColorType.black,R.leftChild&&(R.leftChild.color=s.default.TreeNodeColorType.black),O=S.rotateRight(),g===S&&(g=O),T.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,E(S)):(R.color=s.default.TreeNodeColorType.red,R.rightChild&&(R.rightChild.color=s.default.TreeNodeColorType.black),O=R.rotateLeft(),g===R&&(g=O),E(T))))}else T.color=s.default.TreeNodeColorType.black},I=function(T){for(var S=T;S.leftChild||S.rightChild;){if(S.rightChild){S=y(S.rightChild);var R=T.key;T.key=S.key,S.key=R;var O=T.value;T.value=S.value,S.value=O,T=S}S.leftChild&&(S=p(S.leftChild),R=T.key,T.key=S.key,S.key=R,O=T.value,T.value=S.value,S.value=O,T=S)}E(S),S&&S.remove(),--v,g.color=s.default.TreeNodeColorType.black},P=function(T,S){return!(!T||T.key===void 0)&&(!!P(T.leftChild,S)||!!S(T)||P(T.rightChild,S))};this.eraseElementByPos=function(T){if(T<0||T>=v)throw new Error("pos must more than 0 and less than set's size");var S=0;P(g,function(R){return T===S?(I(R),!0):(++S,!1)})},this.eraseElementByKey=function(T){if(!this.empty()){var S=U(g,T);S!==void 0&&S.key!==void 0&&c(S.key,T)===0&&I(S)}};var M=function(T,S){if(!T||T.key===void 0)throw new Error("unknown error");var R=c(S,T.key);return R<0?T.leftChild?M(T.leftChild,S):(T.leftChild=new s.default,T.leftChild.parent=T,T.leftChild.brother=T.rightChild,T.rightChild&&(T.rightChild.brother=T.leftChild),T.leftChild):R>0?T.rightChild?M(T.rightChild,S):(T.rightChild=new s.default,T.rightChild.parent=T,T.rightChild.brother=T.leftChild,T.leftChild&&(T.leftChild.brother=T.rightChild),T.rightChild):T},D=function(T){var S=T.parent;if(!S){if(T===g)return;throw new Error("unknown error")}if(S.color!==s.default.TreeNodeColorType.black&&S.color===s.default.TreeNodeColorType.red){var R=S.brother,O=S.parent;if(!O)throw new Error("unknown error");if(R&&R.color===s.default.TreeNodeColorType.red)R.color=S.color=s.default.TreeNodeColorType.black,O.color=s.default.TreeNodeColorType.red,D(O);else if(!R||R.color===s.default.TreeNodeColorType.black)if(S===O.leftChild)if(T===S.leftChild){S.color=s.default.TreeNodeColorType.black,O.color=s.default.TreeNodeColorType.red;var K=O.rotateRight();O===g&&(g=K)}else T===S.rightChild&&(K=S.rotateLeft(),O===g&&(g=K),D(S));else S===O.rightChild&&(T===S.leftChild?(K=S.rotateRight(),O===g&&(g=K),D(S)):T===S.rightChild&&(S.color=s.default.TreeNodeColorType.black,O.color=s.default.TreeNodeColorType.red,K=O.rotateLeft(),O===g&&(g=K)))}};this.setElement=function(T,S){if(T==null)throw new Error("to avoid some unnecessary errors, we don't suggest you insert null or undefined here");if(S!=null){if(this.empty())return++v,g.key=T,g.value=S,void(g.color=s.default.TreeNodeColorType.black);var R=M(g,T);R.key===void 0||c(R.key,T)!==0?(++v,R.key=T,R.value=S,D(R),g.color=s.default.TreeNodeColorType.black):R.value=S}else this.eraseElementByKey(T)};var U=function(T,S){if(T&&T.key!==void 0){var R=c(S,T.key);return R<0?U(T.leftChild,S):R>0?U(T.rightChild,S):T}};this.find=function(T){return!!U(g,T)},this.getElementByKey=function(T){var S=U(g,T);if((S==null?void 0:S.key)===void 0||(S==null?void 0:S.value)===void 0)throw new Error("unknown error");return S.value},this.union=function(T){var S=this;T.forEach(function(R){var O=R.key,K=R.value;return S.setElement(O,K)})},this.getHeight=function(){if(this.empty())return 0;var T=function(S){return S?Math.max(T(S.leftChild),T(S.rightChild))+1:1};return T(g)};var G=function(T){return n(this,function(S){switch(S.label){case 0:return T&&T.key!==void 0&&T.value!==void 0?[5,o(G(T.leftChild))]:[2];case 1:return S.sent(),[4,{key:T.key,value:T.value}];case 2:return S.sent(),[5,o(G(T.rightChild))];case 3:return S.sent(),[2]}})};this[Symbol.iterator]=function(){return G(g)},l.forEach(function(T){var S=T.key,R=T.value;return f.setElement(S,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(T,S){return TS?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(T){if(!T||T.key===void 0)throw new Error("unknown error");return T.leftChild?y(T.leftChild):T},p=function(T){if(!T||T.key===void 0)throw new Error("unknown error");return T.rightChild?p(T.rightChild):T};this.front=function(){if(!this.empty())return y(g).key},this.back=function(){if(!this.empty())return p(g).key},this.forEach=function(T){var S,R,O=0;try{for(var K=o(this),$=K.next();!$.done;$=K.next())T($.value,O++)}catch(ae){S={error:ae}}finally{try{$&&!$.done&&(R=K.return)&&R.call(K)}finally{if(S)throw S.error}}},this.getElementByPos=function(T){var S,R;if(T<0||T>=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),$=K.next();!$.done;$=K.next()){var ae=$.value;if(O===T)return ae;++O}}catch(V){S={error:V}}finally{try{$&&!$.done&&(R=K.return)&&R.call(K)}finally{if(S)throw S.error}}throw new Error("unknown error")};var m=function(T){var S=T.parent;if(!S){if(T===g)return;throw new Error("unknown error")}if(T.color!==s.default.TreeNodeColorType.red){var R=T.brother;if(!R)throw new Error("unknown error");if(T===S.leftChild)if(R.color===s.default.TreeNodeColorType.red){R.color=s.default.TreeNodeColorType.black,S.color=s.default.TreeNodeColorType.red;var O=S.rotateLeft();g===S&&(g=O),m(T)}else R.color===s.default.TreeNodeColorType.black&&(R.rightChild&&R.rightChild.color===s.default.TreeNodeColorType.red?(R.color=S.color,S.color=s.default.TreeNodeColorType.black,R.rightChild&&(R.rightChild.color=s.default.TreeNodeColorType.black),O=S.rotateLeft(),g===S&&(g=O),T.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(S)):(R.color=s.default.TreeNodeColorType.red,R.leftChild&&(R.leftChild.color=s.default.TreeNodeColorType.black),O=R.rotateRight(),g===R&&(g=O),m(T)));else T===S.rightChild&&(R.color===s.default.TreeNodeColorType.red?(R.color=s.default.TreeNodeColorType.black,S.color=s.default.TreeNodeColorType.red,O=S.rotateRight(),g===S&&(g=O),m(T)):R.color===s.default.TreeNodeColorType.black&&(R.leftChild&&R.leftChild.color===s.default.TreeNodeColorType.red?(R.color=S.color,S.color=s.default.TreeNodeColorType.black,R.leftChild&&(R.leftChild.color=s.default.TreeNodeColorType.black),O=S.rotateRight(),g===S&&(g=O),T.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(S)):(R.color=s.default.TreeNodeColorType.red,R.rightChild&&(R.rightChild.color=s.default.TreeNodeColorType.black),O=R.rotateLeft(),g===R&&(g=O),m(T))))}else T.color=s.default.TreeNodeColorType.black},b=function(T){for(var S=T;S.leftChild||S.rightChild;){if(S.rightChild){S=y(S.rightChild);var R=T.key;T.key=S.key,S.key=R,T=S}S.leftChild&&(S=p(S.leftChild),R=T.key,T.key=S.key,S.key=R,T=S)}m(S),S&&S.remove(),--v,g.color=s.default.TreeNodeColorType.black},x=function(T,S){return!(!T||T.key===void 0)&&(!!x(T.leftChild,S)||!!S(T)||x(T.rightChild,S))};this.eraseElementByPos=function(T){if(T<0||T>=v)throw new Error("pos must more than 0 and less than set's size");var S=0;x(g,function(R){return T===S?(b(R),!0):(++S,!1)})},this.eraseElementByValue=function(T){if(!this.empty()){var S=I(g,T);S!==void 0&&S.key!==void 0&&c(S.key,T)===0&&b(S)}};var _=function(T,S){if(!T||T.key===void 0)throw new Error("unknown error");var R=c(S,T.key);return R<0?T.leftChild?_(T.leftChild,S):(T.leftChild=new s.default,T.leftChild.parent=T,T.leftChild.brother=T.rightChild,T.rightChild&&(T.rightChild.brother=T.leftChild),T.leftChild):R>0?T.rightChild?_(T.rightChild,S):(T.rightChild=new s.default,T.rightChild.parent=T,T.rightChild.brother=T.leftChild,T.leftChild&&(T.leftChild.brother=T.rightChild),T.rightChild):T},E=function(T){var S=T.parent;if(!S){if(T===g)return;throw new Error("unknown error")}if(S.color!==s.default.TreeNodeColorType.black&&S.color===s.default.TreeNodeColorType.red){var R=S.brother,O=S.parent;if(!O)throw new Error("unknown error");if(R&&R.color===s.default.TreeNodeColorType.red)R.color=S.color=s.default.TreeNodeColorType.black,O.color=s.default.TreeNodeColorType.red,E(O);else if(!R||R.color===s.default.TreeNodeColorType.black)if(S===O.leftChild)if(T===S.leftChild){S.color=s.default.TreeNodeColorType.black,O.color=s.default.TreeNodeColorType.red;var K=O.rotateRight();O===g&&(g=K)}else T===S.rightChild&&(K=S.rotateLeft(),O===g&&(g=K),E(S));else S===O.rightChild&&(T===S.leftChild?(K=S.rotateRight(),O===g&&(g=K),E(S)):T===S.rightChild&&(S.color=s.default.TreeNodeColorType.black,O.color=s.default.TreeNodeColorType.red,K=O.rotateLeft(),O===g&&(g=K)))}};this.insert=function(T){if(T==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=T,void(g.color=s.default.TreeNodeColorType.black);var S=_(g,T);S.key!==void 0&&c(S.key,T)===0||(++v,S.key=T,E(S),g.color=s.default.TreeNodeColorType.black)};var I=function(T,S){if(T&&T.key!==void 0){var R=c(S,T.key);return R<0?I(T.leftChild,S):R>0?I(T.rightChild,S):T}};this.find=function(T){var S=I(g,T);return S!==void 0&&S.key!==void 0&&c(S.key,T)===0};var P=function(T,S){if(T&&T.key!==void 0){var R=c(T.key,S);if(R===0)return T.key;if(R<0)return P(T.rightChild,S);var O=P(T.leftChild,S);return O!==void 0?O:T.key}};this.lowerBound=function(T){return P(g,T)};var M=function(T,S){if(T&&T.key!==void 0){if(c(T.key,S)<=0)return M(T.rightChild,S);var R=M(T.leftChild,S);return R!==void 0?R:T.key}};this.upperBound=function(T){return M(g,T)};var D=function(T,S){if(T&&T.key!==void 0){var R=c(T.key,S);if(R===0)return T.key;if(R>0)return D(T.leftChild,S);var O=D(T.rightChild,S);return O!==void 0?O:T.key}};this.reverseLowerBound=function(T){return D(g,T)};var U=function(T,S){if(T&&T.key!==void 0){if(c(T.key,S)>=0)return U(T.leftChild,S);var R=U(T.rightChild,S);return R!==void 0?R:T.key}};this.reverseUpperBound=function(T){return U(g,T)},this.union=function(T){var S=this;T.forEach(function(R){return S.insert(R)})},this.getHeight=function(){if(this.empty())return 0;var T=function(S){return S?Math.max(T(S.leftChild),T(S.rightChild))+1:1};return T(g)};var G=function(T){return n(this,function(S){switch(S.label){case 0:return T&&T.key!==void 0?[5,o(G(T.leftChild))]:[2];case 1:return S.sent(),[4,T.key];case 2:return S.sent(),[5,o(G(T.rightChild))];case 3:return S.sent(),[2]}})};this[Symbol.iterator]=function(){return G(g)},l.forEach(function(T){return f.insert(T)}),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(E){if(v)throw new TypeError("Generator is already executing.");for(;m;)try{if(v=1,g&&(y=2&E[0]?g.return:E[0]?g.throw||((y=g.return)&&y.call(g),0):g.next)&&!(y=y.call(g,E[1])).done)return y;switch(g=0,y&&(E=[2&E[0],y.value]),E[0]){case 0:case 1:y=E;break;case 4:return m.label++,{value:E[1],done:!1};case 5:m.label++,g=E[1],E=[0];continue;case 7:E=m.ops.pop(),m.trys.pop();continue;default:if(!(y=(y=m.trys).length>0&&y[y.length-1])&&(E[0]===6||E[0]===2)){m=0;continue}if(E[0]===3&&(!y||E[1]>y[0]&&E[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,D,U)=>{const G=M[y].get(D);if(G){const T=G.value;if(x(M,T)){if(E(M,G),!M[l])return}else U&&(M[p]&&(G.value.now=Date.now()),M[g].unshiftNode(G));return T.value}},x=(M,D)=>{if(!D||!D.maxAge&&!M[c])return!1;const U=Date.now()-D.now;return D.maxAge?U>D.maxAge:M[c]&&U>M[c]},_=M=>{if(M[s]>M[o])for(let D=M[g].tail;M[s]>M[o]&&D!==null;){const U=D.prev;E(M,D),D=U}},E=(M,D)=>{if(D){const U=D.value;M[f]&&M[f](U.key,U.value),M[s]-=U.length,M[y].delete(U.key),M[g].removeNode(D)}};class I{constructor(D,U,G,T,S){this.key=D,this.value=U,this.length=G,this.now=T,this.maxAge=S||0}}const P=(M,D,U,G)=>{let T=U.value;x(M,T)&&(E(M,U),M[l]||(T=void 0)),T&&D.call(G,T.value,T.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 D=M.length||m;if(this[h]=typeof D!="function"?m:D,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(D=>{D.length=this[h](D.value,D.key),this[s]+=D.length})),_(this)}get lengthCalculator(){return this[h]}get length(){return this[s]}get itemCount(){return this[g].length}rforEach(M,D){D=D||this;for(let U=this[g].tail;U!==null;){const G=U.prev;P(this,M,U,D),U=G}}forEach(M,D){D=D||this;for(let U=this[g].head;U!==null;){const G=U.next;P(this,M,U,D),U=G}}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,D,U){if((U=U||this[c])&&typeof U!="number")throw new TypeError("maxAge must be a number");const G=U?Date.now():0,T=this[h](D,M);if(this[y].has(M)){if(T>this[o])return E(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=G,R.maxAge=U,R.value=D,this[s]+=T-R.length,R.length=T,this.get(M),_(this),!0}const S=new I(M,D,T,G,U);return S.length>this[o]?(this[f]&&this[f](M,D),!1):(this[s]+=S.length,this[g].unshift(S),this[y].set(M,this[g].head),_(this),!0)}has(M){if(!this[y].has(M))return!1;const D=this[y].get(M).value;return!x(this,D)}get(M){return b(this,M,!0)}peek(M){return b(this,M,!1)}pop(){const M=this[g].tail;return M?(E(this,M),M.value):null}del(M){E(this,this[y].get(M))}load(M){this.reset();const D=Date.now();for(let U=M.length-1;U>=0;U--){const G=M[U],T=G.e||0;if(T===0)this.set(G.k,G.v);else{const S=T-D;S>0&&this.set(G.k,G.v,S)}}}prune(){this[y].forEach((M,D)=>b(this,D,!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 E=this._parseProperties();Object.getOwnPropertyNames(E).length&&(b.properties=E)}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 E=this._parseProperties();Object.getOwnPropertyNames(E).length&&(b.will.properties=E)}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 E=this._parseProperties();Object.getOwnPropertyNames(E).length&&(v.properties=E)}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 k!="number"||k<0||k>65535||k%1!=0)return W.emit("error",new Error("Invalid keepalive")),!1;if(Q+=2,Q+=1,he===5){var ne=S(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=S(W,le.properties)))return!1;Q+=ye.length}}let ge=!1;if(L!=null){if(!ae(L))return W.emit("error",new Error("Invalid username")),!1;ge=!0,Q+=n.byteLength(L)+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+=$(H)+2}W.write(o.CONNECT_HEADER),P(W,Q),T(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|=L!=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",k),W.write(k)}(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 k=0;const C=ee.reasonCode,L=ee.properties;let H=re===5?3:2;if(he==="pubrel"&&(k=1),typeof le!="number")return W.emit("error",new Error("Invalid messageId")),!1;let X=null;if(re===5&&typeof L=="object"){if(!(X=R(W,L,J,H)))return!1;H+=X.length}return W.write(o.ACKS[he][k][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,k=ee.properties;let C=0;if(typeof le!="number")return W.emit("error",new Error("Invalid messageId")),!1;C+=2;let L=null;if(re===5){if(!(L=S(W,k)))return!1;C+=L.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),L!==null&&L.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 Te;M(W,Q),Te=o.SUBSCRIBE_OPTIONS_QOS[ne],re===5&&(Te|=ye?o.SUBSCRIBE_OPTIONS_NL:0,Te|=ge?o.SUBSCRIBE_OPTIONS_RAP:0,Te|=xe?o.SUBSCRIBE_OPTIONS_RH[xe]:0),H=W.write(n.from([Te]))}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 k=0;if(typeof he!="number")return W.emit("error",new Error("Invalid messageId")),!1;if(k+=2,typeof le!="object"||!le.length)return W.emit("error",new Error("Invalid qos vector")),!1;for(let L=0;Lb===U,set(V){V?(v&&Object.keys(v).length!==0||(x=!0),b=U):(x=!1,b=G)}});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 D(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 G(V,F){const q=g(F);return f("writeNumberGenerated: %o",q),V.write(q)}function T(V,F){typeof F=="string"?M(V,F):F?(b(V,F.length),V.write(F)):b(V,0)}function S(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,k)=>se+=3+n.byteLength(he.toString())+2+n.byteLength(k.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=S(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]])),T(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]])),D(V,Y.toString(),J.toString())}):(V.write(n.from([o.properties[F]])),D(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,G=Math.floor,T=String.fromCharCode;function S(Y){throw new RangeError(D[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+=T((W-=65536)>>>10&1023|55296),W=56320|1023&W),J+=T(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?G(Y/b):Y>>1,Y+=G(Y/W);Y>U*p>>1;re+=g)Y=G(Y/U);return G(re+(U+1)*Y/(Y+m))}function F(Y){var W,J,re,ee,he,le,se,k,C,L,H,X=[],Q=Y.length,ne=0,ye=_,ge=x;for((J=Y.lastIndexOf(E))<0&&(J=0),re=0;re=128&&S("not-basic"),X.push(Y.charCodeAt(re));for(ee=J>0?J+1:0;ee=Q&&S("invalid-input"),((k=(H=Y.charCodeAt(ee++))-48<10?H-22:H-65<26?H-65:H-97<26?H-97:g)>=g||k>G((v-ne)/le))&&S("overflow"),ne+=k*le,!(k<(C=se<=ge?y:se>=ge+p?p:se-ge));se+=g)le>G(v/(L=g-C))&&S("overflow"),le*=L;ge=V(ne-he,W=X.length+1,he==0),G(ne/W)>v-ye&&S("overflow"),ye+=G(ne/W),ne%=W,X.splice(ne++,0,ye)}return $(X)}function q(Y){var W,J,re,ee,he,le,se,k,C,L,H,X,Q,ne,ye,ge=[];for(X=(Y=K(Y)).length,W=_,J=0,he=x,le=0;le=W&&HG((v-J)/(Q=re+1))&&S("overflow"),J+=(se-W)*Q,W=se,le=0;lev&&S("overflow"),H==W){for(k=J,C=g;!(k<(L=C<=he?y:C>=he+p?p:C-he));C+=g)ye=k-L,ne=g-L,ge.push(T(ae(L+ye%ne,0))),k=G(ye/ne);ge.push(T(ae(k,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:$},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=E.substr(0,I),b=E.substr(I+1)):(m=E,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(k,new D):O(k,ne,C,!0);else if(ne.ended)U(k,new P);else{if(ne.destroyed)return!1;ne.reading=!1,ne.decoder&&!L?(C=ne.decoder.write(C),ne.objectMode||C.length!==0?O(k,ne,C,!1):F(k,ne)):O(k,ne,C,!1)}else H||(ne.reading=!1,F(k,ne));return!ne.ended&&(ne.lengthC.highWaterMark&&(C.highWaterMark=function(L){return L>=K?L=K:(L--,L|=L>>>1,L|=L>>>2,L|=L>>>4,L|=L>>>8,L|=L>>>16,L++),L}(k)),k<=C.length?k:C.ended?C.length:(C.needReadable=!0,0))}function ae(k){var C=k._readableState;v("emitReadable",C.needReadable,C.emittedReadable),C.needReadable=!1,C.emittedReadable||(v("emitReadable",C.flowing),C.emittedReadable=!0,n.nextTick(V,k))}function V(k){var C=k._readableState;v("emitReadable_",C.destroyed,C.length,C.ended),C.destroyed||!C.length&&!C.ended||(k.emit("readable"),C.emittedReadable=!1),C.needReadable=!C.flowing&&!C.ended&&C.length<=C.highWaterMark,re(k)}function F(k,C){C.readingMore||(C.readingMore=!0,n.nextTick(q,k,C))}function q(k,C){for(;!C.reading&&!C.ended&&(C.length0,C.resumeScheduled&&!C.paused?C.flowing=!0:k.listenerCount("data")>0&&k.resume()}function W(k){v("readable nexttick read 0"),k.read(0)}function J(k,C){v("resume",C.reading),C.reading||k.read(0),C.resumeScheduled=!1,k.emit("resume"),re(k),C.flowing&&!C.reading&&k.read(0)}function re(k){var C=k._readableState;for(v("flow",C.flowing);C.flowing&&k.read()!==null;);}function ee(k,C){return C.length===0?null:(C.objectMode?L=C.buffer.shift():!k||k>=C.length?(L=C.decoder?C.buffer.join(""):C.buffer.length===1?C.buffer.first():C.buffer.concat(C.length),C.buffer.clear()):L=C.buffer.consume(k,C.decoder),L);var L}function he(k){var C=k._readableState;v("endReadable",C.endEmitted),C.endEmitted||(C.ended=!0,n.nextTick(le,C,k))}function le(k,C){if(v("endReadableNT",k.endEmitted,k.length),!k.endEmitted&&k.length===0&&(k.endEmitted=!0,C.readable=!1,C.emit("end"),k.autoDestroy)){var L=C._writableState;(!L||L.autoDestroy&&L.finished)&&C.destroy()}}function se(k,C){for(var L=0,H=k.length;L=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((k=$(k,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-k0?ee(k,C):null)===null?(C.needReadable=C.length<=C.highWaterMark,k=0):(C.length-=k,C.awaitDrain=0),C.length===0&&(C.ended||(C.needReadable=!0),L!==k&&C.ended&&he(this)),H!==null&&this.emit("data",H),H},S.prototype._read=function(k){U(this,new M("_read()"))},S.prototype.pipe=function(k,C){var L=this,H=this._readableState;switch(H.pipesCount){case 0:H.pipes=k;break;case 1:H.pipes=[H.pipes,k];break;default:H.pipes.push(k)}H.pipesCount+=1,v("pipe count=%d opts=%j",H.pipesCount,C);var X=(!C||C.end!==!1)&&k!==n.stdout&&k!==n.stderr?ne:kt;function Q(qe,Qe){v("onunpipe"),qe===L&&Qe&&Qe.hasUnpiped===!1&&(Qe.hasUnpiped=!0,v("cleanup"),k.removeListener("close",xt),k.removeListener("finish",it),k.removeListener("drain",ye),k.removeListener("error",Te),k.removeListener("unpipe",Q),L.removeListener("end",ne),L.removeListener("end",kt),L.removeListener("data",xe),ge=!0,!H.awaitDrain||k._writableState&&!k._writableState.needDrain||ye())}function ne(){v("onend"),k.end()}H.endEmitted?n.nextTick(X):L.once("end",X),k.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))}}(L);k.on("drain",ye);var ge=!1;function xe(qe){v("ondata");var Qe=k.write(qe);v("dest.write",Qe),Qe===!1&&((H.pipesCount===1&&H.pipes===k||H.pipesCount>1&&se(H.pipes,k)!==-1)&&!ge&&(v("false write response, pause",H.awaitDrain),H.awaitDrain++),L.pause())}function Te(qe){v("onerror",qe),kt(),k.removeListener("error",Te),h(k,"error")===0&&U(k,qe)}function xt(){k.removeListener("finish",it),kt()}function it(){v("onfinish"),k.removeListener("close",xt),kt()}function kt(){v("unpipe"),L.unpipe(k)}return L.on("data",xe),function(qe,Qe,Ai){if(typeof qe.prependListener=="function")return qe.prependListener(Qe,Ai);qe._events&&qe._events[Qe]?Array.isArray(qe._events[Qe])?qe._events[Qe].unshift(Ai):qe._events[Qe]=[Ai,qe._events[Qe]]:qe.on(Qe,Ai)}(k,"error",Te),k.once("close",xt),k.once("finish",it),k.emit("pipe",L),H.flowing||(v("pipe resume"),L.resume()),k},S.prototype.unpipe=function(k){var C=this._readableState,L={hasUnpiped:!1};if(C.pipesCount===0)return this;if(C.pipesCount===1)return k&&k!==C.pipes?this:(k||(k=C.pipes),C.pipes=null,C.pipesCount=0,C.flowing=!1,k&&k.emit("unpipe",this,L),this);if(!k){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()):k==="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))),L},S.prototype.addListener=S.prototype.on,S.prototype.removeListener=function(k,C){var L=l.prototype.removeListener.call(this,k,C);return k==="readable"&&n.nextTick(Y,this),L},S.prototype.removeAllListeners=function(k){var C=l.prototype.removeAllListeners.apply(this,arguments);return k!=="readable"&&k!==void 0||n.nextTick(Y,this),C},S.prototype.resume=function(){var k=this._readableState;return k.flowing||(v("resume"),k.flowing=!k.readableListening,function(C,L){L.resumeScheduled||(L.resumeScheduled=!0,n.nextTick(J,C,L))}(this,k)),k.paused=!1,this},S.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},S.prototype.wrap=function(k){var C=this,L=this._readableState,H=!1;for(var X in k.on("end",function(){if(v("wrapped end"),L.decoder&&!L.ended){var ne=L.decoder.end();ne&&ne.length&&C.push(ne)}C.push(null)}),k.on("data",function(ne){v("wrapped data"),L.decoder&&(ne=L.decoder.write(ne)),(!L.objectMode||ne!=null)&&(L.objectMode||ne&&ne.length)&&(C.push(ne)||(H=!0,k.pause()))}),k)this[X]===void 0&&typeof k[X]=="function"&&(this[X]=function(ne){return function(){return k[ne].apply(k,arguments)}}(X));for(var Q=0;Q-1))throw new D(F);return this._writableState.defaultEncoding=F,this},Object.defineProperty(S.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(S.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),S.prototype._write=function(F,q,Y){Y(new x("_write()"))},S.prototype._writev=null,S.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(S.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(S.prototype,"destroyed",{enumerable:!1,get:function(){return this._writableState!==void 0&&this._writableState.destroyed},set:function(F){this._writableState&&(this._writableState.destroyed=F)}}),S.prototype.destroy=y.destroy,S.prototype._undestroy=y.undestroy,S.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(E,I,P){return I in E?Object.defineProperty(E,I,{value:P,enumerable:!0,configurable:!0,writable:!0}):E[I]=P,E}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(E,I){return{value:E,done:I}}function b(E){var I=E[l];if(I!==null){var P=E[p].read();P!==null&&(E[g]=null,E[l]=null,E[c]=null,I(m(P,!1)))}}var x=Object.getPrototypeOf(function(){}),_=Object.setPrototypeOf((s(o={get stream(){return this[p]},next:function(){var E=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,G){n.nextTick(function(){E[f]?G(E[f]):U(m(void 0,!0))})});var P,M=this[g];if(M)P=new Promise(function(U,G){return function(T,S){U.then(function(){G[v]?T(m(void 0,!0)):G[y](T,S)},S)}}(M,this));else{var D=this[p].read();if(D!==null)return Promise.resolve(m(D,!1));P=new Promise(this[y])}return this[g]=P,P}},Symbol.asyncIterator,function(){return this}),s(o,"return",function(){var E=this;return new Promise(function(I,P){E[p].destroy(null,function(M){M?P(M):I(m(void 0,!0))})})}),o),x);a.exports=function(E){var I,P=Object.create(_,(s(I={},p,{value:E,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:E._readableState.endEmitted,writable:!0}),s(I,y,{value:function(M,D){var U=P[p].read();U?(P[g]=null,P[l]=null,P[c]=null,M(m(U,!1))):(P[l]=M,P[c]=D)},writable:!0}),I));return P[g]=null,h(E,function(M){if(M&&M.code!=="ERR_STREAM_PREMATURE_CLOSE"){var D=P[c];return D!==null&&(P[g]=null,P[l]=null,P[c]=null,D(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}),E.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,E=0;_;)p=_.data,m=x,b=E,h.prototype.copy.call(p,m,b),E+=_.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),E||(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(_,E,I){if((192&E[0])!=128)return _.lastNeed=0,"\uFFFD";if(_.lastNeed>1&&E.length>1){if((192&E[1])!=128)return _.lastNeed=1,"\uFFFD";if(_.lastNeed>2&&E.length>2&&(192&E[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?(D>0&&(E.lastNeed=D-1),D):--M=0?(D>0&&(E.lastNeed=D-2),D):--M=0?(D>0&&(D===2?D=0:E.lastNeed=D-3),D):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},E=i("querystring");function I(P,M,D){if(P&&o.isObject(P)&&P instanceof s)return P;var U=new s;return U.parse(P,M,D),U}s.prototype.parse=function(P,M,D){if(!o.isString(P))throw new TypeError("Parameter 'url' must be a string, not "+typeof P);var U=P.indexOf("?"),G=U!==-1&&U127?he+="x":he+=ee[le];if(!he.match(p)){var k=J.slice(0,q),C=J.slice(q+1),L=ee.match(m);L&&(k.push(L[1]),C.unshift(L[2])),C.length&&(S="/"+C.join(".")+S),this.hostname=k.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),S[0]!=="/"&&(S="/"+S))}if(!b[K])for(q=0,re=v.length;q0)&&D.host.split("@"))&&(D.auth=L.shift(),D.host=D.hostname=L.shift())),D.search=P.search,D.query=P.query,o.isNull(D.pathname)&&o.isNull(D.search)||(D.path=(D.pathname?D.pathname:"")+(D.search?D.search:"")),D.href=D.format(),D;if(!ee.length)return D.pathname=null,D.search?D.path="/"+D.search:D.path=null,D.href=D.format(),D;for(var le=ee.slice(-1)[0],se=(D.host||P.host||ee.length>1)&&(le==="."||le==="..")||le==="",k=0,C=ee.length;C>=0;C--)(le=ee[C])==="."?ee.splice(C,1):le===".."?(ee.splice(C,1),k++):k&&(ee.splice(C,1),k--);if(!J&&!re)for(;k--;k)ee.unshift("..");!J||ee[0]===""||ee[0]&&ee[0].charAt(0)==="/"||ee.unshift(""),se&&ee.join("/").substr(-1)!=="/"&&ee.push("");var L,H=ee[0]===""||ee[0]&&ee[0].charAt(0)==="/";return he&&(D.hostname=D.host=H?"":ee.length?ee.shift():"",(L=!!(D.host&&D.host.indexOf("@")>0)&&D.host.split("@"))&&(D.auth=L.shift(),D.host=D.hostname=L.shift())),(J=J||D.host&&ee.length)&&!H&&ee.unshift(""),ee.length?D.pathname=ee.join("/"):(D.pathname=null,D.path=null),o.isNull(D.pathname)&&o.isNull(D.search)||(D.path=(D.pathname?D.pathname:"")+(D.search?D.search:"")),D.auth=P.auth||D.auth,D.slashes=D.slashes||P.slashes,D.href=D.format(),D},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[D]>+U;break;case">=":_=r[D]>=+U;break;case"<":_=r[D]<+U;break;case"<=":_=r[D]<=+U;break;case"=":case"==":_=r[D]==U;break;case"!=":_=r[D]!=U;break;case"[)":_=ko(+r[D],U);break;case"![)":_=!ko(+r[D],U);break;case"[]":_=Eo(r[D],U);break;case"![]":_=!Eo(r[D],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(_,E){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(E)}),(b=p.triggers)===null||b===void 0||b.forEach(function(_,E){var I;x.includes(E)&&((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=Xo,this.setElemPosition=Ei,this.setLifeCycleFunc=xx,this.store=A_(Me()),this.setOptions(i),this.setDatabyOptions(i),this.init(t),this.register(Q2()),this.registerCanvasDraw({cube:l2}),this.registerAnchors(J2()),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 gv(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 Kf(this,document.getElementById(t),this.store):this.canvas=new Kf(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=mf(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=Wo.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),E=_.next();!E.done;E=_.next()){var I=E.value;O_(I,function(){f.render()})}}catch(P){l={error:P}}finally{try{E&&!E.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,Ee.path2dDraws[r.name]&&i.store.path2dMap.set(r,Ee.path2dDraws[r.name](r)),r.type&&i.store.path2dMap.set(r,Ee.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&&yv(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=Ue(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}}T_(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=$e.Node,this.canvas.active(t),this.pushHistory({type:we.Update,initPens:r,pens:ce(t,!0)}),this.render();return}var n=Fi(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 ti(t,i)},e.prototype.data=function(){var t=ce(this.store.data),i=this.store.data,a=i.pens,r=i.paths;t.version=Od.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=Wo.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]=Wo.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=ko(+v,f);break;case"![)":c=!ko(+v,f);break;case"[]":c=Eo(v,f);break;case"![]":c=!Eo(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=zo(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||!Qo(s,this.store)||Xo(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),Fi(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=Ji(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=Ji(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=Ji(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=Ji(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=Ji(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];en.forEach(function(o){a[o]=r[o]||t.store.options.defaultFormat[o]||t.store.options[o]})}else{var n={};en.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 ok(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(mr(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(mr(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(mr(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||W_(b,t))return!1;var _=b.calculative.worldRect;return Jo(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&&Ei(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(mr(c,o.store)),!1),[c],!1),g=[],y=function(x){var _=f[x];v.findIndex(function(E){return E.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(mr(c,o.store)),!1),[c],!1),g=[],y=function(x){var _=f[x];v.findIndex(function(E){return E.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===$e.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=Ea(t,{x:o.x+o.width/2,y:o.y+o.height/2})}if(!r){var o=t.calculative.worldRect;r=Ea(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=$e.Node,r.id=void 0,[r]}var n=ce(t,!0),o=Fi(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=zo(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&&kx(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=mr(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,Ee[this.store.id]=void 0,!t){for(var i in Ee)delete Ee[i];Ee.path2dDraws={},Ee.canvasDraws={},Ee.anchors={},Ee.htmlElements={}}},e}();function sk(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 lk(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 ck(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 uk(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 hk(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 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;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 dk(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 vk(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 gk(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 yk(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 mk(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 gA(){return{flowComment:sk,flowData:lk,flowDb:mk,flowDisplay:ck,flowDocument:uk,flowExternStorage:hk,flowInternalStorage:fk,flowManually:dk,flowParallel:vk,flowQueue:gk,flowSubprocess:yk}}globalThis&&globalThis.__values;var is;(function(e){e[e.Add=0]="Add",e[e.Replace=1]="Replace",e[e.ReplaceAll=2]="ReplaceAll"})(is||(is={}));function mv(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 pv(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+=mv(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 pk(e,t){t.onClick||(t.onClick=wk);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 wk(e){e.disabled||e.disable||(e.checked=!e.checked,e.calculative.canvas.store.emitter.emit("valueUpdate",e),e.calculative.canvas.render())}function bk(e,t){t.onAdd||(t.onAdd=sn,t.onResize=sn,t.onMove=sn,t.onMouseMove=_k,t.onMouseDown=wv,t.onValue=xk,t.onBeforeValue=kk),t.calculative.barRect||sn(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 sn(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),Cc(e)}}function Cc(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,Bi(e)}function wv(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,Cc(e),e.calculative.text=e.value+e.unit,Bi(e),e.calculative.canvas.store.emitter.emit("valueUpdate",e),e.calculative.canvas.render())}}}function _k(e,t){e.calculative.canvas.mouseDown&&wv(e,t)}function xk(e){e.calculative.isUpdateData&&(delete e.calculative.isUpdateData,sn(e)),Cc(e)}function kk(e,t){return e.calculative.isUpdateData=!1,(t.textWidth||t.barHeight)&&(t.textWidth&&(e._textWidth=0),e.calculative.isUpdateData=!0),t}function Ek(e,t){t.onMouseDown||(t.onMouseDown=Ck);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":Cr(t,t.calculative.canvas.parent.store)||"#000000d9",e.textAlign="start",e.textBaseline="middle",e.font=Ar({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 Ck(e,t){e.isForbidden||(e.checked=!e.checked,e.calculative.canvas.store.emitter.emit("valueUpdate",e),e.calculative.canvas.render())}function Ak(e,t){t.onAdd||(t.onAdd=Tk,t.optionPos||(t.onAdd(t),t.calculative.canvas.parent.active([t])),t.onMouseDown=Sk,t.onValue=Rk);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},Ik=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,$r=20;function Vf(e,t){t.onAdd||(t.onAdd=bv,(!t.rowPos||!t.colPos||!t.calculative.maxOffsetY)&&t.onAdd(t),t.onMouseMove=Hk,t.onMouseLeave=Wk,t.onMouseDown=Uk,t.onShowInput=Fk,t.onInput=zk,t.onValue=Xk,t.onBeforeValue=Zk,t.onMouseEnter=iE,t.onWheel=Qk,t.onDestroy=eE,t.onContextmenu=rE,t.onResize=aE,t.onMove=nE),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()}Mk(e,t),Nk(e,t),Ok(e,t),e.restore(),Lk(e,t),Bk(e,t),t.isFirstTime=!1}function Lk(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 E=(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[E[I].col-1]*t.calculative.worldRect.width/t.tableWidth,D=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+D,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 D=t.rowPos[E[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;D>t.calculative.worldRect.height&&(D=t.calculative.worldRect.height),D>=0&&e.lineTo(t.calculative.worldRect.x+I,t.calculative.worldRect.y+D),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 G=b*t.calculative.worldRect.width/t.tableWidth;e.moveTo(t.calculative.worldRect.x+G,t.calculative.worldRect.y),e.lineTo(t.calculative.worldRect.x+G,t.calculative.worldRect.ey)}e.stroke()}})}e.restore()}}function Bk(e,t){if(t.calculative.activeCol!==void 0){e.save(),e.beginPath(),e.strokeStyle=t.activeColor,e.fillStyle="#278df833";var i=Vk(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 Ok(e,t){if(t.calculative.mergeCell){e.save(),e.beginPath(),e.strokeStyle=t.activeColor,e.fillStyle="#278df833";var i=$k(t,t.calculative.mergeCell);e.rect(i.x,i.y,i.width,i.height),e.fill(),e.stroke(),e.restore()}}function Nk(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()),G))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 D=="object")if(c===0)q[P]=D.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&&(D.visible=!1);var W=JSON.parse(JSON.stringify(Y[0].pens));W.forEach(function(se){Object.assign(se,{row:c,col:P},D),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}),Gk(t,F,W),t.calculative.canvas.parent.pushChildren(t,W)}return"continue"}}else D===void 0?q[P]="":q[P]=D.text||D+"";if(!q[P])return"continue";q[P]=Tn(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 "+($||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,k){e.fillText(se,F.x,F.y+le+(k+re)*ee)}):J==="right"?q[P].forEach(function(se,k){e.fillText(se,F.x+F.width,F.y+le+(k+re)*ee)}):q[P].forEach(function(se,k){e.fillText(se,F.x+F.width/2,F.y+le+(k+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 qk(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 jk(e){var t=ce(e.calculative.hoverCell);t.col||(t.col=t.lineCol||0),t.row||(t.row=t.lineRow);var i=kv([Aa(Aa({},e.calculative.activeCell),{rowspan:1,colspan:1}),Aa(Aa({},t),{rowspan:1,colspan:1})]);return e.mergeCells&&(i=xv(e,i)),i}function xv(e,t){var i,a=(i=e.mergeCells)===null||i===void 0?void 0:i.filter(function(r){return Kk(r,t)});return a!=null&&a.length?xv(e,kv(Ik([t],Pk(a),!1))):t}function Kk(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||_n(e,t))}function _n(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 kv(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 Ev(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 cc(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=$r*r:h=0),i>0&&(s=e.colPos[i-1]*r),i===0&&e.rowHeaders&&(s=$r*r),o!=null&&o.length){o[0].col<1?e.rowHeaders?s=$r*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 Vk(e,t){var i=e.calculative.worldRect.width/e.tableWidth,a=0;e.rowHeaders&&(a=$r*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 Yk(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 $k(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=$r*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 Gk(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=sc(i),m=p.next();!m.done;m=p.next()){var b=m.value;v+b.width*s+20*y*s0?r=4:r=-4,rs(e,r),(a=(i=e.calculative.singleton)===null||i===void 0?void 0:i.tableScroll)===null||a===void 0||a.updataScrollHTop()}}function rs(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];Jk(e,n)}),e.calculative.canvas.render()}function Jk(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 eE(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(),Ac(e)}function Ac(e){e.interval&&(globalThis.clearInterval(e.interval),e.interval=null)}function Tc(e){if(e.maxNum&&e.swiper){if(e.interval)return;e.interval=globalThis.setInterval(function(){e.offsetY>=e.calculative.maxOffsetY?(e.offsetY=0,tE(e)):e.offsetY%e.rowHeight?rs(e,1):(e.calculative.stap||(e.calculative.stap=0),e.calculative.stap+=1,e.calculative.stap==12&&(e.calculative.stap=0,rs(e,1)))},50)}}function tE(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 iE(e){Ac(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 lE(e)),e.calculative.singleton.tableScroll.showScroll())}function rE(e,t){e.calculative.singleton||(e.calculative.singleton={}),e.calculative.singleton.tableContextMenu||(e.calculative.singleton.tableContextMenu=new sE(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 aE(e){var t,i;(i=(t=e.calculative.singleton)===null||t===void 0?void 0:t.tableScroll)===null||i===void 0||i.updataScroll()}function nE(e){var t,i;(i=(t=e.calculative.singleton)===null||t===void 0?void 0:t.tableScroll)===null||i===void 0||i.updataScroll()}var oE={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"}]},sE=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++)_n(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=oE,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 vE(e,t){e.onDestroy||(e.onDestroy=yE,e.onAdd=gE);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 pA(){return{interfaceClass:hE,simpleClass:vE}}function mE(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 pE(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=0;)e[t]=0}var CE=0,Cv=1,AE=2,TE=3,SE=258,Sc=29,Pn=256,xn=Pn+1+Sc,Ra=30,Rc=19,Av=2*xn+1,Ur=15,Fl=16,RE=7,Pc=256,Tv=16,Sv=17,Rv=18,uc=[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],Uo=[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],PE=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],Pv=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],IE=512,Qi=new Array((xn+2)*2);Oa(Qi);var dn=new Array(Ra*2);Oa(dn);var kn=new Array(IE);Oa(kn);var En=new Array(SE-TE+1);Oa(En);var Ic=new Array(Sc);Oa(Ic);var as=new Array(Ra);Oa(as);function zl(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 Iv,Lv,Dv;function Hl(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}function Mv(e){return e<256?kn[e]:kn[256+(e>>>7)]}function Cn(e,t){e.pending_buf[e.pending++]=t&255,e.pending_buf[e.pending++]=t>>>8&255}function $t(e,t,i){e.bi_valid>Fl-i?(e.bi_buf|=t<>Fl-e.bi_valid,e.bi_valid+=i-Fl):(e.bi_buf|=t<>>=1,i<<=1;while(--t>0);return i>>>1}function LE(e){e.bi_valid===16?(Cn(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 DE(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<=Ur;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 Ov(e,t,i){var a=new Array(Ur+1),r=0,n,o;for(n=1;n<=Ur;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]=Bv(a[s]++,s))}}function ME(){var e,t,i,a,r,n=new Array(Ur+1);for(i=0,a=0;a>=7;a8?Cn(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 BE(e,t,i,a){Fv(e),a&&(Cn(e,i),Cn(e,~i)),xE.arraySet(e.pending_buf,e.window,t,i,e.pending),e.pending+=i}function Gf(e,t,i,a){var r=t*2,n=i*2;return e[r]>1;o>=1;o--)Wl(e,i,o);l=n;do o=e.heap[1],e.heap[1]=e.heap[e.heap_len--],Wl(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++,Wl(e,i,1);while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],DE(e,t),Ov(i,h,e.bl_count)}function Zf(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[Pv[t]*2+1]===0;t--);return e.opt_len+=3*(t+1)+5+5+4,t}function NE(e,t,i,a){var r;for($t(e,t-257,5),$t(e,i-1,5),$t(e,a-4,4),r=0;r>>=1)if(t&1&&e.dyn_ltree[i*2]!==0)return Yf;if(e.dyn_ltree[9*2]!==0||e.dyn_ltree[10*2]!==0||e.dyn_ltree[13*2]!==0)return $f;for(i=32;i0?(e.strm.data_type===EE&&(e.strm.data_type=FE(e)),hc(e,e.l_desc),hc(e,e.d_desc),o=OE(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?zv(e,t,i,a):e.strategy===kE||n===r?($t(e,(Cv<<1)+(a?1:0),3),Xf(e,Qi,dn)):($t(e,(AE<<1)+(a?1:0),3),NE(e,e.l_desc.max_code+1,e.d_desc.max_code+1,o+1),Xf(e,e.dyn_ltree,e.dyn_dtree)),Nv(e),a&&Fv(e)}function UE(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[(En[i]+Pn+1)*2]++,e.dyn_dtree[Mv(t)*2]++),e.last_lit===e.lit_bufsize-1}Ba._tr_init=zE;Ba._tr_stored_block=zv;Ba._tr_flush_block=WE;Ba._tr_tally=UE;Ba._tr_align=HE;function qE(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 Hv=qE;function jE(){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 KE=jE();function VE(e,t,i,a){var r=KE,n=a+i;e^=-1;for(var o=a;o>>8^r[(e^t[o])&255];return e^-1}var Wv=VE,Lc={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=rr,vi=Ba,Uv=Hv,gr=Wv,YE=Lc,ta=0,$E=1,GE=3,Er=4,ed=5,Ni=0,td=1,gi=-2,XE=-3,Ul=-5,ZE=-1,QE=1,Lo=2,JE=3,eC=4,tC=0,iC=2,ls=8,rC=9,aC=15,nC=8,oC=29,sC=256,fc=sC+1+oC,lC=30,cC=19,uC=2*fc+1,hC=15,He=3,_r=258,ki=_r+He+1,fC=32,cs=42,dc=69,qo=73,jo=91,Ko=103,qr=113,ln=666,mt=1,In=2,Gr=3,Na=4,dC=3;function xr(e,t){return e.msg=YE[t],t}function id(e){return(e<<1)-(e>4?9:0)}function br(e){for(var t=e.length;--t>=0;)e[t]=0}function yr(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 Tt(e,t){vi._tr_flush_block(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,yr(e.strm)}function We(e,t){e.pending_buf[e.pending++]=t}function nn(e,t){e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=t&255}function vC(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=Uv(e.adler,t,r,i):e.state.wrap===2&&(e.adler=gr(e.adler,t,r,i)),e.next_in+=r,e.total_in+=r,r)}function qv(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-ki?e.strstart-(e.w_size-ki):0,l=e.window,c=e.w_mask,f=e.prev,v=e.strstart+_r,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 Xr(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-ki)){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=vC(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(Xr(e),e.lookahead===0&&t===ta)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,Tt(e,!1),e.strm.avail_out===0)||e.strstart-e.block_start>=e.w_size-ki&&(Tt(e,!1),e.strm.avail_out===0))return mt}return e.insert=0,t===Er?(Tt(e,!0),e.strm.avail_out===0?Gr:Na):(e.strstart>e.block_start&&(Tt(e,!1),e.strm.avail_out===0),mt)}function ql(e,t){for(var i,a;;){if(e.lookahead=He&&(e.ins_h=(e.ins_h<=He)if(a=vi._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=vi._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+_r;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=vi._tr_tally(e,1,e.match_length-He),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(i=vi._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),i&&(Tt(e,!1),e.strm.avail_out===0))return mt}return e.insert=0,t===Er?(Tt(e,!0),e.strm.avail_out===0?Gr:Na):e.last_lit&&(Tt(e,!1),e.strm.avail_out===0)?mt:In}function mC(e,t){for(var i;;){if(e.lookahead===0&&(Xr(e),e.lookahead===0)){if(t===ta)return mt;break}if(e.match_length=0,i=vi._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,i&&(Tt(e,!1),e.strm.avail_out===0))return mt}return e.insert=0,t===Er?(Tt(e,!0),e.strm.avail_out===0?Gr:Na):e.last_lit&&(Tt(e,!1),e.strm.avail_out===0)?mt:In}function Di(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 Ta;Ta=[new Di(0,0,0,0,gC),new Di(4,4,8,4,ql),new Di(4,5,16,8,ql),new Di(4,6,32,32,ql),new Di(4,4,16,16,wa),new Di(8,16,32,32,wa),new Di(8,16,128,128,wa),new Di(8,32,128,256,wa),new Di(32,128,258,1024,wa),new Di(32,258,258,4096,wa)];function pC(e){e.window_size=2*e.w_size,br(e.head),e.max_lazy_match=Ta[e.level].max_lazy,e.good_match=Ta[e.level].good_length,e.nice_match=Ta[e.level].nice_length,e.max_chain_length=Ta[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 wC(){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=ls,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(uC*2),this.dyn_dtree=new Nt.Buf16((2*lC+1)*2),this.bl_tree=new Nt.Buf16((2*cC+1)*2),br(this.dyn_ltree),br(this.dyn_dtree),br(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Nt.Buf16(hC+1),this.heap=new Nt.Buf16(2*fc+1),br(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Nt.Buf16(2*fc+1),br(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 jv(e){var t;return!e||!e.state?xr(e,gi):(e.total_in=e.total_out=0,e.data_type=iC,t=e.state,t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=t.wrap?cs:qr,e.adler=t.wrap===2?0:1,t.last_flush=ta,vi._tr_init(t),Ni)}function Kv(e){var t=jv(e);return t===Ni&&pC(e.state),t}function bC(e,t){return!e||!e.state||e.state.wrap!==2?gi:(e.state.gzhead=t,Ni)}function Vv(e,t,i,a,r,n){if(!e)return gi;var o=1;if(t===ZE&&(t=6),a<0?(o=0,a=-a):a>15&&(o=2,a-=16),r<1||r>rC||i!==ls||a<8||a>15||t<0||t>9||n<0||n>eC)return xr(e,gi);a===8&&(a=9);var s=new wC;return e.state=s,s.strm=e,s.wrap=o,s.gzhead=null,s.w_bits=a,s.w_size=1<ed||t<0)return e?xr(e,gi):gi;if(a=e.state,!e.output||!e.input&&e.avail_in!==0||a.status===ln&&t!==Er)return xr(e,e.avail_out===0?Ul:gi);if(a.strm=e,i=a.last_flush,a.last_flush=t,a.status===cs)if(a.wrap===2)e.adler=0,We(a,31),We(a,139),We(a,8),a.gzhead?(We(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)),We(a,a.gzhead.time&255),We(a,a.gzhead.time>>8&255),We(a,a.gzhead.time>>16&255),We(a,a.gzhead.time>>24&255),We(a,a.level===9?2:a.strategy>=Lo||a.level<2?4:0),We(a,a.gzhead.os&255),a.gzhead.extra&&a.gzhead.extra.length&&(We(a,a.gzhead.extra.length&255),We(a,a.gzhead.extra.length>>8&255)),a.gzhead.hcrc&&(e.adler=gr(e.adler,a.pending_buf,a.pending,0)),a.gzindex=0,a.status=dc):(We(a,0),We(a,0),We(a,0),We(a,0),We(a,0),We(a,a.level===9?2:a.strategy>=Lo||a.level<2?4:0),We(a,dC),a.status=qr);else{var o=ls+(a.w_bits-8<<4)<<8,s=-1;a.strategy>=Lo||a.level<2?s=0:a.level<6?s=1:a.level===6?s=2:s=3,o|=s<<6,a.strstart!==0&&(o|=fC),o+=31-o%31,a.status=qr,nn(a,o),a.strstart!==0&&(nn(a,e.adler>>>16),nn(a,e.adler&65535)),e.adler=1}if(a.status===dc)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=gr(e.adler,a.pending_buf,a.pending-r,r)),yr(e),r=a.pending,a.pending===a.pending_buf_size));)We(a,a.gzhead.extra[a.gzindex]&255),a.gzindex++;a.gzhead.hcrc&&a.pending>r&&(e.adler=gr(e.adler,a.pending_buf,a.pending-r,r)),a.gzindex===a.gzhead.extra.length&&(a.gzindex=0,a.status=qo)}else a.status=qo;if(a.status===qo)if(a.gzhead.name){r=a.pending;do{if(a.pending===a.pending_buf_size&&(a.gzhead.hcrc&&a.pending>r&&(e.adler=gr(e.adler,a.pending_buf,a.pending-r,r)),yr(e),r=a.pending,a.pending===a.pending_buf_size)){n=1;break}a.gzindexr&&(e.adler=gr(e.adler,a.pending_buf,a.pending-r,r)),n===0&&(a.gzindex=0,a.status=jo)}else a.status=jo;if(a.status===jo)if(a.gzhead.comment){r=a.pending;do{if(a.pending===a.pending_buf_size&&(a.gzhead.hcrc&&a.pending>r&&(e.adler=gr(e.adler,a.pending_buf,a.pending-r,r)),yr(e),r=a.pending,a.pending===a.pending_buf_size)){n=1;break}a.gzindexr&&(e.adler=gr(e.adler,a.pending_buf,a.pending-r,r)),n===0&&(a.status=Ko)}else a.status=Ko;if(a.status===Ko&&(a.gzhead.hcrc?(a.pending+2>a.pending_buf_size&&yr(e),a.pending+2<=a.pending_buf_size&&(We(a,e.adler&255),We(a,e.adler>>8&255),e.adler=0,a.status=qr)):a.status=qr),a.pending!==0){if(yr(e),e.avail_out===0)return a.last_flush=-1,Ni}else if(e.avail_in===0&&id(t)<=id(i)&&t!==Er)return xr(e,Ul);if(a.status===ln&&e.avail_in!==0)return xr(e,Ul);if(e.avail_in!==0||a.lookahead!==0||t!==ta&&a.status!==ln){var h=a.strategy===Lo?mC(a,t):a.strategy===JE?yC(a,t):Ta[a.level].func(a,t);if((h===Gr||h===Na)&&(a.status=ln),h===mt||h===Gr)return e.avail_out===0&&(a.last_flush=-1),Ni;if(h===In&&(t===$E?vi._tr_align(a):t!==ed&&(vi._tr_stored_block(a,0,0,!1),t===GE&&(br(a.head),a.lookahead===0&&(a.strstart=0,a.block_start=0,a.insert=0))),yr(e),e.avail_out===0))return a.last_flush=-1,Ni}return t!==Er?Ni:a.wrap<=0?td:(a.wrap===2?(We(a,e.adler&255),We(a,e.adler>>8&255),We(a,e.adler>>16&255),We(a,e.adler>>24&255),We(a,e.total_in&255),We(a,e.total_in>>8&255),We(a,e.total_in>>16&255),We(a,e.total_in>>24&255)):(nn(a,e.adler>>>16),nn(a,e.adler&65535)),yr(e),a.wrap>0&&(a.wrap=-a.wrap),a.pending!==0?Ni:td)}function kC(e){var t;return!e||!e.state?gi:(t=e.state.status,t!==cs&&t!==dc&&t!==qo&&t!==jo&&t!==Ko&&t!==qr&&t!==ln?xr(e,gi):(e.state=null,t===qr?xr(e,XE):Ni))}function EC(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!==cs||a.lookahead))return gi;for(o===1&&(e.adler=Uv(e.adler,t,i,0)),a.wrap=0,i>=a.w_size&&(o===0&&(br(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,Xr(a);a.lookahead>=He;){r=a.strstart,n=a.lookahead-(He-1);do a.ins_h=(a.ins_h<=252?6:vr>=248?5:vr>=240?4:vr>=224?3:vr>=192?2:1;An[254]=An[254]=1;ia.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 Gv(e,t){if(t<65534&&(e.subarray&&$v||!e.subarray&&Yv))return String.fromCharCode.apply(null,us.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 Gv(s,a)};ia.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+An[e[i]]>t?i:t};function CC(){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 Xv=CC,vn=zi,gn=rr,vc=ia,gc=Lc,AC=Xv,Zv=Object.prototype.toString,TC=0,jl=4,Pa=0,rd=1,ad=2,SC=-1,RC=0,PC=8;function Zr(e){if(!(this instanceof Zr))return new Zr(e);this.options=gn.assign({level:SC,method:PC,chunkSize:16384,windowBits:15,memLevel:8,strategy:RC,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 AC,this.strm.avail_out=0;var i=vn.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(i!==Pa)throw new Error(gc[i]);if(t.header&&vn.deflateSetHeader(this.strm,t.header),t.dictionary){var a;if(typeof t.dictionary=="string"?a=vc.string2buf(t.dictionary):Zv.call(t.dictionary)==="[object ArrayBuffer]"?a=new Uint8Array(t.dictionary):a=t.dictionary,i=vn.deflateSetDictionary(this.strm,a),i!==Pa)throw new Error(gc[i]);this._dict_set=!0}}Zr.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?jl:TC,typeof e=="string"?i.input=vc.string2buf(e):Zv.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 gn.Buf8(a),i.next_out=0,i.avail_out=a),r=vn.deflate(i,n),r!==rd&&r!==Pa)return this.onEnd(r),this.ended=!0,!1;(i.avail_out===0||i.avail_in===0&&(n===jl||n===ad))&&(this.options.to==="string"?this.onData(vc.buf2binstring(gn.shrinkBuf(i.output,i.next_out))):this.onData(gn.shrinkBuf(i.output,i.next_out)))}while((i.avail_in>0||i.avail_out===0)&&r!==rd);return n===jl?(r=vn.deflateEnd(this.strm),this.onEnd(r),this.ended=!0,r===Pa):(n===ad&&(this.onEnd(Pa),i.avail_out=0),!0)};Zr.prototype.onData=function(e){this.chunks.push(e)};Zr.prototype.onEnd=function(e){e===Pa&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=gn.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};function Dc(e,t){var i=new Zr(t);if(i.push(e,!0),i.err)throw i.msg||gc[i.err];return i.result}function IC(e,t){return t=t||{},t.raw=!0,Dc(e,t)}function LC(e,t){return t=t||{},t.gzip=!0,Dc(e,t)}Rn.Deflate=Zr;Rn.deflate=Dc;Rn.deflateRaw=IC;Rn.gzip=LC;var Ln={},Ci={},Do=30,DC=12,MC=function(t,i){var a,r,n,o,s,h,l,c,f,v,g,y,p,m,b,x,_,E,I,P,M,D,U,G,T;a=t.state,r=t.next_in,G=t.input,n=r+(t.avail_in-5),o=t.next_out,T=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=E>>>16&255,I===0)T[o++]=E&65535;else if(I&16){P=E&65535,I&=15,I&&(p>>=I,p-=I),p<15&&(y+=G[r++]<>>24,y>>>=I,p-=I,I=E>>>16&255,I&16){if(M=E&65535,I&=15,pl){t.msg="invalid distance too far back",a.mode=Do;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=Do;break e}if(D=0,U=g,v===0){if(D+=c-I,I2;)T[o++]=U[D++],T[o++]=U[D++],T[o++]=U[D++],P-=3;P&&(T[o++]=U[D++],P>1&&(T[o++]=U[D++]))}else{D=o-M;do T[o++]=T[D++],T[o++]=T[D++],T[o++]=T[D++],P-=3;while(P>2);P&&(T[o++]=T[D++],P>1&&(T[o++]=T[D++]))}}else if((I&64)===0){E=b[(E&65535)+(y&(1<>3,r-=P,p-=P<<3,y&=(1<=1&&S[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===ld||g!==1))return-1;for(R[1]=0,c=1;cod||t===cd&&x>sd)return 1;for(;;){$=c-m,s[f]T?(ae=O[K+s[f]],V=U[G+s[f]]):(ae=32+64,V=0),E=1<>m)+I]=$<<24|ae<<16|V|0;while(I!==0);for(E=1<>=1;if(E!==0?(_&=E-1,_+=E):_=0,f++,--S[c]===0){if(c===g)break;c=i[a+s[f]]}if(c>y&&(_&M)!==P){for(m===0&&(m=y),D+=v,p=c-m,b=1<od||t===cd&&x>sd)return 1;P=_&M,n[P]=y<<24|p<<16|D-o|0}}return _!==0&&(n[D+_]=c-m<<24|64<<16|0),h.bits=y,0},ri=rr,yc=Hv,Mi=Wv,HC=MC,yn=zC,WC=0,Qv=1,Jv=2,ud=4,UC=5,Mo=6,Qr=0,qC=1,jC=2,yi=-2,eg=-3,tg=-4,KC=-5,hd=8,ig=1,fd=2,dd=3,vd=4,gd=5,yd=6,md=7,pd=8,wd=9,bd=10,ns=11,Gi=12,Vl=13,_d=14,Yl=15,xd=16,kd=17,Ed=18,Cd=19,Bo=20,Oo=21,Ad=22,Td=23,Sd=24,Rd=25,Pd=26,$l=27,Id=28,Ld=29,nt=30,rg=31,VC=32,YC=852,$C=592,GC=15,XC=GC;function Dd(e){return(e>>>24&255)+(e>>>8&65280)+((e&65280)<<8)+((e&255)<<24)}function ZC(){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 ri.Buf16(320),this.work=new ri.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function ag(e){var t;return!e||!e.state?yi:(t=e.state,e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=t.wrap&1),t.mode=ig,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new ri.Buf32(YC),t.distcode=t.distdyn=new ri.Buf32($C),t.sane=1,t.back=-1,Qr)}function ng(e){var t;return!e||!e.state?yi:(t=e.state,t.wsize=0,t.whave=0,t.wnext=0,ag(e))}function og(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))?yi:(a.window!==null&&a.wbits!==t&&(a.window=null),a.wrap=i,a.wbits=t,ng(e))}function sg(e,t){var i,a;return e?(a=new ZC,e.state=a,a.window=null,i=og(e,t),i!==Qr&&(e.state=null),i):yi}function QC(e){return sg(e,XC)}var Md=!0,Gl,Xl;function JC(e){if(Md){var t;for(Gl=new ri.Buf32(512),Xl=new ri.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(yn(Qv,e.lens,0,288,Gl,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;yn(Jv,e.lens,0,32,Xl,0,e.work,{bits:5}),Md=!1}e.lencode=Gl,e.lenbits=9,e.distcode=Xl,e.distbits=5}function lg(e,t,i,a){var r,n=e.state;return n.window===null&&(n.wsize=1<=n.wsize?(ri.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),ri.arraySet(n.window,t,i-a,r,n.wnext),a-=r,a?(ri.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=Mi(i.check,U,2,0),l=0,c=0,i.mode=fd;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)!==hd){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=Mi(i.check,U,2,0)),l=0,c=0,i.mode=dd;case dd: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=Mi(i.check,U,4,0)),l=0,c=0,i.mode=vd;case vd: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=Mi(i.check,U,2,0)),l=0,c=0,i.mode=gd;case gd:if(i.flags&1024){for(;c<16;){if(s===0)break e;s--,l+=a[n++]<>>8&255,i.check=Mi(i.check,U,2,0)),l=0,c=0}else i.head&&(i.head.extra=null);i.mode=yd;case yd: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)),ri.arraySet(i.head.extra,a,n,g,M)),i.flags&512&&(i.check=Mi(i.check,a,g,n)),s-=g,n+=g,i.length-=g),i.length))break e;i.length=0,i.mode=md;case md: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=Gi;break;case bd:for(;c<32;){if(s===0)break e;s--,l+=a[n++]<>>=c&7,c-=c&7,i.mode=$l;break}for(;c<3;){if(s===0)break e;s--,l+=a[n++]<>>=1,c-=1,l&3){case 0:i.mode=_d;break;case 1:if(JC(i),i.mode=Bo,t===Mo){l>>>=2,c-=2;break e}break;case 2:i.mode=kd;break;case 3:e.msg="invalid block type",i.mode=nt}l>>>=2,c-=2;break;case _d: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=Yl,t===Mo)break e;case Yl:i.mode=xd;case xd:if(g=i.length,g){if(g>s&&(g=s),g>h&&(g=h),g===0)break e;ri.arraySet(r,a,n,g,o),s-=g,n+=g,h-=g,o+=g,i.length-=g;break}i.mode=Gi;break;case kd: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=Ed;case Ed:for(;i.have>>=3,c-=3}for(;i.have<19;)i.lens[S[i.have++]]=0;if(i.lencode=i.lendyn,i.lenbits=7,G={bits:i.lenbits},D=yn(WC,i.lens,0,19,i.lencode,0,i.work,G),i.lenbits=G.bits,D){e.msg="invalid code lengths set",i.mode=nt;break}i.have=0,i.mode=Cd;case Cd: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(T=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(T=b+3;c>>=b,c-=b,M=0,g=3+(l&7),l>>>=3,c-=3}else{for(T=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,G={bits:i.lenbits},D=yn(Qv,i.lens,0,i.nlen,i.lencode,0,i.work,G),i.lenbits=G.bits,D){e.msg="invalid literal/lengths set",i.mode=nt;break}if(i.distbits=6,i.distcode=i.distdyn,G={bits:i.distbits},D=yn(Jv,i.lens,i.nlen,i.ndist,i.distcode,0,i.work,G),i.distbits=G.bits,D){e.msg="invalid distances set",i.mode=nt;break}if(i.mode=Bo,t===Mo)break e;case Bo:i.mode=Oo;case Oo: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,HC(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===Gi&&(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++]<>E)],b=m>>>24,x=m>>>16&255,_=m&65535,!(E+b<=c);){if(s===0)break e;s--,l+=a[n++]<>>=E,c-=E,i.back+=E}if(l>>>=b,c-=b,i.back+=b,i.length=_,x===0){i.mode=Pd;break}if(x&32){i.back=-1,i.mode=Gi;break}if(x&64){e.msg="invalid literal/length code",i.mode=nt;break}i.extra=x&15,i.mode=Ad;case Ad:if(i.extra){for(T=i.extra;c>>=i.extra,c-=i.extra,i.back+=i.extra}i.was=i.length,i.mode=Td;case Td:for(;m=i.distcode[l&(1<>>24,x=m>>>16&255,_=m&65535,!(b<=c);){if(s===0)break e;s--,l+=a[n++]<>E)],b=m>>>24,x=m>>>16&255,_=m&65535,!(E+b<=c);){if(s===0)break e;s--,l+=a[n++]<>>=E,c-=E,i.back+=E}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=Sd;case Sd:if(i.extra){for(T=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=Rd;case Rd: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=Oo);break;case Pd:if(h===0)break e;r[o++]=i.length,h--,i.mode=Oo;break;case $l: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 oA,this.strm.avail_out=0;var i=Ia.inflateInit2(this.strm,t.windowBits);if(i!==ft.Z_OK)throw new Error(mc[i]);if(this.header=new sA,Ia.inflateGetHeader(this.strm,this.header),t.dictionary&&(typeof t.dictionary=="string"?t.dictionary=Vo.string2buf(t.dictionary):ug.call(t.dictionary)==="[object ArrayBuffer]"&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(i=Ia.inflateSetDictionary(this.strm,t.dictionary),i!==ft.Z_OK)))throw new Error(mc[i])}Jr.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=Vo.binstring2buf(e):ug.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 mn.Buf8(a),i.next_out=0,i.avail_out=a),n=Ia.inflate(i,ft.Z_NO_FLUSH),n===ft.Z_NEED_DICT&&r&&(n=Ia.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=Vo.utf8border(i.output,i.next_out),h=i.next_out-s,l=Vo.buf2string(i.output,s),i.next_out=h,i.avail_out=a-h,h&&mn.arraySet(i.output,i.output,s,h,0),this.onData(l)):this.onData(mn.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=Ia.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)};Jr.prototype.onData=function(e){this.chunks.push(e)};Jr.prototype.onEnd=function(e){e===ft.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=mn.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};function Mc(e,t){var i=new Jr(t);if(i.push(e,!0),i.err)throw i.msg||mc[i.err];return i.result}function lA(e,t){return t=t||{},t.raw=!0,Mc(e,t)}Ln.Inflate=Jr;Ln.inflate=Mc;Ln.inflateRaw=lA;Ln.ungzip=Mc;var cA=rr.assign,uA=Rn,hA=Ln,fA=cg,hg={};cA(hg,uA,hA,fA);var TA=hg,pc={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,E=16,I=32,P=64,M=128,D=256,U=512,G=30,T="...",S=800,R=16,O=1,K=2,$=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",E],["flip",U],["partial",I],["partialRight",P],["rearg",D]],ee="[object Arguments]",he="[object Array]",le="[object AsyncFunction]",se="[object Boolean]",k="[object Date]",C="[object DOMException]",L="[object Error]",H="[object Function]",X="[object GeneratorFunction]",Q="[object Map]",ne="[object Number]",ye="[object Null]",ge="[object Object]",xe="[object Promise]",Te="[object Proxy]",xt="[object RegExp]",it="[object Set]",kt="[object String]",qe="[object Symbol]",Qe="[object Undefined]",Ai="[object WeakMap]",fg="[object WeakSet]",Fa="[object ArrayBuffer]",ra="[object DataView]",hs="[object Float32Array]",fs="[object Float64Array]",ds="[object Int8Array]",vs="[object Int16Array]",gs="[object Int32Array]",ys="[object Uint8Array]",ms="[object Uint8ClampedArray]",ps="[object Uint16Array]",ws="[object Uint32Array]",dg=/\b__p \+= '';/g,vg=/\b(__p \+=) '' \+/g,gg=/(__e\(.*?\)|\b__t\)) \+\n'';/g,Bc=/&(?:amp|lt|gt|quot|#39);/g,Oc=/[&<>"']/g,yg=RegExp(Bc.source),mg=RegExp(Oc.source),pg=/<%-([\s\S]+?)%>/g,wg=/<%([\s\S]+?)%>/g,Nc=/<%=([\s\S]+?)%>/g,bg=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,_g=/^\w*$/,xg=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,bs=/[\\^$.*+?()[\]{}|]/g,kg=RegExp(bs.source),_s=/^\s+/,Eg=/\s/,Cg=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,Ag=/\{\n\/\* \[wrapped with (.+)\] \*/,Tg=/,? & /,Sg=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,Rg=/[()=,{}\[\]\/\s]/,Pg=/\\(\\)?/g,Ig=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,Fc=/\w*$/,Lg=/^[-+]0x[0-9a-f]+$/i,Dg=/^0b[01]+$/i,Mg=/^\[object .+?Constructor\]$/,Bg=/^0o[0-7]+$/i,Og=/^(?:0|[1-9]\d*)$/,Ng=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Dn=/($^)/,Fg=/['\n\r\u2028\u2029\\]/g,Mn="\\ud800-\\udfff",zg="\\u0300-\\u036f",Hg="\\ufe20-\\ufe2f",Wg="\\u20d0-\\u20ff",zc=zg+Hg+Wg,Hc="\\u2700-\\u27bf",Wc="a-z\\xdf-\\xf6\\xf8-\\xff",Ug="\\xac\\xb1\\xd7\\xf7",qg="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",jg="\\u2000-\\u206f",Kg=" \\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",Uc="A-Z\\xc0-\\xd6\\xd8-\\xde",qc="\\ufe0e\\ufe0f",jc=Ug+qg+jg+Kg,xs="['\u2019]",Vg="["+Mn+"]",Kc="["+jc+"]",Bn="["+zc+"]",Vc="\\d+",Yg="["+Hc+"]",Yc="["+Wc+"]",$c="[^"+Mn+jc+Vc+Hc+Wc+Uc+"]",ks="\\ud83c[\\udffb-\\udfff]",$g="(?:"+Bn+"|"+ks+")",Gc="[^"+Mn+"]",Es="(?:\\ud83c[\\udde6-\\uddff]){2}",Cs="[\\ud800-\\udbff][\\udc00-\\udfff]",aa="["+Uc+"]",Xc="\\u200d",Zc="(?:"+Yc+"|"+$c+")",Gg="(?:"+aa+"|"+$c+")",Qc="(?:"+xs+"(?:d|ll|m|re|s|t|ve))?",Jc="(?:"+xs+"(?:D|LL|M|RE|S|T|VE))?",eu=$g+"?",tu="["+qc+"]?",Xg="(?:"+Xc+"(?:"+[Gc,Es,Cs].join("|")+")"+tu+eu+")*",Zg="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",Qg="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",iu=tu+eu+Xg,Jg="(?:"+[Yg,Es,Cs].join("|")+")"+iu,ey="(?:"+[Gc+Bn+"?",Bn,Es,Cs,Vg].join("|")+")",ty=RegExp(xs,"g"),iy=RegExp(Bn,"g"),As=RegExp(ks+"(?="+ks+")|"+ey+iu,"g"),ry=RegExp([aa+"?"+Yc+"+"+Qc+"(?="+[Kc,aa,"$"].join("|")+")",Gg+"+"+Jc+"(?="+[Kc,aa+Zc,"$"].join("|")+")",aa+"?"+Zc+"+"+Qc,aa+"+"+Jc,Qg,Zg,Vc,Jg].join("|"),"g"),ay=RegExp("["+Xc+Mn+zc+qc+"]"),ny=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,oy=["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"],sy=-1,et={};et[hs]=et[fs]=et[ds]=et[vs]=et[gs]=et[ys]=et[ms]=et[ps]=et[ws]=!0,et[ee]=et[he]=et[Fa]=et[se]=et[ra]=et[k]=et[L]=et[H]=et[Q]=et[ne]=et[ge]=et[xt]=et[it]=et[kt]=et[Ai]=!1;var Je={};Je[ee]=Je[he]=Je[Fa]=Je[ra]=Je[se]=Je[k]=Je[hs]=Je[fs]=Je[ds]=Je[vs]=Je[gs]=Je[Q]=Je[ne]=Je[ge]=Je[xt]=Je[it]=Je[kt]=Je[qe]=Je[ys]=Je[ms]=Je[ps]=Je[ws]=!0,Je[L]=Je[H]=Je[Ai]=!1;var ly={\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"},cy={"&":"&","<":"<",">":">",'"':""","'":"'"},uy={"&":"&","<":"<",">":">",""":'"',"'":"'"},hy={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},fy=parseFloat,dy=parseInt,ru=typeof Ot=="object"&&Ot&&Ot.Object===Object&&Ot,vy=typeof self=="object"&&self&&self.Object===Object&&self,Et=ru||vy||Function("return this")(),Ts=t&&!t.nodeType&&t,Tr=Ts&&!0&&e&&!e.nodeType&&e,au=Tr&&Tr.exports===Ts,Ss=au&&ru.process,ni=function(){try{var te=Tr&&Tr.require&&Tr.require("util").types;return te||Ss&&Ss.binding&&Ss.binding("util")}catch{}}(),nu=ni&&ni.isArrayBuffer,ou=ni&&ni.isDate,su=ni&&ni.isMap,lu=ni&&ni.isRegExp,cu=ni&&ni.isSet,uu=ni&&ni.isTypedArray;function Gt(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 gy(te,ue,oe,pe){for(var Se=-1,je=te==null?0:te.length;++Se-1}function Rs(te,ue,oe){for(var pe=-1,Se=te==null?0:te.length;++pe-1;);return oe}function pu(te,ue){for(var oe=te.length;oe--&&na(ue,te[oe],0)>-1;);return oe}function Ey(te,ue){for(var oe=te.length,pe=0;oe--;)te[oe]===ue&&++pe;return pe}var Cy=Ds(ly),Ay=Ds(cy);function Ty(te){return"\\"+hy[te]}function Sy(te,ue){return te==null?i:te[ue]}function oa(te){return ay.test(te)}function Ry(te){return ny.test(te)}function Py(te){for(var ue,oe=[];!(ue=te.next()).done;)oe.push(ue.value);return oe}function Ns(te){var ue=-1,oe=Array(te.size);return te.forEach(function(pe,Se){oe[++ue]=[Se,pe]}),oe}function wu(te,ue){return function(oe){return te(ue(oe))}}function or(te,ue){for(var oe=-1,pe=te.length,Se=0,je=[];++oe-1}function m0(u,d){var w=this.__data__,A=Jn(w,u);return A<0?(++this.size,w.push([u,d])):w[A][1]=d,this}Hi.prototype.clear=d0,Hi.prototype.delete=v0,Hi.prototype.get=g0,Hi.prototype.has=y0,Hi.prototype.set=m0;function Wi(u){var d=-1,w=u==null?0:u.length;for(this.clear();++d=d?u:d)),u}function ci(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=_m(u),!Z)return zt(u,j)}else{var ve=Rt(u),me=ve==H||ve==X;if(fr(u))return th(u,Z);if(ve==ge||ve==ee||me&&!B){if(j=ie||me?{}:bh(u),!Z)return ie?um(u,D0(j,u)):cm(u,Iu(j,u))}else{if(!Je[ve])return B?u:{};j=xm(u,ve,Z)}}z||(z=new pi);var _e=z.get(u);if(_e)return _e;z.set(u,j),Gh(u)?u.forEach(function(Ae){j.add(ci(Ae,d,w,Ae,u,z))}):Yh(u)&&u.forEach(function(Ae,Be){j.set(Be,ci(Ae,d,w,Be,u,z))});var Ce=fe?ie?cl:ll:ie?Wt:pt,Le=de?i:Ce(u);return oi(Le||u,function(Ae,Be){Le&&(Be=Ae,Ae=u[Be]),Ka(j,Be,ci(Ae,d,w,Be,u,z))}),j}function M0(u){var d=pt(u);return function(w){return Lu(w,u,d)}}function Lu(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 Du(u,d,w){if(typeof u!="function")throw new si(o);return Qa(function(){u.apply(i,w)},d)}function Va(u,d,w,A){var B=-1,z=On,j=!0,Z=u.length,ie=[],fe=d.length;if(!Z)return ie;w&&(d=rt(d,Xt(w))),A?(z=Rs,j=!1):d.length>=r&&(z=za,j=!1,d=new Pr(d));e:for(;++BB?0:B+w),A=A===i||A>B?B:Ie(A),A<0&&(A+=B),A=w>A?0:Zh(A);w0&&w(Z)?d>1?Ct(Z,d-1,w,A,B):nr(B,Z):A||(B[B.length]=Z)}return B}var js=sh(),Ou=sh(!0);function Ti(u,d){return u&&js(u,d,pt)}function Ks(u,d){return u&&Ou(u,d,pt)}function to(u,d){return ar(d,function(w){return Vi(u[w])})}function Lr(u,d){d=ur(d,u);for(var w=0,A=d.length;u!=null&&wd}function N0(u,d){return u!=null&&Ye.call(u,d)}function F0(u,d){return u!=null&&d in Xe(u)}function z0(u,d,w){return u>=St(d,w)&&u=120&&de.length>=120)?new Pr(j&&de):i}de=u[0];var ve=-1,me=Z[0];e:for(;++ve-1;)Z!==u&&Vn.call(Z,ie,1),Vn.call(u,ie,1);return u}function Yu(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;Ki(B)?Vn.call(u,B,1):tl(u,B)}}return u}function Qs(u,d){return u+Gn(Tu()*(d-u+1))}function Q0(u,d,w,A){for(var B=-1,z=yt($n((d-u)/(w||1)),0),j=oe(z);z--;)j[A?z:++B]=u,u+=w;return j}function Js(u,d){var w="";if(!u||d<1||d>V)return w;do d%2&&(w+=u),d=Gn(d/2),d&&(u+=u);while(d);return w}function De(u,d){return yl(kh(u,d,Ut),u+"")}function J0(u){return Pu(ma(u))}function em(u,d){var w=ma(u);return fo(w,Ir(d,0,w.length))}function Ga(u,d,w,A){if(!st(u))return u;d=ur(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&&!Qt(j)&&(w?j<=d:j=r){var fe=d?null:vm(u);if(fe)return Fn(fe);j=!1,B=za,ie=new Pr}else ie=d?[]:Z;e:for(;++A=A?u:ui(u,d,w)}var eh=Ky||function(u){return Et.clearTimeout(u)};function th(u,d){if(d)return u.slice();var w=u.length,A=xu?xu(w):new u.constructor(w);return u.copy(A),A}function nl(u){var d=new u.constructor(u.byteLength);return new jn(d).set(new jn(u)),d}function nm(u,d){var w=d?nl(u.buffer):u.buffer;return new u.constructor(w,u.byteOffset,u.byteLength)}function om(u){var d=new u.constructor(u.source,Fc.exec(u));return d.lastIndex=u.lastIndex,d}function sm(u){return ja?Xe(ja.call(u)):{}}function ih(u,d){var w=d?nl(u.buffer):u.buffer;return new u.constructor(w,u.byteOffset,u.length)}function rh(u,d){if(u!==d){var w=u!==i,A=u===null,B=u===u,z=Qt(u),j=d!==i,Z=d===null,ie=d===d,fe=Qt(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 ah(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 uh(u){return ji(function(d){var w=d.length,A=w,B=li.prototype.thru;for(u&&d.reverse();A--;){var z=d[A];if(typeof z!="function")throw new si(o);if(B&&!j&&uo(z)=="wrapper")var j=new li([],!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 Pr:i;for(z.set(u,d),z.set(d,u);++ve1?"& ":"")+d[A],d=d.join(w>2?", ":" "),u.replace(Cg,`{ /* [wrapped with `+d+`] */ `)}function Em(u){return Re(u)||Br(u)||!!(Cu&&u&&u[Cu])}function Ki(u,d){var w=typeof u;return d=d==null?V:d,!!d&&(w=="number"||w!="symbol"&&Og.test(u))&&u>-1&&u%1==0&&u0){if(++d>=S)return arguments[0]}else d=0;return u.apply(i,arguments)}}function fo(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,Bh(u,w)});function Oh(u){var d=N(u);return d.__chain__=!0,d}function Bp(u,d){return d(u),u}function vo(u,d){return d(u)}var Op=ji(function(u){var d=u.length,w=d?u[0]:0,A=this.__wrapped__,B=function(z){return qs(z,u)};return d>1||this.__actions__.length||!(A instanceof Oe)||!Ki(w)?this.thru(B):(A=A.slice(w,+w+(d?1:0)),A.__actions__.push({func:vo,args:[B],thisArg:i}),new li(A,this.__chain__).thru(function(z){return d&&!z.length&&z.push(i),z}))});function Np(){return Oh(this)}function Fp(){return new li(this.value(),this.__chain__)}function zp(){this.__values__===i&&(this.__values__=Xh(this.value()));var u=this.__index__>=this.__values__.length,d=u?i:this.__values__[this.__index__++];return{done:u,value:d}}function Hp(){return this}function Wp(u){for(var d,w=this;w instanceof Qn;){var A=Rh(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 Up(){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:vo,args:[ml],thisArg:i}),new li(d,this.__chain__)}return this.thru(ml)}function qp(){return Qu(this.__wrapped__,this.__actions__)}var jp=no(function(u,d,w){Ye.call(u,w)?++u[w]:Ui(u,w,1)});function Kp(u,d,w){var A=Re(u)?hu:B0;return w&&Mt(u,d,w)&&(d=i),A(u,ke(d,3))}function Vp(u,d){var w=Re(u)?ar:Bu;return w(u,ke(d,3))}var Yp=ch(Ph),$p=ch(Ih);function Gp(u,d){return Ct(go(u,d),1)}function Xp(u,d){return Ct(go(u,d),ae)}function Zp(u,d,w){return w=w===i?1:Ie(w),Ct(go(u,d),w)}function Nh(u,d){var w=Re(u)?oi:lr;return w(u,ke(d,3))}function Fh(u,d){var w=Re(u)?yy:Mu;return w(u,ke(d,3))}var Qp=no(function(u,d,w){Ye.call(u,w)?u[w].push(d):Ui(u,w,[d])});function Jp(u,d,w,A){u=Ht(u)?u:ma(u),w=w&&!A?Ie(w):0;var B=u.length;return w<0&&(w=yt(B+w,0)),bo(u)?w<=B&&u.indexOf(d,w)>-1:!!B&&na(u,d,w)>-1}var ew=De(function(u,d,w){var A=-1,B=typeof d=="function",z=Ht(u)?oe(u.length):[];return lr(u,function(j){z[++A]=B?Gt(d,j,w):Ya(j,d,w)}),z}),tw=no(function(u,d,w){Ui(u,w,d)});function go(u,d){var w=Re(u)?rt:Wu;return w(u,ke(d,3))}function iw(u,d,w,A){return u==null?[]:(Re(d)||(d=d==null?[]:[d]),w=A?i:w,Re(w)||(w=w==null?[]:[w]),Ku(u,d,w))}var rw=no(function(u,d,w){u[w?0:1].push(d)},function(){return[[],[]]});function aw(u,d,w){var A=Re(u)?Ps:gu,B=arguments.length<3;return A(u,ke(d,4),w,B,lr)}function nw(u,d,w){var A=Re(u)?my:gu,B=arguments.length<3;return A(u,ke(d,4),w,B,Mu)}function ow(u,d){var w=Re(u)?ar:Bu;return w(u,po(ke(d,3)))}function sw(u){var d=Re(u)?Pu:J0;return d(u)}function lw(u,d,w){(w?Mt(u,d,w):d===i)?d=1:d=Ie(d);var A=Re(u)?P0:em;return A(u,d)}function cw(u){var d=Re(u)?I0:im;return d(u)}function uw(u){if(u==null)return 0;if(Ht(u))return bo(u)?sa(u):u.length;var d=Rt(u);return d==Q||d==it?u.size:Gs(u).length}function hw(u,d,w){var A=Re(u)?Is:rm;return w&&Mt(u,d,w)&&(d=i),A(u,ke(d,3))}var fw=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]]),Ku(u,Ct(d,1),[])}),yo=Vy||function(){return Et.Date.now()};function dw(u,d){if(typeof d!="function")throw new si(o);return u=Ie(u),function(){if(--u<1)return d.apply(this,arguments)}}function zh(u,d,w){return d=w?i:d,d=u&&d==null?u.length:d,qi(u,M,i,i,i,i,d)}function Hh(u,d){var w;if(typeof d!="function")throw new si(o);return u=Ie(u),function(){return--u>0&&(w=d.apply(this,arguments)),u<=1&&(d=i),w}}var wl=De(function(u,d,w){var A=m;if(w.length){var B=or(w,ga(wl));A|=I}return qi(u,A,d,w,B)}),Wh=De(function(u,d,w){var A=m|b;if(w.length){var B=or(w,ga(Wh));A|=I}return qi(d,A,u,w,B)});function Uh(u,d,w){d=w?i:d;var A=qi(u,_,i,i,i,i,i,d);return A.placeholder=Uh.placeholder,A}function qh(u,d,w){d=w?i:d;var A=qi(u,E,i,i,i,i,i,d);return A.placeholder=qh.placeholder,A}function jh(u,d,w){var A,B,z,j,Z,ie,fe=0,de=!1,ve=!1,me=!0;if(typeof u!="function")throw new si(o);d=fi(d)||0,st(w)&&(de=!!w.leading,ve="maxWait"in w,z=ve?yt(fi(w.maxWait)||0,d):z,me="trailing"in w?!!w.trailing:me);function _e(ht){var bi=A,$i=B;return A=B=i,fe=ht,j=u.apply($i,bi),j}function Ce(ht){return fe=ht,Z=Qa(Be,d),de?_e(ht):j}function Le(ht){var bi=ht-ie,$i=ht-fe,uf=d-bi;return ve?St(uf,z-$i):uf}function Ae(ht){var bi=ht-ie,$i=ht-fe;return ie===i||bi>=d||bi<0||ve&&$i>=z}function Be(){var ht=yo();if(Ae(ht))return Fe(ht);Z=Qa(Be,Le(ht))}function Fe(ht){return Z=i,me&&A?_e(ht):(A=B=i,j)}function Jt(){Z!==i&&eh(Z),fe=0,A=ie=B=Z=i}function Bt(){return Z===i?j:Fe(yo())}function ei(){var ht=yo(),bi=Ae(ht);if(A=arguments,B=this,ie=ht,bi){if(Z===i)return Ce(ie);if(ve)return eh(Z),Z=Qa(Be,d),_e(ie)}return Z===i&&(Z=Qa(Be,d)),j}return ei.cancel=Jt,ei.flush=Bt,ei}var vw=De(function(u,d){return Du(u,1,d)}),gw=De(function(u,d,w){return Du(u,fi(d)||0,w)});function yw(u){return qi(u,U)}function mo(u,d){if(typeof u!="function"||d!=null&&typeof d!="function")throw new si(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(mo.Cache||Wi),w}mo.Cache=Wi;function po(u){if(typeof u!="function")throw new si(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 mw(u){return Hh(2,u)}var pw=am(function(u,d){d=d.length==1&&Re(d[0])?rt(d[0],Xt(ke())):rt(Ct(d,1),Xt(ke()));var w=d.length;return De(function(A){for(var B=-1,z=St(A.length,w);++B=d}),Br=Fu(function(){return arguments}())?Fu:function(u){return ct(u)&&Ye.call(u,"callee")&&!Eu.call(u,"callee")},Re=oe.isArray,Dw=nu?Xt(nu):W0;function Ht(u){return u!=null&&wo(u.length)&&!Vi(u)}function ut(u){return ct(u)&&Ht(u)}function Mw(u){return u===!0||u===!1||ct(u)&&Dt(u)==se}var fr=$y||Il,Bw=ou?Xt(ou):U0;function Ow(u){return ct(u)&&u.nodeType===1&&!Ja(u)}function Nw(u){if(u==null)return!0;if(Ht(u)&&(Re(u)||typeof u=="string"||typeof u.splice=="function"||fr(u)||ya(u)||Br(u)))return!u.length;var d=Rt(u);if(d==Q||d==it)return!u.size;if(Za(u))return!Gs(u).length;for(var w in u)if(Ye.call(u,w))return!1;return!0}function Fw(u,d){return $a(u,d)}function zw(u,d,w){w=typeof w=="function"?w:i;var A=w?w(u,d):i;return A===i?$a(u,d,i,w):!!A}function _l(u){if(!ct(u))return!1;var d=Dt(u);return d==L||d==C||typeof u.message=="string"&&typeof u.name=="string"&&!Ja(u)}function Hw(u){return typeof u=="number"&&Au(u)}function Vi(u){if(!st(u))return!1;var d=Dt(u);return d==H||d==X||d==le||d==Te}function Vh(u){return typeof u=="number"&&u==Ie(u)}function wo(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 Yh=su?Xt(su):j0;function Ww(u,d){return u===d||$s(u,d,hl(d))}function Uw(u,d,w){return w=typeof w=="function"?w:i,$s(u,d,hl(d),w)}function qw(u){return $h(u)&&u!=+u}function jw(u){if(Tm(u))throw new Se(n);return zu(u)}function Kw(u){return u===null}function Vw(u){return u==null}function $h(u){return typeof u=="number"||ct(u)&&Dt(u)==ne}function Ja(u){if(!ct(u)||Dt(u)!=ge)return!1;var d=Kn(u);if(d===null)return!0;var w=Ye.call(d,"constructor")&&d.constructor;return typeof w=="function"&&w instanceof w&&Wn.call(w)==Uy}var xl=lu?Xt(lu):K0;function Yw(u){return Vh(u)&&u>=-V&&u<=V}var Gh=cu?Xt(cu):V0;function bo(u){return typeof u=="string"||!Re(u)&&ct(u)&&Dt(u)==kt}function Qt(u){return typeof u=="symbol"||ct(u)&&Dt(u)==qe}var ya=uu?Xt(uu):Y0;function $w(u){return u===i}function Gw(u){return ct(u)&&Rt(u)==Ai}function Xw(u){return ct(u)&&Dt(u)==fg}var Zw=co(Xs),Qw=co(function(u,d){return u<=d});function Xh(u){if(!u)return[];if(Ht(u))return bo(u)?mi(u):zt(u);if(Ha&&u[Ha])return Py(u[Ha]());var d=Rt(u),w=d==Q?Ns:d==it?Fn:ma;return w(u)}function Yi(u){if(!u)return u===0?u:0;if(u=fi(u),u===ae||u===-ae){var d=u<0?-1:1;return d*F}return u===u?u:0}function Ie(u){var d=Yi(u),w=d%1;return d===d?w?d-w:d:0}function Zh(u){return u?Ir(Ie(u),0,Y):0}function fi(u){if(typeof u=="number")return u;if(Qt(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=yu(u);var w=Dg.test(u);return w||Bg.test(u)?dy(u.slice(2),w?2:8):Lg.test(u)?q:+u}function Qh(u){return Si(u,Wt(u))}function Jw(u){return u?Ir(Ie(u),-V,V):u===0?u:0}function Ve(u){return u==null?"":Zt(u)}var eb=da(function(u,d){if(Za(d)||Ht(d)){Si(d,pt(d),u);return}for(var w in d)Ye.call(d,w)&&Ka(u,w,d[w])}),Jh=da(function(u,d){Si(d,Wt(d),u)}),_o=da(function(u,d,w,A){Si(d,Wt(d),u,A)}),tb=da(function(u,d,w,A){Si(d,pt(d),u,A)}),ib=ji(qs);function rb(u,d){var w=fa(u);return d==null?w:Iu(w,d)}var ab=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}),Si(u,cl(u),w),A&&(w=ci(w,f|v|g,gm));for(var B=d.length;B--;)tl(w,d[B]);return w});function xb(u,d){return tf(u,po(ke(d)))}var kb=ji(function(u,d){return u==null?{}:X0(u,d)});function tf(u,d){if(u==null)return{};var w=rt(cl(u),function(A){return[A]});return d=ke(d),Vu(u,w,function(A,B){return d(A,B[0])})}function Eb(u,d,w){d=ur(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=Tu();return St(u+B*(d-u+fy("1e-"+((B+"").length-1))),d)}return Qs(u,d)}var Bb=va(function(u,d,w){return d=d.toLowerCase(),u+(w?nf(d):d)});function nf(u){return Cl(Ve(u).toLowerCase())}function of(u){return u=Ve(u),u&&u.replace(Ng,Cy).replace(iy,"")}function Ob(u,d,w){u=Ve(u),d=Zt(d);var A=u.length;w=w===i?A:Ir(Ie(w),0,A);var B=w;return w-=d.length,w>=0&&u.slice(w,B)==d}function Nb(u){return u=Ve(u),u&&mg.test(u)?u.replace(Oc,Ay):u}function Fb(u){return u=Ve(u),u&&kg.test(u)?u.replace(bs,"\\$&"):u}var zb=va(function(u,d,w){return u+(w?"-":"")+d.toLowerCase()}),Hb=va(function(u,d,w){return u+(w?" ":"")+d.toLowerCase()}),Wb=lh("toLowerCase");function Ub(u,d,w){u=Ve(u),d=Ie(d);var A=d?sa(u):0;if(!d||A>=d)return u;var B=(d-A)/2;return lo(Gn(B),w)+u+lo($n(B),w)}function qb(u,d,w){u=Ve(u),d=Ie(d);var A=d?sa(u):0;return d&&A>>0,w?(u=Ve(u),u&&(typeof d=="string"||d!=null&&!xl(d))&&(d=Zt(d),!d&&oa(u))?hr(mi(u),0,w):u.split(d,w)):[]}var Xb=va(function(u,d,w){return u+(w?" ":"")+Cl(d)});function Zb(u,d,w){return u=Ve(u),w=w==null?0:Ir(Ie(w),0,u.length),d=Zt(d),u.slice(w,w+d.length)==d}function Qb(u,d,w){var A=N.templateSettings;w&&Mt(u,d,w)&&(d=i),u=Ve(u),d=_o({},d,A,gh);var B=_o({},d.imports,A.imports,gh),z=pt(B),j=Os(B,z),Z,ie,fe=0,de=d.interpolate||Dn,ve="__p += '",me=Fs((d.escape||Dn).source+"|"+de.source+"|"+(de===Nc?Ig:Dn).source+"|"+(d.evaluate||Dn).source+"|$","g"),_e="//# sourceURL="+(Ye.call(d,"sourceURL")?(d.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++sy+"]")+` `;u.replace(me,function(Ae,Be,Fe,Jt,Bt,ei){return Fe||(Fe=Jt),ve+=u.slice(fe,ei).replace(Fg,Ty),Be&&(Z=!0,ve+=`' + __e(`+Be+`) + '`),Bt&&(ie=!0,ve+=`'; `+Bt+`; __p += '`),Fe&&(ve+=`' + ((__t = (`+Fe+`)) == null ? '' : __t) + '`),fe=ei+Ae.length,Ae}),ve+=`'; `;var Ce=Ye.call(d,"variable")&&d.variable;if(!Ce)ve=`with (obj) { `+ve+` } `;else if(Rg.test(Ce))throw new Se(s);ve=(ie?ve.replace(dg,""):ve).replace(vg,"$1").replace(gg,"$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=lf(function(){return je(z,_e+"return "+ve).apply(i,j)});if(Le.source=ve,_l(Le))throw Le;return Le}function Jb(u){return Ve(u).toLowerCase()}function e1(u){return Ve(u).toUpperCase()}function t1(u,d,w){if(u=Ve(u),u&&(w||d===i))return yu(u);if(!u||!(d=Zt(d)))return u;var A=mi(u),B=mi(d),z=mu(A,B),j=pu(A,B)+1;return hr(A,z,j).join("")}function i1(u,d,w){if(u=Ve(u),u&&(w||d===i))return u.slice(0,bu(u)+1);if(!u||!(d=Zt(d)))return u;var A=mi(u),B=pu(A,mi(d))+1;return hr(A,0,B).join("")}function r1(u,d,w){if(u=Ve(u),u&&(w||d===i))return u.replace(_s,"");if(!u||!(d=Zt(d)))return u;var A=mi(u),B=mu(A,mi(d));return hr(A,B).join("")}function a1(u,d){var w=G,A=T;if(st(d)){var B="separator"in d?d.separator:B;w="length"in d?Ie(d.length):w,A="omission"in d?Zt(d.omission):A}u=Ve(u);var z=u.length;if(oa(u)){var j=mi(u);z=j.length}if(w>=z)return u;var Z=w-sa(A);if(Z<1)return A;var ie=j?hr(j,0,Z).join(""):u.slice(0,Z);if(B===i)return ie+A;if(j&&(Z+=ie.length-Z),xl(B)){if(u.slice(Z).search(B)){var fe,de=ie;for(B.global||(B=Fs(B.source,Ve(Fc.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(Zt(B),Z)!=Z){var me=ie.lastIndexOf(B);me>-1&&(ie=ie.slice(0,me))}return ie+A}function n1(u){return u=Ve(u),u&&yg.test(u)?u.replace(Bc,My):u}var o1=va(function(u,d,w){return u+(w?" ":"")+d.toUpperCase()}),Cl=lh("toUpperCase");function sf(u,d,w){return u=Ve(u),d=w?i:d,d===i?Ry(u)?Ny(u):by(u):u.match(d)||[]}var lf=De(function(u,d){try{return Gt(u,i,d)}catch(w){return _l(w)?w:new Se(w)}}),s1=ji(function(u,d){return oi(d,function(w){w=Ri(w),Ui(u,w,wl(u[w],u))}),u});function l1(u){var d=u==null?0:u.length,w=ke();return u=d?rt(u,function(A){if(typeof A[1]!="function")throw new si(o);return[w(A[0]),A[1]]}):[],De(function(A){for(var B=-1;++BV)return[];var w=Y,A=St(u,Y);d=ke(d),u-=Y;for(var B=Bs(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)},Ti(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,nr([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:vo,args:[ve],thisArg:i}),new li(Ae,me)}return Ce&&Le?u.apply(this,Z):(Ae=this.thru(ve),Ce?A?Ae.value()[0]:Ae.value():Ae)})}),oi(["pop","push","shift","sort","splice","unshift"],function(u){var d=zn[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)})}}),Ti(Oe.prototype,function(u,d){var w=N[d];if(w){var A=w.name+"";Ye.call(ha,A)||(ha[A]=[]),ha[A].push({name:d,func:w})}}),ha[oo(i,b).name]=[{name:"wrapper",func:i}],Oe.prototype.clone=n0,Oe.prototype.reverse=o0,Oe.prototype.value=s0,N.prototype.at=Op,N.prototype.chain=Np,N.prototype.commit=Fp,N.prototype.next=zp,N.prototype.plant=Wp,N.prototype.reverse=Up,N.prototype.toJSON=N.prototype.valueOf=N.prototype.value=qp,N.prototype.first=N.prototype.head,Ha&&(N.prototype[Ha]=Hp),N},la=Fy();Tr?((Tr.exports=la)._=la,Ts._=la):Et._=la}).call(Ot)})(pc,pc.exports);const SA=pc.exports;export{vA as M,SA as _,mA as a,bA as b,pA as c,yA as d,AA as e,gA as f,EA as g,xA as h,kA as i,CA as j,TA as p,wA as s,_A as t};