diff --git a/dashboard-frontend/src/pages/Reference.tsx b/dashboard-frontend/src/pages/Reference.tsx index 1d47611..6b459bc 100644 --- a/dashboard-frontend/src/pages/Reference.tsx +++ b/dashboard-frontend/src/pages/Reference.tsx @@ -758,11 +758,11 @@ export default function Reference() {

diff --git a/meshai/dashboard/static/assets/index-CmwrG05d.js b/meshai/dashboard/static/assets/index-CYCOCObI.js similarity index 99% rename from meshai/dashboard/static/assets/index-CmwrG05d.js rename to meshai/dashboard/static/assets/index-CYCOCObI.js index d541e6a..c05eacc 100644 --- a/meshai/dashboard/static/assets/index-CmwrG05d.js +++ b/meshai/dashboard/static/assets/index-CYCOCObI.js @@ -510,4 +510,4 @@ yyyy`);var n=Uo(t),i=r?"getUTC":"get",a=n[i+"FullYear"](),o=n[i+"Month"]()+1,s=n `||i==="")){var a=e.isSelected(i);ye(r,i)?r[i]=r[i]&&a:r[i]=a}}),r}function tqe(e){e.registerAction("legendToggleSelect","legendselectchanged",Be(rg,"toggleSelected")),e.registerAction("legendAllSelect","legendselectall",Be(rg,"allSelect")),e.registerAction("legendInverseSelect","legendinverseselect",Be(rg,"inverseSelect")),e.registerAction("legendSelect","legendselected",Be(rg,"select")),e.registerAction("legendUnSelect","legendunselected",Be(rg,"unSelect"))}function pie(e){e.registerComponentModel(PO),e.registerComponentView(die),e.registerProcessor(e.PRIORITY.PROCESSOR.SERIES_FILTER,eqe),e.registerSubTypeDefaulter("legend",function(){return"plain"}),tqe(e)}var rqe=function(e){q(t,e);function t(){var r=e!==null&&e.apply(this,arguments)||this;return r.type=t.type,r}return t.prototype.setScrollDataIndex=function(r){this.option.scrollDataIndex=r},t.prototype.init=function(r,n,i){var a=Sf(r);e.prototype.init.call(this,r,n,i),H8(this,r,a)},t.prototype.mergeOption=function(r,n){e.prototype.mergeOption.call(this,r,n),H8(this,this.option,r)},t.type="legend.scroll",t.defaultOption=xu(PO.defaultOption,{scrollDataIndex:0,pageButtonItemGap:5,pageButtonGap:null,pageButtonPosition:"end",pageFormatter:"{current}/{total}",pageIcons:{horizontal:["M0,0L12,-10L12,10z","M0,0L-12,-10L-12,10z"],vertical:["M0,0L20,0L10,-20z","M0,0L20,0L10,20z"]},pageIconColor:K.color.accent50,pageIconInactiveColor:K.color.accent10,pageIconSize:15,pageTextStyle:{color:K.color.tertiary},animationDurationUpdate:800}),t}(PO);function H8(e,t,r){var n=e.getOrient(),i=[1,1];i[n.index]=0,Fo(t,r,{type:"box",ignoreSize:!!i})}var U8=Me,YM=["width","height"],XM=["x","y"],nqe=function(e){q(t,e);function t(){var r=e!==null&&e.apply(this,arguments)||this;return r.type=t.type,r.newlineDisabled=!0,r._currentIndex=0,r}return t.prototype.init=function(){e.prototype.init.call(this),this.group.add(this._containerGroup=new U8),this._containerGroup.add(this.getContentGroup()),this.group.add(this._controllerGroup=new U8)},t.prototype.resetInner=function(){e.prototype.resetInner.call(this),this._controllerGroup.removeAll(),this._containerGroup.removeClipPath(),this._containerGroup.__rectSize=null},t.prototype.renderInner=function(r,n,i,a,o,s,l){var u=this;e.prototype.renderInner.call(this,r,n,i,a,o,s,l);var c=this._controllerGroup,f=n.get("pageIconSize",!0),h=ie(f)?f:[f,f];v("pagePrev",0);var d=n.getModel("pageTextStyle");c.add(new at({name:"pageText",style:{text:"xx/xx",fill:d.getTextColor(),font:d.getFont(),verticalAlign:"middle",align:"center"},silent:!0})),v("pageNext",1);function v(g,m){var y=g+"DataIndex",_=jv(n.get("pageIcons",!0)[n.getOrient().name][m],{onclick:pe(u._pageGo,u,y,n,a)},{x:-h[0]/2,y:-h[1]/2,width:h[0],height:h[1]});_.name=g,c.add(_)}},t.prototype.layoutInner=function(r,n,i,a,o,s){var l=this.getSelectorGroup(),u=r.getOrient().index,c=YM[u],f=XM[u],h=YM[1-u],d=XM[1-u];o&&Bc("horizontal",l,r.get("selectorItemGap",!0));var v=r.get("selectorButtonGap",!0),g=l.getBoundingRect(),m=[-g.x,-g.y],y=Ce(i);o&&(y[c]=i[c]-g[c]-v);var _=this._layoutContentAndController(r,a,y,u,c,h,d,f);if(o){if(s==="end")m[u]+=_[c]+v;else{var b=g[c]+v;m[u]-=b,_[f]-=b}_[c]+=g[c]+v,m[1-u]+=_[d]+_[h]/2-g[h]/2,_[h]=Math.max(_[h],g[h]),_[d]=Math.min(_[d],g[d]+m[1-u]),l.x=m[0],l.y=m[1],l.markRedraw()}return _},t.prototype._layoutContentAndController=function(r,n,i,a,o,s,l,u){var c=this.getContentGroup(),f=this._containerGroup,h=this._controllerGroup;Bc(r.get("orient"),c,r.get("itemGap"),a?i.width:null,a?null:i.height),Bc("horizontal",h,r.get("pageButtonItemGap",!0));var d=c.getBoundingRect(),v=h.getBoundingRect(),g=this._showController=d[o]>i[o],m=[-d.x,-d.y];n||(m[a]=c[u]);var y=[0,0],_=[-v.x,-v.y],b=be(r.get("pageButtonGap",!0),r.get("itemGap",!0));if(g){var S=r.get("pageButtonPosition",!0);S==="end"?_[a]+=i[o]-v[o]:y[a]+=v[o]+b}_[1-a]+=d[s]/2-v[s]/2,c.setPosition(m),f.setPosition(y),h.setPosition(_);var T={x:0,y:0};if(T[o]=g?i[o]:d[o],T[s]=Math.max(d[s],v[s]),T[l]=Math.min(0,v[l]+_[1-a]),f.__rectSize=i[o],g){var A={x:0,y:0};A[o]=Math.max(i[o]-v[o]-b,0),A[s]=T[s],f.setClipPath(new Xe({shape:A})),f.__rectSize=A[o]}else h.eachChild(function(P){P.attr({invisible:!0,silent:!0})});var M=this._getPageInfo(r);return M.pageIndex!=null&<(c,{x:M.contentPosition[0],y:M.contentPosition[1]},g?r:null),this._updatePageInfoView(r,M),T},t.prototype._pageGo=function(r,n,i){var a=this._getPageInfo(n)[r];a!=null&&i.dispatchAction({type:"legendScroll",scrollDataIndex:a,legendId:n.id})},t.prototype._updatePageInfoView=function(r,n){var i=this._controllerGroup;R(["pagePrev","pageNext"],function(c){var f=c+"DataIndex",h=n[f]!=null,d=i.childOfName(c);d&&(d.setStyle("fill",h?r.get("pageIconColor",!0):r.get("pageIconInactiveColor",!0)),d.cursor=h?"pointer":"default")});var a=i.childOfName("pageText"),o=r.get("pageFormatter"),s=n.pageIndex,l=s!=null?s+1:0,u=n.pageCount;a&&o&&a.setStyle("text",ve(o)?o.replace("{current}",l==null?"":l+"").replace("{total}",u==null?"":u+""):o({current:l,total:u}))},t.prototype._getPageInfo=function(r){var n=r.get("scrollDataIndex",!0),i=this.getContentGroup(),a=this._containerGroup.__rectSize,o=r.getOrient().index,s=YM[o],l=XM[o],u=this._findTargetItemIndex(n),c=i.children(),f=c[u],h=c.length,d=h?1:0,v={contentPosition:[i.x,i.y],pageCount:d,pageIndex:d-1,pagePrevDataIndex:null,pageNextDataIndex:null};if(!f)return v;var g=S(f);v.contentPosition[o]=-g.s;for(var m=u+1,y=g,_=g,b=null;m<=h;++m)b=S(c[m]),(!b&&_.e>y.s+a||b&&!T(b,y.s))&&(_.i>y.i?y=_:y=b,y&&(v.pageNextDataIndex==null&&(v.pageNextDataIndex=y.i),++v.pageCount)),_=b;for(var m=u-1,y=g,_=g,b=null;m>=-1;--m)b=S(c[m]),(!b||!T(_,b.s))&&y.i<_.i&&(_=y,v.pagePrevDataIndex==null&&(v.pagePrevDataIndex=y.i),++v.pageCount,++v.pageIndex),y=b;return v;function S(A){if(A){var M=A.getBoundingRect(),P=M[l]+A[l];return{s:P,e:P+M[s],i:A.__legendDataIndex}}}function T(A,M){return A.e>=M&&A.s<=M+a}},t.prototype._findTargetItemIndex=function(r){if(!this._showController)return 0;var n,i=this.getContentGroup(),a;return i.eachChild(function(o,s){var l=o.__legendDataIndex;a==null&&l!=null&&(a=s),l===r&&(n=s)}),n??a},t.type="legend.scroll",t}(die);function iqe(e){e.registerAction("legendScroll","legendscroll",function(t,r){var n=t.scrollDataIndex;n!=null&&r.eachComponent({mainType:"legend",subType:"scroll",query:t},function(i){i.setScrollDataIndex(n)})})}function aqe(e){Ze(pie),e.registerComponentModel(rqe),e.registerComponentView(nqe),iqe(e)}function oqe(e){Ze(pie),Ze(aqe)}var sqe=function(e){q(t,e);function t(){var r=e!==null&&e.apply(this,arguments)||this;return r.type=t.type,r}return t.type="dataZoom.inside",t.defaultOption=xu(Ny.defaultOption,{disabled:!1,zoomLock:!1,zoomOnMouseWheel:!0,moveOnMouseMove:!0,moveOnMouseWheel:!1,preventDefaultMouseMove:!0}),t}(Ny),CR=Je();function lqe(e,t,r){CR(e).coordSysRecordMap.each(function(n){var i=n.dataZoomInfoMap.get(t.uid);i&&(i.getRange=r)})}function uqe(e,t){for(var r=CR(e).coordSysRecordMap,n=r.keys(),i=0;ia[i+n]&&(n=u),o=o&&l.get("preventDefaultMouseMove",!0)}),{controlType:n,opt:{zoomOnMouseWheel:!0,moveOnMouseMove:!0,moveOnMouseWheel:!0,preventDefaultMouseMove:!!o,api:r,zInfo:{component:t.model},triggerInfo:{roamTrigger:null,isInSelf:t.containsPoint}}}}function vqe(e){e.registerProcessor(e.PRIORITY.PROCESSOR.FILTER,function(t,r){var n=CR(r),i=n.coordSysRecordMap||(n.coordSysRecordMap=_e());i.each(function(a){a.dataZoomInfoMap=null}),t.eachComponent({mainType:"dataZoom",subType:"inside"},function(a){var o=Qne(a);R(o.infoList,function(s){var l=s.model.uid,u=i.get(l)||i.set(l,cqe(r,s.model)),c=u.dataZoomInfoMap||(u.dataZoomInfoMap=_e());c.set(a.uid,{dzReferCoordSysInfo:s,model:a,getRange:null})})}),i.each(function(a){var o=a.controller,s,l=a.dataZoomInfoMap;if(l){var u=l.keys()[0];u!=null&&(s=l.get(u))}if(!s){gie(i,a);return}var c=dqe(l,a,r);o.enable(c.controlType,c.opt),Vv(a,"dispatchAction",s.model.get("throttle",!0),"fixRate")})})}var pqe=function(e){q(t,e);function t(){var r=e!==null&&e.apply(this,arguments)||this;return r.type="dataZoom.inside",r}return t.prototype.render=function(r,n,i){if(e.prototype.render.apply(this,arguments),r.noTarget()){this._clear();return}this.range=r.getPercentRange(),lqe(i,r,{pan:pe(qM.pan,this),zoom:pe(qM.zoom,this),scrollMove:pe(qM.scrollMove,this)})},t.prototype.dispose=function(){this._clear(),e.prototype.dispose.apply(this,arguments)},t.prototype._clear=function(){uqe(this.api,this.dataZoomModel),this.range=null},t.type="dataZoom.inside",t}(yR),qM={zoom:function(e,t,r,n){var i=this.range,a=i.slice(),o=e.axisModels[0];if(o){var s=KM[t](null,[n.originX,n.originY],o,r,e),l=(s.signal>0?s.pixelStart+s.pixelLength-s.pixel:s.pixel-s.pixelStart)/s.pixelLength*(a[1]-a[0])+a[0],u=Math.max(1/n.scale,0);a[0]=(a[0]-l)*u+l,a[1]=(a[1]-l)*u+l;var c=this.dataZoomModel.findRepresentativeAxisProxy().getMinMaxSpan();if(au(0,a,[0,100],0,c.minSpan,c.maxSpan),this.range=a,i[0]!==a[0]||i[1]!==a[1])return a}},pan:Z8(function(e,t,r,n,i,a){var o=KM[n]([a.oldX,a.oldY],[a.newX,a.newY],t,i,r);return o.signal*(e[1]-e[0])*o.pixel/o.pixelLength}),scrollMove:Z8(function(e,t,r,n,i,a){var o=KM[n]([0,0],[a.scrollDelta,a.scrollDelta],t,i,r);return o.signal*(e[1]-e[0])*a.scrollDelta})};function Z8(e){return function(t,r,n,i){var a=this.range,o=a.slice(),s=t.axisModels[0];if(s){var l=e(o,s,t,r,n,i);if(au(l,o,[0,100],"all"),this.range=o,a[0]!==o[0]||a[1]!==o[1])return o}}}var KM={grid:function(e,t,r,n,i){var a=r.axis,o={},s=i.model.coordinateSystem.getRect();return e=e||[0,0],a.dim==="x"?(o.pixel=t[0]-e[0],o.pixelLength=s.width,o.pixelStart=s.x,o.signal=a.inverse?1:-1):(o.pixel=t[1]-e[1],o.pixelLength=s.height,o.pixelStart=s.y,o.signal=a.inverse?-1:1),o},polar:function(e,t,r,n,i){var a=r.axis,o={},s=i.model.coordinateSystem,l=s.getRadiusAxis().getExtent(),u=s.getAngleAxis().getExtent();return e=e?s.pointToCoord(e):[0,0],t=s.pointToCoord(t),r.mainType==="radiusAxis"?(o.pixel=t[0]-e[0],o.pixelLength=l[1]-l[0],o.pixelStart=l[0],o.signal=a.inverse?1:-1):(o.pixel=t[1]-e[1],o.pixelLength=u[1]-u[0],o.pixelStart=u[0],o.signal=a.inverse?-1:1),o},singleAxis:function(e,t,r,n,i){var a=r.axis,o=i.model.coordinateSystem.getRect(),s={};return e=e||[0,0],a.orient==="horizontal"?(s.pixel=t[0]-e[0],s.pixelLength=o.width,s.pixelStart=o.x,s.signal=a.inverse?1:-1):(s.pixel=t[1]-e[1],s.pixelLength=o.height,s.pixelStart=o.y,s.signal=a.inverse?-1:1),s}};function mie(e){xR(e),e.registerComponentModel(sqe),e.registerComponentView(pqe),vqe(e)}var gqe=function(e){q(t,e);function t(){var r=e!==null&&e.apply(this,arguments)||this;return r.type=t.type,r}return t.type="dataZoom.slider",t.layoutMode="box",t.defaultOption=xu(Ny.defaultOption,{show:!0,right:"ph",top:"ph",width:"ph",height:"ph",left:null,bottom:null,borderColor:K.color.accent10,borderRadius:0,backgroundColor:K.color.transparent,dataBackground:{lineStyle:{color:K.color.accent30,width:.5},areaStyle:{color:K.color.accent20,opacity:.2}},selectedDataBackground:{lineStyle:{color:K.color.accent40,width:.5},areaStyle:{color:K.color.accent20,opacity:.3}},fillerColor:"rgba(135,175,274,0.2)",handleIcon:"path://M-9.35,34.56V42m0-40V9.5m-2,0h4a2,2,0,0,1,2,2v21a2,2,0,0,1-2,2h-4a2,2,0,0,1-2-2v-21A2,2,0,0,1-11.35,9.5Z",handleSize:"100%",handleStyle:{color:K.color.neutral00,borderColor:K.color.accent20},moveHandleSize:7,moveHandleIcon:"path://M-320.9-50L-320.9-50c18.1,0,27.1,9,27.1,27.1V85.7c0,18.1-9,27.1-27.1,27.1l0,0c-18.1,0-27.1-9-27.1-27.1V-22.9C-348-41-339-50-320.9-50z M-212.3-50L-212.3-50c18.1,0,27.1,9,27.1,27.1V85.7c0,18.1-9,27.1-27.1,27.1l0,0c-18.1,0-27.1-9-27.1-27.1V-22.9C-239.4-41-230.4-50-212.3-50z M-103.7-50L-103.7-50c18.1,0,27.1,9,27.1,27.1V85.7c0,18.1-9,27.1-27.1,27.1l0,0c-18.1,0-27.1-9-27.1-27.1V-22.9C-130.9-41-121.8-50-103.7-50z",moveHandleStyle:{color:K.color.accent40,opacity:.5},showDetail:!0,showDataShadow:"auto",realtime:!0,zoomLock:!1,textStyle:{color:K.color.tertiary},brushSelect:!0,brushStyle:{color:K.color.accent30,opacity:.3},emphasis:{handleLabel:{show:!0},handleStyle:{borderColor:K.color.accent40},moveHandleStyle:{opacity:.8}},defaultLocationEdgeGap:15}),t}(Ny),ng=Xe,mqe=1,QM=30,yqe=7,ig="horizontal",Y8="vertical",xqe=5,_qe=["line","bar","candlestick","scatter"],bqe={easing:"cubicOut",duration:100,delay:0},wqe=function(e){q(t,e);function t(){var r=e!==null&&e.apply(this,arguments)||this;return r.type=t.type,r._displayables={},r}return t.prototype.init=function(r,n){this.api=n,this._onBrush=pe(this._onBrush,this),this._onBrushEnd=pe(this._onBrushEnd,this)},t.prototype.render=function(r,n,i,a){if(e.prototype.render.apply(this,arguments),Vv(this,"_dispatchZoomAction",r.get("throttle"),"fixRate"),this._orient=r.getOrient(),r.get("show")===!1){this.group.removeAll();return}if(r.noTarget()){this._clear(),this.group.removeAll();return}(!a||a.type!=="dataZoom"||a.from!==this.uid)&&this._buildView(),this._updateView()},t.prototype.dispose=function(){this._clear(),e.prototype.dispose.apply(this,arguments)},t.prototype._clear=function(){_y(this,"_dispatchZoomAction");var r=this.api.getZr();r.off("mousemove",this._onBrush),r.off("mouseup",this._onBrushEnd)},t.prototype._buildView=function(){var r=this.group;r.removeAll(),this._brushing=!1,this._displayables.brushRect=null,this._resetLocation(),this._resetInterval();var n=this._displayables.sliderGroup=new Me;this._renderBackground(),this._renderHandle(),this._renderDataShadow(),r.add(n),this._positionGroup()},t.prototype._resetLocation=function(){var r=this.dataZoomModel,n=this.api,i=r.get("brushSelect"),a=i?yqe:0,o=jr(r,n).refContainer,s=this._findCoordRect(),l=r.get("defaultLocationEdgeGap",!0)||0,u=this._orient===ig?{right:o.width-s.x-s.width,top:o.height-QM-l-a,width:s.width,height:QM}:{right:l,top:s.y,width:QM,height:s.height},c=Sf(r.option);R(["right","top","width","height"],function(h){c[h]==="ph"&&(c[h]=u[h])});var f=$t(c,o);this._location={x:f.x,y:f.y},this._size=[f.width,f.height],this._orient===Y8&&this._size.reverse()},t.prototype._positionGroup=function(){var r=this.group,n=this._location,i=this._orient,a=this.dataZoomModel.getFirstTargetAxisModel(),o=a&&a.get("inverse"),s=this._displayables.sliderGroup,l=(this._dataShadowInfo||{}).otherAxisInverse;s.attr(i===ig&&!o?{scaleY:l?1:-1,scaleX:1}:i===ig&&o?{scaleY:l?1:-1,scaleX:-1}:i===Y8&&!o?{scaleY:l?-1:1,scaleX:1,rotation:Math.PI/2}:{scaleY:l?-1:1,scaleX:-1,rotation:Math.PI/2});var u=r.getBoundingRect([s]);r.x=n.x-u.x,r.y=n.y-u.y,r.markRedraw()},t.prototype._getViewExtent=function(){return[0,this._size[0]]},t.prototype._renderBackground=function(){var r=this.dataZoomModel,n=this._size,i=this._displayables.sliderGroup,a=r.get("brushSelect");i.add(new ng({silent:!0,shape:{x:0,y:0,width:n[0],height:n[1]},style:{fill:r.get("backgroundColor")},z2:-40}));var o=new ng({shape:{x:0,y:0,width:n[0],height:n[1]},style:{fill:"transparent"},z2:0,onclick:pe(this._onClickPanel,this)}),s=this.api.getZr();a?(o.on("mousedown",this._onBrushStart,this),o.cursor="crosshair",s.on("mousemove",this._onBrush),s.on("mouseup",this._onBrushEnd)):(s.off("mousemove",this._onBrush),s.off("mouseup",this._onBrushEnd)),i.add(o)},t.prototype._renderDataShadow=function(){var r=this._dataShadowInfo=this._prepareDataShadowInfo();if(this._displayables.dataShadowSegs=[],!r)return;var n=this._size,i=this._shadowSize||[],a=r.series,o=a.getRawData(),s=a.getShadowDim&&a.getShadowDim(),l=s&&o.getDimensionInfo(s)?a.getShadowDim():r.otherDim;if(l==null)return;var u=this._shadowPolygonPts,c=this._shadowPolylinePts;if(o!==this._shadowData||l!==this._shadowDim||n[0]!==i[0]||n[1]!==i[1]){var f=o.getDataExtent(r.thisDim),h=o.getDataExtent(l),d=(h[1]-h[0])*.3;h=[h[0]-d,h[1]+d];var v=[0,n[1]],g=[0,n[0]],m=[[n[0],0],[0,0]],y=[],_=g[1]/Math.max(1,o.count()-1),b=n[0]/(f[1]-f[0]),S=r.thisAxis.type==="time",T=-_,A=Math.round(o.count()/n[0]),M;o.each([r.thisDim,l],function(D,N,B){if(A>0&&B%A){S||(T+=_);return}T=S?(+D-f[0])*b:T+_;var $=N==null||isNaN(N)||N==="",F=$?0:gt(N,h,v,!0);$&&!M&&B?(m.push([m[m.length-1][0],0]),y.push([y[y.length-1][0],0])):!$&&M&&(m.push([T,0]),y.push([T,0])),$||(m.push([T,F]),y.push([T,F])),M=$}),u=this._shadowPolygonPts=m,c=this._shadowPolylinePts=y}this._shadowData=o,this._shadowDim=l,this._shadowSize=[n[0],n[1]];var P=this.dataZoomModel;function k(D){var N=P.getModel(D?"selectedDataBackground":"dataBackground"),B=new Me,$=new wn({shape:{points:u},segmentIgnoreThreshold:1,style:N.getModel("areaStyle").getAreaStyle(),silent:!0,z2:-20}),F=new on({shape:{points:c},segmentIgnoreThreshold:1,style:N.getModel("lineStyle").getLineStyle(),silent:!0,z2:-19});return B.add($),B.add(F),B}for(var I=0;I<3;I++){var O=k(I===1);this._displayables.sliderGroup.add(O),this._displayables.dataShadowSegs.push(O)}},t.prototype._prepareDataShadowInfo=function(){var r=this.dataZoomModel,n=r.get("showDataShadow");if(n!==!1){var i,a=this.ecModel;return r.eachTargetAxis(function(o,s){var l=r.getAxisProxy(o,s).getTargetSeriesModels();R(l,function(u){if(!i&&!(n!==!0&&Ge(_qe,u.get("type"))<0)){var c=a.getComponent(El(o),s).axis,f=Sqe(o),h,d=u.coordinateSystem;f!=null&&d.getOtherAxis&&(h=d.getOtherAxis(c).inverse),f=u.getData().mapDimension(f);var v=u.getData().mapDimension(o);i={thisAxis:c,series:u,thisDim:v,otherDim:f,otherAxisInverse:h}}},this)},this),i}},t.prototype._renderHandle=function(){var r=this.group,n=this._displayables,i=n.handles=[null,null],a=n.handleLabels=[null,null],o=this._displayables.sliderGroup,s=this._size,l=this.dataZoomModel,u=this.api,c=l.get("borderRadius")||0,f=l.get("brushSelect"),h=n.filler=new ng({silent:f,style:{fill:l.get("fillerColor")},textConfig:{position:"inside"}});o.add(h),o.add(new ng({silent:!0,subPixelOptimize:!0,shape:{x:0,y:0,width:s[0],height:s[1],r:c},style:{stroke:l.get("dataBackgroundColor")||l.get("borderColor"),lineWidth:mqe,fill:K.color.transparent}})),R([0,1],function(b){var S=l.get("handleIcon");!gw[S]&&S.indexOf("path://")<0&&S.indexOf("image://")<0&&(S="path://"+S);var T=xr(S,-1,0,2,2,null,!0);T.attr({cursor:Tqe(this._orient),draggable:!0,drift:pe(this._onDragMove,this,b),ondragend:pe(this._onDragEnd,this),onmouseover:pe(this._showDataInfo,this,!0),onmouseout:pe(this._showDataInfo,this,!1),z2:5});var A=T.getBoundingRect(),M=l.get("handleSize");this._handleHeight=de(M,this._size[1]),this._handleWidth=A.width/A.height*this._handleHeight,T.setStyle(l.getModel("handleStyle").getItemStyle()),T.style.strokeNoScale=!0,T.rectHover=!0,T.ensureState("emphasis").style=l.getModel(["emphasis","handleStyle"]).getItemStyle(),Zl(T);var P=l.get("handleColor");P!=null&&(T.style.fill=P),o.add(i[b]=T);var k=l.getModel("textStyle"),I=l.get("handleLabel")||{},O=I.show||!1;r.add(a[b]=new at({silent:!0,invisible:!O,style:Mt(k,{x:0,y:0,text:"",verticalAlign:"middle",align:"center",fill:k.getTextColor(),font:k.getFont()}),z2:10}))},this);var d=h;if(f){var v=de(l.get("moveHandleSize"),s[1]),g=n.moveHandle=new Xe({style:l.getModel("moveHandleStyle").getItemStyle(),silent:!0,shape:{r:[0,0,2,2],y:s[1]-.5,height:v}}),m=v*.8,y=n.moveHandleIcon=xr(l.get("moveHandleIcon"),-m/2,-m/2,m,m,K.color.neutral00,!0);y.silent=!0,y.y=s[1]+v/2-.5,g.ensureState("emphasis").style=l.getModel(["emphasis","moveHandleStyle"]).getItemStyle();var _=Math.min(s[1]/2,Math.max(v,10));d=n.moveZone=new Xe({invisible:!0,shape:{y:s[1]-_,height:v+_}}),d.on("mouseover",function(){u.enterEmphasis(g)}).on("mouseout",function(){u.leaveEmphasis(g)}),o.add(g),o.add(y),o.add(d)}d.attr({draggable:!0,cursor:"default",drift:pe(this._onDragMove,this,"all"),ondragstart:pe(this._showDataInfo,this,!0),ondragend:pe(this._onDragEnd,this),onmouseover:pe(this._showDataInfo,this,!0),onmouseout:pe(this._showDataInfo,this,!1)})},t.prototype._resetInterval=function(){var r=this._range=this.dataZoomModel.getPercentRange(),n=this._getViewExtent();this._handleEnds=[gt(r[0],[0,100],n,!0),gt(r[1],[0,100],n,!0)]},t.prototype._updateInterval=function(r,n){var i=this.dataZoomModel,a=this._handleEnds,o=this._getViewExtent(),s=i.findRepresentativeAxisProxy().getMinMaxSpan(),l=[0,100];au(n,a,o,i.get("zoomLock")?"all":r,s.minSpan!=null?gt(s.minSpan,l,o,!0):null,s.maxSpan!=null?gt(s.maxSpan,l,o,!0):null);var u=this._range,c=this._range=Mi([gt(a[0],o,l,!0),gt(a[1],o,l,!0)]);return!u||u[0]!==c[0]||u[1]!==c[1]},t.prototype._updateView=function(r){var n=this._displayables,i=this._handleEnds,a=Mi(i.slice()),o=this._size;R([0,1],function(d){var v=n.handles[d],g=this._handleHeight;v.attr({scaleX:g/2,scaleY:g/2,x:i[d]+(d?-1:1),y:o[1]/2-g/2})},this),n.filler.setShape({x:a[0],y:0,width:a[1]-a[0],height:o[1]});var s={x:a[0],width:a[1]-a[0]};n.moveHandle&&(n.moveHandle.setShape(s),n.moveZone.setShape(s),n.moveZone.getBoundingRect(),n.moveHandleIcon&&n.moveHandleIcon.attr("x",s.x+s.width/2));for(var l=n.dataShadowSegs,u=[0,a[0],a[1],o[0]],c=0;cn[0]||i[1]<0||i[1]>n[1])){var a=this._handleEnds,o=(a[0]+a[1])/2,s=this._updateInterval("all",i[0]-o);this._updateView(),s&&this._dispatchZoomAction(!1)}},t.prototype._onBrushStart=function(r){var n=r.offsetX,i=r.offsetY;this._brushStart=new Ie(n,i),this._brushing=!0,this._brushStartTime=+new Date},t.prototype._onBrushEnd=function(r){if(this._brushing){var n=this._displayables.brushRect;if(this._brushing=!1,!!n){n.attr("ignore",!0);var i=n.shape,a=+new Date;if(!(a-this._brushStartTime<200&&Math.abs(i.width)<5)){var o=this._getViewExtent(),s=[0,100],l=this._handleEnds=[i.x,i.x+i.width],u=this.dataZoomModel.findRepresentativeAxisProxy().getMinMaxSpan();au(0,l,o,0,u.minSpan!=null?gt(u.minSpan,s,o,!0):null,u.maxSpan!=null?gt(u.maxSpan,s,o,!0):null),this._range=Mi([gt(l[0],o,s,!0),gt(l[1],o,s,!0)]),this._updateView(),this._dispatchZoomAction(!1)}}}},t.prototype._onBrush=function(r){this._brushing&&(zs(r.event),this._updateBrushRect(r.offsetX,r.offsetY))},t.prototype._updateBrushRect=function(r,n){var i=this._displayables,a=this.dataZoomModel,o=i.brushRect;o||(o=i.brushRect=new ng({silent:!0,style:a.getModel("brushStyle").getItemStyle()}),i.sliderGroup.add(o)),o.attr("ignore",!1);var s=this._brushStart,l=this._displayables.sliderGroup,u=l.transformCoordToLocal(r,n),c=l.transformCoordToLocal(s.x,s.y),f=this._size;u[0]=Math.max(Math.min(f[0],u[0]),0),o.setShape({x:c[0],y:0,width:u[0]-c[0],height:f[1]})},t.prototype._dispatchZoomAction=function(r){var n=this._range;this.api.dispatchAction({type:"dataZoom",from:this.uid,dataZoomId:this.dataZoomModel.id,animation:r?bqe:null,start:n[0],end:n[1]})},t.prototype._findCoordRect=function(){var r,n=Qne(this.dataZoomModel).infoList;if(!r&&n.length){var i=n[0].model.coordinateSystem;r=i.getRect&&i.getRect()}if(!r){var a=this.api.getWidth(),o=this.api.getHeight();r={x:a*.2,y:o*.2,width:a*.6,height:o*.6}}return r},t.type="dataZoom.slider",t}(yR);function Sqe(e){var t={x:"y",y:"x",radius:"angle",angle:"radius"};return t[e]}function Tqe(e){return e==="vertical"?"ns-resize":"ew-resize"}function yie(e){e.registerComponentModel(gqe),e.registerComponentView(wqe),xR(e)}function Aqe(e){Ze(mie),Ze(yie)}var xie={get:function(e,t,r){var n=Ce((Cqe[e]||{})[t]);return r&&ie(n)?n[n.length-1]:n}},Cqe={color:{active:["#006edd","#e0ffff"],inactive:[K.color.transparent]},colorHue:{active:[0,360],inactive:[0,0]},colorSaturation:{active:[.3,1],inactive:[0,0]},colorLightness:{active:[.9,.5],inactive:[0,0]},colorAlpha:{active:[.3,1],inactive:[0,0]},opacity:{active:[.3,1],inactive:[0,0]},symbol:{active:["circle","roundRect","diamond"],inactive:["none"]},symbolSize:{active:[10,50],inactive:[0,0]}},X8=Hr.mapVisual,Mqe=Hr.eachVisual,Pqe=ie,q8=R,Lqe=Mi,kqe=gt,Kw=function(e){q(t,e);function t(){var r=e!==null&&e.apply(this,arguments)||this;return r.type=t.type,r.stateList=["inRange","outOfRange"],r.replacableOptionKeys=["inRange","outOfRange","target","controller","color"],r.layoutMode={type:"box",ignoreSize:!0},r.dataBound=[-1/0,1/0],r.targetVisuals={},r.controllerVisuals={},r}return t.prototype.init=function(r,n,i){this.mergeDefaultAndTheme(r,i)},t.prototype.optionUpdated=function(r,n){var i=this.option;!n&&lie(i,r,this.replacableOptionKeys),this.textStyleModel=this.getModel("textStyle"),this.resetItemSize(),this.completeVisualOption()},t.prototype.resetVisual=function(r){var n=this.stateList;r=pe(r,this),this.controllerVisuals=AO(this.option.controller,n,r),this.targetVisuals=AO(this.option.target,n,r)},t.prototype.getItemSymbol=function(){return null},t.prototype.getTargetSeriesIndices=function(){var r=this.option.seriesId,n=this.option.seriesIndex;n==null&&r==null&&(n="all");var i=Iv(this.ecModel,"series",{index:n,id:r},{useDefault:!1,enableAll:!0,enableNone:!1}).models;return se(i,function(a){return a.componentIndex})},t.prototype.eachTargetSeries=function(r,n){R(this.getTargetSeriesIndices(),function(i){var a=this.ecModel.getSeriesByIndex(i);a&&r.call(n,a)},this)},t.prototype.isTargetSeries=function(r){var n=!1;return this.eachTargetSeries(function(i){i===r&&(n=!0)}),n},t.prototype.formatValueText=function(r,n,i){var a=this.option,o=a.precision,s=this.dataBound,l=a.formatter,u;i=i||["<",">"],ie(r)&&(r=r.slice(),u=!0);var c=n?r:u?[f(r[0]),f(r[1])]:f(r);if(ve(l))return l.replace("{value}",u?c[0]:c).replace("{value2}",u?c[1]:c);if(Ae(l))return u?l(r[0],r[1]):l(r);if(u)return r[0]===s[0]?i[0]+" "+c[1]:r[1]===s[1]?i[1]+" "+c[0]:c[0]+" - "+c[1];return c;function f(h){return h===s[0]?"min":h===s[1]?"max":(+h).toFixed(Math.min(o,20))}},t.prototype.resetExtent=function(){var r=this.option,n=Lqe([r.min,r.max]);this._dataExtent=n},t.prototype.getDataDimensionIndex=function(r){var n=this.option.dimension;if(n!=null)return r.getDimensionIndex(n);for(var i=r.dimensions,a=i.length-1;a>=0;a--){var o=i[a],s=r.getDimensionInfo(o);if(!s.isCalculationCoord)return s.storeDimIndex}},t.prototype.getExtent=function(){return this._dataExtent.slice()},t.prototype.completeVisualOption=function(){var r=this.ecModel,n=this.option,i={inRange:n.inRange,outOfRange:n.outOfRange},a=n.target||(n.target={}),o=n.controller||(n.controller={});He(a,i),He(o,i);var s=this.isCategory();l.call(this,a),l.call(this,o),u.call(this,a,"inRange","outOfRange"),c.call(this,o);function l(f){Pqe(n.color)&&!f.inRange&&(f.inRange={color:n.color.slice().reverse()}),f.inRange=f.inRange||{color:r.get("gradientColor")}}function u(f,h,d){var v=f[h],g=f[d];v&&!g&&(g=f[d]={},q8(v,function(m,y){if(Hr.isValidType(y)){var _=xie.get(y,"inactive",s);_!=null&&(g[y]=_,y==="color"&&!g.hasOwnProperty("opacity")&&!g.hasOwnProperty("colorAlpha")&&(g.opacity=[0,0]))}}))}function c(f){var h=(f.inRange||{}).symbol||(f.outOfRange||{}).symbol,d=(f.inRange||{}).symbolSize||(f.outOfRange||{}).symbolSize,v=this.get("inactiveColor"),g=this.getItemSymbol(),m=g||"roundRect";q8(this.stateList,function(y){var _=this.itemSize,b=f[y];b||(b=f[y]={color:s?v:[v]}),b.symbol==null&&(b.symbol=h&&Ce(h)||(s?m:[m])),b.symbolSize==null&&(b.symbolSize=d&&Ce(d)||(s?_[0]:[_[0],_[0]])),b.symbol=X8(b.symbol,function(A){return A==="none"?m:A});var S=b.symbolSize;if(S!=null){var T=-1/0;Mqe(S,function(A){A>T&&(T=A)}),b.symbolSize=X8(S,function(A){return kqe(A,[0,T],[0,_[0]],!0)})}},this)}},t.prototype.resetItemSize=function(){this.itemSize=[parseFloat(this.get("itemWidth")),parseFloat(this.get("itemHeight"))]},t.prototype.isCategory=function(){return!!this.option.categories},t.prototype.setSelected=function(r){},t.prototype.getSelected=function(){return null},t.prototype.getValueState=function(r){return null},t.prototype.getVisualMeta=function(r){return null},t.type="visualMap",t.dependencies=["series"],t.defaultOption={show:!0,z:4,min:0,max:200,left:0,right:null,top:null,bottom:0,itemWidth:null,itemHeight:null,inverse:!1,orient:"vertical",backgroundColor:K.color.transparent,borderColor:K.color.borderTint,contentColor:K.color.theme[0],inactiveColor:K.color.disabled,borderWidth:0,padding:K.size.m,textGap:10,precision:0,textStyle:{color:K.color.secondary}},t}(Qe),K8=[20,140],Iqe=function(e){q(t,e);function t(){var r=e!==null&&e.apply(this,arguments)||this;return r.type=t.type,r}return t.prototype.optionUpdated=function(r,n){e.prototype.optionUpdated.apply(this,arguments),this.resetExtent(),this.resetVisual(function(i){i.mappingMethod="linear",i.dataExtent=this.getExtent()}),this._resetRange()},t.prototype.resetItemSize=function(){e.prototype.resetItemSize.apply(this,arguments);var r=this.itemSize;(r[0]==null||isNaN(r[0]))&&(r[0]=K8[0]),(r[1]==null||isNaN(r[1]))&&(r[1]=K8[1])},t.prototype._resetRange=function(){var r=this.getExtent(),n=this.option.range;!n||n.auto?(r.auto=1,this.option.range=r):ie(n)&&(n[0]>n[1]&&n.reverse(),n[0]=Math.max(n[0],r[0]),n[1]=Math.min(n[1],r[1]))},t.prototype.completeVisualOption=function(){e.prototype.completeVisualOption.apply(this,arguments),R(this.stateList,function(r){var n=this.option.controller[r].symbolSize;n&&n[0]!==n[1]&&(n[0]=n[1]/3)},this)},t.prototype.setSelected=function(r){this.option.range=r.slice(),this._resetRange()},t.prototype.getSelected=function(){var r=this.getExtent(),n=Mi((this.get("range")||[]).slice());return n[0]>r[1]&&(n[0]=r[1]),n[1]>r[1]&&(n[1]=r[1]),n[0]=i[1]||r<=n[1])?"inRange":"outOfRange"},t.prototype.findTargetDataIndices=function(r){var n=[];return this.eachTargetSeries(function(i){var a=[],o=i.getData();o.each(this.getDataDimensionIndex(o),function(s,l){r[0]<=s&&s<=r[1]&&a.push(l)},this),n.push({seriesId:i.id,dataIndex:a})},this),n},t.prototype.getVisualMeta=function(r){var n=Q8(this,"outOfRange",this.getExtent()),i=Q8(this,"inRange",this.option.range.slice()),a=[];function o(d,v){a.push({value:d,color:r(d,v)})}for(var s=0,l=0,u=i.length,c=n.length;lr[1])break;a.push({color:this.getControllerVisual(l,"color",n),offset:s/i})}return a.push({color:this.getControllerVisual(r[1],"color",n),offset:1}),a},t.prototype._createBarPoints=function(r,n){var i=this.visualMapModel.itemSize;return[[i[0]-n[0],r[0]],[i[0],r[0]],[i[0],r[1]],[i[0]-n[1],r[1]]]},t.prototype._createBarGroup=function(r){var n=this._orient,i=this.visualMapModel.get("inverse");return new Me(n==="horizontal"&&!i?{scaleX:r==="bottom"?1:-1,rotation:Math.PI/2}:n==="horizontal"&&i?{scaleX:r==="bottom"?-1:1,rotation:-Math.PI/2}:n==="vertical"&&!i?{scaleX:r==="left"?1:-1,scaleY:-1}:{scaleX:r==="left"?1:-1})},t.prototype._updateHandle=function(r,n){if(this._useHandle){var i=this._shapes,a=this.visualMapModel,o=i.handleThumbs,s=i.handleLabels,l=a.itemSize,u=a.getExtent(),c=this._applyTransform("left",i.mainGroup);Oqe([0,1],function(f){var h=o[f];h.setStyle("fill",n.handlesColor[f]),h.y=r[f];var d=fo(r[f],[0,l[1]],u,!0),v=this.getControllerVisual(d,"symbolSize");h.scaleX=h.scaleY=v/l[0],h.x=l[0]-v/2;var g=Ga(i.handleLabelPoints[f],Yl(h,this.group));if(this._orient==="horizontal"){var m=c==="left"||c==="top"?(l[0]-v)/2:(l[0]-v)/-2;g[1]+=m}s[f].setStyle({x:g[0],y:g[1],text:a.formatValueText(this._dataInterval[f]),verticalAlign:"middle",align:this._orient==="vertical"?this._applyTransform("left",i.mainGroup):"center"})},this)}},t.prototype._showIndicator=function(r,n,i,a){var o=this.visualMapModel,s=o.getExtent(),l=o.itemSize,u=[0,l[1]],c=this._shapes,f=c.indicator;if(f){f.attr("invisible",!1);var h={convertOpacityToAlpha:!0},d=this.getControllerVisual(r,"color",h),v=this.getControllerVisual(r,"symbolSize"),g=fo(r,s,u,!0),m=l[0]-v/2,y={x:f.x,y:f.y};f.y=g,f.x=m;var _=Ga(c.indicatorLabelPoint,Yl(f,this.group)),b=c.indicatorLabel;b.attr("invisible",!1);var S=this._applyTransform("left",c.mainGroup),T=this._orient,A=T==="horizontal";b.setStyle({text:(i||"")+o.formatValueText(n),verticalAlign:A?S:"middle",align:A?"center":S});var M={x:m,y:g,style:{fill:d}},P={style:{x:_[0],y:_[1]}};if(o.ecModel.isAnimationEnabled()&&!this._firstShowIndicator){var k={duration:100,easing:"cubicInOut",additive:!0};f.x=y.x,f.y=y.y,f.animateTo(M,k),b.animateTo(P,k)}else f.attr(M),b.attr(P);this._firstShowIndicator=!1;var I=this._shapes.handleLabels;if(I)for(var O=0;Oo[1]&&(f[1]=1/0),n&&(f[0]===-1/0?this._showIndicator(c,f[1],"< ",l):f[1]===1/0?this._showIndicator(c,f[0],"> ",l):this._showIndicator(c,c,"≈ ",l));var h=this._hoverLinkDataIndices,d=[];(n||rU(i))&&(d=this._hoverLinkDataIndices=i.findTargetDataIndices(f));var v=pRe(h,d);this._dispatchHighDown("downplay",pb(v[0],i)),this._dispatchHighDown("highlight",pb(v[1],i))}},t.prototype._hoverLinkFromSeriesMouseOver=function(r){var n;if(Mc(r.target,function(l){var u=De(l);if(u.dataIndex!=null)return n=u,!0},!0),!!n){var i=this.ecModel.getSeriesByIndex(n.seriesIndex),a=this.visualMapModel;if(a.isTargetSeries(i)){var o=i.getData(n.dataType),s=o.getStore().get(a.getDataDimensionIndex(o),n.dataIndex);isNaN(s)||this._showIndicator(s,s)}}},t.prototype._hideIndicator=function(){var r=this._shapes;r.indicator&&r.indicator.attr("invisible",!0),r.indicatorLabel&&r.indicatorLabel.attr("invisible",!0);var n=this._shapes.handleLabels;if(n)for(var i=0;i=0&&(a.dimension=o,n.push(a))}}),e.getData().setVisual("visualMeta",n)}}];function $qe(e,t,r,n){for(var i=t.targetVisuals[n],a=Hr.prepareVisualTypes(i),o={color:v0(e.getData(),"color")},s=0,l=a.length;s0:t.splitNumber>0)||t.calculable)?"continuous":"piecewise"}),e.registerAction(Rqe,Bqe),R(zqe,function(t){e.registerVisual(e.PRIORITY.VISUAL.COMPONENT,t)}),e.registerPreprocessor(Fqe))}function Sie(e){e.registerComponentModel(Iqe),e.registerComponentView(Nqe),wie(e)}var Vqe=function(e){q(t,e);function t(){var r=e!==null&&e.apply(this,arguments)||this;return r.type=t.type,r._pieceList=[],r}return t.prototype.optionUpdated=function(r,n){e.prototype.optionUpdated.apply(this,arguments),this.resetExtent();var i=this._mode=this._determineMode();this._pieceList=[],Gqe[this._mode].call(this,this._pieceList),this._resetSelected(r,n);var a=this.option.categories;this.resetVisual(function(o,s){i==="categories"?(o.mappingMethod="category",o.categories=Ce(a)):(o.dataExtent=this.getExtent(),o.mappingMethod="piecewise",o.pieceList=se(this._pieceList,function(l){return l=Ce(l),s!=="inRange"&&(l.visual=null),l}))})},t.prototype.completeVisualOption=function(){var r=this.option,n={},i=Hr.listVisualTypes(),a=this.isCategory();R(r.pieces,function(s){R(i,function(l){s.hasOwnProperty(l)&&(n[l]=1)})}),R(n,function(s,l){var u=!1;R(this.stateList,function(c){u=u||o(r,c,l)||o(r.target,c,l)},this),!u&&R(this.stateList,function(c){(r[c]||(r[c]={}))[l]=xie.get(l,c==="inRange"?"active":"inactive",a)})},this);function o(s,l,u){return s&&s[l]&&s[l].hasOwnProperty(u)}e.prototype.completeVisualOption.apply(this,arguments)},t.prototype._resetSelected=function(r,n){var i=this.option,a=this._pieceList,o=(n?i:r).selected||{};if(i.selected=o,R(a,function(l,u){var c=this.getSelectedMapKey(l);o.hasOwnProperty(c)||(o[c]=!0)},this),i.selectedMode==="single"){var s=!1;R(a,function(l,u){var c=this.getSelectedMapKey(l);o[c]&&(s?o[c]=!1:s=!0)},this)}},t.prototype.getItemSymbol=function(){return this.get("itemSymbol")},t.prototype.getSelectedMapKey=function(r){return this._mode==="categories"?r.value+"":r.index+""},t.prototype.getPieceList=function(){return this._pieceList},t.prototype._determineMode=function(){var r=this.option;return r.pieces&&r.pieces.length>0?"pieces":this.option.categories?"categories":"splitNumber"},t.prototype.setSelected=function(r){this.option.selected=Ce(r)},t.prototype.getValueState=function(r){var n=Hr.findPieceIndex(r,this._pieceList);return n!=null&&this.option.selected[this.getSelectedMapKey(this._pieceList[n])]?"inRange":"outOfRange"},t.prototype.findTargetDataIndices=function(r){var n=[],i=this._pieceList;return this.eachTargetSeries(function(a){var o=[],s=a.getData();s.each(this.getDataDimensionIndex(s),function(l,u){var c=Hr.findPieceIndex(l,i);c===r&&o.push(u)},this),n.push({seriesId:a.id,dataIndex:o})},this),n},t.prototype.getRepresentValue=function(r){var n;if(this.isCategory())n=r.value;else if(r.value!=null)n=r.value;else{var i=r.interval||[];n=i[0]===-1/0&&i[1]===1/0?0:(i[0]+i[1])/2}return n},t.prototype.getVisualMeta=function(r){if(this.isCategory())return;var n=[],i=["",""],a=this;function o(c,f){var h=a.getRepresentValue({interval:c});f||(f=a.getValueState(h));var d=r(h,f);c[0]===-1/0?i[0]=d:c[1]===1/0?i[1]=d:n.push({value:c[0],color:d},{value:c[1],color:d})}var s=this._pieceList.slice();if(!s.length)s.push({interval:[-1/0,1/0]});else{var l=s[0].interval[0];l!==-1/0&&s.unshift({interval:[-1/0,l]}),l=s[s.length-1].interval[1],l!==1/0&&s.push({interval:[l,1/0]})}var u=-1/0;return R(s,function(c){var f=c.interval;f&&(f[0]>u&&o([u,f[0]],"outOfRange"),o(f.slice()),u=f[1])},this),{stops:n,outerColors:i}},t.type="visualMap.piecewise",t.defaultOption=xu(Kw.defaultOption,{selected:null,minOpen:!1,maxOpen:!1,align:"auto",itemWidth:20,itemHeight:14,itemSymbol:"roundRect",pieces:null,categories:null,splitNumber:5,selectedMode:"multiple",itemGap:10,hoverLink:!0}),t}(Kw),Gqe={splitNumber:function(e){var t=this.option,r=Math.min(t.precision,20),n=this.getExtent(),i=t.splitNumber;i=Math.max(parseInt(i,10),1),t.splitNumber=i;for(var a=(n[1]-n[0])/i;+a.toFixed(r)!==a&&r<5;)r++;t.precision=r,a=+a.toFixed(r),t.minOpen&&e.push({interval:[-1/0,n[0]],close:[0,0]});for(var o=0,s=n[0];o","≥"][n[0]]];r.text=r.text||this.formatValueText(r.value!=null?r.value:r.interval,!1,i)},this)}};function oU(e,t){var r=e.inverse;(e.orient==="vertical"?!r:r)&&t.reverse()}var Wqe=function(e){q(t,e);function t(){var r=e!==null&&e.apply(this,arguments)||this;return r.type=t.type,r}return t.prototype.doRender=function(){var r=this.group;r.removeAll();var n=this.visualMapModel,i=n.get("textGap"),a=n.textStyleModel,o=this._getItemAlign(),s=n.itemSize,l=this._getViewData(),u=l.endsText,c=nn(n.get("showLabel",!0),!u),f=!n.get("selectedMode");u&&this._renderEndsText(r,u[0],s,c,o),R(l.viewPieceList,function(h){var d=h.piece,v=new Me;v.onclick=pe(this._onItemClick,this,d),this._enableHoverLink(v,h.indexInModelPieceList);var g=n.getRepresentValue(d);if(this._createItemSymbol(v,g,[0,0,s[0],s[1]],f),c){var m=this.visualMapModel.getValueState(g),y=a.get("align")||o;v.add(new at({style:Mt(a,{x:y==="right"?-i:s[0]+i,y:s[1]/2,text:d.text,verticalAlign:a.get("verticalAlign")||"middle",align:y,opacity:be(a.get("opacity"),m==="outOfRange"?.5:1)}),silent:f}))}r.add(v)},this),u&&this._renderEndsText(r,u[1],s,c,o),Bc(n.get("orient"),r,n.get("itemGap")),this.renderBackground(r),this.positionGroup(r)},t.prototype._enableHoverLink=function(r,n){var i=this;r.on("mouseover",function(){return a("highlight")}).on("mouseout",function(){return a("downplay")});var a=function(o){var s=i.visualMapModel;s.option.hoverLink&&i.api.dispatchAction({type:o,batch:pb(s.findTargetDataIndices(n),s)})}},t.prototype._getItemAlign=function(){var r=this.visualMapModel,n=r.option;if(n.orient==="vertical")return bie(r,this.api,r.itemSize);var i=n.align;return(!i||i==="auto")&&(i="left"),i},t.prototype._renderEndsText=function(r,n,i,a,o){if(n){var s=new Me,l=this.visualMapModel.textStyleModel;s.add(new at({style:Mt(l,{x:a?o==="right"?i[0]:0:i[0]/2,y:i[1]/2,verticalAlign:"middle",align:a?o:"center",text:n})})),r.add(s)}},t.prototype._getViewData=function(){var r=this.visualMapModel,n=se(r.getPieceList(),function(s,l){return{piece:s,indexInModelPieceList:l}}),i=r.get("text"),a=r.get("orient"),o=r.get("inverse");return(a==="horizontal"?o:!o)?n.reverse():i&&(i=i.slice().reverse()),{viewPieceList:n,endsText:i}},t.prototype._createItemSymbol=function(r,n,i,a){var o=xr(this.getControllerVisual(n,"symbol"),i[0],i[1],i[2],i[3],this.getControllerVisual(n,"color"));o.silent=a,r.add(o)},t.prototype._onItemClick=function(r){var n=this.visualMapModel,i=n.option,a=i.selectedMode;if(a){var o=Ce(i.selected),s=n.getSelectedMapKey(r);a==="single"||a===!0?(o[s]=!0,R(o,function(l,u){o[u]=u===s})):o[s]=!o[s],this.api.dispatchAction({type:"selectDataRange",from:this.uid,visualMapId:this.visualMapModel.id,selected:o})}},t.type="visualMap.piecewise",t}(_ie);function Tie(e){e.registerComponentModel(Vqe),e.registerComponentView(Wqe),wie(e)}function Hqe(e){Ze(Sie),Ze(Tie)}var Uqe=function(){function e(t){this._thumbnailModel=t}return e.prototype.reset=function(t){this._renderVersion=t.getMainProcessVersion()},e.prototype.renderContent=function(t){var r=t.api.getViewOfComponentModel(this._thumbnailModel);r&&(t.group.silent=!0,r.renderContent({group:t.group,targetTrans:t.targetTrans,z2Range:YQ(t.group),roamType:t.roamType,viewportRect:t.viewportRect,renderVersion:this._renderVersion}))},e.prototype.updateWindow=function(t,r){var n=r.getViewOfComponentModel(this._thumbnailModel);n&&n.updateWindow({targetTrans:t,renderVersion:this._renderVersion})},e}(),Zqe=function(e){q(t,e);function t(){var r=e!==null&&e.apply(this,arguments)||this;return r.type=t.type,r.preventAutoZ=!0,r}return t.prototype.optionUpdated=function(r,n){this._updateBridge()},t.prototype._updateBridge=function(){var r=this._birdge=this._birdge||new Uqe(this);if(this._target=null,this.ecModel.eachSeries(function(i){IW(i,null)}),this.shouldShow()){var n=this.getTarget();IW(n.baseMapProvider,r)}},t.prototype.shouldShow=function(){return this.getShallow("show",!0)},t.prototype.getBridge=function(){return this._birdge},t.prototype.getTarget=function(){if(this._target)return this._target;var r=this.getReferringComponents("series",{useDefault:!1,enableAll:!1,enableNone:!1}).models[0];return r?r.subType!=="graph"&&(r=null):r=this.ecModel.queryComponents({mainType:"series",subType:"graph"})[0],this._target={baseMapProvider:r},this._target},t.type="thumbnail",t.layoutMode="box",t.dependencies=["series","geo"],t.defaultOption={show:!0,right:1,bottom:1,height:"25%",width:"25%",itemStyle:{borderColor:K.color.border,borderWidth:2},windowStyle:{borderWidth:1,color:K.color.neutral30,borderColor:K.color.neutral40,opacity:.3},z:10},t}(Qe),Yqe=function(e){q(t,e);function t(){var r=e!==null&&e.apply(this,arguments)||this;return r.type=t.type,r}return t.prototype.render=function(r,n,i){if(this._api=i,this._model=r,this._coordSys||(this._coordSys=new Pf),!this._isEnabled()){this._clear();return}this._renderVersion=i.getMainProcessVersion();var a=this.group;a.removeAll();var o=r.getModel("itemStyle"),s=o.getItemStyle();s.fill==null&&(s.fill=n.get("backgroundColor")||K.color.neutral00);var l=jr(r,i).refContainer,u=$t(vJ(r,!0),l),c=s.lineWidth||0,f=this._contentRect=af(u.clone(),c/2,!0,!0),h=new Me;a.add(h),h.setClipPath(new Xe({shape:f.plain()}));var d=this._targetGroup=new Me;h.add(d);var v=u.plain();v.r=o.getShallow("borderRadius",!0),a.add(this._bgRect=new Xe({style:s,shape:v,silent:!1,cursor:"grab"}));var g=r.getModel("windowStyle"),m=g.getShallow("borderRadius",!0);h.add(this._windowRect=new Xe({shape:{x:0,y:0,width:0,height:0,r:m},style:g.getItemStyle(),silent:!1,cursor:"grab"})),this._dealRenderContent(),this._dealUpdateWindow(),lU(r,this)},t.prototype.renderContent=function(r){this._bridgeRendered=r,this._isEnabled()&&(this._dealRenderContent(),this._dealUpdateWindow(),lU(this._model,this))},t.prototype._dealRenderContent=function(){var r=this._bridgeRendered;if(!(!r||r.renderVersion!==this._renderVersion)){var n=this._targetGroup,i=this._coordSys,a=this._contentRect;if(n.removeAll(),!!r){var o=r.group,s=o.getBoundingRect();n.add(o),this._bgRect.z2=r.z2Range.min-10,i.setBoundingRect(s.x,s.y,s.width,s.height);var l=$t({left:"center",top:"center",aspect:s.width/s.height},a);i.setViewRect(l.x,l.y,l.width,l.height),o.attr(i.getTransformInfo().raw),this._windowRect.z2=r.z2Range.max+10,this._resetRoamController(r.roamType)}}},t.prototype.updateWindow=function(r){var n=this._bridgeRendered;n&&n.renderVersion===r.renderVersion&&(n.targetTrans=r.targetTrans),this._isEnabled()&&this._dealUpdateWindow()},t.prototype._dealUpdateWindow=function(){var r=this._bridgeRendered;if(!(!r||r.renderVersion!==this._renderVersion)){var n=da([],r.targetTrans),i=Fa([],this._coordSys.transform,n);this._transThisToTarget=da([],i);var a=r.viewportRect;a?a=a.clone():a=new Oe(0,0,this._api.getWidth(),this._api.getHeight()),a.applyTransform(i);var o=this._windowRect,s=o.shape.r;o.setShape(Pe({r:s},a))}},t.prototype._resetRoamController=function(r){var n=this,i=this._api,a=this._roamController;if(a||(a=this._roamController=new Mf(i.getZr())),!r||!this._isEnabled()){a.disable();return}a.enable(r,{api:i,zInfo:{component:this._model},triggerInfo:{roamTrigger:null,isInSelf:function(o,s,l){return n._contentRect.contain(s,l)}}}),a.off("pan").off("zoom").on("pan",pe(this._onPan,this)).on("zoom",pe(this._onZoom,this))},t.prototype._onPan=function(r){var n=this._transThisToTarget;if(!(!this._isEnabled()||!n)){var i=ur([],[r.oldX,r.oldY],n),a=ur([],[r.oldX-r.dx,r.oldY-r.dy],n);this._api.dispatchAction(sU(this._model.getTarget().baseMapProvider,{dx:a[0]-i[0],dy:a[1]-i[1]}))}},t.prototype._onZoom=function(r){var n=this._transThisToTarget;if(!(!this._isEnabled()||!n)){var i=ur([],[r.originX,r.originY],n);this._api.dispatchAction(sU(this._model.getTarget().baseMapProvider,{zoom:1/r.scale,originX:i[0],originY:i[1]}))}},t.prototype._isEnabled=function(){var r=this._model;if(!r||!r.shouldShow())return!1;var n=r.getTarget().baseMapProvider;return!!n},t.prototype._clear=function(){this.group.removeAll(),this._bridgeRendered=null,this._roamController&&this._roamController.disable()},t.prototype.remove=function(){this._clear()},t.prototype.dispose=function(){this._clear()},t.type="thumbnail",t}(Lt);function sU(e,t){var r=e.mainType==="series"?e.subType+"Roam":e.mainType+"Roam",n={type:r};return n[e.mainType+"Id"]=e.id,re(n,t),n}function lU(e,t){var r=of(e);PT(t.group,r.z,r.zlevel)}function Xqe(e){e.registerComponentModel(Zqe),e.registerComponentView(Yqe)}var qqe={label:{enabled:!0},decal:{show:!1}},uU=Je(),Kqe={};function Qqe(e,t){var r=e.getModel("aria");if(!r.get("enabled"))return;var n=Ce(qqe);He(n.label,e.getLocaleModel().get("aria"),!1),He(r.option,n,!1),i(),a();function i(){var u=r.getModel("decal"),c=u.get("show");if(c){var f=_e();e.eachSeries(function(h){if(!h.isColorBySeries()){var d=f.get(h.type);d||(d={},f.set(h.type,d)),uU(h).scope=d}}),e.eachRawSeries(function(h){if(e.isSeriesFiltered(h))return;if(Ae(h.enableAriaDecal)){h.enableAriaDecal();return}var d=h.getData();if(h.isColorBySeries()){var _=mI(h.ecModel,h.name,Kqe,e.getSeriesCount()),b=d.getVisual("decal");d.setVisual("decal",S(b,_))}else{var v=h.getRawData(),g={},m=uU(h).scope;d.each(function(T){var A=d.getRawIndex(T);g[A]=T});var y=v.count();v.each(function(T){var A=g[T],M=v.getName(T)||T+"",P=mI(h.ecModel,M,m,y),k=d.getItemVisual(A,"decal");d.setItemVisual(A,"decal",S(k,P))})}function S(T,A){var M=T?re(re({},A),T):A;return M.dirty=!0,M}})}}function a(){var u=t.getZr().dom;if(u){var c=e.getLocaleModel().get("aria"),f=r.getModel("label");if(f.option=Pe(f.option,c),!!f.get("enabled")){if(u.setAttribute("role","img"),f.get("description")){u.setAttribute("aria-label",f.get("description"));return}var h=e.getSeriesCount(),d=f.get(["data","maxCount"])||10,v=f.get(["series","maxCount"])||10,g=Math.min(h,v),m;if(!(h<1)){var y=s();if(y){var _=f.get(["general","withTitle"]);m=o(_,{title:y})}else m=f.get(["general","withoutTitle"]);var b=[],S=h>1?f.get(["series","multiple","prefix"]):f.get(["series","single","prefix"]);m+=o(S,{seriesCount:h}),e.eachSeries(function(P,k){if(k1?f.get(["series","multiple",D]):f.get(["series","single",D]),I=o(I,{seriesId:P.seriesIndex,seriesName:P.get("name"),seriesType:l(P.subType)});var N=P.getData();if(N.count()>d){var B=f.get(["data","partialData"]);I+=o(B,{displayCnt:d})}else I+=f.get(["data","allData"]);for(var $=f.get(["data","separator","middle"]),F=f.get(["data","separator","end"]),G=f.get(["data","excludeDimensionId"]),z=[],U=0;U":"gt",">=":"gte","=":"eq","!=":"ne","<>":"ne"},tKe=function(){function e(t){var r=this._condVal=ve(t)?new RegExp(t):yK(t)?t:null;if(r==null){var n="";mt(n)}}return e.prototype.evaluate=function(t){var r=typeof t;return ve(r)?this._condVal.test(t):ot(r)?this._condVal.test(t+""):!1},e}(),rKe=function(){function e(){}return e.prototype.evaluate=function(){return this.value},e}(),nKe=function(){function e(){}return e.prototype.evaluate=function(){for(var t=this.children,r=0;r2&&n.push(i),i=[N,B]}function c(N,B,$,F){Wh(N,$)&&Wh(B,F)||i.push(N,B,$,F,$,F)}function f(N,B,$,F,G,z){var U=Math.abs(B-N),H=Math.tan(U/4)*4/3,Y=BP:O2&&n.push(i),n}function EO(e,t,r,n,i,a,o,s,l,u){if(Wh(e,r)&&Wh(t,n)&&Wh(i,o)&&Wh(a,s)){l.push(o,s);return}var c=2/u,f=c*c,h=o-e,d=s-t,v=Math.sqrt(h*h+d*d);h/=v,d/=v;var g=r-e,m=n-t,y=i-o,_=a-s,b=g*g+m*m,S=y*y+_*_;if(b=0&&P=0){l.push(o,s);return}var k=[],I=[];ru(e,r,i,o,.5,k),ru(t,n,a,s,.5,I),EO(k[0],I[0],k[1],I[1],k[2],I[2],k[3],I[3],l,u),EO(k[4],I[4],k[5],I[5],k[6],I[6],k[7],I[7],l,u)}function mKe(e,t){var r=OO(e),n=[];t=t||1;for(var i=0;i0)for(var u=0;uMath.abs(u),f=Cie([l,u],c?0:1,t),h=(c?s:u)/f.length,d=0;di,o=Cie([n,i],a?0:1,t),s=a?"width":"height",l=a?"height":"width",u=a?"x":"y",c=a?"y":"x",f=e[s]/o.length,h=0;h1?null:new Ie(g*l+e,g*u+t)}function _Ke(e,t,r){var n=new Ie;Ie.sub(n,r,t),n.normalize();var i=new Ie;Ie.sub(i,e,t);var a=i.dot(n);return a}function vh(e,t){var r=e[e.length-1];r&&r[0]===t[0]&&r[1]===t[1]||e.push(t)}function bKe(e,t,r){for(var n=e.length,i=[],a=0;ao?(u.x=c.x=s+a/2,u.y=l,c.y=l+o):(u.y=c.y=l+o/2,u.x=s,c.x=s+a),bKe(t,u,c)}function Qw(e,t,r,n){if(r===1)n.push(t);else{var i=Math.floor(r/2),a=e(t);Qw(e,a[0],i,n),Qw(e,a[1],r-i,n)}return n}function wKe(e,t){for(var r=[],n=0;n0;u/=2){var c=0,f=0;(e&u)>0&&(c=1),(t&u)>0&&(f=1),s+=u*u*(3*c^f),f===0&&(c===1&&(e=u-1-e,t=u-1-t),l=e,e=t,t=l)}return s}function tS(e){var t=1/0,r=1/0,n=-1/0,i=-1/0,a=se(e,function(s){var l=s.getBoundingRect(),u=s.getComputedTransform(),c=l.x+l.width/2+(u?u[4]:0),f=l.y+l.height/2+(u?u[5]:0);return t=Math.min(c,t),r=Math.min(f,r),n=Math.max(c,n),i=Math.max(f,i),[c,f]}),o=se(a,function(s,l){return{cp:s,z:IKe(s[0],s[1],t,r,n,i),path:e[l]}});return o.sort(function(s,l){return s.z-l.z}).map(function(s){return s.path})}function Lie(e){return AKe(e.path,e.count)}function DO(){return{fromIndividuals:[],toIndividuals:[],count:0}}function OKe(e,t,r){var n=[];function i(T){for(var A=0;A=0;i--)if(!r[i].many.length){var l=r[s].many;if(l.length<=1)if(s)s=0;else return r;var a=l.length,u=Math.ceil(a/2);r[i].many=l.slice(u,a),r[s].many=l.slice(0,u),s++}return r}var DKe={clone:function(e){for(var t=[],r=1-Math.pow(1-e.path.style.opacity,1/e.count),n=0;n0))return;var s=n.getModel("universalTransition").get("delay"),l=Object.assign({setToFinal:!0},o),u,c;yU(e)&&(u=e,c=t),yU(t)&&(u=t,c=e);function f(y,_,b,S,T){var A=y.many,M=y.one;if(A.length===1&&!T){var P=_?A[0]:M,k=_?M:A[0];if(Jw(P))f({many:[P],one:k},!0,b,S,!0);else{var I=s?Pe({delay:s(b,S)},l):l;PR(P,k,I),a(P,k,P,k,I)}}else for(var O=Pe({dividePath:DKe[r],individualDelay:s&&function(G,z,U,H){return s(G+b,S)}},l),D=_?OKe(A,M,O):EKe(M,A,O),N=D.fromIndividuals,B=D.toIndividuals,$=N.length,F=0;F<$;F++){var I=s?Pe({delay:s(F,$)},l):l;a(N[F],B[F],_?A[F]:y.one,_?y.one:A[F],I)}}for(var h=u?u===e:e.length>t.length,d=u?xU(c,u):xU(h?t:e,[h?e:t]),v=0,g=0;gkie))for(var a=n.getIndices(),o=0;o0&&A.group.traverse(function(P){P instanceof rt&&!P.animators.length&&P.animateFrom({style:{opacity:0}},M)})})}function TU(e){var t=e.getModel("universalTransition").get("seriesKey");return t||e.id}function AU(e){return ie(e)?e.sort().join(","):e}function xl(e){if(e.hostModel)return e.hostModel.getModel("universalTransition").get("divideShape")}function FKe(e,t){var r=_e(),n=_e(),i=_e();return R(e.oldSeries,function(a,o){var s=e.oldDataGroupIds[o],l=e.oldData[o],u=TU(a),c=AU(u);n.set(c,{dataGroupId:s,data:l}),ie(u)&&R(u,function(f){i.set(f,{key:c,dataGroupId:s,data:l})})}),R(t.updatedSeries,function(a){if(a.isUniversalTransitionEnabled()&&a.isAnimationEnabled()){var o=a.get("dataGroupId"),s=a.getData(),l=TU(a),u=AU(l),c=n.get(u);if(c)r.set(u,{oldSeries:[{dataGroupId:c.dataGroupId,divide:xl(c.data),data:c.data}],newSeries:[{dataGroupId:o,divide:xl(s),data:s}]});else if(ie(l)){var f=[];R(l,function(v){var g=n.get(v);g.data&&f.push({dataGroupId:g.dataGroupId,divide:xl(g.data),data:g.data})}),f.length&&r.set(u,{oldSeries:f,newSeries:[{dataGroupId:o,data:s,divide:xl(s)}]})}else{var h=i.get(l);if(h){var d=r.get(h.key);d||(d={oldSeries:[{dataGroupId:h.dataGroupId,data:h.data,divide:xl(h.data)}],newSeries:[]},r.set(h.key,d)),d.newSeries.push({dataGroupId:o,data:s,divide:xl(s)})}}}}),r}function CU(e,t){for(var r=0;r=0&&i.push({dataGroupId:t.oldDataGroupIds[s],data:t.oldData[s],divide:xl(t.oldData[s]),groupIdDim:o.dimension})}),R(Pt(e.to),function(o){var s=CU(r.updatedSeries,o);if(s>=0){var l=r.updatedSeries[s].getData();a.push({dataGroupId:t.oldDataGroupIds[s],data:l,divide:xl(l),groupIdDim:o.dimension})}}),i.length>0&&a.length>0&&Iie(i,a,n)}function GKe(e){e.registerUpdateLifecycle("series:beforeupdate",function(t,r,n){R(Pt(n.seriesTransition),function(i){R(Pt(i.to),function(a){for(var o=n.updatedSeries,s=0;so.vmin?r+=o.vmin-n+(t-o.vmin)/(o.vmax-o.vmin)*o.gapReal:r+=t-n,n=o.vmax,i=!1;break}r+=o.vmin-n+o.gapReal,n=o.vmax}return i&&(r+=t-n),r},e.prototype.unelapse=function(t){for(var r=MU,n=PU,i=!0,a=0,o=0;ol?a=s.vmin+(t-l)/(u-l)*(s.vmax-s.vmin):a=n+t-r,n=s.vmax,i=!1;break}r=u,n=s.vmax}return i&&(a=n+t-r),a},e}();function HKe(){return new WKe}var MU=0,PU=0;function UKe(e,t){var r=0,n={tpAbs:{span:0,val:0},tpPrct:{span:0,val:0}},i=function(){return{has:!1,span:NaN,inExtFrac:NaN,val:NaN}},a={S:{tpAbs:i(),tpPrct:i()},E:{tpAbs:i(),tpPrct:i()}};R(e.breaks,function(s){var l=s.gapParsed;l.type==="tpPrct"&&(r+=l.val);var u=LR(s,t);if(u){var c=u.vmin!==s.vmin,f=u.vmax!==s.vmax,h=u.vmax-u.vmin;if(!(c&&f))if(c||f){var d=c?"S":"E";a[d][l.type].has=!0,a[d][l.type].span=h,a[d][l.type].inExtFrac=h/(s.vmax-s.vmin),a[d][l.type].val=l.val}else n[l.type].span+=h,n[l.type].val+=l.val}});var o=r*(0+(t[1]-t[0])+(n.tpAbs.val-n.tpAbs.span)+(a.S.tpAbs.has?(a.S.tpAbs.val-a.S.tpAbs.span)*a.S.tpAbs.inExtFrac:0)+(a.E.tpAbs.has?(a.E.tpAbs.val-a.E.tpAbs.span)*a.E.tpAbs.inExtFrac:0)-n.tpPrct.span-(a.S.tpPrct.has?a.S.tpPrct.span*a.S.tpPrct.inExtFrac:0)-(a.E.tpPrct.has?a.E.tpPrct.span*a.E.tpPrct.inExtFrac:0))/(1-n.tpPrct.val-(a.S.tpPrct.has?a.S.tpPrct.val*a.S.tpPrct.inExtFrac:0)-(a.E.tpPrct.has?a.E.tpPrct.val*a.E.tpPrct.inExtFrac:0));R(e.breaks,function(s){var l=s.gapParsed;l.type==="tpPrct"&&(s.gapReal=r!==0?Math.max(o,0)*l.val/r:0),l.type==="tpAbs"&&(s.gapReal=l.val),s.gapReal==null&&(s.gapReal=0)})}function ZKe(e,t,r,n,i,a){e!=="no"&&R(r,function(o){var s=LR(o,a);if(s)for(var l=t.length-1;l>=0;l--){var u=t[l],c=n(u),f=i*3/4;c>s.vmin-f&&ct[0]&&r=0&&o<1-1e-5}R(e,function(o){if(!(!o||o.start==null||o.end==null)&&!o.isExpanded){var s={breakOption:Ce(o),vmin:t(o.start),vmax:t(o.end),gapParsed:{type:"tpAbs",val:0},gapReal:null};if(o.gap!=null){var l=!1;if(ve(o.gap)){var u=Ci(o.gap);if(u.match(/%$/)){var c=parseFloat(u)/100;i(c)||(c=0),s.gapParsed.type="tpPrct",s.gapParsed.val=c,l=!0}}if(!l){var f=t(o.gap);(!isFinite(f)||f<0)&&(f=0),s.gapParsed.type="tpAbs",s.gapParsed.val=f}}if(s.vmin===s.vmax&&(s.gapParsed.type="tpAbs",s.gapParsed.val=0),r&&r.noNegative&&R(["vmin","vmax"],function(d){s[d]<0&&(s[d]=0)}),s.vmin>s.vmax){var h=s.vmax;s.vmax=s.vmin,s.vmin=h}n.push(s)}}),n.sort(function(o,s){return o.vmin-s.vmin});var a=-1/0;return R(n,function(o,s){a>o.vmin&&(n[s]=null),a=o.vmax}),{breaks:n.filter(function(o){return!!o})}}function kR(e,t){return jO(t)===jO(e)}function jO(e){return e.start+"_\0_"+e.end}function XKe(e,t,r){var n=[];R(e,function(a,o){var s=t(a);s&&s.type==="vmin"&&n.push([o])}),R(e,function(a,o){var s=t(a);if(s&&s.type==="vmax"){var l=gu(n,function(u){return kR(t(e[u[0]]).parsedBreak.breakOption,s.parsedBreak.breakOption)});l&&l.push(o)}});var i=[];return R(n,function(a){a.length===2&&i.push(r?a:[e[a[0]],e[a[1]]])}),i}function qKe(e,t,r,n){var i,a;if(e.break){var o=e.break.parsedBreak,s=gu(r,function(f){return kR(f.breakOption,e.break.parsedBreak.breakOption)}),l=n(Math.pow(t,o.vmin),s.vmin),u=n(Math.pow(t,o.vmax),s.vmax),c={type:o.gapParsed.type,val:o.gapParsed.type==="tpAbs"?mr(Math.pow(t,o.vmin+o.gapParsed.val))-l:o.gapParsed.val};i={type:e.break.type,parsedBreak:{breakOption:o.breakOption,vmin:l,vmax:u,gapParsed:c,gapReal:o.gapReal}},a=s[e.break.type]}return{brkRoundingCriterion:a,vBreak:i}}function KKe(e,t,r){var n={noNegative:!0},i=NO(e,r,n),a=NO(e,r,n),o=Math.log(t);return a.breaks=se(a.breaks,function(s){var l=Math.log(s.vmin)/o,u=Math.log(s.vmax)/o,c={type:s.gapParsed.type,val:s.gapParsed.type==="tpAbs"?Math.log(s.vmin+s.gapParsed.val)/o-l:s.gapParsed.val};return{vmin:l,vmax:u,gapParsed:c,gapReal:s.gapReal,breakOption:s.breakOption}}),{parsedOriginal:i,parsedLogged:a}}var QKe={vmin:"start",vmax:"end"};function JKe(e,t){return t&&(e=e||{},e.break={type:QKe[t.type],start:t.parsedBreak.vmin,end:t.parsedBreak.vmax}),e}function eQe(){wBe({createScaleBreakContext:HKe,pruneTicksByBreak:ZKe,addBreaksToTicks:YKe,parseAxisBreakOption:NO,identifyAxisBreak:kR,serializeAxisBreakIdentifier:jO,retrieveAxisBreakPairs:XKe,getTicksLogTransformBreak:qKe,logarithmicParseBreaksFromOption:KKe,makeAxisLabelFormatterParamBreak:JKe})}var LU=Je();function tQe(e,t){var r=gu(e,function(n){return Sr().identifyAxisBreak(n.parsedBreak.breakOption,t.breakOption)});return r||e.push(r={zigzagRandomList:[],parsedBreak:t,shouldRemove:!1}),r}function rQe(e){R(e,function(t){return t.shouldRemove=!0})}function nQe(e){for(var t=e.length-1;t>=0;t--)e[t].shouldRemove&&e.splice(t,1)}function iQe(e,t,r,n,i){var a=r.axis;if(a.scale.isBlank()||!Sr())return;var o=Sr().retrieveAxisBreakPairs(a.scale.getTicks({breakTicks:"only_break"}),function(k){return k.break},!1);if(!o.length)return;var s=r.getModel("breakArea"),l=s.get("zigzagAmplitude"),u=s.get("zigzagMinSpan"),c=s.get("zigzagMaxSpan");u=Math.max(2,u||0),c=Math.max(u,c||0);var f=s.get("expandOnClick"),h=s.get("zigzagZ"),d=s.getModel("itemStyle"),v=d.getItemStyle(),g=v.stroke,m=v.lineWidth,y=v.lineDash,_=v.fill,b=new Me({ignoreModelZ:!0}),S=a.isHorizontal(),T=LU(t).visualList||(LU(t).visualList=[]);rQe(T);for(var A=function(k){var I=o[k][0].break.parsedBreak,O=[];O[0]=a.toGlobalCoord(a.dataToCoord(I.vmin,!0)),O[1]=a.toGlobalCoord(a.dataToCoord(I.vmax,!0)),O[1]=z;ge&&(J=z);var We=[],xe=[];We[F]=O,xe[F]=D,!ce&&!ge&&(We[F]+=Z?-l:l,xe[F]-=Z?l:-l),We[G]=J,xe[G]=J,H.push(We),Y.push(xe);var ne=void 0;if(ae_[1]&&_.reverse(),{coordPair:_,brkId:Sr().serializeAxisBreakIdentifier(y.breakOption)}});l.sort(function(m,y){return m.coordPair[0]-y.coordPair[0]});for(var u=o[0],c=null,f=0;f=0?l[0].width:l[1].width),h=(f+c.x)/2-u.x,d=Math.min(h,h-c.x),v=Math.max(h,h-c.x),g=v<0?v:d>0?d:0;s=(h-g)/c.x}var m=new Ie,y=new Ie;Ie.scale(m,n,-s),Ie.scale(y,n,1-s),RI(r[0],m),RI(r[1],y)}function sQe(e,t){var r={breaks:[]};return R(t.breaks,function(n){if(n){var i=gu(e.get("breaks",!0),function(s){return Sr().identifyAxisBreak(s,n)});if(i){var a=t.type,o={isExpanded:!!i.isExpanded};i.isExpanded=a===zT?!0:a===Qte?!1:a===Jte?!i.isExpanded:i.isExpanded,r.breaks.push({start:i.start,end:i.end,isExpanded:!!i.isExpanded,old:o})}}}),r}function lQe(){n6e({adjustBreakLabelPair:oQe,buildAxisBreakLine:aQe,rectCoordBuildBreakAxis:iQe,updateModelAxisBreak:sQe})}function uQe(e){u6e(e),eQe(),lQe()}function cQe(){k6e(fQe)}function fQe(e,t){R(e,function(r){if(!r.model.get(["axisLabel","inside"])){var n=hQe(r);if(n){var i=r.isHorizontal()?"height":"width",a=r.model.get(["axisLabel","margin"]);t[i]-=n[i]+a,r.position==="top"?t.y+=n.height+a:r.position==="left"&&(t.x+=n.width+a)}}})}function hQe(e){var t=e.model,r=e.scale;if(!t.get(["axisLabel","show"])||r.isBlank())return;var n,i,a=r.getExtent();r instanceof Jd?i=r.count():(n=r.getTicks(),i=n.length);var o=e.getLabelModel(),s=Hv(e),l,u=1;i>40&&(u=Math.ceil(i/40));for(var c=0;c1&&arguments[1]!==void 0?arguments[1]:60,i=null;return function(){for(var a=this,o=arguments.length,s=new Array(o),l=0;l12?"#22c55e":e>8?"#4ade80":e>5?"#f59e0b":e>3?"#f97316":"#ef4444"}function LQe(e){return e===null||e>46?0:e>44.5?1:e>43?2:3}function kQe(e){return e==="ROUTER"||e==="ROUTER_LATE"?30:e==="REPEATER"||e==="TRACKER"?25:e==="CLIENT_MUTE"?7:e==="CLIENT_BASE"?12:15}function IQe({nodes:e,edges:t,selectedNodeId:r,onSelectNode:n}){const i=W.useRef(null),[a,o]=W.useState("connected"),s=W.useMemo(()=>{const m=new Set;return t.forEach(y=>{m.add(y.from_node),m.add(y.to_node)}),m},[t]),l=W.useMemo(()=>{let m=e;return a==="connected"?m=m.filter(y=>s.has(y.node_num)):a==="infra"&&(m=m.filter(y=>OU.includes(y.role))),m},[e,a,s]),u=W.useMemo(()=>new Map(l.map(m=>[m.node_num,m])),[l]),c=W.useMemo(()=>t.filter(m=>u.has(m.from_node)&&u.has(m.to_node)),[t,u]),f=W.useMemo(()=>{const m=new Set;return r!==null&&c.forEach(y=>{y.from_node===r&&m.add(y.to_node),y.to_node===r&&m.add(y.from_node)}),m},[r,c]),h=W.useMemo(()=>{const m=l.map(_=>{const b=LQe(_.latitude),S=IU[b%IU.length],T=OU.includes(_.role),A=_.node_num===r,M=f.has(_.node_num),P=r===null||A||M;return{id:String(_.node_num),name:_.short_name,value:_.node_num,symbolSize:kQe(_.role),itemStyle:{color:T?S:"#111827",borderColor:S,borderWidth:T?0:2,opacity:P?1:.15},label:{show:!0,position:"bottom",distance:5,fontSize:10,fontFamily:"JetBrains Mono, monospace",color:P?"#94a3b8":"#94a3b820"},nodeNum:_.node_num,longName:_.long_name,role:_.role}}),y=c.map(_=>{const b=r===null||_.from_node===r||_.to_node===r;return{source:String(_.from_node),target:String(_.to_node),value:_.snr,lineStyle:{color:PQe(_.snr),width:b&&r!==null?2:1,opacity:r===null?.4:b?.6:.04}}});return{nodes:m,links:y}},[l,c,r,f]),d=W.useMemo(()=>({backgroundColor:"#111827",tooltip:{trigger:"item",backgroundColor:"#1e293b",borderColor:"#334155",textStyle:{color:"#e2e8f0",fontFamily:"JetBrains Mono, monospace",fontSize:11},formatter:m=>{if(m.data&&m.data.longName){const y=m.data;return`${y.name}
${y.longName}
Role: ${y.role}`}return""}},series:[{type:"graph",layout:"force",roam:!0,draggable:!0,animation:!1,data:h.nodes,links:h.links,force:{repulsion:200,edgeLength:[80,120],gravity:.1},emphasis:{focus:"adjacency",blurScope:"coordinateSystem",scale:1.1,lineStyle:{width:2}},blur:{itemStyle:{opacity:.15},lineStyle:{opacity:.04}},label:{show:!0,position:"bottom",distance:5,fontSize:10,fontFamily:"JetBrains Mono, monospace"},edgeLabel:{show:!1},edgeSymbol:["none","none"]}]}),[h]),v=W.useCallback(m=>{if(m.data&&"nodeNum"in m.data){const y=m.data.nodeNum;n(r===y?null:y??null)}},[r,n]),g=W.useMemo(()=>({click:v}),[v]);return W.useEffect(()=>{var y;const m=(y=i.current)==null?void 0:y.getEchartsInstance();m&&m.setOption(d,{notMerge:!1,lazyUpdate:!0})},[d]),x.jsxs("div",{className:"relative bg-bg-card rounded-lg border border-border overflow-hidden",children:[x.jsx(MQe,{ref:i,option:d,style:{height:"540px",width:"100%"},onEvents:g,opts:{renderer:"canvas"}}),x.jsxs("div",{className:"absolute top-4 left-4 flex items-center gap-2 bg-bg-card/90 backdrop-blur-sm border border-border rounded px-3 py-2",children:[x.jsx(FE,{size:14,className:"text-slate-500"}),x.jsx("div",{className:"flex gap-1",children:[{key:"connected",label:"Connected"},{key:"infra",label:"Infra"},{key:"all",label:"All"}].map(({key:m,label:y})=>x.jsx("button",{onClick:()=>o(m),className:`px-2 py-1 text-xs rounded transition-colors ${a===m?"bg-accent text-white":"bg-bg-hover text-slate-400 hover:text-slate-200"}`,children:y},m))}),x.jsxs("span",{className:"text-xs text-slate-500 ml-2",children:[l.length," nodes • ",c.length," edges"]})]}),x.jsxs("div",{className:"absolute bottom-4 left-4 bg-bg-card/90 backdrop-blur-sm border border-border rounded p-3",children:[x.jsx("div",{className:"text-xs text-slate-400 font-medium mb-2",children:"Edge Quality (SNR)"}),x.jsx("div",{className:"space-y-1",children:[{label:"Excellent (>12)",color:"#22c55e"},{label:"Good (8-12)",color:"#4ade80"},{label:"Fair (5-8)",color:"#f59e0b"},{label:"Marginal (3-5)",color:"#f97316"},{label:"Poor (<3)",color:"#ef4444"}].map(m=>x.jsxs("div",{className:"flex items-center gap-2",children:[x.jsx("div",{className:"w-4 h-0.5",style:{backgroundColor:m.color}}),x.jsx("span",{className:"text-xs text-slate-500",children:m.label})]},m.label))})]}),x.jsxs("div",{className:"absolute bottom-4 right-4 bg-bg-card/90 backdrop-blur-sm border border-border rounded p-3",children:[x.jsx("div",{className:"text-xs text-slate-400 font-medium mb-2",children:"Node Type"}),x.jsxs("div",{className:"space-y-2",children:[x.jsxs("div",{className:"flex items-center gap-2",children:[x.jsx("div",{className:"w-3 h-3 rounded-full bg-blue-500"}),x.jsx("span",{className:"text-xs text-slate-500",children:"Infrastructure"})]}),x.jsxs("div",{className:"flex items-center gap-2",children:[x.jsx("div",{className:"w-3 h-3 rounded-full bg-gray-900 border-2 border-blue-500"}),x.jsx("span",{className:"text-xs text-slate-500",children:"Client"})]})]})]})]})}function Die(e,t){const r=W.useRef(t);W.useEffect(function(){t!==r.current&&e.attributionControl!=null&&(r.current!=null&&e.attributionControl.removeAttribution(r.current),t!=null&&e.attributionControl.addAttribution(t)),r.current=t},[e,t])}function OQe(e,t,r){t.center!==r.center&&e.setLatLng(t.center),t.radius!=null&&t.radius!==r.radius&&e.setRadius(t.radius)}const EQe=1;function DQe(e){return Object.freeze({__version:EQe,map:e})}function Nie(e,t){return Object.freeze({...e,...t})}const jie=W.createContext(null),Rie=jie.Provider;function KT(){const e=W.useContext(jie);if(e==null)throw new Error("No context provided: useLeafletContext() can only be used in a descendant of ");return e}function NQe(e){function t(r,n){const{instance:i,context:a}=e(r).current;return W.useImperativeHandle(n,()=>i),r.children==null?null:Q.createElement(Rie,{value:a},r.children)}return W.forwardRef(t)}function jQe(e){function t(r,n){const[i,a]=W.useState(!1),{instance:o}=e(r,a).current;W.useImperativeHandle(n,()=>o),W.useEffect(function(){i&&o.update()},[o,i,r.children]);const s=o._contentNode;return s?tZ.createPortal(r.children,s):null}return W.forwardRef(t)}function RQe(e){function t(r,n){const{instance:i}=e(r).current;return W.useImperativeHandle(n,()=>i),null}return W.forwardRef(t)}function DR(e,t){const r=W.useRef();W.useEffect(function(){return t!=null&&e.instance.on(t),r.current=t,function(){r.current!=null&&e.instance.off(r.current),r.current=null}},[e,t])}function QT(e,t){const r=e.pane??t.pane;return r?{...e,pane:r}:e}function BQe(e,t){return function(n,i){const a=KT(),o=e(QT(n,a),a);return Die(a.map,n.attribution),DR(o.current,n.eventHandlers),t(o.current,a,n,i),o}}var zO={exports:{}};/* @preserve * Leaflet 1.9.4, a JS library for interactive maps. https://leafletjs.com * (c) 2010-2023 Vladimir Agafonkin, (c) 2010-2011 CloudMade - */(function(e,t){(function(r,n){n(t)})(ag,function(r){var n="1.9.4";function i(p){var w,C,E,j;for(C=1,E=arguments.length;C"u"||!L||!L.Mixin)){p=b(p)?p:[p];for(var w=0;w0?Math.floor(p):Math.ceil(p)};z.prototype={clone:function(){return new z(this.x,this.y)},add:function(p){return this.clone()._add(H(p))},_add:function(p){return this.x+=p.x,this.y+=p.y,this},subtract:function(p){return this.clone()._subtract(H(p))},_subtract:function(p){return this.x-=p.x,this.y-=p.y,this},divideBy:function(p){return this.clone()._divideBy(p)},_divideBy:function(p){return this.x/=p,this.y/=p,this},multiplyBy:function(p){return this.clone()._multiplyBy(p)},_multiplyBy:function(p){return this.x*=p,this.y*=p,this},scaleBy:function(p){return new z(this.x*p.x,this.y*p.y)},unscaleBy:function(p){return new z(this.x/p.x,this.y/p.y)},round:function(){return this.clone()._round()},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},floor:function(){return this.clone()._floor()},_floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this},ceil:function(){return this.clone()._ceil()},_ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this},trunc:function(){return this.clone()._trunc()},_trunc:function(){return this.x=U(this.x),this.y=U(this.y),this},distanceTo:function(p){p=H(p);var w=p.x-this.x,C=p.y-this.y;return Math.sqrt(w*w+C*C)},equals:function(p){return p=H(p),p.x===this.x&&p.y===this.y},contains:function(p){return p=H(p),Math.abs(p.x)<=Math.abs(this.x)&&Math.abs(p.y)<=Math.abs(this.y)},toString:function(){return"Point("+h(this.x)+", "+h(this.y)+")"}};function H(p,w,C){return p instanceof z?p:b(p)?new z(p[0],p[1]):p==null?p:typeof p=="object"&&"x"in p&&"y"in p?new z(p.x,p.y):new z(p,w,C)}function Y(p,w){if(p)for(var C=w?[p,w]:p,E=0,j=C.length;E=this.min.x&&C.x<=this.max.x&&w.y>=this.min.y&&C.y<=this.max.y},intersects:function(p){p=Z(p);var w=this.min,C=this.max,E=p.min,j=p.max,V=j.x>=w.x&&E.x<=C.x,X=j.y>=w.y&&E.y<=C.y;return V&&X},overlaps:function(p){p=Z(p);var w=this.min,C=this.max,E=p.min,j=p.max,V=j.x>w.x&&E.xw.y&&E.y=w.lat&&j.lat<=C.lat&&E.lng>=w.lng&&j.lng<=C.lng},intersects:function(p){p=ae(p);var w=this._southWest,C=this._northEast,E=p.getSouthWest(),j=p.getNorthEast(),V=j.lat>=w.lat&&E.lat<=C.lat,X=j.lng>=w.lng&&E.lng<=C.lng;return V&&X},overlaps:function(p){p=ae(p);var w=this._southWest,C=this._northEast,E=p.getSouthWest(),j=p.getNorthEast(),V=j.lat>w.lat&&E.latw.lng&&E.lng1,Qie=function(){var p=!1;try{var w=Object.defineProperty({},"passive",{get:function(){p=!0}});window.addEventListener("testPassiveEventSupport",f,w),window.removeEventListener("testPassiveEventSupport",f,w)}catch{}return p}(),Jie=function(){return!!document.createElement("canvas").getContext}(),tA=!!(document.createElementNS&&Fe("svg").createSVGRect),eae=!!tA&&function(){var p=document.createElement("div");return p.innerHTML="",(p.firstChild&&p.firstChild.namespaceURI)==="http://www.w3.org/2000/svg"}(),tae=!tA&&function(){try{var p=document.createElement("div");p.innerHTML='';var w=p.firstChild;return w.style.behavior="url(#default#VML)",w&&typeof w.adj=="object"}catch{return!1}}(),rae=navigator.platform.indexOf("Mac")===0,nae=navigator.platform.indexOf("Linux")===0;function Qa(p){return navigator.userAgent.toLowerCase().indexOf(p)>=0}var Ue={ie:Vt,ielt9:nr,edge:jn,webkit:qr,android:Jn,android23:kf,androidStock:T0,opera:JT,chrome:BR,gecko:zR,safari:Gie,phantom:$R,opera12:FR,win:Wie,ie3d:VR,webkit3d:eA,gecko3d:GR,any3d:Hie,mobile:qv,mobileWebkit:Uie,mobileWebkit3d:Zie,msPointer:WR,pointer:HR,touch:Yie,touchNative:UR,mobileOpera:Xie,mobileGecko:qie,retina:Kie,passiveEvents:Qie,canvas:Jie,svg:tA,vml:tae,inlineSvg:eae,mac:rae,linux:nae},ZR=Ue.msPointer?"MSPointerDown":"pointerdown",YR=Ue.msPointer?"MSPointerMove":"pointermove",XR=Ue.msPointer?"MSPointerUp":"pointerup",qR=Ue.msPointer?"MSPointerCancel":"pointercancel",rA={touchstart:ZR,touchmove:YR,touchend:XR,touchcancel:qR},KR={touchstart:uae,touchmove:A0,touchend:A0,touchcancel:A0},If={},QR=!1;function iae(p,w,C){return w==="touchstart"&&lae(),KR[w]?(C=KR[w].bind(this,C),p.addEventListener(rA[w],C,!1),C):(console.warn("wrong event specified:",w),f)}function aae(p,w,C){if(!rA[w]){console.warn("wrong event specified:",w);return}p.removeEventListener(rA[w],C,!1)}function oae(p){If[p.pointerId]=p}function sae(p){If[p.pointerId]&&(If[p.pointerId]=p)}function JR(p){delete If[p.pointerId]}function lae(){QR||(document.addEventListener(ZR,oae,!0),document.addEventListener(YR,sae,!0),document.addEventListener(XR,JR,!0),document.addEventListener(qR,JR,!0),QR=!0)}function A0(p,w){if(w.pointerType!==(w.MSPOINTER_TYPE_MOUSE||"mouse")){w.touches=[];for(var C in If)w.touches.push(If[C]);w.changedTouches=[w],p(w)}}function uae(p,w){w.MSPOINTER_TYPE_TOUCH&&w.pointerType===w.MSPOINTER_TYPE_TOUCH&&un(w),A0(p,w)}function cae(p){var w={},C,E;for(E in p)C=p[E],w[E]=C&&C.bind?C.bind(p):C;return p=w,w.type="dblclick",w.detail=2,w.isTrusted=!1,w._simulated=!0,w}var fae=200;function hae(p,w){p.addEventListener("dblclick",w);var C=0,E;function j(V){if(V.detail!==1){E=V.detail;return}if(!(V.pointerType==="mouse"||V.sourceCapabilities&&!V.sourceCapabilities.firesTouchEvents)){var X=i5(V);if(!(X.some(function(oe){return oe instanceof HTMLLabelElement&&oe.attributes.for})&&!X.some(function(oe){return oe instanceof HTMLInputElement||oe instanceof HTMLSelectElement}))){var te=Date.now();te-C<=fae?(E++,E===2&&w(cae(V))):E=1,C=te}}}return p.addEventListener("click",j),{dblclick:w,simDblclick:j}}function dae(p,w){p.removeEventListener("dblclick",w.dblclick),p.removeEventListener("click",w.simDblclick)}var nA=P0(["transform","webkitTransform","OTransform","MozTransform","msTransform"]),Kv=P0(["webkitTransition","transition","OTransition","MozTransition","msTransition"]),e5=Kv==="webkitTransition"||Kv==="OTransition"?Kv+"End":"transitionend";function t5(p){return typeof p=="string"?document.getElementById(p):p}function Qv(p,w){var C=p.style[w]||p.currentStyle&&p.currentStyle[w];if((!C||C==="auto")&&document.defaultView){var E=document.defaultView.getComputedStyle(p,null);C=E?E[w]:null}return C==="auto"?null:C}function Tt(p,w,C){var E=document.createElement(p);return E.className=w||"",C&&C.appendChild(E),E}function ir(p){var w=p.parentNode;w&&w.removeChild(p)}function C0(p){for(;p.firstChild;)p.removeChild(p.firstChild)}function Of(p){var w=p.parentNode;w&&w.lastChild!==p&&w.appendChild(p)}function Ef(p){var w=p.parentNode;w&&w.firstChild!==p&&w.insertBefore(p,w.firstChild)}function iA(p,w){if(p.classList!==void 0)return p.classList.contains(w);var C=M0(p);return C.length>0&&new RegExp("(^|\\s)"+w+"(\\s|$)").test(C)}function ut(p,w){if(p.classList!==void 0)for(var C=v(w),E=0,j=C.length;E0?2*window.devicePixelRatio:1;function o5(p){return Ue.edge?p.wheelDeltaY/2:p.deltaY&&p.deltaMode===0?-p.deltaY/gae:p.deltaY&&p.deltaMode===1?-p.deltaY*20:p.deltaY&&p.deltaMode===2?-p.deltaY*60:p.deltaX||p.deltaZ?0:p.wheelDelta?(p.wheelDeltaY||p.wheelDelta)/2:p.detail&&Math.abs(p.detail)<32765?-p.detail*20:p.detail?p.detail/-32765*60:0}function gA(p,w){var C=w.relatedTarget;if(!C)return!0;try{for(;C&&C!==p;)C=C.parentNode}catch{return!1}return C!==p}var mae={__proto__:null,on:st,off:Ht,stopPropagation:Tu,disableScrollPropagation:pA,disableClickPropagation:rp,preventDefault:un,stop:Au,getPropagationPath:i5,getMousePosition:a5,getWheelDelta:o5,isExternalTarget:gA,addListener:st,removeListener:Ht},s5=G.extend({run:function(p,w,C,E){this.stop(),this._el=p,this._inProgress=!0,this._duration=C||.25,this._easeOutPower=1/Math.max(E||.5,.2),this._startPos=Su(p),this._offset=w.subtract(this._startPos),this._startTime=+new Date,this.fire("start"),this._animate()},stop:function(){this._inProgress&&(this._step(!0),this._complete())},_animate:function(){this._animId=O(this._animate,this),this._step()},_step:function(p){var w=+new Date-this._startTime,C=this._duration*1e3;wthis.options.maxZoom)?this.setZoom(p):this},panInsideBounds:function(p,w){this._enforcingBounds=!0;var C=this.getCenter(),E=this._limitCenter(C,this._zoom,ae(p));return C.equals(E)||this.panTo(E,w),this._enforcingBounds=!1,this},panInside:function(p,w){w=w||{};var C=H(w.paddingTopLeft||w.padding||[0,0]),E=H(w.paddingBottomRight||w.padding||[0,0]),j=this.project(this.getCenter()),V=this.project(p),X=this.getPixelBounds(),te=Z([X.min.add(C),X.max.subtract(E)]),oe=te.getSize();if(!te.contains(V)){this._enforcingBounds=!0;var he=V.subtract(te.getCenter()),Ee=te.extend(V).getSize().subtract(oe);j.x+=he.x<0?-Ee.x:Ee.x,j.y+=he.y<0?-Ee.y:Ee.y,this.panTo(this.unproject(j),w),this._enforcingBounds=!1}return this},invalidateSize:function(p){if(!this._loaded)return this;p=i({animate:!1,pan:!0},p===!0?{animate:!0}:p);var w=this.getSize();this._sizeChanged=!0,this._lastCenter=null;var C=this.getSize(),E=w.divideBy(2).round(),j=C.divideBy(2).round(),V=E.subtract(j);return!V.x&&!V.y?this:(p.animate&&p.pan?this.panBy(V):(p.pan&&this._rawPanBy(V),this.fire("move"),p.debounceMoveend?(clearTimeout(this._sizeTimer),this._sizeTimer=setTimeout(o(this.fire,this,"moveend"),200)):this.fire("moveend")),this.fire("resize",{oldSize:w,newSize:C}))},stop:function(){return this.setZoom(this._limitZoom(this._zoom)),this.options.zoomSnap||this.fire("viewreset"),this._stop()},locate:function(p){if(p=this._locateOptions=i({timeout:1e4,watch:!1},p),!("geolocation"in navigator))return this._handleGeolocationError({code:0,message:"Geolocation not supported."}),this;var w=o(this._handleGeolocationResponse,this),C=o(this._handleGeolocationError,this);return p.watch?this._locationWatchId=navigator.geolocation.watchPosition(w,C,p):navigator.geolocation.getCurrentPosition(w,C,p),this},stopLocate:function(){return navigator.geolocation&&navigator.geolocation.clearWatch&&navigator.geolocation.clearWatch(this._locationWatchId),this._locateOptions&&(this._locateOptions.setView=!1),this},_handleGeolocationError:function(p){if(this._container._leaflet_id){var w=p.code,C=p.message||(w===1?"permission denied":w===2?"position unavailable":"timeout");this._locateOptions.setView&&!this._loaded&&this.fitWorld(),this.fire("locationerror",{code:w,message:"Geolocation error: "+C+"."})}},_handleGeolocationResponse:function(p){if(this._container._leaflet_id){var w=p.coords.latitude,C=p.coords.longitude,E=new ce(w,C),j=E.toBounds(p.coords.accuracy*2),V=this._locateOptions;if(V.setView){var X=this.getBoundsZoom(j);this.setView(E,V.maxZoom?Math.min(X,V.maxZoom):X)}var te={latlng:E,bounds:j,timestamp:p.timestamp};for(var oe in p.coords)typeof p.coords[oe]=="number"&&(te[oe]=p.coords[oe]);this.fire("locationfound",te)}},addHandler:function(p,w){if(!w)return this;var C=this[p]=new w(this);return this._handlers.push(C),this.options[p]&&C.enable(),this},remove:function(){if(this._initEvents(!0),this.options.maxBounds&&this.off("moveend",this._panInsideMaxBounds),this._containerId!==this._container._leaflet_id)throw new Error("Map container is being reused by another instance");try{delete this._container._leaflet_id,delete this._containerId}catch{this._container._leaflet_id=void 0,this._containerId=void 0}this._locationWatchId!==void 0&&this.stopLocate(),this._stop(),ir(this._mapPane),this._clearControlPos&&this._clearControlPos(),this._resizeRequest&&(D(this._resizeRequest),this._resizeRequest=null),this._clearHandlers(),this._loaded&&this.fire("unload");var p;for(p in this._layers)this._layers[p].remove();for(p in this._panes)ir(this._panes[p]);return this._layers=[],this._panes=[],delete this._mapPane,delete this._renderer,this},createPane:function(p,w){var C="leaflet-pane"+(p?" leaflet-"+p.replace("Pane","")+"-pane":""),E=Tt("div",C,w||this._mapPane);return p&&(this._panes[p]=E),E},getCenter:function(){return this._checkIfLoaded(),this._lastCenter&&!this._moved()?this._lastCenter.clone():this.layerPointToLatLng(this._getCenterLayerPoint())},getZoom:function(){return this._zoom},getBounds:function(){var p=this.getPixelBounds(),w=this.unproject(p.getBottomLeft()),C=this.unproject(p.getTopRight());return new J(w,C)},getMinZoom:function(){return this.options.minZoom===void 0?this._layersMinZoom||0:this.options.minZoom},getMaxZoom:function(){return this.options.maxZoom===void 0?this._layersMaxZoom===void 0?1/0:this._layersMaxZoom:this.options.maxZoom},getBoundsZoom:function(p,w,C){p=ae(p),C=H(C||[0,0]);var E=this.getZoom()||0,j=this.getMinZoom(),V=this.getMaxZoom(),X=p.getNorthWest(),te=p.getSouthEast(),oe=this.getSize().subtract(C),he=Z(this.project(te,E),this.project(X,E)).getSize(),Ee=Ue.any3d?this.options.zoomSnap:1,et=oe.x/he.x,pt=oe.y/he.y,Rn=w?Math.max(et,pt):Math.min(et,pt);return E=this.getScaleZoom(Rn,E),Ee&&(E=Math.round(E/(Ee/100))*(Ee/100),E=w?Math.ceil(E/Ee)*Ee:Math.floor(E/Ee)*Ee),Math.max(j,Math.min(V,E))},getSize:function(){return(!this._size||this._sizeChanged)&&(this._size=new z(this._container.clientWidth||0,this._container.clientHeight||0),this._sizeChanged=!1),this._size.clone()},getPixelBounds:function(p,w){var C=this._getTopLeftPoint(p,w);return new Y(C,C.add(this.getSize()))},getPixelOrigin:function(){return this._checkIfLoaded(),this._pixelOrigin},getPixelWorldBounds:function(p){return this.options.crs.getProjectedBounds(p===void 0?this.getZoom():p)},getPane:function(p){return typeof p=="string"?this._panes[p]:p},getPanes:function(){return this._panes},getContainer:function(){return this._container},getZoomScale:function(p,w){var C=this.options.crs;return w=w===void 0?this._zoom:w,C.scale(p)/C.scale(w)},getScaleZoom:function(p,w){var C=this.options.crs;w=w===void 0?this._zoom:w;var E=C.zoom(p*C.scale(w));return isNaN(E)?1/0:E},project:function(p,w){return w=w===void 0?this._zoom:w,this.options.crs.latLngToPoint(ge(p),w)},unproject:function(p,w){return w=w===void 0?this._zoom:w,this.options.crs.pointToLatLng(H(p),w)},layerPointToLatLng:function(p){var w=H(p).add(this.getPixelOrigin());return this.unproject(w)},latLngToLayerPoint:function(p){var w=this.project(ge(p))._round();return w._subtract(this.getPixelOrigin())},wrapLatLng:function(p){return this.options.crs.wrapLatLng(ge(p))},wrapLatLngBounds:function(p){return this.options.crs.wrapLatLngBounds(ae(p))},distance:function(p,w){return this.options.crs.distance(ge(p),ge(w))},containerPointToLayerPoint:function(p){return H(p).subtract(this._getMapPanePos())},layerPointToContainerPoint:function(p){return H(p).add(this._getMapPanePos())},containerPointToLatLng:function(p){var w=this.containerPointToLayerPoint(H(p));return this.layerPointToLatLng(w)},latLngToContainerPoint:function(p){return this.layerPointToContainerPoint(this.latLngToLayerPoint(ge(p)))},mouseEventToContainerPoint:function(p){return a5(p,this._container)},mouseEventToLayerPoint:function(p){return this.containerPointToLayerPoint(this.mouseEventToContainerPoint(p))},mouseEventToLatLng:function(p){return this.layerPointToLatLng(this.mouseEventToLayerPoint(p))},_initContainer:function(p){var w=this._container=t5(p);if(w){if(w._leaflet_id)throw new Error("Map container is already initialized.")}else throw new Error("Map container not found.");st(w,"scroll",this._onScroll,this),this._containerId=l(w)},_initLayout:function(){var p=this._container;this._fadeAnimated=this.options.fadeAnimation&&Ue.any3d,ut(p,"leaflet-container"+(Ue.touch?" leaflet-touch":"")+(Ue.retina?" leaflet-retina":"")+(Ue.ielt9?" leaflet-oldie":"")+(Ue.safari?" leaflet-safari":"")+(this._fadeAnimated?" leaflet-fade-anim":""));var w=Qv(p,"position");w!=="absolute"&&w!=="relative"&&w!=="fixed"&&w!=="sticky"&&(p.style.position="relative"),this._initPanes(),this._initControlPos&&this._initControlPos()},_initPanes:function(){var p=this._panes={};this._paneRenderers={},this._mapPane=this.createPane("mapPane",this._container),Cr(this._mapPane,new z(0,0)),this.createPane("tilePane"),this.createPane("overlayPane"),this.createPane("shadowPane"),this.createPane("markerPane"),this.createPane("tooltipPane"),this.createPane("popupPane"),this.options.markerZoomAnimation||(ut(p.markerPane,"leaflet-zoom-hide"),ut(p.shadowPane,"leaflet-zoom-hide"))},_resetView:function(p,w,C){Cr(this._mapPane,new z(0,0));var E=!this._loaded;this._loaded=!0,w=this._limitZoom(w),this.fire("viewprereset");var j=this._zoom!==w;this._moveStart(j,C)._move(p,w)._moveEnd(j),this.fire("viewreset"),E&&this.fire("load")},_moveStart:function(p,w){return p&&this.fire("zoomstart"),w||this.fire("movestart"),this},_move:function(p,w,C,E){w===void 0&&(w=this._zoom);var j=this._zoom!==w;return this._zoom=w,this._lastCenter=p,this._pixelOrigin=this._getNewPixelOrigin(p),E?C&&C.pinch&&this.fire("zoom",C):((j||C&&C.pinch)&&this.fire("zoom",C),this.fire("move",C)),this},_moveEnd:function(p){return p&&this.fire("zoomend"),this.fire("moveend")},_stop:function(){return D(this._flyToFrame),this._panAnim&&this._panAnim.stop(),this},_rawPanBy:function(p){Cr(this._mapPane,this._getMapPanePos().subtract(p))},_getZoomSpan:function(){return this.getMaxZoom()-this.getMinZoom()},_panInsideMaxBounds:function(){this._enforcingBounds||this.panInsideBounds(this.options.maxBounds)},_checkIfLoaded:function(){if(!this._loaded)throw new Error("Set map center and zoom first.")},_initEvents:function(p){this._targets={},this._targets[l(this._container)]=this;var w=p?Ht:st;w(this._container,"click dblclick mousedown mouseup mouseover mouseout mousemove contextmenu keypress keydown keyup",this._handleDOMEvent,this),this.options.trackResize&&w(window,"resize",this._onResize,this),Ue.any3d&&this.options.transform3DLimit&&(p?this.off:this.on).call(this,"moveend",this._onMoveEnd)},_onResize:function(){D(this._resizeRequest),this._resizeRequest=O(function(){this.invalidateSize({debounceMoveend:!0})},this)},_onScroll:function(){this._container.scrollTop=0,this._container.scrollLeft=0},_onMoveEnd:function(){var p=this._getMapPanePos();Math.max(Math.abs(p.x),Math.abs(p.y))>=this.options.transform3DLimit&&this._resetView(this.getCenter(),this.getZoom())},_findEventTargets:function(p,w){for(var C=[],E,j=w==="mouseout"||w==="mouseover",V=p.target||p.srcElement,X=!1;V;){if(E=this._targets[l(V)],E&&(w==="click"||w==="preclick")&&this._draggableMoved(E)){X=!0;break}if(E&&E.listens(w,!0)&&(j&&!gA(V,p)||(C.push(E),j))||V===this._container)break;V=V.parentNode}return!C.length&&!X&&!j&&this.listens(w,!0)&&(C=[this]),C},_isClickDisabled:function(p){for(;p&&p!==this._container;){if(p._leaflet_disable_click)return!0;p=p.parentNode}},_handleDOMEvent:function(p){var w=p.target||p.srcElement;if(!(!this._loaded||w._leaflet_disable_events||p.type==="click"&&this._isClickDisabled(w))){var C=p.type;C==="mousedown"&&cA(w),this._fireDOMEvent(p,C)}},_mouseEvents:["click","dblclick","mouseover","mouseout","contextmenu"],_fireDOMEvent:function(p,w,C){if(p.type==="click"){var E=i({},p);E.type="preclick",this._fireDOMEvent(E,E.type,C)}var j=this._findEventTargets(p,w);if(C){for(var V=[],X=0;X0?Math.round(p-w)/2:Math.max(0,Math.ceil(p))-Math.max(0,Math.floor(w))},_limitZoom:function(p){var w=this.getMinZoom(),C=this.getMaxZoom(),E=Ue.any3d?this.options.zoomSnap:1;return E&&(p=Math.round(p/E)*E),Math.max(w,Math.min(C,p))},_onPanTransitionStep:function(){this.fire("move")},_onPanTransitionEnd:function(){_r(this._mapPane,"leaflet-pan-anim"),this.fire("moveend")},_tryAnimatedPan:function(p,w){var C=this._getCenterOffset(p)._trunc();return(w&&w.animate)!==!0&&!this.getSize().contains(C)?!1:(this.panBy(C,w),!0)},_createAnimProxy:function(){var p=this._proxy=Tt("div","leaflet-proxy leaflet-zoom-animated");this._panes.mapPane.appendChild(p),this.on("zoomanim",function(w){var C=nA,E=this._proxy.style[C];wu(this._proxy,this.project(w.center,w.zoom),this.getZoomScale(w.zoom,1)),E===this._proxy.style[C]&&this._animatingZoom&&this._onZoomTransitionEnd()},this),this.on("load moveend",this._animMoveEnd,this),this._on("unload",this._destroyAnimProxy,this)},_destroyAnimProxy:function(){ir(this._proxy),this.off("load moveend",this._animMoveEnd,this),delete this._proxy},_animMoveEnd:function(){var p=this.getCenter(),w=this.getZoom();wu(this._proxy,this.project(p,w),this.getZoomScale(w,1))},_catchTransitionEnd:function(p){this._animatingZoom&&p.propertyName.indexOf("transform")>=0&&this._onZoomTransitionEnd()},_nothingToAnimate:function(){return!this._container.getElementsByClassName("leaflet-zoom-animated").length},_tryAnimatedZoom:function(p,w,C){if(this._animatingZoom)return!0;if(C=C||{},!this._zoomAnimated||C.animate===!1||this._nothingToAnimate()||Math.abs(w-this._zoom)>this.options.zoomAnimationThreshold)return!1;var E=this.getZoomScale(w),j=this._getCenterOffset(p)._divideBy(1-1/E);return C.animate!==!0&&!this.getSize().contains(j)?!1:(O(function(){this._moveStart(!0,C.noMoveStart||!1)._animateZoom(p,w,!0)},this),!0)},_animateZoom:function(p,w,C,E){this._mapPane&&(C&&(this._animatingZoom=!0,this._animateToCenter=p,this._animateToZoom=w,ut(this._mapPane,"leaflet-zoom-anim")),this.fire("zoomanim",{center:p,zoom:w,noUpdate:E}),this._tempFireZoomEvent||(this._tempFireZoomEvent=this._zoom!==this._animateToZoom),this._move(this._animateToCenter,this._animateToZoom,void 0,!0),setTimeout(o(this._onZoomTransitionEnd,this),250))},_onZoomTransitionEnd:function(){this._animatingZoom&&(this._mapPane&&_r(this._mapPane,"leaflet-zoom-anim"),this._animatingZoom=!1,this._move(this._animateToCenter,this._animateToZoom,void 0,!0),this._tempFireZoomEvent&&this.fire("zoom"),delete this._tempFireZoomEvent,this.fire("move"),this._moveEnd(!0))}});function yae(p,w){return new bt(p,w)}var ba=B.extend({options:{position:"topright"},initialize:function(p){g(this,p)},getPosition:function(){return this.options.position},setPosition:function(p){var w=this._map;return w&&w.removeControl(this),this.options.position=p,w&&w.addControl(this),this},getContainer:function(){return this._container},addTo:function(p){this.remove(),this._map=p;var w=this._container=this.onAdd(p),C=this.getPosition(),E=p._controlCorners[C];return ut(w,"leaflet-control"),C.indexOf("bottom")!==-1?E.insertBefore(w,E.firstChild):E.appendChild(w),this._map.on("unload",this.remove,this),this},remove:function(){return this._map?(ir(this._container),this.onRemove&&this.onRemove(this._map),this._map.off("unload",this.remove,this),this._map=null,this):this},_refocusOnMap:function(p){this._map&&p&&p.screenX>0&&p.screenY>0&&this._map.getContainer().focus()}}),np=function(p){return new ba(p)};bt.include({addControl:function(p){return p.addTo(this),this},removeControl:function(p){return p.remove(),this},_initControlPos:function(){var p=this._controlCorners={},w="leaflet-",C=this._controlContainer=Tt("div",w+"control-container",this._container);function E(j,V){var X=w+j+" "+w+V;p[j+V]=Tt("div",X,C)}E("top","left"),E("top","right"),E("bottom","left"),E("bottom","right")},_clearControlPos:function(){for(var p in this._controlCorners)ir(this._controlCorners[p]);ir(this._controlContainer),delete this._controlCorners,delete this._controlContainer}});var l5=ba.extend({options:{collapsed:!0,position:"topright",autoZIndex:!0,hideSingleBase:!1,sortLayers:!1,sortFunction:function(p,w,C,E){return C1,this._baseLayersList.style.display=p?"":"none"),this._separator.style.display=w&&p?"":"none",this},_onLayerChange:function(p){this._handlingClick||this._update();var w=this._getLayer(l(p.target)),C=w.overlay?p.type==="add"?"overlayadd":"overlayremove":p.type==="add"?"baselayerchange":null;C&&this._map.fire(C,w)},_createRadioElement:function(p,w){var C='",E=document.createElement("div");return E.innerHTML=C,E.firstChild},_addItem:function(p){var w=document.createElement("label"),C=this._map.hasLayer(p.layer),E;p.overlay?(E=document.createElement("input"),E.type="checkbox",E.className="leaflet-control-layers-selector",E.defaultChecked=C):E=this._createRadioElement("leaflet-base-layers_"+l(this),C),this._layerControlInputs.push(E),E.layerId=l(p.layer),st(E,"click",this._onInputClick,this);var j=document.createElement("span");j.innerHTML=" "+p.name;var V=document.createElement("span");w.appendChild(V),V.appendChild(E),V.appendChild(j);var X=p.overlay?this._overlaysList:this._baseLayersList;return X.appendChild(w),this._checkDisabledLayers(),w},_onInputClick:function(){if(!this._preventClick){var p=this._layerControlInputs,w,C,E=[],j=[];this._handlingClick=!0;for(var V=p.length-1;V>=0;V--)w=p[V],C=this._getLayer(w.layerId).layer,w.checked?E.push(C):w.checked||j.push(C);for(V=0;V=0;j--)w=p[j],C=this._getLayer(w.layerId).layer,w.disabled=C.options.minZoom!==void 0&&EC.options.maxZoom},_expandIfNotCollapsed:function(){return this._map&&!this.options.collapsed&&this.expand(),this},_expandSafely:function(){var p=this._section;this._preventClick=!0,st(p,"click",un),this.expand();var w=this;setTimeout(function(){Ht(p,"click",un),w._preventClick=!1})}}),xae=function(p,w,C){return new l5(p,w,C)},mA=ba.extend({options:{position:"topleft",zoomInText:'',zoomInTitle:"Zoom in",zoomOutText:'',zoomOutTitle:"Zoom out"},onAdd:function(p){var w="leaflet-control-zoom",C=Tt("div",w+" leaflet-bar"),E=this.options;return this._zoomInButton=this._createButton(E.zoomInText,E.zoomInTitle,w+"-in",C,this._zoomIn),this._zoomOutButton=this._createButton(E.zoomOutText,E.zoomOutTitle,w+"-out",C,this._zoomOut),this._updateDisabled(),p.on("zoomend zoomlevelschange",this._updateDisabled,this),C},onRemove:function(p){p.off("zoomend zoomlevelschange",this._updateDisabled,this)},disable:function(){return this._disabled=!0,this._updateDisabled(),this},enable:function(){return this._disabled=!1,this._updateDisabled(),this},_zoomIn:function(p){!this._disabled&&this._map._zoomthis._map.getMinZoom()&&this._map.zoomOut(this._map.options.zoomDelta*(p.shiftKey?3:1))},_createButton:function(p,w,C,E,j){var V=Tt("a",C,E);return V.innerHTML=p,V.href="#",V.title=w,V.setAttribute("role","button"),V.setAttribute("aria-label",w),rp(V),st(V,"click",Au),st(V,"click",j,this),st(V,"click",this._refocusOnMap,this),V},_updateDisabled:function(){var p=this._map,w="leaflet-disabled";_r(this._zoomInButton,w),_r(this._zoomOutButton,w),this._zoomInButton.setAttribute("aria-disabled","false"),this._zoomOutButton.setAttribute("aria-disabled","false"),(this._disabled||p._zoom===p.getMinZoom())&&(ut(this._zoomOutButton,w),this._zoomOutButton.setAttribute("aria-disabled","true")),(this._disabled||p._zoom===p.getMaxZoom())&&(ut(this._zoomInButton,w),this._zoomInButton.setAttribute("aria-disabled","true"))}});bt.mergeOptions({zoomControl:!0}),bt.addInitHook(function(){this.options.zoomControl&&(this.zoomControl=new mA,this.addControl(this.zoomControl))});var _ae=function(p){return new mA(p)},u5=ba.extend({options:{position:"bottomleft",maxWidth:100,metric:!0,imperial:!0},onAdd:function(p){var w="leaflet-control-scale",C=Tt("div",w),E=this.options;return this._addScales(E,w+"-line",C),p.on(E.updateWhenIdle?"moveend":"move",this._update,this),p.whenReady(this._update,this),C},onRemove:function(p){p.off(this.options.updateWhenIdle?"moveend":"move",this._update,this)},_addScales:function(p,w,C){p.metric&&(this._mScale=Tt("div",w,C)),p.imperial&&(this._iScale=Tt("div",w,C))},_update:function(){var p=this._map,w=p.getSize().y/2,C=p.distance(p.containerPointToLatLng([0,w]),p.containerPointToLatLng([this.options.maxWidth,w]));this._updateScales(C)},_updateScales:function(p){this.options.metric&&p&&this._updateMetric(p),this.options.imperial&&p&&this._updateImperial(p)},_updateMetric:function(p){var w=this._getRoundNum(p),C=w<1e3?w+" m":w/1e3+" km";this._updateScale(this._mScale,C,w/p)},_updateImperial:function(p){var w=p*3.2808399,C,E,j;w>5280?(C=w/5280,E=this._getRoundNum(C),this._updateScale(this._iScale,E+" mi",E/C)):(j=this._getRoundNum(w),this._updateScale(this._iScale,j+" ft",j/w))},_updateScale:function(p,w,C){p.style.width=Math.round(this.options.maxWidth*C)+"px",p.innerHTML=w},_getRoundNum:function(p){var w=Math.pow(10,(Math.floor(p)+"").length-1),C=p/w;return C=C>=10?10:C>=5?5:C>=3?3:C>=2?2:1,w*C}}),bae=function(p){return new u5(p)},wae='',yA=ba.extend({options:{position:"bottomright",prefix:''+(Ue.inlineSvg?wae+" ":"")+"Leaflet"},initialize:function(p){g(this,p),this._attributions={}},onAdd:function(p){p.attributionControl=this,this._container=Tt("div","leaflet-control-attribution"),rp(this._container);for(var w in p._layers)p._layers[w].getAttribution&&this.addAttribution(p._layers[w].getAttribution());return this._update(),p.on("layeradd",this._addAttribution,this),this._container},onRemove:function(p){p.off("layeradd",this._addAttribution,this)},_addAttribution:function(p){p.layer.getAttribution&&(this.addAttribution(p.layer.getAttribution()),p.layer.once("remove",function(){this.removeAttribution(p.layer.getAttribution())},this))},setPrefix:function(p){return this.options.prefix=p,this._update(),this},addAttribution:function(p){return p?(this._attributions[p]||(this._attributions[p]=0),this._attributions[p]++,this._update(),this):this},removeAttribution:function(p){return p?(this._attributions[p]&&(this._attributions[p]--,this._update()),this):this},_update:function(){if(this._map){var p=[];for(var w in this._attributions)this._attributions[w]&&p.push(w);var C=[];this.options.prefix&&C.push(this.options.prefix),p.length&&C.push(p.join(", ")),this._container.innerHTML=C.join(' ')}}});bt.mergeOptions({attributionControl:!0}),bt.addInitHook(function(){this.options.attributionControl&&new yA().addTo(this)});var Sae=function(p){return new yA(p)};ba.Layers=l5,ba.Zoom=mA,ba.Scale=u5,ba.Attribution=yA,np.layers=xae,np.zoom=_ae,np.scale=bae,np.attribution=Sae;var eo=B.extend({initialize:function(p){this._map=p},enable:function(){return this._enabled?this:(this._enabled=!0,this.addHooks(),this)},disable:function(){return this._enabled?(this._enabled=!1,this.removeHooks(),this):this},enabled:function(){return!!this._enabled}});eo.addTo=function(p,w){return p.addHandler(w,this),this};var Tae={Events:F},c5=Ue.touch?"touchstart mousedown":"mousedown",Js=G.extend({options:{clickTolerance:3},initialize:function(p,w,C,E){g(this,E),this._element=p,this._dragStartTarget=w||p,this._preventOutline=C},enable:function(){this._enabled||(st(this._dragStartTarget,c5,this._onDown,this),this._enabled=!0)},disable:function(){this._enabled&&(Js._dragging===this&&this.finishDrag(!0),Ht(this._dragStartTarget,c5,this._onDown,this),this._enabled=!1,this._moved=!1)},_onDown:function(p){if(this._enabled&&(this._moved=!1,!iA(this._element,"leaflet-zoom-anim"))){if(p.touches&&p.touches.length!==1){Js._dragging===this&&this.finishDrag();return}if(!(Js._dragging||p.shiftKey||p.which!==1&&p.button!==1&&!p.touches)&&(Js._dragging=this,this._preventOutline&&cA(this._element),sA(),Jv(),!this._moving)){this.fire("down");var w=p.touches?p.touches[0]:p,C=r5(this._element);this._startPoint=new z(w.clientX,w.clientY),this._startPos=Su(this._element),this._parentScale=fA(C);var E=p.type==="mousedown";st(document,E?"mousemove":"touchmove",this._onMove,this),st(document,E?"mouseup":"touchend touchcancel",this._onUp,this)}}},_onMove:function(p){if(this._enabled){if(p.touches&&p.touches.length>1){this._moved=!0;return}var w=p.touches&&p.touches.length===1?p.touches[0]:p,C=new z(w.clientX,w.clientY)._subtract(this._startPoint);!C.x&&!C.y||Math.abs(C.x)+Math.abs(C.y)V&&(X=te,V=oe);V>C&&(w[X]=1,_A(p,w,C,E,X),_A(p,w,C,X,j))}function Pae(p,w){for(var C=[p[0]],E=1,j=0,V=p.length;Ew&&(C.push(p[E]),j=E);return jw.max.x&&(C|=2),p.yw.max.y&&(C|=8),C}function Lae(p,w){var C=w.x-p.x,E=w.y-p.y;return C*C+E*E}function ip(p,w,C,E){var j=w.x,V=w.y,X=C.x-j,te=C.y-V,oe=X*X+te*te,he;return oe>0&&(he=((p.x-j)*X+(p.y-V)*te)/oe,he>1?(j=C.x,V=C.y):he>0&&(j+=X*he,V+=te*he)),X=p.x-j,te=p.y-V,E?X*X+te*te:new z(j,V)}function Bi(p){return!b(p[0])||typeof p[0][0]!="object"&&typeof p[0][0]<"u"}function m5(p){return console.warn("Deprecated use of _flat, please use L.LineUtil.isFlat instead."),Bi(p)}function y5(p,w){var C,E,j,V,X,te,oe,he;if(!p||p.length===0)throw new Error("latlngs not passed");Bi(p)||(console.warn("latlngs are not flat! Only the first ring will be used"),p=p[0]);var Ee=ge([0,0]),et=ae(p),pt=et.getNorthWest().distanceTo(et.getSouthWest())*et.getNorthEast().distanceTo(et.getNorthWest());pt<1700&&(Ee=xA(p));var Rn=p.length,Kr=[];for(C=0;CE){oe=(V-E)/j,he=[te.x-oe*(te.x-X.x),te.y-oe*(te.y-X.y)];break}var ei=w.unproject(H(he));return ge([ei.lat+Ee.lat,ei.lng+Ee.lng])}var kae={__proto__:null,simplify:d5,pointToSegmentDistance:v5,closestPointOnSegment:Cae,clipSegment:g5,_getEdgeIntersection:I0,_getBitCode:Cu,_sqClosestPointOnSegment:ip,isFlat:Bi,_flat:m5,polylineCenter:y5},bA={project:function(p){return new z(p.lng,p.lat)},unproject:function(p){return new ce(p.y,p.x)},bounds:new Y([-180,-90],[180,90])},wA={R:6378137,R_MINOR:6356752314245179e-9,bounds:new Y([-2003750834279e-5,-1549657073972e-5],[2003750834279e-5,1876465623138e-5]),project:function(p){var w=Math.PI/180,C=this.R,E=p.lat*w,j=this.R_MINOR/C,V=Math.sqrt(1-j*j),X=V*Math.sin(E),te=Math.tan(Math.PI/4-E/2)/Math.pow((1-X)/(1+X),V/2);return E=-C*Math.log(Math.max(te,1e-10)),new z(p.lng*w*C,E)},unproject:function(p){for(var w=180/Math.PI,C=this.R,E=this.R_MINOR/C,j=Math.sqrt(1-E*E),V=Math.exp(-p.y/C),X=Math.PI/2-2*Math.atan(V),te=0,oe=.1,he;te<15&&Math.abs(oe)>1e-7;te++)he=j*Math.sin(X),he=Math.pow((1-he)/(1+he),j/2),oe=Math.PI/2-2*Math.atan(V*he)-X,X+=oe;return new ce(X*w,p.x*w/C)}},Iae={__proto__:null,LonLat:bA,Mercator:wA,SphericalMercator:fe},Oae=i({},xe,{code:"EPSG:3395",projection:wA,transformation:function(){var p=.5/(Math.PI*wA.R);return ee(p,.5,-p,.5)}()}),x5=i({},xe,{code:"EPSG:4326",projection:bA,transformation:ee(1/180,1,-1/180,.5)}),Eae=i({},We,{projection:bA,transformation:ee(1,0,-1,0),scale:function(p){return Math.pow(2,p)},zoom:function(p){return Math.log(p)/Math.LN2},distance:function(p,w){var C=w.lng-p.lng,E=w.lat-p.lat;return Math.sqrt(C*C+E*E)},infinite:!0});We.Earth=xe,We.EPSG3395=Oae,We.EPSG3857=$e,We.EPSG900913=Se,We.EPSG4326=x5,We.Simple=Eae;var wa=G.extend({options:{pane:"overlayPane",attribution:null,bubblingMouseEvents:!0},addTo:function(p){return p.addLayer(this),this},remove:function(){return this.removeFrom(this._map||this._mapToAdd)},removeFrom:function(p){return p&&p.removeLayer(this),this},getPane:function(p){return this._map.getPane(p?this.options[p]||p:this.options.pane)},addInteractiveTarget:function(p){return this._map._targets[l(p)]=this,this},removeInteractiveTarget:function(p){return delete this._map._targets[l(p)],this},getAttribution:function(){return this.options.attribution},_layerAdd:function(p){var w=p.target;if(w.hasLayer(this)){if(this._map=w,this._zoomAnimated=w._zoomAnimated,this.getEvents){var C=this.getEvents();w.on(C,this),this.once("remove",function(){w.off(C,this)},this)}this.onAdd(w),this.fire("add"),w.fire("layeradd",{layer:this})}}});bt.include({addLayer:function(p){if(!p._layerAdd)throw new Error("The provided object is not a Layer.");var w=l(p);return this._layers[w]?this:(this._layers[w]=p,p._mapToAdd=this,p.beforeAdd&&p.beforeAdd(this),this.whenReady(p._layerAdd,p),this)},removeLayer:function(p){var w=l(p);return this._layers[w]?(this._loaded&&p.onRemove(this),delete this._layers[w],this._loaded&&(this.fire("layerremove",{layer:p}),p.fire("remove")),p._map=p._mapToAdd=null,this):this},hasLayer:function(p){return l(p)in this._layers},eachLayer:function(p,w){for(var C in this._layers)p.call(w,this._layers[C]);return this},_addLayers:function(p){p=p?b(p)?p:[p]:[];for(var w=0,C=p.length;wthis._layersMaxZoom&&this.setZoom(this._layersMaxZoom),this.options.minZoom===void 0&&this._layersMinZoom&&this.getZoom()=2&&w[0]instanceof ce&&w[0].equals(w[C-1])&&w.pop(),w},_setLatLngs:function(p){qo.prototype._setLatLngs.call(this,p),Bi(this._latlngs)&&(this._latlngs=[this._latlngs])},_defaultShape:function(){return Bi(this._latlngs[0])?this._latlngs[0]:this._latlngs[0][0]},_clipPoints:function(){var p=this._renderer._bounds,w=this.options.weight,C=new z(w,w);if(p=new Y(p.min.subtract(C),p.max.add(C)),this._parts=[],!(!this._pxBounds||!this._pxBounds.intersects(p))){if(this.options.noClip){this._parts=this._rings;return}for(var E=0,j=this._rings.length,V;Ep.y!=j.y>p.y&&p.x<(j.x-E.x)*(p.y-E.y)/(j.y-E.y)+E.x&&(w=!w);return w||qo.prototype._containsPoint.call(this,p,!0)}});function Fae(p,w){return new jf(p,w)}var Ko=Xo.extend({initialize:function(p,w){g(this,w),this._layers={},p&&this.addData(p)},addData:function(p){var w=b(p)?p:p.features,C,E,j;if(w){for(C=0,E=w.length;C0&&j.push(j[0].slice()),j}function Rf(p,w){return p.feature?i({},p.feature,{geometry:w}):R0(w)}function R0(p){return p.type==="Feature"||p.type==="FeatureCollection"?p:{type:"Feature",properties:{},geometry:p}}var CA={toGeoJSON:function(p){return Rf(this,{type:"Point",coordinates:AA(this.getLatLng(),p)})}};O0.include(CA),SA.include(CA),E0.include(CA),qo.include({toGeoJSON:function(p){var w=!Bi(this._latlngs),C=j0(this._latlngs,w?1:0,!1,p);return Rf(this,{type:(w?"Multi":"")+"LineString",coordinates:C})}}),jf.include({toGeoJSON:function(p){var w=!Bi(this._latlngs),C=w&&!Bi(this._latlngs[0]),E=j0(this._latlngs,C?2:w?1:0,!0,p);return w||(E=[E]),Rf(this,{type:(C?"Multi":"")+"Polygon",coordinates:E})}}),Df.include({toMultiPoint:function(p){var w=[];return this.eachLayer(function(C){w.push(C.toGeoJSON(p).geometry.coordinates)}),Rf(this,{type:"MultiPoint",coordinates:w})},toGeoJSON:function(p){var w=this.feature&&this.feature.geometry&&this.feature.geometry.type;if(w==="MultiPoint")return this.toMultiPoint(p);var C=w==="GeometryCollection",E=[];return this.eachLayer(function(j){if(j.toGeoJSON){var V=j.toGeoJSON(p);if(C)E.push(V.geometry);else{var X=R0(V);X.type==="FeatureCollection"?E.push.apply(E,X.features):E.push(X)}}}),C?Rf(this,{geometries:E,type:"GeometryCollection"}):{type:"FeatureCollection",features:E}}});function w5(p,w){return new Ko(p,w)}var Vae=w5,B0=wa.extend({options:{opacity:1,alt:"",interactive:!1,crossOrigin:!1,errorOverlayUrl:"",zIndex:1,className:""},initialize:function(p,w,C){this._url=p,this._bounds=ae(w),g(this,C)},onAdd:function(){this._image||(this._initImage(),this.options.opacity<1&&this._updateOpacity()),this.options.interactive&&(ut(this._image,"leaflet-interactive"),this.addInteractiveTarget(this._image)),this.getPane().appendChild(this._image),this._reset()},onRemove:function(){ir(this._image),this.options.interactive&&this.removeInteractiveTarget(this._image)},setOpacity:function(p){return this.options.opacity=p,this._image&&this._updateOpacity(),this},setStyle:function(p){return p.opacity&&this.setOpacity(p.opacity),this},bringToFront:function(){return this._map&&Of(this._image),this},bringToBack:function(){return this._map&&Ef(this._image),this},setUrl:function(p){return this._url=p,this._image&&(this._image.src=p),this},setBounds:function(p){return this._bounds=ae(p),this._map&&this._reset(),this},getEvents:function(){var p={zoom:this._reset,viewreset:this._reset};return this._zoomAnimated&&(p.zoomanim=this._animateZoom),p},setZIndex:function(p){return this.options.zIndex=p,this._updateZIndex(),this},getBounds:function(){return this._bounds},getElement:function(){return this._image},_initImage:function(){var p=this._url.tagName==="IMG",w=this._image=p?this._url:Tt("img");if(ut(w,"leaflet-image-layer"),this._zoomAnimated&&ut(w,"leaflet-zoom-animated"),this.options.className&&ut(w,this.options.className),w.onselectstart=f,w.onmousemove=f,w.onload=o(this.fire,this,"load"),w.onerror=o(this._overlayOnError,this,"error"),(this.options.crossOrigin||this.options.crossOrigin==="")&&(w.crossOrigin=this.options.crossOrigin===!0?"":this.options.crossOrigin),this.options.zIndex&&this._updateZIndex(),p){this._url=w.src;return}w.src=this._url,w.alt=this.options.alt},_animateZoom:function(p){var w=this._map.getZoomScale(p.zoom),C=this._map._latLngBoundsToNewLayerBounds(this._bounds,p.zoom,p.center).min;wu(this._image,C,w)},_reset:function(){var p=this._image,w=new Y(this._map.latLngToLayerPoint(this._bounds.getNorthWest()),this._map.latLngToLayerPoint(this._bounds.getSouthEast())),C=w.getSize();Cr(p,w.min),p.style.width=C.x+"px",p.style.height=C.y+"px"},_updateOpacity:function(){Ri(this._image,this.options.opacity)},_updateZIndex:function(){this._image&&this.options.zIndex!==void 0&&this.options.zIndex!==null&&(this._image.style.zIndex=this.options.zIndex)},_overlayOnError:function(){this.fire("error");var p=this.options.errorOverlayUrl;p&&this._url!==p&&(this._url=p,this._image.src=p)},getCenter:function(){return this._bounds.getCenter()}}),Gae=function(p,w,C){return new B0(p,w,C)},S5=B0.extend({options:{autoplay:!0,loop:!0,keepAspectRatio:!0,muted:!1,playsInline:!0},_initImage:function(){var p=this._url.tagName==="VIDEO",w=this._image=p?this._url:Tt("video");if(ut(w,"leaflet-image-layer"),this._zoomAnimated&&ut(w,"leaflet-zoom-animated"),this.options.className&&ut(w,this.options.className),w.onselectstart=f,w.onmousemove=f,w.onloadeddata=o(this.fire,this,"load"),p){for(var C=w.getElementsByTagName("source"),E=[],j=0;j0?E:[w.src];return}b(this._url)||(this._url=[this._url]),!this.options.keepAspectRatio&&Object.prototype.hasOwnProperty.call(w.style,"objectFit")&&(w.style.objectFit="fill"),w.autoplay=!!this.options.autoplay,w.loop=!!this.options.loop,w.muted=!!this.options.muted,w.playsInline=!!this.options.playsInline;for(var V=0;Vj?(w.height=j+"px",ut(p,V)):_r(p,V),this._containerWidth=this._container.offsetWidth},_animateZoom:function(p){var w=this._map._latLngToNewLayerPoint(this._latlng,p.zoom,p.center),C=this._getAnchor();Cr(this._container,w.add(C))},_adjustPan:function(){if(this.options.autoPan){if(this._map._panAnim&&this._map._panAnim.stop(),this._autopanning){this._autopanning=!1;return}var p=this._map,w=parseInt(Qv(this._container,"marginBottom"),10)||0,C=this._container.offsetHeight+w,E=this._containerWidth,j=new z(this._containerLeft,-C-this._containerBottom);j._add(Su(this._container));var V=p.layerPointToContainerPoint(j),X=H(this.options.autoPanPadding),te=H(this.options.autoPanPaddingTopLeft||X),oe=H(this.options.autoPanPaddingBottomRight||X),he=p.getSize(),Ee=0,et=0;V.x+E+oe.x>he.x&&(Ee=V.x+E-he.x+oe.x),V.x-Ee-te.x<0&&(Ee=V.x-te.x),V.y+C+oe.y>he.y&&(et=V.y+C-he.y+oe.y),V.y-et-te.y<0&&(et=V.y-te.y),(Ee||et)&&(this.options.keepInView&&(this._autopanning=!0),p.fire("autopanstart").panBy([Ee,et]))}},_getAnchor:function(){return H(this._source&&this._source._getPopupAnchor?this._source._getPopupAnchor():[0,0])}}),Uae=function(p,w){return new z0(p,w)};bt.mergeOptions({closePopupOnClick:!0}),bt.include({openPopup:function(p,w,C){return this._initOverlay(z0,p,w,C).openOn(this),this},closePopup:function(p){return p=arguments.length?p:this._popup,p&&p.close(),this}}),wa.include({bindPopup:function(p,w){return this._popup=this._initOverlay(z0,this._popup,p,w),this._popupHandlersAdded||(this.on({click:this._openPopup,keypress:this._onKeyPress,remove:this.closePopup,move:this._movePopup}),this._popupHandlersAdded=!0),this},unbindPopup:function(){return this._popup&&(this.off({click:this._openPopup,keypress:this._onKeyPress,remove:this.closePopup,move:this._movePopup}),this._popupHandlersAdded=!1,this._popup=null),this},openPopup:function(p){return this._popup&&(this instanceof Xo||(this._popup._source=this),this._popup._prepareOpen(p||this._latlng)&&this._popup.openOn(this._map)),this},closePopup:function(){return this._popup&&this._popup.close(),this},togglePopup:function(){return this._popup&&this._popup.toggle(this),this},isPopupOpen:function(){return this._popup?this._popup.isOpen():!1},setPopupContent:function(p){return this._popup&&this._popup.setContent(p),this},getPopup:function(){return this._popup},_openPopup:function(p){if(!(!this._popup||!this._map)){Au(p);var w=p.layer||p.target;if(this._popup._source===w&&!(w instanceof el)){this._map.hasLayer(this._popup)?this.closePopup():this.openPopup(p.latlng);return}this._popup._source=w,this.openPopup(p.latlng)}},_movePopup:function(p){this._popup.setLatLng(p.latlng)},_onKeyPress:function(p){p.originalEvent.keyCode===13&&this._openPopup(p)}});var $0=to.extend({options:{pane:"tooltipPane",offset:[0,0],direction:"auto",permanent:!1,sticky:!1,opacity:.9},onAdd:function(p){to.prototype.onAdd.call(this,p),this.setOpacity(this.options.opacity),p.fire("tooltipopen",{tooltip:this}),this._source&&(this.addEventParent(this._source),this._source.fire("tooltipopen",{tooltip:this},!0))},onRemove:function(p){to.prototype.onRemove.call(this,p),p.fire("tooltipclose",{tooltip:this}),this._source&&(this.removeEventParent(this._source),this._source.fire("tooltipclose",{tooltip:this},!0))},getEvents:function(){var p=to.prototype.getEvents.call(this);return this.options.permanent||(p.preclick=this.close),p},_initLayout:function(){var p="leaflet-tooltip",w=p+" "+(this.options.className||"")+" leaflet-zoom-"+(this._zoomAnimated?"animated":"hide");this._contentNode=this._container=Tt("div",w),this._container.setAttribute("role","tooltip"),this._container.setAttribute("id","leaflet-tooltip-"+l(this))},_updateLayout:function(){},_adjustPan:function(){},_setPosition:function(p){var w,C,E=this._map,j=this._container,V=E.latLngToContainerPoint(E.getCenter()),X=E.layerPointToContainerPoint(p),te=this.options.direction,oe=j.offsetWidth,he=j.offsetHeight,Ee=H(this.options.offset),et=this._getAnchor();te==="top"?(w=oe/2,C=he):te==="bottom"?(w=oe/2,C=0):te==="center"?(w=oe/2,C=he/2):te==="right"?(w=0,C=he/2):te==="left"?(w=oe,C=he/2):X.xthis.options.maxZoom||CE?this._retainParent(j,V,X,E):!1)},_retainChildren:function(p,w,C,E){for(var j=2*p;j<2*p+2;j++)for(var V=2*w;V<2*w+2;V++){var X=new z(j,V);X.z=C+1;var te=this._tileCoordsToKey(X),oe=this._tiles[te];if(oe&&oe.active){oe.retain=!0;continue}else oe&&oe.loaded&&(oe.retain=!0);C+1this.options.maxZoom||this.options.minZoom!==void 0&&j1){this._setView(p,C);return}for(var et=j.min.y;et<=j.max.y;et++)for(var pt=j.min.x;pt<=j.max.x;pt++){var Rn=new z(pt,et);if(Rn.z=this._tileZoom,!!this._isValidTile(Rn)){var Kr=this._tiles[this._tileCoordsToKey(Rn)];Kr?Kr.current=!0:X.push(Rn)}}if(X.sort(function(ei,zf){return ei.distanceTo(V)-zf.distanceTo(V)}),X.length!==0){this._loading||(this._loading=!0,this.fire("loading"));var zi=document.createDocumentFragment();for(pt=0;ptC.max.x)||!w.wrapLat&&(p.yC.max.y))return!1}if(!this.options.bounds)return!0;var E=this._tileCoordsToBounds(p);return ae(this.options.bounds).overlaps(E)},_keyToBounds:function(p){return this._tileCoordsToBounds(this._keyToTileCoords(p))},_tileCoordsToNwSe:function(p){var w=this._map,C=this.getTileSize(),E=p.scaleBy(C),j=E.add(C),V=w.unproject(E,p.z),X=w.unproject(j,p.z);return[V,X]},_tileCoordsToBounds:function(p){var w=this._tileCoordsToNwSe(p),C=new J(w[0],w[1]);return this.options.noWrap||(C=this._map.wrapLatLngBounds(C)),C},_tileCoordsToKey:function(p){return p.x+":"+p.y+":"+p.z},_keyToTileCoords:function(p){var w=p.split(":"),C=new z(+w[0],+w[1]);return C.z=+w[2],C},_removeTile:function(p){var w=this._tiles[p];w&&(ir(w.el),delete this._tiles[p],this.fire("tileunload",{tile:w.el,coords:this._keyToTileCoords(p)}))},_initTile:function(p){ut(p,"leaflet-tile");var w=this.getTileSize();p.style.width=w.x+"px",p.style.height=w.y+"px",p.onselectstart=f,p.onmousemove=f,Ue.ielt9&&this.options.opacity<1&&Ri(p,this.options.opacity)},_addTile:function(p,w){var C=this._getTilePos(p),E=this._tileCoordsToKey(p),j=this.createTile(this._wrapCoords(p),o(this._tileReady,this,p));this._initTile(j),this.createTile.length<2&&O(o(this._tileReady,this,p,null,j)),Cr(j,C),this._tiles[E]={el:j,coords:p,current:!0},w.appendChild(j),this.fire("tileloadstart",{tile:j,coords:p})},_tileReady:function(p,w,C){w&&this.fire("tileerror",{error:w,tile:C,coords:p});var E=this._tileCoordsToKey(p);C=this._tiles[E],C&&(C.loaded=+new Date,this._map._fadeAnimated?(Ri(C.el,0),D(this._fadeFrame),this._fadeFrame=O(this._updateOpacity,this)):(C.active=!0,this._pruneTiles()),w||(ut(C.el,"leaflet-tile-loaded"),this.fire("tileload",{tile:C.el,coords:p})),this._noTilesToLoad()&&(this._loading=!1,this.fire("load"),Ue.ielt9||!this._map._fadeAnimated?O(this._pruneTiles,this):setTimeout(o(this._pruneTiles,this),250)))},_getTilePos:function(p){return p.scaleBy(this.getTileSize()).subtract(this._level.origin)},_wrapCoords:function(p){var w=new z(this._wrapX?c(p.x,this._wrapX):p.x,this._wrapY?c(p.y,this._wrapY):p.y);return w.z=p.z,w},_pxBoundsToTileRange:function(p){var w=this.getTileSize();return new Y(p.min.unscaleBy(w).floor(),p.max.unscaleBy(w).ceil().subtract([1,1]))},_noTilesToLoad:function(){for(var p in this._tiles)if(!this._tiles[p].loaded)return!1;return!0}});function Xae(p){return new op(p)}var Bf=op.extend({options:{minZoom:0,maxZoom:18,subdomains:"abc",errorTileUrl:"",zoomOffset:0,tms:!1,zoomReverse:!1,detectRetina:!1,crossOrigin:!1,referrerPolicy:!1},initialize:function(p,w){this._url=p,w=g(this,w),w.detectRetina&&Ue.retina&&w.maxZoom>0?(w.tileSize=Math.floor(w.tileSize/2),w.zoomReverse?(w.zoomOffset--,w.minZoom=Math.min(w.maxZoom,w.minZoom+1)):(w.zoomOffset++,w.maxZoom=Math.max(w.minZoom,w.maxZoom-1)),w.minZoom=Math.max(0,w.minZoom)):w.zoomReverse?w.minZoom=Math.min(w.maxZoom,w.minZoom):w.maxZoom=Math.max(w.minZoom,w.maxZoom),typeof w.subdomains=="string"&&(w.subdomains=w.subdomains.split("")),this.on("tileunload",this._onTileRemove)},setUrl:function(p,w){return this._url===p&&w===void 0&&(w=!0),this._url=p,w||this.redraw(),this},createTile:function(p,w){var C=document.createElement("img");return st(C,"load",o(this._tileOnLoad,this,w,C)),st(C,"error",o(this._tileOnError,this,w,C)),(this.options.crossOrigin||this.options.crossOrigin==="")&&(C.crossOrigin=this.options.crossOrigin===!0?"":this.options.crossOrigin),typeof this.options.referrerPolicy=="string"&&(C.referrerPolicy=this.options.referrerPolicy),C.alt="",C.src=this.getTileUrl(p),C},getTileUrl:function(p){var w={r:Ue.retina?"@2x":"",s:this._getSubdomain(p),x:p.x,y:p.y,z:this._getZoomForUrl()};if(this._map&&!this._map.options.crs.infinite){var C=this._globalTileRange.max.y-p.y;this.options.tms&&(w.y=C),w["-y"]=C}return _(this._url,i(w,this.options))},_tileOnLoad:function(p,w){Ue.ielt9?setTimeout(o(p,this,null,w),0):p(null,w)},_tileOnError:function(p,w,C){var E=this.options.errorTileUrl;E&&w.getAttribute("src")!==E&&(w.src=E),p(C,w)},_onTileRemove:function(p){p.tile.onload=null},_getZoomForUrl:function(){var p=this._tileZoom,w=this.options.maxZoom,C=this.options.zoomReverse,E=this.options.zoomOffset;return C&&(p=w-p),p+E},_getSubdomain:function(p){var w=Math.abs(p.x+p.y)%this.options.subdomains.length;return this.options.subdomains[w]},_abortLoading:function(){var p,w;for(p in this._tiles)if(this._tiles[p].coords.z!==this._tileZoom&&(w=this._tiles[p].el,w.onload=f,w.onerror=f,!w.complete)){w.src=T;var C=this._tiles[p].coords;ir(w),delete this._tiles[p],this.fire("tileabort",{tile:w,coords:C})}},_removeTile:function(p){var w=this._tiles[p];if(w)return w.el.setAttribute("src",T),op.prototype._removeTile.call(this,p)},_tileReady:function(p,w,C){if(!(!this._map||C&&C.getAttribute("src")===T))return op.prototype._tileReady.call(this,p,w,C)}});function C5(p,w){return new Bf(p,w)}var M5=Bf.extend({defaultWmsParams:{service:"WMS",request:"GetMap",layers:"",styles:"",format:"image/jpeg",transparent:!1,version:"1.1.1"},options:{crs:null,uppercase:!1},initialize:function(p,w){this._url=p;var C=i({},this.defaultWmsParams);for(var E in w)E in this.options||(C[E]=w[E]);w=g(this,w);var j=w.detectRetina&&Ue.retina?2:1,V=this.getTileSize();C.width=V.x*j,C.height=V.y*j,this.wmsParams=C},onAdd:function(p){this._crs=this.options.crs||p.options.crs,this._wmsVersion=parseFloat(this.wmsParams.version);var w=this._wmsVersion>=1.3?"crs":"srs";this.wmsParams[w]=this._crs.code,Bf.prototype.onAdd.call(this,p)},getTileUrl:function(p){var w=this._tileCoordsToNwSe(p),C=this._crs,E=Z(C.project(w[0]),C.project(w[1])),j=E.min,V=E.max,X=(this._wmsVersion>=1.3&&this._crs===x5?[j.y,j.x,V.y,V.x]:[j.x,j.y,V.x,V.y]).join(","),te=Bf.prototype.getTileUrl.call(this,p);return te+m(this.wmsParams,te,this.options.uppercase)+(this.options.uppercase?"&BBOX=":"&bbox=")+X},setParams:function(p,w){return i(this.wmsParams,p),w||this.redraw(),this}});function qae(p,w){return new M5(p,w)}Bf.WMS=M5,C5.wms=qae;var Qo=wa.extend({options:{padding:.1},initialize:function(p){g(this,p),l(this),this._layers=this._layers||{}},onAdd:function(){this._container||(this._initContainer(),ut(this._container,"leaflet-zoom-animated")),this.getPane().appendChild(this._container),this._update(),this.on("update",this._updatePaths,this)},onRemove:function(){this.off("update",this._updatePaths,this),this._destroyContainer()},getEvents:function(){var p={viewreset:this._reset,zoom:this._onZoom,moveend:this._update,zoomend:this._onZoomEnd};return this._zoomAnimated&&(p.zoomanim=this._onAnimZoom),p},_onAnimZoom:function(p){this._updateTransform(p.center,p.zoom)},_onZoom:function(){this._updateTransform(this._map.getCenter(),this._map.getZoom())},_updateTransform:function(p,w){var C=this._map.getZoomScale(w,this._zoom),E=this._map.getSize().multiplyBy(.5+this.options.padding),j=this._map.project(this._center,w),V=E.multiplyBy(-C).add(j).subtract(this._map._getNewPixelOrigin(p,w));Ue.any3d?wu(this._container,V,C):Cr(this._container,V)},_reset:function(){this._update(),this._updateTransform(this._center,this._zoom);for(var p in this._layers)this._layers[p]._reset()},_onZoomEnd:function(){for(var p in this._layers)this._layers[p]._project()},_updatePaths:function(){for(var p in this._layers)this._layers[p]._update()},_update:function(){var p=this.options.padding,w=this._map.getSize(),C=this._map.containerPointToLayerPoint(w.multiplyBy(-p)).round();this._bounds=new Y(C,C.add(w.multiplyBy(1+p*2)).round()),this._center=this._map.getCenter(),this._zoom=this._map.getZoom()}}),P5=Qo.extend({options:{tolerance:0},getEvents:function(){var p=Qo.prototype.getEvents.call(this);return p.viewprereset=this._onViewPreReset,p},_onViewPreReset:function(){this._postponeUpdatePaths=!0},onAdd:function(){Qo.prototype.onAdd.call(this),this._draw()},_initContainer:function(){var p=this._container=document.createElement("canvas");st(p,"mousemove",this._onMouseMove,this),st(p,"click dblclick mousedown mouseup contextmenu",this._onClick,this),st(p,"mouseout",this._handleMouseOut,this),p._leaflet_disable_events=!0,this._ctx=p.getContext("2d")},_destroyContainer:function(){D(this._redrawRequest),delete this._ctx,ir(this._container),Ht(this._container),delete this._container},_updatePaths:function(){if(!this._postponeUpdatePaths){var p;this._redrawBounds=null;for(var w in this._layers)p=this._layers[w],p._update();this._redraw()}},_update:function(){if(!(this._map._animatingZoom&&this._bounds)){Qo.prototype._update.call(this);var p=this._bounds,w=this._container,C=p.getSize(),E=Ue.retina?2:1;Cr(w,p.min),w.width=E*C.x,w.height=E*C.y,w.style.width=C.x+"px",w.style.height=C.y+"px",Ue.retina&&this._ctx.scale(2,2),this._ctx.translate(-p.min.x,-p.min.y),this.fire("update")}},_reset:function(){Qo.prototype._reset.call(this),this._postponeUpdatePaths&&(this._postponeUpdatePaths=!1,this._updatePaths())},_initPath:function(p){this._updateDashArray(p),this._layers[l(p)]=p;var w=p._order={layer:p,prev:this._drawLast,next:null};this._drawLast&&(this._drawLast.next=w),this._drawLast=w,this._drawFirst=this._drawFirst||this._drawLast},_addPath:function(p){this._requestRedraw(p)},_removePath:function(p){var w=p._order,C=w.next,E=w.prev;C?C.prev=E:this._drawLast=E,E?E.next=C:this._drawFirst=C,delete p._order,delete this._layers[l(p)],this._requestRedraw(p)},_updatePath:function(p){this._extendRedrawBounds(p),p._project(),p._update(),this._requestRedraw(p)},_updateStyle:function(p){this._updateDashArray(p),this._requestRedraw(p)},_updateDashArray:function(p){if(typeof p.options.dashArray=="string"){var w=p.options.dashArray.split(/[, ]+/),C=[],E,j;for(j=0;j')}}catch{}return function(p){return document.createElement("<"+p+' xmlns="urn:schemas-microsoft.com:vml" class="lvml">')}}(),Kae={_initContainer:function(){this._container=Tt("div","leaflet-vml-container")},_update:function(){this._map._animatingZoom||(Qo.prototype._update.call(this),this.fire("update"))},_initPath:function(p){var w=p._container=sp("shape");ut(w,"leaflet-vml-shape "+(this.options.className||"")),w.coordsize="1 1",p._path=sp("path"),w.appendChild(p._path),this._updateStyle(p),this._layers[l(p)]=p},_addPath:function(p){var w=p._container;this._container.appendChild(w),p.options.interactive&&p.addInteractiveTarget(w)},_removePath:function(p){var w=p._container;ir(w),p.removeInteractiveTarget(w),delete this._layers[l(p)]},_updateStyle:function(p){var w=p._stroke,C=p._fill,E=p.options,j=p._container;j.stroked=!!E.stroke,j.filled=!!E.fill,E.stroke?(w||(w=p._stroke=sp("stroke")),j.appendChild(w),w.weight=E.weight+"px",w.color=E.color,w.opacity=E.opacity,E.dashArray?w.dashStyle=b(E.dashArray)?E.dashArray.join(" "):E.dashArray.replace(/( *, *)/g," "):w.dashStyle="",w.endcap=E.lineCap.replace("butt","flat"),w.joinstyle=E.lineJoin):w&&(j.removeChild(w),p._stroke=null),E.fill?(C||(C=p._fill=sp("fill")),j.appendChild(C),C.color=E.fillColor||E.color,C.opacity=E.fillOpacity):C&&(j.removeChild(C),p._fill=null)},_updateCircle:function(p){var w=p._point.round(),C=Math.round(p._radius),E=Math.round(p._radiusY||C);this._setPath(p,p._empty()?"M0 0":"AL "+w.x+","+w.y+" "+C+","+E+" 0,"+65535*360)},_setPath:function(p,w){p._path.v=w},_bringToFront:function(p){Of(p._container)},_bringToBack:function(p){Ef(p._container)}},F0=Ue.vml?sp:Fe,lp=Qo.extend({_initContainer:function(){this._container=F0("svg"),this._container.setAttribute("pointer-events","none"),this._rootGroup=F0("g"),this._container.appendChild(this._rootGroup)},_destroyContainer:function(){ir(this._container),Ht(this._container),delete this._container,delete this._rootGroup,delete this._svgSize},_update:function(){if(!(this._map._animatingZoom&&this._bounds)){Qo.prototype._update.call(this);var p=this._bounds,w=p.getSize(),C=this._container;(!this._svgSize||!this._svgSize.equals(w))&&(this._svgSize=w,C.setAttribute("width",w.x),C.setAttribute("height",w.y)),Cr(C,p.min),C.setAttribute("viewBox",[p.min.x,p.min.y,w.x,w.y].join(" ")),this.fire("update")}},_initPath:function(p){var w=p._path=F0("path");p.options.className&&ut(w,p.options.className),p.options.interactive&&ut(w,"leaflet-interactive"),this._updateStyle(p),this._layers[l(p)]=p},_addPath:function(p){this._rootGroup||this._initContainer(),this._rootGroup.appendChild(p._path),p.addInteractiveTarget(p._path)},_removePath:function(p){ir(p._path),p.removeInteractiveTarget(p._path),delete this._layers[l(p)]},_updatePath:function(p){p._project(),p._update()},_updateStyle:function(p){var w=p._path,C=p.options;w&&(C.stroke?(w.setAttribute("stroke",C.color),w.setAttribute("stroke-opacity",C.opacity),w.setAttribute("stroke-width",C.weight),w.setAttribute("stroke-linecap",C.lineCap),w.setAttribute("stroke-linejoin",C.lineJoin),C.dashArray?w.setAttribute("stroke-dasharray",C.dashArray):w.removeAttribute("stroke-dasharray"),C.dashOffset?w.setAttribute("stroke-dashoffset",C.dashOffset):w.removeAttribute("stroke-dashoffset")):w.setAttribute("stroke","none"),C.fill?(w.setAttribute("fill",C.fillColor||C.color),w.setAttribute("fill-opacity",C.fillOpacity),w.setAttribute("fill-rule",C.fillRule||"evenodd")):w.setAttribute("fill","none"))},_updatePoly:function(p,w){this._setPath(p,Ye(p._parts,w))},_updateCircle:function(p){var w=p._point,C=Math.max(Math.round(p._radius),1),E=Math.max(Math.round(p._radiusY),1)||C,j="a"+C+","+E+" 0 1,0 ",V=p._empty()?"M0 0":"M"+(w.x-C)+","+w.y+j+C*2+",0 "+j+-C*2+",0 ";this._setPath(p,V)},_setPath:function(p,w){p._path.setAttribute("d",w)},_bringToFront:function(p){Of(p._path)},_bringToBack:function(p){Ef(p._path)}});Ue.vml&&lp.include(Kae);function k5(p){return Ue.svg||Ue.vml?new lp(p):null}bt.include({getRenderer:function(p){var w=p.options.renderer||this._getPaneRenderer(p.options.pane)||this.options.renderer||this._renderer;return w||(w=this._renderer=this._createRenderer()),this.hasLayer(w)||this.addLayer(w),w},_getPaneRenderer:function(p){if(p==="overlayPane"||p===void 0)return!1;var w=this._paneRenderers[p];return w===void 0&&(w=this._createRenderer({pane:p}),this._paneRenderers[p]=w),w},_createRenderer:function(p){return this.options.preferCanvas&&L5(p)||k5(p)}});var I5=jf.extend({initialize:function(p,w){jf.prototype.initialize.call(this,this._boundsToLatLngs(p),w)},setBounds:function(p){return this.setLatLngs(this._boundsToLatLngs(p))},_boundsToLatLngs:function(p){return p=ae(p),[p.getSouthWest(),p.getNorthWest(),p.getNorthEast(),p.getSouthEast()]}});function Qae(p,w){return new I5(p,w)}lp.create=F0,lp.pointsToPath=Ye,Ko.geometryToLayer=D0,Ko.coordsToLatLng=TA,Ko.coordsToLatLngs=N0,Ko.latLngToCoords=AA,Ko.latLngsToCoords=j0,Ko.getFeature=Rf,Ko.asFeature=R0,bt.mergeOptions({boxZoom:!0});var O5=eo.extend({initialize:function(p){this._map=p,this._container=p._container,this._pane=p._panes.overlayPane,this._resetStateTimeout=0,p.on("unload",this._destroy,this)},addHooks:function(){st(this._container,"mousedown",this._onMouseDown,this)},removeHooks:function(){Ht(this._container,"mousedown",this._onMouseDown,this)},moved:function(){return this._moved},_destroy:function(){ir(this._pane),delete this._pane},_resetState:function(){this._resetStateTimeout=0,this._moved=!1},_clearDeferredResetState:function(){this._resetStateTimeout!==0&&(clearTimeout(this._resetStateTimeout),this._resetStateTimeout=0)},_onMouseDown:function(p){if(!p.shiftKey||p.which!==1&&p.button!==1)return!1;this._clearDeferredResetState(),this._resetState(),Jv(),sA(),this._startPoint=this._map.mouseEventToContainerPoint(p),st(document,{contextmenu:Au,mousemove:this._onMouseMove,mouseup:this._onMouseUp,keydown:this._onKeyDown},this)},_onMouseMove:function(p){this._moved||(this._moved=!0,this._box=Tt("div","leaflet-zoom-box",this._container),ut(this._container,"leaflet-crosshair"),this._map.fire("boxzoomstart")),this._point=this._map.mouseEventToContainerPoint(p);var w=new Y(this._point,this._startPoint),C=w.getSize();Cr(this._box,w.min),this._box.style.width=C.x+"px",this._box.style.height=C.y+"px"},_finish:function(){this._moved&&(ir(this._box),_r(this._container,"leaflet-crosshair")),ep(),lA(),Ht(document,{contextmenu:Au,mousemove:this._onMouseMove,mouseup:this._onMouseUp,keydown:this._onKeyDown},this)},_onMouseUp:function(p){if(!(p.which!==1&&p.button!==1)&&(this._finish(),!!this._moved)){this._clearDeferredResetState(),this._resetStateTimeout=setTimeout(o(this._resetState,this),0);var w=new J(this._map.containerPointToLatLng(this._startPoint),this._map.containerPointToLatLng(this._point));this._map.fitBounds(w).fire("boxzoomend",{boxZoomBounds:w})}},_onKeyDown:function(p){p.keyCode===27&&(this._finish(),this._clearDeferredResetState(),this._resetState())}});bt.addInitHook("addHandler","boxZoom",O5),bt.mergeOptions({doubleClickZoom:!0});var E5=eo.extend({addHooks:function(){this._map.on("dblclick",this._onDoubleClick,this)},removeHooks:function(){this._map.off("dblclick",this._onDoubleClick,this)},_onDoubleClick:function(p){var w=this._map,C=w.getZoom(),E=w.options.zoomDelta,j=p.originalEvent.shiftKey?C-E:C+E;w.options.doubleClickZoom==="center"?w.setZoom(j):w.setZoomAround(p.containerPoint,j)}});bt.addInitHook("addHandler","doubleClickZoom",E5),bt.mergeOptions({dragging:!0,inertia:!0,inertiaDeceleration:3400,inertiaMaxSpeed:1/0,easeLinearity:.2,worldCopyJump:!1,maxBoundsViscosity:0});var D5=eo.extend({addHooks:function(){if(!this._draggable){var p=this._map;this._draggable=new Js(p._mapPane,p._container),this._draggable.on({dragstart:this._onDragStart,drag:this._onDrag,dragend:this._onDragEnd},this),this._draggable.on("predrag",this._onPreDragLimit,this),p.options.worldCopyJump&&(this._draggable.on("predrag",this._onPreDragWrap,this),p.on("zoomend",this._onZoomEnd,this),p.whenReady(this._onZoomEnd,this))}ut(this._map._container,"leaflet-grab leaflet-touch-drag"),this._draggable.enable(),this._positions=[],this._times=[]},removeHooks:function(){_r(this._map._container,"leaflet-grab"),_r(this._map._container,"leaflet-touch-drag"),this._draggable.disable()},moved:function(){return this._draggable&&this._draggable._moved},moving:function(){return this._draggable&&this._draggable._moving},_onDragStart:function(){var p=this._map;if(p._stop(),this._map.options.maxBounds&&this._map.options.maxBoundsViscosity){var w=ae(this._map.options.maxBounds);this._offsetLimit=Z(this._map.latLngToContainerPoint(w.getNorthWest()).multiplyBy(-1),this._map.latLngToContainerPoint(w.getSouthEast()).multiplyBy(-1).add(this._map.getSize())),this._viscosity=Math.min(1,Math.max(0,this._map.options.maxBoundsViscosity))}else this._offsetLimit=null;p.fire("movestart").fire("dragstart"),p.options.inertia&&(this._positions=[],this._times=[])},_onDrag:function(p){if(this._map.options.inertia){var w=this._lastTime=+new Date,C=this._lastPos=this._draggable._absPos||this._draggable._newPos;this._positions.push(C),this._times.push(w),this._prunePositions(w)}this._map.fire("move",p).fire("drag",p)},_prunePositions:function(p){for(;this._positions.length>1&&p-this._times[0]>50;)this._positions.shift(),this._times.shift()},_onZoomEnd:function(){var p=this._map.getSize().divideBy(2),w=this._map.latLngToLayerPoint([0,0]);this._initialWorldOffset=w.subtract(p).x,this._worldWidth=this._map.getPixelWorldBounds().getSize().x},_viscousLimit:function(p,w){return p-(p-w)*this._viscosity},_onPreDragLimit:function(){if(!(!this._viscosity||!this._offsetLimit)){var p=this._draggable._newPos.subtract(this._draggable._startPos),w=this._offsetLimit;p.xw.max.x&&(p.x=this._viscousLimit(p.x,w.max.x)),p.y>w.max.y&&(p.y=this._viscousLimit(p.y,w.max.y)),this._draggable._newPos=this._draggable._startPos.add(p)}},_onPreDragWrap:function(){var p=this._worldWidth,w=Math.round(p/2),C=this._initialWorldOffset,E=this._draggable._newPos.x,j=(E-w+C)%p+w-C,V=(E+w+C)%p-w-C,X=Math.abs(j+C)0?V:-V))-w;this._delta=0,this._startTime=null,X&&(p.options.scrollWheelZoom==="center"?p.setZoom(w+X):p.setZoomAround(this._lastMousePos,w+X))}});bt.addInitHook("addHandler","scrollWheelZoom",j5);var Jae=600;bt.mergeOptions({tapHold:Ue.touchNative&&Ue.safari&&Ue.mobile,tapTolerance:15});var R5=eo.extend({addHooks:function(){st(this._map._container,"touchstart",this._onDown,this)},removeHooks:function(){Ht(this._map._container,"touchstart",this._onDown,this)},_onDown:function(p){if(clearTimeout(this._holdTimeout),p.touches.length===1){var w=p.touches[0];this._startPos=this._newPos=new z(w.clientX,w.clientY),this._holdTimeout=setTimeout(o(function(){this._cancel(),this._isTapValid()&&(st(document,"touchend",un),st(document,"touchend touchcancel",this._cancelClickPrevent),this._simulateEvent("contextmenu",w))},this),Jae),st(document,"touchend touchcancel contextmenu",this._cancel,this),st(document,"touchmove",this._onMove,this)}},_cancelClickPrevent:function p(){Ht(document,"touchend",un),Ht(document,"touchend touchcancel",p)},_cancel:function(){clearTimeout(this._holdTimeout),Ht(document,"touchend touchcancel contextmenu",this._cancel,this),Ht(document,"touchmove",this._onMove,this)},_onMove:function(p){var w=p.touches[0];this._newPos=new z(w.clientX,w.clientY)},_isTapValid:function(){return this._newPos.distanceTo(this._startPos)<=this._map.options.tapTolerance},_simulateEvent:function(p,w){var C=new MouseEvent(p,{bubbles:!0,cancelable:!0,view:window,screenX:w.screenX,screenY:w.screenY,clientX:w.clientX,clientY:w.clientY});C._simulated=!0,w.target.dispatchEvent(C)}});bt.addInitHook("addHandler","tapHold",R5),bt.mergeOptions({touchZoom:Ue.touch,bounceAtZoomLimits:!0});var B5=eo.extend({addHooks:function(){ut(this._map._container,"leaflet-touch-zoom"),st(this._map._container,"touchstart",this._onTouchStart,this)},removeHooks:function(){_r(this._map._container,"leaflet-touch-zoom"),Ht(this._map._container,"touchstart",this._onTouchStart,this)},_onTouchStart:function(p){var w=this._map;if(!(!p.touches||p.touches.length!==2||w._animatingZoom||this._zooming)){var C=w.mouseEventToContainerPoint(p.touches[0]),E=w.mouseEventToContainerPoint(p.touches[1]);this._centerPoint=w.getSize()._divideBy(2),this._startLatLng=w.containerPointToLatLng(this._centerPoint),w.options.touchZoom!=="center"&&(this._pinchStartLatLng=w.containerPointToLatLng(C.add(E)._divideBy(2))),this._startDist=C.distanceTo(E),this._startZoom=w.getZoom(),this._moved=!1,this._zooming=!0,w._stop(),st(document,"touchmove",this._onTouchMove,this),st(document,"touchend touchcancel",this._onTouchEnd,this),un(p)}},_onTouchMove:function(p){if(!(!p.touches||p.touches.length!==2||!this._zooming)){var w=this._map,C=w.mouseEventToContainerPoint(p.touches[0]),E=w.mouseEventToContainerPoint(p.touches[1]),j=C.distanceTo(E)/this._startDist;if(this._zoom=w.getScaleZoom(j,this._startZoom),!w.options.bounceAtZoomLimits&&(this._zoomw.getMaxZoom()&&j>1)&&(this._zoom=w._limitZoom(this._zoom)),w.options.touchZoom==="center"){if(this._center=this._startLatLng,j===1)return}else{var V=C._add(E)._divideBy(2)._subtract(this._centerPoint);if(j===1&&V.x===0&&V.y===0)return;this._center=w.unproject(w.project(this._pinchStartLatLng,this._zoom).subtract(V),this._zoom)}this._moved||(w._moveStart(!0,!1),this._moved=!0),D(this._animRequest);var X=o(w._move,w,this._center,this._zoom,{pinch:!0,round:!1},void 0);this._animRequest=O(X,this,!0),un(p)}},_onTouchEnd:function(){if(!this._moved||!this._zooming){this._zooming=!1;return}this._zooming=!1,D(this._animRequest),Ht(document,"touchmove",this._onTouchMove,this),Ht(document,"touchend touchcancel",this._onTouchEnd,this),this._map.options.zoomAnimation?this._map._animateZoom(this._center,this._map._limitZoom(this._zoom),!0,this._map.options.zoomSnap):this._map._resetView(this._center,this._map._limitZoom(this._zoom))}});bt.addInitHook("addHandler","touchZoom",B5),bt.BoxZoom=O5,bt.DoubleClickZoom=E5,bt.Drag=D5,bt.Keyboard=N5,bt.ScrollWheelZoom=j5,bt.TapHold=R5,bt.TouchZoom=B5,r.Bounds=Y,r.Browser=Ue,r.CRS=We,r.Canvas=P5,r.Circle=SA,r.CircleMarker=E0,r.Class=B,r.Control=ba,r.DivIcon=A5,r.DivOverlay=to,r.DomEvent=mae,r.DomUtil=pae,r.Draggable=Js,r.Evented=G,r.FeatureGroup=Xo,r.GeoJSON=Ko,r.GridLayer=op,r.Handler=eo,r.Icon=Nf,r.ImageOverlay=B0,r.LatLng=ce,r.LatLngBounds=J,r.Layer=wa,r.LayerGroup=Df,r.LineUtil=kae,r.Map=bt,r.Marker=O0,r.Mixin=Tae,r.Path=el,r.Point=z,r.PolyUtil=Aae,r.Polygon=jf,r.Polyline=qo,r.Popup=z0,r.PosAnimation=s5,r.Projection=Iae,r.Rectangle=I5,r.Renderer=Qo,r.SVG=lp,r.SVGOverlay=T5,r.TileLayer=Bf,r.Tooltip=$0,r.Transformation=le,r.Util=N,r.VideoOverlay=S5,r.bind=o,r.bounds=Z,r.canvas=L5,r.circle=zae,r.circleMarker=Bae,r.control=np,r.divIcon=Yae,r.extend=i,r.featureGroup=Nae,r.geoJSON=w5,r.geoJson=Vae,r.gridLayer=Xae,r.icon=jae,r.imageOverlay=Gae,r.latLng=ge,r.latLngBounds=ae,r.layerGroup=Dae,r.map=yae,r.marker=Rae,r.point=H,r.polygon=Fae,r.polyline=$ae,r.popup=Uae,r.rectangle=Qae,r.setOptions=g,r.stamp=l,r.svg=k5,r.svgOverlay=Hae,r.tileLayer=C5,r.tooltip=Zae,r.transformation=ee,r.version=n,r.videoOverlay=Wae;var eoe=window.L;r.noConflict=function(){return window.L=eoe,this},window.L=r})})(zO,zO.exports);var Lf=zO.exports;const Bie=Ft(Lf);function w0(e,t,r){return Object.freeze({instance:e,context:t,container:r})}function NR(e,t){return t==null?function(n,i){const a=W.useRef();return a.current||(a.current=e(n,i)),a}:function(n,i){const a=W.useRef();a.current||(a.current=e(n,i));const o=W.useRef(n),{instance:s}=a.current;return W.useEffect(function(){o.current!==n&&(t(s,n,o.current),o.current=n)},[s,n,i]),a}}function zie(e,t){W.useEffect(function(){return(t.layerContainer??t.map).addLayer(e.instance),function(){var a;(a=t.layerContainer)==null||a.removeLayer(e.instance),t.map.removeLayer(e.instance)}},[t,e])}function zQe(e){return function(r){const n=KT(),i=e(QT(r,n),n);return Die(n.map,r.attribution),DR(i.current,r.eventHandlers),zie(i.current,n),i}}function $Qe(e,t){const r=W.useRef();W.useEffect(function(){if(t.pathOptions!==r.current){const i=t.pathOptions??{};e.instance.setStyle(i),r.current=i}},[e,t])}function FQe(e){return function(r){const n=KT(),i=e(QT(r,n),n);return DR(i.current,r.eventHandlers),zie(i.current,n),$Qe(i.current,r),i}}function $ie(e,t){const r=NR(e),n=BQe(r,t);return jQe(n)}function Fie(e,t){const r=NR(e,t),n=FQe(r);return NQe(n)}function VQe(e,t){const r=NR(e,t),n=zQe(r);return RQe(n)}function GQe(e,t,r){const{opacity:n,zIndex:i}=t;n!=null&&n!==r.opacity&&e.setOpacity(n),i!=null&&i!==r.zIndex&&e.setZIndex(i)}function WQe(){return KT().map}const HQe=Fie(function({center:t,children:r,...n},i){const a=new Lf.CircleMarker(t,n);return w0(a,Nie(i,{overlayContainer:a}))},OQe);function $O(){return $O=Object.assign||function(e){for(var t=1;t(d==null?void 0:d.map)??null,[d]);const g=W.useCallback(y=>{if(y!==null&&d===null){const _=new Lf.Map(y,c);r!=null&&u!=null?_.setView(r,u):e!=null&&_.fitBounds(e,t),l!=null&&_.whenReady(l),v(DQe(_))}},[]);W.useEffect(()=>()=>{d==null||d.map.remove()},[d]);const m=d?Q.createElement(Rie,{value:d},n):o??null;return Q.createElement("div",$O({},h,{ref:g}),m)}const ZQe=W.forwardRef(UQe),YQe=Fie(function({positions:t,...r},n){const i=new Lf.Polyline(t,r);return w0(i,Nie(n,{overlayContainer:i}))},function(t,r,n){r.positions!==n.positions&&t.setLatLngs(r.positions)}),XQe=$ie(function(t,r){const n=new Lf.Popup(t,r.overlayContainer);return w0(n,r)},function(t,r,{position:n},i){W.useEffect(function(){const{instance:o}=t;function s(u){u.popup===o&&(o.update(),i(!0))}function l(u){u.popup===o&&i(!1)}return r.map.on({popupopen:s,popupclose:l}),r.overlayContainer==null?(n!=null&&o.setLatLng(n),o.openOn(r.map)):r.overlayContainer.bindPopup(o),function(){var c;r.map.off({popupopen:s,popupclose:l}),(c=r.overlayContainer)==null||c.unbindPopup(),r.map.removeLayer(o)}},[t,r,i,n])}),qQe=VQe(function({url:t,...r},n){const i=new Lf.TileLayer(t,QT(r,n));return w0(i,n)},function(t,r,n){GQe(t,r,n);const{url:i}=r;i!=null&&i!==n.url&&t.setUrl(i)}),KQe=$ie(function(t,r){const n=new Lf.Tooltip(t,r.overlayContainer);return w0(n,r)},function(t,r,{position:n},i){W.useEffect(function(){const o=r.overlayContainer;if(o==null)return;const{instance:s}=t,l=c=>{c.tooltip===s&&(n!=null&&s.setLatLng(n),s.update(),i(!0))},u=c=>{c.tooltip===s&&i(!1)};return o.on({tooltipopen:l,tooltipclose:u}),o.bindTooltip(s),function(){o.off({tooltipopen:l,tooltipclose:u}),o._map!=null&&o.unbindTooltip()}},[t,r,i,n])}),QQe="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=",JQe="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==",eJe="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACkAAAApCAQAAAACach9AAACMUlEQVR4Ae3ShY7jQBAE0Aoz/f9/HTMzhg1zrdKUrJbdx+Kd2nD8VNudfsL/Th///dyQN2TH6f3y/BGpC379rV+S+qqetBOxImNQXL8JCAr2V4iMQXHGNJxeCfZXhSRBcQMfvkOWUdtfzlLgAENmZDcmo2TVmt8OSM2eXxBp3DjHSMFutqS7SbmemzBiR+xpKCNUIRkdkkYxhAkyGoBvyQFEJEefwSmmvBfJuJ6aKqKWnAkvGZOaZXTUgFqYULWNSHUckZuR1HIIimUExutRxwzOLROIG4vKmCKQt364mIlhSyzAf1m9lHZHJZrlAOMMztRRiKimp/rpdJDc9Awry5xTZCte7FHtuS8wJgeYGrex28xNTd086Dik7vUMscQOa8y4DoGtCCSkAKlNwpgNtphjrC6MIHUkR6YWxxs6Sc5xqn222mmCRFzIt8lEdKx+ikCtg91qS2WpwVfBelJCiQJwvzixfI9cxZQWgiSJelKnwBElKYtDOb2MFbhmUigbReQBV0Cg4+qMXSxXSyGUn4UbF8l+7qdSGnTC0XLCmahIgUHLhLOhpVCtw4CzYXvLQWQbJNmxoCsOKAxSgBJno75avolkRw8iIAFcsdc02e9iyCd8tHwmeSSoKTowIgvscSGZUOA7PuCN5b2BX9mQM7S0wYhMNU74zgsPBj3HU7wguAfnxxjFQGBE6pwN+GjME9zHY7zGp8wVxMShYX9NXvEWD3HbwJf4giO4CFIQxXScH1/TM+04kkBiAAAAAElFTkSuQmCC";delete Bie.Icon.Default.prototype._getIconUrl;Bie.Icon.Default.mergeOptions({iconUrl:QQe,iconRetinaUrl:JQe,shadowUrl:eJe});const EU=["#3b82f6","#a78bfa","#06b6d4","#f59e0b","#22c55e","#ec4899","#8b5cf6","#14b8a6"],tJe=["ROUTER","ROUTER_LATE","REPEATER","TRACKER"];function rJe(e){return e>12?"#22c55e":e>8?"#4ade80":e>5?"#f59e0b":e>3?"#f97316":"#ef4444"}function nJe(e){return e===null||e>46?0:e>44.5?1:e>43?2:3}function iJe(e){if(!e)return"Unknown";const t=new Date(e),n=new Date().getTime()-t.getTime(),i=Math.floor(n/6e4),a=Math.floor(n/36e5),o=Math.floor(n/864e5);return i<1?"Just now":i<60?`${i}m ago`:a<24?`${a}h ago`:`${o}d ago`}function aJe({bounds:e}){const t=WQe();return W.useEffect(()=>{e&&t.fitBounds(e,{padding:[50,50]})},[t,e]),null}function oJe({node:e}){const t=e.latitude!==null&&e.longitude!==null,r=e.battery_level!==null?e.battery_level>100||e.voltage&&e.voltage>4.1?"USB ⚡":`${e.battery_level.toFixed(0)}%`:"Unknown";return x.jsxs("div",{className:"min-w-[200px]",children:[x.jsx("div",{className:"font-semibold text-slate-800",children:e.short_name}),x.jsx("div",{className:"text-xs text-slate-600 mb-2",children:e.long_name}),x.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-1 text-xs",children:[x.jsx("div",{className:"text-slate-500",children:"Role"}),x.jsx("div",{className:"text-slate-700 font-medium",children:e.role}),x.jsx("div",{className:"text-slate-500",children:"Hardware"}),x.jsx("div",{className:"text-slate-700",children:e.hardware||"Unknown"}),x.jsx("div",{className:"text-slate-500",children:"Battery"}),x.jsx("div",{className:"text-slate-700",children:r}),x.jsx("div",{className:"text-slate-500",children:"Last Heard"}),x.jsx("div",{className:"text-slate-700",children:iJe(e.last_heard)})]}),t&&x.jsxs("div",{className:"mt-3 pt-2 border-t border-slate-200 flex gap-2",children:[x.jsxs("a",{href:`https://www.google.com/maps?q=${e.latitude},${e.longitude}`,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 text-xs text-blue-600 hover:text-blue-800",children:[x.jsx(xd,{size:10}),"Google Maps"]}),x.jsxs("a",{href:`https://www.openstreetmap.org/?mlat=${e.latitude}&mlon=${e.longitude}&zoom=14`,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 text-xs text-blue-600 hover:text-blue-800",children:[x.jsx(xd,{size:10}),"OSM"]})]})]})}function sJe({nodes:e,edges:t,selectedNodeId:r,onSelectNode:n}){const i=W.useMemo(()=>e.filter(f=>f.latitude!==null&&f.longitude!==null),[e]),a=e.length-i.length,o=W.useMemo(()=>new Map(i.map(f=>[f.node_num,f])),[i]),s=W.useMemo(()=>t.filter(f=>o.has(f.from_node)&&o.has(f.to_node)),[t,o]),l=W.useMemo(()=>{if(i.length===0)return null;const f=i.map(d=>d.latitude),h=i.map(d=>d.longitude);return[[Math.min(...f),Math.min(...h)],[Math.max(...f),Math.max(...h)]]},[i]),u=[43.6,-114.4],c=W.useMemo(()=>{const f=new Set;return r!==null&&t.forEach(h=>{h.from_node===r&&f.add(h.to_node),h.to_node===r&&f.add(h.from_node)}),f},[r,t]);return x.jsxs("div",{className:"relative bg-bg-card rounded-lg border border-border overflow-hidden",children:[x.jsxs(ZQe,{center:u,zoom:7,style:{width:"100%",height:"540px"},className:"z-0",children:[x.jsx(qQe,{url:"https://{s}.basemaps.cartocdn.com/dark_all/{z}/{x}/{y}{r}.png",attribution:'© OpenStreetMap, © CARTO'}),x.jsx(aJe,{bounds:l}),s.map((f,h)=>{const d=o.get(f.from_node),v=o.get(f.to_node),g=r===null||f.from_node===r||f.to_node===r;return x.jsx(YQe,{positions:[[d.latitude,d.longitude],[v.latitude,v.longitude]],color:rJe(f.snr),weight:g&&r!==null?2.5:1.5,opacity:r===null?.3:g?.6:.08},h)}),i.map(f=>{const h=f.node_num===r,d=c.has(f.node_num),v=r===null||h||d,g=tJe.includes(f.role),m=nJe(f.latitude),y=EU[m%EU.length];return x.jsxs(HQe,{center:[f.latitude,f.longitude],radius:g?8:5,fillColor:g?y:"#111827",fillOpacity:v?.9:.2,stroke:!0,color:h?"#ffffff":y,weight:h?3:g?0:2,opacity:v?1:.3,eventHandlers:{click:()=>n(h?null:f.node_num)},children:[x.jsx(KQe,{direction:"top",offset:[0,-8],children:x.jsx("span",{className:"font-mono text-xs",children:f.short_name})}),x.jsx(XQe,{children:x.jsx(oJe,{node:f})})]},f.node_num)})]}),x.jsxs("div",{className:"absolute bottom-4 left-4 bg-bg-card/90 backdrop-blur-sm border border-border rounded px-3 py-2 text-xs text-slate-400 flex items-center gap-2",children:[x.jsx(bZ,{size:12}),x.jsxs("span",{children:["Showing ",i.length," of ",e.length," nodes",a>0&&x.jsxs("span",{className:"text-slate-500",children:[" (",a," without coordinates)"]})]})]})]})}const DU=["#3b82f6","#a78bfa","#06b6d4","#f59e0b","#22c55e","#ec4899","#8b5cf6","#14b8a6"],lJe=["ROUTER","ROUTER_LATE","REPEATER","TRACKER"];function NU(e){return e>12?"#22c55e":e>8?"#4ade80":e>5?"#f59e0b":e>3?"#f97316":"#ef4444"}function uJe(e){return e>12?"excellent":e>8?"good":e>5?"fair":e>3?"marginal":"poor"}function cJe(e){return e===null||e>46?0:e>44.5?1:e>43?2:3}function fJe(e){return["Northern ID","Central ID","SW Idaho","SC Idaho"][e]||"Unknown"}function hJe(e){if(!e)return"Unknown";const t=new Date(e),n=new Date().getTime()-t.getTime(),i=Math.floor(n/6e4),a=Math.floor(n/36e5),o=Math.floor(n/864e5);return i<1?"Just now":i<60?`${i}m ago`:a<24?`${a}h ago`:`${o}d ago`}function dJe(e){if(!e)return"bg-slate-500";const t=new Date(e),n=(new Date().getTime()-t.getTime())/36e5;return n<1?"bg-green-500":n<24?"bg-amber-500":"bg-slate-500"}function vJe({node:e,edges:t,nodes:r,onSelectNode:n}){const i=W.useMemo(()=>{if(!e)return[];const f=new Map(r.map(d=>[d.node_num,d])),h=[];return t.forEach(d=>{if(d.from_node===e.node_num){const v=f.get(d.to_node);v&&h.push({node:v,snr:d.snr,quality:d.quality})}else if(d.to_node===e.node_num){const v=f.get(d.from_node);v&&h.push({node:v,snr:d.snr,quality:d.quality})}}),h.sort((d,v)=>v.snr-d.snr)},[e,t,r]);if(!e)return x.jsxs("div",{className:"w-[250px] flex-shrink-0 bg-bg-card border-l border-border p-4 flex flex-col items-center justify-center h-[540px]",children:[x.jsx("div",{className:"w-12 h-12 rounded-full bg-bg-hover border border-border flex items-center justify-center mb-3",children:x.jsx(tu,{size:24,className:"text-slate-500"})}),x.jsx("p",{className:"text-sm text-slate-500 text-center",children:"Click a node to inspect"})]});const a=lJe.includes(e.role),o=cJe(e.latitude),s=DU[o%DU.length],l=e.latitude!==null&&e.longitude!==null,u=e.battery_level!==null?e.battery_level>100||e.voltage&&e.voltage>4.1?"USB":`${e.battery_level.toFixed(0)}%`:"—",c=e.battery_level!==null&&(e.battery_level>100||e.voltage&&e.voltage>4.1);return x.jsxs("div",{className:"w-[250px] flex-shrink-0 bg-bg-card border-l border-border flex flex-col h-[540px] overflow-hidden",children:[x.jsxs("div",{className:"p-4 border-b border-border",children:[x.jsx("div",{className:"inline-flex items-center px-2 py-0.5 rounded text-xs font-mono mb-2",style:{backgroundColor:`${s}20`,color:s},children:e.node_id_hex}),x.jsx("div",{className:"font-mono text-lg text-slate-100",children:e.short_name}),x.jsx("div",{className:"text-xs text-slate-500 truncate",children:e.long_name})]}),x.jsxs("div",{className:"p-4 border-b border-border grid grid-cols-2 gap-3",children:[x.jsxs("div",{children:[x.jsx("div",{className:"text-xs text-slate-500 mb-0.5",children:"Role"}),x.jsx("div",{className:`text-sm font-medium ${a?"text-cyan-400":"text-slate-300"}`,children:e.role})]}),x.jsxs("div",{children:[x.jsx("div",{className:"text-xs text-slate-500 mb-0.5",children:"Region"}),x.jsx("div",{className:"text-sm text-slate-300",children:fJe(o)})]}),x.jsxs("div",{children:[x.jsx("div",{className:"text-xs text-slate-500 mb-0.5",children:"Battery"}),x.jsxs("div",{className:"text-sm text-slate-300 flex items-center gap-1",children:[c&&x.jsx(Sm,{size:12,className:"text-amber-400"}),u]})]}),x.jsxs("div",{children:[x.jsx("div",{className:"text-xs text-slate-500 mb-0.5",children:"Status"}),x.jsxs("div",{className:"flex items-center gap-1.5",children:[x.jsx("div",{className:`w-2 h-2 rounded-full ${dJe(e.last_heard)}`}),x.jsx("span",{className:"text-sm text-slate-300",children:hJe(e.last_heard)})]})]}),x.jsxs("div",{className:"col-span-2",children:[x.jsx("div",{className:"text-xs text-slate-500 mb-0.5",children:"Hardware"}),x.jsx("div",{className:"text-sm text-slate-300 font-mono truncate",children:e.hardware||"Unknown"})]})]}),l&&x.jsxs("div",{className:"px-4 py-3 border-b border-border flex gap-3",children:[x.jsxs("a",{href:`https://www.google.com/maps?q=${e.latitude},${e.longitude}`,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 text-xs text-blue-400 hover:text-blue-300",children:[x.jsx(xd,{size:10}),"Google Maps"]}),x.jsxs("a",{href:`https://www.openstreetmap.org/?mlat=${e.latitude}&mlon=${e.longitude}&zoom=14`,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 text-xs text-blue-400 hover:text-blue-300",children:[x.jsx(xd,{size:10}),"OSM"]})]}),x.jsxs("div",{className:"flex-1 overflow-y-auto",children:[x.jsxs("div",{className:"px-4 py-2 text-xs text-slate-500 font-medium sticky top-0 bg-bg-card border-b border-border",children:["Neighbors (",i.length,")"]}),i.length>0?x.jsx("div",{className:"divide-y divide-border",children:i.map(f=>x.jsxs("button",{onClick:()=>n(f.node.node_num),className:"w-full px-4 py-2 text-left hover:bg-bg-hover transition-colors flex items-center gap-2",style:{borderLeftWidth:3,borderLeftColor:NU(f.snr)},children:[x.jsxs("div",{className:"flex-1 min-w-0",children:[x.jsx("div",{className:"text-sm text-slate-200 font-mono truncate",children:f.node.short_name}),x.jsx("div",{className:"text-xs text-slate-500 truncate",children:f.node.long_name})]}),x.jsxs("div",{className:"text-right flex-shrink-0",children:[x.jsxs("div",{className:"text-xs font-mono",style:{color:NU(f.snr)},children:[f.snr.toFixed(1)," dB"]}),x.jsx("div",{className:"text-xs text-slate-500",children:uJe(f.snr)})]})]},f.node.node_num))}):x.jsx("div",{className:"px-4 py-6 text-center text-sm text-slate-500",children:"No known neighbors"})]})]})}const jU=["ROUTER","ROUTER_LATE","REPEATER","TRACKER"];function pJe(e){if(!e)return"bg-slate-500";const t=new Date(e),n=(new Date().getTime()-t.getTime())/36e5;return n<1?"bg-green-500":n<24?"bg-amber-500":"bg-slate-500"}function gJe(e){if(!e)return"—";const t=new Date(e),n=new Date().getTime()-t.getTime(),i=Math.floor(n/6e4),a=Math.floor(n/36e5),o=Math.floor(n/864e5);return i<1?"Just now":i<60?`${i}m ago`:a<24?`${a}h ago`:`${o}d ago`}function mJe(e){return e.battery_level===null?"—":e.battery_level>100||e.voltage&&e.voltage>4.1?"USB ⚡":`${e.battery_level.toFixed(0)}%`}function RU(e){return e===null?"—":e>46?"Northern":e>44.5?"Central":e>43?"SW Idaho":"SC Idaho"}function yJe({nodes:e,selectedNodeId:t,onSelectNode:r}){const[n,i]=W.useState(""),[a,o]=W.useState("short_name"),[s,l]=W.useState("asc"),[u,c]=W.useState("all"),f=W.useMemo(()=>{let v=[...e];if(u==="infra"?v=v.filter(g=>jU.includes(g.role)):u==="online"&&(v=v.filter(g=>{if(!g.last_heard)return!1;const m=new Date(g.last_heard);return(new Date().getTime()-m.getTime())/36e5<1})),n){const g=n.toLowerCase();v=v.filter(m=>m.short_name.toLowerCase().includes(g)||m.long_name.toLowerCase().includes(g)||m.role.toLowerCase().includes(g)||RU(m.latitude).toLowerCase().includes(g))}return v.sort((g,m)=>{let y="",_="";switch(a){case"short_name":y=g.short_name.toLowerCase(),_=m.short_name.toLowerCase();break;case"role":y=g.role,_=m.role;break;case"battery_level":y=g.battery_level??-1,_=m.battery_level??-1;break;case"last_heard":y=g.last_heard?new Date(g.last_heard).getTime():0,_=m.last_heard?new Date(m.last_heard).getTime():0;break;case"hardware":y=g.hardware.toLowerCase(),_=m.hardware.toLowerCase();break}return y<_?s==="asc"?-1:1:y>_?s==="asc"?1:-1:0}),v},[e,n,a,s,u]),h=v=>{a===v?l(s==="asc"?"desc":"asc"):(o(v),l("asc"))},d=({field:v})=>a!==v?null:s==="asc"?x.jsx(Zue,{size:14,className:"inline ml-1"}):x.jsx(Hy,{size:14,className:"inline ml-1"});return x.jsxs("div",{className:"bg-bg-card border border-border rounded-lg overflow-hidden",children:[x.jsxs("div",{className:"p-3 border-b border-border flex items-center gap-3",children:[x.jsxs("div",{className:"relative flex-1 max-w-xs",children:[x.jsx(HE,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-slate-500"}),x.jsx("input",{type:"text",placeholder:"Search nodes...",value:n,onChange:v=>i(v.target.value),className:"w-full pl-9 pr-3 py-1.5 bg-bg-hover border border-border rounded text-sm text-slate-200 placeholder-slate-500 focus:outline-none focus:border-accent"})]}),x.jsxs("div",{className:"flex items-center gap-1",children:[x.jsx(FE,{size:14,className:"text-slate-500 mr-1"}),["all","infra","online"].map(v=>x.jsx("button",{onClick:()=>c(v),className:`px-2 py-1 text-xs rounded transition-colors ${u===v?"bg-accent text-white":"bg-bg-hover text-slate-400 hover:text-slate-200"}`,children:v==="all"?"All":v==="infra"?"Infra":"Online"},v))]}),x.jsxs("div",{className:"text-xs text-slate-500 ml-auto",children:[f.length," of ",e.length," nodes"]})]}),x.jsxs("div",{className:"overflow-x-auto",children:[x.jsxs("table",{className:"w-full text-sm",children:[x.jsx("thead",{children:x.jsxs("tr",{className:"bg-bg-hover text-slate-400 text-xs",children:[x.jsx("th",{className:"w-8 px-3 py-2"}),x.jsxs("th",{className:"px-3 py-2 text-left cursor-pointer hover:text-slate-200",onClick:()=>h("short_name"),children:["Name ",x.jsx(d,{field:"short_name"})]}),x.jsxs("th",{className:"px-3 py-2 text-left cursor-pointer hover:text-slate-200",onClick:()=>h("role"),children:["Role ",x.jsx(d,{field:"role"})]}),x.jsx("th",{className:"px-3 py-2 text-left",children:"Region"}),x.jsxs("th",{className:"px-3 py-2 text-left cursor-pointer hover:text-slate-200",onClick:()=>h("battery_level"),children:["Battery ",x.jsx(d,{field:"battery_level"})]}),x.jsxs("th",{className:"px-3 py-2 text-left cursor-pointer hover:text-slate-200",onClick:()=>h("last_heard"),children:["Last Heard ",x.jsx(d,{field:"last_heard"})]}),x.jsxs("th",{className:"px-3 py-2 text-left cursor-pointer hover:text-slate-200",onClick:()=>h("hardware"),children:["Hardware ",x.jsx(d,{field:"hardware"})]})]})}),x.jsx("tbody",{className:"divide-y divide-border",children:f.slice(0,100).map(v=>{const g=jU.includes(v.role),m=v.node_num===t;return x.jsxs("tr",{onClick:()=>r(v.node_num),className:`cursor-pointer transition-colors ${m?"bg-accent/10":"hover:bg-bg-hover"}`,children:[x.jsx("td",{className:"px-3 py-2",children:x.jsx("div",{className:`w-2 h-2 rounded-full ${pJe(v.last_heard)}`})}),x.jsxs("td",{className:"px-3 py-2",children:[x.jsx("div",{className:"font-mono text-slate-200",children:v.short_name}),x.jsx("div",{className:"text-xs text-slate-500 truncate max-w-[200px]",children:v.long_name})]}),x.jsx("td",{className:"px-3 py-2",children:x.jsx("span",{className:`inline-block px-1.5 py-0.5 rounded text-xs font-medium ${g?"bg-cyan-500/20 text-cyan-400":"bg-slate-500/20 text-slate-400"}`,children:v.role})}),x.jsx("td",{className:"px-3 py-2 text-slate-400",children:RU(v.latitude)}),x.jsx("td",{className:"px-3 py-2 font-mono text-slate-300",children:mJe(v)}),x.jsx("td",{className:"px-3 py-2 text-slate-400",children:gJe(v.last_heard)}),x.jsx("td",{className:"px-3 py-2 font-mono text-xs text-slate-400 truncate max-w-[150px]",children:v.hardware||"—"})]},v.node_num)})})]}),f.length>100&&x.jsxs("div",{className:"px-3 py-2 text-xs text-slate-500 text-center border-t border-border",children:["Showing first 100 of ",f.length," nodes"]}),f.length===0&&x.jsx("div",{className:"px-3 py-8 text-sm text-slate-500 text-center",children:"No nodes match your filters"})]})]})}function xJe(){const[e,t]=W.useState([]),[r,n]=W.useState([]),[i,a]=W.useState([]),[o,s]=W.useState(null),[l,u]=W.useState("topo"),[c,f]=W.useState(!0),[h,d]=W.useState(null);W.useEffect(()=>{document.title="Mesh — MeshAI",Promise.all([oce(),sce(),gce()]).then(([m,y,_])=>{t(m),n(y),a(_),f(!1)}).catch(m=>{d(m.message),f(!1)})},[]);const v=W.useMemo(()=>e.find(m=>m.node_num===o)||null,[e,o]),g=W.useCallback(m=>{s(m)},[]);return c?x.jsx("div",{className:"flex items-center justify-center h-64",children:x.jsx("div",{className:"text-slate-400",children:"Loading mesh data..."})}):h?x.jsx("div",{className:"flex items-center justify-center h-64",children:x.jsxs("div",{className:"text-red-400",children:["Error: ",h]})}):x.jsxs("div",{className:"space-y-6",children:[x.jsxs("div",{className:"flex items-center justify-between",children:[x.jsxs("div",{className:"text-sm text-slate-400",children:[e.length," nodes • ",r.length," edges"]}),x.jsxs("div",{className:"flex items-center bg-bg-card border border-border rounded-lg p-1",children:[x.jsxs("button",{onClick:()=>u("topo"),className:`flex items-center gap-2 px-3 py-1.5 rounded text-sm transition-colors ${l==="topo"?"bg-accent text-white":"text-slate-400 hover:text-slate-200"}`,children:[x.jsx(tce,{size:14}),"Topology"]}),x.jsxs("button",{onClick:()=>u("geo"),className:`flex items-center gap-2 px-3 py-1.5 rounded text-sm transition-colors ${l==="geo"?"bg-accent text-white":"text-slate-400 hover:text-slate-200"}`,children:[x.jsx(Que,{size:14}),"Geographic"]})]})]}),x.jsxs("div",{className:"flex gap-0",children:[x.jsx("div",{className:"flex-1 min-w-0",children:l==="topo"?x.jsx(IQe,{nodes:e,edges:r,selectedNodeId:o,onSelectNode:g}):x.jsx(sJe,{nodes:e,edges:r,selectedNodeId:o,onSelectNode:g})}),x.jsx(vJe,{node:v,edges:r,nodes:e,onSelectNode:g})]}),x.jsx(yJe,{nodes:e,selectedNodeId:o,onSelectNode:g})]})}function _Je({feed:e}){const t=()=>e.is_loaded?e.consecutive_errors>0?"bg-amber-500":"bg-green-500":"bg-red-500",r=()=>e.is_loaded?e.consecutive_errors>0?`${e.consecutive_errors} errors`:"Healthy":"Not loaded",n=i=>i?new Date(i*1e3).toLocaleTimeString():"Never";return x.jsxs("div",{className:"bg-bg-hover rounded-lg p-4",children:[x.jsxs("div",{className:"flex items-center justify-between mb-2",children:[x.jsxs("div",{className:"flex items-center gap-2",children:[x.jsx("div",{className:`w-2 h-2 rounded-full ${t()}`}),x.jsx("span",{className:"text-sm font-medium text-slate-200 uppercase",children:e.source})]}),x.jsx("span",{className:"text-xs text-slate-400",children:r()})]}),x.jsxs("div",{className:"text-xs text-slate-500 space-y-1",children:[x.jsxs("div",{children:["Events: ",e.event_count]}),x.jsxs("div",{children:["Last fetch: ",n(e.last_fetch)]}),e.last_error&&x.jsx("div",{className:"text-amber-500 truncate",children:e.last_error})]})]})}function bJe({event:e}){const r=(a=>{switch(a.toLowerCase()){case"extreme":case"severe":return{bg:"bg-red-500/10",border:"border-red-500",icon:Uy,iconColor:"text-red-500"};case"moderate":case"warning":return{bg:"bg-amber-500/10",border:"border-amber-500",icon:Ds,iconColor:"text-amber-500"};case"minor":return{bg:"bg-yellow-500/10",border:"border-yellow-500",icon:wm,iconColor:"text-yellow-500"};default:return{bg:"bg-slate-500/10",border:"border-slate-500",icon:wm,iconColor:"text-slate-400"}}})(e.severity),n=r.icon,i=a=>a?new Date(a*1e3).toLocaleString():null;return x.jsx("div",{className:`p-4 rounded-lg ${r.bg} border-l-2 ${r.border}`,children:x.jsxs("div",{className:"flex items-start gap-3",children:[x.jsx(n,{size:18,className:r.iconColor}),x.jsxs("div",{className:"flex-1 min-w-0",children:[x.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[x.jsx("span",{className:"text-sm font-medium text-slate-200",children:e.event_type}),x.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded ${r.bg} ${r.iconColor}`,children:e.severity})]}),x.jsx("div",{className:"text-sm text-slate-300 mb-2",children:e.headline}),e.description&&x.jsx("div",{className:"text-xs text-slate-400 mb-2 line-clamp-2",children:e.description}),x.jsxs("div",{className:"flex items-center gap-4 text-xs text-slate-500",children:[x.jsx("span",{className:"uppercase",children:e.source}),e.expires&&x.jsxs("span",{children:["Expires: ",i(e.expires)]})]})]})]})})}function wJe({swpc:e}){var n,i;if(!e||!e.enabled)return x.jsxs("div",{className:"bg-bg-card border border-border rounded-lg p-6",children:[x.jsxs("h2",{className:"text-sm font-medium text-slate-400 mb-4 flex items-center gap-2",children:[x.jsx(Vb,{size:14}),"Solar/Geomagnetic Indices"]}),x.jsx("div",{className:"text-slate-500",children:"Data not available"})]});const t=a=>a===void 0?"text-slate-400":a<=2?"text-green-500":a<=4?"text-amber-500":a<=6?"text-orange-500":"text-red-500",r=a=>a===void 0||a===0?"text-green-500":a<=2?"text-amber-500":a<=3?"text-orange-500":"text-red-500";return x.jsxs("div",{className:"bg-bg-card border border-border rounded-lg p-6",children:[x.jsxs("h2",{className:"text-sm font-medium text-slate-400 mb-4 flex items-center gap-2",children:[x.jsx(Vb,{size:14}),"Solar/Geomagnetic Indices"]}),x.jsxs("div",{className:"grid grid-cols-2 gap-4 mb-4",children:[x.jsxs("div",{className:"bg-bg-hover rounded-lg p-3",children:[x.jsx("div",{className:"text-xs text-slate-500 mb-1",children:"Solar Flux Index"}),x.jsx("div",{className:"text-2xl font-mono text-slate-100",children:((n=e.sfi)==null?void 0:n.toFixed(0))??"—"}),x.jsx("div",{className:"text-xs text-slate-500",children:"SFI (10.7 cm)"})]}),x.jsxs("div",{className:"bg-bg-hover rounded-lg p-3",children:[x.jsx("div",{className:"text-xs text-slate-500 mb-1",children:"Planetary K-Index"}),x.jsx("div",{className:`text-2xl font-mono ${t(e.kp_current)}`,children:((i=e.kp_current)==null?void 0:i.toFixed(1))??"—"}),x.jsx("div",{className:"text-xs text-slate-500",children:"Kp"})]})]}),x.jsxs("div",{className:"bg-bg-hover rounded-lg p-3 mb-4",children:[x.jsx("div",{className:"text-xs text-slate-500 mb-2",children:"NOAA Space Weather Scales"}),x.jsxs("div",{className:"flex items-center gap-4",children:[x.jsxs("div",{className:"flex items-center gap-1",children:[x.jsx("span",{className:"text-xs text-slate-400",children:"R:"}),x.jsx("span",{className:`text-sm font-mono ${r(e.r_scale)}`,children:e.r_scale??0})]}),x.jsxs("div",{className:"flex items-center gap-1",children:[x.jsx("span",{className:"text-xs text-slate-400",children:"S:"}),x.jsx("span",{className:`text-sm font-mono ${r(e.s_scale)}`,children:e.s_scale??0})]}),x.jsxs("div",{className:"flex items-center gap-1",children:[x.jsx("span",{className:"text-xs text-slate-400",children:"G:"}),x.jsx("span",{className:`text-sm font-mono ${r(e.g_scale)}`,children:e.g_scale??0})]})]}),x.jsx("div",{className:"text-xs text-slate-500 mt-2",children:"Radio Blackout / Solar Radiation / Geomagnetic Storm"})]}),e.active_warnings&&e.active_warnings.length>0&&x.jsxs("div",{className:"space-y-2",children:[x.jsx("div",{className:"text-xs text-slate-500",children:"Active Warnings"}),e.active_warnings.slice(0,3).map((a,o)=>x.jsx("div",{className:"text-xs text-amber-400 bg-amber-500/10 rounded p-2",children:a},o))]})]})}function SJe({ducting:e}){if(!e||!e.enabled)return x.jsxs("div",{className:"bg-bg-card border border-border rounded-lg p-6",children:[x.jsxs("h2",{className:"text-sm font-medium text-slate-400 mb-4 flex items-center gap-2",children:[x.jsx(s3,{size:14}),"Tropospheric Ducting"]}),x.jsx("div",{className:"text-slate-500",children:"Data not available"})]});const t=n=>{switch(n){case"normal":return"text-green-500";case"super_refraction":return"text-amber-500";case"surface_duct":case"elevated_duct":return"text-blue-400";default:return"text-slate-400"}},r=n=>n?n.replace("_"," ").replace(/\b\w/g,i=>i.toUpperCase()):"Unknown";return x.jsxs("div",{className:"bg-bg-card border border-border rounded-lg p-6",children:[x.jsxs("h2",{className:"text-sm font-medium text-slate-400 mb-4 flex items-center gap-2",children:[x.jsx(s3,{size:14}),"Tropospheric Ducting"]}),x.jsxs("div",{className:"bg-bg-hover rounded-lg p-4 mb-4",children:[x.jsx("div",{className:"text-xs text-slate-500 mb-1",children:"Condition"}),x.jsx("div",{className:`text-xl font-medium ${t(e.condition)}`,children:r(e.condition)})]}),x.jsxs("div",{className:"grid grid-cols-2 gap-4 mb-4",children:[x.jsxs("div",{className:"bg-bg-hover rounded-lg p-3",children:[x.jsx("div",{className:"text-xs text-slate-500 mb-1",children:"Min Gradient"}),x.jsx("div",{className:"text-lg font-mono text-slate-100",children:e.min_gradient??"—"}),x.jsx("div",{className:"text-xs text-slate-500",children:"M-units/km"})]}),e.duct_thickness_m&&x.jsxs("div",{className:"bg-bg-hover rounded-lg p-3",children:[x.jsx("div",{className:"text-xs text-slate-500 mb-1",children:"Duct Thickness"}),x.jsx("div",{className:"text-lg font-mono text-slate-100",children:e.duct_thickness_m}),x.jsx("div",{className:"text-xs text-slate-500",children:"meters"})]}),e.duct_base_m&&x.jsxs("div",{className:"bg-bg-hover rounded-lg p-3",children:[x.jsx("div",{className:"text-xs text-slate-500 mb-1",children:"Duct Base"}),x.jsx("div",{className:"text-lg font-mono text-slate-100",children:e.duct_base_m}),x.jsx("div",{className:"text-xs text-slate-500",children:"meters AGL"})]})]}),x.jsxs("div",{className:"text-xs text-slate-500 bg-bg-hover rounded p-2",children:[x.jsx("div",{children:"dM/dz reference:"}),x.jsxs("div",{className:"mt-1 space-y-0.5",children:[x.jsx("div",{children:">79: Normal propagation"}),x.jsx("div",{children:"0–79: Super-refraction"}),x.jsx("div",{children:"<0: Ducting (trapping layer)"})]})]}),e.last_update&&x.jsxs("div",{className:"text-xs text-slate-500 mt-3",children:["Last update: ",e.last_update]})]})}function TJe(){var I;const[e,t]=W.useState(null),[r,n]=W.useState([]),[i,a]=W.useState(null),[o,s]=W.useState(null),[l,u]=W.useState([]),[c,f]=W.useState(null),[h,d]=W.useState([]),[v,g]=W.useState([]),[m,y]=W.useState([]),[_,b]=W.useState([]),[S,T]=W.useState(0),[A,M]=W.useState(!0),[P,k]=W.useState(null);return W.useEffect(()=>{document.title="Environment — MeshAI",Promise.all([LZ().catch(()=>null),kZ().catch(()=>[]),IZ().catch(()=>null),OZ().catch(()=>null),cce().catch(()=>[]),fce().catch(()=>null),hce().catch(()=>[]),dce().catch(()=>[]),vce().catch(()=>[]),pce().catch(()=>({hotspots:[],new_ignitions:0}))]).then(([O,D,N,B,$,F,G,z,U,H])=>{t(O),n(D),a(N),s(B),u($),f(F),d(G||[]),g(z||[]),y(U||[]),b((H==null?void 0:H.hotspots)||[]),T((H==null?void 0:H.new_ignitions)||0),M(!1)}).catch(O=>{k(O.message),M(!1)})},[]),A?x.jsx("div",{className:"flex items-center justify-center h-64",children:x.jsx("div",{className:"text-slate-400",children:"Loading environmental data..."})}):P?x.jsx("div",{className:"flex items-center justify-center h-64",children:x.jsxs("div",{className:"text-red-400",children:["Error: ",P]})}):e!=null&&e.enabled?x.jsxs("div",{className:"space-y-6",children:[x.jsxs("div",{className:"flex items-center justify-between",children:[x.jsx("h1",{className:"text-xl font-semibold text-slate-200",children:"Environment"}),x.jsxs("div",{className:"text-xs text-slate-500",children:[r.length," active event",r.length!==1?"s":""]})]}),x.jsxs("div",{className:"bg-bg-card border border-border rounded-lg p-6",children:[x.jsxs("h2",{className:"text-sm font-medium text-slate-400 mb-4 flex items-center gap-2",children:[x.jsx(Wy,{size:14}),"Feed Status"]}),x.jsx("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:e.feeds.map(O=>x.jsx(_Je,{feed:O},O.source))})]}),x.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[x.jsx(wJe,{swpc:i}),x.jsx(SJe,{ducting:o})]}),x.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[x.jsxs("div",{className:"bg-bg-card border border-border rounded-lg p-6",children:[x.jsxs("h2",{className:"text-sm font-medium text-slate-400 mb-4 flex items-center gap-2",children:[x.jsx(VE,{size:14}),"Active Wildfires (",l.length,")"]}),l.length>0?x.jsx("div",{className:"space-y-3",children:l.map(O=>x.jsxs("div",{className:`p-3 rounded-lg ${O.severity==="warning"?"bg-red-500/10 border-l-2 border-red-500":O.severity==="watch"?"bg-amber-500/10 border-l-2 border-amber-500":"bg-slate-500/10 border-l-2 border-slate-500"}`,children:[x.jsxs("div",{className:"flex items-center justify-between mb-1",children:[x.jsx("span",{className:"text-sm font-medium text-slate-200",children:O.name}),x.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded ${O.severity==="warning"?"bg-red-500/20 text-red-400":O.severity==="watch"?"bg-amber-500/20 text-amber-400":"bg-slate-500/20 text-slate-400"}`,children:O.severity})]}),x.jsxs("div",{className:"text-xs text-slate-400 space-y-1",children:[x.jsxs("div",{children:[O.acres.toLocaleString()," acres, ",O.pct_contained,"% contained"]}),O.distance_km&&O.nearest_anchor&&x.jsxs("div",{children:[Math.round(O.distance_km)," km from ",O.nearest_anchor]})]})]},O.event_id))}):x.jsxs("div",{className:"flex items-center gap-2 text-slate-500 py-4",children:[x.jsx(Qh,{size:16,className:"text-green-500"}),x.jsx("span",{children:"No active wildfires in the area"})]})]}),x.jsxs("div",{className:"bg-bg-card border border-border rounded-lg p-6",children:[x.jsxs("h2",{className:"text-sm font-medium text-slate-400 mb-4 flex items-center gap-2",children:[x.jsx(GE,{size:14}),"Avalanche Advisories"]}),c!=null&&c.off_season?x.jsx("div",{className:"text-slate-500 py-4",children:x.jsx("p",{children:"Off season - check back in December"})}):c&&c.advisories.length>0?x.jsxs("div",{className:"space-y-3",children:[c.advisories.map(O=>x.jsxs("div",{className:`p-3 rounded-lg ${O.danger_level>=4?"bg-red-500/10 border-l-2 border-red-500":O.danger_level>=3?"bg-amber-500/10 border-l-2 border-amber-500":O.danger_level>=2?"bg-yellow-500/10 border-l-2 border-yellow-500":"bg-green-500/10 border-l-2 border-green-500"}`,children:[x.jsxs("div",{className:"flex items-center justify-between mb-1",children:[x.jsx("span",{className:"text-sm font-medium text-slate-200",children:O.zone_name}),x.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded ${O.danger_level>=4?"bg-red-500/20 text-red-400":O.danger_level>=3?"bg-amber-500/20 text-amber-400":O.danger_level>=2?"bg-yellow-500/20 text-yellow-400":"bg-green-500/20 text-green-400"}`,children:O.danger_name})]}),x.jsx("div",{className:"text-xs text-slate-400",children:O.center}),O.travel_advice&&x.jsx("div",{className:"text-xs text-slate-500 mt-2 line-clamp-2",children:O.travel_advice})]},O.event_id)),((I=c.advisories[0])==null?void 0:I.center_link)&&x.jsx("a",{href:c.advisories[0].center_link,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-blue-400 hover:underline",children:"View full forecast"})]}):x.jsxs("div",{className:"flex items-center gap-2 text-slate-500 py-4",children:[x.jsx(Qh,{size:16,className:"text-green-500"}),x.jsx("span",{children:"No avalanche advisories"})]})]})]}),h.length>0&&x.jsxs("div",{className:"bg-bg-card border border-border rounded-lg p-6",children:[x.jsxs("h2",{className:"text-sm font-medium text-slate-400 mb-4 flex items-center gap-2",children:[x.jsx(zE,{size:14}),"Stream Gauges (",h.length,")"]}),x.jsx("div",{className:"space-y-2",children:h.map(O=>{var D,N,B,$,F;return x.jsxs("div",{className:`p-3 rounded-lg ${O.severity==="warning"?"bg-amber-500/10 border-l-2 border-amber-500":"bg-blue-500/10 border-l-2 border-blue-500"}`,children:[x.jsxs("div",{className:"flex items-center justify-between",children:[x.jsx("span",{className:"text-sm text-slate-200",children:((D=O.properties)==null?void 0:D.site_name)||"Unknown Site"}),x.jsxs("span",{className:"text-sm font-mono text-slate-300",children:[(B=(N=O.properties)==null?void 0:N.value)==null?void 0:B.toLocaleString()," ",($=O.properties)==null?void 0:$.unit]})]}),x.jsx("div",{className:"text-xs text-slate-500 mt-1",children:(F=O.properties)==null?void 0:F.parameter})]},O.event_id)})})]}),(v.length>0||m.length>0)&&x.jsxs("div",{className:"bg-bg-card border border-border rounded-lg p-6",children:[x.jsxs("h2",{className:"text-sm font-medium text-slate-400 mb-4 flex items-center gap-2",children:[x.jsx(BE,{size:14}),"Road Conditions"]}),v.length>0&&x.jsxs("div",{className:"mb-4",children:[x.jsx("div",{className:"text-xs text-slate-500 mb-2 uppercase",children:"Traffic Flow"}),x.jsx("div",{className:"space-y-2",children:v.map(O=>{var D,N,B,$,F,G,z,U,H;return x.jsxs("div",{className:`p-3 rounded-lg ${(D=O.properties)!=null&&D.roadClosure?"bg-red-500/10 border-l-2 border-red-500":((N=O.properties)==null?void 0:N.speedRatio)<.5?"bg-amber-500/10 border-l-2 border-amber-500":((B=O.properties)==null?void 0:B.speedRatio)<.8?"bg-yellow-500/10 border-l-2 border-yellow-500":"bg-green-500/10 border-l-2 border-green-500"}`,children:[x.jsxs("div",{className:"flex items-center justify-between",children:[x.jsx("span",{className:"text-sm text-slate-200",children:(($=O.properties)==null?void 0:$.corridor)||"Unknown"}),x.jsx("span",{className:"text-sm font-mono text-slate-300",children:(F=O.properties)!=null&&F.roadClosure?"CLOSED":`${Math.round(((G=O.properties)==null?void 0:G.currentSpeed)||0)}mph`})]}),!((z=O.properties)!=null&&z.roadClosure)&&x.jsxs("div",{className:"text-xs text-slate-500 mt-1",children:[Math.round((((U=O.properties)==null?void 0:U.speedRatio)||1)*100),"% of free flow (",Math.round(((H=O.properties)==null?void 0:H.freeFlowSpeed)||0),"mph)"]})]},O.event_id)})})]}),m.length>0&&x.jsxs("div",{children:[x.jsx("div",{className:"text-xs text-slate-500 mb-2 uppercase",children:"Road Events"}),x.jsx("div",{className:"space-y-2",children:m.map(O=>{var D,N;return x.jsxs("div",{className:`p-3 rounded-lg ${(D=O.properties)!=null&&D.is_closure?"bg-red-500/10 border-l-2 border-red-500":"bg-amber-500/10 border-l-2 border-amber-500"}`,children:[x.jsxs("div",{className:"flex items-center gap-2",children:[((N=O.properties)==null?void 0:N.is_closure)&&x.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-red-500/20 text-red-400",children:"CLOSURE"}),x.jsx("span",{className:"text-sm text-slate-200 line-clamp-1",children:O.headline})]}),x.jsx("div",{className:"text-xs text-slate-500 mt-1 uppercase",children:O.event_type})]},O.event_id)})})]})]}),_.length>0&&x.jsxs("div",{className:"bg-bg-card border border-border rounded-lg p-6",children:[x.jsxs("h2",{className:"text-sm font-medium text-slate-400 mb-4 flex items-center gap-2",children:[x.jsx(WE,{size:14}),"Satellite Hotspots (",_.length,")",S>0&&x.jsxs("span",{className:"ml-2 px-2 py-0.5 text-xs rounded-full bg-red-500/20 text-red-400 animate-pulse",children:[S," NEW"]})]}),x.jsx("div",{className:"space-y-2",children:_.map(O=>{var D,N,B,$,F,G;return x.jsxs("div",{className:`p-3 rounded-lg ${(D=O.properties)!=null&&D.new_ignition?"bg-red-500/10 border-l-2 border-red-500":O.severity==="watch"?"bg-amber-500/10 border-l-2 border-amber-500":"bg-orange-500/10 border-l-2 border-orange-500"}`,children:[x.jsxs("div",{className:"flex items-center justify-between",children:[x.jsxs("div",{className:"flex items-center gap-2",children:[((N=O.properties)==null?void 0:N.new_ignition)&&x.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-red-500/20 text-red-400",children:"NEW"}),x.jsx("span",{className:"text-sm text-slate-200",children:O.headline})]}),((B=O.properties)==null?void 0:B.frp)&&x.jsxs("span",{className:"text-sm font-mono text-orange-400",children:[Math.round(O.properties.frp)," MW"]})]}),x.jsxs("div",{className:"text-xs text-slate-500 mt-1 flex items-center gap-3",children:[x.jsxs("span",{children:["Conf: ",(($=O.properties)==null?void 0:$.confidence)||"N/A"]}),((F=O.properties)==null?void 0:F.acq_time)&&x.jsxs("span",{children:["@",O.properties.acq_time,"Z"]}),((G=O.properties)==null?void 0:G.near_fire)&&x.jsxs("span",{children:["Near: ",O.properties.near_fire]})]})]},O.event_id)})})]}),x.jsxs("div",{className:"bg-bg-card border border-border rounded-lg p-6",children:[x.jsxs("h2",{className:"text-sm font-medium text-slate-400 mb-4 flex items-center gap-2",children:[x.jsx(Ds,{size:14}),"Active Events (",r.length,")"]}),r.length>0?x.jsx("div",{className:"space-y-3",children:r.map(O=>x.jsx(bJe,{event:O},O.event_id))}):x.jsxs("div",{className:"flex items-center gap-2 text-slate-500 py-4",children:[x.jsx(Qh,{size:16,className:"text-green-500"}),x.jsx("span",{children:"No active environmental events"})]})]})]}):x.jsxs("div",{className:"flex flex-col items-center justify-center h-[60vh] text-center",children:[x.jsx("div",{className:"w-16 h-16 rounded-full bg-bg-card border border-border flex items-center justify-center mb-6",children:x.jsx(Yc,{size:32,className:"text-slate-500"})}),x.jsx("h2",{className:"text-xl font-semibold text-slate-300 mb-2",children:"Environmental Feeds Disabled"}),x.jsx("p",{className:"text-slate-500 max-w-md",children:"Enable environmental feeds in config.yaml to see weather alerts, space weather indices, and tropospheric ducting data."})]})}function jR({label:e,value:t,onChange:r,helper:n,info:i,roleFilter:a,valueType:o="short_name"}){const[s,l]=W.useState([]),[u,c]=W.useState(!0),[f,h]=W.useState(""),[d,v]=W.useState(!1);W.useEffect(()=>{fetch("/api/nodes").then(S=>S.json()).then(S=>{l(S),c(!1)}).catch(()=>{l([]),c(!1)})},[]);const g=W.useMemo(()=>{let S=s;if(a&&(S=S.filter(T=>a==="ROUTER"||a==="infrastructure"?T.is_infrastructure||T.role==="ROUTER"||T.role==="ROUTER_CLIENT"||T.role==="REPEATER":T.role===a)),f.trim()){const T=f.toLowerCase();S=S.filter(A=>{var M,P,k,I;return((M=A.short_name)==null?void 0:M.toLowerCase().includes(T))||((P=A.long_name)==null?void 0:P.toLowerCase().includes(T))||((k=A.role)==null?void 0:k.toLowerCase().includes(T))||((I=A.node_id_hex)==null?void 0:I.toLowerCase().includes(T))})}return S.sort((T,A)=>(T.short_name||"").localeCompare(A.short_name||""))},[s,f,a]),m=S=>{switch(o){case"node_num":return String(S.node_num);case"node_id_hex":return S.node_id_hex;default:return S.short_name||String(S.node_num)}},y=S=>{const T=m(S);return t.includes(T)},_=S=>{const T=m(S);t.includes(T)?r(t.filter(A=>A!==T)):r([...t,T])},b=S=>{const T=[S.short_name];return S.long_name&&S.long_name!==S.short_name&&T.push(`— ${S.long_name}`),S.role&&T.push(`(${S.role})`),T.join(" ")};return!u&&s.length===0?x.jsxs("div",{className:"space-y-1",children:[x.jsx("label",{className:"block text-xs text-slate-500 uppercase tracking-wide",children:e}),x.jsx("input",{type:"text",value:t.join(", "),onChange:S=>r(S.target.value.split(",").map(T=>T.trim()).filter(Boolean)),placeholder:"Enter node IDs separated by commas",className:"w-full px-3 py-2 bg-[#0a0e17] border border-[#1e2a3a] rounded text-sm text-slate-200 font-mono focus:outline-none focus:border-accent"}),n&&x.jsx("p",{className:"text-xs text-slate-600",children:n})]}):x.jsxs("div",{className:"space-y-1",children:[x.jsx("label",{className:"block text-xs text-slate-500 uppercase tracking-wide",children:e}),t.length>0&&x.jsx("div",{className:"flex flex-wrap gap-2 mb-2",children:t.map(S=>{const T=s.find(A=>m(A)===S);return x.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-1 bg-accent/20 text-accent rounded text-sm",children:[T?T.short_name:S,x.jsx("button",{type:"button",onClick:()=>r(t.filter(A=>A!==S)),className:"hover:text-white",children:x.jsx(hv,{size:14})})]},S)})}),x.jsxs("div",{className:"relative",children:[x.jsxs("div",{className:"relative",children:[x.jsx(HE,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-slate-500"}),x.jsx("input",{type:"text",value:f,onChange:S=>h(S.target.value),onFocus:()=>v(!0),placeholder:u?"Loading nodes...":"Search nodes...",className:"w-full pl-9 pr-3 py-2 bg-[#0a0e17] border border-[#1e2a3a] rounded text-sm text-slate-200 focus:outline-none focus:border-accent"})]}),d&&!u&&x.jsxs(x.Fragment,{children:[x.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>v(!1)}),x.jsx("div",{className:"absolute left-0 right-0 top-full mt-1 z-50 max-h-64 overflow-y-auto bg-[#0a0e17] border border-[#1e2a3a] rounded-lg shadow-xl",children:g.length===0?x.jsx("div",{className:"p-3 text-sm text-slate-500 text-center",children:"No nodes found"}):g.map(S=>x.jsxs("button",{type:"button",onClick:()=>_(S),className:`w-full flex items-center gap-2 px-3 py-2 text-left text-sm hover:bg-[#1e2a3a] ${y(S)?"bg-accent/10":""}`,children:[x.jsx("div",{className:`w-4 h-4 rounded border flex items-center justify-center ${y(S)?"bg-accent border-accent":"border-slate-600"}`,children:y(S)&&x.jsx(md,{size:12,className:"text-white"})}),x.jsx("span",{className:"text-slate-200",children:b(S)})]},S.node_num))})]})]}),n&&x.jsx("p",{className:"text-xs text-slate-600",children:n})]})}function RR(e){const[t,r]=W.useState([]),[n,i]=W.useState(!0);W.useEffect(()=>{fetch("/api/channels").then(h=>h.json()).then(h=>{r(h),i(!1)}).catch(()=>{r([]),i(!1)})},[]);const a=h=>{const d=h.role==="PRIMARY"?"Primary":h.role==="SECONDARY"?"Secondary":"";return`${h.index}: ${h.name}${d?` (${d})`:""}`};if(!n&&t.length===0)return e.mode==="single"?x.jsxs("div",{className:"space-y-1",children:[x.jsx("label",{className:"block text-xs text-slate-500 uppercase tracking-wide",children:e.label}),x.jsx("input",{type:"number",value:e.value,onChange:h=>e.onChange(Number(h.target.value)),min:e.includeDisabled?-1:0,max:7,className:"w-full px-3 py-2 bg-[#0a0e17] border border-[#1e2a3a] rounded text-sm text-slate-200 font-mono focus:outline-none focus:border-accent"}),e.helper&&x.jsx("p",{className:"text-xs text-slate-600",children:e.helper})]}):x.jsxs("div",{className:"space-y-1",children:[x.jsx("label",{className:"block text-xs text-slate-500 uppercase tracking-wide",children:e.label}),x.jsx("input",{type:"text",value:e.value.join(", "),onChange:h=>{const d=h.target.value.split(",").map(v=>parseInt(v.trim())).filter(v=>!isNaN(v));e.onChange(d)},placeholder:"Enter channel numbers separated by commas",className:"w-full px-3 py-2 bg-[#0a0e17] border border-[#1e2a3a] rounded text-sm text-slate-200 font-mono focus:outline-none focus:border-accent"}),e.helper&&x.jsx("p",{className:"text-xs text-slate-600",children:e.helper})]});if(e.mode==="single"){const{value:h,onChange:d,label:v,helper:g,includeDisabled:m}=e,y=t.filter(_=>_.enabled);return x.jsxs("div",{className:"space-y-1",children:[x.jsx("label",{className:"block text-xs text-slate-500 uppercase tracking-wide",children:v}),x.jsxs("select",{value:h,onChange:_=>d(Number(_.target.value)),className:"w-full px-3 py-2 bg-[#0a0e17] border border-[#1e2a3a] rounded text-sm text-slate-200 focus:outline-none focus:border-accent",children:[m&&x.jsx("option",{value:-1,children:"Disabled"}),y.map(_=>x.jsx("option",{value:_.index,children:a(_)},_.index))]}),g&&x.jsx("p",{className:"text-xs text-slate-600",children:g})]})}const{value:o,onChange:s,label:l,helper:u}=e,c=t.filter(h=>h.enabled),f=h=>{o.includes(h)?s(o.filter(d=>d!==h)):s([...o,h].sort((d,v)=>d-v))};return x.jsxs("div",{className:"space-y-1",children:[x.jsx("label",{className:"block text-xs text-slate-500 uppercase tracking-wide",children:l}),x.jsxs("div",{className:"border border-[#1e2a3a] rounded-lg p-2 space-y-1",children:[c.map(h=>x.jsxs("label",{onClick:()=>f(h.index),className:"flex items-center gap-2 p-2 rounded hover:bg-[#0a0e17] cursor-pointer",children:[x.jsx("div",{className:`w-4 h-4 rounded border flex items-center justify-center ${o.includes(h.index)?"bg-accent border-accent":"border-slate-600"}`,children:o.includes(h.index)&&x.jsx(md,{size:12,className:"text-white"})}),x.jsx("span",{className:"text-sm text-slate-200",children:a(h)})]},h.index)),c.length===0&&x.jsx("div",{className:"text-sm text-slate-500 p-2",children:"No channels available"})]}),u&&x.jsx("p",{className:"text-xs text-slate-600",children:u})]})}const BU=[{key:"bot",label:"Bot",icon:Gue},{key:"connection",label:"Connection",icon:MZ},{key:"response",label:"Response",icon:Jue},{key:"history",label:"History",icon:Kue},{key:"memory",label:"Memory",icon:Wue},{key:"context",label:"Context",icon:$E},{key:"commands",label:"Commands",icon:CZ},{key:"llm",label:"LLM",icon:mZ},{key:"weather",label:"Weather",icon:Yc},{key:"meshmonitor",label:"MeshMonitor",icon:tu},{key:"knowledge",label:"Knowledge",icon:pZ},{key:"mesh_sources",label:"Mesh Sources",icon:xZ},{key:"mesh_intelligence",label:"Intelligence",icon:Wy},{key:"environmental",label:"Environmental",icon:rce},{key:"dashboard",label:"Dashboard",icon:_Z}],Kn={bot:"Identity and behavior settings for the bot on the mesh network.",connection:"How MeshAI connects to your Meshtastic radio.",response:"Controls how quickly and how much the bot responds on the mesh.",history:"Conversation history storage and cleanup.",memory:"Short-term conversation memory management. Controls how the bot maintains context within a conversation.",context:"Passive channel monitoring. The bot listens to mesh channels and uses recent messages as context when responding.",commands:"Mesh commands available via the configured prefix. Toggle individual commands on or off.",llm:"AI model configuration. MeshAI uses an LLM to understand questions and generate responses.",weather:"Weather data for the !weather command. This is separate from NWS environmental alerts.",meshmonitor:"AIDA MeshMonitor integration. An additional data source for mesh network monitoring.",knowledge:"Knowledge base for answering questions from stored documents. Connects to Qdrant vector database or local SQLite.",mesh_sources:"Data sources for mesh network information. MeshAI can pull data from multiple sources simultaneously and merge them into a unified view.",mesh_intelligence:"Advanced mesh analysis: health scoring, region management, and automated alerting. The intelligence engine monitors your mesh and detects problems automatically.",environmental:"Live environmental data feeds for situational awareness. Each feed polls a public or authenticated API for real-time conditions affecting your area.",dashboard:"Web dashboard settings. You're looking at it right now."},AJe=[{name:"help",description:"Show available commands and usage"},{name:"health",description:"Mesh network health overview with status dots"},{name:"status",description:"Quick mesh status summary"},{name:"region",description:"List regions or get detailed region breakdown"},{name:"neighbors",description:"Show top infrastructure neighbors with signal quality"},{name:"ping",description:"Test bot responsiveness"},{name:"clear",description:"Clear your conversation history"},{name:"reset",description:"Reset conversation context"},{name:"sub",description:"Subscribe to scheduled reports or alerts"},{name:"unsub",description:"Remove a subscription"},{name:"mysubs",description:"List your active subscriptions"},{name:"alerts",description:"Active NWS weather alerts for mesh area"},{name:"solar",description:"Space weather and HF propagation conditions"},{name:"hf",description:"HF radio propagation (alias for !solar)"},{name:"fire",description:"Active wildfires near the mesh"},{name:"avy",description:"Avalanche advisories for configured zones"},{name:"hotspots",description:"NASA FIRMS satellite fire detections"},{name:"streams",description:"USGS stream gauge readings"},{name:"roads",description:"Road conditions and closures"},{name:"traffic",description:"Traffic flow on monitored corridors"}],CJe=[{value:"US-AL",label:"Alabama"},{value:"US-AK",label:"Alaska"},{value:"US-AZ",label:"Arizona"},{value:"US-AR",label:"Arkansas"},{value:"US-CA",label:"California"},{value:"US-CO",label:"Colorado"},{value:"US-CT",label:"Connecticut"},{value:"US-DE",label:"Delaware"},{value:"US-FL",label:"Florida"},{value:"US-GA",label:"Georgia"},{value:"US-HI",label:"Hawaii"},{value:"US-ID",label:"Idaho"},{value:"US-IL",label:"Illinois"},{value:"US-IN",label:"Indiana"},{value:"US-IA",label:"Iowa"},{value:"US-KS",label:"Kansas"},{value:"US-KY",label:"Kentucky"},{value:"US-LA",label:"Louisiana"},{value:"US-ME",label:"Maine"},{value:"US-MD",label:"Maryland"},{value:"US-MA",label:"Massachusetts"},{value:"US-MI",label:"Michigan"},{value:"US-MN",label:"Minnesota"},{value:"US-MS",label:"Mississippi"},{value:"US-MO",label:"Missouri"},{value:"US-MT",label:"Montana"},{value:"US-NE",label:"Nebraska"},{value:"US-NV",label:"Nevada"},{value:"US-NH",label:"New Hampshire"},{value:"US-NJ",label:"New Jersey"},{value:"US-NM",label:"New Mexico"},{value:"US-NY",label:"New York"},{value:"US-NC",label:"North Carolina"},{value:"US-ND",label:"North Dakota"},{value:"US-OH",label:"Ohio"},{value:"US-OK",label:"Oklahoma"},{value:"US-OR",label:"Oregon"},{value:"US-PA",label:"Pennsylvania"},{value:"US-RI",label:"Rhode Island"},{value:"US-SC",label:"South Carolina"},{value:"US-SD",label:"South Dakota"},{value:"US-TN",label:"Tennessee"},{value:"US-TX",label:"Texas"},{value:"US-UT",label:"Utah"},{value:"US-VT",label:"Vermont"},{value:"US-VA",label:"Virginia"},{value:"US-WA",label:"Washington"},{value:"US-WV",label:"West Virginia"},{value:"US-WI",label:"Wisconsin"},{value:"US-WY",label:"Wyoming"}];function Wo({info:e,link:t,linkText:r="Learn more"}){const[n,i]=W.useState(!1),a=W.useRef(null);return W.useEffect(()=>{if(!n)return;function o(l){a.current&&!a.current.contains(l.target)&&i(!1)}const s=setTimeout(()=>document.addEventListener("mousedown",o),0);return()=>{clearTimeout(s),document.removeEventListener("mousedown",o)}},[n]),x.jsxs("div",{className:"relative inline-block",ref:a,children:[x.jsx("button",{type:"button",onClick:o=>{o.stopPropagation(),i(!n)},className:"ml-1.5 w-4 h-4 rounded-full bg-slate-700 hover:bg-slate-600 text-slate-400 hover:text-slate-200 inline-flex items-center justify-center text-xs transition-colors",title:"More info",children:"?"}),n&&x.jsxs("div",{className:"absolute left-0 top-6 z-50 w-72 p-3 bg-[#1a2332] border border-[#2a3a4a] rounded-lg shadow-xl text-xs text-slate-300 leading-relaxed",children:[x.jsx("button",{type:"button",onClick:()=>i(!1),className:"absolute top-1 right-1 w-5 h-5 rounded hover:bg-slate-700 text-slate-500 hover:text-slate-300 inline-flex items-center justify-center transition-colors","aria-label":"Close",children:x.jsx(hv,{size:12})}),x.jsx("div",{className:"pr-4",children:e}),t&&x.jsxs("a",{href:t,target:"_blank",rel:"noopener noreferrer",className:"mt-2 flex items-center gap-1 text-accent hover:underline",onClick:o=>o.stopPropagation(),children:[r," ",x.jsx(xd,{size:10})]})]})]})}function Qn({text:e}){return x.jsx("p",{className:"text-sm text-slate-500 mb-6 pb-4 border-b border-[#1e2a3a]",children:e})}function At({label:e,value:t,onChange:r,type:n="text",placeholder:i="",helper:a="",info:o="",infoLink:s=""}){const[l,u]=W.useState(!1),c=n==="password";return x.jsxs("div",{className:"space-y-1",children:[x.jsxs("label",{className:"flex items-center text-xs text-slate-500 uppercase tracking-wide",children:[e,o&&x.jsx(Wo,{info:o,link:s})]}),x.jsxs("div",{className:"relative",children:[x.jsx("input",{type:c&&!l?"password":"text",value:t,onChange:f=>r(f.target.value),placeholder:i,className:"w-full px-3 py-2 bg-[#0a0e17] border border-[#1e2a3a] rounded text-sm text-slate-200 font-mono focus:outline-none focus:border-accent placeholder-slate-600"}),c&&x.jsx("button",{type:"button",onClick:()=>u(!l),className:"absolute right-2 top-1/2 -translate-y-1/2 text-slate-500 hover:text-slate-300",children:l?x.jsx(yZ,{size:16}):x.jsx($E,{size:16})})]}),a&&x.jsx("p",{className:"text-xs text-slate-600",children:a})]})}function qe({label:e,value:t,onChange:r,min:n,max:i,step:a=1,helper:o="",info:s="",infoLink:l=""}){return x.jsxs("div",{className:"space-y-1",children:[x.jsxs("label",{className:"flex items-center text-xs text-slate-500 uppercase tracking-wide",children:[e,s&&x.jsx(Wo,{info:s,link:l})]}),x.jsx("input",{type:"number",value:t,onChange:u=>r(Number(u.target.value)),min:n,max:i,step:a,className:"w-full px-3 py-2 bg-[#0a0e17] border border-[#1e2a3a] rounded text-sm text-slate-200 font-mono focus:outline-none focus:border-accent"}),o&&x.jsx("p",{className:"text-xs text-slate-600",children:o})]})}function Et({label:e,checked:t,onChange:r,helper:n="",info:i="",infoLink:a=""}){return x.jsxs("div",{className:"flex items-center justify-between py-2",children:[x.jsxs("div",{children:[x.jsxs("span",{className:"flex items-center text-sm text-slate-300",children:[e,i&&x.jsx(Wo,{info:i,link:a})]}),n&&x.jsx("p",{className:"text-xs text-slate-600",children:n})]}),x.jsx("button",{type:"button",onClick:()=>r(!t),className:`relative w-11 h-6 rounded-full transition-colors ${t?"bg-accent":"bg-[#1e2a3a]"}`,children:x.jsx("span",{className:`absolute top-1 left-1 w-4 h-4 rounded-full bg-white transition-transform ${t?"translate-x-5":""}`})})]})}function Co({label:e,value:t,onChange:r,options:n,helper:i="",info:a="",infoLink:o=""}){return x.jsxs("div",{className:"space-y-1",children:[x.jsxs("label",{className:"flex items-center text-xs text-slate-500 uppercase tracking-wide",children:[e,a&&x.jsx(Wo,{info:a,link:o})]}),x.jsx("select",{value:t,onChange:s=>r(s.target.value),className:"w-full px-3 py-2 bg-[#0a0e17] border border-[#1e2a3a] rounded text-sm text-slate-200 focus:outline-none focus:border-accent",children:n.map(s=>x.jsx("option",{value:s.value,children:s.label},s.value))}),i&&x.jsx("p",{className:"text-xs text-slate-600",children:i})]})}function MJe({label:e,value:t,onChange:r,rows:n=4,helper:i="",info:a="",infoLink:o=""}){return x.jsxs("div",{className:"space-y-1",children:[x.jsxs("label",{className:"flex items-center text-xs text-slate-500 uppercase tracking-wide",children:[e,a&&x.jsx(Wo,{info:a,link:o})]}),x.jsx("textarea",{value:t,onChange:s=>r(s.target.value),rows:n,className:"w-full px-3 py-2 bg-[#0a0e17] border border-[#1e2a3a] rounded text-sm text-slate-200 font-mono focus:outline-none focus:border-accent resize-y"}),i&&x.jsx("p",{className:"text-xs text-slate-600",children:i})]})}function Hh({label:e,value:t,onChange:r,helper:n="",info:i="",infoLink:a=""}){const[o,s]=W.useState(t.join(", "));W.useEffect(()=>{s(t.join(", "))},[t]);const l=()=>{const u=o.split(",").map(c=>c.trim()).filter(Boolean);r(u)};return x.jsxs("div",{className:"space-y-1",children:[x.jsxs("label",{className:"flex items-center text-xs text-slate-500 uppercase tracking-wide",children:[e,i&&x.jsx(Wo,{info:i,link:a})]}),x.jsx("input",{type:"text",value:o,onChange:u=>s(u.target.value),onBlur:l,placeholder:"item1, item2, item3",className:"w-full px-3 py-2 bg-[#0a0e17] border border-[#1e2a3a] rounded text-sm text-slate-200 font-mono focus:outline-none focus:border-accent placeholder-slate-600"}),n&&x.jsx("p",{className:"text-xs text-slate-600",children:n})]})}function PJe({label:e,value:t,onChange:r,helper:n="",info:i="",infoLink:a=""}){const[o,s]=W.useState(t.join(", "));W.useEffect(()=>{s(t.join(", "))},[t]);const l=()=>{const u=o.split(",").map(c=>parseInt(c.trim(),10)).filter(c=>!isNaN(c));r(u)};return x.jsxs("div",{className:"space-y-1",children:[x.jsxs("label",{className:"flex items-center text-xs text-slate-500 uppercase tracking-wide",children:[e,i&&x.jsx(Wo,{info:i,link:a})]}),x.jsx("input",{type:"text",value:o,onChange:u=>s(u.target.value),onBlur:l,placeholder:"0, 1, 2",className:"w-full px-3 py-2 bg-[#0a0e17] border border-[#1e2a3a] rounded text-sm text-slate-200 font-mono focus:outline-none focus:border-accent placeholder-slate-600"}),n&&x.jsx("p",{className:"text-xs text-slate-600",children:n})]})}function Cn({label:e,description:t,checked:r,onChange:n,threshold:i,onThresholdChange:a,thresholdLabel:o,thresholdMin:s,thresholdMax:l,thresholdStep:u=1,thresholdSuffix:c=""}){return x.jsxs("div",{className:"border border-[#1e2a3a] rounded-lg p-3 space-y-2",children:[x.jsxs("div",{className:"flex items-center justify-between",children:[x.jsxs("div",{className:"flex-1",children:[x.jsx("span",{className:"text-sm text-slate-300",children:e}),x.jsx("p",{className:"text-xs text-slate-600",children:t})]}),x.jsx("button",{type:"button",onClick:()=>n(!r),className:`relative w-11 h-6 rounded-full transition-colors flex-shrink-0 ml-3 ${r?"bg-accent":"bg-[#1e2a3a]"}`,children:x.jsx("span",{className:`absolute top-1 left-1 w-4 h-4 rounded-full bg-white transition-transform ${r?"translate-x-5":""}`})})]}),r&&i!==void 0&&a&&x.jsxs("div",{className:"flex items-center gap-2 pt-2 border-t border-[#1e2a3a]",children:[x.jsxs("span",{className:"text-xs text-slate-500",children:[o||"Threshold",":"]}),x.jsx("input",{type:"number",value:i,onChange:f=>a(Number(f.target.value)),min:s,max:l,step:u,className:"w-20 px-2 py-1 bg-[#0a0e17] border border-[#1e2a3a] rounded text-xs text-slate-200 font-mono"}),c&&x.jsx("span",{className:"text-xs text-slate-500",children:c})]})]})}function LJe({data:e,onChange:t}){return x.jsxs("div",{className:"space-y-4",children:[x.jsx(Qn,{text:Kn.bot}),x.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[x.jsx(At,{label:"Bot Name",value:e.name,onChange:r=>t({...e,name:r}),helper:"Name the bot responds to on the mesh",info:"When someone sends a message containing this name, the bot will respond. Also used as the sender name in broadcasts. Changing this requires a restart."}),x.jsx(At,{label:"Owner",value:e.owner,onChange:r=>t({...e,owner:r}),helper:"Your callsign or identifier",info:"Identifies the bot operator. Shown in !help responses and used for admin-level commands."})]}),x.jsx(Et,{label:"Respond to DMs",checked:e.respond_to_dms,onChange:r=>t({...e,respond_to_dms:r}),helper:"Reply when someone sends a direct message",info:"When enabled, the bot responds to direct messages from any node. When disabled, the bot only responds to channel messages that mention its name."}),x.jsx(Et,{label:"Filter BBS Protocols",checked:e.filter_bbs_protocols,onChange:r=>t({...e,filter_bbs_protocols:r}),helper:"Ignore BBS bulletin board traffic",info:"Filters out automated BBS protocol messages (advBBS, MAIL*, BOARD*) so the bot doesn't try to respond to machine-to-machine traffic."})]})}function kJe({data:e,onChange:t}){return x.jsxs("div",{className:"space-y-4",children:[x.jsx(Qn,{text:Kn.connection}),x.jsx(Co,{label:"Connection Type",value:e.type,onChange:r=>t({...e,type:r}),options:[{value:"serial",label:"Serial (USB)"},{value:"tcp",label:"TCP (Network)"}],helper:"Serial for USB-connected radios, TCP for network or meshtasticd",info:"Serial: direct USB connection to a Meshtastic radio. TCP: connect over the network to a radio's IP or to meshtasticd running on another machine."}),e.type==="serial"?x.jsx(At,{label:"Serial Port",value:e.serial_port,onChange:r=>t({...e,serial_port:r}),placeholder:"/dev/ttyUSB0",helper:"Device path for your USB radio",info:"Usually /dev/ttyUSB0 on Linux or /dev/ttyACM0. Check with 'ls /dev/tty*' after plugging in your radio."}):x.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[x.jsx(At,{label:"TCP Host",value:e.tcp_host,onChange:r=>t({...e,tcp_host:r}),placeholder:"192.168.1.100",helper:"IP address or hostname of the radio/meshtasticd"}),x.jsx(qe,{label:"TCP Port",value:e.tcp_port,onChange:r=>t({...e,tcp_port:r}),min:1,max:65535,helper:"Default 4403 for meshtasticd"})]})]})}function IJe({data:e,onChange:t}){return x.jsxs("div",{className:"space-y-4",children:[x.jsx(Qn,{text:Kn.response}),x.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[x.jsx(qe,{label:"Delay Min (sec)",value:e.delay_min,onChange:r=>t({...e,delay_min:r}),min:0,step:.1,helper:"Minimum wait before responding",info:"Adds a random delay between min and max before the bot sends a response. Prevents the bot from appearing to respond instantly, which can feel unnatural on a radio network."}),x.jsx(qe,{label:"Delay Max (sec)",value:e.delay_max,onChange:r=>t({...e,delay_max:r}),min:0,step:.1,helper:"Maximum wait before responding",info:"Also prevents collisions with other traffic by staggering transmissions."})]}),x.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[x.jsx(qe,{label:"Max Length",value:e.max_length,onChange:r=>t({...e,max_length:r}),min:50,max:500,helper:"Maximum characters per response message",info:"Meshtastic packets have limited size. This caps how long each message chunk can be. The bot will split longer responses into multiple messages up to Max Messages."}),x.jsx(qe,{label:"Max Messages",value:e.max_messages,onChange:r=>t({...e,max_messages:r}),min:1,max:10,helper:"Maximum chunks per response",info:"If a response is longer than Max Length, the bot splits it into this many chunks at most. Higher values = more complete answers but more airtime used."})]})]})}function OJe({data:e,onChange:t}){return x.jsxs("div",{className:"space-y-4",children:[x.jsx(Qn,{text:Kn.history}),x.jsx(At,{label:"Database Path",value:e.database,onChange:r=>t({...e,database:r}),helper:"SQLite file for storing conversation history",info:"Path to the SQLite database file. Created automatically if it doesn't exist. Stores all conversation history for context."}),x.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[x.jsx(qe,{label:"Max Messages Per User",value:e.max_messages_per_user,onChange:r=>t({...e,max_messages_per_user:r}),min:0,helper:"History limit per user (0 = unlimited)",info:"Limits how many messages are stored per user. Older messages are pruned when the limit is reached. Set to 0 for no limit."}),x.jsx(qe,{label:"Conversation Timeout (sec)",value:e.conversation_timeout,onChange:r=>t({...e,conversation_timeout:r}),min:0,helper:"Seconds before context resets",info:"If a user doesn't message for this long, their next message starts a new conversation context. The bot won't remember the previous topic."})]}),x.jsx(Et,{label:"Auto Cleanup",checked:e.auto_cleanup,onChange:r=>t({...e,auto_cleanup:r}),helper:"Automatically prune old conversations"}),e.auto_cleanup&&x.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[x.jsx(qe,{label:"Cleanup Interval (hours)",value:e.cleanup_interval_hours,onChange:r=>t({...e,cleanup_interval_hours:r}),min:1,helper:"Hours between cleanup runs"}),x.jsx(qe,{label:"Max Age (days)",value:e.max_age_days,onChange:r=>t({...e,max_age_days:r}),min:1,helper:"Delete conversations older than this"})]})]})}function EJe({data:e,onChange:t}){return x.jsxs("div",{className:"space-y-4",children:[x.jsx(Qn,{text:Kn.memory}),x.jsx(Et,{label:"Enable Memory",checked:e.enabled,onChange:r=>t({...e,enabled:r}),helper:"Keep conversation context between messages"}),e.enabled&&x.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[x.jsx(qe,{label:"Window Size",value:e.window_size,onChange:r=>t({...e,window_size:r}),min:1,helper:"Recent message pairs kept in full",info:"The bot keeps this many recent exchanges (user message + bot response pairs) as full text in context. Older messages are summarized to save token space."}),x.jsx(qe,{label:"Summarize Threshold",value:e.summarize_threshold,onChange:r=>t({...e,summarize_threshold:r}),min:1,helper:"Messages before older context is summarized",info:"When the conversation exceeds this many messages, older ones outside the window are compressed into a summary by the LLM."})]})]})}function DJe({data:e,onChange:t}){return x.jsxs("div",{className:"space-y-4",children:[x.jsx(Qn,{text:Kn.context}),x.jsx(Et,{label:"Enable Passive Context",checked:e.enabled,onChange:r=>t({...e,enabled:r}),helper:"Listen to channel traffic for context",info:"When enabled, the bot monitors mesh channels and includes recent messages in its context. This lets the bot reference things other people said on the channel."}),e.enabled&&x.jsxs(x.Fragment,{children:[x.jsx(RR,{label:"Observe Channels",value:e.observe_channels,onChange:r=>t({...e,observe_channels:r}),helper:"Channels to monitor (empty = all)",info:"Meshtastic channels to listen on. Leave empty to monitor all channels.",mode:"multi"}),x.jsx(jR,{label:"Ignore Nodes",value:e.ignore_nodes,onChange:r=>t({...e,ignore_nodes:r}),helper:"Nodes to exclude from context",info:"Messages from these nodes won't be included in passive context. Useful for filtering out noisy automated nodes."}),x.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[x.jsx(qe,{label:"Max Age (sec)",value:e.max_age,onChange:r=>t({...e,max_age:r}),min:0,helper:"Ignore messages older than this"}),x.jsx(qe,{label:"Max Context Items",value:e.max_context_items,onChange:r=>t({...e,max_context_items:r}),min:1,helper:"Maximum recent messages to include"})]})]})]})}function NJe({data:e,onChange:t}){const r=new Set(e.disabled_commands.map(i=>i.toLowerCase())),n=i=>{const a=i.toLowerCase();r.has(a)?t({...e,disabled_commands:e.disabled_commands.filter(o=>o.toLowerCase()!==a)}):t({...e,disabled_commands:[...e.disabled_commands,i]})};return x.jsxs("div",{className:"space-y-4",children:[x.jsx(Qn,{text:Kn.commands}),x.jsx(Et,{label:"Enable Commands",checked:e.enabled,onChange:i=>t({...e,enabled:i}),helper:"Allow !commands on the mesh"}),e.enabled&&x.jsxs(x.Fragment,{children:[x.jsx(At,{label:"Command Prefix",value:e.prefix,onChange:i=>t({...e,prefix:i}),helper:"Character that triggers commands (e.g. ! for !help)",info:"Users type this character followed by the command name. Only single characters recommended."}),x.jsxs("div",{className:"space-y-2",children:[x.jsxs("label",{className:"flex items-center text-xs text-slate-500 uppercase tracking-wide",children:["Available Commands",x.jsx(Wo,{info:"Toggle commands on or off. Disabled commands won't respond when users invoke them."})]}),x.jsx("div",{className:"grid gap-1",children:AJe.map(i=>{const a=!r.has(i.name.toLowerCase());return x.jsxs("div",{className:"flex items-center justify-between p-2 bg-[#0a0e17] border border-[#1e2a3a] rounded hover:border-[#2a3a4a] transition-colors",children:[x.jsxs("div",{className:"flex items-center gap-3",children:[x.jsxs("code",{className:"text-accent text-sm",children:["!",i.name]}),x.jsx("span",{className:"text-xs text-slate-500",children:i.description})]}),x.jsx("button",{type:"button",onClick:()=>n(i.name),className:`relative w-9 h-5 rounded-full transition-colors ${a?"bg-accent":"bg-[#1e2a3a]"}`,children:x.jsx("span",{className:`absolute top-0.5 left-0.5 w-4 h-4 rounded-full bg-white transition-transform ${a?"translate-x-4":""}`})})]},i.name)})})]})]})]})}function jJe({data:e,onChange:t}){return x.jsxs("div",{className:"space-y-4",children:[x.jsx(Qn,{text:Kn.llm}),x.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[x.jsx(Co,{label:"Backend",value:e.backend,onChange:r=>t({...e,backend:r}),options:[{value:"openai",label:"OpenAI"},{value:"anthropic",label:"Anthropic"},{value:"google",label:"Google (Gemini)"}],helper:"LLM provider to use",info:"OpenAI: GPT models (gpt-4o, gpt-4o-mini). Anthropic: Claude models (claude-sonnet-4-20250514). Google: Gemini models. Can also point to compatible APIs like Ollama, LM Studio, or Open WebUI by changing the Base URL."}),x.jsx(At,{label:"Model",value:e.model,onChange:r=>t({...e,model:r}),placeholder:"gpt-4o-mini",helper:"Specific model name",info:"The specific model to use. Common choices: gpt-4o-mini (fast, cheap), gpt-4o (better, costs more), claude-sonnet-4-20250514 (Anthropic equivalent). For local models via Ollama, use the model name you pulled (e.g. llama3.1)."})]}),x.jsx(At,{label:"API Key",value:e.api_key,onChange:r=>t({...e,api_key:r}),type:"password",helper:"Supports ${ENV_VAR} syntax",info:"Your API key from the provider. You can also use ${ENV_VAR} syntax to read from an environment variable instead of storing the key in the config file."}),x.jsx(At,{label:"Base URL",value:e.base_url,onChange:r=>t({...e,base_url:r}),placeholder:"https://api.openai.com/v1",helper:"API endpoint (change for local LLMs)",info:"Default API endpoint for the selected backend. Change this to point to a local LLM server (Ollama at http://localhost:11434/v1, Open WebUI, LM Studio, etc.) or a proxy."}),x.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[x.jsx(qe,{label:"Timeout (sec)",value:e.timeout,onChange:r=>t({...e,timeout:r}),min:5,max:120,helper:"Maximum seconds to wait for response"}),x.jsx(qe,{label:"Max Response Tokens",value:e.max_response_tokens,onChange:r=>t({...e,max_response_tokens:r}),min:100,helper:"Token limit for LLM responses"})]}),x.jsx(Et,{label:"Use System Prompt",checked:e.use_system_prompt,onChange:r=>t({...e,use_system_prompt:r}),helper:"Enable custom system instructions"}),e.use_system_prompt&&x.jsx(MJe,{label:"System Prompt",value:e.system_prompt,onChange:r=>t({...e,system_prompt:r}),rows:6,helper:"Instructions that shape the bot's personality",info:"Instructions that shape the bot's personality and behavior. The bot always follows these instructions. MeshAI adds mesh health data and environmental context automatically — you don't need to include those here."}),x.jsx(Et,{label:"Web Search",checked:e.web_search,onChange:r=>t({...e,web_search:r}),helper:"Enable web search tool (Open WebUI feature)"}),x.jsx(Et,{label:"Google Grounding",checked:e.google_grounding,onChange:r=>t({...e,google_grounding:r}),helper:"Ground responses in web search (Gemini only)"})]})}function RJe({data:e,onChange:t}){return x.jsxs("div",{className:"space-y-4",children:[x.jsx(Qn,{text:Kn.weather}),x.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[x.jsx(Co,{label:"Primary Provider",value:e.primary,onChange:r=>t({...e,primary:r}),options:[{value:"openmeteo",label:"Open-Meteo"},{value:"wttr",label:"wttr.in"},{value:"llm",label:"LLM"}],helper:"Main weather data source"}),x.jsx(Co,{label:"Fallback Provider",value:e.fallback,onChange:r=>t({...e,fallback:r}),options:[{value:"openmeteo",label:"Open-Meteo"},{value:"wttr",label:"wttr.in"},{value:"llm",label:"LLM"},{value:"none",label:"None"}],helper:"Backup if primary fails"})]}),x.jsx(At,{label:"Default Location",value:e.default_location,onChange:r=>t({...e,default_location:r}),placeholder:"Your city, state",helper:"Location when none specified"})]})}function BJe({data:e,onChange:t}){return x.jsxs("div",{className:"space-y-4",children:[x.jsx(Qn,{text:Kn.meshmonitor}),x.jsx(Et,{label:"Enable MeshMonitor",checked:e.enabled,onChange:r=>t({...e,enabled:r}),helper:"Connect to AIDA MeshMonitor instance",info:"MeshMonitor by Yeraze provides node data, battery info, telemetry, and auto-responder patterns. MeshAI uses this as a data source and avoids duplicate responses."}),e.enabled&&x.jsxs(x.Fragment,{children:[x.jsx(At,{label:"URL",value:e.url,onChange:r=>t({...e,url:r}),placeholder:"http://192.168.1.100:8080",helper:"MeshMonitor API endpoint",info:"Full URL to your MeshMonitor instance. Usually runs on port 8080."}),x.jsx(Et,{label:"Inject Into Prompt",checked:e.inject_into_prompt,onChange:r=>t({...e,inject_into_prompt:r}),helper:"Tell LLM about MeshMonitor commands",info:"Adds MeshMonitor's auto-responder patterns to the LLM context so it knows what commands MeshMonitor handles."}),x.jsx(qe,{label:"Refresh Interval (sec)",value:e.refresh_interval,onChange:r=>t({...e,refresh_interval:r}),min:10,helper:"How often to fetch patterns"}),x.jsx(Et,{label:"Polite Mode",checked:e.polite_mode,onChange:r=>t({...e,polite_mode:r}),helper:"Reduce polling frequency",info:"Reduces polling frequency for shared instances to be a good neighbor."})]})]})}function zJe({data:e,onChange:t}){return x.jsxs("div",{className:"space-y-4",children:[x.jsx(Qn,{text:Kn.knowledge}),x.jsx(Et,{label:"Enable Knowledge Base",checked:e.enabled,onChange:r=>t({...e,enabled:r}),helper:"Answer questions from stored documents",info:"Uses RAG (Retrieval-Augmented Generation) to answer questions from a knowledge base. Supports Qdrant vector database or local SQLite with FTS5."}),e.enabled&&x.jsxs(x.Fragment,{children:[x.jsx(Co,{label:"Backend",value:e.backend,onChange:r=>t({...e,backend:r}),options:[{value:"auto",label:"Auto (Qdrant -> SQLite)"},{value:"qdrant",label:"Qdrant"},{value:"sqlite",label:"SQLite"}],helper:"Knowledge storage backend",info:"Auto tries Qdrant first, falls back to SQLite. Qdrant provides hybrid search with dense+sparse embeddings. SQLite uses FTS5 keyword search."}),(e.backend==="qdrant"||e.backend==="auto")&&x.jsxs(x.Fragment,{children:[x.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[x.jsx(At,{label:"Qdrant Host",value:e.qdrant_host,onChange:r=>t({...e,qdrant_host:r}),helper:"Qdrant server hostname",info:"IP or hostname of your Qdrant vector database server."}),x.jsx(qe,{label:"Qdrant Port",value:e.qdrant_port,onChange:r=>t({...e,qdrant_port:r}),helper:"Default 6333"})]}),x.jsx(At,{label:"Collection",value:e.qdrant_collection,onChange:r=>t({...e,qdrant_collection:r}),helper:"Qdrant collection name"}),x.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[x.jsx(At,{label:"TEI Host",value:e.tei_host,onChange:r=>t({...e,tei_host:r}),helper:"Text Embeddings Inference host",info:"TEI service for generating dense embeddings. Uses BAAI/bge-m3 model."}),x.jsx(qe,{label:"TEI Port",value:e.tei_port,onChange:r=>t({...e,tei_port:r}),helper:"Default 8090"})]}),x.jsx(Et,{label:"Use Sparse Embeddings",checked:e.use_sparse,onChange:r=>t({...e,use_sparse:r}),helper:"Enable hybrid search with sparse vectors",info:"Combines dense embeddings with sparse (keyword-based) embeddings using Reciprocal Rank Fusion for better search results."})]}),x.jsx(At,{label:"SQLite DB Path",value:e.db_path,onChange:r=>t({...e,db_path:r}),helper:"Local knowledge database file"}),x.jsx(qe,{label:"Top K Results",value:e.top_k,onChange:r=>t({...e,top_k:r}),min:1,max:20,helper:"Number of documents to retrieve"})]})]})}function $Je({source:e,onChange:t,onDelete:r}){const[n,i]=W.useState(!1),a={meshview:"Web-based mesh monitoring tool. Enter the full URL of a MeshView instance. No API key typically required.",meshmonitor:"AIDA MeshMonitor API. Provides node data and network statistics. Requires API token.",mqtt:"Subscribe directly to a Meshtastic MQTT broker for real-time packet data. This is push-based (instant) vs the polling approach of MeshView/MeshMonitor."};return x.jsxs("div",{className:"border border-[#1e2a3a] rounded-lg overflow-hidden",children:[x.jsxs("div",{className:"flex items-center justify-between p-3 bg-[#0a0e17] cursor-pointer",onClick:()=>i(!n),children:[x.jsxs("div",{className:"flex items-center gap-3",children:[n?x.jsx(Hy,{size:16}):x.jsx(bm,{size:16}),x.jsx("div",{className:`w-2 h-2 rounded-full ${e.enabled?"bg-green-500":"bg-slate-500"}`}),x.jsx("span",{className:"font-mono text-sm text-slate-200",children:e.name||"Unnamed Source"}),x.jsx("span",{className:"text-xs text-slate-500 bg-[#1e2a3a] px-2 py-0.5 rounded",children:e.type})]}),x.jsx("button",{onClick:o=>{o.stopPropagation(),r()},className:"p-1 text-red-400 hover:text-red-300 hover:bg-red-500/10 rounded",children:x.jsx(UE,{size:14})})]}),n&&x.jsxs("div",{className:"p-4 space-y-4 border-t border-[#1e2a3a]",children:[x.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[x.jsx(At,{label:"Name",value:e.name,onChange:o=>t({...e,name:o}),helper:"Friendly name for this source"}),x.jsx(Co,{label:"Type",value:e.type,onChange:o=>t({...e,type:o}),options:[{value:"meshview",label:"MeshView"},{value:"meshmonitor",label:"MeshMonitor"},{value:"mqtt",label:"MQTT Broker"}],info:a[e.type]||""})]}),e.type!=="mqtt"&&x.jsx(At,{label:"URL",value:e.url,onChange:o=>t({...e,url:o}),helper:"Full URL including protocol"}),e.type==="meshmonitor"&&x.jsx(At,{label:"API Token",value:e.api_token,onChange:o=>t({...e,api_token:o}),type:"password",helper:"Bearer token for authentication"}),e.type==="mqtt"&&x.jsxs(x.Fragment,{children:[x.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[x.jsx(At,{label:"Host",value:e.host||"",onChange:o=>t({...e,host:o}),helper:"MQTT broker hostname"}),x.jsx(qe,{label:"Port",value:e.port||1883,onChange:o=>t({...e,port:o}),min:1,max:65535,helper:"1883 plain, 8883 TLS"})]}),x.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[x.jsx(At,{label:"Username",value:e.username||"",onChange:o=>t({...e,username:o})}),x.jsx(At,{label:"Password",value:e.password||"",onChange:o=>t({...e,password:o}),type:"password"})]}),x.jsx(At,{label:"Topic Root",value:e.topic_root||"msh/US",onChange:o=>t({...e,topic_root:o}),helper:"Base topic to subscribe to"}),x.jsx(Et,{label:"Use TLS",checked:e.use_tls||!1,onChange:o=>t({...e,use_tls:o}),helper:"Encrypt MQTT connection"})]}),x.jsx(qe,{label:"Refresh Interval (sec)",value:e.refresh_interval,onChange:o=>t({...e,refresh_interval:o}),min:10,helper:"Polling frequency"}),x.jsx(Et,{label:"Enabled",checked:e.enabled,onChange:o=>t({...e,enabled:o})}),x.jsx(Et,{label:"Polite Mode",checked:e.polite_mode,onChange:o=>t({...e,polite_mode:o}),helper:"Reduce polling for shared instances"})]})]})}function FJe({data:e,onChange:t}){const r=()=>{t([...e,{name:"New Source",type:"meshview",url:"",api_token:"",refresh_interval:30,polite_mode:!1,enabled:!0,host:"",port:1883,username:"",password:"",topic_root:"msh/US",use_tls:!1}])};return x.jsxs("div",{className:"space-y-4",children:[x.jsx(Qn,{text:Kn.mesh_sources}),e.map((n,i)=>x.jsx($Je,{source:n,onChange:a=>{const o=[...e];o[i]=a,t(o)},onDelete:()=>{confirm(`Delete source "${n.name}"?`)&&t(e.filter((a,o)=>o!==i))}},i)),x.jsxs("button",{onClick:r,className:"w-full py-2 border border-dashed border-[#1e2a3a] rounded-lg text-slate-500 hover:text-slate-300 hover:border-accent flex items-center justify-center gap-2 transition-colors",children:[x.jsx(bS,{size:16})," Add Source"]})]})}function VJe({data:e,onChange:t}){const[r,n]=W.useState(null);return x.jsxs("div",{className:"space-y-6",children:[x.jsx(Qn,{text:Kn.mesh_intelligence}),x.jsx(Et,{label:"Enable Mesh Intelligence",checked:e.enabled,onChange:i=>t({...e,enabled:i}),helper:"Activate health scoring and alerting"}),e.enabled&&x.jsxs(x.Fragment,{children:[x.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[x.jsx(qe,{label:"Locality Radius (miles)",value:e.locality_radius_miles,onChange:i=>t({...e,locality_radius_miles:i}),min:1,step:.5,helper:"Region assignment radius",info:"Nodes within this distance of a region anchor point are assigned to that region."}),x.jsx(qe,{label:"Offline Threshold (hours)",value:e.offline_threshold_hours,onChange:i=>t({...e,offline_threshold_hours:i}),min:1,helper:"Time until node marked offline",info:"A node is considered offline after not being heard for this many hours."})]}),x.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[x.jsx(qe,{label:"Packet Threshold",value:e.packet_threshold,onChange:i=>t({...e,packet_threshold:i}),min:0,helper:"Min packets per 24h to flag",info:"Minimum packets per 24 hours. Nodes below this are flagged as low activity."}),x.jsx(qe,{label:"Battery Warning %",value:e.battery_warning_percent,onChange:i=>t({...e,battery_warning_percent:i}),min:1,max:100,helper:"Global battery warning level"})]}),x.jsx(jR,{label:"Critical Nodes",value:e.critical_nodes,onChange:i=>t({...e,critical_nodes:i}),helper:"Critical infrastructure nodes",info:"Nodes that get priority alerting when they go offline.",roleFilter:"infrastructure"}),x.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[x.jsx(RR,{label:"Alert Channel",value:e.alert_channel,onChange:i=>t({...e,alert_channel:i}),helper:"Channel for broadcast alerts",info:"Meshtastic channel for broadcast alerts. Select Disabled to turn off channel broadcasting.",mode:"single",includeDisabled:!0}),x.jsx(qe,{label:"Alert Cooldown (min)",value:e.alert_cooldown_minutes,onChange:i=>t({...e,alert_cooldown_minutes:i}),min:1,helper:"Min time between repeat alerts",info:"Minimum minutes between repeated alerts for the same condition. Uses scaling cooldown (12h, 24h, 48h)."})]}),x.jsxs("div",{className:"space-y-2",children:[x.jsxs("label",{className:"flex items-center text-xs text-slate-500 uppercase tracking-wide",children:["Regions",x.jsx(Wo,{info:"Regions group mesh nodes by geographic area. Each region has an anchor point (lat/lon) and nodes within the region radius are automatically assigned. Regions enable localized reports, alerts, and health scoring."})]}),e.regions.map((i,a)=>x.jsxs("div",{className:"border border-[#1e2a3a] rounded-lg overflow-hidden",children:[x.jsxs("div",{className:"flex items-center justify-between p-3 bg-[#0a0e17] cursor-pointer",onClick:()=>n(r===a?null:a),children:[x.jsxs("div",{className:"flex items-center gap-3",children:[r===a?x.jsx(Hy,{size:16}):x.jsx(bm,{size:16}),x.jsx("span",{className:"font-medium text-slate-200",children:i.name||"Unnamed Region"}),x.jsx("span",{className:"text-xs text-slate-500",children:i.local_name})]}),x.jsx("button",{onClick:o=>{if(o.stopPropagation(),confirm(`Delete region "${i.name||"Unnamed Region"}"?`)){const s=e.regions.filter((l,u)=>u!==a);t({...e,regions:s})}},className:"p-1 text-red-400 hover:text-red-300 hover:bg-red-500/10 rounded",children:x.jsx(UE,{size:14})})]}),r===a&&x.jsxs("div",{className:"p-4 space-y-3 border-t border-[#1e2a3a]",children:[x.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[x.jsx(At,{label:"Name",value:i.name,onChange:o=>{const s=[...e.regions];s[a]={...i,name:o},t({...e,regions:s})}}),x.jsx(At,{label:"Local Name",value:i.local_name,onChange:o=>{const s=[...e.regions];s[a]={...i,local_name:o},t({...e,regions:s})}})]}),x.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[x.jsx(qe,{label:"Latitude",value:i.lat,onChange:o=>{const s=[...e.regions];s[a]={...i,lat:o},t({...e,regions:s})},step:1e-4}),x.jsx(qe,{label:"Longitude",value:i.lon,onChange:o=>{const s=[...e.regions];s[a]={...i,lon:o},t({...e,regions:s})},step:1e-4})]}),x.jsx(At,{label:"Description",value:i.description,onChange:o=>{const s=[...e.regions];s[a]={...i,description:o},t({...e,regions:s})}}),x.jsx(Hh,{label:"Aliases",value:i.aliases,onChange:o=>{const s=[...e.regions];s[a]={...i,aliases:o},t({...e,regions:s})}}),x.jsx(Hh,{label:"Cities",value:i.cities,onChange:o=>{const s=[...e.regions];s[a]={...i,cities:o},t({...e,regions:s})}})]})]},a)),x.jsxs("button",{onClick:()=>{const i={name:"",local_name:"",lat:0,lon:0,description:"",aliases:[],cities:[]};t({...e,regions:[...e.regions,i]}),n(e.regions.length)},className:"w-full py-2 border border-dashed border-[#1e2a3a] rounded-lg text-slate-500 hover:text-slate-300 hover:border-accent flex items-center justify-center gap-2 transition-colors",children:[x.jsx(bS,{size:16})," Add Region"]})]}),x.jsxs("div",{className:"space-y-3",children:[x.jsxs("label",{className:"flex items-center text-xs text-slate-500 uppercase tracking-wide",children:["Alert Rules",x.jsx(Wo,{info:"Configure which conditions trigger alerts. Each rule can have an optional threshold value."})]}),x.jsxs("div",{className:"space-y-2",children:[x.jsx("h4",{className:"text-xs text-slate-400 font-medium",children:"Infrastructure"}),x.jsx(Cn,{label:"Infra Offline",description:"Alert when an infrastructure node (router/repeater) goes offline",checked:e.alert_rules.infra_offline,onChange:i=>t({...e,alert_rules:{...e.alert_rules,infra_offline:i}})}),x.jsx(Cn,{label:"Infra Recovery",description:"Alert when an offline infrastructure node comes back online",checked:e.alert_rules.infra_recovery,onChange:i=>t({...e,alert_rules:{...e.alert_rules,infra_recovery:i}})}),x.jsx(Cn,{label:"New Router",description:"Alert when a new router/repeater appears on the mesh",checked:e.alert_rules.new_router,onChange:i=>t({...e,alert_rules:{...e.alert_rules,new_router:i}})}),x.jsx(Cn,{label:"Feeder Offline",description:"Alert when a data source (MeshView/MeshMonitor) stops responding",checked:e.alert_rules.feeder_offline,onChange:i=>t({...e,alert_rules:{...e.alert_rules,feeder_offline:i}})}),x.jsx(Cn,{label:"Single Gateway",description:"Alert when an infrastructure node has only one connection path",checked:e.alert_rules.infra_single_gateway,onChange:i=>t({...e,alert_rules:{...e.alert_rules,infra_single_gateway:i}})}),x.jsx(Cn,{label:"Region Blackout",description:"Alert when all infrastructure in a region goes offline",checked:e.alert_rules.region_total_blackout,onChange:i=>t({...e,alert_rules:{...e.alert_rules,region_total_blackout:i}})})]}),x.jsxs("div",{className:"space-y-2",children:[x.jsx("h4",{className:"text-xs text-slate-400 font-medium",children:"Power"}),x.jsx(Cn,{label:"Battery Warning",description:"Alert when infra node battery drops below warning threshold",checked:e.alert_rules.battery_warning,onChange:i=>t({...e,alert_rules:{...e.alert_rules,battery_warning:i}}),threshold:e.alert_rules.battery_warning_threshold,onThresholdChange:i=>t({...e,alert_rules:{...e.alert_rules,battery_warning_threshold:i}}),thresholdLabel:"Below",thresholdMin:10,thresholdMax:90,thresholdSuffix:"%"}),x.jsx(Cn,{label:"Battery Critical",description:"Alert at critical battery level",checked:e.alert_rules.battery_critical,onChange:i=>t({...e,alert_rules:{...e.alert_rules,battery_critical:i}}),threshold:e.alert_rules.battery_critical_threshold,onThresholdChange:i=>t({...e,alert_rules:{...e.alert_rules,battery_critical_threshold:i}}),thresholdLabel:"Below",thresholdMin:5,thresholdMax:50,thresholdSuffix:"%"}),x.jsx(Cn,{label:"Battery Emergency",description:"Alert at emergency battery level",checked:e.alert_rules.battery_emergency,onChange:i=>t({...e,alert_rules:{...e.alert_rules,battery_emergency:i}}),threshold:e.alert_rules.battery_emergency_threshold,onThresholdChange:i=>t({...e,alert_rules:{...e.alert_rules,battery_emergency_threshold:i}}),thresholdLabel:"Below",thresholdMin:1,thresholdMax:25,thresholdSuffix:"%"}),x.jsx(Cn,{label:"Battery Trend Declining",description:"Alert when battery shows a declining trend over 7 days",checked:e.alert_rules.battery_trend_declining,onChange:i=>t({...e,alert_rules:{...e.alert_rules,battery_trend_declining:i}})}),x.jsx(Cn,{label:"Power Source Change",description:"Alert when a node switches between battery and USB power",checked:e.alert_rules.power_source_change,onChange:i=>t({...e,alert_rules:{...e.alert_rules,power_source_change:i}})}),x.jsx(Cn,{label:"Solar Not Charging",description:"Alert when a solar-powered node isn't charging during daylight",checked:e.alert_rules.solar_not_charging,onChange:i=>t({...e,alert_rules:{...e.alert_rules,solar_not_charging:i}})})]}),x.jsxs("div",{className:"space-y-2",children:[x.jsx("h4",{className:"text-xs text-slate-400 font-medium",children:"Utilization"}),x.jsx(Cn,{label:"High Utilization",description:"Alert when channel utilization stays high for extended periods",checked:e.alert_rules.sustained_high_util,onChange:i=>t({...e,alert_rules:{...e.alert_rules,sustained_high_util:i}}),threshold:e.alert_rules.high_util_threshold,onThresholdChange:i=>t({...e,alert_rules:{...e.alert_rules,high_util_threshold:i}}),thresholdLabel:"Above",thresholdMin:5,thresholdMax:50,thresholdSuffix:`% for ${e.alert_rules.high_util_hours}h`}),x.jsx(Cn,{label:"Packet Flood",description:"Alert when a single node sends excessive packets",checked:e.alert_rules.packet_flood,onChange:i=>t({...e,alert_rules:{...e.alert_rules,packet_flood:i}}),threshold:e.alert_rules.packet_flood_threshold,onThresholdChange:i=>t({...e,alert_rules:{...e.alert_rules,packet_flood_threshold:i}}),thresholdLabel:"Over",thresholdMin:100,thresholdMax:2e3,thresholdSuffix:"pkts/24h"})]}),x.jsxs("div",{className:"space-y-2",children:[x.jsx("h4",{className:"text-xs text-slate-400 font-medium",children:"Health Scores"}),x.jsx(Cn,{label:"Mesh Score Alert",description:"Alert when overall mesh health score drops below threshold",checked:e.alert_rules.mesh_score_alert,onChange:i=>t({...e,alert_rules:{...e.alert_rules,mesh_score_alert:i}}),threshold:e.alert_rules.mesh_score_threshold,onThresholdChange:i=>t({...e,alert_rules:{...e.alert_rules,mesh_score_threshold:i}}),thresholdLabel:"Below",thresholdMin:30,thresholdMax:90,thresholdSuffix:"/100"}),x.jsx(Cn,{label:"Region Score Alert",description:"Alert when a region's health score drops below threshold",checked:e.alert_rules.region_score_alert,onChange:i=>t({...e,alert_rules:{...e.alert_rules,region_score_alert:i}}),threshold:e.alert_rules.region_score_threshold,onThresholdChange:i=>t({...e,alert_rules:{...e.alert_rules,region_score_threshold:i}}),thresholdLabel:"Below",thresholdMin:30,thresholdMax:90,thresholdSuffix:"/100"})]})]})]})]})}function GJe({data:e,onChange:t}){var r,n,i,a,o,s,l,u,c,f,h,d,v,g,m,y;return x.jsxs("div",{className:"space-y-6",children:[x.jsx(Qn,{text:Kn.environmental}),x.jsx(Et,{label:"Enable Environmental Feeds",checked:e.enabled,onChange:_=>t({...e,enabled:_}),helper:"Activate live data polling"}),e.enabled&&x.jsxs(x.Fragment,{children:[x.jsx(Hh,{label:"NWS Zones",value:e.nws_zones,onChange:_=>t({...e,nws_zones:_}),helper:"Zone IDs like IDZ016, IDZ030",info:"NWS forecast zones covering your mesh area. Find yours at https://www.weather.gov/pimar/PubZone",infoLink:"https://www.weather.gov/pimar/PubZone"}),x.jsxs("div",{className:"border border-[#1e2a3a] rounded-lg p-4 space-y-3",children:[x.jsxs("div",{className:"flex items-center justify-between",children:[x.jsx("span",{className:"text-sm font-medium text-slate-300",children:"NWS Weather Alerts"}),x.jsx(Et,{label:"",checked:e.nws.enabled,onChange:_=>t({...e,nws:{...e.nws,enabled:_}})})]}),e.nws.enabled&&x.jsxs(x.Fragment,{children:[x.jsx(At,{label:"User Agent",value:e.nws.user_agent,onChange:_=>t({...e,nws:{...e.nws,user_agent:_}}),placeholder:"(MeshAI, your@email.com)",helper:"Required format: (app_name, contact_email)",info:"Required by NWS. You make it up - just use the format (app_name, your_email). No signup needed."}),x.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[x.jsx(qe,{label:"Tick Seconds",value:e.nws.tick_seconds,onChange:_=>t({...e,nws:{...e.nws,tick_seconds:_}}),min:30,helper:"Polling interval"}),x.jsx(Co,{label:"Min Severity",value:e.nws.severity_min,onChange:_=>t({...e,nws:{...e.nws,severity_min:_}}),options:[{value:"minor",label:"Minor"},{value:"moderate",label:"Moderate"},{value:"severe",label:"Severe"},{value:"extreme",label:"Extreme"}],helper:"Filter out lower severity alerts",info:"Minimum severity level to display. 'Moderate' filters out minor advisories. 'Severe' shows only serious warnings."})]})]})]}),x.jsx("div",{className:"border border-[#1e2a3a] rounded-lg p-4",children:x.jsxs("div",{className:"flex items-center justify-between",children:[x.jsxs("div",{children:[x.jsx("span",{className:"text-sm font-medium text-slate-300",children:"NOAA Space Weather (SWPC)"}),x.jsx("p",{className:"text-xs text-slate-600",children:"Solar indices, geomagnetic storms, HF propagation"})]}),x.jsx(Et,{label:"",checked:e.swpc.enabled,onChange:_=>t({...e,swpc:{...e.swpc,enabled:_}})})]})}),x.jsxs("div",{className:"border border-[#1e2a3a] rounded-lg p-4 space-y-3",children:[x.jsxs("div",{className:"flex items-center justify-between",children:[x.jsxs("div",{children:[x.jsx("span",{className:"text-sm font-medium text-slate-300",children:"Tropospheric Ducting"}),x.jsx("p",{className:"text-xs text-slate-600",children:"VHF/UHF extended range conditions"})]}),x.jsx(Et,{label:"",checked:e.ducting.enabled,onChange:_=>t({...e,ducting:{...e.ducting,enabled:_}})})]}),e.ducting.enabled&&x.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[x.jsx(qe,{label:"Tick Seconds",value:e.ducting.tick_seconds,onChange:_=>t({...e,ducting:{...e.ducting,tick_seconds:_}}),min:60}),x.jsx(qe,{label:"Latitude",value:e.ducting.latitude,onChange:_=>t({...e,ducting:{...e.ducting,latitude:_}}),step:.01,info:"Center point of your mesh coverage area. The ducting adapter checks atmospheric conditions at this location."}),x.jsx(qe,{label:"Longitude",value:e.ducting.longitude,onChange:_=>t({...e,ducting:{...e.ducting,longitude:_}}),step:.01})]})]}),x.jsxs("div",{className:"border border-[#1e2a3a] rounded-lg p-4 space-y-3",children:[x.jsxs("div",{className:"flex items-center justify-between",children:[x.jsxs("div",{children:[x.jsx("span",{className:"text-sm font-medium text-slate-300",children:"NIFC Fire Perimeters"}),x.jsx("p",{className:"text-xs text-slate-600",children:"Active wildfires from National Interagency Fire Center"})]}),x.jsx(Et,{label:"",checked:e.fires.enabled,onChange:_=>t({...e,fires:{...e.fires,enabled:_}})})]}),e.fires.enabled&&x.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[x.jsx(qe,{label:"Tick Seconds",value:e.fires.tick_seconds,onChange:_=>t({...e,fires:{...e.fires,tick_seconds:_}}),min:60}),x.jsx(Co,{label:"State",value:e.fires.state,onChange:_=>t({...e,fires:{...e.fires,state:_}}),options:CJe,helper:"Filter fires by state",info:"Two-letter state code for NIFC wildfire filtering."})]})]}),x.jsxs("div",{className:"border border-[#1e2a3a] rounded-lg p-4 space-y-3",children:[x.jsxs("div",{className:"flex items-center justify-between",children:[x.jsxs("div",{children:[x.jsx("span",{className:"text-sm font-medium text-slate-300",children:"Avalanche Advisories"}),x.jsx("p",{className:"text-xs text-slate-600",children:"Backcountry avalanche danger ratings"})]}),x.jsx(Et,{label:"",checked:e.avalanche.enabled,onChange:_=>t({...e,avalanche:{...e.avalanche,enabled:_}})})]}),e.avalanche.enabled&&x.jsxs(x.Fragment,{children:[x.jsx(qe,{label:"Tick Seconds",value:e.avalanche.tick_seconds,onChange:_=>t({...e,avalanche:{...e.avalanche,tick_seconds:_}}),min:60}),x.jsx(Hh,{label:"Center IDs",value:e.avalanche.center_ids,onChange:_=>t({...e,avalanche:{...e.avalanche,center_ids:_}}),helper:"e.g., SNFAC, IPAC, FAC",info:"Find your local center at https://avalanche.org/avalanche-centers/",infoLink:"https://avalanche.org/avalanche-centers/"}),x.jsx(PJe,{label:"Season Months",value:e.avalanche.season_months,onChange:_=>t({...e,avalanche:{...e.avalanche,season_months:_}}),helper:"e.g., 12, 1, 2, 3, 4",info:"Months when avalanche forecasts are active. Default Dec-Apr. Adjust for your region's season."})]})]}),x.jsxs("div",{className:"border border-[#1e2a3a] rounded-lg p-4 space-y-3",children:[x.jsxs("div",{className:"flex items-center justify-between",children:[x.jsxs("div",{children:[x.jsx("span",{className:"text-sm font-medium text-slate-300",children:"USGS Stream Gauges"}),x.jsx("p",{className:"text-xs text-slate-600",children:"River and stream water levels"})]}),x.jsx(Et,{label:"",checked:((r=e.usgs)==null?void 0:r.enabled)||!1,onChange:_=>{var b,S;return t({...e,usgs:{...e.usgs,enabled:_,tick_seconds:((b=e.usgs)==null?void 0:b.tick_seconds)||900,sites:((S=e.usgs)==null?void 0:S.sites)||[]}})}})]}),((n=e.usgs)==null?void 0:n.enabled)&&x.jsxs(x.Fragment,{children:[x.jsx(qe,{label:"Tick Seconds",value:e.usgs.tick_seconds,onChange:_=>t({...e,usgs:{...e.usgs,tick_seconds:_}}),min:900,helper:"Minimum 15 min (900s)"}),x.jsx(Hh,{label:"Site IDs",value:e.usgs.sites,onChange:_=>t({...e,usgs:{...e.usgs,sites:_}}),helper:"USGS gauge site numbers",info:"Find site IDs at waterdata.usgs.gov/nwis",infoLink:"https://waterdata.usgs.gov/nwis"})]})]}),x.jsxs("div",{className:"border border-[#1e2a3a] rounded-lg p-4 space-y-3",children:[x.jsxs("div",{className:"flex items-center justify-between",children:[x.jsxs("div",{children:[x.jsx("span",{className:"text-sm font-medium text-slate-300",children:"TomTom Traffic"}),x.jsx("p",{className:"text-xs text-slate-600",children:"Traffic flow on monitored corridors"})]}),x.jsx(Et,{label:"",checked:((i=e.traffic)==null?void 0:i.enabled)||!1,onChange:_=>{var b,S,T;return t({...e,traffic:{...e.traffic,enabled:_,tick_seconds:((b=e.traffic)==null?void 0:b.tick_seconds)||300,api_key:((S=e.traffic)==null?void 0:S.api_key)||"",corridors:((T=e.traffic)==null?void 0:T.corridors)||[]}})}})]}),((a=e.traffic)==null?void 0:a.enabled)&&x.jsxs(x.Fragment,{children:[x.jsx(At,{label:"API Key",value:e.traffic.api_key,onChange:_=>t({...e,traffic:{...e.traffic,api_key:_}}),type:"password",helper:"Get key at developer.tomtom.com",infoLink:"https://developer.tomtom.com"}),x.jsx(qe,{label:"Tick Seconds",value:e.traffic.tick_seconds,onChange:_=>t({...e,traffic:{...e.traffic,tick_seconds:_}}),min:60}),x.jsx("div",{className:"text-xs text-slate-500 mt-2",children:"Corridors (each with name, lat, lon):"}),(e.traffic.corridors||[]).map((_,b)=>x.jsxs("div",{className:"grid grid-cols-4 gap-2 items-end",children:[x.jsx(At,{label:"Name",value:_.name,onChange:S=>{const T=[...e.traffic.corridors];T[b]={..._,name:S},t({...e,traffic:{...e.traffic,corridors:T}})}}),x.jsx(qe,{label:"Lat",value:_.lat,onChange:S=>{const T=[...e.traffic.corridors];T[b]={..._,lat:S},t({...e,traffic:{...e.traffic,corridors:T}})},step:.01}),x.jsx(qe,{label:"Lon",value:_.lon,onChange:S=>{const T=[...e.traffic.corridors];T[b]={..._,lon:S},t({...e,traffic:{...e.traffic,corridors:T}})},step:.01}),x.jsx("button",{onClick:()=>t({...e,traffic:{...e.traffic,corridors:e.traffic.corridors.filter((S,T)=>T!==b)}}),className:"px-2 py-2 text-xs text-red-400 hover:text-red-300 border border-red-400/30 rounded",children:"Remove"})]},b)),x.jsx("button",{onClick:()=>t({...e,traffic:{...e.traffic,corridors:[...e.traffic.corridors||[],{name:"",lat:0,lon:0}]}}),className:"text-xs text-accent hover:underline",children:"+ Add Corridor"})]})]}),x.jsxs("div",{className:"border border-[#1e2a3a] rounded-lg p-4 space-y-3",children:[x.jsxs("div",{className:"flex items-center justify-between",children:[x.jsxs("div",{children:[x.jsx("span",{className:"text-sm font-medium text-slate-300",children:"511 Road Conditions"}),x.jsx("p",{className:"text-xs text-slate-600",children:"State DOT road events and closures"})]}),x.jsx(Et,{label:"",checked:((o=e.roads511)==null?void 0:o.enabled)||!1,onChange:_=>{var b,S,T,A,M;return t({...e,roads511:{...e.roads511,enabled:_,tick_seconds:((b=e.roads511)==null?void 0:b.tick_seconds)||300,api_key:((S=e.roads511)==null?void 0:S.api_key)||"",base_url:((T=e.roads511)==null?void 0:T.base_url)||"",endpoints:((A=e.roads511)==null?void 0:A.endpoints)||["/get/event"],bbox:((M=e.roads511)==null?void 0:M.bbox)||[]}})}})]}),((s=e.roads511)==null?void 0:s.enabled)&&x.jsxs(x.Fragment,{children:[x.jsx(At,{label:"Base URL",value:e.roads511.base_url,onChange:_=>t({...e,roads511:{...e.roads511,base_url:_}}),placeholder:"https://511.yourstate.gov/api/v2",helper:"State 511 API endpoint"}),x.jsx(At,{label:"API Key",value:e.roads511.api_key,onChange:_=>t({...e,roads511:{...e.roads511,api_key:_}}),type:"password",helper:"Leave empty if not required"}),x.jsx(qe,{label:"Tick Seconds",value:e.roads511.tick_seconds,onChange:_=>t({...e,roads511:{...e.roads511,tick_seconds:_}}),min:60}),x.jsx(Hh,{label:"Endpoints",value:e.roads511.endpoints,onChange:_=>t({...e,roads511:{...e.roads511,endpoints:_}}),helper:"e.g., /get/event, /get/mountainpasses"}),x.jsxs("div",{className:"grid grid-cols-4 gap-2",children:[x.jsx(qe,{label:"West",value:((l=e.roads511.bbox)==null?void 0:l[0])||0,onChange:_=>{const b=[...e.roads511.bbox||[0,0,0,0]];b[0]=_,t({...e,roads511:{...e.roads511,bbox:b}})},step:.01}),x.jsx(qe,{label:"South",value:((u=e.roads511.bbox)==null?void 0:u[1])||0,onChange:_=>{const b=[...e.roads511.bbox||[0,0,0,0]];b[1]=_,t({...e,roads511:{...e.roads511,bbox:b}})},step:.01}),x.jsx(qe,{label:"East",value:((c=e.roads511.bbox)==null?void 0:c[2])||0,onChange:_=>{const b=[...e.roads511.bbox||[0,0,0,0]];b[2]=_,t({...e,roads511:{...e.roads511,bbox:b}})},step:.01}),x.jsx(qe,{label:"North",value:((f=e.roads511.bbox)==null?void 0:f[3])||0,onChange:_=>{const b=[...e.roads511.bbox||[0,0,0,0]];b[3]=_,t({...e,roads511:{...e.roads511,bbox:b}})},step:.01})]}),x.jsx("div",{className:"text-xs text-slate-500",children:"Bounding box filter (leave all 0 to disable)"})]})]}),x.jsxs("div",{className:"border border-[#1e2a3a] rounded-lg p-4 space-y-3",children:[x.jsxs("div",{className:"flex items-center justify-between",children:[x.jsxs("div",{children:[x.jsx("span",{className:"text-sm font-medium text-slate-300",children:"NASA FIRMS Satellite Fire Detection"}),x.jsx("p",{className:"text-xs text-slate-600",children:"Near real-time thermal anomalies from satellites"})]}),x.jsx(Et,{label:"",checked:((h=e.firms)==null?void 0:h.enabled)||!1,onChange:_=>{var b,S,T,A,M,P,k;return t({...e,firms:{...e.firms,enabled:_,tick_seconds:((b=e.firms)==null?void 0:b.tick_seconds)||1800,map_key:((S=e.firms)==null?void 0:S.map_key)||"",source:((T=e.firms)==null?void 0:T.source)||"VIIRS_SNPP_NRT",bbox:((A=e.firms)==null?void 0:A.bbox)||[],day_range:((M=e.firms)==null?void 0:M.day_range)||1,confidence_min:((P=e.firms)==null?void 0:P.confidence_min)||"nominal",proximity_km:((k=e.firms)==null?void 0:k.proximity_km)||10}})}})]}),((d=e.firms)==null?void 0:d.enabled)&&x.jsxs(x.Fragment,{children:[x.jsx(At,{label:"MAP Key",value:e.firms.map_key,onChange:_=>t({...e,firms:{...e.firms,map_key:_}}),type:"password",helper:"Get key at firms.modaps.eosdis.nasa.gov/api/area/",infoLink:"https://firms.modaps.eosdis.nasa.gov/api/area/"}),x.jsx(qe,{label:"Tick Seconds",value:e.firms.tick_seconds,onChange:_=>t({...e,firms:{...e.firms,tick_seconds:_}}),min:300,helper:"Minimum 5 min (300s)"}),x.jsx(Co,{label:"Satellite Source",value:e.firms.source,onChange:_=>t({...e,firms:{...e.firms,source:_}}),options:[{value:"VIIRS_SNPP_NRT",label:"VIIRS SNPP (Near Real-Time)"},{value:"VIIRS_NOAA20_NRT",label:"VIIRS NOAA-20 (Near Real-Time)"},{value:"MODIS_NRT",label:"MODIS (Near Real-Time)"}]}),x.jsx(qe,{label:"Day Range",value:e.firms.day_range,onChange:_=>t({...e,firms:{...e.firms,day_range:_}}),min:1,max:10,helper:"1-10 days of data"}),x.jsx(Co,{label:"Minimum Confidence",value:e.firms.confidence_min,onChange:_=>t({...e,firms:{...e.firms,confidence_min:_}}),options:[{value:"low",label:"Low"},{value:"nominal",label:"Nominal"},{value:"high",label:"High"}]}),x.jsx(qe,{label:"Proximity (km)",value:e.firms.proximity_km,onChange:_=>t({...e,firms:{...e.firms,proximity_km:_}}),step:.5,helper:"Distance to match known fires"}),x.jsxs("div",{className:"grid grid-cols-4 gap-2",children:[x.jsx(qe,{label:"West",value:((v=e.firms.bbox)==null?void 0:v[0])||0,onChange:_=>{const b=[...e.firms.bbox||[0,0,0,0]];b[0]=_,t({...e,firms:{...e.firms,bbox:b}})},step:.01}),x.jsx(qe,{label:"South",value:((g=e.firms.bbox)==null?void 0:g[1])||0,onChange:_=>{const b=[...e.firms.bbox||[0,0,0,0]];b[1]=_,t({...e,firms:{...e.firms,bbox:b}})},step:.01}),x.jsx(qe,{label:"East",value:((m=e.firms.bbox)==null?void 0:m[2])||0,onChange:_=>{const b=[...e.firms.bbox||[0,0,0,0]];b[2]=_,t({...e,firms:{...e.firms,bbox:b}})},step:.01}),x.jsx(qe,{label:"North",value:((y=e.firms.bbox)==null?void 0:y[3])||0,onChange:_=>{const b=[...e.firms.bbox||[0,0,0,0]];b[3]=_,t({...e,firms:{...e.firms,bbox:b}})},step:.01})]}),x.jsx("div",{className:"text-xs text-slate-500",children:"Bounding box for monitoring area (required)"})]})]})]})]})}function WJe({data:e,onChange:t}){return x.jsxs("div",{className:"space-y-4",children:[x.jsx(Qn,{text:Kn.dashboard}),x.jsx(Et,{label:"Enable Dashboard",checked:e.enabled,onChange:r=>t({...e,enabled:r}),helper:"Run the web dashboard"}),e.enabled&&x.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[x.jsx(At,{label:"Host",value:e.host,onChange:r=>t({...e,host:r}),placeholder:"0.0.0.0",helper:"Network bind address",info:"0.0.0.0 = accessible from any device on the network. 127.0.0.1 = only accessible from this machine."}),x.jsx(qe,{label:"Port",value:e.port,onChange:r=>t({...e,port:r}),min:1,max:65535,helper:"Dashboard URL port",info:"Port number for the web dashboard URL. You access the dashboard at http://your-ip:port"})]})]})}function HJe(){var k;const[e,t]=W.useState(null),[r,n]=W.useState(null),[i,a]=W.useState("bot"),[o,s]=W.useState(!0),[l,u]=W.useState(!1),[c,f]=W.useState(null),[h,d]=W.useState(null),[v,g]=W.useState(!1),[m,y]=W.useState(!1),_=W.useCallback(async()=>{try{const I=await fetch("/api/config");if(!I.ok)throw new Error("Failed to fetch config");const O=await I.json();t(O),n(JSON.parse(JSON.stringify(O))),y(!1),f(null)}catch(I){f(I instanceof Error?I.message:"Unknown error")}finally{s(!1)}},[]);W.useEffect(()=>{document.title="Config — MeshAI",_()},[_]),W.useEffect(()=>{e&&r&&y(JSON.stringify(e)!==JSON.stringify(r))},[e,r]);const b=async()=>{if(e){u(!0),f(null),d(null);try{const I=e[i],O=await fetch(`/api/config/${i}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(I)}),D=await O.json();if(!O.ok)throw new Error(D.detail||"Save failed");d(`${i} saved successfully`),n(JSON.parse(JSON.stringify(e))),y(!1),D.restart_required&&g(!0),setTimeout(()=>d(null),3e3)}catch(I){f(I instanceof Error?I.message:"Save failed")}finally{u(!1)}}},S=()=>{r&&(t(JSON.parse(JSON.stringify(r))),y(!1))},T=async()=>{try{await fetch("/api/restart",{method:"POST"}),g(!1),d("Restart initiated")}catch{f("Restart failed")}},A=(I,O)=>{e&&t({...e,[I]:O})};if(o)return x.jsx("div",{className:"flex items-center justify-center h-64",children:x.jsx("div",{className:"text-slate-400",children:"Loading configuration..."})});if(!e)return x.jsx("div",{className:"flex items-center justify-center h-64",children:x.jsx("div",{className:"text-red-400",children:"Failed to load configuration"})});const M=()=>{switch(i){case"bot":return x.jsx(LJe,{data:e.bot,onChange:I=>A("bot",I)});case"connection":return x.jsx(kJe,{data:e.connection,onChange:I=>A("connection",I)});case"response":return x.jsx(IJe,{data:e.response,onChange:I=>A("response",I)});case"history":return x.jsx(OJe,{data:e.history,onChange:I=>A("history",I)});case"memory":return x.jsx(EJe,{data:e.memory,onChange:I=>A("memory",I)});case"context":return x.jsx(DJe,{data:e.context,onChange:I=>A("context",I)});case"commands":return x.jsx(NJe,{data:e.commands,onChange:I=>A("commands",I)});case"llm":return x.jsx(jJe,{data:e.llm,onChange:I=>A("llm",I)});case"weather":return x.jsx(RJe,{data:e.weather,onChange:I=>A("weather",I)});case"meshmonitor":return x.jsx(BJe,{data:e.meshmonitor,onChange:I=>A("meshmonitor",I)});case"knowledge":return x.jsx(zJe,{data:e.knowledge,onChange:I=>A("knowledge",I)});case"mesh_sources":return x.jsx(FJe,{data:e.mesh_sources,onChange:I=>A("mesh_sources",I)});case"mesh_intelligence":return x.jsx(VJe,{data:e.mesh_intelligence,onChange:I=>A("mesh_intelligence",I)});case"environmental":return x.jsx(GJe,{data:e.environmental,onChange:I=>A("environmental",I)});case"dashboard":return x.jsx(WJe,{data:e.dashboard,onChange:I=>A("dashboard",I)});default:return null}},P=((k=BU.find(I=>I.key===i))==null?void 0:k.label)||i;return x.jsxs("div",{className:"flex gap-6 h-[calc(100vh-8rem)]",children:[x.jsx("div",{className:"w-48 flex-shrink-0 space-y-1",children:BU.map(({key:I,label:O,icon:D})=>x.jsxs("button",{onClick:()=>a(I),className:`w-full flex items-center gap-2 px-3 py-2 rounded text-sm transition-colors ${i===I?"bg-accent text-white":"text-slate-400 hover:text-slate-200 hover:bg-bg-hover"}`,children:[x.jsx(D,{size:16}),x.jsx("span",{children:O}),m&&i===I&&x.jsx("span",{className:"ml-auto w-2 h-2 bg-amber-500 rounded-full"})]},I))}),x.jsxs("div",{className:"flex-1 flex flex-col min-w-0",children:[x.jsxs("div",{className:"flex items-center justify-between mb-6",children:[x.jsxs("div",{className:"flex items-center gap-3",children:[x.jsx(AZ,{size:20,className:"text-slate-500"}),x.jsx("h2",{className:"text-lg font-semibold text-slate-200",children:P})]}),x.jsxs("div",{className:"flex items-center gap-2",children:[m&&x.jsxs("button",{onClick:S,className:"flex items-center gap-1.5 px-3 py-1.5 text-sm text-slate-400 hover:text-slate-200 bg-bg-hover rounded transition-colors",children:[x.jsx(SZ,{size:14}),"Discard"]}),x.jsxs("button",{onClick:b,disabled:l||!m,className:"flex items-center gap-1.5 px-4 py-1.5 text-sm bg-accent text-white rounded hover:bg-accent/80 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:[l?x.jsx(wZ,{size:14,className:"animate-spin"}):x.jsx(TZ,{size:14}),"Save"]})]})]}),v&&x.jsxs("div",{className:"flex items-center justify-between p-3 mb-4 bg-amber-500/10 border border-amber-500/30 rounded-lg",children:[x.jsxs("div",{className:"flex items-center gap-2 text-amber-400",children:[x.jsx(Ds,{size:16}),x.jsx("span",{className:"text-sm",children:"Restart required for changes to take effect"})]}),x.jsx("button",{onClick:T,className:"px-3 py-1 text-sm bg-amber-500 text-white rounded hover:bg-amber-600 transition-colors",children:"Restart Now"})]}),c&&x.jsxs("div",{className:"flex items-center gap-2 p-3 mb-4 bg-red-500/10 border border-red-500/30 rounded-lg text-red-400",children:[x.jsx(hv,{size:16}),x.jsx("span",{className:"text-sm",children:c})]}),h&&x.jsxs("div",{className:"flex items-center gap-2 p-3 mb-4 bg-green-500/10 border border-green-500/30 rounded-lg text-green-400",children:[x.jsx(md,{size:16}),x.jsx("span",{className:"text-sm",children:h})]}),x.jsx("div",{className:"flex-1 overflow-y-auto pr-2",children:x.jsx("div",{className:"bg-bg-card border border-border rounded-lg p-6",children:M()})})]})]})}const zU={infra_offline:ice,infra_recovery:MZ,battery_warning:tC,battery_critical:tC,battery_emergency:tC,hf_blackout:Sm,uhf_ducting:tu,weather_warning:Yc,weather_watch:Yc,new_router:tu,packet_flood:Ds,sustained_high_util:Ds,region_blackout:Uy,default:_m};function UJe(e){return zU[e]||zU.default}function Vie(e){switch(e==null?void 0:e.toLowerCase()){case"critical":case"emergency":return{bg:"bg-red-500/10",border:"border-red-500",badge:"bg-red-500/20 text-red-400",iconColor:"text-red-500"};case"warning":return{bg:"bg-amber-500/10",border:"border-amber-500",badge:"bg-amber-500/20 text-amber-400",iconColor:"text-amber-500"};case"watch":return{bg:"bg-yellow-500/10",border:"border-yellow-500",badge:"bg-yellow-500/20 text-yellow-400",iconColor:"text-yellow-500"};case"advisory":case"info":default:return{bg:"bg-blue-500/10",border:"border-blue-500",badge:"bg-blue-500/20 text-blue-400",iconColor:"text-blue-500"}}}function ZJe(e){const t=typeof e=="number"?new Date(e*1e3):new Date(e),n=new Date().getTime()-t.getTime(),i=Math.floor(n/1e3),a=Math.floor(i/60),o=Math.floor(a/60),s=Math.floor(o/24);return i<60?"Just now":a<60?`${a}m ago`:o<24?`${o}h ago`:`${s}d ago`}function YJe(e){return(typeof e=="number"?new Date(e*1e3):new Date(e)).toLocaleString("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:!1})}function XJe(e){return e<60?`${e}s`:e<3600?`${Math.floor(e/60)}m`:e<86400?`${Math.floor(e/3600)}h ${Math.floor(e%3600/60)}m`:`${Math.floor(e/86400)}d`}function qJe({alert:e,onAcknowledge:t}){var i;const r=Vie(e.severity),n=UJe(e.type);return x.jsx("div",{className:`p-4 rounded-lg ${r.bg} border-l-4 ${r.border}`,children:x.jsxs("div",{className:"flex items-start gap-3",children:[x.jsx(n,{size:20,className:r.iconColor}),x.jsxs("div",{className:"flex-1 min-w-0",children:[x.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[x.jsx("span",{className:`text-xs px-2 py-0.5 rounded-full ${r.badge}`,children:(i=e.severity)==null?void 0:i.toUpperCase()}),x.jsx("span",{className:"text-xs text-slate-500",children:e.type})]}),x.jsx("div",{className:"text-sm text-slate-200",children:e.message}),x.jsxs("div",{className:"flex items-center gap-4 mt-2 text-xs text-slate-500",children:[x.jsxs("span",{className:"flex items-center gap-1",children:[x.jsx(yd,{size:12}),e.timestamp?ZJe(e.timestamp):"Just now"]}),e.scope_value&&x.jsxs("span",{children:[e.scope_type,": ",e.scope_value]})]})]}),x.jsx("button",{onClick:()=>t(e),className:"px-3 py-1 text-xs text-slate-400 hover:text-slate-200 border border-border rounded hover:bg-bg-hover transition-colors",children:"Acknowledge"})]})})}function KJe({history:e,typeFilter:t,severityFilter:r,onTypeFilterChange:n,onSeverityFilterChange:i,page:a,totalPages:o,onPageChange:s}){const l=["all","infra_offline","infra_recovery","battery_warning","battery_critical","hf_blackout","uhf_ducting","weather_warning","new_router","packet_flood"],u=["all","critical","warning","watch","info"];return x.jsxs("div",{className:"bg-bg-card border border-border rounded-lg",children:[x.jsxs("div",{className:"p-4 border-b border-border flex items-center gap-4",children:[x.jsxs("div",{className:"flex items-center gap-2",children:[x.jsx(FE,{size:14,className:"text-slate-400"}),x.jsx("span",{className:"text-sm text-slate-400",children:"Filter:"})]}),x.jsx("select",{value:t,onChange:c=>n(c.target.value),className:"bg-bg border border-border rounded px-3 py-1.5 text-sm text-slate-200 focus:outline-none focus:border-blue-500",children:l.map(c=>x.jsx("option",{value:c,children:c==="all"?"All Types":c.replace(/_/g," ")},c))}),x.jsx("select",{value:r,onChange:c=>i(c.target.value),className:"bg-bg border border-border rounded px-3 py-1.5 text-sm text-slate-200 focus:outline-none focus:border-blue-500",children:u.map(c=>x.jsx("option",{value:c,children:c==="all"?"All Severities":c.charAt(0).toUpperCase()+c.slice(1)},c))})]}),x.jsx("div",{className:"overflow-x-auto",children:x.jsxs("table",{className:"w-full",children:[x.jsx("thead",{children:x.jsxs("tr",{className:"border-b border-border",children:[x.jsx("th",{className:"text-left text-xs font-medium text-slate-400 p-4",children:"Time"}),x.jsx("th",{className:"text-left text-xs font-medium text-slate-400 p-4",children:"Type"}),x.jsx("th",{className:"text-left text-xs font-medium text-slate-400 p-4",children:"Severity"}),x.jsx("th",{className:"text-left text-xs font-medium text-slate-400 p-4",children:"Message"}),x.jsx("th",{className:"text-left text-xs font-medium text-slate-400 p-4",children:"Duration"})]})}),x.jsx("tbody",{children:e.length>0?e.map((c,f)=>{const h=Vie(c.severity);return x.jsxs("tr",{className:"border-b border-border hover:bg-bg-hover",children:[x.jsx("td",{className:"p-4 text-sm text-slate-400 font-mono whitespace-nowrap",children:YJe(c.timestamp)}),x.jsx("td",{className:"p-4 text-sm text-slate-300",children:c.type.replace(/_/g," ")}),x.jsx("td",{className:"p-4",children:x.jsx("span",{className:`text-xs px-2 py-0.5 rounded-full ${h.badge}`,children:c.severity})}),x.jsx("td",{className:"p-4 text-sm text-slate-200 max-w-md truncate",children:c.message}),x.jsx("td",{className:"p-4 text-sm text-slate-400 font-mono",children:c.duration?XJe(c.duration):"-"})]},c.id||f)}):x.jsx("tr",{children:x.jsx("td",{colSpan:5,className:"p-8 text-center text-slate-500",children:"No alert history available"})})})]})}),o>1&&x.jsxs("div",{className:"p-4 border-t border-border flex items-center justify-between",children:[x.jsxs("span",{className:"text-sm text-slate-400",children:["Page ",a," of ",o]}),x.jsxs("div",{className:"flex items-center gap-2",children:[x.jsx("button",{onClick:()=>s(a-1),disabled:a<=1,className:"p-2 text-slate-400 hover:text-slate-200 disabled:opacity-50 disabled:cursor-not-allowed",children:x.jsx(Uue,{size:16})}),x.jsx("button",{onClick:()=>s(a+1),disabled:a>=o,className:"p-2 text-slate-400 hover:text-slate-200 disabled:opacity-50 disabled:cursor-not-allowed",children:x.jsx(bm,{size:16})})]})]})]})}function QJe({subscription:e,nodes:t}){const r=o=>{const s=t.find(l=>l.node_id_hex===o||String(l.node_num)===o||l.short_name===o);return s?s.long_name&&s.long_name!==s.short_name?`${s.short_name} (${s.long_name})`:s.short_name:o},n=()=>{if(e.sub_type==="alerts")return"Real-time";const o=e.schedule_time||"0000",s=parseInt(o.slice(0,2)),l=o.slice(2),u=s>=12?"PM":"AM";let f=`${s%12||12}:${l} ${u}`;return e.sub_type==="weekly"&&e.schedule_day&&(f+=` ${e.schedule_day.charAt(0).toUpperCase()}${e.schedule_day.slice(1)}`),f},a=(()=>{switch(e.sub_type){case"alerts":return _m;case"daily":return yd;case"weekly":return yd;default:return _m}})();return x.jsx("div",{className:"p-4 rounded-lg bg-bg-hover border border-border",children:x.jsxs("div",{className:"flex items-center gap-3",children:[x.jsx("div",{className:"w-10 h-10 rounded-lg bg-blue-500/10 flex items-center justify-center",children:x.jsx(a,{size:18,className:"text-blue-400"})}),x.jsxs("div",{className:"flex-1",children:[x.jsxs("div",{className:"text-sm text-slate-200 font-medium",children:[e.sub_type.charAt(0).toUpperCase()+e.sub_type.slice(1),e.scope_type!=="mesh"&&e.scope_value&&x.jsxs("span",{className:"text-slate-400 font-normal ml-2",children:["(",e.scope_type,": ",e.scope_value,")"]})]}),x.jsxs("div",{className:"text-xs text-slate-500 mt-0.5",children:[n()," • ",r(e.user_id)]})]}),x.jsx("div",{className:`w-2 h-2 rounded-full ${e.enabled?"bg-green-500":"bg-slate-500"}`})]})})}function JJe(){const[e,t]=W.useState([]),[r,n]=W.useState([]),[i,a]=W.useState([]),[o,s]=W.useState([]),[l,u]=W.useState(!0),[c,f]=W.useState(null),[h,d]=W.useState("all"),[v,g]=W.useState("all"),[m,y]=W.useState(1),[_,b]=W.useState(1),S=20,[T,A]=W.useState(new Set),{lastAlert:M}=ZE();W.useEffect(()=>{document.title="Alerts — MeshAI"},[]),W.useEffect(()=>{Promise.all([PZ().catch(()=>[]),u3(S,0).catch(()=>({items:[],total:0})),uce().catch(()=>[]),fetch("/api/nodes").then(I=>I.json()).catch(()=>[])]).then(([I,O,D,N])=>{t(I),Array.isArray(O)?(n(O),b(1)):(n(O.items||[]),b(Math.ceil((O.total||0)/S))),a(D),s(N),u(!1)}).catch(I=>{f(I.message),u(!1)})},[]),W.useEffect(()=>{M&&t(I=>I.some(D=>D.type===M.type&&D.message===M.message)?I:[M,...I])},[M]),W.useEffect(()=>{const I=(m-1)*S;u3(S,I,h,v).then(O=>{Array.isArray(O)?(n(O),b(1)):(n(O.items||[]),b(Math.ceil((O.total||0)/S)))}).catch(()=>{})},[m,h,v]);const P=W.useCallback(I=>{const O=`${I.type}-${I.message}-${I.timestamp}`;A(D=>new Set([...D,O]))},[]),k=e.filter(I=>{const O=`${I.type}-${I.message}-${I.timestamp}`;return!T.has(O)});return l?x.jsx("div",{className:"flex items-center justify-center h-64",children:x.jsx("div",{className:"text-slate-400",children:"Loading alerts..."})}):c?x.jsx("div",{className:"flex items-center justify-center h-64",children:x.jsxs("div",{className:"text-red-400",children:["Error: ",c]})}):x.jsxs("div",{className:"space-y-6",children:[x.jsxs("div",{className:"bg-bg-card border border-border rounded-lg p-6",children:[x.jsxs("h2",{className:"text-sm font-medium text-slate-400 mb-4 flex items-center gap-2",children:[x.jsx(Ds,{size:14}),"Active Alerts (",k.length,")"]}),k.length>0?x.jsx("div",{className:"space-y-3",children:k.map((I,O)=>x.jsx(qJe,{alert:I,onAcknowledge:P},`${I.type}-${I.timestamp}-${O}`))}):x.jsxs("div",{className:"flex items-center gap-2 text-slate-500 py-8",children:[x.jsx(Qh,{size:20,className:"text-green-500"}),x.jsx("span",{children:"No active alerts — all systems nominal"})]})]}),x.jsxs("div",{children:[x.jsxs("h2",{className:"text-sm font-medium text-slate-400 mb-4 flex items-center gap-2",children:[x.jsx(yd,{size:14}),"Alert History"]}),x.jsx(KJe,{history:r,typeFilter:h,severityFilter:v,onTypeFilterChange:I=>{d(I),y(1)},onSeverityFilterChange:I=>{g(I),y(1)},page:m,totalPages:_,onPageChange:y})]}),x.jsxs("div",{className:"bg-bg-card border border-border rounded-lg p-6",children:[x.jsxs("h2",{className:"text-sm font-medium text-slate-400 mb-4 flex items-center gap-2",children:[x.jsx(nce,{size:14}),"Mesh Subscriptions (",i.length,")"]}),i.length>0?x.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3",children:i.map(I=>x.jsx(QJe,{subscription:I,nodes:o},I.id))}):x.jsxs("div",{className:"text-slate-500 py-4",children:[x.jsx("p",{children:"No active subscriptions."}),x.jsxs("p",{className:"text-xs mt-2",children:["Manage subscriptions via ",x.jsx("code",{className:"text-blue-400",children:"!subscribe"})," on mesh"]})]})]})]})}const gb=[{value:"info",label:"Info",description:"Routine updates (ducting detected, new router appeared)"},{value:"advisory",label:"Advisory",description:"Worth knowing (weather advisory, traffic slow, battery declining)"},{value:"watch",label:"Watch",description:"Pay attention (fire within 50km, weather watch, stream rising)"},{value:"warning",label:"Warning",description:"Act now (fire within 25km, severe weather, critical battery)"},{value:"critical",label:"Critical",description:"Serious issue (critical node down, battery emergency)"},{value:"emergency",label:"Emergency",description:"Life safety (extreme weather, fire at infrastructure, total blackout)"}],$U=[{id:"mesh_health",name:"Mesh Health Monitoring",description:"Infrastructure problems - offline nodes, low battery, channel congestion",rule:{name:"Mesh Health Monitoring",enabled:!0,trigger_type:"condition",categories:["infra_offline","critical_node_down","infra_recovery","battery_warning","battery_critical","battery_emergency","high_utilization","packet_flood","mesh_score_low"],min_severity:"advisory",delivery_type:"mesh_broadcast",broadcast_channel:0,cooldown_minutes:30,override_quiet:!1,schedule_frequency:"daily",schedule_time:"07:00",schedule_time_2:"",schedule_days:[],message_type:"",custom_message:"",node_ids:[],smtp_host:"",smtp_port:587,smtp_user:"",smtp_password:"",smtp_tls:!0,from_address:"",recipients:[],webhook_url:"",webhook_headers:{}}},{id:"weather_fire",name:"Weather & Fire Alerts",description:"Environmental threats - severe weather, nearby wildfires, new ignitions, flooding",rule:{name:"Weather & Fire Alerts",enabled:!0,trigger_type:"condition",categories:["weather_warning","fire_proximity","new_ignition","stream_flood_warning"],min_severity:"warning",delivery_type:"mesh_broadcast",broadcast_channel:0,cooldown_minutes:15,override_quiet:!1,schedule_frequency:"daily",schedule_time:"07:00",schedule_time_2:"",schedule_days:[],message_type:"",custom_message:"",node_ids:[],smtp_host:"",smtp_port:587,smtp_user:"",smtp_password:"",smtp_tls:!0,from_address:"",recipients:[],webhook_url:"",webhook_headers:{}}},{id:"rf_conditions",name:"RF Conditions",description:"Propagation changes - solar events, HF blackouts, tropospheric ducting",rule:{name:"RF Conditions",enabled:!0,trigger_type:"condition",categories:["hf_blackout","tropospheric_ducting","geomagnetic_storm"],min_severity:"info",delivery_type:"mesh_broadcast",broadcast_channel:0,cooldown_minutes:60,override_quiet:!1,schedule_frequency:"daily",schedule_time:"07:00",schedule_time_2:"",schedule_days:[],message_type:"",custom_message:"",node_ids:[],smtp_host:"",smtp_port:587,smtp_user:"",smtp_password:"",smtp_tls:!0,from_address:"",recipients:[],webhook_url:"",webhook_headers:{}}},{id:"road_traffic",name:"Road & Traffic",description:"Road closures and severe congestion",rule:{name:"Road & Traffic",enabled:!0,trigger_type:"condition",categories:["road_closure","traffic_congestion"],min_severity:"warning",delivery_type:"mesh_broadcast",broadcast_channel:0,cooldown_minutes:30,override_quiet:!1,schedule_frequency:"daily",schedule_time:"07:00",schedule_time_2:"",schedule_days:[],message_type:"",custom_message:"",node_ids:[],smtp_host:"",smtp_port:587,smtp_user:"",smtp_password:"",smtp_tls:!0,from_address:"",recipients:[],webhook_url:"",webhook_headers:{}}},{id:"everything_critical",name:"Everything Critical",description:"All emergency-level events regardless of type",rule:{name:"Everything Critical",enabled:!0,trigger_type:"condition",categories:[],min_severity:"emergency",delivery_type:"mesh_broadcast",broadcast_channel:0,cooldown_minutes:5,override_quiet:!0,schedule_frequency:"daily",schedule_time:"07:00",schedule_time_2:"",schedule_days:[],message_type:"",custom_message:"",node_ids:[],smtp_host:"",smtp_port:587,smtp_user:"",smtp_password:"",smtp_tls:!0,from_address:"",recipients:[],webhook_url:"",webhook_headers:{}}},{id:"morning_briefing",name:"Morning Briefing",description:"Daily health and conditions summary at 7am",rule:{name:"Morning Briefing",enabled:!0,trigger_type:"schedule",categories:[],min_severity:"info",schedule_frequency:"daily",schedule_time:"07:00",schedule_time_2:"",schedule_days:[],message_type:"mesh_health_summary",custom_message:"",delivery_type:"mesh_broadcast",broadcast_channel:0,cooldown_minutes:0,override_quiet:!1,node_ids:[],smtp_host:"",smtp_port:587,smtp_user:"",smtp_password:"",smtp_tls:!0,from_address:"",recipients:[],webhook_url:"",webhook_headers:{}}}];function No({info:e}){const[t,r]=W.useState(!1);return x.jsxs("div",{className:"relative inline-block",children:[x.jsx("button",{type:"button",onClick:n=>{n.stopPropagation(),r(!t)},className:"ml-1.5 w-4 h-4 rounded-full bg-slate-700 hover:bg-slate-600 text-slate-400 hover:text-slate-200 inline-flex items-center justify-center text-xs transition-colors",title:"More info",children:"?"}),t&&x.jsxs(x.Fragment,{children:[x.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>r(!1)}),x.jsx("div",{className:"absolute left-0 top-6 z-50 w-72 p-3 bg-[#1a2332] border border-[#2a3a4a] rounded-lg shadow-xl text-xs text-slate-300 leading-relaxed",children:e})]})]})}function mh({label:e,value:t,onChange:r,type:n="text",placeholder:i="",helper:a="",info:o=""}){const[s,l]=W.useState(!1),u=n==="password";return x.jsxs("div",{className:"space-y-1",children:[x.jsxs("label",{className:"flex items-center text-xs text-slate-500 uppercase tracking-wide",children:[e,o&&x.jsx(No,{info:o})]}),x.jsxs("div",{className:"relative",children:[x.jsx("input",{type:u&&!s?"password":"text",value:t,onChange:c=>r(c.target.value),placeholder:i,className:"w-full px-3 py-2 bg-[#0a0e17] border border-[#1e2a3a] rounded text-sm text-slate-200 font-mono focus:outline-none focus:border-accent placeholder-slate-600"}),u&&x.jsx("button",{type:"button",onClick:()=>l(!s),className:"absolute right-2 top-1/2 -translate-y-1/2 text-slate-500 hover:text-slate-300",children:s?x.jsx(yZ,{size:16}):x.jsx($E,{size:16})})]}),a&&x.jsx("p",{className:"text-xs text-slate-600",children:a})]})}function FU({label:e,value:t,onChange:r,min:n,max:i,step:a=1,helper:o="",info:s=""}){return x.jsxs("div",{className:"space-y-1",children:[x.jsxs("label",{className:"flex items-center text-xs text-slate-500 uppercase tracking-wide",children:[e,s&&x.jsx(No,{info:s})]}),x.jsx("input",{type:"number",value:t,onChange:l=>r(Number(l.target.value)),min:n,max:i,step:a,className:"w-full px-3 py-2 bg-[#0a0e17] border border-[#1e2a3a] rounded text-sm text-slate-200 font-mono focus:outline-none focus:border-accent"}),o&&x.jsx("p",{className:"text-xs text-slate-600",children:o})]})}function rS({label:e,checked:t,onChange:r,helper:n="",info:i=""}){return x.jsxs("div",{className:"flex items-center justify-between py-2",children:[x.jsxs("div",{children:[x.jsxs("span",{className:"flex items-center text-sm text-slate-300",children:[e,i&&x.jsx(No,{info:i})]}),n&&x.jsx("p",{className:"text-xs text-slate-600",children:n})]}),x.jsx("button",{type:"button",onClick:()=>r(!t),className:`relative w-11 h-6 rounded-full transition-colors ${t?"bg-accent":"bg-[#1e2a3a]"}`,children:x.jsx("span",{className:`absolute top-1 left-1 w-4 h-4 rounded-full bg-white transition-transform ${t?"translate-x-5":""}`})})]})}function nS({label:e,value:t,onChange:r,helper:n="",info:i=""}){return x.jsxs("div",{className:"space-y-1",children:[x.jsxs("label",{className:"flex items-center text-xs text-slate-500 uppercase tracking-wide",children:[e,i&&x.jsx(No,{info:i})]}),x.jsx("input",{type:"time",value:t,onChange:a=>r(a.target.value),className:"w-full px-3 py-2 bg-[#0a0e17] border border-[#1e2a3a] rounded text-sm text-slate-200 focus:outline-none focus:border-accent"}),n&&x.jsx("p",{className:"text-xs text-slate-600",children:n})]})}function eet({label:e,value:t,onChange:r,placeholder:n="Add item...",helper:i="",info:a=""}){const[o,s]=W.useState(""),l=()=>{o.trim()&&!t.includes(o.trim())&&(r([...t,o.trim()]),s(""))},u=c=>{r(t.filter((f,h)=>h!==c))};return x.jsxs("div",{className:"space-y-1",children:[x.jsxs("label",{className:"flex items-center text-xs text-slate-500 uppercase tracking-wide",children:[e,a&&x.jsx(No,{info:a})]}),x.jsxs("div",{className:"flex gap-2",children:[x.jsx("input",{type:"text",value:o,onChange:c=>s(c.target.value),onKeyDown:c=>c.key==="Enter"&&(c.preventDefault(),l()),className:"flex-1 px-3 py-2 bg-[#0a0e17] border border-[#1e2a3a] rounded text-sm text-slate-200 font-mono focus:outline-none focus:border-accent",placeholder:n}),x.jsx("button",{type:"button",onClick:l,className:"px-3 py-2 bg-accent hover:bg-accent/80 rounded text-sm text-white transition-colors",children:x.jsx(bS,{size:16})})]}),t.length>0&&x.jsx("div",{className:"flex flex-wrap gap-2 mt-2",children:t.map((c,f)=>x.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-1 bg-[#1e2a3a] rounded text-sm text-slate-300",children:[c,x.jsx("button",{type:"button",onClick:()=>u(f),className:"text-slate-500 hover:text-red-400",children:x.jsx(hv,{size:14})})]},f))}),i&&x.jsx("p",{className:"text-xs text-slate-600",children:i})]})}function tet({value:e,onChange:t}){const[r,n]=W.useState(!1),i=gb.find(a=>a.value===e)||gb[3];return x.jsxs("div",{className:"space-y-1",children:[x.jsxs("label",{className:"flex items-center text-xs text-slate-500 uppercase tracking-wide",children:["Severity Threshold",x.jsx(No,{info:"Only alerts at or above this severity trigger this rule. Lower threshold = more notifications. 'Warning' is recommended for most rules."})]}),x.jsxs("div",{className:"relative",children:[x.jsxs("button",{type:"button",onClick:()=>n(!r),className:"w-full px-3 py-2 bg-[#0a0e17] border border-[#1e2a3a] rounded text-sm text-left flex items-center justify-between hover:border-accent transition-colors",children:[x.jsxs("div",{children:[x.jsx("span",{className:"text-slate-200",children:i.label}),x.jsxs("span",{className:"text-slate-500 ml-2",children:["— ",i.description]})]}),x.jsx(Hy,{size:16,className:`text-slate-500 transition-transform ${r?"rotate-180":""}`})]}),r&&x.jsxs(x.Fragment,{children:[x.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>n(!1)}),x.jsx("div",{className:"absolute left-0 right-0 top-full mt-1 z-50 bg-[#0a0e17] border border-[#1e2a3a] rounded-lg shadow-xl overflow-hidden",children:gb.map(a=>x.jsxs("button",{type:"button",onClick:()=>{t(a.value),n(!1)},className:`w-full px-3 py-2.5 text-left text-sm hover:bg-[#1e2a3a] transition-colors ${e===a.value?"bg-accent/10":""}`,children:[x.jsx("div",{className:"font-medium text-slate-200",children:a.label}),x.jsx("div",{className:"text-xs text-slate-500",children:a.description})]},a.value))})]})]}),x.jsx("p",{className:"text-xs text-slate-600",children:'Lower = more notifications. "Warning" recommended for most rules.'})]})}function ret({rule:e,categories:t,quietHoursEnabled:r,onChange:n,onDelete:i,onDuplicate:a,onTest:o}){var S,T,A,M;const[s,l]=W.useState(!e.name),[u,c]=W.useState(!1),f=[{value:"",label:"(None)",description:"Rule matches but does not deliver"},{value:"mesh_broadcast",label:"Mesh Broadcast",description:"Send to a mesh radio channel"},{value:"mesh_dm",label:"Mesh DM",description:"Direct message to specific nodes"},{value:"email",label:"Email",description:"Send via SMTP"},{value:"webhook",label:"Webhook",description:"POST to any URL"}],h=[{value:"daily",label:"Daily"},{value:"twice_daily",label:"Twice Daily"},{value:"weekly",label:"Weekly"}],d=[{value:"mesh_health_summary",label:"Mesh Health Summary",description:"Current health score, pillar breakdown, problem nodes"},{value:"rf_propagation_report",label:"RF Propagation Report",description:"Solar indices, Kp, ducting conditions"},{value:"alerts_digest",label:"Active Alerts Digest",description:"Summary of all active environmental alerts"},{value:"environmental_conditions",label:"Environmental Conditions",description:"Full conditions: weather, fire, streams, roads"},{value:"custom",label:"Custom Message",description:"Write your own with template tokens"}],v=["monday","tuesday","wednesday","thursday","friday","saturday","sunday"],g=P=>{const k=e.categories||[];k.includes(P)?n({...e,categories:k.filter(I=>I!==P)}):n({...e,categories:[...k,P]})},m=P=>{const k=e.schedule_days||[];k.includes(P)?n({...e,schedule_days:k.filter(I=>I!==P)}):n({...e,schedule_days:[...k,P]})},y=async()=>{c(!0),await o(),c(!1)},_=()=>{if(e.trigger_type==="schedule")return"[Scheduled report preview would appear here]";const P=e.categories||[];if(P.length===0&&t.length>0)return t[0].example_message||"Alert notification";const k=t.find(I=>P.includes(I.id));return(k==null?void 0:k.example_message)||"Alert notification"},b=()=>{var k,I,O,D,N,B,$,F;const P=[];if(e.trigger_type==="schedule"){const G=((k=h.find(U=>U.value===e.schedule_frequency))==null?void 0:k.label)||e.schedule_frequency,z=((I=d.find(U=>U.value===e.message_type))==null?void 0:I.label)||e.message_type;P.push(`${G} at ${e.schedule_time||"??:??"}`),P.push(z)}else{const G=((O=e.categories)==null?void 0:O.length)||0,z=G===0?"All":t.filter(H=>{var Y;return(Y=e.categories)==null?void 0:Y.includes(H.id)}).map(H=>H.name).slice(0,2).join(", ")+(G>2?` +${G-2}`:""),U=((D=gb.find(H=>H.value===e.min_severity))==null?void 0:D.label)||e.min_severity;P.push(`${z} at ${U}+`)}if(!e.delivery_type)P.push("⚠️ No delivery");else{const G=((N=f.find(U=>U.value===e.delivery_type))==null?void 0:N.label)||e.delivery_type;let z="";if(e.delivery_type==="mesh_broadcast")z=`Ch ${e.broadcast_channel}`;else if(e.delivery_type==="mesh_dm")z=`${((B=e.node_ids)==null?void 0:B.length)||0} nodes`;else if(e.delivery_type==="email")z=($=e.recipients)!=null&&$.length?e.recipients[0]+(e.recipients.length>1?` +${e.recipients.length-1}`:""):"no recipients";else if(e.delivery_type==="webhook")try{z=new URL(e.webhook_url).hostname}catch{z=((F=e.webhook_url)==null?void 0:F.slice(0,20))||"no URL"}P.push(`${G}${z?` (${z})`:""}`)}return P.join(" → ")};return x.jsxs("div",{className:`border rounded-lg overflow-hidden ${e.enabled?"border-[#1e2a3a]":"border-slate-700 opacity-60"}`,children:[x.jsxs("div",{className:"flex items-center justify-between p-3 bg-[#0a0e17] cursor-pointer",onClick:()=>l(!s),children:[x.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[s?x.jsx(Hy,{size:16,className:"text-slate-500 flex-shrink-0"}):x.jsx(bm,{size:16,className:"text-slate-500 flex-shrink-0"}),x.jsx("button",{onClick:P=>{P.stopPropagation(),n({...e,enabled:!e.enabled})},className:`w-2 h-2 rounded-full flex-shrink-0 ${e.enabled?"bg-green-500":"bg-slate-500"}`,title:e.enabled?"Enabled":"Disabled"}),e.trigger_type==="schedule"?x.jsx(yd,{size:14,className:"text-blue-400 flex-shrink-0"}):x.jsx(Sm,{size:14,className:"text-yellow-400 flex-shrink-0"}),x.jsx("span",{className:"font-medium text-slate-200 truncate",children:e.name||"New Rule"}),!s&&x.jsx("span",{className:`text-xs truncate hidden sm:block ${e.delivery_type?"text-slate-500":"text-amber-400"}`,children:b()})]}),x.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[x.jsx("button",{onClick:P=>{P.stopPropagation(),y()},disabled:u||!e.name,className:"p-1.5 text-blue-400 hover:text-blue-300 hover:bg-blue-500/10 rounded disabled:opacity-50",title:"Test rule",children:x.jsx(o3,{size:14})}),x.jsx("button",{onClick:P=>{P.stopPropagation(),a()},className:"p-1.5 text-slate-400 hover:text-slate-200 hover:bg-slate-500/10 rounded",title:"Duplicate",children:x.jsx(que,{size:14})}),x.jsx("button",{onClick:P=>{P.stopPropagation(),i()},className:"p-1.5 text-red-400 hover:text-red-300 hover:bg-red-500/10 rounded",title:"Delete",children:x.jsx(UE,{size:14})})]})]}),s&&x.jsxs("div",{className:"p-4 space-y-6 border-t border-[#1e2a3a]",children:[x.jsx(mh,{label:"Rule Name",value:e.name,onChange:P=>n({...e,name:P}),placeholder:"e.g., Emergency Broadcast, Daily Health Report",helper:"A descriptive name for this rule"}),x.jsxs("div",{className:"space-y-2",children:[x.jsx("label",{className:"text-xs text-slate-500 uppercase tracking-wide",children:"Trigger Type"}),x.jsxs("div",{className:"flex gap-2",children:[x.jsxs("button",{type:"button",onClick:()=>n({...e,trigger_type:"condition"}),className:`flex-1 flex items-center justify-center gap-2 px-4 py-3 rounded-lg border transition-colors ${e.trigger_type!=="schedule"?"bg-accent/10 border-accent text-accent":"bg-[#0a0e17] border-[#1e2a3a] text-slate-400 hover:text-slate-200"}`,children:[x.jsx(Sm,{size:16}),x.jsx("span",{children:"Condition"})]}),x.jsxs("button",{type:"button",onClick:()=>n({...e,trigger_type:"schedule"}),className:`flex-1 flex items-center justify-center gap-2 px-4 py-3 rounded-lg border transition-colors ${e.trigger_type==="schedule"?"bg-accent/10 border-accent text-accent":"bg-[#0a0e17] border-[#1e2a3a] text-slate-400 hover:text-slate-200"}`,children:[x.jsx(yd,{size:16}),x.jsx("span",{children:"Schedule"})]})]}),x.jsx("p",{className:"text-xs text-slate-600",children:e.trigger_type==="schedule"?"Send reports on a schedule (daily briefings, weekly digests)":"React to alert conditions (fires, outages, weather warnings)"})]}),e.trigger_type!=="schedule"&&x.jsxs("div",{className:"space-y-4 p-4 bg-[#0a0e17] rounded-lg border border-[#1e2a3a]",children:[x.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium text-slate-300",children:[x.jsx(Ds,{size:14}),"WHEN (Condition)"]}),x.jsx(tet,{value:e.min_severity,onChange:P=>n({...e,min_severity:P})}),x.jsxs("div",{className:"space-y-2",children:[x.jsxs("label",{className:"flex items-center text-xs text-slate-500 uppercase tracking-wide",children:["Alert Categories",x.jsx(No,{info:"Select which types of alerts trigger this rule. Leave all unchecked to match ALL categories."})]}),x.jsx("div",{className:"text-xs text-slate-500 mb-2",children:(((S=e.categories)==null?void 0:S.length)||0)===0?"All categories (none selected)":`${(T=e.categories)==null?void 0:T.length} selected`}),x.jsx("div",{className:"max-h-48 overflow-y-auto border border-[#1e2a3a] rounded-lg p-2 space-y-1",children:t.map(P=>{var k,I;return x.jsxs("label",{onClick:()=>g(P.id),className:"flex items-start gap-2 p-2 rounded hover:bg-[#1e2a3a]/50 cursor-pointer",children:[x.jsx("div",{className:`w-4 h-4 mt-0.5 rounded border flex items-center justify-center flex-shrink-0 ${(k=e.categories)!=null&&k.includes(P.id)?"bg-accent border-accent":"border-slate-600"}`,children:((I=e.categories)==null?void 0:I.includes(P.id))&&x.jsx(md,{size:12,className:"text-white"})}),x.jsxs("div",{className:"flex-1 min-w-0",children:[x.jsx("div",{className:"text-sm text-slate-200",children:P.name}),x.jsx("div",{className:"text-xs text-slate-500",children:P.description})]})]},P.id)})})]})]}),e.trigger_type==="schedule"&&x.jsxs("div",{className:"space-y-4 p-4 bg-[#0a0e17] rounded-lg border border-[#1e2a3a]",children:[x.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium text-slate-300",children:[x.jsx(Hue,{size:14}),"WHEN (Schedule)"]}),x.jsxs("div",{className:"space-y-1",children:[x.jsx("label",{className:"text-xs text-slate-500 uppercase tracking-wide",children:"Frequency"}),x.jsx("select",{value:e.schedule_frequency||"daily",onChange:P=>n({...e,schedule_frequency:P.target.value}),className:"w-full px-3 py-2 bg-[#0a0e17] border border-[#1e2a3a] rounded text-sm text-slate-200 focus:outline-none focus:border-accent",children:h.map(P=>x.jsx("option",{value:P.value,children:P.label},P.value))})]}),x.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[x.jsx(nS,{label:"Time",value:e.schedule_time||"07:00",onChange:P=>n({...e,schedule_time:P})}),e.schedule_frequency==="twice_daily"&&x.jsx(nS,{label:"Second Time",value:e.schedule_time_2||"19:00",onChange:P=>n({...e,schedule_time_2:P})})]}),e.schedule_frequency==="weekly"&&x.jsxs("div",{className:"space-y-2",children:[x.jsx("label",{className:"text-xs text-slate-500 uppercase tracking-wide",children:"Days"}),x.jsx("div",{className:"flex flex-wrap gap-2",children:v.map(P=>{var k;return x.jsx("button",{type:"button",onClick:()=>m(P),className:`px-3 py-1.5 rounded text-sm capitalize transition-colors ${(k=e.schedule_days)!=null&&k.includes(P)?"bg-accent text-white":"bg-[#1e2a3a] text-slate-400 hover:text-slate-200"}`,children:P.slice(0,3)},P)})})]}),x.jsxs("div",{className:"space-y-1",children:[x.jsx("label",{className:"text-xs text-slate-500 uppercase tracking-wide",children:"Report Type"}),x.jsx("select",{value:e.message_type||"mesh_health_summary",onChange:P=>n({...e,message_type:P.target.value}),className:"w-full px-3 py-2 bg-[#0a0e17] border border-[#1e2a3a] rounded text-sm text-slate-200 focus:outline-none focus:border-accent",children:d.map(P=>x.jsx("option",{value:P.value,children:P.label},P.value))}),x.jsx("p",{className:"text-xs text-slate-600",children:(A=d.find(P=>P.value===e.message_type))==null?void 0:A.description})]}),e.message_type==="custom"&&x.jsxs("div",{className:"space-y-1",children:[x.jsxs("label",{className:"flex items-center text-xs text-slate-500 uppercase tracking-wide",children:["Custom Message",x.jsx(No,{info:"Available tokens: {MESH_SCORE}, {NODE_COUNT}, {NODES_ONLINE}, {ACTIVE_ALERTS}, {KP}, {SFI}, {DATE}, {TIME}"})]}),x.jsx("textarea",{value:e.custom_message||"",onChange:P=>n({...e,custom_message:P.target.value}),rows:4,placeholder:"Good morning! Mesh health: {MESH_SCORE}/100 with {NODE_COUNT} nodes online.",className:"w-full px-3 py-2 bg-[#0a0e17] border border-[#1e2a3a] rounded text-sm text-slate-200 font-mono focus:outline-none focus:border-accent placeholder-slate-600"})]})]}),x.jsxs("div",{className:"space-y-4 p-4 bg-[#0a0e17] rounded-lg border border-[#1e2a3a]",children:[x.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium text-slate-300",children:[x.jsx(o3,{size:14}),"SEND VIA"]}),x.jsxs("div",{className:"space-y-1",children:[x.jsxs("label",{className:"flex items-center text-xs text-slate-500 uppercase tracking-wide",children:["Delivery Method",x.jsx(No,{info:"Where this notification gets delivered. Select (None) to save the rule without delivery — it will match conditions but won't send until you configure a delivery method."})]}),x.jsx("select",{value:e.delivery_type||"",onChange:P=>n({...e,delivery_type:P.target.value}),className:"w-full px-3 py-2 bg-[#0a0e17] border border-[#1e2a3a] rounded text-sm text-slate-200 focus:outline-none focus:border-accent",children:f.map(P=>x.jsx("option",{value:P.value,children:P.label},P.value))}),x.jsx("p",{className:"text-xs text-slate-600",children:(M=f.find(P=>P.value===(e.delivery_type||"")))==null?void 0:M.description})]}),!e.delivery_type&&x.jsxs("div",{className:"flex items-start gap-2 p-3 bg-amber-500/10 border border-amber-500/20 rounded-lg",children:[x.jsx(Uy,{size:16,className:"text-amber-400 mt-0.5 flex-shrink-0"}),x.jsx("div",{className:"text-sm text-amber-300",children:"Rule will log matches but not deliver until a delivery method is configured."})]}),e.delivery_type==="mesh_broadcast"&&x.jsx(RR,{label:"Broadcast Channel",value:e.broadcast_channel??0,onChange:P=>n({...e,broadcast_channel:P}),helper:"Select the mesh radio channel",mode:"single"}),e.delivery_type==="mesh_dm"&&x.jsx(jR,{label:"Recipient Nodes",value:e.node_ids||[],onChange:P=>n({...e,node_ids:P}),helper:"Nodes that receive direct messages",valueType:"node_id_hex"}),e.delivery_type==="email"&&x.jsxs("div",{className:"space-y-4",children:[x.jsx(eet,{label:"Recipients",value:e.recipients||[],onChange:P=>n({...e,recipients:P}),placeholder:"email@example.com",helper:"Email addresses to receive alerts"}),x.jsxs("details",{className:"group",children:[x.jsxs("summary",{className:"flex items-center gap-2 cursor-pointer text-sm text-slate-400 hover:text-slate-200",children:[x.jsx(bm,{size:14,className:"group-open:rotate-90 transition-transform"}),"SMTP Configuration"]}),x.jsxs("div",{className:"mt-4 space-y-4 pl-6 border-l border-[#1e2a3a]",children:[x.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[x.jsx(mh,{label:"SMTP Host",value:e.smtp_host||"",onChange:P=>n({...e,smtp_host:P}),placeholder:"smtp.gmail.com"}),x.jsx(FU,{label:"SMTP Port",value:e.smtp_port??587,onChange:P=>n({...e,smtp_port:P}),min:1,max:65535})]}),x.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[x.jsx(mh,{label:"Username",value:e.smtp_user||"",onChange:P=>n({...e,smtp_user:P})}),x.jsx(mh,{label:"Password",value:e.smtp_password||"",onChange:P=>n({...e,smtp_password:P}),type:"password",info:"Gmail users: use an App Password from myaccount.google.com/apppasswords"})]}),x.jsx(rS,{label:"Use TLS",checked:e.smtp_tls??!0,onChange:P=>n({...e,smtp_tls:P})}),x.jsx(mh,{label:"From Address",value:e.from_address||"",onChange:P=>n({...e,from_address:P}),placeholder:"alerts@yourdomain.com"})]})]})]}),e.delivery_type==="webhook"&&x.jsx(mh,{label:"Webhook URL",value:e.webhook_url||"",onChange:P=>n({...e,webhook_url:P}),placeholder:"https://discord.com/api/webhooks/...",helper:"POST alert as JSON",info:"Works with Discord webhooks, ntfy.sh, Slack, Home Assistant, Pushover, or any HTTP POST endpoint."})]}),x.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[x.jsx(FU,{label:"Cooldown (minutes)",value:e.cooldown_minutes??10,onChange:P=>n({...e,cooldown_minutes:P}),min:0,helper:"Min time between repeat sends",info:"Prevents alert spam. Same condition won't re-trigger this rule within this window."}),r&&x.jsx("div",{className:"flex items-end pb-1",children:x.jsx(rS,{label:"Override Quiet Hours",checked:e.override_quiet??!1,onChange:P=>n({...e,override_quiet:P}),helper:"Deliver during quiet hours"})})]}),e.trigger_type!=="schedule"&&x.jsxs("div",{className:"space-y-2",children:[x.jsx("label",{className:"text-xs text-slate-500 uppercase tracking-wide",children:"Example Message"}),x.jsx("div",{className:"p-3 bg-[#1e2a3a]/50 rounded-lg border border-[#1e2a3a]",children:x.jsx("p",{className:"text-sm text-slate-300 font-mono",children:_()})}),x.jsx("p",{className:"text-xs text-slate-600",children:"This is an example of what this rule would send."})]})]})]})}function net(){var D,N;const[e,t]=W.useState(null),[r,n]=W.useState(null),[i,a]=W.useState([]),[o,s]=W.useState(!0),[l,u]=W.useState(!1),[c,f]=W.useState(null),[h,d]=W.useState(null),[v,g]=W.useState(null),[m,y]=W.useState(!1),[_,b]=W.useState(!1),S=W.useCallback(async()=>{try{const[B,$]=await Promise.all([fetch("/api/config/notifications"),fetch("/api/notifications/categories")]);if(!B.ok)throw new Error("Failed to fetch notifications config");const F=await B.json(),G=await $.json();t(F),n(JSON.parse(JSON.stringify(F))),a(G),b(!1),f(null)}catch(B){f(B instanceof Error?B.message:"Unknown error")}finally{s(!1)}},[]);W.useEffect(()=>{document.title="Notifications — MeshAI",S()},[S]),W.useEffect(()=>{e&&r&&b(JSON.stringify(e)!==JSON.stringify(r))},[e,r]);const T=async()=>{if(e){u(!0),f(null),d(null);try{const B=await fetch("/api/config/notifications",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),$=await B.json();if(!B.ok)throw new Error($.detail||"Save failed");d("Notifications config saved successfully"),n(JSON.parse(JSON.stringify(e))),b(!1),setTimeout(()=>d(null),3e3)}catch(B){f(B instanceof Error?B.message:"Save failed")}finally{u(!1)}}},A=()=>{r&&(t(JSON.parse(JSON.stringify(r))),b(!1))},M=()=>({name:"",enabled:!0,trigger_type:"condition",categories:[],min_severity:"warning",schedule_frequency:"daily",schedule_time:"07:00",schedule_time_2:"19:00",schedule_days:["monday"],message_type:"mesh_health_summary",custom_message:"",delivery_type:"",broadcast_channel:0,node_ids:[],smtp_host:"",smtp_port:587,smtp_user:"",smtp_password:"",smtp_tls:!0,from_address:"",recipients:[],webhook_url:"",webhook_headers:{},cooldown_minutes:10,override_quiet:!1}),P=()=>{e&&t({...e,rules:[...e.rules||[],M()]})},k=B=>{if(!e)return;const $=$U.find(F=>F.id===B);$&&(t({...e,rules:[...e.rules||[],{...$.rule}]}),y(!1))},I=B=>{if(!e)return;const $=e.rules[B],F={...JSON.parse(JSON.stringify($)),name:`${$.name} (copy)`},G=[...e.rules];G.splice(B+1,0,F),t({...e,rules:G})},O=async B=>{try{const F=await(await fetch(`/api/notifications/rules/${B}/test`,{method:"POST"})).json();g(F),setTimeout(()=>g(null),5e3)}catch{g({success:!1,message:"Test failed"}),setTimeout(()=>g(null),5e3)}};return o?x.jsx("div",{className:"flex items-center justify-center h-64",children:x.jsx("div",{className:"text-slate-400",children:"Loading notifications config..."})}):e?x.jsxs("div",{className:"max-w-4xl mx-auto space-y-6",children:[x.jsxs("div",{className:"flex items-center justify-between",children:[x.jsx("div",{children:x.jsx("p",{className:"text-sm text-slate-500",children:"Alert delivery and scheduled reports. Rules define what triggers a notification and where it gets sent."})}),x.jsxs("div",{className:"flex items-center gap-2",children:[x.jsx("button",{onClick:S,className:"p-2 text-slate-400 hover:text-slate-200 hover:bg-bg-hover rounded transition-colors",title:"Refresh",children:x.jsx(wZ,{size:18})}),x.jsxs("button",{onClick:A,disabled:!_,className:"flex items-center gap-2 px-3 py-2 text-slate-400 hover:text-slate-200 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:[x.jsx(SZ,{size:16}),"Discard"]}),x.jsxs("button",{onClick:T,disabled:l||!_,className:"flex items-center gap-2 px-4 py-2 bg-accent hover:bg-accent/80 disabled:bg-slate-700 disabled:cursor-not-allowed rounded text-white transition-colors",children:[x.jsx(TZ,{size:16}),l?"Saving...":"Save"]})]})]}),c&&x.jsx("div",{className:"p-3 rounded-lg text-sm bg-red-500/10 text-red-400 border border-red-500/20",children:c}),h&&x.jsxs("div",{className:"p-3 rounded-lg text-sm bg-green-500/10 text-green-400 border border-green-500/20",children:[x.jsx(md,{size:14,className:"inline mr-2"}),h]}),v&&x.jsxs("div",{className:`p-3 rounded-lg text-sm ${v.success?"bg-green-500/10 text-green-400 border border-green-500/20":"bg-red-500/10 text-red-400 border border-red-500/20"}`,children:[v.success?x.jsx(md,{size:14,className:"inline mr-2"}):x.jsx(hv,{size:14,className:"inline mr-2"}),v.message]}),x.jsxs("div",{className:"bg-bg-card border border-border rounded-lg p-6 space-y-6",children:[x.jsx(rS,{label:"Enable Notifications",checked:e.enabled,onChange:B=>t({...e,enabled:B}),helper:"Master switch for all notification delivery",info:"When disabled, no alerts or scheduled messages will be delivered. Alerts still get recorded to history."}),e.enabled&&x.jsxs(x.Fragment,{children:[x.jsxs("div",{className:"space-y-3 p-4 bg-[#0a0e17] rounded-lg border border-[#1e2a3a]",children:[x.jsxs("div",{className:"flex items-center gap-2",children:[x.jsx(ece,{size:14,className:"text-slate-400"}),x.jsx("label",{className:"text-xs text-slate-500 uppercase tracking-wide",children:"Quiet Hours"})]}),x.jsx(rS,{label:"Enable Quiet Hours",checked:e.quiet_hours_enabled??!0,onChange:B=>t({...e,quiet_hours_enabled:B}),helper:"Suppress non-emergency alerts during sleeping hours",info:"When enabled, alerts below emergency severity are held during quiet hours. When disabled, all alerts deliver anytime."}),e.quiet_hours_enabled&&x.jsxs(x.Fragment,{children:[x.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[x.jsx(nS,{label:"Start Time",value:e.quiet_hours_start||"22:00",onChange:B=>t({...e,quiet_hours_start:B}),helper:"When quiet hours begin"}),x.jsx(nS,{label:"End Time",value:e.quiet_hours_end||"06:00",onChange:B=>t({...e,quiet_hours_end:B}),helper:"When quiet hours end"})]}),x.jsx("p",{className:"text-xs text-slate-600",children:'Emergency alerts and rules with "Override Quiet Hours" enabled always deliver.'})]})]}),x.jsxs("div",{className:"space-y-3",children:[x.jsxs("div",{className:"flex items-center justify-between",children:[x.jsxs("label",{className:"flex items-center text-xs text-slate-500 uppercase tracking-wide",children:["Notification Rules",x.jsx(No,{info:"Each rule is self-contained: define what triggers it (condition or schedule), where to send it (mesh, email, webhook), and behavior settings."})]}),x.jsxs("span",{className:"text-xs text-slate-500",children:[((D=e.rules)==null?void 0:D.length)||0," rule",(((N=e.rules)==null?void 0:N.length)||0)!==1?"s":""]})]}),(e.rules||[]).map((B,$)=>x.jsx(ret,{rule:B,categories:i,quietHoursEnabled:e.quiet_hours_enabled??!0,onChange:F=>{const G=[...e.rules||[]];G[$]=F,t({...e,rules:G})},onDelete:()=>{confirm(`Delete rule "${B.name||"New Rule"}"?`)&&t({...e,rules:(e.rules||[]).filter((F,G)=>G!==$)})},onDuplicate:()=>I($),onTest:()=>O($)},$)),x.jsxs("div",{className:"flex gap-2",children:[x.jsxs("button",{onClick:P,className:"flex-1 py-3 border border-dashed border-[#1e2a3a] rounded-lg text-slate-500 hover:text-slate-300 hover:border-accent flex items-center justify-center gap-2 transition-colors",children:[x.jsx(bS,{size:16})," Add Rule"]}),x.jsxs("div",{className:"relative",children:[x.jsxs("button",{onClick:()=>y(!m),className:"py-3 px-4 border border-dashed border-[#1e2a3a] rounded-lg text-slate-500 hover:text-slate-300 hover:border-accent flex items-center gap-2 transition-colors",children:[x.jsx(xZ,{size:16})," Add from Template"]}),m&&x.jsxs(x.Fragment,{children:[x.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>y(!1)}),x.jsxs("div",{className:"absolute right-0 top-full mt-2 z-50 w-80 bg-[#1a2332] border border-[#2a3a4a] rounded-lg shadow-xl overflow-hidden",children:[x.jsx("div",{className:"p-2 border-b border-[#2a3a4a] text-xs text-slate-500 uppercase",children:"Rule Templates"}),$U.map(B=>x.jsxs("button",{onClick:()=>k(B.id),className:"w-full p-3 text-left hover:bg-[#2a3a4a] transition-colors",children:[x.jsx("div",{className:"font-medium text-slate-200",children:B.name}),x.jsx("div",{className:"text-xs text-slate-500 mt-0.5",children:B.description})]},B.id))]})]})]})]})]})]})]})]}):x.jsx("div",{className:"flex items-center justify-center h-64",children:x.jsx("div",{className:"text-red-400",children:"Failed to load notifications config"})})}const VU=[{id:"stream-gauges",label:"Stream Gauges",icon:zE},{id:"wildfire",label:"Wildfire",icon:VE},{id:"firms",label:"Satellite Fire Detection (FIRMS)",icon:WE},{id:"weather-alerts",label:"Weather Alerts",icon:Yue},{id:"solar",label:"Solar & Geomagnetic",icon:Vb},{id:"ducting",label:"Tropospheric Ducting",icon:tu},{id:"avalanche",label:"Avalanche Danger",icon:GE},{id:"traffic",label:"Traffic Flow",icon:BE},{id:"roads-511",label:"Road Conditions (511)",icon:gZ},{id:"mesh-health",label:"Mesh Health",icon:Wy},{id:"notifications",label:"Notifications",icon:_m},{id:"commands",label:"Commands",icon:CZ},{id:"api",label:"API Reference",icon:Xue}];function ar({color:e}){const t={green:"bg-green-500",yellow:"bg-yellow-500",orange:"bg-orange-500",red:"bg-red-500",black:"bg-slate-800 border border-slate-600"};return x.jsx("span",{className:`inline-block w-3 h-3 rounded-full ${t[e]}`})}function Rt({headers:e,rows:t}){return x.jsx("div",{className:"overflow-x-auto my-4",children:x.jsxs("table",{className:"w-full text-sm",children:[x.jsx("thead",{children:x.jsx("tr",{className:"bg-[#1a2332] border-b border-[#2a3a4a]",children:e.map((r,n)=>x.jsx("th",{className:"px-4 py-2 text-left text-slate-400 font-medium",children:r},n))})}),x.jsx("tbody",{children:t.map((r,n)=>x.jsx("tr",{className:`border-b border-[#1e2a3a] ${n%2===0?"bg-[#0d1219]":"bg-[#0a0e17]"}`,children:r.map((i,a)=>x.jsx("td",{className:"px-4 py-2 text-slate-300",children:i},a))},n))})]})})}function Bt({href:e,children:t}){return x.jsxs("a",{href:e,target:"_blank",rel:"noopener noreferrer",className:"text-accent hover:underline inline-flex items-center gap-1",children:[t," ",x.jsx(xd,{size:12})]})}function Te({children:e}){return x.jsx("h3",{className:"text-lg font-semibold text-slate-200 mt-6 mb-3",children:e})}function cl({children:e}){return x.jsx("h4",{className:"text-base font-medium text-slate-300 mt-4 mb-2",children:e})}function Ve({children:e}){return x.jsx("code",{className:"font-mono text-accent bg-[#1a2332] px-1 rounded",children:e})}function pi({id:e,title:t,children:r}){return x.jsxs("section",{id:e,className:"mb-12 scroll-mt-6",children:[x.jsx("h2",{className:"text-2xl font-bold text-slate-100 mb-4 pb-2 border-b border-[#2a3a4a]",children:t}),x.jsx("div",{className:"text-slate-300 leading-relaxed space-y-4",children:r})]})}function iet(){const e=fv(),[t,r]=W.useState(""),[n,i]=W.useState("stream-gauges"),a=W.useRef(null);W.useEffect(()=>{const l=e.hash.replace("#","");if(l&&VU.find(u=>u.id===l)){i(l);const u=document.getElementById(l);u&&u.scrollIntoView({behavior:"smooth"})}},[e.hash]);const o=VU.filter(l=>l.label.toLowerCase().includes(t.toLowerCase())),s=l=>{i(l);const u=document.getElementById(l);u&&u.scrollIntoView({behavior:"smooth"}),window.history.replaceState(null,"",`#${l}`)};return x.jsxs("div",{className:"flex h-full -m-6",children:[x.jsxs("aside",{className:"w-64 flex-shrink-0 bg-bg-card border-r border-border overflow-y-auto",children:[x.jsx("div",{className:"p-4 border-b border-border",children:x.jsxs("div",{className:"relative",children:[x.jsx(HE,{size:16,className:"absolute left-3 top-1/2 -translate-y-1/2 text-slate-500"}),x.jsx("input",{type:"text",value:t,onChange:l=>r(l.target.value),placeholder:"Search topics...",className:"w-full pl-9 pr-3 py-2 bg-[#0a0e17] border border-[#1e2a3a] rounded text-sm text-slate-200 focus:outline-none focus:border-accent placeholder-slate-600"})]})}),x.jsx("nav",{className:"py-2",children:o.map(l=>{const u=l.icon,c=n===l.id;return x.jsxs("button",{onClick:()=>s(l.id),className:`w-full flex items-center gap-3 px-4 py-2.5 text-sm text-left transition-colors ${c?"text-accent bg-accent/10 border-l-2 border-accent":"text-slate-400 hover:text-slate-200 hover:bg-bg-hover border-l-2 border-transparent"}`,children:[x.jsx(u,{size:16}),l.label]},l.id)})})]}),x.jsx("div",{ref:a,className:"flex-1 overflow-y-auto p-6",children:x.jsxs("div",{className:"max-w-4xl",children:[x.jsx("p",{className:"text-slate-400 mb-8",children:"Everything you need to understand and configure MeshAI's monitoring and alerting systems."}),x.jsxs(pi,{id:"stream-gauges",title:"Stream Gauges",children:[x.jsx(Te,{children:"What You're Looking At"}),x.jsx("p",{children:"MeshAI watches river and stream levels at gauges you configure. Each gauge reports two things:"}),x.jsxs("p",{children:[x.jsx("strong",{children:"Water Level (Gage Height)"}),` — how high the water is, measured in feet. Important: this is NOT the depth of the river. It's the height above a fixed measuring point that's different at every gauge. A reading of "10 feet" at one gauge means something completely different than "10 feet" at another. You can only compare readings from the SAME gauge over time.`]}),x.jsxs("p",{children:[x.jsx("strong",{children:"Flow (Discharge)"}),` — how much water is moving past the gauge, in cubic feet per second (CFS). Think of it as the river's "throughput." For scale:`]}),x.jsxs("ul",{className:"list-disc list-inside ml-4 space-y-1",children:[x.jsx("li",{children:"A small creek: 50-200 CFS"}),x.jsx("li",{children:"A mid-size river: 1,000-5,000 CFS"}),x.jsx("li",{children:"A big river in spring runoff: 10,000+ CFS"})]}),x.jsx(Te,{children:"When Does It Flood?"}),x.jsxs("p",{children:["Flood levels are set by the ",x.jsx("strong",{children:"National Weather Service"}),', not USGS. NWS looks at each specific gauge location and decides "at what water level does the road flood? At what level do buildings get water?" Those levels are different everywhere.']}),x.jsxs("p",{children:[x.jsx("strong",{children:"Action Stage"})," — water is rising, time to start paying attention. Usually still inside the riverbanks."]}),x.jsxs("p",{children:[x.jsx("strong",{children:"Minor Flood"})," — low-lying roads start getting water on them. NWS issues a Flood Advisory."]}),x.jsxs("p",{children:[x.jsx("strong",{children:"Moderate Flood"})," — water in buildings near the river. Some people need to evacuate. NWS issues a Flood Warning."]}),x.jsxs("p",{children:[x.jsx("strong",{children:"Major Flood"})," — widespread flooding. Many people evacuating. Serious property damage."]}),x.jsx("p",{children:"MeshAI automatically looks up the flood levels for your gauge from NWS when you add a site. Some remote gauges don't have flood levels assigned — for those, you set them manually if you know what water levels cause problems in your area."}),x.jsx(Te,{children:"Low Water / Drought"}),x.jsx("p",{children:`There's no official "drought stage" for most gauges. If you need to monitor low water (irrigation, fish habitat), set a manual low-water threshold based on what you know about your local river.`}),x.jsx(Te,{children:"Setting It Up"}),x.jsxs("ol",{className:"list-decimal list-inside ml-4 space-y-1",children:[x.jsxs("li",{children:["Find your gauge at ",x.jsx(Bt,{href:"https://waterdata.usgs.gov/nwis",children:"waterdata.usgs.gov/nwis"})]}),x.jsxs("li",{children:["Copy the site number (like ",x.jsx(Ve,{children:"13090500"}),")"]}),x.jsx("li",{children:"Add it in Config → Environmental → USGS"}),x.jsx("li",{children:"MeshAI auto-fills the gauge name and flood levels from NWS"})]}),x.jsx("p",{children:"If NWS flood levels don't populate, your gauge may not have them. Set manual thresholds if you know your local conditions."}),x.jsx(Te,{children:"Learn More"}),x.jsxs("ul",{className:"list-disc list-inside ml-4 space-y-1",children:[x.jsxs("li",{children:[x.jsx(Bt,{href:"https://waterdata.usgs.gov/nwis",children:"USGS Water Data"})," — find gauges near you"]}),x.jsxs("li",{children:[x.jsx(Bt,{href:"https://water.noaa.gov",children:"NWS Water Prediction Service"})," — flood forecasts and thresholds"]}),x.jsxs("li",{children:[x.jsx(Bt,{href:"https://www.usgs.gov/special-topics/water-science-school/science/how-streamflow-measured",children:"Understanding Streamflow"})," — USGS explainer"]})]})]}),x.jsxs(pi,{id:"wildfire",title:"Wildfire",children:[x.jsx(Te,{children:"What You're Looking At"}),x.jsx("p",{children:"MeshAI tracks active wildfire perimeters from the National Interagency Fire Center (NIFC). For each fire, you see the name, size, how much is contained, and how far it is from your mesh nodes."}),x.jsx(Te,{children:"Fire Size — How Big Is It?"}),x.jsx(Rt,{headers:["Size","What That Means"],rows:[["10 acres","Small fire. Usually handled quickly by initial crews."],["100 acres","Notable fire. Active firefighting effort."],["1,000 acres","Large fire. Major resources being deployed."],["10,000+ acres","Very large fire. Multiple teams, aircraft, heavy equipment."],["100,000+ acres","Mega-fire. These make the national news."]]}),x.jsx("p",{children:"For reference, 1,000 acres is about 1.5 square miles."}),x.jsx(Te,{children:"Containment — Is It Under Control?"}),x.jsx("p",{children:"Containment means the percentage of the fire's edge where firefighters have built a control line (a cleared strip to stop the fire from spreading further). It does NOT mean the fire is out inside that line."}),x.jsxs("ul",{className:"list-disc list-inside ml-4 space-y-1",children:[x.jsxs("li",{children:[x.jsx("strong",{children:"0-30%"})," — Essentially uncontrolled. The fire goes where it wants."]}),x.jsxs("li",{children:[x.jsx("strong",{children:"50%"})," — Good progress, but half the edge can still grow."]}),x.jsxs("li",{children:[x.jsx("strong",{children:"80%+"})," — Well controlled. Major growth unlikely."]}),x.jsxs("li",{children:[x.jsx("strong",{children:"100%"}),' — The edge is fully controlled. But the fire may STILL be actively burning inside. "100% contained" does NOT mean "out."']})]}),x.jsx(Te,{children:"How Far Away Should I Worry?"}),x.jsx(Rt,{headers:["Distance","What To Do"],rows:[[x.jsxs(x.Fragment,{children:[x.jsx(ar,{color:"red"})," Under 5 km (3 miles)"]}),x.jsxs(x.Fragment,{children:[x.jsx("strong",{children:"Immediate threat."})," This is evacuation-order range. Embers can fly this far in wind."]})],[x.jsxs(x.Fragment,{children:[x.jsx(ar,{color:"orange"})," 5-15 km (3-10 miles)"]}),x.jsxs(x.Fragment,{children:[x.jsx("strong",{children:"Prepare."})," The fire could reach you in hours under bad conditions. Have a plan."]})],[x.jsxs(x.Fragment,{children:[x.jsx(ar,{color:"yellow"})," 15-30 km (10-20 miles)"]}),x.jsxs(x.Fragment,{children:[x.jsx("strong",{children:"Watch."})," Smoke is likely. Wind shifts could change things fast."]})],[x.jsxs(x.Fragment,{children:[x.jsx(ar,{color:"green"})," Over 30 km (20 miles)"]}),x.jsxs(x.Fragment,{children:[x.jsx("strong",{children:"Awareness."})," Keep an eye on it, but no immediate threat."]})]]}),x.jsx("p",{children:"How fast can a fire travel? In grass with wind: up to 14 mph. In heavy timber: 1-6 mph. A fire 10 miles away could theoretically reach you in 1-2 hours under worst-case conditions, but typical spread is much slower."}),x.jsx(Te,{children:"Which Matters More — Size or Distance?"}),x.jsxs("p",{children:[x.jsx("strong",{children:"Distance is the immediate concern."})," A small uncontained fire 10 km away is more dangerous right now than a huge fire 50 km away. But big fires have more energy and can grow fast under wind shifts — keep watching them."]}),x.jsx(Te,{children:"Setting It Up"}),x.jsxs("p",{children:["Just configure your state code (like ",x.jsx(Ve,{children:"US-ID"})," for Idaho) in Config → Environmental → Fires. MeshAI polls NIFC every 10 minutes for active fires in that state and computes the distance to your mesh nodes automatically."]}),x.jsx(Te,{children:"Learn More"}),x.jsxs("ul",{className:"list-disc list-inside ml-4 space-y-1",children:[x.jsxs("li",{children:[x.jsx(Bt,{href:"https://inciweb.nwcg.gov",children:"InciWeb"})," — detailed incident information"]}),x.jsxs("li",{children:[x.jsx(Bt,{href:"https://data-nifc.opendata.arcgis.com",children:"NIFC Fire Map"})," — raw perimeter data"]}),x.jsxs("li",{children:[x.jsx(Bt,{href:"https://www.ready.gov/wildfires",children:"Ready.gov Wildfires"})," — preparedness guide"]})]})]}),x.jsxs(pi,{id:"firms",title:"Satellite Fire Detection (FIRMS)",children:[x.jsx(Te,{children:"What You're Looking At"}),x.jsx("p",{children:`NASA's VIIRS satellites orbit the Earth and look for heat signatures on the ground. When they see something hot — a fire, a factory, a sunlit building — they flag it as a "hotspot." MeshAI checks these detections for your area.`}),x.jsxs("p",{children:[x.jsx("strong",{children:"Why this matters"}),": satellite hotspots show up ",x.jsx("strong",{children:"hours before"})," official fire perimeters are mapped. If a new fire starts near your mesh, the satellite might see it before anyone on the ground reports it."]}),x.jsx(Te,{children:"Confidence — Is It Really a Fire?"}),x.jsx("p",{children:"Each detection gets a confidence rating:"}),x.jsx(Rt,{headers:["Confidence","What It Means"],rows:[["High","Almost certainly a real fire. Strong heat signature."],["Nominal","Probably a real fire. Most actual fires get this rating."],["Low","Maybe a fire, maybe not. Could be a hot roof, sun reflecting off water, a factory, or a gas flare. Lots of false alarms."]]}),x.jsxs("p",{children:[x.jsx("strong",{children:"Recommendation"}),`: Set the filter to "Nominal + High." If you include "Low" you'll get alerts for every hot parking lot on a summer day.`]}),x.jsx(Te,{children:"FRP — How Intense Is It?"}),x.jsx("p",{children:'FRP (Fire Radiative Power) measures the heat output in megawatts. Think of it as "how hot is this thing":'}),x.jsx(Rt,{headers:["FRP","What It Probably Is"],rows:[["Under 5 MW","Hot surface, small agricultural burn, gas flare, or warm ground"],["5-50 MW","An actual fire — brush fire, grass fire, typical wildfire"],["50-300 MW","Intense fire — trees fully burning, active fire front"],["Over 300 MW","Extreme fire — major wildfire in full force"]]}),x.jsx("p",{children:"Setting the minimum FRP to 5 MW filters out most industrial and agricultural false alarms."}),x.jsx(Te,{children:"New Ignition Detection"}),x.jsxs("p",{children:["MeshAI cross-references satellite hotspots against known NIFC fire perimeters. If a hotspot is NOT near any known fire, it gets flagged as a ",x.jsx("strong",{children:"potential new ignition"})," — maybe a new fire just started. These get elevated priority regardless of confidence level."]}),x.jsx(Te,{children:"Timing"}),x.jsxs("p",{children:["Satellite data arrives ",x.jsx("strong",{children:"1-3 hours"})," after the satellite passes overhead. Each location gets observed about ",x.jsx("strong",{children:"6 times per day"}),` across all satellites, so there are multi-hour gaps. This is not real-time — it's "pretty recent."`]}),x.jsx(Te,{children:"Getting an API Key"}),x.jsxs("ol",{className:"list-decimal list-inside ml-4 space-y-1",children:[x.jsxs("li",{children:["Go to ",x.jsx(Bt,{href:"https://firms.modaps.eosdis.nasa.gov/api/area/",children:"FIRMS API page"})]}),x.jsx("li",{children:'Click "Get MAP_KEY"'}),x.jsx("li",{children:"Register for a free Earthdata account"}),x.jsx("li",{children:"Your key arrives by email"}),x.jsx("li",{children:"Enter it in Config → Environmental → FIRMS"})]}),x.jsx(Te,{children:"Learn More"}),x.jsxs("ul",{className:"list-disc list-inside ml-4 space-y-1",children:[x.jsxs("li",{children:[x.jsx(Bt,{href:"https://firms.modaps.eosdis.nasa.gov",children:"FIRMS Fire Map"})," — see hotspots on a map"]}),x.jsxs("li",{children:[x.jsx(Bt,{href:"https://earthdata.nasa.gov/data/tools/firms/faq",children:"FIRMS FAQ"})," — how it works"]})]})]}),x.jsxs(pi,{id:"weather-alerts",title:"Weather Alerts",children:[x.jsx(Te,{children:"What You're Looking At"}),x.jsx("p",{children:"MeshAI watches for NWS (National Weather Service) alerts affecting your area — warnings, watches, and advisories."}),x.jsx(Te,{children:"Alert Severity — How Serious Is It?"}),x.jsx(Rt,{headers:["Severity","What It Means","Example"],rows:[["Extreme","Life-threatening. The most serious events.","Tornado Emergency, Hurricane Warning, Tsunami Warning"],["Severe","Dangerous. Take protective action.","Tornado Warning, Flash Flood Warning, Blizzard Warning, Red Flag Warning"],["Moderate","Be prepared. Could become dangerous.","Winter Weather Advisory, Wind Advisory, Flood Watch, Heat Advisory"],["Minor","Good to know. Probably won't hurt anyone.","Special Weather Statement, Air Quality Alert"]]}),x.jsx(Te,{children:"When Should I Act? (Urgency)"}),x.jsx(Rt,{headers:["Urgency","What It Means"],rows:[["Immediate","Do something NOW"],["Expected","Do something within the hour"],["Future","Coming in the next several hours"],["Past","It's over — NWS is clearing the alert"]]}),x.jsx(Te,{children:"How Sure Are They? (Certainty)"}),x.jsx(Rt,{headers:["Certainty","What It Means"],rows:[["Observed","It's happening right now. Verified."],["Likely","More than 50% chance"],["Possible","Could happen, but less than 50%"],["Unlikely","Probably won't, but mentioned for awareness"]]}),x.jsx(Te,{children:"These Are Separate Scales"}),x.jsx("p",{children:'A single alert has all three. A hurricane warning for next week is "Severe + Future + Likely." A tornado spotted on the ground is "Extreme + Immediate + Observed." An air quality advisory is "Minor + Expected + Possible."'}),x.jsx(Te,{children:"What Minimum Severity Should I Set?"}),x.jsx(Rt,{headers:["Setting","What You Get","What You Miss"],rows:[["Minor","Everything — high volume","Nothing"],[x.jsxs(x.Fragment,{children:[x.jsx("strong",{children:"Moderate"})," ✓"]}),"Watches, Advisories, and Warnings","Special Weather Statements"],["Severe","Only Warnings — things happening NOW","Watches (which give you hours of advance warning)"],["Extreme","Only the rarest events","Most Tornado and Severe Thunderstorm Warnings"]]}),x.jsxs("p",{children:[x.jsx("strong",{children:"Moderate is recommended."})," It catches Watches (advance warning that conditions may worsen) and Advisories (conditions exist but aren't severe) while filtering out the informational stuff."]}),x.jsx(Te,{children:"Finding Your NWS Zone"}),x.jsxs("ol",{className:"list-decimal list-inside ml-4 space-y-1",children:[x.jsxs("li",{children:["Go to ",x.jsx(Bt,{href:"https://www.weather.gov",children:"weather.gov"})]}),x.jsx("li",{children:"Enter your location"}),x.jsxs("li",{children:["Find your zone code at ",x.jsx(Bt,{href:"https://www.weather.gov/pimar/PubZone",children:"NWS Zone Map"})]}),x.jsxs("li",{children:["Zone codes look like: ",x.jsx(Ve,{children:"IDZ016"}),", ",x.jsx(Ve,{children:"UTZ040"}),", etc."]})]}),x.jsx(Te,{children:"The User-Agent Field"}),x.jsx("p",{children:"NWS wants to know who's using their API — not for approval, just so they can contact you if something breaks. You make it up:"}),x.jsx("p",{children:x.jsx(Ve,{children:"(meshai, you@email.com)"})}),x.jsx("p",{children:"No registration. No waiting. Just type it in."}),x.jsx(Te,{children:"Learn More"}),x.jsxs("ul",{className:"list-disc list-inside ml-4 space-y-1",children:[x.jsxs("li",{children:[x.jsx(Bt,{href:"https://alerts.weather.gov",children:"NWS Active Alerts"})," — see current alerts"]}),x.jsxs("li",{children:[x.jsx(Bt,{href:"https://www.weather.gov/documentation/services-web-api",children:"NWS API Docs"})," — technical details"]})]})]}),x.jsxs(pi,{id:"solar",title:"Solar & Geomagnetic Conditions",children:[x.jsx(Te,{children:"What You're Looking At"}),x.jsx("p",{children:"MeshAI tracks space weather — solar activity and its effects on Earth's magnetic field. This matters for radio operators because the sun directly controls how well HF radio works, and major solar events can affect all radio communications."}),x.jsx(Te,{children:"Solar Flux Index (SFI)"}),x.jsx("p",{children:'Think of SFI as a "how active is the sun" number. Higher = better for HF radio, but also higher risk of solar flares.'}),x.jsx(Rt,{headers:["SFI","What It Means for You"],rows:[["Below 70","Quiet sun. Higher HF bands (10m, 15m) are probably dead. Stick to lower bands."],["70-90","Getting better. Some openings on 15m and above, but inconsistent."],["90-120","Good. Most HF bands work. Reliable contacts on 20m and 15m."],["120-170","Great. All HF bands open. 10m works for worldwide contacts."],["Above 170","Excellent. Best HF conditions — but watch for flares."]]}),x.jsxs("p",{children:[x.jsx("strong",{children:"Quick rule"}),": SFI above 90 and Kp below 4 = good day for HF radio."]}),x.jsx(Te,{children:"Kp Index"}),x.jsx("p",{children:"Kp measures how disturbed Earth's magnetic field is, on a 0-9 scale. Higher = more disturbance = worse for HF radio but better for aurora viewing."}),x.jsx(Rt,{headers:["Kp","What It Means for You"],rows:[["0-2","Quiet. Best HF conditions."],["3","Slightly unsettled. You probably won't notice."],["4","Active. Some noise and fading on HF, especially if you're at higher latitudes."],[x.jsx("strong",{children:"5"}),x.jsxs(x.Fragment,{children:[x.jsx("strong",{children:"Minor storm (G1)."})," HF noticeably degraded. Aurora visible at high latitudes (~60°N)."]})],[x.jsx("strong",{children:"6"}),x.jsxs(x.Fragment,{children:[x.jsx("strong",{children:"Moderate storm (G2)."})," HF getting rough. Aurora moving south (~55°N)."]})],[x.jsx("strong",{children:"7"}),x.jsxs(x.Fragment,{children:[x.jsx("strong",{children:"Strong storm (G3)."})," HF unreliable for 1-2 days. Aurora at mid-latitudes."]})],[x.jsx("strong",{children:"8-9"}),x.jsxs(x.Fragment,{children:[x.jsx("strong",{children:"Severe/Extreme storm."})," HF may black out completely. Aurora visible at very low latitudes. Power grid stress possible."]})]]}),x.jsx(Te,{children:"R / S / G Scales"}),x.jsx("p",{children:"NOAA's shorthand for three types of space weather events:"}),x.jsx(cl,{children:"R (Radio Blackouts) — from solar flares:"}),x.jsxs("ul",{className:"list-disc list-inside ml-4 space-y-1",children:[x.jsx("li",{children:"R1-R2: Brief HF disruption. You might not notice."}),x.jsx("li",{children:"R3: HF goes out for about an hour on the sunlit side of Earth."}),x.jsx("li",{children:"R4-R5: HF dead for hours. Serious."})]}),x.jsx(cl,{children:"S (Solar Radiation Storms) — from energetic particles:"}),x.jsxs("ul",{className:"list-disc list-inside ml-4 space-y-1",children:[x.jsx("li",{children:"Mostly affects polar regions and satellites"}),x.jsx("li",{children:"S3+: Polar HF goes out entirely"})]}),x.jsx(cl,{children:"G (Geomagnetic Storms) — from solar wind disturbances:"}),x.jsx("ul",{className:"list-disc list-inside ml-4 space-y-1",children:x.jsx("li",{children:"Same as the Kp scale: G1 = Kp 5, up to G5 = Kp 9"})}),x.jsx(Te,{children:"Bz — The Storm Predictor"}),x.jsx("p",{children:"Bz measures the direction of the solar wind's magnetic field. When it points south (negative values), the solar wind can dump energy into Earth's magnetic field, causing storms."}),x.jsx(Rt,{headers:["Bz","What It Means"],rows:[["Positive","All good. Solar wind bouncing off."],["0 to -5","Slight coupling. Nothing dramatic."],["-5 to -10","Things starting to pick up. Storm possible."],["Below -10","Storm likely. Kp will start climbing."],["Below -20","Severe storm probable."]]}),x.jsx("p",{children:"Bz can change fast — minute to minute. What matters is whether it stays negative for hours, not brief dips."}),x.jsx(Te,{children:"Learn More"}),x.jsxs("ul",{className:"list-disc list-inside ml-4 space-y-1",children:[x.jsxs("li",{children:[x.jsx(Bt,{href:"https://www.swpc.noaa.gov",children:"SWPC Space Weather Dashboard"})," — live data"]}),x.jsxs("li",{children:[x.jsx(Bt,{href:"https://www.swpc.noaa.gov/noaa-scales-explanation",children:"NOAA Space Weather Scales"})," — what R/S/G mean"]}),x.jsxs("li",{children:[x.jsx(Bt,{href:"https://www.hamqsl.com/solar.html",children:"HamQSL Solar Page"})," — ham-friendly display"]}),x.jsxs("li",{children:[x.jsx(Bt,{href:"https://www.swpc.noaa.gov/products/planetary-k-index",children:"Planetary K-Index"})," — live Kp"]})]})]}),x.jsxs(pi,{id:"ducting",title:"Tropospheric Ducting",children:[x.jsx(Te,{children:"What You're Looking At"}),x.jsx("p",{children:'Sometimes the atmosphere creates an invisible "pipe" that traps radio signals and carries them much farther than normal. This is called tropospheric ducting. It mostly affects VHF and UHF frequencies.'}),x.jsx("p",{children:"MeshAI watches for these conditions by analyzing weather data (temperature and humidity at different altitudes) over your mesh area."}),x.jsx(Te,{children:"How Do I Know If Ducting Is Happening?"}),x.jsx("p",{children:'MeshAI reports a "condition" based on the atmospheric profile:'}),x.jsx(Rt,{headers:["Condition","What It Means"],rows:[["Normal","Standard propagation. Nothing unusual."],["Super-refraction","Slightly enhanced range. You might hear a few more distant stations than usual."],["Surface Duct","Radio signals trapped near the ground. You may hear stations hundreds of km away that you've never heard before."],["Elevated Duct",'Same effect but the "pipe" is up in the atmosphere. Affects signals passing through that altitude.']]}),x.jsx(Te,{children:"What You'll Actually Notice"}),x.jsx("p",{children:"When ducting happens on your mesh:"}),x.jsxs("ul",{className:"list-disc list-inside ml-4 space-y-1",children:[x.jsx("li",{children:"Distant repeaters you've never heard suddenly come in"}),x.jsx("li",{children:"Nodes appear from far outside your normal range"}),x.jsx("li",{children:"You hear FM radio stations from other cities"}),x.jsx("li",{children:"ADS-B flight tracking range gets much longer"}),x.jsx("li",{children:"There might be interference from distant stations on your frequency"})]}),x.jsx(Te,{children:"The dM/dz Number"}),x.jsx("p",{children:`The dashboard shows a "dM/dz" value in "M-units/km." You don't need to understand the math — just know:`}),x.jsxs("ul",{className:"list-disc list-inside ml-4 space-y-1",children:[x.jsxs("li",{children:[x.jsx("strong",{children:"Around 118"})," = normal atmosphere"]}),x.jsxs("li",{children:[x.jsx("strong",{children:"Below 79"})," = enhanced propagation starting"]}),x.jsxs("li",{children:[x.jsx("strong",{children:"Below 0 (negative)"})," = ducting is happening"]}),x.jsxs("li",{children:[x.jsx("strong",{children:"Below -50"})," = strong ducting — classic VHF/UHF DX event"]})]}),x.jsx(Te,{children:"When Does Ducting Happen?"}),x.jsxs("ul",{className:"list-disc list-inside ml-4 space-y-1",children:[x.jsx("li",{children:"Under high-pressure weather systems (clear, stable air)"}),x.jsx("li",{children:"When warm air sits on top of cool air (temperature inversion)"}),x.jsx("li",{children:"Most common in late summer and early fall"}),x.jsx("li",{children:"Strongest along coastlines and over water"}),x.jsx("li",{children:"In mountain valleys: cold air pooling in fall/winter can create surface ducts"})]}),x.jsx(Te,{children:"Setting It Up"}),x.jsx("p",{children:"Just configure the latitude and longitude of the center of your mesh area in Config → Environmental → Ducting. MeshAI checks the atmospheric conditions there every 3 hours using free weather model data. No API key needed."}),x.jsx(Te,{children:"Learn More"}),x.jsxs("ul",{className:"list-disc list-inside ml-4 space-y-1",children:[x.jsxs("li",{children:[x.jsx(Bt,{href:"https://dxinfocentre.com/tropo.html",children:"Tropo Forecast Maps (Hepburn)"})," — 6-day tropo prediction"]}),x.jsxs("li",{children:[x.jsx(Bt,{href:"https://dxmaps.com",children:"DX Maps"})," — real-time VHF/UHF propagation reports"]}),x.jsxs("li",{children:[x.jsx(Bt,{href:"https://en.wikipedia.org/wiki/Tropospheric_propagation",children:"Wikipedia: Tropospheric Propagation"})," — background"]})]})]}),x.jsxs(pi,{id:"avalanche",title:"Avalanche Danger",children:[x.jsx(Te,{children:"What You're Looking At"}),x.jsx("p",{children:"MeshAI pulls avalanche forecasts from your regional avalanche center during winter months. The danger scale has 5 levels and it's the same across all of North America."}),x.jsx(Te,{children:"The Danger Scale"}),x.jsx(Rt,{headers:["Level","Name","Color","What To Do"],rows:[["1","Low",x.jsx(ar,{color:"green"}),"Generally safe. Normal caution in steep terrain."],["2","Moderate",x.jsx(ar,{color:"yellow"}),"Be careful on specific terrain features. Evaluate conditions."],["3","Considerable",x.jsx(ar,{color:"orange"}),x.jsxs(x.Fragment,{children:[x.jsx("strong",{children:"DANGEROUS."}),` This is where most people die in avalanches — they see "3 out of 5" and think it's fine. It's not. Use extreme caution.`]})],["4","High",x.jsx(ar,{color:"red"}),x.jsxs(x.Fragment,{children:[x.jsx("strong",{children:"Very dangerous."})," Stay off anything steep."]})],["5","Extreme",x.jsx(ar,{color:"black"}),x.jsxs(x.Fragment,{children:[x.jsx("strong",{children:"Don't go out."})," Avalanches are happening on their own."]})]]}),x.jsx(Te,{children:"The Most Important Thing to Know"}),x.jsxs("p",{children:[x.jsx("strong",{children:"Level 3 (Considerable) kills more people than any other level."}),' People look at "3 out of 5" and think "middle of the road, probably okay." In reality, the risk roughly doubles at each step up the scale. Level 3 is where dangerous conditions overlap with people thinking they can handle it.']}),x.jsx(Te,{children:"Seasonal"}),x.jsx("p",{children:'MeshAI only checks avalanche conditions during winter months (configurable, default December through April). Outside season, it shows "off season" and saves API calls.'}),x.jsx(Te,{children:"Finding Your Avalanche Center"}),x.jsxs("p",{children:["Go to ",x.jsx(Bt,{href:"https://avalanche.org/avalanche-centers/",children:"avalanche.org/avalanche-centers/"})," for a map. Common center codes:"]}),x.jsxs("ul",{className:"list-disc list-inside ml-4 space-y-1",children:[x.jsxs("li",{children:[x.jsx(Ve,{children:"SNFAC"})," — Sawtooth (central Idaho)"]}),x.jsxs("li",{children:[x.jsx(Ve,{children:"UAC"})," — Utah"]}),x.jsxs("li",{children:[x.jsx(Ve,{children:"NWAC"})," — Cascades/Olympics (WA/OR)"]}),x.jsxs("li",{children:[x.jsx(Ve,{children:"CAIC"})," — Colorado"]}),x.jsxs("li",{children:[x.jsx(Ve,{children:"SAC"})," — Sierra Nevada (CA)"]}),x.jsxs("li",{children:[x.jsx(Ve,{children:"GNFAC"})," — Gallatin (SW Montana)"]})]}),x.jsx(Te,{children:"Learn More"}),x.jsxs("ul",{className:"list-disc list-inside ml-4 space-y-1",children:[x.jsxs("li",{children:[x.jsx(Bt,{href:"https://avalanche.org",children:"Avalanche.org"})," — US forecasts"]}),x.jsxs("li",{children:[x.jsx(Bt,{href:"https://avalanche.org/avalanche-encyclopedia/human/resources/north-american-public-avalanche-danger-scale/",children:"Avalanche Danger Scale"})," — full scale explanation"]}),x.jsxs("li",{children:[x.jsx(Bt,{href:"https://kbyg.org",children:"Know Before You Go"})," — avalanche awareness"]})]})]}),x.jsxs(pi,{id:"traffic",title:"Traffic Flow",children:[x.jsx(Te,{children:"What You're Looking At"}),x.jsx("p",{children:"MeshAI monitors traffic speed on road segments you configure, using data from TomTom (real vehicles with navigation apps reporting their speed)."}),x.jsx(Te,{children:"Speed Ratio — The Key Number"}),x.jsx("p",{children:'MeshAI compares current speed to "free-flow speed" (what traffic normally does when the road is empty). The ratio tells you how congested it is:'}),x.jsx(Rt,{headers:["Ratio","What It Means"],rows:[[x.jsxs(x.Fragment,{children:[x.jsx(ar,{color:"green"})," Above 85%"]}),"Normal. Traffic flowing fine."],[x.jsxs(x.Fragment,{children:[x.jsx(ar,{color:"yellow"})," 65-85%"]}),"Slow. Heavier than usual but moving."],[x.jsxs(x.Fragment,{children:[x.jsx(ar,{color:"orange"})," 40-65%"]}),"Congested. Significant delays."],[x.jsxs(x.Fragment,{children:[x.jsx(ar,{color:"red"})," Below 40%"]}),"Gridlock. Barely moving."]]}),x.jsxs("p",{children:[x.jsx("strong",{children:"Note"}),`: "free-flow speed" is NOT the speed limit. It's what traffic actually does on that road when nobody's in the way. Drivers often exceed speed limits on open highways.`]}),x.jsx(Te,{children:"Confidence — Can You Trust the Data?"}),x.jsx("p",{children:"TomTom's confidence score tells you how much of the reading comes from real vehicles right now vs historical averages:"}),x.jsx(Rt,{headers:["Confidence","What It Means"],rows:[["Above 0.9","Very reliable — lots of real-time probe data"],["0.7-0.9","Good — mix of real-time and historical"],["Below 0.7",x.jsxs(x.Fragment,{children:[x.jsx("strong",{children:"Unreliable"})," — mostly guessing from historical patterns. Don't alert on this."]})]]}),x.jsx("p",{children:"Set minimum confidence to 0.7 to avoid false congestion alerts at night or on rural roads where few probe vehicles drive."}),x.jsx(Te,{children:"Setting Up Corridors"}),x.jsx("p",{children:'Each "corridor" is a point on a road you want to monitor. To add one:'}),x.jsxs("ol",{className:"list-decimal list-inside ml-4 space-y-1",children:[x.jsx("li",{children:"Go to Google Maps, find the road"}),x.jsx("li",{children:`Right-click the road → "What's here?" → copy the coordinates`}),x.jsx("li",{children:"Add the corridor in Config with a name and those coordinates"}),x.jsx("li",{children:"TomTom finds the nearest road segment automatically"})]}),x.jsx(Te,{children:"Getting an API Key"}),x.jsxs("ol",{className:"list-decimal list-inside ml-4 space-y-1",children:[x.jsxs("li",{children:["Sign up at ",x.jsx(Bt,{href:"https://developer.tomtom.com",children:"developer.tomtom.com"})," (free)"]}),x.jsx("li",{children:"Create an app → get your API key"}),x.jsx("li",{children:"Free tier: 2,500 requests/day (plenty for 5-10 corridors)"})]}),x.jsx(Te,{children:"Learn More"}),x.jsxs("ul",{className:"list-disc list-inside ml-4 space-y-1",children:[x.jsxs("li",{children:[x.jsx(Bt,{href:"https://developer.tomtom.com",children:"TomTom Developer Portal"})," — API docs and key signup"]}),x.jsxs("li",{children:[x.jsx(Bt,{href:"https://www.tomtom.com/traffic-index/",children:"TomTom Traffic Index"})," — city congestion rankings"]})]})]}),x.jsxs(pi,{id:"roads-511",title:"Road Conditions (511)",children:[x.jsx(Te,{children:"What You're Looking At"}),x.jsx("p",{children:"511 systems report road closures, construction, weather events, mountain pass conditions, and incidents. Every state runs their own 511 system — there is no national API."}),x.jsx(Te,{children:"Setting It Up"}),x.jsx("p",{children:"You need to find YOUR state's 511 developer API. MeshAI does not include a default URL because every state is different. Some states have free public APIs, some require registration, and some don't have developer APIs at all."}),x.jsx("p",{children:"Configure in Config → Environmental → 511:"}),x.jsxs("ul",{className:"list-disc list-inside ml-4 space-y-1",children:[x.jsxs("li",{children:[x.jsx("strong",{children:"Base URL"})," — your state's API endpoint"]}),x.jsxs("li",{children:[x.jsx("strong",{children:"API Key"})," — if required by your state"]}),x.jsxs("li",{children:[x.jsx("strong",{children:"Endpoints"})," — which data feeds to poll (varies by state)"]})]}),x.jsx(Te,{children:"Learn More"}),x.jsx("p",{children:"Check your state's 511 or DOT website for developer information."})]}),x.jsxs(pi,{id:"mesh-health",title:"Mesh Health",children:[x.jsx(Te,{children:"Health Score"}),x.jsx("p",{children:"MeshAI computes a 0-100 health score for your mesh network by looking at five areas, each weighted differently:"}),x.jsx(Rt,{headers:["Pillar","Weight","What It Measures"],rows:[[x.jsx("strong",{children:"Infrastructure"}),"30%","Are your routers online?"],[x.jsx("strong",{children:"Utilization"}),"25%","Is the radio channel congested?"],[x.jsx("strong",{children:"Coverage"}),"20%","Do nodes have redundant paths to gateways?"],[x.jsx("strong",{children:"Behavior"}),"15%","Are any nodes flooding the channel?"],[x.jsx("strong",{children:"Power"}),"10%","Are battery-powered nodes running low?"]]}),x.jsx("p",{children:"The overall score is the weighted sum:"}),x.jsx("p",{className:"p-3 bg-slate-800 rounded font-mono text-sm",children:"Score = (Infrastructure × 30%) + (Utilization × 25%) + (Coverage × 20%) + (Behavior × 15%) + (Power × 10%)"}),x.jsx(Te,{children:"How Each Pillar Is Calculated"}),x.jsx(cl,{children:"Infrastructure (30%)"}),x.jsx("p",{children:"This is the simplest pillar — what percentage of your infrastructure nodes are currently online?"}),x.jsx("p",{className:"p-3 bg-slate-800 rounded font-mono text-sm",children:"(routers online ÷ total routers) × 100"}),x.jsxs("p",{children:["Only nodes with the ",x.jsx(Ve,{children:"ROUTER"}),", ",x.jsx(Ve,{children:"ROUTER_LATE"}),", or ",x.jsx(Ve,{children:"ROUTER_CLIENT"})," role count as infrastructure. Regular client nodes going offline doesn't affect this score. If you have 5 routers and 3 are online, infrastructure scores 60."]}),x.jsxs("p",{children:[x.jsx("strong",{children:"Special case:"})," If you have no routers at all (all clients), this pillar scores 100. You're not penalized for not having infrastructure — you just don't have any to track."]}),x.jsx(cl,{children:"Utilization (25%)"}),x.jsx("p",{children:"Estimates how much of the radio channel's airtime is being used. MeshAI can't measure airtime directly, so it estimates based on packet counts over the last 24 hours."}),x.jsxs("p",{className:"p-3 bg-slate-800 rounded font-mono text-sm",children:["packets_per_hour = non_text_packets ÷ 24",x.jsx("br",{}),"airtime_estimate = (packets_per_hour × 200ms) ÷ 3,600,000ms × 100%"]}),x.jsx("p",{children:"The 200ms is an approximation for the MediumFast radio preset — each LoRa packet takes roughly 200ms of airtime. Text messages don't count toward utilization (chatting is the point of a mesh)."}),x.jsx(Rt,{headers:["Estimated Airtime","Score","What It Means"],rows:[["Under 15%","100","Channel is clear — this is the goal"],["15-20%","75-100","Getting busy, but fine"],["20-25%","50-75","Congested — firmware starts throttling GPS"],["25-35%","25-50","Seriously congested — collisions happening"],["Over 35%","0-25","Channel is overwhelmed"]]}),x.jsxs("p",{children:[x.jsx("strong",{children:"Special case:"})," If MeshAI doesn't have packet data (no sources reporting packet counts), this pillar scores 100. You're not penalized for missing data."]}),x.jsx(cl,{children:"Coverage (20%)"}),x.jsx("p",{children:'Measures gateway redundancy — how many of your data sources can "see" each node. A node reported by all 3 of your gateways has full coverage. A node only seen by 1 gateway is a single point of failure.'}),x.jsxs("p",{className:"p-3 bg-slate-800 rounded font-mono text-sm",children:["coverage_ratio = average_gateways_per_node ÷ total_sources",x.jsx("br",{}),"single_gw_penalty = (single_gateway_nodes ÷ total_nodes) × 40"]}),x.jsx("p",{children:"If a node is seen by 2 out of 3 sources, its coverage ratio is 0.67. Infrastructure nodes with only single-gateway coverage get an extra penalty — they're critical but have no backup path."}),x.jsx(Rt,{headers:["Coverage Ratio","Base Score","After Penalty"],rows:[["100% (all sources)","100","100 minus single-gw penalty"],["70-99%","90","Minus penalties"],["50-69%","70","Minus penalties"],["Under 50%","50 or less","Heavy penalty"]]}),x.jsxs("p",{children:[x.jsx("strong",{children:"Special case:"})," With only 1 data source, this pillar can't score well — there's no redundancy to measure. Coverage becomes meaningful when you have 2+ sources (MeshMonitor + MQTT, multiple gateways, etc.)."]}),x.jsx(cl,{children:"Behavior (15%)"}),x.jsx("p",{children:"Counts how many nodes are sending an unusually high number of non-text packets. This catches firmware bugs, stuck transmitters, and misconfigured nodes that are flooding the channel."}),x.jsxs("p",{children:[x.jsx("strong",{children:"What counts as flooding:"})," More than 500 non-text packets in 24 hours. Text messages don't count — the behavior pillar only flags telemetry, position, and routing packet floods."]}),x.jsx(Rt,{headers:["Flagged Nodes","Score"],rows:[["0","100"],["1","80"],["2-3","60"],["4-5","40"],["6+","20"]]}),x.jsx("p",{children:"A single misbehaving node only drops the score to 80. It takes multiple problem nodes to seriously hurt the behavior pillar."}),x.jsx(cl,{children:"Power (10%)"}),x.jsx("p",{children:"Measures what fraction of battery-powered nodes are below the warning threshold (default 20%)."}),x.jsx("p",{className:"p-3 bg-slate-800 rounded font-mono text-sm",children:"100 × (1 − low_battery_nodes ÷ total_battery_nodes)"}),x.jsx("p",{children:"If 2 out of 10 battery nodes are below 20%, power scores 80."}),x.jsxs("p",{children:[x.jsx("strong",{children:"Important:"})," USB-powered nodes are excluded from this calculation. Many nodes report 100% battery even when running on wall power with no battery installed. Only nodes actually running on batteries affect this pillar."]}),x.jsx(Te,{children:"Health Tiers"}),x.jsx(Rt,{headers:["Score","Tier","What It Means"],rows:[["90-100",x.jsxs(x.Fragment,{children:[x.jsx(ar,{color:"green"})," Healthy"]}),"Everything's working well."],["75-89",x.jsxs(x.Fragment,{children:[x.jsx(ar,{color:"yellow"})," Slight degradation"]}),"Some issues but the mesh is functional."],["50-74",x.jsxs(x.Fragment,{children:[x.jsx(ar,{color:"orange"})," Unhealthy"]}),"Multiple problems. Reliability is affected."],["25-49",x.jsxs(x.Fragment,{children:[x.jsx(ar,{color:"red"})," Warning"]}),"Significant issues. The mesh is struggling."],["0-24",x.jsxs(x.Fragment,{children:[x.jsx(ar,{color:"black"})," Critical"]}),"Major failures. Barely functional."]]}),x.jsx(Te,{children:"Channel Utilization — Is the Radio Channel Full?"}),x.jsx("p",{children:"Meshtastic radios share one LoRa channel. If too many nodes are transmitting too often, they step on each other and messages get lost."}),x.jsx(Rt,{headers:["Utilization","What's Happening"],rows:[[x.jsxs(x.Fragment,{children:[x.jsx(ar,{color:"green"})," Under 25%"]}),"Healthy. The firmware itself starts throttling above 25% to protect the channel — so under 25% is the target."],[x.jsxs(x.Fragment,{children:[x.jsx(ar,{color:"yellow"})," 25-40%"]}),"Getting busy. Common on larger meshes. Worth watching."],[x.jsxs(x.Fragment,{children:[x.jsx(ar,{color:"orange"})," 40-50%"]}),"Congested. The firmware throttles GPS updates above 40%. Messages are colliding and retrying."],[x.jsxs(x.Fragment,{children:[x.jsx(ar,{color:"red"})," Over 50%"]}),"Serious problem. More time is spent retrying than communicating. Mesh reliability drops fast."],[x.jsxs(x.Fragment,{children:[x.jsx(ar,{color:"black"})," Over 65%"]}),"Documented failure point on busy LONG_FAST meshes. The mesh becomes unusable."]]}),x.jsx(Te,{children:"Packet Flooding"}),x.jsx("p",{className:"p-3 bg-yellow-500/10 border border-yellow-500/30 rounded text-yellow-200",children:x.jsx("strong",{children:'⚠️ "Packet flooding" means a node sending too many RADIO PACKETS. This has nothing to do with water flooding.'})}),x.jsx("p",{children:"A normal Meshtastic node sends a packet every few minutes (announcing itself, reporting telemetry, updating position). If a node starts blasting packets every few seconds, something is wrong — firmware bug, stuck transmitter, or misconfiguration."}),x.jsx(Rt,{headers:["Packets per Minute","What It Means"],rows:[["1-5","Normal"],["5-10","Elevated — might be someone chatting a lot"],["10-20","Suspicious — worth investigating"],["Over 30","Something is broken. This node is actively hurting the mesh."]]}),x.jsx(Te,{children:"Battery Levels"}),x.jsx("p",{children:"Most Meshtastic radios (T-Beam, RAK4631, Heltec V3) use a single lithium battery cell. The voltage tells you how much charge is left:"}),x.jsx(Rt,{headers:["Voltage","Charge","What To Do"],rows:[["4.20V","100%","Full"],["3.80V","~60%","Fine"],[x.jsx("strong",{children:"3.60V"}),x.jsx("strong",{children:"~30%"}),x.jsx(x.Fragment,{children:x.jsx("strong",{children:"⚠️ Warning — charge it soon"})})],[x.jsx("strong",{children:"3.50V"}),x.jsx("strong",{children:"~15%"}),x.jsx(x.Fragment,{children:x.jsx("strong",{children:"🔴 Low — charge it now"})})],[x.jsx("strong",{children:"3.40V"}),x.jsx("strong",{children:"~7%"}),x.jsx(x.Fragment,{children:x.jsx("strong",{children:"⚫ About to die"})})],["3.30V","~3%","Device shutting down"]]}),x.jsxs("p",{children:[x.jsx("strong",{children:"USB-powered nodes"})," report 100% battery even if there's no battery installed. Battery alerts only matter for nodes actually running on battery power."]}),x.jsx(Te,{children:"Node Offline Detection"}),x.jsx("p",{children:`MeshAI marks a node as "offline" when it hasn't been heard for a configurable time period. Different node types need different thresholds:`}),x.jsx(Rt,{headers:["Node Type","Recommended Threshold","Why"],rows:[["Fixed infrastructure (wall power)",x.jsx("strong",{children:"2 hours"}),"These should always be transmitting. 2 hours of silence means something is wrong."],["Fixed client (wall power)","2-4 hours","Same logic, slightly more lenient."],["Mobile / vehicle","4-8 hours","They go behind mountains, into garages, out of range. Normal."],["Solar-powered","12-24 hours","May shut down at night when solar stops charging."]]}),x.jsxs("p",{children:[x.jsx("strong",{children:"Rule of thumb"}),`: set the threshold to about 4× the node's beacon interval. Too tight and nodes will constantly flap "offline/online" from normal gaps. Too loose and real outages go unnoticed.`]})]}),x.jsxs(pi,{id:"notifications",title:"Notifications",children:[x.jsx(Te,{children:"How It Works"}),x.jsxs("ol",{className:"list-decimal list-inside ml-4 space-y-1",children:[x.jsxs("li",{children:[x.jsx("strong",{children:"Something happens"})," — a fire is detected, weather warning issued, node goes offline, etc."]}),x.jsxs("li",{children:[x.jsx("strong",{children:"MeshAI checks your rules"})," — does this event match any of your notification rules? Is it severe enough? Are we in quiet hours?"]}),x.jsxs("li",{children:[x.jsx("strong",{children:"If a rule matches"})," — MeshAI sends the notification through whatever delivery method that rule is configured for."]})]}),x.jsx(Te,{children:"Building Rules"}),x.jsx("p",{children:"Each rule answers three questions:"}),x.jsxs("ul",{className:"list-disc list-inside ml-4 space-y-1",children:[x.jsxs("li",{children:[x.jsx("strong",{children:"WHEN"})," does it trigger? (which categories, what severity)"]}),x.jsxs("li",{children:[x.jsx("strong",{children:"WHERE"})," does it send? (mesh broadcast, email, webhook, etc.)"]}),x.jsxs("li",{children:[x.jsx("strong",{children:"HOW OFTEN"})," at most? (cooldown period)"]})]}),x.jsx("p",{children:'Use "Add from Template" to start with a pre-built rule and customize it, or build from scratch with "Add Rule."'}),x.jsx(Te,{children:"Severity Levels — What Should I Set?"}),x.jsx(Rt,{headers:["Level","When It's Used","Notification Volume"],rows:[["Info","Routine stuff (ducting detected, new router appeared)","High — lots of messages"],["Advisory","Worth knowing (weather advisory, slow traffic, battery declining)","Moderate"],["Watch","Pay attention (fire within 50km, weather watch, stream rising)","Low-moderate"],[x.jsxs(x.Fragment,{children:[x.jsx("strong",{children:"Warning"})," ✓"]}),"Take action (fire within 15km, severe weather, critical battery)","Low — recommended for most rules"],["Emergency","Life safety (extreme weather, fire at infrastructure, total blackout)","Very rare"]]}),x.jsxs("p",{children:[x.jsx("strong",{children:'"Warning" is the sweet spot for most rules.'})," You get alerted when something actually needs your attention without being overwhelmed by every minor event."]}),x.jsx(Te,{children:"Quiet Hours"}),x.jsx("p",{children:'When enabled, non-emergency notifications are held during sleeping hours (default 10pm-6am). Emergency alerts and rules marked "Override Quiet Hours" always get through.'}),x.jsx("p",{children:"You can turn quiet hours off entirely if you don't want them."}),x.jsx(Te,{children:"Webhook — The Swiss Army Knife"}),x.jsx("p",{children:"A webhook sends your alert as an HTTP POST to any URL. This one delivery method works with:"}),x.jsxs("ul",{className:"list-disc list-inside ml-4 space-y-1",children:[x.jsxs("li",{children:[x.jsx("strong",{children:"Discord"})," — use a Discord webhook URL"]}),x.jsxs("li",{children:[x.jsx("strong",{children:"Slack"})," — use a Slack incoming webhook URL"]}),x.jsxs("li",{children:[x.jsx("strong",{children:"ntfy.sh"})," — POST to ",x.jsx(Ve,{children:"https://ntfy.sh/your-topic"})]}),x.jsxs("li",{children:[x.jsx("strong",{children:"Pushover"})," — POST to the Pushover API"]}),x.jsxs("li",{children:[x.jsx("strong",{children:"Home Assistant"})," — POST to an automation webhook URL"]}),x.jsx("li",{children:"Anything else that accepts HTTP POST"})]}),x.jsx("p",{children:"MeshAI doesn't need to know what's on the other end. Give it the URL and it works."})]}),x.jsxs(pi,{id:"commands",title:"Commands",children:[x.jsxs("p",{children:["All commands use the ",x.jsx(Ve,{children:"!"})," prefix (configurable). Send these as a direct message to MeshAI on your mesh."]}),x.jsx(Te,{children:"Basic Commands"}),x.jsx(Rt,{headers:["Command","What It Does"],rows:[[x.jsx(Ve,{children:"!help"}),"Shows all available commands"],[x.jsx(Ve,{children:"!ping"}),"Tests if the bot is alive"],[x.jsx(Ve,{children:"!status"}),"Quick mesh summary (nodes online, health score)"],[x.jsx(Ve,{children:"!health"}),"Detailed health report with pillar scores"],[x.jsx(Ve,{children:"!weather"}),"Current weather for your area"]]}),x.jsx(Te,{children:"Environmental Commands"}),x.jsx(Rt,{headers:["Command","What It Does"],rows:[[x.jsx(Ve,{children:"!alerts"}),"Active NWS weather alerts for your area"],[x.jsxs(x.Fragment,{children:[x.jsx(Ve,{children:"!solar"})," (or ",x.jsx(Ve,{children:"!hf"}),")"]}),"Current solar indices and RF conditions"],[x.jsx(Ve,{children:"!fire"}),"Active wildfires near your mesh"],[x.jsx(Ve,{children:"!avy"}),'Avalanche advisory (seasonal — shows "off season" in summer)'],[x.jsxs(x.Fragment,{children:[x.jsx(Ve,{children:"!streams"})," (or ",x.jsx(Ve,{children:"!gauges"}),")"]}),"Stream gauge readings"],[x.jsxs(x.Fragment,{children:[x.jsx(Ve,{children:"!roads"})," (or ",x.jsx(Ve,{children:"!traffic"}),")"]}),"Road conditions and traffic flow"],[x.jsx(Ve,{children:"!hotspots"}),"Satellite fire detections"]]}),x.jsx(Te,{children:"Subscription Commands"}),x.jsx(Rt,{headers:["Command","What It Does"],rows:[[x.jsx(Ve,{children:"!subscribe"}),"Lists all alert categories you can subscribe to"],[x.jsx(Ve,{children:"!subscribe fire_proximity"}),"Subscribe to a specific category"],[x.jsx(Ve,{children:"!subscribe all"}),"Subscribe to everything"],[x.jsx(Ve,{children:"!unsubscribe fire_proximity"}),"Unsubscribe from a category"],[x.jsx(Ve,{children:"!subscriptions"}),"Shows what you're currently subscribed to"]]}),x.jsx(Te,{children:"Conversational"}),x.jsx("p",{children:`MeshAI isn't just commands — you can ask it questions in plain English. "How's the mesh doing?" "Is there any ducting?" "What's the fire situation?" "How's traffic on I-84?" It uses the live environmental data and mesh health data to answer.`})]}),x.jsxs(pi,{id:"api",title:"API Reference",children:[x.jsxs("p",{children:["MeshAI's REST API is available at ",x.jsx(Ve,{children:"http://your-host:8080"}),". All endpoints return JSON."]}),x.jsx(Te,{children:"System"}),x.jsxs("ul",{className:"list-disc list-inside ml-4 space-y-1",children:[x.jsxs("li",{children:[x.jsx(Ve,{children:"GET /api/status"})," — version, uptime, node count"]}),x.jsxs("li",{children:[x.jsx(Ve,{children:"GET /api/channels"})," — radio channel list"]}),x.jsxs("li",{children:[x.jsx(Ve,{children:"POST /api/restart"})," — restart the bot"]})]}),x.jsx(Te,{children:"Mesh Data"}),x.jsxs("ul",{className:"list-disc list-inside ml-4 space-y-1",children:[x.jsxs("li",{children:[x.jsx(Ve,{children:"GET /api/health"})," — health score and pillars"]}),x.jsxs("li",{children:[x.jsx(Ve,{children:"GET /api/nodes"})," — all nodes with positions and telemetry"]}),x.jsxs("li",{children:[x.jsx(Ve,{children:"GET /api/edges"})," — neighbor links with signal quality"]}),x.jsxs("li",{children:[x.jsx(Ve,{children:"GET /api/regions"})," — region summaries"]}),x.jsxs("li",{children:[x.jsx(Ve,{children:"GET /api/sources"})," — data source health"]})]}),x.jsx(Te,{children:"Configuration"}),x.jsxs("ul",{className:"list-disc list-inside ml-4 space-y-1",children:[x.jsxs("li",{children:[x.jsx(Ve,{children:"GET /api/config"})," — full config"]}),x.jsxs("li",{children:[x.jsxs(Ve,{children:["GET /api/config/","{section}"]})," — one section"]}),x.jsxs("li",{children:[x.jsxs(Ve,{children:["PUT /api/config/","{section}"]})," — update a section"]})]}),x.jsx(Te,{children:"Environmental"}),x.jsxs("ul",{className:"list-disc list-inside ml-4 space-y-1",children:[x.jsxs("li",{children:[x.jsx(Ve,{children:"GET /api/env/status"})," — per-feed health"]}),x.jsxs("li",{children:[x.jsx(Ve,{children:"GET /api/env/active"})," — all active events"]}),x.jsxs("li",{children:[x.jsx(Ve,{children:"GET /api/env/swpc"})," — solar/geomagnetic data"]}),x.jsxs("li",{children:[x.jsx(Ve,{children:"GET /api/env/ducting"})," — atmospheric profile"]}),x.jsxs("li",{children:[x.jsx(Ve,{children:"GET /api/env/fires"})," — wildfire perimeters"]}),x.jsxs("li",{children:[x.jsx(Ve,{children:"GET /api/env/hotspots"})," — satellite fire detections"]})]}),x.jsx(Te,{children:"Alerts"}),x.jsxs("ul",{className:"list-disc list-inside ml-4 space-y-1",children:[x.jsxs("li",{children:[x.jsx(Ve,{children:"GET /api/alerts/active"})," — current alerts"]}),x.jsxs("li",{children:[x.jsx(Ve,{children:"GET /api/alerts/history"})," — past alerts"]}),x.jsxs("li",{children:[x.jsx(Ve,{children:"GET /api/notifications/categories"})," — available alert categories"]})]}),x.jsx(Te,{children:"Real-time"}),x.jsx("ul",{className:"list-disc list-inside ml-4 space-y-1",children:x.jsxs("li",{children:[x.jsx(Ve,{children:"ws://your-host:8080/ws/live"})," — WebSocket for live updates"]})})]})]})})]})}function aet(){return x.jsx(_ce,{children:x.jsx(Sce,{children:x.jsxs(Mue,{children:[x.jsx(fl,{path:"/",element:x.jsx(rNe,{})}),x.jsx(fl,{path:"/mesh",element:x.jsx(xJe,{})}),x.jsx(fl,{path:"/environment",element:x.jsx(TJe,{})}),x.jsx(fl,{path:"/config",element:x.jsx(HJe,{})}),x.jsx(fl,{path:"/alerts",element:x.jsx(JJe,{})}),x.jsx(fl,{path:"/notifications",element:x.jsx(net,{})}),x.jsx(fl,{path:"/reference",element:x.jsx(iet,{})})]})})})}aP.createRoot(document.getElementById("root")).render(x.jsx(Q.StrictMode,{children:x.jsx(Due,{children:x.jsx(aet,{})})})); + */(function(e,t){(function(r,n){n(t)})(ag,function(r){var n="1.9.4";function i(p){var w,C,E,j;for(C=1,E=arguments.length;C"u"||!L||!L.Mixin)){p=b(p)?p:[p];for(var w=0;w0?Math.floor(p):Math.ceil(p)};z.prototype={clone:function(){return new z(this.x,this.y)},add:function(p){return this.clone()._add(H(p))},_add:function(p){return this.x+=p.x,this.y+=p.y,this},subtract:function(p){return this.clone()._subtract(H(p))},_subtract:function(p){return this.x-=p.x,this.y-=p.y,this},divideBy:function(p){return this.clone()._divideBy(p)},_divideBy:function(p){return this.x/=p,this.y/=p,this},multiplyBy:function(p){return this.clone()._multiplyBy(p)},_multiplyBy:function(p){return this.x*=p,this.y*=p,this},scaleBy:function(p){return new z(this.x*p.x,this.y*p.y)},unscaleBy:function(p){return new z(this.x/p.x,this.y/p.y)},round:function(){return this.clone()._round()},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},floor:function(){return this.clone()._floor()},_floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this},ceil:function(){return this.clone()._ceil()},_ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this},trunc:function(){return this.clone()._trunc()},_trunc:function(){return this.x=U(this.x),this.y=U(this.y),this},distanceTo:function(p){p=H(p);var w=p.x-this.x,C=p.y-this.y;return Math.sqrt(w*w+C*C)},equals:function(p){return p=H(p),p.x===this.x&&p.y===this.y},contains:function(p){return p=H(p),Math.abs(p.x)<=Math.abs(this.x)&&Math.abs(p.y)<=Math.abs(this.y)},toString:function(){return"Point("+h(this.x)+", "+h(this.y)+")"}};function H(p,w,C){return p instanceof z?p:b(p)?new z(p[0],p[1]):p==null?p:typeof p=="object"&&"x"in p&&"y"in p?new z(p.x,p.y):new z(p,w,C)}function Y(p,w){if(p)for(var C=w?[p,w]:p,E=0,j=C.length;E=this.min.x&&C.x<=this.max.x&&w.y>=this.min.y&&C.y<=this.max.y},intersects:function(p){p=Z(p);var w=this.min,C=this.max,E=p.min,j=p.max,V=j.x>=w.x&&E.x<=C.x,X=j.y>=w.y&&E.y<=C.y;return V&&X},overlaps:function(p){p=Z(p);var w=this.min,C=this.max,E=p.min,j=p.max,V=j.x>w.x&&E.xw.y&&E.y=w.lat&&j.lat<=C.lat&&E.lng>=w.lng&&j.lng<=C.lng},intersects:function(p){p=ae(p);var w=this._southWest,C=this._northEast,E=p.getSouthWest(),j=p.getNorthEast(),V=j.lat>=w.lat&&E.lat<=C.lat,X=j.lng>=w.lng&&E.lng<=C.lng;return V&&X},overlaps:function(p){p=ae(p);var w=this._southWest,C=this._northEast,E=p.getSouthWest(),j=p.getNorthEast(),V=j.lat>w.lat&&E.latw.lng&&E.lng1,Qie=function(){var p=!1;try{var w=Object.defineProperty({},"passive",{get:function(){p=!0}});window.addEventListener("testPassiveEventSupport",f,w),window.removeEventListener("testPassiveEventSupport",f,w)}catch{}return p}(),Jie=function(){return!!document.createElement("canvas").getContext}(),tA=!!(document.createElementNS&&Fe("svg").createSVGRect),eae=!!tA&&function(){var p=document.createElement("div");return p.innerHTML="",(p.firstChild&&p.firstChild.namespaceURI)==="http://www.w3.org/2000/svg"}(),tae=!tA&&function(){try{var p=document.createElement("div");p.innerHTML='';var w=p.firstChild;return w.style.behavior="url(#default#VML)",w&&typeof w.adj=="object"}catch{return!1}}(),rae=navigator.platform.indexOf("Mac")===0,nae=navigator.platform.indexOf("Linux")===0;function Qa(p){return navigator.userAgent.toLowerCase().indexOf(p)>=0}var Ue={ie:Vt,ielt9:nr,edge:jn,webkit:qr,android:Jn,android23:kf,androidStock:T0,opera:JT,chrome:BR,gecko:zR,safari:Gie,phantom:$R,opera12:FR,win:Wie,ie3d:VR,webkit3d:eA,gecko3d:GR,any3d:Hie,mobile:qv,mobileWebkit:Uie,mobileWebkit3d:Zie,msPointer:WR,pointer:HR,touch:Yie,touchNative:UR,mobileOpera:Xie,mobileGecko:qie,retina:Kie,passiveEvents:Qie,canvas:Jie,svg:tA,vml:tae,inlineSvg:eae,mac:rae,linux:nae},ZR=Ue.msPointer?"MSPointerDown":"pointerdown",YR=Ue.msPointer?"MSPointerMove":"pointermove",XR=Ue.msPointer?"MSPointerUp":"pointerup",qR=Ue.msPointer?"MSPointerCancel":"pointercancel",rA={touchstart:ZR,touchmove:YR,touchend:XR,touchcancel:qR},KR={touchstart:uae,touchmove:A0,touchend:A0,touchcancel:A0},If={},QR=!1;function iae(p,w,C){return w==="touchstart"&&lae(),KR[w]?(C=KR[w].bind(this,C),p.addEventListener(rA[w],C,!1),C):(console.warn("wrong event specified:",w),f)}function aae(p,w,C){if(!rA[w]){console.warn("wrong event specified:",w);return}p.removeEventListener(rA[w],C,!1)}function oae(p){If[p.pointerId]=p}function sae(p){If[p.pointerId]&&(If[p.pointerId]=p)}function JR(p){delete If[p.pointerId]}function lae(){QR||(document.addEventListener(ZR,oae,!0),document.addEventListener(YR,sae,!0),document.addEventListener(XR,JR,!0),document.addEventListener(qR,JR,!0),QR=!0)}function A0(p,w){if(w.pointerType!==(w.MSPOINTER_TYPE_MOUSE||"mouse")){w.touches=[];for(var C in If)w.touches.push(If[C]);w.changedTouches=[w],p(w)}}function uae(p,w){w.MSPOINTER_TYPE_TOUCH&&w.pointerType===w.MSPOINTER_TYPE_TOUCH&&un(w),A0(p,w)}function cae(p){var w={},C,E;for(E in p)C=p[E],w[E]=C&&C.bind?C.bind(p):C;return p=w,w.type="dblclick",w.detail=2,w.isTrusted=!1,w._simulated=!0,w}var fae=200;function hae(p,w){p.addEventListener("dblclick",w);var C=0,E;function j(V){if(V.detail!==1){E=V.detail;return}if(!(V.pointerType==="mouse"||V.sourceCapabilities&&!V.sourceCapabilities.firesTouchEvents)){var X=i5(V);if(!(X.some(function(oe){return oe instanceof HTMLLabelElement&&oe.attributes.for})&&!X.some(function(oe){return oe instanceof HTMLInputElement||oe instanceof HTMLSelectElement}))){var te=Date.now();te-C<=fae?(E++,E===2&&w(cae(V))):E=1,C=te}}}return p.addEventListener("click",j),{dblclick:w,simDblclick:j}}function dae(p,w){p.removeEventListener("dblclick",w.dblclick),p.removeEventListener("click",w.simDblclick)}var nA=P0(["transform","webkitTransform","OTransform","MozTransform","msTransform"]),Kv=P0(["webkitTransition","transition","OTransition","MozTransition","msTransition"]),e5=Kv==="webkitTransition"||Kv==="OTransition"?Kv+"End":"transitionend";function t5(p){return typeof p=="string"?document.getElementById(p):p}function Qv(p,w){var C=p.style[w]||p.currentStyle&&p.currentStyle[w];if((!C||C==="auto")&&document.defaultView){var E=document.defaultView.getComputedStyle(p,null);C=E?E[w]:null}return C==="auto"?null:C}function Tt(p,w,C){var E=document.createElement(p);return E.className=w||"",C&&C.appendChild(E),E}function ir(p){var w=p.parentNode;w&&w.removeChild(p)}function C0(p){for(;p.firstChild;)p.removeChild(p.firstChild)}function Of(p){var w=p.parentNode;w&&w.lastChild!==p&&w.appendChild(p)}function Ef(p){var w=p.parentNode;w&&w.firstChild!==p&&w.insertBefore(p,w.firstChild)}function iA(p,w){if(p.classList!==void 0)return p.classList.contains(w);var C=M0(p);return C.length>0&&new RegExp("(^|\\s)"+w+"(\\s|$)").test(C)}function ut(p,w){if(p.classList!==void 0)for(var C=v(w),E=0,j=C.length;E0?2*window.devicePixelRatio:1;function o5(p){return Ue.edge?p.wheelDeltaY/2:p.deltaY&&p.deltaMode===0?-p.deltaY/gae:p.deltaY&&p.deltaMode===1?-p.deltaY*20:p.deltaY&&p.deltaMode===2?-p.deltaY*60:p.deltaX||p.deltaZ?0:p.wheelDelta?(p.wheelDeltaY||p.wheelDelta)/2:p.detail&&Math.abs(p.detail)<32765?-p.detail*20:p.detail?p.detail/-32765*60:0}function gA(p,w){var C=w.relatedTarget;if(!C)return!0;try{for(;C&&C!==p;)C=C.parentNode}catch{return!1}return C!==p}var mae={__proto__:null,on:st,off:Ht,stopPropagation:Tu,disableScrollPropagation:pA,disableClickPropagation:rp,preventDefault:un,stop:Au,getPropagationPath:i5,getMousePosition:a5,getWheelDelta:o5,isExternalTarget:gA,addListener:st,removeListener:Ht},s5=G.extend({run:function(p,w,C,E){this.stop(),this._el=p,this._inProgress=!0,this._duration=C||.25,this._easeOutPower=1/Math.max(E||.5,.2),this._startPos=Su(p),this._offset=w.subtract(this._startPos),this._startTime=+new Date,this.fire("start"),this._animate()},stop:function(){this._inProgress&&(this._step(!0),this._complete())},_animate:function(){this._animId=O(this._animate,this),this._step()},_step:function(p){var w=+new Date-this._startTime,C=this._duration*1e3;wthis.options.maxZoom)?this.setZoom(p):this},panInsideBounds:function(p,w){this._enforcingBounds=!0;var C=this.getCenter(),E=this._limitCenter(C,this._zoom,ae(p));return C.equals(E)||this.panTo(E,w),this._enforcingBounds=!1,this},panInside:function(p,w){w=w||{};var C=H(w.paddingTopLeft||w.padding||[0,0]),E=H(w.paddingBottomRight||w.padding||[0,0]),j=this.project(this.getCenter()),V=this.project(p),X=this.getPixelBounds(),te=Z([X.min.add(C),X.max.subtract(E)]),oe=te.getSize();if(!te.contains(V)){this._enforcingBounds=!0;var he=V.subtract(te.getCenter()),Ee=te.extend(V).getSize().subtract(oe);j.x+=he.x<0?-Ee.x:Ee.x,j.y+=he.y<0?-Ee.y:Ee.y,this.panTo(this.unproject(j),w),this._enforcingBounds=!1}return this},invalidateSize:function(p){if(!this._loaded)return this;p=i({animate:!1,pan:!0},p===!0?{animate:!0}:p);var w=this.getSize();this._sizeChanged=!0,this._lastCenter=null;var C=this.getSize(),E=w.divideBy(2).round(),j=C.divideBy(2).round(),V=E.subtract(j);return!V.x&&!V.y?this:(p.animate&&p.pan?this.panBy(V):(p.pan&&this._rawPanBy(V),this.fire("move"),p.debounceMoveend?(clearTimeout(this._sizeTimer),this._sizeTimer=setTimeout(o(this.fire,this,"moveend"),200)):this.fire("moveend")),this.fire("resize",{oldSize:w,newSize:C}))},stop:function(){return this.setZoom(this._limitZoom(this._zoom)),this.options.zoomSnap||this.fire("viewreset"),this._stop()},locate:function(p){if(p=this._locateOptions=i({timeout:1e4,watch:!1},p),!("geolocation"in navigator))return this._handleGeolocationError({code:0,message:"Geolocation not supported."}),this;var w=o(this._handleGeolocationResponse,this),C=o(this._handleGeolocationError,this);return p.watch?this._locationWatchId=navigator.geolocation.watchPosition(w,C,p):navigator.geolocation.getCurrentPosition(w,C,p),this},stopLocate:function(){return navigator.geolocation&&navigator.geolocation.clearWatch&&navigator.geolocation.clearWatch(this._locationWatchId),this._locateOptions&&(this._locateOptions.setView=!1),this},_handleGeolocationError:function(p){if(this._container._leaflet_id){var w=p.code,C=p.message||(w===1?"permission denied":w===2?"position unavailable":"timeout");this._locateOptions.setView&&!this._loaded&&this.fitWorld(),this.fire("locationerror",{code:w,message:"Geolocation error: "+C+"."})}},_handleGeolocationResponse:function(p){if(this._container._leaflet_id){var w=p.coords.latitude,C=p.coords.longitude,E=new ce(w,C),j=E.toBounds(p.coords.accuracy*2),V=this._locateOptions;if(V.setView){var X=this.getBoundsZoom(j);this.setView(E,V.maxZoom?Math.min(X,V.maxZoom):X)}var te={latlng:E,bounds:j,timestamp:p.timestamp};for(var oe in p.coords)typeof p.coords[oe]=="number"&&(te[oe]=p.coords[oe]);this.fire("locationfound",te)}},addHandler:function(p,w){if(!w)return this;var C=this[p]=new w(this);return this._handlers.push(C),this.options[p]&&C.enable(),this},remove:function(){if(this._initEvents(!0),this.options.maxBounds&&this.off("moveend",this._panInsideMaxBounds),this._containerId!==this._container._leaflet_id)throw new Error("Map container is being reused by another instance");try{delete this._container._leaflet_id,delete this._containerId}catch{this._container._leaflet_id=void 0,this._containerId=void 0}this._locationWatchId!==void 0&&this.stopLocate(),this._stop(),ir(this._mapPane),this._clearControlPos&&this._clearControlPos(),this._resizeRequest&&(D(this._resizeRequest),this._resizeRequest=null),this._clearHandlers(),this._loaded&&this.fire("unload");var p;for(p in this._layers)this._layers[p].remove();for(p in this._panes)ir(this._panes[p]);return this._layers=[],this._panes=[],delete this._mapPane,delete this._renderer,this},createPane:function(p,w){var C="leaflet-pane"+(p?" leaflet-"+p.replace("Pane","")+"-pane":""),E=Tt("div",C,w||this._mapPane);return p&&(this._panes[p]=E),E},getCenter:function(){return this._checkIfLoaded(),this._lastCenter&&!this._moved()?this._lastCenter.clone():this.layerPointToLatLng(this._getCenterLayerPoint())},getZoom:function(){return this._zoom},getBounds:function(){var p=this.getPixelBounds(),w=this.unproject(p.getBottomLeft()),C=this.unproject(p.getTopRight());return new J(w,C)},getMinZoom:function(){return this.options.minZoom===void 0?this._layersMinZoom||0:this.options.minZoom},getMaxZoom:function(){return this.options.maxZoom===void 0?this._layersMaxZoom===void 0?1/0:this._layersMaxZoom:this.options.maxZoom},getBoundsZoom:function(p,w,C){p=ae(p),C=H(C||[0,0]);var E=this.getZoom()||0,j=this.getMinZoom(),V=this.getMaxZoom(),X=p.getNorthWest(),te=p.getSouthEast(),oe=this.getSize().subtract(C),he=Z(this.project(te,E),this.project(X,E)).getSize(),Ee=Ue.any3d?this.options.zoomSnap:1,et=oe.x/he.x,pt=oe.y/he.y,Rn=w?Math.max(et,pt):Math.min(et,pt);return E=this.getScaleZoom(Rn,E),Ee&&(E=Math.round(E/(Ee/100))*(Ee/100),E=w?Math.ceil(E/Ee)*Ee:Math.floor(E/Ee)*Ee),Math.max(j,Math.min(V,E))},getSize:function(){return(!this._size||this._sizeChanged)&&(this._size=new z(this._container.clientWidth||0,this._container.clientHeight||0),this._sizeChanged=!1),this._size.clone()},getPixelBounds:function(p,w){var C=this._getTopLeftPoint(p,w);return new Y(C,C.add(this.getSize()))},getPixelOrigin:function(){return this._checkIfLoaded(),this._pixelOrigin},getPixelWorldBounds:function(p){return this.options.crs.getProjectedBounds(p===void 0?this.getZoom():p)},getPane:function(p){return typeof p=="string"?this._panes[p]:p},getPanes:function(){return this._panes},getContainer:function(){return this._container},getZoomScale:function(p,w){var C=this.options.crs;return w=w===void 0?this._zoom:w,C.scale(p)/C.scale(w)},getScaleZoom:function(p,w){var C=this.options.crs;w=w===void 0?this._zoom:w;var E=C.zoom(p*C.scale(w));return isNaN(E)?1/0:E},project:function(p,w){return w=w===void 0?this._zoom:w,this.options.crs.latLngToPoint(ge(p),w)},unproject:function(p,w){return w=w===void 0?this._zoom:w,this.options.crs.pointToLatLng(H(p),w)},layerPointToLatLng:function(p){var w=H(p).add(this.getPixelOrigin());return this.unproject(w)},latLngToLayerPoint:function(p){var w=this.project(ge(p))._round();return w._subtract(this.getPixelOrigin())},wrapLatLng:function(p){return this.options.crs.wrapLatLng(ge(p))},wrapLatLngBounds:function(p){return this.options.crs.wrapLatLngBounds(ae(p))},distance:function(p,w){return this.options.crs.distance(ge(p),ge(w))},containerPointToLayerPoint:function(p){return H(p).subtract(this._getMapPanePos())},layerPointToContainerPoint:function(p){return H(p).add(this._getMapPanePos())},containerPointToLatLng:function(p){var w=this.containerPointToLayerPoint(H(p));return this.layerPointToLatLng(w)},latLngToContainerPoint:function(p){return this.layerPointToContainerPoint(this.latLngToLayerPoint(ge(p)))},mouseEventToContainerPoint:function(p){return a5(p,this._container)},mouseEventToLayerPoint:function(p){return this.containerPointToLayerPoint(this.mouseEventToContainerPoint(p))},mouseEventToLatLng:function(p){return this.layerPointToLatLng(this.mouseEventToLayerPoint(p))},_initContainer:function(p){var w=this._container=t5(p);if(w){if(w._leaflet_id)throw new Error("Map container is already initialized.")}else throw new Error("Map container not found.");st(w,"scroll",this._onScroll,this),this._containerId=l(w)},_initLayout:function(){var p=this._container;this._fadeAnimated=this.options.fadeAnimation&&Ue.any3d,ut(p,"leaflet-container"+(Ue.touch?" leaflet-touch":"")+(Ue.retina?" leaflet-retina":"")+(Ue.ielt9?" leaflet-oldie":"")+(Ue.safari?" leaflet-safari":"")+(this._fadeAnimated?" leaflet-fade-anim":""));var w=Qv(p,"position");w!=="absolute"&&w!=="relative"&&w!=="fixed"&&w!=="sticky"&&(p.style.position="relative"),this._initPanes(),this._initControlPos&&this._initControlPos()},_initPanes:function(){var p=this._panes={};this._paneRenderers={},this._mapPane=this.createPane("mapPane",this._container),Cr(this._mapPane,new z(0,0)),this.createPane("tilePane"),this.createPane("overlayPane"),this.createPane("shadowPane"),this.createPane("markerPane"),this.createPane("tooltipPane"),this.createPane("popupPane"),this.options.markerZoomAnimation||(ut(p.markerPane,"leaflet-zoom-hide"),ut(p.shadowPane,"leaflet-zoom-hide"))},_resetView:function(p,w,C){Cr(this._mapPane,new z(0,0));var E=!this._loaded;this._loaded=!0,w=this._limitZoom(w),this.fire("viewprereset");var j=this._zoom!==w;this._moveStart(j,C)._move(p,w)._moveEnd(j),this.fire("viewreset"),E&&this.fire("load")},_moveStart:function(p,w){return p&&this.fire("zoomstart"),w||this.fire("movestart"),this},_move:function(p,w,C,E){w===void 0&&(w=this._zoom);var j=this._zoom!==w;return this._zoom=w,this._lastCenter=p,this._pixelOrigin=this._getNewPixelOrigin(p),E?C&&C.pinch&&this.fire("zoom",C):((j||C&&C.pinch)&&this.fire("zoom",C),this.fire("move",C)),this},_moveEnd:function(p){return p&&this.fire("zoomend"),this.fire("moveend")},_stop:function(){return D(this._flyToFrame),this._panAnim&&this._panAnim.stop(),this},_rawPanBy:function(p){Cr(this._mapPane,this._getMapPanePos().subtract(p))},_getZoomSpan:function(){return this.getMaxZoom()-this.getMinZoom()},_panInsideMaxBounds:function(){this._enforcingBounds||this.panInsideBounds(this.options.maxBounds)},_checkIfLoaded:function(){if(!this._loaded)throw new Error("Set map center and zoom first.")},_initEvents:function(p){this._targets={},this._targets[l(this._container)]=this;var w=p?Ht:st;w(this._container,"click dblclick mousedown mouseup mouseover mouseout mousemove contextmenu keypress keydown keyup",this._handleDOMEvent,this),this.options.trackResize&&w(window,"resize",this._onResize,this),Ue.any3d&&this.options.transform3DLimit&&(p?this.off:this.on).call(this,"moveend",this._onMoveEnd)},_onResize:function(){D(this._resizeRequest),this._resizeRequest=O(function(){this.invalidateSize({debounceMoveend:!0})},this)},_onScroll:function(){this._container.scrollTop=0,this._container.scrollLeft=0},_onMoveEnd:function(){var p=this._getMapPanePos();Math.max(Math.abs(p.x),Math.abs(p.y))>=this.options.transform3DLimit&&this._resetView(this.getCenter(),this.getZoom())},_findEventTargets:function(p,w){for(var C=[],E,j=w==="mouseout"||w==="mouseover",V=p.target||p.srcElement,X=!1;V;){if(E=this._targets[l(V)],E&&(w==="click"||w==="preclick")&&this._draggableMoved(E)){X=!0;break}if(E&&E.listens(w,!0)&&(j&&!gA(V,p)||(C.push(E),j))||V===this._container)break;V=V.parentNode}return!C.length&&!X&&!j&&this.listens(w,!0)&&(C=[this]),C},_isClickDisabled:function(p){for(;p&&p!==this._container;){if(p._leaflet_disable_click)return!0;p=p.parentNode}},_handleDOMEvent:function(p){var w=p.target||p.srcElement;if(!(!this._loaded||w._leaflet_disable_events||p.type==="click"&&this._isClickDisabled(w))){var C=p.type;C==="mousedown"&&cA(w),this._fireDOMEvent(p,C)}},_mouseEvents:["click","dblclick","mouseover","mouseout","contextmenu"],_fireDOMEvent:function(p,w,C){if(p.type==="click"){var E=i({},p);E.type="preclick",this._fireDOMEvent(E,E.type,C)}var j=this._findEventTargets(p,w);if(C){for(var V=[],X=0;X0?Math.round(p-w)/2:Math.max(0,Math.ceil(p))-Math.max(0,Math.floor(w))},_limitZoom:function(p){var w=this.getMinZoom(),C=this.getMaxZoom(),E=Ue.any3d?this.options.zoomSnap:1;return E&&(p=Math.round(p/E)*E),Math.max(w,Math.min(C,p))},_onPanTransitionStep:function(){this.fire("move")},_onPanTransitionEnd:function(){_r(this._mapPane,"leaflet-pan-anim"),this.fire("moveend")},_tryAnimatedPan:function(p,w){var C=this._getCenterOffset(p)._trunc();return(w&&w.animate)!==!0&&!this.getSize().contains(C)?!1:(this.panBy(C,w),!0)},_createAnimProxy:function(){var p=this._proxy=Tt("div","leaflet-proxy leaflet-zoom-animated");this._panes.mapPane.appendChild(p),this.on("zoomanim",function(w){var C=nA,E=this._proxy.style[C];wu(this._proxy,this.project(w.center,w.zoom),this.getZoomScale(w.zoom,1)),E===this._proxy.style[C]&&this._animatingZoom&&this._onZoomTransitionEnd()},this),this.on("load moveend",this._animMoveEnd,this),this._on("unload",this._destroyAnimProxy,this)},_destroyAnimProxy:function(){ir(this._proxy),this.off("load moveend",this._animMoveEnd,this),delete this._proxy},_animMoveEnd:function(){var p=this.getCenter(),w=this.getZoom();wu(this._proxy,this.project(p,w),this.getZoomScale(w,1))},_catchTransitionEnd:function(p){this._animatingZoom&&p.propertyName.indexOf("transform")>=0&&this._onZoomTransitionEnd()},_nothingToAnimate:function(){return!this._container.getElementsByClassName("leaflet-zoom-animated").length},_tryAnimatedZoom:function(p,w,C){if(this._animatingZoom)return!0;if(C=C||{},!this._zoomAnimated||C.animate===!1||this._nothingToAnimate()||Math.abs(w-this._zoom)>this.options.zoomAnimationThreshold)return!1;var E=this.getZoomScale(w),j=this._getCenterOffset(p)._divideBy(1-1/E);return C.animate!==!0&&!this.getSize().contains(j)?!1:(O(function(){this._moveStart(!0,C.noMoveStart||!1)._animateZoom(p,w,!0)},this),!0)},_animateZoom:function(p,w,C,E){this._mapPane&&(C&&(this._animatingZoom=!0,this._animateToCenter=p,this._animateToZoom=w,ut(this._mapPane,"leaflet-zoom-anim")),this.fire("zoomanim",{center:p,zoom:w,noUpdate:E}),this._tempFireZoomEvent||(this._tempFireZoomEvent=this._zoom!==this._animateToZoom),this._move(this._animateToCenter,this._animateToZoom,void 0,!0),setTimeout(o(this._onZoomTransitionEnd,this),250))},_onZoomTransitionEnd:function(){this._animatingZoom&&(this._mapPane&&_r(this._mapPane,"leaflet-zoom-anim"),this._animatingZoom=!1,this._move(this._animateToCenter,this._animateToZoom,void 0,!0),this._tempFireZoomEvent&&this.fire("zoom"),delete this._tempFireZoomEvent,this.fire("move"),this._moveEnd(!0))}});function yae(p,w){return new bt(p,w)}var ba=B.extend({options:{position:"topright"},initialize:function(p){g(this,p)},getPosition:function(){return this.options.position},setPosition:function(p){var w=this._map;return w&&w.removeControl(this),this.options.position=p,w&&w.addControl(this),this},getContainer:function(){return this._container},addTo:function(p){this.remove(),this._map=p;var w=this._container=this.onAdd(p),C=this.getPosition(),E=p._controlCorners[C];return ut(w,"leaflet-control"),C.indexOf("bottom")!==-1?E.insertBefore(w,E.firstChild):E.appendChild(w),this._map.on("unload",this.remove,this),this},remove:function(){return this._map?(ir(this._container),this.onRemove&&this.onRemove(this._map),this._map.off("unload",this.remove,this),this._map=null,this):this},_refocusOnMap:function(p){this._map&&p&&p.screenX>0&&p.screenY>0&&this._map.getContainer().focus()}}),np=function(p){return new ba(p)};bt.include({addControl:function(p){return p.addTo(this),this},removeControl:function(p){return p.remove(),this},_initControlPos:function(){var p=this._controlCorners={},w="leaflet-",C=this._controlContainer=Tt("div",w+"control-container",this._container);function E(j,V){var X=w+j+" "+w+V;p[j+V]=Tt("div",X,C)}E("top","left"),E("top","right"),E("bottom","left"),E("bottom","right")},_clearControlPos:function(){for(var p in this._controlCorners)ir(this._controlCorners[p]);ir(this._controlContainer),delete this._controlCorners,delete this._controlContainer}});var l5=ba.extend({options:{collapsed:!0,position:"topright",autoZIndex:!0,hideSingleBase:!1,sortLayers:!1,sortFunction:function(p,w,C,E){return C1,this._baseLayersList.style.display=p?"":"none"),this._separator.style.display=w&&p?"":"none",this},_onLayerChange:function(p){this._handlingClick||this._update();var w=this._getLayer(l(p.target)),C=w.overlay?p.type==="add"?"overlayadd":"overlayremove":p.type==="add"?"baselayerchange":null;C&&this._map.fire(C,w)},_createRadioElement:function(p,w){var C='",E=document.createElement("div");return E.innerHTML=C,E.firstChild},_addItem:function(p){var w=document.createElement("label"),C=this._map.hasLayer(p.layer),E;p.overlay?(E=document.createElement("input"),E.type="checkbox",E.className="leaflet-control-layers-selector",E.defaultChecked=C):E=this._createRadioElement("leaflet-base-layers_"+l(this),C),this._layerControlInputs.push(E),E.layerId=l(p.layer),st(E,"click",this._onInputClick,this);var j=document.createElement("span");j.innerHTML=" "+p.name;var V=document.createElement("span");w.appendChild(V),V.appendChild(E),V.appendChild(j);var X=p.overlay?this._overlaysList:this._baseLayersList;return X.appendChild(w),this._checkDisabledLayers(),w},_onInputClick:function(){if(!this._preventClick){var p=this._layerControlInputs,w,C,E=[],j=[];this._handlingClick=!0;for(var V=p.length-1;V>=0;V--)w=p[V],C=this._getLayer(w.layerId).layer,w.checked?E.push(C):w.checked||j.push(C);for(V=0;V=0;j--)w=p[j],C=this._getLayer(w.layerId).layer,w.disabled=C.options.minZoom!==void 0&&EC.options.maxZoom},_expandIfNotCollapsed:function(){return this._map&&!this.options.collapsed&&this.expand(),this},_expandSafely:function(){var p=this._section;this._preventClick=!0,st(p,"click",un),this.expand();var w=this;setTimeout(function(){Ht(p,"click",un),w._preventClick=!1})}}),xae=function(p,w,C){return new l5(p,w,C)},mA=ba.extend({options:{position:"topleft",zoomInText:'',zoomInTitle:"Zoom in",zoomOutText:'',zoomOutTitle:"Zoom out"},onAdd:function(p){var w="leaflet-control-zoom",C=Tt("div",w+" leaflet-bar"),E=this.options;return this._zoomInButton=this._createButton(E.zoomInText,E.zoomInTitle,w+"-in",C,this._zoomIn),this._zoomOutButton=this._createButton(E.zoomOutText,E.zoomOutTitle,w+"-out",C,this._zoomOut),this._updateDisabled(),p.on("zoomend zoomlevelschange",this._updateDisabled,this),C},onRemove:function(p){p.off("zoomend zoomlevelschange",this._updateDisabled,this)},disable:function(){return this._disabled=!0,this._updateDisabled(),this},enable:function(){return this._disabled=!1,this._updateDisabled(),this},_zoomIn:function(p){!this._disabled&&this._map._zoomthis._map.getMinZoom()&&this._map.zoomOut(this._map.options.zoomDelta*(p.shiftKey?3:1))},_createButton:function(p,w,C,E,j){var V=Tt("a",C,E);return V.innerHTML=p,V.href="#",V.title=w,V.setAttribute("role","button"),V.setAttribute("aria-label",w),rp(V),st(V,"click",Au),st(V,"click",j,this),st(V,"click",this._refocusOnMap,this),V},_updateDisabled:function(){var p=this._map,w="leaflet-disabled";_r(this._zoomInButton,w),_r(this._zoomOutButton,w),this._zoomInButton.setAttribute("aria-disabled","false"),this._zoomOutButton.setAttribute("aria-disabled","false"),(this._disabled||p._zoom===p.getMinZoom())&&(ut(this._zoomOutButton,w),this._zoomOutButton.setAttribute("aria-disabled","true")),(this._disabled||p._zoom===p.getMaxZoom())&&(ut(this._zoomInButton,w),this._zoomInButton.setAttribute("aria-disabled","true"))}});bt.mergeOptions({zoomControl:!0}),bt.addInitHook(function(){this.options.zoomControl&&(this.zoomControl=new mA,this.addControl(this.zoomControl))});var _ae=function(p){return new mA(p)},u5=ba.extend({options:{position:"bottomleft",maxWidth:100,metric:!0,imperial:!0},onAdd:function(p){var w="leaflet-control-scale",C=Tt("div",w),E=this.options;return this._addScales(E,w+"-line",C),p.on(E.updateWhenIdle?"moveend":"move",this._update,this),p.whenReady(this._update,this),C},onRemove:function(p){p.off(this.options.updateWhenIdle?"moveend":"move",this._update,this)},_addScales:function(p,w,C){p.metric&&(this._mScale=Tt("div",w,C)),p.imperial&&(this._iScale=Tt("div",w,C))},_update:function(){var p=this._map,w=p.getSize().y/2,C=p.distance(p.containerPointToLatLng([0,w]),p.containerPointToLatLng([this.options.maxWidth,w]));this._updateScales(C)},_updateScales:function(p){this.options.metric&&p&&this._updateMetric(p),this.options.imperial&&p&&this._updateImperial(p)},_updateMetric:function(p){var w=this._getRoundNum(p),C=w<1e3?w+" m":w/1e3+" km";this._updateScale(this._mScale,C,w/p)},_updateImperial:function(p){var w=p*3.2808399,C,E,j;w>5280?(C=w/5280,E=this._getRoundNum(C),this._updateScale(this._iScale,E+" mi",E/C)):(j=this._getRoundNum(w),this._updateScale(this._iScale,j+" ft",j/w))},_updateScale:function(p,w,C){p.style.width=Math.round(this.options.maxWidth*C)+"px",p.innerHTML=w},_getRoundNum:function(p){var w=Math.pow(10,(Math.floor(p)+"").length-1),C=p/w;return C=C>=10?10:C>=5?5:C>=3?3:C>=2?2:1,w*C}}),bae=function(p){return new u5(p)},wae='',yA=ba.extend({options:{position:"bottomright",prefix:''+(Ue.inlineSvg?wae+" ":"")+"Leaflet"},initialize:function(p){g(this,p),this._attributions={}},onAdd:function(p){p.attributionControl=this,this._container=Tt("div","leaflet-control-attribution"),rp(this._container);for(var w in p._layers)p._layers[w].getAttribution&&this.addAttribution(p._layers[w].getAttribution());return this._update(),p.on("layeradd",this._addAttribution,this),this._container},onRemove:function(p){p.off("layeradd",this._addAttribution,this)},_addAttribution:function(p){p.layer.getAttribution&&(this.addAttribution(p.layer.getAttribution()),p.layer.once("remove",function(){this.removeAttribution(p.layer.getAttribution())},this))},setPrefix:function(p){return this.options.prefix=p,this._update(),this},addAttribution:function(p){return p?(this._attributions[p]||(this._attributions[p]=0),this._attributions[p]++,this._update(),this):this},removeAttribution:function(p){return p?(this._attributions[p]&&(this._attributions[p]--,this._update()),this):this},_update:function(){if(this._map){var p=[];for(var w in this._attributions)this._attributions[w]&&p.push(w);var C=[];this.options.prefix&&C.push(this.options.prefix),p.length&&C.push(p.join(", ")),this._container.innerHTML=C.join(' ')}}});bt.mergeOptions({attributionControl:!0}),bt.addInitHook(function(){this.options.attributionControl&&new yA().addTo(this)});var Sae=function(p){return new yA(p)};ba.Layers=l5,ba.Zoom=mA,ba.Scale=u5,ba.Attribution=yA,np.layers=xae,np.zoom=_ae,np.scale=bae,np.attribution=Sae;var eo=B.extend({initialize:function(p){this._map=p},enable:function(){return this._enabled?this:(this._enabled=!0,this.addHooks(),this)},disable:function(){return this._enabled?(this._enabled=!1,this.removeHooks(),this):this},enabled:function(){return!!this._enabled}});eo.addTo=function(p,w){return p.addHandler(w,this),this};var Tae={Events:F},c5=Ue.touch?"touchstart mousedown":"mousedown",Js=G.extend({options:{clickTolerance:3},initialize:function(p,w,C,E){g(this,E),this._element=p,this._dragStartTarget=w||p,this._preventOutline=C},enable:function(){this._enabled||(st(this._dragStartTarget,c5,this._onDown,this),this._enabled=!0)},disable:function(){this._enabled&&(Js._dragging===this&&this.finishDrag(!0),Ht(this._dragStartTarget,c5,this._onDown,this),this._enabled=!1,this._moved=!1)},_onDown:function(p){if(this._enabled&&(this._moved=!1,!iA(this._element,"leaflet-zoom-anim"))){if(p.touches&&p.touches.length!==1){Js._dragging===this&&this.finishDrag();return}if(!(Js._dragging||p.shiftKey||p.which!==1&&p.button!==1&&!p.touches)&&(Js._dragging=this,this._preventOutline&&cA(this._element),sA(),Jv(),!this._moving)){this.fire("down");var w=p.touches?p.touches[0]:p,C=r5(this._element);this._startPoint=new z(w.clientX,w.clientY),this._startPos=Su(this._element),this._parentScale=fA(C);var E=p.type==="mousedown";st(document,E?"mousemove":"touchmove",this._onMove,this),st(document,E?"mouseup":"touchend touchcancel",this._onUp,this)}}},_onMove:function(p){if(this._enabled){if(p.touches&&p.touches.length>1){this._moved=!0;return}var w=p.touches&&p.touches.length===1?p.touches[0]:p,C=new z(w.clientX,w.clientY)._subtract(this._startPoint);!C.x&&!C.y||Math.abs(C.x)+Math.abs(C.y)V&&(X=te,V=oe);V>C&&(w[X]=1,_A(p,w,C,E,X),_A(p,w,C,X,j))}function Pae(p,w){for(var C=[p[0]],E=1,j=0,V=p.length;Ew&&(C.push(p[E]),j=E);return jw.max.x&&(C|=2),p.yw.max.y&&(C|=8),C}function Lae(p,w){var C=w.x-p.x,E=w.y-p.y;return C*C+E*E}function ip(p,w,C,E){var j=w.x,V=w.y,X=C.x-j,te=C.y-V,oe=X*X+te*te,he;return oe>0&&(he=((p.x-j)*X+(p.y-V)*te)/oe,he>1?(j=C.x,V=C.y):he>0&&(j+=X*he,V+=te*he)),X=p.x-j,te=p.y-V,E?X*X+te*te:new z(j,V)}function Bi(p){return!b(p[0])||typeof p[0][0]!="object"&&typeof p[0][0]<"u"}function m5(p){return console.warn("Deprecated use of _flat, please use L.LineUtil.isFlat instead."),Bi(p)}function y5(p,w){var C,E,j,V,X,te,oe,he;if(!p||p.length===0)throw new Error("latlngs not passed");Bi(p)||(console.warn("latlngs are not flat! Only the first ring will be used"),p=p[0]);var Ee=ge([0,0]),et=ae(p),pt=et.getNorthWest().distanceTo(et.getSouthWest())*et.getNorthEast().distanceTo(et.getNorthWest());pt<1700&&(Ee=xA(p));var Rn=p.length,Kr=[];for(C=0;CE){oe=(V-E)/j,he=[te.x-oe*(te.x-X.x),te.y-oe*(te.y-X.y)];break}var ei=w.unproject(H(he));return ge([ei.lat+Ee.lat,ei.lng+Ee.lng])}var kae={__proto__:null,simplify:d5,pointToSegmentDistance:v5,closestPointOnSegment:Cae,clipSegment:g5,_getEdgeIntersection:I0,_getBitCode:Cu,_sqClosestPointOnSegment:ip,isFlat:Bi,_flat:m5,polylineCenter:y5},bA={project:function(p){return new z(p.lng,p.lat)},unproject:function(p){return new ce(p.y,p.x)},bounds:new Y([-180,-90],[180,90])},wA={R:6378137,R_MINOR:6356752314245179e-9,bounds:new Y([-2003750834279e-5,-1549657073972e-5],[2003750834279e-5,1876465623138e-5]),project:function(p){var w=Math.PI/180,C=this.R,E=p.lat*w,j=this.R_MINOR/C,V=Math.sqrt(1-j*j),X=V*Math.sin(E),te=Math.tan(Math.PI/4-E/2)/Math.pow((1-X)/(1+X),V/2);return E=-C*Math.log(Math.max(te,1e-10)),new z(p.lng*w*C,E)},unproject:function(p){for(var w=180/Math.PI,C=this.R,E=this.R_MINOR/C,j=Math.sqrt(1-E*E),V=Math.exp(-p.y/C),X=Math.PI/2-2*Math.atan(V),te=0,oe=.1,he;te<15&&Math.abs(oe)>1e-7;te++)he=j*Math.sin(X),he=Math.pow((1-he)/(1+he),j/2),oe=Math.PI/2-2*Math.atan(V*he)-X,X+=oe;return new ce(X*w,p.x*w/C)}},Iae={__proto__:null,LonLat:bA,Mercator:wA,SphericalMercator:fe},Oae=i({},xe,{code:"EPSG:3395",projection:wA,transformation:function(){var p=.5/(Math.PI*wA.R);return ee(p,.5,-p,.5)}()}),x5=i({},xe,{code:"EPSG:4326",projection:bA,transformation:ee(1/180,1,-1/180,.5)}),Eae=i({},We,{projection:bA,transformation:ee(1,0,-1,0),scale:function(p){return Math.pow(2,p)},zoom:function(p){return Math.log(p)/Math.LN2},distance:function(p,w){var C=w.lng-p.lng,E=w.lat-p.lat;return Math.sqrt(C*C+E*E)},infinite:!0});We.Earth=xe,We.EPSG3395=Oae,We.EPSG3857=$e,We.EPSG900913=Se,We.EPSG4326=x5,We.Simple=Eae;var wa=G.extend({options:{pane:"overlayPane",attribution:null,bubblingMouseEvents:!0},addTo:function(p){return p.addLayer(this),this},remove:function(){return this.removeFrom(this._map||this._mapToAdd)},removeFrom:function(p){return p&&p.removeLayer(this),this},getPane:function(p){return this._map.getPane(p?this.options[p]||p:this.options.pane)},addInteractiveTarget:function(p){return this._map._targets[l(p)]=this,this},removeInteractiveTarget:function(p){return delete this._map._targets[l(p)],this},getAttribution:function(){return this.options.attribution},_layerAdd:function(p){var w=p.target;if(w.hasLayer(this)){if(this._map=w,this._zoomAnimated=w._zoomAnimated,this.getEvents){var C=this.getEvents();w.on(C,this),this.once("remove",function(){w.off(C,this)},this)}this.onAdd(w),this.fire("add"),w.fire("layeradd",{layer:this})}}});bt.include({addLayer:function(p){if(!p._layerAdd)throw new Error("The provided object is not a Layer.");var w=l(p);return this._layers[w]?this:(this._layers[w]=p,p._mapToAdd=this,p.beforeAdd&&p.beforeAdd(this),this.whenReady(p._layerAdd,p),this)},removeLayer:function(p){var w=l(p);return this._layers[w]?(this._loaded&&p.onRemove(this),delete this._layers[w],this._loaded&&(this.fire("layerremove",{layer:p}),p.fire("remove")),p._map=p._mapToAdd=null,this):this},hasLayer:function(p){return l(p)in this._layers},eachLayer:function(p,w){for(var C in this._layers)p.call(w,this._layers[C]);return this},_addLayers:function(p){p=p?b(p)?p:[p]:[];for(var w=0,C=p.length;wthis._layersMaxZoom&&this.setZoom(this._layersMaxZoom),this.options.minZoom===void 0&&this._layersMinZoom&&this.getZoom()=2&&w[0]instanceof ce&&w[0].equals(w[C-1])&&w.pop(),w},_setLatLngs:function(p){qo.prototype._setLatLngs.call(this,p),Bi(this._latlngs)&&(this._latlngs=[this._latlngs])},_defaultShape:function(){return Bi(this._latlngs[0])?this._latlngs[0]:this._latlngs[0][0]},_clipPoints:function(){var p=this._renderer._bounds,w=this.options.weight,C=new z(w,w);if(p=new Y(p.min.subtract(C),p.max.add(C)),this._parts=[],!(!this._pxBounds||!this._pxBounds.intersects(p))){if(this.options.noClip){this._parts=this._rings;return}for(var E=0,j=this._rings.length,V;Ep.y!=j.y>p.y&&p.x<(j.x-E.x)*(p.y-E.y)/(j.y-E.y)+E.x&&(w=!w);return w||qo.prototype._containsPoint.call(this,p,!0)}});function Fae(p,w){return new jf(p,w)}var Ko=Xo.extend({initialize:function(p,w){g(this,w),this._layers={},p&&this.addData(p)},addData:function(p){var w=b(p)?p:p.features,C,E,j;if(w){for(C=0,E=w.length;C0&&j.push(j[0].slice()),j}function Rf(p,w){return p.feature?i({},p.feature,{geometry:w}):R0(w)}function R0(p){return p.type==="Feature"||p.type==="FeatureCollection"?p:{type:"Feature",properties:{},geometry:p}}var CA={toGeoJSON:function(p){return Rf(this,{type:"Point",coordinates:AA(this.getLatLng(),p)})}};O0.include(CA),SA.include(CA),E0.include(CA),qo.include({toGeoJSON:function(p){var w=!Bi(this._latlngs),C=j0(this._latlngs,w?1:0,!1,p);return Rf(this,{type:(w?"Multi":"")+"LineString",coordinates:C})}}),jf.include({toGeoJSON:function(p){var w=!Bi(this._latlngs),C=w&&!Bi(this._latlngs[0]),E=j0(this._latlngs,C?2:w?1:0,!0,p);return w||(E=[E]),Rf(this,{type:(C?"Multi":"")+"Polygon",coordinates:E})}}),Df.include({toMultiPoint:function(p){var w=[];return this.eachLayer(function(C){w.push(C.toGeoJSON(p).geometry.coordinates)}),Rf(this,{type:"MultiPoint",coordinates:w})},toGeoJSON:function(p){var w=this.feature&&this.feature.geometry&&this.feature.geometry.type;if(w==="MultiPoint")return this.toMultiPoint(p);var C=w==="GeometryCollection",E=[];return this.eachLayer(function(j){if(j.toGeoJSON){var V=j.toGeoJSON(p);if(C)E.push(V.geometry);else{var X=R0(V);X.type==="FeatureCollection"?E.push.apply(E,X.features):E.push(X)}}}),C?Rf(this,{geometries:E,type:"GeometryCollection"}):{type:"FeatureCollection",features:E}}});function w5(p,w){return new Ko(p,w)}var Vae=w5,B0=wa.extend({options:{opacity:1,alt:"",interactive:!1,crossOrigin:!1,errorOverlayUrl:"",zIndex:1,className:""},initialize:function(p,w,C){this._url=p,this._bounds=ae(w),g(this,C)},onAdd:function(){this._image||(this._initImage(),this.options.opacity<1&&this._updateOpacity()),this.options.interactive&&(ut(this._image,"leaflet-interactive"),this.addInteractiveTarget(this._image)),this.getPane().appendChild(this._image),this._reset()},onRemove:function(){ir(this._image),this.options.interactive&&this.removeInteractiveTarget(this._image)},setOpacity:function(p){return this.options.opacity=p,this._image&&this._updateOpacity(),this},setStyle:function(p){return p.opacity&&this.setOpacity(p.opacity),this},bringToFront:function(){return this._map&&Of(this._image),this},bringToBack:function(){return this._map&&Ef(this._image),this},setUrl:function(p){return this._url=p,this._image&&(this._image.src=p),this},setBounds:function(p){return this._bounds=ae(p),this._map&&this._reset(),this},getEvents:function(){var p={zoom:this._reset,viewreset:this._reset};return this._zoomAnimated&&(p.zoomanim=this._animateZoom),p},setZIndex:function(p){return this.options.zIndex=p,this._updateZIndex(),this},getBounds:function(){return this._bounds},getElement:function(){return this._image},_initImage:function(){var p=this._url.tagName==="IMG",w=this._image=p?this._url:Tt("img");if(ut(w,"leaflet-image-layer"),this._zoomAnimated&&ut(w,"leaflet-zoom-animated"),this.options.className&&ut(w,this.options.className),w.onselectstart=f,w.onmousemove=f,w.onload=o(this.fire,this,"load"),w.onerror=o(this._overlayOnError,this,"error"),(this.options.crossOrigin||this.options.crossOrigin==="")&&(w.crossOrigin=this.options.crossOrigin===!0?"":this.options.crossOrigin),this.options.zIndex&&this._updateZIndex(),p){this._url=w.src;return}w.src=this._url,w.alt=this.options.alt},_animateZoom:function(p){var w=this._map.getZoomScale(p.zoom),C=this._map._latLngBoundsToNewLayerBounds(this._bounds,p.zoom,p.center).min;wu(this._image,C,w)},_reset:function(){var p=this._image,w=new Y(this._map.latLngToLayerPoint(this._bounds.getNorthWest()),this._map.latLngToLayerPoint(this._bounds.getSouthEast())),C=w.getSize();Cr(p,w.min),p.style.width=C.x+"px",p.style.height=C.y+"px"},_updateOpacity:function(){Ri(this._image,this.options.opacity)},_updateZIndex:function(){this._image&&this.options.zIndex!==void 0&&this.options.zIndex!==null&&(this._image.style.zIndex=this.options.zIndex)},_overlayOnError:function(){this.fire("error");var p=this.options.errorOverlayUrl;p&&this._url!==p&&(this._url=p,this._image.src=p)},getCenter:function(){return this._bounds.getCenter()}}),Gae=function(p,w,C){return new B0(p,w,C)},S5=B0.extend({options:{autoplay:!0,loop:!0,keepAspectRatio:!0,muted:!1,playsInline:!0},_initImage:function(){var p=this._url.tagName==="VIDEO",w=this._image=p?this._url:Tt("video");if(ut(w,"leaflet-image-layer"),this._zoomAnimated&&ut(w,"leaflet-zoom-animated"),this.options.className&&ut(w,this.options.className),w.onselectstart=f,w.onmousemove=f,w.onloadeddata=o(this.fire,this,"load"),p){for(var C=w.getElementsByTagName("source"),E=[],j=0;j0?E:[w.src];return}b(this._url)||(this._url=[this._url]),!this.options.keepAspectRatio&&Object.prototype.hasOwnProperty.call(w.style,"objectFit")&&(w.style.objectFit="fill"),w.autoplay=!!this.options.autoplay,w.loop=!!this.options.loop,w.muted=!!this.options.muted,w.playsInline=!!this.options.playsInline;for(var V=0;Vj?(w.height=j+"px",ut(p,V)):_r(p,V),this._containerWidth=this._container.offsetWidth},_animateZoom:function(p){var w=this._map._latLngToNewLayerPoint(this._latlng,p.zoom,p.center),C=this._getAnchor();Cr(this._container,w.add(C))},_adjustPan:function(){if(this.options.autoPan){if(this._map._panAnim&&this._map._panAnim.stop(),this._autopanning){this._autopanning=!1;return}var p=this._map,w=parseInt(Qv(this._container,"marginBottom"),10)||0,C=this._container.offsetHeight+w,E=this._containerWidth,j=new z(this._containerLeft,-C-this._containerBottom);j._add(Su(this._container));var V=p.layerPointToContainerPoint(j),X=H(this.options.autoPanPadding),te=H(this.options.autoPanPaddingTopLeft||X),oe=H(this.options.autoPanPaddingBottomRight||X),he=p.getSize(),Ee=0,et=0;V.x+E+oe.x>he.x&&(Ee=V.x+E-he.x+oe.x),V.x-Ee-te.x<0&&(Ee=V.x-te.x),V.y+C+oe.y>he.y&&(et=V.y+C-he.y+oe.y),V.y-et-te.y<0&&(et=V.y-te.y),(Ee||et)&&(this.options.keepInView&&(this._autopanning=!0),p.fire("autopanstart").panBy([Ee,et]))}},_getAnchor:function(){return H(this._source&&this._source._getPopupAnchor?this._source._getPopupAnchor():[0,0])}}),Uae=function(p,w){return new z0(p,w)};bt.mergeOptions({closePopupOnClick:!0}),bt.include({openPopup:function(p,w,C){return this._initOverlay(z0,p,w,C).openOn(this),this},closePopup:function(p){return p=arguments.length?p:this._popup,p&&p.close(),this}}),wa.include({bindPopup:function(p,w){return this._popup=this._initOverlay(z0,this._popup,p,w),this._popupHandlersAdded||(this.on({click:this._openPopup,keypress:this._onKeyPress,remove:this.closePopup,move:this._movePopup}),this._popupHandlersAdded=!0),this},unbindPopup:function(){return this._popup&&(this.off({click:this._openPopup,keypress:this._onKeyPress,remove:this.closePopup,move:this._movePopup}),this._popupHandlersAdded=!1,this._popup=null),this},openPopup:function(p){return this._popup&&(this instanceof Xo||(this._popup._source=this),this._popup._prepareOpen(p||this._latlng)&&this._popup.openOn(this._map)),this},closePopup:function(){return this._popup&&this._popup.close(),this},togglePopup:function(){return this._popup&&this._popup.toggle(this),this},isPopupOpen:function(){return this._popup?this._popup.isOpen():!1},setPopupContent:function(p){return this._popup&&this._popup.setContent(p),this},getPopup:function(){return this._popup},_openPopup:function(p){if(!(!this._popup||!this._map)){Au(p);var w=p.layer||p.target;if(this._popup._source===w&&!(w instanceof el)){this._map.hasLayer(this._popup)?this.closePopup():this.openPopup(p.latlng);return}this._popup._source=w,this.openPopup(p.latlng)}},_movePopup:function(p){this._popup.setLatLng(p.latlng)},_onKeyPress:function(p){p.originalEvent.keyCode===13&&this._openPopup(p)}});var $0=to.extend({options:{pane:"tooltipPane",offset:[0,0],direction:"auto",permanent:!1,sticky:!1,opacity:.9},onAdd:function(p){to.prototype.onAdd.call(this,p),this.setOpacity(this.options.opacity),p.fire("tooltipopen",{tooltip:this}),this._source&&(this.addEventParent(this._source),this._source.fire("tooltipopen",{tooltip:this},!0))},onRemove:function(p){to.prototype.onRemove.call(this,p),p.fire("tooltipclose",{tooltip:this}),this._source&&(this.removeEventParent(this._source),this._source.fire("tooltipclose",{tooltip:this},!0))},getEvents:function(){var p=to.prototype.getEvents.call(this);return this.options.permanent||(p.preclick=this.close),p},_initLayout:function(){var p="leaflet-tooltip",w=p+" "+(this.options.className||"")+" leaflet-zoom-"+(this._zoomAnimated?"animated":"hide");this._contentNode=this._container=Tt("div",w),this._container.setAttribute("role","tooltip"),this._container.setAttribute("id","leaflet-tooltip-"+l(this))},_updateLayout:function(){},_adjustPan:function(){},_setPosition:function(p){var w,C,E=this._map,j=this._container,V=E.latLngToContainerPoint(E.getCenter()),X=E.layerPointToContainerPoint(p),te=this.options.direction,oe=j.offsetWidth,he=j.offsetHeight,Ee=H(this.options.offset),et=this._getAnchor();te==="top"?(w=oe/2,C=he):te==="bottom"?(w=oe/2,C=0):te==="center"?(w=oe/2,C=he/2):te==="right"?(w=0,C=he/2):te==="left"?(w=oe,C=he/2):X.xthis.options.maxZoom||CE?this._retainParent(j,V,X,E):!1)},_retainChildren:function(p,w,C,E){for(var j=2*p;j<2*p+2;j++)for(var V=2*w;V<2*w+2;V++){var X=new z(j,V);X.z=C+1;var te=this._tileCoordsToKey(X),oe=this._tiles[te];if(oe&&oe.active){oe.retain=!0;continue}else oe&&oe.loaded&&(oe.retain=!0);C+1this.options.maxZoom||this.options.minZoom!==void 0&&j1){this._setView(p,C);return}for(var et=j.min.y;et<=j.max.y;et++)for(var pt=j.min.x;pt<=j.max.x;pt++){var Rn=new z(pt,et);if(Rn.z=this._tileZoom,!!this._isValidTile(Rn)){var Kr=this._tiles[this._tileCoordsToKey(Rn)];Kr?Kr.current=!0:X.push(Rn)}}if(X.sort(function(ei,zf){return ei.distanceTo(V)-zf.distanceTo(V)}),X.length!==0){this._loading||(this._loading=!0,this.fire("loading"));var zi=document.createDocumentFragment();for(pt=0;ptC.max.x)||!w.wrapLat&&(p.yC.max.y))return!1}if(!this.options.bounds)return!0;var E=this._tileCoordsToBounds(p);return ae(this.options.bounds).overlaps(E)},_keyToBounds:function(p){return this._tileCoordsToBounds(this._keyToTileCoords(p))},_tileCoordsToNwSe:function(p){var w=this._map,C=this.getTileSize(),E=p.scaleBy(C),j=E.add(C),V=w.unproject(E,p.z),X=w.unproject(j,p.z);return[V,X]},_tileCoordsToBounds:function(p){var w=this._tileCoordsToNwSe(p),C=new J(w[0],w[1]);return this.options.noWrap||(C=this._map.wrapLatLngBounds(C)),C},_tileCoordsToKey:function(p){return p.x+":"+p.y+":"+p.z},_keyToTileCoords:function(p){var w=p.split(":"),C=new z(+w[0],+w[1]);return C.z=+w[2],C},_removeTile:function(p){var w=this._tiles[p];w&&(ir(w.el),delete this._tiles[p],this.fire("tileunload",{tile:w.el,coords:this._keyToTileCoords(p)}))},_initTile:function(p){ut(p,"leaflet-tile");var w=this.getTileSize();p.style.width=w.x+"px",p.style.height=w.y+"px",p.onselectstart=f,p.onmousemove=f,Ue.ielt9&&this.options.opacity<1&&Ri(p,this.options.opacity)},_addTile:function(p,w){var C=this._getTilePos(p),E=this._tileCoordsToKey(p),j=this.createTile(this._wrapCoords(p),o(this._tileReady,this,p));this._initTile(j),this.createTile.length<2&&O(o(this._tileReady,this,p,null,j)),Cr(j,C),this._tiles[E]={el:j,coords:p,current:!0},w.appendChild(j),this.fire("tileloadstart",{tile:j,coords:p})},_tileReady:function(p,w,C){w&&this.fire("tileerror",{error:w,tile:C,coords:p});var E=this._tileCoordsToKey(p);C=this._tiles[E],C&&(C.loaded=+new Date,this._map._fadeAnimated?(Ri(C.el,0),D(this._fadeFrame),this._fadeFrame=O(this._updateOpacity,this)):(C.active=!0,this._pruneTiles()),w||(ut(C.el,"leaflet-tile-loaded"),this.fire("tileload",{tile:C.el,coords:p})),this._noTilesToLoad()&&(this._loading=!1,this.fire("load"),Ue.ielt9||!this._map._fadeAnimated?O(this._pruneTiles,this):setTimeout(o(this._pruneTiles,this),250)))},_getTilePos:function(p){return p.scaleBy(this.getTileSize()).subtract(this._level.origin)},_wrapCoords:function(p){var w=new z(this._wrapX?c(p.x,this._wrapX):p.x,this._wrapY?c(p.y,this._wrapY):p.y);return w.z=p.z,w},_pxBoundsToTileRange:function(p){var w=this.getTileSize();return new Y(p.min.unscaleBy(w).floor(),p.max.unscaleBy(w).ceil().subtract([1,1]))},_noTilesToLoad:function(){for(var p in this._tiles)if(!this._tiles[p].loaded)return!1;return!0}});function Xae(p){return new op(p)}var Bf=op.extend({options:{minZoom:0,maxZoom:18,subdomains:"abc",errorTileUrl:"",zoomOffset:0,tms:!1,zoomReverse:!1,detectRetina:!1,crossOrigin:!1,referrerPolicy:!1},initialize:function(p,w){this._url=p,w=g(this,w),w.detectRetina&&Ue.retina&&w.maxZoom>0?(w.tileSize=Math.floor(w.tileSize/2),w.zoomReverse?(w.zoomOffset--,w.minZoom=Math.min(w.maxZoom,w.minZoom+1)):(w.zoomOffset++,w.maxZoom=Math.max(w.minZoom,w.maxZoom-1)),w.minZoom=Math.max(0,w.minZoom)):w.zoomReverse?w.minZoom=Math.min(w.maxZoom,w.minZoom):w.maxZoom=Math.max(w.minZoom,w.maxZoom),typeof w.subdomains=="string"&&(w.subdomains=w.subdomains.split("")),this.on("tileunload",this._onTileRemove)},setUrl:function(p,w){return this._url===p&&w===void 0&&(w=!0),this._url=p,w||this.redraw(),this},createTile:function(p,w){var C=document.createElement("img");return st(C,"load",o(this._tileOnLoad,this,w,C)),st(C,"error",o(this._tileOnError,this,w,C)),(this.options.crossOrigin||this.options.crossOrigin==="")&&(C.crossOrigin=this.options.crossOrigin===!0?"":this.options.crossOrigin),typeof this.options.referrerPolicy=="string"&&(C.referrerPolicy=this.options.referrerPolicy),C.alt="",C.src=this.getTileUrl(p),C},getTileUrl:function(p){var w={r:Ue.retina?"@2x":"",s:this._getSubdomain(p),x:p.x,y:p.y,z:this._getZoomForUrl()};if(this._map&&!this._map.options.crs.infinite){var C=this._globalTileRange.max.y-p.y;this.options.tms&&(w.y=C),w["-y"]=C}return _(this._url,i(w,this.options))},_tileOnLoad:function(p,w){Ue.ielt9?setTimeout(o(p,this,null,w),0):p(null,w)},_tileOnError:function(p,w,C){var E=this.options.errorTileUrl;E&&w.getAttribute("src")!==E&&(w.src=E),p(C,w)},_onTileRemove:function(p){p.tile.onload=null},_getZoomForUrl:function(){var p=this._tileZoom,w=this.options.maxZoom,C=this.options.zoomReverse,E=this.options.zoomOffset;return C&&(p=w-p),p+E},_getSubdomain:function(p){var w=Math.abs(p.x+p.y)%this.options.subdomains.length;return this.options.subdomains[w]},_abortLoading:function(){var p,w;for(p in this._tiles)if(this._tiles[p].coords.z!==this._tileZoom&&(w=this._tiles[p].el,w.onload=f,w.onerror=f,!w.complete)){w.src=T;var C=this._tiles[p].coords;ir(w),delete this._tiles[p],this.fire("tileabort",{tile:w,coords:C})}},_removeTile:function(p){var w=this._tiles[p];if(w)return w.el.setAttribute("src",T),op.prototype._removeTile.call(this,p)},_tileReady:function(p,w,C){if(!(!this._map||C&&C.getAttribute("src")===T))return op.prototype._tileReady.call(this,p,w,C)}});function C5(p,w){return new Bf(p,w)}var M5=Bf.extend({defaultWmsParams:{service:"WMS",request:"GetMap",layers:"",styles:"",format:"image/jpeg",transparent:!1,version:"1.1.1"},options:{crs:null,uppercase:!1},initialize:function(p,w){this._url=p;var C=i({},this.defaultWmsParams);for(var E in w)E in this.options||(C[E]=w[E]);w=g(this,w);var j=w.detectRetina&&Ue.retina?2:1,V=this.getTileSize();C.width=V.x*j,C.height=V.y*j,this.wmsParams=C},onAdd:function(p){this._crs=this.options.crs||p.options.crs,this._wmsVersion=parseFloat(this.wmsParams.version);var w=this._wmsVersion>=1.3?"crs":"srs";this.wmsParams[w]=this._crs.code,Bf.prototype.onAdd.call(this,p)},getTileUrl:function(p){var w=this._tileCoordsToNwSe(p),C=this._crs,E=Z(C.project(w[0]),C.project(w[1])),j=E.min,V=E.max,X=(this._wmsVersion>=1.3&&this._crs===x5?[j.y,j.x,V.y,V.x]:[j.x,j.y,V.x,V.y]).join(","),te=Bf.prototype.getTileUrl.call(this,p);return te+m(this.wmsParams,te,this.options.uppercase)+(this.options.uppercase?"&BBOX=":"&bbox=")+X},setParams:function(p,w){return i(this.wmsParams,p),w||this.redraw(),this}});function qae(p,w){return new M5(p,w)}Bf.WMS=M5,C5.wms=qae;var Qo=wa.extend({options:{padding:.1},initialize:function(p){g(this,p),l(this),this._layers=this._layers||{}},onAdd:function(){this._container||(this._initContainer(),ut(this._container,"leaflet-zoom-animated")),this.getPane().appendChild(this._container),this._update(),this.on("update",this._updatePaths,this)},onRemove:function(){this.off("update",this._updatePaths,this),this._destroyContainer()},getEvents:function(){var p={viewreset:this._reset,zoom:this._onZoom,moveend:this._update,zoomend:this._onZoomEnd};return this._zoomAnimated&&(p.zoomanim=this._onAnimZoom),p},_onAnimZoom:function(p){this._updateTransform(p.center,p.zoom)},_onZoom:function(){this._updateTransform(this._map.getCenter(),this._map.getZoom())},_updateTransform:function(p,w){var C=this._map.getZoomScale(w,this._zoom),E=this._map.getSize().multiplyBy(.5+this.options.padding),j=this._map.project(this._center,w),V=E.multiplyBy(-C).add(j).subtract(this._map._getNewPixelOrigin(p,w));Ue.any3d?wu(this._container,V,C):Cr(this._container,V)},_reset:function(){this._update(),this._updateTransform(this._center,this._zoom);for(var p in this._layers)this._layers[p]._reset()},_onZoomEnd:function(){for(var p in this._layers)this._layers[p]._project()},_updatePaths:function(){for(var p in this._layers)this._layers[p]._update()},_update:function(){var p=this.options.padding,w=this._map.getSize(),C=this._map.containerPointToLayerPoint(w.multiplyBy(-p)).round();this._bounds=new Y(C,C.add(w.multiplyBy(1+p*2)).round()),this._center=this._map.getCenter(),this._zoom=this._map.getZoom()}}),P5=Qo.extend({options:{tolerance:0},getEvents:function(){var p=Qo.prototype.getEvents.call(this);return p.viewprereset=this._onViewPreReset,p},_onViewPreReset:function(){this._postponeUpdatePaths=!0},onAdd:function(){Qo.prototype.onAdd.call(this),this._draw()},_initContainer:function(){var p=this._container=document.createElement("canvas");st(p,"mousemove",this._onMouseMove,this),st(p,"click dblclick mousedown mouseup contextmenu",this._onClick,this),st(p,"mouseout",this._handleMouseOut,this),p._leaflet_disable_events=!0,this._ctx=p.getContext("2d")},_destroyContainer:function(){D(this._redrawRequest),delete this._ctx,ir(this._container),Ht(this._container),delete this._container},_updatePaths:function(){if(!this._postponeUpdatePaths){var p;this._redrawBounds=null;for(var w in this._layers)p=this._layers[w],p._update();this._redraw()}},_update:function(){if(!(this._map._animatingZoom&&this._bounds)){Qo.prototype._update.call(this);var p=this._bounds,w=this._container,C=p.getSize(),E=Ue.retina?2:1;Cr(w,p.min),w.width=E*C.x,w.height=E*C.y,w.style.width=C.x+"px",w.style.height=C.y+"px",Ue.retina&&this._ctx.scale(2,2),this._ctx.translate(-p.min.x,-p.min.y),this.fire("update")}},_reset:function(){Qo.prototype._reset.call(this),this._postponeUpdatePaths&&(this._postponeUpdatePaths=!1,this._updatePaths())},_initPath:function(p){this._updateDashArray(p),this._layers[l(p)]=p;var w=p._order={layer:p,prev:this._drawLast,next:null};this._drawLast&&(this._drawLast.next=w),this._drawLast=w,this._drawFirst=this._drawFirst||this._drawLast},_addPath:function(p){this._requestRedraw(p)},_removePath:function(p){var w=p._order,C=w.next,E=w.prev;C?C.prev=E:this._drawLast=E,E?E.next=C:this._drawFirst=C,delete p._order,delete this._layers[l(p)],this._requestRedraw(p)},_updatePath:function(p){this._extendRedrawBounds(p),p._project(),p._update(),this._requestRedraw(p)},_updateStyle:function(p){this._updateDashArray(p),this._requestRedraw(p)},_updateDashArray:function(p){if(typeof p.options.dashArray=="string"){var w=p.options.dashArray.split(/[, ]+/),C=[],E,j;for(j=0;j')}}catch{}return function(p){return document.createElement("<"+p+' xmlns="urn:schemas-microsoft.com:vml" class="lvml">')}}(),Kae={_initContainer:function(){this._container=Tt("div","leaflet-vml-container")},_update:function(){this._map._animatingZoom||(Qo.prototype._update.call(this),this.fire("update"))},_initPath:function(p){var w=p._container=sp("shape");ut(w,"leaflet-vml-shape "+(this.options.className||"")),w.coordsize="1 1",p._path=sp("path"),w.appendChild(p._path),this._updateStyle(p),this._layers[l(p)]=p},_addPath:function(p){var w=p._container;this._container.appendChild(w),p.options.interactive&&p.addInteractiveTarget(w)},_removePath:function(p){var w=p._container;ir(w),p.removeInteractiveTarget(w),delete this._layers[l(p)]},_updateStyle:function(p){var w=p._stroke,C=p._fill,E=p.options,j=p._container;j.stroked=!!E.stroke,j.filled=!!E.fill,E.stroke?(w||(w=p._stroke=sp("stroke")),j.appendChild(w),w.weight=E.weight+"px",w.color=E.color,w.opacity=E.opacity,E.dashArray?w.dashStyle=b(E.dashArray)?E.dashArray.join(" "):E.dashArray.replace(/( *, *)/g," "):w.dashStyle="",w.endcap=E.lineCap.replace("butt","flat"),w.joinstyle=E.lineJoin):w&&(j.removeChild(w),p._stroke=null),E.fill?(C||(C=p._fill=sp("fill")),j.appendChild(C),C.color=E.fillColor||E.color,C.opacity=E.fillOpacity):C&&(j.removeChild(C),p._fill=null)},_updateCircle:function(p){var w=p._point.round(),C=Math.round(p._radius),E=Math.round(p._radiusY||C);this._setPath(p,p._empty()?"M0 0":"AL "+w.x+","+w.y+" "+C+","+E+" 0,"+65535*360)},_setPath:function(p,w){p._path.v=w},_bringToFront:function(p){Of(p._container)},_bringToBack:function(p){Ef(p._container)}},F0=Ue.vml?sp:Fe,lp=Qo.extend({_initContainer:function(){this._container=F0("svg"),this._container.setAttribute("pointer-events","none"),this._rootGroup=F0("g"),this._container.appendChild(this._rootGroup)},_destroyContainer:function(){ir(this._container),Ht(this._container),delete this._container,delete this._rootGroup,delete this._svgSize},_update:function(){if(!(this._map._animatingZoom&&this._bounds)){Qo.prototype._update.call(this);var p=this._bounds,w=p.getSize(),C=this._container;(!this._svgSize||!this._svgSize.equals(w))&&(this._svgSize=w,C.setAttribute("width",w.x),C.setAttribute("height",w.y)),Cr(C,p.min),C.setAttribute("viewBox",[p.min.x,p.min.y,w.x,w.y].join(" ")),this.fire("update")}},_initPath:function(p){var w=p._path=F0("path");p.options.className&&ut(w,p.options.className),p.options.interactive&&ut(w,"leaflet-interactive"),this._updateStyle(p),this._layers[l(p)]=p},_addPath:function(p){this._rootGroup||this._initContainer(),this._rootGroup.appendChild(p._path),p.addInteractiveTarget(p._path)},_removePath:function(p){ir(p._path),p.removeInteractiveTarget(p._path),delete this._layers[l(p)]},_updatePath:function(p){p._project(),p._update()},_updateStyle:function(p){var w=p._path,C=p.options;w&&(C.stroke?(w.setAttribute("stroke",C.color),w.setAttribute("stroke-opacity",C.opacity),w.setAttribute("stroke-width",C.weight),w.setAttribute("stroke-linecap",C.lineCap),w.setAttribute("stroke-linejoin",C.lineJoin),C.dashArray?w.setAttribute("stroke-dasharray",C.dashArray):w.removeAttribute("stroke-dasharray"),C.dashOffset?w.setAttribute("stroke-dashoffset",C.dashOffset):w.removeAttribute("stroke-dashoffset")):w.setAttribute("stroke","none"),C.fill?(w.setAttribute("fill",C.fillColor||C.color),w.setAttribute("fill-opacity",C.fillOpacity),w.setAttribute("fill-rule",C.fillRule||"evenodd")):w.setAttribute("fill","none"))},_updatePoly:function(p,w){this._setPath(p,Ye(p._parts,w))},_updateCircle:function(p){var w=p._point,C=Math.max(Math.round(p._radius),1),E=Math.max(Math.round(p._radiusY),1)||C,j="a"+C+","+E+" 0 1,0 ",V=p._empty()?"M0 0":"M"+(w.x-C)+","+w.y+j+C*2+",0 "+j+-C*2+",0 ";this._setPath(p,V)},_setPath:function(p,w){p._path.setAttribute("d",w)},_bringToFront:function(p){Of(p._path)},_bringToBack:function(p){Ef(p._path)}});Ue.vml&&lp.include(Kae);function k5(p){return Ue.svg||Ue.vml?new lp(p):null}bt.include({getRenderer:function(p){var w=p.options.renderer||this._getPaneRenderer(p.options.pane)||this.options.renderer||this._renderer;return w||(w=this._renderer=this._createRenderer()),this.hasLayer(w)||this.addLayer(w),w},_getPaneRenderer:function(p){if(p==="overlayPane"||p===void 0)return!1;var w=this._paneRenderers[p];return w===void 0&&(w=this._createRenderer({pane:p}),this._paneRenderers[p]=w),w},_createRenderer:function(p){return this.options.preferCanvas&&L5(p)||k5(p)}});var I5=jf.extend({initialize:function(p,w){jf.prototype.initialize.call(this,this._boundsToLatLngs(p),w)},setBounds:function(p){return this.setLatLngs(this._boundsToLatLngs(p))},_boundsToLatLngs:function(p){return p=ae(p),[p.getSouthWest(),p.getNorthWest(),p.getNorthEast(),p.getSouthEast()]}});function Qae(p,w){return new I5(p,w)}lp.create=F0,lp.pointsToPath=Ye,Ko.geometryToLayer=D0,Ko.coordsToLatLng=TA,Ko.coordsToLatLngs=N0,Ko.latLngToCoords=AA,Ko.latLngsToCoords=j0,Ko.getFeature=Rf,Ko.asFeature=R0,bt.mergeOptions({boxZoom:!0});var O5=eo.extend({initialize:function(p){this._map=p,this._container=p._container,this._pane=p._panes.overlayPane,this._resetStateTimeout=0,p.on("unload",this._destroy,this)},addHooks:function(){st(this._container,"mousedown",this._onMouseDown,this)},removeHooks:function(){Ht(this._container,"mousedown",this._onMouseDown,this)},moved:function(){return this._moved},_destroy:function(){ir(this._pane),delete this._pane},_resetState:function(){this._resetStateTimeout=0,this._moved=!1},_clearDeferredResetState:function(){this._resetStateTimeout!==0&&(clearTimeout(this._resetStateTimeout),this._resetStateTimeout=0)},_onMouseDown:function(p){if(!p.shiftKey||p.which!==1&&p.button!==1)return!1;this._clearDeferredResetState(),this._resetState(),Jv(),sA(),this._startPoint=this._map.mouseEventToContainerPoint(p),st(document,{contextmenu:Au,mousemove:this._onMouseMove,mouseup:this._onMouseUp,keydown:this._onKeyDown},this)},_onMouseMove:function(p){this._moved||(this._moved=!0,this._box=Tt("div","leaflet-zoom-box",this._container),ut(this._container,"leaflet-crosshair"),this._map.fire("boxzoomstart")),this._point=this._map.mouseEventToContainerPoint(p);var w=new Y(this._point,this._startPoint),C=w.getSize();Cr(this._box,w.min),this._box.style.width=C.x+"px",this._box.style.height=C.y+"px"},_finish:function(){this._moved&&(ir(this._box),_r(this._container,"leaflet-crosshair")),ep(),lA(),Ht(document,{contextmenu:Au,mousemove:this._onMouseMove,mouseup:this._onMouseUp,keydown:this._onKeyDown},this)},_onMouseUp:function(p){if(!(p.which!==1&&p.button!==1)&&(this._finish(),!!this._moved)){this._clearDeferredResetState(),this._resetStateTimeout=setTimeout(o(this._resetState,this),0);var w=new J(this._map.containerPointToLatLng(this._startPoint),this._map.containerPointToLatLng(this._point));this._map.fitBounds(w).fire("boxzoomend",{boxZoomBounds:w})}},_onKeyDown:function(p){p.keyCode===27&&(this._finish(),this._clearDeferredResetState(),this._resetState())}});bt.addInitHook("addHandler","boxZoom",O5),bt.mergeOptions({doubleClickZoom:!0});var E5=eo.extend({addHooks:function(){this._map.on("dblclick",this._onDoubleClick,this)},removeHooks:function(){this._map.off("dblclick",this._onDoubleClick,this)},_onDoubleClick:function(p){var w=this._map,C=w.getZoom(),E=w.options.zoomDelta,j=p.originalEvent.shiftKey?C-E:C+E;w.options.doubleClickZoom==="center"?w.setZoom(j):w.setZoomAround(p.containerPoint,j)}});bt.addInitHook("addHandler","doubleClickZoom",E5),bt.mergeOptions({dragging:!0,inertia:!0,inertiaDeceleration:3400,inertiaMaxSpeed:1/0,easeLinearity:.2,worldCopyJump:!1,maxBoundsViscosity:0});var D5=eo.extend({addHooks:function(){if(!this._draggable){var p=this._map;this._draggable=new Js(p._mapPane,p._container),this._draggable.on({dragstart:this._onDragStart,drag:this._onDrag,dragend:this._onDragEnd},this),this._draggable.on("predrag",this._onPreDragLimit,this),p.options.worldCopyJump&&(this._draggable.on("predrag",this._onPreDragWrap,this),p.on("zoomend",this._onZoomEnd,this),p.whenReady(this._onZoomEnd,this))}ut(this._map._container,"leaflet-grab leaflet-touch-drag"),this._draggable.enable(),this._positions=[],this._times=[]},removeHooks:function(){_r(this._map._container,"leaflet-grab"),_r(this._map._container,"leaflet-touch-drag"),this._draggable.disable()},moved:function(){return this._draggable&&this._draggable._moved},moving:function(){return this._draggable&&this._draggable._moving},_onDragStart:function(){var p=this._map;if(p._stop(),this._map.options.maxBounds&&this._map.options.maxBoundsViscosity){var w=ae(this._map.options.maxBounds);this._offsetLimit=Z(this._map.latLngToContainerPoint(w.getNorthWest()).multiplyBy(-1),this._map.latLngToContainerPoint(w.getSouthEast()).multiplyBy(-1).add(this._map.getSize())),this._viscosity=Math.min(1,Math.max(0,this._map.options.maxBoundsViscosity))}else this._offsetLimit=null;p.fire("movestart").fire("dragstart"),p.options.inertia&&(this._positions=[],this._times=[])},_onDrag:function(p){if(this._map.options.inertia){var w=this._lastTime=+new Date,C=this._lastPos=this._draggable._absPos||this._draggable._newPos;this._positions.push(C),this._times.push(w),this._prunePositions(w)}this._map.fire("move",p).fire("drag",p)},_prunePositions:function(p){for(;this._positions.length>1&&p-this._times[0]>50;)this._positions.shift(),this._times.shift()},_onZoomEnd:function(){var p=this._map.getSize().divideBy(2),w=this._map.latLngToLayerPoint([0,0]);this._initialWorldOffset=w.subtract(p).x,this._worldWidth=this._map.getPixelWorldBounds().getSize().x},_viscousLimit:function(p,w){return p-(p-w)*this._viscosity},_onPreDragLimit:function(){if(!(!this._viscosity||!this._offsetLimit)){var p=this._draggable._newPos.subtract(this._draggable._startPos),w=this._offsetLimit;p.xw.max.x&&(p.x=this._viscousLimit(p.x,w.max.x)),p.y>w.max.y&&(p.y=this._viscousLimit(p.y,w.max.y)),this._draggable._newPos=this._draggable._startPos.add(p)}},_onPreDragWrap:function(){var p=this._worldWidth,w=Math.round(p/2),C=this._initialWorldOffset,E=this._draggable._newPos.x,j=(E-w+C)%p+w-C,V=(E+w+C)%p-w-C,X=Math.abs(j+C)0?V:-V))-w;this._delta=0,this._startTime=null,X&&(p.options.scrollWheelZoom==="center"?p.setZoom(w+X):p.setZoomAround(this._lastMousePos,w+X))}});bt.addInitHook("addHandler","scrollWheelZoom",j5);var Jae=600;bt.mergeOptions({tapHold:Ue.touchNative&&Ue.safari&&Ue.mobile,tapTolerance:15});var R5=eo.extend({addHooks:function(){st(this._map._container,"touchstart",this._onDown,this)},removeHooks:function(){Ht(this._map._container,"touchstart",this._onDown,this)},_onDown:function(p){if(clearTimeout(this._holdTimeout),p.touches.length===1){var w=p.touches[0];this._startPos=this._newPos=new z(w.clientX,w.clientY),this._holdTimeout=setTimeout(o(function(){this._cancel(),this._isTapValid()&&(st(document,"touchend",un),st(document,"touchend touchcancel",this._cancelClickPrevent),this._simulateEvent("contextmenu",w))},this),Jae),st(document,"touchend touchcancel contextmenu",this._cancel,this),st(document,"touchmove",this._onMove,this)}},_cancelClickPrevent:function p(){Ht(document,"touchend",un),Ht(document,"touchend touchcancel",p)},_cancel:function(){clearTimeout(this._holdTimeout),Ht(document,"touchend touchcancel contextmenu",this._cancel,this),Ht(document,"touchmove",this._onMove,this)},_onMove:function(p){var w=p.touches[0];this._newPos=new z(w.clientX,w.clientY)},_isTapValid:function(){return this._newPos.distanceTo(this._startPos)<=this._map.options.tapTolerance},_simulateEvent:function(p,w){var C=new MouseEvent(p,{bubbles:!0,cancelable:!0,view:window,screenX:w.screenX,screenY:w.screenY,clientX:w.clientX,clientY:w.clientY});C._simulated=!0,w.target.dispatchEvent(C)}});bt.addInitHook("addHandler","tapHold",R5),bt.mergeOptions({touchZoom:Ue.touch,bounceAtZoomLimits:!0});var B5=eo.extend({addHooks:function(){ut(this._map._container,"leaflet-touch-zoom"),st(this._map._container,"touchstart",this._onTouchStart,this)},removeHooks:function(){_r(this._map._container,"leaflet-touch-zoom"),Ht(this._map._container,"touchstart",this._onTouchStart,this)},_onTouchStart:function(p){var w=this._map;if(!(!p.touches||p.touches.length!==2||w._animatingZoom||this._zooming)){var C=w.mouseEventToContainerPoint(p.touches[0]),E=w.mouseEventToContainerPoint(p.touches[1]);this._centerPoint=w.getSize()._divideBy(2),this._startLatLng=w.containerPointToLatLng(this._centerPoint),w.options.touchZoom!=="center"&&(this._pinchStartLatLng=w.containerPointToLatLng(C.add(E)._divideBy(2))),this._startDist=C.distanceTo(E),this._startZoom=w.getZoom(),this._moved=!1,this._zooming=!0,w._stop(),st(document,"touchmove",this._onTouchMove,this),st(document,"touchend touchcancel",this._onTouchEnd,this),un(p)}},_onTouchMove:function(p){if(!(!p.touches||p.touches.length!==2||!this._zooming)){var w=this._map,C=w.mouseEventToContainerPoint(p.touches[0]),E=w.mouseEventToContainerPoint(p.touches[1]),j=C.distanceTo(E)/this._startDist;if(this._zoom=w.getScaleZoom(j,this._startZoom),!w.options.bounceAtZoomLimits&&(this._zoomw.getMaxZoom()&&j>1)&&(this._zoom=w._limitZoom(this._zoom)),w.options.touchZoom==="center"){if(this._center=this._startLatLng,j===1)return}else{var V=C._add(E)._divideBy(2)._subtract(this._centerPoint);if(j===1&&V.x===0&&V.y===0)return;this._center=w.unproject(w.project(this._pinchStartLatLng,this._zoom).subtract(V),this._zoom)}this._moved||(w._moveStart(!0,!1),this._moved=!0),D(this._animRequest);var X=o(w._move,w,this._center,this._zoom,{pinch:!0,round:!1},void 0);this._animRequest=O(X,this,!0),un(p)}},_onTouchEnd:function(){if(!this._moved||!this._zooming){this._zooming=!1;return}this._zooming=!1,D(this._animRequest),Ht(document,"touchmove",this._onTouchMove,this),Ht(document,"touchend touchcancel",this._onTouchEnd,this),this._map.options.zoomAnimation?this._map._animateZoom(this._center,this._map._limitZoom(this._zoom),!0,this._map.options.zoomSnap):this._map._resetView(this._center,this._map._limitZoom(this._zoom))}});bt.addInitHook("addHandler","touchZoom",B5),bt.BoxZoom=O5,bt.DoubleClickZoom=E5,bt.Drag=D5,bt.Keyboard=N5,bt.ScrollWheelZoom=j5,bt.TapHold=R5,bt.TouchZoom=B5,r.Bounds=Y,r.Browser=Ue,r.CRS=We,r.Canvas=P5,r.Circle=SA,r.CircleMarker=E0,r.Class=B,r.Control=ba,r.DivIcon=A5,r.DivOverlay=to,r.DomEvent=mae,r.DomUtil=pae,r.Draggable=Js,r.Evented=G,r.FeatureGroup=Xo,r.GeoJSON=Ko,r.GridLayer=op,r.Handler=eo,r.Icon=Nf,r.ImageOverlay=B0,r.LatLng=ce,r.LatLngBounds=J,r.Layer=wa,r.LayerGroup=Df,r.LineUtil=kae,r.Map=bt,r.Marker=O0,r.Mixin=Tae,r.Path=el,r.Point=z,r.PolyUtil=Aae,r.Polygon=jf,r.Polyline=qo,r.Popup=z0,r.PosAnimation=s5,r.Projection=Iae,r.Rectangle=I5,r.Renderer=Qo,r.SVG=lp,r.SVGOverlay=T5,r.TileLayer=Bf,r.Tooltip=$0,r.Transformation=le,r.Util=N,r.VideoOverlay=S5,r.bind=o,r.bounds=Z,r.canvas=L5,r.circle=zae,r.circleMarker=Bae,r.control=np,r.divIcon=Yae,r.extend=i,r.featureGroup=Nae,r.geoJSON=w5,r.geoJson=Vae,r.gridLayer=Xae,r.icon=jae,r.imageOverlay=Gae,r.latLng=ge,r.latLngBounds=ae,r.layerGroup=Dae,r.map=yae,r.marker=Rae,r.point=H,r.polygon=Fae,r.polyline=$ae,r.popup=Uae,r.rectangle=Qae,r.setOptions=g,r.stamp=l,r.svg=k5,r.svgOverlay=Hae,r.tileLayer=C5,r.tooltip=Zae,r.transformation=ee,r.version=n,r.videoOverlay=Wae;var eoe=window.L;r.noConflict=function(){return window.L=eoe,this},window.L=r})})(zO,zO.exports);var Lf=zO.exports;const Bie=Ft(Lf);function w0(e,t,r){return Object.freeze({instance:e,context:t,container:r})}function NR(e,t){return t==null?function(n,i){const a=W.useRef();return a.current||(a.current=e(n,i)),a}:function(n,i){const a=W.useRef();a.current||(a.current=e(n,i));const o=W.useRef(n),{instance:s}=a.current;return W.useEffect(function(){o.current!==n&&(t(s,n,o.current),o.current=n)},[s,n,i]),a}}function zie(e,t){W.useEffect(function(){return(t.layerContainer??t.map).addLayer(e.instance),function(){var a;(a=t.layerContainer)==null||a.removeLayer(e.instance),t.map.removeLayer(e.instance)}},[t,e])}function zQe(e){return function(r){const n=KT(),i=e(QT(r,n),n);return Die(n.map,r.attribution),DR(i.current,r.eventHandlers),zie(i.current,n),i}}function $Qe(e,t){const r=W.useRef();W.useEffect(function(){if(t.pathOptions!==r.current){const i=t.pathOptions??{};e.instance.setStyle(i),r.current=i}},[e,t])}function FQe(e){return function(r){const n=KT(),i=e(QT(r,n),n);return DR(i.current,r.eventHandlers),zie(i.current,n),$Qe(i.current,r),i}}function $ie(e,t){const r=NR(e),n=BQe(r,t);return jQe(n)}function Fie(e,t){const r=NR(e,t),n=FQe(r);return NQe(n)}function VQe(e,t){const r=NR(e,t),n=zQe(r);return RQe(n)}function GQe(e,t,r){const{opacity:n,zIndex:i}=t;n!=null&&n!==r.opacity&&e.setOpacity(n),i!=null&&i!==r.zIndex&&e.setZIndex(i)}function WQe(){return KT().map}const HQe=Fie(function({center:t,children:r,...n},i){const a=new Lf.CircleMarker(t,n);return w0(a,Nie(i,{overlayContainer:a}))},OQe);function $O(){return $O=Object.assign||function(e){for(var t=1;t(d==null?void 0:d.map)??null,[d]);const g=W.useCallback(y=>{if(y!==null&&d===null){const _=new Lf.Map(y,c);r!=null&&u!=null?_.setView(r,u):e!=null&&_.fitBounds(e,t),l!=null&&_.whenReady(l),v(DQe(_))}},[]);W.useEffect(()=>()=>{d==null||d.map.remove()},[d]);const m=d?Q.createElement(Rie,{value:d},n):o??null;return Q.createElement("div",$O({},h,{ref:g}),m)}const ZQe=W.forwardRef(UQe),YQe=Fie(function({positions:t,...r},n){const i=new Lf.Polyline(t,r);return w0(i,Nie(n,{overlayContainer:i}))},function(t,r,n){r.positions!==n.positions&&t.setLatLngs(r.positions)}),XQe=$ie(function(t,r){const n=new Lf.Popup(t,r.overlayContainer);return w0(n,r)},function(t,r,{position:n},i){W.useEffect(function(){const{instance:o}=t;function s(u){u.popup===o&&(o.update(),i(!0))}function l(u){u.popup===o&&i(!1)}return r.map.on({popupopen:s,popupclose:l}),r.overlayContainer==null?(n!=null&&o.setLatLng(n),o.openOn(r.map)):r.overlayContainer.bindPopup(o),function(){var c;r.map.off({popupopen:s,popupclose:l}),(c=r.overlayContainer)==null||c.unbindPopup(),r.map.removeLayer(o)}},[t,r,i,n])}),qQe=VQe(function({url:t,...r},n){const i=new Lf.TileLayer(t,QT(r,n));return w0(i,n)},function(t,r,n){GQe(t,r,n);const{url:i}=r;i!=null&&i!==n.url&&t.setUrl(i)}),KQe=$ie(function(t,r){const n=new Lf.Tooltip(t,r.overlayContainer);return w0(n,r)},function(t,r,{position:n},i){W.useEffect(function(){const o=r.overlayContainer;if(o==null)return;const{instance:s}=t,l=c=>{c.tooltip===s&&(n!=null&&s.setLatLng(n),s.update(),i(!0))},u=c=>{c.tooltip===s&&i(!1)};return o.on({tooltipopen:l,tooltipclose:u}),o.bindTooltip(s),function(){o.off({tooltipopen:l,tooltipclose:u}),o._map!=null&&o.unbindTooltip()}},[t,r,i,n])}),QQe="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=",JQe="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==",eJe="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACkAAAApCAQAAAACach9AAACMUlEQVR4Ae3ShY7jQBAE0Aoz/f9/HTMzhg1zrdKUrJbdx+Kd2nD8VNudfsL/Th///dyQN2TH6f3y/BGpC379rV+S+qqetBOxImNQXL8JCAr2V4iMQXHGNJxeCfZXhSRBcQMfvkOWUdtfzlLgAENmZDcmo2TVmt8OSM2eXxBp3DjHSMFutqS7SbmemzBiR+xpKCNUIRkdkkYxhAkyGoBvyQFEJEefwSmmvBfJuJ6aKqKWnAkvGZOaZXTUgFqYULWNSHUckZuR1HIIimUExutRxwzOLROIG4vKmCKQt364mIlhSyzAf1m9lHZHJZrlAOMMztRRiKimp/rpdJDc9Awry5xTZCte7FHtuS8wJgeYGrex28xNTd086Dik7vUMscQOa8y4DoGtCCSkAKlNwpgNtphjrC6MIHUkR6YWxxs6Sc5xqn222mmCRFzIt8lEdKx+ikCtg91qS2WpwVfBelJCiQJwvzixfI9cxZQWgiSJelKnwBElKYtDOb2MFbhmUigbReQBV0Cg4+qMXSxXSyGUn4UbF8l+7qdSGnTC0XLCmahIgUHLhLOhpVCtw4CzYXvLQWQbJNmxoCsOKAxSgBJno75avolkRw8iIAFcsdc02e9iyCd8tHwmeSSoKTowIgvscSGZUOA7PuCN5b2BX9mQM7S0wYhMNU74zgsPBj3HU7wguAfnxxjFQGBE6pwN+GjME9zHY7zGp8wVxMShYX9NXvEWD3HbwJf4giO4CFIQxXScH1/TM+04kkBiAAAAAElFTkSuQmCC";delete Bie.Icon.Default.prototype._getIconUrl;Bie.Icon.Default.mergeOptions({iconUrl:QQe,iconRetinaUrl:JQe,shadowUrl:eJe});const EU=["#3b82f6","#a78bfa","#06b6d4","#f59e0b","#22c55e","#ec4899","#8b5cf6","#14b8a6"],tJe=["ROUTER","ROUTER_LATE","REPEATER","TRACKER"];function rJe(e){return e>12?"#22c55e":e>8?"#4ade80":e>5?"#f59e0b":e>3?"#f97316":"#ef4444"}function nJe(e){return e===null||e>46?0:e>44.5?1:e>43?2:3}function iJe(e){if(!e)return"Unknown";const t=new Date(e),n=new Date().getTime()-t.getTime(),i=Math.floor(n/6e4),a=Math.floor(n/36e5),o=Math.floor(n/864e5);return i<1?"Just now":i<60?`${i}m ago`:a<24?`${a}h ago`:`${o}d ago`}function aJe({bounds:e}){const t=WQe();return W.useEffect(()=>{e&&t.fitBounds(e,{padding:[50,50]})},[t,e]),null}function oJe({node:e}){const t=e.latitude!==null&&e.longitude!==null,r=e.battery_level!==null?e.battery_level>100||e.voltage&&e.voltage>4.1?"USB ⚡":`${e.battery_level.toFixed(0)}%`:"Unknown";return x.jsxs("div",{className:"min-w-[200px]",children:[x.jsx("div",{className:"font-semibold text-slate-800",children:e.short_name}),x.jsx("div",{className:"text-xs text-slate-600 mb-2",children:e.long_name}),x.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-1 text-xs",children:[x.jsx("div",{className:"text-slate-500",children:"Role"}),x.jsx("div",{className:"text-slate-700 font-medium",children:e.role}),x.jsx("div",{className:"text-slate-500",children:"Hardware"}),x.jsx("div",{className:"text-slate-700",children:e.hardware||"Unknown"}),x.jsx("div",{className:"text-slate-500",children:"Battery"}),x.jsx("div",{className:"text-slate-700",children:r}),x.jsx("div",{className:"text-slate-500",children:"Last Heard"}),x.jsx("div",{className:"text-slate-700",children:iJe(e.last_heard)})]}),t&&x.jsxs("div",{className:"mt-3 pt-2 border-t border-slate-200 flex gap-2",children:[x.jsxs("a",{href:`https://www.google.com/maps?q=${e.latitude},${e.longitude}`,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 text-xs text-blue-600 hover:text-blue-800",children:[x.jsx(xd,{size:10}),"Google Maps"]}),x.jsxs("a",{href:`https://www.openstreetmap.org/?mlat=${e.latitude}&mlon=${e.longitude}&zoom=14`,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 text-xs text-blue-600 hover:text-blue-800",children:[x.jsx(xd,{size:10}),"OSM"]})]})]})}function sJe({nodes:e,edges:t,selectedNodeId:r,onSelectNode:n}){const i=W.useMemo(()=>e.filter(f=>f.latitude!==null&&f.longitude!==null),[e]),a=e.length-i.length,o=W.useMemo(()=>new Map(i.map(f=>[f.node_num,f])),[i]),s=W.useMemo(()=>t.filter(f=>o.has(f.from_node)&&o.has(f.to_node)),[t,o]),l=W.useMemo(()=>{if(i.length===0)return null;const f=i.map(d=>d.latitude),h=i.map(d=>d.longitude);return[[Math.min(...f),Math.min(...h)],[Math.max(...f),Math.max(...h)]]},[i]),u=[43.6,-114.4],c=W.useMemo(()=>{const f=new Set;return r!==null&&t.forEach(h=>{h.from_node===r&&f.add(h.to_node),h.to_node===r&&f.add(h.from_node)}),f},[r,t]);return x.jsxs("div",{className:"relative bg-bg-card rounded-lg border border-border overflow-hidden",children:[x.jsxs(ZQe,{center:u,zoom:7,style:{width:"100%",height:"540px"},className:"z-0",children:[x.jsx(qQe,{url:"https://{s}.basemaps.cartocdn.com/dark_all/{z}/{x}/{y}{r}.png",attribution:'© OpenStreetMap, © CARTO'}),x.jsx(aJe,{bounds:l}),s.map((f,h)=>{const d=o.get(f.from_node),v=o.get(f.to_node),g=r===null||f.from_node===r||f.to_node===r;return x.jsx(YQe,{positions:[[d.latitude,d.longitude],[v.latitude,v.longitude]],color:rJe(f.snr),weight:g&&r!==null?2.5:1.5,opacity:r===null?.3:g?.6:.08},h)}),i.map(f=>{const h=f.node_num===r,d=c.has(f.node_num),v=r===null||h||d,g=tJe.includes(f.role),m=nJe(f.latitude),y=EU[m%EU.length];return x.jsxs(HQe,{center:[f.latitude,f.longitude],radius:g?8:5,fillColor:g?y:"#111827",fillOpacity:v?.9:.2,stroke:!0,color:h?"#ffffff":y,weight:h?3:g?0:2,opacity:v?1:.3,eventHandlers:{click:()=>n(h?null:f.node_num)},children:[x.jsx(KQe,{direction:"top",offset:[0,-8],children:x.jsx("span",{className:"font-mono text-xs",children:f.short_name})}),x.jsx(XQe,{children:x.jsx(oJe,{node:f})})]},f.node_num)})]}),x.jsxs("div",{className:"absolute bottom-4 left-4 bg-bg-card/90 backdrop-blur-sm border border-border rounded px-3 py-2 text-xs text-slate-400 flex items-center gap-2",children:[x.jsx(bZ,{size:12}),x.jsxs("span",{children:["Showing ",i.length," of ",e.length," nodes",a>0&&x.jsxs("span",{className:"text-slate-500",children:[" (",a," without coordinates)"]})]})]})]})}const DU=["#3b82f6","#a78bfa","#06b6d4","#f59e0b","#22c55e","#ec4899","#8b5cf6","#14b8a6"],lJe=["ROUTER","ROUTER_LATE","REPEATER","TRACKER"];function NU(e){return e>12?"#22c55e":e>8?"#4ade80":e>5?"#f59e0b":e>3?"#f97316":"#ef4444"}function uJe(e){return e>12?"excellent":e>8?"good":e>5?"fair":e>3?"marginal":"poor"}function cJe(e){return e===null||e>46?0:e>44.5?1:e>43?2:3}function fJe(e){return["Northern ID","Central ID","SW Idaho","SC Idaho"][e]||"Unknown"}function hJe(e){if(!e)return"Unknown";const t=new Date(e),n=new Date().getTime()-t.getTime(),i=Math.floor(n/6e4),a=Math.floor(n/36e5),o=Math.floor(n/864e5);return i<1?"Just now":i<60?`${i}m ago`:a<24?`${a}h ago`:`${o}d ago`}function dJe(e){if(!e)return"bg-slate-500";const t=new Date(e),n=(new Date().getTime()-t.getTime())/36e5;return n<1?"bg-green-500":n<24?"bg-amber-500":"bg-slate-500"}function vJe({node:e,edges:t,nodes:r,onSelectNode:n}){const i=W.useMemo(()=>{if(!e)return[];const f=new Map(r.map(d=>[d.node_num,d])),h=[];return t.forEach(d=>{if(d.from_node===e.node_num){const v=f.get(d.to_node);v&&h.push({node:v,snr:d.snr,quality:d.quality})}else if(d.to_node===e.node_num){const v=f.get(d.from_node);v&&h.push({node:v,snr:d.snr,quality:d.quality})}}),h.sort((d,v)=>v.snr-d.snr)},[e,t,r]);if(!e)return x.jsxs("div",{className:"w-[250px] flex-shrink-0 bg-bg-card border-l border-border p-4 flex flex-col items-center justify-center h-[540px]",children:[x.jsx("div",{className:"w-12 h-12 rounded-full bg-bg-hover border border-border flex items-center justify-center mb-3",children:x.jsx(tu,{size:24,className:"text-slate-500"})}),x.jsx("p",{className:"text-sm text-slate-500 text-center",children:"Click a node to inspect"})]});const a=lJe.includes(e.role),o=cJe(e.latitude),s=DU[o%DU.length],l=e.latitude!==null&&e.longitude!==null,u=e.battery_level!==null?e.battery_level>100||e.voltage&&e.voltage>4.1?"USB":`${e.battery_level.toFixed(0)}%`:"—",c=e.battery_level!==null&&(e.battery_level>100||e.voltage&&e.voltage>4.1);return x.jsxs("div",{className:"w-[250px] flex-shrink-0 bg-bg-card border-l border-border flex flex-col h-[540px] overflow-hidden",children:[x.jsxs("div",{className:"p-4 border-b border-border",children:[x.jsx("div",{className:"inline-flex items-center px-2 py-0.5 rounded text-xs font-mono mb-2",style:{backgroundColor:`${s}20`,color:s},children:e.node_id_hex}),x.jsx("div",{className:"font-mono text-lg text-slate-100",children:e.short_name}),x.jsx("div",{className:"text-xs text-slate-500 truncate",children:e.long_name})]}),x.jsxs("div",{className:"p-4 border-b border-border grid grid-cols-2 gap-3",children:[x.jsxs("div",{children:[x.jsx("div",{className:"text-xs text-slate-500 mb-0.5",children:"Role"}),x.jsx("div",{className:`text-sm font-medium ${a?"text-cyan-400":"text-slate-300"}`,children:e.role})]}),x.jsxs("div",{children:[x.jsx("div",{className:"text-xs text-slate-500 mb-0.5",children:"Region"}),x.jsx("div",{className:"text-sm text-slate-300",children:fJe(o)})]}),x.jsxs("div",{children:[x.jsx("div",{className:"text-xs text-slate-500 mb-0.5",children:"Battery"}),x.jsxs("div",{className:"text-sm text-slate-300 flex items-center gap-1",children:[c&&x.jsx(Sm,{size:12,className:"text-amber-400"}),u]})]}),x.jsxs("div",{children:[x.jsx("div",{className:"text-xs text-slate-500 mb-0.5",children:"Status"}),x.jsxs("div",{className:"flex items-center gap-1.5",children:[x.jsx("div",{className:`w-2 h-2 rounded-full ${dJe(e.last_heard)}`}),x.jsx("span",{className:"text-sm text-slate-300",children:hJe(e.last_heard)})]})]}),x.jsxs("div",{className:"col-span-2",children:[x.jsx("div",{className:"text-xs text-slate-500 mb-0.5",children:"Hardware"}),x.jsx("div",{className:"text-sm text-slate-300 font-mono truncate",children:e.hardware||"Unknown"})]})]}),l&&x.jsxs("div",{className:"px-4 py-3 border-b border-border flex gap-3",children:[x.jsxs("a",{href:`https://www.google.com/maps?q=${e.latitude},${e.longitude}`,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 text-xs text-blue-400 hover:text-blue-300",children:[x.jsx(xd,{size:10}),"Google Maps"]}),x.jsxs("a",{href:`https://www.openstreetmap.org/?mlat=${e.latitude}&mlon=${e.longitude}&zoom=14`,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 text-xs text-blue-400 hover:text-blue-300",children:[x.jsx(xd,{size:10}),"OSM"]})]}),x.jsxs("div",{className:"flex-1 overflow-y-auto",children:[x.jsxs("div",{className:"px-4 py-2 text-xs text-slate-500 font-medium sticky top-0 bg-bg-card border-b border-border",children:["Neighbors (",i.length,")"]}),i.length>0?x.jsx("div",{className:"divide-y divide-border",children:i.map(f=>x.jsxs("button",{onClick:()=>n(f.node.node_num),className:"w-full px-4 py-2 text-left hover:bg-bg-hover transition-colors flex items-center gap-2",style:{borderLeftWidth:3,borderLeftColor:NU(f.snr)},children:[x.jsxs("div",{className:"flex-1 min-w-0",children:[x.jsx("div",{className:"text-sm text-slate-200 font-mono truncate",children:f.node.short_name}),x.jsx("div",{className:"text-xs text-slate-500 truncate",children:f.node.long_name})]}),x.jsxs("div",{className:"text-right flex-shrink-0",children:[x.jsxs("div",{className:"text-xs font-mono",style:{color:NU(f.snr)},children:[f.snr.toFixed(1)," dB"]}),x.jsx("div",{className:"text-xs text-slate-500",children:uJe(f.snr)})]})]},f.node.node_num))}):x.jsx("div",{className:"px-4 py-6 text-center text-sm text-slate-500",children:"No known neighbors"})]})]})}const jU=["ROUTER","ROUTER_LATE","REPEATER","TRACKER"];function pJe(e){if(!e)return"bg-slate-500";const t=new Date(e),n=(new Date().getTime()-t.getTime())/36e5;return n<1?"bg-green-500":n<24?"bg-amber-500":"bg-slate-500"}function gJe(e){if(!e)return"—";const t=new Date(e),n=new Date().getTime()-t.getTime(),i=Math.floor(n/6e4),a=Math.floor(n/36e5),o=Math.floor(n/864e5);return i<1?"Just now":i<60?`${i}m ago`:a<24?`${a}h ago`:`${o}d ago`}function mJe(e){return e.battery_level===null?"—":e.battery_level>100||e.voltage&&e.voltage>4.1?"USB ⚡":`${e.battery_level.toFixed(0)}%`}function RU(e){return e===null?"—":e>46?"Northern":e>44.5?"Central":e>43?"SW Idaho":"SC Idaho"}function yJe({nodes:e,selectedNodeId:t,onSelectNode:r}){const[n,i]=W.useState(""),[a,o]=W.useState("short_name"),[s,l]=W.useState("asc"),[u,c]=W.useState("all"),f=W.useMemo(()=>{let v=[...e];if(u==="infra"?v=v.filter(g=>jU.includes(g.role)):u==="online"&&(v=v.filter(g=>{if(!g.last_heard)return!1;const m=new Date(g.last_heard);return(new Date().getTime()-m.getTime())/36e5<1})),n){const g=n.toLowerCase();v=v.filter(m=>m.short_name.toLowerCase().includes(g)||m.long_name.toLowerCase().includes(g)||m.role.toLowerCase().includes(g)||RU(m.latitude).toLowerCase().includes(g))}return v.sort((g,m)=>{let y="",_="";switch(a){case"short_name":y=g.short_name.toLowerCase(),_=m.short_name.toLowerCase();break;case"role":y=g.role,_=m.role;break;case"battery_level":y=g.battery_level??-1,_=m.battery_level??-1;break;case"last_heard":y=g.last_heard?new Date(g.last_heard).getTime():0,_=m.last_heard?new Date(m.last_heard).getTime():0;break;case"hardware":y=g.hardware.toLowerCase(),_=m.hardware.toLowerCase();break}return y<_?s==="asc"?-1:1:y>_?s==="asc"?1:-1:0}),v},[e,n,a,s,u]),h=v=>{a===v?l(s==="asc"?"desc":"asc"):(o(v),l("asc"))},d=({field:v})=>a!==v?null:s==="asc"?x.jsx(Zue,{size:14,className:"inline ml-1"}):x.jsx(Hy,{size:14,className:"inline ml-1"});return x.jsxs("div",{className:"bg-bg-card border border-border rounded-lg overflow-hidden",children:[x.jsxs("div",{className:"p-3 border-b border-border flex items-center gap-3",children:[x.jsxs("div",{className:"relative flex-1 max-w-xs",children:[x.jsx(HE,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-slate-500"}),x.jsx("input",{type:"text",placeholder:"Search nodes...",value:n,onChange:v=>i(v.target.value),className:"w-full pl-9 pr-3 py-1.5 bg-bg-hover border border-border rounded text-sm text-slate-200 placeholder-slate-500 focus:outline-none focus:border-accent"})]}),x.jsxs("div",{className:"flex items-center gap-1",children:[x.jsx(FE,{size:14,className:"text-slate-500 mr-1"}),["all","infra","online"].map(v=>x.jsx("button",{onClick:()=>c(v),className:`px-2 py-1 text-xs rounded transition-colors ${u===v?"bg-accent text-white":"bg-bg-hover text-slate-400 hover:text-slate-200"}`,children:v==="all"?"All":v==="infra"?"Infra":"Online"},v))]}),x.jsxs("div",{className:"text-xs text-slate-500 ml-auto",children:[f.length," of ",e.length," nodes"]})]}),x.jsxs("div",{className:"overflow-x-auto",children:[x.jsxs("table",{className:"w-full text-sm",children:[x.jsx("thead",{children:x.jsxs("tr",{className:"bg-bg-hover text-slate-400 text-xs",children:[x.jsx("th",{className:"w-8 px-3 py-2"}),x.jsxs("th",{className:"px-3 py-2 text-left cursor-pointer hover:text-slate-200",onClick:()=>h("short_name"),children:["Name ",x.jsx(d,{field:"short_name"})]}),x.jsxs("th",{className:"px-3 py-2 text-left cursor-pointer hover:text-slate-200",onClick:()=>h("role"),children:["Role ",x.jsx(d,{field:"role"})]}),x.jsx("th",{className:"px-3 py-2 text-left",children:"Region"}),x.jsxs("th",{className:"px-3 py-2 text-left cursor-pointer hover:text-slate-200",onClick:()=>h("battery_level"),children:["Battery ",x.jsx(d,{field:"battery_level"})]}),x.jsxs("th",{className:"px-3 py-2 text-left cursor-pointer hover:text-slate-200",onClick:()=>h("last_heard"),children:["Last Heard ",x.jsx(d,{field:"last_heard"})]}),x.jsxs("th",{className:"px-3 py-2 text-left cursor-pointer hover:text-slate-200",onClick:()=>h("hardware"),children:["Hardware ",x.jsx(d,{field:"hardware"})]})]})}),x.jsx("tbody",{className:"divide-y divide-border",children:f.slice(0,100).map(v=>{const g=jU.includes(v.role),m=v.node_num===t;return x.jsxs("tr",{onClick:()=>r(v.node_num),className:`cursor-pointer transition-colors ${m?"bg-accent/10":"hover:bg-bg-hover"}`,children:[x.jsx("td",{className:"px-3 py-2",children:x.jsx("div",{className:`w-2 h-2 rounded-full ${pJe(v.last_heard)}`})}),x.jsxs("td",{className:"px-3 py-2",children:[x.jsx("div",{className:"font-mono text-slate-200",children:v.short_name}),x.jsx("div",{className:"text-xs text-slate-500 truncate max-w-[200px]",children:v.long_name})]}),x.jsx("td",{className:"px-3 py-2",children:x.jsx("span",{className:`inline-block px-1.5 py-0.5 rounded text-xs font-medium ${g?"bg-cyan-500/20 text-cyan-400":"bg-slate-500/20 text-slate-400"}`,children:v.role})}),x.jsx("td",{className:"px-3 py-2 text-slate-400",children:RU(v.latitude)}),x.jsx("td",{className:"px-3 py-2 font-mono text-slate-300",children:mJe(v)}),x.jsx("td",{className:"px-3 py-2 text-slate-400",children:gJe(v.last_heard)}),x.jsx("td",{className:"px-3 py-2 font-mono text-xs text-slate-400 truncate max-w-[150px]",children:v.hardware||"—"})]},v.node_num)})})]}),f.length>100&&x.jsxs("div",{className:"px-3 py-2 text-xs text-slate-500 text-center border-t border-border",children:["Showing first 100 of ",f.length," nodes"]}),f.length===0&&x.jsx("div",{className:"px-3 py-8 text-sm text-slate-500 text-center",children:"No nodes match your filters"})]})]})}function xJe(){const[e,t]=W.useState([]),[r,n]=W.useState([]),[i,a]=W.useState([]),[o,s]=W.useState(null),[l,u]=W.useState("topo"),[c,f]=W.useState(!0),[h,d]=W.useState(null);W.useEffect(()=>{document.title="Mesh — MeshAI",Promise.all([oce(),sce(),gce()]).then(([m,y,_])=>{t(m),n(y),a(_),f(!1)}).catch(m=>{d(m.message),f(!1)})},[]);const v=W.useMemo(()=>e.find(m=>m.node_num===o)||null,[e,o]),g=W.useCallback(m=>{s(m)},[]);return c?x.jsx("div",{className:"flex items-center justify-center h-64",children:x.jsx("div",{className:"text-slate-400",children:"Loading mesh data..."})}):h?x.jsx("div",{className:"flex items-center justify-center h-64",children:x.jsxs("div",{className:"text-red-400",children:["Error: ",h]})}):x.jsxs("div",{className:"space-y-6",children:[x.jsxs("div",{className:"flex items-center justify-between",children:[x.jsxs("div",{className:"text-sm text-slate-400",children:[e.length," nodes • ",r.length," edges"]}),x.jsxs("div",{className:"flex items-center bg-bg-card border border-border rounded-lg p-1",children:[x.jsxs("button",{onClick:()=>u("topo"),className:`flex items-center gap-2 px-3 py-1.5 rounded text-sm transition-colors ${l==="topo"?"bg-accent text-white":"text-slate-400 hover:text-slate-200"}`,children:[x.jsx(tce,{size:14}),"Topology"]}),x.jsxs("button",{onClick:()=>u("geo"),className:`flex items-center gap-2 px-3 py-1.5 rounded text-sm transition-colors ${l==="geo"?"bg-accent text-white":"text-slate-400 hover:text-slate-200"}`,children:[x.jsx(Que,{size:14}),"Geographic"]})]})]}),x.jsxs("div",{className:"flex gap-0",children:[x.jsx("div",{className:"flex-1 min-w-0",children:l==="topo"?x.jsx(IQe,{nodes:e,edges:r,selectedNodeId:o,onSelectNode:g}):x.jsx(sJe,{nodes:e,edges:r,selectedNodeId:o,onSelectNode:g})}),x.jsx(vJe,{node:v,edges:r,nodes:e,onSelectNode:g})]}),x.jsx(yJe,{nodes:e,selectedNodeId:o,onSelectNode:g})]})}function _Je({feed:e}){const t=()=>e.is_loaded?e.consecutive_errors>0?"bg-amber-500":"bg-green-500":"bg-red-500",r=()=>e.is_loaded?e.consecutive_errors>0?`${e.consecutive_errors} errors`:"Healthy":"Not loaded",n=i=>i?new Date(i*1e3).toLocaleTimeString():"Never";return x.jsxs("div",{className:"bg-bg-hover rounded-lg p-4",children:[x.jsxs("div",{className:"flex items-center justify-between mb-2",children:[x.jsxs("div",{className:"flex items-center gap-2",children:[x.jsx("div",{className:`w-2 h-2 rounded-full ${t()}`}),x.jsx("span",{className:"text-sm font-medium text-slate-200 uppercase",children:e.source})]}),x.jsx("span",{className:"text-xs text-slate-400",children:r()})]}),x.jsxs("div",{className:"text-xs text-slate-500 space-y-1",children:[x.jsxs("div",{children:["Events: ",e.event_count]}),x.jsxs("div",{children:["Last fetch: ",n(e.last_fetch)]}),e.last_error&&x.jsx("div",{className:"text-amber-500 truncate",children:e.last_error})]})]})}function bJe({event:e}){const r=(a=>{switch(a.toLowerCase()){case"extreme":case"severe":return{bg:"bg-red-500/10",border:"border-red-500",icon:Uy,iconColor:"text-red-500"};case"moderate":case"warning":return{bg:"bg-amber-500/10",border:"border-amber-500",icon:Ds,iconColor:"text-amber-500"};case"minor":return{bg:"bg-yellow-500/10",border:"border-yellow-500",icon:wm,iconColor:"text-yellow-500"};default:return{bg:"bg-slate-500/10",border:"border-slate-500",icon:wm,iconColor:"text-slate-400"}}})(e.severity),n=r.icon,i=a=>a?new Date(a*1e3).toLocaleString():null;return x.jsx("div",{className:`p-4 rounded-lg ${r.bg} border-l-2 ${r.border}`,children:x.jsxs("div",{className:"flex items-start gap-3",children:[x.jsx(n,{size:18,className:r.iconColor}),x.jsxs("div",{className:"flex-1 min-w-0",children:[x.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[x.jsx("span",{className:"text-sm font-medium text-slate-200",children:e.event_type}),x.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded ${r.bg} ${r.iconColor}`,children:e.severity})]}),x.jsx("div",{className:"text-sm text-slate-300 mb-2",children:e.headline}),e.description&&x.jsx("div",{className:"text-xs text-slate-400 mb-2 line-clamp-2",children:e.description}),x.jsxs("div",{className:"flex items-center gap-4 text-xs text-slate-500",children:[x.jsx("span",{className:"uppercase",children:e.source}),e.expires&&x.jsxs("span",{children:["Expires: ",i(e.expires)]})]})]})]})})}function wJe({swpc:e}){var n,i;if(!e||!e.enabled)return x.jsxs("div",{className:"bg-bg-card border border-border rounded-lg p-6",children:[x.jsxs("h2",{className:"text-sm font-medium text-slate-400 mb-4 flex items-center gap-2",children:[x.jsx(Vb,{size:14}),"Solar/Geomagnetic Indices"]}),x.jsx("div",{className:"text-slate-500",children:"Data not available"})]});const t=a=>a===void 0?"text-slate-400":a<=2?"text-green-500":a<=4?"text-amber-500":a<=6?"text-orange-500":"text-red-500",r=a=>a===void 0||a===0?"text-green-500":a<=2?"text-amber-500":a<=3?"text-orange-500":"text-red-500";return x.jsxs("div",{className:"bg-bg-card border border-border rounded-lg p-6",children:[x.jsxs("h2",{className:"text-sm font-medium text-slate-400 mb-4 flex items-center gap-2",children:[x.jsx(Vb,{size:14}),"Solar/Geomagnetic Indices"]}),x.jsxs("div",{className:"grid grid-cols-2 gap-4 mb-4",children:[x.jsxs("div",{className:"bg-bg-hover rounded-lg p-3",children:[x.jsx("div",{className:"text-xs text-slate-500 mb-1",children:"Solar Flux Index"}),x.jsx("div",{className:"text-2xl font-mono text-slate-100",children:((n=e.sfi)==null?void 0:n.toFixed(0))??"—"}),x.jsx("div",{className:"text-xs text-slate-500",children:"SFI (10.7 cm)"})]}),x.jsxs("div",{className:"bg-bg-hover rounded-lg p-3",children:[x.jsx("div",{className:"text-xs text-slate-500 mb-1",children:"Planetary K-Index"}),x.jsx("div",{className:`text-2xl font-mono ${t(e.kp_current)}`,children:((i=e.kp_current)==null?void 0:i.toFixed(1))??"—"}),x.jsx("div",{className:"text-xs text-slate-500",children:"Kp"})]})]}),x.jsxs("div",{className:"bg-bg-hover rounded-lg p-3 mb-4",children:[x.jsx("div",{className:"text-xs text-slate-500 mb-2",children:"NOAA Space Weather Scales"}),x.jsxs("div",{className:"flex items-center gap-4",children:[x.jsxs("div",{className:"flex items-center gap-1",children:[x.jsx("span",{className:"text-xs text-slate-400",children:"R:"}),x.jsx("span",{className:`text-sm font-mono ${r(e.r_scale)}`,children:e.r_scale??0})]}),x.jsxs("div",{className:"flex items-center gap-1",children:[x.jsx("span",{className:"text-xs text-slate-400",children:"S:"}),x.jsx("span",{className:`text-sm font-mono ${r(e.s_scale)}`,children:e.s_scale??0})]}),x.jsxs("div",{className:"flex items-center gap-1",children:[x.jsx("span",{className:"text-xs text-slate-400",children:"G:"}),x.jsx("span",{className:`text-sm font-mono ${r(e.g_scale)}`,children:e.g_scale??0})]})]}),x.jsx("div",{className:"text-xs text-slate-500 mt-2",children:"Radio Blackout / Solar Radiation / Geomagnetic Storm"})]}),e.active_warnings&&e.active_warnings.length>0&&x.jsxs("div",{className:"space-y-2",children:[x.jsx("div",{className:"text-xs text-slate-500",children:"Active Warnings"}),e.active_warnings.slice(0,3).map((a,o)=>x.jsx("div",{className:"text-xs text-amber-400 bg-amber-500/10 rounded p-2",children:a},o))]})]})}function SJe({ducting:e}){if(!e||!e.enabled)return x.jsxs("div",{className:"bg-bg-card border border-border rounded-lg p-6",children:[x.jsxs("h2",{className:"text-sm font-medium text-slate-400 mb-4 flex items-center gap-2",children:[x.jsx(s3,{size:14}),"Tropospheric Ducting"]}),x.jsx("div",{className:"text-slate-500",children:"Data not available"})]});const t=n=>{switch(n){case"normal":return"text-green-500";case"super_refraction":return"text-amber-500";case"surface_duct":case"elevated_duct":return"text-blue-400";default:return"text-slate-400"}},r=n=>n?n.replace("_"," ").replace(/\b\w/g,i=>i.toUpperCase()):"Unknown";return x.jsxs("div",{className:"bg-bg-card border border-border rounded-lg p-6",children:[x.jsxs("h2",{className:"text-sm font-medium text-slate-400 mb-4 flex items-center gap-2",children:[x.jsx(s3,{size:14}),"Tropospheric Ducting"]}),x.jsxs("div",{className:"bg-bg-hover rounded-lg p-4 mb-4",children:[x.jsx("div",{className:"text-xs text-slate-500 mb-1",children:"Condition"}),x.jsx("div",{className:`text-xl font-medium ${t(e.condition)}`,children:r(e.condition)})]}),x.jsxs("div",{className:"grid grid-cols-2 gap-4 mb-4",children:[x.jsxs("div",{className:"bg-bg-hover rounded-lg p-3",children:[x.jsx("div",{className:"text-xs text-slate-500 mb-1",children:"Min Gradient"}),x.jsx("div",{className:"text-lg font-mono text-slate-100",children:e.min_gradient??"—"}),x.jsx("div",{className:"text-xs text-slate-500",children:"M-units/km"})]}),e.duct_thickness_m&&x.jsxs("div",{className:"bg-bg-hover rounded-lg p-3",children:[x.jsx("div",{className:"text-xs text-slate-500 mb-1",children:"Duct Thickness"}),x.jsx("div",{className:"text-lg font-mono text-slate-100",children:e.duct_thickness_m}),x.jsx("div",{className:"text-xs text-slate-500",children:"meters"})]}),e.duct_base_m&&x.jsxs("div",{className:"bg-bg-hover rounded-lg p-3",children:[x.jsx("div",{className:"text-xs text-slate-500 mb-1",children:"Duct Base"}),x.jsx("div",{className:"text-lg font-mono text-slate-100",children:e.duct_base_m}),x.jsx("div",{className:"text-xs text-slate-500",children:"meters AGL"})]})]}),x.jsxs("div",{className:"text-xs text-slate-500 bg-bg-hover rounded p-2",children:[x.jsx("div",{children:"dM/dz reference:"}),x.jsxs("div",{className:"mt-1 space-y-0.5",children:[x.jsx("div",{children:">79: Normal propagation"}),x.jsx("div",{children:"0–79: Super-refraction"}),x.jsx("div",{children:"<0: Ducting (trapping layer)"})]})]}),e.last_update&&x.jsxs("div",{className:"text-xs text-slate-500 mt-3",children:["Last update: ",e.last_update]})]})}function TJe(){var I;const[e,t]=W.useState(null),[r,n]=W.useState([]),[i,a]=W.useState(null),[o,s]=W.useState(null),[l,u]=W.useState([]),[c,f]=W.useState(null),[h,d]=W.useState([]),[v,g]=W.useState([]),[m,y]=W.useState([]),[_,b]=W.useState([]),[S,T]=W.useState(0),[A,M]=W.useState(!0),[P,k]=W.useState(null);return W.useEffect(()=>{document.title="Environment — MeshAI",Promise.all([LZ().catch(()=>null),kZ().catch(()=>[]),IZ().catch(()=>null),OZ().catch(()=>null),cce().catch(()=>[]),fce().catch(()=>null),hce().catch(()=>[]),dce().catch(()=>[]),vce().catch(()=>[]),pce().catch(()=>({hotspots:[],new_ignitions:0}))]).then(([O,D,N,B,$,F,G,z,U,H])=>{t(O),n(D),a(N),s(B),u($),f(F),d(G||[]),g(z||[]),y(U||[]),b((H==null?void 0:H.hotspots)||[]),T((H==null?void 0:H.new_ignitions)||0),M(!1)}).catch(O=>{k(O.message),M(!1)})},[]),A?x.jsx("div",{className:"flex items-center justify-center h-64",children:x.jsx("div",{className:"text-slate-400",children:"Loading environmental data..."})}):P?x.jsx("div",{className:"flex items-center justify-center h-64",children:x.jsxs("div",{className:"text-red-400",children:["Error: ",P]})}):e!=null&&e.enabled?x.jsxs("div",{className:"space-y-6",children:[x.jsxs("div",{className:"flex items-center justify-between",children:[x.jsx("h1",{className:"text-xl font-semibold text-slate-200",children:"Environment"}),x.jsxs("div",{className:"text-xs text-slate-500",children:[r.length," active event",r.length!==1?"s":""]})]}),x.jsxs("div",{className:"bg-bg-card border border-border rounded-lg p-6",children:[x.jsxs("h2",{className:"text-sm font-medium text-slate-400 mb-4 flex items-center gap-2",children:[x.jsx(Wy,{size:14}),"Feed Status"]}),x.jsx("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:e.feeds.map(O=>x.jsx(_Je,{feed:O},O.source))})]}),x.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[x.jsx(wJe,{swpc:i}),x.jsx(SJe,{ducting:o})]}),x.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[x.jsxs("div",{className:"bg-bg-card border border-border rounded-lg p-6",children:[x.jsxs("h2",{className:"text-sm font-medium text-slate-400 mb-4 flex items-center gap-2",children:[x.jsx(VE,{size:14}),"Active Wildfires (",l.length,")"]}),l.length>0?x.jsx("div",{className:"space-y-3",children:l.map(O=>x.jsxs("div",{className:`p-3 rounded-lg ${O.severity==="warning"?"bg-red-500/10 border-l-2 border-red-500":O.severity==="watch"?"bg-amber-500/10 border-l-2 border-amber-500":"bg-slate-500/10 border-l-2 border-slate-500"}`,children:[x.jsxs("div",{className:"flex items-center justify-between mb-1",children:[x.jsx("span",{className:"text-sm font-medium text-slate-200",children:O.name}),x.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded ${O.severity==="warning"?"bg-red-500/20 text-red-400":O.severity==="watch"?"bg-amber-500/20 text-amber-400":"bg-slate-500/20 text-slate-400"}`,children:O.severity})]}),x.jsxs("div",{className:"text-xs text-slate-400 space-y-1",children:[x.jsxs("div",{children:[O.acres.toLocaleString()," acres, ",O.pct_contained,"% contained"]}),O.distance_km&&O.nearest_anchor&&x.jsxs("div",{children:[Math.round(O.distance_km)," km from ",O.nearest_anchor]})]})]},O.event_id))}):x.jsxs("div",{className:"flex items-center gap-2 text-slate-500 py-4",children:[x.jsx(Qh,{size:16,className:"text-green-500"}),x.jsx("span",{children:"No active wildfires in the area"})]})]}),x.jsxs("div",{className:"bg-bg-card border border-border rounded-lg p-6",children:[x.jsxs("h2",{className:"text-sm font-medium text-slate-400 mb-4 flex items-center gap-2",children:[x.jsx(GE,{size:14}),"Avalanche Advisories"]}),c!=null&&c.off_season?x.jsx("div",{className:"text-slate-500 py-4",children:x.jsx("p",{children:"Off season - check back in December"})}):c&&c.advisories.length>0?x.jsxs("div",{className:"space-y-3",children:[c.advisories.map(O=>x.jsxs("div",{className:`p-3 rounded-lg ${O.danger_level>=4?"bg-red-500/10 border-l-2 border-red-500":O.danger_level>=3?"bg-amber-500/10 border-l-2 border-amber-500":O.danger_level>=2?"bg-yellow-500/10 border-l-2 border-yellow-500":"bg-green-500/10 border-l-2 border-green-500"}`,children:[x.jsxs("div",{className:"flex items-center justify-between mb-1",children:[x.jsx("span",{className:"text-sm font-medium text-slate-200",children:O.zone_name}),x.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded ${O.danger_level>=4?"bg-red-500/20 text-red-400":O.danger_level>=3?"bg-amber-500/20 text-amber-400":O.danger_level>=2?"bg-yellow-500/20 text-yellow-400":"bg-green-500/20 text-green-400"}`,children:O.danger_name})]}),x.jsx("div",{className:"text-xs text-slate-400",children:O.center}),O.travel_advice&&x.jsx("div",{className:"text-xs text-slate-500 mt-2 line-clamp-2",children:O.travel_advice})]},O.event_id)),((I=c.advisories[0])==null?void 0:I.center_link)&&x.jsx("a",{href:c.advisories[0].center_link,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-blue-400 hover:underline",children:"View full forecast"})]}):x.jsxs("div",{className:"flex items-center gap-2 text-slate-500 py-4",children:[x.jsx(Qh,{size:16,className:"text-green-500"}),x.jsx("span",{children:"No avalanche advisories"})]})]})]}),h.length>0&&x.jsxs("div",{className:"bg-bg-card border border-border rounded-lg p-6",children:[x.jsxs("h2",{className:"text-sm font-medium text-slate-400 mb-4 flex items-center gap-2",children:[x.jsx(zE,{size:14}),"Stream Gauges (",h.length,")"]}),x.jsx("div",{className:"space-y-2",children:h.map(O=>{var D,N,B,$,F;return x.jsxs("div",{className:`p-3 rounded-lg ${O.severity==="warning"?"bg-amber-500/10 border-l-2 border-amber-500":"bg-blue-500/10 border-l-2 border-blue-500"}`,children:[x.jsxs("div",{className:"flex items-center justify-between",children:[x.jsx("span",{className:"text-sm text-slate-200",children:((D=O.properties)==null?void 0:D.site_name)||"Unknown Site"}),x.jsxs("span",{className:"text-sm font-mono text-slate-300",children:[(B=(N=O.properties)==null?void 0:N.value)==null?void 0:B.toLocaleString()," ",($=O.properties)==null?void 0:$.unit]})]}),x.jsx("div",{className:"text-xs text-slate-500 mt-1",children:(F=O.properties)==null?void 0:F.parameter})]},O.event_id)})})]}),(v.length>0||m.length>0)&&x.jsxs("div",{className:"bg-bg-card border border-border rounded-lg p-6",children:[x.jsxs("h2",{className:"text-sm font-medium text-slate-400 mb-4 flex items-center gap-2",children:[x.jsx(BE,{size:14}),"Road Conditions"]}),v.length>0&&x.jsxs("div",{className:"mb-4",children:[x.jsx("div",{className:"text-xs text-slate-500 mb-2 uppercase",children:"Traffic Flow"}),x.jsx("div",{className:"space-y-2",children:v.map(O=>{var D,N,B,$,F,G,z,U,H;return x.jsxs("div",{className:`p-3 rounded-lg ${(D=O.properties)!=null&&D.roadClosure?"bg-red-500/10 border-l-2 border-red-500":((N=O.properties)==null?void 0:N.speedRatio)<.5?"bg-amber-500/10 border-l-2 border-amber-500":((B=O.properties)==null?void 0:B.speedRatio)<.8?"bg-yellow-500/10 border-l-2 border-yellow-500":"bg-green-500/10 border-l-2 border-green-500"}`,children:[x.jsxs("div",{className:"flex items-center justify-between",children:[x.jsx("span",{className:"text-sm text-slate-200",children:(($=O.properties)==null?void 0:$.corridor)||"Unknown"}),x.jsx("span",{className:"text-sm font-mono text-slate-300",children:(F=O.properties)!=null&&F.roadClosure?"CLOSED":`${Math.round(((G=O.properties)==null?void 0:G.currentSpeed)||0)}mph`})]}),!((z=O.properties)!=null&&z.roadClosure)&&x.jsxs("div",{className:"text-xs text-slate-500 mt-1",children:[Math.round((((U=O.properties)==null?void 0:U.speedRatio)||1)*100),"% of free flow (",Math.round(((H=O.properties)==null?void 0:H.freeFlowSpeed)||0),"mph)"]})]},O.event_id)})})]}),m.length>0&&x.jsxs("div",{children:[x.jsx("div",{className:"text-xs text-slate-500 mb-2 uppercase",children:"Road Events"}),x.jsx("div",{className:"space-y-2",children:m.map(O=>{var D,N;return x.jsxs("div",{className:`p-3 rounded-lg ${(D=O.properties)!=null&&D.is_closure?"bg-red-500/10 border-l-2 border-red-500":"bg-amber-500/10 border-l-2 border-amber-500"}`,children:[x.jsxs("div",{className:"flex items-center gap-2",children:[((N=O.properties)==null?void 0:N.is_closure)&&x.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-red-500/20 text-red-400",children:"CLOSURE"}),x.jsx("span",{className:"text-sm text-slate-200 line-clamp-1",children:O.headline})]}),x.jsx("div",{className:"text-xs text-slate-500 mt-1 uppercase",children:O.event_type})]},O.event_id)})})]})]}),_.length>0&&x.jsxs("div",{className:"bg-bg-card border border-border rounded-lg p-6",children:[x.jsxs("h2",{className:"text-sm font-medium text-slate-400 mb-4 flex items-center gap-2",children:[x.jsx(WE,{size:14}),"Satellite Hotspots (",_.length,")",S>0&&x.jsxs("span",{className:"ml-2 px-2 py-0.5 text-xs rounded-full bg-red-500/20 text-red-400 animate-pulse",children:[S," NEW"]})]}),x.jsx("div",{className:"space-y-2",children:_.map(O=>{var D,N,B,$,F,G;return x.jsxs("div",{className:`p-3 rounded-lg ${(D=O.properties)!=null&&D.new_ignition?"bg-red-500/10 border-l-2 border-red-500":O.severity==="watch"?"bg-amber-500/10 border-l-2 border-amber-500":"bg-orange-500/10 border-l-2 border-orange-500"}`,children:[x.jsxs("div",{className:"flex items-center justify-between",children:[x.jsxs("div",{className:"flex items-center gap-2",children:[((N=O.properties)==null?void 0:N.new_ignition)&&x.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-red-500/20 text-red-400",children:"NEW"}),x.jsx("span",{className:"text-sm text-slate-200",children:O.headline})]}),((B=O.properties)==null?void 0:B.frp)&&x.jsxs("span",{className:"text-sm font-mono text-orange-400",children:[Math.round(O.properties.frp)," MW"]})]}),x.jsxs("div",{className:"text-xs text-slate-500 mt-1 flex items-center gap-3",children:[x.jsxs("span",{children:["Conf: ",(($=O.properties)==null?void 0:$.confidence)||"N/A"]}),((F=O.properties)==null?void 0:F.acq_time)&&x.jsxs("span",{children:["@",O.properties.acq_time,"Z"]}),((G=O.properties)==null?void 0:G.near_fire)&&x.jsxs("span",{children:["Near: ",O.properties.near_fire]})]})]},O.event_id)})})]}),x.jsxs("div",{className:"bg-bg-card border border-border rounded-lg p-6",children:[x.jsxs("h2",{className:"text-sm font-medium text-slate-400 mb-4 flex items-center gap-2",children:[x.jsx(Ds,{size:14}),"Active Events (",r.length,")"]}),r.length>0?x.jsx("div",{className:"space-y-3",children:r.map(O=>x.jsx(bJe,{event:O},O.event_id))}):x.jsxs("div",{className:"flex items-center gap-2 text-slate-500 py-4",children:[x.jsx(Qh,{size:16,className:"text-green-500"}),x.jsx("span",{children:"No active environmental events"})]})]})]}):x.jsxs("div",{className:"flex flex-col items-center justify-center h-[60vh] text-center",children:[x.jsx("div",{className:"w-16 h-16 rounded-full bg-bg-card border border-border flex items-center justify-center mb-6",children:x.jsx(Yc,{size:32,className:"text-slate-500"})}),x.jsx("h2",{className:"text-xl font-semibold text-slate-300 mb-2",children:"Environmental Feeds Disabled"}),x.jsx("p",{className:"text-slate-500 max-w-md",children:"Enable environmental feeds in config.yaml to see weather alerts, space weather indices, and tropospheric ducting data."})]})}function jR({label:e,value:t,onChange:r,helper:n,info:i,roleFilter:a,valueType:o="short_name"}){const[s,l]=W.useState([]),[u,c]=W.useState(!0),[f,h]=W.useState(""),[d,v]=W.useState(!1);W.useEffect(()=>{fetch("/api/nodes").then(S=>S.json()).then(S=>{l(S),c(!1)}).catch(()=>{l([]),c(!1)})},[]);const g=W.useMemo(()=>{let S=s;if(a&&(S=S.filter(T=>a==="ROUTER"||a==="infrastructure"?T.is_infrastructure||T.role==="ROUTER"||T.role==="ROUTER_CLIENT"||T.role==="REPEATER":T.role===a)),f.trim()){const T=f.toLowerCase();S=S.filter(A=>{var M,P,k,I;return((M=A.short_name)==null?void 0:M.toLowerCase().includes(T))||((P=A.long_name)==null?void 0:P.toLowerCase().includes(T))||((k=A.role)==null?void 0:k.toLowerCase().includes(T))||((I=A.node_id_hex)==null?void 0:I.toLowerCase().includes(T))})}return S.sort((T,A)=>(T.short_name||"").localeCompare(A.short_name||""))},[s,f,a]),m=S=>{switch(o){case"node_num":return String(S.node_num);case"node_id_hex":return S.node_id_hex;default:return S.short_name||String(S.node_num)}},y=S=>{const T=m(S);return t.includes(T)},_=S=>{const T=m(S);t.includes(T)?r(t.filter(A=>A!==T)):r([...t,T])},b=S=>{const T=[S.short_name];return S.long_name&&S.long_name!==S.short_name&&T.push(`— ${S.long_name}`),S.role&&T.push(`(${S.role})`),T.join(" ")};return!u&&s.length===0?x.jsxs("div",{className:"space-y-1",children:[x.jsx("label",{className:"block text-xs text-slate-500 uppercase tracking-wide",children:e}),x.jsx("input",{type:"text",value:t.join(", "),onChange:S=>r(S.target.value.split(",").map(T=>T.trim()).filter(Boolean)),placeholder:"Enter node IDs separated by commas",className:"w-full px-3 py-2 bg-[#0a0e17] border border-[#1e2a3a] rounded text-sm text-slate-200 font-mono focus:outline-none focus:border-accent"}),n&&x.jsx("p",{className:"text-xs text-slate-600",children:n})]}):x.jsxs("div",{className:"space-y-1",children:[x.jsx("label",{className:"block text-xs text-slate-500 uppercase tracking-wide",children:e}),t.length>0&&x.jsx("div",{className:"flex flex-wrap gap-2 mb-2",children:t.map(S=>{const T=s.find(A=>m(A)===S);return x.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-1 bg-accent/20 text-accent rounded text-sm",children:[T?T.short_name:S,x.jsx("button",{type:"button",onClick:()=>r(t.filter(A=>A!==S)),className:"hover:text-white",children:x.jsx(hv,{size:14})})]},S)})}),x.jsxs("div",{className:"relative",children:[x.jsxs("div",{className:"relative",children:[x.jsx(HE,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-slate-500"}),x.jsx("input",{type:"text",value:f,onChange:S=>h(S.target.value),onFocus:()=>v(!0),placeholder:u?"Loading nodes...":"Search nodes...",className:"w-full pl-9 pr-3 py-2 bg-[#0a0e17] border border-[#1e2a3a] rounded text-sm text-slate-200 focus:outline-none focus:border-accent"})]}),d&&!u&&x.jsxs(x.Fragment,{children:[x.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>v(!1)}),x.jsx("div",{className:"absolute left-0 right-0 top-full mt-1 z-50 max-h-64 overflow-y-auto bg-[#0a0e17] border border-[#1e2a3a] rounded-lg shadow-xl",children:g.length===0?x.jsx("div",{className:"p-3 text-sm text-slate-500 text-center",children:"No nodes found"}):g.map(S=>x.jsxs("button",{type:"button",onClick:()=>_(S),className:`w-full flex items-center gap-2 px-3 py-2 text-left text-sm hover:bg-[#1e2a3a] ${y(S)?"bg-accent/10":""}`,children:[x.jsx("div",{className:`w-4 h-4 rounded border flex items-center justify-center ${y(S)?"bg-accent border-accent":"border-slate-600"}`,children:y(S)&&x.jsx(md,{size:12,className:"text-white"})}),x.jsx("span",{className:"text-slate-200",children:b(S)})]},S.node_num))})]})]}),n&&x.jsx("p",{className:"text-xs text-slate-600",children:n})]})}function RR(e){const[t,r]=W.useState([]),[n,i]=W.useState(!0);W.useEffect(()=>{fetch("/api/channels").then(h=>h.json()).then(h=>{r(h),i(!1)}).catch(()=>{r([]),i(!1)})},[]);const a=h=>{const d=h.role==="PRIMARY"?"Primary":h.role==="SECONDARY"?"Secondary":"";return`${h.index}: ${h.name}${d?` (${d})`:""}`};if(!n&&t.length===0)return e.mode==="single"?x.jsxs("div",{className:"space-y-1",children:[x.jsx("label",{className:"block text-xs text-slate-500 uppercase tracking-wide",children:e.label}),x.jsx("input",{type:"number",value:e.value,onChange:h=>e.onChange(Number(h.target.value)),min:e.includeDisabled?-1:0,max:7,className:"w-full px-3 py-2 bg-[#0a0e17] border border-[#1e2a3a] rounded text-sm text-slate-200 font-mono focus:outline-none focus:border-accent"}),e.helper&&x.jsx("p",{className:"text-xs text-slate-600",children:e.helper})]}):x.jsxs("div",{className:"space-y-1",children:[x.jsx("label",{className:"block text-xs text-slate-500 uppercase tracking-wide",children:e.label}),x.jsx("input",{type:"text",value:e.value.join(", "),onChange:h=>{const d=h.target.value.split(",").map(v=>parseInt(v.trim())).filter(v=>!isNaN(v));e.onChange(d)},placeholder:"Enter channel numbers separated by commas",className:"w-full px-3 py-2 bg-[#0a0e17] border border-[#1e2a3a] rounded text-sm text-slate-200 font-mono focus:outline-none focus:border-accent"}),e.helper&&x.jsx("p",{className:"text-xs text-slate-600",children:e.helper})]});if(e.mode==="single"){const{value:h,onChange:d,label:v,helper:g,includeDisabled:m}=e,y=t.filter(_=>_.enabled);return x.jsxs("div",{className:"space-y-1",children:[x.jsx("label",{className:"block text-xs text-slate-500 uppercase tracking-wide",children:v}),x.jsxs("select",{value:h,onChange:_=>d(Number(_.target.value)),className:"w-full px-3 py-2 bg-[#0a0e17] border border-[#1e2a3a] rounded text-sm text-slate-200 focus:outline-none focus:border-accent",children:[m&&x.jsx("option",{value:-1,children:"Disabled"}),y.map(_=>x.jsx("option",{value:_.index,children:a(_)},_.index))]}),g&&x.jsx("p",{className:"text-xs text-slate-600",children:g})]})}const{value:o,onChange:s,label:l,helper:u}=e,c=t.filter(h=>h.enabled),f=h=>{o.includes(h)?s(o.filter(d=>d!==h)):s([...o,h].sort((d,v)=>d-v))};return x.jsxs("div",{className:"space-y-1",children:[x.jsx("label",{className:"block text-xs text-slate-500 uppercase tracking-wide",children:l}),x.jsxs("div",{className:"border border-[#1e2a3a] rounded-lg p-2 space-y-1",children:[c.map(h=>x.jsxs("label",{onClick:()=>f(h.index),className:"flex items-center gap-2 p-2 rounded hover:bg-[#0a0e17] cursor-pointer",children:[x.jsx("div",{className:`w-4 h-4 rounded border flex items-center justify-center ${o.includes(h.index)?"bg-accent border-accent":"border-slate-600"}`,children:o.includes(h.index)&&x.jsx(md,{size:12,className:"text-white"})}),x.jsx("span",{className:"text-sm text-slate-200",children:a(h)})]},h.index)),c.length===0&&x.jsx("div",{className:"text-sm text-slate-500 p-2",children:"No channels available"})]}),u&&x.jsx("p",{className:"text-xs text-slate-600",children:u})]})}const BU=[{key:"bot",label:"Bot",icon:Gue},{key:"connection",label:"Connection",icon:MZ},{key:"response",label:"Response",icon:Jue},{key:"history",label:"History",icon:Kue},{key:"memory",label:"Memory",icon:Wue},{key:"context",label:"Context",icon:$E},{key:"commands",label:"Commands",icon:CZ},{key:"llm",label:"LLM",icon:mZ},{key:"weather",label:"Weather",icon:Yc},{key:"meshmonitor",label:"MeshMonitor",icon:tu},{key:"knowledge",label:"Knowledge",icon:pZ},{key:"mesh_sources",label:"Mesh Sources",icon:xZ},{key:"mesh_intelligence",label:"Intelligence",icon:Wy},{key:"environmental",label:"Environmental",icon:rce},{key:"dashboard",label:"Dashboard",icon:_Z}],Kn={bot:"Identity and behavior settings for the bot on the mesh network.",connection:"How MeshAI connects to your Meshtastic radio.",response:"Controls how quickly and how much the bot responds on the mesh.",history:"Conversation history storage and cleanup.",memory:"Short-term conversation memory management. Controls how the bot maintains context within a conversation.",context:"Passive channel monitoring. The bot listens to mesh channels and uses recent messages as context when responding.",commands:"Mesh commands available via the configured prefix. Toggle individual commands on or off.",llm:"AI model configuration. MeshAI uses an LLM to understand questions and generate responses.",weather:"Weather data for the !weather command. This is separate from NWS environmental alerts.",meshmonitor:"AIDA MeshMonitor integration. An additional data source for mesh network monitoring.",knowledge:"Knowledge base for answering questions from stored documents. Connects to Qdrant vector database or local SQLite.",mesh_sources:"Data sources for mesh network information. MeshAI can pull data from multiple sources simultaneously and merge them into a unified view.",mesh_intelligence:"Advanced mesh analysis: health scoring, region management, and automated alerting. The intelligence engine monitors your mesh and detects problems automatically.",environmental:"Live environmental data feeds for situational awareness. Each feed polls a public or authenticated API for real-time conditions affecting your area.",dashboard:"Web dashboard settings. You're looking at it right now."},AJe=[{name:"help",description:"Show available commands and usage"},{name:"health",description:"Mesh network health overview with status dots"},{name:"status",description:"Quick mesh status summary"},{name:"region",description:"List regions or get detailed region breakdown"},{name:"neighbors",description:"Show top infrastructure neighbors with signal quality"},{name:"ping",description:"Test bot responsiveness"},{name:"clear",description:"Clear your conversation history"},{name:"reset",description:"Reset conversation context"},{name:"sub",description:"Subscribe to scheduled reports or alerts"},{name:"unsub",description:"Remove a subscription"},{name:"mysubs",description:"List your active subscriptions"},{name:"alerts",description:"Active NWS weather alerts for mesh area"},{name:"solar",description:"Space weather and HF propagation conditions"},{name:"hf",description:"HF radio propagation (alias for !solar)"},{name:"fire",description:"Active wildfires near the mesh"},{name:"avy",description:"Avalanche advisories for configured zones"},{name:"hotspots",description:"NASA FIRMS satellite fire detections"},{name:"streams",description:"USGS stream gauge readings"},{name:"roads",description:"Road conditions and closures"},{name:"traffic",description:"Traffic flow on monitored corridors"}],CJe=[{value:"US-AL",label:"Alabama"},{value:"US-AK",label:"Alaska"},{value:"US-AZ",label:"Arizona"},{value:"US-AR",label:"Arkansas"},{value:"US-CA",label:"California"},{value:"US-CO",label:"Colorado"},{value:"US-CT",label:"Connecticut"},{value:"US-DE",label:"Delaware"},{value:"US-FL",label:"Florida"},{value:"US-GA",label:"Georgia"},{value:"US-HI",label:"Hawaii"},{value:"US-ID",label:"Idaho"},{value:"US-IL",label:"Illinois"},{value:"US-IN",label:"Indiana"},{value:"US-IA",label:"Iowa"},{value:"US-KS",label:"Kansas"},{value:"US-KY",label:"Kentucky"},{value:"US-LA",label:"Louisiana"},{value:"US-ME",label:"Maine"},{value:"US-MD",label:"Maryland"},{value:"US-MA",label:"Massachusetts"},{value:"US-MI",label:"Michigan"},{value:"US-MN",label:"Minnesota"},{value:"US-MS",label:"Mississippi"},{value:"US-MO",label:"Missouri"},{value:"US-MT",label:"Montana"},{value:"US-NE",label:"Nebraska"},{value:"US-NV",label:"Nevada"},{value:"US-NH",label:"New Hampshire"},{value:"US-NJ",label:"New Jersey"},{value:"US-NM",label:"New Mexico"},{value:"US-NY",label:"New York"},{value:"US-NC",label:"North Carolina"},{value:"US-ND",label:"North Dakota"},{value:"US-OH",label:"Ohio"},{value:"US-OK",label:"Oklahoma"},{value:"US-OR",label:"Oregon"},{value:"US-PA",label:"Pennsylvania"},{value:"US-RI",label:"Rhode Island"},{value:"US-SC",label:"South Carolina"},{value:"US-SD",label:"South Dakota"},{value:"US-TN",label:"Tennessee"},{value:"US-TX",label:"Texas"},{value:"US-UT",label:"Utah"},{value:"US-VT",label:"Vermont"},{value:"US-VA",label:"Virginia"},{value:"US-WA",label:"Washington"},{value:"US-WV",label:"West Virginia"},{value:"US-WI",label:"Wisconsin"},{value:"US-WY",label:"Wyoming"}];function Wo({info:e,link:t,linkText:r="Learn more"}){const[n,i]=W.useState(!1),a=W.useRef(null);return W.useEffect(()=>{if(!n)return;function o(l){a.current&&!a.current.contains(l.target)&&i(!1)}const s=setTimeout(()=>document.addEventListener("mousedown",o),0);return()=>{clearTimeout(s),document.removeEventListener("mousedown",o)}},[n]),x.jsxs("div",{className:"relative inline-block",ref:a,children:[x.jsx("button",{type:"button",onClick:o=>{o.stopPropagation(),i(!n)},className:"ml-1.5 w-4 h-4 rounded-full bg-slate-700 hover:bg-slate-600 text-slate-400 hover:text-slate-200 inline-flex items-center justify-center text-xs transition-colors",title:"More info",children:"?"}),n&&x.jsxs("div",{className:"absolute left-0 top-6 z-50 w-72 p-3 bg-[#1a2332] border border-[#2a3a4a] rounded-lg shadow-xl text-xs text-slate-300 leading-relaxed",children:[x.jsx("button",{type:"button",onClick:()=>i(!1),className:"absolute top-1 right-1 w-5 h-5 rounded hover:bg-slate-700 text-slate-500 hover:text-slate-300 inline-flex items-center justify-center transition-colors","aria-label":"Close",children:x.jsx(hv,{size:12})}),x.jsx("div",{className:"pr-4",children:e}),t&&x.jsxs("a",{href:t,target:"_blank",rel:"noopener noreferrer",className:"mt-2 flex items-center gap-1 text-accent hover:underline",onClick:o=>o.stopPropagation(),children:[r," ",x.jsx(xd,{size:10})]})]})]})}function Qn({text:e}){return x.jsx("p",{className:"text-sm text-slate-500 mb-6 pb-4 border-b border-[#1e2a3a]",children:e})}function At({label:e,value:t,onChange:r,type:n="text",placeholder:i="",helper:a="",info:o="",infoLink:s=""}){const[l,u]=W.useState(!1),c=n==="password";return x.jsxs("div",{className:"space-y-1",children:[x.jsxs("label",{className:"flex items-center text-xs text-slate-500 uppercase tracking-wide",children:[e,o&&x.jsx(Wo,{info:o,link:s})]}),x.jsxs("div",{className:"relative",children:[x.jsx("input",{type:c&&!l?"password":"text",value:t,onChange:f=>r(f.target.value),placeholder:i,className:"w-full px-3 py-2 bg-[#0a0e17] border border-[#1e2a3a] rounded text-sm text-slate-200 font-mono focus:outline-none focus:border-accent placeholder-slate-600"}),c&&x.jsx("button",{type:"button",onClick:()=>u(!l),className:"absolute right-2 top-1/2 -translate-y-1/2 text-slate-500 hover:text-slate-300",children:l?x.jsx(yZ,{size:16}):x.jsx($E,{size:16})})]}),a&&x.jsx("p",{className:"text-xs text-slate-600",children:a})]})}function qe({label:e,value:t,onChange:r,min:n,max:i,step:a=1,helper:o="",info:s="",infoLink:l=""}){return x.jsxs("div",{className:"space-y-1",children:[x.jsxs("label",{className:"flex items-center text-xs text-slate-500 uppercase tracking-wide",children:[e,s&&x.jsx(Wo,{info:s,link:l})]}),x.jsx("input",{type:"number",value:t,onChange:u=>r(Number(u.target.value)),min:n,max:i,step:a,className:"w-full px-3 py-2 bg-[#0a0e17] border border-[#1e2a3a] rounded text-sm text-slate-200 font-mono focus:outline-none focus:border-accent"}),o&&x.jsx("p",{className:"text-xs text-slate-600",children:o})]})}function Et({label:e,checked:t,onChange:r,helper:n="",info:i="",infoLink:a=""}){return x.jsxs("div",{className:"flex items-center justify-between py-2",children:[x.jsxs("div",{children:[x.jsxs("span",{className:"flex items-center text-sm text-slate-300",children:[e,i&&x.jsx(Wo,{info:i,link:a})]}),n&&x.jsx("p",{className:"text-xs text-slate-600",children:n})]}),x.jsx("button",{type:"button",onClick:()=>r(!t),className:`relative w-11 h-6 rounded-full transition-colors ${t?"bg-accent":"bg-[#1e2a3a]"}`,children:x.jsx("span",{className:`absolute top-1 left-1 w-4 h-4 rounded-full bg-white transition-transform ${t?"translate-x-5":""}`})})]})}function Co({label:e,value:t,onChange:r,options:n,helper:i="",info:a="",infoLink:o=""}){return x.jsxs("div",{className:"space-y-1",children:[x.jsxs("label",{className:"flex items-center text-xs text-slate-500 uppercase tracking-wide",children:[e,a&&x.jsx(Wo,{info:a,link:o})]}),x.jsx("select",{value:t,onChange:s=>r(s.target.value),className:"w-full px-3 py-2 bg-[#0a0e17] border border-[#1e2a3a] rounded text-sm text-slate-200 focus:outline-none focus:border-accent",children:n.map(s=>x.jsx("option",{value:s.value,children:s.label},s.value))}),i&&x.jsx("p",{className:"text-xs text-slate-600",children:i})]})}function MJe({label:e,value:t,onChange:r,rows:n=4,helper:i="",info:a="",infoLink:o=""}){return x.jsxs("div",{className:"space-y-1",children:[x.jsxs("label",{className:"flex items-center text-xs text-slate-500 uppercase tracking-wide",children:[e,a&&x.jsx(Wo,{info:a,link:o})]}),x.jsx("textarea",{value:t,onChange:s=>r(s.target.value),rows:n,className:"w-full px-3 py-2 bg-[#0a0e17] border border-[#1e2a3a] rounded text-sm text-slate-200 font-mono focus:outline-none focus:border-accent resize-y"}),i&&x.jsx("p",{className:"text-xs text-slate-600",children:i})]})}function Hh({label:e,value:t,onChange:r,helper:n="",info:i="",infoLink:a=""}){const[o,s]=W.useState(t.join(", "));W.useEffect(()=>{s(t.join(", "))},[t]);const l=()=>{const u=o.split(",").map(c=>c.trim()).filter(Boolean);r(u)};return x.jsxs("div",{className:"space-y-1",children:[x.jsxs("label",{className:"flex items-center text-xs text-slate-500 uppercase tracking-wide",children:[e,i&&x.jsx(Wo,{info:i,link:a})]}),x.jsx("input",{type:"text",value:o,onChange:u=>s(u.target.value),onBlur:l,placeholder:"item1, item2, item3",className:"w-full px-3 py-2 bg-[#0a0e17] border border-[#1e2a3a] rounded text-sm text-slate-200 font-mono focus:outline-none focus:border-accent placeholder-slate-600"}),n&&x.jsx("p",{className:"text-xs text-slate-600",children:n})]})}function PJe({label:e,value:t,onChange:r,helper:n="",info:i="",infoLink:a=""}){const[o,s]=W.useState(t.join(", "));W.useEffect(()=>{s(t.join(", "))},[t]);const l=()=>{const u=o.split(",").map(c=>parseInt(c.trim(),10)).filter(c=>!isNaN(c));r(u)};return x.jsxs("div",{className:"space-y-1",children:[x.jsxs("label",{className:"flex items-center text-xs text-slate-500 uppercase tracking-wide",children:[e,i&&x.jsx(Wo,{info:i,link:a})]}),x.jsx("input",{type:"text",value:o,onChange:u=>s(u.target.value),onBlur:l,placeholder:"0, 1, 2",className:"w-full px-3 py-2 bg-[#0a0e17] border border-[#1e2a3a] rounded text-sm text-slate-200 font-mono focus:outline-none focus:border-accent placeholder-slate-600"}),n&&x.jsx("p",{className:"text-xs text-slate-600",children:n})]})}function Cn({label:e,description:t,checked:r,onChange:n,threshold:i,onThresholdChange:a,thresholdLabel:o,thresholdMin:s,thresholdMax:l,thresholdStep:u=1,thresholdSuffix:c=""}){return x.jsxs("div",{className:"border border-[#1e2a3a] rounded-lg p-3 space-y-2",children:[x.jsxs("div",{className:"flex items-center justify-between",children:[x.jsxs("div",{className:"flex-1",children:[x.jsx("span",{className:"text-sm text-slate-300",children:e}),x.jsx("p",{className:"text-xs text-slate-600",children:t})]}),x.jsx("button",{type:"button",onClick:()=>n(!r),className:`relative w-11 h-6 rounded-full transition-colors flex-shrink-0 ml-3 ${r?"bg-accent":"bg-[#1e2a3a]"}`,children:x.jsx("span",{className:`absolute top-1 left-1 w-4 h-4 rounded-full bg-white transition-transform ${r?"translate-x-5":""}`})})]}),r&&i!==void 0&&a&&x.jsxs("div",{className:"flex items-center gap-2 pt-2 border-t border-[#1e2a3a]",children:[x.jsxs("span",{className:"text-xs text-slate-500",children:[o||"Threshold",":"]}),x.jsx("input",{type:"number",value:i,onChange:f=>a(Number(f.target.value)),min:s,max:l,step:u,className:"w-20 px-2 py-1 bg-[#0a0e17] border border-[#1e2a3a] rounded text-xs text-slate-200 font-mono"}),c&&x.jsx("span",{className:"text-xs text-slate-500",children:c})]})]})}function LJe({data:e,onChange:t}){return x.jsxs("div",{className:"space-y-4",children:[x.jsx(Qn,{text:Kn.bot}),x.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[x.jsx(At,{label:"Bot Name",value:e.name,onChange:r=>t({...e,name:r}),helper:"Name the bot responds to on the mesh",info:"When someone sends a message containing this name, the bot will respond. Also used as the sender name in broadcasts. Changing this requires a restart."}),x.jsx(At,{label:"Owner",value:e.owner,onChange:r=>t({...e,owner:r}),helper:"Your callsign or identifier",info:"Identifies the bot operator. Shown in !help responses and used for admin-level commands."})]}),x.jsx(Et,{label:"Respond to DMs",checked:e.respond_to_dms,onChange:r=>t({...e,respond_to_dms:r}),helper:"Reply when someone sends a direct message",info:"When enabled, the bot responds to direct messages from any node. When disabled, the bot only responds to channel messages that mention its name."}),x.jsx(Et,{label:"Filter BBS Protocols",checked:e.filter_bbs_protocols,onChange:r=>t({...e,filter_bbs_protocols:r}),helper:"Ignore BBS bulletin board traffic",info:"Filters out automated BBS protocol messages (advBBS, MAIL*, BOARD*) so the bot doesn't try to respond to machine-to-machine traffic."})]})}function kJe({data:e,onChange:t}){return x.jsxs("div",{className:"space-y-4",children:[x.jsx(Qn,{text:Kn.connection}),x.jsx(Co,{label:"Connection Type",value:e.type,onChange:r=>t({...e,type:r}),options:[{value:"serial",label:"Serial (USB)"},{value:"tcp",label:"TCP (Network)"}],helper:"Serial for USB-connected radios, TCP for network or meshtasticd",info:"Serial: direct USB connection to a Meshtastic radio. TCP: connect over the network to a radio's IP or to meshtasticd running on another machine."}),e.type==="serial"?x.jsx(At,{label:"Serial Port",value:e.serial_port,onChange:r=>t({...e,serial_port:r}),placeholder:"/dev/ttyUSB0",helper:"Device path for your USB radio",info:"Usually /dev/ttyUSB0 on Linux or /dev/ttyACM0. Check with 'ls /dev/tty*' after plugging in your radio."}):x.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[x.jsx(At,{label:"TCP Host",value:e.tcp_host,onChange:r=>t({...e,tcp_host:r}),placeholder:"192.168.1.100",helper:"IP address or hostname of the radio/meshtasticd"}),x.jsx(qe,{label:"TCP Port",value:e.tcp_port,onChange:r=>t({...e,tcp_port:r}),min:1,max:65535,helper:"Default 4403 for meshtasticd"})]})]})}function IJe({data:e,onChange:t}){return x.jsxs("div",{className:"space-y-4",children:[x.jsx(Qn,{text:Kn.response}),x.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[x.jsx(qe,{label:"Delay Min (sec)",value:e.delay_min,onChange:r=>t({...e,delay_min:r}),min:0,step:.1,helper:"Minimum wait before responding",info:"Adds a random delay between min and max before the bot sends a response. Prevents the bot from appearing to respond instantly, which can feel unnatural on a radio network."}),x.jsx(qe,{label:"Delay Max (sec)",value:e.delay_max,onChange:r=>t({...e,delay_max:r}),min:0,step:.1,helper:"Maximum wait before responding",info:"Also prevents collisions with other traffic by staggering transmissions."})]}),x.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[x.jsx(qe,{label:"Max Length",value:e.max_length,onChange:r=>t({...e,max_length:r}),min:50,max:500,helper:"Maximum characters per response message",info:"Meshtastic packets have limited size. This caps how long each message chunk can be. The bot will split longer responses into multiple messages up to Max Messages."}),x.jsx(qe,{label:"Max Messages",value:e.max_messages,onChange:r=>t({...e,max_messages:r}),min:1,max:10,helper:"Maximum chunks per response",info:"If a response is longer than Max Length, the bot splits it into this many chunks at most. Higher values = more complete answers but more airtime used."})]})]})}function OJe({data:e,onChange:t}){return x.jsxs("div",{className:"space-y-4",children:[x.jsx(Qn,{text:Kn.history}),x.jsx(At,{label:"Database Path",value:e.database,onChange:r=>t({...e,database:r}),helper:"SQLite file for storing conversation history",info:"Path to the SQLite database file. Created automatically if it doesn't exist. Stores all conversation history for context."}),x.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[x.jsx(qe,{label:"Max Messages Per User",value:e.max_messages_per_user,onChange:r=>t({...e,max_messages_per_user:r}),min:0,helper:"History limit per user (0 = unlimited)",info:"Limits how many messages are stored per user. Older messages are pruned when the limit is reached. Set to 0 for no limit."}),x.jsx(qe,{label:"Conversation Timeout (sec)",value:e.conversation_timeout,onChange:r=>t({...e,conversation_timeout:r}),min:0,helper:"Seconds before context resets",info:"If a user doesn't message for this long, their next message starts a new conversation context. The bot won't remember the previous topic."})]}),x.jsx(Et,{label:"Auto Cleanup",checked:e.auto_cleanup,onChange:r=>t({...e,auto_cleanup:r}),helper:"Automatically prune old conversations"}),e.auto_cleanup&&x.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[x.jsx(qe,{label:"Cleanup Interval (hours)",value:e.cleanup_interval_hours,onChange:r=>t({...e,cleanup_interval_hours:r}),min:1,helper:"Hours between cleanup runs"}),x.jsx(qe,{label:"Max Age (days)",value:e.max_age_days,onChange:r=>t({...e,max_age_days:r}),min:1,helper:"Delete conversations older than this"})]})]})}function EJe({data:e,onChange:t}){return x.jsxs("div",{className:"space-y-4",children:[x.jsx(Qn,{text:Kn.memory}),x.jsx(Et,{label:"Enable Memory",checked:e.enabled,onChange:r=>t({...e,enabled:r}),helper:"Keep conversation context between messages"}),e.enabled&&x.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[x.jsx(qe,{label:"Window Size",value:e.window_size,onChange:r=>t({...e,window_size:r}),min:1,helper:"Recent message pairs kept in full",info:"The bot keeps this many recent exchanges (user message + bot response pairs) as full text in context. Older messages are summarized to save token space."}),x.jsx(qe,{label:"Summarize Threshold",value:e.summarize_threshold,onChange:r=>t({...e,summarize_threshold:r}),min:1,helper:"Messages before older context is summarized",info:"When the conversation exceeds this many messages, older ones outside the window are compressed into a summary by the LLM."})]})]})}function DJe({data:e,onChange:t}){return x.jsxs("div",{className:"space-y-4",children:[x.jsx(Qn,{text:Kn.context}),x.jsx(Et,{label:"Enable Passive Context",checked:e.enabled,onChange:r=>t({...e,enabled:r}),helper:"Listen to channel traffic for context",info:"When enabled, the bot monitors mesh channels and includes recent messages in its context. This lets the bot reference things other people said on the channel."}),e.enabled&&x.jsxs(x.Fragment,{children:[x.jsx(RR,{label:"Observe Channels",value:e.observe_channels,onChange:r=>t({...e,observe_channels:r}),helper:"Channels to monitor (empty = all)",info:"Meshtastic channels to listen on. Leave empty to monitor all channels.",mode:"multi"}),x.jsx(jR,{label:"Ignore Nodes",value:e.ignore_nodes,onChange:r=>t({...e,ignore_nodes:r}),helper:"Nodes to exclude from context",info:"Messages from these nodes won't be included in passive context. Useful for filtering out noisy automated nodes."}),x.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[x.jsx(qe,{label:"Max Age (sec)",value:e.max_age,onChange:r=>t({...e,max_age:r}),min:0,helper:"Ignore messages older than this"}),x.jsx(qe,{label:"Max Context Items",value:e.max_context_items,onChange:r=>t({...e,max_context_items:r}),min:1,helper:"Maximum recent messages to include"})]})]})]})}function NJe({data:e,onChange:t}){const r=new Set(e.disabled_commands.map(i=>i.toLowerCase())),n=i=>{const a=i.toLowerCase();r.has(a)?t({...e,disabled_commands:e.disabled_commands.filter(o=>o.toLowerCase()!==a)}):t({...e,disabled_commands:[...e.disabled_commands,i]})};return x.jsxs("div",{className:"space-y-4",children:[x.jsx(Qn,{text:Kn.commands}),x.jsx(Et,{label:"Enable Commands",checked:e.enabled,onChange:i=>t({...e,enabled:i}),helper:"Allow !commands on the mesh"}),e.enabled&&x.jsxs(x.Fragment,{children:[x.jsx(At,{label:"Command Prefix",value:e.prefix,onChange:i=>t({...e,prefix:i}),helper:"Character that triggers commands (e.g. ! for !help)",info:"Users type this character followed by the command name. Only single characters recommended."}),x.jsxs("div",{className:"space-y-2",children:[x.jsxs("label",{className:"flex items-center text-xs text-slate-500 uppercase tracking-wide",children:["Available Commands",x.jsx(Wo,{info:"Toggle commands on or off. Disabled commands won't respond when users invoke them."})]}),x.jsx("div",{className:"grid gap-1",children:AJe.map(i=>{const a=!r.has(i.name.toLowerCase());return x.jsxs("div",{className:"flex items-center justify-between p-2 bg-[#0a0e17] border border-[#1e2a3a] rounded hover:border-[#2a3a4a] transition-colors",children:[x.jsxs("div",{className:"flex items-center gap-3",children:[x.jsxs("code",{className:"text-accent text-sm",children:["!",i.name]}),x.jsx("span",{className:"text-xs text-slate-500",children:i.description})]}),x.jsx("button",{type:"button",onClick:()=>n(i.name),className:`relative w-9 h-5 rounded-full transition-colors ${a?"bg-accent":"bg-[#1e2a3a]"}`,children:x.jsx("span",{className:`absolute top-0.5 left-0.5 w-4 h-4 rounded-full bg-white transition-transform ${a?"translate-x-4":""}`})})]},i.name)})})]})]})]})}function jJe({data:e,onChange:t}){return x.jsxs("div",{className:"space-y-4",children:[x.jsx(Qn,{text:Kn.llm}),x.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[x.jsx(Co,{label:"Backend",value:e.backend,onChange:r=>t({...e,backend:r}),options:[{value:"openai",label:"OpenAI"},{value:"anthropic",label:"Anthropic"},{value:"google",label:"Google (Gemini)"}],helper:"LLM provider to use",info:"OpenAI: GPT models (gpt-4o, gpt-4o-mini). Anthropic: Claude models (claude-sonnet-4-20250514). Google: Gemini models. Can also point to compatible APIs like Ollama, LM Studio, or Open WebUI by changing the Base URL."}),x.jsx(At,{label:"Model",value:e.model,onChange:r=>t({...e,model:r}),placeholder:"gpt-4o-mini",helper:"Specific model name",info:"The specific model to use. Common choices: gpt-4o-mini (fast, cheap), gpt-4o (better, costs more), claude-sonnet-4-20250514 (Anthropic equivalent). For local models via Ollama, use the model name you pulled (e.g. llama3.1)."})]}),x.jsx(At,{label:"API Key",value:e.api_key,onChange:r=>t({...e,api_key:r}),type:"password",helper:"Supports ${ENV_VAR} syntax",info:"Your API key from the provider. You can also use ${ENV_VAR} syntax to read from an environment variable instead of storing the key in the config file."}),x.jsx(At,{label:"Base URL",value:e.base_url,onChange:r=>t({...e,base_url:r}),placeholder:"https://api.openai.com/v1",helper:"API endpoint (change for local LLMs)",info:"Default API endpoint for the selected backend. Change this to point to a local LLM server (Ollama at http://localhost:11434/v1, Open WebUI, LM Studio, etc.) or a proxy."}),x.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[x.jsx(qe,{label:"Timeout (sec)",value:e.timeout,onChange:r=>t({...e,timeout:r}),min:5,max:120,helper:"Maximum seconds to wait for response"}),x.jsx(qe,{label:"Max Response Tokens",value:e.max_response_tokens,onChange:r=>t({...e,max_response_tokens:r}),min:100,helper:"Token limit for LLM responses"})]}),x.jsx(Et,{label:"Use System Prompt",checked:e.use_system_prompt,onChange:r=>t({...e,use_system_prompt:r}),helper:"Enable custom system instructions"}),e.use_system_prompt&&x.jsx(MJe,{label:"System Prompt",value:e.system_prompt,onChange:r=>t({...e,system_prompt:r}),rows:6,helper:"Instructions that shape the bot's personality",info:"Instructions that shape the bot's personality and behavior. The bot always follows these instructions. MeshAI adds mesh health data and environmental context automatically — you don't need to include those here."}),x.jsx(Et,{label:"Web Search",checked:e.web_search,onChange:r=>t({...e,web_search:r}),helper:"Enable web search tool (Open WebUI feature)"}),x.jsx(Et,{label:"Google Grounding",checked:e.google_grounding,onChange:r=>t({...e,google_grounding:r}),helper:"Ground responses in web search (Gemini only)"})]})}function RJe({data:e,onChange:t}){return x.jsxs("div",{className:"space-y-4",children:[x.jsx(Qn,{text:Kn.weather}),x.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[x.jsx(Co,{label:"Primary Provider",value:e.primary,onChange:r=>t({...e,primary:r}),options:[{value:"openmeteo",label:"Open-Meteo"},{value:"wttr",label:"wttr.in"},{value:"llm",label:"LLM"}],helper:"Main weather data source"}),x.jsx(Co,{label:"Fallback Provider",value:e.fallback,onChange:r=>t({...e,fallback:r}),options:[{value:"openmeteo",label:"Open-Meteo"},{value:"wttr",label:"wttr.in"},{value:"llm",label:"LLM"},{value:"none",label:"None"}],helper:"Backup if primary fails"})]}),x.jsx(At,{label:"Default Location",value:e.default_location,onChange:r=>t({...e,default_location:r}),placeholder:"Your city, state",helper:"Location when none specified"})]})}function BJe({data:e,onChange:t}){return x.jsxs("div",{className:"space-y-4",children:[x.jsx(Qn,{text:Kn.meshmonitor}),x.jsx(Et,{label:"Enable MeshMonitor",checked:e.enabled,onChange:r=>t({...e,enabled:r}),helper:"Connect to AIDA MeshMonitor instance",info:"MeshMonitor by Yeraze provides node data, battery info, telemetry, and auto-responder patterns. MeshAI uses this as a data source and avoids duplicate responses."}),e.enabled&&x.jsxs(x.Fragment,{children:[x.jsx(At,{label:"URL",value:e.url,onChange:r=>t({...e,url:r}),placeholder:"http://192.168.1.100:8080",helper:"MeshMonitor API endpoint",info:"Full URL to your MeshMonitor instance. Usually runs on port 8080."}),x.jsx(Et,{label:"Inject Into Prompt",checked:e.inject_into_prompt,onChange:r=>t({...e,inject_into_prompt:r}),helper:"Tell LLM about MeshMonitor commands",info:"Adds MeshMonitor's auto-responder patterns to the LLM context so it knows what commands MeshMonitor handles."}),x.jsx(qe,{label:"Refresh Interval (sec)",value:e.refresh_interval,onChange:r=>t({...e,refresh_interval:r}),min:10,helper:"How often to fetch patterns"}),x.jsx(Et,{label:"Polite Mode",checked:e.polite_mode,onChange:r=>t({...e,polite_mode:r}),helper:"Reduce polling frequency",info:"Reduces polling frequency for shared instances to be a good neighbor."})]})]})}function zJe({data:e,onChange:t}){return x.jsxs("div",{className:"space-y-4",children:[x.jsx(Qn,{text:Kn.knowledge}),x.jsx(Et,{label:"Enable Knowledge Base",checked:e.enabled,onChange:r=>t({...e,enabled:r}),helper:"Answer questions from stored documents",info:"Uses RAG (Retrieval-Augmented Generation) to answer questions from a knowledge base. Supports Qdrant vector database or local SQLite with FTS5."}),e.enabled&&x.jsxs(x.Fragment,{children:[x.jsx(Co,{label:"Backend",value:e.backend,onChange:r=>t({...e,backend:r}),options:[{value:"auto",label:"Auto (Qdrant -> SQLite)"},{value:"qdrant",label:"Qdrant"},{value:"sqlite",label:"SQLite"}],helper:"Knowledge storage backend",info:"Auto tries Qdrant first, falls back to SQLite. Qdrant provides hybrid search with dense+sparse embeddings. SQLite uses FTS5 keyword search."}),(e.backend==="qdrant"||e.backend==="auto")&&x.jsxs(x.Fragment,{children:[x.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[x.jsx(At,{label:"Qdrant Host",value:e.qdrant_host,onChange:r=>t({...e,qdrant_host:r}),helper:"Qdrant server hostname",info:"IP or hostname of your Qdrant vector database server."}),x.jsx(qe,{label:"Qdrant Port",value:e.qdrant_port,onChange:r=>t({...e,qdrant_port:r}),helper:"Default 6333"})]}),x.jsx(At,{label:"Collection",value:e.qdrant_collection,onChange:r=>t({...e,qdrant_collection:r}),helper:"Qdrant collection name"}),x.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[x.jsx(At,{label:"TEI Host",value:e.tei_host,onChange:r=>t({...e,tei_host:r}),helper:"Text Embeddings Inference host",info:"TEI service for generating dense embeddings. Uses BAAI/bge-m3 model."}),x.jsx(qe,{label:"TEI Port",value:e.tei_port,onChange:r=>t({...e,tei_port:r}),helper:"Default 8090"})]}),x.jsx(Et,{label:"Use Sparse Embeddings",checked:e.use_sparse,onChange:r=>t({...e,use_sparse:r}),helper:"Enable hybrid search with sparse vectors",info:"Combines dense embeddings with sparse (keyword-based) embeddings using Reciprocal Rank Fusion for better search results."})]}),x.jsx(At,{label:"SQLite DB Path",value:e.db_path,onChange:r=>t({...e,db_path:r}),helper:"Local knowledge database file"}),x.jsx(qe,{label:"Top K Results",value:e.top_k,onChange:r=>t({...e,top_k:r}),min:1,max:20,helper:"Number of documents to retrieve"})]})]})}function $Je({source:e,onChange:t,onDelete:r}){const[n,i]=W.useState(!1),a={meshview:"Web-based mesh monitoring tool. Enter the full URL of a MeshView instance. No API key typically required.",meshmonitor:"AIDA MeshMonitor API. Provides node data and network statistics. Requires API token.",mqtt:"Subscribe directly to a Meshtastic MQTT broker for real-time packet data. This is push-based (instant) vs the polling approach of MeshView/MeshMonitor."};return x.jsxs("div",{className:"border border-[#1e2a3a] rounded-lg overflow-hidden",children:[x.jsxs("div",{className:"flex items-center justify-between p-3 bg-[#0a0e17] cursor-pointer",onClick:()=>i(!n),children:[x.jsxs("div",{className:"flex items-center gap-3",children:[n?x.jsx(Hy,{size:16}):x.jsx(bm,{size:16}),x.jsx("div",{className:`w-2 h-2 rounded-full ${e.enabled?"bg-green-500":"bg-slate-500"}`}),x.jsx("span",{className:"font-mono text-sm text-slate-200",children:e.name||"Unnamed Source"}),x.jsx("span",{className:"text-xs text-slate-500 bg-[#1e2a3a] px-2 py-0.5 rounded",children:e.type})]}),x.jsx("button",{onClick:o=>{o.stopPropagation(),r()},className:"p-1 text-red-400 hover:text-red-300 hover:bg-red-500/10 rounded",children:x.jsx(UE,{size:14})})]}),n&&x.jsxs("div",{className:"p-4 space-y-4 border-t border-[#1e2a3a]",children:[x.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[x.jsx(At,{label:"Name",value:e.name,onChange:o=>t({...e,name:o}),helper:"Friendly name for this source"}),x.jsx(Co,{label:"Type",value:e.type,onChange:o=>t({...e,type:o}),options:[{value:"meshview",label:"MeshView"},{value:"meshmonitor",label:"MeshMonitor"},{value:"mqtt",label:"MQTT Broker"}],info:a[e.type]||""})]}),e.type!=="mqtt"&&x.jsx(At,{label:"URL",value:e.url,onChange:o=>t({...e,url:o}),helper:"Full URL including protocol"}),e.type==="meshmonitor"&&x.jsx(At,{label:"API Token",value:e.api_token,onChange:o=>t({...e,api_token:o}),type:"password",helper:"Bearer token for authentication"}),e.type==="mqtt"&&x.jsxs(x.Fragment,{children:[x.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[x.jsx(At,{label:"Host",value:e.host||"",onChange:o=>t({...e,host:o}),helper:"MQTT broker hostname"}),x.jsx(qe,{label:"Port",value:e.port||1883,onChange:o=>t({...e,port:o}),min:1,max:65535,helper:"1883 plain, 8883 TLS"})]}),x.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[x.jsx(At,{label:"Username",value:e.username||"",onChange:o=>t({...e,username:o})}),x.jsx(At,{label:"Password",value:e.password||"",onChange:o=>t({...e,password:o}),type:"password"})]}),x.jsx(At,{label:"Topic Root",value:e.topic_root||"msh/US",onChange:o=>t({...e,topic_root:o}),helper:"Base topic to subscribe to"}),x.jsx(Et,{label:"Use TLS",checked:e.use_tls||!1,onChange:o=>t({...e,use_tls:o}),helper:"Encrypt MQTT connection"})]}),x.jsx(qe,{label:"Refresh Interval (sec)",value:e.refresh_interval,onChange:o=>t({...e,refresh_interval:o}),min:10,helper:"Polling frequency"}),x.jsx(Et,{label:"Enabled",checked:e.enabled,onChange:o=>t({...e,enabled:o})}),x.jsx(Et,{label:"Polite Mode",checked:e.polite_mode,onChange:o=>t({...e,polite_mode:o}),helper:"Reduce polling for shared instances"})]})]})}function FJe({data:e,onChange:t}){const r=()=>{t([...e,{name:"New Source",type:"meshview",url:"",api_token:"",refresh_interval:30,polite_mode:!1,enabled:!0,host:"",port:1883,username:"",password:"",topic_root:"msh/US",use_tls:!1}])};return x.jsxs("div",{className:"space-y-4",children:[x.jsx(Qn,{text:Kn.mesh_sources}),e.map((n,i)=>x.jsx($Je,{source:n,onChange:a=>{const o=[...e];o[i]=a,t(o)},onDelete:()=>{confirm(`Delete source "${n.name}"?`)&&t(e.filter((a,o)=>o!==i))}},i)),x.jsxs("button",{onClick:r,className:"w-full py-2 border border-dashed border-[#1e2a3a] rounded-lg text-slate-500 hover:text-slate-300 hover:border-accent flex items-center justify-center gap-2 transition-colors",children:[x.jsx(bS,{size:16})," Add Source"]})]})}function VJe({data:e,onChange:t}){const[r,n]=W.useState(null);return x.jsxs("div",{className:"space-y-6",children:[x.jsx(Qn,{text:Kn.mesh_intelligence}),x.jsx(Et,{label:"Enable Mesh Intelligence",checked:e.enabled,onChange:i=>t({...e,enabled:i}),helper:"Activate health scoring and alerting"}),e.enabled&&x.jsxs(x.Fragment,{children:[x.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[x.jsx(qe,{label:"Locality Radius (miles)",value:e.locality_radius_miles,onChange:i=>t({...e,locality_radius_miles:i}),min:1,step:.5,helper:"Region assignment radius",info:"Nodes within this distance of a region anchor point are assigned to that region."}),x.jsx(qe,{label:"Offline Threshold (hours)",value:e.offline_threshold_hours,onChange:i=>t({...e,offline_threshold_hours:i}),min:1,helper:"Time until node marked offline",info:"A node is considered offline after not being heard for this many hours."})]}),x.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[x.jsx(qe,{label:"Packet Threshold",value:e.packet_threshold,onChange:i=>t({...e,packet_threshold:i}),min:0,helper:"Min packets per 24h to flag",info:"Minimum packets per 24 hours. Nodes below this are flagged as low activity."}),x.jsx(qe,{label:"Battery Warning %",value:e.battery_warning_percent,onChange:i=>t({...e,battery_warning_percent:i}),min:1,max:100,helper:"Global battery warning level"})]}),x.jsx(jR,{label:"Critical Nodes",value:e.critical_nodes,onChange:i=>t({...e,critical_nodes:i}),helper:"Critical infrastructure nodes",info:"Nodes that get priority alerting when they go offline.",roleFilter:"infrastructure"}),x.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[x.jsx(RR,{label:"Alert Channel",value:e.alert_channel,onChange:i=>t({...e,alert_channel:i}),helper:"Channel for broadcast alerts",info:"Meshtastic channel for broadcast alerts. Select Disabled to turn off channel broadcasting.",mode:"single",includeDisabled:!0}),x.jsx(qe,{label:"Alert Cooldown (min)",value:e.alert_cooldown_minutes,onChange:i=>t({...e,alert_cooldown_minutes:i}),min:1,helper:"Min time between repeat alerts",info:"Minimum minutes between repeated alerts for the same condition. Uses scaling cooldown (12h, 24h, 48h)."})]}),x.jsxs("div",{className:"space-y-2",children:[x.jsxs("label",{className:"flex items-center text-xs text-slate-500 uppercase tracking-wide",children:["Regions",x.jsx(Wo,{info:"Regions group mesh nodes by geographic area. Each region has an anchor point (lat/lon) and nodes within the region radius are automatically assigned. Regions enable localized reports, alerts, and health scoring."})]}),e.regions.map((i,a)=>x.jsxs("div",{className:"border border-[#1e2a3a] rounded-lg overflow-hidden",children:[x.jsxs("div",{className:"flex items-center justify-between p-3 bg-[#0a0e17] cursor-pointer",onClick:()=>n(r===a?null:a),children:[x.jsxs("div",{className:"flex items-center gap-3",children:[r===a?x.jsx(Hy,{size:16}):x.jsx(bm,{size:16}),x.jsx("span",{className:"font-medium text-slate-200",children:i.name||"Unnamed Region"}),x.jsx("span",{className:"text-xs text-slate-500",children:i.local_name})]}),x.jsx("button",{onClick:o=>{if(o.stopPropagation(),confirm(`Delete region "${i.name||"Unnamed Region"}"?`)){const s=e.regions.filter((l,u)=>u!==a);t({...e,regions:s})}},className:"p-1 text-red-400 hover:text-red-300 hover:bg-red-500/10 rounded",children:x.jsx(UE,{size:14})})]}),r===a&&x.jsxs("div",{className:"p-4 space-y-3 border-t border-[#1e2a3a]",children:[x.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[x.jsx(At,{label:"Name",value:i.name,onChange:o=>{const s=[...e.regions];s[a]={...i,name:o},t({...e,regions:s})}}),x.jsx(At,{label:"Local Name",value:i.local_name,onChange:o=>{const s=[...e.regions];s[a]={...i,local_name:o},t({...e,regions:s})}})]}),x.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[x.jsx(qe,{label:"Latitude",value:i.lat,onChange:o=>{const s=[...e.regions];s[a]={...i,lat:o},t({...e,regions:s})},step:1e-4}),x.jsx(qe,{label:"Longitude",value:i.lon,onChange:o=>{const s=[...e.regions];s[a]={...i,lon:o},t({...e,regions:s})},step:1e-4})]}),x.jsx(At,{label:"Description",value:i.description,onChange:o=>{const s=[...e.regions];s[a]={...i,description:o},t({...e,regions:s})}}),x.jsx(Hh,{label:"Aliases",value:i.aliases,onChange:o=>{const s=[...e.regions];s[a]={...i,aliases:o},t({...e,regions:s})}}),x.jsx(Hh,{label:"Cities",value:i.cities,onChange:o=>{const s=[...e.regions];s[a]={...i,cities:o},t({...e,regions:s})}})]})]},a)),x.jsxs("button",{onClick:()=>{const i={name:"",local_name:"",lat:0,lon:0,description:"",aliases:[],cities:[]};t({...e,regions:[...e.regions,i]}),n(e.regions.length)},className:"w-full py-2 border border-dashed border-[#1e2a3a] rounded-lg text-slate-500 hover:text-slate-300 hover:border-accent flex items-center justify-center gap-2 transition-colors",children:[x.jsx(bS,{size:16})," Add Region"]})]}),x.jsxs("div",{className:"space-y-3",children:[x.jsxs("label",{className:"flex items-center text-xs text-slate-500 uppercase tracking-wide",children:["Alert Rules",x.jsx(Wo,{info:"Configure which conditions trigger alerts. Each rule can have an optional threshold value."})]}),x.jsxs("div",{className:"space-y-2",children:[x.jsx("h4",{className:"text-xs text-slate-400 font-medium",children:"Infrastructure"}),x.jsx(Cn,{label:"Infra Offline",description:"Alert when an infrastructure node (router/repeater) goes offline",checked:e.alert_rules.infra_offline,onChange:i=>t({...e,alert_rules:{...e.alert_rules,infra_offline:i}})}),x.jsx(Cn,{label:"Infra Recovery",description:"Alert when an offline infrastructure node comes back online",checked:e.alert_rules.infra_recovery,onChange:i=>t({...e,alert_rules:{...e.alert_rules,infra_recovery:i}})}),x.jsx(Cn,{label:"New Router",description:"Alert when a new router/repeater appears on the mesh",checked:e.alert_rules.new_router,onChange:i=>t({...e,alert_rules:{...e.alert_rules,new_router:i}})}),x.jsx(Cn,{label:"Feeder Offline",description:"Alert when a data source (MeshView/MeshMonitor) stops responding",checked:e.alert_rules.feeder_offline,onChange:i=>t({...e,alert_rules:{...e.alert_rules,feeder_offline:i}})}),x.jsx(Cn,{label:"Single Gateway",description:"Alert when an infrastructure node has only one connection path",checked:e.alert_rules.infra_single_gateway,onChange:i=>t({...e,alert_rules:{...e.alert_rules,infra_single_gateway:i}})}),x.jsx(Cn,{label:"Region Blackout",description:"Alert when all infrastructure in a region goes offline",checked:e.alert_rules.region_total_blackout,onChange:i=>t({...e,alert_rules:{...e.alert_rules,region_total_blackout:i}})})]}),x.jsxs("div",{className:"space-y-2",children:[x.jsx("h4",{className:"text-xs text-slate-400 font-medium",children:"Power"}),x.jsx(Cn,{label:"Battery Warning",description:"Alert when infra node battery drops below warning threshold",checked:e.alert_rules.battery_warning,onChange:i=>t({...e,alert_rules:{...e.alert_rules,battery_warning:i}}),threshold:e.alert_rules.battery_warning_threshold,onThresholdChange:i=>t({...e,alert_rules:{...e.alert_rules,battery_warning_threshold:i}}),thresholdLabel:"Below",thresholdMin:10,thresholdMax:90,thresholdSuffix:"%"}),x.jsx(Cn,{label:"Battery Critical",description:"Alert at critical battery level",checked:e.alert_rules.battery_critical,onChange:i=>t({...e,alert_rules:{...e.alert_rules,battery_critical:i}}),threshold:e.alert_rules.battery_critical_threshold,onThresholdChange:i=>t({...e,alert_rules:{...e.alert_rules,battery_critical_threshold:i}}),thresholdLabel:"Below",thresholdMin:5,thresholdMax:50,thresholdSuffix:"%"}),x.jsx(Cn,{label:"Battery Emergency",description:"Alert at emergency battery level",checked:e.alert_rules.battery_emergency,onChange:i=>t({...e,alert_rules:{...e.alert_rules,battery_emergency:i}}),threshold:e.alert_rules.battery_emergency_threshold,onThresholdChange:i=>t({...e,alert_rules:{...e.alert_rules,battery_emergency_threshold:i}}),thresholdLabel:"Below",thresholdMin:1,thresholdMax:25,thresholdSuffix:"%"}),x.jsx(Cn,{label:"Battery Trend Declining",description:"Alert when battery shows a declining trend over 7 days",checked:e.alert_rules.battery_trend_declining,onChange:i=>t({...e,alert_rules:{...e.alert_rules,battery_trend_declining:i}})}),x.jsx(Cn,{label:"Power Source Change",description:"Alert when a node switches between battery and USB power",checked:e.alert_rules.power_source_change,onChange:i=>t({...e,alert_rules:{...e.alert_rules,power_source_change:i}})}),x.jsx(Cn,{label:"Solar Not Charging",description:"Alert when a solar-powered node isn't charging during daylight",checked:e.alert_rules.solar_not_charging,onChange:i=>t({...e,alert_rules:{...e.alert_rules,solar_not_charging:i}})})]}),x.jsxs("div",{className:"space-y-2",children:[x.jsx("h4",{className:"text-xs text-slate-400 font-medium",children:"Utilization"}),x.jsx(Cn,{label:"High Utilization",description:"Alert when channel utilization stays high for extended periods",checked:e.alert_rules.sustained_high_util,onChange:i=>t({...e,alert_rules:{...e.alert_rules,sustained_high_util:i}}),threshold:e.alert_rules.high_util_threshold,onThresholdChange:i=>t({...e,alert_rules:{...e.alert_rules,high_util_threshold:i}}),thresholdLabel:"Above",thresholdMin:5,thresholdMax:50,thresholdSuffix:`% for ${e.alert_rules.high_util_hours}h`}),x.jsx(Cn,{label:"Packet Flood",description:"Alert when a single node sends excessive packets",checked:e.alert_rules.packet_flood,onChange:i=>t({...e,alert_rules:{...e.alert_rules,packet_flood:i}}),threshold:e.alert_rules.packet_flood_threshold,onThresholdChange:i=>t({...e,alert_rules:{...e.alert_rules,packet_flood_threshold:i}}),thresholdLabel:"Over",thresholdMin:100,thresholdMax:2e3,thresholdSuffix:"pkts/24h"})]}),x.jsxs("div",{className:"space-y-2",children:[x.jsx("h4",{className:"text-xs text-slate-400 font-medium",children:"Health Scores"}),x.jsx(Cn,{label:"Mesh Score Alert",description:"Alert when overall mesh health score drops below threshold",checked:e.alert_rules.mesh_score_alert,onChange:i=>t({...e,alert_rules:{...e.alert_rules,mesh_score_alert:i}}),threshold:e.alert_rules.mesh_score_threshold,onThresholdChange:i=>t({...e,alert_rules:{...e.alert_rules,mesh_score_threshold:i}}),thresholdLabel:"Below",thresholdMin:30,thresholdMax:90,thresholdSuffix:"/100"}),x.jsx(Cn,{label:"Region Score Alert",description:"Alert when a region's health score drops below threshold",checked:e.alert_rules.region_score_alert,onChange:i=>t({...e,alert_rules:{...e.alert_rules,region_score_alert:i}}),threshold:e.alert_rules.region_score_threshold,onThresholdChange:i=>t({...e,alert_rules:{...e.alert_rules,region_score_threshold:i}}),thresholdLabel:"Below",thresholdMin:30,thresholdMax:90,thresholdSuffix:"/100"})]})]})]})]})}function GJe({data:e,onChange:t}){var r,n,i,a,o,s,l,u,c,f,h,d,v,g,m,y;return x.jsxs("div",{className:"space-y-6",children:[x.jsx(Qn,{text:Kn.environmental}),x.jsx(Et,{label:"Enable Environmental Feeds",checked:e.enabled,onChange:_=>t({...e,enabled:_}),helper:"Activate live data polling"}),e.enabled&&x.jsxs(x.Fragment,{children:[x.jsx(Hh,{label:"NWS Zones",value:e.nws_zones,onChange:_=>t({...e,nws_zones:_}),helper:"Zone IDs like IDZ016, IDZ030",info:"NWS forecast zones covering your mesh area. Find yours at https://www.weather.gov/pimar/PubZone",infoLink:"https://www.weather.gov/pimar/PubZone"}),x.jsxs("div",{className:"border border-[#1e2a3a] rounded-lg p-4 space-y-3",children:[x.jsxs("div",{className:"flex items-center justify-between",children:[x.jsx("span",{className:"text-sm font-medium text-slate-300",children:"NWS Weather Alerts"}),x.jsx(Et,{label:"",checked:e.nws.enabled,onChange:_=>t({...e,nws:{...e.nws,enabled:_}})})]}),e.nws.enabled&&x.jsxs(x.Fragment,{children:[x.jsx(At,{label:"User Agent",value:e.nws.user_agent,onChange:_=>t({...e,nws:{...e.nws,user_agent:_}}),placeholder:"(MeshAI, your@email.com)",helper:"Required format: (app_name, contact_email)",info:"Required by NWS. You make it up - just use the format (app_name, your_email). No signup needed."}),x.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[x.jsx(qe,{label:"Tick Seconds",value:e.nws.tick_seconds,onChange:_=>t({...e,nws:{...e.nws,tick_seconds:_}}),min:30,helper:"Polling interval"}),x.jsx(Co,{label:"Min Severity",value:e.nws.severity_min,onChange:_=>t({...e,nws:{...e.nws,severity_min:_}}),options:[{value:"minor",label:"Minor"},{value:"moderate",label:"Moderate"},{value:"severe",label:"Severe"},{value:"extreme",label:"Extreme"}],helper:"Filter out lower severity alerts",info:"Minimum severity level to display. 'Moderate' filters out minor advisories. 'Severe' shows only serious warnings."})]})]})]}),x.jsx("div",{className:"border border-[#1e2a3a] rounded-lg p-4",children:x.jsxs("div",{className:"flex items-center justify-between",children:[x.jsxs("div",{children:[x.jsx("span",{className:"text-sm font-medium text-slate-300",children:"NOAA Space Weather (SWPC)"}),x.jsx("p",{className:"text-xs text-slate-600",children:"Solar indices, geomagnetic storms, HF propagation"})]}),x.jsx(Et,{label:"",checked:e.swpc.enabled,onChange:_=>t({...e,swpc:{...e.swpc,enabled:_}})})]})}),x.jsxs("div",{className:"border border-[#1e2a3a] rounded-lg p-4 space-y-3",children:[x.jsxs("div",{className:"flex items-center justify-between",children:[x.jsxs("div",{children:[x.jsx("span",{className:"text-sm font-medium text-slate-300",children:"Tropospheric Ducting"}),x.jsx("p",{className:"text-xs text-slate-600",children:"VHF/UHF extended range conditions"})]}),x.jsx(Et,{label:"",checked:e.ducting.enabled,onChange:_=>t({...e,ducting:{...e.ducting,enabled:_}})})]}),e.ducting.enabled&&x.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[x.jsx(qe,{label:"Tick Seconds",value:e.ducting.tick_seconds,onChange:_=>t({...e,ducting:{...e.ducting,tick_seconds:_}}),min:60}),x.jsx(qe,{label:"Latitude",value:e.ducting.latitude,onChange:_=>t({...e,ducting:{...e.ducting,latitude:_}}),step:.01,info:"Center point of your mesh coverage area. The ducting adapter checks atmospheric conditions at this location."}),x.jsx(qe,{label:"Longitude",value:e.ducting.longitude,onChange:_=>t({...e,ducting:{...e.ducting,longitude:_}}),step:.01})]})]}),x.jsxs("div",{className:"border border-[#1e2a3a] rounded-lg p-4 space-y-3",children:[x.jsxs("div",{className:"flex items-center justify-between",children:[x.jsxs("div",{children:[x.jsx("span",{className:"text-sm font-medium text-slate-300",children:"NIFC Fire Perimeters"}),x.jsx("p",{className:"text-xs text-slate-600",children:"Active wildfires from National Interagency Fire Center"})]}),x.jsx(Et,{label:"",checked:e.fires.enabled,onChange:_=>t({...e,fires:{...e.fires,enabled:_}})})]}),e.fires.enabled&&x.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[x.jsx(qe,{label:"Tick Seconds",value:e.fires.tick_seconds,onChange:_=>t({...e,fires:{...e.fires,tick_seconds:_}}),min:60}),x.jsx(Co,{label:"State",value:e.fires.state,onChange:_=>t({...e,fires:{...e.fires,state:_}}),options:CJe,helper:"Filter fires by state",info:"Two-letter state code for NIFC wildfire filtering."})]})]}),x.jsxs("div",{className:"border border-[#1e2a3a] rounded-lg p-4 space-y-3",children:[x.jsxs("div",{className:"flex items-center justify-between",children:[x.jsxs("div",{children:[x.jsx("span",{className:"text-sm font-medium text-slate-300",children:"Avalanche Advisories"}),x.jsx("p",{className:"text-xs text-slate-600",children:"Backcountry avalanche danger ratings"})]}),x.jsx(Et,{label:"",checked:e.avalanche.enabled,onChange:_=>t({...e,avalanche:{...e.avalanche,enabled:_}})})]}),e.avalanche.enabled&&x.jsxs(x.Fragment,{children:[x.jsx(qe,{label:"Tick Seconds",value:e.avalanche.tick_seconds,onChange:_=>t({...e,avalanche:{...e.avalanche,tick_seconds:_}}),min:60}),x.jsx(Hh,{label:"Center IDs",value:e.avalanche.center_ids,onChange:_=>t({...e,avalanche:{...e.avalanche,center_ids:_}}),helper:"e.g., SNFAC, IPAC, FAC",info:"Find your local center at https://avalanche.org/avalanche-centers/",infoLink:"https://avalanche.org/avalanche-centers/"}),x.jsx(PJe,{label:"Season Months",value:e.avalanche.season_months,onChange:_=>t({...e,avalanche:{...e.avalanche,season_months:_}}),helper:"e.g., 12, 1, 2, 3, 4",info:"Months when avalanche forecasts are active. Default Dec-Apr. Adjust for your region's season."})]})]}),x.jsxs("div",{className:"border border-[#1e2a3a] rounded-lg p-4 space-y-3",children:[x.jsxs("div",{className:"flex items-center justify-between",children:[x.jsxs("div",{children:[x.jsx("span",{className:"text-sm font-medium text-slate-300",children:"USGS Stream Gauges"}),x.jsx("p",{className:"text-xs text-slate-600",children:"River and stream water levels"})]}),x.jsx(Et,{label:"",checked:((r=e.usgs)==null?void 0:r.enabled)||!1,onChange:_=>{var b,S;return t({...e,usgs:{...e.usgs,enabled:_,tick_seconds:((b=e.usgs)==null?void 0:b.tick_seconds)||900,sites:((S=e.usgs)==null?void 0:S.sites)||[]}})}})]}),((n=e.usgs)==null?void 0:n.enabled)&&x.jsxs(x.Fragment,{children:[x.jsx(qe,{label:"Tick Seconds",value:e.usgs.tick_seconds,onChange:_=>t({...e,usgs:{...e.usgs,tick_seconds:_}}),min:900,helper:"Minimum 15 min (900s)"}),x.jsx(Hh,{label:"Site IDs",value:e.usgs.sites,onChange:_=>t({...e,usgs:{...e.usgs,sites:_}}),helper:"USGS gauge site numbers",info:"Find site IDs at waterdata.usgs.gov/nwis",infoLink:"https://waterdata.usgs.gov/nwis"})]})]}),x.jsxs("div",{className:"border border-[#1e2a3a] rounded-lg p-4 space-y-3",children:[x.jsxs("div",{className:"flex items-center justify-between",children:[x.jsxs("div",{children:[x.jsx("span",{className:"text-sm font-medium text-slate-300",children:"TomTom Traffic"}),x.jsx("p",{className:"text-xs text-slate-600",children:"Traffic flow on monitored corridors"})]}),x.jsx(Et,{label:"",checked:((i=e.traffic)==null?void 0:i.enabled)||!1,onChange:_=>{var b,S,T;return t({...e,traffic:{...e.traffic,enabled:_,tick_seconds:((b=e.traffic)==null?void 0:b.tick_seconds)||300,api_key:((S=e.traffic)==null?void 0:S.api_key)||"",corridors:((T=e.traffic)==null?void 0:T.corridors)||[]}})}})]}),((a=e.traffic)==null?void 0:a.enabled)&&x.jsxs(x.Fragment,{children:[x.jsx(At,{label:"API Key",value:e.traffic.api_key,onChange:_=>t({...e,traffic:{...e.traffic,api_key:_}}),type:"password",helper:"Get key at developer.tomtom.com",infoLink:"https://developer.tomtom.com"}),x.jsx(qe,{label:"Tick Seconds",value:e.traffic.tick_seconds,onChange:_=>t({...e,traffic:{...e.traffic,tick_seconds:_}}),min:60}),x.jsx("div",{className:"text-xs text-slate-500 mt-2",children:"Corridors (each with name, lat, lon):"}),(e.traffic.corridors||[]).map((_,b)=>x.jsxs("div",{className:"grid grid-cols-4 gap-2 items-end",children:[x.jsx(At,{label:"Name",value:_.name,onChange:S=>{const T=[...e.traffic.corridors];T[b]={..._,name:S},t({...e,traffic:{...e.traffic,corridors:T}})}}),x.jsx(qe,{label:"Lat",value:_.lat,onChange:S=>{const T=[...e.traffic.corridors];T[b]={..._,lat:S},t({...e,traffic:{...e.traffic,corridors:T}})},step:.01}),x.jsx(qe,{label:"Lon",value:_.lon,onChange:S=>{const T=[...e.traffic.corridors];T[b]={..._,lon:S},t({...e,traffic:{...e.traffic,corridors:T}})},step:.01}),x.jsx("button",{onClick:()=>t({...e,traffic:{...e.traffic,corridors:e.traffic.corridors.filter((S,T)=>T!==b)}}),className:"px-2 py-2 text-xs text-red-400 hover:text-red-300 border border-red-400/30 rounded",children:"Remove"})]},b)),x.jsx("button",{onClick:()=>t({...e,traffic:{...e.traffic,corridors:[...e.traffic.corridors||[],{name:"",lat:0,lon:0}]}}),className:"text-xs text-accent hover:underline",children:"+ Add Corridor"})]})]}),x.jsxs("div",{className:"border border-[#1e2a3a] rounded-lg p-4 space-y-3",children:[x.jsxs("div",{className:"flex items-center justify-between",children:[x.jsxs("div",{children:[x.jsx("span",{className:"text-sm font-medium text-slate-300",children:"511 Road Conditions"}),x.jsx("p",{className:"text-xs text-slate-600",children:"State DOT road events and closures"})]}),x.jsx(Et,{label:"",checked:((o=e.roads511)==null?void 0:o.enabled)||!1,onChange:_=>{var b,S,T,A,M;return t({...e,roads511:{...e.roads511,enabled:_,tick_seconds:((b=e.roads511)==null?void 0:b.tick_seconds)||300,api_key:((S=e.roads511)==null?void 0:S.api_key)||"",base_url:((T=e.roads511)==null?void 0:T.base_url)||"",endpoints:((A=e.roads511)==null?void 0:A.endpoints)||["/get/event"],bbox:((M=e.roads511)==null?void 0:M.bbox)||[]}})}})]}),((s=e.roads511)==null?void 0:s.enabled)&&x.jsxs(x.Fragment,{children:[x.jsx(At,{label:"Base URL",value:e.roads511.base_url,onChange:_=>t({...e,roads511:{...e.roads511,base_url:_}}),placeholder:"https://511.yourstate.gov/api/v2",helper:"State 511 API endpoint"}),x.jsx(At,{label:"API Key",value:e.roads511.api_key,onChange:_=>t({...e,roads511:{...e.roads511,api_key:_}}),type:"password",helper:"Leave empty if not required"}),x.jsx(qe,{label:"Tick Seconds",value:e.roads511.tick_seconds,onChange:_=>t({...e,roads511:{...e.roads511,tick_seconds:_}}),min:60}),x.jsx(Hh,{label:"Endpoints",value:e.roads511.endpoints,onChange:_=>t({...e,roads511:{...e.roads511,endpoints:_}}),helper:"e.g., /get/event, /get/mountainpasses"}),x.jsxs("div",{className:"grid grid-cols-4 gap-2",children:[x.jsx(qe,{label:"West",value:((l=e.roads511.bbox)==null?void 0:l[0])||0,onChange:_=>{const b=[...e.roads511.bbox||[0,0,0,0]];b[0]=_,t({...e,roads511:{...e.roads511,bbox:b}})},step:.01}),x.jsx(qe,{label:"South",value:((u=e.roads511.bbox)==null?void 0:u[1])||0,onChange:_=>{const b=[...e.roads511.bbox||[0,0,0,0]];b[1]=_,t({...e,roads511:{...e.roads511,bbox:b}})},step:.01}),x.jsx(qe,{label:"East",value:((c=e.roads511.bbox)==null?void 0:c[2])||0,onChange:_=>{const b=[...e.roads511.bbox||[0,0,0,0]];b[2]=_,t({...e,roads511:{...e.roads511,bbox:b}})},step:.01}),x.jsx(qe,{label:"North",value:((f=e.roads511.bbox)==null?void 0:f[3])||0,onChange:_=>{const b=[...e.roads511.bbox||[0,0,0,0]];b[3]=_,t({...e,roads511:{...e.roads511,bbox:b}})},step:.01})]}),x.jsx("div",{className:"text-xs text-slate-500",children:"Bounding box filter (leave all 0 to disable)"})]})]}),x.jsxs("div",{className:"border border-[#1e2a3a] rounded-lg p-4 space-y-3",children:[x.jsxs("div",{className:"flex items-center justify-between",children:[x.jsxs("div",{children:[x.jsx("span",{className:"text-sm font-medium text-slate-300",children:"NASA FIRMS Satellite Fire Detection"}),x.jsx("p",{className:"text-xs text-slate-600",children:"Near real-time thermal anomalies from satellites"})]}),x.jsx(Et,{label:"",checked:((h=e.firms)==null?void 0:h.enabled)||!1,onChange:_=>{var b,S,T,A,M,P,k;return t({...e,firms:{...e.firms,enabled:_,tick_seconds:((b=e.firms)==null?void 0:b.tick_seconds)||1800,map_key:((S=e.firms)==null?void 0:S.map_key)||"",source:((T=e.firms)==null?void 0:T.source)||"VIIRS_SNPP_NRT",bbox:((A=e.firms)==null?void 0:A.bbox)||[],day_range:((M=e.firms)==null?void 0:M.day_range)||1,confidence_min:((P=e.firms)==null?void 0:P.confidence_min)||"nominal",proximity_km:((k=e.firms)==null?void 0:k.proximity_km)||10}})}})]}),((d=e.firms)==null?void 0:d.enabled)&&x.jsxs(x.Fragment,{children:[x.jsx(At,{label:"MAP Key",value:e.firms.map_key,onChange:_=>t({...e,firms:{...e.firms,map_key:_}}),type:"password",helper:"Get key at firms.modaps.eosdis.nasa.gov/api/area/",infoLink:"https://firms.modaps.eosdis.nasa.gov/api/area/"}),x.jsx(qe,{label:"Tick Seconds",value:e.firms.tick_seconds,onChange:_=>t({...e,firms:{...e.firms,tick_seconds:_}}),min:300,helper:"Minimum 5 min (300s)"}),x.jsx(Co,{label:"Satellite Source",value:e.firms.source,onChange:_=>t({...e,firms:{...e.firms,source:_}}),options:[{value:"VIIRS_SNPP_NRT",label:"VIIRS SNPP (Near Real-Time)"},{value:"VIIRS_NOAA20_NRT",label:"VIIRS NOAA-20 (Near Real-Time)"},{value:"MODIS_NRT",label:"MODIS (Near Real-Time)"}]}),x.jsx(qe,{label:"Day Range",value:e.firms.day_range,onChange:_=>t({...e,firms:{...e.firms,day_range:_}}),min:1,max:10,helper:"1-10 days of data"}),x.jsx(Co,{label:"Minimum Confidence",value:e.firms.confidence_min,onChange:_=>t({...e,firms:{...e.firms,confidence_min:_}}),options:[{value:"low",label:"Low"},{value:"nominal",label:"Nominal"},{value:"high",label:"High"}]}),x.jsx(qe,{label:"Proximity (km)",value:e.firms.proximity_km,onChange:_=>t({...e,firms:{...e.firms,proximity_km:_}}),step:.5,helper:"Distance to match known fires"}),x.jsxs("div",{className:"grid grid-cols-4 gap-2",children:[x.jsx(qe,{label:"West",value:((v=e.firms.bbox)==null?void 0:v[0])||0,onChange:_=>{const b=[...e.firms.bbox||[0,0,0,0]];b[0]=_,t({...e,firms:{...e.firms,bbox:b}})},step:.01}),x.jsx(qe,{label:"South",value:((g=e.firms.bbox)==null?void 0:g[1])||0,onChange:_=>{const b=[...e.firms.bbox||[0,0,0,0]];b[1]=_,t({...e,firms:{...e.firms,bbox:b}})},step:.01}),x.jsx(qe,{label:"East",value:((m=e.firms.bbox)==null?void 0:m[2])||0,onChange:_=>{const b=[...e.firms.bbox||[0,0,0,0]];b[2]=_,t({...e,firms:{...e.firms,bbox:b}})},step:.01}),x.jsx(qe,{label:"North",value:((y=e.firms.bbox)==null?void 0:y[3])||0,onChange:_=>{const b=[...e.firms.bbox||[0,0,0,0]];b[3]=_,t({...e,firms:{...e.firms,bbox:b}})},step:.01})]}),x.jsx("div",{className:"text-xs text-slate-500",children:"Bounding box for monitoring area (required)"})]})]})]})]})}function WJe({data:e,onChange:t}){return x.jsxs("div",{className:"space-y-4",children:[x.jsx(Qn,{text:Kn.dashboard}),x.jsx(Et,{label:"Enable Dashboard",checked:e.enabled,onChange:r=>t({...e,enabled:r}),helper:"Run the web dashboard"}),e.enabled&&x.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[x.jsx(At,{label:"Host",value:e.host,onChange:r=>t({...e,host:r}),placeholder:"0.0.0.0",helper:"Network bind address",info:"0.0.0.0 = accessible from any device on the network. 127.0.0.1 = only accessible from this machine."}),x.jsx(qe,{label:"Port",value:e.port,onChange:r=>t({...e,port:r}),min:1,max:65535,helper:"Dashboard URL port",info:"Port number for the web dashboard URL. You access the dashboard at http://your-ip:port"})]})]})}function HJe(){var k;const[e,t]=W.useState(null),[r,n]=W.useState(null),[i,a]=W.useState("bot"),[o,s]=W.useState(!0),[l,u]=W.useState(!1),[c,f]=W.useState(null),[h,d]=W.useState(null),[v,g]=W.useState(!1),[m,y]=W.useState(!1),_=W.useCallback(async()=>{try{const I=await fetch("/api/config");if(!I.ok)throw new Error("Failed to fetch config");const O=await I.json();t(O),n(JSON.parse(JSON.stringify(O))),y(!1),f(null)}catch(I){f(I instanceof Error?I.message:"Unknown error")}finally{s(!1)}},[]);W.useEffect(()=>{document.title="Config — MeshAI",_()},[_]),W.useEffect(()=>{e&&r&&y(JSON.stringify(e)!==JSON.stringify(r))},[e,r]);const b=async()=>{if(e){u(!0),f(null),d(null);try{const I=e[i],O=await fetch(`/api/config/${i}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(I)}),D=await O.json();if(!O.ok)throw new Error(D.detail||"Save failed");d(`${i} saved successfully`),n(JSON.parse(JSON.stringify(e))),y(!1),D.restart_required&&g(!0),setTimeout(()=>d(null),3e3)}catch(I){f(I instanceof Error?I.message:"Save failed")}finally{u(!1)}}},S=()=>{r&&(t(JSON.parse(JSON.stringify(r))),y(!1))},T=async()=>{try{await fetch("/api/restart",{method:"POST"}),g(!1),d("Restart initiated")}catch{f("Restart failed")}},A=(I,O)=>{e&&t({...e,[I]:O})};if(o)return x.jsx("div",{className:"flex items-center justify-center h-64",children:x.jsx("div",{className:"text-slate-400",children:"Loading configuration..."})});if(!e)return x.jsx("div",{className:"flex items-center justify-center h-64",children:x.jsx("div",{className:"text-red-400",children:"Failed to load configuration"})});const M=()=>{switch(i){case"bot":return x.jsx(LJe,{data:e.bot,onChange:I=>A("bot",I)});case"connection":return x.jsx(kJe,{data:e.connection,onChange:I=>A("connection",I)});case"response":return x.jsx(IJe,{data:e.response,onChange:I=>A("response",I)});case"history":return x.jsx(OJe,{data:e.history,onChange:I=>A("history",I)});case"memory":return x.jsx(EJe,{data:e.memory,onChange:I=>A("memory",I)});case"context":return x.jsx(DJe,{data:e.context,onChange:I=>A("context",I)});case"commands":return x.jsx(NJe,{data:e.commands,onChange:I=>A("commands",I)});case"llm":return x.jsx(jJe,{data:e.llm,onChange:I=>A("llm",I)});case"weather":return x.jsx(RJe,{data:e.weather,onChange:I=>A("weather",I)});case"meshmonitor":return x.jsx(BJe,{data:e.meshmonitor,onChange:I=>A("meshmonitor",I)});case"knowledge":return x.jsx(zJe,{data:e.knowledge,onChange:I=>A("knowledge",I)});case"mesh_sources":return x.jsx(FJe,{data:e.mesh_sources,onChange:I=>A("mesh_sources",I)});case"mesh_intelligence":return x.jsx(VJe,{data:e.mesh_intelligence,onChange:I=>A("mesh_intelligence",I)});case"environmental":return x.jsx(GJe,{data:e.environmental,onChange:I=>A("environmental",I)});case"dashboard":return x.jsx(WJe,{data:e.dashboard,onChange:I=>A("dashboard",I)});default:return null}},P=((k=BU.find(I=>I.key===i))==null?void 0:k.label)||i;return x.jsxs("div",{className:"flex gap-6 h-[calc(100vh-8rem)]",children:[x.jsx("div",{className:"w-48 flex-shrink-0 space-y-1",children:BU.map(({key:I,label:O,icon:D})=>x.jsxs("button",{onClick:()=>a(I),className:`w-full flex items-center gap-2 px-3 py-2 rounded text-sm transition-colors ${i===I?"bg-accent text-white":"text-slate-400 hover:text-slate-200 hover:bg-bg-hover"}`,children:[x.jsx(D,{size:16}),x.jsx("span",{children:O}),m&&i===I&&x.jsx("span",{className:"ml-auto w-2 h-2 bg-amber-500 rounded-full"})]},I))}),x.jsxs("div",{className:"flex-1 flex flex-col min-w-0",children:[x.jsxs("div",{className:"flex items-center justify-between mb-6",children:[x.jsxs("div",{className:"flex items-center gap-3",children:[x.jsx(AZ,{size:20,className:"text-slate-500"}),x.jsx("h2",{className:"text-lg font-semibold text-slate-200",children:P})]}),x.jsxs("div",{className:"flex items-center gap-2",children:[m&&x.jsxs("button",{onClick:S,className:"flex items-center gap-1.5 px-3 py-1.5 text-sm text-slate-400 hover:text-slate-200 bg-bg-hover rounded transition-colors",children:[x.jsx(SZ,{size:14}),"Discard"]}),x.jsxs("button",{onClick:b,disabled:l||!m,className:"flex items-center gap-1.5 px-4 py-1.5 text-sm bg-accent text-white rounded hover:bg-accent/80 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:[l?x.jsx(wZ,{size:14,className:"animate-spin"}):x.jsx(TZ,{size:14}),"Save"]})]})]}),v&&x.jsxs("div",{className:"flex items-center justify-between p-3 mb-4 bg-amber-500/10 border border-amber-500/30 rounded-lg",children:[x.jsxs("div",{className:"flex items-center gap-2 text-amber-400",children:[x.jsx(Ds,{size:16}),x.jsx("span",{className:"text-sm",children:"Restart required for changes to take effect"})]}),x.jsx("button",{onClick:T,className:"px-3 py-1 text-sm bg-amber-500 text-white rounded hover:bg-amber-600 transition-colors",children:"Restart Now"})]}),c&&x.jsxs("div",{className:"flex items-center gap-2 p-3 mb-4 bg-red-500/10 border border-red-500/30 rounded-lg text-red-400",children:[x.jsx(hv,{size:16}),x.jsx("span",{className:"text-sm",children:c})]}),h&&x.jsxs("div",{className:"flex items-center gap-2 p-3 mb-4 bg-green-500/10 border border-green-500/30 rounded-lg text-green-400",children:[x.jsx(md,{size:16}),x.jsx("span",{className:"text-sm",children:h})]}),x.jsx("div",{className:"flex-1 overflow-y-auto pr-2",children:x.jsx("div",{className:"bg-bg-card border border-border rounded-lg p-6",children:M()})})]})]})}const zU={infra_offline:ice,infra_recovery:MZ,battery_warning:tC,battery_critical:tC,battery_emergency:tC,hf_blackout:Sm,uhf_ducting:tu,weather_warning:Yc,weather_watch:Yc,new_router:tu,packet_flood:Ds,sustained_high_util:Ds,region_blackout:Uy,default:_m};function UJe(e){return zU[e]||zU.default}function Vie(e){switch(e==null?void 0:e.toLowerCase()){case"critical":case"emergency":return{bg:"bg-red-500/10",border:"border-red-500",badge:"bg-red-500/20 text-red-400",iconColor:"text-red-500"};case"warning":return{bg:"bg-amber-500/10",border:"border-amber-500",badge:"bg-amber-500/20 text-amber-400",iconColor:"text-amber-500"};case"watch":return{bg:"bg-yellow-500/10",border:"border-yellow-500",badge:"bg-yellow-500/20 text-yellow-400",iconColor:"text-yellow-500"};case"advisory":case"info":default:return{bg:"bg-blue-500/10",border:"border-blue-500",badge:"bg-blue-500/20 text-blue-400",iconColor:"text-blue-500"}}}function ZJe(e){const t=typeof e=="number"?new Date(e*1e3):new Date(e),n=new Date().getTime()-t.getTime(),i=Math.floor(n/1e3),a=Math.floor(i/60),o=Math.floor(a/60),s=Math.floor(o/24);return i<60?"Just now":a<60?`${a}m ago`:o<24?`${o}h ago`:`${s}d ago`}function YJe(e){return(typeof e=="number"?new Date(e*1e3):new Date(e)).toLocaleString("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:!1})}function XJe(e){return e<60?`${e}s`:e<3600?`${Math.floor(e/60)}m`:e<86400?`${Math.floor(e/3600)}h ${Math.floor(e%3600/60)}m`:`${Math.floor(e/86400)}d`}function qJe({alert:e,onAcknowledge:t}){var i;const r=Vie(e.severity),n=UJe(e.type);return x.jsx("div",{className:`p-4 rounded-lg ${r.bg} border-l-4 ${r.border}`,children:x.jsxs("div",{className:"flex items-start gap-3",children:[x.jsx(n,{size:20,className:r.iconColor}),x.jsxs("div",{className:"flex-1 min-w-0",children:[x.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[x.jsx("span",{className:`text-xs px-2 py-0.5 rounded-full ${r.badge}`,children:(i=e.severity)==null?void 0:i.toUpperCase()}),x.jsx("span",{className:"text-xs text-slate-500",children:e.type})]}),x.jsx("div",{className:"text-sm text-slate-200",children:e.message}),x.jsxs("div",{className:"flex items-center gap-4 mt-2 text-xs text-slate-500",children:[x.jsxs("span",{className:"flex items-center gap-1",children:[x.jsx(yd,{size:12}),e.timestamp?ZJe(e.timestamp):"Just now"]}),e.scope_value&&x.jsxs("span",{children:[e.scope_type,": ",e.scope_value]})]})]}),x.jsx("button",{onClick:()=>t(e),className:"px-3 py-1 text-xs text-slate-400 hover:text-slate-200 border border-border rounded hover:bg-bg-hover transition-colors",children:"Acknowledge"})]})})}function KJe({history:e,typeFilter:t,severityFilter:r,onTypeFilterChange:n,onSeverityFilterChange:i,page:a,totalPages:o,onPageChange:s}){const l=["all","infra_offline","infra_recovery","battery_warning","battery_critical","hf_blackout","uhf_ducting","weather_warning","new_router","packet_flood"],u=["all","critical","warning","watch","info"];return x.jsxs("div",{className:"bg-bg-card border border-border rounded-lg",children:[x.jsxs("div",{className:"p-4 border-b border-border flex items-center gap-4",children:[x.jsxs("div",{className:"flex items-center gap-2",children:[x.jsx(FE,{size:14,className:"text-slate-400"}),x.jsx("span",{className:"text-sm text-slate-400",children:"Filter:"})]}),x.jsx("select",{value:t,onChange:c=>n(c.target.value),className:"bg-bg border border-border rounded px-3 py-1.5 text-sm text-slate-200 focus:outline-none focus:border-blue-500",children:l.map(c=>x.jsx("option",{value:c,children:c==="all"?"All Types":c.replace(/_/g," ")},c))}),x.jsx("select",{value:r,onChange:c=>i(c.target.value),className:"bg-bg border border-border rounded px-3 py-1.5 text-sm text-slate-200 focus:outline-none focus:border-blue-500",children:u.map(c=>x.jsx("option",{value:c,children:c==="all"?"All Severities":c.charAt(0).toUpperCase()+c.slice(1)},c))})]}),x.jsx("div",{className:"overflow-x-auto",children:x.jsxs("table",{className:"w-full",children:[x.jsx("thead",{children:x.jsxs("tr",{className:"border-b border-border",children:[x.jsx("th",{className:"text-left text-xs font-medium text-slate-400 p-4",children:"Time"}),x.jsx("th",{className:"text-left text-xs font-medium text-slate-400 p-4",children:"Type"}),x.jsx("th",{className:"text-left text-xs font-medium text-slate-400 p-4",children:"Severity"}),x.jsx("th",{className:"text-left text-xs font-medium text-slate-400 p-4",children:"Message"}),x.jsx("th",{className:"text-left text-xs font-medium text-slate-400 p-4",children:"Duration"})]})}),x.jsx("tbody",{children:e.length>0?e.map((c,f)=>{const h=Vie(c.severity);return x.jsxs("tr",{className:"border-b border-border hover:bg-bg-hover",children:[x.jsx("td",{className:"p-4 text-sm text-slate-400 font-mono whitespace-nowrap",children:YJe(c.timestamp)}),x.jsx("td",{className:"p-4 text-sm text-slate-300",children:c.type.replace(/_/g," ")}),x.jsx("td",{className:"p-4",children:x.jsx("span",{className:`text-xs px-2 py-0.5 rounded-full ${h.badge}`,children:c.severity})}),x.jsx("td",{className:"p-4 text-sm text-slate-200 max-w-md truncate",children:c.message}),x.jsx("td",{className:"p-4 text-sm text-slate-400 font-mono",children:c.duration?XJe(c.duration):"-"})]},c.id||f)}):x.jsx("tr",{children:x.jsx("td",{colSpan:5,className:"p-8 text-center text-slate-500",children:"No alert history available"})})})]})}),o>1&&x.jsxs("div",{className:"p-4 border-t border-border flex items-center justify-between",children:[x.jsxs("span",{className:"text-sm text-slate-400",children:["Page ",a," of ",o]}),x.jsxs("div",{className:"flex items-center gap-2",children:[x.jsx("button",{onClick:()=>s(a-1),disabled:a<=1,className:"p-2 text-slate-400 hover:text-slate-200 disabled:opacity-50 disabled:cursor-not-allowed",children:x.jsx(Uue,{size:16})}),x.jsx("button",{onClick:()=>s(a+1),disabled:a>=o,className:"p-2 text-slate-400 hover:text-slate-200 disabled:opacity-50 disabled:cursor-not-allowed",children:x.jsx(bm,{size:16})})]})]})]})}function QJe({subscription:e,nodes:t}){const r=o=>{const s=t.find(l=>l.node_id_hex===o||String(l.node_num)===o||l.short_name===o);return s?s.long_name&&s.long_name!==s.short_name?`${s.short_name} (${s.long_name})`:s.short_name:o},n=()=>{if(e.sub_type==="alerts")return"Real-time";const o=e.schedule_time||"0000",s=parseInt(o.slice(0,2)),l=o.slice(2),u=s>=12?"PM":"AM";let f=`${s%12||12}:${l} ${u}`;return e.sub_type==="weekly"&&e.schedule_day&&(f+=` ${e.schedule_day.charAt(0).toUpperCase()}${e.schedule_day.slice(1)}`),f},a=(()=>{switch(e.sub_type){case"alerts":return _m;case"daily":return yd;case"weekly":return yd;default:return _m}})();return x.jsx("div",{className:"p-4 rounded-lg bg-bg-hover border border-border",children:x.jsxs("div",{className:"flex items-center gap-3",children:[x.jsx("div",{className:"w-10 h-10 rounded-lg bg-blue-500/10 flex items-center justify-center",children:x.jsx(a,{size:18,className:"text-blue-400"})}),x.jsxs("div",{className:"flex-1",children:[x.jsxs("div",{className:"text-sm text-slate-200 font-medium",children:[e.sub_type.charAt(0).toUpperCase()+e.sub_type.slice(1),e.scope_type!=="mesh"&&e.scope_value&&x.jsxs("span",{className:"text-slate-400 font-normal ml-2",children:["(",e.scope_type,": ",e.scope_value,")"]})]}),x.jsxs("div",{className:"text-xs text-slate-500 mt-0.5",children:[n()," • ",r(e.user_id)]})]}),x.jsx("div",{className:`w-2 h-2 rounded-full ${e.enabled?"bg-green-500":"bg-slate-500"}`})]})})}function JJe(){const[e,t]=W.useState([]),[r,n]=W.useState([]),[i,a]=W.useState([]),[o,s]=W.useState([]),[l,u]=W.useState(!0),[c,f]=W.useState(null),[h,d]=W.useState("all"),[v,g]=W.useState("all"),[m,y]=W.useState(1),[_,b]=W.useState(1),S=20,[T,A]=W.useState(new Set),{lastAlert:M}=ZE();W.useEffect(()=>{document.title="Alerts — MeshAI"},[]),W.useEffect(()=>{Promise.all([PZ().catch(()=>[]),u3(S,0).catch(()=>({items:[],total:0})),uce().catch(()=>[]),fetch("/api/nodes").then(I=>I.json()).catch(()=>[])]).then(([I,O,D,N])=>{t(I),Array.isArray(O)?(n(O),b(1)):(n(O.items||[]),b(Math.ceil((O.total||0)/S))),a(D),s(N),u(!1)}).catch(I=>{f(I.message),u(!1)})},[]),W.useEffect(()=>{M&&t(I=>I.some(D=>D.type===M.type&&D.message===M.message)?I:[M,...I])},[M]),W.useEffect(()=>{const I=(m-1)*S;u3(S,I,h,v).then(O=>{Array.isArray(O)?(n(O),b(1)):(n(O.items||[]),b(Math.ceil((O.total||0)/S)))}).catch(()=>{})},[m,h,v]);const P=W.useCallback(I=>{const O=`${I.type}-${I.message}-${I.timestamp}`;A(D=>new Set([...D,O]))},[]),k=e.filter(I=>{const O=`${I.type}-${I.message}-${I.timestamp}`;return!T.has(O)});return l?x.jsx("div",{className:"flex items-center justify-center h-64",children:x.jsx("div",{className:"text-slate-400",children:"Loading alerts..."})}):c?x.jsx("div",{className:"flex items-center justify-center h-64",children:x.jsxs("div",{className:"text-red-400",children:["Error: ",c]})}):x.jsxs("div",{className:"space-y-6",children:[x.jsxs("div",{className:"bg-bg-card border border-border rounded-lg p-6",children:[x.jsxs("h2",{className:"text-sm font-medium text-slate-400 mb-4 flex items-center gap-2",children:[x.jsx(Ds,{size:14}),"Active Alerts (",k.length,")"]}),k.length>0?x.jsx("div",{className:"space-y-3",children:k.map((I,O)=>x.jsx(qJe,{alert:I,onAcknowledge:P},`${I.type}-${I.timestamp}-${O}`))}):x.jsxs("div",{className:"flex items-center gap-2 text-slate-500 py-8",children:[x.jsx(Qh,{size:20,className:"text-green-500"}),x.jsx("span",{children:"No active alerts — all systems nominal"})]})]}),x.jsxs("div",{children:[x.jsxs("h2",{className:"text-sm font-medium text-slate-400 mb-4 flex items-center gap-2",children:[x.jsx(yd,{size:14}),"Alert History"]}),x.jsx(KJe,{history:r,typeFilter:h,severityFilter:v,onTypeFilterChange:I=>{d(I),y(1)},onSeverityFilterChange:I=>{g(I),y(1)},page:m,totalPages:_,onPageChange:y})]}),x.jsxs("div",{className:"bg-bg-card border border-border rounded-lg p-6",children:[x.jsxs("h2",{className:"text-sm font-medium text-slate-400 mb-4 flex items-center gap-2",children:[x.jsx(nce,{size:14}),"Mesh Subscriptions (",i.length,")"]}),i.length>0?x.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3",children:i.map(I=>x.jsx(QJe,{subscription:I,nodes:o},I.id))}):x.jsxs("div",{className:"text-slate-500 py-4",children:[x.jsx("p",{children:"No active subscriptions."}),x.jsxs("p",{className:"text-xs mt-2",children:["Manage subscriptions via ",x.jsx("code",{className:"text-blue-400",children:"!subscribe"})," on mesh"]})]})]})]})}const gb=[{value:"info",label:"Info",description:"Routine updates (ducting detected, new router appeared)"},{value:"advisory",label:"Advisory",description:"Worth knowing (weather advisory, traffic slow, battery declining)"},{value:"watch",label:"Watch",description:"Pay attention (fire within 50km, weather watch, stream rising)"},{value:"warning",label:"Warning",description:"Act now (fire within 25km, severe weather, critical battery)"},{value:"critical",label:"Critical",description:"Serious issue (critical node down, battery emergency)"},{value:"emergency",label:"Emergency",description:"Life safety (extreme weather, fire at infrastructure, total blackout)"}],$U=[{id:"mesh_health",name:"Mesh Health Monitoring",description:"Infrastructure problems - offline nodes, low battery, channel congestion",rule:{name:"Mesh Health Monitoring",enabled:!0,trigger_type:"condition",categories:["infra_offline","critical_node_down","infra_recovery","battery_warning","battery_critical","battery_emergency","high_utilization","packet_flood","mesh_score_low"],min_severity:"advisory",delivery_type:"mesh_broadcast",broadcast_channel:0,cooldown_minutes:30,override_quiet:!1,schedule_frequency:"daily",schedule_time:"07:00",schedule_time_2:"",schedule_days:[],message_type:"",custom_message:"",node_ids:[],smtp_host:"",smtp_port:587,smtp_user:"",smtp_password:"",smtp_tls:!0,from_address:"",recipients:[],webhook_url:"",webhook_headers:{}}},{id:"weather_fire",name:"Weather & Fire Alerts",description:"Environmental threats - severe weather, nearby wildfires, new ignitions, flooding",rule:{name:"Weather & Fire Alerts",enabled:!0,trigger_type:"condition",categories:["weather_warning","fire_proximity","new_ignition","stream_flood_warning"],min_severity:"warning",delivery_type:"mesh_broadcast",broadcast_channel:0,cooldown_minutes:15,override_quiet:!1,schedule_frequency:"daily",schedule_time:"07:00",schedule_time_2:"",schedule_days:[],message_type:"",custom_message:"",node_ids:[],smtp_host:"",smtp_port:587,smtp_user:"",smtp_password:"",smtp_tls:!0,from_address:"",recipients:[],webhook_url:"",webhook_headers:{}}},{id:"rf_conditions",name:"RF Conditions",description:"Propagation changes - solar events, HF blackouts, tropospheric ducting",rule:{name:"RF Conditions",enabled:!0,trigger_type:"condition",categories:["hf_blackout","tropospheric_ducting","geomagnetic_storm"],min_severity:"info",delivery_type:"mesh_broadcast",broadcast_channel:0,cooldown_minutes:60,override_quiet:!1,schedule_frequency:"daily",schedule_time:"07:00",schedule_time_2:"",schedule_days:[],message_type:"",custom_message:"",node_ids:[],smtp_host:"",smtp_port:587,smtp_user:"",smtp_password:"",smtp_tls:!0,from_address:"",recipients:[],webhook_url:"",webhook_headers:{}}},{id:"road_traffic",name:"Road & Traffic",description:"Road closures and severe congestion",rule:{name:"Road & Traffic",enabled:!0,trigger_type:"condition",categories:["road_closure","traffic_congestion"],min_severity:"warning",delivery_type:"mesh_broadcast",broadcast_channel:0,cooldown_minutes:30,override_quiet:!1,schedule_frequency:"daily",schedule_time:"07:00",schedule_time_2:"",schedule_days:[],message_type:"",custom_message:"",node_ids:[],smtp_host:"",smtp_port:587,smtp_user:"",smtp_password:"",smtp_tls:!0,from_address:"",recipients:[],webhook_url:"",webhook_headers:{}}},{id:"everything_critical",name:"Everything Critical",description:"All emergency-level events regardless of type",rule:{name:"Everything Critical",enabled:!0,trigger_type:"condition",categories:[],min_severity:"emergency",delivery_type:"mesh_broadcast",broadcast_channel:0,cooldown_minutes:5,override_quiet:!0,schedule_frequency:"daily",schedule_time:"07:00",schedule_time_2:"",schedule_days:[],message_type:"",custom_message:"",node_ids:[],smtp_host:"",smtp_port:587,smtp_user:"",smtp_password:"",smtp_tls:!0,from_address:"",recipients:[],webhook_url:"",webhook_headers:{}}},{id:"morning_briefing",name:"Morning Briefing",description:"Daily health and conditions summary at 7am",rule:{name:"Morning Briefing",enabled:!0,trigger_type:"schedule",categories:[],min_severity:"info",schedule_frequency:"daily",schedule_time:"07:00",schedule_time_2:"",schedule_days:[],message_type:"mesh_health_summary",custom_message:"",delivery_type:"mesh_broadcast",broadcast_channel:0,cooldown_minutes:0,override_quiet:!1,node_ids:[],smtp_host:"",smtp_port:587,smtp_user:"",smtp_password:"",smtp_tls:!0,from_address:"",recipients:[],webhook_url:"",webhook_headers:{}}}];function No({info:e}){const[t,r]=W.useState(!1);return x.jsxs("div",{className:"relative inline-block",children:[x.jsx("button",{type:"button",onClick:n=>{n.stopPropagation(),r(!t)},className:"ml-1.5 w-4 h-4 rounded-full bg-slate-700 hover:bg-slate-600 text-slate-400 hover:text-slate-200 inline-flex items-center justify-center text-xs transition-colors",title:"More info",children:"?"}),t&&x.jsxs(x.Fragment,{children:[x.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>r(!1)}),x.jsx("div",{className:"absolute left-0 top-6 z-50 w-72 p-3 bg-[#1a2332] border border-[#2a3a4a] rounded-lg shadow-xl text-xs text-slate-300 leading-relaxed",children:e})]})]})}function mh({label:e,value:t,onChange:r,type:n="text",placeholder:i="",helper:a="",info:o=""}){const[s,l]=W.useState(!1),u=n==="password";return x.jsxs("div",{className:"space-y-1",children:[x.jsxs("label",{className:"flex items-center text-xs text-slate-500 uppercase tracking-wide",children:[e,o&&x.jsx(No,{info:o})]}),x.jsxs("div",{className:"relative",children:[x.jsx("input",{type:u&&!s?"password":"text",value:t,onChange:c=>r(c.target.value),placeholder:i,className:"w-full px-3 py-2 bg-[#0a0e17] border border-[#1e2a3a] rounded text-sm text-slate-200 font-mono focus:outline-none focus:border-accent placeholder-slate-600"}),u&&x.jsx("button",{type:"button",onClick:()=>l(!s),className:"absolute right-2 top-1/2 -translate-y-1/2 text-slate-500 hover:text-slate-300",children:s?x.jsx(yZ,{size:16}):x.jsx($E,{size:16})})]}),a&&x.jsx("p",{className:"text-xs text-slate-600",children:a})]})}function FU({label:e,value:t,onChange:r,min:n,max:i,step:a=1,helper:o="",info:s=""}){return x.jsxs("div",{className:"space-y-1",children:[x.jsxs("label",{className:"flex items-center text-xs text-slate-500 uppercase tracking-wide",children:[e,s&&x.jsx(No,{info:s})]}),x.jsx("input",{type:"number",value:t,onChange:l=>r(Number(l.target.value)),min:n,max:i,step:a,className:"w-full px-3 py-2 bg-[#0a0e17] border border-[#1e2a3a] rounded text-sm text-slate-200 font-mono focus:outline-none focus:border-accent"}),o&&x.jsx("p",{className:"text-xs text-slate-600",children:o})]})}function rS({label:e,checked:t,onChange:r,helper:n="",info:i=""}){return x.jsxs("div",{className:"flex items-center justify-between py-2",children:[x.jsxs("div",{children:[x.jsxs("span",{className:"flex items-center text-sm text-slate-300",children:[e,i&&x.jsx(No,{info:i})]}),n&&x.jsx("p",{className:"text-xs text-slate-600",children:n})]}),x.jsx("button",{type:"button",onClick:()=>r(!t),className:`relative w-11 h-6 rounded-full transition-colors ${t?"bg-accent":"bg-[#1e2a3a]"}`,children:x.jsx("span",{className:`absolute top-1 left-1 w-4 h-4 rounded-full bg-white transition-transform ${t?"translate-x-5":""}`})})]})}function nS({label:e,value:t,onChange:r,helper:n="",info:i=""}){return x.jsxs("div",{className:"space-y-1",children:[x.jsxs("label",{className:"flex items-center text-xs text-slate-500 uppercase tracking-wide",children:[e,i&&x.jsx(No,{info:i})]}),x.jsx("input",{type:"time",value:t,onChange:a=>r(a.target.value),className:"w-full px-3 py-2 bg-[#0a0e17] border border-[#1e2a3a] rounded text-sm text-slate-200 focus:outline-none focus:border-accent"}),n&&x.jsx("p",{className:"text-xs text-slate-600",children:n})]})}function eet({label:e,value:t,onChange:r,placeholder:n="Add item...",helper:i="",info:a=""}){const[o,s]=W.useState(""),l=()=>{o.trim()&&!t.includes(o.trim())&&(r([...t,o.trim()]),s(""))},u=c=>{r(t.filter((f,h)=>h!==c))};return x.jsxs("div",{className:"space-y-1",children:[x.jsxs("label",{className:"flex items-center text-xs text-slate-500 uppercase tracking-wide",children:[e,a&&x.jsx(No,{info:a})]}),x.jsxs("div",{className:"flex gap-2",children:[x.jsx("input",{type:"text",value:o,onChange:c=>s(c.target.value),onKeyDown:c=>c.key==="Enter"&&(c.preventDefault(),l()),className:"flex-1 px-3 py-2 bg-[#0a0e17] border border-[#1e2a3a] rounded text-sm text-slate-200 font-mono focus:outline-none focus:border-accent",placeholder:n}),x.jsx("button",{type:"button",onClick:l,className:"px-3 py-2 bg-accent hover:bg-accent/80 rounded text-sm text-white transition-colors",children:x.jsx(bS,{size:16})})]}),t.length>0&&x.jsx("div",{className:"flex flex-wrap gap-2 mt-2",children:t.map((c,f)=>x.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-1 bg-[#1e2a3a] rounded text-sm text-slate-300",children:[c,x.jsx("button",{type:"button",onClick:()=>u(f),className:"text-slate-500 hover:text-red-400",children:x.jsx(hv,{size:14})})]},f))}),i&&x.jsx("p",{className:"text-xs text-slate-600",children:i})]})}function tet({value:e,onChange:t}){const[r,n]=W.useState(!1),i=gb.find(a=>a.value===e)||gb[3];return x.jsxs("div",{className:"space-y-1",children:[x.jsxs("label",{className:"flex items-center text-xs text-slate-500 uppercase tracking-wide",children:["Severity Threshold",x.jsx(No,{info:"Only alerts at or above this severity trigger this rule. Lower threshold = more notifications. 'Warning' is recommended for most rules."})]}),x.jsxs("div",{className:"relative",children:[x.jsxs("button",{type:"button",onClick:()=>n(!r),className:"w-full px-3 py-2 bg-[#0a0e17] border border-[#1e2a3a] rounded text-sm text-left flex items-center justify-between hover:border-accent transition-colors",children:[x.jsxs("div",{children:[x.jsx("span",{className:"text-slate-200",children:i.label}),x.jsxs("span",{className:"text-slate-500 ml-2",children:["— ",i.description]})]}),x.jsx(Hy,{size:16,className:`text-slate-500 transition-transform ${r?"rotate-180":""}`})]}),r&&x.jsxs(x.Fragment,{children:[x.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>n(!1)}),x.jsx("div",{className:"absolute left-0 right-0 top-full mt-1 z-50 bg-[#0a0e17] border border-[#1e2a3a] rounded-lg shadow-xl overflow-hidden",children:gb.map(a=>x.jsxs("button",{type:"button",onClick:()=>{t(a.value),n(!1)},className:`w-full px-3 py-2.5 text-left text-sm hover:bg-[#1e2a3a] transition-colors ${e===a.value?"bg-accent/10":""}`,children:[x.jsx("div",{className:"font-medium text-slate-200",children:a.label}),x.jsx("div",{className:"text-xs text-slate-500",children:a.description})]},a.value))})]})]}),x.jsx("p",{className:"text-xs text-slate-600",children:'Lower = more notifications. "Warning" recommended for most rules.'})]})}function ret({rule:e,categories:t,quietHoursEnabled:r,onChange:n,onDelete:i,onDuplicate:a,onTest:o}){var S,T,A,M;const[s,l]=W.useState(!e.name),[u,c]=W.useState(!1),f=[{value:"",label:"(None)",description:"Rule matches but does not deliver"},{value:"mesh_broadcast",label:"Mesh Broadcast",description:"Send to a mesh radio channel"},{value:"mesh_dm",label:"Mesh DM",description:"Direct message to specific nodes"},{value:"email",label:"Email",description:"Send via SMTP"},{value:"webhook",label:"Webhook",description:"POST to any URL"}],h=[{value:"daily",label:"Daily"},{value:"twice_daily",label:"Twice Daily"},{value:"weekly",label:"Weekly"}],d=[{value:"mesh_health_summary",label:"Mesh Health Summary",description:"Current health score, pillar breakdown, problem nodes"},{value:"rf_propagation_report",label:"RF Propagation Report",description:"Solar indices, Kp, ducting conditions"},{value:"alerts_digest",label:"Active Alerts Digest",description:"Summary of all active environmental alerts"},{value:"environmental_conditions",label:"Environmental Conditions",description:"Full conditions: weather, fire, streams, roads"},{value:"custom",label:"Custom Message",description:"Write your own with template tokens"}],v=["monday","tuesday","wednesday","thursday","friday","saturday","sunday"],g=P=>{const k=e.categories||[];k.includes(P)?n({...e,categories:k.filter(I=>I!==P)}):n({...e,categories:[...k,P]})},m=P=>{const k=e.schedule_days||[];k.includes(P)?n({...e,schedule_days:k.filter(I=>I!==P)}):n({...e,schedule_days:[...k,P]})},y=async()=>{c(!0),await o(),c(!1)},_=()=>{if(e.trigger_type==="schedule")return"[Scheduled report preview would appear here]";const P=e.categories||[];if(P.length===0&&t.length>0)return t[0].example_message||"Alert notification";const k=t.find(I=>P.includes(I.id));return(k==null?void 0:k.example_message)||"Alert notification"},b=()=>{var k,I,O,D,N,B,$,F;const P=[];if(e.trigger_type==="schedule"){const G=((k=h.find(U=>U.value===e.schedule_frequency))==null?void 0:k.label)||e.schedule_frequency,z=((I=d.find(U=>U.value===e.message_type))==null?void 0:I.label)||e.message_type;P.push(`${G} at ${e.schedule_time||"??:??"}`),P.push(z)}else{const G=((O=e.categories)==null?void 0:O.length)||0,z=G===0?"All":t.filter(H=>{var Y;return(Y=e.categories)==null?void 0:Y.includes(H.id)}).map(H=>H.name).slice(0,2).join(", ")+(G>2?` +${G-2}`:""),U=((D=gb.find(H=>H.value===e.min_severity))==null?void 0:D.label)||e.min_severity;P.push(`${z} at ${U}+`)}if(!e.delivery_type)P.push("⚠️ No delivery");else{const G=((N=f.find(U=>U.value===e.delivery_type))==null?void 0:N.label)||e.delivery_type;let z="";if(e.delivery_type==="mesh_broadcast")z=`Ch ${e.broadcast_channel}`;else if(e.delivery_type==="mesh_dm")z=`${((B=e.node_ids)==null?void 0:B.length)||0} nodes`;else if(e.delivery_type==="email")z=($=e.recipients)!=null&&$.length?e.recipients[0]+(e.recipients.length>1?` +${e.recipients.length-1}`:""):"no recipients";else if(e.delivery_type==="webhook")try{z=new URL(e.webhook_url).hostname}catch{z=((F=e.webhook_url)==null?void 0:F.slice(0,20))||"no URL"}P.push(`${G}${z?` (${z})`:""}`)}return P.join(" → ")};return x.jsxs("div",{className:`border rounded-lg overflow-hidden ${e.enabled?"border-[#1e2a3a]":"border-slate-700 opacity-60"}`,children:[x.jsxs("div",{className:"flex items-center justify-between p-3 bg-[#0a0e17] cursor-pointer",onClick:()=>l(!s),children:[x.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[s?x.jsx(Hy,{size:16,className:"text-slate-500 flex-shrink-0"}):x.jsx(bm,{size:16,className:"text-slate-500 flex-shrink-0"}),x.jsx("button",{onClick:P=>{P.stopPropagation(),n({...e,enabled:!e.enabled})},className:`w-2 h-2 rounded-full flex-shrink-0 ${e.enabled?"bg-green-500":"bg-slate-500"}`,title:e.enabled?"Enabled":"Disabled"}),e.trigger_type==="schedule"?x.jsx(yd,{size:14,className:"text-blue-400 flex-shrink-0"}):x.jsx(Sm,{size:14,className:"text-yellow-400 flex-shrink-0"}),x.jsx("span",{className:"font-medium text-slate-200 truncate",children:e.name||"New Rule"}),!s&&x.jsx("span",{className:`text-xs truncate hidden sm:block ${e.delivery_type?"text-slate-500":"text-amber-400"}`,children:b()})]}),x.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[x.jsx("button",{onClick:P=>{P.stopPropagation(),y()},disabled:u||!e.name,className:"p-1.5 text-blue-400 hover:text-blue-300 hover:bg-blue-500/10 rounded disabled:opacity-50",title:"Test rule",children:x.jsx(o3,{size:14})}),x.jsx("button",{onClick:P=>{P.stopPropagation(),a()},className:"p-1.5 text-slate-400 hover:text-slate-200 hover:bg-slate-500/10 rounded",title:"Duplicate",children:x.jsx(que,{size:14})}),x.jsx("button",{onClick:P=>{P.stopPropagation(),i()},className:"p-1.5 text-red-400 hover:text-red-300 hover:bg-red-500/10 rounded",title:"Delete",children:x.jsx(UE,{size:14})})]})]}),s&&x.jsxs("div",{className:"p-4 space-y-6 border-t border-[#1e2a3a]",children:[x.jsx(mh,{label:"Rule Name",value:e.name,onChange:P=>n({...e,name:P}),placeholder:"e.g., Emergency Broadcast, Daily Health Report",helper:"A descriptive name for this rule"}),x.jsxs("div",{className:"space-y-2",children:[x.jsx("label",{className:"text-xs text-slate-500 uppercase tracking-wide",children:"Trigger Type"}),x.jsxs("div",{className:"flex gap-2",children:[x.jsxs("button",{type:"button",onClick:()=>n({...e,trigger_type:"condition"}),className:`flex-1 flex items-center justify-center gap-2 px-4 py-3 rounded-lg border transition-colors ${e.trigger_type!=="schedule"?"bg-accent/10 border-accent text-accent":"bg-[#0a0e17] border-[#1e2a3a] text-slate-400 hover:text-slate-200"}`,children:[x.jsx(Sm,{size:16}),x.jsx("span",{children:"Condition"})]}),x.jsxs("button",{type:"button",onClick:()=>n({...e,trigger_type:"schedule"}),className:`flex-1 flex items-center justify-center gap-2 px-4 py-3 rounded-lg border transition-colors ${e.trigger_type==="schedule"?"bg-accent/10 border-accent text-accent":"bg-[#0a0e17] border-[#1e2a3a] text-slate-400 hover:text-slate-200"}`,children:[x.jsx(yd,{size:16}),x.jsx("span",{children:"Schedule"})]})]}),x.jsx("p",{className:"text-xs text-slate-600",children:e.trigger_type==="schedule"?"Send reports on a schedule (daily briefings, weekly digests)":"React to alert conditions (fires, outages, weather warnings)"})]}),e.trigger_type!=="schedule"&&x.jsxs("div",{className:"space-y-4 p-4 bg-[#0a0e17] rounded-lg border border-[#1e2a3a]",children:[x.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium text-slate-300",children:[x.jsx(Ds,{size:14}),"WHEN (Condition)"]}),x.jsx(tet,{value:e.min_severity,onChange:P=>n({...e,min_severity:P})}),x.jsxs("div",{className:"space-y-2",children:[x.jsxs("label",{className:"flex items-center text-xs text-slate-500 uppercase tracking-wide",children:["Alert Categories",x.jsx(No,{info:"Select which types of alerts trigger this rule. Leave all unchecked to match ALL categories."})]}),x.jsx("div",{className:"text-xs text-slate-500 mb-2",children:(((S=e.categories)==null?void 0:S.length)||0)===0?"All categories (none selected)":`${(T=e.categories)==null?void 0:T.length} selected`}),x.jsx("div",{className:"max-h-48 overflow-y-auto border border-[#1e2a3a] rounded-lg p-2 space-y-1",children:t.map(P=>{var k,I;return x.jsxs("label",{onClick:()=>g(P.id),className:"flex items-start gap-2 p-2 rounded hover:bg-[#1e2a3a]/50 cursor-pointer",children:[x.jsx("div",{className:`w-4 h-4 mt-0.5 rounded border flex items-center justify-center flex-shrink-0 ${(k=e.categories)!=null&&k.includes(P.id)?"bg-accent border-accent":"border-slate-600"}`,children:((I=e.categories)==null?void 0:I.includes(P.id))&&x.jsx(md,{size:12,className:"text-white"})}),x.jsxs("div",{className:"flex-1 min-w-0",children:[x.jsx("div",{className:"text-sm text-slate-200",children:P.name}),x.jsx("div",{className:"text-xs text-slate-500",children:P.description})]})]},P.id)})})]})]}),e.trigger_type==="schedule"&&x.jsxs("div",{className:"space-y-4 p-4 bg-[#0a0e17] rounded-lg border border-[#1e2a3a]",children:[x.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium text-slate-300",children:[x.jsx(Hue,{size:14}),"WHEN (Schedule)"]}),x.jsxs("div",{className:"space-y-1",children:[x.jsx("label",{className:"text-xs text-slate-500 uppercase tracking-wide",children:"Frequency"}),x.jsx("select",{value:e.schedule_frequency||"daily",onChange:P=>n({...e,schedule_frequency:P.target.value}),className:"w-full px-3 py-2 bg-[#0a0e17] border border-[#1e2a3a] rounded text-sm text-slate-200 focus:outline-none focus:border-accent",children:h.map(P=>x.jsx("option",{value:P.value,children:P.label},P.value))})]}),x.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[x.jsx(nS,{label:"Time",value:e.schedule_time||"07:00",onChange:P=>n({...e,schedule_time:P})}),e.schedule_frequency==="twice_daily"&&x.jsx(nS,{label:"Second Time",value:e.schedule_time_2||"19:00",onChange:P=>n({...e,schedule_time_2:P})})]}),e.schedule_frequency==="weekly"&&x.jsxs("div",{className:"space-y-2",children:[x.jsx("label",{className:"text-xs text-slate-500 uppercase tracking-wide",children:"Days"}),x.jsx("div",{className:"flex flex-wrap gap-2",children:v.map(P=>{var k;return x.jsx("button",{type:"button",onClick:()=>m(P),className:`px-3 py-1.5 rounded text-sm capitalize transition-colors ${(k=e.schedule_days)!=null&&k.includes(P)?"bg-accent text-white":"bg-[#1e2a3a] text-slate-400 hover:text-slate-200"}`,children:P.slice(0,3)},P)})})]}),x.jsxs("div",{className:"space-y-1",children:[x.jsx("label",{className:"text-xs text-slate-500 uppercase tracking-wide",children:"Report Type"}),x.jsx("select",{value:e.message_type||"mesh_health_summary",onChange:P=>n({...e,message_type:P.target.value}),className:"w-full px-3 py-2 bg-[#0a0e17] border border-[#1e2a3a] rounded text-sm text-slate-200 focus:outline-none focus:border-accent",children:d.map(P=>x.jsx("option",{value:P.value,children:P.label},P.value))}),x.jsx("p",{className:"text-xs text-slate-600",children:(A=d.find(P=>P.value===e.message_type))==null?void 0:A.description})]}),e.message_type==="custom"&&x.jsxs("div",{className:"space-y-1",children:[x.jsxs("label",{className:"flex items-center text-xs text-slate-500 uppercase tracking-wide",children:["Custom Message",x.jsx(No,{info:"Available tokens: {MESH_SCORE}, {NODE_COUNT}, {NODES_ONLINE}, {ACTIVE_ALERTS}, {KP}, {SFI}, {DATE}, {TIME}"})]}),x.jsx("textarea",{value:e.custom_message||"",onChange:P=>n({...e,custom_message:P.target.value}),rows:4,placeholder:"Good morning! Mesh health: {MESH_SCORE}/100 with {NODE_COUNT} nodes online.",className:"w-full px-3 py-2 bg-[#0a0e17] border border-[#1e2a3a] rounded text-sm text-slate-200 font-mono focus:outline-none focus:border-accent placeholder-slate-600"})]})]}),x.jsxs("div",{className:"space-y-4 p-4 bg-[#0a0e17] rounded-lg border border-[#1e2a3a]",children:[x.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium text-slate-300",children:[x.jsx(o3,{size:14}),"SEND VIA"]}),x.jsxs("div",{className:"space-y-1",children:[x.jsxs("label",{className:"flex items-center text-xs text-slate-500 uppercase tracking-wide",children:["Delivery Method",x.jsx(No,{info:"Where this notification gets delivered. Select (None) to save the rule without delivery — it will match conditions but won't send until you configure a delivery method."})]}),x.jsx("select",{value:e.delivery_type||"",onChange:P=>n({...e,delivery_type:P.target.value}),className:"w-full px-3 py-2 bg-[#0a0e17] border border-[#1e2a3a] rounded text-sm text-slate-200 focus:outline-none focus:border-accent",children:f.map(P=>x.jsx("option",{value:P.value,children:P.label},P.value))}),x.jsx("p",{className:"text-xs text-slate-600",children:(M=f.find(P=>P.value===(e.delivery_type||"")))==null?void 0:M.description})]}),!e.delivery_type&&x.jsxs("div",{className:"flex items-start gap-2 p-3 bg-amber-500/10 border border-amber-500/20 rounded-lg",children:[x.jsx(Uy,{size:16,className:"text-amber-400 mt-0.5 flex-shrink-0"}),x.jsx("div",{className:"text-sm text-amber-300",children:"Rule will log matches but not deliver until a delivery method is configured."})]}),e.delivery_type==="mesh_broadcast"&&x.jsx(RR,{label:"Broadcast Channel",value:e.broadcast_channel??0,onChange:P=>n({...e,broadcast_channel:P}),helper:"Select the mesh radio channel",mode:"single"}),e.delivery_type==="mesh_dm"&&x.jsx(jR,{label:"Recipient Nodes",value:e.node_ids||[],onChange:P=>n({...e,node_ids:P}),helper:"Nodes that receive direct messages",valueType:"node_id_hex"}),e.delivery_type==="email"&&x.jsxs("div",{className:"space-y-4",children:[x.jsx(eet,{label:"Recipients",value:e.recipients||[],onChange:P=>n({...e,recipients:P}),placeholder:"email@example.com",helper:"Email addresses to receive alerts"}),x.jsxs("details",{className:"group",children:[x.jsxs("summary",{className:"flex items-center gap-2 cursor-pointer text-sm text-slate-400 hover:text-slate-200",children:[x.jsx(bm,{size:14,className:"group-open:rotate-90 transition-transform"}),"SMTP Configuration"]}),x.jsxs("div",{className:"mt-4 space-y-4 pl-6 border-l border-[#1e2a3a]",children:[x.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[x.jsx(mh,{label:"SMTP Host",value:e.smtp_host||"",onChange:P=>n({...e,smtp_host:P}),placeholder:"smtp.gmail.com"}),x.jsx(FU,{label:"SMTP Port",value:e.smtp_port??587,onChange:P=>n({...e,smtp_port:P}),min:1,max:65535})]}),x.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[x.jsx(mh,{label:"Username",value:e.smtp_user||"",onChange:P=>n({...e,smtp_user:P})}),x.jsx(mh,{label:"Password",value:e.smtp_password||"",onChange:P=>n({...e,smtp_password:P}),type:"password",info:"Gmail users: use an App Password from myaccount.google.com/apppasswords"})]}),x.jsx(rS,{label:"Use TLS",checked:e.smtp_tls??!0,onChange:P=>n({...e,smtp_tls:P})}),x.jsx(mh,{label:"From Address",value:e.from_address||"",onChange:P=>n({...e,from_address:P}),placeholder:"alerts@yourdomain.com"})]})]})]}),e.delivery_type==="webhook"&&x.jsx(mh,{label:"Webhook URL",value:e.webhook_url||"",onChange:P=>n({...e,webhook_url:P}),placeholder:"https://discord.com/api/webhooks/...",helper:"POST alert as JSON",info:"Works with Discord webhooks, ntfy.sh, Slack, Home Assistant, Pushover, or any HTTP POST endpoint."})]}),x.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[x.jsx(FU,{label:"Cooldown (minutes)",value:e.cooldown_minutes??10,onChange:P=>n({...e,cooldown_minutes:P}),min:0,helper:"Min time between repeat sends",info:"Prevents alert spam. Same condition won't re-trigger this rule within this window."}),r&&x.jsx("div",{className:"flex items-end pb-1",children:x.jsx(rS,{label:"Override Quiet Hours",checked:e.override_quiet??!1,onChange:P=>n({...e,override_quiet:P}),helper:"Deliver during quiet hours"})})]}),e.trigger_type!=="schedule"&&x.jsxs("div",{className:"space-y-2",children:[x.jsx("label",{className:"text-xs text-slate-500 uppercase tracking-wide",children:"Example Message"}),x.jsx("div",{className:"p-3 bg-[#1e2a3a]/50 rounded-lg border border-[#1e2a3a]",children:x.jsx("p",{className:"text-sm text-slate-300 font-mono",children:_()})}),x.jsx("p",{className:"text-xs text-slate-600",children:"This is an example of what this rule would send."})]})]})]})}function net(){var D,N;const[e,t]=W.useState(null),[r,n]=W.useState(null),[i,a]=W.useState([]),[o,s]=W.useState(!0),[l,u]=W.useState(!1),[c,f]=W.useState(null),[h,d]=W.useState(null),[v,g]=W.useState(null),[m,y]=W.useState(!1),[_,b]=W.useState(!1),S=W.useCallback(async()=>{try{const[B,$]=await Promise.all([fetch("/api/config/notifications"),fetch("/api/notifications/categories")]);if(!B.ok)throw new Error("Failed to fetch notifications config");const F=await B.json(),G=await $.json();t(F),n(JSON.parse(JSON.stringify(F))),a(G),b(!1),f(null)}catch(B){f(B instanceof Error?B.message:"Unknown error")}finally{s(!1)}},[]);W.useEffect(()=>{document.title="Notifications — MeshAI",S()},[S]),W.useEffect(()=>{e&&r&&b(JSON.stringify(e)!==JSON.stringify(r))},[e,r]);const T=async()=>{if(e){u(!0),f(null),d(null);try{const B=await fetch("/api/config/notifications",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),$=await B.json();if(!B.ok)throw new Error($.detail||"Save failed");d("Notifications config saved successfully"),n(JSON.parse(JSON.stringify(e))),b(!1),setTimeout(()=>d(null),3e3)}catch(B){f(B instanceof Error?B.message:"Save failed")}finally{u(!1)}}},A=()=>{r&&(t(JSON.parse(JSON.stringify(r))),b(!1))},M=()=>({name:"",enabled:!0,trigger_type:"condition",categories:[],min_severity:"warning",schedule_frequency:"daily",schedule_time:"07:00",schedule_time_2:"19:00",schedule_days:["monday"],message_type:"mesh_health_summary",custom_message:"",delivery_type:"",broadcast_channel:0,node_ids:[],smtp_host:"",smtp_port:587,smtp_user:"",smtp_password:"",smtp_tls:!0,from_address:"",recipients:[],webhook_url:"",webhook_headers:{},cooldown_minutes:10,override_quiet:!1}),P=()=>{e&&t({...e,rules:[...e.rules||[],M()]})},k=B=>{if(!e)return;const $=$U.find(F=>F.id===B);$&&(t({...e,rules:[...e.rules||[],{...$.rule}]}),y(!1))},I=B=>{if(!e)return;const $=e.rules[B],F={...JSON.parse(JSON.stringify($)),name:`${$.name} (copy)`},G=[...e.rules];G.splice(B+1,0,F),t({...e,rules:G})},O=async B=>{try{const F=await(await fetch(`/api/notifications/rules/${B}/test`,{method:"POST"})).json();g(F),setTimeout(()=>g(null),5e3)}catch{g({success:!1,message:"Test failed"}),setTimeout(()=>g(null),5e3)}};return o?x.jsx("div",{className:"flex items-center justify-center h-64",children:x.jsx("div",{className:"text-slate-400",children:"Loading notifications config..."})}):e?x.jsxs("div",{className:"max-w-4xl mx-auto space-y-6",children:[x.jsxs("div",{className:"flex items-center justify-between",children:[x.jsx("div",{children:x.jsx("p",{className:"text-sm text-slate-500",children:"Alert delivery and scheduled reports. Rules define what triggers a notification and where it gets sent."})}),x.jsxs("div",{className:"flex items-center gap-2",children:[x.jsx("button",{onClick:S,className:"p-2 text-slate-400 hover:text-slate-200 hover:bg-bg-hover rounded transition-colors",title:"Refresh",children:x.jsx(wZ,{size:18})}),x.jsxs("button",{onClick:A,disabled:!_,className:"flex items-center gap-2 px-3 py-2 text-slate-400 hover:text-slate-200 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:[x.jsx(SZ,{size:16}),"Discard"]}),x.jsxs("button",{onClick:T,disabled:l||!_,className:"flex items-center gap-2 px-4 py-2 bg-accent hover:bg-accent/80 disabled:bg-slate-700 disabled:cursor-not-allowed rounded text-white transition-colors",children:[x.jsx(TZ,{size:16}),l?"Saving...":"Save"]})]})]}),c&&x.jsx("div",{className:"p-3 rounded-lg text-sm bg-red-500/10 text-red-400 border border-red-500/20",children:c}),h&&x.jsxs("div",{className:"p-3 rounded-lg text-sm bg-green-500/10 text-green-400 border border-green-500/20",children:[x.jsx(md,{size:14,className:"inline mr-2"}),h]}),v&&x.jsxs("div",{className:`p-3 rounded-lg text-sm ${v.success?"bg-green-500/10 text-green-400 border border-green-500/20":"bg-red-500/10 text-red-400 border border-red-500/20"}`,children:[v.success?x.jsx(md,{size:14,className:"inline mr-2"}):x.jsx(hv,{size:14,className:"inline mr-2"}),v.message]}),x.jsxs("div",{className:"bg-bg-card border border-border rounded-lg p-6 space-y-6",children:[x.jsx(rS,{label:"Enable Notifications",checked:e.enabled,onChange:B=>t({...e,enabled:B}),helper:"Master switch for all notification delivery",info:"When disabled, no alerts or scheduled messages will be delivered. Alerts still get recorded to history."}),e.enabled&&x.jsxs(x.Fragment,{children:[x.jsxs("div",{className:"space-y-3 p-4 bg-[#0a0e17] rounded-lg border border-[#1e2a3a]",children:[x.jsxs("div",{className:"flex items-center gap-2",children:[x.jsx(ece,{size:14,className:"text-slate-400"}),x.jsx("label",{className:"text-xs text-slate-500 uppercase tracking-wide",children:"Quiet Hours"})]}),x.jsx(rS,{label:"Enable Quiet Hours",checked:e.quiet_hours_enabled??!0,onChange:B=>t({...e,quiet_hours_enabled:B}),helper:"Suppress non-emergency alerts during sleeping hours",info:"When enabled, alerts below emergency severity are held during quiet hours. When disabled, all alerts deliver anytime."}),e.quiet_hours_enabled&&x.jsxs(x.Fragment,{children:[x.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[x.jsx(nS,{label:"Start Time",value:e.quiet_hours_start||"22:00",onChange:B=>t({...e,quiet_hours_start:B}),helper:"When quiet hours begin"}),x.jsx(nS,{label:"End Time",value:e.quiet_hours_end||"06:00",onChange:B=>t({...e,quiet_hours_end:B}),helper:"When quiet hours end"})]}),x.jsx("p",{className:"text-xs text-slate-600",children:'Emergency alerts and rules with "Override Quiet Hours" enabled always deliver.'})]})]}),x.jsxs("div",{className:"space-y-3",children:[x.jsxs("div",{className:"flex items-center justify-between",children:[x.jsxs("label",{className:"flex items-center text-xs text-slate-500 uppercase tracking-wide",children:["Notification Rules",x.jsx(No,{info:"Each rule is self-contained: define what triggers it (condition or schedule), where to send it (mesh, email, webhook), and behavior settings."})]}),x.jsxs("span",{className:"text-xs text-slate-500",children:[((D=e.rules)==null?void 0:D.length)||0," rule",(((N=e.rules)==null?void 0:N.length)||0)!==1?"s":""]})]}),(e.rules||[]).map((B,$)=>x.jsx(ret,{rule:B,categories:i,quietHoursEnabled:e.quiet_hours_enabled??!0,onChange:F=>{const G=[...e.rules||[]];G[$]=F,t({...e,rules:G})},onDelete:()=>{confirm(`Delete rule "${B.name||"New Rule"}"?`)&&t({...e,rules:(e.rules||[]).filter((F,G)=>G!==$)})},onDuplicate:()=>I($),onTest:()=>O($)},$)),x.jsxs("div",{className:"flex gap-2",children:[x.jsxs("button",{onClick:P,className:"flex-1 py-3 border border-dashed border-[#1e2a3a] rounded-lg text-slate-500 hover:text-slate-300 hover:border-accent flex items-center justify-center gap-2 transition-colors",children:[x.jsx(bS,{size:16})," Add Rule"]}),x.jsxs("div",{className:"relative",children:[x.jsxs("button",{onClick:()=>y(!m),className:"py-3 px-4 border border-dashed border-[#1e2a3a] rounded-lg text-slate-500 hover:text-slate-300 hover:border-accent flex items-center gap-2 transition-colors",children:[x.jsx(xZ,{size:16})," Add from Template"]}),m&&x.jsxs(x.Fragment,{children:[x.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>y(!1)}),x.jsxs("div",{className:"absolute right-0 top-full mt-2 z-50 w-80 bg-[#1a2332] border border-[#2a3a4a] rounded-lg shadow-xl overflow-hidden",children:[x.jsx("div",{className:"p-2 border-b border-[#2a3a4a] text-xs text-slate-500 uppercase",children:"Rule Templates"}),$U.map(B=>x.jsxs("button",{onClick:()=>k(B.id),className:"w-full p-3 text-left hover:bg-[#2a3a4a] transition-colors",children:[x.jsx("div",{className:"font-medium text-slate-200",children:B.name}),x.jsx("div",{className:"text-xs text-slate-500 mt-0.5",children:B.description})]},B.id))]})]})]})]})]})]})]})]}):x.jsx("div",{className:"flex items-center justify-center h-64",children:x.jsx("div",{className:"text-red-400",children:"Failed to load notifications config"})})}const VU=[{id:"stream-gauges",label:"Stream Gauges",icon:zE},{id:"wildfire",label:"Wildfire",icon:VE},{id:"firms",label:"Satellite Fire Detection (FIRMS)",icon:WE},{id:"weather-alerts",label:"Weather Alerts",icon:Yue},{id:"solar",label:"Solar & Geomagnetic",icon:Vb},{id:"ducting",label:"Tropospheric Ducting",icon:tu},{id:"avalanche",label:"Avalanche Danger",icon:GE},{id:"traffic",label:"Traffic Flow",icon:BE},{id:"roads-511",label:"Road Conditions (511)",icon:gZ},{id:"mesh-health",label:"Mesh Health",icon:Wy},{id:"notifications",label:"Notifications",icon:_m},{id:"commands",label:"Commands",icon:CZ},{id:"api",label:"API Reference",icon:Xue}];function ar({color:e}){const t={green:"bg-green-500",yellow:"bg-yellow-500",orange:"bg-orange-500",red:"bg-red-500",black:"bg-slate-800 border border-slate-600"};return x.jsx("span",{className:`inline-block w-3 h-3 rounded-full ${t[e]}`})}function Rt({headers:e,rows:t}){return x.jsx("div",{className:"overflow-x-auto my-4",children:x.jsxs("table",{className:"w-full text-sm",children:[x.jsx("thead",{children:x.jsx("tr",{className:"bg-[#1a2332] border-b border-[#2a3a4a]",children:e.map((r,n)=>x.jsx("th",{className:"px-4 py-2 text-left text-slate-400 font-medium",children:r},n))})}),x.jsx("tbody",{children:t.map((r,n)=>x.jsx("tr",{className:`border-b border-[#1e2a3a] ${n%2===0?"bg-[#0d1219]":"bg-[#0a0e17]"}`,children:r.map((i,a)=>x.jsx("td",{className:"px-4 py-2 text-slate-300",children:i},a))},n))})]})})}function Bt({href:e,children:t}){return x.jsxs("a",{href:e,target:"_blank",rel:"noopener noreferrer",className:"text-accent hover:underline inline-flex items-center gap-1",children:[t," ",x.jsx(xd,{size:12})]})}function Te({children:e}){return x.jsx("h3",{className:"text-lg font-semibold text-slate-200 mt-6 mb-3",children:e})}function cl({children:e}){return x.jsx("h4",{className:"text-base font-medium text-slate-300 mt-4 mb-2",children:e})}function Ve({children:e}){return x.jsx("code",{className:"font-mono text-accent bg-[#1a2332] px-1 rounded",children:e})}function pi({id:e,title:t,children:r}){return x.jsxs("section",{id:e,className:"mb-12 scroll-mt-6",children:[x.jsx("h2",{className:"text-2xl font-bold text-slate-100 mb-4 pb-2 border-b border-[#2a3a4a]",children:t}),x.jsx("div",{className:"text-slate-300 leading-relaxed space-y-4",children:r})]})}function iet(){const e=fv(),[t,r]=W.useState(""),[n,i]=W.useState("stream-gauges"),a=W.useRef(null);W.useEffect(()=>{const l=e.hash.replace("#","");if(l&&VU.find(u=>u.id===l)){i(l);const u=document.getElementById(l);u&&u.scrollIntoView({behavior:"smooth"})}},[e.hash]);const o=VU.filter(l=>l.label.toLowerCase().includes(t.toLowerCase())),s=l=>{i(l);const u=document.getElementById(l);u&&u.scrollIntoView({behavior:"smooth"}),window.history.replaceState(null,"",`#${l}`)};return x.jsxs("div",{className:"flex h-full -m-6",children:[x.jsxs("aside",{className:"w-64 flex-shrink-0 bg-bg-card border-r border-border overflow-y-auto",children:[x.jsx("div",{className:"p-4 border-b border-border",children:x.jsxs("div",{className:"relative",children:[x.jsx(HE,{size:16,className:"absolute left-3 top-1/2 -translate-y-1/2 text-slate-500"}),x.jsx("input",{type:"text",value:t,onChange:l=>r(l.target.value),placeholder:"Search topics...",className:"w-full pl-9 pr-3 py-2 bg-[#0a0e17] border border-[#1e2a3a] rounded text-sm text-slate-200 focus:outline-none focus:border-accent placeholder-slate-600"})]})}),x.jsx("nav",{className:"py-2",children:o.map(l=>{const u=l.icon,c=n===l.id;return x.jsxs("button",{onClick:()=>s(l.id),className:`w-full flex items-center gap-3 px-4 py-2.5 text-sm text-left transition-colors ${c?"text-accent bg-accent/10 border-l-2 border-accent":"text-slate-400 hover:text-slate-200 hover:bg-bg-hover border-l-2 border-transparent"}`,children:[x.jsx(u,{size:16}),l.label]},l.id)})})]}),x.jsx("div",{ref:a,className:"flex-1 overflow-y-auto p-6",children:x.jsxs("div",{className:"max-w-4xl",children:[x.jsx("p",{className:"text-slate-400 mb-8",children:"Everything you need to understand and configure MeshAI's monitoring and alerting systems."}),x.jsxs(pi,{id:"stream-gauges",title:"Stream Gauges",children:[x.jsx(Te,{children:"What You're Looking At"}),x.jsx("p",{children:"MeshAI watches river and stream levels at gauges you configure. Each gauge reports two things:"}),x.jsxs("p",{children:[x.jsx("strong",{children:"Water Level (Gage Height)"}),` — how high the water is, measured in feet. Important: this is NOT the depth of the river. It's the height above a fixed measuring point that's different at every gauge. A reading of "10 feet" at one gauge means something completely different than "10 feet" at another. You can only compare readings from the SAME gauge over time.`]}),x.jsxs("p",{children:[x.jsx("strong",{children:"Flow (Discharge)"}),` — how much water is moving past the gauge, in cubic feet per second (CFS). Think of it as the river's "throughput." For scale:`]}),x.jsxs("ul",{className:"list-disc list-inside ml-4 space-y-1",children:[x.jsx("li",{children:"A small creek: 50-200 CFS"}),x.jsx("li",{children:"A mid-size river: 1,000-5,000 CFS"}),x.jsx("li",{children:"A big river in spring runoff: 10,000+ CFS"})]}),x.jsx(Te,{children:"When Does It Flood?"}),x.jsxs("p",{children:["Flood levels are set by the ",x.jsx("strong",{children:"National Weather Service"}),', not USGS. NWS looks at each specific gauge location and decides "at what water level does the road flood? At what level do buildings get water?" Those levels are different everywhere.']}),x.jsxs("p",{children:[x.jsx("strong",{children:"Action Stage"})," — water is rising, time to start paying attention. Usually still inside the riverbanks."]}),x.jsxs("p",{children:[x.jsx("strong",{children:"Minor Flood"})," — low-lying roads start getting water on them. NWS issues a Flood Advisory."]}),x.jsxs("p",{children:[x.jsx("strong",{children:"Moderate Flood"})," — water in buildings near the river. Some people need to evacuate. NWS issues a Flood Warning."]}),x.jsxs("p",{children:[x.jsx("strong",{children:"Major Flood"})," — widespread flooding. Many people evacuating. Serious property damage."]}),x.jsx("p",{children:"MeshAI automatically looks up the flood levels for your gauge from NWS when you add a site. Some remote gauges don't have flood levels assigned — for those, you set them manually if you know what water levels cause problems in your area."}),x.jsx(Te,{children:"Low Water / Drought"}),x.jsx("p",{children:`There's no official "drought stage" for most gauges. If you need to monitor low water (irrigation, fish habitat), set a manual low-water threshold based on what you know about your local river.`}),x.jsx(Te,{children:"Setting It Up"}),x.jsxs("ol",{className:"list-decimal list-inside ml-4 space-y-1",children:[x.jsxs("li",{children:["Find your gauge at ",x.jsx(Bt,{href:"https://waterdata.usgs.gov/nwis",children:"waterdata.usgs.gov/nwis"})]}),x.jsxs("li",{children:["Copy the site number (like ",x.jsx(Ve,{children:"13090500"}),")"]}),x.jsx("li",{children:"Add it in Config → Environmental → USGS"}),x.jsx("li",{children:"MeshAI auto-fills the gauge name and flood levels from NWS"})]}),x.jsx("p",{children:"If NWS flood levels don't populate, your gauge may not have them. Set manual thresholds if you know your local conditions."}),x.jsx(Te,{children:"Learn More"}),x.jsxs("ul",{className:"list-disc list-inside ml-4 space-y-1",children:[x.jsxs("li",{children:[x.jsx(Bt,{href:"https://waterdata.usgs.gov/nwis",children:"USGS Water Data"})," — find gauges near you"]}),x.jsxs("li",{children:[x.jsx(Bt,{href:"https://water.noaa.gov",children:"NWS Water Prediction Service"})," — flood forecasts and thresholds"]}),x.jsxs("li",{children:[x.jsx(Bt,{href:"https://www.usgs.gov/special-topics/water-science-school/science/how-streamflow-measured",children:"Understanding Streamflow"})," — USGS explainer"]})]})]}),x.jsxs(pi,{id:"wildfire",title:"Wildfire",children:[x.jsx(Te,{children:"What You're Looking At"}),x.jsx("p",{children:"MeshAI tracks active wildfire perimeters from the National Interagency Fire Center (NIFC). For each fire, you see the name, size, how much is contained, and how far it is from your mesh nodes."}),x.jsx(Te,{children:"Fire Size — How Big Is It?"}),x.jsx(Rt,{headers:["Size","What That Means"],rows:[["10 acres","Small fire. Usually handled quickly by initial crews."],["100 acres","Notable fire. Active firefighting effort."],["1,000 acres","Large fire. Major resources being deployed."],["10,000+ acres","Very large fire. Multiple teams, aircraft, heavy equipment."],["100,000+ acres","Mega-fire. These make the national news."]]}),x.jsx("p",{children:"For reference, 1,000 acres is about 1.5 square miles."}),x.jsx(Te,{children:"Containment — Is It Under Control?"}),x.jsx("p",{children:"Containment means the percentage of the fire's edge where firefighters have built a control line (a cleared strip to stop the fire from spreading further). It does NOT mean the fire is out inside that line."}),x.jsxs("ul",{className:"list-disc list-inside ml-4 space-y-1",children:[x.jsxs("li",{children:[x.jsx("strong",{children:"0-30%"})," — Essentially uncontrolled. The fire goes where it wants."]}),x.jsxs("li",{children:[x.jsx("strong",{children:"50%"})," — Good progress, but half the edge can still grow."]}),x.jsxs("li",{children:[x.jsx("strong",{children:"80%+"})," — Well controlled. Major growth unlikely."]}),x.jsxs("li",{children:[x.jsx("strong",{children:"100%"}),' — The edge is fully controlled. But the fire may STILL be actively burning inside. "100% contained" does NOT mean "out."']})]}),x.jsx(Te,{children:"How Far Away Should I Worry?"}),x.jsx(Rt,{headers:["Distance","What To Do"],rows:[[x.jsxs(x.Fragment,{children:[x.jsx(ar,{color:"red"})," Under 5 km (3 miles)"]}),x.jsxs(x.Fragment,{children:[x.jsx("strong",{children:"Immediate threat."})," This is evacuation-order range. Embers can fly this far in wind."]})],[x.jsxs(x.Fragment,{children:[x.jsx(ar,{color:"orange"})," 5-15 km (3-10 miles)"]}),x.jsxs(x.Fragment,{children:[x.jsx("strong",{children:"Prepare."})," The fire could reach you in hours under bad conditions. Have a plan."]})],[x.jsxs(x.Fragment,{children:[x.jsx(ar,{color:"yellow"})," 15-30 km (10-20 miles)"]}),x.jsxs(x.Fragment,{children:[x.jsx("strong",{children:"Watch."})," Smoke is likely. Wind shifts could change things fast."]})],[x.jsxs(x.Fragment,{children:[x.jsx(ar,{color:"green"})," Over 30 km (20 miles)"]}),x.jsxs(x.Fragment,{children:[x.jsx("strong",{children:"Awareness."})," Keep an eye on it, but no immediate threat."]})]]}),x.jsx("p",{children:"How fast can a fire travel? In grass with wind: up to 14 mph. In heavy timber: 1-6 mph. A fire 10 miles away could theoretically reach you in 1-2 hours under worst-case conditions, but typical spread is much slower."}),x.jsx(Te,{children:"Which Matters More — Size or Distance?"}),x.jsxs("p",{children:[x.jsx("strong",{children:"Distance is the immediate concern."})," A small uncontained fire 10 km away is more dangerous right now than a huge fire 50 km away. But big fires have more energy and can grow fast under wind shifts — keep watching them."]}),x.jsx(Te,{children:"Setting It Up"}),x.jsxs("p",{children:["Just configure your state code (like ",x.jsx(Ve,{children:"US-ID"})," for Idaho) in Config → Environmental → Fires. MeshAI polls NIFC every 10 minutes for active fires in that state and computes the distance to your mesh nodes automatically."]}),x.jsx(Te,{children:"Learn More"}),x.jsxs("ul",{className:"list-disc list-inside ml-4 space-y-1",children:[x.jsxs("li",{children:[x.jsx(Bt,{href:"https://inciweb.nwcg.gov",children:"InciWeb"})," — detailed incident information"]}),x.jsxs("li",{children:[x.jsx(Bt,{href:"https://data-nifc.opendata.arcgis.com",children:"NIFC Fire Map"})," — raw perimeter data"]}),x.jsxs("li",{children:[x.jsx(Bt,{href:"https://www.ready.gov/wildfires",children:"Ready.gov Wildfires"})," — preparedness guide"]})]})]}),x.jsxs(pi,{id:"firms",title:"Satellite Fire Detection (FIRMS)",children:[x.jsx(Te,{children:"What You're Looking At"}),x.jsx("p",{children:`NASA's VIIRS satellites orbit the Earth and look for heat signatures on the ground. When they see something hot — a fire, a factory, a sunlit building — they flag it as a "hotspot." MeshAI checks these detections for your area.`}),x.jsxs("p",{children:[x.jsx("strong",{children:"Why this matters"}),": satellite hotspots show up ",x.jsx("strong",{children:"hours before"})," official fire perimeters are mapped. If a new fire starts near your mesh, the satellite might see it before anyone on the ground reports it."]}),x.jsx(Te,{children:"Confidence — Is It Really a Fire?"}),x.jsx("p",{children:"Each detection gets a confidence rating:"}),x.jsx(Rt,{headers:["Confidence","What It Means"],rows:[["High","Almost certainly a real fire. Strong heat signature."],["Nominal","Probably a real fire. Most actual fires get this rating."],["Low","Maybe a fire, maybe not. Could be a hot roof, sun reflecting off water, a factory, or a gas flare. Lots of false alarms."]]}),x.jsxs("p",{children:[x.jsx("strong",{children:"Recommendation"}),`: Set the filter to "Nominal + High." If you include "Low" you'll get alerts for every hot parking lot on a summer day.`]}),x.jsx(Te,{children:"FRP — How Intense Is It?"}),x.jsx("p",{children:'FRP (Fire Radiative Power) measures the heat output in megawatts. Think of it as "how hot is this thing":'}),x.jsx(Rt,{headers:["FRP","What It Probably Is"],rows:[["Under 5 MW","Hot surface, small agricultural burn, gas flare, or warm ground"],["5-50 MW","An actual fire — brush fire, grass fire, typical wildfire"],["50-300 MW","Intense fire — trees fully burning, active fire front"],["Over 300 MW","Extreme fire — major wildfire in full force"]]}),x.jsx("p",{children:"Setting the minimum FRP to 5 MW filters out most industrial and agricultural false alarms."}),x.jsx(Te,{children:"New Ignition Detection"}),x.jsxs("p",{children:["MeshAI cross-references satellite hotspots against known NIFC fire perimeters. If a hotspot is NOT near any known fire, it gets flagged as a ",x.jsx("strong",{children:"potential new ignition"})," — maybe a new fire just started. These get elevated priority regardless of confidence level."]}),x.jsx(Te,{children:"Timing"}),x.jsxs("p",{children:["Satellite data arrives ",x.jsx("strong",{children:"1-3 hours"})," after the satellite passes overhead. Each location gets observed about ",x.jsx("strong",{children:"6 times per day"}),` across all satellites, so there are multi-hour gaps. This is not real-time — it's "pretty recent."`]}),x.jsx(Te,{children:"Getting an API Key"}),x.jsxs("ol",{className:"list-decimal list-inside ml-4 space-y-1",children:[x.jsxs("li",{children:["Go to ",x.jsx(Bt,{href:"https://firms.modaps.eosdis.nasa.gov/api/area/",children:"FIRMS API page"})]}),x.jsx("li",{children:'Click "Get MAP_KEY"'}),x.jsx("li",{children:"Register for a free Earthdata account"}),x.jsx("li",{children:"Your key arrives by email"}),x.jsx("li",{children:"Enter it in Config → Environmental → FIRMS"})]}),x.jsx(Te,{children:"Learn More"}),x.jsxs("ul",{className:"list-disc list-inside ml-4 space-y-1",children:[x.jsxs("li",{children:[x.jsx(Bt,{href:"https://firms.modaps.eosdis.nasa.gov",children:"FIRMS Fire Map"})," — see hotspots on a map"]}),x.jsxs("li",{children:[x.jsx(Bt,{href:"https://earthdata.nasa.gov/data/tools/firms/faq",children:"FIRMS FAQ"})," — how it works"]})]})]}),x.jsxs(pi,{id:"weather-alerts",title:"Weather Alerts",children:[x.jsx(Te,{children:"What You're Looking At"}),x.jsx("p",{children:"MeshAI watches for NWS (National Weather Service) alerts affecting your area — warnings, watches, and advisories."}),x.jsx(Te,{children:"Alert Severity — How Serious Is It?"}),x.jsx(Rt,{headers:["Severity","What It Means","Example"],rows:[["Extreme","Life-threatening. The most serious events.","Tornado Emergency, Hurricane Warning, Tsunami Warning"],["Severe","Dangerous. Take protective action.","Tornado Warning, Flash Flood Warning, Blizzard Warning, Red Flag Warning"],["Moderate","Be prepared. Could become dangerous.","Winter Weather Advisory, Wind Advisory, Flood Watch, Heat Advisory"],["Minor","Good to know. Probably won't hurt anyone.","Special Weather Statement, Air Quality Alert"]]}),x.jsx(Te,{children:"When Should I Act? (Urgency)"}),x.jsx(Rt,{headers:["Urgency","What It Means"],rows:[["Immediate","Do something NOW"],["Expected","Do something within the hour"],["Future","Coming in the next several hours"],["Past","It's over — NWS is clearing the alert"]]}),x.jsx(Te,{children:"How Sure Are They? (Certainty)"}),x.jsx(Rt,{headers:["Certainty","What It Means"],rows:[["Observed","It's happening right now. Verified."],["Likely","More than 50% chance"],["Possible","Could happen, but less than 50%"],["Unlikely","Probably won't, but mentioned for awareness"]]}),x.jsx(Te,{children:"These Are Separate Scales"}),x.jsx("p",{children:'A single alert has all three. A hurricane warning for next week is "Severe + Future + Likely." A tornado spotted on the ground is "Extreme + Immediate + Observed." An air quality advisory is "Minor + Expected + Possible."'}),x.jsx(Te,{children:"What Minimum Severity Should I Set?"}),x.jsx(Rt,{headers:["Setting","What You Get","What You Miss"],rows:[["Minor","Everything — high volume","Nothing"],[x.jsxs(x.Fragment,{children:[x.jsx("strong",{children:"Moderate"})," ✓"]}),"Watches, Advisories, and Warnings","Special Weather Statements"],["Severe","Only Warnings — things happening NOW","Watches (which give you hours of advance warning)"],["Extreme","Only the rarest events","Most Tornado and Severe Thunderstorm Warnings"]]}),x.jsxs("p",{children:[x.jsx("strong",{children:"Moderate is recommended."})," It catches Watches (advance warning that conditions may worsen) and Advisories (conditions exist but aren't severe) while filtering out the informational stuff."]}),x.jsx(Te,{children:"Finding Your NWS Zone"}),x.jsxs("ol",{className:"list-decimal list-inside ml-4 space-y-1",children:[x.jsxs("li",{children:["Go to ",x.jsx(Bt,{href:"https://www.weather.gov",children:"weather.gov"})]}),x.jsx("li",{children:"Enter your location"}),x.jsxs("li",{children:["Find your zone code at ",x.jsx(Bt,{href:"https://www.weather.gov/pimar/PubZone",children:"NWS Zone Map"})]}),x.jsxs("li",{children:["Zone codes look like: ",x.jsx(Ve,{children:"IDZ016"}),", ",x.jsx(Ve,{children:"UTZ040"}),", etc."]})]}),x.jsx(Te,{children:"The User-Agent Field"}),x.jsx("p",{children:"NWS wants to know who's using their API — not for approval, just so they can contact you if something breaks. You make it up:"}),x.jsx("p",{children:x.jsx(Ve,{children:"(meshai, you@email.com)"})}),x.jsx("p",{children:"No registration. No waiting. Just type it in."}),x.jsx(Te,{children:"Learn More"}),x.jsxs("ul",{className:"list-disc list-inside ml-4 space-y-1",children:[x.jsxs("li",{children:[x.jsx(Bt,{href:"https://alerts.weather.gov",children:"NWS Active Alerts"})," — see current alerts"]}),x.jsxs("li",{children:[x.jsx(Bt,{href:"https://www.weather.gov/documentation/services-web-api",children:"NWS API Docs"})," — technical details"]})]})]}),x.jsxs(pi,{id:"solar",title:"Solar & Geomagnetic Conditions",children:[x.jsx(Te,{children:"What You're Looking At"}),x.jsx("p",{children:"MeshAI tracks space weather — solar activity and its effects on Earth's magnetic field. This matters for radio operators because the sun directly controls how well HF radio works, and major solar events can affect all radio communications."}),x.jsx(Te,{children:"Solar Flux Index (SFI)"}),x.jsx("p",{children:'Think of SFI as a "how active is the sun" number. Higher = better for HF radio, but also higher risk of solar flares.'}),x.jsx(Rt,{headers:["SFI","What It Means for You"],rows:[["Below 70","Quiet sun. Higher HF bands (10m, 15m) are probably dead. Stick to lower bands."],["70-90","Getting better. Some openings on 15m and above, but inconsistent."],["90-120","Good. Most HF bands work. Reliable contacts on 20m and 15m."],["120-170","Great. All HF bands open. 10m works for worldwide contacts."],["Above 170","Excellent. Best HF conditions — but watch for flares."]]}),x.jsxs("p",{children:[x.jsx("strong",{children:"Quick rule"}),": SFI above 90 and Kp below 4 = good day for HF radio."]}),x.jsx(Te,{children:"Kp Index"}),x.jsx("p",{children:"Kp measures how disturbed Earth's magnetic field is, on a 0-9 scale. Higher = more disturbance = worse for HF radio but better for aurora viewing."}),x.jsx(Rt,{headers:["Kp","What It Means for You"],rows:[["0-2","Quiet. Best HF conditions."],["3","Slightly unsettled. You probably won't notice."],["4","Active. Some noise and fading on HF, especially if you're at higher latitudes."],[x.jsx("strong",{children:"5"}),x.jsxs(x.Fragment,{children:[x.jsx("strong",{children:"Minor storm (G1)."})," HF noticeably degraded. Aurora visible at high latitudes (~60°N)."]})],[x.jsx("strong",{children:"6"}),x.jsxs(x.Fragment,{children:[x.jsx("strong",{children:"Moderate storm (G2)."})," HF getting rough. Aurora moving south (~55°N)."]})],[x.jsx("strong",{children:"7"}),x.jsxs(x.Fragment,{children:[x.jsx("strong",{children:"Strong storm (G3)."})," HF unreliable for 1-2 days. Aurora at mid-latitudes."]})],[x.jsx("strong",{children:"8-9"}),x.jsxs(x.Fragment,{children:[x.jsx("strong",{children:"Severe/Extreme storm."})," HF may black out completely. Aurora visible at very low latitudes. Power grid stress possible."]})]]}),x.jsx(Te,{children:"R / S / G Scales"}),x.jsx("p",{children:"NOAA's shorthand for three types of space weather events:"}),x.jsx(cl,{children:"R (Radio Blackouts) — from solar flares:"}),x.jsxs("ul",{className:"list-disc list-inside ml-4 space-y-1",children:[x.jsx("li",{children:"R1-R2: Brief HF disruption. You might not notice."}),x.jsx("li",{children:"R3: HF goes out for about an hour on the sunlit side of Earth."}),x.jsx("li",{children:"R4-R5: HF dead for hours. Serious."})]}),x.jsx(cl,{children:"S (Solar Radiation Storms) — from energetic particles:"}),x.jsxs("ul",{className:"list-disc list-inside ml-4 space-y-1",children:[x.jsx("li",{children:"Mostly affects polar regions and satellites"}),x.jsx("li",{children:"S3+: Polar HF goes out entirely"})]}),x.jsx(cl,{children:"G (Geomagnetic Storms) — from solar wind disturbances:"}),x.jsx("ul",{className:"list-disc list-inside ml-4 space-y-1",children:x.jsx("li",{children:"Same as the Kp scale: G1 = Kp 5, up to G5 = Kp 9"})}),x.jsx(Te,{children:"Bz — The Storm Predictor"}),x.jsx("p",{children:"Bz measures the direction of the solar wind's magnetic field. When it points south (negative values), the solar wind can dump energy into Earth's magnetic field, causing storms."}),x.jsx(Rt,{headers:["Bz","What It Means"],rows:[["Positive","All good. Solar wind bouncing off."],["0 to -5","Slight coupling. Nothing dramatic."],["-5 to -10","Things starting to pick up. Storm possible."],["Below -10","Storm likely. Kp will start climbing."],["Below -20","Severe storm probable."]]}),x.jsx("p",{children:"Bz can change fast — minute to minute. What matters is whether it stays negative for hours, not brief dips."}),x.jsx(Te,{children:"Learn More"}),x.jsxs("ul",{className:"list-disc list-inside ml-4 space-y-1",children:[x.jsxs("li",{children:[x.jsx(Bt,{href:"https://www.swpc.noaa.gov",children:"SWPC Space Weather Dashboard"})," — live data"]}),x.jsxs("li",{children:[x.jsx(Bt,{href:"https://www.swpc.noaa.gov/noaa-scales-explanation",children:"NOAA Space Weather Scales"})," — what R/S/G mean"]}),x.jsxs("li",{children:[x.jsx(Bt,{href:"https://www.hamqsl.com/solar.html",children:"HamQSL Solar Page"})," — ham-friendly display"]}),x.jsxs("li",{children:[x.jsx(Bt,{href:"https://www.swpc.noaa.gov/products/planetary-k-index",children:"Planetary K-Index"})," — live Kp"]})]})]}),x.jsxs(pi,{id:"ducting",title:"Tropospheric Ducting",children:[x.jsx(Te,{children:"What You're Looking At"}),x.jsx("p",{children:'Sometimes the atmosphere creates an invisible "pipe" that traps radio signals and carries them much farther than normal. This is called tropospheric ducting. It mostly affects VHF and UHF frequencies.'}),x.jsx("p",{children:"MeshAI watches for these conditions by analyzing weather data (temperature and humidity at different altitudes) over your mesh area."}),x.jsx(Te,{children:"How Do I Know If Ducting Is Happening?"}),x.jsx("p",{children:'MeshAI reports a "condition" based on the atmospheric profile:'}),x.jsx(Rt,{headers:["Condition","What It Means"],rows:[["Normal","Standard propagation. Nothing unusual."],["Super-refraction","Slightly enhanced range. You might hear a few more distant stations than usual."],["Surface Duct","Radio signals trapped near the ground. You may hear stations hundreds of km away that you've never heard before."],["Elevated Duct",'Same effect but the "pipe" is up in the atmosphere. Affects signals passing through that altitude.']]}),x.jsx(Te,{children:"What You'll Actually Notice"}),x.jsx("p",{children:"When ducting happens on your mesh:"}),x.jsxs("ul",{className:"list-disc list-inside ml-4 space-y-1",children:[x.jsx("li",{children:"Distant repeaters you've never heard suddenly come in"}),x.jsx("li",{children:"Nodes appear from far outside your normal range"}),x.jsx("li",{children:"You hear FM radio stations from other cities"}),x.jsx("li",{children:"ADS-B flight tracking range gets much longer"}),x.jsx("li",{children:"There might be interference from distant stations on your frequency"})]}),x.jsx(Te,{children:"The dM/dz Number"}),x.jsx("p",{children:`The dashboard shows a "dM/dz" value in "M-units/km." You don't need to understand the math — just know:`}),x.jsxs("ul",{className:"list-disc list-inside ml-4 space-y-1",children:[x.jsxs("li",{children:[x.jsx("strong",{children:"Around 118"})," = normal atmosphere"]}),x.jsxs("li",{children:[x.jsx("strong",{children:"Below 79"})," = enhanced propagation starting"]}),x.jsxs("li",{children:[x.jsx("strong",{children:"Below 0 (negative)"})," = ducting is happening"]}),x.jsxs("li",{children:[x.jsx("strong",{children:"Below -50"})," = strong ducting — classic VHF/UHF DX event"]})]}),x.jsx(Te,{children:"When Does Ducting Happen?"}),x.jsxs("ul",{className:"list-disc list-inside ml-4 space-y-1",children:[x.jsx("li",{children:"Under high-pressure weather systems (clear, stable air)"}),x.jsx("li",{children:"When warm air sits on top of cool air (temperature inversion)"}),x.jsx("li",{children:"Most common in late summer and early fall"}),x.jsx("li",{children:"Strongest along coastlines and over water"}),x.jsx("li",{children:"In mountain valleys: cold air pooling in fall/winter can create surface ducts"})]}),x.jsx(Te,{children:"Setting It Up"}),x.jsx("p",{children:"Just configure the latitude and longitude of the center of your mesh area in Config → Environmental → Ducting. MeshAI checks the atmospheric conditions there every 3 hours using free weather model data. No API key needed."}),x.jsx(Te,{children:"Learn More"}),x.jsxs("ul",{className:"list-disc list-inside ml-4 space-y-1",children:[x.jsxs("li",{children:[x.jsx(Bt,{href:"https://dxinfocentre.com/tropo.html",children:"Tropo Forecast Maps (Hepburn)"})," — 6-day tropo prediction"]}),x.jsxs("li",{children:[x.jsx(Bt,{href:"https://dxmaps.com",children:"DX Maps"})," — real-time VHF/UHF propagation reports"]}),x.jsxs("li",{children:[x.jsx(Bt,{href:"https://en.wikipedia.org/wiki/Tropospheric_propagation",children:"Wikipedia: Tropospheric Propagation"})," — background"]})]})]}),x.jsxs(pi,{id:"avalanche",title:"Avalanche Danger",children:[x.jsx(Te,{children:"What You're Looking At"}),x.jsx("p",{children:"MeshAI pulls avalanche forecasts from your regional avalanche center during winter months. The danger scale has 5 levels and it's the same across all of North America."}),x.jsx(Te,{children:"The Danger Scale"}),x.jsx(Rt,{headers:["Level","Name","Color","What To Do"],rows:[["1","Low",x.jsx(ar,{color:"green"}),"Generally safe. Normal caution in steep terrain."],["2","Moderate",x.jsx(ar,{color:"yellow"}),"Be careful on specific terrain features. Evaluate conditions."],["3","Considerable",x.jsx(ar,{color:"orange"}),x.jsxs(x.Fragment,{children:[x.jsx("strong",{children:"DANGEROUS."}),` This is where most people die in avalanches — they see "3 out of 5" and think it's fine. It's not. Use extreme caution.`]})],["4","High",x.jsx(ar,{color:"red"}),x.jsxs(x.Fragment,{children:[x.jsx("strong",{children:"Very dangerous."})," Stay off anything steep."]})],["5","Extreme",x.jsx(ar,{color:"black"}),x.jsxs(x.Fragment,{children:[x.jsx("strong",{children:"Don't go out."})," Avalanches are happening on their own."]})]]}),x.jsx(Te,{children:"The Most Important Thing to Know"}),x.jsxs("p",{children:[x.jsx("strong",{children:"Level 3 (Considerable) kills more people than any other level."}),' People look at "3 out of 5" and think "middle of the road, probably okay." In reality, the risk roughly doubles at each step up the scale. Level 3 is where dangerous conditions overlap with people thinking they can handle it.']}),x.jsx(Te,{children:"Seasonal"}),x.jsx("p",{children:'MeshAI only checks avalanche conditions during winter months (configurable, default December through April). Outside season, it shows "off season" and saves API calls.'}),x.jsx(Te,{children:"Finding Your Avalanche Center"}),x.jsxs("p",{children:["Go to ",x.jsx(Bt,{href:"https://avalanche.org/avalanche-centers/",children:"avalanche.org/avalanche-centers/"})," for a map. Common center codes:"]}),x.jsxs("ul",{className:"list-disc list-inside ml-4 space-y-1",children:[x.jsxs("li",{children:[x.jsx(Ve,{children:"SNFAC"})," — Sawtooth (central Idaho)"]}),x.jsxs("li",{children:[x.jsx(Ve,{children:"UAC"})," — Utah"]}),x.jsxs("li",{children:[x.jsx(Ve,{children:"NWAC"})," — Cascades/Olympics (WA/OR)"]}),x.jsxs("li",{children:[x.jsx(Ve,{children:"CAIC"})," — Colorado"]}),x.jsxs("li",{children:[x.jsx(Ve,{children:"SAC"})," — Sierra Nevada (CA)"]}),x.jsxs("li",{children:[x.jsx(Ve,{children:"GNFAC"})," — Gallatin (SW Montana)"]})]}),x.jsx(Te,{children:"Learn More"}),x.jsxs("ul",{className:"list-disc list-inside ml-4 space-y-1",children:[x.jsxs("li",{children:[x.jsx(Bt,{href:"https://avalanche.org",children:"Avalanche.org"})," — US forecasts"]}),x.jsxs("li",{children:[x.jsx(Bt,{href:"https://avalanche.org/avalanche-encyclopedia/human/resources/north-american-public-avalanche-danger-scale/",children:"Avalanche Danger Scale"})," — full scale explanation"]}),x.jsxs("li",{children:[x.jsx(Bt,{href:"https://kbyg.org",children:"Know Before You Go"})," — avalanche awareness"]})]})]}),x.jsxs(pi,{id:"traffic",title:"Traffic Flow",children:[x.jsx(Te,{children:"What You're Looking At"}),x.jsx("p",{children:"MeshAI monitors traffic speed on road segments you configure, using data from TomTom (real vehicles with navigation apps reporting their speed)."}),x.jsx(Te,{children:"Speed Ratio — The Key Number"}),x.jsx("p",{children:'MeshAI compares current speed to "free-flow speed" (what traffic normally does when the road is empty). The ratio tells you how congested it is:'}),x.jsx(Rt,{headers:["Ratio","What It Means"],rows:[[x.jsxs(x.Fragment,{children:[x.jsx(ar,{color:"green"})," Above 85%"]}),"Normal. Traffic flowing fine."],[x.jsxs(x.Fragment,{children:[x.jsx(ar,{color:"yellow"})," 65-85%"]}),"Slow. Heavier than usual but moving."],[x.jsxs(x.Fragment,{children:[x.jsx(ar,{color:"orange"})," 40-65%"]}),"Congested. Significant delays."],[x.jsxs(x.Fragment,{children:[x.jsx(ar,{color:"red"})," Below 40%"]}),"Gridlock. Barely moving."]]}),x.jsxs("p",{children:[x.jsx("strong",{children:"Note"}),`: "free-flow speed" is NOT the speed limit. It's what traffic actually does on that road when nobody's in the way. Drivers often exceed speed limits on open highways.`]}),x.jsx(Te,{children:"Confidence — Can You Trust the Data?"}),x.jsx("p",{children:"TomTom's confidence score tells you how much of the reading comes from real vehicles right now vs historical averages:"}),x.jsx(Rt,{headers:["Confidence","What It Means"],rows:[["Above 0.9","Very reliable — lots of real-time probe data"],["0.7-0.9","Good — mix of real-time and historical"],["Below 0.7",x.jsxs(x.Fragment,{children:[x.jsx("strong",{children:"Unreliable"})," — mostly guessing from historical patterns. Don't alert on this."]})]]}),x.jsx("p",{children:"Set minimum confidence to 0.7 to avoid false congestion alerts at night or on rural roads where few probe vehicles drive."}),x.jsx(Te,{children:"Setting Up Corridors"}),x.jsx("p",{children:'Each "corridor" is a point on a road you want to monitor. To add one:'}),x.jsxs("ol",{className:"list-decimal list-inside ml-4 space-y-1",children:[x.jsx("li",{children:"Go to Google Maps, find the road"}),x.jsx("li",{children:`Right-click the road → "What's here?" → copy the coordinates`}),x.jsx("li",{children:"Add the corridor in Config with a name and those coordinates"}),x.jsx("li",{children:"TomTom finds the nearest road segment automatically"})]}),x.jsx(Te,{children:"Getting an API Key"}),x.jsxs("ol",{className:"list-decimal list-inside ml-4 space-y-1",children:[x.jsxs("li",{children:["Sign up at ",x.jsx(Bt,{href:"https://developer.tomtom.com",children:"developer.tomtom.com"})," (free)"]}),x.jsx("li",{children:"Create an app → get your API key"}),x.jsx("li",{children:"Free tier: 2,500 requests/day (plenty for 5-10 corridors)"})]}),x.jsx(Te,{children:"Learn More"}),x.jsxs("ul",{className:"list-disc list-inside ml-4 space-y-1",children:[x.jsxs("li",{children:[x.jsx(Bt,{href:"https://developer.tomtom.com",children:"TomTom Developer Portal"})," — API docs and key signup"]}),x.jsxs("li",{children:[x.jsx(Bt,{href:"https://www.tomtom.com/traffic-index/",children:"TomTom Traffic Index"})," — city congestion rankings"]})]})]}),x.jsxs(pi,{id:"roads-511",title:"Road Conditions (511)",children:[x.jsx(Te,{children:"What You're Looking At"}),x.jsx("p",{children:"511 systems report road closures, construction, weather events, mountain pass conditions, and incidents. Every state runs their own 511 system — there is no national API."}),x.jsx(Te,{children:"Setting It Up"}),x.jsx("p",{children:"You need to find YOUR state's 511 developer API. MeshAI does not include a default URL because every state is different. Some states have free public APIs, some require registration, and some don't have developer APIs at all."}),x.jsx("p",{children:"Configure in Config → Environmental → 511:"}),x.jsxs("ul",{className:"list-disc list-inside ml-4 space-y-1",children:[x.jsxs("li",{children:[x.jsx("strong",{children:"Base URL"})," — your state's API endpoint"]}),x.jsxs("li",{children:[x.jsx("strong",{children:"API Key"})," — if required by your state"]}),x.jsxs("li",{children:[x.jsx("strong",{children:"Endpoints"})," — which data feeds to poll (varies by state)"]})]}),x.jsx(Te,{children:"Learn More"}),x.jsx("p",{children:"Check your state's 511 or DOT website for developer information."})]}),x.jsxs(pi,{id:"mesh-health",title:"Mesh Health",children:[x.jsx(Te,{children:"Health Score"}),x.jsx("p",{children:"MeshAI computes a 0-100 health score for your mesh network by looking at five areas, each weighted differently:"}),x.jsx(Rt,{headers:["Pillar","Weight","What It Measures"],rows:[[x.jsx("strong",{children:"Infrastructure"}),"30%","Are your routers online?"],[x.jsx("strong",{children:"Utilization"}),"25%","Is the radio channel congested?"],[x.jsx("strong",{children:"Coverage"}),"20%","Do nodes have redundant paths to gateways?"],[x.jsx("strong",{children:"Behavior"}),"15%","Are any nodes flooding the channel?"],[x.jsx("strong",{children:"Power"}),"10%","Are battery-powered nodes running low?"]]}),x.jsx("p",{children:"The overall score is the weighted sum:"}),x.jsx("p",{className:"p-3 bg-slate-800 rounded font-mono text-sm",children:"Score = (Infrastructure × 30%) + (Utilization × 25%) + (Coverage × 20%) + (Behavior × 15%) + (Power × 10%)"}),x.jsx(Te,{children:"How Each Pillar Is Calculated"}),x.jsx(cl,{children:"Infrastructure (30%)"}),x.jsx("p",{children:"This is the simplest pillar — what percentage of your infrastructure nodes are currently online?"}),x.jsx("p",{className:"p-3 bg-slate-800 rounded font-mono text-sm",children:"(routers online ÷ total routers) × 100"}),x.jsxs("p",{children:["Only nodes with the ",x.jsx(Ve,{children:"ROUTER"}),", ",x.jsx(Ve,{children:"ROUTER_LATE"}),", or ",x.jsx(Ve,{children:"ROUTER_CLIENT"})," role count as infrastructure. Regular client nodes going offline doesn't affect this score. If you have 5 routers and 3 are online, infrastructure scores 60."]}),x.jsxs("p",{children:[x.jsx("strong",{children:"Special case:"})," If you have no routers at all (all clients), this pillar scores 100. You're not penalized for not having infrastructure — you just don't have any to track."]}),x.jsx(cl,{children:"Utilization (25%)"}),x.jsx("p",{children:"Estimates how much of the radio channel's airtime is being used. MeshAI can't measure airtime directly, so it estimates based on packet counts over the last 24 hours."}),x.jsxs("p",{className:"p-3 bg-slate-800 rounded font-mono text-sm",children:["packets_per_hour = non_text_packets ÷ 24",x.jsx("br",{}),"airtime_estimate = (packets_per_hour × 200ms) ÷ 3,600,000ms × 100%"]}),x.jsx("p",{children:"The 200ms is an approximation for the MediumFast radio preset — each LoRa packet takes roughly 200ms of airtime. Text messages don't count toward utilization (chatting is the point of a mesh)."}),x.jsx(Rt,{headers:["Estimated Airtime","Score","What It Means"],rows:[["Under 20%","100","Channel is clear — this is the goal"],["20-25%","75-100","Slight degradation, occasional collisions"],["25-35%","50-75","Severe degradation — firmware throttling active"],["35-45%","25-50","Mesh struggling badly — reliability dropping"],["Over 45%","0-25","Mesh is effectively dead"]]}),x.jsxs("p",{children:[x.jsx("strong",{children:"Special case:"})," If MeshAI doesn't have packet data (no sources reporting packet counts), this pillar scores 100. You're not penalized for missing data."]}),x.jsx(cl,{children:"Coverage (20%)"}),x.jsx("p",{children:'Measures gateway redundancy — how many of your data sources can "see" each node. A node reported by all 3 of your gateways has full coverage. A node only seen by 1 gateway is a single point of failure.'}),x.jsxs("p",{className:"p-3 bg-slate-800 rounded font-mono text-sm",children:["coverage_ratio = average_gateways_per_node ÷ total_sources",x.jsx("br",{}),"single_gw_penalty = (single_gateway_nodes ÷ total_nodes) × 40"]}),x.jsx("p",{children:"If a node is seen by 2 out of 3 sources, its coverage ratio is 0.67. Infrastructure nodes with only single-gateway coverage get an extra penalty — they're critical but have no backup path."}),x.jsx(Rt,{headers:["Coverage Ratio","Base Score","After Penalty"],rows:[["100% (all sources)","100","100 minus single-gw penalty"],["70-99%","90","Minus penalties"],["50-69%","70","Minus penalties"],["Under 50%","50 or less","Heavy penalty"]]}),x.jsxs("p",{children:[x.jsx("strong",{children:"Special case:"})," With only 1 data source, this pillar can't score well — there's no redundancy to measure. Coverage becomes meaningful when you have 2+ sources (MeshMonitor + MQTT, multiple gateways, etc.)."]}),x.jsx(cl,{children:"Behavior (15%)"}),x.jsx("p",{children:"Counts how many nodes are sending an unusually high number of non-text packets. This catches firmware bugs, stuck transmitters, and misconfigured nodes that are flooding the channel."}),x.jsxs("p",{children:[x.jsx("strong",{children:"What counts as flooding:"})," More than 500 non-text packets in 24 hours. Text messages don't count — the behavior pillar only flags telemetry, position, and routing packet floods."]}),x.jsx(Rt,{headers:["Flagged Nodes","Score"],rows:[["0","100"],["1","80"],["2-3","60"],["4-5","40"],["6+","20"]]}),x.jsx("p",{children:"A single misbehaving node only drops the score to 80. It takes multiple problem nodes to seriously hurt the behavior pillar."}),x.jsx(cl,{children:"Power (10%)"}),x.jsx("p",{children:"Measures what fraction of battery-powered nodes are below the warning threshold (default 20%)."}),x.jsx("p",{className:"p-3 bg-slate-800 rounded font-mono text-sm",children:"100 × (1 − low_battery_nodes ÷ total_battery_nodes)"}),x.jsx("p",{children:"If 2 out of 10 battery nodes are below 20%, power scores 80."}),x.jsxs("p",{children:[x.jsx("strong",{children:"Important:"})," USB-powered nodes are excluded from this calculation. Many nodes report 100% battery even when running on wall power with no battery installed. Only nodes actually running on batteries affect this pillar."]}),x.jsx(Te,{children:"Health Tiers"}),x.jsx(Rt,{headers:["Score","Tier","What It Means"],rows:[["90-100",x.jsxs(x.Fragment,{children:[x.jsx(ar,{color:"green"})," Healthy"]}),"Everything's working well."],["75-89",x.jsxs(x.Fragment,{children:[x.jsx(ar,{color:"yellow"})," Slight degradation"]}),"Some issues but the mesh is functional."],["50-74",x.jsxs(x.Fragment,{children:[x.jsx(ar,{color:"orange"})," Unhealthy"]}),"Multiple problems. Reliability is affected."],["25-49",x.jsxs(x.Fragment,{children:[x.jsx(ar,{color:"red"})," Warning"]}),"Significant issues. The mesh is struggling."],["0-24",x.jsxs(x.Fragment,{children:[x.jsx(ar,{color:"black"})," Critical"]}),"Major failures. Barely functional."]]}),x.jsx(Te,{children:"Channel Utilization — Is the Radio Channel Full?"}),x.jsx("p",{children:"Meshtastic radios share one LoRa channel. If too many nodes are transmitting too often, they step on each other and messages get lost."}),x.jsx(Rt,{headers:["Utilization","What's Happening"],rows:[[x.jsxs(x.Fragment,{children:[x.jsx(ar,{color:"green"})," Under 25%"]}),"Healthy. The firmware itself starts throttling above 25% to protect the channel — so under 25% is the target."],[x.jsxs(x.Fragment,{children:[x.jsx(ar,{color:"yellow"})," 25-40%"]}),"Getting busy. Common on larger meshes. Worth watching."],[x.jsxs(x.Fragment,{children:[x.jsx(ar,{color:"orange"})," 40-50%"]}),"Congested. The firmware throttles GPS updates above 40%. Messages are colliding and retrying."],[x.jsxs(x.Fragment,{children:[x.jsx(ar,{color:"red"})," Over 50%"]}),"Serious problem. More time is spent retrying than communicating. Mesh reliability drops fast."],[x.jsxs(x.Fragment,{children:[x.jsx(ar,{color:"black"})," Over 65%"]}),"Documented failure point on busy LONG_FAST meshes. The mesh becomes unusable."]]}),x.jsx(Te,{children:"Packet Flooding"}),x.jsx("p",{className:"p-3 bg-yellow-500/10 border border-yellow-500/30 rounded text-yellow-200",children:x.jsx("strong",{children:'⚠️ "Packet flooding" means a node sending too many RADIO PACKETS. This has nothing to do with water flooding.'})}),x.jsx("p",{children:"A normal Meshtastic node sends a packet every few minutes (announcing itself, reporting telemetry, updating position). If a node starts blasting packets every few seconds, something is wrong — firmware bug, stuck transmitter, or misconfiguration."}),x.jsx(Rt,{headers:["Packets per Minute","What It Means"],rows:[["1-5","Normal"],["5-10","Elevated — might be someone chatting a lot"],["10-20","Suspicious — worth investigating"],["Over 30","Something is broken. This node is actively hurting the mesh."]]}),x.jsx(Te,{children:"Battery Levels"}),x.jsx("p",{children:"Most Meshtastic radios (T-Beam, RAK4631, Heltec V3) use a single lithium battery cell. The voltage tells you how much charge is left:"}),x.jsx(Rt,{headers:["Voltage","Charge","What To Do"],rows:[["4.20V","100%","Full"],["3.80V","~60%","Fine"],[x.jsx("strong",{children:"3.60V"}),x.jsx("strong",{children:"~30%"}),x.jsx(x.Fragment,{children:x.jsx("strong",{children:"⚠️ Warning — charge it soon"})})],[x.jsx("strong",{children:"3.50V"}),x.jsx("strong",{children:"~15%"}),x.jsx(x.Fragment,{children:x.jsx("strong",{children:"🔴 Low — charge it now"})})],[x.jsx("strong",{children:"3.40V"}),x.jsx("strong",{children:"~7%"}),x.jsx(x.Fragment,{children:x.jsx("strong",{children:"⚫ About to die"})})],["3.30V","~3%","Device shutting down"]]}),x.jsxs("p",{children:[x.jsx("strong",{children:"USB-powered nodes"})," report 100% battery even if there's no battery installed. Battery alerts only matter for nodes actually running on battery power."]}),x.jsx(Te,{children:"Node Offline Detection"}),x.jsx("p",{children:`MeshAI marks a node as "offline" when it hasn't been heard for a configurable time period. Different node types need different thresholds:`}),x.jsx(Rt,{headers:["Node Type","Recommended Threshold","Why"],rows:[["Fixed infrastructure (wall power)",x.jsx("strong",{children:"2 hours"}),"These should always be transmitting. 2 hours of silence means something is wrong."],["Fixed client (wall power)","2-4 hours","Same logic, slightly more lenient."],["Mobile / vehicle","4-8 hours","They go behind mountains, into garages, out of range. Normal."],["Solar-powered","12-24 hours","May shut down at night when solar stops charging."]]}),x.jsxs("p",{children:[x.jsx("strong",{children:"Rule of thumb"}),`: set the threshold to about 4× the node's beacon interval. Too tight and nodes will constantly flap "offline/online" from normal gaps. Too loose and real outages go unnoticed.`]})]}),x.jsxs(pi,{id:"notifications",title:"Notifications",children:[x.jsx(Te,{children:"How It Works"}),x.jsxs("ol",{className:"list-decimal list-inside ml-4 space-y-1",children:[x.jsxs("li",{children:[x.jsx("strong",{children:"Something happens"})," — a fire is detected, weather warning issued, node goes offline, etc."]}),x.jsxs("li",{children:[x.jsx("strong",{children:"MeshAI checks your rules"})," — does this event match any of your notification rules? Is it severe enough? Are we in quiet hours?"]}),x.jsxs("li",{children:[x.jsx("strong",{children:"If a rule matches"})," — MeshAI sends the notification through whatever delivery method that rule is configured for."]})]}),x.jsx(Te,{children:"Building Rules"}),x.jsx("p",{children:"Each rule answers three questions:"}),x.jsxs("ul",{className:"list-disc list-inside ml-4 space-y-1",children:[x.jsxs("li",{children:[x.jsx("strong",{children:"WHEN"})," does it trigger? (which categories, what severity)"]}),x.jsxs("li",{children:[x.jsx("strong",{children:"WHERE"})," does it send? (mesh broadcast, email, webhook, etc.)"]}),x.jsxs("li",{children:[x.jsx("strong",{children:"HOW OFTEN"})," at most? (cooldown period)"]})]}),x.jsx("p",{children:'Use "Add from Template" to start with a pre-built rule and customize it, or build from scratch with "Add Rule."'}),x.jsx(Te,{children:"Severity Levels — What Should I Set?"}),x.jsx(Rt,{headers:["Level","When It's Used","Notification Volume"],rows:[["Info","Routine stuff (ducting detected, new router appeared)","High — lots of messages"],["Advisory","Worth knowing (weather advisory, slow traffic, battery declining)","Moderate"],["Watch","Pay attention (fire within 50km, weather watch, stream rising)","Low-moderate"],[x.jsxs(x.Fragment,{children:[x.jsx("strong",{children:"Warning"})," ✓"]}),"Take action (fire within 15km, severe weather, critical battery)","Low — recommended for most rules"],["Emergency","Life safety (extreme weather, fire at infrastructure, total blackout)","Very rare"]]}),x.jsxs("p",{children:[x.jsx("strong",{children:'"Warning" is the sweet spot for most rules.'})," You get alerted when something actually needs your attention without being overwhelmed by every minor event."]}),x.jsx(Te,{children:"Quiet Hours"}),x.jsx("p",{children:'When enabled, non-emergency notifications are held during sleeping hours (default 10pm-6am). Emergency alerts and rules marked "Override Quiet Hours" always get through.'}),x.jsx("p",{children:"You can turn quiet hours off entirely if you don't want them."}),x.jsx(Te,{children:"Webhook — The Swiss Army Knife"}),x.jsx("p",{children:"A webhook sends your alert as an HTTP POST to any URL. This one delivery method works with:"}),x.jsxs("ul",{className:"list-disc list-inside ml-4 space-y-1",children:[x.jsxs("li",{children:[x.jsx("strong",{children:"Discord"})," — use a Discord webhook URL"]}),x.jsxs("li",{children:[x.jsx("strong",{children:"Slack"})," — use a Slack incoming webhook URL"]}),x.jsxs("li",{children:[x.jsx("strong",{children:"ntfy.sh"})," — POST to ",x.jsx(Ve,{children:"https://ntfy.sh/your-topic"})]}),x.jsxs("li",{children:[x.jsx("strong",{children:"Pushover"})," — POST to the Pushover API"]}),x.jsxs("li",{children:[x.jsx("strong",{children:"Home Assistant"})," — POST to an automation webhook URL"]}),x.jsx("li",{children:"Anything else that accepts HTTP POST"})]}),x.jsx("p",{children:"MeshAI doesn't need to know what's on the other end. Give it the URL and it works."})]}),x.jsxs(pi,{id:"commands",title:"Commands",children:[x.jsxs("p",{children:["All commands use the ",x.jsx(Ve,{children:"!"})," prefix (configurable). Send these as a direct message to MeshAI on your mesh."]}),x.jsx(Te,{children:"Basic Commands"}),x.jsx(Rt,{headers:["Command","What It Does"],rows:[[x.jsx(Ve,{children:"!help"}),"Shows all available commands"],[x.jsx(Ve,{children:"!ping"}),"Tests if the bot is alive"],[x.jsx(Ve,{children:"!status"}),"Quick mesh summary (nodes online, health score)"],[x.jsx(Ve,{children:"!health"}),"Detailed health report with pillar scores"],[x.jsx(Ve,{children:"!weather"}),"Current weather for your area"]]}),x.jsx(Te,{children:"Environmental Commands"}),x.jsx(Rt,{headers:["Command","What It Does"],rows:[[x.jsx(Ve,{children:"!alerts"}),"Active NWS weather alerts for your area"],[x.jsxs(x.Fragment,{children:[x.jsx(Ve,{children:"!solar"})," (or ",x.jsx(Ve,{children:"!hf"}),")"]}),"Current solar indices and RF conditions"],[x.jsx(Ve,{children:"!fire"}),"Active wildfires near your mesh"],[x.jsx(Ve,{children:"!avy"}),'Avalanche advisory (seasonal — shows "off season" in summer)'],[x.jsxs(x.Fragment,{children:[x.jsx(Ve,{children:"!streams"})," (or ",x.jsx(Ve,{children:"!gauges"}),")"]}),"Stream gauge readings"],[x.jsxs(x.Fragment,{children:[x.jsx(Ve,{children:"!roads"})," (or ",x.jsx(Ve,{children:"!traffic"}),")"]}),"Road conditions and traffic flow"],[x.jsx(Ve,{children:"!hotspots"}),"Satellite fire detections"]]}),x.jsx(Te,{children:"Subscription Commands"}),x.jsx(Rt,{headers:["Command","What It Does"],rows:[[x.jsx(Ve,{children:"!subscribe"}),"Lists all alert categories you can subscribe to"],[x.jsx(Ve,{children:"!subscribe fire_proximity"}),"Subscribe to a specific category"],[x.jsx(Ve,{children:"!subscribe all"}),"Subscribe to everything"],[x.jsx(Ve,{children:"!unsubscribe fire_proximity"}),"Unsubscribe from a category"],[x.jsx(Ve,{children:"!subscriptions"}),"Shows what you're currently subscribed to"]]}),x.jsx(Te,{children:"Conversational"}),x.jsx("p",{children:`MeshAI isn't just commands — you can ask it questions in plain English. "How's the mesh doing?" "Is there any ducting?" "What's the fire situation?" "How's traffic on I-84?" It uses the live environmental data and mesh health data to answer.`})]}),x.jsxs(pi,{id:"api",title:"API Reference",children:[x.jsxs("p",{children:["MeshAI's REST API is available at ",x.jsx(Ve,{children:"http://your-host:8080"}),". All endpoints return JSON."]}),x.jsx(Te,{children:"System"}),x.jsxs("ul",{className:"list-disc list-inside ml-4 space-y-1",children:[x.jsxs("li",{children:[x.jsx(Ve,{children:"GET /api/status"})," — version, uptime, node count"]}),x.jsxs("li",{children:[x.jsx(Ve,{children:"GET /api/channels"})," — radio channel list"]}),x.jsxs("li",{children:[x.jsx(Ve,{children:"POST /api/restart"})," — restart the bot"]})]}),x.jsx(Te,{children:"Mesh Data"}),x.jsxs("ul",{className:"list-disc list-inside ml-4 space-y-1",children:[x.jsxs("li",{children:[x.jsx(Ve,{children:"GET /api/health"})," — health score and pillars"]}),x.jsxs("li",{children:[x.jsx(Ve,{children:"GET /api/nodes"})," — all nodes with positions and telemetry"]}),x.jsxs("li",{children:[x.jsx(Ve,{children:"GET /api/edges"})," — neighbor links with signal quality"]}),x.jsxs("li",{children:[x.jsx(Ve,{children:"GET /api/regions"})," — region summaries"]}),x.jsxs("li",{children:[x.jsx(Ve,{children:"GET /api/sources"})," — data source health"]})]}),x.jsx(Te,{children:"Configuration"}),x.jsxs("ul",{className:"list-disc list-inside ml-4 space-y-1",children:[x.jsxs("li",{children:[x.jsx(Ve,{children:"GET /api/config"})," — full config"]}),x.jsxs("li",{children:[x.jsxs(Ve,{children:["GET /api/config/","{section}"]})," — one section"]}),x.jsxs("li",{children:[x.jsxs(Ve,{children:["PUT /api/config/","{section}"]})," — update a section"]})]}),x.jsx(Te,{children:"Environmental"}),x.jsxs("ul",{className:"list-disc list-inside ml-4 space-y-1",children:[x.jsxs("li",{children:[x.jsx(Ve,{children:"GET /api/env/status"})," — per-feed health"]}),x.jsxs("li",{children:[x.jsx(Ve,{children:"GET /api/env/active"})," — all active events"]}),x.jsxs("li",{children:[x.jsx(Ve,{children:"GET /api/env/swpc"})," — solar/geomagnetic data"]}),x.jsxs("li",{children:[x.jsx(Ve,{children:"GET /api/env/ducting"})," — atmospheric profile"]}),x.jsxs("li",{children:[x.jsx(Ve,{children:"GET /api/env/fires"})," — wildfire perimeters"]}),x.jsxs("li",{children:[x.jsx(Ve,{children:"GET /api/env/hotspots"})," — satellite fire detections"]})]}),x.jsx(Te,{children:"Alerts"}),x.jsxs("ul",{className:"list-disc list-inside ml-4 space-y-1",children:[x.jsxs("li",{children:[x.jsx(Ve,{children:"GET /api/alerts/active"})," — current alerts"]}),x.jsxs("li",{children:[x.jsx(Ve,{children:"GET /api/alerts/history"})," — past alerts"]}),x.jsxs("li",{children:[x.jsx(Ve,{children:"GET /api/notifications/categories"})," — available alert categories"]})]}),x.jsx(Te,{children:"Real-time"}),x.jsx("ul",{className:"list-disc list-inside ml-4 space-y-1",children:x.jsxs("li",{children:[x.jsx(Ve,{children:"ws://your-host:8080/ws/live"})," — WebSocket for live updates"]})})]})]})})]})}function aet(){return x.jsx(_ce,{children:x.jsx(Sce,{children:x.jsxs(Mue,{children:[x.jsx(fl,{path:"/",element:x.jsx(rNe,{})}),x.jsx(fl,{path:"/mesh",element:x.jsx(xJe,{})}),x.jsx(fl,{path:"/environment",element:x.jsx(TJe,{})}),x.jsx(fl,{path:"/config",element:x.jsx(HJe,{})}),x.jsx(fl,{path:"/alerts",element:x.jsx(JJe,{})}),x.jsx(fl,{path:"/notifications",element:x.jsx(net,{})}),x.jsx(fl,{path:"/reference",element:x.jsx(iet,{})})]})})})}aP.createRoot(document.getElementById("root")).render(x.jsx(Q.StrictMode,{children:x.jsx(Due,{children:x.jsx(aet,{})})})); diff --git a/meshai/dashboard/static/index.html b/meshai/dashboard/static/index.html index 96e6925..30292c3 100644 --- a/meshai/dashboard/static/index.html +++ b/meshai/dashboard/static/index.html @@ -8,7 +8,7 @@ - + diff --git a/meshai/mesh_health.py b/meshai/mesh_health.py index a1c4190..cc95d44 100644 --- a/meshai/mesh_health.py +++ b/meshai/mesh_health.py @@ -31,10 +31,10 @@ DEFAULT_PACKET_THRESHOLD = 500 # Non-text packets per 24h DEFAULT_BATTERY_WARNING_PERCENT = 20 # Utilization thresholds (percentage) -UTIL_HEALTHY = 15 -UTIL_CAUTION = 20 -UTIL_WARNING = 25 -UTIL_UNHEALTHY = 35 +UTIL_HEALTHY = 20 +UTIL_CAUTION = 25 +UTIL_WARNING = 35 +UTIL_UNHEALTHY = 45 # Pillar weights (5-pillar system) WEIGHT_INFRASTRUCTURE = 0.30