123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119 |
- var Y1=Object.defineProperty;var K1=(e,t,i)=>t in e?Y1(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i;var U=(e,t,i)=>(K1(e,typeof t!="symbol"?t+"":t,i),i);import{O as De}from"./index.036b2901.js";function Ns(e,t){const i=t||new Path2D;e.setTheme||(e.setTheme=X1);let s=e.calculative.borderRadius||0,n=s;const{x:r,y:a,width:o,height:l,ex:u,ey:h}=e.calculative.worldRect;s<1&&(s=o*s,n=l*n);let f=s<n?s:n;if(o<2*f&&(f=o/2),l<2*f&&(f=l/2),i.moveTo(r+f,a),i.arcTo(u,a,u,h,f),i.arcTo(u,h,r,h,f),i.arcTo(r,h,r,a,f),i.arcTo(r,a,u,a,f),i.closePath(),i instanceof Path2D)return i}function X1(e,t){if(!!e.affectByTheme){for(const i in t)if(Object.prototype.hasOwnProperty.call(t,i)){const s=t[i];e.hasOwnProperty(i)&&(e[i]=s),e.calculative.hasOwnProperty(i)&&(e.calculative[i]=s)}e.hoverTextColor=t.textPrimaryColor,e.iconColor=t.buttonBg,e.calculative.iconColor=t.buttonBg,e.hoverBackground=t.formBg,e.activeBackground=t.activeBg,e.color=t.borderColor,e.calculative.color=t.borderColor,e.textColor=t["textColor-9"],e.calculative.textColor=t["textColor-9"]}}const G1=Ns;function Z1(e,t){const i=t||new Path2D,{x:s,y:n,width:r,height:a}=e.calculative.worldRect;if(i.ellipse(s+r/2,n+a/2,r/2,a/2,0,0,Math.PI*2),i instanceof Path2D)return i}var jt;(function(e){e[e.Node=0]="Node",e[e.Line=1]="Line"})(jt||(jt={}));var Ot;(function(e){e[e.None=0]="None",e[e.DisableEdit=1]="DisableEdit",e[e.DisableMove=2]="DisableMove",e[e.DisableScale=3]="DisableScale",e[e.DisableMoveScale=4]="DisableMoveScale",e[e.Disable=10]="Disable"})(Ot||(Ot={}));var nf;(function(e){e[e.Default=0]="Default",e[e.In=1]="In",e[e.Out=2]="Out"})(nf||(nf={}));var Rn;(function(e){e[e.None=0]="None",e[e.Linear=1]="Linear",e[e.Radial=2]="Radial"})(Rn||(Rn={}));var zt;(function(e){e[e.CanvasTemplate=1]="CanvasTemplate",e[e.CanvasImageBottom=2]="CanvasImageBottom",e[e.CanvasMain=3]="CanvasMain",e[e.CanvasImage=4]="CanvasImage"})(zt||(zt={}));const J1=["text","textWidth","textHeight","textLeft","textTop","fontFamily","fontSize","lineHeight","fontStyle","fontWeight","textAlign","textBaseline","whiteSpace","ellipsis","keepDecimal"],Q1=["x","y","width","height","flipX","flipY"],tx=["paddingTop","paddingRight","paddingBottom","paddingLeft","flipX","flipY","visible","showChild"],ex=["iconLeft","iconTop","iconRotate"];var Ze;(function(e){e[e.Normal=0]="Normal",e[e.Beads=1]="Beads",e[e.Dot=2]="Dot",e[e.Arrow=3]="Arrow",e[e.WaterDrop=4]="WaterDrop"})(Ze||(Ze={}));const Td=["gif","iframe","video","echarts","highcharts","lightningCharts","vue"],_l=["radio","checkbox","button","inputDom","slider","echarts"],Gn=new Set(["borderRadius","paddingLeft","paddingRight","paddingTop","paddingBottom","progress","progressColor","verticalProgress","reverseProgress","flipX","flipY","input","lineDash","lineCap","lineJoin","strokeType","lineGradientFromColor","lineGradientToColor","lineGradientAngle","color","hoverColor","activeColor","lineWidth","bkType","gradientFromColor","gradientToColor","gradientAngle","gradientRadius","hoverBackground","activeBackground","globalAlpha","anchorColor","anchorRadius","shadowColor","shadowBlur","shadowOffsetX","shadowOffsetY","textHasShadow","fontFamily","fontSize","textColor","hoverTextColor","activeTextColor","textBackground","fontStyle","fontWeight","textAlign","textBaseline","lineHeight","whiteSpace","textWidth","textHeight","textLeft","textTop","ellipsis","hiddenText","keepDecimal","borderWidth","borderColor","animateLineWidth","lineAnimateType","frames","animateColor","animateType","animateReverse","background","gradientColors","lineGradientColors","animateLineWidth","gradientSmooth","lineSmooth","animations"]);function ix(e){e.onAdd=void 0,e.onValue=void 0,e.onBeforeValue=void 0,e.onDestroy=void 0,e.onMove=void 0,e.onResize=void 0,e.onRotate=void 0,e.onClick=void 0,e.onMouseEnter=void 0,e.onMouseLeave=void 0,e.onMouseDown=void 0,e.onMouseMove=void 0,e.onMouseUp=void 0,e.onShowInput=void 0,e.onInput=void 0,e.onChangeId=void 0,e.onBinds=void 0,e.onStartVideo=void 0,e.onPauseVideo=void 0,e.onStopVideo=void 0,e.onRenderPenRaw=void 0,e.onKeyDown=void 0,e.onContextmenu=void 0,e.onScale=void 0,e.onWheel=void 0,e.onConnectLine=void 0}var xt;(function(e){e[e.None=0]="None",e[e.LineAnchor=1]="LineAnchor",e[e.NodeAnchor=2]="NodeAnchor",e[e.Line=3]="Line",e[e.Node=4]="Node",e[e.Resize=5]="Resize",e[e.Rotate=6]="Rotate",e[e.LineAnchorPrev=7]="LineAnchorPrev",e[e.LineAnchorNext=8]="LineAnchorNext"})(xt||(xt={}));var Yt;(function(e){e[e.None=0]="None",e[e.Translate=1]="Translate",e[e.Select=2]="Select",e[e.Resize=3]="Resize",e[e.AddAnchor=4]="AddAnchor"})(Yt||(Yt={}));var Vi;(function(e){e[e.None=0]="None",e[e.Down=1]="Down",e[e.Translate=2]="Translate"})(Vi||(Vi={}));var Lt;(function(e){e[e.None=-1]="None",e[e.Up=0]="Up",e[e.Right=1]="Right",e[e.Bottom=2]="Bottom",e[e.Left=3]="Left"})(Lt||(Lt={}));const rf=["nw-resize","ne-resize","se-resize","sw-resize"],af=["n-resize","e-resize","s-resize","w-resize"],sx=["curve","polyline","line"],Rd=["dash","lineWidth","lineCap","lineJoin","strokeType","color","lineGradientFromColor","lineGradientToColor","lineGradientAngle","globalAlpha","bkType","background","gradientFromColor","gradientToColor","gradientAngle","gradientRadius","fontFamily","fontSize","textColor","hoverTextColor","activeTextColor","textBackground","fontStyle","fontWeight","textAlign","textBaseline","lineHeight","whiteSpace","textLeft","textTop","flipX","flipY","lineDash","visible","iconColor"];var Fs;(function(e){e[e.Mirror=0]="Mirror",e[e.Bilateral=1]="Bilateral",e[e.Free=2]="Free"})(Fs||(Fs={}));var Ee;(function(e){e[e.Default=0]="Default",e[e.In=1]="In",e[e.Out=2]="Out",e[e.DisableConnected=3]="DisableConnected",e[e.DisableConnectTo=4]="DisableConnectTo",e[e.Disable=10]="Disable"})(Ee||(Ee={}));var ji;(function(e){e[e.Default=0]="Default",e[e.Line=1]="Line"})(ji||(ji={}));function Gt(e,t,i){if(!t||t%360===0)return;const s=t*Math.PI/180,n=(e.x-i.x)*Math.cos(s)-(e.y-i.y)*Math.sin(s)+i.x,r=(e.x-i.x)*Math.sin(s)+(e.y-i.y)*Math.cos(s)+i.y;e.x=n,e.y=r,e.prev&&Gt(e.prev,t,i),e.next&&Gt(e.next,t,i)}function mn(e,t,i=5,s){if(t.type===ji.Line){let n=s.rotate;s.flipX&&(n*=-1),s.flipY&&(n*=-1);let r=t.rotate+n;return s.flipX&&(r*=-1),s.flipY&&(r*=-1),Ui(e,{x:t.x-t.length*s.calculative.canvas.store.data.scale/2,y:t.y-i,width:t.length*s.calculative.canvas.store.data.scale,height:i*2,rotate:r})}else return e.x>t.x-i&&e.x<t.x+i&&e.y>t.y-i&&e.y<t.y+i}function Na(e,t,i){e.x=i.x-(i.x-e.x)*t,e.y=i.y-(i.y-e.y)*t}function ci(e,t){if(e.x===t.x)return e.y<=t.y?0:180;if(e.y===t.y)return e.x<t.x?270:90;const i=e.x-t.x,s=e.y-t.y;let n=Math.atan(Math.abs(i/s))/(2*Math.PI)*360;return i>0&&s>0?n=180-n:i<0&&s>0?n+=180:i<0&&s<0&&(n=360-n),n}function Xa(e,t){const i=e.x-t.x,s=e.y-t.y;return Math.sqrt(i*i+s*s)}function nx(e,t){let i=Lt.None;if(!t)return i;const s=e.x-t.x,n=e.y-t.y;return Math.abs(s)>Math.abs(n)?s>0?i=Lt.Right:i=Lt.Left:n>0?i=Lt.Bottom:i=Lt.Up,i}function nr(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 of(e,t){return e.anchorId===t.anchorId&&e.connectTo===t.connectTo}function va(e,t,i){let s=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<t.x?i.pens[t.penId].flipX||(s*=-1):i.pens[t.penId].flipX&&(s*=-1):e.y<t.y?i.pens[t.penId].flipY||(s*=-1):i.pens[t.penId].flipY&&(s*=-1),e.distance=s}const rx="@meta2d/core",ax="1.0.75",ox="@meta2d/core: Powerful, Beautiful, Simple, Open - Web-Based 2D At Its Best .",lx="index.js",cx="index.d.ts",hx={copy:"copyfiles package.json ../../dist/core/",build:"tsc && npm run copy"},ux=["meta2d","diagram","2D","canvas"],fx="alsmile123@qq.com",dx="MIT",gx={type:"git",url:"git+https://github.com/le5le-com/meta2d.js.git"},vx={url:"https://github.com/le5le-com/meta2d.js/issues"},yx="https://github.com/le5le-com/meta2d.js#readme",mx={"@types/marked":"^4.0.3","@types/offscreencanvas":"latest","@types/zrender":"^4.0.0"},px={mitt:"^2.1.0",mqtt:"^4.2.6"},bx={access:"public"},xx="78f2a53ca1839c89b56e2e498d17ba4eb987ad14",Sd={name:rx,version:ax,description:ox,main:lx,types:cx,scripts:hx,keywords:ux,author:fx,license:dx,repository:gx,bugs:vx,homepage:yx,devDependencies:mx,dependencies:px,publishConfig:bx,gitHead:xx},At={version:Sd.version,path2dDraws:{},canvasDraws:{},anchors:{},htmlElements:{}};function Pd(e){Object.assign(At.path2dDraws,e)}function _x(e){Object.assign(At.canvasDraws,e)}function kx(e){Object.assign(At.anchors,e)}function Ex(e){return{all:e=e||new Map,on:function(t,i){var s=e.get(t);s&&s.push(i)||e.set(t,[i])},off:function(t,i){var s=e.get(t);s&&s.splice(s.indexOf(i)>>>0,1)},emit:function(t,i){(e.get(t)||[]).slice().map(function(s){s(i)}),(e.get("*")||[]).slice().map(function(s){s(t,i)})}}}var Ds;(function(e){e[e.None=-1]="None",e[e.Document=0]="Document",e[e.Canvas=1]="Canvas"})(Ds||(Ds={}));const Ax={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:Ds.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:["tablePlus"],textFlip:!0,textRotate:!0,unavailableKeys:[],diagramOptions:{},svgPathStroke:!0,reconnetTimes:10},Cx=["color","hoverColor","activeColor","disabledColor","background","activeBackground","hoverBackground","disabledBackground","anchorColor","hoverAnchorColor","anchorBackground","animateColor","textColor","ruleColor","ruleLineColor","gridColor","lineColor","penBackground","dockPenColor"],Tx={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"}}},Qn={cssRuleSelector:":root",style_prefix:"le5le_",vendor_css_prefix:"--le-",dark:["textColor-9: rgba(255,255,255,0.90)","textColor-6: rgba(255,255,255,0.60)","textColor-1: rgba(255,255,255,1)","textColor-4: rgba(255,255,255,0.40)","textPrimaryColor: #7f838c","textSecondColor: rgba(255,255,255,0.90)","textDisabledColor: rgba(255,255,255,0.40)","textActiveColor: #0052d9","buttonBg: #4583ff","buttonDisabledBg: #0057CC","buttonDisabledColor: #FFFFFF26","buttonGradient: linear-gradient(360deg,#4583ff, #33ccff)","containerBg: rgba(21,24,28,0.95)","tabBg: #303746","tabActiveBg: #4583ff","tabDisabledBg: #282e3b","tabDisabledColor: rgba(255,255,255,0.26)","tabActiveColor: rgba(255,255,255,0.90)","formBg: #2a2f36","datePickerCellActiveRangeBg: #2c4475","componentDisabledBg: #282e3b","dataPickerCellActiveBg: #001b52","activeBg: #25375b","popContentBg: #252b37","disabledBg: #7f838c","disabledBg-2: #282E3B","tableStripeColor: rgba(150,192,255,0.10)","tableMenuBg: #303746","tableMenuDividerBg: rgb(76 81 94)","tableMenuHandleBg: #454f64","tableMenuColor: #bdc7db","tableMenuBorderColor: transparent","tableColRowBg: #303746","tableColRowActiveBg: #4A5263","tableColRowColor: rgba(255,255,255,0.6)","paginationColor: rgba(255,255,255,0.6)","paginationActiveColor: #4583ff","paginationActiveBg: rgba(69,131,255,0.20)","sliderBg: #303746","sliderBtnBg: #000000","notificationBorderColor: transparent","notificationBg: #282e3b","borderColor: #424b61","borderOutsideColor: #4583ff","formBorderColor: #424b61","borderInsideColor: rgba(255,255,255,0.40)","shadow: 0px 1px 10px 0px rgba(0,0,0,0.05), 0px 4px 5px 0px rgba(0,0,0,0.08), 0px 2px 4px -1px rgba(0,0,0,0.12)","radius: 4px"],light:["textColor-9: rgba(0,0,0,0.90)","textColor-6: rgba(0,0,0,0.60)","textColor-1: rgba(0,0,0,1)","textColor-4: rgba(0,0,0,0.40)","textPrimaryColor: #7f838c","textSecondColor: #171B27","textDisabledColor: rgba(0, 0, 0, 0.6)","textActiveColor: #0052d9","buttonBg: #4583ff","buttonDisabledBg: #b5c7ff","buttonDisabledColor: #FFFFFF","buttonGradient: linear-gradient(360deg,#4583ff, #33ccff)","containerBg: #ffffff","tabBg: #f1f2f5","tabActiveBg: #4583ff","tabDisabledBg: #e2e6ea","tabDisabledColor: rgba(0,0,0,0.26)","tabActiveColor: #ffffff","formBg: #EFF1F4","datePickerCellActiveRangeBg: #f2f3ff","componentDisabledBg: #eee","dataPickerCellActiveBg: #edefff","activeBg: #f2f3ff","popContentBg: #ffffff","disabledBg: #7f838c","disabledBg-2: #E2E6EA","tableStripeColor: #f1f2f5","tableMenuBg: #ffffff","tableMenuDividerBg: #e2e6ea","tableMenuHandleBg: #ebedf1","tableMenuColor: rgba(0,0,0,0.60)","tableMenuBorderColor: #e2e6ea","tableColRowBg: #ebedf1","tableColRowActiveBg: #bcc4d0","tableColRowColor: rgba(0,0,0,0.4)","paginationColor: rgba(0,0,0,0.6)","paginationActiveColor: #ffffff","paginationActiveBg: #4583ff","sliderBg: #e2e6ea","sliderBtnBg: #ffffff","notificationBorderColor: transparent","notificationBg: #ffffff","borderColor: #d6dbe3","borderOutsideColor: #d6dbe3","formBorderColor: #d4d6d9","borderInsideColor: #e7e7e7","shadow: 0px 2px 4px 0px rgba(107,113,121,0.25)","radius: 4px"],camelCaseToHyphenated(e){return e.replace(/[A-Z]/g,t=>"-"+t.toLowerCase())},_addVendorCssPrefix(e){return e.map(t=>{const[i,s]=t.split(":");return`${this.vendor_css_prefix}${this.camelCaseToHyphenated(i.trim())}:${s.trim()}`})},createThemeSheet(e,t){const i=document.createElement("style");i.type="text/css",i.id=this.style_prefix+t,document.head.appendChild(i);const s=e||"dark",n=this.getTheme(s),r=`${this.cssRuleSelector} { ${n.join(";")} }`;i.innerHTML=r},destroyThemeSheet(e){const t=this.findStyleSheet(this.style_prefix+e);t&&document.head.removeChild(t.ownerNode)},addTheme(e,t){Object.assign(this,{[e]:t})},getTheme(e){return this._addVendorCssPrefix(this[e]||this.light)},getThemeObj(e="dark"){const t=":";return this[e].reduce((s,n)=>{const[r,a]=n.split(t);return s[r]=a,s},{})},findStyleSheet(e){const t=document.styleSheets;for(let i=0;i<t.length;i++){const s=t[i];if(s.ownerNode&&s.ownerNode.id===e)return s}return null},updateCssRule(e,t){const s=this.getTheme(t),n=this.findStyleSheet(this.style_prefix+e);if(!n)return;let r=!1;for(let a=0;a<n.cssRules.length;a++)if(n.cssRules[a].selectorText===this.cssRuleSelector){r=!0;break}if(r)for(let a=0;a<n.cssRules.length;a++){const o=n.cssRules[a];if(o.selectorText===this.cssRuleSelector)if(n.insertRule){n.deleteRule(a);const l=`${this.cssRuleSelector} { ${s.join(";")} }`;n.insertRule(l,a)}else n.addRule&&(o.style.cssText=s.join(";"))}else if(n.insertRule){const a=`${this.cssRuleSelector} { ${s.join(";")} }`;n.insertRule(a,n.cssRules.length)}else if(n.addRule){const a=n.cssRules.find(o=>o.selectorText===this.cssRuleSelector);if(a){const o=s.join(";");a.style.cssText+=`; ${o}`}else n.addRule(this.cssRuleSelector,s.join(";"))}}};var bt;(function(e){e[e.Add=0]="Add",e[e.Update=1]="Update",e[e.Delete=2]="Delete",e[e.Replace=3]="Replace"})(bt||(bt={}));const Rx=()=>({data:{x:0,y:0,scale:1,pens:[],origin:{x:0,y:0},center:{x:0,y:0},paths:{}},histories:[],pens:{},path2dMap:new WeakMap,animateMap:new WeakMap,active:[],animates:new Set,options:{...Ax},theme:{...Tx},emitter:Ex(),bindDatas:{},bind:{},pensNetwork:{},cacheDatas:[],messageEvents:{},templatePens:{},globalTriggers:{}}),Sx=(e="default")=>(At[e]||(At[e]=Rx(),At[e].id=e),At[e]),Px=(e,t)=>{const i=e.data.template===t;if(i)for(const s of e.data.pens)s.canvasLayer===zt.CanvasTemplate&&(e.templatePens[s.id]=s);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:i?t:null},e.sameTemplate=i,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()};function Ti(e){const{paddingTop:t,paddingBottom:i,paddingLeft:s,paddingRight:n,worldRect:r,canvas:a}=e.calculative;let{textLeft:o,textTop:l,textWidth:u,textHeight:h}=e.calculative,f=s,g=t;const v=r.width-s-n,y=r.height-t-i;u&&u<1&&(u*=r.width),h&&h<1&&(h*=r.height),u<e.calculative.fontSize&&(u=e.calculative.fontSize),f+=(o||0)+r.x,g+=(l||0)+r.y;const w=e.textAlign||a.store.options.textAlign,p=e.textBaseline||a.store.options.textBaseline;switch(w){case"center":f+=(v-(u||v))/2;break;case"right":f+=v-(u||v);break}switch(p){case"middle":g+=(y-(h||y))/2;break;case"bottom":g+=y-(h||y);break}const _={x:f,y:g,width:u||v,height:h||y};ae(_),e.calculative.worldTextRect=_,xr(e),e.calculative.textDrawRect=void 0}function Id(e,t){const i=t.calculative.fontSize*t.calculative.lineHeight,s=t.calculative.textLines.length*i,n=Ix(e,t),r=t.calculative.worldTextRect;let a=r.x+(r.width-n)/2,o=r.y+(r.height-s)/2;const l=t.calculative.canvas.store.options;switch(t.textAlign||l.textAlign){case"left":a=r.x;break;case"right":a=r.x+r.width-n;break}switch(t.textBaseline||l.textBaseline){case"top":o=r.y;break;case"bottom":o=r.ey-s;break}t.calculative.textDrawRect={x:a,y:o,width:n,height:s},ae(t.calculative.textDrawRect)}function xr(e,t=e.calculative.text){if(t==null){e.calculative.textLines=[];return}t=t.toString();const i=e.calculative.keepDecimal;if(i!=null){const l=Number(t);isNaN(l)||(t=l.toFixed(i))}let s=[];const n=e.calculative.fontSize*e.calculative.lineHeight,r=e.calculative.worldTextRect.height,a=Math.floor(r/n),o=a>1?a:1;switch(e.whiteSpace){case"nowrap":if(e.ellipsis!==!1){const h=lf(t.split(""),e);h[0]&&(s.push(h[0]),h.length>1&&kl(s))}else s.push(t);break;case"pre-line":s=t.split(/[\n]/g),e.ellipsis!==!1&&s.length>o&&(s=s.slice(0,o),kl(s));break;case"break-all":default:const l=t.split(/[\n]/g);let u=0;t:for(const h of l){const f=e.whiteSpace==="break-all"?h.split(""):Ld(h);let g=lf(f,e);if(g.length===0&&(g=[""]),e.ellipsis!=!1)for(const v of g)if(u++,u>o){kl(s);break t}else s.push(v);else s.push(...g)}break}return e.calculative.textLines=s,s}function Ld(e=""){const t=[];let i="";for(let s=0;s<e.length;++s){const n=e.charCodeAt(s);n<33||n>126?(i&&(t.push(i),i=""),t.push(e[s])):i+=e[s]}return i&&t.push(i),t}function lf(e,t){const i=t.calculative.canvas,s=i.offscreen.getContext("2d"),{fontStyle:n,fontWeight:r,fontSize:a,fontFamily:o,lineHeight:l}=t.calculative;s.save();const u=[];let h=e[0]||"";for(let f=1;f<e.length;++f){const g=e[f]||"",v=h+g;let y=0;if(i.store.options.measureTextWidth)s.font=ti({fontStyle:n,fontWeight:r,fontFamily:o||i.store.options.fontFamily,fontSize:a,lineHeight:l}),y=s.measureText(v).width;else{const p=v.match(/[^\x00-\xff]/g)||"",_=p.length*a,E=v.match(/\s/g)||"",x=E.length*a*.3,C=(v.length-p.length-E.length)*a*.6;y=_+x+C}const w=t.calculative.worldTextRect.width;y<=w+.1?h+=g:(h.length&&u.push(h),h=g)}return h.length&&u.push(h),s.restore(),u}function Ix(e,t){let i=0;return t.calculative.textLineWidths=[],t.calculative.textLines.forEach(s=>{const n=e.measureText(s).width;t.calculative.textLineWidths.push(n),i<n&&(i=n)}),i}function kl(e){e[e.length-1]=e[e.length-1].slice(0,-3)+"..."}function Lx(e){let t=e.text.split(`
- `);const i=e.calculative.canvas,s=i.offscreen.getContext("2d"),{fontStyle:n,fontWeight:r,fontSize:a,fontFamily:o,lineHeight:l}=e.calculative;let u=0,h=0;s.save();for(let g=0;g<t.length;g++){if(i.store.options.measureTextWidth)s.font=ti({fontStyle:n,fontWeight:r,fontFamily:o||i.store.options.fontFamily,fontSize:a,lineHeight:l}),h=s.measureText(t[g]).width;else{const v=t[g].match(/[^\x00-\xff]/g)||"",y=v.length*a,w=t[g].match(/\s/g)||"",p=w.length*a*.3,_=(t[g].length-v.length-w.length)*a*.6;h=y+p+_}h>u&&(u=h)}s.restore();let f=t.length*a*l;e.textAlign==="left"||(e.textAlign==="right"?e.x=e.x-(u-e.width):e.x=e.x-(u-e.width)/2),e.textBaseline==="top"||(e.textBaseline==="bottom"?e.y=e.y-(f-e.height):e.y=e.y-(f-e.height)/2),e.height=f+2,e.width=u+2,e.calculative.canvas.updatePenRect(e),e.calculative.canvas.calcActiveRect()}function ht(e,t=!1){if(Array.isArray(e)){const i=[];return e.forEach(s=>{i.push(ht(s,t))}),i}else if(typeof e=="object"){if(e===null)return null;if(e.constructor===RegExp)return e;const i={};for(const s in e)if(!(["canvas","lastFrame"].includes(s)||e[s]instanceof HTMLImageElement||e[s]instanceof HTMLMediaElement)){{if(s==="calculative"&&!t)continue;if(s==="singleton"){t?i[s]={}:i[s]=e[s];continue}}i[s]=ht(e[s],t)}return i}return e}function jl(e,t,i){if(Array.isArray(e)){const s=[];return e.forEach(n=>{s.push(jl(n,t,i))}),s}else if(typeof e=="object"){if(e===null)return null;for(const s in e)if(t.includes(s))if(Array.isArray(e[s]))e[s].forEach((n,r)=>{Number.isNaN(Number(n))||(e[s][r]=Number(n*i))});else{if(Number.isNaN(Number(e[s])))continue;e[s]=Number(e[s])*i}else e[s]=jl(e[s],t,i);return e}return e}const Qe={};function Dd(e,t,i){if(!Qe[t.fromArrow])return;const s=le(t),{x:n,y:r}=s,a={x:n,y:r};if(a.step=(t.fromArrowSize||10)*i.data.scale,s.next)a.rotate=ci(s.next,s)+90;else{const l=t.calculative.worldAnchors[1];if(!l)return;l.prev?a.rotate=ci(l.prev,s)+90:a.rotate=ci(l,s)+90}e.save(),e.beginPath(),e.setLineDash([]);const o=t.fromArrowColor||t.calculative.color;o&&(e.strokeStyle=o),Qe[t.fromArrow](e,t,i,a),e.restore()}function Md(e,t,i){if(!Qe[t.toArrow]||t.calculative.worldAnchors.length<2)return;e.save();const s=Vt(t),{x:n,y:r}=s,a={x:n,y:r};if(a.step=(t.toArrowSize||10)*i.data.scale,s.prev)a.rotate=ci(s.prev,s)+90;else{const l=t.calculative.worldAnchors[t.calculative.worldAnchors.length-2];l.next?a.rotate=ci(l.next,s)+90:a.rotate=ci(l,s)+90}e.beginPath(),e.setLineDash([]);const o=t.toArrowColor||t.calculative.color;o&&(e.strokeStyle=o),Qe[t.toArrow](e,t,i,a),e.restore()}Qe.triangleSolid=(e,t,i,s)=>{e.save(),e.translate(s.x,s.y),e.rotate(s.rotate*Math.PI/180),e.translate(-s.x,-s.y);const n=s.x-s.step;e.moveTo(n,s.y-s.step/4),e.lineTo(s.x,s.y),e.lineTo(n,s.y+s.step/4),e.closePath(),e.stroke(),e.fillStyle=e.strokeStyle,e.fill(),e.restore()};Qe.triangle=(e,t,i,s)=>{e.save(),e.lineWidth<2&&(e.lineWidth=2),e.translate(s.x,s.y),e.rotate(s.rotate*Math.PI/180),e.translate(-s.x,-s.y);const n=s.x-s.step;e.moveTo(n,s.y-s.step/4),e.lineTo(s.x,s.y),e.lineTo(n,s.y+s.step/4),e.closePath(),e.stroke(),e.fillStyle=i.data.background||"#ffffff",e.fill(),e.restore()};Qe.circleSolid=(e,t,i,s)=>{e.save(),e.translate(s.x,s.y),e.rotate(s.rotate*Math.PI/180),e.translate(-s.x,-s.y);const n=s.step/2;e.arc(s.x-n,s.y,n,0,2*Math.PI),e.stroke(),e.fillStyle=e.strokeStyle,e.fill(),e.restore()};Qe.circle=(e,t,i,s)=>{e.save(),e.translate(s.x,s.y),e.rotate(s.rotate*Math.PI/180),e.translate(-s.x,-s.y);const n=s.step/2;e.arc(s.x-n,s.y,n,0,2*Math.PI),e.stroke(),e.fillStyle=i.data.background||"#ffffff",e.fill(),e.restore()};Qe.diamondSolid=(e,t,i,s)=>{e.save(),e.translate(s.x,s.y),e.rotate(s.rotate*Math.PI/180),e.translate(-s.x,-s.y);const n=s.x-s.step,r=s.step/2;e.moveTo(n,s.y),e.lineTo(n+r,s.y-r/2),e.lineTo(s.x,s.y),e.lineTo(n+r,s.y+r/2),e.closePath(),e.stroke(),e.fillStyle=e.strokeStyle,e.fill(),e.restore()};Qe.diamond=(e,t,i,s)=>{e.save(),e.translate(s.x,s.y),e.rotate(s.rotate*Math.PI/180),e.translate(-s.x,-s.y);const n=s.x-s.step,r=s.step/2;e.moveTo(n,s.y),e.lineTo(n+r,s.y-r/2),e.lineTo(s.x,s.y),e.lineTo(n+r,s.y+r/2),e.closePath(),e.stroke(),e.fillStyle=i.data.background||"#ffffff",e.fill(),e.restore()};Qe.line=(e,t,i,s)=>{e.save(),e.translate(s.x,s.y),e.rotate(s.rotate*Math.PI/180),e.translate(-s.x,-s.y);const n=s.x-s.step;e.moveTo(n,s.y-s.step/3),e.lineTo(s.x,s.y),e.lineTo(n,s.y+s.step/3),e.stroke(),e.restore()};Qe.lineUp=(e,t,i,s)=>{e.save(),e.translate(s.x,s.y),e.rotate(s.rotate*Math.PI/180),e.translate(-s.x,-s.y);const n=s.x-s.step;e.moveTo(n,s.y-s.step/3),e.lineTo(s.x,s.y),e.stroke(),e.restore()};Qe.lineDown=(e,t,i,s)=>{e.save(),e.translate(s.x,s.y),e.rotate(s.rotate*Math.PI/180),e.translate(-s.x,-s.y);const n=s.x-s.step;e.moveTo(n,s.y+s.step/3),e.lineTo(s.x,s.y),e.stroke(),e.restore()};function $l(e){const t=parseInt,i=Math.round;let s=e.length,n={};if(s>9){const[r,a,o,l]=e=e.split(",");if(s=e.length,s<3||s>4)return null;n.r=t(r[3]=="a"?r.slice(5):r.slice(4)),n.g=t(a),n.b=t(o),n.a=l?parseFloat(l):-1}else{if(s==8||s==6||s<4)return null;s<6&&(e="#"+e[1]+e[1]+e[2]+e[2]+e[3]+e[3]+(s>4?e[4]+e[4]:"")),e=t(e.slice(1),16),s==9||s==5?(n.r=e>>24&255,n.g=e>>16&255,n.b=e>>8&255,n.a=i((e&255)/.255)/1e3):(n.r=e>>16,n.g=e>>8&255,n.b=e&255,n.a=-1)}return n}function Ae(e,t,i,s){let n,r,a,o,l,u,h,f=Math.round,g=typeof i=="string";return typeof e!="number"||e<-1||e>1||typeof t!="string"||t[0]!="r"&&t[0]!="#"||i&&!g||(h=t.length>9,h=g?i.length>9?!0:i=="c"?!h:!1:h,l=$l(t),o=e<0,u=i&&i!="c"?$l(i):o?{r:0,g:0,b:0,a:-1}:{r:255,g:255,b:255,a:-1},e=o?e*-1:e,o=1-e,!l||!u)?null:(s?(n=f(o*l.r+e*u.r),r=f(o*l.g+e*u.g),a=f(o*l.b+e*u.b)):(n=f((o*l.r**2+e*u.r**2)**.5),r=f((o*l.g**2+e*u.g**2)**.5),a=f((o*l.b**2+e*u.b**2)**.5)),g=l.a,u=u.a,l=g>=0||u>=0,g=l?g<0?u:u<0?g:g*o+u*e:0,h?"rgb"+(l?"a(":"(")+n+","+r+","+a+(l?","+f(g*1e3)/1e3:"")+")":"#"+(4294967296+n*16777216+r*65536+a*256+(l?f(g*255):0)).toString(16).slice(1,l?void 0:-2))}globalThis.pSBC=Ae;function Fa(e,t){const i=$l(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})`}function fn(e,t){if(isNaN(e)){console.warn("realValue not number");return}if(typeof t!="string"){console.warn("collection must be string");return}const[i,s]=[t[0],t[t.length-1]];if(!["[","("].includes(i)){console.warn('collection must start with "[" or "("');return}if(!["]",")"].includes(s)){console.warn('collection must end with "]" or ")"');return}const n=t.substring(1,t.length-1).split(",");if(n.length!==2){console.warn("collection must have 2 numbers");return}const[r,a]=[+n[0],+n[1]];if(r>=a){console.warn("startNum must less than endNum");return}return e>r||i==="["&&e===r?e<a||s==="]"&&e===a:!1}function dn(e,t){if(typeof t!="string"){console.warn("collection must be string");return}const[i,s]=[t[0],t[t.length-1]];if(i!=="["||s!=="]"){console.warn('collection must start with "[" and end with "]"');return}const n=t.substring(1,t.length-1).split(",");for(const r of n)if(r.includes("..")){const[a,o]=r.split(".."),[l,u]=[+a,+o];if(l>=u){console.warn("startNum must less than endNum");return}if(e>=l&&e<=u)return!0}else if(e==r)return!0;return!1}function It(){return((1+Math.random())*4294967296|0).toString(16).substring(1)}const qi=e=>{let t=0,i=0,s=0,n=0;return typeof e=="number"?t=i=s=n=e:typeof e=="string"?t=i=s=n=parseInt(e,10):Array.isArray(e)&&(t=e[0],s=El(e[1])?e[0]:e[1],n=El(e[2])?e[0]:e[2],i=El(e[3])?s:e[3]),[t,s,n,i]};function El(e){return e==null}async function Dx(e){return new Promise((t,i)=>{const s=new FileReader;s.onload=n=>{t(n.target.result)},s.onerror=n=>{i(n)},s.readAsDataURL(e)})}async function Mx(e,t,i,s){const n=new FormData;if(n.append("file",e),i)for(const a in i)i.hasOwnProperty(a)&&n.append(a,i[a]);return(await(await fetch(t,{method:"POST",headers:s,body:n})).json()).url}function Bx(e,t,i){var s=document.createElement("link");s.href=e,s.rel="stylesheet",t&&(s.onload=t),i&&(s.onerror=i),document.head.appendChild(s)}function wn(e){let t=e||window.location.search.split("?")[1];const i=new URLSearchParams(t);return Object.fromEntries(i.entries())}function dr(e){let t;const i=new RegExp("(^| )"+e+"=([^;]*)(;|$)");return(t=document.cookie.match(i))?decodeURIComponent(t[2]):""}var za;(function(e){e[e.None=0]="None",e[e.LocalStorage=1]="LocalStorage",e[e.Cookie=2]="Cookie"})(za||(za={}));const Ox=location.host.indexOf("le5le.com")!==-1;function ql(){var t;const e=(t=globalThis.le5leTokenName)!=null?t:"token";switch(globalThis.le5leTokenType){case za.LocalStorage:return localStorage.getItem(e);case za.Cookie:return dr(e);default:return Ox?dr(e):localStorage.getItem(e)}}async function Bd(e,t){var l,u;if(globalThis.getMeta2dData)return await globalThis.getMeta2dData(t);const i=e.options.navigatorNetWork;let n=`/api/data/${location.href.includes("2d.")||location.href.includes("/2d")?"2d":"v"}/get`,r=((l=wn())==null?void 0:l.id)||n.includes("${id}");if(!r&&((u=wn())==null?void 0:u.data)){n=`./projects/${t}`;const f=new URL(window.location);f.searchParams.set("data",t),history.pushState({},"",f)}i!=null&&i.url&&(i.url.includes("${id}")?n=i.url.replace("${id}",t):n=i.url+((i==null?void 0:i.method)==="GET"?`?id=${t}`:""));let a=(i==null?void 0:i.method)||"POST";r||(a="GET");const o=await fetch(n,{headers:{Authorization:`Bearer ${ql()}`},method:a,body:a==="GET"?void 0:JSON.stringify({id:t})});if(o.ok){let h=await o.text();return h.constructor===Object||h.constructor===Array?h=JSON.parse(JSON.stringify(h)):typeof h=="string"&&(h=JSON.parse(h)),h.data&&(h=h.data),h}else e.emitter.emit("error",{type:"http",error:o})}function ys(e,t){if(t==null)return e;const i=t.split(".");for(;i.length&&(e=e[i.shift()]););return e}function Ha(e,t,i){t!=null&&t.split(".").reduce((s,n,r)=>s[n]=t.split(".").length===++r?i:s[n]||{},e)}function Nx(e){const t=["\u5929","\u4E00","\u4E8C","\u4E09","\u56DB","\u4E94","\u516D"],i=new Date,s=i.getFullYear(),n=i.getMonth()+1,r=i.getDate(),a=i.getDay(),o=i.getHours(),l=i.getMinutes(),u=i.getSeconds();return new Function("year","month","day","week","hours","minutes","seconds",e?`return ${e}`:"return `${year}:${month}:${day} ${hours}:${minutes}:${seconds} \u661F\u671F${week}`")(s,n,r,t[a],o,l,u)}function Fx(e,t){if(!e||!t)return!1;let i=Ge(e);for(;i;){if(i.id===t.id)return!0;i=Ge(i)}return!1}function Ge(e,t){if(!e||!e.parentId||!e.calculative)return;const s=e.calculative.canvas.store.pens[e.parentId];return t&&Ge(s,t)||s}function mi(e,t){if(!e||!e.children)return[];const i=[];return e.children.forEach(s=>{const n=t.pens[s];n&&(i.push(n),i.push(...mi(n,t)))}),i}function uc(e,t){if(!e||!e.followers)return[];const i=[];return e.followers.forEach(s=>{const n=t.pens[s];n&&!n.parentId&&(i.push(n),i.push(...uc(n,t)))}),i}function zx(e,t){const{worldRect:i,gradientFromColor:s,gradientToColor:n,gradientAngle:r}=t.calculative;return Nd(e,i,s,n,r)}function Hx(e,t){const{worldRect:i,gradientFromColor:s,gradientToColor:n,gradientRadius:r}=t.calculative;if(!s||!n)return;const{width:a,height:o,center:l}=i,{x:u,y:h}=l;let f=a;f<o&&(f=o),f*=.5;const g=e.createRadialGradient(u,h,f*(r||0),u,h,f);return g.addColorStop(0,s),g.addColorStop(1,n),g}function Wx(e,t,i,s,n){let r=0;r=Math.PI/2-Math.atan2(s-t,i-e);const a=(e+i)/2,o=(t+s)/2,l=a+n*Math.sin(90*Math.PI/180-r),u=o+n*-Math.cos(90*Math.PI/180-r),h=a+n*Math.sin(270*Math.PI/180-r),f=o+n*-Math.cos(270*Math.PI/180-r);return[l,u,h,f]}function Ux(e,t){const{worldRect:i,gradientColors:s,gradientRadius:n}=t.calculative;if(!s)return;let r=t.calculative.gradientColors;t.calculative.checked&&(r=t.calculative.onGradientColors);const{width:a,height:o,center:l}=i,{x:u,y:h}=l;let f=a;f<o&&(f=o),f*=.5;const{colors:g}=Ys(r),v=e.createRadialGradient(u,h,f*(n||0),u,h,f);return g.forEach(y=>{v.addColorStop(y.i,y.color)}),v}function Vx(e,t){const{x:i,y:s,ex:n,width:r,height:a,center:o}=t.calculative.worldRect;let l=[{x:n,y:s+a/2},{x:i,y:s+a/2}],u=t.calculative.gradientColors;t.calculative.checked&&(u=t.calculative.onGradientColors);const{angle:h,colors:f}=Ys(u);let g=fc(h,r,a);return l.forEach(v=>{Gt(v,h,o)}),Ga(e,l,f,g)}function jx(e,t){const{worldRect:i,textGradientColors:s}=t.calculative;if(!s)return;const{width:n,height:r,center:a}=i,{x:o,y:l}=a;let u=n;u<r&&(u=r),u*=.5;const{colors:h}=Ys(s),f=e.createRadialGradient(o,l,0,o,l,u);return h.forEach(g=>{f.addColorStop(g.i,g.color)}),f}function $x(e,t){const{x:i,y:s,ex:n,width:r,height:a,center:o}=t.calculative.worldRect;let l=[{x:n,y:s+a/2},{x:i,y:s+a/2}];const{angle:u,colors:h}=Ys(t.calculative.textGradientColors);let f=fc(u,r,a);return l.forEach(g=>{Gt(g,u,o)}),Ga(e,l,h,f)}function fc(e,t,i){const s=Math.atan(i/t)/Math.PI*180;let n=(e-90)%360,r=0;return n>s&&n<180-s||n>180+s&&n<360-s||n<0?(n>270?n=360-n:n>180?n=n-180:n>90&&(n=180-n),r=Math.abs(i/Math.sin(n/180*Math.PI)/2)):(n>270?n=360-n:n>180?n=n-180:n>90&&(n=180-n),r=Math.abs(t/Math.cos(n/180*Math.PI)/2)),r}function Ys(e){if(typeof e=="string"&&e.startsWith("linear-gradient")){let t=e.slice(16,-2).split("deg,");if(t.length>1){let i=t[1].split("%,");const s=[];return i.forEach(n=>{if(/rgba?/.test(n)){let r=n.split(") ");s.push({color:qx(r[0]+")"),i:parseFloat(r[1])/100})}else{let r=n.split(" ");r.length>2?s.push({color:r[1],i:parseFloat(r[2])/100}):s.push({color:r[0],i:parseFloat(r[1])/100})}}),{angle:parseFloat(t[0]),colors:s}}else return{angle:parseFloat(t[0]),colors:[]}}else return{angle:0,colors:[]}}function qx(e){if(/rgba?/.test(e)){let t=e.split(",");if(t.length<3)return"";e="#";for(let i=0,s;s=t[i++];)if(i<4)s=parseInt(s.replace(/[^\d]/gi,""),10).toString(16),e+=s.length==1?"0"+s:s;else{s=s.replace(")","");let r=parseInt(s*255+"").toString(16);r=r.length===2?r:"0"+r,e+=r}e=e.toUpperCase()}return e}function Yx(e,t){const{x:i,y:s,ex:n,width:r,height:a,center:o}=t.calculative.worldRect;let l=[{x:n,y:s+a/2},{x:i,y:s+a/2}];const{angle:u,colors:h}=Ys(t.calculative.lineGradientColors);let f=fc(u,r,a);return l.forEach(g=>{Gt(g,u,o)}),Ga(e,l,h,f)}function Ga(e,t,i,s){let n=Wx(t[0].x,t[0].y,t[1].x,t[1].y,s),r=e.createLinearGradient(n[0],n[1],n[2],n[3]);return i.forEach(a=>{r.addColorStop(a.i,a.color)}),r}function hs(e,t,i){let s=[];t.calculative.gradientColorStop?s=t.calculative.gradientColorStop:(s=Ys(t.calculative.lineGradientColors).colors,t.calculative.gradientColorStop=s),e.strokeStyle=Ga(e,i,s,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 Od(e,t){const i=t.calculative.worldAnchors;let s=t.calculative.lineWidth*(t.calculative.gradientSmooth||t.calculative.lineSmooth||0);for(let n=0;n<i.length-1;n++)if((t.lineName==="curve"||t.lineName==="mind")&&i[n].curvePoints){if(n>0){let o=i[n-1].curvePoints;o?ya(e,t,s,o[o.length-1],i[n],i[n].curvePoints[0]):ya(e,t,s,i[n-1],i[n],i[n].curvePoints[0]);let l=Ki(s,i[n],i[n].curvePoints[0]);hs(e,t,[l,i[n].curvePoints[1]])}else hs(e,t,[i[n],i[n].curvePoints[0]]),hs(e,t,[i[n].curvePoints[0],i[n].curvePoints[1]]);let r=i[n].curvePoints.length-1;for(let o=1;o<r;o++)hs(e,t,[i[n].curvePoints[o],i[n].curvePoints[o+1]]);let a=Ki(s,i[n+1],i[n].curvePoints[r]);hs(e,t,[i[n].curvePoints[r],a])}else{let r=i[n],a=i[n+1];if(n>0&&n<i.length-1){let l=i[n-1].curvePoints;l?ya(e,t,s,l[l.length-1],i[n],i[n+1]):ya(e,t,s,i[n-1],i[n],i[n+1])}n>0&&n<i.length-1&&(r=Ki(s,i[n],i[n+1])),n<i.length-2&&(a=Ki(s,i[n+1],i[n]));let o=!1;if(n===0&&t.fromLineCap&&t.fromLineCap!=="butt"&&(e.save(),o=!0,e.lineCap=t.fromLineCap),n!==0&&n===i.length-2&&t.toLineCap&&t.toLineCap!=="butt"&&(e.save(),o=!0,e.lineCap=t.toLineCap),hs(e,t,[r,a]),o&&e.restore(),i.length===2&&n===0){e.save(),o=!0,e.lineCap=t.toLineCap;let l=.1,u=.1;r.x-a.x===0?u=0:l=(r.y-a.y)/(r.x-a.x)*.1,hs(e,t,[{x:a.x-u,y:a.y-l},a]),e.restore()}}}function Ki(e,t,i){let s=Math.sqrt((i.x-t.x)*(i.x-t.x)+(i.y-t.y)*(i.y-t.y));return s===0?{x:t.x,y:t.y}:e<s?{x:t.x+(i.x-t.x)*e/s,y:t.y+(i.y-t.y)*e/s}:{x:t.x+(i.x-t.x)/s/2,y:t.y+(i.y-t.y)/s/2}}function ya(e,t,i,s,n,r){let a=Ki(i,n,s),o=Ki(i,n,r),l={x:n.x,y:n.y},u=Kx(t.calculative.canvas.store.data.smoothNum||20,a,l,o);for(let h=0;h<u.length-1;h++)hs(e,t,[{x:u[h].x,y:u[h].y},{x:u[h+1].x,y:u[h+1].y}])}function cf(e,t,i,s){let n=Ki(t,i,s),r={x:i.x,y:i.y};e.quadraticCurveTo(r.x,r.y,n.x,n.y)}function dc(e){const t=e.calculative.worldAnchors;let i=e.calculative.lineWidth*(e.calculative.gradientSmooth||e.calculative.lineSmooth||0);const s=new Path2D;for(let n=0;n<t.length-1;n++){t[n];let r=t[n+1];if(n==0&&s.moveTo(t[n].x,t[n].y),n>0&&n<t.length-1){let a=t[n-1].curvePoints;cf(s,i,t[n],t[n+1])}n>0&&n<t.length-1&&Ki(i,t[n],t[n+1]),n<t.length-2&&(r=Ki(i,t[n+1],t[n])),s.lineTo(r.x,r.y)}return s}function Kx(e=100,t,i,s,n){let r=null;const a=[];!s&&!n?r=Xx:s&&!n?r=Gx:s&&n&&(r=Zx);for(let o=0;o<e;o++)a.push(r(o/e,t,i,s,n));return n?a.push(n):s&&a.push(s),a}function Xx(e,t,i){const{x:s,y:n}=t,{x:r,y:a}=i;let o=s+(r-s)*e,l=n+(a-n)*e;return{x:o,y:l}}function Gx(e,t,i,s){const{x:n,y:r}=t,{x:a,y:o}=i,{x:l,y:u}=s;let h=(1-e)*(1-e)*n+2*e*(1-e)*a+e*e*l,f=(1-e)*(1-e)*r+2*e*(1-e)*o+e*e*u;return{x:h,y:f}}function Zx(e,t,i,s,n){const{x:r,y:a}=t,{x:o,y:l}=n,{x:u,y:h}=i,{x:f,y:g}=s;let v=r*(1-e)*(1-e)*(1-e)+3*u*e*(1-e)*(1-e)+3*f*e*e*(1-e)+o*e*e*e,y=a*(1-e)*(1-e)*(1-e)+3*h*e*(1-e)*(1-e)+3*g*e*e*(1-e)+l*e*e*e;return{x:v,y}}function Jx(e,t){const{worldRect:i,lineGradientFromColor:s,lineGradientToColor:n,lineGradientAngle:r}=t.calculative;return Nd(e,i,s,n,r)}function Nd(e,t,i,s,n){if(!i||!s)return;const{x:r,y:a,center:o,ex:l,ey:u}=t,h={x:r,y:o.y},f={x:l,y:o.y};n%90===0&&n%180?(h.x=o.x,f.x=o.x,n%270?(h.y=a,f.y=u):(h.y=u,f.y=a)):n&&(Gt(h,n,t.center),Gt(f,n,t.center));const g=e.createLinearGradient(h.x,h.y,f.x,f.y);return g.addColorStop(0,i),g.addColorStop(1,s),g}function Qx(e){const{worldIconRect:t,iconWidth:i,iconHeight:s,imgNaturalWidth:n,imgNaturalHeight:r}=e.calculative;let{x:a,y:o,width:l,height:u}=t;if(i&&(l=i),s&&(u=s),n&&r&&e.imageRatio){const h=t.width/n,f=t.height/r,g=Math.min(h,f),v=n/r;i?u=i/v:s?l=s*v:(l=g*n,u=g*r)}switch(a+=(t.width-l)/2,o+=(t.height-u)/2,e.iconAlign){case"top":o=t.y;break;case"bottom":o=t.ey-u;break;case"left":a=t.x;break;case"right":a=t.ex-l;break;case"left-top":a=t.x,o=t.y;break;case"right-top":a=t.ex-l,o=t.y;break;case"left-bottom":a=t.x,o=t.ey-u;break;case"right-bottom":a=t.ex-l,o=t.ey-u;break}return{x:a,y:o,width:l,height:u}}function kn(e,t){const{x:i,y:s,width:n,height:r}=Qx(t),{worldIconRect:a,iconRotate:o,img:l}=t.calculative;if(o){const{x:u,y:h}=a.center;e.translate(u,h),e.rotate(o*Math.PI/180),e.translate(-u,-h)}if(t.imageRadius){e.save();let u=t.calculative.imageRadius||0,h=u;const{x:f,y:g,width:v,height:y,ex:w,ey:p}=t.calculative.worldRect;u<1&&(u=v*u,h=y*h);let _=u<h?u:h;v<2*_&&(_=v/2),y<2*_&&(_=y/2),e.beginPath(),e.moveTo(f+_,g),e.arcTo(w,g,w,p,_),e.arcTo(w,p,f,p,_),e.arcTo(f,p,f,g,_),e.arcTo(f,g,w,g,_),e.clip(),e.drawImage(l,i,s,n,r),e.restore()}else{let u=s,h=0;if(t.thumbImg){let f=l.naturalWidth,g=l.naturalHeight;h=(r/n*f-g)/2,u=s+h}e.drawImage(l,i,u,n,r-2*h)}}function bs(e,t){const{textColor:i,color:s}=e.calculative,{styles:n}=t;return i||s||n.textColor||n.color}function Fd(e,t){const{fontStyle:i,fontWeight:s,fontSize:n,fontFamily:r,lineHeight:a,text:o,hiddenText:l,canvas:u,textHasShadow:h,textBackground:f,textType:g}=t.calculative;if(o==null||l)return;const v=u.store;e.save(),h||(e.shadowBlur=0,e.shadowOffsetX=0,e.shadowOffsetY=0);let y;t.calculative.disabled?y=t.disabledTextColor||t.disabledColor||Ae(.4,bs(t,v)):t.calculative.hover?y=t.hoverTextColor||t.hoverColor||v.styles.hoverColor:t.calculative.active&&(y=t.activeTextColor||t.activeColor||v.styles.activeColor);let w;g===Rn.Linear?w=$x(e,t):g===Rn.Radial&&(w=jx(e,t)),e.fillStyle=y||w||bs(t,v),e.font=ti({fontStyle:i,fontWeight:s,fontFamily:r||v.options.fontFamily,fontSize:n,lineHeight:a}),!t.calculative.textDrawRect&&Id(e,t);const{x:p,y:_,width:E,height:x}=t.calculative.textDrawRect;f&&(e.save(),e.fillStyle=f,e.fillRect(p,_,E,x),e.restore());const C=.55,S=t.textAlign||v.options.textAlign,D=n*a;t.calculative.textLines.forEach((B,L)=>{const V=t.calculative.textLineWidths[L];let tt=0;S==="center"?tt=(E-V)/2:S==="right"&&(tt=E-V),e.fillText(B,p+tt,_+(L+C)*D);const{textDecorationColor:T,textDecorationDash:R,textDecoration:P}=t;P&&t_(e,{x:p+tt,y:_+(L+C)*D,width:V},{textDecorationColor:T,textDecorationDash:R,fontSize:n});const{textStrickoutColor:O,textStrickoutDash:Y,textStrickout:Z}=t;Z&&e_(e,{x:p+tt,y:_+(L+C)*D,width:V},{textStrickoutColor:O,textStrickoutDash:Y,fontSize:n})}),e.restore()}function t_(e,t,i){const{textDecorationColor:s,textDecorationDash:n,fontSize:r}=i;let{x:a,y:o,width:l}=t;switch(e.textBaseline){case"top":o+=r;break;case"middle":o+=r/2;break}e.save(),e.beginPath(),e.strokeStyle=s||e.fillStyle,e.lineWidth=1,e.moveTo(a,o),e.setLineDash(n||[]),e.lineTo(a+l,o),e.stroke(),e.restore()}function e_(e,t,i){const{textStrickoutColor:s,textStrickoutDash:n,fontSize:r}=i;let{x:a,y:o,width:l}=t;switch(e.textBaseline){case"top":o+=r/2;break;case"bottom":o-=r/2;break}e.save(),e.beginPath(),e.strokeStyle=s||e.fillStyle,e.lineWidth=1,e.moveTo(a,o),e.setLineDash(n||[]),e.lineTo(a+l,o),e.stroke(),e.restore()}function zd(e,t,i){if(i==null)return;const{fontStyle:s,fontWeight:n,fontSize:r,fontFamily:a,lineHeight:o,canvas:l}=t.calculative,u=l.store;e.save();let h;t.calculative.hover?h=t.hoverTextColor||t.hoverColor||u.styles.hoverColor:t.calculative.active&&(h=t.activeTextColor||t.activeColor||u.styles.activeColor),e.fillStyle=h||bs(t,u),e.font=ti({fontStyle:s,fontWeight:n,fontFamily:a||u.options.fontFamily,fontSize:r,lineHeight:o});const f=e.measureText(i).width;let g,v;for(const y of t.calculative.worldAnchors){if(!v){v=y;continue}const w=Xa(v,y),p=Math.floor(w/f);g="";for(let E=0;E<p;E++)g+=i;const _=ci(v,y)-270;if(e.save(),_%360!==0){const{x:E,y:x}=v;e.translate(E,x);let C=_*Math.PI/180;e.rotate(C),e.translate(-E,-x)}e.fillText(g,v.x,v.y+o/2),e.restore(),v=y}e.restore()}function Hd(e,t){const i=t.calculative.canvas.store;e.save(),e.shadowColor="",e.shadowBlur=0,e.shadowOffsetX=0,e.shadowOffsetY=0,e.textAlign="center",e.textBaseline="middle";const s=t.calculative.worldIconRect;let n=s.x+s.width/2,r=s.y+s.height/2;switch(t.iconAlign){case"top":r=s.y,e.textBaseline="top";break;case"bottom":r=s.ey,e.textBaseline="bottom";break;case"left":n=s.x,e.textAlign="left";break;case"right":n=s.ex,e.textAlign="right";break;case"left-top":n=s.x,r=s.y,e.textAlign="left",e.textBaseline="top";break;case"right-top":n=s.ex,r=s.y,e.textAlign="right",e.textBaseline="top";break;case"left-bottom":n=s.x,r=s.ey,e.textAlign="left",e.textBaseline="bottom";break;case"right-bottom":n=s.ex,r=s.ey,e.textAlign="right",e.textBaseline="bottom";break}const a=t.calculative.iconWeight;let o;const l=t.calculative.iconFamily;t.calculative.iconSize>0?o=t.calculative.iconSize:s.width>s.height?o=s.height:o=s.width,e.font=ti({fontSize:o,fontWeight:a,fontFamily:l}),e.fillStyle=t.calculative.iconColor||bs(t,i),t.calculative.iconRotate&&(e.translate(s.center.x,s.center.y),e.rotate(t.calculative.iconRotate*Math.PI/180),e.translate(-s.center.x,-s.center.y)),e.beginPath(),e.fillText(t.calculative.icon,n,r),e.restore()}function Wd(e,t){const i=t.calculative.canvas.store.data.scale,s=t.calculative.canvas.inputDiv.dataset.penId,{x:n,y:r,width:a,height:o}=t.calculative.worldRect;e.save(),e.beginPath(),t.id===s?(e.moveTo(n+a-20*i,r+o/2+2*i),e.lineTo(n+a-14*i,r+o/2-4*i),e.lineTo(n+a-8*i,r+o/2+2*i)):(e.moveTo(n+a-20*i,r+o/2-4*i),e.lineTo(n+a-14*i,r+o/2+2*i),e.lineTo(n+a-8*i,r+o/2-4*i)),e.stroke(),e.restore()}function ti({fontStyle:e="normal",textDecoration:t="normal",fontWeight:i="normal",fontSize:s=12,fontFamily:n="Arial",lineHeight:r=1}={}){return`${e} ${t} ${i} ${s}px/${r} ${n}`}function zs(e,t){const{x:i,ex:s,y:n,ey:r}=t.calculative.worldRect||{};t.calculative.flipX&&(e.translate(i+s,0),e.scale(-1,1)),t.calculative.flipY&&(e.translate(0,n+r),e.scale(1,-1))}function Gi(e,t,i=!1){const{x:s,y:n}=t.calculative.worldRect.pivot||t.calculative.worldRect.center;e.translate(s,n);let r=t.calculative.rotate*Math.PI/180;i||(t.calculative.flipX&&(r*=-1),t.calculative.flipY&&(r*=-1)),e.rotate(r),e.translate(-s,-n)}function Is(e,t,i){e.save(),e.translate(.5,.5),e.beginPath();const s=t.calculative.canvas.store,n=t.textFlip||s.options.textFlip,r=t.textRotate||s.options.textRotate;(!n||!r)&&e.save(),zs(e,t),t.calculative.rotate&&t.name!=="line"&&Gi(e,t),(t.calculative.lineWidth>1||i)&&(e.lineWidth=t.calculative.lineWidth),u_(e,s,t);let a,o=!1,l;t.calculative.disabled?(l=t.disabledColor||s.styles.disabledColor||Ae(.4,t.calculative.color||s.styles.color),a=t.disabledBackground||s.styles.disabledBackground||Ae(.4,t.calculative.background||s.styles.penBackground)):t.mouseDownValid&&t.calculative.mouseDown?(l=t.mouseDownColor||Ae(-.4,t.calculative.color||s.styles.color),a=t.mouseDownBackground||Ae(-.4,t.calculative.background||s.styles.penBackground)):t.switch&&t.calculative.checked?t.calculative.bkType||(a=t.onBackground):t.calculative.hover?(l=t.hoverColor||s.styles.hoverColor,a=t.hoverBackground||s.styles.hoverBackground):t.calculative.active?(l=t.activeColor||s.styles.activeColor,a=t.activeBackground||s.styles.activeBackground):t.calculative.isDock&&(t.type===jt.Line?l=s.styles.dockPenColor:a=Fa(s.styles.dockPenColor,.2));const u=t.calculative.strokeImg;if(t.calculative.strokeImage&&u)e.strokeStyle=l||e.createPattern(u,"repeat");else{let f;t.calculative.strokeType?t.calculative.lineGradientColors?t.name==="line"?o=!0:t.calculative.lineGradient?f=t.calculative.lineGradient:(f=Yx(e,t),t.calculative.lineGradient=f):f=Jx(e,t):f=t.calculative.color||(t.type?s.data.lineColor:"")||s.styles.color,e.strokeStyle=l||f}const h=t.calculative.backgroundImg;if(t.calculative.backgroundImage&&h)e.fillStyle=a||e.createPattern(h,"repeat"),a=!0;else{let f;t.calculative.bkType===Rn.Linear?t.calculative.gradientColors?t.calculative.gradient?f=t.calculative.gradient:(f=Vx(e,t),t.calculative.gradient=f):f=zx(e,t):t.calculative.bkType===Rn.Radial?t.calculative.gradientColors?t.calculative.radialGradient?f=t.calculative.radialGradient:(f=Ux(e,t),t.calculative.radialGradient=f):f=Hx(e,t):f=t.calculative.background||s.styles.penBackground,e.fillStyle=a||f,a=!!f}if(Ud(e,t),Vd(e,t),Hs(e,t),t.calculative.lineDash&&e.setLineDash(t.calculative.lineDash.map(f=>f*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),o?(Od(e,t),$d(!0,e,t,s)):(jd(!0,e,t,s,a),Jd(e,t)),!(t.image&&t.calculative.img)&&t.calculative.icon&&Hd(e,t),t.dropdownList&&Wd(e,t),(!n||!r)&&e.restore(),n&&!r&&zs(e,t),!n&&r&&t.calculative.rotate&&t.name!=="line"&&Gi(e,t,!0),Fd(e,t),t.type===jt.Line&&t.fillTexts)for(const f of t.fillTexts)zd(e,t,f);e.restore()}function Ud(e,t){const i=t.lineCap||(t.type?"round":"square");i?e.lineCap=i:t.type&&(e.lineCap="round")}function Vd(e,t){const i=t.lineJoin;i?e.lineJoin=i:t.type&&(e.lineJoin="round")}function Wa(e,t,i,s){var u;e.save(),i&&e.translate(-i.x,-i.y),(u=e.setAttrs)==null||u.call(e,t);let n=!1;const r=t.calculative.canvas.store,a=t.textFlip||r.options.textFlip,o=t.textRotate||r.options.textRotate;e.beginPath(),(!a||!o)&&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"&&Gi(e,t),(t.calculative.lineWidth>1||s)&&(e.lineWidth=t.calculative.lineWidth);let l;if(t.calculative.hover)e.strokeStyle=t.hoverColor||r.styles.hoverColor,e.fillStyle=t.hoverBackground||r.styles.hoverBackground,l=t.hoverBackground||r.styles.hoverBackground;else if(t.calculative.active)e.strokeStyle=t.activeColor||r.styles.activeColor,e.fillStyle=t.activeBackground||r.styles.activeBackground,l=t.activeBackground||r.styles.activeBackground;else{if(t.strokeImage)t.calculative.strokeImg&&(e.strokeStyle=e.createPattern(t.calculative.strokeImg,"repeat"),l=!0);else{let h;t.calculative.strokeType&&t.calculative.lineGradientColors&&t.name==="line"?n=!0:h=t.calculative.color||r.styles.color,e.strokeStyle=h}t.backgroundImage?t.calculative.backgroundImg&&(e.fillStyle=e.createPattern(t.calculative.backgroundImg,"repeat"),l=!0):(e.fillStyle=t.background,l=!!t.background)}if(Ud(e,t),Vd(e,t),Hs(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),n?(Od(e,t),$d(!0,e,t,r)):(jd(!1,e,t,r,l),Jd(e,t)),t.calculative.img?(e.save(),e.shadowColor="",e.shadowBlur=0,e.shadowOffsetX=0,e.shadowOffsetY=0,kn(e,t),e.restore()):t.calculative.icon&&Hd(e,t),t.dropdownList&&Wd(e,t),(!a||!o)&&e.restore(),a&&!o&&(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))),!a&&o&&t.calculative.rotate&&t.name!=="line"&&Gi(e,t,!0),Fd(e,t),t.type===jt.Line&&t.fillTexts)for(const h of t.fillTexts)zd(e,t,h);e.restore()}function jd(e=!0,t,i,s,n){if(i.name==="drawCommand")return;const r=e?s.path2dMap.get(i):At.path2dDraws[i.name];let a=null,o=null;if(i.type===jt.Line&&(i.fromLineCap&&i.fromLineCap!=="butt"&&(t.lineCap="butt",a=new Path2D,a.moveTo(i.calculative.worldAnchors[0].x,i.calculative.worldAnchors[0].y),a.lineTo(i.calculative.worldAnchors[0].x,i.calculative.worldAnchors[0].y)),i.toLineCap&&i.toLineCap!=="butt"&&(t.lineCap="butt",o=new Path2D,o.moveTo(i.calculative.worldAnchors[i.calculative.worldAnchors.length-1].x,i.calculative.worldAnchors[i.calculative.worldAnchors.length-1].y),o.lineTo(i.calculative.worldAnchors[i.calculative.worldAnchors.length-1].x,i.calculative.worldAnchors[i.calculative.worldAnchors.length-1].y))),r){if(i.type===jt.Line&&i.borderWidth){t.save(),t.beginPath();const u=i.calculative.lineWidth+i.calculative.borderWidth;t.lineWidth=u,t.strokeStyle=i.borderColor,a&&(t.save(),t.lineCap=i.fromLineCap,t.stroke(a),t.restore()),r instanceof Path2D?(n&&t.fill(r),u&&t.stroke(r)):(r(i,t),n&&t.fill(),u&&t.stroke()),o&&(t.save(),t.lineCap=i.toLineCap,t.stroke(o),t.restore()),t.restore()}r instanceof Path2D?i.type?i.close&&n&&t.fill(r):n&&t.fill(r):(t.save(),r(i,t),n&&t.fill(),t.restore());const l=i.calculative.progress;if(l!=null){t.save();const{ex:u,x:h,y:f,width:g,height:v,ey:y}=i.calculative.worldRect;let w=null;if(i.calculative.verticalProgress?w=i.reverseProgress?t.createLinearGradient(h,f,h,f+v*l):t.createLinearGradient(h,y,h,f+v*(1-l)):w=i.reverseProgress?t.createLinearGradient(u,f,h+g*(1-l),f):t.createLinearGradient(h,f,h+g*l,f),i.calculative.progressGradientColors){const{colors:p}=Ys(i.calculative.progressGradientColors);p.forEach(_=>{w.addColorStop(_.i,_.color)})}else{const p=i.calculative.progressColor||i.calculative.color||s.options.activeColor||s.data.color;w.addColorStop(0,p),w.addColorStop(1,p)}w.addColorStop(1,"transparent"),t.fillStyle=w,r instanceof Path2D?t.fill(r):(r(i,t),t.fill()),t.restore()}if(i.calculative.lineWidth&&(r instanceof Path2D?(s.options.svgPathStroke||i.name!=="svgPath")&&(a&&(t.save(),t.lineCap=i.fromLineCap,t.stroke(a),t.restore()),t.stroke(r),o&&(t.save(),t.lineCap=i.toLineCap,t.stroke(o),t.restore())):(r(i,t),t.stroke())),i.type){if(i.calculative.animatePos){if(t.save(),qd(t,i,s),i.lineAnimateType===Ze.Arrow||i.lineAnimateType===Ze.WaterDrop){let u=rg(i,t);u instanceof Path2D?(t.stroke(u),t.fill(u)):(t.stroke(),t.fill())}else r instanceof Path2D?(a&&!i.lineAnimateType&&(t.save(),t.lineCap=i.fromLineCap,t.stroke(a),t.restore()),t.lineCap=i.lineCap,t.stroke(r)):(r(i,t),t.stroke());t.restore()}i.fromArrow&&Dd(t,i,s),i.toArrow&&Md(t,i,s),i.calculative.active&&!i.calculative.pencil&&!s.options.disableAnchor&&!s.data.locked&&Yd(t,i)}}}function $d(e=!0,t,i,s){const n=e?s.path2dMap.get(i):At.path2dDraws[i.name];if(n&&i.type){if(i.calculative.animatePos){if(t.save(),qd(t,i,s),t.beginPath(),n instanceof Path2D)if(i.lineName==="polyline"||i.lineName==="line")if(i.lineAnimateType===Ze.Arrow||i.lineAnimateType===Ze.WaterDrop){const r=rg(i);t.stroke(r),t.fill(r)}else i.calculative.gradientSmooth||i.calculative.lineSmooth?(i.calculative.gradientAnimatePath||(i.calculative.gradientAnimatePath=dc(i)),i.calculative.gradientAnimatePath instanceof Path2D&&t.stroke(i.calculative.gradientAnimatePath)):t.stroke(n);else t.stroke(n);else n(i,t),t.stroke();t.restore()}i.fromArrow&&Dd(t,i,s),i.toArrow&&Md(t,i,s),i.calculative.active&&!i.calculative.pencil&&!s.options.disableAnchor&&!s.data.locked&&Yd(t,i)}}function qd(e,t,i){e.strokeStyle=t.animateColor||i.styles.animateColor,t.animateShadow&&(e.shadowBlur=t.animateShadowBlur||t.animateLineWidth||6,e.shadowColor=t.animateShadowColor||t.animateColor||i.styles.animateColor),t.calculative.animateLineWidth&&(e.lineWidth=t.calculative.animateLineWidth*i.data.scale);let s=0;switch(t.lineAnimateType){case Ze.Beads:t.animateReverse?e.lineDashOffset=t.calculative.animatePos:e.lineDashOffset=t.length-t.calculative.animatePos,s=t.calculative.lineWidth||5,s<5&&(s=5);const n=t.animateLineDash&&t.animateLineDash.map(r=>r*s/5);e.setLineDash(n||[s,s*2]);break;case Ze.Dot:t.animateReverse?e.lineDashOffset=t.calculative.animatePos:e.lineDashOffset=t.length-t.calculative.animatePos,s=t.calculative.animateDotSize||t.calculative.lineWidth*2||6,s<6&&(s=6),s>40&&(s=40),e.lineWidth=(t.calculative.animateLineWidth||s)*i.data.scale,e.setLineDash([.1,t.length]);break;case Ze.Arrow:e.fillStyle=t.animateColor||i.styles.animateColor,e.lineWidth=1;break;case Ze.WaterDrop:e.fillStyle=t.animateColor||i.styles.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 Yd(e,t){const i=t.calculative.canvas.store;e.save(),e.lineWidth=1,e.fillStyle=t.activeColor||i.styles.activeColor,t.calculative.worldAnchors.forEach(s=>{!s.hidden&&!s.isTemp&&i_(e,s,t)}),e.restore()}function i_(e,t,i){if(!t)return;const s=i.calculative.canvas.store.activeAnchor===i.calculative.activeAnchor&&i.calculative.activeAnchor===t;let n=3;i.calculative.lineWidth>3&&(n=i.calculative.lineWidth),i.anchorRadius&&(n=i.anchorRadius),t.radius&&(n=t.radius),s?(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,n,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,n,0,Math.PI*2),e.fill(),e.stroke(),e.restore(),e.beginPath(),e.arc(t.x,t.y,n,0,Math.PI*2),e.fill(),e.stroke()),e.beginPath(),e.arc(t.x,t.y,n,0,Math.PI*2),e.fill(),e.stroke()):(e.save(),e.fillStyle="#ffffff",e.beginPath(),e.arc(t.x,t.y,n,0,Math.PI*2),e.fill(),e.stroke(),e.restore())}function Kd(e){const t=e.calculative.canvas.store;let 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,ae(i),ee(i),e.pivot&&Kl(i,e.pivot);else{const s=t.pens[e.parentId];let n=s.calculative.worldRect;n||(n=Kd(s)),i.x=n.x+n.width*e.x,i.y=n.y+n.height*e.y,i.width=n.width*e.width,i.height=n.height*e.height,s.flipX&&(i.x=n.width-(i.x-n.x+i.width)+n.x),s.flipY&&(i.y=n.height-(i.y-n.y+i.height)+n.y),ae(i),i.rotate=n.rotate+e.rotate,ee(i),e.pivot&&Kl(i,e.pivot)}return e.calculative.worldRect=i,gc(e,i),i}function gc(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 Sa(e){const t=ht(e.calculative.worldRect);if(delete t.pivot,!e.parentId){Object.assign(e,t);return}const s=e.calculative.canvas.store.pens[e.parentId].calculative.worldRect;Object.assign(e,us(t,s))}function En(e){const t=e.calculative.canvas.store;let i=[];if(e.anchors){let s=ht(e.anchors);e.flipX&&s.forEach(n=>{n.x=.5-(n.x-.5)}),e.flipY&&s.forEach(n=>{n.y=.5-(n.y-.5)}),s.forEach(n=>{i.push(s_(e,n))})}if(!i.length&&!e.type&&!e.calculative.canvas.parent.isCombine(e)){const{x:s,y:n,width:r,height:a}=e.calculative.worldRect;i=t.options.defaultAnchors.map((o,l)=>({id:`${l}`,penId:e.id,x:s+r*o.x,y:n+a*o.y}))}e.calculative.rotate&&i.forEach(s=>{Gt(s,e.calculative.rotate,e.calculative.worldRect.pivot||e.calculative.worldRect.center)}),(!e.type||e.anchors)&&(e.calculative.worldAnchors=i),e.calculative.activeAnchor&&i.length&&(e.calculative.activeAnchor=i.find(s=>{s.id,e.calculative.activeAnchor.id})),e.calculative.gradientAnimatePath=void 0}function Xd(e){var t;if((t=e.children)!=null&&t.length){let i=e.calculative.worldRect;e.children.forEach(s=>{const n=e.calculative.canvas.store.pens[s];n.calculative.initRect&&n.calculative.initRelativeRect&&(n.calculative.initRect.x=i.x+i.width*n.calculative.initRelativeRect.x,n.calculative.initRect.y=i.y+i.height*n.calculative.initRelativeRect.y,n.calculative.initRect.ex=n.calculative.initRect.x+i.width*n.calculative.initRelativeRect.width,n.calculative.initRect.ey=n.calculative.initRect.y+i.height+n.calculative.initRelativeRect.height,ee(n.calculative.initRect)),Xd(n)})}}function s_(e,t){const i={...t},{x:s,y:n,width:r,height:a}=e.calculative.worldRect;return i.x=s+r*t.x,i.y=n+a*t.y,t.prev&&(i.prev={penId:e.id,connectTo:t.prev.connectTo,x:s+r*t.prev.x,y:n+a*t.prev.y}),t.next&&(i.next={penId:e.id,connectTo:t.next.connectTo,x:s+r*t.next.x,y:n+a*t.next.y}),i}function hf(e,t){const{paddingTop:i,paddingBottom:s,paddingLeft:n,paddingRight:r}=t.calculative;let a=n,o=i,l=t.calculative.worldRect.width-n-r,u=t.calculative.worldRect.height-i-s,h=t.calculative.iconLeft,f=t.calculative.iconTop;h&&Math.abs(h)<1&&(h=t.calculative.worldRect.width*h),f&&Math.abs(f)<1&&(f=t.calculative.worldRect.height*f),a+=h||0,o+=f||0,l-=h||0,u-=f||0;let g=t.calculative.iconRotate||0;if(t.parentId){const v=e[t.parentId].calculative;v&&(g+=v.rotate,g%=360)}a=t.calculative.worldRect.x+a,o=t.calculative.worldRect.y+o,t.calculative.worldIconRect={x:a,y:o,width:l,height:u,rotate:g},ae(t.calculative.worldIconRect),ee(t.calculative.worldIconRect)}function gn(e,t,i){gr(e.calculative.worldRect,t,i,e.pivot),e.calculative.initRect&&gr(e.calculative.initRect,t,i,e.pivot),Gd(e,t,i),e.calculative.x&&Na(e.calculative,t,i),e.type&&En(e)}function Gd(e,t,i){var s;!e||(s=e.children)!=null&&s.length&&e.children.forEach(n=>{const r=e.calculative.canvas.store.pens[n];r&&(r.calculative.initRect&&gr(r.calculative.initRect,t,i),Gd(r,t,i))})}function n_(e,t){e.anchors||(e.anchors=[]),e.calculative.worldAnchors||(e.calculative.worldAnchors=[]);const 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&&Gt(t,-e.rotate,e.calculative.worldRect.center);const s={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(s)}return i}function r_(e,t,i){e.anchors||(e.anchors=[]),e.calculative.worldAnchors||(e.calculative.worldAnchors=[]);const s=i2(e,t,i);return e.calculative.worldAnchors.splice(i+1,0,s),e.anchors.splice(i+1,0,rr(s,e.calculative.worldRect)),e.calculative.activeAnchor=s,s}function a_(e,t){if(!e||!e.calculative.worldAnchors)return;let i=e.calculative.worldAnchors.findIndex(s=>s.id===t.id);i>-1&&e.calculative.worldAnchors.splice(i,1),i=e.anchors.findIndex(s=>s.id===t.id),i>-1&&e.anchors.splice(i,1)}function Sn(e,t){if(!t||!t.calculative||!t.calculative.worldRect.center)return Lt.None;if(e.anchorId){let i=t.anchors.filter(s=>s.id===e.anchorId);if(i.length&&i[0].direction>-1)return i[0].direction}return nx(e,t.calculative.worldRect.center)}function bn(e,t){let i=1/0,s;return e.calculative.worldAnchors.forEach(n=>{const r=Xa(t,n);i>r&&(i=r,s=n)}),s}function uf(e,t,i){e.x+=t,e.y+=i,e.anchors&&e.anchors.forEach(s=>{nr(s,t,i)}),e.calculative.worldAnchors&&e.calculative.worldAnchors.forEach(s=>{nr(s,t,i)})}function vc(e){if(e&&e.calculative&&e.calculative.worldAnchors.length){let t=Vt(e);if(!e.anchors||!e.anchors.length)for(;e.calculative.worldAnchors.length&&t!==e.calculative.activeAnchor;)e.calculative.worldAnchors.pop(),t=Vt(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 we(e,t,i,s){var o,l,u,h,f,g;if(!e||!t||!i||!s||t.twoWay===Ee.DisableConnected||t.twoWay===Ee.Disable||s.twoWay===Ee.DisableConnectTo||s.twoWay===Ee.Disable)return;if(t.twoWay===Ee.In){if(i.calculative.worldAnchors.length===1)return;const v=Vt(i);if(s.id!==v.id)return}if(t.twoWay===Ee.Out){const v=le(i);if(s.id!==v.id)return}if(s.connectTo===e.id&&s.anchorId===t.id)return;if(s.connectTo){const v=e.calculative.canvas.store.pens[s.connectTo];xn(v,Ls(v,s.anchorId),i,s)}e.connectedLines||(e.connectedLines=[]),e.connectedLines.findIndex(v=>v.lineId===i.id&&v.lineAnchor===s.id&&v.anchor===t.id)<0&&e.connectedLines.push({lineId:i.id,lineAnchor:s.id,anchor:t.id}),s.connectTo=e.id,s.anchorId=t.id,e.type&&we(i,s,e,t),e.calculative.canvas.store.emitter.emit("connectLine",{line:i,lineAnchor:s,pen:e,anchor:t});let r=((o=i.calculative.worldAnchors)==null?void 0:o.length)>=2?(l=i.calculative.worldAnchors)==null?void 0:l[0].connectTo:void 0,a=((u=i.calculative.worldAnchors)==null?void 0:u.length)>=2?(f=i.calculative.canvas.store.pens[(h=i.calculative.worldAnchors)==null?void 0:h[0].connectTo])==null?void 0:f.anchors.find(v=>{var y;return v.id===((y=i.calculative.worldAnchors)==null?void 0:y[0].anchorId)}):void 0;return(g=e.onConnectLine)==null||g.call(e,e,{line:i,lineAnchor:s,pen:e,anchor:t,fromPen:r,fromAnchor:a}),!0}function xn(e,t,i,s){if(!(!e||!t||!i||!s)&&!(!e.connectedLines||!e.connectedLines.length))return i.lastConnected||(i.lastConnected={}),i.lastConnected[e.id]||(i.lastConnected[e.id]=ht(e.connectedLines)),e.connectedLines.forEach((n,r,a)=>{(n.lineId===i.id||n.lineId===i.id)&&n.lineAnchor===s.id&&n.anchor===t.id&&a.splice(r,1)}),s.connectTo=void 0,s.anchorId=void 0,e.type&&t.connectTo===i.id&&t.anchorId===s.id&&xn(i,s,e,t),e.calculative.canvas.store.emitter.emit("disconnectLine",{line:i,lineAnchor:s,pen:e,anchor:t}),!0}function Ls(e,t){var i;if(!(!e||!t))return(i=e.calculative.worldAnchors)==null?void 0:i.find(s=>s.id===t)}function le(e){if(!(!e||!e.calculative.worldAnchors))return e.calculative.worldAnchors[0]}function Vt(e){if(!(!e||!e.calculative.worldAnchors))return e.calculative.worldAnchors[e.calculative.worldAnchors.length-1]}function o_(e,t){var s,n;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;for(const r of e.frames){e.calculative.duration+=r.duration;for(const a in r)a!=="duration"&&!e[a]&&a==="scale"&&(e[a]=1)}}if(e.animateCycle||(e.animateCycle=1/0),e.calculative.start){let r=0;const a=Math.ceil((t-e.calculative.start)/e.calculative.duration);if(a>e.animateCycle)return e.currentAnimation=void 0,e.calculative.start=void 0,df(e,1),0;const o=(t-e.calculative.start)%e.calculative.duration||e.calculative.duration;let l=0;for(const f of e.frames)if(l+=f.duration,o>l)++r;else break;if(!e.frames[r])return!0;let u=!1;r!==e.calculative.frameIndex&&(u=!0,e.calculative.frameIndex=r,e.calculative.frameDuration=e.frames[r].duration,r>0&&(e.calculative.frameStart+=e.frames[r-1].duration),e.calculative.frameEnd=e.calculative.frameStart+e.calculative.frameDuration);let h=!1;if(a>e.calculative.cycleIndex&&(e.calculative.cycleIndex=a,e.calculative.frameStart=e.calculative.start+e.calculative.duration*(a-1),h=!0),u||h)if(e.calculative.x=e.calculative.initRect.x,e.calculative.y=e.calculative.initRect.y,((n=e.children)==null?void 0:n.length)&&!e.parentId?e.calculative.canvas.rotatePen(e,(e.calculative.initRect.rotate||0)-(e.calculative.rotate||0),e.calculative.initRect):e.calculative.rotate=e.calculative.initRect.rotate||0,r>0){e.prevFrame={};const f=e.frames[r-1];for(const g in f)e.prevFrame[g]=f[g];Object.assign(e.prevFrame,{rotate:f.rotate||0,x:f.x||0,y:f.y||0,scale:f.scale||1})}else ff(e)}else{if(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=ht(e.calculative.worldRect),e.parentId&&(e.calculative.initRelativeRect={x:e.x,y:e.y,width:e.width,height:e.height}),(s=e.children)!=null&&s.length){const r=e.calculative.canvas.store;e.calculative.childrenVisible={},e.children.forEach(a=>{e.calculative.childrenVisible[a]=r.pens[a].visible})}e.calculative.initRect.rotate=e.calculative.rotate||0,ff(e)}const i=(t-e.calculative.frameStart)/e.calculative.frameDuration%1;return i>0&&df(e,i),!0}function ff(e){e.prevFrame={};for(const 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 df(e,t){var n,r,a,o,l,u;if(t<0)return;t>1&&(t=1);const i=e.frames[e.calculative.frameIndex],s=e.calculative.canvas.store.data.scale;for(const h in i)if(h!=="duration"){if(h==="scale"){e.calculative.worldRect=ht(e.calculative.initRect),gr(e.calculative.worldRect,e.prevFrame.scale,e.calculative.worldRect.center);const f=e.prevFrame.scale+(i[h]-e.prevFrame.scale)*t;gr(e.calculative.worldRect,f/e.prevFrame.scale,e.calculative.worldRect.center),e.calculative.patchFlags=!0}else if(h==="x"){const f=Zn(e,h,e.calculative.frameIndex)*s;e.calculative.worldRect.x=e.calculative.initRect.x+f,e.calculative.worldRect.ex=e.calculative.initRect.ex+f,e.calculative.worldRect.center.x=e.calculative.initRect.center.x+f,(n=e.calculative.worldRect.pivot)!=null&&n.x&&(e.calculative.worldRect.pivot.x=((r=e.calculative.initRect.pivot)==null?void 0:r.x)+f),Ms(e.calculative.worldRect,i[h]*t*s,0),e.calculative.patchFlags=!0}else if(h==="y"){const f=Zn(e,h,e.calculative.frameIndex)*s;e.calculative.worldRect.y=e.calculative.initRect.y+f,e.calculative.worldRect.ey=e.calculative.initRect.ey+f,e.calculative.worldRect.center.y=e.calculative.initRect.center.y+f,(a=e.calculative.worldRect.pivot)!=null&&a.x&&(e.calculative.worldRect.pivot.y=((o=e.calculative.initRect.pivot)==null?void 0:o.y)+f),Ms(e.calculative.worldRect,0,i[h]*t*s),e.calculative.patchFlags=!0}else if(h==="width"){const f=Zn(e,h,e.calculative.frameIndex)*s;e.calculative.worldRect.width=e.calculative.initRect.width+f,e.calculative.worldRect.ex=e.calculative.initRect.ex+f,e.calculative.worldRect.center.x=e.calculative.initRect.center.x+f;let g=i[h]*t*s;e.calculative.worldRect.width+=g,e.calculative.worldRect.ex+=g,e.calculative.worldRect.center.x+=g,e.calculative.patchFlags=!0}else if(h==="height"){const f=Zn(e,h,e.calculative.frameIndex)*s;e.calculative.worldRect.height=e.calculative.initRect.height+f,e.calculative.worldRect.ey=e.calculative.initRect.ey+f,e.calculative.worldRect.center.y=e.calculative.initRect.center.y+f;let g=i[h]*t*s;e.calculative.worldRect.height+=g,e.calculative.worldRect.ey+=g,e.calculative.worldRect.center.y+=g,e.calculative.patchFlags=!0}else if(h==="rotate"){e.prevFrame[h]>=360&&(e.prevFrame[h]%=360);const f=Zn(e,h,e.calculative.frameIndex),g=(e.calculative.initRect.rotate+f+i[h]*t)%360-(e.calculative.rotate||0);(l=e.children)!=null&&l.length?e.calculative.canvas.rotatePen(e,g,e.calculative.initRect):e.calculative.rotate=(e.calculative.initRect.rotate+f+i[h]*t)%360,e.calculative.patchFlags=!0}else if(h==="image")e.image=i.image,e.calculative.image=void 0,e.calculative.canvas.loadImage(e),e.canvasLayer===zt.CanvasImageBottom?e.calculative.canvas.canvasImageBottom.init():e.canvasLayer===zt.CanvasImage&&e.calculative.canvas.canvasImage.init();else if(l_(i[h],h,e)){e.prevFrame[h]==null&&(h==="globalAlpha"?e.prevFrame[h]=1:e.prevFrame[h]=0);const f=e.prevFrame[h]+(i[h]-e.prevFrame[h])*t;e.calculative[h]=Math.round(f*100)/100}else{if(h==="visible"&&!e.calculative.image){if((u=e.children)!=null&&u.length){const g=mi(e,e.calculative.canvas.store);e.calculative.canvas.initImageCanvas(g)}}e.calculative[h]=i[h];const f={};f[h]=i[h],yc(e,f)}h==="text"&&xr(e)}}function l_(e,t,i){const s=["strokeType","bkType","showChild"];return typeof e=="number"&&i.linear!==!1&&!s.includes(t)}function c_(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 pn(e,t=!0){if(!e.children||e.childActive===!1)return;const i=e.calculative.canvas.store;e.children.forEach(s=>{const n=i.pens[s];n&&(n.calculative.active=t,pn(n,t))})}function tr(e,t=!0){if(!e)return;const i=e.calculative.canvas.store;e.calculative.hover=t,e.childHover!==!1&&e.children&&e.children.forEach(s=>{var n,r;((n=i.pens[s])==null?void 0:n.hoverColor)==null&&((r=i.pens[s])==null?void 0:r.hoverBackground)==null&&tr(i.pens[s],t)})}function Te(e,t){if(!t)return;const i=e.calculative.canvas.store,s=e.calculative.worldRect;if(t.style.opacity=e.globalAlpha+"",t.style.position="absolute",t.style.outline="none",t.style.left=s.x+i.data.x+"px",t.style.top=s.y+i.data.y+"px",t.style.width=s.width+"px",t.style.height=s.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===Ot.DisableEdit||e.locked===Ot.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"),e.className&&(t.className=e.className),e.styles)for(let n in e.styles)t.style[n]=e.styles[n]}function Al(e){return e.every(t=>t.locked)}function gf(e){return e.every(t=>t.disableRotate)}function Zd(e,t,i){var s;e.type?(e.calculative.worldAnchors.forEach(n=>{Gt(n,t,i.center)}),h_(e),Sa(e)):(e.calculative.rotate?e.calculative.rotate+=t:e.calculative.rotate=t,Gt(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)),(s=e.children)==null||s.forEach(n=>{const r=e.calculative.canvas.store.pens[n];Zd(r,t,i)})}function h_(e){var n;if(!((n=e.calculative.worldAnchors)!=null&&n.length)||!isFinite(e.x)||!isFinite(e.x)||e.x==null||e.y==null)return;const t=Zl(e);e.parentId||Object.assign(e,t);const{fontSize:i,lineHeight:s}=e.calculative.canvas.store.options;e.fontSize?e.fontSize<0&&(e.fontSize=0,e.calculative.fontSize=0):(e.fontSize=i>=0?i:12,e.calculative.fontSize=e.fontSize*e.calculative.canvas.store.data.scale),e.lineHeight||(e.lineHeight=s,e.calculative.lineHeight=e.lineHeight),ee(t),e.calculative.worldRect=t,gc(e,t),Ti(e),e.calculative.worldAnchors&&(e.anchors=e.calculative.worldAnchors.map(r=>rr(r,e.calculative.worldRect)))}function vf(e){return e.every(t=>t.disableSize||t.pivot)}function Zn(e,t,i){if(!e.frames||!t)return 0;let s=0;for(let n=0;n<i;n++)e.frames[n]&&(s+=e.frames[n][t]||0);return s}function Ua(e,t){var s;let i=e;for(;i&&i.parentId;){const n=i;i=t.pens[i.parentId];const r=(s=i==null?void 0:i.calculative)==null?void 0:s.showChild;if(r!=null&&i.children[r]!==n.id)return!1}return!0}function Yi(e,t=!1){var n,r,a;const{store:i,canvasRect:s}=e.calculative.canvas;if(t&&((n=e.children)==null||n.forEach(o=>{const l=i.pens[o];l&&Yi(l,!0)})),e.calculative.inView=!0,Ua(e,i)?(e.visible==!1||e.calculative.visible==!1)&&(e.calculative.inView=!1,(e.canvasLayer===zt.CanvasImageBottom||e.canvasLayer===zt.CanvasImage)&&((r=e.frames)==null?void 0:r.length)&&(e.calculative.inView=e.frames.some(o=>o.hasOwnProperty("visible")))):e.calculative.inView=!1,e.calculative.inView){const{x:o,y:l,width:u,height:h,rotate:f}=e.calculative.worldRect,g={x:o+i.data.x,y:l+i.data.y,width:u,height:h,rotate:f};ae(g),Xi(g,s)||(e.calculative.inView=!1)}(a=e.calculative.singleton)!=null&&a.div&&Te(e,e.calculative.singleton.div)}function u_(e,t,i){if(t.fillWorldTextRect){e.save(),e.fillStyle="#c3deb7";const{x:s,y:n,width:r,height:a}=i.calculative.worldTextRect;e.fillRect(s,n,r,a),e.restore()}}function Hs(e,t){const i=t.calculative.globalAlpha;typeof i=="number"&&i<1&&!isNaN(i)&&(e.globalAlpha=i)}function Jd(e,t){const i=f_(e,t)||At.canvasDraws[t.name];i&&(e.save(),i(e,t),e.restore())}function f_(e,t){const i=t.drawCommand;if(!(!i||t.name==="line"))return(s,n)=>{i.forEach(r=>{try{r.steps=r.steps.flat(1/0),r.steps.reduce((a,o)=>{const l=d_(o,n,a.x,a.y);try{if(l.c){if(l.c.startsWith("_")){const h=l.c.split("_")[1];return typeof l.v.value=="number"&&(l.v.value*=n.calculative.canvas.store.data.scale),(l.p||s)[h]=l.v.value,{x:a.x,y:a.y}}let u=[];for(const h in l.v)u.push(l.v[h]);return(l.p||s)[l.c](...u),{x:l.startX||l.v.x,y:l.startY||l.v.y}}return{x:a.x,y:a.y}}catch{}},{})}catch{}}),s.stroke()}}function d_(e,t,i,s){var r;const n={visio:y_,dxf:g_,canvas:v_};return((r=n[t.parseType])==null?void 0:r.call(n,e,t,i,s))||e}function g_(e,t,i,s){var h,f;const{x:n,y:r,width:a,height:o}=t.calculative.worldRect,{originWidth:l,originHeight:u}=t.dxfOrigin;switch(e.c){case"beginPath":return{c:"beginPath",v:{}};case"closePath":return{c:"closePath",v:{}};case"moveTo":return{c:"moveTo",v:{x:e.v.x*(a/l)+n,y:e.v.y*(o/u)+r}};case"lineTo":return{c:"lineTo",v:{x:e.v.x*(a/l)+n,y:e.v.y*(o/u)+r}};case"arc":return{c:"ellipse",v:{x:e.v.x*(a/l)+n,y:e.v.y*(o/u)+r,rx:e.v.xr*(a/l),ry:e.v.yr*(o/u),rotation:e.v.rotation||0,startAngle:e.v.startAngle,endAngle:e.v.endAngle,a:(h=e.v.aclockwise)!=null?h:!0}};case"ellipse":return{c:"ellipse",v:{x:e.v.x*(a/l)+n,y:e.v.y*(o/u)+r,rx:e.v.xr*(a/l),ry:e.v.yr*(o/u),rotation:e.v.rotation||0,startAngle:e.v.startAngle,endAngle:e.v.endAngle,a:(f=e.v.aclockwise)!=null?f:!0}};case"_font":return{c:"_font",v:{value:e.v.fontSize*t.calculative.canvas.store.data.scale+"px "+(e.v.fontFamily||t.calculative.canvas.store.options.fontFamily)}};case"_fillStyle":return{c:"_fillStyle",v:{value:t.color||e.v.value}};default:const g={c:e.c,v:{...e.v}};return g.v.x!==void 0&&(g.v.x=e.v.x*(a/l)+n),g.v.y!==void 0&&(g.v.y=e.v.y*(o/u)+r),g}}function v_(e,t,i,s){var h,f;const{x:n,y:r,width:a,height:o}=t.calculative.worldRect,{originWidth:l,originHeight:u}=t.origin;switch(e.c){case"beginPath":return{c:"beginPath",v:{}};case"closePath":return{c:"closePath",v:{}};case"moveTo":return{c:"moveTo",v:{x:e.v.x*(a/l)+n,y:e.v.y*(o/u)+r}};case"lineTo":return{c:"lineTo",v:{x:e.v.x*(a/l)+n,y:e.v.y*(o/u)+r}};case"arc":return{c:"ellipse",v:{x:e.v.x*(a/l)+n,y:e.v.y*(o/u)+r,rx:e.v.xr*(a/l),ry:e.v.yr*(o/u),rotation:e.v.rotation||0,startAngle:e.v.startAngle,endAngle:e.v.endAngle,a:(h=e.v.aclockwise)!=null?h:!0}};case"ellipse":return{c:"ellipse",v:{x:e.v.x*(a/l)+n,y:e.v.y*(o/u)+r,rx:e.v.xr*(a/l),ry:e.v.yr*(o/u),rotation:e.v.rotation||0,startAngle:e.v.startAngle,endAngle:e.v.endAngle,a:(f=e.v.aclockwise)!=null?f:!0}};case"_font":return{c:"_font",v:{value:e.v.fontSize*t.calculative.canvas.store.data.scale+"px "+(e.v.fontFamily||t.calculative.canvas.store.options.fontFamily)}};default:const g={c:e.c,v:{...e.v}};return g.v.x!==void 0&&(g.v.x=e.v.x*(a/l)+n),g.v.y!==void 0&&(g.v.y=e.v.y*(o/u)+r),g}}function y_(e,t,i,s){const{x:n,y:r,width:a,height:o}=t.calculative.worldRect,{width:l,height:u}=t.origin;switch(e.c){case"MoveTo":return{c:"moveTo",v:{x:+e.v.X*100*(a/l)+n,y:+e.v.Y*100*(o/u)+r}};case"RelMoveTo":return{c:"moveTo",v:{x:+e.v.X*l*(a/l)+n,y:+e.v.Y*u*(o/u)+r}};case"LineTo":return{c:"lineTo",v:{x:+e.v.X*100*(a/l)+n,y:+e.v.Y*100*(o/u)+r}};case"RelLineTo":return{c:"lineTo",v:{x:+e.v.X*l*(a/l)+n,y:+e.v.Y*u*(o/u)+r}};case"Ellipse":let h=e.v.X,f=e.v.Y,g=Math.abs(e.v.A-e.v.C),v=Math.abs(e.v.B-e.v.D);return{c:"ellipse",v:{x:h*100*(a/l)+n,y:f*100*(o/u)+r,radiuX:g*100*(a/l),radiuY:v*100*(o/u),rotation:0,startAngle:0,endAngle:Math.PI*2,anticlockwise:!0}};case"EllipticalArcTo":const y=e.v.X*100*(a/l)+n,w=e.v.Y*100*(o/u)+r,p=e.v.A*100*(a/l)+n,_=e.v.B*100*(o/u)+r;e.v.C;const E=e.v.D*(a/o)*(u/l),x=(y-i)*(_-s)-(w-s)*(p-i)>0,C=yf(i,s,y,w,p,_,E);return!e.orign&&(e.orign={}),!e.orign.startA&&(e.orign.startA=ma(C.x0,C.y0,i,s)),!e.orign.endA&&(e.orign.endA=ma(C.x0,C.y0,y,w)),{c:"ellipse",v:{centerX:C.x0,centerY:C.y0,radiuX:C.a,radiuY:C.b,rotation:0,startAngle:e.orign.startA,endAngle:e.orign.endA,anticlockwise:x},startX:y,startY:w};case"RelEllipticalArcTo":const S=e.v.X*l*(a/l)+n,D=e.v.Y*u*(o/u)+r,B=e.v.A*l*(a/l)+n,L=e.v.B*u*(o/u)+r;e.v.C;const V=e.v.D*(a/o)*(u/l),tt=(S-i)*(L-s)-(D-s)*(B-i)>0,T=yf(i,s,S,D,B,L,V);return!e.orign&&(e.orign={}),!e.orign.startA&&(e.orign.startA=ma(T.x0,T.y0,i,s)),!e.orign.endA&&(e.orign.endA=ma(T.x0,T.y0,S,D)),{c:"ellipse",v:{centerX:T.x0,centerY:T.y0,radiuX:T.a,radiuY:T.b,rotation:0,startAngle:e.orign.startA,endAngle:e.orign.endA,anticlockwise:tt},startX:S,startY:D};case"ArcTo":let R=e.v.X*100*a/l+n,P=e.v.Y*100*o/u+r,O=e.v.A*100*(a/o)*(u/l),Y=(i+R)/2,Z=(s+P)/2,rt=Math.sqrt((R-i)**2+(P-s)**2),$=rt**2/(8*O)+O/2,H=-(P-s)/rt,j=(R-i)/rt,K=Y+H*$,W=Z+j*$,Q=K,st=W,et=Math.atan2(s-st,i-Q),ut=Math.atan2(P-st,R-Q);return{c:"arc",v:{x:Q,y:st,radius:$,startAngle:et,endAngle:ut,aclockwise:!0}};default:const ct=ht(e);return Object.entries(ct.v).forEach(([ot,b])=>{var k,I;(k=ot.endsWith)!=null&&k.call(ot,"_x")?typeof b=="number"&&(ct.v[ot]=b*(a/l)+n):(I=ot.endsWith)!=null&&I.call(ot,"_y")?typeof b=="number"&&(ct.v[ot]=b*(o/u)+r):typeof b=="number"&&(ct.v[ot]=b)}),ct}}function yc(e,t){for(const i in t)Rd.includes(i)&&(i=="fontSize"&&t[i]<0&&(t[i]=0),e[i]=t[i],["fontSize","lineWidth"].includes(i)?(e.calculative[i]=t[i]*e.calculative.canvas.store.data.scale,Ti(e)):e.calculative[i]=t[i]);if(e.calculative.canvas.parent.isCombine(e)){const i=e.children;i==null||i.forEach(s=>{let n=ht(t);e.calculative.childrenVisible&&e.calculative.childrenVisible[s]===!1&&delete n.visible;const r=e.calculative.canvas.store.pens[s];r&&yc(r,n)})}}function yf(e,t,i,s,n,r,a){let o=(e-i)*(e+i)*(s-r)-(i-n)*(i+n)*(t-s)+a*a*(t-s)*(s-r)*(t-r),l=2*((e-i)*(s-r)-(i-n)*(t-s)),u=o/l,h=(e-i)*(i-n)*(e-n)+a*a*((i-n)*(t-s)*(t+s)-(e-i)*(s-r)*(s+r)),f=2*a*a*((i-n)*(t-s)-(e-i)*(s-r)),g=h/f,v=Math.sqrt(Math.pow(e-u,2)+Math.pow(a*(t-g),2)),y=v/a;return{x0:u,y0:g,a:v,b:y}}function ma(e,t,i,s){let n=i-e,r=s-t,a=Math.atan2(r,n);return a<0&&(a+=2*Math.PI),a}function mf(e,t,i){let s,n,r=1/0,a=1/0;const o=8;for(const l of e.data.pens){if(l.calculative.inView===!1)continue;mc(l).forEach(h=>{if(h===t||h===i)return;let f=(l.calculative.worldRect.center.x-t.x)*(l.calculative.worldRect.center.x-t.x)+(l.calculative.worldRect.center.y-t.y)*(l.calculative.worldRect.center.y-t.y);const g=Math.abs(h.x-t.x);g>0&&g<o&&f<r&&(s={x:Math.round(h.x)+.5,y:Math.round(h.y)+.5,prev:{x:Math.round(t.x)+.5,y:Math.round(t.y)+.5},step:h.x-t.x},r=f);const v=Math.abs(h.y-t.y);v>0&&v<o&&f<a&&(n={x:Math.round(h.x)+.5,y:Math.round(h.y)+.5,prev:{x:Math.round(t.x)+.5,y:Math.round(t.y)+.5},step:h.y-t.y},a=f)})}return{xDock:s,yDock:n}}function m_(e,t,i,s){let n=[];return i.length===1?(n=ht(mc(i[0])),n.forEach(r=>{r.x+=s.x,r.y+=s.y})):(ee(t),n=[t.center,...Zi(t)]),Qd(e,n,t,!0)}function mc(e){if(e.type){if(e.type===jt.Line)return e.calculative.worldAnchors}else{const t=Zi(e.calculative.worldRect);return ee(e.calculative.worldRect),[...e.calculative.worldAnchors,...t,e.calculative.worldRect.center]}}function p_(e,t,i,s){const n=Zi(t);return Qd(e,n,t)}function Qd(e,t,i,s=!1){let n,r,a=1/0,o=1/0;const l=10,u=E_(i,l);return e.data.pens.forEach(h=>{const{inView:f,worldRect:g,active:v}=h.calculative;if(f===!1||!s&&v||k_(u,g)||h.type&&e.active.some(w=>tg(e,w,h)))return;const y=mc(h);if(!!y)for(const w of y)for(const p of t){const _=w.x-p.x,E=w.y-p.y,x=Math.abs(_),C=Math.abs(E);i.center||(i.center={x:i.x+i.width/2,y:i.y+i.height/2}),x<l&&x<a&&(n={x:Math.round(w.x)+.5,y:Math.round(w.y)+.5,step:_,prev:{x:Math.round(p.x)+.5,y:Math.round(p.y)+.5},penId:h.id,anchorId:p.id,dockAnchorId:w.id},a=x),C<l&&C<o&&(r={x:Math.round(w.x)+.5,y:Math.round(w.y)+.5,step:E,prev:{x:Math.round(p.x)+.5,y:Math.round(p.y)+.5},penId:h.id,anchorId:p.id,dockAnchorId:w.id},o=C)}}),{xDock:n,yDock:r}}function tg(e,t,i){if(!i.type)return!1;if(Array.isArray(t==null?void 0:t.connectedLines)){for(const s of t==null?void 0:t.connectedLines)if(s.lineId===i.id)return!0}if(Array.isArray(t==null?void 0:t.children))for(const s of t.children){const n=e.pens[s];if(tg(e,n,i))return!0}return!1}function Yl(e,t){return e.toFixed(12)==t}function pf(e){if(e.id=It(),Array.isArray(e.anchors))for(const t of e.anchors)e.type&&(t.id=It()),t.penId=e.id,t.prev&&(e.type&&(t.prev.id=It()),t.prev.penId=e.id),t.next&&(e.type&&(t.next.id=It()),t.next.penId=e.id)}function w_(){let e=null,t=new Map;return(i,s,n,r=!1)=>{if(t.has(i)&&t.get(i)?e=t.get(i):t.set(i,e=new Map),typeof n!="function")return()=>{console.warn("[rewritePenLifeCycle] warn: not a function ")};let a=new Set,o=new Map;e.has(s)&&e.get(s)?a=e.get(s):(o.set(s,i[s]),e.set(s,a)),r?a.delete(n):a.add(n);let l=o.get(s),u=(...h)=>{l==null||l(...h),a.forEach(f=>{f(...h)})};i[s]=u}}let b_=w_();function x_(e){return!e.name&&!e.install?(console.error("installPenPlugin Error: Validation Failed"),!1):!0}function Ui(e,t){if(!t)return;if(t.ex==null&&ae(t),!t.rotate||t.rotate%360===0)return e.x>t.x&&e.x<t.ex&&e.y>t.y&&e.y<t.ey;t.center||ee(t);const i=[{x:t.x,y:t.y},{x:t.ex,y:t.y},{x:t.ex,y:t.ey},{x:t.x,y:t.ey}];return i.forEach(s=>{Gt(s,t.rotate,t.pivot||t.center)}),__(e,i)}function Ws(e,t,i=0){const{x:s,y:n,ex:r,ey:a}=t;return e.x>=s-i&&e.x<=r+i&&e.y>=n-i&&e.y<=a+i}function ee(e){e.center||(e.center={}),e.center.x=e.x+e.width/2,e.center.y=e.y+e.height/2}function ae(e){e.ex=e.x+e.width,e.ey=e.y+e.height}function Kl(e,t){e.pivot||(e.pivot={}),e.pivot.x=e.x+e.width*t.x,e.pivot.y=e.y+e.height*t.y}function __(e,t){if(t.length<3)return!1;let i=!1,s=t[t.length-1];for(const n of t)s.y>e.y!=n.y>e.y&&n.x+(e.y-n.y)*(s.x-n.x)/(s.y-n.y)>e.x&&(i=!i),s=n;return i}function pi(e){const t=[];e.forEach(s=>{if(s.isRuleLine)return;const n=s.calculative.worldRect;if(n){const r=Zi(n);t.push(...r)}});const i=_r(t);return ee(i),i}function Zi(e){const 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||ee(e),t.forEach(i=>{Gt(i,e.rotate,e.pivot||e.center)})),t}function _r(e){let t=1/0,i=1/0,s=-1/0,n=-1/0;return e==null||e.forEach(r=>{!isFinite(r.x)||!isFinite(r.y)||(t=Math.min(t,r.x),i=Math.min(i,r.y),s=Math.max(s,r.x),n=Math.max(n,r.y))}),{x:t,y:i,ex:s,ey:n,width:s-t,height:n-i}}function Xi(e,t,i){return e.rotate&&(e=_r(Zi(e))),i?e.x>t.x&&e.ex<t.ex&&e.y>t.y&&e.ey<t.ey:!(e.x>t.ex||e.ex<t.x||e.ey<t.y||e.y>t.ey)}function k_(e,t){return(t.x>e.ex||t.ex<e.x)&&(t.y>e.ey||t.ey<e.y)}function E_(e,t){const i=qi(t),s={x:e.x-i[3],y:e.y-i[0],width:e.width+i[1]+i[3],height:e.height+i[0]+i[2]};return ae(s),s}function Ms(e,t,i){e.x+=t,e.y+=i,e.ex+=t,e.ey+=i,e.center&&(e.center.x+=t,e.center.y+=i),e.pivot&&(e.pivot.x+=t,e.pivot.y+=i)}function A_(e,t){const i=(e.to.y-e.from.y)/(e.to.x-e.from.x),s=(t.to.y-t.from.y)/(t.to.x-t.from.x);return Xl({k:i,point:e.from},{k:s,point:t.from})}function Xl(e,t){if(Yl(e.k,0))return{x:t.point.x,y:e.point.y};if(Yl(t.k,0))return{x:e.point.x,y:t.point.y};const i=e.point.y-e.k*e.point.x,n=(t.point.y-t.k*t.point.x-i)/(e.k-t.k),r=e.k*n+i;return{x:n,y:r}}function C_(e,t){const i=A_({from:e[0],to:e[2]},{from:e[1],to:e[3]});for(const s of e)Gt(s,-t,i);return _r(e)}function wf(e,t,i,s){let n=e.rotate?e.rotate%360:0;if(n){const r=Zi(e),a=(r[0].y-r[1].y)/(r[0].x-r[1].x),o=(r[1].y-r[2].y)/(r[1].x-r[2].x);if(s<4){if(r[s].x+=t,e.ratio)if(s===0||s===2){let h=t*Math.tan((90-(360-n)-Math.atan(e.width/e.height)/Math.PI*180)/180*Math.PI);r[s].y+=h}else{let h=t*Math.tan((90-(360-n)+Math.atan(e.width/e.height)/Math.PI*180)/180*Math.PI);r[s].y+=h}else r[s].y+=i;const u=r[(s+2)%4];r[(s+1)%4]=Xl({k:s%2?o:a,point:r[s]},{k:s%2?a:o,point:u}),r[(s+4-1)%4]=Xl({k:s%2?a:o,point:r[s]},{k:s%2?o:a,point:u})}else{const u=[4,6].includes(s)?o:a;Yl(u,0)?(r[s%4].x+=t,r[(s+1)%4].x+=t):(r[s%4].y+=i,r[s%4].x+=i/u,r[(s+1)%4].y+=i,r[(s+1)%4].x+=i/u)}if((r[0].x-r[1].x)**2+(r[0].y-r[1].y)**2<25||(r[1].x-r[2].x)**2+(r[1].y-r[2].y)**2<25)return;const l=C_(r,e.rotate);ee(l),Object.assign(e,l);return}switch(s){case 0:if(e.width-t<5||e.height-i<5)break;e.x+=t,e.y+=i,e.width-=t,e.height-=i;break;case 1:if(e.width+t<5||e.height-i<5)break;e.ex+=t,e.y+=i,e.width+=t,e.height-=i;break;case 2:if(e.width+t<5||e.height+i<5)break;e.ex+=t,e.ey+=i,e.width+=t,e.height+=i;break;case 3:if(e.width-t<5||e.height+i<5)break;e.x+=t,e.ey+=i,e.width-=t,e.height+=i;break;case 4:if(e.height-i<5)break;e.y+=i,e.height-=i;break;case 5:if(e.width+t<5)break;e.ex+=t,e.width+=t;break;case 6:if(e.height+i<5)break;e.ey+=i,e.height+=i;break;case 7:if(e.width-t<5)break;e.x+=t,e.width-=t;break}}function gr(e,t,i,s){!e||(e.width*=t,e.height*=t,Na(e,t,i),ae(e),ee(e),s&&Kl(e,s))}function us(e,t){const i={x:(e.x-t.x)/t.width,y:(e.y-t.y)/t.height,width:e.width/t.width,height:e.height/t.height};return ae(i),i}function rr(e,t){const{x:i,y:s,width:n,height:r}=t,{penId:a,connectTo:o}=e,l=Object.assign({},e,{x:n?(e.x-i)/n:0,y:r?(e.y-s)/r:0});return e.prev&&(l.prev={penId:a,connectTo:o,x:n?(e.prev.x-i)/n:0,y:r?(e.prev.y-s)/r:0}),e.next&&(l.next={penId:a,connectTo:o,x:n?(e.next.x-i)/n:0,y:r?(e.next.y-s)/r:0}),l}function T_(e,t){let i=!1;for(let s=0,n=t.length-1;s<t.length;n=s++){let r=t[s].x,a=t[s].y,o=t[n].x,l=t[n].y;a>e.y!=l>e.y&&e.x<(o-r)*(e.y-a)/(l-a)+r&&(i=!i)}return i}const R_=/^[\t\n\f\r ]*([MLHVZCSQTAmlhvzcsqta])[\t\n\f\r ]*/,bf=/^[01]/,Jt=/^[+-]?(([0-9]*\.[0-9]+)|([0-9]+\.)|([0-9]+))([eE][+-]?[0-9]+)?/,S_=/^(([\t\n\f\r ]+,?[\t\n\f\r ]*)|(,[\t\n\f\r ]*))/,P_={M:[Jt,Jt],L:[Jt,Jt],H:[Jt],V:[Jt],Z:[],C:[Jt,Jt,Jt,Jt,Jt,Jt],S:[Jt,Jt,Jt,Jt],Q:[Jt,Jt,Jt,Jt],T:[Jt,Jt],A:[Jt,Jt,Jt,bf,bf,Jt,Jt]};function I_(e){let t=0;const i=[];for(;t<e.length;){const s=e.slice(t).match(R_);if(s!==null){const n=s[1];t+=s[0].length;const r=B_(n,e,t);t=r.cursor,i.push(...r.commands)}else throw new Error("malformed path (first error at "+t+")")}return{commands:i}}function xf(e){let t=1/0,i=1/0,s=-1/0,n=-1/0;return N_(e),e.commands.forEach(r=>{r.worldPoints.forEach((a,o)=>{o%2===0?(a<t&&(t=a),a>s&&(s=a)):(a<i&&(i=a),a>n&&(n=a))})}),--t,--i,{x:t,y:i,ex:s,ey:n,width:s-t+1,height:n-i+1}}function L_(e,t,i){i==null&&(i=t),e.commands.forEach((s,n)=>{if(!(s.relative&&n))switch(s.key){case"A":case"a":s.values[5]+=t,s.values[6]+=i;break;case"V":case"v":s.values[0]+=i;break;default:s.values.forEach((r,a)=>{s.values[a]=r+(a%2===0?t:i)});break}})}function D_(e,t,i){i==null&&(i=t),e.commands.forEach(s=>{switch(s.key){case"A":case"a":const n=s.values[0],r=s.values[1],a=Math.PI*s.values[2]/180,o=Math.cos(a),l=Math.sin(a),u=r*r*i*i*o*o+n*n*i*i*l*l,h=2*t*i*o*l*(r*r-n*n),f=n*n*t*t*o*o+r*r*t*t*l*l,g=-(n*n*r*r*t*t*i*i),v=h*h-4*u*f,y=Math.sqrt((u-f)*(u-f)+h*h);s.values[2]=h!==0?Math.atan((f-u-y)/h)*180/Math.PI:u<f?0:90,s.values[0]=-Math.sqrt(2*v*g*(u+f+y))/v,s.values[1]=-Math.sqrt(2*v*g*(u+f-y))/v,s.values[5]*=t,s.values[6]*=i,s.values[4]=t*i>=0?s.values[4]:1-s.values[4];break;case"V":case"v":s.values[0]*=i;break;default:s.values.forEach((w,p)=>{s.values[p]=w*(p%2===0?t:i)});break}})}function M_(e){let t="";return e.commands.forEach(i=>{t+=i.key+" ",i.values.forEach(s=>{t+=s+" "})}),t}function B_(e,t,i){const s=P_[e.toUpperCase()],n=[];for(;i<=t.length;){const r={key:e,values:[]};for(const a of s){const o=t.slice(i).match(a);if(o!==null){r.values.push(+o[0]),i+=o[0].length;const l=t.slice(i).match(S_);l!==null&&(i+=l[0].length)}else{if(r.values.length===0)return{cursor:i,commands:n};throw new Error("malformed path (first error at "+i+")")}}if(r.relative=r.key.toUpperCase()!==r.key,n.push(r),s.length===0)return{cursor:i,commands:n};e==="m"&&(e="l"),e==="M"&&(e="L")}throw new Error("malformed path (first error at "+i+")")}function O_(e,t){const i=[];let s=e.relative&&t?{x:t.worldPoints[t.worldPoints.length-2],y:t.worldPoints[t.worldPoints.length-1]}:{x:0,y:0};for(let n=0;n<e.values.length-1;n+=2)i.push(s.x+e.values[n]),i.push(s.y+e.values[n+1]);e.worldPoints=i}function N_(e){let t,i=0,s=0;e.commands.forEach(n=>{switch(n.key){case"Z":case"z":n.worldPoints=[i,s];break;case"H":n.worldPoints=[n.values[0],t.worldPoints[t.worldPoints.length-1]];break;case"h":n.worldPoints=[n.values[0]+t.worldPoints[t.worldPoints.length-2],t.worldPoints[t.worldPoints.length-1]];break;case"V":n.worldPoints=[t.worldPoints[t.worldPoints.length-2],n.values[0]];break;case"v":n.worldPoints=[t.worldPoints[t.worldPoints.length-2],n.values[0]+t.worldPoints[t.worldPoints.length-1]];break;case"A":n.worldPoints=[t.worldPoints[t.worldPoints.length-2],n.values[0]+t.worldPoints[t.worldPoints.length-1]];break;default:O_(n,t);break}(n.key==="M"||n.key==="m"||n.key==="Z"||n.key==="z")&&(i=n.worldPoints[n.worldPoints.length-2],s=n.worldPoints[n.worldPoints.length-1]),t=n})}function F_(e,t){var l;const s=e.calculative.canvas.store.data.paths[e.pathId];if(!s)return new Path2D;const n=I_(s);e.calculative.svgRect=xf(n),ee(e.calculative.svgRect),(e.calculative.svgRect.width!==e.calculative.worldRect.width||e.calculative.svgRect.height!==e.calculative.worldRect.height)&&D_(n,e.calculative.worldRect.width/e.calculative.svgRect.width,e.calculative.worldRect.height/e.calculative.svgRect.height);const r=xf(n);ee(r),L_(n,e.calculative.worldRect.x-r.x,e.calculative.worldRect.y-r.y);const a=M_(n);if(t){(l=t.svgPath)==null||l.call(t,a);return}return new Path2D(a)}function z_(e,t){const i=t||new Path2D,{x:s,y:n,width:r,height:a}=e.calculative.worldRect;if(i.moveTo(s+r/2,n),i.lineTo(s+r,n+a/2),i.lineTo(s+r/2,n+a),i.lineTo(s,n+a/2),i.lineTo(s+r/2,n),i.closePath(),i instanceof Path2D)return i}function H_(e,t){const i=t||new Path2D,{x:s,y:n,width:r,height:a}=e.calculative.worldRect;if(i.moveTo(s+r/2,n),i.lineTo(s+r,n+a),i.lineTo(s,n+a),i.lineTo(s+r/2,n),i.closePath(),i instanceof Path2D)return i}function W_(e){const t=[{x:.5,y:0},{x:.75,y:.5},{x:.5,y:1},{x:.25,y:.5}];e.anchors=t.map(({x:i,y:s},n)=>({id:`${n}`,penId:e.id,x:i,y:s}))}function U_(e,t){const i=t||new Path2D,{x:s,y:n,width:r,height:a}=e.calculative.worldRect;if(i.moveTo(s+r/2,n),i.lineTo(s+r,n+a*2/5),i.lineTo(s+r*4/5,n+a),i.lineTo(s+r/5,n+a),i.lineTo(s,n+a*2/5),i.closePath(),i instanceof Path2D)return i}function V_(e){const t=[{x:.5,y:0},{x:1,y:.4},{x:.8,y:1},{x:.2,y:1},{x:0,y:.4}];e.anchors=t.map(({x:i,y:s},n)=>({id:`${n}`,penId:e.id,x:i,y:s}))}function j_(e,t){e.onResize||(e.onResize=$_);const i=t||new Path2D,{width:s,height:n,center:r}=e.calculative.worldRect,a=s>n?n:s,o=r.x,l=r.y,u=l-a/2,h=l-a/4,f=-(h-l)*Math.sin(Math.PI/180*324)+o,g=(h-l)*Math.cos(Math.PI/180*324)+l;i.moveTo(f,g);for(let v=0;v<5;++v)i.lineTo(-(u-l)*Math.sin(Math.PI/180*72*v)+o,(u-l)*Math.cos(Math.PI/180*72*v)+l),i.lineTo((f-o)*Math.cos(Math.PI/180*72*(v+1))-(g-l)*Math.sin(Math.PI/180*72*(v+1))+o,(f-o)*Math.sin(Math.PI/180*72*(v+1))+(g-l)*Math.cos(Math.PI/180*72*(v+1))+l);if(i.closePath(),i instanceof Path2D)return i}function eg(e){const{width:t,height:i}=e,s=t>i?i:t,n=[];for(let r=0;r<5;++r)n.push({flag:1,id:String(r),penId:e.id,x:.5+s/2*Math.sin(Math.PI/180*72*r)/t,y:-s/2*Math.cos(Math.PI/180*72*r)/i+.5});e.anchors=n}function $_(e){const t=e.anchors.filter(i=>i.flag!==1);eg(e),e.anchors=e.anchors.concat(...t)}function q_(e,t){const i=t||new Path2D,{x:s,y:n,width:r,height:a}=e.calculative.worldRect;if(i.moveTo(s+r/4,n),i.lineTo(s+r*3/4,n),i.lineTo(s+r,n+a/2),i.lineTo(s+r*3/4,n+a),i.lineTo(s+r*1/4,n+a),i.lineTo(s,n+a/2),i.lineTo(s+r/4,n),i.closePath(),i instanceof Path2D)return i}function Y_(e,t){const i=t||new Path2D,{x:s,y:n,width:r,height:a}=e.calculative.worldRect;if(i.moveTo(s,n+a/2),i.lineTo(s+a/2,n),i.lineTo(s+a/2,n+a/3),i.lineTo(s+r,n+a/3),i.lineTo(s+r,n+a*2/3),i.lineTo(s+a/2,n+a*2/3),i.lineTo(s+a/2,n+a*2/3),i.lineTo(s+a/2,n+a),i.closePath(),i instanceof Path2D)return i}function K_(e,t){const i=t||new Path2D,{x:s,y:n,width:r,height:a}=e.calculative.worldRect;if(i.moveTo(s,n+a/3),i.lineTo(s+(r-a/2),n+a/3),i.lineTo(s+(r-a/2),n),i.lineTo(s+r,n+a/2),i.lineTo(s+(r-a/2),n+a),i.lineTo(s+(r-a/2),n+a*2/3),i.lineTo(s,n+a*2/3),i.closePath(),i instanceof Path2D)return i}function X_(e,t){const i=t||new Path2D,{x:s,y:n,width:r,height:a}=e.calculative.worldRect;if(i.moveTo(s,n+a/2),i.lineTo(s+a/2,n),i.lineTo(s+a/2,n+a/3),i.lineTo(s+(r-a/2),n+a/3),i.lineTo(s+(r-a/2),n),i.lineTo(s+r,n+a/2),i.lineTo(s+(r-a/2),n+a),i.lineTo(s+(r-a/2),n+a*2/3),i.lineTo(s+a/2,n+a*2/3),i.lineTo(s+a/2,n+a),i.closePath(),i instanceof Path2D)return i}function G_(e,t){const i=t||new Path2D,{x:s,y:n,width:r,height:a,ey:o}=e.calculative.worldRect;if(i.moveTo(s,n),i.lineTo(s+r,n),i.lineTo(s+r,n+a*3/4),i.lineTo(s+r*8/16,n+a*3/4),i.lineTo(s+r/4,o),i.lineTo(s+r*5/16,n+a*3/4),i.lineTo(s,n+a*3/4),i.closePath(),i instanceof Path2D)return i}function Z_(e,t){const i=t||new Path2D,{x:s,y:n,width:r,height:a}=e.calculative.worldRect;if(i.moveTo(s+r/5,n+a*13/16),i.bezierCurveTo(s-r/15,n+a*13/16,s-r/15,n+a*7/16,s+r/5,n+a*7/16),i.bezierCurveTo(s+r/5,n,s+r*4/5,n,s+r*4/5,n+a*7/16),i.bezierCurveTo(s+r*16/15,n+a*7/16,s+r*16/15,n+a*13/16,s+r*4/5,n+a*13/16),i.closePath(),i instanceof Path2D)return i}function J_(e,t){const i=t||new Path2D,{x:s,y:n,width:r,ex:a,ey:o}=e.calculative.worldRect,l=r/6;if(i.moveTo(s,n),i.lineTo(a-l,n),i.lineTo(a,n+l),i.lineTo(a,o),i.lineTo(s,o),i.closePath(),i.moveTo(a-l,n),i.lineTo(a-l,n+l),i.lineTo(a,n+l),i.closePath(),i instanceof Path2D)return i}function Q_(e,t){const{x:i,y:s,width:n,ex:r,ey:a}=t.calculative.worldRect;let o=n*.25;const l=t.z;l>1?o=l*t.calculative.canvas.store.data.scale:l>0&&(o=n*l);const u={x:i,y:s+o},h={x:r-o,y:s+o},f={x:r-o,y:a};Cl(e,[u,h,f,{x:i,y:a}],t.backgroundFront||t.background,t.color),Cl(e,[u,{x:i+o,y:s},{x:r,y:s},h],t.backgroundUp||t.background,t.color),Cl(e,[h,{x:r,y:s},{x:r,y:a-o},f],t.backgroundRight||t.background,t.color)}function Cl(e,t,i="",s=""){e.save(),i&&(e.fillStyle=i),s&&(e.strokeStyle=s),e.beginPath();for(let n=0;n<t.length;++n)n?e.lineTo(t[n].x,t[n].y):e.moveTo(t[n].x,t[n].y);e.closePath(),i&&e.fill(),e.stroke(),e.restore()}function t2(e,t){const i=t||new Path2D,{x:s,y:n,width:r,ex:a,ey:o}=e.calculative.worldRect,l=r/4,u=s+r/2;if(i.arc(u,n+l,l,0,Math.PI*2),i.moveTo(s,n+l*3),i.lineTo(a,n+l*3),i.moveTo(u,n+l*2),i.lineTo(u,n+l*4),i.moveTo(u,n+l*4),i.lineTo(s,o),i.moveTo(u,n+l*4),i.lineTo(a,o),i.closePath(),i instanceof Path2D)return i}function e2(e,t,i){if(t.calculative.worldAnchors||(t.calculative.worldAnchors=[]),i)t.calculative.activeAnchor&&(t.calculative.activeAnchor.next={penId:t.id,x:i.x,y:i.y},Xa(t.calculative.activeAnchor.next,t.calculative.activeAnchor)<5?t.calculative.activeAnchor.next=void 0:(t.calculative.activeAnchor.prev={...t.calculative.activeAnchor.next},Gt(t.calculative.activeAnchor.prev,180,t.calculative.activeAnchor)));else{const s=t.calculative.worldAnchors[0];if(!s.next){const r=Sn(s,e.pens[s.connectTo]);_f(s,r,50),s.prev=void 0}const n=t.calculative.worldAnchors[t.calculative.worldAnchors.length-1];if(n&&n!==s&&!n.prev){const r=Sn(n,e.pens[n.connectTo]);_f(n,r,-50),n.next=void 0}}}function _f(e,t,i){switch(t){case Lt.Up:e.prev={penId:e.penId,x:e.x,y:e.y+i},e.next={penId:e.penId,x:e.x,y:e.y-i};break;case Lt.Right:e.prev={penId:e.penId,x:e.x-i,y:e.y},e.next={penId:e.penId,x:e.x+i,y:e.y};break;case Lt.Bottom:e.prev={penId:e.penId,x:e.x,y:e.y-i},e.next={penId:e.penId,x:e.x,y:e.y+i};break;case Lt.Left:e.prev={penId:e.penId,x:e.x+i,y:e.y},e.next={penId:e.penId,x:e.x-i,y:e.y};break}}function Gl(e,t,i,s){const n=1-e,r=n*n*t.x+2*n*e*i.x+e*e*s.x,a=n*n*t.y+2*n*e*i.y+e*e*s.y;return{x:r,y:a,step:e}}function ig(e,t,i,s,n){const{x:r,y:a}=t,{x:o,y:l}=n,{x:u,y:h}=i,{x:f,y:g}=s,v=1-e,y=r*v*v*v+3*u*e*v*v+3*f*e*e*v+o*e*e*e,w=a*v*v*v+3*h*e*v*v+3*g*e*e*v+l*e*e*e;return{x:y,y:w,step:e}}function ls(e,t,i){return{x:e.x+i*(t.x-e.x),y:e.y+i*(t.y-e.y)}}function i2(e,t,i){let s=e.calculative.worldAnchors[i],n=e.calculative.worldAnchors[i+1];!n&&e.close&&(n=e.calculative.worldAnchors[0]);const r=t.step;let a;if(s.next&&n.prev){const o=s,l=s.next,u=n.prev,h=n,f=ls(o,l,r),g=ls(l,u,r),v=ls(u,h,r),y=ls(f,g,r),w=ls(g,v,r);a=ls(y,w,r),y.penId=e.id,a.prev=y,w.penId=e.id,a.next=w,s.next.x=f.x,s.next.y=f.y,n.prev.x=v.x,n.prev.y=v.y}else if(s.next||n.prev){const o=s,l=s.next||n.prev,u=n,h=ls(o,l,r),f=ls(l,u,r);a=t,h.penId=e.id,f.penId=e.id,a.prev=h,a.next=f,s.next=void 0,n.prev=void 0}else a=t;return a.penId=e.id,a.id=It(),a.prevNextType=Fs.Bilateral,a}function s2(e,t,i){if(t.calculative.worldAnchors||(t.calculative.worldAnchors=[]),t.calculative.worldAnchors.length<2)return;let s=t.calculative.activeAnchor,n=i||Vt(t);if(!s||!n)return;const r=20,a=e.pens[s.connectTo];let o=Sn(s,a);switch(o===Lt.None&&(n.x>s.x?o=Lt.Right:o=Lt.Left),s.next={id:It(),penId:t.id,x:s.x,y:s.y,prevNextType:2},n.prev={id:It(),penId:t.id,x:n.x,y:n.y,prevNextType:2},o){case Lt.Up:s.next.y-=r,n.prev.y=s.y;break;case Lt.Bottom:s.next.y+=r,n.prev.y=s.y;break;case Lt.Left:s.next.x-=r,n.prev.x=s.x;break;default:s.next.x+=r,n.prev.x=s.x;break}}function n2(e,t){const i=t||new Path2D;if((e.lineName==="line"||e.lineName==="polyline")&&e.calculative.lineSmooth){let n=dc(e);if(i instanceof Path2D&&i.addPath(n),i instanceof Path2D)return i}const s=e.calculative.worldAnchors;if(s.length>1){let n;s.forEach(r=>{n?kf(i,n,r):r.start=!0,n=r}),e.close&&(e.lineName==="curve"?kf(i,n,s[0]):i.closePath())}if(i instanceof Path2D)return i}function r2(e,t,i){var r;if(t.calculative.worldAnchors||(t.calculative.worldAnchors=[]),t.calculative.worldAnchors.length<2||((r=t.anchors)==null?void 0:r.length)>1)return;const s=le(t),n=Vt(t);!s||!n||!n.id||s===n||(s.next=void 0,vc(t),n.prev=void 0,t.calculative.worldAnchors.push(n))}function kf(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 Zl(e){return Jl(e),_r(sg(e))}function sg(e){const t=[];let i;return e.calculative.worldAnchors.forEach(s=>{t.push(s),i&&t.push(...Ef(i,s,e)),i=s}),e.close&&e.calculative.worldAnchors.length>1&&t.push(...Ef(i,e.calculative.worldAnchors[0],e)),t}function Va(e){return e!=null&&e.lineWidth?e.lineWidth/2+4:4}function Ef(e,t,i){const s=[];if(!t)return s;let n=.02;if(e.lineLength&&(n=Va(i)/e.lineLength),e.next)if(t.prev)for(let r=n;r<1;r+=n)s.push(ig(r,e,e.next,t.prev,t));else for(let r=n;r<1;r+=n)s.push(Gl(r,e,e.next,t));else if(t.prev)for(let r=n;r<1;r+=n)s.push(Gl(r,e,t.prev,t));else s.push({x:t.x,y:t.y});return s.length>1&&(e.curvePoints=s),s}function a2(e,t){const i=Va(t);let s=0,n,r;for(const a of t.calculative.worldAnchors){if(n){if(r=Af(e,n,a,i),r)return{i:s,point:r};++s}n=a}if(t.close&&t.calculative.worldAnchors.length>1&&(r=Af(e,n,t.calculative.worldAnchors[0],i)))return{i:s,point:r}}function Af(e,t,i,s=4){if(!t.next&&!i.prev){const{x:n,y:r}=t,{x:a,y:o}=i,l=Math.min(n,a),u=Math.max(n,a),h=Math.min(r,o),f=Math.max(r,o);return e.x>=l-s&&e.x<=u+s&&e.y>=h-s&&e.y<=f+s?o2(e,t,i,s):void 0}else if(t.curvePoints){for(const n of t.curvePoints)if(mn(e,n,s))return n}}function o2(e,t,i,s=4){if(t.x===i.x){if(Math.abs(e.x-t.x)<=s)return{x:t.x,y:e.y}}else{const n=(t.y-i.y)/(t.x-i.x),r=t.y-n*t.x;if(Math.abs((n*e.x+r-e.y)/Math.sqrt(n*n+1))<=s){const l=(e.x+n*e.y-n*r)/(n*n+1);return{x:l,y:n*l+r}}}}function Cf(e,t,i,s){if(!t&&!i)return Math.sqrt(Math.pow(Math.abs(e.x-s.x),2)+Math.pow(Math.abs(e.y-s.y),2))||0;const n=document.createElementNS("http://www.w3.org/2000/svg","path");return t&&i?n.setAttribute("d",`M${e.x} ${e.y} C${t.x} ${t.y} ${i.x} ${i.y} ${s.x} ${s.y}`):t?n.setAttribute("d",`M${e.x} ${e.y} Q${t.x} ${t.y} ${s.x} ${s.y}`):n.setAttribute("d",`M${e.x} ${e.y} Q${i.x} ${i.y} ${s.x} ${s.y}`),n.getTotalLength()||0}function Jl(e){if(e.calculative.worldAnchors.length<2)return 0;let t=0,i;if(e.calculative.worldAnchors.forEach(s=>{i&&(i.lineLength=Cf(i,i.next,s.prev,s),t+=i.lineLength),i=s}),e.close){const s=le(e);i.lineLength=Cf(i,i.next,s.prev,s),t+=i.lineLength}return e.calculative.animatePos&&(e.calculative.animatePos=t/e.length*e.calculative.animatePos),e.length=t,t}function Tl(e,t){const i=e.calculative.worldAnchors;for(let s=0;s<i.length-1;s++){const n=i[s],r=i[s+1];if(!n.next&&!r.prev){if(ng(n,r,t))return!0}else if(l2(n,r,t))return!0}return!1}function ng(e,t,i){if(Ws(e,i)||Ws(t,i))return!0;const s=e.x,n=e.y,r=t.x,a=t.y;let o=i.x,l=i.y,u=i.ex,h=i.ey;const f=n-a,g=r-s,v=s*a-r*n;if(f*o+g*l+v>=0&&f*u+g*h+v<=0||f*o+g*l+v<=0&&f*u+g*h+v>=0||f*o+g*h+v>=0&&f*u+g*l+v<=0||f*o+g*h+v<=0&&f*u+g*l+v>=0){if(o>u){const y=o;o=u,u=y}if(l<h){const y=l;l=h,h=y}return!(s<o&&r<o||s>u&&r>u||n>l&&a>l||n<h&&a<h)}else return!1}function l2(e,t,i){if(!e.next&&!t.prev)return ng(e,t,i);if(e.next&&t.prev)for(let n=.02;n<1;n+=.02){const r=ig(n,e,e.next,t.prev,t);if(Ws(r,i))return!0}else if(e.next||t.prev)for(let n=.02;n<1;n+=.02){const r=Gl(n,e,e.next||t.prev,t);if(Ws(r,i))return!0}return!1}let He=10;function c2(e,t,i){var w;if(t.calculative.worldAnchors||(t.calculative.worldAnchors=[]),He=e.options.polylineSpace||10,t.calculative.worldAnchors.length<2)return;let s=le(t),n=Vt(t);if(!s||!n)return;let r;if(((w=t.anchors)==null?void 0:w.length)&&s===t.calculative.activeAnchor?(r=!0,s=n,n=le(t)):(!t.anchors||!t.anchors.length)&&s!==t.calculative.activeAnchor&&(s=t.calculative.activeAnchor),!s||!n)return;s.next=void 0,n.prev=void 0;const a=n.connectTo;vc(t);const o=[],l=e.pens[s.connectTo],u=e.pens[n.connectTo],h=Sn(s,l),f=Sn(n,u);let g=Tf(s,h,He);g&&(s=g,o.push(g)),g=Tf(n,f,He);const v=n;let y;if(g&&(n=g,v.connectTo&&(g.y>v.y&&s.y<v.y||g.y<v.y&&s.y>v.y))){y=g;let p=He;s.x<g.x&&(p=-p),Math.abs(s.x-g.x)<p&&(p=-p),n={x:g.x+p,y:g.y,id:It()}}switch(h){case Lt.Up:o.push(...h2(s,n,f));break;case Lt.Right:o.push(...u2(s,n,f));break;case Lt.Bottom:o.push(...f2(s,n,f));break;case Lt.Left:o.push(...d2(s,n,f));break;default:o.push(...g2(t,s,n));break}if(o.forEach(p=>{p.id=It(),p.penId=t.id,t.calculative.worldAnchors.push(p)}),t.calculative.worldAnchors.push(n),y&&t.calculative.worldAnchors.push(y),g&&t.calculative.worldAnchors.push(v),r&&t.calculative.worldAnchors.reverse(),a){const p=t.calculative.worldAnchors.length-2;t.calculative.worldAnchors[p].isTemp=!1,t.calculative.worldAnchors[1].isTemp=!1}}function Tf(e,t,i){const s={x:e.x,y:e.y,id:It()};switch(t){case Lt.Up:s.y-=i;break;case Lt.Right:s.x+=i;break;case Lt.Bottom:s.y+=i;break;case Lt.Left:s.x-=i;break;default:return}return s}function h2(e,t,i){if(e.x===t.x||e.y===t.y)return[];const s=[];let n,r;switch(i){case Lt.Up:e.y<t.y?(n=t.x,r=e.y):(n=e.x,r=t.y),s.push({x:n,y:r});break;case Lt.Bottom:if(n=t.x,r=e.y,t.y>e.y)n=e.x+(t.x-e.x)/2,s.push({x:n,y:e.y},{x:n,y:t.y});else{const a=(e.y+t.y)/2;s.push({x:e.x,y:a},{x:t.x,y:a})}break;case Lt.Right:n=t.x,r=e.y,t.x<e.x&&t.y<e.y&&(n=e.x,r=t.y),s.push({x:n,y:r});break;case Lt.Left:n=t.x,r=e.y,t.x>e.x&&t.y<e.y&&(n=e.x,r=t.y),s.push({x:n,y:r});break;default:if(t.y>e.y-He)n=e.x+(t.x-e.x)/2,s.push({x:n,y:e.y},{x:n,y:t.y});else{const a=(e.y+t.y+He)/2;s.push({x:e.x,y:a},{x:t.x,y:a})}break}return s}function u2(e,t,i){if(e.x===t.x||e.y===t.y)return[];const s=[];let n,r;switch(i){case Lt.Up:n=e.x,r=t.y,t.x>e.x&&t.y>e.y&&(n=t.x,r=e.y),s.push({x:n,y:r});break;case Lt.Bottom:n=e.x,r=t.y,t.x>e.x&&t.y<e.y&&(n=t.x,r=e.y),s.push({x:n,y:r});break;case Lt.Left:if(n=t.x,r=e.y,t.x<e.x)r=e.y+(t.y-e.y)/2,s.push({x:e.x,y:r},{x:t.x,y:r});else{const a=(e.x+t.x)/2;s.push({x:a,y:r},{x:a,y:t.y})}break;case Lt.Right:t.x<e.x?s.push({x:e.x,y:t.y}):s.push({x:t.x,y:e.y});break;default:if(n=t.x,r=t.y,t.x<e.x+He)s.push({x:e.x,y:r});else{const a=(e.x+t.x-He)/2;s.push({x:a,y:e.y},{x:a,y:r})}break}return s}function f2(e,t,i){if(e.x===t.x||e.y===t.y)return[];const s=[];let n,r;switch(i){case Lt.Up:if(n=e.x,r=t.y,t.y<e.y)n=e.x+(t.x-e.x)/2,s.push({x:n,y:e.y},{x:n,y:t.y});else{const a=(e.y+t.y)/2;s.push({x:n,y:a},{x:t.x,y:a})}break;case Lt.Right:n=t.x,r=e.y,t.x<e.x&&t.y>e.y&&(n=e.x,r=t.y),s.push({x:n,y:r});break;case Lt.Bottom:e.y>t.y?(n=t.x,r=e.y):(n=e.x,r=t.y),s.push({x:n,y:r});break;case Lt.Left:n=t.x,r=e.y,t.x>e.x&&t.y>e.y&&(n=e.x,r=t.y),s.push({x:n,y:r});break;default:if(n=e.x,t.y<e.y+He)n=e.x+(t.x-e.x)/2,s.push({x:n,y:e.y},{x:n,y:t.y});else{const a=(e.y+t.y-He)/2;s.push({x:n,y:a},{x:t.x,y:a})}break}return s}function d2(e,t,i){if(e.x===t.x||e.y===t.y)return[];const s=[];let n,r;switch(i){case Lt.Up:n=e.x,r=t.y,t.x<e.x&&t.y>e.y&&(n=t.x,r=e.y),s.push({x:n,y:r});break;case Lt.Bottom:n=e.x,r=t.y,t.x<e.x&&t.y<e.y&&(n=t.x,r=e.y),s.push({x:n,y:r});break;case Lt.Right:if(n=e.x,r=t.y,t.x>e.x)n=t.x,r=e.y+(t.y-e.y)/2,s.push({x:e.x,y:r},{x:t.x,y:r});else{const a=(e.x+t.x)/2;s.push({x:a,y:e.y},{x:a,y:t.y})}break;case Lt.Left:t.x>e.x?s.push({x:e.x,y:t.y}):s.push({x:t.x,y:e.y});break;default:if(n=e.x,r=t.y,t.x<e.x-He){const a=(e.x+t.x+He)/2;s.push({x:a,y:e.y},{x:a,y:r})}else s.push({x:e.x,y:r});break}return s}function g2(e,t,i){const s=[];e.calculative.drawlineH==null&&(e.calculative.drawlineH=Math.abs(i.x-t.x)>Math.abs(i.y-t.y));let n=e.calculative.worldAnchors.findIndex(r=>r.id==t.id);if(n>1){let r=e.calculative.worldAnchors[n-1];if(r.x===t.x&&r.y!==t.y)return s.push({x:i.x,y:t.y}),s;if(r.y===t.y&&r.x!==t.x)return s.push({x:t.x,y:i.y}),s}return e.calculative.worldAnchors.length&&(i.isTemp=void 0,e.calculative.drawlineH?(s.push({x:i.x,y:t.y}),Math.abs(i.y-t.y)<He&&(i.isTemp=!0)):(s.push({x:t.x,y:i.y}),Math.abs(i.x-t.x)<He&&(i.isTemp=!0))),s}function pa(e,t,i=!0){var n,r;let s=e.calculative.worldAnchors;i||(s=[],e.calculative.worldAnchors.forEach(a=>{s.unshift(a)}));for(let a=0;a<s.length&&s[a].id!==t.id;a++)if(s[a].y!==t.y||s[a].x===((n=s[a+1])==null?void 0:n.x)&&s[a].y!==((r=s[a+1])==null?void 0:r.y))return!1;return!0}function wa(e,t,i=!0){var n,r;let s=e.calculative.worldAnchors;i||(s=[],e.calculative.worldAnchors.forEach(a=>{s.unshift(a)}));for(let a=0;a<s.length&&s[a].id!==t.id;a++)if(s[a].x!==t.x||s[a].y===((n=s[a+1])==null?void 0:n.y)&&s[a].x!==((r=s[a+1])==null?void 0:r.x))return!1;return!0}function v2(e,t,i){if(!e.calculative.worldAnchors)return;const s=e.calculative.worldAnchors.findIndex(l=>l.id===t.id),n=le(e),r=Vt(e);let a=e.calculative.worldAnchors[s-1],o=e.calculative.worldAnchors[s+1];if(e.calculative.h==null&&(n.connectTo&&(pa(e,t,!0)?e.calculative.h=!0:wa(e,t,!0)&&(e.calculative.h=!1)),e.calculative.h==null&&r.connectTo&&(pa(e,t,!1)?e.calculative.h=!0:wa(e,t,!1)&&(e.calculative.h=!1)),e.calculative.h==null&&(a?e.calculative.h=a.y===t.y:o&&(e.calculative.h=o.y===t.y))),e.calculative.h){if(t.x=i.x,n.connectTo&&pa(e,t,!0)){o&&o.y!==t.y&&(o.x=t.x);return}if(r.connectTo&&pa(e,t,!1)){a&&a.y!==t.y&&(a.x=t.x);return}const l=e.anchors[s];let u;for(let h=s-1;h>-1;h--)if(a=e.anchors[h],u==null&&(u=a.y===l.y),u===!0)if(a.y===l.y)e.calculative.worldAnchors[h].y=i.y;else break;else if(a.x===l.x)e.calculative.worldAnchors[h].x=i.x;else break;u=void 0;for(let h=s+1;h<e.calculative.worldAnchors.length&&(o=e.anchors[h],o);h++)if(u==null&&(u=o.y===l.y),u===!0)if(o.y===l.y)e.calculative.worldAnchors[h].y=i.y;else break;else if(o.x===l.x)e.calculative.worldAnchors[h].x=i.x;else break;t.y=i.y}else{if(t.y=i.y,n.connectTo&&wa(e,t,!0)){o&&o.x!==t.x&&(o.y=t.y);return}if(r.connectTo&&wa(e,t,!1)){a&&a.x!==t.x&&(a.y=t.y);return}const l=e.anchors[s];let u;for(let h=s-1;h>-1;h--)if(a=e.anchors[h],u==null&&(u=a.x===l.x),u===!0)if(a.x===l.x)e.calculative.worldAnchors[h].x=i.x;else break;else if(a.y===l.y)e.calculative.worldAnchors[h].y=i.y;else break;u=void 0;for(let h=s+1;h<e.calculative.worldAnchors.length&&(o=e.anchors[h],o);h++)if(u==null&&(u=o.x===l.x),u===!0)if(o.x===l.x)e.calculative.worldAnchors[h].x=i.x;else break;else if(o.y===l.y)e.calculative.worldAnchors[h].y=i.y;else break;t.x=i.x}}function Ql(e,t,i,s){const n=[];let r,a,o,l,u,h,f,g,v,y,w,p,_,E;v=e[i],y=e[s],o=v.x,l=v.y,f=y.x-o,g=y.y-l,E=f*f+g*g,r=t;for(let x=i+1;x<s;x++)w=e[x],f!==0||g!==0?(p=((w.x-o)*f+(w.y-l)*g)/E,p>1?(u=w.x-y.x,h=w.y-y.y):p>0?(u=w.x-(o+f*p),h=w.y-(l+g*p)):(u=w.x-o,h=w.y-l)):(u=w.x-o,h=w.y-l),_=u*u+h*h,_>r&&(a=x,r=_);return r>t&&(a-i>1&&n.push(...Ql(e,t,i,a)),n.push({id:e[a].id,penId:e[a].penId,x:e[a].x,y:e[a].y}),s-a>1&&n.push(...Ql(e,t,a,s))),n}function y2(e,t=.8,i=!1){if(e.length<3)return e;let s,n,r,a,o,l,u,h,f,g,v,y,w,p,_;const E=(x,C,S,D)=>(a=Math.sqrt(x*x+C*C),a>0?(y=x/a,p=C/a):(y=1,p=0),o=Math.sqrt(S*S+D*D),o>0?(w=S/o,_=D/o):(w=1,_=0),Math.acos(y*w+p*_));g=[],v=e.length,s=e[0],e[v-1],g.push({...e[0]});for(let x=0;x<v-1;x++){if(n=e[x],r=e[x+1],f=Math.abs(E(n.x-s.x,n.y-s.y,r.x-n.x,r.y-n.y)),a)if(f<t*3.14)if(i&&(a=Math.min(a,o),o=a),l=(y+w)/2,u=(p+_)/2,h=Math.sqrt(l*l+u*u),h===0)g.push({...n});else{l/=h,u/=h;const C={...n};C.prevNextType=Fs.Bilateral,C.prev={penId:C.penId,x:n.x-l*a*.25,y:n.y-u*a*.25},C.next={penId:C.penId,x:n.x+l*o*.25,y:n.y+u*o*.25},g.push(C)}else g.push({...n});s=n}return g.push({...e[e.length-1]}),g}function rg(e,t){const i=t||new Path2D,s=e.calculative.worldAnchors;let n=e.calculative.canvas.store.data.scale,r=(e.calculative.animateLineWidth||6)*n,a=(e.animateLineWidth*2||12)*n;e.lineAnimateType===Ze.WaterDrop&&(a=(e.animateLineWidth*4||24)*n);let o=(e.animateInterval||100)*n,l=e.calculative.lineWidth*(e.calculative.lineSmooth||0),u=(e.calculative.animateLineWidth/2||3)*n;if(e.animateReverse&&(a=-a,r=-r),s.length>1){let h,f=0;for(let g=0;g<s.length;g++){let v=s[g];if(h){let y=m2(h,v),w={x:h.x+(e.calculative.animatePos-f)%o*Math.cos(y*Math.PI/180),y:h.y-(e.calculative.animatePos-f)%o*Math.sin(y*Math.PI/180)};e.animateReverse&&(w={x:h.x+(e.length-(e.calculative.animatePos+f))%o*Math.cos(y*Math.PI/180),y:h.y-(e.length-(e.calculative.animatePos+f))%o*Math.sin(y*Math.PI/180)});let p=Math.sqrt((w.x-h.x)**2+(w.y-h.y)**2),_=Math.sqrt((v.x-h.x)**2+(v.y-h.y)**2);for(;p<_;)(e.animateReverse&&p-a<_||!e.animateReverse&&p>a)&&p>l+a&&_-p>l&&(e.lineAnimateType===Ze.Arrow?p2(i,w,r,y,u,a):e.lineAnimateType===Ze.WaterDrop&&w2(i,w,e.animateReverse,y,u,a)),w.x+=o*Math.cos(y*Math.PI/180),w.y-=o*Math.sin(y*Math.PI/180),p=Math.sqrt((w.x-h.x)**2+(w.y-h.y)**2)}h=v}}if(i instanceof Path2D)return i}function m2(e,t){let i=t.x-e.x,s=t.y-e.y,n=Math.atan(s/i)*180/Math.PI;return t.x>=e.x?n=-n:n=180-n,n}function gs(e,t,i){let s=(180-i)*Math.PI/180;return{x:(e.x-t.x)*Math.cos(s)-(e.y-t.y)*Math.sin(s)+t.x,y:(e.x-t.x)*Math.sin(s)+(e.y-t.y)*Math.cos(s)+t.y}}function p2(e,t,i,s,n,r){let a=gs({x:t.x+i,y:t.y+.57*i},{x:t.x,y:t.y},s),o=gs({x:t.x+i,y:t.y-.57*i},{x:t.x,y:t.y},s),l=gs({x:t.x+i,y:t.y+n/2},{x:t.x,y:t.y},s),u=gs({x:t.x+r,y:t.y+n/2},{x:t.x,y:t.y},s),h=gs({x:t.x+i,y:t.y-n/2},{x:t.x,y:t.y},s),f=gs({x:t.x+r,y:t.y-n/2},{x:t.x,y:t.y},s);e.moveTo(a.x,a.y),e.lineTo(t.x,t.y),e.lineTo(o.x,o.y),e.lineTo(h.x,h.y),e.lineTo(f.x,f.y),e.lineTo(u.x,u.y),e.lineTo(l.x,l.y),e.lineTo(a.x,a.y)}function w2(e,t,i,s,n,r){let a=n/2;i&&(a=-n/2);let o=gs({x:t.x,y:t.y+a},{x:t.x,y:t.y},s),l=gs({x:t.x+r,y:t.y},{x:t.x,y:t.y},s),u=Math.PI/2;i&&(u=-Math.PI/2),e.moveTo(t.x,t.y),e.arc(t.x,t.y,n/2,-u-s/180*Math.PI,u-s/180*Math.PI,!1),e.lineTo(l.x,l.y),e.lineTo(o.x,o.y)}function b2(e){var i;e.onDestroy||(e.onDestroy=x2,e.onMove=ba,e.onResize=ba,e.onRotate=ba,e.onValue=ba,e.onMouseMove=k2,e.onBeforeValue=_2,e.onRenderPenRaw=E2),e.calculative.singleton||(e.calculative.singleton={});const t=e.calculative.worldRect;if(!e.calculative.singleton.div){const s=document.createElement("div");s.style.position="absolute",s.style.outline="none",s.style.left="-9999px",s.style.top="-9999px",s.style.width=t.width+"px",s.style.height=t.height+"px",document.body.appendChild(s),(i=e.calculative.canvas.externalElements)==null||i.parentElement.appendChild(s),Te(e,s),e.calculative.singleton.div=s;const n=document.createElement("iframe");n.style.width="100%",n.style.height="100%",n.scrolling=e.scrolling||"no",n.frameBorder="0",n.style.border="none",n.src=e.iframe,e.calculative.iframe=e.iframe,s.appendChild(n),og(e),n.onload=()=>{n.setAttribute("document.domain","")}}return e.calculative.patchFlags&&Te(e,e.calculative.singleton.div),e.onRenderPenRaw(e),new Path2D}function x2(e){lg(e),e.calculative.singleton&&e.calculative.singleton.div&&(e.calculative.singleton.div.remove(),delete e.calculative.singleton.div)}function ba(e){e.calculative.singleton.div&&Te(e,e.calculative.singleton.div)}function _2(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={});let i=ht(t);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&&(e.calculative.singleton.div.children.length===1?og(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(let i=1;i<5;i++)e.calculative.singleton.div.children[i].style["backdrop-filter"]=`blur(${t.blur||2}px)`;if(t.blurBackground!==void 0)for(let i=1;i<5;i++)e.calculative.singleton.div.children[i].style.backgroundColor=t.blurBackground;return t}function k2(e,t){if(!(!e.calculative.canvas.store.data.locked&&!e.locked)&&ag(e.operationalRect)&&e.calculative.zIndex<5&&t.x>e.x+e.width*e.operationalRect.x&&t.x<e.x+e.width*(e.operationalRect.x+e.operationalRect.width)&&t.y>e.y+e.height*e.operationalRect.y&&t.y<e.y+e.height*(e.operationalRect.y+e.operationalRect.height)&&e.calculative.singleton.div){let i=e.calculative.singleton.div.parentNode.children;for(let s=0;s<6;s++)i[s].style.pointerEvents="none"}}function ag(e){return e?!e.width||!e.height?!1:(e.x===void 0&&(e.x=(1-e.width)/2),e.y===void 0&&(e.y=(1-e.height)/2),!0):!1}function og(e){if(!ag(e.operationalRect))return;const t=e.calculative.singleton.div;if(!t)return;const i=document.createElement("div");i.style.position="absolute",i.style.left=e.operationalRect.x*100+"%",i.style.top="0px",i.style.width=e.operationalRect.width*100+"%",i.style.height=e.operationalRect.y*100+"%",i.style["backdrop-filter"]=`blur(${e.blur||2}px)`,i.style.backgroundColor=e.blurBackground,t.appendChild(i);const s=document.createElement("div");s.style.position="absolute",s.style.right="0px",s.style.top="0px",s.style.width=(1-e.operationalRect.x-e.operationalRect.width)*100+"%",s.style.height="100%",s.style["backdrop-filter"]=`blur(${e.blur||2}px)`,s.style.backgroundColor=e.blurBackground,t.appendChild(s);const n=document.createElement("div");n.style.position="absolute",n.style.left=e.operationalRect.x*100+"%",n.style.bottom="0px",n.style.width=e.operationalRect.width*100+"%",n.style.height=(1-e.operationalRect.y-e.operationalRect.height)*100+"%",n.style["backdrop-filter"]=`blur(${e.blur||2}px)`,n.style.backgroundColor=e.blurBackground,t.appendChild(n);const r=document.createElement("div");r.style.position="absolute",r.style.left="0px",r.style.top="0px",r.style.width=e.operationalRect.x*100+"%",r.style.height="100%",r.style["backdrop-filter"]=`blur(${e.blur||2}px)`,r.style.backgroundColor=e.blurBackground,t.appendChild(r);let a=()=>{lg(e)};i.onmouseenter=a,n.onmouseenter=a,s.onmouseenter=a,r.onmouseenter=a,t.onmouseleave=a}function lg(e){if(!(!e.calculative.canvas.store.data.locked&&!e.locked)&&e.calculative.zIndex<5){let t=e.calculative.singleton.div.parentNode.children;for(let i=1;i<6;i++)t[i].style.pointerEvents="initial"}}function E2(e){if(e.thumbImg&&!e.calculative.img){const t=new Image;t.crossOrigin=e.crossOrigin==="undefined"?void 0:e.crossOrigin||"anonymous",e.calculative.canvas.store.options.cdn&&!(e.thumbImg.startsWith("http")||e.thumbImg.startsWith("//")||e.thumbImg.startsWith("data:image"))?t.src=e.calculative.canvas.store.options.cdn+e.thumbImg:t.src=e.thumbImg,t.onerror=i=>{t.remove(),e.calculative.img=void 0},e.calculative.img=t}}const We={},Pa=['<svg viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg"><path d="M473.088 125.44L256 256H52.224C23.552 256 0 279.552 0 308.224V716.8c0 28.16 23.04 51.2 51.2 51.2h204.8l217.088 130.56c16.896 10.24 38.912-2.048 38.912-22.016V147.456c0-19.968-21.504-32.256-38.912-22.016zM699.904 320.512c-20.992-18.944-53.248-17.408-72.192 3.584-18.944 20.992-17.408 53.248 3.584 72.192 0.512 0.512 58.368 54.784 58.368 121.344 0 37.888-19.456 74.752-58.368 110.08-20.992 18.944-22.528 51.2-3.584 72.192 10.24 11.264 24.064 16.896 37.888 16.896 12.288 0 24.576-4.608 34.304-13.312 61.44-55.296 92.16-117.76 92.16-185.856 0-112.64-88.576-193.536-92.16-197.12z" fill="" p-id="2434"></path><path d="M853.504 166.4c-20.992-18.944-53.248-16.896-72.192 4.096-18.944 20.992-16.896 53.248 4.096 72.192 1.536 1.024 135.68 122.88 135.68 280.576 0 90.624-45.568 177.152-135.68 257.536-20.992 18.944-23.04 51.2-4.096 72.192 10.24 11.264 24.064 16.896 38.4 16.896 12.288 0 24.576-4.096 34.304-12.8 112.64-100.864 169.984-212.992 169.984-333.824-1.024-202.752-163.84-350.208-170.496-356.864z"></path></svg>','<svg viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" ><path d="M256 768H51.2c-28.16 0-51.2-23.04-51.2-51.2V308.224C0 279.552 23.552 256 52.224 256H256v512zM512 147.456v728.576c0 19.968-21.504 32.256-38.912 22.016L256 768V256l217.088-130.56c17.408-10.24 38.912 2.048 38.912 22.016zM623.104 656.896c-19.968-19.968-19.968-52.224 0-72.192l217.088-217.088c19.968-19.968 52.224-19.968 72.192 0 19.968 19.968 19.968 52.224 0 72.192l-217.088 217.088c-19.456 19.968-52.224 19.968-72.192 0z" fill="" p-id="2582"></path><path d="M623.104 367.104c19.968-19.968 52.224-19.968 72.192 0l217.088 217.088c19.968 19.968 19.968 52.224 0 72.192-19.968 19.968-52.224 19.968-72.192 0l-217.088-217.088c-19.968-19.456-19.968-52.224 0-72.192z"></path></svg>'];function A2(e){var t;if(e.onDestroy||(e.onDestroy=C2,e.onMove=Rl,e.onResize=Rl,e.onRotate=Rl,e.onClick=Rf,e.onValue=R2,e.onChangeId=T2),We[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{const i=document.createElement("div"),s=document.createElement("div");s.style.position="absolute",s.style.outline="none",s.style.left="0",s.style.bottom="0",s.style.width="0",s.style.height="2px",s.style.background="#52c41a",s.style.zIndex="1",e.hideProgress&&(s.style.display="none");const n=document.createElement("div");n.innerHTML=Pa[1],n.style.position="absolute",n.style.right="0",n.style.bottom="0",n.style.width="20px",n.style.height="20px",n.style.fill="hsla(0, 0%, 100%, .8)",n.style.zIndex="1",n.style.display="none",i.appendChild(s),i.appendChild(n),n.onclick=a=>{a.stopPropagation(),e.calculative.media.muted?(n.innerHTML=Pa[0],e.calculative.media.muted=!1):(n.innerHTML=Pa[1],e.calculative.media.muted=!0)},e.calculative.singleton||(e.calculative.singleton={}),e.calculative.singleton.muted=n,i.onmouseenter=a=>{n.style.display="block"},i.onmouseleave=a=>{n.style.display="none"},i.onclick=a=>{a.stopPropagation(),Rf(e)};let r;e.video?(r=document.createElement("video"),r.src=e.video):e.audio&&(r=document.createElement("audio"),r.controls=e.controls,r.src=e.audio),r.loop=e.playLoop,r.ontimeupdate=()=>{cg(s,r,e.calculative.worldRect.width)},r.onended=()=>{e.calculative.onended&&e.calculative.onended(e)},e.calculative.media=r,r.style.position="absolute",r.style.outline="none",r.style.left="0",r.style.top="0",r.style.width="100%",r.style.height="100%",i.appendChild(r),We[e.id]=i,(t=e.calculative.canvas.externalElements)==null||t.parentElement.appendChild(i),Te(e,i),e.autoPlay&&(r.autoplay=!0,r.muted=!0)}return e.calculative.patchFlags&&Te(e,We[e.id]),new Path2D}function C2(e){We[e.id].onclick=null,We[e.id].remove(),We[e.id]=void 0}function Rl(e){Te(e,We[e.id]);const t=We[e.id].children[0],i=We[e.id].children[1];cg(t,i,e.calculative.worldRect.width)}function Rf(e){e.calculative.media&&(e.calculative.media.muted=!1,e.calculative.singleton.muted.innerHTML=Pa[0],e.calculative.media.paused?e.calculative.media.play():e.calculative.media.pause())}function cg(e,t,i){e.style.width=t.currentTime/t.duration*i+"px"}function T2(e,t,i){!We[t]||(We[i]=We[t],delete We[t])}function R2(e){const t=We[e.id];if(!t)return;Te(e,t);const 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}function Pi(){try{const e=new OffscreenCanvas(0,0),t=e.getContext("2d");return t&&t.arc?e:document.createElement("canvas")}catch{return document.createElement("canvas")}}class ar{constructor(t,i){U(this,"parentElement");U(this,"store");U(this,"box");U(this,"text");U(this,"arrowUp");U(this,"arrowDown");U(this,"x");U(this,"y");U(this,"currentPen");this.parentElement=t,this.store=i,this.box=document.createElement("div"),this.text=document.createElement("div"),this.arrowUp=document.createElement("div"),this.arrowDown=document.createElement("div"),this.box.className="meta2d-tooltip",this.text.className="text",this.arrowUp.className="arrow",this.arrowDown.className="arrow down",this.box.appendChild(this.text),this.box.appendChild(this.arrowUp),this.box.appendChild(this.arrowDown),t.appendChild(this.box),this.box.onmouseleave=()=>{this.hide(),this.store.lastHover=void 0};let s;for(let n=0;n<document.styleSheets.length;n++)document.styleSheets[n].title==="le5le.com/tooltip"&&(s=document.styleSheets[n]);if(!s){let n=document.createElement("style");n.type="text/css",n.title="le5le.com/tooltip",document.head.appendChild(n),n=document.createElement("style"),n.type="text/css",document.head.appendChild(n),s=n.sheet,s.insertRule(".meta2d-tooltip{position:absolute;padding:8px 0;z-index:10;left: -9999px;top: -9999px;}"),s.insertRule(".meta2d-tooltip .text{max-width:320px;min-height:30px;max-height:400px;outline:none;padding:8px 16px;border-radius:4px;background:#777777;color:#ffffff;line-height:1.8;overflow-y:auto;}"),s.insertRule(".meta2d-tooltip .arrow{position:absolute;border:10px solid transparent;background:transparent;top:-5px;left:50%;transform:translateX(-50%)}"),s.insertRule(".meta2d-tooltip .arrow.down{top:initial;bottom: -1px;}")}}static getTitle(t){if(t.titleFnJs&&!t.titleFn)try{t.titleFn=new Function("pen",t.titleFnJs)}catch(i){console.log("titleFnJs",i)}return t.titleFn?t.titleFn(t):String(t.title)}setText(t){const i=this.box.getBoundingClientRect();let s=globalThis.marked;const n=ar.getTitle(t);if(s){this.text.innerHTML=s(n);const r=this.text.getElementsByTagName("A");for(let a=0;a<r.length;++a)r[a].setAttribute("target","_blank")}else this.text.innerHTML=n;return i}updateText(t){var n;if(((n=this.currentPen)==null?void 0:n.id)!==t.id||ar.titleEmpty(t))return;const i=this.setText(t),s=this.box.getBoundingClientRect();this.changePositionByText(i,s)}changePositionByText(t,i){this.x-=(i.width-t.width)/2,this.y-=i.height-t.height,this.box.style.left=this.x+"px",this.box.style.top=this.y+"px"}static titleEmpty(t){return!t.title&&!t.titleFn&&!t.titleFnJs}show(t,i){if(this.currentPen=t,ar.titleEmpty(t)){let o=Ge(t,!0);o&&this.show(o,i);return}this.setText(t);const s=this.box.getBoundingClientRect(),n=t.calculative.worldRect;let r=t.calculative.canvas.store.data.x+i.x-s.width/2,a=t.calculative.canvas.store.data.y+i.y-s.height;t.type||(r=t.calculative.canvas.store.data.x+n.x-(s.width-n.width)/2,a=t.calculative.canvas.store.data.y+n.ey-s.height-n.height),a>0?(this.arrowUp.style.borderBottomColor="transparent",this.arrowDown.style.borderTopColor="#777777"):(a+=s.height+n.height+5,this.arrowUp.style.borderBottomColor="#777777",this.arrowDown.style.borderTopColor="transparent"),this.x=r,this.y=a,this.box.style.left=this.x+"px",this.box.style.top=this.y+"px"}hide(){this.currentPen=null,this.x=-9999,this.box.style.left="-9999px"}translate(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")}destroy(){this.box.onmouseleave=null}}class hg{constructor(t){U(this,"parent");U(this,"h");U(this,"v");U(this,"isDownH");U(this,"isDownV");U(this,"x");U(this,"y");U(this,"hSize");U(this,"vSize");U(this,"scrollX");U(this,"scrollY");U(this,"lastScrollX");U(this,"lastScrollY");U(this,"rect");U(this,"isShow");U(this,"pageMode");U(this,"onMouseDownH",t=>{t.preventDefault(),t.stopPropagation(),this.isDownH=t.x,this.x=this.parent.store.data.x||0,this.lastScrollX=this.scrollX});U(this,"onMouseDownV",t=>{t.preventDefault(),t.stopPropagation(),this.isDownV=t.y,this.y=this.parent.store.data.y||0,this.lastScrollY=this.scrollY});U(this,"onMouseMove",t=>{if(this.isDownH){const i=t.x-this.isDownH;this.scrollX=this.lastScrollX+i,this.h.style.left=`${this.scrollX}px`,this.parent.store.data.x=this.x-i*this.rect.width/this.parent.parentElement.clientWidth}if(this.isDownV){const i=t.y-this.isDownV;if(this.pageMode&&this.canMouseMove(i))return;this.scrollY=this.lastScrollY+i,this.v.style.top=`${this.scrollY}px`,this.parent.store.data.y=this.y-i*this.rect.height/this.parent.parentElement.clientHeight}(this.isDownH||this.isDownV)&&(this.parent.onMovePens(),this.parent.canvasTemplate.init(),this.parent.canvasImage.init(),this.parent.canvasImageBottom.init(),this.parent.render())});U(this,"onMouseUp",t=>{!this.isDownH&&!this.isDownV||(this.isDownH=void 0,this.isDownV=void 0,this.scrollX<20?(this.scrollX=20,this.h.style.left=`${this.scrollX}px`):this.scrollX>this.parent.parentElement.clientWidth-this.hSize-20&&(this.scrollX=this.parent.parentElement.clientWidth-this.hSize-20,this.h.style.left=`${this.scrollX}px`),this.scrollY<20?(this.scrollY=20,this.v.style.top=`${this.scrollY}px`):this.scrollY>this.parent.parentElement.clientHeight-this.vSize-20&&(this.scrollY=this.parent.parentElement.clientHeight-this.vSize-20,this.v.style.top=`${this.scrollY}px`),this.resize())});this.parent=t,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);let i;for(let s=0;s<document.styleSheets.length;s++)document.styleSheets[s].title==="le5le/scroll"&&(i=document.styleSheets[s]);if(!i){let s=document.createElement("style");s.type="text/css",s.title="le5le.com/scroll",document.head.appendChild(s),s=document.createElement("style"),s.type="text/css",document.head.appendChild(s),i=s.sheet,i.insertRule(".meta2d-scroll{position:absolute;width:8px;height:200px;background:#dddddd;border-radius:10px;z-index:20;cursor:default;}"),i.insertRule(".meta2d-scroll:hover{background:#cccccc;cursor:pointer}"),i.insertRule(".meta2d-scroll.v{right:0;top:calc(50% - 100px);}"),i.insertRule(".meta2d-scroll.h{bottom:2px;left:calc(50% - 100px);width:200px;height:8px;}")}this.init()}init(){this.isShow=!0,this.resize(),this.initPos()}canMouseMove(t){const i=this.parent.parent.getRect();return t<0&&i.y+this.parent.store.data.y>=0||t>0&&i.ey-this.parent.height+this.parent.store.data.y<=0}changeMode(){this.pageMode=!0,this.h.style.display="none",this.parent.parent.getRect().height<this.parent.height&&(this.v.style.display="none")}initPos(){this.scrollX=(this.parent.parentElement.clientWidth-this.hSize)/2,this.scrollY=(this.parent.parentElement.clientHeight-this.vSize)/2,this.h.style.left=`${this.scrollX}px`,this.v.style.top=`${this.scrollY}px`}resize(){this.rect=pi(this.parent.store.data.pens),this.rect.width<1400&&(this.rect.width=1400),this.rect.height<900&&(this.rect.height=900),this.parent.store.data.x>0?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"}show(){this.isShow=!0,this.h.style.display="block",this.v.style.display="block",document.addEventListener("mousemove",this.onMouseMove),document.addEventListener("mouseup",this.onMouseUp)}hide(){this.isShow=!1,this.h.style.display="none",this.v.style.display="none",this.destroy()}translate(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`)}wheel(t){let 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())}destroy(){document.removeEventListener("mousemove",this.onMouseMove),document.removeEventListener("mouseup",this.onMouseUp)}}class Sf{constructor(t,i,s){U(this,"parentElement");U(this,"store");U(this,"isBottom");U(this,"canvas",document.createElement("canvas"));U(this,"otherOffsreen",Pi());U(this,"offscreen",Pi());U(this,"animateOffsScreen",Pi());U(this,"fitOffscreen",Pi());U(this,"fitFlag",!1);U(this,"currentFit");U(this,"activeFit");this.parentElement=t,this.store=i,this.isBottom=s,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"}resize(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.fitOffscreen.width=t,this.fitOffscreen.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.fitOffscreen.getContext("2d").scale(this.store.dpiRatio,this.store.dpiRatio),this.fitOffscreen.getContext("2d").textBaseline="middle",this.init()}init(){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.fitOffscreen.getContext("2d").clearRect(0,0,this.canvas.width,this.canvas.height);for(const t of this.store.data.pens)this.hasImage(t)&&(t.calculative.imageDrawed=!1);this.isBottom?this.store.patchFlagsBackground=!0:this.store.patchFlagsTop=!0}clear(){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.fitOffscreen.getContext("2d").clearRect(0,0,this.canvas.width,this.canvas.height),this.canvas.getContext("2d").clearRect(0,0,this.canvas.width,this.canvas.height)}hasImage(t){return t.calculative.hasImage=t.calculative&&t.calculative.inView&&(this.isBottom&&t.canvasLayer===zt.CanvasImageBottom||!this.isBottom&&t.canvasLayer===zt.CanvasImage)&&t.image&&t.calculative.img&&t.name!=="gif",t.calculative.hasImage}render(){var a;let t=!1,i=!1;for(const o of this.store.data.pens)this.hasImage(o)&&(this.store.animates.has(o)?i=!0:o.calculative.imageDrawed||(t=!0),o.parentId&&this.store.animates.has(Ge(o,!0))&&(i=!0));const s=this.store.patchFlagsBackground,n=this.store.patchFlagsTop;if(n&&!this.isBottom){const o=this.otherOffsreen.getContext("2d");o.clearRect(0,0,this.canvas.width,this.canvas.height),this.renderRule(o)}if(this.store.patchFlagsLast&&this.offscreen.getContext("2d").clearRect(0,0,this.canvas.width,this.canvas.height),t){const o=this.offscreen.getContext("2d");o.save(),o.clearRect(0,0,this.canvas.width,this.canvas.height),o.translate(this.store.data.x,this.store.data.y);for(const l of this.store.data.pens)!l.calculative.hasImage||this.store.animates.has(l)||this.store.animates.has(Ge(l,!0))||l.canvasLayer!==zt.CanvasTemplate&&(l.name==="combine"&&!l.draw||(l.calculative.imageDrawed=!0,o.save(),zs(o,l),l.calculative.rotate&&Gi(o,l),Hs(o,l),kn(o,l),o.restore()));o.restore()}if(i){const o=this.animateOffsScreen.getContext("2d");o.save(),o.clearRect(0,0,this.canvas.width,this.canvas.height),o.translate(this.store.data.x,this.store.data.y);for(const l of this.store.animates)!l.calculative.hasImage||l.canvasLayer!==zt.CanvasTemplate&&(l.visible===!1||l.calculative.visible===!1||(l.calculative.imageDrawed=!0,o.save(),zs(o,l),l.calculative.rotate&&Gi(o,l),Hs(o,l),kn(o,l),o.restore()));for(const l of this.store.data.pens)!l.calculative.hasImage||!l.parentId||l.canvasLayer!==zt.CanvasTemplate&&(l.visible===!1||l.calculative.visible===!1||this.store.animates.has(Ge(l,!0))&&(l.calculative.imageDrawed=!0,o.save(),zs(o,l),l.calculative.rotate&&Gi(o,l),Hs(o,l),kn(o,l),o.restore()));o.restore()}if(!this.isBottom&&!this.store.data.locked&&this.fitFlag){const o=(this.store.data.width||this.store.options.width)*this.store.data.scale,l=(this.store.data.height||this.store.options.height)*this.store.data.scale,u=this.store.data.origin.x+this.store.data.x||this.store.options.x||0,h=this.store.data.origin.y+this.store.data.y||this.store.options.y||0,f=this.fitOffscreen.getContext("2d");f.save(),f.clearRect(0,0,this.canvas.width,this.canvas.height),f.fillStyle="#ffffff66",f.strokeStyle=this.store.styles.activeColor,(a=this.store.data.fits)==null||a.forEach((g,v)=>{f.fillRect(u+o*g.x,h+l*g.y,o*g.width,l*g.height),g.active&&f.strokeRect(u+o*g.x,h+l*g.y,o*g.width,l*g.height)}),f.restore()}if(t||i||s&&this.isBottom||n&&!this.isBottom){const o=this.canvas.getContext("2d");o.clearRect(0,0,this.canvas.width,this.canvas.height),this.isBottom&&(this.store.patchFlagsBackground=!1),o.drawImage(this.offscreen,0,0,this.canvas.width,this.canvas.height),o.drawImage(this.animateOffsScreen,0,0,this.canvas.width,this.canvas.height),this.isBottom||(o.drawImage(this.otherOffsreen,0,0,this.canvas.width,this.canvas.height),this.store.patchFlagsTop=!1,!this.store.data.locked&&this.fitFlag&&o.drawImage(this.fitOffscreen,0,0,this.canvas.width,this.canvas.height))}}renderRule(t){var x,C,S,D,B,L,V,tt;const{data:i,options:s}=this.store,{rule:n,ruleColor:r,scale:a,origin:o}=i;if(!(n!=null?n:s.rule))return;const l=a*10;t.save();const u=r||s.ruleColor||"#ccc";t.strokeStyle=Fa(u,.7);const h=o.x+i.x,f=o.y+i.y,{width:g,height:v}=this.canvas;let y=((x=s.ruleOptions)==null?void 0:x.height)||20;(C=s.ruleOptions)!=null&&C.background&&(t.beginPath(),t.fillStyle=(S=s.ruleOptions)==null?void 0:S.background,t.rect(0,0,g,y),t.fill(),t.rect(0,0,y,v),t.fill()),(D=s.ruleOptions)!=null&&D.underline&&(t.beginPath(),t.fillStyle=Fa(u,.7),t.moveTo(0,y),t.lineTo(g,y),t.stroke(),t.moveTo(y,0),t.lineTo(y,v),t.stroke());let w=y/4;((B=s.ruleOptions)==null?void 0:B.baseline)==="bottom"&&(w=y*3/4),t.beginPath(),t.lineWidth=y/2,t.lineDashOffset=-h%l,t.setLineDash([1,l-1]),t.moveTo(0,w),t.lineTo(g,w),t.stroke(),t.beginPath(),t.lineDashOffset=-f%l,t.moveTo(w,0),t.lineTo(w,v),t.stroke(),t.strokeStyle=u,t.beginPath(),t.lineWidth=y,t.lineDashOffset=-h%(l*10),t.setLineDash([1,l*10-1]),t.moveTo(0,y/2),t.lineTo(g,y/2),t.stroke(),t.beginPath(),t.lineDashOffset=-f%(l*10),t.moveTo(y/2,0),t.lineTo(y/2,v),t.stroke(),t.beginPath(),t.fillStyle=((L=s.ruleOptions)==null?void 0:L.textColor)||t.strokeStyle;let p=0-Math.floor(h/l/10)*100,_=((V=s.ruleOptions)==null?void 0:V.textTop)||16,E=((tt=s.ruleOptions)==null?void 0:tt.textLeft)||4;h<0&&(p-=100);for(let T=h%(l*10);T<g;T+=10*l,p+=100)l<3&&p%500||t.fillText(p.toString(),T+E,_);p=0-Math.floor(f/l/10)*100,f<0&&(p-=100);for(let T=f%(l*10);T<v;T+=10*l,p+=100)l<3&&p%500||(t.save(),t.beginPath(),t.translate(_,T-E),t.rotate(270*Math.PI/180),t.fillText(p.toString(),0,0),t.restore());t.restore()}}class S2{constructor(t,i,s){U(this,"parentCanvas");U(this,"parentElement");U(this,"store");U(this,"canvas",document.createElement("canvas"));U(this,"magnifierScreen",Pi());U(this,"offscreen",Pi());U(this,"domOffscreen",Pi());U(this,"magnifierSize",300);U(this,"magnifier");this.parentCanvas=t,this.parentElement=i,this.store=s,i.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",this.canvas.style.pointerEvents="none"}resize(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.offscreen.width=t,this.offscreen.height=i,this.offscreen.getContext("2d").scale(this.store.dpiRatio,this.store.dpiRatio),this.offscreen.getContext("2d").textBaseline="middle",this.domOffscreen.width=t,this.domOffscreen.height=i,this.domOffscreen.getContext("2d").scale(this.store.dpiRatio,this.store.dpiRatio),this.domOffscreen.getContext("2d").textBaseline="middle",this.magnifierScreen.width=this.magnifierSize+5,this.magnifierScreen.height=this.magnifierSize+5}renderMagnifier(){if(!this.magnifier)return;const t=this.magnifierSize/2,i=this.magnifierSize+5,s=this.magnifierScreen.getContext("2d");s.clearRect(0,0,i,i),s.lineWidth=5,s.save(),s.translate(2.5,2.5),s.save(),s.arc(t,t,t,0,Math.PI*2,!1),s.clip(),s.translate(-t,-t),s.scale(2,2);const n={x:(this.parentCanvas.mousePos.x+this.store.data.x)*this.store.dpiRatio,y:(this.parentCanvas.mousePos.y+this.store.data.y)*this.store.dpiRatio};[this.parentCanvas.canvasTemplate.bgOffscreen,this.parentCanvas.canvasTemplate.offscreen,this.parentCanvas.canvasImageBottom.offscreen,this.parentCanvas.canvasImageBottom.animateOffsScreen,this.parentCanvas.offscreen,this.parentCanvas.canvasImage.offscreen,this.parentCanvas.canvasImage.animateOffsScreen,this.domOffscreen].forEach(l=>{s.drawImage(l,n.x-t,n.y-t,this.magnifierSize,this.magnifierSize,0,0,this.magnifierSize,this.magnifierSize)}),s.restore(),s.beginPath();const a=s.createRadialGradient(t,t,t-5,t,t,t);a.addColorStop(0,"rgba(0,0,0,0.2)"),a.addColorStop(.8,"rgb(200,200,200)"),a.addColorStop(.9,"rgb(200,200,200)"),a.addColorStop(1,"rgba(200,200,200,0.9)"),s.strokeStyle=a,s.arc(t,t,t,0,Math.PI*2,!1),s.stroke(),s.restore(),this.offscreen.getContext("2d").drawImage(this.magnifierScreen,0,0,this.magnifierSize+5,this.magnifierSize+5,(n.x-t-2.5)/this.store.dpiRatio,(n.y-t-2.5)/this.store.dpiRatio,(this.magnifierSize+5)/this.store.dpiRatio,(this.magnifierSize+5)/this.store.dpiRatio)}updateDomOffscreen(){const t=this.domOffscreen.getContext("2d");t.clearRect(0,0,this.domOffscreen.width,this.domOffscreen.height);for(const i of this.store.data.pens)if((i.externElement||i.name==="gif")&&i.calculative.img){t.save(),t.translate(this.store.data.x,this.store.data.y);const{x:s,y:n,width:r,height:a}=i.calculative.worldRect;t.drawImage(i.calculative.img,s,n,r,a),t.restore()}}render(){this.offscreen.getContext("2d").clearRect(0,0,this.canvas.width,this.canvas.height),this.renderMagnifier();const t=this.canvas.getContext("2d");t.clearRect(0,0,this.canvas.width,this.canvas.height),t.drawImage(this.offscreen,0,0,this.canvas.width,this.canvas.height)}}function ug(e){if(e.data.locked)throw new Error("canvas is locked")}class P2{constructor(t,i){U(this,"parentElement");U(this,"box");U(this,"iframe");U(this,"dialog");U(this,"close");U(this,"title");U(this,"body");U(this,"x");U(this,"y");U(this,"url");U(this,"meta2dDiv");U(this,"dialogMeta2d");U(this,"store");this.parentElement=t,this.store=i,this.box=document.createElement("div"),this.dialog=document.createElement("div");let s=document.createElement("div");this.title=document.createElement("div"),this.close=document.createElement("span"),this.close.innerHTML=`
- <svg fill="none" viewBox="0 0 16 16" width="1em" height="1em">
- <path
- fill="currentColor"
- d="M8 8.92L11.08 12l.92-.92L8.92 8 12 4.92 11.08 4 8 7.08 4.92 4 4 4.92 7.08 8 4 11.08l.92.92L8 8.92z"
- fill-opacity="0.9"
- ></path>
- </svg>`,this.body=document.createElement("div"),this.iframe=document.createElement("iframe"),this.iframe.setAttribute("frameborder","0"),this.meta2dDiv=document.createElement("div"),this.box.className="meta2d-dialog_mask",this.dialog.className="meta2d-dialog",this.body.className="meta2d-dialog_body",s.className="meta2d-dialog_header",this.title.className="meta2d-dialog-content",this.close.className="meta2d-dialog-close",this.meta2dDiv.className="meta2d-dialog-meta2d",s.appendChild(this.title),s.appendChild(this.close),this.body.appendChild(this.iframe),this.body.appendChild(this.meta2dDiv),this.dialog.appendChild(s),this.dialog.appendChild(this.body),this.box.appendChild(this.dialog),t.appendChild(this.box),this.dialog.onclick=r=>{r.stopPropagation()},this.box.onclick=()=>{this.hide()},this.close.onclick=()=>{this.hide()};let n;for(let r=0;r<document.styleSheets.length;r++)document.styleSheets[r].title==="le5le.com/dialog"&&(n=document.styleSheets[r]);if(!n){let r=document.createElement("style");r.type="text/css",r.title="le5le.com/dialog",document.head.appendChild(r),r=document.createElement("style"),r.type="text/css",document.head.appendChild(r),n=r.sheet,n.insertRule(`.meta2d-dialog_mask {
- display: none;
- position: absolute;
- top: 0%;
- left: 0%;
- width: 100%;
- height: 100%;
- background-color: #0000006f;
- z-index: 9999;`),n.insertRule(`.meta2d-dialog_mask .meta2d-dialog {
- position: absolute;
- top: 15vh;
- left: 10%;
- width: 80%;
- height:420px;
- padding: 16px 20px;
- border-radius: 9px;
- background-color: #1e2430;
- z-index: 19999;
- overflow: auto;
- }`),n.insertRule(`.meta2d-dialog_header {
- display: flex;
- position: relative;
- z-index: 999;
- }`),n.insertRule(`.meta2d-dialog-content {
- width: calc(100% - 20px);
- font-weight: 600;
- font-size: 14px;
- color: #bdc7db;
- padding-bottom:8px;
- }`),n.insertRule(`.meta2d-dialog-close {
- width: 20px;
- height: 20px;
- line-height: 20px;
- text-align: center;
- color: #617b91;
- position: absolute;
- right:20px;
- top:2px;
- }`),n.insertRule(`.meta2d-dialog-close svg{
- width: 18px;
- height: 18px;
- }`),n.insertRule(`.meta2d-dialog-close :hover{
- cursor: pointer;
- }`),n.insertRule(`.meta2d-dialog_body{
- width: 100%;
- height: 100%;
- } `),n.insertRule(`.meta2d-dialog_body iframe{
- width: 100%;
- height: 100%;
- }`),n.insertRule(`.meta2d-dialog_body .meta2d-dialog-meta2d{
- width: 100%;
- height: 100%;
- display: none;
- }`)}}async show(t,i,s,n){if(!i)return;const r=this.isUrl(i);if(r?(this.meta2dDiv.style.display="none",this.iframe.style.display="block"):(this.iframe.style.display="none",this.meta2dDiv.style.display="block"),r&&i!==this.url&&(this.iframe.setAttribute("src",i),this.url=i),t&&(this.title.innerText=t),t?(this.dialog.style.padding="16px 20px",this.title.style.display="block",this.body.style.height="calc(100% - 26px)",this.close.style.top="2px",this.close.style.right="2px"):(this.dialog.style.padding="0px",this.title.style.display="none",this.body.style.height="100%",this.body.style.overflow="hidden",this.close.style.top="18px",this.close.style.right="20px"),s&&(this.dialog.style.width=s.width?s.width+"px":"80%",this.dialog.style.height=s.height?s.height+"px":"420px",this.dialog.style.top=s.y?s.y+"px":s.height?`calc( 50% - ${s.height/2}px )`:"15vh",this.dialog.style.left=s.x?s.x+"px":`calc( 50% - ${s.width?s.width/2+"px":"40%"} )`),r&&n){let a=0;const o=setInterval(()=>{this.iframe.contentWindow.meta2d&&(clearInterval(o),setTimeout(()=>{this.iframe.contentWindow.postMessage(JSON.stringify({name:"dialog",data:n}),"*")},100)),a++,a>50&&clearInterval(o)},300)}if((!this.dialogMeta2d||r)&&(this.box.style.display="block"),!r){this.meta2dDiv.style.display="block",this.dialogMeta2d||(globalThis.mainMeta2d=globalThis.meta2d,this.dialogMeta2d=new lk(this.meta2dDiv),globalThis.meta2d=globalThis.mainMeta2d);const a=await Bd(this.store,i);a&&(this.box.style.display="block",this.dialogMeta2d.clear(!0),this.dialogMeta2d.open(a,!1),this.dialogMeta2d.lock(1),this.dialogMeta2d.resize(),this.dialogMeta2d.fitView(!0,0),this.dialogMeta2d.render(!0))}}hide(){this.box.style.display="none"}isUrl(t){return!!(t.startsWith("http")||t.includes("?")||t.includes("/"))}destroy(){var t;this.dialog.onclick=void 0,this.box.onclick=void 0,this.close.onclick=void 0,(t=this.dialogMeta2d)==null||t.destroy(!0)}}class ja{constructor(t){U(this,"parentElement");U(this,"box");U(this,"currentAnchor");this.parentElement=t,this.box=document.createElement("div"),this.box.className="meta2d-title",t.appendChild(this.box);let i;for(let s=0;s<document.styleSheets.length;s++)document.styleSheets[s].title==="le5le.com/title"&&(i=document.styleSheets[s]);if(!i){let s=document.createElement("style");s.type="text/css",s.title="le5le.com/title",document.head.appendChild(s),s=document.createElement("style"),s.type="text/css",document.head.appendChild(s),i=s.sheet,i.insertRule(".meta2d-title{position:absolute;padding:0;z-index:10;left: -9999px;top: -9999px;background:#fff;color:#000; cursor: crosshair;border: 1px solid black;}")}}static getTitle(t){}setText(t){this.box.innerText=t.title}updateText(t){var i;((i=this.currentAnchor)==null?void 0:i.id)===t.id&&(ja.titleEmpty(t)||(this.setText(t),this.changePositionByAnchor(t)))}changePositionByAnchor(t){this.box.style.left=t.x+10+"px",this.box.style.top=t.y+10+"px"}static titleEmpty(t){return!t.title}show(t,i){if(ja.titleEmpty(t))return;this.currentAnchor=t,this.setText(t);let s={x:i.calculative.canvas.store.data.x+t.x,y:i.calculative.canvas.store.data.y+t.y};this.changePositionByAnchor(s)}hide(){this.box.style.left="-9999px",this.box.innerText="",this.currentAnchor=null}destroy(){this.box.onmouseleave=null}}class I2{constructor(t,i){U(this,"parentElement");U(this,"store");U(this,"canvas",document.createElement("canvas"));U(this,"offscreen",Pi());U(this,"bgOffscreen",Pi());U(this,"patchFlags");U(this,"bgPatchFlags");U(this,"fit");this.parentElement=t,this.store=i,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"}resize(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()}init(){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}hidden(){this.canvas.style.display="none"}show(){this.canvas.style.display="block"}clear(){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}render(){var t;if(this.bgPatchFlags){const i=this.bgOffscreen.getContext("2d");i.clearRect(0,0,this.canvas.width,this.canvas.height);const s=this.store.data.width||this.store.options.width,n=this.store.data.height||this.store.options.height,r=this.store.data.x||this.store.options.x||0,a=this.store.data.y||this.store.options.y||0,o=this.store.data.background||this.store.styles.background;o&&(i.save(),i.fillStyle=o,i.globalAlpha=(t=this.store.data.globalAlpha)!=null?t:this.store.options.globalAlpha,s&&n&&!this.fit?(i.shadowOffsetX=this.store.options.shadowOffsetX,i.shadowOffsetY=this.store.options.shadowOffsetY,i.shadowBlur=this.store.options.shadowBlur,i.shadowColor=this.store.options.shadowColor,i.fillRect(this.store.data.origin.x+r,this.store.data.origin.y+a,s*this.store.data.scale,n*this.store.data.scale)):i.fillRect(0,0,this.canvas.width,this.canvas.height),i.restore()),s&&n&&this.store.bkImg&&(i.save(),this.fit?i.drawImage(this.store.bkImg,0,0,this.canvas.offsetWidth,this.canvas.offsetHeight):i.drawImage(this.store.bkImg,this.store.data.origin.x+r,this.store.data.origin.y+a,s*this.store.data.scale,n*this.store.data.scale),i.restore()),this.renderGrid(i)}if(this.patchFlags){const i=this.offscreen.getContext("2d");i.save(),i.clearRect(0,0,this.canvas.width,this.canvas.height),i.translate(this.store.data.x,this.store.data.y);for(const s of this.store.data.pens)if(!!isFinite(s.x)&&s.canvasLayer===zt.CanvasTemplate&&s.calculative.inView){if(s.name==="combine"&&!s.draw)continue;Is(i,s),s.image&&s.name!=="gif"&&s.calculative.img&&(i.save(),zs(i,s),s.calculative.rotate&&Gi(i,s),Hs(i,s),kn(i,s),i.restore())}i.restore()}if(this.patchFlags||this.bgPatchFlags){const i=this.canvas.getContext("2d");i.clearRect(0,0,this.canvas.width,this.canvas.height),i.drawImage(this.bgOffscreen,0,0,this.canvas.width,this.canvas.height),i.drawImage(this.offscreen,0,0,this.canvas.width,this.canvas.height),this.patchFlags=!1,this.bgPatchFlags=!1}}renderGrid(t){const{data:i,options:s}=this.store,{grid:n,gridRotate:r,gridColor:a,gridSize:o,scale:l,origin:u}=i;if(!(n!=null?n:s.grid))return;t.save();const h=(i.width||s.width)*l,f=(i.height||s.height)*l,g=(i.x||s.x||0)+u.x,v=(i.y||s.y||0)+u.y;r&&(t.translate(h/2,f/2),t.rotate(r*Math.PI/180),t.translate(-h/2,-f/2)),t.lineWidth=1,t.strokeStyle=a||s.gridColor,t.beginPath();let y=(o||s.gridSize)*l;if(y=y<0?0:y,!h||!f){const w=this.store.dpiRatio,p=this.canvas.width/w,_=this.canvas.height/w,E=g/y,x=v/y,C=y*10,S=g-Math.ceil(E)*y,D=v-Math.ceil(x)*y,B=p+S+C,L=_+D+C;for(let V=S;V<=B;V+=y)t.moveTo(V,D),t.lineTo(V,_+D+C);for(let V=D;V<=L;V+=y)t.moveTo(S,V),t.lineTo(p+S+C,V)}else{const w=h+g,p=f+v;for(let _=g;_<=w;_+=y)t.moveTo(_,v),t.lineTo(_,f+v);for(let _=v;_<=p;_+=y)t.moveTo(g,_),t.lineTo(h+g,_)}t.stroke(),t.restore()}}const L2={success:{},info:{icon:'<svg fill="none" viewBox="0 0 24 24"><path fill="#0052d9" d="M12 23a11 11 0 100-22 11 11 0 000 22zM11 8.5v-2h2v2h-2zm2 1.5v7.5h-2V10h2z"></path></svg>'},warning:{},error:{}};class D2{constructor(t,i){U(this,"parentElement");U(this,"store");U(this,"box");U(this,"text");U(this,"arrowUp");U(this,"arrowDown");U(this,"icon");U(this,"confirm");U(this,"cancel");U(this,"x");U(this,"y");this.parentElement=t,this.store=i,this.box=document.createElement("div"),this.text=document.createElement("div"),this.arrowUp=document.createElement("div"),this.arrowDown=document.createElement("div"),this.icon=document.createElement("div"),this.confirm=document.createElement("button"),this.cancel=document.createElement("button"),this.box.className="meta2d-popconfirm",this.text.className="text",this.arrowUp.className="arrow",this.arrowDown.className="arrow down",this.icon.className="icon",this.confirm.className="confirm",this.cancel.className="cancel",this.confirm.innerHTML="\u786E\u5B9A",this.cancel.innerHTML="\u53D6\u6D88",this.icon.innerHTML=L2.info.icon,this.box.appendChild(this.text),this.box.appendChild(this.arrowUp),this.box.appendChild(this.arrowDown),this.box.appendChild(this.confirm),this.box.appendChild(this.cancel),this.box.appendChild(this.icon),t.appendChild(this.box);let s;for(let n=0;n<document.styleSheets.length;n++)document.styleSheets[n].title==="le5le.com/popconfirm"&&(s=document.styleSheets[n]);if(!s){let n=document.createElement("style");n.type="text/css",n.title="le5le.com/popconfirm",document.head.appendChild(n),n=document.createElement("style"),n.type="text/css",document.head.appendChild(n),s=n.sheet,s.insertRule(".meta2d-popconfirm{position:absolute;z-index:999;left: -9999px;top: -9999px;padding:16px;max-width:400px;background:#fff;border-radius:6px;box-shadow:0 3px 14px 2px rgba(0, 0, 0, .05),0 8px 10px 1px rgba(0, 0, 0, 6%),0 5px 5px -3px rgba(0, 0, 0, 10%);}"),s.insertRule(".meta2d-popconfirm .text{outline:none;padding:0px 0px 40px 28px;border-radius:4px;color:rgba(0, 0, 0, 0.9);overflow-y:auto;line-height:22px;font-size:13px;}"),s.insertRule(".meta2d-popconfirm .arrow{position:absolute;border:10px solid transparent;background:transparent;top:-18px;left:50%;transform:translateX(-50%)}"),s.insertRule(".meta2d-popconfirm .arrow.down{top:initial;bottom: -18px;}"),s.insertRule(".meta2d-popconfirm .icon{position:absolute;width:22px;height:22px;left:16px;top:16px;}"),s.insertRule(".meta2d-popconfirm .confirm{position:absolute;right:16px;bottom:16px;width:40px;height:24px;text-align:center;background:#4582e6;color:#fff;border-radius:3px;border-color:transparent}"),s.insertRule(".meta2d-popconfirm .confirm:hover{background:#003cab;}"),s.insertRule(".meta2d-popconfirm .cancel{position:absolute;right:64px;bottom:16px;width:40px;height:24px;text-align:center;background:#dcdcdc;color:rgba(0, 0, 0, 0.9);border-radius:3px;border-color:transparent}"),s.insertRule(".meta2d-popconfirm .cancel:hover{background:#a6a6a6;}")}}show(t,i){if(!t)return;const s=this.box.getBoundingClientRect(),n=t.calculative.worldRect;let r=t.calculative.canvas.store.data.x+i.x-s.width/2,a=t.calculative.canvas.store.data.y+i.y-s.height-20;t.type||(r=t.calculative.canvas.store.data.x+n.x-(s.width-n.width)/2,a=t.calculative.canvas.store.data.y+n.ey-s.height-n.height),a>0?(this.arrowUp.style.borderBottomColor="transparent",this.arrowDown.style.borderTopColor="#fff",a-=10):(a+=s.height+n.height+5,a+=10,this.arrowUp.style.borderBottomColor="#fff",this.arrowDown.style.borderTopColor="transparent"),this.x=r,this.y=a,this.box.style.left=this.x+"px",this.box.style.top=this.y+"px"}hide(){this.x=-9999,this.box.style.left="-9999px"}showModal(t,i,s){return new Promise(n=>{this.text.innerHTML=s||"\u786E\u8BA4\u6267\u884C\u64CD\u4F5C\u5417\uFF1F",this.show(t,i),this.confirm.onclick=()=>{n(!0),this.hide()},this.cancel.onclick=()=>{n(!1),this.hide()}})}destroy(){this.box=null}}const ze="-moving";class Pf{constructor(t,i,s){U(this,"parent");U(this,"parentElement");U(this,"store");U(this,"canvas",document.createElement("canvas"));U(this,"offscreen",Pi());U(this,"width");U(this,"height");U(this,"externalElements",document.createElement("div"));U(this,"clientRect");U(this,"canvasRect");U(this,"activeRect");U(this,"initActiveRect");U(this,"dragRect");U(this,"lastRotate",0);U(this,"sizeCPs");U(this,"activeInitPos");U(this,"hoverType",xt.None);U(this,"resizeIndex",0);U(this,"mouseDown");U(this,"hotkeyType");U(this,"mouseRight");U(this,"addCaches");U(this,"touchCenter");U(this,"initTouchDis");U(this,"initScale");U(this,"touchScaling");U(this,"touchMoving");U(this,"startTouches");U(this,"lastOffsetX",0);U(this,"lastOffsetY",0);U(this,"drawingLineName");U(this,"drawLineFns",[...sx]);U(this,"drawingLine");U(this,"pencil");U(this,"pencilLine");U(this,"movingPens");U(this,"patchFlagsLines",new Set);U(this,"dock");U(this,"prevAnchor");U(this,"nextAnchor");U(this,"lastMouseTime",0);U(this,"hoverTimer",0);U(this,"fitTimer",0);U(this,"willInactivePen");U(this,"patchFlags",!1);U(this,"lastRender",0);U(this,"touchStart",0);U(this,"touchStartTimer");U(this,"timer");U(this,"lastAnimateRender",0);U(this,"animateRendering",!1);U(this,"renderTimer");U(this,"initPens");U(this,"pointSize",8);U(this,"pasteOffset",!0);U(this,"opening",!1);U(this,"maxZindex",5);U(this,"canMoveLine",!1);U(this,"randomIdObj");U(this,"keyOptions");U(this,"beforeAddPen");U(this,"beforeAddPens");U(this,"beforeAddAnchor");U(this,"beforeRemovePens");U(this,"beforeRemoveAnchor");U(this,"customResizeDock");U(this,"customMoveDock");U(this,"inputParent",document.createElement("div"));U(this,"inputDiv",document.createElement("div"));U(this,"dropdown",document.createElement("ul"));U(this,"tooltip");U(this,"popconfirm");U(this,"title");U(this,"mousePos",{x:0,y:0});U(this,"scroll");U(this,"movingAnchor");U(this,"canvasTemplate");U(this,"canvasImage");U(this,"canvasImageBottom");U(this,"magnifierCanvas");U(this,"dialog");U(this,"autoPolylineFlag",!1);U(this,"stopPropagation",t=>{t.stopPropagation()});U(this,"curve",e2);U(this,"polyline",c2);U(this,"mind",s2);U(this,"line",r2);U(this,"onCopy",t=>{this.store.options.disableClipboard||t.target!==this.externalElements&&t.target!==document.body&&t.target.offsetParent!==this.externalElements||this.copy()});U(this,"onCut",t=>{this.store.options.disableClipboard||t.target!==this.externalElements&&t.target!==document.body&&t.target.offsetParent!==this.externalElements||this.cut()});U(this,"onPaste",async t=>{if(this.store.data.locked||this.store.options.disableClipboard||t.target!==this.externalElements&&t.target!==document.body&&t.target.offsetParent!==this.externalElements)return;let i;if(navigator.clipboard&&t.clipboardData){const s=t.clipboardData.items;if(s){for(let n=0;n<s.length;n++)if(s[n].type.indexOf("image")!==-1&&s[n].getAsFile()){i=!0;break}}}if(i){const s=t.clipboardData.items;if(s){for(let n=0;n<s.length;n++)if(s[n].type.indexOf("image")!==-1&&s[n].getAsFile()){const{x:r,y:a}=this.mousePos,o=s[n].getAsFile();let l=s[n].type.slice(6)==="gif"?"gif":"image";if(o!==null){const u=l==="gif",h=await this.fileToPen(o,u);h.height=h.height/h.width*100,h.width=100,h.x=r-50/2,h.y=a-h.height/h.width*50,h.externElement=u,this.addPens([h]),this.active([h]),this.copy([h])}}}}else this.paste()});U(this,"onMessage",t=>{if(typeof t.data!="string"||!t.data||t.data.startsWith("setImmediate")||t.data.startsWith("webpackHotUpdate"))return;let i=JSON.parse(t.data);typeof i=="object"?this.parent.doMessageEvent(i.name,JSON.stringify(i.data)):this.parent.doMessageEvent(i)});U(this,"onwheel",t=>{if(this.inputDiv.contentEditable==="true"||this.drawingLine||this.pencil)return;if(this.store.hover&&this.store.hover.onWheel){this.store.hover.onWheel(this.store.hover,t);return}if(this.store.data.disableScale||this.store.options.disableScale||(t.preventDefault(),t.stopPropagation(),this.mouseDown&&(this.hoverType===xt.Node||this.hoverType===xt.Line))||this.store.data.locked===Ot.Disable||this.store.data.locked===Ot.DisableScale||this.store.data.locked===Ot.DisableMoveScale)return;if(!t.ctrlKey&&Math.abs(t.wheelDelta)<100&&t.deltaY.toString().indexOf(".")===-1){if(this.store.options.scroll&&!t.metaKey&&this.scroll){this.scroll.wheel(t.deltaY<0);return}const r=this.store.data.scale||1;this.translate(-t.deltaX/r,-t.deltaY/r);return}if(Math.abs(t.wheelDelta)>100&&this.store.options.scroll&&this.scroll&&!this.store.options.scrollButScale&&!(t.ctrlKey||t.metaKey)){this.scroll.wheel(t.deltaY<0);return}if(this.store.options.disableTouchPadScale)return;let i=.015;if(this.store.options.scaleOff)i=this.store.options.scaleOff,t.deltaY>0&&(i=-this.store.options.scaleOff);else if(/mac os /i.test(navigator.userAgent))t.ctrlKey?t.deltaY>0&&(i*=-1):i*=t.wheelDeltaY/240;else{let a=.2;t.deltaY.toString().indexOf(".")!==-1&&(a=.01),t.deltaY>0?i=-a:i=a}let{offsetX:s,offsetY:n}=t;this.scale(this.store.data.scale+i,{x:s,y:n}),this.externalElements.focus()});U(this,"onkeydown",t=>{var r,a,o;if(this.store.data.locked>=Ot.DisableEdit&&t.target.tagName!=="INPUT"&&t.target.tagName!=="TEXTAREA"&&!t.target.dataset.meta2dIgnore&&this.store.active.forEach(l=>{var u;(u=l.onKeyDown)==null||u.call(l,l,t.key)}),this.store.data.locked>=Ot.DisableEdit||t.target.tagName==="INPUT"||t.target.tagName==="TEXTAREA"||t.target.dataset.meta2dIgnore||this.store.options.unavailableKeys.includes(t.key))return;this.keyOptions||(this.keyOptions={}),this.keyOptions.altKey=t.altKey,this.keyOptions.shiftKey=t.shiftKey,this.keyOptions.ctrlKey=t.ctrlKey,this.keyOptions.metaKey=t.metaKey,this.keyOptions.F=!1,(t.key==="F"||t.key==="f")&&(this.keyOptions.F=!0);let i=10,s=10,n=null;if(this.store.options.strictScope){const l=this.store.data.width||this.store.options.width,u=this.store.data.height||this.store.options.height;l&&u&&(n={x:this.store.data.origin.x,y:this.store.data.origin.y,width:l*this.store.data.scale,height:u*this.store.data.scale})}switch(t.key){case" ":this.hotkeyType=Yt.Translate;break;case"Control":this.drawingLine?this.drawingLine.calculative.drawlineH=!this.drawingLine.calculative.drawlineH:this.hotkeyType||(this.patchFlags=!0,this.hotkeyType=Yt.Select);break;case"Meta":break;case"Shift":this.store.active.length===1&&this.store.active[0].type&&this.store.activeAnchor?this.toggleAnchorHand():this.hotkeyType||(this.patchFlags=!0,this.store.options.resizeMode||(this.hotkeyType=Yt.Resize));break;case"Alt":if(!t.ctrlKey&&!t.shiftKey&&this.drawingLine){const l=Vt(this.drawingLine);l!==this.drawingLine.calculative.activeAnchor?(vc(this.drawingLine),this.drawingLine.calculative.worldAnchors.push(l)):this.drawingLine.calculative.worldAnchors.push({x:l.x,y:l.y});const u=this.drawLineFns.indexOf(this.drawingLineName);this.drawingLineName=this.drawLineFns[(u+1)%this.drawLineFns.length],this.drawingLine.lineName=this.drawingLineName,this.drawline(),this.patchFlags=!0}t.preventDefault();break;case"a":case"A":t.ctrlKey||t.metaKey?(this.active(this.store.data.pens.filter(l=>!l.parentId&&l.locked!==Ot.Disable)),t.preventDefault()):this.toggleAnchorMode();break;case"Delete":case"Backspace":if(this.canvasImage.fitFlag&&this.canvasImage.activeFit){this.deleteFit();break}!this.store.data.locked&&this.delete();break;case"ArrowLeft":if(this.movingAnchor){this.translateAnchor(-1,0);break}if(i=-1,t.shiftKey&&(i=-5),(t.ctrlKey||t.metaKey)&&(i=-10),i=i*this.store.data.scale,this.store.activeAnchor&&this.store.active&&this.store.active.length===1&&this.store.active[0].type){this.moveLineAnchor({x:this.store.activeAnchor.x+i,y:this.store.activeAnchor.y},{});break}n&&this.activeRect.x+i<n.x&&(i=n.x-this.activeRect.x),this.translatePens(this.store.active,i,0);break;case"ArrowUp":if(this.movingAnchor){this.translateAnchor(0,-1);break}if(s=-1,t.shiftKey&&(s=-5),(t.ctrlKey||t.metaKey)&&(s=-10),s=s*this.store.data.scale,n&&this.activeRect.y+s<n.y&&(s=n.y-this.activeRect.y),this.store.activeAnchor&&this.store.active&&this.store.active.length===1&&this.store.active[0].type){this.moveLineAnchor({x:this.store.activeAnchor.x,y:this.store.activeAnchor.y+s},{});break}this.translatePens(this.store.active,0,s);break;case"ArrowRight":if(this.movingAnchor){this.translateAnchor(1,0);break}if(i=1,t.shiftKey&&(i=5),(t.ctrlKey||t.metaKey)&&(i=10),i=i*this.store.data.scale,this.store.activeAnchor&&this.store.active&&this.store.active.length===1&&this.store.active[0].type){this.moveLineAnchor({x:this.store.activeAnchor.x+i,y:this.store.activeAnchor.y},{});break}n&&this.activeRect.x+this.activeRect.width+i>n.x+n.width&&(i=n.x+n.width-(this.activeRect.x+this.activeRect.width)),this.translatePens(this.store.active,i,0);break;case"ArrowDown":if(this.movingAnchor){this.translateAnchor(0,1);break}if(s=1,t.shiftKey&&(s=5),(t.ctrlKey||t.metaKey)&&(s=10),s=s*this.store.data.scale,n&&this.activeRect.y+this.activeRect.height+s>n.y+n.height&&(s=n.y+n.height-(this.activeRect.y+this.activeRect.height)),this.store.activeAnchor&&this.store.active&&this.store.active.length===1&&this.store.active[0].type){this.moveLineAnchor({x:this.store.activeAnchor.x,y:this.store.activeAnchor.y+s},{});break}this.translatePens(this.store.active,0,s);break;case"d":case"D":(r=this.store.active[0])!=null&&r.locked||this.removeAnchorHand();break;case"h":case"H":(a=this.store.active[0])!=null&&a.locked||this.addAnchorHand();break;case"m":case"M":this.toggleMagnifier();break;case"g":case"G":if(t.ctrlKey||t.metaKey){t.shiftKey?this.parent.uncombine():this.store.active.length>1&&this.parent.combine(this.store.active),t.preventDefault();break}this.hoverType===xt.NodeAnchor&&(this.movingAnchor=this.store.hoverAnchor,this.externalElements.style.cursor="move");break;case"s":case"S":!this.store.data.locked&&this.hoverType===xt.LineAnchor&&this.store.hover===this.store.active[0]&&this.splitLine(this.store.active[0],this.store.hoverAnchor),(t.ctrlKey||t.metaKey)&&this.store.emitter.emit("save",{event:t});break;case"c":case"C":(t.ctrlKey||t.metaKey)&&this.store.options.disableClipboard&&this.copy();break;case"x":case"X":(t.ctrlKey||t.metaKey)&&this.store.options.disableClipboard&&this.cut();break;case"\u221A":case"v":case"V":!t.ctrlKey&&!t.metaKey&&(this.pencil&&this.stopPencil(),this.drawingLineName?(this.finishDrawline(),this.drawingLineName=""):this.drawingLineName=this.store.options.drawingLineName),!this.store.data.locked&&(t.ctrlKey||t.metaKey)&&(this.store.options.disableClipboard||!this.store.options.disableClipboard&&t.altKey)&&this.paste();break;case"b":case"B":this.drawingLineName&&(this.finishDrawline(),this.drawingLineName=""),this.pencil?this.stopPencil():this.drawingPencil();break;case"y":case"Y":(t.ctrlKey||t.metaKey)&&this.redo();break;case"z":case"Z":t.ctrlKey||t.metaKey?this.undo():t.shiftKey&&this.redo();break;case"Enter":this.drawingLineName&&(this.finishDrawline(!0),this.store.active[0].anchors[0].connectTo?this.drawingLineName="":this.drawingLineName=this.store.options.drawingLineName),this.store.active&&(this.store.active.forEach(l=>{l.type?(l.close=!l.close,l.close&&sg(l),this.store.path2dMap.set(l,At.path2dDraws.line(l)),Jl(l)):l.calculative.focus=!0}),this.render());break;case"Escape":this.drawingLineName&&this.finishDrawline(),this.drawingLineName=void 0,this.stopPencil(),this.store.active&&this.store.active.forEach(l=>{l.type||(l.calculative.focus=!1)}),this.movingPens&&(this.getAllByPens(this.movingPens).forEach(l=>{this.store.pens[l.id]=void 0}),this.movingPens=void 0,this.mouseDown=void 0,this.clearDock(),(o=this.store.active)==null||o.forEach(l=>{this.updateLines(l)}),this.calcActiveRect(),this.patchFlags=!0),this.hotkeyType=Yt.None,this.movingAnchor=void 0,this.magnifierCanvas.magnifier&&(this.magnifierCanvas.magnifier=!1,this.patchFlags=!0);break;case"E":case"e":this.store.options.disableAnchor=!this.store.options.disableAnchor,this.store.emitter.emit("disableAnchor",this.store.options.disableAnchor);break;case"=":(t.ctrlKey||t.metaKey)&&(this.scale(this.store.data.scale+.1),t.preventDefault(),t.stopPropagation());break;case"-":(t.ctrlKey||t.metaKey)&&(this.scale(this.store.data.scale-.1),t.preventDefault(),t.stopPropagation());break;case"l":case"L":this.canMoveLine=!0;break;case"[":this.parent.down();break;case"]":this.parent.up();break;case"{":this.parent.bottom();break;case"}":this.parent.top();break;case"F":case"f":!this.store.data.locked&&(t.ctrlKey||t.metaKey)&&!this.store.options.disableClipboard&&this.paste(),this.setFollowers();break}this.render(!1)});U(this,"onkeyup",t=>{switch(t.key){case"l":case"L":this.canMoveLine=!1;break}this.hotkeyType&&this.render(),this.hotkeyType<Yt.AddAnchor&&(this.hotkeyType=Yt.None)});U(this,"ondrop",async t=>{if(this.store.data.locked){console.warn("canvas is locked, can not drop");return}t.preventDefault(),t.stopPropagation();const i=t.dataTransfer.getData("Meta2d")||t.dataTransfer.getData("Text");let s=null;try{i&&(s=JSON.parse(i))}catch{}if(!s){const{files:n}=t.dataTransfer;if(n.length&&n[0].type.match("image.*")&&!(this.addCaches&&this.addCaches.length)){const r=n[0].type==="image/gif";s=await this.fileToPen(n[0],r)}else if(this.addCaches&&this.addCaches.length)s=this.addCaches,this.addCaches=[];else{this.store.emitter.emit("drop",void 0);return}}if(s=Array.isArray(s)?s:[s],s[0]&&s[0].draggable!==!1){const n={x:t.offsetX,y:t.offsetY};this.calibrateMouse(n),this.dropPens(s,n),this.addCaches=[],this.getContainerHover(n),this.mousePos.x=n.x,this.mousePos.y=n.y,this.store.emitter.emit("mouseup",{x:n.x,y:n.y,pen:this.store.hoverContainer})}this.store.emitter.emit("drop",s||i)});U(this,"ontouchstart",t=>{this.store.data.locked!==Ot.Disable&&(this.touchStartTimer&&clearTimeout(this.touchStartTimer),this.touchStartTimer=setTimeout(()=>{this.touchStart=performance.now();const i=t.touches[0].pageX-this.clientRect.x,s=t.touches[0].pageY-this.clientRect.y,n={x:i,y:s};if(this.calibrateMouse(n),this.getHover(n),this.onMouseDown({x:i,y:s,clientX:t.touches[0].clientX,clientY:t.touches[0].clientY,pageX:t.touches[0].pageX,pageY:t.touches[0].pageY,ctrlKey:t.ctrlKey||t.metaKey,shiftKey:t.shiftKey,altKey:t.altKey,buttons:1}),t.touches.length===2){this.initTouchDis=Math.hypot(t.touches[0].pageX-t.touches[1].pageX,t.touches[0].pageY-t.touches[1].pageY),this.initScale=this.store.data.scale,this.startTouches=t.touches,this.touchCenter={x:t.touches[0].pageX+(t.touches[1].pageX-t.touches[0].pageX)/2-this.clientRect.x,y:t.touches[0].pageY+(t.touches[1].pageY-t.touches[0].pageY)/2-this.clientRect.y};return}else t.touches.length===3&&(this.store.emitter.emit("contextmenu",{e:{x:i,y:s,clientX:t.touches[0].clientX,clientY:t.touches[0].clientY,pageX:t.touches[0].pageX,pageY:t.touches[0].pageY},clientRect:this.clientRect}),t.preventDefault(),t.stopPropagation());this.touchStartTimer=void 0},50))});U(this,"ontouchmove",t=>{var o;if(this.store.data.locked===Ot.Disable)return;t.stopPropagation(),t.preventDefault();const i=performance.now();if(i-this.touchStart<50)return;this.touchStart=i;const s=t.touches,n=s.length,r=t.touches[0].pageX-this.clientRect.x,a=t.touches[0].pageY-this.clientRect.y;if(n===1)this.onMouseMove({x:r,y:a,clientX:t.changedTouches[0].clientX,clientY:t.changedTouches[0].clientY,pageX:t.changedTouches[0].pageX,pageY:t.changedTouches[0].pageY,ctrlKey:t.ctrlKey||t.metaKey,shiftKey:t.shiftKey,altKey:t.altKey,buttons:1});else if(n===2&&((o=this.startTouches)==null?void 0:o.length)===2){if(!this.touchMoving&&!this.touchScaling){const l=this.startTouches[0].pageX-s[0].pageX,u=this.startTouches[1].pageX-s[1].pageX,h=this.startTouches[0].pageY-s[0].pageY,f=this.startTouches[1].pageY-s[1].pageY;(l>=0&&u<0||l<=0&&u>0)&&(h>=0&&f<0||h<=0&&f>0)?this.touchScaling=!0:this.touchMoving=!0}if(this.touchScaling){if(this.store.data.disableScale||this.store.options.disableScale)return;const l=Math.hypot(s[0].pageX-s[1].pageX,s[0].pageY-s[1].pageY)/this.initTouchDis;this.scale(this.initScale*l,ht(this.touchCenter))}if(this.touchMoving){if(this.store.data.locked>=Ot.DisableMove&&this.store.data.locked!==Ot.DisableScale||this.store.data.disableScale||this.store.options.disableScale)return;if(this.lastOffsetX){const{scale:l}=this.store.data;this.translate((r-this.lastOffsetX)/l,(a-this.lastOffsetY)/l)}this.lastOffsetX=r,this.lastOffsetY=a}}});U(this,"ontouchend",t=>{if(this.store.data.locked===Ot.Disable)return;this.touchCenter=void 0,this.touchScaling=void 0,this.touchMoving=void 0,this.startTouches=void 0,this.lastOffsetX=0,this.lastOffsetY=0;const i=t.changedTouches[0].pageX-this.clientRect.x,s=t.changedTouches[0].pageY-this.clientRect.y;this.onMouseUp({x:i,y:s,clientX:t.changedTouches[0].clientX,clientY:t.changedTouches[0].clientY,pageX:t.changedTouches[0].pageX,pageY:t.changedTouches[0].pageY,ctrlKey:t.ctrlKey||t.metaKey,shiftKey:t.shiftKey,altKey:t.altKey,buttons:1}),setTimeout(()=>{this.render()},20)});U(this,"onGesturestart",t=>{t.preventDefault()});U(this,"onMouseDown",t=>{var i,s,n,r,a;if(t.buttons===2&&!this.drawingLine&&(this.mouseRight=Vi.Down),this.hideInput(),this.popconfirm.hide(),this.store.data.locked===Ot.Disable||t.buttons!==1&&t.buttons!==2){this.hoverType=xt.None;return}if(!this.magnifierCanvas.magnifier){if(this.calibrateMouse(t),this.mousePos.x=t.x,this.mousePos.y=t.y,this.mouseDown=t,this.lastMouseTime=performance.now(),this.canvasImage.fitFlag){this.canvasImage.currentFit||this.calcuActiveFit();return}if(this.hotkeyType===Yt.AddAnchor){this.setAnchor(this.store.pointAt);return}if(!this.store.options.autoAnchor&&!this.drawingLine&&t.shiftKey&&t.ctrlKey&&t.altKey){this.setAnchor(this.store.pointAt),this.drawingLineName=this.store.options.drawingLineName;const o=this.store.activeAnchor;if(!o)return;const l={id:It(),x:o.x,y:o.y};this.drawingLine=this.createDrawingLine(l);let u=le(this.drawingLine);this.drawingLine.calculative.activeAnchor=u,we(this.store.hover,o,this.drawingLine,l),this.drawline();return}if(!(this.hotkeyType===Yt.Translate||this.mouseRight===Vi.Down&&!this.store.options.mouseRightActive)){if(this.drawingLine){if(this.store.hoverAnchor){const l=Vt(this.drawingLine);this.store.hoverAnchor.type===ji.Line?va(l,this.store.hoverAnchor,this.store):(l.x=this.store.hoverAnchor.x,l.y=this.store.hoverAnchor.y),we(this.store.hover,this.store.hoverAnchor,this.drawingLine,l),this.drawline(),this.finishDrawline(!0);return}if(!this.store.options.autoAnchor&&t.shiftKey&&t.altKey&&t.ctrlKey){this.setAnchor(this.store.pointAt);const l=Vt(this.drawingLine),u=this.store.activeAnchor;if(!u)return;l.x=u.x,l.y=u.y,we(this.store.hover,u,this.drawingLine,l),this.drawline(),this.finishDrawline(!0);return}if(t.buttons===2||this.drawingLineName==="mind"&&((i=this.drawingLine)==null?void 0:i.calculative.worldAnchors.length)>1||this.store.options.drawingLineLength&&((s=this.drawingLine)==null?void 0:s.calculative.worldAnchors.length)>this.store.options.drawingLineLength){this.finishDrawline(!0),((n=this.store.active[0])==null?void 0:n.anchors[0].connectTo)||this.store.active.length==0?this.drawingLineName="":this.drawingLineName=this.store.options.drawingLineName;return}if(this.store.options.autoAnchor&&this.hoverType===xt.Node){const l=Vt(this.drawingLine),u=bn(this.store.hover,t);l.x=u.x,l.y=u.y,this.drawingLine.autoTo=!0,we(this.store.hover,u,this.drawingLine,l),this.drawline(),this.finishDrawline(!0);return}const o=Vt(this.drawingLine);o.isTemp?(this.drawingLine.calculative.activeAnchor=this.drawingLine.calculative.worldAnchors[this.drawingLine.calculative.worldAnchors.length-2],o.isTemp=void 0):(this.drawingLine.calculative.activeAnchor=o,this.drawingLine.calculative.worldAnchors.push({x:o.x,y:o.y,penId:o.penId})),this.drawingLine.calculative.drawlineH=void 0,this.drawingLineName!=="polyline"&&this.drawline()}if(this.drawingLineName){if(this.hoverType===xt.Node)if(this.store.options.autoAnchor){this.inactive(!0);const o=bn(this.store.hover,t);this.store.hoverAnchor=o;const l={id:It(),x:o.x,y:o.y};this.drawingLine=this.createDrawingLine(l),this.drawingLine.autoFrom=!0,we(this.store.hover,o,this.drawingLine,l)}else this.inactive(),this.hoverType=xt.None;else if(this.hoverType===xt.NodeAnchor){this.drawingLineName=this.store.options.drawingLineName;const o={id:It(),x:this.store.hoverAnchor.x,y:this.store.hoverAnchor.y};this.drawingLine=this.createDrawingLine(o),this.drawingLine.calculative.activeAnchor=o,we(this.store.hover,this.store.hoverAnchor,this.drawingLine,o)}else if(!this.drawingLine&&this.drawingLineName!=="curve"){this.inactive(!0);const o={id:It(),x:t.x,y:t.y};this.drawingLine=this.createDrawingLine(o),this.drawingLine.calculative.activeAnchor=o}}else if(this.pencil){this.inactive(!0);const o=It(),l={x:t.x,y:t.y,id:It(),penId:o};this.pencilLine=this.getInitPencilLine(l)}else{switch(this.hoverType){case xt.None:(this.store.data.rule||this.store.options.rule)&&!this.store.options.disableRuleLine&&this.addRuleLine(t),this.store.options.resizeMode&&(this.hotkeyType=Yt.None),this.inactive();break;case xt.Node:case xt.Line:if(this.store.hover){if(((r=this.store.active)==null?void 0:r.length)&&this.store.active.length===1&&this.store.hover.id===this.store.active[0].id){this.calcActiveRect();break}const o=Ge(this.store.hover,!0);let l=o||this.store.hover;o&&(o.container||((a=this.store.options.containerShapes)==null?void 0:a.includes(o.name)))&&(l=this.store.hover),t.ctrlKey&&!t.shiftKey?(l.calculative.active?this.willInactivePen=l:this.store.active.length>0&&(l.calculative.active=!0,pn(l),this.store.active.push(l),this.store.emitter.emit("active",this.store.active)),this.patchFlags=!0):t.ctrlKey&&t.shiftKey&&this.store.hover.parentId?this.active([this.store.hover]):(!(this.activeRect&&Ui({x:t.x,y:t.y},this.activeRect))||this.store.active.length==1)&&(l.calculative.active||(this.active([l]),this.store.options.resizeMode&&(this.hotkeyType=Yt.Resize))),this.calcActiveRect()}break;case xt.LineAnchor:this.store.activeAnchor=this.store.hoverAnchor,this.store.hover.calculative.activeAnchor=this.store.hoverAnchor,this.active([this.store.hover]);break;case xt.LineAnchorPrev:case xt.LineAnchorNext:this.store.activeAnchor&&(this.prevAnchor={...this.store.activeAnchor.prev},this.nextAnchor={...this.store.activeAnchor.next});break;case xt.Resize:this.activeInitPos=[],this.store.active.forEach(o=>{this.activeInitPos.push({x:(o.calculative.worldRect.x-this.activeRect.x)/this.activeRect.width,y:(o.calculative.worldRect.y-this.activeRect.y)/this.activeRect.height})});break}this.store.hover&&(this.store.hover.calculative.mouseDown=!0),this.store.emitter.emit("mousedown",{x:t.x,y:t.y,pen:this.store.hover})}this.render()}}});U(this,"onMouseMove",t=>{var s,n,r,a,o,l,u,h;if(this.store.data.locked===Ot.Disable){this.hoverType=xt.None;return}if(this.mouseDown&&!this.mouseDown.restore&&t.buttons!==1&&t.buttons!==2){this.onMouseUp(t);return}if(this.lastMouseTime){if(performance.now()-this.lastMouseTime<50){this.lastMouseTime=0;return}this.lastMouseTime=0}if(this.calibrateMouse(t),this.mousePos.x=t.x,this.mousePos.y=t.y,this.magnifierCanvas.magnifier){this.render();return}if(this.canvasImage.fitFlag&&this.canvasImage.activeFit){const f=performance.now();f-this.fitTimer>100&&(this.mouseDown?this.updateFit(t):this.inFitBorder(this.mousePos),this.fitTimer=f);return}if(this.mouseDown&&!this.store.options.disableTranslate&&!this.store.data.disableTranslate){if(this.mouseRight===Vi.Down&&(this.mouseRight=Vi.Translate),this.store.data.locked===Ot.DisableEdit||this.store.data.locked===Ot.DisableScale||this.hotkeyType===Yt.Translate||this.mouseRight===Vi.Translate){const{scale:f}=this.store.data;let g=(t.x-this.mouseDown.x)/f,v=(t.y-this.mouseDown.y)/f;t.shiftKey&&!t.ctrlKey&&(v=0),t.ctrlKey&&(g=0),this.translate(g,v);return}if(this.store.data.locked)return;if(!this.drawingLine&&!this.pencil){if(!this.drawingLineName&&!this.movingAnchor){if(this.hoverType===xt.NodeAnchor){if(!this.store.hoverAnchor)return;this.drawingLineName=this.store.options.drawingLineName;const f={id:It(),x:this.store.hoverAnchor.x,y:this.store.hoverAnchor.y};this.drawingLine=this.createDrawingLine(f),this.drawingLine.calculative.activeAnchor=f,we(this.store.hover,this.store.hoverAnchor,this.drawingLine,f),this.drawline();return}}else if(this.drawingLineName&&this.hoverType===xt.None){const f={id:It(),x:t.x,y:t.y};this.drawingLine=this.createDrawingLine(f),this.drawingLine.calculative.activeAnchor=f,this.drawline();return}if(t.buttons===1&&(t.ctrlKey||!this.hoverType&&!this.hotkeyType)&&!(t.ctrlKey&&(this.store.activeAnchor||((s=this.store.active)==null?void 0:s.length)))){this.dragRect={x:Math.min(this.mouseDown.x,t.x),y:Math.min(this.mouseDown.y,t.y),ex:Math.max(this.mouseDown.x,t.x),ey:Math.max(this.mouseDown.y,t.y),width:Math.abs(t.x-this.mouseDown.x),height:Math.abs(t.y-this.mouseDown.y)},this.render();return}if(this.movingAnchor){const f=t.x-this.movingAnchor.x,g=t.y-this.movingAnchor.y;this.translateAnchor(f,g),this.render();return}else if(!((n=this.store.active[0])!=null&&n.locked)){const f={x:t.x,y:t.y};if(this.hoverType===xt.LineAnchor){(this.dockInAnchor(t)||((r=this.store.active[0])==null?void 0:r.lineName)==="line")&&!this.store.options.disableDock&&!this.store.options.disableLineDock&&(this.clearDock(),this.dock=mf(this.store,f,this.store.activeAnchor),(a=this.dock)!=null&&a.xDock&&(f.x+=this.dock.xDock.step),(o=this.dock)!=null&&o.yDock&&(f.y+=this.dock.yDock.step)),this.moveLineAnchor(f,t);return}if(this.hoverType===xt.LineAnchorPrev){this.moveLineAnchorPrev(t);return}if(this.hoverType===xt.LineAnchorNext){this.moveLineAnchorNext(t);return}}if(this.hoverType===xt.Rotate){this.rotatePens({x:t.x,y:t.y});return}if(this.hoverType===xt.Resize){this.resizePens(t);return}if(this.hoverType===xt.Node||this.hoverType===xt.Line){const f=t.x-this.mouseDown.x,g=t.y-this.mouseDown.y,v=20;if(t.ctrlKey&&!t.shiftKey&&(Math.abs(f)>=v||Math.abs(g)>=v)&&(this.willInactivePen=void 0),this.store.active.length===1){const y=this.store.active[0];if((y.locked===void 0||y.locked<Ot.DisableMove)&&((l=y==null?void 0:y.onMouseMove)==null||l.call(y,y,this.mousePos)),y.calculative.focus)return}this.movePens(t),this.getContainerHover(t);return}}else if(this.pencil){const{x:f,y:g}=t,v={x:f,y:g};v.id=It(),v.penId=this.pencilLine.id,this.pencilLine.calculative.worldAnchors.push(v),this.store.path2dMap.set(this.pencilLine,At.path2dDraws[this.pencilLine.name](this.pencilLine)),this.patchFlags=!0}}if(this.drawingLine){const{x:f,y:g}=t,v={x:f,y:g};if(v.id=It(),v.penId=this.drawingLine.id,!this.store.options.disableDock&&!this.store.options.disableLineDock&&(this.clearDock(),this.dock=mf(this.store,v),(u=this.dock)!=null&&u.xDock&&(v.x+=this.dock.xDock.step),(h=this.dock)!=null&&h.yDock&&(v.y+=this.dock.yDock.step)),this.mouseDown&&this.drawingLineName==="curve"&&!this.drawingLine.calculative.worldAnchors[0].connectTo)this.drawline(v);else{let y;if(this.drawingLine.calculative.worldAnchors.length>1&&(y=Vt(this.drawingLine)),y?(y.prev=void 0,y.next=void 0,y.id||(y.id=It()),y.x=v.x,y.y=v.y,y.connectTo=void 0):(y={...v},this.drawingLine.calculative.worldAnchors.push(y)),(this.hoverType===xt.NodeAnchor||this.hoverType===xt.LineAnchor)&&(this.store.hoverAnchor.type!==ji.Line&&(y.x=this.store.hoverAnchor.x,y.y=this.store.hoverAnchor.y),y.connectTo=this.store.hoverAnchor.penId,this.drawingLineName==="polyline"&&(y.isTemp=!1)),this.drawingLineName==="line"){if(t.ctrlKey&&!t.shiftKey)y.x=this.drawingLine.calculative.worldAnchors[this.drawingLine.calculative.worldAnchors.length-2].x;else if(t.shiftKey&&!t.ctrlKey)y.y=this.drawingLine.calculative.worldAnchors[this.drawingLine.calculative.worldAnchors.length-2].y;else if(t.shiftKey&&t.ctrlKey){let w=this.drawingLine.calculative.worldAnchors[this.drawingLine.calculative.worldAnchors.length-2];this.getSpecialAngle(y,w)}}this.drawline()}}globalThis.debug&&console.time("hover");const i=performance.now();i-this.hoverTimer>50&&(this.hoverTimer=i,this.getHover(t)),globalThis.debug&&console.timeEnd("hover"),this.hotkeyType===Yt.AddAnchor&&(this.patchFlags=!0),this.render(!1)});U(this,"onMouseUp",t=>{if(this.store.data.locked===Ot.Disable){this.hoverType=xt.None;return}if(!!this.mouseDown){if(this.mouseRight===Vi.Down&&(this.store.hover&&this.store.hover.onContextmenu?this.store.hover.onContextmenu(this.store.hover,t):this.store.emitter.emit("contextmenu",{e:t,clientRect:this.clientRect,pen:this.store.hover})),this.mouseRight=Vi.None,this.calibrateMouse(t),this.mousePos.x=t.x,this.mousePos.y=t.y,this.pencil&&this.finishPencil(),this.drawingLine){if(this.store.hoverAnchor){const i=Vt(this.drawingLine);this.store.hoverAnchor.type===ji.Line?va(i,this.store.hoverAnchor,this.store):(i.x=this.store.hoverAnchor.x,i.y=this.store.hoverAnchor.y),we(this.store.hover,this.store.hoverAnchor,this.drawingLine,i),this.drawline(),this.finishDrawline(!0);return}if(this.store.options.autoAnchor&&this.hoverType===xt.Node){const i=Vt(this.drawingLine),s=bn(this.store.hover,t);i.x=s.x,i.y=s.y,this.drawingLine.autoTo=!0,we(this.store.hover,s,this.drawingLine,i),this.drawline(),this.finishDrawline(!0);return}}if(this.hoverType===xt.LineAnchor&&this.store.hover&&this.store.active[0]&&this.store.active[0].name==="line"&&this.store.active[0]!==this.store.hover){const i=this.store.active[0],s=le(i),n=Vt(i);if(this.store.hoverAnchor){const r=this.store.hover,a=le(r)===this.store.hoverAnchor,o=Vt(r)===this.store.hoverAnchor,l=s===this.store.activeAnchor,u=n===this.store.activeAnchor;if((t.ctrlKey||t.altKey)&&r.type===jt.Line&&(a||o)&&(l||u)){const h=r.calculative.worldAnchors.map(f=>({...f,penId:i.id}));a?h.shift():o&&h.pop(),(a&&l||o&&u)&&h.reverse(),l?(i.calculative.worldAnchors[0].connectTo=void 0,i.calculative.worldAnchors.unshift(...h)):u&&(i.calculative.worldAnchors[i.calculative.worldAnchors.length-1].connectTo=void 0,i.calculative.worldAnchors.push(...h)),this.delete([r]),this.render()}else this.store.activeAnchor&&(this.store.hoverAnchor.type===ji.Line?va(this.store.activeAnchor,this.store.hoverAnchor,this.store):(this.store.activeAnchor.x=this.store.hoverAnchor.x,this.store.activeAnchor.y=this.store.hoverAnchor.y),we(this.store.hover,this.store.hoverAnchor,i,this.store.activeAnchor));this[i.lineName]&&i.lineName!=="polyline"&&this[i.lineName](this.store,i),this.store.path2dMap.set(i,At.path2dDraws.line(i)),this.initLineRect(i)}else s===this.store.activeAnchor&&i.autoFrom?this.calcAutoAnchor(i,s,this.store.hover):n===this.store.activeAnchor&&i.autoTo&&this.calcAutoAnchor(i,n,this.store.hover)}if(this.addCaches&&this.addCaches.length){if(!this.store.data.locked){if(this.dragRect&&this.addCaches.length===1){const i=this.addCaches[0];i.width=this.dragRect.width/this.store.data.scale,i.height=this.dragRect.height/this.store.data.scale,t.x=(this.dragRect.x+this.dragRect.ex)/2,t.y=(this.dragRect.y+this.dragRect.ey)/2}this.dropPens(this.addCaches,t)}this.addCaches=void 0}if(this.hoverType===xt.Rotate&&(this.getSizeCPs(),this.store.active.forEach(i=>{i.rotate=i.calculative.rotate})),this.patchFlagsLines.forEach(i=>{i.type&&this.initLineRect(i)}),this.patchFlagsLines.clear(),this.dragRect)if(this.canvasImage.fitFlag)this.makeFit();else{const i=this.store.data.pens.filter(s=>{if(s.visible===!1||s.locked>=Ot.DisableMove||s.parentId||s.isRuleLine)return!1;if(Xi(s.calculative.worldRect,this.dragRect,t.ctrlKey||this.store.options.dragAllIn))return s.type===jt.Line&&!this.store.options.dragAllIn?Tl(s,this.dragRect):!0});this.active(i)}if(t.button!==2&&(Xa(this.mouseDown,t)<2&&(this.store.hover&&this.store.hover.input&&(this.store.hover.onShowInput?this.store.hover.onShowInput(this.store.hover,t):this.showInput(this.store.hover)),this.store.emitter.emit("click",{x:t.x,y:t.y,pen:this.store.hover})),this.store.hover&&(this.store.hover.calculative.mouseDown=!1),this.store.hover!=this.store.hoverContainer&&this.store.emitter.emit("mouseup",{x:t.x,y:t.y,pen:this.store.hover}),this.store.emitter.emit("mouseup",{x:t.x,y:t.y,pen:this.store.hoverContainer})),this.willInactivePen){this.willInactivePen.calculative.active=void 0,pn(this.willInactivePen,!1);const i=this.store.active.findIndex(s=>s===this.willInactivePen);i>=0&&this.store.active.splice(i,1),this.calcActiveRect(),this.willInactivePen=void 0,this.store.emitter.emit("inactive",[this.willInactivePen]),this.render()}this.movingPens&&(t.altKey&&!t.shiftKey?this.copyMovedPens():this.movedActivePens(t.ctrlKey&&t.shiftKey),this.getAllByPens(this.movingPens).forEach(i=>{this.store.pens[i.id]=void 0}),this.movingPens=void 0),this.store.active&&this.store.active[0]&&(this.store.active[0].calculative.h=void 0),this.mouseDown=void 0,this.lastOffsetX=0,this.lastOffsetY=0,this.clearDock(),this.dragRect=void 0,this.initActiveRect=void 0,this.render()}});U(this,"clearDock",()=>{var r,a,o,l;const t=(a=(r=this.dock)==null?void 0:r.xDock)==null?void 0:a.penId,i=(l=(o=this.dock)==null?void 0:o.yDock)==null?void 0:l.penId,s=this.store.pens[t];s&&(s.calculative.isDock=!1);const n=this.store.pens[i];n&&(n.calculative.isDock=!1),this.dock=void 0});U(this,"onResize",()=>{this.timer&&clearTimeout(this.timer),this.timer=setTimeout(()=>{this.resize(),this.timer=void 0},100)});U(this,"onScroll",()=>{this.timer&&clearTimeout(this.timer),this.timer=setTimeout(()=>{this.clientRect=this.canvas.getBoundingClientRect(),this.timer=void 0},100)});U(this,"calibrateMouse",t=>(t.x-=this.store.data.x,t.y-=this.store.data.y,t));U(this,"getContainerHover",t=>{var s;if(this.dragRect)return;this.store.hoverContainer=void 0;const i=this.store.data.pens.filter(n=>{var r;return n.container||((r=this.store.options.containerShapes)==null?void 0:r.includes(n.name))});if(i.length)for(let n=i.length-1;n>=0;--n){const r=i[n];if(!(r.visible==!1||r.calculative.inView==!1||r.locked===Ot.Disable)){if(Ui(t,r.calculative.worldRect))this.store.hoverContainer=r,(s=r==null?void 0:r.onMouseMove)==null||s.call(r,r,t),this.store.lastHoverContainer!==this.store.hoverContainer&&(this.patchFlags=!0,this.store.lastHoverContainer&&(this.store.lastHoverContainer.calculative.containerHover=!1,this.store.emitter.emit("leave",this.store.lastHoverContainer)),this.store.hoverContainer&&(this.store.hoverContainer.calculative.containerHover=!0,this.store.emitter.emit("enter",this.store.hoverContainer)),this.store.lastHoverContainer=this.store.hoverContainer);else if(r===this.store.hoverContainer&&(this.store.hoverContainer=void 0,this.store.lastHoverContainer!==this.store.hoverContainer)){this.patchFlags=!0;const a=this.store.lastHoverContainer.calculative.canvas.store.pens[this.store.lastHoverContainer.id+ze];this.store.lastHoverContainer&&!a&&(this.store.lastHoverContainer.calculative.containerHover=!1,this.store.emitter.emit("leave",this.store.lastHoverContainer)),this.store.lastHoverContainer=this.store.hoverContainer}}}});U(this,"getHover",t=>{var n,r;if(this.dragRect||this.canvasImage.fitFlag)return;let i=xt.None;this.store.hover=void 0,this.store.hoverAnchor=void 0,this.title.hide(),this.store.pointAt=void 0,this.store.pointAtIndex=void 0;const s=this.store.active.length===1&&this.store.active[0].type;if(!this.drawingLineName&&this.hotkeyType!==Yt.AddAnchor&&this.activeRect&&!s&&!this.store.data.locked){const a=Al(this.store.active),o=gf(this.store.active)||this.store.options.disableRotate,l=vf(this.store.active)||this.store.options.disableSize;if(!a&&!o){const u={x:this.activeRect.center.x,y:this.activeRect.y-30};this.activeRect.rotate&&Gt(u,this.activeRect.rotate,this.activeRect.pivot||this.activeRect.center),!this.hotkeyType&&mn(t,u,this.pointSize)&&(i=xt.Rotate,this.externalElements.style.cursor=`url("${this.store.options.rotateCursor}"), auto`)}if(!a&&!l)for(let u=0;u<8;u++){const h=u<4;if((this.hotkeyType===Yt.Resize||h&&!this.hotkeyType)&&mn(t,this.sizeCPs[u],this.pointSize)){let g=h?rf:af,v=0;Math.abs(this.activeRect.rotate%90-45)<25?(g=h?af:rf,v=Math.round((this.activeRect.rotate-45)/90)+(h?0:1)):v=Math.round(this.activeRect.rotate/90),i=xt.Resize,this.resizeIndex=u,this.externalElements.style.cursor=g[(u+v)%4];break}}}i===xt.None&&(i=this.inPens(t,this.store.data.pens)),!i&&!s&&Ui(t,this.activeRect)&&(i=xt.Node,this.externalElements.style.cursor="move"),this.hoverType=i,i===xt.None&&(this.drawingLineName||this.pencil?this.externalElements.style.cursor="crosshair":this.mouseDown||(this.externalElements.style.cursor="default"),this.store.hover=void 0),this.store.lastHover!==this.store.hover&&(this.patchFlags=!0,this.store.lastHover&&(this.store.lastHover.calculative.hover=!1,tr(Ge(this.store.lastHover,!0)||this.store.lastHover,!1),this.store.emitter.emit("leave",this.store.lastHover),this.tooltip.hide()),this.store.hover&&(this.store.hover.calculative.hover=!0,tr(Ge(this.store.hover,!0)||this.store.hover),this.store.emitter.emit("enter",this.store.hover),this.tooltip.show(this.store.hover,t)),this.store.lastHover=this.store.hover),(r=(n=this.store.hover)==null?void 0:n.onMouseMove)==null||r.call(n,this.store.hover,this.mousePos)});U(this,"inPens",(t,i)=>{var n;let s=xt.None;t:for(let r=i.length-1;r>=0;--r){const a=i[r];if(a.visible==!1||a.calculative.inView==!1||a.locked===Ot.Disable)continue;const o=Va(a);if(!(!a.calculative.active&&!Ws(t,a.calculative.worldRect,o)&&!Ui(t,a.calculative.worldRect))){if(!this.store.data.locked&&this.hotkeyType!==Yt.Resize&&a.calculative.worldAnchors){for(const l of a.calculative.worldAnchors)if(s=this.inAnchor(t,a,l),s){let u=ht(l);Object.assign(u,t),this.title.show(u,a);break t}}if(a.type){if(a.isRuleLine){let u=((n=this.store.options.ruleOptions)==null?void 0:n.height)||20;if(t.x+this.store.data.x>u&&t.y+this.store.data.y>u)break}const l=a2(t,a);if(l){!this.store.data.locked&&!a.locked?this.hotkeyType===Yt.AddAnchor?this.externalElements.style.cursor="pointer":this.externalElements.style.cursor="move":this.externalElements.style.cursor=this.store.options.hoverCursor,a.calculative.disabled&&(this.externalElements.style.cursor="not-allowed"),this.store.hover=a,this.store.pointAt=l.point,this.store.pointAtIndex=l.i,this.initTemplateCanvas([this.store.hover]),s=xt.Line;break}}else{if(a.children){const u=[];if(a.children.forEach(h=>{this.store.pens[h]&&u.push(this.store.pens[h])}),s=this.inPens(t,u),s)break}let l=!1;if(a.name==="line"?l=Ws(t,a.calculative.worldRect,a.lineWidth):l=Ui(t,a.calculative.worldRect),l){if(a.type===jt.Node&&a.name==="line"&&!T_(t,a.calculative.worldAnchors))continue;if(!this.store.data.locked&&!a.locked?this.hotkeyType===Yt.AddAnchor?this.externalElements.style.cursor="pointer":this.externalElements.style.cursor="move":this.externalElements.style.cursor=this.store.options.hoverCursor,a.calculative.disabled&&(this.externalElements.style.cursor="not-allowed"),this.store.hover=a,this.initTemplateCanvas([this.store.hover]),s=xt.Node,this.store.pointAt=t,!t.ctrlKey){let{x:u,y:h,ex:f,ey:g,rotate:v,center:y}=this.store.hover.calculative.worldRect;if(v){const w=[{x:u,y:h},{x:f,y:h},{x:f,y:g},{x:u,y:g}];w.forEach(_=>{Gt(_,v,y)});let p=w[w.length-1];for(const _ of w){if(p.y>t.y!=_.y>t.y){const E=_.x+(t.y-_.y)*(p.x-_.x)/(p.y-_.y);Math.abs(E-this.store.pointAt.x)<10&&(this.store.pointAt.x=E)}p=_}}else this.store.pointAt.x-10<u?this.store.pointAt.x=u:this.store.pointAt.x+10>f&&(this.store.pointAt.x=f),this.store.pointAt.y-10<h?this.store.pointAt.y=h:this.store.pointAt.y+10>g&&(this.store.pointAt.y=g)}break}}}}return s});U(this,"dockInAnchor",t=>{var i,s;this.store.hover=void 0;for(let n=this.store.data.pens.length-1;n>=0;--n){const r=this.store.data.pens[n];if(r.visible==!1||r.locked===Ot.Disable||r===this.store.active[0])continue;let a=Va(r);if(a+=2*this.store.options.anchorRadius,!!Ws(t,r.calculative.worldRect,a)&&(this.store.hover=r,this.hotkeyType!==Yt.Resize&&r.calculative.worldAnchors))for(const o of r.calculative.worldAnchors){if(o.twoWay===Ee.In){const l=Vt(this.store.active[0]);if(this.store.activeAnchor.id!==l.id)continue}if(o.twoWay===Ee.Out){const l=le(this.store.active[0]);if(this.store.activeAnchor.id!==l.id)continue}if(!(o.twoWay===Ee.DisableConnected||o.twoWay===Ee.Disable||((i=this.store.activeAnchor)==null?void 0:i.twoWay)===Ee.DisableConnectTo||((s=this.store.activeAnchor)==null?void 0:s.twoWay)===Ee.Disable)&&(this.title.hide(),this.inAnchor(t,r,o))){let l=ht(o);return Object.assign(l,t),this.title.show(l,r),!0}}}});U(this,"imageTimer");U(this,"templateImageTimer");U(this,"render",t=>{if(t&&(this.opening=!1),this.opening)return;let i;if(t==null||t===!0||t===1/0?(i=performance.now(),this.patchFlags=!0):t>1?i=t:i=performance.now(),!this.patchFlags)return;if(i-this.lastRender<this.store.options.interval){this.renderTimer&&cancelAnimationFrame(this.renderTimer),this.renderTimer=requestAnimationFrame(this.render);return}this.renderTimer=void 0,this.lastRender=i;const s=this.offscreen.getContext("2d");s.clearRect(0,0,this.offscreen.width,this.offscreen.height),s.save(),s.translate(this.store.data.x,this.store.data.y),globalThis.debugRender&&console.time("renderPens"),this.renderPens(),globalThis.debugRender&&console.timeEnd("renderPens"),this.renderBorder(),this.renderHoverPoint(),s.restore(),this.magnifierCanvas.magnifier&&this.magnifierCanvas.render();const n=this.canvas.getContext("2d");n.clearRect(0,0,this.canvas.width,this.canvas.height),n.drawImage(this.offscreen,0,0,this.width,this.height),this.canvasTemplate.render(),this.canvasImageBottom.render(),this.canvasImage.render(),this.patchFlags=!1});U(this,"renderPens",()=>{const t=this.offscreen.getContext("2d");t.strokeStyle=this.store.styles.color;for(const i of this.store.data.pens)!isFinite(i.x)||i.canvasLayer!==zt.CanvasTemplate&&(i.name==="combine"&&!i.draw||i.calculative.inView&&(i.canvasLayer===zt.CanvasMain&&i.name!=="gif"&&i.image&&i.calculative.img&&(t.save(),zs(t,i),i.calculative.rotate&&Gi(t,i),Hs(t,i),kn(t,i),t.restore()),Is(t,i)));this.drawingLine&&Is(t,this.drawingLine),this.pencilLine&&Is(t,this.pencilLine),this.movingPens&&this.movingPens.forEach(i=>{this.renderPenContainChild(t,i)})});U(this,"renderPenContainChild",(t,i)=>{var s;i.calculative.inView&&(i.name==="combine"&&!i.draw||Is(t,i)),(s=i.children)==null||s.forEach(n=>{const r=this.store.pens[n];r&&this.renderPenContainChild(t,r)})});U(this,"renderBorder",()=>{if(!this.store.data.locked&&this.activeRect&&!(this.store.active.length===1&&this.store.active[0].type)&&!this.movingPens){const t=this.offscreen.getContext("2d");t.save(),t.translate(.5,.5);const i=this.activeRect.pivot||this.activeRect.center;if(this.activeRect.rotate&&(t.translate(i.x,i.y),t.rotate(this.activeRect.rotate*Math.PI/180),t.translate(-i.x,-i.y)),t.strokeStyle=this.store.styles.activeColor,t.globalAlpha=this.store.options.activeGlobalAlpha===void 0?.3:this.store.options.activeGlobalAlpha,t.beginPath(),t.lineWidth=this.store.options.activeLineWidth||1,t.setLineDash(this.store.options.activeLineDash||[]),t.strokeRect(this.activeRect.x,this.activeRect.y,this.activeRect.width,this.activeRect.height),t.setLineDash([]),t.lineWidth=1,t.globalAlpha=1,Al(this.store.active)||gf(this.store.active)||this.store.options.disableRotate){t.restore();return}t.beginPath(),t.moveTo(this.activeRect.center.x,this.activeRect.y),t.lineTo(this.activeRect.center.x,this.activeRect.y-30),t.stroke(),t.beginPath(),t.strokeStyle=this.store.styles.activeColor,t.fillStyle="#ffffff",t.arc(this.activeRect.center.x,this.activeRect.y-30,5,0,Math.PI*2),t.fill(),t.stroke(),t.restore()}});U(this,"renderHoverPoint",()=>{if(this.store.data.locked)return;const t=this.offscreen.getContext("2d");if(t.save(),t.translate(.5,.5),!this.store.options.disableAnchor&&this.store.hover&&!this.store.hover.disableAnchor&&(this.hotkeyType!==Yt.Resize||this.store.active.length!==1||this.store.active[0]!==this.store.hover)){const i=[...this.store.hover.calculative.worldAnchors];this.store.pointAt&&this.hotkeyType===Yt.AddAnchor&&i.push(this.store.pointAt),i&&(t.strokeStyle=this.store.hover.anchorColor||this.store.styles.anchorColor,t.fillStyle=this.store.hover.anchorBackground||this.store.options.anchorBackground,i.forEach(s=>{if(s.hidden&&s.locked>Ot.DisableEdit)return;if(s===this.store.hoverAnchor){t.save();const r=this.store.hover.hoverAnchorColor||this.store.options.hoverAnchorColor;t.strokeStyle=r,t.fillStyle=r}t.beginPath();let n=s.radius||this.store.hover.anchorRadius||this.store.options.anchorRadius;if(this.store.hover.type&&!s.radius&&!this.store.hover.anchorRadius&&(n=3,this.store.hover.calculative.lineWidth>3&&(n=this.store.hover.calculative.lineWidth)),s.type===ji.Line){let r=this.store.pens[s.penId].rotate||0;this.store.pens[s.penId].calculative.flipX&&(r*=-1),this.store.pens[s.penId].calculative.flipY&&(r*=-1);let a=s.rotate+r;this.store.pens[s.penId].calculative.flipX&&(a*=-1),this.store.pens[s.penId].calculative.flipY&&(a*=-1),t.save(),t.translate(s.x,s.y),t.rotate(a*Math.PI/180),t.translate(-s.x,-s.y),t.rect(s.x-s.length*this.store.data.scale/2,s.y-n,s.length*this.store.data.scale,n*2),t.restore()}else t.arc(s.x,s.y,n,0,Math.PI*2);if(this.store.hover.type&&this.store.hoverAnchor===s?(t.save(),t.strokeStyle=this.store.hover.activeColor||this.store.styles.activeColor,t.fillStyle=t.strokeStyle):(s.color||s.background)&&(t.save(),t.strokeStyle=s.color,t.fillStyle=s.background),t.fill(),t.stroke(),s===this.store.hoverAnchor&&t.restore(),(this.store.hover.type&&this.store.hoverAnchor===s||s.color||s.background)&&t.restore(),!this.store.hover.parentId&&this.store.hover.children&&this.store.hover.children.length>0&&s===this.store.hoverAnchor){t.save(),t.beginPath(),t.lineWidth=3;const r=this.store.hover.hoverAnchorColor||this.store.options.hoverAnchorColor;globalThis.pSBC&&(t.strokeStyle=globalThis.pSBC(.5,r)),t.arc(s.x,s.y,n+1.5,0,Math.PI*2),t.stroke(),t.restore()}}))}this.hotkeyType!==Yt.AddAnchor&&!this.movingPens&&this.activeRect&&!(this.store.active.length===1&&this.store.active[0].type)&&!Al(this.store.active)&&!vf(this.store.active)&&!this.store.options.disableSize&&(t.strokeStyle=this.store.styles.activeColor,t.fillStyle="#ffffff",this.sizeCPs.forEach((i,s)=>{this.activeRect.rotate&&(t.save(),t.translate(i.x,i.y),t.rotate(this.activeRect.rotate*Math.PI/180),t.translate(-i.x,-i.y)),(s<4||this.hotkeyType===Yt.Resize)&&(t.beginPath(),t.fillRect(i.x-4.5,i.y-4.5,8,8),t.strokeRect(i.x-5.5,i.y-5.5,10,10)),this.activeRect.rotate&&t.restore()})),!this.store.data.locked&&this.dragRect&&(t.save(),t.fillStyle=Fa(this.store.options.dragColor,.2),t.strokeStyle=this.store.options.dragColor,t.beginPath(),t.strokeRect(this.dragRect.x,this.dragRect.y,this.dragRect.width,this.dragRect.height),t.fillRect(this.dragRect.x,this.dragRect.y,this.dragRect.width,this.dragRect.height),t.restore()),this.dock&&(t.strokeStyle=this.store.options.dockColor,this.dock.xDock&&(t.beginPath(),t.moveTo(this.dock.xDock.x,this.dock.xDock.y),t.lineTo(this.dock.xDock.x,this.dock.xDock.prev.y),t.stroke()),this.dock.yDock&&(t.beginPath(),t.moveTo(this.dock.yDock.x,this.dock.yDock.y),t.lineTo(this.dock.yDock.prev.x,this.dock.yDock.y),t.stroke())),t.restore()});U(this,"transTimeout");U(this,"pastePen",(t,i)=>{const s=t.id;if(pf(t),t.parentId=i,t.type===jt.Line?this.changeNodeConnectedLine(s,t,this.store.clipboard.pens):this.changeLineAnchors(s,t,this.store.clipboard.pens),!t.parentId){const r=this.getPenRect(t,this.store.clipboard.origin,this.store.clipboard.scale),a=this.getPenRect(this.store.clipboard.initRect,this.store.clipboard.origin,this.store.clipboard.scale),{origin:o,scale:l}=this.store.data;t.x=o.x+r.x*l,t.y=o.y+r.y*l,t.width=r.width*l,t.height=r.height*l,a.x=o.x+a.x*l,a.y=o.y+a.y*l,ee(a),this.store.clipboard.pos&&(t.x-=a.center.x-this.store.clipboard.pos.x,t.y-=a.center.y-this.store.clipboard.pos.y),this.keyOptions&&this.keyOptions.altKey&&(this.keyOptions.ctrlKey||this.keyOptions.metaKey)?(t.x=-this.store.data.x+this.width/2-t.width/2,t.y=-this.store.data.y+this.height/2-t.height/2):this.keyOptions&&this.keyOptions.shiftKey&&(this.keyOptions.ctrlKey||this.keyOptions.metaKey||this.keyOptions.F)||(t.x+=this.store.clipboard.offset*this.store.data.scale,t.y+=this.store.clipboard.offset*this.store.data.scale)}this.makePen(t);const n=[];if(Array.isArray(t.children))for(const r of t.children){const a=this.store.clipboard.pens.find(o=>o.id===r);a&&n.push(this.pastePen(a,t.id).id)}return t.children=n,Yi(t,!0),t});U(this,"ondblclick",t=>{var i,s,n;if(this.store.hover&&(!this.store.data.locked||this.store.hover.dbInput)&&!this.store.options.disableInput)if(this.store.hover.onShowInput)this.store.hover.onShowInput(this.store.hover,t);else if(this.store.hover&&this.store.hover.parentId)if(((i=this.store.active)==null?void 0:i.length)===1&&this.store.active[0].id===this.store.hover.id)this.showInput(this.store.hover);else{if(this.store.pens[this.store.hover.parentId].children.forEach(r=>{this.store.pens[r].calculative.active=!1,this.store.pens[r].calculative.hover=!1}),this.store.hover.parentId){let r=this.store.hover.id;const a=this.calibrateMouse({x:t.offsetX,y:t.offsetY});let o=1/0;(n=(s=this.store.pens[this.store.hover.parentId])==null?void 0:s.children)==null||n.forEach(l=>{const u=this.store.pens[l];if(Ui(a,u.calculative.worldRect)){const h=Math.sqrt((a.x-u.calculative.worldRect.center.x)**2+(a.y-u.calculative.worldRect.center.y)**2);h<o&&(o=h,r=l)}}),this.store.hover=this.store.pens[r],this.store.pens[r].calculative.hover=!0}this.active([this.store.hover])}else this.showInput(this.store.hover);this.store.emitter.emit("dblclick",{x:t.x,y:t.y,pen:this.store.hover})});U(this,"showInput",(t,i,s="transparent")=>{if(!window||!this.store.hover||this.store.hover.locked||this.store.hover.externElement||this.store.hover.disableInput||this.store.hover.disabled)return;if(this.inputDiv.dataset.penId===t.id){this.inputDiv.dataset.isInput="true",this.inputDiv.contentEditable="true",this.inputDiv.focus();const h=window.getSelection();h.selectAllChildren(this.inputDiv),h.collapseToEnd(),this.inputDiv.scrollTop=this.inputDiv.scrollHeight,this.inputDiv.scrollLeft=this.inputDiv.scrollWidth;return}!i&&!t.dbInput?this.setInputStyle(t):(this.inputDiv.style.width="100%",this.inputDiv.style.height="100%");const n=i||t.calculative.worldTextRect,o=`${(t.calculative.tempText===void 0?t.text+""||"":t.calculative.tempText).replace(/\x20/g," ").split(/[\s\n]/).join("</div><div>")}</div>`.replace("</div>","").replace(/\<div\>\<\/div\>/g,"<div><br></div>");this.inputDiv.innerHTML=o,this.inputParent.style.left=n.x+this.store.data.x-(t.calculative.textLeft||0)+"px",this.inputParent.style.top=n.y+this.store.data.y-(t.calculative.textTop||0)+"px";let l=n.width;this.inputParent.style.width=(l<0?12:l)+"px",this.inputParent.style.height=n.height+(t.textTop||0)+"px",this.inputParent.style.zIndex="9999",this.inputParent.style.background=s,t.rotate%360?this.inputParent.style.transform=`rotate(${t.rotate}deg)`:this.inputParent.style.transform=null,this.inputParent.style.display="flex",this.inputDiv.dataset.penId=t.id,this.inputDiv.contentEditable=t.disableInput==null?"true":t.disableInput.toString(),t.dropdownList&&this.dropdown.style.display!=="block"&&(this.dropdown.style.background=t.dropdownBackground||this.store.styles.popContentBg||"#fff",this.dropdown.style.color=t.dropdownColor||"#bdc7db",this.dropdown.style.width=this.inputParent.style.width,this.dropdown.style.fontSize=(t.fontSize||12)+"px",this.setDropdownList(),this.externalElements.style.zIndex="9999"),this.inputDiv.contentEditable="true",this.inputDiv.focus();const u=window.getSelection();u.selectAllChildren(this.inputDiv),u.collapseToEnd(),this.inputDiv.scrollTop=this.inputDiv.scrollHeight,this.inputDiv.scrollLeft=this.inputDiv.scrollWidth,t.calculative.text=void 0,this.initTemplateCanvas([t]),this.render()});U(this,"setInputStyle",t=>{t.text||(t.text="");let i;for(let l=0;l<document.styleSheets.length;l++)document.styleSheets[l].title==="le5le.com"&&(i=document.styleSheets[l]);let s="overflow: scroll;",n="",r=1;const{scale:a}=this.store.data;if(t.fontSize<12&&(r=12/t.fontSize),t.textAlign?s+=`text-align: ${t.textAlign};`:s+="text-align: center;",t.textAlign&&t.whiteSpace==="pre-line"&&(s+=`align-items: ${{left:"start",center:"center",right:"end"}[t.textAlign]};`),t.textBaseline?s+=`justify-content: ${{top:"start",middle:"center",bottom:"end"}[t.textBaseline]};`:s+="justify-content: center;",t.fontFamily&&(s+=`font-family: ${t.fontFamily};`),t.fontSize&&(t.fontSize*a<12?(s+=`font-size:${t.fontSize}px;`,s+=`zoom:${t.fontSize/12*a};`):s+=`font-size:${t.fontSize*a}px;`),s+=`color:${bs(t,this.store)};`,t.fontStyle&&(s+=`font-style: ${t.fontStyle};`),t.fontWeight&&(s+=`font-weight: ${t.fontWeight};`),t.textLeft&&(s+=`margin-left:${a>1?t.textLeft*r:t.textLeft*r/a}px;`),t.textTop&&(s+=`margin-top:${a>1?t.textTop*r:t.textTop*r/a}px;`),t.lineHeight&&(s+=`line-height:${a>1?t.fontSize*t.lineHeight*a:t.fontSize*t.lineHeight*r}px;`),t.textHeight)s+=`height:${a>1?t.textHeight*r*a:t.textHeight*r}px;`;else{let l=t.calculative.worldRect.height/a;l<0&&(l=0);let u=t.fontSize*a<12?l*r:l*a*r;u<t.fontSize*t.lineHeight*a&&(u=t.fontSize*t.lineHeight*a,s+=`top:-${u/2}px;`),s+=`height:${u}px;`}let o=null;if(t.textWidth)o=t.textWidth<1&&t.textWidth>-1?t.textWidth*t.calculative.worldRect.width:t.textWidth,t.whiteSpace!=="pre-line"&&(o<t.fontSize?s+=`width:${t.fontSize*1.2*r}px;`:s+=`width:${a>1?o*r*a:o*r}px;`);else if(t.whiteSpace===void 0||t.whiteSpace==="break-all"){let l=(t.calculative.worldTextRect.width||12)/a;l<0&&(l=0),s+=`width:${t.fontSize*a<12?l*r:l*a}px;`}if(t.whiteSpace&&(t.whiteSpace==="pre-line"?s+="white-space:pre;":(s+=`white-space:${t.whiteSpace};`,t.whiteSpace==="nowrap"&&(n+="display:contents;"))),t.whiteSpace!=="nowrap"){let l=t.fontSize*1.2*t.text.length,u=(o||t.calculative.worldRect.width/a)*Math.floor(t.calculative.worldRect.height/a/(t.lineHeight*t.fontSize));l>u&&(s+="justify-content: start;")}i.deleteRule(0),i.deleteRule(0),i.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;${s}}`),i.insertRule(`.input-div div{${n}}`)});U(this,"hideInput",()=>{if(this.externalElements.style.zIndex="5",this.inputParent.style.display==="flex"){this.inputParent.style.display="none";const t=this.store.pens[this.inputDiv.dataset.penId];if(!t)return;if(t.calculative.text=t.text,this.inputDiv.dataset.value=this.inputDiv.innerHTML.replace(/\<div\>/g,`
- `).replace(/\<\/div\>/g,"").replace(/\<br\>/g,"").replace(/ /g," ").replace(/(<([^>]+)>)/gi,""),this.inputDiv.dataset.value=this.convertSpecialCharacter(this.inputDiv.dataset.value),t.onInput)t.onInput(t,this.inputDiv.dataset.value);else if(t.text!==this.inputDiv.dataset.value){const i=[ht(t,!0)];t.text=this.inputDiv.dataset.value,t.calculative.text=t.text,this.inputDiv.dataset.penId=void 0,t.text&&t.textAutoAdjust&&!t.parentId&&Lx(t),Ti(t),this.patchFlags=!0,this.pushHistory({type:bt.Update,pens:[ht(t,!0)],initPens:i}),this.store.emitter.emit("change",t),this.store.emitter.emit("valueUpdate",t)}else t.text===this.inputDiv.dataset.value&&t.calculative.textLines.length==0&&Ti(t);this.initTemplateCanvas([t])}this.inputDiv.dataset.penId=void 0,this.dropdown.style.display="none",this.inputDiv.dataset.isInput="false",this.inputDiv.contentEditable="false",this.render()});U(this,"setDropdownList",t=>{this.clearDropdownList();const i=this.store.pens[this.inputDiv.dataset.penId];if(!this.store.data.locked&&!["tablePlus"].includes(i.name))return;if(this.dropdown.style.display="block",!i||!i.dropdownList){this.dropdown.style.display="none";return}if(!i.dropdownList.length){const r=document.createElement("div");r.innerText="None",r.style.padding="5px 12px",r.style.color="#ddd",this.dropdown.appendChild(r);return}const s=this.inputDiv.innerHTML.replace(/\<div\>/g,`
- `).replace(/\<\/div\>/g,"").replace(/\<br\>/g,"");let n=0;for(const r of i.dropdownList){const a=typeof r=="string"?r:r.text;t&&s?a.includes(s)&&this.dropdownAppendOption(a,n):this.dropdownAppendOption(a,n),++n}if(!this.dropdown.hasChildNodes()){const r=document.createElement("div");r.innerText="None",r.style.padding="5px 12px",r.style.color="#ddd",this.dropdown.appendChild(r)}});U(this,"selectDropdown",t=>{const i=t.target,s=this.store.pens[this.inputDiv.dataset.penId];if(!i||!s||!s.dropdownList)return;const n=+i.dataset.i,r=s.dropdownList[n];if(!r)return;const a=[ht(s,!0)];typeof r=="object"?(this.updateValue(s,{...r}),s.calculative.text=void 0,this.calcActiveRect()):s.text=r+"",this.inputDiv.innerText=s.text,this.hideInput(),this.pushHistory({type:bt.Update,pens:[ht(s,!0)],initPens:a}),this.render(),this.store.emitter.emit("change",s),this.store.emitter.emit("valueUpdate",s)});U(this,"inFitBorder",t=>{let i;const s=this.store.data.width||this.store.options.width,n=this.store.data.height||this.store.options.height;let r={x:(t.x-this.store.data.origin.x)/this.store.data.scale,y:(t.y-this.store.data.origin.y)/this.store.data.scale};const a=this.canvasImage.activeFit;this.externalElements.style.cursor="default",r.y>n*a.y-10&&r.y<n*a.y+10&&(i="top",this.externalElements.style.cursor="row-resize"),r.y>n*(a.y+a.height)-10&&r.y<n*(a.y+a.height)+10&&(i="bottom",this.externalElements.style.cursor="row-resize"),r.x>s*a.x-10&&r.x<s*a.x&&(i="left",this.externalElements.style.cursor="col-resize"),r.x>s*(a.x+a.width)-10&&r.x<s*(a.x+a.width)+10&&(i="right",this.externalElements.style.cursor="col-resize"),this.canvasImage.currentFit=i});this.parent=t,this.parentElement=i,this.store=s,this.canvasTemplate=new I2(i,s),this.canvasTemplate.canvas.style.zIndex="1",this.canvasImageBottom=new Sf(i,s,!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 Sf(i,s),this.canvasImage.canvas.style.zIndex="4",this.magnifierCanvas=new S2(this,i,s),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 ar(i,s),this.tooltip.box.onmouseleave=n=>{this.patchFlags=!0,this.store.lastHover&&(this.store.lastHover.calculative.hover=!1);let r=this.store.data.pens.find(a=>a.calculative.hover===!0);tr(r,!1)},this.popconfirm=new D2(i,s),this.dialog=new P2(i,s),this.title=new ja(i),this.store.options.scroll&&(this.scroll=new hg(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),window==null||window.addEventListener("message",this.onMessage)}listen(){switch(this.externalElements.addEventListener("gesturestart",this.onGesturestart),this.externalElements.ondragover=t=>t.preventDefault(),this.externalElements.ondrop=this.ondrop,this.externalElements.oncontextmenu=t=>t.preventDefault(),this.store.options.interval=50,this.externalElements.ontouchstart=this.ontouchstart,this.externalElements.ontouchmove=this.ontouchmove,this.externalElements.ontouchend=this.ontouchend,this.externalElements.onmousedown=t=>{this.onMouseDown({x:t.offsetX,y:t.offsetY,clientX:t.clientX,clientY:t.clientY,pageX:t.pageX,pageY:t.pageY,ctrlKey:t.ctrlKey||t.metaKey,shiftKey:t.shiftKey,altKey:t.altKey,buttons:t.buttons})},this.externalElements.onmousemove=t=>{t.target===this.externalElements&&this.onMouseMove({x:t.offsetX,y:t.offsetY,clientX:t.clientX,clientY:t.clientY,pageX:t.pageX,pageY:t.pageY,ctrlKey:t.ctrlKey||t.metaKey,shiftKey:t.shiftKey,altKey:t.altKey,buttons:t.buttons})},this.externalElements.onmouseup=t=>{this.onMouseUp({x:t.offsetX,y:t.offsetY,clientX:t.clientX,clientY:t.clientY,pageX:t.pageX,pageY:t.pageY,ctrlKey:t.ctrlKey||t.metaKey,shiftKey:t.shiftKey,altKey:t.altKey,buttons:t.buttons,button:t.button})},this.externalElements.onmouseleave=t=>{this.store.data.pens.forEach(i=>{i.calculative.hover&&(i.calculative.hover=!1)}),this.store.hover&&(this.store.hover.calculative.hover=!1,this.store.hover=void 0),this.render(),t.toElement!==this.tooltip.box&&t.toElement!==this.tooltip.arrowUp&&t.toElement!==this.tooltip.arrowDown&&(this.tooltip.hide(),this.store.lastHover=void 0)},this.externalElements.ondblclick=this.ondblclick,this.externalElements.tabIndex=0,this.externalElements.onblur=()=>{this.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 Ds.Document:document.addEventListener("keydown",this.onkeydown),document.addEventListener("keyup",this.onkeyup);break;case Ds.Canvas:this.externalElements.addEventListener("keydown",this.onkeydown),this.externalElements.addEventListener("keyup",this.onkeyup);break}}splitLine(t,i){const s=t.calculative.worldAnchors,n=s.findIndex(h=>h===i);if([-1,0,s.length-1].includes(n))return;const r=ht(t,!0),a=ht(t,!0),o=It();a.id=o,a.calculative.canvas=this,a.calculative.active=!1,a.calculative.hover=!1;const l=ht(s.slice(0,n+1)),u=ht(s.slice(n)).map(h=>(h.penId=o,h));t.calculative.worldAnchors=l,a.calculative.worldAnchors=u,this.initLineRect(t),this.initLineRect(a),this.store.data.pens.push(a),this.store.pens[o]=a,this.pushHistory({type:bt.Add,pens:[ht(a,!0)],step:2}),this.pushHistory({type:bt.Update,initPens:[r],pens:[ht(t,!0)],step:2})}translateAnchor(t,i){this.movingAnchor.x+=t,this.movingAnchor.y+=i;const s=this.movingAnchor.penId;if(s){const n=this.store.pens[s],r=n.calculative.worldRect;this.movingAnchor.x<r.x?this.movingAnchor.x=r.x:this.movingAnchor.x>r.ex&&(this.movingAnchor.x=r.ex),this.movingAnchor.y<r.y?this.movingAnchor.y=r.y:this.movingAnchor.y>r.ey&&(this.movingAnchor.y=r.ey);const a=rr(this.movingAnchor,r),o=n.anchors.findIndex(l=>l.id===this.movingAnchor.id);n.anchors[o]=a,this.patchFlags=!0}}async fileToPen(t,i){let s="";return this.store.options.uploadFn?s=await this.store.options.uploadFn(t):this.store.options.uploadUrl?s=await Mx(t,this.store.options.uploadUrl,this.store.options.uploadParams,this.store.options.uploadHeaders):s=await Dx(t),new Promise((n,r)=>{const a=new Image;a.onload=()=>{At.htmlElements[s]=a,n({width:a.width,height:a.height,name:i?"gif":"image",image:s})},a.onerror=o=>{r(o)},a.crossOrigin="anonymous",a.src=s})}async dropPens(t,i){var l;this.randomIdObj={};for(const u of t)!u.parentId&&this.randomCombineId(u,t);if(Object.keys(this.randomIdObj).length!==0)for(const u of t)u.type?(u.anchors[0].connectTo=this.randomIdObj[u.anchors[0].connectTo],u.anchors[u.anchors.length-1].connectTo=this.randomIdObj[u.anchors[u.anchors.length-1].connectTo]):(l=u.connectedLines)==null||l.forEach(h=>{h.lineAnchor=this.randomIdObj[h.lineAnchor],h.lineId=this.randomIdObj[h.lineId]});for(const u of t)u.id||(u.id=It()),!u.calculative&&(u.calculative={canvas:this}),this.store.pens[u.id]=u;let s=0,n=0,r=0;for(const u of t)u.parentId||(u.width*=this.store.data.scale,u.height*=this.store.data.scale,u.x=i.x-u.width/2+r,u.y=i.y-u.height/2+n,u.tags&&u.tags.includes("meta3d")&&(u.x=this.store.data.origin.x,u.y=this.store.data.origin.y),u.dataset&&(s%2===0?r=u.width-40*this.store.data.scale:r=0,s++,s%2===0&&(n+=u.height+10*this.store.data.scale)));const a=this.store.data.width||this.store.options.width,o=this.store.data.height||this.store.options.height;if(a&&o){let u={x:this.store.data.origin.x,y:this.store.data.origin.y,width:a*this.store.data.scale,height:o*this.store.data.scale},h=!0;for(const f of t)if(!f.parentId){let g=[{x:f.x,y:f.y},{x:f.x+f.width,y:f.y},{x:f.x,y:f.y+f.height},{x:f.x+f.width,y:f.y+f.height},{x:f.x+f.width/2,y:f.y+f.height/2}];if(f.x===u.x&&f.y===u.y&&f.width===u.width&&f.height===u.height||g.some(v=>Ui(v,u))){h=!1,this.store.options.strictScope&&(f.x<u.x&&(f.x=u.x),f.y<u.y&&(f.y=u.y),f.x+f.width>u.x+u.width&&(f.x=u.x+u.width-f.width),f.y+f.height>u.y+u.height&&(f.y=u.y+u.height-f.height));break}}if(h){console.info("\u753B\u7B14\u5728\u5927\u5C4F\u8303\u56F4\u5916");return}}await this.addPens(t,!0),this.active(t.filter(u=>!u.parentId)),this.render(),this.externalElements.focus()}randomCombineId(t,i,s){let n=null;t.type?(t.anchors[0].connectTo||t.anchors[t.anchors.length-1].connectTo)&&(n=[t.id,t.anchors[0].id,t.anchors[t.anchors.length-1].id]):t.connectedLines&&t.connectedLines.length&&(n=[t.id]),pf(t),n&&(n.length===1?this.randomIdObj[n[0]]=t.id:(this.randomIdObj[n[0]]=t.id,this.randomIdObj[n[1]]=t.anchors[0].id,this.randomIdObj[n[2]]=t.anchors[t.anchors.length-1].id)),t.parentId=s;const r=[];if(Array.isArray(t.children))for(const a of t.children){const o=i.find(l=>l.id===a);o&&r.push(this.randomCombineId(o,i,t.id).id)}return t.children=r,t}async addPens(t,i,s){if(this.beforeAddPens&&await this.beforeAddPens(t)!=!0)return[];const n=[];for(const r of t)this.beforeAddPen&&this.beforeAddPen(r)!=!0||(s&&(r.x=r.x*this.store.data.scale+this.store.data.origin.x,r.y=r.y*this.store.data.scale+this.store.data.origin.y,r.width=r.width*this.store.data.scale,r.height=r.height*this.store.data.scale),this.makePen(r),n.push(r));return this.render(),this.store.emitter.emit("add",n),i&&this.pushHistory({type:bt.Add,pens:ht(n,!0)}),n}getInitPencilLine(t){const{data:i,options:s}=this.store,n=i.scale,r=i.lineWidth||1;return{id:t.penId,name:"line",x:t.x,y:t.y,type:jt.Line,calculative:{canvas:this,pencil:!0,active:!0,worldAnchors:[t],lineWidth:r*n},fromArrow:i.fromArrow||s.fromArrow,toArrow:i.toArrow||s.toArrow,lineWidth:r}}createDrawingLine(t){this.inactive();const{data:i,options:s}=this.store,n=i.scale,r=i.lineWidth||1;return t.penId=It(),{id:t.penId,name:"line",lineName:this.drawingLineName,x:t.x,y:t.y,type:jt.Line,calculative:{canvas:this,active:!0,worldAnchors:[t],lineWidth:r*n},fromArrow:i.fromArrow||s.fromArrow,toArrow:i.toArrow||s.toArrow,lineWidth:r}}addRuleLine(t){const{x:i,y:s,scale:n,origin:r}=this.store.data,a=t.x+i,o=t.y+s;let l=t.x,u=t.y,h=0,f=0,g=0,v=0;if(a<=o&&a<20)l=-i,h=this.width,g=1,t.ctrlKey||(u=Math.round((u-r.y)/(n*10))*(n*10)+r.y);else if(o<a&&o<20)u=-s,f=this.height,v=1,t.ctrlKey||(l=Math.round((l-r.x)/(n*10))*(n*10)+r.x);else return;this.addPen({isRuleLine:!0,type:jt.Line,name:"line",lineName:"line",x:l,y:u,width:h,height:f,color:this.store.options.ruleLineColor,anchors:[{x:0,y:0},{x:g,y:v}]})}clearRuleLines(){this.delete(this.ruleLines)}get ruleLines(){return this.store.data.pens.filter(t=>t.isRuleLine)}alignPenToGrid(t){var s;if(this.store.options.autoAlignGrid&&this.store.data.grid&&!t.type){const n=this.store.data.gridSize||this.store.options.gridSize,{origin:r,scale:a}=this.store.data,{x:o,y:l}=t,u={x:o,y:l},h=this.getPenRect(t),f=parseInt((h.x/n).toFixed()),g=parseInt((h.y/n).toFixed()),v=f*n,y=g*n;u.x=r.x+v*a,u.y=r.y+y*a,Object.assign(t,u),(s=t.onMove)==null||s.call(t,t),this.updatePenRect(t),this.calcActiveRect(),this.getSizeCPs()}}movedActivePens(t){let i=this.getAllFollowersByPens(this.store.active,!1);const s=ht(i,!0),n=this.store.data.gridSize||this.store.options.gridSize,{origin:r,scale:a}=this.store.data,o=this.store.options.autoAlignGrid&&this.store.data.grid;if(i.forEach(g=>{var _;const v=this.movingPens.findIndex(E=>E.id===g.id+ze);if(v<0)return;const{x:y,y:w}=this.movingPens[v],p={x:y,y:w};if(o&&!this.movingPens[v].type){const E=this.getPenRect(this.movingPens[v]),x=parseInt((E.x/n).toFixed()),C=parseInt((E.y/n).toFixed()),S=x*n,D=C*n;p.x=r.x+S*a,p.y=r.y+D*a}Object.assign(g,p),(_=g.onMove)==null||_.call(g,g),this.updatePenRect(g),this.updateLines(g),this.store.emitter.emit("updateLines",g),this.patchFlagsLines.forEach(E=>{E.type&&this.initLineRect(E)}),this.patchFlagsLines.clear(),g.calculative.x=g.x,g.calculative.y=g.y,g.calculative.initRect&&(g.calculative.initRect.x=g.calculative.x,g.calculative.initRect.y=g.calculative.y,g.calculative.initRect.ex=g.calculative.x+g.calculative.width,g.calculative.initRect.ey=g.calculative.y+g.calculative.height),Xd(g),g.parentId&&this.parent.updateRectbyChild(g.calculative.worldRect,g,this.store.pens[g.parentId])}),this.initImageCanvas(this.store.active),this.initTemplateCanvas(this.store.active),!this.dock)return;const{xDock:l,yDock:u}=this.dock;let h;l&&(h=this.store.pens[l.penId]),!h&&u&&(h=this.store.pens[u.penId]);const f=ht(this.store.active,!0);if(t&&this.store.active.length===1&&(h==null?void 0:h.type)===1&&((l==null?void 0:l.anchorId)||(u==null?void 0:u.anchorId))){const g=le(h),v=Vt(h);if(l!=null&&l.anchorId){const y=this.store.pens[this.store.active[0].id+ze].calculative.worldAnchors.find(w=>w.id===l.anchorId);y.x===g.x&&y.y===g.y?(s.push(ht(h,!0)),we(this.store.active[0],y,h,g),f.push(ht(h,!0))):y.x===v.x&&y.y===v.y&&(s.push(ht(h,!0)),we(this.store.active[0],y,h,v),f.push(ht(h,!0)))}else if(u!=null&&u.anchorId){const y=this.store.pens[this.store.active[0].id+ze].calculative.worldAnchors.find(w=>w.id===u.anchorId);y.x===g.x&&y.y===g.y?(s.push(ht(h,!0)),we(this.store.active[0],y,h,g),f.push(ht(h,!0))):y.x===v.x&&y.y===v.y&&(s.push(ht(h,!0)),we(this.store.active[0],y,h,v),f.push(ht(h,!0)))}}o&&(this.calcActiveRect(),this.getSizeCPs()),this.pushHistory({type:bt.Update,pens:f,initPens:s}),this.store.emitter.emit("translatePens",f)}copyMovedPens(){this.copy(this.store.active.map((t,i)=>{const{x:s,y:n}=this.movingPens[i];return this.updateLines(t),{...t,x:s,y:n}})),this.pasteOffset=!1,this.paste()}initImageCanvas(t){t.some(i=>this.hasImage(i,!1))&&this.canvasImage.init(),t.some(i=>this.hasImage(i,!0))&&this.canvasImageBottom.init()}initTemplateCanvas(t){t.some(i=>i.canvasLayer===zt.CanvasTemplate)&&this.canvasTemplate.init()}hasImage(t,i){var s;return t.image&&t.name!=="gif"?i?t.canvasLayer===zt.CanvasImageBottom:t.canvasLayer===zt.CanvasImage:(s=t.children)==null?void 0:s.some(n=>{const r=this.store.pens[n];return r&&this.hasImage(r,i)})}inactive(t){!this.store.active.length||(this.initTemplateCanvas(this.store.active),this.store.active.forEach(i=>{i.calculative.active=void 0,i.calculative.activeAnchor=void 0,i.calculative.hover=!1,pn(i,!1)}),!t&&this.store.emitter.emit("inactive",this.store.active),this.store.active=[],this.activeRect=void 0,this.sizeCPs=void 0,this.store.activeAnchor=void 0,this.patchFlags=!0)}active(t,i=!0){if(this.store.active){i&&this.store.emitter.emit("inactive",this.store.active);for(const s of this.store.active)s.calculative.active=void 0,s.calculative.hover=!1,pn(s,!1)}this.store.active=[],t.forEach(s=>{s.calculative.active=!0,pn(s)}),this.store.active.push(...t),this.activeRect=void 0,this.calcActiveRect(),this.initTemplateCanvas(t),this.patchFlags=!0,i&&this.store.emitter.emit("active",this.store.active)}getSizeCPs(){this.sizeCPs=Zi(this.activeRect);const t=[{x:.5,y:0},{x:1,y:.5},{x:.5,y:1},{x:0,y:.5}],{x:i,y:s,width:n,height:r,rotate:a,center:o}=this.activeRect;t.forEach(l=>{const u={x:l.x*n+i,y:l.y*r+s};Gt(u,a,o),this.sizeCPs.push(u)})}getSpecialAngle(t,i){let s=0;t.x-i.x!==0?(s=Math.atan((i.y-t.y)/(t.x-i.x))*180/Math.PI,t.x<i.x&&(s>0?s-=180:s+=180)):i.y>t.y?s=90:i.y<t.y&&(s=-90),s=Math.round(s/15)*15;let n=Math.sqrt((i.x-t.x)*(i.x-t.x)+(i.y-t.y)*(i.y-t.y));t.x=i.x+Math.cos(s/180*Math.PI)*n,t.y=i.y-Math.sin(s/180*Math.PI)*n}clearHover(){this.hoverType=xt.None,this.store.hover=null,this.store.hoverAnchor=null}inAnchor(t,i,s){var n;if(this.store.hoverAnchor=void 0,this.movingAnchor=void 0,!s||s.locked>Ot.DisableEdit||!(i.type&&i.calculative.active)&&this.store.options.disableAnchor||i.disableAnchor)return xt.None;if((this.mouseDown||this.drawingLine)&&i.name==="line"&&s.connectTo){const r=this.findOne(s.connectTo);if((r==null?void 0:r.calculative)&&!(r!=null&&r.calculative.active)){i=r;const a=r.calculative.worldAnchors.find(o=>o.id===s.anchorId);a&&(s=a)}}if(s.twoWay===Ee.Disable&&i.name!=="line")return xt.None;if(i.name==="line"&&s.connectTo){let r=(n=this.findOne(s.connectTo))==null?void 0:n.anchors.find(a=>a.id===s.anchorId);if(r&&r.twoWay)return xt.None}if(this.drawingLine){if(s.twoWay===Ee.Out)return xt.None}else if(!(this.mouseDown&&this.hoverType===xt.LineAnchor)){if(s.twoWay===Ee.In)return xt.None}if(mn(t,s,this.pointSize,s.penId?this.store.pens[s.penId]:void 0))return s!==this.store.hoverAnchor&&(this.patchFlags=!0),this.store.hoverAnchor=s,this.store.hover=i,i.type?s.connectTo&&!i.calculative.active&&(this.store.hover=this.store.pens[s.connectTo],this.store.hover)?(this.store.hoverAnchor=this.store.hover.calculative.worldAnchors.find(r=>r.id===s.anchorId),this.store.hoverAnchor?(this.externalElements.style.cursor="crosshair",xt.NodeAnchor):xt.None):(this.hotkeyType===Yt.AddAnchor?this.externalElements.style.cursor="vertical-text":this.externalElements.style.cursor="pointer",xt.LineAnchor):(this.hotkeyType===Yt.AddAnchor?this.externalElements.style.cursor="vertical-text":this.externalElements.style.cursor="crosshair",xt.NodeAnchor);if(!this.mouseDown&&i.type){if(i.calculative.active&&s.prev&&mn(t,s.prev,this.pointSize))return this.store.hoverAnchor=s,this.store.hover=i,this.externalElements.style.cursor="pointer",xt.LineAnchorPrev;if(i.calculative.active&&s.next&&mn(t,s.next,this.pointSize))return this.store.hoverAnchor=s,this.store.hover=i,this.externalElements.style.cursor="pointer",xt.LineAnchorNext}return xt.None}resize(t,i){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},ae(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";for(const s of this.store.data.pens)s.isRuleLine&&(s.width?s.height||(s.width=this.width):s.height=this.height),Yi(s);this.render()}clearCanvas(){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()}async addPen(t,i,s,n){if(!(this.beforeAddPens&&await this.beforeAddPens([t])!=!0)&&!(this.beforeAddPen&&this.beforeAddPen(t)!=!0))return n&&(t.x=t.x*this.store.data.scale+this.store.data.origin.x,t.y=t.y*this.store.data.scale+this.store.data.origin.y,t.width=t.width*this.store.data.scale,t.height=t.height*this.store.data.scale),this.makePen(t),this.active([t]),this.render(),s&&this.store.emitter.emit("add",[t]),i&&this.pushHistory({type:bt.Add,pens:[t]}),t}pushHistory(t){var n;if(this.store.data.locked)return;const{origin:i,scale:s}=this.store.data;t.origin=ht(i),t.scale=s,t.type!==bt.Update&&t.pens&&t.pens.forEach(r=>{r.calculative&&(r.calculative.layer=this.store.data.pens.findIndex(a=>a.id===r.id))}),this.store.historyIndex<this.store.histories.length-1&&this.store.histories.splice(this.store.historyIndex+1,this.store.histories.length-this.store.historyIndex-1),(n=t.pens)==null||n.forEach(r=>{let a;if(t.initPens)for(const o of t.initPens)o.id===r.id&&(a=o);if(a)for(const o in r)a[o]==null&&(a[o]=void 0)}),this.store.histories.push(t),this.store.historyIndex=this.store.histories.length-1,this.store.emitter.emit("update",{previous:t.initPens,current:t.pens})}undo(){if(this.store.data.locked||this.store.historyIndex==null||this.store.historyIndex<0)return;const t=this.store.histories[this.store.historyIndex--];this.doEditAction(t,!0);let i=t.step;for(;i>1;){const s=this.store.histories[this.store.historyIndex--];this.doEditAction(s,!0),i--}(t.type==bt.Add||t.type==bt.Delete||t.type==bt.Update)&&this.activeHistory()}redo(){if(this.store.data.locked||this.store.historyIndex==null||this.store.historyIndex>this.store.histories.length-2)return;const t=this.store.histories[++this.store.historyIndex];this.doEditAction(t,!1);let i=t.step;for(;i>1;){const s=this.store.histories[++this.store.historyIndex];this.doEditAction(s,!1),i--}(t.type==bt.Add||t.type==bt.Delete||t.type==bt.Update)&&this.activeHistory()}activeHistory(){let t=this.store.histories[this.store.historyIndex+1];const i=[];if(t&&t.type===bt.Update){t.pens.forEach(n=>{i.push(this.store.pens[n.id])}),this.active(i);return}let s=this.store.histories[this.store.historyIndex];s&&(s.type===bt.Add||s.type===bt.Delete)&&(s.pens.forEach(n=>{i.push(this.store.pens[n.id])}),this.active(i))}doEditAction(t,i){switch(this.inactive(),this.store.hoverAnchor=void 0,this.store.hover=void 0,t.type){case bt.Add:t.pens.forEach(r=>{var l;const a=ht(r,!0),o=this.store.data.pens.findIndex(u=>u.id===a.id);o>-1&&((l=a.onDestroy)==null||l.call(a,this.store.pens[a.id]),this.store.data.pens.splice(o,1),this.store.pens[a.id]=void 0,a.calculative||(a.calculative={}),a.calculative.canvas=this,this.store.animates.delete(a),this.store.animateMap.delete(a))}),t.type=bt.Delete;break;case bt.Update:const s=i?t.initPens:t.pens,n=i?t.pens:t.initPens;s.forEach(r=>{const a=ht(r,!0),o=this.store.data.pens.findIndex(l=>l.id===a.id);if(o>-1){if(a.calculative=this.store.data.pens[o].calculative,this.store.data.pens[o].type&&this.store.data.pens[o].lastConnected){for(let u in this.store.data.pens[o].lastConnected)if(this.store.pens[u]){let h=ht(this.store.data.pens[o].lastConnected[u]);this.store.pens[u].connectedLines=h,a.anchors.forEach(f=>{h.forEach(g=>{f.id===g.lineAnchor&&(f.connectTo=u)})})}}this.store.data.pens[o]=a,this.store.pens[a.id]=a;for(const u in a)(typeof a[u]!="object"||u==="lineDash")&&(a.calculative[u]=a[u]);a.calculative.image=void 0;const l=this.getPenRect(a,t.origin,t.scale);if(this.setPenRect(a,l,!1),this.updateLines(a,!0),a.calculative.canvas.parent.isCombine(a)){let u=n.find(h=>h.id===a.id);Rd.forEach(h=>{a[h]!==u[h]&&this.parent.setValue({id:a.id,[h]:a[h]},{render:!0,doEvent:!1})})}}});break;case bt.Delete:t.pens.reverse().forEach(r=>{var o,l;const a=ht(r,!0);if(a.calculative||(a.calculative={}),this.store.data.pens.splice(((o=a.calculative)==null?void 0:o.layer)!==-1?(l=a.calculative)==null?void 0:l.layer:this.store.data.pens.length,0,a),this.store.pens[a.id]=a,a.type&&a.lastConnected)for(let u in a.lastConnected)this.store.pens[u]&&(this.store.pens[u].connectedLines=a.lastConnected[u]);a.calculative.canvas=this}),t.pens.reverse().forEach(r=>{const a=this.store.pens[r.id],o=this.getPenRect(a,t.origin,t.scale);this.setPenRect(a,o,!1),a.calculative.image=void 0,a.calculative.backgroundImage=void 0,a.calculative.strokeImage=void 0,this.loadImage(a)}),t.type=bt.Add;break;case bt.Replace:{const r=i?t.initPens:t.pens;(i?t.pens:t.initPens).forEach(o=>{var h;const l=ht(o,!0);if(this.store.data.pens.findIndex(f=>f.id===l.id)>-1){(h=l.onDestroy)==null||h.call(l,this.store.data.pens.find(g=>g.id===l.id));const f=this.store.data.pens.findIndex(g=>g.id===l.id);this.store.data.pens.splice(f,1),this.store.pens[l.id]=void 0,l.calculative||(l.calculative={}),l.calculative.canvas=this,this.store.animates.delete(l),this.store.animateMap.delete(l)}}),r.reverse().forEach(o=>{var u,h;const l=ht(o,!0);if(l.calculative||(l.calculative={}),this.store.data.pens.splice(((u=l.calculative)==null?void 0:u.layer)!==-1?(h=l.calculative)==null?void 0:h.layer:this.store.data.pens.length,0,l),this.store.pens[l.id]=l,l.type&&l.lastConnected)for(let f in l.lastConnected)this.store.pens[f]&&(this.store.pens[f].connectedLines=l.lastConnected[f]);l.calculative.canvas=this}),r.reverse().forEach(o=>{const l=this.store.data.pens.find(h=>h.id===o.id),u=this.getPenRect(l,t.origin,t.scale);this.setPenRect(l,u,!1),l.calculative.image=void 0,l.calculative.backgroundImage=void 0,l.calculative.strokeImage=void 0,this.loadImage(l)}),t.type=bt.Replace;break}}if(t.type===bt.Update){let s=[...t.pens,...t.initPens];this.initImageCanvas(s),this.initTemplateCanvas(s)}else this.initImageCanvas(t.pens),this.initTemplateCanvas(t.pens);this.parent.onSizeUpdate(),this.render(),this.store.emitter.emit(i?"undo":"redo",t)}makePen(t){var n;if(t.id||(t.id=It()),Math.abs(this.store.lastScale-this.store.data.scale)<1e-4&&this.store.sameTemplate&&this.store.templatePens[t.id]&&t.canvasLayer===zt.CanvasTemplate){t=this.store.templatePens[t.id],this.store.data.pens.push(t),this.updatePenRect(t);return}if(t.copyIndex?(this.store.data.pens.splice(t.copyIndex+1,0,t),delete t.copyIndex):this.store.data.pens.push(t),this.store.pens[t.id]=t,t.path){!t.pathId&&(t.pathId=It());const r=this.store.data.paths;!r[t.pathId]&&(r[t.pathId]=t.path),t.path=void 0}t.lineWidth==null&&(t.lineWidth=1);const{fontSize:i,lineHeight:s}=this.store.options;t.fontSize?t.fontSize<0&&(t.fontSize=0):t.fontSize=i>=0?i:12,t.lineHeight||(t.lineHeight=s),t.image&&t.name!=="gif"&&t.canvasLayer===void 0&&(t.isBottom?t.canvasLayer=zt.CanvasImageBottom:t.canvasLayer=zt.CanvasImage,delete t.isBottom),t.template&&(t.canvasLayer=zt.CanvasTemplate),t.calculative={canvas:this,singleton:(n=t.calculative)==null?void 0:n.singleton},(t.video||t.audio)&&(t.calculative.onended=r=>{this.nextAnimate(r)});for(const r in t)(typeof t[r]!="object"||r==="lineDash")&&(t.calculative[r]=t[r]);if(t.calculative.image=void 0,t.calculative.backgroundImage=void 0,t.calculative.strokeImage=void 0,!t.anchors&&At.anchors[t.name]&&(t.anchors||(t.anchors=[]),At.anchors[t.name](t)),!t.anchors){const r=ht(this.store.options.defaultAnchors);r.forEach((a,o)=>{a.id=`${o}`,a.penId=t.id}),t.anchors=r}this.updatePenRect(t),!t.anchors&&t.calculative.worldAnchors&&(t.anchors=t.calculative.worldAnchors.map(r=>rr(r,t.calculative.worldRect))),!t.rotate&&(t.rotate=0),this.loadImage(t),this.parent.penNetwork(t)}drawline(t){var i;!this.drawingLine||((i=this[this.drawingLineName])==null||i.call(this,this.store,this.drawingLine,t),this.store.path2dMap.set(this.drawingLine,At.path2dDraws.line(this.drawingLine)),this.patchFlags=!0)}initLineRect(t){var r;if(!t)return;if(!((r=t.calculative.worldAnchors)!=null&&r.length)){this._del([t]);return}if(!isFinite(t.x)||!isFinite(t.x)||t.x==null||t.y==null)return;const i=Zl(t);t.parentId||Object.assign(t,i);const{fontSize:s,lineHeight:n}=this.store.options;t.fontSize||(t.fontSize=s>=0?s:12,t.calculative.fontSize=t.fontSize*this.store.data.scale),t.lineHeight||(t.lineHeight=n,t.calculative.lineHeight=t.lineHeight),ee(i),t.calculative.worldRect=i,gc(t,i),Ti(t),Yi(t),t.calculative&&(t.calculative.gradientAnimatePath=void 0),this.store.path2dMap.set(t,At.path2dDraws[t.name](t)),t.calculative.worldAnchors&&(t.anchors=t.calculative.worldAnchors.map(a=>rr(a,t.calculative.worldRect)))}drawingPencil(){ug(this.store),this.pencil=!0,this.externalElements.style.cursor="crosshair"}stopPencil(){this.pencil=!1,this.pencilLine=void 0,this.externalElements.style.cursor="default"}async finishDrawline(t){if(!this.drawingLine)return;const i=le(this.drawingLine);let s=Vt(this.drawingLine);if(s.isTemp&&(this.drawingLine.calculative.worldAnchors.pop(),s=Vt(this.drawingLine)),!t&&(!s.connectTo&&this.drawingLine.calculative.worldAnchors.pop(),le(this.drawingLine)===this.drawingLine.calculative.activeAnchor)){this.drawingLine=void 0,this.render();return}if(!i.connectTo||!s.connectTo){if(this.store.options.disableEmptyLine){i.connectTo&&(this.store.pens[i.connectTo].connectedLines=this.store.pens[i.connectTo].connectedLines.filter(a=>a.lineId!==this.drawingLine.id)),this.drawingLine=void 0,this.render();return}}else if(this.store.options.disableRepeatLine&&this.store.data.pens.find(o=>{if(o.type){const l=le(o),u=Vt(o);return of(l,i)&&of(u,s)}})){this.drawingLine=void 0,this.render();return}const n=Zl(this.drawingLine);Object.assign(this.drawingLine,n),this.drawingLine.calculative.worldRect=n,this.drawingLine.calculative.activeAnchor=Vt(this.drawingLine),this.store.activeAnchor=this.drawingLine.calculative.activeAnchor,(!this.beforeAddPens||await this.beforeAddPens([this.drawingLine]))&&(!this.beforeAddPen||this.beforeAddPen(this.drawingLine))&&(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:bt.Add,pens:ht([this.drawingLine],!0)})),this.store.path2dMap.set(this.drawingLine,At.path2dDraws[this.drawingLine.name](this.drawingLine)),this.drawingLine=void 0,this.drawingLineName=void 0,this.render()}async finishPencil(){if(this.pencilLine){const t=Ql(this.pencilLine.calculative.worldAnchors,10,0,this.pencilLine.calculative.worldAnchors.length-1);let i=le(this.pencilLine);t.unshift({id:i.id,penId:i.penId,x:i.x,y:i.y}),i=Vt(this.pencilLine),t.push({id:i.id,penId:i.penId,x:i.x,y:i.y}),this.pencilLine.calculative.worldAnchors=y2(t),this.pencilLine.calculative.worldAnchors.length>1&&(this.pencilLine.calculative.pencil=!1,this.store.path2dMap.set(this.pencilLine,At.path2dDraws[this.pencilLine.name](this.pencilLine)),(!this.beforeAddPens||await this.beforeAddPens([this.pencilLine]))&&(!this.beforeAddPen||this.beforeAddPen(this.pencilLine))&&(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:bt.Add,pens:ht([this.pencilLine],!0)}))),this.pencilLine=void 0,this.render()}}firefoxLoadSvg(t){const i=new Image,s=new XMLHttpRequest;s.open("GET",t.image,!0),s.onload=()=>{const a=new DOMParser().parseFromString(s.responseText,"text/xml").getElementsByTagName("svg")[0],{width:o,height:l}=t.calculative.worldRect;a.setAttribute("width",`${o}px`),a.setAttribute("height",`${l}px`);const h="data:image/svg+xml;base64,"+btoa(unescape(encodeURIComponent(new XMLSerializer().serializeToString(a))));i.src=h,i.onload=()=>{t.calculative.img=i,t.calculative.imgNaturalWidth=i.naturalWidth||t.iconWidth,t.calculative.imgNaturalHeight=i.naturalHeight||t.iconHeight,At.htmlElements[t.image]=i,this.imageLoaded(),t.canvasLayer===zt.CanvasTemplate&&this.templateImageLoaded()}},s.send()}loadImage(t){if(t.image!==t.calculative.image||!t.calculative.img){if(t.calculative.img=void 0,t.image)if(At.htmlElements[t.image]){const i=At.htmlElements[t.image];t.calculative.img=i,t.calculative.imgNaturalWidth=i.naturalWidth||t.iconWidth,t.calculative.imgNaturalHeight=i.naturalHeight||t.iconHeight,this.imageLoaded(),t.canvasLayer===zt.CanvasTemplate&&this.templateImageLoaded()}else if(navigator.userAgent.includes("Firefox")&&t.image.endsWith(".svg"))this.firefoxLoadSvg(t);else{const i=new Image;i.crossOrigin=t.crossOrigin==="undefined"?void 0:t.crossOrigin||"anonymous",i.src=t.image,this.store.options.cdn&&!(t.image.startsWith("http")||t.image.startsWith("//")||t.image.startsWith("data:image"))&&(i.src=this.store.options.cdn+t.image),i.onload=()=>{t.calculative.img=i,t.calculative.imgNaturalWidth=i.naturalWidth||t.iconWidth,t.calculative.imgNaturalHeight=i.naturalHeight||t.iconHeight,At.htmlElements[t.image]=i,this.imageLoaded(),t.canvasLayer===zt.CanvasTemplate&&this.templateImageLoaded()}}t.calculative.image=t.image}if(t.backgroundImage!==t.calculative.backgroundImage){if(t.calculative.backgroundImg=void 0,t.backgroundImage)if(At.htmlElements[t.backgroundImage]){const i=At.htmlElements[t.backgroundImage];t.calculative.backgroundImg=i}else{const i=new Image;i.crossOrigin="anonymous",i.src=t.backgroundImage,this.store.options.cdn&&!(t.backgroundImage.startsWith("http")||t.backgroundImage.startsWith("//")||t.backgroundImage.startsWith("data:image"))&&(i.src=this.store.options.cdn+t.backgroundImage),i.onload=()=>{t.calculative.backgroundImg=i,At.htmlElements[t.backgroundImage]=i,this.imageLoaded(),t.canvasLayer===zt.CanvasTemplate&&this.templateImageLoaded()}}t.calculative.backgroundImage=t.backgroundImage}if(t.strokeImage!==t.calculative.strokeImage){if(t.calculative.strokeImg=void 0,t.strokeImage)if(At.htmlElements[t.strokeImage]){const i=At.htmlElements[t.strokeImage];t.calculative.strokeImg=i}else{const i=new Image;i.crossOrigin="anonymous",i.src=t.strokeImage,this.store.options.cdn&&!(t.strokeImage.startsWith("http")||t.strokeImage.startsWith("//")||t.strokeImage.startsWith("data:image"))&&(i.src=this.store.options.cdn+t.strokeImage),i.onload=()=>{t.calculative.strokeImg=i,At.htmlElements[t.strokeImage]=i,this.imageLoaded(),t.canvasLayer===zt.CanvasTemplate&&t.name!=="gif"&&this.templateImageLoaded()}}t.calculative.strokeImage=t.strokeImage}}imageLoaded(){this.imageTimer&&clearTimeout(this.imageTimer),this.imageTimer=setTimeout(()=>{this.canvasImage.init(),this.canvasImageBottom.init(),this.render()},100)}templateImageLoaded(){this.templateImageTimer&&clearTimeout(this.templateImageTimer),this.templateImageTimer=setTimeout(()=>{this.canvasTemplate.init(),this.render()},100)}setCalculativeByScale(t){const i=this.store.data.scale;t.calculative.lineWidth=t.lineWidth*i,t.calculative.fontSize=t.fontSize*i,t.fontSize<1&&t.fontSize>0&&(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.calculative.worldRect.width:t.textLeft*i,t.calculative.textTop=t.textTop<1&&t.textTop>-1?t.textTop*t.calculative.worldRect.height:t.textTop*i,t.type===jt.Line&&t.borderWidth&&(t.calculative.borderWidth=t.borderWidth*i)}updatePenRect(t,{worldRectIsReady:i,playingAnimate:s}={}){i?Sa(t):Kd(t),s||this.setCalculativeByScale(t),En(t),hf(this.store.pens,t),Ti(t),Yi(t),At.path2dDraws[t.name]&&this.store.path2dMap.set(t,At.path2dDraws[t.name](t)),t.calculative.patchFlags=!0,this.patchFlags=!0,t.children&&t.children.forEach(n=>{const r=this.store.pens[n];r&&this.updatePenRect(r,{worldRectIsReady:!1})}),t.type&&this.initLineRect(t),t.calculative.gradientTimer&&clearTimeout(t.calculative.gradientTimer),t.calculative.gradientTimer=setTimeout(()=>{t.calculative.lineGradient&&(t.calculative.lineGradient=null),t.calculative.gradient&&(t.calculative.gradient=null),t.calculative.radialGradient&&(t.calculative.radialGradient=null),this.patchFlags=!0,t.calculative.gradientTimer=void 0},50)}initGlobalStyle(){const t={},i={},s={};Cx.forEach(r=>{var a;if(this.store.options[r]!==void 0&&(t[r]=this.store.options[r]),this.store.data[r]!==void 0&&(i[r]=this.store.data[r]),this.store.data.theme){const o=(a=this.store.theme[this.store.data.theme])==null?void 0:a[r];o!==void 0&&(s[r]=o)}}),this.store.styles={};const n=Qn.getThemeObj(this.store.data.theme);Object.assign(this.store.styles,t,i,s,n)}translate(t=0,i=0){if(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){let s=qi(this.store.options.padding);const n=this.store.data.width||this.store.options.width,r=this.store.data.height||this.store.options.height;this.width<(n+s[1]+s[3])*this.store.data.scale&&(this.store.data.x+this.store.data.origin.x>s[3]*this.store.data.scale&&(this.store.data.x=s[3]*this.store.data.scale-this.store.data.origin.x),this.store.data.x+this.store.data.origin.x+n*this.store.data.scale<this.width-s[1]*this.store.data.scale&&(this.store.data.x=this.width-s[1]*this.store.data.scale-(this.store.data.origin.x+n*this.store.data.scale))),this.height<(r+s[0]+s[2])*this.store.data.scale&&(this.store.data.y+this.store.data.origin.y>s[0]*this.store.data.scale&&(this.store.data.y=s[0]*this.store.data.scale-this.store.data.origin.y),this.store.data.y+this.store.data.origin.y+r*this.store.data.scale<this.height-s[2]*this.store.data.scale&&(this.store.data.y=this.height-s[2]*this.store.data.scale-(this.store.data.origin.y+r*this.store.data.scale)))}this.store.data.asyncTranslate?(clearTimeout(this.transTimeout),this.transTimeout=setTimeout(()=>{this.canvasTemplate.init(),this.canvasImage.init(),this.canvasImageBottom.init(),this.render()},300)):(this.canvasTemplate.init(),this.canvasImage.init(),this.canvasImageBottom.init(),this.render()),this.store.emitter.emit("translate",{x:this.store.data.x,y:this.store.data.y}),this.tooltip.translate(t,i),this.scroll&&this.scroll.isShow&&this.scroll.translate(t,i),this.onMovePens()}onMovePens(){var i;const t=this.parent.map;t&&t.isShow&&t.setView();for(const s of this.store.data.pens)Yi(s),(i=s.onMove)==null||i.call(s,s),s.isRuleLine&&(s.width?s.height||(s.x=-this.store.data.x):s.y=-this.store.data.y,this.updatePenRect(s))}scale(t,i={x:0,y:0}){var o;const s=this.store.data.minScale||this.store.options.minScale,n=this.store.data.maxScale||this.store.options.maxScale;if(!(t>=s&&t<=n))return;this.calibrateMouse(i);const r=t/this.store.data.scale;this.store.data.scale=t,this.store.data.center=i,(o=this.store.clipboard)!=null&&o.pos&&Na(this.store.clipboard.pos,r,i),Na(this.store.data.origin,r,i),this.store.data.pens.forEach(l=>{if(!l.parentId){if(gn(l,r,i),l.onScale&&l.onScale(l),l.isRuleLine){const u=1/r,h=l.calculative.worldRect.center;l.width&&l.height||gn(l,u,h)}this.updatePenRect(l,{worldRectIsReady:!0}),this.execPenResize(l)}}),this.onMovePens(),this.calcActiveRect(),this.canvasTemplate.init(),this.canvasImage.init(),this.canvasImageBottom.init();const a=this.parent.map;a&&a.isShow&&a.setView(),this.render(),this.store.emitter.emit("scale",this.store.data.scale)}templateScale(t,i={x:0,y:0}){const{minScale:s,maxScale:n}=this.store.options;if(!(t>=s&&t<=n))return;const r=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(a=>{if(!a.parentId){if(gn(a,r,i),a.onScale&&a.onScale(a),a.isRuleLine){const o=r>1?1:1/r/r,l=a.calculative.worldRect.center;a.width&&a.height||gn(a,o,l)}this.execPenResize(a)}}),this.calcActiveRect()}rotatePens(t){this.initPens||(this.initPens=ht(this.getAllByPens(this.store.active))),this.activeRect.rotate=ci(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);const i=this.activeRect.rotate-this.lastRotate;for(const s of this.store.active){if(s.parentId)return;this.rotatePen(s,i,this.activeRect),s.onRotate&&s.onRotate(s),this.updateLines(s)}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(()=>{this.timer=void 0,this.pushHistory({type:bt.Update,pens:ht(this.getAllByPens(this.store.active)),initPens:this.initPens}),this.initPens=void 0},200)}resizePens(t){if(this.initPens||(this.initPens=ht(this.store.active,!0)),!this.initActiveRect){this.initActiveRect=ht(this.activeRect);return}const i={x:this.mouseDown.x,y:this.mouseDown.y},s={x:t.x,y:t.y};let n=s.x-i.x,r=s.y-i.y;const a=ht(this.initActiveRect);if(wf(a,n,r,this.resizeIndex),ee(a),!this.store.options.disableDock){this.clearDock();const v=this.customResizeDock||p_;this.dock=v(this.store,a,this.store.active,this.resizeIndex);const{xDock:y,yDock:w}=this.dock;if(y){n+=y.step;const p=this.store.pens[y.penId];p.calculative.isDock=!0}if(w){r+=w.step;const p=this.store.pens[w.penId];p.calculative.isDock=!0}}const o=this.activeRect.width,l=this.activeRect.height;let u=n-this.lastOffsetX,h=r-this.lastOffsetY;if(this.lastOffsetX=n,this.lastOffsetY=r,(t.ctrlKey||this.initPens.length===1&&this.initPens[0].ratio)&&(h=([1,3].includes(this.resizeIndex)?-1:1)*(u*l)/o),this.activeRect.ratio=this.initPens[0].ratio,wf(this.activeRect,u,h,this.resizeIndex),this.store.options.strictScope){const v=this.store.data.width||this.store.options.width,y=this.store.data.height||this.store.options.height;if(v&&y){let w={x:this.store.data.origin.x,y:this.store.data.origin.y,width:v*this.store.data.scale,height:y*this.store.data.scale};this.activeRect.x<w.x&&(this.activeRect.width=this.activeRect.width-(w.x-this.activeRect.x),this.activeRect.x=w.x),this.activeRect.y<w.y&&(this.activeRect.height=this.activeRect.height-(w.y-this.activeRect.y),this.activeRect.y=w.y),this.activeRect.x+this.activeRect.width>w.x+w.width&&(this.activeRect.width=this.activeRect.width-(this.activeRect.x+this.activeRect.width-(w.x+w.width)),this.activeRect.x=w.x+w.width-this.activeRect.width,this.activeRect.ex=this.activeRect.x+this.activeRect.width),this.activeRect.y+this.activeRect.height>w.y+w.height&&(this.activeRect.height=this.activeRect.height-(this.activeRect.y+this.activeRect.height-(w.y+w.height)),this.activeRect.y=w.y+w.height-this.activeRect.height,this.activeRect.ey=this.activeRect.y+this.activeRect.height)}}ee(this.activeRect);const f=this.activeRect.width/o,g=this.activeRect.height/l;this.store.active.forEach((v,y)=>{v.calculative.worldRect.x=this.activeInitPos[y].x*this.activeRect.width+this.activeRect.x,v.calculative.worldRect.y=this.activeInitPos[y].y*this.activeRect.height+this.activeRect.y,v.calculative.worldRect.width*=f,v.calculative.iconWidth&&(v.calculative.iconWidth*=f),v.calculative.worldRect.height*=g,v.calculative.iconHeight&&(v.calculative.iconHeight*=g),ae(v.calculative.worldRect),ee(v.calculative.worldRect),this.updatePenRect(v,{worldRectIsReady:!0}),this.execPenResize(v),this.updateLines(v)}),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(()=>{this.timer=void 0,this.pushHistory({type:bt.Update,pens:ht(this.store.active,!0),initPens:this.initPens}),this.initPens=void 0},200)}movePens(t){var o,l;if(!this.activeRect||this.store.data.locked)return;if(!this.initActiveRect){this.initActiveRect=ht(this.activeRect);return}if(!this.store.options.moveConnectedLine&&!this.canMoveLine&&this.store.active.length===1&&(((o=this.store.active[0].anchors[0])==null?void 0:o.connectTo)||((l=this.store.active[0].anchors[this.store.active[0].anchors.length-1])==null?void 0:l.connectTo))||(this.movingPens||(this.initMovingPens(),this.store.active.forEach(u=>{tr(u,!1)}),this.store.hover=void 0),!this.mouseDown))return;let i=t.x-this.mouseDown.x,s=t.y-this.mouseDown.y;t.shiftKey&&!t.ctrlKey&&(s=0),t.ctrlKey&&(i=0);const n=ht(this.initActiveRect);Ms(n,i,s);let r=!1;if(this.store.options.strictScope){const u=this.store.data.width||this.store.options.width,h=this.store.data.height||this.store.options.height;if(u&&h){let f={x:this.store.data.origin.x,y:this.store.data.origin.y,width:u*this.store.data.scale,height:h*this.store.data.scale};n.x<f.x&&(n.x=f.x,r=!0),n.y<f.y&&(n.y=f.y,r=!0),n.x+n.width>f.x+f.width&&(n.x=f.x+f.width-n.width,r=!0),n.y+n.height>f.y+f.height&&(n.y=f.y+f.height-n.height,r=!0)}}const a={x:n.x-this.activeRect.x,y:n.y-this.activeRect.y};if(!this.store.options.disableDock&&!r){this.clearDock();const u=this.customMoveDock||m_;this.dock=u(this.store,n,this.movingPens,a);const{xDock:h,yDock:f}=this.dock;let g;h&&(a.x+=h.step,g=this.store.pens[h.penId],g.calculative.isDock=!0),f&&(a.y+=f.step,g=this.store.pens[f.penId],g.calculative.isDock=!0)}this.translatePens(this.movingPens,a.x,a.y,!0)}changeIdsByMoving(t,i){t.id+=ze,t.parentId&&i.find(s=>s.id===t.parentId)&&(t.parentId+=ze),t.children&&(t.children=t.children.map(s=>s+ze)),t.connectedLines&&(t.connectedLines=t.connectedLines.map(s=>(i.find(n=>n.id===s.lineId)&&(s.lineId+=ze),s))),t.type&&t.calculative.worldAnchors&&(t.calculative.worldAnchors=t.calculative.worldAnchors.map(s=>(s.connectTo&&i.find(n=>n.id===s.connectTo)&&(s.connectTo+=ze),s)))}initMovingPens(){var s,n;if(!this.store.options.moveConnectedLine&&!this.canMoveLine)for(let r=0;r<this.store.active.length;r++){const a=this.store.active[r];(((s=a.anchors[0])==null?void 0:s.connectTo)||((n=a.anchors[a.anchors.length-1])==null?void 0:n.connectTo))&&(this.store.active.splice(r,1),a.calculative.active=void 0,--r)}this.movingPens=ht(this.store.active,!0),this.movingPens=this.getAllFollowersByPens(this.movingPens);const t=this.getAllByPens(this.movingPens),i=ht(t,!0);t.forEach(r=>{this.changeIdsByMoving(r,i),this.store.pens[r.id]=r,r.calculative.canvas=this;const a={globalAlpha:.5};r.lineWidth===0&&(a.lineWidth=1),(r.name.endsWith("Dom")||Td.includes(r.name)||this.store.options.domShapes.includes(r.name)||r.image)&&(a.name="rectangle",a.onDestroy=void 0),this.updateValue(r,a),r.calculative.image=void 0})}moveLineAnchor(t,i){var o,l,u,h,f;if(!this.activeRect||this.store.data.locked)return;if(this.initPens||(this.initPens=ht(this.store.active,!0)),(o=this.store.activeAnchor)!=null&&o.connectTo){const g=this.store.pens[this.store.activeAnchor.connectTo];xn(g,Ls(g,this.store.activeAnchor.anchorId),this.store.pens[this.store.activeAnchor.penId],this.store.activeAnchor)}let s=(l=this.store.activeAnchor)==null?void 0:l.id,n=(h=(u=this.store.pens[this.store.activeAnchor.penId])==null?void 0:u.connectedLines)==null?void 0:h.filter(g=>g.anchor===s);n&&n.length>0&&n.forEach(g=>{const v=this.store.pens[g.lineId];xn(this.store.pens[this.store.activeAnchor.penId],this.store.activeAnchor,v,Ls(v,g.lineAnchor))});const r=this.store.active[0];le(r);const a=Vt(r);if(r.lineName==="polyline"&&!i.shiftKey)v2(r,this.store.activeAnchor,t);else{let g=0,v=0;if(r.lineName==="line"){let y=r.calculative.worldAnchors.findIndex(p=>p.id===this.store.activeAnchor.id);y===0&&(y=2);let w=r.calculative.worldAnchors[y-1];if(i.ctrlKey&&i.shiftKey){let p=ht(t);this.getSpecialAngle(p,w),g=p.x-this.store.activeAnchor.x,v=p.y-this.store.activeAnchor.y}else if(!i.ctrlKey&&i.shiftKey){let p={x:t.x,y:w.y};g=p.x-this.store.activeAnchor.x,v=p.y-this.store.activeAnchor.y}else if(i.ctrlKey&&!i.shiftKey){let p={x:w.x,y:t.y};g=p.x-this.store.activeAnchor.x,v=p.y-this.store.activeAnchor.y}else g=t.x-this.store.activeAnchor.x,v=t.y-this.store.activeAnchor.y}else!i.ctrlKey&&i.shiftKey?(g=t.x-this.store.activeAnchor.x,v=0):i.ctrlKey&&!i.shiftKey?(g=0,v=t.y-this.store.activeAnchor.y):(g=t.x-this.store.activeAnchor.x,v=t.y-this.store.activeAnchor.y);nr(this.store.activeAnchor,g,v),this.store.hover&&this.store.hoverAnchor&&this.store.hoverAnchor.penId!==this.store.activeAnchor.penId&&(this.store.hoverAnchor.type===ji.Line?(g=t.x-this.store.activeAnchor.x,v=t.y-this.store.activeAnchor.y,va(this.store.activeAnchor,this.store.hoverAnchor,this.store)):(g=this.store.hoverAnchor.x-this.store.activeAnchor.x,v=this.store.hoverAnchor.y-this.store.activeAnchor.y),nr(this.store.activeAnchor,g,v),a.prev=void 0,r.lineName!=="polyline"&&((f=this[r.lineName])==null||f.call(this,this.store,r)))}this.patchFlagsLines.add(r),this.store.path2dMap.set(r,At.path2dDraws[r.name](r)),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(()=>{this.timer=void 0,this.pushHistory({type:bt.Update,pens:ht(this.store.active,!0),initPens:this.initPens}),this.initPens=void 0},500)}moveLineAnchorPrev(t){if(!this.activeRect||this.store.data.locked||!this.store.activeAnchor)return;if(this.initPens||(this.initPens=ht(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,Gt(this.store.activeAnchor.next,180,this.store.activeAnchor);else if(this.store.activeAnchor.prevNextType===Fs.Bilateral&&this.prevAnchor){const s=ci(t,this.store.activeAnchor),n=ci(this.prevAnchor,this.store.activeAnchor);this.store.activeAnchor.next.x=this.nextAnchor.x,this.store.activeAnchor.next.y=this.nextAnchor.y,Gt(this.store.activeAnchor.next,s-n,this.store.activeAnchor)}}const i=this.store.active[0];this.patchFlagsLines.add(i),this.store.path2dMap.set(i,At.path2dDraws[i.name](i)),this.render(),this.timer&&clearTimeout(this.timer),this.timer=setTimeout(()=>{this.timer=void 0,this.pushHistory({type:bt.Update,pens:ht(this.store.active,!0),initPens:this.initPens}),this.initPens=void 0},200)}moveLineAnchorNext(t){if(!this.activeRect||this.store.data.locked||!this.store.activeAnchor)return;if(this.initPens||(this.initPens=ht(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,Gt(this.store.activeAnchor.prev,180,this.store.activeAnchor);else if(this.store.activeAnchor.prevNextType===Fs.Bilateral&&this.nextAnchor){const s=ci(t,this.store.activeAnchor),n=ci(this.nextAnchor,this.store.activeAnchor);this.store.activeAnchor.prev.x=this.prevAnchor.x,this.store.activeAnchor.prev.y=this.prevAnchor.y,Gt(this.store.activeAnchor.prev,s-n,this.store.activeAnchor)}}const i=this.store.active[0];this.patchFlagsLines.add(i),this.store.path2dMap.set(i,At.path2dDraws[i.name](i)),this.render(),this.timer&&clearTimeout(this.timer),this.timer=setTimeout(()=>{this.timer=void 0,this.pushHistory({type:bt.Update,pens:ht(this.store.active,!0),initPens:this.initPens}),this.initPens=void 0},200)}async setAnchor(t){var n;const i=[ht(this.store.hover,!0)],s=this.store.hover;if(this.store.hoverAnchor){if(this.beforeRemoveAnchor&&!await this.beforeRemoveAnchor(s,this.store.hoverAnchor))return;s.type===jt.Line&&((n=s.calculative.worldAnchors)==null?void 0:n.length)<=2?this.delete([s]):(a_(s,this.store.hoverAnchor),s.type===jt.Line&&this.initLineRect(s)),this.store.hoverAnchor=void 0,this.store.activeAnchor=void 0,this.externalElements.style.cursor="default"}else if(s){if(this.beforeAddAnchor&&!await this.beforeAddAnchor(s,this.store.pointAt))return;if(s.type===jt.Line){this.store.activeAnchor=r_(s,this.store.pointAt,this.store.pointAtIndex),this.initLineRect(s);const r={x:t.x,y:t.y};this.getHover(r)}else{const r={id:It(),x:t.x,y:t.y};this.store.activeAnchor=n_(s,r)}}this.hotkeyType=Yt.None,this.render(),s&&this.pushHistory({type:bt.Update,pens:[ht(s,!0)],initPens:i})}checkDisconnect(t,i){if(t.id.indexOf(ze)>0){const s=t.id;t=this.store.pens[s.replace(ze,"")]}t.anchors.forEach(s=>{if(s.connectTo&&!i.find(n=>n.id===s.connectTo||n.id===s.connectTo+ze)){const n=this.store.pens[s.connectTo];if(!n||n.type)return;xn(n,Ls(n,s.anchorId),t,s)}})}translatePens(t=this.store.active,i,s,n){if(!t||!t.length||t.some(l=>{if(l.locked>=Ot.DisableMove)return!0}))return;const a=!n&&ht(t,!0);this.activeRect&&Ms(this.activeRect,i,s);const o=this.getAllByPens(t);t.forEach(l=>{var u,h;if(!(l.locked>=Ot.DisableMove)){if(l.type===jt.Line){if(!this.store.options.moveConnectedLine&&!this.canMoveLine||l.isRuleLine)return;uf(l,i,s),this.checkDisconnect(l,o),this.store.path2dMap.set(l,At.path2dDraws[l.name](l)),n||(this.initLineRect(l),(u=l.connectedLines)==null||u.forEach(f=>{const g=this.store.pens[f.lineId];this.initLineRect(g)}))}else Ms(l.calculative.worldRect,i,s),this.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);this.updateLines(l),(h=l.onMove)==null||h.call(l,l)}}),this.activeRect&&this.getSizeCPs(),this.render(),this.tooltip.translate(i,s),n||(this.pushHistory({type:bt.Update,pens:ht(t,!0),initPens:a}),this.initImageCanvas(t),this.initTemplateCanvas(t),this.store.emitter.emit("translatePens",t)),this.store.emitter.emit("translatingPens",t)}templateTranslatePens(t=this.store.active,i,s){if(!t||!t.length)return;const n=this.getAllByPens(t);t.forEach(r=>{var a;if(r.type===jt.Line){if(!this.store.options.moveConnectedLine&&!this.canMoveLine)return;uf(r,i,s),this.checkDisconnect(r,n),this.store.path2dMap.set(r,At.path2dDraws[r.name](r))}else Ms(r.calculative.worldRect,i,s),this.updatePenRect(r,{worldRectIsReady:!0}),r.calculative.x=r.x,r.calculative.y=r.y,r.calculative.initRect&&(r.calculative.initRect.x=r.calculative.x,r.calculative.initRect.y=r.calculative.y,r.calculative.initRect.ex=r.calculative.x+r.calculative.width,r.calculative.initRect.ey=r.calculative.y+r.calculative.height);(a=r.onMove)==null||a.call(r,r)})}calcAutoAnchor(t,i,s,n){const r=le(t),a=Vt(t),o=bn(s,i===r?a:r);!o||(i.x=o.x,i.y=o.y,i.prev=void 0,i.next=void 0,n?n.anchor=o.id:we(s,o,t,i),this[t.lineName]&&this[t.lineName](this.store,t),this.store.path2dMap.set(t,At.path2dDraws.line(t)),this.initLineRect(t))}restoreNodeAnimate(t){var i,s;if(t.calculative.initRect){if(t.keepAnimateState)for(const n in t)t.calculative[n]!==void 0&&n!=="x"&&n!=="y"&&n!=="width"&&n!=="height"&&n!=="initRect"&&(typeof t[n]!="object"||n==="lineDash")&&(n==="fontSize"||n==="lineWidth"?t[n]=t.calculative[n]/t.calculative.canvas.store.data.scale:t[n]=t.calculative[n]);else{const n=t.calculative.initRect.rotate-t.calculative.rotate;for(const a in t)a!=="x"&&a!=="y"&&a!=="width"&&a!=="height"&&a!=="initRect"&&a!=="rotate"&&(typeof t[a]!="object"||a==="lineDash")&&(t.calculative[a]=t[a]);(i=t.children)!=null&&i.length?n&&Zd(t,n,t.calculative.worldRect):t.calculative.rotate=t.rotate;const r=ht(this.store.animateMap.get(t));r&&(r.id=t.id,this.parent.setValue(r,{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,xr(t)),(s=this.store.active)!=null&&s.length&&this.calcActiveRect(),t.calculative.initRect=void 0}}updateLines(t,i){var s;(s=t.children)==null||s.forEach(n=>{const r=this.store.pens[n];r&&this.updateLines(r,i)}),t.connectedLines&&t.connectedLines.forEach((n,r)=>{const a=this.store.pens[n.lineId];if(!a||a.calculative.active)return;const o=Ls(a,n.lineAnchor);if(!o)return;if(!o.connectTo){t.connectedLines.splice(r,1);return}if(a.autoFrom){const g=le(a);g.id===o.id&&this.calcAutoAnchor(a,g,t,n)}if(a.autoTo){const g=Vt(a);g.id===o.id&&this.calcAutoAnchor(a,g,t,n)}const l=Ls(t,n.anchor);if(!l)return;let u=t.rotate;t.flipX&&(u*=-1),t.flipY&&(u*=-1);let h=o.distance*this.store.data.scale*Math.cos((u+l.rotate)/180*Math.PI)||0,f=o.distance*this.store.data.scale*Math.sin((u+l.rotate)/180*Math.PI)||0;if(t.flipX&&(h=-h),t.flipY&&(f=-f),nr(o,l.x-o.x+h,l.y-o.y+f),this.store.options.autoPolyline&&!this.autoPolylineFlag&&a.autoPolyline!==!1&&a.lineName==="polyline"){let g=le(a),v=Vt(a),y=!1;g.id===o.id?(g=o,y=!0):v.id===o.id&&(v=o,y=!0),y&&(a.calculative.worldAnchors=[g,v],a.calculative.activeAnchor=g,this.polyline(this.store,a,v),this.initLineRect(a))}this.store.path2dMap.set(a,At.path2dDraws[a.name](a)),this.patchFlagsLines.add(a),a.calculative.gradientSmooth&&(a.calculative.gradientAnimatePath=dc(a)),i&&Jl(a)})}calcActiveRect(){const t=this.store.active.filter(i=>(!i.locked||i.locked<Ot.DisableMove)&&i.visible!=!1);if(t.length)t.length===1?(this.activeRect=ht(t[0].calculative.worldRect),this.activeRect.rotate=t[0].calculative.rotate||0,ee(this.activeRect)):(this.activeRect=pi(t),this.activeRect.rotate=0);else return;this.lastRotate=0,this.getSizeCPs()}rotatePen(t,i,s){t.type?(t.calculative.worldAnchors.forEach(n=>{Gt(n,i,s.center)}),this.initLineRect(t),Sa(t)):(t.calculative.rotate?t.calculative.rotate+=i:t.calculative.rotate=i,Gt(t.calculative.worldRect.center,i,s.center),t.parentId?(t.calculative.worldRect.x=t.calculative.worldRect.center.x-t.calculative.worldRect.width/2,t.calculative.worldRect.y=t.calculative.worldRect.center.y-t.calculative.worldRect.height/2,t.x=(t.calculative.worldRect.x-s.x)/s.width,t.y=(t.calculative.worldRect.y-s.y)/s.height):(t.x=t.calculative.worldRect.center.x-t.width/2,t.y=t.calculative.worldRect.center.y-t.height/2),t.rotate=t.calculative.rotate,this.updatePenRect(t),t.children&&t.children.forEach(n=>{const r=this.store.pens[n];this.rotatePen(r,i,t.calculative.worldRect)}))}nextAnimate(t){if(!t)return;this.store.emitter.emit("animateEnd",t);let i;t.nextAnimate&&(i=this.store.data.pens.filter(s=>s.id===t.nextAnimate||s.tags&&s.tags.indexOf(t.nextAnimate)>-1)),i&&(i.forEach(s=>{var n,r,a,o,l;if(s.calculative.pause){const u=Date.now()-s.calculative.pause;s.calculative.pause=void 0,s.calculative.frameStart+=u,s.calculative.frameEnd+=u}else if(s.name==="video")s.calculative.media.currentTime=0,(n=s.calculative.media)==null||n.play(),(r=s.onStartVideo)==null||r.call(s,s);else if(s.type||((a=s.frames)==null?void 0:a.length)||s.animations&&s.animations.length){if(s.type){if((l=s.animations)!=null&&l.length){const u=ht(s.animations[0]);delete u.name,u.currentAnimation=0,this.parent.setValue({id:s.id,...u},{doEvent:!1,history:!1})}}else{if(!s.frames&&s.animations&&s.animations.length){let u=(o=s.animations)==null?void 0:o.findIndex(g=>g.autoPlay),h=u===-1?0:u;const f=ht(s.animations[h]);delete f.name,f.currentAnimation=h,!s.type&&f.frames&&(f.showDuration=this.parent.calcAnimateDuration(f)),this.parent.setValue({id:s.id,...f},{doEvent:!1,history:!1})}this.store.animateMap.set(s,this.getFrameProps(s))}this.store.animates.add(s)}}),this.animate())}getFrameProps(t){let i={};return t.frames&&t.frames.forEach(s=>{for(let n in s)!["duration","x","y","width","height","rotate"].includes(n)&&!i[n]&&(i[n]=t[n])}),i}animate(){this.animateRendering||requestAnimationFrame(()=>{const t=Date.now();if(t-this.lastAnimateRender<this.store.options.animateInterval){this.store.animates.size>0&&this.animate();return}this.lastAnimateRender=t,this.animateRendering=!0;const i=[];let s=!1;for(const n of this.store.animates)if(!n.calculative.pause){if(n.calculative.active&&!n.type&&!this.movingPens&&(s=!0),!n.type)o_(n,t)?n.calculative.patchFlags&&(ee(n.calculative.worldRect),this.updatePenRect(n,{worldRectIsReady:!0,playingAnimate:!0})):(requestAnimationFrame(()=>{this.restoreNodeAnimate(n)}),i.push(n),this.nextAnimate(n)),this.updateLines(n,!0);else if(!c_(n)){if(n.keepAnimateState){for(const r in n)n.calculative[r]!==void 0&&r!=="length"&&(typeof n[r]!="object"||r==="lineDash")&&(r==="lineWidth"?n[r]=n.calculative[r]/n.calculative.canvas.store.data.scale:n[r]=n.calculative[r]);Sa(n)}else for(const r in n)(typeof n[r]!="object"||r==="lineDash")&&(r==="lineWidth"?n.calculative[r]=n[r]*n.calculative.canvas.store.data.scale:n.calculative[r]=n[r]);i.push(n),this.nextAnimate(n)}this.patchFlags=!0}s&&this.calcActiveRect(),i.forEach(n=>{this.store.animates.delete(n)}),this.render(!1),this.animateRendering=!1,this.animate()})}get clipboardName(){return"meta2d-clipboard"}async copy(t,i=!0){const s=It(),{origin:n,scale:r}=this.store.data;this.store.clipboard=void 0,localStorage.removeItem(this.clipboardName),sessionStorage.setItem("page",s);let a=this.getAllByPens(ht(t||this.store.active,!0));a.forEach(l=>{l.copyIndex=this.store.data.pens.findIndex(u=>u.id===l.id),l.pathId&&(l.path=this.store.data.paths[l.pathId])}),a.sort((l,u)=>l.copyIndex-u.copyIndex);const o={meta2d:!0,pens:a,origin:ht(n),scale:r,page:s,initRect:ht(this.activeRect),offset:10,mousePos:ht(this.mousePos)};if(navigator.clipboard&&!this.store.options.disableClipboard&&!navigator.userAgent.includes("Firefox"))try{await navigator.clipboard.writeText(JSON.stringify(o))}catch{localStorage.setItem(this.clipboardName,JSON.stringify(o))}else localStorage.setItem(this.clipboardName,JSON.stringify(o));i&&this.store.emitter.emit("copy",o.pens)}cut(t){this.copy(t,!1),this.delete(t),this.store.emitter.emit("cut",t)}async paste(){var l,u;let t,i;if(navigator.clipboard&&!this.store.options.disableClipboard&&!navigator.userAgent.includes("Firefox"))try{t=await((l=navigator.clipboard)==null?void 0:l.readText())}catch{t=localStorage.getItem(this.clipboardName)}else t=localStorage.getItem(this.clipboardName);if(t){try{i=JSON.parse(t)}catch(h){console.warn("\u526A\u5207\u677F\u6570\u636E\u4E0D\u662Fjson",h.message);return}if(!i||!i.meta2d)return}else return;if(this.beforeAddPens&&await this.beforeAddPens(i.pens)!=!0)return;let s,n;this.store.clipboard&&(s=this.store.clipboard.offset+10,n=this.store.clipboard.pos),this.store.clipboard=ht(i);const r=sessionStorage.getItem("page"),a=this.store.data.scale;if(this.store.clipboard.mousePos&&(Math.abs(this.store.clipboard.mousePos.x-this.mousePos.x)>100*a||Math.abs(this.store.clipboard.mousePos.y-this.mousePos.y)>100*a)){const h=(a-this.store.clipboard.scale)*this.store.clipboard.initRect.width/2,f=(a-this.store.clipboard.scale)*this.store.clipboard.initRect.height/2;this.store.clipboard.pos={x:this.mousePos.x-h,y:this.mousePos.y-f},this.store.clipboard.offset=0}else r!==i.page?(this.store.clipboard.pos={x:this.mousePos.x,y:this.mousePos.y},this.store.clipboard.offset=0):this.pasteOffset?(s&&(this.store.clipboard.offset=s),n&&(this.store.clipboard.pos=n)):(this.store.clipboard.offset=0,this.pasteOffset=!0);(u=this.keyOptions)!=null&&u.F||this.store.clipboard.pens.forEach(h=>{delete h.copyIndex});const o=this.store.clipboard.pens.filter(h=>!h.parentId);for(const h of o)this.pastePen(h,void 0);sessionStorage.setItem("page",i.page),this.active(o),this.pushHistory({type:bt.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)}getAllByPens(t){const i=[];for(const s of t)i.push(...ht(mi(s,this.store),!0));return i.concat(t)}getAllFollowersByPens(t,i=!0){const s=t;for(const n of t){let r=uc(n,this.store);i&&(r=ht(r,!0));for(const a of r)s.find(o=>o.id===a.id)||s.push(a)}return s}setFollowers(t=this.store.active){if(!!t)if(t.length<2)t[0].followers=[];else{let i=t.map(n=>n.id);i.pop();const s=t[t.length-1];s.followers?i.forEach(n=>{s.followers.includes(n)||s.followers.push(n)}):s.followers=i}}changeLineAnchors(t,i,s){if(!!Array.isArray(i.connectedLines))for(let n=0;n<i.connectedLines.length;n++){const{lineId:r}=i.connectedLines[n],a=s.find(o=>o.id===r);if(a){const o=a.anchors[0],l=a.anchors[a.anchors.length-1];o.connectTo===t&&(o.connectTo=i.id),l.connectTo===t&&(l.connectTo=i.id)}else i.connectedLines.splice(n,1),n--}}changeNodeConnectedLine(t,i,s){var o;const n=i.anchors[0],r=i.anchors[i.anchors.length-1],a=[n,r];for(const l of a){const u=l.connectTo;if(u){const h=s.find(f=>f.id===u);h?(o=h.connectedLines)==null||o.forEach(f=>{f.lineId===t&&(f.lineId=i.id,f.lineAnchor=l.id)}):(l.connectTo=void 0,l.prev&&(l.prev.connectTo=void 0),l.next&&(l.next.connectTo=void 0))}}}async delete(t=this.store.active,i=!1,s=!0){if(!t||!t.length||this.beforeRemovePens&&await this.beforeRemovePens(t)!=!0||(i||(t=t.filter(r=>!r.locked)),!t||!t.length))return;const n=[];if(this._del(t,n,i),this.initImageCanvas(n),this.initTemplateCanvas(n),this.inactive(),this.clearHover(),this.render(),s){if(n.length===0)return;this.pushHistory({type:bt.Delete,pens:n})}this.store.emitter.emit("delete",t)}_del(t,i,s){!t||t.forEach(n=>{if(n.type&&(n.lastConnected={}),n.parentId)if(this.getLockedParent(n)){console.warn("\u7236\u8282\u70B9\u9501\u5B9A");return}else{const a=Ge(n),o=a.children.indexOf(n.id);a.children.splice(o,1),i&&this.getDelPens(n,i),this.delForce(n)}else{if(!s&&n.locked)return;i&&this.getDelPens(n,i),this.delForce(n)}})}getDelPens(t,i){if(!t)return;if(this.store.data.pens.findIndex(n=>n.id===t.id)>-1){const n=this.store.pens[t.id];n&&n.calculative&&(n.calculative.active=void 0),i.push(n)}t.children&&t.children.forEach(n=>{this.getDelPens(this.store.pens[n],i)})}getLockedParent(t){if(!t.parentId)return!1;const i=Ge(t);if(i.locked)return i;this.getLockedParent(i)}delForce(t){var s;if(!t)return;const i=this.store.data.pens.findIndex(n=>n.id===t.id);i>-1&&(this.delConnectedLines(this.store.data.pens[i]),this.store.data.pens.splice(i,1),this.store.pens[t.id]=void 0,delete this.store.pens[t.id],t.pathId&&delete this.store.data.paths[t.pathId]),this.store.animates.delete(t),this.store.animateMap.delete(t),t.children&&t.children.forEach(n=>{this.delForce(this.store.pens[n])}),(s=t.onDestroy)==null||s.call(t,t)}delConnectedLines(t){var i;if(t.connectedLines)for(let s=0;s<t.connectedLines.length;s++){const{lineId:n,lineAnchor:r}=t.connectedLines[s],a=this.store.pens[n];if(a){let o=a.anchors.find(l=>l.id===r);(o==null?void 0:o.connectTo)===t.id&&(o.connectTo=void 0,o.anchorId=void 0,o.prev&&(o.prev.connectTo=void 0),o.next&&(o.next.connectTo=void 0)),o=Ls(a,r),o&&(o.connectTo=void 0,o.anchorId=void 0,o.prev&&(o.prev.connectTo=void 0),o.next&&(o.next.connectTo=void 0))}}!t.type||(i=t.calculative.worldAnchors)==null||i.forEach((s,n)=>{var a;if(!s.connectTo)return;const r=this.store.pens[s.connectTo];r&&((a=r.calculative.worldAnchors)==null||a.forEach(o=>{xn(r,o,t,s)}))})}convertSpecialCharacter(t){var i={lt:"<",gt:">",nbsp:" ",amp:"&",quot:'"'};return t.replace(/&(lt|gt|nbsp|amp|quot);/gi,function(s,n){return i[n]})}createInput(){this.inputParent.classList.add("meta2d-input"),this.inputDiv.classList.add("input-div"),this.inputParent.appendChild(this.inputDiv),this.dropdown.onmouseleave=()=>{this.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.dropdown.onmousedown=this.stopPropagation;let t;for(let i=0;i<document.styleSheets.length;i++)document.styleSheets[i].title==="le5le.com"&&(t=document.styleSheets[i]);if(!t){const i=document.createElement("style");i.title="le5le.com",document.head.appendChild(i),t=i.sheet,t.insertRule(".meta2d-input{display:none;position:absolute;outline:none;align-items: center;}"),t.insertRule(".meta2d-input textarea{resize:none;border:none;outline:none;background:transparent;flex-grow:1;height:100%;left:0;top:0}"),t.insertRule(".meta2d-input .right{width:10px;height:10px;flex-shrink:0;border-top: 1px solid;border-right: 1px solid;margin-right: 5px;transition: all .3s cubic-bezier(.645,.045,.355,1);position:absolute;right:1px;}"),t.insertRule(".meta2d-input ul{position:absolute;top:100%;margin-top:4px; width:calc(100% + 10px);min-height:30px;border-radius: 2px;box-shadow: 0 2px 8px #00000026;list-style-type: none;background-color: #fff;padding: 4px 0;max-height: 105px;overflow-y: auto;}"),t.insertRule(".meta2d-input ul li{padding: 5px 12px;line-height: 22px;white-space: nowrap;cursor: pointer;}"),t.insertRule(".meta2d-input ul li:hover{background: #eeeeee;}"),t.insertRule(".input-div::-webkit-scrollbar {display:none}"),t.insertRule(".input-div{scrollbar-width: none;}"),t.insertRule(".meta2d-input .input-div{resize:none;border:none;outline:none;background:transparent;flex-grow:1;height:100%;width: 100%;left:0;top:0;display:flex;text-align: center;justify-content: center;flex-direction: column;}"),t.insertRule(".input-div div{}")}this.inputDiv.onfocus=i=>{if(navigator.userAgent.includes("Firefox")){if(!i.target.innerText){let s=this.inputDiv.offsetWidth/2;window.getComputedStyle(this.inputDiv,null).textAlign!=="center"&&(s=0),this.inputDiv.innerHTML=`<br style="margin-left:${s}px;margin-top:4px;" />`}}else if(i.target.innerText)this.inputDiv.style.paddingTop="";else{let s=window.getComputedStyle(this.inputDiv,null);s.justifyContent==="center"&&(this.inputDiv.style.paddingTop=` ${this.inputDiv.offsetHeight/2-parseFloat(s.lineHeight)/2}px`)}},this.inputDiv.onblur=()=>{setTimeout(()=>{this.hideInput()},300)},this.inputDiv.oninput=i=>{const s=this.store.pens[this.inputDiv.dataset.penId];if(s&&s.inputType==="number"){const n=i.target.innerText,r=n.replace(/[^0-9]/g,"");n!==r&&(i.preventDefault(),i.target.innerText=r)}if(navigator.userAgent.includes("Firefox")){if(!i.target.innerText.trim()){let n=this.inputDiv.offsetWidth/2;window.getComputedStyle(this.inputDiv,null).textAlign!=="center"&&(n=0),this.inputDiv.innerHTML=`<br style="margin-left:${n}px;margin-top:4px;" />`}}else if(i.target.innerText)this.inputDiv.style.paddingTop="";else{let n=window.getComputedStyle(this.inputDiv,null);n.justifyContent==="center"&&(this.inputDiv.style.paddingTop=` ${this.inputDiv.offsetHeight/2-parseFloat(n.lineHeight)/2}px`)}this.store.emitter.emit("input",s)},this.inputDiv.onclick=i=>{i.stopPropagation();const s=this.store.pens[this.inputDiv.dataset.penId];this.dropdown.style.display==="block"?this.dropdown.style.display="none":(s==null?void 0:s.dropdownList)&&this.store.data.locked&&(this.dropdown.style.display="block"),this.store.emitter.emit("clickInput",s)},this.inputDiv.onkeyup=i=>{this.setDropdownList(!0);const s=this.store.pens[this.inputDiv.dataset.penId];this.store.emitter.emit("input",{pen:s,text:i.key}),i.stopPropagation()},this.inputDiv.onkeydown=i=>{i.stopPropagation()},this.inputDiv.onmousedown=this.stopPropagation,this.inputDiv.onwheel=i=>{i.stopPropagation()},this.inputDiv.onpaste=i=>{i.preventDefault();let s="";i.clipboardData&&i.clipboardData.getData&&(s=i.clipboardData.getData("text/plain")),document.execCommand("insertHTML",!1,s)}}clearDropdownList(){if(this.dropdown.hasChildNodes())for(let t=0;t<this.dropdown.childNodes.length;t++)this.dropdown.childNodes[t].remove(),--t}dropdownAppendOption(t,i){const s=document.createElement("li");s.onwheel=this.stopPropagation,s.innerText=t,s.style.overflow="hidden",s.style.textOverflow="ellipsis",s.title=t,s.style.zoom=this.store.data.scale,s.onmousedown=this.stopPropagation,s.dataset.i=i+"",s.onclick=this.selectDropdown;const n=this.store.pens[this.inputDiv.dataset.penId];s.onmouseenter=()=>{s.style.background=n.dropdownHoverBackground||this.store.styles.activeBg||"#eee",s.style.color=n.dropdownHoverColor||"#bdc7db"},s.onmouseleave=()=>{s.style.background=n.dropdownBackground||this.store.styles.popContentBg||"#fff",s.style.color=n.dropdownColor||"#bdc7db"},this.dropdown.appendChild(s)}find(t){return this.store.data.pens.filter(i=>i.id==t||i.tags&&i.tags.indexOf(t)>-1)}findOne(t){return this.store.data.pens.find(i=>i.id==t||i.tags&&i.tags.indexOf(t)>-1)}changePenId(t,i){var n,r,a,o,l,u,h;if(t===i)return;const s=this.store.pens[t];if(!!s&&!this.store.pens[i]){if(s.id=i,this.store.pens[i]=this.store.pens[t],(n=s.onChangeId)==null||n.call(s,s,t,i),delete this.store.pens[t],s.parentId){const f=this.store.pens[s.parentId],g=(r=f.children)==null?void 0:r.findIndex(v=>v===t);g!==-1&&((a=f.children)==null||a.splice(g,1,i))}(o=s.children)==null||o.forEach(f=>{const g=this.store.pens[f];g.parentId=i}),s.formId&&s.followers.forEach(f=>{const g=this.store.pens[f];g.formId=i}),s.type===jt.Line?this.changeNodeConnectedLine(t,s,this.store.data.pens):(this.changeLineAnchors(t,s,this.store.data.pens),(l=s.connectedLines)==null||l.forEach(({lineId:f})=>{const g=this.store.pens[f];En(g)})),(u=s.anchors)==null||u.forEach(f=>f.penId=i),(h=s.calculative.worldAnchors)==null||h.forEach(f=>f.penId=i)}}updateValue(t,i){var y,w,p,_,E,x;const s=this.getPenRect(t),n=t.name;Object.assign(t,i);const r=n!==t.name;i.newId&&this.changePenId(t.id,i.newId);let a=!1,o=!1,l=!1,u=!1,h=!1,f=!1,g,v=!1;for(const C in i)C.indexOf(".")===-1?(C==="rotate"?t.disableRotate?t.rotate=t.calculative.rotate||0:g=t.calculative.rotate||0:C==="canvasLayer"||C==="isBottom"||C==="showChild"?f=!0:C==="image"&&(v=!0),(typeof t[C]!="object"||C==="lineDash")&&(!t.disableRotate||C!=="rotate")&&(t.calculative[C]=i[C]),J1.includes(C)&&(o=!0),["name","borderRadius","lineSmooth","close"].includes(C)&&(a=!0),Q1.includes(C)&&(h=!0),tx.includes(C)&&(l=!0),ex.includes(C)&&(u=!0),t.image&&t.name!=="gif"&&["globalAlpha","flipY","flipX","x","y","width","height","iconWidth","iconHeight","imageRatio","iconLeft","iconTop","iconAlign","rotate"].includes(C)&&(v=!0)):(delete t[C],Ha(t,C,i[C])),C.split(".")[0]==="anchors"&&En(t);if(this.setCalculativeByScale(t),r&&((y=t.onDestroy)==null||y.call(t,t),ix(t)),h){const C={x:(w=i.x)!=null?w:s.x,y:(p=i.y)!=null?p:s.y,width:(_=i.width)!=null?_:s.width,height:(E=i.height)!=null?E:s.height};this.setPenRect(t,C,!1),this.updateLines(t,!0),this.store.active&&this.store.active.length&&t.id===this.store.active[0].id&&this.calcActiveRect()}else l?this.updatePenRect(t):(o&&Ti(t),u&&hf(this.store.pens,t),a&&At.path2dDraws[t.name]&&this.store.path2dMap.set(t,At.path2dDraws[t.name](t)));if(g!==void 0){const C=t.calculative.rotate;t.calculative.rotate=g,this.rotatePen(t,C-g,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),f?(this.canvasImage.init(),this.canvasImageBottom.init()):v&&(t.canvasLayer===void 0&&(t.canvasLayer=zt.CanvasImageBottom,t.calculative.canvasLayer=zt.CanvasImageBottom),t.canvasLayer===zt.CanvasImageBottom?this.canvasImageBottom.init():t.canvasLayer===zt.CanvasImage&&this.canvasImage.init()),(i.canvasLayer!==void 0||t.canvasLayer===zt.CanvasTemplate)&&this.initTemplateCanvas([t]),i.zIndex!==void 0&&(x=t.calculative.singleton)!=null&&x.div&&Te(t,t.calculative.singleton.div)}execPenResize(t){var i,s;(i=t.onResize)==null||i.call(t,t),(s=t.children)==null||s.forEach(n=>{const r=this.store.pens[n];r&&this.execPenResize(r)})}setPenRect(t,i,s=!0){if(t.parentId)Object.assign(t,i);else{const{origin:n,scale:r}=this.store.data;t.x=n.x+i.x*r,t.y=n.y+i.y*r,t.width=i.width*r,t.height=i.height*r}this.updatePenRect(t),this.execPenResize(t),s&&this.render()}getPenRect(t,i=this.store.data.origin,s=this.store.data.scale){if(!!t)return t.parentId?{x:t.x,y:t.y,width:t.width,height:t.height}:{x:(t.x-i.x)/s,y:(t.y-i.y)/s,width:t.width/s,height:t.height/s}}toPng(t=2,i,s=!1,n){const r=pi(this.store.data.pens),a=this.store.data.scale;if(!isFinite(r.width))throw new Error("can not to png, because width is not finite");const o=ht(r),l=this.store.data,u=s&&this.store.bkImg;let h=!1,f=!1;if(u){if(r.x+=l.x,r.y+=l.y,ae(r),Xi(r,this.canvasRect,!0))Object.assign(r,this.canvasRect);else{const S=_r([...Zi(r),...Zi(this.canvasRect)]);Object.assign(r,S)}h=r.x===0,f=r.y===0}const g=this.store.data.width||this.store.options.width,v=this.store.data.height||this.store.options.height;let y=!1;g&&v&&!this.store.data.component&&(y=!0),y&&(r.x=this.store.data.origin.x,r.y=this.store.data.origin.y,r.width=g*this.store.data.scale,r.height=v*this.store.data.scale);const w=ht(r),p=qi(t);r.x-=p[3]*a,r.y-=p[0]*a,r.width+=(p[3]+p[1])*a,r.height+=(p[0]+p[2])*a;const _=(n||1920)/r.width;r.width*=_,r.height*=_,ae(r);const E=document.createElement("canvas");if(E.width=r.width,E.height=r.height,E.width>32767||E.height>32767||!navigator.userAgent.includes("Firefox")&&E.height*E.width>268435456||navigator.userAgent.includes("Firefox")&&E.height*E.width>472907776)throw new Error("can not to png, because the size exceeds the browser limit");const x=E.getContext("2d");x.textBaseline="middle",x.scale(_,_);const C=this.store.data.background||this.store.styles.background;if(C&&y&&(x.save(),x.fillStyle=C,x.fillRect(0,0,w.width+(p[1]+p[3])*a,w.height+(p[0]+p[2])*a),x.restore()),u)if(y)x.drawImage(this.store.bkImg,p[3]*a||0,p[0]*a||0,w.width,w.height);else{const S=r.x<0?-r.x:0,D=r.y<0?-r.y:0;x.drawImage(this.store.bkImg,S,D,this.canvasRect.width,this.canvasRect.height)}if(C&&!y)if(u){const S=r.x<0?-r.x:0,D=r.y<0?-r.y:0;x.save(),x.fillStyle=C,x.fillRect(S,D,this.canvasRect.width,this.canvasRect.height),x.restore()}else x.save(),x.fillStyle=C,x.fillRect(0,0,o.width+(p[3]+p[1])*a,o.height+(p[0]+p[2])*a),x.restore();u?y?x.translate(-r.x,-r.y):x.translate((h?l.x:-o.x)+p[3]*a||0,(f?l.y:-o.y)+p[0]*a||0):x.translate(-r.x,-r.y);for(const S of this.store.data.pens){if(!Ua(S,this.store)||S.visible==!1||S.name==="combine"&&!S.draw)continue;const{active:D}=S.calculative;S.calculative.active=!1,S.calculative.img?Wa(x,S):Is(x,S,!0),S.calculative.active=D}if(i){E.toBlob(i);return}return E.toDataURL()}activeToPng(t=2,i){return this.pensToPng(this.store.active,t,i)}pensToPng(t=this.store.active,i=2,s){if(t.length===0)return;const n=this.getAllByPens(t);let r=n.map(v=>v.id);const a=pi(n);if(!isFinite(a.width))throw new Error("can not to png, because width is not finite");const o=ht(a),l=qi(i);a.x-=l[3],a.y-=l[0],a.width+=l[3]+l[1],a.height+=l[0]+l[2],ae(a);const u=(s||a.width)/a.width;a.width*=u,a.height*=u;const h=document.createElement("canvas");if(h.width=a.width,h.height=a.height,h.width>32767||h.height>32767||!navigator.userAgent.includes("Firefox")&&h.height*h.width>268435456||navigator.userAgent.includes("Firefox")&&h.height*h.width>472907776)throw new Error("can not to png, because the size exceeds the browser limit");const f=h.getContext("2d");f.textBaseline="middle",f.scale(u,u);const g=this.store.data.background||this.store.styles.background;g&&(f.save(),f.fillStyle=g,f.fillRect(0,0,o.width+(l[3]+l[1]),o.height+(l[0]+l[2])),f.restore()),f.translate(-o.x+l[3],-o.y+l[0]);for(const v of this.store.data.pens)if(r.includes(v.id)){if(!Ua(v,this.store)||v.visible==!1||v.name==="combine"&&!v.draw)continue;const{active:y}=v.calculative;v.calculative.active=!1,v.calculative.img?Wa(f,v):Is(f,v),v.calculative.active=y}return h.toDataURL()}toggleAnchorMode(){var t;if(this.hotkeyType)this.hotkeyType===Yt.AddAnchor&&(this.hotkeyType=Yt.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?void 0:t.disableAnchor))return;this.hotkeyType=Yt.AddAnchor,this.store.hover&&(this.externalElements.style.cursor="pointer")}this.patchFlags=!0}addAnchorHand(){if(this.store.activeAnchor&&this.store.active&&this.store.active.length===1&&this.store.active[0].type){const t=[ht(this.store.active[0],!0)];this.store.activeAnchor.prev?this.store.activeAnchor.next||(this.store.activeAnchor.next={...this.store.activeAnchor.prev},Gt(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={...this.store.activeAnchor.next},Gt(this.store.activeAnchor.prev,180,this.store.activeAnchor),this.initLineRect(this.store.active[0]),this.patchFlags=!0),this.pushHistory({type:bt.Update,pens:[ht(this.store.active[0],!0)],initPens:t})}}removeAnchorHand(){if(this.store.activeAnchor&&this.store.active&&this.store.active.length===1&&this.store.active[0].type){const t=[ht(this.store.active[0],!0)];this.hoverType===xt.LineAnchorPrev?(this.store.activeAnchor.prev=void 0,this.initLineRect(this.store.active[0]),this.patchFlags=!0):this.hoverType===xt.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:bt.Update,pens:[ht(this.store.active[0])],initPens:t})}}toggleAnchorHand(){this.store.active.length===1&&this.store.active[0].type&&this.store.activeAnchor&&(this.store.activeAnchor.prevNextType||(this.store.activeAnchor.prevNextType=Fs.Mirror),this.store.activeAnchor.prevNextType=(this.store.activeAnchor.prevNextType+1)%3)}gotoView(t,i){let s=pi(this.store.data.pens);if(!isFinite(s.width))throw new Error("can not move view, because width is not finite");const n=this.store.data.width||this.store.options.width,r=this.store.data.height||this.store.options.height;n&&r&&(s={x:this.store.data.origin.x,y:this.store.data.origin.y,width:n*this.store.data.scale,height:r*this.store.data.scale}),this.store.data.x=this.canvas.clientWidth/2-t*s.width-s.x,this.store.data.y=this.canvas.clientHeight/2-i*s.height-s.y,this.onMovePens(),this.canvasTemplate.init(),this.canvasImage.init(),this.canvasImageBottom.init(),this.render()}showMagnifier(){this.magnifierCanvas.canvas.style.zIndex="100",this.externalElements.style.zIndex="101",this.magnifierCanvas.magnifier=!0,this.magnifierCanvas.updateDomOffscreen(),this.externalElements.style.cursor="default",this.render()}hideMagnifier(){this.magnifierCanvas.canvas.style.zIndex="5",this.externalElements.style.zIndex="5",this.magnifierCanvas.magnifier=!1,this.externalElements.style.cursor="default",this.render()}showFit(){this.store.data.locked=0,this.canvasImage.fitFlag=!0,this.canvasImage.activeFit=void 0,this.canvasImage.currentFit=void 0,this.store.data.fits||(this.store.data.fits=[]),this.store.data.fits.forEach(t=>t.active=!1),this.canvasImage.init(),this.canvasImage.render()}hideFit(){this.canvasImage.fitFlag=!1,this.canvasImage.activeFit=void 0,this.canvasImage.currentFit=void 0,this.canvasImage.init(),this.canvasImage.render()}makeFit(){if(this.dragRect.width<100&&this.dragRect.height<100)return;const t=this.store.data.pens.filter(u=>{if(u.parentId||u.isRuleLine)return!1;if(Xi(u.calculative.worldRect,this.dragRect,!0))return u.type===jt.Line&&!this.store.options.dragAllIn?Tl(u,this.dragRect):!0});if(!t.length)return;const i=this.parent.getRect(t),s=this.store.data.scale,n=this.store.data.width||this.store.options.width,r=this.store.data.height||this.store.options.height;let a=(Math.floor(i.x)-this.store.data.origin.x)/s/n,o=(Math.floor(i.y)-this.store.data.origin.y)/s/r,l={x:a,y:o,width:(Math.ceil(i.width)+1)/s/n,height:(Math.ceil(i.height)+1)/s/r,children:t.map(u=>u.id),id:It(),active:!0};l.x<-.1&&(l.x=-.1),l.y<-.1&&(l.y=-.1),l.width>.5?(l.left=!0,l.right=!0,l.leftValue=(l.x-0)*s*n,l.rightValue=(1-(l.x+l.width))*s*n):l.x<.5?(l.left=!0,l.leftValue=(l.x-0)*s*n):(l.right=!0,l.rightValue=(1-(l.x+l.width))*s*n),l.leftValue<1&&(l.leftValue=0),l.rightValue<1&&(l.rightValue=0),l.height>.5?(l.top=!0,l.bottom=!0,l.topValue=(l.y-0)*s*r,l.bottomValue=(1-(l.y+l.height))*s*r):l.y<.5?(l.top=!0,l.topValue=(l.y-0)*s*r):(l.bottom=!0,l.bottomValue=(1-(l.y+l.height))*s*r),l.topValue<1&&(l.topValue=0),l.bottomValue<1&&(l.bottomValue=0),this.store.data.fits||(this.store.data.fits=[]),this.store.data.fits.forEach(u=>{u.active=!1}),this.store.data.fits.push(l),this.canvasImage.activeFit=l,this.store.emitter.emit("fit",l),this.canvasImage.init(),this.canvasImage.render()}updateFit(t){const i=this.store.data.scale,s=this.store.data.width||this.store.options.width,n=this.store.data.height||this.store.options.height;let r=(t.x-this.store.data.origin.x)/i/s,a=(t.y-this.store.data.origin.y)/i/n;if(this.canvasImage.currentFit){const o=this.canvasImage.activeFit;if(this.canvasImage.currentFit==="top"){a<-.1&&(a=-.1);let h=a-o.y;if(o.height-=h,o.height<.01){o.height=.01;return}o.y=a}if(this.canvasImage.currentFit==="bottom"&&(a>1.1&&(a=1.1),o.height=a-o.y,o.height<=.01&&(o.height=.01)),this.canvasImage.currentFit==="left"){r<-.1&&(r=-.1);let h=r-o.x;if(o.width-=h,o.width<.01){o.width=.01;return}o.x=r}this.canvasImage.currentFit==="right"&&(r>1.1&&(r=1.1),o.width=r-o.x,o.width<=.01&&(o.width=.01));let l={x:o.x*s*i+this.store.data.origin.x,y:o.y*n*i+this.store.data.origin.y,width:o.width*s*i,height:o.height*n*i};ae(l);const u=this.store.data.pens.filter(h=>{if(h.parentId||h.isRuleLine)return!1;if(Xi(h.calculative.worldRect,l,!0))return h.type===jt.Line&&!this.store.options.dragAllIn?Tl(h,l):!0});o.left=void 0,o.leftValue=void 0,o.right=void 0,o.rightValue=void 0,o.top=void 0,o.topValue=void 0,o.bottom=void 0,o.bottomValue=void 0,o.width>.5?(o.left=!0,o.right=!0,o.leftValue=(o.x-0)*i*s,o.rightValue=(1-(o.x+o.width))*i*s):o.x<.5?(o.left=!0,o.leftValue=(o.x-0)*i*s):(o.right=!0,o.rightValue=(1-(o.x+o.width))*i*s),Math.abs(o.leftValue)<1&&(o.leftValue=0),Math.abs(o.rightValue)<1&&(o.rightValue=0),o.height>.5?(o.top=!0,o.bottom=!0,o.topValue=(o.y-0)*i*n,o.bottomValue=(1-(o.y+o.height))*i*n):o.y<.5?(o.top=!0,o.topValue=(o.y-0)*i*n):(o.bottom=!0,o.bottomValue=(1-(o.y+o.height))*i*n),Math.abs(o.topValue)<1&&(o.topValue=0),Math.abs(o.bottomValue)<1&&(o.bottomValue=0),o.children=u.map(h=>h.id),this.store.emitter.emit("fit",o),this.mouseDown.x=t.x,this.mouseDown.y=t.y,this.canvasImage.init(),this.canvasImage.render()}}updateFitRect(t=this.canvasImage.activeFit){const i=this.store.data.width||this.store.options.width,s=this.store.data.height||this.store.options.height;t.left&&(t.leftValue?t.x=Math.abs(t.leftValue)<1?t.leftValue:t.leftValue/i:t.x=0),t.right&&(t.rightValue?t.width=1-(Math.abs(t.rightValue)<1?t.rightValue:t.rightValue/i)-t.x:t.width=1-t.x),t.top&&(t.topValue?t.y=Math.abs(t.topValue)<1?t.topValue:t.topValue/s:t.y=0),t.bottom&&(t.bottomValue?t.height=1-(Math.abs(t.bottomValue)<1?t.bottomValue:t.bottomValue/s)-t.y:t.height=1-t.y),this.canvasImage.init(),this.canvasImage.render()}deleteFit(t=this.canvasImage.activeFit){if(!t)return;const i=this.store.data.fits.findIndex(s=>s.id===t.id);this.store.data.fits.splice(i,1),this.canvasImage.activeFit=void 0,this.canvasImage.init(),this.canvasImage.render(),this.store.emitter.emit("fit",void 0)}calcuActiveFit(){var o;const t=this.store.data.width||this.store.options.width,i=this.store.data.height||this.store.options.height;let s=(this.mouseDown.x-this.store.data.origin.x)/this.store.data.scale/t,n=(this.mouseDown.y-this.store.data.origin.y)/this.store.data.scale/i,r=-1,a=-1;(o=this.store.data.fits)==null||o.forEach((l,u)=>{l.ex=null,l.ey=null,Ui({x:s,y:n},l)&&(r=u),l.active&&(a=u)}),r!==-1&&r!==a?(this.canvasImage.activeFit=this.store.data.fits[r],this.store.data.fits[r].active=!0,a!==-1&&(this.store.data.fits[a].active=!1),this.store.emitter.emit("fit",this.store.data.fits[r])):r===-1&&a!==-1&&(this.store.data.fits[a].active=!1,this.store.emitter.emit("fit",void 0),this.canvasImage.activeFit=null),this.inactive(),this.canvasImage.init(),this.canvasImage.render()}toggleMagnifier(){this.magnifierCanvas.magnifier=!this.magnifierCanvas.magnifier,this.magnifierCanvas.magnifier&&(this.externalElements.style.cursor="default"),this.render()}destroy(){var t,i,s,n;switch(this.scroll&&this.scroll.destroy(),(t=this.tooltip)==null||t.destroy(),(i=this.dialog)==null||i.destroy(),(s=this.title)==null||s.destroy(),(n=this.popconfirm)==null||n.destroy(),this.externalElements.removeEventListener("gesturestart",this.onGesturestart),this.externalElements.ondragover=r=>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 Ds.Document:document.removeEventListener("keydown",this.onkeydown),document.removeEventListener("keyup",this.onkeyup);break;case Ds.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("message",this.onMessage),window&&window.removeEventListener("resize",this.onResize),window&&window.removeEventListener("scroll",this.onScroll),this.parentElement.innerHTML=""}}function M2(e,t){const i=t||new Path2D;e.onDestroy||(e.onDestroy=O2,e.onMove=If,e.onRotate=If,e.onMouseEnter=N2,e.onMouseLeave=F2,e.onMouseMove=H2,e.onMouseUp=z2,e.onInput=B2),e.formId=e.id;let s=e.calculative.borderRadius||0,n=s;const{x:r,y:a,width:o,height:l,ex:u,ey:h}=e.calculative.worldRect;e.calculative.worldTextRect,s<1&&(s=o*s,n=l*n);let f=s<n?s:n;if(o<2*f&&(f=o/2),l<2*f&&(f=l/2),i.moveTo(r+f,a),i.arcTo(u,a,u,h,f),i.arcTo(u,h,r,h,f),i.arcTo(r,h,r,a,f),i.arcTo(r,a,u,a,f),i instanceof Path2D)return i}function B2(e,t){e.text=t,e.calculative.text=e.text,e.calculative.canvas.updatePenRect(e)}function O2(e){}function If(e){}function N2(e){}function F2(e){const t=e.calculative.canvas.store.active;t&&t.length&&t.forEach(i=>{if(e.followers){let s=e.followers.findIndex(n=>n===i.id);if(s!==-1){const n=e.calculative.canvas.store.pens[i.id+ze];n&&n.calculative&&(Xi(n.calculative.worldRect,e.calculative.worldRect,!0)||(e.followers.splice(s,1),delete i.formId))}}})}function z2(e){const t=e.calculative.canvas.store.active;t&&t.length&&t.forEach(i=>{const s=e.calculative.canvas.store.pens[i.id+ze];if(s&&s.calculative){let n=ht(e.calculative.worldRect);n.x-=1,n.y-=1,n.width+=2,n.height+=2,Xi(s.calculative.worldRect,n,!0)&&(e.followers||(e.followers=[]),e.followers.includes(i.id)||e.followers.push(i.id),i.formId=e.id)}})}function H2(e,t){}function Lf(e,t){if(e.formId&&e.formKey&&e.formValue){const i=e.calculative.canvas.store.pens[e.formId];i&&(i.formData||(i.formData={}),i.formData[e.formKey]=e[e.formValue])}}function W2(e){const t=e.calculative.canvas.store.pens[e.formId];t.followers.forEach(i=>{const s=e.calculative.canvas.store.pens[i];if(s.formId&&s.formKey&&t.formData[s.formKey]){const n=s[s.formValue];let r="";Array.isArray(n)&&(r=[]),e.calculative.canvas.parent.setValue({id:s.id,[s.formValue]:r},{render:!1,doEvent:!1,history:!1})}}),t.formData={},e.calculative.canvas.parent.render()}const ge={};function U2(e){e.onDestroy||(e.onDestroy=V2,e.onMove=Df,e.onResize=j2,e.onRotate=Df,e.onValue=$2,e.onChangeId=q2);const t=new Path2D;if(!e.image)return;const s=e.calculative.canvas.store.id+"-"+e.id;if(!ge[s]){const n=new Image;n.crossOrigin="anonymous",n.src=e.image,e.calculative.canvas.parent.store.options.cdn&&!(e.image.startsWith("http")||e.image.startsWith("//")||e.image.startsWith("data:image"))&&(n.src=e.calculative.canvas.parent.store.options.cdn+e.image),ge[s]=n,n.onload=()=>{var r;ge[s]===n&&(e.calculative.img=n,e.calculative.imgNaturalWidth=n.naturalWidth||e.iconWidth,e.calculative.imgNaturalHeight=n.naturalHeight||e.iconHeight,(r=e.calculative.canvas.externalElements)==null||r.parentElement.appendChild(n),vr(e,n))}}return e.calculative.patchFlags&&ge[s]&&vr(e,ge[s]),t}function V2(e){const i=e.calculative.canvas.store.id+"-"+e.id;ge[i]&&(ge[i].remove(),ge[i]=void 0)}function Df(e){const i=e.calculative.canvas.store.id+"-"+e.id;!ge[i]||vr(e,ge[i])}function j2(e){const i=e.calculative.canvas.store.id+"-"+e.id;!ge[i]||vr(e,ge[i])}function $2(e){const i=e.calculative.canvas.store.id+"-"+e.id;!ge[i]||(vr(e,ge[i]),ge[i].getAttribute("src")!==e.image&&(ge[i].src=e.image))}function q2(e,t,i){const s=e.calculative.canvas.store.id;!ge[s+"-"+t]||(ge[s+"-"+i]=ge[s+"-"+t],delete ge[s+"-"+t])}function vr(e,t){t.style.objectFit=e.imageRatio?"contain":"fill",Te(e,t)}function Y2(e,t){return e.onResize||(e.onResize=fg,e.onValue=K2),Ns(e,t)}function fg(e){const t=e.anchors.filter(i=>i.flag!==1);dg(e),e.anchors=e.anchors.concat(...t)}function K2(e){fg(e),En(e)}function dg(e){const t=[],{x:i,y:s,width:n,height:r}=e,a=X2(e),o=5;for(let f=0;f<o;f++){if(f===2)continue;let g=i+n*(f+1)/(o+1),v=s;g<i+a?v=_a(i+a,v+a,g,a,-1):g>i+n-a&&(v=_a(i+n-a,v+a,g,a,-1)),t.push({id:String(t.length),flag:1,penId:e.id,x:(g-i)/n,y:(v-s)/r})}const l=3;for(let f=0;f<l;f++){let g=s+r*(f+1)/(l+1),v=i+n;g<s+a?v=xa(v-a,s+a,g,a):g>s+r-a&&(v=xa(v-a,s+r-a,g,a)),t.push({id:String(t.length),flag:1,penId:e.id,x:(v-i)/n,y:(g-s)/r})}const u=5;for(let f=0;f<u;f++){if(f===2)continue;let g=i+n*(f+1)/(u+1),v=s+r;g<i+a?v=_a(i+a,v-a,g,a):g>i+n-a&&(v=_a(i+n-a,v-a,g,a)),t.push({id:String(t.length),flag:1,penId:e.id,x:(g-i)/n,y:(v-s)/r})}const h=3;for(let f=0;f<h;f++){let g=s+r*(f+1)/(h+1),v=i;g<s+a?v=xa(v+a,s+a,g,a,-1):g>s+r-a&&(v=xa(v+a,s+r-a,g,a,-1)),t.push({id:String(t.length),flag:1,penId:e.id,x:(v-i)/n,y:(g-s)/r})}e.anchors=t}function X2(e){let t=e.calculative.borderRadius||0,i=e.calculative.borderRadius||0;const{width:s,height:n}=e;e.calculative.borderRadius<1&&(t=s*e.calculative.borderRadius,i=n*e.calculative.borderRadius);let r=t<i?t:i;return s<2*r&&(r=s/2),n<2*r&&(r=n/2),r}function xa(e,t,i,s,n=1){return n*Math.sqrt(s**2-(i-t)**2)+e}function _a(e,t,i,s,n=1){return n*Math.sqrt(s**2-(i-e)**2)+t}function G2(e,t){const i=t||new Path2D,{x:s,y:n,width:r,height:a}=e.calculative.worldRect;if(i.moveTo(s,n+a),i.lineTo(s+r,n+a),i.closePath(),i instanceof Path2D)return i}function Z2(e){const t=[{x:0,y:1},{x:1,y:1}];e.anchors=t.map(({x:i,y:s},n)=>({id:n+"",x:i,y:s,penId:e.id}))}function J2(){return{rectangle:Ns,square:G1,circle:Z1,svgPath:F_,diamond:z_,triangle:H_,pentagon:U_,pentagram:j_,hexagon:q_,leftArrow:Y_,rightArrow:K_,twowayArrow:X_,message:G_,cloud:Z_,file:J_,people:t2,line:n2,iframe:b2,video:A2,gif:U2,mindNode:Y2,mindLine:G2,mindNode2:Ns,form:M2,combine:Ns}}function Q2(){return{triangle:W_,pentagon:V_,pentagram:eg,mindNode:dg,mindLine:Z2}}var he;(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",e[e.Message=18]="Message"})(he||(he={}));class tk{constructor(t){U(this,"parent");U(this,"box");U(this,"boxWidth",320);U(this,"boxHeight",180);U(this,"ratio",this.boxWidth/this.boxHeight);U(this,"padding",5);U(this,"img");U(this,"isShow");U(this,"isDown");U(this,"view");U(this,"timer");U(this,"onMouseDown",t=>{t.preventDefault(),t.stopPropagation(),this.isDown=!0});U(this,"onMouseMove",t=>{if(t.preventDefault(),t.stopPropagation(),this.isDown)try{this.parent.gotoView(t.offsetX/this.box.clientWidth,t.offsetY/this.box.clientHeight)}catch(i){console.warn(i.message),this.isDown=!1}});U(this,"onMouseUp",t=>{t.preventDefault(),t.stopPropagation();try{this.parent.gotoView(t.offsetX/this.box.clientWidth,t.offsetY/this.box.clientHeight)}catch(i){console.warn(i.message)}finally{this.isDown=!1}});U(this,"onWheel",t=>{let i=.015;if(this.parent.store.options.scaleOff)i=this.parent.store.options.scaleOff,t.deltaY>0&&(i=-this.parent.store.options.scaleOff);else if(/mac os /i.test(navigator.userAgent))t.ctrlKey?t.deltaY>0&&(i*=-1):i*=t.wheelDeltaY/240;else{let l=.2;t.deltaY.toString().indexOf(".")!==-1&&(l=.01),t.deltaY>0?i=-l:i=l}let{offsetX:s,offsetY:n}=t;const r=this.parent.store.data.width||this.parent.store.options.width,a=this.parent.store.data.height||this.parent.store.options.height;if(r&&a)s=s/this.boxWidth*r*this.parent.store.data.scale+this.parent.store.data.origin.x+this.parent.store.data.x,n=n/this.boxHeight*a*this.parent.store.data.scale+this.parent.store.data.origin.y+this.parent.store.data.y;else{const o=this.parent.parent.getRect();s=s/this.boxWidth*o.width+o.x+this.parent.store.data.x,n=n/this.boxHeight*o.height+o.y+this.parent.store.data.y}this.parent.scale(this.parent.store.data.scale+i,{x:s,y:n})});var s;this.parent=t,this.box=document.createElement("div"),this.img=new Image,this.view=document.createElement("div"),this.box.appendChild(this.img),this.box.appendChild(this.view),(s=this.parent.externalElements)==null||s.parentElement.appendChild(this.box),this.box.className="meta2d-map",this.box.onmousedown=this.onMouseDown,this.box.onmousemove=this.onMouseMove,this.box.onmouseup=this.onMouseUp,this.box.onwheel=this.onWheel;let i;for(let n=0;n<document.styleSheets.length;n++)document.styleSheets[n].title==="le5le/map"&&(i=document.styleSheets[n]);if(!i){let n=document.createElement("style");n.type="text/css",n.title="le5le.com/map",document.head.appendChild(n),n=document.createElement("style"),n.type="text/css",document.head.appendChild(n),i=n.sheet,i.insertRule(`.meta2d-map{display:flex;width:${this.boxWidth+2*this.padding}px;height:${this.boxHeight+2*this.padding}px;padding:${this.padding}px;background:#f4f4f4;border:1px solid #ffffff;box-shadow: 0px 0px 14px 0px rgba(0,10,38,0.30);border-radius:8px;position:absolute;z-index:9999;right:0;bottom:0;justify-content:center;align-items:center;cursor:default;user-select:none;overflow: hidden;}`),i.insertRule(".meta2d-map img{max-width:100%;max-height:100%;pointer-events: none;}"),i.insertRule(".meta2d-map div{pointer-events: none;border:1px solid #1890ff;position:absolute}")}}show(){this.box.style.display="flex",this.parent.store.data.pens.length?(this.img.style.display="block",this.img.src=this.parent.toPng(0,void 0,!0),this.setView()):this.img.style.display="none",this.isShow=!0}hide(){this.box.style.display="none",this.isShow=!1}setView(){const t=this.parent.store.data;if(t.pens.length){let i=pi(t.pens);const s=this.parent.store.data.width||this.parent.store.options.width,n=this.parent.store.data.height||this.parent.store.options.height;if(s&&n?i={x:this.parent.store.data.origin.x,y:this.parent.store.data.origin.y,width:s*this.parent.store.data.scale,height:n*this.parent.store.data.scale}:(clearTimeout(this.timer),this.timer=setTimeout(()=>{this.parent.store.bkImg&&(this.img.src=this.parent.toPng(0,void 0,!0))},300)),Ms(i,t.x,t.y),i.width/i.height>this.ratio){const f=i.width/this.ratio;i.y-=(f-i.height)/2,i.height=f,ae(i)}else{const f=i.height*this.ratio;i.x-=(f-i.width)/2,i.width=f,ae(i)}const a=this.parent.canvasRect;let o=0,l=0;if(i.x<0)o=-i.x/i.width;else if(i.x+i.width>a.width){let f=0;a.width>i.width&&(f=a.width-i.width),o=(-i.x+f)/i.width}if(i.y<0)l=-i.y/i.height;else if(i.y+i.height>a.height){let f=0;a.height>i.height&&(f=a.height-i.height),l=(-i.y+f)/i.height}const u=a.width>i.width?1:a.width/i.width,h=a.height>i.height?1:a.height/i.height;this.view.style.left=this.padding+o*this.boxWidth+"px",this.view.style.width=u*this.boxWidth+"px",this.view.style.top=this.padding+l*this.boxHeight+"px",this.view.style.height=h*this.boxHeight+"px"}}}function ka(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 er={exports:{}};(function(e,t){(function(i){e.exports=i()})(function(){return function(){return function i(s,n,r){function a(u,h){if(!n[u]){if(!s[u]){var f=typeof ka=="function"&&ka;if(!h&&f)return f(u,!0);if(o)return o(u,!0);var g=new Error("Cannot find module '"+u+"'");throw g.code="MODULE_NOT_FOUND",g}var v=n[u]={exports:{}};s[u][0].call(v.exports,function(y){return a(s[u][1][y]||y)},v,v.exports,i,s,n,r)}return n[u].exports}for(var o=typeof ka=="function"&&ka,l=0;l<r.length;l++)a(r[l]);return a}}()({1:[function(i,s,n){(function(r,a){(function(){const o=i("events").EventEmitter,l=i("./store"),u=i("./topic-alias-recv"),h=i("./topic-alias-send"),f=i("mqtt-packet"),g=i("./default-message-id-provider"),v=i("readable-stream").Writable,y=i("inherits"),w=i("reinterval"),p=i("rfdc/default"),_=i("./validations"),E=i("xtend"),x=i("debug")("mqttjs:client"),C=r?r.nextTick:function(P){setTimeout(P,0)},S=a.setImmediate||function(P){C(P)},D={keepalive:60,reschedulePings:!0,protocolId:"MQTT",protocolVersion:4,reconnectPeriod:1e3,connectTimeout:3e4,clean:!0,resubscribe:!0},B={0:"",1:"Unacceptable protocol version",2:"Identifier rejected",3:"Server unavailable",4:"Bad username or password",5:"Not authorized",16:"No matching subscribers",17:"No subscription existed",128:"Unspecified error",129:"Malformed Packet",130:"Protocol Error",131:"Implementation specific error",132:"Unsupported Protocol Version",133:"Client Identifier not valid",134:"Bad User Name or Password",135:"Not authorized",136:"Server unavailable",137:"Server busy",138:"Banned",139:"Server shutting down",140:"Bad authentication method",141:"Keep Alive timeout",142:"Session taken over",143:"Topic Filter invalid",144:"Topic Name invalid",145:"Packet identifier in use",146:"Packet Identifier not found",147:"Receive Maximum exceeded",148:"Topic Alias invalid",149:"Packet too large",150:"Message rate too high",151:"Quota exceeded",152:"Administrative action",153:"Payload format invalid",154:"Retain not supported",155:"QoS not supported",156:"Use another server",157:"Server moved",158:"Shared Subscriptions not supported",159:"Connection rate exceeded",160:"Maximum connect time",161:"Subscription Identifiers not supported",162:"Wildcard Subscriptions not supported"};function L(P,O){let Y;O.properties&&(Y=O.properties.topicAlias);let Z=O.topic.toString();if(Z.length===0){if(Y===void 0)return new Error("Unregistered Topic Alias");if((Z=P.topicAliasSend.getTopicByAlias(Y))===void 0)return new Error("Unregistered Topic Alias");O.topic=Z}Y&&delete O.properties.topicAlias}function V(P,O,Y){x("sendPacket :: packet: %O",O),x("sendPacket :: emitting `packetsend`"),P.emit("packetsend",O),x("sendPacket :: writing to stream");const Z=f.writeToStream(O,P.stream,P.options);x("sendPacket :: writeToStream result %s",Z),!Z&&Y&&Y!==T?(x("sendPacket :: handle events on `drain` once through callback."),P.stream.once("drain",Y)):Y&&(x("sendPacket :: invoking cb"),Y())}function tt(P,O,Y,Z){x("storeAndSend :: store packet with cmd %s to outgoingStore",O.cmd);let rt,$=O;if($.cmd==="publish"&&($=p(O),rt=L(P,$)))return Y&&Y(rt);P.outgoingStore.put($,function(H){if(H)return Y&&Y(H);Z(),V(P,O,Y)})}function T(P){x("nop ::",P)}function R(P,O){let Y;const Z=this;if(!(this instanceof R))return new R(P,O);for(Y in this.options=O||{},D)this.options[Y]===void 0?this.options[Y]=D[Y]:this.options[Y]=O[Y];x("MqttClient :: options.protocol",O.protocol),x("MqttClient :: options.protocolVersion",O.protocolVersion),x("MqttClient :: options.username",O.username),x("MqttClient :: options.keepalive",O.keepalive),x("MqttClient :: options.reconnectPeriod",O.reconnectPeriod),x("MqttClient :: options.rejectUnauthorized",O.rejectUnauthorized),x("MqttClient :: options.topicAliasMaximum",O.topicAliasMaximum),this.options.clientId=typeof O.clientId=="string"?O.clientId:"mqttjs_"+Math.random().toString(16).substr(2,8),x("MqttClient :: clientId",this.options.clientId),this.options.customHandleAcks=O.protocolVersion===5&&O.customHandleAcks?O.customHandleAcks:function(){arguments[3](0)},this.streamBuilder=P,this.messageIdProvider=this.options.messageIdProvider===void 0?new g:this.options.messageIdProvider,this.outgoingStore=O.outgoingStore||new l,this.incomingStore=O.incomingStore||new l,this.queueQoSZero=O.queueQoSZero===void 0||O.queueQoSZero,this._resubscribeTopics={},this.messageIdToTopic={},this.pingTimer=null,this.connected=!1,this.disconnecting=!1,this.queue=[],this.connackTimer=null,this.reconnectTimer=null,this._storeProcessing=!1,this._packetIdsDuringStoreProcessing={},this._storeProcessingQueue=[],this.outgoing={},this._firstConnection=!0,O.topicAliasMaximum>0&&(O.topicAliasMaximum>65535?x("MqttClient :: options.topicAliasMaximum is out of range"):this.topicAliasRecv=new u(O.topicAliasMaximum)),this.on("connect",function(){const rt=this.queue;x("connect :: sending queued packets"),function $(){const H=rt.shift();x("deliver :: entry %o",H);let j=null;if(!H)return void Z._resubscribe();j=H.packet,x("deliver :: call _sendPacket for %o",j);let K=!0;j.messageId&&j.messageId!==0&&(Z.messageIdProvider.register(j.messageId)||(K=!1)),K?Z._sendPacket(j,function(W){H.cb&&H.cb(W),$()}):(x("messageId: %d has already used. The message is skipped and removed.",j.messageId),$())}()}),this.on("close",function(){x("close :: connected set to `false`"),this.connected=!1,x("close :: clearing connackTimer"),clearTimeout(this.connackTimer),x("close :: clearing ping timer"),Z.pingTimer!==null&&(Z.pingTimer.clear(),Z.pingTimer=null),this.topicAliasRecv&&this.topicAliasRecv.clear(),x("close :: calling _setupReconnect"),this._setupReconnect()}),o.call(this),x("MqttClient :: setting up stream"),this._setupStream()}y(R,o),R.prototype._setupStream=function(){const P=this,O=new v,Y=f.parser(this.options);let Z=null;const rt=[];function $(){if(rt.length)C(H);else{const K=Z;Z=null,K()}}function H(){x("work :: getting next packet in queue");const K=rt.shift();if(K)x("work :: packet pulled from queue"),P._handlePacket(K,$);else{x("work :: no packets in queue");const W=Z;Z=null,x("work :: done flag is %s",!!W),W&&W()}}x("_setupStream :: calling method to clear reconnect"),this._clearReconnect(),x("_setupStream :: using streamBuilder provided to client to create stream"),this.stream=this.streamBuilder(this),Y.on("packet",function(K){x("parser :: on packet push to packets array."),rt.push(K)}),O._write=function(K,W,Q){Z=Q,x("writable stream :: parsing buffer"),Y.parse(K),H()},x("_setupStream :: pipe stream to writable stream"),this.stream.pipe(O),this.stream.on("error",function(K){x("streamErrorHandler :: error",K.message),K.code?(x("streamErrorHandler :: emitting error"),P.emit("error",K)):T(K)}),this.stream.on("close",function(){var K;x("(%s)stream :: on close",P.options.clientId),(K=P.outgoing)&&(x("flushVolatile :: deleting volatile messages from the queue and setting their callbacks as error function"),Object.keys(K).forEach(function(W){K[W].volatile&&typeof K[W].cb=="function"&&(K[W].cb(new Error("Connection closed")),delete K[W])})),x("stream: emit close to MqttClient"),P.emit("close")}),x("_setupStream: sending packet `connect`");const j=Object.create(this.options);if(j.cmd="connect",this.topicAliasRecv&&(j.properties||(j.properties={}),this.topicAliasRecv&&(j.properties.topicAliasMaximum=this.topicAliasRecv.max)),V(this,j),Y.on("error",this.emit.bind(this,"error")),this.options.properties){if(!this.options.properties.authenticationMethod&&this.options.properties.authenticationData)return P.end(()=>this.emit("error",new Error("Packet has no Authentication Method"))),this;this.options.properties.authenticationMethod&&this.options.authPacket&&typeof this.options.authPacket=="object"&&V(this,E({cmd:"auth",reasonCode:0},this.options.authPacket))}this.stream.setMaxListeners(1e3),clearTimeout(this.connackTimer),this.connackTimer=setTimeout(function(){x("!!connectTimeout hit!! Calling _cleanUp with force `true`"),P._cleanUp(!0)},this.options.connectTimeout)},R.prototype._handlePacket=function(P,O){const Y=this.options;if(Y.protocolVersion===5&&Y.properties&&Y.properties.maximumPacketSize&&Y.properties.maximumPacketSize<P.length)return this.emit("error",new Error("exceeding packets size "+P.cmd)),this.end({reasonCode:149,properties:{reasonString:"Maximum packet size was exceeded"}}),this;switch(x("_handlePacket :: emitting packetreceive"),this.emit("packetreceive",P),P.cmd){case"publish":this._handlePublish(P,O);break;case"puback":case"pubrec":case"pubcomp":case"suback":case"unsuback":this._handleAck(P),O();break;case"pubrel":this._handlePubrel(P,O);break;case"connack":this._handleConnack(P),O();break;case"auth":this._handleAuth(P),O();break;case"pingresp":this._handlePingresp(P),O();break;case"disconnect":this._handleDisconnect(P),O()}},R.prototype._checkDisconnecting=function(P){return this.disconnecting&&(P&&P!==T?P(new Error("client disconnecting")):this.emit("error",new Error("client disconnecting"))),this.disconnecting},R.prototype.publish=function(P,O,Y,Z){x("publish :: message `%s` to topic `%s`",O,P);const rt=this.options;if(typeof Y=="function"&&(Z=Y,Y=null),Y=E({qos:0,retain:!1,dup:!1},Y),this._checkDisconnecting(Z))return this;const $=this,H=function(){let j=0;if((Y.qos===1||Y.qos===2)&&(j=$._nextId())===null)return x("No messageId left"),!1;const K={cmd:"publish",topic:P,payload:O,qos:Y.qos,retain:Y.retain,messageId:j,dup:Y.dup};switch(rt.protocolVersion===5&&(K.properties=Y.properties),x("publish :: qos",Y.qos),Y.qos){case 1:case 2:$.outgoing[K.messageId]={volatile:!1,cb:Z||T},x("MqttClient:publish: packet cmd: %s",K.cmd),$._sendPacket(K,void 0,Y.cbStorePut);break;default:x("MqttClient:publish: packet cmd: %s",K.cmd),$._sendPacket(K,Z,Y.cbStorePut)}return!0};return(this._storeProcessing||this._storeProcessingQueue.length>0||!H())&&this._storeProcessingQueue.push({invoke:H,cbStorePut:Y.cbStorePut,callback:Z}),this},R.prototype.subscribe=function(){const P=this,O=new Array(arguments.length);for(let st=0;st<arguments.length;st++)O[st]=arguments[st];const Y=[];let Z=O.shift();const rt=Z.resubscribe;let $=O.pop()||T,H=O.pop();const j=this.options.protocolVersion;delete Z.resubscribe,typeof Z=="string"&&(Z=[Z]),typeof $!="function"&&(H=$,$=T);const K=_.validateTopics(Z);if(K!==null)return S($,new Error("Invalid topic "+K)),this;if(this._checkDisconnecting($))return x("subscribe: discconecting true"),this;const W={qos:0};if(j===5&&(W.nl=!1,W.rap=!1,W.rh=0),H=E(W,H),Array.isArray(Z)?Z.forEach(function(st){if(x("subscribe: array topic %s",st),!Object.prototype.hasOwnProperty.call(P._resubscribeTopics,st)||P._resubscribeTopics[st].qos<H.qos||rt){const et={topic:st,qos:H.qos};j===5&&(et.nl=H.nl,et.rap=H.rap,et.rh=H.rh,et.properties=H.properties),x("subscribe: pushing topic `%s` and qos `%s` to subs list",et.topic,et.qos),Y.push(et)}}):Object.keys(Z).forEach(function(st){if(x("subscribe: object topic %s",st),!Object.prototype.hasOwnProperty.call(P._resubscribeTopics,st)||P._resubscribeTopics[st].qos<Z[st].qos||rt){const et={topic:st,qos:Z[st].qos};j===5&&(et.nl=Z[st].nl,et.rap=Z[st].rap,et.rh=Z[st].rh,et.properties=H.properties),x("subscribe: pushing `%s` to subs list",et),Y.push(et)}}),!Y.length)return $(null,[]),this;const Q=function(){const st=P._nextId();if(st===null)return x("No messageId left"),!1;const et={cmd:"subscribe",subscriptions:Y,qos:1,retain:!1,dup:!1,messageId:st};if(H.properties&&(et.properties=H.properties),P.options.resubscribe){x("subscribe :: resubscribe true");const ut=[];Y.forEach(function(ct){if(P.options.reconnectPeriod>0){const ot={qos:ct.qos};j===5&&(ot.nl=ct.nl||!1,ot.rap=ct.rap||!1,ot.rh=ct.rh||0,ot.properties=ct.properties),P._resubscribeTopics[ct.topic]=ot,ut.push(ct.topic)}}),P.messageIdToTopic[et.messageId]=ut}return P.outgoing[et.messageId]={volatile:!0,cb:function(ut,ct){if(!ut){const ot=ct.granted;for(let b=0;b<ot.length;b+=1)Y[b].qos=ot[b]}$(ut,Y)}},x("subscribe :: call _sendPacket"),P._sendPacket(et),!0};return(this._storeProcessing||this._storeProcessingQueue.length>0||!Q())&&this._storeProcessingQueue.push({invoke:Q,callback:$}),this},R.prototype.unsubscribe=function(){const P=this,O=new Array(arguments.length);for(let j=0;j<arguments.length;j++)O[j]=arguments[j];let Y=O.shift(),Z=O.pop()||T,rt=O.pop();typeof Y=="string"&&(Y=[Y]),typeof Z!="function"&&(rt=Z,Z=T);const $=_.validateTopics(Y);if($!==null)return S(Z,new Error("Invalid topic "+$)),this;if(P._checkDisconnecting(Z))return this;const H=function(){const j=P._nextId();if(j===null)return x("No messageId left"),!1;const K={cmd:"unsubscribe",qos:1,messageId:j};return typeof Y=="string"?K.unsubscriptions=[Y]:Array.isArray(Y)&&(K.unsubscriptions=Y),P.options.resubscribe&&K.unsubscriptions.forEach(function(W){delete P._resubscribeTopics[W]}),typeof rt=="object"&&rt.properties&&(K.properties=rt.properties),P.outgoing[K.messageId]={volatile:!0,cb:Z},x("unsubscribe: call _sendPacket"),P._sendPacket(K),!0};return(this._storeProcessing||this._storeProcessingQueue.length>0||!H())&&this._storeProcessingQueue.push({invoke:H,callback:Z}),this},R.prototype.end=function(P,O,Y){const Z=this;function rt(){x("end :: (%s) :: finish :: calling _cleanUp with force %s",Z.options.clientId,P),Z._cleanUp(P,()=>{x("end :: finish :: calling process.nextTick on closeStores"),C(function(){x("end :: closeStores: closing incoming and outgoing stores"),Z.disconnected=!0,Z.incomingStore.close(function($){Z.outgoingStore.close(function(H){if(x("end :: closeStores: emitting end"),Z.emit("end"),Y){const j=$||H;x("end :: closeStores: invoking callback with args"),Y(j)}})}),Z._deferredReconnect&&Z._deferredReconnect()}.bind(Z))},O)}return x("end :: (%s)",this.options.clientId),P!=null&&typeof P=="boolean"||(Y=O||T,O=P,P=!1,typeof O!="object"&&(Y=O,O=null,typeof Y!="function"&&(Y=T))),typeof O!="object"&&(Y=O,O=null),x("end :: cb? %s",!!Y),Y=Y||T,this.disconnecting?(Y(),this):(this._clearReconnect(),this.disconnecting=!0,!P&&Object.keys(this.outgoing).length>0?(x("end :: (%s) :: calling finish in 10ms once outgoing is empty",Z.options.clientId),this.once("outgoingEmpty",setTimeout.bind(null,rt,10))):(x("end :: (%s) :: immediately calling finish",Z.options.clientId),rt()),this)},R.prototype.removeOutgoingMessage=function(P){const O=this.outgoing[P]?this.outgoing[P].cb:null;return delete this.outgoing[P],this.outgoingStore.del({messageId:P},function(){O(new Error("Message removed"))}),this},R.prototype.reconnect=function(P){x("client reconnect");const O=this,Y=function(){P?(O.options.incomingStore=P.incomingStore,O.options.outgoingStore=P.outgoingStore):(O.options.incomingStore=null,O.options.outgoingStore=null),O.incomingStore=O.options.incomingStore||new l,O.outgoingStore=O.options.outgoingStore||new l,O.disconnecting=!1,O.disconnected=!1,O._deferredReconnect=null,O._reconnect()};return this.disconnecting&&!this.disconnected?this._deferredReconnect=Y:Y(),this},R.prototype._reconnect=function(){x("_reconnect: emitting reconnect to client"),this.emit("reconnect"),this.connected?(this.end(()=>{this._setupStream()}),x("client already connected. disconnecting first.")):(x("_reconnect: calling _setupStream"),this._setupStream())},R.prototype._setupReconnect=function(){const P=this;!P.disconnecting&&!P.reconnectTimer&&P.options.reconnectPeriod>0?(this.reconnecting||(x("_setupReconnect :: emit `offline` state"),this.emit("offline"),x("_setupReconnect :: set `reconnecting` to `true`"),this.reconnecting=!0),x("_setupReconnect :: setting reconnectTimer for %d ms",P.options.reconnectPeriod),P.reconnectTimer=setInterval(function(){x("reconnectTimer :: reconnect triggered!"),P._reconnect()},P.options.reconnectPeriod)):x("_setupReconnect :: doing nothing...")},R.prototype._clearReconnect=function(){x("_clearReconnect : clearing reconnect timer"),this.reconnectTimer&&(clearInterval(this.reconnectTimer),this.reconnectTimer=null)},R.prototype._cleanUp=function(P,O){const Y=arguments[2];if(O&&(x("_cleanUp :: done callback provided for on stream close"),this.stream.on("close",O)),x("_cleanUp :: forced? %s",P),P)this.options.reconnectPeriod===0&&this.options.clean&&(Z=this.outgoing)&&(x("flush: queue exists? %b",!!Z),Object.keys(Z).forEach(function(rt){typeof Z[rt].cb=="function"&&(Z[rt].cb(new Error("Connection closed")),delete Z[rt])})),x("_cleanUp :: (%s) :: destroying stream",this.options.clientId),this.stream.destroy();else{const rt=E({cmd:"disconnect"},Y);x("_cleanUp :: (%s) :: call _sendPacket with disconnect packet",this.options.clientId),this._sendPacket(rt,S.bind(null,this.stream.end.bind(this.stream)))}var Z;this.disconnecting||(x("_cleanUp :: client not disconnecting. Clearing and resetting reconnect."),this._clearReconnect(),this._setupReconnect()),this.pingTimer!==null&&(x("_cleanUp :: clearing pingTimer"),this.pingTimer.clear(),this.pingTimer=null),O&&!this.connected&&(x("_cleanUp :: (%s) :: removing stream `done` callback `close` listener",this.options.clientId),this.stream.removeListener("close",O),O())},R.prototype._sendPacket=function(P,O,Y){x("_sendPacket :: (%s) :: start",this.options.clientId),Y=Y||T,O=O||T;const Z=function(rt,$){if(rt.options.protocolVersion===5&&$.cmd==="publish"){let H;$.properties&&(H=$.properties.topicAlias);const j=$.topic.toString();if(rt.topicAliasSend)if(H){if(j.length!==0&&(x("applyTopicAlias :: register topic: %s - alias: %d",j,H),!rt.topicAliasSend.put(j,H)))return x("applyTopicAlias :: error out of range. topic: %s - alias: %d",j,H),new Error("Sending Topic Alias out of range")}else j.length!==0&&(rt.options.autoAssignTopicAlias?(H=rt.topicAliasSend.getAliasByTopic(j))?($.topic="",$.properties={...$.properties,topicAlias:H},x("applyTopicAlias :: auto assign(use) topic: %s - alias: %d",j,H)):(H=rt.topicAliasSend.getLruAlias(),rt.topicAliasSend.put(j,H),$.properties={...$.properties,topicAlias:H},x("applyTopicAlias :: auto assign topic: %s - alias: %d",j,H)):rt.options.autoUseTopicAlias&&(H=rt.topicAliasSend.getAliasByTopic(j))&&($.topic="",$.properties={...$.properties,topicAlias:H},x("applyTopicAlias :: auto use topic: %s - alias: %d",j,H)));else if(H)return x("applyTopicAlias :: error out of range. topic: %s - alias: %d",j,H),new Error("Sending Topic Alias out of range")}}(this,P);if(Z)O(Z);else{if(!this.connected)return P.cmd==="auth"?(this._shiftPingInterval(),void V(this,P,O)):(x("_sendPacket :: client not connected. Storing packet offline."),void this._storePacket(P,O,Y));switch(this._shiftPingInterval(),P.cmd){case"publish":break;case"pubrel":return void tt(this,P,O,Y);default:return void V(this,P,O)}switch(P.qos){case 2:case 1:tt(this,P,O,Y);break;case 0:default:V(this,P,O)}x("_sendPacket :: (%s) :: end",this.options.clientId)}},R.prototype._storePacket=function(P,O,Y){x("_storePacket :: packet: %o",P),x("_storePacket :: cb? %s",!!O),Y=Y||T;let Z=P;if(Z.cmd==="publish"){const rt=L(this,Z=p(P));if(rt)return O&&O(rt)}(Z.qos||0)===0&&this.queueQoSZero||Z.cmd!=="publish"?this.queue.push({packet:Z,cb:O}):Z.qos>0?(O=this.outgoing[Z.messageId]?this.outgoing[Z.messageId].cb:null,this.outgoingStore.put(Z,function(rt){if(rt)return O&&O(rt);Y()})):O&&O(new Error("No connection to broker"))},R.prototype._setupPingTimer=function(){x("_setupPingTimer :: keepalive %d (seconds)",this.options.keepalive);const P=this;!this.pingTimer&&this.options.keepalive&&(this.pingResp=!0,this.pingTimer=w(function(){P._checkPing()},1e3*this.options.keepalive))},R.prototype._shiftPingInterval=function(){this.pingTimer&&this.options.keepalive&&this.options.reschedulePings&&this.pingTimer.reschedule(1e3*this.options.keepalive)},R.prototype._checkPing=function(){x("_checkPing :: checking ping..."),this.pingResp?(x("_checkPing :: ping response received. Clearing flag and sending `pingreq`"),this.pingResp=!1,this._sendPacket({cmd:"pingreq"})):(x("_checkPing :: calling _cleanUp with force true"),this._cleanUp(!0))},R.prototype._handlePingresp=function(){this.pingResp=!0},R.prototype._handleConnack=function(P){x("_handleConnack");const O=this.options,Y=O.protocolVersion===5?P.reasonCode:P.returnCode;if(clearTimeout(this.connackTimer),delete this.topicAliasSend,P.properties){if(P.properties.topicAliasMaximum){if(P.properties.topicAliasMaximum>65535)return void this.emit("error",new Error("topicAliasMaximum from broker is out of range"));P.properties.topicAliasMaximum>0&&(this.topicAliasSend=new h(P.properties.topicAliasMaximum))}P.properties.serverKeepAlive&&O.keepalive&&(O.keepalive=P.properties.serverKeepAlive,this._shiftPingInterval()),P.properties.maximumPacketSize&&(O.properties||(O.properties={}),O.properties.maximumPacketSize=P.properties.maximumPacketSize)}if(Y===0)this.reconnecting=!1,this._onConnect(P);else if(Y>0){const Z=new Error("Connection refused: "+B[Y]);Z.code=Y,this.emit("error",Z)}},R.prototype._handleAuth=function(P){const O=this.options.protocolVersion,Y=O===5?P.reasonCode:P.returnCode;if(O!==5){const rt=new Error("Protocol error: Auth packets are only supported in MQTT 5. Your version:"+O);return rt.code=Y,void this.emit("error",rt)}const Z=this;this.handleAuth(P,function(rt,$){if(rt)Z.emit("error",rt);else if(Y===24)Z.reconnecting=!1,Z._sendPacket($);else{const H=new Error("Connection refused: "+B[Y]);rt.code=Y,Z.emit("error",H)}})},R.prototype.handleAuth=function(P,O){O()},R.prototype._handlePublish=function(P,O){x("_handlePublish: packet %o",P),O=O!==void 0?O:T;let Y=P.topic.toString();const Z=P.payload,rt=P.qos,$=P.messageId,H=this,j=this.options,K=[0,16,128,131,135,144,145,151,153];if(this.options.protocolVersion===5){let W;if(P.properties&&(W=P.properties.topicAlias),W!==void 0)if(Y.length===0){if(!(W>0&&W<=65535))return x("_handlePublish :: topic alias out of range. alias: %d",W),void this.emit("error",new Error("Received Topic Alias is out of range"));{const Q=this.topicAliasRecv.getTopicByAlias(W);if(!Q)return x("_handlePublish :: unregistered topic alias. alias: %d",W),void this.emit("error",new Error("Received unregistered Topic Alias"));x("_handlePublish :: topic complemented by alias. topic: %s - alias: %d",Y=Q,W)}}else{if(!this.topicAliasRecv.put(Y,W))return x("_handlePublish :: topic alias out of range. alias: %d",W),void this.emit("error",new Error("Received Topic Alias is out of range"));x("_handlePublish :: registered topic: %s - alias: %d",Y,W)}}switch(x("_handlePublish: qos %d",rt),rt){case 2:j.customHandleAcks(Y,Z,P,function(W,Q){return W instanceof Error||(Q=W,W=null),W?H.emit("error",W):K.indexOf(Q)===-1?H.emit("error",new Error("Wrong reason code for pubrec")):void(Q?H._sendPacket({cmd:"pubrec",messageId:$,reasonCode:Q},O):H.incomingStore.put(P,function(){H._sendPacket({cmd:"pubrec",messageId:$},O)}))});break;case 1:j.customHandleAcks(Y,Z,P,function(W,Q){return W instanceof Error||(Q=W,W=null),W?H.emit("error",W):K.indexOf(Q)===-1?H.emit("error",new Error("Wrong reason code for puback")):(Q||H.emit("message",Y,Z,P),void H.handleMessage(P,function(st){if(st)return O&&O(st);H._sendPacket({cmd:"puback",messageId:$,reasonCode:Q},O)}))});break;case 0:this.emit("message",Y,Z,P),this.handleMessage(P,O);break;default:x("_handlePublish: unknown QoS. Doing nothing.")}},R.prototype.handleMessage=function(P,O){O()},R.prototype._handleAck=function(P){const O=P.messageId,Y=P.cmd;let Z=null;const rt=this.outgoing[O]?this.outgoing[O].cb:null,$=this;let H;if(rt){switch(x("_handleAck :: packet type",Y),Y){case"pubcomp":case"puback":{const j=P.reasonCode;j&&j>0&&j!==16&&((H=new Error("Publish error: "+B[j])).code=j,rt(H,P)),delete this.outgoing[O],this.outgoingStore.del(P,rt),this.messageIdProvider.deallocate(O),this._invokeStoreProcessingQueue();break}case"pubrec":{Z={cmd:"pubrel",qos:2,messageId:O};const j=P.reasonCode;j&&j>0&&j!==16?((H=new Error("Publish error: "+B[j])).code=j,rt(H,P)):this._sendPacket(Z);break}case"suback":delete this.outgoing[O],this.messageIdProvider.deallocate(O);for(let j=0;j<P.granted.length;j++)if((128&P.granted[j])!=0){const K=this.messageIdToTopic[O];K&&K.forEach(function(W){delete $._resubscribeTopics[W]})}this._invokeStoreProcessingQueue(),rt(null,P);break;case"unsuback":delete this.outgoing[O],this.messageIdProvider.deallocate(O),this._invokeStoreProcessingQueue(),rt(null);break;default:$.emit("error",new Error("unrecognized packet type"))}this.disconnecting&&Object.keys(this.outgoing).length===0&&this.emit("outgoingEmpty")}else x("_handleAck :: Server sent an ack in error. Ignoring.")},R.prototype._handlePubrel=function(P,O){x("handling pubrel packet"),O=O!==void 0?O:T;const Y=this,Z={cmd:"pubcomp",messageId:P.messageId};Y.incomingStore.get(P,function(rt,$){rt?Y._sendPacket(Z,O):(Y.emit("message",$.topic,$.payload,$),Y.handleMessage($,function(H){if(H)return O(H);Y.incomingStore.del($,T),Y._sendPacket(Z,O)}))})},R.prototype._handleDisconnect=function(P){this.emit("disconnect",P)},R.prototype._nextId=function(){return this.messageIdProvider.allocate()},R.prototype.getLastMessageId=function(){return this.messageIdProvider.getLastAllocated()},R.prototype._resubscribe=function(){x("_resubscribe");const P=Object.keys(this._resubscribeTopics);if(!this._firstConnection&&(this.options.clean||this.options.protocolVersion===5&&!this.connackPacket.sessionPresent)&&P.length>0)if(this.options.resubscribe)if(this.options.protocolVersion===5){x("_resubscribe: protocolVersion 5");for(let O=0;O<P.length;O++){const Y={};Y[P[O]]=this._resubscribeTopics[P[O]],Y.resubscribe=!0,this.subscribe(Y,{properties:Y[P[O]].properties})}}else this._resubscribeTopics.resubscribe=!0,this.subscribe(this._resubscribeTopics);else this._resubscribeTopics={};this._firstConnection=!1},R.prototype._onConnect=function(P){if(this.disconnected)return void this.emit("connect",P);const O=this;this.connackPacket=P,this.messageIdProvider.clear(),this._setupPingTimer(),this.connected=!0,function Y(){let Z=O.outgoingStore.createStream();function rt(){O._storeProcessing=!1,O._packetIdsDuringStoreProcessing={}}function $(){Z.destroy(),Z=null,O._flushStoreProcessingQueue(),rt()}O.once("close",$),Z.on("error",function(H){rt(),O._flushStoreProcessingQueue(),O.removeListener("close",$),O.emit("error",H)}),Z.on("end",function(){let H=!0;for(const j in O._packetIdsDuringStoreProcessing)if(!O._packetIdsDuringStoreProcessing[j]){H=!1;break}H?(rt(),O.removeListener("close",$),O._invokeAllStoreProcessingQueue(),O.emit("connect",P)):Y()}),function H(){if(!Z)return;O._storeProcessing=!0;const j=Z.read(1);let K;j?O._packetIdsDuringStoreProcessing[j.messageId]?H():O.disconnecting||O.reconnectTimer?Z.destroy&&Z.destroy():(K=O.outgoing[j.messageId]?O.outgoing[j.messageId].cb:null,O.outgoing[j.messageId]={volatile:!1,cb:function(W,Q){K&&K(W,Q),H()}},O._packetIdsDuringStoreProcessing[j.messageId]=!0,O.messageIdProvider.register(j.messageId)?O._sendPacket(j):x("messageId: %d has already used.",j.messageId)):Z.once("readable",H)}()}()},R.prototype._invokeStoreProcessingQueue=function(){if(this._storeProcessingQueue.length>0){const P=this._storeProcessingQueue[0];if(P&&P.invoke())return this._storeProcessingQueue.shift(),!0}return!1},R.prototype._invokeAllStoreProcessingQueue=function(){for(;this._invokeStoreProcessingQueue(););},R.prototype._flushStoreProcessingQueue=function(){for(const P of this._storeProcessingQueue)P.cbStorePut&&P.cbStorePut(new Error("Connection closed")),P.callback&&P.callback(new Error("Connection closed"));this._storeProcessingQueue.splice(0)},s.exports=R}).call(this)}).call(this,i("_process"),typeof De<"u"?De: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,s,n){const{Buffer:r}=i("buffer"),a=i("readable-stream").Transform,o=i("duplexify");let l,u,h,f=!1;s.exports=function(g,v){if(v.hostname=v.hostname||v.host,!v.hostname)throw new Error("Could not determine host. Specify host manually.");const y=v.protocolId==="MQIsdp"&&v.protocolVersion===3?"mqttv3.1":"mqtt";(function(p){p.hostname||(p.hostname="localhost"),p.path||(p.path="/"),p.wsOptions||(p.wsOptions={})})(v);const w=function(p,_){const E=p.protocol==="alis"?"wss":"ws";let x=E+"://"+p.hostname+p.path;return p.port&&p.port!==80&&p.port!==443&&(x=E+"://"+p.hostname+":"+p.port+p.path),typeof p.transformWsUrl=="function"&&(x=p.transformWsUrl(x,p,_)),x}(v,g);return(l=v.my).connectSocket({url:w,protocols:y}),u=function(){const p=new a;return p._write=function(_,E,x){l.sendSocketMessage({data:_.buffer,success:function(){x()},fail:function(){x(new Error)}})},p._flush=function(_){l.closeSocket({success:function(){_()}})},p}(),h=o.obj(),f||(f=!0,l.onSocketOpen(function(){h.setReadable(u),h.setWritable(u),h.emit("connect")}),l.onSocketMessage(function(p){if(typeof p.data=="string"){const _=r.from(p.data,"base64");u.push(_)}else{const _=new FileReader;_.addEventListener("load",function(){let E=_.result;E=E instanceof ArrayBuffer?r.from(E):r.from(E,"utf8"),u.push(E)}),_.readAsArrayBuffer(p.data)}}),l.onSocketClose(function(){h.end(),h.destroy()}),l.onSocketError(function(p){h.destroy(p)})),h}},{buffer:17,duplexify:20,"readable-stream":69}],3:[function(i,s,n){const r=i("net"),a=i("debug")("mqttjs:tcp");s.exports=function(o,l){l.port=l.port||1883,l.hostname=l.hostname||l.host||"localhost";const u=l.port,h=l.hostname;return a("port %d and host %s",u,h),r.createConnection(u,h)}},{debug:18,net:16}],4:[function(i,s,n){const r=i("tls"),a=i("net"),o=i("debug")("mqttjs:tls");s.exports=function(l,u){u.port=u.port||8883,u.host=u.hostname||u.host||"localhost",a.isIP(u.host)===0&&(u.servername=u.host),u.rejectUnauthorized=u.rejectUnauthorized!==!1,delete u.path,o("port %d host %s rejectUnauthorized %b",u.port,u.host,u.rejectUnauthorized);const h=r.connect(u);function f(g){u.rejectUnauthorized&&l.emit("error",g),h.end()}return h.on("secureConnect",function(){u.rejectUnauthorized&&!h.authorized?h.emit("error",new Error("TLS not authorized")):h.removeListener("error",f)}),h.on("error",f),h}},{debug:18,net:16,tls:16}],5:[function(i,s,n){(function(r){(function(){const{Buffer:a}=i("buffer"),o=i("ws"),l=i("debug")("mqttjs:ws"),u=i("duplexify"),h=i("readable-stream").Transform,f=["rejectUnauthorized","ca","cert","key","pfx","passphrase"],g=r!==void 0&&r.title==="browser"||typeof __webpack_require__=="function";function v(w,p){let _=w.protocol+"://"+w.hostname+":"+w.port+w.path;return typeof w.transformWsUrl=="function"&&(_=w.transformWsUrl(_,w,p)),_}function y(w){const p=w;return w.hostname||(p.hostname="localhost"),w.port||(w.protocol==="wss"?p.port=443:p.port=80),w.path||(p.path="/"),w.wsOptions||(p.wsOptions={}),g||w.protocol!=="wss"||f.forEach(function(_){Object.prototype.hasOwnProperty.call(w,_)&&!Object.prototype.hasOwnProperty.call(w.wsOptions,_)&&(p.wsOptions[_]=w[_])}),p}s.exports=g?function(w,p){let _;l("browserStreamBuilder");const E=function(P){const O=y(P);if(O.hostname||(O.hostname=O.host),!O.hostname){if(typeof document>"u")throw new Error("Could not determine host. Specify host manually.");const Y=new URL(document.URL);O.hostname=Y.hostname,O.port||(O.port=Y.port)}return O.objectMode===void 0&&(O.objectMode=!(O.binary===!0||O.binary===void 0)),O}(p).browserBufferSize||524288,x=p.browserBufferTimeout||1e3,C=!p.objectMode,S=function(P,O){const Y=O.protocolId==="MQIsdp"&&O.protocolVersion===3?"mqttv3.1":"mqtt",Z=v(O,P),rt=new WebSocket(Z,[Y]);return rt.binaryType="arraybuffer",rt}(w,p),D=function(P,O,Y){const Z=new h({objectModeMode:P.objectMode});return Z._write=O,Z._flush=Y,Z}(p,function P(O,Y,Z){S.bufferedAmount>E&&setTimeout(P,x,O,Y,Z),C&&typeof O=="string"&&(O=a.from(O,"utf8"));try{S.send(O)}catch(rt){return Z(rt)}Z()},function(P){S.close(),P()});p.objectMode||(D._writev=R),D.on("close",()=>{S.close()});const B=S.addEventListener!==void 0;function L(){_.setReadable(D),_.setWritable(D),_.emit("connect")}function V(){_.end(),_.destroy()}function tt(P){_.destroy(P)}function T(P){let O=P.data;O=O instanceof ArrayBuffer?a.from(O):a.from(O,"utf8"),D.push(O)}function R(P,O){const Y=new Array(P.length);for(let Z=0;Z<P.length;Z++)typeof P[Z].chunk=="string"?Y[Z]=a.from(P[Z],"utf8"):Y[Z]=P[Z].chunk;this._write(a.concat(Y),"binary",O)}return S.readyState===S.OPEN?_=D:(_=_=u(void 0,void 0,p),p.objectMode||(_._writev=R),B?S.addEventListener("open",L):S.onopen=L),_.socket=S,B?(S.addEventListener("close",V),S.addEventListener("error",tt),S.addEventListener("message",T)):(S.onclose=V,S.onerror=tt,S.onmessage=T),_}:function(w,p){l("streamBuilder");const _=y(p),E=v(_,w),x=function(S,D,B){l("createWebSocket"),l("protocol: "+B.protocolId+" "+B.protocolVersion);const L=B.protocolId==="MQIsdp"&&B.protocolVersion===3?"mqttv3.1":"mqtt";return l("creating new Websocket for url: "+D+" and protocol: "+L),new o(D,[L],B.wsOptions)}(0,E,_),C=o.createWebSocketStream(x,_.wsOptions);return C.url=E,x.on("close",()=>{C.destroy()}),C}}).call(this)}).call(this,i("_process"))},{_process:50,buffer:17,debug:18,duplexify:20,"readable-stream":69,ws:80}],6:[function(i,s,n){const{Buffer:r}=i("buffer"),a=i("readable-stream").Transform,o=i("duplexify");let l,u,h;s.exports=function(f,g){if(g.hostname=g.hostname||g.host,!g.hostname)throw new Error("Could not determine host. Specify host manually.");const v=g.protocolId==="MQIsdp"&&g.protocolVersion===3?"mqttv3.1":"mqtt";(function(p){p.hostname||(p.hostname="localhost"),p.path||(p.path="/"),p.wsOptions||(p.wsOptions={})})(g);const y=function(p,_){const E=p.protocol==="wxs"?"wss":"ws";let x=E+"://"+p.hostname+p.path;return p.port&&p.port!==80&&p.port!==443&&(x=E+"://"+p.hostname+":"+p.port+p.path),typeof p.transformWsUrl=="function"&&(x=p.transformWsUrl(x,p,_)),x}(g,f);l=wx.connectSocket({url:y,protocols:[v]}),u=function(){const p=new a;return p._write=function(_,E,x){l.send({data:_.buffer,success:function(){x()},fail:function(C){x(new Error(C))}})},p._flush=function(_){l.close({success:function(){_()}})},p}(),(h=o.obj())._destroy=function(p,_){l.close({success:function(){_&&_(p)}})};const w=h.destroy;return h.destroy=function(){h.destroy=w;const p=this;setTimeout(function(){l.close({fail:function(){p._destroy(new Error)}})},0)}.bind(h),l.onOpen(function(){h.setReadable(u),h.setWritable(u),h.emit("connect")}),l.onMessage(function(p){let _=p.data;_=_ instanceof ArrayBuffer?r.from(_):r.from(_,"utf8"),u.push(_)}),l.onClose(function(){h.end(),h.destroy()}),l.onError(function(p){h.destroy(new Error(p.errMsg))}),h}},{buffer:17,duplexify:20,"readable-stream":69}],7:[function(i,s,n){function r(){if(!(this instanceof r))return new r;this.nextId=Math.max(1,Math.floor(65535*Math.random()))}r.prototype.allocate=function(){const a=this.nextId++;return this.nextId===65536&&(this.nextId=1),a},r.prototype.getLastAllocated=function(){return this.nextId===1?65535:this.nextId-1},r.prototype.register=function(a){return!0},r.prototype.deallocate=function(a){},r.prototype.clear=function(){},s.exports=r},{}],8:[function(i,s,n){const r=i("xtend"),a=i("readable-stream").Readable,o={objectMode:!0},l={clean:!0};function u(h){if(!(this instanceof u))return new u(h);this.options=h||{},this.options=r(l,h),this._inflights=new Map}u.prototype.put=function(h,f){return this._inflights.set(h.messageId,h),f&&f(),this},u.prototype.createStream=function(){const h=new a(o),f=[];let g=!1,v=0;return this._inflights.forEach(function(y,w){f.push(y)}),h._read=function(){!g&&v<f.length?this.push(f[v++]):this.push(null)},h.destroy=function(){if(g)return;const y=this;g=!0,setTimeout(function(){y.emit("close")},0)},h},u.prototype.del=function(h,f){return(h=this._inflights.get(h.messageId))?(this._inflights.delete(h.messageId),f(null,h)):f&&f(new Error("missing packet")),this},u.prototype.get=function(h,f){return(h=this._inflights.get(h.messageId))?f(null,h):f&&f(new Error("missing packet")),this},u.prototype.close=function(h){this.options.clean&&(this._inflights=null),h&&h()},s.exports=u},{"readable-stream":69,xtend:81}],9:[function(i,s,n){function r(a){if(!(this instanceof r))return new r(a);this.aliasToTopic={},this.max=a}r.prototype.put=function(a,o){return!(o===0||o>this.max)&&(this.aliasToTopic[o]=a,this.length=Object.keys(this.aliasToTopic).length,!0)},r.prototype.getTopicByAlias=function(a){return this.aliasToTopic[a]},r.prototype.clear=function(){this.aliasToTopic={}},s.exports=r},{}],10:[function(i,s,n){const r=i("lru-cache"),a=i("number-allocator").NumberAllocator;function o(l){if(!(this instanceof o))return new o(l);l>0&&(this.aliasToTopic=new r({max:l}),this.topicToAlias={},this.numberAllocator=new a(1,l),this.max=l,this.length=0)}o.prototype.put=function(l,u){if(u===0||u>this.max)return!1;const h=this.aliasToTopic.get(u);return h&&delete this.topicToAlias[h],this.aliasToTopic.set(u,l),this.topicToAlias[l]=u,this.numberAllocator.use(u),this.length=this.aliasToTopic.length,!0},o.prototype.getTopicByAlias=function(l){return this.aliasToTopic.get(l)},o.prototype.getAliasByTopic=function(l){const u=this.topicToAlias[l];return u!==void 0&&this.aliasToTopic.get(u),u},o.prototype.clear=function(){this.aliasToTopic.reset(),this.topicToAlias={},this.numberAllocator.clear(),this.length=0},o.prototype.getLruAlias=function(){return this.numberAllocator.firstVacant()||this.aliasToTopic.keys()[this.aliasToTopic.length-1]},s.exports=o},{"lru-cache":37,"number-allocator":46}],11:[function(i,s,n){function r(a){const o=a.split("/");for(let l=0;l<o.length;l++)if(o[l]!=="+"){if(o[l]==="#")return l===o.length-1;if(o[l].indexOf("+")!==-1||o[l].indexOf("#")!==-1)return!1}return!0}s.exports={validateTopics:function(a){if(a.length===0)return"empty_topic_list";for(let o=0;o<a.length;o++)if(!r(a[o]))return a[o];return null}}},{}],12:[function(i,s,n){(function(r){(function(){const a=i("../client"),o=i("../store"),l=i("url"),u=i("xtend"),h=i("debug")("mqttjs"),f={};function g(v,y){if(h("connecting to an MQTT broker..."),typeof v!="object"||y||(y=v,v=null),y=y||{},v){const p=l.parse(v,!0);if(p.port!=null&&(p.port=Number(p.port)),(y=u(p,y)).protocol===null)throw new Error("Missing protocol");y.protocol=y.protocol.replace(/:$/,"")}if(function(p){let _;p.auth&&((_=p.auth.match(/^(.+):(.+)$/))?(p.username=_[1],p.password=_[2]):p.username=p.auth)}(y),y.query&&typeof y.query.clientId=="string"&&(y.clientId=y.query.clientId),y.cert&&y.key){if(!y.protocol)throw new Error("Missing secure protocol key");if(["mqtts","wss","wxs","alis"].indexOf(y.protocol)===-1)switch(y.protocol){case"mqtt":y.protocol="mqtts";break;case"ws":y.protocol="wss";break;case"wx":y.protocol="wxs";break;case"ali":y.protocol="alis";break;default:throw new Error('Unknown protocol for secure connection: "'+y.protocol+'"!')}}if(!f[y.protocol]){const p=["mqtts","wss"].indexOf(y.protocol)!==-1;y.protocol=["mqtt","mqtts","ws","wss","wx","wxs","ali","alis"].filter(function(_,E){return(!p||E%2!=0)&&typeof f[_]=="function"})[0]}if(y.clean===!1&&!y.clientId)throw new Error("Missing clientId for unclean clients");y.protocol&&(y.defaultProtocol=y.protocol);const w=new a(function(p){return y.servers&&(p._reconnectCount&&p._reconnectCount!==y.servers.length||(p._reconnectCount=0),y.host=y.servers[p._reconnectCount].host,y.port=y.servers[p._reconnectCount].port,y.protocol=y.servers[p._reconnectCount].protocol?y.servers[p._reconnectCount].protocol:y.defaultProtocol,y.hostname=y.host,p._reconnectCount++),h("calling streambuilder for",y.protocol),f[y.protocol](p,y)},y);return w.on("error",function(){}),w}r!==void 0&&r.title!=="browser"||typeof __webpack_require__!="function"?(f.mqtt=i("./tcp"),f.tcp=i("./tcp"),f.ssl=i("./tls"),f.tls=i("./tls"),f.mqtts=i("./tls")):(f.wx=i("./wx"),f.wxs=i("./wx"),f.ali=i("./ali"),f.alis=i("./ali")),f.ws=i("./ws"),f.wss=i("./ws"),s.exports=g,s.exports.connect=g,s.exports.MqttClient=a,s.exports.Store=o}).call(this)}).call(this,i("_process"))},{"../client":1,"../store":8,"./ali":2,"./tcp":3,"./tls":4,"./ws":5,"./wx":6,_process:50,debug:18,url:76,xtend:81}],13:[function(i,s,n){n.byteLength=function(v){var y=f(v),w=y[0],p=y[1];return 3*(w+p)/4-p},n.toByteArray=function(v){var y,w,p=f(v),_=p[0],E=p[1],x=new o(function(D,B,L){return 3*(B+L)/4-L}(0,_,E)),C=0,S=E>0?_-4:_;for(w=0;w<S;w+=4)y=a[v.charCodeAt(w)]<<18|a[v.charCodeAt(w+1)]<<12|a[v.charCodeAt(w+2)]<<6|a[v.charCodeAt(w+3)],x[C++]=y>>16&255,x[C++]=y>>8&255,x[C++]=255&y;return E===2&&(y=a[v.charCodeAt(w)]<<2|a[v.charCodeAt(w+1)]>>4,x[C++]=255&y),E===1&&(y=a[v.charCodeAt(w)]<<10|a[v.charCodeAt(w+1)]<<4|a[v.charCodeAt(w+2)]>>2,x[C++]=y>>8&255,x[C++]=255&y),x},n.fromByteArray=function(v){for(var y,w=v.length,p=w%3,_=[],E=0,x=w-p;E<x;E+=16383)_.push(g(v,E,E+16383>x?x:E+16383));return p===1?(y=v[w-1],_.push(r[y>>2]+r[y<<4&63]+"==")):p===2&&(y=(v[w-2]<<8)+v[w-1],_.push(r[y>>10]+r[y>>4&63]+r[y<<2&63]+"=")),_.join("")};for(var r=[],a=[],o=typeof Uint8Array<"u"?Uint8Array:Array,l="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",u=0,h=l.length;u<h;++u)r[u]=l[u],a[l.charCodeAt(u)]=u;function f(v){var y=v.length;if(y%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var w=v.indexOf("=");return w===-1&&(w=y),[w,w===y?0:4-w%4]}function g(v,y,w){for(var p,_,E=[],x=y;x<w;x+=3)p=(v[x]<<16&16711680)+(v[x+1]<<8&65280)+(255&v[x+2]),E.push(r[(_=p)>>18&63]+r[_>>12&63]+r[_>>6&63]+r[63&_]);return E.join("")}a["-".charCodeAt(0)]=62,a["_".charCodeAt(0)]=63},{}],14:[function(i,s,n){const{Buffer:r}=i("buffer"),a=Symbol.for("BufferList");function o(l){if(!(this instanceof o))return new o(l);o._init.call(this,l)}o._init=function(l){Object.defineProperty(this,a,{value:!0}),this._bufs=[],this.length=0,l&&this.append(l)},o.prototype._new=function(l){return new o(l)},o.prototype._offset=function(l){if(l===0)return[0,0];let u=0;for(let h=0;h<this._bufs.length;h++){const f=u+this._bufs[h].length;if(l<f||h===this._bufs.length-1)return[h,l-u];u=f}},o.prototype._reverseOffset=function(l){const u=l[0];let h=l[1];for(let f=0;f<u;f++)h+=this._bufs[f].length;return h},o.prototype.get=function(l){if(l>this.length||l<0)return;const u=this._offset(l);return this._bufs[u[0]][u[1]]},o.prototype.slice=function(l,u){return typeof l=="number"&&l<0&&(l+=this.length),typeof u=="number"&&u<0&&(u+=this.length),this.copy(null,0,l,u)},o.prototype.copy=function(l,u,h,f){if((typeof h!="number"||h<0)&&(h=0),(typeof f!="number"||f>this.length)&&(f=this.length),h>=this.length||f<=0)return l||r.alloc(0);const g=!!l,v=this._offset(h),y=f-h;let w=y,p=g&&u||0,_=v[1];if(h===0&&f===this.length){if(!g)return this._bufs.length===1?this._bufs[0]:r.concat(this._bufs,this.length);for(let E=0;E<this._bufs.length;E++)this._bufs[E].copy(l,p),p+=this._bufs[E].length;return l}if(w<=this._bufs[v[0]].length-_)return g?this._bufs[v[0]].copy(l,u,_,_+w):this._bufs[v[0]].slice(_,_+w);g||(l=r.allocUnsafe(y));for(let E=v[0];E<this._bufs.length;E++){const x=this._bufs[E].length-_;if(!(w>x)){this._bufs[E].copy(l,p,_,_+w),p+=x;break}this._bufs[E].copy(l,p,_),p+=x,w-=x,_&&(_=0)}return l.length>p?l.slice(0,p):l},o.prototype.shallowSlice=function(l,u){if(l=l||0,u=typeof u!="number"?this.length:u,l<0&&(l+=this.length),u<0&&(u+=this.length),l===u)return this._new();const h=this._offset(l),f=this._offset(u),g=this._bufs.slice(h[0],f[0]+1);return f[1]===0?g.pop():g[g.length-1]=g[g.length-1].slice(0,f[1]),h[1]!==0&&(g[0]=g[0].slice(h[1])),this._new(g)},o.prototype.toString=function(l,u,h){return this.slice(u,h).toString(l)},o.prototype.consume=function(l){if(l=Math.trunc(l),Number.isNaN(l)||l<=0)return this;for(;this._bufs.length;){if(!(l>=this._bufs[0].length)){this._bufs[0]=this._bufs[0].slice(l),this.length-=l;break}l-=this._bufs[0].length,this.length-=this._bufs[0].length,this._bufs.shift()}return this},o.prototype.duplicate=function(){const l=this._new();for(let u=0;u<this._bufs.length;u++)l.append(this._bufs[u]);return l},o.prototype.append=function(l){if(l==null)return this;if(l.buffer)this._appendBuffer(r.from(l.buffer,l.byteOffset,l.byteLength));else if(Array.isArray(l))for(let u=0;u<l.length;u++)this.append(l[u]);else if(this._isBufferList(l))for(let u=0;u<l._bufs.length;u++)this.append(l._bufs[u]);else typeof l=="number"&&(l=l.toString()),this._appendBuffer(r.from(l));return this},o.prototype._appendBuffer=function(l){this._bufs.push(l),this.length+=l.length},o.prototype.indexOf=function(l,u,h){if(h===void 0&&typeof u=="string"&&(h=u,u=void 0),typeof l=="function"||Array.isArray(l))throw new TypeError('The "value" argument must be one of type string, Buffer, BufferList, or Uint8Array.');if(typeof l=="number"?l=r.from([l]):typeof l=="string"?l=r.from(l,h):this._isBufferList(l)?l=l.slice():Array.isArray(l.buffer)?l=r.from(l.buffer,l.byteOffset,l.byteLength):r.isBuffer(l)||(l=r.from(l)),u=Number(u||0),isNaN(u)&&(u=0),u<0&&(u=this.length+u),u<0&&(u=0),l.length===0)return u>this.length?this.length:u;const f=this._offset(u);let g=f[0],v=f[1];for(;g<this._bufs.length;g++){const y=this._bufs[g];for(;v<y.length;)if(y.length-v>=l.length){const w=y.indexOf(l,v);if(w!==-1)return this._reverseOffset([g,w]);v=y.length-l.length+1}else{const w=this._reverseOffset([g,v]);if(this._match(w,l))return w;v++}v=0}return-1},o.prototype._match=function(l,u){if(this.length-l<u.length)return!1;for(let h=0;h<u.length;h++)if(this.get(l+h)!==u[h])return!1;return!0},function(){const l={readDoubleBE:8,readDoubleLE:8,readFloatBE:4,readFloatLE:4,readInt32BE:4,readInt32LE:4,readUInt32BE:4,readUInt32LE:4,readInt16BE:2,readInt16LE:2,readUInt16BE:2,readUInt16LE:2,readInt8:1,readUInt8:1,readIntBE:null,readIntLE:null,readUIntBE:null,readUIntLE:null};for(const u in l)(function(h){o.prototype[h]=l[h]===null?function(f,g){return this.slice(f,f+g)[h](0,g)}:function(f=0){return this.slice(f,f+l[h])[h](0)}})(u)}(),o.prototype._isBufferList=function(l){return l instanceof o||o.isBufferList(l)},o.isBufferList=function(l){return l!=null&&l[a]},s.exports=o},{buffer:17}],15:[function(i,s,n){const r=i("readable-stream").Duplex,a=i("inherits"),o=i("./BufferList");function l(u){if(!(this instanceof l))return new l(u);if(typeof u=="function"){this._callback=u;const h=function(f){this._callback&&(this._callback(f),this._callback=null)}.bind(this);this.on("pipe",function(f){f.on("error",h)}),this.on("unpipe",function(f){f.removeListener("error",h)}),u=null}o._init.call(this,u),r.call(this)}a(l,r),Object.assign(l.prototype,o.prototype),l.prototype._new=function(u){return new l(u)},l.prototype._write=function(u,h,f){this._appendBuffer(u),typeof f=="function"&&f()},l.prototype._read=function(u){if(!this.length)return this.push(null);u=Math.min(u,this.length),this.push(this.slice(0,u)),this.consume(u)},l.prototype.end=function(u){r.prototype.end.call(this,u),this._callback&&(this._callback(null,this.slice()),this._callback=null)},l.prototype._destroy=function(u,h){this._bufs.length=0,this.length=0,h(u)},l.prototype._isBufferList=function(u){return u instanceof l||u instanceof o||l.isBufferList(u)},l.isBufferList=o.isBufferList,s.exports=l,s.exports.BufferListStream=l,s.exports.BufferList=o},{"./BufferList":14,inherits:24,"readable-stream":69}],16:[function(i,s,n){},{}],17:[function(i,s,n){(function(r){(function(){var a=i("base64-js"),o=i("ieee754");n.Buffer=h,n.SlowBuffer=function(b){return+b!=b&&(b=0),h.alloc(+b)},n.INSPECT_MAX_BYTES=50;var l=2147483647;function u(b){if(b>l)throw new RangeError('The value "'+b+'" is invalid for option "size"');var k=new Uint8Array(b);return k.__proto__=h.prototype,k}function h(b,k,I){if(typeof b=="number"){if(typeof k=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return v(b)}return f(b,k,I)}function f(b,k,I){if(typeof b=="string")return function(G,at){if(typeof at=="string"&&at!==""||(at="utf8"),!h.isEncoding(at))throw new TypeError("Unknown encoding: "+at);var mt=0|p(G,at),yt=u(mt),kt=yt.write(G,at);return kt!==mt&&(yt=yt.slice(0,kt)),yt}(b,k);if(ArrayBuffer.isView(b))return y(b);if(b==null)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof b);if(ct(b,ArrayBuffer)||b&&ct(b.buffer,ArrayBuffer))return function(G,at,mt){if(at<0||G.byteLength<at)throw new RangeError('"offset" is outside of buffer bounds');if(G.byteLength<at+(mt||0))throw new RangeError('"length" is outside of buffer bounds');var yt;return yt=at===void 0&&mt===void 0?new Uint8Array(G):mt===void 0?new Uint8Array(G,at):new Uint8Array(G,at,mt),yt.__proto__=h.prototype,yt}(b,k,I);if(typeof b=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');var F=b.valueOf&&b.valueOf();if(F!=null&&F!==b)return h.from(F,k,I);var X=function(G){if(h.isBuffer(G)){var at=0|w(G.length),mt=u(at);return mt.length===0||G.copy(mt,0,0,at),mt}if(G.length!==void 0)return typeof G.length!="number"||ot(G.length)?u(0):y(G);if(G.type==="Buffer"&&Array.isArray(G.data))return y(G.data)}(b);if(X)return X;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof b[Symbol.toPrimitive]=="function")return h.from(b[Symbol.toPrimitive]("string"),k,I);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof b)}function g(b){if(typeof b!="number")throw new TypeError('"size" argument must be of type number');if(b<0)throw new RangeError('The value "'+b+'" is invalid for option "size"')}function v(b){return g(b),u(b<0?0:0|w(b))}function y(b){for(var k=b.length<0?0:0|w(b.length),I=u(k),F=0;F<k;F+=1)I[F]=255&b[F];return I}function w(b){if(b>=l)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+l.toString(16)+" bytes");return 0|b}function p(b,k){if(h.isBuffer(b))return b.length;if(ArrayBuffer.isView(b)||ct(b,ArrayBuffer))return b.byteLength;if(typeof b!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof b);var I=b.length,F=arguments.length>2&&arguments[2]===!0;if(!F&&I===0)return 0;for(var X=!1;;)switch(k){case"ascii":case"latin1":case"binary":return I;case"utf8":case"utf-8":return st(b).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*I;case"hex":return I>>>1;case"base64":return et(b).length;default:if(X)return F?-1:st(b).length;k=(""+k).toLowerCase(),X=!0}}function _(b,k,I){var F=b[k];b[k]=b[I],b[I]=F}function E(b,k,I,F,X){if(b.length===0)return-1;if(typeof I=="string"?(F=I,I=0):I>2147483647?I=2147483647:I<-2147483648&&(I=-2147483648),ot(I=+I)&&(I=X?0:b.length-1),I<0&&(I=b.length+I),I>=b.length){if(X)return-1;I=b.length-1}else if(I<0){if(!X)return-1;I=0}if(typeof k=="string"&&(k=h.from(k,F)),h.isBuffer(k))return k.length===0?-1:x(b,k,I,F,X);if(typeof k=="number")return k&=255,typeof Uint8Array.prototype.indexOf=="function"?X?Uint8Array.prototype.indexOf.call(b,k,I):Uint8Array.prototype.lastIndexOf.call(b,k,I):x(b,[k],I,F,X);throw new TypeError("val must be string, number or Buffer")}function x(b,k,I,F,X){var G,at=1,mt=b.length,yt=k.length;if(F!==void 0&&((F=String(F).toLowerCase())==="ucs2"||F==="ucs-2"||F==="utf16le"||F==="utf-16le")){if(b.length<2||k.length<2)return-1;at=2,mt/=2,yt/=2,I/=2}function kt(xe,$t){return at===1?xe[$t]:xe.readUInt16BE($t*at)}if(X){var Rt=-1;for(G=I;G<mt;G++)if(kt(b,G)===kt(k,Rt===-1?0:G-Rt)){if(Rt===-1&&(Rt=G),G-Rt+1===yt)return Rt*at}else Rt!==-1&&(G-=G-Rt),Rt=-1}else for(I+yt>mt&&(I=mt-yt),G=I;G>=0;G--){for(var be=!0,se=0;se<yt;se++)if(kt(b,G+se)!==kt(k,se)){be=!1;break}if(be)return G}return-1}function C(b,k,I,F){I=Number(I)||0;var X=b.length-I;F?(F=Number(F))>X&&(F=X):F=X;var G=k.length;F>G/2&&(F=G/2);for(var at=0;at<F;++at){var mt=parseInt(k.substr(2*at,2),16);if(ot(mt))return at;b[I+at]=mt}return at}function S(b,k,I,F){return ut(st(k,b.length-I),b,I,F)}function D(b,k,I,F){return ut(function(X){for(var G=[],at=0;at<X.length;++at)G.push(255&X.charCodeAt(at));return G}(k),b,I,F)}function B(b,k,I,F){return D(b,k,I,F)}function L(b,k,I,F){return ut(et(k),b,I,F)}function V(b,k,I,F){return ut(function(X,G){for(var at,mt,yt,kt=[],Rt=0;Rt<X.length&&!((G-=2)<0);++Rt)at=X.charCodeAt(Rt),mt=at>>8,yt=at%256,kt.push(yt),kt.push(mt);return kt}(k,b.length-I),b,I,F)}function tt(b,k,I){return k===0&&I===b.length?a.fromByteArray(b):a.fromByteArray(b.slice(k,I))}function T(b,k,I){I=Math.min(b.length,I);for(var F=[],X=k;X<I;){var G,at,mt,yt,kt=b[X],Rt=null,be=kt>239?4:kt>223?3:kt>191?2:1;if(X+be<=I)switch(be){case 1:kt<128&&(Rt=kt);break;case 2:(192&(G=b[X+1]))==128&&(yt=(31&kt)<<6|63&G)>127&&(Rt=yt);break;case 3:G=b[X+1],at=b[X+2],(192&G)==128&&(192&at)==128&&(yt=(15&kt)<<12|(63&G)<<6|63&at)>2047&&(yt<55296||yt>57343)&&(Rt=yt);break;case 4:G=b[X+1],at=b[X+2],mt=b[X+3],(192&G)==128&&(192&at)==128&&(192&mt)==128&&(yt=(15&kt)<<18|(63&G)<<12|(63&at)<<6|63&mt)>65535&&yt<1114112&&(Rt=yt)}Rt===null?(Rt=65533,be=1):Rt>65535&&(Rt-=65536,F.push(Rt>>>10&1023|55296),Rt=56320|1023&Rt),F.push(Rt),X+=be}return function(se){var xe=se.length;if(xe<=R)return String.fromCharCode.apply(String,se);for(var $t="",Qt=0;Qt<xe;)$t+=String.fromCharCode.apply(String,se.slice(Qt,Qt+=R));return $t}(F)}n.kMaxLength=l,h.TYPED_ARRAY_SUPPORT=function(){try{var b=new Uint8Array(1);return b.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},b.foo()===42}catch{return!1}}(),h.TYPED_ARRAY_SUPPORT||typeof console>"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(h.prototype,"parent",{enumerable:!0,get:function(){if(h.isBuffer(this))return this.buffer}}),Object.defineProperty(h.prototype,"offset",{enumerable:!0,get:function(){if(h.isBuffer(this))return this.byteOffset}}),typeof Symbol<"u"&&Symbol.species!=null&&h[Symbol.species]===h&&Object.defineProperty(h,Symbol.species,{value:null,configurable:!0,enumerable:!1,writable:!1}),h.poolSize=8192,h.from=function(b,k,I){return f(b,k,I)},h.prototype.__proto__=Uint8Array.prototype,h.__proto__=Uint8Array,h.alloc=function(b,k,I){return function(F,X,G){return g(F),F<=0?u(F):X!==void 0?typeof G=="string"?u(F).fill(X,G):u(F).fill(X):u(F)}(b,k,I)},h.allocUnsafe=function(b){return v(b)},h.allocUnsafeSlow=function(b){return v(b)},h.isBuffer=function(b){return b!=null&&b._isBuffer===!0&&b!==h.prototype},h.compare=function(b,k){if(ct(b,Uint8Array)&&(b=h.from(b,b.offset,b.byteLength)),ct(k,Uint8Array)&&(k=h.from(k,k.offset,k.byteLength)),!h.isBuffer(b)||!h.isBuffer(k))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(b===k)return 0;for(var I=b.length,F=k.length,X=0,G=Math.min(I,F);X<G;++X)if(b[X]!==k[X]){I=b[X],F=k[X];break}return I<F?-1:F<I?1:0},h.isEncoding=function(b){switch(String(b).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},h.concat=function(b,k){if(!Array.isArray(b))throw new TypeError('"list" argument must be an Array of Buffers');if(b.length===0)return h.alloc(0);var I;if(k===void 0)for(k=0,I=0;I<b.length;++I)k+=b[I].length;var F=h.allocUnsafe(k),X=0;for(I=0;I<b.length;++I){var G=b[I];if(ct(G,Uint8Array)&&(G=h.from(G)),!h.isBuffer(G))throw new TypeError('"list" argument must be an Array of Buffers');G.copy(F,X),X+=G.length}return F},h.byteLength=p,h.prototype._isBuffer=!0,h.prototype.swap16=function(){var b=this.length;if(b%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var k=0;k<b;k+=2)_(this,k,k+1);return this},h.prototype.swap32=function(){var b=this.length;if(b%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var k=0;k<b;k+=4)_(this,k,k+3),_(this,k+1,k+2);return this},h.prototype.swap64=function(){var b=this.length;if(b%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var k=0;k<b;k+=8)_(this,k,k+7),_(this,k+1,k+6),_(this,k+2,k+5),_(this,k+3,k+4);return this},h.prototype.toString=function(){var b=this.length;return b===0?"":arguments.length===0?T(this,0,b):function(k,I,F){var X=!1;if((I===void 0||I<0)&&(I=0),I>this.length||((F===void 0||F>this.length)&&(F=this.length),F<=0)||(F>>>=0)<=(I>>>=0))return"";for(k||(k="utf8");;)switch(k){case"hex":return Y(this,I,F);case"utf8":case"utf-8":return T(this,I,F);case"ascii":return P(this,I,F);case"latin1":case"binary":return O(this,I,F);case"base64":return tt(this,I,F);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Z(this,I,F);default:if(X)throw new TypeError("Unknown encoding: "+k);k=(k+"").toLowerCase(),X=!0}}.apply(this,arguments)},h.prototype.toLocaleString=h.prototype.toString,h.prototype.equals=function(b){if(!h.isBuffer(b))throw new TypeError("Argument must be a Buffer");return this===b||h.compare(this,b)===0},h.prototype.inspect=function(){var b="",k=n.INSPECT_MAX_BYTES;return b=this.toString("hex",0,k).replace(/(.{2})/g,"$1 ").trim(),this.length>k&&(b+=" ... "),"<Buffer "+b+">"},h.prototype.compare=function(b,k,I,F,X){if(ct(b,Uint8Array)&&(b=h.from(b,b.offset,b.byteLength)),!h.isBuffer(b))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof b);if(k===void 0&&(k=0),I===void 0&&(I=b?b.length:0),F===void 0&&(F=0),X===void 0&&(X=this.length),k<0||I>b.length||F<0||X>this.length)throw new RangeError("out of range index");if(F>=X&&k>=I)return 0;if(F>=X)return-1;if(k>=I)return 1;if(k>>>=0,I>>>=0,F>>>=0,X>>>=0,this===b)return 0;for(var G=X-F,at=I-k,mt=Math.min(G,at),yt=this.slice(F,X),kt=b.slice(k,I),Rt=0;Rt<mt;++Rt)if(yt[Rt]!==kt[Rt]){G=yt[Rt],at=kt[Rt];break}return G<at?-1:at<G?1:0},h.prototype.includes=function(b,k,I){return this.indexOf(b,k,I)!==-1},h.prototype.indexOf=function(b,k,I){return E(this,b,k,I,!0)},h.prototype.lastIndexOf=function(b,k,I){return E(this,b,k,I,!1)},h.prototype.write=function(b,k,I,F){if(k===void 0)F="utf8",I=this.length,k=0;else if(I===void 0&&typeof k=="string")F=k,I=this.length,k=0;else{if(!isFinite(k))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");k>>>=0,isFinite(I)?(I>>>=0,F===void 0&&(F="utf8")):(F=I,I=void 0)}var X=this.length-k;if((I===void 0||I>X)&&(I=X),b.length>0&&(I<0||k<0)||k>this.length)throw new RangeError("Attempt to write outside buffer bounds");F||(F="utf8");for(var G=!1;;)switch(F){case"hex":return C(this,b,k,I);case"utf8":case"utf-8":return S(this,b,k,I);case"ascii":return D(this,b,k,I);case"latin1":case"binary":return B(this,b,k,I);case"base64":return L(this,b,k,I);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return V(this,b,k,I);default:if(G)throw new TypeError("Unknown encoding: "+F);F=(""+F).toLowerCase(),G=!0}},h.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var R=4096;function P(b,k,I){var F="";I=Math.min(b.length,I);for(var X=k;X<I;++X)F+=String.fromCharCode(127&b[X]);return F}function O(b,k,I){var F="";I=Math.min(b.length,I);for(var X=k;X<I;++X)F+=String.fromCharCode(b[X]);return F}function Y(b,k,I){var F=b.length;(!k||k<0)&&(k=0),(!I||I<0||I>F)&&(I=F);for(var X="",G=k;G<I;++G)X+=Q(b[G]);return X}function Z(b,k,I){for(var F=b.slice(k,I),X="",G=0;G<F.length;G+=2)X+=String.fromCharCode(F[G]+256*F[G+1]);return X}function rt(b,k,I){if(b%1!=0||b<0)throw new RangeError("offset is not uint");if(b+k>I)throw new RangeError("Trying to access beyond buffer length")}function $(b,k,I,F,X,G){if(!h.isBuffer(b))throw new TypeError('"buffer" argument must be a Buffer instance');if(k>X||k<G)throw new RangeError('"value" argument is out of bounds');if(I+F>b.length)throw new RangeError("Index out of range")}function H(b,k,I,F,X,G){if(I+F>b.length)throw new RangeError("Index out of range");if(I<0)throw new RangeError("Index out of range")}function j(b,k,I,F,X){return k=+k,I>>>=0,X||H(b,0,I,4),o.write(b,k,I,F,23,4),I+4}function K(b,k,I,F,X){return k=+k,I>>>=0,X||H(b,0,I,8),o.write(b,k,I,F,52,8),I+8}h.prototype.slice=function(b,k){var I=this.length;b=~~b,k=k===void 0?I:~~k,b<0?(b+=I)<0&&(b=0):b>I&&(b=I),k<0?(k+=I)<0&&(k=0):k>I&&(k=I),k<b&&(k=b);var F=this.subarray(b,k);return F.__proto__=h.prototype,F},h.prototype.readUIntLE=function(b,k,I){b>>>=0,k>>>=0,I||rt(b,k,this.length);for(var F=this[b],X=1,G=0;++G<k&&(X*=256);)F+=this[b+G]*X;return F},h.prototype.readUIntBE=function(b,k,I){b>>>=0,k>>>=0,I||rt(b,k,this.length);for(var F=this[b+--k],X=1;k>0&&(X*=256);)F+=this[b+--k]*X;return F},h.prototype.readUInt8=function(b,k){return b>>>=0,k||rt(b,1,this.length),this[b]},h.prototype.readUInt16LE=function(b,k){return b>>>=0,k||rt(b,2,this.length),this[b]|this[b+1]<<8},h.prototype.readUInt16BE=function(b,k){return b>>>=0,k||rt(b,2,this.length),this[b]<<8|this[b+1]},h.prototype.readUInt32LE=function(b,k){return b>>>=0,k||rt(b,4,this.length),(this[b]|this[b+1]<<8|this[b+2]<<16)+16777216*this[b+3]},h.prototype.readUInt32BE=function(b,k){return b>>>=0,k||rt(b,4,this.length),16777216*this[b]+(this[b+1]<<16|this[b+2]<<8|this[b+3])},h.prototype.readIntLE=function(b,k,I){b>>>=0,k>>>=0,I||rt(b,k,this.length);for(var F=this[b],X=1,G=0;++G<k&&(X*=256);)F+=this[b+G]*X;return F>=(X*=128)&&(F-=Math.pow(2,8*k)),F},h.prototype.readIntBE=function(b,k,I){b>>>=0,k>>>=0,I||rt(b,k,this.length);for(var F=k,X=1,G=this[b+--F];F>0&&(X*=256);)G+=this[b+--F]*X;return G>=(X*=128)&&(G-=Math.pow(2,8*k)),G},h.prototype.readInt8=function(b,k){return b>>>=0,k||rt(b,1,this.length),128&this[b]?-1*(255-this[b]+1):this[b]},h.prototype.readInt16LE=function(b,k){b>>>=0,k||rt(b,2,this.length);var I=this[b]|this[b+1]<<8;return 32768&I?4294901760|I:I},h.prototype.readInt16BE=function(b,k){b>>>=0,k||rt(b,2,this.length);var I=this[b+1]|this[b]<<8;return 32768&I?4294901760|I:I},h.prototype.readInt32LE=function(b,k){return b>>>=0,k||rt(b,4,this.length),this[b]|this[b+1]<<8|this[b+2]<<16|this[b+3]<<24},h.prototype.readInt32BE=function(b,k){return b>>>=0,k||rt(b,4,this.length),this[b]<<24|this[b+1]<<16|this[b+2]<<8|this[b+3]},h.prototype.readFloatLE=function(b,k){return b>>>=0,k||rt(b,4,this.length),o.read(this,b,!0,23,4)},h.prototype.readFloatBE=function(b,k){return b>>>=0,k||rt(b,4,this.length),o.read(this,b,!1,23,4)},h.prototype.readDoubleLE=function(b,k){return b>>>=0,k||rt(b,8,this.length),o.read(this,b,!0,52,8)},h.prototype.readDoubleBE=function(b,k){return b>>>=0,k||rt(b,8,this.length),o.read(this,b,!1,52,8)},h.prototype.writeUIntLE=function(b,k,I,F){b=+b,k>>>=0,I>>>=0,F||$(this,b,k,I,Math.pow(2,8*I)-1,0);var X=1,G=0;for(this[k]=255&b;++G<I&&(X*=256);)this[k+G]=b/X&255;return k+I},h.prototype.writeUIntBE=function(b,k,I,F){b=+b,k>>>=0,I>>>=0,F||$(this,b,k,I,Math.pow(2,8*I)-1,0);var X=I-1,G=1;for(this[k+X]=255&b;--X>=0&&(G*=256);)this[k+X]=b/G&255;return k+I},h.prototype.writeUInt8=function(b,k,I){return b=+b,k>>>=0,I||$(this,b,k,1,255,0),this[k]=255&b,k+1},h.prototype.writeUInt16LE=function(b,k,I){return b=+b,k>>>=0,I||$(this,b,k,2,65535,0),this[k]=255&b,this[k+1]=b>>>8,k+2},h.prototype.writeUInt16BE=function(b,k,I){return b=+b,k>>>=0,I||$(this,b,k,2,65535,0),this[k]=b>>>8,this[k+1]=255&b,k+2},h.prototype.writeUInt32LE=function(b,k,I){return b=+b,k>>>=0,I||$(this,b,k,4,4294967295,0),this[k+3]=b>>>24,this[k+2]=b>>>16,this[k+1]=b>>>8,this[k]=255&b,k+4},h.prototype.writeUInt32BE=function(b,k,I){return b=+b,k>>>=0,I||$(this,b,k,4,4294967295,0),this[k]=b>>>24,this[k+1]=b>>>16,this[k+2]=b>>>8,this[k+3]=255&b,k+4},h.prototype.writeIntLE=function(b,k,I,F){if(b=+b,k>>>=0,!F){var X=Math.pow(2,8*I-1);$(this,b,k,I,X-1,-X)}var G=0,at=1,mt=0;for(this[k]=255&b;++G<I&&(at*=256);)b<0&&mt===0&&this[k+G-1]!==0&&(mt=1),this[k+G]=(b/at>>0)-mt&255;return k+I},h.prototype.writeIntBE=function(b,k,I,F){if(b=+b,k>>>=0,!F){var X=Math.pow(2,8*I-1);$(this,b,k,I,X-1,-X)}var G=I-1,at=1,mt=0;for(this[k+G]=255&b;--G>=0&&(at*=256);)b<0&&mt===0&&this[k+G+1]!==0&&(mt=1),this[k+G]=(b/at>>0)-mt&255;return k+I},h.prototype.writeInt8=function(b,k,I){return b=+b,k>>>=0,I||$(this,b,k,1,127,-128),b<0&&(b=255+b+1),this[k]=255&b,k+1},h.prototype.writeInt16LE=function(b,k,I){return b=+b,k>>>=0,I||$(this,b,k,2,32767,-32768),this[k]=255&b,this[k+1]=b>>>8,k+2},h.prototype.writeInt16BE=function(b,k,I){return b=+b,k>>>=0,I||$(this,b,k,2,32767,-32768),this[k]=b>>>8,this[k+1]=255&b,k+2},h.prototype.writeInt32LE=function(b,k,I){return b=+b,k>>>=0,I||$(this,b,k,4,2147483647,-2147483648),this[k]=255&b,this[k+1]=b>>>8,this[k+2]=b>>>16,this[k+3]=b>>>24,k+4},h.prototype.writeInt32BE=function(b,k,I){return b=+b,k>>>=0,I||$(this,b,k,4,2147483647,-2147483648),b<0&&(b=4294967295+b+1),this[k]=b>>>24,this[k+1]=b>>>16,this[k+2]=b>>>8,this[k+3]=255&b,k+4},h.prototype.writeFloatLE=function(b,k,I){return j(this,b,k,!0,I)},h.prototype.writeFloatBE=function(b,k,I){return j(this,b,k,!1,I)},h.prototype.writeDoubleLE=function(b,k,I){return K(this,b,k,!0,I)},h.prototype.writeDoubleBE=function(b,k,I){return K(this,b,k,!1,I)},h.prototype.copy=function(b,k,I,F){if(!h.isBuffer(b))throw new TypeError("argument should be a Buffer");if(I||(I=0),F||F===0||(F=this.length),k>=b.length&&(k=b.length),k||(k=0),F>0&&F<I&&(F=I),F===I||b.length===0||this.length===0)return 0;if(k<0)throw new RangeError("targetStart out of bounds");if(I<0||I>=this.length)throw new RangeError("Index out of range");if(F<0)throw new RangeError("sourceEnd out of bounds");F>this.length&&(F=this.length),b.length-k<F-I&&(F=b.length-k+I);var X=F-I;if(this===b&&typeof Uint8Array.prototype.copyWithin=="function")this.copyWithin(k,I,F);else if(this===b&&I<k&&k<F)for(var G=X-1;G>=0;--G)b[G+k]=this[G+I];else Uint8Array.prototype.set.call(b,this.subarray(I,F),k);return X},h.prototype.fill=function(b,k,I,F){if(typeof b=="string"){if(typeof k=="string"?(F=k,k=0,I=this.length):typeof I=="string"&&(F=I,I=this.length),F!==void 0&&typeof F!="string")throw new TypeError("encoding must be a string");if(typeof F=="string"&&!h.isEncoding(F))throw new TypeError("Unknown encoding: "+F);if(b.length===1){var X=b.charCodeAt(0);(F==="utf8"&&X<128||F==="latin1")&&(b=X)}}else typeof b=="number"&&(b&=255);if(k<0||this.length<k||this.length<I)throw new RangeError("Out of range index");if(I<=k)return this;var G;if(k>>>=0,I=I===void 0?this.length:I>>>0,b||(b=0),typeof b=="number")for(G=k;G<I;++G)this[G]=b;else{var at=h.isBuffer(b)?b:h.from(b,F),mt=at.length;if(mt===0)throw new TypeError('The value "'+b+'" is invalid for argument "value"');for(G=0;G<I-k;++G)this[G+k]=at[G%mt]}return this};var W=/[^+/0-9A-Za-z-_]/g;function Q(b){return b<16?"0"+b.toString(16):b.toString(16)}function st(b,k){var I;k=k||1/0;for(var F=b.length,X=null,G=[],at=0;at<F;++at){if((I=b.charCodeAt(at))>55295&&I<57344){if(!X){if(I>56319){(k-=3)>-1&&G.push(239,191,189);continue}if(at+1===F){(k-=3)>-1&&G.push(239,191,189);continue}X=I;continue}if(I<56320){(k-=3)>-1&&G.push(239,191,189),X=I;continue}I=65536+(X-55296<<10|I-56320)}else X&&(k-=3)>-1&&G.push(239,191,189);if(X=null,I<128){if((k-=1)<0)break;G.push(I)}else if(I<2048){if((k-=2)<0)break;G.push(I>>6|192,63&I|128)}else if(I<65536){if((k-=3)<0)break;G.push(I>>12|224,I>>6&63|128,63&I|128)}else{if(!(I<1114112))throw new Error("Invalid code point");if((k-=4)<0)break;G.push(I>>18|240,I>>12&63|128,I>>6&63|128,63&I|128)}}return G}function et(b){return a.toByteArray(function(k){if((k=(k=k.split("=")[0]).trim().replace(W,"")).length<2)return"";for(;k.length%4!=0;)k+="=";return k}(b))}function ut(b,k,I,F){for(var X=0;X<F&&!(X+I>=k.length||X>=b.length);++X)k[X+I]=b[X];return X}function ct(b,k){return b instanceof k||b!=null&&b.constructor!=null&&b.constructor.name!=null&&b.constructor.name===k.name}function ot(b){return b!=b}}).call(this)}).call(this,i("buffer").Buffer)},{"base64-js":13,buffer:17,ieee754:23}],18:[function(i,s,n){(function(r){(function(){n.formatArgs=function(o){if(o[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+o[0]+(this.useColors?"%c ":" ")+"+"+s.exports.humanize(this.diff),!this.useColors)return;const l="color: "+this.color;o.splice(1,0,l,"color: inherit");let u=0,h=0;o[0].replace(/%[a-zA-Z%]/g,f=>{f!=="%%"&&f==="%c"&&(h=++u)}),o.splice(h,0,l)},n.save=function(o){try{o?n.storage.setItem("debug",o):n.storage.removeItem("debug")}catch{}},n.load=function(){let o;try{o=n.storage.getItem("debug")}catch{}return!o&&r!==void 0&&"env"in r&&(o=r.env.DEBUG),o},n.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+)/)},n.storage=function(){try{return localStorage}catch{}}(),n.destroy=(()=>{let o=!1;return()=>{o||(o=!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`."))}})(),n.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"],n.log=console.debug||console.log||(()=>{}),s.exports=i("./common")(n);const{formatters:a}=s.exports;a.j=function(o){try{return JSON.stringify(o)}catch(l){return"[UnexpectedJSONParseError]: "+l.message}}}).call(this)}).call(this,i("_process"))},{"./common":19,_process:50}],19:[function(i,s,n){s.exports=function(r){function a(u){let h,f,g,v=null;function y(...w){if(!y.enabled)return;const p=y,_=Number(new Date),E=_-(h||_);p.diff=E,p.prev=h,p.curr=_,h=_,w[0]=a.coerce(w[0]),typeof w[0]!="string"&&w.unshift("%O");let x=0;w[0]=w[0].replace(/%([a-zA-Z%])/g,(C,S)=>{if(C==="%%")return"%";x++;const D=a.formatters[S];if(typeof D=="function"){const B=w[x];C=D.call(p,B),w.splice(x,1),x--}return C}),a.formatArgs.call(p,w),(p.log||a.log).apply(p,w)}return y.namespace=u,y.useColors=a.useColors(),y.color=a.selectColor(u),y.extend=o,y.destroy=a.destroy,Object.defineProperty(y,"enabled",{enumerable:!0,configurable:!1,get:()=>v!==null?v:(f!==a.namespaces&&(f=a.namespaces,g=a.enabled(u)),g),set:w=>{v=w}}),typeof a.init=="function"&&a.init(y),y}function o(u,h){const f=a(this.namespace+(h===void 0?":":h)+u);return f.log=this.log,f}function l(u){return u.toString().substring(2,u.toString().length-2).replace(/\.\*\?$/,"*")}return a.debug=a,a.default=a,a.coerce=function(u){return u instanceof Error?u.stack||u.message:u},a.disable=function(){const u=[...a.names.map(l),...a.skips.map(l).map(h=>"-"+h)].join(",");return a.enable(""),u},a.enable=function(u){let h;a.save(u),a.namespaces=u,a.names=[],a.skips=[];const f=(typeof u=="string"?u:"").split(/[\s,]+/),g=f.length;for(h=0;h<g;h++)f[h]&&((u=f[h].replace(/\*/g,".*?"))[0]==="-"?a.skips.push(new RegExp("^"+u.substr(1)+"$")):a.names.push(new RegExp("^"+u+"$")))},a.enabled=function(u){if(u[u.length-1]==="*")return!0;let h,f;for(h=0,f=a.skips.length;h<f;h++)if(a.skips[h].test(u))return!1;for(h=0,f=a.names.length;h<f;h++)if(a.names[h].test(u))return!0;return!1},a.humanize=i("ms"),a.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")},Object.keys(r).forEach(u=>{a[u]=r[u]}),a.names=[],a.skips=[],a.formatters={},a.selectColor=function(u){let h=0;for(let f=0;f<u.length;f++)h=(h<<5)-h+u.charCodeAt(f),h|=0;return a.colors[Math.abs(h)%a.colors.length]},a.enable(a.load()),a}},{ms:45}],20:[function(i,s,n){(function(r,a){(function(){var o=i("readable-stream"),l=i("end-of-stream"),u=i("inherits"),h=i("stream-shift"),f=a.from&&a.from!==Uint8Array.from?a.from([0]):new a([0]),g=function(p,_){p._corked?p.once("uncork",_):_()},v=function(p,_){return function(E){E?function(x,C){x._autoDestroy&&x.destroy(C)}(p,E.message==="premature close"?null:E):_&&!p._ended&&p.end()}},y=function(){},w=function(p,_,E){if(!(this instanceof w))return new w(p,_,E);o.Duplex.call(this,E),this._writable=null,this._readable=null,this._readable2=null,this._autoDestroy=!E||E.autoDestroy!==!1,this._forwardDestroy=!E||E.destroy!==!1,this._forwardEnd=!E||E.end!==!1,this._corked=1,this._ondrain=null,this._drained=!1,this._forwarding=!1,this._unwrite=null,this._unread=null,this._ended=!1,this.destroyed=!1,p&&this.setWritable(p),_&&this.setReadable(_)};u(w,o.Duplex),w.obj=function(p,_,E){return E||(E={}),E.objectMode=!0,E.highWaterMark=16,new w(p,_,E)},w.prototype.cork=function(){++this._corked==1&&this.emit("cork")},w.prototype.uncork=function(){this._corked&&--this._corked==0&&this.emit("uncork")},w.prototype.setWritable=function(p){if(this._unwrite&&this._unwrite(),this.destroyed)p&&p.destroy&&p.destroy();else if(p!==null&&p!==!1){var _=this,E=l(p,{writable:!0,readable:!1},v(this,this._forwardEnd)),x=function(){var C=_._ondrain;_._ondrain=null,C&&C()};this._unwrite&&r.nextTick(x),this._writable=p,this._writable.on("drain",x),this._unwrite=function(){_._writable.removeListener("drain",x),E()},this.uncork()}else this.end()},w.prototype.setReadable=function(p){if(this._unread&&this._unread(),this.destroyed)p&&p.destroy&&p.destroy();else{if(p===null||p===!1)return this.push(null),void this.resume();var _,E=this,x=l(p,{writable:!1,readable:!0},v(this)),C=function(){E._forward()},S=function(){E.push(null)};this._drained=!0,this._readable=p,this._readable2=p._readableState?p:(_=p,new o.Readable({objectMode:!0,highWaterMark:16}).wrap(_)),this._readable2.on("readable",C),this._readable2.on("end",S),this._unread=function(){E._readable2.removeListener("readable",C),E._readable2.removeListener("end",S),x()},this._forward()}},w.prototype._read=function(){this._drained=!0,this._forward()},w.prototype._forward=function(){if(!this._forwarding&&this._readable2&&this._drained){var p;for(this._forwarding=!0;this._drained&&(p=h(this._readable2))!==null;)this.destroyed||(this._drained=this.push(p));this._forwarding=!1}},w.prototype.destroy=function(p,_){if(_||(_=y),this.destroyed)return _(null);this.destroyed=!0;var E=this;r.nextTick(function(){E._destroy(p),_(null)})},w.prototype._destroy=function(p){if(p){var _=this._ondrain;this._ondrain=null,_?_(p):this.emit("error",p)}this._forwardDestroy&&(this._readable&&this._readable.destroy&&this._readable.destroy(),this._writable&&this._writable.destroy&&this._writable.destroy()),this.emit("close")},w.prototype._write=function(p,_,E){if(!this.destroyed)return this._corked?g(this,this._write.bind(this,p,_,E)):p===f?this._finish(E):this._writable?void(this._writable.write(p)===!1?this._ondrain=E:this.destroyed||E()):E()},w.prototype._finish=function(p){var _=this;this.emit("preend"),g(this,function(){var E,x;E=_._forwardEnd&&_._writable,x=function(){_._writableState.prefinished===!1&&(_._writableState.prefinished=!0),_.emit("prefinish"),g(_,p)},E?E._writableState&&E._writableState.finished?x():E._writableState?E.end(x):(E.end(),x()):x()})},w.prototype.end=function(p,_,E){return typeof p=="function"?this.end(null,null,p):typeof _=="function"?this.end(p,null,_):(this._ended=!0,p&&this.write(p),this._writableState.ending||this._writableState.destroyed||this.write(f),o.Writable.prototype.end.call(this,E))},s.exports=w}).call(this)}).call(this,i("_process"),i("buffer").Buffer)},{_process:50,buffer:17,"end-of-stream":21,inherits:24,"readable-stream":69,"stream-shift":74}],21:[function(i,s,n){(function(r){(function(){var a=i("once"),o=function(){},l=function(u,h,f){if(typeof h=="function")return l(u,null,h);h||(h={}),f=a(f||o);var g=u._writableState,v=u._readableState,y=h.readable||h.readable!==!1&&u.readable,w=h.writable||h.writable!==!1&&u.writable,p=!1,_=function(){u.writable||E()},E=function(){w=!1,y||f.call(u)},x=function(){y=!1,w||f.call(u)},C=function(V){f.call(u,V?new Error("exited with error code: "+V):null)},S=function(V){f.call(u,V)},D=function(){r.nextTick(B)},B=function(){if(!p)return(!y||v&&v.ended&&!v.destroyed)&&(!w||g&&g.ended&&!g.destroyed)?void 0:f.call(u,new Error("premature close"))},L=function(){u.req.on("finish",E)};return function(V){return V.setHeader&&typeof V.abort=="function"}(u)?(u.on("complete",E),u.on("abort",D),u.req?L():u.on("request",L)):w&&!g&&(u.on("end",_),u.on("close",_)),function(V){return V.stdio&&Array.isArray(V.stdio)&&V.stdio.length===3}(u)&&u.on("exit",C),u.on("end",x),u.on("finish",E),h.error!==!1&&u.on("error",S),u.on("close",D),function(){p=!0,u.removeListener("complete",E),u.removeListener("abort",D),u.removeListener("request",L),u.req&&u.req.removeListener("finish",E),u.removeListener("end",_),u.removeListener("close",_),u.removeListener("finish",E),u.removeListener("exit",C),u.removeListener("end",x),u.removeListener("error",S),u.removeListener("close",D)}};s.exports=l}).call(this)}).call(this,i("_process"))},{_process:50,once:48}],22:[function(i,s,n){var r=Object.create||function(x){var C=function(){};return C.prototype=x,new C},a=Object.keys||function(x){var C=[];for(var S in x)Object.prototype.hasOwnProperty.call(x,S)&&C.push(S);return S},o=Function.prototype.bind||function(x){var C=this;return function(){return C.apply(x,arguments)}};function l(){this._events&&Object.prototype.hasOwnProperty.call(this,"_events")||(this._events=r(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0}s.exports=l,l.EventEmitter=l,l.prototype._events=void 0,l.prototype._maxListeners=void 0;var u,h=10;try{var f={};Object.defineProperty&&Object.defineProperty(f,"x",{value:0}),u=f.x===0}catch{u=!1}function g(x){return x._maxListeners===void 0?l.defaultMaxListeners:x._maxListeners}function v(x,C,S,D){var B,L,V;if(typeof S!="function")throw new TypeError('"listener" argument must be a function');if((L=x._events)?(L.newListener&&(x.emit("newListener",C,S.listener?S.listener:S),L=x._events),V=L[C]):(L=x._events=r(null),x._eventsCount=0),V){if(typeof V=="function"?V=L[C]=D?[S,V]:[V,S]:D?V.unshift(S):V.push(S),!V.warned&&(B=g(x))&&B>0&&V.length>B){V.warned=!0;var tt=new Error("Possible EventEmitter memory leak detected. "+V.length+' "'+String(C)+'" listeners added. Use emitter.setMaxListeners() to increase limit.');tt.name="MaxListenersExceededWarning",tt.emitter=x,tt.type=C,tt.count=V.length,typeof console=="object"&&console.warn&&console.warn("%s: %s",tt.name,tt.message)}}else V=L[C]=S,++x._eventsCount;return x}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 x=new Array(arguments.length),C=0;C<x.length;++C)x[C]=arguments[C];this.listener.apply(this.target,x)}}function w(x,C,S){var D={fired:!1,wrapFn:void 0,target:x,type:C,listener:S},B=o.call(y,D);return B.listener=S,D.wrapFn=B,B}function p(x,C,S){var D=x._events;if(!D)return[];var B=D[C];return B?typeof B=="function"?S?[B.listener||B]:[B]:S?function(L){for(var V=new Array(L.length),tt=0;tt<V.length;++tt)V[tt]=L[tt].listener||L[tt];return V}(B):E(B,B.length):[]}function _(x){var C=this._events;if(C){var S=C[x];if(typeof S=="function")return 1;if(S)return S.length}return 0}function E(x,C){for(var S=new Array(C),D=0;D<C;++D)S[D]=x[D];return S}u?Object.defineProperty(l,"defaultMaxListeners",{enumerable:!0,get:function(){return h},set:function(x){if(typeof x!="number"||x<0||x!=x)throw new TypeError('"defaultMaxListeners" must be a positive number');h=x}}):l.defaultMaxListeners=h,l.prototype.setMaxListeners=function(x){if(typeof x!="number"||x<0||isNaN(x))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=x,this},l.prototype.getMaxListeners=function(){return g(this)},l.prototype.emit=function(x){var C,S,D,B,L,V,tt=x==="error";if(V=this._events)tt=tt&&V.error==null;else if(!tt)return!1;if(tt){if(arguments.length>1&&(C=arguments[1]),C instanceof Error)throw C;var T=new Error('Unhandled "error" event. ('+C+")");throw T.context=C,T}if(!(S=V[x]))return!1;var R=typeof S=="function";switch(D=arguments.length){case 1:(function(P,O,Y){if(O)P.call(Y);else for(var Z=P.length,rt=E(P,Z),$=0;$<Z;++$)rt[$].call(Y)})(S,R,this);break;case 2:(function(P,O,Y,Z){if(O)P.call(Y,Z);else for(var rt=P.length,$=E(P,rt),H=0;H<rt;++H)$[H].call(Y,Z)})(S,R,this,arguments[1]);break;case 3:(function(P,O,Y,Z,rt){if(O)P.call(Y,Z,rt);else for(var $=P.length,H=E(P,$),j=0;j<$;++j)H[j].call(Y,Z,rt)})(S,R,this,arguments[1],arguments[2]);break;case 4:(function(P,O,Y,Z,rt,$){if(O)P.call(Y,Z,rt,$);else for(var H=P.length,j=E(P,H),K=0;K<H;++K)j[K].call(Y,Z,rt,$)})(S,R,this,arguments[1],arguments[2],arguments[3]);break;default:for(B=new Array(D-1),L=1;L<D;L++)B[L-1]=arguments[L];(function(P,O,Y,Z){if(O)P.apply(Y,Z);else for(var rt=P.length,$=E(P,rt),H=0;H<rt;++H)$[H].apply(Y,Z)})(S,R,this,B)}return!0},l.prototype.addListener=function(x,C){return v(this,x,C,!1)},l.prototype.on=l.prototype.addListener,l.prototype.prependListener=function(x,C){return v(this,x,C,!0)},l.prototype.once=function(x,C){if(typeof C!="function")throw new TypeError('"listener" argument must be a function');return this.on(x,w(this,x,C)),this},l.prototype.prependOnceListener=function(x,C){if(typeof C!="function")throw new TypeError('"listener" argument must be a function');return this.prependListener(x,w(this,x,C)),this},l.prototype.removeListener=function(x,C){var S,D,B,L,V;if(typeof C!="function")throw new TypeError('"listener" argument must be a function');if(!(D=this._events))return this;if(!(S=D[x]))return this;if(S===C||S.listener===C)--this._eventsCount==0?this._events=r(null):(delete D[x],D.removeListener&&this.emit("removeListener",x,S.listener||C));else if(typeof S!="function"){for(B=-1,L=S.length-1;L>=0;L--)if(S[L]===C||S[L].listener===C){V=S[L].listener,B=L;break}if(B<0)return this;B===0?S.shift():function(tt,T){for(var R=T,P=R+1,O=tt.length;P<O;R+=1,P+=1)tt[R]=tt[P];tt.pop()}(S,B),S.length===1&&(D[x]=S[0]),D.removeListener&&this.emit("removeListener",x,V||C)}return this},l.prototype.removeAllListeners=function(x){var C,S,D;if(!(S=this._events))return this;if(!S.removeListener)return arguments.length===0?(this._events=r(null),this._eventsCount=0):S[x]&&(--this._eventsCount==0?this._events=r(null):delete S[x]),this;if(arguments.length===0){var B,L=a(S);for(D=0;D<L.length;++D)(B=L[D])!=="removeListener"&&this.removeAllListeners(B);return this.removeAllListeners("removeListener"),this._events=r(null),this._eventsCount=0,this}if(typeof(C=S[x])=="function")this.removeListener(x,C);else if(C)for(D=C.length-1;D>=0;D--)this.removeListener(x,C[D]);return this},l.prototype.listeners=function(x){return p(this,x,!0)},l.prototype.rawListeners=function(x){return p(this,x,!1)},l.listenerCount=function(x,C){return typeof x.listenerCount=="function"?x.listenerCount(C):_.call(x,C)},l.prototype.listenerCount=_,l.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]}},{}],23:[function(i,s,n){n.read=function(r,a,o,l,u){var h,f,g=8*u-l-1,v=(1<<g)-1,y=v>>1,w=-7,p=o?u-1:0,_=o?-1:1,E=r[a+p];for(p+=_,h=E&(1<<-w)-1,E>>=-w,w+=g;w>0;h=256*h+r[a+p],p+=_,w-=8);for(f=h&(1<<-w)-1,h>>=-w,w+=l;w>0;f=256*f+r[a+p],p+=_,w-=8);if(h===0)h=1-y;else{if(h===v)return f?NaN:1/0*(E?-1:1);f+=Math.pow(2,l),h-=y}return(E?-1:1)*f*Math.pow(2,h-l)},n.write=function(r,a,o,l,u,h){var f,g,v,y=8*h-u-1,w=(1<<y)-1,p=w>>1,_=u===23?Math.pow(2,-24)-Math.pow(2,-77):0,E=l?0:h-1,x=l?1:-1,C=a<0||a===0&&1/a<0?1:0;for(a=Math.abs(a),isNaN(a)||a===1/0?(g=isNaN(a)?1:0,f=w):(f=Math.floor(Math.log(a)/Math.LN2),a*(v=Math.pow(2,-f))<1&&(f--,v*=2),(a+=f+p>=1?_/v:_*Math.pow(2,1-p))*v>=2&&(f++,v/=2),f+p>=w?(g=0,f=w):f+p>=1?(g=(a*v-1)*Math.pow(2,u),f+=p):(g=a*Math.pow(2,p-1)*Math.pow(2,u),f=0));u>=8;r[o+E]=255&g,E+=x,g/=256,u-=8);for(f=f<<u|g,y+=u;y>0;r[o+E]=255&f,E+=x,f/=256,y-=8);r[o+E-x]|=128*C}},{}],24:[function(i,s,n){typeof Object.create=="function"?s.exports=function(r,a){a&&(r.super_=a,r.prototype=Object.create(a.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}))}:s.exports=function(r,a){if(a){r.super_=a;var o=function(){};o.prototype=a.prototype,r.prototype=new o,r.prototype.constructor=r}}},{}],25:[function(i,s,n){Object.defineProperty(n,"__esModule",{value:!0});var r=function(){function a(o,l){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=o,this.value=l}return a.prototype.rotateLeft=function(){var o=this.parent,l=this.brother,u=this.leftChild,h=this.rightChild;if(!h)throw new Error("unknown error");var f=h.leftChild,g=h.rightChild;return o&&(o.leftChild===this?o.leftChild=h:o.rightChild===this&&(o.rightChild=h)),h.parent=o,h.brother=l,h.leftChild=this,h.rightChild=g,l&&(l.brother=h),this.parent=h,this.brother=g,this.leftChild=u,this.rightChild=f,g&&(g.parent=h,g.brother=this),u&&(u.parent=this,u.brother=f),f&&(f.parent=this,f.brother=u),h},a.prototype.rotateRight=function(){var o=this.parent,l=this.brother,u=this.leftChild;if(!u)throw new Error("unknown error");var h=this.rightChild,f=u.leftChild,g=u.rightChild;return o&&(o.leftChild===this?o.leftChild=u:o.rightChild===this&&(o.rightChild=u)),u.parent=o,u.brother=l,u.leftChild=f,u.rightChild=this,l&&(l.brother=u),f&&(f.parent=u,f.brother=this),this.parent=u,this.brother=f,this.leftChild=g,this.rightChild=h,g&&(g.parent=this,g.brother=h),h&&(h.parent=this,h.brother=g),u},a.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},a.TreeNodeColorType={red:!0,black:!1},a}();Object.freeze(r),n.default=r},{}],26:[function(i,s,n){var r=this&&this.__generator||function(o,l){var u,h,f,g,v={label:0,sent:function(){if(1&f[0])throw f[1];return f[1]},trys:[],ops:[]};return g={next:y(0),throw:y(1),return:y(2)},typeof Symbol=="function"&&(g[Symbol.iterator]=function(){return this}),g;function y(w){return function(p){return function(_){if(u)throw new TypeError("Generator is already executing.");for(;v;)try{if(u=1,h&&(f=2&_[0]?h.return:_[0]?h.throw||((f=h.return)&&f.call(h),0):h.next)&&!(f=f.call(h,_[1])).done)return f;switch(h=0,f&&(_=[2&_[0],f.value]),_[0]){case 0:case 1:f=_;break;case 4:return v.label++,{value:_[1],done:!1};case 5:v.label++,h=_[1],_=[0];continue;case 7:_=v.ops.pop(),v.trys.pop();continue;default:if(!(f=(f=v.trys).length>0&&f[f.length-1])&&(_[0]===6||_[0]===2)){v=0;continue}if(_[0]===3&&(!f||_[1]>f[0]&&_[1]<f[3])){v.label=_[1];break}if(_[0]===6&&v.label<f[1]){v.label=f[1],f=_;break}if(f&&v.label<f[2]){v.label=f[2],v.ops.push(_);break}f[2]&&v.ops.pop(),v.trys.pop();continue}_=l.call(o,v)}catch(E){_=[6,E],h=0}finally{u=f=0}if(5&_[0])throw _[1];return{value:_[0]?_[1]:void 0,done:!0}}([w,p])}}};function a(o){var l=this;o===void 0&&(o=[]);var u=[],h=0,f=0,g=0,v=0,y=0,w=0;this.size=function(){return w},this.empty=function(){return w===0},this.clear=function(){h=g=f=v=y=w=0,_.call(this,a.bucketSize),w=0},this.front=function(){return u[h][f]},this.back=function(){return u[g][v]},this.forEach=function(E){if(!this.empty()){var x=0;if(h!==g){for(S=f;S<a.bucketSize;++S)E(u[h][S],x++);for(S=h+1;S<g;++S)for(var C=0;C<a.bucketSize;++C)E(u[S][C],x++);for(S=0;S<=v;++S)E(u[g][S],x++)}else for(var S=f;S<=v;++S)E(u[h][S],x++)}};var p=function(E){var x=h*a.bucketSize+f,C=x+E,S=g*a.bucketSize+v;if(C<x||C>S)throw new Error("pos should more than 0 and less than queue's size");return{curNodeBucketIndex:Math.floor(C/a.bucketSize),curNodePointerIndex:C%a.bucketSize}};this.getElementByPos=function(E){var x=p(E),C=x.curNodeBucketIndex,S=x.curNodePointerIndex;return u[C][S]},this.eraseElementByPos=function(E){var x=this;if(E<0||E>w)throw new Error("pos should more than 0 and less than queue's size");if(E===0)this.popFront();else if(E===this.size())this.popBack();else{for(var C=[],S=E+1;S<w;++S)C.push(this.getElementByPos(S));this.cut(E),this.popBack(),C.forEach(function(D){return x.pushBack(D)})}},this.eraseElementByValue=function(E){if(!this.empty()){var x=[];this.forEach(function(D){D!==E&&x.push(D)});for(var C=x.length,S=0;S<C;++S)this.setElementByPos(S,x[S]);this.cut(C-1)}};var _=function(E){for(var x=[],C=E*a.sigma,S=Math.max(Math.ceil(C/a.bucketSize),2),D=0;D<S;++D)x.push(new Array(a.bucketSize));var B=Math.ceil(E/a.bucketSize),L=Math.floor(S/2)-Math.floor(B/2),V=L,tt=0;if(this.size())for(D=0;D<B;++D){for(var T=0;T<a.bucketSize;++T)if(x[L+D][T]=this.front(),this.popFront(),this.empty()){V=L+D,tt=T;break}if(this.empty())break}u=x,h=L,f=0,g=V,v=tt,y=S,w=E};this.pushBack=function(E){this.empty()||(g===y-1&&v===a.bucketSize-1&&_.call(this,this.size()),v<a.bucketSize-1?++v:g<y-1&&(++g,v=0)),++w,u[g][v]=E},this.popBack=function(){this.empty()||(this.size()!==1&&(v>0?--v:h<g&&(--g,v=a.bucketSize-1)),w>0&&--w)},this.setElementByPos=function(E,x){var C=p(E),S=C.curNodeBucketIndex,D=C.curNodePointerIndex;u[S][D]=x},this.insert=function(E,x,C){var S=this;if(C===void 0&&(C=1),E===0)for(;C--;)this.pushFront(x);else if(E===this.size())for(;C--;)this.pushBack(x);else{for(var D=[],B=E;B<w;++B)D.push(this.getElementByPos(B));for(this.cut(E-1),B=0;B<C;++B)this.pushBack(x);D.forEach(function(L){return S.pushBack(L)})}},this.find=function(E){if(h===g){for(var x=f;x<=v;++x)if(u[h][x]===E)return!0;return!1}for(x=f;x<a.bucketSize;++x)if(u[h][x]===E)return!0;for(x=h+1;x<g;++x)for(var C=0;C<a.bucketSize;++C)if(u[x][C]===E)return!0;for(x=0;x<=v;++x)if(u[g][x]===E)return!0;return!1},this.reverse=function(){for(var E=0,x=w-1;E<x;){var C=this.getElementByPos(E);this.setElementByPos(E,this.getElementByPos(x)),this.setElementByPos(x,C),++E,--x}},this.unique=function(){if(!this.empty()){var E=[],x=this.front();this.forEach(function(S,D){D!==0&&S===x||(E.push(S),x=S)});for(var C=0;C<w;++C)this.setElementByPos(C,E[C]);this.cut(E.length-1)}},this.sort=function(E){var x=[];this.forEach(function(S){x.push(S)}),x.sort(E);for(var C=0;C<w;++C)this.setElementByPos(C,x[C])},this.pushFront=function(E){this.empty()||(h===0&&f===0&&_.call(this,this.size()),f>0?--f:h>0&&(--h,f=a.bucketSize-1)),++w,u[h][f]=E},this.popFront=function(){this.empty()||(this.size()!==1&&(f<a.bucketSize-1?++f:h<g&&(++h,f=0)),w>0&&--w)},this.shrinkToFit=function(){var E=this,x=[];this.forEach(function(B){x.push(B)});var C=x.length;u=[];for(var S=Math.ceil(C/a.bucketSize),D=0;D<S;++D)u.push(new Array(a.bucketSize));this.clear(),x.forEach(function(B){return E.pushBack(B)})},this.cut=function(E){if(E<0)this.clear();else{var x=p(E),C=x.curNodeBucketIndex,S=x.curNodePointerIndex;g=C,v=S,w=E+1}},this[Symbol.iterator]=function(){return function(){var E,x;return r(this,function(C){switch(C.label){case 0:if(w===0)return[2];if(h!==g)return[3,5];x=f,C.label=1;case 1:return x<=v?[4,u[h][x]]:[3,4];case 2:C.sent(),C.label=3;case 3:return++x,[3,1];case 4:return[2];case 5:x=f,C.label=6;case 6:return x<a.bucketSize?[4,u[h][x]]:[3,9];case 7:C.sent(),C.label=8;case 8:return++x,[3,6];case 9:x=h+1,C.label=10;case 10:if(!(x<g))return[3,15];E=0,C.label=11;case 11:return E<a.bucketSize?[4,u[x][E]]:[3,14];case 12:C.sent(),C.label=13;case 13:return++E,[3,11];case 14:return++x,[3,10];case 15:x=0,C.label=16;case 16:return x<=v?[4,u[g][x]]:[3,19];case 17:C.sent(),C.label=18;case 18:return++x,[3,16];case 19:return[2]}})}()},function(){var E=a.bucketSize;o.size?E=o.size():o.length&&(E=o.length);var x=E*a.sigma;y=Math.ceil(x/a.bucketSize),y=Math.max(y,3);for(var C=0;C<y;++C)u.push(new Array(a.bucketSize));var S=Math.ceil(E/a.bucketSize);h=Math.floor(y/2)-Math.floor(S/2),g=h,o.forEach(function(D){return l.pushBack(D)})}(),Object.freeze(this)}Object.defineProperty(n,"__esModule",{value:!0}),a.sigma=3,a.bucketSize=5e3,Object.freeze(a),n.default=a},{}],27:[function(i,s,n){var r=this&&this.__generator||function(h,f){var g,v,y,w,p={label:0,sent:function(){if(1&y[0])throw y[1];return y[1]},trys:[],ops:[]};return w={next:_(0),throw:_(1),return:_(2)},typeof Symbol=="function"&&(w[Symbol.iterator]=function(){return this}),w;function _(E){return function(x){return function(C){if(g)throw new TypeError("Generator is already executing.");for(;p;)try{if(g=1,v&&(y=2&C[0]?v.return:C[0]?v.throw||((y=v.return)&&y.call(v),0):v.next)&&!(y=y.call(v,C[1])).done)return y;switch(v=0,y&&(C=[2&C[0],y.value]),C[0]){case 0:case 1:y=C;break;case 4:return p.label++,{value:C[1],done:!1};case 5:p.label++,v=C[1],C=[0];continue;case 7:C=p.ops.pop(),p.trys.pop();continue;default:if(!(y=(y=p.trys).length>0&&y[y.length-1])&&(C[0]===6||C[0]===2)){p=0;continue}if(C[0]===3&&(!y||C[1]>y[0]&&C[1]<y[3])){p.label=C[1];break}if(C[0]===6&&p.label<y[1]){p.label=y[1],y=C;break}if(y&&p.label<y[2]){p.label=y[2],p.ops.push(C);break}y[2]&&p.ops.pop(),p.trys.pop();continue}C=f.call(h,p)}catch(S){C=[6,S],v=0}finally{g=y=0}if(5&C[0])throw C[1];return{value:C[0]?C[1]:void 0,done:!0}}([E,x])}}},a=this&&this.__values||function(h){var f=typeof Symbol=="function"&&Symbol.iterator,g=f&&h[f],v=0;if(g)return g.call(h);if(h&&typeof h.length=="number")return{next:function(){return h&&v>=h.length&&(h=void 0),{value:h&&h[v++],done:!h}}};throw new TypeError(f?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(n,"__esModule",{value:!0});var o=i("../LinkList/LinkList"),l=i("../Map/Map");function u(h,f,g){var v=this;if(h===void 0&&(h=[]),f===void 0&&(f=u.initSize),g=g||function(_){var E,x,C=0,S="";if(typeof _=="number")C=((C=Math.floor(_))<<5)-C,C&=C;else{S=typeof _!="string"?JSON.stringify(_):_;try{for(var D=a(S),B=D.next();!B.done;B=D.next())C=(C<<5)-C+B.value.charCodeAt(0),C&=C}catch(L){E={error:L}}finally{try{B&&!B.done&&(x=D.return)&&x.call(D)}finally{if(E)throw E.error}}}return C^=C>>>16},(f&f-1)!=0)throw new Error("initBucketNum must be 2 to the power of n");var y=0,w=[],p=Math.max(u.initSize,Math.min(u.maxSize,f));this.size=function(){return y},this.empty=function(){return y===0},this.clear=function(){y=0,p=f,w=[]},this.forEach=function(_){var E=0;w.forEach(function(x){x.forEach(function(C){_(C,E++)})})},this.setElement=function(_,E){var x,C;if(_==null)throw new Error("to avoid some unnecessary errors, we don't suggest you insert null or undefined here");if(E!=null){var S=g(_)&p-1;if(w[S]){var D=w[S].size();if(w[S]instanceof o.default){try{for(var B=a(w[S]),L=B.next();!L.done;L=B.next()){var V=L.value;if(V.key===_)return void(V.value=E)}}catch(T){x={error:T}}finally{try{L&&!L.done&&(C=B.return)&&C.call(B)}finally{if(x)throw x.error}}w[S].pushBack({key:_,value:E}),w[S].size()>=u.treeifyThreshold&&(w[S]=new l.default(w[S]))}else w[S].setElement(_,E);var tt=w[S].size();y+=tt-D}else++y,w[S]=new o.default([{key:_,value:E}]);y>p*u.sigma&&function(T){if(!(T>=u.maxSize)){p=2*T;var R=[];w.forEach(function(P,O){if(!P.empty()){if(P instanceof o.default&&P.size()===1){var Y=P.front(),Z=Y.key,rt=Y.value;R[g(Z)&p-1]=new o.default([{key:Z,value:rt}])}else if(P instanceof l.default){var $=new o.default,H=new o.default;P.forEach(function(W){(g(W.key)&T)==0?$.pushBack(W):H.pushBack(W)}),$.size()>u.untreeifyThreshold?R[O]=new l.default($):$.size()&&(R[O]=$),H.size()>u.untreeifyThreshold?R[O+T]=new l.default(H):H.size()&&(R[O+T]=H)}else{var j=new o.default,K=new o.default;P.forEach(function(W){(g(W.key)&T)==0?j.pushBack(W):K.pushBack(W)}),j.size()&&(R[O]=j),K.size()&&(R[O+T]=K)}w[O].clear()}}),w=R}}.call(this,p)}else this.eraseElementByKey(_)},this.getElementByKey=function(_){var E,x,C=g(_)&p-1;if(w[C]){if(w[C]instanceof l.default)return w[C].getElementByKey(_);try{for(var S=a(w[C]),D=S.next();!D.done;D=S.next()){var B=D.value;if(B.key===_)return B.value}}catch(L){E={error:L}}finally{try{D&&!D.done&&(x=S.return)&&x.call(S)}finally{if(E)throw E.error}}}},this.eraseElementByKey=function(_){var E,x,C=g(_)&p-1;if(w[C]){var S=w[C].size();if(w[C]instanceof l.default)w[C].eraseElementByKey(_),w[C].size()<=u.untreeifyThreshold&&(w[C]=new o.default(w[C]));else{var D=-1;try{for(var B=a(w[C]),L=B.next();!L.done;L=B.next())if(++D,L.value.key===_){w[C].eraseElementByPos(D);break}}catch(tt){E={error:tt}}finally{try{L&&!L.done&&(x=B.return)&&x.call(B)}finally{if(E)throw E.error}}}var V=w[C].size();y+=V-S}},this.find=function(_){var E,x,C=g(_)&p-1;if(!w[C])return!1;if(w[C]instanceof l.default)return w[C].find(_);try{for(var S=a(w[C]),D=S.next();!D.done;D=S.next())if(D.value.key===_)return!0}catch(B){E={error:B}}finally{try{D&&!D.done&&(x=S.return)&&x.call(S)}finally{if(E)throw E.error}}return!1},this[Symbol.iterator]=function(){return function(){var _,E,x,C,S,D;return r(this,function(B){switch(B.label){case 0:_=0,B.label=1;case 1:if(!(_<p))return[3,10];for(;_<p&&!w[_];)++_;if(_>=p)return[3,10];B.label=2;case 2:B.trys.push([2,7,8,9]),S=void 0,E=a(w[_]),x=E.next(),B.label=3;case 3:return x.done?[3,6]:[4,x.value];case 4:B.sent(),B.label=5;case 5:return x=E.next(),[3,3];case 6:return[3,9];case 7:return C=B.sent(),S={error:C},[3,9];case 8:try{x&&!x.done&&(D=E.return)&&D.call(E)}finally{if(S)throw S.error}return[7];case 9:return++_,[3,1];case 10:return[2]}})}()},h.forEach(function(_){var E=_.key,x=_.value;return v.setElement(E,x)}),Object.freeze(this)}u.initSize=16,u.maxSize=1<<30,u.sigma=.75,u.treeifyThreshold=8,u.untreeifyThreshold=6,u.minTreeifySize=64,Object.freeze(u),n.default=u},{"../LinkList/LinkList":29,"../Map/Map":30}],28:[function(i,s,n){var r=this&&this.__generator||function(h,f){var g,v,y,w,p={label:0,sent:function(){if(1&y[0])throw y[1];return y[1]},trys:[],ops:[]};return w={next:_(0),throw:_(1),return:_(2)},typeof Symbol=="function"&&(w[Symbol.iterator]=function(){return this}),w;function _(E){return function(x){return function(C){if(g)throw new TypeError("Generator is already executing.");for(;p;)try{if(g=1,v&&(y=2&C[0]?v.return:C[0]?v.throw||((y=v.return)&&y.call(v),0):v.next)&&!(y=y.call(v,C[1])).done)return y;switch(v=0,y&&(C=[2&C[0],y.value]),C[0]){case 0:case 1:y=C;break;case 4:return p.label++,{value:C[1],done:!1};case 5:p.label++,v=C[1],C=[0];continue;case 7:C=p.ops.pop(),p.trys.pop();continue;default:if(!(y=(y=p.trys).length>0&&y[y.length-1])&&(C[0]===6||C[0]===2)){p=0;continue}if(C[0]===3&&(!y||C[1]>y[0]&&C[1]<y[3])){p.label=C[1];break}if(C[0]===6&&p.label<y[1]){p.label=y[1],y=C;break}if(y&&p.label<y[2]){p.label=y[2],p.ops.push(C);break}y[2]&&p.ops.pop(),p.trys.pop();continue}C=f.call(h,p)}catch(S){C=[6,S],v=0}finally{g=y=0}if(5&C[0])throw C[1];return{value:C[0]?C[1]:void 0,done:!0}}([E,x])}}},a=this&&this.__values||function(h){var f=typeof Symbol=="function"&&Symbol.iterator,g=f&&h[f],v=0;if(g)return g.call(h);if(h&&typeof h.length=="number")return{next:function(){return h&&v>=h.length&&(h=void 0),{value:h&&h[v++],done:!h}}};throw new TypeError(f?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(n,"__esModule",{value:!0});var o=i("../Set/Set"),l=i("../LinkList/LinkList");function u(h,f,g){var v=this;if(h===void 0&&(h=[]),f===void 0&&(f=u.initSize),g=g||function(_){var E=0,x="";if(typeof _=="number")E=((E=Math.floor(_))<<5)-E,E&=E;else{x=typeof _!="string"?JSON.stringify(_):_;for(var C=0;C<x.length;C++)E=(E<<5)-E+x.charCodeAt(C),E&=E}return E^=E>>>16},(f&f-1)!=0)throw new Error("initBucketNum must be 2 to the power of n");var y=0,w=[],p=Math.max(u.initSize,Math.min(u.maxSize,f));this.size=function(){return y},this.empty=function(){return y===0},this.clear=function(){y=0,p=f,w=[]},this.forEach=function(_){var E=0;w.forEach(function(x){x.forEach(function(C){_(C,E++)})})},this.insert=function(_){if(_==null)throw new Error("to avoid some unnecessary errors, we don't suggest you insert null or undefined here");var E=g(_)&p-1;if(w[E]){var x=w[E].size();if(w[E]instanceof l.default){if(w[E].find(_))return;w[E].pushBack(_),w[E].size()>=u.treeifyThreshold&&(w[E]=new o.default(w[E]))}else w[E].insert(_);var C=w[E].size();y+=C-x}else w[E]=new l.default([_]),++y;y>p*u.sigma&&function(S){if(!(S>=u.maxSize)){p=2*S;var D=[];w.forEach(function(B,L){if(!B.empty()){if(B instanceof l.default&&B.size()===1){var V=B.front();if(V===void 0)throw new Error("unknown error");D[g(V)&p-1]=new l.default([V])}else if(B instanceof o.default){var tt=new l.default,T=new l.default;B.forEach(function(O){(g(O)&S)==0?tt.pushBack(O):T.pushBack(O)}),tt.size()>u.untreeifyThreshold?D[L]=new o.default(tt):tt.size()&&(D[L]=tt),T.size()>u.untreeifyThreshold?D[L+S]=new o.default(T):T.size()&&(D[L+S]=T)}else{var R=new l.default,P=new l.default;B.forEach(function(O){(g(O)&S)==0?R.pushBack(O):P.pushBack(O)}),R.size()&&(D[L]=R),P.size()&&(D[L+S]=P)}w[L].clear()}}),w=D}}.call(this,p)},this.eraseElementByValue=function(_){var E=g(_)&p-1;if(w[E]){var x=w[E].size();w[E].eraseElementByValue(_),w[E]instanceof o.default&&w[E].size()<=u.untreeifyThreshold&&(w[E]=new l.default(w[E]));var C=w[E].size();y+=C-x}},this.find=function(_){var E=g(_)&p-1;return!!w[E]&&w[E].find(_)},this[Symbol.iterator]=function(){return function(){var _,E,x,C,S,D;return r(this,function(B){switch(B.label){case 0:_=0,B.label=1;case 1:if(!(_<p))return[3,10];for(;_<p&&!w[_];)++_;if(_>=p)return[3,10];B.label=2;case 2:B.trys.push([2,7,8,9]),S=void 0,E=a(w[_]),x=E.next(),B.label=3;case 3:return x.done?[3,6]:[4,x.value];case 4:B.sent(),B.label=5;case 5:return x=E.next(),[3,3];case 6:return[3,9];case 7:return C=B.sent(),S={error:C},[3,9];case 8:try{x&&!x.done&&(D=E.return)&&D.call(E)}finally{if(S)throw S.error}return[7];case 9:return++_,[3,1];case 10:return[2]}})}()},h.forEach(function(_){return v.insert(_)}),Object.freeze(this)}u.initSize=16,u.maxSize=1<<30,u.sigma=.75,u.treeifyThreshold=8,u.untreeifyThreshold=6,u.minTreeifySize=64,Object.freeze(u),n.default=u},{"../LinkList/LinkList":29,"../Set/Set":33}],29:[function(i,s,n){var r=this&&this.__generator||function(l,u){var h,f,g,v,y={label:0,sent:function(){if(1&g[0])throw g[1];return g[1]},trys:[],ops:[]};return v={next:w(0),throw:w(1),return:w(2)},typeof Symbol=="function"&&(v[Symbol.iterator]=function(){return this}),v;function w(p){return function(_){return function(E){if(h)throw new TypeError("Generator is already executing.");for(;y;)try{if(h=1,f&&(g=2&E[0]?f.return:E[0]?f.throw||((g=f.return)&&g.call(f),0):f.next)&&!(g=g.call(f,E[1])).done)return g;switch(f=0,g&&(E=[2&E[0],g.value]),E[0]){case 0:case 1:g=E;break;case 4:return y.label++,{value:E[1],done:!1};case 5:y.label++,f=E[1],E=[0];continue;case 7:E=y.ops.pop(),y.trys.pop();continue;default:if(!(g=(g=y.trys).length>0&&g[g.length-1])&&(E[0]===6||E[0]===2)){y=0;continue}if(E[0]===3&&(!g||E[1]>g[0]&&E[1]<g[3])){y.label=E[1];break}if(E[0]===6&&y.label<g[1]){y.label=g[1],g=E;break}if(g&&y.label<g[2]){y.label=g[2],y.ops.push(E);break}g[2]&&y.ops.pop(),y.trys.pop();continue}E=u.call(l,y)}catch(x){E=[6,x],f=0}finally{h=g=0}if(5&E[0])throw E[1];return{value:E[0]?E[1]:void 0,done:!0}}([p,_])}}};Object.defineProperty(n,"__esModule",{value:!0});var a=function(){return function(l){this.value=void 0,this.pre=void 0,this.next=void 0,this.value=l}}();function o(l){var u=this;l===void 0&&(l=[]);var h=0,f=void 0,g=void 0;this.size=function(){return h},this.empty=function(){return h===0},this.clear=function(){f=g=void 0,h=0},this.front=function(){return f==null?void 0:f.value},this.back=function(){return g==null?void 0:g.value},this.forEach=function(v){for(var y=f,w=0;y;){if(y.value===void 0)throw new Error("unknown error");v(y.value,w++),y=y.next}},this.getElementByPos=function(v){if(v<0||v>=h)throw new Error("pos must more then 0 and less then the list length");for(var y=f;v--&&y;)y=y.next;if(!y||y.value===void 0)throw new Error("unknown error");return y.value},this.eraseElementByPos=function(v){if(v<0||v>=h)throw new Error("erase pos must more then 0 and less then the list length");if(v===0)this.popFront();else if(v===h-1)this.popBack();else{for(var y=f;v--;){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 w=y.pre,p=y.next;p.pre=w,w.next=p,h>0&&--h}},this.eraseElementByValue=function(v){for(;f&&f.value===v;)this.popFront();for(;g&&g.value===v;)this.popBack();if(f)for(var y=f;y;){if(y.value===v){var w=y.pre,p=y.next;p&&(p.pre=w),w&&(w.next=p),h>0&&--h}y=y.next}},this.pushBack=function(v){if(v==null)throw new Error("you can't push null or undefined here");++h;var y=new a(v);g?(g.next=y,y.pre=g,g=y):f=g=y},this.popBack=function(){g&&(h>0&&--h,g&&(f===g?f=g=void 0:(g=g.pre)&&(g.next=void 0)))},this.setElementByPos=function(v,y){if(y==null)throw new Error("you can't set null or undefined here");if(v<0||v>=h)throw new Error("pos must more then 0 and less then the list length");for(var w=f;v--;){if(!w)throw new Error("unknown error");w=w.next}w&&(w.value=y)},this.insert=function(v,y,w){if(w===void 0&&(w=1),y==null)throw new Error("you can't insert null or undefined here");if(v<0||v>h)throw new Error("insert pos must more then 0 and less then or equal to the list length");if(w<0)throw new Error("insert size must more than 0");if(v===0)for(;w--;)this.pushFront(y);else if(v===h)for(;w--;)this.pushBack(y);else{for(var p=f,_=1;_<v;++_){if(!(p!=null&&p.next))throw new Error("unknown error");p=p==null?void 0:p.next}if(!p)throw new Error("unknown error");var E=p.next;for(h+=w;w--;)p.next=new a(y),p.next.pre=p,p=p.next;p.next=E,E&&(E.pre=p)}},this.find=function(v){for(var y=f;y;){if(y.value===v)return!0;y=y.next}return!1},this.reverse=function(){for(var v=f,y=g,w=0;v&&y&&2*w<h;){var p=v.value;v.value=y.value,y.value=p,v=v.next,y=y.pre,++w}},this.unique=function(){for(var v=f;v;){for(var y=v;y&&y.next&&y.value===y.next.value;)y=y.next,h>0&&--h;v.next=y.next,v.next&&(v.next.pre=v),v=v.next}},this.sort=function(v){var y=[];this.forEach(function(p){y.push(p)}),y.sort(v);var w=f;y.forEach(function(p){w&&(w.value=p,w=w.next)})},this.pushFront=function(v){if(v==null)throw new Error("you can't push null or undefined here");++h;var y=new a(v);f?(y.next=f,f.pre=y,f=y):f=g=y},this.popFront=function(){f&&(h>0&&--h,f&&(f===g?f=g=void 0:(f=f.next)&&(f.pre=void 0)))},this.merge=function(v){var y=this,w=f;v.forEach(function(p){for(;w&&w.value!==void 0&&w.value<=p;)w=w.next;if(w===void 0)y.pushBack(p),w=g;else if(w===f)y.pushFront(p),w=f;else{++h;var _=w.pre;_&&(_.next=new a(p),_.next.pre=_,_.next.next=w,w&&(w.pre=_.next))}})},this[Symbol.iterator]=function(){return function(){var v;return r(this,function(y){switch(y.label){case 0:v=f,y.label=1;case 1:if(v===void 0)return[3,3];if(!v.value)throw new Error("unknown error");return[4,v.value];case 2:return y.sent(),v=v.next,[3,1];case 3:return[2]}})}()},l.forEach(function(v){return u.pushBack(v)}),Object.freeze(this)}Object.freeze(o),n.default=o},{}],30:[function(i,s,n){var r=this&&this.__generator||function(u,h){var f,g,v,y,w={label:0,sent:function(){if(1&v[0])throw v[1];return v[1]},trys:[],ops:[]};return y={next:p(0),throw:p(1),return:p(2)},typeof Symbol=="function"&&(y[Symbol.iterator]=function(){return this}),y;function p(_){return function(E){return function(x){if(f)throw new TypeError("Generator is already executing.");for(;w;)try{if(f=1,g&&(v=2&x[0]?g.return:x[0]?g.throw||((v=g.return)&&v.call(g),0):g.next)&&!(v=v.call(g,x[1])).done)return v;switch(g=0,v&&(x=[2&x[0],v.value]),x[0]){case 0:case 1:v=x;break;case 4:return w.label++,{value:x[1],done:!1};case 5:w.label++,g=x[1],x=[0];continue;case 7:x=w.ops.pop(),w.trys.pop();continue;default:if(!(v=(v=w.trys).length>0&&v[v.length-1])&&(x[0]===6||x[0]===2)){w=0;continue}if(x[0]===3&&(!v||x[1]>v[0]&&x[1]<v[3])){w.label=x[1];break}if(x[0]===6&&w.label<v[1]){w.label=v[1],v=x;break}if(v&&w.label<v[2]){w.label=v[2],w.ops.push(x);break}v[2]&&w.ops.pop(),w.trys.pop();continue}x=h.call(u,w)}catch(C){x=[6,C],g=0}finally{f=v=0}if(5&x[0])throw x[1];return{value:x[0]?x[1]:void 0,done:!0}}([_,E])}}},a=this&&this.__values||function(u){var h=typeof Symbol=="function"&&Symbol.iterator,f=h&&u[h],g=0;if(f)return f.call(u);if(u&&typeof u.length=="number")return{next:function(){return u&&g>=u.length&&(u=void 0),{value:u&&u[g++],done:!u}}};throw new TypeError(h?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(n,"__esModule",{value:!0});var o=i("../Base/TreeNode");function l(u,h){var f=this;u===void 0&&(u=[]),h=h||function(T,R){return T<R?-1:T>R?1:0};var g=0,v=new o.default;v.color=o.default.TreeNodeColorType.black,this.size=function(){return g},this.empty=function(){return g===0},this.clear=function(){g=0,v.key=v.value=void 0,v.leftChild=v.rightChild=v.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},w=function(T){if(!T||T.key===void 0)throw new Error("unknown error");return T.rightChild?w(T.rightChild):T};this.front=function(){if(!this.empty()){var T=y(v);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=w(v);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 R,P,O=0;try{for(var Y=a(this),Z=Y.next();!Z.done;Z=Y.next())T(Z.value,O++)}catch(rt){R={error:rt}}finally{try{Z&&!Z.done&&(P=Y.return)&&P.call(Y)}finally{if(R)throw R.error}}},this.getElementByPos=function(T){var R,P;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 Y=a(this),Z=Y.next();!Z.done;Z=Y.next()){var rt=Z.value;if(O===T)return rt;++O}}catch($){R={error:$}}finally{try{Z&&!Z.done&&(P=Y.return)&&P.call(Y)}finally{if(R)throw R.error}}throw new Error("unknown Error")};var p=function(T,R){if(T&&T.key!==void 0&&T.value!==void 0){var P=h(T.key,R);return P===0?{key:T.key,value:T.value}:P<0?p(T.rightChild,R):p(T.leftChild,R)||{key:T.key,value:T.value}}};this.lowerBound=function(T){return p(v,T)};var _=function(T,R){if(T&&T.key!==void 0&&T.value!==void 0)return h(T.key,R)<=0?_(T.rightChild,R):_(T.leftChild,R)||{key:T.key,value:T.value}};this.upperBound=function(T){return _(v,T)};var E=function(T,R){if(T&&T.key!==void 0&&T.value!==void 0){var P=h(T.key,R);return P===0?{key:T.key,value:T.value}:P>0?E(T.leftChild,R):E(T.rightChild,R)||{key:T.key,value:T.value}}};this.reverseLowerBound=function(T){return E(v,T)};var x=function(T,R){if(T&&T.key!==void 0&&T.value!==void 0)return h(T.key,R)>=0?x(T.leftChild,R):x(T.rightChild,R)||{key:T.key,value:T.value}};this.reverseUpperBound=function(T){return x(v,T)};var C=function(T){var R=T.parent;if(!R){if(T===v)return;throw new Error("unknown error")}if(T.color!==o.default.TreeNodeColorType.red){var P=T.brother;if(!P)throw new Error("unknown error");if(T===R.leftChild)if(P.color===o.default.TreeNodeColorType.red){P.color=o.default.TreeNodeColorType.black,R.color=o.default.TreeNodeColorType.red;var O=R.rotateLeft();v===R&&(v=O),C(T)}else P.color===o.default.TreeNodeColorType.black&&(P.rightChild&&P.rightChild.color===o.default.TreeNodeColorType.red?(P.color=R.color,R.color=o.default.TreeNodeColorType.black,P.rightChild&&(P.rightChild.color=o.default.TreeNodeColorType.black),O=R.rotateLeft(),v===R&&(v=O),T.color=o.default.TreeNodeColorType.black):P.rightChild&&P.rightChild.color!==o.default.TreeNodeColorType.black||!P.leftChild||P.leftChild.color!==o.default.TreeNodeColorType.red?P.leftChild&&P.leftChild.color!==o.default.TreeNodeColorType.black||P.rightChild&&P.rightChild.color!==o.default.TreeNodeColorType.black||(P.color=o.default.TreeNodeColorType.red,C(R)):(P.color=o.default.TreeNodeColorType.red,P.leftChild&&(P.leftChild.color=o.default.TreeNodeColorType.black),O=P.rotateRight(),v===P&&(v=O),C(T)));else T===R.rightChild&&(P.color===o.default.TreeNodeColorType.red?(P.color=o.default.TreeNodeColorType.black,R.color=o.default.TreeNodeColorType.red,O=R.rotateRight(),v===R&&(v=O),C(T)):P.color===o.default.TreeNodeColorType.black&&(P.leftChild&&P.leftChild.color===o.default.TreeNodeColorType.red?(P.color=R.color,R.color=o.default.TreeNodeColorType.black,P.leftChild&&(P.leftChild.color=o.default.TreeNodeColorType.black),O=R.rotateRight(),v===R&&(v=O),T.color=o.default.TreeNodeColorType.black):P.leftChild&&P.leftChild.color!==o.default.TreeNodeColorType.black||!P.rightChild||P.rightChild.color!==o.default.TreeNodeColorType.red?P.leftChild&&P.leftChild.color!==o.default.TreeNodeColorType.black||P.rightChild&&P.rightChild.color!==o.default.TreeNodeColorType.black||(P.color=o.default.TreeNodeColorType.red,C(R)):(P.color=o.default.TreeNodeColorType.red,P.rightChild&&(P.rightChild.color=o.default.TreeNodeColorType.black),O=P.rotateLeft(),v===P&&(v=O),C(T))))}else T.color=o.default.TreeNodeColorType.black},S=function(T){for(var R=T;R.leftChild||R.rightChild;){if(R.rightChild){R=y(R.rightChild);var P=T.key;T.key=R.key,R.key=P;var O=T.value;T.value=R.value,R.value=O,T=R}R.leftChild&&(R=w(R.leftChild),P=T.key,T.key=R.key,R.key=P,O=T.value,T.value=R.value,R.value=O,T=R)}C(R),R&&R.remove(),--g,v.color=o.default.TreeNodeColorType.black},D=function(T,R){return!(!T||T.key===void 0)&&(!!D(T.leftChild,R)||!!R(T)||D(T.rightChild,R))};this.eraseElementByPos=function(T){if(T<0||T>=g)throw new Error("pos must more than 0 and less than set's size");var R=0;D(v,function(P){return T===R?(S(P),!0):(++R,!1)})},this.eraseElementByKey=function(T){if(!this.empty()){var R=V(v,T);R!==void 0&&R.key!==void 0&&h(R.key,T)===0&&S(R)}};var B=function(T,R){if(!T||T.key===void 0)throw new Error("unknown error");var P=h(R,T.key);return P<0?T.leftChild?B(T.leftChild,R):(T.leftChild=new o.default,T.leftChild.parent=T,T.leftChild.brother=T.rightChild,T.rightChild&&(T.rightChild.brother=T.leftChild),T.leftChild):P>0?T.rightChild?B(T.rightChild,R):(T.rightChild=new o.default,T.rightChild.parent=T,T.rightChild.brother=T.leftChild,T.leftChild&&(T.leftChild.brother=T.rightChild),T.rightChild):T},L=function(T){var R=T.parent;if(!R){if(T===v)return;throw new Error("unknown error")}if(R.color!==o.default.TreeNodeColorType.black&&R.color===o.default.TreeNodeColorType.red){var P=R.brother,O=R.parent;if(!O)throw new Error("unknown error");if(P&&P.color===o.default.TreeNodeColorType.red)P.color=R.color=o.default.TreeNodeColorType.black,O.color=o.default.TreeNodeColorType.red,L(O);else if(!P||P.color===o.default.TreeNodeColorType.black)if(R===O.leftChild)if(T===R.leftChild){R.color=o.default.TreeNodeColorType.black,O.color=o.default.TreeNodeColorType.red;var Y=O.rotateRight();O===v&&(v=Y)}else T===R.rightChild&&(Y=R.rotateLeft(),O===v&&(v=Y),L(R));else R===O.rightChild&&(T===R.leftChild?(Y=R.rotateRight(),O===v&&(v=Y),L(R)):T===R.rightChild&&(R.color=o.default.TreeNodeColorType.black,O.color=o.default.TreeNodeColorType.red,Y=O.rotateLeft(),O===v&&(v=Y)))}};this.setElement=function(T,R){if(T==null)throw new Error("to avoid some unnecessary errors, we don't suggest you insert null or undefined here");if(R!=null){if(this.empty())return++g,v.key=T,v.value=R,void(v.color=o.default.TreeNodeColorType.black);var P=B(v,T);P.key===void 0||h(P.key,T)!==0?(++g,P.key=T,P.value=R,L(P),v.color=o.default.TreeNodeColorType.black):P.value=R}else this.eraseElementByKey(T)};var V=function(T,R){if(T&&T.key!==void 0){var P=h(R,T.key);return P<0?V(T.leftChild,R):P>0?V(T.rightChild,R):T}};this.find=function(T){return!!V(v,T)},this.getElementByKey=function(T){var R=V(v,T);if((R==null?void 0:R.key)===void 0||(R==null?void 0:R.value)===void 0)throw new Error("unknown error");return R.value},this.union=function(T){var R=this;T.forEach(function(P){var O=P.key,Y=P.value;return R.setElement(O,Y)})},this.getHeight=function(){if(this.empty())return 0;var T=function(R){return R?Math.max(T(R.leftChild),T(R.rightChild))+1:1};return T(v)};var tt=function(T){return r(this,function(R){switch(R.label){case 0:return T&&T.key!==void 0&&T.value!==void 0?[5,a(tt(T.leftChild))]:[2];case 1:return R.sent(),[4,{key:T.key,value:T.value}];case 2:return R.sent(),[5,a(tt(T.rightChild))];case 3:return R.sent(),[2]}})};this[Symbol.iterator]=function(){return tt(v)},u.forEach(function(T){var R=T.key,P=T.value;return f.setElement(R,P)}),Object.freeze(this)}Object.freeze(l),n.default=l},{"../Base/TreeNode":25}],31:[function(i,s,n){function r(a,o){a===void 0&&(a=[]),o=o||function(g,v){return g>v?-1:g<v?1:0};var l=[];a.forEach(function(g){return l.push(g)});var u=l.length,h=function(g,v){if(g<0||g>=u)throw new Error("unknown error");if(v<0||v>=u)throw new Error("unknown error");var y=l[g];l[g]=l[v],l[v]=y},f=function(g){if(g<0||g>=u)throw new Error("unknown error");var v=2*g+1,y=2*g+2;v<u&&o(l[g],l[v])>0&&h(g,v),y<u&&o(l[g],l[y])>0&&h(g,y)};(function(){for(var g=Math.floor((u-1)/2);g>=0;--g)for(var v=g,y=2*v+1;y<u;){var w=y+1,p=y;if(w<u&&o(l[y],l[w])>0&&(p=w),o(l[v],l[p])<=0)break;h(v,p),y=2*(v=p)+1}})(),this.size=function(){return u},this.empty=function(){return u===0},this.clear=function(){u=0,l.length=0},this.push=function(g){if(l.push(g),++u!==1)for(var v=u-1;v>0;){var y=Math.floor((v-1)/2);if(o(l[y],g)<=0)break;f(y),v=y}},this.pop=function(){if(!this.empty())if(this.size()!==1){var g=l[u-1];--u;for(var v=0;v<this.size();){var y=2*v+1,w=2*v+2;if(y>=this.size())break;var p=y;if(w<this.size()&&o(l[y],l[w])>0&&(p=w),o(l[p],g)>=0)break;l[v]=l[p],v=p}l[v]=g}else--u},this.top=function(){return l[0]},Object.freeze(this)}Object.defineProperty(n,"__esModule",{value:!0}),Object.freeze(r),n.default=r},{}],32:[function(i,s,n){Object.defineProperty(n,"__esModule",{value:!0});var r=i("../LinkList/LinkList");function a(o){o===void 0&&(o=[]);var l=new r.default(o);this.size=function(){return l.size()},this.empty=function(){return l.empty()},this.clear=function(){l.clear()},this.push=function(u){l.pushBack(u)},this.pop=function(){l.popFront()},this.front=function(){return l.front()},Object.freeze(this)}Object.freeze(a),n.default=a},{"../LinkList/LinkList":29}],33:[function(i,s,n){var r=this&&this.__generator||function(u,h){var f,g,v,y,w={label:0,sent:function(){if(1&v[0])throw v[1];return v[1]},trys:[],ops:[]};return y={next:p(0),throw:p(1),return:p(2)},typeof Symbol=="function"&&(y[Symbol.iterator]=function(){return this}),y;function p(_){return function(E){return function(x){if(f)throw new TypeError("Generator is already executing.");for(;w;)try{if(f=1,g&&(v=2&x[0]?g.return:x[0]?g.throw||((v=g.return)&&v.call(g),0):g.next)&&!(v=v.call(g,x[1])).done)return v;switch(g=0,v&&(x=[2&x[0],v.value]),x[0]){case 0:case 1:v=x;break;case 4:return w.label++,{value:x[1],done:!1};case 5:w.label++,g=x[1],x=[0];continue;case 7:x=w.ops.pop(),w.trys.pop();continue;default:if(!(v=(v=w.trys).length>0&&v[v.length-1])&&(x[0]===6||x[0]===2)){w=0;continue}if(x[0]===3&&(!v||x[1]>v[0]&&x[1]<v[3])){w.label=x[1];break}if(x[0]===6&&w.label<v[1]){w.label=v[1],v=x;break}if(v&&w.label<v[2]){w.label=v[2],w.ops.push(x);break}v[2]&&w.ops.pop(),w.trys.pop();continue}x=h.call(u,w)}catch(C){x=[6,C],g=0}finally{f=v=0}if(5&x[0])throw x[1];return{value:x[0]?x[1]:void 0,done:!0}}([_,E])}}},a=this&&this.__values||function(u){var h=typeof Symbol=="function"&&Symbol.iterator,f=h&&u[h],g=0;if(f)return f.call(u);if(u&&typeof u.length=="number")return{next:function(){return u&&g>=u.length&&(u=void 0),{value:u&&u[g++],done:!u}}};throw new TypeError(h?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(n,"__esModule",{value:!0});var o=i("../Base/TreeNode");function l(u,h){var f=this;u===void 0&&(u=[]),h=h||function(T,R){return T<R?-1:T>R?1:0};var g=0,v=new o.default;v.color=o.default.TreeNodeColorType.black,this.size=function(){return g},this.empty=function(){return g===0},this.clear=function(){g=0,v.key=void 0,v.leftChild=v.rightChild=v.brother=v.parent=void 0,v.color=o.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},w=function(T){if(!T||T.key===void 0)throw new Error("unknown error");return T.rightChild?w(T.rightChild):T};this.front=function(){if(!this.empty())return y(v).key},this.back=function(){if(!this.empty())return w(v).key},this.forEach=function(T){var R,P,O=0;try{for(var Y=a(this),Z=Y.next();!Z.done;Z=Y.next())T(Z.value,O++)}catch(rt){R={error:rt}}finally{try{Z&&!Z.done&&(P=Y.return)&&P.call(Y)}finally{if(R)throw R.error}}},this.getElementByPos=function(T){var R,P;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 Y=a(this),Z=Y.next();!Z.done;Z=Y.next()){var rt=Z.value;if(O===T)return rt;++O}}catch($){R={error:$}}finally{try{Z&&!Z.done&&(P=Y.return)&&P.call(Y)}finally{if(R)throw R.error}}throw new Error("unknown error")};var p=function(T){var R=T.parent;if(!R){if(T===v)return;throw new Error("unknown error")}if(T.color!==o.default.TreeNodeColorType.red){var P=T.brother;if(!P)throw new Error("unknown error");if(T===R.leftChild)if(P.color===o.default.TreeNodeColorType.red){P.color=o.default.TreeNodeColorType.black,R.color=o.default.TreeNodeColorType.red;var O=R.rotateLeft();v===R&&(v=O),p(T)}else P.color===o.default.TreeNodeColorType.black&&(P.rightChild&&P.rightChild.color===o.default.TreeNodeColorType.red?(P.color=R.color,R.color=o.default.TreeNodeColorType.black,P.rightChild&&(P.rightChild.color=o.default.TreeNodeColorType.black),O=R.rotateLeft(),v===R&&(v=O),T.color=o.default.TreeNodeColorType.black):P.rightChild&&P.rightChild.color!==o.default.TreeNodeColorType.black||!P.leftChild||P.leftChild.color!==o.default.TreeNodeColorType.red?P.leftChild&&P.leftChild.color!==o.default.TreeNodeColorType.black||P.rightChild&&P.rightChild.color!==o.default.TreeNodeColorType.black||(P.color=o.default.TreeNodeColorType.red,p(R)):(P.color=o.default.TreeNodeColorType.red,P.leftChild&&(P.leftChild.color=o.default.TreeNodeColorType.black),O=P.rotateRight(),v===P&&(v=O),p(T)));else T===R.rightChild&&(P.color===o.default.TreeNodeColorType.red?(P.color=o.default.TreeNodeColorType.black,R.color=o.default.TreeNodeColorType.red,O=R.rotateRight(),v===R&&(v=O),p(T)):P.color===o.default.TreeNodeColorType.black&&(P.leftChild&&P.leftChild.color===o.default.TreeNodeColorType.red?(P.color=R.color,R.color=o.default.TreeNodeColorType.black,P.leftChild&&(P.leftChild.color=o.default.TreeNodeColorType.black),O=R.rotateRight(),v===R&&(v=O),T.color=o.default.TreeNodeColorType.black):P.leftChild&&P.leftChild.color!==o.default.TreeNodeColorType.black||!P.rightChild||P.rightChild.color!==o.default.TreeNodeColorType.red?P.leftChild&&P.leftChild.color!==o.default.TreeNodeColorType.black||P.rightChild&&P.rightChild.color!==o.default.TreeNodeColorType.black||(P.color=o.default.TreeNodeColorType.red,p(R)):(P.color=o.default.TreeNodeColorType.red,P.rightChild&&(P.rightChild.color=o.default.TreeNodeColorType.black),O=P.rotateLeft(),v===P&&(v=O),p(T))))}else T.color=o.default.TreeNodeColorType.black},_=function(T){for(var R=T;R.leftChild||R.rightChild;){if(R.rightChild){R=y(R.rightChild);var P=T.key;T.key=R.key,R.key=P,T=R}R.leftChild&&(R=w(R.leftChild),P=T.key,T.key=R.key,R.key=P,T=R)}p(R),R&&R.remove(),--g,v.color=o.default.TreeNodeColorType.black},E=function(T,R){return!(!T||T.key===void 0)&&(!!E(T.leftChild,R)||!!R(T)||E(T.rightChild,R))};this.eraseElementByPos=function(T){if(T<0||T>=g)throw new Error("pos must more than 0 and less than set's size");var R=0;E(v,function(P){return T===R?(_(P),!0):(++R,!1)})},this.eraseElementByValue=function(T){if(!this.empty()){var R=S(v,T);R!==void 0&&R.key!==void 0&&h(R.key,T)===0&&_(R)}};var x=function(T,R){if(!T||T.key===void 0)throw new Error("unknown error");var P=h(R,T.key);return P<0?T.leftChild?x(T.leftChild,R):(T.leftChild=new o.default,T.leftChild.parent=T,T.leftChild.brother=T.rightChild,T.rightChild&&(T.rightChild.brother=T.leftChild),T.leftChild):P>0?T.rightChild?x(T.rightChild,R):(T.rightChild=new o.default,T.rightChild.parent=T,T.rightChild.brother=T.leftChild,T.leftChild&&(T.leftChild.brother=T.rightChild),T.rightChild):T},C=function(T){var R=T.parent;if(!R){if(T===v)return;throw new Error("unknown error")}if(R.color!==o.default.TreeNodeColorType.black&&R.color===o.default.TreeNodeColorType.red){var P=R.brother,O=R.parent;if(!O)throw new Error("unknown error");if(P&&P.color===o.default.TreeNodeColorType.red)P.color=R.color=o.default.TreeNodeColorType.black,O.color=o.default.TreeNodeColorType.red,C(O);else if(!P||P.color===o.default.TreeNodeColorType.black)if(R===O.leftChild)if(T===R.leftChild){R.color=o.default.TreeNodeColorType.black,O.color=o.default.TreeNodeColorType.red;var Y=O.rotateRight();O===v&&(v=Y)}else T===R.rightChild&&(Y=R.rotateLeft(),O===v&&(v=Y),C(R));else R===O.rightChild&&(T===R.leftChild?(Y=R.rotateRight(),O===v&&(v=Y),C(R)):T===R.rightChild&&(R.color=o.default.TreeNodeColorType.black,O.color=o.default.TreeNodeColorType.red,Y=O.rotateLeft(),O===v&&(v=Y)))}};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++g,v.key=T,void(v.color=o.default.TreeNodeColorType.black);var R=x(v,T);R.key!==void 0&&h(R.key,T)===0||(++g,R.key=T,C(R),v.color=o.default.TreeNodeColorType.black)};var S=function(T,R){if(T&&T.key!==void 0){var P=h(R,T.key);return P<0?S(T.leftChild,R):P>0?S(T.rightChild,R):T}};this.find=function(T){var R=S(v,T);return R!==void 0&&R.key!==void 0&&h(R.key,T)===0};var D=function(T,R){if(T&&T.key!==void 0){var P=h(T.key,R);if(P===0)return T.key;if(P<0)return D(T.rightChild,R);var O=D(T.leftChild,R);return O!==void 0?O:T.key}};this.lowerBound=function(T){return D(v,T)};var B=function(T,R){if(T&&T.key!==void 0){if(h(T.key,R)<=0)return B(T.rightChild,R);var P=B(T.leftChild,R);return P!==void 0?P:T.key}};this.upperBound=function(T){return B(v,T)};var L=function(T,R){if(T&&T.key!==void 0){var P=h(T.key,R);if(P===0)return T.key;if(P>0)return L(T.leftChild,R);var O=L(T.rightChild,R);return O!==void 0?O:T.key}};this.reverseLowerBound=function(T){return L(v,T)};var V=function(T,R){if(T&&T.key!==void 0){if(h(T.key,R)>=0)return V(T.leftChild,R);var P=V(T.rightChild,R);return P!==void 0?P:T.key}};this.reverseUpperBound=function(T){return V(v,T)},this.union=function(T){var R=this;T.forEach(function(P){return R.insert(P)})},this.getHeight=function(){if(this.empty())return 0;var T=function(R){return R?Math.max(T(R.leftChild),T(R.rightChild))+1:1};return T(v)};var tt=function(T){return r(this,function(R){switch(R.label){case 0:return T&&T.key!==void 0?[5,a(tt(T.leftChild))]:[2];case 1:return R.sent(),[4,T.key];case 2:return R.sent(),[5,a(tt(T.rightChild))];case 3:return R.sent(),[2]}})};this[Symbol.iterator]=function(){return tt(v)},u.forEach(function(T){return f.insert(T)}),Object.freeze(this)}Object.freeze(l),n.default=l},{"../Base/TreeNode":25}],34:[function(i,s,n){function r(a){var o=this;a===void 0&&(a=[]);var l=0,u=[];this.size=function(){return l},this.empty=function(){return l===0},this.clear=function(){l=0,u.length=0},this.push=function(h){u.push(h),++l},this.pop=function(){u.pop(),l>0&&--l},this.top=function(){return u[l-1]},a.forEach(function(h){return o.push(h)}),Object.freeze(this)}Object.defineProperty(n,"__esModule",{value:!0}),Object.freeze(r),n.default=r},{}],35:[function(i,s,n){var r=this&&this.__generator||function(h,f){var g,v,y,w,p={label:0,sent:function(){if(1&y[0])throw y[1];return y[1]},trys:[],ops:[]};return w={next:_(0),throw:_(1),return:_(2)},typeof Symbol=="function"&&(w[Symbol.iterator]=function(){return this}),w;function _(E){return function(x){return function(C){if(g)throw new TypeError("Generator is already executing.");for(;p;)try{if(g=1,v&&(y=2&C[0]?v.return:C[0]?v.throw||((y=v.return)&&y.call(v),0):v.next)&&!(y=y.call(v,C[1])).done)return y;switch(v=0,y&&(C=[2&C[0],y.value]),C[0]){case 0:case 1:y=C;break;case 4:return p.label++,{value:C[1],done:!1};case 5:p.label++,v=C[1],C=[0];continue;case 7:C=p.ops.pop(),p.trys.pop();continue;default:if(!(y=(y=p.trys).length>0&&y[y.length-1])&&(C[0]===6||C[0]===2)){p=0;continue}if(C[0]===3&&(!y||C[1]>y[0]&&C[1]<y[3])){p.label=C[1];break}if(C[0]===6&&p.label<y[1]){p.label=y[1],y=C;break}if(y&&p.label<y[2]){p.label=y[2],p.ops.push(C);break}y[2]&&p.ops.pop(),p.trys.pop();continue}C=f.call(h,p)}catch(S){C=[6,S],v=0}finally{g=y=0}if(5&C[0])throw C[1];return{value:C[0]?C[1]:void 0,done:!0}}([E,x])}}},a=this&&this.__read||function(h,f){var g=typeof Symbol=="function"&&h[Symbol.iterator];if(!g)return h;var v,y,w=g.call(h),p=[];try{for(;(f===void 0||f-- >0)&&!(v=w.next()).done;)p.push(v.value)}catch(_){y={error:_}}finally{try{v&&!v.done&&(g=w.return)&&g.call(w)}finally{if(y)throw y.error}}return p},o=this&&this.__spreadArray||function(h,f,g){if(g||arguments.length===2)for(var v,y=0,w=f.length;y<w;y++)!v&&y in f||(v||(v=Array.prototype.slice.call(f,0,y)),v[y]=f[y]);return h.concat(v||Array.prototype.slice.call(f))},l=this&&this.__values||function(h){var f=typeof Symbol=="function"&&Symbol.iterator,g=f&&h[f],v=0;if(g)return g.call(h);if(h&&typeof h.length=="number")return{next:function(){return h&&v>=h.length&&(h=void 0),{value:h&&h[v++],done:!h}}};throw new TypeError(f?"Object is not iterable.":"Symbol.iterator is not defined.")};function u(h){var f=this;h===void 0&&(h=[]);var g=0,v=[];this.size=function(){return g},this.empty=function(){return g===0},this.clear=function(){g=0,v.length=0},this.front=function(){if(!this.empty())return v[0]},this.back=function(){if(!this.empty())return v[g-1]},this.forEach=function(y){v.forEach(y)},this.getElementByPos=function(y){if(y<0||y>=g)throw new Error("pos must more than 0 and less than vector's size");return v[y]},this.eraseElementByPos=function(y){if(y<0||y>=g)throw new Error("pos must more than 0 and less than vector's size");for(var w=y;w<g-1;++w)v[w]=v[w+1];this.popBack()},this.eraseElementByValue=function(y){var w=[];this.forEach(function(_){_!==y&&w.push(_)}),w.forEach(function(_,E){v[E]=_});for(var p=w.length;g>p;)this.popBack()},this.pushBack=function(y){v.push(y),++g},this.popBack=function(){v.pop(),g>0&&--g},this.setElementByPos=function(y,w){if(y<0||y>=g)throw new Error("pos must more than 0 and less than vector's size");v[y]=w},this.insert=function(y,w,p){if(p===void 0&&(p=1),y<0||y>g)throw new Error("pos must more than 0 and less than or equal to vector's size");v.splice.apply(v,o([y,0],a(new Array(p).fill(w)),!1)),g+=p},this.find=function(y){return v.includes(y)},this.reverse=function(){v.reverse()},this.unique=function(){var y,w=[];this.forEach(function(_,E){E!==0&&_===y||(w.push(_),y=_)}),w.forEach(function(_,E){v[E]=_});for(var p=w.length;g>p;)this.popBack()},this.sort=function(y){v.sort(y)},this[Symbol.iterator]=function(){return function(){return r(this,function(y){switch(y.label){case 0:return[5,l(v)];case 1:return[2,y.sent()]}})}()},h.forEach(function(y){return f.pushBack(y)}),Object.freeze(this)}Object.defineProperty(n,"__esModule",{value:!0}),Object.freeze(u),n.default=u},{}],36:[function(i,s,n){Object.defineProperty(n,"__esModule",{value:!0}),n.HashMap=n.HashSet=n.Map=n.Set=n.PriorityQueue=n.Deque=n.LinkList=n.Queue=n.Stack=n.Vector=void 0;var r=i("./Vector/Vector");n.Vector=r.default;var a=i("./Stack/Stack");n.Stack=a.default;var o=i("./Queue/Queue");n.Queue=o.default;var l=i("./LinkList/LinkList");n.LinkList=l.default;var u=i("./Deque/Deque");n.Deque=u.default;var h=i("./PriorityQueue/PriorityQueue");n.PriorityQueue=h.default;var f=i("./Set/Set");n.Set=f.default;var g=i("./Map/Map");n.Map=g.default;var v=i("./HashSet/HashSet");n.HashSet=v.default;var y=i("./HashMap/HashMap");n.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,s,n){const r=i("yallist"),a=Symbol("max"),o=Symbol("length"),l=Symbol("lengthCalculator"),u=Symbol("allowStale"),h=Symbol("maxAge"),f=Symbol("dispose"),g=Symbol("noDisposeOnSet"),v=Symbol("lruList"),y=Symbol("cache"),w=Symbol("updateAgeOnGet"),p=()=>1,_=(B,L,V)=>{const tt=B[y].get(L);if(tt){const T=tt.value;if(E(B,T)){if(C(B,tt),!B[u])return}else V&&(B[w]&&(tt.value.now=Date.now()),B[v].unshiftNode(tt));return T.value}},E=(B,L)=>{if(!L||!L.maxAge&&!B[h])return!1;const V=Date.now()-L.now;return L.maxAge?V>L.maxAge:B[h]&&V>B[h]},x=B=>{if(B[o]>B[a])for(let L=B[v].tail;B[o]>B[a]&&L!==null;){const V=L.prev;C(B,L),L=V}},C=(B,L)=>{if(L){const V=L.value;B[f]&&B[f](V.key,V.value),B[o]-=V.length,B[y].delete(V.key),B[v].removeNode(L)}};class S{constructor(L,V,tt,T,R){this.key=L,this.value=V,this.length=tt,this.now=T,this.maxAge=R||0}}const D=(B,L,V,tt)=>{let T=V.value;E(B,T)&&(C(B,V),B[u]||(T=void 0)),T&&L.call(tt,T.value,T.key,B)};s.exports=class{constructor(B){if(typeof B=="number"&&(B={max:B}),B||(B={}),B.max&&(typeof B.max!="number"||B.max<0))throw new TypeError("max must be a non-negative number");this[a]=B.max||1/0;const L=B.length||p;if(this[l]=typeof L!="function"?p:L,this[u]=B.stale||!1,B.maxAge&&typeof B.maxAge!="number")throw new TypeError("maxAge must be a number");this[h]=B.maxAge||0,this[f]=B.dispose,this[g]=B.noDisposeOnSet||!1,this[w]=B.updateAgeOnGet||!1,this.reset()}set max(B){if(typeof B!="number"||B<0)throw new TypeError("max must be a non-negative number");this[a]=B||1/0,x(this)}get max(){return this[a]}set allowStale(B){this[u]=!!B}get allowStale(){return this[u]}set maxAge(B){if(typeof B!="number")throw new TypeError("maxAge must be a non-negative number");this[h]=B,x(this)}get maxAge(){return this[h]}set lengthCalculator(B){typeof B!="function"&&(B=p),B!==this[l]&&(this[l]=B,this[o]=0,this[v].forEach(L=>{L.length=this[l](L.value,L.key),this[o]+=L.length})),x(this)}get lengthCalculator(){return this[l]}get length(){return this[o]}get itemCount(){return this[v].length}rforEach(B,L){L=L||this;for(let V=this[v].tail;V!==null;){const tt=V.prev;D(this,B,V,L),V=tt}}forEach(B,L){L=L||this;for(let V=this[v].head;V!==null;){const tt=V.next;D(this,B,V,L),V=tt}}keys(){return this[v].toArray().map(B=>B.key)}values(){return this[v].toArray().map(B=>B.value)}reset(){this[f]&&this[v]&&this[v].length&&this[v].forEach(B=>this[f](B.key,B.value)),this[y]=new Map,this[v]=new r,this[o]=0}dump(){return this[v].map(B=>!E(this,B)&&{k:B.key,v:B.value,e:B.now+(B.maxAge||0)}).toArray().filter(B=>B)}dumpLru(){return this[v]}set(B,L,V){if((V=V||this[h])&&typeof V!="number")throw new TypeError("maxAge must be a number");const tt=V?Date.now():0,T=this[l](L,B);if(this[y].has(B)){if(T>this[a])return C(this,this[y].get(B)),!1;const P=this[y].get(B).value;return this[f]&&(this[g]||this[f](B,P.value)),P.now=tt,P.maxAge=V,P.value=L,this[o]+=T-P.length,P.length=T,this.get(B),x(this),!0}const R=new S(B,L,T,tt,V);return R.length>this[a]?(this[f]&&this[f](B,L),!1):(this[o]+=R.length,this[v].unshift(R),this[y].set(B,this[v].head),x(this),!0)}has(B){if(!this[y].has(B))return!1;const L=this[y].get(B).value;return!E(this,L)}get(B){return _(this,B,!0)}peek(B){return _(this,B,!1)}pop(){const B=this[v].tail;return B?(C(this,B),B.value):null}del(B){C(this,this[y].get(B))}load(B){this.reset();const L=Date.now();for(let V=B.length-1;V>=0;V--){const tt=B[V],T=tt.e||0;if(T===0)this.set(tt.k,tt.v);else{const R=T-L;R>0&&this.set(tt.k,tt.v,R)}}}prune(){this[y].forEach((B,L)=>_(this,L,!1))}}},{yallist:83}],38:[function(i,s,n){(function(r){(function(){const a=s.exports;a.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"},a.codes={};for(const l in a.types){const u=a.types[l];a.codes[u]=l}a.CMD_SHIFT=4,a.CMD_MASK=240,a.DUP_MASK=8,a.QOS_MASK=3,a.QOS_SHIFT=1,a.RETAIN_MASK=1,a.VARBYTEINT_MASK=127,a.VARBYTEINT_FIN_MASK=128,a.VARBYTEINT_MAX=268435455,a.SESSIONPRESENT_MASK=1,a.SESSIONPRESENT_HEADER=r.from([a.SESSIONPRESENT_MASK]),a.CONNACK_HEADER=r.from([a.codes.connack<<a.CMD_SHIFT]),a.USERNAME_MASK=128,a.PASSWORD_MASK=64,a.WILL_RETAIN_MASK=32,a.WILL_QOS_MASK=24,a.WILL_QOS_SHIFT=3,a.WILL_FLAG_MASK=4,a.CLEAN_SESSION_MASK=2,a.CONNECT_HEADER=r.from([a.codes.connect<<a.CMD_SHIFT]),a.properties={sessionExpiryInterval:17,willDelayInterval:24,receiveMaximum:33,maximumPacketSize:39,topicAliasMaximum:34,requestResponseInformation:25,requestProblemInformation:23,userProperties:38,authenticationMethod:21,authenticationData:22,payloadFormatIndicator:1,messageExpiryInterval:2,contentType:3,responseTopic:8,correlationData:9,maximumQoS:36,retainAvailable:37,assignedClientIdentifier:18,reasonString:31,wildcardSubscriptionAvailable:40,subscriptionIdentifiersAvailable:41,sharedSubscriptionAvailable:42,serverKeepAlive:19,responseInformation:26,serverReference:28,topicAlias:35,subscriptionIdentifier:11},a.propertiesCodes={};for(const l in a.properties){const u=a.properties[l];a.propertiesCodes[u]=l}function o(l){return[0,1,2].map(u=>[0,1].map(h=>[0,1].map(f=>{const g=r.alloc(1);return g.writeUInt8(a.codes[l]<<a.CMD_SHIFT|(h?a.DUP_MASK:0)|u<<a.QOS_SHIFT|f,0,!0),g})))}a.propertiesTypes={sessionExpiryInterval:"int32",willDelayInterval:"int32",receiveMaximum:"int16",maximumPacketSize:"int32",topicAliasMaximum:"int16",requestResponseInformation:"byte",requestProblemInformation:"byte",userProperties:"pair",authenticationMethod:"string",authenticationData:"binary",payloadFormatIndicator:"byte",messageExpiryInterval:"int32",contentType:"string",responseTopic:"string",correlationData:"binary",maximumQoS:"int8",retainAvailable:"byte",assignedClientIdentifier:"string",reasonString:"string",wildcardSubscriptionAvailable:"byte",subscriptionIdentifiersAvailable:"byte",sharedSubscriptionAvailable:"byte",serverKeepAlive:"int16",responseInformation:"string",serverReference:"string",topicAlias:"int16",subscriptionIdentifier:"var"},a.PUBLISH_HEADER=o("publish"),a.SUBSCRIBE_HEADER=o("subscribe"),a.SUBSCRIBE_OPTIONS_QOS_MASK=3,a.SUBSCRIBE_OPTIONS_NL_MASK=1,a.SUBSCRIBE_OPTIONS_NL_SHIFT=2,a.SUBSCRIBE_OPTIONS_RAP_MASK=1,a.SUBSCRIBE_OPTIONS_RAP_SHIFT=3,a.SUBSCRIBE_OPTIONS_RH_MASK=3,a.SUBSCRIBE_OPTIONS_RH_SHIFT=4,a.SUBSCRIBE_OPTIONS_RH=[0,16,32],a.SUBSCRIBE_OPTIONS_NL=4,a.SUBSCRIBE_OPTIONS_RAP=8,a.SUBSCRIBE_OPTIONS_QOS=[0,1,2],a.UNSUBSCRIBE_HEADER=o("unsubscribe"),a.ACKS={unsuback:o("unsuback"),puback:o("puback"),pubcomp:o("pubcomp"),pubrel:o("pubrel"),pubrec:o("pubrec")},a.SUBACK_HEADER=r.from([a.codes.suback<<a.CMD_SHIFT]),a.VERSION3=r.from([3]),a.VERSION4=r.from([4]),a.VERSION5=r.from([5]),a.VERSION131=r.from([131]),a.VERSION132=r.from([132]),a.QOS=[0,1,2].map(l=>r.from([l])),a.EMPTY={pingreq:r.from([a.codes.pingreq<<4,0]),pingresp:r.from([a.codes.pingresp<<4,0]),disconnect:r.from([a.codes.disconnect<<4,0])}}).call(this)}).call(this,i("buffer").Buffer)},{buffer:17}],39:[function(i,s,n){(function(r){(function(){const a=i("./writeToStream"),o=i("events");class l extends o{constructor(){super(),this._array=new Array(20),this._i=0}write(h){return this._array[this._i++]=h,!0}concat(){let h=0;const f=new Array(this._array.length),g=this._array;let v,y=0;for(v=0;v<g.length&&g[v]!==void 0;v++)typeof g[v]!="string"?f[v]=g[v].length:f[v]=r.byteLength(g[v]),h+=f[v];const w=r.allocUnsafe(h);for(v=0;v<g.length&&g[v]!==void 0;v++)typeof g[v]!="string"?(g[v].copy(w,y),y+=f[v]):(w.write(g[v],y),y+=f[v]);return w}}s.exports=function(u,h){const f=new l;return a(u,f,h),f.concat()}}).call(this)}).call(this,i("buffer").Buffer)},{"./writeToStream":44,buffer:17,events:22}],40:[function(i,s,n){n.parser=i("./parser").parser,n.generate=i("./generate"),n.writeToStream=i("./writeToStream")},{"./generate":39,"./parser":43,"./writeToStream":44}],41:[function(i,s,n){(function(r){(function(){const o={},l=r.isBuffer(r.from([1,2]).subarray(0,1));function u(h){const f=r.allocUnsafe(2);return f.writeUInt8(h>>8,0),f.writeUInt8(255&h,1),f}s.exports={cache:o,generateCache:function(){for(let h=0;h<65536;h++)o[h]=u(h)},generateNumber:u,genBufVariableByteInt:function(h){let f=0,g=0;const v=r.allocUnsafe(4);do f=h%128|0,(h=h/128|0)>0&&(f|=128),v.writeUInt8(f,g++);while(h>0&&g<4);return h>0&&(g=0),l?v.subarray(0,g):v.slice(0,g)},generate4ByteBuffer:function(h){const f=r.allocUnsafe(4);return f.writeUInt32BE(h,0),f}}}).call(this)}).call(this,i("buffer").Buffer)},{buffer:17}],42:[function(i,s,n){s.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,s,n){const r=i("bl"),a=i("events"),o=i("./packet"),l=i("./constants"),u=i("debug")("mqtt-packet:parser");class h extends a{constructor(){super(),this.parser=this.constructor.parser}static parser(g){return this instanceof h?(this.settings=g||{},this._states=["_parseHeader","_parseLength","_parsePayload","_newPacket"],this._resetState(),this):new h().parser(g)}_resetState(){u("_resetState: resetting packet, error, _list, and _stateCounter"),this.packet=new o,this.error=null,this._list=r(),this._stateCounter=0}parse(g){for(this.error&&this._resetState(),this._list.append(g),u("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++,u("parse: state complete. _stateCounter is now: %d",this._stateCounter),u("parse: packet.length: %d, buffer list length: %d",this.packet.length,this._list.length),this._stateCounter>=this._states.length&&(this._stateCounter=0);return u("parse: exited while loop. packet: %d, buffer list length: %d",this.packet.length,this._list.length),this._list.length}_parseHeader(){const g=this._list.readUInt8(0);return this.packet.cmd=l.types[g>>l.CMD_SHIFT],this.packet.retain=(g&l.RETAIN_MASK)!=0,this.packet.qos=g>>l.QOS_SHIFT&l.QOS_MASK,this.packet.dup=(g&l.DUP_MASK)!=0,u("_parseHeader: packet: %o",this.packet),this._list.consume(1),!0}_parseLength(){const g=this._parseVarByteNum(!0);return g&&(this.packet.length=g.value,this._list.consume(g.bytes)),u("_parseLength %d",g.value),!!g}_parsePayload(){u("_parsePayload: payload %O",this._list);let g=!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"))}g=!0}return u("_parsePayload complete result: %s",g),g}_parseConnect(){let g,v,y,w;u("_parseConnect");const p={},_=this.packet,E=this._parseString();if(E===null)return this._emitError(new Error("Cannot parse protocolId"));if(E!=="MQTT"&&E!=="MQIsdp")return this._emitError(new Error("Invalid protocolId"));if(_.protocolId=E,this._pos>=this._list.length)return this._emitError(new Error("Packet too short"));if(_.protocolVersion=this._list.readUInt8(this._pos),_.protocolVersion>=128&&(_.bridgeMode=!0,_.protocolVersion=_.protocolVersion-128),_.protocolVersion!==3&&_.protocolVersion!==4&&_.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(p.username=this._list.readUInt8(this._pos)&l.USERNAME_MASK,p.password=this._list.readUInt8(this._pos)&l.PASSWORD_MASK,p.will=this._list.readUInt8(this._pos)&l.WILL_FLAG_MASK,p.will&&(_.will={},_.will.retain=(this._list.readUInt8(this._pos)&l.WILL_RETAIN_MASK)!=0,_.will.qos=(this._list.readUInt8(this._pos)&l.WILL_QOS_MASK)>>l.WILL_QOS_SHIFT),_.clean=(this._list.readUInt8(this._pos)&l.CLEAN_SESSION_MASK)!=0,this._pos++,_.keepalive=this._parseNum(),_.keepalive===-1)return this._emitError(new Error("Packet too short"));if(_.protocolVersion===5){const C=this._parseProperties();Object.getOwnPropertyNames(C).length&&(_.properties=C)}const x=this._parseString();if(x===null)return this._emitError(new Error("Packet too short"));if(_.clientId=x,u("_parseConnect: packet.clientId: %s",_.clientId),p.will){if(_.protocolVersion===5){const C=this._parseProperties();Object.getOwnPropertyNames(C).length&&(_.will.properties=C)}if((g=this._parseString())===null)return this._emitError(new Error("Cannot parse will topic"));if(_.will.topic=g,u("_parseConnect: packet.will.topic: %s",_.will.topic),(v=this._parseBuffer())===null)return this._emitError(new Error("Cannot parse will payload"));_.will.payload=v,u("_parseConnect: packet.will.paylaod: %s",_.will.payload)}if(p.username){if((w=this._parseString())===null)return this._emitError(new Error("Cannot parse username"));_.username=w,u("_parseConnect: packet.username: %s",_.username)}if(p.password){if((y=this._parseBuffer())===null)return this._emitError(new Error("Cannot parse password"));_.password=y}return this.settings=_,u("_parseConnect: complete"),_}_parseConnack(){u("_parseConnack");const g=this.packet;if(this._list.length<1)return null;if(g.sessionPresent=!!(this._list.readUInt8(this._pos++)&l.SESSIONPRESENT_MASK),this.settings.protocolVersion===5)this._list.length>=2?g.reasonCode=this._list.readUInt8(this._pos++):g.reasonCode=0;else{if(this._list.length<2)return null;g.returnCode=this._list.readUInt8(this._pos++)}if(g.returnCode===-1||g.reasonCode===-1)return this._emitError(new Error("Cannot parse return code"));if(this.settings.protocolVersion===5){const v=this._parseProperties();Object.getOwnPropertyNames(v).length&&(g.properties=v)}u("_parseConnack: complete")}_parsePublish(){u("_parsePublish");const g=this.packet;if(g.topic=this._parseString(),g.topic===null)return this._emitError(new Error("Cannot parse topic"));if(!(g.qos>0)||this._parseMessageId()){if(this.settings.protocolVersion===5){const v=this._parseProperties();Object.getOwnPropertyNames(v).length&&(g.properties=v)}g.payload=this._list.slice(this._pos,g.length),u("_parsePublish: payload from buffer list: %o",g.payload)}}_parseSubscribe(){u("_parseSubscribe");const g=this.packet;let v,y,w,p,_,E,x;if(g.qos!==1)return this._emitError(new Error("Wrong subscribe header"));if(g.subscriptions=[],this._parseMessageId()){if(this.settings.protocolVersion===5){const C=this._parseProperties();Object.getOwnPropertyNames(C).length&&(g.properties=C)}for(;this._pos<g.length;){if((v=this._parseString())===null)return this._emitError(new Error("Cannot parse topic"));if(this._pos>=g.length)return this._emitError(new Error("Malformed Subscribe Payload"));w=(y=this._parseByte())&l.SUBSCRIBE_OPTIONS_QOS_MASK,E=(y>>l.SUBSCRIBE_OPTIONS_NL_SHIFT&l.SUBSCRIBE_OPTIONS_NL_MASK)!=0,_=(y>>l.SUBSCRIBE_OPTIONS_RAP_SHIFT&l.SUBSCRIBE_OPTIONS_RAP_MASK)!=0,p=y>>l.SUBSCRIBE_OPTIONS_RH_SHIFT&l.SUBSCRIBE_OPTIONS_RH_MASK,x={topic:v,qos:w},this.settings.protocolVersion===5?(x.nl=E,x.rap=_,x.rh=p):this.settings.bridgeMode&&(x.rh=0,x.rap=!0,x.nl=!0),u("_parseSubscribe: push subscription `%s` to subscription",x),g.subscriptions.push(x)}}}_parseSuback(){u("_parseSuback");const g=this.packet;if(this.packet.granted=[],this._parseMessageId()){if(this.settings.protocolVersion===5){const v=this._parseProperties();Object.getOwnPropertyNames(v).length&&(g.properties=v)}for(;this._pos<this.packet.length;)this.packet.granted.push(this._list.readUInt8(this._pos++))}}_parseUnsubscribe(){u("_parseUnsubscribe");const g=this.packet;if(g.unsubscriptions=[],this._parseMessageId()){if(this.settings.protocolVersion===5){const v=this._parseProperties();Object.getOwnPropertyNames(v).length&&(g.properties=v)}for(;this._pos<g.length;){const v=this._parseString();if(v===null)return this._emitError(new Error("Cannot parse topic"));u("_parseUnsubscribe: push topic `%s` to unsubscriptions",v),g.unsubscriptions.push(v)}}}_parseUnsuback(){u("_parseUnsuback");const g=this.packet;if(!this._parseMessageId())return this._emitError(new Error("Cannot parse messageId"));if(this.settings.protocolVersion===5){const v=this._parseProperties();for(Object.getOwnPropertyNames(v).length&&(g.properties=v),g.granted=[];this._pos<this.packet.length;)this.packet.granted.push(this._list.readUInt8(this._pos++))}}_parseConfirmation(){u("_parseConfirmation: packet.cmd: `%s`",this.packet.cmd);const g=this.packet;if(this._parseMessageId(),this.settings.protocolVersion===5&&(g.length>2?(g.reasonCode=this._parseByte(),u("_parseConfirmation: packet.reasonCode `%d`",g.reasonCode)):g.reasonCode=0,g.length>3)){const v=this._parseProperties();Object.getOwnPropertyNames(v).length&&(g.properties=v)}return!0}_parseDisconnect(){const g=this.packet;if(u("_parseDisconnect"),this.settings.protocolVersion===5){this._list.length>0?g.reasonCode=this._parseByte():g.reasonCode=0;const v=this._parseProperties();Object.getOwnPropertyNames(v).length&&(g.properties=v)}return u("_parseDisconnect result: true"),!0}_parseAuth(){u("_parseAuth");const g=this.packet;if(this.settings.protocolVersion!==5)return this._emitError(new Error("Not supported auth packet for this version MQTT"));g.reasonCode=this._parseByte();const v=this._parseProperties();return Object.getOwnPropertyNames(v).length&&(g.properties=v),u("_parseAuth: result: true"),!0}_parseMessageId(){const g=this.packet;return g.messageId=this._parseNum(),g.messageId===null?(this._emitError(new Error("Cannot parse messageId")),!1):(u("_parseMessageId: packet.messageId %d",g.messageId),!0)}_parseString(g){const v=this._parseNum(),y=v+this._pos;if(v===-1||y>this._list.length||y>this.packet.length)return null;const w=this._list.toString("utf8",this._pos,y);return this._pos+=v,u("_parseString: result: %s",w),w}_parseStringPair(){return u("_parseStringPair"),{name:this._parseString(),value:this._parseString()}}_parseBuffer(){const g=this._parseNum(),v=g+this._pos;if(g===-1||v>this._list.length||v>this.packet.length)return null;const y=this._list.slice(this._pos,v);return this._pos+=g,u("_parseBuffer: result: %o",y),y}_parseNum(){if(this._list.length-this._pos<2)return-1;const g=this._list.readUInt16BE(this._pos);return this._pos+=2,u("_parseNum: result: %s",g),g}_parse4ByteNum(){if(this._list.length-this._pos<4)return-1;const g=this._list.readUInt32BE(this._pos);return this._pos+=4,u("_parse4ByteNum: result: %s",g),g}_parseVarByteNum(g){u("_parseVarByteNum");let v,y=0,w=1,p=0,_=!1;const E=this._pos?this._pos:0;for(;y<4&&E+y<this._list.length;){if(p+=w*((v=this._list.readUInt8(E+y++))&l.VARBYTEINT_MASK),w*=128,(v&l.VARBYTEINT_FIN_MASK)==0){_=!0;break}if(this._list.length<=y)break}return!_&&y===4&&this._list.length>=y&&this._emitError(new Error("Invalid variable byte integer")),E&&(this._pos+=y),u("_parseVarByteNum: result: %o",_=!!_&&(g?{bytes:y,value:p}:p)),_}_parseByte(){let g;return this._pos<this._list.length&&(g=this._list.readUInt8(this._pos),this._pos++),u("_parseByte: result: %o",g),g}_parseByType(g){switch(u("_parseByType: type: %s",g),g){case"byte":return this._parseByte()!==0;case"int8":return this._parseByte();case"int16":return this._parseNum();case"int32":return this._parse4ByteNum();case"var":return this._parseVarByteNum();case"string":return this._parseString();case"pair":return this._parseStringPair();case"binary":return this._parseBuffer()}}_parseProperties(){u("_parseProperties");const g=this._parseVarByteNum(),v=this._pos+g,y={};for(;this._pos<v;){const w=this._parseByte();if(!w)return this._emitError(new Error("Cannot parse property code type")),!1;const p=l.propertiesCodes[w];if(!p)return this._emitError(new Error("Unknown property")),!1;if(p!=="userProperties")y[p]?Array.isArray(y[p])?y[p].push(this._parseByType(l.propertiesTypes[p])):(y[p]=[y[p]],y[p].push(this._parseByType(l.propertiesTypes[p]))):y[p]=this._parseByType(l.propertiesTypes[p]);else{y[p]||(y[p]=Object.create(null));const _=this._parseByType(l.propertiesTypes[p]);if(y[p][_.name])if(Array.isArray(y[p][_.name]))y[p][_.name].push(_.value);else{const E=y[p][_.name];y[p][_.name]=[E],y[p][_.name].push(_.value)}else y[p][_.name]=_.value}}return y}_newPacket(){return u("_newPacket"),this.packet&&(this._list.consume(this.packet.length),u("_newPacket: parser emit packet: packet.cmd: %s, packet.payload: %s, packet.length: %d",this.packet.cmd,this.packet.payload,this.packet.length),this.emit("packet",this.packet)),u("_newPacket: new packet"),this.packet=new o,this._pos=0,!0}_emitError(g){u("_emitError"),this.error=g,this.emit("error",g)}}s.exports=h},{"./constants":38,"./packet":42,bl:15,debug:18,events:22}],44:[function(i,s,n){(function(r){(function(){const a=i("./constants"),o=r.allocUnsafe(0),l=r.from([0]),u=i("./numbers"),h=i("process-nextick-args").nextTick,f=i("debug")("mqtt-packet:writeToStream"),g=u.cache,v=u.generateNumber,y=u.generateCache,w=u.genBufVariableByteInt,p=u.generate4ByteBuffer;let _=V,E=!0;function x($,H,j){switch(f("generate called"),H.cork&&(H.cork(),h(C,H)),E&&(E=!1,y()),f("generate: packet.cmd: %s",$.cmd),$.cmd){case"connect":return function(K,W,Q){const st=K||{},et=st.protocolId||"MQTT";let ut=st.protocolVersion||4;const ct=st.will;let ot=st.clean;const b=st.keepalive||0,k=st.clientId||"",I=st.username,F=st.password,X=st.properties;ot===void 0&&(ot=!0);let G=0;if(!et||typeof et!="string"&&!r.isBuffer(et))return W.emit("error",new Error("Invalid protocolId")),!1;if(G+=et.length+2,ut!==3&&ut!==4&&ut!==5)return W.emit("error",new Error("Invalid protocol version")),!1;if(G+=1,(typeof k=="string"||r.isBuffer(k))&&(k||ut>=4)&&(k||ot))G+=r.byteLength(k)+2;else{if(ut<4)return W.emit("error",new Error("clientId must be supplied before 3.1.1")),!1;if(1*ot==0)return W.emit("error",new Error("clientId must be given if cleanSession set to 0")),!1}if(typeof b!="number"||b<0||b>65535||b%1!=0)return W.emit("error",new Error("Invalid keepalive")),!1;if(G+=2,G+=1,ut===5){var at=R(W,X);if(!at)return!1;G+=at.length}if(ct){if(typeof ct!="object")return W.emit("error",new Error("Invalid will")),!1;if(!ct.topic||typeof ct.topic!="string")return W.emit("error",new Error("Invalid will topic")),!1;if(G+=r.byteLength(ct.topic)+2,G+=2,ct.payload){if(!(ct.payload.length>=0))return W.emit("error",new Error("Invalid will payload")),!1;typeof ct.payload=="string"?G+=r.byteLength(ct.payload):G+=ct.payload.length}var mt={};if(ut===5){if(!(mt=R(W,ct.properties)))return!1;G+=mt.length}}let yt=!1;if(I!=null){if(!rt(I))return W.emit("error",new Error("Invalid username")),!1;yt=!0,G+=r.byteLength(I)+2}if(F!=null){if(!yt)return W.emit("error",new Error("Username is required to use password")),!1;if(!rt(F))return W.emit("error",new Error("Invalid password")),!1;G+=Z(F)+2}W.write(a.CONNECT_HEADER),D(W,G),T(W,et),st.bridgeMode&&(ut+=128),W.write(ut===131?a.VERSION131:ut===132?a.VERSION132:ut===4?a.VERSION4:ut===5?a.VERSION5:a.VERSION3);let kt=0;return kt|=I!=null?a.USERNAME_MASK:0,kt|=F!=null?a.PASSWORD_MASK:0,kt|=ct&&ct.retain?a.WILL_RETAIN_MASK:0,kt|=ct&&ct.qos?ct.qos<<a.WILL_QOS_SHIFT:0,kt|=ct?a.WILL_FLAG_MASK:0,kt|=ot?a.CLEAN_SESSION_MASK:0,W.write(r.from([kt])),_(W,b),ut===5&&at.write(),T(W,k),ct&&(ut===5&&mt.write(),B(W,ct.topic),T(W,ct.payload)),I!=null&&T(W,I),F!=null&&T(W,F),!0}($,H);case"connack":return function(K,W,Q){const st=Q?Q.protocolVersion:4,et=K||{},ut=st===5?et.reasonCode:et.returnCode,ct=et.properties;let ot=2;if(typeof ut!="number")return W.emit("error",new Error("Invalid return code")),!1;let b=null;if(st===5){if(!(b=R(W,ct)))return!1;ot+=b.length}return W.write(a.CONNACK_HEADER),D(W,ot),W.write(et.sessionPresent?a.SESSIONPRESENT_HEADER:l),W.write(r.from([ut])),b!=null&&b.write(),!0}($,H,j);case"publish":return function(K,W,Q){f("publish: packet: %o",K);const st=Q?Q.protocolVersion:4,et=K||{},ut=et.qos||0,ct=et.retain?a.RETAIN_MASK:0,ot=et.topic,b=et.payload||o,k=et.messageId,I=et.properties;let F=0;if(typeof ot=="string")F+=r.byteLength(ot)+2;else{if(!r.isBuffer(ot))return W.emit("error",new Error("Invalid topic")),!1;F+=ot.length+2}if(r.isBuffer(b)?F+=b.length:F+=r.byteLength(b),ut&&typeof k!="number")return W.emit("error",new Error("Invalid messageId")),!1;ut&&(F+=2);let X=null;if(st===5){if(!(X=R(W,I)))return!1;F+=X.length}return W.write(a.PUBLISH_HEADER[ut][et.dup?1:0][ct?1:0]),D(W,F),_(W,Z(ot)),W.write(ot),ut>0&&_(W,k),X!=null&&X.write(),f("publish: payload: %o",b),W.write(b)}($,H,j);case"puback":case"pubrec":case"pubrel":case"pubcomp":return function(K,W,Q){const st=Q?Q.protocolVersion:4,et=K||{},ut=et.cmd||"puback",ct=et.messageId,ot=et.dup&&ut==="pubrel"?a.DUP_MASK:0;let b=0;const k=et.reasonCode,I=et.properties;let F=st===5?3:2;if(ut==="pubrel"&&(b=1),typeof ct!="number")return W.emit("error",new Error("Invalid messageId")),!1;let X=null;if(st===5&&typeof I=="object"){if(!(X=P(W,I,Q,F)))return!1;F+=X.length}return W.write(a.ACKS[ut][b][ot][0]),D(W,F),_(W,ct),st===5&&W.write(r.from([k])),X!==null&&X.write(),!0}($,H,j);case"subscribe":return function(K,W,Q){f("subscribe: packet: ");const st=Q?Q.protocolVersion:4,et=K||{},ut=et.dup?a.DUP_MASK:0,ct=et.messageId,ot=et.subscriptions,b=et.properties;let k=0;if(typeof ct!="number")return W.emit("error",new Error("Invalid messageId")),!1;k+=2;let I=null;if(st===5){if(!(I=R(W,b)))return!1;k+=I.length}if(typeof ot!="object"||!ot.length)return W.emit("error",new Error("Invalid subscriptions")),!1;for(let X=0;X<ot.length;X+=1){const G=ot[X].topic,at=ot[X].qos;if(typeof G!="string")return W.emit("error",new Error("Invalid subscriptions - invalid topic")),!1;if(typeof at!="number")return W.emit("error",new Error("Invalid subscriptions - invalid qos")),!1;if(st===5){if(typeof(ot[X].nl||!1)!="boolean")return W.emit("error",new Error("Invalid subscriptions - invalid No Local")),!1;if(typeof(ot[X].rap||!1)!="boolean")return W.emit("error",new Error("Invalid subscriptions - invalid Retain as Published")),!1;const kt=ot[X].rh||0;if(typeof kt!="number"||kt>2)return W.emit("error",new Error("Invalid subscriptions - invalid Retain Handling")),!1}k+=r.byteLength(G)+2+1}f("subscribe: writing to stream: %o",a.SUBSCRIBE_HEADER),W.write(a.SUBSCRIBE_HEADER[1][ut?1:0][0]),D(W,k),_(W,ct),I!==null&&I.write();let F=!0;for(const X of ot){const G=X.topic,at=X.qos,mt=+X.nl,yt=+X.rap,kt=X.rh;let Rt;B(W,G),Rt=a.SUBSCRIBE_OPTIONS_QOS[at],st===5&&(Rt|=mt?a.SUBSCRIBE_OPTIONS_NL:0,Rt|=yt?a.SUBSCRIBE_OPTIONS_RAP:0,Rt|=kt?a.SUBSCRIBE_OPTIONS_RH[kt]:0),F=W.write(r.from([Rt]))}return F}($,H,j);case"suback":return function(K,W,Q){const st=Q?Q.protocolVersion:4,et=K||{},ut=et.messageId,ct=et.granted,ot=et.properties;let b=0;if(typeof ut!="number")return W.emit("error",new Error("Invalid messageId")),!1;if(b+=2,typeof ct!="object"||!ct.length)return W.emit("error",new Error("Invalid qos vector")),!1;for(let I=0;I<ct.length;I+=1){if(typeof ct[I]!="number")return W.emit("error",new Error("Invalid qos vector")),!1;b+=1}let k=null;if(st===5){if(!(k=P(W,ot,Q,b)))return!1;b+=k.length}return W.write(a.SUBACK_HEADER),D(W,b),_(W,ut),k!==null&&k.write(),W.write(r.from(ct))}($,H,j);case"unsubscribe":return function(K,W,Q){const st=Q?Q.protocolVersion:4,et=K||{},ut=et.messageId,ct=et.dup?a.DUP_MASK:0,ot=et.unsubscriptions,b=et.properties;let k=0;if(typeof ut!="number")return W.emit("error",new Error("Invalid messageId")),!1;if(k+=2,typeof ot!="object"||!ot.length)return W.emit("error",new Error("Invalid unsubscriptions")),!1;for(let X=0;X<ot.length;X+=1){if(typeof ot[X]!="string")return W.emit("error",new Error("Invalid unsubscriptions")),!1;k+=r.byteLength(ot[X])+2}let I=null;if(st===5){if(!(I=R(W,b)))return!1;k+=I.length}W.write(a.UNSUBSCRIBE_HEADER[1][ct?1:0][0]),D(W,k),_(W,ut),I!==null&&I.write();let F=!0;for(let X=0;X<ot.length;X++)F=B(W,ot[X]);return F}($,H,j);case"unsuback":return function(K,W,Q){const st=Q?Q.protocolVersion:4,et=K||{},ut=et.messageId,ct=et.dup?a.DUP_MASK:0,ot=et.granted,b=et.properties,k=et.cmd;let I=2;if(typeof ut!="number")return W.emit("error",new Error("Invalid messageId")),!1;if(st===5){if(typeof ot!="object"||!ot.length)return W.emit("error",new Error("Invalid qos vector")),!1;for(let X=0;X<ot.length;X+=1){if(typeof ot[X]!="number")return W.emit("error",new Error("Invalid qos vector")),!1;I+=1}}let F=null;if(st===5){if(!(F=P(W,b,Q,I)))return!1;I+=F.length}return W.write(a.ACKS[k][0][ct][0]),D(W,I),_(W,ut),F!==null&&F.write(),st===5&&W.write(r.from(ot)),!0}($,H,j);case"pingreq":case"pingresp":return function(K,W,Q){return W.write(a.EMPTY[K.cmd])}($,H);case"disconnect":return function(K,W,Q){const st=Q?Q.protocolVersion:4,et=K||{},ut=et.reasonCode,ct=et.properties;let ot=st===5?1:0,b=null;if(st===5){if(!(b=P(W,ct,Q,ot)))return!1;ot+=b.length}return W.write(r.from([a.codes.disconnect<<4])),D(W,ot),st===5&&W.write(r.from([ut])),b!==null&&b.write(),!0}($,H,j);case"auth":return function(K,W,Q){const st=Q?Q.protocolVersion:4,et=K||{},ut=et.reasonCode,ct=et.properties;let ot=st===5?1:0;st!==5&&W.emit("error",new Error("Invalid mqtt version for auth packet"));const b=P(W,ct,Q,ot);return b?(ot+=b.length,W.write(r.from([a.codes.auth<<4])),D(W,ot),W.write(r.from([ut])),b!==null&&b.write(),!0):!1}($,H,j);default:return H.emit("error",new Error("Unknown command")),!1}}function C($){$.uncork()}Object.defineProperty(x,"cacheNumbers",{get:()=>_===V,set($){$?(g&&Object.keys(g).length!==0||(E=!0),_=V):(E=!1,_=tt)}});const S={};function D($,H){if(H>a.VARBYTEINT_MAX)return $.emit("error",new Error(`Invalid variable byte integer: ${H}`)),!1;let j=S[H];return j||(j=w(H),H<16384&&(S[H]=j)),f("writeVarByteInt: writing to stream: %o",j),$.write(j)}function B($,H){const j=r.byteLength(H);return _($,j),f("writeString: %s",H),$.write(H,"utf8")}function L($,H,j){B($,H),B($,j)}function V($,H){return f("writeNumberCached: number: %d",H),f("writeNumberCached: %o",g[H]),$.write(g[H])}function tt($,H){const j=v(H);return f("writeNumberGenerated: %o",j),$.write(j)}function T($,H){typeof H=="string"?B($,H):H?(_($,H.length),$.write(H)):_($,0)}function R($,H){if(typeof H!="object"||H.length!=null)return{length:1,write(){Y($,{},0)}};let j=0;function K(W,Q){let st=0;switch(a.propertiesTypes[W]){case"byte":if(typeof Q!="boolean")return $.emit("error",new Error(`Invalid ${W}: ${Q}`)),!1;st+=2;break;case"int8":if(typeof Q!="number"||Q<0||Q>255)return $.emit("error",new Error(`Invalid ${W}: ${Q}`)),!1;st+=2;break;case"binary":if(Q&&Q===null)return $.emit("error",new Error(`Invalid ${W}: ${Q}`)),!1;st+=1+r.byteLength(Q)+2;break;case"int16":if(typeof Q!="number"||Q<0||Q>65535)return $.emit("error",new Error(`Invalid ${W}: ${Q}`)),!1;st+=3;break;case"int32":if(typeof Q!="number"||Q<0||Q>4294967295)return $.emit("error",new Error(`Invalid ${W}: ${Q}`)),!1;st+=5;break;case"var":if(typeof Q!="number"||Q<0||Q>268435455)return $.emit("error",new Error(`Invalid ${W}: ${Q}`)),!1;st+=1+r.byteLength(w(Q));break;case"string":if(typeof Q!="string")return $.emit("error",new Error(`Invalid ${W}: ${Q}`)),!1;st+=3+r.byteLength(Q.toString());break;case"pair":if(typeof Q!="object")return $.emit("error",new Error(`Invalid ${W}: ${Q}`)),!1;st+=Object.getOwnPropertyNames(Q).reduce((et,ut)=>{const ct=Q[ut];return Array.isArray(ct)?et+=ct.reduce((ot,b)=>ot+=3+r.byteLength(ut.toString())+2+r.byteLength(b.toString()),0):et+=3+r.byteLength(ut.toString())+2+r.byteLength(Q[ut].toString()),et},0);break;default:return $.emit("error",new Error(`Invalid property ${W}: ${Q}`)),!1}return st}if(H)for(const W in H){let Q=0,st=0;const et=H[W];if(Array.isArray(et))for(let ut=0;ut<et.length;ut++){if(!(st=K(W,et[ut])))return!1;Q+=st}else{if(!(st=K(W,et)))return!1;Q=st}if(!Q)return!1;j+=Q}return{length:r.byteLength(w(j))+j,write(){Y($,H,j)}}}function P($,H,j,K){const W=["reasonString","userProperties"],Q=j&&j.properties&&j.properties.maximumPacketSize?j.properties.maximumPacketSize:0;let st=R($,H);if(Q)for(;K+st.length>Q;){const et=W.shift();if(!et||!H[et])return!1;delete H[et],st=R($,H)}return st}function O($,H,j){switch(a.propertiesTypes[H]){case"byte":$.write(r.from([a.properties[H]])),$.write(r.from([+j]));break;case"int8":$.write(r.from([a.properties[H]])),$.write(r.from([j]));break;case"binary":$.write(r.from([a.properties[H]])),T($,j);break;case"int16":$.write(r.from([a.properties[H]])),_($,j);break;case"int32":$.write(r.from([a.properties[H]])),function(K,W){const Q=p(W);f("write4ByteNumber: %o",Q),K.write(Q)}($,j);break;case"var":$.write(r.from([a.properties[H]])),D($,j);break;case"string":$.write(r.from([a.properties[H]])),B($,j);break;case"pair":Object.getOwnPropertyNames(j).forEach(K=>{const W=j[K];Array.isArray(W)?W.forEach(Q=>{$.write(r.from([a.properties[H]])),L($,K.toString(),Q.toString())}):($.write(r.from([a.properties[H]])),L($,K.toString(),W.toString()))});break;default:return $.emit("error",new Error(`Invalid property ${H} value: ${j}`)),!1}}function Y($,H,j){D($,j);for(const K in H)if(Object.prototype.hasOwnProperty.call(H,K)&&H[K]!==null){const W=H[K];if(Array.isArray(W))for(let Q=0;Q<W.length;Q++)O($,K,W[Q]);else O($,K,W)}}function Z($){return $?$ instanceof r?$.length:r.byteLength($):0}function rt($){return typeof $=="string"||$ instanceof r}s.exports=x}).call(this)}).call(this,i("buffer").Buffer)},{"./constants":38,"./numbers":41,buffer:17,debug:18,"process-nextick-args":49}],45:[function(i,s,n){var r=1e3,a=60*r,o=60*a,l=24*o,u=7*l,h=365.25*l;function f(g,v,y,w){var p=v>=1.5*y;return Math.round(g/y)+" "+w+(p?"s":"")}s.exports=function(g,v){v=v||{};var y=typeof g;if(y==="string"&&g.length>0)return function(w){if(!((w=String(w)).length>100)){var p=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(w);if(!!p){var _=parseFloat(p[1]);switch((p[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return _*h;case"weeks":case"week":case"w":return _*u;case"days":case"day":case"d":return _*l;case"hours":case"hour":case"hrs":case"hr":case"h":return _*o;case"minutes":case"minute":case"mins":case"min":case"m":return _*a;case"seconds":case"second":case"secs":case"sec":case"s":return _*r;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return _;default:return}}}}(g);if(y==="number"&&isFinite(g))return v.long?function(w){var p=Math.abs(w);return p>=l?f(w,p,l,"day"):p>=o?f(w,p,o,"hour"):p>=a?f(w,p,a,"minute"):p>=r?f(w,p,r,"second"):w+" ms"}(g):function(w){var p=Math.abs(w);return p>=l?Math.round(w/l)+"d":p>=o?Math.round(w/o)+"h":p>=a?Math.round(w/a)+"m":p>=r?Math.round(w/r)+"s":w+"ms"}(g);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(g))}},{}],46:[function(i,s,n){const r=i("./lib/number-allocator.js");s.exports.NumberAllocator=r},{"./lib/number-allocator.js":47}],47:[function(i,s,n){const r=i("js-sdsl").Set,a=i("debug")("number-allocator:trace"),o=i("debug")("number-allocator:error");function l(h,f){this.low=h,this.high=f}function u(h,f){if(!(this instanceof u))return new u(h,f);this.min=h,this.max=f,this.ss=new r([],(g,v)=>g.compare(v)),a("Create"),this.clear()}l.prototype.equals=function(h){return this.low===h.low&&this.high===h.high},l.prototype.compare=function(h){return this.low<h.low&&this.high<h.low?-1:h.low<this.low&&h.high<this.low?1:0},u.prototype.firstVacant=function(){return this.ss.size()===0?null:this.ss.front().low},u.prototype.alloc=function(){if(this.ss.size()===0)return a("alloc():empty"),null;const h=this.ss.front(),f=h.low;return f+1<=h.high?++h.low:this.ss.eraseElementByPos(0),a("alloc():"+f),f},u.prototype.use=function(h){const f=new l(h,h),g=this.ss.lowerBound(f);if(g){if(g.equals(f))return this.ss.eraseElementByValue(g),a("use():"+h),!0;if(g.low>h)return!1;if(g.low===h)return++g.low,a("use():"+h),!0;if(g.high===h)return--g.high,a("use():"+h),!0;const v=g.low;return g.low=h+1,this.ss.insert(new l(v,h-1)),a("use():"+h),!0}return a("use():failed"),!1},u.prototype.free=function(h){if(h<this.min||h>this.max)return void o("free():"+h+" is out of range");const f=new l(h,h),g=this.ss.lowerBound(f);if(g){if(g.low<=h&&h<=g.high)return void o("free():"+h+" has already been vacant");if(g===this.ss.front())h+1===g.low?--g.low:this.ss.insert(f);else{const v=this.ss.reverseLowerBound(f);v.high+1===h?h+1===g.low?(this.ss.eraseElementByValue(v),g.low=v.low):v.high=h:h+1===g.low?g.low=h:this.ss.insert(f)}}else{if(g===this.ss.front())return void this.ss.insert(f);const v=this.ss.reverseLowerBound(f);v.high+1===h?v.high=h:this.ss.insert(f)}a("free():"+h)},u.prototype.clear=function(){a("clear()"),this.ss.clear(),this.ss.insert(new l(this.min,this.max))},u.prototype.intervalCount=function(){return this.ss.size()},u.prototype.dump=function(){console.log("length:"+this.ss.size());for(const h of this.ss)console.log(h)},s.exports=u},{debug:18,"js-sdsl":36}],48:[function(i,s,n){var r=i("wrappy");function a(l){var u=function(){return u.called?u.value:(u.called=!0,u.value=l.apply(this,arguments))};return u.called=!1,u}function o(l){var u=function(){if(u.called)throw new Error(u.onceError);return u.called=!0,u.value=l.apply(this,arguments)},h=l.name||"Function wrapped with `once`";return u.onceError=h+" shouldn't be called more than once",u.called=!1,u}s.exports=r(a),s.exports.strict=r(o),a.proto=a(function(){Object.defineProperty(Function.prototype,"once",{value:function(){return a(this)},configurable:!0}),Object.defineProperty(Function.prototype,"onceStrict",{value:function(){return o(this)},configurable:!0})})},{wrappy:79}],49:[function(i,s,n){(function(r){(function(){r===void 0||!r.version||r.version.indexOf("v0.")===0||r.version.indexOf("v1.")===0&&r.version.indexOf("v1.8.")!==0?s.exports={nextTick:function(a,o,l,u){if(typeof a!="function")throw new TypeError('"callback" argument must be a function');var h,f,g=arguments.length;switch(g){case 0:case 1:return r.nextTick(a);case 2:return r.nextTick(function(){a.call(null,o)});case 3:return r.nextTick(function(){a.call(null,o,l)});case 4:return r.nextTick(function(){a.call(null,o,l,u)});default:for(h=new Array(g-1),f=0;f<h.length;)h[f++]=arguments[f];return r.nextTick(function(){a.apply(null,h)})}}}:s.exports=r}).call(this)}).call(this,i("_process"))},{_process:50}],50:[function(i,s,n){var r,a,o=s.exports={};function l(){throw new Error("setTimeout has not been defined")}function u(){throw new Error("clearTimeout has not been defined")}function h(x){if(r===setTimeout)return setTimeout(x,0);if((r===l||!r)&&setTimeout)return r=setTimeout,setTimeout(x,0);try{return r(x,0)}catch{try{return r.call(null,x,0)}catch{return r.call(this,x,0)}}}(function(){try{r=typeof setTimeout=="function"?setTimeout:l}catch{r=l}try{a=typeof clearTimeout=="function"?clearTimeout:u}catch{a=u}})();var f,g=[],v=!1,y=-1;function w(){v&&f&&(v=!1,f.length?g=f.concat(g):y=-1,g.length&&p())}function p(){if(!v){var x=h(w);v=!0;for(var C=g.length;C;){for(f=g,g=[];++y<C;)f&&f[y].run();y=-1,C=g.length}f=null,v=!1,function(S){if(a===clearTimeout)return clearTimeout(S);if((a===u||!a)&&clearTimeout)return a=clearTimeout,clearTimeout(S);try{a(S)}catch{try{return a.call(null,S)}catch{return a.call(this,S)}}}(x)}}function _(x,C){this.fun=x,this.array=C}function E(){}o.nextTick=function(x){var C=new Array(arguments.length-1);if(arguments.length>1)for(var S=1;S<arguments.length;S++)C[S-1]=arguments[S];g.push(new _(x,C)),g.length!==1||v||h(p)},_.prototype.run=function(){this.fun.apply(null,this.array)},o.title="browser",o.browser=!0,o.env={},o.argv=[],o.version="",o.versions={},o.on=E,o.addListener=E,o.once=E,o.off=E,o.removeListener=E,o.removeAllListeners=E,o.emit=E,o.prependListener=E,o.prependOnceListener=E,o.listeners=function(x){return[]},o.binding=function(x){throw new Error("process.binding is not supported")},o.cwd=function(){return"/"},o.chdir=function(x){throw new Error("process.chdir is not supported")},o.umask=function(){return 0}},{}],51:[function(i,s,n){(function(r){(function(){(function(a){var o=typeof n=="object"&&n&&!n.nodeType&&n,l=typeof s=="object"&&s&&!s.nodeType&&s,u=typeof r=="object"&&r;u.global!==u&&u.window!==u&&u.self!==u||(a=u);var h,f,g=2147483647,v=36,y=1,w=26,p=38,_=700,E=72,x=128,C="-",S=/^xn--/,D=/[^\x20-\x7E]/,B=/[\x2E\u3002\uFF0E\uFF61]/g,L={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},V=v-y,tt=Math.floor,T=String.fromCharCode;function R(K){throw new RangeError(L[K])}function P(K,W){for(var Q=K.length,st=[];Q--;)st[Q]=W(K[Q]);return st}function O(K,W){var Q=K.split("@"),st="";return Q.length>1&&(st=Q[0]+"@",K=Q[1]),st+P((K=K.replace(B,".")).split("."),W).join(".")}function Y(K){for(var W,Q,st=[],et=0,ut=K.length;et<ut;)(W=K.charCodeAt(et++))>=55296&&W<=56319&&et<ut?(64512&(Q=K.charCodeAt(et++)))==56320?st.push(((1023&W)<<10)+(1023&Q)+65536):(st.push(W),et--):st.push(W);return st}function Z(K){return P(K,function(W){var Q="";return W>65535&&(Q+=T((W-=65536)>>>10&1023|55296),W=56320|1023&W),Q+=T(W)}).join("")}function rt(K,W){return K+22+75*(K<26)-((W!=0)<<5)}function $(K,W,Q){var st=0;for(K=Q?tt(K/_):K>>1,K+=tt(K/W);K>V*w>>1;st+=v)K=tt(K/V);return tt(st+(V+1)*K/(K+p))}function H(K){var W,Q,st,et,ut,ct,ot,b,k,I,F,X=[],G=K.length,at=0,mt=x,yt=E;for((Q=K.lastIndexOf(C))<0&&(Q=0),st=0;st<Q;++st)K.charCodeAt(st)>=128&&R("not-basic"),X.push(K.charCodeAt(st));for(et=Q>0?Q+1:0;et<G;){for(ut=at,ct=1,ot=v;et>=G&&R("invalid-input"),((b=(F=K.charCodeAt(et++))-48<10?F-22:F-65<26?F-65:F-97<26?F-97:v)>=v||b>tt((g-at)/ct))&&R("overflow"),at+=b*ct,!(b<(k=ot<=yt?y:ot>=yt+w?w:ot-yt));ot+=v)ct>tt(g/(I=v-k))&&R("overflow"),ct*=I;yt=$(at-ut,W=X.length+1,ut==0),tt(at/W)>g-mt&&R("overflow"),mt+=tt(at/W),at%=W,X.splice(at++,0,mt)}return Z(X)}function j(K){var W,Q,st,et,ut,ct,ot,b,k,I,F,X,G,at,mt,yt=[];for(X=(K=Y(K)).length,W=x,Q=0,ut=E,ct=0;ct<X;++ct)(F=K[ct])<128&&yt.push(T(F));for(st=et=yt.length,et&&yt.push(C);st<X;){for(ot=g,ct=0;ct<X;++ct)(F=K[ct])>=W&&F<ot&&(ot=F);for(ot-W>tt((g-Q)/(G=st+1))&&R("overflow"),Q+=(ot-W)*G,W=ot,ct=0;ct<X;++ct)if((F=K[ct])<W&&++Q>g&&R("overflow"),F==W){for(b=Q,k=v;!(b<(I=k<=ut?y:k>=ut+w?w:k-ut));k+=v)mt=b-I,at=v-I,yt.push(T(rt(I+mt%at,0))),b=tt(mt/at);yt.push(T(rt(b,0))),ut=$(Q,G,st==et),Q=0,++st}++Q,++W}return yt.join("")}if(h={version:"1.4.1",ucs2:{decode:Y,encode:Z},decode:H,encode:j,toASCII:function(K){return O(K,function(W){return D.test(W)?"xn--"+j(W):W})},toUnicode:function(K){return O(K,function(W){return S.test(W)?H(W.slice(4).toLowerCase()):W})}},o&&l)if(s.exports==o)l.exports=h;else for(f in h)h.hasOwnProperty(f)&&(o[f]=h[f]);else a.punycode=h})(this)}).call(this)}).call(this,typeof De<"u"?De:typeof self<"u"?self:typeof window<"u"?window:{})},{}],52:[function(i,s,n){function r(o,l){return Object.prototype.hasOwnProperty.call(o,l)}s.exports=function(o,l,u,h){l=l||"&",u=u||"=";var f={};if(typeof o!="string"||o.length===0)return f;var g=/\+/g;o=o.split(l);var v=1e3;h&&typeof h.maxKeys=="number"&&(v=h.maxKeys);var y=o.length;v>0&&y>v&&(y=v);for(var w=0;w<y;++w){var p,_,E,x,C=o[w].replace(g,"%20"),S=C.indexOf(u);S>=0?(p=C.substr(0,S),_=C.substr(S+1)):(p=C,_=""),E=decodeURIComponent(p),x=decodeURIComponent(_),r(f,E)?a(f[E])?f[E].push(x):f[E]=[f[E],x]:f[E]=x}return f};var a=Array.isArray||function(o){return Object.prototype.toString.call(o)==="[object Array]"}},{}],53:[function(i,s,n){var r=function(u){switch(typeof u){case"string":return u;case"boolean":return u?"true":"false";case"number":return isFinite(u)?u:"";default:return""}};s.exports=function(u,h,f,g){return h=h||"&",f=f||"=",u===null&&(u=void 0),typeof u=="object"?o(l(u),function(v){var y=encodeURIComponent(r(v))+f;return a(u[v])?o(u[v],function(w){return y+encodeURIComponent(r(w))}).join(h):y+encodeURIComponent(r(u[v]))}).join(h):g?encodeURIComponent(r(g))+f+encodeURIComponent(r(u)):""};var a=Array.isArray||function(u){return Object.prototype.toString.call(u)==="[object Array]"};function o(u,h){if(u.map)return u.map(h);for(var f=[],g=0;g<u.length;g++)f.push(h(u[g],g));return f}var l=Object.keys||function(u){var h=[];for(var f in u)Object.prototype.hasOwnProperty.call(u,f)&&h.push(f);return h}},{}],54:[function(i,s,n){n.decode=n.parse=i("./decode"),n.encode=n.stringify=i("./encode")},{"./decode":52,"./encode":53}],55:[function(i,s,n){var r={};function a(l,u,h){h||(h=Error);var f=function(g){var v,y;function w(p,_,E){return g.call(this,function(x,C,S){return typeof u=="string"?u:u(x,C,S)}(p,_,E))||this}return y=g,(v=w).prototype=Object.create(y.prototype),v.prototype.constructor=v,v.__proto__=y,w}(h);f.prototype.name=h.name,f.prototype.code=l,r[l]=f}function o(l,u){if(Array.isArray(l)){var h=l.length;return l=l.map(function(f){return String(f)}),h>2?"one of ".concat(u," ").concat(l.slice(0,h-1).join(", "),", or ")+l[h-1]:h===2?"one of ".concat(u," ").concat(l[0]," or ").concat(l[1]):"of ".concat(u," ").concat(l[0])}return"of ".concat(u," ").concat(String(l))}a("ERR_INVALID_OPT_VALUE",function(l,u){return'The value "'+u+'" is invalid for option "'+l+'"'},TypeError),a("ERR_INVALID_ARG_TYPE",function(l,u,h){var f,g,v;if(typeof u=="string"&&(g="not ",u.substr(0,g.length)===g)?(f="must not be",u=u.replace(/^not /,"")):f="must be",function(w,p,_){return(_===void 0||_>w.length)&&(_=w.length),w.substring(_-p.length,_)===p}(l," argument"))v="The ".concat(l," ").concat(f," ").concat(o(u,"type"));else{var y=function(w,p,_){return typeof _!="number"&&(_=0),!(_+p.length>w.length)&&w.indexOf(p,_)!==-1}(l,".")?"property":"argument";v='The "'.concat(l,'" ').concat(y," ").concat(f," ").concat(o(u,"type"))}return v+=". Received type ".concat(typeof h)},TypeError),a("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),a("ERR_METHOD_NOT_IMPLEMENTED",function(l){return"The "+l+" method is not implemented"}),a("ERR_STREAM_PREMATURE_CLOSE","Premature close"),a("ERR_STREAM_DESTROYED",function(l){return"Cannot call "+l+" after a stream was destroyed"}),a("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),a("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),a("ERR_STREAM_WRITE_AFTER_END","write after end"),a("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),a("ERR_UNKNOWN_ENCODING",function(l){return"Unknown encoding: "+l},TypeError),a("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),s.exports.codes=r},{}],56:[function(i,s,n){(function(r){(function(){var a=Object.keys||function(w){var p=[];for(var _ in w)p.push(_);return p};s.exports=g;var o=i("./_stream_readable"),l=i("./_stream_writable");i("inherits")(g,o);for(var u=a(l.prototype),h=0;h<u.length;h++){var f=u[h];g.prototype[f]||(g.prototype[f]=l.prototype[f])}function g(w){if(!(this instanceof g))return new g(w);o.call(this,w),l.call(this,w),this.allowHalfOpen=!0,w&&(w.readable===!1&&(this.readable=!1),w.writable===!1&&(this.writable=!1),w.allowHalfOpen===!1&&(this.allowHalfOpen=!1,this.once("end",v)))}function v(){this._writableState.ended||r.nextTick(y,this)}function y(w){w.end()}Object.defineProperty(g.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(g.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(g.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(g.prototype,"destroyed",{enumerable:!1,get:function(){return this._readableState!==void 0&&this._writableState!==void 0&&this._readableState.destroyed&&this._writableState.destroyed},set:function(w){this._readableState!==void 0&&this._writableState!==void 0&&(this._readableState.destroyed=w,this._writableState.destroyed=w)}})}).call(this)}).call(this,i("_process"))},{"./_stream_readable":58,"./_stream_writable":60,_process:50,inherits:24}],57:[function(i,s,n){s.exports=a;var r=i("./_stream_transform");function a(o){if(!(this instanceof a))return new a(o);r.call(this,o)}i("inherits")(a,r),a.prototype._transform=function(o,l,u){u(null,o)}},{"./_stream_transform":59,inherits:24}],58:[function(i,s,n){(function(r,a){(function(){var o;s.exports=R,R.ReadableState=T,i("events").EventEmitter;var l=function(b,k){return b.listeners(k).length},u=i("./internal/streams/stream"),h=i("buffer").Buffer,f=a.Uint8Array||function(){},g,v=i("util");g=v&&v.debuglog?v.debuglog("stream"):function(){};var y,w,p,_=i("./internal/streams/buffer_list"),E=i("./internal/streams/destroy"),x=i("./internal/streams/state").getHighWaterMark,C=i("../errors").codes,S=C.ERR_INVALID_ARG_TYPE,D=C.ERR_STREAM_PUSH_AFTER_EOF,B=C.ERR_METHOD_NOT_IMPLEMENTED,L=C.ERR_STREAM_UNSHIFT_AFTER_END_EVENT;i("inherits")(R,u);var V=E.errorOrDestroy,tt=["error","close","destroy","pause","resume"];function T(b,k,I){o=o||i("./_stream_duplex"),b=b||{},typeof I!="boolean"&&(I=k instanceof o),this.objectMode=!!b.objectMode,I&&(this.objectMode=this.objectMode||!!b.readableObjectMode),this.highWaterMark=x(this,b,"readableHighWaterMark",I),this.buffer=new _,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.paused=!0,this.emitClose=b.emitClose!==!1,this.autoDestroy=!!b.autoDestroy,this.destroyed=!1,this.defaultEncoding=b.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,b.encoding&&(y||(y=i("string_decoder/").StringDecoder),this.decoder=new y(b.encoding),this.encoding=b.encoding)}function R(b){if(o=o||i("./_stream_duplex"),!(this instanceof R))return new R(b);var k=this instanceof o;this._readableState=new T(b,this,k),this.readable=!0,b&&(typeof b.read=="function"&&(this._read=b.read),typeof b.destroy=="function"&&(this._destroy=b.destroy)),u.call(this)}function P(b,k,I,F,X){g("readableAddChunk",k);var G,at=b._readableState;if(k===null)at.reading=!1,function(mt,yt){if(g("onEofChunk"),!yt.ended){if(yt.decoder){var kt=yt.decoder.end();kt&&kt.length&&(yt.buffer.push(kt),yt.length+=yt.objectMode?1:kt.length)}yt.ended=!0,yt.sync?rt(mt):(yt.needReadable=!1,yt.emittedReadable||(yt.emittedReadable=!0,$(mt)))}}(b,at);else if(X||(G=function(mt,yt){var kt;Rt=yt,h.isBuffer(Rt)||Rt instanceof f||typeof yt=="string"||yt===void 0||mt.objectMode||(kt=new S("chunk",["string","Buffer","Uint8Array"],yt));var Rt;return kt}(at,k)),G)V(b,G);else if(at.objectMode||k&&k.length>0)if(typeof k=="string"||at.objectMode||Object.getPrototypeOf(k)===h.prototype||(k=function(mt){return h.from(mt)}(k)),F)at.endEmitted?V(b,new L):O(b,at,k,!0);else if(at.ended)V(b,new D);else{if(at.destroyed)return!1;at.reading=!1,at.decoder&&!I?(k=at.decoder.write(k),at.objectMode||k.length!==0?O(b,at,k,!1):H(b,at)):O(b,at,k,!1)}else F||(at.reading=!1,H(b,at));return!at.ended&&(at.length<at.highWaterMark||at.length===0)}function O(b,k,I,F){k.flowing&&k.length===0&&!k.sync?(k.awaitDrain=0,b.emit("data",I)):(k.length+=k.objectMode?1:I.length,F?k.buffer.unshift(I):k.buffer.push(I),k.needReadable&&rt(b)),H(b,k)}Object.defineProperty(R.prototype,"destroyed",{enumerable:!1,get:function(){return this._readableState!==void 0&&this._readableState.destroyed},set:function(b){this._readableState&&(this._readableState.destroyed=b)}}),R.prototype.destroy=E.destroy,R.prototype._undestroy=E.undestroy,R.prototype._destroy=function(b,k){k(b)},R.prototype.push=function(b,k){var I,F=this._readableState;return F.objectMode?I=!0:typeof b=="string"&&((k=k||F.defaultEncoding)!==F.encoding&&(b=h.from(b,k),k=""),I=!0),P(this,b,k,!1,I)},R.prototype.unshift=function(b){return P(this,b,null,!0,!1)},R.prototype.isPaused=function(){return this._readableState.flowing===!1},R.prototype.setEncoding=function(b){y||(y=i("string_decoder/").StringDecoder);var k=new y(b);this._readableState.decoder=k,this._readableState.encoding=this._readableState.decoder.encoding;for(var I=this._readableState.buffer.head,F="";I!==null;)F+=k.write(I.data),I=I.next;return this._readableState.buffer.clear(),F!==""&&this._readableState.buffer.push(F),this._readableState.length=F.length,this};var Y=1073741824;function Z(b,k){return b<=0||k.length===0&&k.ended?0:k.objectMode?1:b!=b?k.flowing&&k.length?k.buffer.head.data.length:k.length:(b>k.highWaterMark&&(k.highWaterMark=function(I){return I>=Y?I=Y:(I--,I|=I>>>1,I|=I>>>2,I|=I>>>4,I|=I>>>8,I|=I>>>16,I++),I}(b)),b<=k.length?b:k.ended?k.length:(k.needReadable=!0,0))}function rt(b){var k=b._readableState;g("emitReadable",k.needReadable,k.emittedReadable),k.needReadable=!1,k.emittedReadable||(g("emitReadable",k.flowing),k.emittedReadable=!0,r.nextTick($,b))}function $(b){var k=b._readableState;g("emitReadable_",k.destroyed,k.length,k.ended),k.destroyed||!k.length&&!k.ended||(b.emit("readable"),k.emittedReadable=!1),k.needReadable=!k.flowing&&!k.ended&&k.length<=k.highWaterMark,st(b)}function H(b,k){k.readingMore||(k.readingMore=!0,r.nextTick(j,b,k))}function j(b,k){for(;!k.reading&&!k.ended&&(k.length<k.highWaterMark||k.flowing&&k.length===0);){var I=k.length;if(g("maybeReadMore read 0"),b.read(0),I===k.length)break}k.readingMore=!1}function K(b){var k=b._readableState;k.readableListening=b.listenerCount("readable")>0,k.resumeScheduled&&!k.paused?k.flowing=!0:b.listenerCount("data")>0&&b.resume()}function W(b){g("readable nexttick read 0"),b.read(0)}function Q(b,k){g("resume",k.reading),k.reading||b.read(0),k.resumeScheduled=!1,b.emit("resume"),st(b),k.flowing&&!k.reading&&b.read(0)}function st(b){var k=b._readableState;for(g("flow",k.flowing);k.flowing&&b.read()!==null;);}function et(b,k){return k.length===0?null:(k.objectMode?I=k.buffer.shift():!b||b>=k.length?(I=k.decoder?k.buffer.join(""):k.buffer.length===1?k.buffer.first():k.buffer.concat(k.length),k.buffer.clear()):I=k.buffer.consume(b,k.decoder),I);var I}function ut(b){var k=b._readableState;g("endReadable",k.endEmitted),k.endEmitted||(k.ended=!0,r.nextTick(ct,k,b))}function ct(b,k){if(g("endReadableNT",b.endEmitted,b.length),!b.endEmitted&&b.length===0&&(b.endEmitted=!0,k.readable=!1,k.emit("end"),b.autoDestroy)){var I=k._writableState;(!I||I.autoDestroy&&I.finished)&&k.destroy()}}function ot(b,k){for(var I=0,F=b.length;I<F;I++)if(b[I]===k)return I;return-1}R.prototype.read=function(b){g("read",b),b=parseInt(b,10);var k=this._readableState,I=b;if(b!==0&&(k.emittedReadable=!1),b===0&&k.needReadable&&((k.highWaterMark!==0?k.length>=k.highWaterMark:k.length>0)||k.ended))return g("read: emitReadable",k.length,k.ended),k.length===0&&k.ended?ut(this):rt(this),null;if((b=Z(b,k))===0&&k.ended)return k.length===0&&ut(this),null;var F,X=k.needReadable;return g("need readable",X),(k.length===0||k.length-b<k.highWaterMark)&&g("length less than watermark",X=!0),k.ended||k.reading?g("reading or ended",X=!1):X&&(g("do read"),k.reading=!0,k.sync=!0,k.length===0&&(k.needReadable=!0),this._read(k.highWaterMark),k.sync=!1,k.reading||(b=Z(I,k))),(F=b>0?et(b,k):null)===null?(k.needReadable=k.length<=k.highWaterMark,b=0):(k.length-=b,k.awaitDrain=0),k.length===0&&(k.ended||(k.needReadable=!0),I!==b&&k.ended&&ut(this)),F!==null&&this.emit("data",F),F},R.prototype._read=function(b){V(this,new B("_read()"))},R.prototype.pipe=function(b,k){var I=this,F=this._readableState;switch(F.pipesCount){case 0:F.pipes=b;break;case 1:F.pipes=[F.pipes,b];break;default:F.pipes.push(b)}F.pipesCount+=1,g("pipe count=%d opts=%j",F.pipesCount,k);var X=(!k||k.end!==!1)&&b!==r.stdout&&b!==r.stderr?at:xe;function G($t,Qt){g("onunpipe"),$t===I&&Qt&&Qt.hasUnpiped===!1&&(Qt.hasUnpiped=!0,g("cleanup"),b.removeListener("close",be),b.removeListener("finish",se),b.removeListener("drain",mt),b.removeListener("error",Rt),b.removeListener("unpipe",G),I.removeListener("end",at),I.removeListener("end",xe),I.removeListener("data",kt),yt=!0,!F.awaitDrain||b._writableState&&!b._writableState.needDrain||mt())}function at(){g("onend"),b.end()}F.endEmitted?r.nextTick(X):I.once("end",X),b.on("unpipe",G);var mt=function($t){return function(){var Qt=$t._readableState;g("pipeOnDrain",Qt.awaitDrain),Qt.awaitDrain&&Qt.awaitDrain--,Qt.awaitDrain===0&&l($t,"data")&&(Qt.flowing=!0,st($t))}}(I);b.on("drain",mt);var yt=!1;function kt($t){g("ondata");var Qt=b.write($t);g("dest.write",Qt),Qt===!1&&((F.pipesCount===1&&F.pipes===b||F.pipesCount>1&&ot(F.pipes,b)!==-1)&&!yt&&(g("false write response, pause",F.awaitDrain),F.awaitDrain++),I.pause())}function Rt($t){g("onerror",$t),xe(),b.removeListener("error",Rt),l(b,"error")===0&&V(b,$t)}function be(){b.removeListener("finish",se),xe()}function se(){g("onfinish"),b.removeListener("close",be),xe()}function xe(){g("unpipe"),I.unpipe(b)}return I.on("data",kt),function($t,Qt,xi){if(typeof $t.prependListener=="function")return $t.prependListener(Qt,xi);$t._events&&$t._events[Qt]?Array.isArray($t._events[Qt])?$t._events[Qt].unshift(xi):$t._events[Qt]=[xi,$t._events[Qt]]:$t.on(Qt,xi)}(b,"error",Rt),b.once("close",be),b.once("finish",se),b.emit("pipe",I),F.flowing||(g("pipe resume"),I.resume()),b},R.prototype.unpipe=function(b){var k=this._readableState,I={hasUnpiped:!1};if(k.pipesCount===0)return this;if(k.pipesCount===1)return b&&b!==k.pipes?this:(b||(b=k.pipes),k.pipes=null,k.pipesCount=0,k.flowing=!1,b&&b.emit("unpipe",this,I),this);if(!b){var F=k.pipes,X=k.pipesCount;k.pipes=null,k.pipesCount=0,k.flowing=!1;for(var G=0;G<X;G++)F[G].emit("unpipe",this,{hasUnpiped:!1});return this}var at=ot(k.pipes,b);return at===-1?this:(k.pipes.splice(at,1),k.pipesCount-=1,k.pipesCount===1&&(k.pipes=k.pipes[0]),b.emit("unpipe",this,I),this)},R.prototype.on=function(b,k){var I=u.prototype.on.call(this,b,k),F=this._readableState;return b==="data"?(F.readableListening=this.listenerCount("readable")>0,F.flowing!==!1&&this.resume()):b==="readable"&&(F.endEmitted||F.readableListening||(F.readableListening=F.needReadable=!0,F.flowing=!1,F.emittedReadable=!1,g("on readable",F.length,F.reading),F.length?rt(this):F.reading||r.nextTick(W,this))),I},R.prototype.addListener=R.prototype.on,R.prototype.removeListener=function(b,k){var I=u.prototype.removeListener.call(this,b,k);return b==="readable"&&r.nextTick(K,this),I},R.prototype.removeAllListeners=function(b){var k=u.prototype.removeAllListeners.apply(this,arguments);return b!=="readable"&&b!==void 0||r.nextTick(K,this),k},R.prototype.resume=function(){var b=this._readableState;return b.flowing||(g("resume"),b.flowing=!b.readableListening,function(k,I){I.resumeScheduled||(I.resumeScheduled=!0,r.nextTick(Q,k,I))}(this,b)),b.paused=!1,this},R.prototype.pause=function(){return g("call pause flowing=%j",this._readableState.flowing),this._readableState.flowing!==!1&&(g("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this},R.prototype.wrap=function(b){var k=this,I=this._readableState,F=!1;for(var X in b.on("end",function(){if(g("wrapped end"),I.decoder&&!I.ended){var at=I.decoder.end();at&&at.length&&k.push(at)}k.push(null)}),b.on("data",function(at){g("wrapped data"),I.decoder&&(at=I.decoder.write(at)),(!I.objectMode||at!=null)&&(I.objectMode||at&&at.length)&&(k.push(at)||(F=!0,b.pause()))}),b)this[X]===void 0&&typeof b[X]=="function"&&(this[X]=function(at){return function(){return b[at].apply(b,arguments)}}(X));for(var G=0;G<tt.length;G++)b.on(tt[G],this.emit.bind(this,tt[G]));return this._read=function(at){g("wrapped _read",at),F&&(F=!1,b.resume())},this},typeof Symbol=="function"&&(R.prototype[Symbol.asyncIterator]=function(){return w===void 0&&(w=i("./internal/streams/async_iterator")),w(this)}),Object.defineProperty(R.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),Object.defineProperty(R.prototype,"readableBuffer",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}}),Object.defineProperty(R.prototype,"readableFlowing",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(b){this._readableState&&(this._readableState.flowing=b)}}),R._fromList=et,Object.defineProperty(R.prototype,"readableLength",{enumerable:!1,get:function(){return this._readableState.length}}),typeof Symbol=="function"&&(R.from=function(b,k){return p===void 0&&(p=i("./internal/streams/from")),p(R,b,k)})}).call(this)}).call(this,i("_process"),typeof De<"u"?De:typeof self<"u"?self:typeof window<"u"?window:{})},{"../errors":55,"./_stream_duplex":56,"./internal/streams/async_iterator":61,"./internal/streams/buffer_list":62,"./internal/streams/destroy":63,"./internal/streams/from":65,"./internal/streams/state":67,"./internal/streams/stream":68,_process:50,buffer:17,events:22,inherits:24,"string_decoder/":75,util:16}],59:[function(i,s,n){s.exports=f;var r=i("../errors").codes,a=r.ERR_METHOD_NOT_IMPLEMENTED,o=r.ERR_MULTIPLE_CALLBACK,l=r.ERR_TRANSFORM_ALREADY_TRANSFORMING,u=r.ERR_TRANSFORM_WITH_LENGTH_0,h=i("./_stream_duplex");function f(y){if(!(this instanceof f))return new f(y);h.call(this,y),this._transformState={afterTransform:function(w,p){var _=this._transformState;_.transforming=!1;var E=_.writecb;if(E===null)return this.emit("error",new o);_.writechunk=null,_.writecb=null,p!=null&&this.push(p),E(w);var x=this._readableState;x.reading=!1,(x.needReadable||x.length<x.highWaterMark)&&this._read(x.highWaterMark)}.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,y&&(typeof y.transform=="function"&&(this._transform=y.transform),typeof y.flush=="function"&&(this._flush=y.flush)),this.on("prefinish",g)}function g(){var y=this;typeof this._flush!="function"||this._readableState.destroyed?v(this,null,null):this._flush(function(w,p){v(y,w,p)})}function v(y,w,p){if(w)return y.emit("error",w);if(p!=null&&y.push(p),y._writableState.length)throw new u;if(y._transformState.transforming)throw new l;return y.push(null)}i("inherits")(f,h),f.prototype.push=function(y,w){return this._transformState.needTransform=!1,h.prototype.push.call(this,y,w)},f.prototype._transform=function(y,w,p){p(new a("_transform()"))},f.prototype._write=function(y,w,p){var _=this._transformState;if(_.writecb=p,_.writechunk=y,_.writeencoding=w,!_.transforming){var E=this._readableState;(_.needTransform||E.needReadable||E.length<E.highWaterMark)&&this._read(E.highWaterMark)}},f.prototype._read=function(y){var w=this._transformState;w.writechunk===null||w.transforming?w.needTransform=!0:(w.transforming=!0,this._transform(w.writechunk,w.writeencoding,w.afterTransform))},f.prototype._destroy=function(y,w){h.prototype._destroy.call(this,y,function(p){w(p)})}},{"../errors":55,"./_stream_duplex":56,inherits:24}],60:[function(i,s,n){(function(r,a){(function(){function o(H){var j=this;this.next=null,this.entry=null,this.finish=function(){(function(K,W,Q){var st=K.entry;for(K.entry=null;st;){var et=st.callback;W.pendingcb--,et(Q),st=st.next}W.corkedRequestsFree.next=K})(j,H)}}var l;s.exports=R,R.WritableState=T;var u={deprecate:i("util-deprecate")},h=i("./internal/streams/stream"),f=i("buffer").Buffer,g=a.Uint8Array||function(){},v,y=i("./internal/streams/destroy"),w=i("./internal/streams/state").getHighWaterMark,p=i("../errors").codes,_=p.ERR_INVALID_ARG_TYPE,E=p.ERR_METHOD_NOT_IMPLEMENTED,x=p.ERR_MULTIPLE_CALLBACK,C=p.ERR_STREAM_CANNOT_PIPE,S=p.ERR_STREAM_DESTROYED,D=p.ERR_STREAM_NULL_VALUES,B=p.ERR_STREAM_WRITE_AFTER_END,L=p.ERR_UNKNOWN_ENCODING,V=y.errorOrDestroy;function tt(){}function T(H,j,K){l=l||i("./_stream_duplex"),H=H||{},typeof K!="boolean"&&(K=j instanceof l),this.objectMode=!!H.objectMode,K&&(this.objectMode=this.objectMode||!!H.writableObjectMode),this.highWaterMark=w(this,H,"writableHighWaterMark",K),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var W=H.decodeStrings===!1;this.decodeStrings=!W,this.defaultEncoding=H.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(Q){(function(st,et){var ut=st._writableState,ct=ut.sync,ot=ut.writecb;if(typeof ot!="function")throw new x;if(function(k){k.writing=!1,k.writecb=null,k.length-=k.writelen,k.writelen=0}(ut),et)(function(k,I,F,X,G){--I.pendingcb,F?(r.nextTick(G,X),r.nextTick($,k,I),k._writableState.errorEmitted=!0,V(k,X)):(G(X),k._writableState.errorEmitted=!0,V(k,X),$(k,I))})(st,ut,ct,et,ot);else{var b=Z(ut)||st.destroyed;b||ut.corked||ut.bufferProcessing||!ut.bufferedRequest||Y(st,ut),ct?r.nextTick(O,st,ut,b,ot):O(st,ut,b,ot)}})(j,Q)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=H.emitClose!==!1,this.autoDestroy=!!H.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new o(this)}function R(H){var j=this instanceof(l=l||i("./_stream_duplex"));if(!j&&!v.call(R,this))return new R(H);this._writableState=new T(H,this,j),this.writable=!0,H&&(typeof H.write=="function"&&(this._write=H.write),typeof H.writev=="function"&&(this._writev=H.writev),typeof H.destroy=="function"&&(this._destroy=H.destroy),typeof H.final=="function"&&(this._final=H.final)),h.call(this)}function P(H,j,K,W,Q,st,et){j.writelen=W,j.writecb=et,j.writing=!0,j.sync=!0,j.destroyed?j.onwrite(new S("write")):K?H._writev(Q,j.onwrite):H._write(Q,st,j.onwrite),j.sync=!1}function O(H,j,K,W){K||function(Q,st){st.length===0&&st.needDrain&&(st.needDrain=!1,Q.emit("drain"))}(H,j),j.pendingcb--,W(),$(H,j)}function Y(H,j){j.bufferProcessing=!0;var K=j.bufferedRequest;if(H._writev&&K&&K.next){var W=j.bufferedRequestCount,Q=new Array(W),st=j.corkedRequestsFree;st.entry=K;for(var et=0,ut=!0;K;)Q[et]=K,K.isBuf||(ut=!1),K=K.next,et+=1;Q.allBuffers=ut,P(H,j,!0,j.length,Q,"",st.finish),j.pendingcb++,j.lastBufferedRequest=null,st.next?(j.corkedRequestsFree=st.next,st.next=null):j.corkedRequestsFree=new o(j),j.bufferedRequestCount=0}else{for(;K;){var ct=K.chunk,ot=K.encoding,b=K.callback;if(P(H,j,!1,j.objectMode?1:ct.length,ct,ot,b),K=K.next,j.bufferedRequestCount--,j.writing)break}K===null&&(j.lastBufferedRequest=null)}j.bufferedRequest=K,j.bufferProcessing=!1}function Z(H){return H.ending&&H.length===0&&H.bufferedRequest===null&&!H.finished&&!H.writing}function rt(H,j){H._final(function(K){j.pendingcb--,K&&V(H,K),j.prefinished=!0,H.emit("prefinish"),$(H,j)})}function $(H,j){var K=Z(j);if(K&&(function(Q,st){st.prefinished||st.finalCalled||(typeof Q._final!="function"||st.destroyed?(st.prefinished=!0,Q.emit("prefinish")):(st.pendingcb++,st.finalCalled=!0,r.nextTick(rt,Q,st)))}(H,j),j.pendingcb===0&&(j.finished=!0,H.emit("finish"),j.autoDestroy))){var W=H._readableState;(!W||W.autoDestroy&&W.endEmitted)&&H.destroy()}return K}i("inherits")(R,h),T.prototype.getBuffer=function(){for(var H=this.bufferedRequest,j=[];H;)j.push(H),H=H.next;return j},function(){try{Object.defineProperty(T.prototype,"buffer",{get:u.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch{}}(),typeof Symbol=="function"&&Symbol.hasInstance&&typeof Function.prototype[Symbol.hasInstance]=="function"?(v=Function.prototype[Symbol.hasInstance],Object.defineProperty(R,Symbol.hasInstance,{value:function(H){return!!v.call(this,H)||this===R&&H&&H._writableState instanceof T}})):v=function(H){return H instanceof this},R.prototype.pipe=function(){V(this,new C)},R.prototype.write=function(H,j,K){var W,Q=this._writableState,st=!1,et=!Q.objectMode&&(W=H,f.isBuffer(W)||W instanceof g);return et&&!f.isBuffer(H)&&(H=function(ut){return f.from(ut)}(H)),typeof j=="function"&&(K=j,j=null),et?j="buffer":j||(j=Q.defaultEncoding),typeof K!="function"&&(K=tt),Q.ending?function(ut,ct){var ot=new B;V(ut,ot),r.nextTick(ct,ot)}(this,K):(et||function(ut,ct,ot,b){var k;return ot===null?k=new D:typeof ot=="string"||ct.objectMode||(k=new _("chunk",["string","Buffer"],ot)),!k||(V(ut,k),r.nextTick(b,k),!1)}(this,Q,H,K))&&(Q.pendingcb++,st=function(ut,ct,ot,b,k,I){if(!ot){var F=function(mt,yt,kt){return mt.objectMode||mt.decodeStrings===!1||typeof yt!="string"||(yt=f.from(yt,kt)),yt}(ct,b,k);b!==F&&(ot=!0,k="buffer",b=F)}var X=ct.objectMode?1:b.length;ct.length+=X;var G=ct.length<ct.highWaterMark;if(G||(ct.needDrain=!0),ct.writing||ct.corked){var at=ct.lastBufferedRequest;ct.lastBufferedRequest={chunk:b,encoding:k,isBuf:ot,callback:I,next:null},at?at.next=ct.lastBufferedRequest:ct.bufferedRequest=ct.lastBufferedRequest,ct.bufferedRequestCount+=1}else P(ut,ct,!1,X,b,k,I);return G}(this,Q,et,H,j,K)),st},R.prototype.cork=function(){this._writableState.corked++},R.prototype.uncork=function(){var H=this._writableState;H.corked&&(H.corked--,H.writing||H.corked||H.bufferProcessing||!H.bufferedRequest||Y(this,H))},R.prototype.setDefaultEncoding=function(H){if(typeof H=="string"&&(H=H.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((H+"").toLowerCase())>-1))throw new L(H);return this._writableState.defaultEncoding=H,this},Object.defineProperty(R.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(R.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),R.prototype._write=function(H,j,K){K(new E("_write()"))},R.prototype._writev=null,R.prototype.end=function(H,j,K){var W=this._writableState;return typeof H=="function"?(K=H,H=null,j=null):typeof j=="function"&&(K=j,j=null),H!=null&&this.write(H,j),W.corked&&(W.corked=1,this.uncork()),W.ending||function(Q,st,et){st.ending=!0,$(Q,st),et&&(st.finished?r.nextTick(et):Q.once("finish",et)),st.ended=!0,Q.writable=!1}(this,W,K),this},Object.defineProperty(R.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(R.prototype,"destroyed",{enumerable:!1,get:function(){return this._writableState!==void 0&&this._writableState.destroyed},set:function(H){this._writableState&&(this._writableState.destroyed=H)}}),R.prototype.destroy=y.destroy,R.prototype._undestroy=y.undestroy,R.prototype._destroy=function(H,j){j(H)}}).call(this)}).call(this,i("_process"),typeof De<"u"?De: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,s,n){(function(r){(function(){var a;function o(C,S,D){return S in C?Object.defineProperty(C,S,{value:D,enumerable:!0,configurable:!0,writable:!0}):C[S]=D,C}var l=i("./end-of-stream"),u=Symbol("lastResolve"),h=Symbol("lastReject"),f=Symbol("error"),g=Symbol("ended"),v=Symbol("lastPromise"),y=Symbol("handlePromise"),w=Symbol("stream");function p(C,S){return{value:C,done:S}}function _(C){var S=C[u];if(S!==null){var D=C[w].read();D!==null&&(C[v]=null,C[u]=null,C[h]=null,S(p(D,!1)))}}var E=Object.getPrototypeOf(function(){}),x=Object.setPrototypeOf((o(a={get stream(){return this[w]},next:function(){var C=this,S=this[f];if(S!==null)return Promise.reject(S);if(this[g])return Promise.resolve(p(void 0,!0));if(this[w].destroyed)return new Promise(function(V,tt){r.nextTick(function(){C[f]?tt(C[f]):V(p(void 0,!0))})});var D,B=this[v];if(B)D=new Promise(function(V,tt){return function(T,R){V.then(function(){tt[g]?T(p(void 0,!0)):tt[y](T,R)},R)}}(B,this));else{var L=this[w].read();if(L!==null)return Promise.resolve(p(L,!1));D=new Promise(this[y])}return this[v]=D,D}},Symbol.asyncIterator,function(){return this}),o(a,"return",function(){var C=this;return new Promise(function(S,D){C[w].destroy(null,function(B){B?D(B):S(p(void 0,!0))})})}),a),E);s.exports=function(C){var S,D=Object.create(x,(o(S={},w,{value:C,writable:!0}),o(S,u,{value:null,writable:!0}),o(S,h,{value:null,writable:!0}),o(S,f,{value:null,writable:!0}),o(S,g,{value:C._readableState.endEmitted,writable:!0}),o(S,y,{value:function(B,L){var V=D[w].read();V?(D[v]=null,D[u]=null,D[h]=null,B(p(V,!1))):(D[u]=B,D[h]=L)},writable:!0}),S));return D[v]=null,l(C,function(B){if(B&&B.code!=="ERR_STREAM_PREMATURE_CLOSE"){var L=D[h];return L!==null&&(D[v]=null,D[u]=null,D[h]=null,L(B)),void(D[f]=B)}var V=D[u];V!==null&&(D[v]=null,D[u]=null,D[h]=null,V(p(void 0,!0))),D[g]=!0}),C.on("readable",function(B){r.nextTick(_,B)}.bind(null,D)),D}}).call(this)}).call(this,i("_process"))},{"./end-of-stream":64,_process:50}],62:[function(i,s,n){function r(f,g){var v=Object.keys(f);if(Object.getOwnPropertySymbols){var y=Object.getOwnPropertySymbols(f);g&&(y=y.filter(function(w){return Object.getOwnPropertyDescriptor(f,w).enumerable})),v.push.apply(v,y)}return v}function a(f,g,v){return g in f?Object.defineProperty(f,g,{value:v,enumerable:!0,configurable:!0,writable:!0}):f[g]=v,f}function o(f,g){for(var v=0;v<g.length;v++){var y=g[v];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(f,y.key,y)}}var l=i("buffer").Buffer,u=i("util").inspect,h=u&&u.custom||"inspect";s.exports=function(){function f(){(function(y,w){if(!(y instanceof w))throw new TypeError("Cannot call a class as a function")})(this,f),this.head=null,this.tail=null,this.length=0}var g,v;return g=f,(v=[{key:"push",value:function(y){var w={data:y,next:null};this.length>0?this.tail.next=w:this.head=w,this.tail=w,++this.length}},{key:"unshift",value:function(y){var w={data:y,next:this.head};this.length===0&&(this.tail=w),this.head=w,++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 w=this.head,p=""+w.data;w=w.next;)p+=y+w.data;return p}},{key:"concat",value:function(y){if(this.length===0)return l.alloc(0);for(var w,p,_,E=l.allocUnsafe(y>>>0),x=this.head,C=0;x;)w=x.data,p=E,_=C,l.prototype.copy.call(w,p,_),C+=x.data.length,x=x.next;return E}},{key:"consume",value:function(y,w){var p;return y<this.head.data.length?(p=this.head.data.slice(0,y),this.head.data=this.head.data.slice(y)):p=y===this.head.data.length?this.shift():w?this._getString(y):this._getBuffer(y),p}},{key:"first",value:function(){return this.head.data}},{key:"_getString",value:function(y){var w=this.head,p=1,_=w.data;for(y-=_.length;w=w.next;){var E=w.data,x=y>E.length?E.length:y;if(x===E.length?_+=E:_+=E.slice(0,y),(y-=x)===0){x===E.length?(++p,w.next?this.head=w.next:this.head=this.tail=null):(this.head=w,w.data=E.slice(x));break}++p}return this.length-=p,_}},{key:"_getBuffer",value:function(y){var w=l.allocUnsafe(y),p=this.head,_=1;for(p.data.copy(w),y-=p.data.length;p=p.next;){var E=p.data,x=y>E.length?E.length:y;if(E.copy(w,w.length-y,0,x),(y-=x)===0){x===E.length?(++_,p.next?this.head=p.next:this.head=this.tail=null):(this.head=p,p.data=E.slice(x));break}++_}return this.length-=_,w}},{key:h,value:function(y,w){return u(this,function(p){for(var _=1;_<arguments.length;_++){var E=arguments[_]!=null?arguments[_]:{};_%2?r(Object(E),!0).forEach(function(x){a(p,x,E[x])}):Object.getOwnPropertyDescriptors?Object.defineProperties(p,Object.getOwnPropertyDescriptors(E)):r(Object(E)).forEach(function(x){Object.defineProperty(p,x,Object.getOwnPropertyDescriptor(E,x))})}return p}({},w,{depth:0,customInspect:!1}))}}])&&o(g.prototype,v),f}()},{buffer:17,util:16}],63:[function(i,s,n){(function(r){(function(){function a(u,h){l(u,h),o(u)}function o(u){u._writableState&&!u._writableState.emitClose||u._readableState&&!u._readableState.emitClose||u.emit("close")}function l(u,h){u.emit("error",h)}s.exports={destroy:function(u,h){var f=this,g=this._readableState&&this._readableState.destroyed,v=this._writableState&&this._writableState.destroyed;return g||v?(h?h(u):u&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,r.nextTick(l,this,u)):r.nextTick(l,this,u)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(u||null,function(y){!h&&y?f._writableState?f._writableState.errorEmitted?r.nextTick(o,f):(f._writableState.errorEmitted=!0,r.nextTick(a,f,y)):r.nextTick(a,f,y):h?(r.nextTick(o,f),h(y)):r.nextTick(o,f)}),this)},undestroy:function(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)},errorOrDestroy:function(u,h){var f=u._readableState,g=u._writableState;f&&f.autoDestroy||g&&g.autoDestroy?u.destroy(h):u.emit("error",h)}}}).call(this)}).call(this,i("_process"))},{_process:50}],64:[function(i,s,n){var r=i("../../../errors").codes.ERR_STREAM_PREMATURE_CLOSE;function a(){}s.exports=function o(l,u,h){if(typeof u=="function")return o(l,null,u);u||(u={}),h=function(S){var D=!1;return function(){if(!D){D=!0;for(var B=arguments.length,L=new Array(B),V=0;V<B;V++)L[V]=arguments[V];S.apply(this,L)}}}(h||a);var f=u.readable||u.readable!==!1&&l.readable,g=u.writable||u.writable!==!1&&l.writable,v=function(){l.writable||w()},y=l._writableState&&l._writableState.finished,w=function(){g=!1,y=!0,f||h.call(l)},p=l._readableState&&l._readableState.endEmitted,_=function(){f=!1,p=!0,g||h.call(l)},E=function(S){h.call(l,S)},x=function(){var S;return f&&!p?(l._readableState&&l._readableState.ended||(S=new r),h.call(l,S)):g&&!y?(l._writableState&&l._writableState.ended||(S=new r),h.call(l,S)):void 0},C=function(){l.req.on("finish",w)};return function(S){return S.setHeader&&typeof S.abort=="function"}(l)?(l.on("complete",w),l.on("abort",x),l.req?C():l.on("request",C)):g&&!l._writableState&&(l.on("end",v),l.on("close",v)),l.on("end",_),l.on("finish",w),u.error!==!1&&l.on("error",E),l.on("close",x),function(){l.removeListener("complete",w),l.removeListener("abort",x),l.removeListener("request",C),l.req&&l.req.removeListener("finish",w),l.removeListener("end",v),l.removeListener("close",v),l.removeListener("finish",w),l.removeListener("end",_),l.removeListener("error",E),l.removeListener("close",x)}}},{"../../../errors":55}],65:[function(i,s,n){s.exports=function(){throw new Error("Readable.from is not available in the browser")}},{}],66:[function(i,s,n){var r,a=i("../../../errors").codes,o=a.ERR_MISSING_ARGS,l=a.ERR_STREAM_DESTROYED;function u(g){if(g)throw g}function h(g){g()}function f(g,v){return g.pipe(v)}s.exports=function(){for(var g=arguments.length,v=new Array(g),y=0;y<g;y++)v[y]=arguments[y];var w,p=function(E){return E.length?typeof E[E.length-1]!="function"?u:E.pop():u}(v);if(Array.isArray(v[0])&&(v=v[0]),v.length<2)throw new o("streams");var _=v.map(function(E,x){var C=x<v.length-1;return function(S,D,B,L){L=function(T){var R=!1;return function(){R||(R=!0,T.apply(void 0,arguments))}}(L);var V=!1;S.on("close",function(){V=!0}),r===void 0&&(r=i("./end-of-stream")),r(S,{readable:D,writable:B},function(T){if(T)return L(T);V=!0,L()});var tt=!1;return function(T){if(!V&&!tt)return tt=!0,function(R){return R.setHeader&&typeof R.abort=="function"}(S)?S.abort():typeof S.destroy=="function"?S.destroy():void L(T||new l("pipe"))}}(E,C,x>0,function(S){w||(w=S),S&&_.forEach(h),C||(_.forEach(h),p(w))})});return v.reduce(f)}},{"../../../errors":55,"./end-of-stream":64}],67:[function(i,s,n){var r=i("../../../errors").codes.ERR_INVALID_OPT_VALUE;s.exports={getHighWaterMark:function(a,o,l,u){var h=function(f,g,v){return f.highWaterMark!=null?f.highWaterMark:g?f[v]:null}(o,u,l);if(h!=null){if(!isFinite(h)||Math.floor(h)!==h||h<0)throw new r(u?l:"highWaterMark",h);return Math.floor(h)}return a.objectMode?16:16384}}},{"../../../errors":55}],68:[function(i,s,n){s.exports=i("events").EventEmitter},{events:22}],69:[function(i,s,n){(n=s.exports=i("./lib/_stream_readable.js")).Stream=n,n.Readable=n,n.Writable=i("./lib/_stream_writable.js"),n.Duplex=i("./lib/_stream_duplex.js"),n.Transform=i("./lib/_stream_transform.js"),n.PassThrough=i("./lib/_stream_passthrough.js"),n.finished=i("./lib/internal/streams/end-of-stream.js"),n.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,s,n){s.exports=function(){if(typeof arguments[0]!="function")throw new Error("callback needed");if(typeof arguments[1]!="number")throw new Error("interval needed");var r;if(arguments.length>0){r=new Array(arguments.length-2);for(var a=0;a<r.length;a++)r[a]=arguments[a+2]}return new function(o,l,u){var h=this;this._callback=o,this._args=u,this._interval=setInterval(o,l,this._args),this.reschedule=function(f){f||(f=h._interval),h._interval&&clearInterval(h._interval),h._interval=setInterval(h._callback,f,h._args)},this.clear=function(){h._interval&&(clearInterval(h._interval),h._interval=void 0)},this.destroy=function(){h._interval&&clearInterval(h._interval),h._callback=void 0,h._interval=void 0,h._args=void 0}}(arguments[0],arguments[1],r)}},{}],71:[function(i,s,n){s.exports=i("./index.js")()},{"./index.js":72}],72:[function(i,s,n){(function(r){(function(){function a(o){return o instanceof r?r.from(o):new o.constructor(o.buffer.slice(),o.byteOffset,o.length)}s.exports=function(o){return(o=o||{}).circles?function(u){var h=[],f=[];return u.proto?function v(y){if(typeof y!="object"||y===null)return y;if(y instanceof Date)return new Date(y);if(Array.isArray(y))return g(y,v);if(y instanceof Map)return new Map(g(Array.from(y),v));if(y instanceof Set)return new Set(g(Array.from(y),v));var w={};for(var p in h.push(y),f.push(w),y){var _=y[p];if(typeof _!="object"||_===null)w[p]=_;else if(_ instanceof Date)w[p]=new Date(_);else if(_ instanceof Map)w[p]=new Map(g(Array.from(_),v));else if(_ instanceof Set)w[p]=new Set(g(Array.from(_),v));else if(ArrayBuffer.isView(_))w[p]=a(_);else{var E=h.indexOf(_);w[p]=E!==-1?f[E]:v(_)}}return h.pop(),f.pop(),w}:function v(y){if(typeof y!="object"||y===null)return y;if(y instanceof Date)return new Date(y);if(Array.isArray(y))return g(y,v);if(y instanceof Map)return new Map(g(Array.from(y),v));if(y instanceof Set)return new Set(g(Array.from(y),v));var w={};for(var p in h.push(y),f.push(w),y)if(Object.hasOwnProperty.call(y,p)!==!1){var _=y[p];if(typeof _!="object"||_===null)w[p]=_;else if(_ instanceof Date)w[p]=new Date(_);else if(_ instanceof Map)w[p]=new Map(g(Array.from(_),v));else if(_ instanceof Set)w[p]=new Set(g(Array.from(_),v));else if(ArrayBuffer.isView(_))w[p]=a(_);else{var E=h.indexOf(_);w[p]=E!==-1?f[E]:v(_)}}return h.pop(),f.pop(),w};function g(v,y){for(var w=Object.keys(v),p=new Array(w.length),_=0;_<w.length;_++){var E=w[_],x=v[E];if(typeof x!="object"||x===null)p[E]=x;else if(x instanceof Date)p[E]=new Date(x);else if(ArrayBuffer.isView(x))p[E]=a(x);else{var C=h.indexOf(x);p[E]=C!==-1?f[C]:y(x)}}return p}}(o):o.proto?function u(h){if(typeof h!="object"||h===null)return h;if(h instanceof Date)return new Date(h);if(Array.isArray(h))return l(h,u);if(h instanceof Map)return new Map(l(Array.from(h),u));if(h instanceof Set)return new Set(l(Array.from(h),u));var f={};for(var g in h){var v=h[g];typeof v!="object"||v===null?f[g]=v:v instanceof Date?f[g]=new Date(v):v instanceof Map?f[g]=new Map(l(Array.from(v),u)):v instanceof Set?f[g]=new Set(l(Array.from(v),u)):ArrayBuffer.isView(v)?f[g]=a(v):f[g]=u(v)}return f}:function u(h){if(typeof h!="object"||h===null)return h;if(h instanceof Date)return new Date(h);if(Array.isArray(h))return l(h,u);if(h instanceof Map)return new Map(l(Array.from(h),u));if(h instanceof Set)return new Set(l(Array.from(h),u));var f={};for(var g in h)if(Object.hasOwnProperty.call(h,g)!==!1){var v=h[g];typeof v!="object"||v===null?f[g]=v:v instanceof Date?f[g]=new Date(v):v instanceof Map?f[g]=new Map(l(Array.from(v),u)):v instanceof Set?f[g]=new Set(l(Array.from(v),u)):ArrayBuffer.isView(v)?f[g]=a(v):f[g]=u(v)}return f};function l(u,h){for(var f=Object.keys(u),g=new Array(f.length),v=0;v<f.length;v++){var y=f[v],w=u[y];typeof w!="object"||w===null?g[y]=w:w instanceof Date?g[y]=new Date(w):ArrayBuffer.isView(w)?g[y]=a(w):g[y]=h(w)}return g}}}).call(this)}).call(this,i("buffer").Buffer)},{buffer:17}],73:[function(i,s,n){var r=i("buffer"),a=r.Buffer;function o(u,h){for(var f in u)h[f]=u[f]}function l(u,h,f){return a(u,h,f)}a.from&&a.alloc&&a.allocUnsafe&&a.allocUnsafeSlow?s.exports=r:(o(r,n),n.Buffer=l),l.prototype=Object.create(a.prototype),o(a,l),l.from=function(u,h,f){if(typeof u=="number")throw new TypeError("Argument must not be a number");return a(u,h,f)},l.alloc=function(u,h,f){if(typeof u!="number")throw new TypeError("Argument must be a number");var g=a(u);return h!==void 0?typeof f=="string"?g.fill(h,f):g.fill(h):g.fill(0),g},l.allocUnsafe=function(u){if(typeof u!="number")throw new TypeError("Argument must be a number");return a(u)},l.allocUnsafeSlow=function(u){if(typeof u!="number")throw new TypeError("Argument must be a number");return r.SlowBuffer(u)}},{buffer:17}],74:[function(i,s,n){s.exports=function(r){var a=r._readableState;return a?a.objectMode||typeof r._duplexState=="number"?r.read():r.read((o=a,o.buffer.length?o.buffer.head?o.buffer.head.data.length:o.buffer[0].length:o.length)):null;var o}},{}],75:[function(i,s,n){var r=i("safe-buffer").Buffer,a=r.isEncoding||function(p){switch((p=""+p)&&p.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function o(p){var _;switch(this.encoding=function(E){var x=function(C){if(!C)return"utf8";for(var S;;)switch(C){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return C;default:if(S)return;C=(""+C).toLowerCase(),S=!0}}(E);if(typeof x!="string"&&(r.isEncoding===a||!a(E)))throw new Error("Unknown encoding: "+E);return x||E}(p),this.encoding){case"utf16le":this.text=h,this.end=f,_=4;break;case"utf8":this.fillLast=u,_=4;break;case"base64":this.text=g,this.end=v,_=3;break;default:return this.write=y,void(this.end=w)}this.lastNeed=0,this.lastTotal=0,this.lastChar=r.allocUnsafe(_)}function l(p){return p<=127?0:p>>5==6?2:p>>4==14?3:p>>3==30?4:p>>6==2?-1:-2}function u(p){var _=this.lastTotal-this.lastNeed,E=function(x,C,S){if((192&C[0])!=128)return x.lastNeed=0,"\uFFFD";if(x.lastNeed>1&&C.length>1){if((192&C[1])!=128)return x.lastNeed=1,"\uFFFD";if(x.lastNeed>2&&C.length>2&&(192&C[2])!=128)return x.lastNeed=2,"\uFFFD"}}(this,p);return E!==void 0?E:this.lastNeed<=p.length?(p.copy(this.lastChar,_,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(p.copy(this.lastChar,_,0,p.length),void(this.lastNeed-=p.length))}function h(p,_){if((p.length-_)%2==0){var E=p.toString("utf16le",_);if(E){var x=E.charCodeAt(E.length-1);if(x>=55296&&x<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=p[p.length-2],this.lastChar[1]=p[p.length-1],E.slice(0,-1)}return E}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=p[p.length-1],p.toString("utf16le",_,p.length-1)}function f(p){var _=p&&p.length?this.write(p):"";if(this.lastNeed){var E=this.lastTotal-this.lastNeed;return _+this.lastChar.toString("utf16le",0,E)}return _}function g(p,_){var E=(p.length-_)%3;return E===0?p.toString("base64",_):(this.lastNeed=3-E,this.lastTotal=3,E===1?this.lastChar[0]=p[p.length-1]:(this.lastChar[0]=p[p.length-2],this.lastChar[1]=p[p.length-1]),p.toString("base64",_,p.length-E))}function v(p){var _=p&&p.length?this.write(p):"";return this.lastNeed?_+this.lastChar.toString("base64",0,3-this.lastNeed):_}function y(p){return p.toString(this.encoding)}function w(p){return p&&p.length?this.write(p):""}n.StringDecoder=o,o.prototype.write=function(p){if(p.length===0)return"";var _,E;if(this.lastNeed){if((_=this.fillLast(p))===void 0)return"";E=this.lastNeed,this.lastNeed=0}else E=0;return E<p.length?_?_+this.text(p,E):this.text(p,E):_||""},o.prototype.end=function(p){var _=p&&p.length?this.write(p):"";return this.lastNeed?_+"\uFFFD":_},o.prototype.text=function(p,_){var E=function(C,S,D){var B=S.length-1;if(B<D)return 0;var L=l(S[B]);return L>=0?(L>0&&(C.lastNeed=L-1),L):--B<D||L===-2?0:(L=l(S[B]))>=0?(L>0&&(C.lastNeed=L-2),L):--B<D||L===-2?0:(L=l(S[B]))>=0?(L>0&&(L===2?L=0:C.lastNeed=L-3),L):0}(this,p,_);if(!this.lastNeed)return p.toString("utf8",_);this.lastTotal=E;var x=p.length-(E-this.lastNeed);return p.copy(this.lastChar,0,x),p.toString("utf8",_,x)},o.prototype.fillLast=function(p){if(this.lastNeed<=p.length)return p.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);p.copy(this.lastChar,this.lastTotal-this.lastNeed,0,p.length),this.lastNeed-=p.length}},{"safe-buffer":73}],76:[function(i,s,n){var r=i("punycode"),a=i("./util");function o(){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}n.parse=S,n.resolve=function(D,B){return S(D,!1,!0).resolve(B)},n.resolveObject=function(D,B){return D?S(D,!1,!0).resolveObject(B):B},n.format=function(D){return a.isString(D)&&(D=S(D)),D instanceof o?D.format():o.prototype.format.call(D)},n.Url=o;var l=/^([a-z0-9.+-]+:)/i,u=/:[0-9]*$/,h=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,f=["{","}","|","\\","^","`"].concat(["<",">",'"',"`"," ","\r",`
- `," "]),g=["'"].concat(f),v=["%","/","?",";","#"].concat(g),y=["/","?","#"],w=/^[+a-z0-9A-Z_-]{0,63}$/,p=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,_={javascript:!0,"javascript:":!0},E={javascript:!0,"javascript:":!0},x={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},C=i("querystring");function S(D,B,L){if(D&&a.isObject(D)&&D instanceof o)return D;var V=new o;return V.parse(D,B,L),V}o.prototype.parse=function(D,B,L){if(!a.isString(D))throw new TypeError("Parameter 'url' must be a string, not "+typeof D);var V=D.indexOf("?"),tt=V!==-1&&V<D.indexOf("#")?"?":"#",T=D.split(tt);T[0]=T[0].replace(/\\/g,"/");var R=D=T.join(tt);if(R=R.trim(),!L&&D.split("#").length===1){var P=h.exec(R);if(P)return this.path=R,this.href=R,this.pathname=P[1],P[2]?(this.search=P[2],this.query=B?C.parse(this.search.substr(1)):this.search.substr(1)):B&&(this.search="",this.query={}),this}var O=l.exec(R);if(O){var Y=(O=O[0]).toLowerCase();this.protocol=Y,R=R.substr(O.length)}if(L||O||R.match(/^\/\/[^@\/]+@[^@\/]+/)){var Z=R.substr(0,2)==="//";!Z||O&&E[O]||(R=R.substr(2),this.slashes=!0)}if(!E[O]&&(Z||O&&!x[O])){for(var rt,$,H=-1,j=0;j<y.length;j++)(K=R.indexOf(y[j]))!==-1&&(H===-1||K<H)&&(H=K);for(($=H===-1?R.lastIndexOf("@"):R.lastIndexOf("@",H))!==-1&&(rt=R.slice(0,$),R=R.slice($+1),this.auth=decodeURIComponent(rt)),H=-1,j=0;j<v.length;j++){var K;(K=R.indexOf(v[j]))!==-1&&(H===-1||K<H)&&(H=K)}H===-1&&(H=R.length),this.host=R.slice(0,H),R=R.slice(H),this.parseHost(),this.hostname=this.hostname||"";var W=this.hostname[0]==="["&&this.hostname[this.hostname.length-1]==="]";if(!W)for(var Q=this.hostname.split(/\./),st=(j=0,Q.length);j<st;j++){var et=Q[j];if(et&&!et.match(w)){for(var ut="",ct=0,ot=et.length;ct<ot;ct++)et.charCodeAt(ct)>127?ut+="x":ut+=et[ct];if(!ut.match(w)){var b=Q.slice(0,j),k=Q.slice(j+1),I=et.match(p);I&&(b.push(I[1]),k.unshift(I[2])),k.length&&(R="/"+k.join(".")+R),this.hostname=b.join(".");break}}}this.hostname.length>255?this.hostname="":this.hostname=this.hostname.toLowerCase(),W||(this.hostname=r.toASCII(this.hostname));var F=this.port?":"+this.port:"",X=this.hostname||"";this.host=X+F,this.href+=this.host,W&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),R[0]!=="/"&&(R="/"+R))}if(!_[Y])for(j=0,st=g.length;j<st;j++){var G=g[j];if(R.indexOf(G)!==-1){var at=encodeURIComponent(G);at===G&&(at=escape(G)),R=R.split(G).join(at)}}var mt=R.indexOf("#");mt!==-1&&(this.hash=R.substr(mt),R=R.slice(0,mt));var yt=R.indexOf("?");if(yt!==-1?(this.search=R.substr(yt),this.query=R.substr(yt+1),B&&(this.query=C.parse(this.query)),R=R.slice(0,yt)):B&&(this.search="",this.query={}),R&&(this.pathname=R),x[Y]&&this.hostname&&!this.pathname&&(this.pathname="/"),this.pathname||this.search){F=this.pathname||"";var kt=this.search||"";this.path=F+kt}return this.href=this.format(),this},o.prototype.format=function(){var D=this.auth||"";D&&(D=(D=encodeURIComponent(D)).replace(/%3A/i,":"),D+="@");var B=this.protocol||"",L=this.pathname||"",V=this.hash||"",tt=!1,T="";this.host?tt=D+this.host:this.hostname&&(tt=D+(this.hostname.indexOf(":")===-1?this.hostname:"["+this.hostname+"]"),this.port&&(tt+=":"+this.port)),this.query&&a.isObject(this.query)&&Object.keys(this.query).length&&(T=C.stringify(this.query));var R=this.search||T&&"?"+T||"";return B&&B.substr(-1)!==":"&&(B+=":"),this.slashes||(!B||x[B])&&tt!==!1?(tt="//"+(tt||""),L&&L.charAt(0)!=="/"&&(L="/"+L)):tt||(tt=""),V&&V.charAt(0)!=="#"&&(V="#"+V),R&&R.charAt(0)!=="?"&&(R="?"+R),B+tt+(L=L.replace(/[?#]/g,function(P){return encodeURIComponent(P)}))+(R=R.replace("#","%23"))+V},o.prototype.resolve=function(D){return this.resolveObject(S(D,!1,!0)).format()},o.prototype.resolveObject=function(D){if(a.isString(D)){var B=new o;B.parse(D,!1,!0),D=B}for(var L=new o,V=Object.keys(this),tt=0;tt<V.length;tt++){var T=V[tt];L[T]=this[T]}if(L.hash=D.hash,D.href==="")return L.href=L.format(),L;if(D.slashes&&!D.protocol){for(var R=Object.keys(D),P=0;P<R.length;P++){var O=R[P];O!=="protocol"&&(L[O]=D[O])}return x[L.protocol]&&L.hostname&&!L.pathname&&(L.path=L.pathname="/"),L.href=L.format(),L}if(D.protocol&&D.protocol!==L.protocol){if(!x[D.protocol]){for(var Y=Object.keys(D),Z=0;Z<Y.length;Z++){var rt=Y[Z];L[rt]=D[rt]}return L.href=L.format(),L}if(L.protocol=D.protocol,D.host||E[D.protocol])L.pathname=D.pathname;else{for(var $=(D.pathname||"").split("/");$.length&&!(D.host=$.shift()););D.host||(D.host=""),D.hostname||(D.hostname=""),$[0]!==""&&$.unshift(""),$.length<2&&$.unshift(""),L.pathname=$.join("/")}if(L.search=D.search,L.query=D.query,L.host=D.host||"",L.auth=D.auth,L.hostname=D.hostname||D.host,L.port=D.port,L.pathname||L.search){var H=L.pathname||"",j=L.search||"";L.path=H+j}return L.slashes=L.slashes||D.slashes,L.href=L.format(),L}var K=L.pathname&&L.pathname.charAt(0)==="/",W=D.host||D.pathname&&D.pathname.charAt(0)==="/",Q=W||K||L.host&&D.pathname,st=Q,et=L.pathname&&L.pathname.split("/")||[],ut=($=D.pathname&&D.pathname.split("/")||[],L.protocol&&!x[L.protocol]);if(ut&&(L.hostname="",L.port=null,L.host&&(et[0]===""?et[0]=L.host:et.unshift(L.host)),L.host="",D.protocol&&(D.hostname=null,D.port=null,D.host&&($[0]===""?$[0]=D.host:$.unshift(D.host)),D.host=null),Q=Q&&($[0]===""||et[0]==="")),W)L.host=D.host||D.host===""?D.host:L.host,L.hostname=D.hostname||D.hostname===""?D.hostname:L.hostname,L.search=D.search,L.query=D.query,et=$;else if($.length)et||(et=[]),et.pop(),et=et.concat($),L.search=D.search,L.query=D.query;else if(!a.isNullOrUndefined(D.search))return ut&&(L.hostname=L.host=et.shift(),(I=!!(L.host&&L.host.indexOf("@")>0)&&L.host.split("@"))&&(L.auth=I.shift(),L.host=L.hostname=I.shift())),L.search=D.search,L.query=D.query,a.isNull(L.pathname)&&a.isNull(L.search)||(L.path=(L.pathname?L.pathname:"")+(L.search?L.search:"")),L.href=L.format(),L;if(!et.length)return L.pathname=null,L.search?L.path="/"+L.search:L.path=null,L.href=L.format(),L;for(var ct=et.slice(-1)[0],ot=(L.host||D.host||et.length>1)&&(ct==="."||ct==="..")||ct==="",b=0,k=et.length;k>=0;k--)(ct=et[k])==="."?et.splice(k,1):ct===".."?(et.splice(k,1),b++):b&&(et.splice(k,1),b--);if(!Q&&!st)for(;b--;b)et.unshift("..");!Q||et[0]===""||et[0]&&et[0].charAt(0)==="/"||et.unshift(""),ot&&et.join("/").substr(-1)!=="/"&&et.push("");var I,F=et[0]===""||et[0]&&et[0].charAt(0)==="/";return ut&&(L.hostname=L.host=F?"":et.length?et.shift():"",(I=!!(L.host&&L.host.indexOf("@")>0)&&L.host.split("@"))&&(L.auth=I.shift(),L.host=L.hostname=I.shift())),(Q=Q||L.host&&et.length)&&!F&&et.unshift(""),et.length?L.pathname=et.join("/"):(L.pathname=null,L.path=null),a.isNull(L.pathname)&&a.isNull(L.search)||(L.path=(L.pathname?L.pathname:"")+(L.search?L.search:"")),L.auth=D.auth||L.auth,L.slashes=L.slashes||D.slashes,L.href=L.format(),L},o.prototype.parseHost=function(){var D=this.host,B=u.exec(D);B&&((B=B[0])!==":"&&(this.port=B.substr(1)),D=D.substr(0,D.length-B.length)),D&&(this.hostname=D)}},{"./util":77,punycode:51,querystring:54}],77:[function(i,s,n){s.exports={isString:function(r){return typeof r=="string"},isObject:function(r){return typeof r=="object"&&r!==null},isNull:function(r){return r===null},isNullOrUndefined:function(r){return r==null}}},{}],78:[function(i,s,n){(function(r){(function(){function a(o){try{if(!r.localStorage)return!1}catch{return!1}var l=r.localStorage[o];return l!=null&&String(l).toLowerCase()==="true"}s.exports=function(o,l){if(a("noDeprecation"))return o;var u=!1;return function(){if(!u){if(a("throwDeprecation"))throw new Error(l);a("traceDeprecation")?console.trace(l):console.warn(l),u=!0}return o.apply(this,arguments)}}}).call(this)}).call(this,typeof De<"u"?De:typeof self<"u"?self:typeof window<"u"?window:{})},{}],79:[function(i,s,n){s.exports=function r(a,o){if(a&&o)return r(a)(o);if(typeof a!="function")throw new TypeError("need wrapper function");return Object.keys(a).forEach(function(u){l[u]=a[u]}),l;function l(){for(var u=new Array(arguments.length),h=0;h<u.length;h++)u[h]=arguments[h];var f=a.apply(this,u),g=u[u.length-1];return typeof f=="function"&&f!==g&&Object.keys(g).forEach(function(v){f[v]=g[v]}),f}}},{}],80:[function(i,s,n){s.exports=function(){throw new Error("ws does not work in the browser. Browser clients must use the native WebSocket object")}},{}],81:[function(i,s,n){s.exports=function(){for(var a={},o=0;o<arguments.length;o++){var l=arguments[o];for(var u in l)r.call(l,u)&&(a[u]=l[u])}return a};var r=Object.prototype.hasOwnProperty},{}],82:[function(i,s,n){s.exports=function(r){r.prototype[Symbol.iterator]=function*(){for(let a=this.head;a;a=a.next)yield a.value}}},{}],83:[function(i,s,n){function r(h){var f=this;if(f instanceof r||(f=new r),f.tail=null,f.head=null,f.length=0,h&&typeof h.forEach=="function")h.forEach(function(y){f.push(y)});else if(arguments.length>0)for(var g=0,v=arguments.length;g<v;g++)f.push(arguments[g]);return f}function a(h,f,g){var v=f===h.head?new u(g,null,f,h):new u(g,f,f.next,h);return v.next===null&&(h.tail=v),v.prev===null&&(h.head=v),h.length++,v}function o(h,f){h.tail=new u(f,h.tail,null,h),h.head||(h.head=h.tail),h.length++}function l(h,f){h.head=new u(f,null,h.head,h),h.tail||(h.tail=h.head),h.length++}function u(h,f,g,v){if(!(this instanceof u))return new u(h,f,g,v);this.list=v,this.value=h,f?(f.next=this,this.prev=f):this.prev=null,g?(g.prev=this,this.next=g):this.next=null}s.exports=r,r.Node=u,r.create=r,r.prototype.removeNode=function(h){if(h.list!==this)throw new Error("removing node which does not belong to this list");var f=h.next,g=h.prev;return f&&(f.prev=g),g&&(g.next=f),h===this.head&&(this.head=f),h===this.tail&&(this.tail=g),h.list.length--,h.next=null,h.prev=null,h.list=null,f},r.prototype.unshiftNode=function(h){if(h!==this.head){h.list&&h.list.removeNode(h);var f=this.head;h.list=this,h.next=f,f&&(f.prev=h),this.head=h,this.tail||(this.tail=h),this.length++}},r.prototype.pushNode=function(h){if(h!==this.tail){h.list&&h.list.removeNode(h);var f=this.tail;h.list=this,h.prev=f,f&&(f.next=h),this.tail=h,this.head||(this.head=h),this.length++}},r.prototype.push=function(){for(var h=0,f=arguments.length;h<f;h++)o(this,arguments[h]);return this.length},r.prototype.unshift=function(){for(var h=0,f=arguments.length;h<f;h++)l(this,arguments[h]);return this.length},r.prototype.pop=function(){if(this.tail){var h=this.tail.value;return this.tail=this.tail.prev,this.tail?this.tail.next=null:this.head=null,this.length--,h}},r.prototype.shift=function(){if(this.head){var h=this.head.value;return this.head=this.head.next,this.head?this.head.prev=null:this.tail=null,this.length--,h}},r.prototype.forEach=function(h,f){f=f||this;for(var g=this.head,v=0;g!==null;v++)h.call(f,g.value,v,this),g=g.next},r.prototype.forEachReverse=function(h,f){f=f||this;for(var g=this.tail,v=this.length-1;g!==null;v--)h.call(f,g.value,v,this),g=g.prev},r.prototype.get=function(h){for(var f=0,g=this.head;g!==null&&f<h;f++)g=g.next;if(f===h&&g!==null)return g.value},r.prototype.getReverse=function(h){for(var f=0,g=this.tail;g!==null&&f<h;f++)g=g.prev;if(f===h&&g!==null)return g.value},r.prototype.map=function(h,f){f=f||this;for(var g=new r,v=this.head;v!==null;)g.push(h.call(f,v.value,this)),v=v.next;return g},r.prototype.mapReverse=function(h,f){f=f||this;for(var g=new r,v=this.tail;v!==null;)g.push(h.call(f,v.value,this)),v=v.prev;return g},r.prototype.reduce=function(h,f){var g,v=this.head;if(arguments.length>1)g=f;else{if(!this.head)throw new TypeError("Reduce of empty list with no initial value");v=this.head.next,g=this.head.value}for(var y=0;v!==null;y++)g=h(g,v.value,y),v=v.next;return g},r.prototype.reduceReverse=function(h,f){var g,v=this.tail;if(arguments.length>1)g=f;else{if(!this.tail)throw new TypeError("Reduce of empty list with no initial value");v=this.tail.prev,g=this.tail.value}for(var y=this.length-1;v!==null;y--)g=h(g,v.value,y),v=v.prev;return g},r.prototype.toArray=function(){for(var h=new Array(this.length),f=0,g=this.head;g!==null;f++)h[f]=g.value,g=g.next;return h},r.prototype.toArrayReverse=function(){for(var h=new Array(this.length),f=0,g=this.tail;g!==null;f++)h[f]=g.value,g=g.prev;return h},r.prototype.slice=function(h,f){(f=f||this.length)<0&&(f+=this.length),(h=h||0)<0&&(h+=this.length);var g=new r;if(f<h||f<0)return g;h<0&&(h=0),f>this.length&&(f=this.length);for(var v=0,y=this.head;y!==null&&v<h;v++)y=y.next;for(;y!==null&&v<f;v++,y=y.next)g.push(y.value);return g},r.prototype.sliceReverse=function(h,f){(f=f||this.length)<0&&(f+=this.length),(h=h||0)<0&&(h+=this.length);var g=new r;if(f<h||f<0)return g;h<0&&(h=0),f>this.length&&(f=this.length);for(var v=this.length,y=this.tail;y!==null&&v>f;v--)y=y.prev;for(;y!==null&&v>h;v--,y=y.prev)g.push(y.value);return g},r.prototype.splice=function(h,f,...g){h>this.length&&(h=this.length-1),h<0&&(h=this.length+h);for(var v=0,y=this.head;y!==null&&v<h;v++)y=y.next;var w=[];for(v=0;y&&v<f;v++)w.push(y.value),y=this.removeNode(y);for(y===null&&(y=this.tail),y!==this.head&&y!==this.tail&&(y=y.prev),v=0;v<g.length;v++)y=a(this,y,g[v]);return w},r.prototype.reverse=function(){for(var h=this.head,f=this.tail,g=h;g!==null;g=g.prev){var v=g.prev;g.prev=g.next,g.next=v}return this.head=f,this.tail=h,this};try{i("./iterator.js")(r)}catch{}},{"./iterator.js":82}]},{},[12])(12)})})(er);const Mf={success:{color:"#2ba471",icon:'<svg fill="none" viewBox="0 0 24 24"><path d="M12 23a11 11 0 100-22 11 11 0 000 22zM7.5 10.59l3 3 6-6L17.91 9l-7.41 7.41L6.09 12l1.41-1.41z"></path></svg>'},info:{color:"#0052d9",icon:'<svg fill="none" viewBox="0 0 24 24"><path d="M12 23a11 11 0 100-22 11 11 0 000 22zM11 8.5v-2h2v2h-2zm2 1.5v7.5h-2V10h2z"></path></svg>'},warning:{color:"#e37318",icon:'<svg fill="none" viewBox="0 0 24 24"><path d="M12 1a11 11 0 110 22 11 11 0 010-22zm-1 13h2V6.5h-2V14zm2 1.5h-2v2h2v-2z"></path></svg>'},error:{color:"#d54941",icon:'<svg fill="none" viewBox="0 0 24 24"><path d="M12 1a11 11 0 110 22 11 11 0 010-22zm-1 13h2V6.5h-2V14zm2 1.5h-2v2h2v-2z"></path></svg>'},question:{color:"#0052d9",icon:'<svg fill="none" viewBox="0 0 24 24"><path d="M12 23a11 11 0 100-22 11 11 0 000 22zm-.17-11.11c.43-.53.97-.97 1.4-1.32A2 2 0 0012 7a2 2 0 00-1.89 1.33l-.33.95L7.9 8.6l.34-.94a4 4 0 116.24 4.47 7 7 0 00-1.1 1.01c-.27.34-.37.61-.37.85v1.25h-2V14c0-.87.39-1.57.83-2.11zM11 18.25v-2h2v2h-2z"></path></svg>'}},Xe={};class ek{constructor(t,i){U(this,"parentElement");U(this,"box");U(this,"icon");U(this,"text");U(this,"closeBtn");U(this,"duration");U(this,"content");U(this,"theme");U(this,"placement");U(this,"height");U(this,"id");var n;this.parentElement=t,this.box=document.createElement("div"),this.icon=document.createElement("div"),this.text=document.createElement("div"),this.box.className="meta2d-message",this.icon.className="icon",this.text.className="text",this.icon.innerHTML=Mf[i.theme||"info"].icon,this.text.innerHTML=i.content,this.box.appendChild(this.icon),this.box.appendChild(this.text),i.closeBtn&&(this.closeBtn=document.createElement("div"),this.closeBtn.className="close",this.closeBtn.innerHTML="x",this.closeBtn.onclick=()=>{this.close()},this.box.appendChild(this.closeBtn)),t.appendChild(this.box);let s;for(let r=0;r<document.styleSheets.length;r++)document.styleSheets[r].title==="le5le.com/message"&&(s=document.styleSheets[r]);if(!s){let r=document.createElement("style");r.type="text/css",r.title="le5le.com/message",document.head.appendChild(r),r=document.createElement("style"),r.type="text/css",document.head.appendChild(r),s=r.sheet,s.insertRule(`.meta2d-message{
- position:absolute;
- z-index:999;
- transform: translateX(-50%);
- padding:12px 16px;
- max-width:400px;
- background:#fff;
- border-radius:6px;
- box-shadow:0 3px 14px 2px rgba(0, 0, 0, .05),0 8px 10px 1px rgba(0, 0, 0, 6%),0 5px 5px -3px rgba(0, 0, 0, 10%);
- display:flex;
- animation: fadein .5s;}`),s.insertRule(`
- @keyframes fadein {
- 0% {
- transform: translate(-50%, -100%);
- }
- 100% {
- transform: translate(-50%,0);
- }
- }`),s.insertRule(".meta2d-message .icon{width:20px;height:20px;}"),s.insertRule(".meta2d-message .text{color:rgba(0, 0, 0, 0.9);font-size:12px;margin-left:8px;line-height:20px;}"),s.insertRule(".meta2d-message .close{width:20px;height:20px;padding-left: 16px; cursor: pointer;}")}this.id=i.id||It(),this.duration=(n=i.duration)!=null?n:3e3,this.placement=i.placement||"top",this.theme=i.theme||"info",this.height=i.height}init(){Xe[this.id]=this,this.duration&&setTimeout(()=>{this.close()},this.duration);let t=-1;Object.keys(Xe).forEach(i=>{var s;((s=Xe[i])==null?void 0:s.placement)===this.placement&&t++}),this.setPosition(this.placement,t),this.icon.children[0].style.fill=Mf[this.theme].color}setPosition(t,i=0){switch(t){case"top":this.box.style.top=`${30+i*(this.height||60)}px`,this.box.style.left="50%";break;case"bottom":this.box.style.bottom=`${30+i*(this.height||60)}px`,this.box.style.left="50%";break;case"left":this.box.style.top=`${30+i*(this.height||60)}px`,this.box.style.left="30px";break;case"right":this.box.style.top=`${30+i*(this.height||60)}px`,this.box.style.right="30px";break}}close(){Object.keys(Xe).forEach(t=>{var i;if(((i=Xe[t])==null?void 0:i.placement)===this.placement)switch(this.placement){case"top":case"left":case"right":Xe[t].box.style.top=parseInt(Xe[t].box.style.top)-60+"px";break;case"bottom":Xe[t].box.style.bottom=parseInt(Xe[t].box.style.bottom)-60+"px";break}}),Xe[this.id]=null,delete Xe[this.id],this.box.remove()}}function ik(e,t){e.jetLinksList.length&&(e.jetLinksClient=new WebSocket(`${t.url}/${localStorage.getItem("X-Access-Token")||dr("X-Access-Token")||new URLSearchParams(location.search).get("X-Access-Token")||""}`),e.jetLinksClient.onmessage=i=>{var n;const s=JSON.parse(i.data);if(!!s.payload)if((n=s.payload)!=null&&n.properties){const r=[];for(let a in s.payload.properties)a.startsWith("_")||r.push({id:`${s.payload.headers.productId}#${s.payload.deviceId}#${a}`,value:s.payload.properties[a]});e.setDatas(r,{history:!1})}else s.topic.startsWith("/notifications")&&gg(e,s)},e.jetLinksClient.onopen=()=>{e.jetLinksList.forEach(i=>{e.jetLinksClient.send(JSON.stringify({type:"sub",topic:`/device${i.topic}/message/property/report`,parameter:{deviceId:i.deviceId,properties:i.properties,history:1},id:i.topic+"-"+It()}))}),t.notification&&e.jetLinksClient.send(JSON.stringify({type:"sub",topic:"/notifications",id:"notification",parameter:{}}))})}function gg(e,t){var a,o;let i=t.payload.topicName,s=t.payload.message,n=t.payload.notifyTime,r=`<div style="padding:0px 12px 0px 0px;width:300px;">
- <div style="display:flex;height: 20px;justify-content: space-between">
- <div style="color: #000000d9;
- font-size: 14px;
- font-weight: 700;">${i}</div><div style="color: #00000073;">${sk(n)}</div>
- </div>
- <span>${s}</span>
- </div>`;e.message({content:r,duration:0,closeBtn:!0,placement:"right",height:75}),(a=t.payload.detail)!=null&&a.alarmConfigId&&ok(e,(o=t.payload.detail)==null?void 0:o.alarmConfigId)}globalThis.doWarning=gg;function sk(e){const t=new Date(e),i=t.getFullYear(),s=(t.getMonth()+1+"").padStart(2,"0"),n=(t.getDate()+"").padStart(2,"0"),r=(t.getHours()+"").padStart(2,"0"),a=(t.getMinutes()+"").padStart(2,"0"),o=(t.getSeconds()+"").padStart(2,"0");return i+"-"+s+"-"+n+" "+r+":"+a+":"+o}function nk(e){e.jetLinksClient&&(e.jetLinksClient.close(),e.jetLinksClient=void 0)}function rk(e,t,i){const s=[];return i.list.forEach((n,r)=>{var o,l,u;const a=n.params?e.findOne(n.params):t;s[r]={deviceId:a.deviceId,productId:a.productId,properties:{}};for(let h in n.value)if(n.value[h]===void 0||n.value[h]===""){const f=(o=a.realTimes)==null?void 0:o.find(g=>g.propertyId===h);f&&(s[r].properties[h]=a[f.key])}else if(typeof n.value[h]=="string"&&((l=n.value[h])==null?void 0:l.indexOf("${"))>-1){let f=n.value[h].match(new RegExp("(?<=\\$\\{).*?(?=\\})","g"));f!=null&&f.length&&(s[r].properties[h]=(u=a[f[0]])!=null?u:e.getDynamicParam(f[0]))}else s[r].properties[h]=n.value[h]}),s}async function ak(e,t){t.forEach(async i=>{let s=i.deviceId;if(s&&s.indexOf("${")>-1){let r=s.match(new RegExp("(?<=\\$\\{).*?(?=\\})","g"));r!=null&&r.length&&(s=e.getDynamicParam(r[0])||s)}(await fetch(`/api/device-instance/${s}/property`,{headers:{"X-Access-Token":localStorage.getItem("X-Access-Token")||new URLSearchParams(location.search).get("X-Access-Token")||"","Content-Type":"application/json"},method:"put",body:JSON.stringify(i.properties)})).ok?(console.info("\u53D1\u9001\u6210\u529F"),e.message({theme:"success",content:"\u4E0B\u53D1\u6210\u529F"})):e.message({theme:"error",content:"\u4E0B\u53D1\u5931\u8D25"})})}async function ok(e,t){const i=await fetch(`/api/alarm/config/${t}`,{headers:{"X-Access-Token":localStorage.getItem("X-Access-Token")||new URLSearchParams(location.search).get("X-Access-Token")||"","Content-Type":"application/json"},method:"GET"});if(i.ok){let s=i.json();console.log("alarm"),s.result.media&&vg(e,s.result.media,s.result.playTimes)}}function vg(e,t,i){if(e.store.globalAudio||(e.store.globalAudio=document.createElement("audio")),e.store.globalAudio.src=t,e.store.globalAudio.play(),i===-1)e.store.globalAudio.loop=!0;else{e.store.globalAudio.loop=!1;let s=0;e.store.globalAudio.onended=()=>{s++,s<i&&e.store.globalAudio.play()}}}globalThis.createAudio=vg;class lk{constructor(t,i={}){U(this,"store");U(this,"canvas");U(this,"websocket");U(this,"mqttClient");U(this,"websockets");U(this,"mqttClients");U(this,"eventSources");U(this,"penPluginMap",new Map);U(this,"socketFn");U(this,"events",{});U(this,"map");U(this,"mapTimer");U(this,"facePen",Sn);U(this,"getWords",Ld);U(this,"calcTextLines",xr);U(this,"calcTextRect",Ti);U(this,"calcTextDrawRect",Id);U(this,"jetLinksList",[]);U(this,"jetLinksClient");U(this,"register",Pd);U(this,"registerCanvasDraw",_x);U(this,"registerAnchors",kx);U(this,"websocketTimes",0);U(this,"mqttTimes",0);U(this,"httpTimer");U(this,"httpTimerList",[]);U(this,"updateTimer");U(this,"updateTimerList",[]);U(this,"sqlTimerList",[]);U(this,"iotMqttClient");U(this,"iotTimer");U(this,"iotWebsocketClient");U(this,"onEvent",(t,i)=>{switch(t){case"add":i.forEach(s=>{var n;(n=s.onAdd)==null||n.call(s,s)}),this.onSizeUpdate();break;case"enter":i&&i.onMouseEnter&&i.onMouseEnter(i,this.canvas.mousePos),this.store.data.locked&&this.doEvent(i,t);break;case"leave":i&&i.onMouseLeave&&i.onMouseLeave(i,this.canvas.mousePos),this.store.data.locked&&this.doEvent(i,t);break;case"active":case"inactive":this.store.data.locked&&i.forEach(s=>{this.doEvent(s,t)});break;case"click":if(this.store.data.locked&&i.pen&&!i.pen.disabled&&i.pen.switch&&(i.pen.checked=!i.pen.checked,i.pen.calculative.checked=i.pen.checked,i.pen.calculative.gradient=void 0,i.pen.calculative.radialGradient=void 0),i.pen&&i.pen.formId){const s=this.store.pens[i.pen.formId];i.pen.formType==="submit"?this.store.data.locked&&s&&!s.disabled&&this.doEvent(s,"submit"):i.pen.formType==="reset"&&(W2(i.pen),this.store.data.locked&&s&&!s.disabled&&this.doEvent(s,"reset"))}i.pen&&i.pen.onClick&&!i.pen.disabled&&i.pen.onClick(i.pen,this.canvas.mousePos),this.store.data.locked&&i.pen&&!i.pen.disabled&&this.doEvent(i.pen,t);break;case"contextmenu":i.pen&&i.pen.onContextmenu&&!i.pen.disabled&&i.pen.onContextmenu(i.pen,this.canvas.mousePos),this.store.data.locked&&i.pen&&!i.pen.disabled&&this.doEvent(i.pen,t);break;case"mousedown":i.pen&&i.pen.onMouseDown&&!i.pen.disabled&&i.pen.onMouseDown(i.pen,this.canvas.mousePos),this.store.data.locked&&i.pen&&!i.pen.disabled&&this.doEvent(i.pen,t);break;case"mouseup":i.pen&&i.pen.onMouseUp&&!i.pen.disabled&&i.pen.onMouseUp(i.pen,this.canvas.mousePos),this.store.data.locked&&i.pen&&!i.pen.disabled&&this.doEvent(i.pen,t);break;case"dblclick":this.store.data.locked&&i.pen&&!i.pen.disabled&&this.doEvent(i.pen,t);break;case"valueUpdate":i&&Lf(i,i.formValue),this.store.data.locked&&this.doEvent(i,t),this.canvas.tooltip.updateText(i);break;case"update":case"delete":case"translatePens":case"rotatePens":case"resizePens":this.onSizeUpdate();break;case"navigator":this.store.data.id||console.warn("\u8BF7\u5148\u4FDD\u5B58\u5F53\u524D\u56FE\u7EB8"),this.navigatorTo(i.params);break;case"input":this.store.data.locked&&i&&!i.disabled&&this.doEvent(i,t);break;case"change":i.pen&&Lf(i.pen),this.store.data.locked&&i&&!i.disabled&&this.doEvent(i,t);break}this.doMessageEvent(t)});U(this,"doEvent",(t,i)=>{var r,a,o,l,u,h,f,g,v,y;if(!t)return;let s=!1,n=[];if((r=t.events)==null||r.forEach((w,p)=>{var _;if(w.actions&&w.actions.length){if(w.name===i){let E=!1;w.conditions&&w.conditions.length?w.conditionType==="and"?E=w.conditions.every(x=>this.judgeCondition(t,x.key,x)):w.conditionType==="or"&&(E=w.conditions.some(x=>this.judgeCondition(t,x.key,x))):E=!0,E&&n.push(p)}}else if(s=!0,this.events[w.action]&&w.name===i){let E=!((_=w.where)!=null&&_.type);if(w.where){const{fn:x,fnJs:C,comparison:S,key:D,value:B}=w.where;if(x)E=x(t,{meta2d:this});else if(C){try{w.where.fn=new Function("pen","context",C)}catch(L){console.error("Error: make function:",L)}w.where.fn&&(E=w.where.fn(t,{meta2d:this}))}else{let L=t[D];switch(["x","y","width","height"].includes(D)&&(L=this.getPenRect(t)[D]),S){case">":E=L>+B;break;case">=":E=L>=+B;break;case"<":E=L<+B;break;case"<=":E=L<=+B;break;case"=":case"==":E=L==B;break;case"!=":E=L!=B;break;case"[)":E=fn(+L,B);break;case"![)":E=!fn(+L,B);break;case"[]":E=dn(L,B);break;case"![]":E=!dn(L,B);break}}}E&&n.push(p)}}),s?(a=t.events)==null||a.forEach((w,p)=>{n.includes(p)&&this.events[w.action](t,w)}):(o=t.events)==null||o.forEach(async(w,p)=>{if(n.includes(p)){if(w.confirm&&!await this.canvas.popconfirm.showModal(t,this.canvas.mousePos,w.confirmTitle))return;w.actions.forEach(_=>{if(_.timeout){let E=setTimeout(()=>{this.events[_.action]&&(this.events[_.action](t,_),clearTimeout(E),E=null)},_.timeout)}else this.events[_.action]&&this.events[_.action](t,_)})}}),i==="valueUpdate"){(l=t.realTimes)==null||l.forEach(p=>{var E,x;let _=[];(E=p.triggers)==null||E.forEach((C,S)=>{var B;let D=!1;(B=C.conditions)!=null&&B.length?C.conditionType==="and"?D=C.conditions.every(L=>this.judgeCondition(t,p.key,L)):C.conditionType==="or"&&(D=C.conditions.some(L=>this.judgeCondition(t,p.key,L))):D=!0,D&&_.push(S)}),(x=p.triggers)==null||x.forEach((C,S)=>{var D;_.includes(S)&&((D=C.actions)==null||D.forEach(B=>{if(B.timeout){let L=setTimeout(()=>{this.events[B.action]&&(this.events[B.action](t,B),clearTimeout(L),L=null)},B.timeout)}else this.events[B.action](t,B)}))})});let w=[];if((u=this.store.globalTriggers[t.id])==null||u.forEach((p,_)=>{var x;let E=!1;(x=p.conditions)!=null&&x.length?p.conditionType==="and"?E=p.conditions.every(C=>this.judgeCondition(this.store.pens[C.source],C.key,C)):p.conditionType==="or"&&(E=p.conditions.some(C=>this.judgeCondition(this.store.pens[C.source],C.key,C))):E=!0,E&&w.push(_)}),(h=this.store.globalTriggers[t.id])==null||h.forEach((p,_)=>{var E;w.includes(_)&&((E=p.actions)==null||E.forEach(x=>{if(x.timeout){let C=setTimeout(()=>{this.events[x.action]&&(this.events[x.action](t,x),clearTimeout(C),C=null)},x.timeout)}else this.events[x.action](t,x)}))}),(f=t.triggers)!=null&&f.length){for(let p of t.triggers)if((g=p.status)!=null&&g.length)for(let _ of p.status){let E=!1;if((v=_.conditions)!=null&&v.length?_.conditionType==="and"?E=_.conditions.every(x=>this.judgeCondition(t,x.key,x)):_.conditionType==="or"&&(E=_.conditions.some(x=>this.judgeCondition(t,x.key,x))):E=!0,E){(y=_.actions)==null||y.forEach(x=>{if(x.timeout){let C=setTimeout(()=>{this.events[x.action]&&(this.events[x.action](t,x),clearTimeout(C),C=null)},x.timeout)}else this.events[x.action](t,x)});break}}}}this.doEvent(this.store.pens[t.parentId],i)});U(this,"doDataEvent",t=>{var n,r,a;if(!((n=this.store.data.dataEvents)!=null&&n.length))return;const i=t.reduce((o,{dataId:l,id:u,value:h})=>(o[u||l]=h,o),{});let s=[];(r=this.store.data.dataEvents)==null||r.forEach((o,l)=>{let u=!1;o.conditions&&o.conditions.length?o.conditionType==="and"?u=o.conditions.every(h=>this.dataJudegeCondition(i,h.key,h)):o.conditionType==="or"&&(u=o.conditions.some(h=>this.dataJudegeCondition(i,h.key,h))):u=!0,u&&s.push(l)}),(a=this.store.data.dataEvents)==null||a.forEach((o,l)=>{var u;s.includes(l)&&((u=o.actions)==null||u.forEach(h=>{this.events[h.action](i,h)}))})});U(this,"renderPenRaw",Wa);U(this,"setElemPosition",Te);U(this,"setLifeCycleFunc",b_);this.store=Sx(It()),this.setOptions(i),this.setDatabyOptions(i),this.init(t),this.register(J2()),this.registerCanvasDraw({cube:Q_}),this.registerAnchors(Q2()),globalThis.meta2d=this,this.initEventFns(),this.store.emitter.on("*",this.onEvent)}get beforeAddPen(){return this.canvas.beforeAddPen}set beforeAddPen(t){this.canvas.beforeAddPen=t}get beforeAddPens(){return this.canvas.beforeAddPens}set beforeAddPens(t){this.canvas.beforeAddPens=t}get beforeAddAnchor(){return this.canvas.beforeAddAnchor}set beforeAddAnchor(t){this.canvas.beforeAddAnchor=t}get beforeRemovePens(){return this.canvas.beforeRemovePens}set beforeRemovePens(t){this.canvas.beforeRemovePens=t}get beforeRemoveAnchor(){return this.canvas.beforeRemoveAnchor}set beforeRemoveAnchor(t){this.canvas.beforeRemoveAnchor=t}setOptions(t={}){var i,s;(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.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=Yt.None)),(t.width!==void 0||t.height!==void 0)&&(this.canvas&&(this.canvas.canvasTemplate.bgPatchFlags=!0),this.canvas&&this.canvas.canvasTemplate.canvas.style.backgroundImage&&(this.canvas.canvasTemplate.canvas.style.backgroundImage="")),this.store.options=Object.assign(this.store.options,t),this.canvas&&t.scroll!==void 0&&(t.scroll?(!this.canvas.scroll&&(this.canvas.scroll=new hg(this.canvas)),this.canvas.scroll.show()):this.canvas.scroll&&this.canvas.scroll.hide()),(s=this.canvas)==null||s.initGlobalStyle()}getOptions(){return this.store.options}registerTheme(t,i){if(!Array.isArray(i))return;const s=/^\s*\S+\s*:\s*\S+\s*$/;if(!i.every(o=>s.test(o)))return;const r={},a=[];for(let o=0;o<i.length;o++){const u=i[o].split(":"),h=u[0].trim(),f=u[1].trim();a.push([h,f].join(":")),r[h]=f}Qn.addTheme(t,a),this.store.theme[t]=r}setTheme(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}),Qn.updateCssRule(this.store.id,t),this.canvas.initGlobalStyle();for(let i=0;i<this.store.data.pens.length;i++){const s=this.store.data.pens[i];s.setTheme&&s.setTheme(s,this.store.styles)}this.render()}setDatabyOptions(t={}){const{color:i,activeColor:s,activeBackground:n,grid:r,gridColor:a,gridSize:o,fromArrow:l,toArrow:u,rule:h,ruleColor:f,textColor:g,x:v=0,y=0}=t;this.setRule({rule:h,ruleColor:f}),this.setGrid({grid:r,gridColor:a,gridSize:o}),this.store.data=Object.assign(this.store.data,{textColor:g,color:i,activeColor:s,activeBackground:n,fromArrow:l,toArrow:u,x:v,y})}init(t){typeof t=="string"?this.canvas=new Pf(this,document.getElementById(t),this.store):this.canvas=new Pf(this,t,this.store),this.canvas.initGlobalStyle(),this.resize(),this.canvas.listen(),Qn.createThemeSheet(this.store.data.theme,this.store.id)}initEventFns(){this.events[he.Link]=(t,i)=>{var s;if(window&&i.value&&typeof i.value=="string"){window.open(i.value,(s=i.params)!=null?s:"_blank");return}console.warn("[meta2d] Link param is not a string")},this.events[he.SetProps]=(t,i)=>{const s=i.value;if(s&&typeof s=="object"){(i.params?this.find(i.params):this.find(t.id)).forEach(r=>{s.hasOwnProperty("visible")&&r.visible!==s.visible&&this.setVisible(r,s.visible),this.setValue({id:r.id,...s},{render:!1,doEvent:!1})}),this.render();return}console.warn("[meta2d] SetProps value is not an object")},this.events[he.StartAnimate]=(t,i)=>{let s=t;if(i.value&&(s=this.findOne(i.value)),!(this.store.animates.has(s)&&!s.calculative.pause&&s.animateName===i.params)){if(i.targetType&&i.params){this.startAnimate(i.value||[t],i.params);return}if(!i.value||typeof i.value=="string"){this.startAnimate(i.value||[t]);return}console.warn("[meta2d] StartAnimate value is not a string")}},this.events[he.PauseAnimate]=(t,i)=>{if(!i.value||typeof i.value=="string"){this.pauseAnimate(i.value||[t]);return}console.warn("[meta2d] PauseAnimate value is not a string")},this.events[he.StopAnimate]=(t,i)=>{if(!i.value||typeof i.value=="string"){if(i.value){let s=this.findOne(i.value);if(!this.store.animates.has(s))return}else if(!this.store.animates.has(t))return;this.stopAnimate(i.value||[t]);return}console.warn("[meta2d] StopAnimate event value is not a string")},this.events[he.StartVideo]=(t,i)=>{if(!i.value||typeof i.value=="string"){this.startVideo(i.value||[t]);return}console.warn("[meta2d] StartVideo value is not a string")},this.events[he.PauseVideo]=(t,i)=>{if(!i.value||typeof i.value=="string"){this.pauseVideo(i.value||[t]);return}console.warn("[meta2d] PauseVideo value is not a string")},this.events[he.StopVideo]=(t,i)=>{if(!i.value||typeof i.value=="string"){this.stopVideo(i.value||[t]);return}console.warn("[meta2d] StopVideo event value is not a string")},this.events[he.JS]=(t,i,s)=>{var n;if(i.value&&!i.fn)try{if(typeof i.value!="string")throw new Error("[meta2d] Function value must be string");const r=i.value;i.fn=new Function("pen","params","context",r)}catch(r){console.error("[meta2d]: Error on make a function:",r)}(n=i.fn)==null||n.call(i,t,s||i.params,{meta2d:this,eventName:i.name})},this.events[he.GlobalFn]=(t,i)=>{if(typeof i.value!="string"){console.warn("[meta2d] GlobalFn value must be a string");return}globalThis[i.value]&&globalThis[i.value](t,i.params)},this.events[he.Emit]=(t,i)=>{if(typeof i.value!="string"){console.warn("[meta2d] Emit value must be a string");return}this.store.emitter.emit(i.value,{pen:t,params:i.params,eventName:i.name})},this.events[he.SendPropData]=(t,i)=>{const s=ht(i.value);if(s&&typeof s=="object"){const n=i.params?this.findOne(i.params):t;for(let r in s)(s[r]===void 0||s[r]==="")&&(s[r]=n[r]);s.id=n.id,this.doSendDataEvent(s,i.extend);return}console.warn("[meta2d] SendPropData value is not an object")},this.events[he.SendVarData]=(t,i)=>{const s=ht(i.value);if(s&&typeof s=="object"){const n=i.params?this.findOne(i.params):t;let r=[];for(let a in s){let o={dataId:a,value:s[a]};if(!o.value){let l=n.form.find(u=>u.dataIds&&u.dataIds.dataId===o.dataId);l&&(o.value=n[l.key])}r.push(o)}this.doSendDataEvent(r,i.extend);return}console.warn("[meta2d] SendVarData value is not an object")},this.events[he.Navigator]=(t,i)=>{i.value&&typeof i.value=="string"&&this.navigatorTo(i.value)},this.events[he.Dialog]=(t,i)=>{var s;if(i.params&&typeof i.params=="string"){let n=i.params;if(i.params.includes("${")){let a=(s=i.params.match(/\$\{([^}]+)\}/g))==null?void 0:s.map(o=>o.slice(2,-1));a&&(a==null||a.forEach(o=>{n=n.replace(`\${${o}}`,t[o])}))}Object.keys(i.extend).forEach(a=>{["x","y","width","height"].includes(a)||(n.indexOf("?")!==-1?n+=`&${a}=${i.extend[a]}`:n+=`?${a}=${i.extend[a]}`)});const r=this.getEventData(i.list,t);this.canvas.dialog.show(i.value,n,i.extend,r)}},this.events[he.SendData]=(t,i)=>{var n,r,a,o,l;if((n=i.data)!=null&&n.length){const u=this.getSendData(i.data);t.formId&&t.formData&&Object.assign(u,t.formData),this.sendDataToNetWork(u,t,i);return}if((r=i.list)!=null&&r.length){if(i.network&&i.network.protocol==="ADIIOT"){const h=rk(this,t,i);h.length&&ak(this,h);return}const u=this.getEventData(i.list,t);t.deviceId&&(u.deviceId=t.deviceId),t.formId&&t.formData&&Object.assign(u,t.formData),this.sendDataToNetWork(u,t,i);return}const s=ht(i.value);if(s&&typeof s=="object"&&i.targetType==="id"){const u=i.params?this.findOne(i.params):t;for(let h in s)if(s[h]===void 0||s[h]==="")s[h]=u[h];else if(typeof s[h]=="string"&&((a=s[h])==null?void 0:a.indexOf("${"))>-1){let f=(o=s[h].match(/\$\{([^}]+)\}/g))==null?void 0:o.map(g=>g.slice(2,-1));f!=null&&f.length&&(s[h]=(l=u[f[0]])!=null?l:this.getDynamicParam(f[0]))}u.deviceId&&(s.deviceId=u.deviceId),this.sendDataToNetWork(s,t,i);return}},this.events[he.PostMessage]=(t,i)=>{if(typeof i.value!="string"){console.warn("[meta2d] Emit value must be a string");return}const s=i.params?this.findOne(i.params):t;if(s.name!=="iframe"||!s.iframe){console.warn("\u4E0D\u662F\u5D4C\u5165\u9875\u9762");return}let n=wn(s.iframe.split("?")[1]);const r=this.getEventData(i.list,s);s.calculative.singleton.div.children[0].contentWindow.postMessage(JSON.stringify({name:i.value,id:n.id,data:r}),"*")},this.events[he.PostMessageToParent]=(t,i)=>{if(typeof i.value!="string"){console.warn("[meta2d] Emit value must be a string");return}const s=this.getEventData(i.list,t);window.parent.postMessage(JSON.stringify({name:i.value,data:s}),"*")},this.events[he.Message]=(t,i)=>{this.message({theme:i.params,content:i.value,...i.extend})}}getSendData(t){const i={};return t.forEach(s=>{if(s.prop)if(s.id&&s.id!=="\u56FA\u5B9A\u503C"){const n=this.findOne(s.id);i[s.prop]=n[s.key]}else i[s.prop]=this.convertType(s.value,s.type)}),i}convertType(t,i){if(typeof t=="string"){if(["switch","bool","boolean"].includes(i)){if(t==="false")return!1;if(t==="true")return!0}else if(["integer","number","int","enum","double","float"].includes(i)&&!isNaN(Number(t)))return Number(t)}return t}getEventData(t,i){const s={};return t!=null&&t.length&&t.forEach(n=>{var a,o,l;const r=n.params?this.findOne(n.params):i;for(let u in n.value)if(n.value[u]===void 0||n.value[u]==="")s[u]=r[u];else if(typeof n.value[u]=="string"&&((a=n.value[u])==null?void 0:a.indexOf("${"))>-1){let h=(o=n.value[u].match(/\$\{([^}]+)\}/g))==null?void 0:o.map(f=>f.slice(2,-1));h!=null&&h.length&&(s[u]=(l=r[h[0]])!=null?l:this.getDynamicParam(h[0]))}else s[u]=n.value[u]}),Object.keys(s).length?s:{}}message(t){new ek(this.canvas.parentElement,t).init()}closeAll(){for(let t in Xe)Xe[t].close()}async navigatorTo(t){var n;if(!t)return;if((n=wn())==null?void 0:n.id){const r=new URL(window.location);r.searchParams.set("id",t),history.pushState({},"",r)}const s=await Bd(this.store,t);s&&(this.open(s),this.fitView(!0,10))}doSendDataEvent(t,i){let s=JSON.stringify(t);this.mqttClient&&this.mqttClient.connected&&(i?i.split(",").forEach(n=>{this.mqttClient.publish(n,s)}):this.store.data.mqttTopics&&this.store.data.mqttTopics.split(",").forEach(n=>{this.mqttClient.publish(n,s)})),this.websocket&&this.websocket.readyState===1&&this.websocket.send(s),(this.store.data.https||this.store.data.http)&&this.sendDatabyHttp(s),this.store.emitter.emit("sendData",s)}async sendDataToNetWork(t,i,s){var r,a,o,l,u,h;const n=ht(s.network);if(n.data&&(Object.assign(n,n.data),delete n.data),n.protocol==="iot"){this.iotMqttClient&&this.iotMqttClient.publish(`le5le-iot/property/set/${(r=this.store.data.iot)==null?void 0:r.token}`,JSON.stringify(t));return}if(!!n.url){if(n.protocol==="http"){if(typeof n.headers=="object"){for(let y in n.headers)if(typeof n.headers[y]=="string"){let w=(a=n.headers[y].match(/\$\{([^}]+)\}/g))==null?void 0:a.map(p=>p.slice(2,-1));w&&(n.headers[y]=n.headers[y].replace(`\${${w[0]}}`,this.getDynamicParam(w[0])))}}let f,g=n.url;if(n.method==="GET"&&(f="?"+Object.keys(t).map(y=>y+"="+t[y]).join("&")),n.method==="POST"&&g.indexOf("${")>-1){let y=(o=g.match(/\$\{([^}]+)\}/g))==null?void 0:o.map(w=>w.slice(2,-1));y&&y.forEach(w=>{g=g.replace(`\${${w}}`,ys(i,w)||this.getDynamicParam(w))})}const v=await fetch(g+(f||""),{headers:n.headers||{},method:n.method,body:n.method==="POST"?JSON.stringify(t):void 0});if(v.ok){if(s.callback){const y=await v.text();if(!s.fn)try{if(typeof s.callback!="string")throw new Error("[meta2d] Function callback must be string");const w=s.callback;s.fn=new Function("pen","data","context",w)}catch(w){console.error("[meta2d]: Error on make a function:",w)}(l=s.fn)==null||l.call(s,i,y,{meta2d:this,e:s})}console.info("http\u6D88\u606F\u53D1\u9001\u6210\u529F")}}else if(n.protocol==="mqtt"){const f=(u=this.mqttClients)==null?void 0:u.filter(g=>g.options.href===n.url);if(f&&f.length)f[0].connected&&n.topics.split(",").forEach(g=>{f[0].publish(g,JSON.stringify(t))});else{let g=er.exports.connect(n.url,n.options);g.on("connect",()=>{console.info("mqtt\u8FDE\u63A5\u6210\u529F"),n.topics.split(",").forEach(v=>{g.publish(v,JSON.stringify(t)),setTimeout(()=>{g==null||g.end()},1e3)})})}}else if(n.protocol==="websocket"){const f=(h=this.websockets)==null?void 0:h.filter(g=>g.url===n.url);if(f&&f.length)f[0].readyState===1&&f[0].send(JSON.stringify(t));else{let g=new WebSocket(n.url,n.protocols||void 0);g.onopen=function(){console.info("websocket\u8FDE\u63A5\u6210\u529F"),g.send(JSON.stringify(t)),setTimeout(()=>{g.close()},100)}}}}}resize(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()}async addPen(t,i,s=!0,n=!1){return await this.canvas.addPen(t,i,s,n)}async addPens(t,i,s=!1){return await this.canvas.addPens(t,i,s)}render(t){var i;(i=this.canvas)==null||i.render(t)}async setBackgroundImage(t,i){var o,l,u,h;let s=this;async function n(f){return new Promise(g=>{const v=new Image;v.src=f,s.store.options.cdn&&!(f.startsWith("http")||f.startsWith("//")||f.startsWith("data:image"))&&(v.src=s.store.options.cdn+f),v.crossOrigin="anonymous",v.onload=()=>{g(v)}})}this.store.data.bkImage=t;const r=(i==null?void 0:i.width)||((o=this.store.data)==null?void 0:o.width)||((l=this.store.options)==null?void 0:l.width),a=(i==null?void 0:i.height)||((u=this.store.data)==null?void 0:u.height)||((h=this.store.options)==null?void 0:h.height);if(r&&a?(this.canvas.canvasTemplate.canvas.style.backgroundImage=null,this.canvas&&(this.canvas.canvasTemplate.bgPatchFlags=!0)):this.canvas.canvasTemplate.canvas.style.backgroundImage=t?`url('${t}')`:"",t){const f=await n(t);this.store.bkImg=f,r&&a&&this.canvas&&(this.canvas.canvasTemplate.init(),this.render())}else this.store.bkImg=null}setBackgroundColor(t=this.store.data.background){this.store.data.background=t,this.canvas&&(this.canvas.canvasTemplate.bgPatchFlags=!0)}setGrid({grid:t=this.store.data.grid,gridColor:i=this.store.data.gridColor,gridSize:s=this.store.data.gridSize,gridRotate:n=this.store.data.gridRotate}={}){this.store.data.grid=t,this.store.data.gridColor=i,this.store.data.gridSize=s<0?0:s,this.store.data.gridRotate=n,this.canvas&&(this.canvas.canvasTemplate.bgPatchFlags=!0)}setRule({rule:t=this.store.data.rule,ruleColor:i=this.store.data.ruleColor}={}){this.store.data.rule=t,this.store.data.ruleColor=i,this.store.patchFlagsTop=!0}open(t,i=!0){if(this.clear(!1,t==null?void 0:t.template),this.canvas.autoPolylineFlag=!0,t){t.theme&&this.setTheme(t.theme),this.setBackgroundImage(t.bkImage,t),Object.assign(this.store.data,t),this.store.data.pens=[];for(const s of t.pens)s.id||(s.id=It()),!s.calculative&&(s.calculative={canvas:this.canvas}),this.store.pens[s.id]=s;for(const s of t.pens)this.canvas.makePen(s)}if(this.canvas.patchFlagsLines.forEach(s=>{s.type&&this.canvas.initLineRect(s)}),this.store.data.template||(this.store.data.template=It()),i||(this.canvas.opening=!0),this.doInitJS(),this.doInitFn(),this.initBindDatas(),this.initBinds(),this.initMessageEvents(),this.initGlobalTriggers(),this.startAnimate(),this.startVideo(),this.listenSocket(),this.connectSocket(),this.connectNetwork(),this.startDataMock(),this.canvas.initGlobalStyle(),this.render(),setTimeout(()=>{const s=this.store.data.pens.find(n=>n.autofocus);s&&this.focus(s.id)},100),this.store.data.iconUrls)for(const s of this.store.data.iconUrls)Bx(s,()=>{this.render()});this.canvas.autoPolylineFlag=!1,this.store.emitter.emit("opened"),this.canvas.scroll&&this.canvas.scroll.isShow&&this.canvas.scroll.init()}cacheData(t){if(t&&this.store.options.cacheLength){let i=this.store.cacheDatas.findIndex(s=>s.data&&s.data._id===t);if(i===-1)this.store.cacheDatas.push({data:ht(this.store.data,!0)}),this.store.cacheDatas.length>this.store.options.cacheLength&&this.store.cacheDatas.shift();else{let s=this.store.cacheDatas.splice(i,1)[0];this.store.cacheDatas.push(s)}}}loadCacheData(t){let i=this.store.cacheDatas.findIndex(s=>s.data&&s.data._id===t);i!==-1&&(this.store.data=this.store.cacheDatas[i].data,this.setBackgroundImage(this.store.data.bkImage),this.store.pens={},this.store.data.pens.forEach(s=>{s.calculative.canvas=this.canvas,this.store.pens[s.id]=s,At.path2dDraws[s.name]&&this.store.path2dMap.set(s,At.path2dDraws[s.name](s)),s.type&&this.store.path2dMap.set(s,At.path2dDraws[s.name](s)),s.image&&(s.calculative.imageDrawed=!1,this.canvas.loadImage(s))}),this.render())}statistics(){const t=this.store.data.pens.length,i=this.store.data.pens.filter(o=>o.image).length,s=this.store.data.pens.filter(o=>o.image&&o.calculative.inView).length,n=this.store.data.pens.filter(o=>o.name.endsWith("Dom")||Td.includes(o.name)||this.store.options.domShapes.includes(o.name)||o.externElement).length,r=this.store.animates.size;let a=0;return Object.keys(this.store.bind).forEach(o=>{a+=this.store.bind[o].length}),Object.keys(this.store.bindDatas).forEach(o=>{a+=this.store.bindDatas[o].length}),{\u56FE\u5143\u603B\u6570\u91CF:t,\u56FE\u7247\u56FE\u5143\u6570\u91CF:i,\u56FE\u7247\u56FE\u5143\u7ED8\u5236\u6570\u91CF:s,dom\u56FE\u5143\u6570\u91CF:n,\u6B63\u5728\u6267\u884C\u7684\u52A8\u753B\u6570\u91CF:r,\u6570\u636E\u70B9\u6570\u91CF:a}}initBindDatas(){this.store.bindDatas={},this.store.data.pens.forEach(t=>{var i;(i=t.form)==null||i.forEach(s=>{let n;s.dataIds&&(Array.isArray(s.dataIds)?n=s.dataIds:n=[s.dataIds]),n==null||n.forEach(r=>{this.store.bindDatas[r.dataId]||(this.store.bindDatas[r.dataId]=[]),this.store.bindDatas[r.dataId].push({id:t.id,formItem:s})})})})}initBinds(){this.jetLinksList=[],this.store.bind={};const t=[],i=[];this.store.data.pens.forEach(s=>{var n,r;(n=s.realTimes)==null||n.forEach(a=>{if(a.bind&&a.bind.id){let o=a.productId||s.productId,l=a.deviceId||s.deviceId,u=a.propertyId,h=!1;if(o&&o.indexOf("${")>-1){let f=o.match(new RegExp("(?<=\\$\\{).*?(?=\\})","g"));f!=null&&f.length&&(o=this.getDynamicParam(f[0])||o),h=!0}if(l&&l.indexOf("${")>-1){let f=l.match(new RegExp("(?<=\\$\\{).*?(?=\\})","g"));f!=null&&f.length&&(l=this.getDynamicParam(f[0])||l),h=!0}if(u&&u.indexOf("${")>-1){let f=u.match(new RegExp("(?<=\\$\\{).*?(?=\\})","g"));f!=null&&f.length&&(u=this.getDynamicParam(f[0])||u),h=!0}if(h&&a.bind&&(a.bind.id=o+"#"+l+"#"+u),this.store.bind[a.bind.id]||(this.store.bind[a.bind.id]=[]),this.store.bind[a.bind.id].push({id:s.id,key:a.key}),o&&l&&u){const f=this.jetLinksList.findIndex(g=>g.topic.startsWith(`/${o}/${l}`));f>-1?this.jetLinksList[f].properties.includes(a.propertyId)||this.jetLinksList[f].properties.push(a.propertyId):this.jetLinksList.push({topic:`/${o}/${l}`,deviceId:l,properties:[a.propertyId]})}if(a.bind.class==="iot"){let f=a.bind.id.split("#"),g=t.findIndex(y=>y.deviceId===f[0]);g>-1?t[g].properties.includes(f[1])||t[g].properties.push(f[1]):t.push({deviceId:f[0],properties:[f[1]],token:a.bind.token}),i.findIndex(y=>y.key===a.bind.id)===-1&&i.push({key:a.bind.id,label:a.bind.label})}else if(a.bind.class==="sql"){let f=a.bind.id.split("#");const g=this.store.data.sqls.find(v=>v.bindId===f[0]);if(g){g.keys||(g.keys=[]),f.shift();const v=f.join("#");g.keys.includes(v)||g.keys.push(v)}}}}),(r=s.events)==null||r.forEach(a=>{var l;const o=(l=a.actions)==null?void 0:l.filter(u=>u.action===he.SendData);o==null||o.forEach(u=>{var h;(h=u.data)==null||h.forEach(f=>{if(f.class==="iot"){let g=f.prop.split("#"),v=t.findIndex(y=>y.deviceId===g[0]);v>-1?t[v].properties.includes(g[1])||t[v].properties.push(g[1]):t.push({deviceId:g[0],properties:[g[1]],token:f.token})}})})})}),t.length&&(this.store.data.iot||(this.store.data.iot={}),this.store.data.iot.devices=t),i.length&&(this.store.data.iot.list=i)}connectSocket(){this.connectWebsocket(),this.connectMqtt(),this.connectHttp()}doInitJS(){const t=this.store.data.initJs;if(t&&t.trim())try{new Function("context",t)({meta2d:this})}catch(i){console.warn("initJs error",i)}}doInitFn(){let t=wn(),i=[];for(let s in t)t.hasOwnProperty(s)&&s.startsWith("bind-")&&i.push({id:s.replace("bind-",""),dataId:s.replace("bind-",""),value:t[s]});i.length&&this.setDatas(i,{history:!1})}drawLine(t){t&&ug(this.store),this.canvas.drawingLineName=t}alignPenToGrid(t){this.canvas.alignPenToGrid(t)}drawingPencil(){this.canvas.drawingPencil()}stopPencil(){this.canvas.stopPencil()}lock(t){this.store.data.locked=t,this.finishDrawLine(!0),this.canvas.drawingLineName="",this.stopPencil(),this.store.data.pens.forEach(i=>{var s;i.externElement===!0&&(s=i.calculative.singleton)!=null&&s.div&&Te(i,i.calculative.singleton.div)}),t>0&&this.initMessageEvents()}async finishDrawLine(t){await this.canvas.finishDrawline(t)}async finishPencil(){await this.canvas.finishPencil()}updateLineType(t,i){if(!t||t.name!="line"||!i||!this.canvas[i])return;t.lineName=i;const s=le(t),n=Vt(t);s.prev=void 0,s.next=void 0,n.prev=void 0,n.next=void 0,t.calculative.worldAnchors=[s,n],t.calculative.activeAnchor=s,this.canvas[i](this.store,t,n),t.lineName==="curve"&&(s.prev={penId:s.penId,x:s.x-50,y:s.y},s.next={penId:s.penId,x:s.x+50,y:s.y},n.prev={penId:n.penId,x:n.x-50,y:n.y},n.next={penId:n.penId,x:n.x+50,y:n.y}),t.calculative.activeAnchor=void 0,this.canvas.initLineRect(t),this.render()}addDrawLineFn(t,i){this.canvas[t]=i,this.canvas.drawLineFns.push(t)}removeDrawLineFn(t){const i=this.canvas.drawLineFns.indexOf(t);i>-1&&this.canvas.drawLineFns.splice(i,1)}showMagnifier(){this.canvas.showMagnifier()}hideMagnifier(){this.canvas.hideMagnifier()}toggleMagnifier(){this.canvas.toggleMagnifier()}clear(t=!0,i){var s;for(const n of this.store.data.pens)(s=n.onDestroy)==null||s.call(n,n);Px(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()}emit(t,i){this.store.emitter.emit(t,i)}on(t,i){return this.store.emitter.on(t,i),this}off(t,i){return this.store.emitter.off(t,i),this}registerMoveDock(t){this.canvas.customMoveDock=t}registerResizeDock(t){this.canvas.customResizeDock=t}find(t){return this.canvas.find(t)}findOne(t){return this.canvas.findOne(t)}getPenRect(t){return this.canvas.getPenRect(t)}setPenRect(t,i,s=!0){this.canvas.setPenRect(t,i,s)}startAnimate(t,i){this.stopAnimate(t);let s;t?typeof t=="string"?s=this.find(t):s=t:s=this.store.data.pens.filter(n=>(n.type||n.frames)&&n.autoPlay||n.animations&&n.animations.length&&n.animations.findIndex(r=>r.autoPlay)!==-1),s.length&&(s.forEach(n=>{var r,a;if(n.calculative.pause){const o=Date.now()-n.calculative.pause;n.calculative.pause=void 0,n.calculative.frameStart+=o,n.calculative.frameEnd+=o}else{let o=-1;if(i!==void 0&&n.animations){if(typeof i=="string"){if(o=n.animations.findIndex(l=>l.name===i),o===-1)return}else if(typeof i=="number")if(n.animations.length>i)o=i;else return}else i===void 0&&(o=(r=n.animations)==null?void 0:r.findIndex(l=>l.autoPlay),o===-1&&((a=n.animations)==null?void 0:a.length)&&(o=0));if(o!==-1&&o!==void 0){const l=ht(n.animations[o]);l.animateName=l.name,delete l.name,l.currentAnimation=o,!n.type&&l.frames&&(l.showDuration=this.calcAnimateDuration(l)),this.setValue({id:n.id,...l},{doEvent:!1,history:!1})}this.store.animates.add(n),n.type||this.store.animateMap.set(n,n.calculative.canvas.getFrameProps(n))}}),this.initImageCanvas(s),this.canvas.animate())}pauseAnimate(t){let i=[];t?typeof t=="string"?i=this.find(t):i=t:this.store.animates.forEach(s=>{i.push(s)}),i.forEach(s=>{s.calculative.pause||(s.calculative.pause=Date.now())})}stopAnimate(t){let i=[];t?typeof t=="string"?i=this.find(t):i=t:this.store.animates.forEach(s=>{i.push(s)}),i.forEach(s=>{s.currentAnimation=void 0,s.calculative.pause=void 0,s.calculative.start=void 0,s.calculative.duration=void 0,s.calculative.animatePos=0,this.store.animates.delete(s),this.canvas.restoreNodeAnimate(s),this.canvas.updateLines(s),this.store.animateMap.delete(s)}),this.initImageCanvas(i),setTimeout(()=>{var s;(s=this.canvas)==null||s.calcActiveRect(),this.render()},20)}startVideo(t){let i;t?typeof t=="string"?i=this.find(t):i=t:i=this.store.data.pens.filter(s=>(s.video||s.audio)&&s.autoPlay),i.forEach(s=>{var n,r;(n=s.calculative.media)==null||n.play(),(r=s.onStartVideo)==null||r.call(s,s)})}pauseVideo(t){let i=[];t?typeof t=="string"?i=this.find(t):i=t:i=this.store.data.pens.filter(s=>(s.video||s.audio)&&s.autoPlay),i.forEach(s=>{var n,r;(n=s.calculative.media)==null||n.pause(),(r=s.onPauseVideo)==null||r.call(s,s)})}stopVideo(t){let i=[];t?typeof t=="string"?i=this.find(t):i=t:i=this.store.data.pens.filter(s=>(s.video||s.audio)&&s.autoPlay),i.forEach(s=>{var n;s.calculative.media&&(s.calculative.media.currentTime=0,s.calculative.media.pause()),(n=s.onStopVideo)==null||n.call(s,s)})}calcAnimateDuration(t){return t.frames.reduce((i,s)=>i+s.duration,0)}combine(t=this.store.active,i,s=!0){if(!t||!t.length)return;const n=ht(t);if(t.length===1&&t[0].type){t[0].type=jt.Node,this.canvas.active(t),this.pushHistory({type:bt.Update,initPens:n,pens:ht(t,!0)}),this.render();return}const r=pi(t);let a={id:It(),name:"combine",...r,children:[],showChild:i};this.canvas.makePen(a);const o=ht(a);let l=1/0;return t.forEach(u=>{var g;const h=this.store.data.pens.findIndex(v=>v.id===u.id);if(h<l&&(l=h),u===a||u.parentId===a.id||u.id===a.id)return;a.children.push(u.id),u.parentId=a.id;const f=us(u.calculative.worldRect,r);Object.assign(u,f),u.locked=(g=u.lockedOnCombine)!=null?g:Ot.None,u.locked=u.interaction||_l.includes(u.name)?0:u.locked}),this.store.data.pens.splice(l,0,a),this.store.data.pens.pop(),s&&this.canvas.active([a]),this.pushHistory({type:bt.Add,pens:[o],step:3}),this.pushHistory({type:bt.Update,initPens:[o],pens:[a],step:3}),this.pushHistory({type:bt.Update,initPens:n,pens:t,step:3}),i!=null&&(t.forEach(u=>{Yi(u,!0)}),this.initImageCanvas([a])),this.store.emitter.emit("combine",[a]),this.render(),a}uncombine(t){if(!t&&this.store.active&&(t=this.store.active[0]),!t||!t.children)return;const i=t.children.map(r=>this.store.pens[r]);let s=ht(i);i.forEach(r=>{r.parentId=void 0,r.x=r.calculative.worldRect.x,r.y=r.calculative.worldRect.y,r.width=r.calculative.worldRect.width,r.height=r.calculative.worldRect.height,r.locked=Ot.None,r.calculative.active=void 0,r.calculative.hover=!1,this.setVisible(r,!0)});const n=this.isCombine(t)?3:2;this.pushHistory({type:bt.Update,initPens:s,pens:i,step:n}),s=[ht(t)],t.children=void 0,this.pushHistory({type:bt.Update,initPens:s,pens:[t],step:n}),this.isCombine(t)&&(this.delete([t]),this.store.histories[this.store.histories.length-1].step=n),this.inactive()}clearCombine(t){if(!t&&this.store.active&&(t=this.store.active[0]),!t||!t.children)return;const i=mi(t,this.store);i.forEach(n=>{n.parentId=void 0,n.x=n.calculative.worldRect.x,n.y=n.calculative.worldRect.y,n.width=n.calculative.worldRect.width,n.height=n.calculative.worldRect.height,n.locked=Ot.None,n.calculative.active=void 0,n.calculative.hover=!1,n.showChild!==void 0&&this.setVisible(n,!0),n.children=void 0});const s=[];i.forEach((n,r)=>{n.name==="combine"&&(n.children=void 0,s.push(n))}),this.delete(s,!0,!1),t.children=void 0,this.isCombine(t)&&this.delete([t],!0,!1),this.inactive()}appendChild(t=this.store.active){if(!t||t.length<2)return;const i=t.findIndex(s=>s.name==="combine"&&s.showChild!==void 0);if(i!==-1){let s=t[i];const n=pi(t);Object.assign(s,n),Object.assign(s.calculative.worldRect,n),En(s),s.children.forEach(r=>{const a=this.store.pens[r],o=us(a.calculative.worldRect,n);Object.assign(a,o)}),t.forEach(r=>{var a;if(r.id!==s.id){s.children.push(r.id),r.parentId=s.id;const o=us(r.calculative.worldRect,n);Object.assign(r,o),r.locked=(a=r.lockedOnCombine)!=null?a:Ot.DisableMove,r.locked=r.interaction||_l.includes(r.name)?0:r.locked,Yi(r,!0)}}),this.initImageCanvas(t),this.render()}else console.warn("Invalid operation!")}updateRectbyChild(t,i,s){if(ae(t),ee(t),i.calculative.worldRect=t,Xi(t,s.calculative.worldRect,!0)){const n=us(t,s.calculative.worldRect);Object.assign(i,n)}else{let n=Math.min(t.x,s.calculative.worldRect.x),r=Math.min(t.y,s.calculative.worldRect.y),a=Math.max(t.ex,s.calculative.worldRect.ex),o=Math.max(t.ey,s.calculative.worldRect.ey);s.calculative.worldRect={x:n,y:r,width:a-n,height:o-r,ex:a,ey:o},s.parentId||Object.assign(s,s.calculative.worldRect),ee(s.calculative.worldRect),s.children.forEach(l=>{const u=this.store.pens[l],h=us(u.calculative.worldRect,s.calculative.worldRect);Object.assign(u,h)}),s.parentId&&this.updateRectbyChild(s.calculative.worldRect,s,this.store.pens[s.parentId])}this.canvas.updatePenRect(s),this.render()}isCombine(t){return!!(t.name==="combine"||t.children&&t.children.length>0)}active(t,i=!0){this.canvas.active(t,i)}inactive(){this.canvas.inactive()}activeAll(){this.canvas.active(this.store.data.pens.filter(t=>!t.parentId&&t.locked!==Ot.Disable)),this.render()}focus(t){const i=this.findOne(t);i&&(this.store.hover=i,this.store.hover.calculative.hover=!0,this.showInput(i))}delete(t,i=!1,s=!0){this.canvas.delete(t,i,s)}scale(t,i={x:0,y:0}){this.canvas.scale(t,i)}translate(t,i){this.canvas.translate(t,i)}translatePens(t,i,s){this.canvas.translatePens(t,i,s)}getParent(t,i){return Ge(t,i)}getAllChildren(t){return mi(t,this.store)}getAllFollowers(t){return uc(t,this.store)}data(){const t=ht(this.store.data),{pens:i,paths:s}=this.store.data;t.version=Sd.version,t.paths={};for(const n in s)Object.prototype.hasOwnProperty.call(s,n)&&i.find(r=>r.pathId===n)&&(t.paths[n]=s[n]);return t.dataPoints=[...Object.keys(this.store.bind),...Object.keys(this.store.bindDatas)],t}copy(t){this.canvas.copy(t)}cut(t){this.canvas.cut(t)}paste(){this.canvas.paste()}undo(){this.canvas.undo()}redo(){this.canvas.redo()}listenSocket(){try{let t;const i=this.store.data.socketCbJs;if(i&&(t=new Function("e","context",i)),!t)return this.socketFn=null,!1;this.socketFn=t}catch(t){return console.error("Create the function for socket:",t),!1}return!0}connectWebsocket(t){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=i=>{this.socketCallback(i.data,{type:"websocket",url:this.store.data.websocket})},this.websocket.onerror=i=>{this.store.emitter.emit("error",{type:"websocket",error:i})},this.websocket.onclose=()=>{if(this.store.options.reconnetTimes&&(this.websocketTimes++,this.websocketTimes>=this.store.options.reconnetTimes)){this.websocketTimes=0,this.closeWebsocket();return}console.info("Canvas websocket closed and reconneting..."),this.connectWebsocket()})}closeWebsocket(){this.websocket&&(this.websocket.onclose=void 0,this.websocket.close(),this.websocket=void 0)}connectMqtt(t){if(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=It());const i={...this.store.data.mqttOptions};i.username||delete i.username,i.password||delete i.password;const{username:s,password:n}=i;s&&n||!s&&!n?(this.mqttClient=er.exports.connect(this.store.data.mqtt,i),this.mqttClient.on("message",(r,a)=>{this.socketCallback(a.toString(),{topic:r,type:"mqtt",url:this.store.data.mqtt})}),this.mqttClient.on("error",r=>{this.store.emitter.emit("error",{type:"mqtt",error:r})}),this.mqttClient.on("close",()=>{this.store.options.reconnetTimes&&(this.mqttTimes++,this.mqttTimes>=this.store.options.reconnetTimes&&(this.mqttTimes=0,this.closeMqtt()))}),this.store.data.mqttTopics&&this.mqttClient.subscribe(this.store.data.mqttTopics.split(","))):console.warn("\u7F3A\u5C11\u7528\u6237\u540D\u6216\u5BC6\u7801")}}closeMqtt(){var t;(t=this.mqttClient)==null||t.end()}connectHttp(){this.closeHttp();const{https:t}=this.store.data;if(t)this.store.data.cancelFirstConnect||t.forEach(async i=>{this.oldRequestHttp(i)}),t.forEach((i,s)=>{i.http&&i.httpTimeInterval!==0&&(i.times=0,this.httpTimerList[s]=setInterval(async()=>{this.oldRequestHttp(i),this.store.options.reconnetTimes&&i.times>=this.store.options.reconnetTimes&&(i.times=0,clearInterval(this.httpTimerList[s]),this.httpTimerList[s]=void 0)},i.httpTimeInterval||1e3))});else{const{http:i,httpTimeInterval:s,httpHeaders:n}=this.store.data;i&&(this.httpTimer=setInterval(async()=>{const r=await fetch(i,{headers:n});if(r.ok){const a=await r.text();this.socketCallback(a,{type:"http",url:i})}},s||1e3))}}async oldRequestHttp(t){let i=ht(t);if(i.http){const s=await fetch(i.http,{headers:i.httpHeaders,method:i.method||"GET",body:i.method==="POST"?JSON.stringify(i.body):void 0});if(s.ok){const n=await s.text();this.socketCallback(n,{type:"http",url:i.http})}else t.times++,this.store.emitter.emit("error",{type:"http",error:s})}}async sendDatabyHttp(t){const{https:i}=this.store.data;if(i)i.forEach(async s=>{s.http&&(await fetch(s.http,{method:"post",body:t,headers:s.httpHeaders})).ok&&console.info("http\u6D88\u606F\u53D1\u9001\u6210\u529F")});else{const{http:s,httpHeaders:n}=this.store.data;s&&(await fetch(s,{method:"post",body:t,headers:n})).ok&&console.info("http\u6D88\u606F\u53D1\u9001\u6210\u529F")}}closeHttp(){clearInterval(this.httpTimer),this.httpTimer=void 0,this.httpTimerList&&this.httpTimerList.forEach(t=>{clearInterval(t),t=void 0})}connectNetwork(){this.closeNetwork();const{networks:t}=this.store.data,i=[];if(t){let s=0,n=0,r=0,a=0;this.mqttClients=[],this.websockets=[],this.eventSources=[],t.forEach(async o=>{o.protocol==="mqtt"?(o.index=s,this.connectNetMqtt(o),s+=1):o.protocol==="websocket"?(o.index=r,this.connectNetWebSocket(o),r+=1):o.protocol==="http"?(o.index=n,i.push({url:o.url,interval:o.interval,headers:o.headers||void 0,method:o.method,body:o.body}),n+=1):o.protocol==="ADIIOT"?ik(this,o):o.protocol==="SSE"&&(o.index=a,this.connectSSE(o),a+=1)})}this.onNetworkConnect(i),this.connectIot(),this.connectSqls()}reconnectNetwork(t){var s,n;const i=this.store.data.networks[t];if(i.protocol==="mqtt")this.mqttClients&&((s=this.mqttClients[i.index])==null||s.end()),this.connectNetMqtt(i);else if(i.protocol==="websocket")this.websockets&&this.websockets[i.index]&&(this.websockets[i.index].onclose=void 0,this.websockets[i.index].close(),this.websockets[i.index]=void 0),this.connectNetWebSocket(i);else if(i.protocol==="http"){this.updateTimerList&&(clearInterval(this.updateTimerList[i.index]),this.updateTimerList[i.index]=void 0);const r=ht(i);this.store.data.cancelFirstConnect||this.requestHttp(r),this.updateTimerList[i.index]=setInterval(async()=>{this.requestHttp(r)},r.interval||1e3)}else i.protocol==="SSE"&&(this.eventSources&&((n=this.eventSources[i.index])==null||n.close(),this.eventSources[i.index]=void 0),this.connectSSE(i))}async connectIot(){var n;const{iot:t}=this.store.data;if(!(t&&((n=t==null?void 0:t.devices)==null?void 0:n.length)))return;const i=globalThis.iotUrl||await this.getMqttUrl();if(!i){console.warn("iot Request address error");return}const s=await this.getIotToken(t.devices,t.protocol==="websocket"?1:void 0);t.token=s,this.iotMqttClient=er.exports.connect(i),this.iotMqttClient.on("message",(r,a)=>{this.socketCallback(a.toString(),{topic:`le5le-iot/properties/${s}`,type:"iot",url:i,method:"mqtt"})}),this.iotMqttClient.on("error",r=>{this.store.emitter.emit("error",{type:"mqtt",error:r})}),this.iotMqttClient.subscribe(`le5le-iot/properties/${s}`),this.iotTimer=setInterval(()=>{this.iotMqttClient&&this.iotMqttClient.publish("le5le-iot/subscribe/ping",s)},3e5)}connectSqls(){const{sqls:t}=this.store.data;if(t&&t.length){let i=0;t.forEach(async s=>{await this.doSqlCode(s),s.interval&&(s.index=i,this.sqlTimerList[i]=setInterval(async()=>{await this.doSqlCode(s)},s.interval),i+=1)})}}connectSSE(t){this.eventSources[t.index]=new EventSource(t.url,{withCredentials:t.withCredentials}),this.eventSources[t.index].onmessage=i=>{this.socketCallback(i.data,{type:"SSE",url:t.url})},this.eventSources[t.index].onerror=i=>{this.store.emitter.emit("error",{type:"SSE",error:i})}}closeSSE(){this.eventSources&&this.eventSources.forEach(t=>{t&&(t.close(),t=void 0)})}connectNetMqtt(t){var s;t.options.clientId&&!t.options.customClientId&&(t.options.clientId=It());let i=t.url;if(i.indexOf("${")>-1){let n=(s=i.match(/\$\{([^}]+)\}/g))==null?void 0:s.map(r=>r.slice(2,-1));n&&n.forEach(r=>{i=i.replace(`\${${r}}`,this.getDynamicParam(r))})}t.times=0,this.mqttClients[t.index]=er.exports.connect(i,t.options),this.mqttClients[t.index].on("message",(n,r)=>{this.socketCallback(r.toString(),{topic:n,type:"mqtt",url:t.url})}),this.mqttClients[t.index].on("error",n=>{this.store.emitter.emit("error",{type:"mqtt",error:n})}),this.mqttClients[t.index].on("close",()=>{var n;this.store.options.reconnetTimes&&(t.times++,t.times>=this.store.options.reconnetTimes&&(t.times=0,this.mqttClients&&((n=this.mqttClients[t.index])==null||n.end())))}),t.topics&&this.mqttClients[t.index].subscribe(t.topics.split(","))}connectNetWebSocket(t){var s,n;this.websockets[t.index]&&(this.websockets[t.index].onclose=void 0,(s=this.websockets[t.index])==null||s.close(),this.websockets[t.index]=void 0);let i=t.url;if(i.indexOf("${")>-1){let r=(n=i.match(/\$\{([^}]+)\}/g))==null?void 0:n.map(a=>a.slice(2,-1));r&&r.forEach(a=>{i=i.replace(`\${${a}}`,this.getDynamicParam(a))})}this.websockets[t.index]=new WebSocket(i,t.protocols||void 0),this.websockets[t.index].onmessage=r=>{this.socketCallback(r.data,{type:"websocket",url:t.url})},this.websockets[t.index].onerror=r=>{this.store.emitter.emit("error",{type:"websocket",error:r})},this.websockets[t.index].onclose=()=>{var r;if(this.store.options.reconnetTimes&&(t.times++,t.times>=this.store.options.reconnetTimes)){t.times=0,this.websockets[t.index].onclose=void 0,(r=this.websockets[t.index])==null||r.close(),this.websockets[t.index]=void 0;return}setTimeout(()=>{console.info("Canvas websocket closed and reconneting..."),this.connectNetWebSocket(t)},2e3)}}async getMqttUrl(){const t=await fetch("/api/iot/app/mqtt",{method:"GET",headers:{Authorization:`Bearer ${ql()}`}});if(t.ok){const i=await t.text();let s=JSON.parse(i);return s.wssPort||s.wsPort?`${location.protocol==="https:"?"wss":"ws"}://${s.host}:${location.protocol==="https:"?s.wssPort:s.wsPort}${s.path}`:void 0}}async getIotToken(t,i){const s=await fetch("/api/iot/subscribe/properties",{method:"POST",headers:{Authorization:`Bearer ${ql()}`},body:JSON.stringify({devices:t,type:i})});if(s.ok){const n=await s.text();return JSON.parse(n).token}}async doSqlCode(t){var r;const i=t.method||"get";let s=t.sql;i==="list"&&(s+=` LIMIT ${t.pageSize||20}`+(t.current>1?" OFFSET "+(t.current-1)*t.pageSize:""));const n=await fetch(`/api/iot/data/sql/${i}`,{method:"POST",headers:{Authorization:`Bearer ${dr("token")||localStorage.getItem("token")||new URLSearchParams(location.search).get("token")||""}`},body:JSON.stringify({dbid:t.dbid,sql:s})});if(n.ok){let a=await n.text();if(a){const o=[];a=JSON.parse(a),(r=t.keys)==null||r.forEach(l=>{o.push({id:t.bindId+"#"+l,value:ys(a,l.split("#").join("."))})}),o.push({id:t.bindId,value:a}),this.socketCallback(JSON.stringify(o),{type:"sql",url:`/api/iot/data/sql/${i}`,method:i})}}}randomString(t){t=t||32;let i="ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678",s=i.length,n="";for(let r=0;r<t;r++)n+=i.charAt(Math.floor(Math.random()*s));return n}mockValue(t){let i;if(t.enableMock&&t.mock!==void 0)if(t.type==="float")if(t.mock&&t.mock.indexOf(",")!==-1){let s=t.mock.split(","),n=Math.floor(Math.random()*s.length);i=parseFloat(s[n])}else if(t.mock&&t.mock.indexOf("-")!==-1){let s,n,r,a=t.mock.split("-");if(t.mock.charAt(0)==="-"?a.length===4?(s=-parseFloat(a[3]),n=-parseFloat(a[1]),r=a[3]):(s=parseFloat(a[2]),n=-parseFloat(a[1]),r=a[2]):(s=parseFloat(a[1]),n=parseFloat(a[0]),r=a[1]),(r+"").indexOf(".")!==-1){let o=(r+"").split(".")[1].length;i=(Math.random()*(s-n)+n).toFixed(o)}else i=Math.random()*(s-n)+n}else i=parseFloat(t.mock);else if(t.type==="integer")if(t.mock&&t.mock.indexOf(",")!==-1){let s=t.mock.split(","),n=Math.floor(Math.random()*s.length);i=parseInt(s[n])}else if(t.mock&&t.mock.indexOf("-")!==-1){let s,n,r=t.mock.split("-");t.mock.charAt(0)==="-"?r.length===4?(s=-parseFloat(r[3]),n=-parseFloat(r[1])):(s=parseFloat(r[2]),n=-parseFloat(r[1])):(s=parseInt(r[1]),n=parseInt(r[0])),i=parseInt(Math.random()*(s-n)+n+"")}else i=parseInt(t.mock);else if(t.type==="bool")typeof t.mock=="boolean"?i=t.mock:t.mock==="true"?i=!0:t.mock==="false"?i=!1:i=Math.random()<.5;else if(t.type==="object"||t.type==="array")t.mock;else if(t.mock&&t.mock.indexOf(",")!==-1){let s=t.mock.split(","),n=Math.floor(Math.random()*s.length);i=s[n]}else if(t.mock&&t.mock.startsWith("[")&&t.mock.endsWith("]")){let s=parseInt(t.mock.substring(1,t.mock.length-1));i=this.randomString(s)}else i=t.mock;return i}dataMock(){var i,s;let t=[];(s=(i=this.store.data.dataset)==null?void 0:i.devices)==null||s.forEach(n=>{let r=this.mockValue(n);r!==void 0&&t.push({id:n.id,value:r})}),t.length&&this.setDatas(t,{render:!0,doEvent:!0,history:!1})}startDataMock(){this.store.data.enableMock&&(this.stopDataMock(),this.initBinds(),this.updateTimer=setInterval(()=>{this.store.data.pens.forEach(i=>{this.penMock(i)}),this.dataMock(),this.render()},this.store.data.networkInterval||1e3))}stopDataMock(){clearInterval(this.updateTimer),this.updateTimer=void 0}penMock(t){var i;if(t.realTimes){let s={};if(t.realTimes.forEach(n=>{let r=this.mockValue(n);r!==void 0&&(s[n.key]=r)}),Object.keys(s).length){let n=t.onBeforeValue?t.onBeforeValue(t,s):s;this.canvas.updateValue(t,n),(i=t.onValue)==null||i.call(t,t),this.store.emitter.emit("valueUpdate",t)}}}penNetwork(t){const i={url:t.apiUrl,method:t.apiMethod,headers:t.apiHeaders,body:t.apiBody};this.requestHttp(i),t.apiEnable?(this.store.pensNetwork||(this.store.pensNetwork={}),this.store.pensNetwork[t.id]=i):delete this.store.pensNetwork[t.id]}getDynamicParam(t){return wn()[t]||localStorage[t]||dr(t)||globalThis[t]||""}onNetworkConnect(t){if(!!(t&&t.length)){if(this.store.pensNetwork)for(let i in this.store.pensNetwork)t.push(this.store.pensNetwork[i]);this.store.data.cancelFirstConnect||t.forEach(async i=>{this.requestHttp(i)}),t.forEach((i,s)=>{i.times=0,i.interval!==0&&(this.updateTimerList[s]=setInterval(async()=>{this.requestHttp(i),this.store.options.reconnetTimes&&i.times>=this.store.options.reconnetTimes&&(i.times=0,clearInterval(this.updateTimerList[s]),this.updateTimerList[s]=void 0)},i.interval||1e3))})}}async requestHttp(t){var s,n,r;let i=ht(t);if(i.url){if(i.url.indexOf("${")>-1){let o=(s=i.url.match(/\$\{([^}]+)\}/g))==null?void 0:s.map(l=>l.slice(2,-1));o&&o.forEach(l=>{i.url=i.url.replace(`\${${l}}`,this.getDynamicParam(l))})}if(typeof i.headers=="object"){for(let o in i.headers)if(typeof i.headers[o]=="string"){let l=(n=i.headers[o].match(/\$\{([^}]+)\}/g))==null?void 0:n.map(u=>u.slice(2,-1));l&&(i.headers[o]=i.headers[o].replace(`\${${l[0]}}`,this.getDynamicParam(l[0])))}}if(typeof i.body=="object"){for(let o in i.body)if(typeof i.body[o]=="string"){let l=(r=i.body[o].match(/\$\{([^}]+)\}/g))==null?void 0:r.map(u=>u.slice(2,-1));l&&(i.body[o]=i.body[o].replace(`\${${l[0]}}`,this.getDynamicParam(l[0])))}}const a=await fetch(i.url,{headers:i.headers,method:i.method,body:i.method==="GET"?void 0:JSON.stringify(i.body)});if(a.ok){const o=await a.text();this.socketCallback(o,{type:"http",url:i.url})}else t.times++,this.store.emitter.emit("error",{type:"http",error:a})}}closeNetwork(){this.mqttClients&&this.mqttClients.forEach(t=>{t.end()}),this.websockets&&this.websockets.forEach(t=>{t&&(t.onclose=void 0,t.close(),t=void 0)}),this.mqttClients=void 0,this.websockets=void 0,this.updateTimerList&&this.updateTimerList.forEach(t=>{clearInterval(t),t=void 0}),this.sqlTimerList&&this.sqlTimerList.forEach(t=>{clearInterval(t),t=void 0}),this.iotMqttClient&&(this.iotMqttClient.end(),this.iotMqttClient=void 0),clearInterval(this.iotTimer),this.iotTimer=void 0,nk(this),this.closeSSE()}socketCallback(t,i){this.store.emitter.emit("socket",{message:t,context:i});let s=t;if(this.socketFn&&(s=this.socketFn(t,{meta2d:this,type:i.type,topic:i.topic,url:i.url,method:i.method}),!s))return;s===!0&&(s=t);let n;if(s.constructor===Object||s.constructor===Array)n=s;else if(typeof s=="string")try{n=JSON.parse(s)}catch(r){console.warn("Invalid socket data:",n,r)}else return;!n||(Array.isArray(n)||(n=[n]),n.length&&(n[0].dataId?this.setDatas(n):n.forEach(r=>{this.setValue(r)})))}setDatas(t,{render:i=!0,doEvent:s=!0,history:n}={}){const r=new Map;t.forEach(l=>{var u,h;(u=this.store.bindDatas[l.dataId])==null||u.forEach(f=>{const g=this.store.pens[f.id];if(!g)return;let v=r.get(g);if(!g.noOnBinds&&typeof g.onBinds=="function"){if(v)return;r.set(g,g.onBinds(g,t,f.formItem));return}v?v[f.formItem.key]=l.value:(v={id:f.id,[f.formItem.key]:l.value},r.set(g,v))}),(h=this.store.bind[l.id||l.dataId])==null||h.forEach(f=>{const g=this.store.pens[f.id];if(!g)return;let v=r.get(g);v?v[f.key]=l.value:(v={id:f.id,[f.key]:l.value},r.set(g,v))})}),this.store.data.locked&&this.doDataEvent(t);let a,o;n&&(a=[]),r.forEach((l,u)=>{this.setValue(l,{render:!1,doEvent:s,history:!1}),n&&(a.push(ht(u,!0)),o.push(u))}),i&&this.render(),n&&this.pushHistory({type:bt.Update,initPens:a,pens:o})}setValue(t,{render:i=!0,doEvent:s=!0,history:n}={}){let r=[];if(!t)return;if(t.id){if(t.id===this.store.data.id){this.setDatabyOptions(t),t.bkImage&&this.setBackgroundImage(t.bkImage),t.background&&this.setBackgroundColor(t.background),this.render();return}const o=this.store.pens[t.id];if(o)r=[o];else{let l=this.store.bind[t.id];if(l&&l.length){r=[],this.setDatas([t],{render:i,doEvent:s,history:n});return}}}else if(t.dataId){r=[],this.setDatas([t],{render:i,doEvent:s,history:n});return}else if(t.tag)r=this.find(t.tag);else{let o=[];for(let l in t)o.push({dataId:l,id:l,value:t[l]});o.length&&this.setDatas(o,{render:i,doEvent:s,history:n});return}n=n&&!this.store.data.locked;let a;if(n&&(a=ht(r)),r.forEach(o=>{var u;const l=o.onBeforeValue?o.onBeforeValue(o,t):t;t.frames&&(this.stopAnimate([o]),t.showDuration||(t.showDuration=t.frames.reduce((h,f)=>h+f.duration,0))),yc(o,l),this.canvas.updateValue(o,l),(u=o.onValue)==null||u.call(o,o)}),!this.store.data.locked&&this.store.active.length&&!this.canvas.movingPens&&this.canvas.calcActiveRect(),n){let o=ht(r);this.pushHistory({type:bt.Update,initPens:a,pens:o})}s&&r.forEach(o=>{this.store.emitter.emit("valueUpdate",o)}),i&&this.render()}_setValue(t,i=!1){this.setValue(t,{history:i,render:!1,doEvent:!1})}pushHistory(t){this.canvas.pushHistory(t)}showInput(t,i){this.canvas.showInput(t,i)}hideInput(){this.canvas.hideInput()}clearDropdownList(){this.canvas.clearDropdownList()}clearRuleLines(){this.canvas.clearRuleLines()}doMessageEvent(t,i){this.store.messageEvents[t]&&this.store.messageEvents[t].forEach(s=>{let n=!1;s.event.conditions&&s.event.conditions.length?s.event.conditionType==="and"?n=s.event.conditions.every(r=>this.judgeCondition(s.pen,r.key,r)):s.event.conditionType==="or"&&(n=s.event.conditions.some(r=>this.judgeCondition(s.pen,r.key,r))):n=!0,n&&s.event.actions.forEach(r=>{this.events[r.action](s.pen,r,i)})})}initGlobalTriggers(){var t;this.store.globalTriggers={},(t=this.store.data.triggers)==null||t.forEach(i=>{i.conditions.forEach(s=>{s.source&&(this.store.globalTriggers[s.source]||(this.store.globalTriggers[s.source]=[]),this.store.globalTriggers[s.source].includes(i)||this.store.globalTriggers[s.source].push(i))})})}initMessageEvents(){this.store.messageEvents={},this.store.data.pens.forEach(t=>{var i;(i=t.events)==null||i.forEach(s=>{s.name==="message"&&s.message&&(this.store.messageEvents[s.message]||(this.store.messageEvents[s.message]=[]),this.store.messageEvents[s.message].push({pen:t,event:s}))})})}dataJudegeCondition(t,i,s){const{type:n,target:r,fnJs:a,fn:o,operator:l,valueType:u}=s;let h=!1;if(n==="fn"){if(o)h=o(t,{meta2d:this});else if(a){try{s.fn=new Function("data","context",a)}catch(f){console.error("Error: make function:",f)}s.fn&&(h=s.fn(t,{meta2d:this}))}}else{let f=s.value;u==="prop"&&(f=t[s.value]);let g=t[i];switch(l){case">":h=g>+f;break;case">=":h=g>=+f;break;case"<":h=g<+f;break;case"<=":h=g<=+f;break;case"=":case"==":h=g==f;break;case"!=":h=g!=f;break;case"[)":h=fn(+g,f);break;case"![)":h=!fn(+g,f);break;case"[]":h=dn(g,f);break;case"![]":h=!dn(g,f);break}}return h}judgeCondition(t,i,s){const{type:n,target:r,fnJs:a,fn:o,operator:l,valueType:u}=s;let h=!1;if(n==="fn"){if(o)h=o(t,{meta2d:this});else if(a){try{s.fn=new Function("pen","context",a)}catch(f){console.error("Error: make function:",f)}s.fn&&(h=s.fn(t,{meta2d:this}))}}else{let f=s.value;u==="prop"&&(f=this.store.pens[r][s.value]);let g=ys(t,i);switch(["x","y","width","height"].includes(i)&&(g=this.getPenRect(t)[i]),l){case">":h=g>+f;break;case">=":h=g>=+f;break;case"<":h=g<+f;break;case"<=":h=g<=+f;break;case"=":case"==":h=g==f;break;case"!=":h=g!=f;break;case"[)":h=fn(+g,f);break;case"![)":h=!fn(+g,f);break;case"[]":h=dn(g,f);break;case"![]":h=!dn(g,f);break}}return h}pushChildren(t,i){const s=[ht(t,!0)],n=[];t.children||(t.children=[]);const r=[];i.forEach(o=>{var h;let l=ht(o,!0);if((!o.id||!this.store.pens[o.id])&&(this.canvas.makePen(o),l=null),o.parentId){const f=this.store.pens[o.parentId],g=f.children.findIndex(v=>v===o.id);s.push(ht(f,!0)),f.children.splice(g,1),r.push(ht(f,!0))}t.children.push(o.id),o.parentId=t.id;const u=us(o.calculative.worldRect,t.calculative.worldRect);Object.assign(o,u),o.locked=(h=o.lockedOnCombine)!=null?h:Ot.DisableMove,o.locked=o.interaction||_l.includes(o.name)?0:o.locked,l?(s.push(l),r.push(ht(o,!0))):n.push(ht(o,!0))}),r.push(ht(t,!0));let a=1;n.length&&(a=2,this.pushHistory({type:bt.Add,pens:n,step:a})),this.pushHistory({type:bt.Update,initPens:s,pens:r,step:a})}toPng(t,i,s=!1,n){return this.canvas.toPng(t,i,s,n)}activeToPng(t,i){return this.canvas.activeToPng(t,i)}pensToPng(t=this.store.active,i,s){return this.canvas.pensToPng(t,i,s)}downloadPng(t,i,s){var n;for(const r of this.store.data.pens)(r.calculative.img||["iframe"].includes(r.name))&&((n=r.onRenderPenRaw)==null||n.call(r,r));setTimeout(()=>{const r=document.createElement("a");r.setAttribute("download",(t||this.store.data.name||"le5le.meta2d")+".png"),r.setAttribute("href",this.toPng(i,void 0,!0,s));const a=document.createEvent("MouseEvents");a.initEvent("click",!0,!0),r.dispatchEvent(a)},1e3)}downloadSvg(){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");let t=!1;const i=this.store.data.width||this.store.options.width,s=this.store.data.height||this.store.options.height;i&&s&&!this.store.data.component&&(t=!0);const n=this.getRect();t&&(n.x=this.store.data.origin.x,n.y=this.store.data.origin.y,n.width=i*this.store.data.scale,n.height=s*this.store.data.scale),n.x-=10,n.y-=10;const r=new window.C2S(n.width+20,n.height+20);r.textBaseline="middle",r.strokeStyle=this.store.styles.color;const a=this.store.data.background||this.store.styles.background;a&&t&&(r.save(),r.fillStyle=a,r.fillRect(0,0,n.width,n.height),r.restore()),this.store.bkImg&&t&&r.drawImage(this.store.bkImg,0,0,n.width,n.height),a&&!t&&(r.save(),r.fillStyle=a,r.fillRect(0,0,n.width+20,n.height+20),r.restore());for(const v of this.store.data.pens)v.visible==!1||!Ua(v,this.store)||v.name==="combine"&&!v.draw||Wa(r,v,n,!0);let o=r.getSerializedSvg();this.store.data.background?(o=o.replace("{{bk}}",""),o=o.replace("{{bkRect}}",`<rect x="0" y="0" width="100%" height="100%" fill="${this.store.data.background}"></rect>`)):(o=o.replace("{{bk}}",""),o=o.replace("{{bkRect}}","")),o=o.replace(/--le5le--/g,"&#x");const l=window.URL,u=new Blob([o]),h=l.createObjectURL(u),f=document.createElement("a");f.setAttribute("download",`${this.store.data.name||"le5le.meta2d"}.svg`),f.setAttribute("href",h);const g=document.createEvent("MouseEvents");g.initEvent("click",!0,!0),f.dispatchEvent(g)}getRect(t=this.store.data.pens){return pi(t)}hiddenTemplate(){this.canvas.canvasTemplate.hidden()}showTemplate(){this.canvas.canvasTemplate.show()}lockTemplate(t){this.store.data.pens.forEach(i=>{i.canvasLayer===zt.CanvasTemplate&&(i.locked=t)})}fitView(t=!0,i=10){var f,g;if(!this.hasView())return;const{canvas:s}=this.canvas,{offsetWidth:n,offsetHeight:r}=s;this.resize(n,r);const a=qi(i),o=this.getRect(),l=(n-a[1]-a[3])/o.width,u=(r-a[0]-a[2])/o.height;let h=l;t?h=l>u?u:l:h=l>u?l:u,(f=this.store.data.fits)!=null&&f.length&&(this.canvas.opening=!0),this.scale(h*this.store.data.scale),this.centerView(),(g=this.store.data.fits)!=null&&g.length&&this.fillView()}fillView(){var n,r;const t=this.getRect(),i=this.canvas.width-t.width,s=this.canvas.height-t.height;if(Math.abs(i)>10){(n=this.store.data.fits)==null||n.forEach(o=>{let l=[];o.children.forEach(h=>{this.store.pens[h]&&(this.store.pens[h].locked=Ot.None,l.push(this.store.pens[h]))});let u=i/2;if(o.left&&o.right){let h=o.leftValue,f=o.rightValue;h?h=Math.abs(h)<1?h*this.canvas.width:h:h=0,f?f=Math.abs(f)<1?f*this.canvas.width:f:f=0;let g=(this.canvas.width-h-f)/(t.width-h-f);l.forEach(v=>{var y;v.image&&v.imageRatio&&v.calculative.worldRect.width/this.canvas.width>.1&&(v.imageRatio=!1),v.calculative.worldRect.x=t.x-i/2+h+(v.calculative.worldRect.x-t.x)*g,v.calculative.worldRect.width*=g,v.calculative.worldRect.ex=v.calculative.worldRect.x+v.calculative.worldRect.width,v.calculative.width=v.calculative.worldRect.width,v.calculative.x=v.calculative.worldRect.x,v.width=v.calculative.worldRect.width,v.x=v.calculative.worldRect.x,this.canvas.updatePenRect(v,{worldRectIsReady:!1}),v.externElement&&((y=v.onResize)==null||y.call(v,v))})}else o.left?(u=-u,o.leftValue&&(u+=Math.abs(o.leftValue)<1?o.leftValue*this.canvas.width:o.leftValue),this.translatePens(l,u,0)):o.right&&(o.rightValue&&(u=u-(Math.abs(o.rightValue)<1?o.rightValue*this.canvas.width:o.rightValue)),this.translatePens(l,u,0))});const a=this.store.data.pens.filter(o=>o.name==="iframe");a==null||a.forEach(o=>{var u,h;const l=o.calculative.worldRect;if(l.width/this.store.data.scale>t.width*.8){let f=l.width;o.calculative.worldRect.x=l.x-i/2,o.calculative.worldRect.width=l.width+i,o.calculative.worldRect.ex=l.ex+i,o.operationalRect.x=o.operationalRect.x*f/o.calculative.worldRect.width,o.operationalRect.width=(o.calculative.worldRect.width-(1-o.operationalRect.width)*f)/o.calculative.worldRect.width,(u=o.onBeforeValue)==null||u.call(o,o,{operationalRect:o.operationalRect}),(h=o.onResize)==null||h.call(o,o)}})}if(Math.abs(s)>10){(r=this.store.data.fits)==null||r.forEach(o=>{let l=[];o.children.forEach(h=>{this.store.pens[h]&&(this.store.pens[h].locked=Ot.None,l.push(this.store.pens[h]))});let u=s/2;if(o.top&&o.bottom){let h=o.topValue,f=o.bottomValue;h?h=Math.abs(h)<1?h*this.canvas.height:h:h=0,f?f=Math.abs(f)<1?f*this.canvas.height:f:f=0;let g=(this.canvas.height-h-f)/(t.height-h-f);l.forEach(v=>{var y;v.image&&v.imageRatio&&v.calculative.worldRect.height/this.canvas.height>.1&&(v.imageRatio=!1),v.calculative.worldRect.y=t.y-s/2+h+(v.calculative.worldRect.y-t.y)*g,v.calculative.worldRect.height*=g,v.calculative.worldRect.ey=v.calculative.worldRect.y+v.calculative.worldRect.height,v.calculative.height=v.calculative.worldRect.height,v.calculative.y=v.calculative.worldRect.y,v.height=v.calculative.worldRect.height,v.y=v.calculative.worldRect.y,this.canvas.updatePenRect(v,{worldRectIsReady:!1}),v.externElement&&((y=v.onResize)==null||y.call(v,v))})}else o.top?(u=-u,o.topValue&&(u+=Math.abs(o.topValue)<1?o.topValue*this.canvas.height:o.topValue),this.translatePens(l,0,u)):o.bottom&&(o.bottomValue&&(u=u-(Math.abs(o.bottomValue)<1?o.bottomValue*this.canvas.height:o.bottomValue)),this.translatePens(l,0,u))});const a=this.store.data.pens.filter(o=>o.name==="iframe");a==null||a.forEach(o=>{var u,h;const l=o.calculative.worldRect;if(l.height/this.store.data.scale>t.height*.8){let f=l.height;o.calculative.worldRect.y=l.y-s/2,o.calculative.worldRect.height=l.height+s,o.calculative.worldRect.ey=l.ey+s,o.operationalRect.y=o.operationalRect.y*f/o.calculative.worldRect.width,o.operationalRect.height=(o.calculative.worldRect.height-(1-o.operationalRect.height)*f)/o.calculative.worldRect.height,(u=o.onBeforeValue)==null||u.call(o,o,{operationalRect:o.operationalRect}),(h=o.onResize)==null||h.call(o,o)}})}this.canvas.canvasTemplate.fit=!0,this.canvas.canvasTemplate.init(),this.canvas.canvasImage.init(),this.canvas.canvasImageBottom.init(),this.render(!0)}trimPens(){let t=this.store.data.pens.filter(i=>i.name==="line"&&i.anchors.length<2);this.delete(t)}fitTemplateView(t=!0,i=10){if(!this.hasView())return;const{canvas:s}=this.canvas,{offsetWidth:n,offsetHeight:r}=s,a=qi(i),o=this.getRect(),l=(n-a[1]-a[3])/o.width,u=(r-a[0]-a[2])/o.height;let h=l;t?h=l>u?u:l:h=l>u?l:u,this.canvas.templateScale(h*this.store.data.scale);let f=this.getRect(),g=this.store.data.pens.filter(v=>!v.parentId);this.canvas.templateTranslatePens(g,-f.x,-f.y),this.store.data.pens.forEach(v=>{v.type?this.canvas.initLineRect(v):this.canvas.updateLines(v)}),this.centerView()}fitSizeView(t=!0,i=10){var g,v;const{canvas:s}=this.canvas,{offsetWidth:n,offsetHeight:r}=s;this.resize(n,r);const a=qi(i),o=(this.store.data.width||this.store.options.width)*this.store.data.scale,l=(this.store.data.height||this.store.options.height)*this.store.data.scale,u=(n-a[1]-a[3])/o,h=(r-a[0]-a[2])/l;let f=u;t==="width"?f=u:t==="height"?f=h:t?f=u>h?h:u:f=u>h?u:h,(g=this.store.data.fits)!=null&&g.length&&(this.canvas.opening=!0),this.scale(f*this.store.data.scale),this.centerSizeView(),(v=this.store.data.fits)!=null&&v.length&&this.fillView()}centerSizeView(){const t=this.getViewCenter(),i=this.store.data.width||this.store.options.width,s=this.store.data.height||this.store.options.height,n={x:0,y:0,width:i,height:s};ee(n);const{center:r}=n,{scale:a,origin:o,x:l,y:u}=this.store.data;this.translate((t.x-o.x)/a-r.x-l/a,(t.y-o.y)/a-r.y-u/a);const{canvas:h}=this.canvas,f=(h.scrollWidth-h.offsetWidth)/2,g=(h.scrollHeight-h.offsetHeight)/2;h.scrollTo(f,g)}scrollView(t=10,i=!1){if(!this.hasView()||!this.canvas.scroll)return;const{canvas:s}=this.canvas,{offsetWidth:n,offsetHeight:r}=s;this.resize(n,r);const a=qi(t),o=this.getRect(),l=(n-a[1]-a[3])/o.width;this.scale(l*this.store.data.scale),this.topView(a[0]),i&&this.canvas.scroll.changeMode()}screenView(t=10,i=!0){if(!this.hasView())return;const{canvas:s}=this.canvas,{offsetWidth:n,offsetHeight:r}=s;this.resize(n,r);const a=qi(t),o=this.getRect();let l=(n-a[1]-a[3])/o.width;i||(l=(r-a[0]-a[2])/o.height),this.scale(l*this.store.data.scale),this.topView(a[0])}topView(t=10){if(!this.hasView())return;const i=this.getRect(),s=this.getViewCenter(),n=this.getPenRect(i);ee(n);const{center:r}=n,{scale:a,origin:o,x:l,y:u}=this.store.data;this.translate((s.x-o.x)/a-r.x-l/a,(t-o.y)/a-n.y-u/a);const{canvas:h}=this.canvas,f=(h.scrollWidth-h.offsetWidth)/2,g=(h.scrollHeight-h.offsetHeight)/2;h.scrollTo(f,g)}centerView(){if(!this.hasView())return;const t=this.getRect(),i=this.getViewCenter(),s=this.getPenRect(t);ee(s);const{center:n}=s,{scale:r,origin:a,x:o,y:l}=this.store.data;this.translate((i.x-a.x)/r-n.x-o/r,(i.y-a.y)/r-n.y-l/r);const{canvas:u}=this.canvas,h=(u.scrollWidth-u.offsetWidth)/2,f=(u.scrollHeight-u.offsetHeight)/2;u.scrollTo(h,f)}hasView(){return!!this.store.data.pens.filter(t=>!t.isRuleLine).length}getViewCenter(){const{width:t,height:i}=this.canvas;return{x:t/2,y:i/2}}beSameByFirst(t=this.store.data.pens,i){const s=ht(t),n=t[0],{width:r,height:a}=this.getPenRect(n);for(let o=1;o<t.length;o++){const l=t[o];i==="width"?this.setValue({id:l.id,width:r},{render:!1,doEvent:!1}):i==="height"?this.setValue({id:l.id,height:a},{render:!1,doEvent:!1}):this.setValue({id:l.id,width:r,height:a},{render:!1,doEvent:!1})}this.render(),this.pushHistory({type:bt.Update,initPens:s,pens:t})}beSameByLast(t=this.store.data.pens,i){const s=ht(t),n=t[t.length-1],{width:r,height:a}=this.getPenRect(n);for(let o=0;o<t.length-1;o++){const l=t[o];i==="width"?this.setValue({id:l.id,width:r},{render:!1,doEvent:!1}):i==="height"?this.setValue({id:l.id,height:a},{render:!1,doEvent:!1}):this.setValue({id:l.id,width:r,height:a},{render:!1,doEvent:!1})}this.render(),this.pushHistory({type:bt.Update,initPens:s,pens:t})}formatPainterByFirst(t=this.store.data.pens){const i=ht(t),s=t[0],n={};Gn.forEach(r=>{n[r]=s[r]});for(let r=1;r<t.length;r++){const a=t[r];this.setValue({id:a.id,...n},{render:!1,doEvent:!1})}this.render(),this.pushHistory({type:bt.Update,initPens:i,pens:t})}formatPainterByLast(t=this.store.data.pens){const i=ht(t),s=t[t.length-1],n={};Gn.forEach(r=>{n[r]=s[r]});for(let r=0;r<t.length-1;r++){const a=t[r];this.setValue({id:a.id,...n},{render:!1,doEvent:!1})}this.render(),this.pushHistory({type:bt.Update,initPens:i,pens:t})}setFormatPainter(){const t=this.store.active,i={};if(t.length>0){const s=t[0];Gn.forEach(n=>{i[n]=s[n]!==void 0?s[n]:this.store.options.defaultFormat[n]||this.store.data[n]||this.store.options[n]})}else Gn.forEach(s=>{this.store.options.defaultFormat[s]||this.store.data[s]||this.store.options[s]});localStorage.setItem("meta2d-formatPainter",JSON.stringify(i))}formatPainter(){const t=this.store.active,i=ht(t),s=JSON.parse(localStorage.getItem("meta2d-formatPainter"));for(let n=0;n<t.length;n++){const r=t[n];this.setValue({id:r.id,...s},{render:!1,doEvent:!1})}this.render(),this.pushHistory({type:bt.Update,initPens:i,pens:t})}clearFormatPainter(){const t=this.store.active,i=ht(t);Gn.forEach(s=>{for(let n=0;n<t.length;n++){const r=t[n],{fontSize:a,lineHeight:o}=this.store.options;s==="lineWidth"?(r.lineWidth=1,r.calculative.lineWidth=1):s==="fontSize"?(r.fontSize=a,r.calculative.fontSize=a):s==="lineHeight"?(r.lineHeight=o,r.calculative.lineHeight=o):(delete r[s],delete r.calculative[s])}}),this.render(),this.pushHistory({type:bt.Update,initPens:i,pens:t})}alignNodes(t,i=this.store.data.pens,s){!s&&(s=this.getPenRect(this.getRect(i)));const n=ht(i);for(const r of i)this.alignPen(t,r,s);this.initImageCanvas(i),this.initTemplateCanvas(i),this.render(),this.pushHistory({type:bt.Update,initPens:n,pens:i})}alignNodesV(t,i=this.store.data.pens,s=!1){const n=this.store.data.width||this.store.options.width,r=this.store.data.height||this.store.options.height;let a={x:0,y:0,width:n,height:r};const o=ht(i);if(s){const l=this.store.data.scale,u=this.getRect(i),h=(u.x-this.store.data.origin.x)/l,f=(u.y-this.store.data.origin.y)/l,g=u.width/l,v=u.height/l;let y=0,w=0;switch(t){case"left":y=-h;break;case"right":y=n-(h+g);break;case"top":w=-f;break;case"bottom":w=r-(f+v);break;case"center":y=n/2-(h+g/2);break;case"middle":w=r/2-(f+v/2);break}this.translatePens(i,y*l,w*l)}else for(const l of i)this.alignPen(t,l,a);this.initImageCanvas(i),this.initTemplateCanvas(i),this.render(),this.pushHistory({type:bt.Update,initPens:o,pens:i})}alignNodesByFirst(t,i=this.store.data.pens){const s=ht(i),n=i[0],r=this.getPenRect(n);for(let a=1;a<i.length;a++){const o=i[a];this.alignPen(t,o,r)}this.initImageCanvas(i),this.initTemplateCanvas(i),this.render(),this.pushHistory({type:bt.Update,initPens:s,pens:i})}alignNodesByLast(t,i=this.store.data.pens){const s=ht(i),n=i[i.length-1],r=this.getPenRect(n);for(let a=0;a<i.length-1;a++){const o=i[a];this.alignPen(t,o,r)}this.initImageCanvas(i),this.initTemplateCanvas(i),this.render(),this.pushHistory({type:bt.Update,initPens:s,pens:i})}alignPen(t,i,s){const n=this.getPenRect(i);switch(t){case"left":n.x=s.x;break;case"right":n.x=s.x+s.width-n.width;break;case"top":n.y=s.y;break;case"bottom":n.y=s.y+s.height-n.height;break;case"center":n.x=s.x+s.width/2-n.width/2;break;case"middle":n.y=s.y+s.height/2-n.height/2;break}this.setValue({id:i.id,...n},{render:!1,doEvent:!1})}spaceBetweenByDirection(t,i=this.store.data.pens,s){if(!s){let u=1/0,h=-1/0,f=t==="width"?"x":"y";i.forEach(g=>{u=Math.min(u,g.calculative.worldRect[f]),h=Math.max(h,g.calculative.worldRect["e"+f])}),s=(h-u)/this.store.data.scale}if(i=i.filter(u=>!u.parentId),i.length<=2)return;const n=ht(i),r=i.reduce((u,h)=>{const f=this.getPenRect(h);return u+f[t]},0),a=(s-r)/(i.length-1);i=i.sort((u,h)=>t==="width"?u.x-h.x:u.y-h.y);const o=this.getPenRect(i[0]);let l=t==="width"?o.x:o.y;for(const u of i){const h=this.getPenRect(u);t==="width"?h.x=l:h.y=l,l+=h[t]+a,this.setValue({id:u.id,...h},{render:!1,doEvent:!1})}this.initImageCanvas(i),this.initTemplateCanvas(i),this.render(),this.pushHistory({type:bt.Update,initPens:n,pens:i})}spaceBetween(t,i){this.spaceBetweenByDirection("width",t,i)}spaceBetweenColumn(t,i){this.spaceBetweenByDirection("height",t,i)}layout(t=this.store.data.pens,i,s=30){const n=this.getPenRect(pi(t));!i&&(i=n.width),t=t.filter(u=>!u.type&&!u.parentId);const r=ht(t);let a=0;t.forEach(u=>{const h=this.getPenRect(u);h.height>a&&(a=h.height)});let o=n.x,l=n.y;t.forEach((u,h)=>{const f=this.getPenRect(u);if(f.x=o,f.y=l+a/2-f.height/2,this.setValue({id:u.id,...f},{render:!1,doEvent:!1}),h===t.length-1)return;const g=o+f.width-n.x,v=this.getPenRect(t[h+1]);Math.round(i-g)>=Math.round(v.width+s)?o+=f.width+s:(o=n.x,l+=a+s)}),this.initImageCanvas(t),this.initTemplateCanvas(t),this.render(),this.pushHistory({type:bt.Update,initPens:r,pens:t})}gotoView(t){const i=this.getViewCenter(),s=i.x-t.calculative.worldRect.x-t.calculative.worldRect.width/2,n=i.y-t.calculative.worldRect.y-t.calculative.worldRect.height/2;this.canvas.scroll&&this.canvas.scroll.isShow&&this.canvas.scroll.translate(s-this.store.data.x,n-this.store.data.y),this.store.data.x=s,this.store.data.y=n;for(const r of this.store.data.pens)Yi(r);this.canvas.canvasImage.init(),this.canvas.canvasImageBottom.init(),this.render()}showMap(){this.map||(this.map=new tk(this.canvas)),this.map.show()}hideMap(){this.map.hide()}onSizeUpdate(){this.mapTimer&&(clearTimeout(this.mapTimer),this.mapTimer=void 0),this.mapTimer=setTimeout(()=>{this.map&&this.map.isShow&&this.map.show(),this.canvas&&this.canvas.scroll&&this.canvas.scroll.isShow&&this.canvas.scroll.resize()},500)}toggleAnchorMode(){this.canvas.toggleAnchorMode()}addAnchorHand(){this.canvas.addAnchorHand()}removeAnchorHand(){this.canvas.removeAnchorHand()}toggleAnchorHand(){this.canvas.toggleAnchorHand()}top(t){t||(t=this.store.active),Array.isArray(t)||(t=[t]);for(const i of t){const s=this.store.data.pens,n=[...mi(i,this.store),i].map(a=>a.id);s.filter(a=>n.includes(a.id)).forEach(a=>{const o=s.findIndex(l=>l.id===a.id);o>-1&&(s.push(s[o]),s.splice(o,1),this.initTemplateCanvas([a]),this.initImageCanvas([a])),this.specificLayerMove(a,"top")})}this.store.emitter.emit("layer",{type:"top",pens:t})}initImageCanvas(t){this.canvas&&this.canvas.initImageCanvas(t)}initTemplateCanvas(t){this.canvas&&this.canvas.initTemplateCanvas(t)}bottom(t){t||(t=this.store.active),Array.isArray(t)||(t=[t]);for(const i of t){const s=this.store.data.pens,n=[...mi(i,this.store),i].map(a=>a.id),r=s.filter(a=>n.includes(a.id));for(let a=r.length-1;a>=0;a--){const o=r[a],l=s.findIndex(u=>u.id===o.id);l>-1&&(s.unshift(s[l]),s.splice(l+1,1),this.initTemplateCanvas([o]),this.initImageCanvas([o])),this.specificLayerMove(o,"bottom")}}this.store.emitter.emit("layer",{type:"bottom",pens:t})}upByArea(t){if(this.store.data.pens.findIndex(l=>l.id===t.id)===-1){console.warn("upByArea: pen not in canvas");return}const s=[t,...mi(t,this.store)];let n=s.map(l=>this.store.data.pens.findIndex(u=>u.id===l.id));n.includes(-1)&&(console.warn("upByArea: pen children not in canvas"),n=n.filter(l=>l!==-1));const r=Math.min(...n),a=t.calculative.worldRect,o=this.store.data.pens.findIndex((l,u)=>{if(u<=r||l.id===t.id||Fx(l,t))return!1;const h=l.calculative.worldRect;return Xi(a,h)});if(o===-1){this.up(t);return}this.store.data.pens.splice(o+1,0,...s);for(const l of s){const u=this.store.data.pens.findIndex(h=>h.id===l.id);u>-1&&this.store.data.pens.splice(u,1)}this.initImageCanvas([t])}specificLayerMove(t,i){var s;if(t.image&&t.name!=="gif"){let n=zt.CanvasImageBottom;i==="top"?n=zt.CanvasImage:(i==="up"||i==="down")&&(n=zt.CanvasMain),this.setValue({id:t.id,canvasLayer:n},{render:!1,doEvent:!1,history:!1})}else if(t.externElement||t.name==="gif"){let n=0;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<0&&(n=0)),this.setValue({id:t.id,zIndex:n},{render:!1,doEvent:!1,history:!1}),(s=t.calculative.singleton)!=null&&s.div&&Te(t,t.calculative.singleton.div)}}up(t){t||(t=this.store.active),Array.isArray(t)||(t=[t]);for(const i of t){const s=this.store.data.pens;if(i.children&&i.children.length){const n=[...mi(i,this.store),i],r=[];for(let l=0;l<s.length;l++){const u=s[l];n.findIndex(h=>h.id===u.id)!==-1&&(u.temIndex=l,r.push(u))}let a=-1,o=0;r.forEach(l=>{l.temIndex-=o,s.splice(l.temIndex,1),o+=1,a=l.temIndex,delete l.temIndex,this.specificLayerMove(l,"up")}),s.splice(a+1,0,...r),this.initTemplateCanvas(r),this.initImageCanvas(r)}else{const n=s.findIndex(r=>r.id===i.id);n>-1&&n!==s.length-1&&(s.splice(n+2,0,s[n]),s.splice(n,1),this.initTemplateCanvas([i]),this.initImageCanvas([i])),this.specificLayerMove(i,"up")}}this.store.emitter.emit("layer",{type:"up",pens:t})}down(t){t||(t=this.store.active),Array.isArray(t)||(t=[t]);for(const i of t){const s=this.store.data.pens;if(i.children&&i.children.length){const n=[...mi(i,this.store),i],r=[];for(let l=0;l<s.length;l++){const u=s[l];n.findIndex(h=>h.id===u.id)!==-1&&(u.temIndex=l,r.push(u))}let a=-1,o=0;r.forEach((l,u)=>{l.temIndex-=o,s.splice(l.temIndex,1),o+=1,u===0&&(a=l.temIndex),delete l.temIndex,this.specificLayerMove(l,"down")}),s.splice(a-1,0,...r),this.initTemplateCanvas(r),this.initImageCanvas(r)}else{const n=s.findIndex(r=>r.id===i.id);n>-1&&n!==0&&(s.splice(n-1,0,s[n]),s.splice(n+1,1),this.initTemplateCanvas([i]),this.initImageCanvas([i])),this.specificLayerMove(i,"down")}}this.store.emitter.emit("layer",{type:"down",pens:t})}setLayer(t,i,s=this.store.data.pens){const n=s.findIndex(r=>r.id===t.id);n>-1&&(n>i?(s.splice(i,0,s[n]),s.splice(n+1,1)):n<i&&(s.splice(i,0,s[n]),s.splice(n,1)))}changePenId(t,i){this.canvas.changePenId(t,i)}getLines(t,i="all"){var n;if(t.type===jt.Line)return[];const s=[];return(n=t.connectedLines)==null||n.forEach(({lineId:r})=>{const a=this.store.pens[r];if(!a){console.warn(t,"node contain a error connectedLine");return}if(!s.find(o=>o.id===a.id))switch(i){case"all":s.push(a);break;case"in":Vt(a).connectTo===t.id&&s.push(a);break;case"out":le(a).connectTo===t.id&&s.push(a);break}}),s}nextNode(t){if(t.type===jt.Line){const i=this.store.pens[Vt(t).connectTo];return i?[i]:[]}else{const i=this.getLines(t,"out"),s=[];return i.forEach(n=>{const r=this.nextNode(n);for(const a of r)!s.find(l=>l.id===a.id)&&s.push(a)}),s}}previousNode(t){if(t.type===jt.Line){const i=this.store.pens[le(t).connectTo];return i?[i]:[]}else{const i=this.getLines(t,"in"),s=[];return i.forEach(n=>{const r=this.previousNode(n);for(const a of r)!s.find(l=>l.id===a.id)&&s.push(a)}),s}}getNext(t){var s;if(t.type===jt.Line){console.warn("\u975E\u8FDE\u7EBF\u8282\u70B9");return}const i=[];return(s=t.connectedLines)==null||s.forEach(({lineId:n,anchor:r})=>{var l,u;const a=(l=t.anchors)==null?void 0:l.filter(h=>h.id===r)[0],o=this.findOne(n);if(o.anchors[0].connectTo==t.id){const h=o.anchors[o.anchors.length-1].connectTo;if(h){const f=this.findOne(h),g=(u=f.connectedLines)==null?void 0:u.filter(y=>y.lineId===o.id)[0],v=f.anchors.filter(y=>y.id===g.anchor)[0];i.push({from:t,fromAnchor:a,line:o,to:f,toAnchor:v})}}}),i}addAnchor(t,i,s){if(!t)return;if(t.anchors||(t.anchors=[]),t.calculative.worldAnchors||(t.calculative.worldAnchors=[]),t.type===jt.Line&&(s<0&&(s=t.anchors.length+1+s),s>t.anchors.length&&(s=t.anchors.length),s<0&&(s=0),s==0&&t.anchors[0].connectTo||s==t.anchors.length&&t.anchors[s-1].connectTo)){console.warn("\u7AEF\u70B9\u5B58\u5728\u8FDE\u63A5\u5173\u7CFB");return}let n=null,r=null;i.x<=1&&i.x>=0&&i.y<=1&&i.y>=0?(r={id:i.id||It(),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&&Gt(r,t.rotate,t.calculative.worldRect.center),n={id:r.id,penId:t.id,x:i.x,y:i.y}):(r={id:i.id||It(),penId:t.id,x:i.x,y:i.y},t.calculative.worldRect&&(t.rotate%360&&Gt(i,-t.rotate,t.calculative.worldRect.center),n={id:r.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===jt.Line?(t.calculative.worldAnchors.splice(s,0,r),t.anchors.splice(s,0,n),this.canvas.updateLines(t),this.canvas.initLineRect(t),this.render()):(t.calculative.worldAnchors.push(r),t.anchors.push(n))}connectLine(t,i,s,n,r=!0){if(!s){const u=i.calculative.worldRect;s=bn(t,{x:u.x+u.width/2,y:u.y+u.height/2})}if(!n){const u=t.calculative.worldRect;n=bn(i,{x:u.x+u.width/2,y:u.y+u.height/2})}const a=Math.abs(s.x-n.x),l={height:Math.abs(s.y-n.y),lineName:"line",lineWidth:1,name:"line",type:1,width:a,x:Math.min(s.x,n.x),y:Math.min(s.y,n.y),anchors:[{x:s.x>n.x?1:0,y:s.y>n.y?1:0,id:It()},{x:s.x>n.x?0:1,y:s.x>n.x?0:1,id:It()}]};return this.addPens([l]),we(t,s,l,l.calculative.worldAnchors[0]),we(i,n,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),r&&this.render(),l}toComponent(t=this.store.data.pens,i,s){if(t.length===1){const h=ht(t[0]);return h.type=jt.Node,h.id=void 0,[h]}const n=ht(t,!0),r=pi(n);let a={id:It(),name:"combine",...r,children:[],showChild:i};s&&(a.anchors=[{id:"0",penId:a.id,x:.5,y:0},{id:"1",penId:a.id,x:1,y:.5},{id:"2",penId:a.id,x:.5,y:1},{id:"3",penId:a.id,x:0,y:.5}]);const o=n.filter(h=>!h.parentId),l=n.find(h=>h.width===r.width&&h.height===r.height),u=l&&i===void 0;return o.length===1?a=o[0]:u&&(l.children||(l.children=[]),a=l),n.forEach(h=>{var g;if(h===a||h.parentId===a.id||h.parentId)return;a.children.push(h.id),h.parentId=a.id;const f=us(h.calculative.worldRect,r);Object.assign(h,f),h.locked=(g=h.lockedOnCombine)!=null?g:Ot.DisableMove}),u||o.length===1?ht(n):ht([a,...n])}installPenPlugins(t,i){if(!t.tag&&!t.name&&!t.id)return;let s;t.id?s="id":t.tag?s="tag":t.name&&(s="name"),i.forEach(n=>{let r=n.plugin,a=n.options;if(!!r&&x_(r)&&s)if(r.install(t,a),!this.penPluginMap.has(r))this.penPluginMap.set(r,[{[s]:t[s],option:a}]);else{let o=this.penPluginMap.get(r).find(l=>l[s]===t[s]);o?o.option=a:this.penPluginMap.get(r).push({[s]:t[s],option:a})}})}uninstallPenPlugins(t,i){let s;t.id?s="id":t.tag?s="tag":t.name&&(s="name"),s&&i.forEach(n=>{let r=n.plugin;r.uninstall(t,n.options);let a=this.penPluginMap.get(r),o=a.findIndex(l=>l[s]===t[s]);o!==-1&&(a.splice(o,1),a.length===0&&this.penPluginMap.delete(r))})}setVisible(t,i,s=!0){if(this.onSizeUpdate(),this.setValue({id:t.id,visible:i},{render:!1,doEvent:!1}),t.children)for(const r of t.children){const a=this.store.pens[r];a&&this.setVisible(a,i,!1)}let n=mi(t,this.store);n.push(t),this.initImageCanvas(n),s&&this.render()}clearHover(){this.canvas.clearHover()}closeSocket(){this.closeWebsocket(),this.closeMqtt(),this.closeHttp()}destroy(t){if(this.clear(!1),this.stopDataMock(),this.closeSocket(),this.closeNetwork(),this.closeAll(),Qn.destroyThemeSheet(this.store.id),this.store.emitter.all.clear(),this.canvas.destroy(),this.canvas=void 0,At[this.store.id]=void 0,!t){for(const i in At)delete At[i];At.path2dDraws={},At.canvasDraws={},At.anchors={},At.htmlElements={}}}}function ck(e,t){const i=t||new Path2D,{x:s,y:n,width:r,ey:a}=e.calculative.worldRect,o=r/4;if(i.moveTo(s+o,n),i.lineTo(s,n),i.lineTo(s,a),i.lineTo(s+o,a),i instanceof Path2D)return i}function hk(e){const t=[{x:.25,y:0},{x:.25,y:1},{x:0,y:.5}];e.anchors=t.map(({x:i,y:s},n)=>({id:n+"",x:i,y:s,penId:e.id}))}function uk(e,t){const i=t||new Path2D,{x:s,y:n,width:r,ex:a,ey:o}=e.calculative.worldRect,l=e.offsetX;let u=r/7;if(l>1?u=l:l>0&&(u=r*l),i.moveTo(s+u,n),i.lineTo(a,n),i.lineTo(s+r-u,o),i.lineTo(s,o),i.closePath(),i instanceof Path2D)return i}function fk(e){const t=[{x:.5,y:0},{x:.9285714285714286,y:.5},{x:.5,y:1},{x:.07142857142857142,y:.5}];e.anchors=t.map(({x:i,y:s},n)=>({id:`${n}`,penId:e.id,x:i,y:s}))}function dk(e,t){const i=t||new Path2D,{x:s,y:n,width:r,height:a,ex:o,ey:l}=e.calculative.worldRect,u=r/8;if(i.moveTo(s+u,n),i.lineTo(o-u,n),i.bezierCurveTo(o+u/3,n,o+u/3,l,o-u,l),i.lineTo(s+u,l),i.lineTo(s,n+a/2),i.closePath(),i instanceof Path2D)return i}function gk(e,t){const i=t||new Path2D,{x:s,y:n,width:r,height:a,ex:o,center:l}=e.calculative.worldRect,u=l.x,h=n+a*6/7,f=a/6;if(i.moveTo(s,n),i.lineTo(o,n),i.lineTo(o,h),i.bezierCurveTo(o-20,h-f,u+r/5,h-f,u,h),i.bezierCurveTo(u-r/5,h+f,s,h+f,s,h),i.closePath(),i instanceof Path2D)return i}function vk(e){const t=[{x:.5,y:0},{x:1,y:.5},{x:.5,y:.8571428571428571},{x:0,y:.5}];e.anchors=t.map(({x:i,y:s},n)=>({id:`${n}`,penId:e.id,x:i,y:s}))}function yk(e,t){const i=t||new Path2D,{x:s,y:n,width:r,ex:a,ey:o}=e.calculative.worldRect,l=r/10;if(i.moveTo(s+l*2,n),i.bezierCurveTo(s-l*2/3,n,s-l*2/3,o,s+l*2,o),i.lineTo(a,o),i.bezierCurveTo(a-l,o,a-l,n,a,n),i.closePath(),i instanceof Path2D)return i}function mk(e,t){const i=t||new Path2D,{x:s,y:n,width:r,ex:a,ey:o}=e.calculative.worldRect;i.moveTo(s,n),i.lineTo(a,n),i.lineTo(a,o),i.lineTo(s,o),i.closePath();const l=r/7;if(i.moveTo(s,n+l),i.lineTo(a,n+l),i.moveTo(s+l,n),i.lineTo(s+l,o),i instanceof Path2D)return i}function pk(e,t){const i=t||new Path2D,{x:s,y:n,height:r,ex:a,ey:o}=e.calculative.worldRect,l=r/4;if(i.moveTo(s,n+l),i.lineTo(a,n),i.lineTo(a,o),i.lineTo(s,o),i.closePath(),i instanceof Path2D)return i}function wk(e){const t=[{x:.5,y:.125},{x:1,y:.5},{x:.5,y:1},{x:0,y:.5}];e.anchors=t.map(({x:i,y:s},n)=>({id:`${n}`,penId:e.id,x:i,y:s}))}function bk(e,t){const i=t||new Path2D,{x:s,y:n,ex:r,ey:a}=e.calculative.worldRect;if(i.moveTo(s,n),i.lineTo(r,n),i.moveTo(s,a),i.lineTo(r,a),i instanceof Path2D)return i}function xk(e){const t=[{x:.5,y:0},{x:.5,y:1}];e.anchors=t.map(({x:i,y:s},n)=>({id:n+"",x:i,y:s,penId:e.id}))}function _k(e,t){const i=t||new Path2D,{x:s,y:n,width:r,height:a,ex:o,ey:l}=e.calculative.worldRect;if(i.ellipse(s+r/2,n+a/2,r/2,a/2,0,0,Math.PI*2),i.moveTo(s+r/2,l),i.lineTo(o,l),i.closePath(),i instanceof Path2D)return i}function kk(e,t){const i=t||new Path2D,{x:s,y:n,width:r,ex:a,ey:o}=e.calculative.worldRect,l=r/7;if(i.moveTo(s,n),i.lineTo(a,n),i.lineTo(a,o),i.lineTo(s,o),i.closePath(),i.moveTo(s+l,n),i.lineTo(s+l,o),i.moveTo(a-l,n),i.lineTo(a-l,o),i instanceof Path2D)return i}function Ek(e,t){const i=t||new Path2D,{x:s,y:n,height:r,ex:a,ey:o}=e.calculative.worldRect,l=r/7;if(i.moveTo(s,n+l),i.bezierCurveTo(s,n-l/2|0,a,n-l/2|0,a,n+l),i.lineTo(a,o-l),i.bezierCurveTo(a,o+l/2|0,s,o+l/2|0,s,o-l),i.closePath(),i.moveTo(s,o-l),i.bezierCurveTo(s,o-l*2|0,a,o-l*2|0,a,o-l),i instanceof Path2D)return i}function YC(){return{flowComment:ck,flowData:uk,flowDb:Ek,flowDisplay:dk,flowDocument:gk,flowExternStorage:yk,flowInternalStorage:mk,flowManually:pk,flowParallel:bk,flowQueue:_k,flowSubprocess:kk}}function KC(){return{flowDocument:vk,flowManually:wk,flowParallel:xk,flowComment:hk,flowData:fk}}var $a;(function(e){e[e.Add=0]="Add",e[e.Replace=1]="Replace",e[e.ReplaceAll=2]="ReplaceAll"})($a||($a={}));function yg(e,t){const i=t.calculative.worldRect.height*14/16,n=(e.match(/[\u4e00-\u9fa5]/g)||"").length;return(e.length-n)*i*.6+n*i}function mg(e){if(e.direction=="horizontal"){const t=[];let i=0;const s=e.height;e.checkboxHeight=s,e.options.forEach((r,a)=>{t.push(a*(40+s)+i),i+=yg(r.text,e)}),e.optionPos=t;const n=t.length*(40+s)+i;e.checkboxWidth=n,e.width=n,e.calculative.width=n,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}},ae(e.calculative.worldRect)}else if(e.direction=="vertical"){e.optionInterval==null&&(e.optionInterval=20),e.optionHeight||(e.optionHeight=20);const t=[];e.options.forEach((s,n)=>{t.push(n*(e.optionInterval+e.optionHeight))}),e.optionPos=t;const i=t[t.length-1]+e.optionHeight;e.checkboxHeight=i,e.width||(e.height=i,e.calculative.height=i,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}},ae(e.calculative.worldRect))}}function Bf(e,t){t.onAdd||(t.onAdd=pg,(!t.rowPos||!t.colPos||!t.calculative.maxOffsetY)&&t.onAdd(t),t.onMouseMove=Ik,t.onMouseLeave=Lk,t.onMouseDown=Dk,t.onShowInput=Sk,t.onInput=Pk,t.onValue=Ok,t.onBeforeValue=Nk,t.onMouseEnter=Uk,t.onWheel=Fk,t.onDestroy=Hk),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));const i=t.calculative.canvas.store;if(t.calculative.canvas.store.data,t.calculative.canvas.store.options,t.color=t.color||i.styles.color,t.textColor=t.textColor||t.color||i.styles.textColor,t.activeColor=t.activeColor||i.styles.activeColor,t.hoverColor=t.hoverColor||i.styles.hoverColor,t.activeBackground=t.activeBackground||i.styles.activeBackground,t.hoverBackground=t.hoverBackground||i.styles.hoverBackground,!t.hasHeader){e.save(),e.beginPath();const{x:s,y:n,width:r,height:a}=t.calculative.worldRect;e.fillStyle="#fff0",e.rect(s-1,n-1,r+2,a+2),e.fill(),e.clip()}Tk(e,t),Rk(e,t),Ak(e,t),e.restore(),t.isFirstTime=!1}function Ak(e,t){if(!t.calculative.hover||!t.calculative.hoverCell||t.calculative.isInput||!t.calculative.isHover)return;let i=t.calculative.worldRect,s=t.calculative.canvas.mousePos;if(!(s.x>i.x&&s.x<i.x+i.width&&s.y>i.y&&s.y<i.y+i.height)){t.calculative.hover=!1,t.calculative.isHover=!1,t.calculative.hoverCell=void 0;return}const{row:n,col:r}=t.calculative.hoverCell,{x:a,y:o}=t.calculative.canvas.mousePos;if(!t.data[n])return;let l=t.data[n][r];if(typeof l=="object"||!l)return;e.save(),e.beginPath(),e.textAlign="start",e.textBaseline="middle",e.font=e.font=(t.calculative.fontStyle||"")+" normal "+(t.calculative.fontWeight||"")+" "+(t.calculative.fontSize||12)+"px "+t.calculative.fontFamily;const u=e.measureText(l).width;e.beginPath(),e.fillStyle="#fff",e.strokeStyle="#000",e.moveTo(a,o),e.rect(a-10,o,u+20,20),e.fill(),e.stroke(),e.beginPath(),e.fillStyle="#000",e.fillText(l,a,o+10),e.restore()}function Ck(e){const t=[],i=[],s={};e.rowHeight||(e.rowHeight=40),e.colWidth||(e.colWidth=150);let n=0;const r=e.styles&&e.styles.filter(v=>v.col!==void 0&&v.row===void 0&&v.width);let a={};r&&r.forEach(v=>{a[v.col]=v.width});for(let v=0;v<e.data[0].length;v++){n+=(a[v]||e.colWidth)*e.calculative.canvas.store.data.scale,t.push(n);let y=e.styles&&e.styles.filter(w=>w.col===v&&w.row===void 0);y&&(s[v]=y[0])}let o=0;const l=e.styles&&e.styles.filter(v=>v.col===void 0&&v.row!==void 0&&v.height);let u={};l&&l.forEach(v=>{u[v.row]=v.height});let h=o;for(let v=0;v<e.data.length;v++)o+=(u[v]||e.rowHeight)*e.calculative.canvas.store.data.scale,i.push(o),v<e.maxNum&&(h=o);if(e.calculative.maxOffsetY=(o-h)/e.calculative.canvas.store.data.scale,e.initWorldRect)return;e.colPos=t,e.rowPos=i,e.colStyle=s,e.initScale=e.calculative.canvas.store.data.scale,e.tableWidth=n,e.tableHeight=h||o,e.calculative.width=n,e.calculative.height=h||o,e.calculative.width=n,e.calculative.height=h||o,e.height||(e.height=e.calculative.height),e.width||(e.width=e.calculative.width);let f=e.x,g=e.y;if(e.parentId){let v=e.calculative.canvas.store.pens[e.parentId];f=v.calculative.worldRect.x+v.calculative.worldRect.width*e.x,g=v.calculative.worldRect.y+v.calculative.worldRect.height*e.y}e.calculative.worldRect={x:f,y:g,height:e.calculative.height,width:e.calculative.width,center:{x:e.x+e.calculative.width/2,y:e.y+e.calculative.height/2}},e.width=e.calculative.width,e.height=e.calculative.height,e.initWorldRect||(e.initWorldRect={width:e.calculative.worldRect.width,height:e.calculative.worldRect.height}),ae(e.calculative.worldRect)}function Tk(e,t){if(!t.colPos)return;const{x:i,y:s,width:n,height:r,ex:a,ey:o}=t.calculative.worldRect;e.save(),e.beginPath(),e.strokeStyle=t.color;let l=t.calculative.borderRadius||0,u=l;l<1&&(l=n*l,u=r*u);let h=l<u?l:u;if(n<2*h&&(h=n/2),r<2*h&&(h=r/2),e.moveTo(i+h,s),e.arcTo(a,s,a,o,h),e.arcTo(a,o,i,o,h),e.arcTo(i,o,i,s,h),e.arcTo(i,s,a,s,h),t.background&&(e.fillStyle=t.background,e.fill()),t.bordered!==!1&&(e.strokeStyle=t.borderColor||"#424B61",e.stroke()),t.hLine!==!1){let f=t.rowPos[t.rowPos.length-1];t.hasHeader&&(e.beginPath(),e.moveTo(t.calculative.worldRect.x,t.calculative.worldRect.y+t.rowPos[0]*t.calculative.worldRect.height/t.tableHeight),e.lineTo(t.calculative.worldRect.ex,t.calculative.worldRect.y+t.rowPos[0]*t.calculative.worldRect.height/t.tableHeight),e.strokeStyle=t.borderColor||"#424B61",e.stroke());for(const g of t.rowPos){if(g===f)continue;const v=g*t.calculative.worldRect.height/t.tableHeight-t.offsetY*t.calculative.canvas.store.data.scale;if(t.hasHeader){if(v<0+t.rowPos[0]||v>t.calculative.worldRect.height)continue}else if(v<0||v>t.calculative.worldRect.height)continue;e.beginPath(),e.moveTo(t.calculative.worldRect.x,t.calculative.worldRect.y+v),e.lineTo(t.calculative.worldRect.ex,t.calculative.worldRect.y+v),e.strokeStyle=t.borderColor||"#424B61",e.stroke()}}if(t.vLine!==!1){let f=t.colPos[t.colPos.length-1];t.colPos.forEach((g,v)=>{if(g===f)return;const y=g*t.calculative.worldRect.width/t.tableWidth;e.beginPath(),e.moveTo(t.calculative.worldRect.x+y,t.calculative.worldRect.y),e.lineTo(t.calculative.worldRect.x+y,t.calculative.worldRect.ey),e.strokeStyle=t.borderColor||"#424B61",e.stroke()})}e.restore()}function Rk(e,t){var s,n,r,a,o;if(!t.colPos)return;t.calculative.texts||(t.calculative.texts=[]);const i=1;for(let l=0;l<t.rowPos.length;l++){if(t.hasHeader&&l===1){e.save(),e.beginPath();const{x:h,y:f,width:g,height:v}=t.calculative.worldRect;e.fillStyle="#fff0",e.rect(h-1,f+t.rowPos[0]*t.calculative.worldRect.height/t.tableHeight-1,g+2,v-t.rowPos[0]*t.calculative.worldRect.height/t.tableHeight+2),e.fill(),e.clip()}let{style:u}=Mk(t,l);for(let h=0;h<t.colPos.length;h++){let{value:f,style:g}=bg(t,l,h),v=!0;if(Array.isArray(g)&&g.length>0){let L=0;g.forEach((V,tt)=>{V.wheres&&V.wheres.every(R=>new Function("attr",`return attr ${R.comparison} ${R.value}`)(f))&&(L=tt)}),g=g[L]}else g.wheres&&Array.isArray(g.wheres)&&(v=!1,v=g.wheres.every(function(L){return new Function("attr",`return attr ${L.comparison} ${L.value}`)(f)}));let y=t.color,w=t.textColor||t.color,p=null,_=null,E=null,x=null;v&&(y=g.color||u.color||t.color,w=g.textColor||u.textColor||t.textColor,p=g.background||u.background,_=(g.fontSize||u.fontSize||0)*t.calculative.canvas.store.data.scale,E=g.fontWeight||u.fontWeight,x=g.fontStyle||u.fontStyle);let C;t.stripe&&(t.hasHeader!==!1?l%2===1&&(p=p||t.stripeColor||"#407FFF1F"):l%2===0&&(p=p||t.stripeColor||"#407FFF1F")),t.calculative.active&&((s=t.calculative.activeCell)==null?void 0:s.row)===l&&((n=t.calculative.activeCell)==null?void 0:n.col)===h&&(y=t.activeColor,p=t.activeBackground,C=y,w=t.activeTextColor||t.activeColor),t.calculative.hover&&((r=t.calculative.hoverCell)==null?void 0:r.row)===l&&((a=t.calculative.hoverCell)==null?void 0:a.col)===h&&(y=t.hoverColor,p=t.hoverBackground,w=t.hoverTextColor||t.hoverColor,C=y);const S=_g(t,l,h);if(S.y+S.height<t.calculative.worldRect.y||S.y>t.calculative.worldRect.height+t.calculative.worldRect.y)continue;p&&(e.save(),e.beginPath(),e.fillStyle=p,e.fillRect(S.x,S.y,S.width+.25*t.calculative.canvas.store.data.scale,S.height),e.restore()),C&&(e.save(),e.beginPath(),e.strokeStyle=C,e.strokeRect(S.x,S.y,S.width,S.height),e.restore()),t.calculative.worldTextRect=S;let D=t.calculative.texts[l];if(t.calculative.texts[l]||(D=[],t.calculative.texts.push(D)),D[h]==null){if(typeof f=="object"){const L=t.styles&&t.styles.filter(V=>V.col===h&&V.row===void 0&&V.pens);if(L.length>0){if(D[h]="",t.isFirstTime){t.maxNum&&t.hasHeader&&l>=t.maxNum&&(f.visible=!1);let V=JSON.parse(JSON.stringify(L[0].pens));V.forEach(tt=>{Object.assign(tt,{row:l,col:h},f),tt.activeBackground=tt.background,tt.hoverBackground=tt.background,tt.activeColor=tt.color,tt.hoverColor=tt.color,tt.activeTextColor=tt.textColor,tt.hoverTextColor=tt.textColor,tt.height*=t.calculative.canvas.store.data.scale,tt.width*=t.calculative.canvas.store.data.scale}),Bk(t,S,V),t.calculative.canvas.parent.pushChildren(t,V)}continue}}else f===void 0?D[h]="":D[h]=f.text||f+"";if(!D[h])continue;D[h]=xr(t,D[h])}if(!D[h])continue;e.save(),e.beginPath(),e.fillStyle=w,e.textAlign="center",e.textBaseline="middle",e.font=(x||t.calculative.fontStyle||"")+" normal "+(E||t.calculative.fontWeight||"")+" "+(_||t.calculative.fontSize||12)*i+"px "+t.calculative.fontFamily;let B=t.colStyle&&((o=t.colStyle[h])==null?void 0:o.textAlign);if(B&&(e.textAlign=B),D[h].length===1)B==="left"?e.fillText(D[h][0],S.x,S.y+S.height/2):B==="right"?e.fillText(D[h][0],S.x+S.width,S.y+S.height/2):e.fillText(D[h][0],S.x+S.width/2,S.y+S.height/2);else{const V=(_||t.calculative.fontSize)*t.calculative.lineHeight*i,tt=D[h].length*V;let T=(S.height-tt)/2;B==="left"?D[h].forEach((R,P)=>{e.fillText(R,S.x,S.y+T+(P+.55)*V)}):B==="right"?D[h].forEach((R,P)=>{e.fillText(R,S.x+S.width,S.y+T+(P+.55)*V)}):D[h].forEach((R,P)=>{e.fillText(R,S.x+S.width/2,S.y+T+(P+.55)*V)})}e.restore()}}}function pg(e){var t;wc(e),(t=e.children)!=null&&t.length||(e.isFirstTime=!0),e.offsetY||(e.offsetY=0),Ck(e)}function Sk(e,t){if(!e.calculative.hoverCell)return;const{value:i}=bg(e,e.calculative.hoverCell.row,e.calculative.hoverCell.col);if(typeof i=="object")return;e.calculative.isHover=!1,e.calculative.isInput=!0,e.calculative.canvas.render(),e.calculative.inputCell=e.calculative.hoverCell;const s=_g(e,e.calculative.hoverCell.row,e.calculative.hoverCell.col);e.calculative.tempText=i.text||i+"",e.calculative.canvas.showInput(e,s,"#ffffff")}function Pk(e,t){!e.calculative.inputCell||(xg(e,e.calculative.inputCell.row,e.calculative.inputCell.col,t),e.calculative.isInput=!1,e.calculative.isHover=!0,e.calculative.canvas.render())}function Ik(e,t){e.timer&&(e.calculative.isHover=!1,clearTimeout(e.timer)),e.timer=setTimeout(()=>{e.calculative.isHover=!0,e.calculative.canvas.render()},500),e.calculative.hoverCell=wg(e,t),e.calculative.canvas.render()}function Lk(e,t){wc(e),e.calculative.hoverCell=void 0,e.calculative.canvas.render()}function Dk(e,t){e.calculative.activeCell=wg(e,t),e.calculative.canvas.render()}function wg(e,t){const i=e.calculative.worldRect.width/e.tableWidth,s=e.calculative.worldRect.height/e.tableHeight,n={row:0,col:0};for(let r=0;r<e.colPos.length;r++)t.x>e.calculative.worldRect.x+e.colPos[r]*i&&(n.col=r+1);for(let r=0;r<e.rowPos.length;r++)t.y>e.calculative.worldRect.y+e.rowPos[r]*s-e.offsetY*e.calculative.canvas.store.data.scale&&(n.row=r+1);return n}function bg(e,t,i){if(!e.data||!Array.isArray(e.data))return;const s=e.data[t],n=e.styles&&e.styles.filter(r=>r.row===t&&r.col===i);if(Array.isArray(s))return{value:s[i],style:(n==null?void 0:n.length)>0?n.length>1?n:n[0]:{}};if(!s.data||!Array.isArray(s.data))return}function Mk(e,t){if(!e.data||!Array.isArray(e.data))return;const i=e.data[t],s=e.styles&&e.styles.filter(n=>n.row===t&&n.col===void 0);if(Array.isArray(i))return{value:i,style:(s==null?void 0:s.length)>0?s[0]:{}};if(!i.data||!Array.isArray(i.data))return}function xg(e,t,i,s){if(!e.data||!Array.isArray(e.data))return;e.isFirstTime=!1,e.calculative.texts=void 0;let n=e.data[t];!n||(n[i]instanceof Object||(n[i]=s),e.calculative.canvas.store.emitter.emit("valueUpdate",e))}function _g(e,t,i){const s=e.calculative.worldRect.width/e.tableWidth,n=e.calculative.worldRect.height/e.tableHeight;let r=0,a=e.colPos[i]*s;i>0&&(r=e.colPos[i-1]*s);let o=0,l=e.rowPos[t]*n;t>0&&(o=e.rowPos[t-1]*n);let u=e.offsetY*e.calculative.canvas.store.data.scale;return t===0&&e.hasHeader&&(u=0),{x:e.calculative.worldRect.x+r,y:e.calculative.worldRect.y+o-u,ex:e.calculative.worldRect.x+a,ey:e.calculative.worldRect.y+l-u,width:a-r,height:l-o}}function Bk(e,t,i){if(!(i&&i.length))return;const s=e.calculative.worldRect.width/e.tableWidth,n=e.calculative.worldRect.height/e.tableHeight;let r=1,a=1;e.initWorldRect&&(e.calculative.worldRect.width!==e.initWorldRect.width&&(r=e.calculative.worldRect.width/e.initWorldRect.width),e.calculative.worldRect.height!==e.initWorldRect.height&&(a=e.calculative.worldRect.height/e.initWorldRect.height));let o=0,l=0,u=0;const h=e.calculative.canvas.store.data.scale;if(i.length>1){for(const f of i)l+f.width*s+20*h*s<t.width?(f.x=t.x+l+10*h*s,f.y=t.y+u+10*h*n,l+=(f.width+10*h)*s,o=Math.max(o,u+(f.height+10*h)*n)):(l=0,u=o,f.x=t.x+l+10*h*s,f.y=t.y+u+10*h*n,o+=(f.height+10*h)*n);if(o+20*h*n<t.height){const f=(t.height-o-10*h*n)/2;for(const g of i)g.y+=f}}else i[0].x=t.x+(t.width-i[0].width)/2,i[0].y=t.y+(t.height-i[0].height)/2;i.forEach(f=>{f.width=f.width*r,f.height=f.height*a})}function Ok(e){if(e.calculative.isUpdateData){delete e.calculative.isUpdateData;let t=ht(e.children);e.children=[],pg(e),t&&t.forEach(i=>{e.calculative.canvas.delForce(e.calculative.canvas.findOne(i))}),e.calculative.texts=void 0}}function Nk(e,t){if(e.calculative.isUpdateData=!1,e.swiper!==void 0&&(e.swiper?wc(e):pc(e)),t.styles&&(e.initWorldRect=void 0),t.table||t.col==null&&t.row==null){if(t.dataY){const s=e.replaceMode;let n=[];return s?s===$a.Replace?(n=e.data,t.dataX&&t.dataX.forEach((r,a)=>{n[r]=t.dataY[a]})):s===$a.ReplaceAll&&(t.dataX?n[0]=t.dataX:n[0]=e.data[0],n=n.concat(t.dataY)):n=e.data.concat(t.dataY),delete t.dataX,delete t.dataY,e.calculative.isUpdateData=!0,Object.assign(t,{data:n})}(t.data||t.styles||t.maxNum||t.rowHeight||t.colWidth)&&(e.calculative.isUpdateData=!0,e.initWorldRect=null);for(let s of Object.keys(t))s.includes("data.")&&(e.calculative.isUpdateData=!0);return t}let i=e.data[t.row];return i&&(i[t.col]instanceof Object||(i[t.col]=t.value),xg(e,t.row,t.col,t.value),e.calculative.canvas.render(),delete t.col,delete t.row),t}function Fk(e,t){if(!e.locked&&!e.calculative.canvas.store.data.locked||!e.maxNum)return;let i=0;t.deltaY>0?i=4:i=-4,tc(e,i)}function tc(e,t){var i;e.offsetY||(e.offsetY=0),e.offsetY+=t,e.offsetY>e.calculative.maxOffsetY&&(e.offsetY=e.calculative.maxOffsetY),e.offsetY<0&&(e.offsetY=0),(i=e.children)==null||i.forEach(s=>{const n=e.calculative.canvas.store.pens[s];zk(e,n)}),e.calculative.canvas.render()}function zk(e,t){if(!t)return;t.oldY||(t.oldY=t.y),t.calculative.worldRect,e.calculative.worldRect;const i=e.calculative.canvas.store.data.scale;e.calculative.worldRect.height/e.tableHeight;const s=e.rowHeight;t.y=t.oldY-e.offsetY*i/e.calculative.worldRect.height;const n=s*(e.initScale||1)/e.tableHeight*e.maxNum;if(e.calculative.canvas.updatePenRect(t),e.hasHeader)if(t.y<e.rowPos[0]/e.tableHeight){if(t.calculative.visible=!1,t.visible=!1,t.y<e.rowPos[0]/e.tableHeight/2){t.oldY+=n;let r=t.row+e.maxNum;if(!e.data[r])return;let a=ht(e.data[r][t.col]);a.background&&(a.activeBackground=a.background,a.hoverBackground=a.background),a.color&&(a.hoverColor=a.color,a.activeColor=a.color),a.textColor&&(a.activeTextColor=a.textColor,a.hoverTextColor=a.textColor),Object.assign(t,a,{row:r}),Object.assign(t.calculative,a,{row:r})}}else if(t.y+t.height>1){if(t.calculative.visible=!1,t.visible=!1,t.y+t.height/2>1){t.oldY-=n;let r=t.row-e.maxNum;if(!e.data[r])return;let a=ht(e.data[r][t.col]);a.background&&(a.activeBackground=a.background,a.hoverBackground=a.background),a.color&&(a.hoverColor=a.color,a.activeColor=a.color),a.textColor&&(a.activeTextColor=a.textColor,a.hoverTextColor=a.textColor),Object.assign(t,a,{row:r}),Object.assign(t.calculative,a,{row:r})}}else t.visible=!0,t.calculative.visible=!0;else if(t.y<0){if(t.calculative.visible=!1,t.visible=!1,t.y<-s/e.tableHeight/2){t.oldY+=n;let r=t.row+e.maxNum;if(!e.data[r])return;let a=ht(e.data[r][t.col]);a.background&&(a.activeBackground=a.background,a.hoverBackground=a.background),a.color&&(a.hoverColor=a.color,a.activeColor=a.color),a.textColor&&(a.activeTextColor=a.textColor,a.hoverTextColor=a.textColor),Object.assign(t,a,{row:r}),Object.assign(t.calculative,a,{row:r})}}else if(t.y+t.height>1){if(t.calculative.visible=!1,t.visible=!1,t.y+t.height/2>1){t.oldY-=n;let r=t.row-e.maxNum;if(!e.data[r])return;let a=ht(e.data[r][t.col]);a.background&&(a.activeBackground=a.background,a.hoverBackground=a.background),a.color&&(a.hoverColor=a.color,a.activeColor=a.color),a.textColor&&(a.activeTextColor=a.textColor,a.hoverTextColor=a.textColor),Object.assign(t,a,{row:r}),Object.assign(t.calculative,a,{row:r})}}else t.calculative.visible=!0,t.visible=!0}function Hk(e){pc(e)}function pc(e){e.interval&&(globalThis.clearInterval(e.interval),e.interval=null)}function wc(e){if(e.maxNum&&e.swiper){if(e.interval)return;e.interval=globalThis.setInterval(()=>{e.offsetY>=e.calculative.maxOffsetY?(e.offsetY=0,Wk(e)):e.offsetY%e.rowHeight?tc(e,1):(e.calculative.stap||(e.calculative.stap=0),e.calculative.stap+=1,e.calculative.stap==12&&(e.calculative.stap=0,tc(e,1)))},50)}}function Wk(e){var t;(t=e.children)==null||t.forEach(i=>{const s=e.rowHeight,n=e.calculative.canvas.store.pens[i];if(!n)return;const r=s*(e.initScale||1)/e.tableHeight*e.maxNum;n.oldY-=r;const a=n.row-e.maxNum;if(!e.data[a])return;let o=ht(e.data[a][n.col]);o.background&&(o.activeBackground=o.background,o.hoverBackground=o.background),o.color&&(o.hoverColor=o.color,o.activeColor=o.color),o.textColor&&(o.activeTextColor=o.textColor,o.hoverTextColor=o.textColor),n.calculative.visible=!0,n.visible=!0,Object.assign(n,o,{row:a}),Object.assign(n.calculative,o,{row:a})}),e.calculative.canvas.render()}function Uk(e){pc(e)}function Vk(e,t){t.onClick||(t.onClick=jk,t.setTheme=$k);let i=t.calculative.worldRect.x,s=t.calculative.worldRect.y,n=t.calculative.worldRect.width,r=t.calculative.worldRect.height;n<r*1.5&&(n=1.5*r),e.beginPath(),e.arc(i+r/2,s+r/2,r/2,Math.PI/2,Math.PI*3/2),e.lineTo(i+n-r/2,s),e.arc(i+n-r/2,s+r/2,r/2,-Math.PI/2,Math.PI/2),e.lineTo(i+r/2,s+r),t.checked?(e.fillStyle=t.onColor,(t.disabled||t.disable)&&(e.fillStyle=t.disableOnColor||Ae(.6,t.onColor)),t.lineWidth&&(e.strokeStyle=t.onStrokeColor,e.stroke()),e.fill(),e.closePath(),e.beginPath(),e.fillStyle="#ffffff",e.moveTo(i+r*2,s+r/2),e.arc(i+n-r/2,s+r/2,r/2>2?r/2-2:1,0,Math.PI*2),e.fill()):(e.fillStyle=t.offColor,(t.disabled||t.disable)&&(e.fillStyle=t.disableOffColor||Ae(.6,t.offColor)),t.lineWidth&&(e.strokeStyle=t.offStrokeColor,e.stroke()),e.fill(),e.closePath(),e.beginPath(),e.fillStyle="#ffffff",e.moveTo(i+r,s+r/2),e.arc(i+r/2,s+r/2,r/2>2?r/2-2:1,0,Math.PI*2),e.fill()),e.closePath()}function jk(e){e.disableDefaultClick||e.disabled||e.disable||(e.checked=!e.checked,e.calculative.canvas.store.emitter.emit("valueUpdate",e),e.calculative.canvas.render())}function $k(e,t){for(const i in t)if(Object.prototype.hasOwnProperty.call(t,i)){const s=t[i];e.hasOwnProperty(i)&&(e[i]=s),e.calculative.hasOwnProperty(i)&&(e.calculative[i]=s)}e.onStrokeColor=t.borderColor,e.offStrokeColor=t.borderColor}function qk(e,t){t.onAdd||(t.onAdd=ir,t.onResize=ir,t.onMove=ir,t.onMouseMove=Yk,t.onMouseDown=kg,t.onValue=Kk,t.onBeforeValue=Xk,t.setTheme=Gk),t.calculative.barRect||ir(t);const i=t.calculative.canvas.store;t.calculative.canvas.store.options;let s=t.background;t.disabled&&(s=t.disabledBackground||Ae(.6,s)),e.fillStyle=s,e.beginPath();let n=t.calculative.worldRect.x+t.calculative.barRect.x,r=t.calculative.worldRect.y+t.calculative.barRect.y,a=t.calculative.barRect.width,o=t.calculative.barRect.height,l=o/2;e.moveTo(n+l,r),e.arcTo(n+a,r,n+a,r+o,l),e.arcTo(n+a,r+o,n,r+o,l),e.arcTo(n,r+o,t.x,t.y,l),e.arcTo(n,r,n+a,r,l),e.fill();let u=t.activeColor||i.styles.activeColor;t.disabled&&(u=t.disabledColor||Ae(.6,u)),e.fillStyle=u,e.beginPath(),a=t.calculative.ballRect.x,e.moveTo(n+l,r),e.arcTo(n+a,r,n+a,r+o,l),e.arcTo(n+a,r+o,n,r+o,l),e.arcTo(n,r+o,t.x,t.y,l),e.arcTo(n,r,n+a,r,l),e.fill(),e.fillStyle=t.btnBackground||"#fff",e.strokeStyle=u,e.lineWidth=2,e.beginPath(),n=t.calculative.worldRect.x+t.calculative.ballRect.x,r=t.calculative.worldRect.y+t.calculative.ballRect.y+t.calculative.ballRect.height/2,e.lineWidth=t.calculative.ballRect.width/10,e.arc(n,r,t.calculative.ballRect.width/2,0,Math.PI*2),e.fill(),e.stroke()}function ir(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)return;const t=e.calculative.worldRect.width/e.sliderWidth,i=e.calculative.worldRect.height/e.sliderHeight,s=Math.min(t,i);e.fontSize=e._fontSize*s;const n=e.calculative.worldRect.width-e._textWidth*s;e.textLeft=n+10*s,e.calculative.textLeft=e.textLeft,e.calculative.barRect={x:0,y:(e.calculative.worldRect.height-e.barHeight*i)/2,width:n,height:e.barHeight*i},ae(e.calculative.barRect),bc(e)}function bc(e){const 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},ae(e.calculative.ballRect),e.calculative.text=e.value+e.unit,Ti(e)}function kg(e,t){if(e.disabled)return;const i=t.x-e.calculative.worldRect.x;if(i>e.calculative.barRect.width)return;let s=Math.round(i/e.calculative.barRect.width*100);s<e.min||s>e.max||s<0||s>100||(e.value=s,bc(e),e.calculative.text=e.value+e.unit,Ti(e),e.calculative.canvas.store.emitter.emit("valueUpdate",e),e.calculative.canvas.render())}function Yk(e,t){e.calculative.canvas.mouseDown&&kg(e,t)}function Kk(e){e.calculative.isUpdateData&&(delete e.calculative.isUpdateData,ir(e)),bc(e)}function Xk(e,t){return e.calculative.isUpdateData=!1,(t.textWidth||t.barHeight)&&(t.textWidth&&(e._textWidth=0),e.calculative.isUpdateData=!0),t}function Gk(e,t){for(const i in t)if(Object.prototype.hasOwnProperty.call(t,i)){const s=t[i];e.hasOwnProperty(i)&&(e[i]=s),e.calculative.hasOwnProperty(i)&&(e.calculative[i]=s)}e.background=t.sliderBg,e.calculative.background=t.sliderBg,e.btnBackground=t.sliderBtnBg,e.calculative.btnBackground=t.sliderBtnBg,e.activeColor=t.tabActiveBg,e.calculative.activeColor=t.tabActiveBg}function Zk(e,t){t.onMouseDown||(t.onMouseDown=Jk),t.options||(t.options=t.data);let i=t.calculative.worldRect.x,s=t.calculative.worldRect.y,n=t.calculative.worldRect.height;t.calculative.worldRect.width;const{fontStyle:r,fontWeight:a,fontSize:o,fontFamily:l,lineHeight:u}=t.calculative;let h=2;e.beginPath(),e.moveTo(i,s),e.arcTo(i+n,s,i+n,s+n,h),e.arcTo(i+n,s+n,i,s+n,h),e.arcTo(i,s+n,i,s,h),e.arcTo(i,s,i+n,s,h),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||Ae(.6,t.background)||"#ebebeb",e.strokeStyle=t.disabledColor||Ae(.6,t.color)||"#d9d9d9"),e.closePath(),e.fill(),e.stroke(),e.save(),t.checked&&(e.beginPath(),e.lineWidth=n/10,e.strokeStyle="#ffffff",e.moveTo(i+102/506*n,s+n/2),e.lineTo(i+220/506*n,s+346/460*n),e.lineTo(i+404/506*n,s+142/460*n),e.stroke()),e.restore(),e.save(),e.fillStyle=t.disabled||t.isForbidden?t.disabledTextColor||Ae(.6,t.textColor||t.color)||"#00000040":bs(t,t.calculative.canvas.parent.store)||"#000000d9",e.textAlign="start",e.textBaseline="middle",e.font=ti({fontStyle:r,fontWeight:a,fontFamily:l||t.calculative.canvas.parent.store.options.fontFamily,fontSize:o,lineHeight:u}),e.fillText(t.value+"",i+n+10,s+n/2),e.restore()}function Jk(e,t){e.isForbidden||(e.checked=!e.checked,e.calculative.canvas.store.emitter.emit("valueUpdate",e),e.calculative.canvas.render())}function Qk(e,t){t.options||(t.options=t.data),t.onAdd||(t.onAdd=tE,t.optionPos||(t.onAdd(t),t.calculative.canvas.parent.active([t])),t.onMouseDown=eE,t.onValue=iE,t.onBeforeValue=sE);let i=t.calculative.worldRect.x,s=t.calculative.worldRect.y,n=t.calculative.worldRect.height,r=t.calculative.worldRect.width;if(!t.optionPos)return;const{fontStyle:a,fontWeight:o,fontSize:l,fontFamily:u,lineHeight:h}=t.calculative;if(t.direction=="horizontal")for(let f=0;f<t.optionPos.length;f++){const g=t.optionPos[f]*r/t.checkboxWidth,v=t.options[f].isForbidden||t.disabled;e.beginPath(),e.arc(i+g+n/2,s+n/2,n/2,0,Math.PI*2),e.strokeStyle="#d9d9d9",e.fillStyle="#ffffff00",t.options[f].text===t.checked&&(e.strokeStyle=t.options[f].background||t.background||"#1890ff"),v&&(e.fillStyle=t.disabledBackground||Ae(.6,t.background)||"#ebebeb",e.strokeStyle=t.disabledColor||Ae(.6,t.color)||"#d9d9d9",t.options[f].text===t.checked&&(e.fillStyle="#ffffff00")),e.closePath(),e.fill(),e.stroke(),e.save(),t.options[f].text===t.checked&&(e.beginPath(),e.strokeStyle=t.options[f].background?t.options[f].background+"20":t.background||"#1890ff20",v&&(e.strokeStyle=t.disabledBackground||Ae(.6,t.background)||"#ebebeb"),e.arc(i+n/2+g,s+n/2,n/2+1.5,0,Math.PI*2),e.stroke(),e.closePath(),e.beginPath(),e.fillStyle=t.options[f].background||t.background||"#1890ff",v&&(e.fillStyle=t.disabledBackground||Ae(.6,t.background)||"#ebebeb"),e.arc(i+n/2+g,s+n/2,n/4,0,Math.PI*2),e.fill(),e.closePath()),e.restore(),e.save(),e.fillStyle=v?t.disabledTextColor||"#00000040":bs(t,t.calculative.canvas.parent.store)||"#000000d9";const y=t.calculative.worldRect.height*14/16;e.textAlign="start",e.textBaseline="middle",e.font=ti({fontStyle:a,fontWeight:o,fontFamily:u||t.calculative.canvas.parent.store.options.fontFamily,fontSize:y,lineHeight:h}),e.fillText(t.options[f].text,i+n+g+10/t.checkboxWidth*r,s+n/2),e.restore()}else if(t.direction=="vertical"){const f=t.optionHeight*n/t.checkboxHeight;for(let g=0;g<t.optionPos.length;g++){const v=t.optionPos[g]*n/t.checkboxHeight,y=t.options[g].isForbidden;e.beginPath(),e.arc(i+f/2,s+f/2+v,f/2,0,Math.PI*2),e.strokeStyle="#d9d9d9",e.fillStyle="#ffffff00",t.options[g].text===t.checked&&(e.strokeStyle=t.options[g].background||"#1890ff"),y&&(e.fillStyle="#ebebeb",e.strokeStyle="#d9d9d9"),e.closePath(),e.fill(),e.stroke(),e.save(),!y&&t.options[g].text===t.checked&&(e.beginPath(),e.strokeStyle=t.options[g].background?t.options[g].background+"20":"#1890ff20",e.arc(i+f/2,s+f/2+v,f/2+1.5,0,Math.PI*2),e.stroke(),e.closePath(),e.beginPath(),e.fillStyle=t.options[g].background||"#1890ff",e.arc(i+f/2,s+f/2+v,f/4,0,Math.PI*2),e.fill(),e.closePath()),e.restore(),e.save(),e.fillStyle=y?"#00000040":bs(t,t.calculative.canvas.parent.store)||"#000000d9";const w=14*t.calculative.worldRect.height/t.checkboxHeight;e.textAlign="start",e.textBaseline="middle",e.font=ti({fontStyle:a,fontWeight:o,fontFamily:u||t.calculative.canvas.parent.store.options.fontFamily,fontSize:w,lineHeight:h}),e.fillText(t.options[g].text,i+f+10,s+f/2+v),e.restore()}}}function tE(e){mg(e)}function eE(e,t){if(e.direction=="horizontal")for(let i=0;i<e.optionPos.length;i++)!e.options[i].isForbidden&&t.x>e.calculative.worldRect.x+e.optionPos[i]*e.calculative.worldRect.width/e.checkboxWidth&&t.x<e.calculative.worldRect.x+(e.optionPos[i]+e.height)/e.checkboxWidth*e.calculative.worldRect.width+yg(e.options[i].text,e)+10/e.checkboxWidth*e.calculative.worldRect.width&&(e.checked=e.options[i].text,e.calculative.canvas.store.emitter.emit("valueUpdate",e));else if(e.direction=="vertical"){const i=e.calculative.worldRect.height/e.checkboxHeight;for(let s=0;s<e.optionPos.length;s++)!e.options[s].isForbidden&&t.y>e.calculative.worldRect.y+e.optionPos[s]*i&&t.y<e.calculative.worldRect.y+(e.optionPos[s]+e.optionHeight)*i&&(e.checked=e.options[s].text,e.calculative.canvas.store.emitter.emit("valueUpdate",e))}e.calculative.canvas.render()}function iE(e){e.calculative.flag&&mg(e)}function sE(e,t){return e.calculative.flag=!1,(t.options!==void 0||t.direction!==void 0||t.optionInterval!==void 0||t.optionHeight!==void 0)&&(e.calculative.flag=!0),t}function XC(){return{radio:Qk,switch:Vk,slider:qk,checkbox:Zk,table:Bf,table2:Bf}}function nE(e,t){const{x:i,y:s,width:n,height:r}=t.calculative.worldRect;e.beginPath(),e.ellipse(i+n/2,s+r/2,n/2,r/2,0,0,Math.PI*2),e.stroke(),e.beginPath(),e.fillStyle=e.strokeStyle,e.ellipse(i+n/2,s+r/2,n/4,r/4,0,0,Math.PI*2),e.fill()}function rE(e,t){const i=t||new Path2D,{x:s,y:n,width:r,height:a,ey:o}=e.calculative.worldRect,l=e.calculative.lineLeft||.08;let u=e.calculative.borderRadius||0,h=u;u<1&&(u=r*u,h=a*u);let f=u<h?u:h;if(r<2*f&&(f=r/2),a<2*f&&(f=a/2),i.moveTo(s+f,n),i.arcTo(s+r,n,s+r,n+a,f),i.arcTo(s+r,n+a,s,n+a,f),i.arcTo(s,n+a,s,n,f),i.arcTo(s,n,s+r,n,f),i.closePath(),i.moveTo(s+l*r,n),i.lineTo(s+l*r,o),i instanceof Path2D)return i}function aE(e,t){const i=t||new Path2D,{x:s,y:n,width:r,height:a,ex:o}=e.calculative.worldRect,l=e.calculative.lineTop||.08;let u=e.calculative.borderRadius||0,h=u;u<1&&(u=r*u,h=a*h);let f=u<h?u:h;if(r<2*f&&(f=r/2),a<2*f&&(f=a/2),i.moveTo(s+f,n),i.arcTo(s+r,n,s+r,n+a,f),i.arcTo(s+r,n+a,s,n+a,f),i.arcTo(s,n+a,s,n,f),i.arcTo(s,n,s+r,n,f),i.closePath(),i.moveTo(s,n+l*a),i.lineTo(o,n+l*a),i instanceof Path2D)return i}function GC(){return{forkV:Ns,forkH:Ns,swimlaneH:rE,swimlaneV:aE}}function ZC(){return{activityFinal:nE}}function oE(e,t){e.onDestroy||(e.onDestroy=cE,e.onAdd=lE);const i=t||new Path2D,{x:s,y:n,width:r,height:a,ex:o}=e.calculative.worldRect;let l=e.calculative.borderRadius||0,u=l;l<1&&(l*=r,u*=a);let h=l<u?l:u;r<2*h&&(h=r/2),a<2*h&&(h=a/2),i.moveTo(s+h,n),i.arcTo(s+r,n,s+r,n+a,h),i.arcTo(s+r,n+a,s,n+a,h),i.arcTo(s,n+a,s,n,h),i.arcTo(s,n,s+r,n,h);const f=.2*a;i.moveTo(s,n+f),i.lineTo(o,n+f);const g=n+f+(a-f)/2;if(i.moveTo(s,g),i.lineTo(o,g),i.closePath(),i instanceof Path2D)return i}function lE(e){const{x:t,y:i,width:s,height:n}=e.calculative.worldRect,r=e.list,a={name:"text",x:t,y:i+.2*n,width:s,height:.4*n,textAlign:"left",textBaseline:"top",textLeft:10,textTop:10},o={name:"text",x:t,y:i+.6*n,width:s,height:.4*n,textAlign:"left",textBaseline:"top",textLeft:10,textTop:10};Object.assign(a,r[0]),Object.assign(o,r[1]),e.calculative.canvas.makePen(a),e.calculative.canvas.makePen(o),e.calculative.canvas.parent.pushChildren(e,[a]),e.calculative.canvas.parent.pushChildren(e,[o])}function cE(e){const t=e.calculative.canvas.store;e.children.forEach(i=>{const s=t.data.pens.findIndex(n=>n.id===i);s>-1&&(t.data.pens.splice(s,1),t.pens[i]=void 0)}),e.children=void 0}function hE(e,t){e.onDestroy||(e.onDestroy=fE,e.onAdd=uE);const i=t||new Path2D,{x:s,y:n,width:r,height:a,ex:o}=e.calculative.worldRect;let l=e.calculative.borderRadius||0,u=l;l<1&&(l=r*l,u=a*u);let h=l<u?l:u;r<2*h&&(h=r/2),a<2*h&&(h=a/2),i.moveTo(s+h,n),i.arcTo(s+r,n,s+r,n+a,h),i.lineTo(s+r,n+a-h),i.arcTo(s+r,n+a,s,n+a,h),i.arcTo(s,n+a,s,n,h),i.arcTo(s,n,s+r,n,h);const f=.2*a;if(i.moveTo(s,n+f),i.lineTo(o,n+f),i.closePath(),i instanceof Path2D)return i}function uE(e){const{x:t,y:i,width:s,height:n}=e.calculative.worldRect,r=e.list;let a={name:"text",x:t,y:i+.2*n,width:s,height:.8*n,textAlign:"left",textBaseline:"top",textLeft:10,textTop:10};Object.assign(a,r[0]),e.calculative.canvas.makePen(a),e.calculative.canvas.parent.pushChildren(e,[a])}function fE(e){const t=e.calculative.canvas.store;e.children.forEach(i=>{const s=t.data.pens.findIndex(n=>n.id===i);s>-1&&(t.data.pens.splice(s,1),t.pens[i]=void 0)}),e.children=[]}function JC(){return{interfaceClass:oE,simpleClass:hE}}var or;(function(e){e[e.Add=0]="Add",e[e.Replace=1]="Replace",e[e.ReplaceAll=2]="ReplaceAll"})(or||(or={}));let ec=["fontSize","nameGap","margin","width","symbolSize","itemWidth","itemHeight","fontWeight","top","left","right","bottom","zoom","edgeSymbolSize","nodeWidth","nodeGap","distance","length","length2","offsetCenter","size","symbolOffset","padding","barWidth","symbolOffset","shadowOffsetY","shadowOffsetX"];function dE(e){var n,r;let t=globalThis.echarts;if(!e.echarts||!t)return;if(typeof e.echarts=="string")try{e.echarts=JSON.parse(e.echarts)}catch{}ec=((n=e.calculative.canvas.store.options.diagramOptions.chart)==null?void 0:n.keyWords)||ec,e.onDestroy||(e.onDestroy=vE,e.onMove=Ia,e.onResize=yE,e.onRotate=Ia,e.onValue=pE,e.onBeforeValue=wE,e.onBinds=bE,e.onMouseEnter=Ia,e.onRenderPenRaw=Sl,e.onScale=mE),e.calculative.singleton||(e.calculative.singleton={});const i=new Path2D,s=e.calculative.worldRect;if(!e.calculative.singleton.div){const a=document.createElement("div");a.style.position="absolute",a.style.outline="none",a.style.left="-9999px",a.style.top="-9999px",a.style.width=s.width+"px",a.style.height=s.height+"px",document.body.appendChild(a),(r=e.calculative.canvas.externalElements)==null||r.parentElement.appendChild(a),Te(e,a),e.calculative.singleton.div=a,e.calculative.singleton.echart=t.init(a,e.echarts.theme),gE(e),e.calculative.singleton.echartsReady=!0,e.echarts.geoName&&!t.getMap(e.echarts.geoName)&&(e.echarts.geoJson?t.registerMap(e.echarts.geoName,e.echarts.geoJson):e.echarts.geoUrl&&(e.calculative.singleton.echartsReady=!1,fetch(e.echarts.geoUrl).then(o=>{o.text().then(l=>{if(typeof l=="string")try{l=JSON.parse(l)}catch{}if(l.constructor!==Object&&l.constructor!==Array){console.warn("Invalid data:",l);return}t.registerMap(e.echarts.geoName,l),e.calculative.singleton.echartsReady=!0,e.calculative.singleton.echart.setOption(qa(e.echarts.option,e.calculative.canvas.store.data.scale),!0),e.calculative.singleton.echart.resize(),setTimeout(()=>{Sl(e)},300)})}))),e.calculative.singleton.echartsReady&&setTimeout(()=>{e.calculative.singleton.echart.setOption(qa(e.echarts.option,e.calculative.canvas.store.data.scale),!0),setTimeout(()=>Sl(e),300)})}return i}function gE(e){var s;const t=e.calculative.singleton.echart,i=["click","dblclick","mousedown","mousemove","mouseup","mouseover","mouseout","globalout","contextmenu"];i.forEach(n=>{t.off(n)}),(s=e.events)==null||s.forEach(n=>{n.actions&&n.actions.length&&i.includes(n.name)&&t.on(n.name,r=>{let a=!1;n.conditions&&n.conditions.length?n.conditionType==="and"?a=n.conditions.every(o=>e.calculative.canvas.parent.judgeCondition(e,o.key,o)):n.conditionType==="or"&&(a=n.conditions.some(o=>e.calculative.canvas.parent.judgeCondition(e,o.key,o))):a=!0,a&&n.actions.forEach(o=>{if(o.timeout){let l=setTimeout(()=>{e.calculative.canvas.parent.events[o.action]&&(e.calculative.canvas.parent.events[o.action](e,o,r),clearTimeout(l),l=null)},o.timeout)}else e.calculative.canvas.parent.events[o.action]&&e.calculative.canvas.parent.events[o.action](e,o,r)})})})}function vE(e){if(e.calculative.singleton&&e.calculative.singleton.div){e.calculative.singleton.div.remove();let t=globalThis.echarts;t&&t.dispose(e.calculative.singleton.echart),delete e.calculative.singleton.div,delete e.calculative.singleton.echart}}function Ia(e){e.calculative.singleton.div&&Te(e,e.calculative.singleton.div)}function yE(e){var t;Ia(e),(t=e.calculative.singleton)!=null&&t.echart&&e.calculative.singleton.echart.resize()}function mE(e){var i,s;if(!e.calculative.singleton.echart)return;let t=globalThis.echarts;if(Te(e,e.calculative.singleton.div),!(e.echarts.geoName&&!t.getMap(e.echarts.geoName))){if(!e.echarts.diabled){if((i=e.echarts.option)!=null&&i.dataZoom){const r=e.calculative.singleton.echart.getOption().dataZoom;(s=e.echarts.option.dataZoom)==null||s.forEach((a,o)=>{r[o]&&(a.start=r[o].start,a.end=r[o].end)})}e.calculative.singleton.echart.setOption(qa(e.echarts.option,e.calculative.canvas.store.data.scale),!0)}e.calculative.singleton.echart.resize()}}function pE(e){var t,i;if(!!e.calculative.singleton.echart&&(Te(e,e.calculative.singleton.div),e.calculative.singleton.echartsReady))if(e.calculative.partialOption){const s=e.calculative.partialOption.echarts.option;(Array.isArray((t=e.echarts)==null?void 0:t.replaceMerge)?(i=e.echarts)==null?void 0:i.replaceMerge.some(r=>s[r]):!1)?e.calculative.singleton.echart.setOption(ht(s),{replaceMerge:e.echarts.replaceMerge}):e.calculative.singleton.echart.setOption(ht(s))}else e.calculative.singleton.echart.setOption(qa(e.echarts.option,e.calculative.canvas.store.data.scale),!0)}function wE(e,t){if(e.calculative.partialOption=null,t.echarts){let y=globalThis.echarts;return t.echarts.geoName&&!y.getMap(t.echarts.geoName)&&(t.echarts.geoJson?y.registerMap(t.echarts.geoName,t.echarts.geoJson):t.echarts.geoUrl&&(e.calculative.singleton.echartsReady=!1,fetch(t.echarts.geoUrl).then(w=>{w.text().then(p=>{if(typeof p=="string")try{p=JSON.parse(p)}catch{}if(p.constructor!==Object&&p.constructor!==Array){console.warn("Invalid data:",p);return}return y.registerMap(t.echarts.geoName,p),e.calculative.singleton.echartsReady=!0,e.onValue(e),!1})}))),t}if(e.realTimes&&e.realTimes.length){let y=Object.keys(t);const{xAxis:w,yAxis:p}=e.echarts.option,{max:_,replaceMode:E,timeFormat:x}=e.echarts;let C=[],S=!1;for(let D in t)if(D.includes("echarts.option")){S=!0;let B=ys(e,D);if(Array.isArray(B)&&E===or.Add&&(B.push(t[D]),_&&B.splice(0,B.length-_),t[D]=B,!y.includes("echarts.option.xAxis.data"))){let L="echarts.option.xAxis.data";Array.isArray(w)&&w.length&&(L="echarts.option.xAxis.0.data");let V=ys(e,L),tt=Nx(x||"`${hours}:${minutes}:${seconds}`");V.push(tt),_&&V.splice(0,V.length-_),t[L]=V}if(D.includes(".data.")){let L=D.substring(0,D.indexOf(".data.")+5);C.includes(L)||C.push(L)}}if(S){const D=ht(t);e.calculative.partialOption=xE(D,e),C.forEach(B=>{let L=ys(e,B);Ha(e.calculative.partialOption,B,L)})}return t}if(!t.dataX&&!t.dataY)return t;const i=e.echarts,{max:s,replaceMode:n}=i;let r=t.dataX,a=t.dataY,o=[];a&&o.push("echarts.option.series");const l=i.option.series,u=l.length,{xAxis:h,yAxis:f}=i.option;Array.isArray(h)&&h.length>1&&console.warn("echarts \u53EA\u652F\u6301\u5355 x \u8F74\uFF0C\u591A x \u8F74\u5C06\u88AB\u5FFD\u7565");const g=Array.isArray(h)?h[0]:h,v=Array.isArray(f)?f[0]:f;if(n)if(n===or.Replace){if(!g&&!v)a&&(u===1?(!Array.isArray(a)&&(a=[a]),a.forEach((y,w)=>{const p=l[0].data.find(_=>_.name===y.name);p&&(p.value=y.value)})):l.forEach((y,w)=>{Array.isArray(a[w])||(a[w]=[a[w]]),a[w].forEach((p,_)=>{const E=y.data.find(x=>x.name===p.name);E&&(E.value=p.value)})}));else if((g.type==="category"||v.type==="category")&&r&&a){const y=g.type==="category"?g.data:v.data;!Array.isArray(r)&&(r=[r]),!Array.isArray(a)&&(a=[a]),g.type==="category"?o.push("echarts.option.xAxis"):o.push("echarts.option.yAxis"),u===1?a.forEach((w,p)=>{const _=y.indexOf(r[p]);l[0].data[_]=w}):l.forEach((w,p)=>{a[p].forEach((_,E)=>{const x=y.indexOf(r[E]);w.data[x]=_})})}}else n===or.ReplaceAll&&(r&&(g.data=r,g.data.splice(0,g.data.length-s),o.push("echarts.option.xAxis")),a&&(u===1?(l[0].data=a,l[0].data.splice(0,l[0].data.length-s)):l.forEach((y,w)=>{y.data=a[w],y.data.splice(0,y.data.length-s)})));else{if(r){!Array.isArray(r)&&(r=[r]);const y=g.data;y.push(...r),y.splice(0,y.length-s),o.push("echarts.option.xAxis")}if(a)if(u===1){!Array.isArray(a)&&(a=[a]);const y=l[0].data;y.push(...a),y.splice(0,y.length-s)}else l.forEach((y,w)=>{Array.isArray(a[w])||(a[w]=[a[w]]);const p=y.data;p.push(...a[w]),p.splice(0,p.length-s)})}return e.calculative.partialOption={},o.forEach(y=>{let w=ys(e,y);Ha(e.calculative.partialOption,y,w)}),delete t.dataX,delete t.dataY,Object.assign(t,{echarts:i})}function bE(e,t,i){if(i.key!=="dataY")return;const s=e.echarts,{xAxis:n,yAxis:r}=s.option;Array.isArray(n)&&n.length>1&&console.warn("echarts \u53EA\u652F\u6301\u5355 x \u8F74\uFF0C\u591A x \u8F74\u5C06\u88AB\u5FFD\u7565");const a=Array.isArray(n)?n[0]:n,o=Array.isArray(r)?r[0]:r,l=s.option.series;if(!a&&!o){const u=[];if(Array.isArray(l)&&l.length===1)return l[0].data.forEach(h=>{const{dataId:f}=i.dataIds.find(g=>g.name===h.name);if(f){const g=t.find(v=>v.dataId===f);g&&u.push({name:h.name,value:g.value})}}),{id:e.id,dataY:u}}else if(a.type==="category"||o.type==="category"){const u=[],h=[],f=a.type==="category"?a.data:o.data;return f==null||f.forEach(g=>{const{dataId:v}=i.dataIds.find(y=>y.name===g);if(v){const y=t.find(w=>w.dataId===v);y&&(h.push(g),u.push(y.value))}}),{id:e.id,dataY:u,dataX:h}}else if(a.type==="time"){const u=[],h=+new Date;let f=!1;if(l.forEach((g,v)=>{const y=[],{dataId:w}=i.dataIds.find(p=>p.name===g.name);if(w){const p=t.find(_=>_.dataId===w);p&&(y.push([h,p.value]),f=!0)}u[v]=y}),f)u.forEach((g,v)=>{if(!g||g.length===0){const y=l[v].data[l[v].data.length-1];u[v]=[[h,y[1]]]}});else return;return{id:e.id,dataY:u.length===1?u[0]:u}}}function Sl(e){var i,s;const t=new Image;t.src=(s=(i=e.calculative.singleton)==null?void 0:i.echart)==null?void 0:s.getDataURL({pixelRatio:2}),e.calculative.img=t}function qa(e,t){const i=ht(e);if(i.dataZoom){let s=["right","top","width","height","left","bottom"];for(let n=0;n<s.length;n++)i.dataZoom.forEach(r=>{isNaN(r[s[n]])||(r[s[n]]*=t)})}return jl(i,ec,t),i}function xE(e,t){const i={};return Object.keys(e).forEach(s=>{const n=s.split(".");let r=i;n.forEach((a,o)=>{const l=!isNaN(parseInt(a));if(o===6){let u=n.slice(0,7).join(".");Ha(t,s,e[s]);let h=ys(t,u);r[n[o]]=h}else{if(o>6)return;if(o===n.length-1)l?(Array.isArray(r)||(r=[]),r[parseInt(a)]=e[s]):r[a]=e[s];else if(l){const u=parseInt(a);if(Array.isArray(r)||r[n[o-1]],r[u]||(r[u]={}),Array.isArray(r))for(let h=0;h<parseInt(a);h++)r[h]||(r[h]={});r=r[u]}else r[a]||(a==="series"?r[a]=[]:r[a]={}),r=r[a]}})}),i}function QC(e){e&&(globalThis.echarts=e),Pd({echarts:dE})}const _E=15;function Ps(e,t=_E){let i=""+e;return i.indexOf(".")>=0&&(i=Number.parseFloat(i).toFixed(t)),Number.parseFloat(i)}function Pl(e){return typeof e=="number"&&Number.isFinite(e)}function kE(e){e={max:null,min:null,splitNumber:4,symmetrical:!1,deviation:!1,preferZero:!1,...e};const t=[10,15,20,25,30,40,50,60,70,80,90,100,150];let{max:i,min:s,splitNumber:n,symmetrical:r,deviation:a,preferZero:o}=e;if(!Pl(i)||!Pl(s)||i<s)return{splitNumber:n};if(i===s&&i===0)return{max:Ps(t[0]*n),min:s,interval:t[0],splitNumber:n};i===s&&(o=!0),(!Pl(n)||n<=0)&&(n=4),o&&i*s>0&&(i<0?i=0:s=0);const l=(i-s)/n;let u=Math.floor(Math.log10(l)-1);u=Math.pow(10,u);const h=l/u;let f=t[0]*u,g=-1,v;for(v=0;v<t.length;v++)if(t[v]>h){f=t[v]*u;break}let y=i,w=s;function p(E){if(y=parseInt(""+(i/E+1))*E,w=parseInt(""+(s/E-1))*E,i===0&&(y=0),s===0&&(w=0),r&&y*w<0){const x=Math.max(Math.abs(y),Math.abs(w));y=x,w=-x}}if(p(f),a)return{max:Ps(y),min:Ps(w),interval:Ps(f),splitNumber:Math.round((y-w)/f)};if(!r||y*w>0){let E;t:do{if(E=Math.round((y-w)/f),(v-g)*(E-n)<0){for(;E<n;)if(w-s<=y-i&&w!==0||y===0?w-=f:y+=f,E++,E===n)break t}if(v>=t.length-1||v<=0||E===n)break;g=v,E>n?f=t[++v]*u:f=t[--v]*u,p(f)}while(E!==n)}y=Ps(y),w=Ps(w);const _=Ps((y-w)/n);return{max:y,min:w,interval:_,splitNumber:n}}function Eg(e,t){var p,_,E,x,C,S,D,B,L,V,tt,T,R,P,O,Y,Z,rt,$,H,j,K,W,Q,st,et,ut,ct;const i=t.calculative.worldRect.x,s=t.calculative.worldRect.y,n=t.calculative.worldRect.width,r=t.calculative.worldRect.height;let a=t.calculative.canvas.store.data.scale,o=[];if(t.echarts)for(let ot=0;ot<t.echarts.option.series.length;ot++)o.push(t.echarts.option.series[ot].data);else o=t.data;let l=[];for(let ot=0;ot<o.length;ot++)l=l.concat(o[ot]);let u={max:Math.max.apply(null,l),min:Math.min.apply(null,l),splitNumber:5},h=kE(u),f=t.echarts?t.echarts.option.xAxis.data.length:t.xAxisData.length;e.beginPath(),e.strokeStyle="#BFBFBF",e.lineWidth=6*a,e.lineCap="butt";let g=(n-1*(f+1))/f;e.setLineDash([1,g]),e.moveTo(i,s+r+3*a),e.lineTo(i+n,s+r+3*a),e.stroke(),e.closePath(),e.beginPath(),e.lineWidth=1*a,e.setLineDash([]),e.moveTo(i,s+r),e.lineTo(i+n,s+r),e.stroke(),e.closePath(),e.beginPath(),e.fillStyle="#BFBFBF",e.strokeStyle="#E9E9E9",e.setLineDash([2,2]);let v={fontStyle:((_=(p=t.yAxis)==null?void 0:p.axisLabel)==null?void 0:_.fontStyle)||t.fontStyle,textDecoration:(x=(E=t.yAxis)==null?void 0:E.axisLabel)==null?void 0:x.textDecoration,fontWeight:((S=(C=t.yAxis)==null?void 0:C.axisLabel)==null?void 0:S.fontWeight)||t.fontWeight,fontFamily:((B=(D=t.yAxis)==null?void 0:D.axisLabel)==null?void 0:B.fontFamily)||t.fontFamily,fontSize:((V=(L=t.yAxis)==null?void 0:L.axisLabel)==null?void 0:V.fontSize)||t.fontSize,lineHeight:((T=(tt=t.yAxis)==null?void 0:tt.axisLabel)==null?void 0:T.lineHeight)||t.lineHeight};e.fillStyle=((P=(R=t.yAxis)==null?void 0:R.axisLabel)==null?void 0:P.fontColor)||t.color;for(let ot=0;ot<h.splitNumber+1;ot++){let b=ot*r/h.splitNumber;e.textAlign="right",e.textBaseline="middle",e.font=ti(v),e.fillText(h.max-ot*h.interval+"",i-10*a,s+b),e.fill(),ot<h.splitNumber&&(e.beginPath(),e.moveTo(i,s+b),e.lineTo(i+n,s+b),e.stroke())}e.closePath(),e.beginPath(),e.strokeStyle="#BFBFBF";let y=t.echarts?t.echarts.option.xAxis.data:t.xAxisData,w=0;for(let ot=0;ot<y.length;ot++){w=i+(1+g/2)+(g+1)*ot,e.textAlign="center",e.textBaseline="top";let b={fontStyle:((Y=(O=t.xAxis)==null?void 0:O.axisLabel)==null?void 0:Y.fontStyle)||t.calculative.fontStyle,textDecoration:(rt=(Z=t.xAxis)==null?void 0:Z.axisLabel)==null?void 0:rt.textDecoration,fontWeight:((H=($=t.xAxis)==null?void 0:$.axisLabel)==null?void 0:H.fontWeight)||t.calculative.fontWeight,fontFamily:((K=(j=t.xAxis)==null?void 0:j.axisLabel)==null?void 0:K.fontFamily)||t.calculative.fontFamily,fontSize:((Q=(W=t.xAxis)==null?void 0:W.axisLabel)==null?void 0:Q.fontSize)||t.calculative.fontSize,lineHeight:((et=(st=t.xAxis)==null?void 0:st.axisLabel)==null?void 0:et.lineHeight)||t.calculative.lineHeight};e.font=ti(b),e.fillStyle=((ct=(ut=t.xAxis)==null?void 0:ut.axisLabel)==null?void 0:ct.fontColor)||t.calculative.color,e.fillText(y[ot],w,s+r+10*a),e.fill()}return e.closePath(),e.setLineDash([]),{dash:g,normalizedOption:h}}function EE(e,t){if(!isNaN(e))return t===-1?e:Math.round(Number(e)*1e3)/1e3}var Pn;(function(e){e[e.Add=0]="Add",e[e.Replace=1]="Replace",e[e.ReplaceAll=2]="ReplaceAll"})(Pn||(Pn={}));function AE(e,t){t.onBeforeValue||(t.onBeforeValue=Ag);const i=t.calculative.worldRect.x,s=t.calculative.worldRect.y;t.calculative.worldRect.width;const n=t.calculative.worldRect.height;let r=t.calculative.canvas.store.data.scale,a=[];t.echarts&&!t.echarts.option.color&&(t.echarts.option.color=["#1890ff","#2FC25B","#FACC14","#c23531","#2f4554","#61a0a8","#d48265"]);let o=Eg(e,t),l=o.dash,u=o.normalizedOption;const h=!!(t.echarts?t.echarts.option.series[0].smooth:t.smooth);let f=[];if(t.echarts)for(let g=0;g<t.echarts.option.series.length;g++)a.push(t.echarts.option.series[g].data);else a=t.data;for(let g=0;g<a.length;g++){e.beginPath();let v=a[g];e.strokeStyle=t.echarts?t.echarts.option.color[g]:t.chartsColor[g],e.fillStyle=t.echarts?t.echarts.option.color[g]:t.chartsColor[g];let y=i+(1+l/2),w=s+n-(v[0]-u.min)/(u.max-u.min)*n;if(e.moveTo(y,w),f.push({x:y,y:w}),h)if(v.length<=2)for(let p=1;p<v.length;p++)y=i+(1+l/2)+(l+1)*p,w=s+n-(v[p]-u.min)/(u.max-u.min)*n,e.lineTo(y,w),f.push({x:y,y:w});else{let p,_,E,x;v.forEach((C,S)=>{y=i+(1+l/2)+(l+1)*S,w=s+n-(v[S]-u.min)/(u.max-u.min)*n;let D=i+(1+l/2)+(l+1)*(S+1),B=s+n-(v[S+1]-u.min)/(u.max-u.min)*n,L=i+(1+l/2)+(l+1)*(S-1),V=s+n-(v[S-1]-u.min)/(u.max-u.min)*n,tt=i+(1+l/2)+(l+1)*(S+2),T=s+n-(v[S+2]-u.min)/(u.max-u.min)*n;S===0?(L=i+(1+l/2)+(l+1)*S,V=s+n-(v[S]-u.min)/(u.max-u.min)*n):S===v.length-2&&(tt=i+(1+l/2)+(l+1)*(S+1),T=s+n-(v[S+1]-u.min)/(u.max-u.min)*n),f.push({x:y,y:w}),p=y+(D-L)/4,_=w+(B-V)/4,E=D-(tt-y)/4,x=B-(T-w)/4,e.bezierCurveTo(p,_,E,x,D,B)})}else for(let p=1;p<v.length;p++)y=i+(1+l/2)+(l+1)*p,w=s+n-(v[p]-u.min)/(u.max-u.min)*n,e.lineTo(y,w),f.push({x:y,y:w});e.stroke(),e.closePath(),e.save(),f.forEach((p,_)=>{e.beginPath(),e.strokeStyle="#fff",e.lineWidth=2*r,e.arc(p.x,p.y,4*r,0,Math.PI*2),e.stroke(),e.fill(),e.closePath()}),e.restore(),f=[]}}function Ag(e,t){if(t.xAxisData||t.data||!t.dataX&&!t.dataY)return t;const i=e.xAxisData,s=e.data,n=e.replaceMode;let r=[],a=[];return n?n===Pn.Replace?(t.dataX.forEach((o,l)=>{let u=i.indexOf(o);s.forEach((h,f)=>{h[u]=t.dataY[f][l]})}),r=i,a=s):n===Pn.ReplaceAll&&(r=t.dataX,a=t.dataY):(r=[...i,...t.dataX],s.forEach((o,l)=>{let u=[...o,...t.dataY[l]];a.push(u)})),delete t.dataX,delete t.dataY,Object.assign(t,{xAxisData:r,data:a})}function CE(e,t){var h,f;t.onBeforeValue||(t.onBeforeValue=TE);let i=t.calculative.canvas.store.data.scale;const s=t.calculative.worldRect.x,n=t.calculative.worldRect.y,r=t.calculative.worldRect.width,a=t.calculative.worldRect.height,o=!!t.echarts;t.echarts?(t.echarts.option.color||(t.echarts.option.color=["#1890ff","#2FC25B","#FACC14","#c23531","#2f4554","#61a0a8","#d48265"]),t.chartsColor=t.echarts.option.color):t.chartsColor||(t.chartsColor=["#1890ff","#2FC25B","#FACC14","#c23531","#2f4554","#61a0a8","#d48265"]);const l=o?t.echarts.option.series:t.data;let u=0;for(let g=0;g<l.length;g++){let v=l[g],y=r/2;a<r&&(y=a/2);const w=s+r/2,p=n+a/2;let _=0;o?_=v.data.reduce((B,L)=>B+L.value,0):_=v.reduce((B,L)=>B+L.value,0);const E=y*parseFloat(o?v.radius[0]:t.chartsRadius[g][0])/100,x=y*parseFloat(o?v.radius[1]:t.chartsRadius[g][1])/100;if(E>x)return;let C=0,S=0;e.strokeStyle=o&&((h=v.itemStyle)==null?void 0:h.borderColor)||"#fff",e.lineWidth=(o&&((f=v.itemStyle)==null?void 0:f.borderWidth)||2)*i;const D=o?v.data:v;D.forEach((B,L)=>{var Y,Z,rt,$,H,j,K,W,Q,st,et,ut,ct;S+=Math.PI*2*B.value/_,e.beginPath();let V=u+L;V>=t.chartsColor.length&&(V=V%t.chartsColor.length),e.fillStyle=o?t.echarts.option.color[V]:t.chartsColor[V],e.moveTo(w+E*Math.sin(S),p-E*Math.cos(S)),e.arc(w,p,E,-Math.PI/2+S,-Math.PI/2+C,!0),e.lineTo(w+x*Math.sin(C),p-x*Math.cos(C)),e.arc(w,p,x,-Math.PI/2+C,-Math.PI/2+S),e.lineTo(w+E*Math.sin(S),p-E*Math.cos(S)),e.stroke(),e.fill(),e.closePath();let tt=(C+S)/2,T=w+(x+10*i)*Math.sin(tt),R=p-(x+10*i)*Math.cos(tt),P=e.fillStyle;v.label||(v.label={position:"outside",show:!0}),o&&["inner","inside"].includes(v.label.position)?(e.fillStyle="#ffffff",T=w+(x-E)/2*Math.sin(tt),R=p-(x-E)/2*Math.cos(tt)):o&&v.label.position=="outside",v.labelLine||(v.labelLine={show:!0}),(o&&v.labelLine.show!==!1||!o)&&(e.beginPath(),e.strokeStyle=o?t.echarts.option.color[u+L]:t.chartsColor[u+L],e.moveTo(w+x*Math.sin(tt),p-x*Math.cos(tt)),e.lineTo(T,R));let O={fontStyle:((Y=t.tickLabel)==null?void 0:Y.fontStyle)||t.calculative.fontStyle,fontWeight:((Z=t.tickLabel)==null?void 0:Z.fontWeight)||t.calculative.fontWeight,fontFamily:((rt=t.tickLabel)==null?void 0:rt.fontFamily)||t.calculative.fontFamily,lineHeight:(($=t.tickLabel)==null?void 0:$.lineHeight)||t.calculative.lineHeight,fontSize:(((H=t.tickLabel)==null?void 0:H.fontSize)||t.calculative.fontSize)*i};e.font=ti(O),e.textBaseline="middle",e.textAlign="center",tt>Math.PI?((o&&v.label.position==="outside"||!o)&&(e.textAlign="end"),(o&&v.labelLine.show!==!1||!o&&((W=(K=(j=t.tickLabel)==null?void 0:j.labelLine)==null?void 0:K.show)!=null?W:!0))&&e.lineTo(T-5*i,R),(o&&v.label.show!==!1||!o&&((st=(Q=t.tickLabel)==null?void 0:Q.show)!=null?st:!0))&&e.fillText(B.name,T-5*i,R)):((o&&v.label.position==="outside"||!o)&&(e.textAlign="start"),(o&&v.labelLine.show!==!1||!o)&&e.lineTo(T+5*i,R),(o&&v.label.show!==!1||!o&&((ut=(et=t.tickLabel)==null?void 0:et.show)!=null?ut:!0))&&e.fillText(B.name,T+5*i,R)),e.stroke(),e.closePath(),e.fillStyle=P,e.strokeStyle=o&&((ct=v.itemStyle)==null?void 0:ct.borderColor)||"#fff",C=S}),u+=D.length}}function TE(e,t){if(t.data||!t.dataX&&!t.dataY)return t;const i=e.data,s=e.replaceMode;let n=[];return s?s===Pn.Replace?(t.dataY.forEach((r,a)=>{r.forEach((o,l)=>{let u=i[a].filter(h=>h.name===o.name);u.length>0&&(u[0].value=o.value)})}),n=i):s===Pn.ReplaceAll&&(n=t.dataY):i.forEach((r,a)=>{let o=[...r,...t.dataY[a]];n.push(o)}),delete t.dataX,delete t.dataY,Object.assign(t,{data:n})}function RE(e,t){t.onBeforeValue||(t.onBeforeValue=Ag);let i=t.calculative.canvas.store.data.scale;const s=t.calculative.worldRect.x,n=t.calculative.worldRect.y;t.calculative.worldRect.width;const r=t.calculative.worldRect.height;let a=[];if(t.echarts&&!t.echarts.option.color&&(t.echarts.option.color=["#1890ff","#2FC25B","#FACC14","#c23531","#2f4554","#61a0a8","#d48265"]),t.echarts)for(let f=0;f<t.echarts.option.series.length;f++)a.push(t.echarts.option.series[f].data);else a=t.data;let o=Eg(e,t),l=o.dash,u=o.normalizedOption,h=l*4/5/a.length;for(let f=0;f<a.length;f++){e.beginPath();let g=a[f];e.fillStyle=t.echarts?t.echarts.option.color[f]:t.chartsColor[f],e.strokeStyle="#ffffff",e.lineWidth=1*i;let v=0,y=0,w=0;for(let p=0;p<g.length;p++)v=s+(1+.1*l)+(l+1)*p+h*f,w=(g[p]-u.min)/(u.max-u.min)*r,y=n+r-w,e.rect(v,y,h-1,w-1),e.stroke(),e.fill();e.closePath()}}function SE(e,t){var $,H,j,K,W,Q,st,et,ut,ct,ot,b,k,I;t.onAdd||(t.onAdd=PE,t.onDestroy=IE,t.onClick=LE,t.clockInterval&&(t.onDestroy(t),t.onAdd(t)));const i=t.calculative.worldRect.x,s=t.calculative.worldRect.y,n=t.calculative.worldRect.width,r=t.calculative.worldRect.height;let a=t.calculative.canvas.store.data.scale,o={startAngle:225,endAngle:-45,min:0,max:100,splitNumber:10};if(t.echarts&&t.echarts.option){let F=t.echarts.option.series[0];t.startAngle=F.startAngle||o.startAngle,t.endAngle=F.endAngle||o.endAngle,t.min=F.min||o.min,t.max=F.max||o.max,t.axisLine=F.axisLine.lineStyle.color,t.unit=F.detail.formatter.replace("{value}",""),t.value=F.data[0].value,t.splitNumber=F.splitNumber||o.splitNumber}t={...o,...t};let l=n>r?r/2*9/10:n/2*9/10,u=i+n/2,h=s+r/2,f=t.echarts?t.echarts.option.series[0].data[0].value:t.value,g,v=t.startAngle-t.endAngle,y=t.background||"#E6EBF8";e.strokeStyle=y;let w=l/10;e.lineWidth=w,e.beginPath(),e.lineCap="round",e.arc(u,h,l,-t.startAngle/180*Math.PI,-t.endAngle/180*Math.PI),e.stroke(),e.closePath();let p=0;if(t.axisLine&&!t.isClock)for(let F=t.axisLine.length-1;F>=0;F--)t.axisLine[F][0]*(t.max-t.min)<f?p=t.axisLine[F][0]:(p=(f-t.min)/(t.max-t.min),g=t.axisLine[F][1]),e.beginPath(),e.strokeStyle=t.axisLine[F][1],e.arc(u,h,l,-t.startAngle/180*Math.PI,(-t.startAngle+p*v)/180*Math.PI),e.stroke(),e.closePath();e.lineCap="butt";let _=2*a,E=l-w;E<0&&(E=0);let x=v/180*Math.PI*E,C=(x-_*t.splitNumber)/t.splitNumber,S=v/180*Math.PI*_/2/x;e.beginPath(),e.strokeStyle=t.color||"#999999",e.lineWidth=l/20,e.setLineDash([_,C]),e.arc(u,h,E,-t.startAngle/180*Math.PI-S,-t.endAngle/180*Math.PI+S),e.stroke(),e.closePath();let D=1*a,B=l-w;B<0&&(B=0);let L=v/180*Math.PI*B,V=(L-D*5*t.splitNumber)/5/t.splitNumber,tt=v/180*Math.PI*D/2/L;e.beginPath(),e.strokeStyle=t.color||"#999999",e.lineWidth=l/40,e.setLineDash([D,V]),e.arc(u,h,B,-t.startAngle/180*Math.PI-tt,-t.endAngle/180*Math.PI+tt),e.stroke(),e.closePath(),e.beginPath();let T=t.max-t.min,R=T/t.splitNumber,P={fontStyle:(($=t.tickLabel)==null?void 0:$.fontStyle)||t.calculative.fontStyle,textDecoration:((H=t.tickLabel)==null?void 0:H.textDecoration)||t.textDecoration,fontWeight:((j=t.tickLabel)==null?void 0:j.fontWeight)||t.calculative.fontWeight,fontFamily:((K=t.tickLabel)==null?void 0:K.fontFamily)||t.calculative.fontFamily,fontSize:(((W=t.tickLabel)==null?void 0:W.fontSize)||t.calculative.fontSize)*a,lineHeight:((Q=t.tickLabel)==null?void 0:Q.lineHeight)||t.calculative.lineHeight};e.font=ti(P);let O=l-w-l/20;for(let F=0;F<=t.splitNumber;F++){if(Math.abs(t.startAngle)+Math.abs(t.endAngle)===360&&F==0)continue;let X=t.startAngle-R*F/T*v,G=Math.cos(X/180*Math.PI),at=Math.sin(X/180*Math.PI);e.fillStyle=((st=t.tickLabel)==null?void 0:st.color)||"#999999",G>.02?e.textAlign="end":G<-.02?e.textAlign="start":e.textAlign="center",at>.02?e.textBaseline="top":at<-.02?e.textBaseline="bottom":e.textBaseline="middle",e.fillText(EE(R*F+t.min,1),u+O*G,h-O*at),e.fill()}e.closePath();let Y=1,Z=["value"];if(t.isClock&&(Y=3,Z=["hourvalue","minutevalue","secondvalue"]),t.isClock)for(let F=0;F<Y;F++){let X=(t.startAngle-(t[Z[F]]-t.min)/(t.max-t.min)*v)/180*Math.PI;F>0&&(X=(t.startAngle-(t[Z[F]]-t.min)/(t.max*5-t.min)*v)/180*Math.PI);let G=4/5*l;Z[F]==="hourvalue"&&(G=3/5*l),Z[F]==="minutevalue"&&(G=3.5/5*l);let at=l*1/40;e.beginPath(),e.setLineDash([]),e.lineWidth=l/(F+1)/20,e.strokeStyle=t.color||"#999999",e.moveTo(u-at*3*Math.cos(X),h+at*3*Math.sin(X)),e.lineTo(u+G*Math.cos(X),h-G*Math.sin(X)),e.stroke()}else{let F=(t.startAngle-(f-t.min)/(t.max-t.min)*v)/180*Math.PI,X=4/5*l,G=l*1/40;e.beginPath(),e.setLineDash([]),e.lineWidth=2,e.fillStyle=g,e.moveTo(u-G*3*Math.cos(F),h+G*3*Math.sin(F)),e.lineTo(u+G*Math.cos(F-Math.PI/2),h-G*Math.sin(F-Math.PI/2)),e.lineTo(u+X*Math.cos(F),h-X*Math.sin(F)),e.lineTo(u+G*Math.cos(F+Math.PI/2),h-G*Math.sin(F+Math.PI/2)),e.lineTo(u-G*3*Math.cos(F),h+G*3*Math.sin(F)),e.fill()}e.beginPath(),e.textAlign="center",e.textBaseline="middle";let rt={fontStyle:((et=t.titleLabel)==null?void 0:et.fontStyle)||t.calculative.fontStyle,textDecoration:((ut=t.titleLabel)==null?void 0:ut.textDecoration)||t.textDecoration,fontWeight:((ct=t.titleLabel)==null?void 0:ct.fontWeight)||t.calculative.fontWeight,fontFamily:((ot=t.titleLabel)==null?void 0:ot.fontFamily)||t.calculative.fontFamily,fontSize:(((b=t.titleLabel)==null?void 0:b.fontSize)||t.calculative.fontSize)*a,lineHeight:((k=t.titleLabel)==null?void 0:k.lineHeight)||t.calculative.lineHeight};e.font=ti(rt),e.fillStyle=((I=t.titleLabel)==null?void 0:I.color)||g,t.isClock?e.fillText(("0"+parseInt(t.hourvalue)).slice(-2)+":"+("0"+parseInt(t.minutevalue)).slice(-2)+":"+("0"+parseInt(t.secondvalue)).slice(-2),u,h+l/2):e.fillText(f+" "+(t.unit||""),u,h+l/2),e.fill(),t.isClock&&(e.beginPath(),e.fillStyle=t.color||"#999999",e.strokeStyle="#ffffff",e.arc(u,h,l/20,0,Math.PI*2),e.stroke(),e.fill(),e.closePath())}function PE(e){if(e.isClock)e.clockInterval=setInterval(()=>{let t=new Date,i=t.getSeconds(),s=t.getMinutes()+i/60,n=t.getHours()%12+s/60;e.calculative.canvas.parent.setValue({id:e.id,hourvalue:n,minutevalue:s,secondvalue:i},{render:!0,doEvent:!1})},1e3);else{const t=e.value;e.value=0,e.frames=[{duration:2e3,value:t}],e.calculative.canvas.parent.startAnimate(e.id),setTimeout(()=>{e.value=t},1e3)}}function IE(e){e.clockInterval&&(clearInterval(e.clockInterval),e.clockInterval=void 0)}function LE(e){e.isClock&&(e.onDestroy(e),e.onAdd(e))}function tT(){return{lineChart:AE,histogram:RE,pieChart:CE,gauge:SE}}function DE(e,t){const i=t||new Path2D,{x:s,y:n,width:r,height:a}=e.calculative.worldRect;if(i.rect(s,n,r,a),i.closePath(),i instanceof Path2D)return i}function ME(e,t){var g;const i=(g=t.headHeight)!=null?g:50,{x:s,y:n,width:r,height:a,ey:o}=t.calculative.worldRect;let l=t.calculative.borderRadius||0,u=l;t.calculative.borderRadius<1&&(l*=r,u*=a);let h=l<u?l:u;r<2*h&&(h=r/2),i<2*h&&(h=i/2),e.beginPath(),e.moveTo(s+h,n),e.arcTo(s+r,n,s+r,n+i,h),e.arcTo(s+r,n+i,s,n+i,h),e.arcTo(s,n+i,s,n,h),e.arcTo(s,n,s+r,n,h),e.closePath(),e.stroke(),e.save(),e.beginPath(),e.lineWidth=1,e.setLineDash([7,7]);const f=s+r/2;e.moveTo(f,n+i+1),e.lineTo(f,o),e.stroke(),e.restore()}function eT(){return{sequenceFocus:DE}}function iT(){return{lifeline:ME}}function BE(e,t){const i=t||new Path2D,{x:s,y:n,width:r,height:a}=e.calculative.worldRect,o=a/6,l=r/4;if(i.moveTo(s+l*2,n+0),i.lineTo(s+l*2,n+o),i.moveTo(s,n+o+l*2),i.arc(s+l*2,n+o+l*2,l*2,Math.PI*1,Math.PI*2,!1),i.lineTo(s+l*4,n+o*5),i.lineTo(s,n+o*5),i.lineTo(s,n+o+l*2),i.moveTo(s+l,n+o*5),i.lineTo(s+l,n+o*6),i.moveTo(s+l*2,n+o*5),i.lineTo(s+l*2,n+o*6),i.moveTo(s+l*3,n+o*5),i.lineTo(s+l*3,n+o*6),i.closePath(),i instanceof Path2D)return i}function Of(e){const t=[{x:.5,y:0},{x:.25,y:1},{x:.5,y:1},{x:.75,y:1}];e.anchors=t.map(({x:i,y:s},n)=>({id:`${n}`,penId:e.id,x:i,y:s}))}function OE(e,t){const i=t||new Path2D,{x:s,y:n,width:r,height:a}=e.calculative.worldRect,o=a-r,l=.5*r;if(i.moveTo(s+r/2,n),i.lineTo(s+r/2,n+o),i.moveTo(s+r,n+l+o),i.arc(s+r/2,n+l+o,l,0,Math.PI*2,!1),i.closePath(),i instanceof Path2D)return i}function Nf(e){const t=[{x:.5,y:0},{x:.5,y:1}];e.anchors=t.map(({x:i,y:s},n)=>({id:`${n}`,penId:e.id,x:i,y:s}))}function NE(e,t){const i=t||new Path2D,{x:s,y:n,width:r,height:a}=e.calculative.worldRect,o=a/2,l=r/5;if(i.moveTo(s,n+o),i.lineTo(s+l,n+o),i.moveTo(s+l*5,n+o),i.ellipse(s+l*3,n+o,2*l,o,0,0,Math.PI*2),i.closePath(),i instanceof Path2D)return i}function FE(e){const t=[{x:.6,y:0},{x:1,y:.5},{x:.6,y:1},{x:0,y:.5}];e.anchors=t.map(({x:i,y:s},n)=>({id:`${n}`,penId:e.id,x:i,y:s}))}function zE(e,t){const i=t||new Path2D,{x:s,y:n,width:r,height:a}=e.calculative.worldRect,o=a/4,l=.5*r;if(i.moveTo(s+l,n),i.lineTo(s+l,n+o),i.moveTo(s,n+o),i.rect(s,n+o,l*2,o*2),i.moveTo(s+l,n+3*o),i.lineTo(s+l,n+4*o),i.closePath(),i instanceof Path2D)return i}function HE(e,t){const i=t||new Path2D,{x:s,y:n,width:r,height:a}=e.calculative.worldRect,o=a/8,l=.25*r;if(i.moveTo(s+l*2,n),i.lineTo(s+l*2,n+o*2),i.lineTo(s+l*3,n+o*3),i.lineTo(s+l*3,n+o*5),i.lineTo(s+l*2,n+o*6),i.lineTo(s+l*1,n+o*5),i.lineTo(s+l*1,n+o*3),i.lineTo(s+l*2,n+o*2),i.moveTo(s+l*3,n+o*4),i.lineTo(s+l*4,n+o*4),i.moveTo(s+l*2,n+o*6),i.lineTo(s+l*2,n+o*8),i.closePath(),i instanceof Path2D)return i}function WE(e){const t=[{x:.5,y:0},{x:1,y:.5},{x:.5,y:1}];e.anchors=t.map(({x:i,y:s},n)=>({id:`${n}`,penId:e.id,x:i,y:s}))}function UE(e,t){const i=t||new Path2D,{x:s,y:n,width:r,height:a}=e.calculative.worldRect,o=r/2,l=a/10;if(i.moveTo(s+o,n),i.lineTo(s+o,n+l),i.moveTo(s+o,n+l),i.quadraticCurveTo(s+o*2,n+l,s+o*2,n+l*9),i.moveTo(s+o,n+l),i.quadraticCurveTo(s,n+l,s,n+l*9),i.quadraticCurveTo(s+o,n+l*6,s+o*2,n+l*9),i.moveTo(s+o,n+a*3/4),i.lineTo(s+o,n+a),i.moveTo(s+o*2/5,n+a*201/250),i.lineTo(s+o*2/5,n+a),i.moveTo(s+o*8/5,n+a*201/250),i.lineTo(s+o*8/5,n+a),i.closePath(),i instanceof Path2D)return i}function Ff(e){const t=[{x:.5,y:0},{x:.2,y:1},{x:.5,y:1},{x:.8,y:1}];e.anchors=t.map(({x:i,y:s},n)=>({id:`${n}`,penId:e.id,x:i,y:s}))}function VE(e,t){const i=t||new Path2D,{x:s,y:n,width:r,height:a}=e.calculative.worldRect,o=a/6,l=r/4;if(i.moveTo(s+l*2,n+0),i.lineTo(s+l*2,n+o),i.moveTo(s,n+o+l*2),i.arc(s+l*2,n+o+l*2,l*2,Math.PI*1,Math.PI*2,!1),i.lineTo(s+l*4,n+o*5),i.lineTo(s,n+o*5),i.lineTo(s,n+o+l*2),i.moveTo(s,n+o*5-o/3),i.lineTo(s+l*4,n+o*5-o/3),i.moveTo(s+l,n+o*5),i.lineTo(s+l,n+o*6),i.moveTo(s+l*2,n+o*5),i.lineTo(s+l*2,n+o*6),i.moveTo(s+l*3,n+o*5),i.lineTo(s+l*3,n+o*6),i.closePath(),i instanceof Path2D)return i}function jE(e,t){const i=t||new Path2D,{x:s,y:n,width:r,height:a}=e.calculative.worldRect,o=a/4,l=.5*r;if(i.moveTo(s+l,n),i.lineTo(s+l,n+o),i.lineTo(s+l*2,n+o*2),i.lineTo(s+l*2,n+o*4),i.lineTo(s,n+o*4),i.lineTo(s,n+o*2),i.lineTo(s+l,n+o),i.closePath(),i instanceof Path2D)return i}function $E(e,t){const i=t||new Path2D,{x:s,y:n,width:r,height:a}=e.calculative.worldRect,o=a/4,l=r/2;if(i.moveTo(s+l,n),i.lineTo(s+l,n+o),i.lineTo(s+l*2,n+o*4),i.lineTo(s,n+o*4),i.lineTo(s+l,n+o),i.closePath(),i instanceof Path2D)return i}function qE(e,t){const i=t||new Path2D,{x:s,y:n,width:r,height:a}=e.calculative.worldRect,o=a/3,l=.5*r;if(i.moveTo(s+l,n),i.lineTo(s+l,n+o),i.lineTo(s+r,n+2*o),i.lineTo(s+l,n+a),i.lineTo(s,n+2*o),i.lineTo(s+l,n+o),i.closePath(),i instanceof Path2D)return i}function YE(e){const t=[{x:.5,y:0},{x:1,y:.6666666666666666},{x:.5,y:1},{x:0,y:.6666666666666666}];e.anchors=t.map(({x:i,y:s},n)=>({id:`${n}`,penId:e.id,x:i,y:s}))}function KE(e,t){const i=t||new Path2D,{x:s,y:n,width:r,height:a}=e.calculative.worldRect;let o=r/2,l=a/10;if(i.moveTo(s+o,n),i.lineTo(s+o,n+l),i.moveTo(s+o,n+l),i.quadraticCurveTo(s+o*2,n+l,s+o*2,n+l*9),i.moveTo(s+o,n+l),i.quadraticCurveTo(s,n+l,s,n+l*9),i.quadraticCurveTo(s+o,n+l*6,s+o*2,n+l*9),i.moveTo(s,n+l*10),i.quadraticCurveTo(s+o,n+l*7,s+o*2,n+l*10),i.moveTo(s+o*2/5,n+a*201/250+l),i.lineTo(s+o*2/5,n+a),i.moveTo(s+o*8/5,n+a*201/250+l),i.lineTo(s+o*8/5,n+a),i.closePath(),i instanceof Path2D)return i}function XE(e){const t=[{x:.5,y:0},{x:.2,y:1},{x:.8,y:1}];e.anchors=t.map(({x:i,y:s},n)=>({id:`${n}`,penId:e.id,x:i,y:s}))}function GE(e,t){const{x:i,y:s,width:n,height:r}=t.calculative.worldRect,a=n/2,o=r/10;e.beginPath(),e.moveTo(i+a,s),e.lineTo(i+a,s+o),e.moveTo(i+a,s+o),e.quadraticCurveTo(i+a*2,s+o,i+a*2,s+o*9),e.moveTo(i+a,s+o),e.quadraticCurveTo(i,s+o,i,s+o*9),e.quadraticCurveTo(i+a,s+o*6,i+a*2,s+o*9),e.moveTo(i+a,s+r*3/4),e.lineTo(i+a,s+r*9/10),e.moveTo(i+a*2/5,s+r*201/250),e.lineTo(i+a*2/5,s+r*9/10),e.moveTo(i+a*8/5,s+r*201/250),e.lineTo(i+a*8/5,s+r*9/10),e.stroke(),e.closePath(),e.beginPath();const l=a*2>o*10?o:a/5;e.fillStyle="#333333",e.font=l+"px Arial",e.textBaseline="bottom",e.textAlign="center",e.fillText("o",i+a,s+r),e.fillText("m",i+a*2/5,s+r),e.fillText("o",i+a*8/5,s+r),e.closePath()}function sT(){return{andGate:BE,basicEvent:OE,conditionalEvent:NE,event:zE,forbiddenGate:HE,orGate:UE,priorityAndGate:VE,switchEvent:jE,transferSymbol:$E,unexpandedEvent:qE,xorGate:KE}}function nT(){return{votingGate:GE}}function rT(){return{andGate:Of,orGate:Ff,priorityAndGate:Of,votingGate:Ff,xorGate:XE,forbiddenGate:WE,basicEvent:Nf,unexpandedEvent:YE,conditionalEvent:FE,transferSymbol:Nf}}const aT={background:"#ECE5E5",color:"#fff",textColor:"#fff",anchorColor:"#f90",gridSize:30,grid:!1,gridColor:"rgba(255,255,255,0.1)",drawingLineName:"line"},oT=[{name:"line",label:"\u76F4\u7EBF",icon:"t-line"},{name:"polyline",label:"\u7EBF\u6BB5",icon:"t-polyline"},{name:"curve",label:"\u66F2\u7EBF",icon:"t-curve2"},{name:"mind",label:"\u8111\u56FE\u66F2\u7EBF",icon:"t-mind"}],lT=["triangle","diamond","circle","lineDown","lineUp","triangleSolid","diamondSolid","circleSolid","line"],cT=["#000","#fff","#f00","#0f0","rgba(255,255,255,0.5)"],ZE={name:"\u7BA1\u9053",show:!0,list:[{name:"\u77ED",data:{text:"",width:22,height:30,name:"svgPath",image:"/static/figures/pipe-new/\u77ED.svg"}},{name:"\u6A2A\u5411",data:{text:"",width:68,height:30,name:"svgPath",image:"/static/figures/pipe-new/\u6A2A\u5411.svg"}},{name:"45\u5EA6",data:{text:"",width:75,height:58,name:"svgPath",image:"/static/figures/pipe-new/45\u5EA6.svg"}},{name:"90\u5EA6",data:{text:"",width:84,height:84,name:"svgPath",image:"/static/figures/pipe-new/90\u5EA6.svg"}},{name:"\u56DB\u901A",data:{text:"",width:95,height:84,name:"svgPath",image:"/static/figures/pipe-new/\u56DB\u901A.svg"}},{name:"\u77ED-\u7070\u8272",data:{text:"",width:22,height:30,name:"svgPath",image:"/static/figures/pipe-new/\u77ED-\u7070\u8272.svg"}},{name:"\u6A2A\u5411-\u7070\u8272",data:{text:"",width:68,height:30,name:"svgPath",image:"/static/figures/pipe-new/\u6A2A\u5411-\u7070\u8272.svg"}},{name:"45\u5EA6-\u7070\u8272",data:{text:"",width:75,height:58,name:"svgPath",image:"/static/figures/pipe-new/45\u5EA6-\u7070\u8272.svg"}},{name:"90\u5EA6-\u7070\u8272",data:{text:"",width:84,height:84,name:"svgPath",image:"/static/figures/pipe-new/90\u5EA6-\u7070\u8272.svg"}},{name:"\u4E09\u901AL",data:{text:"",width:91,height:79,name:"svgPath",image:"/static/figures/pipe-new/\u4E09\u901AL.svg"}},{name:"\u77ED-\u84DD\u8272",data:{text:"",width:22,height:30,name:"svgPath",image:"/static/figures/pipe-new/\u77ED-\u84DD\u8272.svg"}},{name:"\u6A2A\u5411-\u84DD\u8272",data:{text:"",width:68,height:30,name:"svgPath",image:"/static/figures/pipe-new/\u6A2A\u5411-\u84DD\u8272.svg"}},{name:"45\u5EA6-\u84DD\u8272",data:{text:"",width:75,height:58,name:"svgPath",image:"/static/figures/pipe-new/45\u5EA6-\u84DD\u8272.svg"}},{name:"90\u5EA6-\u84DD\u8272",data:{text:"",width:84,height:84,name:"svgPath",image:"/static/figures/pipe-new/90\u5EA6-\u84DD\u8272.svg"}},{name:"\u4E09\u901AT",data:{text:"",width:85,height:66,name:"svgPath",image:"/static/figures/pipe-new/\u4E09\u901AT.svg"}},{name:"\u77ED-\u7D2B\u8272",data:{text:"",width:22,height:30,name:"svgPath",image:"/static/figures/pipe-new/\u77ED-\u7D2B\u8272.svg"}},{name:"\u6A2A\u5411-\u7D2B\u8272",data:{text:"",width:68,height:30,name:"svgPath",image:"/static/figures/pipe-new/\u6A2A\u5411-\u7D2B\u8272.svg"}},{name:"45\u5EA6-\u7D2B\u8272",data:{text:"",width:75,height:58,name:"svgPath",image:"/static/figures/pipe-new/45\u5EA6-\u7D2B\u8272.svg"}},{name:"90\u5EA6-\u7D2B\u8272",data:{text:"",width:84,height:84,name:"svgPath",image:"/static/figures/pipe-new/90\u5EA6-\u7D2B\u8272.svg"}},{name:"\u4E09\u901AY",data:{text:"",width:85,height:85,name:"svgPath",image:"/static/figures/pipe-new/\u4E09\u901AY.svg"}},{name:"\u9600\u95E8-\u7EFF\u8272",data:{text:"",width:32,height:80,name:"svgPath",image:"/static/figures/pipe-new/\u9600\u95E8-green.svg"}},{name:"\u9600\u95E8-\u7EA2\u8272",data:{text:"",width:32,height:80,name:"svgPath",image:"/static/figures/pipe-new/\u9600\u95E8-red.svg"}},{name:"\u9600\u95E8-\u9EC4\u8272",data:{text:"",width:32,height:80,name:"svgPath",image:"/static/figures/pipe-new/\u9600\u95E8-yellow.svg"}},{name:"\u7BA1\u9053\u5E26\u9600\u95E8",data:{text:"",width:86,height:38,name:"svgPath",image:"/static/figures/pipe-new/\u7BA1\u9053\u5E26\u9600\u95E8.svg"}},{name:"\u5206\u6C14\u7F38",data:{text:"",width:229,height:108,name:"svgPath",image:"/static/figures/pipe-new/\u5206\u6C14\u7F38.svg"}}]},JE={name:"\u6309\u94AE",show:!0,list:[{data:{text:"",width:40,height:40,name:"svgPath",image:"/static/figures/btn-1/\u6309\u94AE0.svg"}},{data:{text:"",width:40,height:40,name:"svgPath",image:"/static/figures/btn-1/\u6309\u94AE1.svg"}},{data:{text:"",width:40,height:40,name:"svgPath",image:"/static/figures/btn-1/\u6309\u94AE2.svg"}},{data:{text:"",width:40,height:40,name:"svgPath",image:"/static/figures/btn-1/\u6309\u94AE3.svg"}},{data:{text:"",width:40,height:40,name:"svgPath",image:"/static/figures/btn-1/\u6309\u94AE4.svg"}},{data:{text:"",width:40,height:40,name:"svgPath",image:"/static/figures/btn-1/\u6309\u94AE5.svg"}},{data:{text:"",width:40,height:40,name:"svgPath",image:"/static/figures/btn-1/\u6309\u94AE6.svg"}},{data:{text:"",width:40,height:40,name:"svgPath",image:"/static/figures/btn-1/\u6309\u94AE7.svg"}},{data:{text:"",width:40,height:40,name:"svgPath",image:"/static/figures/btn-1/\u6309\u94AE8.svg"}},{data:{text:"",width:40,height:40,name:"svgPath",image:"/static/figures/btn-1/\u6309\u94AE9.svg"}},{data:{text:"",width:40,height:40,name:"svgPath",image:"/static/figures/btn-1/\u6309\u94AE10.svg"}},{data:{text:"",width:40,height:40,name:"svgPath",image:"/static/figures/btn-1/\u6309\u94AE11.svg"}},{data:{text:"",width:40,height:40,name:"svgPath",image:"/static/figures/btn-1/\u6309\u94AE12.svg"}},{data:{text:"",width:40,height:40,name:"svgPath",image:"/static/figures/btn-1/\u6309\u94AE13.svg"}},{data:{text:"",width:40,height:40,name:"svgPath",image:"/static/figures/btn-1/\u6309\u94AE14.svg"}},{data:{text:"",width:40,height:40,name:"svgPath",image:"/static/figures/btn-1/\u6309\u94AE15.svg"}},{data:{text:"",width:40,height:40,name:"svgPath",image:"/static/figures/btn-1/\u6309\u94AE16.svg"}},{data:{text:"",width:40,height:40,name:"svgPath",image:"/static/figures/btn-1/\u6309\u94AE17.svg"}},{data:{text:"",width:40,height:40,name:"svgPath",image:"/static/figures/btn-1/\u6309\u94AE18.svg"}},{data:{text:"",width:40,height:40,name:"svgPath",image:"/static/figures/btn-1/\u6309\u94AE19.svg"}},{data:{text:"",width:40,height:40,name:"svgPath",image:"/static/figures/btn-1/\u6309\u94AE20.svg"}},{data:{text:"",width:40,height:40,name:"svgPath",image:"/static/figures/btn-1/\u6309\u94AE21.svg"}},{data:{text:"",width:40,height:40,name:"svgPath",image:"/static/figures/btn-1/\u6309\u94AE22.svg"}},{data:{text:"",width:40,height:40,name:"svgPath",image:"/static/figures/btn-1/\u6309\u94AE23.svg"}},{data:{text:"",width:40,height:40,name:"svgPath",image:"/static/figures/btn-1/\u6309\u94AE24.svg"}},{data:{text:"",width:40,height:40,name:"svgPath",image:"/static/figures/btn-1/\u6309\u94AE25.svg"}},{data:{text:"",width:31,height:52,name:"svgPath",image:"/static/figures/btn-1/\u6309\u94AE26.svg"}},{data:{text:"",width:31,height:52,name:"svgPath",image:"/static/figures/btn-1/\u6309\u94AE27.svg"}},{data:{text:"",width:40,height:40,name:"svgPath",image:"/static/figures/btn-1/\u6309\u94AE28.svg"}},{data:{text:"",width:31,height:52,name:"svgPath",image:"/static/figures/btn-1/\u6309\u94AE29.svg"}},{data:{text:"",width:31,height:52,name:"svgPath",image:"/static/figures/btn-1/\u6309\u94AE30.svg"}},{data:{text:"",width:31,height:52,name:"svgPath",image:"/static/figures/btn-1/\u6309\u94AE31.svg"}},{data:{text:"",width:31,height:52,name:"svgPath",image:"/static/figures/btn-1/\u6309\u94AE32.svg"}},{data:{text:"",width:31,height:52,name:"svgPath",image:"/static/figures/btn-1/\u6309\u94AE33.svg"}},{data:{text:"",width:31,height:52,name:"svgPath",image:"/static/figures/btn-1/\u6309\u94AE34.svg"}},{data:{text:"",width:31,height:52,name:"svgPath",image:"/static/figures/btn-1/\u6309\u94AE35.svg"}},{data:{text:"",width:31,height:52,name:"svgPath",image:"/static/figures/btn-1/\u6309\u94AE36.svg"}},{data:{text:"",width:31,height:52,name:"svgPath",image:"/static/figures/btn-1/\u6309\u94AE37.svg"}},{data:{text:"",width:40,height:40,name:"svgPath",image:"/static/figures/btn-1/\u6309\u94AE38.svg"}},{data:{text:"",width:40,height:40,name:"svgPath",image:"/static/figures/btn-1/\u6309\u94AE39.svg"}},{data:{text:"",width:40,height:40,name:"svgPath",image:"/static/figures/btn-1/\u6309\u94AE40.svg"}},{data:{text:"",width:40,height:40,name:"svgPath",image:"/static/figures/btn-1/\u6309\u94AE41.svg"}},{data:{text:"",width:40,height:40,name:"svgPath",image:"/static/figures/btn-1/\u6309\u94AE42.svg"}},{data:{text:"",width:40,height:40,name:"svgPath",image:"/static/figures/btn-1/\u6309\u94AE43.svg"}},{data:{text:"",width:40,height:40,name:"svgPath",image:"/static/figures/btn-1/\u6309\u94AE44.svg"}},{data:{text:"",width:40,height:40,name:"svgPath",image:"/static/figures/btn-1/\u6309\u94AE45.svg"}},{data:{text:"",width:40,height:40,name:"svgPath",image:"/static/figures/btn-1/\u6309\u94AE46.svg"}},{data:{text:"",width:40,height:40,name:"svgPath",image:"/static/figures/btn-1/\u6309\u94AE47.svg"}},{data:{text:"",width:40,height:40,name:"svgPath",image:"/static/figures/btn-1/\u6309\u94AE48.svg"}},{data:{text:"",width:40,height:40,name:"svgPath",image:"/static/figures/btn-1/\u6309\u94AE49.svg"}}]},QE={name:"\u7535\u529B",show:!0,list:[{data:{text:"",width:40,height:40,name:"svgPath",image:"/static/figures/ele-1/1.svg"}},{data:{text:"",width:40,height:40,name:"svgPath",image:"/static/figures/ele-1/2.svg"}},{data:{text:"",width:40,height:40,name:"svgPath",image:"/static/figures/ele-1/3.svg"}},{data:{text:"",width:40,height:40,name:"svgPath",image:"/static/figures/ele-1/4.svg"}},{data:{text:"",width:40,height:40,name:"svgPath",image:"/static/figures/ele-1/5.svg"}},{data:{text:"",width:40,height:40,name:"svgPath",image:"/static/figures/ele-1/6.svg"}},{data:{text:"",width:40,height:40,name:"svgPath",image:"/static/figures/ele-1/7.svg"}},{data:{text:"",width:40,height:40,name:"svgPath",image:"/static/figures/ele-1/8.svg"}},{data:{text:"",width:40,height:40,name:"svgPath",image:"/static/figures/ele-1/9.svg"}},{data:{text:"",width:40,height:40,name:"svgPath",image:"/static/figures/ele-1/10.svg"}},{data:{text:"",width:40,height:40,name:"svgPath",image:"/static/figures/ele-1/11.svg"}},{data:{text:"",width:40,height:40,name:"svgPath",image:"/static/figures/ele-1/12.svg"}},{data:{text:"",width:40,height:40,name:"svgPath",image:"/static/figures/ele-1/13.svg"}},{data:{text:"",width:40,height:40,name:"svgPath",image:"/static/figures/ele-1/14.svg"}},{data:{text:"",width:40,height:40,name:"svgPath",image:"/static/figures/ele-1/15.svg"}},{data:{text:"",width:40,height:40,name:"svgPath",image:"/static/figures/ele-1/16.svg"}},{data:{text:"",width:40,height:40,name:"svgPath",image:"/static/figures/ele-1/17.svg"}}]},hT=["time-comp"],uT=[{name:"\u57FA\u672C\u5F62\u72B6",show:!0,list:[{name:"square",icon:"t-icon t-rect",id:1,data:{text:"\u6B63\u65B9\u5F62",width:100,height:100,name:"square"}},{name:"rectangle",icon:"t-icon t-rectangle",id:2,data:{text:"\u5706\u89D2\u77E9\u5F62",width:200,height:50,borderRadius:.1,name:"rectangle"}},{name:"circle",icon:"t-icon t-circle",id:3,data:{text:"\u5706",width:100,height:100,name:"circle"}},{name:"text",icon:"t-icon t-text",id:16,data:{text:"\u6587\u5B57",width:100,height:40,name:"text",disableAnchor:!0}},{name:"triangle",icon:"t-icon t-triangle",id:4,data:{text:"\u4E09\u89D2\u5F62",width:100,height:100,name:"triangle"}},{name:"diamond",icon:"t-icon t-diamond",id:5,data:{text:"\u83F1\u5F62",width:100,height:100,name:"diamond"}},{name:"pentagon",icon:"t-icon t-pentagon",id:6,data:{text:"\u4E94\u8FB9\u5F62",width:100,height:100,name:"pentagon"}},{name:"hexagon",icon:"t-icon t-hexagon",id:7,data:{text:"\u516D\u8FB9\u5F62",width:100,height:100,name:"hexagon"}},{name:"pentagram",icon:"t-icon t-pentagram",id:8,data:{text:"\u4E94\u89D2\u661F",width:100,height:100,name:"pentagram"}},{name:"leftArrow",icon:"t-icon t-arrow-left",id:9,data:{text:"\u5DE6\u7BAD\u5934",width:120,height:60,name:"leftArrow"}},{name:"rightArrow",icon:"t-icon t-arrow-right",id:10,data:{text:"\u53F3\u7BAD\u5934",width:120,height:60,name:"rightArrow"}},{name:"twowayArrow",icon:"t-icon t-twoway-arrow",id:11,data:{text:"\u53CC\u5411\u7BAD\u5934",width:150,height:60,name:"twowayArrow"}},{name:"cloud",icon:"t-icon t-cloud",id:13,data:{text:"\u4E91",width:100,height:100,name:"cloud"}},{name:"message",icon:"t-icon t-msg",id:14,data:{textTop:-.1,text:"\u6D88\u606F\u6846",width:100,height:100,name:"message"}},{name:"file",icon:"t-icon t-file",id:15,data:{text:"\u6587\u6863",width:80,height:100,name:"file"}},{name:"image",icon:"t-icon t-image",id:17,data:{text:"",width:100,height:100,name:"image",image:"https://zhgy.sagoo.cn/base-api/upload_file/2023-11-24/cx73xp2ebryeijgtdt.jpeg"}},{name:"\u52A8\u56FE",icon:"t-icon t-image",data:{text:"",width:100,height:100,name:"gif",image:"/plugin/topo/static/gif.gif"}},{name:"people",icon:"t-icon t-people",id:19,data:{width:70,height:100,name:"people"}},{name:"switch",icon:"t-icon t-kaiguan",data:{name:"switch",checked:!0,onColor:"#1890ff",offColor:"#BFBFBF",width:60,height:30}}]},{name:"Echarts\u56FE\u5F62",show:!0,list:[{name:"\u6298\u7EBF\u56FE",icon:"t-icon t-line-chart",data:{name:"echarts",width:400,height:300,externElement:!0,disableAnchor:!0,echarts:{option:{grid:{top:10,bottom:50,left:40,right:5},xAxis:{type:"category",data:["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],axisLabel:{fontSize:12}},yAxis:{type:"value",axisLabel:{fontSize:12}},series:[{data:[820,932,901,934,1290,1330,1320],type:"line"}]}}}},{name:"\u67F1\u72B6\u56FE",icon:"t-icon t-bar-chart",data:{width:300,height:200,disableAnchor:!0,externElement:!0,name:"echarts",echarts:{option:{tooltip:{trigger:"axis",axisPointer:{type:"shadow"}},grid:{left:"3%",right:"4%",bottom:"3%",containLabel:!0},xAxis:{type:"category",data:["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],axisTick:{alignWithLabel:!0}},yAxis:[{type:"value"}],series:[{name:"\u76F4\u63A5\u8BBF\u95EE",type:"bar",barWidth:"60%",data:[10,52,200,334,390,330,220]}]},max:100}}},{name:"\u997C\u56FE",icon:"t-icon t-pie-chart",data:{width:200,height:200,disableAnchor:!0,externElement:!0,name:"echarts",echarts:{option:{tooltip:{trigger:"item",formatter:"{a} <br/>{b}: {c} ({d}%)"},legend:{},series:[{name:"\u8BBF\u95EE\u6765\u6E90",type:"pie",radius:["50%","70%"],avoidLabelOverlap:!1,label:{normal:{show:!1,position:"center"},emphasis:{show:!0,textStyle:{fontSize:"30",fontWeight:"bold"}}},labelLine:{normal:{show:!1}},data:[{value:335,name:"\u76F4\u63A5\u8BBF\u95EE"},{value:310,name:"\u90AE\u4EF6\u8425\u9500"},{value:234,name:"\u8054\u76DF\u5E7F\u544A"},{value:135,name:"\u89C6\u9891\u5E7F\u544A"},{value:1548,name:"\u641C\u7D22\u5F15\u64CE"}]}]}}}},{name:"\u4EEA\u8868\u76D8",icon:"t-icon t-dashboard-chart",data:{width:300,height:300,disableAnchor:!0,externElement:!0,name:"echarts",echarts:{option:{tooltip:{formatter:"{a} <br/>{b} : {c}%"},series:[{name:"\u4E1A\u52A1\u6307\u6807",type:"gauge",detail:{formatter:"{value}%"},data:[{value:50,name:"\u5B8C\u6210\u7387"}]}]}}}}]},{name:"\u529F\u80FD\u7EC4\u4EF6",show:!0,list:[{name:"\u65F6\u95F4",icon:"topoicon topo-time",id:16,data:{text:"2022/12/12 12:12:12",width:200,height:40,name:"text",tags:["time-comp"],disableAnchor:!0}},{name:"\u6309\u94AE",icon:"t-icon t-anniu",data:{name:"rectangle",customType:"link-button",x:300,y:200,width:80,height:30,disableAnchor:!0,borderRadius:2,text:"\u6309\u94AE",activeBackground:"#40a9ff",activeColor:"#40a9ff",background:"#1890ff",color:"#1890ff",hoverBackground:"#40a9ff",hoverColor:"#40a9ff",textColor:"#ffffff",hoverTextColor:"#ffffff",activeTextColor:"#ffffff"}}]},{...ZE},{...JE},{...QE},{name:"\u7535\u529B\u7CFB\u7EDF-1",show:!0,list:[{font_family:"sg-ele",my_class:"uniE00A",unicode:"e900"},{font_family:"sg-ele",my_class:"uniE04D",unicode:"e97e"},{font_family:"sg-ele",my_class:"uniE04E",unicode:"e97f"},{font_family:"sg-ele",my_class:"uniE005",unicode:"e981"},{font_family:"sg-ele",my_class:"uniE007",unicode:"e98f"},{font_family:"sg-ele",my_class:"uniE006",unicode:"e988"},{font_family:"sg-ele",my_class:"uniE008",unicode:"e996"},{font_family:"sg-ele",my_class:"uniE009",unicode:"e99d"},{font_family:"sg-ele",my_class:"uniE012",unicode:"e9b2"},{font_family:"sg-ele",my_class:"uniE082",unicode:"ea09"},{font_family:"sg-ele",my_class:"uniE088",unicode:"ea0f"},{font_family:"sg-ele",my_class:"uniE090",unicode:"ea11"},{font_family:"sg-ele",my_class:"uniE107",unicode:"ea22"},{font_family:"sg-ele",my_class:"uniE152",unicode:"ea4f"},{font_family:"sg-ele",my_class:"uniE080",unicode:"ea07"},{font_family:"sg-ele",my_class:"uniE084",unicode:"ea0b"},{font_family:"sg-ele",my_class:"uniE059",unicode:"e9f2"},{font_family:"sg-ele",my_class:"uniE10C",unicode:"e9a7"},{font_family:"sg-ele",my_class:"uniE0A0",unicode:"e901"}]},{name:"\u7535\u529B\u7CFB\u7EDF-2",show:!0,list:[{font_family:"sg-ele",my_class:"uniE09E",unicode:"e9a2"},{font_family:"sg-ele",my_class:"uniE010",unicode:"e9a4"},{font_family:"sg-ele",my_class:"uniE014",unicode:"e9bf"},{font_family:"sg-ele",my_class:"uniE040",unicode:"e9df"},{font_family:"sg-ele",my_class:"uniE041",unicode:"e9e0"},{font_family:"sg-ele",my_class:"uniE042",unicode:"e9e1"},{font_family:"sg-ele",my_class:"uniE043",unicode:"e9e2"},{font_family:"sg-ele",my_class:"uniE044",unicode:"e9e3"},{font_family:"sg-ele",my_class:"uniE062",unicode:"e9f5"},{font_family:"sg-ele",my_class:"uniE110",unicode:"ea25"},{font_family:"sg-ele",my_class:"uniE095",unicode:"ea16"},{font_family:"sg-ele",my_class:"uniE0FC",unicode:"e961"},{font_family:"sg-ele",my_class:"uniE02B",unicode:"e96e"},{font_family:"sg-ele",my_class:"uniE06C",unicode:"e98b"},{font_family:"sg-ele",my_class:"uniE0A1",unicode:"e902"},{font_family:"sg-ele",my_class:"uniE0ED",unicode:"e951"},{font_family:"sg-ele",my_class:"uniE00E",unicode:"e943"},{font_family:"sg-ele",my_class:"uniE0DB",unicode:"e93e"},{font_family:"sg-ele",my_class:"uniE0F0",unicode:"e955"},{font_family:"sg-ele",my_class:"uniE0EC",unicode:"e950"},{font_family:"sg-ele",my_class:"uniE0EE",unicode:"e952"},{font_family:"sg-ele",my_class:"uniE00B",unicode:"e911"},{font_family:"sg-ele",my_class:"uniE018",unicode:"e9c9"},{font_family:"sg-ele",my_class:"uniE103",unicode:"ea1e"},{font_family:"sg-ele",my_class:"uniE094",unicode:"ea15"},{font_family:"sg-ele",my_class:"uniE073",unicode:"ea00"}]},{name:"\u7535\u529B\u7CFB\u7EDF-3",show:!0,list:[{font_family:"sg-ele",my_class:"uniE0E4",unicode:"e948"},{font_family:"sg-ele",my_class:"uniE00F",unicode:"e954"},{font_family:"sg-ele",my_class:"uniE05A",unicode:"e982"},{font_family:"sg-ele",my_class:"uniE0AC",unicode:"e90d"},{font_family:"sg-ele",my_class:"uniE0AD",unicode:"e90e"},{font_family:"sg-ele",my_class:"uniE08F",unicode:"e99c"},{font_family:"sg-ele",my_class:"uniE02D",unicode:"e970"},{font_family:"sg-ele",my_class:"uniE09A",unicode:"e99e"},{font_family:"sg-ele",my_class:"uniE00D",unicode:"e932"},{font_family:"sg-ele",my_class:"uniE0C5",unicode:"e928"},{font_family:"sg-ele",my_class:"uniE10B",unicode:"e9a6"},{font_family:"sg-ele",my_class:"uniE00C",unicode:"e922"},{font_family:"sg-ele",my_class:"uniE0F5",unicode:"e95a"},{font_family:"sg-ele",my_class:"uniE01D",unicode:"e969"},{font_family:"sg-ele",my_class:"uniE02C",unicode:"e96f"},{font_family:"sg-ele",my_class:"uniE002",unicode:"e96c"},{font_family:"sg-ele",my_class:"uniE019",unicode:"e9ca"},{font_family:"sg-ele",my_class:"uniE020",unicode:"e9cb"},{font_family:"sg-ele",my_class:"uniE021",unicode:"e9cc"},{font_family:"sg-ele",my_class:"uniE022",unicode:"e9cd"},{font_family:"sg-ele",my_class:"uniE102",unicode:"ea1d"},{font_family:"sg-ele",my_class:"uniE023",unicode:"e9ce"},{font_family:"sg-ele",my_class:"uniE024",unicode:"e9cf"},{font_family:"sg-ele",my_class:"uniE025",unicode:"e9d0"},{font_family:"sg-ele",my_class:"uniE015",unicode:"e9c6"},{font_family:"sg-ele",my_class:"uniE0CB",unicode:"e92d"},{font_family:"sg-ele",my_class:"uniE0E2",unicode:"e946"},{font_family:"sg-ele",my_class:"uniE091",unicode:"ea12"},{font_family:"sg-ele",my_class:"uniE096",unicode:"ea17"}]},{name:"\u7535\u529B\u7CFB\u7EDF-4",show:!0,list:[{font_family:"sg-ele",my_class:"uniE0A2",unicode:"e903"},{font_family:"sg-ele",my_class:"uniE0A3",unicode:"e904"},{font_family:"sg-ele",my_class:"uniE0A6",unicode:"e907"},{font_family:"sg-ele",my_class:"uniE0A8",unicode:"e909"},{font_family:"sg-ele",my_class:"uniE0AE",unicode:"e90f"},{font_family:"sg-ele",my_class:"uniE0C7",unicode:"e929"},{font_family:"sg-ele",my_class:"uniE0C8",unicode:"e92a"},{font_family:"sg-ele",my_class:"uniE0EB",unicode:"e94f"},{font_family:"sg-ele",my_class:"uniE03E",unicode:"e978"},{font_family:"sg-ele",my_class:"uniE05F",unicode:"e987"},{font_family:"sg-ele",my_class:"uniE08A",unicode:"e997"},{font_family:"sg-ele",my_class:"uniE0BC",unicode:"e91e"},{font_family:"sg-ele",my_class:"uniE071",unicode:"e9fe"},{font_family:"sg-ele",my_class:"uniE111",unicode:"ea26"},{font_family:"sg-ele",my_class:"uniE112",unicode:"ea27"},{font_family:"sg-ele",my_class:"uniE100",unicode:"ea1b"},{font_family:"sg-ele",my_class:"uniE108",unicode:"ea23"},{font_family:"sg-ele",my_class:"uniE104",unicode:"ea1f"},{font_family:"sg-ele",my_class:"uniE105",unicode:"ea20"},{font_family:"sg-ele",my_class:"uniE079",unicode:"ea06"},{font_family:"sg-ele",my_class:"uniE072",unicode:"e9ff"},{font_family:"sg-ele",my_class:"uniE10D",unicode:"e9a8"},{font_family:"sg-ele",my_class:"uniE056",unicode:"e9ef"},{font_family:"sg-ele",my_class:"uniE047",unicode:"e9e6"},{font_family:"sg-ele",my_class:"uniE048",unicode:"e9e7"},{font_family:"sg-ele",my_class:"uniE049",unicode:"e9e8"},{font_family:"sg-ele",my_class:"uniE026",unicode:"e9d1"},{font_family:"sg-ele",my_class:"uniE028",unicode:"e9d3"},{font_family:"sg-ele",my_class:"uniE06F",unicode:"e98e"},{font_family:"sg-ele",my_class:"uniE11B",unicode:"e9ad"},{font_family:"sg-ele",my_class:"uniE04A",unicode:"e97b"},{font_family:"sg-ele",my_class:"uniE04B",unicode:"e97c"},{font_family:"sg-ele",my_class:"uniE04C",unicode:"e97d"},{font_family:"sg-ele",my_class:"uniE0EF",unicode:"e953"},{font_family:"sg-ele",my_class:"uniE0D8",unicode:"e93b"},{font_family:"sg-ele",my_class:"uniE0C9",unicode:"e92b"},{font_family:"sg-ele",my_class:"uniE0BE",unicode:"e920"}]},{name:"\u7535\u529B\u7CFB\u7EDF-5",show:!0,list:[{font_family:"sg-ele",my_class:"uniE140",unicode:"ea43"},{font_family:"sg-ele",my_class:"uniE0B5",unicode:"e917"},{font_family:"sg-ele",my_class:"uniE0E8",unicode:"e94c"},{font_family:"sg-ele",my_class:"uniE0B9",unicode:"e91b"},{font_family:"sg-ele",my_class:"uniE0AB",unicode:"e90c"},{font_family:"sg-ele",my_class:"uniE14F",unicode:"e9c5"},{font_family:"sg-ele",my_class:"uniE070",unicode:"e9fd"},{font_family:"sg-ele",my_class:"uniE0A7",unicode:"e908"},{font_family:"sg-ele",my_class:"uniE0A9",unicode:"e90a"},{font_family:"sg-ele",my_class:"uniE0AA",unicode:"e90b"},{font_family:"sg-ele",my_class:"uniE077",unicode:"ea04"},{font_family:"sg-ele",my_class:"uniE06E",unicode:"e98d"},{font_family:"sg-ele",my_class:"uniE10E",unicode:"e9a9"},{font_family:"sg-ele",my_class:"uniE10F",unicode:"e9aa"},{font_family:"sg-ele",my_class:"uniE0DC",unicode:"e93f"},{font_family:"sg-ele",my_class:"uniE0E7",unicode:"e94b"},{font_family:"sg-ele",my_class:"uniE113",unicode:"ea28"},{font_family:"sg-ele",my_class:"uniE127",unicode:"ea36"},{font_family:"sg-ele",my_class:"uniE097",unicode:"ea18"},{font_family:"sg-ele",my_class:"uniE136",unicode:"ea3f"},{font_family:"sg-ele",my_class:"uniE0A5",unicode:"e906"},{font_family:"sg-ele",my_class:"uniE0CE",unicode:"e930"},{font_family:"sg-ele",my_class:"uniE045",unicode:"e9e4"},{font_family:"sg-ele",my_class:"uniE046",unicode:"e9e5"},{font_family:"sg-ele",my_class:"uniE0E0",unicode:"e944"},{font_family:"sg-ele",my_class:"uniE063",unicode:"e9f6"},{font_family:"sg-ele",my_class:"uniE0F1",unicode:"e956"},{font_family:"sg-ele",my_class:"uniE07C",unicode:"e992"},{font_family:"sg-ele",my_class:"uniE07D",unicode:"e993"},{font_family:"sg-ele",my_class:"uniE08C",unicode:"e999"},{font_family:"sg-ele",my_class:"uniE0B3",unicode:"e915"},{font_family:"sg-ele",my_class:"uniE0AF",unicode:"e910"},{font_family:"sg-ele",my_class:"uniE0B2",unicode:"e914"},{font_family:"sg-ele",my_class:"uniE0B6",unicode:"e918"},{font_family:"sg-ele",my_class:"uniE0FB",unicode:"e960"},{font_family:"sg-ele",my_class:"uniE0B8",unicode:"e91a"},{font_family:"sg-ele",my_class:"uniE0CD",unicode:"e92f"},{font_family:"sg-ele",my_class:"uniE0D1",unicode:"e934"},{font_family:"sg-ele",my_class:"uniE0D3",unicode:"e936"},{font_family:"sg-ele",my_class:"uniE0D5",unicode:"e938"},{font_family:"sg-ele",my_class:"uniE087",unicode:"ea0e"},{font_family:"sg-ele",my_class:"uniE0D9",unicode:"e93c"},{font_family:"sg-ele",my_class:"uniE0DD",unicode:"e940"},{font_family:"sg-ele",my_class:"uniE0DE",unicode:"e941"},{font_family:"sg-ele",my_class:"uniE0DF",unicode:"e942"},{font_family:"sg-ele",my_class:"uniE0E3",unicode:"e947"},{font_family:"sg-ele",my_class:"uniE0E5",unicode:"e949"},{font_family:"sg-ele",my_class:"uniE0E6",unicode:"e94a"},{font_family:"sg-ele",my_class:"uniE0E9",unicode:"e94d"},{font_family:"sg-ele",my_class:"uniE0F2",unicode:"e957"},{font_family:"sg-ele",my_class:"uniE0FA",unicode:"e95f"},{font_family:"sg-ele",my_class:"uniE0FF",unicode:"e964"},{font_family:"sg-ele",my_class:"uniE001",unicode:"e965"},{font_family:"sg-ele",my_class:"uniE01A",unicode:"e966"},{font_family:"sg-ele",my_class:"uniE01E",unicode:"e96a"},{font_family:"sg-ele",my_class:"uniE003",unicode:"e973"},{font_family:"sg-ele",my_class:"uniE0E1",unicode:"e945"},{font_family:"sg-ele",my_class:"uniE035",unicode:"e9da"},{font_family:"sg-ele",my_class:"uniE0C0",unicode:"e923"},{font_family:"sg-ele",my_class:"uniE03F",unicode:"e979"},{font_family:"sg-ele",my_class:"uniE05E",unicode:"e986"},{font_family:"sg-ele",my_class:"uniE07F",unicode:"e995"},{font_family:"sg-ele",my_class:"uniE08B",unicode:"e998"},{font_family:"sg-ele",my_class:"uniE08D",unicode:"e99a"},{font_family:"sg-ele",my_class:"uniE09B",unicode:"e99f"},{font_family:"sg-ele",my_class:"uniE09C",unicode:"e9a0"},{font_family:"sg-ele",my_class:"uniE029",unicode:"e9d4"},{font_family:"sg-ele",my_class:"uniE036",unicode:"e9db"},{font_family:"sg-ele",my_class:"uniE037",unicode:"e9dc"},{font_family:"sg-ele",my_class:"uniE038",unicode:"e9dd"},{font_family:"sg-ele",my_class:"uniE053",unicode:"e9ec"},{font_family:"sg-ele",my_class:"uniE054",unicode:"e9ed"},{font_family:"sg-ele",my_class:"uniE076",unicode:"ea03"},{font_family:"sg-ele",my_class:"uniE081",unicode:"ea08"},{font_family:"sg-ele",my_class:"uniE085",unicode:"ea0c"},{font_family:"sg-ele",my_class:"uniE089",unicode:"ea10"},{font_family:"sg-ele",my_class:"uniE098",unicode:"ea19"},{font_family:"sg-ele",my_class:"uniE093",unicode:"ea14"}]},{name:"\u7535\u529B\u7CFB\u7EDF-6",show:!0,list:[{font_family:"sg-ele",my_class:"uniE147",unicode:"ea4a"},{font_family:"sg-ele",my_class:"uniE145",unicode:"ea48"},{font_family:"sg-ele",my_class:"uniE148",unicode:"ea4b"},{font_family:"sg-ele",my_class:"uniE139",unicode:"ea42"},{font_family:"sg-ele",my_class:"uniE133",unicode:"ea3c"},{font_family:"sg-ele",my_class:"uniE135",unicode:"ea3e"},{font_family:"sg-ele",my_class:"uniE064",unicode:"e9f7"},{font_family:"sg-ele",my_class:"uniE065",unicode:"e9f8"},{font_family:"sg-ele",my_class:"uniE066",unicode:"e9f9"},{font_family:"sg-ele",my_class:"uniE067",unicode:"e9fa"},{font_family:"sg-ele",my_class:"uniE068",unicode:"e9fb"},{font_family:"sg-ele",my_class:"uniE14B",unicode:"e9c1"},{font_family:"sg-ele",my_class:"uniE14D",unicode:"e9c3"},{font_family:"sg-ele",my_class:"uniE13A",unicode:"e9b9"},{font_family:"sg-ele",my_class:"uniE13B",unicode:"e9ba"},{font_family:"sg-ele",my_class:"uniE12C",unicode:"e9b4"},{font_family:"sg-ele",my_class:"uniE06D",unicode:"e98c"},{font_family:"sg-ele",my_class:"uniE05C",unicode:"e984"},{font_family:"sg-ele",my_class:"uniE03A",unicode:"e974"},{font_family:"sg-ele",my_class:"uniE03B",unicode:"e975"},{font_family:"sg-ele",my_class:"uniE03C",unicode:"e976"},{font_family:"sg-ele",my_class:"uniE004",unicode:"e97a"},{font_family:"sg-ele",my_class:"uniE134",unicode:"ea3d"},{font_family:"sg-ele",my_class:"uniE128",unicode:"ea37"},{font_family:"sg-ele",my_class:"uniE122",unicode:"ea31"},{font_family:"sg-ele",my_class:"uniE123",unicode:"ea32"},{font_family:"sg-ele",my_class:"uniE120",unicode:"ea2f"},{font_family:"sg-ele",my_class:"uniE039",unicode:"e9de"},{font_family:"sg-ele",my_class:"uniE03D",unicode:"e977"},{font_family:"sg-ele",my_class:"uniE05D",unicode:"e985"},{font_family:"sg-ele",my_class:"uniE0EA",unicode:"e94e"},{font_family:"sg-ele",my_class:"uniE08E",unicode:"e99b"},{font_family:"sg-ele",my_class:"uniE07A",unicode:"e990"},{font_family:"sg-ele",my_class:"uniE07B",unicode:"e991"},{font_family:"sg-ele",my_class:"uniE074",unicode:"ea01"},{font_family:"sg-ele",my_class:"uniE078",unicode:"ea05"}]},{name:"\u7535\u529B\u7CFB\u7EDF-7",show:!0,list:[{font_family:"sg-ele",my_class:"uniE02A",unicode:"e96d"},{font_family:"sg-ele",my_class:"uniE02E",unicode:"e971"},{font_family:"sg-ele",my_class:"uniE02F",unicode:"e972"},{font_family:"sg-ele",my_class:"uniE131",unicode:"ea3a"},{font_family:"sg-ele",my_class:"uniE132",unicode:"ea3b"},{font_family:"sg-ele",my_class:"uniE143",unicode:"ea46"},{font_family:"sg-ele",my_class:"uniE0A4",unicode:"e905"},{font_family:"sg-ele",my_class:"uniE144",unicode:"ea47"},{font_family:"sg-ele",my_class:"uniE146",unicode:"ea49"},{font_family:"sg-ele",my_class:"uniE149",unicode:"ea4c"},{font_family:"sg-ele",my_class:"uniE150",unicode:"ea4d"},{font_family:"sg-ele",my_class:"uniE154",unicode:"ea50"},{font_family:"sg-ele",my_class:"uniE151",unicode:"ea4e"},{font_family:"sg-ele",my_class:"uniE138",unicode:"ea41"},{font_family:"sg-ele",my_class:"uniE0C2",unicode:"e925"},{font_family:"sg-ele",my_class:"uniE027",unicode:"e9d2"},{font_family:"sg-ele",my_class:"uniE141",unicode:"ea44"},{font_family:"sg-ele",my_class:"uniE126",unicode:"ea35"},{font_family:"sg-ele",my_class:"uniE129",unicode:"ea38"},{font_family:"sg-ele",my_class:"uniE130",unicode:"ea39"},{font_family:"sg-ele",my_class:"uniE069",unicode:"e9fc"},{font_family:"sg-ele",my_class:"uniE057",unicode:"e9f0"},{font_family:"sg-ele",my_class:"uniE058",unicode:"e9f1"},{font_family:"sg-ele",my_class:"uniE030",unicode:"e9d5"},{font_family:"sg-ele",my_class:"uniE031",unicode:"e9d6"},{font_family:"sg-ele",my_class:"uniE032",unicode:"e9d7"},{font_family:"sg-ele",my_class:"uniE033",unicode:"e9d8"},{font_family:"sg-ele",my_class:"uniE034",unicode:"e9d9"},{font_family:"sg-ele",my_class:"uniE12B",unicode:"e9b3"},{font_family:"sg-ele",my_class:"uniE12D",unicode:"e9b5"},{font_family:"sg-ele",my_class:"uniE12E",unicode:"e9b6"},{font_family:"sg-ele",my_class:"uniE12F",unicode:"e9b7"},{font_family:"sg-ele",my_class:"uniE14A",unicode:"e9c0"},{font_family:"sg-ele",my_class:"uniE14C",unicode:"e9c2"},{font_family:"sg-ele",my_class:"uniE14E",unicode:"e9c4"},{font_family:"sg-ele",my_class:"uniE06A",unicode:"e989"},{font_family:"sg-ele",my_class:"uniE011",unicode:"e9ab"},{font_family:"sg-ele",my_class:"uniE075",unicode:"ea02"},{font_family:"sg-ele",my_class:"uniE083",unicode:"ea0a"},{font_family:"sg-ele",my_class:"uniE0C4",unicode:"e927"},{font_family:"sg-ele",my_class:"uniE0B1",unicode:"e913"},{font_family:"sg-ele",my_class:"uniE0FE",unicode:"e963"}]},{name:"\u7535\u529B\u7CFB\u7EDF-8",show:!0,list:[{font_family:"sg-ele",my_class:"uniE114",unicode:"ea29"},{font_family:"sg-ele",my_class:"uniE115",unicode:"ea2a"},{font_family:"sg-ele",my_class:"uniE116",unicode:"ea2b"},{font_family:"sg-ele",my_class:"uniE117",unicode:"ea2c"},{font_family:"sg-ele",my_class:"uniE118",unicode:"ea2d"},{font_family:"sg-ele",my_class:"uniE119",unicode:"ea2e"},{font_family:"sg-ele",my_class:"uniE121",unicode:"ea30"},{font_family:"sg-ele",my_class:"uniE124",unicode:"ea33"},{font_family:"sg-ele",my_class:"uniE0B0",unicode:"e912"},{font_family:"sg-ele",my_class:"uniE0B7",unicode:"e919"},{font_family:"sg-ele",my_class:"uniE0BA",unicode:"e91c"},{font_family:"sg-ele",my_class:"uniE0BB",unicode:"e91d"},{font_family:"sg-ele",my_class:"uniE0BD",unicode:"e91f"},{font_family:"sg-ele",my_class:"uniE0C1",unicode:"e924"},{font_family:"sg-ele",my_class:"uniE0CC",unicode:"e92e"},{font_family:"sg-ele",my_class:"uniE0DA",unicode:"e93d"},{font_family:"sg-ele",my_class:"uniE0F3",unicode:"e958"},{font_family:"sg-ele",my_class:"uniE0F4",unicode:"e959"},{font_family:"sg-ele",my_class:"uniE0F6",unicode:"e95b"},{font_family:"sg-ele",my_class:"uniE0F7",unicode:"e95c"},{font_family:"sg-ele",my_class:"uniE0F8",unicode:"e95d"},{font_family:"sg-ele",my_class:"uniE0F9",unicode:"e95e"},{font_family:"sg-ele",my_class:"uniE0FD",unicode:"e962"},{font_family:"sg-ele",my_class:"uniE04F",unicode:"e980"},{font_family:"sg-ele",my_class:"uniE05B",unicode:"e983"},{font_family:"sg-ele",my_class:"uniE11A",unicode:"e9ac"},{font_family:"sg-ele",my_class:"uniE11C",unicode:"e9ae"},{font_family:"sg-ele",my_class:"uniE11D",unicode:"e9af"},{font_family:"sg-ele",my_class:"uniE11E",unicode:"e9b0"},{font_family:"sg-ele",my_class:"uniE13C",unicode:"e9bb"},{font_family:"sg-ele",my_class:"uniE13D",unicode:"e9bc"},{font_family:"sg-ele",my_class:"uniE13E",unicode:"e9bd"},{font_family:"sg-ele",my_class:"uniE052",unicode:"e9eb"},{font_family:"sg-ele",my_class:"uniE055",unicode:"e9ee"},{font_family:"sg-ele",my_class:"uniE060",unicode:"e9f3"},{font_family:"sg-ele",my_class:"uniE0B4",unicode:"e916"},{font_family:"sg-ele",my_class:"uniE0BF",unicode:"e921"},{font_family:"sg-ele",my_class:"uniE0CA",unicode:"e92c"},{font_family:"sg-ele",my_class:"uniE0D7",unicode:"e93a"},{font_family:"sg-ele",my_class:"uniE06B",unicode:"e98a"},{font_family:"sg-ele",my_class:"uniE10A",unicode:"e9a5"},{font_family:"sg-ele",my_class:"uniE017",unicode:"e9c8"},{font_family:"sg-ele",my_class:"uniE050",unicode:"e9e9"},{font_family:"sg-ele",my_class:"uniE086",unicode:"ea0d"},{font_family:"sg-ele",my_class:"uniE099",unicode:"ea1a"},{font_family:"sg-ele",my_class:"uniE101",unicode:"ea1c"}]},{name:"\u7535\u529B\u7CFB\u7EDF-9",show:!0,list:[{font_family:"sg-ele",my_class:"uniE106",unicode:"ea21"},{font_family:"sg-ele",my_class:"uniE109",unicode:"ea24"},{font_family:"sg-ele",my_class:"uniE061",unicode:"e9f4"},{font_family:"sg-ele",my_class:"uniE092",unicode:"ea13"},{font_family:"sg-ele",my_class:"uniE01B",unicode:"e967"},{font_family:"sg-ele",my_class:"uniE01C",unicode:"e968"},{font_family:"sg-ele",my_class:"uniE09D",unicode:"e9a1"},{font_family:"sg-ele",my_class:"uniE09F",unicode:"e9a3"},{font_family:"sg-ele",my_class:"uniE11F",unicode:"e9b1"},{font_family:"sg-ele",my_class:"uniE13F",unicode:"e9be"},{font_family:"sg-ele",my_class:"uniE016",unicode:"e9c7"},{font_family:"sg-ele",my_class:"uniE125",unicode:"ea34"},{font_family:"sg-ele",my_class:"uniE137",unicode:"ea40"},{font_family:"sg-ele",my_class:"uniE142",unicode:"ea45"},{font_family:"sg-ele",my_class:"uniE0C3",unicode:"e926"},{font_family:"sg-ele",my_class:"uniE0CF",unicode:"e931"},{font_family:"sg-ele",my_class:"uniE0D0",unicode:"e933"},{font_family:"sg-ele",my_class:"uniE0D2",unicode:"e935"},{font_family:"sg-ele",my_class:"uniE0D4",unicode:"e937"},{font_family:"sg-ele",my_class:"uniE0D6",unicode:"e939"},{font_family:"sg-ele",my_class:"uniE051",unicode:"e9ea"}]},{name:"\u8111\u56FE",show:!1,list:[{name:"mindNode",icon:"t-icon t-zhuti",data:{text:"\u4E3B\u9898",width:200,height:50,name:"mindNode",borderRadius:.5}},{name:"mindLine",icon:"t-icon t-zizhuti",data:{text:"\u5B50\u4E3B\u9898",width:160,height:40,name:"mindLine"}}]},{name:"\u6D41\u7A0B\u56FE",show:!1,list:[{name:"\u5F00\u59CB/\u7ED3\u675F",icon:"t-icon t-flow-start",id:21,data:{text:"\u5F00\u59CB/\u7ED3\u675F",width:120,height:40,borderRadius:.5,name:"rectangle"}},{name:"\u6D41\u7A0B",icon:"t-icon t-rectangle",id:22,data:{text:"\u6D41\u7A0B",width:120,height:40,name:"rectangle"}},{name:"\u5224\u5B9A",icon:"t-icon t-diamond",id:23,data:{text:"\u5224\u5B9A",width:120,height:60,name:"diamond"}},{name:"\u6570\u636E",icon:"t-icon t-flow-data",id:24,data:{text:"\u6570\u636E",width:120,height:50,name:"flowData"}},{name:"\u51C6\u5907",icon:"t-icon t-flow-ready",id:25,data:{text:"\u51C6\u5907",width:120,height:50,name:"hexagon"}},{name:"\u5B50\u6D41\u7A0B",icon:"t-icon t-flow-subprocess",id:26,data:{text:"\u5B50\u6D41\u7A0B",width:120,height:50,name:"flowSubprocess"}},{name:"\u6570\u636E\u5E93",icon:"t-icon t-db",id:27,data:{text:"\u6570\u636E\u5E93",width:80,height:120,name:"flowDb"}},{name:"\u6587\u6863",icon:"t-icon t-flow-document",id:28,data:{text:"\u6587\u6863",width:120,height:100,name:"flowDocument"}},{name:"\u5185\u90E8\u5B58\u50A8",icon:"t-icon t-internal-storage",id:29,data:{text:"\u5185\u90E8\u5B58\u50A8",width:120,height:80,name:"flowInternalStorage"}},{name:"\u5916\u90E8\u5B58\u50A8",icon:"t-icon t-extern-storage",id:30,data:{text:"\u5916\u90E8\u5B58\u50A8",width:120,height:80,name:"flowExternStorage"}},{name:"\u961F\u5217",icon:"t-icon t-flow-queue",id:31,data:{text:"\u961F\u5217",width:100,height:100,name:"flowQueue"}},{name:"\u624B\u52A8\u8F93\u5165",icon:"t-icon t-flow-manually",id:32,data:{text:"\u624B\u52A8\u8F93\u5165",width:120,height:80,name:"flowManually"}},{name:"\u5C55\u793A",icon:"t-icon t-flow-display",id:33,data:{text:"\u5C55\u793A",width:120,height:80,name:"flowDisplay"}},{name:"\u5E76\u884C\u6A21\u5F0F",icon:"t-icon t-flow-parallel",id:34,data:{text:"\u5E76\u884C\u6A21\u5F0F",width:120,height:50,name:"flowParallel"}},{name:"\u6CE8\u91CA",icon:"t-icon t-flow-comment",id:35,data:{text:"\u6CE8\u91CA",width:100,height:100,name:"flowComment"}}]},{name:"\u6D3B\u52A8\u56FE",show:!1,list:[{name:"\u5F00\u59CB",icon:"t-icon t-inital",id:36,data:{text:"",width:30,height:30,name:"circle",background:"#555",color:"transparent"}},{name:"\u7ED3\u675F",icon:"t-icon t-final",id:37,data:{width:30,height:30,name:"activityFinal"}},{name:"\u6D3B\u52A8",icon:"t-icon t-action",id:38,data:{text:"\u6D3B\u52A8",width:120,height:50,borderRadius:.25,name:"rectangle"}},{name:"\u51B3\u7B56/\u5408\u5E76",icon:"t-icon t-diamond",id:39,data:{text:"\u51B3\u7B56/\u5408\u5E76",width:120,height:50,name:"diamond"}},{name:"\u5782\u76F4\u6CF3\u9053",icon:"t-icon t-swimlane-v",id:40,data:{text:"\u5782\u76F4\u6CF3\u9053",width:200,height:500,name:"swimlaneV",textHeight:.1}},{name:"\u6C34\u5E73\u6CF3\u9053",icon:"t-icon t-swimlane-h",id:41,data:{text:"\u6C34\u5E73\u6CF3\u9053",width:500,height:200,name:"swimlaneH",textWidth:.01,textLeft:.04,textAlign:"start"}},{name:"\u5782\u76F4\u5206\u5C94/\u6C47\u5408",icon:"t-icon t-fork-v",id:42,data:{text:"\u5782\u76F4\u5206\u5C94/\u6C47\u5408",width:10,height:150,name:"forkV",fillStyle:"#555",strokeStyle:"transparent"}},{name:"\u6C34\u5E73\u5206\u5C94/\u6C47\u5408",icon:"t-icon t-fork",id:43,data:{text:"\u6C34\u5E73\u5206\u5C94/\u6C47\u5408",width:150,height:10,name:"forkH",fillStyle:"#555",strokeStyle:"transparent"}}]},{name:"\u65F6\u5E8F\u56FE\u548C\u7C7B\u56FE",show:!1,list:[{name:"\u751F\u547D\u7EBF",icon:"t-icon t-lifeline",id:44,data:{text:"\u751F\u547D\u7EBF",width:150,height:400,textHeight:50,name:"lifeline"}},{name:"\u6FC0\u6D3B",icon:"t-icon t-focus",id:45,data:{text:"\u6FC0\u6D3B",width:12,height:200,name:"sequenceFocus"}},{name:"\u7B80\u5355\u7C7B",icon:"t-icon t-simple-class",id:46,data:{text:"Topolgoy",width:270,height:200,textHeight:.2,name:"simpleClass",textAlign:"center",textBaseline:"top",textTop:10,list:[{text:`- name: string
- + setName(name: string): void`}]}},{name:"\u7C7B",icon:"t-icon t-class",id:47,data:{text:"Topolgoy",width:270,height:200,textHeight:.2,name:"interfaceClass",textAlign:"center",textBaseline:"top",textTop:10,list:[{text:"- name: string"},{text:"+ setName(name: string): void"}]}}]}];var Ji={};(function(e){var t=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";function i(r,a){return Object.prototype.hasOwnProperty.call(r,a)}e.assign=function(r){for(var a=Array.prototype.slice.call(arguments,1);a.length;){var o=a.shift();if(!!o){if(typeof o!="object")throw new TypeError(o+"must be non-object");for(var l in o)i(o,l)&&(r[l]=o[l])}}return r},e.shrinkBuf=function(r,a){return r.length===a?r:r.subarray?r.subarray(0,a):(r.length=a,r)};var s={arraySet:function(r,a,o,l,u){if(a.subarray&&r.subarray){r.set(a.subarray(o,o+l),u);return}for(var h=0;h<l;h++)r[u+h]=a[o+h]},flattenChunks:function(r){var a,o,l,u,h,f;for(l=0,a=0,o=r.length;a<o;a++)l+=r[a].length;for(f=new Uint8Array(l),u=0,a=0,o=r.length;a<o;a++)h=r[a],f.set(h,u),u+=h.length;return f}},n={arraySet:function(r,a,o,l,u){for(var h=0;h<l;h++)r[u+h]=a[o+h]},flattenChunks:function(r){return[].concat.apply([],r)}};e.setTyped=function(r){r?(e.Buf8=Uint8Array,e.Buf16=Uint16Array,e.Buf32=Int32Array,e.assign(e,s)):(e.Buf8=Array,e.Buf16=Array,e.Buf32=Array,e.assign(e,n))},e.setTyped(t)})(Ji);var kr={},Ii={},In={},tA=Ji,eA=4,zf=0,Hf=1,iA=2;function Ln(e){for(var t=e.length;--t>=0;)e[t]=0}var sA=0,Cg=1,nA=2,rA=3,aA=258,xc=29,Er=256,yr=Er+1+xc,An=30,_c=19,Tg=2*yr+1,Bs=15,Il=16,oA=7,kc=256,Rg=16,Sg=17,Pg=18,ic=[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],La=[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],lA=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],Ig=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],cA=512,$i=new Array((yr+2)*2);Ln($i);var lr=new Array(An*2);Ln(lr);var mr=new Array(cA);Ln(mr);var pr=new Array(aA-rA+1);Ln(pr);var Ec=new Array(xc);Ln(Ec);var Ya=new Array(An);Ln(Ya);function Ll(e,t,i,s,n){this.static_tree=e,this.extra_bits=t,this.extra_base=i,this.elems=s,this.max_length=n,this.has_stree=e&&e.length}var Lg,Dg,Mg;function Dl(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}function Bg(e){return e<256?mr[e]:mr[256+(e>>>7)]}function wr(e,t){e.pending_buf[e.pending++]=t&255,e.pending_buf[e.pending++]=t>>>8&255}function Ue(e,t,i){e.bi_valid>Il-i?(e.bi_buf|=t<<e.bi_valid&65535,wr(e,e.bi_buf),e.bi_buf=t>>Il-e.bi_valid,e.bi_valid+=i-Il):(e.bi_buf|=t<<e.bi_valid&65535,e.bi_valid+=i)}function Ri(e,t,i){Ue(e,i[t*2],i[t*2+1])}function Og(e,t){var i=0;do i|=e&1,e>>>=1,i<<=1;while(--t>0);return i>>>1}function hA(e){e.bi_valid===16?(wr(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 uA(e,t){var i=t.dyn_tree,s=t.max_code,n=t.stat_desc.static_tree,r=t.stat_desc.has_stree,a=t.stat_desc.extra_bits,o=t.stat_desc.extra_base,l=t.stat_desc.max_length,u,h,f,g,v,y,w=0;for(g=0;g<=Bs;g++)e.bl_count[g]=0;for(i[e.heap[e.heap_max]*2+1]=0,u=e.heap_max+1;u<Tg;u++)h=e.heap[u],g=i[i[h*2+1]*2+1]+1,g>l&&(g=l,w++),i[h*2+1]=g,!(h>s)&&(e.bl_count[g]++,v=0,h>=o&&(v=a[h-o]),y=i[h*2],e.opt_len+=y*(g+v),r&&(e.static_len+=y*(n[h*2+1]+v)));if(w!==0){do{for(g=l-1;e.bl_count[g]===0;)g--;e.bl_count[g]--,e.bl_count[g+1]+=2,e.bl_count[l]--,w-=2}while(w>0);for(g=l;g!==0;g--)for(h=e.bl_count[g];h!==0;)f=e.heap[--u],!(f>s)&&(i[f*2+1]!==g&&(e.opt_len+=(g-i[f*2+1])*i[f*2],i[f*2+1]=g),h--)}}function Ng(e,t,i){var s=new Array(Bs+1),n=0,r,a;for(r=1;r<=Bs;r++)s[r]=n=n+i[r-1]<<1;for(a=0;a<=t;a++){var o=e[a*2+1];o!==0&&(e[a*2]=Og(s[o]++,o))}}function fA(){var e,t,i,s,n,r=new Array(Bs+1);for(i=0,s=0;s<xc-1;s++)for(Ec[s]=i,e=0;e<1<<ic[s];e++)pr[i++]=s;for(pr[i-1]=s,n=0,s=0;s<16;s++)for(Ya[s]=n,e=0;e<1<<La[s];e++)mr[n++]=s;for(n>>=7;s<An;s++)for(Ya[s]=n<<7,e=0;e<1<<La[s]-7;e++)mr[256+n++]=s;for(t=0;t<=Bs;t++)r[t]=0;for(e=0;e<=143;)$i[e*2+1]=8,e++,r[8]++;for(;e<=255;)$i[e*2+1]=9,e++,r[9]++;for(;e<=279;)$i[e*2+1]=7,e++,r[7]++;for(;e<=287;)$i[e*2+1]=8,e++,r[8]++;for(Ng($i,yr+1,r),e=0;e<An;e++)lr[e*2+1]=5,lr[e*2]=Og(e,5);Lg=new Ll($i,ic,Er+1,yr,Bs),Dg=new Ll(lr,La,0,An,Bs),Mg=new Ll(new Array(0),lA,0,_c,oA)}function Fg(e){var t;for(t=0;t<yr;t++)e.dyn_ltree[t*2]=0;for(t=0;t<An;t++)e.dyn_dtree[t*2]=0;for(t=0;t<_c;t++)e.bl_tree[t*2]=0;e.dyn_ltree[kc*2]=1,e.opt_len=e.static_len=0,e.last_lit=e.matches=0}function zg(e){e.bi_valid>8?wr(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 dA(e,t,i,s){zg(e),s&&(wr(e,i),wr(e,~i)),tA.arraySet(e.pending_buf,e.window,t,i,e.pending),e.pending+=i}function Wf(e,t,i,s){var n=t*2,r=i*2;return e[n]<e[r]||e[n]===e[r]&&s[t]<=s[i]}function Ml(e,t,i){for(var s=e.heap[i],n=i<<1;n<=e.heap_len&&(n<e.heap_len&&Wf(t,e.heap[n+1],e.heap[n],e.depth)&&n++,!Wf(t,s,e.heap[n],e.depth));)e.heap[i]=e.heap[n],i=n,n<<=1;e.heap[i]=s}function Uf(e,t,i){var s,n,r=0,a,o;if(e.last_lit!==0)do s=e.pending_buf[e.d_buf+r*2]<<8|e.pending_buf[e.d_buf+r*2+1],n=e.pending_buf[e.l_buf+r],r++,s===0?Ri(e,n,t):(a=pr[n],Ri(e,a+Er+1,t),o=ic[a],o!==0&&(n-=Ec[a],Ue(e,n,o)),s--,a=Bg(s),Ri(e,a,i),o=La[a],o!==0&&(s-=Ya[a],Ue(e,s,o)));while(r<e.last_lit);Ri(e,kc,t)}function sc(e,t){var i=t.dyn_tree,s=t.stat_desc.static_tree,n=t.stat_desc.has_stree,r=t.stat_desc.elems,a,o,l=-1,u;for(e.heap_len=0,e.heap_max=Tg,a=0;a<r;a++)i[a*2]!==0?(e.heap[++e.heap_len]=l=a,e.depth[a]=0):i[a*2+1]=0;for(;e.heap_len<2;)u=e.heap[++e.heap_len]=l<2?++l:0,i[u*2]=1,e.depth[u]=0,e.opt_len--,n&&(e.static_len-=s[u*2+1]);for(t.max_code=l,a=e.heap_len>>1;a>=1;a--)Ml(e,i,a);u=r;do a=e.heap[1],e.heap[1]=e.heap[e.heap_len--],Ml(e,i,1),o=e.heap[1],e.heap[--e.heap_max]=a,e.heap[--e.heap_max]=o,i[u*2]=i[a*2]+i[o*2],e.depth[u]=(e.depth[a]>=e.depth[o]?e.depth[a]:e.depth[o])+1,i[a*2+1]=i[o*2+1]=u,e.heap[1]=u++,Ml(e,i,1);while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],uA(e,t),Ng(i,l,e.bl_count)}function Vf(e,t,i){var s,n=-1,r,a=t[0*2+1],o=0,l=7,u=4;for(a===0&&(l=138,u=3),t[(i+1)*2+1]=65535,s=0;s<=i;s++)r=a,a=t[(s+1)*2+1],!(++o<l&&r===a)&&(o<u?e.bl_tree[r*2]+=o:r!==0?(r!==n&&e.bl_tree[r*2]++,e.bl_tree[Rg*2]++):o<=10?e.bl_tree[Sg*2]++:e.bl_tree[Pg*2]++,o=0,n=r,a===0?(l=138,u=3):r===a?(l=6,u=3):(l=7,u=4))}function jf(e,t,i){var s,n=-1,r,a=t[0*2+1],o=0,l=7,u=4;for(a===0&&(l=138,u=3),s=0;s<=i;s++)if(r=a,a=t[(s+1)*2+1],!(++o<l&&r===a)){if(o<u)do Ri(e,r,e.bl_tree);while(--o!==0);else r!==0?(r!==n&&(Ri(e,r,e.bl_tree),o--),Ri(e,Rg,e.bl_tree),Ue(e,o-3,2)):o<=10?(Ri(e,Sg,e.bl_tree),Ue(e,o-3,3)):(Ri(e,Pg,e.bl_tree),Ue(e,o-11,7));o=0,n=r,a===0?(l=138,u=3):r===a?(l=6,u=3):(l=7,u=4)}}function gA(e){var t;for(Vf(e,e.dyn_ltree,e.l_desc.max_code),Vf(e,e.dyn_dtree,e.d_desc.max_code),sc(e,e.bl_desc),t=_c-1;t>=3&&e.bl_tree[Ig[t]*2+1]===0;t--);return e.opt_len+=3*(t+1)+5+5+4,t}function vA(e,t,i,s){var n;for(Ue(e,t-257,5),Ue(e,i-1,5),Ue(e,s-4,4),n=0;n<s;n++)Ue(e,e.bl_tree[Ig[n]*2+1],3);jf(e,e.dyn_ltree,t-1),jf(e,e.dyn_dtree,i-1)}function yA(e){var t=4093624447,i;for(i=0;i<=31;i++,t>>>=1)if(t&1&&e.dyn_ltree[i*2]!==0)return zf;if(e.dyn_ltree[9*2]!==0||e.dyn_ltree[10*2]!==0||e.dyn_ltree[13*2]!==0)return Hf;for(i=32;i<Er;i++)if(e.dyn_ltree[i*2]!==0)return Hf;return zf}var $f=!1;function mA(e){$f||(fA(),$f=!0),e.l_desc=new Dl(e.dyn_ltree,Lg),e.d_desc=new Dl(e.dyn_dtree,Dg),e.bl_desc=new Dl(e.bl_tree,Mg),e.bi_buf=0,e.bi_valid=0,Fg(e)}function Hg(e,t,i,s){Ue(e,(sA<<1)+(s?1:0),3),dA(e,t,i,!0)}function pA(e){Ue(e,Cg<<1,3),Ri(e,kc,$i),hA(e)}function wA(e,t,i,s){var n,r,a=0;e.level>0?(e.strm.data_type===iA&&(e.strm.data_type=yA(e)),sc(e,e.l_desc),sc(e,e.d_desc),a=gA(e),n=e.opt_len+3+7>>>3,r=e.static_len+3+7>>>3,r<=n&&(n=r)):n=r=i+5,i+4<=n&&t!==-1?Hg(e,t,i,s):e.strategy===eA||r===n?(Ue(e,(Cg<<1)+(s?1:0),3),Uf(e,$i,lr)):(Ue(e,(nA<<1)+(s?1:0),3),vA(e,e.l_desc.max_code+1,e.d_desc.max_code+1,a+1),Uf(e,e.dyn_ltree,e.dyn_dtree)),Fg(e),s&&zg(e)}function bA(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[(pr[i]+Er+1)*2]++,e.dyn_dtree[Bg(t)*2]++),e.last_lit===e.lit_bufsize-1}In._tr_init=mA;In._tr_stored_block=Hg;In._tr_flush_block=wA;In._tr_tally=bA;In._tr_align=pA;function xA(e,t,i,s){for(var n=e&65535|0,r=e>>>16&65535|0,a=0;i!==0;){a=i>2e3?2e3:i,i-=a;do n=n+t[s++]|0,r=r+n|0;while(--a);n%=65521,r%=65521}return n|r<<16|0}var Wg=xA;function _A(){for(var e,t=[],i=0;i<256;i++){e=i;for(var s=0;s<8;s++)e=e&1?3988292384^e>>>1:e>>>1;t[i]=e}return t}var kA=_A();function EA(e,t,i,s){var n=kA,r=s+i;e^=-1;for(var a=s;a<r;a++)e=e>>>8^n[(e^t[a])&255];return e^-1}var Ug=EA,Ac={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"},Me=Ji,hi=In,Vg=Wg,fs=Ug,AA=Ac,Ks=0,CA=1,TA=3,ws=4,qf=5,Si=0,Yf=1,ui=-2,RA=-3,Bl=-5,SA=-1,PA=1,Ea=2,IA=3,LA=4,DA=0,MA=2,Za=8,BA=9,OA=15,NA=8,FA=29,zA=256,nc=zA+1+FA,HA=30,WA=19,UA=2*nc+1,VA=15,Wt=3,ms=258,wi=ms+Wt+1,jA=32,Ja=42,rc=69,Da=73,Ma=91,Ba=103,Os=113,sr=666,me=1,Ar=2,Us=3,Dn=4,$A=3;function ps(e,t){return e.msg=AA[t],t}function Kf(e){return(e<<1)-(e>4?9:0)}function vs(e){for(var t=e.length;--t>=0;)e[t]=0}function ds(e){var t=e.state,i=t.pending;i>e.avail_out&&(i=e.avail_out),i!==0&&(Me.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 Ce(e,t){hi._tr_flush_block(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,ds(e.strm)}function Ut(e,t){e.pending_buf[e.pending++]=t}function Jn(e,t){e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=t&255}function qA(e,t,i,s){var n=e.avail_in;return n>s&&(n=s),n===0?0:(e.avail_in-=n,Me.arraySet(t,e.input,e.next_in,n,i),e.state.wrap===1?e.adler=Vg(e.adler,t,n,i):e.state.wrap===2&&(e.adler=fs(e.adler,t,n,i)),e.next_in+=n,e.total_in+=n,n)}function jg(e,t){var i=e.max_chain_length,s=e.strstart,n,r,a=e.prev_length,o=e.nice_match,l=e.strstart>e.w_size-wi?e.strstart-(e.w_size-wi):0,u=e.window,h=e.w_mask,f=e.prev,g=e.strstart+ms,v=u[s+a-1],y=u[s+a];e.prev_length>=e.good_match&&(i>>=2),o>e.lookahead&&(o=e.lookahead);do if(n=t,!(u[n+a]!==y||u[n+a-1]!==v||u[n]!==u[s]||u[++n]!==u[s+1])){s+=2,n++;do;while(u[++s]===u[++n]&&u[++s]===u[++n]&&u[++s]===u[++n]&&u[++s]===u[++n]&&u[++s]===u[++n]&&u[++s]===u[++n]&&u[++s]===u[++n]&&u[++s]===u[++n]&&s<g);if(r=ms-(g-s),s=g-ms,r>a){if(e.match_start=t,a=r,r>=o)break;v=u[s+a-1],y=u[s+a]}}while((t=f[t&h])>l&&--i!==0);return a<=e.lookahead?a:e.lookahead}function Vs(e){var t=e.w_size,i,s,n,r,a;do{if(r=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-wi)){Me.arraySet(e.window,e.window,t,t,0),e.match_start-=t,e.strstart-=t,e.block_start-=t,s=e.hash_size,i=s;do n=e.head[--i],e.head[i]=n>=t?n-t:0;while(--s);s=t,i=s;do n=e.prev[--i],e.prev[i]=n>=t?n-t:0;while(--s);r+=t}if(e.strm.avail_in===0)break;if(s=qA(e.strm,e.window,e.strstart+e.lookahead,r),e.lookahead+=s,e.lookahead+e.insert>=Wt)for(a=e.strstart-e.insert,e.ins_h=e.window[a],e.ins_h=(e.ins_h<<e.hash_shift^e.window[a+1])&e.hash_mask;e.insert&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[a+Wt-1])&e.hash_mask,e.prev[a&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=a,a++,e.insert--,!(e.lookahead+e.insert<Wt)););}while(e.lookahead<wi&&e.strm.avail_in!==0)}function YA(e,t){var i=65535;for(i>e.pending_buf_size-5&&(i=e.pending_buf_size-5);;){if(e.lookahead<=1){if(Vs(e),e.lookahead===0&&t===Ks)return me;if(e.lookahead===0)break}e.strstart+=e.lookahead,e.lookahead=0;var s=e.block_start+i;if((e.strstart===0||e.strstart>=s)&&(e.lookahead=e.strstart-s,e.strstart=s,Ce(e,!1),e.strm.avail_out===0)||e.strstart-e.block_start>=e.w_size-wi&&(Ce(e,!1),e.strm.avail_out===0))return me}return e.insert=0,t===ws?(Ce(e,!0),e.strm.avail_out===0?Us:Dn):(e.strstart>e.block_start&&(Ce(e,!1),e.strm.avail_out===0),me)}function Ol(e,t){for(var i,s;;){if(e.lookahead<wi){if(Vs(e),e.lookahead<wi&&t===Ks)return me;if(e.lookahead===0)break}if(i=0,e.lookahead>=Wt&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+Wt-1])&e.hash_mask,i=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),i!==0&&e.strstart-i<=e.w_size-wi&&(e.match_length=jg(e,i)),e.match_length>=Wt)if(s=hi._tr_tally(e,e.strstart-e.match_start,e.match_length-Wt),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=Wt){e.match_length--;do e.strstart++,e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+Wt-1])&e.hash_mask,i=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart;while(--e.match_length!==0);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+1])&e.hash_mask;else s=hi._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(s&&(Ce(e,!1),e.strm.avail_out===0))return me}return e.insert=e.strstart<Wt-1?e.strstart:Wt-1,t===ws?(Ce(e,!0),e.strm.avail_out===0?Us:Dn):e.last_lit&&(Ce(e,!1),e.strm.avail_out===0)?me:Ar}function vn(e,t){for(var i,s,n;;){if(e.lookahead<wi){if(Vs(e),e.lookahead<wi&&t===Ks)return me;if(e.lookahead===0)break}if(i=0,e.lookahead>=Wt&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+Wt-1])&e.hash_mask,i=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=Wt-1,i!==0&&e.prev_length<e.max_lazy_match&&e.strstart-i<=e.w_size-wi&&(e.match_length=jg(e,i),e.match_length<=5&&(e.strategy===PA||e.match_length===Wt&&e.strstart-e.match_start>4096)&&(e.match_length=Wt-1)),e.prev_length>=Wt&&e.match_length<=e.prev_length){n=e.strstart+e.lookahead-Wt,s=hi._tr_tally(e,e.strstart-1-e.prev_match,e.prev_length-Wt),e.lookahead-=e.prev_length-1,e.prev_length-=2;do++e.strstart<=n&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+Wt-1])&e.hash_mask,i=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart);while(--e.prev_length!==0);if(e.match_available=0,e.match_length=Wt-1,e.strstart++,s&&(Ce(e,!1),e.strm.avail_out===0))return me}else if(e.match_available){if(s=hi._tr_tally(e,0,e.window[e.strstart-1]),s&&Ce(e,!1),e.strstart++,e.lookahead--,e.strm.avail_out===0)return me}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(s=hi._tr_tally(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<Wt-1?e.strstart:Wt-1,t===ws?(Ce(e,!0),e.strm.avail_out===0?Us:Dn):e.last_lit&&(Ce(e,!1),e.strm.avail_out===0)?me:Ar}function KA(e,t){for(var i,s,n,r,a=e.window;;){if(e.lookahead<=ms){if(Vs(e),e.lookahead<=ms&&t===Ks)return me;if(e.lookahead===0)break}if(e.match_length=0,e.lookahead>=Wt&&e.strstart>0&&(n=e.strstart-1,s=a[n],s===a[++n]&&s===a[++n]&&s===a[++n])){r=e.strstart+ms;do;while(s===a[++n]&&s===a[++n]&&s===a[++n]&&s===a[++n]&&s===a[++n]&&s===a[++n]&&s===a[++n]&&s===a[++n]&&n<r);e.match_length=ms-(r-n),e.match_length>e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=Wt?(i=hi._tr_tally(e,1,e.match_length-Wt),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(i=hi._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),i&&(Ce(e,!1),e.strm.avail_out===0))return me}return e.insert=0,t===ws?(Ce(e,!0),e.strm.avail_out===0?Us:Dn):e.last_lit&&(Ce(e,!1),e.strm.avail_out===0)?me:Ar}function XA(e,t){for(var i;;){if(e.lookahead===0&&(Vs(e),e.lookahead===0)){if(t===Ks)return me;break}if(e.match_length=0,i=hi._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,i&&(Ce(e,!1),e.strm.avail_out===0))return me}return e.insert=0,t===ws?(Ce(e,!0),e.strm.avail_out===0?Us:Dn):e.last_lit&&(Ce(e,!1),e.strm.avail_out===0)?me:Ar}function Ai(e,t,i,s,n){this.good_length=e,this.max_lazy=t,this.nice_length=i,this.max_chain=s,this.func=n}var _n;_n=[new Ai(0,0,0,0,YA),new Ai(4,4,8,4,Ol),new Ai(4,5,16,8,Ol),new Ai(4,6,32,32,Ol),new Ai(4,4,16,16,vn),new Ai(8,16,32,32,vn),new Ai(8,16,128,128,vn),new Ai(8,32,128,256,vn),new Ai(32,128,258,1024,vn),new Ai(32,258,258,4096,vn)];function GA(e){e.window_size=2*e.w_size,vs(e.head),e.max_lazy_match=_n[e.level].max_lazy,e.good_match=_n[e.level].good_length,e.nice_match=_n[e.level].nice_length,e.max_chain_length=_n[e.level].max_chain,e.strstart=0,e.block_start=0,e.lookahead=0,e.insert=0,e.match_length=e.prev_length=Wt-1,e.match_available=0,e.ins_h=0}function ZA(){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=Za,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 Me.Buf16(UA*2),this.dyn_dtree=new Me.Buf16((2*HA+1)*2),this.bl_tree=new Me.Buf16((2*WA+1)*2),vs(this.dyn_ltree),vs(this.dyn_dtree),vs(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Me.Buf16(VA+1),this.heap=new Me.Buf16(2*nc+1),vs(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Me.Buf16(2*nc+1),vs(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 $g(e){var t;return!e||!e.state?ps(e,ui):(e.total_in=e.total_out=0,e.data_type=MA,t=e.state,t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=t.wrap?Ja:Os,e.adler=t.wrap===2?0:1,t.last_flush=Ks,hi._tr_init(t),Si)}function qg(e){var t=$g(e);return t===Si&&GA(e.state),t}function JA(e,t){return!e||!e.state||e.state.wrap!==2?ui:(e.state.gzhead=t,Si)}function Yg(e,t,i,s,n,r){if(!e)return ui;var a=1;if(t===SA&&(t=6),s<0?(a=0,s=-s):s>15&&(a=2,s-=16),n<1||n>BA||i!==Za||s<8||s>15||t<0||t>9||r<0||r>LA)return ps(e,ui);s===8&&(s=9);var o=new ZA;return e.state=o,o.strm=e,o.wrap=a,o.gzhead=null,o.w_bits=s,o.w_size=1<<o.w_bits,o.w_mask=o.w_size-1,o.hash_bits=n+7,o.hash_size=1<<o.hash_bits,o.hash_mask=o.hash_size-1,o.hash_shift=~~((o.hash_bits+Wt-1)/Wt),o.window=new Me.Buf8(o.w_size*2),o.head=new Me.Buf16(o.hash_size),o.prev=new Me.Buf16(o.w_size),o.lit_bufsize=1<<n+6,o.pending_buf_size=o.lit_bufsize*4,o.pending_buf=new Me.Buf8(o.pending_buf_size),o.d_buf=1*o.lit_bufsize,o.l_buf=(1+2)*o.lit_bufsize,o.level=t,o.strategy=r,o.method=i,qg(e)}function QA(e,t){return Yg(e,t,Za,OA,NA,DA)}function tC(e,t){var i,s,n,r;if(!e||!e.state||t>qf||t<0)return e?ps(e,ui):ui;if(s=e.state,!e.output||!e.input&&e.avail_in!==0||s.status===sr&&t!==ws)return ps(e,e.avail_out===0?Bl:ui);if(s.strm=e,i=s.last_flush,s.last_flush=t,s.status===Ja)if(s.wrap===2)e.adler=0,Ut(s,31),Ut(s,139),Ut(s,8),s.gzhead?(Ut(s,(s.gzhead.text?1:0)+(s.gzhead.hcrc?2:0)+(s.gzhead.extra?4:0)+(s.gzhead.name?8:0)+(s.gzhead.comment?16:0)),Ut(s,s.gzhead.time&255),Ut(s,s.gzhead.time>>8&255),Ut(s,s.gzhead.time>>16&255),Ut(s,s.gzhead.time>>24&255),Ut(s,s.level===9?2:s.strategy>=Ea||s.level<2?4:0),Ut(s,s.gzhead.os&255),s.gzhead.extra&&s.gzhead.extra.length&&(Ut(s,s.gzhead.extra.length&255),Ut(s,s.gzhead.extra.length>>8&255)),s.gzhead.hcrc&&(e.adler=fs(e.adler,s.pending_buf,s.pending,0)),s.gzindex=0,s.status=rc):(Ut(s,0),Ut(s,0),Ut(s,0),Ut(s,0),Ut(s,0),Ut(s,s.level===9?2:s.strategy>=Ea||s.level<2?4:0),Ut(s,$A),s.status=Os);else{var a=Za+(s.w_bits-8<<4)<<8,o=-1;s.strategy>=Ea||s.level<2?o=0:s.level<6?o=1:s.level===6?o=2:o=3,a|=o<<6,s.strstart!==0&&(a|=jA),a+=31-a%31,s.status=Os,Jn(s,a),s.strstart!==0&&(Jn(s,e.adler>>>16),Jn(s,e.adler&65535)),e.adler=1}if(s.status===rc)if(s.gzhead.extra){for(n=s.pending;s.gzindex<(s.gzhead.extra.length&65535)&&!(s.pending===s.pending_buf_size&&(s.gzhead.hcrc&&s.pending>n&&(e.adler=fs(e.adler,s.pending_buf,s.pending-n,n)),ds(e),n=s.pending,s.pending===s.pending_buf_size));)Ut(s,s.gzhead.extra[s.gzindex]&255),s.gzindex++;s.gzhead.hcrc&&s.pending>n&&(e.adler=fs(e.adler,s.pending_buf,s.pending-n,n)),s.gzindex===s.gzhead.extra.length&&(s.gzindex=0,s.status=Da)}else s.status=Da;if(s.status===Da)if(s.gzhead.name){n=s.pending;do{if(s.pending===s.pending_buf_size&&(s.gzhead.hcrc&&s.pending>n&&(e.adler=fs(e.adler,s.pending_buf,s.pending-n,n)),ds(e),n=s.pending,s.pending===s.pending_buf_size)){r=1;break}s.gzindex<s.gzhead.name.length?r=s.gzhead.name.charCodeAt(s.gzindex++)&255:r=0,Ut(s,r)}while(r!==0);s.gzhead.hcrc&&s.pending>n&&(e.adler=fs(e.adler,s.pending_buf,s.pending-n,n)),r===0&&(s.gzindex=0,s.status=Ma)}else s.status=Ma;if(s.status===Ma)if(s.gzhead.comment){n=s.pending;do{if(s.pending===s.pending_buf_size&&(s.gzhead.hcrc&&s.pending>n&&(e.adler=fs(e.adler,s.pending_buf,s.pending-n,n)),ds(e),n=s.pending,s.pending===s.pending_buf_size)){r=1;break}s.gzindex<s.gzhead.comment.length?r=s.gzhead.comment.charCodeAt(s.gzindex++)&255:r=0,Ut(s,r)}while(r!==0);s.gzhead.hcrc&&s.pending>n&&(e.adler=fs(e.adler,s.pending_buf,s.pending-n,n)),r===0&&(s.status=Ba)}else s.status=Ba;if(s.status===Ba&&(s.gzhead.hcrc?(s.pending+2>s.pending_buf_size&&ds(e),s.pending+2<=s.pending_buf_size&&(Ut(s,e.adler&255),Ut(s,e.adler>>8&255),e.adler=0,s.status=Os)):s.status=Os),s.pending!==0){if(ds(e),e.avail_out===0)return s.last_flush=-1,Si}else if(e.avail_in===0&&Kf(t)<=Kf(i)&&t!==ws)return ps(e,Bl);if(s.status===sr&&e.avail_in!==0)return ps(e,Bl);if(e.avail_in!==0||s.lookahead!==0||t!==Ks&&s.status!==sr){var l=s.strategy===Ea?XA(s,t):s.strategy===IA?KA(s,t):_n[s.level].func(s,t);if((l===Us||l===Dn)&&(s.status=sr),l===me||l===Us)return e.avail_out===0&&(s.last_flush=-1),Si;if(l===Ar&&(t===CA?hi._tr_align(s):t!==qf&&(hi._tr_stored_block(s,0,0,!1),t===TA&&(vs(s.head),s.lookahead===0&&(s.strstart=0,s.block_start=0,s.insert=0))),ds(e),e.avail_out===0))return s.last_flush=-1,Si}return t!==ws?Si:s.wrap<=0?Yf:(s.wrap===2?(Ut(s,e.adler&255),Ut(s,e.adler>>8&255),Ut(s,e.adler>>16&255),Ut(s,e.adler>>24&255),Ut(s,e.total_in&255),Ut(s,e.total_in>>8&255),Ut(s,e.total_in>>16&255),Ut(s,e.total_in>>24&255)):(Jn(s,e.adler>>>16),Jn(s,e.adler&65535)),ds(e),s.wrap>0&&(s.wrap=-s.wrap),s.pending!==0?Si:Yf)}function eC(e){var t;return!e||!e.state?ui:(t=e.state.status,t!==Ja&&t!==rc&&t!==Da&&t!==Ma&&t!==Ba&&t!==Os&&t!==sr?ps(e,ui):(e.state=null,t===Os?ps(e,RA):Si))}function iC(e,t){var i=t.length,s,n,r,a,o,l,u,h;if(!e||!e.state||(s=e.state,a=s.wrap,a===2||a===1&&s.status!==Ja||s.lookahead))return ui;for(a===1&&(e.adler=Vg(e.adler,t,i,0)),s.wrap=0,i>=s.w_size&&(a===0&&(vs(s.head),s.strstart=0,s.block_start=0,s.insert=0),h=new Me.Buf8(s.w_size),Me.arraySet(h,t,i-s.w_size,s.w_size,0),t=h,i=s.w_size),o=e.avail_in,l=e.next_in,u=e.input,e.avail_in=i,e.next_in=0,e.input=t,Vs(s);s.lookahead>=Wt;){n=s.strstart,r=s.lookahead-(Wt-1);do s.ins_h=(s.ins_h<<s.hash_shift^s.window[n+Wt-1])&s.hash_mask,s.prev[n&s.w_mask]=s.head[s.ins_h],s.head[s.ins_h]=n,n++;while(--r);s.strstart=n,s.lookahead=Wt-1,Vs(s)}return s.strstart+=s.lookahead,s.block_start=s.strstart,s.insert=s.lookahead,s.lookahead=0,s.match_length=s.prev_length=Wt-1,s.match_available=0,e.next_in=l,e.input=u,e.avail_in=o,s.wrap=a,Si}Ii.deflateInit=QA;Ii.deflateInit2=Yg;Ii.deflateReset=qg;Ii.deflateResetKeep=$g;Ii.deflateSetHeader=JA;Ii.deflate=tC;Ii.deflateEnd=eC;Ii.deflateSetDictionary=iC;Ii.deflateInfo="pako deflate (from Nodeca project)";var Xs={},Qa=Ji,Kg=!0,Xg=!0;try{String.fromCharCode.apply(null,[0])}catch{Kg=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{Xg=!1}var br=new Qa.Buf8(256);for(var cs=0;cs<256;cs++)br[cs]=cs>=252?6:cs>=248?5:cs>=240?4:cs>=224?3:cs>=192?2:1;br[254]=br[254]=1;Xs.string2buf=function(e){var t,i,s,n,r,a=e.length,o=0;for(n=0;n<a;n++)i=e.charCodeAt(n),(i&64512)===55296&&n+1<a&&(s=e.charCodeAt(n+1),(s&64512)===56320&&(i=65536+(i-55296<<10)+(s-56320),n++)),o+=i<128?1:i<2048?2:i<65536?3:4;for(t=new Qa.Buf8(o),r=0,n=0;r<o;n++)i=e.charCodeAt(n),(i&64512)===55296&&n+1<a&&(s=e.charCodeAt(n+1),(s&64512)===56320&&(i=65536+(i-55296<<10)+(s-56320),n++)),i<128?t[r++]=i:i<2048?(t[r++]=192|i>>>6,t[r++]=128|i&63):i<65536?(t[r++]=224|i>>>12,t[r++]=128|i>>>6&63,t[r++]=128|i&63):(t[r++]=240|i>>>18,t[r++]=128|i>>>12&63,t[r++]=128|i>>>6&63,t[r++]=128|i&63);return t};function Gg(e,t){if(t<65534&&(e.subarray&&Xg||!e.subarray&&Kg))return String.fromCharCode.apply(null,Qa.shrinkBuf(e,t));for(var i="",s=0;s<t;s++)i+=String.fromCharCode(e[s]);return i}Xs.buf2binstring=function(e){return Gg(e,e.length)};Xs.binstring2buf=function(e){for(var t=new Qa.Buf8(e.length),i=0,s=t.length;i<s;i++)t[i]=e.charCodeAt(i);return t};Xs.buf2string=function(e,t){var i,s,n,r,a=t||e.length,o=new Array(a*2);for(s=0,i=0;i<a;){if(n=e[i++],n<128){o[s++]=n;continue}if(r=br[n],r>4){o[s++]=65533,i+=r-1;continue}for(n&=r===2?31:r===3?15:7;r>1&&i<a;)n=n<<6|e[i++]&63,r--;if(r>1){o[s++]=65533;continue}n<65536?o[s++]=n:(n-=65536,o[s++]=55296|n>>10&1023,o[s++]=56320|n&1023)}return Gg(o,s)};Xs.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+br[e[i]]>t?i:t};function sC(){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 Zg=sC,cr=Ii,hr=Ji,ac=Xs,oc=Ac,nC=Zg,Jg=Object.prototype.toString,rC=0,Nl=4,Cn=0,Xf=1,Gf=2,aC=-1,oC=0,lC=8;function js(e){if(!(this instanceof js))return new js(e);this.options=hr.assign({level:aC,method:lC,chunkSize:16384,windowBits:15,memLevel:8,strategy:oC,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 nC,this.strm.avail_out=0;var i=cr.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(i!==Cn)throw new Error(oc[i]);if(t.header&&cr.deflateSetHeader(this.strm,t.header),t.dictionary){var s;if(typeof t.dictionary=="string"?s=ac.string2buf(t.dictionary):Jg.call(t.dictionary)==="[object ArrayBuffer]"?s=new Uint8Array(t.dictionary):s=t.dictionary,i=cr.deflateSetDictionary(this.strm,s),i!==Cn)throw new Error(oc[i]);this._dict_set=!0}}js.prototype.push=function(e,t){var i=this.strm,s=this.options.chunkSize,n,r;if(this.ended)return!1;r=t===~~t?t:t===!0?Nl:rC,typeof e=="string"?i.input=ac.string2buf(e):Jg.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 hr.Buf8(s),i.next_out=0,i.avail_out=s),n=cr.deflate(i,r),n!==Xf&&n!==Cn)return this.onEnd(n),this.ended=!0,!1;(i.avail_out===0||i.avail_in===0&&(r===Nl||r===Gf))&&(this.options.to==="string"?this.onData(ac.buf2binstring(hr.shrinkBuf(i.output,i.next_out))):this.onData(hr.shrinkBuf(i.output,i.next_out)))}while((i.avail_in>0||i.avail_out===0)&&n!==Xf);return r===Nl?(n=cr.deflateEnd(this.strm),this.onEnd(n),this.ended=!0,n===Cn):(r===Gf&&(this.onEnd(Cn),i.avail_out=0),!0)};js.prototype.onData=function(e){this.chunks.push(e)};js.prototype.onEnd=function(e){e===Cn&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=hr.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};function Cc(e,t){var i=new js(t);if(i.push(e,!0),i.err)throw i.msg||oc[i.err];return i.result}function cC(e,t){return t=t||{},t.raw=!0,Cc(e,t)}function hC(e,t){return t=t||{},t.gzip=!0,Cc(e,t)}kr.Deflate=js;kr.deflate=Cc;kr.deflateRaw=cC;kr.gzip=hC;var Cr={},bi={},Aa=30,uC=12,fC=function(t,i){var s,n,r,a,o,l,u,h,f,g,v,y,w,p,_,E,x,C,S,D,B,L,V,tt,T;s=t.state,n=t.next_in,tt=t.input,r=n+(t.avail_in-5),a=t.next_out,T=t.output,o=a-(i-t.avail_out),l=a+(t.avail_out-257),u=s.dmax,h=s.wsize,f=s.whave,g=s.wnext,v=s.window,y=s.hold,w=s.bits,p=s.lencode,_=s.distcode,E=(1<<s.lenbits)-1,x=(1<<s.distbits)-1;t:do{w<15&&(y+=tt[n++]<<w,w+=8,y+=tt[n++]<<w,w+=8),C=p[y&E];e:for(;;){if(S=C>>>24,y>>>=S,w-=S,S=C>>>16&255,S===0)T[a++]=C&65535;else if(S&16){D=C&65535,S&=15,S&&(w<S&&(y+=tt[n++]<<w,w+=8),D+=y&(1<<S)-1,y>>>=S,w-=S),w<15&&(y+=tt[n++]<<w,w+=8,y+=tt[n++]<<w,w+=8),C=_[y&x];i:for(;;){if(S=C>>>24,y>>>=S,w-=S,S=C>>>16&255,S&16){if(B=C&65535,S&=15,w<S&&(y+=tt[n++]<<w,w+=8,w<S&&(y+=tt[n++]<<w,w+=8)),B+=y&(1<<S)-1,B>u){t.msg="invalid distance too far back",s.mode=Aa;break t}if(y>>>=S,w-=S,S=a-o,B>S){if(S=B-S,S>f&&s.sane){t.msg="invalid distance too far back",s.mode=Aa;break t}if(L=0,V=v,g===0){if(L+=h-S,S<D){D-=S;do T[a++]=v[L++];while(--S);L=a-B,V=T}}else if(g<S){if(L+=h+g-S,S-=g,S<D){D-=S;do T[a++]=v[L++];while(--S);if(L=0,g<D){S=g,D-=S;do T[a++]=v[L++];while(--S);L=a-B,V=T}}}else if(L+=g-S,S<D){D-=S;do T[a++]=v[L++];while(--S);L=a-B,V=T}for(;D>2;)T[a++]=V[L++],T[a++]=V[L++],T[a++]=V[L++],D-=3;D&&(T[a++]=V[L++],D>1&&(T[a++]=V[L++]))}else{L=a-B;do T[a++]=T[L++],T[a++]=T[L++],T[a++]=T[L++],D-=3;while(D>2);D&&(T[a++]=T[L++],D>1&&(T[a++]=T[L++]))}}else if((S&64)===0){C=_[(C&65535)+(y&(1<<S)-1)];continue i}else{t.msg="invalid distance code",s.mode=Aa;break t}break}}else if((S&64)===0){C=p[(C&65535)+(y&(1<<S)-1)];continue e}else if(S&32){s.mode=uC;break t}else{t.msg="invalid literal/length code",s.mode=Aa;break t}break}}while(n<r&&a<l);D=w>>3,n-=D,w-=D<<3,y&=(1<<w)-1,t.next_in=n,t.next_out=a,t.avail_in=n<r?5+(r-n):5-(n-r),t.avail_out=a<l?257+(l-a):257-(a-l),s.hold=y,s.bits=w},Zf=Ji,yn=15,Jf=852,Qf=592,td=0,Fl=1,ed=2,dC=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],gC=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],vC=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],yC=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64],mC=function(t,i,s,n,r,a,o,l){var u=l.bits,h=0,f=0,g=0,v=0,y=0,w=0,p=0,_=0,E=0,x=0,C,S,D,B,L,V=null,tt=0,T,R=new Zf.Buf16(yn+1),P=new Zf.Buf16(yn+1),O=null,Y=0,Z,rt,$;for(h=0;h<=yn;h++)R[h]=0;for(f=0;f<n;f++)R[i[s+f]]++;for(y=u,v=yn;v>=1&&R[v]===0;v--);if(y>v&&(y=v),v===0)return r[a++]=1<<24|64<<16|0,r[a++]=1<<24|64<<16|0,l.bits=1,0;for(g=1;g<v&&R[g]===0;g++);for(y<g&&(y=g),_=1,h=1;h<=yn;h++)if(_<<=1,_-=R[h],_<0)return-1;if(_>0&&(t===td||v!==1))return-1;for(P[1]=0,h=1;h<yn;h++)P[h+1]=P[h]+R[h];for(f=0;f<n;f++)i[s+f]!==0&&(o[P[i[s+f]]++]=f);if(t===td?(V=O=o,T=19):t===Fl?(V=dC,tt-=257,O=gC,Y-=257,T=256):(V=vC,O=yC,T=-1),x=0,f=0,h=g,L=a,w=y,p=0,D=-1,E=1<<y,B=E-1,t===Fl&&E>Jf||t===ed&&E>Qf)return 1;for(;;){Z=h-p,o[f]<T?(rt=0,$=o[f]):o[f]>T?(rt=O[Y+o[f]],$=V[tt+o[f]]):(rt=32+64,$=0),C=1<<h-p,S=1<<w,g=S;do S-=C,r[L+(x>>p)+S]=Z<<24|rt<<16|$|0;while(S!==0);for(C=1<<h-1;x&C;)C>>=1;if(C!==0?(x&=C-1,x+=C):x=0,f++,--R[h]===0){if(h===v)break;h=i[s+o[f]]}if(h>y&&(x&B)!==D){for(p===0&&(p=y),L+=g,w=h-p,_=1<<w;w+p<v&&(_-=R[w+p],!(_<=0));)w++,_<<=1;if(E+=1<<w,t===Fl&&E>Jf||t===ed&&E>Qf)return 1;D=x&B,r[D]=y<<24|w<<16|L-a|0}}return x!==0&&(r[L+x]=h-p<<24|64<<16|0),l.bits=y,0},Je=Ji,lc=Wg,Ci=Ug,pC=fC,ur=mC,wC=0,Qg=1,tv=2,id=4,bC=5,Ca=6,$s=0,xC=1,_C=2,fi=-2,ev=-3,iv=-4,kC=-5,sd=8,sv=1,nd=2,rd=3,ad=4,od=5,ld=6,cd=7,hd=8,ud=9,fd=10,Ka=11,Wi=12,zl=13,dd=14,Hl=15,gd=16,vd=17,yd=18,md=19,Ta=20,Ra=21,pd=22,wd=23,bd=24,xd=25,_d=26,Wl=27,kd=28,Ed=29,re=30,nv=31,EC=32,AC=852,CC=592,TC=15,RC=TC;function Ad(e){return(e>>>24&255)+(e>>>8&65280)+((e&65280)<<8)+((e&255)<<24)}function SC(){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 Je.Buf16(320),this.work=new Je.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function rv(e){var t;return!e||!e.state?fi:(t=e.state,e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=t.wrap&1),t.mode=sv,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Je.Buf32(AC),t.distcode=t.distdyn=new Je.Buf32(CC),t.sane=1,t.back=-1,$s)}function av(e){var t;return!e||!e.state?fi:(t=e.state,t.wsize=0,t.whave=0,t.wnext=0,rv(e))}function ov(e,t){var i,s;return!e||!e.state||(s=e.state,t<0?(i=0,t=-t):(i=(t>>4)+1,t<48&&(t&=15)),t&&(t<8||t>15))?fi:(s.window!==null&&s.wbits!==t&&(s.window=null),s.wrap=i,s.wbits=t,av(e))}function lv(e,t){var i,s;return e?(s=new SC,e.state=s,s.window=null,i=ov(e,t),i!==$s&&(e.state=null),i):fi}function PC(e){return lv(e,RC)}var Cd=!0,Ul,Vl;function IC(e){if(Cd){var t;for(Ul=new Je.Buf32(512),Vl=new Je.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(ur(Qg,e.lens,0,288,Ul,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;ur(tv,e.lens,0,32,Vl,0,e.work,{bits:5}),Cd=!1}e.lencode=Ul,e.lenbits=9,e.distcode=Vl,e.distbits=5}function cv(e,t,i,s){var n,r=e.state;return r.window===null&&(r.wsize=1<<r.wbits,r.wnext=0,r.whave=0,r.window=new Je.Buf8(r.wsize)),s>=r.wsize?(Je.arraySet(r.window,t,i-r.wsize,r.wsize,0),r.wnext=0,r.whave=r.wsize):(n=r.wsize-r.wnext,n>s&&(n=s),Je.arraySet(r.window,t,i-s,n,r.wnext),s-=n,s?(Je.arraySet(r.window,t,i-s,s,0),r.wnext=s,r.whave=r.wsize):(r.wnext+=n,r.wnext===r.wsize&&(r.wnext=0),r.whave<r.wsize&&(r.whave+=n))),0}function LC(e,t){var i,s,n,r,a,o,l,u,h,f,g,v,y,w,p=0,_,E,x,C,S,D,B,L,V=new Je.Buf8(4),tt,T,R=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!e||!e.state||!e.output||!e.input&&e.avail_in!==0)return fi;i=e.state,i.mode===Wi&&(i.mode=zl),a=e.next_out,n=e.output,l=e.avail_out,r=e.next_in,s=e.input,o=e.avail_in,u=i.hold,h=i.bits,f=o,g=l,L=$s;t:for(;;)switch(i.mode){case sv:if(i.wrap===0){i.mode=zl;break}for(;h<16;){if(o===0)break t;o--,u+=s[r++]<<h,h+=8}if(i.wrap&2&&u===35615){i.check=0,V[0]=u&255,V[1]=u>>>8&255,i.check=Ci(i.check,V,2,0),u=0,h=0,i.mode=nd;break}if(i.flags=0,i.head&&(i.head.done=!1),!(i.wrap&1)||(((u&255)<<8)+(u>>8))%31){e.msg="incorrect header check",i.mode=re;break}if((u&15)!==sd){e.msg="unknown compression method",i.mode=re;break}if(u>>>=4,h-=4,B=(u&15)+8,i.wbits===0)i.wbits=B;else if(B>i.wbits){e.msg="invalid window size",i.mode=re;break}i.dmax=1<<B,e.adler=i.check=1,i.mode=u&512?fd:Wi,u=0,h=0;break;case nd:for(;h<16;){if(o===0)break t;o--,u+=s[r++]<<h,h+=8}if(i.flags=u,(i.flags&255)!==sd){e.msg="unknown compression method",i.mode=re;break}if(i.flags&57344){e.msg="unknown header flags set",i.mode=re;break}i.head&&(i.head.text=u>>8&1),i.flags&512&&(V[0]=u&255,V[1]=u>>>8&255,i.check=Ci(i.check,V,2,0)),u=0,h=0,i.mode=rd;case rd:for(;h<32;){if(o===0)break t;o--,u+=s[r++]<<h,h+=8}i.head&&(i.head.time=u),i.flags&512&&(V[0]=u&255,V[1]=u>>>8&255,V[2]=u>>>16&255,V[3]=u>>>24&255,i.check=Ci(i.check,V,4,0)),u=0,h=0,i.mode=ad;case ad:for(;h<16;){if(o===0)break t;o--,u+=s[r++]<<h,h+=8}i.head&&(i.head.xflags=u&255,i.head.os=u>>8),i.flags&512&&(V[0]=u&255,V[1]=u>>>8&255,i.check=Ci(i.check,V,2,0)),u=0,h=0,i.mode=od;case od:if(i.flags&1024){for(;h<16;){if(o===0)break t;o--,u+=s[r++]<<h,h+=8}i.length=u,i.head&&(i.head.extra_len=u),i.flags&512&&(V[0]=u&255,V[1]=u>>>8&255,i.check=Ci(i.check,V,2,0)),u=0,h=0}else i.head&&(i.head.extra=null);i.mode=ld;case ld:if(i.flags&1024&&(v=i.length,v>o&&(v=o),v&&(i.head&&(B=i.head.extra_len-i.length,i.head.extra||(i.head.extra=new Array(i.head.extra_len)),Je.arraySet(i.head.extra,s,r,v,B)),i.flags&512&&(i.check=Ci(i.check,s,v,r)),o-=v,r+=v,i.length-=v),i.length))break t;i.length=0,i.mode=cd;case cd:if(i.flags&2048){if(o===0)break t;v=0;do B=s[r+v++],i.head&&B&&i.length<65536&&(i.head.name+=String.fromCharCode(B));while(B&&v<o);if(i.flags&512&&(i.check=Ci(i.check,s,v,r)),o-=v,r+=v,B)break t}else i.head&&(i.head.name=null);i.length=0,i.mode=hd;case hd:if(i.flags&4096){if(o===0)break t;v=0;do B=s[r+v++],i.head&&B&&i.length<65536&&(i.head.comment+=String.fromCharCode(B));while(B&&v<o);if(i.flags&512&&(i.check=Ci(i.check,s,v,r)),o-=v,r+=v,B)break t}else i.head&&(i.head.comment=null);i.mode=ud;case ud:if(i.flags&512){for(;h<16;){if(o===0)break t;o--,u+=s[r++]<<h,h+=8}if(u!==(i.check&65535)){e.msg="header crc mismatch",i.mode=re;break}u=0,h=0}i.head&&(i.head.hcrc=i.flags>>9&1,i.head.done=!0),e.adler=i.check=0,i.mode=Wi;break;case fd:for(;h<32;){if(o===0)break t;o--,u+=s[r++]<<h,h+=8}e.adler=i.check=Ad(u),u=0,h=0,i.mode=Ka;case Ka:if(i.havedict===0)return e.next_out=a,e.avail_out=l,e.next_in=r,e.avail_in=o,i.hold=u,i.bits=h,_C;e.adler=i.check=1,i.mode=Wi;case Wi:if(t===bC||t===Ca)break t;case zl:if(i.last){u>>>=h&7,h-=h&7,i.mode=Wl;break}for(;h<3;){if(o===0)break t;o--,u+=s[r++]<<h,h+=8}switch(i.last=u&1,u>>>=1,h-=1,u&3){case 0:i.mode=dd;break;case 1:if(IC(i),i.mode=Ta,t===Ca){u>>>=2,h-=2;break t}break;case 2:i.mode=vd;break;case 3:e.msg="invalid block type",i.mode=re}u>>>=2,h-=2;break;case dd:for(u>>>=h&7,h-=h&7;h<32;){if(o===0)break t;o--,u+=s[r++]<<h,h+=8}if((u&65535)!==(u>>>16^65535)){e.msg="invalid stored block lengths",i.mode=re;break}if(i.length=u&65535,u=0,h=0,i.mode=Hl,t===Ca)break t;case Hl:i.mode=gd;case gd:if(v=i.length,v){if(v>o&&(v=o),v>l&&(v=l),v===0)break t;Je.arraySet(n,s,r,v,a),o-=v,r+=v,l-=v,a+=v,i.length-=v;break}i.mode=Wi;break;case vd:for(;h<14;){if(o===0)break t;o--,u+=s[r++]<<h,h+=8}if(i.nlen=(u&31)+257,u>>>=5,h-=5,i.ndist=(u&31)+1,u>>>=5,h-=5,i.ncode=(u&15)+4,u>>>=4,h-=4,i.nlen>286||i.ndist>30){e.msg="too many length or distance symbols",i.mode=re;break}i.have=0,i.mode=yd;case yd:for(;i.have<i.ncode;){for(;h<3;){if(o===0)break t;o--,u+=s[r++]<<h,h+=8}i.lens[R[i.have++]]=u&7,u>>>=3,h-=3}for(;i.have<19;)i.lens[R[i.have++]]=0;if(i.lencode=i.lendyn,i.lenbits=7,tt={bits:i.lenbits},L=ur(wC,i.lens,0,19,i.lencode,0,i.work,tt),i.lenbits=tt.bits,L){e.msg="invalid code lengths set",i.mode=re;break}i.have=0,i.mode=md;case md:for(;i.have<i.nlen+i.ndist;){for(;p=i.lencode[u&(1<<i.lenbits)-1],_=p>>>24,E=p>>>16&255,x=p&65535,!(_<=h);){if(o===0)break t;o--,u+=s[r++]<<h,h+=8}if(x<16)u>>>=_,h-=_,i.lens[i.have++]=x;else{if(x===16){for(T=_+2;h<T;){if(o===0)break t;o--,u+=s[r++]<<h,h+=8}if(u>>>=_,h-=_,i.have===0){e.msg="invalid bit length repeat",i.mode=re;break}B=i.lens[i.have-1],v=3+(u&3),u>>>=2,h-=2}else if(x===17){for(T=_+3;h<T;){if(o===0)break t;o--,u+=s[r++]<<h,h+=8}u>>>=_,h-=_,B=0,v=3+(u&7),u>>>=3,h-=3}else{for(T=_+7;h<T;){if(o===0)break t;o--,u+=s[r++]<<h,h+=8}u>>>=_,h-=_,B=0,v=11+(u&127),u>>>=7,h-=7}if(i.have+v>i.nlen+i.ndist){e.msg="invalid bit length repeat",i.mode=re;break}for(;v--;)i.lens[i.have++]=B}}if(i.mode===re)break;if(i.lens[256]===0){e.msg="invalid code -- missing end-of-block",i.mode=re;break}if(i.lenbits=9,tt={bits:i.lenbits},L=ur(Qg,i.lens,0,i.nlen,i.lencode,0,i.work,tt),i.lenbits=tt.bits,L){e.msg="invalid literal/lengths set",i.mode=re;break}if(i.distbits=6,i.distcode=i.distdyn,tt={bits:i.distbits},L=ur(tv,i.lens,i.nlen,i.ndist,i.distcode,0,i.work,tt),i.distbits=tt.bits,L){e.msg="invalid distances set",i.mode=re;break}if(i.mode=Ta,t===Ca)break t;case Ta:i.mode=Ra;case Ra:if(o>=6&&l>=258){e.next_out=a,e.avail_out=l,e.next_in=r,e.avail_in=o,i.hold=u,i.bits=h,pC(e,g),a=e.next_out,n=e.output,l=e.avail_out,r=e.next_in,s=e.input,o=e.avail_in,u=i.hold,h=i.bits,i.mode===Wi&&(i.back=-1);break}for(i.back=0;p=i.lencode[u&(1<<i.lenbits)-1],_=p>>>24,E=p>>>16&255,x=p&65535,!(_<=h);){if(o===0)break t;o--,u+=s[r++]<<h,h+=8}if(E&&(E&240)===0){for(C=_,S=E,D=x;p=i.lencode[D+((u&(1<<C+S)-1)>>C)],_=p>>>24,E=p>>>16&255,x=p&65535,!(C+_<=h);){if(o===0)break t;o--,u+=s[r++]<<h,h+=8}u>>>=C,h-=C,i.back+=C}if(u>>>=_,h-=_,i.back+=_,i.length=x,E===0){i.mode=_d;break}if(E&32){i.back=-1,i.mode=Wi;break}if(E&64){e.msg="invalid literal/length code",i.mode=re;break}i.extra=E&15,i.mode=pd;case pd:if(i.extra){for(T=i.extra;h<T;){if(o===0)break t;o--,u+=s[r++]<<h,h+=8}i.length+=u&(1<<i.extra)-1,u>>>=i.extra,h-=i.extra,i.back+=i.extra}i.was=i.length,i.mode=wd;case wd:for(;p=i.distcode[u&(1<<i.distbits)-1],_=p>>>24,E=p>>>16&255,x=p&65535,!(_<=h);){if(o===0)break t;o--,u+=s[r++]<<h,h+=8}if((E&240)===0){for(C=_,S=E,D=x;p=i.distcode[D+((u&(1<<C+S)-1)>>C)],_=p>>>24,E=p>>>16&255,x=p&65535,!(C+_<=h);){if(o===0)break t;o--,u+=s[r++]<<h,h+=8}u>>>=C,h-=C,i.back+=C}if(u>>>=_,h-=_,i.back+=_,E&64){e.msg="invalid distance code",i.mode=re;break}i.offset=x,i.extra=E&15,i.mode=bd;case bd:if(i.extra){for(T=i.extra;h<T;){if(o===0)break t;o--,u+=s[r++]<<h,h+=8}i.offset+=u&(1<<i.extra)-1,u>>>=i.extra,h-=i.extra,i.back+=i.extra}if(i.offset>i.dmax){e.msg="invalid distance too far back",i.mode=re;break}i.mode=xd;case xd:if(l===0)break t;if(v=g-l,i.offset>v){if(v=i.offset-v,v>i.whave&&i.sane){e.msg="invalid distance too far back",i.mode=re;break}v>i.wnext?(v-=i.wnext,y=i.wsize-v):y=i.wnext-v,v>i.length&&(v=i.length),w=i.window}else w=n,y=a-i.offset,v=i.length;v>l&&(v=l),l-=v,i.length-=v;do n[a++]=w[y++];while(--v);i.length===0&&(i.mode=Ra);break;case _d:if(l===0)break t;n[a++]=i.length,l--,i.mode=Ra;break;case Wl:if(i.wrap){for(;h<32;){if(o===0)break t;o--,u|=s[r++]<<h,h+=8}if(g-=l,e.total_out+=g,i.total+=g,g&&(e.adler=i.check=i.flags?Ci(i.check,n,g,a-g):lc(i.check,n,g,a-g)),g=l,(i.flags?u:Ad(u))!==i.check){e.msg="incorrect data check",i.mode=re;break}u=0,h=0}i.mode=kd;case kd:if(i.wrap&&i.flags){for(;h<32;){if(o===0)break t;o--,u+=s[r++]<<h,h+=8}if(u!==(i.total&4294967295)){e.msg="incorrect length check",i.mode=re;break}u=0,h=0}i.mode=Ed;case Ed:L=xC;break t;case re:L=ev;break t;case nv:return iv;case EC:default:return fi}return e.next_out=a,e.avail_out=l,e.next_in=r,e.avail_in=o,i.hold=u,i.bits=h,(i.wsize||g!==e.avail_out&&i.mode<re&&(i.mode<Wl||t!==id))&&cv(e,e.output,e.next_out,g-e.avail_out),f-=e.avail_in,g-=e.avail_out,e.total_in+=f,e.total_out+=g,i.total+=g,i.wrap&&g&&(e.adler=i.check=i.flags?Ci(i.check,n,g,e.next_out-g):lc(i.check,n,g,e.next_out-g)),e.data_type=i.bits+(i.last?64:0)+(i.mode===Wi?128:0)+(i.mode===Ta||i.mode===Hl?256:0),(f===0&&g===0||t===id)&&L===$s&&(L=kC),L}function DC(e){if(!e||!e.state)return fi;var t=e.state;return t.window&&(t.window=null),e.state=null,$s}function MC(e,t){var i;return!e||!e.state||(i=e.state,(i.wrap&2)===0)?fi:(i.head=t,t.done=!1,$s)}function BC(e,t){var i=t.length,s,n,r;return!e||!e.state||(s=e.state,s.wrap!==0&&s.mode!==Ka)?fi:s.mode===Ka&&(n=1,n=lc(n,t,i,0),n!==s.check)?ev:(r=cv(e,t,i,i),r?(s.mode=nv,iv):(s.havedict=1,$s))}bi.inflateReset=av;bi.inflateReset2=ov;bi.inflateResetKeep=rv;bi.inflateInit=PC;bi.inflateInit2=lv;bi.inflate=LC;bi.inflateEnd=DC;bi.inflateGetHeader=MC;bi.inflateSetDictionary=BC;bi.inflateInfo="pako inflate (from Nodeca project)";var hv={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8};function OC(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}var NC=OC,Tn=bi,fr=Ji,Oa=Xs,de=hv,cc=Ac,FC=Zg,zC=NC,uv=Object.prototype.toString;function qs(e){if(!(this instanceof qs))return new qs(e);this.options=fr.assign({chunkSize:16384,windowBits:0,to:""},e||{});var t=this.options;t.raw&&t.windowBits>=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 FC,this.strm.avail_out=0;var i=Tn.inflateInit2(this.strm,t.windowBits);if(i!==de.Z_OK)throw new Error(cc[i]);if(this.header=new zC,Tn.inflateGetHeader(this.strm,this.header),t.dictionary&&(typeof t.dictionary=="string"?t.dictionary=Oa.string2buf(t.dictionary):uv.call(t.dictionary)==="[object ArrayBuffer]"&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(i=Tn.inflateSetDictionary(this.strm,t.dictionary),i!==de.Z_OK)))throw new Error(cc[i])}qs.prototype.push=function(e,t){var i=this.strm,s=this.options.chunkSize,n=this.options.dictionary,r,a,o,l,u,h=!1;if(this.ended)return!1;a=t===~~t?t:t===!0?de.Z_FINISH:de.Z_NO_FLUSH,typeof e=="string"?i.input=Oa.binstring2buf(e):uv.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 fr.Buf8(s),i.next_out=0,i.avail_out=s),r=Tn.inflate(i,de.Z_NO_FLUSH),r===de.Z_NEED_DICT&&n&&(r=Tn.inflateSetDictionary(this.strm,n)),r===de.Z_BUF_ERROR&&h===!0&&(r=de.Z_OK,h=!1),r!==de.Z_STREAM_END&&r!==de.Z_OK)return this.onEnd(r),this.ended=!0,!1;i.next_out&&(i.avail_out===0||r===de.Z_STREAM_END||i.avail_in===0&&(a===de.Z_FINISH||a===de.Z_SYNC_FLUSH))&&(this.options.to==="string"?(o=Oa.utf8border(i.output,i.next_out),l=i.next_out-o,u=Oa.buf2string(i.output,o),i.next_out=l,i.avail_out=s-l,l&&fr.arraySet(i.output,i.output,o,l,0),this.onData(u)):this.onData(fr.shrinkBuf(i.output,i.next_out))),i.avail_in===0&&i.avail_out===0&&(h=!0)}while((i.avail_in>0||i.avail_out===0)&&r!==de.Z_STREAM_END);return r===de.Z_STREAM_END&&(a=de.Z_FINISH),a===de.Z_FINISH?(r=Tn.inflateEnd(this.strm),this.onEnd(r),this.ended=!0,r===de.Z_OK):(a===de.Z_SYNC_FLUSH&&(this.onEnd(de.Z_OK),i.avail_out=0),!0)};qs.prototype.onData=function(e){this.chunks.push(e)};qs.prototype.onEnd=function(e){e===de.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=fr.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};function Tc(e,t){var i=new qs(t);if(i.push(e,!0),i.err)throw i.msg||cc[i.err];return i.result}function HC(e,t){return t=t||{},t.raw=!0,Tc(e,t)}Cr.Inflate=qs;Cr.inflate=Tc;Cr.inflateRaw=HC;Cr.ungzip=Tc;var WC=Ji.assign,UC=kr,VC=Cr,jC=hv,fv={};WC(fv,UC,VC,jC);var fT=fv,hc={exports:{}};/**
- * @license
- * Lodash <https://lodash.com/>
- * Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
- * Released under MIT license <https://lodash.com/license>
- * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
- * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
- */(function(e,t){(function(){var i,s="4.17.21",n=200,r="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",a="Expected a function",o="Invalid `variable` option passed into `_.template`",l="__lodash_hash_undefined__",u=500,h="__lodash_placeholder__",f=1,g=2,v=4,y=1,w=2,p=1,_=2,E=4,x=8,C=16,S=32,D=64,B=128,L=256,V=512,tt=30,T="...",R=800,P=16,O=1,Y=2,Z=3,rt=1/0,$=9007199254740991,H=17976931348623157e292,j=0/0,K=4294967295,W=K-1,Q=K>>>1,st=[["ary",B],["bind",p],["bindKey",_],["curry",x],["curryRight",C],["flip",V],["partial",S],["partialRight",D],["rearg",L]],et="[object Arguments]",ut="[object Array]",ct="[object AsyncFunction]",ot="[object Boolean]",b="[object Date]",k="[object DOMException]",I="[object Error]",F="[object Function]",X="[object GeneratorFunction]",G="[object Map]",at="[object Number]",mt="[object Null]",yt="[object Object]",kt="[object Promise]",Rt="[object Proxy]",be="[object RegExp]",se="[object Set]",xe="[object String]",$t="[object Symbol]",Qt="[object Undefined]",xi="[object WeakMap]",dv="[object WeakSet]",Mn="[object ArrayBuffer]",Gs="[object DataView]",to="[object Float32Array]",eo="[object Float64Array]",io="[object Int8Array]",so="[object Int16Array]",no="[object Int32Array]",ro="[object Uint8Array]",ao="[object Uint8ClampedArray]",oo="[object Uint16Array]",lo="[object Uint32Array]",gv=/\b__p \+= '';/g,vv=/\b(__p \+=) '' \+/g,yv=/(__e\(.*?\)|\b__t\)) \+\n'';/g,Rc=/&(?:amp|lt|gt|quot|#39);/g,Sc=/[&<>"']/g,mv=RegExp(Rc.source),pv=RegExp(Sc.source),wv=/<%-([\s\S]+?)%>/g,bv=/<%([\s\S]+?)%>/g,Pc=/<%=([\s\S]+?)%>/g,xv=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,_v=/^\w*$/,kv=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,co=/[\\^$.*+?()[\]{}|]/g,Ev=RegExp(co.source),ho=/^\s+/,Av=/\s/,Cv=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,Tv=/\{\n\/\* \[wrapped with (.+)\] \*/,Rv=/,? & /,Sv=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,Pv=/[()=,{}\[\]\/\s]/,Iv=/\\(\\)?/g,Lv=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,Ic=/\w*$/,Dv=/^[-+]0x[0-9a-f]+$/i,Mv=/^0b[01]+$/i,Bv=/^\[object .+?Constructor\]$/,Ov=/^0o[0-7]+$/i,Nv=/^(?:0|[1-9]\d*)$/,Fv=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Tr=/($^)/,zv=/['\n\r\u2028\u2029\\]/g,Rr="\\ud800-\\udfff",Hv="\\u0300-\\u036f",Wv="\\ufe20-\\ufe2f",Uv="\\u20d0-\\u20ff",Lc=Hv+Wv+Uv,Dc="\\u2700-\\u27bf",Mc="a-z\\xdf-\\xf6\\xf8-\\xff",Vv="\\xac\\xb1\\xd7\\xf7",jv="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",$v="\\u2000-\\u206f",qv=" \\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",Bc="A-Z\\xc0-\\xd6\\xd8-\\xde",Oc="\\ufe0e\\ufe0f",Nc=Vv+jv+$v+qv,uo="['\u2019]",Yv="["+Rr+"]",Fc="["+Nc+"]",Sr="["+Lc+"]",zc="\\d+",Kv="["+Dc+"]",Hc="["+Mc+"]",Wc="[^"+Rr+Nc+zc+Dc+Mc+Bc+"]",fo="\\ud83c[\\udffb-\\udfff]",Xv="(?:"+Sr+"|"+fo+")",Uc="[^"+Rr+"]",go="(?:\\ud83c[\\udde6-\\uddff]){2}",vo="[\\ud800-\\udbff][\\udc00-\\udfff]",Zs="["+Bc+"]",Vc="\\u200d",jc="(?:"+Hc+"|"+Wc+")",Gv="(?:"+Zs+"|"+Wc+")",$c="(?:"+uo+"(?:d|ll|m|re|s|t|ve))?",qc="(?:"+uo+"(?:D|LL|M|RE|S|T|VE))?",Yc=Xv+"?",Kc="["+Oc+"]?",Zv="(?:"+Vc+"(?:"+[Uc,go,vo].join("|")+")"+Kc+Yc+")*",Jv="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",Qv="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",Xc=Kc+Yc+Zv,t0="(?:"+[Kv,go,vo].join("|")+")"+Xc,e0="(?:"+[Uc+Sr+"?",Sr,go,vo,Yv].join("|")+")",i0=RegExp(uo,"g"),s0=RegExp(Sr,"g"),yo=RegExp(fo+"(?="+fo+")|"+e0+Xc,"g"),n0=RegExp([Zs+"?"+Hc+"+"+$c+"(?="+[Fc,Zs,"$"].join("|")+")",Gv+"+"+qc+"(?="+[Fc,Zs+jc,"$"].join("|")+")",Zs+"?"+jc+"+"+$c,Zs+"+"+qc,Qv,Jv,zc,t0].join("|"),"g"),r0=RegExp("["+Vc+Rr+Lc+Oc+"]"),a0=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,o0=["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"],l0=-1,ie={};ie[to]=ie[eo]=ie[io]=ie[so]=ie[no]=ie[ro]=ie[ao]=ie[oo]=ie[lo]=!0,ie[et]=ie[ut]=ie[Mn]=ie[ot]=ie[Gs]=ie[b]=ie[I]=ie[F]=ie[G]=ie[at]=ie[yt]=ie[be]=ie[se]=ie[xe]=ie[xi]=!1;var te={};te[et]=te[ut]=te[Mn]=te[Gs]=te[ot]=te[b]=te[to]=te[eo]=te[io]=te[so]=te[no]=te[G]=te[at]=te[yt]=te[be]=te[se]=te[xe]=te[$t]=te[ro]=te[ao]=te[oo]=te[lo]=!0,te[I]=te[F]=te[xi]=!1;var c0={\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"},h0={"&":"&","<":"<",">":">",'"':""","'":"'"},u0={"&":"&","<":"<",">":">",""":'"',"'":"'"},f0={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},d0=parseFloat,g0=parseInt,Gc=typeof De=="object"&&De&&De.Object===Object&&De,v0=typeof self=="object"&&self&&self.Object===Object&&self,_e=Gc||v0||Function("return this")(),mo=t&&!t.nodeType&&t,xs=mo&&!0&&e&&!e.nodeType&&e,Zc=xs&&xs.exports===mo,po=Zc&&Gc.process,ei=function(){try{var it=xs&&xs.require&&xs.require("util").types;return it||po&&po.binding&&po.binding("util")}catch{}}(),Jc=ei&&ei.isArrayBuffer,Qc=ei&&ei.isDate,th=ei&&ei.isMap,eh=ei&&ei.isRegExp,ih=ei&&ei.isSet,sh=ei&&ei.isTypedArray;function Ve(it,ft,lt){switch(lt.length){case 0:return it.call(ft);case 1:return it.call(ft,lt[0]);case 2:return it.call(ft,lt[0],lt[1]);case 3:return it.call(ft,lt[0],lt[1],lt[2])}return it.apply(ft,lt)}function y0(it,ft,lt,wt){for(var St=-1,qt=it==null?0:it.length;++St<qt;){var ve=it[St];ft(wt,ve,lt(ve),it)}return wt}function ii(it,ft){for(var lt=-1,wt=it==null?0:it.length;++lt<wt&&ft(it[lt],lt,it)!==!1;);return it}function m0(it,ft){for(var lt=it==null?0:it.length;lt--&&ft(it[lt],lt,it)!==!1;);return it}function nh(it,ft){for(var lt=-1,wt=it==null?0:it.length;++lt<wt;)if(!ft(it[lt],lt,it))return!1;return!0}function Qi(it,ft){for(var lt=-1,wt=it==null?0:it.length,St=0,qt=[];++lt<wt;){var ve=it[lt];ft(ve,lt,it)&&(qt[St++]=ve)}return qt}function Pr(it,ft){var lt=it==null?0:it.length;return!!lt&&Js(it,ft,0)>-1}function wo(it,ft,lt){for(var wt=-1,St=it==null?0:it.length;++wt<St;)if(lt(ft,it[wt]))return!0;return!1}function ne(it,ft){for(var lt=-1,wt=it==null?0:it.length,St=Array(wt);++lt<wt;)St[lt]=ft(it[lt],lt,it);return St}function ts(it,ft){for(var lt=-1,wt=ft.length,St=it.length;++lt<wt;)it[St+lt]=ft[lt];return it}function bo(it,ft,lt,wt){var St=-1,qt=it==null?0:it.length;for(wt&&qt&&(lt=it[++St]);++St<qt;)lt=ft(lt,it[St],St,it);return lt}function p0(it,ft,lt,wt){var St=it==null?0:it.length;for(wt&&St&&(lt=it[--St]);St--;)lt=ft(lt,it[St],St,it);return lt}function xo(it,ft){for(var lt=-1,wt=it==null?0:it.length;++lt<wt;)if(ft(it[lt],lt,it))return!0;return!1}var w0=_o("length");function b0(it){return it.split("")}function x0(it){return it.match(Sv)||[]}function rh(it,ft,lt){var wt;return lt(it,function(St,qt,ve){if(ft(St,qt,ve))return wt=qt,!1}),wt}function Ir(it,ft,lt,wt){for(var St=it.length,qt=lt+(wt?1:-1);wt?qt--:++qt<St;)if(ft(it[qt],qt,it))return qt;return-1}function Js(it,ft,lt){return ft===ft?D0(it,ft,lt):Ir(it,ah,lt)}function _0(it,ft,lt,wt){for(var St=lt-1,qt=it.length;++St<qt;)if(wt(it[St],ft))return St;return-1}function ah(it){return it!==it}function oh(it,ft){var lt=it==null?0:it.length;return lt?Eo(it,ft)/lt:j}function _o(it){return function(ft){return ft==null?i:ft[it]}}function ko(it){return function(ft){return it==null?i:it[ft]}}function lh(it,ft,lt,wt,St){return St(it,function(qt,ve,Zt){lt=wt?(wt=!1,qt):ft(lt,qt,ve,Zt)}),lt}function k0(it,ft){var lt=it.length;for(it.sort(ft);lt--;)it[lt]=it[lt].value;return it}function Eo(it,ft){for(var lt,wt=-1,St=it.length;++wt<St;){var qt=ft(it[wt]);qt!==i&&(lt=lt===i?qt:lt+qt)}return lt}function Ao(it,ft){for(var lt=-1,wt=Array(it);++lt<it;)wt[lt]=ft(lt);return wt}function E0(it,ft){return ne(ft,function(lt){return[lt,it[lt]]})}function ch(it){return it&&it.slice(0,dh(it)+1).replace(ho,"")}function je(it){return function(ft){return it(ft)}}function Co(it,ft){return ne(ft,function(lt){return it[lt]})}function Bn(it,ft){return it.has(ft)}function hh(it,ft){for(var lt=-1,wt=it.length;++lt<wt&&Js(ft,it[lt],0)>-1;);return lt}function uh(it,ft){for(var lt=it.length;lt--&&Js(ft,it[lt],0)>-1;);return lt}function A0(it,ft){for(var lt=it.length,wt=0;lt--;)it[lt]===ft&&++wt;return wt}var C0=ko(c0),T0=ko(h0);function R0(it){return"\\"+f0[it]}function S0(it,ft){return it==null?i:it[ft]}function Qs(it){return r0.test(it)}function P0(it){return a0.test(it)}function I0(it){for(var ft,lt=[];!(ft=it.next()).done;)lt.push(ft.value);return lt}function To(it){var ft=-1,lt=Array(it.size);return it.forEach(function(wt,St){lt[++ft]=[St,wt]}),lt}function fh(it,ft){return function(lt){return it(ft(lt))}}function es(it,ft){for(var lt=-1,wt=it.length,St=0,qt=[];++lt<wt;){var ve=it[lt];(ve===ft||ve===h)&&(it[lt]=h,qt[St++]=lt)}return qt}function Lr(it){var ft=-1,lt=Array(it.size);return it.forEach(function(wt){lt[++ft]=wt}),lt}function L0(it){var ft=-1,lt=Array(it.size);return it.forEach(function(wt){lt[++ft]=[wt,wt]}),lt}function D0(it,ft,lt){for(var wt=lt-1,St=it.length;++wt<St;)if(it[wt]===ft)return wt;return-1}function M0(it,ft,lt){for(var wt=lt+1;wt--;)if(it[wt]===ft)return wt;return wt}function tn(it){return Qs(it)?O0(it):w0(it)}function di(it){return Qs(it)?N0(it):b0(it)}function dh(it){for(var ft=it.length;ft--&&Av.test(it.charAt(ft)););return ft}var B0=ko(u0);function O0(it){for(var ft=yo.lastIndex=0;yo.test(it);)++ft;return ft}function N0(it){return it.match(yo)||[]}function F0(it){return it.match(n0)||[]}var z0=function it(ft){ft=ft==null?_e:en.defaults(_e.Object(),ft,en.pick(_e,o0));var lt=ft.Array,wt=ft.Date,St=ft.Error,qt=ft.Function,ve=ft.Math,Zt=ft.Object,Ro=ft.RegExp,H0=ft.String,si=ft.TypeError,Dr=lt.prototype,W0=qt.prototype,sn=Zt.prototype,Mr=ft["__core-js_shared__"],Br=W0.toString,Xt=sn.hasOwnProperty,U0=0,gh=function(){var c=/[^.]+$/.exec(Mr&&Mr.keys&&Mr.keys.IE_PROTO||"");return c?"Symbol(src)_1."+c:""}(),Or=sn.toString,V0=Br.call(Zt),j0=_e._,$0=Ro("^"+Br.call(Xt).replace(co,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Nr=Zc?ft.Buffer:i,is=ft.Symbol,Fr=ft.Uint8Array,vh=Nr?Nr.allocUnsafe:i,zr=fh(Zt.getPrototypeOf,Zt),yh=Zt.create,mh=sn.propertyIsEnumerable,Hr=Dr.splice,ph=is?is.isConcatSpreadable:i,On=is?is.iterator:i,_s=is?is.toStringTag:i,Wr=function(){try{var c=Ts(Zt,"defineProperty");return c({},"",{}),c}catch{}}(),q0=ft.clearTimeout!==_e.clearTimeout&&ft.clearTimeout,Y0=wt&&wt.now!==_e.Date.now&&wt.now,K0=ft.setTimeout!==_e.setTimeout&&ft.setTimeout,Ur=ve.ceil,Vr=ve.floor,So=Zt.getOwnPropertySymbols,X0=Nr?Nr.isBuffer:i,wh=ft.isFinite,G0=Dr.join,Z0=fh(Zt.keys,Zt),ye=ve.max,Re=ve.min,J0=wt.now,Q0=ft.parseInt,bh=ve.random,ty=Dr.reverse,Po=Ts(ft,"DataView"),Nn=Ts(ft,"Map"),Io=Ts(ft,"Promise"),nn=Ts(ft,"Set"),Fn=Ts(ft,"WeakMap"),zn=Ts(Zt,"create"),jr=Fn&&new Fn,rn={},ey=Rs(Po),iy=Rs(Nn),sy=Rs(Io),ny=Rs(nn),ry=Rs(Fn),$r=is?is.prototype:i,Hn=$r?$r.valueOf:i,xh=$r?$r.toString:i;function N(c){if(ce(c)&&!Pt(c)&&!(c instanceof Ft)){if(c instanceof ni)return c;if(Xt.call(c,"__wrapped__"))return _u(c)}return new ni(c)}var an=function(){function c(){}return function(d){if(!oe(d))return{};if(yh)return yh(d);c.prototype=d;var m=new c;return c.prototype=i,m}}();function qr(){}function ni(c,d){this.__wrapped__=c,this.__actions__=[],this.__chain__=!!d,this.__index__=0,this.__values__=i}N.templateSettings={escape:wv,evaluate:bv,interpolate:Pc,variable:"",imports:{_:N}},N.prototype=qr.prototype,N.prototype.constructor=N,ni.prototype=an(qr.prototype),ni.prototype.constructor=ni;function Ft(c){this.__wrapped__=c,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=K,this.__views__=[]}function ay(){var c=new Ft(this.__wrapped__);return c.__actions__=Be(this.__actions__),c.__dir__=this.__dir__,c.__filtered__=this.__filtered__,c.__iteratees__=Be(this.__iteratees__),c.__takeCount__=this.__takeCount__,c.__views__=Be(this.__views__),c}function oy(){if(this.__filtered__){var c=new Ft(this);c.__dir__=-1,c.__filtered__=!0}else c=this.clone(),c.__dir__*=-1;return c}function ly(){var c=this.__wrapped__.value(),d=this.__dir__,m=Pt(c),A=d<0,M=m?c.length:0,z=bm(0,M,this.__views__),q=z.start,J=z.end,nt=J-q,dt=A?J:q-1,gt=this.__iteratees__,vt=gt.length,pt=0,_t=Re(nt,this.__takeCount__);if(!m||!A&&M==nt&&_t==nt)return $h(c,this.__actions__);var Ct=[];t:for(;nt--&&pt<_t;){dt+=d;for(var Mt=-1,Tt=c[dt];++Mt<vt;){var Nt=gt[Mt],Ht=Nt.iteratee,Ye=Nt.type,Le=Ht(Tt);if(Ye==Y)Tt=Le;else if(!Le){if(Ye==O)continue t;break t}}Ct[pt++]=Tt}return Ct}Ft.prototype=an(qr.prototype),Ft.prototype.constructor=Ft;function ks(c){var d=-1,m=c==null?0:c.length;for(this.clear();++d<m;){var A=c[d];this.set(A[0],A[1])}}function cy(){this.__data__=zn?zn(null):{},this.size=0}function hy(c){var d=this.has(c)&&delete this.__data__[c];return this.size-=d?1:0,d}function uy(c){var d=this.__data__;if(zn){var m=d[c];return m===l?i:m}return Xt.call(d,c)?d[c]:i}function fy(c){var d=this.__data__;return zn?d[c]!==i:Xt.call(d,c)}function dy(c,d){var m=this.__data__;return this.size+=this.has(c)?0:1,m[c]=zn&&d===i?l:d,this}ks.prototype.clear=cy,ks.prototype.delete=hy,ks.prototype.get=uy,ks.prototype.has=fy,ks.prototype.set=dy;function Li(c){var d=-1,m=c==null?0:c.length;for(this.clear();++d<m;){var A=c[d];this.set(A[0],A[1])}}function gy(){this.__data__=[],this.size=0}function vy(c){var d=this.__data__,m=Yr(d,c);if(m<0)return!1;var A=d.length-1;return m==A?d.pop():Hr.call(d,m,1),--this.size,!0}function yy(c){var d=this.__data__,m=Yr(d,c);return m<0?i:d[m][1]}function my(c){return Yr(this.__data__,c)>-1}function py(c,d){var m=this.__data__,A=Yr(m,c);return A<0?(++this.size,m.push([c,d])):m[A][1]=d,this}Li.prototype.clear=gy,Li.prototype.delete=vy,Li.prototype.get=yy,Li.prototype.has=my,Li.prototype.set=py;function Di(c){var d=-1,m=c==null?0:c.length;for(this.clear();++d<m;){var A=c[d];this.set(A[0],A[1])}}function wy(){this.size=0,this.__data__={hash:new ks,map:new(Nn||Li),string:new ks}}function by(c){var d=ra(this,c).delete(c);return this.size-=d?1:0,d}function xy(c){return ra(this,c).get(c)}function _y(c){return ra(this,c).has(c)}function ky(c,d){var m=ra(this,c),A=m.size;return m.set(c,d),this.size+=m.size==A?0:1,this}Di.prototype.clear=wy,Di.prototype.delete=by,Di.prototype.get=xy,Di.prototype.has=_y,Di.prototype.set=ky;function Es(c){var d=-1,m=c==null?0:c.length;for(this.__data__=new Di;++d<m;)this.add(c[d])}function Ey(c){return this.__data__.set(c,l),this}function Ay(c){return this.__data__.has(c)}Es.prototype.add=Es.prototype.push=Ey,Es.prototype.has=Ay;function gi(c){var d=this.__data__=new Li(c);this.size=d.size}function Cy(){this.__data__=new Li,this.size=0}function Ty(c){var d=this.__data__,m=d.delete(c);return this.size=d.size,m}function Ry(c){return this.__data__.get(c)}function Sy(c){return this.__data__.has(c)}function Py(c,d){var m=this.__data__;if(m instanceof Li){var A=m.__data__;if(!Nn||A.length<n-1)return A.push([c,d]),this.size=++m.size,this;m=this.__data__=new Di(A)}return m.set(c,d),this.size=m.size,this}gi.prototype.clear=Cy,gi.prototype.delete=Ty,gi.prototype.get=Ry,gi.prototype.has=Sy,gi.prototype.set=Py;function _h(c,d){var m=Pt(c),A=!m&&Ss(c),M=!m&&!A&&os(c),z=!m&&!A&&!M&&hn(c),q=m||A||M||z,J=q?Ao(c.length,H0):[],nt=J.length;for(var dt in c)(d||Xt.call(c,dt))&&!(q&&(dt=="length"||M&&(dt=="offset"||dt=="parent")||z&&(dt=="buffer"||dt=="byteLength"||dt=="byteOffset")||Ni(dt,nt)))&&J.push(dt);return J}function kh(c){var d=c.length;return d?c[Uo(0,d-1)]:i}function Iy(c,d){return aa(Be(c),As(d,0,c.length))}function Ly(c){return aa(Be(c))}function Lo(c,d,m){(m!==i&&!vi(c[d],m)||m===i&&!(d in c))&&Mi(c,d,m)}function Wn(c,d,m){var A=c[d];(!(Xt.call(c,d)&&vi(A,m))||m===i&&!(d in c))&&Mi(c,d,m)}function Yr(c,d){for(var m=c.length;m--;)if(vi(c[m][0],d))return m;return-1}function Dy(c,d,m,A){return ss(c,function(M,z,q){d(A,M,m(M),q)}),A}function Eh(c,d){return c&&ki(d,pe(d),c)}function My(c,d){return c&&ki(d,Ne(d),c)}function Mi(c,d,m){d=="__proto__"&&Wr?Wr(c,d,{configurable:!0,enumerable:!0,value:m,writable:!0}):c[d]=m}function Do(c,d){for(var m=-1,A=d.length,M=lt(A),z=c==null;++m<A;)M[m]=z?i:dl(c,d[m]);return M}function As(c,d,m){return c===c&&(m!==i&&(c=c<=m?c:m),d!==i&&(c=c>=d?c:d)),c}function ri(c,d,m,A,M,z){var q,J=d&f,nt=d&g,dt=d&v;if(m&&(q=M?m(c,A,M,z):m(c)),q!==i)return q;if(!oe(c))return c;var gt=Pt(c);if(gt){if(q=_m(c),!J)return Be(c,q)}else{var vt=Se(c),pt=vt==F||vt==X;if(os(c))return Kh(c,J);if(vt==yt||vt==et||pt&&!M){if(q=nt||pt?{}:du(c),!J)return nt?um(c,My(q,c)):hm(c,Eh(q,c))}else{if(!te[vt])return M?c:{};q=km(c,vt,J)}}z||(z=new gi);var _t=z.get(c);if(_t)return _t;z.set(c,q),Uu(c)?c.forEach(function(Tt){q.add(ri(Tt,d,m,Tt,c,z))}):Hu(c)&&c.forEach(function(Tt,Nt){q.set(Nt,ri(Tt,d,m,Nt,c,z))});var Ct=dt?nt?Qo:Jo:nt?Ne:pe,Mt=gt?i:Ct(c);return ii(Mt||c,function(Tt,Nt){Mt&&(Nt=Tt,Tt=c[Nt]),Wn(q,Nt,ri(Tt,d,m,Nt,c,z))}),q}function By(c){var d=pe(c);return function(m){return Ah(m,c,d)}}function Ah(c,d,m){var A=m.length;if(c==null)return!A;for(c=Zt(c);A--;){var M=m[A],z=d[M],q=c[M];if(q===i&&!(M in c)||!z(q))return!1}return!0}function Ch(c,d,m){if(typeof c!="function")throw new si(a);return Kn(function(){c.apply(i,m)},d)}function Un(c,d,m,A){var M=-1,z=Pr,q=!0,J=c.length,nt=[],dt=d.length;if(!J)return nt;m&&(d=ne(d,je(m))),A?(z=wo,q=!1):d.length>=n&&(z=Bn,q=!1,d=new Es(d));t:for(;++M<J;){var gt=c[M],vt=m==null?gt:m(gt);if(gt=A||gt!==0?gt:0,q&&vt===vt){for(var pt=dt;pt--;)if(d[pt]===vt)continue t;nt.push(gt)}else z(d,vt,A)||nt.push(gt)}return nt}var ss=Qh(_i),Th=Qh(Bo,!0);function Oy(c,d){var m=!0;return ss(c,function(A,M,z){return m=!!d(A,M,z),m}),m}function Kr(c,d,m){for(var A=-1,M=c.length;++A<M;){var z=c[A],q=d(z);if(q!=null&&(J===i?q===q&&!qe(q):m(q,J)))var J=q,nt=z}return nt}function Ny(c,d,m,A){var M=c.length;for(m=Dt(m),m<0&&(m=-m>M?0:M+m),A=A===i||A>M?M:Dt(A),A<0&&(A+=M),A=m>A?0:ju(A);m<A;)c[m++]=d;return c}function Rh(c,d){var m=[];return ss(c,function(A,M,z){d(A,M,z)&&m.push(A)}),m}function ke(c,d,m,A,M){var z=-1,q=c.length;for(m||(m=Am),M||(M=[]);++z<q;){var J=c[z];d>0&&m(J)?d>1?ke(J,d-1,m,A,M):ts(M,J):A||(M[M.length]=J)}return M}var Mo=tu(),Sh=tu(!0);function _i(c,d){return c&&Mo(c,d,pe)}function Bo(c,d){return c&&Sh(c,d,pe)}function Xr(c,d){return Qi(d,function(m){return Fi(c[m])})}function Cs(c,d){d=rs(d,c);for(var m=0,A=d.length;c!=null&&m<A;)c=c[Ei(d[m++])];return m&&m==A?c:i}function Ph(c,d,m){var A=d(c);return Pt(c)?A:ts(A,m(c))}function Pe(c){return c==null?c===i?Qt:mt:_s&&_s in Zt(c)?wm(c):Lm(c)}function Oo(c,d){return c>d}function Fy(c,d){return c!=null&&Xt.call(c,d)}function zy(c,d){return c!=null&&d in Zt(c)}function Hy(c,d,m){return c>=Re(d,m)&&c<ye(d,m)}function No(c,d,m){for(var A=m?wo:Pr,M=c[0].length,z=c.length,q=z,J=lt(z),nt=1/0,dt=[];q--;){var gt=c[q];q&&d&&(gt=ne(gt,je(d))),nt=Re(gt.length,nt),J[q]=!m&&(d||M>=120&>.length>=120)?new Es(q&>):i}gt=c[0];var vt=-1,pt=J[0];t:for(;++vt<M&&dt.length<nt;){var _t=gt[vt],Ct=d?d(_t):_t;if(_t=m||_t!==0?_t:0,!(pt?Bn(pt,Ct):A(dt,Ct,m))){for(q=z;--q;){var Mt=J[q];if(!(Mt?Bn(Mt,Ct):A(c[q],Ct,m)))continue t}pt&&pt.push(Ct),dt.push(_t)}}return dt}function Wy(c,d,m,A){return _i(c,function(M,z,q){d(A,m(M),z,q)}),A}function Vn(c,d,m){d=rs(d,c),c=mu(c,d);var A=c==null?c:c[Ei(oi(d))];return A==null?i:Ve(A,c,m)}function Ih(c){return ce(c)&&Pe(c)==et}function Uy(c){return ce(c)&&Pe(c)==Mn}function Vy(c){return ce(c)&&Pe(c)==b}function jn(c,d,m,A,M){return c===d?!0:c==null||d==null||!ce(c)&&!ce(d)?c!==c&&d!==d:jy(c,d,m,A,jn,M)}function jy(c,d,m,A,M,z){var q=Pt(c),J=Pt(d),nt=q?ut:Se(c),dt=J?ut:Se(d);nt=nt==et?yt:nt,dt=dt==et?yt:dt;var gt=nt==yt,vt=dt==yt,pt=nt==dt;if(pt&&os(c)){if(!os(d))return!1;q=!0,gt=!1}if(pt&&!gt)return z||(z=new gi),q||hn(c)?hu(c,d,m,A,M,z):mm(c,d,nt,m,A,M,z);if(!(m&y)){var _t=gt&&Xt.call(c,"__wrapped__"),Ct=vt&&Xt.call(d,"__wrapped__");if(_t||Ct){var Mt=_t?c.value():c,Tt=Ct?d.value():d;return z||(z=new gi),M(Mt,Tt,m,A,z)}}return pt?(z||(z=new gi),pm(c,d,m,A,M,z)):!1}function $y(c){return ce(c)&&Se(c)==G}function Fo(c,d,m,A){var M=m.length,z=M,q=!A;if(c==null)return!z;for(c=Zt(c);M--;){var J=m[M];if(q&&J[2]?J[1]!==c[J[0]]:!(J[0]in c))return!1}for(;++M<z;){J=m[M];var nt=J[0],dt=c[nt],gt=J[1];if(q&&J[2]){if(dt===i&&!(nt in c))return!1}else{var vt=new gi;if(A)var pt=A(dt,gt,nt,c,d,vt);if(!(pt===i?jn(gt,dt,y|w,A,vt):pt))return!1}}return!0}function Lh(c){if(!oe(c)||Tm(c))return!1;var d=Fi(c)?$0:Bv;return d.test(Rs(c))}function qy(c){return ce(c)&&Pe(c)==be}function Yy(c){return ce(c)&&Se(c)==se}function Ky(c){return ce(c)&&fa(c.length)&&!!ie[Pe(c)]}function Dh(c){return typeof c=="function"?c:c==null?Fe:typeof c=="object"?Pt(c)?Oh(c[0],c[1]):Bh(c):ef(c)}function zo(c){if(!Yn(c))return Z0(c);var d=[];for(var m in Zt(c))Xt.call(c,m)&&m!="constructor"&&d.push(m);return d}function Xy(c){if(!oe(c))return Im(c);var d=Yn(c),m=[];for(var A in c)A=="constructor"&&(d||!Xt.call(c,A))||m.push(A);return m}function Ho(c,d){return c<d}function Mh(c,d){var m=-1,A=Oe(c)?lt(c.length):[];return ss(c,function(M,z,q){A[++m]=d(M,z,q)}),A}function Bh(c){var d=el(c);return d.length==1&&d[0][2]?vu(d[0][0],d[0][1]):function(m){return m===c||Fo(m,c,d)}}function Oh(c,d){return sl(c)&&gu(d)?vu(Ei(c),d):function(m){var A=dl(m,c);return A===i&&A===d?gl(m,c):jn(d,A,y|w)}}function Gr(c,d,m,A,M){c!==d&&Mo(d,function(z,q){if(M||(M=new gi),oe(z))Gy(c,d,q,m,Gr,A,M);else{var J=A?A(rl(c,q),z,q+"",c,d,M):i;J===i&&(J=z),Lo(c,q,J)}},Ne)}function Gy(c,d,m,A,M,z,q){var J=rl(c,m),nt=rl(d,m),dt=q.get(nt);if(dt){Lo(c,m,dt);return}var gt=z?z(J,nt,m+"",c,d,q):i,vt=gt===i;if(vt){var pt=Pt(nt),_t=!pt&&os(nt),Ct=!pt&&!_t&&hn(nt);gt=nt,pt||_t||Ct?Pt(J)?gt=J:ue(J)?gt=Be(J):_t?(vt=!1,gt=Kh(nt,!0)):Ct?(vt=!1,gt=Xh(nt,!0)):gt=[]:Xn(nt)||Ss(nt)?(gt=J,Ss(J)?gt=$u(J):(!oe(J)||Fi(J))&&(gt=du(nt))):vt=!1}vt&&(q.set(nt,gt),M(gt,nt,A,z,q),q.delete(nt)),Lo(c,m,gt)}function Nh(c,d){var m=c.length;if(!!m)return d+=d<0?m:0,Ni(d,m)?c[d]:i}function Fh(c,d,m){d.length?d=ne(d,function(z){return Pt(z)?function(q){return Cs(q,z.length===1?z[0]:z)}:z}):d=[Fe];var A=-1;d=ne(d,je(Et()));var M=Mh(c,function(z,q,J){var nt=ne(d,function(dt){return dt(z)});return{criteria:nt,index:++A,value:z}});return k0(M,function(z,q){return cm(z,q,m)})}function Zy(c,d){return zh(c,d,function(m,A){return gl(c,A)})}function zh(c,d,m){for(var A=-1,M=d.length,z={};++A<M;){var q=d[A],J=Cs(c,q);m(J,q)&&$n(z,rs(q,c),J)}return z}function Jy(c){return function(d){return Cs(d,c)}}function Wo(c,d,m,A){var M=A?_0:Js,z=-1,q=d.length,J=c;for(c===d&&(d=Be(d)),m&&(J=ne(c,je(m)));++z<q;)for(var nt=0,dt=d[z],gt=m?m(dt):dt;(nt=M(J,gt,nt,A))>-1;)J!==c&&Hr.call(J,nt,1),Hr.call(c,nt,1);return c}function Hh(c,d){for(var m=c?d.length:0,A=m-1;m--;){var M=d[m];if(m==A||M!==z){var z=M;Ni(M)?Hr.call(c,M,1):$o(c,M)}}return c}function Uo(c,d){return c+Vr(bh()*(d-c+1))}function Qy(c,d,m,A){for(var M=-1,z=ye(Ur((d-c)/(m||1)),0),q=lt(z);z--;)q[A?z:++M]=c,c+=m;return q}function Vo(c,d){var m="";if(!c||d<1||d>$)return m;do d%2&&(m+=c),d=Vr(d/2),d&&(c+=c);while(d);return m}function Bt(c,d){return al(yu(c,d,Fe),c+"")}function tm(c){return kh(un(c))}function em(c,d){var m=un(c);return aa(m,As(d,0,m.length))}function $n(c,d,m,A){if(!oe(c))return c;d=rs(d,c);for(var M=-1,z=d.length,q=z-1,J=c;J!=null&&++M<z;){var nt=Ei(d[M]),dt=m;if(nt==="__proto__"||nt==="constructor"||nt==="prototype")return c;if(M!=q){var gt=J[nt];dt=A?A(gt,nt,J):i,dt===i&&(dt=oe(gt)?gt:Ni(d[M+1])?[]:{})}Wn(J,nt,dt),J=J[nt]}return c}var Wh=jr?function(c,d){return jr.set(c,d),c}:Fe,im=Wr?function(c,d){return Wr(c,"toString",{configurable:!0,enumerable:!1,value:yl(d),writable:!0})}:Fe;function sm(c){return aa(un(c))}function ai(c,d,m){var A=-1,M=c.length;d<0&&(d=-d>M?0:M+d),m=m>M?M:m,m<0&&(m+=M),M=d>m?0:m-d>>>0,d>>>=0;for(var z=lt(M);++A<M;)z[A]=c[A+d];return z}function nm(c,d){var m;return ss(c,function(A,M,z){return m=d(A,M,z),!m}),!!m}function Zr(c,d,m){var A=0,M=c==null?A:c.length;if(typeof d=="number"&&d===d&&M<=Q){for(;A<M;){var z=A+M>>>1,q=c[z];q!==null&&!qe(q)&&(m?q<=d:q<d)?A=z+1:M=z}return M}return jo(c,d,Fe,m)}function jo(c,d,m,A){var M=0,z=c==null?0:c.length;if(z===0)return 0;d=m(d);for(var q=d!==d,J=d===null,nt=qe(d),dt=d===i;M<z;){var gt=Vr((M+z)/2),vt=m(c[gt]),pt=vt!==i,_t=vt===null,Ct=vt===vt,Mt=qe(vt);if(q)var Tt=A||Ct;else dt?Tt=Ct&&(A||pt):J?Tt=Ct&&pt&&(A||!_t):nt?Tt=Ct&&pt&&!_t&&(A||!Mt):_t||Mt?Tt=!1:Tt=A?vt<=d:vt<d;Tt?M=gt+1:z=gt}return Re(z,W)}function Uh(c,d){for(var m=-1,A=c.length,M=0,z=[];++m<A;){var q=c[m],J=d?d(q):q;if(!m||!vi(J,nt)){var nt=J;z[M++]=q===0?0:q}}return z}function Vh(c){return typeof c=="number"?c:qe(c)?j:+c}function $e(c){if(typeof c=="string")return c;if(Pt(c))return ne(c,$e)+"";if(qe(c))return xh?xh.call(c):"";var d=c+"";return d=="0"&&1/c==-rt?"-0":d}function ns(c,d,m){var A=-1,M=Pr,z=c.length,q=!0,J=[],nt=J;if(m)q=!1,M=wo;else if(z>=n){var dt=d?null:vm(c);if(dt)return Lr(dt);q=!1,M=Bn,nt=new Es}else nt=d?[]:J;t:for(;++A<z;){var gt=c[A],vt=d?d(gt):gt;if(gt=m||gt!==0?gt:0,q&&vt===vt){for(var pt=nt.length;pt--;)if(nt[pt]===vt)continue t;d&&nt.push(vt),J.push(gt)}else M(nt,vt,m)||(nt!==J&&nt.push(vt),J.push(gt))}return J}function $o(c,d){return d=rs(d,c),c=mu(c,d),c==null||delete c[Ei(oi(d))]}function jh(c,d,m,A){return $n(c,d,m(Cs(c,d)),A)}function Jr(c,d,m,A){for(var M=c.length,z=A?M:-1;(A?z--:++z<M)&&d(c[z],z,c););return m?ai(c,A?0:z,A?z+1:M):ai(c,A?z+1:0,A?M:z)}function $h(c,d){var m=c;return m instanceof Ft&&(m=m.value()),bo(d,function(A,M){return M.func.apply(M.thisArg,ts([A],M.args))},m)}function qo(c,d,m){var A=c.length;if(A<2)return A?ns(c[0]):[];for(var M=-1,z=lt(A);++M<A;)for(var q=c[M],J=-1;++J<A;)J!=M&&(z[M]=Un(z[M]||q,c[J],d,m));return ns(ke(z,1),d,m)}function qh(c,d,m){for(var A=-1,M=c.length,z=d.length,q={};++A<M;){var J=A<z?d[A]:i;m(q,c[A],J)}return q}function Yo(c){return ue(c)?c:[]}function Ko(c){return typeof c=="function"?c:Fe}function rs(c,d){return Pt(c)?c:sl(c,d)?[c]:xu(Kt(c))}var rm=Bt;function as(c,d,m){var A=c.length;return m=m===i?A:m,!d&&m>=A?c:ai(c,d,m)}var Yh=q0||function(c){return _e.clearTimeout(c)};function Kh(c,d){if(d)return c.slice();var m=c.length,A=vh?vh(m):new c.constructor(m);return c.copy(A),A}function Xo(c){var d=new c.constructor(c.byteLength);return new Fr(d).set(new Fr(c)),d}function am(c,d){var m=d?Xo(c.buffer):c.buffer;return new c.constructor(m,c.byteOffset,c.byteLength)}function om(c){var d=new c.constructor(c.source,Ic.exec(c));return d.lastIndex=c.lastIndex,d}function lm(c){return Hn?Zt(Hn.call(c)):{}}function Xh(c,d){var m=d?Xo(c.buffer):c.buffer;return new c.constructor(m,c.byteOffset,c.length)}function Gh(c,d){if(c!==d){var m=c!==i,A=c===null,M=c===c,z=qe(c),q=d!==i,J=d===null,nt=d===d,dt=qe(d);if(!J&&!dt&&!z&&c>d||z&&q&&nt&&!J&&!dt||A&&q&&nt||!m&&nt||!M)return 1;if(!A&&!z&&!dt&&c<d||dt&&m&&M&&!A&&!z||J&&m&&M||!q&&M||!nt)return-1}return 0}function cm(c,d,m){for(var A=-1,M=c.criteria,z=d.criteria,q=M.length,J=m.length;++A<q;){var nt=Gh(M[A],z[A]);if(nt){if(A>=J)return nt;var dt=m[A];return nt*(dt=="desc"?-1:1)}}return c.index-d.index}function Zh(c,d,m,A){for(var M=-1,z=c.length,q=m.length,J=-1,nt=d.length,dt=ye(z-q,0),gt=lt(nt+dt),vt=!A;++J<nt;)gt[J]=d[J];for(;++M<q;)(vt||M<z)&&(gt[m[M]]=c[M]);for(;dt--;)gt[J++]=c[M++];return gt}function Jh(c,d,m,A){for(var M=-1,z=c.length,q=-1,J=m.length,nt=-1,dt=d.length,gt=ye(z-J,0),vt=lt(gt+dt),pt=!A;++M<gt;)vt[M]=c[M];for(var _t=M;++nt<dt;)vt[_t+nt]=d[nt];for(;++q<J;)(pt||M<z)&&(vt[_t+m[q]]=c[M++]);return vt}function Be(c,d){var m=-1,A=c.length;for(d||(d=lt(A));++m<A;)d[m]=c[m];return d}function ki(c,d,m,A){var M=!m;m||(m={});for(var z=-1,q=d.length;++z<q;){var J=d[z],nt=A?A(m[J],c[J],J,m,c):i;nt===i&&(nt=c[J]),M?Mi(m,J,nt):Wn(m,J,nt)}return m}function hm(c,d){return ki(c,il(c),d)}function um(c,d){return ki(c,uu(c),d)}function Qr(c,d){return function(m,A){var M=Pt(m)?y0:Dy,z=d?d():{};return M(m,c,Et(A,2),z)}}function on(c){return Bt(function(d,m){var A=-1,M=m.length,z=M>1?m[M-1]:i,q=M>2?m[2]:i;for(z=c.length>3&&typeof z=="function"?(M--,z):i,q&&Ie(m[0],m[1],q)&&(z=M<3?i:z,M=1),d=Zt(d);++A<M;){var J=m[A];J&&c(d,J,A,z)}return d})}function Qh(c,d){return function(m,A){if(m==null)return m;if(!Oe(m))return c(m,A);for(var M=m.length,z=d?M:-1,q=Zt(m);(d?z--:++z<M)&&A(q[z],z,q)!==!1;);return m}}function tu(c){return function(d,m,A){for(var M=-1,z=Zt(d),q=A(d),J=q.length;J--;){var nt=q[c?J:++M];if(m(z[nt],nt,z)===!1)break}return d}}function fm(c,d,m){var A=d&p,M=qn(c);function z(){var q=this&&this!==_e&&this instanceof z?M:c;return q.apply(A?m:this,arguments)}return z}function eu(c){return function(d){d=Kt(d);var m=Qs(d)?di(d):i,A=m?m[0]:d.charAt(0),M=m?as(m,1).join(""):d.slice(1);return A[c]()+M}}function ln(c){return function(d){return bo(Qu(Ju(d).replace(i0,"")),c,"")}}function qn(c){return function(){var d=arguments;switch(d.length){case 0:return new c;case 1:return new c(d[0]);case 2:return new c(d[0],d[1]);case 3:return new c(d[0],d[1],d[2]);case 4:return new c(d[0],d[1],d[2],d[3]);case 5:return new c(d[0],d[1],d[2],d[3],d[4]);case 6:return new c(d[0],d[1],d[2],d[3],d[4],d[5]);case 7:return new c(d[0],d[1],d[2],d[3],d[4],d[5],d[6])}var m=an(c.prototype),A=c.apply(m,d);return oe(A)?A:m}}function dm(c,d,m){var A=qn(c);function M(){for(var z=arguments.length,q=lt(z),J=z,nt=cn(M);J--;)q[J]=arguments[J];var dt=z<3&&q[0]!==nt&&q[z-1]!==nt?[]:es(q,nt);if(z-=dt.length,z<m)return au(c,d,ta,M.placeholder,i,q,dt,i,i,m-z);var gt=this&&this!==_e&&this instanceof M?A:c;return Ve(gt,this,q)}return M}function iu(c){return function(d,m,A){var M=Zt(d);if(!Oe(d)){var z=Et(m,3);d=pe(d),m=function(J){return z(M[J],J,M)}}var q=c(d,m,A);return q>-1?M[z?d[q]:q]:i}}function su(c){return Oi(function(d){var m=d.length,A=m,M=ni.prototype.thru;for(c&&d.reverse();A--;){var z=d[A];if(typeof z!="function")throw new si(a);if(M&&!q&&na(z)=="wrapper")var q=new ni([],!0)}for(A=q?A:m;++A<m;){z=d[A];var J=na(z),nt=J=="wrapper"?tl(z):i;nt&&nl(nt[0])&&nt[1]==(B|x|S|L)&&!nt[4].length&&nt[9]==1?q=q[na(nt[0])].apply(q,nt[3]):q=z.length==1&&nl(z)?q[J]():q.thru(z)}return function(){var dt=arguments,gt=dt[0];if(q&&dt.length==1&&Pt(gt))return q.plant(gt).value();for(var vt=0,pt=m?d[vt].apply(this,dt):gt;++vt<m;)pt=d[vt].call(this,pt);return pt}})}function ta(c,d,m,A,M,z,q,J,nt,dt){var gt=d&B,vt=d&p,pt=d&_,_t=d&(x|C),Ct=d&V,Mt=pt?i:qn(c);function Tt(){for(var Nt=arguments.length,Ht=lt(Nt),Ye=Nt;Ye--;)Ht[Ye]=arguments[Ye];if(_t)var Le=cn(Tt),Ke=A0(Ht,Le);if(A&&(Ht=Zh(Ht,A,M,_t)),z&&(Ht=Jh(Ht,z,q,_t)),Nt-=Ke,_t&&Nt<dt){var fe=es(Ht,Le);return au(c,d,ta,Tt.placeholder,m,Ht,fe,J,nt,dt-Nt)}var yi=vt?m:this,Hi=pt?yi[c]:c;return Nt=Ht.length,J?Ht=Dm(Ht,J):Ct&&Nt>1&&Ht.reverse(),gt&&nt<Nt&&(Ht.length=nt),this&&this!==_e&&this instanceof Tt&&(Hi=Mt||qn(Hi)),Hi.apply(yi,Ht)}return Tt}function nu(c,d){return function(m,A){return Wy(m,c,d(A),{})}}function ea(c,d){return function(m,A){var M;if(m===i&&A===i)return d;if(m!==i&&(M=m),A!==i){if(M===i)return A;typeof m=="string"||typeof A=="string"?(m=$e(m),A=$e(A)):(m=Vh(m),A=Vh(A)),M=c(m,A)}return M}}function Go(c){return Oi(function(d){return d=ne(d,je(Et())),Bt(function(m){var A=this;return c(d,function(M){return Ve(M,A,m)})})})}function ia(c,d){d=d===i?" ":$e(d);var m=d.length;if(m<2)return m?Vo(d,c):d;var A=Vo(d,Ur(c/tn(d)));return Qs(d)?as(di(A),0,c).join(""):A.slice(0,c)}function gm(c,d,m,A){var M=d&p,z=qn(c);function q(){for(var J=-1,nt=arguments.length,dt=-1,gt=A.length,vt=lt(gt+nt),pt=this&&this!==_e&&this instanceof q?z:c;++dt<gt;)vt[dt]=A[dt];for(;nt--;)vt[dt++]=arguments[++J];return Ve(pt,M?m:this,vt)}return q}function ru(c){return function(d,m,A){return A&&typeof A!="number"&&Ie(d,m,A)&&(m=A=i),d=zi(d),m===i?(m=d,d=0):m=zi(m),A=A===i?d<m?1:-1:zi(A),Qy(d,m,A,c)}}function sa(c){return function(d,m){return typeof d=="string"&&typeof m=="string"||(d=li(d),m=li(m)),c(d,m)}}function au(c,d,m,A,M,z,q,J,nt,dt){var gt=d&x,vt=gt?q:i,pt=gt?i:q,_t=gt?z:i,Ct=gt?i:z;d|=gt?S:D,d&=~(gt?D:S),d&E||(d&=~(p|_));var Mt=[c,d,M,_t,vt,Ct,pt,J,nt,dt],Tt=m.apply(i,Mt);return nl(c)&&pu(Tt,Mt),Tt.placeholder=A,wu(Tt,c,d)}function Zo(c){var d=ve[c];return function(m,A){if(m=li(m),A=A==null?0:Re(Dt(A),292),A&&wh(m)){var M=(Kt(m)+"e").split("e"),z=d(M[0]+"e"+(+M[1]+A));return M=(Kt(z)+"e").split("e"),+(M[0]+"e"+(+M[1]-A))}return d(m)}}var vm=nn&&1/Lr(new nn([,-0]))[1]==rt?function(c){return new nn(c)}:wl;function ou(c){return function(d){var m=Se(d);return m==G?To(d):m==se?L0(d):E0(d,c(d))}}function Bi(c,d,m,A,M,z,q,J){var nt=d&_;if(!nt&&typeof c!="function")throw new si(a);var dt=A?A.length:0;if(dt||(d&=~(S|D),A=M=i),q=q===i?q:ye(Dt(q),0),J=J===i?J:Dt(J),dt-=M?M.length:0,d&D){var gt=A,vt=M;A=M=i}var pt=nt?i:tl(c),_t=[c,d,m,A,M,gt,vt,z,q,J];if(pt&&Pm(_t,pt),c=_t[0],d=_t[1],m=_t[2],A=_t[3],M=_t[4],J=_t[9]=_t[9]===i?nt?0:c.length:ye(_t[9]-dt,0),!J&&d&(x|C)&&(d&=~(x|C)),!d||d==p)var Ct=fm(c,d,m);else d==x||d==C?Ct=dm(c,d,J):(d==S||d==(p|S))&&!M.length?Ct=gm(c,d,m,A):Ct=ta.apply(i,_t);var Mt=pt?Wh:pu;return wu(Mt(Ct,_t),c,d)}function lu(c,d,m,A){return c===i||vi(c,sn[m])&&!Xt.call(A,m)?d:c}function cu(c,d,m,A,M,z){return oe(c)&&oe(d)&&(z.set(d,c),Gr(c,d,i,cu,z),z.delete(d)),c}function ym(c){return Xn(c)?i:c}function hu(c,d,m,A,M,z){var q=m&y,J=c.length,nt=d.length;if(J!=nt&&!(q&&nt>J))return!1;var dt=z.get(c),gt=z.get(d);if(dt&>)return dt==d&>==c;var vt=-1,pt=!0,_t=m&w?new Es:i;for(z.set(c,d),z.set(d,c);++vt<J;){var Ct=c[vt],Mt=d[vt];if(A)var Tt=q?A(Mt,Ct,vt,d,c,z):A(Ct,Mt,vt,c,d,z);if(Tt!==i){if(Tt)continue;pt=!1;break}if(_t){if(!xo(d,function(Nt,Ht){if(!Bn(_t,Ht)&&(Ct===Nt||M(Ct,Nt,m,A,z)))return _t.push(Ht)})){pt=!1;break}}else if(!(Ct===Mt||M(Ct,Mt,m,A,z))){pt=!1;break}}return z.delete(c),z.delete(d),pt}function mm(c,d,m,A,M,z,q){switch(m){case Gs:if(c.byteLength!=d.byteLength||c.byteOffset!=d.byteOffset)return!1;c=c.buffer,d=d.buffer;case Mn:return!(c.byteLength!=d.byteLength||!z(new Fr(c),new Fr(d)));case ot:case b:case at:return vi(+c,+d);case I:return c.name==d.name&&c.message==d.message;case be:case xe:return c==d+"";case G:var J=To;case se:var nt=A&y;if(J||(J=Lr),c.size!=d.size&&!nt)return!1;var dt=q.get(c);if(dt)return dt==d;A|=w,q.set(c,d);var gt=hu(J(c),J(d),A,M,z,q);return q.delete(c),gt;case $t:if(Hn)return Hn.call(c)==Hn.call(d)}return!1}function pm(c,d,m,A,M,z){var q=m&y,J=Jo(c),nt=J.length,dt=Jo(d),gt=dt.length;if(nt!=gt&&!q)return!1;for(var vt=nt;vt--;){var pt=J[vt];if(!(q?pt in d:Xt.call(d,pt)))return!1}var _t=z.get(c),Ct=z.get(d);if(_t&&Ct)return _t==d&&Ct==c;var Mt=!0;z.set(c,d),z.set(d,c);for(var Tt=q;++vt<nt;){pt=J[vt];var Nt=c[pt],Ht=d[pt];if(A)var Ye=q?A(Ht,Nt,pt,d,c,z):A(Nt,Ht,pt,c,d,z);if(!(Ye===i?Nt===Ht||M(Nt,Ht,m,A,z):Ye)){Mt=!1;break}Tt||(Tt=pt=="constructor")}if(Mt&&!Tt){var Le=c.constructor,Ke=d.constructor;Le!=Ke&&"constructor"in c&&"constructor"in d&&!(typeof Le=="function"&&Le instanceof Le&&typeof Ke=="function"&&Ke instanceof Ke)&&(Mt=!1)}return z.delete(c),z.delete(d),Mt}function Oi(c){return al(yu(c,i,Au),c+"")}function Jo(c){return Ph(c,pe,il)}function Qo(c){return Ph(c,Ne,uu)}var tl=jr?function(c){return jr.get(c)}:wl;function na(c){for(var d=c.name+"",m=rn[d],A=Xt.call(rn,d)?m.length:0;A--;){var M=m[A],z=M.func;if(z==null||z==c)return M.name}return d}function cn(c){var d=Xt.call(N,"placeholder")?N:c;return d.placeholder}function Et(){var c=N.iteratee||ml;return c=c===ml?Dh:c,arguments.length?c(arguments[0],arguments[1]):c}function ra(c,d){var m=c.__data__;return Cm(d)?m[typeof d=="string"?"string":"hash"]:m.map}function el(c){for(var d=pe(c),m=d.length;m--;){var A=d[m],M=c[A];d[m]=[A,M,gu(M)]}return d}function Ts(c,d){var m=S0(c,d);return Lh(m)?m:i}function wm(c){var d=Xt.call(c,_s),m=c[_s];try{c[_s]=i;var A=!0}catch{}var M=Or.call(c);return A&&(d?c[_s]=m:delete c[_s]),M}var il=So?function(c){return c==null?[]:(c=Zt(c),Qi(So(c),function(d){return mh.call(c,d)}))}:bl,uu=So?function(c){for(var d=[];c;)ts(d,il(c)),c=zr(c);return d}:bl,Se=Pe;(Po&&Se(new Po(new ArrayBuffer(1)))!=Gs||Nn&&Se(new Nn)!=G||Io&&Se(Io.resolve())!=kt||nn&&Se(new nn)!=se||Fn&&Se(new Fn)!=xi)&&(Se=function(c){var d=Pe(c),m=d==yt?c.constructor:i,A=m?Rs(m):"";if(A)switch(A){case ey:return Gs;case iy:return G;case sy:return kt;case ny:return se;case ry:return xi}return d});function bm(c,d,m){for(var A=-1,M=m.length;++A<M;){var z=m[A],q=z.size;switch(z.type){case"drop":c+=q;break;case"dropRight":d-=q;break;case"take":d=Re(d,c+q);break;case"takeRight":c=ye(c,d-q);break}}return{start:c,end:d}}function xm(c){var d=c.match(Tv);return d?d[1].split(Rv):[]}function fu(c,d,m){d=rs(d,c);for(var A=-1,M=d.length,z=!1;++A<M;){var q=Ei(d[A]);if(!(z=c!=null&&m(c,q)))break;c=c[q]}return z||++A!=M?z:(M=c==null?0:c.length,!!M&&fa(M)&&Ni(q,M)&&(Pt(c)||Ss(c)))}function _m(c){var d=c.length,m=new c.constructor(d);return d&&typeof c[0]=="string"&&Xt.call(c,"index")&&(m.index=c.index,m.input=c.input),m}function du(c){return typeof c.constructor=="function"&&!Yn(c)?an(zr(c)):{}}function km(c,d,m){var A=c.constructor;switch(d){case Mn:return Xo(c);case ot:case b:return new A(+c);case Gs:return am(c,m);case to:case eo:case io:case so:case no:case ro:case ao:case oo:case lo:return Xh(c,m);case G:return new A;case at:case xe:return new A(c);case be:return om(c);case se:return new A;case $t:return lm(c)}}function Em(c,d){var m=d.length;if(!m)return c;var A=m-1;return d[A]=(m>1?"& ":"")+d[A],d=d.join(m>2?", ":" "),c.replace(Cv,`{
- /* [wrapped with `+d+`] */
- `)}function Am(c){return Pt(c)||Ss(c)||!!(ph&&c&&c[ph])}function Ni(c,d){var m=typeof c;return d=d==null?$:d,!!d&&(m=="number"||m!="symbol"&&Nv.test(c))&&c>-1&&c%1==0&&c<d}function Ie(c,d,m){if(!oe(m))return!1;var A=typeof d;return(A=="number"?Oe(m)&&Ni(d,m.length):A=="string"&&d in m)?vi(m[d],c):!1}function sl(c,d){if(Pt(c))return!1;var m=typeof c;return m=="number"||m=="symbol"||m=="boolean"||c==null||qe(c)?!0:_v.test(c)||!xv.test(c)||d!=null&&c in Zt(d)}function Cm(c){var d=typeof c;return d=="string"||d=="number"||d=="symbol"||d=="boolean"?c!=="__proto__":c===null}function nl(c){var d=na(c),m=N[d];if(typeof m!="function"||!(d in Ft.prototype))return!1;if(c===m)return!0;var A=tl(m);return!!A&&c===A[0]}function Tm(c){return!!gh&&gh in c}var Rm=Mr?Fi:xl;function Yn(c){var d=c&&c.constructor,m=typeof d=="function"&&d.prototype||sn;return c===m}function gu(c){return c===c&&!oe(c)}function vu(c,d){return function(m){return m==null?!1:m[c]===d&&(d!==i||c in Zt(m))}}function Sm(c){var d=ha(c,function(A){return m.size===u&&m.clear(),A}),m=d.cache;return d}function Pm(c,d){var m=c[1],A=d[1],M=m|A,z=M<(p|_|B),q=A==B&&m==x||A==B&&m==L&&c[7].length<=d[8]||A==(B|L)&&d[7].length<=d[8]&&m==x;if(!(z||q))return c;A&p&&(c[2]=d[2],M|=m&p?0:E);var J=d[3];if(J){var nt=c[3];c[3]=nt?Zh(nt,J,d[4]):J,c[4]=nt?es(c[3],h):d[4]}return J=d[5],J&&(nt=c[5],c[5]=nt?Jh(nt,J,d[6]):J,c[6]=nt?es(c[5],h):d[6]),J=d[7],J&&(c[7]=J),A&B&&(c[8]=c[8]==null?d[8]:Re(c[8],d[8])),c[9]==null&&(c[9]=d[9]),c[0]=d[0],c[1]=M,c}function Im(c){var d=[];if(c!=null)for(var m in Zt(c))d.push(m);return d}function Lm(c){return Or.call(c)}function yu(c,d,m){return d=ye(d===i?c.length-1:d,0),function(){for(var A=arguments,M=-1,z=ye(A.length-d,0),q=lt(z);++M<z;)q[M]=A[d+M];M=-1;for(var J=lt(d+1);++M<d;)J[M]=A[M];return J[d]=m(q),Ve(c,this,J)}}function mu(c,d){return d.length<2?c:Cs(c,ai(d,0,-1))}function Dm(c,d){for(var m=c.length,A=Re(d.length,m),M=Be(c);A--;){var z=d[A];c[A]=Ni(z,m)?M[z]:i}return c}function rl(c,d){if(!(d==="constructor"&&typeof c[d]=="function")&&d!="__proto__")return c[d]}var pu=bu(Wh),Kn=K0||function(c,d){return _e.setTimeout(c,d)},al=bu(im);function wu(c,d,m){var A=d+"";return al(c,Em(A,Mm(xm(A),m)))}function bu(c){var d=0,m=0;return function(){var A=J0(),M=P-(A-m);if(m=A,M>0){if(++d>=R)return arguments[0]}else d=0;return c.apply(i,arguments)}}function aa(c,d){var m=-1,A=c.length,M=A-1;for(d=d===i?A:d;++m<d;){var z=Uo(m,M),q=c[z];c[z]=c[m],c[m]=q}return c.length=d,c}var xu=Sm(function(c){var d=[];return c.charCodeAt(0)===46&&d.push(""),c.replace(kv,function(m,A,M,z){d.push(M?z.replace(Iv,"$1"):A||m)}),d});function Ei(c){if(typeof c=="string"||qe(c))return c;var d=c+"";return d=="0"&&1/c==-rt?"-0":d}function Rs(c){if(c!=null){try{return Br.call(c)}catch{}try{return c+""}catch{}}return""}function Mm(c,d){return ii(st,function(m){var A="_."+m[0];d&m[1]&&!Pr(c,A)&&c.push(A)}),c.sort()}function _u(c){if(c instanceof Ft)return c.clone();var d=new ni(c.__wrapped__,c.__chain__);return d.__actions__=Be(c.__actions__),d.__index__=c.__index__,d.__values__=c.__values__,d}function Bm(c,d,m){(m?Ie(c,d,m):d===i)?d=1:d=ye(Dt(d),0);var A=c==null?0:c.length;if(!A||d<1)return[];for(var M=0,z=0,q=lt(Ur(A/d));M<A;)q[z++]=ai(c,M,M+=d);return q}function Om(c){for(var d=-1,m=c==null?0:c.length,A=0,M=[];++d<m;){var z=c[d];z&&(M[A++]=z)}return M}function Nm(){var c=arguments.length;if(!c)return[];for(var d=lt(c-1),m=arguments[0],A=c;A--;)d[A-1]=arguments[A];return ts(Pt(m)?Be(m):[m],ke(d,1))}var Fm=Bt(function(c,d){return ue(c)?Un(c,ke(d,1,ue,!0)):[]}),zm=Bt(function(c,d){var m=oi(d);return ue(m)&&(m=i),ue(c)?Un(c,ke(d,1,ue,!0),Et(m,2)):[]}),Hm=Bt(function(c,d){var m=oi(d);return ue(m)&&(m=i),ue(c)?Un(c,ke(d,1,ue,!0),i,m):[]});function Wm(c,d,m){var A=c==null?0:c.length;return A?(d=m||d===i?1:Dt(d),ai(c,d<0?0:d,A)):[]}function Um(c,d,m){var A=c==null?0:c.length;return A?(d=m||d===i?1:Dt(d),d=A-d,ai(c,0,d<0?0:d)):[]}function Vm(c,d){return c&&c.length?Jr(c,Et(d,3),!0,!0):[]}function jm(c,d){return c&&c.length?Jr(c,Et(d,3),!0):[]}function $m(c,d,m,A){var M=c==null?0:c.length;return M?(m&&typeof m!="number"&&Ie(c,d,m)&&(m=0,A=M),Ny(c,d,m,A)):[]}function ku(c,d,m){var A=c==null?0:c.length;if(!A)return-1;var M=m==null?0:Dt(m);return M<0&&(M=ye(A+M,0)),Ir(c,Et(d,3),M)}function Eu(c,d,m){var A=c==null?0:c.length;if(!A)return-1;var M=A-1;return m!==i&&(M=Dt(m),M=m<0?ye(A+M,0):Re(M,A-1)),Ir(c,Et(d,3),M,!0)}function Au(c){var d=c==null?0:c.length;return d?ke(c,1):[]}function qm(c){var d=c==null?0:c.length;return d?ke(c,rt):[]}function Ym(c,d){var m=c==null?0:c.length;return m?(d=d===i?1:Dt(d),ke(c,d)):[]}function Km(c){for(var d=-1,m=c==null?0:c.length,A={};++d<m;){var M=c[d];A[M[0]]=M[1]}return A}function Cu(c){return c&&c.length?c[0]:i}function Xm(c,d,m){var A=c==null?0:c.length;if(!A)return-1;var M=m==null?0:Dt(m);return M<0&&(M=ye(A+M,0)),Js(c,d,M)}function Gm(c){var d=c==null?0:c.length;return d?ai(c,0,-1):[]}var Zm=Bt(function(c){var d=ne(c,Yo);return d.length&&d[0]===c[0]?No(d):[]}),Jm=Bt(function(c){var d=oi(c),m=ne(c,Yo);return d===oi(m)?d=i:m.pop(),m.length&&m[0]===c[0]?No(m,Et(d,2)):[]}),Qm=Bt(function(c){var d=oi(c),m=ne(c,Yo);return d=typeof d=="function"?d:i,d&&m.pop(),m.length&&m[0]===c[0]?No(m,i,d):[]});function tp(c,d){return c==null?"":G0.call(c,d)}function oi(c){var d=c==null?0:c.length;return d?c[d-1]:i}function ep(c,d,m){var A=c==null?0:c.length;if(!A)return-1;var M=A;return m!==i&&(M=Dt(m),M=M<0?ye(A+M,0):Re(M,A-1)),d===d?M0(c,d,M):Ir(c,ah,M,!0)}function ip(c,d){return c&&c.length?Nh(c,Dt(d)):i}var sp=Bt(Tu);function Tu(c,d){return c&&c.length&&d&&d.length?Wo(c,d):c}function np(c,d,m){return c&&c.length&&d&&d.length?Wo(c,d,Et(m,2)):c}function rp(c,d,m){return c&&c.length&&d&&d.length?Wo(c,d,i,m):c}var ap=Oi(function(c,d){var m=c==null?0:c.length,A=Do(c,d);return Hh(c,ne(d,function(M){return Ni(M,m)?+M:M}).sort(Gh)),A});function op(c,d){var m=[];if(!(c&&c.length))return m;var A=-1,M=[],z=c.length;for(d=Et(d,3);++A<z;){var q=c[A];d(q,A,c)&&(m.push(q),M.push(A))}return Hh(c,M),m}function ol(c){return c==null?c:ty.call(c)}function lp(c,d,m){var A=c==null?0:c.length;return A?(m&&typeof m!="number"&&Ie(c,d,m)?(d=0,m=A):(d=d==null?0:Dt(d),m=m===i?A:Dt(m)),ai(c,d,m)):[]}function cp(c,d){return Zr(c,d)}function hp(c,d,m){return jo(c,d,Et(m,2))}function up(c,d){var m=c==null?0:c.length;if(m){var A=Zr(c,d);if(A<m&&vi(c[A],d))return A}return-1}function fp(c,d){return Zr(c,d,!0)}function dp(c,d,m){return jo(c,d,Et(m,2),!0)}function gp(c,d){var m=c==null?0:c.length;if(m){var A=Zr(c,d,!0)-1;if(vi(c[A],d))return A}return-1}function vp(c){return c&&c.length?Uh(c):[]}function yp(c,d){return c&&c.length?Uh(c,Et(d,2)):[]}function mp(c){var d=c==null?0:c.length;return d?ai(c,1,d):[]}function pp(c,d,m){return c&&c.length?(d=m||d===i?1:Dt(d),ai(c,0,d<0?0:d)):[]}function wp(c,d,m){var A=c==null?0:c.length;return A?(d=m||d===i?1:Dt(d),d=A-d,ai(c,d<0?0:d,A)):[]}function bp(c,d){return c&&c.length?Jr(c,Et(d,3),!1,!0):[]}function xp(c,d){return c&&c.length?Jr(c,Et(d,3)):[]}var _p=Bt(function(c){return ns(ke(c,1,ue,!0))}),kp=Bt(function(c){var d=oi(c);return ue(d)&&(d=i),ns(ke(c,1,ue,!0),Et(d,2))}),Ep=Bt(function(c){var d=oi(c);return d=typeof d=="function"?d:i,ns(ke(c,1,ue,!0),i,d)});function Ap(c){return c&&c.length?ns(c):[]}function Cp(c,d){return c&&c.length?ns(c,Et(d,2)):[]}function Tp(c,d){return d=typeof d=="function"?d:i,c&&c.length?ns(c,i,d):[]}function ll(c){if(!(c&&c.length))return[];var d=0;return c=Qi(c,function(m){if(ue(m))return d=ye(m.length,d),!0}),Ao(d,function(m){return ne(c,_o(m))})}function Ru(c,d){if(!(c&&c.length))return[];var m=ll(c);return d==null?m:ne(m,function(A){return Ve(d,i,A)})}var Rp=Bt(function(c,d){return ue(c)?Un(c,d):[]}),Sp=Bt(function(c){return qo(Qi(c,ue))}),Pp=Bt(function(c){var d=oi(c);return ue(d)&&(d=i),qo(Qi(c,ue),Et(d,2))}),Ip=Bt(function(c){var d=oi(c);return d=typeof d=="function"?d:i,qo(Qi(c,ue),i,d)}),Lp=Bt(ll);function Dp(c,d){return qh(c||[],d||[],Wn)}function Mp(c,d){return qh(c||[],d||[],$n)}var Bp=Bt(function(c){var d=c.length,m=d>1?c[d-1]:i;return m=typeof m=="function"?(c.pop(),m):i,Ru(c,m)});function Su(c){var d=N(c);return d.__chain__=!0,d}function Op(c,d){return d(c),c}function oa(c,d){return d(c)}var Np=Oi(function(c){var d=c.length,m=d?c[0]:0,A=this.__wrapped__,M=function(z){return Do(z,c)};return d>1||this.__actions__.length||!(A instanceof Ft)||!Ni(m)?this.thru(M):(A=A.slice(m,+m+(d?1:0)),A.__actions__.push({func:oa,args:[M],thisArg:i}),new ni(A,this.__chain__).thru(function(z){return d&&!z.length&&z.push(i),z}))});function Fp(){return Su(this)}function zp(){return new ni(this.value(),this.__chain__)}function Hp(){this.__values__===i&&(this.__values__=Vu(this.value()));var c=this.__index__>=this.__values__.length,d=c?i:this.__values__[this.__index__++];return{done:c,value:d}}function Wp(){return this}function Up(c){for(var d,m=this;m instanceof qr;){var A=_u(m);A.__index__=0,A.__values__=i,d?M.__wrapped__=A:d=A;var M=A;m=m.__wrapped__}return M.__wrapped__=c,d}function Vp(){var c=this.__wrapped__;if(c instanceof Ft){var d=c;return this.__actions__.length&&(d=new Ft(this)),d=d.reverse(),d.__actions__.push({func:oa,args:[ol],thisArg:i}),new ni(d,this.__chain__)}return this.thru(ol)}function jp(){return $h(this.__wrapped__,this.__actions__)}var $p=Qr(function(c,d,m){Xt.call(c,m)?++c[m]:Mi(c,m,1)});function qp(c,d,m){var A=Pt(c)?nh:Oy;return m&&Ie(c,d,m)&&(d=i),A(c,Et(d,3))}function Yp(c,d){var m=Pt(c)?Qi:Rh;return m(c,Et(d,3))}var Kp=iu(ku),Xp=iu(Eu);function Gp(c,d){return ke(la(c,d),1)}function Zp(c,d){return ke(la(c,d),rt)}function Jp(c,d,m){return m=m===i?1:Dt(m),ke(la(c,d),m)}function Pu(c,d){var m=Pt(c)?ii:ss;return m(c,Et(d,3))}function Iu(c,d){var m=Pt(c)?m0:Th;return m(c,Et(d,3))}var Qp=Qr(function(c,d,m){Xt.call(c,m)?c[m].push(d):Mi(c,m,[d])});function tw(c,d,m,A){c=Oe(c)?c:un(c),m=m&&!A?Dt(m):0;var M=c.length;return m<0&&(m=ye(M+m,0)),da(c)?m<=M&&c.indexOf(d,m)>-1:!!M&&Js(c,d,m)>-1}var ew=Bt(function(c,d,m){var A=-1,M=typeof d=="function",z=Oe(c)?lt(c.length):[];return ss(c,function(q){z[++A]=M?Ve(d,q,m):Vn(q,d,m)}),z}),iw=Qr(function(c,d,m){Mi(c,m,d)});function la(c,d){var m=Pt(c)?ne:Mh;return m(c,Et(d,3))}function sw(c,d,m,A){return c==null?[]:(Pt(d)||(d=d==null?[]:[d]),m=A?i:m,Pt(m)||(m=m==null?[]:[m]),Fh(c,d,m))}var nw=Qr(function(c,d,m){c[m?0:1].push(d)},function(){return[[],[]]});function rw(c,d,m){var A=Pt(c)?bo:lh,M=arguments.length<3;return A(c,Et(d,4),m,M,ss)}function aw(c,d,m){var A=Pt(c)?p0:lh,M=arguments.length<3;return A(c,Et(d,4),m,M,Th)}function ow(c,d){var m=Pt(c)?Qi:Rh;return m(c,ua(Et(d,3)))}function lw(c){var d=Pt(c)?kh:tm;return d(c)}function cw(c,d,m){(m?Ie(c,d,m):d===i)?d=1:d=Dt(d);var A=Pt(c)?Iy:em;return A(c,d)}function hw(c){var d=Pt(c)?Ly:sm;return d(c)}function uw(c){if(c==null)return 0;if(Oe(c))return da(c)?tn(c):c.length;var d=Se(c);return d==G||d==se?c.size:zo(c).length}function fw(c,d,m){var A=Pt(c)?xo:nm;return m&&Ie(c,d,m)&&(d=i),A(c,Et(d,3))}var dw=Bt(function(c,d){if(c==null)return[];var m=d.length;return m>1&&Ie(c,d[0],d[1])?d=[]:m>2&&Ie(d[0],d[1],d[2])&&(d=[d[0]]),Fh(c,ke(d,1),[])}),ca=Y0||function(){return _e.Date.now()};function gw(c,d){if(typeof d!="function")throw new si(a);return c=Dt(c),function(){if(--c<1)return d.apply(this,arguments)}}function Lu(c,d,m){return d=m?i:d,d=c&&d==null?c.length:d,Bi(c,B,i,i,i,i,d)}function Du(c,d){var m;if(typeof d!="function")throw new si(a);return c=Dt(c),function(){return--c>0&&(m=d.apply(this,arguments)),c<=1&&(d=i),m}}var cl=Bt(function(c,d,m){var A=p;if(m.length){var M=es(m,cn(cl));A|=S}return Bi(c,A,d,m,M)}),Mu=Bt(function(c,d,m){var A=p|_;if(m.length){var M=es(m,cn(Mu));A|=S}return Bi(d,A,c,m,M)});function Bu(c,d,m){d=m?i:d;var A=Bi(c,x,i,i,i,i,i,d);return A.placeholder=Bu.placeholder,A}function Ou(c,d,m){d=m?i:d;var A=Bi(c,C,i,i,i,i,i,d);return A.placeholder=Ou.placeholder,A}function Nu(c,d,m){var A,M,z,q,J,nt,dt=0,gt=!1,vt=!1,pt=!0;if(typeof c!="function")throw new si(a);d=li(d)||0,oe(m)&&(gt=!!m.leading,vt="maxWait"in m,z=vt?ye(li(m.maxWait)||0,d):z,pt="trailing"in m?!!m.trailing:pt);function _t(fe){var yi=A,Hi=M;return A=M=i,dt=fe,q=c.apply(Hi,yi),q}function Ct(fe){return dt=fe,J=Kn(Nt,d),gt?_t(fe):q}function Mt(fe){var yi=fe-nt,Hi=fe-dt,sf=d-yi;return vt?Re(sf,z-Hi):sf}function Tt(fe){var yi=fe-nt,Hi=fe-dt;return nt===i||yi>=d||yi<0||vt&&Hi>=z}function Nt(){var fe=ca();if(Tt(fe))return Ht(fe);J=Kn(Nt,Mt(fe))}function Ht(fe){return J=i,pt&&A?_t(fe):(A=M=i,q)}function Ye(){J!==i&&Yh(J),dt=0,A=nt=M=J=i}function Le(){return J===i?q:Ht(ca())}function Ke(){var fe=ca(),yi=Tt(fe);if(A=arguments,M=this,nt=fe,yi){if(J===i)return Ct(nt);if(vt)return Yh(J),J=Kn(Nt,d),_t(nt)}return J===i&&(J=Kn(Nt,d)),q}return Ke.cancel=Ye,Ke.flush=Le,Ke}var vw=Bt(function(c,d){return Ch(c,1,d)}),yw=Bt(function(c,d,m){return Ch(c,li(d)||0,m)});function mw(c){return Bi(c,V)}function ha(c,d){if(typeof c!="function"||d!=null&&typeof d!="function")throw new si(a);var m=function(){var A=arguments,M=d?d.apply(this,A):A[0],z=m.cache;if(z.has(M))return z.get(M);var q=c.apply(this,A);return m.cache=z.set(M,q)||z,q};return m.cache=new(ha.Cache||Di),m}ha.Cache=Di;function ua(c){if(typeof c!="function")throw new si(a);return function(){var d=arguments;switch(d.length){case 0:return!c.call(this);case 1:return!c.call(this,d[0]);case 2:return!c.call(this,d[0],d[1]);case 3:return!c.call(this,d[0],d[1],d[2])}return!c.apply(this,d)}}function pw(c){return Du(2,c)}var ww=rm(function(c,d){d=d.length==1&&Pt(d[0])?ne(d[0],je(Et())):ne(ke(d,1),je(Et()));var m=d.length;return Bt(function(A){for(var M=-1,z=Re(A.length,m);++M<z;)A[M]=d[M].call(this,A[M]);return Ve(c,this,A)})}),hl=Bt(function(c,d){var m=es(d,cn(hl));return Bi(c,S,i,d,m)}),Fu=Bt(function(c,d){var m=es(d,cn(Fu));return Bi(c,D,i,d,m)}),bw=Oi(function(c,d){return Bi(c,L,i,i,i,d)});function xw(c,d){if(typeof c!="function")throw new si(a);return d=d===i?d:Dt(d),Bt(c,d)}function _w(c,d){if(typeof c!="function")throw new si(a);return d=d==null?0:ye(Dt(d),0),Bt(function(m){var A=m[d],M=as(m,0,d);return A&&ts(M,A),Ve(c,this,M)})}function kw(c,d,m){var A=!0,M=!0;if(typeof c!="function")throw new si(a);return oe(m)&&(A="leading"in m?!!m.leading:A,M="trailing"in m?!!m.trailing:M),Nu(c,d,{leading:A,maxWait:d,trailing:M})}function Ew(c){return Lu(c,1)}function Aw(c,d){return hl(Ko(d),c)}function Cw(){if(!arguments.length)return[];var c=arguments[0];return Pt(c)?c:[c]}function Tw(c){return ri(c,v)}function Rw(c,d){return d=typeof d=="function"?d:i,ri(c,v,d)}function Sw(c){return ri(c,f|v)}function Pw(c,d){return d=typeof d=="function"?d:i,ri(c,f|v,d)}function Iw(c,d){return d==null||Ah(c,d,pe(d))}function vi(c,d){return c===d||c!==c&&d!==d}var Lw=sa(Oo),Dw=sa(function(c,d){return c>=d}),Ss=Ih(function(){return arguments}())?Ih:function(c){return ce(c)&&Xt.call(c,"callee")&&!mh.call(c,"callee")},Pt=lt.isArray,Mw=Jc?je(Jc):Uy;function Oe(c){return c!=null&&fa(c.length)&&!Fi(c)}function ue(c){return ce(c)&&Oe(c)}function Bw(c){return c===!0||c===!1||ce(c)&&Pe(c)==ot}var os=X0||xl,Ow=Qc?je(Qc):Vy;function Nw(c){return ce(c)&&c.nodeType===1&&!Xn(c)}function Fw(c){if(c==null)return!0;if(Oe(c)&&(Pt(c)||typeof c=="string"||typeof c.splice=="function"||os(c)||hn(c)||Ss(c)))return!c.length;var d=Se(c);if(d==G||d==se)return!c.size;if(Yn(c))return!zo(c).length;for(var m in c)if(Xt.call(c,m))return!1;return!0}function zw(c,d){return jn(c,d)}function Hw(c,d,m){m=typeof m=="function"?m:i;var A=m?m(c,d):i;return A===i?jn(c,d,i,m):!!A}function ul(c){if(!ce(c))return!1;var d=Pe(c);return d==I||d==k||typeof c.message=="string"&&typeof c.name=="string"&&!Xn(c)}function Ww(c){return typeof c=="number"&&wh(c)}function Fi(c){if(!oe(c))return!1;var d=Pe(c);return d==F||d==X||d==ct||d==Rt}function zu(c){return typeof c=="number"&&c==Dt(c)}function fa(c){return typeof c=="number"&&c>-1&&c%1==0&&c<=$}function oe(c){var d=typeof c;return c!=null&&(d=="object"||d=="function")}function ce(c){return c!=null&&typeof c=="object"}var Hu=th?je(th):$y;function Uw(c,d){return c===d||Fo(c,d,el(d))}function Vw(c,d,m){return m=typeof m=="function"?m:i,Fo(c,d,el(d),m)}function jw(c){return Wu(c)&&c!=+c}function $w(c){if(Rm(c))throw new St(r);return Lh(c)}function qw(c){return c===null}function Yw(c){return c==null}function Wu(c){return typeof c=="number"||ce(c)&&Pe(c)==at}function Xn(c){if(!ce(c)||Pe(c)!=yt)return!1;var d=zr(c);if(d===null)return!0;var m=Xt.call(d,"constructor")&&d.constructor;return typeof m=="function"&&m instanceof m&&Br.call(m)==V0}var fl=eh?je(eh):qy;function Kw(c){return zu(c)&&c>=-$&&c<=$}var Uu=ih?je(ih):Yy;function da(c){return typeof c=="string"||!Pt(c)&&ce(c)&&Pe(c)==xe}function qe(c){return typeof c=="symbol"||ce(c)&&Pe(c)==$t}var hn=sh?je(sh):Ky;function Xw(c){return c===i}function Gw(c){return ce(c)&&Se(c)==xi}function Zw(c){return ce(c)&&Pe(c)==dv}var Jw=sa(Ho),Qw=sa(function(c,d){return c<=d});function Vu(c){if(!c)return[];if(Oe(c))return da(c)?di(c):Be(c);if(On&&c[On])return I0(c[On]());var d=Se(c),m=d==G?To:d==se?Lr:un;return m(c)}function zi(c){if(!c)return c===0?c:0;if(c=li(c),c===rt||c===-rt){var d=c<0?-1:1;return d*H}return c===c?c:0}function Dt(c){var d=zi(c),m=d%1;return d===d?m?d-m:d:0}function ju(c){return c?As(Dt(c),0,K):0}function li(c){if(typeof c=="number")return c;if(qe(c))return j;if(oe(c)){var d=typeof c.valueOf=="function"?c.valueOf():c;c=oe(d)?d+"":d}if(typeof c!="string")return c===0?c:+c;c=ch(c);var m=Mv.test(c);return m||Ov.test(c)?g0(c.slice(2),m?2:8):Dv.test(c)?j:+c}function $u(c){return ki(c,Ne(c))}function tb(c){return c?As(Dt(c),-$,$):c===0?c:0}function Kt(c){return c==null?"":$e(c)}var eb=on(function(c,d){if(Yn(d)||Oe(d)){ki(d,pe(d),c);return}for(var m in d)Xt.call(d,m)&&Wn(c,m,d[m])}),qu=on(function(c,d){ki(d,Ne(d),c)}),ga=on(function(c,d,m,A){ki(d,Ne(d),c,A)}),ib=on(function(c,d,m,A){ki(d,pe(d),c,A)}),sb=Oi(Do);function nb(c,d){var m=an(c);return d==null?m:Eh(m,d)}var rb=Bt(function(c,d){c=Zt(c);var m=-1,A=d.length,M=A>2?d[2]:i;for(M&&Ie(d[0],d[1],M)&&(A=1);++m<A;)for(var z=d[m],q=Ne(z),J=-1,nt=q.length;++J<nt;){var dt=q[J],gt=c[dt];(gt===i||vi(gt,sn[dt])&&!Xt.call(c,dt))&&(c[dt]=z[dt])}return c}),ab=Bt(function(c){return c.push(i,cu),Ve(Yu,i,c)});function ob(c,d){return rh(c,Et(d,3),_i)}function lb(c,d){return rh(c,Et(d,3),Bo)}function cb(c,d){return c==null?c:Mo(c,Et(d,3),Ne)}function hb(c,d){return c==null?c:Sh(c,Et(d,3),Ne)}function ub(c,d){return c&&_i(c,Et(d,3))}function fb(c,d){return c&&Bo(c,Et(d,3))}function db(c){return c==null?[]:Xr(c,pe(c))}function gb(c){return c==null?[]:Xr(c,Ne(c))}function dl(c,d,m){var A=c==null?i:Cs(c,d);return A===i?m:A}function vb(c,d){return c!=null&&fu(c,d,Fy)}function gl(c,d){return c!=null&&fu(c,d,zy)}var yb=nu(function(c,d,m){d!=null&&typeof d.toString!="function"&&(d=Or.call(d)),c[d]=m},yl(Fe)),mb=nu(function(c,d,m){d!=null&&typeof d.toString!="function"&&(d=Or.call(d)),Xt.call(c,d)?c[d].push(m):c[d]=[m]},Et),pb=Bt(Vn);function pe(c){return Oe(c)?_h(c):zo(c)}function Ne(c){return Oe(c)?_h(c,!0):Xy(c)}function wb(c,d){var m={};return d=Et(d,3),_i(c,function(A,M,z){Mi(m,d(A,M,z),A)}),m}function bb(c,d){var m={};return d=Et(d,3),_i(c,function(A,M,z){Mi(m,M,d(A,M,z))}),m}var xb=on(function(c,d,m){Gr(c,d,m)}),Yu=on(function(c,d,m,A){Gr(c,d,m,A)}),_b=Oi(function(c,d){var m={};if(c==null)return m;var A=!1;d=ne(d,function(z){return z=rs(z,c),A||(A=z.length>1),z}),ki(c,Qo(c),m),A&&(m=ri(m,f|g|v,ym));for(var M=d.length;M--;)$o(m,d[M]);return m});function kb(c,d){return Ku(c,ua(Et(d)))}var Eb=Oi(function(c,d){return c==null?{}:Zy(c,d)});function Ku(c,d){if(c==null)return{};var m=ne(Qo(c),function(A){return[A]});return d=Et(d),zh(c,m,function(A,M){return d(A,M[0])})}function Ab(c,d,m){d=rs(d,c);var A=-1,M=d.length;for(M||(M=1,c=i);++A<M;){var z=c==null?i:c[Ei(d[A])];z===i&&(A=M,z=m),c=Fi(z)?z.call(c):z}return c}function Cb(c,d,m){return c==null?c:$n(c,d,m)}function Tb(c,d,m,A){return A=typeof A=="function"?A:i,c==null?c:$n(c,d,m,A)}var Xu=ou(pe),Gu=ou(Ne);function Rb(c,d,m){var A=Pt(c),M=A||os(c)||hn(c);if(d=Et(d,4),m==null){var z=c&&c.constructor;M?m=A?new z:[]:oe(c)?m=Fi(z)?an(zr(c)):{}:m={}}return(M?ii:_i)(c,function(q,J,nt){return d(m,q,J,nt)}),m}function Sb(c,d){return c==null?!0:$o(c,d)}function Pb(c,d,m){return c==null?c:jh(c,d,Ko(m))}function Ib(c,d,m,A){return A=typeof A=="function"?A:i,c==null?c:jh(c,d,Ko(m),A)}function un(c){return c==null?[]:Co(c,pe(c))}function Lb(c){return c==null?[]:Co(c,Ne(c))}function Db(c,d,m){return m===i&&(m=d,d=i),m!==i&&(m=li(m),m=m===m?m:0),d!==i&&(d=li(d),d=d===d?d:0),As(li(c),d,m)}function Mb(c,d,m){return d=zi(d),m===i?(m=d,d=0):m=zi(m),c=li(c),Hy(c,d,m)}function Bb(c,d,m){if(m&&typeof m!="boolean"&&Ie(c,d,m)&&(d=m=i),m===i&&(typeof d=="boolean"?(m=d,d=i):typeof c=="boolean"&&(m=c,c=i)),c===i&&d===i?(c=0,d=1):(c=zi(c),d===i?(d=c,c=0):d=zi(d)),c>d){var A=c;c=d,d=A}if(m||c%1||d%1){var M=bh();return Re(c+M*(d-c+d0("1e-"+((M+"").length-1))),d)}return Uo(c,d)}var Ob=ln(function(c,d,m){return d=d.toLowerCase(),c+(m?Zu(d):d)});function Zu(c){return vl(Kt(c).toLowerCase())}function Ju(c){return c=Kt(c),c&&c.replace(Fv,C0).replace(s0,"")}function Nb(c,d,m){c=Kt(c),d=$e(d);var A=c.length;m=m===i?A:As(Dt(m),0,A);var M=m;return m-=d.length,m>=0&&c.slice(m,M)==d}function Fb(c){return c=Kt(c),c&&pv.test(c)?c.replace(Sc,T0):c}function zb(c){return c=Kt(c),c&&Ev.test(c)?c.replace(co,"\\$&"):c}var Hb=ln(function(c,d,m){return c+(m?"-":"")+d.toLowerCase()}),Wb=ln(function(c,d,m){return c+(m?" ":"")+d.toLowerCase()}),Ub=eu("toLowerCase");function Vb(c,d,m){c=Kt(c),d=Dt(d);var A=d?tn(c):0;if(!d||A>=d)return c;var M=(d-A)/2;return ia(Vr(M),m)+c+ia(Ur(M),m)}function jb(c,d,m){c=Kt(c),d=Dt(d);var A=d?tn(c):0;return d&&A<d?c+ia(d-A,m):c}function $b(c,d,m){c=Kt(c),d=Dt(d);var A=d?tn(c):0;return d&&A<d?ia(d-A,m)+c:c}function qb(c,d,m){return m||d==null?d=0:d&&(d=+d),Q0(Kt(c).replace(ho,""),d||0)}function Yb(c,d,m){return(m?Ie(c,d,m):d===i)?d=1:d=Dt(d),Vo(Kt(c),d)}function Kb(){var c=arguments,d=Kt(c[0]);return c.length<3?d:d.replace(c[1],c[2])}var Xb=ln(function(c,d,m){return c+(m?"_":"")+d.toLowerCase()});function Gb(c,d,m){return m&&typeof m!="number"&&Ie(c,d,m)&&(d=m=i),m=m===i?K:m>>>0,m?(c=Kt(c),c&&(typeof d=="string"||d!=null&&!fl(d))&&(d=$e(d),!d&&Qs(c))?as(di(c),0,m):c.split(d,m)):[]}var Zb=ln(function(c,d,m){return c+(m?" ":"")+vl(d)});function Jb(c,d,m){return c=Kt(c),m=m==null?0:As(Dt(m),0,c.length),d=$e(d),c.slice(m,m+d.length)==d}function Qb(c,d,m){var A=N.templateSettings;m&&Ie(c,d,m)&&(d=i),c=Kt(c),d=ga({},d,A,lu);var M=ga({},d.imports,A.imports,lu),z=pe(M),q=Co(M,z),J,nt,dt=0,gt=d.interpolate||Tr,vt="__p += '",pt=Ro((d.escape||Tr).source+"|"+gt.source+"|"+(gt===Pc?Lv:Tr).source+"|"+(d.evaluate||Tr).source+"|$","g"),_t="//# sourceURL="+(Xt.call(d,"sourceURL")?(d.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++l0+"]")+`
- `;c.replace(pt,function(Tt,Nt,Ht,Ye,Le,Ke){return Ht||(Ht=Ye),vt+=c.slice(dt,Ke).replace(zv,R0),Nt&&(J=!0,vt+=`' +
- __e(`+Nt+`) +
- '`),Le&&(nt=!0,vt+=`';
- `+Le+`;
- __p += '`),Ht&&(vt+=`' +
- ((__t = (`+Ht+`)) == null ? '' : __t) +
- '`),dt=Ke+Tt.length,Tt}),vt+=`';
- `;var Ct=Xt.call(d,"variable")&&d.variable;if(!Ct)vt=`with (obj) {
- `+vt+`
- }
- `;else if(Pv.test(Ct))throw new St(o);vt=(nt?vt.replace(gv,""):vt).replace(vv,"$1").replace(yv,"$1;"),vt="function("+(Ct||"obj")+`) {
- `+(Ct?"":`obj || (obj = {});
- `)+"var __t, __p = ''"+(J?", __e = _.escape":"")+(nt?`, __j = Array.prototype.join;
- function print() { __p += __j.call(arguments, '') }
- `:`;
- `)+vt+`return __p
- }`;var Mt=tf(function(){return qt(z,_t+"return "+vt).apply(i,q)});if(Mt.source=vt,ul(Mt))throw Mt;return Mt}function t1(c){return Kt(c).toLowerCase()}function e1(c){return Kt(c).toUpperCase()}function i1(c,d,m){if(c=Kt(c),c&&(m||d===i))return ch(c);if(!c||!(d=$e(d)))return c;var A=di(c),M=di(d),z=hh(A,M),q=uh(A,M)+1;return as(A,z,q).join("")}function s1(c,d,m){if(c=Kt(c),c&&(m||d===i))return c.slice(0,dh(c)+1);if(!c||!(d=$e(d)))return c;var A=di(c),M=uh(A,di(d))+1;return as(A,0,M).join("")}function n1(c,d,m){if(c=Kt(c),c&&(m||d===i))return c.replace(ho,"");if(!c||!(d=$e(d)))return c;var A=di(c),M=hh(A,di(d));return as(A,M).join("")}function r1(c,d){var m=tt,A=T;if(oe(d)){var M="separator"in d?d.separator:M;m="length"in d?Dt(d.length):m,A="omission"in d?$e(d.omission):A}c=Kt(c);var z=c.length;if(Qs(c)){var q=di(c);z=q.length}if(m>=z)return c;var J=m-tn(A);if(J<1)return A;var nt=q?as(q,0,J).join(""):c.slice(0,J);if(M===i)return nt+A;if(q&&(J+=nt.length-J),fl(M)){if(c.slice(J).search(M)){var dt,gt=nt;for(M.global||(M=Ro(M.source,Kt(Ic.exec(M))+"g")),M.lastIndex=0;dt=M.exec(gt);)var vt=dt.index;nt=nt.slice(0,vt===i?J:vt)}}else if(c.indexOf($e(M),J)!=J){var pt=nt.lastIndexOf(M);pt>-1&&(nt=nt.slice(0,pt))}return nt+A}function a1(c){return c=Kt(c),c&&mv.test(c)?c.replace(Rc,B0):c}var o1=ln(function(c,d,m){return c+(m?" ":"")+d.toUpperCase()}),vl=eu("toUpperCase");function Qu(c,d,m){return c=Kt(c),d=m?i:d,d===i?P0(c)?F0(c):x0(c):c.match(d)||[]}var tf=Bt(function(c,d){try{return Ve(c,i,d)}catch(m){return ul(m)?m:new St(m)}}),l1=Oi(function(c,d){return ii(d,function(m){m=Ei(m),Mi(c,m,cl(c[m],c))}),c});function c1(c){var d=c==null?0:c.length,m=Et();return c=d?ne(c,function(A){if(typeof A[1]!="function")throw new si(a);return[m(A[0]),A[1]]}):[],Bt(function(A){for(var M=-1;++M<d;){var z=c[M];if(Ve(z[0],this,A))return Ve(z[1],this,A)}})}function h1(c){return By(ri(c,f))}function yl(c){return function(){return c}}function u1(c,d){return c==null||c!==c?d:c}var f1=su(),d1=su(!0);function Fe(c){return c}function ml(c){return Dh(typeof c=="function"?c:ri(c,f))}function g1(c){return Bh(ri(c,f))}function v1(c,d){return Oh(c,ri(d,f))}var y1=Bt(function(c,d){return function(m){return Vn(m,c,d)}}),m1=Bt(function(c,d){return function(m){return Vn(c,m,d)}});function pl(c,d,m){var A=pe(d),M=Xr(d,A);m==null&&!(oe(d)&&(M.length||!A.length))&&(m=d,d=c,c=this,M=Xr(d,pe(d)));var z=!(oe(m)&&"chain"in m)||!!m.chain,q=Fi(c);return ii(M,function(J){var nt=d[J];c[J]=nt,q&&(c.prototype[J]=function(){var dt=this.__chain__;if(z||dt){var gt=c(this.__wrapped__),vt=gt.__actions__=Be(this.__actions__);return vt.push({func:nt,args:arguments,thisArg:c}),gt.__chain__=dt,gt}return nt.apply(c,ts([this.value()],arguments))})}),c}function p1(){return _e._===this&&(_e._=j0),this}function wl(){}function w1(c){return c=Dt(c),Bt(function(d){return Nh(d,c)})}var b1=Go(ne),x1=Go(nh),_1=Go(xo);function ef(c){return sl(c)?_o(Ei(c)):Jy(c)}function k1(c){return function(d){return c==null?i:Cs(c,d)}}var E1=ru(),A1=ru(!0);function bl(){return[]}function xl(){return!1}function C1(){return{}}function T1(){return""}function R1(){return!0}function S1(c,d){if(c=Dt(c),c<1||c>$)return[];var m=K,A=Re(c,K);d=Et(d),c-=K;for(var M=Ao(A,d);++m<c;)d(m);return M}function P1(c){return Pt(c)?ne(c,Ei):qe(c)?[c]:Be(xu(Kt(c)))}function I1(c){var d=++U0;return Kt(c)+d}var L1=ea(function(c,d){return c+d},0),D1=Zo("ceil"),M1=ea(function(c,d){return c/d},1),B1=Zo("floor");function O1(c){return c&&c.length?Kr(c,Fe,Oo):i}function N1(c,d){return c&&c.length?Kr(c,Et(d,2),Oo):i}function F1(c){return oh(c,Fe)}function z1(c,d){return oh(c,Et(d,2))}function H1(c){return c&&c.length?Kr(c,Fe,Ho):i}function W1(c,d){return c&&c.length?Kr(c,Et(d,2),Ho):i}var U1=ea(function(c,d){return c*d},1),V1=Zo("round"),j1=ea(function(c,d){return c-d},0);function $1(c){return c&&c.length?Eo(c,Fe):0}function q1(c,d){return c&&c.length?Eo(c,Et(d,2)):0}return N.after=gw,N.ary=Lu,N.assign=eb,N.assignIn=qu,N.assignInWith=ga,N.assignWith=ib,N.at=sb,N.before=Du,N.bind=cl,N.bindAll=l1,N.bindKey=Mu,N.castArray=Cw,N.chain=Su,N.chunk=Bm,N.compact=Om,N.concat=Nm,N.cond=c1,N.conforms=h1,N.constant=yl,N.countBy=$p,N.create=nb,N.curry=Bu,N.curryRight=Ou,N.debounce=Nu,N.defaults=rb,N.defaultsDeep=ab,N.defer=vw,N.delay=yw,N.difference=Fm,N.differenceBy=zm,N.differenceWith=Hm,N.drop=Wm,N.dropRight=Um,N.dropRightWhile=Vm,N.dropWhile=jm,N.fill=$m,N.filter=Yp,N.flatMap=Gp,N.flatMapDeep=Zp,N.flatMapDepth=Jp,N.flatten=Au,N.flattenDeep=qm,N.flattenDepth=Ym,N.flip=mw,N.flow=f1,N.flowRight=d1,N.fromPairs=Km,N.functions=db,N.functionsIn=gb,N.groupBy=Qp,N.initial=Gm,N.intersection=Zm,N.intersectionBy=Jm,N.intersectionWith=Qm,N.invert=yb,N.invertBy=mb,N.invokeMap=ew,N.iteratee=ml,N.keyBy=iw,N.keys=pe,N.keysIn=Ne,N.map=la,N.mapKeys=wb,N.mapValues=bb,N.matches=g1,N.matchesProperty=v1,N.memoize=ha,N.merge=xb,N.mergeWith=Yu,N.method=y1,N.methodOf=m1,N.mixin=pl,N.negate=ua,N.nthArg=w1,N.omit=_b,N.omitBy=kb,N.once=pw,N.orderBy=sw,N.over=b1,N.overArgs=ww,N.overEvery=x1,N.overSome=_1,N.partial=hl,N.partialRight=Fu,N.partition=nw,N.pick=Eb,N.pickBy=Ku,N.property=ef,N.propertyOf=k1,N.pull=sp,N.pullAll=Tu,N.pullAllBy=np,N.pullAllWith=rp,N.pullAt=ap,N.range=E1,N.rangeRight=A1,N.rearg=bw,N.reject=ow,N.remove=op,N.rest=xw,N.reverse=ol,N.sampleSize=cw,N.set=Cb,N.setWith=Tb,N.shuffle=hw,N.slice=lp,N.sortBy=dw,N.sortedUniq=vp,N.sortedUniqBy=yp,N.split=Gb,N.spread=_w,N.tail=mp,N.take=pp,N.takeRight=wp,N.takeRightWhile=bp,N.takeWhile=xp,N.tap=Op,N.throttle=kw,N.thru=oa,N.toArray=Vu,N.toPairs=Xu,N.toPairsIn=Gu,N.toPath=P1,N.toPlainObject=$u,N.transform=Rb,N.unary=Ew,N.union=_p,N.unionBy=kp,N.unionWith=Ep,N.uniq=Ap,N.uniqBy=Cp,N.uniqWith=Tp,N.unset=Sb,N.unzip=ll,N.unzipWith=Ru,N.update=Pb,N.updateWith=Ib,N.values=un,N.valuesIn=Lb,N.without=Rp,N.words=Qu,N.wrap=Aw,N.xor=Sp,N.xorBy=Pp,N.xorWith=Ip,N.zip=Lp,N.zipObject=Dp,N.zipObjectDeep=Mp,N.zipWith=Bp,N.entries=Xu,N.entriesIn=Gu,N.extend=qu,N.extendWith=ga,pl(N,N),N.add=L1,N.attempt=tf,N.camelCase=Ob,N.capitalize=Zu,N.ceil=D1,N.clamp=Db,N.clone=Tw,N.cloneDeep=Sw,N.cloneDeepWith=Pw,N.cloneWith=Rw,N.conformsTo=Iw,N.deburr=Ju,N.defaultTo=u1,N.divide=M1,N.endsWith=Nb,N.eq=vi,N.escape=Fb,N.escapeRegExp=zb,N.every=qp,N.find=Kp,N.findIndex=ku,N.findKey=ob,N.findLast=Xp,N.findLastIndex=Eu,N.findLastKey=lb,N.floor=B1,N.forEach=Pu,N.forEachRight=Iu,N.forIn=cb,N.forInRight=hb,N.forOwn=ub,N.forOwnRight=fb,N.get=dl,N.gt=Lw,N.gte=Dw,N.has=vb,N.hasIn=gl,N.head=Cu,N.identity=Fe,N.includes=tw,N.indexOf=Xm,N.inRange=Mb,N.invoke=pb,N.isArguments=Ss,N.isArray=Pt,N.isArrayBuffer=Mw,N.isArrayLike=Oe,N.isArrayLikeObject=ue,N.isBoolean=Bw,N.isBuffer=os,N.isDate=Ow,N.isElement=Nw,N.isEmpty=Fw,N.isEqual=zw,N.isEqualWith=Hw,N.isError=ul,N.isFinite=Ww,N.isFunction=Fi,N.isInteger=zu,N.isLength=fa,N.isMap=Hu,N.isMatch=Uw,N.isMatchWith=Vw,N.isNaN=jw,N.isNative=$w,N.isNil=Yw,N.isNull=qw,N.isNumber=Wu,N.isObject=oe,N.isObjectLike=ce,N.isPlainObject=Xn,N.isRegExp=fl,N.isSafeInteger=Kw,N.isSet=Uu,N.isString=da,N.isSymbol=qe,N.isTypedArray=hn,N.isUndefined=Xw,N.isWeakMap=Gw,N.isWeakSet=Zw,N.join=tp,N.kebabCase=Hb,N.last=oi,N.lastIndexOf=ep,N.lowerCase=Wb,N.lowerFirst=Ub,N.lt=Jw,N.lte=Qw,N.max=O1,N.maxBy=N1,N.mean=F1,N.meanBy=z1,N.min=H1,N.minBy=W1,N.stubArray=bl,N.stubFalse=xl,N.stubObject=C1,N.stubString=T1,N.stubTrue=R1,N.multiply=U1,N.nth=ip,N.noConflict=p1,N.noop=wl,N.now=ca,N.pad=Vb,N.padEnd=jb,N.padStart=$b,N.parseInt=qb,N.random=Bb,N.reduce=rw,N.reduceRight=aw,N.repeat=Yb,N.replace=Kb,N.result=Ab,N.round=V1,N.runInContext=it,N.sample=lw,N.size=uw,N.snakeCase=Xb,N.some=fw,N.sortedIndex=cp,N.sortedIndexBy=hp,N.sortedIndexOf=up,N.sortedLastIndex=fp,N.sortedLastIndexBy=dp,N.sortedLastIndexOf=gp,N.startCase=Zb,N.startsWith=Jb,N.subtract=j1,N.sum=$1,N.sumBy=q1,N.template=Qb,N.times=S1,N.toFinite=zi,N.toInteger=Dt,N.toLength=ju,N.toLower=t1,N.toNumber=li,N.toSafeInteger=tb,N.toString=Kt,N.toUpper=e1,N.trim=i1,N.trimEnd=s1,N.trimStart=n1,N.truncate=r1,N.unescape=a1,N.uniqueId=I1,N.upperCase=o1,N.upperFirst=vl,N.each=Pu,N.eachRight=Iu,N.first=Cu,pl(N,function(){var c={};return _i(N,function(d,m){Xt.call(N.prototype,m)||(c[m]=d)}),c}(),{chain:!1}),N.VERSION=s,ii(["bind","bindKey","curry","curryRight","partial","partialRight"],function(c){N[c].placeholder=N}),ii(["drop","take"],function(c,d){Ft.prototype[c]=function(m){m=m===i?1:ye(Dt(m),0);var A=this.__filtered__&&!d?new Ft(this):this.clone();return A.__filtered__?A.__takeCount__=Re(m,A.__takeCount__):A.__views__.push({size:Re(m,K),type:c+(A.__dir__<0?"Right":"")}),A},Ft.prototype[c+"Right"]=function(m){return this.reverse()[c](m).reverse()}}),ii(["filter","map","takeWhile"],function(c,d){var m=d+1,A=m==O||m==Z;Ft.prototype[c]=function(M){var z=this.clone();return z.__iteratees__.push({iteratee:Et(M,3),type:m}),z.__filtered__=z.__filtered__||A,z}}),ii(["head","last"],function(c,d){var m="take"+(d?"Right":"");Ft.prototype[c]=function(){return this[m](1).value()[0]}}),ii(["initial","tail"],function(c,d){var m="drop"+(d?"":"Right");Ft.prototype[c]=function(){return this.__filtered__?new Ft(this):this[m](1)}}),Ft.prototype.compact=function(){return this.filter(Fe)},Ft.prototype.find=function(c){return this.filter(c).head()},Ft.prototype.findLast=function(c){return this.reverse().find(c)},Ft.prototype.invokeMap=Bt(function(c,d){return typeof c=="function"?new Ft(this):this.map(function(m){return Vn(m,c,d)})}),Ft.prototype.reject=function(c){return this.filter(ua(Et(c)))},Ft.prototype.slice=function(c,d){c=Dt(c);var m=this;return m.__filtered__&&(c>0||d<0)?new Ft(m):(c<0?m=m.takeRight(-c):c&&(m=m.drop(c)),d!==i&&(d=Dt(d),m=d<0?m.dropRight(-d):m.take(d-c)),m)},Ft.prototype.takeRightWhile=function(c){return this.reverse().takeWhile(c).reverse()},Ft.prototype.toArray=function(){return this.take(K)},_i(Ft.prototype,function(c,d){var m=/^(?:filter|find|map|reject)|While$/.test(d),A=/^(?:head|last)$/.test(d),M=N[A?"take"+(d=="last"?"Right":""):d],z=A||/^find/.test(d);!M||(N.prototype[d]=function(){var q=this.__wrapped__,J=A?[1]:arguments,nt=q instanceof Ft,dt=J[0],gt=nt||Pt(q),vt=function(Nt){var Ht=M.apply(N,ts([Nt],J));return A&&pt?Ht[0]:Ht};gt&&m&&typeof dt=="function"&&dt.length!=1&&(nt=gt=!1);var pt=this.__chain__,_t=!!this.__actions__.length,Ct=z&&!pt,Mt=nt&&!_t;if(!z&>){q=Mt?q:new Ft(this);var Tt=c.apply(q,J);return Tt.__actions__.push({func:oa,args:[vt],thisArg:i}),new ni(Tt,pt)}return Ct&&Mt?c.apply(this,J):(Tt=this.thru(vt),Ct?A?Tt.value()[0]:Tt.value():Tt)})}),ii(["pop","push","shift","sort","splice","unshift"],function(c){var d=Dr[c],m=/^(?:push|sort|unshift)$/.test(c)?"tap":"thru",A=/^(?:pop|shift)$/.test(c);N.prototype[c]=function(){var M=arguments;if(A&&!this.__chain__){var z=this.value();return d.apply(Pt(z)?z:[],M)}return this[m](function(q){return d.apply(Pt(q)?q:[],M)})}}),_i(Ft.prototype,function(c,d){var m=N[d];if(m){var A=m.name+"";Xt.call(rn,A)||(rn[A]=[]),rn[A].push({name:d,func:m})}}),rn[ta(i,_).name]=[{name:"wrapper",func:i}],Ft.prototype.clone=ay,Ft.prototype.reverse=oy,Ft.prototype.value=ly,N.prototype.at=Np,N.prototype.chain=Fp,N.prototype.commit=zp,N.prototype.next=Hp,N.prototype.plant=Up,N.prototype.reverse=Vp,N.prototype.toJSON=N.prototype.valueOf=N.prototype.value=jp,N.prototype.first=N.prototype.head,On&&(N.prototype[On]=Wp),N},en=z0();xs?((xs.exports=en)._=en,mo._=en):_e._=en}).call(De)})(hc,hc.exports);const dT=hc.exports;export{lk as M,dT as _,KC as a,GC as b,ZC as c,JC as d,iT as e,YC as f,XC as g,tT as h,sT as i,nT as j,rT as k,uT as l,cT as m,oT as n,lT as o,fT as p,hT as q,QC as r,eT as s,aT as t};
|