123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125 |
- var ex=Object.defineProperty;var ix=(e,t,i)=>t in e?ex(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i;var W=(e,t,i)=>(ix(e,typeof t!="symbol"?t+"":t,i),i);import{P as De}from"./index.51881bf4.js";function Fs(e,t){const i=t||new Path2D;if(e.name==="combine"&&!e.draw)return i instanceof Path2D?i:void 0;e.setTheme||(e.setTheme=sx);let s=e.calculative.borderRadius||0,n=s;const{x:a,y:r,width:l,height:o,ex:u,ey:c}=e.calculative.worldRect;s<1&&(s=l*s,n=o*n);let f=s<n?s:n;if(l<2*f&&(f=l/2),o<2*f&&(f=o/2),i.moveTo(a+f,r),i.arcTo(u,r,u,c,f),i.arcTo(u,c,a,c,f),i.arcTo(a,c,a,r,f),i.arcTo(a,r,u,r,f),i.closePath(),i instanceof Path2D)return i}function sx(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 nx=Fs;function ax(e,t){const i=t||new Path2D,{x:s,y:n,width:a,height:r}=e.calculative.worldRect;if(i.ellipse(s+a/2,n+r/2,a/2,r/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 cf;(function(e){e[e.Default=0]="Default",e[e.In=1]="In",e[e.Out=2]="Out"})(cf||(cf={}));var Sn;(function(e){e[e.None=0]="None",e[e.Linear=1]="Linear",e[e.Radial=2]="Radial"})(Sn||(Sn={}));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 rx=["text","textWidth","textHeight","textLeft","textTop","fontFamily","fontSize","lineHeight","fontStyle","fontWeight","textAlign","textBaseline","whiteSpace","ellipsis","keepDecimal"],ox=["x","y","width","height","flipX","flipY"],lx=["paddingTop","paddingRight","paddingBottom","paddingLeft","flipX","flipY","visible","showChild"],cx=["iconLeft","iconTop","iconRotate"],Bd=["globalAlpha","flipY","flipX","x","y","width","height","iconWidth","iconHeight","imageRatio","iconLeft","iconTop","iconAlign","rotate","visible"];var We;(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",e[e.Custom=5]="Custom"})(We||(We={}));var wn;(function(e){e[e.Image=0]="Image",e[e.Icon=1]="Icon",e[e.Pen=2]="Pen",e[e.Element=3]="Element"})(wn||(wn={}));const Od=["gif","iframe","video","echarts","highcharts","lightningCharts","vue"],Cl=["radio","checkbox","button","inputDom","slider","echarts"],Zn=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","shadow","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","toArrow","fromArrow","lineName","textType","textGradientColors"]),Rl={textType:0,bkType:0,strokeType:0};function hx(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 $i;(function(e){e[e.None=0]="None",e[e.Down=1]="Down",e[e.Translate=2]="Translate"})($i||($i={}));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 hf=["nw-resize","ne-resize","se-resize","sw-resize"],uf=["n-resize","e-resize","s-resize","w-resize"],ux=["curve","polyline","line"],Fd=["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 Ns;(function(e){e[e.Mirror=0]="Mirror",e[e.Bilateral=1]="Bilateral",e[e.Free=2]="Free"})(Ns||(Ns={}));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,a=(e.x-i.x)*Math.sin(s)+(e.y-i.y)*Math.cos(s)+i.y;e.x=n,e.y=a,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 a=t.rotate+n;return s.flipX&&(a*=-1),s.flipY&&(a*=-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:a})}else return e.x>t.x-i&&e.x<t.x+i&&e.y>t.y-i&&e.y<t.y+i}function Hr(e,t,i){e.x=i.x-(i.x-e.x)*t,e.y=i.y-(i.y-e.y)*t}function ui(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 Qr(e,t){const i=e.x-t.x,s=e.y-t.y;return Math.sqrt(i*i+s*s)}function fx(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 aa(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 ff(e,t){return e.anchorId===t.anchorId&&e.connectTo===t.connectTo}function yr(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 dx="@meta2d/core",gx="1.0.86",vx="@meta2d/core: Powerful, Beautiful, Simple, Open - Web-Based 2D At Its Best .",yx="index.js",mx="index.d.ts",px={copy:"copyfiles package.json ../../dist/core/",build:"tsc && npm run copy"},bx=["meta2d","diagram","2D","canvas"],xx="alsmile123@qq.com",_x="MIT",kx={type:"git",url:"git+https://github.com/le5le-com/meta2d.js.git"},Ex={url:"https://github.com/le5le-com/meta2d.js/issues"},Ax="https://github.com/le5le-com/meta2d.js#readme",Cx={"@types/marked":"^4.0.3","@types/offscreencanvas":"latest","@types/zrender":"^4.0.0"},Rx={mitt:"^2.1.0",mqtt:"^4.2.6"},Tx={access:"public"},Sx="78f2a53ca1839c89b56e2e498d17ba4eb987ad14",Nd={name:dx,version:gx,description:vx,main:yx,types:mx,scripts:px,keywords:bx,author:xx,license:_x,repository:kx,bugs:Ex,homepage:Ax,devDependencies:Cx,dependencies:Rx,publishConfig:Tx,gitHead:Sx},kt={version:Nd.version,path2dDraws:{},canvasDraws:{},anchors:{},lineAnimateDraws:{},htmlElements:{}};function zd(e){Object.assign(kt.path2dDraws,e)}function Px(e){Object.assign(kt.canvasDraws,e)}function Ix(e){Object.assign(kt.anchors,e)}function Lx(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 Dx={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},Mx=["color","hoverColor","activeColor","disabledColor","background","activeBackground","hoverBackground","disabledBackground","anchorColor","hoverAnchorColor","anchorBackground","animateColor","textColor","ruleColor","ruleLineColor","gridColor","lineColor","penBackground","dockPenColor"],Bx={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"}}},ta={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),a=`${this.cssRuleSelector} { ${n.join(";")} }`;i.innerHTML=a},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[a,r]=n.split(t);return s[a]=r,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 a=!1;for(let r=0;r<n.cssRules.length;r++)if(n.cssRules[r].selectorText===this.cssRuleSelector){a=!0;break}if(a)for(let r=0;r<n.cssRules.length;r++){const l=n.cssRules[r];if(l.selectorText===this.cssRuleSelector)if(n.insertRule){n.deleteRule(r);const o=`${this.cssRuleSelector} { ${s.join(";")} }`;n.insertRule(o,r)}else n.addRule&&(l.style.cssText=s.join(";"))}else if(n.insertRule){const r=`${this.cssRuleSelector} { ${s.join(";")} }`;n.insertRule(r,n.cssRules.length)}else if(n.addRule){const r=n.cssRules.find(l=>l.selectorText===this.cssRuleSelector);if(r){const l=s.join(";");r.style.cssText+=`; ${l}`}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 Ox=()=>({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:{...Dx},theme:{...Bx},emitter:Lx(),bindDatas:{},bind:{},pensNetwork:{},cacheDatas:[],messageEvents:{},templatePens:{},globalTriggers:{}}),Fx=(e="default")=>(kt[e]||(kt[e]=Ox(),kt[e].id=e),kt[e]),Nx=(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,lineAnimateDraws:{}},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 Ri(e){const{paddingTop:t,paddingBottom:i,paddingLeft:s,paddingRight:n,worldRect:a,canvas:r}=e.calculative;let{textLeft:l,textTop:o,textWidth:u,textHeight:c}=e.calculative,f=s,g=t;const v=a.width-s-n,y=a.height-t-i;u&&u<1&&(u*=a.width),c&&c<1&&(c*=a.height),u<e.calculative.fontSize&&(u=e.calculative.fontSize),f+=(l||0)+a.x,g+=(o||0)+a.y;const w=e.textAlign||r.store.options.textAlign,m=e.textBaseline||r.store.options.textBaseline;switch(w){case"center":f+=(v-(u||v))/2;break;case"right":f+=v-(u||v);break}switch(m){case"middle":g+=(y-(c||y))/2;break;case"bottom":g+=y-(c||y);break}const _={x:f,y:g,width:u||v,height:c||y};re(_),e.calculative.worldTextRect=_,_a(e),e.calculative.textDrawRect=void 0}function vc(e,t){const i=t.calculative.fontSize*t.calculative.lineHeight,s=t.calculative.textLines.length*i,n=zx(e,t),a=t.calculative.worldTextRect;let r=a.x+(a.width-n)/2,l=a.y+(a.height-s)/2;const o=t.calculative.canvas.store.options;switch(t.textAlign||o.textAlign){case"left":r=a.x;break;case"right":r=a.x+a.width-n;break}switch(t.textBaseline||o.textBaseline){case"top":l=a.y;break;case"bottom":l=a.ey-s;break}t.calculative.textDrawRect={x:r,y:l,width:n,height:s},re(t.calculative.textDrawRect)}function _a(e,t=e.calculative.text){if(t==null){e.calculative.textLines=[];return}t=t.toString();const i=e.calculative.keepDecimal;if(i!=null){const o=Number(t);isNaN(o)||(t=o.toFixed(i))}let s=[];const n=e.calculative.fontSize*e.calculative.lineHeight,a=e.calculative.worldTextRect.height,r=Math.floor(a/n),l=r>1?r:1;switch(e.whiteSpace){case"nowrap":if(e.ellipsis!==!1){const c=df(t.split(""),e);c[0]&&(s.push(c[0]),c.length>1&&Tl(s))}else s.push(t);break;case"pre-line":s=t.split(/[\n]/g),e.ellipsis!==!1&&s.length>l&&(s=s.slice(0,l),Tl(s));break;case"break-all":default:const o=t.split(/[\n]/g);let u=0;t:for(const c of o){const f=e.whiteSpace==="break-all"?c.split(""):Hd(c);let g=df(f,e);if(g.length===0&&(g=[""]),e.ellipsis!=!1)for(const v of g)if(u++,u>l){Tl(s);break t}else s.push(v);else s.push(...g)}break}return e.calculative.textLines=s,s}function Hd(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 df(e,t){const i=t.calculative.canvas,s=i.offscreen.getContext("2d"),{fontStyle:n,fontWeight:a,fontSize:r,fontFamily:l,lineHeight:o}=t.calculative;s.save();const u=[];let c=e[0]||"";for(let f=1;f<e.length;++f){const g=e[f]||"",v=c+g;let y=0;if(i.store.options.measureTextWidth)s.font=Be({fontStyle:n,fontWeight:a,fontFamily:l||i.store.options.fontFamily,fontSize:r,lineHeight:o}),y=s.measureText(v).width;else{const m=v.match(/[^\x00-\xff]/g)||"",_=m.length*r,E=v.match(/\s/g)||"",x=E.length*r*.3,C=(v.length-m.length-E.length)*r*.6;y=_+x+C}const w=t.calculative.worldTextRect.width;y<=w+.1?c+=g:(c.length&&u.push(c),c=g)}return c.length&&u.push(c),s.restore(),u}function zx(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 Tl(e){e[e.length-1]=e[e.length-1].slice(0,-3)+"..."}function Hx(e){let t=e.text.split(`
- `);const i=e.calculative.canvas,s=i.offscreen.getContext("2d"),{fontStyle:n,fontWeight:a,fontSize:r,fontFamily:l,lineHeight:o}=e.calculative;let u=0,c=0;s.save();for(let g=0;g<t.length;g++){if(i.store.options.measureTextWidth)s.font=Be({fontStyle:n,fontWeight:a,fontFamily:l||i.store.options.fontFamily,fontSize:r,lineHeight:o}),c=s.measureText(t[g]).width;else{const v=t[g].match(/[^\x00-\xff]/g)||"",y=v.length*r,w=t[g].match(/\s/g)||"",m=w.length*r*.3,_=(t[g].length-v.length-w.length)*r*.6;c=y+m+_}c>u&&(u=c)}s.restore();let f=t.length*r*o;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+5,e.width=u+5,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","socketFn"].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 Xl(e,t,i){if(Array.isArray(e)){const s=[];return e.forEach(n=>{s.push(Xl(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,a)=>{Number.isNaN(Number(n))||(e[s][a]=Number(n*i))});else{if(Number.isNaN(Number(e[s])))continue;e[s]=Number(e[s])*i}else e[s]=Xl(e[s],t,i);return e}return e}const Ve={};function Wd(e,t,i){if(!Ve[t.fromArrow])return;const s=le(t),{x:n,y:a}=s,r={x:n,y:a};if(r.step=(t.fromArrowSize||10)*i.data.scale,s.next)r.rotate=ui(s.next,s)+90;else{const o=t.calculative.worldAnchors[1];if(!o)return;o.prev?r.rotate=ui(o.prev,s)+90:r.rotate=ui(o,s)+90}e.save(),e.beginPath(),e.setLineDash([]);const l=t.fromArrowColor||t.calculative.color;l&&(e.strokeStyle=l),Ve[t.fromArrow](e,t,i,r),e.restore()}function Ud(e,t,i){if(!Ve[t.toArrow]||t.calculative.worldAnchors.length<2)return;e.save();const s=$t(t),{x:n,y:a}=s,r={x:n,y:a};if(r.step=(t.toArrowSize||10)*i.data.scale,s.prev)r.rotate=ui(s.prev,s)+90;else{const o=t.calculative.worldAnchors[t.calculative.worldAnchors.length-2];o.next?r.rotate=ui(o.next,s)+90:r.rotate=ui(o,s)+90}e.beginPath(),e.setLineDash([]);const l=t.toArrowColor||t.calculative.color;l&&(e.strokeStyle=l),Ve[t.toArrow](e,t,i,r),e.restore()}Ve.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()};Ve.reTriangleSolid=(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/2;e.moveTo(s.x,s.y-s.step/2),e.lineTo(n,s.y),e.lineTo(s.x,s.y+s.step/2),e.closePath(),e.stroke(),e.fillStyle=e.strokeStyle,e.fill(),e.restore()};Ve.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()};Ve.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()};Ve.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()};Ve.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,a=s.step/2;e.moveTo(n,s.y),e.lineTo(n+a,s.y-a/2),e.lineTo(s.x,s.y),e.lineTo(n+a,s.y+a/2),e.closePath(),e.stroke(),e.fillStyle=e.strokeStyle,e.fill(),e.restore()};Ve.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,a=s.step/2;e.moveTo(n,s.y),e.lineTo(n+a,s.y-a/2),e.lineTo(s.x,s.y),e.lineTo(n+a,s.y+a/2),e.closePath(),e.stroke(),e.fillStyle=i.data.background||"#ffffff",e.fill(),e.restore()};Ve.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()};Ve.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()};Ve.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 Gl(e){const t=parseInt,i=Math.round;let s=e.length,n={};if(s>9){const[a,r,l,o]=e=e.split(",");if(s=e.length,s<3||s>4)return null;n.r=t(a[3]=="a"?a.slice(5):a.slice(4)),n.g=t(r),n.b=t(l),n.a=o?parseFloat(o):-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,a,r,l,o,u,c,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||(c=t.length>9,c=g?i.length>9?!0:i=="c"?!c:!1:c,o=Gl(t),l=e<0,u=i&&i!="c"?Gl(i):l?{r:0,g:0,b:0,a:-1}:{r:255,g:255,b:255,a:-1},e=l?e*-1:e,l=1-e,!o||!u)?null:(s?(n=f(l*o.r+e*u.r),a=f(l*o.g+e*u.g),r=f(l*o.b+e*u.b)):(n=f((l*o.r**2+e*u.r**2)**.5),a=f((l*o.g**2+e*u.g**2)**.5),r=f((l*o.b**2+e*u.b**2)**.5)),g=o.a,u=u.a,o=g>=0||u>=0,g=o?g<0?u:u<0?g:g*l+u*e:0,c?"rgb"+(o?"a(":"(")+n+","+a+","+r+(o?","+f(g*1e3)/1e3:"")+")":"#"+(4294967296+n*16777216+a*65536+r*256+(o?f(g*255):0)).toString(16).slice(1,o?void 0:-2))}globalThis.pSBC=Ae;function Wr(e,t){const i=Gl(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[a,r]=[+n[0],+n[1]];if(a>=r){console.warn("startNum must less than endNum");return}return e>a||i==="["&&e===a?e<r||s==="]"&&e===r:!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 a of n)if(a.includes("..")){const[r,l]=a.split(".."),[o,u]=[+r,+l];if(o>=u){console.warn("startNum must less than endNum");return}if(e>=o&&e<=u)return!0}else if(e==a)return!0;return!1}function Wx(e,t,i){const s=1-e;return 3*s*s*e*t+3*s*e*e*i+e*e*e}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=Sl(e[1])?e[0]:e[1],n=Sl(e[2])?e[0]:e[2],i=Sl(e[3])?s:e[3]),[t,s,n,i]};function Sl(e){return e==null}async function Ux(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 $x(e,t,i,s){const n=new FormData;if(n.append("file",e),i)for(const r in i)i.hasOwnProperty(r)&&n.append(r,i[r]);return(await(await fetch(t,{method:"POST",headers:s,body:n})).json()).url}function jx(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 bn(e){let t=e||window.location.search.split("?")[1];const i=new URLSearchParams(t);return Object.fromEntries(i.entries())}function ga(e){let t;const i=new RegExp("(^| )"+e+"=([^;]*)(;|$)");return(t=document.cookie.match(i))?decodeURIComponent(t[2]):""}var Ur;(function(e){e[e.None=0]="None",e[e.LocalStorage=1]="LocalStorage",e[e.Cookie=2]="Cookie"})(Ur||(Ur={}));const Vx=location.host.indexOf("le5le.com")!==-1;function Ir(){var t;const e=(t=globalThis.le5leTokenName)!=null?t:"token";switch(globalThis.le5leTokenType){case Ur.LocalStorage:return localStorage.getItem(e);case Ur.Cookie:return ga(e);default:return Vx?ga(e):localStorage.getItem(e)}}async function $d(e,t){var o,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`,a=((o=bn())==null?void 0:o.id)||n.includes("${id}");if(!a&&((u=bn())==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 r=(i==null?void 0:i.method)||"POST";a||(r="GET");const l=await fetch(n,{headers:{Authorization:`Bearer ${Ir()}`},method:r,body:r==="GET"?void 0:JSON.stringify({id:t})});if(l.ok){let c=await l.text();return c.constructor===Object||c.constructor===Array?c=JSON.parse(JSON.stringify(c)):typeof c=="string"&&(c=JSON.parse(c)),c.data&&(c=c.data),c}else e.emitter.emit("error",{type:"http",error:l})}function ms(e,t){if(t==null)return e;const i=t.split(".");for(;i.length&&(e=e[i.shift()]););return e}function $r(e,t,i){t!=null&&t.split(".").reduce((s,n,a)=>s[n]=t.split(".").length===++a?i:s[n]||{},e)}function Zl(e,t){const i=["\u5929","\u4E00","\u4E8C","\u4E09","\u56DB","\u4E94","\u516D"];let s=new Date;t&&(s=new Date(t));const n=s.getFullYear(),a=s.getMonth()+1,r=s.getDate(),l=s.getDay(),o=s.getHours(),u=s.getMinutes(),c=s.getSeconds();return new Function("year","month","day","week","hours","minutes","seconds",e?`return ${e}`:"return `${year}:${month}:${day} ${hours}:${minutes}:${seconds} \u661F\u671F${week}`")(n,a,r,i[l],o,u,c)}function qx(e,t){if(!e||!t)return!1;let i=ti(e);for(;i;){if(i.id===t.id)return!0;i=ti(i)}return!1}function ti(e,t){if(!e||!e.parentId||!e.calculative)return;const s=e.calculative.canvas.store.pens[e.parentId];return t&&ti(s,t)||s}function Qe(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(...Qe(n,t)))}),i}function yc(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(...yc(n,t)))}),i}function Yx(e,t){const{worldRect:i,gradientFromColor:s,gradientToColor:n,gradientAngle:a}=t.calculative;return Vd(e,i,s,n,a)}function Kx(e,t){const{worldRect:i,gradientFromColor:s,gradientToColor:n,gradientRadius:a}=t.calculative;if(!s||!n)return;const{width:r,height:l,center:o}=i,{x:u,y:c}=o;let f=r;f<l&&(f=l),f*=.5;const g=e.createRadialGradient(u,c,f*(a||0),u,c,f);return g.addColorStop(0,s),g.addColorStop(1,n),g}function Xx(e,t,i,s,n){let a=0;a=Math.PI/2-Math.atan2(s-t,i-e);const r=(e+i)/2,l=(t+s)/2,o=r+n*Math.sin(90*Math.PI/180-a),u=l+n*-Math.cos(90*Math.PI/180-a),c=r+n*Math.sin(270*Math.PI/180-a),f=l+n*-Math.cos(270*Math.PI/180-a);return[o,u,c,f]}function Gx(e,t){const{worldRect:i,gradientColors:s,gradientRadius:n}=t.calculative;if(!s)return;let a=t.calculative.gradientColors;t.calculative.checked&&(a=t.calculative.onGradientColors);const{width:r,height:l,center:o}=i,{x:u,y:c}=o;let f=r;f<l&&(f=l),f*=.5;const{colors:g}=Ys(a),v=e.createRadialGradient(u,c,f*(n||0),u,c,f);return g.forEach(y=>{v.addColorStop(y.i,y.color)}),v}function Zx(e,t){const{x:i,y:s,ex:n,width:a,height:r,center:l}=t.calculative.worldRect;let o=[{x:n,y:s+r/2},{x:i,y:s+r/2}],u=t.calculative.gradientColors;t.calculative.checked&&(u=t.calculative.onGradientColors);const{angle:c,colors:f}=Ys(u);let g=mc(c,a,r);return o.forEach(v=>{Gt(v,c,l)}),to(e,o,f,g)}function Jx(e,t){const{worldRect:i,textGradientColors:s}=t.calculative;if(!s)return;const{width:n,height:a,center:r}=i,{x:l,y:o}=r;let u=n;u<a&&(u=a),u*=.5;const{colors:c}=Ys(s),f=e.createRadialGradient(l,o,0,l,o,u);return c.forEach(g=>{f.addColorStop(g.i,g.color)}),f}function Qx(e,t){!t.calculative.textDrawRect&&vc(e,t),Qt(t.calculative.textDrawRect);const{x:i,y:s,ex:n,width:a,height:r,center:l}=t.calculative.textDrawRect;let o=[{x:n,y:s+r/2},{x:i,y:s+r/2}];const{angle:u,colors:c}=Ys(t.calculative.textGradientColors);let f=mc(u,a,r);return o.forEach(g=>{Gt(g,u,l)}),to(e,o,c,f)}function mc(e,t,i){const s=Math.atan(i/t)/Math.PI*180;let n=(e-90)%360,a=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),a=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),a=Math.abs(t/Math.cos(n/180*Math.PI)/2)),a}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 a=n.split(") ");s.push({color:t_(a[0]+")"),i:parseFloat(a[1])/100})}else{let a=n.split(" ");a.length>2?s.push({color:a[1],i:parseFloat(a[2])/100}):s.push({color:a[0],i:parseFloat(a[1])/100})}}),{angle:parseFloat(t[0]),colors:s}}else return{angle:parseFloat(t[0]),colors:[]}}else return{angle:0,colors:[]}}function t_(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 a=parseInt(s*255+"").toString(16);a=a.length===2?a:"0"+a,e+=a}e=e.toUpperCase()}return e}function e_(e,t){const{x:i,y:s,ex:n,width:a,height:r,center:l}=t.calculative.worldRect;let o=[{x:n,y:s+r/2},{x:i,y:s+r/2}];const{angle:u,colors:c}=Ys(t.calculative.lineGradientColors);let f=mc(u,a,r);return o.forEach(g=>{Gt(g,u,l)}),to(e,o,c,f)}function to(e,t,i,s){let n=Xx(t[0].x,t[0].y,t[1].x,t[1].y,s),a=e.createLinearGradient(n[0],n[1],n[2],n[3]);return i.forEach(r=>{a.addColorStop(r.i,r.color)}),a}function us(e,t,i){let s=[];t.calculative.gradientColorStop?s=t.calculative.gradientColorStop:(s=Ys(t.calculative.lineGradientColors).colors,t.calculative.gradientColorStop=s),e.strokeStyle=to(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 jd(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 l=i[n-1].curvePoints;l?mr(e,t,s,l[l.length-1],i[n],i[n].curvePoints[0]):mr(e,t,s,i[n-1],i[n],i[n].curvePoints[0]);let o=Ki(s,i[n],i[n].curvePoints[0]);us(e,t,[o,i[n].curvePoints[1]])}else us(e,t,[i[n],i[n].curvePoints[0]]),us(e,t,[i[n].curvePoints[0],i[n].curvePoints[1]]);let a=i[n].curvePoints.length-1;for(let l=1;l<a;l++)us(e,t,[i[n].curvePoints[l],i[n].curvePoints[l+1]]);let r=Ki(s,i[n+1],i[n].curvePoints[a]);us(e,t,[i[n].curvePoints[a],r])}else{let a=i[n],r=i[n+1];if(n>0&&n<i.length-1){let o=i[n-1].curvePoints;o?mr(e,t,s,o[o.length-1],i[n],i[n+1]):mr(e,t,s,i[n-1],i[n],i[n+1])}n>0&&n<i.length-1&&(a=Ki(s,i[n],i[n+1])),n<i.length-2&&(r=Ki(s,i[n+1],i[n]));let l=!1;if(n===0&&t.fromLineCap&&t.fromLineCap!=="butt"&&(e.save(),l=!0,e.lineCap=t.fromLineCap),n!==0&&n===i.length-2&&t.toLineCap&&t.toLineCap!=="butt"&&(e.save(),l=!0,e.lineCap=t.toLineCap),us(e,t,[a,r]),l&&e.restore(),i.length===2&&n===0){e.save(),l=!0,e.lineCap=t.toLineCap;let o=.1,u=.1;a.x-r.x===0?u=0:o=(a.y-r.y)/(a.x-r.x)*.1,us(e,t,[{x:r.x-u,y:r.y-o},r]),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 mr(e,t,i,s,n,a){let r=Ki(i,n,s),l=Ki(i,n,a),o={x:n.x,y:n.y},u=i_(t.calculative.canvas.store.data.smoothNum||20,r,o,l);for(let c=0;c<u.length-1;c++)us(e,t,[{x:u[c].x,y:u[c].y},{x:u[c+1].x,y:u[c+1].y}])}function gf(e,t,i,s){let n=Ki(t,i,s),a={x:i.x,y:i.y};e.quadraticCurveTo(a.x,a.y,n.x,n.y)}function pc(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 a=t[n+1];if(n==0&&s.moveTo(t[n].x,t[n].y),n>0&&n<t.length-1){let r=t[n-1].curvePoints;gf(s,i,t[n],t[n+1])}n>0&&n<t.length-1&&Ki(i,t[n],t[n+1]),n<t.length-2&&(a=Ki(i,t[n+1],t[n])),s.lineTo(a.x,a.y)}return s}function i_(e=100,t,i,s,n){let a=null;const r=[];!s&&!n?a=s_:s&&!n?a=n_:s&&n&&(a=a_);for(let l=0;l<e;l++)r.push(a(l/e,t,i,s,n));return n?r.push(n):s&&r.push(s),r}function s_(e,t,i){const{x:s,y:n}=t,{x:a,y:r}=i;let l=s+(a-s)*e,o=n+(r-n)*e;return{x:l,y:o}}function n_(e,t,i,s){const{x:n,y:a}=t,{x:r,y:l}=i,{x:o,y:u}=s;let c=(1-e)*(1-e)*n+2*e*(1-e)*r+e*e*o,f=(1-e)*(1-e)*a+2*e*(1-e)*l+e*e*u;return{x:c,y:f}}function a_(e,t,i,s,n){const{x:a,y:r}=t,{x:l,y:o}=n,{x:u,y:c}=i,{x:f,y:g}=s;let v=a*(1-e)*(1-e)*(1-e)+3*u*e*(1-e)*(1-e)+3*f*e*e*(1-e)+l*e*e*e,y=r*(1-e)*(1-e)*(1-e)+3*c*e*(1-e)*(1-e)+3*g*e*e*(1-e)+o*e*e*e;return{x:v,y}}function r_(e,t){const{worldRect:i,lineGradientFromColor:s,lineGradientToColor:n,lineGradientAngle:a}=t.calculative;return Vd(e,i,s,n,a)}function Vd(e,t,i,s,n){if(!i||!s)return;const{x:a,y:r,center:l,ex:o,ey:u}=t,c={x:a,y:l.y},f={x:o,y:l.y};n%90===0&&n%180?(c.x=l.x,f.x=l.x,n%270?(c.y=r,f.y=u):(c.y=u,f.y=r)):n&&(Gt(c,n,t.center),Gt(f,n,t.center));const g=e.createLinearGradient(c.x,c.y,f.x,f.y);return g.addColorStop(0,i),g.addColorStop(1,s),g}function o_(e){const{worldIconRect:t,iconWidth:i,iconHeight:s,imgNaturalWidth:n,imgNaturalHeight:a}=e.calculative;let{x:r,y:l,width:o,height:u}=t;if(i&&(o=i),s&&(u=s),n&&a&&e.imageRatio){const c=t.width/n,f=t.height/a,g=Math.min(c,f),v=n/a;i?u=i/v:s?o=s*v:(o=g*n,u=g*a)}switch(r+=(t.width-o)/2,l+=(t.height-u)/2,e.iconAlign){case"top":l=t.y;break;case"bottom":l=t.ey-u;break;case"left":r=t.x;break;case"right":r=t.ex-o;break;case"left-top":r=t.x,l=t.y;break;case"right-top":r=t.ex-o,l=t.y;break;case"left-bottom":r=t.x,l=t.ey-u;break;case"right-bottom":r=t.ex-o,l=t.ey-u;break}return{x:r,y:l,width:o,height:u}}function En(e,t){const{x:i,y:s,width:n,height:a}=o_(t),{worldIconRect:r,iconRotate:l,img:o}=t.calculative;if(e.filter=t.filter,l){const{x:u,y:c}=r.center;e.translate(u,c),e.rotate(l*Math.PI/180),e.translate(-u,-c)}if(t.imageRadius){e.save();let u=t.calculative.imageRadius||0,c=u;const{x:f,y:g,width:v,height:y,ex:w,ey:m}=t.calculative.worldRect;u<1&&(u=v*u,c=y*c);let _=u<c?u:c;v<2*_&&(_=v/2),y<2*_&&(_=y/2),e.beginPath(),e.moveTo(f+_,g),e.arcTo(w,g,w,m,_),e.arcTo(w,m,f,m,_),e.arcTo(f,m,f,g,_),e.arcTo(f,g,w,g,_),e.clip(),e.drawImage(o,i,s,n,a),e.restore()}else{let u=s,c=0;if(t.thumbImg){let f=o.naturalWidth,g=o.naturalHeight;c=(a/n*f-g)/2,u=s+c}e.drawImage(o,i,u,n,a-2*c)}}function Ji(e,t){const{textColor:i,color:s}=e.calculative,{styles:n}=t;return i||s||n.textColor||n.color}function qd(e,t){const{fontStyle:i,fontWeight:s,fontSize:n,fontFamily:a,lineHeight:r,text:l,hiddenText:o,canvas:u,textHasShadow:c,textBackground:f,textType:g}=t.calculative;if(t.input&&!t.text&&t.calculative.canvas.inputDiv.dataset.penId!==t.id){e.save(),e.font=Be({fontStyle:i,fontWeight:s,fontFamily:a,fontSize:n,lineHeight:r}),e.fillStyle=t.placeholderColor||"#c0c0c0";const M=t.calculative.worldTextRect;e.fillText(t.placeholder||"\u8BF7\u8F93\u5165",M.x,M.y+M.height/2),e.restore()}if(l==null||o)return;const v=u.store;e.save(),c||(e.shadowBlur=0,e.shadowOffsetX=0,e.shadowOffsetY=0);let y;t.calculative.disabled?y=t.disabledTextColor||t.disabledColor||Ae(.4,Ji(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===Sn.Linear?w=Qx(e,t):g===Sn.Radial&&(w=Jx(e,t)),e.fillStyle=y||w||Ji(t,v),e.font=Be({fontStyle:i,fontWeight:s,fontFamily:a||v.options.fontFamily,fontSize:n,lineHeight:r}),!t.calculative.textDrawRect&&vc(e,t);const{x:m,y:_,width:E,height:x}=t.calculative.textDrawRect;f&&(e.save(),e.fillStyle=f,e.fillRect(m,_,E,x),e.restore());const C=.55,S=t.textAlign||v.options.textAlign,L=n*r;t.calculative.textLines.forEach((M,D)=>{const $=t.calculative.textLineWidths[D];let Q=0;S==="center"?Q=(E-$)/2:S==="right"&&(Q=E-$),e.fillText(M,m+Q,_+(D+C)*L);const{textDecorationColor:R,textDecorationDash:T,textDecoration:P}=t;P&&l_(e,{x:m+Q,y:_+(D+C)*L,width:$},{textDecorationColor:R,textDecorationDash:T,fontSize:n});const{textStrickoutColor:O,textStrickoutDash:Y,textStrickout:Z}=t;Z&&c_(e,{x:m+Q,y:_+(D+C)*L,width:$},{textStrickoutColor:O,textStrickoutDash:Y,fontSize:n})}),e.restore()}function l_(e,t,i){const{textDecorationColor:s,textDecorationDash:n,fontSize:a}=i;let{x:r,y:l,width:o}=t;switch(e.textBaseline){case"top":l+=a;break;case"middle":l+=a/2;break}e.save(),e.beginPath(),e.strokeStyle=s||e.fillStyle,e.lineWidth=1,e.moveTo(r,l),e.setLineDash(n||[]),e.lineTo(r+o,l),e.stroke(),e.restore()}function c_(e,t,i){const{textStrickoutColor:s,textStrickoutDash:n,fontSize:a}=i;let{x:r,y:l,width:o}=t;switch(e.textBaseline){case"top":l+=a/2;break;case"bottom":l-=a/2;break}e.save(),e.beginPath(),e.strokeStyle=s||e.fillStyle,e.lineWidth=1,e.moveTo(r,l),e.setLineDash(n||[]),e.lineTo(r+o,l),e.stroke(),e.restore()}function Yd(e,t,i){if(i==null)return;const{fontStyle:s,fontWeight:n,fontSize:a,fontFamily:r,lineHeight:l,canvas:o}=t.calculative,u=o.store;e.save();let c;t.calculative.hover?c=t.hoverTextColor||t.hoverColor||u.styles.hoverColor:t.calculative.active&&(c=t.activeTextColor||t.activeColor||u.styles.activeColor),e.fillStyle=c||Ji(t,u),e.font=Be({fontStyle:s,fontWeight:n,fontFamily:r||u.options.fontFamily,fontSize:a,lineHeight:l});const f=e.measureText(i).width;let g,v;for(const y of t.calculative.worldAnchors){if(!v){v=y;continue}const w=Qr(v,y),m=Math.floor(w/f);g="";for(let E=0;E<m;E++)g+=i;const _=ui(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+l/2),e.restore(),v=y}e.restore()}function Kd(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,a=s.y+s.height/2;switch(t.iconAlign){case"top":a=s.y,e.textBaseline="top";break;case"bottom":a=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,a=s.y,e.textAlign="left",e.textBaseline="top";break;case"right-top":n=s.ex,a=s.y,e.textAlign="right",e.textBaseline="top";break;case"left-bottom":n=s.x,a=s.ey,e.textAlign="left",e.textBaseline="bottom";break;case"right-bottom":n=s.ex,a=s.ey,e.textAlign="right",e.textBaseline="bottom";break}const r=t.calculative.iconWeight;let l;const o=t.calculative.iconFamily;t.calculative.iconSize>0?l=t.calculative.iconSize:s.width>s.height?l=s.height:l=s.width,e.font=Be({fontSize:l,fontWeight:r,fontFamily:o}),e.fillStyle=t.calculative.iconColor||Ji(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,a),e.restore()}function Xd(e,t){if(!t.input)return;const i=t.calculative.canvas.store.data.scale,s=t.calculative.canvas.inputDiv.dataset.penId,{x:n,y:a,width:r,height:l}=t.calculative.worldRect;e.save(),e.beginPath(),t.id===s?(e.moveTo(n+r-20*i,a+l/2+2*i),e.lineTo(n+r-14*i,a+l/2-4*i),e.lineTo(n+r-8*i,a+l/2+2*i)):(e.moveTo(n+r-20*i,a+l/2-4*i),e.lineTo(n+r-14*i,a+l/2+2*i),e.lineTo(n+r-8*i,a+l/2-4*i)),e.stroke(),e.restore()}function Be({fontStyle:e="normal",textDecoration:t="normal",fontWeight:i="normal",fontSize:s=12,fontFamily:n="Arial",lineHeight:a=1}={}){return`${e} ${t} ${i} ${s}px/${a} ${n}`}function zs(e,t){const{x:i,ex:s,y:n,ey:a}=t.calculative.worldRect||{};t.calculative.flipX&&(e.translate(i+s,0),e.scale(-1,1)),t.calculative.flipY&&(e.translate(0,n+a),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 a=t.calculative.rotate*Math.PI/180;i||(t.calculative.flipX&&(a*=-1),t.calculative.flipY&&(a*=-1)),e.rotate(a),e.translate(-s,-n)}function Is(e,t,i){e.save(),e.translate(.5,.5),e.beginPath(),I_(e,t);const s=t.calculative.canvas.store,n=t.textFlip||s.options.textFlip,a=t.textRotate||s.options.textRotate;(!n||!a)&&e.save(),zs(e,t),t.calculative.rotate&&t.name!=="line"&&Gi(e,t),(t.calculative.lineWidth>1||i)&&(e.lineWidth=t.calculative.lineWidth),A_(e,s,t);let r,l=!1,o;t.calculative.disabled?(o=t.disabledColor||s.styles.disabledColor||Ae(.4,t.calculative.color||s.styles.color),r=t.disabledBackground||s.styles.disabledBackground||Ae(.4,t.calculative.background||s.styles.penBackground)):t.mouseDownValid&&t.calculative.mouseDown?(o=t.mouseDownColor||Ae(-.4,t.calculative.color||s.styles.color),r=t.mouseDownBackground||Ae(-.4,t.calculative.background||s.styles.penBackground)):t.switch&&t.calculative.checked?t.calculative.bkType||(r=t.onBackground):t.calculative.hover?(o=t.hoverColor||s.styles.hoverColor,r=t.hoverBackground||s.styles.hoverBackground):t.calculative.active?(o=t.activeColor||s.styles.activeColor,r=t.activeBackground||s.styles.activeBackground):t.calculative.isDock&&(t.type===jt.Line?o=s.styles.dockPenColor:r=Wr(s.styles.dockPenColor,.2));const u=t.calculative.strokeImg;if(t.calculative.strokeImage&&u)e.strokeStyle=o||e.createPattern(u,"repeat");else{let f;t.calculative.strokeType?t.calculative.lineGradientColors?t.name==="line"?l=!0:t.calculative.lineGradient?f=t.calculative.lineGradient:(f=e_(e,t),t.calculative.lineGradient=f):f=r_(e,t):f=t.calculative.color||(t.type?s.data.lineColor:"")||s.styles.color,e.strokeStyle=o||f}const c=t.calculative.backgroundImg;if(t.calculative.backgroundImage&&c)e.fillStyle=r||e.createPattern(c,"repeat"),r=!0;else{let f;t.calculative.bkType===Sn.Linear?t.calculative.gradientColors?t.calculative.gradient?f=t.calculative.gradient:(f=Zx(e,t),t.calculative.gradient=f):f=Yx(e,t):t.calculative.bkType===Sn.Radial?t.calculative.gradientColors?t.calculative.radialGradient?f=t.calculative.radialGradient:(f=Gx(e,t),t.calculative.radialGradient=f):f=Kx(e,t):f=t.calculative.background||s.styles.penBackground,e.fillStyle=r||f,r=!!f}if(Gd(e,t),Zd(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),l?(jd(e,t),Qd(!0,e,t,s)):(Jd(!0,e,t,s,r),rg(e,t)),!(t.image&&t.calculative.img)&&t.calculative.icon&&Kd(e,t),t.dropdownList&&Xd(e,t),(!n||!a)&&e.restore(),n&&!a&&zs(e,t),!n&&a&&t.calculative.rotate&&t.name!=="line"&&Gi(e,t,!0),qd(e,t),t.type===jt.Line&&t.fillTexts)for(const f of t.fillTexts)Yd(e,t,f);e.restore()}function Gd(e,t){const i=t.lineCap||(t.type?"round":"square");i?e.lineCap=i:t.type&&(e.lineCap="round")}function Zd(e,t){const i=t.lineJoin;i?e.lineJoin=i:t.type&&(e.lineJoin="round")}function jr(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 a=t.calculative.canvas.store,r=t.textFlip||a.options.textFlip,l=t.textRotate||a.options.textRotate;e.beginPath(),(!r||!l)&&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 o;if(t.calculative.hover)e.strokeStyle=t.hoverColor||a.styles.hoverColor,e.fillStyle=t.hoverBackground||a.styles.hoverBackground,o=t.hoverBackground||a.styles.hoverBackground;else if(t.calculative.active)e.strokeStyle=t.activeColor||a.styles.activeColor,e.fillStyle=t.activeBackground||a.styles.activeBackground,o=t.activeBackground||a.styles.activeBackground;else{if(t.strokeImage)t.calculative.strokeImg&&(e.strokeStyle=e.createPattern(t.calculative.strokeImg,"repeat"),o=!0);else{let c;t.calculative.strokeType&&t.calculative.lineGradientColors&&t.name==="line"?n=!0:c=t.calculative.color||a.styles.color,e.strokeStyle=c}t.backgroundImage?t.calculative.backgroundImg&&(e.fillStyle=e.createPattern(t.calculative.backgroundImg,"repeat"),o=!0):(e.fillStyle=t.background,o=!!t.background)}if(Gd(e,t),Zd(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?(jd(e,t),Qd(!0,e,t,a)):(Jd(!1,e,t,a,o),rg(e,t)),t.calculative.img?(e.save(),e.shadowColor="",e.shadowBlur=0,e.shadowOffsetX=0,e.shadowOffsetY=0,En(e,t),e.restore()):t.calculative.icon&&Kd(e,t),t.dropdownList&&Xd(e,t),(!r||!l)&&e.restore(),r&&!l&&(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))),!r&&l&&t.calculative.rotate&&t.name!=="line"&&Gi(e,t,!0),qd(e,t),t.type===jt.Line&&t.fillTexts)for(const c of t.fillTexts)Yd(e,t,c);e.restore()}function Jd(e=!0,t,i,s,n){if(i.name==="drawCommand")return;const a=e?s.path2dMap.get(i):kt.path2dDraws[i.name];let r=null,l=null;if(i.type===jt.Line&&(i.fromLineCap&&i.fromLineCap!=="butt"&&(t.lineCap="butt",r=new Path2D,r.moveTo(i.calculative.worldAnchors[0].x,i.calculative.worldAnchors[0].y),r.lineTo(i.calculative.worldAnchors[0].x,i.calculative.worldAnchors[0].y)),i.toLineCap&&i.toLineCap!=="butt"&&(t.lineCap="butt",l=new Path2D,l.moveTo(i.calculative.worldAnchors[i.calculative.worldAnchors.length-1].x,i.calculative.worldAnchors[i.calculative.worldAnchors.length-1].y),l.lineTo(i.calculative.worldAnchors[i.calculative.worldAnchors.length-1].x,i.calculative.worldAnchors[i.calculative.worldAnchors.length-1].y))),a){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,r&&(t.save(),t.lineCap=i.fromLineCap,t.stroke(r),t.restore()),a instanceof Path2D?(n&&t.fill(a),u&&t.stroke(a)):(a(i,t),n&&t.fill(),u&&t.stroke()),l&&(t.save(),t.lineCap=i.toLineCap,t.stroke(l),t.restore()),t.restore()}a instanceof Path2D?i.type?i.close&&n&&t.fill(a):n&&t.fill(a):(t.save(),a(i,t),n&&t.fill(),t.restore());const o=i.calculative.progress;if(o!=null){t.save();const{ex:u,x:c,y:f,width:g,height:v,ey:y}=i.calculative.worldRect;let w=null;if(i.calculative.verticalProgress?w=i.reverseProgress?t.createLinearGradient(c,f,c,f+v*o):t.createLinearGradient(c,y,c,f+v*(1-o)):w=i.reverseProgress?t.createLinearGradient(u,f,c+g*(1-o),f):t.createLinearGradient(c,f,c+g*o,f),i.calculative.progressGradientColors){const{colors:m}=Ys(i.calculative.progressGradientColors);m.forEach(_=>{w.addColorStop(_.i,_.color)})}else{const m=i.calculative.progressColor||i.calculative.color||s.options.activeColor||s.data.color;w.addColorStop(0,m),w.addColorStop(1,m)}w.addColorStop(1,"transparent"),t.fillStyle=w,a instanceof Path2D?t.fill(a):(a(i,t),t.fill()),t.restore()}if(i.calculative.lineWidth&&(a instanceof Path2D?(s.options.svgPathStroke||i.name!=="svgPath")&&(r&&(t.save(),t.lineCap=i.fromLineCap,t.stroke(r),t.restore()),t.stroke(a),l&&(t.save(),t.lineCap=i.toLineCap,t.stroke(l),t.restore())):(a(i,t),t.stroke())),i.type){if(i.calculative.animatePos){if(t.save(),tg(t,i,s),i.lineAnimateType===We.Arrow||i.lineAnimateType===We.WaterDrop){let u=dg(i,t);u instanceof Path2D?(t.stroke(u),t.fill(u)):(t.stroke(),t.fill())}else a instanceof Path2D?(r&&!i.lineAnimateType&&(t.save(),t.lineCap=i.fromLineCap,t.stroke(r),t.restore()),t.lineCap=i.lineCap,t.stroke(a)):(a(i,t),t.stroke());t.restore()}i.fromArrow&&Wd(t,i,s),i.toArrow&&Ud(t,i,s),i.calculative.active&&!i.calculative.pencil&&!s.options.disableAnchor&&!s.data.locked&&eg(t,i)}}}function Qd(e=!0,t,i,s){const n=e?s.path2dMap.get(i):kt.path2dDraws[i.name];if(n&&i.type){if(i.calculative.animatePos){if(t.save(),tg(t,i,s),t.beginPath(),n instanceof Path2D)if(i.lineName==="polyline"||i.lineName==="line")if(i.lineAnimateType===We.Arrow||i.lineAnimateType===We.WaterDrop){const a=dg(i);t.stroke(a),t.fill(a)}else i.calculative.gradientSmooth||i.calculative.lineSmooth?(i.calculative.gradientAnimatePath||(i.calculative.gradientAnimatePath=pc(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&&Wd(t,i,s),i.toArrow&&Ud(t,i,s),i.calculative.active&&!i.calculative.pencil&&!s.options.disableAnchor&&!s.data.locked&&eg(t,i)}}function tg(e,t,i){var n;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 We.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 a=t.animateLineDash&&t.animateLineDash.map(r=>r*s/5);e.setLineDash(a||[s,s*2]);break;case We.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 We.Arrow:e.fillStyle=t.animateColor||i.styles.animateColor,e.lineWidth=1;break;case We.WaterDrop:e.fillStyle=t.animateColor||i.styles.animateColor,e.lineWidth=1;break;case We.Custom:switch(t.lineAnimateTargetType){case wn.Image:if((n=t.lineAnimateImages)!=null||(t.lineAnimateImages=[]),t.lineAnimateImages.length>0){const o=t.lineAnimateImages.map((u,c)=>{const f=kt.htmlElements[u];if(!f)t.calculative.canvas.__loadImage(u);else return f});pr(e,t,"image",o)}break;case wn.Icon:const r=t.lineAnimateIcon;pr(e,t,"icon",r);break;case wn.Pen:t.lineAnimatePens&&pr(e,t,"pen",t.lineAnimatePens);break;case wn.Element:const l=t.lineAnimateElement;pr(e,t,"element",l)}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 pr(e,t,i,s){let n=null;switch(i){case"image":n=h_(s);break;case"icon":n=f_(s);break;case"pen":let a=t.calculative.canvas.find(s);t.lineAnimateElementCount=a.length,n=u_(a);break;case"element":if(n=kt.lineAnimateDraws[s],!n)return;break}d_(e,t,n)}function h_(e){return function(t,i,s,n){const a=i.calculative.canvas.store.data.scale,r=i.lineAnimateElementWidth||10,l=i.lineAnimateElementHeight||10,o=e[n%e.length];!o||(t.beginPath(),t.translate(s.x+r/2*a,s.y+l/2*a),t.rotate(s.rotate*Math.PI/180),t.scale(a,a),t.translate(-(r/2*a),-(l/2*a)),t.drawImage(o,0,0,r,l))}}function u_(e){return function(t,i,s,n){const a=e[n%e.length];if(!a)return;const r=i.calculative.canvas.store.data.scale,l=i.calculative.canvas.store.data.origin,o=i.calculative.canvas.parent,u=a.width,c=a.height,f=s.x-u/2,g=s.y-c/2,v=(f-l.x)/r,y=(g-l.y)/r,w=u/r,m=c/r,_={x:v,y,width:w,height:m,rotate:s.rotate};o.setValue({id:a.id,..._})}}function f_(e){return function(t,i,s,n){const a=i.calculative.canvas.store.data.scale,r=i.lineAnimateElementWidth||10,l=i.lineAnimateElementHeight||10;t.beginPath(),t.translate(s.x+r/2*a,s.y+l/2*a),t.rotate(s.rotate*Math.PI/180),t.scale(a,a),t.translate(-(r/2*a),-(l/2*a));const o=i.calculative.iconWeight;let u;const c=i.calculative.iconFamily;u=i.calculative.iconSize||Math.max(i.lineAnimateElementWidth||0,i.lineAnimateElementHeight||0)||10,t.font=Be({fontSize:u,fontWeight:o,fontFamily:c}),t.fillStyle=i.calculative.iconColor||Ji(i,i.calculative.canvas.parent.store),i.calculative.iconRotate&&t.rotate(i.calculative.iconRotate*Math.PI/180),t.beginPath(),t.fillText(e,0,0)}}function d_(e,t,i){var l;const s=Array.isArray(t.lineAnimateDash)?t.lineAnimateDash:((l=t.lineAnimateDash)==null?void 0:l.split(",").map(o=>Number(o)))||[10,20],n=t.calculative.canvas.store.data.scale,a=Yr(t)/n;g_(a,s,t.lineAnimateDashOffset,t.lineAnimateElementCount).forEach((o,u)=>{const c=v_(t,o.start);if(!!c)try{e.save(),i(e,t,c,u),e.restore()}catch(f){e.restore(),console.warn(f)}})}function g_(e,t,i=0,s,n=0){const a=[];if(!t||t.length===0)return a.push({start:0,end:e,isDash:!0}),a;const r=t.reduce((c,f)=>c+f,0);let l=(-i+n)%r;l<0&&(l+=r);let o=0,u=0;for(s||(s=1/0);u<e&&o<s;)for(let c=0;c<t.length;c++){const f=t[c],g=c%2===0;let v=u,y=u+f-l;if(y>e&&(y=e),g&&y>v){const w=(v+n)%e,m=(y+n)%e;a.push({start:w,end:m,isDash:!0}),o+=1}if(u=y,l=0,u>=e||o>=s)break}return a}function v_(e,t=0){let i,s=null;if(e.calculative.worldAnchors.forEach(r=>{s&&(i=Lf(i,s,s.next,r.prev,r)),s=r}),e.close){let r=e.calculative.worldAnchors[0];i=Lf(i,s,s.next,r.prev,r)}let n=0;return e.animateReverse?n=e.length-e.calculative.animatePos-t*e.calculative.canvas.store.data.scale:n=e.calculative.animatePos-t*e.calculative.canvas.store.data.scale,A2(i,n)}function eg(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&&y_(e,s,t)}),e.restore()}function y_(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 ig(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,re(i),Qt(i),e.pivot&&Ql(i,e.pivot);else{const s=t.pens[e.parentId];let n=s.calculative.worldRect;n||(n=ig(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),re(i),i.rotate=n.rotate+e.rotate,Qt(i),e.pivot&&Ql(i,e.pivot)}return e.calculative.worldRect=i,wc(e,i),i}function wc(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 Lr(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,fs(t,s))}function An(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(m_(e,n))})}if(!i.length&&!e.type&&!e.calculative.canvas.parent.isCombine(e)){const{x:s,y:n,width:a,height:r}=e.calculative.worldRect;i=t.options.defaultAnchors.map((l,o)=>({id:`${o}`,penId:e.id,x:s+a*l.x,y:n+r*l.y}))}e.calculative.rotate&&e.name!=="line"&&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 sg(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,Qt(n.calculative.initRect)),sg(n)})}}function m_(e,t){const i={...t},{x:s,y:n,width:a,height:r}=e.calculative.worldRect;return i.x=s+a*t.x,i.y=n+r*t.y,t.prev&&(i.prev={penId:e.id,connectTo:t.prev.connectTo,x:s+a*t.prev.x,y:n+r*t.prev.y}),t.next&&(i.next={penId:e.id,connectTo:t.next.connectTo,x:s+a*t.next.x,y:n+r*t.next.y}),i}function vf(e,t){const{paddingTop:i,paddingBottom:s,paddingLeft:n,paddingRight:a}=t.calculative;let r=n,l=i,o=t.calculative.worldRect.width-n-a,u=t.calculative.worldRect.height-i-s,c=t.calculative.iconLeft,f=t.calculative.iconTop;c&&Math.abs(c)<1&&(c=t.calculative.worldRect.width*c),f&&Math.abs(f)<1&&(f=t.calculative.worldRect.height*f),r+=c||0,l+=f||0,o-=c||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)}r=t.calculative.worldRect.x+r,l=t.calculative.worldRect.y+l,t.calculative.worldIconRect={x:r,y:l,width:o,height:u,rotate:g},re(t.calculative.worldIconRect),Qt(t.calculative.worldIconRect)}function gn(e,t,i){va(e.calculative.worldRect,t,i,e.pivot),e.calculative.initRect&&va(e.calculative.initRect,t,i,e.pivot),ng(e,t,i),e.calculative.x&&Hr(e.calculative,t,i),e.type&&An(e)}function ng(e,t,i){var s;!e||(s=e.children)!=null&&s.length&&e.children.forEach(n=>{const a=e.calculative.canvas.store.pens[n];a&&(a.calculative.initRect&&va(a.calculative.initRect,t,i),ng(a,t,i))})}function p_(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 w_(e,t,i){e.anchors||(e.anchors=[]),e.calculative.worldAnchors||(e.calculative.worldAnchors=[]);const s=p2(e,t,i);return e.calculative.worldAnchors.splice(i+1,0,s),e.anchors.splice(i+1,0,ra(s,e.calculative.worldRect)),e.calculative.activeAnchor=s,s}function b_(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 Pn(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 fx(e,t.calculative.worldRect.center)}function xn(e,t){let i=1/0,s;return e.calculative.worldAnchors.forEach(n=>{const a=Qr(t,n);i>a&&(i=a,s=n)}),s}function yf(e,t,i){e.x+=t,e.y+=i,e.anchors&&e.anchors.forEach(s=>{aa(s,t,i)}),e.calculative.worldAnchors&&e.calculative.worldAnchors.forEach(s=>{aa(s,t,i)})}function bc(e){if(e&&e.calculative&&e.calculative.worldAnchors.length){let t=$t(e);if(!e.anchors||!e.anchors.length)for(;e.calculative.worldAnchors.length&&t!==e.calculative.activeAnchor;)e.calculative.worldAnchors.pop(),t=$t(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 l,o,u,c,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=$t(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];_n(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 a=((l=i.calculative.worldAnchors)==null?void 0:l.length)>=2?(o=i.calculative.worldAnchors)==null?void 0:o[0].connectTo:void 0,r=((u=i.calculative.worldAnchors)==null?void 0:u.length)>=2?(f=i.calculative.canvas.store.pens[(c=i.calculative.worldAnchors)==null?void 0:c[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:a,fromAnchor:r}),!0}function _n(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,a,r)=>{(n.lineId===i.id||n.lineId===i.id)&&n.lineAnchor===s.id&&n.anchor===t.id&&r.splice(a,1)}),s.connectTo=void 0,s.anchorId=void 0,e.type&&t.connectTo===i.id&&t.anchorId===s.id&&_n(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 $t(e){if(!(!e||!e.calculative.worldAnchors))return e.calculative.worldAnchors[e.calculative.worldAnchors.length-1]}function x_(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 a of e.frames){e.calculative.duration+=a.duration;for(const r in a)r!=="duration"&&!e[r]&&r==="scale"&&(e[r]=1)}}if(e.animateCycle||(e.animateCycle=1/0),e.calculative.start){let a=0;const r=Math.ceil((t-e.calculative.start)/e.calculative.duration);if(r>e.animateCycle)return e.currentAnimation=void 0,e.calculative.start=void 0,pf(e,1),0;const l=(t-e.calculative.start)%e.calculative.duration||e.calculative.duration;let o=0;for(const f of e.frames)if(o+=f.duration,l>o)++a;else break;if(!e.frames[a])return!0;let u=!1;a!==e.calculative.frameIndex&&(u=!0,e.calculative.frameIndex=a,e.calculative.frameDuration=e.frames[a].duration,a>0&&(e.calculative.frameStart+=e.frames[a-1].duration),e.calculative.frameEnd=e.calculative.frameStart+e.calculative.frameDuration);let c=!1;if(r>e.calculative.cycleIndex&&(e.calculative.cycleIndex=r,e.calculative.frameStart=e.calculative.start+e.calculative.duration*(r-1),c=!0),u||c)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,a>0){e.prevFrame={};const f=e.frames[a-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 mf(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 a=e.calculative.canvas.store;e.calculative.childrenVisible={},e.children.forEach(r=>{e.calculative.childrenVisible[r]=a.pens[r].visible})}e.calculative.initRect.rotate=e.calculative.rotate||0,mf(e)}const i=(t-e.calculative.frameStart)/e.calculative.frameDuration%1;return i>0&&pf(e,i),!0}function mf(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 pf(e,t){var n,a,r,l,o,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 c in i)if(c!=="duration"){if(c==="scale"){e.calculative.worldRect=ht(e.calculative.initRect),va(e.calculative.worldRect,e.prevFrame.scale,e.calculative.worldRect.center);const f=e.prevFrame.scale+(i[c]-e.prevFrame.scale)*t;va(e.calculative.worldRect,f/e.prevFrame.scale,e.calculative.worldRect.center),e.calculative.patchFlags=!0}else if(c==="x"){const f=Jn(e,c,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=((a=e.calculative.initRect.pivot)==null?void 0:a.x)+f),Ms(e.calculative.worldRect,i[c]*t*s,0),e.calculative.patchFlags=!0}else if(c==="y"){const f=Jn(e,c,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,(r=e.calculative.worldRect.pivot)!=null&&r.x&&(e.calculative.worldRect.pivot.y=((l=e.calculative.initRect.pivot)==null?void 0:l.y)+f),Ms(e.calculative.worldRect,0,i[c]*t*s),e.calculative.patchFlags=!0}else if(c==="width"){const f=Jn(e,c,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[c]*t*s;e.calculative.worldRect.width+=g,e.calculative.worldRect.ex+=g,e.calculative.worldRect.center.x+=g,e.calculative.patchFlags=!0}else if(c==="height"){const f=Jn(e,c,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[c]*t*s;e.calculative.worldRect.height+=g,e.calculative.worldRect.ey+=g,e.calculative.worldRect.center.y+=g,e.calculative.patchFlags=!0}else if(c==="rotate"){e.prevFrame[c]>=360&&(e.prevFrame[c]%=360);const f=Jn(e,c,e.calculative.frameIndex),g=(e.calculative.initRect.rotate+f+i[c]*t)%360-(e.calculative.rotate||0);(o=e.children)!=null&&o.length?e.calculative.canvas.rotatePen(e,g,e.calculative.initRect):e.calculative.rotate=(e.calculative.initRect.rotate+f+i[c]*t)%360,e.calculative.patchFlags=!0}else if(c==="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(__(i[c],c,e)){e.prevFrame[c]==null&&(c==="globalAlpha"?e.prevFrame[c]=1:e.prevFrame[c]=0);const f=e.prevFrame[c]+(i[c]-e.prevFrame[c])*t;e.calculative[c]=Math.round(f*100)/100}else{if(c==="visible"&&!e.calculative.image){if((u=e.children)!=null&&u.length){const g=Qe(e,e.calculative.canvas.store);e.calculative.canvas.initImageCanvas(g)}}e.calculative[c]=i[c];const f={};f[c]=i[c],xc(e,f)}c==="text"&&_a(e)}}function __(e,t,i){const s=["strokeType","bkType","showChild"];return typeof e=="number"&&i.linear!==!1&&!s.includes(t)}function k_(e,t){if(e.calculative.start===0)return e.calculative.start=void 0,e.calculative.cycleStart=void 0,0;e.animateCycle||(e.animateCycle=1/0),e.animateSpan||(e.animateSpan=1);const i=(t-e.calculative.cycleStart)/1e3;if(e.curveAnimate){let s=[];e.animateTimingFunction?s=Array.isArray(e.animateTimingFunction)?e.animateTimingFunction:e.animateTimingFunction.split(","):s=[.25,.25,.75,.75];const n=e.duration||5,a=i/n,r=Wx(a,s[1],s[3]);e.calculative.animatePos=r*e.length}else e.calculative.animatePos+=e.animateSpan*(e.calculative.canvas.store.data.scale||1);if(e.calculative.cycleStart||(e.calculative.cycleStart=t),!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||e.curveAnimate&&i>e.duration){if(++e.calculative.cycleIndex,e.calculative.cycleIndex>e.animateCycle)return e.currentAnimation=void 0,e.calculative.start=void 0,e.calculative.cycleStart=void 0,0;e.calculative.cycleStart=void 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 ea(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,a;((n=i.pens[s])==null?void 0:n.hoverColor)==null&&((a=i.pens[s])==null?void 0:a.hoverBackground)==null&&ea(i.pens[s],t)})}function Re(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 Pl(e){return e.every(t=>t.locked)}function wf(e){return e.every(t=>t.disableRotate)}function ag(e,t,i){var s;e.type?(e.calculative.worldAnchors.forEach(n=>{Gt(n,t,i.center)}),E_(e),Lr(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 a=e.calculative.canvas.store.pens[n];ag(a,t,i)})}function E_(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=ic(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),Qt(t),e.calculative.worldRect=t,wc(e,t),Ri(e),e.calculative.worldAnchors&&(e.anchors=e.calculative.worldAnchors.map(a=>ra(a,e.calculative.worldRect)))}function bf(e){return e.every(t=>t.disableSize||t.pivot)}function Jn(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 Vr(e,t){var s;let i=e;for(;i&&i.parentId;){const n=i;i=t.pens[i.parentId];const a=(s=i==null?void 0:i.calculative)==null?void 0:s.showChild;if(a!=null&&i.children[a]!==n.id)return!1}return!0}function Yi(e,t=!1){var n,a,r;const{store:i,canvasRect:s}=e.calculative.canvas;if(t&&((n=e.children)==null||n.forEach(l=>{const o=i.pens[l];o&&Yi(o,!0)})),e.calculative.inView=!0,Vr(e,i)?(e.visible==!1||e.calculative.visible==!1)&&(e.calculative.inView=!1,(e.canvasLayer===zt.CanvasImageBottom||e.canvasLayer===zt.CanvasImage)&&((a=e.frames)==null?void 0:a.length)&&(e.calculative.inView=e.frames.some(l=>l.hasOwnProperty("visible")))):e.calculative.inView=!1,e.calculative.inView){const{x:l,y:o,width:u,height:c,rotate:f}=e.calculative.worldRect,g={x:l+i.data.x,y:o+i.data.y,width:u,height:c,rotate:f};re(g),Xi(g,s)||(e.calculative.inView=!1)}(r=e.calculative.singleton)!=null&&r.div&&Re(e,e.calculative.singleton.div)}function A_(e,t,i){if(t.fillWorldTextRect){e.save(),e.fillStyle="#c3deb7";const{x:s,y:n,width:a,height:r}=i.calculative.worldTextRect;e.fillRect(s,n,a,r),e.restore()}}function Hs(e,t){const i=t.calculative.globalAlpha;typeof i=="number"&&i<1&&!isNaN(i)&&(e.globalAlpha=i)}function rg(e,t){const i=C_(e,t)||kt.canvasDraws[t.name];i&&(e.save(),i(e,t),e.restore())}function C_(e,t){const i=t.drawCommand;if(!(!i||t.name==="line"))return(s,n)=>{i.forEach(a=>{try{a.steps=a.steps.flat(1/0),a.steps.reduce((r,l)=>{const o=R_(l,n,r.x,r.y);try{if(o.c){if(o.c.startsWith("_")){const c=o.c.split("_")[1];return typeof o.v.value=="number"&&(o.v.value*=n.calculative.canvas.store.data.scale),(o.p||s)[c]=o.v.value,{x:r.x,y:r.y}}let u=[];for(const c in o.v)u.push(o.v[c]);return(o.p||s)[o.c](...u),{x:o.startX||o.v.x,y:o.startY||o.v.y}}return{x:r.x,y:r.y}}catch{}},{})}catch{}}),s.stroke()}}function R_(e,t,i,s){var a;const n={visio:P_,dxf:T_,canvas:S_};return((a=n[t.parseType])==null?void 0:a.call(n,e,t,i,s))||e}function T_(e,t,i,s){var c,f;const{x:n,y:a,width:r,height:l}=t.calculative.worldRect,{originWidth:o,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*(r/o)+n,y:e.v.y*(l/u)+a}};case"lineTo":return{c:"lineTo",v:{x:e.v.x*(r/o)+n,y:e.v.y*(l/u)+a}};case"arc":return{c:"ellipse",v:{x:e.v.x*(r/o)+n,y:e.v.y*(l/u)+a,rx:e.v.xr*(r/o),ry:e.v.yr*(l/u),rotation:e.v.rotation||0,startAngle:e.v.startAngle,endAngle:e.v.endAngle,a:(c=e.v.aclockwise)!=null?c:!0}};case"ellipse":return{c:"ellipse",v:{x:e.v.x*(r/o)+n,y:e.v.y*(l/u)+a,rx:e.v.xr*(r/o),ry:e.v.yr*(l/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*(r/o)+n),g.v.y!==void 0&&(g.v.y=e.v.y*(l/u)+a),g}}function S_(e,t,i,s){var c,f;const{x:n,y:a,width:r,height:l}=t.calculative.worldRect,{originWidth:o,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*(r/o)+n,y:e.v.y*(l/u)+a}};case"lineTo":return{c:"lineTo",v:{x:e.v.x*(r/o)+n,y:e.v.y*(l/u)+a}};case"arc":return{c:"ellipse",v:{x:e.v.x*(r/o)+n,y:e.v.y*(l/u)+a,rx:e.v.xr*(r/o),ry:e.v.yr*(l/u),rotation:e.v.rotation||0,startAngle:e.v.startAngle,endAngle:e.v.endAngle,a:(c=e.v.aclockwise)!=null?c:!0}};case"ellipse":return{c:"ellipse",v:{x:e.v.x*(r/o)+n,y:e.v.y*(l/u)+a,rx:e.v.xr*(r/o),ry:e.v.yr*(l/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*(r/o)+n),g.v.y!==void 0&&(g.v.y=e.v.y*(l/u)+a),g}}function P_(e,t,i,s){const{x:n,y:a,width:r,height:l}=t.calculative.worldRect,{width:o,height:u}=t.origin;switch(e.c){case"MoveTo":return{c:"moveTo",v:{x:+e.v.X*100*(r/o)+n,y:+e.v.Y*100*(l/u)+a}};case"RelMoveTo":return{c:"moveTo",v:{x:+e.v.X*o*(r/o)+n,y:+e.v.Y*u*(l/u)+a}};case"LineTo":return{c:"lineTo",v:{x:+e.v.X*100*(r/o)+n,y:+e.v.Y*100*(l/u)+a}};case"RelLineTo":return{c:"lineTo",v:{x:+e.v.X*o*(r/o)+n,y:+e.v.Y*u*(l/u)+a}};case"Ellipse":let c=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:c*100*(r/o)+n,y:f*100*(l/u)+a,radiuX:g*100*(r/o),radiuY:v*100*(l/u),rotation:0,startAngle:0,endAngle:Math.PI*2,anticlockwise:!0}};case"EllipticalArcTo":const y=e.v.X*100*(r/o)+n,w=e.v.Y*100*(l/u)+a,m=e.v.A*100*(r/o)+n,_=e.v.B*100*(l/u)+a;e.v.C;const E=e.v.D*(r/l)*(u/o),x=(y-i)*(_-s)-(w-s)*(m-i)>0,C=xf(i,s,y,w,m,_,E);return!e.orign&&(e.orign={}),!e.orign.startA&&(e.orign.startA=wr(C.x0,C.y0,i,s)),!e.orign.endA&&(e.orign.endA=wr(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*o*(r/o)+n,L=e.v.Y*u*(l/u)+a,M=e.v.A*o*(r/o)+n,D=e.v.B*u*(l/u)+a;e.v.C;const $=e.v.D*(r/l)*(u/o),Q=(S-i)*(D-s)-(L-s)*(M-i)>0,R=xf(i,s,S,L,M,D,$);return!e.orign&&(e.orign={}),!e.orign.startA&&(e.orign.startA=wr(R.x0,R.y0,i,s)),!e.orign.endA&&(e.orign.endA=wr(R.x0,R.y0,S,L)),{c:"ellipse",v:{centerX:R.x0,centerY:R.y0,radiuX:R.a,radiuY:R.b,rotation:0,startAngle:e.orign.startA,endAngle:e.orign.endA,anticlockwise:Q},startX:S,startY:L};case"ArcTo":let T=e.v.X*100*r/o+n,P=e.v.Y*100*l/u+a,O=e.v.A*100*(r/l)*(u/o),Y=(i+T)/2,Z=(s+P)/2,at=Math.sqrt((T-i)**2+(P-s)**2),V=at**2/(8*O)+O/2,H=-(P-s)/at,j=(T-i)/at,K=Y+H*V,U=Z+j*V,tt=K,st=U,et=Math.atan2(s-st,i-tt),ut=Math.atan2(P-st,T-tt);return{c:"arc",v:{x:tt,y:st,radius:V,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*(r/o)+n):(I=ot.endsWith)!=null&&I.call(ot,"_y")?typeof b=="number"&&(ct.v[ot]=b*(l/u)+a):typeof b=="number"&&(ct.v[ot]=b)}),ct}}function I_(e,t){e.filter=t.filter}function xc(e,t){for(const i in t)Fd.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,Ri(e)):e.calculative[i]=t[i]),e.image&&e.name!=="gif"&&Bd.includes(i)&&(e.calculative.canvas.store.patchFlagsTop=!0,e.calculative.canvas.store.patchFlagsBackground=!0,e.calculative.imageDrawed=!1);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 a=e.calculative.canvas.store.pens[s];a&&xc(a,n)})}}function xf(e,t,i,s,n,a,r){let l=(e-i)*(e+i)*(s-a)-(i-n)*(i+n)*(t-s)+r*r*(t-s)*(s-a)*(t-a),o=2*((e-i)*(s-a)-(i-n)*(t-s)),u=l/o,c=(e-i)*(i-n)*(e-n)+r*r*((i-n)*(t-s)*(t+s)-(e-i)*(s-a)*(s+a)),f=2*r*r*((i-n)*(t-s)-(e-i)*(s-a)),g=c/f,v=Math.sqrt(Math.pow(e-u,2)+Math.pow(r*(t-g),2)),y=v/r;return{x0:u,y0:g,a:v,b:y}}function wr(e,t,i,s){let n=i-e,a=s-t,r=Math.atan2(a,n);return r<0&&(r+=2*Math.PI),r}function _f(e,t,i){let s,n,a=1/0,r=1/0;const l=8;for(const o of e.data.pens){if(o.calculative.inView===!1)continue;_c(o).forEach(c=>{if(c===t||c===i)return;let f=(o.calculative.worldRect.center.x-t.x)*(o.calculative.worldRect.center.x-t.x)+(o.calculative.worldRect.center.y-t.y)*(o.calculative.worldRect.center.y-t.y);const g=Math.abs(c.x-t.x);g>0&&g<l&&f<a&&(s={x:Math.round(c.x)+.5,y:Math.round(c.y)+.5,prev:{x:Math.round(t.x)+.5,y:Math.round(t.y)+.5},step:c.x-t.x},a=f);const v=Math.abs(c.y-t.y);v>0&&v<l&&f<r&&(n={x:Math.round(c.x)+.5,y:Math.round(c.y)+.5,prev:{x:Math.round(t.x)+.5,y:Math.round(t.y)+.5},step:c.y-t.y},r=f)})}return{xDock:s,yDock:n}}function L_(e,t,i,s){let n=[];return i.length===1?(n=ht(_c(i[0])),n.forEach(a=>{a.x+=s.x,a.y+=s.y})):(Qt(t),n=[t.center,...Zi(t)]),og(e,n,t,!0)}function _c(e){if(e.type){if(e.type===jt.Line)return e.calculative.worldAnchors}else{const t=Zi(e.calculative.worldRect);return Qt(e.calculative.worldRect),[...e.calculative.worldAnchors,...t,e.calculative.worldRect.center]}}function D_(e,t,i,s){const n=Zi(t);return og(e,n,t)}function og(e,t,i,s=!1){let n,a,r=1/0,l=1/0;const o=10,u=H_(i,o);return e.data.pens.forEach(c=>{const{inView:f,worldRect:g,active:v}=c.calculative;if(f===!1||!s&&v||z_(u,g)||c.type&&e.active.some(w=>lg(e,w,c)))return;const y=_c(c);if(!!y)for(const w of y)for(const m of t){const _=w.x-m.x,E=w.y-m.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<o&&x<r&&(n={x:Math.round(w.x)+.5,y:Math.round(w.y)+.5,step:_,prev:{x:Math.round(m.x)+.5,y:Math.round(m.y)+.5},penId:c.id,anchorId:m.id,dockAnchorId:w.id},r=x),C<o&&C<l&&(a={x:Math.round(w.x)+.5,y:Math.round(w.y)+.5,step:E,prev:{x:Math.round(m.x)+.5,y:Math.round(m.y)+.5},penId:c.id,anchorId:m.id,dockAnchorId:w.id},l=C)}}),{xDock:n,yDock:a}}function lg(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(lg(e,n,i))return!0}return!1}function Jl(e,t){return e.toFixed(12)==t}function M_(e,t=4){let i=e.map(u=>u.calculative.worldRect);const s=i.map(u=>u.x),n=i.map(u=>u.y),a=s.reduce((u,c)=>u+c,0)/s.length,r=n.reduce((u,c)=>u+c,0)/n.length,l=Math.sqrt(s.map(u=>Math.pow(u-a,2)).reduce((u,c)=>u+c,0)/s.length),o=Math.sqrt(n.map(u=>Math.pow(u-r,2)).reduce((u,c)=>u+c,0)/n.length);return e.filter(u=>{let c=u.calculative.worldRect;const f=(c.x-a)/l,g=(c.y-r)/o;return Math.sqrt(f*f+g*g)>t})}function kf(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 B_(){let e=null,t=new Map;return(i,s,n,a=!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 r=new Set,l=new Map;e.has(s)&&e.get(s)?r=e.get(s):(l.set(s,i[s]),e.set(s,r)),a?r.delete(n):r.add(n);let o=l.get(s),u=(...c)=>{o==null||o(...c),r.forEach(f=>{f(...c)})};i[s]=u}}let O_=B_();function F_(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&&re(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||Qt(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)}),N_(e,i)}function Ws(e,t,i=0){const{x:s,y:n,ex:a,ey:r}=t;return e.x>=s-i&&e.x<=a+i&&e.y>=n-i&&e.y<=r+i}function Qt(e){e.center||(e.center={}),e.center.x=e.x+e.width/2,e.center.y=e.y+e.height/2}function re(e){e.ex=e.x+e.width,e.ey=e.y+e.height}function Ql(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 N_(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 hi(e){const t=[];e.forEach(s=>{if(s.isRuleLine)return;const n=s.calculative.worldRect;if(n){const a=Zi(n);t.push(...a)}});const i=ka(t);return Qt(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||Qt(e),t.forEach(i=>{Gt(i,e.rotate,e.pivot||e.center)})),t}function ka(e){let t=1/0,i=1/0,s=-1/0,n=-1/0;return e==null||e.forEach(a=>{!isFinite(a.x)||!isFinite(a.y)||(t=Math.min(t,a.x),i=Math.min(i,a.y),s=Math.max(s,a.x),n=Math.max(n,a.y))}),{x:t,y:i,ex:s,ey:n,width:s-t,height:n-i}}function Xi(e,t,i){return e.rotate&&(e=ka(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 z_(e,t){return(t.x>e.ex||t.ex<e.x)&&(t.y>e.ey||t.ey<e.y)}function H_(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 re(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 W_(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 tc({k:i,point:e.from},{k:s,point:t.from})}function tc(e,t){if(Jl(e.k,0))return{x:t.point.x,y:e.point.y};if(Jl(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),a=e.k*n+i;return{x:n,y:a}}function U_(e,t){const i=W_({from:e[0],to:e[2]},{from:e[1],to:e[3]});for(const s of e)Gt(s,-t,i);return ka(e)}function Ef(e,t,i,s){let n=e.rotate?e.rotate%360:0;if(n){const a=Zi(e),r=(a[0].y-a[1].y)/(a[0].x-a[1].x),l=(a[1].y-a[2].y)/(a[1].x-a[2].x);if(s<4){if(a[s].x+=t,e.ratio)if(s===0||s===2){let c=t*Math.tan((90-(360-n)-Math.atan(e.width/e.height)/Math.PI*180)/180*Math.PI);a[s].y+=c}else{let c=t*Math.tan((90-(360-n)+Math.atan(e.width/e.height)/Math.PI*180)/180*Math.PI);a[s].y+=c}else a[s].y+=i;const u=a[(s+2)%4];a[(s+1)%4]=tc({k:s%2?l:r,point:a[s]},{k:s%2?r:l,point:u}),a[(s+4-1)%4]=tc({k:s%2?r:l,point:a[s]},{k:s%2?l:r,point:u})}else{const u=[4,6].includes(s)?l:r;Jl(u,0)?(a[s%4].x+=t,a[(s+1)%4].x+=t):(a[s%4].y+=i,a[s%4].x+=i/u,a[(s+1)%4].y+=i,a[(s+1)%4].x+=i/u)}if((a[0].x-a[1].x)**2+(a[0].y-a[1].y)**2<25||(a[1].x-a[2].x)**2+(a[1].y-a[2].y)**2<25)return;const o=U_(a,e.rotate);Qt(o),Object.assign(e,o);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 va(e,t,i,s){!e||(e.width*=t,e.height*=t,Hr(e,t,i),re(e),Qt(e),s&&Ql(e,s))}function fs(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 re(i),i}function ra(e,t){const{x:i,y:s,width:n,height:a}=t,{penId:r,connectTo:l}=e,o=Object.assign({},e,{x:n?(e.x-i)/n:0,y:a?(e.y-s)/a:0});return e.prev&&(o.prev={penId:r,connectTo:l,x:n?(e.prev.x-i)/n:0,y:a?(e.prev.y-s)/a:0}),e.next&&(o.next={penId:r,connectTo:l,x:n?(e.next.x-i)/n:0,y:a?(e.next.y-s)/a:0}),o}function $_(e,t){let i=!1;for(let s=0,n=t.length-1;s<t.length;n=s++){let a=t[s].x,r=t[s].y,l=t[n].x,o=t[n].y;r>e.y!=o>e.y&&e.x<(l-a)*(e.y-r)/(o-r)+a&&(i=!i)}return i}const j_=/^[\t\n\f\r ]*([MLHVZCSQTAmlhvzcsqta])[\t\n\f\r ]*/,Af=/^[01]/,Jt=/^[+-]?(([0-9]*\.[0-9]+)|([0-9]+\.)|([0-9]+))([eE][+-]?[0-9]+)?/,V_=/^(([\t\n\f\r ]+,?[\t\n\f\r ]*)|(,[\t\n\f\r ]*))/,q_={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,Af,Af,Jt,Jt]};function Y_(e){let t=0;const i=[];for(;t<e.length;){const s=e.slice(t).match(j_);if(s!==null){const n=s[1];t+=s[0].length;const a=Z_(n,e,t);t=a.cursor,i.push(...a.commands)}else throw new Error("malformed path (first error at "+t+")")}return{commands:i}}function Cf(e){let t=1/0,i=1/0,s=-1/0,n=-1/0;return Q_(e),e.commands.forEach(a=>{a.worldPoints.forEach((r,l)=>{l%2===0?(r<t&&(t=r),r>s&&(s=r)):(r<i&&(i=r),r>n&&(n=r))})}),{x:t,y:i,ex:s,ey:n,width:s-t+1,height:n-i+1}}function K_(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((a,r)=>{s.values[r]=a+(r%2===0?t:i)});break}})}function X_(e,t,i){i==null&&(i=t),e.commands.forEach(s=>{switch(s.key){case"A":case"a":const n=s.values[0],a=s.values[1],r=Math.PI*s.values[2]/180,l=Math.cos(r),o=Math.sin(r),u=a*a*i*i*l*l+n*n*i*i*o*o,c=2*t*i*l*o*(a*a-n*n),f=n*n*t*t*l*l+a*a*t*t*o*o,g=-(n*n*a*a*t*t*i*i),v=c*c-4*u*f,y=Math.sqrt((u-f)*(u-f)+c*c);s.values[2]=c!==0?Math.atan((f-u-y)/c)*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,m)=>{s.values[m]=w*(m%2===0?t:i)});break}})}function G_(e){let t="";return e.commands.forEach(i=>{t+=i.key+" ",i.values.forEach(s=>{t+=s+" "})}),t}function Z_(e,t,i){const s=q_[e.toUpperCase()],n=[];for(;i<=t.length;){const a={key:e,values:[]};for(const r of s){const l=t.slice(i).match(r);if(l!==null){a.values.push(+l[0]),i+=l[0].length;const o=t.slice(i).match(V_);o!==null&&(i+=o[0].length)}else{if(a.values.length===0)return{cursor:i,commands:n};throw new Error("malformed path (first error at "+i+")")}}if(a.relative=a.key.toUpperCase()!==a.key,n.push(a),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 J_(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 Q_(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:J_(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 t2(e,t){var o;const s=e.calculative.canvas.store.data.paths[e.pathId];if(!s)return new Path2D;const n=Y_(s);e.calculative.svgRect=Cf(n),Qt(e.calculative.svgRect),(e.calculative.svgRect.width!==e.calculative.worldRect.width||e.calculative.svgRect.height!==e.calculative.worldRect.height)&&X_(n,e.calculative.worldRect.width/e.calculative.svgRect.width,e.calculative.worldRect.height/e.calculative.svgRect.height);const a=Cf(n);Qt(a),K_(n,e.calculative.worldRect.x-a.x,e.calculative.worldRect.y-a.y);const r=G_(n);if(t){(o=t.svgPath)==null||o.call(t,r);return}return new Path2D(r)}function e2(e,t){const i=t||new Path2D,{x:s,y:n,width:a,height:r}=e.calculative.worldRect;if(i.moveTo(s+a/2,n),i.lineTo(s+a,n+r/2),i.lineTo(s+a/2,n+r),i.lineTo(s,n+r/2),i.lineTo(s+a/2,n),i.closePath(),i instanceof Path2D)return i}function i2(e,t){const i=t||new Path2D,{x:s,y:n,width:a,height:r}=e.calculative.worldRect;if(i.moveTo(s+a/2,n),i.lineTo(s+a,n+r),i.lineTo(s,n+r),i.lineTo(s+a/2,n),i.closePath(),i instanceof Path2D)return i}function s2(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 n2(e,t){const i=t||new Path2D,{x:s,y:n,width:a,height:r}=e.calculative.worldRect;if(i.moveTo(s+a/2,n),i.lineTo(s+a,n+r*2/5),i.lineTo(s+a*4/5,n+r),i.lineTo(s+a/5,n+r),i.lineTo(s,n+r*2/5),i.closePath(),i instanceof Path2D)return i}function a2(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 r2(e,t){e.onResize||(e.onResize=o2);const i=t||new Path2D,{width:s,height:n,center:a}=e.calculative.worldRect,r=s>n?n:s,l=a.x,o=a.y,u=o-r/2,c=o-r/4,f=-(c-o)*Math.sin(Math.PI/180*324)+l,g=(c-o)*Math.cos(Math.PI/180*324)+o;i.moveTo(f,g);for(let v=0;v<5;++v)i.lineTo(-(u-o)*Math.sin(Math.PI/180*72*v)+l,(u-o)*Math.cos(Math.PI/180*72*v)+o),i.lineTo((f-l)*Math.cos(Math.PI/180*72*(v+1))-(g-o)*Math.sin(Math.PI/180*72*(v+1))+l,(f-l)*Math.sin(Math.PI/180*72*(v+1))+(g-o)*Math.cos(Math.PI/180*72*(v+1))+o);if(i.closePath(),i instanceof Path2D)return i}function cg(e){const{width:t,height:i}=e,s=t>i?i:t,n=[];for(let a=0;a<5;++a)n.push({flag:1,id:String(a),penId:e.id,x:.5+s/2*Math.sin(Math.PI/180*72*a)/t,y:-s/2*Math.cos(Math.PI/180*72*a)/i+.5});e.anchors=n}function o2(e){const t=e.anchors.filter(i=>i.flag!==1);cg(e),e.anchors=e.anchors.concat(...t)}function l2(e,t){const i=t||new Path2D,{x:s,y:n,width:a,height:r}=e.calculative.worldRect;if(i.moveTo(s+a/4,n),i.lineTo(s+a*3/4,n),i.lineTo(s+a,n+r/2),i.lineTo(s+a*3/4,n+r),i.lineTo(s+a*1/4,n+r),i.lineTo(s,n+r/2),i.lineTo(s+a/4,n),i.closePath(),i instanceof Path2D)return i}function c2(e,t){const i=t||new Path2D,{x:s,y:n,width:a,height:r}=e.calculative.worldRect;if(i.moveTo(s,n+r/2),i.lineTo(s+r/2,n),i.lineTo(s+r/2,n+r/3),i.lineTo(s+a,n+r/3),i.lineTo(s+a,n+r*2/3),i.lineTo(s+r/2,n+r*2/3),i.lineTo(s+r/2,n+r*2/3),i.lineTo(s+r/2,n+r),i.closePath(),i instanceof Path2D)return i}function h2(e,t){const i=t||new Path2D,{x:s,y:n,width:a,height:r}=e.calculative.worldRect;if(i.moveTo(s,n+r/3),i.lineTo(s+(a-r/2),n+r/3),i.lineTo(s+(a-r/2),n),i.lineTo(s+a,n+r/2),i.lineTo(s+(a-r/2),n+r),i.lineTo(s+(a-r/2),n+r*2/3),i.lineTo(s,n+r*2/3),i.closePath(),i instanceof Path2D)return i}function u2(e,t){const i=t||new Path2D,{x:s,y:n,width:a,height:r}=e.calculative.worldRect;if(i.moveTo(s,n+r/2),i.lineTo(s+r/2,n),i.lineTo(s+r/2,n+r/3),i.lineTo(s+(a-r/2),n+r/3),i.lineTo(s+(a-r/2),n),i.lineTo(s+a,n+r/2),i.lineTo(s+(a-r/2),n+r),i.lineTo(s+(a-r/2),n+r*2/3),i.lineTo(s+r/2,n+r*2/3),i.lineTo(s+r/2,n+r),i.closePath(),i instanceof Path2D)return i}function f2(e,t){const i=t||new Path2D,{x:s,y:n,width:a,height:r,ey:l}=e.calculative.worldRect;if(i.moveTo(s,n),i.lineTo(s+a,n),i.lineTo(s+a,n+r*3/4),i.lineTo(s+a*8/16,n+r*3/4),i.lineTo(s+a/4,l),i.lineTo(s+a*5/16,n+r*3/4),i.lineTo(s,n+r*3/4),i.closePath(),i instanceof Path2D)return i}function d2(e,t){const i=t||new Path2D,{x:s,y:n,width:a,height:r}=e.calculative.worldRect;if(i.moveTo(s+a/5,n+r*13/16),i.bezierCurveTo(s-a/15,n+r*13/16,s-a/15,n+r*7/16,s+a/5,n+r*7/16),i.bezierCurveTo(s+a/5,n,s+a*4/5,n,s+a*4/5,n+r*7/16),i.bezierCurveTo(s+a*16/15,n+r*7/16,s+a*16/15,n+r*13/16,s+a*4/5,n+r*13/16),i.closePath(),i instanceof Path2D)return i}function g2(e,t){const i=t||new Path2D,{x:s,y:n,width:a,ex:r,ey:l}=e.calculative.worldRect,o=a/6;if(i.moveTo(s,n),i.lineTo(r-o,n),i.lineTo(r,n+o),i.lineTo(r,l),i.lineTo(s,l),i.closePath(),i.moveTo(r-o,n),i.lineTo(r-o,n+o),i.lineTo(r,n+o),i.closePath(),i instanceof Path2D)return i}function v2(e,t){const{x:i,y:s,width:n,ex:a,ey:r}=t.calculative.worldRect;let l=n*.25;const o=t.z;o>1?l=o*t.calculative.canvas.store.data.scale:o>0&&(l=n*o);const u={x:i,y:s+l},c={x:a-l,y:s+l},f={x:a-l,y:r};Il(e,[u,c,f,{x:i,y:r}],t.backgroundFront||t.background,t.color),Il(e,[u,{x:i+l,y:s},{x:a,y:s},c],t.backgroundUp||t.background,t.color),Il(e,[c,{x:a,y:s},{x:a,y:r-l},f],t.backgroundRight||t.background,t.color)}function Il(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 y2(e,t){const i=t||new Path2D,{x:s,y:n,width:a,ex:r,ey:l}=e.calculative.worldRect,o=a/4,u=s+a/2;if(i.arc(u,n+o,o,0,Math.PI*2),i.moveTo(s,n+o*3),i.lineTo(r,n+o*3),i.moveTo(u,n+o*2),i.lineTo(u,n+o*4),i.moveTo(u,n+o*4),i.lineTo(s,l),i.moveTo(u,n+o*4),i.lineTo(r,l),i.closePath(),i instanceof Path2D)return i}function m2(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},Qr(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 a=Pn(s,e.pens[s.connectTo]);Rf(s,a,50),s.prev=void 0}const n=t.calculative.worldAnchors[t.calculative.worldAnchors.length-1];if(n&&n!==s&&!n.prev){const a=Pn(n,e.pens[n.connectTo]);Rf(n,a,-50),n.next=void 0}}}function Rf(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 ec(e,t,i,s){const n=1-e,a=n*n*t.x+2*n*e*i.x+e*e*s.x,r=n*n*t.y+2*n*e*i.y+e*e*s.y;return{x:a,y:r,step:e}}function hg(e,t,i,s,n){const{x:a,y:r}=t,{x:l,y:o}=n,{x:u,y:c}=i,{x:f,y:g}=s,v=1-e,y=a*v*v*v+3*u*e*v*v+3*f*e*e*v+l*e*e*e,w=r*v*v*v+3*c*e*v*v+3*g*e*e*v+o*e*e*e;return{x:y,y:w,step:e}}function cs(e,t,i){return{x:e.x+i*(t.x-e.x),y:e.y+i*(t.y-e.y)}}function p2(e,t,i){let s=e.calculative.worldAnchors[i],n=e.calculative.worldAnchors[i+1];!n&&e.close&&(n=e.calculative.worldAnchors[0]);const a=t.step;let r;if(s.next&&n.prev){const l=s,o=s.next,u=n.prev,c=n,f=cs(l,o,a),g=cs(o,u,a),v=cs(u,c,a),y=cs(f,g,a),w=cs(g,v,a);r=cs(y,w,a),y.penId=e.id,r.prev=y,w.penId=e.id,r.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 l=s,o=s.next||n.prev,u=n,c=cs(l,o,a),f=cs(o,u,a);r=t,c.penId=e.id,f.penId=e.id,r.prev=c,r.next=f,s.next=void 0,n.prev=void 0}else r=t;return r.penId=e.id,r.id=It(),r.prevNextType=Ns.Bilateral,r}function w2(e,t,i){if(t.calculative.worldAnchors||(t.calculative.worldAnchors=[]),t.calculative.worldAnchors.length<2)return;let s=t.calculative.activeAnchor,n=i||$t(t);if(!s||!n)return;const a=20,r=e.pens[s.connectTo];let l=Pn(s,r);switch(l===Lt.None&&(n.x>s.x?l=Lt.Right:l=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},l){case Lt.Up:s.next.y-=a,n.prev.y=s.y;break;case Lt.Bottom:s.next.y+=a,n.prev.y=s.y;break;case Lt.Left:s.next.x-=a,n.prev.x=s.x;break;default:s.next.x+=a,n.prev.x=s.x;break}}function b2(e,t){const i=t||new Path2D;if((e.lineName==="line"||e.lineName==="polyline")&&e.calculative.lineSmooth){let n=pc(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(a=>{n?Tf(i,n,a):a.start=!0,n=a}),e.close&&(e.lineName==="curve"?Tf(i,n,s[0]):i.closePath())}if(i instanceof Path2D)return i}function x2(e,t,i){var a;if(t.calculative.worldAnchors||(t.calculative.worldAnchors=[]),t.calculative.worldAnchors.length<2||((a=t.anchors)==null?void 0:a.length)>1)return;const s=le(t),n=$t(t);!s||!n||!n.id||s===n||(s.next=void 0,bc(t),n.prev=void 0,t.calculative.worldAnchors.push(n))}function Tf(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 ic(e){return Yr(e),ka(ug(e))}function ug(e){const t=[];let i;return e.calculative.worldAnchors.forEach(s=>{t.push(s),i&&t.push(...Sf(i,s,e)),i=s}),e.close&&e.calculative.worldAnchors.length>1&&t.push(...Sf(i,e.calculative.worldAnchors[0],e)),t}function qr(e){return e!=null&&e.lineWidth?e.lineWidth/2+4:4}function Sf(e,t,i){const s=[];if(!t)return s;let n=.02;if(e.lineLength&&!i.parentId&&(n=qr(i)/e.lineLength),e.next)if(t.prev)for(let a=n;a<1;a+=n)s.push(hg(a,e,e.next,t.prev,t));else for(let a=n;a<1;a+=n)s.push(ec(a,e,e.next,t));else if(t.prev)for(let a=n;a<1;a+=n)s.push(ec(a,e,t.prev,t));else s.push({x:t.x,y:t.y});return s.length>1&&(e.curvePoints=s),s}function _2(e,t){const i=qr(t);let s=0,n,a;for(const r of t.calculative.worldAnchors){if(n){if(a=Pf(e,n,r,i),a)return{i:s,point:a};++s}n=r}if(t.close&&t.calculative.worldAnchors.length>1&&(a=Pf(e,n,t.calculative.worldAnchors[0],i)))return{i:s,point:a}}function Pf(e,t,i,s=4){if(!t.next&&!i.prev){const{x:n,y:a}=t,{x:r,y:l}=i,o=Math.min(n,r),u=Math.max(n,r),c=Math.min(a,l),f=Math.max(a,l);return e.x>=o-s&&e.x<=u+s&&e.y>=c-s&&e.y<=f+s?k2(e,t,i,s):void 0}else if(t.curvePoints){for(const n of t.curvePoints)if(mn(e,n,s))return n}}function k2(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),a=t.y-n*t.x;if(Math.abs((n*e.x+a-e.y)/Math.sqrt(n*n+1))<=s){const o=(e.x+n*e.y-n*a)/(n*n+1);return{x:o,y:n*o+a}}}}function If(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 Yr(e){if(e.calculative.worldAnchors.length<2)return 0;let t=0,i;if(e.calculative.worldAnchors.forEach(s=>{i&&(i.lineLength=If(i,i.next,s.prev,s),t+=i.lineLength),i=s}),e.close){const s=le(e);i.lineLength=If(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 Ll(e,t){const i=e.calculative.worldAnchors;for(let s=0;s<i.length-1;s++){const n=i[s],a=i[s+1];if(!n.next&&!a.prev){if(fg(n,a,t))return!0}else if(E2(n,a,t))return!0}return!1}function fg(e,t,i){if(Ws(e,i)||Ws(t,i))return!0;const s=e.x,n=e.y,a=t.x,r=t.y;let l=i.x,o=i.y,u=i.ex,c=i.ey;const f=n-r,g=a-s,v=s*r-a*n;if(f*l+g*o+v>=0&&f*u+g*c+v<=0||f*l+g*o+v<=0&&f*u+g*c+v>=0||f*l+g*c+v>=0&&f*u+g*o+v<=0||f*l+g*c+v<=0&&f*u+g*o+v>=0){if(l>u){const y=l;l=u,u=y}if(o<c){const y=o;o=c,c=y}return!(s<l&&a<l||s>u&&a>u||n>o&&r>o||n<c&&r<c)}else return!1}function E2(e,t,i){if(!e.next&&!t.prev)return fg(e,t,i);if(e.next&&t.prev)for(let n=.02;n<1;n+=.02){const a=hg(n,e,e.next,t.prev,t);if(Ws(a,i))return!0}else if(e.next||t.prev)for(let n=.02;n<1;n+=.02){const a=ec(n,e,e.next||t.prev,t);if(Ws(a,i))return!0}return!1}function Lf(e,t,i,s,n){let a="";return e||(a+=`M${t.x} ${t.y} `,e=document.createElementNS("http://www.w3.org/2000/svg","path"),e.setAttribute("d",a)),a=e.getAttribute("d")||"",i&&s?a+=`C${i.x} ${i.y} ${s.x} ${s.y} ${n.x} ${n.y}`:i?a+=`Q${i.x} ${i.y} ${n.x} ${n.y}`:a+=`Q${(s==null?void 0:s.x)||t.x} ${(s==null?void 0:s.y)||t.y} ${n.x} ${n.y}`,e.setAttribute("d",a),e}function A2(e,t){const i=e.getTotalLength();if(t<0||t>i)return null;const s=.01,n=e.getPointAtLength(t),a=e.getPointAtLength(t-s),r=Math.atan2(n.y-a.y,n.x-a.x);return{x:n.x,y:n.y,rotate:r/Math.PI*180,progress:t/i}}let Ue=10;function C2(e,t,i){var w;if(t.calculative.worldAnchors||(t.calculative.worldAnchors=[]),Ue=e.options.polylineSpace||10,t.calculative.worldAnchors.length<2)return;let s=le(t),n=$t(t);if(!s||!n)return;let a;if(((w=t.anchors)==null?void 0:w.length)&&s===t.calculative.activeAnchor?(a=!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 r=n.connectTo;bc(t);const l=[],o=e.pens[s.connectTo],u=e.pens[n.connectTo],c=Pn(s,o),f=Pn(n,u);let g=Df(s,c,Ue);g&&(s=g,l.push(g)),g=Df(n,f,Ue);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 m=Ue;s.x<g.x&&(m=-m),Math.abs(s.x-g.x)<m&&(m=-m),n={x:g.x+m,y:g.y,id:It()}}switch(c){case Lt.Up:l.push(...R2(s,n,f));break;case Lt.Right:l.push(...T2(s,n,f));break;case Lt.Bottom:l.push(...S2(s,n,f));break;case Lt.Left:l.push(...P2(s,n,f));break;default:l.push(...I2(t,s,n));break}if(l.forEach(m=>{m.id=It(),m.penId=t.id,t.calculative.worldAnchors.push(m)}),t.calculative.worldAnchors.push(n),y&&t.calculative.worldAnchors.push(y),g&&t.calculative.worldAnchors.push(v),a&&t.calculative.worldAnchors.reverse(),r){const m=t.calculative.worldAnchors.length-2;t.calculative.worldAnchors[m].isTemp=!1,t.calculative.worldAnchors[1].isTemp=!1}}function Df(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 R2(e,t,i){if(e.x===t.x||e.y===t.y)return[];const s=[];let n,a;switch(i){case Lt.Up:e.y<t.y?(n=t.x,a=e.y):(n=e.x,a=t.y),s.push({x:n,y:a});break;case Lt.Bottom:if(n=t.x,a=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 r=(e.y+t.y)/2;s.push({x:e.x,y:r},{x:t.x,y:r})}break;case Lt.Right:n=t.x,a=e.y,t.x<e.x&&t.y<e.y&&(n=e.x,a=t.y),s.push({x:n,y:a});break;case Lt.Left:n=t.x,a=e.y,t.x>e.x&&t.y<e.y&&(n=e.x,a=t.y),s.push({x:n,y:a});break;default:if(t.y>e.y-Ue)n=e.x+(t.x-e.x)/2,s.push({x:n,y:e.y},{x:n,y:t.y});else{const r=(e.y+t.y+Ue)/2;s.push({x:e.x,y:r},{x:t.x,y:r})}break}return s}function T2(e,t,i){if(e.x===t.x||e.y===t.y)return[];const s=[];let n,a;switch(i){case Lt.Up:n=e.x,a=t.y,t.x>e.x&&t.y>e.y&&(n=t.x,a=e.y),s.push({x:n,y:a});break;case Lt.Bottom:n=e.x,a=t.y,t.x>e.x&&t.y<e.y&&(n=t.x,a=e.y),s.push({x:n,y:a});break;case Lt.Left:if(n=t.x,a=e.y,t.x<e.x)a=e.y+(t.y-e.y)/2,s.push({x:e.x,y:a},{x:t.x,y:a});else{const r=(e.x+t.x)/2;s.push({x:r,y:a},{x:r,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,a=t.y,t.x<e.x+Ue)s.push({x:e.x,y:a});else{const r=(e.x+t.x-Ue)/2;s.push({x:r,y:e.y},{x:r,y:a})}break}return s}function S2(e,t,i){if(e.x===t.x||e.y===t.y)return[];const s=[];let n,a;switch(i){case Lt.Up:if(n=e.x,a=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 r=(e.y+t.y)/2;s.push({x:n,y:r},{x:t.x,y:r})}break;case Lt.Right:n=t.x,a=e.y,t.x<e.x&&t.y>e.y&&(n=e.x,a=t.y),s.push({x:n,y:a});break;case Lt.Bottom:e.y>t.y?(n=t.x,a=e.y):(n=e.x,a=t.y),s.push({x:n,y:a});break;case Lt.Left:n=t.x,a=e.y,t.x>e.x&&t.y>e.y&&(n=e.x,a=t.y),s.push({x:n,y:a});break;default:if(n=e.x,t.y<e.y+Ue)n=e.x+(t.x-e.x)/2,s.push({x:n,y:e.y},{x:n,y:t.y});else{const r=(e.y+t.y-Ue)/2;s.push({x:n,y:r},{x:t.x,y:r})}break}return s}function P2(e,t,i){if(e.x===t.x||e.y===t.y)return[];const s=[];let n,a;switch(i){case Lt.Up:n=e.x,a=t.y,t.x<e.x&&t.y>e.y&&(n=t.x,a=e.y),s.push({x:n,y:a});break;case Lt.Bottom:n=e.x,a=t.y,t.x<e.x&&t.y<e.y&&(n=t.x,a=e.y),s.push({x:n,y:a});break;case Lt.Right:if(n=e.x,a=t.y,t.x>e.x)n=t.x,a=e.y+(t.y-e.y)/2,s.push({x:e.x,y:a},{x:t.x,y:a});else{const r=(e.x+t.x)/2;s.push({x:r,y:e.y},{x:r,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,a=t.y,t.x<e.x-Ue){const r=(e.x+t.x+Ue)/2;s.push({x:r,y:e.y},{x:r,y:a})}else s.push({x:e.x,y:a});break}return s}function I2(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(a=>a.id==t.id);if(n>1){let a=e.calculative.worldAnchors[n-1];if(a.x===t.x&&a.y!==t.y)return s.push({x:i.x,y:t.y}),s;if(a.y===t.y&&a.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)<Ue&&(i.isTemp=!0)):(s.push({x:t.x,y:i.y}),Math.abs(i.x-t.x)<Ue&&(i.isTemp=!0))),s}function br(e,t,i=!0){var n,a;let s=e.calculative.worldAnchors;i||(s=[],e.calculative.worldAnchors.forEach(r=>{s.unshift(r)}));for(let r=0;r<s.length&&s[r].id!==t.id;r++)if(s[r].y!==t.y||s[r].x===((n=s[r+1])==null?void 0:n.x)&&s[r].y!==((a=s[r+1])==null?void 0:a.y))return!1;return!0}function xr(e,t,i=!0){var n,a;let s=e.calculative.worldAnchors;i||(s=[],e.calculative.worldAnchors.forEach(r=>{s.unshift(r)}));for(let r=0;r<s.length&&s[r].id!==t.id;r++)if(s[r].x!==t.x||s[r].y===((n=s[r+1])==null?void 0:n.y)&&s[r].x!==((a=s[r+1])==null?void 0:a.x))return!1;return!0}function L2(e,t,i){if(!e.calculative.worldAnchors)return;const s=e.calculative.worldAnchors.findIndex(o=>o.id===t.id),n=le(e),a=$t(e);let r=e.calculative.worldAnchors[s-1],l=e.calculative.worldAnchors[s+1];if(e.calculative.h==null&&(n.connectTo&&(br(e,t,!0)?e.calculative.h=!0:xr(e,t,!0)&&(e.calculative.h=!1)),e.calculative.h==null&&a.connectTo&&(br(e,t,!1)?e.calculative.h=!0:xr(e,t,!1)&&(e.calculative.h=!1)),e.calculative.h==null&&(r?e.calculative.h=r.y===t.y:l&&(e.calculative.h=l.y===t.y))),e.calculative.h){if(t.x=i.x,n.connectTo&&br(e,t,!0)){l&&l.y!==t.y&&(l.x=t.x);return}if(a.connectTo&&br(e,t,!1)){r&&r.y!==t.y&&(r.x=t.x);return}const o=e.anchors[s];let u;for(let c=s-1;c>-1;c--)if(r=e.anchors[c],u==null&&(u=r.y===o.y),u===!0)if(r.y===o.y)e.calculative.worldAnchors[c].y=i.y;else break;else if(r.x===o.x)e.calculative.worldAnchors[c].x=i.x;else break;u=void 0;for(let c=s+1;c<e.calculative.worldAnchors.length&&(l=e.anchors[c],l);c++)if(u==null&&(u=l.y===o.y),u===!0)if(l.y===o.y)e.calculative.worldAnchors[c].y=i.y;else break;else if(l.x===o.x)e.calculative.worldAnchors[c].x=i.x;else break;t.y=i.y}else{if(t.y=i.y,n.connectTo&&xr(e,t,!0)){l&&l.x!==t.x&&(l.y=t.y);return}if(a.connectTo&&xr(e,t,!1)){r&&r.x!==t.x&&(r.y=t.y);return}const o=e.anchors[s];let u;for(let c=s-1;c>-1;c--)if(r=e.anchors[c],u==null&&(u=r.x===o.x),u===!0)if(r.x===o.x)e.calculative.worldAnchors[c].x=i.x;else break;else if(r.y===o.y)e.calculative.worldAnchors[c].y=i.y;else break;u=void 0;for(let c=s+1;c<e.calculative.worldAnchors.length&&(l=e.anchors[c],l);c++)if(u==null&&(u=l.x===o.x),u===!0)if(l.x===o.x)e.calculative.worldAnchors[c].x=i.x;else break;else if(l.y===o.y)e.calculative.worldAnchors[c].y=i.y;else break;t.x=i.x}}function sc(e,t,i,s){const n=[];let a,r,l,o,u,c,f,g,v,y,w,m,_,E;v=e[i],y=e[s],l=v.x,o=v.y,f=y.x-l,g=y.y-o,E=f*f+g*g,a=t;for(let x=i+1;x<s;x++)w=e[x],f!==0||g!==0?(m=((w.x-l)*f+(w.y-o)*g)/E,m>1?(u=w.x-y.x,c=w.y-y.y):m>0?(u=w.x-(l+f*m),c=w.y-(o+g*m)):(u=w.x-l,c=w.y-o)):(u=w.x-l,c=w.y-o),_=u*u+c*c,_>a&&(r=x,a=_);return a>t&&(r-i>1&&n.push(...sc(e,t,i,r)),n.push({id:e[r].id,penId:e[r].penId,x:e[r].x,y:e[r].y}),s-r>1&&n.push(...sc(e,t,r,s))),n}function D2(e,t=.8,i=!1){if(e.length<3)return e;let s,n,a,r,l,o,u,c,f,g,v,y,w,m,_;const E=(x,C,S,L)=>(r=Math.sqrt(x*x+C*C),r>0?(y=x/r,m=C/r):(y=1,m=0),l=Math.sqrt(S*S+L*L),l>0?(w=S/l,_=L/l):(w=1,_=0),Math.acos(y*w+m*_));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],a=e[x+1],f=Math.abs(E(n.x-s.x,n.y-s.y,a.x-n.x,a.y-n.y)),r)if(f<t*3.14)if(i&&(r=Math.min(r,l),l=r),o=(y+w)/2,u=(m+_)/2,c=Math.sqrt(o*o+u*u),c===0)g.push({...n});else{o/=c,u/=c;const C={...n};C.prevNextType=Ns.Bilateral,C.prev={penId:C.penId,x:n.x-o*r*.25,y:n.y-u*r*.25},C.next={penId:C.penId,x:n.x+o*l*.25,y:n.y+u*l*.25},g.push(C)}else g.push({...n});s=n}return g.push({...e[e.length-1]}),g}function dg(e,t){const i=t||new Path2D,s=e.calculative.worldAnchors;let n=e.calculative.canvas.store.data.scale,a=(e.calculative.animateLineWidth||6)*n,r=(e.animateLineWidth*2||12)*n;e.lineAnimateType===We.WaterDrop&&(r=(e.animateLineWidth*4||24)*n);let l=(e.animateInterval||100)*n,o=e.calculative.lineWidth*(e.calculative.lineSmooth||0),u=(e.calculative.animateLineWidth/2||3)*n;if(e.animateReverse&&(r=-r,a=-a),s.length>1){let c,f=0;for(let g=0;g<s.length;g++){let v=s[g];if(c){let y=M2(c,v),w={x:c.x+(e.calculative.animatePos-f)%l*Math.cos(y*Math.PI/180),y:c.y-(e.calculative.animatePos-f)%l*Math.sin(y*Math.PI/180)};e.animateReverse&&(w={x:c.x+(e.length-(e.calculative.animatePos+f))%l*Math.cos(y*Math.PI/180),y:c.y-(e.length-(e.calculative.animatePos+f))%l*Math.sin(y*Math.PI/180)});let m=Math.sqrt((w.x-c.x)**2+(w.y-c.y)**2),_=Math.sqrt((v.x-c.x)**2+(v.y-c.y)**2);for(;m<_;)(e.animateReverse&&m-r<_||!e.animateReverse&&m>r)&&m>o+r&&_-m>o&&(e.lineAnimateType===We.Arrow?B2(i,w,a,y,u,r):e.lineAnimateType===We.WaterDrop&&O2(i,w,e.animateReverse,y,u,r)),w.x+=l*Math.cos(y*Math.PI/180),w.y-=l*Math.sin(y*Math.PI/180),m=Math.sqrt((w.x-c.x)**2+(w.y-c.y)**2)}c=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 vs(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 B2(e,t,i,s,n,a){let r=vs({x:t.x+i,y:t.y+.57*i},{x:t.x,y:t.y},s),l=vs({x:t.x+i,y:t.y-.57*i},{x:t.x,y:t.y},s),o=vs({x:t.x+i,y:t.y+n/2},{x:t.x,y:t.y},s),u=vs({x:t.x+a,y:t.y+n/2},{x:t.x,y:t.y},s),c=vs({x:t.x+i,y:t.y-n/2},{x:t.x,y:t.y},s),f=vs({x:t.x+a,y:t.y-n/2},{x:t.x,y:t.y},s);e.moveTo(r.x,r.y),e.lineTo(t.x,t.y),e.lineTo(l.x,l.y),e.lineTo(c.x,c.y),e.lineTo(f.x,f.y),e.lineTo(u.x,u.y),e.lineTo(o.x,o.y),e.lineTo(r.x,r.y)}function O2(e,t,i,s,n,a){let r=n/2;i&&(r=-n/2);let l=vs({x:t.x,y:t.y+r},{x:t.x,y:t.y},s),o=vs({x:t.x+a,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(o.x,o.y),e.lineTo(l.x,l.y)}function F2(e){var i;e.onDestroy||(e.onDestroy=N2,e.onMove=_r,e.onResize=_r,e.onRotate=_r,e.onValue=_r,e.onMouseMove=H2,e.onBeforeValue=z2,e.onRenderPenRaw=W2),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),Re(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),vg(e),n.onload=()=>{n.setAttribute("document.domain","")}}return e.calculative.patchFlags&&Re(e,e.calculative.singleton.div),e.onRenderPenRaw(e),new Path2D}function N2(e){yg(e),e.calculative.singleton&&e.calculative.singleton.div&&(e.calculative.singleton.div.remove(),delete e.calculative.singleton.div)}function _r(e){e.calculative.singleton.div&&Re(e,e.calculative.singleton.div)}function z2(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?vg(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 H2(e,t){if(!(!e.calculative.canvas.store.data.locked&&!e.locked)&&gg(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 gg(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 vg(e){if(!gg(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 a=document.createElement("div");a.style.position="absolute",a.style.left="0px",a.style.top="0px",a.style.width=e.operationalRect.x*100+"%",a.style.height="100%",a.style["backdrop-filter"]=`blur(${e.blur||2}px)`,a.style.backgroundColor=e.blurBackground,t.appendChild(a);let r=()=>{yg(e)};i.onmouseenter=r,n.onmouseenter=r,s.onmouseenter=r,a.onmouseenter=r,t.onmouseleave=r}function yg(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 W2(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 $e={},Dr=['<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 U2(e){var t;if(e.onDestroy||(e.onDestroy=$2,e.onMove=Dl,e.onResize=Dl,e.onRotate=Dl,e.onClick=Mf,e.onValue=V2,e.onChangeId=j2),$e[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=Dr[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=r=>{r.stopPropagation(),e.calculative.media.muted?(n.innerHTML=Dr[0],e.calculative.media.muted=!1):(n.innerHTML=Dr[1],e.calculative.media.muted=!0)},e.calculative.singleton||(e.calculative.singleton={}),e.calculative.singleton.muted=n,i.onmouseenter=r=>{e.hideMuted||(n.style.display="block")},i.onmouseleave=r=>{n.style.display="none"},i.onclick=r=>{r.stopPropagation(),Mf(e)};let a;e.audio?(a=document.createElement("audio"),a.controls=e.controls,a.src=e.audio):(a=document.createElement("video"),a.src=e.video),a.loop=e.playLoop,a.ontimeupdate=()=>{mg(s,a,e.calculative.worldRect.width)},a.onended=()=>{e.calculative.onended&&e.calculative.onended(e)},e.calculative.media=a,a.style.position="absolute",a.style.outline="none",a.style.left="0",a.style.top="0",a.style.width="100%",a.style.height="100%",a.style.objectFit=e.objectFit||"contain",i.appendChild(a),$e[e.id]=i,(t=e.calculative.canvas.externalElements)==null||t.parentElement.appendChild(i),Re(e,i),e.autoPlay&&(a.autoplay=!0,a.muted=!0)}return e.calculative.patchFlags&&Re(e,$e[e.id]),new Path2D}function $2(e){$e[e.id].onclick=null,$e[e.id].remove(),$e[e.id]=void 0}function Dl(e){Re(e,$e[e.id]);const t=$e[e.id].children[0],i=$e[e.id].children[1];mg(t,i,e.calculative.worldRect.width)}function Mf(e){e.calculative.media&&(e.calculative.media.muted=!1,e.calculative.singleton.muted.innerHTML=Dr[0],e.calculative.media.paused?e.calculative.media.play():e.calculative.media.pause())}function mg(e,t,i){e.style.width=t.currentTime/t.duration*i+"px"}function j2(e,t,i){!$e[t]||($e[i]=$e[t],delete $e[t])}function V2(e){const t=$e[e.id];if(!t)return;Re(e,t),e.calculative.media||(e.calculative.media=t.querySelector("video"));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 oa{constructor(t,i){W(this,"parentElement");W(this,"store");W(this,"box");W(this,"text");W(this,"arrowUp");W(this,"arrowDown");W(this,"x");W(this,"y");W(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=oa.getTitle(t);if(s){this.text.innerHTML=s(n);const a=this.text.getElementsByTagName("A");for(let r=0;r<a.length;++r)a[r].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||oa.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,oa.titleEmpty(t)){let l=ti(t,!0);l&&this.show(l,i);return}this.setText(t);const s=this.box.getBoundingClientRect(),n=t.calculative.worldRect;let a=t.calculative.canvas.store.data.x+i.x-s.width/2,r=t.calculative.canvas.store.data.y+i.y-s.height;t.type||(a=t.calculative.canvas.store.data.x+n.x-(s.width-n.width)/2,r=t.calculative.canvas.store.data.y+n.ey-s.height-n.height),r>0?(this.arrowUp.style.borderBottomColor="transparent",this.arrowDown.style.borderTopColor="#777777"):(r+=s.height+n.height+5,this.arrowUp.style.borderBottomColor="#777777",this.arrowDown.style.borderTopColor="transparent"),this.x=a,this.y=r,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 pg{constructor(t){W(this,"parent");W(this,"h");W(this,"v");W(this,"isDownH");W(this,"isDownV");W(this,"x");W(this,"y");W(this,"hSize");W(this,"vSize");W(this,"scrollX");W(this,"scrollY");W(this,"lastScrollX");W(this,"lastScrollY");W(this,"rect");W(this,"isShow");W(this,"pageMode");W(this,"onMouseDownH",t=>{t.preventDefault(),t.stopPropagation(),this.isDownH=t.x,this.x=this.parent.store.data.x||0,this.lastScrollX=this.scrollX});W(this,"onMouseDownV",t=>{t.preventDefault(),t.stopPropagation(),this.isDownV=t.y,this.y=this.parent.store.data.y||0,this.lastScrollY=this.scrollY});W(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())});W(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=hi(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 Bf{constructor(t,i,s){W(this,"parentElement");W(this,"store");W(this,"isBottom");W(this,"canvas",document.createElement("canvas"));W(this,"otherOffsreen",Pi());W(this,"offscreen",Pi());W(this,"animateOffsScreen",Pi());W(this,"fitOffscreen",Pi());W(this,"fitFlag",!1);W(this,"currentFit");W(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 r;let t=!1,i=!1;for(const l of this.store.data.pens)this.hasImage(l)&&(this.store.animates.has(l)?i=!0:l.calculative.imageDrawed||(t=!0),l.parentId&&this.store.animates.has(ti(l,!0))&&(i=!0));const s=this.store.patchFlagsBackground,n=this.store.patchFlagsTop;if(n&&!this.isBottom){const l=this.otherOffsreen.getContext("2d");l.clearRect(0,0,this.canvas.width,this.canvas.height),this.renderRule(l)}if(this.store.patchFlagsLast&&this.offscreen.getContext("2d").clearRect(0,0,this.canvas.width,this.canvas.height),t){const l=this.offscreen.getContext("2d");l.save(),l.clearRect(0,0,this.canvas.width,this.canvas.height),l.translate(this.store.data.x,this.store.data.y);for(const o of this.store.data.pens)!o.calculative.hasImage||this.store.animates.has(o)||this.store.animates.has(ti(o,!0))||o.canvasLayer!==zt.CanvasTemplate&&(o.calculative.imageDrawed=!0,l.save(),zs(l,o),o.calculative.rotate&&Gi(l,o),Hs(l,o),En(l,o),l.restore());l.restore()}if(i){const l=this.animateOffsScreen.getContext("2d");l.save(),l.clearRect(0,0,this.canvas.width,this.canvas.height),l.translate(this.store.data.x,this.store.data.y);for(const o of this.store.animates)!o.calculative.hasImage||o.canvasLayer!==zt.CanvasTemplate&&(o.visible===!1||o.calculative.visible===!1||(o.calculative.imageDrawed=!0,l.save(),zs(l,o),o.calculative.rotate&&Gi(l,o),Hs(l,o),En(l,o),l.restore()));for(const o of this.store.data.pens)!o.calculative.hasImage||!o.parentId||o.canvasLayer!==zt.CanvasTemplate&&(o.visible===!1||o.calculative.visible===!1||this.store.animates.has(ti(o,!0))&&(o.calculative.imageDrawed=!0,l.save(),zs(l,o),o.calculative.rotate&&Gi(l,o),Hs(l,o),En(l,o),l.restore()));l.restore()}if(!this.isBottom&&!this.store.data.locked&&this.fitFlag){const l=(this.store.data.width||this.store.options.width)*this.store.data.scale,o=(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,c=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,(r=this.store.data.fits)==null||r.forEach((g,v)=>{f.fillRect(u+l*g.x,c+o*g.y,l*g.width,o*g.height),g.active&&f.strokeRect(u+l*g.x,c+o*g.y,l*g.width,o*g.height)}),f.restore()}if(t||i||s&&this.isBottom||n&&!this.isBottom){const l=this.canvas.getContext("2d");l.clearRect(0,0,this.canvas.width,this.canvas.height),this.isBottom&&(this.store.patchFlagsBackground=!1),l.drawImage(this.offscreen,0,0,this.canvas.width,this.canvas.height),l.drawImage(this.animateOffsScreen,0,0,this.canvas.width,this.canvas.height),this.isBottom||(l.drawImage(this.otherOffsreen,0,0,this.canvas.width,this.canvas.height),this.store.patchFlagsTop=!1,!this.store.data.locked&&this.fitFlag&&l.drawImage(this.fitOffscreen,0,0,this.canvas.width,this.canvas.height))}}renderRule(t){var x,C,S,L,M,D,$,Q;const{data:i,options:s}=this.store,{rule:n,ruleColor:a,scale:r,origin:l}=i;if(!(n!=null?n:s.rule))return;const o=r*10;t.save();const u=a||s.ruleColor||"#ccc";t.strokeStyle=Wr(u,.7);const c=l.x+i.x,f=l.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()),(L=s.ruleOptions)!=null&&L.underline&&(t.beginPath(),t.fillStyle=Wr(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;((M=s.ruleOptions)==null?void 0:M.baseline)==="bottom"&&(w=y*3/4),t.beginPath(),t.lineWidth=y/2,t.lineDashOffset=-c%o,t.setLineDash([1,o-1]),t.moveTo(0,w),t.lineTo(g,w),t.stroke(),t.beginPath(),t.lineDashOffset=-f%o,t.moveTo(w,0),t.lineTo(w,v),t.stroke(),t.strokeStyle=u,t.beginPath(),t.lineWidth=y,t.lineDashOffset=-c%(o*10),t.setLineDash([1,o*10-1]),t.moveTo(0,y/2),t.lineTo(g,y/2),t.stroke(),t.beginPath(),t.lineDashOffset=-f%(o*10),t.moveTo(y/2,0),t.lineTo(y/2,v),t.stroke(),t.beginPath(),t.fillStyle=((D=s.ruleOptions)==null?void 0:D.textColor)||t.strokeStyle;let m=0-Math.floor(c/o/10)*100,_=(($=s.ruleOptions)==null?void 0:$.textTop)||16,E=((Q=s.ruleOptions)==null?void 0:Q.textLeft)||4;c<0&&(m-=100);for(let R=c%(o*10);R<g;R+=10*o,m+=100)o<3&&m%500||t.fillText(m.toString(),R+E,_);m=0-Math.floor(f/o/10)*100,f<0&&(m-=100);for(let R=f%(o*10);R<v;R+=10*o,m+=100)o<3&&m%500||(t.save(),t.beginPath(),t.translate(_,R-E),t.rotate(270*Math.PI/180),t.fillText(m.toString(),0,0),t.restore());t.restore()}}class q2{constructor(t,i,s){W(this,"parentCanvas");W(this,"parentElement");W(this,"store");W(this,"canvas",document.createElement("canvas"));W(this,"magnifierScreen",Pi());W(this,"offscreen",Pi());W(this,"domOffscreen",Pi());W(this,"magnifierSize",300);W(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(o=>{s.drawImage(o,n.x-t,n.y-t,this.magnifierSize,this.magnifierSize,0,0,this.magnifierSize,this.magnifierSize)}),s.restore(),s.beginPath();const r=s.createRadialGradient(t,t,t-5,t,t,t);r.addColorStop(0,"rgba(0,0,0,0.2)"),r.addColorStop(.8,"rgb(200,200,200)"),r.addColorStop(.9,"rgb(200,200,200)"),r.addColorStop(1,"rgba(200,200,200,0.9)"),s.strokeStyle=r,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:a,height:r}=i.calculative.worldRect;t.drawImage(i.calculative.img,s,n,a,r),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 wg(e){if(e.data.locked)throw new Error("canvas is locked")}class Y2{constructor(t,i){W(this,"parentElement");W(this,"box");W(this,"iframe");W(this,"dialog");W(this,"close");W(this,"title");W(this,"body");W(this,"x");W(this,"y");W(this,"url");W(this,"meta2dDiv");W(this,"dialogMeta2d");W(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=a=>{a.stopPropagation()},this.box.onclick=()=>{this.hide()},this.close.onclick=()=>{this.hide()};let n;for(let a=0;a<document.styleSheets.length;a++)document.styleSheets[a].title==="le5le.com/dialog"&&(n=document.styleSheets[a]);if(!n){let a=document.createElement("style");a.type="text/css",a.title="le5le.com/dialog",document.head.appendChild(a),a=document.createElement("style"),a.type="text/css",document.head.appendChild(a),n=a.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;
- 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 a=this.isUrl(i);if(a?(this.meta2dDiv.style.display="none",this.iframe.style.display="block"):(this.iframe.style.display="none",this.meta2dDiv.style.display="block"),a&&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.body.style.background="#1e2430"):(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",this.body.style.background="transparent"),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%"} )`),a&&n){let r=0;const l=setInterval(()=>{this.iframe.contentWindow.meta2d&&(clearInterval(l),setTimeout(()=>{this.iframe.contentWindow.postMessage(JSON.stringify({name:"dialog",data:n}),"*")},100)),r++,r>50&&clearInterval(l)},300)}if((!this.dialogMeta2d||a)&&(this.box.style.display="block"),!a){this.meta2dDiv.style.display="block",this.dialogMeta2d||(globalThis.mainMeta2d=globalThis.meta2d,this.dialogMeta2d=new Ak(this.meta2dDiv),globalThis.meta2d=globalThis.mainMeta2d);const r=await $d(this.store,i);r&&(this.box.style.display="block",this.dialogMeta2d.clear(!0),this.dialogMeta2d.open(r,!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 Kr{constructor(t){W(this,"parentElement");W(this,"box");W(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&&(Kr.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(Kr.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 K2{constructor(t,i){W(this,"parentElement");W(this,"store");W(this,"canvas",document.createElement("canvas"));W(this,"offscreen",Pi());W(this,"bgOffscreen",Pi());W(this,"patchFlags");W(this,"bgPatchFlags");W(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,a=this.store.data.x||this.store.options.x||0,r=this.store.data.y||this.store.options.y||0,l=this.store.data.background||this.store.styles.background;l&&(i.save(),i.fillStyle=l,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+a,this.store.data.origin.y+r,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+a,this.store.data.origin.y+r,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)!isFinite(s.x)||s.canvasLayer===zt.CanvasTemplate&&s.calculative.inView&&(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),En(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:a,gridColor:r,gridSize:l,scale:o,origin:u}=i;if(!(n!=null?n:s.grid))return;t.save();const c=(i.width||s.width)*o,f=(i.height||s.height)*o,g=(i.x||s.x||0)+u.x,v=(i.y||s.y||0)+u.y;t.lineWidth=1,t.strokeStyle=r||s.gridColor,t.beginPath();let y=(l||s.gridSize)*o;if(y=y<0?0:y,!c||!f){const w=this.store.dpiRatio,m=this.canvas.width/w,_=this.canvas.height/w,E=g/y,x=v/y,C=y*10,S=g-Math.ceil(E)*y,L=v-Math.ceil(x)*y,M=m+S+C,D=_+L+C;if(a){const $=a*Math.PI/180,Q=$+Math.PI/2,R={x:Math.sin($),y:-Math.cos($)},T={x:Math.sin(Q),y:-Math.cos(Q)};Of(t,m,_,y,R),Of(t,m,_,y,T)}else{for(let $=S;$<=M;$+=y)t.moveTo($,L),t.lineTo($,_+L+C);for(let $=L;$<=D;$+=y)t.moveTo(S,$),t.lineTo(m+S+C,$)}}else if(a){const w=a*Math.PI/180,m=w+Math.PI/2,_={x:Math.sin(w),y:-Math.cos(w)},E={x:Math.sin(m),y:-Math.cos(m)};Ff(t,g,v,c,f,y,_),Ff(t,g,v,c,f,y,E)}else{const w=c+g,m=f+v;for(let _=g;_<=w;_+=y)t.moveTo(_,v),t.lineTo(_,f+v);for(let _=v;_<=m;_+=y)t.moveTo(g,_),t.lineTo(c+g,_)}t.stroke(),t.restore()}}function Of(e,t,i,s,n,a){const r=[{x:0,y:0},{x:t,y:0},{x:t,y:i},{x:0,y:i}];let l=1/0,o=-1/0;r.forEach(c=>{const f=c.x*n.x+c.y*n.y;l=Math.min(l,f),o=Math.max(o,f)});const u=Math.ceil((o-l)/s);e.beginPath();for(let c=0;c<=u;c++){const f=l+c*s;let g=[];for(let v=0;v<r.length;v++){const y=r[v],w=r[(v+1)%r.length],m=n.x*(w.y-y.y)-n.y*(w.x-y.x);if(Math.abs(m)>1e-6){const _=(f-y.x*n.x-y.y*n.y)/(n.x*(w.x-y.x)+n.y*(w.y-y.y));if(_>=0&&_<=1){const E=y.x+_*(w.x-y.x),x=y.y+_*(w.y-y.y);g.push({x:E,y:x})}}}g.length>=2&&(e.moveTo(g[0].x,g[0].y),e.lineTo(g[1].x,g[1].y))}e.stroke()}function Ff(e,t,i,s,n,a,r,l){const o=[{x:t,y:i},{x:t+s,y:i},{x:t+s,y:i+n},{x:t,y:i+n}];let u=1/0,c=-1/0;o.forEach(y=>{const w=y.x*r.x+y.y*r.y;u=Math.min(u,w),c=Math.max(c,w)});const f=c-u,g=Math.ceil(f/a),v=u;e.beginPath();for(let y=0;y<=g;y++){const w=v+y*a,m=[];for(let _=0;_<o.length;_++){const E=o[_],x=o[(_+1)%4],C=x.x-E.x,S=x.y-E.y,L=r.x*S-r.y*C;if(Math.abs(L)>1e-6){const M=(w-E.x*r.x-E.y*r.y)/(r.x*C+r.y*S);M>=0&&M<=1&&m.push({x:E.x+M*C,y:E.y+M*S})}}m.length>=2&&(e.moveTo(m[0].x,m[0].y),e.lineTo(m[1].x,m[1].y))}e.stroke()}const X2={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 G2{constructor(t,i){W(this,"parentElement");W(this,"store");W(this,"box");W(this,"text");W(this,"arrowUp");W(this,"arrowDown");W(this,"icon");W(this,"confirm");W(this,"cancel");W(this,"x");W(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=X2.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 a=t.calculative.canvas.store.data.x+i.x-s.width/2,r=t.calculative.canvas.store.data.y+i.y-s.height-20;t.type||(a=t.calculative.canvas.store.data.x+n.x-(s.width-n.width)/2,r=t.calculative.canvas.store.data.y+n.ey-s.height-n.height),r>0?(this.arrowUp.style.borderBottomColor="transparent",this.arrowDown.style.borderTopColor="#fff",r-=10):(r+=s.height+n.height+5,r+=10,this.arrowUp.style.borderBottomColor="#fff",this.arrowDown.style.borderTopColor="transparent"),this.x=a,this.y=r,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 He="-moving";class Nf{constructor(t,i,s){W(this,"parent");W(this,"parentElement");W(this,"store");W(this,"canvas",document.createElement("canvas"));W(this,"offscreen",Pi());W(this,"width");W(this,"height");W(this,"externalElements",document.createElement("div"));W(this,"clientRect");W(this,"canvasRect");W(this,"activeRect");W(this,"initActiveRect");W(this,"dragRect");W(this,"lastRotate",0);W(this,"sizeCPs");W(this,"activeInitPos");W(this,"hoverType",xt.None);W(this,"resizeIndex",0);W(this,"mouseDown");W(this,"hotkeyType");W(this,"mouseRight");W(this,"addCaches");W(this,"touchCenter");W(this,"initTouchDis");W(this,"initScale");W(this,"touchScaling");W(this,"touchMoving");W(this,"startTouches");W(this,"lastOffsetX",0);W(this,"lastOffsetY",0);W(this,"drawingLineName");W(this,"drawLineFns",[...ux]);W(this,"drawingLine");W(this,"pencil");W(this,"pencilLine");W(this,"movingPens");W(this,"patchFlagsLines",new Set);W(this,"dock");W(this,"prevAnchor");W(this,"nextAnchor");W(this,"lastMouseTime",0);W(this,"hoverTimer",0);W(this,"fitTimer",0);W(this,"willInactivePen");W(this,"patchFlags",!1);W(this,"lastRender",0);W(this,"touchStart",0);W(this,"touchStartTimer");W(this,"timer");W(this,"lastAnimateRender",0);W(this,"animateRendering",!1);W(this,"renderTimer");W(this,"initPens");W(this,"pointSize",8);W(this,"pasteOffset",!0);W(this,"opening",!1);W(this,"maxZindex",5);W(this,"canMoveLine",!1);W(this,"randomIdObj");W(this,"keyOptions");W(this,"beforeAddPen");W(this,"beforeAddPens");W(this,"beforeAddAnchor");W(this,"beforeRemovePens");W(this,"beforeRemoveAnchor");W(this,"customResizeDock");W(this,"customMoveDock");W(this,"inputParent",document.createElement("div"));W(this,"inputDiv",document.createElement("div"));W(this,"dropdown",document.createElement("ul"));W(this,"tooltip");W(this,"popconfirm");W(this,"title");W(this,"mousePos",{x:0,y:0});W(this,"scroll");W(this,"movingAnchor");W(this,"canvasTemplate");W(this,"canvasImage");W(this,"canvasImageBottom");W(this,"magnifierCanvas");W(this,"dialog");W(this,"autoPolylineFlag",!1);W(this,"stopPropagation",t=>{t.stopPropagation()});W(this,"curve",m2);W(this,"polyline",C2);W(this,"mind",w2);W(this,"line",x2);W(this,"onCopy",t=>{this.store.options.disableClipboard||t.target!==this.externalElements&&t.target!==document.body&&t.target.offsetParent!==this.externalElements||this.copy()});W(this,"onCut",t=>{this.store.options.disableClipboard||t.target!==this.externalElements&&t.target!==document.body&&t.target.offsetParent!==this.externalElements||this.cut()});W(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:a,y:r}=this.mousePos,l=s[n].getAsFile();let o=s[n].type.slice(6)==="gif"?"gif":"image";if(l!==null){const u=o==="gif",c=await this.fileToPen(l,u);c.height=c.height/c.width*100,c.width=100,c.x=a-50/2,c.y=r-c.height/c.width*50,c.externElement=u,this.addPens([c]),this.active([c]),this.copy([c])}}}}else this.paste()});W(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)});W(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 a=this.store.data.scale||1;this.translate(-t.deltaX/a,-t.deltaY/a);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 r=.2;t.deltaY.toString().indexOf(".")!==-1&&(r=.01),t.deltaY>0?i=-r:i=r}let{offsetX:s,offsetY:n}=t;this.scale(this.store.data.scale+i,{x:s,y:n}),this.externalElements.focus()});W(this,"onkeydown",t=>{var a,r,l;if(this.store.data.locked>=Ot.DisableEdit&&t.target.tagName!=="INPUT"&&t.target.tagName!=="TEXTAREA"&&!t.target.dataset.meta2dIgnore&&this.store.active.forEach(o=>{var u;(u=o.onKeyDown)==null||u.call(o,o,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 o=this.store.data.width||this.store.options.width,u=this.store.data.height||this.store.options.height;o&&u&&(n={x:this.store.data.origin.x,y:this.store.data.origin.y,width:o*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 o=$t(this.drawingLine);o!==this.drawingLine.calculative.activeAnchor?(bc(this.drawingLine),this.drawingLine.calculative.worldAnchors.push(o)):this.drawingLine.calculative.worldAnchors.push({x:o.x,y:o.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(o=>!o.parentId&&o.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":(a=this.store.active[0])!=null&&a.locked||this.removeAnchorHand();break;case"h":case"H":(r=this.store.active[0])!=null&&r.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(o=>{o.type?(o.close=!o.close,o.close&&ug(o),this.store.path2dMap.set(o,kt.path2dDraws.line(o)),Yr(o)):o.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(o=>{o.type||(o.calculative.focus=!1)}),this.movingPens&&(this.getAllByPens(this.movingPens).forEach(o=>{this.store.pens[o.id]=void 0}),this.movingPens=void 0,this.mouseDown=void 0,this.clearDock(),(l=this.store.active)==null||l.forEach(o=>{this.updateLines(o)}),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)});W(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)});W(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 a=n[0].type==="image/gif";s=await this.fileToPen(n[0],a)}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)});W(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))});W(this,"ontouchmove",t=>{var l;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,a=t.touches[0].pageX-this.clientRect.x,r=t.touches[0].pageY-this.clientRect.y;if(n===1)this.onMouseMove({x:a,y:r,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&&((l=this.startTouches)==null?void 0:l.length)===2){if(!this.touchMoving&&!this.touchScaling){const o=this.startTouches[0].pageX-s[0].pageX,u=this.startTouches[1].pageX-s[1].pageX,c=this.startTouches[0].pageY-s[0].pageY,f=this.startTouches[1].pageY-s[1].pageY;(o>=0&&u<0||o<=0&&u>0)&&(c>=0&&f<0||c<=0&&f>0)?this.touchScaling=!0:this.touchMoving=!0}if(this.touchScaling){if(this.store.data.disableScale||this.store.options.disableScale)return;const o=Math.hypot(s[0].pageX-s[1].pageX,s[0].pageY-s[1].pageY)/this.initTouchDis;this.scale(this.initScale*o,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:o}=this.store.data;this.translate((a-this.lastOffsetX)/o,(r-this.lastOffsetY)/o)}this.lastOffsetX=a,this.lastOffsetY=r}}});W(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)});W(this,"onGesturestart",t=>{t.preventDefault()});W(this,"onMouseDown",t=>{var i,s,n,a,r;if(t.buttons===2&&!this.drawingLine&&(this.mouseRight=$i.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 l=this.store.activeAnchor;if(!l)return;const o={id:It(),x:l.x,y:l.y};this.drawingLine=this.createDrawingLine(o);let u=le(this.drawingLine);this.drawingLine.calculative.activeAnchor=u,we(this.store.hover,l,this.drawingLine,o),this.drawline();return}if(!(this.hotkeyType===Yt.Translate||this.mouseRight===$i.Down&&!this.store.options.mouseRightActive)){if(this.drawingLine){if(this.store.hoverAnchor){const o=$t(this.drawingLine);this.store.hoverAnchor.type===ji.Line?yr(o,this.store.hoverAnchor,this.store):(o.x=this.store.hoverAnchor.x,o.y=this.store.hoverAnchor.y),we(this.store.hover,this.store.hoverAnchor,this.drawingLine,o),this.drawline(),this.finishDrawline(!0);return}if(!this.store.options.autoAnchor&&t.shiftKey&&t.altKey&&t.ctrlKey){this.setAnchor(this.store.pointAt);const o=$t(this.drawingLine),u=this.store.activeAnchor;if(!u)return;o.x=u.x,o.y=u.y,we(this.store.hover,u,this.drawingLine,o),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 o=$t(this.drawingLine),u=xn(this.store.hover,t);o.x=u.x,o.y=u.y,this.drawingLine.autoTo=!0,we(this.store.hover,u,this.drawingLine,o),this.drawline(),this.finishDrawline(!0);return}const l=$t(this.drawingLine);l.isTemp?(this.drawingLine.calculative.activeAnchor=this.drawingLine.calculative.worldAnchors[this.drawingLine.calculative.worldAnchors.length-2],l.isTemp=void 0):(this.drawingLine.calculative.activeAnchor=l,this.drawingLine.calculative.worldAnchors.push({x:l.x,y:l.y,penId:l.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 l=xn(this.store.hover,t);this.store.hoverAnchor=l;const o={id:It(),x:l.x,y:l.y};this.drawingLine=this.createDrawingLine(o),this.drawingLine.autoFrom=!0,we(this.store.hover,l,this.drawingLine,o)}else this.inactive(),this.hoverType=xt.None;else if(this.hoverType===xt.NodeAnchor){this.drawingLineName=this.store.options.drawingLineName;const l={id:It(),x:this.store.hoverAnchor.x,y:this.store.hoverAnchor.y};this.drawingLine=this.createDrawingLine(l),this.drawingLine.calculative.activeAnchor=l,we(this.store.hover,this.store.hoverAnchor,this.drawingLine,l)}else if(!this.drawingLine&&this.drawingLineName!=="curve"){this.inactive(!0);const l={id:It(),x:t.x,y:t.y};this.drawingLine=this.createDrawingLine(l),this.drawingLine.calculative.activeAnchor=l}}else if(this.pencil){this.inactive(!0);const l=It(),o={x:t.x,y:t.y,id:It(),penId:l};this.pencilLine=this.getInitPencilLine(o)}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(((a=this.store.active)==null?void 0:a.length)&&this.store.active.length===1&&this.store.hover.id===this.store.active[0].id){this.calcActiveRect();break}const l=ti(this.store.hover,!0);let o=l||this.store.hover;l&&(l.container||((r=this.store.options.containerShapes)==null?void 0:r.includes(l.name)))&&(o=this.store.hover),t.ctrlKey&&!t.shiftKey?(o.calculative.active?this.willInactivePen=o:this.store.active.length>0&&(o.calculative.active=!0,pn(o),this.store.active.push(o),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)&&(o.calculative.active||(this.active([o]),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(l=>{this.activeInitPos.push({x:(l.calculative.worldRect.x-this.activeRect.x)/this.activeRect.width,y:(l.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()}}});W(this,"onMouseMove",t=>{var s,n,a,r,l,o,u,c;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===$i.Down&&(this.mouseRight=$i.Translate),this.store.data.locked===Ot.DisableEdit||this.store.data.locked===Ot.DisableScale||this.hotkeyType===Yt.Translate||this.mouseRight===$i.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)||((a=this.store.active[0])==null?void 0:a.lineName)==="line")&&!this.store.options.disableDock&&!this.store.options.disableLineDock&&(this.clearDock(),this.dock=_f(this.store,f,this.store.activeAnchor),(r=this.dock)!=null&&r.xDock&&(f.x+=this.dock.xDock.step),(l=this.dock)!=null&&l.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)&&((o=y==null?void 0:y.onMouseMove)==null||o.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,kt.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=_f(this.store,v),(u=this.dock)!=null&&u.xDock&&(v.x+=this.dock.xDock.step),(c=this.dock)!=null&&c.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=$t(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)});W(this,"onMouseUp",t=>{if(this.store.data.locked===Ot.Disable){this.hoverType=xt.None;return}if(!!this.mouseDown){if(this.mouseRight===$i.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=$i.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=$t(this.drawingLine);this.store.hoverAnchor.type===ji.Line?yr(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=$t(this.drawingLine),s=xn(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=$t(i);if(this.store.hoverAnchor){const a=this.store.hover,r=le(a)===this.store.hoverAnchor,l=$t(a)===this.store.hoverAnchor,o=s===this.store.activeAnchor,u=n===this.store.activeAnchor;if((t.ctrlKey||t.altKey)&&a.type===jt.Line&&(r||l)&&(o||u)){const c=a.calculative.worldAnchors.map(f=>({...f,penId:i.id}));r?c.shift():l&&c.pop(),(r&&o||l&&u)&&c.reverse(),o?(i.calculative.worldAnchors[0].connectTo=void 0,i.calculative.worldAnchors.unshift(...c)):u&&(i.calculative.worldAnchors[i.calculative.worldAnchors.length-1].connectTo=void 0,i.calculative.worldAnchors.push(...c)),this.delete([a]),this.render()}else this.store.activeAnchor&&(this.store.hoverAnchor.type===ji.Line?yr(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,kt.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?Ll(s,this.dragRect):!0});this.active(i)}if(t.button!==2&&(Qr(this.mouseDown,t)<2&&(this.store.hover&&this.store.hover.input&&(this.store.hover.onShowInput?this.store.hover.onShowInput(this.store.hover,t):(this.store.hover.parentId&&this.active([this.store.hover]),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()}});W(this,"clearDock",()=>{var a,r,l,o;const t=(r=(a=this.dock)==null?void 0:a.xDock)==null?void 0:r.penId,i=(o=(l=this.dock)==null?void 0:l.yDock)==null?void 0:o.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});W(this,"onResize",()=>{this.timer&&clearTimeout(this.timer),this.timer=setTimeout(()=>{this.resize(),this.timer=void 0},100)});W(this,"onScroll",()=>{this.timer&&clearTimeout(this.timer),this.timer=setTimeout(()=>{this.clientRect=this.canvas.getBoundingClientRect(),this.timer=void 0},100)});W(this,"calibrateMouse",t=>(t.x-=this.store.data.x,t.y-=this.store.data.y,t));W(this,"getContainerHover",t=>{var s;if(this.dragRect)return;this.store.hoverContainer=void 0;const i=this.store.data.pens.filter(n=>{var a;return n.container||((a=this.store.options.containerShapes)==null?void 0:a.includes(n.name))});if(i.length)for(let n=i.length-1;n>=0;--n){const a=i[n];if(!(a.visible==!1||a.calculative.inView==!1||a.locked===Ot.Disable)){if(Ui(t,a.calculative.worldRect))this.store.hoverContainer=a,(s=a==null?void 0:a.onMouseMove)==null||s.call(a,a,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(a===this.store.hoverContainer&&(this.store.hoverContainer=void 0,this.store.lastHoverContainer!==this.store.hoverContainer)){this.patchFlags=!0;const r=this.store.lastHoverContainer.calculative.canvas.store.pens[this.store.lastHoverContainer.id+He];this.store.lastHoverContainer&&!r&&(this.store.lastHoverContainer.calculative.containerHover=!1,this.store.emitter.emit("leave",this.store.lastHoverContainer)),this.store.lastHoverContainer=this.store.hoverContainer}}}});W(this,"getHover",t=>{var n,a;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 r=Pl(this.store.active),l=wf(this.store.active)||this.store.options.disableRotate,o=bf(this.store.active)||this.store.options.disableSize;if(!r&&!l){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(!r&&!o)for(let u=0;u<8;u++){const c=u<4;if((this.hotkeyType===Yt.Resize||c&&!this.hotkeyType)&&mn(t,this.sizeCPs[u],this.pointSize)){let g=c?hf:uf,v=0;Math.abs(this.activeRect.rotate%90-45)<25?(g=c?uf:hf,v=Math.round((this.activeRect.rotate-45)/90)+(c?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,ea(ti(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,ea(ti(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),(a=(n=this.store.hover)==null?void 0:n.onMouseMove)==null||a.call(n,this.store.hover,this.mousePos)});W(this,"inPens",(t,i)=>{var n;let s=xt.None;t:for(let a=i.length-1;a>=0;--a){const r=i[a];if(r.visible==!1||r.calculative.inView==!1||r.locked===Ot.Disable)continue;const l=qr(r);if(!(!r.calculative.active&&!Ws(t,r.calculative.worldRect,l)&&!Ui(t,r.calculative.worldRect))){if(!this.store.data.locked&&this.hotkeyType!==Yt.Resize&&r.calculative.worldAnchors){for(const o of r.calculative.worldAnchors)if(s=this.inAnchor(t,r,o),s){let u=ht(o);Object.assign(u,t),this.title.show(u,r);break t}}if(r.type){if(r.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 o=_2(t,r);if(o){!this.store.data.locked&&!r.locked?this.hotkeyType===Yt.AddAnchor?this.externalElements.style.cursor="pointer":this.externalElements.style.cursor="move":this.externalElements.style.cursor=this.store.options.hoverCursor,r.calculative.disabled&&(this.externalElements.style.cursor="not-allowed"),this.store.hover=r,this.store.pointAt=o.point,this.store.pointAtIndex=o.i,this.initTemplateCanvas([this.store.hover]),s=xt.Line;break}}else{if(r.children){const u=[];if(r.children.forEach(c=>{this.store.pens[c]&&u.push(this.store.pens[c])}),s=this.inPens(t,u),s)break}let o=!1;if(r.name==="line"?o=Ws(t,r.calculative.worldRect,r.lineWidth):o=Ui(t,r.calculative.worldRect),o){if(r.type===jt.Node&&r.name==="line"&&!$_(t,r.calculative.worldAnchors))continue;if(!this.store.data.locked&&!r.locked?this.hotkeyType===Yt.AddAnchor?this.externalElements.style.cursor="pointer":this.externalElements.style.cursor="move":this.externalElements.style.cursor=this.store.options.hoverCursor,r.calculative.disabled&&(this.externalElements.style.cursor="not-allowed"),this.store.hover=r,this.initTemplateCanvas([this.store.hover]),s=xt.Node,this.store.pointAt=t,!t.ctrlKey){let{x:u,y:c,ex:f,ey:g,rotate:v,center:y}=this.store.hover.calculative.worldRect;if(v){const w=[{x:u,y:c},{x:f,y:c},{x:f,y:g},{x:u,y:g}];w.forEach(_=>{Gt(_,v,y)});let m=w[w.length-1];for(const _ of w){if(m.y>t.y!=_.y>t.y){const E=_.x+(t.y-_.y)*(m.x-_.x)/(m.y-_.y);Math.abs(E-this.store.pointAt.x)<10&&(this.store.pointAt.x=E)}m=_}}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<c?this.store.pointAt.y=c:this.store.pointAt.y+10>g&&(this.store.pointAt.y=g)}break}}}}return s});W(this,"dockInAnchor",t=>{var i,s;this.store.hover=void 0;for(let n=this.store.data.pens.length-1;n>=0;--n){const a=this.store.data.pens[n];if(a.visible==!1||a.locked===Ot.Disable||a===this.store.active[0])continue;let r=qr(a);if(r+=2*this.store.options.anchorRadius,!!Ws(t,a.calculative.worldRect,r)&&(this.store.hover=a,this.hotkeyType!==Yt.Resize&&a.calculative.worldAnchors))for(const l of a.calculative.worldAnchors){if(l.twoWay===Ee.In){const o=$t(this.store.active[0]);if(this.store.activeAnchor.id!==o.id)continue}if(l.twoWay===Ee.Out){const o=le(this.store.active[0]);if(this.store.activeAnchor.id!==o.id)continue}if(!(l.twoWay===Ee.DisableConnected||l.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,a,l))){let o=ht(l);return Object.assign(o,t),this.title.show(o,a),!0}}}});W(this,"imageTimer");W(this,"templateImageTimer");W(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});W(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.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),En(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)})});W(this,"renderPenContainChild",(t,i)=>{var s;i.calculative.inView&&Is(t,i),(s=i.children)==null||s.forEach(n=>{const a=this.store.pens[n];a&&this.renderPenContainChild(t,a)})});W(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,Pl(this.store.active)||wf(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()}});W(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 a=this.store.hover.hoverAnchorColor||this.store.options.hoverAnchorColor;t.strokeStyle=a,t.fillStyle=a}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 a=this.store.pens[s.penId].rotate||0;this.store.pens[s.penId].calculative.flipX&&(a*=-1),this.store.pens[s.penId].calculative.flipY&&(a*=-1);let r=s.rotate+a;this.store.pens[s.penId].calculative.flipX&&(r*=-1),this.store.pens[s.penId].calculative.flipY&&(r*=-1),t.save(),t.translate(s.x,s.y),t.rotate(r*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 a=this.store.hover.hoverAnchorColor||this.store.options.hoverAnchorColor;globalThis.pSBC&&(t.strokeStyle=globalThis.pSBC(.5,a)),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)&&!Pl(this.store.active)&&!bf(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=Wr(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()});W(this,"transTimeout");W(this,"pastePen",(t,i)=>{const s=t.id;if(kf(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 a=this.getPenRect(t,this.store.clipboard.origin,this.store.clipboard.scale),r=this.getPenRect(this.store.clipboard.initRect,this.store.clipboard.origin,this.store.clipboard.scale),{origin:l,scale:o}=this.store.data;t.x=l.x+a.x*o,t.y=l.y+a.y*o,t.width=a.width*o,t.height=a.height*o,r.x=l.x+r.x*o,r.y=l.y+r.y*o,Qt(r),this.store.clipboard.pos&&(t.x-=r.center.x-this.store.clipboard.pos.x,t.y-=r.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 a of t.children){const r=this.store.clipboard.pens.find(l=>l.id===a);r&&n.push(this.pastePen(r,t.id).id)}return t.children=n,Yi(t,!0),t});W(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(a=>{this.store.pens[a].calculative.active=!1,this.store.pens[a].calculative.hover=!1}),this.store.hover.parentId){let a=this.store.hover.id;const r=this.calibrateMouse({x:t.offsetX,y:t.offsetY});let l=1/0;(n=(s=this.store.pens[this.store.hover.parentId])==null?void 0:s.children)==null||n.forEach(o=>{const u=this.store.pens[o];if(Ui(r,u.calculative.worldRect)){const c=Math.sqrt((r.x-u.calculative.worldRect.center.x)**2+(r.y-u.calculative.worldRect.center.y)**2);c<l&&(l=c,a=o)}}),this.store.hover=this.store.pens[a],this.store.pens[a].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})});W(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 c=window.getSelection();c.selectAllChildren(this.inputDiv),c.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,l=`${(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=l,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 o=n.width;this.inputParent.style.width=(o<0?12:o)+"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()});W(this,"setInputStyle",t=>{t.text||(t.text="");let i;for(let o=0;o<document.styleSheets.length;o++)document.styleSheets[o].title==="le5le.com"&&(i=document.styleSheets[o]);let s="overflow: scroll;",n="",a=1;const{scale:r}=this.store.data;if(t.fontSize<12&&(a=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*r<12?(s+=`font-size:${t.fontSize}px;`,s+=`zoom:${t.fontSize/12*r};`):s+=`font-size:${t.fontSize*r}px;`),s+=`color:${Ji(t,this.store)};`,t.fontStyle&&(s+=`font-style: ${t.fontStyle};`),t.fontWeight&&(s+=`font-weight: ${t.fontWeight};`),t.textLeft&&(s+=`margin-left:${r>1?t.textLeft*a:t.textLeft*a/r}px;`),t.textTop&&(s+=`margin-top:${r>1?t.textTop*a:t.textTop*a/r}px;`),t.lineHeight&&(s+=`line-height:${r>1?t.fontSize*t.lineHeight*r:t.fontSize*t.lineHeight*a}px;`),t.textHeight)s+=`height:${r>1?t.textHeight*a*r:t.textHeight*a}px;`;else{let o=t.calculative.worldRect.height/r;o<0&&(o=0);let u=t.fontSize*r<12?o*a:o*r*a;u<t.fontSize*t.lineHeight*r&&(u=t.fontSize*t.lineHeight*r,s+=`top:-${u/2}px;`),s+=`height:${u}px;`}let l=null;if(t.textWidth)l=t.textWidth<1&&t.textWidth>-1?t.textWidth*t.calculative.worldRect.width:t.textWidth,t.whiteSpace!=="pre-line"&&(l<t.fontSize?s+=`width:${t.fontSize*1.2*a}px;`:s+=`width:${r>1?l*a*r:l*a}px;`);else if(t.whiteSpace===void 0||t.whiteSpace==="break-all"){let o=(t.calculative.worldTextRect.width||12)/r;o<0&&(o=0),s+=`width:${t.fontSize*r<12?o*a:o*r}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 o=t.fontSize*1.2*t.text.length,u=(l||t.calculative.worldRect.width/r)*Math.floor(t.calculative.worldRect.height/r/(t.lineHeight*t.fontSize));o>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}}`)});W(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&&Hx(t),Ri(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&&Ri(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()});W(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 a=document.createElement("div");a.innerText="None",a.style.padding="5px 12px",a.style.color="#ddd",this.dropdown.appendChild(a);return}const s=this.inputDiv.innerHTML.replace(/\<div\>/g,`
- `).replace(/\<\/div\>/g,"").replace(/\<br\>/g,"");let n=0;for(const a of i.dropdownList){const r=typeof a=="string"?a:a.text;t&&s?r.includes(s)&&this.dropdownAppendOption(r,n):this.dropdownAppendOption(r,n),++n}if(!this.dropdown.hasChildNodes()){const a=document.createElement("div");a.innerText="None",a.style.padding="5px 12px",a.style.color="#ddd",this.dropdown.appendChild(a)}});W(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,a=s.dropdownList[n];if(!a)return;const r=[ht(s,!0)];typeof a=="object"?(this.updateValue(s,{...a}),s.calculative.text=void 0,this.calcActiveRect()):s.text=a+"",this.inputDiv.innerText=s.text,this.hideInput(),this.pushHistory({type:bt.Update,pens:[ht(s,!0)],initPens:r}),this.render(),this.store.emitter.emit("change",s),this.store.emitter.emit("valueUpdate",s)});W(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 a={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 r=this.canvasImage.activeFit;this.externalElements.style.cursor="default",a.y>n*r.y-10&&a.y<n*r.y+10&&(i="top",this.externalElements.style.cursor="row-resize"),a.y>n*(r.y+r.height)-10&&a.y<n*(r.y+r.height)+10&&(i="bottom",this.externalElements.style.cursor="row-resize"),a.x>s*r.x-10&&a.x<s*r.x&&(i="left",this.externalElements.style.cursor="col-resize"),a.x>s*(r.x+r.width)-10&&a.x<s*(r.x+r.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 K2(i,s),this.canvasTemplate.canvas.style.zIndex="1",this.canvasImageBottom=new Bf(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 Bf(i,s),this.canvasImage.canvas.style.zIndex="4",this.magnifierCanvas=new q2(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 oa(i,s),this.tooltip.box.onmouseleave=n=>{this.patchFlags=!0,this.store.lastHover&&(this.store.lastHover.calculative.hover=!1);let a=this.store.data.pens.find(r=>r.calculative.hover===!0);ea(a,!1)},this.popconfirm=new G2(i,s),this.dialog=new Y2(i,s),this.title=new Kr(i),this.store.options.scroll&&(this.scroll=new pg(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(c=>c===i);if([-1,0,s.length-1].includes(n))return;const a=ht(t,!0),r=ht(t,!0),l=It();r.id=l,r.calculative.canvas=this,r.calculative.active=!1,r.calculative.hover=!1;const o=ht(s.slice(0,n+1)),u=ht(s.slice(n)).map(c=>(c.penId=l,c));t.calculative.worldAnchors=o,r.calculative.worldAnchors=u,this.initLineRect(t),this.initLineRect(r),this.store.data.pens.push(r),this.store.pens[l]=r,this.pushHistory({type:bt.Add,pens:[ht(r,!0)],step:2}),this.pushHistory({type:bt.Update,initPens:[a],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],a=n.calculative.worldRect;this.movingAnchor.x<a.x?this.movingAnchor.x=a.x:this.movingAnchor.x>a.ex&&(this.movingAnchor.x=a.ex),this.movingAnchor.y<a.y?this.movingAnchor.y=a.y:this.movingAnchor.y>a.ey&&(this.movingAnchor.y=a.ey);const r=ra(this.movingAnchor,a),l=n.anchors.findIndex(o=>o.id===this.movingAnchor.id);n.anchors[l]=r,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 $x(t,this.store.options.uploadUrl,this.store.options.uploadParams,this.store.options.uploadHeaders):s=await Ux(t),new Promise((n,a)=>{const r=new Image;r.onload=()=>{kt.htmlElements[s]=r,n({width:r.width,height:r.height,name:i?"gif":"image",image:s})},r.onerror=l=>{a(l)},r.crossOrigin="anonymous",r.src=s})}async dropPens(t,i){var o,u,c,f;this.randomIdObj={};for(const g of t)!g.parentId&&this.randomCombineId(g,t);if(Object.keys(this.randomIdObj).length!==0){const g=Object.keys(this.randomIdObj).join("|"),v=new RegExp(`(${g})`,"g");for(const y of t){if(y.type?(y.anchors[0].connectTo=this.randomIdObj[y.anchors[0].connectTo],y.anchors[y.anchors.length-1].connectTo=this.randomIdObj[y.anchors[y.anchors.length-1].connectTo]):(o=y.connectedLines)==null||o.forEach(w=>{w.lineAnchor=this.randomIdObj[w.lineAnchor],w.lineId=this.randomIdObj[w.lineId]}),(u=y.animations)!=null&&u.length){const w=JSON.stringify(y.animations).replace(v,m=>this.randomIdObj[m]);y.animations=JSON.parse(w)}if((c=y.triggers)!=null&&c.length){const w=JSON.stringify(y.triggers).replace(v,m=>this.randomIdObj[m]);y.triggers=JSON.parse(w)}if((f=y.events)!=null&&f.length){const w=JSON.stringify(y.events).replace(v,m=>this.randomIdObj[m]);y.events=JSON.parse(w)}}}for(const g of t)g.id||(g.id=It()),!g.calculative&&(g.calculative={canvas:this}),this.store.pens[g.id]=g;let s=0,n=0,a=0;for(const g of t)g.parentId||(g.width*=this.store.data.scale,g.height*=this.store.data.scale,g.x=i.x-g.width/2+a,g.y=i.y-g.height/2+n,g.tags&&g.tags.includes("meta3d")&&(g.x=this.store.data.origin.x,g.y=this.store.data.origin.y),g.dataset&&(s%2===0?a=g.width-40*this.store.data.scale:a=0,s++,s%2===0&&(n+=g.height+10*this.store.data.scale)));const r=this.store.data.width||this.store.options.width,l=this.store.data.height||this.store.options.height;if(r&&l){let g={x:this.store.data.origin.x,y:this.store.data.origin.y,width:r*this.store.data.scale,height:l*this.store.data.scale},v=!0;for(const y of t)if(!y.parentId){let w=[{x:y.x,y:y.y},{x:y.x+y.width,y:y.y},{x:y.x,y:y.y+y.height},{x:y.x+y.width,y:y.y+y.height},{x:y.x+y.width/2,y:y.y+y.height/2}];if(y.x===g.x&&y.y===g.y&&y.width===g.width&&y.height===g.height||w.some(m=>Ui(m,g))){v=!1,this.store.options.strictScope&&(y.x<g.x&&(y.x=g.x),y.y<g.y&&(y.y=g.y),y.x+y.width>g.x+g.width&&(y.x=g.x+g.width-y.width),y.y+y.height>g.y+g.height&&(y.y=g.y+g.height-y.height));break}}if(v){console.info("\u753B\u7B14\u5728\u5927\u5C4F\u8303\u56F4\u5916");return}}await this.addPens(t,!0),this.active(t.filter(g=>!g.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]:n=[t.id]:i.length>1&&(n=[t.id]),kf(t),i.length>1&&(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 a=[];if(Array.isArray(t.children))for(const r of t.children){const l=i.find(o=>o.id===r);l&&a.push(this.randomCombineId(l,i,t.id).id)}return t.children=a,t}async addPens(t,i,s){if(this.beforeAddPens&&await this.beforeAddPens(t)!=!0)return[];const n=[];for(const a of t)this.beforeAddPen&&this.beforeAddPen(a)!=!0||(s&&!a.parentId&&(a.x=a.x*this.store.data.scale+this.store.data.origin.x,a.y=a.y*this.store.data.scale+this.store.data.origin.y,a.width=a.width*this.store.data.scale,a.height=a.height*this.store.data.scale),this.makePen(a),n.push(a));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,a=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:a*n},fromArrow:i.fromArrow||s.fromArrow,toArrow:i.toArrow||s.toArrow,lineWidth:a}}createDrawingLine(t){this.inactive();const{data:i,options:s}=this.store,n=i.scale,a=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:a*n,...s.linePresetStyle},fromArrow:i.fromArrow||s.fromArrow,toArrow:i.toArrow||s.toArrow,lineWidth:a,...s.linePresetStyle}}addRuleLine(t){const{x:i,y:s,scale:n,origin:a}=this.store.data,r=t.x+i,l=t.y+s;let o=t.x,u=t.y,c=0,f=0,g=0,v=0;if(r<=l&&r<20)o=-i,c=this.width,g=1,t.ctrlKey||(u=Math.round((u-a.y)/(n*10))*(n*10)+a.y);else if(l<r&&l<20)u=-s,f=this.height,v=1,t.ctrlKey||(o=Math.round((o-a.x)/(n*10))*(n*10)+a.x);else return;this.addPen({isRuleLine:!0,type:jt.Line,name:"line",lineName:"line",x:o,y:u,width:c,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:a,scale:r}=this.store.data,{x:l,y:o}=t,u={x:l,y:o},c=this.getPenRect(t),f=parseInt((c.x/n).toFixed()),g=parseInt((c.y/n).toFixed()),v=f*n,y=g*n;u.x=a.x+v*r,u.y=a.y+y*r,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:a,scale:r}=this.store.data,l=this.store.options.autoAlignGrid&&(this.store.data.grid||this.store.options.grid);if(i.forEach(g=>{var _;const v=this.movingPens.findIndex(E=>E.id===g.id+He);if(v<0)return;const{x:y,y:w}=this.movingPens[v],m={x:y,y:w};if(l&&!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,L=C*n;m.x=a.x+S*r,m.y=a.y+L*r}Object.assign(g,m),(_=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),sg(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:o,yDock:u}=this.dock;let c;o&&(c=this.store.pens[o.penId]),!c&&u&&(c=this.store.pens[u.penId]);const f=ht(this.store.active,!0);if(t&&this.store.active.length===1&&(c==null?void 0:c.type)===1&&((o==null?void 0:o.anchorId)||(u==null?void 0:u.anchorId))){const g=le(c),v=$t(c);if(o!=null&&o.anchorId){const y=this.store.pens[this.store.active[0].id+He].calculative.worldAnchors.find(w=>w.id===o.anchorId);y.x===g.x&&y.y===g.y?(s.push(ht(c,!0)),we(this.store.active[0],y,c,g),f.push(ht(c,!0))):y.x===v.x&&y.y===v.y&&(s.push(ht(c,!0)),we(this.store.active[0],y,c,v),f.push(ht(c,!0)))}else if(u!=null&&u.anchorId){const y=this.store.pens[this.store.active[0].id+He].calculative.worldAnchors.find(w=>w.id===u.anchorId);y.x===g.x&&y.y===g.y?(s.push(ht(c,!0)),we(this.store.active[0],y,c,g),f.push(ht(c,!0))):y.x===v.x&&y.y===v.y&&(s.push(ht(c,!0)),we(this.store.active[0],y,c,v),f.push(ht(c,!0)))}}l&&(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 a=this.store.pens[n];return a&&this.hasImage(a,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:a,rotate:r,center:l}=this.activeRect;t.forEach(o=>{const u={x:o.x*n+i,y:o.y*a+s};Gt(u,r,l),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 a=this.findOne(s.connectTo);if((a==null?void 0:a.calculative)&&!(a!=null&&a.calculative.active)){i=a;const r=a.calculative.worldAnchors.find(l=>l.id===s.anchorId);r&&(s=r)}}if(s.twoWay===Ee.Disable&&i.name!=="line")return xt.None;if(i.name==="line"&&s.connectTo){let a=(n=this.findOne(s.connectTo))==null?void 0:n.anchors.find(r=>r.id===s.anchorId);if(a&&a.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(a=>a.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},re(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,this.updatePenRect(s)),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(a=>{a.calculative&&(a.calculative.layer=this.store.data.pens.findIndex(r=>r.id===a.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(a=>{let r;if(t.initPens)for(const l of t.initPens)l.id===a.id&&(r=l);if(r)for(const l in a)r[l]==null&&(r[l]=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(a=>{var o;const r=ht(a,!0),l=this.store.data.pens.findIndex(u=>u.id===r.id);l>-1&&((o=r.onDestroy)==null||o.call(r,this.store.pens[r.id]),this.store.data.pens.splice(l,1),this.store.pens[r.id]=void 0,r.calculative||(r.calculative={}),r.calculative.canvas=this,this.store.animates.delete(r),this.store.animateMap.delete(r))}),t.type=bt.Delete;break;case bt.Update:const s=i?t.initPens:t.pens,n=i?t.pens:t.initPens;s.forEach(a=>{const r=ht(a,!0),l=this.store.data.pens.findIndex(o=>o.id===r.id);if(l>-1){if(r.calculative=this.store.data.pens[l].calculative,this.store.data.pens[l].type&&this.store.data.pens[l].lastConnected){for(let u in this.store.data.pens[l].lastConnected)if(this.store.pens[u]){let c=ht(this.store.data.pens[l].lastConnected[u]);this.store.pens[u].connectedLines=c,r.anchors.forEach(f=>{c.forEach(g=>{f.id===g.lineAnchor&&(f.connectTo=u)})})}}this.store.data.pens[l]=r,this.store.pens[r.id]=r;for(const u in r)(typeof r[u]!="object"||u==="lineDash")&&(r.calculative[u]=r[u]);r.calculative.image=void 0;const o=this.getPenRect(r,t.origin,t.scale);if(this.setPenRect(r,o,!1),this.updateLines(r,!0),r.calculative.canvas.parent.isCombine(r)){let u=n.find(c=>c.id===r.id);Fd.forEach(c=>{r[c]!==u[c]&&this.parent.setValue({id:r.id,[c]:r[c]},{render:!0,doEvent:!1})})}}});break;case bt.Delete:t.pens.reverse().forEach(a=>{var l,o;const r=ht(a,!0);if(r.calculative||(r.calculative={}),this.store.data.pens.splice(((l=r.calculative)==null?void 0:l.layer)!==-1?(o=r.calculative)==null?void 0:o.layer:this.store.data.pens.length,0,r),this.store.pens[r.id]=r,r.type&&r.lastConnected)for(let u in r.lastConnected)this.store.pens[u]&&(this.store.pens[u].connectedLines=r.lastConnected[u]);r.calculative.canvas=this}),t.pens.reverse().forEach(a=>{const r=this.store.pens[a.id],l=this.getPenRect(r,t.origin,t.scale);this.setPenRect(r,l,!1),r.calculative.image=void 0,r.calculative.backgroundImage=void 0,r.calculative.strokeImage=void 0,this.loadImage(r)}),t.type=bt.Add;break;case bt.Replace:{const a=i?t.initPens:t.pens;(i?t.pens:t.initPens).forEach(l=>{var c;const o=ht(l,!0);if(this.store.data.pens.findIndex(f=>f.id===o.id)>-1){(c=o.onDestroy)==null||c.call(o,this.store.data.pens.find(g=>g.id===o.id));const f=this.store.data.pens.findIndex(g=>g.id===o.id);this.store.data.pens.splice(f,1),this.store.pens[o.id]=void 0,o.calculative||(o.calculative={}),o.calculative.canvas=this,this.store.animates.delete(o),this.store.animateMap.delete(o)}}),a.reverse().forEach(l=>{var u,c;const o=ht(l,!0);if(o.calculative||(o.calculative={}),this.store.data.pens.splice(((u=o.calculative)==null?void 0:u.layer)!==-1?(c=o.calculative)==null?void 0:c.layer:this.store.data.pens.length,0,o),this.store.pens[o.id]=o,o.type&&o.lastConnected)for(let f in o.lastConnected)this.store.pens[f]&&(this.store.pens[f].connectedLines=o.lastConnected[f]);o.calculative.canvas=this}),a.reverse().forEach(l=>{const o=this.store.data.pens.find(c=>c.id===l.id),u=this.getPenRect(o,t.origin,t.scale);this.setPenRect(o,u,!1),o.calculative.image=void 0,o.calculative.backgroundImage=void 0,o.calculative.strokeImage=void 0,this.loadImage(o)}),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,a;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&&kt.anchors[t.name]&&(t.anchors||(t.anchors=[]),kt.anchors[t.name](t)),!t.anchors){const r=ht(this.store.options.defaultAnchors);r.forEach((l,o)=>{l.id=`${o}`,l.penId=t.id}),t.anchors=r}this.updatePenRect(t),!t.anchors&&t.calculative.worldAnchors&&(t.anchors=t.calculative.worldAnchors.map(r=>ra(r,t.calculative.worldRect))),!t.rotate&&(t.rotate=0),(a=t.lineAnimateImages)!=null||(t.lineAnimateImages=[]),t.lineAnimateImages&&t.lineAnimateImages.forEach(r=>{this.__loadImage(r)}),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,kt.path2dDraws.line(this.drawingLine)),this.patchFlags=!0)}initLineRect(t){var a;if(!t)return;if(!((a=t.calculative.worldAnchors)!=null&&a.length)){this._del([t]);return}if(!isFinite(t.x)||!isFinite(t.x)||t.x==null||t.y==null)return;const i=ic(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),Qt(i),t.calculative.worldRect=i,wc(t,i),Ri(t),Yi(t),t.calculative&&(t.calculative.gradientAnimatePath=void 0),this.store.path2dMap.set(t,kt.path2dDraws[t.name](t)),t.calculative.worldAnchors&&(t.anchors=t.calculative.worldAnchors.map(r=>ra(r,t.calculative.worldRect)))}drawingPencil(){wg(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=$t(this.drawingLine);if(s.isTemp&&(this.drawingLine.calculative.worldAnchors.pop(),s=$t(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(r=>r.lineId!==this.drawingLine.id)),this.drawingLine=void 0,this.render();return}}else if(this.store.options.disableRepeatLine&&this.store.data.pens.find(l=>{if(l.type){const o=le(l),u=$t(l);return ff(o,i)&&ff(u,s)}})){this.drawingLine=void 0,this.render();return}const n=ic(this.drawingLine);Object.assign(this.drawingLine,n),this.drawingLine.calculative.worldRect=n,this.drawingLine.calculative.activeAnchor=$t(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,kt.path2dDraws[this.drawingLine.name](this.drawingLine)),this.drawingLine=void 0,this.drawingLineName=void 0,this.render()}async finishPencil(){if(this.pencilLine){const t=sc(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=$t(this.pencilLine),t.push({id:i.id,penId:i.penId,x:i.x,y:i.y}),this.pencilLine.calculative.worldAnchors=D2(t),this.pencilLine.calculative.worldAnchors.length>1&&(this.pencilLine.calculative.pencil=!1,this.store.path2dMap.set(this.pencilLine,kt.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 r=new DOMParser().parseFromString(s.responseText,"text/xml").getElementsByTagName("svg")[0],{width:l,height:o}=t.calculative.worldRect;r.setAttribute("width",`${l}px`),r.setAttribute("height",`${o}px`);const c="data:image/svg+xml;base64,"+btoa(unescape(encodeURIComponent(new XMLSerializer().serializeToString(r))));i.src=c,i.onload=()=>{t.calculative.img=i,t.calculative.imgNaturalWidth=i.naturalWidth||t.iconWidth,t.calculative.imgNaturalHeight=i.naturalHeight||t.iconHeight,kt.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(kt.htmlElements[t.image]){const i=kt.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,kt.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(kt.htmlElements[t.backgroundImage]){const i=kt.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,kt.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(kt.htmlElements[t.strokeImage]){const i=kt.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,kt.htmlElements[t.strokeImage]=i,this.imageLoaded(),t.canvasLayer===zt.CanvasTemplate&&t.name!=="gif"&&this.templateImageLoaded()}}t.calculative.strokeImage=t.strokeImage}}__loadImage(t){return new Promise(i=>{if(kt.htmlElements[t])i(kt.htmlElements[t]);else{const s=new Image;s.crossOrigin="anonymous",s.src=t,this.store.options.cdn&&!(t.startsWith("http")||t.startsWith("//")||t.startsWith("data:image"))&&(s.src=this.store.options.cdn+t),s.onload=()=>{kt.htmlElements[t]=s,i(s)}}})}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?Lr(t):ig(t),s||this.setCalculativeByScale(t),An(t),vf(this.store.pens,t),Ri(t),Yi(t),kt.path2dDraws[t.name]&&this.store.path2dMap.set(t,kt.path2dDraws[t.name](t)),t.calculative.patchFlags=!0,this.patchFlags=!0,t.children&&t.children.forEach(n=>{const a=this.store.pens[n];a&&this.updatePenRect(a,{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(){if(this.store.options.themeOnlyCanvas||this.store.data.themeOnlyCanvas)return;const t={},i={},s={};Mx.forEach(a=>{var r;if(this.store.options[a]!==void 0&&(t[a]=this.store.options[a]),this.store.data[a]!==void 0&&(i[a]=this.store.data[a]),this.store.data.theme){const l=(r=this.store.theme[this.store.data.theme])==null?void 0:r[a];l!==void 0&&(s[a]=l)}}),this.store.styles={};const n=ta.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,a=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<(a+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+a*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+a*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 l;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 a=t/this.store.data.scale;this.store.data.scale=t,this.store.data.center=i,(l=this.store.clipboard)!=null&&l.pos&&Hr(this.store.clipboard.pos,a,i),Hr(this.store.data.origin,a,i),this.store.data.pens.forEach(o=>{if(o.onScale&&o.onScale(o),!o.parentId){if(gn(o,a,i),o.isRuleLine){const u=1/a,c=o.calculative.worldRect.center;o.width&&o.height||gn(o,u,c)}this.updatePenRect(o,{worldRectIsReady:!0}),this.execPenResize(o)}}),this.onMovePens(),this.calcActiveRect(),this.canvasTemplate.init(),this.canvasImage.init(),this.canvasImageBottom.init();const r=this.parent.map;r&&r.isShow&&r.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 a=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(r=>{if(!r.parentId){if(gn(r,a,i),r.onScale&&r.onScale(r),r.isRuleLine){const l=a>1?1:1/a/a,o=r.calculative.worldRect.center;r.width&&r.height||gn(r,l,o)}this.execPenResize(r)}}),this.calcActiveRect()}rotatePens(t){this.initPens||(this.initPens=ht(this.getAllByPens(this.store.active))),this.activeRect.rotate=ui(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,a=s.y-i.y;const r=ht(this.initActiveRect);if(Ef(r,n,a,this.resizeIndex),Qt(r),!this.store.options.disableDock){this.clearDock();const v=this.customResizeDock||D_;this.dock=v(this.store,r,this.store.active,this.resizeIndex);const{xDock:y,yDock:w}=this.dock;if(y){n+=y.step;const m=this.store.pens[y.penId];m.calculative.isDock=!0}if(w){a+=w.step;const m=this.store.pens[w.penId];m.calculative.isDock=!0}}const l=this.activeRect.width,o=this.activeRect.height;let u=n-this.lastOffsetX,c=a-this.lastOffsetY;if(this.lastOffsetX=n,this.lastOffsetY=a,(t.ctrlKey||this.initPens.length===1&&this.initPens[0].ratio)&&(c=([1,3].includes(this.resizeIndex)?-1:1)*(u*o)/l),this.activeRect.ratio=this.initPens[0].ratio,Ef(this.activeRect,u,c,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)}}Qt(this.activeRect);const f=this.activeRect.width/l,g=this.activeRect.height/o;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),re(v.calculative.worldRect),Qt(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 l,o;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&&(((l=this.store.active[0].anchors[0])==null?void 0:l.connectTo)||((o=this.store.active[0].anchors[this.store.active[0].anchors.length-1])==null?void 0:o.connectTo))||(this.movingPens||(this.initMovingPens(),this.store.active.forEach(u=>{ea(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 a=!1;if(this.store.options.strictScope){const u=this.store.data.width||this.store.options.width,c=this.store.data.height||this.store.options.height;if(u&&c){let f={x:this.store.data.origin.x,y:this.store.data.origin.y,width:u*this.store.data.scale,height:c*this.store.data.scale};n.x<f.x&&(n.x=f.x,a=!0),n.y<f.y&&(n.y=f.y,a=!0),n.x+n.width>f.x+f.width&&(n.x=f.x+f.width-n.width,a=!0),n.y+n.height>f.y+f.height&&(n.y=f.y+f.height-n.height,a=!0)}}const r={x:n.x-this.activeRect.x,y:n.y-this.activeRect.y};if(!this.store.options.disableDock&&!a){this.clearDock();const u=this.customMoveDock||L_;this.dock=u(this.store,n,this.movingPens,r);const{xDock:c,yDock:f}=this.dock;let g;c&&(r.x+=c.step,g=this.store.pens[c.penId],g.calculative.isDock=!0),f&&(r.y+=f.step,g=this.store.pens[f.penId],g.calculative.isDock=!0)}this.translatePens(this.movingPens,r.x,r.y,!0)}changeIdsByMoving(t,i){t.id+=He,t.parentId&&i.find(s=>s.id===t.parentId)&&(t.parentId+=He),t.children&&(t.children=t.children.map(s=>s+He)),t.connectedLines&&(t.connectedLines=t.connectedLines.map(s=>(i.find(n=>n.id===s.lineId)&&(s.lineId+=He),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+=He),s)))}initMovingPens(){var s,n;if(!this.store.options.moveConnectedLine&&!this.canMoveLine)for(let a=0;a<this.store.active.length;a++){const r=this.store.active[a];(((s=r.anchors[0])==null?void 0:s.connectTo)||((n=r.anchors[r.anchors.length-1])==null?void 0:n.connectTo))&&(this.store.active.splice(a,1),r.calculative.active=void 0,--a)}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(a=>{this.changeIdsByMoving(a,i),this.store.pens[a.id]=a,a.calculative.canvas=this;const r={globalAlpha:.5};a.lineWidth===0&&(r.lineWidth=1),(a.name.endsWith("Dom")||Od.includes(a.name)||this.store.options.domShapes.includes(a.name)||a.image)&&(r.name="rectangle",r.onDestroy=void 0),this.updateValue(a,r),a.calculative.image=void 0})}moveLineAnchor(t,i){var l,o,u,c,f;if(!this.activeRect||this.store.data.locked)return;if(this.initPens||(this.initPens=ht(this.store.active,!0)),(l=this.store.activeAnchor)!=null&&l.connectTo){const g=this.store.pens[this.store.activeAnchor.connectTo];_n(g,Ls(g,this.store.activeAnchor.anchorId),this.store.pens[this.store.activeAnchor.penId],this.store.activeAnchor)}let s=(o=this.store.activeAnchor)==null?void 0:o.id,n=(c=(u=this.store.pens[this.store.activeAnchor.penId])==null?void 0:u.connectedLines)==null?void 0:c.filter(g=>g.anchor===s);n&&n.length>0&&n.forEach(g=>{const v=this.store.pens[g.lineId];_n(this.store.pens[this.store.activeAnchor.penId],this.store.activeAnchor,v,Ls(v,g.lineAnchor))});const a=this.store.active[0];le(a);const r=$t(a);if(a.lineName==="polyline"&&!i.shiftKey)L2(a,this.store.activeAnchor,t);else{let g=0,v=0;if(a.lineName==="line"){let y=a.calculative.worldAnchors.findIndex(m=>m.id===this.store.activeAnchor.id);y===0&&(y=2);let w=a.calculative.worldAnchors[y-1];if(i.ctrlKey&&i.shiftKey){let m=ht(t);this.getSpecialAngle(m,w),g=m.x-this.store.activeAnchor.x,v=m.y-this.store.activeAnchor.y}else if(!i.ctrlKey&&i.shiftKey){let m={x:t.x,y:w.y};g=m.x-this.store.activeAnchor.x,v=m.y-this.store.activeAnchor.y}else if(i.ctrlKey&&!i.shiftKey){let m={x:w.x,y:t.y};g=m.x-this.store.activeAnchor.x,v=m.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);aa(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,yr(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),aa(this.store.activeAnchor,g,v),r.prev=void 0,a.lineName!=="polyline"&&((f=this[a.lineName])==null||f.call(this,this.store,a)))}this.patchFlagsLines.add(a),this.store.path2dMap.set(a,kt.path2dDraws[a.name](a)),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===Ns.Bilateral&&this.prevAnchor){const s=ui(t,this.store.activeAnchor),n=ui(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,kt.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===Ns.Bilateral&&this.nextAnchor){const s=ui(t,this.store.activeAnchor),n=ui(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,kt.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]):(b_(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=w_(s,this.store.pointAt,this.store.pointAtIndex),this.initLineRect(s);const a={x:t.x,y:t.y};this.getHover(a)}else{const a={id:It(),x:t.x,y:t.y};this.store.activeAnchor=p_(s,a)}}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(He)>0){const s=t.id;t=this.store.pens[s.replace(He,"")]}t.anchors.forEach(s=>{if(s.connectTo&&!i.find(n=>n.id===s.connectTo||n.id===s.connectTo+He)){const n=this.store.pens[s.connectTo];if(!n||n.type)return;_n(n,Ls(n,s.anchorId),t,s)}})}translatePens(t=this.store.active,i,s,n){if(!t||!t.length||t.some(o=>{if(o.locked>=Ot.DisableMove)return!0}))return;const r=!n&&ht(t,!0);this.activeRect&&Ms(this.activeRect,i,s);const l=this.getAllByPens(t);t.forEach(o=>{var u,c;if(!(o.locked>=Ot.DisableMove)){if(o.type===jt.Line){if(!this.store.options.moveConnectedLine&&!this.canMoveLine||o.isRuleLine)return;yf(o,i,s),this.checkDisconnect(o,l),this.store.path2dMap.set(o,kt.path2dDraws[o.name](o)),n||(this.initLineRect(o),(u=o.connectedLines)==null||u.forEach(f=>{const g=this.store.pens[f.lineId];this.initLineRect(g)}))}else Ms(o.calculative.worldRect,i,s),this.updatePenRect(o,{worldRectIsReady:!0}),o.calculative.x=o.x,o.calculative.y=o.y,o.calculative.initRect&&(o.calculative.initRect.x=o.calculative.x,o.calculative.initRect.y=o.calculative.y,o.calculative.initRect.ex=o.calculative.x+o.calculative.width,o.calculative.initRect.ey=o.calculative.y+o.calculative.height);this.updateLines(o),(c=o.onMove)==null||c.call(o,o)}}),this.activeRect&&this.getSizeCPs(),this.render(),this.tooltip.translate(i,s),n||(this.pushHistory({type:bt.Update,pens:ht(t,!0),initPens:r}),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(a=>{var r;if(a.type===jt.Line){if(!this.store.options.moveConnectedLine&&!this.canMoveLine)return;yf(a,i,s),this.checkDisconnect(a,n),this.store.path2dMap.set(a,kt.path2dDraws[a.name](a))}else Ms(a.calculative.worldRect,i,s),this.updatePenRect(a,{worldRectIsReady:!0}),a.calculative.x=a.x,a.calculative.y=a.y,a.calculative.initRect&&(a.calculative.initRect.x=a.calculative.x,a.calculative.initRect.y=a.calculative.y,a.calculative.initRect.ex=a.calculative.x+a.calculative.width,a.calculative.initRect.ey=a.calculative.y+a.calculative.height);(r=a.onMove)==null||r.call(a,a)})}calcAutoAnchor(t,i,s,n){const a=le(t),r=$t(t),l=xn(s,i===a?r:a);!l||(i.x=l.x,i.y=l.y,i.prev=void 0,i.next=void 0,n?n.anchor=l.id:we(s,l,t,i),this[t.lineName]&&this[t.lineName](this.store,t),this.store.path2dMap.set(t,kt.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 r in t)r!=="x"&&r!=="y"&&r!=="width"&&r!=="height"&&r!=="initRect"&&r!=="rotate"&&(typeof t[r]!="object"||r==="lineDash")&&(t.calculative[r]=t[r]);(i=t.children)!=null&&i.length?n&&ag(t,n,t.calculative.worldRect):t.calculative.rotate=t.rotate;const a=ht(this.store.animateMap.get(t));a&&(a.id=t.id,this.parent.setValue(a,{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,_a(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 a=this.store.pens[n];a&&this.updateLines(a,i)}),t.connectedLines&&t.connectedLines.forEach((n,a)=>{const r=this.store.pens[n.lineId];if(!r||r.calculative.active)return;const l=Ls(r,n.lineAnchor);if(!l)return;if(!l.connectTo){t.connectedLines.splice(a,1);return}if(r.autoFrom){const g=le(r);g.id===l.id&&this.calcAutoAnchor(r,g,t,n)}if(r.autoTo){const g=$t(r);g.id===l.id&&this.calcAutoAnchor(r,g,t,n)}const o=Ls(t,n.anchor);if(!o)return;let u=t.rotate;t.flipX&&(u*=-1),t.flipY&&(u*=-1);let c=l.distance*this.store.data.scale*Math.cos((u+o.rotate)/180*Math.PI)||0,f=l.distance*this.store.data.scale*Math.sin((u+o.rotate)/180*Math.PI)||0;if(t.flipX&&(c=-c),t.flipY&&(f=-f),aa(l,o.x-l.x+c,o.y-l.y+f),this.store.options.autoPolyline&&!this.autoPolylineFlag&&r.autoPolyline!==!1&&r.lineName==="polyline"){let g=le(r),v=$t(r),y=!1;g.id===l.id?(g=l,y=!0):v.id===l.id&&(v=l,y=!0),y&&(r.calculative.worldAnchors=[g,v],r.calculative.activeAnchor=g,this.polyline(this.store,r,v),this.initLineRect(r))}this.store.path2dMap.set(r,kt.path2dDraws[r.name](r)),this.patchFlagsLines.add(r),r.calculative.gradientSmooth&&(r.calculative.gradientAnimatePath=pc(r)),i&&Yr(r)})}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,Qt(this.activeRect)):(this.activeRect=hi(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),Lr(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 a=this.store.pens[n];this.rotatePen(a,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,a,r,l,o;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(),(a=s.onStartVideo)==null||a.call(s,s);else if(s.type||((r=s.frames)==null?void 0:r.length)||s.animations&&s.animations.length){if(s.type){if((o=s.animations)!=null&&o.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=(l=s.animations)==null?void 0:l.findIndex(g=>g.autoPlay),c=u===-1?0:u;const f=ht(s.animations[c]);delete f.name,f.currentAnimation=c,!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)x_(n,t)?n.calculative.patchFlags&&(Qt(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(!k_(n,t)){if(n.keepAnimateState){for(const a in n)n.calculative[a]!==void 0&&a!=="length"&&(typeof n[a]!="object"||a==="lineDash")&&(a==="lineWidth"?n[a]=n.calculative[a]/n.calculative.canvas.store.data.scale:n[a]=n.calculative[a]);Lr(n)}else for(const a in n)(typeof n[a]!="object"||a==="lineDash")&&(a==="lineWidth"?n.calculative[a]=n[a]*n.calculative.canvas.store.data.scale:n.calculative[a]=n[a]);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:a}=this.store.data;this.store.clipboard=void 0,localStorage.removeItem(this.clipboardName),sessionStorage.setItem("page",s);let r=this.getAllByPens(ht(t||this.store.active,!0));r.forEach(o=>{o.copyIndex=this.store.data.pens.findIndex(u=>u.id===o.id),o.pathId&&(o.path=this.store.data.paths[o.pathId])}),r.sort((o,u)=>o.copyIndex-u.copyIndex);const l={meta2d:!0,pens:r,origin:ht(n),scale:a,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(l))}catch{localStorage.setItem(this.clipboardName,JSON.stringify(l))}else localStorage.setItem(this.clipboardName,JSON.stringify(l));i&&this.store.emitter.emit("copy",l.pens)}cut(t){this.copy(t,!1),this.delete(t),this.store.emitter.emit("cut",t)}async paste(){var o,u;let t,i;if(navigator.clipboard&&!this.store.options.disableClipboard&&!navigator.userAgent.includes("Firefox"))try{t=await((o=navigator.clipboard)==null?void 0:o.readText())}catch{t=localStorage.getItem(this.clipboardName)}else t=localStorage.getItem(this.clipboardName);if(t){try{i=JSON.parse(t)}catch(c){console.warn("\u526A\u5207\u677F\u6570\u636E\u4E0D\u662Fjson",c.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 a=sessionStorage.getItem("page"),r=this.store.data.scale;if(this.store.clipboard.mousePos&&(Math.abs(this.store.clipboard.mousePos.x-this.mousePos.x)>100*r||Math.abs(this.store.clipboard.mousePos.y-this.mousePos.y)>100*r)){let c=-this.store.clipboard.initRect.width/this.store.clipboard.scale/10/r,f=-this.store.clipboard.initRect.height/this.store.clipboard.scale/10/r,g=(r-this.store.clipboard.scale)*this.store.clipboard.initRect.width/2+c,v=(r-this.store.clipboard.scale)*this.store.clipboard.initRect.height/2+f;r<this.store.clipboard.scale&&(g=(r-this.store.clipboard.scale)/((this.store.clipboard.scale-r)*100)*this.store.clipboard.initRect.width/2+c,v=(r-this.store.clipboard.scale)/((this.store.clipboard.scale-r)*100)*this.store.clipboard.initRect.height/2+f),this.store.clipboard.pens.length>1&&(g=(r-1)*this.store.clipboard.initRect.width/this.store.clipboard.scale/2,v=(r-1)*this.store.clipboard.initRect.height/this.store.clipboard.scale/2),this.store.clipboard.pos={x:this.mousePos.x-g,y:this.mousePos.y-v},this.store.clipboard.offset=0}else a!==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(c=>{delete c.copyIndex});const l=this.store.clipboard.pens.filter(c=>!c.parentId);for(const c of l)this.pastePen(c,void 0);sessionStorage.setItem("page",i.page),this.active(l),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(Qe(s,this.store),!0));return i.concat(t)}getAllFollowersByPens(t,i=!0){const s=t;for(const n of t){let a=yc(n,this.store);i&&(a=ht(a,!0));for(const r of a)s.find(l=>l.id===r.id)||s.push(r)}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:a}=i.connectedLines[n],r=s.find(l=>l.id===a);if(r){const l=r.anchors[0],o=r.anchors[r.anchors.length-1];l.connectTo===t&&(l.connectTo=i.id),o.connectTo===t&&(o.connectTo=i.id)}else i.connectedLines.splice(n,1),n--}}changeNodeConnectedLine(t,i,s){var l;const n=i.anchors[0],a=i.anchors[i.anchors.length-1],r=[n,a];for(const o of r){const u=o.connectTo;if(u){const c=s.find(f=>f.id===u);c?(l=c.connectedLines)==null||l.forEach(f=>{f.lineId===t&&(f.lineId=i.id,f.lineAnchor=o.id)}):(o.connectTo=void 0,o.prev&&(o.prev.connectTo=void 0),o.next&&(o.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(a=>!a.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 r=ti(n),l=r.children.indexOf(n.id);r.children.splice(l,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=ti(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:a}=t.connectedLines[s],r=this.store.pens[n];if(r){let l=r.anchors.find(o=>o.id===a);(l==null?void 0:l.connectTo)===t.id&&(l.connectTo=void 0,l.anchorId=void 0,l.prev&&(l.prev.connectTo=void 0),l.next&&(l.next.connectTo=void 0)),l=Ls(r,a),l&&(l.connectTo=void 0,l.anchorId=void 0,l.prev&&(l.prev.connectTo=void 0),l.next&&(l.next.connectTo=void 0))}}!t.type||(i=t.calculative.worldAnchors)==null||i.forEach((s,n)=>{var r;if(!s.connectTo)return;const a=this.store.pens[s.connectTo];a&&((r=a.calculative.worldAnchors)==null||r.forEach(l=>{_n(a,l,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,a=n.replace(/[^0-9]/g,"");n!==a&&(i.preventDefault(),i.target.innerText=a)}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,a,r,l,o,u,c;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=(a=f.children)==null?void 0:a.findIndex(v=>v===t);g!==-1&&((r=f.children)==null||r.splice(g,1,i))}(l=s.children)==null||l.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),(o=s.connectedLines)==null||o.forEach(({lineId:f})=>{const g=this.store.pens[f];An(g)})),(u=s.anchors)==null||u.forEach(f=>f.penId=i),(c=s.calculative.worldAnchors)==null||c.forEach(f=>f.penId=i)}}updateValue(t,i){var y,w,m,_,E,x;const s=this.getPenRect(t),n=t.name;Object.assign(t,i);const a=n!==t.name;i.newId&&this.changePenId(t.id,i.newId);let r=!1,l=!1,o=!1,u=!1,c=!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]),rx.includes(C)&&(l=!0),["name","borderRadius","lineSmooth","close"].includes(C)&&(r=!0),ox.includes(C)&&(c=!0),lx.includes(C)&&(o=!0),cx.includes(C)&&(u=!0),t.image&&t.name!=="gif"&&Bd.includes(C)&&(v=!0)):(delete t[C],$r(t,C,i[C])),C.split(".")[0]==="anchors"&&An(t);if(this.setCalculativeByScale(t),a&&((y=t.onDestroy)==null||y.call(t,t),hx(t)),c){const C={x:(w=i.x)!=null?w:s.x,y:(m=i.y)!=null?m: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 o?this.updatePenRect(t):(l&&Ri(t),u&&vf(this.store.pens,t),r&&kt.path2dDraws[t.name]&&this.store.path2dMap.set(t,kt.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&&Re(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 a=this.store.pens[n];a&&this.execPenResize(a)})}setPenRect(t,i,s=!0){if(t.parentId)Object.assign(t,i);else{const{origin:n,scale:a}=this.store.data;t.x=n.x+i.x*a,t.y=n.y+i.y*a,t.width=i.width*a,t.height=i.height*a}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 a=hi(this.store.data.pens),r=this.store.data.scale;if(!isFinite(a.width))throw new Error("can not to png, because width is not finite");const l=ht(a),o=this.store.data,u=s&&this.store.bkImg;let c=!1,f=!1;if(u){if(a.x+=o.x,a.y+=o.y,re(a),Xi(a,this.canvasRect,!0))Object.assign(a,this.canvasRect);else{const S=ka([...Zi(a),...Zi(this.canvasRect)]);Object.assign(a,S)}c=a.x===0,f=a.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&&(a.x=this.store.data.origin.x,a.y=this.store.data.origin.y,a.width=g*this.store.data.scale,a.height=v*this.store.data.scale);const w=ht(a),m=qi(t);a.x-=m[3]*r,a.y-=m[0]*r,a.width+=(m[3]+m[1])*r,a.height+=(m[0]+m[2])*r;const _=(n||1920)/a.width;a.width*=_,a.height*=_,re(a);const E=document.createElement("canvas");if(E.width=a.width,E.height=a.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.options.downloadBgTransparent?void 0:this.store.data.background||this.store.styles.background;if(C&&y&&(x.save(),x.fillStyle=C,x.fillRect(0,0,w.width+(m[1]+m[3])*r,w.height+(m[0]+m[2])*r),x.restore()),u)if(y)x.drawImage(this.store.bkImg,m[3]*r||0,m[0]*r||0,w.width,w.height);else{const S=a.x<0?-a.x:0,L=a.y<0?-a.y:0;x.drawImage(this.store.bkImg,S,L,this.canvasRect.width,this.canvasRect.height)}if(C&&!y)if(u){const S=a.x<0?-a.x:0,L=a.y<0?-a.y:0;x.save(),x.fillStyle=C,x.fillRect(S,L,this.canvasRect.width,this.canvasRect.height),x.restore()}else x.save(),x.fillStyle=C,x.fillRect(0,0,l.width+(m[3]+m[1])*r,l.height+(m[0]+m[2])*r),x.restore();u?y?x.translate(-a.x,-a.y):x.translate((c?o.x:-l.x)+m[3]*r||0,(f?o.y:-l.y)+m[0]*r||0):x.translate(-a.x,-a.y);for(const S of this.store.data.pens){if(!Vr(S,this.store)||S.visible==!1)continue;const{active:L}=S.calculative;S.calculative.active=!1,S.calculative.img?jr(x,S):Is(x,S,!0),S.calculative.active=L}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 a=n.map(v=>v.id);const r=hi(n);if(!isFinite(r.width))throw new Error("can not to png, because width is not finite");const l=ht(r),o=qi(i);r.x-=o[3],r.y-=o[0],r.width+=o[3]+o[1],r.height+=o[0]+o[2],re(r);const u=(s||r.width)/r.width;r.width*=u,r.height*=u;const c=document.createElement("canvas");if(c.width=r.width,c.height=r.height,c.width>32767||c.height>32767||!navigator.userAgent.includes("Firefox")&&c.height*c.width>268435456||navigator.userAgent.includes("Firefox")&&c.height*c.width>472907776)throw new Error("can not to png, because the size exceeds the browser limit");const f=c.getContext("2d");f.textBaseline="middle",f.scale(u,u);const g=this.store.options.downloadBgTransparent?void 0:this.store.data.background||this.store.styles.background;g&&(f.save(),f.fillStyle=g,f.fillRect(0,0,l.width+(o[3]+o[1]),l.height+(o[0]+o[2])),f.restore()),f.translate(-l.x+o[3],-l.y+o[0]);for(const v of this.store.data.pens)if(a.includes(v.id)){if(!Vr(v,this.store)||v.visible==!1)continue;const{active:y}=v.calculative;v.calculative.active=!1,v.calculative.img?jr(f,v):Is(f,v),v.calculative.active=y}return c.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=Ns.Mirror),this.store.activeAnchor.prevNextType=(this.store.activeAnchor.prevNextType+1)%3)}gotoView(t,i){let s=hi(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,a=this.store.data.height||this.store.options.height;n&&a&&(s={x:this.store.data.origin.x,y:this.store.data.origin.y,width:n*this.store.data.scale,height:a*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.magnifierCanvas.render(),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?Ll(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,a=this.store.data.height||this.store.options.height;let r=(Math.floor(i.x)-this.store.data.origin.x)/s/n,l=(Math.floor(i.y)-this.store.data.origin.y)/s/a,o={x:r,y:l,width:(Math.ceil(i.width)+1)/s/n,height:(Math.ceil(i.height)+1)/s/a,children:t.map(u=>u.id),id:It(),active:!0};o.x<-.1&&(o.x=-.1),o.y<-.1&&(o.y=-.1),o.width>.5?(o.left=!0,o.right=!0,o.leftValue=(o.x-0)*s*n,o.rightValue=(1-(o.x+o.width))*s*n):o.x<.5?(o.left=!0,o.leftValue=(o.x-0)*s*n):(o.right=!0,o.rightValue=(1-(o.x+o.width))*s*n),o.leftValue<1&&(o.leftValue=0),o.rightValue<1&&(o.rightValue=0),o.height>.5?(o.top=!0,o.bottom=!0,o.topValue=(o.y-0)*s*a,o.bottomValue=(1-(o.y+o.height))*s*a):o.y<.5?(o.top=!0,o.topValue=(o.y-0)*s*a):(o.bottom=!0,o.bottomValue=(1-(o.y+o.height))*s*a),o.topValue<1&&(o.topValue=0),o.bottomValue<1&&(o.bottomValue=0),this.store.data.fits||(this.store.data.fits=[]),this.store.data.fits.forEach(u=>{u.active=!1}),this.store.data.fits.push(o),this.canvasImage.activeFit=o,this.store.emitter.emit("fit",o),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 a=(t.x-this.store.data.origin.x)/i/s,r=(t.y-this.store.data.origin.y)/i/n;if(this.canvasImage.currentFit){const l=this.canvasImage.activeFit;if(this.canvasImage.currentFit==="top"){r<-.1&&(r=-.1);let c=r-l.y;if(l.height-=c,l.height<.01){l.height=.01;return}l.y=r}if(this.canvasImage.currentFit==="bottom"&&(r>1.1&&(r=1.1),l.height=r-l.y,l.height<=.01&&(l.height=.01)),this.canvasImage.currentFit==="left"){a<-.1&&(a=-.1);let c=a-l.x;if(l.width-=c,l.width<.01){l.width=.01;return}l.x=a}this.canvasImage.currentFit==="right"&&(a>1.1&&(a=1.1),l.width=a-l.x,l.width<=.01&&(l.width=.01));let o={x:l.x*s*i+this.store.data.origin.x,y:l.y*n*i+this.store.data.origin.y,width:l.width*s*i,height:l.height*n*i};re(o);const u=this.store.data.pens.filter(c=>{if(c.parentId||c.isRuleLine)return!1;if(Xi(c.calculative.worldRect,o,!0))return c.type===jt.Line&&!this.store.options.dragAllIn?Ll(c,o):!0});l.left=void 0,l.leftValue=void 0,l.right=void 0,l.rightValue=void 0,l.top=void 0,l.topValue=void 0,l.bottom=void 0,l.bottomValue=void 0,l.width>.5?(l.left=!0,l.right=!0,l.leftValue=(l.x-0)*i*s,l.rightValue=(1-(l.x+l.width))*i*s):l.x<.5?(l.left=!0,l.leftValue=(l.x-0)*i*s):(l.right=!0,l.rightValue=(1-(l.x+l.width))*i*s),Math.abs(l.leftValue)<1&&(l.leftValue=0),Math.abs(l.rightValue)<1&&(l.rightValue=0),l.height>.5?(l.top=!0,l.bottom=!0,l.topValue=(l.y-0)*i*n,l.bottomValue=(1-(l.y+l.height))*i*n):l.y<.5?(l.top=!0,l.topValue=(l.y-0)*i*n):(l.bottom=!0,l.bottomValue=(1-(l.y+l.height))*i*n),Math.abs(l.topValue)<1&&(l.topValue=0),Math.abs(l.bottomValue)<1&&(l.bottomValue=0),l.children=u.map(c=>c.id),this.store.emitter.emit("fit",l),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 l;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,a=-1,r=-1;(l=this.store.data.fits)==null||l.forEach((o,u)=>{o.ex=null,o.ey=null,Ui({x:s,y:n},o)&&(a=u),o.active&&(r=u)}),a!==-1&&a!==r?(this.canvasImage.activeFit=this.store.data.fits[a],this.store.data.fits[a].active=!0,r!==-1&&(this.store.data.fits[r].active=!1),this.store.emitter.emit("fit",this.store.data.fits[a])):a===-1&&r!==-1&&(this.store.data.fits[r].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=a=>a.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 Z2(e,t){const i=t||new Path2D;e.onDestroy||(e.onDestroy=Q2,e.onMove=zf,e.onRotate=zf,e.onMouseEnter=tk,e.onMouseLeave=ek,e.onMouseMove=sk,e.onMouseUp=ik,e.onInput=J2),e.formId=e.id;let s=e.calculative.borderRadius||0,n=s;const{x:a,y:r,width:l,height:o,ex:u,ey:c}=e.calculative.worldRect;e.calculative.worldTextRect,s<1&&(s=l*s,n=o*n);let f=s<n?s:n;if(l<2*f&&(f=l/2),o<2*f&&(f=o/2),i.moveTo(a+f,r),i.arcTo(u,r,u,c,f),i.arcTo(u,c,a,c,f),i.arcTo(a,c,a,r,f),i.arcTo(a,r,u,r,f),i instanceof Path2D)return i}function J2(e,t){e.text=t,e.calculative.text=e.text,e.calculative.canvas.updatePenRect(e)}function Q2(e){}function zf(e){}function tk(e){}function ek(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+He];n&&n.calculative&&(Xi(n.calculative.worldRect,e.calculative.worldRect,!0)||(e.followers.splice(s,1),delete i.formId))}}})}function ik(e){const t=e.calculative.canvas.store.active;t&&t.length&&t.forEach(i=>{const s=e.calculative.canvas.store.pens[i.id+He];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 sk(e,t){}function Hf(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 nk(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 a="";Array.isArray(n)&&(a=[]),e.calculative.canvas.parent.setValue({id:s.id,[s.formValue]:a},{render:!1,doEvent:!1,history:!1})}}),t.formData={},e.calculative.canvas.parent.render()}const ge={};function ak(e){e.onDestroy||(e.onDestroy=rk,e.onMove=Wf,e.onResize=ok,e.onRotate=Wf,e.onValue=lk,e.onChangeId=ck);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 a;ge[s]===n&&(e.calculative.img=n,e.calculative.imgNaturalWidth=n.naturalWidth||e.iconWidth,e.calculative.imgNaturalHeight=n.naturalHeight||e.iconHeight,(a=e.calculative.canvas.externalElements)==null||a.parentElement.appendChild(n),ya(e,n))}}return e.calculative.patchFlags&&ge[s]&&ya(e,ge[s]),t}function rk(e){const i=e.calculative.canvas.store.id+"-"+e.id;ge[i]&&(ge[i].remove(),ge[i]=void 0)}function Wf(e){const i=e.calculative.canvas.store.id+"-"+e.id;!ge[i]||ya(e,ge[i])}function ok(e){const i=e.calculative.canvas.store.id+"-"+e.id;!ge[i]||ya(e,ge[i])}function lk(e){const i=e.calculative.canvas.store.id+"-"+e.id;!ge[i]||(ya(e,ge[i]),ge[i].getAttribute("src")!==e.image&&(ge[i].src=e.image))}function ck(e,t,i){const s=e.calculative.canvas.store.id;!ge[s+"-"+t]||(ge[s+"-"+i]=ge[s+"-"+t],delete ge[s+"-"+t])}function ya(e,t){t.style.objectFit=e.imageRatio?"contain":"fill",Re(e,t)}function hk(e,t){return e.onResize||(e.onResize=bg,e.onValue=uk),Fs(e,t)}function bg(e){const t=e.anchors.filter(i=>i.flag!==1);xg(e),e.anchors=e.anchors.concat(...t)}function uk(e){bg(e),An(e)}function xg(e){const t=[],{x:i,y:s,width:n,height:a}=e,r=fk(e),l=5;for(let f=0;f<l;f++){if(f===2)continue;let g=i+n*(f+1)/(l+1),v=s;g<i+r?v=Er(i+r,v+r,g,r,-1):g>i+n-r&&(v=Er(i+n-r,v+r,g,r,-1)),t.push({id:String(t.length),flag:1,penId:e.id,x:(g-i)/n,y:(v-s)/a})}const o=3;for(let f=0;f<o;f++){let g=s+a*(f+1)/(o+1),v=i+n;g<s+r?v=kr(v-r,s+r,g,r):g>s+a-r&&(v=kr(v-r,s+a-r,g,r)),t.push({id:String(t.length),flag:1,penId:e.id,x:(v-i)/n,y:(g-s)/a})}const u=5;for(let f=0;f<u;f++){if(f===2)continue;let g=i+n*(f+1)/(u+1),v=s+a;g<i+r?v=Er(i+r,v-r,g,r):g>i+n-r&&(v=Er(i+n-r,v-r,g,r)),t.push({id:String(t.length),flag:1,penId:e.id,x:(g-i)/n,y:(v-s)/a})}const c=3;for(let f=0;f<c;f++){let g=s+a*(f+1)/(c+1),v=i;g<s+r?v=kr(v+r,s+r,g,r,-1):g>s+a-r&&(v=kr(v+r,s+a-r,g,r,-1)),t.push({id:String(t.length),flag:1,penId:e.id,x:(v-i)/n,y:(g-s)/a})}e.anchors=t}function fk(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 a=t<i?t:i;return s<2*a&&(a=s/2),n<2*a&&(a=n/2),a}function kr(e,t,i,s,n=1){return n*Math.sqrt(s**2-(i-t)**2)+e}function Er(e,t,i,s,n=1){return n*Math.sqrt(s**2-(i-e)**2)+t}function dk(e,t){const i=t||new Path2D,{x:s,y:n,width:a,height:r}=e.calculative.worldRect;if(i.moveTo(s,n+r),i.lineTo(s+a,n+r),i.closePath(),i instanceof Path2D)return i}function gk(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 vk(){return{rectangle:Fs,square:nx,circle:ax,svgPath:t2,diamond:e2,triangle:i2,pentagon:n2,pentagram:r2,hexagon:l2,leftArrow:c2,rightArrow:h2,twowayArrow:u2,message:f2,cloud:d2,file:g2,people:y2,line:b2,iframe:F2,video:U2,gif:ak,mindNode:hk,mindLine:dk,mindNode2:Fs,form:Z2,combine:Fs}}function yk(){return{triangle:s2,pentagon:a2,pentagram:cg,mindNode:xg,mindLine:gk}}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 mk{constructor(t){W(this,"parent");W(this,"box");W(this,"boxWidth",320);W(this,"boxHeight",180);W(this,"ratio",this.boxWidth/this.boxHeight);W(this,"padding",5);W(this,"img");W(this,"isShow");W(this,"isDown");W(this,"view");W(this,"timer");W(this,"onMouseDown",t=>{t.preventDefault(),t.stopPropagation(),this.isDown=!0});W(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}});W(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}});W(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 o=.2;t.deltaY.toString().indexOf(".")!==-1&&(o=.01),t.deltaY>0?i=-o:i=o}let{offsetX:s,offsetY:n}=t;const a=this.parent.store.data.width||this.parent.store.options.width,r=this.parent.store.data.height||this.parent.store.options.height;if(a&&r)s=s/this.boxWidth*a*this.parent.store.data.scale+this.parent.store.data.origin.x+this.parent.store.data.x,n=n/this.boxHeight*r*this.parent.store.data.scale+this.parent.store.data.origin.y+this.parent.store.data.y;else{const l=this.parent.parent.getRect();s=s/this.boxWidth*l.width+l.x+this.parent.store.data.x,n=n/this.boxHeight*l.height+l.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=hi(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,re(i)}else{const f=i.height*this.ratio;i.x-=(f-i.width)/2,i.width=f,re(i)}const r=this.parent.canvasRect;let l=0,o=0;if(i.x<0)l=-i.x/i.width;else if(i.x+i.width>r.width){let f=0;r.width>i.width&&(f=r.width-i.width),l=(-i.x+f)/i.width}if(i.y<0)o=-i.y/i.height;else if(i.y+i.height>r.height){let f=0;r.height>i.height&&(f=r.height-i.height),o=(-i.y+f)/i.height}const u=r.width>i.width?1:r.width/i.width,c=r.height>i.height?1:r.height/i.height;this.view.style.left=this.padding+l*this.boxWidth+"px",this.view.style.width=u*this.boxWidth+"px",this.view.style.top=this.padding+o*this.boxHeight+"px",this.view.style.height=c*this.boxHeight+"px"}}}function Ar(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 ia={exports:{}};(function(e,t){(function(i){e.exports=i()})(function(){return function(){return function i(s,n,a){function r(u,c){if(!n[u]){if(!s[u]){var f=typeof Ar=="function"&&Ar;if(!c&&f)return f(u,!0);if(l)return l(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 r(s[u][1][y]||y)},v,v.exports,i,s,n,a)}return n[u].exports}for(var l=typeof Ar=="function"&&Ar,o=0;o<a.length;o++)r(a[o]);return r}}()({1:[function(i,s,n){(function(a,r){(function(){const l=i("events").EventEmitter,o=i("./store"),u=i("./topic-alias-recv"),c=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"),m=i("rfdc/default"),_=i("./validations"),E=i("xtend"),x=i("debug")("mqttjs:client"),C=a?a.nextTick:function(P){setTimeout(P,0)},S=r.setImmediate||function(P){C(P)},L={keepalive:60,reschedulePings:!0,protocolId:"MQTT",protocolVersion:4,reconnectPeriod:1e3,connectTimeout:3e4,clean:!0,resubscribe:!0},M={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 D(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 $(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!==R?(x("sendPacket :: handle events on `drain` once through callback."),P.stream.once("drain",Y)):Y&&(x("sendPacket :: invoking cb"),Y())}function Q(P,O,Y,Z){x("storeAndSend :: store packet with cmd %s to outgoingStore",O.cmd);let at,V=O;if(V.cmd==="publish"&&(V=m(O),at=D(P,V)))return Y&&Y(at);P.outgoingStore.put(V,function(H){if(H)return Y&&Y(H);Z(),$(P,O,Y)})}function R(P){x("nop ::",P)}function T(P,O){let Y;const Z=this;if(!(this instanceof T))return new T(P,O);for(Y in this.options=O||{},L)this.options[Y]===void 0?this.options[Y]=L[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 o,this.incomingStore=O.incomingStore||new o,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 at=this.queue;x("connect :: sending queued packets"),function V(){const H=at.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(U){H.cb&&H.cb(U),V()}):(x("messageId: %d has already used. The message is skipped and removed.",j.messageId),V())}()}),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()}),l.call(this),x("MqttClient :: setting up stream"),this._setupStream()}y(T,l),T.prototype._setupStream=function(){const P=this,O=new v,Y=f.parser(this.options);let Z=null;const at=[];function V(){if(at.length)C(H);else{const K=Z;Z=null,K()}}function H(){x("work :: getting next packet in queue");const K=at.shift();if(K)x("work :: packet pulled from queue"),P._handlePacket(K,V);else{x("work :: no packets in queue");const U=Z;Z=null,x("work :: done flag is %s",!!U),U&&U()}}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."),at.push(K)}),O._write=function(K,U,tt){Z=tt,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)):R(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(U){K[U].volatile&&typeof K[U].cb=="function"&&(K[U].cb(new Error("Connection closed")),delete K[U])})),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)),$(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"&&$(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)},T.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()}},T.prototype._checkDisconnecting=function(P){return this.disconnecting&&(P&&P!==R?P(new Error("client disconnecting")):this.emit("error",new Error("client disconnecting"))),this.disconnecting},T.prototype.publish=function(P,O,Y,Z){x("publish :: message `%s` to topic `%s`",O,P);const at=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 V=this,H=function(){let j=0;if((Y.qos===1||Y.qos===2)&&(j=V._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(at.protocolVersion===5&&(K.properties=Y.properties),x("publish :: qos",Y.qos),Y.qos){case 1:case 2:V.outgoing[K.messageId]={volatile:!1,cb:Z||R},x("MqttClient:publish: packet cmd: %s",K.cmd),V._sendPacket(K,void 0,Y.cbStorePut);break;default:x("MqttClient:publish: packet cmd: %s",K.cmd),V._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},T.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 at=Z.resubscribe;let V=O.pop()||R,H=O.pop();const j=this.options.protocolVersion;delete Z.resubscribe,typeof Z=="string"&&(Z=[Z]),typeof V!="function"&&(H=V,V=R);const K=_.validateTopics(Z);if(K!==null)return S(V,new Error("Invalid topic "+K)),this;if(this._checkDisconnecting(V))return x("subscribe: discconecting true"),this;const U={qos:0};if(j===5&&(U.nl=!1,U.rap=!1,U.rh=0),H=E(U,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||at){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||at){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 V(null,[]),this;const tt=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]}V(ut,Y)}},x("subscribe :: call _sendPacket"),P._sendPacket(et),!0};return(this._storeProcessing||this._storeProcessingQueue.length>0||!tt())&&this._storeProcessingQueue.push({invoke:tt,callback:V}),this},T.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()||R,at=O.pop();typeof Y=="string"&&(Y=[Y]),typeof Z!="function"&&(at=Z,Z=R);const V=_.validateTopics(Y);if(V!==null)return S(Z,new Error("Invalid topic "+V)),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(U){delete P._resubscribeTopics[U]}),typeof at=="object"&&at.properties&&(K.properties=at.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},T.prototype.end=function(P,O,Y){const Z=this;function at(){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(V){Z.outgoingStore.close(function(H){if(x("end :: closeStores: emitting end"),Z.emit("end"),Y){const j=V||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||R,O=P,P=!1,typeof O!="object"&&(Y=O,O=null,typeof Y!="function"&&(Y=R))),typeof O!="object"&&(Y=O,O=null),x("end :: cb? %s",!!Y),Y=Y||R,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,at,10))):(x("end :: (%s) :: immediately calling finish",Z.options.clientId),at()),this)},T.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},T.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 o,O.outgoingStore=O.options.outgoingStore||new o,O.disconnecting=!1,O.disconnected=!1,O._deferredReconnect=null,O._reconnect()};return this.disconnecting&&!this.disconnected?this._deferredReconnect=Y:Y(),this},T.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())},T.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...")},T.prototype._clearReconnect=function(){x("_clearReconnect : clearing reconnect timer"),this.reconnectTimer&&(clearInterval(this.reconnectTimer),this.reconnectTimer=null)},T.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(at){typeof Z[at].cb=="function"&&(Z[at].cb(new Error("Connection closed")),delete Z[at])})),x("_cleanUp :: (%s) :: destroying stream",this.options.clientId),this.stream.destroy();else{const at=E({cmd:"disconnect"},Y);x("_cleanUp :: (%s) :: call _sendPacket with disconnect packet",this.options.clientId),this._sendPacket(at,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())},T.prototype._sendPacket=function(P,O,Y){x("_sendPacket :: (%s) :: start",this.options.clientId),Y=Y||R,O=O||R;const Z=function(at,V){if(at.options.protocolVersion===5&&V.cmd==="publish"){let H;V.properties&&(H=V.properties.topicAlias);const j=V.topic.toString();if(at.topicAliasSend)if(H){if(j.length!==0&&(x("applyTopicAlias :: register topic: %s - alias: %d",j,H),!at.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&&(at.options.autoAssignTopicAlias?(H=at.topicAliasSend.getAliasByTopic(j))?(V.topic="",V.properties={...V.properties,topicAlias:H},x("applyTopicAlias :: auto assign(use) topic: %s - alias: %d",j,H)):(H=at.topicAliasSend.getLruAlias(),at.topicAliasSend.put(j,H),V.properties={...V.properties,topicAlias:H},x("applyTopicAlias :: auto assign topic: %s - alias: %d",j,H)):at.options.autoUseTopicAlias&&(H=at.topicAliasSend.getAliasByTopic(j))&&(V.topic="",V.properties={...V.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 $(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 Q(this,P,O,Y);default:return void $(this,P,O)}switch(P.qos){case 2:case 1:Q(this,P,O,Y);break;case 0:default:$(this,P,O)}x("_sendPacket :: (%s) :: end",this.options.clientId)}},T.prototype._storePacket=function(P,O,Y){x("_storePacket :: packet: %o",P),x("_storePacket :: cb? %s",!!O),Y=Y||R;let Z=P;if(Z.cmd==="publish"){const at=D(this,Z=m(P));if(at)return O&&O(at)}(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(at){if(at)return O&&O(at);Y()})):O&&O(new Error("No connection to broker"))},T.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))},T.prototype._shiftPingInterval=function(){this.pingTimer&&this.options.keepalive&&this.options.reschedulePings&&this.pingTimer.reschedule(1e3*this.options.keepalive)},T.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))},T.prototype._handlePingresp=function(){this.pingResp=!0},T.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 c(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: "+M[Y]);Z.code=Y,this.emit("error",Z)}},T.prototype._handleAuth=function(P){const O=this.options.protocolVersion,Y=O===5?P.reasonCode:P.returnCode;if(O!==5){const at=new Error("Protocol error: Auth packets are only supported in MQTT 5. Your version:"+O);return at.code=Y,void this.emit("error",at)}const Z=this;this.handleAuth(P,function(at,V){if(at)Z.emit("error",at);else if(Y===24)Z.reconnecting=!1,Z._sendPacket(V);else{const H=new Error("Connection refused: "+M[Y]);at.code=Y,Z.emit("error",H)}})},T.prototype.handleAuth=function(P,O){O()},T.prototype._handlePublish=function(P,O){x("_handlePublish: packet %o",P),O=O!==void 0?O:R;let Y=P.topic.toString();const Z=P.payload,at=P.qos,V=P.messageId,H=this,j=this.options,K=[0,16,128,131,135,144,145,151,153];if(this.options.protocolVersion===5){let U;if(P.properties&&(U=P.properties.topicAlias),U!==void 0)if(Y.length===0){if(!(U>0&&U<=65535))return x("_handlePublish :: topic alias out of range. alias: %d",U),void this.emit("error",new Error("Received Topic Alias is out of range"));{const tt=this.topicAliasRecv.getTopicByAlias(U);if(!tt)return x("_handlePublish :: unregistered topic alias. alias: %d",U),void this.emit("error",new Error("Received unregistered Topic Alias"));x("_handlePublish :: topic complemented by alias. topic: %s - alias: %d",Y=tt,U)}}else{if(!this.topicAliasRecv.put(Y,U))return x("_handlePublish :: topic alias out of range. alias: %d",U),void this.emit("error",new Error("Received Topic Alias is out of range"));x("_handlePublish :: registered topic: %s - alias: %d",Y,U)}}switch(x("_handlePublish: qos %d",at),at){case 2:j.customHandleAcks(Y,Z,P,function(U,tt){return U instanceof Error||(tt=U,U=null),U?H.emit("error",U):K.indexOf(tt)===-1?H.emit("error",new Error("Wrong reason code for pubrec")):void(tt?H._sendPacket({cmd:"pubrec",messageId:V,reasonCode:tt},O):H.incomingStore.put(P,function(){H._sendPacket({cmd:"pubrec",messageId:V},O)}))});break;case 1:j.customHandleAcks(Y,Z,P,function(U,tt){return U instanceof Error||(tt=U,U=null),U?H.emit("error",U):K.indexOf(tt)===-1?H.emit("error",new Error("Wrong reason code for puback")):(tt||H.emit("message",Y,Z,P),void H.handleMessage(P,function(st){if(st)return O&&O(st);H._sendPacket({cmd:"puback",messageId:V,reasonCode:tt},O)}))});break;case 0:this.emit("message",Y,Z,P),this.handleMessage(P,O);break;default:x("_handlePublish: unknown QoS. Doing nothing.")}},T.prototype.handleMessage=function(P,O){O()},T.prototype._handleAck=function(P){const O=P.messageId,Y=P.cmd;let Z=null;const at=this.outgoing[O]?this.outgoing[O].cb:null,V=this;let H;if(at){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: "+M[j])).code=j,at(H,P)),delete this.outgoing[O],this.outgoingStore.del(P,at),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: "+M[j])).code=j,at(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(U){delete V._resubscribeTopics[U]})}this._invokeStoreProcessingQueue(),at(null,P);break;case"unsuback":delete this.outgoing[O],this.messageIdProvider.deallocate(O),this._invokeStoreProcessingQueue(),at(null);break;default:V.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.")},T.prototype._handlePubrel=function(P,O){x("handling pubrel packet"),O=O!==void 0?O:R;const Y=this,Z={cmd:"pubcomp",messageId:P.messageId};Y.incomingStore.get(P,function(at,V){at?Y._sendPacket(Z,O):(Y.emit("message",V.topic,V.payload,V),Y.handleMessage(V,function(H){if(H)return O(H);Y.incomingStore.del(V,R),Y._sendPacket(Z,O)}))})},T.prototype._handleDisconnect=function(P){this.emit("disconnect",P)},T.prototype._nextId=function(){return this.messageIdProvider.allocate()},T.prototype.getLastMessageId=function(){return this.messageIdProvider.getLastAllocated()},T.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},T.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 at(){O._storeProcessing=!1,O._packetIdsDuringStoreProcessing={}}function V(){Z.destroy(),Z=null,O._flushStoreProcessingQueue(),at()}O.once("close",V),Z.on("error",function(H){at(),O._flushStoreProcessingQueue(),O.removeListener("close",V),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?(at(),O.removeListener("close",V),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(U,tt){K&&K(U,tt),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)}()}()},T.prototype._invokeStoreProcessingQueue=function(){if(this._storeProcessingQueue.length>0){const P=this._storeProcessingQueue[0];if(P&&P.invoke())return this._storeProcessingQueue.shift(),!0}return!1},T.prototype._invokeAllStoreProcessingQueue=function(){for(;this._invokeStoreProcessingQueue(););},T.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=T}).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:a}=i("buffer"),r=i("readable-stream").Transform,l=i("duplexify");let o,u,c,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(m){m.hostname||(m.hostname="localhost"),m.path||(m.path="/"),m.wsOptions||(m.wsOptions={})})(v);const w=function(m,_){const E=m.protocol==="alis"?"wss":"ws";let x=E+"://"+m.hostname+m.path;return m.port&&m.port!==80&&m.port!==443&&(x=E+"://"+m.hostname+":"+m.port+m.path),typeof m.transformWsUrl=="function"&&(x=m.transformWsUrl(x,m,_)),x}(v,g);return(o=v.my).connectSocket({url:w,protocols:y}),u=function(){const m=new r;return m._write=function(_,E,x){o.sendSocketMessage({data:_.buffer,success:function(){x()},fail:function(){x(new Error)}})},m._flush=function(_){o.closeSocket({success:function(){_()}})},m}(),c=l.obj(),f||(f=!0,o.onSocketOpen(function(){c.setReadable(u),c.setWritable(u),c.emit("connect")}),o.onSocketMessage(function(m){if(typeof m.data=="string"){const _=a.from(m.data,"base64");u.push(_)}else{const _=new FileReader;_.addEventListener("load",function(){let E=_.result;E=E instanceof ArrayBuffer?a.from(E):a.from(E,"utf8"),u.push(E)}),_.readAsArrayBuffer(m.data)}}),o.onSocketClose(function(){c.end(),c.destroy()}),o.onSocketError(function(m){c.destroy(m)})),c}},{buffer:17,duplexify:20,"readable-stream":69}],3:[function(i,s,n){const a=i("net"),r=i("debug")("mqttjs:tcp");s.exports=function(l,o){o.port=o.port||1883,o.hostname=o.hostname||o.host||"localhost";const u=o.port,c=o.hostname;return r("port %d and host %s",u,c),a.createConnection(u,c)}},{debug:18,net:16}],4:[function(i,s,n){const a=i("tls"),r=i("net"),l=i("debug")("mqttjs:tls");s.exports=function(o,u){u.port=u.port||8883,u.host=u.hostname||u.host||"localhost",r.isIP(u.host)===0&&(u.servername=u.host),u.rejectUnauthorized=u.rejectUnauthorized!==!1,delete u.path,l("port %d host %s rejectUnauthorized %b",u.port,u.host,u.rejectUnauthorized);const c=a.connect(u);function f(g){u.rejectUnauthorized&&o.emit("error",g),c.end()}return c.on("secureConnect",function(){u.rejectUnauthorized&&!c.authorized?c.emit("error",new Error("TLS not authorized")):c.removeListener("error",f)}),c.on("error",f),c}},{debug:18,net:16,tls:16}],5:[function(i,s,n){(function(a){(function(){const{Buffer:r}=i("buffer"),l=i("ws"),o=i("debug")("mqttjs:ws"),u=i("duplexify"),c=i("readable-stream").Transform,f=["rejectUnauthorized","ca","cert","key","pfx","passphrase"],g=a!==void 0&&a.title==="browser"||typeof __webpack_require__=="function";function v(w,m){let _=w.protocol+"://"+w.hostname+":"+w.port+w.path;return typeof w.transformWsUrl=="function"&&(_=w.transformWsUrl(_,w,m)),_}function y(w){const m=w;return w.hostname||(m.hostname="localhost"),w.port||(w.protocol==="wss"?m.port=443:m.port=80),w.path||(m.path="/"),w.wsOptions||(m.wsOptions={}),g||w.protocol!=="wss"||f.forEach(function(_){Object.prototype.hasOwnProperty.call(w,_)&&!Object.prototype.hasOwnProperty.call(w.wsOptions,_)&&(m.wsOptions[_]=w[_])}),m}s.exports=g?function(w,m){let _;o("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}(m).browserBufferSize||524288,x=m.browserBufferTimeout||1e3,C=!m.objectMode,S=function(P,O){const Y=O.protocolId==="MQIsdp"&&O.protocolVersion===3?"mqttv3.1":"mqtt",Z=v(O,P),at=new WebSocket(Z,[Y]);return at.binaryType="arraybuffer",at}(w,m),L=function(P,O,Y){const Z=new c({objectModeMode:P.objectMode});return Z._write=O,Z._flush=Y,Z}(m,function P(O,Y,Z){S.bufferedAmount>E&&setTimeout(P,x,O,Y,Z),C&&typeof O=="string"&&(O=r.from(O,"utf8"));try{S.send(O)}catch(at){return Z(at)}Z()},function(P){S.close(),P()});m.objectMode||(L._writev=T),L.on("close",()=>{S.close()});const M=S.addEventListener!==void 0;function D(){_.setReadable(L),_.setWritable(L),_.emit("connect")}function $(){_.end(),_.destroy()}function Q(P){_.destroy(P)}function R(P){let O=P.data;O=O instanceof ArrayBuffer?r.from(O):r.from(O,"utf8"),L.push(O)}function T(P,O){const Y=new Array(P.length);for(let Z=0;Z<P.length;Z++)typeof P[Z].chunk=="string"?Y[Z]=r.from(P[Z],"utf8"):Y[Z]=P[Z].chunk;this._write(r.concat(Y),"binary",O)}return S.readyState===S.OPEN?_=L:(_=_=u(void 0,void 0,m),m.objectMode||(_._writev=T),M?S.addEventListener("open",D):S.onopen=D),_.socket=S,M?(S.addEventListener("close",$),S.addEventListener("error",Q),S.addEventListener("message",R)):(S.onclose=$,S.onerror=Q,S.onmessage=R),_}:function(w,m){o("streamBuilder");const _=y(m),E=v(_,w),x=function(S,L,M){o("createWebSocket"),o("protocol: "+M.protocolId+" "+M.protocolVersion);const D=M.protocolId==="MQIsdp"&&M.protocolVersion===3?"mqttv3.1":"mqtt";return o("creating new Websocket for url: "+L+" and protocol: "+D),new l(L,[D],M.wsOptions)}(0,E,_),C=l.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:a}=i("buffer"),r=i("readable-stream").Transform,l=i("duplexify");let o,u,c;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(m){m.hostname||(m.hostname="localhost"),m.path||(m.path="/"),m.wsOptions||(m.wsOptions={})})(g);const y=function(m,_){const E=m.protocol==="wxs"?"wss":"ws";let x=E+"://"+m.hostname+m.path;return m.port&&m.port!==80&&m.port!==443&&(x=E+"://"+m.hostname+":"+m.port+m.path),typeof m.transformWsUrl=="function"&&(x=m.transformWsUrl(x,m,_)),x}(g,f);o=wx.connectSocket({url:y,protocols:[v]}),u=function(){const m=new r;return m._write=function(_,E,x){o.send({data:_.buffer,success:function(){x()},fail:function(C){x(new Error(C))}})},m._flush=function(_){o.close({success:function(){_()}})},m}(),(c=l.obj())._destroy=function(m,_){o.close({success:function(){_&&_(m)}})};const w=c.destroy;return c.destroy=function(){c.destroy=w;const m=this;setTimeout(function(){o.close({fail:function(){m._destroy(new Error)}})},0)}.bind(c),o.onOpen(function(){c.setReadable(u),c.setWritable(u),c.emit("connect")}),o.onMessage(function(m){let _=m.data;_=_ instanceof ArrayBuffer?a.from(_):a.from(_,"utf8"),u.push(_)}),o.onClose(function(){c.end(),c.destroy()}),o.onError(function(m){c.destroy(new Error(m.errMsg))}),c}},{buffer:17,duplexify:20,"readable-stream":69}],7:[function(i,s,n){function a(){if(!(this instanceof a))return new a;this.nextId=Math.max(1,Math.floor(65535*Math.random()))}a.prototype.allocate=function(){const r=this.nextId++;return this.nextId===65536&&(this.nextId=1),r},a.prototype.getLastAllocated=function(){return this.nextId===1?65535:this.nextId-1},a.prototype.register=function(r){return!0},a.prototype.deallocate=function(r){},a.prototype.clear=function(){},s.exports=a},{}],8:[function(i,s,n){const a=i("xtend"),r=i("readable-stream").Readable,l={objectMode:!0},o={clean:!0};function u(c){if(!(this instanceof u))return new u(c);this.options=c||{},this.options=a(o,c),this._inflights=new Map}u.prototype.put=function(c,f){return this._inflights.set(c.messageId,c),f&&f(),this},u.prototype.createStream=function(){const c=new r(l),f=[];let g=!1,v=0;return this._inflights.forEach(function(y,w){f.push(y)}),c._read=function(){!g&&v<f.length?this.push(f[v++]):this.push(null)},c.destroy=function(){if(g)return;const y=this;g=!0,setTimeout(function(){y.emit("close")},0)},c},u.prototype.del=function(c,f){return(c=this._inflights.get(c.messageId))?(this._inflights.delete(c.messageId),f(null,c)):f&&f(new Error("missing packet")),this},u.prototype.get=function(c,f){return(c=this._inflights.get(c.messageId))?f(null,c):f&&f(new Error("missing packet")),this},u.prototype.close=function(c){this.options.clean&&(this._inflights=null),c&&c()},s.exports=u},{"readable-stream":69,xtend:81}],9:[function(i,s,n){function a(r){if(!(this instanceof a))return new a(r);this.aliasToTopic={},this.max=r}a.prototype.put=function(r,l){return!(l===0||l>this.max)&&(this.aliasToTopic[l]=r,this.length=Object.keys(this.aliasToTopic).length,!0)},a.prototype.getTopicByAlias=function(r){return this.aliasToTopic[r]},a.prototype.clear=function(){this.aliasToTopic={}},s.exports=a},{}],10:[function(i,s,n){const a=i("lru-cache"),r=i("number-allocator").NumberAllocator;function l(o){if(!(this instanceof l))return new l(o);o>0&&(this.aliasToTopic=new a({max:o}),this.topicToAlias={},this.numberAllocator=new r(1,o),this.max=o,this.length=0)}l.prototype.put=function(o,u){if(u===0||u>this.max)return!1;const c=this.aliasToTopic.get(u);return c&&delete this.topicToAlias[c],this.aliasToTopic.set(u,o),this.topicToAlias[o]=u,this.numberAllocator.use(u),this.length=this.aliasToTopic.length,!0},l.prototype.getTopicByAlias=function(o){return this.aliasToTopic.get(o)},l.prototype.getAliasByTopic=function(o){const u=this.topicToAlias[o];return u!==void 0&&this.aliasToTopic.get(u),u},l.prototype.clear=function(){this.aliasToTopic.reset(),this.topicToAlias={},this.numberAllocator.clear(),this.length=0},l.prototype.getLruAlias=function(){return this.numberAllocator.firstVacant()||this.aliasToTopic.keys()[this.aliasToTopic.length-1]},s.exports=l},{"lru-cache":37,"number-allocator":46}],11:[function(i,s,n){function a(r){const l=r.split("/");for(let o=0;o<l.length;o++)if(l[o]!=="+"){if(l[o]==="#")return o===l.length-1;if(l[o].indexOf("+")!==-1||l[o].indexOf("#")!==-1)return!1}return!0}s.exports={validateTopics:function(r){if(r.length===0)return"empty_topic_list";for(let l=0;l<r.length;l++)if(!a(r[l]))return r[l];return null}}},{}],12:[function(i,s,n){(function(a){(function(){const r=i("../client"),l=i("../store"),o=i("url"),u=i("xtend"),c=i("debug")("mqttjs"),f={};function g(v,y){if(c("connecting to an MQTT broker..."),typeof v!="object"||y||(y=v,v=null),y=y||{},v){const m=o.parse(v,!0);if(m.port!=null&&(m.port=Number(m.port)),(y=u(m,y)).protocol===null)throw new Error("Missing protocol");y.protocol=y.protocol.replace(/:$/,"")}if(function(m){let _;m.auth&&((_=m.auth.match(/^(.+):(.+)$/))?(m.username=_[1],m.password=_[2]):m.username=m.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 m=["mqtts","wss"].indexOf(y.protocol)!==-1;y.protocol=["mqtt","mqtts","ws","wss","wx","wxs","ali","alis"].filter(function(_,E){return(!m||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 r(function(m){return y.servers&&(m._reconnectCount&&m._reconnectCount!==y.servers.length||(m._reconnectCount=0),y.host=y.servers[m._reconnectCount].host,y.port=y.servers[m._reconnectCount].port,y.protocol=y.servers[m._reconnectCount].protocol?y.servers[m._reconnectCount].protocol:y.defaultProtocol,y.hostname=y.host,m._reconnectCount++),c("calling streambuilder for",y.protocol),f[y.protocol](m,y)},y);return w.on("error",function(){}),w}a!==void 0&&a.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=r,s.exports.Store=l}).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],m=y[1];return 3*(w+m)/4-m},n.toByteArray=function(v){var y,w,m=f(v),_=m[0],E=m[1],x=new l(function(L,M,D){return 3*(M+D)/4-D}(0,_,E)),C=0,S=E>0?_-4:_;for(w=0;w<S;w+=4)y=r[v.charCodeAt(w)]<<18|r[v.charCodeAt(w+1)]<<12|r[v.charCodeAt(w+2)]<<6|r[v.charCodeAt(w+3)],x[C++]=y>>16&255,x[C++]=y>>8&255,x[C++]=255&y;return E===2&&(y=r[v.charCodeAt(w)]<<2|r[v.charCodeAt(w+1)]>>4,x[C++]=255&y),E===1&&(y=r[v.charCodeAt(w)]<<10|r[v.charCodeAt(w+1)]<<4|r[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,m=w%3,_=[],E=0,x=w-m;E<x;E+=16383)_.push(g(v,E,E+16383>x?x:E+16383));return m===1?(y=v[w-1],_.push(a[y>>2]+a[y<<4&63]+"==")):m===2&&(y=(v[w-2]<<8)+v[w-1],_.push(a[y>>10]+a[y>>4&63]+a[y<<2&63]+"=")),_.join("")};for(var a=[],r=[],l=typeof Uint8Array<"u"?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",u=0,c=o.length;u<c;++u)a[u]=o[u],r[o.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 m,_,E=[],x=y;x<w;x+=3)m=(v[x]<<16&16711680)+(v[x+1]<<8&65280)+(255&v[x+2]),E.push(a[(_=m)>>18&63]+a[_>>12&63]+a[_>>6&63]+a[63&_]);return E.join("")}r["-".charCodeAt(0)]=62,r["_".charCodeAt(0)]=63},{}],14:[function(i,s,n){const{Buffer:a}=i("buffer"),r=Symbol.for("BufferList");function l(o){if(!(this instanceof l))return new l(o);l._init.call(this,o)}l._init=function(o){Object.defineProperty(this,r,{value:!0}),this._bufs=[],this.length=0,o&&this.append(o)},l.prototype._new=function(o){return new l(o)},l.prototype._offset=function(o){if(o===0)return[0,0];let u=0;for(let c=0;c<this._bufs.length;c++){const f=u+this._bufs[c].length;if(o<f||c===this._bufs.length-1)return[c,o-u];u=f}},l.prototype._reverseOffset=function(o){const u=o[0];let c=o[1];for(let f=0;f<u;f++)c+=this._bufs[f].length;return c},l.prototype.get=function(o){if(o>this.length||o<0)return;const u=this._offset(o);return this._bufs[u[0]][u[1]]},l.prototype.slice=function(o,u){return typeof o=="number"&&o<0&&(o+=this.length),typeof u=="number"&&u<0&&(u+=this.length),this.copy(null,0,o,u)},l.prototype.copy=function(o,u,c,f){if((typeof c!="number"||c<0)&&(c=0),(typeof f!="number"||f>this.length)&&(f=this.length),c>=this.length||f<=0)return o||a.alloc(0);const g=!!o,v=this._offset(c),y=f-c;let w=y,m=g&&u||0,_=v[1];if(c===0&&f===this.length){if(!g)return this._bufs.length===1?this._bufs[0]:a.concat(this._bufs,this.length);for(let E=0;E<this._bufs.length;E++)this._bufs[E].copy(o,m),m+=this._bufs[E].length;return o}if(w<=this._bufs[v[0]].length-_)return g?this._bufs[v[0]].copy(o,u,_,_+w):this._bufs[v[0]].slice(_,_+w);g||(o=a.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(o,m,_,_+w),m+=x;break}this._bufs[E].copy(o,m,_),m+=x,w-=x,_&&(_=0)}return o.length>m?o.slice(0,m):o},l.prototype.shallowSlice=function(o,u){if(o=o||0,u=typeof u!="number"?this.length:u,o<0&&(o+=this.length),u<0&&(u+=this.length),o===u)return this._new();const c=this._offset(o),f=this._offset(u),g=this._bufs.slice(c[0],f[0]+1);return f[1]===0?g.pop():g[g.length-1]=g[g.length-1].slice(0,f[1]),c[1]!==0&&(g[0]=g[0].slice(c[1])),this._new(g)},l.prototype.toString=function(o,u,c){return this.slice(u,c).toString(o)},l.prototype.consume=function(o){if(o=Math.trunc(o),Number.isNaN(o)||o<=0)return this;for(;this._bufs.length;){if(!(o>=this._bufs[0].length)){this._bufs[0]=this._bufs[0].slice(o),this.length-=o;break}o-=this._bufs[0].length,this.length-=this._bufs[0].length,this._bufs.shift()}return this},l.prototype.duplicate=function(){const o=this._new();for(let u=0;u<this._bufs.length;u++)o.append(this._bufs[u]);return o},l.prototype.append=function(o){if(o==null)return this;if(o.buffer)this._appendBuffer(a.from(o.buffer,o.byteOffset,o.byteLength));else if(Array.isArray(o))for(let u=0;u<o.length;u++)this.append(o[u]);else if(this._isBufferList(o))for(let u=0;u<o._bufs.length;u++)this.append(o._bufs[u]);else typeof o=="number"&&(o=o.toString()),this._appendBuffer(a.from(o));return this},l.prototype._appendBuffer=function(o){this._bufs.push(o),this.length+=o.length},l.prototype.indexOf=function(o,u,c){if(c===void 0&&typeof u=="string"&&(c=u,u=void 0),typeof o=="function"||Array.isArray(o))throw new TypeError('The "value" argument must be one of type string, Buffer, BufferList, or Uint8Array.');if(typeof o=="number"?o=a.from([o]):typeof o=="string"?o=a.from(o,c):this._isBufferList(o)?o=o.slice():Array.isArray(o.buffer)?o=a.from(o.buffer,o.byteOffset,o.byteLength):a.isBuffer(o)||(o=a.from(o)),u=Number(u||0),isNaN(u)&&(u=0),u<0&&(u=this.length+u),u<0&&(u=0),o.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>=o.length){const w=y.indexOf(o,v);if(w!==-1)return this._reverseOffset([g,w]);v=y.length-o.length+1}else{const w=this._reverseOffset([g,v]);if(this._match(w,o))return w;v++}v=0}return-1},l.prototype._match=function(o,u){if(this.length-o<u.length)return!1;for(let c=0;c<u.length;c++)if(this.get(o+c)!==u[c])return!1;return!0},function(){const o={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 o)(function(c){l.prototype[c]=o[c]===null?function(f,g){return this.slice(f,f+g)[c](0,g)}:function(f=0){return this.slice(f,f+o[c])[c](0)}})(u)}(),l.prototype._isBufferList=function(o){return o instanceof l||l.isBufferList(o)},l.isBufferList=function(o){return o!=null&&o[r]},s.exports=l},{buffer:17}],15:[function(i,s,n){const a=i("readable-stream").Duplex,r=i("inherits"),l=i("./BufferList");function o(u){if(!(this instanceof o))return new o(u);if(typeof u=="function"){this._callback=u;const c=function(f){this._callback&&(this._callback(f),this._callback=null)}.bind(this);this.on("pipe",function(f){f.on("error",c)}),this.on("unpipe",function(f){f.removeListener("error",c)}),u=null}l._init.call(this,u),a.call(this)}r(o,a),Object.assign(o.prototype,l.prototype),o.prototype._new=function(u){return new o(u)},o.prototype._write=function(u,c,f){this._appendBuffer(u),typeof f=="function"&&f()},o.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)},o.prototype.end=function(u){a.prototype.end.call(this,u),this._callback&&(this._callback(null,this.slice()),this._callback=null)},o.prototype._destroy=function(u,c){this._bufs.length=0,this.length=0,c(u)},o.prototype._isBufferList=function(u){return u instanceof o||u instanceof l||o.isBufferList(u)},o.isBufferList=l.isBufferList,s.exports=o,s.exports.BufferListStream=o,s.exports.BufferList=l},{"./BufferList":14,inherits:24,"readable-stream":69}],16:[function(i,s,n){},{}],17:[function(i,s,n){(function(a){(function(){var r=i("base64-js"),l=i("ieee754");n.Buffer=c,n.SlowBuffer=function(b){return+b!=b&&(b=0),c.alloc(+b)},n.INSPECT_MAX_BYTES=50;var o=2147483647;function u(b){if(b>o)throw new RangeError('The value "'+b+'" is invalid for option "size"');var k=new Uint8Array(b);return k.__proto__=c.prototype,k}function c(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,rt){if(typeof rt=="string"&&rt!==""||(rt="utf8"),!c.isEncoding(rt))throw new TypeError("Unknown encoding: "+rt);var mt=0|m(G,rt),yt=u(mt),Et=yt.write(G,rt);return Et!==mt&&(yt=yt.slice(0,Et)),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,rt,mt){if(rt<0||G.byteLength<rt)throw new RangeError('"offset" is outside of buffer bounds');if(G.byteLength<rt+(mt||0))throw new RangeError('"length" is outside of buffer bounds');var yt;return yt=rt===void 0&&mt===void 0?new Uint8Array(G):mt===void 0?new Uint8Array(G,rt):new Uint8Array(G,rt,mt),yt.__proto__=c.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 N=b.valueOf&&b.valueOf();if(N!=null&&N!==b)return c.from(N,k,I);var X=function(G){if(c.isBuffer(G)){var rt=0|w(G.length),mt=u(rt);return mt.length===0||G.copy(mt,0,0,rt),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 c.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),N=0;N<k;N+=1)I[N]=255&b[N];return I}function w(b){if(b>=o)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o.toString(16)+" bytes");return 0|b}function m(b,k){if(c.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,N=arguments.length>2&&arguments[2]===!0;if(!N&&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 N?-1:st(b).length;k=(""+k).toLowerCase(),X=!0}}function _(b,k,I){var N=b[k];b[k]=b[I],b[I]=N}function E(b,k,I,N,X){if(b.length===0)return-1;if(typeof I=="string"?(N=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=c.from(k,N)),c.isBuffer(k))return k.length===0?-1:x(b,k,I,N,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,N,X);throw new TypeError("val must be string, number or Buffer")}function x(b,k,I,N,X){var G,rt=1,mt=b.length,yt=k.length;if(N!==void 0&&((N=String(N).toLowerCase())==="ucs2"||N==="ucs-2"||N==="utf16le"||N==="utf-16le")){if(b.length<2||k.length<2)return-1;rt=2,mt/=2,yt/=2,I/=2}function Et(xe,Vt){return rt===1?xe[Vt]:xe.readUInt16BE(Vt*rt)}if(X){var Tt=-1;for(G=I;G<mt;G++)if(Et(b,G)===Et(k,Tt===-1?0:G-Tt)){if(Tt===-1&&(Tt=G),G-Tt+1===yt)return Tt*rt}else Tt!==-1&&(G-=G-Tt),Tt=-1}else for(I+yt>mt&&(I=mt-yt),G=I;G>=0;G--){for(var be=!0,se=0;se<yt;se++)if(Et(b,G+se)!==Et(k,se)){be=!1;break}if(be)return G}return-1}function C(b,k,I,N){I=Number(I)||0;var X=b.length-I;N?(N=Number(N))>X&&(N=X):N=X;var G=k.length;N>G/2&&(N=G/2);for(var rt=0;rt<N;++rt){var mt=parseInt(k.substr(2*rt,2),16);if(ot(mt))return rt;b[I+rt]=mt}return rt}function S(b,k,I,N){return ut(st(k,b.length-I),b,I,N)}function L(b,k,I,N){return ut(function(X){for(var G=[],rt=0;rt<X.length;++rt)G.push(255&X.charCodeAt(rt));return G}(k),b,I,N)}function M(b,k,I,N){return L(b,k,I,N)}function D(b,k,I,N){return ut(et(k),b,I,N)}function $(b,k,I,N){return ut(function(X,G){for(var rt,mt,yt,Et=[],Tt=0;Tt<X.length&&!((G-=2)<0);++Tt)rt=X.charCodeAt(Tt),mt=rt>>8,yt=rt%256,Et.push(yt),Et.push(mt);return Et}(k,b.length-I),b,I,N)}function Q(b,k,I){return k===0&&I===b.length?r.fromByteArray(b):r.fromByteArray(b.slice(k,I))}function R(b,k,I){I=Math.min(b.length,I);for(var N=[],X=k;X<I;){var G,rt,mt,yt,Et=b[X],Tt=null,be=Et>239?4:Et>223?3:Et>191?2:1;if(X+be<=I)switch(be){case 1:Et<128&&(Tt=Et);break;case 2:(192&(G=b[X+1]))==128&&(yt=(31&Et)<<6|63&G)>127&&(Tt=yt);break;case 3:G=b[X+1],rt=b[X+2],(192&G)==128&&(192&rt)==128&&(yt=(15&Et)<<12|(63&G)<<6|63&rt)>2047&&(yt<55296||yt>57343)&&(Tt=yt);break;case 4:G=b[X+1],rt=b[X+2],mt=b[X+3],(192&G)==128&&(192&rt)==128&&(192&mt)==128&&(yt=(15&Et)<<18|(63&G)<<12|(63&rt)<<6|63&mt)>65535&&yt<1114112&&(Tt=yt)}Tt===null?(Tt=65533,be=1):Tt>65535&&(Tt-=65536,N.push(Tt>>>10&1023|55296),Tt=56320|1023&Tt),N.push(Tt),X+=be}return function(se){var xe=se.length;if(xe<=T)return String.fromCharCode.apply(String,se);for(var Vt="",te=0;te<xe;)Vt+=String.fromCharCode.apply(String,se.slice(te,te+=T));return Vt}(N)}n.kMaxLength=o,c.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}}(),c.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(c.prototype,"parent",{enumerable:!0,get:function(){if(c.isBuffer(this))return this.buffer}}),Object.defineProperty(c.prototype,"offset",{enumerable:!0,get:function(){if(c.isBuffer(this))return this.byteOffset}}),typeof Symbol<"u"&&Symbol.species!=null&&c[Symbol.species]===c&&Object.defineProperty(c,Symbol.species,{value:null,configurable:!0,enumerable:!1,writable:!1}),c.poolSize=8192,c.from=function(b,k,I){return f(b,k,I)},c.prototype.__proto__=Uint8Array.prototype,c.__proto__=Uint8Array,c.alloc=function(b,k,I){return function(N,X,G){return g(N),N<=0?u(N):X!==void 0?typeof G=="string"?u(N).fill(X,G):u(N).fill(X):u(N)}(b,k,I)},c.allocUnsafe=function(b){return v(b)},c.allocUnsafeSlow=function(b){return v(b)},c.isBuffer=function(b){return b!=null&&b._isBuffer===!0&&b!==c.prototype},c.compare=function(b,k){if(ct(b,Uint8Array)&&(b=c.from(b,b.offset,b.byteLength)),ct(k,Uint8Array)&&(k=c.from(k,k.offset,k.byteLength)),!c.isBuffer(b)||!c.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,N=k.length,X=0,G=Math.min(I,N);X<G;++X)if(b[X]!==k[X]){I=b[X],N=k[X];break}return I<N?-1:N<I?1:0},c.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}},c.concat=function(b,k){if(!Array.isArray(b))throw new TypeError('"list" argument must be an Array of Buffers');if(b.length===0)return c.alloc(0);var I;if(k===void 0)for(k=0,I=0;I<b.length;++I)k+=b[I].length;var N=c.allocUnsafe(k),X=0;for(I=0;I<b.length;++I){var G=b[I];if(ct(G,Uint8Array)&&(G=c.from(G)),!c.isBuffer(G))throw new TypeError('"list" argument must be an Array of Buffers');G.copy(N,X),X+=G.length}return N},c.byteLength=m,c.prototype._isBuffer=!0,c.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},c.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},c.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},c.prototype.toString=function(){var b=this.length;return b===0?"":arguments.length===0?R(this,0,b):function(k,I,N){var X=!1;if((I===void 0||I<0)&&(I=0),I>this.length||((N===void 0||N>this.length)&&(N=this.length),N<=0)||(N>>>=0)<=(I>>>=0))return"";for(k||(k="utf8");;)switch(k){case"hex":return Y(this,I,N);case"utf8":case"utf-8":return R(this,I,N);case"ascii":return P(this,I,N);case"latin1":case"binary":return O(this,I,N);case"base64":return Q(this,I,N);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Z(this,I,N);default:if(X)throw new TypeError("Unknown encoding: "+k);k=(k+"").toLowerCase(),X=!0}}.apply(this,arguments)},c.prototype.toLocaleString=c.prototype.toString,c.prototype.equals=function(b){if(!c.isBuffer(b))throw new TypeError("Argument must be a Buffer");return this===b||c.compare(this,b)===0},c.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+">"},c.prototype.compare=function(b,k,I,N,X){if(ct(b,Uint8Array)&&(b=c.from(b,b.offset,b.byteLength)),!c.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),N===void 0&&(N=0),X===void 0&&(X=this.length),k<0||I>b.length||N<0||X>this.length)throw new RangeError("out of range index");if(N>=X&&k>=I)return 0;if(N>=X)return-1;if(k>=I)return 1;if(k>>>=0,I>>>=0,N>>>=0,X>>>=0,this===b)return 0;for(var G=X-N,rt=I-k,mt=Math.min(G,rt),yt=this.slice(N,X),Et=b.slice(k,I),Tt=0;Tt<mt;++Tt)if(yt[Tt]!==Et[Tt]){G=yt[Tt],rt=Et[Tt];break}return G<rt?-1:rt<G?1:0},c.prototype.includes=function(b,k,I){return this.indexOf(b,k,I)!==-1},c.prototype.indexOf=function(b,k,I){return E(this,b,k,I,!0)},c.prototype.lastIndexOf=function(b,k,I){return E(this,b,k,I,!1)},c.prototype.write=function(b,k,I,N){if(k===void 0)N="utf8",I=this.length,k=0;else if(I===void 0&&typeof k=="string")N=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,N===void 0&&(N="utf8")):(N=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");N||(N="utf8");for(var G=!1;;)switch(N){case"hex":return C(this,b,k,I);case"utf8":case"utf-8":return S(this,b,k,I);case"ascii":return L(this,b,k,I);case"latin1":case"binary":return M(this,b,k,I);case"base64":return D(this,b,k,I);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return $(this,b,k,I);default:if(G)throw new TypeError("Unknown encoding: "+N);N=(""+N).toLowerCase(),G=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var T=4096;function P(b,k,I){var N="";I=Math.min(b.length,I);for(var X=k;X<I;++X)N+=String.fromCharCode(127&b[X]);return N}function O(b,k,I){var N="";I=Math.min(b.length,I);for(var X=k;X<I;++X)N+=String.fromCharCode(b[X]);return N}function Y(b,k,I){var N=b.length;(!k||k<0)&&(k=0),(!I||I<0||I>N)&&(I=N);for(var X="",G=k;G<I;++G)X+=tt(b[G]);return X}function Z(b,k,I){for(var N=b.slice(k,I),X="",G=0;G<N.length;G+=2)X+=String.fromCharCode(N[G]+256*N[G+1]);return X}function at(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 V(b,k,I,N,X,G){if(!c.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+N>b.length)throw new RangeError("Index out of range")}function H(b,k,I,N,X,G){if(I+N>b.length)throw new RangeError("Index out of range");if(I<0)throw new RangeError("Index out of range")}function j(b,k,I,N,X){return k=+k,I>>>=0,X||H(b,0,I,4),l.write(b,k,I,N,23,4),I+4}function K(b,k,I,N,X){return k=+k,I>>>=0,X||H(b,0,I,8),l.write(b,k,I,N,52,8),I+8}c.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 N=this.subarray(b,k);return N.__proto__=c.prototype,N},c.prototype.readUIntLE=function(b,k,I){b>>>=0,k>>>=0,I||at(b,k,this.length);for(var N=this[b],X=1,G=0;++G<k&&(X*=256);)N+=this[b+G]*X;return N},c.prototype.readUIntBE=function(b,k,I){b>>>=0,k>>>=0,I||at(b,k,this.length);for(var N=this[b+--k],X=1;k>0&&(X*=256);)N+=this[b+--k]*X;return N},c.prototype.readUInt8=function(b,k){return b>>>=0,k||at(b,1,this.length),this[b]},c.prototype.readUInt16LE=function(b,k){return b>>>=0,k||at(b,2,this.length),this[b]|this[b+1]<<8},c.prototype.readUInt16BE=function(b,k){return b>>>=0,k||at(b,2,this.length),this[b]<<8|this[b+1]},c.prototype.readUInt32LE=function(b,k){return b>>>=0,k||at(b,4,this.length),(this[b]|this[b+1]<<8|this[b+2]<<16)+16777216*this[b+3]},c.prototype.readUInt32BE=function(b,k){return b>>>=0,k||at(b,4,this.length),16777216*this[b]+(this[b+1]<<16|this[b+2]<<8|this[b+3])},c.prototype.readIntLE=function(b,k,I){b>>>=0,k>>>=0,I||at(b,k,this.length);for(var N=this[b],X=1,G=0;++G<k&&(X*=256);)N+=this[b+G]*X;return N>=(X*=128)&&(N-=Math.pow(2,8*k)),N},c.prototype.readIntBE=function(b,k,I){b>>>=0,k>>>=0,I||at(b,k,this.length);for(var N=k,X=1,G=this[b+--N];N>0&&(X*=256);)G+=this[b+--N]*X;return G>=(X*=128)&&(G-=Math.pow(2,8*k)),G},c.prototype.readInt8=function(b,k){return b>>>=0,k||at(b,1,this.length),128&this[b]?-1*(255-this[b]+1):this[b]},c.prototype.readInt16LE=function(b,k){b>>>=0,k||at(b,2,this.length);var I=this[b]|this[b+1]<<8;return 32768&I?4294901760|I:I},c.prototype.readInt16BE=function(b,k){b>>>=0,k||at(b,2,this.length);var I=this[b+1]|this[b]<<8;return 32768&I?4294901760|I:I},c.prototype.readInt32LE=function(b,k){return b>>>=0,k||at(b,4,this.length),this[b]|this[b+1]<<8|this[b+2]<<16|this[b+3]<<24},c.prototype.readInt32BE=function(b,k){return b>>>=0,k||at(b,4,this.length),this[b]<<24|this[b+1]<<16|this[b+2]<<8|this[b+3]},c.prototype.readFloatLE=function(b,k){return b>>>=0,k||at(b,4,this.length),l.read(this,b,!0,23,4)},c.prototype.readFloatBE=function(b,k){return b>>>=0,k||at(b,4,this.length),l.read(this,b,!1,23,4)},c.prototype.readDoubleLE=function(b,k){return b>>>=0,k||at(b,8,this.length),l.read(this,b,!0,52,8)},c.prototype.readDoubleBE=function(b,k){return b>>>=0,k||at(b,8,this.length),l.read(this,b,!1,52,8)},c.prototype.writeUIntLE=function(b,k,I,N){b=+b,k>>>=0,I>>>=0,N||V(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},c.prototype.writeUIntBE=function(b,k,I,N){b=+b,k>>>=0,I>>>=0,N||V(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},c.prototype.writeUInt8=function(b,k,I){return b=+b,k>>>=0,I||V(this,b,k,1,255,0),this[k]=255&b,k+1},c.prototype.writeUInt16LE=function(b,k,I){return b=+b,k>>>=0,I||V(this,b,k,2,65535,0),this[k]=255&b,this[k+1]=b>>>8,k+2},c.prototype.writeUInt16BE=function(b,k,I){return b=+b,k>>>=0,I||V(this,b,k,2,65535,0),this[k]=b>>>8,this[k+1]=255&b,k+2},c.prototype.writeUInt32LE=function(b,k,I){return b=+b,k>>>=0,I||V(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},c.prototype.writeUInt32BE=function(b,k,I){return b=+b,k>>>=0,I||V(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},c.prototype.writeIntLE=function(b,k,I,N){if(b=+b,k>>>=0,!N){var X=Math.pow(2,8*I-1);V(this,b,k,I,X-1,-X)}var G=0,rt=1,mt=0;for(this[k]=255&b;++G<I&&(rt*=256);)b<0&&mt===0&&this[k+G-1]!==0&&(mt=1),this[k+G]=(b/rt>>0)-mt&255;return k+I},c.prototype.writeIntBE=function(b,k,I,N){if(b=+b,k>>>=0,!N){var X=Math.pow(2,8*I-1);V(this,b,k,I,X-1,-X)}var G=I-1,rt=1,mt=0;for(this[k+G]=255&b;--G>=0&&(rt*=256);)b<0&&mt===0&&this[k+G+1]!==0&&(mt=1),this[k+G]=(b/rt>>0)-mt&255;return k+I},c.prototype.writeInt8=function(b,k,I){return b=+b,k>>>=0,I||V(this,b,k,1,127,-128),b<0&&(b=255+b+1),this[k]=255&b,k+1},c.prototype.writeInt16LE=function(b,k,I){return b=+b,k>>>=0,I||V(this,b,k,2,32767,-32768),this[k]=255&b,this[k+1]=b>>>8,k+2},c.prototype.writeInt16BE=function(b,k,I){return b=+b,k>>>=0,I||V(this,b,k,2,32767,-32768),this[k]=b>>>8,this[k+1]=255&b,k+2},c.prototype.writeInt32LE=function(b,k,I){return b=+b,k>>>=0,I||V(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},c.prototype.writeInt32BE=function(b,k,I){return b=+b,k>>>=0,I||V(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},c.prototype.writeFloatLE=function(b,k,I){return j(this,b,k,!0,I)},c.prototype.writeFloatBE=function(b,k,I){return j(this,b,k,!1,I)},c.prototype.writeDoubleLE=function(b,k,I){return K(this,b,k,!0,I)},c.prototype.writeDoubleBE=function(b,k,I){return K(this,b,k,!1,I)},c.prototype.copy=function(b,k,I,N){if(!c.isBuffer(b))throw new TypeError("argument should be a Buffer");if(I||(I=0),N||N===0||(N=this.length),k>=b.length&&(k=b.length),k||(k=0),N>0&&N<I&&(N=I),N===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(N<0)throw new RangeError("sourceEnd out of bounds");N>this.length&&(N=this.length),b.length-k<N-I&&(N=b.length-k+I);var X=N-I;if(this===b&&typeof Uint8Array.prototype.copyWithin=="function")this.copyWithin(k,I,N);else if(this===b&&I<k&&k<N)for(var G=X-1;G>=0;--G)b[G+k]=this[G+I];else Uint8Array.prototype.set.call(b,this.subarray(I,N),k);return X},c.prototype.fill=function(b,k,I,N){if(typeof b=="string"){if(typeof k=="string"?(N=k,k=0,I=this.length):typeof I=="string"&&(N=I,I=this.length),N!==void 0&&typeof N!="string")throw new TypeError("encoding must be a string");if(typeof N=="string"&&!c.isEncoding(N))throw new TypeError("Unknown encoding: "+N);if(b.length===1){var X=b.charCodeAt(0);(N==="utf8"&&X<128||N==="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 rt=c.isBuffer(b)?b:c.from(b,N),mt=rt.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]=rt[G%mt]}return this};var U=/[^+/0-9A-Za-z-_]/g;function tt(b){return b<16?"0"+b.toString(16):b.toString(16)}function st(b,k){var I;k=k||1/0;for(var N=b.length,X=null,G=[],rt=0;rt<N;++rt){if((I=b.charCodeAt(rt))>55295&&I<57344){if(!X){if(I>56319){(k-=3)>-1&&G.push(239,191,189);continue}if(rt+1===N){(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 r.toByteArray(function(k){if((k=(k=k.split("=")[0]).trim().replace(U,"")).length<2)return"";for(;k.length%4!=0;)k+="=";return k}(b))}function ut(b,k,I,N){for(var X=0;X<N&&!(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(a){(function(){n.formatArgs=function(l){if(l[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+l[0]+(this.useColors?"%c ":" ")+"+"+s.exports.humanize(this.diff),!this.useColors)return;const o="color: "+this.color;l.splice(1,0,o,"color: inherit");let u=0,c=0;l[0].replace(/%[a-zA-Z%]/g,f=>{f!=="%%"&&f==="%c"&&(c=++u)}),l.splice(c,0,o)},n.save=function(l){try{l?n.storage.setItem("debug",l):n.storage.removeItem("debug")}catch{}},n.load=function(){let l;try{l=n.storage.getItem("debug")}catch{}return!l&&a!==void 0&&"env"in a&&(l=a.env.DEBUG),l},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 l=!1;return()=>{l||(l=!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:r}=s.exports;r.j=function(l){try{return JSON.stringify(l)}catch(o){return"[UnexpectedJSONParseError]: "+o.message}}}).call(this)}).call(this,i("_process"))},{"./common":19,_process:50}],19:[function(i,s,n){s.exports=function(a){function r(u){let c,f,g,v=null;function y(...w){if(!y.enabled)return;const m=y,_=Number(new Date),E=_-(c||_);m.diff=E,m.prev=c,m.curr=_,c=_,w[0]=r.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 L=r.formatters[S];if(typeof L=="function"){const M=w[x];C=L.call(m,M),w.splice(x,1),x--}return C}),r.formatArgs.call(m,w),(m.log||r.log).apply(m,w)}return y.namespace=u,y.useColors=r.useColors(),y.color=r.selectColor(u),y.extend=l,y.destroy=r.destroy,Object.defineProperty(y,"enabled",{enumerable:!0,configurable:!1,get:()=>v!==null?v:(f!==r.namespaces&&(f=r.namespaces,g=r.enabled(u)),g),set:w=>{v=w}}),typeof r.init=="function"&&r.init(y),y}function l(u,c){const f=r(this.namespace+(c===void 0?":":c)+u);return f.log=this.log,f}function o(u){return u.toString().substring(2,u.toString().length-2).replace(/\.\*\?$/,"*")}return r.debug=r,r.default=r,r.coerce=function(u){return u instanceof Error?u.stack||u.message:u},r.disable=function(){const u=[...r.names.map(o),...r.skips.map(o).map(c=>"-"+c)].join(",");return r.enable(""),u},r.enable=function(u){let c;r.save(u),r.namespaces=u,r.names=[],r.skips=[];const f=(typeof u=="string"?u:"").split(/[\s,]+/),g=f.length;for(c=0;c<g;c++)f[c]&&((u=f[c].replace(/\*/g,".*?"))[0]==="-"?r.skips.push(new RegExp("^"+u.substr(1)+"$")):r.names.push(new RegExp("^"+u+"$")))},r.enabled=function(u){if(u[u.length-1]==="*")return!0;let c,f;for(c=0,f=r.skips.length;c<f;c++)if(r.skips[c].test(u))return!1;for(c=0,f=r.names.length;c<f;c++)if(r.names[c].test(u))return!0;return!1},r.humanize=i("ms"),r.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(a).forEach(u=>{r[u]=a[u]}),r.names=[],r.skips=[],r.formatters={},r.selectColor=function(u){let c=0;for(let f=0;f<u.length;f++)c=(c<<5)-c+u.charCodeAt(f),c|=0;return r.colors[Math.abs(c)%r.colors.length]},r.enable(r.load()),r}},{ms:45}],20:[function(i,s,n){(function(a,r){(function(){var l=i("readable-stream"),o=i("end-of-stream"),u=i("inherits"),c=i("stream-shift"),f=r.from&&r.from!==Uint8Array.from?r.from([0]):new r([0]),g=function(m,_){m._corked?m.once("uncork",_):_()},v=function(m,_){return function(E){E?function(x,C){x._autoDestroy&&x.destroy(C)}(m,E.message==="premature close"?null:E):_&&!m._ended&&m.end()}},y=function(){},w=function(m,_,E){if(!(this instanceof w))return new w(m,_,E);l.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,m&&this.setWritable(m),_&&this.setReadable(_)};u(w,l.Duplex),w.obj=function(m,_,E){return E||(E={}),E.objectMode=!0,E.highWaterMark=16,new w(m,_,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(m){if(this._unwrite&&this._unwrite(),this.destroyed)m&&m.destroy&&m.destroy();else if(m!==null&&m!==!1){var _=this,E=o(m,{writable:!0,readable:!1},v(this,this._forwardEnd)),x=function(){var C=_._ondrain;_._ondrain=null,C&&C()};this._unwrite&&a.nextTick(x),this._writable=m,this._writable.on("drain",x),this._unwrite=function(){_._writable.removeListener("drain",x),E()},this.uncork()}else this.end()},w.prototype.setReadable=function(m){if(this._unread&&this._unread(),this.destroyed)m&&m.destroy&&m.destroy();else{if(m===null||m===!1)return this.push(null),void this.resume();var _,E=this,x=o(m,{writable:!1,readable:!0},v(this)),C=function(){E._forward()},S=function(){E.push(null)};this._drained=!0,this._readable=m,this._readable2=m._readableState?m:(_=m,new l.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 m;for(this._forwarding=!0;this._drained&&(m=c(this._readable2))!==null;)this.destroyed||(this._drained=this.push(m));this._forwarding=!1}},w.prototype.destroy=function(m,_){if(_||(_=y),this.destroyed)return _(null);this.destroyed=!0;var E=this;a.nextTick(function(){E._destroy(m),_(null)})},w.prototype._destroy=function(m){if(m){var _=this._ondrain;this._ondrain=null,_?_(m):this.emit("error",m)}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(m,_,E){if(!this.destroyed)return this._corked?g(this,this._write.bind(this,m,_,E)):m===f?this._finish(E):this._writable?void(this._writable.write(m)===!1?this._ondrain=E:this.destroyed||E()):E()},w.prototype._finish=function(m){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(_,m)},E?E._writableState&&E._writableState.finished?x():E._writableState?E.end(x):(E.end(),x()):x()})},w.prototype.end=function(m,_,E){return typeof m=="function"?this.end(null,null,m):typeof _=="function"?this.end(m,null,_):(this._ended=!0,m&&this.write(m),this._writableState.ending||this._writableState.destroyed||this.write(f),l.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(a){(function(){var r=i("once"),l=function(){},o=function(u,c,f){if(typeof c=="function")return o(u,null,c);c||(c={}),f=r(f||l);var g=u._writableState,v=u._readableState,y=c.readable||c.readable!==!1&&u.readable,w=c.writable||c.writable!==!1&&u.writable,m=!1,_=function(){u.writable||E()},E=function(){w=!1,y||f.call(u)},x=function(){y=!1,w||f.call(u)},C=function($){f.call(u,$?new Error("exited with error code: "+$):null)},S=function($){f.call(u,$)},L=function(){a.nextTick(M)},M=function(){if(!m)return(!y||v&&v.ended&&!v.destroyed)&&(!w||g&&g.ended&&!g.destroyed)?void 0:f.call(u,new Error("premature close"))},D=function(){u.req.on("finish",E)};return function($){return $.setHeader&&typeof $.abort=="function"}(u)?(u.on("complete",E),u.on("abort",L),u.req?D():u.on("request",D)):w&&!g&&(u.on("end",_),u.on("close",_)),function($){return $.stdio&&Array.isArray($.stdio)&&$.stdio.length===3}(u)&&u.on("exit",C),u.on("end",x),u.on("finish",E),c.error!==!1&&u.on("error",S),u.on("close",L),function(){m=!0,u.removeListener("complete",E),u.removeListener("abort",L),u.removeListener("request",D),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",L)}};s.exports=o}).call(this)}).call(this,i("_process"))},{_process:50,once:48}],22:[function(i,s,n){var a=Object.create||function(x){var C=function(){};return C.prototype=x,new C},r=Object.keys||function(x){var C=[];for(var S in x)Object.prototype.hasOwnProperty.call(x,S)&&C.push(S);return S},l=Function.prototype.bind||function(x){var C=this;return function(){return C.apply(x,arguments)}};function o(){this._events&&Object.prototype.hasOwnProperty.call(this,"_events")||(this._events=a(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0}s.exports=o,o.EventEmitter=o,o.prototype._events=void 0,o.prototype._maxListeners=void 0;var u,c=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?o.defaultMaxListeners:x._maxListeners}function v(x,C,S,L){var M,D,$;if(typeof S!="function")throw new TypeError('"listener" argument must be a function');if((D=x._events)?(D.newListener&&(x.emit("newListener",C,S.listener?S.listener:S),D=x._events),$=D[C]):(D=x._events=a(null),x._eventsCount=0),$){if(typeof $=="function"?$=D[C]=L?[S,$]:[$,S]:L?$.unshift(S):$.push(S),!$.warned&&(M=g(x))&&M>0&&$.length>M){$.warned=!0;var Q=new Error("Possible EventEmitter memory leak detected. "+$.length+' "'+String(C)+'" listeners added. Use emitter.setMaxListeners() to increase limit.');Q.name="MaxListenersExceededWarning",Q.emitter=x,Q.type=C,Q.count=$.length,typeof console=="object"&&console.warn&&console.warn("%s: %s",Q.name,Q.message)}}else $=D[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 L={fired:!1,wrapFn:void 0,target:x,type:C,listener:S},M=l.call(y,L);return M.listener=S,L.wrapFn=M,M}function m(x,C,S){var L=x._events;if(!L)return[];var M=L[C];return M?typeof M=="function"?S?[M.listener||M]:[M]:S?function(D){for(var $=new Array(D.length),Q=0;Q<$.length;++Q)$[Q]=D[Q].listener||D[Q];return $}(M):E(M,M.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),L=0;L<C;++L)S[L]=x[L];return S}u?Object.defineProperty(o,"defaultMaxListeners",{enumerable:!0,get:function(){return c},set:function(x){if(typeof x!="number"||x<0||x!=x)throw new TypeError('"defaultMaxListeners" must be a positive number');c=x}}):o.defaultMaxListeners=c,o.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},o.prototype.getMaxListeners=function(){return g(this)},o.prototype.emit=function(x){var C,S,L,M,D,$,Q=x==="error";if($=this._events)Q=Q&&$.error==null;else if(!Q)return!1;if(Q){if(arguments.length>1&&(C=arguments[1]),C instanceof Error)throw C;var R=new Error('Unhandled "error" event. ('+C+")");throw R.context=C,R}if(!(S=$[x]))return!1;var T=typeof S=="function";switch(L=arguments.length){case 1:(function(P,O,Y){if(O)P.call(Y);else for(var Z=P.length,at=E(P,Z),V=0;V<Z;++V)at[V].call(Y)})(S,T,this);break;case 2:(function(P,O,Y,Z){if(O)P.call(Y,Z);else for(var at=P.length,V=E(P,at),H=0;H<at;++H)V[H].call(Y,Z)})(S,T,this,arguments[1]);break;case 3:(function(P,O,Y,Z,at){if(O)P.call(Y,Z,at);else for(var V=P.length,H=E(P,V),j=0;j<V;++j)H[j].call(Y,Z,at)})(S,T,this,arguments[1],arguments[2]);break;case 4:(function(P,O,Y,Z,at,V){if(O)P.call(Y,Z,at,V);else for(var H=P.length,j=E(P,H),K=0;K<H;++K)j[K].call(Y,Z,at,V)})(S,T,this,arguments[1],arguments[2],arguments[3]);break;default:for(M=new Array(L-1),D=1;D<L;D++)M[D-1]=arguments[D];(function(P,O,Y,Z){if(O)P.apply(Y,Z);else for(var at=P.length,V=E(P,at),H=0;H<at;++H)V[H].apply(Y,Z)})(S,T,this,M)}return!0},o.prototype.addListener=function(x,C){return v(this,x,C,!1)},o.prototype.on=o.prototype.addListener,o.prototype.prependListener=function(x,C){return v(this,x,C,!0)},o.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},o.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},o.prototype.removeListener=function(x,C){var S,L,M,D,$;if(typeof C!="function")throw new TypeError('"listener" argument must be a function');if(!(L=this._events))return this;if(!(S=L[x]))return this;if(S===C||S.listener===C)--this._eventsCount==0?this._events=a(null):(delete L[x],L.removeListener&&this.emit("removeListener",x,S.listener||C));else if(typeof S!="function"){for(M=-1,D=S.length-1;D>=0;D--)if(S[D]===C||S[D].listener===C){$=S[D].listener,M=D;break}if(M<0)return this;M===0?S.shift():function(Q,R){for(var T=R,P=T+1,O=Q.length;P<O;T+=1,P+=1)Q[T]=Q[P];Q.pop()}(S,M),S.length===1&&(L[x]=S[0]),L.removeListener&&this.emit("removeListener",x,$||C)}return this},o.prototype.removeAllListeners=function(x){var C,S,L;if(!(S=this._events))return this;if(!S.removeListener)return arguments.length===0?(this._events=a(null),this._eventsCount=0):S[x]&&(--this._eventsCount==0?this._events=a(null):delete S[x]),this;if(arguments.length===0){var M,D=r(S);for(L=0;L<D.length;++L)(M=D[L])!=="removeListener"&&this.removeAllListeners(M);return this.removeAllListeners("removeListener"),this._events=a(null),this._eventsCount=0,this}if(typeof(C=S[x])=="function")this.removeListener(x,C);else if(C)for(L=C.length-1;L>=0;L--)this.removeListener(x,C[L]);return this},o.prototype.listeners=function(x){return m(this,x,!0)},o.prototype.rawListeners=function(x){return m(this,x,!1)},o.listenerCount=function(x,C){return typeof x.listenerCount=="function"?x.listenerCount(C):_.call(x,C)},o.prototype.listenerCount=_,o.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]}},{}],23:[function(i,s,n){n.read=function(a,r,l,o,u){var c,f,g=8*u-o-1,v=(1<<g)-1,y=v>>1,w=-7,m=l?u-1:0,_=l?-1:1,E=a[r+m];for(m+=_,c=E&(1<<-w)-1,E>>=-w,w+=g;w>0;c=256*c+a[r+m],m+=_,w-=8);for(f=c&(1<<-w)-1,c>>=-w,w+=o;w>0;f=256*f+a[r+m],m+=_,w-=8);if(c===0)c=1-y;else{if(c===v)return f?NaN:1/0*(E?-1:1);f+=Math.pow(2,o),c-=y}return(E?-1:1)*f*Math.pow(2,c-o)},n.write=function(a,r,l,o,u,c){var f,g,v,y=8*c-u-1,w=(1<<y)-1,m=w>>1,_=u===23?Math.pow(2,-24)-Math.pow(2,-77):0,E=o?0:c-1,x=o?1:-1,C=r<0||r===0&&1/r<0?1:0;for(r=Math.abs(r),isNaN(r)||r===1/0?(g=isNaN(r)?1:0,f=w):(f=Math.floor(Math.log(r)/Math.LN2),r*(v=Math.pow(2,-f))<1&&(f--,v*=2),(r+=f+m>=1?_/v:_*Math.pow(2,1-m))*v>=2&&(f++,v/=2),f+m>=w?(g=0,f=w):f+m>=1?(g=(r*v-1)*Math.pow(2,u),f+=m):(g=r*Math.pow(2,m-1)*Math.pow(2,u),f=0));u>=8;a[l+E]=255&g,E+=x,g/=256,u-=8);for(f=f<<u|g,y+=u;y>0;a[l+E]=255&f,E+=x,f/=256,y-=8);a[l+E-x]|=128*C}},{}],24:[function(i,s,n){typeof Object.create=="function"?s.exports=function(a,r){r&&(a.super_=r,a.prototype=Object.create(r.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}}))}:s.exports=function(a,r){if(r){a.super_=r;var l=function(){};l.prototype=r.prototype,a.prototype=new l,a.prototype.constructor=a}}},{}],25:[function(i,s,n){Object.defineProperty(n,"__esModule",{value:!0});var a=function(){function r(l,o){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=l,this.value=o}return r.prototype.rotateLeft=function(){var l=this.parent,o=this.brother,u=this.leftChild,c=this.rightChild;if(!c)throw new Error("unknown error");var f=c.leftChild,g=c.rightChild;return l&&(l.leftChild===this?l.leftChild=c:l.rightChild===this&&(l.rightChild=c)),c.parent=l,c.brother=o,c.leftChild=this,c.rightChild=g,o&&(o.brother=c),this.parent=c,this.brother=g,this.leftChild=u,this.rightChild=f,g&&(g.parent=c,g.brother=this),u&&(u.parent=this,u.brother=f),f&&(f.parent=this,f.brother=u),c},r.prototype.rotateRight=function(){var l=this.parent,o=this.brother,u=this.leftChild;if(!u)throw new Error("unknown error");var c=this.rightChild,f=u.leftChild,g=u.rightChild;return l&&(l.leftChild===this?l.leftChild=u:l.rightChild===this&&(l.rightChild=u)),u.parent=l,u.brother=o,u.leftChild=f,u.rightChild=this,o&&(o.brother=u),f&&(f.parent=u,f.brother=this),this.parent=u,this.brother=f,this.leftChild=g,this.rightChild=c,g&&(g.parent=this,g.brother=c),c&&(c.parent=this,c.brother=g),u},r.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},r.TreeNodeColorType={red:!0,black:!1},r}();Object.freeze(a),n.default=a},{}],26:[function(i,s,n){var a=this&&this.__generator||function(l,o){var u,c,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(m){return function(_){if(u)throw new TypeError("Generator is already executing.");for(;v;)try{if(u=1,c&&(f=2&_[0]?c.return:_[0]?c.throw||((f=c.return)&&f.call(c),0):c.next)&&!(f=f.call(c,_[1])).done)return f;switch(c=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++,c=_[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}_=o.call(l,v)}catch(E){_=[6,E],c=0}finally{u=f=0}if(5&_[0])throw _[1];return{value:_[0]?_[1]:void 0,done:!0}}([w,m])}}};function r(l){var o=this;l===void 0&&(l=[]);var u=[],c=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(){c=g=f=v=y=w=0,_.call(this,r.bucketSize),w=0},this.front=function(){return u[c][f]},this.back=function(){return u[g][v]},this.forEach=function(E){if(!this.empty()){var x=0;if(c!==g){for(S=f;S<r.bucketSize;++S)E(u[c][S],x++);for(S=c+1;S<g;++S)for(var C=0;C<r.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[c][S],x++)}};var m=function(E){var x=c*r.bucketSize+f,C=x+E,S=g*r.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/r.bucketSize),curNodePointerIndex:C%r.bucketSize}};this.getElementByPos=function(E){var x=m(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(L){return x.pushBack(L)})}},this.eraseElementByValue=function(E){if(!this.empty()){var x=[];this.forEach(function(L){L!==E&&x.push(L)});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*r.sigma,S=Math.max(Math.ceil(C/r.bucketSize),2),L=0;L<S;++L)x.push(new Array(r.bucketSize));var M=Math.ceil(E/r.bucketSize),D=Math.floor(S/2)-Math.floor(M/2),$=D,Q=0;if(this.size())for(L=0;L<M;++L){for(var R=0;R<r.bucketSize;++R)if(x[D+L][R]=this.front(),this.popFront(),this.empty()){$=D+L,Q=R;break}if(this.empty())break}u=x,c=D,f=0,g=$,v=Q,y=S,w=E};this.pushBack=function(E){this.empty()||(g===y-1&&v===r.bucketSize-1&&_.call(this,this.size()),v<r.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:c<g&&(--g,v=r.bucketSize-1)),w>0&&--w)},this.setElementByPos=function(E,x){var C=m(E),S=C.curNodeBucketIndex,L=C.curNodePointerIndex;u[S][L]=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 L=[],M=E;M<w;++M)L.push(this.getElementByPos(M));for(this.cut(E-1),M=0;M<C;++M)this.pushBack(x);L.forEach(function(D){return S.pushBack(D)})}},this.find=function(E){if(c===g){for(var x=f;x<=v;++x)if(u[c][x]===E)return!0;return!1}for(x=f;x<r.bucketSize;++x)if(u[c][x]===E)return!0;for(x=c+1;x<g;++x)for(var C=0;C<r.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,L){L!==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()||(c===0&&f===0&&_.call(this,this.size()),f>0?--f:c>0&&(--c,f=r.bucketSize-1)),++w,u[c][f]=E},this.popFront=function(){this.empty()||(this.size()!==1&&(f<r.bucketSize-1?++f:c<g&&(++c,f=0)),w>0&&--w)},this.shrinkToFit=function(){var E=this,x=[];this.forEach(function(M){x.push(M)});var C=x.length;u=[];for(var S=Math.ceil(C/r.bucketSize),L=0;L<S;++L)u.push(new Array(r.bucketSize));this.clear(),x.forEach(function(M){return E.pushBack(M)})},this.cut=function(E){if(E<0)this.clear();else{var x=m(E),C=x.curNodeBucketIndex,S=x.curNodePointerIndex;g=C,v=S,w=E+1}},this[Symbol.iterator]=function(){return function(){var E,x;return a(this,function(C){switch(C.label){case 0:if(w===0)return[2];if(c!==g)return[3,5];x=f,C.label=1;case 1:return x<=v?[4,u[c][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<r.bucketSize?[4,u[c][x]]:[3,9];case 7:C.sent(),C.label=8;case 8:return++x,[3,6];case 9:x=c+1,C.label=10;case 10:if(!(x<g))return[3,15];E=0,C.label=11;case 11:return E<r.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=r.bucketSize;l.size?E=l.size():l.length&&(E=l.length);var x=E*r.sigma;y=Math.ceil(x/r.bucketSize),y=Math.max(y,3);for(var C=0;C<y;++C)u.push(new Array(r.bucketSize));var S=Math.ceil(E/r.bucketSize);c=Math.floor(y/2)-Math.floor(S/2),g=c,l.forEach(function(L){return o.pushBack(L)})}(),Object.freeze(this)}Object.defineProperty(n,"__esModule",{value:!0}),r.sigma=3,r.bucketSize=5e3,Object.freeze(r),n.default=r},{}],27:[function(i,s,n){var a=this&&this.__generator||function(c,f){var g,v,y,w,m={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(;m;)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 m.label++,{value:C[1],done:!1};case 5:m.label++,v=C[1],C=[0];continue;case 7:C=m.ops.pop(),m.trys.pop();continue;default:if(!(y=(y=m.trys).length>0&&y[y.length-1])&&(C[0]===6||C[0]===2)){m=0;continue}if(C[0]===3&&(!y||C[1]>y[0]&&C[1]<y[3])){m.label=C[1];break}if(C[0]===6&&m.label<y[1]){m.label=y[1],y=C;break}if(y&&m.label<y[2]){m.label=y[2],m.ops.push(C);break}y[2]&&m.ops.pop(),m.trys.pop();continue}C=f.call(c,m)}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])}}},r=this&&this.__values||function(c){var f=typeof Symbol=="function"&&Symbol.iterator,g=f&&c[f],v=0;if(g)return g.call(c);if(c&&typeof c.length=="number")return{next:function(){return c&&v>=c.length&&(c=void 0),{value:c&&c[v++],done:!c}}};throw new TypeError(f?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(n,"__esModule",{value:!0});var l=i("../LinkList/LinkList"),o=i("../Map/Map");function u(c,f,g){var v=this;if(c===void 0&&(c=[]),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 L=r(S),M=L.next();!M.done;M=L.next())C=(C<<5)-C+M.value.charCodeAt(0),C&=C}catch(D){E={error:D}}finally{try{M&&!M.done&&(x=L.return)&&x.call(L)}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=[],m=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,m=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(_)&m-1;if(w[S]){var L=w[S].size();if(w[S]instanceof l.default){try{for(var M=r(w[S]),D=M.next();!D.done;D=M.next()){var $=D.value;if($.key===_)return void($.value=E)}}catch(R){x={error:R}}finally{try{D&&!D.done&&(C=M.return)&&C.call(M)}finally{if(x)throw x.error}}w[S].pushBack({key:_,value:E}),w[S].size()>=u.treeifyThreshold&&(w[S]=new o.default(w[S]))}else w[S].setElement(_,E);var Q=w[S].size();y+=Q-L}else++y,w[S]=new l.default([{key:_,value:E}]);y>m*u.sigma&&function(R){if(!(R>=u.maxSize)){m=2*R;var T=[];w.forEach(function(P,O){if(!P.empty()){if(P instanceof l.default&&P.size()===1){var Y=P.front(),Z=Y.key,at=Y.value;T[g(Z)&m-1]=new l.default([{key:Z,value:at}])}else if(P instanceof o.default){var V=new l.default,H=new l.default;P.forEach(function(U){(g(U.key)&R)==0?V.pushBack(U):H.pushBack(U)}),V.size()>u.untreeifyThreshold?T[O]=new o.default(V):V.size()&&(T[O]=V),H.size()>u.untreeifyThreshold?T[O+R]=new o.default(H):H.size()&&(T[O+R]=H)}else{var j=new l.default,K=new l.default;P.forEach(function(U){(g(U.key)&R)==0?j.pushBack(U):K.pushBack(U)}),j.size()&&(T[O]=j),K.size()&&(T[O+R]=K)}w[O].clear()}}),w=T}}.call(this,m)}else this.eraseElementByKey(_)},this.getElementByKey=function(_){var E,x,C=g(_)&m-1;if(w[C]){if(w[C]instanceof o.default)return w[C].getElementByKey(_);try{for(var S=r(w[C]),L=S.next();!L.done;L=S.next()){var M=L.value;if(M.key===_)return M.value}}catch(D){E={error:D}}finally{try{L&&!L.done&&(x=S.return)&&x.call(S)}finally{if(E)throw E.error}}}},this.eraseElementByKey=function(_){var E,x,C=g(_)&m-1;if(w[C]){var S=w[C].size();if(w[C]instanceof o.default)w[C].eraseElementByKey(_),w[C].size()<=u.untreeifyThreshold&&(w[C]=new l.default(w[C]));else{var L=-1;try{for(var M=r(w[C]),D=M.next();!D.done;D=M.next())if(++L,D.value.key===_){w[C].eraseElementByPos(L);break}}catch(Q){E={error:Q}}finally{try{D&&!D.done&&(x=M.return)&&x.call(M)}finally{if(E)throw E.error}}}var $=w[C].size();y+=$-S}},this.find=function(_){var E,x,C=g(_)&m-1;if(!w[C])return!1;if(w[C]instanceof o.default)return w[C].find(_);try{for(var S=r(w[C]),L=S.next();!L.done;L=S.next())if(L.value.key===_)return!0}catch(M){E={error:M}}finally{try{L&&!L.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,L;return a(this,function(M){switch(M.label){case 0:_=0,M.label=1;case 1:if(!(_<m))return[3,10];for(;_<m&&!w[_];)++_;if(_>=m)return[3,10];M.label=2;case 2:M.trys.push([2,7,8,9]),S=void 0,E=r(w[_]),x=E.next(),M.label=3;case 3:return x.done?[3,6]:[4,x.value];case 4:M.sent(),M.label=5;case 5:return x=E.next(),[3,3];case 6:return[3,9];case 7:return C=M.sent(),S={error:C},[3,9];case 8:try{x&&!x.done&&(L=E.return)&&L.call(E)}finally{if(S)throw S.error}return[7];case 9:return++_,[3,1];case 10:return[2]}})}()},c.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 a=this&&this.__generator||function(c,f){var g,v,y,w,m={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(;m;)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 m.label++,{value:C[1],done:!1};case 5:m.label++,v=C[1],C=[0];continue;case 7:C=m.ops.pop(),m.trys.pop();continue;default:if(!(y=(y=m.trys).length>0&&y[y.length-1])&&(C[0]===6||C[0]===2)){m=0;continue}if(C[0]===3&&(!y||C[1]>y[0]&&C[1]<y[3])){m.label=C[1];break}if(C[0]===6&&m.label<y[1]){m.label=y[1],y=C;break}if(y&&m.label<y[2]){m.label=y[2],m.ops.push(C);break}y[2]&&m.ops.pop(),m.trys.pop();continue}C=f.call(c,m)}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])}}},r=this&&this.__values||function(c){var f=typeof Symbol=="function"&&Symbol.iterator,g=f&&c[f],v=0;if(g)return g.call(c);if(c&&typeof c.length=="number")return{next:function(){return c&&v>=c.length&&(c=void 0),{value:c&&c[v++],done:!c}}};throw new TypeError(f?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(n,"__esModule",{value:!0});var l=i("../Set/Set"),o=i("../LinkList/LinkList");function u(c,f,g){var v=this;if(c===void 0&&(c=[]),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=[],m=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,m=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(_)&m-1;if(w[E]){var x=w[E].size();if(w[E]instanceof o.default){if(w[E].find(_))return;w[E].pushBack(_),w[E].size()>=u.treeifyThreshold&&(w[E]=new l.default(w[E]))}else w[E].insert(_);var C=w[E].size();y+=C-x}else w[E]=new o.default([_]),++y;y>m*u.sigma&&function(S){if(!(S>=u.maxSize)){m=2*S;var L=[];w.forEach(function(M,D){if(!M.empty()){if(M instanceof o.default&&M.size()===1){var $=M.front();if($===void 0)throw new Error("unknown error");L[g($)&m-1]=new o.default([$])}else if(M instanceof l.default){var Q=new o.default,R=new o.default;M.forEach(function(O){(g(O)&S)==0?Q.pushBack(O):R.pushBack(O)}),Q.size()>u.untreeifyThreshold?L[D]=new l.default(Q):Q.size()&&(L[D]=Q),R.size()>u.untreeifyThreshold?L[D+S]=new l.default(R):R.size()&&(L[D+S]=R)}else{var T=new o.default,P=new o.default;M.forEach(function(O){(g(O)&S)==0?T.pushBack(O):P.pushBack(O)}),T.size()&&(L[D]=T),P.size()&&(L[D+S]=P)}w[D].clear()}}),w=L}}.call(this,m)},this.eraseElementByValue=function(_){var E=g(_)&m-1;if(w[E]){var x=w[E].size();w[E].eraseElementByValue(_),w[E]instanceof l.default&&w[E].size()<=u.untreeifyThreshold&&(w[E]=new o.default(w[E]));var C=w[E].size();y+=C-x}},this.find=function(_){var E=g(_)&m-1;return!!w[E]&&w[E].find(_)},this[Symbol.iterator]=function(){return function(){var _,E,x,C,S,L;return a(this,function(M){switch(M.label){case 0:_=0,M.label=1;case 1:if(!(_<m))return[3,10];for(;_<m&&!w[_];)++_;if(_>=m)return[3,10];M.label=2;case 2:M.trys.push([2,7,8,9]),S=void 0,E=r(w[_]),x=E.next(),M.label=3;case 3:return x.done?[3,6]:[4,x.value];case 4:M.sent(),M.label=5;case 5:return x=E.next(),[3,3];case 6:return[3,9];case 7:return C=M.sent(),S={error:C},[3,9];case 8:try{x&&!x.done&&(L=E.return)&&L.call(E)}finally{if(S)throw S.error}return[7];case 9:return++_,[3,1];case 10:return[2]}})}()},c.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 a=this&&this.__generator||function(o,u){var c,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(m){return function(_){return function(E){if(c)throw new TypeError("Generator is already executing.");for(;y;)try{if(c=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(o,y)}catch(x){E=[6,x],f=0}finally{c=g=0}if(5&E[0])throw E[1];return{value:E[0]?E[1]:void 0,done:!0}}([m,_])}}};Object.defineProperty(n,"__esModule",{value:!0});var r=function(){return function(o){this.value=void 0,this.pre=void 0,this.next=void 0,this.value=o}}();function l(o){var u=this;o===void 0&&(o=[]);var c=0,f=void 0,g=void 0;this.size=function(){return c},this.empty=function(){return c===0},this.clear=function(){f=g=void 0,c=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>=c)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>=c)throw new Error("erase pos must more then 0 and less then the list length");if(v===0)this.popFront();else if(v===c-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,m=y.next;m.pre=w,w.next=m,c>0&&--c}},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,m=y.next;m&&(m.pre=w),w&&(w.next=m),c>0&&--c}y=y.next}},this.pushBack=function(v){if(v==null)throw new Error("you can't push null or undefined here");++c;var y=new r(v);g?(g.next=y,y.pre=g,g=y):f=g=y},this.popBack=function(){g&&(c>0&&--c,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>=c)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>c)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===c)for(;w--;)this.pushBack(y);else{for(var m=f,_=1;_<v;++_){if(!(m!=null&&m.next))throw new Error("unknown error");m=m==null?void 0:m.next}if(!m)throw new Error("unknown error");var E=m.next;for(c+=w;w--;)m.next=new r(y),m.next.pre=m,m=m.next;m.next=E,E&&(E.pre=m)}},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<c;){var m=v.value;v.value=y.value,y.value=m,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,c>0&&--c;v.next=y.next,v.next&&(v.next.pre=v),v=v.next}},this.sort=function(v){var y=[];this.forEach(function(m){y.push(m)}),y.sort(v);var w=f;y.forEach(function(m){w&&(w.value=m,w=w.next)})},this.pushFront=function(v){if(v==null)throw new Error("you can't push null or undefined here");++c;var y=new r(v);f?(y.next=f,f.pre=y,f=y):f=g=y},this.popFront=function(){f&&(c>0&&--c,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(m){for(;w&&w.value!==void 0&&w.value<=m;)w=w.next;if(w===void 0)y.pushBack(m),w=g;else if(w===f)y.pushFront(m),w=f;else{++c;var _=w.pre;_&&(_.next=new r(m),_.next.pre=_,_.next.next=w,w&&(w.pre=_.next))}})},this[Symbol.iterator]=function(){return function(){var v;return a(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]}})}()},o.forEach(function(v){return u.pushBack(v)}),Object.freeze(this)}Object.freeze(l),n.default=l},{}],30:[function(i,s,n){var a=this&&this.__generator||function(u,c){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:m(0),throw:m(1),return:m(2)},typeof Symbol=="function"&&(y[Symbol.iterator]=function(){return this}),y;function m(_){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=c.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])}}},r=this&&this.__values||function(u){var c=typeof Symbol=="function"&&Symbol.iterator,f=c&&u[c],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(c?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(n,"__esModule",{value:!0});var l=i("../Base/TreeNode");function o(u,c){var f=this;u===void 0&&(u=[]),c=c||function(R,T){return R<T?-1:R>T?1:0};var g=0,v=new l.default;v.color=l.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(R){if(!R||R.key===void 0)throw new Error("unknown error");return R.leftChild?y(R.leftChild):R},w=function(R){if(!R||R.key===void 0)throw new Error("unknown error");return R.rightChild?w(R.rightChild):R};this.front=function(){if(!this.empty()){var R=y(v);if(R.key===void 0||R.value===void 0)throw new Error("unknown error");return{key:R.key,value:R.value}}},this.back=function(){if(!this.empty()){var R=w(v);if(R.key===void 0||R.value===void 0)throw new Error("unknown error");return{key:R.key,value:R.value}}},this.forEach=function(R){var T,P,O=0;try{for(var Y=r(this),Z=Y.next();!Z.done;Z=Y.next())R(Z.value,O++)}catch(at){T={error:at}}finally{try{Z&&!Z.done&&(P=Y.return)&&P.call(Y)}finally{if(T)throw T.error}}},this.getElementByPos=function(R){var T,P;if(R<0||R>=this.size())throw new Error("pos must more than 0 and less than set's size");var O=0;try{for(var Y=r(this),Z=Y.next();!Z.done;Z=Y.next()){var at=Z.value;if(O===R)return at;++O}}catch(V){T={error:V}}finally{try{Z&&!Z.done&&(P=Y.return)&&P.call(Y)}finally{if(T)throw T.error}}throw new Error("unknown Error")};var m=function(R,T){if(R&&R.key!==void 0&&R.value!==void 0){var P=c(R.key,T);return P===0?{key:R.key,value:R.value}:P<0?m(R.rightChild,T):m(R.leftChild,T)||{key:R.key,value:R.value}}};this.lowerBound=function(R){return m(v,R)};var _=function(R,T){if(R&&R.key!==void 0&&R.value!==void 0)return c(R.key,T)<=0?_(R.rightChild,T):_(R.leftChild,T)||{key:R.key,value:R.value}};this.upperBound=function(R){return _(v,R)};var E=function(R,T){if(R&&R.key!==void 0&&R.value!==void 0){var P=c(R.key,T);return P===0?{key:R.key,value:R.value}:P>0?E(R.leftChild,T):E(R.rightChild,T)||{key:R.key,value:R.value}}};this.reverseLowerBound=function(R){return E(v,R)};var x=function(R,T){if(R&&R.key!==void 0&&R.value!==void 0)return c(R.key,T)>=0?x(R.leftChild,T):x(R.rightChild,T)||{key:R.key,value:R.value}};this.reverseUpperBound=function(R){return x(v,R)};var C=function(R){var T=R.parent;if(!T){if(R===v)return;throw new Error("unknown error")}if(R.color!==l.default.TreeNodeColorType.red){var P=R.brother;if(!P)throw new Error("unknown error");if(R===T.leftChild)if(P.color===l.default.TreeNodeColorType.red){P.color=l.default.TreeNodeColorType.black,T.color=l.default.TreeNodeColorType.red;var O=T.rotateLeft();v===T&&(v=O),C(R)}else P.color===l.default.TreeNodeColorType.black&&(P.rightChild&&P.rightChild.color===l.default.TreeNodeColorType.red?(P.color=T.color,T.color=l.default.TreeNodeColorType.black,P.rightChild&&(P.rightChild.color=l.default.TreeNodeColorType.black),O=T.rotateLeft(),v===T&&(v=O),R.color=l.default.TreeNodeColorType.black):P.rightChild&&P.rightChild.color!==l.default.TreeNodeColorType.black||!P.leftChild||P.leftChild.color!==l.default.TreeNodeColorType.red?P.leftChild&&P.leftChild.color!==l.default.TreeNodeColorType.black||P.rightChild&&P.rightChild.color!==l.default.TreeNodeColorType.black||(P.color=l.default.TreeNodeColorType.red,C(T)):(P.color=l.default.TreeNodeColorType.red,P.leftChild&&(P.leftChild.color=l.default.TreeNodeColorType.black),O=P.rotateRight(),v===P&&(v=O),C(R)));else R===T.rightChild&&(P.color===l.default.TreeNodeColorType.red?(P.color=l.default.TreeNodeColorType.black,T.color=l.default.TreeNodeColorType.red,O=T.rotateRight(),v===T&&(v=O),C(R)):P.color===l.default.TreeNodeColorType.black&&(P.leftChild&&P.leftChild.color===l.default.TreeNodeColorType.red?(P.color=T.color,T.color=l.default.TreeNodeColorType.black,P.leftChild&&(P.leftChild.color=l.default.TreeNodeColorType.black),O=T.rotateRight(),v===T&&(v=O),R.color=l.default.TreeNodeColorType.black):P.leftChild&&P.leftChild.color!==l.default.TreeNodeColorType.black||!P.rightChild||P.rightChild.color!==l.default.TreeNodeColorType.red?P.leftChild&&P.leftChild.color!==l.default.TreeNodeColorType.black||P.rightChild&&P.rightChild.color!==l.default.TreeNodeColorType.black||(P.color=l.default.TreeNodeColorType.red,C(T)):(P.color=l.default.TreeNodeColorType.red,P.rightChild&&(P.rightChild.color=l.default.TreeNodeColorType.black),O=P.rotateLeft(),v===P&&(v=O),C(R))))}else R.color=l.default.TreeNodeColorType.black},S=function(R){for(var T=R;T.leftChild||T.rightChild;){if(T.rightChild){T=y(T.rightChild);var P=R.key;R.key=T.key,T.key=P;var O=R.value;R.value=T.value,T.value=O,R=T}T.leftChild&&(T=w(T.leftChild),P=R.key,R.key=T.key,T.key=P,O=R.value,R.value=T.value,T.value=O,R=T)}C(T),T&&T.remove(),--g,v.color=l.default.TreeNodeColorType.black},L=function(R,T){return!(!R||R.key===void 0)&&(!!L(R.leftChild,T)||!!T(R)||L(R.rightChild,T))};this.eraseElementByPos=function(R){if(R<0||R>=g)throw new Error("pos must more than 0 and less than set's size");var T=0;L(v,function(P){return R===T?(S(P),!0):(++T,!1)})},this.eraseElementByKey=function(R){if(!this.empty()){var T=$(v,R);T!==void 0&&T.key!==void 0&&c(T.key,R)===0&&S(T)}};var M=function(R,T){if(!R||R.key===void 0)throw new Error("unknown error");var P=c(T,R.key);return P<0?R.leftChild?M(R.leftChild,T):(R.leftChild=new l.default,R.leftChild.parent=R,R.leftChild.brother=R.rightChild,R.rightChild&&(R.rightChild.brother=R.leftChild),R.leftChild):P>0?R.rightChild?M(R.rightChild,T):(R.rightChild=new l.default,R.rightChild.parent=R,R.rightChild.brother=R.leftChild,R.leftChild&&(R.leftChild.brother=R.rightChild),R.rightChild):R},D=function(R){var T=R.parent;if(!T){if(R===v)return;throw new Error("unknown error")}if(T.color!==l.default.TreeNodeColorType.black&&T.color===l.default.TreeNodeColorType.red){var P=T.brother,O=T.parent;if(!O)throw new Error("unknown error");if(P&&P.color===l.default.TreeNodeColorType.red)P.color=T.color=l.default.TreeNodeColorType.black,O.color=l.default.TreeNodeColorType.red,D(O);else if(!P||P.color===l.default.TreeNodeColorType.black)if(T===O.leftChild)if(R===T.leftChild){T.color=l.default.TreeNodeColorType.black,O.color=l.default.TreeNodeColorType.red;var Y=O.rotateRight();O===v&&(v=Y)}else R===T.rightChild&&(Y=T.rotateLeft(),O===v&&(v=Y),D(T));else T===O.rightChild&&(R===T.leftChild?(Y=T.rotateRight(),O===v&&(v=Y),D(T)):R===T.rightChild&&(T.color=l.default.TreeNodeColorType.black,O.color=l.default.TreeNodeColorType.red,Y=O.rotateLeft(),O===v&&(v=Y)))}};this.setElement=function(R,T){if(R==null)throw new Error("to avoid some unnecessary errors, we don't suggest you insert null or undefined here");if(T!=null){if(this.empty())return++g,v.key=R,v.value=T,void(v.color=l.default.TreeNodeColorType.black);var P=M(v,R);P.key===void 0||c(P.key,R)!==0?(++g,P.key=R,P.value=T,D(P),v.color=l.default.TreeNodeColorType.black):P.value=T}else this.eraseElementByKey(R)};var $=function(R,T){if(R&&R.key!==void 0){var P=c(T,R.key);return P<0?$(R.leftChild,T):P>0?$(R.rightChild,T):R}};this.find=function(R){return!!$(v,R)},this.getElementByKey=function(R){var T=$(v,R);if((T==null?void 0:T.key)===void 0||(T==null?void 0:T.value)===void 0)throw new Error("unknown error");return T.value},this.union=function(R){var T=this;R.forEach(function(P){var O=P.key,Y=P.value;return T.setElement(O,Y)})},this.getHeight=function(){if(this.empty())return 0;var R=function(T){return T?Math.max(R(T.leftChild),R(T.rightChild))+1:1};return R(v)};var Q=function(R){return a(this,function(T){switch(T.label){case 0:return R&&R.key!==void 0&&R.value!==void 0?[5,r(Q(R.leftChild))]:[2];case 1:return T.sent(),[4,{key:R.key,value:R.value}];case 2:return T.sent(),[5,r(Q(R.rightChild))];case 3:return T.sent(),[2]}})};this[Symbol.iterator]=function(){return Q(v)},u.forEach(function(R){var T=R.key,P=R.value;return f.setElement(T,P)}),Object.freeze(this)}Object.freeze(o),n.default=o},{"../Base/TreeNode":25}],31:[function(i,s,n){function a(r,l){r===void 0&&(r=[]),l=l||function(g,v){return g>v?-1:g<v?1:0};var o=[];r.forEach(function(g){return o.push(g)});var u=o.length,c=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=o[g];o[g]=o[v],o[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&&l(o[g],o[v])>0&&c(g,v),y<u&&l(o[g],o[y])>0&&c(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,m=y;if(w<u&&l(o[y],o[w])>0&&(m=w),l(o[v],o[m])<=0)break;c(v,m),y=2*(v=m)+1}})(),this.size=function(){return u},this.empty=function(){return u===0},this.clear=function(){u=0,o.length=0},this.push=function(g){if(o.push(g),++u!==1)for(var v=u-1;v>0;){var y=Math.floor((v-1)/2);if(l(o[y],g)<=0)break;f(y),v=y}},this.pop=function(){if(!this.empty())if(this.size()!==1){var g=o[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 m=y;if(w<this.size()&&l(o[y],o[w])>0&&(m=w),l(o[m],g)>=0)break;o[v]=o[m],v=m}o[v]=g}else--u},this.top=function(){return o[0]},Object.freeze(this)}Object.defineProperty(n,"__esModule",{value:!0}),Object.freeze(a),n.default=a},{}],32:[function(i,s,n){Object.defineProperty(n,"__esModule",{value:!0});var a=i("../LinkList/LinkList");function r(l){l===void 0&&(l=[]);var o=new a.default(l);this.size=function(){return o.size()},this.empty=function(){return o.empty()},this.clear=function(){o.clear()},this.push=function(u){o.pushBack(u)},this.pop=function(){o.popFront()},this.front=function(){return o.front()},Object.freeze(this)}Object.freeze(r),n.default=r},{"../LinkList/LinkList":29}],33:[function(i,s,n){var a=this&&this.__generator||function(u,c){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:m(0),throw:m(1),return:m(2)},typeof Symbol=="function"&&(y[Symbol.iterator]=function(){return this}),y;function m(_){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=c.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])}}},r=this&&this.__values||function(u){var c=typeof Symbol=="function"&&Symbol.iterator,f=c&&u[c],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(c?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(n,"__esModule",{value:!0});var l=i("../Base/TreeNode");function o(u,c){var f=this;u===void 0&&(u=[]),c=c||function(R,T){return R<T?-1:R>T?1:0};var g=0,v=new l.default;v.color=l.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=l.default.TreeNodeColorType.black};var y=function(R){if(!R||R.key===void 0)throw new Error("unknown error");return R.leftChild?y(R.leftChild):R},w=function(R){if(!R||R.key===void 0)throw new Error("unknown error");return R.rightChild?w(R.rightChild):R};this.front=function(){if(!this.empty())return y(v).key},this.back=function(){if(!this.empty())return w(v).key},this.forEach=function(R){var T,P,O=0;try{for(var Y=r(this),Z=Y.next();!Z.done;Z=Y.next())R(Z.value,O++)}catch(at){T={error:at}}finally{try{Z&&!Z.done&&(P=Y.return)&&P.call(Y)}finally{if(T)throw T.error}}},this.getElementByPos=function(R){var T,P;if(R<0||R>=this.size())throw new Error("pos must more than 0 and less than set's size");var O=0;try{for(var Y=r(this),Z=Y.next();!Z.done;Z=Y.next()){var at=Z.value;if(O===R)return at;++O}}catch(V){T={error:V}}finally{try{Z&&!Z.done&&(P=Y.return)&&P.call(Y)}finally{if(T)throw T.error}}throw new Error("unknown error")};var m=function(R){var T=R.parent;if(!T){if(R===v)return;throw new Error("unknown error")}if(R.color!==l.default.TreeNodeColorType.red){var P=R.brother;if(!P)throw new Error("unknown error");if(R===T.leftChild)if(P.color===l.default.TreeNodeColorType.red){P.color=l.default.TreeNodeColorType.black,T.color=l.default.TreeNodeColorType.red;var O=T.rotateLeft();v===T&&(v=O),m(R)}else P.color===l.default.TreeNodeColorType.black&&(P.rightChild&&P.rightChild.color===l.default.TreeNodeColorType.red?(P.color=T.color,T.color=l.default.TreeNodeColorType.black,P.rightChild&&(P.rightChild.color=l.default.TreeNodeColorType.black),O=T.rotateLeft(),v===T&&(v=O),R.color=l.default.TreeNodeColorType.black):P.rightChild&&P.rightChild.color!==l.default.TreeNodeColorType.black||!P.leftChild||P.leftChild.color!==l.default.TreeNodeColorType.red?P.leftChild&&P.leftChild.color!==l.default.TreeNodeColorType.black||P.rightChild&&P.rightChild.color!==l.default.TreeNodeColorType.black||(P.color=l.default.TreeNodeColorType.red,m(T)):(P.color=l.default.TreeNodeColorType.red,P.leftChild&&(P.leftChild.color=l.default.TreeNodeColorType.black),O=P.rotateRight(),v===P&&(v=O),m(R)));else R===T.rightChild&&(P.color===l.default.TreeNodeColorType.red?(P.color=l.default.TreeNodeColorType.black,T.color=l.default.TreeNodeColorType.red,O=T.rotateRight(),v===T&&(v=O),m(R)):P.color===l.default.TreeNodeColorType.black&&(P.leftChild&&P.leftChild.color===l.default.TreeNodeColorType.red?(P.color=T.color,T.color=l.default.TreeNodeColorType.black,P.leftChild&&(P.leftChild.color=l.default.TreeNodeColorType.black),O=T.rotateRight(),v===T&&(v=O),R.color=l.default.TreeNodeColorType.black):P.leftChild&&P.leftChild.color!==l.default.TreeNodeColorType.black||!P.rightChild||P.rightChild.color!==l.default.TreeNodeColorType.red?P.leftChild&&P.leftChild.color!==l.default.TreeNodeColorType.black||P.rightChild&&P.rightChild.color!==l.default.TreeNodeColorType.black||(P.color=l.default.TreeNodeColorType.red,m(T)):(P.color=l.default.TreeNodeColorType.red,P.rightChild&&(P.rightChild.color=l.default.TreeNodeColorType.black),O=P.rotateLeft(),v===P&&(v=O),m(R))))}else R.color=l.default.TreeNodeColorType.black},_=function(R){for(var T=R;T.leftChild||T.rightChild;){if(T.rightChild){T=y(T.rightChild);var P=R.key;R.key=T.key,T.key=P,R=T}T.leftChild&&(T=w(T.leftChild),P=R.key,R.key=T.key,T.key=P,R=T)}m(T),T&&T.remove(),--g,v.color=l.default.TreeNodeColorType.black},E=function(R,T){return!(!R||R.key===void 0)&&(!!E(R.leftChild,T)||!!T(R)||E(R.rightChild,T))};this.eraseElementByPos=function(R){if(R<0||R>=g)throw new Error("pos must more than 0 and less than set's size");var T=0;E(v,function(P){return R===T?(_(P),!0):(++T,!1)})},this.eraseElementByValue=function(R){if(!this.empty()){var T=S(v,R);T!==void 0&&T.key!==void 0&&c(T.key,R)===0&&_(T)}};var x=function(R,T){if(!R||R.key===void 0)throw new Error("unknown error");var P=c(T,R.key);return P<0?R.leftChild?x(R.leftChild,T):(R.leftChild=new l.default,R.leftChild.parent=R,R.leftChild.brother=R.rightChild,R.rightChild&&(R.rightChild.brother=R.leftChild),R.leftChild):P>0?R.rightChild?x(R.rightChild,T):(R.rightChild=new l.default,R.rightChild.parent=R,R.rightChild.brother=R.leftChild,R.leftChild&&(R.leftChild.brother=R.rightChild),R.rightChild):R},C=function(R){var T=R.parent;if(!T){if(R===v)return;throw new Error("unknown error")}if(T.color!==l.default.TreeNodeColorType.black&&T.color===l.default.TreeNodeColorType.red){var P=T.brother,O=T.parent;if(!O)throw new Error("unknown error");if(P&&P.color===l.default.TreeNodeColorType.red)P.color=T.color=l.default.TreeNodeColorType.black,O.color=l.default.TreeNodeColorType.red,C(O);else if(!P||P.color===l.default.TreeNodeColorType.black)if(T===O.leftChild)if(R===T.leftChild){T.color=l.default.TreeNodeColorType.black,O.color=l.default.TreeNodeColorType.red;var Y=O.rotateRight();O===v&&(v=Y)}else R===T.rightChild&&(Y=T.rotateLeft(),O===v&&(v=Y),C(T));else T===O.rightChild&&(R===T.leftChild?(Y=T.rotateRight(),O===v&&(v=Y),C(T)):R===T.rightChild&&(T.color=l.default.TreeNodeColorType.black,O.color=l.default.TreeNodeColorType.red,Y=O.rotateLeft(),O===v&&(v=Y)))}};this.insert=function(R){if(R==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=R,void(v.color=l.default.TreeNodeColorType.black);var T=x(v,R);T.key!==void 0&&c(T.key,R)===0||(++g,T.key=R,C(T),v.color=l.default.TreeNodeColorType.black)};var S=function(R,T){if(R&&R.key!==void 0){var P=c(T,R.key);return P<0?S(R.leftChild,T):P>0?S(R.rightChild,T):R}};this.find=function(R){var T=S(v,R);return T!==void 0&&T.key!==void 0&&c(T.key,R)===0};var L=function(R,T){if(R&&R.key!==void 0){var P=c(R.key,T);if(P===0)return R.key;if(P<0)return L(R.rightChild,T);var O=L(R.leftChild,T);return O!==void 0?O:R.key}};this.lowerBound=function(R){return L(v,R)};var M=function(R,T){if(R&&R.key!==void 0){if(c(R.key,T)<=0)return M(R.rightChild,T);var P=M(R.leftChild,T);return P!==void 0?P:R.key}};this.upperBound=function(R){return M(v,R)};var D=function(R,T){if(R&&R.key!==void 0){var P=c(R.key,T);if(P===0)return R.key;if(P>0)return D(R.leftChild,T);var O=D(R.rightChild,T);return O!==void 0?O:R.key}};this.reverseLowerBound=function(R){return D(v,R)};var $=function(R,T){if(R&&R.key!==void 0){if(c(R.key,T)>=0)return $(R.leftChild,T);var P=$(R.rightChild,T);return P!==void 0?P:R.key}};this.reverseUpperBound=function(R){return $(v,R)},this.union=function(R){var T=this;R.forEach(function(P){return T.insert(P)})},this.getHeight=function(){if(this.empty())return 0;var R=function(T){return T?Math.max(R(T.leftChild),R(T.rightChild))+1:1};return R(v)};var Q=function(R){return a(this,function(T){switch(T.label){case 0:return R&&R.key!==void 0?[5,r(Q(R.leftChild))]:[2];case 1:return T.sent(),[4,R.key];case 2:return T.sent(),[5,r(Q(R.rightChild))];case 3:return T.sent(),[2]}})};this[Symbol.iterator]=function(){return Q(v)},u.forEach(function(R){return f.insert(R)}),Object.freeze(this)}Object.freeze(o),n.default=o},{"../Base/TreeNode":25}],34:[function(i,s,n){function a(r){var l=this;r===void 0&&(r=[]);var o=0,u=[];this.size=function(){return o},this.empty=function(){return o===0},this.clear=function(){o=0,u.length=0},this.push=function(c){u.push(c),++o},this.pop=function(){u.pop(),o>0&&--o},this.top=function(){return u[o-1]},r.forEach(function(c){return l.push(c)}),Object.freeze(this)}Object.defineProperty(n,"__esModule",{value:!0}),Object.freeze(a),n.default=a},{}],35:[function(i,s,n){var a=this&&this.__generator||function(c,f){var g,v,y,w,m={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(;m;)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 m.label++,{value:C[1],done:!1};case 5:m.label++,v=C[1],C=[0];continue;case 7:C=m.ops.pop(),m.trys.pop();continue;default:if(!(y=(y=m.trys).length>0&&y[y.length-1])&&(C[0]===6||C[0]===2)){m=0;continue}if(C[0]===3&&(!y||C[1]>y[0]&&C[1]<y[3])){m.label=C[1];break}if(C[0]===6&&m.label<y[1]){m.label=y[1],y=C;break}if(y&&m.label<y[2]){m.label=y[2],m.ops.push(C);break}y[2]&&m.ops.pop(),m.trys.pop();continue}C=f.call(c,m)}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])}}},r=this&&this.__read||function(c,f){var g=typeof Symbol=="function"&&c[Symbol.iterator];if(!g)return c;var v,y,w=g.call(c),m=[];try{for(;(f===void 0||f-- >0)&&!(v=w.next()).done;)m.push(v.value)}catch(_){y={error:_}}finally{try{v&&!v.done&&(g=w.return)&&g.call(w)}finally{if(y)throw y.error}}return m},l=this&&this.__spreadArray||function(c,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 c.concat(v||Array.prototype.slice.call(f))},o=this&&this.__values||function(c){var f=typeof Symbol=="function"&&Symbol.iterator,g=f&&c[f],v=0;if(g)return g.call(c);if(c&&typeof c.length=="number")return{next:function(){return c&&v>=c.length&&(c=void 0),{value:c&&c[v++],done:!c}}};throw new TypeError(f?"Object is not iterable.":"Symbol.iterator is not defined.")};function u(c){var f=this;c===void 0&&(c=[]);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 m=w.length;g>m;)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,m){if(m===void 0&&(m=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,l([y,0],r(new Array(m).fill(w)),!1)),g+=m},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 m=w.length;g>m;)this.popBack()},this.sort=function(y){v.sort(y)},this[Symbol.iterator]=function(){return function(){return a(this,function(y){switch(y.label){case 0:return[5,o(v)];case 1:return[2,y.sent()]}})}()},c.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 a=i("./Vector/Vector");n.Vector=a.default;var r=i("./Stack/Stack");n.Stack=r.default;var l=i("./Queue/Queue");n.Queue=l.default;var o=i("./LinkList/LinkList");n.LinkList=o.default;var u=i("./Deque/Deque");n.Deque=u.default;var c=i("./PriorityQueue/PriorityQueue");n.PriorityQueue=c.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 a=i("yallist"),r=Symbol("max"),l=Symbol("length"),o=Symbol("lengthCalculator"),u=Symbol("allowStale"),c=Symbol("maxAge"),f=Symbol("dispose"),g=Symbol("noDisposeOnSet"),v=Symbol("lruList"),y=Symbol("cache"),w=Symbol("updateAgeOnGet"),m=()=>1,_=(M,D,$)=>{const Q=M[y].get(D);if(Q){const R=Q.value;if(E(M,R)){if(C(M,Q),!M[u])return}else $&&(M[w]&&(Q.value.now=Date.now()),M[v].unshiftNode(Q));return R.value}},E=(M,D)=>{if(!D||!D.maxAge&&!M[c])return!1;const $=Date.now()-D.now;return D.maxAge?$>D.maxAge:M[c]&&$>M[c]},x=M=>{if(M[l]>M[r])for(let D=M[v].tail;M[l]>M[r]&&D!==null;){const $=D.prev;C(M,D),D=$}},C=(M,D)=>{if(D){const $=D.value;M[f]&&M[f]($.key,$.value),M[l]-=$.length,M[y].delete($.key),M[v].removeNode(D)}};class S{constructor(D,$,Q,R,T){this.key=D,this.value=$,this.length=Q,this.now=R,this.maxAge=T||0}}const L=(M,D,$,Q)=>{let R=$.value;E(M,R)&&(C(M,$),M[u]||(R=void 0)),R&&D.call(Q,R.value,R.key,M)};s.exports=class{constructor(M){if(typeof M=="number"&&(M={max:M}),M||(M={}),M.max&&(typeof M.max!="number"||M.max<0))throw new TypeError("max must be a non-negative number");this[r]=M.max||1/0;const D=M.length||m;if(this[o]=typeof D!="function"?m:D,this[u]=M.stale||!1,M.maxAge&&typeof M.maxAge!="number")throw new TypeError("maxAge must be a number");this[c]=M.maxAge||0,this[f]=M.dispose,this[g]=M.noDisposeOnSet||!1,this[w]=M.updateAgeOnGet||!1,this.reset()}set max(M){if(typeof M!="number"||M<0)throw new TypeError("max must be a non-negative number");this[r]=M||1/0,x(this)}get max(){return this[r]}set allowStale(M){this[u]=!!M}get allowStale(){return this[u]}set maxAge(M){if(typeof M!="number")throw new TypeError("maxAge must be a non-negative number");this[c]=M,x(this)}get maxAge(){return this[c]}set lengthCalculator(M){typeof M!="function"&&(M=m),M!==this[o]&&(this[o]=M,this[l]=0,this[v].forEach(D=>{D.length=this[o](D.value,D.key),this[l]+=D.length})),x(this)}get lengthCalculator(){return this[o]}get length(){return this[l]}get itemCount(){return this[v].length}rforEach(M,D){D=D||this;for(let $=this[v].tail;$!==null;){const Q=$.prev;L(this,M,$,D),$=Q}}forEach(M,D){D=D||this;for(let $=this[v].head;$!==null;){const Q=$.next;L(this,M,$,D),$=Q}}keys(){return this[v].toArray().map(M=>M.key)}values(){return this[v].toArray().map(M=>M.value)}reset(){this[f]&&this[v]&&this[v].length&&this[v].forEach(M=>this[f](M.key,M.value)),this[y]=new Map,this[v]=new a,this[l]=0}dump(){return this[v].map(M=>!E(this,M)&&{k:M.key,v:M.value,e:M.now+(M.maxAge||0)}).toArray().filter(M=>M)}dumpLru(){return this[v]}set(M,D,$){if(($=$||this[c])&&typeof $!="number")throw new TypeError("maxAge must be a number");const Q=$?Date.now():0,R=this[o](D,M);if(this[y].has(M)){if(R>this[r])return C(this,this[y].get(M)),!1;const P=this[y].get(M).value;return this[f]&&(this[g]||this[f](M,P.value)),P.now=Q,P.maxAge=$,P.value=D,this[l]+=R-P.length,P.length=R,this.get(M),x(this),!0}const T=new S(M,D,R,Q,$);return T.length>this[r]?(this[f]&&this[f](M,D),!1):(this[l]+=T.length,this[v].unshift(T),this[y].set(M,this[v].head),x(this),!0)}has(M){if(!this[y].has(M))return!1;const D=this[y].get(M).value;return!E(this,D)}get(M){return _(this,M,!0)}peek(M){return _(this,M,!1)}pop(){const M=this[v].tail;return M?(C(this,M),M.value):null}del(M){C(this,this[y].get(M))}load(M){this.reset();const D=Date.now();for(let $=M.length-1;$>=0;$--){const Q=M[$],R=Q.e||0;if(R===0)this.set(Q.k,Q.v);else{const T=R-D;T>0&&this.set(Q.k,Q.v,T)}}}prune(){this[y].forEach((M,D)=>_(this,D,!1))}}},{yallist:83}],38:[function(i,s,n){(function(a){(function(){const r=s.exports;r.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"},r.codes={};for(const o in r.types){const u=r.types[o];r.codes[u]=o}r.CMD_SHIFT=4,r.CMD_MASK=240,r.DUP_MASK=8,r.QOS_MASK=3,r.QOS_SHIFT=1,r.RETAIN_MASK=1,r.VARBYTEINT_MASK=127,r.VARBYTEINT_FIN_MASK=128,r.VARBYTEINT_MAX=268435455,r.SESSIONPRESENT_MASK=1,r.SESSIONPRESENT_HEADER=a.from([r.SESSIONPRESENT_MASK]),r.CONNACK_HEADER=a.from([r.codes.connack<<r.CMD_SHIFT]),r.USERNAME_MASK=128,r.PASSWORD_MASK=64,r.WILL_RETAIN_MASK=32,r.WILL_QOS_MASK=24,r.WILL_QOS_SHIFT=3,r.WILL_FLAG_MASK=4,r.CLEAN_SESSION_MASK=2,r.CONNECT_HEADER=a.from([r.codes.connect<<r.CMD_SHIFT]),r.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},r.propertiesCodes={};for(const o in r.properties){const u=r.properties[o];r.propertiesCodes[u]=o}function l(o){return[0,1,2].map(u=>[0,1].map(c=>[0,1].map(f=>{const g=a.alloc(1);return g.writeUInt8(r.codes[o]<<r.CMD_SHIFT|(c?r.DUP_MASK:0)|u<<r.QOS_SHIFT|f,0,!0),g})))}r.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"},r.PUBLISH_HEADER=l("publish"),r.SUBSCRIBE_HEADER=l("subscribe"),r.SUBSCRIBE_OPTIONS_QOS_MASK=3,r.SUBSCRIBE_OPTIONS_NL_MASK=1,r.SUBSCRIBE_OPTIONS_NL_SHIFT=2,r.SUBSCRIBE_OPTIONS_RAP_MASK=1,r.SUBSCRIBE_OPTIONS_RAP_SHIFT=3,r.SUBSCRIBE_OPTIONS_RH_MASK=3,r.SUBSCRIBE_OPTIONS_RH_SHIFT=4,r.SUBSCRIBE_OPTIONS_RH=[0,16,32],r.SUBSCRIBE_OPTIONS_NL=4,r.SUBSCRIBE_OPTIONS_RAP=8,r.SUBSCRIBE_OPTIONS_QOS=[0,1,2],r.UNSUBSCRIBE_HEADER=l("unsubscribe"),r.ACKS={unsuback:l("unsuback"),puback:l("puback"),pubcomp:l("pubcomp"),pubrel:l("pubrel"),pubrec:l("pubrec")},r.SUBACK_HEADER=a.from([r.codes.suback<<r.CMD_SHIFT]),r.VERSION3=a.from([3]),r.VERSION4=a.from([4]),r.VERSION5=a.from([5]),r.VERSION131=a.from([131]),r.VERSION132=a.from([132]),r.QOS=[0,1,2].map(o=>a.from([o])),r.EMPTY={pingreq:a.from([r.codes.pingreq<<4,0]),pingresp:a.from([r.codes.pingresp<<4,0]),disconnect:a.from([r.codes.disconnect<<4,0])}}).call(this)}).call(this,i("buffer").Buffer)},{buffer:17}],39:[function(i,s,n){(function(a){(function(){const r=i("./writeToStream"),l=i("events");class o extends l{constructor(){super(),this._array=new Array(20),this._i=0}write(c){return this._array[this._i++]=c,!0}concat(){let c=0;const f=new Array(this._array.length),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]=a.byteLength(g[v]),c+=f[v];const w=a.allocUnsafe(c);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,c){const f=new o;return r(u,f,c),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(a){(function(){const l={},o=a.isBuffer(a.from([1,2]).subarray(0,1));function u(c){const f=a.allocUnsafe(2);return f.writeUInt8(c>>8,0),f.writeUInt8(255&c,1),f}s.exports={cache:l,generateCache:function(){for(let c=0;c<65536;c++)l[c]=u(c)},generateNumber:u,genBufVariableByteInt:function(c){let f=0,g=0;const v=a.allocUnsafe(4);do f=c%128|0,(c=c/128|0)>0&&(f|=128),v.writeUInt8(f,g++);while(c>0&&g<4);return c>0&&(g=0),o?v.subarray(0,g):v.slice(0,g)},generate4ByteBuffer:function(c){const f=a.allocUnsafe(4);return f.writeUInt32BE(c,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 a=i("bl"),r=i("events"),l=i("./packet"),o=i("./constants"),u=i("debug")("mqtt-packet:parser");class c extends r{constructor(){super(),this.parser=this.constructor.parser}static parser(g){return this instanceof c?(this.settings=g||{},this._states=["_parseHeader","_parseLength","_parsePayload","_newPacket"],this._resetState(),this):new c().parser(g)}_resetState(){u("_resetState: resetting packet, error, _list, and _stateCounter"),this.packet=new l,this.error=null,this._list=a(),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=o.types[g>>o.CMD_SHIFT],this.packet.retain=(g&o.RETAIN_MASK)!=0,this.packet.qos=g>>o.QOS_SHIFT&o.QOS_MASK,this.packet.dup=(g&o.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 m={},_=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(m.username=this._list.readUInt8(this._pos)&o.USERNAME_MASK,m.password=this._list.readUInt8(this._pos)&o.PASSWORD_MASK,m.will=this._list.readUInt8(this._pos)&o.WILL_FLAG_MASK,m.will&&(_.will={},_.will.retain=(this._list.readUInt8(this._pos)&o.WILL_RETAIN_MASK)!=0,_.will.qos=(this._list.readUInt8(this._pos)&o.WILL_QOS_MASK)>>o.WILL_QOS_SHIFT),_.clean=(this._list.readUInt8(this._pos)&o.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),m.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(m.username){if((w=this._parseString())===null)return this._emitError(new Error("Cannot parse username"));_.username=w,u("_parseConnect: packet.username: %s",_.username)}if(m.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++)&o.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,m,_,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())&o.SUBSCRIBE_OPTIONS_QOS_MASK,E=(y>>o.SUBSCRIBE_OPTIONS_NL_SHIFT&o.SUBSCRIBE_OPTIONS_NL_MASK)!=0,_=(y>>o.SUBSCRIBE_OPTIONS_RAP_SHIFT&o.SUBSCRIBE_OPTIONS_RAP_MASK)!=0,m=y>>o.SUBSCRIBE_OPTIONS_RH_SHIFT&o.SUBSCRIBE_OPTIONS_RH_MASK,x={topic:v,qos:w},this.settings.protocolVersion===5?(x.nl=E,x.rap=_,x.rh=m):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,m=0,_=!1;const E=this._pos?this._pos:0;for(;y<4&&E+y<this._list.length;){if(m+=w*((v=this._list.readUInt8(E+y++))&o.VARBYTEINT_MASK),w*=128,(v&o.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:m}:m)),_}_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 m=o.propertiesCodes[w];if(!m)return this._emitError(new Error("Unknown property")),!1;if(m!=="userProperties")y[m]?Array.isArray(y[m])?y[m].push(this._parseByType(o.propertiesTypes[m])):(y[m]=[y[m]],y[m].push(this._parseByType(o.propertiesTypes[m]))):y[m]=this._parseByType(o.propertiesTypes[m]);else{y[m]||(y[m]=Object.create(null));const _=this._parseByType(o.propertiesTypes[m]);if(y[m][_.name])if(Array.isArray(y[m][_.name]))y[m][_.name].push(_.value);else{const E=y[m][_.name];y[m][_.name]=[E],y[m][_.name].push(_.value)}else y[m][_.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 l,this._pos=0,!0}_emitError(g){u("_emitError"),this.error=g,this.emit("error",g)}}s.exports=c},{"./constants":38,"./packet":42,bl:15,debug:18,events:22}],44:[function(i,s,n){(function(a){(function(){const r=i("./constants"),l=a.allocUnsafe(0),o=a.from([0]),u=i("./numbers"),c=i("process-nextick-args").nextTick,f=i("debug")("mqtt-packet:writeToStream"),g=u.cache,v=u.generateNumber,y=u.generateCache,w=u.genBufVariableByteInt,m=u.generate4ByteBuffer;let _=$,E=!0;function x(V,H,j){switch(f("generate called"),H.cork&&(H.cork(),c(C,H)),E&&(E=!1,y()),f("generate: packet.cmd: %s",V.cmd),V.cmd){case"connect":return function(K,U,tt){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,N=st.password,X=st.properties;ot===void 0&&(ot=!0);let G=0;if(!et||typeof et!="string"&&!a.isBuffer(et))return U.emit("error",new Error("Invalid protocolId")),!1;if(G+=et.length+2,ut!==3&&ut!==4&&ut!==5)return U.emit("error",new Error("Invalid protocol version")),!1;if(G+=1,(typeof k=="string"||a.isBuffer(k))&&(k||ut>=4)&&(k||ot))G+=a.byteLength(k)+2;else{if(ut<4)return U.emit("error",new Error("clientId must be supplied before 3.1.1")),!1;if(1*ot==0)return U.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 U.emit("error",new Error("Invalid keepalive")),!1;if(G+=2,G+=1,ut===5){var rt=T(U,X);if(!rt)return!1;G+=rt.length}if(ct){if(typeof ct!="object")return U.emit("error",new Error("Invalid will")),!1;if(!ct.topic||typeof ct.topic!="string")return U.emit("error",new Error("Invalid will topic")),!1;if(G+=a.byteLength(ct.topic)+2,G+=2,ct.payload){if(!(ct.payload.length>=0))return U.emit("error",new Error("Invalid will payload")),!1;typeof ct.payload=="string"?G+=a.byteLength(ct.payload):G+=ct.payload.length}var mt={};if(ut===5){if(!(mt=T(U,ct.properties)))return!1;G+=mt.length}}let yt=!1;if(I!=null){if(!at(I))return U.emit("error",new Error("Invalid username")),!1;yt=!0,G+=a.byteLength(I)+2}if(N!=null){if(!yt)return U.emit("error",new Error("Username is required to use password")),!1;if(!at(N))return U.emit("error",new Error("Invalid password")),!1;G+=Z(N)+2}U.write(r.CONNECT_HEADER),L(U,G),R(U,et),st.bridgeMode&&(ut+=128),U.write(ut===131?r.VERSION131:ut===132?r.VERSION132:ut===4?r.VERSION4:ut===5?r.VERSION5:r.VERSION3);let Et=0;return Et|=I!=null?r.USERNAME_MASK:0,Et|=N!=null?r.PASSWORD_MASK:0,Et|=ct&&ct.retain?r.WILL_RETAIN_MASK:0,Et|=ct&&ct.qos?ct.qos<<r.WILL_QOS_SHIFT:0,Et|=ct?r.WILL_FLAG_MASK:0,Et|=ot?r.CLEAN_SESSION_MASK:0,U.write(a.from([Et])),_(U,b),ut===5&&rt.write(),R(U,k),ct&&(ut===5&&mt.write(),M(U,ct.topic),R(U,ct.payload)),I!=null&&R(U,I),N!=null&&R(U,N),!0}(V,H);case"connack":return function(K,U,tt){const st=tt?tt.protocolVersion:4,et=K||{},ut=st===5?et.reasonCode:et.returnCode,ct=et.properties;let ot=2;if(typeof ut!="number")return U.emit("error",new Error("Invalid return code")),!1;let b=null;if(st===5){if(!(b=T(U,ct)))return!1;ot+=b.length}return U.write(r.CONNACK_HEADER),L(U,ot),U.write(et.sessionPresent?r.SESSIONPRESENT_HEADER:o),U.write(a.from([ut])),b!=null&&b.write(),!0}(V,H,j);case"publish":return function(K,U,tt){f("publish: packet: %o",K);const st=tt?tt.protocolVersion:4,et=K||{},ut=et.qos||0,ct=et.retain?r.RETAIN_MASK:0,ot=et.topic,b=et.payload||l,k=et.messageId,I=et.properties;let N=0;if(typeof ot=="string")N+=a.byteLength(ot)+2;else{if(!a.isBuffer(ot))return U.emit("error",new Error("Invalid topic")),!1;N+=ot.length+2}if(a.isBuffer(b)?N+=b.length:N+=a.byteLength(b),ut&&typeof k!="number")return U.emit("error",new Error("Invalid messageId")),!1;ut&&(N+=2);let X=null;if(st===5){if(!(X=T(U,I)))return!1;N+=X.length}return U.write(r.PUBLISH_HEADER[ut][et.dup?1:0][ct?1:0]),L(U,N),_(U,Z(ot)),U.write(ot),ut>0&&_(U,k),X!=null&&X.write(),f("publish: payload: %o",b),U.write(b)}(V,H,j);case"puback":case"pubrec":case"pubrel":case"pubcomp":return function(K,U,tt){const st=tt?tt.protocolVersion:4,et=K||{},ut=et.cmd||"puback",ct=et.messageId,ot=et.dup&&ut==="pubrel"?r.DUP_MASK:0;let b=0;const k=et.reasonCode,I=et.properties;let N=st===5?3:2;if(ut==="pubrel"&&(b=1),typeof ct!="number")return U.emit("error",new Error("Invalid messageId")),!1;let X=null;if(st===5&&typeof I=="object"){if(!(X=P(U,I,tt,N)))return!1;N+=X.length}return U.write(r.ACKS[ut][b][ot][0]),L(U,N),_(U,ct),st===5&&U.write(a.from([k])),X!==null&&X.write(),!0}(V,H,j);case"subscribe":return function(K,U,tt){f("subscribe: packet: ");const st=tt?tt.protocolVersion:4,et=K||{},ut=et.dup?r.DUP_MASK:0,ct=et.messageId,ot=et.subscriptions,b=et.properties;let k=0;if(typeof ct!="number")return U.emit("error",new Error("Invalid messageId")),!1;k+=2;let I=null;if(st===5){if(!(I=T(U,b)))return!1;k+=I.length}if(typeof ot!="object"||!ot.length)return U.emit("error",new Error("Invalid subscriptions")),!1;for(let X=0;X<ot.length;X+=1){const G=ot[X].topic,rt=ot[X].qos;if(typeof G!="string")return U.emit("error",new Error("Invalid subscriptions - invalid topic")),!1;if(typeof rt!="number")return U.emit("error",new Error("Invalid subscriptions - invalid qos")),!1;if(st===5){if(typeof(ot[X].nl||!1)!="boolean")return U.emit("error",new Error("Invalid subscriptions - invalid No Local")),!1;if(typeof(ot[X].rap||!1)!="boolean")return U.emit("error",new Error("Invalid subscriptions - invalid Retain as Published")),!1;const Et=ot[X].rh||0;if(typeof Et!="number"||Et>2)return U.emit("error",new Error("Invalid subscriptions - invalid Retain Handling")),!1}k+=a.byteLength(G)+2+1}f("subscribe: writing to stream: %o",r.SUBSCRIBE_HEADER),U.write(r.SUBSCRIBE_HEADER[1][ut?1:0][0]),L(U,k),_(U,ct),I!==null&&I.write();let N=!0;for(const X of ot){const G=X.topic,rt=X.qos,mt=+X.nl,yt=+X.rap,Et=X.rh;let Tt;M(U,G),Tt=r.SUBSCRIBE_OPTIONS_QOS[rt],st===5&&(Tt|=mt?r.SUBSCRIBE_OPTIONS_NL:0,Tt|=yt?r.SUBSCRIBE_OPTIONS_RAP:0,Tt|=Et?r.SUBSCRIBE_OPTIONS_RH[Et]:0),N=U.write(a.from([Tt]))}return N}(V,H,j);case"suback":return function(K,U,tt){const st=tt?tt.protocolVersion:4,et=K||{},ut=et.messageId,ct=et.granted,ot=et.properties;let b=0;if(typeof ut!="number")return U.emit("error",new Error("Invalid messageId")),!1;if(b+=2,typeof ct!="object"||!ct.length)return U.emit("error",new Error("Invalid qos vector")),!1;for(let I=0;I<ct.length;I+=1){if(typeof ct[I]!="number")return U.emit("error",new Error("Invalid qos vector")),!1;b+=1}let k=null;if(st===5){if(!(k=P(U,ot,tt,b)))return!1;b+=k.length}return U.write(r.SUBACK_HEADER),L(U,b),_(U,ut),k!==null&&k.write(),U.write(a.from(ct))}(V,H,j);case"unsubscribe":return function(K,U,tt){const st=tt?tt.protocolVersion:4,et=K||{},ut=et.messageId,ct=et.dup?r.DUP_MASK:0,ot=et.unsubscriptions,b=et.properties;let k=0;if(typeof ut!="number")return U.emit("error",new Error("Invalid messageId")),!1;if(k+=2,typeof ot!="object"||!ot.length)return U.emit("error",new Error("Invalid unsubscriptions")),!1;for(let X=0;X<ot.length;X+=1){if(typeof ot[X]!="string")return U.emit("error",new Error("Invalid unsubscriptions")),!1;k+=a.byteLength(ot[X])+2}let I=null;if(st===5){if(!(I=T(U,b)))return!1;k+=I.length}U.write(r.UNSUBSCRIBE_HEADER[1][ct?1:0][0]),L(U,k),_(U,ut),I!==null&&I.write();let N=!0;for(let X=0;X<ot.length;X++)N=M(U,ot[X]);return N}(V,H,j);case"unsuback":return function(K,U,tt){const st=tt?tt.protocolVersion:4,et=K||{},ut=et.messageId,ct=et.dup?r.DUP_MASK:0,ot=et.granted,b=et.properties,k=et.cmd;let I=2;if(typeof ut!="number")return U.emit("error",new Error("Invalid messageId")),!1;if(st===5){if(typeof ot!="object"||!ot.length)return U.emit("error",new Error("Invalid qos vector")),!1;for(let X=0;X<ot.length;X+=1){if(typeof ot[X]!="number")return U.emit("error",new Error("Invalid qos vector")),!1;I+=1}}let N=null;if(st===5){if(!(N=P(U,b,tt,I)))return!1;I+=N.length}return U.write(r.ACKS[k][0][ct][0]),L(U,I),_(U,ut),N!==null&&N.write(),st===5&&U.write(a.from(ot)),!0}(V,H,j);case"pingreq":case"pingresp":return function(K,U,tt){return U.write(r.EMPTY[K.cmd])}(V,H);case"disconnect":return function(K,U,tt){const st=tt?tt.protocolVersion:4,et=K||{},ut=et.reasonCode,ct=et.properties;let ot=st===5?1:0,b=null;if(st===5){if(!(b=P(U,ct,tt,ot)))return!1;ot+=b.length}return U.write(a.from([r.codes.disconnect<<4])),L(U,ot),st===5&&U.write(a.from([ut])),b!==null&&b.write(),!0}(V,H,j);case"auth":return function(K,U,tt){const st=tt?tt.protocolVersion:4,et=K||{},ut=et.reasonCode,ct=et.properties;let ot=st===5?1:0;st!==5&&U.emit("error",new Error("Invalid mqtt version for auth packet"));const b=P(U,ct,tt,ot);return b?(ot+=b.length,U.write(a.from([r.codes.auth<<4])),L(U,ot),U.write(a.from([ut])),b!==null&&b.write(),!0):!1}(V,H,j);default:return H.emit("error",new Error("Unknown command")),!1}}function C(V){V.uncork()}Object.defineProperty(x,"cacheNumbers",{get:()=>_===$,set(V){V?(g&&Object.keys(g).length!==0||(E=!0),_=$):(E=!1,_=Q)}});const S={};function L(V,H){if(H>r.VARBYTEINT_MAX)return V.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),V.write(j)}function M(V,H){const j=a.byteLength(H);return _(V,j),f("writeString: %s",H),V.write(H,"utf8")}function D(V,H,j){M(V,H),M(V,j)}function $(V,H){return f("writeNumberCached: number: %d",H),f("writeNumberCached: %o",g[H]),V.write(g[H])}function Q(V,H){const j=v(H);return f("writeNumberGenerated: %o",j),V.write(j)}function R(V,H){typeof H=="string"?M(V,H):H?(_(V,H.length),V.write(H)):_(V,0)}function T(V,H){if(typeof H!="object"||H.length!=null)return{length:1,write(){Y(V,{},0)}};let j=0;function K(U,tt){let st=0;switch(r.propertiesTypes[U]){case"byte":if(typeof tt!="boolean")return V.emit("error",new Error(`Invalid ${U}: ${tt}`)),!1;st+=2;break;case"int8":if(typeof tt!="number"||tt<0||tt>255)return V.emit("error",new Error(`Invalid ${U}: ${tt}`)),!1;st+=2;break;case"binary":if(tt&&tt===null)return V.emit("error",new Error(`Invalid ${U}: ${tt}`)),!1;st+=1+a.byteLength(tt)+2;break;case"int16":if(typeof tt!="number"||tt<0||tt>65535)return V.emit("error",new Error(`Invalid ${U}: ${tt}`)),!1;st+=3;break;case"int32":if(typeof tt!="number"||tt<0||tt>4294967295)return V.emit("error",new Error(`Invalid ${U}: ${tt}`)),!1;st+=5;break;case"var":if(typeof tt!="number"||tt<0||tt>268435455)return V.emit("error",new Error(`Invalid ${U}: ${tt}`)),!1;st+=1+a.byteLength(w(tt));break;case"string":if(typeof tt!="string")return V.emit("error",new Error(`Invalid ${U}: ${tt}`)),!1;st+=3+a.byteLength(tt.toString());break;case"pair":if(typeof tt!="object")return V.emit("error",new Error(`Invalid ${U}: ${tt}`)),!1;st+=Object.getOwnPropertyNames(tt).reduce((et,ut)=>{const ct=tt[ut];return Array.isArray(ct)?et+=ct.reduce((ot,b)=>ot+=3+a.byteLength(ut.toString())+2+a.byteLength(b.toString()),0):et+=3+a.byteLength(ut.toString())+2+a.byteLength(tt[ut].toString()),et},0);break;default:return V.emit("error",new Error(`Invalid property ${U}: ${tt}`)),!1}return st}if(H)for(const U in H){let tt=0,st=0;const et=H[U];if(Array.isArray(et))for(let ut=0;ut<et.length;ut++){if(!(st=K(U,et[ut])))return!1;tt+=st}else{if(!(st=K(U,et)))return!1;tt=st}if(!tt)return!1;j+=tt}return{length:a.byteLength(w(j))+j,write(){Y(V,H,j)}}}function P(V,H,j,K){const U=["reasonString","userProperties"],tt=j&&j.properties&&j.properties.maximumPacketSize?j.properties.maximumPacketSize:0;let st=T(V,H);if(tt)for(;K+st.length>tt;){const et=U.shift();if(!et||!H[et])return!1;delete H[et],st=T(V,H)}return st}function O(V,H,j){switch(r.propertiesTypes[H]){case"byte":V.write(a.from([r.properties[H]])),V.write(a.from([+j]));break;case"int8":V.write(a.from([r.properties[H]])),V.write(a.from([j]));break;case"binary":V.write(a.from([r.properties[H]])),R(V,j);break;case"int16":V.write(a.from([r.properties[H]])),_(V,j);break;case"int32":V.write(a.from([r.properties[H]])),function(K,U){const tt=m(U);f("write4ByteNumber: %o",tt),K.write(tt)}(V,j);break;case"var":V.write(a.from([r.properties[H]])),L(V,j);break;case"string":V.write(a.from([r.properties[H]])),M(V,j);break;case"pair":Object.getOwnPropertyNames(j).forEach(K=>{const U=j[K];Array.isArray(U)?U.forEach(tt=>{V.write(a.from([r.properties[H]])),D(V,K.toString(),tt.toString())}):(V.write(a.from([r.properties[H]])),D(V,K.toString(),U.toString()))});break;default:return V.emit("error",new Error(`Invalid property ${H} value: ${j}`)),!1}}function Y(V,H,j){L(V,j);for(const K in H)if(Object.prototype.hasOwnProperty.call(H,K)&&H[K]!==null){const U=H[K];if(Array.isArray(U))for(let tt=0;tt<U.length;tt++)O(V,K,U[tt]);else O(V,K,U)}}function Z(V){return V?V instanceof a?V.length:a.byteLength(V):0}function at(V){return typeof V=="string"||V instanceof a}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 a=1e3,r=60*a,l=60*r,o=24*l,u=7*o,c=365.25*o;function f(g,v,y,w){var m=v>=1.5*y;return Math.round(g/y)+" "+w+(m?"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 m=/^(-?(?:\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(!!m){var _=parseFloat(m[1]);switch((m[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return _*c;case"weeks":case"week":case"w":return _*u;case"days":case"day":case"d":return _*o;case"hours":case"hour":case"hrs":case"hr":case"h":return _*l;case"minutes":case"minute":case"mins":case"min":case"m":return _*r;case"seconds":case"second":case"secs":case"sec":case"s":return _*a;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 m=Math.abs(w);return m>=o?f(w,m,o,"day"):m>=l?f(w,m,l,"hour"):m>=r?f(w,m,r,"minute"):m>=a?f(w,m,a,"second"):w+" ms"}(g):function(w){var m=Math.abs(w);return m>=o?Math.round(w/o)+"d":m>=l?Math.round(w/l)+"h":m>=r?Math.round(w/r)+"m":m>=a?Math.round(w/a)+"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 a=i("./lib/number-allocator.js");s.exports.NumberAllocator=a},{"./lib/number-allocator.js":47}],47:[function(i,s,n){const a=i("js-sdsl").Set,r=i("debug")("number-allocator:trace"),l=i("debug")("number-allocator:error");function o(c,f){this.low=c,this.high=f}function u(c,f){if(!(this instanceof u))return new u(c,f);this.min=c,this.max=f,this.ss=new a([],(g,v)=>g.compare(v)),r("Create"),this.clear()}o.prototype.equals=function(c){return this.low===c.low&&this.high===c.high},o.prototype.compare=function(c){return this.low<c.low&&this.high<c.low?-1:c.low<this.low&&c.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 r("alloc():empty"),null;const c=this.ss.front(),f=c.low;return f+1<=c.high?++c.low:this.ss.eraseElementByPos(0),r("alloc():"+f),f},u.prototype.use=function(c){const f=new o(c,c),g=this.ss.lowerBound(f);if(g){if(g.equals(f))return this.ss.eraseElementByValue(g),r("use():"+c),!0;if(g.low>c)return!1;if(g.low===c)return++g.low,r("use():"+c),!0;if(g.high===c)return--g.high,r("use():"+c),!0;const v=g.low;return g.low=c+1,this.ss.insert(new o(v,c-1)),r("use():"+c),!0}return r("use():failed"),!1},u.prototype.free=function(c){if(c<this.min||c>this.max)return void l("free():"+c+" is out of range");const f=new o(c,c),g=this.ss.lowerBound(f);if(g){if(g.low<=c&&c<=g.high)return void l("free():"+c+" has already been vacant");if(g===this.ss.front())c+1===g.low?--g.low:this.ss.insert(f);else{const v=this.ss.reverseLowerBound(f);v.high+1===c?c+1===g.low?(this.ss.eraseElementByValue(v),g.low=v.low):v.high=c:c+1===g.low?g.low=c: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===c?v.high=c:this.ss.insert(f)}r("free():"+c)},u.prototype.clear=function(){r("clear()"),this.ss.clear(),this.ss.insert(new o(this.min,this.max))},u.prototype.intervalCount=function(){return this.ss.size()},u.prototype.dump=function(){console.log("length:"+this.ss.size());for(const c of this.ss)console.log(c)},s.exports=u},{debug:18,"js-sdsl":36}],48:[function(i,s,n){var a=i("wrappy");function r(o){var u=function(){return u.called?u.value:(u.called=!0,u.value=o.apply(this,arguments))};return u.called=!1,u}function l(o){var u=function(){if(u.called)throw new Error(u.onceError);return u.called=!0,u.value=o.apply(this,arguments)},c=o.name||"Function wrapped with `once`";return u.onceError=c+" shouldn't be called more than once",u.called=!1,u}s.exports=a(r),s.exports.strict=a(l),r.proto=r(function(){Object.defineProperty(Function.prototype,"once",{value:function(){return r(this)},configurable:!0}),Object.defineProperty(Function.prototype,"onceStrict",{value:function(){return l(this)},configurable:!0})})},{wrappy:79}],49:[function(i,s,n){(function(a){(function(){a===void 0||!a.version||a.version.indexOf("v0.")===0||a.version.indexOf("v1.")===0&&a.version.indexOf("v1.8.")!==0?s.exports={nextTick:function(r,l,o,u){if(typeof r!="function")throw new TypeError('"callback" argument must be a function');var c,f,g=arguments.length;switch(g){case 0:case 1:return a.nextTick(r);case 2:return a.nextTick(function(){r.call(null,l)});case 3:return a.nextTick(function(){r.call(null,l,o)});case 4:return a.nextTick(function(){r.call(null,l,o,u)});default:for(c=new Array(g-1),f=0;f<c.length;)c[f++]=arguments[f];return a.nextTick(function(){r.apply(null,c)})}}}:s.exports=a}).call(this)}).call(this,i("_process"))},{_process:50}],50:[function(i,s,n){var a,r,l=s.exports={};function o(){throw new Error("setTimeout has not been defined")}function u(){throw new Error("clearTimeout has not been defined")}function c(x){if(a===setTimeout)return setTimeout(x,0);if((a===o||!a)&&setTimeout)return a=setTimeout,setTimeout(x,0);try{return a(x,0)}catch{try{return a.call(null,x,0)}catch{return a.call(this,x,0)}}}(function(){try{a=typeof setTimeout=="function"?setTimeout:o}catch{a=o}try{r=typeof clearTimeout=="function"?clearTimeout:u}catch{r=u}})();var f,g=[],v=!1,y=-1;function w(){v&&f&&(v=!1,f.length?g=f.concat(g):y=-1,g.length&&m())}function m(){if(!v){var x=c(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(r===clearTimeout)return clearTimeout(S);if((r===u||!r)&&clearTimeout)return r=clearTimeout,clearTimeout(S);try{r(S)}catch{try{return r.call(null,S)}catch{return r.call(this,S)}}}(x)}}function _(x,C){this.fun=x,this.array=C}function E(){}l.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||c(m)},_.prototype.run=function(){this.fun.apply(null,this.array)},l.title="browser",l.browser=!0,l.env={},l.argv=[],l.version="",l.versions={},l.on=E,l.addListener=E,l.once=E,l.off=E,l.removeListener=E,l.removeAllListeners=E,l.emit=E,l.prependListener=E,l.prependOnceListener=E,l.listeners=function(x){return[]},l.binding=function(x){throw new Error("process.binding is not supported")},l.cwd=function(){return"/"},l.chdir=function(x){throw new Error("process.chdir is not supported")},l.umask=function(){return 0}},{}],51:[function(i,s,n){(function(a){(function(){(function(r){var l=typeof n=="object"&&n&&!n.nodeType&&n,o=typeof s=="object"&&s&&!s.nodeType&&s,u=typeof a=="object"&&a;u.global!==u&&u.window!==u&&u.self!==u||(r=u);var c,f,g=2147483647,v=36,y=1,w=26,m=38,_=700,E=72,x=128,C="-",S=/^xn--/,L=/[^\x20-\x7E]/,M=/[\x2E\u3002\uFF0E\uFF61]/g,D={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},$=v-y,Q=Math.floor,R=String.fromCharCode;function T(K){throw new RangeError(D[K])}function P(K,U){for(var tt=K.length,st=[];tt--;)st[tt]=U(K[tt]);return st}function O(K,U){var tt=K.split("@"),st="";return tt.length>1&&(st=tt[0]+"@",K=tt[1]),st+P((K=K.replace(M,".")).split("."),U).join(".")}function Y(K){for(var U,tt,st=[],et=0,ut=K.length;et<ut;)(U=K.charCodeAt(et++))>=55296&&U<=56319&&et<ut?(64512&(tt=K.charCodeAt(et++)))==56320?st.push(((1023&U)<<10)+(1023&tt)+65536):(st.push(U),et--):st.push(U);return st}function Z(K){return P(K,function(U){var tt="";return U>65535&&(tt+=R((U-=65536)>>>10&1023|55296),U=56320|1023&U),tt+=R(U)}).join("")}function at(K,U){return K+22+75*(K<26)-((U!=0)<<5)}function V(K,U,tt){var st=0;for(K=tt?Q(K/_):K>>1,K+=Q(K/U);K>$*w>>1;st+=v)K=Q(K/$);return Q(st+($+1)*K/(K+m))}function H(K){var U,tt,st,et,ut,ct,ot,b,k,I,N,X=[],G=K.length,rt=0,mt=x,yt=E;for((tt=K.lastIndexOf(C))<0&&(tt=0),st=0;st<tt;++st)K.charCodeAt(st)>=128&&T("not-basic"),X.push(K.charCodeAt(st));for(et=tt>0?tt+1:0;et<G;){for(ut=rt,ct=1,ot=v;et>=G&&T("invalid-input"),((b=(N=K.charCodeAt(et++))-48<10?N-22:N-65<26?N-65:N-97<26?N-97:v)>=v||b>Q((g-rt)/ct))&&T("overflow"),rt+=b*ct,!(b<(k=ot<=yt?y:ot>=yt+w?w:ot-yt));ot+=v)ct>Q(g/(I=v-k))&&T("overflow"),ct*=I;yt=V(rt-ut,U=X.length+1,ut==0),Q(rt/U)>g-mt&&T("overflow"),mt+=Q(rt/U),rt%=U,X.splice(rt++,0,mt)}return Z(X)}function j(K){var U,tt,st,et,ut,ct,ot,b,k,I,N,X,G,rt,mt,yt=[];for(X=(K=Y(K)).length,U=x,tt=0,ut=E,ct=0;ct<X;++ct)(N=K[ct])<128&&yt.push(R(N));for(st=et=yt.length,et&&yt.push(C);st<X;){for(ot=g,ct=0;ct<X;++ct)(N=K[ct])>=U&&N<ot&&(ot=N);for(ot-U>Q((g-tt)/(G=st+1))&&T("overflow"),tt+=(ot-U)*G,U=ot,ct=0;ct<X;++ct)if((N=K[ct])<U&&++tt>g&&T("overflow"),N==U){for(b=tt,k=v;!(b<(I=k<=ut?y:k>=ut+w?w:k-ut));k+=v)mt=b-I,rt=v-I,yt.push(R(at(I+mt%rt,0))),b=Q(mt/rt);yt.push(R(at(b,0))),ut=V(tt,G,st==et),tt=0,++st}++tt,++U}return yt.join("")}if(c={version:"1.4.1",ucs2:{decode:Y,encode:Z},decode:H,encode:j,toASCII:function(K){return O(K,function(U){return L.test(U)?"xn--"+j(U):U})},toUnicode:function(K){return O(K,function(U){return S.test(U)?H(U.slice(4).toLowerCase()):U})}},l&&o)if(s.exports==l)o.exports=c;else for(f in c)c.hasOwnProperty(f)&&(l[f]=c[f]);else r.punycode=c})(this)}).call(this)}).call(this,typeof De<"u"?De:typeof self<"u"?self:typeof window<"u"?window:{})},{}],52:[function(i,s,n){function a(l,o){return Object.prototype.hasOwnProperty.call(l,o)}s.exports=function(l,o,u,c){o=o||"&",u=u||"=";var f={};if(typeof l!="string"||l.length===0)return f;var g=/\+/g;l=l.split(o);var v=1e3;c&&typeof c.maxKeys=="number"&&(v=c.maxKeys);var y=l.length;v>0&&y>v&&(y=v);for(var w=0;w<y;++w){var m,_,E,x,C=l[w].replace(g,"%20"),S=C.indexOf(u);S>=0?(m=C.substr(0,S),_=C.substr(S+1)):(m=C,_=""),E=decodeURIComponent(m),x=decodeURIComponent(_),a(f,E)?r(f[E])?f[E].push(x):f[E]=[f[E],x]:f[E]=x}return f};var r=Array.isArray||function(l){return Object.prototype.toString.call(l)==="[object Array]"}},{}],53:[function(i,s,n){var a=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,c,f,g){return c=c||"&",f=f||"=",u===null&&(u=void 0),typeof u=="object"?l(o(u),function(v){var y=encodeURIComponent(a(v))+f;return r(u[v])?l(u[v],function(w){return y+encodeURIComponent(a(w))}).join(c):y+encodeURIComponent(a(u[v]))}).join(c):g?encodeURIComponent(a(g))+f+encodeURIComponent(a(u)):""};var r=Array.isArray||function(u){return Object.prototype.toString.call(u)==="[object Array]"};function l(u,c){if(u.map)return u.map(c);for(var f=[],g=0;g<u.length;g++)f.push(c(u[g],g));return f}var o=Object.keys||function(u){var c=[];for(var f in u)Object.prototype.hasOwnProperty.call(u,f)&&c.push(f);return c}},{}],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 a={};function r(o,u,c){c||(c=Error);var f=function(g){var v,y;function w(m,_,E){return g.call(this,function(x,C,S){return typeof u=="string"?u:u(x,C,S)}(m,_,E))||this}return y=g,(v=w).prototype=Object.create(y.prototype),v.prototype.constructor=v,v.__proto__=y,w}(c);f.prototype.name=c.name,f.prototype.code=o,a[o]=f}function l(o,u){if(Array.isArray(o)){var c=o.length;return o=o.map(function(f){return String(f)}),c>2?"one of ".concat(u," ").concat(o.slice(0,c-1).join(", "),", or ")+o[c-1]:c===2?"one of ".concat(u," ").concat(o[0]," or ").concat(o[1]):"of ".concat(u," ").concat(o[0])}return"of ".concat(u," ").concat(String(o))}r("ERR_INVALID_OPT_VALUE",function(o,u){return'The value "'+u+'" is invalid for option "'+o+'"'},TypeError),r("ERR_INVALID_ARG_TYPE",function(o,u,c){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,m,_){return(_===void 0||_>w.length)&&(_=w.length),w.substring(_-m.length,_)===m}(o," argument"))v="The ".concat(o," ").concat(f," ").concat(l(u,"type"));else{var y=function(w,m,_){return typeof _!="number"&&(_=0),!(_+m.length>w.length)&&w.indexOf(m,_)!==-1}(o,".")?"property":"argument";v='The "'.concat(o,'" ').concat(y," ").concat(f," ").concat(l(u,"type"))}return v+=". Received type ".concat(typeof c)},TypeError),r("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),r("ERR_METHOD_NOT_IMPLEMENTED",function(o){return"The "+o+" method is not implemented"}),r("ERR_STREAM_PREMATURE_CLOSE","Premature close"),r("ERR_STREAM_DESTROYED",function(o){return"Cannot call "+o+" after a stream was destroyed"}),r("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),r("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),r("ERR_STREAM_WRITE_AFTER_END","write after end"),r("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),r("ERR_UNKNOWN_ENCODING",function(o){return"Unknown encoding: "+o},TypeError),r("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),s.exports.codes=a},{}],56:[function(i,s,n){(function(a){(function(){var r=Object.keys||function(w){var m=[];for(var _ in w)m.push(_);return m};s.exports=g;var l=i("./_stream_readable"),o=i("./_stream_writable");i("inherits")(g,l);for(var u=r(o.prototype),c=0;c<u.length;c++){var f=u[c];g.prototype[f]||(g.prototype[f]=o.prototype[f])}function g(w){if(!(this instanceof g))return new g(w);l.call(this,w),o.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||a.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=r;var a=i("./_stream_transform");function r(l){if(!(this instanceof r))return new r(l);a.call(this,l)}i("inherits")(r,a),r.prototype._transform=function(l,o,u){u(null,l)}},{"./_stream_transform":59,inherits:24}],58:[function(i,s,n){(function(a,r){(function(){var l;s.exports=T,T.ReadableState=R,i("events").EventEmitter;var o=function(b,k){return b.listeners(k).length},u=i("./internal/streams/stream"),c=i("buffer").Buffer,f=r.Uint8Array||function(){},g,v=i("util");g=v&&v.debuglog?v.debuglog("stream"):function(){};var y,w,m,_=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,L=C.ERR_STREAM_PUSH_AFTER_EOF,M=C.ERR_METHOD_NOT_IMPLEMENTED,D=C.ERR_STREAM_UNSHIFT_AFTER_END_EVENT;i("inherits")(T,u);var $=E.errorOrDestroy,Q=["error","close","destroy","pause","resume"];function R(b,k,I){l=l||i("./_stream_duplex"),b=b||{},typeof I!="boolean"&&(I=k instanceof l),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 T(b){if(l=l||i("./_stream_duplex"),!(this instanceof T))return new T(b);var k=this instanceof l;this._readableState=new R(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,N,X){g("readableAddChunk",k);var G,rt=b._readableState;if(k===null)rt.reading=!1,function(mt,yt){if(g("onEofChunk"),!yt.ended){if(yt.decoder){var Et=yt.decoder.end();Et&&Et.length&&(yt.buffer.push(Et),yt.length+=yt.objectMode?1:Et.length)}yt.ended=!0,yt.sync?at(mt):(yt.needReadable=!1,yt.emittedReadable||(yt.emittedReadable=!0,V(mt)))}}(b,rt);else if(X||(G=function(mt,yt){var Et;Tt=yt,c.isBuffer(Tt)||Tt instanceof f||typeof yt=="string"||yt===void 0||mt.objectMode||(Et=new S("chunk",["string","Buffer","Uint8Array"],yt));var Tt;return Et}(rt,k)),G)$(b,G);else if(rt.objectMode||k&&k.length>0)if(typeof k=="string"||rt.objectMode||Object.getPrototypeOf(k)===c.prototype||(k=function(mt){return c.from(mt)}(k)),N)rt.endEmitted?$(b,new D):O(b,rt,k,!0);else if(rt.ended)$(b,new L);else{if(rt.destroyed)return!1;rt.reading=!1,rt.decoder&&!I?(k=rt.decoder.write(k),rt.objectMode||k.length!==0?O(b,rt,k,!1):H(b,rt)):O(b,rt,k,!1)}else N||(rt.reading=!1,H(b,rt));return!rt.ended&&(rt.length<rt.highWaterMark||rt.length===0)}function O(b,k,I,N){k.flowing&&k.length===0&&!k.sync?(k.awaitDrain=0,b.emit("data",I)):(k.length+=k.objectMode?1:I.length,N?k.buffer.unshift(I):k.buffer.push(I),k.needReadable&&at(b)),H(b,k)}Object.defineProperty(T.prototype,"destroyed",{enumerable:!1,get:function(){return this._readableState!==void 0&&this._readableState.destroyed},set:function(b){this._readableState&&(this._readableState.destroyed=b)}}),T.prototype.destroy=E.destroy,T.prototype._undestroy=E.undestroy,T.prototype._destroy=function(b,k){k(b)},T.prototype.push=function(b,k){var I,N=this._readableState;return N.objectMode?I=!0:typeof b=="string"&&((k=k||N.defaultEncoding)!==N.encoding&&(b=c.from(b,k),k=""),I=!0),P(this,b,k,!1,I)},T.prototype.unshift=function(b){return P(this,b,null,!0,!1)},T.prototype.isPaused=function(){return this._readableState.flowing===!1},T.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,N="";I!==null;)N+=k.write(I.data),I=I.next;return this._readableState.buffer.clear(),N!==""&&this._readableState.buffer.push(N),this._readableState.length=N.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 at(b){var k=b._readableState;g("emitReadable",k.needReadable,k.emittedReadable),k.needReadable=!1,k.emittedReadable||(g("emitReadable",k.flowing),k.emittedReadable=!0,a.nextTick(V,b))}function V(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,a.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 U(b){g("readable nexttick read 0"),b.read(0)}function tt(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,a.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,N=b.length;I<N;I++)if(b[I]===k)return I;return-1}T.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):at(this),null;if((b=Z(b,k))===0&&k.ended)return k.length===0&&ut(this),null;var N,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))),(N=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)),N!==null&&this.emit("data",N),N},T.prototype._read=function(b){$(this,new M("_read()"))},T.prototype.pipe=function(b,k){var I=this,N=this._readableState;switch(N.pipesCount){case 0:N.pipes=b;break;case 1:N.pipes=[N.pipes,b];break;default:N.pipes.push(b)}N.pipesCount+=1,g("pipe count=%d opts=%j",N.pipesCount,k);var X=(!k||k.end!==!1)&&b!==a.stdout&&b!==a.stderr?rt:xe;function G(Vt,te){g("onunpipe"),Vt===I&&te&&te.hasUnpiped===!1&&(te.hasUnpiped=!0,g("cleanup"),b.removeListener("close",be),b.removeListener("finish",se),b.removeListener("drain",mt),b.removeListener("error",Tt),b.removeListener("unpipe",G),I.removeListener("end",rt),I.removeListener("end",xe),I.removeListener("data",Et),yt=!0,!N.awaitDrain||b._writableState&&!b._writableState.needDrain||mt())}function rt(){g("onend"),b.end()}N.endEmitted?a.nextTick(X):I.once("end",X),b.on("unpipe",G);var mt=function(Vt){return function(){var te=Vt._readableState;g("pipeOnDrain",te.awaitDrain),te.awaitDrain&&te.awaitDrain--,te.awaitDrain===0&&o(Vt,"data")&&(te.flowing=!0,st(Vt))}}(I);b.on("drain",mt);var yt=!1;function Et(Vt){g("ondata");var te=b.write(Vt);g("dest.write",te),te===!1&&((N.pipesCount===1&&N.pipes===b||N.pipesCount>1&&ot(N.pipes,b)!==-1)&&!yt&&(g("false write response, pause",N.awaitDrain),N.awaitDrain++),I.pause())}function Tt(Vt){g("onerror",Vt),xe(),b.removeListener("error",Tt),o(b,"error")===0&&$(b,Vt)}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",Et),function(Vt,te,xi){if(typeof Vt.prependListener=="function")return Vt.prependListener(te,xi);Vt._events&&Vt._events[te]?Array.isArray(Vt._events[te])?Vt._events[te].unshift(xi):Vt._events[te]=[xi,Vt._events[te]]:Vt.on(te,xi)}(b,"error",Tt),b.once("close",be),b.once("finish",se),b.emit("pipe",I),N.flowing||(g("pipe resume"),I.resume()),b},T.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 N=k.pipes,X=k.pipesCount;k.pipes=null,k.pipesCount=0,k.flowing=!1;for(var G=0;G<X;G++)N[G].emit("unpipe",this,{hasUnpiped:!1});return this}var rt=ot(k.pipes,b);return rt===-1?this:(k.pipes.splice(rt,1),k.pipesCount-=1,k.pipesCount===1&&(k.pipes=k.pipes[0]),b.emit("unpipe",this,I),this)},T.prototype.on=function(b,k){var I=u.prototype.on.call(this,b,k),N=this._readableState;return b==="data"?(N.readableListening=this.listenerCount("readable")>0,N.flowing!==!1&&this.resume()):b==="readable"&&(N.endEmitted||N.readableListening||(N.readableListening=N.needReadable=!0,N.flowing=!1,N.emittedReadable=!1,g("on readable",N.length,N.reading),N.length?at(this):N.reading||a.nextTick(U,this))),I},T.prototype.addListener=T.prototype.on,T.prototype.removeListener=function(b,k){var I=u.prototype.removeListener.call(this,b,k);return b==="readable"&&a.nextTick(K,this),I},T.prototype.removeAllListeners=function(b){var k=u.prototype.removeAllListeners.apply(this,arguments);return b!=="readable"&&b!==void 0||a.nextTick(K,this),k},T.prototype.resume=function(){var b=this._readableState;return b.flowing||(g("resume"),b.flowing=!b.readableListening,function(k,I){I.resumeScheduled||(I.resumeScheduled=!0,a.nextTick(tt,k,I))}(this,b)),b.paused=!1,this},T.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},T.prototype.wrap=function(b){var k=this,I=this._readableState,N=!1;for(var X in b.on("end",function(){if(g("wrapped end"),I.decoder&&!I.ended){var rt=I.decoder.end();rt&&rt.length&&k.push(rt)}k.push(null)}),b.on("data",function(rt){g("wrapped data"),I.decoder&&(rt=I.decoder.write(rt)),(!I.objectMode||rt!=null)&&(I.objectMode||rt&&rt.length)&&(k.push(rt)||(N=!0,b.pause()))}),b)this[X]===void 0&&typeof b[X]=="function"&&(this[X]=function(rt){return function(){return b[rt].apply(b,arguments)}}(X));for(var G=0;G<Q.length;G++)b.on(Q[G],this.emit.bind(this,Q[G]));return this._read=function(rt){g("wrapped _read",rt),N&&(N=!1,b.resume())},this},typeof Symbol=="function"&&(T.prototype[Symbol.asyncIterator]=function(){return w===void 0&&(w=i("./internal/streams/async_iterator")),w(this)}),Object.defineProperty(T.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),Object.defineProperty(T.prototype,"readableBuffer",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}}),Object.defineProperty(T.prototype,"readableFlowing",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(b){this._readableState&&(this._readableState.flowing=b)}}),T._fromList=et,Object.defineProperty(T.prototype,"readableLength",{enumerable:!1,get:function(){return this._readableState.length}}),typeof Symbol=="function"&&(T.from=function(b,k){return m===void 0&&(m=i("./internal/streams/from")),m(T,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 a=i("../errors").codes,r=a.ERR_METHOD_NOT_IMPLEMENTED,l=a.ERR_MULTIPLE_CALLBACK,o=a.ERR_TRANSFORM_ALREADY_TRANSFORMING,u=a.ERR_TRANSFORM_WITH_LENGTH_0,c=i("./_stream_duplex");function f(y){if(!(this instanceof f))return new f(y);c.call(this,y),this._transformState={afterTransform:function(w,m){var _=this._transformState;_.transforming=!1;var E=_.writecb;if(E===null)return this.emit("error",new l);_.writechunk=null,_.writecb=null,m!=null&&this.push(m),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,m){v(y,w,m)})}function v(y,w,m){if(w)return y.emit("error",w);if(m!=null&&y.push(m),y._writableState.length)throw new u;if(y._transformState.transforming)throw new o;return y.push(null)}i("inherits")(f,c),f.prototype.push=function(y,w){return this._transformState.needTransform=!1,c.prototype.push.call(this,y,w)},f.prototype._transform=function(y,w,m){m(new r("_transform()"))},f.prototype._write=function(y,w,m){var _=this._transformState;if(_.writecb=m,_.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){c.prototype._destroy.call(this,y,function(m){w(m)})}},{"../errors":55,"./_stream_duplex":56,inherits:24}],60:[function(i,s,n){(function(a,r){(function(){function l(H){var j=this;this.next=null,this.entry=null,this.finish=function(){(function(K,U,tt){var st=K.entry;for(K.entry=null;st;){var et=st.callback;U.pendingcb--,et(tt),st=st.next}U.corkedRequestsFree.next=K})(j,H)}}var o;s.exports=T,T.WritableState=R;var u={deprecate:i("util-deprecate")},c=i("./internal/streams/stream"),f=i("buffer").Buffer,g=r.Uint8Array||function(){},v,y=i("./internal/streams/destroy"),w=i("./internal/streams/state").getHighWaterMark,m=i("../errors").codes,_=m.ERR_INVALID_ARG_TYPE,E=m.ERR_METHOD_NOT_IMPLEMENTED,x=m.ERR_MULTIPLE_CALLBACK,C=m.ERR_STREAM_CANNOT_PIPE,S=m.ERR_STREAM_DESTROYED,L=m.ERR_STREAM_NULL_VALUES,M=m.ERR_STREAM_WRITE_AFTER_END,D=m.ERR_UNKNOWN_ENCODING,$=y.errorOrDestroy;function Q(){}function R(H,j,K){o=o||i("./_stream_duplex"),H=H||{},typeof K!="boolean"&&(K=j instanceof o),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 U=H.decodeStrings===!1;this.decodeStrings=!U,this.defaultEncoding=H.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(tt){(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,N,X,G){--I.pendingcb,N?(a.nextTick(G,X),a.nextTick(V,k,I),k._writableState.errorEmitted=!0,$(k,X)):(G(X),k._writableState.errorEmitted=!0,$(k,X),V(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?a.nextTick(O,st,ut,b,ot):O(st,ut,b,ot)}})(j,tt)},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 l(this)}function T(H){var j=this instanceof(o=o||i("./_stream_duplex"));if(!j&&!v.call(T,this))return new T(H);this._writableState=new R(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)),c.call(this)}function P(H,j,K,U,tt,st,et){j.writelen=U,j.writecb=et,j.writing=!0,j.sync=!0,j.destroyed?j.onwrite(new S("write")):K?H._writev(tt,j.onwrite):H._write(tt,st,j.onwrite),j.sync=!1}function O(H,j,K,U){K||function(tt,st){st.length===0&&st.needDrain&&(st.needDrain=!1,tt.emit("drain"))}(H,j),j.pendingcb--,U(),V(H,j)}function Y(H,j){j.bufferProcessing=!0;var K=j.bufferedRequest;if(H._writev&&K&&K.next){var U=j.bufferedRequestCount,tt=new Array(U),st=j.corkedRequestsFree;st.entry=K;for(var et=0,ut=!0;K;)tt[et]=K,K.isBuf||(ut=!1),K=K.next,et+=1;tt.allBuffers=ut,P(H,j,!0,j.length,tt,"",st.finish),j.pendingcb++,j.lastBufferedRequest=null,st.next?(j.corkedRequestsFree=st.next,st.next=null):j.corkedRequestsFree=new l(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 at(H,j){H._final(function(K){j.pendingcb--,K&&$(H,K),j.prefinished=!0,H.emit("prefinish"),V(H,j)})}function V(H,j){var K=Z(j);if(K&&(function(tt,st){st.prefinished||st.finalCalled||(typeof tt._final!="function"||st.destroyed?(st.prefinished=!0,tt.emit("prefinish")):(st.pendingcb++,st.finalCalled=!0,a.nextTick(at,tt,st)))}(H,j),j.pendingcb===0&&(j.finished=!0,H.emit("finish"),j.autoDestroy))){var U=H._readableState;(!U||U.autoDestroy&&U.endEmitted)&&H.destroy()}return K}i("inherits")(T,c),R.prototype.getBuffer=function(){for(var H=this.bufferedRequest,j=[];H;)j.push(H),H=H.next;return j},function(){try{Object.defineProperty(R.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(T,Symbol.hasInstance,{value:function(H){return!!v.call(this,H)||this===T&&H&&H._writableState instanceof R}})):v=function(H){return H instanceof this},T.prototype.pipe=function(){$(this,new C)},T.prototype.write=function(H,j,K){var U,tt=this._writableState,st=!1,et=!tt.objectMode&&(U=H,f.isBuffer(U)||U 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=tt.defaultEncoding),typeof K!="function"&&(K=Q),tt.ending?function(ut,ct){var ot=new M;$(ut,ot),a.nextTick(ct,ot)}(this,K):(et||function(ut,ct,ot,b){var k;return ot===null?k=new L:typeof ot=="string"||ct.objectMode||(k=new _("chunk",["string","Buffer"],ot)),!k||($(ut,k),a.nextTick(b,k),!1)}(this,tt,H,K))&&(tt.pendingcb++,st=function(ut,ct,ot,b,k,I){if(!ot){var N=function(mt,yt,Et){return mt.objectMode||mt.decodeStrings===!1||typeof yt!="string"||(yt=f.from(yt,Et)),yt}(ct,b,k);b!==N&&(ot=!0,k="buffer",b=N)}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 rt=ct.lastBufferedRequest;ct.lastBufferedRequest={chunk:b,encoding:k,isBuf:ot,callback:I,next:null},rt?rt.next=ct.lastBufferedRequest:ct.bufferedRequest=ct.lastBufferedRequest,ct.bufferedRequestCount+=1}else P(ut,ct,!1,X,b,k,I);return G}(this,tt,et,H,j,K)),st},T.prototype.cork=function(){this._writableState.corked++},T.prototype.uncork=function(){var H=this._writableState;H.corked&&(H.corked--,H.writing||H.corked||H.bufferProcessing||!H.bufferedRequest||Y(this,H))},T.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 D(H);return this._writableState.defaultEncoding=H,this},Object.defineProperty(T.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(T.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),T.prototype._write=function(H,j,K){K(new E("_write()"))},T.prototype._writev=null,T.prototype.end=function(H,j,K){var U=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),U.corked&&(U.corked=1,this.uncork()),U.ending||function(tt,st,et){st.ending=!0,V(tt,st),et&&(st.finished?a.nextTick(et):tt.once("finish",et)),st.ended=!0,tt.writable=!1}(this,U,K),this},Object.defineProperty(T.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(T.prototype,"destroyed",{enumerable:!1,get:function(){return this._writableState!==void 0&&this._writableState.destroyed},set:function(H){this._writableState&&(this._writableState.destroyed=H)}}),T.prototype.destroy=y.destroy,T.prototype._undestroy=y.undestroy,T.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(a){(function(){var r;function l(C,S,L){return S in C?Object.defineProperty(C,S,{value:L,enumerable:!0,configurable:!0,writable:!0}):C[S]=L,C}var o=i("./end-of-stream"),u=Symbol("lastResolve"),c=Symbol("lastReject"),f=Symbol("error"),g=Symbol("ended"),v=Symbol("lastPromise"),y=Symbol("handlePromise"),w=Symbol("stream");function m(C,S){return{value:C,done:S}}function _(C){var S=C[u];if(S!==null){var L=C[w].read();L!==null&&(C[v]=null,C[u]=null,C[c]=null,S(m(L,!1)))}}var E=Object.getPrototypeOf(function(){}),x=Object.setPrototypeOf((l(r={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(m(void 0,!0));if(this[w].destroyed)return new Promise(function($,Q){a.nextTick(function(){C[f]?Q(C[f]):$(m(void 0,!0))})});var L,M=this[v];if(M)L=new Promise(function($,Q){return function(R,T){$.then(function(){Q[g]?R(m(void 0,!0)):Q[y](R,T)},T)}}(M,this));else{var D=this[w].read();if(D!==null)return Promise.resolve(m(D,!1));L=new Promise(this[y])}return this[v]=L,L}},Symbol.asyncIterator,function(){return this}),l(r,"return",function(){var C=this;return new Promise(function(S,L){C[w].destroy(null,function(M){M?L(M):S(m(void 0,!0))})})}),r),E);s.exports=function(C){var S,L=Object.create(x,(l(S={},w,{value:C,writable:!0}),l(S,u,{value:null,writable:!0}),l(S,c,{value:null,writable:!0}),l(S,f,{value:null,writable:!0}),l(S,g,{value:C._readableState.endEmitted,writable:!0}),l(S,y,{value:function(M,D){var $=L[w].read();$?(L[v]=null,L[u]=null,L[c]=null,M(m($,!1))):(L[u]=M,L[c]=D)},writable:!0}),S));return L[v]=null,o(C,function(M){if(M&&M.code!=="ERR_STREAM_PREMATURE_CLOSE"){var D=L[c];return D!==null&&(L[v]=null,L[u]=null,L[c]=null,D(M)),void(L[f]=M)}var $=L[u];$!==null&&(L[v]=null,L[u]=null,L[c]=null,$(m(void 0,!0))),L[g]=!0}),C.on("readable",function(M){a.nextTick(_,M)}.bind(null,L)),L}}).call(this)}).call(this,i("_process"))},{"./end-of-stream":64,_process:50}],62:[function(i,s,n){function a(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 r(f,g,v){return g in f?Object.defineProperty(f,g,{value:v,enumerable:!0,configurable:!0,writable:!0}):f[g]=v,f}function l(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 o=i("buffer").Buffer,u=i("util").inspect,c=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,m=""+w.data;w=w.next;)m+=y+w.data;return m}},{key:"concat",value:function(y){if(this.length===0)return o.alloc(0);for(var w,m,_,E=o.allocUnsafe(y>>>0),x=this.head,C=0;x;)w=x.data,m=E,_=C,o.prototype.copy.call(w,m,_),C+=x.data.length,x=x.next;return E}},{key:"consume",value:function(y,w){var m;return y<this.head.data.length?(m=this.head.data.slice(0,y),this.head.data=this.head.data.slice(y)):m=y===this.head.data.length?this.shift():w?this._getString(y):this._getBuffer(y),m}},{key:"first",value:function(){return this.head.data}},{key:"_getString",value:function(y){var w=this.head,m=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?(++m,w.next?this.head=w.next:this.head=this.tail=null):(this.head=w,w.data=E.slice(x));break}++m}return this.length-=m,_}},{key:"_getBuffer",value:function(y){var w=o.allocUnsafe(y),m=this.head,_=1;for(m.data.copy(w),y-=m.data.length;m=m.next;){var E=m.data,x=y>E.length?E.length:y;if(E.copy(w,w.length-y,0,x),(y-=x)===0){x===E.length?(++_,m.next?this.head=m.next:this.head=this.tail=null):(this.head=m,m.data=E.slice(x));break}++_}return this.length-=_,w}},{key:c,value:function(y,w){return u(this,function(m){for(var _=1;_<arguments.length;_++){var E=arguments[_]!=null?arguments[_]:{};_%2?a(Object(E),!0).forEach(function(x){r(m,x,E[x])}):Object.getOwnPropertyDescriptors?Object.defineProperties(m,Object.getOwnPropertyDescriptors(E)):a(Object(E)).forEach(function(x){Object.defineProperty(m,x,Object.getOwnPropertyDescriptor(E,x))})}return m}({},w,{depth:0,customInspect:!1}))}}])&&l(g.prototype,v),f}()},{buffer:17,util:16}],63:[function(i,s,n){(function(a){(function(){function r(u,c){o(u,c),l(u)}function l(u){u._writableState&&!u._writableState.emitClose||u._readableState&&!u._readableState.emitClose||u.emit("close")}function o(u,c){u.emit("error",c)}s.exports={destroy:function(u,c){var f=this,g=this._readableState&&this._readableState.destroyed,v=this._writableState&&this._writableState.destroyed;return g||v?(c?c(u):u&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,a.nextTick(o,this,u)):a.nextTick(o,this,u)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(u||null,function(y){!c&&y?f._writableState?f._writableState.errorEmitted?a.nextTick(l,f):(f._writableState.errorEmitted=!0,a.nextTick(r,f,y)):a.nextTick(r,f,y):c?(a.nextTick(l,f),c(y)):a.nextTick(l,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,c){var f=u._readableState,g=u._writableState;f&&f.autoDestroy||g&&g.autoDestroy?u.destroy(c):u.emit("error",c)}}}).call(this)}).call(this,i("_process"))},{_process:50}],64:[function(i,s,n){var a=i("../../../errors").codes.ERR_STREAM_PREMATURE_CLOSE;function r(){}s.exports=function l(o,u,c){if(typeof u=="function")return l(o,null,u);u||(u={}),c=function(S){var L=!1;return function(){if(!L){L=!0;for(var M=arguments.length,D=new Array(M),$=0;$<M;$++)D[$]=arguments[$];S.apply(this,D)}}}(c||r);var f=u.readable||u.readable!==!1&&o.readable,g=u.writable||u.writable!==!1&&o.writable,v=function(){o.writable||w()},y=o._writableState&&o._writableState.finished,w=function(){g=!1,y=!0,f||c.call(o)},m=o._readableState&&o._readableState.endEmitted,_=function(){f=!1,m=!0,g||c.call(o)},E=function(S){c.call(o,S)},x=function(){var S;return f&&!m?(o._readableState&&o._readableState.ended||(S=new a),c.call(o,S)):g&&!y?(o._writableState&&o._writableState.ended||(S=new a),c.call(o,S)):void 0},C=function(){o.req.on("finish",w)};return function(S){return S.setHeader&&typeof S.abort=="function"}(o)?(o.on("complete",w),o.on("abort",x),o.req?C():o.on("request",C)):g&&!o._writableState&&(o.on("end",v),o.on("close",v)),o.on("end",_),o.on("finish",w),u.error!==!1&&o.on("error",E),o.on("close",x),function(){o.removeListener("complete",w),o.removeListener("abort",x),o.removeListener("request",C),o.req&&o.req.removeListener("finish",w),o.removeListener("end",v),o.removeListener("close",v),o.removeListener("finish",w),o.removeListener("end",_),o.removeListener("error",E),o.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 a,r=i("../../../errors").codes,l=r.ERR_MISSING_ARGS,o=r.ERR_STREAM_DESTROYED;function u(g){if(g)throw g}function c(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,m=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 l("streams");var _=v.map(function(E,x){var C=x<v.length-1;return function(S,L,M,D){D=function(R){var T=!1;return function(){T||(T=!0,R.apply(void 0,arguments))}}(D);var $=!1;S.on("close",function(){$=!0}),a===void 0&&(a=i("./end-of-stream")),a(S,{readable:L,writable:M},function(R){if(R)return D(R);$=!0,D()});var Q=!1;return function(R){if(!$&&!Q)return Q=!0,function(T){return T.setHeader&&typeof T.abort=="function"}(S)?S.abort():typeof S.destroy=="function"?S.destroy():void D(R||new o("pipe"))}}(E,C,x>0,function(S){w||(w=S),S&&_.forEach(c),C||(_.forEach(c),m(w))})});return v.reduce(f)}},{"../../../errors":55,"./end-of-stream":64}],67:[function(i,s,n){var a=i("../../../errors").codes.ERR_INVALID_OPT_VALUE;s.exports={getHighWaterMark:function(r,l,o,u){var c=function(f,g,v){return f.highWaterMark!=null?f.highWaterMark:g?f[v]:null}(l,u,o);if(c!=null){if(!isFinite(c)||Math.floor(c)!==c||c<0)throw new a(u?o:"highWaterMark",c);return Math.floor(c)}return r.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 a;if(arguments.length>0){a=new Array(arguments.length-2);for(var r=0;r<a.length;r++)a[r]=arguments[r+2]}return new function(l,o,u){var c=this;this._callback=l,this._args=u,this._interval=setInterval(l,o,this._args),this.reschedule=function(f){f||(f=c._interval),c._interval&&clearInterval(c._interval),c._interval=setInterval(c._callback,f,c._args)},this.clear=function(){c._interval&&(clearInterval(c._interval),c._interval=void 0)},this.destroy=function(){c._interval&&clearInterval(c._interval),c._callback=void 0,c._interval=void 0,c._args=void 0}}(arguments[0],arguments[1],a)}},{}],71:[function(i,s,n){s.exports=i("./index.js")()},{"./index.js":72}],72:[function(i,s,n){(function(a){(function(){function r(l){return l instanceof a?a.from(l):new l.constructor(l.buffer.slice(),l.byteOffset,l.length)}s.exports=function(l){return(l=l||{}).circles?function(u){var c=[],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 m in c.push(y),f.push(w),y){var _=y[m];if(typeof _!="object"||_===null)w[m]=_;else if(_ instanceof Date)w[m]=new Date(_);else if(_ instanceof Map)w[m]=new Map(g(Array.from(_),v));else if(_ instanceof Set)w[m]=new Set(g(Array.from(_),v));else if(ArrayBuffer.isView(_))w[m]=r(_);else{var E=c.indexOf(_);w[m]=E!==-1?f[E]:v(_)}}return c.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 m in c.push(y),f.push(w),y)if(Object.hasOwnProperty.call(y,m)!==!1){var _=y[m];if(typeof _!="object"||_===null)w[m]=_;else if(_ instanceof Date)w[m]=new Date(_);else if(_ instanceof Map)w[m]=new Map(g(Array.from(_),v));else if(_ instanceof Set)w[m]=new Set(g(Array.from(_),v));else if(ArrayBuffer.isView(_))w[m]=r(_);else{var E=c.indexOf(_);w[m]=E!==-1?f[E]:v(_)}}return c.pop(),f.pop(),w};function g(v,y){for(var w=Object.keys(v),m=new Array(w.length),_=0;_<w.length;_++){var E=w[_],x=v[E];if(typeof x!="object"||x===null)m[E]=x;else if(x instanceof Date)m[E]=new Date(x);else if(ArrayBuffer.isView(x))m[E]=r(x);else{var C=c.indexOf(x);m[E]=C!==-1?f[C]:y(x)}}return m}}(l):l.proto?function u(c){if(typeof c!="object"||c===null)return c;if(c instanceof Date)return new Date(c);if(Array.isArray(c))return o(c,u);if(c instanceof Map)return new Map(o(Array.from(c),u));if(c instanceof Set)return new Set(o(Array.from(c),u));var f={};for(var g in c){var v=c[g];typeof v!="object"||v===null?f[g]=v:v instanceof Date?f[g]=new Date(v):v instanceof Map?f[g]=new Map(o(Array.from(v),u)):v instanceof Set?f[g]=new Set(o(Array.from(v),u)):ArrayBuffer.isView(v)?f[g]=r(v):f[g]=u(v)}return f}:function u(c){if(typeof c!="object"||c===null)return c;if(c instanceof Date)return new Date(c);if(Array.isArray(c))return o(c,u);if(c instanceof Map)return new Map(o(Array.from(c),u));if(c instanceof Set)return new Set(o(Array.from(c),u));var f={};for(var g in c)if(Object.hasOwnProperty.call(c,g)!==!1){var v=c[g];typeof v!="object"||v===null?f[g]=v:v instanceof Date?f[g]=new Date(v):v instanceof Map?f[g]=new Map(o(Array.from(v),u)):v instanceof Set?f[g]=new Set(o(Array.from(v),u)):ArrayBuffer.isView(v)?f[g]=r(v):f[g]=u(v)}return f};function o(u,c){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]=r(w):g[y]=c(w)}return g}}}).call(this)}).call(this,i("buffer").Buffer)},{buffer:17}],73:[function(i,s,n){var a=i("buffer"),r=a.Buffer;function l(u,c){for(var f in u)c[f]=u[f]}function o(u,c,f){return r(u,c,f)}r.from&&r.alloc&&r.allocUnsafe&&r.allocUnsafeSlow?s.exports=a:(l(a,n),n.Buffer=o),o.prototype=Object.create(r.prototype),l(r,o),o.from=function(u,c,f){if(typeof u=="number")throw new TypeError("Argument must not be a number");return r(u,c,f)},o.alloc=function(u,c,f){if(typeof u!="number")throw new TypeError("Argument must be a number");var g=r(u);return c!==void 0?typeof f=="string"?g.fill(c,f):g.fill(c):g.fill(0),g},o.allocUnsafe=function(u){if(typeof u!="number")throw new TypeError("Argument must be a number");return r(u)},o.allocUnsafeSlow=function(u){if(typeof u!="number")throw new TypeError("Argument must be a number");return a.SlowBuffer(u)}},{buffer:17}],74:[function(i,s,n){s.exports=function(a){var r=a._readableState;return r?r.objectMode||typeof a._duplexState=="number"?a.read():a.read((l=r,l.buffer.length?l.buffer.head?l.buffer.head.data.length:l.buffer[0].length:l.length)):null;var l}},{}],75:[function(i,s,n){var a=i("safe-buffer").Buffer,r=a.isEncoding||function(m){switch((m=""+m)&&m.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 l(m){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"&&(a.isEncoding===r||!r(E)))throw new Error("Unknown encoding: "+E);return x||E}(m),this.encoding){case"utf16le":this.text=c,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=a.allocUnsafe(_)}function o(m){return m<=127?0:m>>5==6?2:m>>4==14?3:m>>3==30?4:m>>6==2?-1:-2}function u(m){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,m);return E!==void 0?E:this.lastNeed<=m.length?(m.copy(this.lastChar,_,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(m.copy(this.lastChar,_,0,m.length),void(this.lastNeed-=m.length))}function c(m,_){if((m.length-_)%2==0){var E=m.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]=m[m.length-2],this.lastChar[1]=m[m.length-1],E.slice(0,-1)}return E}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=m[m.length-1],m.toString("utf16le",_,m.length-1)}function f(m){var _=m&&m.length?this.write(m):"";if(this.lastNeed){var E=this.lastTotal-this.lastNeed;return _+this.lastChar.toString("utf16le",0,E)}return _}function g(m,_){var E=(m.length-_)%3;return E===0?m.toString("base64",_):(this.lastNeed=3-E,this.lastTotal=3,E===1?this.lastChar[0]=m[m.length-1]:(this.lastChar[0]=m[m.length-2],this.lastChar[1]=m[m.length-1]),m.toString("base64",_,m.length-E))}function v(m){var _=m&&m.length?this.write(m):"";return this.lastNeed?_+this.lastChar.toString("base64",0,3-this.lastNeed):_}function y(m){return m.toString(this.encoding)}function w(m){return m&&m.length?this.write(m):""}n.StringDecoder=l,l.prototype.write=function(m){if(m.length===0)return"";var _,E;if(this.lastNeed){if((_=this.fillLast(m))===void 0)return"";E=this.lastNeed,this.lastNeed=0}else E=0;return E<m.length?_?_+this.text(m,E):this.text(m,E):_||""},l.prototype.end=function(m){var _=m&&m.length?this.write(m):"";return this.lastNeed?_+"\uFFFD":_},l.prototype.text=function(m,_){var E=function(C,S,L){var M=S.length-1;if(M<L)return 0;var D=o(S[M]);return D>=0?(D>0&&(C.lastNeed=D-1),D):--M<L||D===-2?0:(D=o(S[M]))>=0?(D>0&&(C.lastNeed=D-2),D):--M<L||D===-2?0:(D=o(S[M]))>=0?(D>0&&(D===2?D=0:C.lastNeed=D-3),D):0}(this,m,_);if(!this.lastNeed)return m.toString("utf8",_);this.lastTotal=E;var x=m.length-(E-this.lastNeed);return m.copy(this.lastChar,0,x),m.toString("utf8",_,x)},l.prototype.fillLast=function(m){if(this.lastNeed<=m.length)return m.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);m.copy(this.lastChar,this.lastTotal-this.lastNeed,0,m.length),this.lastNeed-=m.length}},{"safe-buffer":73}],76:[function(i,s,n){var a=i("punycode"),r=i("./util");function l(){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(L,M){return S(L,!1,!0).resolve(M)},n.resolveObject=function(L,M){return L?S(L,!1,!0).resolveObject(M):M},n.format=function(L){return r.isString(L)&&(L=S(L)),L instanceof l?L.format():l.prototype.format.call(L)},n.Url=l;var o=/^([a-z0-9.+-]+:)/i,u=/:[0-9]*$/,c=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,f=["{","}","|","\\","^","`"].concat(["<",">",'"',"`"," ","\r",`
- `," "]),g=["'"].concat(f),v=["%","/","?",";","#"].concat(g),y=["/","?","#"],w=/^[+a-z0-9A-Z_-]{0,63}$/,m=/^([+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(L,M,D){if(L&&r.isObject(L)&&L instanceof l)return L;var $=new l;return $.parse(L,M,D),$}l.prototype.parse=function(L,M,D){if(!r.isString(L))throw new TypeError("Parameter 'url' must be a string, not "+typeof L);var $=L.indexOf("?"),Q=$!==-1&&$<L.indexOf("#")?"?":"#",R=L.split(Q);R[0]=R[0].replace(/\\/g,"/");var T=L=R.join(Q);if(T=T.trim(),!D&&L.split("#").length===1){var P=c.exec(T);if(P)return this.path=T,this.href=T,this.pathname=P[1],P[2]?(this.search=P[2],this.query=M?C.parse(this.search.substr(1)):this.search.substr(1)):M&&(this.search="",this.query={}),this}var O=o.exec(T);if(O){var Y=(O=O[0]).toLowerCase();this.protocol=Y,T=T.substr(O.length)}if(D||O||T.match(/^\/\/[^@\/]+@[^@\/]+/)){var Z=T.substr(0,2)==="//";!Z||O&&E[O]||(T=T.substr(2),this.slashes=!0)}if(!E[O]&&(Z||O&&!x[O])){for(var at,V,H=-1,j=0;j<y.length;j++)(K=T.indexOf(y[j]))!==-1&&(H===-1||K<H)&&(H=K);for((V=H===-1?T.lastIndexOf("@"):T.lastIndexOf("@",H))!==-1&&(at=T.slice(0,V),T=T.slice(V+1),this.auth=decodeURIComponent(at)),H=-1,j=0;j<v.length;j++){var K;(K=T.indexOf(v[j]))!==-1&&(H===-1||K<H)&&(H=K)}H===-1&&(H=T.length),this.host=T.slice(0,H),T=T.slice(H),this.parseHost(),this.hostname=this.hostname||"";var U=this.hostname[0]==="["&&this.hostname[this.hostname.length-1]==="]";if(!U)for(var tt=this.hostname.split(/\./),st=(j=0,tt.length);j<st;j++){var et=tt[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=tt.slice(0,j),k=tt.slice(j+1),I=et.match(m);I&&(b.push(I[1]),k.unshift(I[2])),k.length&&(T="/"+k.join(".")+T),this.hostname=b.join(".");break}}}this.hostname.length>255?this.hostname="":this.hostname=this.hostname.toLowerCase(),U||(this.hostname=a.toASCII(this.hostname));var N=this.port?":"+this.port:"",X=this.hostname||"";this.host=X+N,this.href+=this.host,U&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),T[0]!=="/"&&(T="/"+T))}if(!_[Y])for(j=0,st=g.length;j<st;j++){var G=g[j];if(T.indexOf(G)!==-1){var rt=encodeURIComponent(G);rt===G&&(rt=escape(G)),T=T.split(G).join(rt)}}var mt=T.indexOf("#");mt!==-1&&(this.hash=T.substr(mt),T=T.slice(0,mt));var yt=T.indexOf("?");if(yt!==-1?(this.search=T.substr(yt),this.query=T.substr(yt+1),M&&(this.query=C.parse(this.query)),T=T.slice(0,yt)):M&&(this.search="",this.query={}),T&&(this.pathname=T),x[Y]&&this.hostname&&!this.pathname&&(this.pathname="/"),this.pathname||this.search){N=this.pathname||"";var Et=this.search||"";this.path=N+Et}return this.href=this.format(),this},l.prototype.format=function(){var L=this.auth||"";L&&(L=(L=encodeURIComponent(L)).replace(/%3A/i,":"),L+="@");var M=this.protocol||"",D=this.pathname||"",$=this.hash||"",Q=!1,R="";this.host?Q=L+this.host:this.hostname&&(Q=L+(this.hostname.indexOf(":")===-1?this.hostname:"["+this.hostname+"]"),this.port&&(Q+=":"+this.port)),this.query&&r.isObject(this.query)&&Object.keys(this.query).length&&(R=C.stringify(this.query));var T=this.search||R&&"?"+R||"";return M&&M.substr(-1)!==":"&&(M+=":"),this.slashes||(!M||x[M])&&Q!==!1?(Q="//"+(Q||""),D&&D.charAt(0)!=="/"&&(D="/"+D)):Q||(Q=""),$&&$.charAt(0)!=="#"&&($="#"+$),T&&T.charAt(0)!=="?"&&(T="?"+T),M+Q+(D=D.replace(/[?#]/g,function(P){return encodeURIComponent(P)}))+(T=T.replace("#","%23"))+$},l.prototype.resolve=function(L){return this.resolveObject(S(L,!1,!0)).format()},l.prototype.resolveObject=function(L){if(r.isString(L)){var M=new l;M.parse(L,!1,!0),L=M}for(var D=new l,$=Object.keys(this),Q=0;Q<$.length;Q++){var R=$[Q];D[R]=this[R]}if(D.hash=L.hash,L.href==="")return D.href=D.format(),D;if(L.slashes&&!L.protocol){for(var T=Object.keys(L),P=0;P<T.length;P++){var O=T[P];O!=="protocol"&&(D[O]=L[O])}return x[D.protocol]&&D.hostname&&!D.pathname&&(D.path=D.pathname="/"),D.href=D.format(),D}if(L.protocol&&L.protocol!==D.protocol){if(!x[L.protocol]){for(var Y=Object.keys(L),Z=0;Z<Y.length;Z++){var at=Y[Z];D[at]=L[at]}return D.href=D.format(),D}if(D.protocol=L.protocol,L.host||E[L.protocol])D.pathname=L.pathname;else{for(var V=(L.pathname||"").split("/");V.length&&!(L.host=V.shift()););L.host||(L.host=""),L.hostname||(L.hostname=""),V[0]!==""&&V.unshift(""),V.length<2&&V.unshift(""),D.pathname=V.join("/")}if(D.search=L.search,D.query=L.query,D.host=L.host||"",D.auth=L.auth,D.hostname=L.hostname||L.host,D.port=L.port,D.pathname||D.search){var H=D.pathname||"",j=D.search||"";D.path=H+j}return D.slashes=D.slashes||L.slashes,D.href=D.format(),D}var K=D.pathname&&D.pathname.charAt(0)==="/",U=L.host||L.pathname&&L.pathname.charAt(0)==="/",tt=U||K||D.host&&L.pathname,st=tt,et=D.pathname&&D.pathname.split("/")||[],ut=(V=L.pathname&&L.pathname.split("/")||[],D.protocol&&!x[D.protocol]);if(ut&&(D.hostname="",D.port=null,D.host&&(et[0]===""?et[0]=D.host:et.unshift(D.host)),D.host="",L.protocol&&(L.hostname=null,L.port=null,L.host&&(V[0]===""?V[0]=L.host:V.unshift(L.host)),L.host=null),tt=tt&&(V[0]===""||et[0]==="")),U)D.host=L.host||L.host===""?L.host:D.host,D.hostname=L.hostname||L.hostname===""?L.hostname:D.hostname,D.search=L.search,D.query=L.query,et=V;else if(V.length)et||(et=[]),et.pop(),et=et.concat(V),D.search=L.search,D.query=L.query;else if(!r.isNullOrUndefined(L.search))return ut&&(D.hostname=D.host=et.shift(),(I=!!(D.host&&D.host.indexOf("@")>0)&&D.host.split("@"))&&(D.auth=I.shift(),D.host=D.hostname=I.shift())),D.search=L.search,D.query=L.query,r.isNull(D.pathname)&&r.isNull(D.search)||(D.path=(D.pathname?D.pathname:"")+(D.search?D.search:"")),D.href=D.format(),D;if(!et.length)return D.pathname=null,D.search?D.path="/"+D.search:D.path=null,D.href=D.format(),D;for(var ct=et.slice(-1)[0],ot=(D.host||L.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(!tt&&!st)for(;b--;b)et.unshift("..");!tt||et[0]===""||et[0]&&et[0].charAt(0)==="/"||et.unshift(""),ot&&et.join("/").substr(-1)!=="/"&&et.push("");var I,N=et[0]===""||et[0]&&et[0].charAt(0)==="/";return ut&&(D.hostname=D.host=N?"":et.length?et.shift():"",(I=!!(D.host&&D.host.indexOf("@")>0)&&D.host.split("@"))&&(D.auth=I.shift(),D.host=D.hostname=I.shift())),(tt=tt||D.host&&et.length)&&!N&&et.unshift(""),et.length?D.pathname=et.join("/"):(D.pathname=null,D.path=null),r.isNull(D.pathname)&&r.isNull(D.search)||(D.path=(D.pathname?D.pathname:"")+(D.search?D.search:"")),D.auth=L.auth||D.auth,D.slashes=D.slashes||L.slashes,D.href=D.format(),D},l.prototype.parseHost=function(){var L=this.host,M=u.exec(L);M&&((M=M[0])!==":"&&(this.port=M.substr(1)),L=L.substr(0,L.length-M.length)),L&&(this.hostname=L)}},{"./util":77,punycode:51,querystring:54}],77:[function(i,s,n){s.exports={isString:function(a){return typeof a=="string"},isObject:function(a){return typeof a=="object"&&a!==null},isNull:function(a){return a===null},isNullOrUndefined:function(a){return a==null}}},{}],78:[function(i,s,n){(function(a){(function(){function r(l){try{if(!a.localStorage)return!1}catch{return!1}var o=a.localStorage[l];return o!=null&&String(o).toLowerCase()==="true"}s.exports=function(l,o){if(r("noDeprecation"))return l;var u=!1;return function(){if(!u){if(r("throwDeprecation"))throw new Error(o);r("traceDeprecation")?console.trace(o):console.warn(o),u=!0}return l.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 a(r,l){if(r&&l)return a(r)(l);if(typeof r!="function")throw new TypeError("need wrapper function");return Object.keys(r).forEach(function(u){o[u]=r[u]}),o;function o(){for(var u=new Array(arguments.length),c=0;c<u.length;c++)u[c]=arguments[c];var f=r.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 r={},l=0;l<arguments.length;l++){var o=arguments[l];for(var u in o)a.call(o,u)&&(r[u]=o[u])}return r};var a=Object.prototype.hasOwnProperty},{}],82:[function(i,s,n){s.exports=function(a){a.prototype[Symbol.iterator]=function*(){for(let r=this.head;r;r=r.next)yield r.value}}},{}],83:[function(i,s,n){function a(c){var f=this;if(f instanceof a||(f=new a),f.tail=null,f.head=null,f.length=0,c&&typeof c.forEach=="function")c.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 r(c,f,g){var v=f===c.head?new u(g,null,f,c):new u(g,f,f.next,c);return v.next===null&&(c.tail=v),v.prev===null&&(c.head=v),c.length++,v}function l(c,f){c.tail=new u(f,c.tail,null,c),c.head||(c.head=c.tail),c.length++}function o(c,f){c.head=new u(f,null,c.head,c),c.tail||(c.tail=c.head),c.length++}function u(c,f,g,v){if(!(this instanceof u))return new u(c,f,g,v);this.list=v,this.value=c,f?(f.next=this,this.prev=f):this.prev=null,g?(g.prev=this,this.next=g):this.next=null}s.exports=a,a.Node=u,a.create=a,a.prototype.removeNode=function(c){if(c.list!==this)throw new Error("removing node which does not belong to this list");var f=c.next,g=c.prev;return f&&(f.prev=g),g&&(g.next=f),c===this.head&&(this.head=f),c===this.tail&&(this.tail=g),c.list.length--,c.next=null,c.prev=null,c.list=null,f},a.prototype.unshiftNode=function(c){if(c!==this.head){c.list&&c.list.removeNode(c);var f=this.head;c.list=this,c.next=f,f&&(f.prev=c),this.head=c,this.tail||(this.tail=c),this.length++}},a.prototype.pushNode=function(c){if(c!==this.tail){c.list&&c.list.removeNode(c);var f=this.tail;c.list=this,c.prev=f,f&&(f.next=c),this.tail=c,this.head||(this.head=c),this.length++}},a.prototype.push=function(){for(var c=0,f=arguments.length;c<f;c++)l(this,arguments[c]);return this.length},a.prototype.unshift=function(){for(var c=0,f=arguments.length;c<f;c++)o(this,arguments[c]);return this.length},a.prototype.pop=function(){if(this.tail){var c=this.tail.value;return this.tail=this.tail.prev,this.tail?this.tail.next=null:this.head=null,this.length--,c}},a.prototype.shift=function(){if(this.head){var c=this.head.value;return this.head=this.head.next,this.head?this.head.prev=null:this.tail=null,this.length--,c}},a.prototype.forEach=function(c,f){f=f||this;for(var g=this.head,v=0;g!==null;v++)c.call(f,g.value,v,this),g=g.next},a.prototype.forEachReverse=function(c,f){f=f||this;for(var g=this.tail,v=this.length-1;g!==null;v--)c.call(f,g.value,v,this),g=g.prev},a.prototype.get=function(c){for(var f=0,g=this.head;g!==null&&f<c;f++)g=g.next;if(f===c&&g!==null)return g.value},a.prototype.getReverse=function(c){for(var f=0,g=this.tail;g!==null&&f<c;f++)g=g.prev;if(f===c&&g!==null)return g.value},a.prototype.map=function(c,f){f=f||this;for(var g=new a,v=this.head;v!==null;)g.push(c.call(f,v.value,this)),v=v.next;return g},a.prototype.mapReverse=function(c,f){f=f||this;for(var g=new a,v=this.tail;v!==null;)g.push(c.call(f,v.value,this)),v=v.prev;return g},a.prototype.reduce=function(c,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=c(g,v.value,y),v=v.next;return g},a.prototype.reduceReverse=function(c,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=c(g,v.value,y),v=v.prev;return g},a.prototype.toArray=function(){for(var c=new Array(this.length),f=0,g=this.head;g!==null;f++)c[f]=g.value,g=g.next;return c},a.prototype.toArrayReverse=function(){for(var c=new Array(this.length),f=0,g=this.tail;g!==null;f++)c[f]=g.value,g=g.prev;return c},a.prototype.slice=function(c,f){(f=f||this.length)<0&&(f+=this.length),(c=c||0)<0&&(c+=this.length);var g=new a;if(f<c||f<0)return g;c<0&&(c=0),f>this.length&&(f=this.length);for(var v=0,y=this.head;y!==null&&v<c;v++)y=y.next;for(;y!==null&&v<f;v++,y=y.next)g.push(y.value);return g},a.prototype.sliceReverse=function(c,f){(f=f||this.length)<0&&(f+=this.length),(c=c||0)<0&&(c+=this.length);var g=new a;if(f<c||f<0)return g;c<0&&(c=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>c;v--,y=y.prev)g.push(y.value);return g},a.prototype.splice=function(c,f,...g){c>this.length&&(c=this.length-1),c<0&&(c=this.length+c);for(var v=0,y=this.head;y!==null&&v<c;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=r(this,y,g[v]);return w},a.prototype.reverse=function(){for(var c=this.head,f=this.tail,g=c;g!==null;g=g.prev){var v=g.prev;g.prev=g.next,g.next=v}return this.head=f,this.tail=c,this};try{i("./iterator.js")(a)}catch{}},{"./iterator.js":82}]},{},[12])(12)})})(ia);const Uf={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>'}},Je={};class pk{constructor(t,i){W(this,"parentElement");W(this,"box");W(this,"icon");W(this,"text");W(this,"closeBtn");W(this,"duration");W(this,"content");W(this,"theme");W(this,"placement");W(this,"height");W(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=Uf[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 a=0;a<document.styleSheets.length;a++)document.styleSheets[a].title==="le5le.com/message"&&(s=document.styleSheets[a]);if(!s){let a=document.createElement("style");a.type="text/css",a.title="le5le.com/message",document.head.appendChild(a),a=document.createElement("style"),a.type="text/css",document.head.appendChild(a),s=a.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(){Je[this.id]=this,this.duration&&setTimeout(()=>{this.close()},this.duration);let t=-1;Object.keys(Je).forEach(i=>{var s;((s=Je[i])==null?void 0:s.placement)===this.placement&&t++}),this.setPosition(this.placement,t),this.icon.children[0].style.fill=Uf[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(Je).forEach(t=>{var i;if(((i=Je[t])==null?void 0:i.placement)===this.placement)switch(this.placement){case"top":case"left":case"right":Je[t].box.style.top=parseInt(Je[t].box.style.top)-60+"px";break;case"bottom":Je[t].box.style.bottom=parseInt(Je[t].box.style.bottom)-60+"px";break}}),Je[this.id]=null,delete Je[this.id],this.box.remove()}}function wk(e,t){if(e.jetLinksList.length){let i=t.url;i.startsWith("/")&&(i=(location.protocol==="https:"?"wss://":"ws://")+window.location.host+i),e.jetLinksClient=new WebSocket(`${i}/${localStorage.getItem("X-Access-Token")||ga("X-Access-Token")||new URLSearchParams(location.search).get("X-Access-Token")||""}`),e.jetLinksClient.onmessage=s=>{var a;const n=JSON.parse(s.data);if(!!n.payload)if((a=n.payload)!=null&&a.properties){const r=[];for(let l in n.payload.properties)r.push({id:`${n.payload.headers.productId}#${n.payload.deviceId}#${l}`,value:n.payload.properties[l]});e.setDatas(r,{history:!1})}else n.topic.startsWith("/notifications")&&_g(e,n)},e.jetLinksClient.onopen=()=>{e.jetLinksList.forEach(s=>{e.jetLinksClient.send(JSON.stringify({type:"sub",topic:`/device${s.topic}/message/property/report`,parameter:{deviceId:s.deviceId,properties:s.properties,history:1},id:s.topic+"-"+It()}))}),t.notification&&e.jetLinksClient.send(JSON.stringify({type:"sub",topic:"/notifications",id:"notification",parameter:{}}))}}}function _g(e,t){var r,l;let i=t.payload.topicName,s=t.payload.message,n=t.payload.notifyTime,a=`<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;">${bk(n)}</div>
- </div>
- <span>${s}</span>
- </div>`;e.message({content:a,duration:0,closeBtn:!0,placement:"right",height:75}),(r=t.payload.detail)!=null&&r.alarmConfigId&&Ek(e,(l=t.payload.detail)==null?void 0:l.alarmConfigId)}globalThis.doWarning=_g;function bk(e){const t=new Date(e),i=t.getFullYear(),s=(t.getMonth()+1+"").padStart(2,"0"),n=(t.getDate()+"").padStart(2,"0"),a=(t.getHours()+"").padStart(2,"0"),r=(t.getMinutes()+"").padStart(2,"0"),l=(t.getSeconds()+"").padStart(2,"0");return i+"-"+s+"-"+n+" "+a+":"+r+":"+l}function xk(e){e.jetLinksClient&&(e.jetLinksClient.close(),e.jetLinksClient=void 0)}function _k(e,t,i){const s=[];return i.list.forEach((n,a)=>{var l,o,u;const r=n.params?e.findOne(n.params):t;s[a]={deviceId:r.deviceId,productId:r.productId,properties:{}};for(let c in n.value)if(n.value[c]===void 0||n.value[c]===""){const f=(l=r.realTimes)==null?void 0:l.find(g=>g.propertyId===c);f&&(s[a].properties[c]=r[f.key])}else if(typeof n.value[c]=="string"&&((o=n.value[c])==null?void 0:o.indexOf("${"))>-1){let f=n.value[c].match(new RegExp("(?<=\\$\\{).*?(?=\\})","g"));f!=null&&f.length&&(s[a].properties[c]=(u=r[f[0]])!=null?u:e.getDynamicParam(f[0]))}else s[a].properties[c]=n.value[c]}),s}async function kk(e,t){t.forEach(async i=>{let s=i.deviceId;if(s&&s.indexOf("${")>-1){let a=s.match(new RegExp("(?<=\\$\\{).*?(?=\\})","g"));a!=null&&a.length&&(s=e.getDynamicParam(a[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 Ek(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=await i.json();s.result.media&&kg(e,s.result.media,s.result.playTimes)}}function kg(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=kg;class Ak{constructor(t,i={}){W(this,"store");W(this,"canvas");W(this,"websocket");W(this,"mqttClient");W(this,"websockets");W(this,"mqttClients");W(this,"eventSources");W(this,"penPluginMap",new Map);W(this,"socketFn");W(this,"events",{});W(this,"map");W(this,"mapTimer");W(this,"facePen",Pn);W(this,"getWords",Hd);W(this,"calcTextLines",_a);W(this,"calcTextRect",Ri);W(this,"calcTextDrawRect",vc);W(this,"jetLinksList",[]);W(this,"jetLinksClient");W(this,"register",zd);W(this,"registerCanvasDraw",Px);W(this,"registerAnchors",Ix);W(this,"registerLineAnimateDraws",(t,i)=>{this.store.data.lineAnimateDraws[t]=i,kt.lineAnimateDraws[t]=new Function("ctx","pen","state","index",i)});W(this,"websocketTimes",0);W(this,"mqttTimes",0);W(this,"httpTimer");W(this,"httpTimerList",[]);W(this,"updateTimer");W(this,"updateTimerList",[]);W(this,"sqlTimerList",[]);W(this,"iotMqttClient");W(this,"iotTimer");W(this,"iotWebsocketClient");W(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"&&(nk(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&&Hf(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&&Hf(i.pen),i.pen?this.store.data.locked&&!i.pen.disabled&&this.doEvent(i.pen,t):this.store.data.locked&&i&&!i.disabled&&this.doEvent(i,t);break}this.doMessageEvent(t,i)});W(this,"doEvent",(t,i)=>{var a,r,l,o,u,c,f,g,v,y;if(!t)return;let s=!1,n=[];if((a=t.events)==null||a.forEach((w,m)=>{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(m)}}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:L,value:M}=w.where;if(x)E=x(t,{meta2d:this});else if(C){try{w.where.fn=new Function("pen","context",C)}catch(D){console.error("Error: make function:",D)}w.where.fn&&(E=w.where.fn(t,{meta2d:this}))}else{let D=t[L];switch(["x","y","width","height"].includes(L)&&(D=this.getPenRect(t)[L]),S){case">":E=D>+M;break;case">=":E=D>=+M;break;case"<":E=D<+M;break;case"<=":E=D<=+M;break;case"=":case"==":E=D==M;break;case"!=":E=D!=M;break;case"[)":E=fn(+D,M);break;case"![)":E=!fn(+D,M);break;case"[]":E=dn(D,M);break;case"![]":E=!dn(D,M);break}}}E&&n.push(m)}}),s?(r=t.events)==null||r.forEach((w,m)=>{n.includes(m)&&this.events[w.action](t,w)}):(l=t.events)==null||l.forEach(async(w,m)=>{if(n.includes(m)){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"){(o=t.realTimes)==null||o.forEach(m=>{var E,x;let _=[];(E=m.triggers)==null||E.forEach((C,S)=>{var M;let L=!1;(M=C.conditions)!=null&&M.length?C.conditionType==="and"?L=C.conditions.every(D=>this.judgeCondition(t,m.key,D)):C.conditionType==="or"&&(L=C.conditions.some(D=>this.judgeCondition(t,m.key,D))):L=!0,L&&_.push(S)}),(x=m.triggers)==null||x.forEach((C,S)=>{var L;_.includes(S)&&((L=C.actions)==null||L.forEach(M=>{if(M.timeout){let D=setTimeout(()=>{this.events[M.action]&&(this.events[M.action](t,M),clearTimeout(D),D=null)},M.timeout)}else this.events[M.action](t,M)}))})});let w=[];if((u=this.store.globalTriggers[t.id])==null||u.forEach((m,_)=>{var x;let E=!1;(x=m.conditions)!=null&&x.length?m.conditionType==="and"?E=m.conditions.every(C=>this.judgeCondition(this.store.pens[C.source],C.key,C)):m.conditionType==="or"&&(E=m.conditions.some(C=>this.judgeCondition(this.store.pens[C.source],C.key,C))):E=!0,E&&w.push(_)}),(c=this.store.globalTriggers[t.id])==null||c.forEach((m,_)=>{var E;w.includes(_)&&((E=m.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 m of t.triggers)if((g=m.status)!=null&&g.length)for(let _ of m.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)});W(this,"doDataEvent",t=>{var n,a,r;if(!((n=this.store.data.dataEvents)!=null&&n.length))return;const i=t.reduce((l,{dataId:o,id:u,value:c})=>(l[u||o]=c,l),{});let s=[];(a=this.store.data.dataEvents)==null||a.forEach((l,o)=>{let u=!1;l.conditions&&l.conditions.length?l.conditionType==="and"?u=l.conditions.every(c=>this.dataJudegeCondition(i,c.key,c)):l.conditionType==="or"&&(u=l.conditions.some(c=>this.dataJudegeCondition(i,c.key,c))):u=!0,u&&s.push(o)}),(r=this.store.data.dataEvents)==null||r.forEach((l,o)=>{var u;s.includes(o)&&((u=l.actions)==null||u.forEach(c=>{this.events[c.action](i,c)}))})});W(this,"renderPenRaw",jr);W(this,"setElemPosition",Re);W(this,"setLifeCycleFunc",O_);this.store=Fx(It()),this.setOptions(i),this.setDatabyOptions(i),this.init(t),this.register(vk()),this.registerCanvasDraw({cube:v2}),this.registerAnchors(yk()),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 pg(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(l=>s.test(l)))return;const a={},r=[];for(let l=0;l<i.length;l++){const u=i[l].split(":"),c=u[0].trim(),f=u[1].trim();r.push([c,f].join(":")),a[c]=f}ta.addTheme(t,r),this.store.theme[t]=a}setTheme(t){if(this.store.data.theme=t,this.setBackgroundColor(this.store.theme[t].background),this.canvas.parentElement.style.background=this.store.theme[t].parentBackground,this.setOptions({ruleColor:this.store.theme[t].ruleColor,ruleOptions:this.store.theme[t].ruleOptions}),!(this.store.options.themeOnlyCanvas||this.store.data.themeOnlyCanvas)){this.store.data.color=this.store.theme[t].color,ta.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:a,gridColor:r,gridSize:l,fromArrow:o,toArrow:u,rule:c,ruleColor:f,textColor:g,x:v=0,y=0}=t;this.setRule({rule:c,ruleColor:f}),this.setGrid({grid:a,gridColor:r,gridSize:l}),this.store.data=Object.assign(this.store.data,{textColor:g,color:i,activeColor:s,activeBackground:n,fromArrow:o,toArrow:u,x:v,y})}init(t){typeof t=="string"?this.canvas=new Nf(this,document.getElementById(t),this.store):this.canvas=new Nf(this,t,this.store),this.canvas.initGlobalStyle(),this.resize(),this.canvas.listen(),ta.createThemeSheet(this.store.data.theme,this.store.id)}initEventFns(){this.events[he.Link]=(t,i)=>{var s,n;if(window&&i.value&&typeof i.value=="string"){let a=i.value;if(a.includes("${")){let r=(s=a.match(/\$\{([^}]+)\}/g))==null?void 0:s.map(l=>l.slice(2,-1));r&&(r==null||r.forEach(l=>{a=a.replace(`\${${l}}`,t[l]||this.getDynamicParam(l))}))}window.open(a,(n=i.params)!=null?n:"_blank");return}console.warn("[meta2d] Link param is not a string")},this.events[he.SetProps]=(t,i)=>{var n,a,r;const s=i.value;if(s&&typeof s=="object"){const l=i.params?this.find(i.params):this.find(t.id),o={};for(let u in s)if((n=s[u])!=null&&n.id)o[u]=(a=this.store.pens[s[u].id])==null?void 0:a[s[u].key];else if(typeof s[u]=="string"&&s[u].includes("${")){let c=s[u],f=(r=c.match(/\$\{([^}]+)\}/g))==null?void 0:r.map(g=>g.slice(2,-1));f&&f.forEach(g=>{c=c.replace(`\${${g}}`,t[g]||this.getDynamicParam(g))}),o[u]=c}else o[u]=s[u];l.forEach(u=>{o.hasOwnProperty("visible")&&u.visible!==o.visible&&this.setVisible(u,o.visible),this.setValue({id:u.id,...o},{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 a=i.value;i.fn=new Function("pen","params","context",a)}catch(a){console.error("[meta2d]: Error on make a function:",a)}(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 a in s)(s[a]===void 0||s[a]==="")&&(s[a]=n[a]);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 a=[];for(let r in s){let l={dataId:r,value:s[r]};if(!l.value){let o=n.form.find(u=>u.dataIds&&u.dataIds.dataId===l.dataId);o&&(l.value=n[o.key])}a.push(l)}this.doSendDataEvent(a,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 r=(s=i.params.match(/\$\{([^}]+)\}/g))==null?void 0:s.map(l=>l.slice(2,-1));r&&(r==null||r.forEach(l=>{n=n.replace(`\${${l}}`,t[l]||this.getDynamicParam(l))}))}Object.keys(i.extend).forEach(r=>{["x","y","width","height"].includes(r)||(n.indexOf("?")!==-1?n+=`&${r}=${i.extend[r]}`:n+=`?${r}=${i.extend[r]}`)});let a=this.getEventData(i.list,t);Object.keys(a).length&&(a=null),this.canvas.dialog.show(i.value,n,i.extend,a)}},this.events[he.SendData]=(t,i)=>{var n,a,r,l,o;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((a=i.list)!=null&&a.length){if(i.network&&i.network.protocol==="ADIIOT"){const c=_k(this,t,i);c.length&&kk(this,c);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 c in s)if(s[c]===void 0||s[c]==="")s[c]=u[c];else if(typeof s[c]=="string"&&((r=s[c])==null?void 0:r.indexOf("${"))>-1){let f=(l=s[c].match(/\$\{([^}]+)\}/g))==null?void 0:l.map(g=>g.slice(2,-1));f!=null&&f.length&&(s[c]=(o=u[f[0]])!=null?o: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=bn(s.iframe.split("?")[1]);const a=this.getEventData(i.list,s);s.calculative.singleton.div.children[0].contentWindow.postMessage(JSON.stringify({name:i.value,id:n.id,data:a}),"*")},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=>{var n;if(s.prop)if(s.id&&s.id!=="\u56FA\u5B9A\u503C"){const a=this.findOne(s.id);i[s.prop]=a[s.key]}else if(typeof s.value=="string"&&s.value.includes("${")){let a=s.value,r=(n=a.match(/\$\{([^}]+)\}/g))==null?void 0:n.map(l=>l.slice(2,-1));r&&r.forEach(l=>{a=a.replace(`\${${l}}`,this.getDynamicParam(l))}),i[s.prop]=a}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 r,l,o;const a=n.params?this.findOne(n.params):i;for(let u in n.value)if(n.value[u]===void 0||n.value[u]==="")s[u]=a[u];else if(typeof n.value[u]=="string"&&((r=n.value[u])==null?void 0:r.indexOf("${"))>-1){let c=(l=n.value[u].match(/\$\{([^}]+)\}/g))==null?void 0:l.map(f=>f.slice(2,-1));c!=null&&c.length&&(s[u]=(o=a[c[0]])!=null?o:this.getDynamicParam(c[0]))}else s[u]=n.value[u]}),Object.keys(s).length?s:{}}message(t){new pk(this.canvas.parentElement,t).init()}closeAll(){for(let t in Je)Je[t].close()}async navigatorTo(t){var n;if(!t)return;if((n=bn())==null?void 0:n.id){const a=new URL(window.location);a.searchParams.set("id",t),history.pushState({},"",a)}const s=await $d(this.store,t);s&&(this.open(s),this.lock(1),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 a,r,l,o,u,c;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/${(a=this.store.data.iot)==null?void 0:a.token}`,JSON.stringify(t));return}if(!!n.url){if(n.protocol==="http"){if(typeof n.headers=="object"){let y=JSON.stringify(n.headers),w=(r=y.match(/\$\{([^}]+)\}/g))==null?void 0:r.map(m=>m.slice(2,-1));if(w!=null&&w.length)for(let m=0;m<w.length;m++)y=y.replace(`\${${w[m]}}`,this.getDynamicParam(w[m]));n.headers=JSON.parse(y)}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=(l=g.match(/\$\{([^}]+)\}/g))==null?void 0:l.map(w=>w.slice(2,-1));y&&y.forEach(w=>{g=g.replace(`\${${w}}`,ms(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)}(o=s.fn)==null||o.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=ia.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=(c=this.websockets)==null?void 0:c.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 l,o,u,c;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 a=(i==null?void 0:i.width)||((l=this.store.data)==null?void 0:l.width)||((o=this.store.options)==null?void 0:o.width),r=(i==null?void 0:i.height)||((u=this.store.data)==null?void 0:u.height)||((c=this.store.options)==null?void 0:c.height);if(a&&r?(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,a&&r&&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.initBindDatas(),this.initBinds(),this.doInitFn(),this.loadLineAnimateDraws(),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)jx(s,()=>{this.render()});this.canvas.autoPolylineFlag=!1,this.store.emitter.emit("opened"),this.canvas.scroll&&this.canvas.scroll.isShow&&this.canvas.scroll.init()}dirtyData(t){const i=this.store.data.pens,s=this.store.data.width||this.store.options.width,n=this.store.data.height||this.store.options.height,a=[];for(let r=i.length-1;r>=0;r--){let l=i[r];if(l.parentId){const o=this.store.pens[l.parentId];(l.x>10||l.y>10||l.width>10||l.height>10||!o.children||!o.children.includes(l.id))&&a.push(l)}if(s&&n){let o=this.getPenRect(l);(o.x<-10||o.y<-10||o.x+o.width>s||o.y+o.height>n)&&a.push(l)}}return(!s||!n)&&M_(i).forEach(l=>{a.filter(u=>u.id===l.id).length||a.push(l)}),t&&this.active(a),a}clearDirtyData(){let t=this.dirtyData();this.delete(t,!0)}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,kt.path2dDraws[s.name]&&this.store.path2dMap.set(s,kt.path2dDraws[s.name](s)),s.type&&this.store.path2dMap.set(s,kt.path2dDraws[s.name](s)),s.image&&(s.calculative.imageDrawed=!1,this.canvas.loadImage(s))}),this.render())}loadLineAnimateDraws(){kt.lineAnimateDraws={},Object.entries(this.store.data.lineAnimateDraws).forEach(([t,i])=>{kt.lineAnimateDraws[t]=new Function("ctx","pen","state","index",i)})}statistics(){const t=this.store.data.pens.length,i=this.store.data.pens.filter(l=>l.image).length,s=this.store.data.pens.filter(l=>l.image&&l.calculative.inView).length,n=this.store.data.pens.filter(l=>l.name.endsWith("Dom")||Od.includes(l.name)||this.store.options.domShapes.includes(l.name)||l.externElement).length,a=this.store.animates.size;let r=0;return Object.keys(this.store.bind).forEach(l=>{r+=this.store.bind[l].length}),Object.keys(this.store.bindDatas).forEach(l=>{r+=this.store.bindDatas[l].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:a,\u6570\u636E\u70B9\u6570\u91CF:r}}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(a=>{this.store.bindDatas[a.dataId]||(this.store.bindDatas[a.dataId]=[]),this.store.bindDatas[a.dataId].push({id:t.id,formItem:s})})})})}initBinds(){this.jetLinksList=[],this.store.bind={};const t=[],i=[];this.store.data.pens.forEach(s=>{var n,a;(n=s.realTimes)==null||n.forEach(r=>{if(r.bind&&r.bind.id){let l=r.productId||s.productId,o=r.deviceId||s.deviceId,u=r.propertyId,c=!1;if(l&&l.indexOf("${")>-1){let f=l.match(new RegExp("(?<=\\$\\{).*?(?=\\})","g"));f!=null&&f.length&&(l=this.getDynamicParam(f[0])||l),c=!0}if(o&&o.indexOf("${")>-1){let f=o.match(new RegExp("(?<=\\$\\{).*?(?=\\})","g"));f!=null&&f.length&&(o=this.getDynamicParam(f[0])||o),c=!0}if(u&&u.indexOf("${")>-1){let f=u.match(new RegExp("(?<=\\$\\{).*?(?=\\})","g"));f!=null&&f.length&&(u=this.getDynamicParam(f[0])||u),c=!0}if(c&&r.bind&&(r.bind.id=l+"#"+o+"#"+u),this.store.bind[r.bind.id]||(this.store.bind[r.bind.id]=[]),this.store.bind[r.bind.id].push({id:s.id,key:r.key}),l&&o&&u){const f=this.jetLinksList.findIndex(g=>g.topic.startsWith(`/${l}/${o}`));f>-1?this.jetLinksList[f].properties.includes(r.propertyId)||this.jetLinksList[f].properties.push(r.propertyId):this.jetLinksList.push({topic:`/${l}/${o}`,deviceId:o,properties:[r.propertyId]})}if(r.bind.class==="iot"){let f=r.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:r.bind.token}),i.findIndex(y=>y.key===r.bind.id)===-1&&i.push({key:r.bind.id,label:r.bind.label})}else if(r.bind.class==="sql"){let f=r.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)}}}}),(a=s.events)==null||a.forEach(r=>{var o;const l=(o=r.actions)==null?void 0:o.filter(u=>u.action===he.SendData);l==null||l.forEach(u=>{var c;(c=u.data)==null||c.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=bn(),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&&wg(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&&Re(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=$t(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);Nx(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}updateLineAnimateDraws(t,i){!i||(delete this.store.data.lineAnimateDraws[t],delete kt.lineAnimateDraws[t],i!==-1&&this.registerLineAnimateDraws(i.name||t,i.code))}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(a=>a.autoPlay)!==-1),s.length&&(s.forEach(n=>{var a,r;if(n.calculative.pause){const l=Date.now()-n.calculative.pause;n.calculative.pause=void 0,n.calculative.frameStart+=l,n.calculative.frameEnd+=l}else{let l=-1;if(i!==void 0&&n.animations){if(typeof i=="string"){if(l=n.animations.findIndex(o=>o.name===i),l===-1)return}else if(typeof i=="number")if(n.animations.length>i)l=i;else return}else i===void 0&&(l=(a=n.animations)==null?void 0:a.findIndex(o=>o.autoPlay),l===-1&&((r=n.animations)==null?void 0:r.length)&&(l=0));if(l!==-1&&l!==void 0){const o=ht(n.animations[l]);o.animateName=o.name,delete o.name,o.currentAnimation=l,!n.type&&o.frames&&(o.showDuration=this.calcAnimateDuration(o)),this.setValue({id:n.id,...o},{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.cycleStart=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,a;(n=s.calculative.media)==null||n.play(),(a=s.onStartVideo)==null||a.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,a;(n=s.calculative.media)==null||n.pause(),(a=s.onPauseVideo)==null||a.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 a=hi(t);let r={id:It(),name:"combine",...a,children:[],showChild:i};this.canvas.makePen(r);const l=ht(r);let o=1/0;return t.forEach(u=>{var g;const c=this.store.data.pens.findIndex(v=>v.id===u.id);if(c<o&&(o=c),u===r||u.parentId===r.id||u.id===r.id)return;r.children.push(u.id),u.parentId=r.id;const f=fs(u.calculative.worldRect,a);Object.assign(u,f),u.locked=(g=u.lockedOnCombine)!=null?g:Ot.None,u.locked=u.interaction||Cl.includes(u.name)?0:u.locked}),this.store.data.pens.splice(o,0,r),this.store.data.pens.pop(),s&&this.canvas.active([r]),this.pushHistory({type:bt.Add,pens:[l],step:3}),this.pushHistory({type:bt.Update,initPens:[l],pens:[r],step:3}),this.pushHistory({type:bt.Update,initPens:n,pens:t,step:3}),i!=null&&(t.forEach(u=>{Yi(u,!0)}),this.initImageCanvas([r])),this.store.emitter.emit("combine",[r]),this.render(),r}uncombine(t){if(!t&&this.store.active&&(t=this.store.active[0]),!t||!t.children)return;const i=t.children.map(a=>this.store.pens[a]);let s=ht(i);i.forEach(a=>{a.parentId=void 0,a.x=a.calculative.worldRect.x,a.y=a.calculative.worldRect.y,a.width=a.calculative.worldRect.width,a.height=a.calculative.worldRect.height,a.locked=Ot.None,a.calculative.active=void 0,a.calculative.hover=!1,this.setVisible(a,!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=Qe(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,a)=>{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=hi(t);Object.assign(s,n),Object.assign(s.calculative.worldRect,n),An(s),s.children.forEach(a=>{const r=this.store.pens[a],l=fs(r.calculative.worldRect,n);Object.assign(r,l)}),t.forEach(a=>{var r;if(a.id!==s.id){s.children.push(a.id),a.parentId=s.id;const l=fs(a.calculative.worldRect,n);Object.assign(a,l),a.locked=(r=a.lockedOnCombine)!=null?r:Ot.DisableMove,a.locked=a.interaction||Cl.includes(a.name)?0:a.locked,Yi(a,!0)}}),this.initImageCanvas(t),this.render()}else console.warn("Invalid operation!")}updateRectbyChild(t,i,s){if(re(t),Qt(t),i.calculative.worldRect=t,s.container&&Xi(t,s.calculative.worldRect,!0)){const n=fs(t,s.calculative.worldRect);Object.assign(i,n)}else{if(s.container){let n=Math.min(t.x,s.calculative.worldRect.x),a=Math.min(t.y,s.calculative.worldRect.y),r=Math.max(t.ex,s.calculative.worldRect.ex),l=Math.max(t.ey,s.calculative.worldRect.ey);s.calculative.worldRect={x:n,y:a,width:r-n,height:l-a,ex:r,ey:l},Qt(s.calculative.worldRect)}else{const n=s.children.map(a=>this.store.pens[a]);s.calculative.worldRect=hi(n)}s.parentId||Object.assign(s,s.calculative.worldRect),s.children.forEach(n=>{const a=this.store.pens[n],r=fs(a.calculative.worldRect,s.calculative.worldRect);Object.assign(a,r)}),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 ti(t,i)}getAllChildren(t){return Qe(t,this.store)}getAllFollowers(t){return yc(t,this.store)}data(){const t=ht(this.store.data),{pens:i,paths:s}=this.store.data;t.version=Nd.version,t.paths={};for(const n in s)Object.prototype.hasOwnProperty.call(s,n)&&i.find(a=>a.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=ia.exports.connect(this.store.data.mqtt,i),this.mqttClient.on("message",(a,r)=>{this.socketCallback(r.toString(),{topic:a,type:"mqtt",url:this.store.data.mqtt})}),this.mqttClient.on("error",a=>{this.store.emitter.emit("error",{type:"mqtt",error:a})}),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 a=await fetch(i,{headers:n});if(a.ok){const r=await a.text();this.socketCallback(r,{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,a=0,r=0;this.mqttClients=[],this.websockets=[],this.eventSources=[],t.forEach(async l=>{l.protocol==="mqtt"?(l.index=s,this.connectNetMqtt(l),s+=1):l.protocol==="websocket"?(l.index=a,this.connectNetWebSocket(l),a+=1):l.protocol==="http"?(l.index=n,i.push({url:l.url,interval:l.interval,headers:l.headers||void 0,method:l.method,body:l.body,enable:l.enable,index:l.index,once:l.once}),n+=1):l.protocol==="ADIIOT"?wk(this,l):l.protocol==="SSE"&&(l.index=r,this.connectSSE(l),r+=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 a=ht(i);this.store.data.cancelFirstConnect||this.requestHttp(a),this.updateTimerList[i.index]=setInterval(async()=>{this.requestHttp(a)},a.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))||t&&t.enable===!1)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=ia.exports.connect(i),this.iotMqttClient.on("message",(a,r)=>{this.socketCallback(r.toString(),{topic:`le5le-iot/properties/${s}`,type:"iot",url:i,method:"mqtt"})}),this.iotMqttClient.on("error",a=>{this.store.emitter.emit("error",{type:"mqtt",error:a})}),this.iotMqttClient.subscribe(`le5le-iot/properties/${s}`),this.iotTimer=setInterval(()=>{this.iotMqttClient&&this.iotMqttClient.publish("le5le-iot/subscribe/ping",s)},3e5)}closeIot(){if(this.iotMqttClient){const{iot:t}=this.store.data;t!=null&&t.token&&this.unsubscribeIot(t.token),this.iotMqttClient.end(),this.iotMqttClient=void 0}clearInterval(this.iotTimer),this.iotTimer=void 0}connectSqls(){const{sqls:t}=this.store.data;t&&t.length&&t.forEach(async(i,s)=>{i.enable!==!1&&(await this.doSqlCode(i),i.interval&&(i.index=s,this.sqlTimerList[s]=setInterval(async()=>{await this.doSqlCode(i)},i.interval)))})}connectSSE(t){t.enable!==!1&&(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,name:t.name,net:t})},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 n,a,r,l;if(t.enable===!1)return;t.options.clientId&&!t.options.customClientId&&(t.options.clientId=It());let i=t.url;if(i.indexOf("${")>-1){let o=(n=i.match(/\$\{([^}]+)\}/g))==null?void 0:n.map(u=>u.slice(2,-1));o&&o.forEach(u=>{i=i.replace(`\${${u}}`,this.getDynamicParam(u))})}t.times=0;let s=ht(t.options);if((s==null?void 0:s.username)&&s.username.includes("${")){let o=(a=s.username.match(/\$\{([^}]+)\}/g))==null?void 0:a.map(u=>u.slice(2,-1));o&&o.forEach(u=>{s.username=s.username.replace(`\${${u}}`,this.getDynamicParam(u))})}if((s==null?void 0:s.password)&&s.password.includes("${")){let o=(r=s.password.match(/\$\{([^}]+)\}/g))==null?void 0:r.map(u=>u.slice(2,-1));o&&o.forEach(u=>{s.password=s.password.replace(`\${${u}}`,this.getDynamicParam(u))})}if(this.mqttClients[t.index]=ia.exports.connect(i,s),this.mqttClients[t.index].on("message",(o,u)=>{this.socketCallback(u.toString(),{topic:o,type:"mqtt",url:t.url,name:t.name,net:t})}),this.mqttClients[t.index].on("error",o=>{this.store.emitter.emit("error",{type:"mqtt",error:o})}),this.mqttClients[t.index].on("close",()=>{var o;this.store.options.reconnetTimes&&(t.times++,t.times>=this.store.options.reconnetTimes&&(t.times=0,this.mqttClients&&((o=this.mqttClients[t.index])==null||o.end())))}),t.topics){let o=t.topics;if(o.indexOf("${")>-1){let u=(l=o.match(/\$\{([^}]+)\}/g))==null?void 0:l.map(c=>c.slice(2,-1));u&&u.forEach(c=>{o=o.replace(`\${${c}}`,this.getDynamicParam(c))})}this.mqttClients[t.index].subscribe(o.split(","))}}connectNetWebSocket(t){var s,n;if(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),t.enable===!1)return;let i=t.url;if(i.indexOf("${")>-1){let a=(n=i.match(/\$\{([^}]+)\}/g))==null?void 0:n.map(r=>r.slice(2,-1));a&&a.forEach(r=>{i=i.replace(`\${${r}}`,this.getDynamicParam(r))})}this.websockets[t.index]=new WebSocket(i,t.protocols||void 0),this.websockets[t.index].onmessage=a=>{this.socketCallback(a.data,{type:"websocket",url:t.url,name:t.name,net:t})},this.websockets[t.index].onerror=a=>{this.store.emitter.emit("error",{type:"websocket",error:a})},this.websockets[t.index].onclose=()=>{var a;if(this.store.options.reconnetTimes&&(t.times++,t.times>=this.store.options.reconnetTimes)){t.times=0,this.websockets[t.index].onclose=void 0,(a=this.websockets[t.index])==null||a.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 ${Ir()}`}});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 ${Ir()}`},body:JSON.stringify({devices:t,type:i})});if(s.ok){const n=await s.text();return JSON.parse(n).token}}async unsubscribeIot(t){return await fetch("/api/iot/unsubscribe/properties",{method:"POST",headers:{Authorization:`Bearer ${Ir()}`},body:JSON.stringify({token:t})})}async doSqlCode(t){var a;const i=t.method||"get";let s=t.sql;i==="list"&&(t.dbType==="oracle"?s.includes("OFFSET")||(s+=` OFFSET ${(t.current||1-1)*(t.pageSize||20)} ROWS FETCH NEXT ${t.pageSize||20} ROWS ONLY`):s.includes("LIMIT")||(s+=` LIMIT ${t.pageSize||20}`+(t.current>1?" OFFSET "+(t.current-1)*(t.pageSize||20):"")));const n=await fetch(`/api/iot/data/sql/${i}`,{method:"POST",headers:{Authorization:`Bearer ${ga("token")||localStorage.getItem("token")||new URLSearchParams(location.search).get("token")||""}`},body:JSON.stringify({dbId:t.dbId||t.dbid,sql:s})});if(n.ok){let r=await n.text();if(r){const l=[];if(r=JSON.parse(r),r.error){this.store.emitter.emit("error",{type:"sql",error:r.error});return}(a=t.keys)==null||a.forEach(o=>{l.push({id:t.bindId+"#"+o,value:ms(r,o.split("#").join("."))})}),l.push({id:t.bindId,value:r}),this.socketCallback(JSON.stringify(l),{type:"sql",url:`/api/iot/data/sql/${i}`,method:i})}}}randomString(t){t=t||32;let i="ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678",s=i.length,n="";for(let a=0;a<t;a++)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,a,r=t.mock.split("-");if(t.mock.charAt(0)==="-"?r.length===4?(s=-parseFloat(r[3]),n=-parseFloat(r[1]),a=r[3]):(s=parseFloat(r[2]),n=-parseFloat(r[1]),a=r[2]):(s=parseFloat(r[1]),n=parseFloat(r[0]),a=r[1]),(a+"").indexOf(".")!==-1){let l=(a+"").split(".")[1].length;i=(Math.random()*(s-n)+n).toFixed(l)}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,a=t.mock.split("-");t.mock.charAt(0)==="-"?a.length===4?(s=-parseFloat(a[3]),n=-parseFloat(a[1])):(s=parseFloat(a[2]),n=-parseFloat(a[1])):(s=parseInt(a[1]),n=parseInt(a[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 a=this.mockValue(n);a!==void 0&&t.push({id:n.id,value:a})}),t.length&&this.setDatas(t,{render:!0,doEvent:!0,history:!1})}networkMock(){if(this.store.data.networks&&this.store.data.networks.length){let t=[];this.store.data.networks.forEach(i=>{var s;i.enable===!1&&((s=i.children)==null||s.forEach(n=>{let a=ht(n);a.enableMock=!0;let r=this.mockValue(a);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.networkMock(),this.render()},this.store.data.networkInterval||1e3)):this.stopDataMock()}stopDataMock(){clearInterval(this.updateTimer),this.updateTimer=void 0}penMock(t){var i;if(t.realTimes){let s={};if(t.realTimes.forEach(n=>{let a=this.mockValue(n);a!==void 0&&(s[n.key]=a)}),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 bn()[t]||localStorage[t]||ga(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=>{i.enable!==!1&&this.requestHttp(i)}),t.forEach((i,s)=>{i.times=0,i.interval!==0&&i.enable!==!1&&(i.once?setTimeout(async()=>{this.requestHttp(i)},i.interval||1e3):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,a;let i=ht(t);if(i.url){if(i.url.indexOf("${")>-1){let l=(s=i.url.match(/\$\{([^}]+)\}/g))==null?void 0:s.map(o=>o.slice(2,-1));l&&l.forEach(o=>{i.url=i.url.replace(`\${${o}}`,this.getDynamicParam(o))})}if(typeof i.headers=="object"){let l=JSON.stringify(i.headers),o=(n=l.match(/\$\{([^}]+)\}/g))==null?void 0:n.map(u=>u.slice(2,-1));if(o!=null&&o.length)for(let u=0;u<o.length;u++)l=l.replace(`\${${o[u]}}`,this.getDynamicParam(o[u]));i.headers=JSON.parse(l)}if(typeof i.body=="object"){let l=JSON.stringify(i.body),o=(a=l.match(/\$\{([^}]+)\}/g))==null?void 0:a.map(u=>u.slice(2,-1));if(o!=null&&o.length)for(let u=0;u<o.length;u++)l=l.replace(`\${${o[u]}}`,this.getDynamicParam(o[u]));i.body=JSON.parse(l)}const r=await fetch(i.url,{headers:i.headers,method:i.method,body:i.method==="GET"?void 0:JSON.stringify(i.body)});if(r.ok){const l=await r.text(),o=this.store.data.networks.filter(u=>u.protocol==="http")[i.index];this.socketCallback(l,{type:"http",url:i.url,name:i.name,net:o})}else t.times++,this.store.emitter.emit("error",{type:"http",error:r})}}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.closeIot(),xk(this),this.closeSSE()}socketCallback(t,i){var a,r;this.store.emitter.emit("socket",{message:t,context:i});let s=t;if((a=i.net)!=null&&a.socketCbJs&&((r=i.net)!=null&&r.socketFn||(i.net.socketFn=new Function("e","context",i.net.socketCbJs)),i.net.socketFn)){if(s=i.net.socketFn(t,{meta2d:this,type:i.type,topic:i.topic,url:i.url,method:i.method}),!s)return;s&&s!==!0&&(t=s)}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(l){console.warn("Invalid socket data:",n,l)}else return;!n||(Array.isArray(n)||(n=[n]),n.length&&(n[0].dataId?this.setDatas(n):n.forEach(l=>{this.setValue(l)})))}setDatas(t,{render:i=!0,doEvent:s=!0,history:n}={}){const a=new Map;t.forEach(o=>{var u,c;(u=this.store.bindDatas[o.dataId])==null||u.forEach(f=>{const g=this.store.pens[f.id];if(!g)return;let v=a.get(g);if(!g.noOnBinds&&typeof g.onBinds=="function"){if(v)return;a.set(g,g.onBinds(g,t,f.formItem));return}v?v[f.formItem.key]=o.value:(v={id:f.id,[f.formItem.key]:o.value},a.set(g,v))}),(c=this.store.bind[o.id||o.dataId])==null||c.forEach(f=>{const g=this.store.pens[f.id];if(!g)return;let v=a.get(g);v?v[f.key]=o.value:(v={id:f.id,[f.key]:o.value},a.set(g,v))})}),this.store.data.locked&&this.doDataEvent(t);let r,l;n&&(r=[]),a.forEach((o,u)=>{this.setValue(o,{render:!1,doEvent:s,history:!1}),n&&(r.push(ht(u,!0)),l.push(u))}),i&&this.render(),n&&this.pushHistory({type:bt.Update,initPens:r,pens:l})}setValue(t,{render:i=!0,doEvent:s=!0,history:n}={}){let a=[];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 l=this.store.pens[t.id];if(l)a=[l];else{let o=this.store.bind[t.id];if(o&&o.length){a=[],this.setDatas([t],{render:i,doEvent:s,history:n});return}}}else if(t.dataId){a=[],this.setDatas([t],{render:i,doEvent:s,history:n});return}else if(t.tag)a=this.find(t.tag);else{let l=[];for(let o in t)l.push({dataId:o,id:o,value:t[o]});l.length&&this.setDatas(l,{render:i,doEvent:s,history:n});return}n=n&&!this.store.data.locked;let r;if(n&&(r=ht(a)),a.forEach(l=>{var u;const o=l.onBeforeValue?l.onBeforeValue(l,t):t;t.frames&&(this.stopAnimate([l]),t.showDuration||(t.showDuration=t.frames.reduce((c,f)=>c+f.duration,0))),xc(l,o),this.canvas.updateValue(l,o),(u=l.onValue)==null||u.call(l,l)}),!this.store.data.locked&&this.store.active.length&&!this.canvas.movingPens&&this.canvas.calcActiveRect(),n){let l=ht(a);this.pushHistory({type:bt.Update,initPens:r,pens:l})}s&&a.forEach(l=>{this.store.emitter.emit("valueUpdate",l)}),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(a=>this.judgeCondition(s.pen,a.key,a)):s.event.conditionType==="or"&&(n=s.event.conditions.some(a=>this.judgeCondition(s.pen,a.key,a))):n=!0,n&&s.event.actions.forEach(a=>{this.events[a.action](s.pen,a,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:a,fnJs:r,fn:l,operator:o,valueType:u}=s;let c=!1;if(n==="fn"){if(l)c=l(t,{meta2d:this});else if(r){try{s.fn=new Function("data","context",r)}catch(f){console.error("Error: make function:",f)}s.fn&&(c=s.fn(t,{meta2d:this}))}}else{let f=s.value;u==="prop"&&(f=t[s.value]);let g=t[i];switch(o){case">":c=g>+f;break;case">=":c=g>=+f;break;case"<":c=g<+f;break;case"<=":c=g<=+f;break;case"=":case"==":c=g==f;break;case"!=":c=g!=f;break;case"[)":c=fn(+g,f);break;case"![)":c=!fn(+g,f);break;case"[]":c=dn(g,f);break;case"![]":c=!dn(g,f);break}}return c}judgeCondition(t,i,s){const{type:n,target:a,fnJs:r,fn:l,operator:o,valueType:u}=s;let c=!1;if(n==="fn"){if(l)c=l(t,{meta2d:this});else if(r){try{s.fn=new Function("pen","context",r)}catch(f){console.error("Error: make function:",f)}s.fn&&(c=s.fn(t,{meta2d:this}))}}else{let f=s.value;u==="prop"&&(f=this.store.pens[a][s.value]);let g=ms(t,i);switch(["x","y","width","height"].includes(i)&&(g=this.getPenRect(t)[i]),o){case">":c=g>+f;break;case">=":c=g>=+f;break;case"<":c=g<+f;break;case"<=":c=g<=+f;break;case"=":case"==":c=g==f;break;case"!=":c=g!=f;break;case"[)":c=fn(+g,f);break;case"![)":c=!fn(+g,f);break;case"[]":c=dn(g,f);break;case"![]":c=!dn(g,f);break}}return c}pushChildren(t,i){const s=[ht(t,!0)],n=[];t.children||(t.children=[]);const a=[];i.forEach(l=>{var c;let o=ht(l,!0);if((!l.id||!this.store.pens[l.id])&&(this.canvas.makePen(l),o=null),l.parentId){const f=this.store.pens[l.parentId],g=f.children.findIndex(v=>v===l.id);s.push(ht(f,!0)),f.children.splice(g,1),a.push(ht(f,!0))}t.children.push(l.id),l.parentId=t.id;const u=fs(l.calculative.worldRect,t.calculative.worldRect);Object.assign(l,u),l.locked=(c=l.lockedOnCombine)!=null?c:Ot.DisableMove,l.locked=l.interaction||Cl.includes(l.name)?0:l.locked,o?(s.push(o),a.push(ht(l,!0))):n.push(ht(l,!0))}),a.push(ht(t,!0));let r=1;n.length&&(r=2,this.pushHistory({type:bt.Add,pens:n,step:r})),this.pushHistory({type:bt.Update,initPens:s,pens:a,step:r})}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 a of this.store.data.pens)(a.calculative.img||["iframe"].includes(a.name))&&((n=a.onRenderPenRaw)==null||n.call(a,a));setTimeout(()=>{const a=document.createElement("a");a.setAttribute("download",(t||this.store.data.name||"le5le.meta2d")+".png"),a.setAttribute("href",this.toPng(i,void 0,!0,s));const r=document.createEvent("MouseEvents");r.initEvent("click",!0,!0),a.dispatchEvent(r)},1e3)}downloadSvg(t){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 i=!1;const s=this.store.data.width||this.store.options.width,n=this.store.data.height||this.store.options.height;s&&n&&!this.store.data.component&&(i=!0);const a=this.getRect();i&&(a.x=this.store.data.origin.x,a.y=this.store.data.origin.y,a.width=s*this.store.data.scale,a.height=n*this.store.data.scale),a.x-=10,a.y-=10;const r=new window.C2S(a.width+20,a.height+20);r.textBaseline="middle",r.strokeStyle=this.store.styles.color;const l=this.store.options.downloadBgTransparent?void 0:this.store.data.background||this.store.styles.background;l&&i&&(r.save(),r.fillStyle=l,r.fillRect(0,0,a.width,a.height),r.restore()),this.store.bkImg&&i&&r.drawImage(this.store.bkImg,0,0,a.width,a.height),l&&!i&&(r.save(),r.fillStyle=l,r.fillRect(0,0,a.width+20,a.height+20),r.restore());for(const y of this.store.data.pens)y.visible==!1||!Vr(y,this.store)||jr(r,y,a,!0);let o=r.getSerializedSvg();t!=null&&t.length&&(o=o.replace("<defs/>",`<defs>
- <style type="text/css">
- ${t.join(`
- `)}
- </style>
- {{bk}}
- </defs>
- {{bkRect}}`)),l?(o=o.replace("{{bk}}",""),o=o.replace("{{bkRect}}",`<rect x="0" y="0" width="100%" height="100%" fill="${l}"></rect>`)):(o=o.replace("{{bk}}",""),o=o.replace("{{bkRect}}","")),o=o.replace(/--le5le--/g,"&#x");const u=window.URL,c=new Blob([o]),f=u.createObjectURL(c),g=document.createElement("a");g.setAttribute("download",`${this.store.data.name||"le5le.meta2d"}.svg`),g.setAttribute("href",f);const v=document.createEvent("MouseEvents");v.initEvent("click",!0,!0),g.dispatchEvent(v)}getRect(t=this.store.data.pens){return hi(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:a}=s;this.resize(n,a);const r=qi(i),l=this.getRect(),o=(n-r[1]-r[3])/l.width,u=(a-r[0]-r[2])/l.height;let c=o;t?c=o>u?u:o:c=o>u?o:u,(f=this.store.data.fits)!=null&&f.length&&(this.canvas.opening=!0),this.scale(c*this.store.data.scale),this.centerView(),(g=this.store.data.fits)!=null&&g.length&&this.fillView()}fillView(){var n,a;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 u=[];o.children.forEach(f=>{this.store.pens[f]&&(this.store.pens[f].locked=Ot.None,u.push(this.store.pens[f]))});let c=i/2;if(o.left&&o.right){let f=o.leftValue,g=o.rightValue;f?f=Math.abs(f)<1?f*this.canvas.width:f:f=0,g?g=Math.abs(g)<1?g*this.canvas.width:g:g=0;let v=(this.canvas.width-f-g)/(t.width-f-g);u.forEach(y=>{var w,m;y.image&&y.imageRatio&&y.calculative.worldRect.width/this.canvas.width>.1&&(y.imageRatio=!1),y.calculative.worldRect.x=t.x-i/2+f+(y.calculative.worldRect.x-t.x)*v,y.calculative.worldRect.width*=v,y.calculative.worldRect.ex=y.calculative.worldRect.x+y.calculative.worldRect.width,y.calculative.width=y.calculative.worldRect.width,y.calculative.x=y.calculative.worldRect.x,y.width=y.calculative.worldRect.width,y.x=y.calculative.worldRect.x,this.canvas.updatePenRect(y,{worldRectIsReady:!1}),y.externElement&&((w=y.onResize)==null||w.call(y,y)),(m=y.children)!=null&&m.length&&Qe(y,this.store).forEach(E=>{var x;E.externElement&&((x=E.onResize)==null||x.call(E,E))})})}else o.left?(c=-c,o.leftValue&&(c+=Math.abs(o.leftValue)<1?o.leftValue*this.canvas.width:o.leftValue),this.translatePens(u,c,0)):o.right&&(o.rightValue&&(c=c-(Math.abs(o.rightValue)<1?o.rightValue*this.canvas.width:o.rightValue)),this.translatePens(u,c,0))});const r=this.store.data.pens.filter(o=>o.name==="iframe");r==null||r.forEach(o=>{var c,f;const u=o.calculative.worldRect;if(u.width/this.store.data.scale>t.width*.8){let g=u.width;o.calculative.worldRect.x=u.x-i/2,o.calculative.worldRect.width=u.width+i,o.calculative.worldRect.ex=u.ex+i,o.operationalRect.x=o.operationalRect.x*g/o.calculative.worldRect.width,o.operationalRect.width=(o.calculative.worldRect.width-(1-o.operationalRect.width)*g)/o.calculative.worldRect.width,(c=o.onBeforeValue)==null||c.call(o,o,{operationalRect:o.operationalRect}),(f=o.onResize)==null||f.call(o,o)}});const l=this.store.data.pens.filter(o=>o.name==="video");l==null||l.forEach(o=>{var c;const u=o.calculative.worldRect;u.width/this.store.data.scale>t.width*.8&&(o.calculative.worldRect.x=u.x-i/2,o.calculative.worldRect.width=u.width+i,o.calculative.worldRect.ex=u.ex+i,(c=o.onResize)==null||c.call(o,o))})}if(Math.abs(s)>10){(a=this.store.data.fits)==null||a.forEach(o=>{let u=[];o.children.forEach(f=>{this.store.pens[f]&&(this.store.pens[f].locked=Ot.None,u.push(this.store.pens[f]))});let c=s/2;if(o.top&&o.bottom){let f=o.topValue,g=o.bottomValue;f?f=Math.abs(f)<1?f*this.canvas.height:f:f=0,g?g=Math.abs(g)<1?g*this.canvas.height:g:g=0;let v=(this.canvas.height-f-g)/t.height;u.forEach(y=>{var w,m;y.image&&y.imageRatio&&y.calculative.worldRect.height/this.canvas.height>.1&&(y.imageRatio=!1),y.calculative.worldRect.y=t.y-s/2+f+(y.calculative.worldRect.y-t.y)*v,y.calculative.worldRect.height*=v,y.calculative.worldRect.ey=y.calculative.worldRect.y+y.calculative.worldRect.height,y.calculative.height=y.calculative.worldRect.height,y.calculative.y=y.calculative.worldRect.y,y.height=y.calculative.worldRect.height,y.y=y.calculative.worldRect.y,this.canvas.updatePenRect(y,{worldRectIsReady:!1}),y.externElement&&((w=y.onResize)==null||w.call(y,y)),(m=y.children)!=null&&m.length&&Qe(y,this.store).forEach(E=>{var x;E.externElement&&((x=E.onResize)==null||x.call(E,E))})})}else o.top?(c=-c,o.topValue&&(c+=Math.abs(o.topValue)<1?o.topValue*this.canvas.height:o.topValue),this.translatePens(u,0,c)):o.bottom&&(o.bottomValue&&(c=c-(Math.abs(o.bottomValue)<1?o.bottomValue*this.canvas.height:o.bottomValue)),this.translatePens(u,0,c))});const r=this.store.data.pens.filter(o=>o.name==="iframe");r==null||r.forEach(o=>{var c,f;const u=o.calculative.worldRect;if(u.height/this.store.data.scale>t.height*.8){let g=u.height;o.calculative.worldRect.y=u.y-s/2,o.calculative.worldRect.height=u.height+s,o.calculative.worldRect.ey=u.ey+s,o.operationalRect.y=o.operationalRect.y*g/o.calculative.worldRect.width,o.operationalRect.height=(o.calculative.worldRect.height-(1-o.operationalRect.height)*g)/o.calculative.worldRect.height,(c=o.onBeforeValue)==null||c.call(o,o,{operationalRect:o.operationalRect}),(f=o.onResize)==null||f.call(o,o)}});const l=this.store.data.pens.filter(o=>o.name==="video");l==null||l.forEach(o=>{var c;const u=o.calculative.worldRect;u.height/this.store.data.scale>t.height*.8&&(o.calculative.worldRect.y=u.y-s/2,o.calculative.worldRect.height=u.height+s,o.calculative.worldRect.ey=u.ey+s,(c=o.onResize)==null||c.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:a}=s,r=qi(i),l=this.getRect(),o=(n-r[1]-r[3])/l.width,u=(a-r[0]-r[2])/l.height;let c=o;t?c=o>u?u:o:c=o>u?o:u,this.canvas.templateScale(c*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:a}=s;this.resize(n,a);const r=qi(i),l=(this.store.data.width||this.store.options.width)*this.store.data.scale,o=(this.store.data.height||this.store.options.height)*this.store.data.scale,u=(n-r[1]-r[3])/l,c=(a-r[0]-r[2])/o;let f=u;t==="width"?f=u:t==="height"?f=c:t?f=u>c?c:u:f=u>c?u:c,(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};Qt(n);const{center:a}=n,{scale:r,origin:l,x:o,y:u}=this.store.data;this.translate((t.x-l.x)/r-a.x-o/r,(t.y-l.y)/r-a.y-u/r);const{canvas:c}=this.canvas,f=(c.scrollWidth-c.offsetWidth)/2,g=(c.scrollHeight-c.offsetHeight)/2;c.scrollTo(f,g)}scrollView(t=10,i=!1){if(!this.hasView()||!this.canvas.scroll)return;const{canvas:s}=this.canvas,{offsetWidth:n,offsetHeight:a}=s;this.resize(n,a);const r=qi(t),l=this.getRect(),o=(n-r[1]-r[3])/l.width;this.scale(o*this.store.data.scale),this.topView(r[0]),i&&this.canvas.scroll.changeMode()}screenView(t=10,i=!0){if(!this.hasView())return;const{canvas:s}=this.canvas,{offsetWidth:n,offsetHeight:a}=s;this.resize(n,a);const r=qi(t),l=this.getRect();let o=(n-r[1]-r[3])/l.width;i||(o=(a-r[0]-r[2])/l.height),this.scale(o*this.store.data.scale),this.topView(r[0])}topView(t=10){if(!this.hasView())return;const i=this.getRect(),s=this.getViewCenter(),n=this.getPenRect(i);Qt(n);const{center:a}=n,{scale:r,origin:l,x:o,y:u}=this.store.data;this.translate((s.x-l.x)/r-a.x-o/r,(t-l.y)/r-n.y-u/r);const{canvas:c}=this.canvas,f=(c.scrollWidth-c.offsetWidth)/2,g=(c.scrollHeight-c.offsetHeight)/2;c.scrollTo(f,g)}centerView(){if(!this.hasView())return;const t=this.getRect(),i=this.getViewCenter(),s=this.getPenRect(t);Qt(s);const{center:n}=s,{scale:a,origin:r,x:l,y:o}=this.store.data;this.translate((i.x-r.x)/a-n.x-l/a,(i.y-r.y)/a-n.y-o/a);const{canvas:u}=this.canvas,c=(u.scrollWidth-u.offsetWidth)/2,f=(u.scrollHeight-u.offsetHeight)/2;u.scrollTo(c,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:a,height:r}=this.getPenRect(n);for(let l=1;l<t.length;l++){const o=t[l];i==="width"?this.setValue({id:o.id,width:a},{render:!1,doEvent:!1}):i==="height"?this.setValue({id:o.id,height:r},{render:!1,doEvent:!1}):this.setValue({id:o.id,width:a,height:r},{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:a,height:r}=this.getPenRect(n);for(let l=0;l<t.length-1;l++){const o=t[l];i==="width"?this.setValue({id:o.id,width:a},{render:!1,doEvent:!1}):i==="height"?this.setValue({id:o.id,height:r},{render:!1,doEvent:!1}):this.setValue({id:o.id,width:a,height:r},{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={};Zn.forEach(a=>{n[a]=s[a]});for(let a=1;a<t.length;a++){const r=t[a];this.setValue({id:r.id,...Rl,...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={};Zn.forEach(a=>{n[a]=s[a]});for(let a=0;a<t.length-1;a++){const r=t[a];this.setValue({id:r.id,...Rl,...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];Zn.forEach(n=>{i[n]=s[n]!==void 0?s[n]:this.store.options.defaultFormat[n]||this.store.data[n]||this.store.options[n]})}else Zn.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 a=t[n];this.setValue({id:a.id,...Rl,...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);Zn.forEach(s=>{for(let n=0;n<t.length;n++){const a=t[n],{fontSize:r,lineHeight:l}=this.store.options;s==="lineWidth"?(a.lineWidth=1,a.calculative.lineWidth=1):s==="fontSize"?(a.fontSize=r,a.calculative.fontSize=r):s==="lineHeight"?(a.lineHeight=l,a.calculative.lineHeight=l):(delete a[s],delete a.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 a of i)this.alignPen(t,a,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,a=this.store.data.height||this.store.options.height;let r={x:0,y:0,width:n,height:a};const l=ht(i);if(s){const o=this.store.data.scale,u=this.getRect(i),c=(u.x-this.store.data.origin.x)/o,f=(u.y-this.store.data.origin.y)/o,g=u.width/o,v=u.height/o;let y=0,w=0;switch(t){case"left":y=-c;break;case"right":y=n-(c+g);break;case"top":w=-f;break;case"bottom":w=a-(f+v);break;case"center":y=n/2-(c+g/2);break;case"middle":w=a/2-(f+v/2);break}this.translatePens(i,y*o,w*o)}else for(const o of i)this.alignPen(t,o,r);this.initImageCanvas(i),this.initTemplateCanvas(i),this.render(),this.pushHistory({type:bt.Update,initPens:l,pens:i})}alignNodesByFirst(t,i=this.store.data.pens){const s=ht(i),n=i[0],a=this.getPenRect(n);for(let r=1;r<i.length;r++){const l=i[r];this.alignPen(t,l,a)}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],a=this.getPenRect(n);for(let r=0;r<i.length-1;r++){const l=i[r];this.alignPen(t,l,a)}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,c=-1/0,f=t==="width"?"x":"y";i.forEach(g=>{u=Math.min(u,g.calculative.worldRect[f]),c=Math.max(c,g.calculative.worldRect["e"+f])}),s=(c-u)/this.store.data.scale}if(i=i.filter(u=>!u.parentId),i.length<=2)return;const n=ht(i),a=i.reduce((u,c)=>{const f=this.getPenRect(c);return u+f[t]},0),r=(s-a)/(i.length-1);i=i.sort((u,c)=>t==="width"?u.x-c.x:u.y-c.y);const l=this.getPenRect(i[0]);let o=t==="width"?l.x:l.y;for(const u of i){const c=this.getPenRect(u);t==="width"?c.x=o:c.y=o,o+=c[t]+r,this.setValue({id:u.id,...c},{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(hi(t));!i&&(i=n.width),t=t.filter(u=>!u.type&&!u.parentId);const a=ht(t);let r=0;t.forEach(u=>{const c=this.getPenRect(u);c.height>r&&(r=c.height)});let l=n.x,o=n.y;t.forEach((u,c)=>{const f=this.getPenRect(u);if(f.x=l,f.y=o+r/2-f.height/2,this.setValue({id:u.id,...f},{render:!1,doEvent:!1}),c===t.length-1)return;const g=l+f.width-n.x,v=this.getPenRect(t[c+1]);Math.round(i-g)>=Math.round(v.width+s)?l+=f.width+s:(l=n.x,o+=r+s)}),this.initImageCanvas(t),this.initTemplateCanvas(t),this.render(),this.pushHistory({type:bt.Update,initPens:a,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 a of this.store.data.pens)Yi(a);this.canvas.canvasImage.init(),this.canvas.canvasImageBottom.init(),this.render()}showMap(){this.map||(this.map=new mk(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=[...Qe(i,this.store),i].map(r=>r.id);s.filter(r=>n.includes(r.id)).forEach(r=>{const l=s.findIndex(o=>o.id===r.id);l>-1&&(s.push(s[l]),s.splice(l,1),this.initTemplateCanvas([r]),this.initImageCanvas([r])),this.specificLayerMove(r,"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=[...Qe(i,this.store),i].map(r=>r.id),a=s.filter(r=>n.includes(r.id));for(let r=a.length-1;r>=0;r--){const l=a[r],o=s.findIndex(u=>u.id===l.id);o>-1&&(s.unshift(s[o]),s.splice(o+1,1),this.initTemplateCanvas([l]),this.initImageCanvas([l])),this.specificLayerMove(l,"bottom")}}this.store.emitter.emit("layer",{type:"bottom",pens:t})}upByArea(t){if(this.store.data.pens.findIndex(o=>o.id===t.id)===-1){console.warn("upByArea: pen not in canvas");return}const s=[t,...Qe(t,this.store)];let n=s.map(o=>this.store.data.pens.findIndex(u=>u.id===o.id));n.includes(-1)&&(console.warn("upByArea: pen children not in canvas"),n=n.filter(o=>o!==-1));const a=Math.min(...n),r=t.calculative.worldRect,l=this.store.data.pens.findIndex((o,u)=>{if(u<=a||o.id===t.id||qx(o,t))return!1;const c=o.calculative.worldRect;return Xi(r,c)});if(l===-1){this.up(t);return}this.store.data.pens.splice(l+1,0,...s);for(const o of s){const u=this.store.data.pens.findIndex(c=>c.id===o.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&&Re(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=[...Qe(i,this.store),i],a=[];for(let o=0;o<s.length;o++){const u=s[o];n.findIndex(c=>c.id===u.id)!==-1&&(u.temIndex=o,a.push(u))}let r=-1,l=0;a.forEach(o=>{o.temIndex-=l,s.splice(o.temIndex,1),l+=1,r=o.temIndex,delete o.temIndex,this.specificLayerMove(o,"up")}),s.splice(r+1,0,...a),this.initTemplateCanvas(a),this.initImageCanvas(a)}else{const n=s.findIndex(a=>a.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=[...Qe(i,this.store),i],a=[];for(let o=0;o<s.length;o++){const u=s[o];n.findIndex(c=>c.id===u.id)!==-1&&(u.temIndex=o,a.push(u))}let r=-1,l=0;a.forEach((o,u)=>{o.temIndex-=l,s.splice(o.temIndex,1),l+=1,u===0&&(r=o.temIndex),delete o.temIndex,this.specificLayerMove(o,"down")}),s.splice(r-1,0,...a),this.initTemplateCanvas(a),this.initImageCanvas(a)}else{const n=s.findIndex(a=>a.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(a=>a.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:a})=>{const r=this.store.pens[a];if(!r){console.warn(t,"node contain a error connectedLine");return}if(!s.find(l=>l.id===r.id))switch(i){case"all":s.push(r);break;case"in":$t(r).connectTo===t.id&&s.push(r);break;case"out":le(r).connectTo===t.id&&s.push(r);break}}),s}nextNode(t){if(t.type===jt.Line){const i=this.store.pens[$t(t).connectTo];return i?[i]:[]}else{const i=this.getLines(t,"out"),s=[];return i.forEach(n=>{const a=this.nextNode(n);for(const r of a)!s.find(o=>o.id===r.id)&&s.push(r)}),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 a=this.previousNode(n);for(const r of a)!s.find(o=>o.id===r.id)&&s.push(r)}),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:a})=>{var o,u;const r=(o=t.anchors)==null?void 0:o.filter(c=>c.id===a)[0],l=this.findOne(n);if(l.anchors[0].connectTo==t.id){const c=l.anchors[l.anchors.length-1].connectTo;if(c){const f=this.findOne(c),g=(u=f.connectedLines)==null?void 0:u.filter(y=>y.lineId===l.id)[0],v=f.anchors.filter(y=>y.id===g.anchor)[0];i.push({from:t,fromAnchor:r,line:l,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,a=null;i.x<=1&&i.x>=0&&i.y<=1&&i.y>=0?(a={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(a,t.rotate,t.calculative.worldRect.center),n={id:a.id,penId:t.id,x:i.x,y:i.y}):(a={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:a.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,a),t.anchors.splice(s,0,n),this.canvas.updateLines(t),this.canvas.initLineRect(t),this.render()):(t.calculative.worldAnchors.push(a),t.anchors.push(n))}connectLine(t,i,s,n,a=!0){if(!s){const u=i.calculative.worldRect;s=xn(t,{x:u.x+u.width/2,y:u.y+u.height/2})}if(!n){const u=t.calculative.worldRect;n=xn(i,{x:u.x+u.width/2,y:u.y+u.height/2})}const r=Math.abs(s.x-n.x),o={height:Math.abs(s.y-n.y),lineName:"line",lineWidth:1,name:"line",type:1,width:r,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([o]),we(t,s,o,o.calculative.worldAnchors[0]),we(i,n,o,o.calculative.worldAnchors[1]),o.calculative.active=!1,this.canvas.updateLines(o),this.canvas.updateLines(t),this.canvas.updateLines(i),this.canvas.initLineRect(o),a&&this.render(),o}toComponent(t=this.store.data.pens,i,s){if(t.length===1){const c=ht(t[0]);return c.type=jt.Node,c.id=void 0,[c]}const n=ht(t,!0),a=hi(n);let r={id:It(),name:"combine",...a,children:[],showChild:i};s&&(r.anchors=[{id:"0",penId:r.id,x:.5,y:0},{id:"1",penId:r.id,x:1,y:.5},{id:"2",penId:r.id,x:.5,y:1},{id:"3",penId:r.id,x:0,y:.5}]);const l=n.filter(c=>!c.parentId),o=n.find(c=>c.width===a.width&&c.height===a.height),u=o&&i===void 0;return l.length===1?r=l[0]:u&&(o.children||(o.children=[]),r=o),n.forEach(c=>{var g;if(c===r||c.parentId===r.id||c.parentId)return;r.children.push(c.id),c.parentId=r.id;const f=fs(c.calculative.worldRect,a);Object.assign(c,f),c.locked=(g=c.lockedOnCombine)!=null?g:Ot.DisableMove}),u||l.length===1?ht(n):ht([r,...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 a=n.plugin,r=n.options;if(!!a&&F_(a)&&s)if(a.install(t,r),!this.penPluginMap.has(a))this.penPluginMap.set(a,[{[s]:t[s],option:r}]);else{let l=this.penPluginMap.get(a).find(o=>o[s]===t[s]);l?l.option=r:this.penPluginMap.get(a).push({[s]:t[s],option:r})}})}uninstallPenPlugins(t,i){let s;t.id?s="id":t.tag?s="tag":t.name&&(s="name"),s&&i.forEach(n=>{let a=n.plugin;a.uninstall(t,n.options);let r=this.penPluginMap.get(a),l=r.findIndex(o=>o[s]===t[s]);l!==-1&&(r.splice(l,1),r.length===0&&this.penPluginMap.delete(a))})}setVisible(t,i,s=!0){if(this.onSizeUpdate(),this.setValue({id:t.id,visible:i},{render:!1,doEvent:!1}),t.children)for(const a of t.children){const r=this.store.pens[a];r&&this.setVisible(r,i,!1)}let n=Qe(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(),ta.destroyThemeSheet(this.store.id),this.store.emitter.all.clear(),this.canvas.destroy(),this.canvas=void 0,kt[this.store.id]=void 0,!t){for(const i in kt)delete kt[i];kt.path2dDraws={},kt.canvasDraws={},kt.anchors={},kt.htmlElements={}}}}function Ck(e,t){const i=t||new Path2D,{x:s,y:n,width:a,ey:r}=e.calculative.worldRect,l=a/4;if(i.moveTo(s+l,n),i.lineTo(s,n),i.lineTo(s,r),i.lineTo(s+l,r),i instanceof Path2D)return i}function Rk(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 Tk(e,t){const i=t||new Path2D,{x:s,y:n,width:a,ex:r,ey:l}=e.calculative.worldRect,o=e.offsetX;let u=a/7;if(o>1?u=o:o>0&&(u=a*o),i.moveTo(s+u,n),i.lineTo(r,n),i.lineTo(s+a-u,l),i.lineTo(s,l),i.closePath(),i instanceof Path2D)return i}function Sk(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 Pk(e,t){const i=t||new Path2D,{x:s,y:n,width:a,height:r,ex:l,ey:o}=e.calculative.worldRect,u=a/8;if(i.moveTo(s+u,n),i.lineTo(l-u,n),i.bezierCurveTo(l+u/3,n,l+u/3,o,l-u,o),i.lineTo(s+u,o),i.lineTo(s,n+r/2),i.closePath(),i instanceof Path2D)return i}function Ik(e,t){const i=t||new Path2D,{x:s,y:n,width:a,height:r,ex:l,center:o}=e.calculative.worldRect,u=o.x,c=n+r*6/7,f=r/6;if(i.moveTo(s,n),i.lineTo(l,n),i.lineTo(l,c),i.bezierCurveTo(l-20,c-f,u+a/5,c-f,u,c),i.bezierCurveTo(u-a/5,c+f,s,c+f,s,c),i.closePath(),i instanceof Path2D)return i}function Lk(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 Dk(e,t){const i=t||new Path2D,{x:s,y:n,width:a,ex:r,ey:l}=e.calculative.worldRect,o=a/10;if(i.moveTo(s+o*2,n),i.bezierCurveTo(s-o*2/3,n,s-o*2/3,l,s+o*2,l),i.lineTo(r,l),i.bezierCurveTo(r-o,l,r-o,n,r,n),i.closePath(),i instanceof Path2D)return i}function Mk(e,t){const i=t||new Path2D,{x:s,y:n,width:a,ex:r,ey:l}=e.calculative.worldRect;i.moveTo(s,n),i.lineTo(r,n),i.lineTo(r,l),i.lineTo(s,l),i.closePath();const o=a/7;if(i.moveTo(s,n+o),i.lineTo(r,n+o),i.moveTo(s+o,n),i.lineTo(s+o,l),i instanceof Path2D)return i}function Bk(e,t){const i=t||new Path2D,{x:s,y:n,height:a,ex:r,ey:l}=e.calculative.worldRect,o=a/4;if(i.moveTo(s,n+o),i.lineTo(r,n),i.lineTo(r,l),i.lineTo(s,l),i.closePath(),i instanceof Path2D)return i}function Ok(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 Fk(e,t){const i=t||new Path2D,{x:s,y:n,ex:a,ey:r}=e.calculative.worldRect;if(i.moveTo(s,n),i.lineTo(a,n),i.moveTo(s,r),i.lineTo(a,r),i instanceof Path2D)return i}function Nk(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 zk(e,t){const i=t||new Path2D,{x:s,y:n,width:a,height:r,ex:l,ey:o}=e.calculative.worldRect;if(i.ellipse(s+a/2,n+r/2,a/2,r/2,0,0,Math.PI*2),i.moveTo(s+a/2,o),i.lineTo(l,o),i.closePath(),i instanceof Path2D)return i}function Hk(e,t){const i=t||new Path2D,{x:s,y:n,width:a,ex:r,ey:l}=e.calculative.worldRect,o=a/7;if(i.moveTo(s,n),i.lineTo(r,n),i.lineTo(r,l),i.lineTo(s,l),i.closePath(),i.moveTo(s+o,n),i.lineTo(s+o,l),i.moveTo(r-o,n),i.lineTo(r-o,l),i instanceof Path2D)return i}function Wk(e,t){const i=t||new Path2D,{x:s,y:n,height:a,ex:r,ey:l}=e.calculative.worldRect,o=a/7;if(i.moveTo(s,n+o),i.bezierCurveTo(s,n-o/2|0,r,n-o/2|0,r,n+o),i.lineTo(r,l-o),i.bezierCurveTo(r,l+o/2|0,s,l+o/2|0,s,l-o),i.closePath(),i.moveTo(s,l-o),i.bezierCurveTo(s,l-o*2|0,r,l-o*2|0,r,l-o),i instanceof Path2D)return i}function uR(){return{flowComment:Ck,flowData:Tk,flowDb:Wk,flowDisplay:Pk,flowDocument:Ik,flowExternStorage:Dk,flowInternalStorage:Mk,flowManually:Bk,flowParallel:Fk,flowQueue:zk,flowSubprocess:Hk}}function fR(){return{flowDocument:Lk,flowManually:Ok,flowParallel:Nk,flowComment:Rk,flowData:Sk}}var Xr;(function(e){e[e.Add=0]="Add",e[e.Replace=1]="Replace",e[e.ReplaceAll=2]="ReplaceAll"})(Xr||(Xr={}));function Eg(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 Ag(e){if(e.direction=="horizontal"){const t=[];let i=0;const s=e.height;e.checkboxHeight=s,e.options.forEach((a,r)=>{t.push(r*(40+s)+i),i+=Eg(a.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}},re(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}},re(e.calculative.worldRect))}}function $f(e,t){t.onAdd||(t.onAdd=Cg,(!t.rowPos||!t.colPos||!t.calculative.maxOffsetY)&&t.onAdd(t),t.onMouseMove=Kk,t.onMouseLeave=Xk,t.onMouseDown=Gk,t.onShowInput=qk,t.onInput=Yk,t.onValue=Qk,t.onBeforeValue=tE,t.onMouseEnter=aE,t.onWheel=eE,t.onDestroy=sE),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:a,height:r}=t.calculative.worldRect;e.fillStyle="#fff0",e.rect(s-1,n-1,a+2,r+2),e.fill(),e.clip()}jk(e,t),Vk(e,t),Uk(e,t),e.restore(),t.isFirstTime=!1}function Uk(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:a}=t.calculative.hoverCell,{x:r,y:l}=t.calculative.canvas.mousePos;if(!t.data[n])return;let o=t.data[n][a];if(typeof o=="object"||!o)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(o).width;e.beginPath(),e.fillStyle="#fff",e.strokeStyle="#000",e.moveTo(r,l),e.rect(r-10,l,u+20,20),e.fill(),e.stroke(),e.beginPath(),e.fillStyle="#000",e.fillText(o,r,l+10),e.restore()}function $k(e){const t=[],i=[],s={};e.rowHeight||(e.rowHeight=40),e.colWidth||(e.colWidth=150);let n=0;const a=e.styles&&e.styles.filter(v=>v.col!==void 0&&v.row===void 0&&v.width);let r={};a&&a.forEach(v=>{r[v.col]=v.width});for(let v=0;v<e.data[0].length;v++){n+=(r[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 l=0;const o=e.styles&&e.styles.filter(v=>v.col===void 0&&v.row!==void 0&&v.height);let u={};o&&o.forEach(v=>{u[v.row]=v.height});let c=l;for(let v=0;v<e.data.length;v++)l+=(u[v]||e.rowHeight)*e.calculative.canvas.store.data.scale,i.push(l),v<e.maxNum&&(c=l);if(e.calculative.maxOffsetY=(l-c)/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=c||l,e.calculative.width=n,e.calculative.height=c||l,e.calculative.width=n,e.calculative.height=c||l,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}),re(e.calculative.worldRect)}function jk(e,t){if(!t.colPos)return;const{x:i,y:s,width:n,height:a,ex:r,ey:l}=t.calculative.worldRect;e.save(),e.beginPath(),e.strokeStyle=t.color;let o=t.calculative.borderRadius||0,u=o;o<1&&(o=n*o,u=a*u);let c=o<u?o:u;if(n<2*c&&(c=n/2),a<2*c&&(c=a/2),e.moveTo(i+c,s),e.arcTo(r,s,r,l,c),e.arcTo(r,l,i,l,c),e.arcTo(i,l,i,s,c),e.arcTo(i,s,r,s,c),t.background&&(e.fillStyle=t.background,e.fill()),t.bordered!==!1&&(e.strokeStyle=t.borderColor||t.color||"#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||t.color||"#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||t.color||"#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||t.color||"#424B61",e.stroke()})}e.restore()}function Vk(e,t){var s,n,a,r,l;if(!t.colPos)return;t.calculative.texts||(t.calculative.texts=[]);const i=1;for(let o=0;o<t.rowPos.length;o++){if(t.hasHeader&&o===1){e.save(),e.beginPath();const{x:c,y:f,width:g,height:v}=t.calculative.worldRect;e.fillStyle="#fff0",e.rect(c-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}=Zk(t,o);for(let c=0;c<t.colPos.length;c++){let{value:f,style:g}=Tg(t,o,c),v=!0;if(Array.isArray(g)&&g.length>0){let D=0;g.forEach(($,Q)=>{$.wheres&&$.wheres.every(T=>new Function("attr",`return attr ${T.comparison} ${T.value}`)(f))&&(D=Q)}),g=g[D]}else g.wheres&&Array.isArray(g.wheres)&&(v=!1,v=g.wheres.every(function(D){return new Function("attr",`return attr ${D.comparison} ${D.value}`)(f)}));let y=t.color,w=t.textColor||t.color,m=null,_=null,E=null,x=null;v&&(y=g.color||u.color||t.color,w=g.textColor||u.textColor||t.textColor,m=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?o%2===1&&(m=m||t.stripeColor||"#407FFF1F"):o%2===0&&(m=m||t.stripeColor||"#407FFF1F")),t.calculative.active&&((s=t.calculative.activeCell)==null?void 0:s.row)===o&&((n=t.calculative.activeCell)==null?void 0:n.col)===c&&(y=t.activeColor,m=t.activeBackground,C=y,w=t.activeTextColor||t.activeColor),t.calculative.hover&&((a=t.calculative.hoverCell)==null?void 0:a.row)===o&&((r=t.calculative.hoverCell)==null?void 0:r.col)===c&&(y=t.hoverColor,m=t.hoverBackground,w=t.hoverTextColor||t.hoverColor,C=y);const S=Pg(t,o,c);if(S.y+S.height<t.calculative.worldRect.y||S.y>t.calculative.worldRect.height+t.calculative.worldRect.y)continue;m&&(e.save(),e.beginPath(),e.fillStyle=m,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 L=t.calculative.texts[o];if(t.calculative.texts[o]||(L=[],t.calculative.texts.push(L)),L[c]==null){if(typeof f=="object"){const D=t.styles&&t.styles.filter($=>$.col===c&&$.row===void 0&&$.pens);if(D.length>0){if(L[c]="",t.isFirstTime){t.maxNum&&t.hasHeader&&o>=t.maxNum&&(f.visible=!1);let $=JSON.parse(JSON.stringify(D[0].pens));$.forEach(Q=>{Object.assign(Q,{row:o,col:c},f),Q.activeBackground=Q.background,Q.hoverBackground=Q.background,Q.activeColor=Q.color,Q.hoverColor=Q.color,Q.activeTextColor=Q.textColor,Q.hoverTextColor=Q.textColor,Q.height*=t.calculative.canvas.store.data.scale,Q.width*=t.calculative.canvas.store.data.scale}),Jk(t,S,$),t.calculative.canvas.parent.pushChildren(t,$)}continue}}else f===void 0?L[c]="":L[c]=f.text||f+"";if(!L[c])continue;L[c]=_a(t,L[c])}if(!L[c])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 M=t.colStyle&&((l=t.colStyle[c])==null?void 0:l.textAlign);if(M&&(e.textAlign=M),L[c].length===1)M==="left"?e.fillText(L[c][0],S.x,S.y+S.height/2):M==="right"?e.fillText(L[c][0],S.x+S.width,S.y+S.height/2):e.fillText(L[c][0],S.x+S.width/2,S.y+S.height/2);else{const $=(_||t.calculative.fontSize)*t.calculative.lineHeight*i,Q=L[c].length*$;let R=(S.height-Q)/2;M==="left"?L[c].forEach((T,P)=>{e.fillText(T,S.x,S.y+R+(P+.55)*$)}):M==="right"?L[c].forEach((T,P)=>{e.fillText(T,S.x+S.width,S.y+R+(P+.55)*$)}):L[c].forEach((T,P)=>{e.fillText(T,S.x+S.width/2,S.y+R+(P+.55)*$)})}e.restore()}}}function Cg(e){var t;Ec(e),(t=e.children)!=null&&t.length||(e.isFirstTime=!0),e.offsetY||(e.offsetY=0),$k(e)}function qk(e,t){if(!e.calculative.hoverCell)return;const{value:i}=Tg(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=Pg(e,e.calculative.hoverCell.row,e.calculative.hoverCell.col);e.calculative.tempText=i.text||i+"",e.calculative.canvas.showInput(e,s,"#ffffff")}function Yk(e,t){!e.calculative.inputCell||(Sg(e,e.calculative.inputCell.row,e.calculative.inputCell.col,t),e.calculative.isInput=!1,e.calculative.isHover=!0,e.calculative.canvas.render())}function Kk(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=Rg(e,t),e.calculative.canvas.render()}function Xk(e,t){Ec(e),e.calculative.hoverCell=void 0,e.calculative.canvas.render()}function Gk(e,t){e.calculative.activeCell=Rg(e,t),e.calculative.canvas.render()}function Rg(e,t){const i=e.calculative.worldRect.width/e.tableWidth,s=e.calculative.worldRect.height/e.tableHeight,n={row:0,col:0};for(let a=0;a<e.colPos.length;a++)t.x>e.calculative.worldRect.x+e.colPos[a]*i&&(n.col=a+1);for(let a=0;a<e.rowPos.length;a++)t.y>e.calculative.worldRect.y+e.rowPos[a]*s-e.offsetY*e.calculative.canvas.store.data.scale&&(n.row=a+1);return n}function Tg(e,t,i){if(!e.data||!Array.isArray(e.data))return;const s=e.data[t],n=e.styles&&e.styles.filter(a=>a.row===t&&a.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 Zk(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 Sg(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 Pg(e,t,i){const s=e.calculative.worldRect.width/e.tableWidth,n=e.calculative.worldRect.height/e.tableHeight;let a=0,r=e.colPos[i]*s;i>0&&(a=e.colPos[i-1]*s);let l=0,o=e.rowPos[t]*n;t>0&&(l=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+a,y:e.calculative.worldRect.y+l-u,ex:e.calculative.worldRect.x+r,ey:e.calculative.worldRect.y+o-u,width:r-a,height:o-l}}function Jk(e,t,i){if(!(i&&i.length))return;const s=e.calculative.worldRect.width/e.tableWidth,n=e.calculative.worldRect.height/e.tableHeight;let a=1,r=1;e.initWorldRect&&(e.calculative.worldRect.width!==e.initWorldRect.width&&(a=e.calculative.worldRect.width/e.initWorldRect.width),e.calculative.worldRect.height!==e.initWorldRect.height&&(r=e.calculative.worldRect.height/e.initWorldRect.height));let l=0,o=0,u=0;const c=e.calculative.canvas.store.data.scale;if(i.length>1){for(const f of i)o+f.width*s+20*c*s<t.width?(f.x=t.x+o+10*c*s,f.y=t.y+u+10*c*n,o+=(f.width+10*c)*s,l=Math.max(l,u+(f.height+10*c)*n)):(o=0,u=l,f.x=t.x+o+10*c*s,f.y=t.y+u+10*c*n,l+=(f.height+10*c)*n);if(l+20*c*n<t.height){const f=(t.height-l-10*c*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*a,f.height=f.height*r})}function Qk(e){if(e.calculative.isUpdateData){delete e.calculative.isUpdateData;let t=ht(e.children);e.children=[],Cg(e),t&&t.forEach(i=>{e.calculative.canvas.delForce(e.calculative.canvas.findOne(i))}),e.calculative.texts=void 0}}function tE(e,t){if(e.calculative.isUpdateData=!1,e.swiper!==void 0&&(e.swiper?Ec(e):kc(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===Xr.Replace?(n=e.data,t.dataX&&t.dataX.forEach((a,r)=>{n[a]=t.dataY[r]})):s===Xr.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),Sg(e,t.row,t.col,t.value),e.calculative.canvas.render(),delete t.col,delete t.row),t}function eE(e,t){if(!e.locked&&!e.calculative.canvas.store.data.locked||!e.maxNum)return;let i=0;t.deltaY>0?i=4:i=-4,nc(e,i)}function nc(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];iE(e,n)}),e.calculative.canvas.render()}function iE(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 a=t.row+e.maxNum;if(!e.data[a])return;let r=ht(e.data[a][t.col]);r.background&&(r.activeBackground=r.background,r.hoverBackground=r.background),r.color&&(r.hoverColor=r.color,r.activeColor=r.color),r.textColor&&(r.activeTextColor=r.textColor,r.hoverTextColor=r.textColor),Object.assign(t,r,{row:a}),Object.assign(t.calculative,r,{row:a})}}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 a=t.row-e.maxNum;if(!e.data[a])return;let r=ht(e.data[a][t.col]);r.background&&(r.activeBackground=r.background,r.hoverBackground=r.background),r.color&&(r.hoverColor=r.color,r.activeColor=r.color),r.textColor&&(r.activeTextColor=r.textColor,r.hoverTextColor=r.textColor),Object.assign(t,r,{row:a}),Object.assign(t.calculative,r,{row:a})}}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 a=t.row+e.maxNum;if(!e.data[a])return;let r=ht(e.data[a][t.col]);r.background&&(r.activeBackground=r.background,r.hoverBackground=r.background),r.color&&(r.hoverColor=r.color,r.activeColor=r.color),r.textColor&&(r.activeTextColor=r.textColor,r.hoverTextColor=r.textColor),Object.assign(t,r,{row:a}),Object.assign(t.calculative,r,{row:a})}}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 a=t.row-e.maxNum;if(!e.data[a])return;let r=ht(e.data[a][t.col]);r.background&&(r.activeBackground=r.background,r.hoverBackground=r.background),r.color&&(r.hoverColor=r.color,r.activeColor=r.color),r.textColor&&(r.activeTextColor=r.textColor,r.hoverTextColor=r.textColor),Object.assign(t,r,{row:a}),Object.assign(t.calculative,r,{row:a})}}else t.calculative.visible=!0,t.visible=!0}function sE(e){kc(e)}function kc(e){e.interval&&(globalThis.clearInterval(e.interval),e.interval=null)}function Ec(e){if(e.maxNum&&e.swiper){if(e.interval)return;e.interval=globalThis.setInterval(()=>{e.offsetY>=e.calculative.maxOffsetY?(e.offsetY=0,nE(e)):e.offsetY%e.rowHeight?nc(e,1):(e.calculative.stap||(e.calculative.stap=0),e.calculative.stap+=1,e.calculative.stap==12&&(e.calculative.stap=0,nc(e,1)))},50)}}function nE(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 a=s*(e.initScale||1)/e.tableHeight*e.maxNum;n.oldY-=a;const r=n.row-e.maxNum;if(!e.data[r])return;let l=ht(e.data[r][n.col]);l.background&&(l.activeBackground=l.background,l.hoverBackground=l.background),l.color&&(l.hoverColor=l.color,l.activeColor=l.color),l.textColor&&(l.activeTextColor=l.textColor,l.hoverTextColor=l.textColor),n.calculative.visible=!0,n.visible=!0,Object.assign(n,l,{row:r}),Object.assign(n.calculative,l,{row:r})}),e.calculative.canvas.render()}function aE(e){kc(e)}function rE(e,t){t.onClick||(t.onClick=oE,t.setTheme=lE);let i=t.calculative.worldRect.x,s=t.calculative.worldRect.y,n=t.calculative.worldRect.width,a=t.calculative.worldRect.height;n<a*1.5&&(n=1.5*a),e.beginPath(),e.arc(i+a/2,s+a/2,a/2,Math.PI/2,Math.PI*3/2),e.lineTo(i+n-a/2,s),e.arc(i+n-a/2,s+a/2,a/2,-Math.PI/2,Math.PI/2),e.lineTo(i+a/2,s+a),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+a*2,s+a/2),e.arc(i+n-a/2,s+a/2,a/2>2?a/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+a,s+a/2),e.arc(i+a/2,s+a/2,a/2>2?a/2-2:1,0,Math.PI*2),e.fill()),e.closePath()}function oE(e){e.disableDefaultClick||e.disabled||e.disable||(e.checked=!e.checked,e.calculative.canvas.store.emitter.emit("valueUpdate",e),e.calculative.canvas.render())}function lE(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 cE(e,t){t.onAdd||(t.onAdd=sa,t.onResize=sa,t.onMove=sa,t.onMouseMove=hE,t.onMouseDown=Ig,t.onValue=uE,t.onBeforeValue=fE,t.setTheme=dE),t.calculative.barRect||sa(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,a=t.calculative.worldRect.y+t.calculative.barRect.y,r=t.calculative.barRect.width,l=t.calculative.barRect.height,o=l/2;e.moveTo(n+o,a),e.arcTo(n+r,a,n+r,a+l,o),e.arcTo(n+r,a+l,n,a+l,o),e.arcTo(n,a+l,t.x,t.y,o),e.arcTo(n,a,n+r,a,o),e.fill();let u=t.activeColor||i.styles.activeColor;t.disabled&&(u=t.disabledColor||Ae(.6,u)),e.fillStyle=u,e.beginPath(),r=t.calculative.ballRect.x,e.moveTo(n+o,a),e.arcTo(n+r,a,n+r,a+l,o),e.arcTo(n+r,a+l,n,a+l,o),e.arcTo(n,a+l,t.x,t.y,o),e.arcTo(n,a,n+r,a,o),e.fill(),e.fillStyle=t.btnBackground||"#fff",e.strokeStyle=u,e.lineWidth=2,e.beginPath(),n=t.calculative.worldRect.x+t.calculative.ballRect.x,a=t.calculative.worldRect.y+t.calculative.ballRect.y+t.calculative.ballRect.height/2,e.lineWidth=t.calculative.ballRect.width/10,e.arc(n,a,t.calculative.ballRect.width/2,0,Math.PI*2),e.fill(),e.stroke()}function sa(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},re(e.calculative.barRect),Ac(e)}function Ac(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},re(e.calculative.ballRect),e.calculative.text=e.value+e.unit,Ri(e)}function Ig(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,Ac(e),e.calculative.text=e.value+e.unit,Ri(e),e.calculative.canvas.store.emitter.emit("valueUpdate",e),e.calculative.canvas.render())}function hE(e,t){e.calculative.canvas.mouseDown&&Ig(e,t)}function uE(e){e.calculative.isUpdateData&&(delete e.calculative.isUpdateData,sa(e)),Ac(e)}function fE(e,t){return e.calculative.isUpdateData=!1,(t.textWidth||t.barHeight)&&(t.textWidth&&(e._textWidth=0),e.calculative.isUpdateData=!0),t}function dE(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 gE(e,t){t.onMouseDown||(t.onMouseDown=vE),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:a,fontWeight:r,fontSize:l,fontFamily:o,lineHeight:u}=t.calculative;let c=2;e.beginPath(),e.moveTo(i,s),e.arcTo(i+n,s,i+n,s+n,c),e.arcTo(i+n,s+n,i,s+n,c),e.arcTo(i,s+n,i,s,c),e.arcTo(i,s,i+n,s,c),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":Ji(t,t.calculative.canvas.parent.store)||"#000000d9",e.textAlign="start",e.textBaseline="middle",e.font=Be({fontStyle:a,fontWeight:r,fontFamily:o||t.calculative.canvas.parent.store.options.fontFamily,fontSize:l,lineHeight:u}),e.fillText(t.value+"",i+n+10,s+n/2),e.restore()}function vE(e,t){e.isForbidden||(e.checked=!e.checked,e.calculative.canvas.store.emitter.emit("valueUpdate",e),e.calculative.canvas.render())}function yE(e,t){t.options||(t.options=t.data),t.onAdd||(t.onAdd=mE,t.optionPos||(t.onAdd(t),t.calculative.canvas.parent.active([t])),t.onMouseDown=pE,t.onValue=wE,t.onBeforeValue=bE);let i=t.calculative.worldRect.x,s=t.calculative.worldRect.y,n=t.calculative.worldRect.height,a=t.calculative.worldRect.width;if(!t.optionPos)return;const{fontStyle:r,fontWeight:l,fontSize:o,fontFamily:u,lineHeight:c}=t.calculative;if(t.direction=="horizontal")for(let f=0;f<t.optionPos.length;f++){const g=t.optionPos[f]*a/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":Ji(t,t.calculative.canvas.parent.store)||"#000000d9";const y=t.calculative.worldRect.height*14/16;e.textAlign="start",e.textBaseline="middle",e.font=Be({fontStyle:r,fontWeight:l,fontFamily:u||t.calculative.canvas.parent.store.options.fontFamily,fontSize:y,lineHeight:c}),e.fillText(t.options[f].text,i+n+g+10/t.checkboxWidth*a,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":Ji(t,t.calculative.canvas.parent.store)||"#000000d9";const w=14*t.calculative.worldRect.height/t.checkboxHeight;e.textAlign="start",e.textBaseline="middle",e.font=Be({fontStyle:r,fontWeight:l,fontFamily:u||t.calculative.canvas.parent.store.options.fontFamily,fontSize:w,lineHeight:c}),e.fillText(t.options[g].text,i+f+10,s+f/2+v),e.restore()}}}function mE(e){Ag(e)}function pE(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+Eg(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 wE(e){e.calculative.flag&&Ag(e)}function bE(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 dR(){return{radio:yE,switch:rE,slider:cE,checkbox:gE,table:$f,table2:$f}}function xE(e,t){const{x:i,y:s,width:n,height:a}=t.calculative.worldRect;e.beginPath(),e.ellipse(i+n/2,s+a/2,n/2,a/2,0,0,Math.PI*2),e.stroke(),e.beginPath(),e.fillStyle=e.strokeStyle,e.ellipse(i+n/2,s+a/2,n/4,a/4,0,0,Math.PI*2),e.fill()}function _E(e,t){const i=t||new Path2D,{x:s,y:n,width:a,height:r,ey:l}=e.calculative.worldRect,o=e.calculative.lineLeft||.08;let u=e.calculative.borderRadius||0,c=u;u<1&&(u=a*u,c=r*u);let f=u<c?u:c;if(a<2*f&&(f=a/2),r<2*f&&(f=r/2),i.moveTo(s+f,n),i.arcTo(s+a,n,s+a,n+r,f),i.arcTo(s+a,n+r,s,n+r,f),i.arcTo(s,n+r,s,n,f),i.arcTo(s,n,s+a,n,f),i.closePath(),i.moveTo(s+o*a,n),i.lineTo(s+o*a,l),i instanceof Path2D)return i}function kE(e,t){const i=t||new Path2D,{x:s,y:n,width:a,height:r,ex:l}=e.calculative.worldRect,o=e.calculative.lineTop||.08;let u=e.calculative.borderRadius||0,c=u;u<1&&(u=a*u,c=r*c);let f=u<c?u:c;if(a<2*f&&(f=a/2),r<2*f&&(f=r/2),i.moveTo(s+f,n),i.arcTo(s+a,n,s+a,n+r,f),i.arcTo(s+a,n+r,s,n+r,f),i.arcTo(s,n+r,s,n,f),i.arcTo(s,n,s+a,n,f),i.closePath(),i.moveTo(s,n+o*r),i.lineTo(l,n+o*r),i instanceof Path2D)return i}function gR(){return{forkV:Fs,forkH:Fs,swimlaneH:_E,swimlaneV:kE}}function vR(){return{activityFinal:xE}}function EE(e,t){e.onDestroy||(e.onDestroy=CE,e.onAdd=AE);const i=t||new Path2D,{x:s,y:n,width:a,height:r,ex:l}=e.calculative.worldRect;let o=e.calculative.borderRadius||0,u=o;o<1&&(o*=a,u*=r);let c=o<u?o:u;a<2*c&&(c=a/2),r<2*c&&(c=r/2),i.moveTo(s+c,n),i.arcTo(s+a,n,s+a,n+r,c),i.arcTo(s+a,n+r,s,n+r,c),i.arcTo(s,n+r,s,n,c),i.arcTo(s,n,s+a,n,c);const f=.2*r;i.moveTo(s,n+f),i.lineTo(l,n+f);const g=n+f+(r-f)/2;if(i.moveTo(s,g),i.lineTo(l,g),i.closePath(),i instanceof Path2D)return i}function AE(e){const{x:t,y:i,width:s,height:n}=e.calculative.worldRect,a=e.list,r={name:"text",x:t,y:i+.2*n,width:s,height:.4*n,textAlign:"left",textBaseline:"top",textLeft:10,textTop:10},l={name:"text",x:t,y:i+.6*n,width:s,height:.4*n,textAlign:"left",textBaseline:"top",textLeft:10,textTop:10};Object.assign(r,a[0]),Object.assign(l,a[1]),e.calculative.canvas.makePen(r),e.calculative.canvas.makePen(l),e.calculative.canvas.parent.pushChildren(e,[r]),e.calculative.canvas.parent.pushChildren(e,[l])}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 RE(e,t){e.onDestroy||(e.onDestroy=SE,e.onAdd=TE);const i=t||new Path2D,{x:s,y:n,width:a,height:r,ex:l}=e.calculative.worldRect;let o=e.calculative.borderRadius||0,u=o;o<1&&(o=a*o,u=r*u);let c=o<u?o:u;a<2*c&&(c=a/2),r<2*c&&(c=r/2),i.moveTo(s+c,n),i.arcTo(s+a,n,s+a,n+r,c),i.lineTo(s+a,n+r-c),i.arcTo(s+a,n+r,s,n+r,c),i.arcTo(s,n+r,s,n,c),i.arcTo(s,n,s+a,n,c);const f=.2*r;if(i.moveTo(s,n+f),i.lineTo(l,n+f),i.closePath(),i instanceof Path2D)return i}function TE(e){const{x:t,y:i,width:s,height:n}=e.calculative.worldRect,a=e.list;let r={name:"text",x:t,y:i+.2*n,width:s,height:.8*n,textAlign:"left",textBaseline:"top",textLeft:10,textTop:10};Object.assign(r,a[0]),e.calculative.canvas.makePen(r),e.calculative.canvas.parent.pushChildren(e,[r])}function SE(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 yR(){return{interfaceClass:EE,simpleClass:RE}}var la;(function(e){e[e.Add=0]="Add",e[e.Replace=1]="Replace",e[e.ReplaceAll=2]="ReplaceAll"})(la||(la={}));let ac=["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 PE(e){var n,a;let t=globalThis.echarts;if(!e.echarts||!t)return;if(typeof e.echarts=="string")try{e.echarts=JSON.parse(e.echarts)}catch{}ac=((n=e.calculative.canvas.store.options.diagramOptions.chart)==null?void 0:n.keyWords)||ac,e.onDestroy||(e.onDestroy=LE,e.onMove=Mr,e.onResize=DE,e.onRotate=Mr,e.onValue=BE,e.onBeforeValue=OE,e.onBinds=NE,e.onMouseEnter=Mr,e.onRenderPenRaw=Ml,e.onScale=ME),e.calculative.singleton||(e.calculative.singleton={});const i=new Path2D,s=e.calculative.worldRect;if(!e.calculative.singleton.div){const r=document.createElement("div");r.style.position="absolute",r.style.outline="none",r.style.left="-9999px",r.style.top="-9999px",r.style.width=s.width+"px",r.style.height=s.height+"px",document.body.appendChild(r),(a=e.calculative.canvas.externalElements)==null||a.parentElement.appendChild(r),Re(e,r),e.calculative.singleton.div=r,e.calculative.singleton.echart=t.init(r,e.echarts.theme),IE(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(l=>{l.text().then(o=>{if(typeof o=="string")try{o=JSON.parse(o)}catch{}if(o.constructor!==Object&&o.constructor!==Array){console.warn("Invalid data:",o);return}t.registerMap(e.echarts.geoName,o),e.calculative.singleton.echartsReady=!0,e.calculative.singleton.echart.setOption(Gr(e.echarts.option,e.calculative.canvas.store.data.scale),!0),e.calculative.singleton.echart.resize(),setTimeout(()=>{Ml(e)},300)})}))),e.calculative.singleton.echartsReady&&setTimeout(()=>{e.calculative.singleton.echart.setOption(Gr(e.echarts.option,e.calculative.canvas.store.data.scale),!0),setTimeout(()=>Ml(e),300)})}return i}function IE(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,a=>{let r=!1;n.conditions&&n.conditions.length?n.conditionType==="and"?r=n.conditions.every(l=>e.calculative.canvas.parent.judgeCondition(e,l.key,l)):n.conditionType==="or"&&(r=n.conditions.some(l=>e.calculative.canvas.parent.judgeCondition(e,l.key,l))):r=!0,r&&n.actions.forEach(l=>{if(l.timeout){let o=setTimeout(()=>{e.calculative.canvas.parent.events[l.action]&&(e.calculative.canvas.parent.events[l.action](e,l,a),clearTimeout(o),o=null)},l.timeout)}else e.calculative.canvas.parent.events[l.action]&&e.calculative.canvas.parent.events[l.action](e,l,a)})})})}function LE(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 Mr(e){e.calculative.singleton.div&&Re(e,e.calculative.singleton.div)}function DE(e){var t;Mr(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(Re(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 a=e.calculative.singleton.echart.getOption().dataZoom;(s=e.echarts.option.dataZoom)==null||s.forEach((r,l)=>{a[l]&&(r.start=a[l].start,r.end=a[l].end)})}e.calculative.singleton.echart.setOption(Gr(e.echarts.option,e.calculative.canvas.store.data.scale),!0)}e.calculative.singleton.echart.resize()}}function BE(e){var t,i;if(!!e.calculative.singleton.echart&&(Re(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(a=>s[a]):!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(Gr(e.echarts.option,e.calculative.canvas.store.data.scale),!0)}function OE(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(m=>{if(typeof m=="string")try{m=JSON.parse(m)}catch{}if(m.constructor!==Object&&m.constructor!==Array){console.warn("Invalid data:",m);return}return y.registerMap(t.echarts.geoName,m),e.calculative.singleton.echartsReady=!0,e.onValue(e),!1})}))),t}if(e.realTimes&&e.realTimes.length){e.echarts.dataMap&&t.data&&(t=FE(e,t));let y=Object.keys(t);const{xAxis:w,yAxis:m}=e.echarts.option,{max:_,replaceMode:E,timeFormat:x}=e.echarts;let C=[],S=!1;for(let L in t)if(L.includes("echarts.option")){S=!0;let M=ms(e,L);if(Array.isArray(M)&&E===la.Add&&(M.push(t[L]),_&&M.splice(0,M.length-_),t[L]=M,!y.includes("echarts.option.xAxis.data"))){let D="echarts.option.xAxis.data";Array.isArray(w)&&w.length&&(D="echarts.option.xAxis.0.data");let $=ms(e,D),Q=Zl(x||"`${hours}:${minutes}:${seconds}`");$.push(Q),_&&$.splice(0,$.length-_),t[D]=$}if(L.includes(".data.")){let D=L.substring(0,L.indexOf(".data.")+5);C.includes(D)||C.push(D)}}if(S){const L=ht(t);e.calculative.partialOption=zE(L,e),C.forEach(M=>{let D=ms(e,M);$r(e.calculative.partialOption,M,D)})}return t}if(!t.dataX&&!t.dataY)return t;const i=e.echarts,{max:s,replaceMode:n}=i;let a=t.dataX,r=t.dataY,l=[];r&&l.push("echarts.option.series");const o=i.option.series,u=o.length,{xAxis:c,yAxis:f}=i.option;Array.isArray(c)&&c.length>1&&console.warn("echarts \u53EA\u652F\u6301\u5355 x \u8F74\uFF0C\u591A x \u8F74\u5C06\u88AB\u5FFD\u7565");const g=Array.isArray(c)?c[0]:c,v=Array.isArray(f)?f[0]:f;if(n)if(n===la.Replace){if(!g&&!v)r&&(u===1?(!Array.isArray(r)&&(r=[r]),r.forEach((y,w)=>{const m=o[0].data.find(_=>_.name===y.name);m&&(m.value=y.value)})):o.forEach((y,w)=>{Array.isArray(r[w])||(r[w]=[r[w]]),r[w].forEach((m,_)=>{const E=y.data.find(x=>x.name===m.name);E&&(E.value=m.value)})}));else if((g.type==="category"||v.type==="category")&&a&&r){const y=g.type==="category"?g.data:v.data;!Array.isArray(a)&&(a=[a]),!Array.isArray(r)&&(r=[r]),g.type==="category"?l.push("echarts.option.xAxis"):l.push("echarts.option.yAxis"),u===1?r.forEach((w,m)=>{const _=y.indexOf(a[m]);o[0].data[_]=w}):o.forEach((w,m)=>{r[m].forEach((_,E)=>{const x=y.indexOf(a[E]);w.data[x]=_})})}}else n===la.ReplaceAll&&(a&&(g.data=a,g.data.splice(0,g.data.length-s),l.push("echarts.option.xAxis")),r&&(u===1?(o[0].data=r,o[0].data.splice(0,o[0].data.length-s)):o.forEach((y,w)=>{y.data=r[w],y.data.splice(0,y.data.length-s)})));else{if(a){!Array.isArray(a)&&(a=[a]);const y=g.data;y.push(...a),y.splice(0,y.length-s),l.push("echarts.option.xAxis")}if(r)if(u===1){!Array.isArray(r)&&(r=[r]);const y=o[0].data;y.push(...r),y.splice(0,y.length-s)}else o.forEach((y,w)=>{Array.isArray(r[w])||(r[w]=[r[w]]);const m=y.data;m.push(...r[w]),m.splice(0,m.length-s)})}return e.calculative.partialOption={},l.forEach(y=>{let w=ms(e,y);$r(e.calculative.partialOption,y,w)}),delete t.dataX,delete t.dataY,Object.assign(t,{echarts:i})}function FE(e,t){var i,s;if(!e.echarts.dataMap||!t.data)return t;if(t.data){let n={};if(Array.isArray(t.data))for(const a in e.echarts.dataMap)e.echarts.dataMap.hasOwnProperty(a)&&(((i=e.echarts.timeKeys)==null?void 0:i.length)&&e.echarts.timeKeys.includes(e.echarts.dataMap[a])?n[a]=t.data.map(r=>Zl(e.echarts.timeFormat,r[e.echarts.dataMap[a]])):n[a]=t.data.map(r=>r[e.echarts.dataMap[a]]));else for(const a in e.echarts.dataMap)e.echarts.dataMap.hasOwnProperty(a)&&(((s=e.echarts.timeKeys)==null?void 0:s.length)&&e.echarts.timeKeys.includes(e.echarts.dataMap[a])?n[a]=Zl(e.echarts.timeFormat,t.data[e.echarts.dataMap[a]]):n[a]=t.data[e.echarts.dataMap[a]]);return delete t.data,Object.assign(t,n),t}}function NE(e,t,i){if(i.key!=="dataY")return;const s=e.echarts,{xAxis:n,yAxis:a}=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 r=Array.isArray(n)?n[0]:n,l=Array.isArray(a)?a[0]:a,o=s.option.series;if(!r&&!l){const u=[];if(Array.isArray(o)&&o.length===1)return o[0].data.forEach(c=>{const{dataId:f}=i.dataIds.find(g=>g.name===c.name);if(f){const g=t.find(v=>v.dataId===f);g&&u.push({name:c.name,value:g.value})}}),{id:e.id,dataY:u}}else if(r.type==="category"||l.type==="category"){const u=[],c=[],f=r.type==="category"?r.data:l.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&&(c.push(g),u.push(y.value))}}),{id:e.id,dataY:u,dataX:c}}else if(r.type==="time"){const u=[],c=+new Date;let f=!1;if(o.forEach((g,v)=>{const y=[],{dataId:w}=i.dataIds.find(m=>m.name===g.name);if(w){const m=t.find(_=>_.dataId===w);m&&(y.push([c,m.value]),f=!0)}u[v]=y}),f)u.forEach((g,v)=>{if(!g||g.length===0){const y=o[v].data[o[v].data.length-1];u[v]=[[c,y[1]]]}});else return;return{id:e.id,dataY:u.length===1?u[0]:u}}}function Ml(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 Gr(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(a=>{isNaN(a[s[n]])||(a[s[n]]*=t)})}return Xl(i,ac,t),i}function zE(e,t){const i={};return Object.keys(e).forEach(s=>{const n=s.split(".");let a=i;n.forEach((r,l)=>{const o=!isNaN(parseInt(r));if(l===6){let u=n.slice(0,7).join(".");$r(t,s,e[s]);let c=ms(t,u);a[n[l]]=c}else{if(l>6)return;if(l===n.length-1)o?(Array.isArray(a)||(a=[]),a[parseInt(r)]=e[s]):a[r]=e[s];else if(o){const u=parseInt(r);if(Array.isArray(a)||a[n[l-1]],a[u]||(a[u]={}),Array.isArray(a))for(let c=0;c<parseInt(r);c++)a[c]||(a[c]={});a=a[u]}else a[r]||(r==="series"?a[r]=[]:a[r]={}),a=a[r]}})}),i}function mR(e){e&&(globalThis.echarts=e),zd({echarts:PE})}const HE=15;function Ps(e,t=HE){let i=""+e;return i.indexOf(".")>=0&&(i=Number.parseFloat(i).toFixed(t)),Number.parseFloat(i)}function Bl(e){return typeof e=="number"&&Number.isFinite(e)}function WE(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:a,deviation:r,preferZero:l}=e;if(!Bl(i)||!Bl(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&&(l=!0),(!Bl(n)||n<=0)&&(n=4),l&&i*s>0&&(i<0?i=0:s=0);const o=(i-s)/n;let u=Math.floor(Math.log10(o)-1);u=Math.pow(10,u);const c=o/u;let f=t[0]*u,g=-1,v;for(v=0;v<t.length;v++)if(t[v]>c){f=t[v]*u;break}let y=i,w=s;function m(E){if(y=parseInt(""+(i/E+1))*E,w=parseInt(""+(s/E-1))*E,i===0&&(y=0),s===0&&(w=0),a&&y*w<0){const x=Math.max(Math.abs(y),Math.abs(w));y=x,w=-x}}if(m(f),r)return{max:Ps(y),min:Ps(w),interval:Ps(f),splitNumber:Math.round((y-w)/f)};if(!a||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,m(f)}while(E!==n)}y=Ps(y),w=Ps(w);const _=Ps((y-w)/n);return{max:y,min:w,interval:_,splitNumber:n}}function Lg(e,t){var m,_,E,x,C,S,L,M,D,$,Q,R,T,P,O,Y,Z,at,V,H,j,K,U,tt,st,et,ut,ct;const i=t.calculative.worldRect.x,s=t.calculative.worldRect.y,n=t.calculative.worldRect.width,a=t.calculative.worldRect.height;let r=t.calculative.canvas.store.data.scale,l=[];if(t.echarts)for(let ot=0;ot<t.echarts.option.series.length;ot++)l.push(t.echarts.option.series[ot].data);else l=t.data;let o=[];for(let ot=0;ot<l.length;ot++)o=o.concat(l[ot]);let u={max:Math.max.apply(null,o),min:Math.min.apply(null,o),splitNumber:5},c=WE(u),f=t.echarts?t.echarts.option.xAxis.data.length:t.xAxisData.length;e.beginPath(),e.strokeStyle="#BFBFBF",e.lineWidth=6*r,e.lineCap="butt";let g=(n-1*(f+1))/f;e.setLineDash([1,g]),e.moveTo(i,s+a+3*r),e.lineTo(i+n,s+a+3*r),e.stroke(),e.closePath(),e.beginPath(),e.lineWidth=1*r,e.setLineDash([]),e.moveTo(i,s+a),e.lineTo(i+n,s+a),e.stroke(),e.closePath(),e.beginPath(),e.fillStyle="#BFBFBF",e.strokeStyle="#E9E9E9",e.setLineDash([2,2]);let v={fontStyle:((_=(m=t.yAxis)==null?void 0:m.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:((M=(L=t.yAxis)==null?void 0:L.axisLabel)==null?void 0:M.fontFamily)||t.fontFamily,fontSize:(($=(D=t.yAxis)==null?void 0:D.axisLabel)==null?void 0:$.fontSize)||t.fontSize,lineHeight:((R=(Q=t.yAxis)==null?void 0:Q.axisLabel)==null?void 0:R.lineHeight)||t.lineHeight};e.fillStyle=((P=(T=t.yAxis)==null?void 0:T.axisLabel)==null?void 0:P.fontColor)||t.color;for(let ot=0;ot<c.splitNumber+1;ot++){let b=ot*a/c.splitNumber;e.textAlign="right",e.textBaseline="middle",e.font=Be(v),e.fillText(c.max-ot*c.interval+"",i-10*r,s+b),e.fill(),ot<c.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:(at=(Z=t.xAxis)==null?void 0:Z.axisLabel)==null?void 0:at.textDecoration,fontWeight:((H=(V=t.xAxis)==null?void 0:V.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:((tt=(U=t.xAxis)==null?void 0:U.axisLabel)==null?void 0:tt.fontSize)||t.calculative.fontSize,lineHeight:((et=(st=t.xAxis)==null?void 0:st.axisLabel)==null?void 0:et.lineHeight)||t.calculative.lineHeight};e.font=Be(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+a+10*r),e.fill()}return e.closePath(),e.setLineDash([]),{dash:g,normalizedOption:c}}function UE(e,t){if(!isNaN(e))return t===-1?e:Math.round(Number(e)*1e3)/1e3}var In;(function(e){e[e.Add=0]="Add",e[e.Replace=1]="Replace",e[e.ReplaceAll=2]="ReplaceAll"})(In||(In={}));function $E(e,t){t.onBeforeValue||(t.onBeforeValue=Dg);const i=t.calculative.worldRect.x,s=t.calculative.worldRect.y;t.calculative.worldRect.width;const n=t.calculative.worldRect.height;let a=t.calculative.canvas.store.data.scale,r=[];t.echarts&&!t.echarts.option.color&&(t.echarts.option.color=["#1890ff","#2FC25B","#FACC14","#c23531","#2f4554","#61a0a8","#d48265"]);let l=Lg(e,t),o=l.dash,u=l.normalizedOption;const c=!!(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++)r.push(t.echarts.option.series[g].data);else r=t.data;for(let g=0;g<r.length;g++){e.beginPath();let v=r[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+o/2),w=s+n-(v[0]-u.min)/(u.max-u.min)*n;if(e.moveTo(y,w),f.push({x:y,y:w}),c)if(v.length<=2)for(let m=1;m<v.length;m++)y=i+(1+o/2)+(o+1)*m,w=s+n-(v[m]-u.min)/(u.max-u.min)*n,e.lineTo(y,w),f.push({x:y,y:w});else{let m,_,E,x;v.forEach((C,S)=>{y=i+(1+o/2)+(o+1)*S,w=s+n-(v[S]-u.min)/(u.max-u.min)*n;let L=i+(1+o/2)+(o+1)*(S+1),M=s+n-(v[S+1]-u.min)/(u.max-u.min)*n,D=i+(1+o/2)+(o+1)*(S-1),$=s+n-(v[S-1]-u.min)/(u.max-u.min)*n,Q=i+(1+o/2)+(o+1)*(S+2),R=s+n-(v[S+2]-u.min)/(u.max-u.min)*n;S===0?(D=i+(1+o/2)+(o+1)*S,$=s+n-(v[S]-u.min)/(u.max-u.min)*n):S===v.length-2&&(Q=i+(1+o/2)+(o+1)*(S+1),R=s+n-(v[S+1]-u.min)/(u.max-u.min)*n),f.push({x:y,y:w}),m=y+(L-D)/4,_=w+(M-$)/4,E=L-(Q-y)/4,x=M-(R-w)/4,e.bezierCurveTo(m,_,E,x,L,M)})}else for(let m=1;m<v.length;m++)y=i+(1+o/2)+(o+1)*m,w=s+n-(v[m]-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((m,_)=>{e.beginPath(),e.strokeStyle="#fff",e.lineWidth=2*a,e.arc(m.x,m.y,4*a,0,Math.PI*2),e.stroke(),e.fill(),e.closePath()}),e.restore(),f=[]}}function Dg(e,t){if(t.xAxisData||t.data||!t.dataX&&!t.dataY)return t;const i=e.xAxisData,s=e.data,n=e.replaceMode;let a=[],r=[];return n?n===In.Replace?(t.dataX.forEach((l,o)=>{let u=i.indexOf(l);s.forEach((c,f)=>{c[u]=t.dataY[f][o]})}),a=i,r=s):n===In.ReplaceAll&&(a=t.dataX,r=t.dataY):(a=[...i,...t.dataX],s.forEach((l,o)=>{let u=[...l,...t.dataY[o]];r.push(u)})),delete t.dataX,delete t.dataY,Object.assign(t,{xAxisData:a,data:r})}function jE(e,t){var c,f;t.onBeforeValue||(t.onBeforeValue=VE);let i=t.calculative.canvas.store.data.scale;const s=t.calculative.worldRect.x,n=t.calculative.worldRect.y,a=t.calculative.worldRect.width,r=t.calculative.worldRect.height,l=!!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 o=l?t.echarts.option.series:t.data;let u=0;for(let g=0;g<o.length;g++){let v=o[g],y=a/2;r<a&&(y=r/2);const w=s+a/2,m=n+r/2;let _=0;l?_=v.data.reduce((M,D)=>M+D.value,0):_=v.reduce((M,D)=>M+D.value,0);const E=y*parseFloat(l?v.radius[0]:t.chartsRadius[g][0])/100,x=y*parseFloat(l?v.radius[1]:t.chartsRadius[g][1])/100;if(E>x)return;let C=0,S=0;e.strokeStyle=l&&((c=v.itemStyle)==null?void 0:c.borderColor)||"#fff",e.lineWidth=(l&&((f=v.itemStyle)==null?void 0:f.borderWidth)||2)*i;const L=l?v.data:v;L.forEach((M,D)=>{var Y,Z,at,V,H,j,K,U,tt,st,et,ut,ct;S+=Math.PI*2*M.value/_,e.beginPath();let $=u+D;$>=t.chartsColor.length&&($=$%t.chartsColor.length),e.fillStyle=l?t.echarts.option.color[$]:t.chartsColor[$],e.moveTo(w+E*Math.sin(S),m-E*Math.cos(S)),e.arc(w,m,E,-Math.PI/2+S,-Math.PI/2+C,!0),e.lineTo(w+x*Math.sin(C),m-x*Math.cos(C)),e.arc(w,m,x,-Math.PI/2+C,-Math.PI/2+S),e.lineTo(w+E*Math.sin(S),m-E*Math.cos(S)),e.stroke(),e.fill(),e.closePath();let Q=(C+S)/2,R=w+(x+10*i)*Math.sin(Q),T=m-(x+10*i)*Math.cos(Q),P=e.fillStyle;v.label||(v.label={position:"outside",show:!0}),l&&["inner","inside"].includes(v.label.position)?(e.fillStyle="#ffffff",R=w+(x-E)/2*Math.sin(Q),T=m-(x-E)/2*Math.cos(Q)):l&&v.label.position=="outside",v.labelLine||(v.labelLine={show:!0}),(l&&v.labelLine.show!==!1||!l)&&(e.beginPath(),e.strokeStyle=l?t.echarts.option.color[u+D]:t.chartsColor[u+D],e.moveTo(w+x*Math.sin(Q),m-x*Math.cos(Q)),e.lineTo(R,T));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:((at=t.tickLabel)==null?void 0:at.fontFamily)||t.calculative.fontFamily,lineHeight:((V=t.tickLabel)==null?void 0:V.lineHeight)||t.calculative.lineHeight,fontSize:(((H=t.tickLabel)==null?void 0:H.fontSize)||t.calculative.fontSize)*i};e.font=Be(O),e.textBaseline="middle",e.textAlign="center",Q>Math.PI?((l&&v.label.position==="outside"||!l)&&(e.textAlign="end"),(l&&v.labelLine.show!==!1||!l&&((U=(K=(j=t.tickLabel)==null?void 0:j.labelLine)==null?void 0:K.show)!=null?U:!0))&&e.lineTo(R-5*i,T),(l&&v.label.show!==!1||!l&&((st=(tt=t.tickLabel)==null?void 0:tt.show)!=null?st:!0))&&e.fillText(M.name,R-5*i,T)):((l&&v.label.position==="outside"||!l)&&(e.textAlign="start"),(l&&v.labelLine.show!==!1||!l)&&e.lineTo(R+5*i,T),(l&&v.label.show!==!1||!l&&((ut=(et=t.tickLabel)==null?void 0:et.show)!=null?ut:!0))&&e.fillText(M.name,R+5*i,T)),e.stroke(),e.closePath(),e.fillStyle=P,e.strokeStyle=l&&((ct=v.itemStyle)==null?void 0:ct.borderColor)||"#fff",C=S}),u+=L.length}}function VE(e,t){if(t.data||!t.dataX&&!t.dataY)return t;const i=e.data,s=e.replaceMode;let n=[];return s?s===In.Replace?(t.dataY.forEach((a,r)=>{a.forEach((l,o)=>{let u=i[r].filter(c=>c.name===l.name);u.length>0&&(u[0].value=l.value)})}),n=i):s===In.ReplaceAll&&(n=t.dataY):i.forEach((a,r)=>{let l=[...a,...t.dataY[r]];n.push(l)}),delete t.dataX,delete t.dataY,Object.assign(t,{data:n})}function qE(e,t){t.onBeforeValue||(t.onBeforeValue=Dg);let i=t.calculative.canvas.store.data.scale;const s=t.calculative.worldRect.x,n=t.calculative.worldRect.y;t.calculative.worldRect.width;const a=t.calculative.worldRect.height;let r=[];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++)r.push(t.echarts.option.series[f].data);else r=t.data;let l=Lg(e,t),o=l.dash,u=l.normalizedOption,c=o*4/5/r.length;for(let f=0;f<r.length;f++){e.beginPath();let g=r[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 m=0;m<g.length;m++)v=s+(1+.1*o)+(o+1)*m+c*f,w=(g[m]-u.min)/(u.max-u.min)*a,y=n+a-w,e.rect(v,y,c-1,w-1),e.stroke(),e.fill();e.closePath()}}function YE(e,t){var V,H,j,K,U,tt,st,et,ut,ct,ot,b,k,I;t.onAdd||(t.onAdd=KE,t.onDestroy=XE,t.onClick=GE,t.clockInterval&&(t.onDestroy(t),t.onAdd(t)));const i=t.calculative.worldRect.x,s=t.calculative.worldRect.y,n=t.calculative.worldRect.width,a=t.calculative.worldRect.height;let r=t.calculative.canvas.store.data.scale,l={startAngle:225,endAngle:-45,min:0,max:100,splitNumber:10};if(t.echarts&&t.echarts.option){let N=t.echarts.option.series[0];t.startAngle=N.startAngle||l.startAngle,t.endAngle=N.endAngle||l.endAngle,t.min=N.min||l.min,t.max=N.max||l.max,t.axisLine=N.axisLine.lineStyle.color,t.unit=N.detail.formatter.replace("{value}",""),t.value=N.data[0].value,t.splitNumber=N.splitNumber||l.splitNumber}t={...l,...t};let o=n>a?a/2*9/10:n/2*9/10,u=i+n/2,c=s+a/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=o/10;e.lineWidth=w,e.beginPath(),e.lineCap="round",e.arc(u,c,o,-t.startAngle/180*Math.PI,-t.endAngle/180*Math.PI),e.stroke(),e.closePath();let m=0;if(t.axisLine&&!t.isClock)for(let N=t.axisLine.length-1;N>=0;N--)t.axisLine[N][0]*(t.max-t.min)<f?m=t.axisLine[N][0]:(m=(f-t.min)/(t.max-t.min),g=t.axisLine[N][1]),e.beginPath(),e.strokeStyle=t.axisLine[N][1],e.arc(u,c,o,-t.startAngle/180*Math.PI,(-t.startAngle+m*v)/180*Math.PI),e.stroke(),e.closePath();e.lineCap="butt";let _=2*r,E=o-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=o/20,e.setLineDash([_,C]),e.arc(u,c,E,-t.startAngle/180*Math.PI-S,-t.endAngle/180*Math.PI+S),e.stroke(),e.closePath();let L=1*r,M=o-w;M<0&&(M=0);let D=v/180*Math.PI*M,$=(D-L*5*t.splitNumber)/5/t.splitNumber,Q=v/180*Math.PI*L/2/D;e.beginPath(),e.strokeStyle=t.color||"#999999",e.lineWidth=o/40,e.setLineDash([L,$]),e.arc(u,c,M,-t.startAngle/180*Math.PI-Q,-t.endAngle/180*Math.PI+Q),e.stroke(),e.closePath(),e.beginPath();let R=t.max-t.min,T=R/t.splitNumber,P={fontStyle:((V=t.tickLabel)==null?void 0:V.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:(((U=t.tickLabel)==null?void 0:U.fontSize)||t.calculative.fontSize)*r,lineHeight:((tt=t.tickLabel)==null?void 0:tt.lineHeight)||t.calculative.lineHeight};e.font=Be(P);let O=o-w-o/20;for(let N=0;N<=t.splitNumber;N++){if(Math.abs(t.startAngle)+Math.abs(t.endAngle)===360&&N==0)continue;let X=t.startAngle-T*N/R*v,G=Math.cos(X/180*Math.PI),rt=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",rt>.02?e.textBaseline="top":rt<-.02?e.textBaseline="bottom":e.textBaseline="middle",e.fillText(UE(T*N+t.min,1),u+O*G,c-O*rt),e.fill()}e.closePath();let Y=1,Z=["value"];if(t.isClock&&(Y=3,Z=["hourvalue","minutevalue","secondvalue"]),t.isClock)for(let N=0;N<Y;N++){let X=(t.startAngle-(t[Z[N]]-t.min)/(t.max-t.min)*v)/180*Math.PI;N>0&&(X=(t.startAngle-(t[Z[N]]-t.min)/(t.max*5-t.min)*v)/180*Math.PI);let G=4/5*o;Z[N]==="hourvalue"&&(G=3/5*o),Z[N]==="minutevalue"&&(G=3.5/5*o);let rt=o*1/40;e.beginPath(),e.setLineDash([]),e.lineWidth=o/(N+1)/20,e.strokeStyle=t.color||"#999999",e.moveTo(u-rt*3*Math.cos(X),c+rt*3*Math.sin(X)),e.lineTo(u+G*Math.cos(X),c-G*Math.sin(X)),e.stroke()}else{let N=(t.startAngle-(f-t.min)/(t.max-t.min)*v)/180*Math.PI,X=4/5*o,G=o*1/40;e.beginPath(),e.setLineDash([]),e.lineWidth=2,e.fillStyle=g,e.moveTo(u-G*3*Math.cos(N),c+G*3*Math.sin(N)),e.lineTo(u+G*Math.cos(N-Math.PI/2),c-G*Math.sin(N-Math.PI/2)),e.lineTo(u+X*Math.cos(N),c-X*Math.sin(N)),e.lineTo(u+G*Math.cos(N+Math.PI/2),c-G*Math.sin(N+Math.PI/2)),e.lineTo(u-G*3*Math.cos(N),c+G*3*Math.sin(N)),e.fill()}e.beginPath(),e.textAlign="center",e.textBaseline="middle";let at={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)*r,lineHeight:((k=t.titleLabel)==null?void 0:k.lineHeight)||t.calculative.lineHeight};e.font=Be(at),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,c+o/2):e.fillText(f+" "+(t.unit||""),u,c+o/2),e.fill(),t.isClock&&(e.beginPath(),e.fillStyle=t.color||"#999999",e.strokeStyle="#ffffff",e.arc(u,c,o/20,0,Math.PI*2),e.stroke(),e.fill(),e.closePath())}function KE(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 XE(e){e.clockInterval&&(clearInterval(e.clockInterval),e.clockInterval=void 0)}function GE(e){e.isClock&&(e.onDestroy(e),e.onAdd(e))}function pR(){return{lineChart:$E,histogram:qE,pieChart:jE,gauge:YE}}function ZE(e,t){const i=t||new Path2D,{x:s,y:n,width:a,height:r}=e.calculative.worldRect;if(i.rect(s,n,a,r),i.closePath(),i instanceof Path2D)return i}function JE(e,t){var g;const i=(g=t.headHeight)!=null?g:50,{x:s,y:n,width:a,height:r,ey:l}=t.calculative.worldRect;let o=t.calculative.borderRadius||0,u=o;t.calculative.borderRadius<1&&(o*=a,u*=r);let c=o<u?o:u;a<2*c&&(c=a/2),i<2*c&&(c=i/2),e.beginPath(),e.moveTo(s+c,n),e.arcTo(s+a,n,s+a,n+i,c),e.arcTo(s+a,n+i,s,n+i,c),e.arcTo(s,n+i,s,n,c),e.arcTo(s,n,s+a,n,c),e.closePath(),e.stroke(),e.save(),e.beginPath(),e.lineWidth=1,e.setLineDash([7,7]);const f=s+a/2;e.moveTo(f,n+i+1),e.lineTo(f,l),e.stroke(),e.restore()}function wR(){return{sequenceFocus:ZE}}function bR(){return{lifeline:JE}}function QE(e,t){const i=t||new Path2D,{x:s,y:n,width:a,height:r}=e.calculative.worldRect,l=r/6,o=a/4;if(i.moveTo(s+o*2,n+0),i.lineTo(s+o*2,n+l),i.moveTo(s,n+l+o*2),i.arc(s+o*2,n+l+o*2,o*2,Math.PI*1,Math.PI*2,!1),i.lineTo(s+o*4,n+l*5),i.lineTo(s,n+l*5),i.lineTo(s,n+l+o*2),i.moveTo(s+o,n+l*5),i.lineTo(s+o,n+l*6),i.moveTo(s+o*2,n+l*5),i.lineTo(s+o*2,n+l*6),i.moveTo(s+o*3,n+l*5),i.lineTo(s+o*3,n+l*6),i.closePath(),i instanceof Path2D)return i}function jf(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 tA(e,t){const i=t||new Path2D,{x:s,y:n,width:a,height:r}=e.calculative.worldRect,l=r-a,o=.5*a;if(i.moveTo(s+a/2,n),i.lineTo(s+a/2,n+l),i.moveTo(s+a,n+o+l),i.arc(s+a/2,n+o+l,o,0,Math.PI*2,!1),i.closePath(),i instanceof Path2D)return i}function Vf(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 eA(e,t){const i=t||new Path2D,{x:s,y:n,width:a,height:r}=e.calculative.worldRect,l=r/2,o=a/5;if(i.moveTo(s,n+l),i.lineTo(s+o,n+l),i.moveTo(s+o*5,n+l),i.ellipse(s+o*3,n+l,2*o,l,0,0,Math.PI*2),i.closePath(),i instanceof Path2D)return i}function iA(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 sA(e,t){const i=t||new Path2D,{x:s,y:n,width:a,height:r}=e.calculative.worldRect,l=r/4,o=.5*a;if(i.moveTo(s+o,n),i.lineTo(s+o,n+l),i.moveTo(s,n+l),i.rect(s,n+l,o*2,l*2),i.moveTo(s+o,n+3*l),i.lineTo(s+o,n+4*l),i.closePath(),i instanceof Path2D)return i}function nA(e,t){const i=t||new Path2D,{x:s,y:n,width:a,height:r}=e.calculative.worldRect,l=r/8,o=.25*a;if(i.moveTo(s+o*2,n),i.lineTo(s+o*2,n+l*2),i.lineTo(s+o*3,n+l*3),i.lineTo(s+o*3,n+l*5),i.lineTo(s+o*2,n+l*6),i.lineTo(s+o*1,n+l*5),i.lineTo(s+o*1,n+l*3),i.lineTo(s+o*2,n+l*2),i.moveTo(s+o*3,n+l*4),i.lineTo(s+o*4,n+l*4),i.moveTo(s+o*2,n+l*6),i.lineTo(s+o*2,n+l*8),i.closePath(),i instanceof Path2D)return i}function aA(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 rA(e,t){const i=t||new Path2D,{x:s,y:n,width:a,height:r}=e.calculative.worldRect,l=a/2,o=r/10;if(i.moveTo(s+l,n),i.lineTo(s+l,n+o),i.moveTo(s+l,n+o),i.quadraticCurveTo(s+l*2,n+o,s+l*2,n+o*9),i.moveTo(s+l,n+o),i.quadraticCurveTo(s,n+o,s,n+o*9),i.quadraticCurveTo(s+l,n+o*6,s+l*2,n+o*9),i.moveTo(s+l,n+r*3/4),i.lineTo(s+l,n+r),i.moveTo(s+l*2/5,n+r*201/250),i.lineTo(s+l*2/5,n+r),i.moveTo(s+l*8/5,n+r*201/250),i.lineTo(s+l*8/5,n+r),i.closePath(),i instanceof Path2D)return i}function qf(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 oA(e,t){const i=t||new Path2D,{x:s,y:n,width:a,height:r}=e.calculative.worldRect,l=r/6,o=a/4;if(i.moveTo(s+o*2,n+0),i.lineTo(s+o*2,n+l),i.moveTo(s,n+l+o*2),i.arc(s+o*2,n+l+o*2,o*2,Math.PI*1,Math.PI*2,!1),i.lineTo(s+o*4,n+l*5),i.lineTo(s,n+l*5),i.lineTo(s,n+l+o*2),i.moveTo(s,n+l*5-l/3),i.lineTo(s+o*4,n+l*5-l/3),i.moveTo(s+o,n+l*5),i.lineTo(s+o,n+l*6),i.moveTo(s+o*2,n+l*5),i.lineTo(s+o*2,n+l*6),i.moveTo(s+o*3,n+l*5),i.lineTo(s+o*3,n+l*6),i.closePath(),i instanceof Path2D)return i}function lA(e,t){const i=t||new Path2D,{x:s,y:n,width:a,height:r}=e.calculative.worldRect,l=r/4,o=.5*a;if(i.moveTo(s+o,n),i.lineTo(s+o,n+l),i.lineTo(s+o*2,n+l*2),i.lineTo(s+o*2,n+l*4),i.lineTo(s,n+l*4),i.lineTo(s,n+l*2),i.lineTo(s+o,n+l),i.closePath(),i instanceof Path2D)return i}function cA(e,t){const i=t||new Path2D,{x:s,y:n,width:a,height:r}=e.calculative.worldRect,l=r/4,o=a/2;if(i.moveTo(s+o,n),i.lineTo(s+o,n+l),i.lineTo(s+o*2,n+l*4),i.lineTo(s,n+l*4),i.lineTo(s+o,n+l),i.closePath(),i instanceof Path2D)return i}function hA(e,t){const i=t||new Path2D,{x:s,y:n,width:a,height:r}=e.calculative.worldRect,l=r/3,o=.5*a;if(i.moveTo(s+o,n),i.lineTo(s+o,n+l),i.lineTo(s+a,n+2*l),i.lineTo(s+o,n+r),i.lineTo(s,n+2*l),i.lineTo(s+o,n+l),i.closePath(),i instanceof Path2D)return i}function uA(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 fA(e,t){const i=t||new Path2D,{x:s,y:n,width:a,height:r}=e.calculative.worldRect;let l=a/2,o=r/10;if(i.moveTo(s+l,n),i.lineTo(s+l,n+o),i.moveTo(s+l,n+o),i.quadraticCurveTo(s+l*2,n+o,s+l*2,n+o*9),i.moveTo(s+l,n+o),i.quadraticCurveTo(s,n+o,s,n+o*9),i.quadraticCurveTo(s+l,n+o*6,s+l*2,n+o*9),i.moveTo(s,n+o*10),i.quadraticCurveTo(s+l,n+o*7,s+l*2,n+o*10),i.moveTo(s+l*2/5,n+r*201/250+o),i.lineTo(s+l*2/5,n+r),i.moveTo(s+l*8/5,n+r*201/250+o),i.lineTo(s+l*8/5,n+r),i.closePath(),i instanceof Path2D)return i}function dA(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 gA(e,t){const{x:i,y:s,width:n,height:a}=t.calculative.worldRect,r=n/2,l=a/10;e.beginPath(),e.moveTo(i+r,s),e.lineTo(i+r,s+l),e.moveTo(i+r,s+l),e.quadraticCurveTo(i+r*2,s+l,i+r*2,s+l*9),e.moveTo(i+r,s+l),e.quadraticCurveTo(i,s+l,i,s+l*9),e.quadraticCurveTo(i+r,s+l*6,i+r*2,s+l*9),e.moveTo(i+r,s+a*3/4),e.lineTo(i+r,s+a*9/10),e.moveTo(i+r*2/5,s+a*201/250),e.lineTo(i+r*2/5,s+a*9/10),e.moveTo(i+r*8/5,s+a*201/250),e.lineTo(i+r*8/5,s+a*9/10),e.stroke(),e.closePath(),e.beginPath();const o=r*2>l*10?l:r/5;e.fillStyle="#333333",e.font=o+"px Arial",e.textBaseline="bottom",e.textAlign="center",e.fillText("o",i+r,s+a),e.fillText("m",i+r*2/5,s+a),e.fillText("o",i+r*8/5,s+a),e.closePath()}function xR(){return{andGate:QE,basicEvent:tA,conditionalEvent:eA,event:sA,forbiddenGate:nA,orGate:rA,priorityAndGate:oA,switchEvent:lA,transferSymbol:cA,unexpandedEvent:hA,xorGate:fA}}function _R(){return{votingGate:gA}}function kR(){return{andGate:jf,orGate:qf,priorityAndGate:jf,votingGate:qf,xorGate:dA,forbiddenGate:aA,basicEvent:Vf,unexpandedEvent:uA,conditionalEvent:iA,transferSymbol:Vf}}const ER={background:"#ECE5E5",color:"#fff",textColor:"#fff",anchorColor:"#f90",gridSize:30,grid:!1,gridColor:"rgba(255,255,255,0.1)",drawingLineName:"line"},AR=[{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"}],CR=["triangle","diamond","circle","lineDown","lineUp","triangleSolid","diamondSolid","circleSolid","line"],RR=["#000","#fff","#f00","#0f0","rgba(255,255,255,0.5)"],vA={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"}}]},yA={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"}}]},mA={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"}}]},TR=["time-comp"],SR=[{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,canDataBind:!0,echarts:{option:{grid:{top:10,bottom:30,left:40,right:50},xAxis:{type:"category",data:["Mon","Tue","Wed","Thu","Fri","Sat","Sun"]},yAxis:{type:"value"},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",canDataBind:!0,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",canDataBind:!1,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",canDataBind:!0,echarts:{option:{series:[{name:"\u4E1A\u52A1\u6307\u6807",type:"gauge",min:0,max:100,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"}}]},{...vA},{...yA},{...mA},{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 Qi={};(function(e){var t=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";function i(a,r){return Object.prototype.hasOwnProperty.call(a,r)}e.assign=function(a){for(var r=Array.prototype.slice.call(arguments,1);r.length;){var l=r.shift();if(!!l){if(typeof l!="object")throw new TypeError(l+"must be non-object");for(var o in l)i(l,o)&&(a[o]=l[o])}}return a},e.shrinkBuf=function(a,r){return a.length===r?a:a.subarray?a.subarray(0,r):(a.length=r,a)};var s={arraySet:function(a,r,l,o,u){if(r.subarray&&a.subarray){a.set(r.subarray(l,l+o),u);return}for(var c=0;c<o;c++)a[u+c]=r[l+c]},flattenChunks:function(a){var r,l,o,u,c,f;for(o=0,r=0,l=a.length;r<l;r++)o+=a[r].length;for(f=new Uint8Array(o),u=0,r=0,l=a.length;r<l;r++)c=a[r],f.set(c,u),u+=c.length;return f}},n={arraySet:function(a,r,l,o,u){for(var c=0;c<o;c++)a[u+c]=r[l+c]},flattenChunks:function(a){return[].concat.apply([],a)}};e.setTyped=function(a){a?(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)})(Qi);var Ea={},Ii={},Ln={},pA=Qi,wA=4,Yf=0,Kf=1,bA=2;function Dn(e){for(var t=e.length;--t>=0;)e[t]=0}var xA=0,Mg=1,_A=2,kA=3,EA=258,Cc=29,Aa=256,ma=Aa+1+Cc,Cn=30,Rc=19,Bg=2*ma+1,Bs=15,Ol=16,AA=7,Tc=256,Og=16,Fg=17,Ng=18,rc=[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],Br=[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],CA=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],zg=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],RA=512,Vi=new Array((ma+2)*2);Dn(Vi);var ca=new Array(Cn*2);Dn(ca);var pa=new Array(RA);Dn(pa);var wa=new Array(EA-kA+1);Dn(wa);var Sc=new Array(Cc);Dn(Sc);var Zr=new Array(Cn);Dn(Zr);function Fl(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 Hg,Wg,Ug;function Nl(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}function $g(e){return e<256?pa[e]:pa[256+(e>>>7)]}function ba(e,t){e.pending_buf[e.pending++]=t&255,e.pending_buf[e.pending++]=t>>>8&255}function je(e,t,i){e.bi_valid>Ol-i?(e.bi_buf|=t<<e.bi_valid&65535,ba(e,e.bi_buf),e.bi_buf=t>>Ol-e.bi_valid,e.bi_valid+=i-Ol):(e.bi_buf|=t<<e.bi_valid&65535,e.bi_valid+=i)}function Ti(e,t,i){je(e,i[t*2],i[t*2+1])}function jg(e,t){var i=0;do i|=e&1,e>>>=1,i<<=1;while(--t>0);return i>>>1}function TA(e){e.bi_valid===16?(ba(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 SA(e,t){var i=t.dyn_tree,s=t.max_code,n=t.stat_desc.static_tree,a=t.stat_desc.has_stree,r=t.stat_desc.extra_bits,l=t.stat_desc.extra_base,o=t.stat_desc.max_length,u,c,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<Bg;u++)c=e.heap[u],g=i[i[c*2+1]*2+1]+1,g>o&&(g=o,w++),i[c*2+1]=g,!(c>s)&&(e.bl_count[g]++,v=0,c>=l&&(v=r[c-l]),y=i[c*2],e.opt_len+=y*(g+v),a&&(e.static_len+=y*(n[c*2+1]+v)));if(w!==0){do{for(g=o-1;e.bl_count[g]===0;)g--;e.bl_count[g]--,e.bl_count[g+1]+=2,e.bl_count[o]--,w-=2}while(w>0);for(g=o;g!==0;g--)for(c=e.bl_count[g];c!==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),c--)}}function Vg(e,t,i){var s=new Array(Bs+1),n=0,a,r;for(a=1;a<=Bs;a++)s[a]=n=n+i[a-1]<<1;for(r=0;r<=t;r++){var l=e[r*2+1];l!==0&&(e[r*2]=jg(s[l]++,l))}}function PA(){var e,t,i,s,n,a=new Array(Bs+1);for(i=0,s=0;s<Cc-1;s++)for(Sc[s]=i,e=0;e<1<<rc[s];e++)wa[i++]=s;for(wa[i-1]=s,n=0,s=0;s<16;s++)for(Zr[s]=n,e=0;e<1<<Br[s];e++)pa[n++]=s;for(n>>=7;s<Cn;s++)for(Zr[s]=n<<7,e=0;e<1<<Br[s]-7;e++)pa[256+n++]=s;for(t=0;t<=Bs;t++)a[t]=0;for(e=0;e<=143;)Vi[e*2+1]=8,e++,a[8]++;for(;e<=255;)Vi[e*2+1]=9,e++,a[9]++;for(;e<=279;)Vi[e*2+1]=7,e++,a[7]++;for(;e<=287;)Vi[e*2+1]=8,e++,a[8]++;for(Vg(Vi,ma+1,a),e=0;e<Cn;e++)ca[e*2+1]=5,ca[e*2]=jg(e,5);Hg=new Fl(Vi,rc,Aa+1,ma,Bs),Wg=new Fl(ca,Br,0,Cn,Bs),Ug=new Fl(new Array(0),CA,0,Rc,AA)}function qg(e){var t;for(t=0;t<ma;t++)e.dyn_ltree[t*2]=0;for(t=0;t<Cn;t++)e.dyn_dtree[t*2]=0;for(t=0;t<Rc;t++)e.bl_tree[t*2]=0;e.dyn_ltree[Tc*2]=1,e.opt_len=e.static_len=0,e.last_lit=e.matches=0}function Yg(e){e.bi_valid>8?ba(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 IA(e,t,i,s){Yg(e),s&&(ba(e,i),ba(e,~i)),pA.arraySet(e.pending_buf,e.window,t,i,e.pending),e.pending+=i}function Xf(e,t,i,s){var n=t*2,a=i*2;return e[n]<e[a]||e[n]===e[a]&&s[t]<=s[i]}function zl(e,t,i){for(var s=e.heap[i],n=i<<1;n<=e.heap_len&&(n<e.heap_len&&Xf(t,e.heap[n+1],e.heap[n],e.depth)&&n++,!Xf(t,s,e.heap[n],e.depth));)e.heap[i]=e.heap[n],i=n,n<<=1;e.heap[i]=s}function Gf(e,t,i){var s,n,a=0,r,l;if(e.last_lit!==0)do s=e.pending_buf[e.d_buf+a*2]<<8|e.pending_buf[e.d_buf+a*2+1],n=e.pending_buf[e.l_buf+a],a++,s===0?Ti(e,n,t):(r=wa[n],Ti(e,r+Aa+1,t),l=rc[r],l!==0&&(n-=Sc[r],je(e,n,l)),s--,r=$g(s),Ti(e,r,i),l=Br[r],l!==0&&(s-=Zr[r],je(e,s,l)));while(a<e.last_lit);Ti(e,Tc,t)}function oc(e,t){var i=t.dyn_tree,s=t.stat_desc.static_tree,n=t.stat_desc.has_stree,a=t.stat_desc.elems,r,l,o=-1,u;for(e.heap_len=0,e.heap_max=Bg,r=0;r<a;r++)i[r*2]!==0?(e.heap[++e.heap_len]=o=r,e.depth[r]=0):i[r*2+1]=0;for(;e.heap_len<2;)u=e.heap[++e.heap_len]=o<2?++o:0,i[u*2]=1,e.depth[u]=0,e.opt_len--,n&&(e.static_len-=s[u*2+1]);for(t.max_code=o,r=e.heap_len>>1;r>=1;r--)zl(e,i,r);u=a;do r=e.heap[1],e.heap[1]=e.heap[e.heap_len--],zl(e,i,1),l=e.heap[1],e.heap[--e.heap_max]=r,e.heap[--e.heap_max]=l,i[u*2]=i[r*2]+i[l*2],e.depth[u]=(e.depth[r]>=e.depth[l]?e.depth[r]:e.depth[l])+1,i[r*2+1]=i[l*2+1]=u,e.heap[1]=u++,zl(e,i,1);while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],SA(e,t),Vg(i,o,e.bl_count)}function Zf(e,t,i){var s,n=-1,a,r=t[0*2+1],l=0,o=7,u=4;for(r===0&&(o=138,u=3),t[(i+1)*2+1]=65535,s=0;s<=i;s++)a=r,r=t[(s+1)*2+1],!(++l<o&&a===r)&&(l<u?e.bl_tree[a*2]+=l:a!==0?(a!==n&&e.bl_tree[a*2]++,e.bl_tree[Og*2]++):l<=10?e.bl_tree[Fg*2]++:e.bl_tree[Ng*2]++,l=0,n=a,r===0?(o=138,u=3):a===r?(o=6,u=3):(o=7,u=4))}function Jf(e,t,i){var s,n=-1,a,r=t[0*2+1],l=0,o=7,u=4;for(r===0&&(o=138,u=3),s=0;s<=i;s++)if(a=r,r=t[(s+1)*2+1],!(++l<o&&a===r)){if(l<u)do Ti(e,a,e.bl_tree);while(--l!==0);else a!==0?(a!==n&&(Ti(e,a,e.bl_tree),l--),Ti(e,Og,e.bl_tree),je(e,l-3,2)):l<=10?(Ti(e,Fg,e.bl_tree),je(e,l-3,3)):(Ti(e,Ng,e.bl_tree),je(e,l-11,7));l=0,n=a,r===0?(o=138,u=3):a===r?(o=6,u=3):(o=7,u=4)}}function LA(e){var t;for(Zf(e,e.dyn_ltree,e.l_desc.max_code),Zf(e,e.dyn_dtree,e.d_desc.max_code),oc(e,e.bl_desc),t=Rc-1;t>=3&&e.bl_tree[zg[t]*2+1]===0;t--);return e.opt_len+=3*(t+1)+5+5+4,t}function DA(e,t,i,s){var n;for(je(e,t-257,5),je(e,i-1,5),je(e,s-4,4),n=0;n<s;n++)je(e,e.bl_tree[zg[n]*2+1],3);Jf(e,e.dyn_ltree,t-1),Jf(e,e.dyn_dtree,i-1)}function MA(e){var t=4093624447,i;for(i=0;i<=31;i++,t>>>=1)if(t&1&&e.dyn_ltree[i*2]!==0)return Yf;if(e.dyn_ltree[9*2]!==0||e.dyn_ltree[10*2]!==0||e.dyn_ltree[13*2]!==0)return Kf;for(i=32;i<Aa;i++)if(e.dyn_ltree[i*2]!==0)return Kf;return Yf}var Qf=!1;function BA(e){Qf||(PA(),Qf=!0),e.l_desc=new Nl(e.dyn_ltree,Hg),e.d_desc=new Nl(e.dyn_dtree,Wg),e.bl_desc=new Nl(e.bl_tree,Ug),e.bi_buf=0,e.bi_valid=0,qg(e)}function Kg(e,t,i,s){je(e,(xA<<1)+(s?1:0),3),IA(e,t,i,!0)}function OA(e){je(e,Mg<<1,3),Ti(e,Tc,Vi),TA(e)}function FA(e,t,i,s){var n,a,r=0;e.level>0?(e.strm.data_type===bA&&(e.strm.data_type=MA(e)),oc(e,e.l_desc),oc(e,e.d_desc),r=LA(e),n=e.opt_len+3+7>>>3,a=e.static_len+3+7>>>3,a<=n&&(n=a)):n=a=i+5,i+4<=n&&t!==-1?Kg(e,t,i,s):e.strategy===wA||a===n?(je(e,(Mg<<1)+(s?1:0),3),Gf(e,Vi,ca)):(je(e,(_A<<1)+(s?1:0),3),DA(e,e.l_desc.max_code+1,e.d_desc.max_code+1,r+1),Gf(e,e.dyn_ltree,e.dyn_dtree)),qg(e),s&&Yg(e)}function NA(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[(wa[i]+Aa+1)*2]++,e.dyn_dtree[$g(t)*2]++),e.last_lit===e.lit_bufsize-1}Ln._tr_init=BA;Ln._tr_stored_block=Kg;Ln._tr_flush_block=FA;Ln._tr_tally=NA;Ln._tr_align=OA;function zA(e,t,i,s){for(var n=e&65535|0,a=e>>>16&65535|0,r=0;i!==0;){r=i>2e3?2e3:i,i-=r;do n=n+t[s++]|0,a=a+n|0;while(--r);n%=65521,a%=65521}return n|a<<16|0}var Xg=zA;function HA(){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 WA=HA();function UA(e,t,i,s){var n=WA,a=s+i;e^=-1;for(var r=s;r<a;r++)e=e>>>8^n[(e^t[r])&255];return e^-1}var Gg=UA,Pc={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=Qi,fi=Ln,Zg=Xg,ds=Gg,$A=Pc,Ks=0,jA=1,VA=3,bs=4,td=5,Si=0,ed=1,di=-2,qA=-3,Hl=-5,YA=-1,KA=1,Cr=2,XA=3,GA=4,ZA=0,JA=2,eo=8,QA=9,tC=15,eC=8,iC=29,sC=256,lc=sC+1+iC,nC=30,aC=19,rC=2*lc+1,oC=15,Wt=3,ps=258,wi=ps+Wt+1,lC=32,io=42,cc=69,Or=73,Fr=91,Nr=103,Os=113,na=666,me=1,Ca=2,Us=3,Mn=4,cC=3;function ws(e,t){return e.msg=$A[t],t}function id(e){return(e<<1)-(e>4?9:0)}function ys(e){for(var t=e.length;--t>=0;)e[t]=0}function gs(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){fi._tr_flush_block(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,gs(e.strm)}function Ut(e,t){e.pending_buf[e.pending++]=t}function Qn(e,t){e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=t&255}function hC(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=Zg(e.adler,t,n,i):e.state.wrap===2&&(e.adler=ds(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,a,r=e.prev_length,l=e.nice_match,o=e.strstart>e.w_size-wi?e.strstart-(e.w_size-wi):0,u=e.window,c=e.w_mask,f=e.prev,g=e.strstart+ps,v=u[s+r-1],y=u[s+r];e.prev_length>=e.good_match&&(i>>=2),l>e.lookahead&&(l=e.lookahead);do if(n=t,!(u[n+r]!==y||u[n+r-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(a=ps-(g-s),s=g-ps,a>r){if(e.match_start=t,r=a,a>=l)break;v=u[s+r-1],y=u[s+r]}}while((t=f[t&c])>o&&--i!==0);return r<=e.lookahead?r:e.lookahead}function $s(e){var t=e.w_size,i,s,n,a,r;do{if(a=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);a+=t}if(e.strm.avail_in===0)break;if(s=hC(e.strm,e.window,e.strstart+e.lookahead,a),e.lookahead+=s,e.lookahead+e.insert>=Wt)for(r=e.strstart-e.insert,e.ins_h=e.window[r],e.ins_h=(e.ins_h<<e.hash_shift^e.window[r+1])&e.hash_mask;e.insert&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[r+Wt-1])&e.hash_mask,e.prev[r&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=r,r++,e.insert--,!(e.lookahead+e.insert<Wt)););}while(e.lookahead<wi&&e.strm.avail_in!==0)}function uC(e,t){var i=65535;for(i>e.pending_buf_size-5&&(i=e.pending_buf_size-5);;){if(e.lookahead<=1){if($s(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===bs?(Ce(e,!0),e.strm.avail_out===0?Us:Mn):(e.strstart>e.block_start&&(Ce(e,!1),e.strm.avail_out===0),me)}function Wl(e,t){for(var i,s;;){if(e.lookahead<wi){if($s(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=fi._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=fi._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===bs?(Ce(e,!0),e.strm.avail_out===0?Us:Mn):e.last_lit&&(Ce(e,!1),e.strm.avail_out===0)?me:Ca}function vn(e,t){for(var i,s,n;;){if(e.lookahead<wi){if($s(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===KA||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=fi._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=fi._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=fi._tr_tally(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<Wt-1?e.strstart:Wt-1,t===bs?(Ce(e,!0),e.strm.avail_out===0?Us:Mn):e.last_lit&&(Ce(e,!1),e.strm.avail_out===0)?me:Ca}function fC(e,t){for(var i,s,n,a,r=e.window;;){if(e.lookahead<=ps){if($s(e),e.lookahead<=ps&&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=r[n],s===r[++n]&&s===r[++n]&&s===r[++n])){a=e.strstart+ps;do;while(s===r[++n]&&s===r[++n]&&s===r[++n]&&s===r[++n]&&s===r[++n]&&s===r[++n]&&s===r[++n]&&s===r[++n]&&n<a);e.match_length=ps-(a-n),e.match_length>e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=Wt?(i=fi._tr_tally(e,1,e.match_length-Wt),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(i=fi._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===bs?(Ce(e,!0),e.strm.avail_out===0?Us:Mn):e.last_lit&&(Ce(e,!1),e.strm.avail_out===0)?me:Ca}function dC(e,t){for(var i;;){if(e.lookahead===0&&($s(e),e.lookahead===0)){if(t===Ks)return me;break}if(e.match_length=0,i=fi._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===bs?(Ce(e,!0),e.strm.avail_out===0?Us:Mn):e.last_lit&&(Ce(e,!1),e.strm.avail_out===0)?me:Ca}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 kn;kn=[new Ai(0,0,0,0,uC),new Ai(4,4,8,4,Wl),new Ai(4,5,16,8,Wl),new Ai(4,6,32,32,Wl),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 gC(e){e.window_size=2*e.w_size,ys(e.head),e.max_lazy_match=kn[e.level].max_lazy,e.good_match=kn[e.level].good_length,e.nice_match=kn[e.level].nice_length,e.max_chain_length=kn[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 vC(){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=eo,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(rC*2),this.dyn_dtree=new Me.Buf16((2*nC+1)*2),this.bl_tree=new Me.Buf16((2*aC+1)*2),ys(this.dyn_ltree),ys(this.dyn_dtree),ys(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Me.Buf16(oC+1),this.heap=new Me.Buf16(2*lc+1),ys(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Me.Buf16(2*lc+1),ys(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 Qg(e){var t;return!e||!e.state?ws(e,di):(e.total_in=e.total_out=0,e.data_type=JA,t=e.state,t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=t.wrap?io:Os,e.adler=t.wrap===2?0:1,t.last_flush=Ks,fi._tr_init(t),Si)}function tv(e){var t=Qg(e);return t===Si&&gC(e.state),t}function yC(e,t){return!e||!e.state||e.state.wrap!==2?di:(e.state.gzhead=t,Si)}function ev(e,t,i,s,n,a){if(!e)return di;var r=1;if(t===YA&&(t=6),s<0?(r=0,s=-s):s>15&&(r=2,s-=16),n<1||n>QA||i!==eo||s<8||s>15||t<0||t>9||a<0||a>GA)return ws(e,di);s===8&&(s=9);var l=new vC;return e.state=l,l.strm=e,l.wrap=r,l.gzhead=null,l.w_bits=s,l.w_size=1<<l.w_bits,l.w_mask=l.w_size-1,l.hash_bits=n+7,l.hash_size=1<<l.hash_bits,l.hash_mask=l.hash_size-1,l.hash_shift=~~((l.hash_bits+Wt-1)/Wt),l.window=new Me.Buf8(l.w_size*2),l.head=new Me.Buf16(l.hash_size),l.prev=new Me.Buf16(l.w_size),l.lit_bufsize=1<<n+6,l.pending_buf_size=l.lit_bufsize*4,l.pending_buf=new Me.Buf8(l.pending_buf_size),l.d_buf=1*l.lit_bufsize,l.l_buf=(1+2)*l.lit_bufsize,l.level=t,l.strategy=a,l.method=i,tv(e)}function mC(e,t){return ev(e,t,eo,tC,eC,ZA)}function pC(e,t){var i,s,n,a;if(!e||!e.state||t>td||t<0)return e?ws(e,di):di;if(s=e.state,!e.output||!e.input&&e.avail_in!==0||s.status===na&&t!==bs)return ws(e,e.avail_out===0?Hl:di);if(s.strm=e,i=s.last_flush,s.last_flush=t,s.status===io)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>=Cr||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=ds(e.adler,s.pending_buf,s.pending,0)),s.gzindex=0,s.status=cc):(Ut(s,0),Ut(s,0),Ut(s,0),Ut(s,0),Ut(s,0),Ut(s,s.level===9?2:s.strategy>=Cr||s.level<2?4:0),Ut(s,cC),s.status=Os);else{var r=eo+(s.w_bits-8<<4)<<8,l=-1;s.strategy>=Cr||s.level<2?l=0:s.level<6?l=1:s.level===6?l=2:l=3,r|=l<<6,s.strstart!==0&&(r|=lC),r+=31-r%31,s.status=Os,Qn(s,r),s.strstart!==0&&(Qn(s,e.adler>>>16),Qn(s,e.adler&65535)),e.adler=1}if(s.status===cc)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=ds(e.adler,s.pending_buf,s.pending-n,n)),gs(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=ds(e.adler,s.pending_buf,s.pending-n,n)),s.gzindex===s.gzhead.extra.length&&(s.gzindex=0,s.status=Or)}else s.status=Or;if(s.status===Or)if(s.gzhead.name){n=s.pending;do{if(s.pending===s.pending_buf_size&&(s.gzhead.hcrc&&s.pending>n&&(e.adler=ds(e.adler,s.pending_buf,s.pending-n,n)),gs(e),n=s.pending,s.pending===s.pending_buf_size)){a=1;break}s.gzindex<s.gzhead.name.length?a=s.gzhead.name.charCodeAt(s.gzindex++)&255:a=0,Ut(s,a)}while(a!==0);s.gzhead.hcrc&&s.pending>n&&(e.adler=ds(e.adler,s.pending_buf,s.pending-n,n)),a===0&&(s.gzindex=0,s.status=Fr)}else s.status=Fr;if(s.status===Fr)if(s.gzhead.comment){n=s.pending;do{if(s.pending===s.pending_buf_size&&(s.gzhead.hcrc&&s.pending>n&&(e.adler=ds(e.adler,s.pending_buf,s.pending-n,n)),gs(e),n=s.pending,s.pending===s.pending_buf_size)){a=1;break}s.gzindex<s.gzhead.comment.length?a=s.gzhead.comment.charCodeAt(s.gzindex++)&255:a=0,Ut(s,a)}while(a!==0);s.gzhead.hcrc&&s.pending>n&&(e.adler=ds(e.adler,s.pending_buf,s.pending-n,n)),a===0&&(s.status=Nr)}else s.status=Nr;if(s.status===Nr&&(s.gzhead.hcrc?(s.pending+2>s.pending_buf_size&&gs(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(gs(e),e.avail_out===0)return s.last_flush=-1,Si}else if(e.avail_in===0&&id(t)<=id(i)&&t!==bs)return ws(e,Hl);if(s.status===na&&e.avail_in!==0)return ws(e,Hl);if(e.avail_in!==0||s.lookahead!==0||t!==Ks&&s.status!==na){var o=s.strategy===Cr?dC(s,t):s.strategy===XA?fC(s,t):kn[s.level].func(s,t);if((o===Us||o===Mn)&&(s.status=na),o===me||o===Us)return e.avail_out===0&&(s.last_flush=-1),Si;if(o===Ca&&(t===jA?fi._tr_align(s):t!==td&&(fi._tr_stored_block(s,0,0,!1),t===VA&&(ys(s.head),s.lookahead===0&&(s.strstart=0,s.block_start=0,s.insert=0))),gs(e),e.avail_out===0))return s.last_flush=-1,Si}return t!==bs?Si:s.wrap<=0?ed:(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)):(Qn(s,e.adler>>>16),Qn(s,e.adler&65535)),gs(e),s.wrap>0&&(s.wrap=-s.wrap),s.pending!==0?Si:ed)}function wC(e){var t;return!e||!e.state?di:(t=e.state.status,t!==io&&t!==cc&&t!==Or&&t!==Fr&&t!==Nr&&t!==Os&&t!==na?ws(e,di):(e.state=null,t===Os?ws(e,qA):Si))}function bC(e,t){var i=t.length,s,n,a,r,l,o,u,c;if(!e||!e.state||(s=e.state,r=s.wrap,r===2||r===1&&s.status!==io||s.lookahead))return di;for(r===1&&(e.adler=Zg(e.adler,t,i,0)),s.wrap=0,i>=s.w_size&&(r===0&&(ys(s.head),s.strstart=0,s.block_start=0,s.insert=0),c=new Me.Buf8(s.w_size),Me.arraySet(c,t,i-s.w_size,s.w_size,0),t=c,i=s.w_size),l=e.avail_in,o=e.next_in,u=e.input,e.avail_in=i,e.next_in=0,e.input=t,$s(s);s.lookahead>=Wt;){n=s.strstart,a=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(--a);s.strstart=n,s.lookahead=Wt-1,$s(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=o,e.input=u,e.avail_in=l,s.wrap=r,Si}Ii.deflateInit=mC;Ii.deflateInit2=ev;Ii.deflateReset=tv;Ii.deflateResetKeep=Qg;Ii.deflateSetHeader=yC;Ii.deflate=pC;Ii.deflateEnd=wC;Ii.deflateSetDictionary=bC;Ii.deflateInfo="pako deflate (from Nodeca project)";var Xs={},so=Qi,iv=!0,sv=!0;try{String.fromCharCode.apply(null,[0])}catch{iv=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{sv=!1}var xa=new so.Buf8(256);for(var hs=0;hs<256;hs++)xa[hs]=hs>=252?6:hs>=248?5:hs>=240?4:hs>=224?3:hs>=192?2:1;xa[254]=xa[254]=1;Xs.string2buf=function(e){var t,i,s,n,a,r=e.length,l=0;for(n=0;n<r;n++)i=e.charCodeAt(n),(i&64512)===55296&&n+1<r&&(s=e.charCodeAt(n+1),(s&64512)===56320&&(i=65536+(i-55296<<10)+(s-56320),n++)),l+=i<128?1:i<2048?2:i<65536?3:4;for(t=new so.Buf8(l),a=0,n=0;a<l;n++)i=e.charCodeAt(n),(i&64512)===55296&&n+1<r&&(s=e.charCodeAt(n+1),(s&64512)===56320&&(i=65536+(i-55296<<10)+(s-56320),n++)),i<128?t[a++]=i:i<2048?(t[a++]=192|i>>>6,t[a++]=128|i&63):i<65536?(t[a++]=224|i>>>12,t[a++]=128|i>>>6&63,t[a++]=128|i&63):(t[a++]=240|i>>>18,t[a++]=128|i>>>12&63,t[a++]=128|i>>>6&63,t[a++]=128|i&63);return t};function nv(e,t){if(t<65534&&(e.subarray&&sv||!e.subarray&&iv))return String.fromCharCode.apply(null,so.shrinkBuf(e,t));for(var i="",s=0;s<t;s++)i+=String.fromCharCode(e[s]);return i}Xs.buf2binstring=function(e){return nv(e,e.length)};Xs.binstring2buf=function(e){for(var t=new so.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,a,r=t||e.length,l=new Array(r*2);for(s=0,i=0;i<r;){if(n=e[i++],n<128){l[s++]=n;continue}if(a=xa[n],a>4){l[s++]=65533,i+=a-1;continue}for(n&=a===2?31:a===3?15:7;a>1&&i<r;)n=n<<6|e[i++]&63,a--;if(a>1){l[s++]=65533;continue}n<65536?l[s++]=n:(n-=65536,l[s++]=55296|n>>10&1023,l[s++]=56320|n&1023)}return nv(l,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+xa[e[i]]>t?i:t};function xC(){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 av=xC,ha=Ii,ua=Qi,hc=Xs,uc=Pc,_C=av,rv=Object.prototype.toString,kC=0,Ul=4,Rn=0,sd=1,nd=2,EC=-1,AC=0,CC=8;function js(e){if(!(this instanceof js))return new js(e);this.options=ua.assign({level:EC,method:CC,chunkSize:16384,windowBits:15,memLevel:8,strategy:AC,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 _C,this.strm.avail_out=0;var i=ha.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(i!==Rn)throw new Error(uc[i]);if(t.header&&ha.deflateSetHeader(this.strm,t.header),t.dictionary){var s;if(typeof t.dictionary=="string"?s=hc.string2buf(t.dictionary):rv.call(t.dictionary)==="[object ArrayBuffer]"?s=new Uint8Array(t.dictionary):s=t.dictionary,i=ha.deflateSetDictionary(this.strm,s),i!==Rn)throw new Error(uc[i]);this._dict_set=!0}}js.prototype.push=function(e,t){var i=this.strm,s=this.options.chunkSize,n,a;if(this.ended)return!1;a=t===~~t?t:t===!0?Ul:kC,typeof e=="string"?i.input=hc.string2buf(e):rv.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 ua.Buf8(s),i.next_out=0,i.avail_out=s),n=ha.deflate(i,a),n!==sd&&n!==Rn)return this.onEnd(n),this.ended=!0,!1;(i.avail_out===0||i.avail_in===0&&(a===Ul||a===nd))&&(this.options.to==="string"?this.onData(hc.buf2binstring(ua.shrinkBuf(i.output,i.next_out))):this.onData(ua.shrinkBuf(i.output,i.next_out)))}while((i.avail_in>0||i.avail_out===0)&&n!==sd);return a===Ul?(n=ha.deflateEnd(this.strm),this.onEnd(n),this.ended=!0,n===Rn):(a===nd&&(this.onEnd(Rn),i.avail_out=0),!0)};js.prototype.onData=function(e){this.chunks.push(e)};js.prototype.onEnd=function(e){e===Rn&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=ua.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};function Ic(e,t){var i=new js(t);if(i.push(e,!0),i.err)throw i.msg||uc[i.err];return i.result}function RC(e,t){return t=t||{},t.raw=!0,Ic(e,t)}function TC(e,t){return t=t||{},t.gzip=!0,Ic(e,t)}Ea.Deflate=js;Ea.deflate=Ic;Ea.deflateRaw=RC;Ea.gzip=TC;var Ra={},bi={},Rr=30,SC=12,PC=function(t,i){var s,n,a,r,l,o,u,c,f,g,v,y,w,m,_,E,x,C,S,L,M,D,$,Q,R;s=t.state,n=t.next_in,Q=t.input,a=n+(t.avail_in-5),r=t.next_out,R=t.output,l=r-(i-t.avail_out),o=r+(t.avail_out-257),u=s.dmax,c=s.wsize,f=s.whave,g=s.wnext,v=s.window,y=s.hold,w=s.bits,m=s.lencode,_=s.distcode,E=(1<<s.lenbits)-1,x=(1<<s.distbits)-1;t:do{w<15&&(y+=Q[n++]<<w,w+=8,y+=Q[n++]<<w,w+=8),C=m[y&E];e:for(;;){if(S=C>>>24,y>>>=S,w-=S,S=C>>>16&255,S===0)R[r++]=C&65535;else if(S&16){L=C&65535,S&=15,S&&(w<S&&(y+=Q[n++]<<w,w+=8),L+=y&(1<<S)-1,y>>>=S,w-=S),w<15&&(y+=Q[n++]<<w,w+=8,y+=Q[n++]<<w,w+=8),C=_[y&x];i:for(;;){if(S=C>>>24,y>>>=S,w-=S,S=C>>>16&255,S&16){if(M=C&65535,S&=15,w<S&&(y+=Q[n++]<<w,w+=8,w<S&&(y+=Q[n++]<<w,w+=8)),M+=y&(1<<S)-1,M>u){t.msg="invalid distance too far back",s.mode=Rr;break t}if(y>>>=S,w-=S,S=r-l,M>S){if(S=M-S,S>f&&s.sane){t.msg="invalid distance too far back",s.mode=Rr;break t}if(D=0,$=v,g===0){if(D+=c-S,S<L){L-=S;do R[r++]=v[D++];while(--S);D=r-M,$=R}}else if(g<S){if(D+=c+g-S,S-=g,S<L){L-=S;do R[r++]=v[D++];while(--S);if(D=0,g<L){S=g,L-=S;do R[r++]=v[D++];while(--S);D=r-M,$=R}}}else if(D+=g-S,S<L){L-=S;do R[r++]=v[D++];while(--S);D=r-M,$=R}for(;L>2;)R[r++]=$[D++],R[r++]=$[D++],R[r++]=$[D++],L-=3;L&&(R[r++]=$[D++],L>1&&(R[r++]=$[D++]))}else{D=r-M;do R[r++]=R[D++],R[r++]=R[D++],R[r++]=R[D++],L-=3;while(L>2);L&&(R[r++]=R[D++],L>1&&(R[r++]=R[D++]))}}else if((S&64)===0){C=_[(C&65535)+(y&(1<<S)-1)];continue i}else{t.msg="invalid distance code",s.mode=Rr;break t}break}}else if((S&64)===0){C=m[(C&65535)+(y&(1<<S)-1)];continue e}else if(S&32){s.mode=SC;break t}else{t.msg="invalid literal/length code",s.mode=Rr;break t}break}}while(n<a&&r<o);L=w>>3,n-=L,w-=L<<3,y&=(1<<w)-1,t.next_in=n,t.next_out=r,t.avail_in=n<a?5+(a-n):5-(n-a),t.avail_out=r<o?257+(o-r):257-(r-o),s.hold=y,s.bits=w},ad=Qi,yn=15,rd=852,od=592,ld=0,$l=1,cd=2,IC=[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],LC=[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],DC=[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],MC=[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],BC=function(t,i,s,n,a,r,l,o){var u=o.bits,c=0,f=0,g=0,v=0,y=0,w=0,m=0,_=0,E=0,x=0,C,S,L,M,D,$=null,Q=0,R,T=new ad.Buf16(yn+1),P=new ad.Buf16(yn+1),O=null,Y=0,Z,at,V;for(c=0;c<=yn;c++)T[c]=0;for(f=0;f<n;f++)T[i[s+f]]++;for(y=u,v=yn;v>=1&&T[v]===0;v--);if(y>v&&(y=v),v===0)return a[r++]=1<<24|64<<16|0,a[r++]=1<<24|64<<16|0,o.bits=1,0;for(g=1;g<v&&T[g]===0;g++);for(y<g&&(y=g),_=1,c=1;c<=yn;c++)if(_<<=1,_-=T[c],_<0)return-1;if(_>0&&(t===ld||v!==1))return-1;for(P[1]=0,c=1;c<yn;c++)P[c+1]=P[c]+T[c];for(f=0;f<n;f++)i[s+f]!==0&&(l[P[i[s+f]]++]=f);if(t===ld?($=O=l,R=19):t===$l?($=IC,Q-=257,O=LC,Y-=257,R=256):($=DC,O=MC,R=-1),x=0,f=0,c=g,D=r,w=y,m=0,L=-1,E=1<<y,M=E-1,t===$l&&E>rd||t===cd&&E>od)return 1;for(;;){Z=c-m,l[f]<R?(at=0,V=l[f]):l[f]>R?(at=O[Y+l[f]],V=$[Q+l[f]]):(at=32+64,V=0),C=1<<c-m,S=1<<w,g=S;do S-=C,a[D+(x>>m)+S]=Z<<24|at<<16|V|0;while(S!==0);for(C=1<<c-1;x&C;)C>>=1;if(C!==0?(x&=C-1,x+=C):x=0,f++,--T[c]===0){if(c===v)break;c=i[s+l[f]]}if(c>y&&(x&M)!==L){for(m===0&&(m=y),D+=g,w=c-m,_=1<<w;w+m<v&&(_-=T[w+m],!(_<=0));)w++,_<<=1;if(E+=1<<w,t===$l&&E>rd||t===cd&&E>od)return 1;L=x&M,a[L]=y<<24|w<<16|D-r|0}}return x!==0&&(a[D+x]=c-m<<24|64<<16|0),o.bits=y,0},ei=Qi,fc=Xg,Ci=Gg,OC=PC,fa=BC,FC=0,ov=1,lv=2,hd=4,NC=5,Tr=6,Vs=0,zC=1,HC=2,gi=-2,cv=-3,hv=-4,WC=-5,ud=8,uv=1,fd=2,dd=3,gd=4,vd=5,yd=6,md=7,pd=8,wd=9,bd=10,Jr=11,Wi=12,jl=13,xd=14,Vl=15,_d=16,kd=17,Ed=18,Ad=19,Sr=20,Pr=21,Cd=22,Rd=23,Td=24,Sd=25,Pd=26,ql=27,Id=28,Ld=29,ae=30,fv=31,UC=32,$C=852,jC=592,VC=15,qC=VC;function Dd(e){return(e>>>24&255)+(e>>>8&65280)+((e&65280)<<8)+((e&255)<<24)}function YC(){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 ei.Buf16(320),this.work=new ei.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function dv(e){var t;return!e||!e.state?gi:(t=e.state,e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=t.wrap&1),t.mode=uv,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new ei.Buf32($C),t.distcode=t.distdyn=new ei.Buf32(jC),t.sane=1,t.back=-1,Vs)}function gv(e){var t;return!e||!e.state?gi:(t=e.state,t.wsize=0,t.whave=0,t.wnext=0,dv(e))}function vv(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))?gi:(s.window!==null&&s.wbits!==t&&(s.window=null),s.wrap=i,s.wbits=t,gv(e))}function yv(e,t){var i,s;return e?(s=new YC,e.state=s,s.window=null,i=vv(e,t),i!==Vs&&(e.state=null),i):gi}function KC(e){return yv(e,qC)}var Md=!0,Yl,Kl;function XC(e){if(Md){var t;for(Yl=new ei.Buf32(512),Kl=new ei.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(fa(ov,e.lens,0,288,Yl,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;fa(lv,e.lens,0,32,Kl,0,e.work,{bits:5}),Md=!1}e.lencode=Yl,e.lenbits=9,e.distcode=Kl,e.distbits=5}function mv(e,t,i,s){var n,a=e.state;return a.window===null&&(a.wsize=1<<a.wbits,a.wnext=0,a.whave=0,a.window=new ei.Buf8(a.wsize)),s>=a.wsize?(ei.arraySet(a.window,t,i-a.wsize,a.wsize,0),a.wnext=0,a.whave=a.wsize):(n=a.wsize-a.wnext,n>s&&(n=s),ei.arraySet(a.window,t,i-s,n,a.wnext),s-=n,s?(ei.arraySet(a.window,t,i-s,s,0),a.wnext=s,a.whave=a.wsize):(a.wnext+=n,a.wnext===a.wsize&&(a.wnext=0),a.whave<a.wsize&&(a.whave+=n))),0}function GC(e,t){var i,s,n,a,r,l,o,u,c,f,g,v,y,w,m=0,_,E,x,C,S,L,M,D,$=new ei.Buf8(4),Q,R,T=[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 gi;i=e.state,i.mode===Wi&&(i.mode=jl),r=e.next_out,n=e.output,o=e.avail_out,a=e.next_in,s=e.input,l=e.avail_in,u=i.hold,c=i.bits,f=l,g=o,D=Vs;t:for(;;)switch(i.mode){case uv:if(i.wrap===0){i.mode=jl;break}for(;c<16;){if(l===0)break t;l--,u+=s[a++]<<c,c+=8}if(i.wrap&2&&u===35615){i.check=0,$[0]=u&255,$[1]=u>>>8&255,i.check=Ci(i.check,$,2,0),u=0,c=0,i.mode=fd;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=ae;break}if((u&15)!==ud){e.msg="unknown compression method",i.mode=ae;break}if(u>>>=4,c-=4,M=(u&15)+8,i.wbits===0)i.wbits=M;else if(M>i.wbits){e.msg="invalid window size",i.mode=ae;break}i.dmax=1<<M,e.adler=i.check=1,i.mode=u&512?bd:Wi,u=0,c=0;break;case fd:for(;c<16;){if(l===0)break t;l--,u+=s[a++]<<c,c+=8}if(i.flags=u,(i.flags&255)!==ud){e.msg="unknown compression method",i.mode=ae;break}if(i.flags&57344){e.msg="unknown header flags set",i.mode=ae;break}i.head&&(i.head.text=u>>8&1),i.flags&512&&($[0]=u&255,$[1]=u>>>8&255,i.check=Ci(i.check,$,2,0)),u=0,c=0,i.mode=dd;case dd:for(;c<32;){if(l===0)break t;l--,u+=s[a++]<<c,c+=8}i.head&&(i.head.time=u),i.flags&512&&($[0]=u&255,$[1]=u>>>8&255,$[2]=u>>>16&255,$[3]=u>>>24&255,i.check=Ci(i.check,$,4,0)),u=0,c=0,i.mode=gd;case gd:for(;c<16;){if(l===0)break t;l--,u+=s[a++]<<c,c+=8}i.head&&(i.head.xflags=u&255,i.head.os=u>>8),i.flags&512&&($[0]=u&255,$[1]=u>>>8&255,i.check=Ci(i.check,$,2,0)),u=0,c=0,i.mode=vd;case vd:if(i.flags&1024){for(;c<16;){if(l===0)break t;l--,u+=s[a++]<<c,c+=8}i.length=u,i.head&&(i.head.extra_len=u),i.flags&512&&($[0]=u&255,$[1]=u>>>8&255,i.check=Ci(i.check,$,2,0)),u=0,c=0}else i.head&&(i.head.extra=null);i.mode=yd;case yd:if(i.flags&1024&&(v=i.length,v>l&&(v=l),v&&(i.head&&(M=i.head.extra_len-i.length,i.head.extra||(i.head.extra=new Array(i.head.extra_len)),ei.arraySet(i.head.extra,s,a,v,M)),i.flags&512&&(i.check=Ci(i.check,s,v,a)),l-=v,a+=v,i.length-=v),i.length))break t;i.length=0,i.mode=md;case md:if(i.flags&2048){if(l===0)break t;v=0;do M=s[a+v++],i.head&&M&&i.length<65536&&(i.head.name+=String.fromCharCode(M));while(M&&v<l);if(i.flags&512&&(i.check=Ci(i.check,s,v,a)),l-=v,a+=v,M)break t}else i.head&&(i.head.name=null);i.length=0,i.mode=pd;case pd:if(i.flags&4096){if(l===0)break t;v=0;do M=s[a+v++],i.head&&M&&i.length<65536&&(i.head.comment+=String.fromCharCode(M));while(M&&v<l);if(i.flags&512&&(i.check=Ci(i.check,s,v,a)),l-=v,a+=v,M)break t}else i.head&&(i.head.comment=null);i.mode=wd;case wd:if(i.flags&512){for(;c<16;){if(l===0)break t;l--,u+=s[a++]<<c,c+=8}if(u!==(i.check&65535)){e.msg="header crc mismatch",i.mode=ae;break}u=0,c=0}i.head&&(i.head.hcrc=i.flags>>9&1,i.head.done=!0),e.adler=i.check=0,i.mode=Wi;break;case bd:for(;c<32;){if(l===0)break t;l--,u+=s[a++]<<c,c+=8}e.adler=i.check=Dd(u),u=0,c=0,i.mode=Jr;case Jr:if(i.havedict===0)return e.next_out=r,e.avail_out=o,e.next_in=a,e.avail_in=l,i.hold=u,i.bits=c,HC;e.adler=i.check=1,i.mode=Wi;case Wi:if(t===NC||t===Tr)break t;case jl:if(i.last){u>>>=c&7,c-=c&7,i.mode=ql;break}for(;c<3;){if(l===0)break t;l--,u+=s[a++]<<c,c+=8}switch(i.last=u&1,u>>>=1,c-=1,u&3){case 0:i.mode=xd;break;case 1:if(XC(i),i.mode=Sr,t===Tr){u>>>=2,c-=2;break t}break;case 2:i.mode=kd;break;case 3:e.msg="invalid block type",i.mode=ae}u>>>=2,c-=2;break;case xd:for(u>>>=c&7,c-=c&7;c<32;){if(l===0)break t;l--,u+=s[a++]<<c,c+=8}if((u&65535)!==(u>>>16^65535)){e.msg="invalid stored block lengths",i.mode=ae;break}if(i.length=u&65535,u=0,c=0,i.mode=Vl,t===Tr)break t;case Vl:i.mode=_d;case _d:if(v=i.length,v){if(v>l&&(v=l),v>o&&(v=o),v===0)break t;ei.arraySet(n,s,a,v,r),l-=v,a+=v,o-=v,r+=v,i.length-=v;break}i.mode=Wi;break;case kd:for(;c<14;){if(l===0)break t;l--,u+=s[a++]<<c,c+=8}if(i.nlen=(u&31)+257,u>>>=5,c-=5,i.ndist=(u&31)+1,u>>>=5,c-=5,i.ncode=(u&15)+4,u>>>=4,c-=4,i.nlen>286||i.ndist>30){e.msg="too many length or distance symbols",i.mode=ae;break}i.have=0,i.mode=Ed;case Ed:for(;i.have<i.ncode;){for(;c<3;){if(l===0)break t;l--,u+=s[a++]<<c,c+=8}i.lens[T[i.have++]]=u&7,u>>>=3,c-=3}for(;i.have<19;)i.lens[T[i.have++]]=0;if(i.lencode=i.lendyn,i.lenbits=7,Q={bits:i.lenbits},D=fa(FC,i.lens,0,19,i.lencode,0,i.work,Q),i.lenbits=Q.bits,D){e.msg="invalid code lengths set",i.mode=ae;break}i.have=0,i.mode=Ad;case Ad:for(;i.have<i.nlen+i.ndist;){for(;m=i.lencode[u&(1<<i.lenbits)-1],_=m>>>24,E=m>>>16&255,x=m&65535,!(_<=c);){if(l===0)break t;l--,u+=s[a++]<<c,c+=8}if(x<16)u>>>=_,c-=_,i.lens[i.have++]=x;else{if(x===16){for(R=_+2;c<R;){if(l===0)break t;l--,u+=s[a++]<<c,c+=8}if(u>>>=_,c-=_,i.have===0){e.msg="invalid bit length repeat",i.mode=ae;break}M=i.lens[i.have-1],v=3+(u&3),u>>>=2,c-=2}else if(x===17){for(R=_+3;c<R;){if(l===0)break t;l--,u+=s[a++]<<c,c+=8}u>>>=_,c-=_,M=0,v=3+(u&7),u>>>=3,c-=3}else{for(R=_+7;c<R;){if(l===0)break t;l--,u+=s[a++]<<c,c+=8}u>>>=_,c-=_,M=0,v=11+(u&127),u>>>=7,c-=7}if(i.have+v>i.nlen+i.ndist){e.msg="invalid bit length repeat",i.mode=ae;break}for(;v--;)i.lens[i.have++]=M}}if(i.mode===ae)break;if(i.lens[256]===0){e.msg="invalid code -- missing end-of-block",i.mode=ae;break}if(i.lenbits=9,Q={bits:i.lenbits},D=fa(ov,i.lens,0,i.nlen,i.lencode,0,i.work,Q),i.lenbits=Q.bits,D){e.msg="invalid literal/lengths set",i.mode=ae;break}if(i.distbits=6,i.distcode=i.distdyn,Q={bits:i.distbits},D=fa(lv,i.lens,i.nlen,i.ndist,i.distcode,0,i.work,Q),i.distbits=Q.bits,D){e.msg="invalid distances set",i.mode=ae;break}if(i.mode=Sr,t===Tr)break t;case Sr:i.mode=Pr;case Pr:if(l>=6&&o>=258){e.next_out=r,e.avail_out=o,e.next_in=a,e.avail_in=l,i.hold=u,i.bits=c,OC(e,g),r=e.next_out,n=e.output,o=e.avail_out,a=e.next_in,s=e.input,l=e.avail_in,u=i.hold,c=i.bits,i.mode===Wi&&(i.back=-1);break}for(i.back=0;m=i.lencode[u&(1<<i.lenbits)-1],_=m>>>24,E=m>>>16&255,x=m&65535,!(_<=c);){if(l===0)break t;l--,u+=s[a++]<<c,c+=8}if(E&&(E&240)===0){for(C=_,S=E,L=x;m=i.lencode[L+((u&(1<<C+S)-1)>>C)],_=m>>>24,E=m>>>16&255,x=m&65535,!(C+_<=c);){if(l===0)break t;l--,u+=s[a++]<<c,c+=8}u>>>=C,c-=C,i.back+=C}if(u>>>=_,c-=_,i.back+=_,i.length=x,E===0){i.mode=Pd;break}if(E&32){i.back=-1,i.mode=Wi;break}if(E&64){e.msg="invalid literal/length code",i.mode=ae;break}i.extra=E&15,i.mode=Cd;case Cd:if(i.extra){for(R=i.extra;c<R;){if(l===0)break t;l--,u+=s[a++]<<c,c+=8}i.length+=u&(1<<i.extra)-1,u>>>=i.extra,c-=i.extra,i.back+=i.extra}i.was=i.length,i.mode=Rd;case Rd:for(;m=i.distcode[u&(1<<i.distbits)-1],_=m>>>24,E=m>>>16&255,x=m&65535,!(_<=c);){if(l===0)break t;l--,u+=s[a++]<<c,c+=8}if((E&240)===0){for(C=_,S=E,L=x;m=i.distcode[L+((u&(1<<C+S)-1)>>C)],_=m>>>24,E=m>>>16&255,x=m&65535,!(C+_<=c);){if(l===0)break t;l--,u+=s[a++]<<c,c+=8}u>>>=C,c-=C,i.back+=C}if(u>>>=_,c-=_,i.back+=_,E&64){e.msg="invalid distance code",i.mode=ae;break}i.offset=x,i.extra=E&15,i.mode=Td;case Td:if(i.extra){for(R=i.extra;c<R;){if(l===0)break t;l--,u+=s[a++]<<c,c+=8}i.offset+=u&(1<<i.extra)-1,u>>>=i.extra,c-=i.extra,i.back+=i.extra}if(i.offset>i.dmax){e.msg="invalid distance too far back",i.mode=ae;break}i.mode=Sd;case Sd:if(o===0)break t;if(v=g-o,i.offset>v){if(v=i.offset-v,v>i.whave&&i.sane){e.msg="invalid distance too far back",i.mode=ae;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=r-i.offset,v=i.length;v>o&&(v=o),o-=v,i.length-=v;do n[r++]=w[y++];while(--v);i.length===0&&(i.mode=Pr);break;case Pd:if(o===0)break t;n[r++]=i.length,o--,i.mode=Pr;break;case ql:if(i.wrap){for(;c<32;){if(l===0)break t;l--,u|=s[a++]<<c,c+=8}if(g-=o,e.total_out+=g,i.total+=g,g&&(e.adler=i.check=i.flags?Ci(i.check,n,g,r-g):fc(i.check,n,g,r-g)),g=o,(i.flags?u:Dd(u))!==i.check){e.msg="incorrect data check",i.mode=ae;break}u=0,c=0}i.mode=Id;case Id:if(i.wrap&&i.flags){for(;c<32;){if(l===0)break t;l--,u+=s[a++]<<c,c+=8}if(u!==(i.total&4294967295)){e.msg="incorrect length check",i.mode=ae;break}u=0,c=0}i.mode=Ld;case Ld:D=zC;break t;case ae:D=cv;break t;case fv:return hv;case UC:default:return gi}return e.next_out=r,e.avail_out=o,e.next_in=a,e.avail_in=l,i.hold=u,i.bits=c,(i.wsize||g!==e.avail_out&&i.mode<ae&&(i.mode<ql||t!==hd))&&mv(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):fc(i.check,n,g,e.next_out-g)),e.data_type=i.bits+(i.last?64:0)+(i.mode===Wi?128:0)+(i.mode===Sr||i.mode===Vl?256:0),(f===0&&g===0||t===hd)&&D===Vs&&(D=WC),D}function ZC(e){if(!e||!e.state)return gi;var t=e.state;return t.window&&(t.window=null),e.state=null,Vs}function JC(e,t){var i;return!e||!e.state||(i=e.state,(i.wrap&2)===0)?gi:(i.head=t,t.done=!1,Vs)}function QC(e,t){var i=t.length,s,n,a;return!e||!e.state||(s=e.state,s.wrap!==0&&s.mode!==Jr)?gi:s.mode===Jr&&(n=1,n=fc(n,t,i,0),n!==s.check)?cv:(a=mv(e,t,i,i),a?(s.mode=fv,hv):(s.havedict=1,Vs))}bi.inflateReset=gv;bi.inflateReset2=vv;bi.inflateResetKeep=dv;bi.inflateInit=KC;bi.inflateInit2=yv;bi.inflate=GC;bi.inflateEnd=ZC;bi.inflateGetHeader=JC;bi.inflateSetDictionary=QC;bi.inflateInfo="pako inflate (from Nodeca project)";var pv={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 tR(){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 eR=tR,Tn=bi,da=Qi,zr=Xs,de=pv,dc=Pc,iR=av,sR=eR,wv=Object.prototype.toString;function qs(e){if(!(this instanceof qs))return new qs(e);this.options=da.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 iR,this.strm.avail_out=0;var i=Tn.inflateInit2(this.strm,t.windowBits);if(i!==de.Z_OK)throw new Error(dc[i]);if(this.header=new sR,Tn.inflateGetHeader(this.strm,this.header),t.dictionary&&(typeof t.dictionary=="string"?t.dictionary=zr.string2buf(t.dictionary):wv.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(dc[i])}qs.prototype.push=function(e,t){var i=this.strm,s=this.options.chunkSize,n=this.options.dictionary,a,r,l,o,u,c=!1;if(this.ended)return!1;r=t===~~t?t:t===!0?de.Z_FINISH:de.Z_NO_FLUSH,typeof e=="string"?i.input=zr.binstring2buf(e):wv.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 da.Buf8(s),i.next_out=0,i.avail_out=s),a=Tn.inflate(i,de.Z_NO_FLUSH),a===de.Z_NEED_DICT&&n&&(a=Tn.inflateSetDictionary(this.strm,n)),a===de.Z_BUF_ERROR&&c===!0&&(a=de.Z_OK,c=!1),a!==de.Z_STREAM_END&&a!==de.Z_OK)return this.onEnd(a),this.ended=!0,!1;i.next_out&&(i.avail_out===0||a===de.Z_STREAM_END||i.avail_in===0&&(r===de.Z_FINISH||r===de.Z_SYNC_FLUSH))&&(this.options.to==="string"?(l=zr.utf8border(i.output,i.next_out),o=i.next_out-l,u=zr.buf2string(i.output,l),i.next_out=o,i.avail_out=s-o,o&&da.arraySet(i.output,i.output,l,o,0),this.onData(u)):this.onData(da.shrinkBuf(i.output,i.next_out))),i.avail_in===0&&i.avail_out===0&&(c=!0)}while((i.avail_in>0||i.avail_out===0)&&a!==de.Z_STREAM_END);return a===de.Z_STREAM_END&&(r=de.Z_FINISH),r===de.Z_FINISH?(a=Tn.inflateEnd(this.strm),this.onEnd(a),this.ended=!0,a===de.Z_OK):(r===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=da.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};function Lc(e,t){var i=new qs(t);if(i.push(e,!0),i.err)throw i.msg||dc[i.err];return i.result}function nR(e,t){return t=t||{},t.raw=!0,Lc(e,t)}Ra.Inflate=qs;Ra.inflate=Lc;Ra.inflateRaw=nR;Ra.ungzip=Lc;var aR=Qi.assign,rR=Ea,oR=Ra,lR=pv,bv={};aR(bv,rR,oR,lR);var PR=bv,gc={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,a="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",r="Expected a function",l="Invalid `variable` option passed into `_.template`",o="__lodash_hash_undefined__",u=500,c="__lodash_placeholder__",f=1,g=2,v=4,y=1,w=2,m=1,_=2,E=4,x=8,C=16,S=32,L=64,M=128,D=256,$=512,Q=30,R="...",T=800,P=16,O=1,Y=2,Z=3,at=1/0,V=9007199254740991,H=17976931348623157e292,j=0/0,K=4294967295,U=K-1,tt=K>>>1,st=[["ary",M],["bind",m],["bindKey",_],["curry",x],["curryRight",C],["flip",$],["partial",S],["partialRight",L],["rearg",D]],et="[object Arguments]",ut="[object Array]",ct="[object AsyncFunction]",ot="[object Boolean]",b="[object Date]",k="[object DOMException]",I="[object Error]",N="[object Function]",X="[object GeneratorFunction]",G="[object Map]",rt="[object Number]",mt="[object Null]",yt="[object Object]",Et="[object Promise]",Tt="[object Proxy]",be="[object RegExp]",se="[object Set]",xe="[object String]",Vt="[object Symbol]",te="[object Undefined]",xi="[object WeakMap]",xv="[object WeakSet]",Bn="[object ArrayBuffer]",Gs="[object DataView]",no="[object Float32Array]",ao="[object Float64Array]",ro="[object Int8Array]",oo="[object Int16Array]",lo="[object Int32Array]",co="[object Uint8Array]",ho="[object Uint8ClampedArray]",uo="[object Uint16Array]",fo="[object Uint32Array]",_v=/\b__p \+= '';/g,kv=/\b(__p \+=) '' \+/g,Ev=/(__e\(.*?\)|\b__t\)) \+\n'';/g,Dc=/&(?:amp|lt|gt|quot|#39);/g,Mc=/[&<>"']/g,Av=RegExp(Dc.source),Cv=RegExp(Mc.source),Rv=/<%-([\s\S]+?)%>/g,Tv=/<%([\s\S]+?)%>/g,Bc=/<%=([\s\S]+?)%>/g,Sv=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Pv=/^\w*$/,Iv=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,go=/[\\^$.*+?()[\]{}|]/g,Lv=RegExp(go.source),vo=/^\s+/,Dv=/\s/,Mv=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,Bv=/\{\n\/\* \[wrapped with (.+)\] \*/,Ov=/,? & /,Fv=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,Nv=/[()=,{}\[\]\/\s]/,zv=/\\(\\)?/g,Hv=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,Oc=/\w*$/,Wv=/^[-+]0x[0-9a-f]+$/i,Uv=/^0b[01]+$/i,$v=/^\[object .+?Constructor\]$/,jv=/^0o[0-7]+$/i,Vv=/^(?:0|[1-9]\d*)$/,qv=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Ta=/($^)/,Yv=/['\n\r\u2028\u2029\\]/g,Sa="\\ud800-\\udfff",Kv="\\u0300-\\u036f",Xv="\\ufe20-\\ufe2f",Gv="\\u20d0-\\u20ff",Fc=Kv+Xv+Gv,Nc="\\u2700-\\u27bf",zc="a-z\\xdf-\\xf6\\xf8-\\xff",Zv="\\xac\\xb1\\xd7\\xf7",Jv="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",Qv="\\u2000-\\u206f",ty=" \\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",Hc="A-Z\\xc0-\\xd6\\xd8-\\xde",Wc="\\ufe0e\\ufe0f",Uc=Zv+Jv+Qv+ty,yo="['\u2019]",ey="["+Sa+"]",$c="["+Uc+"]",Pa="["+Fc+"]",jc="\\d+",iy="["+Nc+"]",Vc="["+zc+"]",qc="[^"+Sa+Uc+jc+Nc+zc+Hc+"]",mo="\\ud83c[\\udffb-\\udfff]",sy="(?:"+Pa+"|"+mo+")",Yc="[^"+Sa+"]",po="(?:\\ud83c[\\udde6-\\uddff]){2}",wo="[\\ud800-\\udbff][\\udc00-\\udfff]",Zs="["+Hc+"]",Kc="\\u200d",Xc="(?:"+Vc+"|"+qc+")",ny="(?:"+Zs+"|"+qc+")",Gc="(?:"+yo+"(?:d|ll|m|re|s|t|ve))?",Zc="(?:"+yo+"(?:D|LL|M|RE|S|T|VE))?",Jc=sy+"?",Qc="["+Wc+"]?",ay="(?:"+Kc+"(?:"+[Yc,po,wo].join("|")+")"+Qc+Jc+")*",ry="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",oy="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",th=Qc+Jc+ay,ly="(?:"+[iy,po,wo].join("|")+")"+th,cy="(?:"+[Yc+Pa+"?",Pa,po,wo,ey].join("|")+")",hy=RegExp(yo,"g"),uy=RegExp(Pa,"g"),bo=RegExp(mo+"(?="+mo+")|"+cy+th,"g"),fy=RegExp([Zs+"?"+Vc+"+"+Gc+"(?="+[$c,Zs,"$"].join("|")+")",ny+"+"+Zc+"(?="+[$c,Zs+Xc,"$"].join("|")+")",Zs+"?"+Xc+"+"+Gc,Zs+"+"+Zc,oy,ry,jc,ly].join("|"),"g"),dy=RegExp("["+Kc+Sa+Fc+Wc+"]"),gy=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,vy=["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"],yy=-1,ie={};ie[no]=ie[ao]=ie[ro]=ie[oo]=ie[lo]=ie[co]=ie[ho]=ie[uo]=ie[fo]=!0,ie[et]=ie[ut]=ie[Bn]=ie[ot]=ie[Gs]=ie[b]=ie[I]=ie[N]=ie[G]=ie[rt]=ie[yt]=ie[be]=ie[se]=ie[xe]=ie[xi]=!1;var ee={};ee[et]=ee[ut]=ee[Bn]=ee[Gs]=ee[ot]=ee[b]=ee[no]=ee[ao]=ee[ro]=ee[oo]=ee[lo]=ee[G]=ee[rt]=ee[yt]=ee[be]=ee[se]=ee[xe]=ee[Vt]=ee[co]=ee[ho]=ee[uo]=ee[fo]=!0,ee[I]=ee[N]=ee[xi]=!1;var my={\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"},py={"&":"&","<":"<",">":">",'"':""","'":"'"},wy={"&":"&","<":"<",">":">",""":'"',"'":"'"},by={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},xy=parseFloat,_y=parseInt,eh=typeof De=="object"&&De&&De.Object===Object&&De,ky=typeof self=="object"&&self&&self.Object===Object&&self,_e=eh||ky||Function("return this")(),xo=t&&!t.nodeType&&t,xs=xo&&!0&&e&&!e.nodeType&&e,ih=xs&&xs.exports===xo,_o=ih&&eh.process,ii=function(){try{var it=xs&&xs.require&&xs.require("util").types;return it||_o&&_o.binding&&_o.binding("util")}catch{}}(),sh=ii&&ii.isArrayBuffer,nh=ii&&ii.isDate,ah=ii&&ii.isMap,rh=ii&&ii.isRegExp,oh=ii&&ii.isSet,lh=ii&&ii.isTypedArray;function qe(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 Ey(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 si(it,ft){for(var lt=-1,wt=it==null?0:it.length;++lt<wt&&ft(it[lt],lt,it)!==!1;);return it}function Ay(it,ft){for(var lt=it==null?0:it.length;lt--&&ft(it[lt],lt,it)!==!1;);return it}function ch(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 ts(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 Ia(it,ft){var lt=it==null?0:it.length;return!!lt&&Js(it,ft,0)>-1}function ko(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 es(it,ft){for(var lt=-1,wt=ft.length,St=it.length;++lt<wt;)it[St+lt]=ft[lt];return it}function Eo(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 Cy(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 Ao(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 Ry=Co("length");function Ty(it){return it.split("")}function Sy(it){return it.match(Fv)||[]}function hh(it,ft,lt){var wt;return lt(it,function(St,qt,ve){if(ft(St,qt,ve))return wt=qt,!1}),wt}function La(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?Wy(it,ft,lt):La(it,uh,lt)}function Py(it,ft,lt,wt){for(var St=lt-1,qt=it.length;++St<qt;)if(wt(it[St],ft))return St;return-1}function uh(it){return it!==it}function fh(it,ft){var lt=it==null?0:it.length;return lt?To(it,ft)/lt:j}function Co(it){return function(ft){return ft==null?i:ft[it]}}function Ro(it){return function(ft){return it==null?i:it[ft]}}function dh(it,ft,lt,wt,St){return St(it,function(qt,ve,Zt){lt=wt?(wt=!1,qt):ft(lt,qt,ve,Zt)}),lt}function Iy(it,ft){var lt=it.length;for(it.sort(ft);lt--;)it[lt]=it[lt].value;return it}function To(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 So(it,ft){for(var lt=-1,wt=Array(it);++lt<it;)wt[lt]=ft(lt);return wt}function Ly(it,ft){return ne(ft,function(lt){return[lt,it[lt]]})}function gh(it){return it&&it.slice(0,ph(it)+1).replace(vo,"")}function Ye(it){return function(ft){return it(ft)}}function Po(it,ft){return ne(ft,function(lt){return it[lt]})}function On(it,ft){return it.has(ft)}function vh(it,ft){for(var lt=-1,wt=it.length;++lt<wt&&Js(ft,it[lt],0)>-1;);return lt}function yh(it,ft){for(var lt=it.length;lt--&&Js(ft,it[lt],0)>-1;);return lt}function Dy(it,ft){for(var lt=it.length,wt=0;lt--;)it[lt]===ft&&++wt;return wt}var My=Ro(my),By=Ro(py);function Oy(it){return"\\"+by[it]}function Fy(it,ft){return it==null?i:it[ft]}function Qs(it){return dy.test(it)}function Ny(it){return gy.test(it)}function zy(it){for(var ft,lt=[];!(ft=it.next()).done;)lt.push(ft.value);return lt}function Io(it){var ft=-1,lt=Array(it.size);return it.forEach(function(wt,St){lt[++ft]=[St,wt]}),lt}function mh(it,ft){return function(lt){return it(ft(lt))}}function is(it,ft){for(var lt=-1,wt=it.length,St=0,qt=[];++lt<wt;){var ve=it[lt];(ve===ft||ve===c)&&(it[lt]=c,qt[St++]=lt)}return qt}function Da(it){var ft=-1,lt=Array(it.size);return it.forEach(function(wt){lt[++ft]=wt}),lt}function Hy(it){var ft=-1,lt=Array(it.size);return it.forEach(function(wt){lt[++ft]=[wt,wt]}),lt}function Wy(it,ft,lt){for(var wt=lt-1,St=it.length;++wt<St;)if(it[wt]===ft)return wt;return-1}function Uy(it,ft,lt){for(var wt=lt+1;wt--;)if(it[wt]===ft)return wt;return wt}function tn(it){return Qs(it)?jy(it):Ry(it)}function vi(it){return Qs(it)?Vy(it):Ty(it)}function ph(it){for(var ft=it.length;ft--&&Dv.test(it.charAt(ft)););return ft}var $y=Ro(wy);function jy(it){for(var ft=bo.lastIndex=0;bo.test(it);)++ft;return ft}function Vy(it){return it.match(bo)||[]}function qy(it){return it.match(fy)||[]}var Yy=function it(ft){ft=ft==null?_e:en.defaults(_e.Object(),ft,en.pick(_e,vy));var lt=ft.Array,wt=ft.Date,St=ft.Error,qt=ft.Function,ve=ft.Math,Zt=ft.Object,Lo=ft.RegExp,Ky=ft.String,ni=ft.TypeError,Ma=lt.prototype,Xy=qt.prototype,sn=Zt.prototype,Ba=ft["__core-js_shared__"],Oa=Xy.toString,Xt=sn.hasOwnProperty,Gy=0,wh=function(){var h=/[^.]+$/.exec(Ba&&Ba.keys&&Ba.keys.IE_PROTO||"");return h?"Symbol(src)_1."+h:""}(),Fa=sn.toString,Zy=Oa.call(Zt),Jy=_e._,Qy=Lo("^"+Oa.call(Xt).replace(go,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Na=ih?ft.Buffer:i,ss=ft.Symbol,za=ft.Uint8Array,bh=Na?Na.allocUnsafe:i,Ha=mh(Zt.getPrototypeOf,Zt),xh=Zt.create,_h=sn.propertyIsEnumerable,Wa=Ma.splice,kh=ss?ss.isConcatSpreadable:i,Fn=ss?ss.iterator:i,_s=ss?ss.toStringTag:i,Ua=function(){try{var h=Rs(Zt,"defineProperty");return h({},"",{}),h}catch{}}(),t0=ft.clearTimeout!==_e.clearTimeout&&ft.clearTimeout,e0=wt&&wt.now!==_e.Date.now&&wt.now,i0=ft.setTimeout!==_e.setTimeout&&ft.setTimeout,$a=ve.ceil,ja=ve.floor,Do=Zt.getOwnPropertySymbols,s0=Na?Na.isBuffer:i,Eh=ft.isFinite,n0=Ma.join,a0=mh(Zt.keys,Zt),ye=ve.max,Te=ve.min,r0=wt.now,o0=ft.parseInt,Ah=ve.random,l0=Ma.reverse,Mo=Rs(ft,"DataView"),Nn=Rs(ft,"Map"),Bo=Rs(ft,"Promise"),nn=Rs(ft,"Set"),zn=Rs(ft,"WeakMap"),Hn=Rs(Zt,"create"),Va=zn&&new zn,an={},c0=Ts(Mo),h0=Ts(Nn),u0=Ts(Bo),f0=Ts(nn),d0=Ts(zn),qa=ss?ss.prototype:i,Wn=qa?qa.valueOf:i,Ch=qa?qa.toString:i;function F(h){if(ce(h)&&!Pt(h)&&!(h instanceof Nt)){if(h instanceof ai)return h;if(Xt.call(h,"__wrapped__"))return Ru(h)}return new ai(h)}var rn=function(){function h(){}return function(d){if(!oe(d))return{};if(xh)return xh(d);h.prototype=d;var p=new h;return h.prototype=i,p}}();function Ya(){}function ai(h,d){this.__wrapped__=h,this.__actions__=[],this.__chain__=!!d,this.__index__=0,this.__values__=i}F.templateSettings={escape:Rv,evaluate:Tv,interpolate:Bc,variable:"",imports:{_:F}},F.prototype=Ya.prototype,F.prototype.constructor=F,ai.prototype=rn(Ya.prototype),ai.prototype.constructor=ai;function Nt(h){this.__wrapped__=h,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=K,this.__views__=[]}function g0(){var h=new Nt(this.__wrapped__);return h.__actions__=Oe(this.__actions__),h.__dir__=this.__dir__,h.__filtered__=this.__filtered__,h.__iteratees__=Oe(this.__iteratees__),h.__takeCount__=this.__takeCount__,h.__views__=Oe(this.__views__),h}function v0(){if(this.__filtered__){var h=new Nt(this);h.__dir__=-1,h.__filtered__=!0}else h=this.clone(),h.__dir__*=-1;return h}function y0(){var h=this.__wrapped__.value(),d=this.__dir__,p=Pt(h),A=d<0,B=p?h.length:0,z=Tm(0,B,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=Te(nt,this.__takeCount__);if(!p||!A&&B==nt&&_t==nt)return Gh(h,this.__actions__);var Ct=[];t:for(;nt--&&pt<_t;){dt+=d;for(var Mt=-1,Rt=h[dt];++Mt<vt;){var Ft=gt[Mt],Ht=Ft.iteratee,Ge=Ft.type,Le=Ht(Rt);if(Ge==Y)Rt=Le;else if(!Le){if(Ge==O)continue t;break t}}Ct[pt++]=Rt}return Ct}Nt.prototype=rn(Ya.prototype),Nt.prototype.constructor=Nt;function ks(h){var d=-1,p=h==null?0:h.length;for(this.clear();++d<p;){var A=h[d];this.set(A[0],A[1])}}function m0(){this.__data__=Hn?Hn(null):{},this.size=0}function p0(h){var d=this.has(h)&&delete this.__data__[h];return this.size-=d?1:0,d}function w0(h){var d=this.__data__;if(Hn){var p=d[h];return p===o?i:p}return Xt.call(d,h)?d[h]:i}function b0(h){var d=this.__data__;return Hn?d[h]!==i:Xt.call(d,h)}function x0(h,d){var p=this.__data__;return this.size+=this.has(h)?0:1,p[h]=Hn&&d===i?o:d,this}ks.prototype.clear=m0,ks.prototype.delete=p0,ks.prototype.get=w0,ks.prototype.has=b0,ks.prototype.set=x0;function Li(h){var d=-1,p=h==null?0:h.length;for(this.clear();++d<p;){var A=h[d];this.set(A[0],A[1])}}function _0(){this.__data__=[],this.size=0}function k0(h){var d=this.__data__,p=Ka(d,h);if(p<0)return!1;var A=d.length-1;return p==A?d.pop():Wa.call(d,p,1),--this.size,!0}function E0(h){var d=this.__data__,p=Ka(d,h);return p<0?i:d[p][1]}function A0(h){return Ka(this.__data__,h)>-1}function C0(h,d){var p=this.__data__,A=Ka(p,h);return A<0?(++this.size,p.push([h,d])):p[A][1]=d,this}Li.prototype.clear=_0,Li.prototype.delete=k0,Li.prototype.get=E0,Li.prototype.has=A0,Li.prototype.set=C0;function Di(h){var d=-1,p=h==null?0:h.length;for(this.clear();++d<p;){var A=h[d];this.set(A[0],A[1])}}function R0(){this.size=0,this.__data__={hash:new ks,map:new(Nn||Li),string:new ks}}function T0(h){var d=rr(this,h).delete(h);return this.size-=d?1:0,d}function S0(h){return rr(this,h).get(h)}function P0(h){return rr(this,h).has(h)}function I0(h,d){var p=rr(this,h),A=p.size;return p.set(h,d),this.size+=p.size==A?0:1,this}Di.prototype.clear=R0,Di.prototype.delete=T0,Di.prototype.get=S0,Di.prototype.has=P0,Di.prototype.set=I0;function Es(h){var d=-1,p=h==null?0:h.length;for(this.__data__=new Di;++d<p;)this.add(h[d])}function L0(h){return this.__data__.set(h,o),this}function D0(h){return this.__data__.has(h)}Es.prototype.add=Es.prototype.push=L0,Es.prototype.has=D0;function yi(h){var d=this.__data__=new Li(h);this.size=d.size}function M0(){this.__data__=new Li,this.size=0}function B0(h){var d=this.__data__,p=d.delete(h);return this.size=d.size,p}function O0(h){return this.__data__.get(h)}function F0(h){return this.__data__.has(h)}function N0(h,d){var p=this.__data__;if(p instanceof Li){var A=p.__data__;if(!Nn||A.length<n-1)return A.push([h,d]),this.size=++p.size,this;p=this.__data__=new Di(A)}return p.set(h,d),this.size=p.size,this}yi.prototype.clear=M0,yi.prototype.delete=B0,yi.prototype.get=O0,yi.prototype.has=F0,yi.prototype.set=N0;function Rh(h,d){var p=Pt(h),A=!p&&Ss(h),B=!p&&!A&&ls(h),z=!p&&!A&&!B&&hn(h),q=p||A||B||z,J=q?So(h.length,Ky):[],nt=J.length;for(var dt in h)(d||Xt.call(h,dt))&&!(q&&(dt=="length"||B&&(dt=="offset"||dt=="parent")||z&&(dt=="buffer"||dt=="byteLength"||dt=="byteOffset")||Fi(dt,nt)))&&J.push(dt);return J}function Th(h){var d=h.length;return d?h[qo(0,d-1)]:i}function z0(h,d){return or(Oe(h),As(d,0,h.length))}function H0(h){return or(Oe(h))}function Oo(h,d,p){(p!==i&&!mi(h[d],p)||p===i&&!(d in h))&&Mi(h,d,p)}function Un(h,d,p){var A=h[d];(!(Xt.call(h,d)&&mi(A,p))||p===i&&!(d in h))&&Mi(h,d,p)}function Ka(h,d){for(var p=h.length;p--;)if(mi(h[p][0],d))return p;return-1}function W0(h,d,p,A){return ns(h,function(B,z,q){d(A,B,p(B),q)}),A}function Sh(h,d){return h&&ki(d,pe(d),h)}function U0(h,d){return h&&ki(d,Ne(d),h)}function Mi(h,d,p){d=="__proto__"&&Ua?Ua(h,d,{configurable:!0,enumerable:!0,value:p,writable:!0}):h[d]=p}function Fo(h,d){for(var p=-1,A=d.length,B=lt(A),z=h==null;++p<A;)B[p]=z?i:ml(h,d[p]);return B}function As(h,d,p){return h===h&&(p!==i&&(h=h<=p?h:p),d!==i&&(h=h>=d?h:d)),h}function ri(h,d,p,A,B,z){var q,J=d&f,nt=d&g,dt=d&v;if(p&&(q=B?p(h,A,B,z):p(h)),q!==i)return q;if(!oe(h))return h;var gt=Pt(h);if(gt){if(q=Pm(h),!J)return Oe(h,q)}else{var vt=Se(h),pt=vt==N||vt==X;if(ls(h))return Qh(h,J);if(vt==yt||vt==et||pt&&!B){if(q=nt||pt?{}:pu(h),!J)return nt?wm(h,U0(q,h)):pm(h,Sh(q,h))}else{if(!ee[vt])return B?h:{};q=Im(h,vt,J)}}z||(z=new yi);var _t=z.get(h);if(_t)return _t;z.set(h,q),Yu(h)?h.forEach(function(Rt){q.add(ri(Rt,d,p,Rt,h,z))}):Vu(h)&&h.forEach(function(Rt,Ft){q.set(Ft,ri(Rt,d,p,Ft,h,z))});var Ct=dt?nt?sl:il:nt?Ne:pe,Mt=gt?i:Ct(h);return si(Mt||h,function(Rt,Ft){Mt&&(Ft=Rt,Rt=h[Ft]),Un(q,Ft,ri(Rt,d,p,Ft,h,z))}),q}function $0(h){var d=pe(h);return function(p){return Ph(p,h,d)}}function Ph(h,d,p){var A=p.length;if(h==null)return!A;for(h=Zt(h);A--;){var B=p[A],z=d[B],q=h[B];if(q===i&&!(B in h)||!z(q))return!1}return!0}function Ih(h,d,p){if(typeof h!="function")throw new ni(r);return Xn(function(){h.apply(i,p)},d)}function $n(h,d,p,A){var B=-1,z=Ia,q=!0,J=h.length,nt=[],dt=d.length;if(!J)return nt;p&&(d=ne(d,Ye(p))),A?(z=ko,q=!1):d.length>=n&&(z=On,q=!1,d=new Es(d));t:for(;++B<J;){var gt=h[B],vt=p==null?gt:p(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 ns=nu(_i),Lh=nu(zo,!0);function j0(h,d){var p=!0;return ns(h,function(A,B,z){return p=!!d(A,B,z),p}),p}function Xa(h,d,p){for(var A=-1,B=h.length;++A<B;){var z=h[A],q=d(z);if(q!=null&&(J===i?q===q&&!Xe(q):p(q,J)))var J=q,nt=z}return nt}function V0(h,d,p,A){var B=h.length;for(p=Dt(p),p<0&&(p=-p>B?0:B+p),A=A===i||A>B?B:Dt(A),A<0&&(A+=B),A=p>A?0:Xu(A);p<A;)h[p++]=d;return h}function Dh(h,d){var p=[];return ns(h,function(A,B,z){d(A,B,z)&&p.push(A)}),p}function ke(h,d,p,A,B){var z=-1,q=h.length;for(p||(p=Dm),B||(B=[]);++z<q;){var J=h[z];d>0&&p(J)?d>1?ke(J,d-1,p,A,B):es(B,J):A||(B[B.length]=J)}return B}var No=au(),Mh=au(!0);function _i(h,d){return h&&No(h,d,pe)}function zo(h,d){return h&&Mh(h,d,pe)}function Ga(h,d){return ts(d,function(p){return Ni(h[p])})}function Cs(h,d){d=rs(d,h);for(var p=0,A=d.length;h!=null&&p<A;)h=h[Ei(d[p++])];return p&&p==A?h:i}function Bh(h,d,p){var A=d(h);return Pt(h)?A:es(A,p(h))}function Pe(h){return h==null?h===i?te:mt:_s&&_s in Zt(h)?Rm(h):Hm(h)}function Ho(h,d){return h>d}function q0(h,d){return h!=null&&Xt.call(h,d)}function Y0(h,d){return h!=null&&d in Zt(h)}function K0(h,d,p){return h>=Te(d,p)&&h<ye(d,p)}function Wo(h,d,p){for(var A=p?ko:Ia,B=h[0].length,z=h.length,q=z,J=lt(z),nt=1/0,dt=[];q--;){var gt=h[q];q&&d&&(gt=ne(gt,Ye(d))),nt=Te(gt.length,nt),J[q]=!p&&(d||B>=120&>.length>=120)?new Es(q&>):i}gt=h[0];var vt=-1,pt=J[0];t:for(;++vt<B&&dt.length<nt;){var _t=gt[vt],Ct=d?d(_t):_t;if(_t=p||_t!==0?_t:0,!(pt?On(pt,Ct):A(dt,Ct,p))){for(q=z;--q;){var Mt=J[q];if(!(Mt?On(Mt,Ct):A(h[q],Ct,p)))continue t}pt&&pt.push(Ct),dt.push(_t)}}return dt}function X0(h,d,p,A){return _i(h,function(B,z,q){d(A,p(B),z,q)}),A}function jn(h,d,p){d=rs(d,h),h=_u(h,d);var A=h==null?h:h[Ei(li(d))];return A==null?i:qe(A,h,p)}function Oh(h){return ce(h)&&Pe(h)==et}function G0(h){return ce(h)&&Pe(h)==Bn}function Z0(h){return ce(h)&&Pe(h)==b}function Vn(h,d,p,A,B){return h===d?!0:h==null||d==null||!ce(h)&&!ce(d)?h!==h&&d!==d:J0(h,d,p,A,Vn,B)}function J0(h,d,p,A,B,z){var q=Pt(h),J=Pt(d),nt=q?ut:Se(h),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&&ls(h)){if(!ls(d))return!1;q=!0,gt=!1}if(pt&&!gt)return z||(z=new yi),q||hn(h)?vu(h,d,p,A,B,z):Am(h,d,nt,p,A,B,z);if(!(p&y)){var _t=gt&&Xt.call(h,"__wrapped__"),Ct=vt&&Xt.call(d,"__wrapped__");if(_t||Ct){var Mt=_t?h.value():h,Rt=Ct?d.value():d;return z||(z=new yi),B(Mt,Rt,p,A,z)}}return pt?(z||(z=new yi),Cm(h,d,p,A,B,z)):!1}function Q0(h){return ce(h)&&Se(h)==G}function Uo(h,d,p,A){var B=p.length,z=B,q=!A;if(h==null)return!z;for(h=Zt(h);B--;){var J=p[B];if(q&&J[2]?J[1]!==h[J[0]]:!(J[0]in h))return!1}for(;++B<z;){J=p[B];var nt=J[0],dt=h[nt],gt=J[1];if(q&&J[2]){if(dt===i&&!(nt in h))return!1}else{var vt=new yi;if(A)var pt=A(dt,gt,nt,h,d,vt);if(!(pt===i?Vn(gt,dt,y|w,A,vt):pt))return!1}}return!0}function Fh(h){if(!oe(h)||Bm(h))return!1;var d=Ni(h)?Qy:$v;return d.test(Ts(h))}function tm(h){return ce(h)&&Pe(h)==be}function em(h){return ce(h)&&Se(h)==se}function im(h){return ce(h)&&dr(h.length)&&!!ie[Pe(h)]}function Nh(h){return typeof h=="function"?h:h==null?ze:typeof h=="object"?Pt(h)?Wh(h[0],h[1]):Hh(h):of(h)}function $o(h){if(!Kn(h))return a0(h);var d=[];for(var p in Zt(h))Xt.call(h,p)&&p!="constructor"&&d.push(p);return d}function sm(h){if(!oe(h))return zm(h);var d=Kn(h),p=[];for(var A in h)A=="constructor"&&(d||!Xt.call(h,A))||p.push(A);return p}function jo(h,d){return h<d}function zh(h,d){var p=-1,A=Fe(h)?lt(h.length):[];return ns(h,function(B,z,q){A[++p]=d(B,z,q)}),A}function Hh(h){var d=al(h);return d.length==1&&d[0][2]?bu(d[0][0],d[0][1]):function(p){return p===h||Uo(p,h,d)}}function Wh(h,d){return ol(h)&&wu(d)?bu(Ei(h),d):function(p){var A=ml(p,h);return A===i&&A===d?pl(p,h):Vn(d,A,y|w)}}function Za(h,d,p,A,B){h!==d&&No(d,function(z,q){if(B||(B=new yi),oe(z))nm(h,d,q,p,Za,A,B);else{var J=A?A(cl(h,q),z,q+"",h,d,B):i;J===i&&(J=z),Oo(h,q,J)}},Ne)}function nm(h,d,p,A,B,z,q){var J=cl(h,p),nt=cl(d,p),dt=q.get(nt);if(dt){Oo(h,p,dt);return}var gt=z?z(J,nt,p+"",h,d,q):i,vt=gt===i;if(vt){var pt=Pt(nt),_t=!pt&&ls(nt),Ct=!pt&&!_t&&hn(nt);gt=nt,pt||_t||Ct?Pt(J)?gt=J:ue(J)?gt=Oe(J):_t?(vt=!1,gt=Qh(nt,!0)):Ct?(vt=!1,gt=tu(nt,!0)):gt=[]:Gn(nt)||Ss(nt)?(gt=J,Ss(J)?gt=Gu(J):(!oe(J)||Ni(J))&&(gt=pu(nt))):vt=!1}vt&&(q.set(nt,gt),B(gt,nt,A,z,q),q.delete(nt)),Oo(h,p,gt)}function Uh(h,d){var p=h.length;if(!!p)return d+=d<0?p:0,Fi(d,p)?h[d]:i}function $h(h,d,p){d.length?d=ne(d,function(z){return Pt(z)?function(q){return Cs(q,z.length===1?z[0]:z)}:z}):d=[ze];var A=-1;d=ne(d,Ye(At()));var B=zh(h,function(z,q,J){var nt=ne(d,function(dt){return dt(z)});return{criteria:nt,index:++A,value:z}});return Iy(B,function(z,q){return mm(z,q,p)})}function am(h,d){return jh(h,d,function(p,A){return pl(h,A)})}function jh(h,d,p){for(var A=-1,B=d.length,z={};++A<B;){var q=d[A],J=Cs(h,q);p(J,q)&&qn(z,rs(q,h),J)}return z}function rm(h){return function(d){return Cs(d,h)}}function Vo(h,d,p,A){var B=A?Py:Js,z=-1,q=d.length,J=h;for(h===d&&(d=Oe(d)),p&&(J=ne(h,Ye(p)));++z<q;)for(var nt=0,dt=d[z],gt=p?p(dt):dt;(nt=B(J,gt,nt,A))>-1;)J!==h&&Wa.call(J,nt,1),Wa.call(h,nt,1);return h}function Vh(h,d){for(var p=h?d.length:0,A=p-1;p--;){var B=d[p];if(p==A||B!==z){var z=B;Fi(B)?Wa.call(h,B,1):Xo(h,B)}}return h}function qo(h,d){return h+ja(Ah()*(d-h+1))}function om(h,d,p,A){for(var B=-1,z=ye($a((d-h)/(p||1)),0),q=lt(z);z--;)q[A?z:++B]=h,h+=p;return q}function Yo(h,d){var p="";if(!h||d<1||d>V)return p;do d%2&&(p+=h),d=ja(d/2),d&&(h+=h);while(d);return p}function Bt(h,d){return hl(xu(h,d,ze),h+"")}function lm(h){return Th(un(h))}function cm(h,d){var p=un(h);return or(p,As(d,0,p.length))}function qn(h,d,p,A){if(!oe(h))return h;d=rs(d,h);for(var B=-1,z=d.length,q=z-1,J=h;J!=null&&++B<z;){var nt=Ei(d[B]),dt=p;if(nt==="__proto__"||nt==="constructor"||nt==="prototype")return h;if(B!=q){var gt=J[nt];dt=A?A(gt,nt,J):i,dt===i&&(dt=oe(gt)?gt:Fi(d[B+1])?[]:{})}Un(J,nt,dt),J=J[nt]}return h}var qh=Va?function(h,d){return Va.set(h,d),h}:ze,hm=Ua?function(h,d){return Ua(h,"toString",{configurable:!0,enumerable:!1,value:bl(d),writable:!0})}:ze;function um(h){return or(un(h))}function oi(h,d,p){var A=-1,B=h.length;d<0&&(d=-d>B?0:B+d),p=p>B?B:p,p<0&&(p+=B),B=d>p?0:p-d>>>0,d>>>=0;for(var z=lt(B);++A<B;)z[A]=h[A+d];return z}function fm(h,d){var p;return ns(h,function(A,B,z){return p=d(A,B,z),!p}),!!p}function Ja(h,d,p){var A=0,B=h==null?A:h.length;if(typeof d=="number"&&d===d&&B<=tt){for(;A<B;){var z=A+B>>>1,q=h[z];q!==null&&!Xe(q)&&(p?q<=d:q<d)?A=z+1:B=z}return B}return Ko(h,d,ze,p)}function Ko(h,d,p,A){var B=0,z=h==null?0:h.length;if(z===0)return 0;d=p(d);for(var q=d!==d,J=d===null,nt=Xe(d),dt=d===i;B<z;){var gt=ja((B+z)/2),vt=p(h[gt]),pt=vt!==i,_t=vt===null,Ct=vt===vt,Mt=Xe(vt);if(q)var Rt=A||Ct;else dt?Rt=Ct&&(A||pt):J?Rt=Ct&&pt&&(A||!_t):nt?Rt=Ct&&pt&&!_t&&(A||!Mt):_t||Mt?Rt=!1:Rt=A?vt<=d:vt<d;Rt?B=gt+1:z=gt}return Te(z,U)}function Yh(h,d){for(var p=-1,A=h.length,B=0,z=[];++p<A;){var q=h[p],J=d?d(q):q;if(!p||!mi(J,nt)){var nt=J;z[B++]=q===0?0:q}}return z}function Kh(h){return typeof h=="number"?h:Xe(h)?j:+h}function Ke(h){if(typeof h=="string")return h;if(Pt(h))return ne(h,Ke)+"";if(Xe(h))return Ch?Ch.call(h):"";var d=h+"";return d=="0"&&1/h==-at?"-0":d}function as(h,d,p){var A=-1,B=Ia,z=h.length,q=!0,J=[],nt=J;if(p)q=!1,B=ko;else if(z>=n){var dt=d?null:km(h);if(dt)return Da(dt);q=!1,B=On,nt=new Es}else nt=d?[]:J;t:for(;++A<z;){var gt=h[A],vt=d?d(gt):gt;if(gt=p||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 B(nt,vt,p)||(nt!==J&&nt.push(vt),J.push(gt))}return J}function Xo(h,d){return d=rs(d,h),h=_u(h,d),h==null||delete h[Ei(li(d))]}function Xh(h,d,p,A){return qn(h,d,p(Cs(h,d)),A)}function Qa(h,d,p,A){for(var B=h.length,z=A?B:-1;(A?z--:++z<B)&&d(h[z],z,h););return p?oi(h,A?0:z,A?z+1:B):oi(h,A?z+1:0,A?B:z)}function Gh(h,d){var p=h;return p instanceof Nt&&(p=p.value()),Eo(d,function(A,B){return B.func.apply(B.thisArg,es([A],B.args))},p)}function Go(h,d,p){var A=h.length;if(A<2)return A?as(h[0]):[];for(var B=-1,z=lt(A);++B<A;)for(var q=h[B],J=-1;++J<A;)J!=B&&(z[B]=$n(z[B]||q,h[J],d,p));return as(ke(z,1),d,p)}function Zh(h,d,p){for(var A=-1,B=h.length,z=d.length,q={};++A<B;){var J=A<z?d[A]:i;p(q,h[A],J)}return q}function Zo(h){return ue(h)?h:[]}function Jo(h){return typeof h=="function"?h:ze}function rs(h,d){return Pt(h)?h:ol(h,d)?[h]:Cu(Kt(h))}var dm=Bt;function os(h,d,p){var A=h.length;return p=p===i?A:p,!d&&p>=A?h:oi(h,d,p)}var Jh=t0||function(h){return _e.clearTimeout(h)};function Qh(h,d){if(d)return h.slice();var p=h.length,A=bh?bh(p):new h.constructor(p);return h.copy(A),A}function Qo(h){var d=new h.constructor(h.byteLength);return new za(d).set(new za(h)),d}function gm(h,d){var p=d?Qo(h.buffer):h.buffer;return new h.constructor(p,h.byteOffset,h.byteLength)}function vm(h){var d=new h.constructor(h.source,Oc.exec(h));return d.lastIndex=h.lastIndex,d}function ym(h){return Wn?Zt(Wn.call(h)):{}}function tu(h,d){var p=d?Qo(h.buffer):h.buffer;return new h.constructor(p,h.byteOffset,h.length)}function eu(h,d){if(h!==d){var p=h!==i,A=h===null,B=h===h,z=Xe(h),q=d!==i,J=d===null,nt=d===d,dt=Xe(d);if(!J&&!dt&&!z&&h>d||z&&q&&nt&&!J&&!dt||A&&q&&nt||!p&&nt||!B)return 1;if(!A&&!z&&!dt&&h<d||dt&&p&&B&&!A&&!z||J&&p&&B||!q&&B||!nt)return-1}return 0}function mm(h,d,p){for(var A=-1,B=h.criteria,z=d.criteria,q=B.length,J=p.length;++A<q;){var nt=eu(B[A],z[A]);if(nt){if(A>=J)return nt;var dt=p[A];return nt*(dt=="desc"?-1:1)}}return h.index-d.index}function iu(h,d,p,A){for(var B=-1,z=h.length,q=p.length,J=-1,nt=d.length,dt=ye(z-q,0),gt=lt(nt+dt),vt=!A;++J<nt;)gt[J]=d[J];for(;++B<q;)(vt||B<z)&&(gt[p[B]]=h[B]);for(;dt--;)gt[J++]=h[B++];return gt}function su(h,d,p,A){for(var B=-1,z=h.length,q=-1,J=p.length,nt=-1,dt=d.length,gt=ye(z-J,0),vt=lt(gt+dt),pt=!A;++B<gt;)vt[B]=h[B];for(var _t=B;++nt<dt;)vt[_t+nt]=d[nt];for(;++q<J;)(pt||B<z)&&(vt[_t+p[q]]=h[B++]);return vt}function Oe(h,d){var p=-1,A=h.length;for(d||(d=lt(A));++p<A;)d[p]=h[p];return d}function ki(h,d,p,A){var B=!p;p||(p={});for(var z=-1,q=d.length;++z<q;){var J=d[z],nt=A?A(p[J],h[J],J,p,h):i;nt===i&&(nt=h[J]),B?Mi(p,J,nt):Un(p,J,nt)}return p}function pm(h,d){return ki(h,rl(h),d)}function wm(h,d){return ki(h,yu(h),d)}function tr(h,d){return function(p,A){var B=Pt(p)?Ey:W0,z=d?d():{};return B(p,h,At(A,2),z)}}function on(h){return Bt(function(d,p){var A=-1,B=p.length,z=B>1?p[B-1]:i,q=B>2?p[2]:i;for(z=h.length>3&&typeof z=="function"?(B--,z):i,q&&Ie(p[0],p[1],q)&&(z=B<3?i:z,B=1),d=Zt(d);++A<B;){var J=p[A];J&&h(d,J,A,z)}return d})}function nu(h,d){return function(p,A){if(p==null)return p;if(!Fe(p))return h(p,A);for(var B=p.length,z=d?B:-1,q=Zt(p);(d?z--:++z<B)&&A(q[z],z,q)!==!1;);return p}}function au(h){return function(d,p,A){for(var B=-1,z=Zt(d),q=A(d),J=q.length;J--;){var nt=q[h?J:++B];if(p(z[nt],nt,z)===!1)break}return d}}function bm(h,d,p){var A=d&m,B=Yn(h);function z(){var q=this&&this!==_e&&this instanceof z?B:h;return q.apply(A?p:this,arguments)}return z}function ru(h){return function(d){d=Kt(d);var p=Qs(d)?vi(d):i,A=p?p[0]:d.charAt(0),B=p?os(p,1).join(""):d.slice(1);return A[h]()+B}}function ln(h){return function(d){return Eo(af(nf(d).replace(hy,"")),h,"")}}function Yn(h){return function(){var d=arguments;switch(d.length){case 0:return new h;case 1:return new h(d[0]);case 2:return new h(d[0],d[1]);case 3:return new h(d[0],d[1],d[2]);case 4:return new h(d[0],d[1],d[2],d[3]);case 5:return new h(d[0],d[1],d[2],d[3],d[4]);case 6:return new h(d[0],d[1],d[2],d[3],d[4],d[5]);case 7:return new h(d[0],d[1],d[2],d[3],d[4],d[5],d[6])}var p=rn(h.prototype),A=h.apply(p,d);return oe(A)?A:p}}function xm(h,d,p){var A=Yn(h);function B(){for(var z=arguments.length,q=lt(z),J=z,nt=cn(B);J--;)q[J]=arguments[J];var dt=z<3&&q[0]!==nt&&q[z-1]!==nt?[]:is(q,nt);if(z-=dt.length,z<p)return uu(h,d,er,B.placeholder,i,q,dt,i,i,p-z);var gt=this&&this!==_e&&this instanceof B?A:h;return qe(gt,this,q)}return B}function ou(h){return function(d,p,A){var B=Zt(d);if(!Fe(d)){var z=At(p,3);d=pe(d),p=function(J){return z(B[J],J,B)}}var q=h(d,p,A);return q>-1?B[z?d[q]:q]:i}}function lu(h){return Oi(function(d){var p=d.length,A=p,B=ai.prototype.thru;for(h&&d.reverse();A--;){var z=d[A];if(typeof z!="function")throw new ni(r);if(B&&!q&&ar(z)=="wrapper")var q=new ai([],!0)}for(A=q?A:p;++A<p;){z=d[A];var J=ar(z),nt=J=="wrapper"?nl(z):i;nt&&ll(nt[0])&&nt[1]==(M|x|S|D)&&!nt[4].length&&nt[9]==1?q=q[ar(nt[0])].apply(q,nt[3]):q=z.length==1&&ll(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=p?d[vt].apply(this,dt):gt;++vt<p;)pt=d[vt].call(this,pt);return pt}})}function er(h,d,p,A,B,z,q,J,nt,dt){var gt=d&M,vt=d&m,pt=d&_,_t=d&(x|C),Ct=d&$,Mt=pt?i:Yn(h);function Rt(){for(var Ft=arguments.length,Ht=lt(Ft),Ge=Ft;Ge--;)Ht[Ge]=arguments[Ge];if(_t)var Le=cn(Rt),Ze=Dy(Ht,Le);if(A&&(Ht=iu(Ht,A,B,_t)),z&&(Ht=su(Ht,z,q,_t)),Ft-=Ze,_t&&Ft<dt){var fe=is(Ht,Le);return uu(h,d,er,Rt.placeholder,p,Ht,fe,J,nt,dt-Ft)}var pi=vt?p:this,Hi=pt?pi[h]:h;return Ft=Ht.length,J?Ht=Wm(Ht,J):Ct&&Ft>1&&Ht.reverse(),gt&&nt<Ft&&(Ht.length=nt),this&&this!==_e&&this instanceof Rt&&(Hi=Mt||Yn(Hi)),Hi.apply(pi,Ht)}return Rt}function cu(h,d){return function(p,A){return X0(p,h,d(A),{})}}function ir(h,d){return function(p,A){var B;if(p===i&&A===i)return d;if(p!==i&&(B=p),A!==i){if(B===i)return A;typeof p=="string"||typeof A=="string"?(p=Ke(p),A=Ke(A)):(p=Kh(p),A=Kh(A)),B=h(p,A)}return B}}function tl(h){return Oi(function(d){return d=ne(d,Ye(At())),Bt(function(p){var A=this;return h(d,function(B){return qe(B,A,p)})})})}function sr(h,d){d=d===i?" ":Ke(d);var p=d.length;if(p<2)return p?Yo(d,h):d;var A=Yo(d,$a(h/tn(d)));return Qs(d)?os(vi(A),0,h).join(""):A.slice(0,h)}function _m(h,d,p,A){var B=d&m,z=Yn(h);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:h;++dt<gt;)vt[dt]=A[dt];for(;nt--;)vt[dt++]=arguments[++J];return qe(pt,B?p:this,vt)}return q}function hu(h){return function(d,p,A){return A&&typeof A!="number"&&Ie(d,p,A)&&(p=A=i),d=zi(d),p===i?(p=d,d=0):p=zi(p),A=A===i?d<p?1:-1:zi(A),om(d,p,A,h)}}function nr(h){return function(d,p){return typeof d=="string"&&typeof p=="string"||(d=ci(d),p=ci(p)),h(d,p)}}function uu(h,d,p,A,B,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:L,d&=~(gt?L:S),d&E||(d&=~(m|_));var Mt=[h,d,B,_t,vt,Ct,pt,J,nt,dt],Rt=p.apply(i,Mt);return ll(h)&&ku(Rt,Mt),Rt.placeholder=A,Eu(Rt,h,d)}function el(h){var d=ve[h];return function(p,A){if(p=ci(p),A=A==null?0:Te(Dt(A),292),A&&Eh(p)){var B=(Kt(p)+"e").split("e"),z=d(B[0]+"e"+(+B[1]+A));return B=(Kt(z)+"e").split("e"),+(B[0]+"e"+(+B[1]-A))}return d(p)}}var km=nn&&1/Da(new nn([,-0]))[1]==at?function(h){return new nn(h)}:kl;function fu(h){return function(d){var p=Se(d);return p==G?Io(d):p==se?Hy(d):Ly(d,h(d))}}function Bi(h,d,p,A,B,z,q,J){var nt=d&_;if(!nt&&typeof h!="function")throw new ni(r);var dt=A?A.length:0;if(dt||(d&=~(S|L),A=B=i),q=q===i?q:ye(Dt(q),0),J=J===i?J:Dt(J),dt-=B?B.length:0,d&L){var gt=A,vt=B;A=B=i}var pt=nt?i:nl(h),_t=[h,d,p,A,B,gt,vt,z,q,J];if(pt&&Nm(_t,pt),h=_t[0],d=_t[1],p=_t[2],A=_t[3],B=_t[4],J=_t[9]=_t[9]===i?nt?0:h.length:ye(_t[9]-dt,0),!J&&d&(x|C)&&(d&=~(x|C)),!d||d==m)var Ct=bm(h,d,p);else d==x||d==C?Ct=xm(h,d,J):(d==S||d==(m|S))&&!B.length?Ct=_m(h,d,p,A):Ct=er.apply(i,_t);var Mt=pt?qh:ku;return Eu(Mt(Ct,_t),h,d)}function du(h,d,p,A){return h===i||mi(h,sn[p])&&!Xt.call(A,p)?d:h}function gu(h,d,p,A,B,z){return oe(h)&&oe(d)&&(z.set(d,h),Za(h,d,i,gu,z),z.delete(d)),h}function Em(h){return Gn(h)?i:h}function vu(h,d,p,A,B,z){var q=p&y,J=h.length,nt=d.length;if(J!=nt&&!(q&&nt>J))return!1;var dt=z.get(h),gt=z.get(d);if(dt&>)return dt==d&>==h;var vt=-1,pt=!0,_t=p&w?new Es:i;for(z.set(h,d),z.set(d,h);++vt<J;){var Ct=h[vt],Mt=d[vt];if(A)var Rt=q?A(Mt,Ct,vt,d,h,z):A(Ct,Mt,vt,h,d,z);if(Rt!==i){if(Rt)continue;pt=!1;break}if(_t){if(!Ao(d,function(Ft,Ht){if(!On(_t,Ht)&&(Ct===Ft||B(Ct,Ft,p,A,z)))return _t.push(Ht)})){pt=!1;break}}else if(!(Ct===Mt||B(Ct,Mt,p,A,z))){pt=!1;break}}return z.delete(h),z.delete(d),pt}function Am(h,d,p,A,B,z,q){switch(p){case Gs:if(h.byteLength!=d.byteLength||h.byteOffset!=d.byteOffset)return!1;h=h.buffer,d=d.buffer;case Bn:return!(h.byteLength!=d.byteLength||!z(new za(h),new za(d)));case ot:case b:case rt:return mi(+h,+d);case I:return h.name==d.name&&h.message==d.message;case be:case xe:return h==d+"";case G:var J=Io;case se:var nt=A&y;if(J||(J=Da),h.size!=d.size&&!nt)return!1;var dt=q.get(h);if(dt)return dt==d;A|=w,q.set(h,d);var gt=vu(J(h),J(d),A,B,z,q);return q.delete(h),gt;case Vt:if(Wn)return Wn.call(h)==Wn.call(d)}return!1}function Cm(h,d,p,A,B,z){var q=p&y,J=il(h),nt=J.length,dt=il(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(h),Ct=z.get(d);if(_t&&Ct)return _t==d&&Ct==h;var Mt=!0;z.set(h,d),z.set(d,h);for(var Rt=q;++vt<nt;){pt=J[vt];var Ft=h[pt],Ht=d[pt];if(A)var Ge=q?A(Ht,Ft,pt,d,h,z):A(Ft,Ht,pt,h,d,z);if(!(Ge===i?Ft===Ht||B(Ft,Ht,p,A,z):Ge)){Mt=!1;break}Rt||(Rt=pt=="constructor")}if(Mt&&!Rt){var Le=h.constructor,Ze=d.constructor;Le!=Ze&&"constructor"in h&&"constructor"in d&&!(typeof Le=="function"&&Le instanceof Le&&typeof Ze=="function"&&Ze instanceof Ze)&&(Mt=!1)}return z.delete(h),z.delete(d),Mt}function Oi(h){return hl(xu(h,i,Pu),h+"")}function il(h){return Bh(h,pe,rl)}function sl(h){return Bh(h,Ne,yu)}var nl=Va?function(h){return Va.get(h)}:kl;function ar(h){for(var d=h.name+"",p=an[d],A=Xt.call(an,d)?p.length:0;A--;){var B=p[A],z=B.func;if(z==null||z==h)return B.name}return d}function cn(h){var d=Xt.call(F,"placeholder")?F:h;return d.placeholder}function At(){var h=F.iteratee||xl;return h=h===xl?Nh:h,arguments.length?h(arguments[0],arguments[1]):h}function rr(h,d){var p=h.__data__;return Mm(d)?p[typeof d=="string"?"string":"hash"]:p.map}function al(h){for(var d=pe(h),p=d.length;p--;){var A=d[p],B=h[A];d[p]=[A,B,wu(B)]}return d}function Rs(h,d){var p=Fy(h,d);return Fh(p)?p:i}function Rm(h){var d=Xt.call(h,_s),p=h[_s];try{h[_s]=i;var A=!0}catch{}var B=Fa.call(h);return A&&(d?h[_s]=p:delete h[_s]),B}var rl=Do?function(h){return h==null?[]:(h=Zt(h),ts(Do(h),function(d){return _h.call(h,d)}))}:El,yu=Do?function(h){for(var d=[];h;)es(d,rl(h)),h=Ha(h);return d}:El,Se=Pe;(Mo&&Se(new Mo(new ArrayBuffer(1)))!=Gs||Nn&&Se(new Nn)!=G||Bo&&Se(Bo.resolve())!=Et||nn&&Se(new nn)!=se||zn&&Se(new zn)!=xi)&&(Se=function(h){var d=Pe(h),p=d==yt?h.constructor:i,A=p?Ts(p):"";if(A)switch(A){case c0:return Gs;case h0:return G;case u0:return Et;case f0:return se;case d0:return xi}return d});function Tm(h,d,p){for(var A=-1,B=p.length;++A<B;){var z=p[A],q=z.size;switch(z.type){case"drop":h+=q;break;case"dropRight":d-=q;break;case"take":d=Te(d,h+q);break;case"takeRight":h=ye(h,d-q);break}}return{start:h,end:d}}function Sm(h){var d=h.match(Bv);return d?d[1].split(Ov):[]}function mu(h,d,p){d=rs(d,h);for(var A=-1,B=d.length,z=!1;++A<B;){var q=Ei(d[A]);if(!(z=h!=null&&p(h,q)))break;h=h[q]}return z||++A!=B?z:(B=h==null?0:h.length,!!B&&dr(B)&&Fi(q,B)&&(Pt(h)||Ss(h)))}function Pm(h){var d=h.length,p=new h.constructor(d);return d&&typeof h[0]=="string"&&Xt.call(h,"index")&&(p.index=h.index,p.input=h.input),p}function pu(h){return typeof h.constructor=="function"&&!Kn(h)?rn(Ha(h)):{}}function Im(h,d,p){var A=h.constructor;switch(d){case Bn:return Qo(h);case ot:case b:return new A(+h);case Gs:return gm(h,p);case no:case ao:case ro:case oo:case lo:case co:case ho:case uo:case fo:return tu(h,p);case G:return new A;case rt:case xe:return new A(h);case be:return vm(h);case se:return new A;case Vt:return ym(h)}}function Lm(h,d){var p=d.length;if(!p)return h;var A=p-1;return d[A]=(p>1?"& ":"")+d[A],d=d.join(p>2?", ":" "),h.replace(Mv,`{
- /* [wrapped with `+d+`] */
- `)}function Dm(h){return Pt(h)||Ss(h)||!!(kh&&h&&h[kh])}function Fi(h,d){var p=typeof h;return d=d==null?V:d,!!d&&(p=="number"||p!="symbol"&&Vv.test(h))&&h>-1&&h%1==0&&h<d}function Ie(h,d,p){if(!oe(p))return!1;var A=typeof d;return(A=="number"?Fe(p)&&Fi(d,p.length):A=="string"&&d in p)?mi(p[d],h):!1}function ol(h,d){if(Pt(h))return!1;var p=typeof h;return p=="number"||p=="symbol"||p=="boolean"||h==null||Xe(h)?!0:Pv.test(h)||!Sv.test(h)||d!=null&&h in Zt(d)}function Mm(h){var d=typeof h;return d=="string"||d=="number"||d=="symbol"||d=="boolean"?h!=="__proto__":h===null}function ll(h){var d=ar(h),p=F[d];if(typeof p!="function"||!(d in Nt.prototype))return!1;if(h===p)return!0;var A=nl(p);return!!A&&h===A[0]}function Bm(h){return!!wh&&wh in h}var Om=Ba?Ni:Al;function Kn(h){var d=h&&h.constructor,p=typeof d=="function"&&d.prototype||sn;return h===p}function wu(h){return h===h&&!oe(h)}function bu(h,d){return function(p){return p==null?!1:p[h]===d&&(d!==i||h in Zt(p))}}function Fm(h){var d=ur(h,function(A){return p.size===u&&p.clear(),A}),p=d.cache;return d}function Nm(h,d){var p=h[1],A=d[1],B=p|A,z=B<(m|_|M),q=A==M&&p==x||A==M&&p==D&&h[7].length<=d[8]||A==(M|D)&&d[7].length<=d[8]&&p==x;if(!(z||q))return h;A&m&&(h[2]=d[2],B|=p&m?0:E);var J=d[3];if(J){var nt=h[3];h[3]=nt?iu(nt,J,d[4]):J,h[4]=nt?is(h[3],c):d[4]}return J=d[5],J&&(nt=h[5],h[5]=nt?su(nt,J,d[6]):J,h[6]=nt?is(h[5],c):d[6]),J=d[7],J&&(h[7]=J),A&M&&(h[8]=h[8]==null?d[8]:Te(h[8],d[8])),h[9]==null&&(h[9]=d[9]),h[0]=d[0],h[1]=B,h}function zm(h){var d=[];if(h!=null)for(var p in Zt(h))d.push(p);return d}function Hm(h){return Fa.call(h)}function xu(h,d,p){return d=ye(d===i?h.length-1:d,0),function(){for(var A=arguments,B=-1,z=ye(A.length-d,0),q=lt(z);++B<z;)q[B]=A[d+B];B=-1;for(var J=lt(d+1);++B<d;)J[B]=A[B];return J[d]=p(q),qe(h,this,J)}}function _u(h,d){return d.length<2?h:Cs(h,oi(d,0,-1))}function Wm(h,d){for(var p=h.length,A=Te(d.length,p),B=Oe(h);A--;){var z=d[A];h[A]=Fi(z,p)?B[z]:i}return h}function cl(h,d){if(!(d==="constructor"&&typeof h[d]=="function")&&d!="__proto__")return h[d]}var ku=Au(qh),Xn=i0||function(h,d){return _e.setTimeout(h,d)},hl=Au(hm);function Eu(h,d,p){var A=d+"";return hl(h,Lm(A,Um(Sm(A),p)))}function Au(h){var d=0,p=0;return function(){var A=r0(),B=P-(A-p);if(p=A,B>0){if(++d>=T)return arguments[0]}else d=0;return h.apply(i,arguments)}}function or(h,d){var p=-1,A=h.length,B=A-1;for(d=d===i?A:d;++p<d;){var z=qo(p,B),q=h[z];h[z]=h[p],h[p]=q}return h.length=d,h}var Cu=Fm(function(h){var d=[];return h.charCodeAt(0)===46&&d.push(""),h.replace(Iv,function(p,A,B,z){d.push(B?z.replace(zv,"$1"):A||p)}),d});function Ei(h){if(typeof h=="string"||Xe(h))return h;var d=h+"";return d=="0"&&1/h==-at?"-0":d}function Ts(h){if(h!=null){try{return Oa.call(h)}catch{}try{return h+""}catch{}}return""}function Um(h,d){return si(st,function(p){var A="_."+p[0];d&p[1]&&!Ia(h,A)&&h.push(A)}),h.sort()}function Ru(h){if(h instanceof Nt)return h.clone();var d=new ai(h.__wrapped__,h.__chain__);return d.__actions__=Oe(h.__actions__),d.__index__=h.__index__,d.__values__=h.__values__,d}function $m(h,d,p){(p?Ie(h,d,p):d===i)?d=1:d=ye(Dt(d),0);var A=h==null?0:h.length;if(!A||d<1)return[];for(var B=0,z=0,q=lt($a(A/d));B<A;)q[z++]=oi(h,B,B+=d);return q}function jm(h){for(var d=-1,p=h==null?0:h.length,A=0,B=[];++d<p;){var z=h[d];z&&(B[A++]=z)}return B}function Vm(){var h=arguments.length;if(!h)return[];for(var d=lt(h-1),p=arguments[0],A=h;A--;)d[A-1]=arguments[A];return es(Pt(p)?Oe(p):[p],ke(d,1))}var qm=Bt(function(h,d){return ue(h)?$n(h,ke(d,1,ue,!0)):[]}),Ym=Bt(function(h,d){var p=li(d);return ue(p)&&(p=i),ue(h)?$n(h,ke(d,1,ue,!0),At(p,2)):[]}),Km=Bt(function(h,d){var p=li(d);return ue(p)&&(p=i),ue(h)?$n(h,ke(d,1,ue,!0),i,p):[]});function Xm(h,d,p){var A=h==null?0:h.length;return A?(d=p||d===i?1:Dt(d),oi(h,d<0?0:d,A)):[]}function Gm(h,d,p){var A=h==null?0:h.length;return A?(d=p||d===i?1:Dt(d),d=A-d,oi(h,0,d<0?0:d)):[]}function Zm(h,d){return h&&h.length?Qa(h,At(d,3),!0,!0):[]}function Jm(h,d){return h&&h.length?Qa(h,At(d,3),!0):[]}function Qm(h,d,p,A){var B=h==null?0:h.length;return B?(p&&typeof p!="number"&&Ie(h,d,p)&&(p=0,A=B),V0(h,d,p,A)):[]}function Tu(h,d,p){var A=h==null?0:h.length;if(!A)return-1;var B=p==null?0:Dt(p);return B<0&&(B=ye(A+B,0)),La(h,At(d,3),B)}function Su(h,d,p){var A=h==null?0:h.length;if(!A)return-1;var B=A-1;return p!==i&&(B=Dt(p),B=p<0?ye(A+B,0):Te(B,A-1)),La(h,At(d,3),B,!0)}function Pu(h){var d=h==null?0:h.length;return d?ke(h,1):[]}function tp(h){var d=h==null?0:h.length;return d?ke(h,at):[]}function ep(h,d){var p=h==null?0:h.length;return p?(d=d===i?1:Dt(d),ke(h,d)):[]}function ip(h){for(var d=-1,p=h==null?0:h.length,A={};++d<p;){var B=h[d];A[B[0]]=B[1]}return A}function Iu(h){return h&&h.length?h[0]:i}function sp(h,d,p){var A=h==null?0:h.length;if(!A)return-1;var B=p==null?0:Dt(p);return B<0&&(B=ye(A+B,0)),Js(h,d,B)}function np(h){var d=h==null?0:h.length;return d?oi(h,0,-1):[]}var ap=Bt(function(h){var d=ne(h,Zo);return d.length&&d[0]===h[0]?Wo(d):[]}),rp=Bt(function(h){var d=li(h),p=ne(h,Zo);return d===li(p)?d=i:p.pop(),p.length&&p[0]===h[0]?Wo(p,At(d,2)):[]}),op=Bt(function(h){var d=li(h),p=ne(h,Zo);return d=typeof d=="function"?d:i,d&&p.pop(),p.length&&p[0]===h[0]?Wo(p,i,d):[]});function lp(h,d){return h==null?"":n0.call(h,d)}function li(h){var d=h==null?0:h.length;return d?h[d-1]:i}function cp(h,d,p){var A=h==null?0:h.length;if(!A)return-1;var B=A;return p!==i&&(B=Dt(p),B=B<0?ye(A+B,0):Te(B,A-1)),d===d?Uy(h,d,B):La(h,uh,B,!0)}function hp(h,d){return h&&h.length?Uh(h,Dt(d)):i}var up=Bt(Lu);function Lu(h,d){return h&&h.length&&d&&d.length?Vo(h,d):h}function fp(h,d,p){return h&&h.length&&d&&d.length?Vo(h,d,At(p,2)):h}function dp(h,d,p){return h&&h.length&&d&&d.length?Vo(h,d,i,p):h}var gp=Oi(function(h,d){var p=h==null?0:h.length,A=Fo(h,d);return Vh(h,ne(d,function(B){return Fi(B,p)?+B:B}).sort(eu)),A});function vp(h,d){var p=[];if(!(h&&h.length))return p;var A=-1,B=[],z=h.length;for(d=At(d,3);++A<z;){var q=h[A];d(q,A,h)&&(p.push(q),B.push(A))}return Vh(h,B),p}function ul(h){return h==null?h:l0.call(h)}function yp(h,d,p){var A=h==null?0:h.length;return A?(p&&typeof p!="number"&&Ie(h,d,p)?(d=0,p=A):(d=d==null?0:Dt(d),p=p===i?A:Dt(p)),oi(h,d,p)):[]}function mp(h,d){return Ja(h,d)}function pp(h,d,p){return Ko(h,d,At(p,2))}function wp(h,d){var p=h==null?0:h.length;if(p){var A=Ja(h,d);if(A<p&&mi(h[A],d))return A}return-1}function bp(h,d){return Ja(h,d,!0)}function xp(h,d,p){return Ko(h,d,At(p,2),!0)}function _p(h,d){var p=h==null?0:h.length;if(p){var A=Ja(h,d,!0)-1;if(mi(h[A],d))return A}return-1}function kp(h){return h&&h.length?Yh(h):[]}function Ep(h,d){return h&&h.length?Yh(h,At(d,2)):[]}function Ap(h){var d=h==null?0:h.length;return d?oi(h,1,d):[]}function Cp(h,d,p){return h&&h.length?(d=p||d===i?1:Dt(d),oi(h,0,d<0?0:d)):[]}function Rp(h,d,p){var A=h==null?0:h.length;return A?(d=p||d===i?1:Dt(d),d=A-d,oi(h,d<0?0:d,A)):[]}function Tp(h,d){return h&&h.length?Qa(h,At(d,3),!1,!0):[]}function Sp(h,d){return h&&h.length?Qa(h,At(d,3)):[]}var Pp=Bt(function(h){return as(ke(h,1,ue,!0))}),Ip=Bt(function(h){var d=li(h);return ue(d)&&(d=i),as(ke(h,1,ue,!0),At(d,2))}),Lp=Bt(function(h){var d=li(h);return d=typeof d=="function"?d:i,as(ke(h,1,ue,!0),i,d)});function Dp(h){return h&&h.length?as(h):[]}function Mp(h,d){return h&&h.length?as(h,At(d,2)):[]}function Bp(h,d){return d=typeof d=="function"?d:i,h&&h.length?as(h,i,d):[]}function fl(h){if(!(h&&h.length))return[];var d=0;return h=ts(h,function(p){if(ue(p))return d=ye(p.length,d),!0}),So(d,function(p){return ne(h,Co(p))})}function Du(h,d){if(!(h&&h.length))return[];var p=fl(h);return d==null?p:ne(p,function(A){return qe(d,i,A)})}var Op=Bt(function(h,d){return ue(h)?$n(h,d):[]}),Fp=Bt(function(h){return Go(ts(h,ue))}),Np=Bt(function(h){var d=li(h);return ue(d)&&(d=i),Go(ts(h,ue),At(d,2))}),zp=Bt(function(h){var d=li(h);return d=typeof d=="function"?d:i,Go(ts(h,ue),i,d)}),Hp=Bt(fl);function Wp(h,d){return Zh(h||[],d||[],Un)}function Up(h,d){return Zh(h||[],d||[],qn)}var $p=Bt(function(h){var d=h.length,p=d>1?h[d-1]:i;return p=typeof p=="function"?(h.pop(),p):i,Du(h,p)});function Mu(h){var d=F(h);return d.__chain__=!0,d}function jp(h,d){return d(h),h}function lr(h,d){return d(h)}var Vp=Oi(function(h){var d=h.length,p=d?h[0]:0,A=this.__wrapped__,B=function(z){return Fo(z,h)};return d>1||this.__actions__.length||!(A instanceof Nt)||!Fi(p)?this.thru(B):(A=A.slice(p,+p+(d?1:0)),A.__actions__.push({func:lr,args:[B],thisArg:i}),new ai(A,this.__chain__).thru(function(z){return d&&!z.length&&z.push(i),z}))});function qp(){return Mu(this)}function Yp(){return new ai(this.value(),this.__chain__)}function Kp(){this.__values__===i&&(this.__values__=Ku(this.value()));var h=this.__index__>=this.__values__.length,d=h?i:this.__values__[this.__index__++];return{done:h,value:d}}function Xp(){return this}function Gp(h){for(var d,p=this;p instanceof Ya;){var A=Ru(p);A.__index__=0,A.__values__=i,d?B.__wrapped__=A:d=A;var B=A;p=p.__wrapped__}return B.__wrapped__=h,d}function Zp(){var h=this.__wrapped__;if(h instanceof Nt){var d=h;return this.__actions__.length&&(d=new Nt(this)),d=d.reverse(),d.__actions__.push({func:lr,args:[ul],thisArg:i}),new ai(d,this.__chain__)}return this.thru(ul)}function Jp(){return Gh(this.__wrapped__,this.__actions__)}var Qp=tr(function(h,d,p){Xt.call(h,p)?++h[p]:Mi(h,p,1)});function tw(h,d,p){var A=Pt(h)?ch:j0;return p&&Ie(h,d,p)&&(d=i),A(h,At(d,3))}function ew(h,d){var p=Pt(h)?ts:Dh;return p(h,At(d,3))}var iw=ou(Tu),sw=ou(Su);function nw(h,d){return ke(cr(h,d),1)}function aw(h,d){return ke(cr(h,d),at)}function rw(h,d,p){return p=p===i?1:Dt(p),ke(cr(h,d),p)}function Bu(h,d){var p=Pt(h)?si:ns;return p(h,At(d,3))}function Ou(h,d){var p=Pt(h)?Ay:Lh;return p(h,At(d,3))}var ow=tr(function(h,d,p){Xt.call(h,p)?h[p].push(d):Mi(h,p,[d])});function lw(h,d,p,A){h=Fe(h)?h:un(h),p=p&&!A?Dt(p):0;var B=h.length;return p<0&&(p=ye(B+p,0)),gr(h)?p<=B&&h.indexOf(d,p)>-1:!!B&&Js(h,d,p)>-1}var cw=Bt(function(h,d,p){var A=-1,B=typeof d=="function",z=Fe(h)?lt(h.length):[];return ns(h,function(q){z[++A]=B?qe(d,q,p):jn(q,d,p)}),z}),hw=tr(function(h,d,p){Mi(h,p,d)});function cr(h,d){var p=Pt(h)?ne:zh;return p(h,At(d,3))}function uw(h,d,p,A){return h==null?[]:(Pt(d)||(d=d==null?[]:[d]),p=A?i:p,Pt(p)||(p=p==null?[]:[p]),$h(h,d,p))}var fw=tr(function(h,d,p){h[p?0:1].push(d)},function(){return[[],[]]});function dw(h,d,p){var A=Pt(h)?Eo:dh,B=arguments.length<3;return A(h,At(d,4),p,B,ns)}function gw(h,d,p){var A=Pt(h)?Cy:dh,B=arguments.length<3;return A(h,At(d,4),p,B,Lh)}function vw(h,d){var p=Pt(h)?ts:Dh;return p(h,fr(At(d,3)))}function yw(h){var d=Pt(h)?Th:lm;return d(h)}function mw(h,d,p){(p?Ie(h,d,p):d===i)?d=1:d=Dt(d);var A=Pt(h)?z0:cm;return A(h,d)}function pw(h){var d=Pt(h)?H0:um;return d(h)}function ww(h){if(h==null)return 0;if(Fe(h))return gr(h)?tn(h):h.length;var d=Se(h);return d==G||d==se?h.size:$o(h).length}function bw(h,d,p){var A=Pt(h)?Ao:fm;return p&&Ie(h,d,p)&&(d=i),A(h,At(d,3))}var xw=Bt(function(h,d){if(h==null)return[];var p=d.length;return p>1&&Ie(h,d[0],d[1])?d=[]:p>2&&Ie(d[0],d[1],d[2])&&(d=[d[0]]),$h(h,ke(d,1),[])}),hr=e0||function(){return _e.Date.now()};function _w(h,d){if(typeof d!="function")throw new ni(r);return h=Dt(h),function(){if(--h<1)return d.apply(this,arguments)}}function Fu(h,d,p){return d=p?i:d,d=h&&d==null?h.length:d,Bi(h,M,i,i,i,i,d)}function Nu(h,d){var p;if(typeof d!="function")throw new ni(r);return h=Dt(h),function(){return--h>0&&(p=d.apply(this,arguments)),h<=1&&(d=i),p}}var dl=Bt(function(h,d,p){var A=m;if(p.length){var B=is(p,cn(dl));A|=S}return Bi(h,A,d,p,B)}),zu=Bt(function(h,d,p){var A=m|_;if(p.length){var B=is(p,cn(zu));A|=S}return Bi(d,A,h,p,B)});function Hu(h,d,p){d=p?i:d;var A=Bi(h,x,i,i,i,i,i,d);return A.placeholder=Hu.placeholder,A}function Wu(h,d,p){d=p?i:d;var A=Bi(h,C,i,i,i,i,i,d);return A.placeholder=Wu.placeholder,A}function Uu(h,d,p){var A,B,z,q,J,nt,dt=0,gt=!1,vt=!1,pt=!0;if(typeof h!="function")throw new ni(r);d=ci(d)||0,oe(p)&&(gt=!!p.leading,vt="maxWait"in p,z=vt?ye(ci(p.maxWait)||0,d):z,pt="trailing"in p?!!p.trailing:pt);function _t(fe){var pi=A,Hi=B;return A=B=i,dt=fe,q=h.apply(Hi,pi),q}function Ct(fe){return dt=fe,J=Xn(Ft,d),gt?_t(fe):q}function Mt(fe){var pi=fe-nt,Hi=fe-dt,lf=d-pi;return vt?Te(lf,z-Hi):lf}function Rt(fe){var pi=fe-nt,Hi=fe-dt;return nt===i||pi>=d||pi<0||vt&&Hi>=z}function Ft(){var fe=hr();if(Rt(fe))return Ht(fe);J=Xn(Ft,Mt(fe))}function Ht(fe){return J=i,pt&&A?_t(fe):(A=B=i,q)}function Ge(){J!==i&&Jh(J),dt=0,A=nt=B=J=i}function Le(){return J===i?q:Ht(hr())}function Ze(){var fe=hr(),pi=Rt(fe);if(A=arguments,B=this,nt=fe,pi){if(J===i)return Ct(nt);if(vt)return Jh(J),J=Xn(Ft,d),_t(nt)}return J===i&&(J=Xn(Ft,d)),q}return Ze.cancel=Ge,Ze.flush=Le,Ze}var kw=Bt(function(h,d){return Ih(h,1,d)}),Ew=Bt(function(h,d,p){return Ih(h,ci(d)||0,p)});function Aw(h){return Bi(h,$)}function ur(h,d){if(typeof h!="function"||d!=null&&typeof d!="function")throw new ni(r);var p=function(){var A=arguments,B=d?d.apply(this,A):A[0],z=p.cache;if(z.has(B))return z.get(B);var q=h.apply(this,A);return p.cache=z.set(B,q)||z,q};return p.cache=new(ur.Cache||Di),p}ur.Cache=Di;function fr(h){if(typeof h!="function")throw new ni(r);return function(){var d=arguments;switch(d.length){case 0:return!h.call(this);case 1:return!h.call(this,d[0]);case 2:return!h.call(this,d[0],d[1]);case 3:return!h.call(this,d[0],d[1],d[2])}return!h.apply(this,d)}}function Cw(h){return Nu(2,h)}var Rw=dm(function(h,d){d=d.length==1&&Pt(d[0])?ne(d[0],Ye(At())):ne(ke(d,1),Ye(At()));var p=d.length;return Bt(function(A){for(var B=-1,z=Te(A.length,p);++B<z;)A[B]=d[B].call(this,A[B]);return qe(h,this,A)})}),gl=Bt(function(h,d){var p=is(d,cn(gl));return Bi(h,S,i,d,p)}),$u=Bt(function(h,d){var p=is(d,cn($u));return Bi(h,L,i,d,p)}),Tw=Oi(function(h,d){return Bi(h,D,i,i,i,d)});function Sw(h,d){if(typeof h!="function")throw new ni(r);return d=d===i?d:Dt(d),Bt(h,d)}function Pw(h,d){if(typeof h!="function")throw new ni(r);return d=d==null?0:ye(Dt(d),0),Bt(function(p){var A=p[d],B=os(p,0,d);return A&&es(B,A),qe(h,this,B)})}function Iw(h,d,p){var A=!0,B=!0;if(typeof h!="function")throw new ni(r);return oe(p)&&(A="leading"in p?!!p.leading:A,B="trailing"in p?!!p.trailing:B),Uu(h,d,{leading:A,maxWait:d,trailing:B})}function Lw(h){return Fu(h,1)}function Dw(h,d){return gl(Jo(d),h)}function Mw(){if(!arguments.length)return[];var h=arguments[0];return Pt(h)?h:[h]}function Bw(h){return ri(h,v)}function Ow(h,d){return d=typeof d=="function"?d:i,ri(h,v,d)}function Fw(h){return ri(h,f|v)}function Nw(h,d){return d=typeof d=="function"?d:i,ri(h,f|v,d)}function zw(h,d){return d==null||Ph(h,d,pe(d))}function mi(h,d){return h===d||h!==h&&d!==d}var Hw=nr(Ho),Ww=nr(function(h,d){return h>=d}),Ss=Oh(function(){return arguments}())?Oh:function(h){return ce(h)&&Xt.call(h,"callee")&&!_h.call(h,"callee")},Pt=lt.isArray,Uw=sh?Ye(sh):G0;function Fe(h){return h!=null&&dr(h.length)&&!Ni(h)}function ue(h){return ce(h)&&Fe(h)}function $w(h){return h===!0||h===!1||ce(h)&&Pe(h)==ot}var ls=s0||Al,jw=nh?Ye(nh):Z0;function Vw(h){return ce(h)&&h.nodeType===1&&!Gn(h)}function qw(h){if(h==null)return!0;if(Fe(h)&&(Pt(h)||typeof h=="string"||typeof h.splice=="function"||ls(h)||hn(h)||Ss(h)))return!h.length;var d=Se(h);if(d==G||d==se)return!h.size;if(Kn(h))return!$o(h).length;for(var p in h)if(Xt.call(h,p))return!1;return!0}function Yw(h,d){return Vn(h,d)}function Kw(h,d,p){p=typeof p=="function"?p:i;var A=p?p(h,d):i;return A===i?Vn(h,d,i,p):!!A}function vl(h){if(!ce(h))return!1;var d=Pe(h);return d==I||d==k||typeof h.message=="string"&&typeof h.name=="string"&&!Gn(h)}function Xw(h){return typeof h=="number"&&Eh(h)}function Ni(h){if(!oe(h))return!1;var d=Pe(h);return d==N||d==X||d==ct||d==Tt}function ju(h){return typeof h=="number"&&h==Dt(h)}function dr(h){return typeof h=="number"&&h>-1&&h%1==0&&h<=V}function oe(h){var d=typeof h;return h!=null&&(d=="object"||d=="function")}function ce(h){return h!=null&&typeof h=="object"}var Vu=ah?Ye(ah):Q0;function Gw(h,d){return h===d||Uo(h,d,al(d))}function Zw(h,d,p){return p=typeof p=="function"?p:i,Uo(h,d,al(d),p)}function Jw(h){return qu(h)&&h!=+h}function Qw(h){if(Om(h))throw new St(a);return Fh(h)}function tb(h){return h===null}function eb(h){return h==null}function qu(h){return typeof h=="number"||ce(h)&&Pe(h)==rt}function Gn(h){if(!ce(h)||Pe(h)!=yt)return!1;var d=Ha(h);if(d===null)return!0;var p=Xt.call(d,"constructor")&&d.constructor;return typeof p=="function"&&p instanceof p&&Oa.call(p)==Zy}var yl=rh?Ye(rh):tm;function ib(h){return ju(h)&&h>=-V&&h<=V}var Yu=oh?Ye(oh):em;function gr(h){return typeof h=="string"||!Pt(h)&&ce(h)&&Pe(h)==xe}function Xe(h){return typeof h=="symbol"||ce(h)&&Pe(h)==Vt}var hn=lh?Ye(lh):im;function sb(h){return h===i}function nb(h){return ce(h)&&Se(h)==xi}function ab(h){return ce(h)&&Pe(h)==xv}var rb=nr(jo),ob=nr(function(h,d){return h<=d});function Ku(h){if(!h)return[];if(Fe(h))return gr(h)?vi(h):Oe(h);if(Fn&&h[Fn])return zy(h[Fn]());var d=Se(h),p=d==G?Io:d==se?Da:un;return p(h)}function zi(h){if(!h)return h===0?h:0;if(h=ci(h),h===at||h===-at){var d=h<0?-1:1;return d*H}return h===h?h:0}function Dt(h){var d=zi(h),p=d%1;return d===d?p?d-p:d:0}function Xu(h){return h?As(Dt(h),0,K):0}function ci(h){if(typeof h=="number")return h;if(Xe(h))return j;if(oe(h)){var d=typeof h.valueOf=="function"?h.valueOf():h;h=oe(d)?d+"":d}if(typeof h!="string")return h===0?h:+h;h=gh(h);var p=Uv.test(h);return p||jv.test(h)?_y(h.slice(2),p?2:8):Wv.test(h)?j:+h}function Gu(h){return ki(h,Ne(h))}function lb(h){return h?As(Dt(h),-V,V):h===0?h:0}function Kt(h){return h==null?"":Ke(h)}var cb=on(function(h,d){if(Kn(d)||Fe(d)){ki(d,pe(d),h);return}for(var p in d)Xt.call(d,p)&&Un(h,p,d[p])}),Zu=on(function(h,d){ki(d,Ne(d),h)}),vr=on(function(h,d,p,A){ki(d,Ne(d),h,A)}),hb=on(function(h,d,p,A){ki(d,pe(d),h,A)}),ub=Oi(Fo);function fb(h,d){var p=rn(h);return d==null?p:Sh(p,d)}var db=Bt(function(h,d){h=Zt(h);var p=-1,A=d.length,B=A>2?d[2]:i;for(B&&Ie(d[0],d[1],B)&&(A=1);++p<A;)for(var z=d[p],q=Ne(z),J=-1,nt=q.length;++J<nt;){var dt=q[J],gt=h[dt];(gt===i||mi(gt,sn[dt])&&!Xt.call(h,dt))&&(h[dt]=z[dt])}return h}),gb=Bt(function(h){return h.push(i,gu),qe(Ju,i,h)});function vb(h,d){return hh(h,At(d,3),_i)}function yb(h,d){return hh(h,At(d,3),zo)}function mb(h,d){return h==null?h:No(h,At(d,3),Ne)}function pb(h,d){return h==null?h:Mh(h,At(d,3),Ne)}function wb(h,d){return h&&_i(h,At(d,3))}function bb(h,d){return h&&zo(h,At(d,3))}function xb(h){return h==null?[]:Ga(h,pe(h))}function _b(h){return h==null?[]:Ga(h,Ne(h))}function ml(h,d,p){var A=h==null?i:Cs(h,d);return A===i?p:A}function kb(h,d){return h!=null&&mu(h,d,q0)}function pl(h,d){return h!=null&&mu(h,d,Y0)}var Eb=cu(function(h,d,p){d!=null&&typeof d.toString!="function"&&(d=Fa.call(d)),h[d]=p},bl(ze)),Ab=cu(function(h,d,p){d!=null&&typeof d.toString!="function"&&(d=Fa.call(d)),Xt.call(h,d)?h[d].push(p):h[d]=[p]},At),Cb=Bt(jn);function pe(h){return Fe(h)?Rh(h):$o(h)}function Ne(h){return Fe(h)?Rh(h,!0):sm(h)}function Rb(h,d){var p={};return d=At(d,3),_i(h,function(A,B,z){Mi(p,d(A,B,z),A)}),p}function Tb(h,d){var p={};return d=At(d,3),_i(h,function(A,B,z){Mi(p,B,d(A,B,z))}),p}var Sb=on(function(h,d,p){Za(h,d,p)}),Ju=on(function(h,d,p,A){Za(h,d,p,A)}),Pb=Oi(function(h,d){var p={};if(h==null)return p;var A=!1;d=ne(d,function(z){return z=rs(z,h),A||(A=z.length>1),z}),ki(h,sl(h),p),A&&(p=ri(p,f|g|v,Em));for(var B=d.length;B--;)Xo(p,d[B]);return p});function Ib(h,d){return Qu(h,fr(At(d)))}var Lb=Oi(function(h,d){return h==null?{}:am(h,d)});function Qu(h,d){if(h==null)return{};var p=ne(sl(h),function(A){return[A]});return d=At(d),jh(h,p,function(A,B){return d(A,B[0])})}function Db(h,d,p){d=rs(d,h);var A=-1,B=d.length;for(B||(B=1,h=i);++A<B;){var z=h==null?i:h[Ei(d[A])];z===i&&(A=B,z=p),h=Ni(z)?z.call(h):z}return h}function Mb(h,d,p){return h==null?h:qn(h,d,p)}function Bb(h,d,p,A){return A=typeof A=="function"?A:i,h==null?h:qn(h,d,p,A)}var tf=fu(pe),ef=fu(Ne);function Ob(h,d,p){var A=Pt(h),B=A||ls(h)||hn(h);if(d=At(d,4),p==null){var z=h&&h.constructor;B?p=A?new z:[]:oe(h)?p=Ni(z)?rn(Ha(h)):{}:p={}}return(B?si:_i)(h,function(q,J,nt){return d(p,q,J,nt)}),p}function Fb(h,d){return h==null?!0:Xo(h,d)}function Nb(h,d,p){return h==null?h:Xh(h,d,Jo(p))}function zb(h,d,p,A){return A=typeof A=="function"?A:i,h==null?h:Xh(h,d,Jo(p),A)}function un(h){return h==null?[]:Po(h,pe(h))}function Hb(h){return h==null?[]:Po(h,Ne(h))}function Wb(h,d,p){return p===i&&(p=d,d=i),p!==i&&(p=ci(p),p=p===p?p:0),d!==i&&(d=ci(d),d=d===d?d:0),As(ci(h),d,p)}function Ub(h,d,p){return d=zi(d),p===i?(p=d,d=0):p=zi(p),h=ci(h),K0(h,d,p)}function $b(h,d,p){if(p&&typeof p!="boolean"&&Ie(h,d,p)&&(d=p=i),p===i&&(typeof d=="boolean"?(p=d,d=i):typeof h=="boolean"&&(p=h,h=i)),h===i&&d===i?(h=0,d=1):(h=zi(h),d===i?(d=h,h=0):d=zi(d)),h>d){var A=h;h=d,d=A}if(p||h%1||d%1){var B=Ah();return Te(h+B*(d-h+xy("1e-"+((B+"").length-1))),d)}return qo(h,d)}var jb=ln(function(h,d,p){return d=d.toLowerCase(),h+(p?sf(d):d)});function sf(h){return wl(Kt(h).toLowerCase())}function nf(h){return h=Kt(h),h&&h.replace(qv,My).replace(uy,"")}function Vb(h,d,p){h=Kt(h),d=Ke(d);var A=h.length;p=p===i?A:As(Dt(p),0,A);var B=p;return p-=d.length,p>=0&&h.slice(p,B)==d}function qb(h){return h=Kt(h),h&&Cv.test(h)?h.replace(Mc,By):h}function Yb(h){return h=Kt(h),h&&Lv.test(h)?h.replace(go,"\\$&"):h}var Kb=ln(function(h,d,p){return h+(p?"-":"")+d.toLowerCase()}),Xb=ln(function(h,d,p){return h+(p?" ":"")+d.toLowerCase()}),Gb=ru("toLowerCase");function Zb(h,d,p){h=Kt(h),d=Dt(d);var A=d?tn(h):0;if(!d||A>=d)return h;var B=(d-A)/2;return sr(ja(B),p)+h+sr($a(B),p)}function Jb(h,d,p){h=Kt(h),d=Dt(d);var A=d?tn(h):0;return d&&A<d?h+sr(d-A,p):h}function Qb(h,d,p){h=Kt(h),d=Dt(d);var A=d?tn(h):0;return d&&A<d?sr(d-A,p)+h:h}function t1(h,d,p){return p||d==null?d=0:d&&(d=+d),o0(Kt(h).replace(vo,""),d||0)}function e1(h,d,p){return(p?Ie(h,d,p):d===i)?d=1:d=Dt(d),Yo(Kt(h),d)}function i1(){var h=arguments,d=Kt(h[0]);return h.length<3?d:d.replace(h[1],h[2])}var s1=ln(function(h,d,p){return h+(p?"_":"")+d.toLowerCase()});function n1(h,d,p){return p&&typeof p!="number"&&Ie(h,d,p)&&(d=p=i),p=p===i?K:p>>>0,p?(h=Kt(h),h&&(typeof d=="string"||d!=null&&!yl(d))&&(d=Ke(d),!d&&Qs(h))?os(vi(h),0,p):h.split(d,p)):[]}var a1=ln(function(h,d,p){return h+(p?" ":"")+wl(d)});function r1(h,d,p){return h=Kt(h),p=p==null?0:As(Dt(p),0,h.length),d=Ke(d),h.slice(p,p+d.length)==d}function o1(h,d,p){var A=F.templateSettings;p&&Ie(h,d,p)&&(d=i),h=Kt(h),d=vr({},d,A,du);var B=vr({},d.imports,A.imports,du),z=pe(B),q=Po(B,z),J,nt,dt=0,gt=d.interpolate||Ta,vt="__p += '",pt=Lo((d.escape||Ta).source+"|"+gt.source+"|"+(gt===Bc?Hv:Ta).source+"|"+(d.evaluate||Ta).source+"|$","g"),_t="//# sourceURL="+(Xt.call(d,"sourceURL")?(d.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++yy+"]")+`
- `;h.replace(pt,function(Rt,Ft,Ht,Ge,Le,Ze){return Ht||(Ht=Ge),vt+=h.slice(dt,Ze).replace(Yv,Oy),Ft&&(J=!0,vt+=`' +
- __e(`+Ft+`) +
- '`),Le&&(nt=!0,vt+=`';
- `+Le+`;
- __p += '`),Ht&&(vt+=`' +
- ((__t = (`+Ht+`)) == null ? '' : __t) +
- '`),dt=Ze+Rt.length,Rt}),vt+=`';
- `;var Ct=Xt.call(d,"variable")&&d.variable;if(!Ct)vt=`with (obj) {
- `+vt+`
- }
- `;else if(Nv.test(Ct))throw new St(l);vt=(nt?vt.replace(_v,""):vt).replace(kv,"$1").replace(Ev,"$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=rf(function(){return qt(z,_t+"return "+vt).apply(i,q)});if(Mt.source=vt,vl(Mt))throw Mt;return Mt}function l1(h){return Kt(h).toLowerCase()}function c1(h){return Kt(h).toUpperCase()}function h1(h,d,p){if(h=Kt(h),h&&(p||d===i))return gh(h);if(!h||!(d=Ke(d)))return h;var A=vi(h),B=vi(d),z=vh(A,B),q=yh(A,B)+1;return os(A,z,q).join("")}function u1(h,d,p){if(h=Kt(h),h&&(p||d===i))return h.slice(0,ph(h)+1);if(!h||!(d=Ke(d)))return h;var A=vi(h),B=yh(A,vi(d))+1;return os(A,0,B).join("")}function f1(h,d,p){if(h=Kt(h),h&&(p||d===i))return h.replace(vo,"");if(!h||!(d=Ke(d)))return h;var A=vi(h),B=vh(A,vi(d));return os(A,B).join("")}function d1(h,d){var p=Q,A=R;if(oe(d)){var B="separator"in d?d.separator:B;p="length"in d?Dt(d.length):p,A="omission"in d?Ke(d.omission):A}h=Kt(h);var z=h.length;if(Qs(h)){var q=vi(h);z=q.length}if(p>=z)return h;var J=p-tn(A);if(J<1)return A;var nt=q?os(q,0,J).join(""):h.slice(0,J);if(B===i)return nt+A;if(q&&(J+=nt.length-J),yl(B)){if(h.slice(J).search(B)){var dt,gt=nt;for(B.global||(B=Lo(B.source,Kt(Oc.exec(B))+"g")),B.lastIndex=0;dt=B.exec(gt);)var vt=dt.index;nt=nt.slice(0,vt===i?J:vt)}}else if(h.indexOf(Ke(B),J)!=J){var pt=nt.lastIndexOf(B);pt>-1&&(nt=nt.slice(0,pt))}return nt+A}function g1(h){return h=Kt(h),h&&Av.test(h)?h.replace(Dc,$y):h}var v1=ln(function(h,d,p){return h+(p?" ":"")+d.toUpperCase()}),wl=ru("toUpperCase");function af(h,d,p){return h=Kt(h),d=p?i:d,d===i?Ny(h)?qy(h):Sy(h):h.match(d)||[]}var rf=Bt(function(h,d){try{return qe(h,i,d)}catch(p){return vl(p)?p:new St(p)}}),y1=Oi(function(h,d){return si(d,function(p){p=Ei(p),Mi(h,p,dl(h[p],h))}),h});function m1(h){var d=h==null?0:h.length,p=At();return h=d?ne(h,function(A){if(typeof A[1]!="function")throw new ni(r);return[p(A[0]),A[1]]}):[],Bt(function(A){for(var B=-1;++B<d;){var z=h[B];if(qe(z[0],this,A))return qe(z[1],this,A)}})}function p1(h){return $0(ri(h,f))}function bl(h){return function(){return h}}function w1(h,d){return h==null||h!==h?d:h}var b1=lu(),x1=lu(!0);function ze(h){return h}function xl(h){return Nh(typeof h=="function"?h:ri(h,f))}function _1(h){return Hh(ri(h,f))}function k1(h,d){return Wh(h,ri(d,f))}var E1=Bt(function(h,d){return function(p){return jn(p,h,d)}}),A1=Bt(function(h,d){return function(p){return jn(h,p,d)}});function _l(h,d,p){var A=pe(d),B=Ga(d,A);p==null&&!(oe(d)&&(B.length||!A.length))&&(p=d,d=h,h=this,B=Ga(d,pe(d)));var z=!(oe(p)&&"chain"in p)||!!p.chain,q=Ni(h);return si(B,function(J){var nt=d[J];h[J]=nt,q&&(h.prototype[J]=function(){var dt=this.__chain__;if(z||dt){var gt=h(this.__wrapped__),vt=gt.__actions__=Oe(this.__actions__);return vt.push({func:nt,args:arguments,thisArg:h}),gt.__chain__=dt,gt}return nt.apply(h,es([this.value()],arguments))})}),h}function C1(){return _e._===this&&(_e._=Jy),this}function kl(){}function R1(h){return h=Dt(h),Bt(function(d){return Uh(d,h)})}var T1=tl(ne),S1=tl(ch),P1=tl(Ao);function of(h){return ol(h)?Co(Ei(h)):rm(h)}function I1(h){return function(d){return h==null?i:Cs(h,d)}}var L1=hu(),D1=hu(!0);function El(){return[]}function Al(){return!1}function M1(){return{}}function B1(){return""}function O1(){return!0}function F1(h,d){if(h=Dt(h),h<1||h>V)return[];var p=K,A=Te(h,K);d=At(d),h-=K;for(var B=So(A,d);++p<h;)d(p);return B}function N1(h){return Pt(h)?ne(h,Ei):Xe(h)?[h]:Oe(Cu(Kt(h)))}function z1(h){var d=++Gy;return Kt(h)+d}var H1=ir(function(h,d){return h+d},0),W1=el("ceil"),U1=ir(function(h,d){return h/d},1),$1=el("floor");function j1(h){return h&&h.length?Xa(h,ze,Ho):i}function V1(h,d){return h&&h.length?Xa(h,At(d,2),Ho):i}function q1(h){return fh(h,ze)}function Y1(h,d){return fh(h,At(d,2))}function K1(h){return h&&h.length?Xa(h,ze,jo):i}function X1(h,d){return h&&h.length?Xa(h,At(d,2),jo):i}var G1=ir(function(h,d){return h*d},1),Z1=el("round"),J1=ir(function(h,d){return h-d},0);function Q1(h){return h&&h.length?To(h,ze):0}function tx(h,d){return h&&h.length?To(h,At(d,2)):0}return F.after=_w,F.ary=Fu,F.assign=cb,F.assignIn=Zu,F.assignInWith=vr,F.assignWith=hb,F.at=ub,F.before=Nu,F.bind=dl,F.bindAll=y1,F.bindKey=zu,F.castArray=Mw,F.chain=Mu,F.chunk=$m,F.compact=jm,F.concat=Vm,F.cond=m1,F.conforms=p1,F.constant=bl,F.countBy=Qp,F.create=fb,F.curry=Hu,F.curryRight=Wu,F.debounce=Uu,F.defaults=db,F.defaultsDeep=gb,F.defer=kw,F.delay=Ew,F.difference=qm,F.differenceBy=Ym,F.differenceWith=Km,F.drop=Xm,F.dropRight=Gm,F.dropRightWhile=Zm,F.dropWhile=Jm,F.fill=Qm,F.filter=ew,F.flatMap=nw,F.flatMapDeep=aw,F.flatMapDepth=rw,F.flatten=Pu,F.flattenDeep=tp,F.flattenDepth=ep,F.flip=Aw,F.flow=b1,F.flowRight=x1,F.fromPairs=ip,F.functions=xb,F.functionsIn=_b,F.groupBy=ow,F.initial=np,F.intersection=ap,F.intersectionBy=rp,F.intersectionWith=op,F.invert=Eb,F.invertBy=Ab,F.invokeMap=cw,F.iteratee=xl,F.keyBy=hw,F.keys=pe,F.keysIn=Ne,F.map=cr,F.mapKeys=Rb,F.mapValues=Tb,F.matches=_1,F.matchesProperty=k1,F.memoize=ur,F.merge=Sb,F.mergeWith=Ju,F.method=E1,F.methodOf=A1,F.mixin=_l,F.negate=fr,F.nthArg=R1,F.omit=Pb,F.omitBy=Ib,F.once=Cw,F.orderBy=uw,F.over=T1,F.overArgs=Rw,F.overEvery=S1,F.overSome=P1,F.partial=gl,F.partialRight=$u,F.partition=fw,F.pick=Lb,F.pickBy=Qu,F.property=of,F.propertyOf=I1,F.pull=up,F.pullAll=Lu,F.pullAllBy=fp,F.pullAllWith=dp,F.pullAt=gp,F.range=L1,F.rangeRight=D1,F.rearg=Tw,F.reject=vw,F.remove=vp,F.rest=Sw,F.reverse=ul,F.sampleSize=mw,F.set=Mb,F.setWith=Bb,F.shuffle=pw,F.slice=yp,F.sortBy=xw,F.sortedUniq=kp,F.sortedUniqBy=Ep,F.split=n1,F.spread=Pw,F.tail=Ap,F.take=Cp,F.takeRight=Rp,F.takeRightWhile=Tp,F.takeWhile=Sp,F.tap=jp,F.throttle=Iw,F.thru=lr,F.toArray=Ku,F.toPairs=tf,F.toPairsIn=ef,F.toPath=N1,F.toPlainObject=Gu,F.transform=Ob,F.unary=Lw,F.union=Pp,F.unionBy=Ip,F.unionWith=Lp,F.uniq=Dp,F.uniqBy=Mp,F.uniqWith=Bp,F.unset=Fb,F.unzip=fl,F.unzipWith=Du,F.update=Nb,F.updateWith=zb,F.values=un,F.valuesIn=Hb,F.without=Op,F.words=af,F.wrap=Dw,F.xor=Fp,F.xorBy=Np,F.xorWith=zp,F.zip=Hp,F.zipObject=Wp,F.zipObjectDeep=Up,F.zipWith=$p,F.entries=tf,F.entriesIn=ef,F.extend=Zu,F.extendWith=vr,_l(F,F),F.add=H1,F.attempt=rf,F.camelCase=jb,F.capitalize=sf,F.ceil=W1,F.clamp=Wb,F.clone=Bw,F.cloneDeep=Fw,F.cloneDeepWith=Nw,F.cloneWith=Ow,F.conformsTo=zw,F.deburr=nf,F.defaultTo=w1,F.divide=U1,F.endsWith=Vb,F.eq=mi,F.escape=qb,F.escapeRegExp=Yb,F.every=tw,F.find=iw,F.findIndex=Tu,F.findKey=vb,F.findLast=sw,F.findLastIndex=Su,F.findLastKey=yb,F.floor=$1,F.forEach=Bu,F.forEachRight=Ou,F.forIn=mb,F.forInRight=pb,F.forOwn=wb,F.forOwnRight=bb,F.get=ml,F.gt=Hw,F.gte=Ww,F.has=kb,F.hasIn=pl,F.head=Iu,F.identity=ze,F.includes=lw,F.indexOf=sp,F.inRange=Ub,F.invoke=Cb,F.isArguments=Ss,F.isArray=Pt,F.isArrayBuffer=Uw,F.isArrayLike=Fe,F.isArrayLikeObject=ue,F.isBoolean=$w,F.isBuffer=ls,F.isDate=jw,F.isElement=Vw,F.isEmpty=qw,F.isEqual=Yw,F.isEqualWith=Kw,F.isError=vl,F.isFinite=Xw,F.isFunction=Ni,F.isInteger=ju,F.isLength=dr,F.isMap=Vu,F.isMatch=Gw,F.isMatchWith=Zw,F.isNaN=Jw,F.isNative=Qw,F.isNil=eb,F.isNull=tb,F.isNumber=qu,F.isObject=oe,F.isObjectLike=ce,F.isPlainObject=Gn,F.isRegExp=yl,F.isSafeInteger=ib,F.isSet=Yu,F.isString=gr,F.isSymbol=Xe,F.isTypedArray=hn,F.isUndefined=sb,F.isWeakMap=nb,F.isWeakSet=ab,F.join=lp,F.kebabCase=Kb,F.last=li,F.lastIndexOf=cp,F.lowerCase=Xb,F.lowerFirst=Gb,F.lt=rb,F.lte=ob,F.max=j1,F.maxBy=V1,F.mean=q1,F.meanBy=Y1,F.min=K1,F.minBy=X1,F.stubArray=El,F.stubFalse=Al,F.stubObject=M1,F.stubString=B1,F.stubTrue=O1,F.multiply=G1,F.nth=hp,F.noConflict=C1,F.noop=kl,F.now=hr,F.pad=Zb,F.padEnd=Jb,F.padStart=Qb,F.parseInt=t1,F.random=$b,F.reduce=dw,F.reduceRight=gw,F.repeat=e1,F.replace=i1,F.result=Db,F.round=Z1,F.runInContext=it,F.sample=yw,F.size=ww,F.snakeCase=s1,F.some=bw,F.sortedIndex=mp,F.sortedIndexBy=pp,F.sortedIndexOf=wp,F.sortedLastIndex=bp,F.sortedLastIndexBy=xp,F.sortedLastIndexOf=_p,F.startCase=a1,F.startsWith=r1,F.subtract=J1,F.sum=Q1,F.sumBy=tx,F.template=o1,F.times=F1,F.toFinite=zi,F.toInteger=Dt,F.toLength=Xu,F.toLower=l1,F.toNumber=ci,F.toSafeInteger=lb,F.toString=Kt,F.toUpper=c1,F.trim=h1,F.trimEnd=u1,F.trimStart=f1,F.truncate=d1,F.unescape=g1,F.uniqueId=z1,F.upperCase=v1,F.upperFirst=wl,F.each=Bu,F.eachRight=Ou,F.first=Iu,_l(F,function(){var h={};return _i(F,function(d,p){Xt.call(F.prototype,p)||(h[p]=d)}),h}(),{chain:!1}),F.VERSION=s,si(["bind","bindKey","curry","curryRight","partial","partialRight"],function(h){F[h].placeholder=F}),si(["drop","take"],function(h,d){Nt.prototype[h]=function(p){p=p===i?1:ye(Dt(p),0);var A=this.__filtered__&&!d?new Nt(this):this.clone();return A.__filtered__?A.__takeCount__=Te(p,A.__takeCount__):A.__views__.push({size:Te(p,K),type:h+(A.__dir__<0?"Right":"")}),A},Nt.prototype[h+"Right"]=function(p){return this.reverse()[h](p).reverse()}}),si(["filter","map","takeWhile"],function(h,d){var p=d+1,A=p==O||p==Z;Nt.prototype[h]=function(B){var z=this.clone();return z.__iteratees__.push({iteratee:At(B,3),type:p}),z.__filtered__=z.__filtered__||A,z}}),si(["head","last"],function(h,d){var p="take"+(d?"Right":"");Nt.prototype[h]=function(){return this[p](1).value()[0]}}),si(["initial","tail"],function(h,d){var p="drop"+(d?"":"Right");Nt.prototype[h]=function(){return this.__filtered__?new Nt(this):this[p](1)}}),Nt.prototype.compact=function(){return this.filter(ze)},Nt.prototype.find=function(h){return this.filter(h).head()},Nt.prototype.findLast=function(h){return this.reverse().find(h)},Nt.prototype.invokeMap=Bt(function(h,d){return typeof h=="function"?new Nt(this):this.map(function(p){return jn(p,h,d)})}),Nt.prototype.reject=function(h){return this.filter(fr(At(h)))},Nt.prototype.slice=function(h,d){h=Dt(h);var p=this;return p.__filtered__&&(h>0||d<0)?new Nt(p):(h<0?p=p.takeRight(-h):h&&(p=p.drop(h)),d!==i&&(d=Dt(d),p=d<0?p.dropRight(-d):p.take(d-h)),p)},Nt.prototype.takeRightWhile=function(h){return this.reverse().takeWhile(h).reverse()},Nt.prototype.toArray=function(){return this.take(K)},_i(Nt.prototype,function(h,d){var p=/^(?:filter|find|map|reject)|While$/.test(d),A=/^(?:head|last)$/.test(d),B=F[A?"take"+(d=="last"?"Right":""):d],z=A||/^find/.test(d);!B||(F.prototype[d]=function(){var q=this.__wrapped__,J=A?[1]:arguments,nt=q instanceof Nt,dt=J[0],gt=nt||Pt(q),vt=function(Ft){var Ht=B.apply(F,es([Ft],J));return A&&pt?Ht[0]:Ht};gt&&p&&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 Nt(this);var Rt=h.apply(q,J);return Rt.__actions__.push({func:lr,args:[vt],thisArg:i}),new ai(Rt,pt)}return Ct&&Mt?h.apply(this,J):(Rt=this.thru(vt),Ct?A?Rt.value()[0]:Rt.value():Rt)})}),si(["pop","push","shift","sort","splice","unshift"],function(h){var d=Ma[h],p=/^(?:push|sort|unshift)$/.test(h)?"tap":"thru",A=/^(?:pop|shift)$/.test(h);F.prototype[h]=function(){var B=arguments;if(A&&!this.__chain__){var z=this.value();return d.apply(Pt(z)?z:[],B)}return this[p](function(q){return d.apply(Pt(q)?q:[],B)})}}),_i(Nt.prototype,function(h,d){var p=F[d];if(p){var A=p.name+"";Xt.call(an,A)||(an[A]=[]),an[A].push({name:d,func:p})}}),an[er(i,_).name]=[{name:"wrapper",func:i}],Nt.prototype.clone=g0,Nt.prototype.reverse=v0,Nt.prototype.value=y0,F.prototype.at=Vp,F.prototype.chain=qp,F.prototype.commit=Yp,F.prototype.next=Kp,F.prototype.plant=Gp,F.prototype.reverse=Zp,F.prototype.toJSON=F.prototype.valueOf=F.prototype.value=Jp,F.prototype.first=F.prototype.head,Fn&&(F.prototype[Fn]=Xp),F},en=Yy();xs?((xs.exports=en)._=en,xo._=en):_e._=en}).call(De)})(gc,gc.exports);const IR=gc.exports;export{Ak as M,IR as _,fR as a,gR as b,vR as c,yR as d,bR as e,uR as f,dR as g,pR as h,xR as i,_R as j,kR as k,SR as l,RR as m,AR as n,CR as o,PR as p,TR as q,mR as r,wR as s,ER as t};
|