diff --git a/assets/index.b23b175b.js b/assets/index.45dec1d5.js similarity index 97% rename from assets/index.b23b175b.js rename to assets/index.45dec1d5.js index 0495b69..2d0e827 100644 --- a/assets/index.b23b175b.js +++ b/assets/index.45dec1d5.js @@ -86,12 +86,12 @@ hooks.version="2.29.4";setHookCallback(createLocal);hooks.fn=proto;hooks.min=min * http://www.w3.org/TR/css3-color/#svg-color * * @preserve - */(function(e,t){(function(r,n){e.exports=n()})(commonjsGlobal$2,function(){for(var r=function(Me,He,qe){return He===void 0&&(He=0),qe===void 0&&(qe=1),Meqe?qe:Me},n=r,o=function(Me){Me._clipped=!1,Me._unclipped=Me.slice(0);for(var He=0;He<=3;He++)He<3?((Me[He]<0||Me[He]>255)&&(Me._clipped=!0),Me[He]=n(Me[He],0,255)):He===3&&(Me[He]=n(Me[He],0,1));return Me},a={},l=0,c=["Boolean","Number","String","Function","Array","Date","RegExp","Undefined","Null"];l=3?Array.prototype.slice.call(Me):_(Me[0])=="object"&&He?He.split("").filter(function(qe){return Me[0][qe]!==void 0}).map(function(qe){return Me[0][qe]}):Me[0]},S=g,O=function(Me){if(Me.length<2)return null;var He=Me.length-1;return S(Me[He])=="string"?Me[He].toLowerCase():null},E=Math.PI,T={clip_rgb:o,limit:r,type:g,unpack:x,last:O,PI:E,TWOPI:E*2,PITHIRD:E/3,DEG2RAD:E/180,RAD2DEG:180/E},D={format:{},autodetect:[]},$=T.last,I=T.clip_rgb,H=T.type,se=D,ie=function(){for(var He=[],qe=arguments.length;qe--;)He[qe]=arguments[qe];var ot=this;if(H(He[0])==="object"&&He[0].constructor&&He[0].constructor===this.constructor)return He[0];var dt=$(He),ft=!1;if(!dt){ft=!0,se.sorted||(se.autodetect=se.autodetect.sort(function(Ct,Pt){return Pt.p-Ct.p}),se.sorted=!0);for(var ht=0,mt=se.autodetect;ht4?Me[4]:1;return ft===1?[0,0,0,ht]:[qe>=1?0:255*(1-qe)*(1-ft),ot>=1?0:255*(1-ot)*(1-ft),dt>=1?0:255*(1-dt)*(1-ft),ht]},N=te,B=me,ee=ne,oe=D,he=T.unpack,be=T.type,Ce=ve;ee.prototype.cmyk=function(){return Ce(this._rgb)},B.cmyk=function(){for(var Me=[],He=arguments.length;He--;)Me[He]=arguments[He];return new(Function.prototype.bind.apply(ee,[null].concat(Me,["cmyk"])))},oe.format.cmyk=N,oe.autodetect.push({p:2,test:function(){for(var Me=[],He=arguments.length;He--;)Me[He]=arguments[He];if(Me=he(Me,"cmyk"),be(Me)==="array"&&Me.length===4)return"cmyk"}});var Oe=T.unpack,Se=T.last,$e=function(Me){return Math.round(Me*100)/100},ke=function(){for(var Me=[],He=arguments.length;He--;)Me[He]=arguments[He];var qe=Oe(Me,"hsla"),ot=Se(Me)||"lsa";return qe[0]=$e(qe[0]||0),qe[1]=$e(qe[1]*100)+"%",qe[2]=$e(qe[2]*100)+"%",ot==="hsla"||qe.length>3&&qe[3]<1?(qe[3]=qe.length>3?qe[3]:1,ot="hsla"):qe.length=3,ot+"("+qe.join(",")+")"},Re=ke,Be=T.unpack,Ee=function(){for(var Me=[],He=arguments.length;He--;)Me[He]=arguments[He];Me=Be(Me,"rgba");var qe=Me[0],ot=Me[1],dt=Me[2];qe/=255,ot/=255,dt/=255;var ft=Math.min(qe,ot,dt),ht=Math.max(qe,ot,dt),mt=(ht+ft)/2,yt,xt;return ht===ft?(yt=0,xt=Number.NaN):yt=mt<.5?(ht-ft)/(ht+ft):(ht-ft)/(2-ht-ft),qe==ht?xt=(ot-dt)/(ht-ft):ot==ht?xt=2+(dt-qe)/(ht-ft):dt==ht&&(xt=4+(qe-ot)/(ht-ft)),xt*=60,xt<0&&(xt+=360),Me.length>3&&Me[3]!==void 0?[xt,yt,mt,Me[3]]:[xt,yt,mt]},Pe=Ee,Ie=T.unpack,Fe=T.last,fe=Re,ae=Pe,ue=Math.round,xe=function(){for(var Me=[],He=arguments.length;He--;)Me[He]=arguments[He];var qe=Ie(Me,"rgba"),ot=Fe(Me)||"rgb";return ot.substr(0,3)=="hsl"?fe(ae(qe),ot):(qe[0]=ue(qe[0]),qe[1]=ue(qe[1]),qe[2]=ue(qe[2]),(ot==="rgba"||qe.length>3&&qe[3]<1)&&(qe[3]=qe.length>3?qe[3]:1,ot="rgba"),ot+"("+qe.slice(0,ot==="rgb"?3:4).join(",")+")")},Ae=xe,De=T.unpack,ze=Math.round,je=function(){for(var Me,He=[],qe=arguments.length;qe--;)He[qe]=arguments[qe];He=De(He,"hsl");var ot=He[0],dt=He[1],ft=He[2],ht,mt,yt;if(dt===0)ht=mt=yt=ft*255;else{var xt=[0,0,0],Ct=[0,0,0],Pt=ft<.5?ft*(1+dt):ft+dt-ft*dt,kt=2*ft-Pt,$t=ot/360;xt[0]=$t+1/3,xt[1]=$t,xt[2]=$t-1/3;for(var It=0;It<3;It++)xt[It]<0&&(xt[It]+=1),xt[It]>1&&(xt[It]-=1),6*xt[It]<1?Ct[It]=kt+(Pt-kt)*6*xt[It]:2*xt[It]<1?Ct[It]=Pt:3*xt[It]<2?Ct[It]=kt+(Pt-kt)*(2/3-xt[It])*6:Ct[It]=kt;Me=[ze(Ct[0]*255),ze(Ct[1]*255),ze(Ct[2]*255)],ht=Me[0],mt=Me[1],yt=Me[2]}return He.length>3?[ht,mt,yt,He[3]]:[ht,mt,yt,1]},Ke=je,Ze=Ke,Ge=D,Ne=/^rgb\(\s*(-?\d+),\s*(-?\d+)\s*,\s*(-?\d+)\s*\)$/,We=/^rgba\(\s*(-?\d+),\s*(-?\d+)\s*,\s*(-?\d+)\s*,\s*([01]|[01]?\.\d+)\)$/,Ye=/^rgb\(\s*(-?\d+(?:\.\d+)?)%,\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*\)$/,Qe=/^rgba\(\s*(-?\d+(?:\.\d+)?)%,\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*,\s*([01]|[01]?\.\d+)\)$/,Le=/^hsl\(\s*(-?\d+(?:\.\d+)?),\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*\)$/,ye=/^hsla\(\s*(-?\d+(?:\.\d+)?),\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*,\s*([01]|[01]?\.\d+)\)$/,we=Math.round,Ve=function(Me){Me=Me.toLowerCase().trim();var He;if(Ge.format.named)try{return Ge.format.named(Me)}catch{}if(He=Me.match(Ne)){for(var qe=He.slice(1,4),ot=0;ot<3;ot++)qe[ot]=+qe[ot];return qe[3]=1,qe}if(He=Me.match(We)){for(var dt=He.slice(1,5),ft=0;ft<4;ft++)dt[ft]=+dt[ft];return dt}if(He=Me.match(Ye)){for(var ht=He.slice(1,4),mt=0;mt<3;mt++)ht[mt]=we(ht[mt]*2.55);return ht[3]=1,ht}if(He=Me.match(Qe)){for(var yt=He.slice(1,5),xt=0;xt<3;xt++)yt[xt]=we(yt[xt]*2.55);return yt[3]=+yt[3],yt}if(He=Me.match(Le)){var Ct=He.slice(1,4);Ct[1]*=.01,Ct[2]*=.01;var Pt=Ze(Ct);return Pt[3]=1,Pt}if(He=Me.match(ye)){var kt=He.slice(1,4);kt[1]*=.01,kt[2]*=.01;var $t=Ze(kt);return $t[3]=+He[4],$t}};Ve.test=function(Me){return Ne.test(Me)||We.test(Me)||Ye.test(Me)||Qe.test(Me)||Le.test(Me)||ye.test(Me)};var Xe=Ve,nt=me,lt=ne,pt=D,_t=T.type,St=Ae,Et=Xe;lt.prototype.css=function(Me){return St(this._rgb,Me)},nt.css=function(){for(var Me=[],He=arguments.length;He--;)Me[He]=arguments[He];return new(Function.prototype.bind.apply(lt,[null].concat(Me,["css"])))},pt.format.css=Et,pt.autodetect.push({p:5,test:function(Me){for(var He=[],qe=arguments.length-1;qe-- >0;)He[qe]=arguments[qe+1];if(!He.length&&_t(Me)==="string"&&Et.test(Me))return"css"}});var bt=ne,Nt=me,Ft=D,qt=T.unpack;Ft.format.gl=function(){for(var Me=[],He=arguments.length;He--;)Me[He]=arguments[He];var qe=qt(Me,"rgba");return qe[0]*=255,qe[1]*=255,qe[2]*=255,qe},Nt.gl=function(){for(var Me=[],He=arguments.length;He--;)Me[He]=arguments[He];return new(Function.prototype.bind.apply(bt,[null].concat(Me,["gl"])))},bt.prototype.gl=function(){var Me=this._rgb;return[Me[0]/255,Me[1]/255,Me[2]/255,Me[3]]};var Xt=T.unpack,mr=function(){for(var Me=[],He=arguments.length;He--;)Me[He]=arguments[He];var qe=Xt(Me,"rgb"),ot=qe[0],dt=qe[1],ft=qe[2],ht=Math.min(ot,dt,ft),mt=Math.max(ot,dt,ft),yt=mt-ht,xt=yt*100/255,Ct=ht/(255-yt)*100,Pt;return yt===0?Pt=Number.NaN:(ot===mt&&(Pt=(dt-ft)/yt),dt===mt&&(Pt=2+(ft-ot)/yt),ft===mt&&(Pt=4+(ot-dt)/yt),Pt*=60,Pt<0&&(Pt+=360)),[Pt,xt,Ct]},nr=mr,ur=T.unpack,Mr=Math.floor,Pr=function(){for(var Me,He,qe,ot,dt,ft,ht=[],mt=arguments.length;mt--;)ht[mt]=arguments[mt];ht=ur(ht,"hcg");var yt=ht[0],xt=ht[1],Ct=ht[2],Pt,kt,$t;Ct=Ct*255;var It=xt*255;if(xt===0)Pt=kt=$t=Ct;else{yt===360&&(yt=0),yt>360&&(yt-=360),yt<0&&(yt+=360),yt/=60;var Ut=Mr(yt),Wt=yt-Ut,Yt=Ct*(1-xt),Zt=Yt+It*(1-Wt),_r=Yt+It*Wt,vr=Yt+It;switch(Ut){case 0:Me=[vr,_r,Yt],Pt=Me[0],kt=Me[1],$t=Me[2];break;case 1:He=[Zt,vr,Yt],Pt=He[0],kt=He[1],$t=He[2];break;case 2:qe=[Yt,vr,_r],Pt=qe[0],kt=qe[1],$t=qe[2];break;case 3:ot=[Yt,Zt,vr],Pt=ot[0],kt=ot[1],$t=ot[2];break;case 4:dt=[_r,Yt,vr],Pt=dt[0],kt=dt[1],$t=dt[2];break;case 5:ft=[vr,Yt,Zt],Pt=ft[0],kt=ft[1],$t=ft[2];break}}return[Pt,kt,$t,ht.length>3?ht[3]:1]},fr=Pr,hr=T.unpack,Ir=T.type,Bi=me,li=ne,Mn=D,Sr=nr;li.prototype.hcg=function(){return Sr(this._rgb)},Bi.hcg=function(){for(var Me=[],He=arguments.length;He--;)Me[He]=arguments[He];return new(Function.prototype.bind.apply(li,[null].concat(Me,["hcg"])))},Mn.format.hcg=fr,Mn.autodetect.push({p:1,test:function(){for(var Me=[],He=arguments.length;He--;)Me[He]=arguments[He];if(Me=hr(Me,"hcg"),Ir(Me)==="array"&&Me.length===3)return"hcg"}});var Lt=T.unpack,On=T.last,Ur=Math.round,Dn=function(){for(var Me=[],He=arguments.length;He--;)Me[He]=arguments[He];var qe=Lt(Me,"rgba"),ot=qe[0],dt=qe[1],ft=qe[2],ht=qe[3],mt=On(Me)||"auto";ht===void 0&&(ht=1),mt==="auto"&&(mt=ht<1?"rgba":"rgb"),ot=Ur(ot),dt=Ur(dt),ft=Ur(ft);var yt=ot<<16|dt<<8|ft,xt="000000"+yt.toString(16);xt=xt.substr(xt.length-6);var Ct="0"+Ur(ht*255).toString(16);switch(Ct=Ct.substr(Ct.length-2),mt.toLowerCase()){case"rgba":return"#"+xt+Ct;case"argb":return"#"+Ct+xt;default:return"#"+xt}},tn=Dn,rn=/^#?([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/,Nn=/^#?([A-Fa-f0-9]{8}|[A-Fa-f0-9]{4})$/,$r=function(Me){if(Me.match(rn)){(Me.length===4||Me.length===7)&&(Me=Me.substr(1)),Me.length===3&&(Me=Me.split(""),Me=Me[0]+Me[0]+Me[1]+Me[1]+Me[2]+Me[2]);var He=parseInt(Me,16),qe=He>>16,ot=He>>8&255,dt=He&255;return[qe,ot,dt,1]}if(Me.match(Nn)){(Me.length===5||Me.length===9)&&(Me=Me.substr(1)),Me.length===4&&(Me=Me.split(""),Me=Me[0]+Me[0]+Me[1]+Me[1]+Me[2]+Me[2]+Me[3]+Me[3]);var ft=parseInt(Me,16),ht=ft>>24&255,mt=ft>>16&255,yt=ft>>8&255,xt=Math.round((ft&255)/255*100)/100;return[ht,mt,yt,xt]}throw new Error("unknown hex color: "+Me)},qr=$r,ci=me,nn=ne,wo=T.type,vs=D,bs=tn;nn.prototype.hex=function(Me){return bs(this._rgb,Me)},ci.hex=function(){for(var Me=[],He=arguments.length;He--;)Me[He]=arguments[He];return new(Function.prototype.bind.apply(nn,[null].concat(Me,["hex"])))},vs.format.hex=qr,vs.autodetect.push({p:4,test:function(Me){for(var He=[],qe=arguments.length-1;qe-- >0;)He[qe]=arguments[qe+1];if(!He.length&&wo(Me)==="string"&&[3,4,5,6,7,8,9].indexOf(Me.length)>=0)return"hex"}});var Eo=T.unpack,Bn=T.TWOPI,So=Math.min,Co=Math.sqrt,ko=Math.acos,Ao=function(){for(var Me=[],He=arguments.length;He--;)Me[He]=arguments[He];var qe=Eo(Me,"rgb"),ot=qe[0],dt=qe[1],ft=qe[2];ot/=255,dt/=255,ft/=255;var ht,mt=So(ot,dt,ft),yt=(ot+dt+ft)/3,xt=yt>0?1-mt/yt:0;return xt===0?ht=NaN:(ht=(ot-dt+(ot-ft))/2,ht/=Co((ot-dt)*(ot-dt)+(ot-ft)*(dt-ft)),ht=ko(ht),ft>dt&&(ht=Bn-ht),ht/=Bn),[ht*360,xt,yt]},To=Ao,Fi=T.unpack,sn=T.limit,an=T.TWOPI,ui=T.PITHIRD,Or=Math.cos,Gt=function(){for(var Me=[],He=arguments.length;He--;)Me[He]=arguments[He];Me=Fi(Me,"hsi");var qe=Me[0],ot=Me[1],dt=Me[2],ft,ht,mt;return isNaN(qe)&&(qe=0),isNaN(ot)&&(ot=0),qe>360&&(qe-=360),qe<0&&(qe+=360),qe/=360,qe<1/3?(mt=(1-ot)/3,ft=(1+ot*Or(an*qe)/Or(ui-an*qe))/3,ht=1-(mt+ft)):qe<2/3?(qe-=1/3,ft=(1-ot)/3,ht=(1+ot*Or(an*qe)/Or(ui-an*qe))/3,mt=1-(ft+ht)):(qe-=2/3,ht=(1-ot)/3,mt=(1+ot*Or(an*qe)/Or(ui-an*qe))/3,ft=1-(ht+mt)),ft=sn(dt*ft*3),ht=sn(dt*ht*3),mt=sn(dt*mt*3),[ft*255,ht*255,mt*255,Me.length>3?Me[3]:1]},ar=Gt,hi=T.unpack,En=T.type,Sn=me,di=ne,Bt=D,cr=To;di.prototype.hsi=function(){return cr(this._rgb)},Sn.hsi=function(){for(var Me=[],He=arguments.length;He--;)Me[He]=arguments[He];return new(Function.prototype.bind.apply(di,[null].concat(Me,["hsi"])))},Bt.format.hsi=ar,Bt.autodetect.push({p:2,test:function(){for(var Me=[],He=arguments.length;He--;)Me[He]=arguments[He];if(Me=hi(Me,"hsi"),En(Me)==="array"&&Me.length===3)return"hsi"}});var Ui=T.unpack,fi=T.type,kr=me,_s=ne,Fn=D,ln=Pe;_s.prototype.hsl=function(){return ln(this._rgb)},kr.hsl=function(){for(var Me=[],He=arguments.length;He--;)Me[He]=arguments[He];return new(Function.prototype.bind.apply(_s,[null].concat(Me,["hsl"])))},Fn.format.hsl=Ke,Fn.autodetect.push({p:2,test:function(){for(var Me=[],He=arguments.length;He--;)Me[He]=arguments[He];if(Me=Ui(Me,"hsl"),fi(Me)==="array"&&Me.length===3)return"hsl"}});var dr=T.unpack,cn=Math.min,Un=Math.max,Vn=function(){for(var Me=[],He=arguments.length;He--;)Me[He]=arguments[He];Me=dr(Me,"rgb");var qe=Me[0],ot=Me[1],dt=Me[2],ft=cn(qe,ot,dt),ht=Un(qe,ot,dt),mt=ht-ft,yt,xt,Ct;return Ct=ht/255,ht===0?(yt=Number.NaN,xt=0):(xt=mt/ht,qe===ht&&(yt=(ot-dt)/mt),ot===ht&&(yt=2+(dt-qe)/mt),dt===ht&&(yt=4+(qe-ot)/mt),yt*=60,yt<0&&(yt+=360)),[yt,xt,Ct]},Vi=Vn,Hn=T.unpack,Hi=Math.floor,zi=function(){for(var Me,He,qe,ot,dt,ft,ht=[],mt=arguments.length;mt--;)ht[mt]=arguments[mt];ht=Hn(ht,"hsv");var yt=ht[0],xt=ht[1],Ct=ht[2],Pt,kt,$t;if(Ct*=255,xt===0)Pt=kt=$t=Ct;else{yt===360&&(yt=0),yt>360&&(yt-=360),yt<0&&(yt+=360),yt/=60;var It=Hi(yt),Ut=yt-It,Wt=Ct*(1-xt),Yt=Ct*(1-xt*Ut),Zt=Ct*(1-xt*(1-Ut));switch(It){case 0:Me=[Ct,Zt,Wt],Pt=Me[0],kt=Me[1],$t=Me[2];break;case 1:He=[Yt,Ct,Wt],Pt=He[0],kt=He[1],$t=He[2];break;case 2:qe=[Wt,Ct,Zt],Pt=qe[0],kt=qe[1],$t=qe[2];break;case 3:ot=[Wt,Yt,Ct],Pt=ot[0],kt=ot[1],$t=ot[2];break;case 4:dt=[Zt,Wt,Ct],Pt=dt[0],kt=dt[1],$t=dt[2];break;case 5:ft=[Ct,Wt,Yt],Pt=ft[0],kt=ft[1],$t=ft[2];break}}return[Pt,kt,$t,ht.length>3?ht[3]:1]},pi=zi,Wi=T.unpack,ji=T.type,mi=me,Gi=ne,gi=D,Po=Vi;Gi.prototype.hsv=function(){return Po(this._rgb)},mi.hsv=function(){for(var Me=[],He=arguments.length;He--;)Me[He]=arguments[He];return new(Function.prototype.bind.apply(Gi,[null].concat(Me,["hsv"])))},gi.format.hsv=pi,gi.autodetect.push({p:2,test:function(){for(var Me=[],He=arguments.length;He--;)Me[He]=arguments[He];if(Me=Wi(Me,"hsv"),ji(Me)==="array"&&Me.length===3)return"hsv"}});var Ot={Kn:18,Xn:.95047,Yn:1,Zn:1.08883,t0:.137931034,t1:.206896552,t2:.12841855,t3:.008856452},br=Ot,tr=T.unpack,Yi=Math.pow,Ki=function(){for(var Me=[],He=arguments.length;He--;)Me[He]=arguments[He];var qe=tr(Me,"rgb"),ot=qe[0],dt=qe[1],ft=qe[2],ht=un(ot,dt,ft),mt=ht[0],yt=ht[1],xt=ht[2],Ct=116*yt-16;return[Ct<0?0:Ct,500*(mt-yt),200*(yt-xt)]},zn=function(Me){return(Me/=255)<=.04045?Me/12.92:Yi((Me+.055)/1.055,2.4)},Wn=function(Me){return Me>br.t3?Yi(Me,1/3):Me/br.t2+br.t0},un=function(Me,He,qe){Me=zn(Me),He=zn(He),qe=zn(qe);var ot=Wn((.4124564*Me+.3575761*He+.1804375*qe)/br.Xn),dt=Wn((.2126729*Me+.7151522*He+.072175*qe)/br.Yn),ft=Wn((.0193339*Me+.119192*He+.9503041*qe)/br.Zn);return[ot,dt,ft]},yi=Ki,Dr=Ot,gr=T.unpack,hn=Math.pow,xs=function(){for(var Me=[],He=arguments.length;He--;)Me[He]=arguments[He];Me=gr(Me,"lab");var qe=Me[0],ot=Me[1],dt=Me[2],ft,ht,mt,yt,xt,Ct;return ht=(qe+16)/116,ft=isNaN(ot)?ht:ht+ot/500,mt=isNaN(dt)?ht:ht-dt/200,ht=Dr.Yn*qi(ht),ft=Dr.Xn*qi(ft),mt=Dr.Zn*qi(mt),yt=vi(3.2404542*ft-1.5371385*ht-.4985314*mt),xt=vi(-.969266*ft+1.8760108*ht+.041556*mt),Ct=vi(.0556434*ft-.2040259*ht+1.0572252*mt),[yt,xt,Ct,Me.length>3?Me[3]:1]},vi=function(Me){return 255*(Me<=.00304?12.92*Me:1.055*hn(Me,1/2.4)-.055)},qi=function(Me){return Me>Dr.t1?Me*Me*Me:Dr.t2*(Me-Dr.t0)},Xi=xs,Zi=T.unpack,Io=T.type,ws=me,zt=ne,Es=D,Lr=yi;zt.prototype.lab=function(){return Lr(this._rgb)},ws.lab=function(){for(var Me=[],He=arguments.length;He--;)Me[He]=arguments[He];return new(Function.prototype.bind.apply(zt,[null].concat(Me,["lab"])))},Es.format.lab=Xi,Es.autodetect.push({p:2,test:function(){for(var Me=[],He=arguments.length;He--;)Me[He]=arguments[He];if(Me=Zi(Me,"lab"),Io(Me)==="array"&&Me.length===3)return"lab"}});var jn=T.unpack,Ss=T.RAD2DEG,$o=Math.sqrt,Qi=Math.atan2,Lo=Math.round,Cs=function(){for(var Me=[],He=arguments.length;He--;)Me[He]=arguments[He];var qe=jn(Me,"lab"),ot=qe[0],dt=qe[1],ft=qe[2],ht=$o(dt*dt+ft*ft),mt=(Qi(ft,dt)*Ss+360)%360;return Lo(ht*1e4)===0&&(mt=Number.NaN),[ot,ht,mt]},ks=Cs,Ro=T.unpack,Ji=yi,Mo=ks,Nr=function(){for(var Me=[],He=arguments.length;He--;)Me[He]=arguments[He];var qe=Ro(Me,"rgb"),ot=qe[0],dt=qe[1],ft=qe[2],ht=Ji(ot,dt,ft),mt=ht[0],yt=ht[1],xt=ht[2];return Mo(mt,yt,xt)},Oo=Nr,As=T.unpack,Xr=T.DEG2RAD,Ts=Math.sin,Ps=Math.cos,Do=function(){for(var Me=[],He=arguments.length;He--;)Me[He]=arguments[He];var qe=As(Me,"lch"),ot=qe[0],dt=qe[1],ft=qe[2];return isNaN(ft)&&(ft=0),ft=ft*Xr,[ot,Ps(ft)*dt,Ts(ft)*dt]},Is=Do,es=T.unpack,No=Is,$s=Xi,Ls=function(){for(var Me=[],He=arguments.length;He--;)Me[He]=arguments[He];Me=es(Me,"lch");var qe=Me[0],ot=Me[1],dt=Me[2],ft=No(qe,ot,dt),ht=ft[0],mt=ft[1],yt=ft[2],xt=$s(ht,mt,yt),Ct=xt[0],Pt=xt[1],kt=xt[2];return[Ct,Pt,kt,Me.length>3?Me[3]:1]},Gn=Ls,dn=T.unpack,Bo=Gn,Yn=function(){for(var Me=[],He=arguments.length;He--;)Me[He]=arguments[He];var qe=dn(Me,"hcl").reverse();return Bo.apply(void 0,qe)},Ar=Yn,Rs=T.unpack,Ms=T.type,Os=me,Kn=ne,bi=D,Ds=Oo;Kn.prototype.lch=function(){return Ds(this._rgb)},Kn.prototype.hcl=function(){return Ds(this._rgb).reverse()},Os.lch=function(){for(var Me=[],He=arguments.length;He--;)Me[He]=arguments[He];return new(Function.prototype.bind.apply(Kn,[null].concat(Me,["lch"])))},Os.hcl=function(){for(var Me=[],He=arguments.length;He--;)Me[He]=arguments[He];return new(Function.prototype.bind.apply(Kn,[null].concat(Me,["hcl"])))},bi.format.lch=Gn,bi.format.hcl=Ar,["lch","hcl"].forEach(function(Me){return bi.autodetect.push({p:2,test:function(){for(var He=[],qe=arguments.length;qe--;)He[qe]=arguments[qe];if(He=Rs(He,Me),Ms(He)==="array"&&He.length===3)return Me}})});var ts={aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflower:"#6495ed",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",green:"#008000",greenyellow:"#adff2f",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",indianred:"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",laserlemon:"#ffff54",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrod:"#fafad2",lightgoldenrodyellow:"#fafad2",lightgray:"#d3d3d3",lightgreen:"#90ee90",lightgrey:"#d3d3d3",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",maroon2:"#7f0000",maroon3:"#b03060",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370db",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#db7093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",purple2:"#7f007f",purple3:"#a020f0",rebeccapurple:"#663399",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",slategrey:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32"},_i=ts,Fo=ne,Ns=D,Bs=T.type,qn=_i,Rr=qr,Cn=tn;Fo.prototype.name=function(){for(var Me=Cn(this._rgb,"rgb"),He=0,qe=Object.keys(qn);He0;)He[qe]=arguments[qe+1];if(!He.length&&Bs(Me)==="string"&&qn[Me.toLowerCase()])return"named"}});var Uo=T.unpack,fn=function(){for(var Me=[],He=arguments.length;He--;)Me[He]=arguments[He];var qe=Uo(Me,"rgb"),ot=qe[0],dt=qe[1],ft=qe[2];return(ot<<16)+(dt<<8)+ft},Vo=fn,kn=T.type,Ho=function(Me){if(kn(Me)=="number"&&Me>=0&&Me<=16777215){var He=Me>>16,qe=Me>>8&255,ot=Me&255;return[He,qe,ot,1]}throw new Error("unknown num color: "+Me)},Xn=Ho,Fs=me,Zn=ne,Us=D,Zr=T.type,xi=Vo;Zn.prototype.num=function(){return xi(this._rgb)},Fs.num=function(){for(var Me=[],He=arguments.length;He--;)Me[He]=arguments[He];return new(Function.prototype.bind.apply(Zn,[null].concat(Me,["num"])))},Us.format.num=Xn,Us.autodetect.push({p:5,test:function(){for(var Me=[],He=arguments.length;He--;)Me[He]=arguments[He];if(Me.length===1&&Zr(Me[0])==="number"&&Me[0]>=0&&Me[0]<=16777215)return"num"}});var zo=me,Qn=ne,Vs=D,Br=T.unpack,Hs=T.type,pn=Math.round;Qn.prototype.rgb=function(Me){return Me===void 0&&(Me=!0),Me===!1?this._rgb.slice(0,3):this._rgb.slice(0,3).map(pn)},Qn.prototype.rgba=function(Me){return Me===void 0&&(Me=!0),this._rgb.slice(0,4).map(function(He,qe){return qe<3?Me===!1?He:pn(He):He})},zo.rgb=function(){for(var Me=[],He=arguments.length;He--;)Me[He]=arguments[He];return new(Function.prototype.bind.apply(Qn,[null].concat(Me,["rgb"])))},Vs.format.rgb=function(){for(var Me=[],He=arguments.length;He--;)Me[He]=arguments[He];var qe=Br(Me,"rgba");return qe[3]===void 0&&(qe[3]=1),qe},Vs.autodetect.push({p:3,test:function(){for(var Me=[],He=arguments.length;He--;)Me[He]=arguments[He];if(Me=Br(Me,"rgba"),Hs(Me)==="array"&&(Me.length===3||Me.length===4&&Hs(Me[3])=="number"&&Me[3]>=0&&Me[3]<=1))return"rgb"}});var wi=Math.log,Vr=function(Me){var He=Me/100,qe,ot,dt;return He<66?(qe=255,ot=He<6?0:-155.25485562709179-.44596950469579133*(ot=He-2)+104.49216199393888*wi(ot),dt=He<20?0:-254.76935184120902+.8274096064007395*(dt=He-10)+115.67994401066147*wi(dt)):(qe=351.97690566805693+.114206453784165*(qe=He-55)-40.25366309332127*wi(qe),ot=325.4494125711974+.07943456536662342*(ot=He-50)-28.0852963507957*wi(ot),dt=255),[qe,ot,dt,1]},Jn=Vr,zs=Jn,rs=T.unpack,Ei=Math.round,ns=function(){for(var Me=[],He=arguments.length;He--;)Me[He]=arguments[He];for(var qe=rs(Me,"rgb"),ot=qe[0],dt=qe[2],ft=1e3,ht=4e4,mt=.4,yt;ht-ft>mt;){yt=(ht+ft)*.5;var xt=zs(yt);xt[2]/xt[0]>=dt/ot?ht=yt:ft=yt}return Ei(yt)},Si=ns,Qr=me,mn=ne,ei=D,Ws=Si;mn.prototype.temp=mn.prototype.kelvin=mn.prototype.temperature=function(){return Ws(this._rgb)},Qr.temp=Qr.kelvin=Qr.temperature=function(){for(var Me=[],He=arguments.length;He--;)Me[He]=arguments[He];return new(Function.prototype.bind.apply(mn,[null].concat(Me,["temp"])))},ei.format.temp=ei.format.kelvin=ei.format.temperature=Jn;var Wo=T.unpack,An=Math.cbrt,jo=Math.pow,js=Math.sign,Go=function(){for(var Me=[],He=arguments.length;He--;)Me[He]=arguments[He];var qe=Wo(Me,"rgb"),ot=qe[0],dt=qe[1],ft=qe[2],ht=[ss(ot/255),ss(dt/255),ss(ft/255)],mt=ht[0],yt=ht[1],xt=ht[2],Ct=An(.4122214708*mt+.5363325363*yt+.0514459929*xt),Pt=An(.2119034982*mt+.6806995451*yt+.1073969566*xt),kt=An(.0883024619*mt+.2817188376*yt+.6299787005*xt);return[.2104542553*Ct+.793617785*Pt-.0040720468*kt,1.9779984951*Ct-2.428592205*Pt+.4505937099*kt,.0259040371*Ct+.7827717662*Pt-.808675766*kt]},is=Go;function ss(Me){var He=Math.abs(Me);return He<.04045?Me/12.92:(js(Me)||1)*jo((He+.055)/1.055,2.4)}var Fr=T.unpack,gn=Math.pow,Yo=Math.sign,Ci=function(){for(var Me=[],He=arguments.length;He--;)Me[He]=arguments[He];Me=Fr(Me,"lab");var qe=Me[0],ot=Me[1],dt=Me[2],ft=gn(qe+.3963377774*ot+.2158037573*dt,3),ht=gn(qe-.1055613458*ot-.0638541728*dt,3),mt=gn(qe-.0894841775*ot-1.291485548*dt,3);return[255*ki(4.0767416621*ft-3.3077115913*ht+.2309699292*mt),255*ki(-1.2684380046*ft+2.6097574011*ht-.3413193965*mt),255*ki(-.0041960863*ft-.7034186147*ht+1.707614701*mt),Me.length>3?Me[3]:1]},Gs=Ci;function ki(Me){var He=Math.abs(Me);return He>.0031308?(Yo(Me)||1)*(1.055*gn(He,1/2.4)-.055):Me*12.92}var Ko=T.unpack,ti=T.type,qo=me,yn=ne,os=D,Ys=is;yn.prototype.oklab=function(){return Ys(this._rgb)},qo.oklab=function(){for(var Me=[],He=arguments.length;He--;)Me[He]=arguments[He];return new(Function.prototype.bind.apply(yn,[null].concat(Me,["oklab"])))},os.format.oklab=Gs,os.autodetect.push({p:3,test:function(){for(var Me=[],He=arguments.length;He--;)Me[He]=arguments[He];if(Me=Ko(Me,"oklab"),ti(Me)==="array"&&Me.length===3)return"oklab"}});var Xo=T.unpack,Hr=is,Ks=ks,qs=function(){for(var Me=[],He=arguments.length;He--;)Me[He]=arguments[He];var qe=Xo(Me,"rgb"),ot=qe[0],dt=qe[1],ft=qe[2],ht=Hr(ot,dt,ft),mt=ht[0],yt=ht[1],xt=ht[2];return Ks(mt,yt,xt)},ri=qs,Zo=T.unpack,Ai=Is,ni=Gs,Xs=function(){for(var Me=[],He=arguments.length;He--;)Me[He]=arguments[He];Me=Zo(Me,"lch");var qe=Me[0],ot=Me[1],dt=Me[2],ft=Ai(qe,ot,dt),ht=ft[0],mt=ft[1],yt=ft[2],xt=ni(ht,mt,yt),Ct=xt[0],Pt=xt[1],kt=xt[2];return[Ct,Pt,kt,Me.length>3?Me[3]:1]},Zs=Xs,Qo=T.unpack,Qs=T.type,Js=me,ls=ne,cs=D,eo=ri;ls.prototype.oklch=function(){return eo(this._rgb)},Js.oklch=function(){for(var Me=[],He=arguments.length;He--;)Me[He]=arguments[He];return new(Function.prototype.bind.apply(ls,[null].concat(Me,["oklch"])))},cs.format.oklch=Zs,cs.autodetect.push({p:3,test:function(){for(var Me=[],He=arguments.length;He--;)Me[He]=arguments[He];if(Me=Qo(Me,"oklch"),Qs(Me)==="array"&&Me.length===3)return"oklch"}});var ro=ne,no=T.type;ro.prototype.alpha=function(Me,He){return He===void 0&&(He=!1),Me!==void 0&&no(Me)==="number"?He?(this._rgb[3]=Me,this):new ro([this._rgb[0],this._rgb[1],this._rgb[2],Me],"rgb"):this._rgb[3]};var so=ne;so.prototype.clipped=function(){return this._rgb._clipped||!1};var vn=ne,b=Ot;vn.prototype.darken=function(Me){Me===void 0&&(Me=1);var He=this,qe=He.lab();return qe[0]-=b.Kn*Me,new vn(qe,"lab").alpha(He.alpha(),!0)},vn.prototype.brighten=function(Me){return Me===void 0&&(Me=1),this.darken(-Me)},vn.prototype.darker=vn.prototype.darken,vn.prototype.brighter=vn.prototype.brighten;var k=ne;k.prototype.get=function(Me){var He=Me.split("."),qe=He[0],ot=He[1],dt=this[qe]();if(ot){var ft=qe.indexOf(ot)-(qe.substr(0,2)==="ok"?2:0);if(ft>-1)return dt[ft];throw new Error("unknown channel "+ot+" in mode "+qe)}else return dt};var ce=ne,Te=T.type,Ue=Math.pow,rt=1e-7,ct=20;ce.prototype.luminance=function(Me){if(Me!==void 0&&Te(Me)==="number"){if(Me===0)return new ce([0,0,0,this._rgb[3]],"rgb");if(Me===1)return new ce([255,255,255,this._rgb[3]],"rgb");var He=this.luminance(),qe="rgb",ot=ct,dt=function(ht,mt){var yt=ht.interpolate(mt,.5,qe),xt=yt.luminance();return Math.abs(Me-xt)Me?dt(ht,yt):dt(yt,mt)},ft=(He>Me?dt(new ce([0,0,0]),this):dt(this,new ce([255,255,255]))).rgb();return new ce(ft.concat([this._rgb[3]]))}return gt.apply(void 0,this._rgb.slice(0,3))};var gt=function(Me,He,qe){return Me=vt(Me),He=vt(He),qe=vt(qe),.2126*Me+.7152*He+.0722*qe},vt=function(Me){return Me/=255,Me<=.03928?Me/12.92:Ue((Me+.055)/1.055,2.4)},wt={},Tt=ne,Mt=T.type,Dt=wt,Cr=function(Me,He,qe){qe===void 0&&(qe=.5);for(var ot=[],dt=arguments.length-3;dt-- >0;)ot[dt]=arguments[dt+3];var ft=ot[0]||"lrgb";if(!Dt[ft]&&!ot.length&&(ft=Object.keys(Dt)[0]),!Dt[ft])throw new Error("interpolation mode "+ft+" is not defined");return Mt(Me)!=="object"&&(Me=new Tt(Me)),Mt(He)!=="object"&&(He=new Tt(He)),Dt[ft](Me,He,qe).alpha(Me.alpha()+qe*(He.alpha()-Me.alpha()))},Jr=ne,Ti=Cr;Jr.prototype.mix=Jr.prototype.interpolate=function(Me,He){He===void 0&&(He=.5);for(var qe=[],ot=arguments.length-2;ot-- >0;)qe[ot]=arguments[ot+2];return Ti.apply(void 0,[this,Me,He].concat(qe))};var zr=ne;zr.prototype.premultiply=function(Me){Me===void 0&&(Me=!1);var He=this._rgb,qe=He[3];return Me?(this._rgb=[He[0]*qe,He[1]*qe,He[2]*qe,qe],this):new zr([He[0]*qe,He[1]*qe,He[2]*qe,qe],"rgb")};var ii=ne,Jo=Ot;ii.prototype.saturate=function(Me){Me===void 0&&(Me=1);var He=this,qe=He.lch();return qe[1]+=Jo.Kn*Me,qe[1]<0&&(qe[1]=0),new ii(qe,"lch").alpha(He.alpha(),!0)},ii.prototype.desaturate=function(Me){return Me===void 0&&(Me=1),this.saturate(-Me)};var oo=ne,ao=T.type;oo.prototype.set=function(Me,He,qe){qe===void 0&&(qe=!1);var ot=Me.split("."),dt=ot[0],ft=ot[1],ht=this[dt]();if(ft){var mt=dt.indexOf(ft)-(dt.substr(0,2)==="ok"?2:0);if(mt>-1){if(ao(He)=="string")switch(He.charAt(0)){case"+":ht[mt]+=+He;break;case"-":ht[mt]+=+He;break;case"*":ht[mt]*=+He.substr(1);break;case"/":ht[mt]/=+He.substr(1);break;default:ht[mt]=+He}else if(ao(He)==="number")ht[mt]=He;else throw new Error("unsupported value for Color.set");var yt=new oo(ht,dt);return qe?(this._rgb=yt._rgb,this):yt}throw new Error("unknown channel "+ft+" in mode "+dt)}else return ht};var lo=ne,ea=function(Me,He,qe){var ot=Me._rgb,dt=He._rgb;return new lo(ot[0]+qe*(dt[0]-ot[0]),ot[1]+qe*(dt[1]-ot[1]),ot[2]+qe*(dt[2]-ot[2]),"rgb")};wt.rgb=ea;var uo=ne,lr=Math.sqrt,Wr=Math.pow,ta=function(Me,He,qe){var ot=Me._rgb,dt=ot[0],ft=ot[1],ht=ot[2],mt=He._rgb,yt=mt[0],xt=mt[1],Ct=mt[2];return new uo(lr(Wr(dt,2)*(1-qe)+Wr(yt,2)*qe),lr(Wr(ft,2)*(1-qe)+Wr(xt,2)*qe),lr(Wr(ht,2)*(1-qe)+Wr(Ct,2)*qe),"rgb")};wt.lrgb=ta;var ra=ne,na=function(Me,He,qe){var ot=Me.lab(),dt=He.lab();return new ra(ot[0]+qe*(dt[0]-ot[0]),ot[1]+qe*(dt[1]-ot[1]),ot[2]+qe*(dt[2]-ot[2]),"lab")};wt.lab=na;var Pi=ne,bn=function(Me,He,qe,ot){var dt,ft,ht,mt;ot==="hsl"?(ht=Me.hsl(),mt=He.hsl()):ot==="hsv"?(ht=Me.hsv(),mt=He.hsv()):ot==="hcg"?(ht=Me.hcg(),mt=He.hcg()):ot==="hsi"?(ht=Me.hsi(),mt=He.hsi()):ot==="lch"||ot==="hcl"?(ot="hcl",ht=Me.hcl(),mt=He.hcl()):ot==="oklch"&&(ht=Me.oklch().reverse(),mt=He.oklch().reverse());var yt,xt,Ct,Pt,kt,$t;(ot.substr(0,1)==="h"||ot==="oklch")&&(dt=ht,yt=dt[0],Ct=dt[1],kt=dt[2],ft=mt,xt=ft[0],Pt=ft[1],$t=ft[2]);var It,Ut,Wt,Yt;return!isNaN(yt)&&!isNaN(xt)?(xt>yt&&xt-yt>180?Yt=xt-(yt+360):xt180?Yt=xt+360-yt:Yt=xt-yt,Ut=yt+qe*Yt):isNaN(yt)?isNaN(xt)?Ut=Number.NaN:(Ut=xt,(kt==1||kt==0)&&ot!="hsv"&&(It=Pt)):(Ut=yt,($t==1||$t==0)&&ot!="hsv"&&(It=Ct)),It===void 0&&(It=Ct+qe*(Pt-Ct)),Wt=kt+qe*($t-kt),ot==="oklch"?new Pi([Wt,It,Ut],ot):new Pi([Ut,It,Wt],ot)},ia=bn,wa=function(Me,He,qe){return ia(Me,He,qe,"lch")};wt.lch=wa,wt.hcl=wa;var Wa=ne,ja=function(Me,He,qe){var ot=Me.num(),dt=He.num();return new Wa(ot+qe*(dt-ot),"num")};wt.num=ja;var Ga=bn,Ya=function(Me,He,qe){return Ga(Me,He,qe,"hcg")};wt.hcg=Ya;var Ka=bn,qa=function(Me,He,qe){return Ka(Me,He,qe,"hsi")};wt.hsi=qa;var Xa=bn,Za=function(Me,He,qe){return Xa(Me,He,qe,"hsl")};wt.hsl=Za;var Qa=bn,Ja=function(Me,He,qe){return Qa(Me,He,qe,"hsv")};wt.hsv=Ja;var el=ne,tl=function(Me,He,qe){var ot=Me.oklab(),dt=He.oklab();return new el(ot[0]+qe*(dt[0]-ot[0]),ot[1]+qe*(dt[1]-ot[1]),ot[2]+qe*(dt[2]-ot[2]),"oklab")};wt.oklab=tl;var rl=bn,nl=function(Me,He,qe){return rl(Me,He,qe,"oklch")};wt.oklch=nl;var sa=ne,il=T.clip_rgb,oa=Math.pow,aa=Math.sqrt,la=Math.PI,Ea=Math.cos,Sa=Math.sin,sl=Math.atan2,ol=function(Me,He,qe){He===void 0&&(He="lrgb"),qe===void 0&&(qe=null);var ot=Me.length;qe||(qe=Array.from(new Array(ot)).map(function(){return 1}));var dt=ot/qe.reduce(function(Ut,Wt){return Ut+Wt});if(qe.forEach(function(Ut,Wt){qe[Wt]*=dt}),Me=Me.map(function(Ut){return new sa(Ut)}),He==="lrgb")return al(Me,qe);for(var ft=Me.shift(),ht=ft.get(He),mt=[],yt=0,xt=0,Ct=0;Ct=360;)It-=360;ht[$t]=It}else ht[$t]=ht[$t]/mt[$t];return kt/=ot,new sa(ht,He).alpha(kt>.99999?1:kt,!0)},al=function(Me,He){for(var qe=Me.length,ot=[0,0,0,0],dt=0;dt.9999999&&(ot[3]=1),new sa(il(ot))},jr=me,Ii=T.type,ll=Math.pow,ca=function(Me){var He="rgb",qe=jr("#ccc"),ot=0,dt=[0,1],ft=[],ht=[0,0],mt=!1,yt=[],xt=!1,Ct=0,Pt=1,kt=!1,$t={},It=!0,Ut=1,Wt=function(At){if(At=At||["#fff","#000"],At&&Ii(At)==="string"&&jr.brewer&&jr.brewer[At.toLowerCase()]&&(At=jr.brewer[At.toLowerCase()]),Ii(At)==="array"){At.length===1&&(At=[At[0],At[0]]),At=At.slice(0);for(var Rt=0;Rt=mt[Ht];)Ht++;return Ht-1}return 0},Zt=function(At){return At},_r=function(At){return At},vr=function(At,Rt){var Ht,Vt;if(Rt==null&&(Rt=!1),isNaN(At)||At===null)return qe;if(Rt)Vt=At;else if(mt&&mt.length>2){var xr=Yt(At);Vt=xr/(mt.length-2)}else Pt!==Ct?Vt=(At-Ct)/(Pt-Ct):Vt=1;Vt=_r(Vt),Rt||(Vt=Zt(Vt)),Ut!==1&&(Vt=ll(Vt,Ut)),Vt=ht[0]+Vt*(1-ht[0]-ht[1]),Vt=Math.min(1,Math.max(0,Vt));var sr=Math.floor(Vt*1e4);if(It&&$t[sr])Ht=$t[sr];else{if(Ii(yt)==="array")for(var Kt=0;Kt=Qt&&Kt===ft.length-1){Ht=yt[Kt];break}if(Vt>Qt&&Vt2){var Kt=At.map(function(Jt,er){return er/(At.length-1)}),Qt=At.map(function(Jt){return(Jt-Ct)/(Pt-Ct)});Qt.every(function(Jt,er){return Kt[er]===Jt})||(_r=function(Jt){if(Jt<=0||Jt>=1)return Jt;for(var er=0;Jt>=Qt[er+1];)er++;var Yr=(Jt-Qt[er])/(Qt[er+1]-Qt[er]),In=Kt[er]+Yr*(Kt[er+1]-Kt[er]);return In})}}return dt=[Ct,Pt],jt},jt.mode=function(At){return arguments.length?(He=At,Tr(),jt):He},jt.range=function(At,Rt){return Wt(At),jt},jt.out=function(At){return xt=At,jt},jt.spread=function(At){return arguments.length?(ot=At,jt):ot},jt.correctLightness=function(At){return At==null&&(At=!0),kt=At,Tr(),kt?Zt=function(Rt){for(var Ht=vr(0,!0).lab()[0],Vt=vr(1,!0).lab()[0],xr=Ht>Vt,sr=vr(Rt,!0).lab()[0],Kt=Ht+(Vt-Ht)*Rt,Qt=sr-Kt,Jt=0,er=1,Yr=20;Math.abs(Qt)>.01&&Yr-- >0;)(function(){return xr&&(Qt*=-1),Qt<0?(Jt=Rt,Rt+=(er-Rt)*.5):(er=Rt,Rt+=(Jt-Rt)*.5),sr=vr(Rt,!0).lab()[0],Qt=sr-Kt})();return Rt}:Zt=function(Rt){return Rt},jt},jt.padding=function(At){return At!=null?(Ii(At)==="number"&&(At=[At,At]),ht=At,jt):ht},jt.colors=function(At,Rt){arguments.length<2&&(Rt="hex");var Ht=[];if(arguments.length===0)Ht=yt.slice(0);else if(At===1)Ht=[jt(.5)];else if(At>1){var Vt=dt[0],xr=dt[1]-Vt;Ht=cl(0,At,!1).map(function(er){return jt(Vt+er/(At-1)*xr)})}else{Me=[];var sr=[];if(mt&&mt.length>2)for(var Kt=1,Qt=mt.length,Jt=1<=Qt;Jt?KtQt;Jt?Kt++:Kt--)sr.push((mt[Kt-1]+mt[Kt])*.5);else sr=dt;Ht=sr.map(function(er){return jt(er)})}return jr[Rt]&&(Ht=Ht.map(function(er){return er[Rt]()})),Ht},jt.cache=function(At){return At!=null?(It=At,jt):It},jt.gamma=function(At){return At!=null?(Ut=At,jt):Ut},jt.nodata=function(At){return At!=null?(qe=jr(At),jt):qe},jt};function cl(Me,He,qe){for(var ot=[],dt=Meft;dt?ht++:ht--)ot.push(ht);return ot}var us=ne,ul=ca,hl=function(Me){for(var He=[1,1],qe=1;qe=5){var xt,Ct,Pt;xt=Me.map(function(kt){return kt.lab()}),Pt=Me.length-1,Ct=hl(Pt),dt=function(kt){var $t=1-kt,It=[0,1,2].map(function(Ut){return xt.reduce(function(Wt,Yt,Zt){return Wt+Ct[Zt]*Math.pow($t,Pt-Zt)*Math.pow(kt,Zt)*Yt[Ut]},0)});return new us(It,"lab")}}else throw new RangeError("No point in running bezier with only one color.");return dt},fl=function(Me){var He=dl(Me);return He.scale=function(){return ul(He)},He},ua=me,Gr=function(Me,He,qe){if(!Gr[qe])throw new Error("unknown blend mode "+qe);return Gr[qe](Me,He)},Tn=function(Me){return function(He,qe){var ot=ua(qe).rgb(),dt=ua(He).rgb();return ua.rgb(Me(ot,dt))}},Pn=function(Me){return function(He,qe){var ot=[];return ot[0]=Me(He[0],qe[0]),ot[1]=Me(He[1],qe[1]),ot[2]=Me(He[2],qe[2]),ot}},pl=function(Me){return Me},ml=function(Me,He){return Me*He/255},gl=function(Me,He){return Me>He?He:Me},yl=function(Me,He){return Me>He?Me:He},vl=function(Me,He){return 255*(1-(1-Me/255)*(1-He/255))},bl=function(Me,He){return He<128?2*Me*He/255:255*(1-2*(1-Me/255)*(1-He/255))},_l=function(Me,He){return 255*(1-(1-He/255)/(Me/255))},xl=function(Me,He){return Me===255?255:(Me=255*(He/255)/(1-Me/255),Me>255?255:Me)};Gr.normal=Tn(Pn(pl)),Gr.multiply=Tn(Pn(ml)),Gr.screen=Tn(Pn(vl)),Gr.overlay=Tn(Pn(bl)),Gr.darken=Tn(Pn(gl)),Gr.lighten=Tn(Pn(yl)),Gr.dodge=Tn(Pn(xl)),Gr.burn=Tn(Pn(_l));for(var wl=Gr,ha=T.type,El=T.clip_rgb,Sl=T.TWOPI,Cl=Math.pow,kl=Math.sin,Al=Math.cos,Ca=me,Tl=function(Me,He,qe,ot,dt){Me===void 0&&(Me=300),He===void 0&&(He=-1.5),qe===void 0&&(qe=1),ot===void 0&&(ot=1),dt===void 0&&(dt=[0,1]);var ft=0,ht;ha(dt)==="array"?ht=dt[1]-dt[0]:(ht=0,dt=[dt,dt]);var mt=function(yt){var xt=Sl*((Me+120)/360+He*yt),Ct=Cl(dt[0]+ht*yt,ot),Pt=ft!==0?qe[0]+yt*ft:qe,kt=Pt*Ct*(1-Ct)/2,$t=Al(xt),It=kl(xt),Ut=Ct+kt*(-.14861*$t+1.78277*It),Wt=Ct+kt*(-.29227*$t-.90649*It),Yt=Ct+kt*(1.97294*$t);return Ca(El([Ut*255,Wt*255,Yt*255,1]))};return mt.start=function(yt){return yt==null?Me:(Me=yt,mt)},mt.rotations=function(yt){return yt==null?He:(He=yt,mt)},mt.gamma=function(yt){return yt==null?ot:(ot=yt,mt)},mt.hue=function(yt){return yt==null?qe:(qe=yt,ha(qe)==="array"?(ft=qe[1]-qe[0],ft===0&&(qe=qe[1])):ft=0,mt)},mt.lightness=function(yt){return yt==null?dt:(ha(yt)==="array"?(dt=yt,ht=yt[1]-yt[0]):(dt=[yt,yt],ht=0),mt)},mt.scale=function(){return Ca.scale(mt)},mt.hue(qe),mt},Pl=ne,Il="0123456789abcdef",$l=Math.floor,Ll=Math.random,Rl=function(){for(var Me="#",He=0;He<6;He++)Me+=Il.charAt($l(Ll()*16));return new Pl(Me,"hex")},da=g,ka=Math.log,Ml=Math.pow,Ol=Math.floor,Dl=Math.abs,Aa=function(Me,He){He===void 0&&(He=null);var qe={min:Number.MAX_VALUE,max:Number.MAX_VALUE*-1,sum:0,values:[],count:0};return da(Me)==="object"&&(Me=Object.values(Me)),Me.forEach(function(ot){He&&da(ot)==="object"&&(ot=ot[He]),ot!=null&&!isNaN(ot)&&(qe.values.push(ot),qe.sum+=ot,otqe.max&&(qe.max=ot),qe.count+=1)}),qe.domain=[qe.min,qe.max],qe.limits=function(ot,dt){return Ta(qe,ot,dt)},qe},Ta=function(Me,He,qe){He===void 0&&(He="equal"),qe===void 0&&(qe=7),da(Me)=="array"&&(Me=Aa(Me));var ot=Me.min,dt=Me.max,ft=Me.values.sort(function(pa,ma){return pa-ma});if(qe===1)return[ot,dt];var ht=[];if(He.substr(0,1)==="c"&&(ht.push(ot),ht.push(dt)),He.substr(0,1)==="e"){ht.push(ot);for(var mt=1;mt 0");var yt=Math.LOG10E*ka(ot),xt=Math.LOG10E*ka(dt);ht.push(ot);for(var Ct=1;Ct200&&(_r=!1)}for(var $n={},$i=0;$iot?(qe+.05)/(ot+.05):(ot+.05)/(qe+.05)},$a=ne,_n=Math.sqrt,pr=Math.pow,Bl=Math.min,Fl=Math.max,La=Math.atan2,Ra=Math.abs,ho=Math.cos,Ma=Math.sin,Ul=Math.exp,Oa=Math.PI,Vl=function(Me,He,qe,ot,dt){qe===void 0&&(qe=1),ot===void 0&&(ot=1),dt===void 0&&(dt=1);var ft=function(oi){return 360*oi/(2*Oa)},ht=function(oi){return 2*Oa*oi/360};Me=new $a(Me),He=new $a(He);var mt=Array.from(Me.lab()),yt=mt[0],xt=mt[1],Ct=mt[2],Pt=Array.from(He.lab()),kt=Pt[0],$t=Pt[1],It=Pt[2],Ut=(yt+kt)/2,Wt=_n(pr(xt,2)+pr(Ct,2)),Yt=_n(pr($t,2)+pr(It,2)),Zt=(Wt+Yt)/2,_r=.5*(1-_n(pr(Zt,7)/(pr(Zt,7)+pr(25,7)))),vr=xt*(1+_r),Tr=$t*(1+_r),jt=_n(pr(vr,2)+pr(Ct,2)),At=_n(pr(Tr,2)+pr(It,2)),Rt=(jt+At)/2,Ht=ft(La(Ct,vr)),Vt=ft(La(It,Tr)),xr=Ht>=0?Ht:Ht+360,sr=Vt>=0?Vt:Vt+360,Kt=Ra(xr-sr)>180?(xr+sr+360)/2:(xr+sr)/2,Qt=1-.17*ho(ht(Kt-30))+.24*ho(ht(2*Kt))+.32*ho(ht(3*Kt+6))-.2*ho(ht(4*Kt-63)),Jt=sr-xr;Jt=Ra(Jt)<=180?Jt:sr<=xr?Jt+360:Jt-360,Jt=2*_n(jt*At)*Ma(ht(Jt)/2);var er=kt-yt,Yr=At-jt,In=1+.015*pr(Ut-50,2)/_n(20+pr(Ut-50,2)),$n=1+.045*Rt,$i=1+.015*Rt*Qt,Li=30*Ul(-pr((Kt-275)/25,2)),xn=2*_n(pr(Rt,7)/(pr(Rt,7)+pr(25,7))),si=-xn*Ma(2*ht(Li)),hs=_n(pr(er/(qe*In),2)+pr(Yr/(ot*$n),2)+pr(Jt/(dt*$i),2)+si*(Yr/(ot*$n))*(Jt/(dt*$i)));return Fl(0,Bl(100,hs))},Da=ne,Hl=function(Me,He,qe){qe===void 0&&(qe="lab"),Me=new Da(Me),He=new Da(He);var ot=Me.get(qe),dt=He.get(qe),ft=0;for(var ht in ot){var mt=(ot[ht]||0)-(dt[ht]||0);ft+=mt*mt}return Math.sqrt(ft)},zl=ne,Wl=function(){for(var Me=[],He=arguments.length;He--;)Me[He]=arguments[He];try{return new(Function.prototype.bind.apply(zl,[null].concat(Me))),!0}catch{return!1}},Na=me,Ba=ca,jl={cool:function(){return Ba([Na.hsl(180,1,.9),Na.hsl(250,.7,.4)])},hot:function(){return Ba(["#000","#f00","#ff0","#fff"]).mode("rgb")}},fo={OrRd:["#fff7ec","#fee8c8","#fdd49e","#fdbb84","#fc8d59","#ef6548","#d7301f","#b30000","#7f0000"],PuBu:["#fff7fb","#ece7f2","#d0d1e6","#a6bddb","#74a9cf","#3690c0","#0570b0","#045a8d","#023858"],BuPu:["#f7fcfd","#e0ecf4","#bfd3e6","#9ebcda","#8c96c6","#8c6bb1","#88419d","#810f7c","#4d004b"],Oranges:["#fff5eb","#fee6ce","#fdd0a2","#fdae6b","#fd8d3c","#f16913","#d94801","#a63603","#7f2704"],BuGn:["#f7fcfd","#e5f5f9","#ccece6","#99d8c9","#66c2a4","#41ae76","#238b45","#006d2c","#00441b"],YlOrBr:["#ffffe5","#fff7bc","#fee391","#fec44f","#fe9929","#ec7014","#cc4c02","#993404","#662506"],YlGn:["#ffffe5","#f7fcb9","#d9f0a3","#addd8e","#78c679","#41ab5d","#238443","#006837","#004529"],Reds:["#fff5f0","#fee0d2","#fcbba1","#fc9272","#fb6a4a","#ef3b2c","#cb181d","#a50f15","#67000d"],RdPu:["#fff7f3","#fde0dd","#fcc5c0","#fa9fb5","#f768a1","#dd3497","#ae017e","#7a0177","#49006a"],Greens:["#f7fcf5","#e5f5e0","#c7e9c0","#a1d99b","#74c476","#41ab5d","#238b45","#006d2c","#00441b"],YlGnBu:["#ffffd9","#edf8b1","#c7e9b4","#7fcdbb","#41b6c4","#1d91c0","#225ea8","#253494","#081d58"],Purples:["#fcfbfd","#efedf5","#dadaeb","#bcbddc","#9e9ac8","#807dba","#6a51a3","#54278f","#3f007d"],GnBu:["#f7fcf0","#e0f3db","#ccebc5","#a8ddb5","#7bccc4","#4eb3d3","#2b8cbe","#0868ac","#084081"],Greys:["#ffffff","#f0f0f0","#d9d9d9","#bdbdbd","#969696","#737373","#525252","#252525","#000000"],YlOrRd:["#ffffcc","#ffeda0","#fed976","#feb24c","#fd8d3c","#fc4e2a","#e31a1c","#bd0026","#800026"],PuRd:["#f7f4f9","#e7e1ef","#d4b9da","#c994c7","#df65b0","#e7298a","#ce1256","#980043","#67001f"],Blues:["#f7fbff","#deebf7","#c6dbef","#9ecae1","#6baed6","#4292c6","#2171b5","#08519c","#08306b"],PuBuGn:["#fff7fb","#ece2f0","#d0d1e6","#a6bddb","#67a9cf","#3690c0","#02818a","#016c59","#014636"],Viridis:["#440154","#482777","#3f4a8a","#31678e","#26838f","#1f9d8a","#6cce5a","#b6de2b","#fee825"],Spectral:["#9e0142","#d53e4f","#f46d43","#fdae61","#fee08b","#ffffbf","#e6f598","#abdda4","#66c2a5","#3288bd","#5e4fa2"],RdYlGn:["#a50026","#d73027","#f46d43","#fdae61","#fee08b","#ffffbf","#d9ef8b","#a6d96a","#66bd63","#1a9850","#006837"],RdBu:["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#f7f7f7","#d1e5f0","#92c5de","#4393c3","#2166ac","#053061"],PiYG:["#8e0152","#c51b7d","#de77ae","#f1b6da","#fde0ef","#f7f7f7","#e6f5d0","#b8e186","#7fbc41","#4d9221","#276419"],PRGn:["#40004b","#762a83","#9970ab","#c2a5cf","#e7d4e8","#f7f7f7","#d9f0d3","#a6dba0","#5aae61","#1b7837","#00441b"],RdYlBu:["#a50026","#d73027","#f46d43","#fdae61","#fee090","#ffffbf","#e0f3f8","#abd9e9","#74add1","#4575b4","#313695"],BrBG:["#543005","#8c510a","#bf812d","#dfc27d","#f6e8c3","#f5f5f5","#c7eae5","#80cdc1","#35978f","#01665e","#003c30"],RdGy:["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#ffffff","#e0e0e0","#bababa","#878787","#4d4d4d","#1a1a1a"],PuOr:["#7f3b08","#b35806","#e08214","#fdb863","#fee0b6","#f7f7f7","#d8daeb","#b2abd2","#8073ac","#542788","#2d004b"],Set2:["#66c2a5","#fc8d62","#8da0cb","#e78ac3","#a6d854","#ffd92f","#e5c494","#b3b3b3"],Accent:["#7fc97f","#beaed4","#fdc086","#ffff99","#386cb0","#f0027f","#bf5b17","#666666"],Set1:["#e41a1c","#377eb8","#4daf4a","#984ea3","#ff7f00","#ffff33","#a65628","#f781bf","#999999"],Set3:["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3","#fdb462","#b3de69","#fccde5","#d9d9d9","#bc80bd","#ccebc5","#ffed6f"],Dark2:["#1b9e77","#d95f02","#7570b3","#e7298a","#66a61e","#e6ab02","#a6761d","#666666"],Paired:["#a6cee3","#1f78b4","#b2df8a","#33a02c","#fb9a99","#e31a1c","#fdbf6f","#ff7f00","#cab2d6","#6a3d9a","#ffff99","#b15928"],Pastel2:["#b3e2cd","#fdcdac","#cbd5e8","#f4cae4","#e6f5c9","#fff2ae","#f1e2cc","#cccccc"],Pastel1:["#fbb4ae","#b3cde3","#ccebc5","#decbe4","#fed9a6","#ffffcc","#e5d8bd","#fddaec","#f2f2f2"]},fa=0,Fa=Object.keys(fo);fal===o);if(r[a])return r[a]}return r[r.length-1]}const markerIcon2x="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAABSCAMAAAAhFXfZAAAC91BMVEVMaXEzeak2f7I4g7g3g7cua5gzeKg8hJo3grY4g7c3grU0gLI2frE0daAubJc2gbQwd6QzeKk2gLMtd5sxdKIua5g1frA2f7IydaM0e6w2fq41fK01eqo3grgubJgta5cxdKI1f7AydaQydaMxc6EubJgvbJkwcZ4ubZkwcJwubZgubJcydqUydKIxapgubJctbJcubZcubJcvbJYubJcvbZkubJctbJctbZcubJg2f7AubJcrbZcubJcubJcua5g3grY0fq8ubJcubJdEkdEwhsw6i88vhswuhcsuhMtBjMgthMsrg8srgss6is8qgcs8i9A9iMYtg8spgcoogMo7hcMngMonf8olfso4gr8kfck5iM8jfMk4iM8he8k1fro7itAgesk2hs8eecgzfLcofssdeMg0hc4cd8g2hcsxeLQbdsgZdcgxeLImfcszhM0vda4xgckzhM4xg84wf8Yxgs4udKsvfcQucqhUndROmdM1fK0wcZ8vb5w0eqpQm9MzeKhXoNVcpdYydKNWn9VZotVKltJFjsIwcJ1Rms9OlslLmtH///8+kc9epdYzd6dbo9VHkMM2f7FHmNBClM8ydqVcpNY9hro3gLM9hLczealQmcw3fa46f7A8gLMxc6I3eagyc6FIldJMl9JSnNRSntNNl9JPnNJFi75UnM9ZodVKksg8kM45jc09e6ZHltFBk883gbRBh7pDk9EwcaBzn784g7dKkcY2i81Om9M7j85Llc81is09g7Q4grY/j9A0eqxKmdFFltBEjcXf6fFImdBCiLxJl9FGlNFBi78yiMxVndEvbpo6js74+vx+psPP3+o/ks5HkcpGmNCjwdZCkNDM3ehYoNJEls+lxNkxh8xHks0+jdC1zd5Lg6r+/v/H2ufz9/o3jM3t8/edvdM/k89Th61OiLBSjbZklbaTt9BfptdjmL1AicBHj8hGk9FAgK1dkLNTjLRekrdClc/k7fM0icy0y9tgp9c4jc2NtM9Dlc8zicxeXZn3AAAAQ3RSTlMAHDdTb4yPA+LtnEQmC4L2EmHqB7XA0d0sr478x4/Yd5i1zOfyPkf1sLVq4Nh3FvjxopQ2/STNuFzUwFIwxKaejILpIBEV9wAABhVJREFUeF6s1NdyFEcYBeBeoQIhRAkLlRDGrhIgY3BJL8CVeKzuyXFzzjkn5ZxzzuScg3PO8cKzu70JkO0LfxdTU//pM9vTu7Xgf6KqOVTb9X7toRrVEfBf1HTVjZccrT/2by1VV928Yty9ZbVuucdz90frG8DBjl9pVApbOstvmMuvVgaNXSfAAd6pGxpy6yxf5ph43pS/4f3uoaGm2rdu72S9xzOvMymkZFq/ptDrk90mhW7e4zl7HLzhxGWPR20xmSxJ/VqldG5m9XhaVOA1DadsNh3Pu5L2N6QtPO/32JpqQBVVk20oy/Pi2s23WEvyfHbe1thadVQttvm7Llf65gGmXK67XtupyoM7HQhmXdLS8oGWJNeOJ3C5fG5XCEJnkez3/oFdsvgJ4l2ANZwhrJKk/7OSXa+3Vw2WJMlKnGkobouYk6T0TyX30klOUnTD9HJ5qpckL3EW/w4XF3Xd0FGywXUrstrclVsqz5Pd/sXFYyDnPdrLcQODmGOK47IZb4CmibmMn+MYRzFZ5jg33ZL/EJrWcszHmANy3ARBK/IXtciJy8VsitPSdE3uuHxzougojcUdr8/32atnz/ev3f/K5wtpxUTpcaI45zusVDpYtZi+jg0oU9b3x74h7+n9ABvYEZeKaVq0sh0AtLKsFtqNBdeT0MrSzwwlq9+x6xAO4tgOtSzbCjrNQQiNvQUbUEubvzBUeGw26yDCsRHCoLkTHDa7IdOLIThs/gHvChszh2CimE8peRs47cxANI0lYNB5y1DljpOF0IhzBDPOZnDOqYYbeGKECbPzWnXludPphw5c2YBq5zlwXphIbO4VDCZ0gnPfUO1TwZoYwAs2ExPCedAu9DAjfQUjzITQb3jNj0KG2Sgt6BHaQUdYzWz+XmBktOHwanXjaSTcwwziBcuMOtwBmqPrTOxFQR/DRKKPqyur0aiW6cULYsx6tBm0jXpR/AUWR6HRq9WVW6MRhIq5jLyjbaCTDCijyYJNpCajdyobP/eTw0iexBAKkJ3gA5KcQb2zBXsIBckn+xVv8jkZSaEFHE+jFEleAEfayRU0MouNoBmB/L50Ai/HSLIHxcrpCvnhSQAuakKp2C/YbCylJjXRVy/z3+Kv/RrNcCo+WUzlVEhzKffnTQnxeN9fWF88fiNCUdSTsaufaChKWInHeysygfpIqagoakW+vV20J8uyl6TyNKEZWV4oRSPyCkWpgOLSbkCObT8o2r6tlG58HQquf6O0v50tB7JM7F4EORd2dx/K0w/KHsVkLPaoYrwgP/y7krr3SSMA4zj+OBgmjYkxcdIJQyQRKgg2viX9Hddi9UBb29LrKR7CVVEEEXWojUkXNyfTNDE14W9gbHJNuhjDettN3ZvbOvdOqCD3Jp/9l+/wJE+9PkYGjx/fqkys3S2rMozM/o2106rfMUINo6hVqz+eu/hd1c4xTg0TAfy5kV+4UG6+IthHTU9woWmxuKNbTfuCSfovBCxq7EtHqvYL4Sm6F8GVxsSXHMQ07TOi1DKtZxjWaaIyi4CXWjxPccUw8WVbMYY5wxC1mzEyXMJWkllpRloi+Kkoq69sxBTlElF6aAxYUbjXNlhlDZilDnM4U5SlN5biRsRHnbx3mbeWjEh4mEyiuJDl5XcWVmX5GvNkFgLWZM5qwsop4/AWfLhU1cR7k1VVvcYCWRkOI6Xy5gmnphCYIkvzuNYzHzosq2oNk2RtSs8khfUOfHIDgR6ysYBaMpl4uEgk2U/oJTs9AaTSwma7dT69geAE2ZpEjUsn2ieJNHeKfrI3EcAGJ2ZaNgVuC8EBctCLc57P5u5led6IOBkIYkuQMrmmjChs4VkfOerHqSBkPzZlhe06RslZ3zMjk2sscqKwY0RcjKK+LWbzd7KiHhkncs/siFJ+V5eXxD34B8nVuJEpGJNmxN2gH3vSvp7J70tF+D1Ej8qUJD1TkErAND2GZwTFg/LubvmgiBG3SOvdlsqFQrkEzJCL1rstlnVFROixZoDDSuXQFHESwVGlcuQcMb/b42NgjLowh5MTDFE3vNB5qStRIErdCQEh6pLPR92anSUb/wAIhldAaDMpGgAAAABJRU5ErkJggg==",markerIcon="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABkAAAApCAYAAADAk4LOAAAFgUlEQVR4Aa1XA5BjWRTN2oW17d3YaZtr2962HUzbDNpjszW24mRt28p47v7zq/bXZtrp/lWnXr337j3nPCe85NcypgSFdugCpW5YoDAMRaIMqRi6aKq5E3YqDQO3qAwjVWrD8Ncq/RBpykd8oZUb/kaJutow8r1aP9II0WmLKLIsJyv1w/kqw9Ch2MYdB++12Onxee/QMwvf4/Dk/Lfp/i4nxTXtOoQ4pW5Aj7wpici1A9erdAN2OH64x8OSP9j3Ft3b7aWkTg/Fm91siTra0f9on5sQr9INejH6CUUUpavjFNq1B+Oadhxmnfa8RfEmN8VNAsQhPqF55xHkMzz3jSmChWU6f7/XZKNH+9+hBLOHYozuKQPxyMPUKkrX/K0uWnfFaJGS1QPRtZsOPtr3NsW0uyh6NNCOkU3Yz+bXbT3I8G3xE5EXLXtCXbbqwCO9zPQYPRTZ5vIDXD7U+w7rFDEoUUf7ibHIR4y6bLVPXrz8JVZEql13trxwue/uDivd3fkWRbS6/IA2bID4uk0UpF1N8qLlbBlXs4Ee7HLTfV1j54APvODnSfOWBqtKVvjgLKzF5YdEk5ewRkGlK0i33Eofffc7HT56jD7/6U+qH3Cx7SBLNntH5YIPvODnyfIXZYRVDPqgHtLs5ABHD3YzLuespb7t79FY34DjMwrVrcTuwlT55YMPvOBnRrJ4VXTdNnYug5ucHLBjEpt30701A3Ts+HEa73u6dT3FNWwflY86eMHPk+Yu+i6pzUpRrW7SNDg5JHR4KapmM5Wv2E8Tfcb1HoqqHMHU+uWDD7zg54mz5/2BSnizi9T1Dg4QQXLToGNCkb6tb1NU+QAlGr1++eADrzhn/u8Q2YZhQVlZ5+CAOtqfbhmaUCS1ezNFVm2imDbPmPng5wmz+gwh+oHDce0eUtQ6OGDIyR0uUhUsoO3vfDmmgOezH0mZN59x7MBi++WDL1g/eEiU3avlidO671bkLfwbw5XV2P8Pzo0ydy4t2/0eu33xYSOMOD8hTf4CrBtGMSoXfPLchX+J0ruSePw3LZeK0juPJbYzrhkH0io7B3k164hiGvawhOKMLkrQLyVpZg8rHFW7E2uHOL888IBPlNZ1FPzstSJM694fWr6RwpvcJK60+0HCILTBzZLFNdtAzJaohze60T8qBzyh5ZuOg5e7uwQppofEmf2++DYvmySqGBuKaicF1blQjhuHdvCIMvp8whTTfZzI7RldpwtSzL+F1+wkdZ2TBOW2gIF88PBTzD/gpeREAMEbxnJcaJHNHrpzji0gQCS6hdkEeYt9DF/2qPcEC8RM28Hwmr3sdNyht00byAut2k3gufWNtgtOEOFGUwcXWNDbdNbpgBGxEvKkOQsxivJx33iow0Vw5S6SVTrpVq11ysA2Rp7gTfPfktc6zhtXBBC+adRLshf6sG2RfHPZ5EAc4sVZ83yCN00Fk/4kggu40ZTvIEm5g24qtU4KjBrx/BTTH8ifVASAG7gKrnWxJDcU7x8X6Ecczhm3o6YicvsLXWfh3Ch1W0k8x0nXF+0fFxgt4phz8QvypiwCCFKMqXCnqXExjq10beH+UUA7+nG6mdG/Pu0f3LgFcGrl2s0kNNjpmoJ9o4B29CMO8dMT4Q5ox8uitF6fqsrJOr8qnwNbRzv6hSnG5wP+64C7h9lp30hKNtKdWjtdkbuPA19nJ7Tz3zR/ibgARbhb4AlhavcBebmTHcFl2fvYEnW0ox9xMxKBS8btJ+KiEbq9zA4RthQXDhPa0T9TEe69gWupwc6uBUphquXgf+/FrIjweHQS4/pduMe5ERUMHUd9xv8ZR98CxkS4F2n3EUrUZ10EYNw7BWm9x1GiPssi3GgiGRDKWRYZfXlON+dfNbM+GgIwYdwAAAAASUVORK5CYII=",markerShadow="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACkAAAApCAQAAAACach9AAACMUlEQVR4Ae3ShY7jQBAE0Aoz/f9/HTMzhg1zrdKUrJbdx+Kd2nD8VNudfsL/Th///dyQN2TH6f3y/BGpC379rV+S+qqetBOxImNQXL8JCAr2V4iMQXHGNJxeCfZXhSRBcQMfvkOWUdtfzlLgAENmZDcmo2TVmt8OSM2eXxBp3DjHSMFutqS7SbmemzBiR+xpKCNUIRkdkkYxhAkyGoBvyQFEJEefwSmmvBfJuJ6aKqKWnAkvGZOaZXTUgFqYULWNSHUckZuR1HIIimUExutRxwzOLROIG4vKmCKQt364mIlhSyzAf1m9lHZHJZrlAOMMztRRiKimp/rpdJDc9Awry5xTZCte7FHtuS8wJgeYGrex28xNTd086Dik7vUMscQOa8y4DoGtCCSkAKlNwpgNtphjrC6MIHUkR6YWxxs6Sc5xqn222mmCRFzIt8lEdKx+ikCtg91qS2WpwVfBelJCiQJwvzixfI9cxZQWgiSJelKnwBElKYtDOb2MFbhmUigbReQBV0Cg4+qMXSxXSyGUn4UbF8l+7qdSGnTC0XLCmahIgUHLhLOhpVCtw4CzYXvLQWQbJNmxoCsOKAxSgBJno75avolkRw8iIAFcsdc02e9iyCd8tHwmeSSoKTowIgvscSGZUOA7PuCN5b2BX9mQM7S0wYhMNU74zgsPBj3HU7wguAfnxxjFQGBE6pwN+GjME9zHY7zGp8wVxMShYX9NXvEWD3HbwJf4giO4CFIQxXScH1/TM+04kkBiAAAAAElFTkSuQmCC",queue=new queue$1;let scale,markersLayer,pathsLayer,moveLayer,handlerClickMarker;delete L$2.Icon.Default.prototype._getIconUrl;L$2.Icon.Default.mergeOptions({iconRetinaUrl:markerIcon2x,iconUrl:markerIcon,shadowUrl:markerShadow});const messageTypes={0:"text",1:"air",2:"garbage",3:"water",4:"fire",5:"forest",6:"alert ",7:"notif",8:"recycle",9:"parking",42:"gank"};let messageIconName={},messageIconType={};const messagesLayers=Object.values(messageTypes).reduce((e,t)=>(e[t]=null,e),{});async function init$2(e,t,r){for(const o of Object.keys(messageTypes)){try{messageIconType[o]=(await __variableDynamicImportRuntimeHelper(Object.assign({"../../assets/message/msg-air.png":()=>__vitePreload(()=>import("./msg-air.abb754d3.js"),[],import.meta.url),"../../assets/message/msg-alert.png":()=>__vitePreload(()=>import("./msg-alert.9404c396.js"),[],import.meta.url),"../../assets/message/msg-fire.png":()=>__vitePreload(()=>import("./msg-fire.faa011b0.js"),[],import.meta.url),"../../assets/message/msg-forest.png":()=>__vitePreload(()=>import("./msg-forest.a623a1f9.js"),[],import.meta.url),"../../assets/message/msg-gank.png":()=>__vitePreload(()=>import("./msg-gank.34a748fe.js"),[],import.meta.url),"../../assets/message/msg-garbage.png":()=>__vitePreload(()=>import("./msg-garbage.b797b882.js"),[],import.meta.url),"../../assets/message/msg-notif.png":()=>__vitePreload(()=>import("./msg-notif.d72c5a6f.js"),[],import.meta.url),"../../assets/message/msg-parking.png":()=>__vitePreload(()=>import("./msg-parking.5da4fdeb.js"),[],import.meta.url),"../../assets/message/msg-recycle.png":()=>__vitePreload(()=>import("./msg-recycle.eab79c00.js"),[],import.meta.url),"../../assets/message/msg-text.png":()=>__vitePreload(()=>import("./msg-text.470fee8d.js"),[],import.meta.url),"../../assets/message/msg-water.png":()=>__vitePreload(()=>import("./msg-water.b0066085.js"),[],import.meta.url)}),`../../assets/message/msg-${messageTypes[o]}.png`)).default}catch{messageIconType[o]=(await __vitePreload(()=>import("./msg-text.470fee8d.js"),[],import.meta.url)).default}messageIconName[messageTypes[o]]=messageIconType[o]}handlerClickMarker=o=>{/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)?e.setActiveArea({position:"absolute",top:"90px",left:"0px",right:"0px",height:"20%"}):e.setActiveArea({position:"absolute",top:"0px",left:"0px",right:"50%",height:"100%"}),e.panTo(o.latlng),r(o.target.options.data)};const n=getMeasurementByName(t);scale=generate$1(n.colors,n.range),markersLayer=new L$2.MarkerClusterGroup({showCoverageOnHover:!1,maxClusterRadius:120,iconCreateFunction:iconCreate}),e.addLayer(markersLayer),pathsLayer=new L$2.layerGroup,e.addLayer(pathsLayer),moveLayer=new L$2.layerGroup,e.addLayer(moveLayer);for(const o of Object.values(messageTypes))messagesLayers[o]=new L$2.MarkerClusterGroup({showCoverageOnHover:!1,maxClusterRadius:120,iconCreateFunction:a=>iconCreateMsg(a,o)});for(const o of Object.values(messagesLayers))e.addLayer(o)}function isReadyLayers(){return!!(markersLayer&&pathsLayer&&moveLayer)}function iconCreate(e){const t=e.getAllChildMarkers(),r=e.getChildCount();let n=0,o=0;t.forEach(u=>{u.options.data.value===void 0&&u.options.data.value!==""||(n++,o+=Number(u.options.data.value))}),n>0&&(o=o/n);const a=getColorRGB(scale,o),l=getColorDarkenRGB(scale,o),c=scale(o).luminance()<.4;return new L$2.DivIcon({html:`
${r}
`,className:"marker-cluster",iconSize:new L$2.Point(40,40)})}function iconCreateMsg(e,t="text"){const r=e.getChildCount();return new L$2.DivIcon({html:`
${r}
`,className:"marker-cluster",iconSize:new L$2.Point(40,40)})}function findMarker(e){return new Promise(t=>{markersLayer&&markersLayer.eachLayer(r=>{r.options.data.sensor_id===e&&t(r)}),t(!1)})}function createIconBrand(e,t){return L$2.divIcon({html:``,iconSize:[40,40],className:"marker-icon"})}function createIconMsg(e=0){return L$2.divIcon({html:``,iconSize:[40,40],className:"marker-icon"})}function createIconArrow(e,t,r){return L$2.divIcon({className:"",html:`
+ */(function(e,t){(function(r,n){e.exports=n()})(commonjsGlobal$2,function(){for(var r=function(Me,He,qe){return He===void 0&&(He=0),qe===void 0&&(qe=1),Meqe?qe:Me},n=r,o=function(Me){Me._clipped=!1,Me._unclipped=Me.slice(0);for(var He=0;He<=3;He++)He<3?((Me[He]<0||Me[He]>255)&&(Me._clipped=!0),Me[He]=n(Me[He],0,255)):He===3&&(Me[He]=n(Me[He],0,1));return Me},a={},l=0,c=["Boolean","Number","String","Function","Array","Date","RegExp","Undefined","Null"];l=3?Array.prototype.slice.call(Me):_(Me[0])=="object"&&He?He.split("").filter(function(qe){return Me[0][qe]!==void 0}).map(function(qe){return Me[0][qe]}):Me[0]},S=g,O=function(Me){if(Me.length<2)return null;var He=Me.length-1;return S(Me[He])=="string"?Me[He].toLowerCase():null},E=Math.PI,T={clip_rgb:o,limit:r,type:g,unpack:x,last:O,PI:E,TWOPI:E*2,PITHIRD:E/3,DEG2RAD:E/180,RAD2DEG:180/E},D={format:{},autodetect:[]},$=T.last,I=T.clip_rgb,H=T.type,se=D,ie=function(){for(var He=[],qe=arguments.length;qe--;)He[qe]=arguments[qe];var ot=this;if(H(He[0])==="object"&&He[0].constructor&&He[0].constructor===this.constructor)return He[0];var dt=$(He),ft=!1;if(!dt){ft=!0,se.sorted||(se.autodetect=se.autodetect.sort(function(Ct,Pt){return Pt.p-Ct.p}),se.sorted=!0);for(var ht=0,mt=se.autodetect;ht4?Me[4]:1;return ft===1?[0,0,0,ht]:[qe>=1?0:255*(1-qe)*(1-ft),ot>=1?0:255*(1-ot)*(1-ft),dt>=1?0:255*(1-dt)*(1-ft),ht]},N=te,B=me,ee=ne,oe=D,he=T.unpack,be=T.type,Ce=ve;ee.prototype.cmyk=function(){return Ce(this._rgb)},B.cmyk=function(){for(var Me=[],He=arguments.length;He--;)Me[He]=arguments[He];return new(Function.prototype.bind.apply(ee,[null].concat(Me,["cmyk"])))},oe.format.cmyk=N,oe.autodetect.push({p:2,test:function(){for(var Me=[],He=arguments.length;He--;)Me[He]=arguments[He];if(Me=he(Me,"cmyk"),be(Me)==="array"&&Me.length===4)return"cmyk"}});var Oe=T.unpack,Se=T.last,$e=function(Me){return Math.round(Me*100)/100},ke=function(){for(var Me=[],He=arguments.length;He--;)Me[He]=arguments[He];var qe=Oe(Me,"hsla"),ot=Se(Me)||"lsa";return qe[0]=$e(qe[0]||0),qe[1]=$e(qe[1]*100)+"%",qe[2]=$e(qe[2]*100)+"%",ot==="hsla"||qe.length>3&&qe[3]<1?(qe[3]=qe.length>3?qe[3]:1,ot="hsla"):qe.length=3,ot+"("+qe.join(",")+")"},Re=ke,Be=T.unpack,Ee=function(){for(var Me=[],He=arguments.length;He--;)Me[He]=arguments[He];Me=Be(Me,"rgba");var qe=Me[0],ot=Me[1],dt=Me[2];qe/=255,ot/=255,dt/=255;var ft=Math.min(qe,ot,dt),ht=Math.max(qe,ot,dt),mt=(ht+ft)/2,yt,xt;return ht===ft?(yt=0,xt=Number.NaN):yt=mt<.5?(ht-ft)/(ht+ft):(ht-ft)/(2-ht-ft),qe==ht?xt=(ot-dt)/(ht-ft):ot==ht?xt=2+(dt-qe)/(ht-ft):dt==ht&&(xt=4+(qe-ot)/(ht-ft)),xt*=60,xt<0&&(xt+=360),Me.length>3&&Me[3]!==void 0?[xt,yt,mt,Me[3]]:[xt,yt,mt]},Pe=Ee,Ie=T.unpack,Fe=T.last,fe=Re,ae=Pe,ue=Math.round,xe=function(){for(var Me=[],He=arguments.length;He--;)Me[He]=arguments[He];var qe=Ie(Me,"rgba"),ot=Fe(Me)||"rgb";return ot.substr(0,3)=="hsl"?fe(ae(qe),ot):(qe[0]=ue(qe[0]),qe[1]=ue(qe[1]),qe[2]=ue(qe[2]),(ot==="rgba"||qe.length>3&&qe[3]<1)&&(qe[3]=qe.length>3?qe[3]:1,ot="rgba"),ot+"("+qe.slice(0,ot==="rgb"?3:4).join(",")+")")},Ae=xe,De=T.unpack,ze=Math.round,je=function(){for(var Me,He=[],qe=arguments.length;qe--;)He[qe]=arguments[qe];He=De(He,"hsl");var ot=He[0],dt=He[1],ft=He[2],ht,mt,yt;if(dt===0)ht=mt=yt=ft*255;else{var xt=[0,0,0],Ct=[0,0,0],Pt=ft<.5?ft*(1+dt):ft+dt-ft*dt,kt=2*ft-Pt,$t=ot/360;xt[0]=$t+1/3,xt[1]=$t,xt[2]=$t-1/3;for(var It=0;It<3;It++)xt[It]<0&&(xt[It]+=1),xt[It]>1&&(xt[It]-=1),6*xt[It]<1?Ct[It]=kt+(Pt-kt)*6*xt[It]:2*xt[It]<1?Ct[It]=Pt:3*xt[It]<2?Ct[It]=kt+(Pt-kt)*(2/3-xt[It])*6:Ct[It]=kt;Me=[ze(Ct[0]*255),ze(Ct[1]*255),ze(Ct[2]*255)],ht=Me[0],mt=Me[1],yt=Me[2]}return He.length>3?[ht,mt,yt,He[3]]:[ht,mt,yt,1]},Ke=je,Ze=Ke,Ge=D,Ne=/^rgb\(\s*(-?\d+),\s*(-?\d+)\s*,\s*(-?\d+)\s*\)$/,We=/^rgba\(\s*(-?\d+),\s*(-?\d+)\s*,\s*(-?\d+)\s*,\s*([01]|[01]?\.\d+)\)$/,Ye=/^rgb\(\s*(-?\d+(?:\.\d+)?)%,\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*\)$/,Qe=/^rgba\(\s*(-?\d+(?:\.\d+)?)%,\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*,\s*([01]|[01]?\.\d+)\)$/,Le=/^hsl\(\s*(-?\d+(?:\.\d+)?),\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*\)$/,ye=/^hsla\(\s*(-?\d+(?:\.\d+)?),\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*,\s*([01]|[01]?\.\d+)\)$/,we=Math.round,Ve=function(Me){Me=Me.toLowerCase().trim();var He;if(Ge.format.named)try{return Ge.format.named(Me)}catch{}if(He=Me.match(Ne)){for(var qe=He.slice(1,4),ot=0;ot<3;ot++)qe[ot]=+qe[ot];return qe[3]=1,qe}if(He=Me.match(We)){for(var dt=He.slice(1,5),ft=0;ft<4;ft++)dt[ft]=+dt[ft];return dt}if(He=Me.match(Ye)){for(var ht=He.slice(1,4),mt=0;mt<3;mt++)ht[mt]=we(ht[mt]*2.55);return ht[3]=1,ht}if(He=Me.match(Qe)){for(var yt=He.slice(1,5),xt=0;xt<3;xt++)yt[xt]=we(yt[xt]*2.55);return yt[3]=+yt[3],yt}if(He=Me.match(Le)){var Ct=He.slice(1,4);Ct[1]*=.01,Ct[2]*=.01;var Pt=Ze(Ct);return Pt[3]=1,Pt}if(He=Me.match(ye)){var kt=He.slice(1,4);kt[1]*=.01,kt[2]*=.01;var $t=Ze(kt);return $t[3]=+He[4],$t}};Ve.test=function(Me){return Ne.test(Me)||We.test(Me)||Ye.test(Me)||Qe.test(Me)||Le.test(Me)||ye.test(Me)};var Xe=Ve,nt=me,lt=ne,pt=D,_t=T.type,St=Ae,Et=Xe;lt.prototype.css=function(Me){return St(this._rgb,Me)},nt.css=function(){for(var Me=[],He=arguments.length;He--;)Me[He]=arguments[He];return new(Function.prototype.bind.apply(lt,[null].concat(Me,["css"])))},pt.format.css=Et,pt.autodetect.push({p:5,test:function(Me){for(var He=[],qe=arguments.length-1;qe-- >0;)He[qe]=arguments[qe+1];if(!He.length&&_t(Me)==="string"&&Et.test(Me))return"css"}});var bt=ne,Nt=me,Ft=D,qt=T.unpack;Ft.format.gl=function(){for(var Me=[],He=arguments.length;He--;)Me[He]=arguments[He];var qe=qt(Me,"rgba");return qe[0]*=255,qe[1]*=255,qe[2]*=255,qe},Nt.gl=function(){for(var Me=[],He=arguments.length;He--;)Me[He]=arguments[He];return new(Function.prototype.bind.apply(bt,[null].concat(Me,["gl"])))},bt.prototype.gl=function(){var Me=this._rgb;return[Me[0]/255,Me[1]/255,Me[2]/255,Me[3]]};var Xt=T.unpack,mr=function(){for(var Me=[],He=arguments.length;He--;)Me[He]=arguments[He];var qe=Xt(Me,"rgb"),ot=qe[0],dt=qe[1],ft=qe[2],ht=Math.min(ot,dt,ft),mt=Math.max(ot,dt,ft),yt=mt-ht,xt=yt*100/255,Ct=ht/(255-yt)*100,Pt;return yt===0?Pt=Number.NaN:(ot===mt&&(Pt=(dt-ft)/yt),dt===mt&&(Pt=2+(ft-ot)/yt),ft===mt&&(Pt=4+(ot-dt)/yt),Pt*=60,Pt<0&&(Pt+=360)),[Pt,xt,Ct]},nr=mr,ur=T.unpack,Mr=Math.floor,Pr=function(){for(var Me,He,qe,ot,dt,ft,ht=[],mt=arguments.length;mt--;)ht[mt]=arguments[mt];ht=ur(ht,"hcg");var yt=ht[0],xt=ht[1],Ct=ht[2],Pt,kt,$t;Ct=Ct*255;var It=xt*255;if(xt===0)Pt=kt=$t=Ct;else{yt===360&&(yt=0),yt>360&&(yt-=360),yt<0&&(yt+=360),yt/=60;var Ut=Mr(yt),Wt=yt-Ut,Yt=Ct*(1-xt),Zt=Yt+It*(1-Wt),_r=Yt+It*Wt,vr=Yt+It;switch(Ut){case 0:Me=[vr,_r,Yt],Pt=Me[0],kt=Me[1],$t=Me[2];break;case 1:He=[Zt,vr,Yt],Pt=He[0],kt=He[1],$t=He[2];break;case 2:qe=[Yt,vr,_r],Pt=qe[0],kt=qe[1],$t=qe[2];break;case 3:ot=[Yt,Zt,vr],Pt=ot[0],kt=ot[1],$t=ot[2];break;case 4:dt=[_r,Yt,vr],Pt=dt[0],kt=dt[1],$t=dt[2];break;case 5:ft=[vr,Yt,Zt],Pt=ft[0],kt=ft[1],$t=ft[2];break}}return[Pt,kt,$t,ht.length>3?ht[3]:1]},fr=Pr,hr=T.unpack,Ir=T.type,Bi=me,li=ne,Mn=D,Sr=nr;li.prototype.hcg=function(){return Sr(this._rgb)},Bi.hcg=function(){for(var Me=[],He=arguments.length;He--;)Me[He]=arguments[He];return new(Function.prototype.bind.apply(li,[null].concat(Me,["hcg"])))},Mn.format.hcg=fr,Mn.autodetect.push({p:1,test:function(){for(var Me=[],He=arguments.length;He--;)Me[He]=arguments[He];if(Me=hr(Me,"hcg"),Ir(Me)==="array"&&Me.length===3)return"hcg"}});var Lt=T.unpack,On=T.last,Ur=Math.round,Dn=function(){for(var Me=[],He=arguments.length;He--;)Me[He]=arguments[He];var qe=Lt(Me,"rgba"),ot=qe[0],dt=qe[1],ft=qe[2],ht=qe[3],mt=On(Me)||"auto";ht===void 0&&(ht=1),mt==="auto"&&(mt=ht<1?"rgba":"rgb"),ot=Ur(ot),dt=Ur(dt),ft=Ur(ft);var yt=ot<<16|dt<<8|ft,xt="000000"+yt.toString(16);xt=xt.substr(xt.length-6);var Ct="0"+Ur(ht*255).toString(16);switch(Ct=Ct.substr(Ct.length-2),mt.toLowerCase()){case"rgba":return"#"+xt+Ct;case"argb":return"#"+Ct+xt;default:return"#"+xt}},tn=Dn,rn=/^#?([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/,Nn=/^#?([A-Fa-f0-9]{8}|[A-Fa-f0-9]{4})$/,$r=function(Me){if(Me.match(rn)){(Me.length===4||Me.length===7)&&(Me=Me.substr(1)),Me.length===3&&(Me=Me.split(""),Me=Me[0]+Me[0]+Me[1]+Me[1]+Me[2]+Me[2]);var He=parseInt(Me,16),qe=He>>16,ot=He>>8&255,dt=He&255;return[qe,ot,dt,1]}if(Me.match(Nn)){(Me.length===5||Me.length===9)&&(Me=Me.substr(1)),Me.length===4&&(Me=Me.split(""),Me=Me[0]+Me[0]+Me[1]+Me[1]+Me[2]+Me[2]+Me[3]+Me[3]);var ft=parseInt(Me,16),ht=ft>>24&255,mt=ft>>16&255,yt=ft>>8&255,xt=Math.round((ft&255)/255*100)/100;return[ht,mt,yt,xt]}throw new Error("unknown hex color: "+Me)},qr=$r,ci=me,nn=ne,wo=T.type,vs=D,bs=tn;nn.prototype.hex=function(Me){return bs(this._rgb,Me)},ci.hex=function(){for(var Me=[],He=arguments.length;He--;)Me[He]=arguments[He];return new(Function.prototype.bind.apply(nn,[null].concat(Me,["hex"])))},vs.format.hex=qr,vs.autodetect.push({p:4,test:function(Me){for(var He=[],qe=arguments.length-1;qe-- >0;)He[qe]=arguments[qe+1];if(!He.length&&wo(Me)==="string"&&[3,4,5,6,7,8,9].indexOf(Me.length)>=0)return"hex"}});var Eo=T.unpack,Bn=T.TWOPI,So=Math.min,Co=Math.sqrt,ko=Math.acos,Ao=function(){for(var Me=[],He=arguments.length;He--;)Me[He]=arguments[He];var qe=Eo(Me,"rgb"),ot=qe[0],dt=qe[1],ft=qe[2];ot/=255,dt/=255,ft/=255;var ht,mt=So(ot,dt,ft),yt=(ot+dt+ft)/3,xt=yt>0?1-mt/yt:0;return xt===0?ht=NaN:(ht=(ot-dt+(ot-ft))/2,ht/=Co((ot-dt)*(ot-dt)+(ot-ft)*(dt-ft)),ht=ko(ht),ft>dt&&(ht=Bn-ht),ht/=Bn),[ht*360,xt,yt]},To=Ao,Fi=T.unpack,sn=T.limit,an=T.TWOPI,ui=T.PITHIRD,Or=Math.cos,Gt=function(){for(var Me=[],He=arguments.length;He--;)Me[He]=arguments[He];Me=Fi(Me,"hsi");var qe=Me[0],ot=Me[1],dt=Me[2],ft,ht,mt;return isNaN(qe)&&(qe=0),isNaN(ot)&&(ot=0),qe>360&&(qe-=360),qe<0&&(qe+=360),qe/=360,qe<1/3?(mt=(1-ot)/3,ft=(1+ot*Or(an*qe)/Or(ui-an*qe))/3,ht=1-(mt+ft)):qe<2/3?(qe-=1/3,ft=(1-ot)/3,ht=(1+ot*Or(an*qe)/Or(ui-an*qe))/3,mt=1-(ft+ht)):(qe-=2/3,ht=(1-ot)/3,mt=(1+ot*Or(an*qe)/Or(ui-an*qe))/3,ft=1-(ht+mt)),ft=sn(dt*ft*3),ht=sn(dt*ht*3),mt=sn(dt*mt*3),[ft*255,ht*255,mt*255,Me.length>3?Me[3]:1]},ar=Gt,hi=T.unpack,En=T.type,Sn=me,di=ne,Bt=D,cr=To;di.prototype.hsi=function(){return cr(this._rgb)},Sn.hsi=function(){for(var Me=[],He=arguments.length;He--;)Me[He]=arguments[He];return new(Function.prototype.bind.apply(di,[null].concat(Me,["hsi"])))},Bt.format.hsi=ar,Bt.autodetect.push({p:2,test:function(){for(var Me=[],He=arguments.length;He--;)Me[He]=arguments[He];if(Me=hi(Me,"hsi"),En(Me)==="array"&&Me.length===3)return"hsi"}});var Ui=T.unpack,fi=T.type,kr=me,_s=ne,Fn=D,ln=Pe;_s.prototype.hsl=function(){return ln(this._rgb)},kr.hsl=function(){for(var Me=[],He=arguments.length;He--;)Me[He]=arguments[He];return new(Function.prototype.bind.apply(_s,[null].concat(Me,["hsl"])))},Fn.format.hsl=Ke,Fn.autodetect.push({p:2,test:function(){for(var Me=[],He=arguments.length;He--;)Me[He]=arguments[He];if(Me=Ui(Me,"hsl"),fi(Me)==="array"&&Me.length===3)return"hsl"}});var dr=T.unpack,cn=Math.min,Un=Math.max,Vn=function(){for(var Me=[],He=arguments.length;He--;)Me[He]=arguments[He];Me=dr(Me,"rgb");var qe=Me[0],ot=Me[1],dt=Me[2],ft=cn(qe,ot,dt),ht=Un(qe,ot,dt),mt=ht-ft,yt,xt,Ct;return Ct=ht/255,ht===0?(yt=Number.NaN,xt=0):(xt=mt/ht,qe===ht&&(yt=(ot-dt)/mt),ot===ht&&(yt=2+(dt-qe)/mt),dt===ht&&(yt=4+(qe-ot)/mt),yt*=60,yt<0&&(yt+=360)),[yt,xt,Ct]},Vi=Vn,Hn=T.unpack,Hi=Math.floor,zi=function(){for(var Me,He,qe,ot,dt,ft,ht=[],mt=arguments.length;mt--;)ht[mt]=arguments[mt];ht=Hn(ht,"hsv");var yt=ht[0],xt=ht[1],Ct=ht[2],Pt,kt,$t;if(Ct*=255,xt===0)Pt=kt=$t=Ct;else{yt===360&&(yt=0),yt>360&&(yt-=360),yt<0&&(yt+=360),yt/=60;var It=Hi(yt),Ut=yt-It,Wt=Ct*(1-xt),Yt=Ct*(1-xt*Ut),Zt=Ct*(1-xt*(1-Ut));switch(It){case 0:Me=[Ct,Zt,Wt],Pt=Me[0],kt=Me[1],$t=Me[2];break;case 1:He=[Yt,Ct,Wt],Pt=He[0],kt=He[1],$t=He[2];break;case 2:qe=[Wt,Ct,Zt],Pt=qe[0],kt=qe[1],$t=qe[2];break;case 3:ot=[Wt,Yt,Ct],Pt=ot[0],kt=ot[1],$t=ot[2];break;case 4:dt=[Zt,Wt,Ct],Pt=dt[0],kt=dt[1],$t=dt[2];break;case 5:ft=[Ct,Wt,Yt],Pt=ft[0],kt=ft[1],$t=ft[2];break}}return[Pt,kt,$t,ht.length>3?ht[3]:1]},pi=zi,Wi=T.unpack,ji=T.type,mi=me,Gi=ne,gi=D,Po=Vi;Gi.prototype.hsv=function(){return Po(this._rgb)},mi.hsv=function(){for(var Me=[],He=arguments.length;He--;)Me[He]=arguments[He];return new(Function.prototype.bind.apply(Gi,[null].concat(Me,["hsv"])))},gi.format.hsv=pi,gi.autodetect.push({p:2,test:function(){for(var Me=[],He=arguments.length;He--;)Me[He]=arguments[He];if(Me=Wi(Me,"hsv"),ji(Me)==="array"&&Me.length===3)return"hsv"}});var Ot={Kn:18,Xn:.95047,Yn:1,Zn:1.08883,t0:.137931034,t1:.206896552,t2:.12841855,t3:.008856452},br=Ot,tr=T.unpack,Yi=Math.pow,Ki=function(){for(var Me=[],He=arguments.length;He--;)Me[He]=arguments[He];var qe=tr(Me,"rgb"),ot=qe[0],dt=qe[1],ft=qe[2],ht=un(ot,dt,ft),mt=ht[0],yt=ht[1],xt=ht[2],Ct=116*yt-16;return[Ct<0?0:Ct,500*(mt-yt),200*(yt-xt)]},zn=function(Me){return(Me/=255)<=.04045?Me/12.92:Yi((Me+.055)/1.055,2.4)},Wn=function(Me){return Me>br.t3?Yi(Me,1/3):Me/br.t2+br.t0},un=function(Me,He,qe){Me=zn(Me),He=zn(He),qe=zn(qe);var ot=Wn((.4124564*Me+.3575761*He+.1804375*qe)/br.Xn),dt=Wn((.2126729*Me+.7151522*He+.072175*qe)/br.Yn),ft=Wn((.0193339*Me+.119192*He+.9503041*qe)/br.Zn);return[ot,dt,ft]},yi=Ki,Dr=Ot,gr=T.unpack,hn=Math.pow,xs=function(){for(var Me=[],He=arguments.length;He--;)Me[He]=arguments[He];Me=gr(Me,"lab");var qe=Me[0],ot=Me[1],dt=Me[2],ft,ht,mt,yt,xt,Ct;return ht=(qe+16)/116,ft=isNaN(ot)?ht:ht+ot/500,mt=isNaN(dt)?ht:ht-dt/200,ht=Dr.Yn*qi(ht),ft=Dr.Xn*qi(ft),mt=Dr.Zn*qi(mt),yt=vi(3.2404542*ft-1.5371385*ht-.4985314*mt),xt=vi(-.969266*ft+1.8760108*ht+.041556*mt),Ct=vi(.0556434*ft-.2040259*ht+1.0572252*mt),[yt,xt,Ct,Me.length>3?Me[3]:1]},vi=function(Me){return 255*(Me<=.00304?12.92*Me:1.055*hn(Me,1/2.4)-.055)},qi=function(Me){return Me>Dr.t1?Me*Me*Me:Dr.t2*(Me-Dr.t0)},Xi=xs,Zi=T.unpack,Io=T.type,ws=me,zt=ne,Es=D,Lr=yi;zt.prototype.lab=function(){return Lr(this._rgb)},ws.lab=function(){for(var Me=[],He=arguments.length;He--;)Me[He]=arguments[He];return new(Function.prototype.bind.apply(zt,[null].concat(Me,["lab"])))},Es.format.lab=Xi,Es.autodetect.push({p:2,test:function(){for(var Me=[],He=arguments.length;He--;)Me[He]=arguments[He];if(Me=Zi(Me,"lab"),Io(Me)==="array"&&Me.length===3)return"lab"}});var jn=T.unpack,Ss=T.RAD2DEG,$o=Math.sqrt,Qi=Math.atan2,Lo=Math.round,Cs=function(){for(var Me=[],He=arguments.length;He--;)Me[He]=arguments[He];var qe=jn(Me,"lab"),ot=qe[0],dt=qe[1],ft=qe[2],ht=$o(dt*dt+ft*ft),mt=(Qi(ft,dt)*Ss+360)%360;return Lo(ht*1e4)===0&&(mt=Number.NaN),[ot,ht,mt]},ks=Cs,Ro=T.unpack,Ji=yi,Mo=ks,Nr=function(){for(var Me=[],He=arguments.length;He--;)Me[He]=arguments[He];var qe=Ro(Me,"rgb"),ot=qe[0],dt=qe[1],ft=qe[2],ht=Ji(ot,dt,ft),mt=ht[0],yt=ht[1],xt=ht[2];return Mo(mt,yt,xt)},Oo=Nr,As=T.unpack,Xr=T.DEG2RAD,Ts=Math.sin,Ps=Math.cos,Do=function(){for(var Me=[],He=arguments.length;He--;)Me[He]=arguments[He];var qe=As(Me,"lch"),ot=qe[0],dt=qe[1],ft=qe[2];return isNaN(ft)&&(ft=0),ft=ft*Xr,[ot,Ps(ft)*dt,Ts(ft)*dt]},Is=Do,es=T.unpack,No=Is,$s=Xi,Ls=function(){for(var Me=[],He=arguments.length;He--;)Me[He]=arguments[He];Me=es(Me,"lch");var qe=Me[0],ot=Me[1],dt=Me[2],ft=No(qe,ot,dt),ht=ft[0],mt=ft[1],yt=ft[2],xt=$s(ht,mt,yt),Ct=xt[0],Pt=xt[1],kt=xt[2];return[Ct,Pt,kt,Me.length>3?Me[3]:1]},Gn=Ls,dn=T.unpack,Bo=Gn,Yn=function(){for(var Me=[],He=arguments.length;He--;)Me[He]=arguments[He];var qe=dn(Me,"hcl").reverse();return Bo.apply(void 0,qe)},Ar=Yn,Rs=T.unpack,Ms=T.type,Os=me,Kn=ne,bi=D,Ds=Oo;Kn.prototype.lch=function(){return Ds(this._rgb)},Kn.prototype.hcl=function(){return Ds(this._rgb).reverse()},Os.lch=function(){for(var Me=[],He=arguments.length;He--;)Me[He]=arguments[He];return new(Function.prototype.bind.apply(Kn,[null].concat(Me,["lch"])))},Os.hcl=function(){for(var Me=[],He=arguments.length;He--;)Me[He]=arguments[He];return new(Function.prototype.bind.apply(Kn,[null].concat(Me,["hcl"])))},bi.format.lch=Gn,bi.format.hcl=Ar,["lch","hcl"].forEach(function(Me){return bi.autodetect.push({p:2,test:function(){for(var He=[],qe=arguments.length;qe--;)He[qe]=arguments[qe];if(He=Rs(He,Me),Ms(He)==="array"&&He.length===3)return Me}})});var ts={aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflower:"#6495ed",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",green:"#008000",greenyellow:"#adff2f",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",indianred:"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",laserlemon:"#ffff54",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrod:"#fafad2",lightgoldenrodyellow:"#fafad2",lightgray:"#d3d3d3",lightgreen:"#90ee90",lightgrey:"#d3d3d3",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",maroon2:"#7f0000",maroon3:"#b03060",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370db",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#db7093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",purple2:"#7f007f",purple3:"#a020f0",rebeccapurple:"#663399",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",slategrey:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32"},_i=ts,Fo=ne,Ns=D,Bs=T.type,qn=_i,Rr=qr,Cn=tn;Fo.prototype.name=function(){for(var Me=Cn(this._rgb,"rgb"),He=0,qe=Object.keys(qn);He0;)He[qe]=arguments[qe+1];if(!He.length&&Bs(Me)==="string"&&qn[Me.toLowerCase()])return"named"}});var Uo=T.unpack,fn=function(){for(var Me=[],He=arguments.length;He--;)Me[He]=arguments[He];var qe=Uo(Me,"rgb"),ot=qe[0],dt=qe[1],ft=qe[2];return(ot<<16)+(dt<<8)+ft},Vo=fn,kn=T.type,Ho=function(Me){if(kn(Me)=="number"&&Me>=0&&Me<=16777215){var He=Me>>16,qe=Me>>8&255,ot=Me&255;return[He,qe,ot,1]}throw new Error("unknown num color: "+Me)},Xn=Ho,Fs=me,Zn=ne,Us=D,Zr=T.type,xi=Vo;Zn.prototype.num=function(){return xi(this._rgb)},Fs.num=function(){for(var Me=[],He=arguments.length;He--;)Me[He]=arguments[He];return new(Function.prototype.bind.apply(Zn,[null].concat(Me,["num"])))},Us.format.num=Xn,Us.autodetect.push({p:5,test:function(){for(var Me=[],He=arguments.length;He--;)Me[He]=arguments[He];if(Me.length===1&&Zr(Me[0])==="number"&&Me[0]>=0&&Me[0]<=16777215)return"num"}});var zo=me,Qn=ne,Vs=D,Br=T.unpack,Hs=T.type,pn=Math.round;Qn.prototype.rgb=function(Me){return Me===void 0&&(Me=!0),Me===!1?this._rgb.slice(0,3):this._rgb.slice(0,3).map(pn)},Qn.prototype.rgba=function(Me){return Me===void 0&&(Me=!0),this._rgb.slice(0,4).map(function(He,qe){return qe<3?Me===!1?He:pn(He):He})},zo.rgb=function(){for(var Me=[],He=arguments.length;He--;)Me[He]=arguments[He];return new(Function.prototype.bind.apply(Qn,[null].concat(Me,["rgb"])))},Vs.format.rgb=function(){for(var Me=[],He=arguments.length;He--;)Me[He]=arguments[He];var qe=Br(Me,"rgba");return qe[3]===void 0&&(qe[3]=1),qe},Vs.autodetect.push({p:3,test:function(){for(var Me=[],He=arguments.length;He--;)Me[He]=arguments[He];if(Me=Br(Me,"rgba"),Hs(Me)==="array"&&(Me.length===3||Me.length===4&&Hs(Me[3])=="number"&&Me[3]>=0&&Me[3]<=1))return"rgb"}});var wi=Math.log,Vr=function(Me){var He=Me/100,qe,ot,dt;return He<66?(qe=255,ot=He<6?0:-155.25485562709179-.44596950469579133*(ot=He-2)+104.49216199393888*wi(ot),dt=He<20?0:-254.76935184120902+.8274096064007395*(dt=He-10)+115.67994401066147*wi(dt)):(qe=351.97690566805693+.114206453784165*(qe=He-55)-40.25366309332127*wi(qe),ot=325.4494125711974+.07943456536662342*(ot=He-50)-28.0852963507957*wi(ot),dt=255),[qe,ot,dt,1]},Jn=Vr,zs=Jn,rs=T.unpack,Ei=Math.round,ns=function(){for(var Me=[],He=arguments.length;He--;)Me[He]=arguments[He];for(var qe=rs(Me,"rgb"),ot=qe[0],dt=qe[2],ft=1e3,ht=4e4,mt=.4,yt;ht-ft>mt;){yt=(ht+ft)*.5;var xt=zs(yt);xt[2]/xt[0]>=dt/ot?ht=yt:ft=yt}return Ei(yt)},Si=ns,Qr=me,mn=ne,ei=D,Ws=Si;mn.prototype.temp=mn.prototype.kelvin=mn.prototype.temperature=function(){return Ws(this._rgb)},Qr.temp=Qr.kelvin=Qr.temperature=function(){for(var Me=[],He=arguments.length;He--;)Me[He]=arguments[He];return new(Function.prototype.bind.apply(mn,[null].concat(Me,["temp"])))},ei.format.temp=ei.format.kelvin=ei.format.temperature=Jn;var Wo=T.unpack,An=Math.cbrt,jo=Math.pow,js=Math.sign,Go=function(){for(var Me=[],He=arguments.length;He--;)Me[He]=arguments[He];var qe=Wo(Me,"rgb"),ot=qe[0],dt=qe[1],ft=qe[2],ht=[ss(ot/255),ss(dt/255),ss(ft/255)],mt=ht[0],yt=ht[1],xt=ht[2],Ct=An(.4122214708*mt+.5363325363*yt+.0514459929*xt),Pt=An(.2119034982*mt+.6806995451*yt+.1073969566*xt),kt=An(.0883024619*mt+.2817188376*yt+.6299787005*xt);return[.2104542553*Ct+.793617785*Pt-.0040720468*kt,1.9779984951*Ct-2.428592205*Pt+.4505937099*kt,.0259040371*Ct+.7827717662*Pt-.808675766*kt]},is=Go;function ss(Me){var He=Math.abs(Me);return He<.04045?Me/12.92:(js(Me)||1)*jo((He+.055)/1.055,2.4)}var Fr=T.unpack,gn=Math.pow,Yo=Math.sign,Ci=function(){for(var Me=[],He=arguments.length;He--;)Me[He]=arguments[He];Me=Fr(Me,"lab");var qe=Me[0],ot=Me[1],dt=Me[2],ft=gn(qe+.3963377774*ot+.2158037573*dt,3),ht=gn(qe-.1055613458*ot-.0638541728*dt,3),mt=gn(qe-.0894841775*ot-1.291485548*dt,3);return[255*ki(4.0767416621*ft-3.3077115913*ht+.2309699292*mt),255*ki(-1.2684380046*ft+2.6097574011*ht-.3413193965*mt),255*ki(-.0041960863*ft-.7034186147*ht+1.707614701*mt),Me.length>3?Me[3]:1]},Gs=Ci;function ki(Me){var He=Math.abs(Me);return He>.0031308?(Yo(Me)||1)*(1.055*gn(He,1/2.4)-.055):Me*12.92}var Ko=T.unpack,ti=T.type,qo=me,yn=ne,os=D,Ys=is;yn.prototype.oklab=function(){return Ys(this._rgb)},qo.oklab=function(){for(var Me=[],He=arguments.length;He--;)Me[He]=arguments[He];return new(Function.prototype.bind.apply(yn,[null].concat(Me,["oklab"])))},os.format.oklab=Gs,os.autodetect.push({p:3,test:function(){for(var Me=[],He=arguments.length;He--;)Me[He]=arguments[He];if(Me=Ko(Me,"oklab"),ti(Me)==="array"&&Me.length===3)return"oklab"}});var Xo=T.unpack,Hr=is,Ks=ks,qs=function(){for(var Me=[],He=arguments.length;He--;)Me[He]=arguments[He];var qe=Xo(Me,"rgb"),ot=qe[0],dt=qe[1],ft=qe[2],ht=Hr(ot,dt,ft),mt=ht[0],yt=ht[1],xt=ht[2];return Ks(mt,yt,xt)},ri=qs,Zo=T.unpack,Ai=Is,ni=Gs,Xs=function(){for(var Me=[],He=arguments.length;He--;)Me[He]=arguments[He];Me=Zo(Me,"lch");var qe=Me[0],ot=Me[1],dt=Me[2],ft=Ai(qe,ot,dt),ht=ft[0],mt=ft[1],yt=ft[2],xt=ni(ht,mt,yt),Ct=xt[0],Pt=xt[1],kt=xt[2];return[Ct,Pt,kt,Me.length>3?Me[3]:1]},Zs=Xs,Qo=T.unpack,Qs=T.type,Js=me,ls=ne,cs=D,eo=ri;ls.prototype.oklch=function(){return eo(this._rgb)},Js.oklch=function(){for(var Me=[],He=arguments.length;He--;)Me[He]=arguments[He];return new(Function.prototype.bind.apply(ls,[null].concat(Me,["oklch"])))},cs.format.oklch=Zs,cs.autodetect.push({p:3,test:function(){for(var Me=[],He=arguments.length;He--;)Me[He]=arguments[He];if(Me=Qo(Me,"oklch"),Qs(Me)==="array"&&Me.length===3)return"oklch"}});var ro=ne,no=T.type;ro.prototype.alpha=function(Me,He){return He===void 0&&(He=!1),Me!==void 0&&no(Me)==="number"?He?(this._rgb[3]=Me,this):new ro([this._rgb[0],this._rgb[1],this._rgb[2],Me],"rgb"):this._rgb[3]};var so=ne;so.prototype.clipped=function(){return this._rgb._clipped||!1};var vn=ne,b=Ot;vn.prototype.darken=function(Me){Me===void 0&&(Me=1);var He=this,qe=He.lab();return qe[0]-=b.Kn*Me,new vn(qe,"lab").alpha(He.alpha(),!0)},vn.prototype.brighten=function(Me){return Me===void 0&&(Me=1),this.darken(-Me)},vn.prototype.darker=vn.prototype.darken,vn.prototype.brighter=vn.prototype.brighten;var k=ne;k.prototype.get=function(Me){var He=Me.split("."),qe=He[0],ot=He[1],dt=this[qe]();if(ot){var ft=qe.indexOf(ot)-(qe.substr(0,2)==="ok"?2:0);if(ft>-1)return dt[ft];throw new Error("unknown channel "+ot+" in mode "+qe)}else return dt};var ce=ne,Te=T.type,Ue=Math.pow,rt=1e-7,ct=20;ce.prototype.luminance=function(Me){if(Me!==void 0&&Te(Me)==="number"){if(Me===0)return new ce([0,0,0,this._rgb[3]],"rgb");if(Me===1)return new ce([255,255,255,this._rgb[3]],"rgb");var He=this.luminance(),qe="rgb",ot=ct,dt=function(ht,mt){var yt=ht.interpolate(mt,.5,qe),xt=yt.luminance();return Math.abs(Me-xt)Me?dt(ht,yt):dt(yt,mt)},ft=(He>Me?dt(new ce([0,0,0]),this):dt(this,new ce([255,255,255]))).rgb();return new ce(ft.concat([this._rgb[3]]))}return gt.apply(void 0,this._rgb.slice(0,3))};var gt=function(Me,He,qe){return Me=vt(Me),He=vt(He),qe=vt(qe),.2126*Me+.7152*He+.0722*qe},vt=function(Me){return Me/=255,Me<=.03928?Me/12.92:Ue((Me+.055)/1.055,2.4)},wt={},Tt=ne,Mt=T.type,Dt=wt,Cr=function(Me,He,qe){qe===void 0&&(qe=.5);for(var ot=[],dt=arguments.length-3;dt-- >0;)ot[dt]=arguments[dt+3];var ft=ot[0]||"lrgb";if(!Dt[ft]&&!ot.length&&(ft=Object.keys(Dt)[0]),!Dt[ft])throw new Error("interpolation mode "+ft+" is not defined");return Mt(Me)!=="object"&&(Me=new Tt(Me)),Mt(He)!=="object"&&(He=new Tt(He)),Dt[ft](Me,He,qe).alpha(Me.alpha()+qe*(He.alpha()-Me.alpha()))},Jr=ne,Ti=Cr;Jr.prototype.mix=Jr.prototype.interpolate=function(Me,He){He===void 0&&(He=.5);for(var qe=[],ot=arguments.length-2;ot-- >0;)qe[ot]=arguments[ot+2];return Ti.apply(void 0,[this,Me,He].concat(qe))};var zr=ne;zr.prototype.premultiply=function(Me){Me===void 0&&(Me=!1);var He=this._rgb,qe=He[3];return Me?(this._rgb=[He[0]*qe,He[1]*qe,He[2]*qe,qe],this):new zr([He[0]*qe,He[1]*qe,He[2]*qe,qe],"rgb")};var ii=ne,Jo=Ot;ii.prototype.saturate=function(Me){Me===void 0&&(Me=1);var He=this,qe=He.lch();return qe[1]+=Jo.Kn*Me,qe[1]<0&&(qe[1]=0),new ii(qe,"lch").alpha(He.alpha(),!0)},ii.prototype.desaturate=function(Me){return Me===void 0&&(Me=1),this.saturate(-Me)};var oo=ne,ao=T.type;oo.prototype.set=function(Me,He,qe){qe===void 0&&(qe=!1);var ot=Me.split("."),dt=ot[0],ft=ot[1],ht=this[dt]();if(ft){var mt=dt.indexOf(ft)-(dt.substr(0,2)==="ok"?2:0);if(mt>-1){if(ao(He)=="string")switch(He.charAt(0)){case"+":ht[mt]+=+He;break;case"-":ht[mt]+=+He;break;case"*":ht[mt]*=+He.substr(1);break;case"/":ht[mt]/=+He.substr(1);break;default:ht[mt]=+He}else if(ao(He)==="number")ht[mt]=He;else throw new Error("unsupported value for Color.set");var yt=new oo(ht,dt);return qe?(this._rgb=yt._rgb,this):yt}throw new Error("unknown channel "+ft+" in mode "+dt)}else return ht};var lo=ne,ea=function(Me,He,qe){var ot=Me._rgb,dt=He._rgb;return new lo(ot[0]+qe*(dt[0]-ot[0]),ot[1]+qe*(dt[1]-ot[1]),ot[2]+qe*(dt[2]-ot[2]),"rgb")};wt.rgb=ea;var uo=ne,lr=Math.sqrt,Wr=Math.pow,ta=function(Me,He,qe){var ot=Me._rgb,dt=ot[0],ft=ot[1],ht=ot[2],mt=He._rgb,yt=mt[0],xt=mt[1],Ct=mt[2];return new uo(lr(Wr(dt,2)*(1-qe)+Wr(yt,2)*qe),lr(Wr(ft,2)*(1-qe)+Wr(xt,2)*qe),lr(Wr(ht,2)*(1-qe)+Wr(Ct,2)*qe),"rgb")};wt.lrgb=ta;var ra=ne,na=function(Me,He,qe){var ot=Me.lab(),dt=He.lab();return new ra(ot[0]+qe*(dt[0]-ot[0]),ot[1]+qe*(dt[1]-ot[1]),ot[2]+qe*(dt[2]-ot[2]),"lab")};wt.lab=na;var Pi=ne,bn=function(Me,He,qe,ot){var dt,ft,ht,mt;ot==="hsl"?(ht=Me.hsl(),mt=He.hsl()):ot==="hsv"?(ht=Me.hsv(),mt=He.hsv()):ot==="hcg"?(ht=Me.hcg(),mt=He.hcg()):ot==="hsi"?(ht=Me.hsi(),mt=He.hsi()):ot==="lch"||ot==="hcl"?(ot="hcl",ht=Me.hcl(),mt=He.hcl()):ot==="oklch"&&(ht=Me.oklch().reverse(),mt=He.oklch().reverse());var yt,xt,Ct,Pt,kt,$t;(ot.substr(0,1)==="h"||ot==="oklch")&&(dt=ht,yt=dt[0],Ct=dt[1],kt=dt[2],ft=mt,xt=ft[0],Pt=ft[1],$t=ft[2]);var It,Ut,Wt,Yt;return!isNaN(yt)&&!isNaN(xt)?(xt>yt&&xt-yt>180?Yt=xt-(yt+360):xt180?Yt=xt+360-yt:Yt=xt-yt,Ut=yt+qe*Yt):isNaN(yt)?isNaN(xt)?Ut=Number.NaN:(Ut=xt,(kt==1||kt==0)&&ot!="hsv"&&(It=Pt)):(Ut=yt,($t==1||$t==0)&&ot!="hsv"&&(It=Ct)),It===void 0&&(It=Ct+qe*(Pt-Ct)),Wt=kt+qe*($t-kt),ot==="oklch"?new Pi([Wt,It,Ut],ot):new Pi([Ut,It,Wt],ot)},ia=bn,wa=function(Me,He,qe){return ia(Me,He,qe,"lch")};wt.lch=wa,wt.hcl=wa;var Wa=ne,ja=function(Me,He,qe){var ot=Me.num(),dt=He.num();return new Wa(ot+qe*(dt-ot),"num")};wt.num=ja;var Ga=bn,Ya=function(Me,He,qe){return Ga(Me,He,qe,"hcg")};wt.hcg=Ya;var Ka=bn,qa=function(Me,He,qe){return Ka(Me,He,qe,"hsi")};wt.hsi=qa;var Xa=bn,Za=function(Me,He,qe){return Xa(Me,He,qe,"hsl")};wt.hsl=Za;var Qa=bn,Ja=function(Me,He,qe){return Qa(Me,He,qe,"hsv")};wt.hsv=Ja;var el=ne,tl=function(Me,He,qe){var ot=Me.oklab(),dt=He.oklab();return new el(ot[0]+qe*(dt[0]-ot[0]),ot[1]+qe*(dt[1]-ot[1]),ot[2]+qe*(dt[2]-ot[2]),"oklab")};wt.oklab=tl;var rl=bn,nl=function(Me,He,qe){return rl(Me,He,qe,"oklch")};wt.oklch=nl;var sa=ne,il=T.clip_rgb,oa=Math.pow,aa=Math.sqrt,la=Math.PI,Ea=Math.cos,Sa=Math.sin,sl=Math.atan2,ol=function(Me,He,qe){He===void 0&&(He="lrgb"),qe===void 0&&(qe=null);var ot=Me.length;qe||(qe=Array.from(new Array(ot)).map(function(){return 1}));var dt=ot/qe.reduce(function(Ut,Wt){return Ut+Wt});if(qe.forEach(function(Ut,Wt){qe[Wt]*=dt}),Me=Me.map(function(Ut){return new sa(Ut)}),He==="lrgb")return al(Me,qe);for(var ft=Me.shift(),ht=ft.get(He),mt=[],yt=0,xt=0,Ct=0;Ct=360;)It-=360;ht[$t]=It}else ht[$t]=ht[$t]/mt[$t];return kt/=ot,new sa(ht,He).alpha(kt>.99999?1:kt,!0)},al=function(Me,He){for(var qe=Me.length,ot=[0,0,0,0],dt=0;dt.9999999&&(ot[3]=1),new sa(il(ot))},jr=me,Ii=T.type,ll=Math.pow,ca=function(Me){var He="rgb",qe=jr("#ccc"),ot=0,dt=[0,1],ft=[],ht=[0,0],mt=!1,yt=[],xt=!1,Ct=0,Pt=1,kt=!1,$t={},It=!0,Ut=1,Wt=function(At){if(At=At||["#fff","#000"],At&&Ii(At)==="string"&&jr.brewer&&jr.brewer[At.toLowerCase()]&&(At=jr.brewer[At.toLowerCase()]),Ii(At)==="array"){At.length===1&&(At=[At[0],At[0]]),At=At.slice(0);for(var Rt=0;Rt=mt[Ht];)Ht++;return Ht-1}return 0},Zt=function(At){return At},_r=function(At){return At},vr=function(At,Rt){var Ht,Vt;if(Rt==null&&(Rt=!1),isNaN(At)||At===null)return qe;if(Rt)Vt=At;else if(mt&&mt.length>2){var xr=Yt(At);Vt=xr/(mt.length-2)}else Pt!==Ct?Vt=(At-Ct)/(Pt-Ct):Vt=1;Vt=_r(Vt),Rt||(Vt=Zt(Vt)),Ut!==1&&(Vt=ll(Vt,Ut)),Vt=ht[0]+Vt*(1-ht[0]-ht[1]),Vt=Math.min(1,Math.max(0,Vt));var sr=Math.floor(Vt*1e4);if(It&&$t[sr])Ht=$t[sr];else{if(Ii(yt)==="array")for(var Kt=0;Kt=Qt&&Kt===ft.length-1){Ht=yt[Kt];break}if(Vt>Qt&&Vt2){var Kt=At.map(function(Jt,er){return er/(At.length-1)}),Qt=At.map(function(Jt){return(Jt-Ct)/(Pt-Ct)});Qt.every(function(Jt,er){return Kt[er]===Jt})||(_r=function(Jt){if(Jt<=0||Jt>=1)return Jt;for(var er=0;Jt>=Qt[er+1];)er++;var Yr=(Jt-Qt[er])/(Qt[er+1]-Qt[er]),In=Kt[er]+Yr*(Kt[er+1]-Kt[er]);return In})}}return dt=[Ct,Pt],jt},jt.mode=function(At){return arguments.length?(He=At,Tr(),jt):He},jt.range=function(At,Rt){return Wt(At),jt},jt.out=function(At){return xt=At,jt},jt.spread=function(At){return arguments.length?(ot=At,jt):ot},jt.correctLightness=function(At){return At==null&&(At=!0),kt=At,Tr(),kt?Zt=function(Rt){for(var Ht=vr(0,!0).lab()[0],Vt=vr(1,!0).lab()[0],xr=Ht>Vt,sr=vr(Rt,!0).lab()[0],Kt=Ht+(Vt-Ht)*Rt,Qt=sr-Kt,Jt=0,er=1,Yr=20;Math.abs(Qt)>.01&&Yr-- >0;)(function(){return xr&&(Qt*=-1),Qt<0?(Jt=Rt,Rt+=(er-Rt)*.5):(er=Rt,Rt+=(Jt-Rt)*.5),sr=vr(Rt,!0).lab()[0],Qt=sr-Kt})();return Rt}:Zt=function(Rt){return Rt},jt},jt.padding=function(At){return At!=null?(Ii(At)==="number"&&(At=[At,At]),ht=At,jt):ht},jt.colors=function(At,Rt){arguments.length<2&&(Rt="hex");var Ht=[];if(arguments.length===0)Ht=yt.slice(0);else if(At===1)Ht=[jt(.5)];else if(At>1){var Vt=dt[0],xr=dt[1]-Vt;Ht=cl(0,At,!1).map(function(er){return jt(Vt+er/(At-1)*xr)})}else{Me=[];var sr=[];if(mt&&mt.length>2)for(var Kt=1,Qt=mt.length,Jt=1<=Qt;Jt?KtQt;Jt?Kt++:Kt--)sr.push((mt[Kt-1]+mt[Kt])*.5);else sr=dt;Ht=sr.map(function(er){return jt(er)})}return jr[Rt]&&(Ht=Ht.map(function(er){return er[Rt]()})),Ht},jt.cache=function(At){return At!=null?(It=At,jt):It},jt.gamma=function(At){return At!=null?(Ut=At,jt):Ut},jt.nodata=function(At){return At!=null?(qe=jr(At),jt):qe},jt};function cl(Me,He,qe){for(var ot=[],dt=Meft;dt?ht++:ht--)ot.push(ht);return ot}var us=ne,ul=ca,hl=function(Me){for(var He=[1,1],qe=1;qe=5){var xt,Ct,Pt;xt=Me.map(function(kt){return kt.lab()}),Pt=Me.length-1,Ct=hl(Pt),dt=function(kt){var $t=1-kt,It=[0,1,2].map(function(Ut){return xt.reduce(function(Wt,Yt,Zt){return Wt+Ct[Zt]*Math.pow($t,Pt-Zt)*Math.pow(kt,Zt)*Yt[Ut]},0)});return new us(It,"lab")}}else throw new RangeError("No point in running bezier with only one color.");return dt},fl=function(Me){var He=dl(Me);return He.scale=function(){return ul(He)},He},ua=me,Gr=function(Me,He,qe){if(!Gr[qe])throw new Error("unknown blend mode "+qe);return Gr[qe](Me,He)},Tn=function(Me){return function(He,qe){var ot=ua(qe).rgb(),dt=ua(He).rgb();return ua.rgb(Me(ot,dt))}},Pn=function(Me){return function(He,qe){var ot=[];return ot[0]=Me(He[0],qe[0]),ot[1]=Me(He[1],qe[1]),ot[2]=Me(He[2],qe[2]),ot}},pl=function(Me){return Me},ml=function(Me,He){return Me*He/255},gl=function(Me,He){return Me>He?He:Me},yl=function(Me,He){return Me>He?Me:He},vl=function(Me,He){return 255*(1-(1-Me/255)*(1-He/255))},bl=function(Me,He){return He<128?2*Me*He/255:255*(1-2*(1-Me/255)*(1-He/255))},_l=function(Me,He){return 255*(1-(1-He/255)/(Me/255))},xl=function(Me,He){return Me===255?255:(Me=255*(He/255)/(1-Me/255),Me>255?255:Me)};Gr.normal=Tn(Pn(pl)),Gr.multiply=Tn(Pn(ml)),Gr.screen=Tn(Pn(vl)),Gr.overlay=Tn(Pn(bl)),Gr.darken=Tn(Pn(gl)),Gr.lighten=Tn(Pn(yl)),Gr.dodge=Tn(Pn(xl)),Gr.burn=Tn(Pn(_l));for(var wl=Gr,ha=T.type,El=T.clip_rgb,Sl=T.TWOPI,Cl=Math.pow,kl=Math.sin,Al=Math.cos,Ca=me,Tl=function(Me,He,qe,ot,dt){Me===void 0&&(Me=300),He===void 0&&(He=-1.5),qe===void 0&&(qe=1),ot===void 0&&(ot=1),dt===void 0&&(dt=[0,1]);var ft=0,ht;ha(dt)==="array"?ht=dt[1]-dt[0]:(ht=0,dt=[dt,dt]);var mt=function(yt){var xt=Sl*((Me+120)/360+He*yt),Ct=Cl(dt[0]+ht*yt,ot),Pt=ft!==0?qe[0]+yt*ft:qe,kt=Pt*Ct*(1-Ct)/2,$t=Al(xt),It=kl(xt),Ut=Ct+kt*(-.14861*$t+1.78277*It),Wt=Ct+kt*(-.29227*$t-.90649*It),Yt=Ct+kt*(1.97294*$t);return Ca(El([Ut*255,Wt*255,Yt*255,1]))};return mt.start=function(yt){return yt==null?Me:(Me=yt,mt)},mt.rotations=function(yt){return yt==null?He:(He=yt,mt)},mt.gamma=function(yt){return yt==null?ot:(ot=yt,mt)},mt.hue=function(yt){return yt==null?qe:(qe=yt,ha(qe)==="array"?(ft=qe[1]-qe[0],ft===0&&(qe=qe[1])):ft=0,mt)},mt.lightness=function(yt){return yt==null?dt:(ha(yt)==="array"?(dt=yt,ht=yt[1]-yt[0]):(dt=[yt,yt],ht=0),mt)},mt.scale=function(){return Ca.scale(mt)},mt.hue(qe),mt},Pl=ne,Il="0123456789abcdef",$l=Math.floor,Ll=Math.random,Rl=function(){for(var Me="#",He=0;He<6;He++)Me+=Il.charAt($l(Ll()*16));return new Pl(Me,"hex")},da=g,ka=Math.log,Ml=Math.pow,Ol=Math.floor,Dl=Math.abs,Aa=function(Me,He){He===void 0&&(He=null);var qe={min:Number.MAX_VALUE,max:Number.MAX_VALUE*-1,sum:0,values:[],count:0};return da(Me)==="object"&&(Me=Object.values(Me)),Me.forEach(function(ot){He&&da(ot)==="object"&&(ot=ot[He]),ot!=null&&!isNaN(ot)&&(qe.values.push(ot),qe.sum+=ot,otqe.max&&(qe.max=ot),qe.count+=1)}),qe.domain=[qe.min,qe.max],qe.limits=function(ot,dt){return Ta(qe,ot,dt)},qe},Ta=function(Me,He,qe){He===void 0&&(He="equal"),qe===void 0&&(qe=7),da(Me)=="array"&&(Me=Aa(Me));var ot=Me.min,dt=Me.max,ft=Me.values.sort(function(pa,ma){return pa-ma});if(qe===1)return[ot,dt];var ht=[];if(He.substr(0,1)==="c"&&(ht.push(ot),ht.push(dt)),He.substr(0,1)==="e"){ht.push(ot);for(var mt=1;mt 0");var yt=Math.LOG10E*ka(ot),xt=Math.LOG10E*ka(dt);ht.push(ot);for(var Ct=1;Ct200&&(_r=!1)}for(var $n={},$i=0;$iot?(qe+.05)/(ot+.05):(ot+.05)/(qe+.05)},$a=ne,_n=Math.sqrt,pr=Math.pow,Bl=Math.min,Fl=Math.max,La=Math.atan2,Ra=Math.abs,ho=Math.cos,Ma=Math.sin,Ul=Math.exp,Oa=Math.PI,Vl=function(Me,He,qe,ot,dt){qe===void 0&&(qe=1),ot===void 0&&(ot=1),dt===void 0&&(dt=1);var ft=function(oi){return 360*oi/(2*Oa)},ht=function(oi){return 2*Oa*oi/360};Me=new $a(Me),He=new $a(He);var mt=Array.from(Me.lab()),yt=mt[0],xt=mt[1],Ct=mt[2],Pt=Array.from(He.lab()),kt=Pt[0],$t=Pt[1],It=Pt[2],Ut=(yt+kt)/2,Wt=_n(pr(xt,2)+pr(Ct,2)),Yt=_n(pr($t,2)+pr(It,2)),Zt=(Wt+Yt)/2,_r=.5*(1-_n(pr(Zt,7)/(pr(Zt,7)+pr(25,7)))),vr=xt*(1+_r),Tr=$t*(1+_r),jt=_n(pr(vr,2)+pr(Ct,2)),At=_n(pr(Tr,2)+pr(It,2)),Rt=(jt+At)/2,Ht=ft(La(Ct,vr)),Vt=ft(La(It,Tr)),xr=Ht>=0?Ht:Ht+360,sr=Vt>=0?Vt:Vt+360,Kt=Ra(xr-sr)>180?(xr+sr+360)/2:(xr+sr)/2,Qt=1-.17*ho(ht(Kt-30))+.24*ho(ht(2*Kt))+.32*ho(ht(3*Kt+6))-.2*ho(ht(4*Kt-63)),Jt=sr-xr;Jt=Ra(Jt)<=180?Jt:sr<=xr?Jt+360:Jt-360,Jt=2*_n(jt*At)*Ma(ht(Jt)/2);var er=kt-yt,Yr=At-jt,In=1+.015*pr(Ut-50,2)/_n(20+pr(Ut-50,2)),$n=1+.045*Rt,$i=1+.015*Rt*Qt,Li=30*Ul(-pr((Kt-275)/25,2)),xn=2*_n(pr(Rt,7)/(pr(Rt,7)+pr(25,7))),si=-xn*Ma(2*ht(Li)),hs=_n(pr(er/(qe*In),2)+pr(Yr/(ot*$n),2)+pr(Jt/(dt*$i),2)+si*(Yr/(ot*$n))*(Jt/(dt*$i)));return Fl(0,Bl(100,hs))},Da=ne,Hl=function(Me,He,qe){qe===void 0&&(qe="lab"),Me=new Da(Me),He=new Da(He);var ot=Me.get(qe),dt=He.get(qe),ft=0;for(var ht in ot){var mt=(ot[ht]||0)-(dt[ht]||0);ft+=mt*mt}return Math.sqrt(ft)},zl=ne,Wl=function(){for(var Me=[],He=arguments.length;He--;)Me[He]=arguments[He];try{return new(Function.prototype.bind.apply(zl,[null].concat(Me))),!0}catch{return!1}},Na=me,Ba=ca,jl={cool:function(){return Ba([Na.hsl(180,1,.9),Na.hsl(250,.7,.4)])},hot:function(){return Ba(["#000","#f00","#ff0","#fff"]).mode("rgb")}},fo={OrRd:["#fff7ec","#fee8c8","#fdd49e","#fdbb84","#fc8d59","#ef6548","#d7301f","#b30000","#7f0000"],PuBu:["#fff7fb","#ece7f2","#d0d1e6","#a6bddb","#74a9cf","#3690c0","#0570b0","#045a8d","#023858"],BuPu:["#f7fcfd","#e0ecf4","#bfd3e6","#9ebcda","#8c96c6","#8c6bb1","#88419d","#810f7c","#4d004b"],Oranges:["#fff5eb","#fee6ce","#fdd0a2","#fdae6b","#fd8d3c","#f16913","#d94801","#a63603","#7f2704"],BuGn:["#f7fcfd","#e5f5f9","#ccece6","#99d8c9","#66c2a4","#41ae76","#238b45","#006d2c","#00441b"],YlOrBr:["#ffffe5","#fff7bc","#fee391","#fec44f","#fe9929","#ec7014","#cc4c02","#993404","#662506"],YlGn:["#ffffe5","#f7fcb9","#d9f0a3","#addd8e","#78c679","#41ab5d","#238443","#006837","#004529"],Reds:["#fff5f0","#fee0d2","#fcbba1","#fc9272","#fb6a4a","#ef3b2c","#cb181d","#a50f15","#67000d"],RdPu:["#fff7f3","#fde0dd","#fcc5c0","#fa9fb5","#f768a1","#dd3497","#ae017e","#7a0177","#49006a"],Greens:["#f7fcf5","#e5f5e0","#c7e9c0","#a1d99b","#74c476","#41ab5d","#238b45","#006d2c","#00441b"],YlGnBu:["#ffffd9","#edf8b1","#c7e9b4","#7fcdbb","#41b6c4","#1d91c0","#225ea8","#253494","#081d58"],Purples:["#fcfbfd","#efedf5","#dadaeb","#bcbddc","#9e9ac8","#807dba","#6a51a3","#54278f","#3f007d"],GnBu:["#f7fcf0","#e0f3db","#ccebc5","#a8ddb5","#7bccc4","#4eb3d3","#2b8cbe","#0868ac","#084081"],Greys:["#ffffff","#f0f0f0","#d9d9d9","#bdbdbd","#969696","#737373","#525252","#252525","#000000"],YlOrRd:["#ffffcc","#ffeda0","#fed976","#feb24c","#fd8d3c","#fc4e2a","#e31a1c","#bd0026","#800026"],PuRd:["#f7f4f9","#e7e1ef","#d4b9da","#c994c7","#df65b0","#e7298a","#ce1256","#980043","#67001f"],Blues:["#f7fbff","#deebf7","#c6dbef","#9ecae1","#6baed6","#4292c6","#2171b5","#08519c","#08306b"],PuBuGn:["#fff7fb","#ece2f0","#d0d1e6","#a6bddb","#67a9cf","#3690c0","#02818a","#016c59","#014636"],Viridis:["#440154","#482777","#3f4a8a","#31678e","#26838f","#1f9d8a","#6cce5a","#b6de2b","#fee825"],Spectral:["#9e0142","#d53e4f","#f46d43","#fdae61","#fee08b","#ffffbf","#e6f598","#abdda4","#66c2a5","#3288bd","#5e4fa2"],RdYlGn:["#a50026","#d73027","#f46d43","#fdae61","#fee08b","#ffffbf","#d9ef8b","#a6d96a","#66bd63","#1a9850","#006837"],RdBu:["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#f7f7f7","#d1e5f0","#92c5de","#4393c3","#2166ac","#053061"],PiYG:["#8e0152","#c51b7d","#de77ae","#f1b6da","#fde0ef","#f7f7f7","#e6f5d0","#b8e186","#7fbc41","#4d9221","#276419"],PRGn:["#40004b","#762a83","#9970ab","#c2a5cf","#e7d4e8","#f7f7f7","#d9f0d3","#a6dba0","#5aae61","#1b7837","#00441b"],RdYlBu:["#a50026","#d73027","#f46d43","#fdae61","#fee090","#ffffbf","#e0f3f8","#abd9e9","#74add1","#4575b4","#313695"],BrBG:["#543005","#8c510a","#bf812d","#dfc27d","#f6e8c3","#f5f5f5","#c7eae5","#80cdc1","#35978f","#01665e","#003c30"],RdGy:["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#ffffff","#e0e0e0","#bababa","#878787","#4d4d4d","#1a1a1a"],PuOr:["#7f3b08","#b35806","#e08214","#fdb863","#fee0b6","#f7f7f7","#d8daeb","#b2abd2","#8073ac","#542788","#2d004b"],Set2:["#66c2a5","#fc8d62","#8da0cb","#e78ac3","#a6d854","#ffd92f","#e5c494","#b3b3b3"],Accent:["#7fc97f","#beaed4","#fdc086","#ffff99","#386cb0","#f0027f","#bf5b17","#666666"],Set1:["#e41a1c","#377eb8","#4daf4a","#984ea3","#ff7f00","#ffff33","#a65628","#f781bf","#999999"],Set3:["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3","#fdb462","#b3de69","#fccde5","#d9d9d9","#bc80bd","#ccebc5","#ffed6f"],Dark2:["#1b9e77","#d95f02","#7570b3","#e7298a","#66a61e","#e6ab02","#a6761d","#666666"],Paired:["#a6cee3","#1f78b4","#b2df8a","#33a02c","#fb9a99","#e31a1c","#fdbf6f","#ff7f00","#cab2d6","#6a3d9a","#ffff99","#b15928"],Pastel2:["#b3e2cd","#fdcdac","#cbd5e8","#f4cae4","#e6f5c9","#fff2ae","#f1e2cc","#cccccc"],Pastel1:["#fbb4ae","#b3cde3","#ccebc5","#decbe4","#fed9a6","#ffffcc","#e5d8bd","#fddaec","#f2f2f2"]},fa=0,Fa=Object.keys(fo);fal===o);if(r[a])return r[a]}return r[r.length-1]}const markerIcon2x="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAABSCAMAAAAhFXfZAAAC91BMVEVMaXEzeak2f7I4g7g3g7cua5gzeKg8hJo3grY4g7c3grU0gLI2frE0daAubJc2gbQwd6QzeKk2gLMtd5sxdKIua5g1frA2f7IydaM0e6w2fq41fK01eqo3grgubJgta5cxdKI1f7AydaQydaMxc6EubJgvbJkwcZ4ubZkwcJwubZgubJcydqUydKIxapgubJctbJcubZcubJcvbJYubJcvbZkubJctbJctbZcubJg2f7AubJcrbZcubJcubJcua5g3grY0fq8ubJcubJdEkdEwhsw6i88vhswuhcsuhMtBjMgthMsrg8srgss6is8qgcs8i9A9iMYtg8spgcoogMo7hcMngMonf8olfso4gr8kfck5iM8jfMk4iM8he8k1fro7itAgesk2hs8eecgzfLcofssdeMg0hc4cd8g2hcsxeLQbdsgZdcgxeLImfcszhM0vda4xgckzhM4xg84wf8Yxgs4udKsvfcQucqhUndROmdM1fK0wcZ8vb5w0eqpQm9MzeKhXoNVcpdYydKNWn9VZotVKltJFjsIwcJ1Rms9OlslLmtH///8+kc9epdYzd6dbo9VHkMM2f7FHmNBClM8ydqVcpNY9hro3gLM9hLczealQmcw3fa46f7A8gLMxc6I3eagyc6FIldJMl9JSnNRSntNNl9JPnNJFi75UnM9ZodVKksg8kM45jc09e6ZHltFBk883gbRBh7pDk9EwcaBzn784g7dKkcY2i81Om9M7j85Llc81is09g7Q4grY/j9A0eqxKmdFFltBEjcXf6fFImdBCiLxJl9FGlNFBi78yiMxVndEvbpo6js74+vx+psPP3+o/ks5HkcpGmNCjwdZCkNDM3ehYoNJEls+lxNkxh8xHks0+jdC1zd5Lg6r+/v/H2ufz9/o3jM3t8/edvdM/k89Th61OiLBSjbZklbaTt9BfptdjmL1AicBHj8hGk9FAgK1dkLNTjLRekrdClc/k7fM0icy0y9tgp9c4jc2NtM9Dlc8zicxeXZn3AAAAQ3RSTlMAHDdTb4yPA+LtnEQmC4L2EmHqB7XA0d0sr478x4/Yd5i1zOfyPkf1sLVq4Nh3FvjxopQ2/STNuFzUwFIwxKaejILpIBEV9wAABhVJREFUeF6s1NdyFEcYBeBeoQIhRAkLlRDGrhIgY3BJL8CVeKzuyXFzzjkn5ZxzzuScg3PO8cKzu70JkO0LfxdTU//pM9vTu7Xgf6KqOVTb9X7toRrVEfBf1HTVjZccrT/2by1VV928Yty9ZbVuucdz90frG8DBjl9pVApbOstvmMuvVgaNXSfAAd6pGxpy6yxf5ph43pS/4f3uoaGm2rdu72S9xzOvMymkZFq/ptDrk90mhW7e4zl7HLzhxGWPR20xmSxJ/VqldG5m9XhaVOA1DadsNh3Pu5L2N6QtPO/32JpqQBVVk20oy/Pi2s23WEvyfHbe1thadVQttvm7Llf65gGmXK67XtupyoM7HQhmXdLS8oGWJNeOJ3C5fG5XCEJnkez3/oFdsvgJ4l2ANZwhrJKk/7OSXa+3Vw2WJMlKnGkobouYk6T0TyX30klOUnTD9HJ5qpckL3EW/w4XF3Xd0FGywXUrstrclVsqz5Pd/sXFYyDnPdrLcQODmGOK47IZb4CmibmMn+MYRzFZ5jg33ZL/EJrWcszHmANy3ARBK/IXtciJy8VsitPSdE3uuHxzougojcUdr8/32atnz/ev3f/K5wtpxUTpcaI45zusVDpYtZi+jg0oU9b3x74h7+n9ABvYEZeKaVq0sh0AtLKsFtqNBdeT0MrSzwwlq9+x6xAO4tgOtSzbCjrNQQiNvQUbUEubvzBUeGw26yDCsRHCoLkTHDa7IdOLIThs/gHvChszh2CimE8peRs47cxANI0lYNB5y1DljpOF0IhzBDPOZnDOqYYbeGKECbPzWnXludPphw5c2YBq5zlwXphIbO4VDCZ0gnPfUO1TwZoYwAs2ExPCedAu9DAjfQUjzITQb3jNj0KG2Sgt6BHaQUdYzWz+XmBktOHwanXjaSTcwwziBcuMOtwBmqPrTOxFQR/DRKKPqyur0aiW6cULYsx6tBm0jXpR/AUWR6HRq9WVW6MRhIq5jLyjbaCTDCijyYJNpCajdyobP/eTw0iexBAKkJ3gA5KcQb2zBXsIBckn+xVv8jkZSaEFHE+jFEleAEfayRU0MouNoBmB/L50Ai/HSLIHxcrpCvnhSQAuakKp2C/YbCylJjXRVy/z3+Kv/RrNcCo+WUzlVEhzKffnTQnxeN9fWF88fiNCUdSTsaufaChKWInHeysygfpIqagoakW+vV20J8uyl6TyNKEZWV4oRSPyCkWpgOLSbkCObT8o2r6tlG58HQquf6O0v50tB7JM7F4EORd2dx/K0w/KHsVkLPaoYrwgP/y7krr3SSMA4zj+OBgmjYkxcdIJQyQRKgg2viX9Hddi9UBb29LrKR7CVVEEEXWojUkXNyfTNDE14W9gbHJNuhjDettN3ZvbOvdOqCD3Jp/9l+/wJE+9PkYGjx/fqkys3S2rMozM/o2106rfMUINo6hVqz+eu/hd1c4xTg0TAfy5kV+4UG6+IthHTU9woWmxuKNbTfuCSfovBCxq7EtHqvYL4Sm6F8GVxsSXHMQ07TOi1DKtZxjWaaIyi4CXWjxPccUw8WVbMYY5wxC1mzEyXMJWkllpRloi+Kkoq69sxBTlElF6aAxYUbjXNlhlDZilDnM4U5SlN5biRsRHnbx3mbeWjEh4mEyiuJDl5XcWVmX5GvNkFgLWZM5qwsop4/AWfLhU1cR7k1VVvcYCWRkOI6Xy5gmnphCYIkvzuNYzHzosq2oNk2RtSs8khfUOfHIDgR6ysYBaMpl4uEgk2U/oJTs9AaTSwma7dT69geAE2ZpEjUsn2ieJNHeKfrI3EcAGJ2ZaNgVuC8EBctCLc57P5u5led6IOBkIYkuQMrmmjChs4VkfOerHqSBkPzZlhe06RslZ3zMjk2sscqKwY0RcjKK+LWbzd7KiHhkncs/siFJ+V5eXxD34B8nVuJEpGJNmxN2gH3vSvp7J70tF+D1Ej8qUJD1TkErAND2GZwTFg/LubvmgiBG3SOvdlsqFQrkEzJCL1rstlnVFROixZoDDSuXQFHESwVGlcuQcMb/b42NgjLowh5MTDFE3vNB5qStRIErdCQEh6pLPR92anSUb/wAIhldAaDMpGgAAAABJRU5ErkJggg==",markerIcon="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABkAAAApCAYAAADAk4LOAAAFgUlEQVR4Aa1XA5BjWRTN2oW17d3YaZtr2962HUzbDNpjszW24mRt28p47v7zq/bXZtrp/lWnXr337j3nPCe85NcypgSFdugCpW5YoDAMRaIMqRi6aKq5E3YqDQO3qAwjVWrD8Ncq/RBpykd8oZUb/kaJutow8r1aP9II0WmLKLIsJyv1w/kqw9Ch2MYdB++12Onxee/QMwvf4/Dk/Lfp/i4nxTXtOoQ4pW5Aj7wpici1A9erdAN2OH64x8OSP9j3Ft3b7aWkTg/Fm91siTra0f9on5sQr9INejH6CUUUpavjFNq1B+Oadhxmnfa8RfEmN8VNAsQhPqF55xHkMzz3jSmChWU6f7/XZKNH+9+hBLOHYozuKQPxyMPUKkrX/K0uWnfFaJGS1QPRtZsOPtr3NsW0uyh6NNCOkU3Yz+bXbT3I8G3xE5EXLXtCXbbqwCO9zPQYPRTZ5vIDXD7U+w7rFDEoUUf7ibHIR4y6bLVPXrz8JVZEql13trxwue/uDivd3fkWRbS6/IA2bID4uk0UpF1N8qLlbBlXs4Ee7HLTfV1j54APvODnSfOWBqtKVvjgLKzF5YdEk5ewRkGlK0i33Eofffc7HT56jD7/6U+qH3Cx7SBLNntH5YIPvODnyfIXZYRVDPqgHtLs5ABHD3YzLuespb7t79FY34DjMwrVrcTuwlT55YMPvOBnRrJ4VXTdNnYug5ucHLBjEpt30701A3Ts+HEa73u6dT3FNWwflY86eMHPk+Yu+i6pzUpRrW7SNDg5JHR4KapmM5Wv2E8Tfcb1HoqqHMHU+uWDD7zg54mz5/2BSnizi9T1Dg4QQXLToGNCkb6tb1NU+QAlGr1++eADrzhn/u8Q2YZhQVlZ5+CAOtqfbhmaUCS1ezNFVm2imDbPmPng5wmz+gwh+oHDce0eUtQ6OGDIyR0uUhUsoO3vfDmmgOezH0mZN59x7MBi++WDL1g/eEiU3avlidO671bkLfwbw5XV2P8Pzo0ydy4t2/0eu33xYSOMOD8hTf4CrBtGMSoXfPLchX+J0ruSePw3LZeK0juPJbYzrhkH0io7B3k164hiGvawhOKMLkrQLyVpZg8rHFW7E2uHOL888IBPlNZ1FPzstSJM694fWr6RwpvcJK60+0HCILTBzZLFNdtAzJaohze60T8qBzyh5ZuOg5e7uwQppofEmf2++DYvmySqGBuKaicF1blQjhuHdvCIMvp8whTTfZzI7RldpwtSzL+F1+wkdZ2TBOW2gIF88PBTzD/gpeREAMEbxnJcaJHNHrpzji0gQCS6hdkEeYt9DF/2qPcEC8RM28Hwmr3sdNyht00byAut2k3gufWNtgtOEOFGUwcXWNDbdNbpgBGxEvKkOQsxivJx33iow0Vw5S6SVTrpVq11ysA2Rp7gTfPfktc6zhtXBBC+adRLshf6sG2RfHPZ5EAc4sVZ83yCN00Fk/4kggu40ZTvIEm5g24qtU4KjBrx/BTTH8ifVASAG7gKrnWxJDcU7x8X6Ecczhm3o6YicvsLXWfh3Ch1W0k8x0nXF+0fFxgt4phz8QvypiwCCFKMqXCnqXExjq10beH+UUA7+nG6mdG/Pu0f3LgFcGrl2s0kNNjpmoJ9o4B29CMO8dMT4Q5ox8uitF6fqsrJOr8qnwNbRzv6hSnG5wP+64C7h9lp30hKNtKdWjtdkbuPA19nJ7Tz3zR/ibgARbhb4AlhavcBebmTHcFl2fvYEnW0ox9xMxKBS8btJ+KiEbq9zA4RthQXDhPa0T9TEe69gWupwc6uBUphquXgf+/FrIjweHQS4/pduMe5ERUMHUd9xv8ZR98CxkS4F2n3EUrUZ10EYNw7BWm9x1GiPssi3GgiGRDKWRYZfXlON+dfNbM+GgIwYdwAAAAASUVORK5CYII=",markerShadow="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACkAAAApCAQAAAACach9AAACMUlEQVR4Ae3ShY7jQBAE0Aoz/f9/HTMzhg1zrdKUrJbdx+Kd2nD8VNudfsL/Th///dyQN2TH6f3y/BGpC379rV+S+qqetBOxImNQXL8JCAr2V4iMQXHGNJxeCfZXhSRBcQMfvkOWUdtfzlLgAENmZDcmo2TVmt8OSM2eXxBp3DjHSMFutqS7SbmemzBiR+xpKCNUIRkdkkYxhAkyGoBvyQFEJEefwSmmvBfJuJ6aKqKWnAkvGZOaZXTUgFqYULWNSHUckZuR1HIIimUExutRxwzOLROIG4vKmCKQt364mIlhSyzAf1m9lHZHJZrlAOMMztRRiKimp/rpdJDc9Awry5xTZCte7FHtuS8wJgeYGrex28xNTd086Dik7vUMscQOa8y4DoGtCCSkAKlNwpgNtphjrC6MIHUkR6YWxxs6Sc5xqn222mmCRFzIt8lEdKx+ikCtg91qS2WpwVfBelJCiQJwvzixfI9cxZQWgiSJelKnwBElKYtDOb2MFbhmUigbReQBV0Cg4+qMXSxXSyGUn4UbF8l+7qdSGnTC0XLCmahIgUHLhLOhpVCtw4CzYXvLQWQbJNmxoCsOKAxSgBJno75avolkRw8iIAFcsdc02e9iyCd8tHwmeSSoKTowIgvscSGZUOA7PuCN5b2BX9mQM7S0wYhMNU74zgsPBj3HU7wguAfnxxjFQGBE6pwN+GjME9zHY7zGp8wVxMShYX9NXvEWD3HbwJf4giO4CFIQxXScH1/TM+04kkBiAAAAAElFTkSuQmCC",queue=new queue$1;let scale,markersLayer,pathsLayer,moveLayer,handlerClickMarker;delete L$2.Icon.Default.prototype._getIconUrl;L$2.Icon.Default.mergeOptions({iconRetinaUrl:markerIcon2x,iconUrl:markerIcon,shadowUrl:markerShadow});const messageTypes={0:"text",1:"air",2:"garbage",3:"water",4:"fire",5:"forest",6:"alert",7:"notif",8:"recycle",9:"parking",42:"gank"};let messageIconName={},messageIconType={};const messagesLayers=Object.values(messageTypes).reduce((e,t)=>(e[t]=null,e),{});async function init$2(e,t,r){for(const o of Object.keys(messageTypes)){try{messageIconType[o]=(await __variableDynamicImportRuntimeHelper(Object.assign({"../../assets/message/msg-air.png":()=>__vitePreload(()=>import("./msg-air.abb754d3.js"),[],import.meta.url),"../../assets/message/msg-alert.png":()=>__vitePreload(()=>import("./msg-alert.9404c396.js"),[],import.meta.url),"../../assets/message/msg-fire.png":()=>__vitePreload(()=>import("./msg-fire.faa011b0.js"),[],import.meta.url),"../../assets/message/msg-forest.png":()=>__vitePreload(()=>import("./msg-forest.a623a1f9.js"),[],import.meta.url),"../../assets/message/msg-gank.png":()=>__vitePreload(()=>import("./msg-gank.34a748fe.js"),[],import.meta.url),"../../assets/message/msg-garbage.png":()=>__vitePreload(()=>import("./msg-garbage.b797b882.js"),[],import.meta.url),"../../assets/message/msg-notif.png":()=>__vitePreload(()=>import("./msg-notif.d72c5a6f.js"),[],import.meta.url),"../../assets/message/msg-parking.png":()=>__vitePreload(()=>import("./msg-parking.5da4fdeb.js"),[],import.meta.url),"../../assets/message/msg-recycle.png":()=>__vitePreload(()=>import("./msg-recycle.eab79c00.js"),[],import.meta.url),"../../assets/message/msg-text.png":()=>__vitePreload(()=>import("./msg-text.470fee8d.js"),[],import.meta.url),"../../assets/message/msg-water.png":()=>__vitePreload(()=>import("./msg-water.b0066085.js"),[],import.meta.url)}),`../../assets/message/msg-${messageTypes[o]}.png`)).default}catch{messageIconType[o]=(await __vitePreload(()=>import("./msg-text.470fee8d.js"),[],import.meta.url)).default}messageIconName[messageTypes[o]]=messageIconType[o]}handlerClickMarker=o=>{/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)?e.setActiveArea({position:"absolute",top:"90px",left:"0px",right:"0px",height:"20%"}):e.setActiveArea({position:"absolute",top:"0px",left:"0px",right:"50%",height:"100%"}),e.panTo(o.latlng),r(o.target.options.data)};const n=getMeasurementByName(t);scale=generate$1(n.colors,n.range),markersLayer=new L$2.MarkerClusterGroup({showCoverageOnHover:!1,maxClusterRadius:120,iconCreateFunction:iconCreate}),e.addLayer(markersLayer),pathsLayer=new L$2.layerGroup,e.addLayer(pathsLayer),moveLayer=new L$2.layerGroup,e.addLayer(moveLayer);for(const o of Object.values(messageTypes))messagesLayers[o]=new L$2.MarkerClusterGroup({showCoverageOnHover:!1,maxClusterRadius:120,iconCreateFunction:a=>iconCreateMsg(a,o)});for(const o of Object.values(messagesLayers))e.addLayer(o)}function isReadyLayers(){return!!(markersLayer&&pathsLayer&&moveLayer)}function iconCreate(e){const t=e.getAllChildMarkers(),r=e.getChildCount();let n=0,o=0;t.forEach(u=>{u.options.data.value===void 0&&u.options.data.value!==""||(n++,o+=Number(u.options.data.value))}),n>0&&(o=o/n);const a=getColorRGB(scale,o),l=getColorDarkenRGB(scale,o),c=scale(o).luminance()<.4;return new L$2.DivIcon({html:`
${r}
`,className:"marker-cluster",iconSize:new L$2.Point(40,40)})}function iconCreateMsg(e,t="text"){const r=e.getChildCount();return new L$2.DivIcon({html:`
${r}
`,className:"marker-cluster",iconSize:new L$2.Point(40,40)})}function findMarker(e){return new Promise(t=>{markersLayer&&markersLayer.eachLayer(r=>{r.options.data.sensor_id===e&&t(r)}),t(!1)})}function createIconBrand(e,t){return L$2.divIcon({html:``,iconSize:[40,40],className:"marker-icon"})}function createIconMsg(e=0){return L$2.divIcon({html:``,iconSize:[40,40],className:"marker-icon"})}function createIconArrow(e,t,r){return L$2.divIcon({className:"",html:`
${t} m/s
-
`,iconSize:new L$2.Point(40,40)})}function iconCreateCircle(e){return new L$2.DivIcon({html:`
`,className:"marker-cluster",iconSize:new L$2.Point(40,40)})}function createMarkerBrand(e,t,r){return L$2.marker(new L$2.LatLng(e[0],e[1]),{icon:createIconBrand(t.sensor_id,r.rgb),data:t,typeMarker:"brand"})}function createMarkerArrow(e,t,r){return L$2.marker(new L$2.LatLng(e[0],e[1]),{icon:createIconArrow(t.data.windang,t.data.windspeed,r.basic),data:t,typeMarker:"arrow"})}function createMarkerCircle(e,t,r){return L$2.marker(new L$2.LatLng(e[0],e[1]),{icon:iconCreateCircle(r),data:t,typeMarker:"circle"})}function createMarkerUser(e,t){return L$2.marker(new L$2.LatLng(e[0],e[1]),{icon:createIconMsg(t.data.type),data:t,typeMarker:"msg"})}function createMarker(e,t){const r=[e.geo.lat,e.geo.lng];let n;return sensors[e.sensor_id]&&sensors[e.sensor_id].icon?n=createMarkerBrand(r,e,t):e.data.windang?n=createMarkerArrow(r,e,t):e.model===4?n=createMarkerUser(r,e):n=createMarkerCircle(r,e,t),n}function updateMarker(e,t,r){if(e.options.typeMarker==="brand"?e.setIcon(createIconBrand(t.sensor_id,r.rgb)):e.options.typeMarker==="arrow"&&Object.prototype.hasOwnProperty.call(t.data,"windang")?e.setIcon(createIconArrow(t.data.windang,t.data.windspeed,r.basic)):e.setIcon(iconCreateCircle(r)),t.model===3){const n=[t.geo.lat,t.geo.lng];e.setLatLng(new L$2.LatLng(n[0],n[1]))}}async function addPoint(e){e.sensor_id==="ab9de1c7a82d9b193fd9f169d8af1b64ce4f7b391d9f50f9ac127a49615a9693"&&console.log("GRAY PM10",e),e.sensor_id==="3eb468d90d6640bcef0b0b792a947d05bcc4da1b11316b283dda59e79336fdaa"&&console.log("GREEN PM10",e),queue.add(t.bind(queue,e));async function t(r){try{if(r.model===1)console.log(r);else if(r.model===2){await addMarker(r);const n=new BroadcastChannel("sensors");n.postMessage(r),n.close()}else r.model===3?(await addMarker(r),await addPointPath(r)):r.model===4&&await addMarkerUser(r)}catch(n){console.log(n)}this.next()}}function markercolor(e){let t=null;const r=localStorage.getItem("currentUnit")??null,n=measurements[r].zones;if(r){const o=n.find(a=>e<=a?.value);o?t=o?.color:n[n.length-1]?.value||(t=n[n.length-1]?.color)}return t||"#a1a1a1"}async function addMarker(e){const t={basic:"#a1a1a1",border:"#999",rgb:[161,161,161]};e.isEmpty||(t.basic="color-mix(in srgb, "+markercolor(e.value)+" 70%, transparent)",t.border="color-mix(in srgb, "+t.basic+", #000 10%)");const r=await findMarker(e.sensor_id);if(r)e.isEmpty||updateMarker(r,e,t);else{const n=createMarker(e,t);n.on("click",handlerClickMarker),markersLayer?markersLayer.addLayer(n):console.log("Not found markersLayer")}}const paths={};async function addPointPath(e){const t=e.isEmpty?"#bb4506":getColor(scale,e.value),r=[e.geo.lat,e.geo.lng],n=paths[e.sensor_id]||null;if(n){const o=n.getLatLngs();if(o[o.length-1].lat===Number(r[0])&&o[o.length-1].lng===Number(r[1]))return;o.length===1?n.arrowheads({yawn:30,fill:!0,frequency:"allvertices",size:"15px"}).setStyle({color:t}).addLatLng(r):n.setStyle({color:t}).addLatLng(r)}else{const o=L$2.polyline([r],{color:t,weight:2,opacity:.8,data:e});paths[e.sensor_id]=o}}async function showPath(e){const t=paths[e]||null;t&&pathsLayer&&pathsLayer.addLayer(t)}async function hidePath(e){const t=paths[e]||null;t&&pathsLayer&&pathsLayer.hasLayer(t)&&pathsLayer.removeLayer(t)}async function addMarkerUser(e){const t={basic:"#f99981",border:"#999",rgb:[161,161,161]};if(!await findMarker(e.sensor_id)){const n=createMarker(e,t);n.on("click",handlerClickMarker),messageTypes[e.data.type]&&messagesLayers[messageTypes[e.data.type]]&&messagesLayers[messageTypes[e.data.type]].addLayer(n)}}function clear(){if(markersLayer){markersLayer.clearLayers();const e=new BroadcastChannel("sensorsremoved");e.postMessage(!0),e.close()}pathsLayer&&pathsLayer.clearLayers();for(const e of Object.values(messagesLayers))e&&e.clearLayers()}function switchMessagesLayer(e,t=!1){for(const r of Object.values(messagesLayers))r&&(t?e.addLayer(r):e.removeLayer(r))}function bind$1(e,t){return function(){return e.apply(t,arguments)}}const{toString:toString$7}=Object.prototype,{getPrototypeOf}=Object,kindOf=(e=>t=>{const r=toString$7.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),kindOfTest=e=>(e=e.toLowerCase(),t=>kindOf(t)===e),typeOfTest=e=>t=>typeof t===e,{isArray:isArray$3}=Array,isUndefined=typeOfTest("undefined");function isBuffer$1(e){return e!==null&&!isUndefined(e)&&e.constructor!==null&&!isUndefined(e.constructor)&&isFunction$1(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const isArrayBuffer$1=kindOfTest("ArrayBuffer");function isArrayBufferView(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&isArrayBuffer$1(e.buffer),t}const isString$1=typeOfTest("string"),isFunction$1=typeOfTest("function"),isNumber$1=typeOfTest("number"),isObject$1=e=>e!==null&&typeof e=="object",isBoolean$1=e=>e===!0||e===!1,isPlainObject$2=e=>{if(kindOf(e)!=="object")return!1;const t=getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)},isDate$1=kindOfTest("Date"),isFile=kindOfTest("File"),isBlob=kindOfTest("Blob"),isFileList=kindOfTest("FileList"),isStream=e=>isObject$1(e)&&isFunction$1(e.pipe),isFormData=e=>{const t="[object FormData]";return e&&(typeof FormData=="function"&&e instanceof FormData||toString$7.call(e)===t||isFunction$1(e.toString)&&e.toString()===t)},isURLSearchParams=kindOfTest("URLSearchParams"),trim=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function forEach(e,t,{allOwnKeys:r=!1}={}){if(e===null||typeof e>"u")return;let n,o;if(typeof e!="object"&&(e=[e]),isArray$3(e))for(n=0,o=e.length;n{isPlainObject$2(e[n])&&isPlainObject$2(r)?e[n]=merge$2(e[n],r):isPlainObject$2(r)?e[n]=merge$2({},r):isArray$3(r)?e[n]=r.slice():e[n]=r};for(let r=0,n=arguments.length;r(forEach(t,(o,a)=>{r&&isFunction$1(o)?e[a]=bind$1(o,r):e[a]=o},{allOwnKeys:n}),e),stripBOM=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),inherits=(e,t,r,n)=>{e.prototype=Object.create(t.prototype,n),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),r&&Object.assign(e.prototype,r)},toFlatObject=(e,t,r,n)=>{let o,a,l;const c={};if(t=t||{},e==null)return t;do{for(o=Object.getOwnPropertyNames(e),a=o.length;a-- >0;)l=o[a],(!n||n(l,e,t))&&!c[l]&&(t[l]=e[l],c[l]=!0);e=r!==!1&&getPrototypeOf(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},endsWith=(e,t,r)=>{e=String(e),(r===void 0||r>e.length)&&(r=e.length),r-=t.length;const n=e.indexOf(t,r);return n!==-1&&n===r},toArray$2=e=>{if(!e)return null;if(isArray$3(e))return e;let t=e.length;if(!isNumber$1(t))return null;const r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},isTypedArray=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&getPrototypeOf(Uint8Array)),forEachEntry=(e,t)=>{const n=(e&&e[Symbol.iterator]).call(e);let o;for(;(o=n.next())&&!o.done;){const a=o.value;t.call(e,a[0],a[1])}},matchAll=(e,t)=>{let r;const n=[];for(;(r=e.exec(t))!==null;)n.push(r);return n},isHTMLForm=kindOfTest("HTMLFormElement"),toCamelCase=e=>e.toLowerCase().replace(/[_-\s]([a-z\d])(\w*)/g,function(r,n,o){return n.toUpperCase()+o}),hasOwnProperty$2=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),isRegExp$1=kindOfTest("RegExp"),reduceDescriptors=(e,t)=>{const r=Object.getOwnPropertyDescriptors(e),n={};forEach(r,(o,a)=>{t(o,a,e)!==!1&&(n[a]=o)}),Object.defineProperties(e,n)},freezeMethods=e=>{reduceDescriptors(e,(t,r)=>{const n=e[r];if(!!isFunction$1(n)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not read-only method '"+r+"'")})}})},toObjectSet=(e,t)=>{const r={},n=o=>{o.forEach(a=>{r[a]=!0})};return isArray$3(e)?n(e):n(String(e).split(t)),r},noop$5=()=>{},toFiniteNumber=(e,t)=>(e=+e,Number.isFinite(e)?e:t),utils={isArray:isArray$3,isArrayBuffer:isArrayBuffer$1,isBuffer:isBuffer$1,isFormData,isArrayBufferView,isString:isString$1,isNumber:isNumber$1,isBoolean:isBoolean$1,isObject:isObject$1,isPlainObject:isPlainObject$2,isUndefined,isDate:isDate$1,isFile,isBlob,isRegExp:isRegExp$1,isFunction:isFunction$1,isStream,isURLSearchParams,isTypedArray,isFileList,forEach,merge:merge$2,extend,trim,stripBOM,inherits,toFlatObject,kindOf,kindOfTest,endsWith,toArray:toArray$2,forEachEntry,matchAll,isHTMLForm,hasOwnProperty:hasOwnProperty$2,hasOwnProp:hasOwnProperty$2,reduceDescriptors,freezeMethods,toObjectSet,toCamelCase,noop:noop$5,toFiniteNumber};function AxiosError(e,t,r,n,o){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),r&&(this.config=r),n&&(this.request=n),o&&(this.response=o)}utils.inherits(AxiosError,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code,status:this.response&&this.response.status?this.response.status:null}}});const prototype$1=AxiosError.prototype,descriptors={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(e=>{descriptors[e]={value:e}});Object.defineProperties(AxiosError,descriptors);Object.defineProperty(prototype$1,"isAxiosError",{value:!0});AxiosError.from=(e,t,r,n,o,a)=>{const l=Object.create(prototype$1);return utils.toFlatObject(e,l,function(u){return u!==Error.prototype},c=>c!=="isAxiosError"),AxiosError.call(l,e.message,t,r,n,o),l.cause=e,l.name=e.name,a&&Object.assign(l,a),l};var browser$8=typeof self=="object"?self.FormData:window.FormData;function isVisitable(e){return utils.isPlainObject(e)||utils.isArray(e)}function removeBrackets(e){return utils.endsWith(e,"[]")?e.slice(0,-2):e}function renderKey(e,t,r){return e?e.concat(t).map(function(o,a){return o=removeBrackets(o),!r&&a?"["+o+"]":o}).join(r?".":""):t}function isFlatArray(e){return utils.isArray(e)&&!e.some(isVisitable)}const predicates=utils.toFlatObject(utils,{},null,function(t){return/^is[A-Z]/.test(t)});function isSpecCompliant(e){return e&&utils.isFunction(e.append)&&e[Symbol.toStringTag]==="FormData"&&e[Symbol.iterator]}function toFormData(e,t,r){if(!utils.isObject(e))throw new TypeError("target must be an object");t=t||new(browser$8||FormData),r=utils.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(T,D){return!utils.isUndefined(D[T])});const n=r.metaTokens,o=r.visitor||_,a=r.dots,l=r.indexes,u=(r.Blob||typeof Blob<"u"&&Blob)&&isSpecCompliant(t);if(!utils.isFunction(o))throw new TypeError("visitor must be a function");function g(E){if(E===null)return"";if(utils.isDate(E))return E.toISOString();if(!u&&utils.isBlob(E))throw new AxiosError("Blob is not supported. Use a Buffer instead.");return utils.isArrayBuffer(E)||utils.isTypedArray(E)?u&&typeof Blob=="function"?new Blob([E]):Buffer.from(E):E}function _(E,T,D){let $=E;if(E&&!D&&typeof E=="object"){if(utils.endsWith(T,"{}"))T=n?T:T.slice(0,-2),E=JSON.stringify(E);else if(utils.isArray(E)&&isFlatArray(E)||utils.isFileList(E)||utils.endsWith(T,"[]")&&($=utils.toArray(E)))return T=removeBrackets(T),$.forEach(function(H,se){!utils.isUndefined(H)&&t.append(l===!0?renderKey([T],se,a):l===null?T:T+"[]",g(H))}),!1}return isVisitable(E)?!0:(t.append(renderKey(D,T,a),g(E)),!1)}const x=[],S=Object.assign(predicates,{defaultVisitor:_,convertValue:g,isVisitable});function O(E,T){if(!utils.isUndefined(E)){if(x.indexOf(E)!==-1)throw Error("Circular reference detected in "+T.join("."));x.push(E),utils.forEach(E,function($,I){(!utils.isUndefined($)&&o.call(t,$,utils.isString(I)?I.trim():I,T,S))===!0&&O($,T?T.concat(I):[I])}),x.pop()}}if(!utils.isObject(e))throw new TypeError("data must be an object");return O(e),t}function encode$f(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(n){return t[n]})}function AxiosURLSearchParams(e,t){this._pairs=[],e&&toFormData(e,this,t)}const prototype=AxiosURLSearchParams.prototype;prototype.append=function(t,r){this._pairs.push([t,r])};prototype.toString=function(t){const r=t?function(n){return t.call(this,n,encode$f)}:encode$f;return this._pairs.map(function(o){return r(o[0])+"="+r(o[1])},"").join("&")};function encode$e(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function buildURL(e,t,r){if(!t)return e;const n=e.indexOf("#");n!==-1&&(e=e.slice(0,n));const o=r&&r.encode||encode$e,a=utils.isURLSearchParams(t)?t.toString():new AxiosURLSearchParams(t,r).toString(o);return a&&(e+=(e.indexOf("?")===-1?"?":"&")+a),e}class InterceptorManager{constructor(){this.handlers=[]}use(t,r,n){return this.handlers.push({fulfilled:t,rejected:r,synchronous:n?n.synchronous:!1,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){utils.forEach(this.handlers,function(n){n!==null&&t(n)})}}const transitionalDefaults={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},URLSearchParams$2=typeof URLSearchParams<"u"?URLSearchParams:AxiosURLSearchParams,FormData$1=FormData,isStandardBrowserEnv=(()=>{let e;return typeof navigator<"u"&&((e=navigator.product)==="ReactNative"||e==="NativeScript"||e==="NS")?!1:typeof window<"u"&&typeof document<"u"})(),platform={isBrowser:!0,classes:{URLSearchParams:URLSearchParams$2,FormData:FormData$1,Blob},isStandardBrowserEnv,protocols:["http","https","file","blob","url","data"]};function toURLEncodedForm(e,t){return toFormData(e,new platform.classes.URLSearchParams,Object.assign({visitor:function(r,n,o,a){return platform.isNode&&utils.isBuffer(r)?(this.append(n,r.toString("base64")),!1):a.defaultVisitor.apply(this,arguments)}},t))}function parsePropPath(e){return utils.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function arrayToObject(e){const t={},r=Object.keys(e);let n;const o=r.length;let a;for(n=0;n=r.length;return l=!l&&utils.isArray(o)?o.length:l,u?(utils.hasOwnProp(o,l)?o[l]=[o[l],n]:o[l]=n,!c):((!o[l]||!utils.isObject(o[l]))&&(o[l]=[]),t(r,n,o[l],a)&&utils.isArray(o[l])&&(o[l]=arrayToObject(o[l])),!c)}if(utils.isFormData(e)&&utils.isFunction(e.entries)){const r={};return utils.forEachEntry(e,(n,o)=>{t(parsePropPath(n),o,r,0)}),r}return null}function settle(e,t,r){const n=r.config.validateStatus;!r.status||!n||n(r.status)?e(r):t(new AxiosError("Request failed with status code "+r.status,[AxiosError.ERR_BAD_REQUEST,AxiosError.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r))}const cookies=platform.isStandardBrowserEnv?function(){return{write:function(r,n,o,a,l,c){const u=[];u.push(r+"="+encodeURIComponent(n)),utils.isNumber(o)&&u.push("expires="+new Date(o).toGMTString()),utils.isString(a)&&u.push("path="+a),utils.isString(l)&&u.push("domain="+l),c===!0&&u.push("secure"),document.cookie=u.join("; ")},read:function(r){const n=document.cookie.match(new RegExp("(^|;\\s*)("+r+")=([^;]*)"));return n?decodeURIComponent(n[3]):null},remove:function(r){this.write(r,"",Date.now()-864e5)}}}():function(){return{write:function(){},read:function(){return null},remove:function(){}}}();function isAbsoluteURL(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function combineURLs(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}function buildFullPath(e,t){return e&&!isAbsoluteURL(t)?combineURLs(e,t):t}const isURLSameOrigin=platform.isStandardBrowserEnv?function(){const t=/(msie|trident)/i.test(navigator.userAgent),r=document.createElement("a");let n;function o(a){let l=a;return t&&(r.setAttribute("href",l),l=r.href),r.setAttribute("href",l),{href:r.href,protocol:r.protocol?r.protocol.replace(/:$/,""):"",host:r.host,search:r.search?r.search.replace(/^\?/,""):"",hash:r.hash?r.hash.replace(/^#/,""):"",hostname:r.hostname,port:r.port,pathname:r.pathname.charAt(0)==="/"?r.pathname:"/"+r.pathname}}return n=o(window.location.href),function(l){const c=utils.isString(l)?o(l):l;return c.protocol===n.protocol&&c.host===n.host}}():function(){return function(){return!0}}();function CanceledError(e,t,r){AxiosError.call(this,e??"canceled",AxiosError.ERR_CANCELED,t,r),this.name="CanceledError"}utils.inherits(CanceledError,AxiosError,{__CANCEL__:!0});function parseProtocol(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}const ignoreDuplicateOf=utils.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),parseHeaders=e=>{const t={};let r,n,o;return e&&e.split(` +
`,iconSize:new L$2.Point(40,40)})}function iconCreateCircle(e){return new L$2.DivIcon({html:`
`,className:"marker-cluster",iconSize:new L$2.Point(40,40)})}function createMarkerBrand(e,t,r){return L$2.marker(new L$2.LatLng(e[0],e[1]),{icon:createIconBrand(t.sensor_id,r.rgb),data:t,typeMarker:"brand"})}function createMarkerArrow(e,t,r){return L$2.marker(new L$2.LatLng(e[0],e[1]),{icon:createIconArrow(t.data.windang,t.data.windspeed,r.basic),data:t,typeMarker:"arrow"})}function createMarkerCircle(e,t,r){return L$2.marker(new L$2.LatLng(e[0],e[1]),{icon:iconCreateCircle(r),data:t,typeMarker:"circle"})}function createMarkerUser(e,t){return L$2.marker(new L$2.LatLng(e[0],e[1]),{icon:createIconMsg(t.measurement?.type||0),data:t,typeMarker:"msg"})}function createMarker(e,t){const r=[e.geo.lat,e.geo.lng];let n;return sensors[e.sensor_id]&&sensors[e.sensor_id].icon?n=createMarkerBrand(r,e,t):e.data.windang?n=createMarkerArrow(r,e,t):e.model===4?n=createMarkerUser(r,e):n=createMarkerCircle(r,e,t),n}function updateMarker(e,t,r){if(e.options.typeMarker==="brand"?e.setIcon(createIconBrand(t.sensor_id,r.rgb)):e.options.typeMarker==="arrow"&&Object.prototype.hasOwnProperty.call(t.data,"windang")?e.setIcon(createIconArrow(t.data.windang,t.data.windspeed,r.basic)):e.setIcon(iconCreateCircle(r)),t.model===3){const n=[t.geo.lat,t.geo.lng];e.setLatLng(new L$2.LatLng(n[0],n[1]))}}async function addPoint(e){e.sensor_id==="ab9de1c7a82d9b193fd9f169d8af1b64ce4f7b391d9f50f9ac127a49615a9693"&&console.log("GRAY PM10",e),e.sensor_id==="3eb468d90d6640bcef0b0b792a947d05bcc4da1b11316b283dda59e79336fdaa"&&console.log("GREEN PM10",e),queue.add(t.bind(queue,e));async function t(r){try{if(r.model===1)console.log(r);else if(r.model===2){await addMarker(r);const n=new BroadcastChannel("sensors");n.postMessage(r),n.close()}else r.model===3?(await addMarker(r),await addPointPath(r)):r.model===4&&await addMarkerUser(r)}catch(n){console.log(n)}this.next()}}function markercolor(e){let t=null;const r=localStorage.getItem("currentUnit")??null,n=measurements[r].zones;if(r){const o=n.find(a=>e<=a?.value);o?t=o?.color:n[n.length-1]?.value||(t=n[n.length-1]?.color)}return t||"#a1a1a1"}async function addMarker(e){const t={basic:"#a1a1a1",border:"#999",rgb:[161,161,161]};e.isEmpty||(t.basic="color-mix(in srgb, "+markercolor(e.value)+" 70%, transparent)",t.border="color-mix(in srgb, "+t.basic+", #000 10%)");const r=await findMarker(e.sensor_id);if(r)e.isEmpty||updateMarker(r,e,t);else{const n=createMarker(e,t);n.on("click",handlerClickMarker),markersLayer?markersLayer.addLayer(n):console.log("Not found markersLayer")}}const paths={};async function addPointPath(e){const t=e.isEmpty?"#bb4506":getColor(scale,e.value),r=[e.geo.lat,e.geo.lng],n=paths[e.sensor_id]||null;if(n){const o=n.getLatLngs();if(o[o.length-1].lat===Number(r[0])&&o[o.length-1].lng===Number(r[1]))return;o.length===1?n.arrowheads({yawn:30,fill:!0,frequency:"allvertices",size:"15px"}).setStyle({color:t}).addLatLng(r):n.setStyle({color:t}).addLatLng(r)}else{const o=L$2.polyline([r],{color:t,weight:2,opacity:.8,data:e});paths[e.sensor_id]=o}}async function showPath(e){const t=paths[e]||null;t&&pathsLayer&&pathsLayer.addLayer(t)}async function hidePath(e){const t=paths[e]||null;t&&pathsLayer&&pathsLayer.hasLayer(t)&&pathsLayer.removeLayer(t)}async function addMarkerUser(e){const t={basic:"#f99981",border:"#999",rgb:[161,161,161]};if(!await findMarker(e.sensor_id)){const n=createMarker(e,t);n.on("click",handlerClickMarker),e.measurement&&messageTypes[e.measurement.type]&&messagesLayers[messageTypes[e.measurement.type]]&&messagesLayers[messageTypes[e.measurement.type]].addLayer(n)}}function clear(){if(markersLayer){markersLayer.clearLayers();const e=new BroadcastChannel("sensorsremoved");e.postMessage(!0),e.close()}pathsLayer&&pathsLayer.clearLayers();for(const e of Object.values(messagesLayers))e&&e.clearLayers()}function switchMessagesLayer(e,t=!1){for(const r of Object.values(messagesLayers))r&&(t?e.addLayer(r):e.removeLayer(r))}function bind$1(e,t){return function(){return e.apply(t,arguments)}}const{toString:toString$7}=Object.prototype,{getPrototypeOf}=Object,kindOf=(e=>t=>{const r=toString$7.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),kindOfTest=e=>(e=e.toLowerCase(),t=>kindOf(t)===e),typeOfTest=e=>t=>typeof t===e,{isArray:isArray$3}=Array,isUndefined=typeOfTest("undefined");function isBuffer$1(e){return e!==null&&!isUndefined(e)&&e.constructor!==null&&!isUndefined(e.constructor)&&isFunction$1(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const isArrayBuffer$1=kindOfTest("ArrayBuffer");function isArrayBufferView(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&isArrayBuffer$1(e.buffer),t}const isString$1=typeOfTest("string"),isFunction$1=typeOfTest("function"),isNumber$1=typeOfTest("number"),isObject$1=e=>e!==null&&typeof e=="object",isBoolean$1=e=>e===!0||e===!1,isPlainObject$2=e=>{if(kindOf(e)!=="object")return!1;const t=getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)},isDate$1=kindOfTest("Date"),isFile=kindOfTest("File"),isBlob=kindOfTest("Blob"),isFileList=kindOfTest("FileList"),isStream=e=>isObject$1(e)&&isFunction$1(e.pipe),isFormData=e=>{const t="[object FormData]";return e&&(typeof FormData=="function"&&e instanceof FormData||toString$7.call(e)===t||isFunction$1(e.toString)&&e.toString()===t)},isURLSearchParams=kindOfTest("URLSearchParams"),trim=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function forEach(e,t,{allOwnKeys:r=!1}={}){if(e===null||typeof e>"u")return;let n,o;if(typeof e!="object"&&(e=[e]),isArray$3(e))for(n=0,o=e.length;n{isPlainObject$2(e[n])&&isPlainObject$2(r)?e[n]=merge$2(e[n],r):isPlainObject$2(r)?e[n]=merge$2({},r):isArray$3(r)?e[n]=r.slice():e[n]=r};for(let r=0,n=arguments.length;r(forEach(t,(o,a)=>{r&&isFunction$1(o)?e[a]=bind$1(o,r):e[a]=o},{allOwnKeys:n}),e),stripBOM=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),inherits=(e,t,r,n)=>{e.prototype=Object.create(t.prototype,n),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),r&&Object.assign(e.prototype,r)},toFlatObject=(e,t,r,n)=>{let o,a,l;const c={};if(t=t||{},e==null)return t;do{for(o=Object.getOwnPropertyNames(e),a=o.length;a-- >0;)l=o[a],(!n||n(l,e,t))&&!c[l]&&(t[l]=e[l],c[l]=!0);e=r!==!1&&getPrototypeOf(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},endsWith=(e,t,r)=>{e=String(e),(r===void 0||r>e.length)&&(r=e.length),r-=t.length;const n=e.indexOf(t,r);return n!==-1&&n===r},toArray$2=e=>{if(!e)return null;if(isArray$3(e))return e;let t=e.length;if(!isNumber$1(t))return null;const r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},isTypedArray=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&getPrototypeOf(Uint8Array)),forEachEntry=(e,t)=>{const n=(e&&e[Symbol.iterator]).call(e);let o;for(;(o=n.next())&&!o.done;){const a=o.value;t.call(e,a[0],a[1])}},matchAll=(e,t)=>{let r;const n=[];for(;(r=e.exec(t))!==null;)n.push(r);return n},isHTMLForm=kindOfTest("HTMLFormElement"),toCamelCase=e=>e.toLowerCase().replace(/[_-\s]([a-z\d])(\w*)/g,function(r,n,o){return n.toUpperCase()+o}),hasOwnProperty$2=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),isRegExp$1=kindOfTest("RegExp"),reduceDescriptors=(e,t)=>{const r=Object.getOwnPropertyDescriptors(e),n={};forEach(r,(o,a)=>{t(o,a,e)!==!1&&(n[a]=o)}),Object.defineProperties(e,n)},freezeMethods=e=>{reduceDescriptors(e,(t,r)=>{const n=e[r];if(!!isFunction$1(n)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not read-only method '"+r+"'")})}})},toObjectSet=(e,t)=>{const r={},n=o=>{o.forEach(a=>{r[a]=!0})};return isArray$3(e)?n(e):n(String(e).split(t)),r},noop$5=()=>{},toFiniteNumber=(e,t)=>(e=+e,Number.isFinite(e)?e:t),utils={isArray:isArray$3,isArrayBuffer:isArrayBuffer$1,isBuffer:isBuffer$1,isFormData,isArrayBufferView,isString:isString$1,isNumber:isNumber$1,isBoolean:isBoolean$1,isObject:isObject$1,isPlainObject:isPlainObject$2,isUndefined,isDate:isDate$1,isFile,isBlob,isRegExp:isRegExp$1,isFunction:isFunction$1,isStream,isURLSearchParams,isTypedArray,isFileList,forEach,merge:merge$2,extend,trim,stripBOM,inherits,toFlatObject,kindOf,kindOfTest,endsWith,toArray:toArray$2,forEachEntry,matchAll,isHTMLForm,hasOwnProperty:hasOwnProperty$2,hasOwnProp:hasOwnProperty$2,reduceDescriptors,freezeMethods,toObjectSet,toCamelCase,noop:noop$5,toFiniteNumber};function AxiosError(e,t,r,n,o){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),r&&(this.config=r),n&&(this.request=n),o&&(this.response=o)}utils.inherits(AxiosError,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code,status:this.response&&this.response.status?this.response.status:null}}});const prototype$1=AxiosError.prototype,descriptors={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(e=>{descriptors[e]={value:e}});Object.defineProperties(AxiosError,descriptors);Object.defineProperty(prototype$1,"isAxiosError",{value:!0});AxiosError.from=(e,t,r,n,o,a)=>{const l=Object.create(prototype$1);return utils.toFlatObject(e,l,function(u){return u!==Error.prototype},c=>c!=="isAxiosError"),AxiosError.call(l,e.message,t,r,n,o),l.cause=e,l.name=e.name,a&&Object.assign(l,a),l};var browser$8=typeof self=="object"?self.FormData:window.FormData;function isVisitable(e){return utils.isPlainObject(e)||utils.isArray(e)}function removeBrackets(e){return utils.endsWith(e,"[]")?e.slice(0,-2):e}function renderKey(e,t,r){return e?e.concat(t).map(function(o,a){return o=removeBrackets(o),!r&&a?"["+o+"]":o}).join(r?".":""):t}function isFlatArray(e){return utils.isArray(e)&&!e.some(isVisitable)}const predicates=utils.toFlatObject(utils,{},null,function(t){return/^is[A-Z]/.test(t)});function isSpecCompliant(e){return e&&utils.isFunction(e.append)&&e[Symbol.toStringTag]==="FormData"&&e[Symbol.iterator]}function toFormData(e,t,r){if(!utils.isObject(e))throw new TypeError("target must be an object");t=t||new(browser$8||FormData),r=utils.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(T,D){return!utils.isUndefined(D[T])});const n=r.metaTokens,o=r.visitor||_,a=r.dots,l=r.indexes,u=(r.Blob||typeof Blob<"u"&&Blob)&&isSpecCompliant(t);if(!utils.isFunction(o))throw new TypeError("visitor must be a function");function g(E){if(E===null)return"";if(utils.isDate(E))return E.toISOString();if(!u&&utils.isBlob(E))throw new AxiosError("Blob is not supported. Use a Buffer instead.");return utils.isArrayBuffer(E)||utils.isTypedArray(E)?u&&typeof Blob=="function"?new Blob([E]):Buffer.from(E):E}function _(E,T,D){let $=E;if(E&&!D&&typeof E=="object"){if(utils.endsWith(T,"{}"))T=n?T:T.slice(0,-2),E=JSON.stringify(E);else if(utils.isArray(E)&&isFlatArray(E)||utils.isFileList(E)||utils.endsWith(T,"[]")&&($=utils.toArray(E)))return T=removeBrackets(T),$.forEach(function(H,se){!utils.isUndefined(H)&&t.append(l===!0?renderKey([T],se,a):l===null?T:T+"[]",g(H))}),!1}return isVisitable(E)?!0:(t.append(renderKey(D,T,a),g(E)),!1)}const x=[],S=Object.assign(predicates,{defaultVisitor:_,convertValue:g,isVisitable});function O(E,T){if(!utils.isUndefined(E)){if(x.indexOf(E)!==-1)throw Error("Circular reference detected in "+T.join("."));x.push(E),utils.forEach(E,function($,I){(!utils.isUndefined($)&&o.call(t,$,utils.isString(I)?I.trim():I,T,S))===!0&&O($,T?T.concat(I):[I])}),x.pop()}}if(!utils.isObject(e))throw new TypeError("data must be an object");return O(e),t}function encode$f(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(n){return t[n]})}function AxiosURLSearchParams(e,t){this._pairs=[],e&&toFormData(e,this,t)}const prototype=AxiosURLSearchParams.prototype;prototype.append=function(t,r){this._pairs.push([t,r])};prototype.toString=function(t){const r=t?function(n){return t.call(this,n,encode$f)}:encode$f;return this._pairs.map(function(o){return r(o[0])+"="+r(o[1])},"").join("&")};function encode$e(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function buildURL(e,t,r){if(!t)return e;const n=e.indexOf("#");n!==-1&&(e=e.slice(0,n));const o=r&&r.encode||encode$e,a=utils.isURLSearchParams(t)?t.toString():new AxiosURLSearchParams(t,r).toString(o);return a&&(e+=(e.indexOf("?")===-1?"?":"&")+a),e}class InterceptorManager{constructor(){this.handlers=[]}use(t,r,n){return this.handlers.push({fulfilled:t,rejected:r,synchronous:n?n.synchronous:!1,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){utils.forEach(this.handlers,function(n){n!==null&&t(n)})}}const transitionalDefaults={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},URLSearchParams$2=typeof URLSearchParams<"u"?URLSearchParams:AxiosURLSearchParams,FormData$1=FormData,isStandardBrowserEnv=(()=>{let e;return typeof navigator<"u"&&((e=navigator.product)==="ReactNative"||e==="NativeScript"||e==="NS")?!1:typeof window<"u"&&typeof document<"u"})(),platform={isBrowser:!0,classes:{URLSearchParams:URLSearchParams$2,FormData:FormData$1,Blob},isStandardBrowserEnv,protocols:["http","https","file","blob","url","data"]};function toURLEncodedForm(e,t){return toFormData(e,new platform.classes.URLSearchParams,Object.assign({visitor:function(r,n,o,a){return platform.isNode&&utils.isBuffer(r)?(this.append(n,r.toString("base64")),!1):a.defaultVisitor.apply(this,arguments)}},t))}function parsePropPath(e){return utils.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function arrayToObject(e){const t={},r=Object.keys(e);let n;const o=r.length;let a;for(n=0;n=r.length;return l=!l&&utils.isArray(o)?o.length:l,u?(utils.hasOwnProp(o,l)?o[l]=[o[l],n]:o[l]=n,!c):((!o[l]||!utils.isObject(o[l]))&&(o[l]=[]),t(r,n,o[l],a)&&utils.isArray(o[l])&&(o[l]=arrayToObject(o[l])),!c)}if(utils.isFormData(e)&&utils.isFunction(e.entries)){const r={};return utils.forEachEntry(e,(n,o)=>{t(parsePropPath(n),o,r,0)}),r}return null}function settle(e,t,r){const n=r.config.validateStatus;!r.status||!n||n(r.status)?e(r):t(new AxiosError("Request failed with status code "+r.status,[AxiosError.ERR_BAD_REQUEST,AxiosError.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r))}const cookies=platform.isStandardBrowserEnv?function(){return{write:function(r,n,o,a,l,c){const u=[];u.push(r+"="+encodeURIComponent(n)),utils.isNumber(o)&&u.push("expires="+new Date(o).toGMTString()),utils.isString(a)&&u.push("path="+a),utils.isString(l)&&u.push("domain="+l),c===!0&&u.push("secure"),document.cookie=u.join("; ")},read:function(r){const n=document.cookie.match(new RegExp("(^|;\\s*)("+r+")=([^;]*)"));return n?decodeURIComponent(n[3]):null},remove:function(r){this.write(r,"",Date.now()-864e5)}}}():function(){return{write:function(){},read:function(){return null},remove:function(){}}}();function isAbsoluteURL(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function combineURLs(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}function buildFullPath(e,t){return e&&!isAbsoluteURL(t)?combineURLs(e,t):t}const isURLSameOrigin=platform.isStandardBrowserEnv?function(){const t=/(msie|trident)/i.test(navigator.userAgent),r=document.createElement("a");let n;function o(a){let l=a;return t&&(r.setAttribute("href",l),l=r.href),r.setAttribute("href",l),{href:r.href,protocol:r.protocol?r.protocol.replace(/:$/,""):"",host:r.host,search:r.search?r.search.replace(/^\?/,""):"",hash:r.hash?r.hash.replace(/^#/,""):"",hostname:r.hostname,port:r.port,pathname:r.pathname.charAt(0)==="/"?r.pathname:"/"+r.pathname}}return n=o(window.location.href),function(l){const c=utils.isString(l)?o(l):l;return c.protocol===n.protocol&&c.host===n.host}}():function(){return function(){return!0}}();function CanceledError(e,t,r){AxiosError.call(this,e??"canceled",AxiosError.ERR_CANCELED,t,r),this.name="CanceledError"}utils.inherits(CanceledError,AxiosError,{__CANCEL__:!0});function parseProtocol(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}const ignoreDuplicateOf=utils.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),parseHeaders=e=>{const t={};let r,n,o;return e&&e.split(` `).forEach(function(l){o=l.indexOf(":"),r=l.substring(0,o).trim().toLowerCase(),n=l.substring(o+1).trim(),!(!r||t[r]&&ignoreDuplicateOf[r])&&(r==="set-cookie"?t[r]?t[r].push(n):t[r]=[n]:t[r]=t[r]?t[r]+", "+n:n)}),t},$internals=Symbol("internals"),$defaults=Symbol("defaults");function normalizeHeader(e){return e&&String(e).trim().toLowerCase()}function normalizeValue(e){return e===!1||e==null?e:String(e)}function parseTokens(e){const t=Object.create(null),r=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let n;for(;n=r.exec(e);)t[n[1]]=n[2];return t}function matchHeaderValue(e,t,r,n){if(utils.isFunction(n))return n.call(this,t,r);if(!!utils.isString(t)){if(utils.isString(n))return t.indexOf(n)!==-1;if(utils.isRegExp(n))return n.test(t)}}function formatHeader(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,r,n)=>r.toUpperCase()+n)}function buildAccessors(e,t){const r=utils.toCamelCase(" "+t);["get","set","has"].forEach(n=>{Object.defineProperty(e,n+r,{value:function(o,a,l){return this[n].call(this,t,o,a,l)},configurable:!0})})}function findKey(e,t){t=t.toLowerCase();const r=Object.keys(e);let n=r.length,o;for(;n-- >0;)if(o=r[n],t===o.toLowerCase())return o;return null}function AxiosHeaders(e,t){e&&this.set(e),this[$defaults]=t||null}Object.assign(AxiosHeaders.prototype,{set:function(e,t,r){const n=this;function o(a,l,c){const u=normalizeHeader(l);if(!u)throw new Error("header name must be a non-empty string");const g=findKey(n,u);g&&c!==!0&&(n[g]===!1||c===!1)||(utils.isArray(a)?a=a.map(normalizeValue):a=normalizeValue(a),n[g||l]=a)}return utils.isPlainObject(e)?utils.forEach(e,(a,l)=>{o(a,l,t)}):o(t,e,r),this},get:function(e,t){if(e=normalizeHeader(e),!e)return;const r=findKey(this,e);if(r){const n=this[r];if(!t)return n;if(t===!0)return parseTokens(n);if(utils.isFunction(t))return t.call(this,n,r);if(utils.isRegExp(t))return t.exec(n);throw new TypeError("parser must be boolean|regexp|function")}},has:function(e,t){if(e=normalizeHeader(e),e){const r=findKey(this,e);return!!(r&&(!t||matchHeaderValue(this,this[r],r,t)))}return!1},delete:function(e,t){const r=this;let n=!1;function o(a){if(a=normalizeHeader(a),a){const l=findKey(r,a);l&&(!t||matchHeaderValue(r,r[l],l,t))&&(delete r[l],n=!0)}}return utils.isArray(e)?e.forEach(o):o(e),n},clear:function(){return Object.keys(this).forEach(this.delete.bind(this))},normalize:function(e){const t=this,r={};return utils.forEach(this,(n,o)=>{const a=findKey(r,o);if(a){t[a]=normalizeValue(n),delete t[o];return}const l=e?formatHeader(o):String(o).trim();l!==o&&delete t[o],t[l]=normalizeValue(n),r[l]=!0}),this},toJSON:function(){const e=Object.create(null);return utils.forEach(Object.assign({},this[$defaults]||null,this),(t,r)=>{t==null||t===!1||(e[r]=utils.isArray(t)?t.join(", "):t)}),e}});Object.assign(AxiosHeaders,{from:function(e){return utils.isString(e)?new this(parseHeaders(e)):e instanceof this?e:new this(e)},accessor:function(e){const r=(this[$internals]=this[$internals]={accessors:{}}).accessors,n=this.prototype;function o(a){const l=normalizeHeader(a);r[l]||(buildAccessors(n,a),r[l]=!0)}return utils.isArray(e)?e.forEach(o):o(e),this}});AxiosHeaders.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent"]);utils.freezeMethods(AxiosHeaders.prototype);utils.freezeMethods(AxiosHeaders);function speedometer(e,t){e=e||10;const r=new Array(e),n=new Array(e);let o=0,a=0,l;return t=t!==void 0?t:1e3,function(u){const g=Date.now(),_=n[a];l||(l=g),r[o]=u,n[o]=g;let x=a,S=0;for(;x!==o;)S+=r[x++],x=x%e;if(o=(o+1)%e,o===a&&(a=(a+1)%e),g-l{const a=o.loaded,l=o.lengthComputable?o.total:void 0,c=a-r,u=n(c),g=a<=l;r=a;const _={loaded:a,total:l,progress:l?a/l:void 0,bytes:c,rate:u||void 0,estimated:u&&l&&g?(l-a)/u:void 0};_[t?"download":"upload"]=!0,e(_)}}function xhrAdapter(e){return new Promise(function(r,n){let o=e.data;const a=AxiosHeaders.from(e.headers).normalize(),l=e.responseType;let c;function u(){e.cancelToken&&e.cancelToken.unsubscribe(c),e.signal&&e.signal.removeEventListener("abort",c)}utils.isFormData(o)&&platform.isStandardBrowserEnv&&a.setContentType(!1);let g=new XMLHttpRequest;if(e.auth){const O=e.auth.username||"",E=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";a.set("Authorization","Basic "+btoa(O+":"+E))}const _=buildFullPath(e.baseURL,e.url);g.open(e.method.toUpperCase(),buildURL(_,e.params,e.paramsSerializer),!0),g.timeout=e.timeout;function x(){if(!g)return;const O=AxiosHeaders.from("getAllResponseHeaders"in g&&g.getAllResponseHeaders()),T={data:!l||l==="text"||l==="json"?g.responseText:g.response,status:g.status,statusText:g.statusText,headers:O,config:e,request:g};settle(function($){r($),u()},function($){n($),u()},T),g=null}if("onloadend"in g?g.onloadend=x:g.onreadystatechange=function(){!g||g.readyState!==4||g.status===0&&!(g.responseURL&&g.responseURL.indexOf("file:")===0)||setTimeout(x)},g.onabort=function(){!g||(n(new AxiosError("Request aborted",AxiosError.ECONNABORTED,e,g)),g=null)},g.onerror=function(){n(new AxiosError("Network Error",AxiosError.ERR_NETWORK,e,g)),g=null},g.ontimeout=function(){let E=e.timeout?"timeout of "+e.timeout+"ms exceeded":"timeout exceeded";const T=e.transitional||transitionalDefaults;e.timeoutErrorMessage&&(E=e.timeoutErrorMessage),n(new AxiosError(E,T.clarifyTimeoutError?AxiosError.ETIMEDOUT:AxiosError.ECONNABORTED,e,g)),g=null},platform.isStandardBrowserEnv){const O=(e.withCredentials||isURLSameOrigin(_))&&e.xsrfCookieName&&cookies.read(e.xsrfCookieName);O&&a.set(e.xsrfHeaderName,O)}o===void 0&&a.setContentType(null),"setRequestHeader"in g&&utils.forEach(a.toJSON(),function(E,T){g.setRequestHeader(T,E)}),utils.isUndefined(e.withCredentials)||(g.withCredentials=!!e.withCredentials),l&&l!=="json"&&(g.responseType=e.responseType),typeof e.onDownloadProgress=="function"&&g.addEventListener("progress",progressEventReducer(e.onDownloadProgress,!0)),typeof e.onUploadProgress=="function"&&g.upload&&g.upload.addEventListener("progress",progressEventReducer(e.onUploadProgress)),(e.cancelToken||e.signal)&&(c=O=>{!g||(n(!O||O.type?new CanceledError(null,e,g):O),g.abort(),g=null)},e.cancelToken&&e.cancelToken.subscribe(c),e.signal&&(e.signal.aborted?c():e.signal.addEventListener("abort",c)));const S=parseProtocol(_);if(S&&platform.protocols.indexOf(S)===-1){n(new AxiosError("Unsupported protocol "+S+":",AxiosError.ERR_BAD_REQUEST,e));return}g.send(o||null)})}const adapters={http:xhrAdapter,xhr:xhrAdapter},adapters$1={getAdapter:e=>{if(utils.isString(e)){const t=adapters[e];if(!e)throw Error(utils.hasOwnProp(e)?`Adapter '${e}' is not available in the build`:`Can not resolve adapter '${e}'`);return t}if(!utils.isFunction(e))throw new TypeError("adapter is not a function");return e},adapters},DEFAULT_CONTENT_TYPE={"Content-Type":"application/x-www-form-urlencoded"};function getDefaultAdapter(){let e;return typeof XMLHttpRequest<"u"?e=adapters$1.getAdapter("xhr"):typeof process<"u"&&utils.kindOf(process)==="process"&&(e=adapters$1.getAdapter("http")),e}function stringifySafely(e,t,r){if(utils.isString(e))try{return(t||JSON.parse)(e),utils.trim(e)}catch(n){if(n.name!=="SyntaxError")throw n}return(r||JSON.stringify)(e)}const defaults$1={transitional:transitionalDefaults,adapter:getDefaultAdapter(),transformRequest:[function(t,r){const n=r.getContentType()||"",o=n.indexOf("application/json")>-1,a=utils.isObject(t);if(a&&utils.isHTMLForm(t)&&(t=new FormData(t)),utils.isFormData(t))return o&&o?JSON.stringify(formDataToJSON(t)):t;if(utils.isArrayBuffer(t)||utils.isBuffer(t)||utils.isStream(t)||utils.isFile(t)||utils.isBlob(t))return t;if(utils.isArrayBufferView(t))return t.buffer;if(utils.isURLSearchParams(t))return r.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let c;if(a){if(n.indexOf("application/x-www-form-urlencoded")>-1)return toURLEncodedForm(t,this.formSerializer).toString();if((c=utils.isFileList(t))||n.indexOf("multipart/form-data")>-1){const u=this.env&&this.env.FormData;return toFormData(c?{"files[]":t}:t,u&&new u,this.formSerializer)}}return a||o?(r.setContentType("application/json",!1),stringifySafely(t)):t}],transformResponse:[function(t){const r=this.transitional||defaults$1.transitional,n=r&&r.forcedJSONParsing,o=this.responseType==="json";if(t&&utils.isString(t)&&(n&&!this.responseType||o)){const l=!(r&&r.silentJSONParsing)&&o;try{return JSON.parse(t)}catch(c){if(l)throw c.name==="SyntaxError"?AxiosError.from(c,AxiosError.ERR_BAD_RESPONSE,this,null,this.response):c}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:platform.classes.FormData,Blob:platform.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};utils.forEach(["delete","get","head"],function(t){defaults$1.headers[t]={}});utils.forEach(["post","put","patch"],function(t){defaults$1.headers[t]=utils.merge(DEFAULT_CONTENT_TYPE)});function transformData(e,t){const r=this||defaults$1,n=t||r,o=AxiosHeaders.from(n.headers);let a=n.data;return utils.forEach(e,function(c){a=c.call(r,a,o.normalize(),t?t.status:void 0)}),o.normalize(),a}function isCancel(e){return!!(e&&e.__CANCEL__)}function throwIfCancellationRequested(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new CanceledError}function dispatchRequest(e){return throwIfCancellationRequested(e),e.headers=AxiosHeaders.from(e.headers),e.data=transformData.call(e,e.transformRequest),(e.adapter||defaults$1.adapter)(e).then(function(n){return throwIfCancellationRequested(e),n.data=transformData.call(e,e.transformResponse,n),n.headers=AxiosHeaders.from(n.headers),n},function(n){return isCancel(n)||(throwIfCancellationRequested(e),n&&n.response&&(n.response.data=transformData.call(e,e.transformResponse,n.response),n.response.headers=AxiosHeaders.from(n.response.headers))),Promise.reject(n)})}function mergeConfig(e,t){t=t||{};const r={};function n(g,_){return utils.isPlainObject(g)&&utils.isPlainObject(_)?utils.merge(g,_):utils.isPlainObject(_)?utils.merge({},_):utils.isArray(_)?_.slice():_}function o(g){if(utils.isUndefined(t[g])){if(!utils.isUndefined(e[g]))return n(void 0,e[g])}else return n(e[g],t[g])}function a(g){if(!utils.isUndefined(t[g]))return n(void 0,t[g])}function l(g){if(utils.isUndefined(t[g])){if(!utils.isUndefined(e[g]))return n(void 0,e[g])}else return n(void 0,t[g])}function c(g){if(g in t)return n(e[g],t[g]);if(g in e)return n(void 0,e[g])}const u={url:a,method:a,data:a,baseURL:l,transformRequest:l,transformResponse:l,paramsSerializer:l,timeout:l,timeoutMessage:l,withCredentials:l,adapter:l,responseType:l,xsrfCookieName:l,xsrfHeaderName:l,onUploadProgress:l,onDownloadProgress:l,decompress:l,maxContentLength:l,maxBodyLength:l,beforeRedirect:l,transport:l,httpAgent:l,httpsAgent:l,cancelToken:l,socketPath:l,responseEncoding:l,validateStatus:c};return utils.forEach(Object.keys(e).concat(Object.keys(t)),function(_){const x=u[_]||o,S=x(_);utils.isUndefined(S)&&x!==c||(r[_]=S)}),r}const VERSION$2="1.1.2",validators$1={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{validators$1[e]=function(n){return typeof n===e||"a"+(t<1?"n ":" ")+e}});const deprecatedWarnings={};validators$1.transitional=function(t,r,n){function o(a,l){return"[Axios v"+VERSION$2+"] Transitional option '"+a+"'"+l+(n?". "+n:"")}return(a,l,c)=>{if(t===!1)throw new AxiosError(o(l," has been removed"+(r?" in "+r:"")),AxiosError.ERR_DEPRECATED);return r&&!deprecatedWarnings[l]&&(deprecatedWarnings[l]=!0,console.warn(o(l," has been deprecated since v"+r+" and will be removed in the near future"))),t?t(a,l,c):!0}};function assertOptions(e,t,r){if(typeof e!="object")throw new AxiosError("options must be an object",AxiosError.ERR_BAD_OPTION_VALUE);const n=Object.keys(e);let o=n.length;for(;o-- >0;){const a=n[o],l=t[a];if(l){const c=e[a],u=c===void 0||l(c,a,e);if(u!==!0)throw new AxiosError("option "+a+" must be "+u,AxiosError.ERR_BAD_OPTION_VALUE);continue}if(r!==!0)throw new AxiosError("Unknown option "+a,AxiosError.ERR_BAD_OPTION)}}const validator={assertOptions,validators:validators$1},validators=validator.validators;class Axios{constructor(t){this.defaults=t,this.interceptors={request:new InterceptorManager,response:new InterceptorManager}}request(t,r){typeof t=="string"?(r=r||{},r.url=t):r=t||{},r=mergeConfig(this.defaults,r);const n=r.transitional;n!==void 0&&validator.assertOptions(n,{silentJSONParsing:validators.transitional(validators.boolean),forcedJSONParsing:validators.transitional(validators.boolean),clarifyTimeoutError:validators.transitional(validators.boolean)},!1),r.method=(r.method||this.defaults.method||"get").toLowerCase();const o=r.headers&&utils.merge(r.headers.common,r.headers[r.method]);o&&utils.forEach(["delete","get","head","post","put","patch","common"],function(O){delete r.headers[O]}),r.headers=new AxiosHeaders(r.headers,o);const a=[];let l=!0;this.interceptors.request.forEach(function(O){typeof O.runWhen=="function"&&O.runWhen(r)===!1||(l=l&&O.synchronous,a.unshift(O.fulfilled,O.rejected))});const c=[];this.interceptors.response.forEach(function(O){c.push(O.fulfilled,O.rejected)});let u,g=0,_;if(!l){const S=[dispatchRequest.bind(this),void 0];for(S.unshift.apply(S,a),S.push.apply(S,c),_=S.length,u=Promise.resolve(r);g<_;)u=u.then(S[g++],S[g++]);return u}_=a.length;let x=r;for(g=0;g<_;){const S=a[g++],O=a[g++];try{x=S(x)}catch(E){O.call(this,E);break}}try{u=dispatchRequest.call(this,x)}catch(S){return Promise.reject(S)}for(g=0,_=c.length;g<_;)u=u.then(c[g++],c[g++]);return u}getUri(t){t=mergeConfig(this.defaults,t);const r=buildFullPath(t.baseURL,t.url);return buildURL(r,t.params,t.paramsSerializer)}}utils.forEach(["delete","get","head","options"],function(t){Axios.prototype[t]=function(r,n){return this.request(mergeConfig(n||{},{method:t,url:r,data:(n||{}).data}))}});utils.forEach(["post","put","patch"],function(t){function r(n){return function(a,l,c){return this.request(mergeConfig(c||{},{method:t,headers:n?{"Content-Type":"multipart/form-data"}:{},url:a,data:l}))}}Axios.prototype[t]=r(),Axios.prototype[t+"Form"]=r(!0)});class CancelToken{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let r;this.promise=new Promise(function(a){r=a});const n=this;this.promise.then(o=>{if(!n._listeners)return;let a=n._listeners.length;for(;a-- >0;)n._listeners[a](o);n._listeners=null}),this.promise.then=o=>{let a;const l=new Promise(c=>{n.subscribe(c),a=c}).then(o);return l.cancel=function(){n.unsubscribe(a)},l},t(function(a,l,c){n.reason||(n.reason=new CanceledError(a,l,c),r(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const r=this._listeners.indexOf(t);r!==-1&&this._listeners.splice(r,1)}static source(){let t;return{token:new CancelToken(function(o){t=o}),cancel:t}}}function spread(e){return function(r){return e.apply(null,r)}}function isAxiosError(e){return utils.isObject(e)&&e.isAxiosError===!0}function createInstance(e){const t=new Axios(e),r=bind$1(Axios.prototype.request,t);return utils.extend(r,Axios.prototype,t,{allOwnKeys:!0}),utils.extend(r,t,null,{allOwnKeys:!0}),r.create=function(o){return createInstance(mergeConfig(e,o))},r}const axios=createInstance(defaults$1);axios.Axios=Axios;axios.CanceledError=CanceledError;axios.CancelToken=CancelToken;axios.isCancel=isCancel;axios.VERSION=VERSION$2;axios.toFormData=toFormData;axios.AxiosError=AxiosError;axios.Cancel=axios.CanceledError;axios.all=function(t){return Promise.all(t)};axios.spread=spread;axios.isAxiosError=isAxiosError;axios.formToJSON=e=>formDataToJSON(utils.isHTMLForm(e)?new FormData(e):e);L.DomUtil.setTransform||(L.DomUtil.setTransform=function(e,t,r){var n=t||new L.Point(0,0);e.style[L.DomUtil.TRANSFORM]=(L.Browser.ie3d?"translate("+n.x+"px,"+n.y+"px)":"translate3d("+n.x+"px,"+n.y+"px,0)")+(r?" scale("+r+")":"")});L.CanvasLayer=(L.Layer?L.Layer:L.Class).extend({initialize:function(t){this._map=null,this._canvas=null,this._frame=null,this._delegate=null,L.setOptions(this,t)},delegate:function(t){return this._delegate=t,this},needRedraw:function(){return this._frame||(this._frame=L.Util.requestAnimFrame(this.drawLayer,this)),this},_onLayerDidResize:function(t){this._canvas.width=t.newSize.x,this._canvas.height=t.newSize.y},_onLayerDidMove:function(){var t=this._map.containerPointToLayerPoint([0,0]);L.DomUtil.setPosition(this._canvas,t),this.drawLayer()},getEvents:function(){var t={resize:this._onLayerDidResize,moveend:this._onLayerDidMove};return this._map.options.zoomAnimation&&L.Browser.any3d&&(t.zoomanim=this._animateZoom),t},onAdd:function(t){this._map=t,this._canvas=L.DomUtil.create("canvas","leaflet-layer"),this.tiles={};var r=this._map.getSize();this._canvas.width=r.x,this._canvas.height=r.y;var n=this._map.options.zoomAnimation&&L.Browser.any3d;L.DomUtil.addClass(this._canvas,"leaflet-zoom-"+(n?"animated":"hide")),this.options.pane.appendChild(this._canvas),t.on(this.getEvents(),this);var o=this._delegate||this;o.onLayerDidMount&&o.onLayerDidMount(),this.needRedraw();var a=this;setTimeout(function(){a._onLayerDidMove()},0)},onRemove:function(t){var r=this._delegate||this;r.onLayerWillUnmount&&r.onLayerWillUnmount(),this.options.pane.removeChild(this._canvas),t.off(this.getEvents(),this),this._canvas=null},addTo:function(t){return t.addLayer(this),this},drawLayer:function(){var t=this._map.getSize(),r=this._map.getBounds(),n=this._map.getZoom(),o=this._map.options.crs.project(this._map.getCenter()),a=this._map.options.crs.project(this._map.containerPointToLatLng(this._map.getSize())),l=this._delegate||this;l.onDrawLayer&&l.onDrawLayer({layer:this,canvas:this._canvas,bounds:r,size:t,zoom:n,center:o,corner:a}),this._frame=null},_setTransform:function(t,r,n){var o=r||new L.Point(0,0);t.style[L.DomUtil.TRANSFORM]=(L.Browser.ie3d?"translate("+o.x+"px,"+o.y+"px)":"translate3d("+o.x+"px,"+o.y+"px,0)")+(n?" scale("+n+")":"")},_animateZoom:function(t){var r=this._map.getZoomScale(t.zoom),n=L.Layer?this._map._latLngToNewLayerPoint(this._map.getBounds().getNorthWest(),t.zoom,t.center):this._map._getCenterOffset(t.center)._multiplyBy(-r).subtract(this._map._getMapPanePos());L.DomUtil.setTransform(this._canvas,n,r)}});L.canvasLayer=function(e){return new L.CanvasLayer(e)};L.Control.Velocity=L.Control.extend({options:{position:"bottomleft",emptyString:"Unavailable",angleConvention:"bearingCCW",showCardinal:!1,speedUnit:"m/s",directionString:"Direction",speedString:"Speed",onAdd:null,onRemove:null},onAdd:function(t){return this._container=L.DomUtil.create("div","leaflet-control-velocity"),L.DomEvent.disableClickPropagation(this._container),t.on("mousemove",this._onMouseMove,this),this._container.innerHTML=this.options.emptyString,this.options.leafletVelocity.options.onAdd&&this.options.leafletVelocity.options.onAdd(),this._container},onRemove:function(t){t.off("mousemove",this._onMouseMove,this),this.options.leafletVelocity.options.onRemove&&this.options.leafletVelocity.options.onRemove()},vectorToSpeed:function(t,r,n){var o=Math.sqrt(Math.pow(t,2)+Math.pow(r,2));return n==="k/h"?this.meterSec2kilometerHour(o):n==="kt"?this.meterSec2Knots(o):n==="mph"?this.meterSec2milesHour(o):o},vectorToDegrees:function(t,r,n){n.endsWith("CCW")&&(r=r>0?r=-r:Math.abs(r));var o=Math.sqrt(Math.pow(t,2)+Math.pow(r,2)),a=Math.atan2(t/o,r/o),l=a*180/Math.PI+180;return(n==="bearingCW"||n==="meteoCCW")&&(l+=180,l>=360&&(l-=360)),l},degreesToCardinalDirection:function(t){var r="";return t>=0&&t<11.25||t>=348.75?r="N":t>=11.25&&t<33.75?r="NNW":t>=33.75&&t<56.25?r="NW":t>=56.25&&t<78.75?r="WNW":t>=78.25&&t<101.25?r="W":t>=101.25&&t<123.75?r="WSW":t>=123.75&&t<146.25?r="SW":t>=146.25&&t<168.75?r="SSW":t>=168.75&&t<191.25?r="S":t>=191.25&&t<213.75?r="SSE":t>=213.75&&t<236.25?r="SE":t>=236.25&&t<258.75?r="ESE":t>=258.75&&t<281.25?r="E":t>=281.25&&t<303.75?r="ENE":t>=303.75&&t<326.25?r="NE":t>=326.25&&t<348.75&&(r="NNE"),r},meterSec2Knots:function(t){return t/.514},meterSec2kilometerHour:function(t){return t*3.6},meterSec2milesHour:function(t){return t*2.23694},_onMouseMove:function(t){var r=this,n=this.options.leafletVelocity._map.containerPointToLatLng(L.point(t.containerPoint.x,t.containerPoint.y)),o=this.options.leafletVelocity._windy.interpolatePoint(n.lng,n.lat),a="";if(o&&!isNaN(o[0])&&!isNaN(o[1])&&o[2]){var l=r.vectorToDegrees(o[0],o[1],this.options.angleConvention),c=this.options.showCardinal?" (".concat(r.degreesToCardinalDirection(l),") "):"";a=" ".concat(this.options.velocityType," ").concat(this.options.directionString,": ").concat(l.toFixed(2),"\xB0").concat(c,", ").concat(this.options.velocityType," ").concat(this.options.speedString,": ").concat(r.vectorToSpeed(o[0],o[1],this.options.speedUnit).toFixed(2)," ").concat(this.options.speedUnit)}else a=this.options.emptyString;r._container.innerHTML=a}});L.Map.mergeOptions({positionControl:!1});L.Map.addInitHook(function(){this.options.positionControl&&(this.positionControl=new L.Control.MousePosition,this.addControl(this.positionControl))});L.control.velocity=function(e){return new L.Control.Velocity(e)};L.VelocityLayer=(L.Layer?L.Layer:L.Class).extend({options:{displayValues:!0,displayOptions:{velocityType:"Velocity",position:"bottomleft",emptyString:"No velocity data"},maxVelocity:10,colorScale:null,data:null},_map:null,_canvasLayer:null,_windy:null,_context:null,_timer:0,_mouseControl:null,initialize:function(t){L.setOptions(this,t)},onAdd:function(t){this._paneName=this.options.paneName||"overlayPane";var r=t._panes.overlayPane;t.getPane&&(r=t.getPane(this._paneName),r||(r=t.createPane(this._paneName))),this._canvasLayer=L.canvasLayer({pane:r}).delegate(this),this._canvasLayer.addTo(t),this._map=t},onRemove:function(t){this._destroyWind()},setData:function(t){this.options.data=t,this._windy&&(this._windy.setData(t),this._clearAndRestart()),this.fire("load")},setOpacity:function(t){this._canvasLayer.setOpacity(t)},setOptions:function(t){this.options=Object.assign(this.options,t),t.hasOwnProperty("displayOptions")&&(this.options.displayOptions=Object.assign(this.options.displayOptions,t.displayOptions),this._initMouseHandler(!0)),t.hasOwnProperty("data")&&(this.options.data=t.data),this._windy&&(this._windy.setOptions(t),t.hasOwnProperty("data")&&this._windy.setData(t.data),this._clearAndRestart()),this.fire("load")},onDrawLayer:function(t,r){var n=this;if(!this._windy){this._initWindy(this);return}!this.options.data||(this._timer&&clearTimeout(n._timer),this._timer=setTimeout(function(){n._startWindy()},750))},_startWindy:function(){var t=this._map.getBounds(),r=this._map.getSize();this._windy.start([[0,0],[r.x,r.y]],r.x,r.y,[[t._southWest.lng,t._southWest.lat],[t._northEast.lng,t._northEast.lat]])},_initWindy:function(t){var r=Object.assign({canvas:t._canvasLayer._canvas,map:this._map},t.options);this._windy=new Windy(r),this._context=this._canvasLayer._canvas.getContext("2d"),this._canvasLayer._canvas.classList.add("velocity-overlay"),this.onDrawLayer(),this._map.on("dragstart",t._windy.stop),this._map.on("dragend",t._clearAndRestart),this._map.on("zoomstart",t._windy.stop),this._map.on("zoomend",t._clearAndRestart),this._map.on("resize",t._clearWind),this._initMouseHandler(!1)},_initMouseHandler:function(t){if(t&&(this._map.removeControl(this._mouseControl),this._mouseControl=!1),!this._mouseControl&&this.options.displayValues){var r=this.options.displayOptions||{};r.leafletVelocity=this,this._mouseControl=L.control.velocity(r).addTo(this._map)}},_clearAndRestart:function(){this._context&&this._context.clearRect(0,0,3e3,3e3),this._windy&&this._startWindy()},_clearWind:function(){this._windy&&this._windy.stop(),this._context&&this._context.clearRect(0,0,3e3,3e3)},_destroyWind:function(){this._timer&&clearTimeout(this._timer),this._windy&&this._windy.stop(),this._context&&this._context.clearRect(0,0,3e3,3e3),this._mouseControl&&this._map.removeControl(this._mouseControl),this._mouseControl=null,this._windy=null,this._map.removeLayer(this._canvasLayer)}});L.velocityLayer=function(e){return new L.VelocityLayer(e)};var Windy=function(t){var r=t.minVelocity||0,n=t.maxVelocity||10,o=(t.velocityScale||.005)*(Math.pow(window.devicePixelRatio,1/3)||1),a=t.particleAge||90,l=t.lineWidth||1,c=t.particleMultiplier||1/300,u=Math.pow(window.devicePixelRatio,1/3)||1.6,g=t.frameRate||15,_=1e3/g,x=.97,S=["rgb(36,104, 180)","rgb(60,157, 194)","rgb(128,205,193 )","rgb(151,218,168 )","rgb(198,231,181)","rgb(238,247,217)","rgb(255,238,159)","rgb(252,217,125)","rgb(255,182,100)","rgb(252,150,75)","rgb(250,112,52)","rgb(245,64,32)","rgb(237,45,28)","rgb(220,24,32)","rgb(180,0,35)"],O=t.colorScale||S,E=[NaN,NaN,null],T,D,$=t.data,I,H,se,ie,ne,le,me,_e=function(ae){$=ae},ge=function(ae){ae.hasOwnProperty("minVelocity")&&(r=ae.minVelocity),ae.hasOwnProperty("maxVelocity")&&(n=ae.maxVelocity),ae.hasOwnProperty("velocityScale")&&(o=(ae.velocityScale||.005)*(Math.pow(window.devicePixelRatio,1/3)||1)),ae.hasOwnProperty("particleAge")&&(a=ae.particleAge),ae.hasOwnProperty("lineWidth")&&(l=ae.lineWidth),ae.hasOwnProperty("particleMultiplier")&&(c=ae.particleMultiplier),ae.hasOwnProperty("opacity")&&(x=+ae.opacity),ae.hasOwnProperty("frameRate")&&(g=ae.frameRate),_=1e3/g},de=function(ae,ue,xe,Ae,De,ze){var je=1-ae,Ke=1-ue,Ze=je*Ke,Ge=ae*Ke,Ne=je*ue,We=ae*ue,Ye=xe[0]*Ze+Ae[0]*Ge+De[0]*Ne+ze[0]*We,Qe=xe[1]*Ze+Ae[1]*Ge+De[1]*Ne+ze[1]*We;return[Ye,Qe,Math.sqrt(Ye*Ye+Qe*Qe)]},ve=function(ae,ue){var xe=ae.data,Ae=ue.data;return{header:ae.header,data:function(ze){return[xe[ze],Ae[ze]]},interpolate:de}},pe=function(ae){var ue=null,xe=null;return ae.forEach(function(Ae){switch(Ae.header.parameterCategory+","+Ae.header.parameterNumber){case"1,2":case"2,2":ue=Ae;break;case"1,3":case"2,3":xe=Ae;break}}),ve(ue,xe)},te=function(ae,ue){var xe=!0;ae.length<2&&(xe=!1),xe||console.log("Windy Error: data must have at least two components (u,v)"),T=pe(ae);var Ae=T.header;if(Ae.hasOwnProperty("gridDefinitionTemplate")&&Ae.gridDefinitionTemplate!=0&&(xe=!1),xe||console.log("Windy Error: Only data with Latitude_Longitude coordinates is supported"),xe=!0,H=Ae.lo1,se=Ae.la1,ie=Ae.dx,ne=Ae.dy,le=Ae.nx,me=Ae.ny,Ae.hasOwnProperty("scanMode")){var De=Ae.scanMode.toString(2);De=("0"+De).slice(-8);var ze=De.split("").map(Number).map(Boolean);ze[0]&&(ie=-ie),ze[1]&&(ne=-ne),ze[2]&&(xe=!1),ze[3]&&(xe=!1),ze[4]&&(xe=!1),ze[5]&&(xe=!1),ze[6]&&(xe=!1),ze[7]&&(xe=!1),xe||console.log("Windy Error: Data with scanMode: "+Ae.scanMode+" is not supported.")}I=new Date(Ae.refTime),I.setHours(I.getHours()+Ae.forecastTime),D=[];for(var je=0,Ke=Math.floor(le*ie)>=360,Ze=0;Ze1e3){setTimeout(Ne,25);return}Ce(Ke,ue,Ae)})()},Be,Ee=function(ae,ue){function xe(Qe,Le){return O.indexFor=function(ye){return Math.max(0,Math.min(O.length-1,Math.round((ye-Qe)/(Le-Qe)*(O.length-1))))},O}var Ae=xe(r,n),De=Ae.map(function(){return[]}),ze=Math.round(ae.width*ae.height*c);oe()&&(ze*=u);for(var je="rgba(0, 0, 0, ".concat(x,")"),Ke=[],Ze=0;Zea&&(ue.randomize(Qe).age=0);var Le=Qe.x,ye=Qe.y,we=ue(Le,ye),Ve=we[2];if(Ve===null)Qe.age=a;else{var Xe=Le+we[0],nt=ye+we[1];ue(Xe,nt)[2]!==null?(Qe.xt=Xe,Qe.yt=nt,De[Ae.indexFor(Ve)].push(Qe)):(Qe.x=Xe,Qe.y=nt)}Qe.age+=1})}var Ne=t.canvas.getContext("2d");Ne.lineWidth=l,Ne.fillStyle=je,Ne.globalAlpha=.6;function We(){var Qe="lighter";Ne.globalCompositeOperation="destination-in",Ne.fillRect(ae.x,ae.y,ae.width,ae.height),Ne.globalCompositeOperation=Qe,Ne.globalAlpha=x===0?0:x*.9,De.forEach(function(Le,ye){Le.length>0&&(Ne.beginPath(),Ne.strokeStyle=Ae[ye],Le.forEach(function(we){Ne.moveTo(we.x,we.y),Ne.lineTo(we.xt,we.yt),we.x=we.xt,we.y=we.yt}),Ne.stroke())})}var Ye=Date.now();(function Qe(){Be=requestAnimationFrame(Qe);var Le=Date.now(),ye=Le-Ye;ye>_&&(Ye=Le-ye%_,Ge(),We())})()},Pe=function(ae,ue,xe,Ae){var De={south:Se(Ae[0][1]),north:Se(Ae[1][1]),east:Se(Ae[1][0]),west:Se(Ae[0][0]),width:ue,height:xe};Ie(),te($,function(ze){Re(ze,Oe(ae,ue,xe),De,function(je,Ke){Fe.field=Ke,Ee(je,Ke)})})},Ie=function(){Fe.field&&Fe.field.release(),Be&&cancelAnimationFrame(Be)},Fe={params:t,start:Pe,stop:Ie,createField:Ce,interpolatePoint:N,setData:_e,setOptions:ge};return Fe};window.cancelAnimationFrame||(window.cancelAnimationFrame=function(e){clearTimeout(e)});const leafletVelocity="";let windLayer;function init$1(){return axios.get(config$2.WIND_PROVIDER).then(e=>{windLayer=L$2.velocityLayer({displayValues:!1,data:e.data,maxVelocity:15,velocityScale:.01,colorScale:["rgb(60,157,194)","rgb(128,205,193)","rgb(250,112,52)","rgb(245,64,32)"]})})}function switchLayer(e,t=!1){windLayer&&(t?e.addLayer(windLayer):e.removeLayer(windLayer))}const _export_sfc=(e,t)=>{const r=e.__vccOpts||e;for(const[n,o]of t)r[n]=o;return r},_sfc_main$g={data(){return{start:hooks().subtract(1,"days").format("YYYY-MM-DD"),end:hooks().format("YYYY-MM-DD"),maxDate:hooks().format("YYYY-MM-DD"),cities:{},city:"",timePeriod:[{title:this.$t("history.currentDay"),value:"24hours"},{title:this.$t("history.currentMonth"),value:"currentMonth"},{title:this.$t("history.chooseDates"),value:"chooseDates"}],period:"24hours"}},computed:{startTimestamp:function(){return Number(hooks(this.start+" 00:00:00","YYYY-MM-DD HH:mm:ss").format("X"))},endTimestamp:function(){return Number(hooks(this.end+" 23:59:59","YYYY-MM-DD HH:mm:ss").format("X"))},link(){return`${config$2.REMOTE_PROVIDER}api/sensor/csv/${this.startTimestamp}/${this.endTimestamp}/${this.city}`}},watch:{period(e){e==="24hours"?(this.start=hooks().format("YYYY-MM-DD"),this.end=hooks().format("YYYY-MM-DD")):e==="currentMonth"&&(this.start=hooks().subtract(1,"month").format("YYYY-MM-DD"),this.end=hooks().format("YYYY-MM-DD"))}},async created(){try{const e=await axios.get(`${config$2.REMOTE_PROVIDER}api/sensor/cities`);this.cities=e.data.result;const t=Object.keys(this.cities),r=Object.keys(this.cities[t[0]]);this.city=this.cities[t[0]][r[0]][0]}catch(e){console.log(e.message)}}},_hoisted_1$e=["action"],_hoisted_2$b=["label"],_hoisted_3$9=["value"],_hoisted_4$6=["value"],_hoisted_5$6={key:0,class:"flexline"},_hoisted_6$6=["max"],_hoisted_7$6=["max"],_hoisted_8$6=["value"];function _sfc_render$g(e,t,r,n,o,a){return openBlock(),createElementBlock("form",{action:a.link},[createBaseVNode("section",null,[withDirectives(createBaseVNode("select",{"onUpdate:modelValue":t[0]||(t[0]=l=>o.city=l),class:"block"},[(openBlock(!0),createElementBlock(Fragment,null,renderList(Object.keys(o.cities),(l,c)=>(openBlock(),createElementBlock("optgroup",{label:l,key:c},[(openBlock(!0),createElementBlock(Fragment,null,renderList(Object.keys(o.cities[l]),(u,g)=>(openBlock(),createElementBlock(Fragment,{key:g},[(openBlock(!0),createElementBlock(Fragment,null,renderList(o.cities[l][u],(_,x)=>(openBlock(),createElementBlock("option",{value:_,key:x},toDisplayString$1(_),9,_hoisted_3$9))),128))],64))),128))],8,_hoisted_2$b))),128))],512),[[vModelSelect,o.city]])]),createBaseVNode("section",null,[withDirectives(createBaseVNode("select",{"onUpdate:modelValue":t[1]||(t[1]=l=>o.period=l),class:"block"},[(openBlock(!0),createElementBlock(Fragment,null,renderList(o.timePeriod,l=>(openBlock(),createElementBlock("option",{value:l.value,key:l.value},toDisplayString$1(l.title),9,_hoisted_4$6))),128))],512),[[vModelSelect,o.period]])]),o.period==="chooseDates"?(openBlock(),createElementBlock("section",_hoisted_5$6,[withDirectives(createBaseVNode("input",{type:"date","onUpdate:modelValue":t[2]||(t[2]=l=>o.start=l),max:o.maxDate},null,8,_hoisted_6$6),[[vModelText,o.start]]),createTextVNode(" \u2013 "),withDirectives(createBaseVNode("input",{type:"date","onUpdate:modelValue":t[3]||(t[3]=l=>o.end=l),max:o.maxDate},null,8,_hoisted_7$6),[[vModelText,o.end]])])):createCommentVNode("",!0),createBaseVNode("section",null,[createBaseVNode("input",{type:"submit",value:e.$t("history.button"),class:"block"},null,8,_hoisted_8$6)])],8,_hoisted_1$e)}const HistoryImport=_export_sfc(_sfc_main$g,[["render",_sfc_render$g]]),agents=["QmcQJV9CQ7UCHAtGw55urFS39knSVR2nocNVNv1N1BuWwG","QmYAesHYTymfXyXitPBaHLBrC3dfVrRESFd28gfnbyjo7e","QmQHzQqXe5npsyRfRFrSbjDHTKKRz1cULajerNZrJLAMsK","QmXzPWCya9xakMQY2YLdhscHHhQ7ojNhGJzuunC57FZnta","QmRohqPDqYVwttjxJrhQVtZJH9o5QFBja3NT62aAbNDVkX","QmRjxZ7ccJ5N2HgLmz5we9pezBvP7gDvx2BjDJSw6p1TCE","QmamWhrh3qqaRzbjcZ1Si9k8V2ytoJhhPDzVGyzEAtdUCc","QmZuyyMJRo5Cs4GkARbvkxrBbiP2oRUNpWc7dBmTACZg4T","12D3KooWP2yCMkb67Xj8EkDEDfzvEgMhR7kdun8MvDcvsqoUPmuD","12D3KooWRazGg1wMjjEFaaZGXseHpt3MXrU5oZS2idQZ6M4GPL4U","12D3KooWB7wQJuFyUQL1RjdkEwDQ82msxB4xsLCHHGdJLGxaqrmR","12D3KooWGQAxCSvgAbcVHXxuzaBgzie9HSUStjvnQRQBY2CTjnLU","12D3KooWKDUV8Je6EQLhKDsiQCgzQEDKBo8ukPcxYKmts47nST4D"];function getAgents(){return agents}function setTypeProvider(e){localStorage.setItem("provider_type",e)}function getTypeProvider(){return localStorage.getItem("provider_type")||config$2.DEFAUL_TYPE_PROVIDER}const _sfc_main$f={props:["current"],data(){return{type:this.current,measurements:Object.entries(measurements),store:useStore()}},computed:{locale(){return localStorage.getItem("locale")||this.$i18n.locale||"en"},availableunits(){let e=[];return this.store.sensors.forEach(t=>{Object.keys(t.data).forEach(r=>{e.push(r.toLowerCase())})}),[...new Set(e)]},availableoptions(){let e=[];return this.availableunits.forEach(t=>{measurements[t]&&e.push({name:measurements[t]?.nameshort?measurements[t].nameshort[this.locale]:measurements[t]?.label,value:t})}),e}},watch:{type:async function(){await this.$router.push({name:"main",params:{provider:getTypeProvider(),type:this.type,zoom:this.$route.params.zoom,lat:this.$route.params.lat,lng:this.$route.params.lng,sensor:this.$route.params.sensor}}),this.$router.go(0)}}},_hoisted_1$d=["value"];function _sfc_render$f(e,t,r,n,o,a){return o.store.sensors.length>0?withDirectives((openBlock(),createElementBlock("select",{key:0,"onUpdate:modelValue":t[0]||(t[0]=l=>o.type=l)},[(openBlock(!0),createElementBlock(Fragment,null,renderList(a.availableoptions,l=>(openBlock(),createElementBlock("option",{key:l.value,value:l.value},toDisplayString$1(l.name),9,_hoisted_1$d))),128))],512)),[[vModelSelect,o.type]]):createCommentVNode("",!0)}const Measures=_export_sfc(_sfc_main$f,[["render",_sfc_render$f]]),Bookmarks_vue_vue_type_style_index_0_scoped_c34104c4_lang="",_sfc_main$e={data(){return{store:useStore()}},computed:{bookmarks:function(){return this.store.idbBookmarks}},methods:{deletebookmark(e){IDBworkflow(this.store.idbBookmarkDbname,this.store.idbBookmarkVDbver,this.store.idbBookmarkVDbtable,"readwrite",t=>{t.delete(e);const r=new BroadcastChannel(this.store.idbWatcherBroadcast);r.postMessage(this.store.idbBookmarkVDbtable),r.close()})},showsensor(e){window.location.href=this.getlink(e),location.reload()},getlink(e){if(e.link&&e.geo){const t=JSON.parse(e.geo),r=localStorage.getItem("provider_type")||"remote";return window.location.origin+"/#/"+r+"/pm10/20/"+t.lat+"/"+t.lng+"/"+e.link}}}},_hoisted_1$c=["href","onClick"],_hoisted_2$a={key:0,class:"name"},_hoisted_3$8=["onClick"];function _sfc_render$e(e,t,r,n,o,a){const l=resolveComponent("font-awesome-icon");return!a.bookmarks||a.bookmarks.length<1?(openBlock(),createElementBlock(Fragment,{key:0},[createTextVNode(toDisplayString$1(e.$t("bookmarks.listempty")),1)],64)):(openBlock(!0),createElementBlock(Fragment,{key:1},renderList(a.bookmarks,c=>(openBlock(),createElementBlock("section",{key:c.id,class:"flexline"},[createBaseVNode("a",{href:a.getlink(c),onClick:withModifiers(u=>a.showsensor(c),["prevent"])},[c.customName?(openBlock(),createElementBlock("b",_hoisted_2$a,toDisplayString$1(c.customName),1)):createCommentVNode("",!0),c.address?(openBlock(),createElementBlock("b",{key:1,class:normalizeClass(c.customName?"addresssm":"adresslg")},toDisplayString$1(c.address),3)):createCommentVNode("",!0)],8,_hoisted_1$c),createBaseVNode("button",{title:"Remove this sensor",onClick:withModifiers(u=>a.deletebookmark(c.id),["prevent"])},[createVNode(l,{icon:"fa-solid fa-xmark"})],8,_hoisted_3$8)]))),128))}const Bookmarks=_export_sfc(_sfc_main$e,[["render",_sfc_render$e],["__scopeId","data-v-c34104c4"]]),Footer_vue_vue_type_style_index_0_scoped_652e2662_lang="",Footer_vue_vue_type_style_index_1_lang="",_sfc_main$d={emits:["history"],props:["currentProvider","canHistory","measuretype"],components:{HistoryImport,Measures,Bookmarks},data(){return{store:useStore(),isActive:!1,isActiveMenu:!1,isMeasuresPopupOpen:!1,realtime:this.currentProvider==="realtime",wind:!1,messages:config$2.SHOW_MESSAGES,start:hooks().format("YYYY-MM-DD"),maxDate:hooks().format("YYYY-MM-DD")}},computed:{startTimestamp:function(){return Number(hooks(this.start+" 00:00:00","YYYY-MM-DD HH:mm:ss").format("X"))},endTimestamp:function(){return Number(hooks(this.start+" 23:59:59","YYYY-MM-DD HH:mm:ss").format("X"))},bookmarks:function(){return this.store.idbBookmarks}},watch:{async realtime(e){await this.$router.push({name:"main",params:{provider:e?"realtime":"remote",type:this.$route.params.type,zoom:this.$route.params.zoom,lat:this.$route.params.lat,lng:this.$route.params.lng,sensor:this.$route.params.sensor}}),this.$router.go(0)},start(){this.getHistory()},canHistory:{handler(e){e&&this.getHistory()},immediate:!0},wind(e){switchLayer(instanceMap(),e)},messages(e){switchMessagesLayer(instanceMap(),e)}},methods:{getHistory(){this.realtime||this.$emit("history",{start:this.startTimestamp,end:this.endTimestamp})}}},_withScopeId$7=e=>(pushScopeId("data-v-652e2662"),e=e(),popScopeId(),e),_hoisted_1$b={class:"mapcontrols"},_hoisted_2$9={class:"flexline"},_hoisted_3$7={id:"bookmarks",class:"popover-bottom-left popover",popover:""},_hoisted_4$5=["max","disabled"],_hoisted_5$5={class:"flexline"},_hoisted_6$5={id:"mapsettings",class:"popover-bottom-right popover",popover:""},_hoisted_7$5=["checked"],_hoisted_8$5={for:"realtime"},_hoisted_9$5=["disabled","checked"],_hoisted_10$4={for:"wind"},_hoisted_11$2=["checked"],_hoisted_12$2={for:"messages"},_hoisted_13$2=_withScopeId$7(()=>createBaseVNode("hr",null,null,-1)),_hoisted_14$2={class:"popovercontrol",popovertarget:"mapsettings"};function _sfc_render$d(e,t,r,n,o,a){const l=resolveComponent("Bookmarks"),c=resolveComponent("font-awesome-icon"),u=resolveComponent("Measures"),g=resolveComponent("HistoryImport");return openBlock(),createElementBlock("div",_hoisted_1$b,[createBaseVNode("div",_hoisted_2$9,[createBaseVNode("div",_hoisted_3$7,[createBaseVNode("h3",null,toDisplayString$1(e.$t("bookmarks.listtitle")),1),createVNode(l)]),createBaseVNode("button",{class:normalizeClass(["popovercontrol",a.bookmarks&&a.bookmarks.length>0?"active":null]),popovertarget:"bookmarks"},[createVNode(c,{icon:"fa-solid fa-bookmark"})],2),withDirectives(createBaseVNode("input",{type:"date","onUpdate:modelValue":t[0]||(t[0]=_=>o.start=_),max:o.maxDate,disabled:r.currentProvider=="realtime"},null,8,_hoisted_4$5),[[vModelText,o.start]]),createVNode(u,{current:r.measuretype.toLowerCase()},null,8,["current"])]),createBaseVNode("div",_hoisted_5$5,[createBaseVNode("div",_hoisted_6$5,[createBaseVNode("section",null,[withDirectives(createBaseVNode("input",{id:"realtime","onUpdate:modelValue":t[1]||(t[1]=_=>o.realtime=_),type:"checkbox",checked:o.realtime},null,8,_hoisted_7$5),[[vModelCheckbox,o.realtime]]),createBaseVNode("label",_hoisted_8$5,toDisplayString$1(e.$t("provider.realtime")),1)]),createBaseVNode("section",null,[withDirectives(createBaseVNode("input",{id:"wind","onUpdate:modelValue":t[2]||(t[2]=_=>o.wind=_),type:"checkbox",disabled:!o.realtime,checked:o.wind&&o.realtime},null,8,_hoisted_9$5),[[vModelCheckbox,o.wind]]),createBaseVNode("label",_hoisted_10$4,toDisplayString$1(e.$t("layer.wind")),1)]),createBaseVNode("section",null,[withDirectives(createBaseVNode("input",{id:"messages","onUpdate:modelValue":t[3]||(t[3]=_=>o.messages=_),type:"checkbox",checked:o.messages},null,8,_hoisted_11$2),[[vModelCheckbox,o.messages]]),createBaseVNode("label",_hoisted_12$2,toDisplayString$1(e.$t("layer.messages")),1)]),_hoisted_13$2,createBaseVNode("section",null,[createBaseVNode("h3",null,toDisplayString$1(e.$t("history.title")),1),createVNode(g)])]),createBaseVNode("button",_hoisted_14$2,[createVNode(c,{icon:"fa-solid fa-gear"})]),renderSlot(e.$slots,"default",{},void 0,!0)])])}const Footer=_export_sfc(_sfc_main$d,[["render",_sfc_render$d],["__scopeId","data-v-652e2662"]]),Map_vue_vue_type_style_index_0_lang="",Map_vue_vue_type_style_index_1_scoped_88bd01ca_lang="",__default__={emits:["city","clickMarker","close"],props:["measuretype","historyready","historyhandler"],components:{Footer},data(){return{store:useStore(),locale:localStorage.getItem("locale")||this.$i18n.locale||"en",theme:window?.matchMedia("(prefers-color-scheme: light)").matches?"light":"dark",userposition:null,geoavailable:!1,geoisloading:!1,geomsg:"",geomsgopened:!1,geomsgopenedtime:5e3,geomsgopenedtimer:null,map:null}},computed:{zoom(){return this.store.mapposition.zoom},lat(){return this.store.mapposition.lat},lng(){return this.store.mapposition.lng},provider(){return getTypeProvider()}},methods:{themelistener({matches:e,media:t}){!e||(t==="(prefers-color-scheme: dark)"?this.theme="dark":t==="(prefers-color-scheme: light)"&&(this.theme="light"),setTheme(this.theme))},relocatemap(e,t,r,n="default"){console.log("relocatemap",e,t,r,n);const o={name:"main",params:{provider:getTypeProvider(),type:this.$route.params.type||"pm10",zoom:r,lat:e,lng:t,sensor:this.$route.params.sensor}};this.$router.currentRoute.value.name==="main"&&(n==="reload"?(this.$router.push(o).catch(a=>{console.warn(a)}),setview([e,t],r)):this.$router.replace(o).catch(a=>{console.warn(a)}))},closegeotip(){this.geomsg="",this.geomsgopened=!1,this.geomsgopenedtimer&&clearTimeout(this.geomsgopenedtimer)},opengeotip(e){this.closegeotip(),this.geomsg=e,this.geomsgopened=!0,this.geomsgopenedtimer=setTimeout(()=>{this.geomsg="",this.geomsgopened=!1},this.geomsgopenedtime)},getlocalmappos(){const e=localStorage.getItem("map-position")||JSON.stringify({lat:config$2.MAP.position.lat,lng:config$2.MAP.position.lng,zoom:config$2.MAP.zoom}),t=!0;localStorage.getItem("map-position")||(t=!1),this.store.setmapposition(JSON.parse(e).lat,JSON.parse(e).lng,JSON.parse(e).zoom,t)},setgeo(e=!1){return new Promise((t,r)=>{this.geoisloading=!0,"geolocation"in navigator?(this.geoavailable=!0,localStorage.getItem("map-position")&&!e?(this.getlocalmappos(),t("Geolocation is set from local data")):navigator.geolocation.getCurrentPosition(n=>{this.userposition=[n.coords.latitude,n.coords.longitude],this.store.setmapposition(this.userposition[0],this.userposition[1],20),this.userposition&&this.map&&drawuser(this.userposition,this.zoom),t("Geolocation is determined")},n=>{r(`Geolocation is not established [code - ${n.code}]`)},{enableHighAccuracy:!0,timeout:5e3,maximumAge:5*60*1e3})):(this.geoavailable=!1,r("Geolocation is not available"))})},resetgeo(){this.closegeotip(),this.setgeo(!0).then(e=>{this.relocatemap(this.lat,this.lng,this.zoom,"reload"),this.geoisloading=!1,this.opengeotip(e)}).catch(e=>{this.geoisloading=!1,this.opengeotip(e)})},async loadMap(){this.geoisloading=!1,this.map=init$3([this.lat,this.lng],this.zoom,this.theme),this.relocatemap(this.lat,this.lng,this.zoom,"reload"),this.map.on("zoomend",e=>{this.relocatemap(e.target.getCenter().lat.toFixed(4),e.target.getCenter().lng.toFixed(4),e.target.getZoom()),this.store.setmapposition(e.target.getCenter().lat.toFixed(4),e.target.getCenter().lng.toFixed(4),e.target.getZoom())}),this.map.on("moveend",e=>{setTimeout(()=>{this.relocatemap(e.target.getCenter().lat.toFixed(4),e.target.getCenter().lng.toFixed(4),e.target.getZoom()),this.store.setmapposition(e.target.getCenter().lat.toFixed(4),e.target.getCenter().lng.toFixed(4),e.target.getZoom())},50)}),init$2(toRaw(this.map),this.measuretype,e=>{this.$emit("clickMarker",e)}),this.provider==="realtime"&&await init$1(),await this.store.idbBookmarkGet()}},unmounted(){removeMap()},watch:{geoisloading(e){console.log("geoisloading changed",e)},geomsg(e){console.log("geomsg changed",e)}},async mounted(){window.matchMedia&&(window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change",this.themelistener),window.matchMedia("(prefers-color-scheme: light)").addEventListener("change",this.themelistener)),this.setgeo().then(async e=>{this.opengeotip(e),this.loadMap()}).catch(e=>{this.opengeotip(e+", setting up default position..."),this.loadMap()})}},__injectCSSVars__=()=>{useCssVars(e=>({"5262759d":e.geomsgopenedtime}))},__setup__=__default__.setup;__default__.setup=__setup__?(e,t)=>(__injectCSSVars__(),__setup__(e,t)):__injectCSSVars__;const _sfc_main$c=__default__,_hoisted_1$a=["area-label","title"];function _sfc_render$c(e,t,r,n,o,a){const l=resolveComponent("font-awesome-icon"),c=resolveComponent("Footer");return openBlock(),createElementBlock(Fragment,null,[createBaseVNode("div",{class:normalizeClass([{inactive:o.store.mapinactive},"mapcontainer"]),id:"map"},null,2),createVNode(c,{currentProvider:a.provider,canHistory:r.historyready,onHistory:r.historyhandler,measuretype:r.measuretype},{default:withCtx(()=>[o.geoavailable?(openBlock(),createElementBlock("button",{key:0,class:"popovercontrol popoovergeo",onClick:t[1]||(t[1]=withModifiers((...u)=>a.resetgeo&&a.resetgeo(...u),["prevent"])),"area-label":e.$t("showlocation"),title:o.geoisloading?e.$t("locationloading"):e.$t("showlocation")},[createVNode(l,{icon:"fa-solid fa-location-arrow",fade:o.geoisloading},null,8,["fade"]),o.geomsg!==""?(openBlock(),createElementBlock("div",{key:0,class:normalizeClass(["popoovergeo-tip",o.geomsgopened?"opened":"closed"])},[createTextVNode(toDisplayString$1(o.geomsg)+" ",1),createVNode(l,{icon:"fa-solid fa-xmark",class:"popoovergeo-tipclose",onClick:t[0]||(t[0]=withModifiers(u=>o.geomsg="",["stop"]))})],2)):createCommentVNode("",!0)],8,_hoisted_1$a)):createCommentVNode("",!0)]),_:1},8,["currentProvider","canHistory","onHistory","measuretype"])],64)}const Map$1=_export_sfc(_sfc_main$c,[["render",_sfc_render$c],["__scopeId","data-v-88bd01ca"]]),Sensor_vue_vue_type_style_index_0_scoped_1ca21f0d_lang="",_sfc_main$b={},_withScopeId$6=e=>(pushScopeId("data-v-1ca21f0d"),e=e(),popScopeId(),e),_hoisted_1$9={version:"1.1",id:"Layer_1",xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink",x:"0px",y:"0px",viewBox:"0 0 51 72.6",style:{"enable-background":"new 0 0 51 72.6"},"xml:space":"preserve"},_hoisted_2$8=_withScopeId$6(()=>createBaseVNode("g",null,[createBaseVNode("path",{d:`M29.5,63h-8.1c-1.5,0-2.6,1.2-2.6,2.6v1.2c0,1.5,1.2,2.6,2.6,2.6h1.1v0.8c0,1.3,1.1,2.4,2.4,2.4H26c1.3,0,2.4-1.1,2.4-2.4 v-0.8h1.1c1.5,0,2.6-1.2,2.6-2.6v-1.2C32.2,64.2,31,63,29.5,63z`}),createBaseVNode("path",{d:`M25.5,24.3L25.5,24.3c-1.1,0-3.1-0.9-3.1-2.1l1-20.2c0-1.1,0.9-2.1,2.1-2.1h0c1.1,0,2.1,0.9,2.1,2.1l1,20.2 C28.6,23.4,26.7,24.3,25.5,24.3z`}),createBaseVNode("path",{class:"st0",d:`M45,65.8H6.1c-3.2,0-5.8-2.6-5.8-5.8V24c0-3.2,2.6-5.8,5.8-5.8H45c3.2,0,5.8,2.6,5.8,5.8v36 @@ -175,7 +175,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho )(?:%[0-9a-zA-Z]{1,})? // %eth0 %1 `.replace(/\s*\/\/.*$/gm,"").replace(/\n/g,"").trim(),v46Exact=new RegExp(`(?:^${v4}$)|(?:^${v6}$)`),v4exact=new RegExp(`^${v4}$`),v6exact=new RegExp(`^${v6}$`),ipRegex=e=>e&&e.exact?v46Exact:new RegExp(`(?:${boundry(e)}${v4}${boundry(e)})|(?:${boundry(e)}${v6}${boundry(e)})`,"g");ipRegex.v4=e=>e&&e.exact?v4exact:new RegExp(`${boundry(e)}${v4}${boundry(e)}`,"g");ipRegex.v6=e=>e&&e.exact?v6exact:new RegExp(`${boundry(e)}${v6}${boundry(e)}`,"g");var ipaddr$1={exports:{}};(function(e){(function(t){const r="(0?\\d+|0x[a-f0-9]+)",n={fourOctet:new RegExp(`^${r}\\.${r}\\.${r}\\.${r}$`,"i"),threeOctet:new RegExp(`^${r}\\.${r}\\.${r}$`,"i"),twoOctet:new RegExp(`^${r}\\.${r}$`,"i"),longValue:new RegExp(`^${r}$`,"i")},o=new RegExp("^0[0-7]+$","i"),a=new RegExp("^0x[a-f0-9]+$","i"),l="%[0-9a-z]{1,}",c="(?:[0-9a-f]+::?)+",u={zoneIndex:new RegExp(l,"i"),native:new RegExp(`^(::)?(${c})?([0-9a-f]+)?(::)?(${l})?$`,"i"),deprecatedTransitional:new RegExp(`^(?:::)(${r}\\.${r}\\.${r}\\.${r}(${l})?)$`,"i"),transitional:new RegExp(`^((?:${c})|(?:::)(?:${c})?)${r}\\.${r}\\.${r}\\.${r}(${l})?$`,"i")};function g(E,T){if(E.indexOf("::")!==E.lastIndexOf("::"))return null;let D=0,$=-1,I=(E.match(u.zoneIndex)||[])[0],H,se;for(I&&(I=I.substring(1),E=E.replace(/%.+$/,""));($=E.indexOf(":",$+1))>=0;)D++;if(E.substr(0,2)==="::"&&D--,E.substr(-2,2)==="::"&&D--,D>T)return null;for(se=T-D,H=":";se--;)H+="0:";return E=E.replace("::",H),E[0]===":"&&(E=E.slice(1)),E[E.length-1]===":"&&(E=E.slice(0,-1)),T=function(){const ie=E.split(":"),ne=[];for(let le=0;le0;){if(H=D-$,H<0&&(H=0),E[I]>>H!==T[I]>>H)return!1;$-=D,I+=1}return!0}function x(E){if(a.test(E))return parseInt(E,16);if(E[0]==="0"&&!isNaN(parseInt(E[1],10))){if(o.test(E))return parseInt(E,8);throw new Error(`ipaddr: cannot parse ${E} as octal`)}return parseInt(E,10)}function S(E,T){for(;E.length=0;I-=1)if(H=this.octets[I],H in $){if(se=$[H],D&&se!==0)return null;se!==8&&(D=!0),T+=se}else return null;return 32-T},E.prototype.range=function(){return O.subnetMatch(this,this.SpecialRanges)},E.prototype.toByteArray=function(){return this.octets.slice(0)},E.prototype.toIPv4MappedAddress=function(){return O.IPv6.parse(`::ffff:${this.toString()}`)},E.prototype.toNormalizedString=function(){return this.toString()},E.prototype.toString=function(){return this.octets.join(".")},E}(),O.IPv4.broadcastAddressFromCIDR=function(E){try{const T=this.parseCIDR(E),D=T[0].toByteArray(),$=this.subnetMaskFromPrefixLength(T[1]).toByteArray(),I=[];let H=0;for(;H<4;)I.push(parseInt(D[H],10)|parseInt($[H],10)^255),H++;return new this(I)}catch{throw new Error("ipaddr: the address does not have IPv4 CIDR format")}},O.IPv4.isIPv4=function(E){return this.parser(E)!==null},O.IPv4.isValid=function(E){try{return new this(this.parser(E)),!0}catch{return!1}},O.IPv4.isValidFourPartDecimal=function(E){return!!(O.IPv4.isValid(E)&&E.match(/^(0|[1-9]\d*)(\.(0|[1-9]\d*)){3}$/))},O.IPv4.networkAddressFromCIDR=function(E){let T,D,$,I,H;try{for(T=this.parseCIDR(E),$=T[0].toByteArray(),H=this.subnetMaskFromPrefixLength(T[1]).toByteArray(),I=[],D=0;D<4;)I.push(parseInt($[D],10)&parseInt(H[D],10)),D++;return new this(I)}catch{throw new Error("ipaddr: the address does not have IPv4 CIDR format")}},O.IPv4.parse=function(E){const T=this.parser(E);if(T===null)throw new Error("ipaddr: string is not formatted like an IPv4 Address");return new this(T)},O.IPv4.parseCIDR=function(E){let T;if(T=E.match(/^(.+)\/(\d+)$/)){const D=parseInt(T[2]);if(D>=0&&D<=32){const $=[this.parse(T[1]),D];return Object.defineProperty($,"toString",{value:function(){return this.join("/")}}),$}}throw new Error("ipaddr: string is not formatted like an IPv4 CIDR range")},O.IPv4.parser=function(E){let T,D,$;if(T=E.match(n.fourOctet))return function(){const I=T.slice(1,6),H=[];for(let se=0;se4294967295||$<0)throw new Error("ipaddr: address outside defined range");return function(){const I=[];let H;for(H=0;H<=24;H+=8)I.push($>>H&255);return I}().reverse()}else return(T=E.match(n.twoOctet))?function(){const I=T.slice(1,4),H=[];if($=x(I[1]),$>16777215||$<0)throw new Error("ipaddr: address outside defined range");return H.push(x(I[0])),H.push($>>16&255),H.push($>>8&255),H.push($&255),H}():(T=E.match(n.threeOctet))?function(){const I=T.slice(1,5),H=[];if($=x(I[2]),$>65535||$<0)throw new Error("ipaddr: address outside defined range");return H.push(x(I[0])),H.push(x(I[1])),H.push($>>8&255),H.push($&255),H}():null},O.IPv4.subnetMaskFromPrefixLength=function(E){if(E=parseInt(E),E<0||E>32)throw new Error("ipaddr: invalid IPv4 prefix length");const T=[0,0,0,0];let D=0;const $=Math.floor(E/8);for(;D<$;)T[D]=255,D++;return $<4&&(T[$]=Math.pow(2,E%8)-1<<8-E%8),new this(T)},O.IPv6=function(){function E(T,D){let $,I;if(T.length===16)for(this.parts=[],$=0;$<=14;$+=2)this.parts.push(T[$]<<8|T[$+1]);else if(T.length===8)this.parts=T;else throw new Error("ipaddr: ipv6 part count should be 8 or 16");for($=0;$=0;se-=1)if(I=this.parts[se],I in $){if(H=$[I],D&&H!==0)return null;H!==16&&(D=!0),T+=H}else return null;return 128-T},E.prototype.range=function(){return O.subnetMatch(this,this.SpecialRanges)},E.prototype.toByteArray=function(){let T;const D=[],$=this.parts;for(let I=0;I<$.length;I++)T=$[I],D.push(T>>8),D.push(T&255);return D},E.prototype.toFixedLengthString=function(){const T=function(){const $=[];for(let I=0;I>8,D&255,$>>8,$&255])},E.prototype.toNormalizedString=function(){const T=function(){const $=[];for(let I=0;II&&($=H.index,I=H[0].length);return I<0?D:`${D.substring(0,$)}::${D.substring($+I)}`},E.prototype.toString=function(){return this.toRFC5952String()},E}(),O.IPv6.broadcastAddressFromCIDR=function(E){try{const T=this.parseCIDR(E),D=T[0].toByteArray(),$=this.subnetMaskFromPrefixLength(T[1]).toByteArray(),I=[];let H=0;for(;H<16;)I.push(parseInt(D[H],10)|parseInt($[H],10)^255),H++;return new this(I)}catch(T){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${T})`)}},O.IPv6.isIPv6=function(E){return this.parser(E)!==null},O.IPv6.isValid=function(E){if(typeof E=="string"&&E.indexOf(":")===-1)return!1;try{const T=this.parser(E);return new this(T.parts,T.zoneId),!0}catch{return!1}},O.IPv6.networkAddressFromCIDR=function(E){let T,D,$,I,H;try{for(T=this.parseCIDR(E),$=T[0].toByteArray(),H=this.subnetMaskFromPrefixLength(T[1]).toByteArray(),I=[],D=0;D<16;)I.push(parseInt($[D],10)&parseInt(H[D],10)),D++;return new this(I)}catch(se){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${se})`)}},O.IPv6.parse=function(E){const T=this.parser(E);if(T.parts===null)throw new Error("ipaddr: string is not formatted like an IPv6 Address");return new this(T.parts,T.zoneId)},O.IPv6.parseCIDR=function(E){let T,D,$;if((D=E.match(/^(.+)\/(\d+)$/))&&(T=parseInt(D[2]),T>=0&&T<=128))return $=[this.parse(D[1]),T],Object.defineProperty($,"toString",{value:function(){return this.join("/")}}),$;throw new Error("ipaddr: string is not formatted like an IPv6 CIDR range")},O.IPv6.parser=function(E){let T,D,$,I,H,se;if($=E.match(u.deprecatedTransitional))return this.parser(`::ffff:${$[1]}`);if(u.native.test(E))return g(E,8);if(($=E.match(u.transitional))&&(se=$[6]||"",T=g($[1].slice(0,-1)+se,6),T.parts)){for(H=[parseInt($[2]),parseInt($[3]),parseInt($[4]),parseInt($[5])],D=0;D128)throw new Error("ipaddr: invalid IPv6 prefix length");const T=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];let D=0;const $=Math.floor(E/8);for(;D<$;)T[D]=255,D++;return $<16&&(T[$]=Math.pow(2,E%8)-1<<8-E%8),new this(T)},O.fromByteArray=function(E){const T=E.length;if(T===4)return new O.IPv4(E);if(T===16)return new O.IPv6(E);throw new Error("ipaddr: the binary input is neither an IPv6 nor IPv4 address")},O.isValid=function(E){return O.IPv6.isValid(E)||O.IPv4.isValid(E)},O.parse=function(E){if(O.IPv6.isValid(E))return O.IPv6.parse(E);if(O.IPv4.isValid(E))return O.IPv4.parse(E);throw new Error("ipaddr: the address has neither IPv6 nor IPv4 format")},O.parseCIDR=function(E){try{return O.IPv6.parseCIDR(E)}catch{try{return O.IPv4.parseCIDR(E)}catch{throw new Error("ipaddr: the address has neither IPv6 nor IPv4 CIDR format")}}},O.process=function(E){const T=this.parse(E);return T.kind()==="ipv6"&&T.isIPv4MappedAddress()?T.toIPv4Address():T},O.subnetMatch=function(E,T,D){let $,I,H,se;D==null&&(D="unicast");for(I in T)if(Object.prototype.hasOwnProperty.call(T,I)){for(H=T[I],H[0]&&!(H[0]instanceof Array)&&(H=[H]),$=0;$new Netmask_1(e));function ipv4_check(e){for(let t of NETMASK_RANGES)if(t.contains(e))return!0;return!1}function ipv6_check(e){return/^::$/.test(e)||/^::1$/.test(e)||/^::f{4}:([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(e)||/^::f{4}:0.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(e)||/^64:ff9b::([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(e)||/^100::([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(e)||/^2001::([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(e)||/^2001:2[0-9a-fA-F]:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(e)||/^2001:db8:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(e)||/^2002:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(e)||/^f[c-d]([0-9a-fA-F]{2,2}):/i.test(e)||/^fe[8-9a-bA-B][0-9a-fA-F]:/i.test(e)||/^ff([0-9a-fA-F]{2,2}):/i.test(e)}const is_ip_private=e=>{if(is_valid(e)){const t=parse$6(e);if(t.kind()==="ipv4")return ipv4_check(t.toNormalizedString());if(t.kind()==="ipv6")return ipv6_check(e)}else if(isIP(e)&&ipRegex.v6().test(e))return ipv6_check(e)};function connectionGater(e={}){return{denyDialPeer:async()=>!1,denyDialMultiaddr:async t=>{const r=t.stringTuples();return r[0][0]===4||r[0][0]===41?Boolean(is_ip_private(`${r[0][1]}`)):!1},denyInboundConnection:async()=>!1,denyOutboundConnection:async()=>!1,denyInboundEncryptedConnection:async()=>!1,denyOutboundEncryptedConnection:async()=>!1,denyInboundUpgradedConnection:async()=>!1,denyOutboundUpgradedConnection:async()=>!1,filterMultiaddrForPeer:async()=>!0,...e}}const toParts=e=>e.toString().split("/").slice(1),func=e=>({match:t=>t.length<1?!1:e(t[0])?t.slice(1):!1,pattern:"fn"}),literal=e=>({match:t=>func(r=>r===e).match(t),pattern:e}),string=()=>({match:e=>func(t=>typeof t=="string").match(e),pattern:"{string}"}),number$1=()=>({match:e=>func(t=>!isNaN(parseInt(t))).match(e),pattern:"{number}"}),peerId=()=>({match:e=>{if(e.length<2||e[0]!=="p2p"&&e[0]!=="ipfs")return!1;if(e[1].startsWith("Q")||e[1].startsWith("1"))try{base58btc$1.decode(`z${e[1]}`)}catch{return!1}else return!1;return e.slice(2)},pattern:"/p2p/{peerid}"}),certhash=()=>({match:e=>{if(e.length<2||e[0]!=="certhash")return!1;try{base64url$1.decode(e[1])}catch{return!1}return e.slice(2)},pattern:"/certhash/{certhash}"}),optional=e=>({match:t=>{const r=e.match(t);return r===!1?t:r},pattern:`optional(${e.pattern})`}),or=(...e)=>({match:t=>{let r;for(const n of e){const o=n.match(t);o!==!1&&(r==null||o.lengtht.pattern).join(", ")})`}),and=(...e)=>({match:t=>{for(const r of e){const n=r.match(t);if(n===!1)return!1;t=n}return t},pattern:`and(${e.map(t=>t.pattern).join(", ")})`});function fmt(...e){function t(o){let a=toParts(o);for(const l of e){const c=l.match(a);if(c===!1)return!1;a=c}return a}function r(o){return t(o)!==!1}function n(o){const a=t(o);return a===!1?!1:a.length===0}return{matches:r,exactMatch:n}}const _DNS4=and(literal("dns4"),string()),_DNS6=and(literal("dns6"),string()),_DNSADDR=and(literal("dnsaddr"),string()),_DNS=and(literal("dns"),string());fmt(or(_DNS,_DNSADDR,_DNS4,_DNS6));const _IP4=and(literal("ip4"),func(isIPv4)),_IP6=and(literal("ip6"),func(isIPv6)),_IP=or(_IP4,_IP6),IP_OR_DOMAIN=or(_IP,_DNS,_DNS4,_DNS6,_DNSADDR),_TCP=and(IP_OR_DOMAIN,literal("tcp"),number$1()),_UDP=and(IP_OR_DOMAIN,literal("udp"),number$1()),TCP_OR_UDP=or(_TCP,_UDP),_QUIC=and(_UDP,literal("quic")),_QUICV1=and(_UDP,literal("quic-v1")),QUIC_V0_OR_V1=or(_QUIC,_QUICV1),_WEB=or(IP_OR_DOMAIN,_TCP,_UDP,_QUIC,_QUICV1),_WebSockets=or(and(_WEB,literal("ws"),optional(peerId()))),_WebSocketsSecure=or(and(_WEB,literal("wss"),optional(peerId())),and(_WEB,literal("tls"),literal("ws"),optional(peerId()))),_WebRTCDirect=and(TCP_OR_UDP,literal("webrtc-direct"),certhash(),optional(certhash()),optional(peerId())),_WebTransport=and(_QUICV1,literal("webtransport"),certhash(),certhash(),optional(peerId())),_P2P=or(_WebSockets,_WebSocketsSecure,and(_TCP,optional(peerId())),and(QUIC_V0_OR_V1,optional(peerId())),and(IP_OR_DOMAIN,optional(peerId())),_WebRTCDirect,_WebTransport,peerId()),_Circuit=and(_P2P,literal("p2p-circuit"),peerId()),Circuit=fmt(_Circuit);or(and(_P2P,literal("p2p-circuit"),literal("webrtc"),peerId()),and(_P2P,literal("webrtc"),optional(peerId())),literal("webrtc"));function isPrivate(e){try{const{address:t}=e.nodeAddress();return Boolean(is_ip_private(t))}catch{return!0}}function publicAddressesFirst(e,t){const r=isPrivate(e.multiaddr),n=isPrivate(t.multiaddr);return r&&!n?1:!r&&n?-1:0}function certifiedAddressesFirst(e,t){return e.isCertified&&!t.isCertified?-1:!e.isCertified&&t.isCertified?1:0}function circuitRelayAddressesLast(e,t){const r=Circuit.exactMatch(e.multiaddr),n=Circuit.exactMatch(t.multiaddr);return r&&!n?1:!r&&n?-1:0}function defaultAddressSort(e,t){const r=publicAddressesFirst(e,t);if(r!==0)return r;const n=circuitRelayAddressesLast(e,t);return n!==0?n:certifiedAddressesFirst(e,t)}var s$3=1e3,m$4=s$3*60,h$4=m$4*60,d$5=h$4*24,w$2=d$5*7,y$3=d$5*365.25,ms$3=function(e,t){t=t||{};var r=typeof e;if(r==="string"&&e.length>0)return parse$5(e);if(r==="number"&&isFinite(e))return t.long?fmtLong$3(e):fmtShort$3(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function parse$5(e){if(e=String(e),!(e.length>100)){var t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(!!t){var r=parseFloat(t[1]),n=(t[2]||"ms").toLowerCase();switch(n){case"years":case"year":case"yrs":case"yr":case"y":return r*y$3;case"weeks":case"week":case"w":return r*w$2;case"days":case"day":case"d":return r*d$5;case"hours":case"hour":case"hrs":case"hr":case"h":return r*h$4;case"minutes":case"minute":case"mins":case"min":case"m":return r*m$4;case"seconds":case"second":case"secs":case"sec":case"s":return r*s$3;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:return}}}}function fmtShort$3(e){var t=Math.abs(e);return t>=d$5?Math.round(e/d$5)+"d":t>=h$4?Math.round(e/h$4)+"h":t>=m$4?Math.round(e/m$4)+"m":t>=s$3?Math.round(e/s$3)+"s":e+"ms"}function fmtLong$3(e){var t=Math.abs(e);return t>=d$5?plural$3(e,t,d$5,"day"):t>=h$4?plural$3(e,t,h$4,"hour"):t>=m$4?plural$3(e,t,m$4,"minute"):t>=s$3?plural$3(e,t,s$3,"second"):e+" ms"}function plural$3(e,t,r,n){var o=t>=r*1.5;return Math.round(e/r)+" "+n+(o?"s":"")}var receptacle=Receptacle,toMS=ms$3,cache$1=Receptacle.prototype,counter=new Date%1e9;function getUID(){return(Math.random()*1e9>>>0)+counter++}function Receptacle(e){e=e||{},this.id=e.id||getUID(),this.max=e.max||1/0,this.items=e.items||[],this._lookup={},this.size=this.items.length,this.lastModified=new Date(e.lastModified||new Date);for(var t,r,n=this.items.length;n--;)t=this.items[n],r=new Date(t.expires)-new Date,this._lookup[t.key]=t,r>0?this.expire(t.key,r):r<=0&&this.delete(t.key)}cache$1.has=function(e){return e in this._lookup};cache$1.get=function(e){if(!this.has(e))return null;var t=this._lookup[e];return t.refresh&&this.expire(e,t.refresh),this.items.splice(this.items.indexOf(t),1),this.items.push(t),t.value};cache$1.meta=function(e){if(!this.has(e))return null;var t=this._lookup[e];return"meta"in t?t.meta:null};cache$1.set=function(e,t,r){var n=this._lookup[e],o=this._lookup[e]={key:e,value:t};return this.lastModified=new Date,n?(clearTimeout(n.timeout),this.items.splice(this.items.indexOf(n),1,o)):(this.size>=this.max&&this.delete(this.items[0].key),this.items.push(o),this.size++),r&&("ttl"in r&&this.expire(e,r.ttl),"meta"in r&&(o.meta=r.meta),r.refresh&&(o.refresh=r.ttl)),this};cache$1.delete=function(e){var t=this._lookup[e];return t?(this.lastModified=new Date,this.items.splice(this.items.indexOf(t),1),clearTimeout(t.timeout),delete this._lookup[e],this.size--,this):!1};cache$1.expire=function(e,t){var r=t||0,n=this._lookup[e];if(!n)return this;if(typeof r=="string"&&(r=toMS(t)),typeof r!="number")throw new TypeError("Expiration time must be a string or number.");return clearTimeout(n.timeout),n.timeout=setTimeout(this.delete.bind(this,n.key),r),n.expires=Number(new Date)+r,this};cache$1.clear=function(){for(var e=this.items.length;e--;)this.delete(this.items[e].key);return this};cache$1.toJSON=function(){for(var e=new Array(this.items.length),t,r=e.length;r--;)t=this.items[r],e[r]={key:t.key,meta:t.meta,value:t.value,expires:t.expires,refresh:t.refresh};return{id:this.id,max:isFinite(this.max)?this.max:void 0,lastModified:this.lastModified,items:e}};const globalFetch=globalThis.fetch,globalHeaders=globalThis.Headers;function buildResource(e,t,r){return`${e}?name=${t}&type=${r}`}async function request(e,t){return await(await globalFetch(e,{headers:new globalHeaders({accept:"application/dns-json"}),signal:t})).json()}function getCacheKey(e,t){return`${t}_${e}`}const log$m=Object.assign(debug$9("dns-over-http-resolver"),{error:debug$9("dns-over-http-resolver:error")});class Resolver{constructor(t={}){this._cache=new receptacle({max:t?.maxCache??100}),this._TXTcache=new receptacle({max:t?.maxCache??100}),this._servers=["https://cloudflare-dns.com/dns-query","https://dns.google/resolve"],this._request=t.request??request,this._abortControllers=[]}cancel(){this._abortControllers.forEach(t=>t.abort())}getServers(){return this._servers}_getShuffledServers(){const t=[...this._servers];for(let r=t.length-1;r>0;r--){const n=Math.floor(Math.random()*r),o=t[r];t[r]=t[n],t[n]=o}return t}setServers(t){this._servers=t}async resolve(t,r="A"){switch(r){case"A":return await this.resolve4(t);case"AAAA":return await this.resolve6(t);case"TXT":return await this.resolveTxt(t);default:throw new Error(`${r} is not supported`)}}async resolve4(t){const r="A",n=this._cache.get(getCacheKey(t,r));if(n!=null)return n;let o=!1;for(const a of this._getShuffledServers()){const l=new AbortController;this._abortControllers.push(l);try{const c=await this._request(buildResource(a,t,r),l.signal),u=c.Answer.map(_=>_.data),g=Math.min(...c.Answer.map(_=>_.TTL));return this._cache.set(getCacheKey(t,r),u,{ttl:g}),u}catch{l.signal.aborted&&(o=!0),log$m.error(`${a} could not resolve ${t} record ${r}`)}finally{this._abortControllers=this._abortControllers.filter(c=>c!==l)}}throw o?Object.assign(new Error("queryA ECANCELLED"),{code:"ECANCELLED"}):new Error(`Could not resolve ${t} record ${r}`)}async resolve6(t){const r="AAAA",n=this._cache.get(getCacheKey(t,r));if(n!=null)return n;let o=!1;for(const a of this._getShuffledServers()){const l=new AbortController;this._abortControllers.push(l);try{const c=await this._request(buildResource(a,t,r),l.signal),u=c.Answer.map(_=>_.data),g=Math.min(...c.Answer.map(_=>_.TTL));return this._cache.set(getCacheKey(t,r),u,{ttl:g}),u}catch{l.signal.aborted&&(o=!0),log$m.error(`${a} could not resolve ${t} record ${r}`)}finally{this._abortControllers=this._abortControllers.filter(c=>c!==l)}}throw o?Object.assign(new Error("queryAaaa ECANCELLED"),{code:"ECANCELLED"}):new Error(`Could not resolve ${t} record ${r}`)}async resolveTxt(t){const r="TXT",n=this._TXTcache.get(getCacheKey(t,r));if(n!=null)return n;let o=!1;for(const a of this._getShuffledServers()){const l=new AbortController;this._abortControllers.push(l);try{const c=await this._request(buildResource(a,t,r),l.signal),u=c.Answer.map(_=>[_.data.replace(/['"]+/g,"")]),g=Math.min(...c.Answer.map(_=>_.TTL));return this._TXTcache.set(getCacheKey(t,r),u,{ttl:g}),u}catch{l.signal.aborted&&(o=!0),log$m.error(`${a} could not resolve ${t} record ${r}`)}finally{this._abortControllers=this._abortControllers.filter(c=>c!==l)}}throw o?Object.assign(new Error("queryTxt ECANCELLED"),{code:"ECANCELLED"}):new Error(`Could not resolve ${t} record ${r}`)}clearCache(){this._cache.clear(),this._TXTcache.clear()}}const{code:dnsaddrCode}=getProtocol("dnsaddr");async function dnsaddrResolver(e,t={}){const r=new Resolver;t.signal!=null&&t.signal.addEventListener("abort",()=>{r.cancel()});const n=e.getPeerId(),[,o]=e.stringTuples().find(([c])=>c===dnsaddrCode)??[];if(o==null)throw new Error("No hostname found in multiaddr");let l=(await r.resolveTxt(`_dnsaddr.${o}`)).flat().map(c=>c.split("=")[1]).filter(Boolean);return n!=null&&(l=l.filter(c=>c.includes(n))),l}var messages$1;(function(e){e.NOT_STARTED_YET="The libp2p node is not started yet",e.DHT_DISABLED="DHT is not available",e.PUBSUB_DISABLED="PubSub is not available",e.CONN_ENCRYPTION_REQUIRED="At least one connection encryption module is required",e.ERR_TRANSPORTS_REQUIRED="At least one transport module is required",e.ERR_PROTECTOR_REQUIRED="Private network is enforced, but no protector was provided",e.NOT_FOUND="Not found"})(messages$1||(messages$1={}));var codes;(function(e){e.DHT_DISABLED="ERR_DHT_DISABLED",e.ERR_PUBSUB_DISABLED="ERR_PUBSUB_DISABLED",e.PUBSUB_NOT_STARTED="ERR_PUBSUB_NOT_STARTED",e.DHT_NOT_STARTED="ERR_DHT_NOT_STARTED",e.CONN_ENCRYPTION_REQUIRED="ERR_CONN_ENCRYPTION_REQUIRED",e.ERR_TRANSPORTS_REQUIRED="ERR_TRANSPORTS_REQUIRED",e.ERR_PROTECTOR_REQUIRED="ERR_PROTECTOR_REQUIRED",e.ERR_PEER_DIAL_INTERCEPTED="ERR_PEER_DIAL_INTERCEPTED",e.ERR_CONNECTION_INTERCEPTED="ERR_CONNECTION_INTERCEPTED",e.ERR_INVALID_PROTOCOLS_FOR_STREAM="ERR_INVALID_PROTOCOLS_FOR_STREAM",e.ERR_CONNECTION_ENDED="ERR_CONNECTION_ENDED",e.ERR_CONNECTION_FAILED="ERR_CONNECTION_FAILED",e.ERR_NODE_NOT_STARTED="ERR_NODE_NOT_STARTED",e.ERR_ALREADY_ABORTED="ERR_ALREADY_ABORTED",e.ERR_TOO_MANY_ADDRESSES="ERR_TOO_MANY_ADDRESSES",e.ERR_NO_VALID_ADDRESSES="ERR_NO_VALID_ADDRESSES",e.ERR_RELAYED_DIAL="ERR_RELAYED_DIAL",e.ERR_DIALED_SELF="ERR_DIALED_SELF",e.ERR_DISCOVERED_SELF="ERR_DISCOVERED_SELF",e.ERR_DUPLICATE_TRANSPORT="ERR_DUPLICATE_TRANSPORT",e.ERR_ENCRYPTION_FAILED="ERR_ENCRYPTION_FAILED",e.ERR_HOP_REQUEST_FAILED="ERR_HOP_REQUEST_FAILED",e.ERR_INVALID_KEY="ERR_INVALID_KEY",e.ERR_INVALID_MESSAGE="ERR_INVALID_MESSAGE",e.ERR_INVALID_PARAMETERS="ERR_INVALID_PARAMETERS",e.ERR_INVALID_PEER="ERR_INVALID_PEER",e.ERR_MUXER_UNAVAILABLE="ERR_MUXER_UNAVAILABLE",e.ERR_NOT_FOUND="ERR_NOT_FOUND",e.ERR_TIMEOUT="ERR_TIMEOUT",e.ERR_TRANSPORT_UNAVAILABLE="ERR_TRANSPORT_UNAVAILABLE",e.ERR_TRANSPORT_DIAL_FAILED="ERR_TRANSPORT_DIAL_FAILED",e.ERR_UNSUPPORTED_PROTOCOL="ERR_UNSUPPORTED_PROTOCOL",e.ERR_PROTOCOL_HANDLER_ALREADY_REGISTERED="ERR_PROTOCOL_HANDLER_ALREADY_REGISTERED",e.ERR_INVALID_MULTIADDR="ERR_INVALID_MULTIADDR",e.ERR_SIGNATURE_NOT_VALID="ERR_SIGNATURE_NOT_VALID",e.ERR_FIND_SELF="ERR_FIND_SELF",e.ERR_NO_ROUTERS_AVAILABLE="ERR_NO_ROUTERS_AVAILABLE",e.ERR_CONNECTION_NOT_MULTIPLEXED="ERR_CONNECTION_NOT_MULTIPLEXED",e.ERR_NO_DIAL_TOKENS="ERR_NO_DIAL_TOKENS",e.ERR_KEYCHAIN_REQUIRED="ERR_KEYCHAIN_REQUIRED",e.ERR_INVALID_CMS="ERR_INVALID_CMS",e.ERR_MISSING_KEYS="ERR_MISSING_KEYS",e.ERR_NO_KEY="ERR_NO_KEY",e.ERR_INVALID_KEY_NAME="ERR_INVALID_KEY_NAME",e.ERR_INVALID_KEY_TYPE="ERR_INVALID_KEY_TYPE",e.ERR_KEY_ALREADY_EXISTS="ERR_KEY_ALREADY_EXISTS",e.ERR_INVALID_KEY_SIZE="ERR_INVALID_KEY_SIZE",e.ERR_KEY_NOT_FOUND="ERR_KEY_NOT_FOUND",e.ERR_OLD_KEY_NAME_INVALID="ERR_OLD_KEY_NAME_INVALID",e.ERR_NEW_KEY_NAME_INVALID="ERR_NEW_KEY_NAME_INVALID",e.ERR_PASSWORD_REQUIRED="ERR_PASSWORD_REQUIRED",e.ERR_PEM_REQUIRED="ERR_PEM_REQUIRED",e.ERR_CANNOT_READ_KEY="ERR_CANNOT_READ_KEY",e.ERR_MISSING_PRIVATE_KEY="ERR_MISSING_PRIVATE_KEY",e.ERR_MISSING_PUBLIC_KEY="ERR_MISSING_PUBLIC_KEY",e.ERR_INVALID_OLD_PASS_TYPE="ERR_INVALID_OLD_PASS_TYPE",e.ERR_INVALID_NEW_PASS_TYPE="ERR_INVALID_NEW_PASS_TYPE",e.ERR_INVALID_PASS_LENGTH="ERR_INVALID_PASS_LENGTH",e.ERR_NOT_IMPLEMENTED="ERR_NOT_IMPLEMENTED",e.ERR_WRONG_PING_ACK="ERR_WRONG_PING_ACK",e.ERR_INVALID_RECORD="ERR_INVALID_RECORD",e.ERR_ALREADY_SUCCEEDED="ERR_ALREADY_SUCCEEDED",e.ERR_NO_HANDLER_FOR_PROTOCOL="ERR_NO_HANDLER_FOR_PROTOCOL",e.ERR_TOO_MANY_OUTBOUND_PROTOCOL_STREAMS="ERR_TOO_MANY_OUTBOUND_PROTOCOL_STREAMS",e.ERR_TOO_MANY_INBOUND_PROTOCOL_STREAMS="ERR_TOO_MANY_INBOUND_PROTOCOL_STREAMS",e.ERR_CONNECTION_DENIED="ERR_CONNECTION_DENIED",e.ERR_TRANSFER_LIMIT_EXCEEDED="ERR_TRANSFER_LIMIT_EXCEEDED"})(codes||(codes={}));const DefaultConfig={addresses:{listen:[],announce:[],noAnnounce:[],announceFilter:e=>e},connectionManager:{resolvers:{dnsaddr:dnsaddrResolver},addressSorter:defaultAddressSort},transportManager:{faultTolerance:FaultTolerance.FATAL_ALL}};function validateConfig(e){const t=mergeOptions(DefaultConfig,e);if(t.transports==null||t.transports.length<1)throw new CodeError(messages$1.ERR_TRANSPORTS_REQUIRED,codes.ERR_TRANSPORTS_REQUIRED);if(t.connectionProtector===null&&globalThis.process?.env?.LIBP2P_FORCE_PNET!=null)throw new CodeError(messages$1.ERR_PROTECTOR_REQUIRED,codes.ERR_PROTECTOR_REQUIRED);return t}const KEEP_ALIVE="keep-alive",log$l=logger("libp2p:get-peer");function getPeerAddress(e){if(isPeerId(e))return{peerId:e,multiaddrs:[]};Array.isArray(e)||(e=[e]);let t;if(e.length>0){const r=e[0].getPeerId();t=r==null?void 0:peerIdFromString(r),e.forEach(n=>{if(!isMultiaddr(n))throw log$l.error("multiaddr %s was invalid",n),new CodeError("Invalid Multiaddr",codes.ERR_INVALID_MULTIADDR);const o=n.getPeerId();if(o==null){if(t!=null)throw new CodeError("Multiaddrs must all have the same peer id or have no peer id",codes.ERR_INVALID_PARAMETERS)}else{const a=peerIdFromString(o);if(t==null||!t.equals(a))throw new CodeError("Multiaddrs must all have the same peer id or have no peer id",codes.ERR_INVALID_PARAMETERS)}})}return{peerId:t,multiaddrs:e}}function lowerBound(e,t,r){let n=0,o=e.length;for(;o>0;){const a=Math.trunc(o/2);let l=n+a;r(e[l],t)<=0?(n=++l,o-=a+1):o=a}return n}var Kr;class PeerPriorityQueue{constructor(){Er(this,Kr,[])}enqueue(t,r){const n=r?.peerId,o=r?.priority??0;if(n==null)throw new CodeError("missing peer id",codes.ERR_INVALID_PARAMETERS);const a={priority:o,peerId:n,run:t};if(this.size>0&&ir(this,Kr)[this.size-1].priority>=o){ir(this,Kr).push(a);return}const l=lowerBound(ir(this,Kr),a,(c,u)=>u.priority-c.priority);ir(this,Kr).splice(l,0,a)}dequeue(){return ir(this,Kr).shift()?.run}filter(t){if(t.peerId!=null){const r=t.peerId;return ir(this,Kr).filter(n=>r.equals(n.peerId)).map(n=>n.run)}return ir(this,Kr).filter(r=>r.priority===t.priority).map(r=>r.run)}get size(){return ir(this,Kr).length}}Kr=new WeakMap;class PeerJobQueue extends PQueue{constructor(t={}){super({...t,queueClass:PeerPriorityQueue})}hasJob(t){return this.sizeBy({peerId:t})>0}}const DIAL_TIMEOUT=3e4,INBOUND_UPGRADE_TIMEOUT=3e4,MAX_PEER_ADDRS_TO_DIAL=25,MAX_PARALLEL_DIALS_PER_PEER=1,AUTO_DIAL_INTERVAL=5e3,AUTO_DIAL_CONCURRENCY=25,AUTO_DIAL_PRIORITY=0,AUTO_DIAL_MAX_QUEUE_LENGTH=100,AUTO_DIAL_DISCOVERED_PEERS_DEBOUNCE=10,INBOUND_CONNECTION_THRESHOLD=5,MAX_INCOMING_PENDING_CONNECTIONS=10,LAST_DIAL_FAILURE_KEY="last-dial-failure",MIN_CONNECTIONS=5,MAX_CONNECTIONS=100,MAX_PARALLEL_DIALS=50,AUTO_DIAL_PEER_RETRY_THRESHOLD=1e3*60*7,log$k=logger("libp2p:connection-manager:auto-dial"),defaultOptions$3={minConnections:MIN_CONNECTIONS,maxQueueLength:AUTO_DIAL_MAX_QUEUE_LENGTH,autoDialConcurrency:AUTO_DIAL_CONCURRENCY,autoDialPriority:AUTO_DIAL_PRIORITY,autoDialInterval:AUTO_DIAL_INTERVAL,autoDialPeerRetryThreshold:AUTO_DIAL_PEER_RETRY_THRESHOLD,autoDialDiscoveredPeersDebounce:AUTO_DIAL_DISCOVERED_PEERS_DEBOUNCE};class AutoDial{constructor(t,r){Je(this,"connectionManager");Je(this,"peerStore");Je(this,"queue");Je(this,"minConnections");Je(this,"autoDialPriority");Je(this,"autoDialIntervalMs");Je(this,"autoDialMaxQueueLength");Je(this,"autoDialPeerRetryThresholdMs");Je(this,"autoDialDiscoveredPeersDebounce");Je(this,"autoDialInterval");Je(this,"started");Je(this,"running");this.connectionManager=t.connectionManager,this.peerStore=t.peerStore,this.minConnections=r.minConnections??defaultOptions$3.minConnections,this.autoDialPriority=r.autoDialPriority??defaultOptions$3.autoDialPriority,this.autoDialIntervalMs=r.autoDialInterval??defaultOptions$3.autoDialInterval,this.autoDialMaxQueueLength=r.maxQueueLength??defaultOptions$3.maxQueueLength,this.autoDialPeerRetryThresholdMs=r.autoDialPeerRetryThreshold??defaultOptions$3.autoDialPeerRetryThreshold,this.autoDialDiscoveredPeersDebounce=r.autoDialDiscoveredPeersDebounce??defaultOptions$3.autoDialDiscoveredPeersDebounce,this.started=!1,this.running=!1,this.queue=new PeerJobQueue({concurrency:r.autoDialConcurrency??defaultOptions$3.autoDialConcurrency}),this.queue.addListener("error",o=>{log$k.error("error during auto-dial",o)}),t.events.addEventListener("connection:close",()=>{this.autoDial().catch(o=>{log$k.error(o)})});let n;t.events.addEventListener("peer:discovery",()=>{clearTimeout(n),n=setTimeout(()=>{this.autoDial().catch(o=>{log$k.error(o)})},this.autoDialDiscoveredPeersDebounce)})}isStarted(){return this.started}start(){this.autoDialInterval=setTimeout(()=>{this.autoDial().catch(t=>{log$k.error("error while autodialing",t)})},this.autoDialIntervalMs),this.started=!0}afterStart(){this.autoDial().catch(t=>{log$k.error("error while autodialing",t)})}stop(){this.queue.clear(),clearTimeout(this.autoDialInterval),this.started=!1,this.running=!1}async autoDial(){if(!this.started)return;const t=this.connectionManager.getConnectionsMap(),r=t.size;if(r>=this.minConnections){this.minConnections>0&&log$k.trace("have enough connections %d/%d",r,this.minConnections);return}if(this.queue.size>this.autoDialMaxQueueLength){log$k("not enough connections %d/%d but auto dial queue is full",r,this.minConnections);return}if(this.running){log$k("not enough connections %d/%d - but skipping autodial as it is already running",r,this.minConnections);return}this.running=!0,log$k("not enough connections %d/%d - will dial peers to increase the number of connections",r,this.minConnections);const n=new PeerSet(this.connectionManager.getDialQueue().map(g=>g.peerId).filter(Boolean)),o=await this.peerStore.all({filters:[g=>g.addresses.length===0?(log$k.trace("not autodialing %p because they have no addresses"),!1):t.has(g.id)?(log$k.trace("not autodialing %p because they are already connected"),!1):n.has(g.id)?(log$k.trace("not autodialing %p because they are already being dialed"),!1):this.queue.hasJob(g.id)?(log$k.trace("not autodialing %p because they are already being autodialed"),!1):!0]}),a=o.sort(()=>Math.random()>.5?1:-1),l=new PeerMap;for(const g of a)l.has(g.id)||l.set(g.id,[...g.tags.values()].reduce((_,x)=>_+x.value,0));const u=a.sort((g,_)=>{const x=l.get(g.id)??0,S=l.get(_.id)??0;return x>S?-1:x{const _=g.metadata.get(LAST_DIAL_FAILURE_KEY);if(_==null)return!0;const x=parseInt(toString$5(_));return isNaN(x)?!0:Date.now()-x>this.autoDialPeerRetryThresholdMs});log$k("selected %d/%d peers to dial",u.length,o.length);for(const g of u)this.queue.add(async()=>{const _=this.connectionManager.getConnectionsMap().size;if(_>=this.minConnections){log$k("got enough connections now %d/%d",_,this.minConnections),this.queue.clear();return}log$k("connecting to a peerStore stored peer %p",g.id),await this.connectionManager.openConnection(g.id,{priority:this.autoDialPriority})},{peerId:g.id}).catch(_=>{log$k.error("could not connect to peerStore stored peer",_)});this.running=!1,this.started&&(this.autoDialInterval=setTimeout(()=>{this.autoDial().catch(g=>{log$k.error("error while autodialing",g)})},this.autoDialIntervalMs))}}const log$j=logger("libp2p:connection-manager:connection-pruner"),defaultOptions$2={maxConnections:MAX_CONNECTIONS,allow:[]};class ConnectionPruner{constructor(t,r={}){Je(this,"maxConnections");Je(this,"connectionManager");Je(this,"peerStore");Je(this,"allow");Je(this,"events");this.maxConnections=r.maxConnections??defaultOptions$2.maxConnections,this.allow=r.allow??defaultOptions$2.allow,this.connectionManager=t.connectionManager,this.peerStore=t.peerStore,this.events=t.events,t.events.addEventListener("connection:open",()=>{this.maybePruneConnections().catch(n=>{log$j.error(n)})})}async maybePruneConnections(){const t=this.connectionManager.getConnections(),r=t.length,n=Math.max(r-this.maxConnections,0);if(log$j("checking max connections limit %d/%d",r,this.maxConnections),r<=this.maxConnections)return;log$j("max connections limit exceeded %d/%d, pruning %d connection(s)",r,this.maxConnections,n);const o=new PeerMap;for(const c of t){const u=c.remotePeer;if(!o.has(u)){o.set(u,0);try{const g=await this.peerStore.get(u);o.set(u,[...g.tags.values()].reduce((_,x)=>_+x.value,0))}catch(g){g.code!=="ERR_NOT_FOUND"&&log$j.error("error loading peer tags",g)}}}const a=t.sort((c,u)=>{const g=o.get(c.remotePeer)??0,_=o.get(u.remotePeer)??0;if(g>_)return 1;if(g<_)return-1;const x=c.timeline.open,S=u.timeline.open;return xS?-1:0}),l=[];for(const c of a)if(log$j("too many connections open - closing a connection to %p",c.remotePeer),this.allow.some(g=>c.remoteAddr.toString().startsWith(g.toString()))||l.push(c),l.length===n)break;await Promise.all(l.map(async c=>{try{await c.close()}catch(u){log$j.error(u)}})),this.events.safeDispatchEvent("connection:prune",{detail:l})}}function anySignal(e){const t=new globalThis.AbortController;function r(){t.abort();for(const a of e)a?.removeEventListener!=null&&a.removeEventListener("abort",r)}for(const a of e){if(a?.aborted===!0){r();break}a?.addEventListener!=null&&a.addEventListener("abort",r)}function n(){for(const a of e)a?.removeEventListener!=null&&a.removeEventListener("abort",r)}const o=t.signal;return o.clear=n,o}const log$i=logger("libp2p:connection-manager:utils");async function resolveMultiaddrs(e,t){if(!e.protoNames().includes("dnsaddr"))return[e];const n=await resolveRecord(e,t),l=(await Promise.all(n.map(async c=>resolveMultiaddrs(c,t)))).flat().reduce((c,u)=>(c.find(g=>g.equals(u))==null&&c.push(u),c),[]);return log$i("resolved %s to",e,l.map(c=>c.toString())),l}async function resolveRecord(e,t){try{return e=multiaddr(e.toString()),await e.resolve(t)}catch(r){return log$i.error(`multiaddr ${e.toString()} could not be resolved`,r),[]}}function combineSignals(...e){const t=[];for(const n of e)if(n!=null){try{events$1.exports.setMaxListeners?.(1/0,n)}catch{}t.push(n)}const r=anySignal(t);try{events$1.exports.setMaxListeners?.(1/0,r)}catch{}return r}const log$h=logger("libp2p:connection-manager:dial-queue"),defaultOptions$1={addressSorter:defaultAddressSort,maxParallelDials:MAX_PARALLEL_DIALS,maxPeerAddrsToDial:MAX_PEER_ADDRS_TO_DIAL,maxParallelDialsPerPeer:MAX_PARALLEL_DIALS_PER_PEER,dialTimeout:DIAL_TIMEOUT,resolvers:{dnsaddr:dnsaddrResolver}};class DialQueue{constructor(t,r={}){Je(this,"pendingDials");Je(this,"queue");Je(this,"peerId");Je(this,"peerStore");Je(this,"connectionGater");Je(this,"transportManager");Je(this,"addressSorter");Je(this,"maxPeerAddrsToDial");Je(this,"maxParallelDialsPerPeer");Je(this,"dialTimeout");Je(this,"inProgressDialCount");Je(this,"pendingDialCount");Je(this,"shutDownController");this.addressSorter=r.addressSorter??defaultOptions$1.addressSorter,this.maxPeerAddrsToDial=r.maxPeerAddrsToDial??defaultOptions$1.maxPeerAddrsToDial,this.maxParallelDialsPerPeer=r.maxParallelDialsPerPeer??defaultOptions$1.maxParallelDialsPerPeer,this.dialTimeout=r.dialTimeout??defaultOptions$1.dialTimeout,this.peerId=t.peerId,this.peerStore=t.peerStore,this.connectionGater=t.connectionGater,this.transportManager=t.transportManager,this.shutDownController=new AbortController;try{events$1.exports.setMaxListeners?.(1/0,this.shutDownController.signal)}catch{}this.pendingDialCount=t.metrics?.registerMetric("libp2p_dialler_pending_dials"),this.inProgressDialCount=t.metrics?.registerMetric("libp2p_dialler_in_progress_dials"),this.pendingDials=[];for(const[n,o]of Object.entries(r.resolvers??{}))resolvers.set(n,o);this.queue=new PQueue({concurrency:r.maxParallelDials??defaultOptions$1.maxParallelDials}),this.queue.on("add",()=>{this.pendingDialCount?.update(this.queue.size),this.inProgressDialCount?.update(this.queue.pending)}),this.queue.on("active",()=>{this.pendingDialCount?.update(this.queue.size),this.inProgressDialCount?.update(this.queue.pending)}),this.queue.on("completed",()=>{this.pendingDialCount?.update(this.queue.size),this.inProgressDialCount?.update(this.queue.pending)}),this.queue.on("error",n=>{log$h.error("error in dial queue",n),this.pendingDialCount?.update(this.queue.size),this.inProgressDialCount?.update(this.queue.pending)}),this.queue.on("empty",()=>{this.pendingDialCount?.update(this.queue.size),this.inProgressDialCount?.update(this.queue.pending)}),this.queue.on("idle",()=>{this.pendingDialCount?.update(this.queue.size),this.inProgressDialCount?.update(this.queue.pending)})}stop(){this.shutDownController.abort()}async dial(t,r={}){const{peerId:n,multiaddrs:o}=getPeerAddress(t),a=o.map(_=>({multiaddr:_,isCertified:!1})),l=this.createDialAbortControllers(r.signal);let c;try{c=await this.calculateMultiaddrs(n,a,{...r,signal:l})}catch(_){throw l.clear(),_}const u=this.pendingDials.find(_=>!!(_.peerId!=null&&n!=null&&_.peerId.equals(n)||c.map(({multiaddr:x})=>x.toString()).join()===_.multiaddrs.map(x=>x.toString()).join()));if(u!=null)return log$h("joining existing dial target for %p",n),l.clear(),u.promise;log$h("creating dial target for",c.map(({multiaddr:_})=>_.toString()));const g={id:randomId(),status:"queued",peerId:n,multiaddrs:c.map(({multiaddr:_})=>_)};return g.promise=this.performDial(g,{...r,signal:l}).finally(()=>{this.pendingDials=this.pendingDials.filter(_=>_.id!==g.id),l.clear()}).catch(async _=>{if(log$h.error("dial failed to %s",g.multiaddrs.map(x=>x.toString()).join(", "),_),n!=null)try{await this.peerStore.patch(n,{metadata:{[LAST_DIAL_FAILURE_KEY]:fromString$1(Date.now().toString())}})}catch(x){log$h.error("could not update last dial failure key for %p",n,x)}throw l.aborted?new CodeError(_.message,codes.ERR_TIMEOUT):_}),this.pendingDials.push(g),g.promise}createDialAbortControllers(t){const r=anySignal([AbortSignal.timeout(this.dialTimeout),this.shutDownController.signal,t]);try{events$1.exports.setMaxListeners?.(1/0,r)}catch{}return r}async calculateMultiaddrs(t,r=[],n={}){if(t!=null){if(this.peerId.equals(t))throw new CodeError("Tried to dial self",codes.ERR_DIALED_SELF);if(await this.connectionGater.denyDialPeer?.(t)===!0)throw new CodeError("The dial request is blocked by gater.allowDialPeer",codes.ERR_PEER_DIAL_INTERCEPTED);if(r.length===0){log$h("loading multiaddrs for %p",t);try{const _=await this.peerStore.get(t);r.push(..._.addresses),log$h("loaded multiaddrs for %p",t,r.map(({multiaddr:x})=>x.toString()))}catch(_){if(_.code!==codes.ERR_NOT_FOUND)throw _}}}const o=(await Promise.all(r.map(async _=>{const x=await resolveMultiaddrs(_.multiaddr,n);return x.length===1&&x[0].equals(_.multiaddr)?_:x.map(S=>({multiaddr:S,isCertified:!1}))}))).flat(),a=o.filter(_=>{if(this.transportManager.transportForMultiaddr(_.multiaddr)==null)return!1;const x=_.multiaddr.getPeerId();return t!=null&&x!=null?t.equals(x):!0}),l=new Map;for(const _ of a){const x=_.multiaddr.toString(),S=l.get(x);if(S!=null){S.isCertified=S.isCertified||_.isCertified||!1;continue}l.set(x,_)}let c=[...l.values()];if((c.length===0||c.length>this.maxPeerAddrsToDial)&&(log$h("addresses for %p before filtering",t??"unknown peer",o.map(({multiaddr:_})=>_.toString())),log$h("addresses for %p after filtering",t??"unknown peer",c.map(({multiaddr:_})=>_.toString()))),c.length===0)throw new CodeError("The dial request has no valid addresses",codes.ERR_NO_VALID_ADDRESSES);if(c.length>this.maxPeerAddrsToDial)throw new CodeError("dial with more addresses than allowed",codes.ERR_TOO_MANY_ADDRESSES);if(t!=null){const _=`/p2p/${t.toString()}`;c=c.map(x=>{const S=x.multiaddr.getPeerId();return x.multiaddr.protos().pop()?.path===!0?x:S!==t.toString()?{multiaddr:x.multiaddr.encapsulate(_),isCertified:x.isCertified}:x})}const u=[];for(const _ of c)this.connectionGater.denyDialMultiaddr!=null&&await this.connectionGater.denyDialMultiaddr(_.multiaddr)||u.push(_);const g=u.sort(this.addressSorter);if(g.length===0)throw new CodeError("The connection gater denied all addresses in the dial request",codes.ERR_NO_VALID_ADDRESSES);return g}async performDial(t,r={}){const n=t.multiaddrs.map(()=>new AbortController);try{const o=new PQueue({concurrency:this.maxParallelDialsPerPeer});o.on("error",l=>{log$h.error("error dialling",l)});const a=await Promise.any(t.multiaddrs.map(async(l,c)=>{const u=n[c];if(u==null)throw new CodeError("dialAction did not come with an AbortController",codes.ERR_INVALID_PARAMETERS);const g=combineSignals(u.signal,r.signal);g.addEventListener("abort",()=>{log$h("dial to %a aborted",l)});const _=pDefer();return await o.add(async()=>{if(g.aborted){log$h("dial to %a was aborted before reaching the head of the peer dial queue",l),_.reject(new AbortError$4);return}await this.queue.add(async()=>{try{if(g.aborted){log$h("dial to %a was aborted before reaching the head of the dial queue",l),_.reject(new AbortError$4);return}t.status="active";const x=await this.transportManager.dial(l,{...r,signal:g});if(u.signal.aborted){log$h("multiple dials succeeded, closing superfluous connection"),x.close().catch(S=>{log$h.error("error closing superfluous connection",S)}),_.reject(new AbortError$4);return}n[c]=void 0,n.forEach(S=>{S!==void 0&&S.abort()}),log$h("dial to %a succeeded",l),_.resolve(x)}catch(x){log$h.error("error during dial of %a",l,x),_.reject(x)}},{...r,signal:g}).catch(x=>{_.reject(x)})},{signal:g}).catch(x=>{_.reject(x)}).finally(()=>{g.clear()}),_.promise}));if(a==null)throw new CodeError("successful dial led to empty object returned from peer dial queue",codes.ERR_TRANSPORT_DIAL_FAILED);return t.status="success",a}catch(o){throw t.status="error",t.multiaddrs.length===1&&o.name==="AggregateError"?o.errors[0]:o}}}function randomId(){return`${parseInt(String(Math.random()*1e9),10).toString()}${Date.now()}`}const log$g=logger("libp2p:connection-manager"),DEFAULT_DIAL_PRIORITY=50,defaultOptions={minConnections:MIN_CONNECTIONS,maxConnections:MAX_CONNECTIONS,inboundConnectionThreshold:INBOUND_CONNECTION_THRESHOLD,maxIncomingPendingConnections:MAX_INCOMING_PENDING_CONNECTIONS,autoDialConcurrency:AUTO_DIAL_CONCURRENCY,autoDialPriority:AUTO_DIAL_PRIORITY,autoDialMaxQueueLength:AUTO_DIAL_MAX_QUEUE_LENGTH};class DefaultConnectionManager{constructor(t,r={}){Je(this,"started");Je(this,"connections");Je(this,"allow");Je(this,"deny");Je(this,"maxIncomingPendingConnections");Je(this,"incomingPendingConnections");Je(this,"maxConnections");Je(this,"dialQueue");Je(this,"autoDial");Je(this,"connectionPruner");Je(this,"inboundConnectionRateLimiter");Je(this,"peerStore");Je(this,"metrics");Je(this,"events");this.maxConnections=r.maxConnections??defaultOptions.maxConnections;const n=r.minConnections??defaultOptions.minConnections;if(this.maxConnectionsmultiaddr(o)),this.deny=(r.deny??[]).map(o=>multiaddr(o)),this.incomingPendingConnections=0,this.maxIncomingPendingConnections=r.maxIncomingPendingConnections??defaultOptions.maxIncomingPendingConnections,this.inboundConnectionRateLimiter=new rateLimiterFlexible.RateLimiterMemory({points:r.inboundConnectionThreshold??defaultOptions.inboundConnectionThreshold,duration:1}),this.autoDial=new AutoDial({connectionManager:this,peerStore:t.peerStore,events:t.events},{minConnections:n,autoDialConcurrency:r.autoDialConcurrency??defaultOptions.autoDialConcurrency,autoDialPriority:r.autoDialPriority??defaultOptions.autoDialPriority,maxQueueLength:r.autoDialMaxQueueLength??defaultOptions.autoDialMaxQueueLength}),this.connectionPruner=new ConnectionPruner({connectionManager:this,peerStore:t.peerStore,events:t.events},{maxConnections:this.maxConnections,allow:this.allow}),this.dialQueue=new DialQueue({peerId:t.peerId,metrics:t.metrics,peerStore:t.peerStore,transportManager:t.transportManager,connectionGater:t.connectionGater},{addressSorter:r.addressSorter??defaultAddressSort,maxParallelDials:r.maxParallelDials??MAX_PARALLEL_DIALS,maxPeerAddrsToDial:r.maxPeerAddrsToDial??MAX_PEER_ADDRS_TO_DIAL,maxParallelDialsPerPeer:r.maxParallelDialsPerPeer??MAX_PARALLEL_DIALS_PER_PEER,dialTimeout:r.dialTimeout??DIAL_TIMEOUT,resolvers:r.resolvers??{dnsaddr:dnsaddrResolver}})}isStarted(){return this.started}async start(){this.metrics?.registerMetricGroup("libp2p_connection_manager_connections",{calculate:()=>{const t={inbound:0,outbound:0};for(const r of this.connections.values())for(const n of r)n.direction==="inbound"?t.inbound++:t.outbound++;return t}}),this.metrics?.registerMetricGroup("libp2p_protocol_streams_total",{label:"protocol",calculate:()=>{const t={};for(const r of this.connections.values())for(const n of r)for(const o of n.streams){const a=`${o.direction} ${o.protocol??"unnegotiated"}`;t[a]=(t[a]??0)+1}return t}}),this.metrics?.registerMetricGroup("libp2p_connection_manager_protocol_streams_per_connection_90th_percentile",{label:"protocol",calculate:()=>{const t={};for(const n of this.connections.values())for(const o of n){const a={};for(const l of o.streams){const c=`${l.direction} ${l.protocol??"unnegotiated"}`;a[c]=(a[c]??0)+1}for(const[l,c]of Object.entries(a))t[l]=t[l]??[],t[l].push(c)}const r={};for(let[n,o]of Object.entries(t)){o=o.sort((l,c)=>l-c);const a=Math.floor(o.length*.9);r[n]=o[a]}return r}}),this.autoDial.start(),this.started=!0,log$g("started")}async afterStart(){Promise.resolve().then(async()=>{const t=await this.peerStore.all({filters:[r=>r.tags.has(KEEP_ALIVE)]});await Promise.all(t.map(async r=>{await this.openConnection(r.id).catch(n=>{log$g.error(n)})}))}).catch(t=>{log$g.error(t)}),this.autoDial.afterStart()}async stop(){this.dialQueue.stop(),this.autoDial.stop();const t=[];for(const r of this.connections.values())for(const n of r)t.push((async()=>{try{await n.close()}catch(o){log$g.error(o)}})());log$g("closing %d connections",t.length),await Promise.all(t),this.connections.clear(),log$g("stopped")}onConnect(t){this._onConnect(t).catch(r=>{log$g.error(r)})}async _onConnect(t){const{detail:r}=t;if(!this.started){await r.close();return}const n=r.remotePeer,o=this.connections.get(n);let a=!1;o!=null?o.push(r):(a=!0,this.connections.set(n,[r])),n.publicKey!=null&&n.type==="RSA"&&await this.peerStore.patch(n,{publicKey:n.publicKey}),a&&this.events.safeDispatchEvent("peer:connect",{detail:r.remotePeer})}onDisconnect(t){const{detail:r}=t;if(!this.started)return;const n=r.remotePeer;let o=this.connections.get(n);o!=null&&o.length>1?(o=o.filter(a=>a.id!==r.id),this.connections.set(n,o)):o!=null&&(this.connections.delete(n),this.events.safeDispatchEvent("peer:disconnect",{detail:r.remotePeer}))}getConnections(t){if(t!=null)return this.connections.get(t)??[];let r=[];for(const n of this.connections.values())r=r.concat(n);return r}getConnectionsMap(){return this.connections}async openConnection(t,r={}){if(!this.isStarted())throw new CodeError("Not started",codes.ERR_NODE_NOT_STARTED);r.signal?.throwIfAborted();const{peerId:n}=getPeerAddress(t);if(n!=null&&r.force!==!0){log$g("dial %p",n);const c=this.getConnections(n);if(c.length>0)return log$g("had an existing connection to %p",n),c[0]}const o=await this.dialQueue.dial(t,{...r,priority:r.priority??DEFAULT_DIAL_PRIORITY});let a=this.connections.get(o.remotePeer);a==null&&(a=[],this.connections.set(o.remotePeer,a));let l=!1;for(const c of a)c.id===o.id&&(l=!0);return l||a.push(o),o}async closeConnections(t,r={}){const n=this.connections.get(t)??[];await Promise.all(n.map(async o=>{try{await o.close(r)}catch(a){o.abort(a)}}))}async acceptIncomingConnection(t){if(this.deny.some(o=>t.remoteAddr.toString().startsWith(o.toString())))return log$g("connection from %a refused - connection remote address was in deny list",t.remoteAddr),!1;if(this.allow.some(o=>t.remoteAddr.toString().startsWith(o.toString())))return this.incomingPendingConnections++,!0;if(this.incomingPendingConnections===this.maxIncomingPendingConnections)return log$g("connection from %a refused - incomingPendingConnections exceeded by host",t.remoteAddr),!1;if(t.remoteAddr.isThinWaistAddress()){const o=t.remoteAddr.nodeAddress().address;try{await this.inboundConnectionRateLimiter.consume(o,1)}catch{return log$g("connection from %a refused - inboundConnectionThreshold exceeded by host %s",t.remoteAddr,o),!1}}return this.getConnections().length(await t.merge(r.id,{multiaddrs:r.multiaddrs}),r))}function uniquePeers(e){const t=new Set;return filter(e,r=>t.has(r.id.toString())?!1:(t.add(r.id.toString()),!0))}async function*requirePeers(e,t=1){let r=0;for await(const n of e)r++,yield n;if(rn.findProviders(t,r))),n=>storeAddresses(n,this.components.peerStore),n=>uniquePeers(n),n=>requirePeers(n))}async provide(t,r={}){if(this.routers.length===0)throw new CodeError("No content routers available",codes.ERR_NO_ROUTERS_AVAILABLE);await Promise.all(this.routers.map(async n=>{await n.provide(t,r)}))}async put(t,r,n){if(!this.isStarted())throw new CodeError(messages$1.NOT_STARTED_YET,codes.DHT_NOT_STARTED);await Promise.all(this.routers.map(async o=>{await o.put(t,r,n)}))}async get(t,r){if(!this.isStarted())throw new CodeError(messages$1.NOT_STARTED_YET,codes.DHT_NOT_STARTED);return Promise.any(this.routers.map(async n=>n.get(t,r)))}}function isAsyncIterable(e){return e[Symbol.asyncIterator]!=null}function first(e){if(isAsyncIterable(e))return(async()=>{for await(const t of e)return t})();for(const t of e)return t}const log$f=logger("libp2p:peer-routing");class DefaultPeerRouting{constructor(t,r){Je(this,"components");Je(this,"routers");this.components=t,this.routers=r.routers??[]}async findPeer(t,r){if(this.routers.length===0)throw new CodeError("No peer routers available",codes.ERR_NO_ROUTERS_AVAILABLE);if(t.toString()===this.components.peerId.toString())throw new CodeError("Should not try to find self",codes.ERR_FIND_SELF);const n=await pipe(merge$1(...this.routers.map(o=>async function*(){try{yield await o.findPeer(t,r)}catch(a){log$f.error(a)}}())),o=>filter(o,Boolean),o=>storeAddresses(o,this.components.peerStore),async o=>first(o));if(n!=null)return n;throw new CodeError(messages$1.NOT_FOUND,codes.ERR_NOT_FOUND)}async*getClosestPeers(t,r){if(this.routers.length===0)throw new CodeError("No peer routers available",codes.ERR_NO_ROUTERS_AVAILABLE);yield*pipe(merge$1(...this.routers.map(n=>n.getClosestPeers(t,r))),n=>storeAddresses(n,this.components.peerStore),n=>uniquePeers(n),n=>requirePeers(n))}}const log$e=logger("libp2p:registrar"),DEFAULT_MAX_INBOUND_STREAMS=32,DEFAULT_MAX_OUTBOUND_STREAMS=64;class DefaultRegistrar{constructor(t){Je(this,"topologies");Je(this,"handlers");Je(this,"components");this.topologies=new Map,this.handlers=new Map,this.components=t,this._onDisconnect=this._onDisconnect.bind(this),this._onPeerUpdate=this._onPeerUpdate.bind(this),this._onConnect=this._onConnect.bind(this),this.components.events.addEventListener("peer:disconnect",this._onDisconnect),this.components.events.addEventListener("peer:connect",this._onConnect),this.components.events.addEventListener("peer:update",this._onPeerUpdate)}getProtocols(){return Array.from(new Set([...this.handlers.keys()])).sort()}getHandler(t){const r=this.handlers.get(t);if(r==null)throw new CodeError(`No handler registered for protocol ${t}`,codes.ERR_NO_HANDLER_FOR_PROTOCOL);return r}getTopologies(t){const r=this.topologies.get(t);return r==null?[]:[...r.values()]}async handle(t,r,n){if(this.handlers.has(t))throw new CodeError(`Handler already registered for protocol ${t}`,codes.ERR_PROTOCOL_HANDLER_ALREADY_REGISTERED);const o=mergeOptions.bind({ignoreUndefined:!0})({maxInboundStreams:DEFAULT_MAX_INBOUND_STREAMS,maxOutboundStreams:DEFAULT_MAX_OUTBOUND_STREAMS},n);this.handlers.set(t,{handler:r,options:o}),await this.components.peerStore.merge(this.components.peerId,{protocols:[t]})}async unhandle(t){(Array.isArray(t)?t:[t]).forEach(n=>{this.handlers.delete(n)}),await this.components.peerStore.patch(this.components.peerId,{protocols:this.getProtocols()})}async register(t,r){if(r==null)throw new CodeError("invalid topology",codes.ERR_INVALID_PARAMETERS);const n=`${(Math.random()*1e9).toString(36)}${Date.now()}`;let o=this.topologies.get(t);return o==null&&(o=new Map,this.topologies.set(t,o)),o.set(n,r),n}unregister(t){for(const[r,n]of this.topologies.entries())n.has(t)&&(n.delete(t),n.size===0&&this.topologies.delete(r))}_onDisconnect(t){const r=t.detail;this.components.peerStore.get(r).then(n=>{for(const o of n.protocols){const a=this.topologies.get(o);if(a!=null)for(const l of a.values())l.onDisconnect?.(r)}}).catch(n=>{n.code!==codes.ERR_NOT_FOUND&&log$e.error("could not inform topologies of disconnecting peer %p",r,n)})}_onConnect(t){const r=t.detail;this.components.peerStore.get(r).then(n=>{const o=this.components.connectionManager.getConnections(n.id)[0];if(o==null){log$e("peer %p connected but the connection manager did not have a connection",n);return}for(const a of n.protocols){const l=this.topologies.get(a);if(l!=null)for(const c of l.values())c.onConnect?.(r,o)}}).catch(n=>{n.code!==codes.ERR_NOT_FOUND&&log$e.error("could not inform topologies of connecting peer %p",r,n)})}_onPeerUpdate(t){const{peer:r,previous:n}=t.detail,o=(n?.protocols??[]).filter(l=>!r.protocols.includes(l)),a=r.protocols.filter(l=>!(n?.protocols??[]).includes(l));for(const l of o){const c=this.topologies.get(l);if(c!=null)for(const u of c.values())u.onDisconnect?.(r.id)}for(const l of a){const c=this.topologies.get(l);if(c!=null)for(const u of c.values()){const g=this.components.connectionManager.getConnections(r.id)[0];g!=null&&u.onConnect?.(r.id,g)}}}}class TrackedMap extends Map{constructor(r){super();Je(this,"metric");const{name:n,metrics:o}=r;this.metric=o.registerMetric(n),this.updateComponentMetric()}set(r,n){return super.set(r,n),this.updateComponentMetric(),this}delete(r){const n=super.delete(r);return this.updateComponentMetric(),n}clear(){super.clear(),this.updateComponentMetric()}updateComponentMetric(){this.metric.update(this.size)}}function trackedMap(e){const{name:t,metrics:r}=e;let n;return r!=null?n=new TrackedMap({name:t,metrics:r}):n=new Map,n}const log$d=logger("libp2p:transports");class DefaultTransportManager{constructor(t,r={}){Je(this,"components");Je(this,"transports");Je(this,"listeners");Je(this,"faultTolerance");Je(this,"started");this.components=t,this.started=!1,this.transports=new Map,this.listeners=trackedMap({name:"libp2p_transport_manager_listeners",metrics:this.components.metrics}),this.faultTolerance=r.faultTolerance??FaultTolerance.FATAL_ALL}add(t){const r=t[Symbol.toStringTag];if(r==null)throw new CodeError("Transport must have a valid tag",codes.ERR_INVALID_KEY);if(this.transports.has(r))throw new CodeError(`There is already a transport with the tag ${r}`,codes.ERR_DUPLICATE_TRANSPORT);log$d("adding transport %s",r),this.transports.set(r,t),this.listeners.has(r)||this.listeners.set(r,[])}isStarted(){return this.started}start(){this.started=!0}async afterStart(){const t=this.components.addressManager.getListenAddrs();await this.listen(t)}async stop(){const t=[];for(const[r,n]of this.listeners)for(log$d("closing listeners for %s",r);n.length>0;){const o=n.pop();o!=null&&t.push(o.close())}await Promise.all(t),log$d("all listeners closed");for(const r of this.listeners.keys())this.listeners.set(r,[]);this.started=!1}async dial(t,r){const n=this.transportForMultiaddr(t);if(n==null)throw new CodeError(`No transport available for address ${String(t)}`,codes.ERR_TRANSPORT_UNAVAILABLE);try{return await n.dial(t,{...r,upgrader:this.components.upgrader})}catch(o){throw o.code==null&&(o.code=codes.ERR_TRANSPORT_DIAL_FAILED),o}}getAddrs(){let t=[];for(const r of this.listeners.values())for(const n of r)t=[...t,...n.getAddrs()];return t}getTransports(){return Array.of(...this.transports.values())}getListeners(){return Array.of(...this.listeners.values()).flat()}transportForMultiaddr(t){for(const r of this.transports.values())if(r.filter([t]).length>0)return r}async listen(t){if(!this.isStarted())throw new CodeError("Not started",codes.ERR_NODE_NOT_STARTED);if(t==null||t.length===0){log$d("no addresses were provided for listening, this node is dial only");return}const r=[];for(const[n,o]of this.transports.entries()){const a=o.filter(t),l=[];for(const g of a){log$d("creating listener for %s on %a",n,g);const _=o.createListener({upgrader:this.components.upgrader});let x=this.listeners.get(n)??[];x==null&&(x=[],this.listeners.set(n,x)),x.push(_),_.addEventListener("listening",()=>{this.components.events.safeDispatchEvent("transport:listening",{detail:_})}),_.addEventListener("close",()=>{const S=x.findIndex(O=>O===_);x.splice(S,1),this.components.events.safeDispatchEvent("transport:close",{detail:_})}),l.push(_.listen(g))}if(l.length===0){r.push(n);continue}if((await Promise.allSettled(l)).find(g=>g.status==="fulfilled")==null&&this.faultTolerance!==FaultTolerance.NO_FATAL)throw new CodeError(`Transport (${n}) could not listen on any available address`,codes.ERR_NO_VALID_ADDRESSES)}if(r.length===this.transports.size){const n=`no valid addresses were provided for transports [${r.join(", ")}]`;if(this.faultTolerance===FaultTolerance.FATAL_ALL)throw new CodeError(n,codes.ERR_NO_VALID_ADDRESSES);log$d(`libp2p in dial mode only: ${n}`)}}async remove(t){log$d("removing %s",t);for(const r of this.listeners.get(t)??[])await r.close();this.transports.delete(t),this.listeners.delete(t)}async removeAll(){const t=[];for(const r of this.transports.keys())t.push(this.remove(r));await Promise.all(t)}}const PROTOCOL_ID="/multistream/1.0.0",MAX_PROTOCOL_LENGTH=1024;function reader(e){const t=async function*(){let r=yield,n=new Uint8ArrayList;for await(const o of e){if(r==null){n.append(o),r=yield n,n=new Uint8ArrayList;continue}for(n.append(o);n.length>=r;){const a=n.sublist(0,r);if(n.consume(r),r=yield a,r==null){n.length>0&&(r=yield n,n=new Uint8ArrayList);break}}}if(r!=null)throw Object.assign(new Error(`stream ended before ${r} bytes became available`),{code:"ERR_UNDER_READ",buffer:n})}();return t.next(),t}function handshake(e){const t=pushable(),r=reader(e.source),n=pDefer();let o;const a=e.sink(async function*(){yield*t,yield*await n.promise}());return a.catch(c=>{o=c}),{reader:r,writer:t,stream:{sink:async c=>{if(o!=null){await Promise.reject(o);return}n.resolve(c),await a},source:r},rest:()=>t.end(),write:t.push,read:async()=>{const c=await r.next();if(c.value!=null)return c.value}}}const log$c=logger("libp2p:mss"),NewLine=fromString$1(` `);function encode$1(e){const t=new Uint8ArrayList(e,NewLine);return encode$c.single(t)}function write(e,t,r={}){const n=encode$1(t);r.writeBytes===!0?e.push(n.subarray()):e.push(n)}function writeAll(e,t,r={}){const n=new Uint8ArrayList;for(const o of t)n.append(encode$1(o));r.writeBytes===!0?e.push(n.subarray()):e.push(n)}async function read(e,t){let r=1;const n={[Symbol.asyncIterator]:()=>n,next:async()=>e.next(r)};let o=n;t?.signal!=null&&(o=abortableSource(n,t.signal));const a=c=>{r=c},l=await pipe(o,c=>decode$a(c,{onLength:a,maxDataLength:MAX_PROTOCOL_LENGTH}),async c=>first(c));if(l==null||l.length===0)throw new CodeError("no buffer returned","ERR_INVALID_MULTISTREAM_SELECT_MESSAGE");if(l.get(l.byteLength-1)!==NewLine[0])throw log$c.error("Invalid mss message - missing newline - %s",l.subarray()),new CodeError("missing newline","ERR_INVALID_MULTISTREAM_SELECT_MESSAGE");return l.sublist(0,-1)}async function readString(e,t){const r=await read(e,t);return toString$5(r.subarray())}const log$b=logger("libp2p:mss:select");async function select(e,t,r={}){t=Array.isArray(t)?[...t]:[t];const{reader:n,writer:o,rest:a,stream:l}=handshake(e),c=t.shift();if(c==null)throw new Error("At least one protocol must be specified");log$b.trace('select: write ["%s", "%s"]',PROTOCOL_ID,c);const u=fromString$1(PROTOCOL_ID),g=fromString$1(c);writeAll(o,[u,g],r);let _=await readString(n,r);if(log$b.trace('select: read "%s"',_),_===PROTOCOL_ID&&(_=await readString(n,r),log$b.trace('select: read "%s"',_)),_===c)return a(),{stream:l,protocol:c};for(const x of t){log$b.trace('select: write "%s"',x),write(o,fromString$1(x),r);const S=await readString(n,r);if(log$b.trace('select: read "%s" for "%s"',S,x),S===x)return a(),{stream:l,protocol:x}}throw a(),new CodeError("protocol selection failed","ERR_UNSUPPORTED_PROTOCOL")}const log$a=logger("libp2p:mss:handle");async function handle(e,t,r){t=Array.isArray(t)?t:[t];const{writer:n,reader:o,rest:a,stream:l}=handshake(e);for(;;){const c=await readString(o,r);if(log$a.trace('read "%s"',c),c===PROTOCOL_ID){log$a.trace('respond with "%s" for "%s"',PROTOCOL_ID,c),write(n,fromString$1(PROTOCOL_ID),r);continue}if(t.includes(c))return write(n,fromString$1(c),r),log$a.trace('respond with "%s" for "%s"',c,c),a(),{stream:l,protocol:c};if(c==="ls"){write(n,new Uint8ArrayList(...t.map(u=>encode$1(fromString$1(u)))),r),log$a.trace('respond with "%s" for %s',t,c);continue}write(n,fromString$1("na"),r),log$a('respond with "na" for "%s"',c)}}const symbol=Symbol.for("@libp2p/connection"),log$9=logger("libp2p:connection"),CLOSE_TIMEOUT=500;var ic,sc;class ConnectionImpl{constructor(t){Je(this,"id");Je(this,"remoteAddr");Je(this,"remotePeer");Je(this,"direction");Je(this,"timeline");Je(this,"multiplexer");Je(this,"encryption");Je(this,"status");Je(this,"transient");Je(this,"tags");Je(this,"_newStream");Je(this,"_close");Je(this,"_abort");Je(this,"_getStreams");Je(this,ic,"Connection");Je(this,sc,!0);const{remoteAddr:r,remotePeer:n,newStream:o,close:a,abort:l,getStreams:c}=t;this.id=`${parseInt(String(Math.random()*1e9)).toString(36)}${Date.now()}`,this.remoteAddr=r,this.remotePeer=n,this.direction=t.direction,this.status="open",this.timeline=t.timeline,this.multiplexer=t.multiplexer,this.encryption=t.encryption,this.transient=t.transient??!1,this._newStream=o,this._close=a,this._abort=l,this._getStreams=c,this.tags=[]}get streams(){return this._getStreams()}async newStream(t,r){if(this.status==="closing")throw new CodeError("the connection is being closed","ERR_CONNECTION_BEING_CLOSED");if(this.status==="closed")throw new CodeError("the connection is closed","ERR_CONNECTION_CLOSED");if(Array.isArray(t)||(t=[t]),this.transient&&r?.runOnTransientConnection!==!0)throw new CodeError("Cannot open protocol stream on transient connection","ERR_TRANSIENT_CONNECTION");const n=await this._newStream(t,r);return n.direction="outbound",n}async close(t={}){if(!(this.status==="closed"||this.status==="closing")){log$9("closing connection to %a",this.remoteAddr),this.status="closing",t.signal=t?.signal??AbortSignal.timeout(CLOSE_TIMEOUT);try{events$1.exports.setMaxListeners?.(1/0,t.signal)}catch{}try{await Promise.all(this.streams.map(async r=>r.close(t))),await this._close(t),this.timeline.close=Date.now(),this.status="closed"}catch(r){log$9.error("error encountered during graceful close of connection to %a",this.remoteAddr,r),this.abort(r)}}}abort(t){log$9.error("aborting connection to %a due to error",this.remoteAddr,t),this.status="closing",this.streams.forEach(r=>{r.abort(t)}),log$9.error("all streams aborted",this.streams.length),this._abort(t),this.timeline.close=Date.now(),this.status="closed"}}ic=Symbol.toStringTag,sc=symbol;function createConnection(e){return new ConnectionImpl(e)}const log$8=logger("libp2p:upgrader");function findIncomingStreamLimit(e,t){try{const{options:r}=t.getHandler(e);return r.maxInboundStreams}catch(r){if(r.code!==codes.ERR_NO_HANDLER_FOR_PROTOCOL)throw r}return DEFAULT_MAX_INBOUND_STREAMS}function findOutgoingStreamLimit(e,t,r={}){try{const{options:n}=t.getHandler(e);if(n.maxOutboundStreams!=null)return n.maxOutboundStreams}catch(n){if(n.code!==codes.ERR_NO_HANDLER_FOR_PROTOCOL)throw n}return r.maxOutboundStreams??DEFAULT_MAX_OUTBOUND_STREAMS}function countStreams(e,t,r){let n=0;return r.streams.forEach(o=>{o.direction===t&&o.protocol===e&&n++}),n}class DefaultUpgrader{constructor(t,r){Je(this,"components");Je(this,"connectionEncryption");Je(this,"muxers");Je(this,"inboundUpgradeTimeout");Je(this,"events");this.components=t,this.connectionEncryption=new Map,r.connectionEncryption.forEach(n=>{this.connectionEncryption.set(n.protocol,n)}),this.muxers=new Map,r.muxers.forEach(n=>{this.muxers.set(n.protocol,n)}),this.inboundUpgradeTimeout=r.inboundUpgradeTimeout??INBOUND_UPGRADE_TIMEOUT,this.events=t.events}async shouldBlockConnection(t,r,n){const o=this.components.connectionGater[n];if(o!==void 0&&await o(t,r))throw new CodeError(`The multiaddr connection is blocked by gater.${n}`,codes.ERR_CONNECTION_INTERCEPTED)}async upgradeInbound(t,r){if(!await this.components.connectionManager.acceptIncomingConnection(t))throw new CodeError("connection denied",codes.ERR_CONNECTION_DENIED);let o,a,l,c,u;const g=AbortSignal.timeout(this.inboundUpgradeTimeout),_=()=>{t.abort(new CodeError("inbound upgrade timeout",codes.ERR_TIMEOUT))};g.addEventListener("abort",_,{once:!0});try{events$1.exports.setMaxListeners?.(1/0,g)}catch{}try{if(await this.components.connectionGater.denyInboundConnection?.(t)===!0)throw new CodeError("The multiaddr connection is blocked by gater.acceptConnection",codes.ERR_CONNECTION_INTERCEPTED);this.components.metrics?.trackMultiaddrConnection(t),log$8("starting the inbound connection upgrade");let x=t;if(r?.skipProtection!==!0){const S=this.components.connectionProtector;S!=null&&(log$8("protecting the inbound connection"),x=await S.protect(t))}try{if(o=x,r?.skipEncryption!==!0){({conn:o,remotePeer:a,protocol:u}=await this._encryptInbound(x));const S={...x,...o};await this.shouldBlockConnection(a,S,"denyInboundEncryptedConnection")}else{const S=t.remoteAddr.getPeerId();if(S==null)throw new CodeError("inbound connection that skipped encryption must have a peer id",codes.ERR_INVALID_MULTIADDR);const O=peerIdFromString(S);u="native",a=O}if(l=o,r?.muxerFactory!=null)c=r.muxerFactory;else if(this.muxers.size>0){const S=await this._multiplexInbound({...x,...o},this.muxers);c=S.muxerFactory,l=S.stream}}catch(S){throw log$8.error("Failed to upgrade inbound connection",S),S}return await this.shouldBlockConnection(a,t,"denyInboundUpgradedConnection"),log$8("Successfully upgraded inbound connection"),this._createConnection({cryptoProtocol:u,direction:"inbound",maConn:t,upgradedConn:l,muxerFactory:c,remotePeer:a,transient:r?.transient})}finally{g.removeEventListener("abort",_),this.components.connectionManager.afterUpgradeInbound()}}async upgradeOutbound(t,r){const n=t.remoteAddr.getPeerId();let o;n!=null&&(o=peerIdFromString(n),await this.shouldBlockConnection(o,t,"denyOutboundConnection"));let a,l,c,u,g;this.components.metrics?.trackMultiaddrConnection(t),log$8("Starting the outbound connection upgrade");let _=t;if(r?.skipProtection!==!0){const x=this.components.connectionProtector;x!=null&&(_=await x.protect(t))}try{if(a=_,r?.skipEncryption!==!0){({conn:a,remotePeer:l,protocol:u}=await this._encryptOutbound(_,o));const x={..._,...a};await this.shouldBlockConnection(l,x,"denyOutboundEncryptedConnection")}else{if(o==null)throw new CodeError("Encryption was skipped but no peer id was passed",codes.ERR_INVALID_PEER);u="native",l=o}if(c=a,r?.muxerFactory!=null)g=r.muxerFactory;else if(this.muxers.size>0){const x=await this._multiplexOutbound({..._,...a},this.muxers);g=x.muxerFactory,c=x.stream}}catch(x){throw log$8.error("Failed to upgrade outbound connection",x),await t.close(x),x}return await this.shouldBlockConnection(l,t,"denyOutboundUpgradedConnection"),log$8("Successfully upgraded outbound connection"),this._createConnection({cryptoProtocol:u,direction:"outbound",maConn:t,upgradedConn:c,muxerFactory:g,remotePeer:l,transient:r?.transient})}_createConnection(t){const{cryptoProtocol:r,direction:n,maConn:o,upgradedConn:a,remotePeer:l,muxerFactory:c,transient:u}=t;let g,_,x;c!=null&&(g=c.createStreamMuxer({direction:n,onIncomingStream:E=>{x!=null&&Promise.resolve().then(async()=>{const T=this.components.registrar.getProtocols(),{stream:D,protocol:$}=await handle(E,T);if(log$8("%s: incoming stream opened on %s",n,$),x==null)return;const I=findIncomingStreamLimit($,this.components.registrar);if(countStreams($,"inbound",x)===I){const se=new CodeError(`Too many inbound protocol streams for protocol "${$}" - limit ${I}`,codes.ERR_TOO_MANY_INBOUND_PROTOCOL_STREAMS);throw E.abort(se),se}E.source=D.source,E.sink=D.sink,E.protocol=$,await this.components.peerStore.merge(l,{protocols:[$]}),this.components.metrics?.trackProtocolStream(E,x),this._onStream({connection:x,stream:E,protocol:$})}).catch(async T=>{log$8.error(T),E.timeline.close==null&&await E.close()})}}),_=async(E,T={})=>{if(g==null)throw new CodeError("Stream is not multiplexed",codes.ERR_MUXER_UNAVAILABLE);log$8("%s: starting new stream on %s",n,E);const D=await g.newStream();try{if(T.signal==null){log$8("No abort signal was passed while trying to negotiate protocols %s falling back to default timeout",E),T.signal=AbortSignal.timeout(3e4);try{events$1.exports.setMaxListeners?.(1/0,T.signal)}catch{}}const{stream:$,protocol:I}=await select(D,E,T),H=findOutgoingStreamLimit(I,this.components.registrar,T);if(countStreams(I,"outbound",x)>=H){const ie=new CodeError(`Too many outbound protocol streams for protocol "${I}" - limit ${H}`,codes.ERR_TOO_MANY_OUTBOUND_PROTOCOL_STREAMS);throw D.abort(ie),ie}return await this.components.peerStore.merge(l,{protocols:[I]}),D.source=$.source,D.sink=$.sink,D.protocol=I,this.components.metrics?.trackProtocolStream(D,x),D}catch($){throw log$8.error("could not create new stream",$),D.timeline.close==null&&D.abort($),$.code!=null?$:new CodeError(String($),codes.ERR_UNSUPPORTED_PROTOCOL)}},Promise.all([g.sink(a.source),a.sink(g.source)]).catch(E=>{log$8.error(E)}));const S=o.timeline;o.timeline=new Proxy(S,{set:(...E)=>(x!=null&&E[1]==="close"&&E[2]!=null&&S.close==null&&(async()=>{try{x.status==="open"&&await x.close()}catch(T){log$8.error(T)}finally{this.events.safeDispatchEvent("connection:close",{detail:x})}})().catch(T=>{log$8.error(T)}),Reflect.set(...E))}),o.timeline.upgraded=Date.now();const O=()=>{throw new CodeError("connection is not multiplexed",codes.ERR_CONNECTION_NOT_MULTIPLEXED)};return x=createConnection({remoteAddr:o.remoteAddr,remotePeer:l,status:"open",direction:n,timeline:o.timeline,multiplexer:g?.protocol,encryption:r,transient:u,newStream:_??O,getStreams:()=>g!=null?g.streams:[],close:async E=>{await o.close(E),g!=null&&await g.close(E)},abort:E=>{o.abort(E),g?.abort(E)}}),this.events.safeDispatchEvent("connection:open",{detail:x}),x}_onStream(t){const{connection:r,stream:n,protocol:o}=t,{handler:a,options:l}=this.components.registrar.getHandler(o);if(r.transient&&l.runOnTransientConnection!==!0)throw new CodeError("Cannot open protocol stream on transient connection","ERR_TRANSIENT_CONNECTION");a({connection:r,stream:n})}async _encryptInbound(t){const r=Array.from(this.connectionEncryption.keys());log$8("handling inbound crypto protocol selection",r);try{const{stream:n,protocol:o}=await handle(t,r,{writeBytes:!0}),a=this.connectionEncryption.get(o);if(a==null)throw new Error(`no crypto module found for ${o}`);return log$8("encrypting inbound connection..."),{...await a.secureInbound(this.components.peerId,n),protocol:o}}catch(n){throw new CodeError(String(n),codes.ERR_ENCRYPTION_FAILED)}}async _encryptOutbound(t,r){const n=Array.from(this.connectionEncryption.keys());log$8("selecting outbound crypto protocol",n);try{const{stream:o,protocol:a}=await select(t,n,{writeBytes:!0}),l=this.connectionEncryption.get(a);if(l==null)throw new Error(`no crypto module found for ${a}`);return log$8("encrypting outbound connection to %p",r),{...await l.secureOutbound(this.components.peerId,o,r),protocol:a}}catch(o){throw new CodeError(String(o),codes.ERR_ENCRYPTION_FAILED)}}async _multiplexOutbound(t,r){const n=Array.from(r.keys());log$8("outbound selecting muxer %s",n);try{const{stream:o,protocol:a}=await select(t,n,{writeBytes:!0});log$8("%s selected as muxer protocol",a);const l=r.get(a);return{stream:o,muxerFactory:l}}catch(o){throw log$8.error("error multiplexing outbound stream",o),new CodeError(String(o),codes.ERR_MUXER_UNAVAILABLE)}}async _multiplexInbound(t,r){const n=Array.from(r.keys());log$8("inbound handling muxers %s",n);try{const{stream:o,protocol:a}=await handle(t,n,{writeBytes:!0}),l=r.get(a);return{stream:o,muxerFactory:l}}catch(o){throw log$8.error("error multiplexing inbound stream",o),new CodeError(String(o),codes.ERR_MUXER_UNAVAILABLE)}}}const log$7=logger("libp2p");var wn,gs,ya;class Libp2pNode extends EventEmitter$2{constructor(r){super();Er(this,gs);Je(this,"peerId");Je(this,"peerStore");Je(this,"contentRouting");Je(this,"peerRouting");Je(this,"keychain");Je(this,"metrics");Je(this,"services");Je(this,"components");Er(this,wn,void 0);const n=new EventEmitter$2,o=n.dispatchEvent.bind(n);n.dispatchEvent=g=>{const _=o(g),x=this.dispatchEvent(new CustomEvent$1(g.type,{detail:g.detail}));return _||x};try{events$1.exports.setMaxListeners?.(1/0,n)}catch{}Ln(this,wn,!1),this.peerId=r.peerId,this.services={};const a=this.components=defaultComponents({peerId:r.peerId,events:n,datastore:r.datastore??new MemoryDatastore,connectionGater:connectionGater(r.connectionGater)});this.peerStore=this.configureComponent("peerStore",new PersistentPeerStore(a,{addressFilter:this.components.connectionGater.filterMultiaddrForPeer,...r.peerStore})),r.metrics!=null&&(this.metrics=this.configureComponent("metrics",r.metrics(this.components))),a.events.addEventListener("peer:update",g=>{if(g.detail.previous==null){const _={id:g.detail.peer.id,multiaddrs:g.detail.peer.addresses.map(x=>x.multiaddr),protocols:g.detail.peer.protocols};a.events.safeDispatchEvent("peer:discovery",{detail:_})}}),r.connectionProtector!=null&&this.configureComponent("connectionProtector",r.connectionProtector(a)),this.components.upgrader=new DefaultUpgrader(this.components,{connectionEncryption:(r.connectionEncryption??[]).map((g,_)=>this.configureComponent(`connection-encryption-${_}`,g(this.components))),muxers:(r.streamMuxers??[]).map((g,_)=>this.configureComponent(`stream-muxers-${_}`,g(this.components))),inboundUpgradeTimeout:r.connectionManager.inboundUpgradeTimeout}),this.configureComponent("transportManager",new DefaultTransportManager(this.components,r.transportManager)),this.configureComponent("connectionManager",new DefaultConnectionManager(this.components,r.connectionManager)),this.configureComponent("registrar",new DefaultRegistrar(this.components)),this.configureComponent("addressManager",new DefaultAddressManager(this.components,r.addresses));const l=DefaultKeyChain.generateOptions();this.keychain=this.configureComponent("keyChain",new DefaultKeyChain(this.components,{...l,...r.keychain}));const c=(r.peerRouters??[]).map((g,_)=>this.configureComponent(`peer-router-${_}`,g(this.components)));this.peerRouting=this.components.peerRouting=this.configureComponent("peerRouting",new DefaultPeerRouting(this.components,{routers:c}));const u=(r.contentRouters??[]).map((g,_)=>this.configureComponent(`content-router-${_}`,g(this.components)));if(this.contentRouting=this.components.contentRouting=this.configureComponent("contentRouting",new CompoundContentRouting(this.components,{routers:u})),(r.peerDiscovery??[]).forEach((g,_)=>{this.configureComponent(`peer-discovery-${_}`,g(this.components)).addEventListener("peer",S=>{wr(this,gs,ya).call(this,S)})}),r.transports.forEach((g,_)=>{this.components.transportManager.add(this.configureComponent(`transport-${_}`,g(this.components)))}),r.services!=null)for(const g of Object.keys(r.services)){const _=r.services[g],x=_(this.components);if(x==null){log$7.error("service factory %s returned null or undefined instance",g);continue}this.services[g]=x,this.configureComponent(g,x),x[contentRouting]!=null&&(log$7("registering service %s for content routing",g),u.push(x[contentRouting])),x[peerRouting]!=null&&(log$7("registering service %s for peer routing",g),c.push(x[peerRouting])),x[peerDiscovery]!=null&&(log$7("registering service %s for peer discovery",g),x[peerDiscovery].addEventListener("peer",S=>{wr(this,gs,ya).call(this,S)}))}}configureComponent(r,n){return n==null&&log$7.error("component %s was null or undefined",r),this.components[r]=n,n}async start(){if(ir(this,wn))return;Ln(this,wn,!0),log$7("libp2p is starting"),(await this.keychain.listKeys()).find(n=>n.name==="self")==null&&(log$7("importing self key into keychain"),await this.keychain.importPeer("self",this.components.peerId));try{await this.components.beforeStart?.(),await this.components.start(),await this.components.afterStart?.(),this.safeDispatchEvent("start",{detail:this}),log$7("libp2p has started")}catch(n){throw log$7.error("An error occurred starting libp2p",n),await this.stop(),n}}async stop(){!ir(this,wn)||(log$7("libp2p is stopping"),Ln(this,wn,!1),await this.components.beforeStop?.(),await this.components.stop(),await this.components.afterStop?.(),this.safeDispatchEvent("stop",{detail:this}),log$7("libp2p has stopped"))}isStarted(){return ir(this,wn)}getConnections(r){return this.components.connectionManager.getConnections(r)}getDialQueue(){return this.components.connectionManager.getDialQueue()}getPeers(){const r=new PeerSet;for(const n of this.components.connectionManager.getConnections())r.add(n.remotePeer);return Array.from(r)}async dial(r,n={}){return this.components.connectionManager.openConnection(r,n)}async dialProtocol(r,n,o={}){if(n==null)throw new CodeError("no protocols were provided to open a stream",codes.ERR_INVALID_PROTOCOLS_FOR_STREAM);if(n=Array.isArray(n)?n:[n],n.length===0)throw new CodeError("no protocols were provided to open a stream",codes.ERR_INVALID_PROTOCOLS_FOR_STREAM);return(await this.dial(r,o)).newStream(n,o)}getMultiaddrs(){return this.components.addressManager.getAddresses()}getProtocols(){return this.components.registrar.getProtocols()}async hangUp(r,n={}){isMultiaddr(r)&&(r=peerIdFromString(r.getPeerId()??"")),await this.components.connectionManager.closeConnections(r,n)}async getPublicKey(r,n={}){if(log$7("getPublicKey %p",r),r.publicKey!=null)return r.publicKey;const o=await this.peerStore.get(r);if(o.id.publicKey!=null)return o.id.publicKey;const a=concat$1([fromString$1("/pk/"),r.multihash.digest]),l=await this.contentRouting.get(a,n);return unmarshalPublicKey(l),await this.peerStore.patch(r,{publicKey:l}),l}async handle(r,n,o){Array.isArray(r)||(r=[r]),await Promise.all(r.map(async a=>{await this.components.registrar.handle(a,n,o)}))}async unhandle(r){Array.isArray(r)||(r=[r]),await Promise.all(r.map(async n=>{await this.components.registrar.unhandle(n)}))}async register(r,n){return this.components.registrar.register(r,n)}unregister(r){this.components.registrar.unregister(r)}}wn=new WeakMap,gs=new WeakSet,ya=function(r){const{detail:n}=r;if(n.id.toString()===this.peerId.toString()){log$7.error(new Error(codes.ERR_DISCOVERED_SELF));return}this.components.peerStore.merge(n.id,{multiaddrs:n.multiaddrs,protocols:n.protocols}).catch(o=>{log$7.error(o)})};async function createLibp2pNode(e){if(e.peerId==null){const t=e.datastore;if(t!=null)try{const r=new DefaultKeyChain({datastore:t},mergeOptions(DefaultKeyChain.generateOptions(),e.keychain));e.peerId=await r.exportPeerId("self")}catch(r){if(r.code!=="ERR_NOT_FOUND")throw r}}return e.peerId==null&&(e.peerId=await createEd25519PeerId()),new Libp2pNode(validateConfig(e))}async function createLibp2p(e){const t=await createLibp2pNode(e);return e.start!==!1&&await t.start(),t}const CIRCUIT_PROTO_CODE=290,RELAY_RENDEZVOUS_NS="/libp2p/relay",DEFAULT_RESERVATION_CONCURRENCY=1,RELAY_TAG="circuit-relay-relay";BigInt(1<<17);const RELAY_V2_HOP_CODEC="/libp2p/circuit/relay/0.2.0/hop",RELAY_V2_STOP_CODEC="/libp2p/circuit/relay/0.2.0/stop";var HopMessage;(function(e){(function(n){n.RESERVE="RESERVE",n.CONNECT="CONNECT",n.STATUS="STATUS"})(e.Type||(e.Type={}));let t;(function(n){n[n.RESERVE=0]="RESERVE",n[n.CONNECT=1]="CONNECT",n[n.STATUS=2]="STATUS"})(t||(t={})),function(n){n.codec=()=>enumeration(t)}(e.Type||(e.Type={}));let r;e.codec=()=>(r==null&&(r=message((n,o,a={})=>{a.lengthDelimited!==!1&&o.fork(),n.type!=null&&(o.uint32(8),e.Type.codec().encode(n.type,o)),n.peer!=null&&(o.uint32(18),Peer.codec().encode(n.peer,o)),n.reservation!=null&&(o.uint32(26),Reservation.codec().encode(n.reservation,o)),n.limit!=null&&(o.uint32(34),Limit.codec().encode(n.limit,o)),n.status!=null&&(o.uint32(40),Status.codec().encode(n.status,o)),a.lengthDelimited!==!1&&o.ldelim()},(n,o)=>{const a={},l=o==null?n.len:n.pos+o;for(;n.pos>>3){case 1:a.type=e.Type.codec().decode(n);break;case 2:a.peer=Peer.codec().decode(n,n.uint32());break;case 3:a.reservation=Reservation.codec().decode(n,n.uint32());break;case 4:a.limit=Limit.codec().decode(n,n.uint32());break;case 5:a.status=Status.codec().decode(n);break;default:n.skipType(c&7);break}}return a})),r),e.encode=n=>encodeMessage(n,e.codec()),e.decode=n=>decodeMessage(n,e.codec())})(HopMessage||(HopMessage={}));var StopMessage;(function(e){(function(n){n.CONNECT="CONNECT",n.STATUS="STATUS"})(e.Type||(e.Type={}));let t;(function(n){n[n.CONNECT=0]="CONNECT",n[n.STATUS=1]="STATUS"})(t||(t={})),function(n){n.codec=()=>enumeration(t)}(e.Type||(e.Type={}));let r;e.codec=()=>(r==null&&(r=message((n,o,a={})=>{a.lengthDelimited!==!1&&o.fork(),n.type!=null&&(o.uint32(8),e.Type.codec().encode(n.type,o)),n.peer!=null&&(o.uint32(18),Peer.codec().encode(n.peer,o)),n.limit!=null&&(o.uint32(26),Limit.codec().encode(n.limit,o)),n.status!=null&&(o.uint32(32),Status.codec().encode(n.status,o)),a.lengthDelimited!==!1&&o.ldelim()},(n,o)=>{const a={},l=o==null?n.len:n.pos+o;for(;n.pos>>3){case 1:a.type=e.Type.codec().decode(n);break;case 2:a.peer=Peer.codec().decode(n,n.uint32());break;case 3:a.limit=Limit.codec().decode(n,n.uint32());break;case 4:a.status=Status.codec().decode(n);break;default:n.skipType(c&7);break}}return a})),r),e.encode=n=>encodeMessage(n,e.codec()),e.decode=n=>decodeMessage(n,e.codec())})(StopMessage||(StopMessage={}));var Peer;(function(e){let t;e.codec=()=>(t==null&&(t=message((r,n,o={})=>{if(o.lengthDelimited!==!1&&n.fork(),r.id!=null&&r.id.byteLength>0&&(n.uint32(10),n.bytes(r.id)),r.addrs!=null)for(const a of r.addrs)n.uint32(18),n.bytes(a);o.lengthDelimited!==!1&&n.ldelim()},(r,n)=>{const o={id:new Uint8Array(0),addrs:[]},a=n==null?r.len:r.pos+n;for(;r.pos>>3){case 1:o.id=r.bytes();break;case 2:o.addrs.push(r.bytes());break;default:r.skipType(l&7);break}}return o})),t),e.encode=r=>encodeMessage(r,e.codec()),e.decode=r=>decodeMessage(r,e.codec())})(Peer||(Peer={}));var Reservation;(function(e){let t;e.codec=()=>(t==null&&(t=message((r,n,o={})=>{if(o.lengthDelimited!==!1&&n.fork(),r.expire!=null&&r.expire!==0n&&(n.uint32(8),n.uint64(r.expire)),r.addrs!=null)for(const a of r.addrs)n.uint32(18),n.bytes(a);r.voucher!=null&&(n.uint32(26),n.bytes(r.voucher)),o.lengthDelimited!==!1&&n.ldelim()},(r,n)=>{const o={expire:0n,addrs:[]},a=n==null?r.len:r.pos+n;for(;r.pos>>3){case 1:o.expire=r.uint64();break;case 2:o.addrs.push(r.bytes());break;case 3:o.voucher=r.bytes();break;default:r.skipType(l&7);break}}return o})),t),e.encode=r=>encodeMessage(r,e.codec()),e.decode=r=>decodeMessage(r,e.codec())})(Reservation||(Reservation={}));var Limit;(function(e){let t;e.codec=()=>(t==null&&(t=message((r,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),r.duration!=null&&(n.uint32(8),n.uint32(r.duration)),r.data!=null&&(n.uint32(16),n.uint64(r.data)),o.lengthDelimited!==!1&&n.ldelim()},(r,n)=>{const o={},a=n==null?r.len:r.pos+n;for(;r.pos>>3){case 1:o.duration=r.uint32();break;case 2:o.data=r.uint64();break;default:r.skipType(l&7);break}}return o})),t),e.encode=r=>encodeMessage(r,e.codec()),e.decode=r=>decodeMessage(r,e.codec())})(Limit||(Limit={}));var Status;(function(e){e.UNUSED="UNUSED",e.OK="OK",e.RESERVATION_REFUSED="RESERVATION_REFUSED",e.RESOURCE_LIMIT_EXCEEDED="RESOURCE_LIMIT_EXCEEDED",e.PERMISSION_DENIED="PERMISSION_DENIED",e.CONNECTION_FAILED="CONNECTION_FAILED",e.NO_RESERVATION="NO_RESERVATION",e.MALFORMED_MESSAGE="MALFORMED_MESSAGE",e.UNEXPECTED_MESSAGE="UNEXPECTED_MESSAGE"})(Status||(Status={}));var __StatusValues;(function(e){e[e.UNUSED=0]="UNUSED",e[e.OK=100]="OK",e[e.RESERVATION_REFUSED=200]="RESERVATION_REFUSED",e[e.RESOURCE_LIMIT_EXCEEDED=201]="RESOURCE_LIMIT_EXCEEDED",e[e.PERMISSION_DENIED=202]="PERMISSION_DENIED",e[e.CONNECTION_FAILED=203]="CONNECTION_FAILED",e[e.NO_RESERVATION=204]="NO_RESERVATION",e[e.MALFORMED_MESSAGE=400]="MALFORMED_MESSAGE",e[e.UNEXPECTED_MESSAGE=401]="UNEXPECTED_MESSAGE"})(__StatusValues||(__StatusValues={}));(function(e){e.codec=()=>enumeration(__StatusValues)})(Status||(Status={}));var ReservationVoucher;(function(e){let t;e.codec=()=>(t==null&&(t=message((r,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),r.relay!=null&&r.relay.byteLength>0&&(n.uint32(10),n.bytes(r.relay)),r.peer!=null&&r.peer.byteLength>0&&(n.uint32(18),n.bytes(r.peer)),r.expiration!=null&&r.expiration!==0n&&(n.uint32(24),n.uint64(r.expiration)),o.lengthDelimited!==!1&&n.ldelim()},(r,n)=>{const o={relay:new Uint8Array(0),peer:new Uint8Array(0),expiration:0n},a=n==null?r.len:r.pos+n;for(;r.pos>>3){case 1:o.relay=r.bytes();break;case 2:o.peer=r.bytes();break;case 3:o.expiration=r.uint64();break;default:r.skipType(l&7);break}}return o})),t),e.encode=r=>encodeMessage(r,e.codec()),e.decode=r=>decodeMessage(r,e.codec())})(ReservationVoucher||(ReservationVoucher={}));logger("libp2p:circuit-relay:utils");async function namespaceToCid(e){const t=new TextEncoder().encode(e),r=await sha256$1.digest(t);return CID.createV0(r)}function getExpirationMilliseconds(e){const t=e*BigInt(1e3),r=new Date().getTime();return Number(t-BigInt(r))}var retry$1={exports:{}},retry={};function RetryOperation(e,t){typeof t=="boolean"&&(t={forever:t}),this._originalTimeouts=JSON.parse(JSON.stringify(e)),this._timeouts=e,this._options=t||{},this._maxRetryTime=t&&t.maxRetryTime||1/0,this._fn=null,this._errors=[],this._attempts=1,this._operationTimeout=null,this._operationTimeoutCb=null,this._timeout=null,this._operationStart=null,this._timer=null,this._options.forever&&(this._cachedTimeouts=this._timeouts.slice(0))}var retry_operation=RetryOperation;RetryOperation.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts.slice(0)};RetryOperation.prototype.stop=function(){this._timeout&&clearTimeout(this._timeout),this._timer&&clearTimeout(this._timer),this._timeouts=[],this._cachedTimeouts=null};RetryOperation.prototype.retry=function(e){if(this._timeout&&clearTimeout(this._timeout),!e)return!1;var t=new Date().getTime();if(e&&t-this._operationStart>=this._maxRetryTime)return this._errors.push(e),this._errors.unshift(new Error("RetryOperation timeout occurred")),!1;this._errors.push(e);var r=this._timeouts.shift();if(r===void 0)if(this._cachedTimeouts)this._errors.splice(0,this._errors.length-1),r=this._cachedTimeouts.slice(-1);else return!1;var n=this;return this._timer=setTimeout(function(){n._attempts++,n._operationTimeoutCb&&(n._timeout=setTimeout(function(){n._operationTimeoutCb(n._attempts)},n._operationTimeout),n._options.unref&&n._timeout.unref()),n._fn(n._attempts)},r),this._options.unref&&this._timer.unref(),!0};RetryOperation.prototype.attempt=function(e,t){this._fn=e,t&&(t.timeout&&(this._operationTimeout=t.timeout),t.cb&&(this._operationTimeoutCb=t.cb));var r=this;this._operationTimeoutCb&&(this._timeout=setTimeout(function(){r._operationTimeoutCb()},r._operationTimeout)),this._operationStart=new Date().getTime(),this._fn(this._attempts)};RetryOperation.prototype.try=function(e){console.log("Using RetryOperation.try() is deprecated"),this.attempt(e)};RetryOperation.prototype.start=function(e){console.log("Using RetryOperation.start() is deprecated"),this.attempt(e)};RetryOperation.prototype.start=RetryOperation.prototype.try;RetryOperation.prototype.errors=function(){return this._errors};RetryOperation.prototype.attempts=function(){return this._attempts};RetryOperation.prototype.mainError=function(){if(this._errors.length===0)return null;for(var e={},t=null,r=0,n=0;n=r&&(t=o,r=l)}return t};(function(e){var t=retry_operation;e.operation=function(r){var n=e.timeouts(r);return new t(n,{forever:r&&(r.forever||r.retries===1/0),unref:r&&r.unref,maxRetryTime:r&&r.maxRetryTime})},e.timeouts=function(r){if(r instanceof Array)return[].concat(r);var n={retries:10,factor:2,minTimeout:1*1e3,maxTimeout:1/0,randomize:!1};for(var o in r)n[o]=r[o];if(n.minTimeout>n.maxTimeout)throw new Error("minTimeout is greater than maxTimeout");for(var a=[],l=0;l{this.safeDispatchEvent("relay:discover",{detail:r})}}),this.discover().catch(r=>{log$5.error("error listening on relays",r)}),this.started=!0}stop(){this.topologyId!=null&&this.registrar.unregister(this.topologyId),this.started=!1}async discover(){log$5("searching peer store for relays");const r=await this.peerStore.all({filters:[n=>n.protocols.includes(RELAY_V2_HOP_CODEC)],orders:[()=>Math.random()<.5?1:-1]});for(const n of r)log$5("found relay peer %p in content peer store",n.id),this.safeDispatchEvent("relay:discover",{detail:n.id});log$5("found %d relay peers in peer store",r.length);try{log$5("searching content routing for relays");const n=await namespaceToCid(RELAY_RENDEZVOUS_NS);let o=0;for await(const a of this.contentRouting.findProviders(n))if(a.multiaddrs.length>0&&!a.id.equals(this.peerId)){const l=a.id;o++,await this.peerStore.merge(l,{multiaddrs:a.multiaddrs}),log$5("found relay peer %p in content routing",l),this.safeDispatchEvent("relay:discover",{detail:l})}log$5("found %d relay peers in content routing",o)}catch(n){log$5.error("failed when finding relays on the network",n)}}}const log$4=logger("libp2p:circuit-relay:transport:listener");var bo,Va;class CircuitRelayTransportListener extends EventEmitter$2{constructor(r){super();Er(this,bo);Je(this,"connectionManager");Je(this,"relayStore");Je(this,"listeningAddrs");this.connectionManager=r.connectionManager,this.relayStore=r.relayStore,this.listeningAddrs=new PeerMap,this.relayStore.addEventListener("relay:removed",n=>{wr(this,bo,Va).call(this,n.detail)})}async listen(r){log$4("listen on %a",r);const n=r.getPeerId();let o;if(n!=null){const l=peerIdFromString(n),c=this.connectionManager.getConnectionsMap().get(l)??[];c.length>0&&(o=c[0])}if(o==null){const l=r.toString().split("/p2p-circuit").find(u=>u!==""),c=multiaddr(l);o=await this.connectionManager.openConnection(c)}if(!this.relayStore.hasReservation(o.remotePeer)){await this.relayStore.addRelay(o.remotePeer,"configured");return}const a=this.relayStore.getReservation(o.remotePeer);if(a==null)throw new CodeError("Did not have reservation after making reservation","ERR_NO_RESERVATION");if(this.listeningAddrs.has(o.remotePeer)){log$4("already listening on relay %p",o.remotePeer);return}this.listeningAddrs.set(o.remotePeer,a.addrs.map(l=>multiaddr(l).encapsulate("/p2p-circuit"))),this.safeDispatchEvent("listening",{})}getAddrs(){return[...this.listeningAddrs.values()].flat()}async close(){}}bo=new WeakSet,Va=function(r){const n=this.listeningAddrs.has(r);log$4("relay peer removed %p - had reservation",r,n),this.listeningAddrs.delete(r),n&&this.safeDispatchEvent("close",{})};function createListener(e){return new CircuitRelayTransportListener(e)}const log$3=logger("libp2p:circuit-relay:transport:reservation-store"),REFRESH_WINDOW=60*1e3*10,REFRESH_TIMEOUT=60*1e3*5,REFRESH_TIMEOUT_MIN=30*1e3;var _o,Ha,xo,za;class ReservationStore extends EventEmitter$2{constructor(r,n){super();Er(this,_o);Er(this,xo);Je(this,"peerId");Je(this,"connectionManager");Je(this,"transportManager");Je(this,"peerStore");Je(this,"events");Je(this,"reserveQueue");Je(this,"reservations");Je(this,"maxDiscoveredRelays");Je(this,"maxReservationQueueLength");Je(this,"reservationCompletionTimeout");Je(this,"started");this.peerId=r.peerId,this.connectionManager=r.connectionManager,this.transportManager=r.transportManager,this.peerStore=r.peerStore,this.events=r.events,this.reservations=new PeerMap,this.maxDiscoveredRelays=n?.discoverRelays??0,this.maxReservationQueueLength=n?.maxReservationQueueLength??100,this.reservationCompletionTimeout=n?.reservationCompletionTimeout??1e4,this.started=!1,this.reserveQueue=new PeerJobQueue({concurrency:n?.reservationConcurrency??DEFAULT_RESERVATION_CONCURRENCY}),this.events.addEventListener("peer:disconnect",o=>{wr(this,xo,za).call(this,o.detail)})}isStarted(){return this.started}async start(){this.started=!0}async stop(){this.reserveQueue.clear(),this.reservations.forEach(({timeout:r})=>{clearTimeout(r)}),this.reservations.clear(),this.started=!1}async addRelay(r,n){if(this.peerId.equals(r)){log$3("not trying to use self as relay");return}if(this.reserveQueue.size>this.maxReservationQueueLength){log$3("not adding relay as the queue is full");return}if(this.reserveQueue.hasJob(r)){log$3("relay peer is already in the reservation queue");return}log$3("add relay %p",r),await this.reserveQueue.add(async()=>{try{const o=this.reservations.get(r);if(o!=null){if(getExpirationMilliseconds(o.reservation.expire)>REFRESH_WINDOW){log$3("already have reservation on relay peer %p and it expires in more than 10 minutes",r);return}clearTimeout(o.timeout),this.reservations.delete(r)}if(n==="discovered"&&[...this.reservations.values()].reduce((x,S)=>(S.type==="discovered"&&x++,x),0)>=this.maxDiscoveredRelays){log$3("already have enough discovered relays");return}const a=AbortSignal.timeout(this.reservationCompletionTimeout),l=await this.connectionManager.openConnection(r,{signal:a});if(l.remoteAddr.protoNames().includes("p2p-circuit")){log$3("not creating reservation over relayed connection");return}const c=await wr(this,_o,Ha).call(this,l,{signal:a});log$3("created reservation on relay peer %p",r);const u=getExpirationMilliseconds(c.expire),g=Math.min(Math.max(u-REFRESH_TIMEOUT,REFRESH_TIMEOUT_MIN),Math.pow(2,31)-1),_=setTimeout(()=>{this.addRelay(r,n).catch(x=>{log$3.error("could not refresh reservation to relay %p",r,x)})},g);this.reservations.set(r,{timeout:_,reservation:c,type:n}),await this.peerStore.merge(r,{tags:{[RELAY_TAG]:{value:1,ttl:u}}}),await this.transportManager.listen([multiaddr(`/p2p/${r.toString()}/p2p-circuit`)])}catch(o){log$3.error("could not reserve slot on %p",r,o);const a=this.reservations.get(r);a!=null&&clearTimeout(a.timeout),this.reservations.delete(r)}},{peerId:r})}hasReservation(r){return this.reservations.has(r)}getReservation(r){return this.reservations.get(r)?.reservation}}_o=new WeakSet,Ha=async function(r,n){n.signal?.throwIfAborted(),log$3("requesting reservation from %p",r.remotePeer);const o=await r.newStream(RELAY_V2_HOP_CODEC,n),l=pbStream(o).pb(HopMessage);await l.write({type:HopMessage.Type.RESERVE},n);let c;try{c=await l.read(n)}catch(g){throw log$3.error("error parsing reserve message response from %p because",r.remotePeer,g),g}finally{await o.close()}if(c.status===Status.OK&&c.reservation!=null)return c.reservation;const u=`reservation failed with status ${c.status??"undefined"}`;throw log$3.error(u),new Error(u)},xo=new WeakSet,za=function(r){const n=this.reservations.get(r);n!=null&&(log$3("connection to relay %p closed, removing reservation from local store",r),clearTimeout(n.timeout),this.reservations.delete(r),this.safeDispatchEvent("relay:removed",{detail:r}),this.reservations.size{if(e.peer==null)return!1;try{e.peer.addrs.forEach(multiaddr)}catch{return!1}return!0},defaults={maxInboundStopStreams:MAX_CONNECTIONS,maxOutboundStopStreams:MAX_CONNECTIONS,stopTimeout:3e4};var oc,ac;class CircuitRelayTransport{constructor(t,r){Je(this,"discovery");Je(this,"registrar");Je(this,"peerStore");Je(this,"connectionManager");Je(this,"peerId");Je(this,"upgrader");Je(this,"addressManager");Je(this,"connectionGater");Je(this,"reservationStore");Je(this,"maxInboundStopStreams");Je(this,"maxOutboundStopStreams");Je(this,"stopTimeout");Je(this,"started");Je(this,oc,!0);Je(this,ac,"libp2p/circuit-relay-v2");this.registrar=t.registrar,this.peerStore=t.peerStore,this.connectionManager=t.connectionManager,this.peerId=t.peerId,this.upgrader=t.upgrader,this.addressManager=t.addressManager,this.connectionGater=t.connectionGater,this.maxInboundStopStreams=r.maxInboundStopStreams??defaults.maxInboundStopStreams,this.maxOutboundStopStreams=r.maxOutboundStopStreams??defaults.maxOutboundStopStreams,this.stopTimeout=r.stopTimeout??defaults.stopTimeout,r.discoverRelays!=null&&r.discoverRelays>0&&(this.discovery=new RelayDiscovery(t),this.discovery.addEventListener("relay:discover",n=>{this.reservationStore.addRelay(n.detail,"discovered").catch(o=>{log$2.error("could not add discovered relay %p",n.detail,o)})})),this.reservationStore=new ReservationStore(t,r),this.reservationStore.addEventListener("relay:not-enough-relays",()=>{this.discovery?.discover().catch(n=>{log$2.error("could not discover relays",n)})}),this.started=!1}isStarted(){return this.started}async start(){await this.reservationStore.start(),await this.discovery?.start(),await this.registrar.handle(RELAY_V2_STOP_CODEC,t=>{this.onStop(t).catch(r=>{log$2.error("error while handling STOP protocol",r),t.stream.abort(r)})},{maxInboundStreams:this.maxInboundStopStreams,maxOutboundStreams:this.maxOutboundStopStreams,runOnTransientConnection:!0}),this.started=!0}async stop(){this.discovery?.stop(),await this.reservationStore.stop(),await this.registrar.unhandle(RELAY_V2_STOP_CODEC),this.started=!1}async dial(t,r={}){if(t.protoCodes().filter(E=>E===CIRCUIT_PROTO_CODE).length!==1){const E="Invalid circuit relay address";throw log$2.error(E,t),new CodeError(E,codes.ERR_RELAYED_DIAL)}const n=t.toString().split("/p2p-circuit"),o=multiaddr(n[0]),a=multiaddr(n[n.length-1]),l=o.getPeerId(),c=a.getPeerId();if(l==null||c==null){const E=`Circuit relay dial to ${t.toString()} failed as address did not have peer ids`;throw log$2.error(E),new CodeError(E,codes.ERR_RELAYED_DIAL)}const u=peerIdFromString(l),g=peerIdFromString(c);let _=!1,S=this.connectionManager.getConnections(u)[0];S==null&&(await this.peerStore.merge(u,{multiaddrs:[o]}),S=await this.connectionManager.openConnection(u,r),_=!0);let O;try{return O=await S.newStream([RELAY_V2_HOP_CODEC]),await this.connectV2({stream:O,connection:S,destinationPeer:g,destinationAddr:a,relayAddr:o,ma:t,disconnectOnFailure:_})}catch(E){throw log$2.error(`Circuit relay dial to destination ${g.toString()} via relay ${u.toString()} failed`,E),O?.abort(E),_&&await S.close(),E}}async connectV2({stream:t,connection:r,destinationPeer:n,destinationAddr:o,relayAddr:a,ma:l,disconnectOnFailure:c}){try{const u=pbStream(t),g=u.pb(HopMessage);await g.write({type:HopMessage.Type.CONNECT,peer:{id:n.toBytes(),addrs:[multiaddr(o).bytes]}});const _=await g.read();if(_.status!==Status.OK)throw new CodeError(`failed to connect via relay with status ${_?.status?.toString()??"undefined"}`,codes.ERR_HOP_REQUEST_FAILED);const x=streamToMaConnection({stream:u.unwrap(),remoteAddr:l,localAddr:a.encapsulate(`/p2p-circuit/p2p/${this.peerId.toString()}`)});return log$2("new outbound transient connection %a",x.remoteAddr),await this.upgrader.upgradeOutbound(x,{transient:!0})}catch(u){throw log$2.error(`Circuit relay dial to destination ${n.toString()} via relay ${r.remotePeer.toString()} failed`,u),c&&await r.close(),u}}createListener(t){return createListener({connectionManager:this.connectionManager,relayStore:this.reservationStore})}filter(t){return t=Array.isArray(t)?t:[t],t.filter(r=>Circuit$1.matches(r))}async onStop({connection:t,stream:r}){const n=AbortSignal.timeout(this.stopTimeout),o=pbStream(r).pb(StopMessage),a=await o.read({signal:n});if(log$2("new circuit relay v2 stop stream from %p with type %s",t.remotePeer,a.type),a?.type===void 0){log$2.error("type was missing from circuit v2 stop protocol request from %s",t.remotePeer),await o.write({type:StopMessage.Type.STATUS,status:Status.MALFORMED_MESSAGE},{signal:n}),await r.close();return}if(a.type!==StopMessage.Type.CONNECT){log$2.error("invalid stop connect request via peer %p",t.remotePeer),await o.write({type:StopMessage.Type.STATUS,status:Status.UNEXPECTED_MESSAGE},{signal:n}),await r.close();return}if(!isValidStop(a)){log$2.error("invalid stop connect request via peer %p",t.remotePeer),await o.write({type:StopMessage.Type.STATUS,status:Status.MALFORMED_MESSAGE},{signal:n}),await r.close();return}const l=peerIdFromBytes(a.peer.id);if(await this.connectionGater.denyInboundRelayedConnection?.(t.remotePeer,l)===!0){log$2.error("connection gater denied inbound relayed connection from %p",t.remotePeer),await o.write({type:StopMessage.Type.STATUS,status:Status.PERMISSION_DENIED},{signal:n}),await r.close();return}log$2.trace("sending success response to %p",t.remotePeer),await o.write({type:StopMessage.Type.STATUS,status:Status.OK},{signal:n});const c=t.remoteAddr.encapsulate(`/p2p-circuit/p2p/${l.toString()}`),u=this.addressManager.getAddresses()[0],g=streamToMaConnection({stream:o.unwrap().unwrap(),remoteAddr:c,localAddr:u});log$2("new inbound transient connection %a",g.remoteAddr),await this.upgrader.upgradeInbound(g,{transient:!0}),log$2("%s connection %a upgraded","inbound",g.remoteAddr)}}oc=symbol$1,ac=Symbol.toStringTag;function circuitRelayTransport(e={}){return t=>new CircuitRelayTransport(t,e)}const version="0.46.11",AGENT_VERSION=`js-libp2p/${version}`,IDENTIFY_PROTOCOL_VERSION="0.1.0",MULTICODEC_IDENTIFY_PROTOCOL_NAME="id",MULTICODEC_IDENTIFY_PUSH_PROTOCOL_NAME="id/push",MULTICODEC_IDENTIFY_PROTOCOL_VERSION="1.0.0",MULTICODEC_IDENTIFY_PUSH_PROTOCOL_VERSION="1.0.0";var Identify;(function(e){let t;e.codec=()=>(t==null&&(t=message((r,n,o={})=>{if(o.lengthDelimited!==!1&&n.fork(),r.protocolVersion!=null&&(n.uint32(42),n.string(r.protocolVersion)),r.agentVersion!=null&&(n.uint32(50),n.string(r.agentVersion)),r.publicKey!=null&&(n.uint32(10),n.bytes(r.publicKey)),r.listenAddrs!=null)for(const a of r.listenAddrs)n.uint32(18),n.bytes(a);if(r.observedAddr!=null&&(n.uint32(34),n.bytes(r.observedAddr)),r.protocols!=null)for(const a of r.protocols)n.uint32(26),n.string(a);r.signedPeerRecord!=null&&(n.uint32(66),n.bytes(r.signedPeerRecord)),o.lengthDelimited!==!1&&n.ldelim()},(r,n)=>{const o={listenAddrs:[],protocols:[]},a=n==null?r.len:r.pos+n;for(;r.pos>>3){case 5:o.protocolVersion=r.string();break;case 6:o.agentVersion=r.string();break;case 1:o.publicKey=r.bytes();break;case 2:o.listenAddrs.push(r.bytes());break;case 4:o.observedAddr=r.bytes();break;case 3:o.protocols.push(r.string());break;case 8:o.signedPeerRecord=r.bytes();break;default:r.skipType(l&7);break}}return o})),t),e.encode=r=>encodeMessage(r,e.codec()),e.decode=r=>decodeMessage(r,e.codec())})(Identify||(Identify={}));const log$1=logger("libp2p:identify"),MAX_IDENTIFY_MESSAGE_SIZE=1024*8,defaultValues={protocolPrefix:"ipfs",agentVersion:AGENT_VERSION,timeout:6e4,maxInboundStreams:1,maxOutboundStreams:1,maxPushIncomingStreams:1,maxPushOutgoingStreams:1,maxObservedAddresses:10,maxIdentifyMessageSize:8192,runOnConnectionOpen:!0,runOnTransientConnection:!0};var ys,va;class DefaultIdentifyService{constructor(t,r){Er(this,ys);Je(this,"identifyProtocolStr");Je(this,"identifyPushProtocolStr");Je(this,"host");Je(this,"started");Je(this,"timeout");Je(this,"peerId");Je(this,"peerStore");Je(this,"registrar");Je(this,"connectionManager");Je(this,"addressManager");Je(this,"maxInboundStreams");Je(this,"maxOutboundStreams");Je(this,"maxPushIncomingStreams");Je(this,"maxPushOutgoingStreams");Je(this,"maxIdentifyMessageSize");Je(this,"maxObservedAddresses");Je(this,"events");Je(this,"runOnTransientConnection");this.started=!1,this.peerId=t.peerId,this.peerStore=t.peerStore,this.registrar=t.registrar,this.addressManager=t.addressManager,this.connectionManager=t.connectionManager,this.events=t.events,this.identifyProtocolStr=`/${r.protocolPrefix??defaultValues.protocolPrefix}/${MULTICODEC_IDENTIFY_PROTOCOL_NAME}/${MULTICODEC_IDENTIFY_PROTOCOL_VERSION}`,this.identifyPushProtocolStr=`/${r.protocolPrefix??defaultValues.protocolPrefix}/${MULTICODEC_IDENTIFY_PUSH_PROTOCOL_NAME}/${MULTICODEC_IDENTIFY_PUSH_PROTOCOL_VERSION}`,this.timeout=r.timeout??defaultValues.timeout,this.maxInboundStreams=r.maxInboundStreams??defaultValues.maxInboundStreams,this.maxOutboundStreams=r.maxOutboundStreams??defaultValues.maxOutboundStreams,this.maxPushIncomingStreams=r.maxPushIncomingStreams??defaultValues.maxPushIncomingStreams,this.maxPushOutgoingStreams=r.maxPushOutgoingStreams??defaultValues.maxPushOutgoingStreams,this.maxIdentifyMessageSize=r.maxIdentifyMessageSize??defaultValues.maxIdentifyMessageSize,this.maxObservedAddresses=r.maxObservedAddresses??defaultValues.maxObservedAddresses,this.runOnTransientConnection=r.runOnTransientConnection??defaultValues.runOnTransientConnection,this.host={protocolVersion:`${r.protocolPrefix??defaultValues.protocolPrefix}/${IDENTIFY_PROTOCOL_VERSION}`,agentVersion:r.agentVersion??defaultValues.agentVersion},(r.runOnConnectionOpen??defaultValues.runOnConnectionOpen)&&t.events.addEventListener("connection:open",n=>{const o=n.detail;this.identify(o).catch(a=>{log$1.error("error during identify trigged by connection:open",a)})}),t.events.addEventListener("self:peer:update",n=>{this.push().catch(o=>{log$1.error(o)})}),this.host.agentVersion===AGENT_VERSION&&(isNode||isElectronMain?this.host.agentVersion+=` UserAgent=${globalThis.process.version}`:(isBrowser||isWebWorker||isElectronRenderer||isReactNative)&&(this.host.agentVersion+=` UserAgent=${globalThis.navigator.userAgent}`))}isStarted(){return this.started}async start(){this.started||(await this.peerStore.merge(this.peerId,{metadata:{AgentVersion:fromString$1(this.host.agentVersion),ProtocolVersion:fromString$1(this.host.protocolVersion)}}),await this.registrar.handle(this.identifyProtocolStr,t=>{this._handleIdentify(t).catch(r=>{log$1.error(r)})},{maxInboundStreams:this.maxInboundStreams,maxOutboundStreams:this.maxOutboundStreams,runOnTransientConnection:this.runOnTransientConnection}),await this.registrar.handle(this.identifyPushProtocolStr,t=>{this._handlePush(t).catch(r=>{log$1.error(r)})},{maxInboundStreams:this.maxPushIncomingStreams,maxOutboundStreams:this.maxPushOutgoingStreams,runOnTransientConnection:this.runOnTransientConnection}),this.started=!0)}async stop(){await this.registrar.unhandle(this.identifyProtocolStr),await this.registrar.unhandle(this.identifyPushProtocolStr),this.started=!1}async pushToConnections(t){const r=this.addressManager.getAddresses().map(_=>_.decapsulateCode(getProtocol("p2p").code)),n=new PeerRecord({peerId:this.peerId,multiaddrs:r}),o=await RecordEnvelope.seal(n,this.peerId),a=this.registrar.getProtocols(),l=await this.peerStore.get(this.peerId),c=toString$5(l.metadata.get("AgentVersion")??fromString$1(this.host.agentVersion)),u=toString$5(l.metadata.get("ProtocolVersion")??fromString$1(this.host.protocolVersion)),g=t.map(async _=>{let x;const S=AbortSignal.timeout(this.timeout);try{events$1.exports.setMaxListeners?.(1/0,S)}catch{}try{x=await _.newStream([this.identifyPushProtocolStr],{signal:S,runOnTransientConnection:this.runOnTransientConnection}),await pbStream(x,{maxDataLength:this.maxIdentifyMessageSize??MAX_IDENTIFY_MESSAGE_SIZE}).pb(Identify).write({listenAddrs:r.map(E=>E.bytes),signedPeerRecord:o.marshal(),protocols:a,agentVersion:c,protocolVersion:u},{signal:S}),await x.close({signal:S})}catch(O){log$1.error("could not push identify update to peer",O),x?.abort(O)}});await Promise.all(g)}async push(){if(!this.isStarted())return;const t=[];await Promise.all(this.connectionManager.getConnections().map(async r=>{try{if(!(await this.peerStore.get(r.remotePeer)).protocols.includes(this.identifyPushProtocolStr))return;t.push(r)}catch(n){if(n.code!==codes.ERR_NOT_FOUND)throw n}})),await this.pushToConnections(t)}async _identify(t,r={}){let n;r.signal=r.signal??AbortSignal.timeout(this.timeout);try{n=await t.newStream([this.identifyProtocolStr],{...r,runOnTransientConnection:this.runOnTransientConnection});const a=await pbStream(n,{maxDataLength:this.maxIdentifyMessageSize??MAX_IDENTIFY_MESSAGE_SIZE}).pb(Identify).read(r);return await n.close(r),a}catch(o){throw log$1.error("error while reading identify message",o),n?.abort(o),o}}async identify(t,r={}){const n=await this._identify(t,r),{publicKey:o,protocols:a,observedAddr:l}=n;if(o==null)throw new CodeError("public key was missing from identify message",codes.ERR_MISSING_PUBLIC_KEY);const c=await peerIdFromKeys(o);if(!t.remotePeer.equals(c))throw new CodeError("identified peer does not match the expected peer",codes.ERR_INVALID_PEER);if(this.peerId.equals(c))throw new CodeError("identified peer is our own peer id?",codes.ERR_INVALID_PEER);const u=getCleanMultiaddr(l);log$1("identify completed for peer %p and protocols %o",c,a),log$1("our observed address is %a",u),u!=null&&this.addressManager.getObservedAddrs().length<(this.maxObservedAddresses??1/0)&&(log$1("storing our observed address %a",u),this.addressManager.addObservedAddr(u));const g=await wr(this,ys,va).call(this,t.remotePeer,n),_={peerId:c,protocolVersion:n.protocolVersion,agentVersion:n.agentVersion,publicKey:n.publicKey,listenAddrs:n.listenAddrs.map(x=>multiaddr(x)),observedAddr:n.observedAddr==null?void 0:multiaddr(n.observedAddr),protocols:n.protocols,signedPeerRecord:g};return this.events.safeDispatchEvent("peer:identify",{detail:_}),_}async _handleIdentify(t){const{connection:r,stream:n}=t,o=AbortSignal.timeout(this.timeout);try{events$1.exports.setMaxListeners?.(1/0,o)}catch{}try{const a=this.peerId.publicKey??new Uint8Array(0),l=await this.peerStore.get(this.peerId),c=this.addressManager.getAddresses().map(_=>_.decapsulateCode(getProtocol("p2p").code));let u=l.peerRecordEnvelope;if(c.length>0&&u==null){const _=new PeerRecord({peerId:this.peerId,multiaddrs:c});u=(await RecordEnvelope.seal(_,this.peerId)).marshal().subarray()}await pbStream(n).pb(Identify).write({protocolVersion:this.host.protocolVersion,agentVersion:this.host.agentVersion,publicKey:a,listenAddrs:c.map(_=>_.bytes),signedPeerRecord:u,observedAddr:r.remoteAddr.bytes,protocols:l.protocols},{signal:o}),await n.close({signal:o})}catch(a){log$1.error("could not respond to identify request",a),n.abort(a)}}async _handlePush(t){const{connection:r,stream:n}=t;try{if(this.peerId.equals(r.remotePeer))throw new Error("received push from ourselves?");const o={signal:AbortSignal.timeout(this.timeout)},l=await pbStream(n,{maxDataLength:this.maxIdentifyMessageSize??MAX_IDENTIFY_MESSAGE_SIZE}).pb(Identify).read(o);await n.close(o),await wr(this,ys,va).call(this,r.remotePeer,l)}catch(o){log$1.error("received invalid message",o),n.abort(o);return}log$1("handled push from %p",r.remotePeer)}}ys=new WeakSet,va=async function(t,r){if(log$1("received identify from %p",t),r==null)throw new Error("Message was null or undefined");const n={addresses:r.listenAddrs.map(a=>({isCertified:!1,multiaddr:multiaddr(a)})),protocols:r.protocols,metadata:new Map,peerRecordEnvelope:r.signedPeerRecord};let o;if(r.signedPeerRecord!=null){log$1("received signedPeerRecord in push from %p",t);let a=r.signedPeerRecord;const l=await RecordEnvelope.openAndCertify(a,PeerRecord.DOMAIN);let c=PeerRecord.createFromProtobuf(l.payload);if(!c.peerId.equals(l.peerId))throw new Error("signing key does not match PeerId in the PeerRecord");if(!t.equals(c.peerId))throw new Error("signing key does not match remote PeerId");let u;try{u=await this.peerStore.get(c.peerId)}catch(g){if(g.code!=="ERR_NOT_FOUND")throw g}if(u!=null&&(n.metadata=u.metadata,u.peerRecordEnvelope!=null)){const g=await RecordEnvelope.createFromProtobuf(u.peerRecordEnvelope),_=PeerRecord.createFromProtobuf(g.payload);_.seqNumber>=c.seqNumber&&(log$1("sequence number was lower or equal to existing sequence number - stored: %d received: %d",_.seqNumber,c.seqNumber),c=_,a=u.peerRecordEnvelope)}n.peerRecordEnvelope=a,n.addresses=c.multiaddrs.map(g=>({isCertified:!0,multiaddr:g})),o={seq:c.seqNumber,addresses:c.multiaddrs}}else log$1("%p did not send a signed peer record",t);return r.agentVersion!=null&&n.metadata.set("AgentVersion",fromString$1(r.agentVersion)),r.protocolVersion!=null&&n.metadata.set("ProtocolVersion",fromString$1(r.protocolVersion)),await this.peerStore.patch(t,n),o};function getCleanMultiaddr(e){if(e!=null&&e.length>0)try{return multiaddr(e)}catch{}}function identifyService(e={}){return t=>new DefaultIdentifyService(t,e)}const createNode=async e=>await createLibp2p({addresses:{listen:["/webrtc"]},transports:[webSockets({filter:all$1}),webRTC(),circuitRelayTransport({discoverRelays:1})],streamMuxers:[mplex()],connectionEncryption:[noise()],services:{pubsub:floodsub(),identify:identifyService()},peerDiscovery:[bootstrap({list:e.bootstrappers})],connectionGater:{denyDialMultiaddr:()=>!1}}),topic="airalab.lighthouse.5.robonomics.eth";class Provider$1{constructor(t){this.node=null,this.isReady=!1,this.whiteListAccounts=[],this.history={},this.init(t).then(()=>{this.isReady=!0,window.pubsubPeers=()=>{console.log("peers",this.node.services.pubsub.getPeers().map(r=>r.toString())),console.log("pubsub",this.node.services.pubsub.getSubscribers(topic).map(r=>r.toString()))}})}async init(t){this.node=await createNode(t),this.whiteListAccounts=getAgents()}ready(){return new Promise(t=>{const r=setInterval(()=>{this.isReady&&(t(),clearInterval(r))},100)})}getHistoryBySensor(t){return Promise.resolve(this.history[t]?this.history[t]:[])}watch(t){this.node.services.pubsub.subscribe(topic),this.node.services.pubsub.addEventListener("message",r=>{const n=r.detail.from.toString();if(!this.whiteListAccounts.includes(n))return;let o;try{o=JSON.parse(Buffer.from(r.detail.data).toString("utf8"))}catch(l){console.error(l.message);return}for(const l in o){const c=o[l];if(Object.prototype.hasOwnProperty.call(c,"model")&&(!Object.prototype.hasOwnProperty.call(this.history,l)||this.history[l].find(u=>u.timestamp===c.measurement.timestamp)===void 0)){const{timestamp:u,...g}=c.measurement,_={};for(var a in g){const T=a.toLowerCase();_[T]=measurements[T]?.calculate?measurements[T].calculate(g[a]):g[a]}const[x,S]=c.geo.split(","),O=c.donated_by||void 0,E={sensor_id:l,sender:n,model:c.model,geo:{lat:x,lng:S},data:_,donated_by:O,timestamp:u};Object.prototype.hasOwnProperty.call(this.history,l)||(this.history[l]=[]),this.history[l].push(E),t(E)}}})}}var lib$1={exports:{}},re=/^(?:(?![^:@]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,parts=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],parseuri$2=function e(t){var r=t,n=t.indexOf("["),o=t.indexOf("]");n!=-1&&o!=-1&&(t=t.substring(0,n)+t.substring(n,o).replace(/:/g,";")+t.substring(o,t.length));for(var a=re.exec(t||""),l={},c=14;c--;)l[parts[c]]=a[c]||"";return n!=-1&&o!=-1&&(l.source=r,l.host=l.host.substring(1,l.host.length-1).replace(/;/g,":"),l.authority=l.authority.replace("[","").replace("]","").replace(/;/g,":"),l.ipv6uri=!0),l.pathNames=pathNames(l,l.path),l.queryKey=queryKey(l,l.query),l};function pathNames(e,t){var r=/\/{2,9}/g,n=t.replace(r,"/").split("/");return(t.substr(0,1)=="/"||t.length===0)&&n.splice(0,1),t.substr(t.length-1,1)=="/"&&n.splice(n.length-1,1),n}function queryKey(e,t){var r={};return t.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(n,o,a){o&&(r[o]=a)}),r}var browser$3={exports:{}},debug$8={exports:{}},s$2=1e3,m$3=s$2*60,h$3=m$3*60,d$4=h$3*24,y$2=d$4*365.25,ms$2=function(e,t){t=t||{};var r=typeof e;if(r==="string"&&e.length>0)return parse$4(e);if(r==="number"&&isNaN(e)===!1)return t.long?fmtLong$2(e):fmtShort$2(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function parse$4(e){if(e=String(e),!(e.length>100)){var t=/^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(e);if(!!t){var r=parseFloat(t[1]),n=(t[2]||"ms").toLowerCase();switch(n){case"years":case"year":case"yrs":case"yr":case"y":return r*y$2;case"days":case"day":case"d":return r*d$4;case"hours":case"hour":case"hrs":case"hr":case"h":return r*h$3;case"minutes":case"minute":case"mins":case"min":case"m":return r*m$3;case"seconds":case"second":case"secs":case"sec":case"s":return r*s$2;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:return}}}}function fmtShort$2(e){return e>=d$4?Math.round(e/d$4)+"d":e>=h$3?Math.round(e/h$3)+"h":e>=m$3?Math.round(e/m$3)+"m":e>=s$2?Math.round(e/s$2)+"s":e+"ms"}function fmtLong$2(e){return plural$2(e,d$4,"day")||plural$2(e,h$3,"hour")||plural$2(e,m$3,"minute")||plural$2(e,s$2,"second")||e+" ms"}function plural$2(e,t,r){if(!(e=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}t.formatters.j=function(u){try{return JSON.stringify(u)}catch(g){return"[UnexpectedJSONParseError]: "+g.message}};function n(u){var g=this.useColors;if(u[0]=(g?"%c":"")+this.namespace+(g?" %c":" ")+u[0]+(g?"%c ":" ")+"+"+t.humanize(this.diff),!!g){var _="color: "+this.color;u.splice(1,0,_,"color: inherit");var x=0,S=0;u[0].replace(/%[a-zA-Z%]/g,function(O){O!=="%%"&&(x++,O==="%c"&&(S=x))}),u.splice(S,0,_)}}function o(){return typeof console=="object"&&console.log&&Function.prototype.apply.call(console.log,console,arguments)}function a(u){try{u==null?t.storage.removeItem("debug"):t.storage.debug=u}catch{}}function l(){var u;try{u=t.storage.debug}catch{}return!u&&typeof process<"u"&&"env"in process&&(u={}.DEBUG),u}t.enable(l());function c(){try{return window.localStorage}catch{}}})(browser$3,browser$3.exports);var parseuri$1=parseuri$2,debug$7=browser$3.exports("socket.io-client:url"),url_1=url;function url(e,t){var r=e;t=t||typeof location<"u"&&location,e==null&&(e=t.protocol+"//"+t.host),typeof e=="string"&&(e.charAt(0)==="/"&&(e.charAt(1)==="/"?e=t.protocol+e:e=t.host+e),/^(https?|wss?):\/\//.test(e)||(debug$7("protocol-less url %s",e),typeof t<"u"?e=t.protocol+"//"+e:e="https://"+e),debug$7("parse %s",e),r=parseuri$1(e)),r.port||(/^(http|ws)$/.test(r.protocol)?r.port="80":/^(http|ws)s$/.test(r.protocol)&&(r.port="443")),r.path=r.path||"/";var n=r.host.indexOf(":")!==-1,o=n?"["+r.host+"]":r.host;return r.id=r.protocol+"://"+o+":"+r.port,r.href=r.protocol+"://"+o+(t&&t.port===r.port?"":":"+r.port),r}var socket_ioParser={},browser$2={exports:{}},debug$6={exports:{}},s$1=1e3,m$2=s$1*60,h$2=m$2*60,d$3=h$2*24,y$1=d$3*365.25,ms$1=function(e,t){t=t||{};var r=typeof e;if(r==="string"&&e.length>0)return parse$3(e);if(r==="number"&&isNaN(e)===!1)return t.long?fmtLong$1(e):fmtShort$1(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function parse$3(e){if(e=String(e),!(e.length>100)){var t=/^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(e);if(!!t){var r=parseFloat(t[1]),n=(t[2]||"ms").toLowerCase();switch(n){case"years":case"year":case"yrs":case"yr":case"y":return r*y$1;case"days":case"day":case"d":return r*d$3;case"hours":case"hour":case"hrs":case"hr":case"h":return r*h$2;case"minutes":case"minute":case"mins":case"min":case"m":return r*m$2;case"seconds":case"second":case"secs":case"sec":case"s":return r*s$1;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:return}}}}function fmtShort$1(e){return e>=d$3?Math.round(e/d$3)+"d":e>=h$2?Math.round(e/h$2)+"h":e>=m$2?Math.round(e/m$2)+"m":e>=s$1?Math.round(e/s$1)+"s":e+"ms"}function fmtLong$1(e){return plural$1(e,d$3,"day")||plural$1(e,h$2,"hour")||plural$1(e,m$2,"minute")||plural$1(e,s$1,"second")||e+" ms"}function plural$1(e,t,r){if(!(e=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}t.formatters.j=function(u){try{return JSON.stringify(u)}catch(g){return"[UnexpectedJSONParseError]: "+g.message}};function n(u){var g=this.useColors;if(u[0]=(g?"%c":"")+this.namespace+(g?" %c":" ")+u[0]+(g?"%c ":" ")+"+"+t.humanize(this.diff),!!g){var _="color: "+this.color;u.splice(1,0,_,"color: inherit");var x=0,S=0;u[0].replace(/%[a-zA-Z%]/g,function(O){O!=="%%"&&(x++,O==="%c"&&(S=x))}),u.splice(S,0,_)}}function o(){return typeof console=="object"&&console.log&&Function.prototype.apply.call(console.log,console,arguments)}function a(u){try{u==null?t.storage.removeItem("debug"):t.storage.debug=u}catch{}}function l(){var u;try{u=t.storage.debug}catch{}return!u&&typeof process<"u"&&"env"in process&&(u={}.DEBUG),u}t.enable(l());function c(){try{return window.localStorage}catch{}}})(browser$2,browser$2.exports);var componentEmitter={exports:{}};(function(e){e.exports=t;function t(n){if(n)return r(n)}function r(n){for(var o in t.prototype)n[o]=t.prototype[o];return n}t.prototype.on=t.prototype.addEventListener=function(n,o){return this._callbacks=this._callbacks||{},(this._callbacks["$"+n]=this._callbacks["$"+n]||[]).push(o),this},t.prototype.once=function(n,o){function a(){this.off(n,a),o.apply(this,arguments)}return a.fn=o,this.on(n,a),this},t.prototype.off=t.prototype.removeListener=t.prototype.removeAllListeners=t.prototype.removeEventListener=function(n,o){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var a=this._callbacks["$"+n];if(!a)return this;if(arguments.length==1)return delete this._callbacks["$"+n],this;for(var l,c=0;c=0&&e.numn&&(r=n),t>=n||t>=r||n===0)return new ArrayBuffer(0);for(var o=new Uint8Array(e),a=new Uint8Array(r-t),l=t,c=0;l=55296&&o<=56319&&r65535&&(n-=65536,o+=stringFromCharCode(n>>>10&1023|55296),n=56320|n&1023),o+=stringFromCharCode(n);return o}function checkScalarValue(e,t){if(e>=55296&&e<=57343){if(t)throw Error("Lone surrogate U+"+e.toString(16).toUpperCase()+" is not a scalar value");return!1}return!0}function createByte(e,t){return stringFromCharCode(e>>t&63|128)}function encodeCodePoint(e,t){if((e&4294967168)==0)return stringFromCharCode(e);var r="";return(e&4294965248)==0?r=stringFromCharCode(e>>6&31|192):(e&4294901760)==0?(checkScalarValue(e,t)||(e=65533),r=stringFromCharCode(e>>12&15|224),r+=createByte(e,6)):(e&4292870144)==0&&(r=stringFromCharCode(e>>18&7|240),r+=createByte(e,12),r+=createByte(e,6)),r+=stringFromCharCode(e&63|128),r}function utf8encode(e,t){t=t||{};for(var r=t.strict!==!1,n=ucs2decode$1(e),o=n.length,a=-1,l,c="";++a=byteCount)throw Error("Invalid byte index");var e=byteArray[byteIndex]&255;if(byteIndex++,(e&192)==128)return e&63;throw Error("Invalid continuation byte")}function decodeSymbol(e){var t,r,n,o,a;if(byteIndex>byteCount)throw Error("Invalid byte index");if(byteIndex==byteCount)return!1;if(t=byteArray[byteIndex]&255,byteIndex++,(t&128)==0)return t;if((t&224)==192){if(r=readContinuationByte(),a=(t&31)<<6|r,a>=128)return a;throw Error("Invalid continuation byte")}if((t&240)==224){if(r=readContinuationByte(),n=readContinuationByte(),a=(t&15)<<12|r<<6|n,a>=2048)return checkScalarValue(a,e)?a:65533;throw Error("Invalid continuation byte")}if((t&248)==240&&(r=readContinuationByte(),n=readContinuationByte(),o=readContinuationByte(),a=(t&7)<<18|r<<12|n<<6|o,a>=65536&&a<=1114111))return a;throw Error("Invalid UTF-8 detected")}var byteArray,byteCount,byteIndex;function utf8decode(e,t){t=t||{};var r=t.strict!==!1;byteArray=ucs2decode$1(e),byteCount=byteArray.length,byteIndex=0;for(var n=[],o;(o=decodeSymbol(r))!==!1;)n.push(o);return ucs2encode(n)}var utf8={version:"2.1.2",encode:utf8encode,decode:utf8decode},base64Arraybuffer={},hasRequiredBase64Arraybuffer;function requireBase64Arraybuffer(){return hasRequiredBase64Arraybuffer||(hasRequiredBase64Arraybuffer=1,function(e){base64Arraybuffer.encode=function(t){var r=new Uint8Array(t),n,o=r.length,a="";for(n=0;n>2],a+=e[(r[n]&3)<<4|r[n+1]>>4],a+=e[(r[n+1]&15)<<2|r[n+2]>>6],a+=e[r[n+2]&63];return o%3===2?a=a.substring(0,a.length-1)+"=":o%3===1&&(a=a.substring(0,a.length-2)+"=="),a},base64Arraybuffer.decode=function(t){var r=t.length*.75,n=t.length,o,a=0,l,c,u,g;t[t.length-1]==="="&&(r--,t[t.length-2]==="="&&r--);var _=new ArrayBuffer(r),x=new Uint8Array(_);for(o=0;o>4,x[a++]=(c&15)<<4|u>>2,x[a++]=(u&3)<<6|g&63;return _}}("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/")),base64Arraybuffer}var blob,hasRequiredBlob;function requireBlob(){if(hasRequiredBlob)return blob;hasRequiredBlob=1;var e=typeof e<"u"?e:typeof WebKitBlobBuilder<"u"?WebKitBlobBuilder:typeof MSBlobBuilder<"u"?MSBlobBuilder:typeof MozBlobBuilder<"u"?MozBlobBuilder:!1,t=function(){try{var c=new Blob(["hi"]);return c.size===2}catch{return!1}}(),r=t&&function(){try{var c=new Blob([new Uint8Array([1,2])]);return c.size===2}catch{return!1}}(),n=e&&e.prototype.append&&e.prototype.getBlob;function o(c){return c.map(function(u){if(u.buffer instanceof ArrayBuffer){var g=u.buffer;if(u.byteLength!==g.byteLength){var _=new Uint8Array(u.byteLength);_.set(new Uint8Array(g,u.byteOffset,u.byteLength)),g=_.buffer}return g}return u})}function a(c,u){u=u||{};var g=new e;return o(c).forEach(function(_){g.append(_)}),u.type?g.getBlob(u.type):g.getBlob()}function l(c,u){return new Blob(o(c),u||{})}return typeof Blob<"u"&&(a.prototype=Blob.prototype,l.prototype=Blob.prototype),blob=function(){return t?r?Blob:l:n?a:void 0}(),blob}(function(e){var t=keys,r=hasBinary2,n=arraybuffer_slice,o=after_1,a=utf8,l;typeof ArrayBuffer<"u"&&(l=requireBase64Arraybuffer());var c=typeof navigator<"u"&&/Android/i.test(navigator.userAgent),u=typeof navigator<"u"&&/PhantomJS/i.test(navigator.userAgent),g=c||u;e.protocol=3;var _=e.packets={open:0,close:1,ping:2,pong:3,message:4,upgrade:5,noop:6},x=t(_),S={type:"error",data:"parser error"},O=requireBlob();e.encodePacket=function(se,ie,ne,le){typeof ie=="function"&&(le=ie,ie=!1),typeof ne=="function"&&(le=ne,ne=null);var me=se.data===void 0?void 0:se.data.buffer||se.data;if(typeof ArrayBuffer<"u"&&me instanceof ArrayBuffer)return T(se,ie,le);if(typeof O<"u"&&me instanceof O)return $(se,ie,le);if(me&&me.base64)return E(se,le);var _e=_[se.type];return se.data!==void 0&&(_e+=ne?a.encode(String(se.data),{strict:!1}):String(se.data)),le(""+_e)};function E(se,ie){var ne="b"+e.packets[se.type]+se.data.data;return ie(ne)}function T(se,ie,ne){if(!ie)return e.encodeBase64Packet(se,ne);var le=se.data,me=new Uint8Array(le),_e=new Uint8Array(1+le.byteLength);_e[0]=_[se.type];for(var ge=0;ge1?{type:x[me],data:se.substring(1)}:{type:x[me]}}var le=new Uint8Array(se),me=le[0],_e=n(se,1);return O&&ie==="blob"&&(_e=new O([_e])),{type:x[me],data:_e}};function I(se){try{se=a.decode(se,{strict:!1})}catch{return!1}return se}e.decodeBase64Packet=function(se,ie){var ne=x[se.charAt(0)];if(!l)return{type:ne,data:{base64:!0,data:se.substr(1)}};var le=l.decode(se.substr(1));return ie==="blob"&&O&&(le=new O([le])),{type:ne,data:le}},e.encodePayload=function(se,ie,ne){typeof ie=="function"&&(ne=ie,ie=null);var le=r(se);if(ie&&le)return O&&!g?e.encodePayloadAsBlob(se,ne):e.encodePayloadAsArrayBuffer(se,ne);if(!se.length)return ne("0:");function me(ge){return ge.length+":"+ge}function _e(ge,de){e.encodePacket(ge,le?ie:!1,!1,function(ve){de(null,me(ve))})}H(se,_e,function(ge,de){return ne(de.join(""))})};function H(se,ie,ne){for(var le=new Array(se.length),me=o(se.length,ne),_e=function(de,ve,pe){ie(ve,function(te,N){le[de]=N,pe(te,le)})},ge=0;ge0;){for(var _e=new Uint8Array(le),ge=_e[0]===0,de="",ve=1;_e[ve]!==255;ve++){if(de.length>310)return ne(S,0,1);de+=_e[ve]}le=n(le,2+de.length),de=parseInt(de);var pe=n(le,0,de);if(ge)try{pe=String.fromCharCode.apply(null,new Uint8Array(pe))}catch{var te=new Uint8Array(pe);pe="";for(var ve=0;ve0);return t}function decode(e){var t=0;for(i=0;i0)return parse$2(e);if(r==="number"&&isNaN(e)===!1)return t.long?fmtLong(e):fmtShort(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function parse$2(e){if(e=String(e),!(e.length>100)){var t=/^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(e);if(!!t){var r=parseFloat(t[1]),n=(t[2]||"ms").toLowerCase();switch(n){case"years":case"year":case"yrs":case"yr":case"y":return r*y;case"days":case"day":case"d":return r*d$2;case"hours":case"hour":case"hrs":case"hr":case"h":return r*h$1;case"minutes":case"minute":case"mins":case"min":case"m":return r*m$1;case"seconds":case"second":case"secs":case"sec":case"s":return r*s;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:return}}}}function fmtShort(e){return e>=d$2?Math.round(e/d$2)+"d":e>=h$1?Math.round(e/h$1)+"h":e>=m$1?Math.round(e/m$1)+"m":e>=s?Math.round(e/s)+"s":e+"ms"}function fmtLong(e){return plural(e,d$2,"day")||plural(e,h$1,"hour")||plural(e,m$1,"minute")||plural(e,s,"second")||e+" ms"}function plural(e,t,r){if(!(e=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}t.formatters.j=function(u){try{return JSON.stringify(u)}catch(g){return"[UnexpectedJSONParseError]: "+g.message}};function n(u){var g=this.useColors;if(u[0]=(g?"%c":"")+this.namespace+(g?" %c":" ")+u[0]+(g?"%c ":" ")+"+"+t.humanize(this.diff),!!g){var _="color: "+this.color;u.splice(1,0,_,"color: inherit");var x=0,S=0;u[0].replace(/%[a-zA-Z%]/g,function(O){O!=="%%"&&(x++,O==="%c"&&(S=x))}),u.splice(S,0,_)}}function o(){return typeof console=="object"&&console.log&&Function.prototype.apply.call(console.log,console,arguments)}function a(u){try{u==null?t.storage.removeItem("debug"):t.storage.debug=u}catch{}}function l(){var u;try{u=t.storage.debug}catch{}return!u&&typeof process<"u"&&"env"in process&&(u={}.DEBUG),u}t.enable(l());function c(){try{return window.localStorage}catch{}}})(browser,browser.exports);var Transport$1=requireTransport(),parseqs$2=parseqs$3,parser$3=browser$1,inherit$3=componentInherit,yeast$1=yeast_1,debug$4=browser.exports("engine.io-client:polling"),polling$1=Polling$2,hasXHR2=function(){var e=xmlhttprequest_browser,t=new e({xdomain:!1});return t.responseType!=null}();function Polling$2(e){var t=e&&e.forceBase64;(!hasXHR2||t)&&(this.supportsBinary=!1),Transport$1.call(this,e)}inherit$3(Polling$2,Transport$1);Polling$2.prototype.name="polling";Polling$2.prototype.doOpen=function(){this.poll()};Polling$2.prototype.pause=function(e){var t=this;this.readyState="pausing";function r(){debug$4("paused"),t.readyState="paused",e()}if(this.polling||!this.writable){var n=0;this.polling&&(debug$4("we are currently polling - waiting to pause"),n++,this.once("pollComplete",function(){debug$4("pre-pause polling complete"),--n||r()})),this.writable||(debug$4("we are currently writing - waiting to pause"),n++,this.once("drain",function(){debug$4("pre-pause writing complete"),--n||r()}))}else r()};Polling$2.prototype.poll=function(){debug$4("polling"),this.polling=!0,this.doPoll(),this.emit("poll")};Polling$2.prototype.onData=function(e){var t=this;debug$4("polling got data %s",e);var r=function(n,o,a){if(t.readyState==="opening"&&n.type==="open"&&t.onOpen(),n.type==="close")return t.onClose(),!1;t.onPacket(n)};parser$3.decodePayload(e,this.socket.binaryType,r),this.readyState!=="closed"&&(this.polling=!1,this.emit("pollComplete"),this.readyState==="open"?this.poll():debug$4('ignoring poll - transport state "%s"',this.readyState))};Polling$2.prototype.doClose=function(){var e=this;function t(){debug$4("writing close packet"),e.write([{type:"close"}])}this.readyState==="open"?(debug$4("transport open - closing"),t()):(debug$4("transport not open - deferring close"),this.once("open",t))};Polling$2.prototype.write=function(e){var t=this;this.writable=!1;var r=function(){t.writable=!0,t.emit("drain")};parser$3.encodePayload(e,this.supportsBinary,function(n){t.doWrite(n,r)})};Polling$2.prototype.uri=function(){var e=this.query||{},t=this.secure?"https":"http",r="";this.timestampRequests!==!1&&(e[this.timestampParam]=yeast$1()),!this.supportsBinary&&!e.sid&&(e.b64=1),e=parseqs$2.encode(e),this.port&&(t==="https"&&Number(this.port)!==443||t==="http"&&Number(this.port)!==80)&&(r=":"+this.port),e.length&&(e="?"+e);var n=this.hostname.indexOf(":")!==-1;return t+"://"+(n?"["+this.hostname+"]":this.hostname)+r+this.path+e};var XMLHttpRequest$2=xmlhttprequest_browser,Polling$1=polling$1,Emitter$2=componentEmitter.exports,inherit$2=componentInherit,debug$3=browser.exports("engine.io-client:polling-xhr"),globalThis$2=globalThis_browser;pollingXhr.exports=XHR$1;pollingXhr.exports.Request=Request;function empty$1(){}function XHR$1(e){if(Polling$1.call(this,e),this.requestTimeout=e.requestTimeout,this.extraHeaders=e.extraHeaders,typeof location<"u"){var t=location.protocol==="https:",r=location.port;r||(r=t?443:80),this.xd=typeof location<"u"&&e.hostname!==location.hostname||r!==e.port,this.xs=e.secure!==t}}inherit$2(XHR$1,Polling$1);XHR$1.prototype.supportsBinary=!0;XHR$1.prototype.request=function(e){return e=e||{},e.uri=this.uri(),e.xd=this.xd,e.xs=this.xs,e.agent=this.agent||!1,e.supportsBinary=this.supportsBinary,e.enablesXDR=this.enablesXDR,e.withCredentials=this.withCredentials,e.pfx=this.pfx,e.key=this.key,e.passphrase=this.passphrase,e.cert=this.cert,e.ca=this.ca,e.ciphers=this.ciphers,e.rejectUnauthorized=this.rejectUnauthorized,e.requestTimeout=this.requestTimeout,e.extraHeaders=this.extraHeaders,new Request(e)};XHR$1.prototype.doWrite=function(e,t){var r=typeof e!="string"&&e!==void 0,n=this.request({method:"POST",data:e,isBinary:r}),o=this;n.on("success",t),n.on("error",function(a){o.onError("xhr post error",a)}),this.sendXhr=n};XHR$1.prototype.doPoll=function(){debug$3("xhr poll");var e=this.request(),t=this;e.on("data",function(r){t.onData(r)}),e.on("error",function(r){t.onError("xhr poll error",r)}),this.pollXhr=e};function Request(e){this.method=e.method||"GET",this.uri=e.uri,this.xd=!!e.xd,this.xs=!!e.xs,this.async=e.async!==!1,this.data=e.data!==void 0?e.data:null,this.agent=e.agent,this.isBinary=e.isBinary,this.supportsBinary=e.supportsBinary,this.enablesXDR=e.enablesXDR,this.withCredentials=e.withCredentials,this.requestTimeout=e.requestTimeout,this.pfx=e.pfx,this.key=e.key,this.passphrase=e.passphrase,this.cert=e.cert,this.ca=e.ca,this.ciphers=e.ciphers,this.rejectUnauthorized=e.rejectUnauthorized,this.extraHeaders=e.extraHeaders,this.create()}Emitter$2(Request.prototype);Request.prototype.create=function(){var e={agent:this.agent,xdomain:this.xd,xscheme:this.xs,enablesXDR:this.enablesXDR};e.pfx=this.pfx,e.key=this.key,e.passphrase=this.passphrase,e.cert=this.cert,e.ca=this.ca,e.ciphers=this.ciphers,e.rejectUnauthorized=this.rejectUnauthorized;var t=this.xhr=new XMLHttpRequest$2(e),r=this;try{debug$3("xhr open %s: %s",this.method,this.uri),t.open(this.method,this.uri,this.async);try{if(this.extraHeaders){t.setDisableHeaderCheck&&t.setDisableHeaderCheck(!0);for(var n in this.extraHeaders)this.extraHeaders.hasOwnProperty(n)&&t.setRequestHeader(n,this.extraHeaders[n])}}catch{}if(this.method==="POST")try{this.isBinary?t.setRequestHeader("Content-type","application/octet-stream"):t.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{t.setRequestHeader("Accept","*/*")}catch{}"withCredentials"in t&&(t.withCredentials=this.withCredentials),this.requestTimeout&&(t.timeout=this.requestTimeout),this.hasXDR()?(t.onload=function(){r.onLoad()},t.onerror=function(){r.onError(t.responseText)}):t.onreadystatechange=function(){if(t.readyState===2)try{var o=t.getResponseHeader("Content-Type");(r.supportsBinary&&o==="application/octet-stream"||o==="application/octet-stream; charset=UTF-8")&&(t.responseType="arraybuffer")}catch{}t.readyState===4&&(t.status===200||t.status===1223?r.onLoad():setTimeout(function(){r.onError(typeof t.status=="number"?t.status:0)},0))},debug$3("xhr data %s",this.data),t.send(this.data)}catch(o){setTimeout(function(){r.onError(o)},0);return}typeof document<"u"&&(this.index=Request.requestsCount++,Request.requests[this.index]=this)};Request.prototype.onSuccess=function(){this.emit("success"),this.cleanup()};Request.prototype.onData=function(e){this.emit("data",e),this.onSuccess()};Request.prototype.onError=function(e){this.emit("error",e),this.cleanup(!0)};Request.prototype.cleanup=function(e){if(!(typeof this.xhr>"u"||this.xhr===null)){if(this.hasXDR()?this.xhr.onload=this.xhr.onerror=empty$1:this.xhr.onreadystatechange=empty$1,e)try{this.xhr.abort()}catch{}typeof document<"u"&&delete Request.requests[this.index],this.xhr=null}};Request.prototype.onLoad=function(){var e;try{var t;try{t=this.xhr.getResponseHeader("Content-Type")}catch{}t==="application/octet-stream"||t==="application/octet-stream; charset=UTF-8"?e=this.xhr.response||this.xhr.responseText:e=this.xhr.responseText}catch(r){this.onError(r)}e!=null&&this.onData(e)};Request.prototype.hasXDR=function(){return typeof XDomainRequest<"u"&&!this.xs&&this.enablesXDR};Request.prototype.abort=function(){this.cleanup()};Request.requestsCount=0;Request.requests={};if(typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",unloadHandler);else if(typeof addEventListener=="function"){var terminationEvent="onpagehide"in globalThis$2?"pagehide":"unload";addEventListener(terminationEvent,unloadHandler,!1)}}function unloadHandler(){for(var e in Request.requests)Request.requests.hasOwnProperty(e)&&Request.requests[e].abort()}var Polling=polling$1,inherit$1=componentInherit,globalThis$1=globalThis_browser,pollingJsonp=JSONPPolling,rNewline=/\n/g,rEscapedNewline=/\\n/g,callbacks;function empty(){}function JSONPPolling(e){Polling.call(this,e),this.query=this.query||{},callbacks||(callbacks=globalThis$1.___eio=globalThis$1.___eio||[]),this.index=callbacks.length;var t=this;callbacks.push(function(r){t.onData(r)}),this.query.j=this.index,typeof addEventListener=="function"&&addEventListener("beforeunload",function(){t.script&&(t.script.onerror=empty)},!1)}inherit$1(JSONPPolling,Polling);JSONPPolling.prototype.supportsBinary=!1;JSONPPolling.prototype.doClose=function(){this.script&&(this.script.parentNode.removeChild(this.script),this.script=null),this.form&&(this.form.parentNode.removeChild(this.form),this.form=null,this.iframe=null),Polling.prototype.doClose.call(this)};JSONPPolling.prototype.doPoll=function(){var e=this,t=document.createElement("script");this.script&&(this.script.parentNode.removeChild(this.script),this.script=null),t.async=!0,t.src=this.uri(),t.onerror=function(o){e.onError("jsonp poll error",o)};var r=document.getElementsByTagName("script")[0];r?r.parentNode.insertBefore(t,r):(document.head||document.body).appendChild(t),this.script=t;var n=typeof navigator<"u"&&/gecko/i.test(navigator.userAgent);n&&setTimeout(function(){var o=document.createElement("iframe");document.body.appendChild(o),document.body.removeChild(o)},100)};JSONPPolling.prototype.doWrite=function(e,t){var r=this;if(!this.form){var n=document.createElement("form"),o=document.createElement("textarea"),a=this.iframeId="eio_iframe_"+this.index,l;n.className="socketio",n.style.position="absolute",n.style.top="-1000px",n.style.left="-1000px",n.target=a,n.method="POST",n.setAttribute("accept-charset","utf-8"),o.name="d",n.appendChild(o),document.body.appendChild(n),this.form=n,this.area=o}this.form.action=this.uri();function c(){u(),t()}function u(){if(r.iframe)try{r.form.removeChild(r.iframe)}catch(_){r.onError("jsonp polling iframe removal error",_)}try{var g='