@usex/mikrotik-mcp 3.48.0 → 3.49.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -1143,7 +1143,7 @@ function computeStats(events, opts) {
1143
1143
  // package.json
1144
1144
  var package_default = {
1145
1145
  name: "@usex/mikrotik-mcp",
1146
- version: "3.48.0",
1146
+ version: "3.49.0",
1147
1147
  description: "MCP server for MikroTik RouterOS \u2014 660+ tools over SSH for firewall, NAT, routing, DHCP, DNS, WireGuard, wireless, QoS and more.",
1148
1148
  keywords: [
1149
1149
  "ai",
package/dist/index.js CHANGED
@@ -131,7 +131,7 @@ function registerPrompts(server) {
131
131
  // package.json
132
132
  var package_default = {
133
133
  name: "@usex/mikrotik-mcp",
134
- version: "3.48.0",
134
+ version: "3.49.0",
135
135
  description: "MCP server for MikroTik RouterOS \u2014 660+ tools over SSH for firewall, NAT, routing, DHCP, DNS, WireGuard, wireless, QoS and more.",
136
136
  keywords: [
137
137
  "ai",
@@ -71,18 +71,19 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
71
71
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function zU(e,t){if(e){if(typeof e==`string`)return BU(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?BU(e,t):void 0}}function BU(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function VU(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function HU(e){if(Array.isArray(e))return e}var UU=(0,v.createContext)(void 0),WU=e=>{var t=e.children,n=LU((0,v.useState)(`${Zu(`recharts`)}-clip`),1)[0],r=rH();if(r==null)return null;var i=r.x,a=r.y,o=r.width,s=r.height;return v.createElement(UU.Provider,{value:n},v.createElement(`defs`,null,v.createElement(`clipPath`,{id:n},v.createElement(`rect`,{x:i,y:a,height:s,width:o}))),t)};function GU(e,t){if(t<1)return[];if(t===1)return e;for(var n=[],r=0;r<e.length;r+=t){var i=e[r];i!==void 0&&n.push(i)}return n}function KU(e,t,n){return NU({width:e.width+t.width,height:e.height+t.height},n)}function qU(e,t,n){var r=n===`width`,i=e.x,a=e.y,o=e.width,s=e.height;return t===1?{start:r?i:a,end:r?i+o:a+s}:{start:r?i+o:a+s,end:r?i:a}}function JU(e,t,n,r,i){if(e*t<e*r||e*t>e*i)return!1;var a=n();return e*(t-e*a/2-r)>=0&&e*(t+e*a/2-i)<=0}function YU(e,t){return GU(e,t+1)}function XU(e,t,n,r,i){for(var a=(r||[]).slice(),o=t.start,s=t.end,c=0,l=1,u=o,d=function(){var t=r?.[c];if(t===void 0)return{v:GU(r,l)};var a=c,d,f=()=>(d===void 0&&(d=n(t,a)),d),p=t.coordinate,m=c===0||JU(e,p,f,u,s);m||(c=0,u=o,l+=1),m&&(u=p+e*(f()/2+i),c+=l)},f;l<=a.length;)if(f=d(),f)return f.v;return[]}function ZU(e,t,n,r,i){var a=(r||[]).slice().length;if(a===0)return[];for(var o=t.start,s=t.end,c=1;c<=a;c++){for(var l=(a-1)%c,u=o,d=!0,f=function(){var t=r[m];if(t==null)return 0;var a=m,o,c=()=>(o===void 0&&(o=n(t,a)),o),f=t.coordinate,p=m===l||JU(e,f,c,u,s);if(!p)return d=!1,1;p&&(u=f+e*(c()/2+i))},p,m=l;m<a&&(p=f(),!(p!==0&&p===1));m+=c);if(d){for(var h=[],g=l;g<a;g+=c){var _=r[g];_!=null&&h.push(_)}return h}}return[]}function QU(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function $U(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?QU(Object(n),!0).forEach(function(t){eW(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):QU(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function eW(e,t,n){return(t=tW(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function tW(e){var t=nW(e,`string`);return typeof t==`symbol`?t:t+``}function nW(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function rW(e,t,n,r,i){for(var a=(r||[]).slice(),o=a.length,s=t.start,c=t.end,l=function(t){var r=a[t];if(r==null)return 1;var l=r,u,d=()=>(u===void 0&&(u=n(r,t)),u);if(t===o-1){var f=e*(l.coordinate+e*d()/2-c);a[t]=l=$U($U({},l),{},{tickCoord:f>0?l.coordinate-f*e:l.coordinate})}else a[t]=l=$U($U({},l),{},{tickCoord:l.coordinate});l.tickCoord!=null&&JU(e,l.tickCoord,d,s,c)&&(c=l.tickCoord-e*(d()/2+i),a[t]=$U($U({},l),{},{isShow:!0}))},u=o-1;u>=0;u--)if(l(u))continue;return a}function iW(e,t,n,r,i,a){var o=(r||[]).slice(),s=o.length,c=t.start,l=t.end;if(a){var u=r[s-1];if(u!=null){var d=n(u,s-1),f=e*(u.coordinate+e*d/2-l);o[s-1]=u=$U($U({},u),{},{tickCoord:f>0?u.coordinate-f*e:u.coordinate}),u.tickCoord!=null&&JU(e,u.tickCoord,()=>d,c,l)&&(l=u.tickCoord-e*(d/2+i),o[s-1]=$U($U({},u),{},{isShow:!0}))}}for(var p=a?s-1:s,m=function(t){var r=o[t];if(r==null)return 1;var a=r,s,u=()=>(s===void 0&&(s=n(r,t)),s);if(t===0){var d=e*(a.coordinate-e*u()/2-c);o[t]=a=$U($U({},a),{},{tickCoord:d<0?a.coordinate-d*e:a.coordinate})}else o[t]=a=$U($U({},a),{},{tickCoord:a.coordinate});a.tickCoord!=null&&JU(e,a.tickCoord,u,c,l)&&(c=a.tickCoord+e*(u()/2+i),o[t]=$U($U({},a),{},{isShow:!0}))},h=0;h<p;h++)if(m(h))continue;return o}function aW(e,t,n){var r=e.tick,i=e.ticks,a=e.viewBox,o=e.minTickGap,s=e.orientation,c=e.interval,l=e.tickFormatter,u=e.unit,d=e.angle;if(!i||!i.length||!r)return[];if(Z(c)||Sb.isSsr)return YU(i,Z(c)?c:0)??[];var f=[],p=s===`top`||s===`bottom`?`width`:`height`,m=u&&p===`width`?MI(u,{fontSize:t,letterSpacing:n}):{width:0,height:0},h=(e,r)=>{var i=typeof l==`function`?l(e.value,r):e.value;return p===`width`?KU(MI(i,{fontSize:t,letterSpacing:n}),m,d):MI(i,{fontSize:t,letterSpacing:n})[p]},g=i[0],_=i[1],v=i.length>=2&&g!=null&&_!=null?Ku(_.coordinate-g.coordinate):1,y=qU(a,v,p);return c===`equidistantPreserveStart`?XU(v,y,h,i,o):c===`equidistantPreserveEnd`?ZU(v,y,h,i,o):(f=c===`preserveStart`||c===`preserveStartEnd`?iW(v,y,h,i,o,c===`preserveStartEnd`):rW(v,y,h,i,o),f.filter(e=>e.isShow))}var oW=e=>{var t=e.ticks,n=e.label,r=e.labelGapWithTick,i=r===void 0?5:r,a=e.tickSize,o=a===void 0?0:a,s=e.tickMargin,c=s===void 0?0:s,l=0;if(t){Array.from(t).forEach(e=>{if(e){var t=e.getBoundingClientRect();t.width>l&&(l=t.width)}});var u=n?n.getBoundingClientRect().width:0,d=o+c,f=l+d+u+(n?i:0);return Math.round(f)}return 0},sW=bh({name:`renderedTicks`,initialState:{xAxis:{},yAxis:{}},reducers:{setRenderedTicks:(e,t)=>{var n=t.payload,r=n.axisType,i=n.axisId,a=n.ticks;e[r][i]=Oy(a)},removeRenderedTicks:(e,t)=>{var n=t.payload,r=n.axisType,i=n.axisId;delete e[r][i]}}}),cW=sW.actions,lW=cW.setRenderedTicks,uW=cW.removeRenderedTicks,dW=sW.reducer,fW=[`axisLine`,`width`,`height`,`className`,`hide`,`ticks`,`axisType`,`axisId`];function pW(e,t){return vW(e)||_W(e,t)||hW(e,t)||mW()}function mW(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
72
72
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function hW(e,t){if(e){if(typeof e==`string`)return gW(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?gW(e,t):void 0}}function gW(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function _W(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function vW(e){if(Array.isArray(e))return e}function yW(e,t){if(e==null)return{};var n,r,i=bW(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function bW(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function xW(){return xW=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},xW.apply(null,arguments)}function SW(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function CW(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?SW(Object(n),!0).forEach(function(t){wW(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):SW(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function wW(e,t,n){return(t=TW(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function TW(e){var t=EW(e,`string`);return typeof t==`symbol`?t:t+``}function EW(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var DW={x:0,y:0,width:0,height:0,viewBox:{x:0,y:0,width:0,height:0},orientation:`bottom`,ticks:[],stroke:`#666`,tickLine:!0,axisLine:!0,tick:!0,mirror:!1,minTickGap:5,tickSize:6,tickMargin:2,interval:`preserveEnd`,zIndex:tw.axis};function OW(e){var t=e.x,n=e.y,r=e.width,i=e.height,a=e.orientation,o=e.mirror,s=e.axisLine,c=e.otherSvgProps;if(!s)return null;var l=CW(CW(CW({},c),wl(s)),{},{fill:`none`});if(a===`top`||a===`bottom`){var u=+(a===`top`&&!o||a===`bottom`&&o);l=CW(CW({},l),{},{x1:t,y1:n+u*i,x2:t+r,y2:n+u*i})}else{var d=+(a===`left`&&!o||a===`right`&&o);l=CW(CW({},l),{},{x1:t+d*r,y1:n,x2:t+d*r,y2:n+i})}return v.createElement(`line`,xW({},l,{className:vl(`recharts-cartesian-axis-line`,Hu(s,`className`))}))}function kW(e,t,n,r,i,a,o,s,c){var l,u,d,f,p,m,h=s?-1:1,g=e.tickSize||o,_=Z(e.tickCoord)?e.tickCoord:e.coordinate;switch(a){case`top`:l=u=e.coordinate,f=n+ +!s*i,d=f-h*g,m=d-h*c,p=_;break;case`left`:d=f=e.coordinate,u=t+ +!s*r,l=u-h*g,p=l-h*c,m=_;break;case`right`:d=f=e.coordinate,u=t+ +s*r,l=u+h*g,p=l+h*c,m=_;break;default:l=u=e.coordinate,f=n+ +s*i,d=f+h*g,m=d+h*c,p=_;break}return{line:{x1:l,y1:d,x2:u,y2:f},tick:{x:p,y:m}}}function AW(e,t){switch(e){case`left`:return t?`start`:`end`;case`right`:return t?`end`:`start`;default:return`middle`}}function jW(e,t){switch(e){case`left`:case`right`:return`middle`;case`top`:return t?`start`:`end`;default:return t?`end`:`start`}}function MW(e){var t=e.option,n=e.tickProps,r=e.value,i,a=vl(n.className,`recharts-cartesian-axis-tick-value`);if(v.isValidElement(t))i=v.cloneElement(t,CW(CW({},n),{},{className:a}));else if(typeof t==`function`)i=t(CW(CW({},n),{},{className:a}));else{var o=`recharts-cartesian-axis-tick-value`;typeof t!=`boolean`&&(o=vl(o,tz(t))),i=v.createElement(kL,xW({},n,{className:o}),r)}return i}function NW(e){var t=e.ticks,n=e.axisType,r=e.axisId,i=jf();return(0,v.useEffect)(()=>r==null||n==null?ad:(i(lW({ticks:t.map(e=>({value:e.value,coordinate:e.coordinate,offset:e.offset,index:e.index})),axisId:r,axisType:n})),()=>{i(uW({axisId:r,axisType:n}))}),[i,t,r,n]),null}var PW=(0,v.forwardRef)((e,t)=>{var n=e.ticks,r=n===void 0?[]:n,i=e.tick,a=e.tickLine,o=e.stroke,s=e.tickFormatter,c=e.unit,l=e.padding,u=e.tickTextProps,d=e.orientation,f=e.mirror,p=e.x,m=e.y,h=e.width,g=e.height,_=e.tickSize,y=e.tickMargin,b=e.fontSize,x=e.letterSpacing,S=e.getTicksConfig,C=e.events,w=e.axisType,T=e.axisId,E=aW(CW(CW({},S),{},{ticks:r}),b,x),D=wl(S),O=Tl(i),k=vL(D.textAnchor)?D.textAnchor:AW(d,f),A=jW(d,f),j={};typeof a==`object`&&(j=a);var M=CW(CW({},D),{},{fill:`none`},j),N=E.map(e=>CW({entry:e},kW(e,p,m,h,g,d,_,f,y))),P=N.map(e=>{var t=e.entry,n=e.line;return v.createElement(J,{className:`recharts-cartesian-axis-tick`,key:`tick-${t.value}-${t.coordinate}-${t.tickCoord}`},a&&v.createElement(`line`,xW({},M,n,{className:vl(`recharts-cartesian-axis-tick-line`,Hu(a,`className`))})))}),F=N.map((e,t)=>{var n=e.entry,r=e.tick,a=CW(CW({},CW(CW(CW(CW({verticalAnchor:A},D),{},{textAnchor:k,stroke:`none`,fill:o},r),{},{index:t,payload:n,visibleTicksCount:E.length,tickFormatter:s,padding:l},u),{},{angle:u?.angle??D.angle??0})),O);return v.createElement(J,xW({className:`recharts-cartesian-axis-tick-label`,key:`tick-label-${n.value}-${n.coordinate}-${n.tickCoord}`},ld(C,n,t)),i&&v.createElement(MW,{option:i,tickProps:a,value:`${typeof s==`function`?s(n.value,t):n.value}${c||``}`}))});return v.createElement(`g`,{className:`recharts-cartesian-axis-ticks recharts-${w}-ticks`},v.createElement(NW,{ticks:E,axisId:T,axisType:w}),F.length>0&&v.createElement(gF,{zIndex:tw.label},v.createElement(`g`,{className:`recharts-cartesian-axis-tick-labels recharts-${w}-tick-labels`,ref:t},F)),P.length>0&&v.createElement(`g`,{className:`recharts-cartesian-axis-tick-lines recharts-${w}-tick-lines`},P))}),FW=(0,v.forwardRef)((e,t)=>{var n=e.axisLine,r=e.width,i=e.height,a=e.className,o=e.hide,s=e.ticks,c=e.axisType,l=e.axisId,u=yW(e,fW),d=pW((0,v.useState)(``),2),f=d[0],p=d[1],m=pW((0,v.useState)(``),2),h=m[0],g=m[1],_=(0,v.useRef)(null);(0,v.useImperativeHandle)(t,()=>({getCalculatedWidth:()=>oW({ticks:_.current,label:e.labelRef?.current,labelGapWithTick:5,tickSize:e.tickSize,tickMargin:e.tickMargin})}));var y=(0,v.useCallback)(e=>{if(e){var t=e.getElementsByClassName(`recharts-cartesian-axis-tick-value`);_.current=t;var n=t[0];if(n){var r=window.getComputedStyle(n),i=r.fontSize,a=r.letterSpacing;(i!==f||a!==h)&&(p(i),g(a))}}},[f,h]);return o||r!=null&&r<=0||i!=null&&i<=0?null:v.createElement(gF,{zIndex:e.zIndex},v.createElement(J,{className:vl(`recharts-cartesian-axis`,a)},v.createElement(OW,{x:e.x,y:e.y,width:r,height:i,orientation:e.orientation,mirror:e.mirror,axisLine:n,otherSvgProps:wl(e)}),v.createElement(PW,{ref:y,axisType:c,events:u,fontSize:f,getTicksConfig:e,height:e.height,letterSpacing:h,mirror:e.mirror,orientation:e.orientation,padding:e.padding,stroke:e.stroke,tick:e.tick,tickFormatter:e.tickFormatter,tickLine:e.tickLine,tickMargin:e.tickMargin,tickSize:e.tickSize,tickTextProps:e.tickTextProps,ticks:s,unit:e.unit,width:e.width,x:e.x,y:e.y,axisId:l}),v.createElement(qL,{x:e.x,y:e.y,width:e.width,height:e.height,lowerWidth:e.width,upperWidth:e.width},v.createElement(sR,{label:e.label,labelRef:e.labelRef}),e.children)))}),IW=v.forwardRef((e,t)=>{var n=hd(e,DW);return v.createElement(FW,xW({},n,{ref:t}))});IW.displayName=`CartesianAxis`;var LW=[`x1`,`y1`,`x2`,`y2`,`key`],RW=[`offset`],zW=[`xAxisId`,`yAxisId`],BW=[`xAxisId`,`yAxisId`];function VW(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function HW(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?VW(Object(n),!0).forEach(function(t){UW(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):VW(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function UW(e,t,n){return(t=WW(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function WW(e){var t=GW(e,`string`);return typeof t==`symbol`?t:t+``}function GW(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function KW(){return KW=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},KW.apply(null,arguments)}function qW(e,t){if(e==null)return{};var n,r,i=JW(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function JW(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}var YW=e=>{var t=e.fill;if(!t||t===`none`)return null;var n=e.fillOpacity,r=e.x,i=e.y,a=e.width,o=e.height,s=e.ry;return v.createElement(`rect`,{x:r,y:i,ry:s,width:a,height:o,stroke:`none`,fill:t,fillOpacity:n,className:`recharts-cartesian-grid-bg`})};function XW(e){var t=e.option,n=e.lineItemProps,r;if(v.isValidElement(t))r=v.cloneElement(t,n);else if(typeof t==`function`)r=t(n);else{var i=n.x1,a=n.y1,o=n.x2,s=n.y2,c=n.key,l=wl(qW(n,LW))??{};l.offset;var u=qW(l,RW);r=v.createElement(`line`,KW({},u,{x1:i,y1:a,x2:o,y2:s,fill:`none`,key:c}))}return r}function ZW(e){var t=e.x,n=e.width,r=e.horizontal,i=r===void 0?!0:r,a=e.horizontalPoints;if(!i||!a||!a.length)return null;e.xAxisId,e.yAxisId;var o=qW(e,zW),s=a.map((e,r)=>{var a=HW(HW({},o),{},{x1:t,y1:e,x2:t+n,y2:e,key:`line-${r}`,index:r});return v.createElement(XW,{key:`line-${r}`,option:i,lineItemProps:a})});return v.createElement(`g`,{className:`recharts-cartesian-grid-horizontal`},s)}function QW(e){var t=e.y,n=e.height,r=e.vertical,i=r===void 0?!0:r,a=e.verticalPoints;if(!i||!a||!a.length)return null;e.xAxisId,e.yAxisId;var o=qW(e,BW),s=a.map((e,r)=>{var a=HW(HW({},o),{},{x1:e,y1:t,x2:e,y2:t+n,key:`line-${r}`,index:r});return v.createElement(XW,{option:i,lineItemProps:a,key:`line-${r}`})});return v.createElement(`g`,{className:`recharts-cartesian-grid-vertical`},s)}function $W(e){var t=e.horizontalFill,n=e.fillOpacity,r=e.x,i=e.y,a=e.width,o=e.height,s=e.horizontalPoints,c=e.horizontal;if(!(c===void 0||c)||!t||!t.length||s==null)return null;var l=s.map(e=>Math.round(e+i-i)).sort((e,t)=>e-t);i!==l[0]&&l.unshift(0);var u=l.map((e,s)=>{var c=l[s+1],u=c==null?i+o-e:c-e;if(u<=0)return null;var d=s%t.length;return v.createElement(`rect`,{key:`react-${s}`,y:e,x:r,height:u,width:a,stroke:`none`,fill:t[d],fillOpacity:n,className:`recharts-cartesian-grid-bg`})});return v.createElement(`g`,{className:`recharts-cartesian-gridstripes-horizontal`},u)}function eG(e){var t=e.vertical,n=t===void 0?!0:t,r=e.verticalFill,i=e.fillOpacity,a=e.x,o=e.y,s=e.width,c=e.height,l=e.verticalPoints;if(!n||!r||!r.length)return null;var u=l.map(e=>Math.round(e+a-a)).sort((e,t)=>e-t);a!==u[0]&&u.unshift(0);var d=u.map((e,t)=>{var n=u[t+1],l=n==null?a+s-e:n-e;if(l<=0)return null;var d=t%r.length;return v.createElement(`rect`,{key:`react-${t}`,x:e,y:o,width:l,height:c,stroke:`none`,fill:r[d],fillOpacity:i,className:`recharts-cartesian-grid-bg`})});return v.createElement(`g`,{className:`recharts-cartesian-gridstripes-vertical`},d)}var tG=(e,t)=>{var n=e.xAxis,r=e.width,i=e.height,a=e.offset;return Eg(aW(HW(HW(HW({},DW),n),{},{ticks:Dg(n,!0),viewBox:{x:0,y:0,width:r,height:i}})),a.left,a.left+a.width,t)},nG=(e,t)=>{var n=e.yAxis,r=e.width,i=e.height,a=e.offset;return Eg(aW(HW(HW(HW({},DW),n),{},{ticks:Dg(n,!0),viewBox:{x:0,y:0,width:r,height:i}})),a.top,a.top+a.height,t)},rG={horizontal:!0,vertical:!0,horizontalPoints:[],verticalPoints:[],stroke:`#ccc`,fill:`none`,verticalFill:[],horizontalFill:[],xAxisId:0,yAxisId:0,syncWithTicks:!1,zIndex:tw.grid};function iG(e){var t=$_(),n=ev(),r=Q_(),i=HW(HW({},hd(e,rG)),{},{x:Z(e.x)?e.x:r.left,y:Z(e.y)?e.y:r.top,width:Z(e.width)?e.width:r.width,height:Z(e.height)?e.height:r.height}),a=i.xAxisId,o=i.yAxisId,s=i.x,c=i.y,l=i.width,u=i.height,d=i.syncWithTicks,f=i.horizontalValues,p=i.verticalValues,m=p_(),h=Q(e=>LM(e,`xAxis`,a,m)),g=Q(e=>LM(e,`yAxis`,o,m));if(!_g(l)||!_g(u)||!Z(s)||!Z(c))return null;var _=i.verticalCoordinatesGenerator||tG,y=i.horizontalCoordinatesGenerator||nG,b=i.horizontalPoints,x=i.verticalPoints;if((!b||!b.length)&&typeof y==`function`){var S=f&&f.length,C=y({yAxis:g?HW(HW({},g),{},{ticks:S?f:g.ticks}):void 0,width:t??l,height:n??u,offset:r},S?!0:d);y_(Array.isArray(C),`horizontalCoordinatesGenerator should return Array but instead it returned [${typeof C}]`),Array.isArray(C)&&(b=C)}if((!x||!x.length)&&typeof _==`function`){var w=p&&p.length,T=_({xAxis:h?HW(HW({},h),{},{ticks:w?p:h.ticks}):void 0,width:t??l,height:n??u,offset:r},w?!0:d);y_(Array.isArray(T),`verticalCoordinatesGenerator should return Array but instead it returned [${typeof T}]`),Array.isArray(T)&&(x=T)}return v.createElement(gF,{zIndex:i.zIndex},v.createElement(`g`,{className:`recharts-cartesian-grid`},v.createElement(YW,{fill:i.fill,fillOpacity:i.fillOpacity,x:i.x,y:i.y,width:i.width,height:i.height,ry:i.ry}),v.createElement($W,KW({},i,{horizontalPoints:b})),v.createElement(eG,KW({},i,{verticalPoints:x})),v.createElement(ZW,KW({},i,{offset:r,horizontalPoints:b,xAxis:h,yAxis:g})),v.createElement(QW,KW({},i,{offset:r,verticalPoints:x,xAxis:h,yAxis:g}))))}iG.displayName=`CartesianGrid`;var aG=bh({name:`errorBars`,initialState:{},reducers:{addErrorBar:(e,t)=>{var n=t.payload,r=n.itemId,i=n.errorBar;e[r]||(e[r]=[]),e[r].push(i)},replaceErrorBar:(e,t)=>{var n=t.payload,r=n.itemId,i=n.prev,a=n.next;e[r]&&(e[r]=e[r].map(e=>e.dataKey===i.dataKey&&e.direction===i.direction?a:e))},removeErrorBar:(e,t)=>{var n=t.payload,r=n.itemId,i=n.errorBar;e[r]&&(e[r]=e[r].filter(e=>e.dataKey!==i.dataKey||e.direction!==i.direction))}}}),oG=aG.actions;oG.addErrorBar,oG.replaceErrorBar,oG.removeErrorBar;var sG=aG.reducer;function cG(e,t){var n=Q(t=>zA(t,e)),r=Q(e=>HA(e,t)),i=n?.allowDataOverflow??LA.allowDataOverflow,a=r?.allowDataOverflow??BA.allowDataOverflow;return{needClip:i||a,needClipX:i,needClipY:a}}function lG(e){var t=e.xAxisId,n=e.yAxisId,r=e.clipPathId,i=rH(),a=cG(t,n),o=a.needClipX,s=a.needClipY,c=a.needClip,l=Q(e=>fM(e,t,!1)),u=Q(e=>pM(e,n,!1));if(!c||!i)return null;var d=i.x,f=i.y,p=i.width,m=i.height,h=o&&l?Math.min(l[0],l[1]):d-p/2,g=s&&u?Math.min(u[0],u[1]):f-m/2,_=o&&l?Math.abs(l[1]-l[0]):p*2,y=s&&u?Math.abs(u[1]-u[0]):m*2;return v.createElement(`clipPath`,{id:`clipPath-${r}`},v.createElement(`rect`,{x:h,y:g,width:_,height:y}))}function uG(e){var t=Tl(e),n=3,r=2;if(t!=null){var i=t.r,a=t.strokeWidth,o=Number(i),s=Number(a);return(Number.isNaN(o)||o<0)&&(o=n),(Number.isNaN(s)||s<0)&&(s=r),{r:o,strokeWidth:s}}return{r:n,strokeWidth:r}}function dG(e,t){return e.graphicalItems.cartesianItems.find(e=>e.id===t)?.xAxisId??0}function fG(e,t){return e.graphicalItems.cartesianItems.find(e=>e.id===t)?.yAxisId??0}var pG=(e,t,n)=>HM(e,`xAxis`,dG(e,t),n),mG=(e,t,n)=>VM(e,`xAxis`,dG(e,t),n),hG=(e,t,n)=>HM(e,`yAxis`,fG(e,t),n),gG=(e,t,n)=>VM(e,`yAxis`,fG(e,t),n),_G=$([tv,pG,hG,mG,gG],(e,t,n,r,i)=>Tg(e,`xAxis`)?Bg(t,r,!1):Bg(n,i,!1)),vG=$([XA,(e,t)=>t],(e,t)=>e.filter(e=>e.type===`area`).find(e=>e.id===t)),yG=e=>Tg(tv(e),`xAxis`)?`yAxis`:`xAxis`,bG=(e,t)=>yG(e)===`yAxis`?fG(e,t):dG(e,t),xG=$([tv,pG,hG,mG,gG,$([vG,(e,t,n)=>Sj(e,yG(e),bG(e,t),n)],(e,t)=>{if(!(e==null||t==null)){var n=e.stackId,r=Ew(e);if(!(n==null||r==null)){var i=(t[n]?.stackedData)?.find(e=>e.key===r);if(i!=null)return i.map(e=>[e[0],e[1]])}}}),mC,_G,vG,ew],(e,t,n,r,i,a,o,s,c,l)=>{var u=o.chartData,d=o.dataStartIndex,f=o.dataEndIndex;if(!(c==null||e!==`horizontal`&&e!==`vertical`||t==null||n==null||r==null||i==null||r.length===0||i.length===0||s==null)){var p=c.data,m=p&&p.length>0?p:u?.slice(d,f+1);if(m!=null)return eK({layout:e,xAxis:t,yAxis:n,xAxisTicks:r,yAxisTicks:i,dataStartIndex:d,areaSettings:c,stackedData:a,displayedData:m,chartBaseValue:l,bandSize:s})}}),SG=[`animationElapsedTime`,`isAnimating`,`isEntrance`,`layout`,`isRange`,`stroke`,`connectNulls`],CG=[`id`,`baseLine`];function wG(){return wG=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},wG.apply(null,arguments)}function TG(e,t){if(e==null)return{};var n,r,i=EG(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function EG(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function DG(e){var t=e.alpha,n=e.baseLine,r=e.points,i=e.strokeWidth,a=r[0]?.x,o=r[r.length-1]?.x;if(!gg(a)||!gg(o))return null;var s=t*Math.abs(a-o),c=Math.max(...r.map(e=>e.y||0));return Z(n)?c=Math.max(n,c):n&&Array.isArray(n)&&n.length&&(c=Math.max(...n.map(e=>e.y||0),c)),Z(c)?v.createElement(`rect`,{x:a<o?a:a-s,y:0,width:s,height:Math.floor(c+(i?parseInt(`${i}`,10):1))}):null}function OG(e){var t=e.alpha,n=e.baseLine,r=e.points,i=e.strokeWidth,a=r[0]?.y,o=r[r.length-1]?.y;if(!gg(a)||!gg(o))return null;var s=t*Math.abs(a-o),c=Math.max(...r.map(e=>e.x||0));return Z(n)?c=Math.max(n,c):n&&Array.isArray(n)&&n.length&&(c=Math.max(...n.map(e=>e.x||0),c)),Z(c)?v.createElement(`rect`,{x:0,y:a<o?a:a-s,width:c+(i?parseInt(`${i}`,10):1),height:Math.floor(s)}):null}function kG(e){var t=e.alpha,n=e.layout,r=e.points,i=e.baseLine,a=e.strokeWidth;return n===`vertical`?v.createElement(OG,{alpha:t,points:r,baseLine:i,strokeWidth:a}):v.createElement(DG,{alpha:t,points:r,baseLine:i,strokeWidth:a})}function AG(e){var t=e.animationElapsedTime,n=t===void 0?1:t,r=e.isAnimating,i=r===void 0?!1:r,a=e.isEntrance,o=a===void 0?!1:a,s=e.layout,c=e.isRange,l=e.stroke,u=e.connectNulls,d=TG(e,SG),f=s===`vertical`?`vertical`:`horizontal`,p=u??!1,m=FB(),h=d.id,g=d.baseLine,_=wl(TG(d,CG)),y=v.createElement(ax,wG({},d,{id:h,baseLine:g,connectNulls:p,stroke:`none`,className:`recharts-area-area`,layout:f})),b=l!==`none`&&v.createElement(ax,wG({},_,{className:`recharts-area-curve`,layout:f,type:d.type,connectNulls:p,fill:`none`,stroke:l,points:d.points})),x=l!==`none`&&c&&Array.isArray(g)&&v.createElement(ax,wG({},_,{className:`recharts-area-curve`,layout:f,type:d.type,connectNulls:p,fill:`none`,stroke:l,points:g}));return o&&(i||n<1)?v.createElement(J,null,v.createElement(`defs`,null,v.createElement(`clipPath`,{id:m},v.createElement(kG,{alpha:n,points:d.points??[],baseLine:g,layout:f,strokeWidth:d.strokeWidth}))),v.createElement(J,{clipPath:`url(#${m})`},y,b,x)):v.createElement(v.Fragment,null,y,b,x)}var jG=[`id`],MG=[`activeDot`,`animationBegin`,`animationDuration`,`animationEasing`,`connectNulls`,`dot`,`fill`,`fillOpacity`,`hide`,`isAnimationActive`,`legendType`,`stroke`,`xAxisId`,`yAxisId`];function NG(){return NG=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},NG.apply(null,arguments)}function PG(e,t){if(e==null)return{};var n,r,i=FG(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function FG(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function IG(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function LG(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?IG(Object(n),!0).forEach(function(t){RG(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):IG(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function RG(e,t,n){return(t=zG(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function zG(e){var t=BG(e,`string`);return typeof t==`symbol`?t:t+``}function BG(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var VG={activeDot:!0,animationBegin:0,animationDuration:1500,animationEasing:`ease`,animationMatchBy:fB,animationInterpolateFn:(e,t)=>e==null?[]:t===1?e.flatMap(e=>e.status===`removed`?[]:[e.next]):e.flatMap(e=>e.status===`matched`?[LG(LG({},e.next),{},{x:ed(e.prev.x,e.next.x,t),y:ed(e.prev.y,e.next.y,t)})]:e.status===`added`?[e.next]:[]),connectNulls:!1,dot:!1,fill:`#3182bd`,fillOpacity:.6,hide:!1,isAnimationActive:`auto`,legendType:`line`,stroke:`#3182bd`,strokeWidth:1,type:`linear`,label:!1,shape:AG,xAxisId:0,yAxisId:0,zIndex:tw.area};function HG(e,t){return e&&e!==`none`?e:t}var UG=e=>{var t=e.dataKey,n=e.name,r=e.stroke,i=e.fill,a=e.legendType;return[{inactive:e.hide,dataKey:t,type:a,color:HG(r,i),value:Hg(n,t),payload:e}]},WG=v.memo(e=>{var t=e.dataKey,n=e.data,r=e.stroke,i=e.strokeWidth,a=e.fill,o=e.name,s=e.hide,c=e.unit,l=e.formatter,u=e.tooltipType,d=e.id,f={dataDefinedOnItem:n,getPosition:ad,settings:{stroke:r,strokeWidth:i,fill:a,dataKey:t,nameKey:void 0,name:Hg(o,t),hide:s,type:u,color:HG(r,a),unit:c,formatter:l,graphicalItemId:d}};return v.createElement(rB,{tooltipEntrySettings:f})});function GG(e){var t=e.clipPathId,n=e.points,r=e.props,i=r.needClip,a=r.dot,o=r.dataKey,s=wl(r);return v.createElement(BV,{points:n,dot:a,className:`recharts-area-dots`,dotClassName:`recharts-area-dot`,dataKey:o,baseProps:s,needClip:i,clipPathId:t})}function KG(e){var t=e.showLabels,n=e.children,r=e.points.map(e=>{var t={x:e.x??0,y:e.y??0,width:0,lowerWidth:0,upperWidth:0,height:0};return LG(LG({},t),{},{value:e.value,payload:e.payload,parentViewBox:void 0,viewBox:t,fill:void 0})});return v.createElement(hR,{value:t?r:void 0},n)}function qG(e){var t=e.points,n=e.baseLine,r=e.needClip,i=e.clipPathId,a=e.props,o=e.animationElapsedTime,s=e.isAnimating,c=e.isEntrance,l=a.layout,u=a.type,d=a.stroke,f=a.connectNulls,p=a.isRange,m=a.shape,h=a.id,g=PG(a,jG),_=LG(LG({},El(g)),{},{id:h,points:t,connectNulls:f,type:u,baseLine:n,layout:l,stroke:d,isRange:p,animationElapsedTime:o,isAnimating:s,isEntrance:c});return v.createElement(v.Fragment,null,t?.length>1&&v.createElement(J,{clipPath:r?`url(#clipPath-${i})`:void 0},v.createElement($z,{option:m,DefaultShape:VG.shape,shapeProps:_})),v.createElement(GG,{points:t,props:g,clipPathId:i}))}function JG(e,t,n){return Z(e)?ed(Z(t)?t:void 0,e,n):nd(e)||qu(e)?ed(Z(t)?t:void 0,0,n):e}function YG(e){var t=e.needClip,n=e.clipPathId,r=e.props,i=e.previousPointsRef,a=e.previousBaselineRef,o=r.points,s=r.baseLine,c=r.isAnimationActive,l=r.animationBegin,u=r.animationDuration,d=r.animationEasing,f=r.animationMatchBy,p=r.animationInterpolateFn,m=(0,v.useMemo)(()=>({points:o,baseLine:s}),[o,s]),h=bB(m,a),g=rv(),_=DB(r.onAnimationStart,r.onAnimationEnd),y=_.isAnimating,b=_.handleAnimationStart,x=_.handleAnimationEnd,S=h.startValue;if(g==null)return null;var C=Array.isArray(s)&&Array.isArray(S)?yB(S,s,f):Array.isArray(s)?yB(null,s,f):null;return v.createElement(OB,{animationInput:m,animationIdPrefix:`recharts-area-`,items:o,previousItemsRef:i,isAnimationActive:c,animationBegin:l,animationDuration:u,animationEasing:d,onAnimationStart:b,onAnimationEnd:x,animationInterpolateFn:p,animationMatchBy:f,layout:g},(e,i,a)=>{var c=i===1?s:Array.isArray(s)?p(C,i,g):a?s:JG(s,S,i);return h.syncStepValue(c,i),v.createElement(KG,{showLabels:!y,points:o},r.children,v.createElement(qG,{points:e,baseLine:c,needClip:t,clipPathId:n,props:r,animationElapsedTime:i,isAnimating:y||i<1,isEntrance:a}),v.createElement(xR,{label:r.label}))})}function XG(e){var t=e.needClip,n=e.clipPathId,r=e.props,i=(0,v.useRef)(null),a=(0,v.useRef)();return v.createElement(YG,{needClip:t,clipPathId:n,props:r,previousPointsRef:i,previousBaselineRef:a})}var ZG=class extends v.PureComponent{render(){var e=this.props,t=e.hide,n=e.dot,r=e.points,i=e.className,a=e.top,o=e.left,s=e.needClip,c=e.xAxisId,l=e.yAxisId,u=e.width,d=e.height,f=e.id,p=e.baseLine,m=e.zIndex;if(t)return null;var h=vl(`recharts-area`,i),g=f,_=uG(n),y=_.r,b=_.strokeWidth,x=Hz(n),S=y*2+b,C=s?`url(#clipPath-${x?``:`dots-`}${g})`:void 0;return v.createElement(gF,{zIndex:m},v.createElement(J,{className:h},s&&v.createElement(`defs`,null,v.createElement(lG,{clipPathId:g,xAxisId:c,yAxisId:l}),!x&&v.createElement(`clipPath`,{id:`clipPath-dots-${g}`},v.createElement(`rect`,{x:o-S/2,y:a-S/2,width:u+S,height:d+S}))),v.createElement(XG,{needClip:s,clipPathId:g,props:this.props})),v.createElement(dH,{points:r,mainColor:HG(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:C}),this.props.isRange&&Array.isArray(p)&&v.createElement(dH,{points:p,mainColor:HG(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:C}))}};function QG(e){var t=e.activeDot,n=e.animationBegin,r=e.animationDuration,i=e.animationEasing,a=e.connectNulls,o=e.dot,s=e.fill,c=e.fillOpacity,l=e.hide,u=e.isAnimationActive,d=e.legendType,f=e.stroke,p=e.xAxisId,m=e.yAxisId,h=PG(e,MG),g=nv(),_=FP(),y=cG(p,m).needClip,b=p_(),x=Q(t=>xG(t,e.id,b))??{},S=x.points,C=x.isRange,w=x.baseLine,T=rH();if(g!==`horizontal`&&g!==`vertical`||T==null||_!==`AreaChart`&&_!==`ComposedChart`)return null;var E=T.height,D=T.width,O=T.x,k=T.y;return!S||!S.length?null:v.createElement(ZG,NG({},h,{activeDot:t,animationBegin:n,animationDuration:r,animationEasing:i,baseLine:w,connectNulls:a,dot:o,fill:s,fillOpacity:c,height:E,hide:l,layout:g,isAnimationActive:u,isRange:C,legendType:d,needClip:y,points:S,stroke:f,width:D,left:O,top:k,xAxisId:p,yAxisId:m}))}var $G=(e,t,n,r,i)=>{var a=n??t;if(Z(a))return a;var o=e===`horizontal`?i:r,s=o.scale.domain();if(o.type===`number`){var c=Math.max(s[0],s[1]),l=Math.min(s[0],s[1]);return a===`dataMin`?l:a===`dataMax`||c<0?c:Math.max(Math.min(s[0],s[1]),0)}return a===`dataMin`?s[0]:a===`dataMax`?s[1]:s[0]};function eK(e){var t=e.areaSettings,n=t.connectNulls,r=t.baseValue,i=t.dataKey,a=e.stackedData,o=e.layout,s=e.chartBaseValue,c=e.xAxis,l=e.yAxis,u=e.displayedData,d=e.dataStartIndex,f=e.xAxisTicks,p=e.yAxisTicks,m=e.bandSize,h=a&&a.length,g=$G(o,s,r,c,l),_=o===`horizontal`,v=!1,y=u.map((e,t)=>{var r;if(h)r=a[d+t];else{var o=Cg(e,i);Array.isArray(o)?(r=o,v=!0):r=[g,o]}var s=r?.[1]??null,u=s==null||h&&!n&&Cg(e,i)==null;return _?{x:Mg({axis:c,ticks:f,bandSize:m,entry:e,index:t}),y:u?null:l.scale.map(s)??null,value:r,payload:e}:{x:u?null:c.scale.map(s)??null,y:Mg({axis:l,ticks:p,bandSize:m,entry:e,index:t}),value:r,payload:e}});return{points:y,baseLine:(h||v?y.map(e=>{var t=Array.isArray(e.value)?e.value[0]:null;return _?{x:e.x,y:t!=null&&e.y!=null?l.scale.map(t)??null:null,payload:e.payload}:{x:t==null?null:c.scale.map(t)??null,y:e.y,payload:e.payload}}):_?l.scale.map(g):c.scale.map(g))??0,isRange:v}}function tK(e){var t=hd(e,VG),n=p_();return v.createElement(RB,{id:t.id,type:`area`},e=>v.createElement(v.Fragment,null,v.createElement(iB,{legendPayload:UG(t)}),v.createElement(WG,{dataKey:t.dataKey,data:t.data,stroke:t.stroke,strokeWidth:t.strokeWidth,fill:t.fill,name:t.name,hide:t.hide,unit:t.unit,formatter:t.formatter,tooltipType:t.tooltipType,id:e}),v.createElement(JB,{type:`area`,id:e,data:t.data,dataKey:t.dataKey,xAxisId:t.xAxisId,yAxisId:t.yAxisId,zAxisId:0,stackId:jg(t.stackId),hide:t.hide,barSize:void 0,baseValue:t.baseValue,isPanorama:n,connectNulls:t.connectNulls}),v.createElement(QG,NG({},t,{id:e}))))}var nK=v.memo(tK,$y);nK.displayName=`Area`;var rK=[`domain`,`range`],iK=[`domain`,`range`];function aK(e,t){if(e==null)return{};var n,r,i=oK(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function oK(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function sK(e,t){return e===t?!0:Array.isArray(e)&&e.length===2&&Array.isArray(t)&&t.length===2?e[0]===t[0]&&e[1]===t[1]:!1}function cK(e,t){if(e===t)return!0;var n=e.domain,r=e.range,i=aK(e,rK),a=t.domain,o=t.range,s=aK(t,iK);return!sK(n,a)||!sK(r,o)?!1:$y(i,s)}var lK=[`type`],uK=[`dangerouslySetInnerHTML`,`ticks`,`scale`],dK=[`id`,`scale`];function fK(){return fK=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},fK.apply(null,arguments)}function pK(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function mK(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?pK(Object(n),!0).forEach(function(t){hK(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):pK(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function hK(e,t,n){return(t=gK(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function gK(e){var t=_K(e,`string`);return typeof t==`symbol`?t:t+``}function _K(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function vK(e,t){if(e==null)return{};var n,r,i=yK(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function yK(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function bK(e){var t=jf(),n=(0,v.useRef)(null),r=rv(),i=e.type,a=vK(e,lK),o=aw(r,`xAxis`,i),s=(0,v.useMemo)(()=>{if(o!=null)return mK(mK({},a),{},{type:o})},[a,o]);return(0,v.useLayoutEffect)(()=>{s!=null&&(n.current===null?t(JV(s)):n.current!==s&&t(YV({prev:n.current,next:s})),n.current=s)},[s,t]),(0,v.useLayoutEffect)(()=>()=>{n.current&&=(t(XV(n.current)),null)},[t]),null}var xK=e=>{var t=e.xAxisId,n=e.className,r=Q(d_),i=p_(),a=`xAxis`,o=Q(e=>zM(e,a,t,i)),s=Q(e=>DM(e,t)),c=Q(e=>MM(e,t)),l=Q(e=>RA(e,t));if(s==null||c==null||l==null)return null;e.dangerouslySetInnerHTML,e.ticks,e.scale;var u=vK(e,uK);l.id,l.scale;var d=vK(l,dK);return v.createElement(IW,fK({},u,d,{x:c.x,y:c.y,width:s.width,height:s.height,className:vl(`recharts-${a} ${a}`,n),viewBox:r,ticks:o,axisType:a,axisId:t}))},SK={allowDataOverflow:LA.allowDataOverflow,allowDecimals:LA.allowDecimals,allowDuplicatedCategory:LA.allowDuplicatedCategory,angle:LA.angle,axisLine:DW.axisLine,height:LA.height,hide:!1,includeHidden:LA.includeHidden,interval:LA.interval,label:!1,minTickGap:LA.minTickGap,mirror:LA.mirror,orientation:LA.orientation,padding:LA.padding,reversed:LA.reversed,scale:LA.scale,tick:LA.tick,tickCount:LA.tickCount,tickLine:DW.tickLine,tickSize:DW.tickSize,type:LA.type,niceTicks:LA.niceTicks,xAxisId:0},CK=v.memo(e=>{var t=hd(e,SK);return v.createElement(v.Fragment,null,v.createElement(bK,{allowDataOverflow:t.allowDataOverflow,allowDecimals:t.allowDecimals,allowDuplicatedCategory:t.allowDuplicatedCategory,angle:t.angle,dataKey:t.dataKey,domain:t.domain,height:t.height,hide:t.hide,id:t.xAxisId,includeHidden:t.includeHidden,interval:t.interval,minTickGap:t.minTickGap,mirror:t.mirror,name:t.name,orientation:t.orientation,padding:t.padding,reversed:t.reversed,scale:t.scale,tick:t.tick,tickCount:t.tickCount,tickFormatter:t.tickFormatter,ticks:t.ticks,type:t.type,unit:t.unit,niceTicks:t.niceTicks}),v.createElement(xK,t))},cK);CK.displayName=`XAxis`;var wK=[`type`],TK=[`dangerouslySetInnerHTML`,`ticks`,`scale`],EK=[`id`,`scale`];function DK(){return DK=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},DK.apply(null,arguments)}function OK(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function kK(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?OK(Object(n),!0).forEach(function(t){AK(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):OK(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function AK(e,t,n){return(t=jK(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function jK(e){var t=MK(e,`string`);return typeof t==`symbol`?t:t+``}function MK(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function NK(e,t){if(e==null)return{};var n,r,i=PK(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function PK(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function FK(e){var t=jf(),n=(0,v.useRef)(null),r=rv(),i=e.type,a=NK(e,wK),o=aw(r,`yAxis`,i),s=(0,v.useMemo)(()=>{if(o!=null)return kK(kK({},a),{},{type:o})},[o,a]);return(0,v.useLayoutEffect)(()=>{s!=null&&(n.current===null?t(ZV(s)):n.current!==s&&t(QV({prev:n.current,next:s})),n.current=s)},[s,t]),(0,v.useLayoutEffect)(()=>()=>{n.current&&=(t($V(n.current)),null)},[t]),null}function IK(e){var t=e.yAxisId,n=e.className,r=e.width,i=e.label,a=(0,v.useRef)(null),o=(0,v.useRef)(null),s=Q(d_),c=p_(),l=jf(),u=`yAxis`,d=Q(e=>PM(e,t)),f=Q(e=>NM(e,t)),p=Q(e=>zM(e,u,t,c)),m=Q(e=>VA(e,t));if((0,v.useLayoutEffect)(()=>{if(!(r!==`auto`||!d||QL(i)||(0,v.isValidElement)(i)||m==null)){var e=a.current;if(e){var n=e.getCalculatedWidth();Math.round(d.width)!==Math.round(n)&&l(eH({id:t,width:n}))}}},[p,d,l,i,t,r,m]),d==null||f==null||m==null)return null;e.dangerouslySetInnerHTML,e.ticks,e.scale;var h=NK(e,TK);m.id,m.scale;var g=NK(m,EK);return v.createElement(IW,DK({},h,g,{ref:a,labelRef:o,x:f.x,y:f.y,tickTextProps:r===`auto`?{width:void 0}:{width:r},width:d.width,height:d.height,className:vl(`recharts-${u} ${u}`,n),viewBox:s,ticks:p,axisType:u,axisId:t}))}var LK={allowDataOverflow:BA.allowDataOverflow,allowDecimals:BA.allowDecimals,allowDuplicatedCategory:BA.allowDuplicatedCategory,angle:BA.angle,axisLine:DW.axisLine,hide:!1,includeHidden:BA.includeHidden,interval:BA.interval,label:!1,minTickGap:BA.minTickGap,mirror:BA.mirror,orientation:BA.orientation,padding:BA.padding,reversed:BA.reversed,scale:BA.scale,tick:BA.tick,tickCount:BA.tickCount,tickLine:DW.tickLine,tickSize:DW.tickSize,type:BA.type,niceTicks:BA.niceTicks,width:BA.width,yAxisId:0},RK=v.memo(e=>{var t=hd(e,LK);return v.createElement(v.Fragment,null,v.createElement(FK,{interval:t.interval,id:t.yAxisId,scale:t.scale,type:t.type,domain:t.domain,allowDataOverflow:t.allowDataOverflow,dataKey:t.dataKey,allowDuplicatedCategory:t.allowDuplicatedCategory,allowDecimals:t.allowDecimals,tickCount:t.tickCount,padding:t.padding,includeHidden:t.includeHidden,reversed:t.reversed,ticks:t.ticks,width:t.width,orientation:t.orientation,mirror:t.mirror,hide:t.hide,unit:t.unit,name:t.name,angle:t.angle,minTickGap:t.minTickGap,tick:t.tick,tickFormatter:t.tickFormatter,niceTicks:t.niceTicks}),v.createElement(IK,t))},cK);RK.displayName=`YAxis`;var zK=$([(e,t)=>t,tv,Cw,Mw,iP,oP,zP,l_],ZP);function BK(e){return`getBBox`in e.currentTarget&&typeof e.currentTarget.getBBox==`function`}function VK(e){var t=e.currentTarget.getBoundingClientRect(),n,r;if(BK(e)){var i=e.currentTarget.getBBox();n=i.width>0?t.width/i.width:1,r=i.height>0?t.height/i.height:1}else{var a=e.currentTarget;n=a.offsetWidth>0?t.width/a.offsetWidth:1,r=a.offsetHeight>0?t.height/a.offsetHeight:1}var o=(e,i)=>({relativeX:Math.round((e-t.left)/n),relativeY:Math.round((i-t.top)/r)});return`touches`in e?Array.from(e.touches).map(e=>o(e.clientX,e.clientY)):o(e.clientX,e.clientY)}var HK=Qm(`mouseClick`),UK=og();UK.startListening({actionCreator:HK,effect:(e,t)=>{var n=e.payload,r=zK(t.getState(),VK(n));r?.activeIndex!=null&&t.dispatch(lN({activeIndex:r.activeIndex,activeDataKey:void 0,activeCoordinate:r.activeCoordinate}))}});var WK=Qm(`mouseMove`),GK=og(),KK=null,qK=null,JK=null;GK.startListening({actionCreator:WK,effect:(e,t)=>{var n=e.payload,r=t.getState().eventSettings,i=r.throttleDelay,a=r.throttledEvents,o=a===`all`||a?.includes(`mousemove`);KK!==null&&(cancelAnimationFrame(KK),KK=null),qK!==null&&(typeof i!=`number`||!o)&&(clearTimeout(qK),qK=null),JK=VK(n);var s=()=>{var e=t.getState(),n=qM(e,e.tooltip.settings.shared);if(!JK){KK=null,qK=null;return}if(n===`axis`){var r=zK(e,JK);r?.activeIndex==null?t.dispatch(oN()):t.dispatch(cN({activeIndex:r.activeIndex,activeDataKey:void 0,activeCoordinate:r.activeCoordinate}))}KK=null,qK=null};if(!o){s();return}i===`raf`?KK=requestAnimationFrame(s):typeof i==`number`&&qK===null&&(qK=setTimeout(s,i))}});function YK(e,t){return t instanceof HTMLElement?`HTMLElement <${t.tagName} class="${t.className}">`:t===window?`global.window`:e===`children`&&typeof t==`object`&&t?`<<CHILDREN>>`:t}var XK={accessibilityLayer:!0,barCategoryGap:`10%`,barGap:4,barSize:void 0,className:void 0,maxBarSize:void 0,stackOffset:`none`,syncId:void 0,syncMethod:`index`,baseValue:void 0,reverseStackOrder:!1},ZK=bh({name:`rootProps`,initialState:XK,reducers:{updateOptions:(e,t)=>{e.accessibilityLayer=t.payload.accessibilityLayer,e.barCategoryGap=t.payload.barCategoryGap,e.barGap=t.payload.barGap??XK.barGap,e.barSize=t.payload.barSize,e.maxBarSize=t.payload.maxBarSize,e.stackOffset=t.payload.stackOffset,e.syncId=t.payload.syncId,e.syncMethod=t.payload.syncMethod,e.className=t.payload.className,e.baseValue=t.payload.baseValue,e.reverseStackOrder=t.payload.reverseStackOrder}}}),QK=ZK.reducer,$K=ZK.actions.updateOptions,eq=bh({name:`polarOptions`,initialState:null,reducers:{updatePolarOptions:(e,t)=>e===null?t.payload:(e.startAngle=t.payload.startAngle,e.endAngle=t.payload.endAngle,e.cx=t.payload.cx,e.cy=t.payload.cy,e.innerRadius=t.payload.innerRadius,e.outerRadius=t.payload.outerRadius,e)}}),tq=eq.actions.updatePolarOptions,nq=eq.reducer,rq=Qm(`keyDown`),iq=Qm(`focus`),aq=Qm(`blur`),oq=og(),sq=null,cq=null,lq=null;oq.startListening({actionCreator:rq,effect:(e,t)=>{lq=e.payload,sq!==null&&(cancelAnimationFrame(sq),sq=null);var n=t.getState().eventSettings,r=n.throttleDelay,i=n.throttledEvents,a=i===`all`||i.includes(`keydown`);cq!==null&&(typeof r!=`number`||!a)&&(clearTimeout(cq),cq=null);var o=()=>{try{var e=t.getState();if(e.rootProps.accessibilityLayer===!1)return;var n=e.tooltip.keyboardInteraction,r=lq;if(r!==`ArrowRight`&&r!==`ArrowLeft`&&r!==`Enter`)return;var i=wN(n,KN(e),yj(e),tP(e)),a=i==null?-1:Number(i),o=!Number.isFinite(a)||a<0,s=oP(e),c=KN(e),l=qM(e,e.tooltip.settings.shared);if(r===`Enter`){if(o)return;var u=WP(e,l,`hover`,String(n.index));t.dispatch(dN({active:!n.active,activeIndex:n.index,activeCoordinate:u}));return}var d=UM(e)===`left-to-right`?1:-1,f=r===`ArrowRight`?1:-1,p;if(o){var m=yj(e),h=tP(e),g=f*d,_=e=>({active:!1,index:String(e),dataKey:void 0,graphicalItemId:void 0,coordinate:void 0});if(p=-1,g>0){for(var v=0;v<c.length;v++)if(wN(_(v),c,m,h)!=null){p=v;break}}else for(var y=c.length-1;y>=0;y--)if(wN(_(y),c,m,h)!=null){p=y;break}if(p<0)return}else{p=a+f*d;var b=s?.length||c.length;if(b===0||p>=b||p<0)return}var x=WP(e,l,`hover`,String(p));t.dispatch(dN({active:!0,activeIndex:p.toString(),activeCoordinate:x}))}finally{sq=null,cq=null}};if(!a){o();return}r===`raf`?sq=requestAnimationFrame(o):typeof r==`number`&&cq===null&&(o(),lq=null,cq=setTimeout(()=>{lq?o():(cq=null,sq=null)},r))}}),oq.startListening({actionCreator:iq,effect:(e,t)=>{var n=t.getState();if(n.rootProps.accessibilityLayer!==!1){var r=n.tooltip.keyboardInteraction;if(!r.active&&r.index==null){var i=`0`,a=WP(n,qM(n,n.tooltip.settings.shared),`hover`,String(i));t.dispatch(dN({active:!0,activeIndex:i,activeCoordinate:a}))}}}}),oq.startListening({actionCreator:aq,effect:(e,t)=>{var n=t.getState();if(n.rootProps.accessibilityLayer!==!1){var r=n.tooltip.keyboardInteraction;r.active&&t.dispatch(dN({active:!1,activeIndex:r.index,activeCoordinate:r.coordinate}))}}});function uq(e){e.persist();var t=e.currentTarget;return new Proxy(e,{get:(e,n)=>{if(n===`currentTarget`)return t;var r=Reflect.get(e,n);return typeof r==`function`?r.bind(e):r}})}var dq=Qm(`externalEvent`),fq=og(),pq=new Map,mq=new Map,hq=new Map;fq.startListening({actionCreator:dq,effect:(e,t)=>{var n=e.payload,r=n.handler,i=n.reactEvent;if(r!=null){var a=i.type,o=uq(i);hq.set(a,{handler:r,reactEvent:o});var s=pq.get(a);s!==void 0&&(cancelAnimationFrame(s),pq.delete(a));var c=t.getState().eventSettings,l=c.throttleDelay,u=c.throttledEvents,d=u===`all`||u?.includes(a),f=mq.get(a);f!==void 0&&(typeof l!=`number`||!d)&&(clearTimeout(f),mq.delete(a));var p=()=>{var e=hq.get(a);try{if(!e)return;var n=e.handler,r=e.reactEvent,i=t.getState(),o={activeCoordinate:gP(i),activeDataKey:pP(i),activeIndex:dP(i),activeLabel:fP(i),activeTooltipIndex:dP(i),isTooltipActive:_P(i)};n&&n(o,r)}finally{pq.delete(a),mq.delete(a),hq.delete(a)}};if(!d){p();return}if(l===`raf`){var m=requestAnimationFrame(p);pq.set(a,m)}else if(typeof l==`number`){if(!mq.has(a)){p();var h=setTimeout(p,l);mq.set(a,h)}}else p()}}});var gq=$([$([ON],e=>e.tooltipItemPayloads),(e,t)=>t,(e,t,n)=>n],(e,t,n)=>{if(t!=null){var r=e.find(e=>e.settings.graphicalItemId===n);if(r!=null){var i=r.getPosition;if(i!=null)return i(t)}}}),_q=Qm(`touchMove`),vq=og(),yq=null,bq=null,xq=null,Sq=null;vq.startListening({actionCreator:_q,effect:(e,t)=>{var n=e.payload;if(!(n.touches==null||n.touches.length===0)){Sq=uq(n);var r=t.getState().eventSettings,i=r.throttleDelay,a=r.throttledEvents,o=a===`all`||a.includes(`touchmove`);yq!==null&&(cancelAnimationFrame(yq),yq=null),bq!==null&&(typeof i!=`number`||!o)&&(clearTimeout(bq),bq=null),xq=Array.from(n.touches).map(e=>VK({clientX:e.clientX,clientY:e.clientY,currentTarget:n.currentTarget}));var s=()=>{if(Sq!=null){var e=t.getState(),n=qM(e,e.tooltip.settings.shared);if(n===`axis`){var r=xq?.[0];if(r==null){yq=null,bq=null;return}var i=zK(e,r);i?.activeIndex!=null&&t.dispatch(cN({activeIndex:i.activeIndex,activeDataKey:void 0,activeCoordinate:i.activeCoordinate}))}else if(n===`item`){var a=Sq.touches[0];if(document.elementFromPoint==null||a==null)return;var o=document.elementFromPoint(a.clientX,a.clientY);if(!o||!o.getAttribute)return;var s=o.getAttribute(Zg),c=o.getAttribute(`data-recharts-item-id`)??void 0,l=HN(e).find(e=>e.id===c);if(s==null||l==null||c==null)return;var u=l.dataKey,d=gq(e,s,c);t.dispatch(iN({activeDataKey:u,activeIndex:s,activeCoordinate:d,activeGraphicalItemId:c}))}yq=null,bq=null}};if(!o){s();return}i===`raf`?yq=requestAnimationFrame(s):typeof i==`number`&&bq===null&&(s(),Sq=null,bq=setTimeout(()=>{Sq?s():(bq=null,yq=null)},i))}}});var Cq={throttleDelay:`raf`,throttledEvents:[`mousemove`,`touchmove`,`pointermove`,`scroll`,`wheel`]},wq=bh({name:`eventSettings`,initialState:Cq,reducers:{setEventSettings:(e,t)=>{t.payload.throttleDelay!=null&&(e.throttleDelay=t.payload.throttleDelay),t.payload.throttledEvents!=null&&(e.throttledEvents=Oy(t.payload.throttledEvents))}}}),Tq=wq.actions.setEventSettings,Eq=wq.reducer,Dq=Cp({brush:jU,cartesianAxis:tH,chartData:VF,errorBars:sG,eventSettings:Eq,graphicalItems:qB,layout:mg,legend:Py,options:PF,polarAxis:ez,polarOptions:nq,referenceElements:IU,renderedTicks:dW,rootProps:QK,tooltip:fN,zIndex:mF}),Oq=function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:`Chart`;return uh({reducer:Dq,preloadedState:e,middleware:e=>e({serializableCheck:!1,immutableCheck:![`commonjs`,`es6`,`production`].includes(`es6`)}).concat([UK.middleware,GK.middleware,oq.middleware,fq.middleware,vq.middleware]),enhancers:e=>{var t=e;return typeof e==`function`&&(t=e()),t.concat(ch({type:`raf`}))},devTools:Sb.devToolsEnabled&&{serialize:{replacer:YK},name:`recharts-${t}`}})};function kq(e){var t=e.preloadedState,n=e.children,r=e.reduxStoreName,i=p_(),a=(0,v.useRef)(null);if(i)return n;a.current??=Oq(t,r);var o=Of;return v.createElement(Xy,{context:o,store:a.current},n)}function Aq(e){var t=e.layout,n=e.margin,r=jf(),i=p_();return(0,v.useEffect)(()=>{i||(r(dg(t)),r(ug(n)))},[r,i,t,n]),null}var jq=(0,v.memo)(Aq,$y);function Mq(e){var t=jf();return(0,v.useEffect)(()=>{t($K(e))},[t,e]),null}var Nq=(0,v.memo)(e=>{var t=jf();return(0,v.useEffect)(()=>{t(Tq(e))},[t,e]),null},$y);function Pq(e){var t=e.zIndex,n=e.isPanorama,r=(0,v.useRef)(null),i=jf();return(0,v.useLayoutEffect)(()=>(r.current&&i(fF({zIndex:t,element:r.current,isPanorama:n})),()=>{i(pF({zIndex:t,isPanorama:n}))}),[i,t,n]),v.createElement(`g`,{tabIndex:-1,ref:r,className:`recharts-zIndex-layer_${t}`})}function Fq(e){var t=e.children,n=e.isPanorama,r=Q($P);if(!r||r.length===0)return t;var i=r.filter(e=>e<0),a=r.filter(e=>e>0);return v.createElement(v.Fragment,null,i.map(e=>v.createElement(Pq,{key:e,zIndex:e,isPanorama:n})),t,a.map(e=>v.createElement(Pq,{key:e,zIndex:e,isPanorama:n})))}var Iq=[`children`];function Lq(e,t){if(e==null)return{};var n,r,i=Rq(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function Rq(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function zq(){return zq=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},zq.apply(null,arguments)}var Bq={width:`100%`,height:`100%`,display:`block`},Vq=(0,v.forwardRef)((e,t)=>{var n=$_(),r=ev(),i=Wb();if(!_g(n)||!_g(r))return null;var a=e.children,o=e.otherAttributes,s=e.title,c=e.desc,l,u;return o!=null&&(l=typeof o.tabIndex==`number`?o.tabIndex:i?0:void 0,u=typeof o.role==`string`?o.role:i?`application`:void 0),v.createElement(Ml,zq({},o,{title:s,desc:c,role:u,tabIndex:l,width:n,height:r,style:Bq,ref:t}),a)}),Hq=e=>{var t=e.children,n=Q(h_);if(!n)return null;var r=n.width,i=n.height,a=n.y,o=n.x;return v.createElement(Ml,{width:r,height:i,x:o,y:a},t)},Uq=(0,v.forwardRef)((e,t)=>{var n=e.children,r=Lq(e,Iq);return p_()?v.createElement(Hq,null,v.createElement(Fq,{isPanorama:!0},n)):v.createElement(Vq,zq({ref:t},r),v.createElement(Fq,{isPanorama:!1},n))});function Wq(e,t){return Yq(e)||Jq(e,t)||Kq(e,t)||Gq()}function Gq(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
73
73
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Kq(e,t){if(e){if(typeof e==`string`)return qq(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?qq(e,t):void 0}}function qq(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function Jq(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function Yq(e){if(Array.isArray(e))return e}function Xq(){var e=jf(),t=Wq((0,v.useState)(null),2),n=t[0],r=t[1],i=Q(qg);return(0,v.useEffect)(()=>{if(n!=null){var t=n.getBoundingClientRect().width/n.offsetWidth;gg(t)&&t!==i&&e(pg(t))}},[n,e,i]),r}function Zq(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Qq(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Zq(Object(n),!0).forEach(function(t){$q(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Zq(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function $q(e,t,n){return(t=eJ(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function eJ(e){var t=tJ(e,`string`);return typeof t==`symbol`?t:t+``}function tJ(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function nJ(){return nJ=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},nJ.apply(null,arguments)}function rJ(e,t){return cJ(e)||sJ(e,t)||aJ(e,t)||iJ()}function iJ(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
74
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function aJ(e,t){if(e){if(typeof e==`string`)return oJ(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?oJ(e,t):void 0}}function oJ(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function sJ(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function cJ(e){if(Array.isArray(e))return e}var lJ=()=>(QF(),null);function uJ(e){if(typeof e==`number`)return e;if(typeof e==`string`){var t=parseFloat(e);if(!Number.isNaN(t))return t}return 0}var dJ=(0,v.forwardRef)((e,t)=>{var n=(0,v.useRef)(null),r=rJ((0,v.useState)({containerWidth:uJ(e.style?.width),containerHeight:uJ(e.style?.height)}),2),i=r[0],a=r[1],o=(0,v.useCallback)((e,t)=>{a(n=>{var r=Math.round(e),i=Math.round(t);return n.containerWidth===r&&n.containerHeight===i?n:{containerWidth:r,containerHeight:i}})},[]),s=(0,v.useCallback)(e=>{if(typeof t==`function`&&t(e),n.current!=null&&(n.current.disconnect(),n.current=null),e!=null&&typeof ResizeObserver<`u`){var r=e.getBoundingClientRect(),i=r.width,a=r.height;o(i,a);var s=new ResizeObserver(e=>{var t=e[0];if(t!=null){var n=t.contentRect,r=n.width,i=n.height;o(r,i)}});s.observe(e),n.current=s}},[t,o]);return(0,v.useEffect)(()=>()=>{n.current?.disconnect()},[o]),v.createElement(v.Fragment,null,v.createElement(sv,{width:i.containerWidth,height:i.containerHeight}),v.createElement(`div`,nJ({ref:s},e)))}),fJ=(0,v.forwardRef)((e,t)=>{var n=e.width,r=e.height,i=rJ((0,v.useState)({containerWidth:uJ(n),containerHeight:uJ(r)}),2),a=i[0],o=i[1],s=(0,v.useCallback)((e,t)=>{o(n=>{var r=Math.round(e),i=Math.round(t);return n.containerWidth===r&&n.containerHeight===i?n:{containerWidth:r,containerHeight:i}})},[]),c=(0,v.useCallback)(e=>{if(typeof t==`function`&&t(e),e!=null){var n=e.getBoundingClientRect(),r=n.width,i=n.height;s(r,i)}},[t,s]);return v.createElement(v.Fragment,null,v.createElement(sv,{width:a.containerWidth,height:a.containerHeight}),v.createElement(`div`,nJ({ref:c},e)))}),pJ=(0,v.forwardRef)((e,t)=>{var n=e.width,r=e.height;return v.createElement(v.Fragment,null,v.createElement(sv,{width:n,height:r}),v.createElement(`div`,nJ({ref:t},e)))}),mJ=(0,v.forwardRef)((e,t)=>{var n=e.width,r=e.height;return typeof n==`string`||typeof r==`string`?v.createElement(fJ,nJ({},e,{ref:t})):typeof n==`number`&&typeof r==`number`?v.createElement(pJ,nJ({},e,{width:n,height:r,ref:t})):v.createElement(v.Fragment,null,v.createElement(sv,{width:n,height:r}),v.createElement(`div`,nJ({ref:t},e)))});function hJ(e){return e?dJ:mJ}var gJ=(0,v.forwardRef)((e,t)=>{var n=e.children,r=e.className,i=e.height,a=e.onClick,o=e.onContextMenu,s=e.onDoubleClick,c=e.onMouseDown,l=e.onMouseEnter,u=e.onMouseLeave,d=e.onMouseMove,f=e.onMouseUp,p=e.onTouchEnd,m=e.onTouchMove,h=e.onTouchStart,g=e.style,_=e.width,y=e.responsive,b=e.dispatchTouchEvents,x=b===void 0?!0:b,S=(0,v.useRef)(null),C=jf(),w=rJ((0,v.useState)(null),2),T=w[0],E=w[1],D=rJ((0,v.useState)(null),2),O=D[0],k=D[1],A=Xq(),j=K_(),M=j?.width>0?j.width:_,N=j?.height>0?j.height:i,P=(0,v.useCallback)(e=>{A(e),typeof t==`function`&&t(e),E(e),k(e),e!=null&&(S.current=e)},[A,t,E,k]),F=(0,v.useCallback)(e=>{C(HK(e)),C(dq({handler:a,reactEvent:e}))},[C,a]),I=(0,v.useCallback)(e=>{C(WK(e)),C(dq({handler:l,reactEvent:e}))},[C,l]),L=(0,v.useCallback)(e=>{C(oN()),C(dq({handler:u,reactEvent:e}))},[C,u]),ee=(0,v.useCallback)(e=>{C(WK(e)),C(dq({handler:d,reactEvent:e}))},[C,d]),te=(0,v.useCallback)(()=>{C(iq())},[C]),R=(0,v.useCallback)(()=>{C(aq())},[C]),z=(0,v.useCallback)(e=>{C(rq(e.key))},[C]),ne=(0,v.useCallback)(e=>{C(dq({handler:o,reactEvent:e}))},[C,o]),B=(0,v.useCallback)(e=>{C(dq({handler:s,reactEvent:e}))},[C,s]),V=(0,v.useCallback)(e=>{C(dq({handler:c,reactEvent:e}))},[C,c]),re=(0,v.useCallback)(e=>{C(dq({handler:f,reactEvent:e}))},[C,f]),ie=(0,v.useCallback)(e=>{C(dq({handler:h,reactEvent:e}))},[C,h]),ae=(0,v.useCallback)(e=>{x&&C(_q(e)),C(dq({handler:m,reactEvent:e}))},[C,x,m]),oe=(0,v.useCallback)(e=>{C(dq({handler:p,reactEvent:e}))},[C,p]),se=hJ(y);return v.createElement(EF.Provider,{value:T},v.createElement(Ll.Provider,{value:O},v.createElement(se,{width:M??g?.width,height:N??g?.height,className:vl(`recharts-wrapper`,r),style:Qq({position:`relative`,cursor:`default`,width:M,height:N},g),onClick:F,onContextMenu:ne,onDoubleClick:B,onFocus:te,onBlur:R,onKeyDown:z,onMouseDown:V,onMouseEnter:I,onMouseLeave:L,onMouseMove:ee,onMouseUp:re,onTouchEnd:oe,onTouchMove:ae,onTouchStart:ie,ref:P},v.createElement(lJ,null),n)))}),_J=[`width`,`height`,`responsive`,`children`,`className`,`style`,`compact`,`title`,`desc`];function vJ(e,t){if(e==null)return{};var n,r,i=yJ(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function yJ(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}var bJ=(0,v.forwardRef)((e,t)=>{var n=e.width,r=e.height,i=e.responsive,a=e.children,o=e.className,s=e.style,c=e.compact,l=e.title,u=e.desc,d=wl(vJ(e,_J));return c?v.createElement(v.Fragment,null,v.createElement(sv,{width:n,height:r}),v.createElement(Uq,{otherAttributes:d,title:l,desc:u},a)):v.createElement(gJ,{className:o,style:s,width:n,height:r,responsive:i??!1,onClick:e.onClick,onMouseLeave:e.onMouseLeave,onMouseEnter:e.onMouseEnter,onMouseMove:e.onMouseMove,onMouseDown:e.onMouseDown,onMouseUp:e.onMouseUp,onContextMenu:e.onContextMenu,onDoubleClick:e.onDoubleClick,onTouchStart:e.onTouchStart,onTouchMove:e.onTouchMove,onTouchEnd:e.onTouchEnd},v.createElement(Uq,{otherAttributes:d,title:l,desc:u,ref:t},v.createElement(WU,null,a)))});function xJ(){return xJ=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},xJ.apply(null,arguments)}function SJ(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function CJ(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?SJ(Object(n),!0).forEach(function(t){wJ(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):SJ(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function wJ(e,t,n){return(t=TJ(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function TJ(e){var t=EJ(e,`string`);return typeof t==`symbol`?t:t+``}function EJ(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var DJ=CJ({accessibilityLayer:!0,barCategoryGap:`10%`,barGap:4,layout:`horizontal`,margin:{top:5,right:5,bottom:5,left:5},responsive:!1,reverseStackOrder:!1,stackOffset:`none`,syncMethod:`index`},Cq),OJ=(0,v.forwardRef)(function(e,t){var n=hd(e.categoricalChartProps,DJ),r=e.chartName,i=e.defaultTooltipEventType,a=e.validateTooltipEventTypes,o=e.tooltipPayloadSearcher,s=e.categoricalChartProps,c={chartName:r,defaultTooltipEventType:i,validateTooltipEventTypes:a,tooltipPayloadSearcher:o,eventEmitter:void 0};return v.createElement(kq,{preloadedState:{options:c},reduxStoreName:s.id??r},v.createElement(OU,{chartData:s.data}),v.createElement(jq,{layout:n.layout,margin:n.margin}),v.createElement(Nq,{throttleDelay:n.throttleDelay,throttledEvents:n.throttledEvents}),v.createElement(Mq,{baseValue:n.baseValue,accessibilityLayer:n.accessibilityLayer,barCategoryGap:n.barCategoryGap,maxBarSize:n.maxBarSize,stackOffset:n.stackOffset,barGap:n.barGap,barSize:n.barSize,syncId:n.syncId,syncMethod:n.syncMethod,className:n.className,reverseStackOrder:n.reverseStackOrder}),v.createElement(bJ,xJ({},n,{ref:t})))});function kJ(e){var t=jf();return(0,v.useEffect)(()=>{t(tq(e))},[t,e]),null}var AJ=[`layout`];function jJ(){return jJ=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},jJ.apply(null,arguments)}function MJ(e,t){if(e==null)return{};var n,r,i=NJ(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function NJ(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function PJ(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function FJ(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?PJ(Object(n),!0).forEach(function(t){IJ(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):PJ(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function IJ(e,t,n){return(t=LJ(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function LJ(e){var t=RJ(e,`string`);return typeof t==`symbol`?t:t+``}function RJ(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var zJ=FJ({accessibilityLayer:!0,stackOffset:`none`,barCategoryGap:`10%`,barGap:4,margin:{top:5,right:5,bottom:5,left:5},reverseStackOrder:!1,syncMethod:`index`,layout:`radial`,responsive:!1,cx:`50%`,cy:`50%`,innerRadius:0,outerRadius:`80%`},Cq),BJ=(0,v.forwardRef)(function(e,t){var n=hd(e.categoricalChartProps,zJ),r=n.layout,i=MJ(n,AJ),a=e.chartName,o={chartName:a,defaultTooltipEventType:e.defaultTooltipEventType,validateTooltipEventTypes:e.validateTooltipEventTypes,tooltipPayloadSearcher:e.tooltipPayloadSearcher,eventEmitter:void 0};return v.createElement(kq,{preloadedState:{options:o},reduxStoreName:n.id??a},v.createElement(OU,{chartData:n.data}),v.createElement(jq,{layout:r,margin:n.margin}),v.createElement(Nq,{throttleDelay:n.throttleDelay,throttledEvents:n.throttledEvents}),v.createElement(Mq,{baseValue:void 0,accessibilityLayer:n.accessibilityLayer,barCategoryGap:n.barCategoryGap,maxBarSize:n.maxBarSize,stackOffset:n.stackOffset,barGap:n.barGap,barSize:n.barSize,syncId:n.syncId,syncMethod:n.syncMethod,className:n.className,reverseStackOrder:n.reverseStackOrder}),v.createElement(kJ,{cx:n.cx,cy:n.cy,startAngle:n.startAngle,endAngle:n.endAngle,innerRadius:n.innerRadius,outerRadius:n.outerRadius}),v.createElement(bJ,jJ({},i,{ref:t})))});function VJ(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function HJ(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?VJ(Object(n),!0).forEach(function(t){UJ(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):VJ(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function UJ(e,t,n){return(t=WJ(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function WJ(e){var t=GJ(e,`string`);return typeof t==`symbol`?t:t+``}function GJ(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var KJ=[`item`],qJ=HJ(HJ({},zJ),{},{layout:`centric`,startAngle:0,endAngle:360}),JJ=(0,v.forwardRef)((e,t)=>{var n=hd(e,qJ);return v.createElement(BJ,{chartName:`PieChart`,defaultTooltipEventType:`item`,validateTooltipEventTypes:KJ,tooltipPayloadSearcher:MF,categoricalChartProps:n,ref:t})}),YJ=[`axis`],XJ=(0,v.forwardRef)((e,t)=>v.createElement(OJ,{chartName:`AreaChart`,defaultTooltipEventType:`axis`,validateTooltipEventTypes:YJ,tooltipPayloadSearcher:MF,categoricalChartProps:e,ref:t}));function ZJ(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function QJ(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?ZJ(Object(n),!0).forEach(function(t){$J(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ZJ(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function $J(e,t,n){return(t=eY(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function eY(e){var t=tY(e,`string`);return typeof t==`symbol`?t:t+``}function tY(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var nY=[`axis`,`item`],rY=QJ(QJ({},zJ),{},{layout:`radial`,startAngle:0,endAngle:360}),iY=(0,v.forwardRef)((e,t)=>{var n=hd(e,rY);return v.createElement(BJ,{chartName:`RadialBarChart`,defaultTooltipEventType:`axis`,validateTooltipEventTypes:nY,tooltipPayloadSearcher:MF,categoricalChartProps:n,ref:t})}),aY=e=>new Date(e).toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`,hour12:!1});function oY({active:e,payload:t,label:n,unit:r}){return!e||!t?.length?null:(0,q.jsxs)(`div`,{className:`chart-tip`,children:[n!=null&&(0,q.jsx)(`div`,{className:`chart-tip__label`,children:n}),t.map((e,t)=>(0,q.jsxs)(`div`,{className:`chart-tip__row`,children:[(0,q.jsx)(`span`,{className:`chart-tip__dot`,style:{background:e.color}}),(0,q.jsx)(`span`,{className:`chart-tip__name`,children:e.name??e.dataKey}),(0,q.jsxs)(`span`,{className:`chart-tip__val`,children:[typeof e.value==`number`?e.value.toLocaleString():e.value,r??``]})]},t))]})}var sY=`color-mix(in srgb, var(--mt-border) 80%, transparent)`,cY={fill:`var(--mt-text-faint)`,fontSize:10,fontFamily:`var(--mt-mono)`};function lY({series:e}){return(0,q.jsx)(`div`,{className:`chart`,style:{height:200},children:(0,q.jsx)(J_,{width:`100%`,height:`100%`,children:(0,q.jsxs)(XJ,{data:e,margin:{top:8,right:8,left:-18,bottom:0},children:[(0,q.jsxs)(`defs`,{children:[(0,q.jsxs)(`linearGradient`,{id:`fillOk`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,q.jsx)(`stop`,{offset:`0%`,stopColor:`var(--page-accent)`,stopOpacity:.5}),(0,q.jsx)(`stop`,{offset:`100%`,stopColor:`var(--page-accent)`,stopOpacity:.04})]}),(0,q.jsxs)(`linearGradient`,{id:`fillErr`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,q.jsx)(`stop`,{offset:`0%`,stopColor:`var(--mt-bad)`,stopOpacity:.55}),(0,q.jsx)(`stop`,{offset:`100%`,stopColor:`var(--mt-bad)`,stopOpacity:.05})]})]}),(0,q.jsx)(iG,{vertical:!1,stroke:sY,strokeDasharray:`3 3`}),(0,q.jsx)(CK,{dataKey:`t`,tickFormatter:aY,tick:cY,tickLine:!1,axisLine:!1,minTickGap:48}),(0,q.jsx)(RK,{tick:cY,tickLine:!1,axisLine:!1,width:34,allowDecimals:!1}),(0,q.jsx)(hI,{cursor:{stroke:sY},content:({active:e,payload:t,label:n})=>(0,q.jsx)(oY,{active:e,payload:t,label:typeof n==`number`?aY(n):n})}),(0,q.jsx)(nK,{type:`monotone`,dataKey:`ok`,name:`ok`,stackId:`1`,stroke:`var(--page-accent)`,fill:`url(#fillOk)`,strokeWidth:2,isAnimationActive:!1}),(0,q.jsx)(nK,{type:`monotone`,dataKey:`error`,name:`error`,stackId:`1`,stroke:`var(--mt-bad)`,fill:`url(#fillErr)`,strokeWidth:2,isAnimationActive:!1})]})})})}function uY({segments:e,centerLabel:t=`calls`}){let n=e.filter(e=>e.value>0),r=e.reduce((e,t)=>e+t.value,0);return(0,q.jsxs)(`div`,{className:`chart chart--donut`,children:[(0,q.jsx)(`div`,{className:`chart-donut__svg`,children:(0,q.jsx)(J_,{width:`100%`,height:180,children:(0,q.jsxs)(JJ,{children:[(0,q.jsx)(hI,{content:({active:e,payload:t})=>(0,q.jsx)(oY,{active:e,payload:t})}),(0,q.jsx)(OV,{data:n,dataKey:`value`,nameKey:`label`,innerRadius:58,outerRadius:80,paddingAngle:2,strokeWidth:0,isAnimationActive:!1,children:n.map(e=>(0,q.jsx)(gI,{fill:e.color},e.label))}),(0,q.jsx)(`text`,{x:`50%`,y:`47%`,textAnchor:`middle`,fill:`var(--mt-text)`,fontSize:22,fontWeight:600,children:r.toLocaleString()}),(0,q.jsx)(`text`,{x:`50%`,y:`59%`,textAnchor:`middle`,fill:`var(--mt-text-dim)`,fontSize:10,children:t})]})})}),(0,q.jsx)(`div`,{className:`chart-legend`,children:n.map(e=>(0,q.jsxs)(`span`,{children:[(0,q.jsx)(`i`,{style:{background:e.color}}),e.label,` `,(0,q.jsx)(`b`,{children:e.value})]},e.label))})]})}function dY({values:e,color:t,unit:n,maxValue:r,id:i}){let a=e.filter(e=>e!=null);if(a.length===0)return(0,q.jsx)(`div`,{className:`spark spark--empty`,children:`no samples yet`});let o=e.map((e,t)=>({i:t,v:e})),s=a[a.length-1],c=`ma-${(i??t).replace(/[^a-z0-9]/gi,``)}`,l=Math.min(...a),u=Math.max(...a),d=Math.max(0,(n===`%`?10:0)-(u-l))/2,f=l-d,p=u+d,m=(p-f)*.15||1;return f=Math.max(0,f-m),p+=m,r!=null&&(p=Math.min(r,p)),p<=f&&(p=f+1),(0,q.jsxs)(`div`,{className:`chart chart--spark`,children:[(0,q.jsxs)(`span`,{className:`chart-spark__last`,style:{color:t},children:[s.toFixed(n===`%`?0:1),n??``]}),(0,q.jsx)(J_,{width:`100%`,height:46,children:(0,q.jsxs)(XJ,{data:o,margin:{top:4,right:2,left:2,bottom:0},children:[(0,q.jsx)(`defs`,{children:(0,q.jsxs)(`linearGradient`,{id:c,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,q.jsx)(`stop`,{offset:`0%`,stopColor:t,stopOpacity:.35}),(0,q.jsx)(`stop`,{offset:`100%`,stopColor:t,stopOpacity:0})]})}),(0,q.jsx)(RK,{hide:!0,domain:[f,p]}),(0,q.jsx)(hI,{cursor:{stroke:sY},content:({active:e,payload:r})=>(0,q.jsx)(oY,{active:e,payload:r?.map(e=>({...e,name:`value`,color:t})),unit:n})}),(0,q.jsx)(nK,{type:`monotone`,dataKey:`v`,stroke:t,fill:`url(#${c})`,strokeWidth:1.7,connectNulls:!1,isAnimationActive:!1,dot:!1})]})})]})}function fY({value:e,label:t,color:n}){let r=e!=null,i=r?Math.max(0,Math.min(100,e)):0;return(0,q.jsxs)(`div`,{className:`gauge`,children:[(0,q.jsxs)(`div`,{className:`gauge__radial`,children:[(0,q.jsx)(J_,{width:72,height:72,children:(0,q.jsxs)(iY,{data:[{name:t,value:i,fill:n}],innerRadius:`72%`,outerRadius:`100%`,startAngle:90,endAngle:-270,barSize:7,children:[(0,q.jsx)(Cz,{type:`number`,domain:[0,100],tick:!1,axisLine:!1}),(0,q.jsx)(DU,{dataKey:`value`,cornerRadius:4,background:{fill:`var(--mt-surface-2)`},isAnimationActive:!1})]})}),(0,q.jsx)(`span`,{className:`gauge__pct`,style:{color:r?`var(--mt-text)`:`var(--mt-text-faint)`},children:r?`${Math.round(i)}%`:`n/a`})]}),(0,q.jsx)(`span`,{className:`gauge__label`,children:t})]})}var pY=40,mY=30,hY=1e3,gY=`http://www.w3.org/2000/svg`,_Y=e=>`${(e/1e6).toFixed(2)} Mbps`,vY=e=>e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(0)}k`:e>0?`${Math.round(e)}`:`0`;function yY({history:e}){let t=Math.max(1,...e.flatMap(e=>[e.rx,e.tx])),n=e=>8+e*504/Math.max(1,pY-1),r=e=>142-e/t*134,i=t=>e.map((e,i)=>`${n(i).toFixed(1)},${r(t(e)).toFixed(1)}`).join(` `),a=t=>{if(e.length<2)return``;let r=n(0).toFixed(1),a=n(e.length-1).toFixed(1);return`${r},${142 .toFixed(1)} ${i(t)} ${a},${142 .toFixed(1)}`};return(0,q.jsx)(`svg`,{className:`clients-chart`,viewBox:`0 0 520 150`,xmlns:gY,role:`img`,children:e.length>=2&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`polygon`,{className:`rx area`,points:a(e=>e.rx)}),(0,q.jsx)(`polygon`,{className:`tx area`,points:a(e=>e.tx)}),(0,q.jsx)(`polyline`,{className:`rx line`,points:i(e=>e.rx)}),(0,q.jsx)(`polyline`,{className:`tx line`,points:i(e=>e.tx)})]})})}function bY({history:e}){if(e.length<2)return(0,q.jsx)(`svg`,{className:`mini-spark`,viewBox:`0 0 80 18`});let t=Math.max(1,...e.flatMap(e=>[e.rx,e.tx])),n=e=>1+e*78/Math.max(1,mY-1),r=e=>17-e/t*16,i=t=>e.map((e,i)=>`${n(i).toFixed(1)},${r(t(e)).toFixed(1)}`).join(` `),a=t=>{let r=n(0).toFixed(1),a=n(e.length-1).toFixed(1),o=17 .toFixed(1);return`${r},${o} ${i(t)} ${a},${o}`};return(0,q.jsxs)(`svg`,{className:`mini-spark`,viewBox:`0 0 80 18`,xmlns:gY,children:[(0,q.jsx)(`polygon`,{className:`rx area`,points:a(e=>e.rx)}),(0,q.jsx)(`polygon`,{className:`tx area`,points:a(e=>e.tx)}),(0,q.jsx)(`polyline`,{className:`rx line`,points:i(e=>e.rx)}),(0,q.jsx)(`polyline`,{className:`tx line`,points:i(e=>e.tx)})]})}function xY({ip:e,deviceName:t,current:n,onSaved:r}){let[i,a]=(0,v.useState)(n.download),[o,s]=(0,v.useState)(n.upload),[c,l]=(0,v.useState)(!1),[u,d]=(0,v.useState)(!1),[f,p]=(0,v.useState)(null);(0,v.useEffect)(()=>{c||(a(n.download),s(n.upload))},[n.download,n.upload,c]);let m=(0,v.useCallback)(async(n,i)=>{d(!0),p(null);try{let a=await mc(`/api/clients/limits`,{ip:e,device:t,download:n,upload:i});p(a.message),a.ok&&(l(!1),r())}catch(e){p(e instanceof Error?e.message:String(e))}finally{d(!1)}},[e,t,r]),h=!!(n.download||n.upload);return(0,q.jsxs)(`div`,{className:`clients-limits`,children:[(0,q.jsxs)(`div`,{className:`clients-limits__hd`,children:[(0,q.jsx)(`span`,{className:`clients-limits__label`,children:`Rate limits`}),(0,q.jsxs)(`span`,{className:`muted`,children:[`current: ↓ `,n.download||`unlimited`,` · ↑ `,n.upload||`unlimited`]})]}),(0,q.jsxs)(`div`,{className:`clients-limits__row`,children:[(0,q.jsxs)(`label`,{className:`clients-limits__field`,children:[(0,q.jsx)(`span`,{className:`muted`,children:`↓ Download`}),(0,q.jsx)(Ic,{placeholder:`10M · blank = unlimited`,value:i,onChange:e=>{l(!0),a(e.target.value)}})]}),(0,q.jsxs)(`label`,{className:`clients-limits__field`,children:[(0,q.jsx)(`span`,{className:`muted`,children:`↑ Upload`}),(0,q.jsx)(Ic,{placeholder:`2M · blank = unlimited`,value:o,onChange:e=>{l(!0),s(e.target.value)}})]}),(0,q.jsx)(jc,{size:`sm`,type:`accent`,loading:u,onClick:()=>void m(i,o),children:`Apply`}),(0,q.jsx)(jc,{size:`sm`,ghost:!0,disabled:u||!h,onClick:()=>{a(``),s(``),m(``,``)},children:`Remove`})]}),f&&(0,q.jsx)(`div`,{className:`muted clients-limits__msg`,children:f})]})}function SY({device:e,deviceName:t,traffic:n}){let r=n!==void 0;return(0,q.jsxs)(`div`,{className:`clients-detail`,children:[(0,q.jsxs)(`div`,{className:`clients-detail__hd`,children:[(0,q.jsx)(`span`,{className:`clients-detail__title`,children:e.host||e.comment||e.ip}),(0,q.jsxs)(`span`,{className:`muted`,children:[e.ip||`no IP`,` · `,e.mac,` · `,e.iface||`?`,` · `,e.status]})]}),r?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`div`,{className:`clients-rates`,children:[(0,q.jsxs)(`span`,{className:`rate rx`,children:[`↓ `,_Y(n.rxRate)]}),(0,q.jsxs)(`span`,{className:`rate tx`,children:[`↑ `,_Y(n.txRate)]})]}),(0,q.jsx)(yY,{history:n.history}),(0,q.jsxs)(`div`,{className:`muted clients-totals`,children:[`total ↓ `,Cc(n.rxBytes),` · ↑ `,Cc(n.txBytes)]})]}):(0,q.jsxs)(Mc,{type:`secondary`,label:`No per-device counter`,children:[`Set a rate limit below to start tracking this device's Download/Upload (it creates a simple queue targeting `,(0,q.jsx)(`code`,{children:e.ip}),`), or leave it unlimited.`]}),e.ip&&(0,q.jsx)(xY,{ip:e.ip,deviceName:t,current:{download:n?.downloadLimit??``,upload:n?.uploadLimit??``},onSaved:()=>{}}),e.ip&&(0,q.jsxs)(`div`,{className:`clients-history`,children:[(0,q.jsx)(`div`,{className:`clients-history__hd`,children:`Usage history · last 3 months`}),(0,q.jsx)(Wc,{endpoint:`/api/usage/client?ip=${encodeURIComponent(e.ip)}${t?`&device=${encodeURIComponent(t)}`:``}&days=90`,days:90})]})]})}function CY(e){let[t,n]=(0,v.useState)(new Map),r=(0,v.useRef)(null);return(0,v.useEffect)(()=>{r.current=null,n(new Map)},[e]),(0,v.useEffect)(()=>{if(!e)return;let t=!1,i=async()=>{try{let i=await pc(`/api/clients/traffic-bulk${e?`?device=${encodeURIComponent(e)}`:``}`);if(t)return;let a=r.current;if(r.current={ts:i.ts,queues:i.queues},!a)return;let o=Math.max(.1,(i.ts-a.ts)/1e3);n(e=>{let t=new Map;for(let[n,r]of Object.entries(i.queues)){let i=a.queues[n],s=e.get(n),c=i?Math.max(0,r.rxBytes-i.rxBytes):0,l=i?Math.max(0,r.txBytes-i.txBytes):0,u=c/o*8,d=l/o*8,f=[...s?.history??[],{rx:u,tx:d}].slice(-30);t.set(n,{rxRate:u,txRate:d,rxBytes:r.rxBytes,txBytes:r.txBytes,downloadLimit:r.downloadLimit,uploadLimit:r.uploadLimit,history:f})}return t})}catch{}};i();let a=setInterval(()=>void i(),hY);return()=>{t=!0,clearInterval(a)}},[e]),t}function wY(){let[e,t]=(0,v.useState)(null),[n,r]=(0,v.useState)(``),[i,a]=(0,v.useState)(null),[o,s]=(0,v.useState)(null),[c,l]=(0,v.useState)(null),[u,d]=(0,v.useState)(null),[f,p]=(0,v.useState)(``),[m,h]=(0,v.useState)(null),g=CY(n);(0,v.useEffect)(()=>{pc(`/api/devices`).then(e=>{t(e),r(t=>t||e.defaultDevice||e.devices[0]?.name||``)}).catch(()=>t({server:``,defaultDevice:``,devices:[]}))},[]);let _=(0,v.useCallback)(async()=>{try{let e=n?`?device=${encodeURIComponent(n)}`:``;a(await pc(`/api/clients${e}`)),d(null)}catch(e){d(e instanceof Error?e.message:String(e))}},[n]);(0,v.useEffect)(()=>{a(null),s(null),_();let e=setInterval(()=>void _(),15e3);return()=>clearInterval(e)},[_]);let y=(0,v.useCallback)(async(e,t,r)=>{l(t),d(null);try{let i=await mc(`/api/clients/${e}`,{mac:t,device:n,...r});i.view?a(i.view):await _(),i.ok||d(i.message)}catch(e){d(e instanceof Error?e.message:String(e))}finally{l(null)}},[n,_]),b=(0,v.useCallback)((e,t)=>{s(e.mac),h({mac:e.mac,field:t,value:t===`ip`?e.ip:e.comment||e.host})},[]),x=(0,v.useCallback)(async()=>{if(!m)return;let e=m.value.trim();m.field===`ip`?e&&await y(`set-ip`,m.mac,{ip:e}):await y(`label`,m.mac,{label:e}),h(null)},[m,y]),S=(0,v.useMemo)(()=>{let e=i?.devices??[],t=f.trim().toLowerCase();return t?e.filter(e=>e.ip.toLowerCase().includes(t)||e.mac.toLowerCase().includes(t)||e.host.toLowerCase().includes(t)||e.comment.toLowerCase().includes(t)):e},[i,f]),C=(0,v.useMemo)(()=>i?.devices.find(e=>e.mac===o)??null,[i,o]),w=e?.devices??[],T=i?.counts;return(0,q.jsx)(`section`,{className:`view`,children:(0,q.jsxs)(_c,{title:`Connected clients`,className:`reveal`,extra:(0,q.jsxs)(`div`,{className:`clients-toolbar`,children:[w.length>1&&(0,q.jsx)(Lc,{value:n,onChange:e=>r(e.target.value),"aria-label":`Router`,children:w.map(e=>(0,q.jsxs)(`option`,{value:e.name,children:[e.name,e.isDefault?` (default)`:``]},e.name))}),(0,q.jsx)(`input`,{className:`geist-input`,placeholder:`Filter IP / MAC / name…`,value:f,onChange:e=>p(e.target.value)}),(0,q.jsx)(jc,{size:`sm`,ghost:!0,onClick:()=>void _(),children:`↻ Refresh`})]}),children:[T&&(0,q.jsxs)(`div`,{className:`clients-counts muted`,children:[T.total,` total · `,T.static,` static · `,T.blocked,` blocked`]}),u&&(0,q.jsx)(Mc,{type:`error`,className:`clients-error`,children:u}),i?S.length===0?(0,q.jsxs)(`div`,{className:`feed-empty`,children:[(0,q.jsx)(`div`,{className:`feed-empty__icon`,children:`📡`}),(0,q.jsx)(`p`,{className:`feed-empty__title`,children:`No connected devices`}),(0,q.jsxs)(`p`,{className:`feed-empty__sub`,children:[`Nothing in this router's DHCP-lease or ARP table`,f?` matches the filter`:``,`.`]})]}):(0,q.jsxs)(`div`,{className:`clients-table`,children:[(0,q.jsxs)(`div`,{className:`clients-row clients-row--head`,children:[(0,q.jsx)(`span`,{children:`IP`}),(0,q.jsx)(`span`,{children:`Name`}),(0,q.jsx)(`span`,{children:`MAC`}),(0,q.jsx)(`span`,{children:`Iface`}),(0,q.jsx)(`span`,{children:`Status`}),(0,q.jsx)(`span`,{children:`Traffic`}),(0,q.jsx)(`span`,{className:`clients-actions-h`,children:`Actions`})]}),S.map(e=>{let t=e.mac===o,n=c===e.mac,r=e.ip?g.get(e.ip):void 0;return(0,q.jsxs)(`div`,{className:[`clients-row`,t?`is-selected`:``,e.blocked?`is-blocked`:``].filter(Boolean).join(` `),onClick:()=>s(t?null:e.mac),children:[(0,q.jsx)(`span`,{className:`clients-ip`,children:e.ip||`—`}),(0,q.jsx)(`span`,{className:`clients-name`,children:e.host||e.comment||`(unknown)`}),(0,q.jsx)(`span`,{className:`clients-mac`,children:e.mac}),(0,q.jsx)(`span`,{className:`muted`,children:e.iface||``}),(0,q.jsxs)(`span`,{className:`clients-badges`,children:[e.static&&(0,q.jsx)(Nc,{type:`secondary`,children:`static`}),e.blocked?(0,q.jsx)(Nc,{type:`error`,children:`blocked`}):(0,q.jsx)(`span`,{className:`muted`,children:e.status})]}),(0,q.jsx)(`span`,{className:`clients-traffic`,children:r?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`span`,{className:`clients-traffic__rates`,children:[(0,q.jsxs)(`span`,{className:`rx`,children:[`↓`,vY(r.rxRate)]}),(0,q.jsxs)(`span`,{className:`tx`,children:[`↑`,vY(r.txRate)]})]}),(0,q.jsx)(bY,{history:r.history})]}):(0,q.jsx)(`span`,{className:`muted`,children:e.ip?`—`:``})}),(0,q.jsxs)(`span`,{className:`clients-actions`,onClick:e=>e.stopPropagation(),role:`presentation`,children:[e.blocked?(0,q.jsx)(jc,{size:`sm`,type:`success`,ghost:!0,loading:n,onClick:()=>void y(`allow`,e.mac),children:`Allow`}):(0,q.jsx)(jc,{size:`sm`,type:`error`,ghost:!0,loading:n,onClick:()=>void y(`block`,e.mac),children:`Block`}),!e.static&&(0,q.jsx)(jc,{size:`sm`,ghost:!0,loading:n,onClick:()=>void y(`pin`,e.mac),children:`Pin IP`}),(0,q.jsx)(jc,{size:`sm`,ghost:!0,disabled:n,onClick:()=>b(e,`ip`),children:`Set IP`}),(0,q.jsx)(jc,{size:`sm`,ghost:!0,disabled:n,onClick:()=>b(e,`label`),children:`Label`})]})]},e.mac)})]}):(0,q.jsx)(`div`,{className:`muted`,children:`loading connected devices…`}),m&&C?.mac===m.mac&&(0,q.jsxs)(`div`,{className:`clients-edit`,children:[(0,q.jsxs)(`span`,{className:`clients-edit__label`,children:[m.field===`ip`?`Reserve IP for`:`Label for`,` `,(0,q.jsx)(`b`,{children:C.host||C.mac}),`:`]}),(0,q.jsx)(Ic,{autoFocus:!0,value:m.value,placeholder:m.field===`ip`?`e.g. 192.168.88.50`:`e.g. Ali phone`,onChange:e=>h({...m,value:e.target.value}),onKeyDown:e=>{e.key===`Enter`&&x(),e.key===`Escape`&&h(null)}}),(0,q.jsx)(jc,{size:`sm`,type:`accent`,loading:c===m.mac,onClick:()=>void x(),children:`Save`}),(0,q.jsx)(jc,{size:`sm`,ghost:!0,onClick:()=>h(null),children:`Cancel`})]}),C&&(0,q.jsx)(SY,{device:C,deviceName:n,traffic:C.ip?g.get(C.ip):void 0})]})})}function TY(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function EY(e){return new Date(e).toLocaleString(void 0,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`,hour12:!1})}function DY({onRestored:e}){let[t,n]=(0,v.useState)(null),[r,i]=(0,v.useState)(null),[a,o]=(0,v.useState)(!1),[s,c]=(0,v.useState)(null),[l,u]=(0,v.useState)(null),[d,f]=(0,v.useState)(null),[p,m]=(0,v.useState)(null),h=(0,v.useCallback)(()=>{pc(`/api/config/history`).then(n).catch(()=>n({versions:[],bytes:0,retention:50}))},[]);(0,v.useEffect)(()=>h(),[h]);let g=(e,t)=>mc(e,t).catch(()=>({error:`request failed`})),_=async()=>{let e=(p??``).trim();m(null);let t=await g(`/api/config/history/checkpoint`,{label:e||void 0});i(t.ok?`Checkpoint saved${e?` · “${e}”`:``}`:`Failed: ${t.error}`),t.ok&&h()},y=async e=>{if(s===e){c(null),u(null);return}c(e),u(null);let t=await pc(`/api/config/history/diff?id=${encodeURIComponent(e)}`).catch(()=>null);u(t)},b=async t=>{f(null),o(!0);let n=await g(`/api/config/history/restore`,{id:t});o(!1),i(n.ok?`Restored ${t}${n.persisted===!1?` (applied live, not persisted)`:``}`:`Restore failed: ${n.error}`),n.ok&&(h(),e())},x=async e=>{let t=await g(`/api/config/history/delete`,{id:e});i(t.ok?`Version deleted`:`Failed: ${t.error}`),t.ok&&h()};return t?(0,q.jsxs)(q.Fragment,{children:[r&&(0,q.jsx)(`div`,{className:`cfg-msg`,children:r}),(0,q.jsxs)(`div`,{className:`toolbar`,style:{marginBottom:14},children:[p===null?(0,q.jsx)(`button`,{className:`btn is-active`,onClick:()=>m(``),children:`★ Save checkpoint`}):(0,q.jsxs)(`span`,{className:`cfgver-cp`,children:[(0,q.jsx)(`input`,{className:`backup-path-input`,autoFocus:!0,placeholder:`checkpoint name (e.g. pre-upgrade)`,value:p,onChange:e=>m(e.target.value),onKeyDown:e=>{e.key===`Enter`&&_(),e.key===`Escape`&&m(null)}}),(0,q.jsx)(`button`,{className:`topo-btn cfg-save`,onClick:()=>void _(),children:`Save`}),(0,q.jsx)(`button`,{className:`topo-btn`,onClick:()=>m(null),children:`Cancel`})]}),(0,q.jsx)(`span`,{style:{flex:1}}),(0,q.jsxs)(`span`,{className:`muted`,children:[t.versions.length,` versions · `,TY(t.bytes),` · auto-keep `,t.retention]})]}),t.versions.length===0?(0,q.jsx)(`div`,{className:`muted`,children:`No versions yet — they appear here after each config change.`}):(0,q.jsx)(`ol`,{className:`cfgver`,children:t.versions.map((e,t)=>{let n=e.drift.added+e.drift.removed;return(0,q.jsxs)(`li`,{className:`cfgver__row${t===0?` is-head`:``}`,children:[(0,q.jsx)(`span`,{className:`cfgver__dot`,"aria-hidden":`true`}),(0,q.jsxs)(`div`,{className:`cfgver__main`,children:[(0,q.jsxs)(`div`,{className:`cfgver__line`,children:[(0,q.jsx)(`span`,{className:`cfgver__kind cfgver__kind--${e.kind}`,children:e.kind===`checkpoint`?`★ checkpoint`:`auto`}),e.label&&(0,q.jsx)(`span`,{className:`cfgver__label`,children:e.label}),(0,q.jsx)(`span`,{className:`cfgver__time`,children:EY(e.ts)}),t===0?(0,q.jsx)(`span`,{className:`cfgver__cur`,children:`latest`}):n===0?(0,q.jsx)(`span`,{className:`cfgver__same`,children:`identical to current`}):(0,q.jsxs)(`span`,{className:`cfgver__drift`,children:[(0,q.jsxs)(`span`,{className:`add`,children:[`+`,e.drift.added]}),(0,q.jsxs)(`span`,{className:`rem`,children:[`−`,e.drift.removed]}),(0,q.jsx)(`span`,{className:`muted`,children:` vs current`})]})]}),s===e.id&&(0,q.jsx)(`div`,{className:`cfgver__diff`,children:l?l.unified.trim()?(0,q.jsx)(`pre`,{className:`body diff`,children:l.unified}):(0,q.jsx)(`span`,{className:`muted`,children:`No differences from the current config.`}):(0,q.jsx)(`span`,{className:`muted`,children:`computing diff…`})})]}),(0,q.jsxs)(`div`,{className:`cfgver__actions`,children:[(0,q.jsx)(`button`,{className:`topo-btn`,onClick:()=>void y(e.id),children:s===e.id?`Hide`:`Diff`}),d===e.id?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`button`,{className:`topo-btn cfg-save`,disabled:a,onClick:()=>void b(e.id),children:`Confirm restore`}),(0,q.jsx)(`button`,{className:`topo-btn`,onClick:()=>f(null),children:`Cancel`})]}):(0,q.jsx)(`button`,{className:`topo-btn`,disabled:t===0,title:t===0?`This is the current config`:`Restore this version`,onClick:()=>f(e.id),children:`Restore`}),e.kind===`checkpoint`&&(0,q.jsx)(`button`,{className:`topo-btn cfgver__del`,title:`Delete`,onClick:()=>void x(e.id),children:`✕`})]})]},e.id)})})]}):(0,q.jsx)(`div`,{className:`muted`,children:`loading history…`})}function OY(e){if(!e)return[];let t=[],n=e=>e?Array.isArray(e.enum)?`enum`:e.type===`array`?`array<${n(e.items)}>`:Array.isArray(e.type)?e.type.join(` | `):e.type??(e.properties?`object`:`any`):`any`,r=(e,i,a,o)=>{let s=e.properties??{};for(let[e,c]of Object.entries(s)){let s=i?`${i}.${e}`:e,l=a||e;t.push({path:s,section:l,type:n(c),def:c.default===void 0?void 0:JSON.stringify(c.default),desc:c.description,enumv:Array.isArray(c.enum)?c.enum:void 0,required:o.has(e)}),c.properties&&r(c,s,l,new Set(c.required??[]));let u=c.additionalProperties;u?.properties&&r(u,`${s}.<name>`,l,new Set(u.required??[]));let d=c.items;d?.properties&&r(d,`${s}[]`,l,new Set(d.required??[]))}};return r(e,``,``,new Set(e.required??[])),t}function kY(){let[e,t]=(0,v.useState)(null),[n,r]=(0,v.useState)(``);(0,v.useEffect)(()=>{pc(`/api/config-schema`).then(t).catch(()=>{})},[]);let i=(0,v.useMemo)(()=>OY(e),[e]),a=n.trim().toLowerCase(),o=a?i.filter(e=>e.path.toLowerCase().includes(a)||(e.desc??``).toLowerCase().includes(a)):i,s=(0,v.useMemo)(()=>{let e=new Map;for(let t of o){let n=e.get(t.section)??[];n.push(t),e.set(t.section,n)}return[...e.entries()]},[o]);return e?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`div`,{className:`toolbar`,style:{marginBottom:12},children:[(0,q.jsx)(`input`,{className:`backup-path-input`,style:{width:`min(360px, 60vw)`},placeholder:`Search fields & descriptions…`,value:n,onChange:e=>r(e.target.value)}),(0,q.jsx)(`span`,{style:{flex:1}}),(0,q.jsxs)(`span`,{className:`muted`,children:[o.length,` options`]})]}),s.length===0?(0,q.jsxs)(`div`,{className:`muted`,children:[`No fields match “`,n,`”.`]}):(0,q.jsx)(`div`,{className:`fguide`,children:s.map(([e,t])=>(0,q.jsxs)(`div`,{className:`fguide__sec`,children:[(0,q.jsx)(`h4`,{className:`fguide__sechd`,children:e}),(0,q.jsx)(`div`,{className:`fguide__list`,children:t.map(e=>(0,q.jsxs)(`div`,{className:`fguide__item`,children:[(0,q.jsxs)(`div`,{className:`fguide__top`,children:[(0,q.jsx)(`code`,{className:`fguide__path`,children:e.path}),(0,q.jsx)(`span`,{className:`fguide__type`,children:e.type}),e.required&&(0,q.jsx)(`span`,{className:`fguide__req`,children:`required`}),e.def!==void 0&&(0,q.jsxs)(`span`,{className:`fguide__def`,children:[`default `,(0,q.jsx)(`code`,{children:e.def})]})]}),e.desc&&(0,q.jsx)(`p`,{className:`fguide__desc`,children:e.desc}),e.enumv&&(0,q.jsx)(`div`,{className:`fguide__enum`,children:e.enumv.map(e=>(0,q.jsx)(`code`,{children:e},e))})]},e.path))})]},e))})]}):(0,q.jsx)(`div`,{className:`muted`,children:`loading schema…`})}var AY=/("(?:\\.|[^"\\])*"(?:\s*:)?)|\b(true|false|null)\b|(-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?)/g;function jY(e){let t=[],n=0,r=0;for(let i of e.matchAll(AY)){let a=i.index??0;a>n&&t.push(e.slice(n,a));let o=i[0],s;s=i[1]===void 0?i[2]===void 0?`j-num`:o===`null`?`j-null`:`j-bool`:/:\s*$/.test(o)?`j-key`:`j-str`,t.push((0,q.jsx)(`span`,{className:s,children:o},r++)),n=a+o.length}return n<e.length&&t.push(e.slice(n)),t}var MY=new RegExp([/(;;;[^\n]*)/,/("(?:\\.|[^"\\])*")/,/([0-9A-Fa-f]{2}(?::[0-9A-Fa-f]{2}){5})/,/(\d{1,3}(?:\.\d{1,3}){3}(?:\/\d{1,2})?)/,/([A-Za-z.][\w.-]*)(?==)/,/\b(running|enabled|active|connected|established|reachable|bound|authorized|ok|up)\b/,/\b(disabled|invalid|inactive|stopped|unreachable|timeout|failure|failed|error|rejected|expired|down)\b/,/\b(yes|no|true|false)\b/,/\b(dynamic|slave|builtin|default|passthrough|complete)\b/,/(-?\d+(?:\.\d+)?)/].map(e=>e.source).join(`|`),`gi`);function NY(e){let t=[],n=0,r=0;for(let i of e.matchAll(MY)){let a=i.index??0;a>n&&t.push(e.slice(n,a));let o=i[0],s=`ros-num`;i[1]===void 0?i[2]===void 0?i[3]===void 0?i[4]===void 0?i[5]===void 0?i[6]===void 0?i[7]===void 0?i[8]===void 0?i[9]!==void 0&&(s=`ros-dim`):s=`ros-bool`:s=`ros-bad`:s=`ros-good`:s=`ros-key`:s=`ros-ip`:s=`ros-mac`:s=`ros-str`:s=`ros-comment`,t.push((0,q.jsx)(`span`,{className:s,children:o},r++)),n=a+o.length}return n<e.length&&t.push(e.slice(n)),t}var PY=`mt-pretty-input`;function FY(){try{return localStorage.getItem(PY)!==`0`}catch{return!0}}function IY(e){try{localStorage.setItem(PY,e?`1`:`0`)}catch{}}function LY(e,t){if(!t)return e;try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}}function RY({value:e,maxHeight:t}){let n=typeof e==`string`?e:JSON.stringify(e,null,2);return(0,q.jsx)(`pre`,{className:`body json`,style:t?{maxHeight:t}:void 0,children:jY(n)})}function zY(e){let t=new Set,n=new Set,r=e=>{if(!e||typeof e!=`object`)return;let i=e;if(i.properties&&typeof i.properties==`object`)for(let e of Object.keys(i.properties))t.add(e),r(i.properties[e]);if(Array.isArray(i.enum))for(let e of i.enum)typeof e==`string`&&n.add(e);for(let e of[`items`,`additionalProperties`,`anyOf`,`oneOf`,`allOf`]){let t=i[e];Array.isArray(t)?t.forEach(r):t&&typeof t==`object`&&r(t)}for(let e of[`$defs`,`definitions`,`patternProperties`]){let t=i[e];if(t&&typeof t==`object`)for(let e of Object.values(t))r(e)}};return r(e),{keys:[...t].sort(),enums:[...n.add(`true`).add(`false`)].sort()}}function BY(e,t){let n=t;for(;n>0&&/[A-Za-z0-9_.-]/.test(e[n-1]);)n--;let r=e.slice(n,t),i=n-1;for(;i>=0&&/\s/.test(e[i]);)i--;return{word:r,start:n,isValue:e[i]===`:`}}var VY=[[`revert in 30s`,3e4],[`revert in 60s`,6e4],[`revert in 2m`,12e4],[`no auto-revert`,0]];function HY({initial:e,onClose:t,onReload:n}){let[r,i]=(0,v.useState)(()=>JSON.stringify(e,null,2)),[a,o]=(0,v.useState)({keys:[],enums:[]}),[s,c]=(0,v.useState)([]),[l,u]=(0,v.useState)(null),[d,f]=(0,v.useState)(null),[p,m]=(0,v.useState)({}),[h,g]=(0,v.useState)(null),[_,y]=(0,v.useState)(null),[b,x]=(0,v.useState)(0),[S,C]=(0,v.useState)(6e4),[w,T]=(0,v.useState)(null),E=(0,v.useRef)(null),D=(0,v.useRef)(null),O=(0,v.useRef)(null),k=(0,v.useRef)(null);(0,v.useEffect)(()=>{pc(`/api/config-schema`).then(e=>o(zY(e))).catch(()=>{})},[]),(0,v.useEffect)(()=>{D.current!=null&&E.current&&(E.current.selectionStart=E.current.selectionEnd=D.current,D.current=null)}),(0,v.useEffect)(()=>{let e=setTimeout(()=>{let e;try{e=JSON.parse(r)}catch(e){u(e instanceof Error?e.message:String(e)),c([]);return}u(null),mc(`/api/config/validate`,e).then(e=>c(e.errors??[])).catch(()=>{})},350);return()=>clearTimeout(e)},[r]),(0,v.useEffect)(()=>{if(!_||b<=0)return;let e=setInterval(()=>x(e=>Math.max(0,e-1)),1e3);return()=>clearInterval(e)},[_,b]),(0,v.useEffect)(()=>{_&&b===0&&(_.rollbackMs??0)>0&&(T(`Auto-reverted — changes were not confirmed in time.`),y(null),n())},[_,b,n]);let A=!l&&s.length===0,j=e=>{let{word:t,start:n,isValue:r}=BY(e.value,e.selectionStart);if(t.length<1){f(null);return}let i=(r?a.enums:a.keys).filter(e=>e.startsWith(t)&&e!==t).slice(0,8);if(!i.length){f(null);return}let o=e.value.slice(0,e.selectionStart).split(`
74
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function aJ(e,t){if(e){if(typeof e==`string`)return oJ(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?oJ(e,t):void 0}}function oJ(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function sJ(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function cJ(e){if(Array.isArray(e))return e}var lJ=()=>(QF(),null);function uJ(e){if(typeof e==`number`)return e;if(typeof e==`string`){var t=parseFloat(e);if(!Number.isNaN(t))return t}return 0}var dJ=(0,v.forwardRef)((e,t)=>{var n=(0,v.useRef)(null),r=rJ((0,v.useState)({containerWidth:uJ(e.style?.width),containerHeight:uJ(e.style?.height)}),2),i=r[0],a=r[1],o=(0,v.useCallback)((e,t)=>{a(n=>{var r=Math.round(e),i=Math.round(t);return n.containerWidth===r&&n.containerHeight===i?n:{containerWidth:r,containerHeight:i}})},[]),s=(0,v.useCallback)(e=>{if(typeof t==`function`&&t(e),n.current!=null&&(n.current.disconnect(),n.current=null),e!=null&&typeof ResizeObserver<`u`){var r=e.getBoundingClientRect(),i=r.width,a=r.height;o(i,a);var s=new ResizeObserver(e=>{var t=e[0];if(t!=null){var n=t.contentRect,r=n.width,i=n.height;o(r,i)}});s.observe(e),n.current=s}},[t,o]);return(0,v.useEffect)(()=>()=>{n.current?.disconnect()},[o]),v.createElement(v.Fragment,null,v.createElement(sv,{width:i.containerWidth,height:i.containerHeight}),v.createElement(`div`,nJ({ref:s},e)))}),fJ=(0,v.forwardRef)((e,t)=>{var n=e.width,r=e.height,i=rJ((0,v.useState)({containerWidth:uJ(n),containerHeight:uJ(r)}),2),a=i[0],o=i[1],s=(0,v.useCallback)((e,t)=>{o(n=>{var r=Math.round(e),i=Math.round(t);return n.containerWidth===r&&n.containerHeight===i?n:{containerWidth:r,containerHeight:i}})},[]),c=(0,v.useCallback)(e=>{if(typeof t==`function`&&t(e),e!=null){var n=e.getBoundingClientRect(),r=n.width,i=n.height;s(r,i)}},[t,s]);return v.createElement(v.Fragment,null,v.createElement(sv,{width:a.containerWidth,height:a.containerHeight}),v.createElement(`div`,nJ({ref:c},e)))}),pJ=(0,v.forwardRef)((e,t)=>{var n=e.width,r=e.height;return v.createElement(v.Fragment,null,v.createElement(sv,{width:n,height:r}),v.createElement(`div`,nJ({ref:t},e)))}),mJ=(0,v.forwardRef)((e,t)=>{var n=e.width,r=e.height;return typeof n==`string`||typeof r==`string`?v.createElement(fJ,nJ({},e,{ref:t})):typeof n==`number`&&typeof r==`number`?v.createElement(pJ,nJ({},e,{width:n,height:r,ref:t})):v.createElement(v.Fragment,null,v.createElement(sv,{width:n,height:r}),v.createElement(`div`,nJ({ref:t},e)))});function hJ(e){return e?dJ:mJ}var gJ=(0,v.forwardRef)((e,t)=>{var n=e.children,r=e.className,i=e.height,a=e.onClick,o=e.onContextMenu,s=e.onDoubleClick,c=e.onMouseDown,l=e.onMouseEnter,u=e.onMouseLeave,d=e.onMouseMove,f=e.onMouseUp,p=e.onTouchEnd,m=e.onTouchMove,h=e.onTouchStart,g=e.style,_=e.width,y=e.responsive,b=e.dispatchTouchEvents,x=b===void 0?!0:b,S=(0,v.useRef)(null),C=jf(),w=rJ((0,v.useState)(null),2),T=w[0],E=w[1],D=rJ((0,v.useState)(null),2),O=D[0],k=D[1],A=Xq(),j=K_(),M=j?.width>0?j.width:_,N=j?.height>0?j.height:i,P=(0,v.useCallback)(e=>{A(e),typeof t==`function`&&t(e),E(e),k(e),e!=null&&(S.current=e)},[A,t,E,k]),F=(0,v.useCallback)(e=>{C(HK(e)),C(dq({handler:a,reactEvent:e}))},[C,a]),I=(0,v.useCallback)(e=>{C(WK(e)),C(dq({handler:l,reactEvent:e}))},[C,l]),L=(0,v.useCallback)(e=>{C(oN()),C(dq({handler:u,reactEvent:e}))},[C,u]),ee=(0,v.useCallback)(e=>{C(WK(e)),C(dq({handler:d,reactEvent:e}))},[C,d]),te=(0,v.useCallback)(()=>{C(iq())},[C]),R=(0,v.useCallback)(()=>{C(aq())},[C]),z=(0,v.useCallback)(e=>{C(rq(e.key))},[C]),ne=(0,v.useCallback)(e=>{C(dq({handler:o,reactEvent:e}))},[C,o]),B=(0,v.useCallback)(e=>{C(dq({handler:s,reactEvent:e}))},[C,s]),V=(0,v.useCallback)(e=>{C(dq({handler:c,reactEvent:e}))},[C,c]),re=(0,v.useCallback)(e=>{C(dq({handler:f,reactEvent:e}))},[C,f]),ie=(0,v.useCallback)(e=>{C(dq({handler:h,reactEvent:e}))},[C,h]),ae=(0,v.useCallback)(e=>{x&&C(_q(e)),C(dq({handler:m,reactEvent:e}))},[C,x,m]),oe=(0,v.useCallback)(e=>{C(dq({handler:p,reactEvent:e}))},[C,p]),se=hJ(y);return v.createElement(EF.Provider,{value:T},v.createElement(Ll.Provider,{value:O},v.createElement(se,{width:M??g?.width,height:N??g?.height,className:vl(`recharts-wrapper`,r),style:Qq({position:`relative`,cursor:`default`,width:M,height:N},g),onClick:F,onContextMenu:ne,onDoubleClick:B,onFocus:te,onBlur:R,onKeyDown:z,onMouseDown:V,onMouseEnter:I,onMouseLeave:L,onMouseMove:ee,onMouseUp:re,onTouchEnd:oe,onTouchMove:ae,onTouchStart:ie,ref:P},v.createElement(lJ,null),n)))}),_J=[`width`,`height`,`responsive`,`children`,`className`,`style`,`compact`,`title`,`desc`];function vJ(e,t){if(e==null)return{};var n,r,i=yJ(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function yJ(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}var bJ=(0,v.forwardRef)((e,t)=>{var n=e.width,r=e.height,i=e.responsive,a=e.children,o=e.className,s=e.style,c=e.compact,l=e.title,u=e.desc,d=wl(vJ(e,_J));return c?v.createElement(v.Fragment,null,v.createElement(sv,{width:n,height:r}),v.createElement(Uq,{otherAttributes:d,title:l,desc:u},a)):v.createElement(gJ,{className:o,style:s,width:n,height:r,responsive:i??!1,onClick:e.onClick,onMouseLeave:e.onMouseLeave,onMouseEnter:e.onMouseEnter,onMouseMove:e.onMouseMove,onMouseDown:e.onMouseDown,onMouseUp:e.onMouseUp,onContextMenu:e.onContextMenu,onDoubleClick:e.onDoubleClick,onTouchStart:e.onTouchStart,onTouchMove:e.onTouchMove,onTouchEnd:e.onTouchEnd},v.createElement(Uq,{otherAttributes:d,title:l,desc:u,ref:t},v.createElement(WU,null,a)))});function xJ(){return xJ=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},xJ.apply(null,arguments)}function SJ(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function CJ(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?SJ(Object(n),!0).forEach(function(t){wJ(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):SJ(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function wJ(e,t,n){return(t=TJ(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function TJ(e){var t=EJ(e,`string`);return typeof t==`symbol`?t:t+``}function EJ(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var DJ=CJ({accessibilityLayer:!0,barCategoryGap:`10%`,barGap:4,layout:`horizontal`,margin:{top:5,right:5,bottom:5,left:5},responsive:!1,reverseStackOrder:!1,stackOffset:`none`,syncMethod:`index`},Cq),OJ=(0,v.forwardRef)(function(e,t){var n=hd(e.categoricalChartProps,DJ),r=e.chartName,i=e.defaultTooltipEventType,a=e.validateTooltipEventTypes,o=e.tooltipPayloadSearcher,s=e.categoricalChartProps,c={chartName:r,defaultTooltipEventType:i,validateTooltipEventTypes:a,tooltipPayloadSearcher:o,eventEmitter:void 0};return v.createElement(kq,{preloadedState:{options:c},reduxStoreName:s.id??r},v.createElement(OU,{chartData:s.data}),v.createElement(jq,{layout:n.layout,margin:n.margin}),v.createElement(Nq,{throttleDelay:n.throttleDelay,throttledEvents:n.throttledEvents}),v.createElement(Mq,{baseValue:n.baseValue,accessibilityLayer:n.accessibilityLayer,barCategoryGap:n.barCategoryGap,maxBarSize:n.maxBarSize,stackOffset:n.stackOffset,barGap:n.barGap,barSize:n.barSize,syncId:n.syncId,syncMethod:n.syncMethod,className:n.className,reverseStackOrder:n.reverseStackOrder}),v.createElement(bJ,xJ({},n,{ref:t})))});function kJ(e){var t=jf();return(0,v.useEffect)(()=>{t(tq(e))},[t,e]),null}var AJ=[`layout`];function jJ(){return jJ=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},jJ.apply(null,arguments)}function MJ(e,t){if(e==null)return{};var n,r,i=NJ(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function NJ(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function PJ(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function FJ(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?PJ(Object(n),!0).forEach(function(t){IJ(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):PJ(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function IJ(e,t,n){return(t=LJ(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function LJ(e){var t=RJ(e,`string`);return typeof t==`symbol`?t:t+``}function RJ(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var zJ=FJ({accessibilityLayer:!0,stackOffset:`none`,barCategoryGap:`10%`,barGap:4,margin:{top:5,right:5,bottom:5,left:5},reverseStackOrder:!1,syncMethod:`index`,layout:`radial`,responsive:!1,cx:`50%`,cy:`50%`,innerRadius:0,outerRadius:`80%`},Cq),BJ=(0,v.forwardRef)(function(e,t){var n=hd(e.categoricalChartProps,zJ),r=n.layout,i=MJ(n,AJ),a=e.chartName,o={chartName:a,defaultTooltipEventType:e.defaultTooltipEventType,validateTooltipEventTypes:e.validateTooltipEventTypes,tooltipPayloadSearcher:e.tooltipPayloadSearcher,eventEmitter:void 0};return v.createElement(kq,{preloadedState:{options:o},reduxStoreName:n.id??a},v.createElement(OU,{chartData:n.data}),v.createElement(jq,{layout:r,margin:n.margin}),v.createElement(Nq,{throttleDelay:n.throttleDelay,throttledEvents:n.throttledEvents}),v.createElement(Mq,{baseValue:void 0,accessibilityLayer:n.accessibilityLayer,barCategoryGap:n.barCategoryGap,maxBarSize:n.maxBarSize,stackOffset:n.stackOffset,barGap:n.barGap,barSize:n.barSize,syncId:n.syncId,syncMethod:n.syncMethod,className:n.className,reverseStackOrder:n.reverseStackOrder}),v.createElement(kJ,{cx:n.cx,cy:n.cy,startAngle:n.startAngle,endAngle:n.endAngle,innerRadius:n.innerRadius,outerRadius:n.outerRadius}),v.createElement(bJ,jJ({},i,{ref:t})))});function VJ(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function HJ(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?VJ(Object(n),!0).forEach(function(t){UJ(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):VJ(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function UJ(e,t,n){return(t=WJ(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function WJ(e){var t=GJ(e,`string`);return typeof t==`symbol`?t:t+``}function GJ(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var KJ=[`item`],qJ=HJ(HJ({},zJ),{},{layout:`centric`,startAngle:0,endAngle:360}),JJ=(0,v.forwardRef)((e,t)=>{var n=hd(e,qJ);return v.createElement(BJ,{chartName:`PieChart`,defaultTooltipEventType:`item`,validateTooltipEventTypes:KJ,tooltipPayloadSearcher:MF,categoricalChartProps:n,ref:t})}),YJ=[`axis`],XJ=(0,v.forwardRef)((e,t)=>v.createElement(OJ,{chartName:`AreaChart`,defaultTooltipEventType:`axis`,validateTooltipEventTypes:YJ,tooltipPayloadSearcher:MF,categoricalChartProps:e,ref:t}));function ZJ(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function QJ(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?ZJ(Object(n),!0).forEach(function(t){$J(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ZJ(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function $J(e,t,n){return(t=eY(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function eY(e){var t=tY(e,`string`);return typeof t==`symbol`?t:t+``}function tY(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var nY=[`axis`,`item`],rY=QJ(QJ({},zJ),{},{layout:`radial`,startAngle:0,endAngle:360}),iY=(0,v.forwardRef)((e,t)=>{var n=hd(e,rY);return v.createElement(BJ,{chartName:`RadialBarChart`,defaultTooltipEventType:`axis`,validateTooltipEventTypes:nY,tooltipPayloadSearcher:MF,categoricalChartProps:n,ref:t})}),aY=e=>new Date(e).toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`,hour12:!1});function oY({active:e,payload:t,label:n,unit:r}){return!e||!t?.length?null:(0,q.jsxs)(`div`,{className:`chart-tip`,children:[n!=null&&(0,q.jsx)(`div`,{className:`chart-tip__label`,children:n}),t.map((e,t)=>(0,q.jsxs)(`div`,{className:`chart-tip__row`,children:[(0,q.jsx)(`span`,{className:`chart-tip__dot`,style:{background:e.color}}),(0,q.jsx)(`span`,{className:`chart-tip__name`,children:e.name??e.dataKey}),(0,q.jsxs)(`span`,{className:`chart-tip__val`,children:[typeof e.value==`number`?e.value.toLocaleString():e.value,r??``]})]},t))]})}var sY=`color-mix(in srgb, var(--mt-border) 80%, transparent)`,cY={fill:`var(--mt-text-faint)`,fontSize:10,fontFamily:`var(--mt-mono)`};function lY({series:e}){return(0,q.jsx)(`div`,{className:`chart`,style:{height:200},children:(0,q.jsx)(J_,{width:`100%`,height:`100%`,children:(0,q.jsxs)(XJ,{data:e,margin:{top:8,right:8,left:-18,bottom:0},children:[(0,q.jsxs)(`defs`,{children:[(0,q.jsxs)(`linearGradient`,{id:`fillOk`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,q.jsx)(`stop`,{offset:`0%`,stopColor:`var(--sky)`,stopOpacity:.5}),(0,q.jsx)(`stop`,{offset:`100%`,stopColor:`var(--sky)`,stopOpacity:.04})]}),(0,q.jsxs)(`linearGradient`,{id:`fillErr`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,q.jsx)(`stop`,{offset:`0%`,stopColor:`var(--mt-bad)`,stopOpacity:.55}),(0,q.jsx)(`stop`,{offset:`100%`,stopColor:`var(--mt-bad)`,stopOpacity:.05})]})]}),(0,q.jsx)(iG,{vertical:!1,stroke:sY,strokeDasharray:`3 3`}),(0,q.jsx)(CK,{dataKey:`t`,tickFormatter:aY,tick:cY,tickLine:!1,axisLine:!1,minTickGap:48}),(0,q.jsx)(RK,{tick:cY,tickLine:!1,axisLine:!1,width:34,allowDecimals:!1}),(0,q.jsx)(hI,{cursor:{stroke:sY},content:({active:e,payload:t,label:n})=>(0,q.jsx)(oY,{active:e,payload:t,label:typeof n==`number`?aY(n):n})}),(0,q.jsx)(nK,{type:`monotone`,dataKey:`ok`,name:`ok`,stackId:`1`,stroke:`var(--sky)`,fill:`url(#fillOk)`,strokeWidth:2,isAnimationActive:!1}),(0,q.jsx)(nK,{type:`monotone`,dataKey:`error`,name:`error`,stackId:`1`,stroke:`var(--mt-bad)`,fill:`url(#fillErr)`,strokeWidth:2,isAnimationActive:!1})]})})})}function uY({segments:e,centerLabel:t=`calls`}){let n=e.filter(e=>e.value>0),r=e.reduce((e,t)=>e+t.value,0);return(0,q.jsxs)(`div`,{className:`chart chart--donut`,children:[(0,q.jsx)(`div`,{className:`chart-donut__svg`,children:(0,q.jsx)(J_,{width:`100%`,height:180,children:(0,q.jsxs)(JJ,{children:[(0,q.jsx)(hI,{content:({active:e,payload:t})=>(0,q.jsx)(oY,{active:e,payload:t})}),(0,q.jsx)(OV,{data:n,dataKey:`value`,nameKey:`label`,innerRadius:58,outerRadius:80,paddingAngle:2,strokeWidth:0,isAnimationActive:!1,children:n.map(e=>(0,q.jsx)(gI,{fill:e.color},e.label))}),(0,q.jsx)(`text`,{x:`50%`,y:`47%`,textAnchor:`middle`,fill:`var(--mt-text)`,fontSize:22,fontWeight:600,children:r.toLocaleString()}),(0,q.jsx)(`text`,{x:`50%`,y:`59%`,textAnchor:`middle`,fill:`var(--mt-text-dim)`,fontSize:10,children:t})]})})}),(0,q.jsx)(`div`,{className:`chart-legend`,children:n.map(e=>(0,q.jsxs)(`span`,{children:[(0,q.jsx)(`i`,{style:{background:e.color}}),e.label,` `,(0,q.jsx)(`b`,{children:e.value})]},e.label))})]})}function dY({values:e,color:t,unit:n,maxValue:r,id:i}){let a=e.filter(e=>e!=null);if(a.length===0)return(0,q.jsx)(`div`,{className:`spark spark--empty`,children:`no samples yet`});let o=e.map((e,t)=>({i:t,v:e})),s=a[a.length-1],c=`ma-${(i??t).replace(/[^a-z0-9]/gi,``)}`,l=Math.min(...a),u=Math.max(...a),d=Math.max(0,(n===`%`?10:0)-(u-l))/2,f=l-d,p=u+d,m=(p-f)*.15||1;return f=Math.max(0,f-m),p+=m,r!=null&&(p=Math.min(r,p)),p<=f&&(p=f+1),(0,q.jsxs)(`div`,{className:`chart chart--spark`,children:[(0,q.jsxs)(`span`,{className:`chart-spark__last`,style:{color:t},children:[s.toFixed(n===`%`?0:1),n??``]}),(0,q.jsx)(J_,{width:`100%`,height:46,children:(0,q.jsxs)(XJ,{data:o,margin:{top:4,right:2,left:2,bottom:0},children:[(0,q.jsx)(`defs`,{children:(0,q.jsxs)(`linearGradient`,{id:c,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,q.jsx)(`stop`,{offset:`0%`,stopColor:t,stopOpacity:.35}),(0,q.jsx)(`stop`,{offset:`100%`,stopColor:t,stopOpacity:0})]})}),(0,q.jsx)(RK,{hide:!0,domain:[f,p]}),(0,q.jsx)(hI,{cursor:{stroke:sY},content:({active:e,payload:r})=>(0,q.jsx)(oY,{active:e,payload:r?.map(e=>({...e,name:`value`,color:t})),unit:n})}),(0,q.jsx)(nK,{type:`monotone`,dataKey:`v`,stroke:t,fill:`url(#${c})`,strokeWidth:1.7,connectNulls:!1,isAnimationActive:!1,dot:!1})]})})]})}function fY({value:e,label:t,color:n}){let r=e!=null,i=r?Math.max(0,Math.min(100,e)):0;return(0,q.jsxs)(`div`,{className:`gauge`,children:[(0,q.jsxs)(`div`,{className:`gauge__radial`,children:[(0,q.jsx)(J_,{width:72,height:72,children:(0,q.jsxs)(iY,{data:[{name:t,value:i,fill:n}],innerRadius:`72%`,outerRadius:`100%`,startAngle:90,endAngle:-270,barSize:7,children:[(0,q.jsx)(Cz,{type:`number`,domain:[0,100],tick:!1,axisLine:!1}),(0,q.jsx)(DU,{dataKey:`value`,cornerRadius:4,background:{fill:`var(--mt-surface-2)`},isAnimationActive:!1})]})}),(0,q.jsx)(`span`,{className:`gauge__pct`,style:{color:r?`var(--mt-text)`:`var(--mt-text-faint)`},children:r?`${Math.round(i)}%`:`n/a`})]}),(0,q.jsx)(`span`,{className:`gauge__label`,children:t})]})}var pY=40,mY=30,hY=1e3,gY=`http://www.w3.org/2000/svg`,_Y=e=>`${(e/1e6).toFixed(2)} Mbps`,vY=e=>e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(0)}k`:e>0?`${Math.round(e)}`:`0`;function yY({history:e}){let t=Math.max(1,...e.flatMap(e=>[e.rx,e.tx])),n=e=>8+e*504/Math.max(1,pY-1),r=e=>142-e/t*134,i=t=>e.map((e,i)=>`${n(i).toFixed(1)},${r(t(e)).toFixed(1)}`).join(` `),a=t=>{if(e.length<2)return``;let r=n(0).toFixed(1),a=n(e.length-1).toFixed(1);return`${r},${142 .toFixed(1)} ${i(t)} ${a},${142 .toFixed(1)}`};return(0,q.jsx)(`svg`,{className:`clients-chart`,viewBox:`0 0 520 150`,xmlns:gY,role:`img`,children:e.length>=2&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`polygon`,{className:`rx area`,points:a(e=>e.rx)}),(0,q.jsx)(`polygon`,{className:`tx area`,points:a(e=>e.tx)}),(0,q.jsx)(`polyline`,{className:`rx line`,points:i(e=>e.rx)}),(0,q.jsx)(`polyline`,{className:`tx line`,points:i(e=>e.tx)})]})})}function bY({history:e}){if(e.length<2)return(0,q.jsx)(`svg`,{className:`mini-spark`,viewBox:`0 0 80 18`});let t=Math.max(1,...e.flatMap(e=>[e.rx,e.tx])),n=e=>1+e*78/Math.max(1,mY-1),r=e=>17-e/t*16,i=t=>e.map((e,i)=>`${n(i).toFixed(1)},${r(t(e)).toFixed(1)}`).join(` `),a=t=>{let r=n(0).toFixed(1),a=n(e.length-1).toFixed(1),o=17 .toFixed(1);return`${r},${o} ${i(t)} ${a},${o}`};return(0,q.jsxs)(`svg`,{className:`mini-spark`,viewBox:`0 0 80 18`,xmlns:gY,children:[(0,q.jsx)(`polygon`,{className:`rx area`,points:a(e=>e.rx)}),(0,q.jsx)(`polygon`,{className:`tx area`,points:a(e=>e.tx)}),(0,q.jsx)(`polyline`,{className:`rx line`,points:i(e=>e.rx)}),(0,q.jsx)(`polyline`,{className:`tx line`,points:i(e=>e.tx)})]})}function xY({ip:e,deviceName:t,current:n,onSaved:r}){let[i,a]=(0,v.useState)(n.download),[o,s]=(0,v.useState)(n.upload),[c,l]=(0,v.useState)(!1),[u,d]=(0,v.useState)(!1),[f,p]=(0,v.useState)(null);(0,v.useEffect)(()=>{c||(a(n.download),s(n.upload))},[n.download,n.upload,c]);let m=(0,v.useCallback)(async(n,i)=>{d(!0),p(null);try{let a=await mc(`/api/clients/limits`,{ip:e,device:t,download:n,upload:i});p(a.message),a.ok&&(l(!1),r())}catch(e){p(e instanceof Error?e.message:String(e))}finally{d(!1)}},[e,t,r]),h=!!(n.download||n.upload);return(0,q.jsxs)(`div`,{className:`clients-limits`,children:[(0,q.jsxs)(`div`,{className:`clients-limits__hd`,children:[(0,q.jsx)(`span`,{className:`clients-limits__label`,children:`Rate limits`}),(0,q.jsxs)(`span`,{className:`muted`,children:[`current: ↓ `,n.download||`unlimited`,` · ↑ `,n.upload||`unlimited`]})]}),(0,q.jsxs)(`div`,{className:`clients-limits__row`,children:[(0,q.jsxs)(`label`,{className:`clients-limits__field`,children:[(0,q.jsx)(`span`,{className:`muted`,children:`↓ Download`}),(0,q.jsx)(Ic,{placeholder:`10M · blank = unlimited`,value:i,onChange:e=>{l(!0),a(e.target.value)}})]}),(0,q.jsxs)(`label`,{className:`clients-limits__field`,children:[(0,q.jsx)(`span`,{className:`muted`,children:`↑ Upload`}),(0,q.jsx)(Ic,{placeholder:`2M · blank = unlimited`,value:o,onChange:e=>{l(!0),s(e.target.value)}})]}),(0,q.jsx)(jc,{size:`sm`,type:`accent`,loading:u,onClick:()=>void m(i,o),children:`Apply`}),(0,q.jsx)(jc,{size:`sm`,ghost:!0,disabled:u||!h,onClick:()=>{a(``),s(``),m(``,``)},children:`Remove`})]}),f&&(0,q.jsx)(`div`,{className:`muted clients-limits__msg`,children:f})]})}function SY({device:e,deviceName:t,traffic:n}){let r=n!==void 0;return(0,q.jsxs)(`div`,{className:`clients-detail`,children:[(0,q.jsxs)(`div`,{className:`clients-detail__hd`,children:[(0,q.jsx)(`span`,{className:`clients-detail__title`,children:e.host||e.comment||e.ip}),(0,q.jsxs)(`span`,{className:`muted`,children:[e.ip||`no IP`,` · `,e.mac,` · `,e.iface||`?`,` · `,e.status]})]}),r?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`div`,{className:`clients-rates`,children:[(0,q.jsxs)(`span`,{className:`rate rx`,children:[`↓ `,_Y(n.rxRate)]}),(0,q.jsxs)(`span`,{className:`rate tx`,children:[`↑ `,_Y(n.txRate)]})]}),(0,q.jsx)(yY,{history:n.history}),(0,q.jsxs)(`div`,{className:`muted clients-totals`,children:[`total ↓ `,Cc(n.rxBytes),` · ↑ `,Cc(n.txBytes)]})]}):(0,q.jsxs)(Mc,{type:`secondary`,label:`No per-device counter`,children:[`Set a rate limit below to start tracking this device's Download/Upload (it creates a simple queue targeting `,(0,q.jsx)(`code`,{children:e.ip}),`), or leave it unlimited.`]}),e.ip&&(0,q.jsx)(xY,{ip:e.ip,deviceName:t,current:{download:n?.downloadLimit??``,upload:n?.uploadLimit??``},onSaved:()=>{}}),e.ip&&(0,q.jsxs)(`div`,{className:`clients-history`,children:[(0,q.jsx)(`div`,{className:`clients-history__hd`,children:`Usage history · last 3 months`}),(0,q.jsx)(Wc,{endpoint:`/api/usage/client?ip=${encodeURIComponent(e.ip)}${t?`&device=${encodeURIComponent(t)}`:``}&days=90`,days:90})]})]})}function CY(e){let[t,n]=(0,v.useState)(new Map),r=(0,v.useRef)(null);return(0,v.useEffect)(()=>{r.current=null,n(new Map)},[e]),(0,v.useEffect)(()=>{if(!e)return;let t=!1,i=async()=>{try{let i=await pc(`/api/clients/traffic-bulk${e?`?device=${encodeURIComponent(e)}`:``}`);if(t)return;let a=r.current;if(r.current={ts:i.ts,queues:i.queues},!a)return;let o=Math.max(.1,(i.ts-a.ts)/1e3);n(e=>{let t=new Map;for(let[n,r]of Object.entries(i.queues)){let i=a.queues[n],s=e.get(n),c=i?Math.max(0,r.rxBytes-i.rxBytes):0,l=i?Math.max(0,r.txBytes-i.txBytes):0,u=c/o*8,d=l/o*8,f=[...s?.history??[],{rx:u,tx:d}].slice(-30);t.set(n,{rxRate:u,txRate:d,rxBytes:r.rxBytes,txBytes:r.txBytes,downloadLimit:r.downloadLimit,uploadLimit:r.uploadLimit,history:f})}return t})}catch{}};i();let a=setInterval(()=>void i(),hY);return()=>{t=!0,clearInterval(a)}},[e]),t}function wY(){let[e,t]=(0,v.useState)(null),[n,r]=(0,v.useState)(``),[i,a]=(0,v.useState)(null),[o,s]=(0,v.useState)(null),[c,l]=(0,v.useState)(null),[u,d]=(0,v.useState)(null),[f,p]=(0,v.useState)(``),[m,h]=(0,v.useState)(null),g=CY(n);(0,v.useEffect)(()=>{pc(`/api/devices`).then(e=>{t(e),r(t=>t||e.defaultDevice||e.devices[0]?.name||``)}).catch(()=>t({server:``,defaultDevice:``,devices:[]}))},[]);let _=(0,v.useCallback)(async()=>{try{let e=n?`?device=${encodeURIComponent(n)}`:``;a(await pc(`/api/clients${e}`)),d(null)}catch(e){d(e instanceof Error?e.message:String(e))}},[n]);(0,v.useEffect)(()=>{a(null),s(null),_();let e=setInterval(()=>void _(),15e3);return()=>clearInterval(e)},[_]);let y=(0,v.useCallback)(async(e,t,r)=>{l(t),d(null);try{let i=await mc(`/api/clients/${e}`,{mac:t,device:n,...r});i.view?a(i.view):await _(),i.ok||d(i.message)}catch(e){d(e instanceof Error?e.message:String(e))}finally{l(null)}},[n,_]),b=(0,v.useCallback)((e,t)=>{s(e.mac),h({mac:e.mac,field:t,value:t===`ip`?e.ip:e.comment||e.host})},[]),x=(0,v.useCallback)(async()=>{if(!m)return;let e=m.value.trim();m.field===`ip`?e&&await y(`set-ip`,m.mac,{ip:e}):await y(`label`,m.mac,{label:e}),h(null)},[m,y]),S=(0,v.useMemo)(()=>{let e=i?.devices??[],t=f.trim().toLowerCase();return t?e.filter(e=>e.ip.toLowerCase().includes(t)||e.mac.toLowerCase().includes(t)||e.host.toLowerCase().includes(t)||e.comment.toLowerCase().includes(t)):e},[i,f]),C=(0,v.useMemo)(()=>i?.devices.find(e=>e.mac===o)??null,[i,o]),w=e?.devices??[],T=i?.counts;return(0,q.jsx)(`section`,{className:`view`,children:(0,q.jsxs)(_c,{title:`Connected clients`,className:`reveal`,extra:(0,q.jsxs)(`div`,{className:`clients-toolbar`,children:[w.length>1&&(0,q.jsx)(Lc,{value:n,onChange:e=>r(e.target.value),"aria-label":`Router`,children:w.map(e=>(0,q.jsxs)(`option`,{value:e.name,children:[e.name,e.isDefault?` (default)`:``]},e.name))}),(0,q.jsx)(`input`,{className:`geist-input`,placeholder:`Filter IP / MAC / name…`,value:f,onChange:e=>p(e.target.value)}),(0,q.jsx)(jc,{size:`sm`,ghost:!0,onClick:()=>void _(),children:`↻ Refresh`})]}),children:[T&&(0,q.jsxs)(`div`,{className:`clients-counts muted`,children:[T.total,` total · `,T.static,` static · `,T.blocked,` blocked`]}),u&&(0,q.jsx)(Mc,{type:`error`,className:`clients-error`,children:u}),i?S.length===0?(0,q.jsxs)(`div`,{className:`feed-empty`,children:[(0,q.jsx)(`div`,{className:`feed-empty__icon`,children:`📡`}),(0,q.jsx)(`p`,{className:`feed-empty__title`,children:`No connected devices`}),(0,q.jsxs)(`p`,{className:`feed-empty__sub`,children:[`Nothing in this router's DHCP-lease or ARP table`,f?` matches the filter`:``,`.`]})]}):(0,q.jsxs)(`div`,{className:`clients-table`,children:[(0,q.jsxs)(`div`,{className:`clients-row clients-row--head`,children:[(0,q.jsx)(`span`,{children:`IP`}),(0,q.jsx)(`span`,{children:`Name`}),(0,q.jsx)(`span`,{children:`MAC`}),(0,q.jsx)(`span`,{children:`Iface`}),(0,q.jsx)(`span`,{children:`Status`}),(0,q.jsx)(`span`,{children:`Traffic`}),(0,q.jsx)(`span`,{className:`clients-actions-h`,children:`Actions`})]}),S.map(e=>{let t=e.mac===o,n=c===e.mac,r=e.ip?g.get(e.ip):void 0;return(0,q.jsxs)(`div`,{className:[`clients-row`,t?`is-selected`:``,e.blocked?`is-blocked`:``].filter(Boolean).join(` `),onClick:()=>s(t?null:e.mac),children:[(0,q.jsx)(`span`,{className:`clients-ip`,children:e.ip||`—`}),(0,q.jsx)(`span`,{className:`clients-name`,children:e.host||e.comment||`(unknown)`}),(0,q.jsx)(`span`,{className:`clients-mac`,children:e.mac}),(0,q.jsx)(`span`,{className:`muted`,children:e.iface||``}),(0,q.jsxs)(`span`,{className:`clients-badges`,children:[e.static&&(0,q.jsx)(Nc,{type:`secondary`,children:`static`}),e.blocked?(0,q.jsx)(Nc,{type:`error`,children:`blocked`}):(0,q.jsx)(`span`,{className:`muted`,children:e.status})]}),(0,q.jsx)(`span`,{className:`clients-traffic`,children:r?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`span`,{className:`clients-traffic__rates`,children:[(0,q.jsxs)(`span`,{className:`rx`,children:[`↓`,vY(r.rxRate)]}),(0,q.jsxs)(`span`,{className:`tx`,children:[`↑`,vY(r.txRate)]})]}),(0,q.jsx)(bY,{history:r.history})]}):(0,q.jsx)(`span`,{className:`muted`,children:e.ip?`—`:``})}),(0,q.jsxs)(`span`,{className:`clients-actions`,onClick:e=>e.stopPropagation(),role:`presentation`,children:[e.blocked?(0,q.jsx)(jc,{size:`sm`,type:`success`,ghost:!0,loading:n,onClick:()=>void y(`allow`,e.mac),children:`Allow`}):(0,q.jsx)(jc,{size:`sm`,type:`error`,ghost:!0,loading:n,onClick:()=>void y(`block`,e.mac),children:`Block`}),!e.static&&(0,q.jsx)(jc,{size:`sm`,ghost:!0,loading:n,onClick:()=>void y(`pin`,e.mac),children:`Pin IP`}),(0,q.jsx)(jc,{size:`sm`,ghost:!0,disabled:n,onClick:()=>b(e,`ip`),children:`Set IP`}),(0,q.jsx)(jc,{size:`sm`,ghost:!0,disabled:n,onClick:()=>b(e,`label`),children:`Label`})]})]},e.mac)})]}):(0,q.jsx)(`div`,{className:`muted`,children:`loading connected devices…`}),m&&C?.mac===m.mac&&(0,q.jsxs)(`div`,{className:`clients-edit`,children:[(0,q.jsxs)(`span`,{className:`clients-edit__label`,children:[m.field===`ip`?`Reserve IP for`:`Label for`,` `,(0,q.jsx)(`b`,{children:C.host||C.mac}),`:`]}),(0,q.jsx)(Ic,{autoFocus:!0,value:m.value,placeholder:m.field===`ip`?`e.g. 192.168.88.50`:`e.g. Ali phone`,onChange:e=>h({...m,value:e.target.value}),onKeyDown:e=>{e.key===`Enter`&&x(),e.key===`Escape`&&h(null)}}),(0,q.jsx)(jc,{size:`sm`,type:`accent`,loading:c===m.mac,onClick:()=>void x(),children:`Save`}),(0,q.jsx)(jc,{size:`sm`,ghost:!0,onClick:()=>h(null),children:`Cancel`})]}),C&&(0,q.jsx)(SY,{device:C,deviceName:n,traffic:C.ip?g.get(C.ip):void 0})]})})}function TY(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function EY(e){return new Date(e).toLocaleString(void 0,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`,hour12:!1})}function DY({onRestored:e}){let[t,n]=(0,v.useState)(null),[r,i]=(0,v.useState)(null),[a,o]=(0,v.useState)(!1),[s,c]=(0,v.useState)(null),[l,u]=(0,v.useState)(null),[d,f]=(0,v.useState)(null),[p,m]=(0,v.useState)(null),h=(0,v.useCallback)(()=>{pc(`/api/config/history`).then(n).catch(()=>n({versions:[],bytes:0,retention:50}))},[]);(0,v.useEffect)(()=>h(),[h]);let g=(e,t)=>mc(e,t).catch(()=>({error:`request failed`})),_=async()=>{let e=(p??``).trim();m(null);let t=await g(`/api/config/history/checkpoint`,{label:e||void 0});i(t.ok?`Checkpoint saved${e?` · “${e}”`:``}`:`Failed: ${t.error}`),t.ok&&h()},y=async e=>{if(s===e){c(null),u(null);return}c(e),u(null);let t=await pc(`/api/config/history/diff?id=${encodeURIComponent(e)}`).catch(()=>null);u(t)},b=async t=>{f(null),o(!0);let n=await g(`/api/config/history/restore`,{id:t});o(!1),i(n.ok?`Restored ${t}${n.persisted===!1?` (applied live, not persisted)`:``}`:`Restore failed: ${n.error}`),n.ok&&(h(),e())},x=async e=>{let t=await g(`/api/config/history/delete`,{id:e});i(t.ok?`Version deleted`:`Failed: ${t.error}`),t.ok&&h()};return t?(0,q.jsxs)(q.Fragment,{children:[r&&(0,q.jsx)(`div`,{className:`cfg-msg`,children:r}),(0,q.jsxs)(`div`,{className:`toolbar`,style:{marginBottom:14},children:[p===null?(0,q.jsx)(`button`,{className:`btn is-active`,onClick:()=>m(``),children:`★ Save checkpoint`}):(0,q.jsxs)(`span`,{className:`cfgver-cp`,children:[(0,q.jsx)(`input`,{className:`backup-path-input`,autoFocus:!0,placeholder:`checkpoint name (e.g. pre-upgrade)`,value:p,onChange:e=>m(e.target.value),onKeyDown:e=>{e.key===`Enter`&&_(),e.key===`Escape`&&m(null)}}),(0,q.jsx)(`button`,{className:`topo-btn cfg-save`,onClick:()=>void _(),children:`Save`}),(0,q.jsx)(`button`,{className:`topo-btn`,onClick:()=>m(null),children:`Cancel`})]}),(0,q.jsx)(`span`,{style:{flex:1}}),(0,q.jsxs)(`span`,{className:`muted`,children:[t.versions.length,` versions · `,TY(t.bytes),` · auto-keep `,t.retention]})]}),t.versions.length===0?(0,q.jsx)(`div`,{className:`muted`,children:`No versions yet — they appear here after each config change.`}):(0,q.jsx)(`ol`,{className:`cfgver`,children:t.versions.map((e,t)=>{let n=e.drift.added+e.drift.removed;return(0,q.jsxs)(`li`,{className:`cfgver__row${t===0?` is-head`:``}`,children:[(0,q.jsx)(`span`,{className:`cfgver__dot`,"aria-hidden":`true`}),(0,q.jsxs)(`div`,{className:`cfgver__main`,children:[(0,q.jsxs)(`div`,{className:`cfgver__line`,children:[(0,q.jsx)(`span`,{className:`cfgver__kind cfgver__kind--${e.kind}`,children:e.kind===`checkpoint`?`★ checkpoint`:`auto`}),e.label&&(0,q.jsx)(`span`,{className:`cfgver__label`,children:e.label}),(0,q.jsx)(`span`,{className:`cfgver__time`,children:EY(e.ts)}),t===0?(0,q.jsx)(`span`,{className:`cfgver__cur`,children:`latest`}):n===0?(0,q.jsx)(`span`,{className:`cfgver__same`,children:`identical to current`}):(0,q.jsxs)(`span`,{className:`cfgver__drift`,children:[(0,q.jsxs)(`span`,{className:`add`,children:[`+`,e.drift.added]}),(0,q.jsxs)(`span`,{className:`rem`,children:[`−`,e.drift.removed]}),(0,q.jsx)(`span`,{className:`muted`,children:` vs current`})]})]}),s===e.id&&(0,q.jsx)(`div`,{className:`cfgver__diff`,children:l?l.unified.trim()?(0,q.jsx)(`pre`,{className:`body diff`,children:l.unified}):(0,q.jsx)(`span`,{className:`muted`,children:`No differences from the current config.`}):(0,q.jsx)(`span`,{className:`muted`,children:`computing diff…`})})]}),(0,q.jsxs)(`div`,{className:`cfgver__actions`,children:[(0,q.jsx)(`button`,{className:`topo-btn`,onClick:()=>void y(e.id),children:s===e.id?`Hide`:`Diff`}),d===e.id?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`button`,{className:`topo-btn cfg-save`,disabled:a,onClick:()=>void b(e.id),children:`Confirm restore`}),(0,q.jsx)(`button`,{className:`topo-btn`,onClick:()=>f(null),children:`Cancel`})]}):(0,q.jsx)(`button`,{className:`topo-btn`,disabled:t===0,title:t===0?`This is the current config`:`Restore this version`,onClick:()=>f(e.id),children:`Restore`}),e.kind===`checkpoint`&&(0,q.jsx)(`button`,{className:`topo-btn cfgver__del`,title:`Delete`,onClick:()=>void x(e.id),children:`✕`})]})]},e.id)})})]}):(0,q.jsx)(`div`,{className:`muted`,children:`loading history…`})}function OY(e){if(!e)return[];let t=[],n=e=>e?Array.isArray(e.enum)?`enum`:e.type===`array`?`array<${n(e.items)}>`:Array.isArray(e.type)?e.type.join(` | `):e.type??(e.properties?`object`:`any`):`any`,r=(e,i,a,o)=>{let s=e.properties??{};for(let[e,c]of Object.entries(s)){let s=i?`${i}.${e}`:e,l=a||e;t.push({path:s,section:l,type:n(c),def:c.default===void 0?void 0:JSON.stringify(c.default),desc:c.description,enumv:Array.isArray(c.enum)?c.enum:void 0,required:o.has(e)}),c.properties&&r(c,s,l,new Set(c.required??[]));let u=c.additionalProperties;u?.properties&&r(u,`${s}.<name>`,l,new Set(u.required??[]));let d=c.items;d?.properties&&r(d,`${s}[]`,l,new Set(d.required??[]))}};return r(e,``,``,new Set(e.required??[])),t}function kY(){let[e,t]=(0,v.useState)(null),[n,r]=(0,v.useState)(``);(0,v.useEffect)(()=>{pc(`/api/config-schema`).then(t).catch(()=>{})},[]);let i=(0,v.useMemo)(()=>OY(e),[e]),a=n.trim().toLowerCase(),o=a?i.filter(e=>e.path.toLowerCase().includes(a)||(e.desc??``).toLowerCase().includes(a)):i,s=(0,v.useMemo)(()=>{let e=new Map;for(let t of o){let n=e.get(t.section)??[];n.push(t),e.set(t.section,n)}return[...e.entries()]},[o]);return e?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`div`,{className:`toolbar`,style:{marginBottom:12},children:[(0,q.jsx)(`input`,{className:`backup-path-input`,style:{width:`min(360px, 60vw)`},placeholder:`Search fields & descriptions…`,value:n,onChange:e=>r(e.target.value)}),(0,q.jsx)(`span`,{style:{flex:1}}),(0,q.jsxs)(`span`,{className:`muted`,children:[o.length,` options`]})]}),s.length===0?(0,q.jsxs)(`div`,{className:`muted`,children:[`No fields match “`,n,`”.`]}):(0,q.jsx)(`div`,{className:`fguide`,children:s.map(([e,t])=>(0,q.jsxs)(`div`,{className:`fguide__sec`,children:[(0,q.jsx)(`h4`,{className:`fguide__sechd`,children:e}),(0,q.jsx)(`div`,{className:`fguide__list`,children:t.map(e=>(0,q.jsxs)(`div`,{className:`fguide__item`,children:[(0,q.jsxs)(`div`,{className:`fguide__top`,children:[(0,q.jsx)(`code`,{className:`fguide__path`,children:e.path}),(0,q.jsx)(`span`,{className:`fguide__type`,children:e.type}),e.required&&(0,q.jsx)(`span`,{className:`fguide__req`,children:`required`}),e.def!==void 0&&(0,q.jsxs)(`span`,{className:`fguide__def`,children:[`default `,(0,q.jsx)(`code`,{children:e.def})]})]}),e.desc&&(0,q.jsx)(`p`,{className:`fguide__desc`,children:e.desc}),e.enumv&&(0,q.jsx)(`div`,{className:`fguide__enum`,children:e.enumv.map(e=>(0,q.jsx)(`code`,{children:e},e))})]},e.path))})]},e))})]}):(0,q.jsx)(`div`,{className:`muted`,children:`loading schema…`})}var AY=/("(?:\\.|[^"\\])*"(?:\s*:)?)|\b(true|false|null)\b|(-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?)/g;function jY(e){let t=[],n=0,r=0;for(let i of e.matchAll(AY)){let a=i.index??0;a>n&&t.push(e.slice(n,a));let o=i[0],s;s=i[1]===void 0?i[2]===void 0?`j-num`:o===`null`?`j-null`:`j-bool`:/:\s*$/.test(o)?`j-key`:`j-str`,t.push((0,q.jsx)(`span`,{className:s,children:o},r++)),n=a+o.length}return n<e.length&&t.push(e.slice(n)),t}var MY=new RegExp([/(;;;[^\n]*)/,/("(?:\\.|[^"\\])*")/,/([0-9A-Fa-f]{2}(?::[0-9A-Fa-f]{2}){5})/,/(\d{1,3}(?:\.\d{1,3}){3}(?:\/\d{1,2})?)/,/([A-Za-z.][\w.-]*)(?==)/,/\b(running|enabled|active|connected|established|reachable|bound|authorized|ok|up)\b/,/\b(disabled|invalid|inactive|stopped|unreachable|timeout|failure|failed|error|rejected|expired|down)\b/,/\b(yes|no|true|false)\b/,/\b(dynamic|slave|builtin|default|passthrough|complete)\b/,/(-?\d+(?:\.\d+)?)/].map(e=>e.source).join(`|`),`gi`);function NY(e){let t=[],n=0,r=0;for(let i of e.matchAll(MY)){let a=i.index??0;a>n&&t.push(e.slice(n,a));let o=i[0],s=`ros-num`;i[1]===void 0?i[2]===void 0?i[3]===void 0?i[4]===void 0?i[5]===void 0?i[6]===void 0?i[7]===void 0?i[8]===void 0?i[9]!==void 0&&(s=`ros-dim`):s=`ros-bool`:s=`ros-bad`:s=`ros-good`:s=`ros-key`:s=`ros-ip`:s=`ros-mac`:s=`ros-str`:s=`ros-comment`,t.push((0,q.jsx)(`span`,{className:s,children:o},r++)),n=a+o.length}return n<e.length&&t.push(e.slice(n)),t}var PY=`mt-pretty-input`;function FY(){try{return localStorage.getItem(PY)!==`0`}catch{return!0}}function IY(e){try{localStorage.setItem(PY,e?`1`:`0`)}catch{}}function LY(e,t){if(!t)return e;try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}}function RY({value:e,maxHeight:t}){let n=typeof e==`string`?e:JSON.stringify(e,null,2);return(0,q.jsx)(`pre`,{className:`body json`,style:t?{maxHeight:t}:void 0,children:jY(n)})}function zY(e){let t=new Set,n=new Set,r=e=>{if(!e||typeof e!=`object`)return;let i=e;if(i.properties&&typeof i.properties==`object`)for(let e of Object.keys(i.properties))t.add(e),r(i.properties[e]);if(Array.isArray(i.enum))for(let e of i.enum)typeof e==`string`&&n.add(e);for(let e of[`items`,`additionalProperties`,`anyOf`,`oneOf`,`allOf`]){let t=i[e];Array.isArray(t)?t.forEach(r):t&&typeof t==`object`&&r(t)}for(let e of[`$defs`,`definitions`,`patternProperties`]){let t=i[e];if(t&&typeof t==`object`)for(let e of Object.values(t))r(e)}};return r(e),{keys:[...t].sort(),enums:[...n.add(`true`).add(`false`)].sort()}}function BY(e,t){let n=t;for(;n>0&&/[A-Za-z0-9_.-]/.test(e[n-1]);)n--;let r=e.slice(n,t),i=n-1;for(;i>=0&&/\s/.test(e[i]);)i--;return{word:r,start:n,isValue:e[i]===`:`}}var VY=[[`revert in 30s`,3e4],[`revert in 60s`,6e4],[`revert in 2m`,12e4],[`no auto-revert`,0]];function HY({initial:e,onClose:t,onReload:n}){let[r,i]=(0,v.useState)(()=>JSON.stringify(e,null,2)),[a,o]=(0,v.useState)({keys:[],enums:[]}),[s,c]=(0,v.useState)([]),[l,u]=(0,v.useState)(null),[d,f]=(0,v.useState)(null),[p,m]=(0,v.useState)({}),[h,g]=(0,v.useState)(null),[_,y]=(0,v.useState)(null),[b,x]=(0,v.useState)(0),[S,C]=(0,v.useState)(6e4),[w,T]=(0,v.useState)(null),E=(0,v.useRef)(null),D=(0,v.useRef)(null),O=(0,v.useRef)(null),k=(0,v.useRef)(null);(0,v.useEffect)(()=>{pc(`/api/config-schema`).then(e=>o(zY(e))).catch(()=>{})},[]),(0,v.useEffect)(()=>{D.current!=null&&E.current&&(E.current.selectionStart=E.current.selectionEnd=D.current,D.current=null)}),(0,v.useEffect)(()=>{let e=setTimeout(()=>{let e;try{e=JSON.parse(r)}catch(e){u(e instanceof Error?e.message:String(e)),c([]);return}u(null),mc(`/api/config/validate`,e).then(e=>c(e.errors??[])).catch(()=>{})},350);return()=>clearTimeout(e)},[r]),(0,v.useEffect)(()=>{if(!_||b<=0)return;let e=setInterval(()=>x(e=>Math.max(0,e-1)),1e3);return()=>clearInterval(e)},[_,b]),(0,v.useEffect)(()=>{_&&b===0&&(_.rollbackMs??0)>0&&(T(`Auto-reverted — changes were not confirmed in time.`),y(null),n())},[_,b,n]);let A=!l&&s.length===0,j=e=>{let{word:t,start:n,isValue:r}=BY(e.value,e.selectionStart);if(t.length<1){f(null);return}let i=(r?a.enums:a.keys).filter(e=>e.startsWith(t)&&e!==t).slice(0,8);if(!i.length){f(null);return}let o=e.value.slice(0,e.selectionStart).split(`
75
75
  `),s=o[o.length-1].length,c=Math.min(12+s*7.22-e.scrollLeft,e.clientWidth-160),l=10+o.length*18-e.scrollTop+4;f({items:i,index:0,start:n,x:Math.max(4,c),y:l})},M=e=>{let t=E.current;if(!t||!d)return;let n=r.slice(0,d.start)+e+r.slice(t.selectionStart);D.current=d.start+e.length,i(n),f(null)},N=e=>{if(!d){e.key===` `&&e.ctrlKey&&(e.preventDefault(),j(e.currentTarget));return}e.key===`ArrowDown`?(e.preventDefault(),f({...d,index:(d.index+1)%d.items.length})):e.key===`ArrowUp`?(e.preventDefault(),f({...d,index:(d.index-1+d.items.length)%d.items.length})):e.key===`Enter`||e.key===`Tab`?(e.preventDefault(),M(d.items[d.index])):e.key===`Escape`&&f(null)},P=()=>{try{return JSON.parse(r)}catch{return null}},F=async()=>{let e=P();if(!e?.devices)return;T(`Testing devices…`);let t={};for(let[n,r]of Object.entries(e.devices)){let e=await mc(`/api/config/test-device`,{name:n,config:r}).catch(()=>({ok:!1}));t[n]=e.ok&&e.status?.reachable===!0?{ok:!0,label:`${Math.round(e.status.latencyMs??0)}ms · ${e.status.identity??`ok`}`}:{ok:!1,label:e.status?.error??e.errors?.[0]?.message??`unreachable`},m({...t})}T(null)},I=async()=>{let e=P();e!=null&&g(await mc(`/api/config/preview`,e))},L=async()=>{let e=P();if(e==null)return;T(`Saving…`);let t=await mc(`/api/config`,{config:e,rollbackMs:S});if(T(null),g(null),!t.ok){c(t.errors??[{path:`(root)`,message:`save rejected`}]);return}y(t),x(Math.round((t.rollbackMs??0)/1e3))},ee=async()=>{_?.pendingId&&(await mc(`/api/config/keep`,{pendingId:_.pendingId}),y(null),T(`Changes kept.`),n())},te=async()=>{_?.pendingId&&(await mc(`/api/config/rollback`,{pendingId:_.pendingId}),y(null),T(`Reverted to the previous config.`),n())},R=r.split(`
76
76
  `).length;return(0,q.jsxs)(`div`,{className:`cfgstudio`,children:[(0,q.jsxs)(`div`,{className:`cfg-toolbar`,children:[(0,q.jsx)(`span`,{className:`cfg-status ${A?`is-ok`:`is-bad`}`,children:l?`invalid JSON`:s.length?`${s.length} schema issue(s)`:`valid ✓`}),(0,q.jsx)(`span`,{style:{flex:1}}),(0,q.jsx)(`button`,{className:`topo-btn`,onClick:()=>void F(),children:`Test devices`}),(0,q.jsx)(`button`,{className:`topo-btn`,onClick:()=>void I(),disabled:!A,children:`Preview diff`}),(0,q.jsx)(`select`,{className:`cfg-select`,value:S,onChange:e=>C(Number(e.target.value)),title:`Auto-revert window`,children:VY.map(([e,t])=>(0,q.jsx)(`option`,{value:t,children:e},t))}),(0,q.jsx)(`button`,{className:`topo-btn cfg-save`,onClick:()=>void L(),disabled:!A||!!_,children:`Save`}),(0,q.jsx)(`button`,{className:`topo-btn`,onClick:t,children:`Close`})]}),w&&(0,q.jsx)(`div`,{className:`cfg-msg`,children:w}),_&&(0,q.jsxs)(`div`,{className:`cfg-banner`,children:[(0,q.jsx)(`strong`,{children:`Applied.`}),` `,(_.rollbackMs??0)>0?(0,q.jsxs)(q.Fragment,{children:[`Reverting in `,(0,q.jsxs)(`span`,{className:`cfg-count`,children:[b,`s`]}),` unless you keep it.`]}):(0,q.jsx)(q.Fragment,{children:`Saved without an auto-revert window.`}),_.devicesChanged&&(0,q.jsxs)(`span`,{className:`cfg-warn`,children:[` `,`· device list changed — reconnect the MCP client to expose it to the model`]}),(0,q.jsx)(`span`,{style:{flex:1}}),(0,q.jsx)(`button`,{className:`topo-btn cfg-save`,onClick:()=>void ee(),children:`Keep changes`}),(0,q.jsx)(`button`,{className:`topo-btn`,onClick:()=>void te(),children:`Revert now`})]}),(0,q.jsxs)(`div`,{className:`cfg-editor`,children:[(0,q.jsx)(`pre`,{className:`cfg-gutter`,"aria-hidden":`true`,ref:k,children:Array.from({length:R},(e,t)=>t+1).join(`
77
77
  `)}),(0,q.jsxs)(`div`,{className:`cfg-ta-wrap`,children:[(0,q.jsxs)(`pre`,{className:`cfg-hl`,"aria-hidden":`true`,ref:O,children:[jY(r),`
78
78
  `]}),(0,q.jsx)(`textarea`,{ref:E,className:`cfg-ta`,spellCheck:!1,wrap:`off`,value:r,onChange:e=>{i(e.target.value),j(e.currentTarget)},onKeyDown:N,onClick:()=>f(null),onScroll:e=>{let t=e.currentTarget;O.current&&(O.current.scrollTop=t.scrollTop,O.current.scrollLeft=t.scrollLeft),k.current&&(k.current.scrollTop=t.scrollTop)}}),d&&(0,q.jsx)(`div`,{className:`cfg-ac`,style:{left:d.x,top:d.y},children:d.items.map((e,t)=>(0,q.jsx)(`div`,{className:`cfg-ac-item${t===d.index?` is-sel`:``}`,onMouseDown:t=>{t.preventDefault(),M(e)},children:e},e))})]})]}),Object.keys(p).length>0&&(0,q.jsx)(`div`,{className:`cfg-chips`,children:Object.entries(p).map(([e,t])=>(0,q.jsxs)(`span`,{className:`cfg-chip ${t.ok?`is-ok`:`is-bad`}`,children:[t.ok?`●`:`○`,` `,e,`: `,t.label]},e))}),(l||s.length>0)&&(0,q.jsx)(`div`,{className:`cfg-errors`,children:l?(0,q.jsxs)(`div`,{className:`cfg-err`,children:[`JSON: `,l]}):s.slice(0,12).map((e,t)=>(0,q.jsxs)(`div`,{className:`cfg-err`,children:[(0,q.jsx)(`code`,{children:e.path}),` — `,e.message]},t))}),h&&(0,q.jsxs)(`div`,{className:`cfg-preview`,children:[(0,q.jsxs)(`div`,{className:`cfg-preview__hd`,children:[(0,q.jsx)(`strong`,{children:`Diff vs current`}),(0,q.jsx)(`span`,{className:`muted`,children:h.summary?.changed?`+${h.summary.added} / -${h.summary.removed}`:`no changes`}),(0,q.jsx)(`span`,{style:{flex:1}}),(0,q.jsx)(`button`,{className:`topo-btn`,onClick:()=>g(null),children:`✕`})]}),(0,q.jsx)(`pre`,{className:`cfg-diff`,children:(h.unified||`(identical)`).split(`
79
79
  `).map((e,t)=>(0,q.jsx)(`div`,{className:e.startsWith(`+`)?`d-add`:e.startsWith(`-`)?`d-del`:e.startsWith(`@@`)?`d-hunk`:``,children:e||` `},t))})]})]})}function UY({x:e,y:t,text:n,className:r,textClassName:i,padX:a=9,fontSize:o=9}){let s=(0,v.useRef)(null),[c,l]=(0,v.useState)(()=>n.length*o*.62);(0,v.useLayoutEffect)(()=>{let e=s.current?.getComputedTextLength();e&&e>0&&l(e)},[n,o]);let u=Math.round(c+a*2);return(0,q.jsxs)(`g`,{transform:`translate(${e.toFixed(1)},${t.toFixed(1)})`,children:[(0,q.jsx)(`rect`,{className:r,x:-u/2,y:-9,rx:9,width:u,height:18}),(0,q.jsx)(`text`,{ref:s,className:i,x:0,y:3.5,textAnchor:`middle`,fontSize:o,children:n})]})}function WY(e){return e.reachable===!0?{label:`online`,color:`#d4d4d8`}:e.reachable===!1?{label:`offline`,color:`#f87171`}:{label:`checking…`,color:`#71717a`}}function GY(e){let t=0;for(let n=0;n<e.length;n++)t=Math.imul(t,31)+e.charCodeAt(n)>>>0;return`hsl(${t%360} 70% 62%)`}function KY(e,t,n,r){let i=1-r;return{x:i*i*e.x+2*i*r*t.x+r*r*n.x,y:i*i*e.y+2*i*r*t.y+r*r*n.y}}function qY(e,t,n,r){let i=1-r,a=2*i*(t.x-e.x)+2*r*(n.x-t.x),o=2*i*(t.y-e.y)+2*r*(n.y-t.y);return Math.atan2(o,a)*180/Math.PI}var JY=`#e4e4e7`,YY=`#d4d4d8`,XY=`#f59e0b`;function ZY(e){return e.jumpVia?e.jumpVia:e.jumpHost?`${e.jumpHost.host}:${e.jumpHost.port}`:null}var QY=18,$Y=e=>e.length>QY?`${e.slice(0,QY-1)}…`:e,eX=e=>Math.max(23,Math.min(70,e.length*3.1+12));function tX({payload:e,pulses:t}){let n=e.devices,r=Math.max(1,n.length),i=n.map(e=>{let t=$Y(e.name);return{d:e,label:t,r:eX(t)}}),a=Math.max(23,...i.map(e=>e.r)),o=r>1?(a+18)/Math.sin(Math.PI/r):0,s=Math.max(110+a,o,120),c=a+60,l=Math.max(700,Math.round((s+a+40)*2)),u=Math.round((s+c)*2),d=l/2,f=u/2,p={x:d,y:f},m=i.map((e,t)=>{let n=t/r*Math.PI*2-Math.PI/2+(r%2==0?Math.PI/r:0);return{...e,i:t,x:d+s*Math.cos(n),y:f+s*Math.sin(n)}});return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`svg`,{className:`conn`,viewBox:`0 0 ${l} ${u}`,width:`100%`,height:u,preserveAspectRatio:`xMidYMid meet`,children:[(0,q.jsxs)(`defs`,{children:[(0,q.jsxs)(`radialGradient`,{id:`conn-hub`,cx:`0.5`,cy:`0.34`,r:`0.75`,children:[(0,q.jsx)(`stop`,{offset:`0`,stopColor:`#fafafa`}),(0,q.jsx)(`stop`,{offset:`0.6`,stopColor:`#d4d4d8`}),(0,q.jsx)(`stop`,{offset:`1`,stopColor:`#a1a1aa`})]}),(0,q.jsxs)(`radialGradient`,{id:`conn-orb`,cx:`0.5`,cy:`0.32`,r:`0.85`,children:[(0,q.jsx)(`stop`,{offset:`0`,stopColor:`#27272a`}),(0,q.jsx)(`stop`,{offset:`1`,stopColor:`#18181b`})]}),(0,q.jsxs)(`radialGradient`,{id:`conn-burst`,cx:`0.5`,cy:`0.5`,r:`0.5`,children:[(0,q.jsx)(`stop`,{offset:`0`,stopColor:`#fafafa`}),(0,q.jsx)(`stop`,{offset:`0.5`,stopColor:`#e4e4e7`}),(0,q.jsx)(`stop`,{offset:`1`,stopColor:`#a1a1aa`,stopOpacity:`0`})]}),(0,q.jsxs)(`linearGradient`,{id:`conn-tunnel-grad`,x1:`0`,y1:`0`,x2:`1`,y2:`0`,children:[(0,q.jsx)(`stop`,{offset:`0`,stopColor:XY,stopOpacity:`0.15`}),(0,q.jsx)(`stop`,{offset:`0.5`,stopColor:XY,stopOpacity:`0.95`}),(0,q.jsx)(`stop`,{offset:`1`,stopColor:XY,stopOpacity:`0.15`})]}),(0,q.jsxs)(`filter`,{id:`conn-tunnel-glow`,x:`-40%`,y:`-40%`,width:`180%`,height:`180%`,children:[(0,q.jsx)(`feGaussianBlur`,{stdDeviation:`3`,result:`b`}),(0,q.jsxs)(`feMerge`,{children:[(0,q.jsx)(`feMergeNode`,{in:`b`}),(0,q.jsx)(`feMergeNode`,{in:`SourceGraphic`})]})]})]}),[.5,.78,1].map((e,t)=>(0,q.jsx)(`circle`,{className:`conn-grid`,cx:d,cy:f,r:s*e},`g-${t}`)),[0,1,2].map(e=>(0,q.jsx)(`circle`,{className:`conn-sonar`,cx:d,cy:f,style:{animationDelay:`${e*1.1}s`}},`s-${e}`)),m.map(({d:e,i:n,x:r,y:i})=>{let a=WY(e.status),o=e.status.reachable===!0,s=e.status.reachable==null,c={x:r,y:i},l=(d+r)/2,u=(f+i)/2,m=r-d,h=i-f,g=Math.hypot(m,h)||1,_=-h/g,v=m/g,y={x:l+_*16,y:u+v*16},b={x:l-_*16,y:u-v*16},x=`M${d},${f} Q${y.x.toFixed(1)},${y.y.toFixed(1)} ${r.toFixed(1)},${i.toFixed(1)}`,S=`M${d},${f} Q${b.x.toFixed(1)},${b.y.toFixed(1)} ${r.toFixed(1)},${i.toFixed(1)}`,C=`M${d},${f} Q${l.toFixed(1)},${u.toFixed(1)} ${r.toFixed(1)},${i.toFixed(1)}`,w=KY(p,y,c,.52),T=qY(p,y,c,.52),E=KY(p,b,c,.48),D=qY(p,b,c,.48)+180,O=t[e.name]??0;return(0,q.jsxs)(`g`,{children:[(0,q.jsx)(`path`,{id:`conn-cmd-${n}`,className:`conn-link`,d:x,stroke:o?JY:a.color,strokeOpacity:o?.5:.32,strokeDasharray:s?`2 8`:o?void 0:`6 7`}),(0,q.jsx)(`path`,{id:`conn-res-${n}`,className:`conn-link`,d:S,stroke:o?YY:a.color,strokeOpacity:o?.5:.18,strokeDasharray:o?void 0:`6 7`}),o&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`path`,{className:`conn-flow`,d:x,stroke:`#e4e4e7`}),(0,q.jsx)(`circle`,{className:`conn-packet`,r:3.2,fill:`#e4e4e7`,children:(0,q.jsx)(`animateMotion`,{dur:`2.6s`,repeatCount:`indefinite`,calcMode:`linear`,children:(0,q.jsx)(`mpath`,{href:`#conn-cmd-${n}`})})}),(0,q.jsx)(`rect`,{className:`conn-packet`,x:-2.6,y:-2.6,width:5.2,height:5.2,fill:`#d4d4d8`,transform:`rotate(45)`,children:(0,q.jsx)(`animateMotion`,{dur:`2.6s`,begin:`0.9s`,repeatCount:`indefinite`,calcMode:`linear`,keyPoints:`1;0`,keyTimes:`0;1`,children:(0,q.jsx)(`mpath`,{href:`#conn-res-${n}`})})}),(0,q.jsx)(`path`,{className:`conn-chevron`,d:`M-4,-3 L4,0 L-4,3`,stroke:`#e4e4e7`,transform:`translate(${w.x.toFixed(1)},${w.y.toFixed(1)}) rotate(${T.toFixed(1)})`}),(0,q.jsx)(`path`,{className:`conn-chevron`,d:`M-4,-3 L4,0 L-4,3`,stroke:`#d4d4d8`,transform:`translate(${E.x.toFixed(1)},${E.y.toFixed(1)}) rotate(${D.toFixed(1)})`})]}),O>0&&(0,q.jsx)(`g`,{children:(0,q.jsxs)(`circle`,{r:6,fill:`url(#conn-burst)`,children:[(0,q.jsx)(`animateMotion`,{dur:`1.1s`,repeatCount:`1`,calcMode:`linear`,keyPoints:`0;1;0`,keyTimes:`0;0.5;1`,path:C}),(0,q.jsx)(`animate`,{attributeName:`opacity`,values:`0;1;1;0`,keyTimes:`0;0.1;0.85;1`,dur:`1.1s`,repeatCount:`1`,fill:`freeze`})]})},`burst-${e.name}-${O}`)]},`l-${e.name}`)}),m.map(e=>{let t=e.d.jumpVia,n=t?m.find(e=>e.d.name===t):void 0,r=!n&&e.d.jumpHost?e.d.jumpHost:void 0;if(!n&&!r)return null;let i={x:e.x,y:e.y},a=Math.hypot(e.x-d,e.y-f)||1,o=(e.x-d)/a,s=(e.y-f)/a,c=n?{x:n.x,y:n.y}:{x:e.x+o*(e.r+46),y:e.y+s*(e.r+46)},l=(c.x+i.x)/2,u=(c.y+i.y)/2,p=Math.hypot(l-d,u-f)||1,h=n?50:16,g={x:l+(l-d)/p*h,y:u+(u-f)/p*h},_=`M${c.x.toFixed(1)},${c.y.toFixed(1)} Q${g.x.toFixed(1)},${g.y.toFixed(1)} ${i.x.toFixed(1)},${i.y.toFixed(1)}`,v=ZY(e.d)??``,y=KY(c,g,i,.5),b=`conn-tunnel-${e.i}`;return(0,q.jsxs)(`g`,{className:`conn-tunnel-g`,children:[(0,q.jsx)(`path`,{className:`conn-tunnel-halo`,d:_,stroke:XY}),(0,q.jsx)(`path`,{id:b,className:`conn-tunnel`,d:_,stroke:`url(#conn-tunnel-grad)`,filter:`url(#conn-tunnel-glow)`}),r&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`circle`,{className:`conn-tunnel-sat`,cx:c.x,cy:c.y,r:11,fill:`#1c1917`,stroke:`#f59e0b`}),(0,q.jsx)(`text`,{x:c.x,y:c.y+3.5,textAnchor:`middle`,fontSize:11,children:`🛡️`})]}),(0,q.jsxs)(`text`,{className:`conn-tunnel-lock`,fontSize:13,textAnchor:`middle`,children:[`🔒`,(0,q.jsx)(`animateMotion`,{dur:`2.4s`,repeatCount:`indefinite`,calcMode:`linear`,rotate:`auto`,children:(0,q.jsx)(`mpath`,{href:`#${b}`})})]}),(0,q.jsx)(UY,{x:y.x,y:y.y,text:`⤳ via ${v}`,className:`conn-tunnel-badge`,textClassName:`conn-tunnel-badge-tx`})]},`jump-${e.d.name}`)}),(0,q.jsx)(`circle`,{className:`conn-hub-glow`,cx:d,cy:f,r:42}),(0,q.jsx)(`circle`,{className:`conn-hub-ring`,cx:d,cy:f,r:37}),(0,q.jsx)(`circle`,{cx:d,cy:f,r:29,fill:`url(#conn-hub)`,stroke:`#71717a`,strokeWidth:1.5}),(0,q.jsx)(`text`,{x:d,y:f-4,textAnchor:`middle`,fill:`#09090b`,fontSize:12,fontWeight:700,children:`LLM`}),(0,q.jsx)(`text`,{x:d,y:f+8,textAnchor:`middle`,fill:`#3f3f46`,fontSize:8,fontWeight:600,children:`⇄ MCP`}),(0,q.jsx)(`text`,{x:d,y:f+18,textAnchor:`middle`,fill:`#3f3f46`,fontSize:7.5,fontWeight:600,children:`server`}),m.map(({d:e,x:t,y:n,r,label:i})=>{let a=WY(e.status),o=e.status.reachable===!0,s=o?`${e.status.latencyMs??`?`} ms`:a.label,c=GY(e.name);return(0,q.jsxs)(`g`,{className:`conn-node`,children:[o&&(0,q.jsx)(`circle`,{className:`conn-node-halo`,cx:t,cy:n,r:r+1,stroke:c}),e.pool?.pooled&&(0,q.jsx)(`circle`,{cx:t,cy:n,r:r+5,fill:`none`,stroke:e.pool.inflight>0?`#3b82f6`:`#22c55e`,strokeWidth:1.5,strokeDasharray:e.pool.inflight>0?void 0:`4 4`,opacity:.5,className:e.pool.inflight>0?`conn-blink`:void 0}),(0,q.jsx)(`circle`,{cx:t,cy:n,r,fill:`url(#conn-orb)`}),(0,q.jsx)(`circle`,{cx:t,cy:n,r,fill:c,opacity:.16}),(0,q.jsx)(`circle`,{cx:t,cy:n,r,fill:`none`,stroke:c,strokeWidth:2.5}),(0,q.jsx)(`circle`,{className:o?`conn-blink`:void 0,cx:t+r*.7,cy:n-r*.7,r:4.5,fill:a.color,stroke:`#0a121b`,strokeWidth:1.5}),(0,q.jsx)(`text`,{x:t,y:n+3.5,textAnchor:`middle`,fill:`#fafafa`,fontSize:10,fontWeight:600,children:i}),(0,q.jsx)(`text`,{x:t,y:n+r+14,textAnchor:`middle`,fill:`#a1a1aa`,fontSize:9,children:e.address??e.host}),(0,q.jsx)(`text`,{x:t,y:n+r+26,textAnchor:`middle`,fill:a.color,fontSize:9,fontWeight:600,children:s})]},`n-${e.name}`)})]}),(0,q.jsxs)(`div`,{className:`conn-legend`,children:[(0,q.jsxs)(`span`,{children:[(0,q.jsx)(`i`,{style:{background:JY}}),` command · LLM → device`]}),(0,q.jsxs)(`span`,{children:[(0,q.jsx)(`i`,{style:{background:YY}}),` response · device → LLM`]}),(0,q.jsxs)(`span`,{children:[(0,q.jsx)(`i`,{style:{background:`#e4e4e7`}}),` live call (round-trip)`]}),e.devices.some(e=>ZY(e))&&(0,q.jsxs)(`span`,{children:[(0,q.jsx)(`i`,{style:{background:`#f59e0b`}}),` 🔒 SSH jump tunnel (ProxyJump)`]}),e.devices.some(e=>e.pool?.pooled)&&(0,q.jsxs)(`span`,{children:[(0,q.jsx)(`i`,{style:{background:`#22c55e`}}),` pooled SSH connection`]})]})]})}function nX({d:e}){let t=WY(e.status),n=e.status.reachable===!0?`${t.label} · ${e.status.latencyMs??`?`}ms${e.status.version?` · v${e.status.version}`:``}`:e.status.reachable===!1?`${t.label}${e.status.error?` · ${e.status.error}`:``}`:t.label,r=GY(e.name);return(0,q.jsxs)(`div`,{className:`card dev-card`,style:{borderLeft:`3px solid ${r}`},children:[(0,q.jsxs)(`div`,{className:`dev-card__top`,children:[(0,q.jsx)(`span`,{className:`dot`,style:{background:r},title:`device colour`}),(0,q.jsx)(`span`,{className:`dev-card__name`,children:e.name}),e.isDefault&&(0,q.jsx)(Nc,{type:`accent`,children:`default`}),(0,q.jsx)(`span`,{className:`dot dot--status`,style:{background:t.color},title:t.label}),(0,q.jsx)(`span`,{style:{flex:1}}),(0,q.jsx)(`span`,{className:`chip`,children:e.authMode})]}),(0,q.jsxs)(`div`,{className:`dev-card__meta`,children:[(0,q.jsx)(`span`,{children:e.mac?`mac`:`host`}),(0,q.jsx)(`b`,{children:e.address??`${e.host}:${e.port}`}),(0,q.jsx)(`span`,{children:`user`}),(0,q.jsx)(`b`,{children:e.username}),(0,q.jsx)(`span`,{children:`status`}),(0,q.jsx)(`b`,{style:{color:t.color},children:n}),(0,q.jsx)(`span`,{children:`activity`}),(0,q.jsxs)(`b`,{children:[e.activity.calls,` calls · `,e.activity.errors,` err`,e.activity.avgMs?` · ${Sc(e.activity.avgMs)} avg`:``]}),e.pool&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`span`,{children:`pool`}),(0,q.jsx)(`b`,{style:{color:e.pool.dead?`#ef4444`:e.pool.inflight>0?`#3b82f6`:e.pool.pooled?`#22c55e`:`#52525b`},children:e.pool.pooled?e.pool.inflight>0?`${e.pool.inflight} inflight`:`connected`:`—`})]}),e.description&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`span`,{children:`note`}),(0,q.jsx)(`b`,{children:e.description})]})]}),ZY(e)&&(0,q.jsxs)(`div`,{className:`jump-route`,title:`Reached over SSH through the bastion ${ZY(e)} (ProxyJump) — no port exposed on ${e.name}.`,children:[(0,q.jsxs)(`span`,{className:`jump-route__hop jump-route__hop--bastion`,children:[`🛡️ `,ZY(e),e.jumpVia?(0,q.jsx)(`i`,{className:`jump-route__tag`,children:`jump`}):null]}),(0,q.jsx)(`span`,{className:`jump-route__wire jump-route__wire--enc`,children:(0,q.jsx)(`span`,{className:`jump-route__lock`,"aria-hidden":!0,children:`🔒`})}),(0,q.jsxs)(`span`,{className:`jump-route__hop jump-route__hop--dest`,style:{borderColor:r},title:e.name,children:[`📡 `,e.name]})]})]})}function rX({event:e,onClose:t}){let[n,r]=(0,v.useState)(FY);return(0,q.jsx)(`div`,{className:`overlay`,onClick:e=>e.target===e.currentTarget&&t(),children:(0,q.jsxs)(`div`,{className:`sheet`,children:[(0,q.jsxs)(`div`,{className:`sheet__hd`,children:[(0,q.jsx)(`span`,{className:`risk risk-${e.risk}`,children:e.risk}),(0,q.jsxs)(`h3`,{className:`sheet__tool`,children:[e.tool,(0,q.jsx)(xc,{text:e.tool,className:`iconbtn`,icon:!0,title:`Copy tool name`})]}),(0,q.jsx)(`span`,{style:{flex:1}}),(0,q.jsx)(jc,{type:`secondary`,size:`sm`,onClick:t,children:`✕ Close`})]}),(0,q.jsxs)(`div`,{className:`kv__body`,children:[(0,q.jsx)(`div`,{className:`kv__k`,children:`title`}),(0,q.jsx)(`div`,{className:`kv__v`,children:e.title}),e.reason&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`div`,{className:`kv__k kv__k--reason`,children:`reason`}),(0,q.jsx)(`div`,{className:`kv__v kv__v--reason`,children:e.reason})]}),(0,q.jsx)(`div`,{className:`kv__k`,children:`time`}),(0,q.jsx)(`div`,{className:`kv__v`,children:new Date(e.ts).toLocaleString(void 0,{hour12:!1})}),(0,q.jsx)(`div`,{className:`kv__k`,children:`device`}),(0,q.jsx)(`div`,{className:`kv__v`,children:e.device??`—`}),(0,q.jsx)(`div`,{className:`kv__k`,children:`transport`}),(0,q.jsx)(`div`,{className:`kv__v`,children:e.transport??`—`}),(0,q.jsx)(`div`,{className:`kv__k`,children:`duration`}),(0,q.jsx)(`div`,{className:`kv__v`,children:Sc(e.durationMs)}),(0,q.jsx)(`div`,{className:`kv__k`,children:`status`}),(0,q.jsx)(`div`,{className:`kv__v`,children:(0,q.jsx)(`span`,{className:e.isError?`status-err`:`status-ok`,children:e.isError?`error`:`ok`})}),(0,q.jsx)(`div`,{className:`kv__k`,children:`output size`}),(0,q.jsxs)(`div`,{className:`kv__v`,children:[Cc(e.outputBytes),e.truncated?` (truncated)`:``]}),(0,q.jsx)(`div`,{className:`kv__k`,children:`structured`}),(0,q.jsx)(`div`,{className:`kv__v`,children:e.hasStructured?`yes (renders an MCP App view)`:`no`})]}),e.error&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`h2`,{className:`muted`,children:`ERROR`}),(0,q.jsx)(`pre`,{className:`body`,style:{color:`var(--mt-bad)`},children:e.error})]}),(0,q.jsxs)(`div`,{className:`sheet__hd`,children:[(0,q.jsx)(`h2`,{className:`muted`,style:{margin:0},children:`INPUT`}),(0,q.jsx)(`span`,{style:{flex:1}}),e.input&&(0,q.jsx)(jc,{type:`secondary`,size:`sm`,ghost:!0,onClick:()=>r(e=>{let t=!e;return IY(t),t}),title:n?`Showing pretty-printed JSON — click for raw`:`Showing raw JSON — click to pretty-print`,children:n?`✦ Pretty`:`{ } Raw`}),(0,q.jsx)(xc,{text:e.input,title:`Copy input JSON`})]}),e.input?(0,q.jsx)(RY,{value:LY(e.input,n)}):(0,q.jsx)(`pre`,{className:`body`,children:`—`}),(0,q.jsxs)(`div`,{className:`sheet__hd`,children:[(0,q.jsx)(`h2`,{className:`muted`,style:{margin:0},children:`OUTPUT`}),(0,q.jsx)(`span`,{style:{flex:1}}),(0,q.jsx)(xc,{text:e.output,title:`Copy output`})]}),(0,q.jsx)(`pre`,{className:`body ros`,children:e.output?NY(e.output):`—`})]})})}var iX=e=>e==null?`?`:Cc(e);function aX({d:e}){let t=e.status,n=e.history??[];return t.reachable===!0||n.length>0?(0,q.jsxs)(`div`,{className:`card health-card`,children:[(0,q.jsxs)(`div`,{className:`health-card__hd`,children:[(0,q.jsx)(Pc,{color:WY(t).color}),(0,q.jsx)(`span`,{className:`dev-card__name`,children:e.name}),e.isDefault&&(0,q.jsx)(Nc,{type:`accent`,children:`default`}),(0,q.jsx)(`span`,{style:{flex:1}}),(0,q.jsx)(Nc,{type:t.version?`success`:`default`,children:t.version?`v${t.version}`:`—`})]}),(0,q.jsxs)(`div`,{className:`health-card__sub muted`,children:[t.boardName??`router`,t.architecture?` · ${t.architecture}`:``,t.cpuCount?` · ${t.cpuCount} cpu`:``,t.uptime?` · up ${t.uptime}`:``]}),(0,q.jsxs)(`div`,{className:`health-card__gauges`,children:[(0,q.jsx)(fY,{value:t.cpuLoad,label:`CPU`,color:Dc.cpu}),(0,q.jsx)(fY,{value:t.memUsedPct,label:`MEM`,color:Dc.mem}),(0,q.jsx)(fY,{value:t.hddUsedPct,label:`DISK`,color:Dc.disk})]}),(0,q.jsxs)(`div`,{className:`health-card__charts`,children:[(0,q.jsxs)(`div`,{className:`health-chart`,children:[(0,q.jsx)(`span`,{className:`health-chart__k`,children:`CPU load`}),(0,q.jsx)(dY,{id:`${e.name}-cpu`,values:n.map(e=>e.cpuLoad),color:Dc.cpu,maxValue:100,unit:`%`})]}),(0,q.jsxs)(`div`,{className:`health-chart`,children:[(0,q.jsx)(`span`,{className:`health-chart__k`,children:`Memory used`}),(0,q.jsx)(dY,{id:`${e.name}-mem`,values:n.map(e=>e.memUsedPct),color:Dc.mem,maxValue:100,unit:`%`})]}),(0,q.jsxs)(`div`,{className:`health-chart`,children:[(0,q.jsx)(`span`,{className:`health-chart__k`,children:`Probe latency`}),(0,q.jsx)(dY,{id:`${e.name}-lat`,values:n.map(e=>e.latencyMs),color:Dc.latency,unit:`ms`})]})]}),(0,q.jsxs)(`div`,{className:`health-card__foot muted`,children:[`RAM `,iX(t.totalMemory&&t.freeMemory?t.totalMemory-t.freeMemory:void 0),` /`,` `,iX(t.totalMemory),` · free disk `,iX(t.freeHdd)]})]}):(0,q.jsxs)(`div`,{className:`card health-card health-card--na`,children:[(0,q.jsxs)(`div`,{className:`health-card__hd`,children:[(0,q.jsx)(Pc,{color:WY(t).color}),(0,q.jsx)(`span`,{className:`dev-card__name`,children:e.name}),e.isDefault&&(0,q.jsx)(Nc,{type:`accent`,children:`default`})]}),(0,q.jsx)(`p`,{className:`muted`,style:{margin:0},children:t.reachable===!1?`Offline — ${t.error??`unreachable`}`:e.mac?`Waiting for the first MAC-Telnet probe (these run every few minutes to avoid contending with tool calls)…`:`Waiting for the first health probe…`})]})}function oX(e,t){let n=(0,v.useRef)(e),r=(0,v.useRef)(t);n.current=e,r.current=t,(0,v.useEffect)(()=>{let e=!1,t=null,i=null,a=()=>{e||(i=new EventSource(fc(`/api/sse`)),i.addEventListener(`hello`,()=>r.current(`sse`)),i.addEventListener(`tool`,e=>{try{n.current(JSON.parse(e.data))}catch{}}),i.onerror=()=>{i&&i.readyState===EventSource.CONNECTING&&r.current(`off`)})},o=()=>{if(e)return;let i=location.protocol===`https:`?`wss`:`ws`;t=new WebSocket(fc(`${i}://${location.host}/api/stream`));let s=!1;t.onopen=()=>{s=!0,r.current(`ws`)},t.onerror=()=>t?.close(),t.onmessage=e=>{try{let t=JSON.parse(e.data);t.type===`event`&&t.event&&n.current(t.event)}catch{}},t.onclose=()=>{e||(r.current(`off`),s?setTimeout(o,2e3):a())}};return o(),()=>{e=!0,t?.close(),i?.close()}},[])}function sX(e){(0,v.useLayoutEffect)(()=>{let t=e.current;if(!t||window.matchMedia(`(prefers-reduced-motion: reduce)`).matches)return;document.documentElement.classList.add(`js-motion`);let n=new WeakSet,r=e=>{n.has(e)||(n.add(e),Ri.set(e,{opacity:0,y:26}),K.create({trigger:e,start:`top 90%`,once:!0,onEnter:()=>Ri.to(e,{opacity:1,y:0,duration:.7,ease:`power3.out`})}))},i=e=>{for(let t of e.querySelectorAll(`.reveal`))r(t)};i(t);let a=new MutationObserver(e=>{for(let t of e)for(let e of t.addedNodes)e instanceof Element&&(e.matches(`.reveal`)&&r(e),i(e))});a.observe(t,{childList:!0,subtree:!0});let o=setInterval(()=>K.refresh(),1200),s=setTimeout(()=>clearInterval(o),7e3);return()=>{a.disconnect(),clearInterval(o),clearTimeout(s);for(let e of K.getAll())e.kill();document.documentElement.classList.remove(`js-motion`)}},[e])}function cX({m:e,busy:t,onToggle:n}){return(0,q.jsxs)(`label`,{className:`mod-row`,"data-on":e.enabled?`1`:void 0,title:e.description,children:[(0,q.jsx)(`input`,{type:`checkbox`,checked:e.enabled,disabled:t,onChange:()=>n(e.slug,!e.enabled)}),(0,q.jsxs)(`span`,{className:`mod-row__main`,children:[(0,q.jsxs)(`span`,{className:`mod-row__name`,children:[e.label,(0,q.jsx)(`code`,{className:`mod-row__slug`,children:e.slug})]}),(0,q.jsx)(`span`,{className:`mod-row__desc muted`,children:e.description})]}),(0,q.jsxs)(`span`,{className:`mod-row__count muted`,children:[e.toolCount,` tool`,e.toolCount===1?``:`s`]})]})}function lX(){let[e,t]=(0,v.useState)(null),[n,r]=(0,v.useState)(new Set),[i,a]=(0,v.useState)(null),[o,s]=(0,v.useState)(``),c=(0,v.useCallback)(()=>{pc(`/api/modules`).then(t).catch(()=>a(`could not load modules`))},[]);(0,v.useEffect)(()=>c(),[c]);let l=e=>t(t=>t?{...t,...e}:e),u=(0,v.useCallback)(async(e,n)=>{r(t=>new Set(t).add(e)),t(t=>t&&{...t,modules:t.modules.map(t=>t.slug===e?{...t,enabled:n}:t)});let i=await mc(`/api/modules/toggle`,{slug:e,enabled:n}).catch(()=>({error:`request failed`}));if(r(t=>{let n=new Set(t);return n.delete(e),n}),i.error||i.ok===!1){a(i.error??`toggle failed`),c();return}l(i);let o=i.persisted?`saved to config`:`applied live (not saved)`,s=i.warning?` ⚠ ${i.warning}`:``;a(`${e} ${n?`enabled`:`disabled`} — ${o}. Reconnect the MCP client (or restart the server) for the tool list to update.${s}`)},[c]),d=(0,v.useCallback)(async(e,t)=>{for(let n of e)await u(n,t)},[u]),f=(0,v.useMemo)(()=>{if(!e)return[];let t=o.trim().toLowerCase(),n=e=>!t||e.slug.toLowerCase().includes(t)||e.label.toLowerCase().includes(t)||e.group.toLowerCase().includes(t)||e.description.toLowerCase().includes(t),r=new Map;for(let t of e.modules){if(!n(t))continue;let e=r.get(t.group)??[];e.push(t),r.set(t.group,e)}return[...r.entries()].map(([e,t])=>({group:e,modules:t}))},[e,o]);if(!e)return(0,q.jsx)(`div`,{className:`muted`,children:`loading modules…`});let p=f.reduce((e,t)=>e+t.modules.length,0);return(0,q.jsx)(`section`,{className:`view`,children:(0,q.jsxs)(_c,{title:`Tool modules`,className:`reveal`,extra:(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`span`,{className:`muted`,children:[e.enabledModules,`/`,e.total,` modules · `,e.enabledTools,`/`,e.totalTools,` `,`tools exposed`]}),(0,q.jsx)(`button`,{className:`btn`,onClick:c,style:{marginLeft:10},children:`↻ Refresh`})]}),children:[(0,q.jsxs)(`div`,{className:`legend`,style:{margin:`0 0 10px`},children:[(0,q.jsxs)(`span`,{children:[`writes to: `,(0,q.jsx)(`code`,{children:e.source?.path??`config file`})]}),(0,q.jsx)(`span`,{children:e.hasAllowList?`allow-list active`:`all modules on by default`})]}),(0,q.jsxs)(`p`,{className:`muted`,style:{margin:`0 0 12px`,fontSize:12},children:[`Toggle a module to expose or hide all of its tools. Disabling adds it to`,` `,(0,q.jsx)(`code`,{children:`tools.disabledModules`}),` in your config file; enabling removes it (or adds it to`,` `,(0,q.jsx)(`code`,{children:`tools.enabledModules`}),` when an allow-list is in force). Trimming the surface below ~150–200 tools makes every remaining tool reliably findable by the MCP client. The client must reconnect for changes to take effect.`]}),(0,q.jsxs)(`div`,{className:`mod-toolbar`,children:[(0,q.jsx)(`input`,{className:`input`,placeholder:`Filter modules by name, slug, group or description…`,value:o,onChange:e=>s(e.target.value)}),(0,q.jsx)(`span`,{style:{flex:1}}),(0,q.jsx)(`button`,{className:`btn`,onClick:()=>void d(e.modules.filter(e=>!e.enabled).map(e=>e.slug),!0),children:`Enable all`}),` `,(0,q.jsx)(`button`,{className:`btn`,onClick:()=>void d(e.modules.filter(e=>e.enabled).map(e=>e.slug),!1),children:`Disable all`})]}),i&&(0,q.jsx)(`div`,{className:`cfg-msg`,style:{marginTop:12},children:i}),p===0?(0,q.jsxs)(`div`,{className:`muted`,style:{padding:12},children:[`No modules match “`,o,`”.`]}):(0,q.jsx)(`div`,{className:`mod-groups`,children:f.map(({group:e,modules:t})=>{let r=t.filter(e=>e.enabled).length,i=t.map(e=>e.slug);return(0,q.jsxs)(`div`,{className:`mod-group`,children:[(0,q.jsxs)(`div`,{className:`mod-group__hd`,children:[(0,q.jsx)(`h3`,{className:`mod-group__title`,children:e}),(0,q.jsxs)(`span`,{className:`muted`,children:[r,`/`,t.length,` on`]}),(0,q.jsx)(`span`,{style:{flex:1}}),(0,q.jsx)(`button`,{className:`btn btn-sm`,onClick:()=>void d(i.filter(e=>{let n=t.find(t=>t.slug===e);return n?!n.enabled:!1}),!0),children:`Enable group`}),` `,(0,q.jsx)(`button`,{className:`btn btn-sm`,onClick:()=>void d(i.filter(e=>{let n=t.find(t=>t.slug===e);return n?n.enabled:!1}),!1),children:`Disable group`})]}),(0,q.jsx)(`div`,{className:`mod-list`,children:t.map(e=>(0,q.jsx)(cX,{m:e,busy:n.has(e.slug),onToggle:(e,t)=>void u(e,t)},e.slug))})]},e)})})]})})}var uX={TCP:`#e4e4e7`,UDP:`#d4d4d8`,ICMP:`#a1a1aa`,ICMPv6:`#a1a1aa`,ARP:`#e4e4e7`,IPv6:`#a1a1aa`},dX=e=>e&&uX[e]||`#71717a`;function fX(){let[e,t]=(0,v.useState)(null),[n,r]=(0,v.useState)(!1);(0,v.useEffect)(()=>{let e=()=>void pc(`/api/capture/packets?limit=150`).then(t).catch(()=>{});e();let n=setInterval(e,1500);return()=>clearInterval(n)},[]);let i=e?.stats,a=e?.packets??[],o=async()=>{r(!0),await mc(`/api/capture/stop`,{}).catch(()=>{}),r(!1)};if(!i||!i.running&&i.packets===0)return(0,q.jsxs)(`div`,{className:`cap-idle muted`,children:[`No capture running. Start one with the `,(0,q.jsx)(`code`,{children:`start_packet_capture`}),` tool — point the device's TZSP stream at this host — and decoded packets stream in here live.`]});let s=Math.max(1,...Object.values(i.protocols));return(0,q.jsxs)(`div`,{className:`cap`,children:[(0,q.jsxs)(`div`,{className:`cap-bar`,children:[(0,q.jsx)(`span`,{className:`cap-dot${i.running?` is-on`:``}`}),(0,q.jsx)(`b`,{children:i.running?`capturing`:`stopped`}),(0,q.jsxs)(`span`,{className:`muted`,children:[`UDP `,i.port]}),(0,q.jsxs)(`span`,{className:`muted`,children:[Tc(i.packets),` pkts · `,Cc(i.bytes)]}),(0,q.jsx)(`span`,{style:{flex:1}}),(0,q.jsx)(`a`,{className:`btn`,href:fc(`/api/capture/pcap`),download:`capture.pcap`,children:`⤓ pcap`}),(0,q.jsx)(`button`,{className:`btn btn-danger`,onClick:()=>void o(),disabled:n||!i.running,children:`■ Stop`})]}),(0,q.jsxs)(`div`,{className:`cap-cols`,children:[(0,q.jsxs)(`div`,{className:`cap-side`,children:[(0,q.jsx)(`div`,{className:`cap-h`,children:`Protocols`}),Object.entries(i.protocols).map(([e,t])=>(0,q.jsxs)(`div`,{className:`cap-pbar`,children:[(0,q.jsx)(`span`,{className:`cap-plabel`,style:{color:dX(e)},children:e}),(0,q.jsx)(`span`,{className:`cap-ptrack`,children:(0,q.jsx)(`i`,{style:{width:`${t/s*100}%`,background:dX(e)}})}),(0,q.jsx)(`span`,{className:`cap-pn`,children:t})]},e)),(0,q.jsx)(`div`,{className:`cap-h`,style:{marginTop:12},children:`Top talkers`}),i.topTalkers.length===0&&(0,q.jsx)(`div`,{className:`muted`,children:`—`}),i.topTalkers.map(e=>(0,q.jsxs)(`div`,{className:`cap-talker`,children:[(0,q.jsx)(`span`,{children:e.addr}),(0,q.jsx)(`b`,{children:e.count})]},e.addr))]}),(0,q.jsx)(`div`,{className:`cap-list`,children:a.length===0?(0,q.jsx)(`div`,{className:`muted`,style:{padding:10},children:`waiting for packets…`}):a.map((e,t)=>(0,q.jsxs)(`div`,{className:`cap-row`,children:[(0,q.jsx)(`span`,{className:`cap-tt`,children:wc(e.ts)}),(0,q.jsx)(`span`,{className:`cap-proto`,style:{color:dX(e.protocol)},children:e.protocol??e.ethType}),(0,q.jsx)(`span`,{className:`cap-len`,children:e.len}),(0,q.jsx)(`span`,{className:`cap-info`,children:e.info})]},t))})]})]})}function pX(){let[e,t]=(0,v.useState)(null),[n,r]=(0,v.useState)(null),[i,a]=(0,v.useState)(null),[o,s]=(0,v.useState)(null),c=(0,v.useCallback)(()=>{pc(`/api/s3/list`).then(t).catch(()=>t({configured:!1,objects:[]}))},[]);(0,v.useEffect)(()=>c(),[c]);let l=e=>{pc(`/api/s3/presign?key=${encodeURIComponent(e)}`).then(e=>{e.url?window.open(e.url,`_blank`,`noopener`):s(`could not generate download link`)}).catch(()=>s(`could not generate download link`))},u=async e=>{a(e);let t=await mc(`/api/s3/delete`,{key:e}).catch(()=>({error:`request failed`}));a(null),r(null),t.ok?(s(`Deleted ${e}`),c()):s(t.error??`delete failed`)};return e?e.configured?(0,q.jsx)(`section`,{className:`view`,children:(0,q.jsxs)(_c,{title:`S3 backups`,className:`reveal`,extra:(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`span`,{className:`muted`,children:[e.target,` · `,e.objects.length,` object`,e.objects.length===1?``:`s`,e.truncated?` (truncated)`:``]}),(0,q.jsx)(`button`,{className:`btn`,onClick:c,style:{marginLeft:10},children:`↻ Refresh`})]}),children:[o&&(0,q.jsx)(`div`,{className:`cfg-msg`,children:o}),e.objects.length===0?(0,q.jsxs)(`div`,{className:`muted`,style:{padding:12},children:[`No objects in the bucket. Upload one with the `,(0,q.jsx)(`code`,{children:`upload_backup_to_s3`}),` tool.`]}):(0,q.jsx)(`div`,{className:`feedwrap`,children:(0,q.jsxs)(`table`,{className:`feed`,children:[(0,q.jsx)(`thead`,{children:(0,q.jsxs)(`tr`,{children:[(0,q.jsx)(`th`,{children:`key`}),(0,q.jsx)(`th`,{className:`num`,children:`size`}),(0,q.jsx)(`th`,{children:`modified`}),(0,q.jsx)(`th`,{style:{width:200},children:`actions`})]})}),(0,q.jsx)(`tbody`,{children:e.objects.map(e=>(0,q.jsxs)(`tr`,{children:[(0,q.jsx)(`td`,{children:e.key}),(0,q.jsx)(`td`,{className:`num`,children:Cc(e.size)}),(0,q.jsx)(`td`,{children:e.lastModified?new Date(e.lastModified).toLocaleString(void 0,{hour12:!1}):`—`}),(0,q.jsxs)(`td`,{onClick:e=>e.stopPropagation(),children:[(0,q.jsx)(`button`,{className:`btn`,onClick:()=>l(e.key),children:`⤓ Download`}),` `,n===e.key?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`button`,{className:`btn btn-danger`,disabled:i===e.key,onClick:()=>void u(e.key),children:`✓ Confirm`}),` `,(0,q.jsx)(`button`,{className:`btn`,onClick:()=>r(null),children:`Cancel`})]}):(0,q.jsx)(`button`,{className:`btn`,onClick:()=>r(e.key),children:`🗑 Delete`})]})]},e.key))})]})})]})}):(0,q.jsxs)(`div`,{className:`feed-empty`,children:[(0,q.jsx)(`div`,{className:`feed-empty__icon`,children:`☁️`}),(0,q.jsx)(`p`,{className:`feed-empty__title`,children:`S3 is not configured`}),(0,q.jsxs)(`p`,{className:`feed-empty__sub`,children:[`Add an `,(0,q.jsx)(`code`,{children:`s3`}),` block (bucket + credentials) to your config to manage backup objects here.`]})]}):(0,q.jsx)(`div`,{className:`muted`,children:`loading S3 objects…`})}function mX(){let[e,t]=(0,v.useState)(null),[n,r]=(0,v.useState)(``),[i,a]=(0,v.useState)(``),[o,s]=(0,v.useState)(null),[c,l]=(0,v.useState)(null),u=(0,v.useCallback)(()=>{pc(`/api/snapshots`).then(e=>t(e.snapshots)).catch(()=>t([]))},[]);(0,v.useEffect)(()=>u(),[u]);let d=e=>{pc(`/api/snapshot/${encodeURIComponent(e)}`).then(s).catch(()=>{})},f=()=>{!n||!i||mc(`/api/snapshots/diff`,{from:n,to:i}).then(l).catch(()=>{})};if(!e)return(0,q.jsx)(`div`,{className:`muted`,children:`loading snapshots…`});if(e.length===0)return(0,q.jsxs)(`div`,{className:`feed-empty`,children:[(0,q.jsx)(`div`,{className:`feed-empty__icon`,children:`🕰️`}),(0,q.jsx)(`p`,{className:`feed-empty__title`,children:`No config snapshots yet`}),(0,q.jsxs)(`p`,{className:`feed-empty__sub`,children:[`Capture one with the `,(0,q.jsx)(`code`,{children:`capture_config_snapshot`}),` tool — then time-travel diff any two here.`]})]});let p=e.map(e=>(0,q.jsxs)(`option`,{value:e.id,children:[e.device,` · `,e.label??e.id,` · `,wc(e.ts)]},e.id));return(0,q.jsxs)(`section`,{className:`view`,children:[(0,q.jsxs)(_c,{title:`Config snapshots`,className:`reveal`,extra:(0,q.jsx)(`button`,{className:`btn`,onClick:u,children:`↻ Refresh`}),children:[(0,q.jsxs)(`div`,{className:`toolbar`,style:{marginBottom:12},children:[(0,q.jsxs)(`select`,{className:`btn`,value:n,onChange:e=>r(e.target.value),children:[(0,q.jsx)(`option`,{value:``,children:`diff from…`}),p]}),(0,q.jsxs)(`select`,{className:`btn`,value:i,onChange:e=>a(e.target.value),children:[(0,q.jsx)(`option`,{value:``,children:`to…`}),p]}),(0,q.jsx)(`button`,{className:`btn is-active`,onClick:f,disabled:!n||!i,children:`Diff →`}),(0,q.jsxs)(`span`,{className:`muted`,children:[e.length,` snapshots`]})]}),(0,q.jsx)(`div`,{className:`feedwrap`,children:(0,q.jsxs)(`table`,{className:`feed`,children:[(0,q.jsx)(`thead`,{children:(0,q.jsxs)(`tr`,{children:[(0,q.jsx)(`th`,{children:`captured`}),(0,q.jsx)(`th`,{children:`device`}),(0,q.jsx)(`th`,{children:`label`}),(0,q.jsx)(`th`,{children:`version`}),(0,q.jsx)(`th`,{className:`num`,children:`lines`}),(0,q.jsx)(`th`,{className:`num`,children:`size`}),(0,q.jsx)(`th`,{children:`output`})]})}),(0,q.jsx)(`tbody`,{children:e.map(e=>(0,q.jsxs)(`tr`,{className:o?.id===e.id?`is-selected`:void 0,onClick:()=>d(e.id),children:[(0,q.jsx)(`td`,{children:wc(e.ts)}),(0,q.jsx)(`td`,{children:e.device}),(0,q.jsx)(`td`,{children:e.label??`—`}),(0,q.jsx)(`td`,{children:e.rosVersion??`—`}),(0,q.jsx)(`td`,{className:`num`,children:e.lines}),(0,q.jsx)(`td`,{className:`num`,children:Cc(e.bytes)}),(0,q.jsx)(`td`,{className:`preview`,children:`view export →`})]},e.id))})]})})]}),c&&(0,q.jsx)(_c,{title:`Time-travel diff`,className:`reveal`,extra:(0,q.jsx)(`span`,{className:`muted`,children:c.summary.changed?`+${c.summary.added} / -${c.summary.removed}`:`identical`}),children:(0,q.jsx)(`pre`,{className:`cfg-diff`,children:(c.unified||`(identical)`).split(`
80
- `).map((e,t)=>(0,q.jsx)(`div`,{className:e.startsWith(`+`)?`d-add`:e.startsWith(`-`)?`d-del`:e.startsWith(`@@`)?`d-hunk`:``,children:e||` `},t))})}),o&&(0,q.jsx)(_c,{title:`Snapshot · ${o.label??o.id}`,className:`reveal`,extra:(0,q.jsx)(jc,{type:`secondary`,size:`sm`,onClick:()=>s(null),children:`✕ Close`}),children:(0,q.jsx)(`pre`,{className:`body`,style:{maxHeight:460},children:o.body||`(empty)`})})]})}function hX(e){return e==null?`#3f3f46`:e>=85?`#f87171`:e>=60?`#a1a1aa`:`#d4d4d8`}function gX({topo:e,onOnboard:t}){let[n,r]=(0,v.useState)(null),i=e.nodes.filter(e=>e.kind===`device`),a=e.nodes.filter(e=>e.kind===`neighbor`),o=Math.max(1,i.length),s=i.length<=1?0:Math.min(150,76+o*8),c=s+(i.length<=1?180:140),l=Math.max(360,Math.round((c+78)*2)),u=l/2,d=new Map,f=new Map;i.forEach((e,t)=>{if(i.length===1){d.set(e.id,{x:380,y:u}),f.set(e.id,-Math.PI/2);return}let n=t/o*Math.PI*2-Math.PI/2;f.set(e.id,n),d.set(e.id,{x:380+s*Math.cos(n),y:u+s*Math.sin(n)})});let p=new Map,m=new Set(a.map(e=>e.id));for(let t of e.edges)m.has(t.to)&&!p.has(t.to)&&p.set(t.to,t.from);let h=new Map;for(let e of a){let t=p.get(e.id)??i[0]?.id??``;h.set(t,[...h.get(t)??[],e.id])}if(i.length<=1)a.forEach((e,t)=>{let n=t/Math.max(1,a.length)*Math.PI*2-Math.PI/2;d.set(e.id,{x:380+c*Math.cos(n),y:u+c*Math.sin(n)})});else for(let[e,t]of h){let n=f.get(e)??-Math.PI/2,r=Math.min(Math.PI/2.2,.32*t.length);t.forEach((e,i)=>{let a=t.length===1?n:n-r/2+r*i/(t.length-1);d.set(e,{x:380+c*Math.cos(a),y:u+c*Math.sin(a)})})}let g=new Map(e.nodes.map(e=>[e.id,e])),_=n?g.get(n):null;return(0,q.jsxs)(`div`,{className:`topo`,children:[(0,q.jsxs)(`svg`,{viewBox:`0 0 760 ${l}`,width:`100%`,height:Math.min(l,540),preserveAspectRatio:`xMidYMid meet`,children:[e.edges.map((e,t)=>{let n=d.get(e.from),r=d.get(e.to);return!n||!r?null:(0,q.jsx)(`line`,{className:`topo-edge${m.has(e.to)?` is-dashed`:``}`,x1:n.x,y1:n.y,x2:r.x,y2:r.y,children:(0,q.jsxs)(`title`,{children:[e.from,` → `,e.to,e.interface?` (${e.interface})`:``]})},`e-${t}`)}),e.nodes.map(e=>{let t=d.get(e.id);if(!t)return null;let i=e.kind===`device`,a=i?132:108,o=i?50:38,s=t.x-a/2,c=t.y-o/2,l=e.reachable===!0?`#d4d4d8`:e.reachable===!1?`#f87171`:i?`#71717a`:`#e4e4e7`,u=n===e.id;return(0,q.jsxs)(`g`,{className:`topo-node${i?` is-device`:` is-neighbor`}${e.onboardable?` is-onboard`:``}${u?` is-picked`:``}`,transform:`translate(${s},${c})`,onClick:()=>r(t=>t===e.id?null:e.id),children:[(0,q.jsx)(`rect`,{width:a,height:o,rx:9,style:{stroke:l}}),(0,q.jsx)(`text`,{className:`topo-label`,x:9,y:16,children:(e.label||e.id).slice(0,16)}),i?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`text`,{className:`topo-sub`,x:9,y:30,children:(e.board||e.ip||``).slice(0,18)}),(0,q.jsx)(`rect`,{className:`topo-bar-bg`,x:9,y:37,width:a-18,height:4,rx:2}),(0,q.jsx)(`rect`,{x:9,y:37,width:(a-18)*Math.min(100,e.cpuLoad??0)/100,height:4,rx:2,style:{fill:hX(e.cpuLoad)}}),(0,q.jsx)(`rect`,{className:`topo-bar-bg`,x:9,y:43,width:a-18,height:4,rx:2}),(0,q.jsx)(`rect`,{x:9,y:43,width:(a-18)*Math.min(100,e.memUsedPct??0)/100,height:4,rx:2,style:{fill:hX(e.memUsedPct)}})]}):(0,q.jsx)(`text`,{className:`topo-sub`,x:9,y:29,children:e.onboardable?`+ onboard`:e.ip||e.mac||``})]},e.id)})]}),(0,q.jsxs)(`div`,{className:`topo-foot`,children:[(0,q.jsxs)(`span`,{className:`legend`,children:[(0,q.jsxs)(`span`,{children:[(0,q.jsx)(`i`,{className:`dot`,style:{background:`#d4d4d8`}}),` online`]}),(0,q.jsxs)(`span`,{children:[(0,q.jsx)(`i`,{className:`dot`,style:{background:`#f87171`}}),` offline`]}),(0,q.jsxs)(`span`,{children:[(0,q.jsx)(`i`,{className:`dot`,style:{background:`#e4e4e7`}}),` neighbour`]}),(0,q.jsxs)(`span`,{className:`muted`,children:[e.stats.devices,` devices · `,e.stats.neighbors,` discovered ·`,` `,e.stats.onboardable,` onboardable`]})]}),_&&(0,q.jsxs)(`div`,{className:`topo-pop`,children:[(0,q.jsxs)(`div`,{className:`topo-pop__hd`,children:[(0,q.jsx)(`strong`,{children:_.label}),(0,q.jsx)(`span`,{className:`muted`,children:[_.board,_.version,_.mac].filter(Boolean).join(` · `)||`no details advertised`}),(0,q.jsx)(`span`,{style:{flex:1}}),(0,q.jsx)(`button`,{className:`topo-btn`,onClick:()=>r(null),children:`✕`})]}),_.suggestedConfig?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`div`,{className:`muted`,style:{margin:`2px 0 6px`},children:`Not managed yet — add this to your device config to onboard it:`}),(0,q.jsx)(`pre`,{className:`topo-stub`,children:JSON.stringify({[_.suggestedConfig.name]:_X(_.suggestedConfig)},null,2)}),(0,q.jsx)(xc,{className:`topo-btn`,title:`Copy config stub`,label:`Copy config stub`,text:JSON.stringify({[_.suggestedConfig.name]:_X(_.suggestedConfig)},null,2)}),t&&(0,q.jsx)(`button`,{className:`topo-btn cfg-save`,onClick:()=>t(_.suggestedConfig.name,_X(_.suggestedConfig)),children:`Add to config →`})]}):(0,q.jsxs)(`div`,{className:`muted`,children:[`Managed device`,_.ip?` · ${_.ip}`:``,_.uptime?` · up ${_.uptime}`:``]})]})]})]})}function _X(e){let t={port:e.port,username:e.username};return e.host&&(t.host=e.host),e.mac&&(t.mac=e.mac),t}function vX(e){return e>=1e3?`${(e/1e3).toFixed(1)}s`:`${Math.round(e)}ms`}function yX(e){return!e||!e.pooled?`#52525b`:e.dead?`#ef4444`:e.inflight>0?`#3b82f6`:`#22c55e`}function bX(e){return!e||!e.pooled?`no connection`:e.dead?`reconnecting`:e.inflight>0?`${e.inflight} inflight`:`ready`}function xX({device:e}){let t=e.pool,n=!t||!t.pooled?`disconnected`:t.dead?`dead`:t.inflight>0?`busy`:`idle`,r=yX(t),i=!t||!t.pooled?0:t.inflight>0?Math.min(8+t.inflight*15,100):100;return(0,q.jsxs)(`div`,{className:`pool-card pool-card--${n}`,children:[(0,q.jsxs)(`div`,{className:`pool-card__hd`,children:[(0,q.jsx)(`span`,{className:`pool-card__dot`,style:{background:r}}),(0,q.jsx)(`span`,{className:`pool-card__name`,children:e.name}),(0,q.jsx)(`span`,{className:`pool-card__badge`,style:{color:r},children:bX(t)})]}),(0,q.jsxs)(`div`,{className:`pool-pipe`,children:[(0,q.jsx)(`div`,{className:`pool-pipe__fill${n===`busy`?` pool-pipe__fill--pulse`:``}`,style:{width:`${i}%`,background:r}}),t&&t.pooled&&t.inflight>0&&(0,q.jsxs)(`span`,{className:`pool-pipe__label`,children:[t.inflight,` ch`]})]})]})}function SX({k:e,v:t,sub:n}){return(0,q.jsxs)(`div`,{className:`stat`,style:{minWidth:100},children:[(0,q.jsx)(`p`,{className:`k`,children:e}),(0,q.jsxs)(`div`,{className:`v`,children:[t,n!=null&&(0,q.jsxs)(`small`,{children:[` `,n]})]})]})}function CX({devices:e,poolPayload:t}){let n=e.filter(e=>e.pool!==null&&e.pool!==void 0);if(!(t?.enabled??n.length>0)&&n.length===0)return(0,q.jsxs)(`details`,{className:`pool-panel`,open:!0,children:[(0,q.jsx)(`summary`,{style:{cursor:`pointer`,fontWeight:600,marginBottom:8},children:`SSH Connection Pool`}),(0,q.jsxs)(`p`,{className:`pool-disabled`,children:[`Connection pooling is disabled. Enable it with `,(0,q.jsx)(`code`,{children:`--ssh-keep-alive true`}),` or`,` `,(0,q.jsx)(`code`,{children:`MIKROTIK_SSH__KEEP_ALIVE=true`}),` to keep persistent SSH connections across tool calls.`]})]});let r=t?.aggregate,i=t?.config;return(0,q.jsxs)(`details`,{className:`pool-panel`,open:!0,children:[(0,q.jsx)(`summary`,{style:{cursor:`pointer`,fontWeight:600,marginBottom:8},children:`SSH Connection Pool`}),r&&(0,q.jsxs)(`div`,{className:`pool-stats`,children:[(0,q.jsx)(SX,{k:`Connections`,v:String(r.totalConnections)}),(0,q.jsx)(SX,{k:`Inflight`,v:String(r.totalInflight),sub:`channels`}),(0,q.jsx)(SX,{k:`Idle`,v:String(r.totalIdle)}),(0,q.jsx)(SX,{k:`Busy`,v:String(r.totalBusy)}),i&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(SX,{k:`Keepalive`,v:vX(i.keepAliveInterval)}),(0,q.jsx)(SX,{k:`Idle timeout`,v:vX(i.idleTimeout)})]})]}),n.length>0&&(0,q.jsx)(`div`,{className:`pool-grid`,children:n.map(e=>(0,q.jsx)(xX,{device:e},e.name))})]})}var wX=`mt-whats-new-dismissed`,TX=`mt-whats-new-seen-version`;function EX(e){try{return localStorage.getItem(wX)===e}catch{return!1}}function DX(e){try{localStorage.setItem(wX,e)}catch{}}function OX(e){try{let t=localStorage.getItem(TX);return localStorage.setItem(TX,e),t!==null&&t!==e}catch{return!1}}function kX(e){let t=e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`),n=[];t=t.replace(/```(\w*)\n([\s\S]*?)```/g,(e,t,r)=>(n.push(`<pre><code>${r.trim()}</code></pre>`),`%%CB${n.length-1}%%`));let r=[];t=t.replace(/`([^`]+)`/g,(e,t)=>(r.push(`<code>${t}</code>`),`%%IC${r.length-1}%%`)),t=t.replace(/!\[([^\]]*)\]\(([^)]+)\)/g,`<img src="$2" alt="$1" style="max-width:100%;border-radius:6px;margin:6px 0"/>`),t=t.replace(/\[([^\]]+)\]\(([^)]+)\)/g,`<a href="$2" target="_blank" rel="noopener">$1</a>`),t=t.replace(/\*\*\*(.+?)\*\*\*/g,`<strong><em>$1</em></strong>`),t=t.replace(/\*\*(.+?)\*\*/g,`<strong>$1</strong>`),t=t.replace(/(?<!\*)\*([^*]+)\*(?!\*)/g,`<em>$1</em>`),t=t.replace(/~~(.+?)~~/g,`<del>$1</del>`),t=t.replace(/^#### (.+)$/gm,`<h5>$1</h5>`),t=t.replace(/^### (.+)$/gm,`<h4>$1</h4>`),t=t.replace(/^## (.+)$/gm,`<h3>$1</h3>`),t=t.replace(/^# (.+)$/gm,`<h2>$1</h2>`),t=t.replace(/^&gt; (.+)$/gm,`<blockquote>$1</blockquote>`),t=t.replace(/<\/blockquote>\n<blockquote>/g,`
80
+ `).map((e,t)=>(0,q.jsx)(`div`,{className:e.startsWith(`+`)?`d-add`:e.startsWith(`-`)?`d-del`:e.startsWith(`@@`)?`d-hunk`:``,children:e||` `},t))})}),o&&(0,q.jsx)(_c,{title:`Snapshot · ${o.label??o.id}`,className:`reveal`,extra:(0,q.jsx)(jc,{type:`secondary`,size:`sm`,onClick:()=>s(null),children:`✕ Close`}),children:(0,q.jsx)(`pre`,{className:`body`,style:{maxHeight:460},children:o.body||`(empty)`})})]})}function hX(e){return e==null?`#3f3f46`:e>=85?`#f87171`:e>=60?`#a1a1aa`:`#d4d4d8`}function gX({topo:e,onOnboard:t}){let[n,r]=(0,v.useState)(null),i=e.nodes.filter(e=>e.kind===`device`),a=e.nodes.filter(e=>e.kind===`neighbor`),o=Math.max(1,i.length),s=i.length<=1?0:Math.min(150,76+o*8),c=s+(i.length<=1?180:140),l=Math.max(360,Math.round((c+78)*2)),u=l/2,d=new Map,f=new Map;i.forEach((e,t)=>{if(i.length===1){d.set(e.id,{x:380,y:u}),f.set(e.id,-Math.PI/2);return}let n=t/o*Math.PI*2-Math.PI/2;f.set(e.id,n),d.set(e.id,{x:380+s*Math.cos(n),y:u+s*Math.sin(n)})});let p=new Map,m=new Set(a.map(e=>e.id));for(let t of e.edges)m.has(t.to)&&!p.has(t.to)&&p.set(t.to,t.from);let h=new Map;for(let e of a){let t=p.get(e.id)??i[0]?.id??``;h.set(t,[...h.get(t)??[],e.id])}if(i.length<=1)a.forEach((e,t)=>{let n=t/Math.max(1,a.length)*Math.PI*2-Math.PI/2;d.set(e.id,{x:380+c*Math.cos(n),y:u+c*Math.sin(n)})});else for(let[e,t]of h){let n=f.get(e)??-Math.PI/2,r=Math.min(Math.PI/2.2,.32*t.length);t.forEach((e,i)=>{let a=t.length===1?n:n-r/2+r*i/(t.length-1);d.set(e,{x:380+c*Math.cos(a),y:u+c*Math.sin(a)})})}let g=new Map(e.nodes.map(e=>[e.id,e])),_=n?g.get(n):null;return(0,q.jsxs)(`div`,{className:`topo`,children:[(0,q.jsxs)(`svg`,{viewBox:`0 0 760 ${l}`,width:`100%`,height:Math.min(l,540),preserveAspectRatio:`xMidYMid meet`,children:[e.edges.map((e,t)=>{let n=d.get(e.from),r=d.get(e.to);return!n||!r?null:(0,q.jsx)(`line`,{className:`topo-edge${m.has(e.to)?` is-dashed`:``}`,x1:n.x,y1:n.y,x2:r.x,y2:r.y,children:(0,q.jsxs)(`title`,{children:[e.from,` → `,e.to,e.interface?` (${e.interface})`:``]})},`e-${t}`)}),e.nodes.map(e=>{let t=d.get(e.id);if(!t)return null;let i=e.kind===`device`,a=i?132:108,o=i?50:38,s=t.x-a/2,c=t.y-o/2,l=e.reachable===!0?`#d4d4d8`:e.reachable===!1?`#f87171`:i?`#71717a`:`#e4e4e7`,u=n===e.id;return(0,q.jsxs)(`g`,{className:`topo-node${i?` is-device`:` is-neighbor`}${e.onboardable?` is-onboard`:``}${u?` is-picked`:``}`,transform:`translate(${s},${c})`,onClick:()=>r(t=>t===e.id?null:e.id),children:[(0,q.jsx)(`rect`,{width:a,height:o,rx:9,style:{stroke:l}}),(0,q.jsx)(`text`,{className:`topo-label`,x:9,y:16,children:(e.label||e.id).slice(0,16)}),i?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`text`,{className:`topo-sub`,x:9,y:30,children:(e.board||e.ip||``).slice(0,18)}),(0,q.jsx)(`rect`,{className:`topo-bar-bg`,x:9,y:37,width:a-18,height:4,rx:2}),(0,q.jsx)(`rect`,{x:9,y:37,width:(a-18)*Math.min(100,e.cpuLoad??0)/100,height:4,rx:2,style:{fill:hX(e.cpuLoad)}}),(0,q.jsx)(`rect`,{className:`topo-bar-bg`,x:9,y:43,width:a-18,height:4,rx:2}),(0,q.jsx)(`rect`,{x:9,y:43,width:(a-18)*Math.min(100,e.memUsedPct??0)/100,height:4,rx:2,style:{fill:hX(e.memUsedPct)}})]}):(0,q.jsx)(`text`,{className:`topo-sub`,x:9,y:29,children:e.onboardable?`+ onboard`:e.ip||e.mac||``})]},e.id)})]}),(0,q.jsxs)(`div`,{className:`topo-foot`,children:[(0,q.jsxs)(`span`,{className:`legend`,children:[(0,q.jsxs)(`span`,{children:[(0,q.jsx)(`i`,{className:`dot`,style:{background:`#d4d4d8`}}),` online`]}),(0,q.jsxs)(`span`,{children:[(0,q.jsx)(`i`,{className:`dot`,style:{background:`#f87171`}}),` offline`]}),(0,q.jsxs)(`span`,{children:[(0,q.jsx)(`i`,{className:`dot`,style:{background:`#e4e4e7`}}),` neighbour`]}),(0,q.jsxs)(`span`,{className:`muted`,children:[e.stats.devices,` devices · `,e.stats.neighbors,` discovered ·`,` `,e.stats.onboardable,` onboardable`]})]}),_&&(0,q.jsxs)(`div`,{className:`topo-pop`,children:[(0,q.jsxs)(`div`,{className:`topo-pop__hd`,children:[(0,q.jsx)(`strong`,{children:_.label}),(0,q.jsx)(`span`,{className:`muted`,children:[_.board,_.version,_.mac].filter(Boolean).join(` · `)||`no details advertised`}),(0,q.jsx)(`span`,{style:{flex:1}}),(0,q.jsx)(`button`,{className:`topo-btn`,onClick:()=>r(null),children:`✕`})]}),_.suggestedConfig?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`div`,{className:`muted`,style:{margin:`2px 0 6px`},children:`Not managed yet — add this to your device config to onboard it:`}),(0,q.jsx)(`pre`,{className:`topo-stub`,children:JSON.stringify({[_.suggestedConfig.name]:_X(_.suggestedConfig)},null,2)}),(0,q.jsx)(xc,{className:`topo-btn`,title:`Copy config stub`,label:`Copy config stub`,text:JSON.stringify({[_.suggestedConfig.name]:_X(_.suggestedConfig)},null,2)}),t&&(0,q.jsx)(`button`,{className:`topo-btn cfg-save`,onClick:()=>t(_.suggestedConfig.name,_X(_.suggestedConfig)),children:`Add to config →`})]}):(0,q.jsxs)(`div`,{className:`muted`,children:[`Managed device`,_.ip?` · ${_.ip}`:``,_.uptime?` · up ${_.uptime}`:``]})]})]})]})}function _X(e){let t={port:e.port,username:e.username};return e.host&&(t.host=e.host),e.mac&&(t.mac=e.mac),t}function vX(e){return e>=1e3?`${(e/1e3).toFixed(1)}s`:`${Math.round(e)}ms`}function yX(e){return!e||!e.pooled?`#52525b`:e.dead?`#ef4444`:e.inflight>0?`#3b82f6`:`#22c55e`}function bX(e){return!e||!e.pooled?`no connection`:e.dead?`reconnecting`:e.inflight>0?`${e.inflight} inflight`:`ready`}function xX({device:e}){let t=e.pool,n=!t||!t.pooled?`disconnected`:t.dead?`dead`:t.inflight>0?`busy`:`idle`,r=yX(t),i=!t||!t.pooled?0:t.inflight>0?Math.min(8+t.inflight*15,100):100;return(0,q.jsxs)(`div`,{className:`pool-card pool-card--${n}`,children:[(0,q.jsxs)(`div`,{className:`pool-card__hd`,children:[(0,q.jsx)(`span`,{className:`pool-card__dot`,style:{background:r}}),(0,q.jsx)(`span`,{className:`pool-card__name`,children:e.name}),(0,q.jsx)(`span`,{className:`pool-card__badge`,style:{color:r},children:bX(t)})]}),(0,q.jsxs)(`div`,{className:`pool-pipe`,children:[(0,q.jsx)(`div`,{className:`pool-pipe__fill${n===`busy`?` pool-pipe__fill--pulse`:``}`,style:{width:`${i}%`,background:r}}),t&&t.pooled&&t.inflight>0&&(0,q.jsxs)(`span`,{className:`pool-pipe__label`,children:[t.inflight,` ch`]})]})]})}function SX({k:e,v:t,sub:n}){return(0,q.jsxs)(`div`,{className:`stat`,style:{minWidth:100},children:[(0,q.jsx)(`p`,{className:`k`,children:e}),(0,q.jsxs)(`div`,{className:`v`,children:[t,n!=null&&(0,q.jsxs)(`small`,{children:[` `,n]})]})]})}function CX({devices:e,poolPayload:t}){let n=e.filter(e=>e.pool!==null&&e.pool!==void 0);if(!(t?.enabled??n.length>0)&&n.length===0)return(0,q.jsxs)(`details`,{className:`pool-panel`,open:!0,children:[(0,q.jsx)(`summary`,{style:{cursor:`pointer`,fontWeight:600,marginBottom:8},children:`SSH Connection Pool`}),(0,q.jsxs)(`p`,{className:`pool-disabled`,children:[`Connection pooling is disabled. Enable it with `,(0,q.jsx)(`code`,{children:`--ssh-keep-alive true`}),` or`,` `,(0,q.jsx)(`code`,{children:`MIKROTIK_SSH__KEEP_ALIVE=true`}),` to keep persistent SSH connections across tool calls.`]})]});let r=t?.aggregate,i=t?.config;return(0,q.jsxs)(`details`,{className:`pool-panel`,open:!0,children:[(0,q.jsx)(`summary`,{style:{cursor:`pointer`,fontWeight:600,marginBottom:8},children:`SSH Connection Pool`}),r&&(0,q.jsxs)(`div`,{className:`pool-stats`,children:[(0,q.jsx)(SX,{k:`Connections`,v:String(r.totalConnections)}),(0,q.jsx)(SX,{k:`Inflight`,v:String(r.totalInflight),sub:`channels`}),(0,q.jsx)(SX,{k:`Idle`,v:String(r.totalIdle)}),(0,q.jsx)(SX,{k:`Busy`,v:String(r.totalBusy)}),i&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(SX,{k:`Keepalive`,v:vX(i.keepAliveInterval)}),(0,q.jsx)(SX,{k:`Idle timeout`,v:vX(i.idleTimeout)})]})]}),n.length>0&&(0,q.jsx)(`div`,{className:`pool-grid`,children:n.map(e=>(0,q.jsx)(xX,{device:e},e.name))})]})}var wX=`mt-whats-new-dismissed`,TX=`mt-whats-new-seen-version`;function EX(e){try{return localStorage.getItem(wX)===e}catch{return!1}}function DX(e){try{localStorage.setItem(wX,e)}catch{}}function OX(e){try{let t=localStorage.getItem(TX);return localStorage.setItem(TX,e),t!==null&&t!==e}catch{return!1}}function kX(e){let t=e.replace(/\r\n?/g,`
81
+ `);t=t.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`);let n=[];t=t.replace(/```(\w*)\n([\s\S]*?)```/g,(e,t,r)=>(n.push(`<pre><code>${r.trim()}</code></pre>`),`%%CB${n.length-1}%%`));let r=[];t=t.replace(/`([^`]+)`/g,(e,t)=>(r.push(`<code>${t}</code>`),`%%IC${r.length-1}%%`)),t=t.replace(/!\[([^\]]*)\]\(([^)]+)\)/g,`<img src="$2" alt="$1" style="max-width:100%;border-radius:6px;margin:6px 0"/>`),t=t.replace(/\[([^\]]+)\]\(([^)]+)\)/g,`<a href="$2" target="_blank" rel="noopener">$1</a>`),t=t.replace(/(?<!=["'])(https?:\/\/[^\s<>")\]]+)/g,`<a href="$1" target="_blank" rel="noopener">$1</a>`),t=t.replace(/\*\*\*(.+?)\*\*\*/g,`<strong><em>$1</em></strong>`),t=t.replace(/\*\*(.+?)\*\*/g,`<strong>$1</strong>`),t=t.replace(/(?<!\*)\*([^*]+)\*(?!\*)/g,`<em>$1</em>`),t=t.replace(/~~(.+?)~~/g,`<del>$1</del>`),t=t.replace(/^#### (.+)$/gm,`<h5>$1</h5>`),t=t.replace(/^### (.+)$/gm,`<h4>$1</h4>`),t=t.replace(/^## (.+)$/gm,`<h3>$1</h3>`),t=t.replace(/^# (.+)$/gm,`<h2>$1</h2>`),t=t.replace(/^&gt; (.+)$/gm,`<blockquote>$1</blockquote>`),t=t.replace(/<\/blockquote>\n<blockquote>/g,`
81
82
  `),t=t.replace(/^---$/gm,`<hr/>`),t=t.replace(/((?:^\|.+\|\n?)+)/gm,e=>{let t=e.trim().split(`
82
- `).filter(Boolean);if(t.length<2)return e;let n=e=>e.split(`|`).slice(1,-1).map(e=>e.trim()),r=n(t[0]),i=/^\|[\s:*-]+\|$/.test(t[1].replace(/[^|:*-\s]/g,``)),a=i?n(t[1]):null,o=a?a.map(e=>e.startsWith(`:`)&&e.endsWith(`:`)?`center`:e.endsWith(`:`)?`right`:`left`):r.map(()=>`left`),s=t.slice(i?2:1),c=`<div class="wn-table-wrap"><table><thead><tr>`;for(let e=0;e<r.length;e++)c+=`<th style="text-align:${o[e]}">${r[e]}</th>`;c+=`</tr></thead><tbody>`;for(let e of s){let t=n(e);c+=`<tr>`;for(let e=0;e<r.length;e++)c+=`<td style="text-align:${o[e]}">${t[e]??``}</td>`;c+=`</tr>`}return c+=`</tbody></table></div>`,c}),t=t.replace(/^(\d+)\. (.+)$/gm,`<oli>$2</oli>`),t=t.replace(/<\/oli>\n\n+<oli>/g,`</oli>
83
- <oli>`),t=t.replace(/((?:<oli>.*<\/oli>\n?)+)/g,e=>`<ol>${e.replace(/<\/?oli>/g,e=>e.replace(`oli`,`li`))}</ol>`),t=t.replace(/^[-*] (.+)$/gm,`<li>$1</li>`),t=t.replace(/<\/li>\n\n+<li>/g,`</li>
84
- <li>`),t=t.replace(/((?:<li>.*<\/li>\n?)+)/g,`<ul>$1</ul>`),t=t.replace(/<li>\[x\] (.+?)<\/li>/g,`<li class="wn-task done"><span class="wn-check">&#10003;</span> $1</li>`),t=t.replace(/<li>\[ \] (.+?)<\/li>/g,`<li class="wn-task"><span class="wn-check">&#9744;</span> $1</li>`);let i=t.split(`
85
- `),a=[];for(let e of i){let t=e.trim();t?/^<(h[2-5]|ul|ol|li|pre|blockquote|hr|div|table|img)/.test(t)?a.push(t):a.push(`<p>${t}</p>`):a.push(``)}return t=a.join(`
83
+ `).filter(Boolean);if(t.length<2)return e;let n=e=>e.split(`|`).slice(1,-1).map(e=>e.trim()),r=n(t[0]),i=/^(\|[\s:*-]+)+\|$/.test(t[1].replace(/[^|:*-\s]/g,``)),a=i?n(t[1]):null,o=a?a.map(e=>e.startsWith(`:`)&&e.endsWith(`:`)?`center`:e.endsWith(`:`)?`right`:`left`):r.map(()=>`left`),s=t.slice(i?2:1),c=`<div class="wn-table-wrap"><table><thead><tr>`;for(let e=0;e<r.length;e++)c+=`<th style="text-align:${o[e]}">${r[e]}</th>`;c+=`</tr></thead><tbody>`;for(let e of s){let t=n(e);c+=`<tr>`;for(let e=0;e<r.length;e++)c+=`<td style="text-align:${o[e]}">${t[e]??``}</td>`;c+=`</tr>`}return c+=`</tbody></table></div>`,c}),t=t.replace(/^(\d+)\. (.+)$/gm,`<oli>$2</oli>`),t=t.replace(/<\/oli>\n\n+<oli>/g,`</oli>
84
+ <oli>`),t=t.replace(/((?:<oli>.*<\/oli>\n?)+)/g,e=>`<ol>${e.trimEnd().replace(/<\/?oli>/g,e=>e.replace(`oli`,`li`))}</ol>`),t=t.replace(/^[-*] (.+)$/gm,`<li>$1</li>`),t=t.replace(/<\/li>\n\n+<li>/g,`</li>
85
+ <li>`),t=t.replace(/((?:<li>.*<\/li>\n?)+)/g,e=>`<ul>${e.trimEnd()}</ul>`),t=t.replace(/<li>\[x\] (.+?)<\/li>/g,`<li class="wn-task done"><span class="wn-check">&#10003;</span> $1</li>`),t=t.replace(/<li>\[ \] (.+?)<\/li>/g,`<li class="wn-task"><span class="wn-check">&#9744;</span> $1</li>`);let i=t.split(`
86
+ `),a=[];for(let e of i){let t=e.trim();t?/^<\/?(h[2-5]|ul|ol|li|pre|blockquote|hr|div|table|img)/.test(t)?a.push(t):a.push(`<p>${t}</p>`):a.push(``)}return t=a.join(`
86
87
  `),t=t.replace(/%%CB(\d+)%%/g,(e,t)=>n[Number(t)]),t=t.replace(/%%IC(\d+)%%/g,(e,t)=>r[Number(t)]),t}function AX(e){let t=(e*37+13)%100,n=(e*53+7)%100,r=e*.3%6,i=2+e%3;return{left:`${t}%`,top:`${n}%`,width:i,height:i,animationDelay:`${r}s`,animationDuration:`${4+e%4}s`}}var jX=Array.from({length:20},(e,t)=>t),MX=600*1e3;function NX(e){let[t,n]=(0,v.useState)(null),[r,i]=(0,v.useState)(!1);(0,v.useEffect)(()=>{if(!e)return;let t=OX(e),r=null,a=()=>{pc(`/api/releases/latest`).then(e=>{n(e);let a=r===null,o=r!==null&&e.version!==r;if(r=e.version,a&&t){setTimeout(()=>i(!0),1200);return}e.isNewer&&!EX(e.version)&&(a||o)&&setTimeout(()=>i(!0),a?1200:0)}).catch(()=>{})};a();let o=setInterval(a,MX);return()=>clearInterval(o)},[e]);let a=(0,v.useCallback)(()=>{t?.isNewer&&DX(t.version),i(!1)},[t]),o=(0,v.useCallback)(()=>i(!0),[]);return{release:t,showModal:r,showIndicator:t!==null&&t.isNewer,openModal:o,dismissRelease:a}}function PX({release:e,onDismiss:t}){let[n,r]=(0,v.useState)(!1),i=(0,v.useRef)(null),a=(0,v.useCallback)(()=>{r(!0),setTimeout(()=>{r(!1),t()},300)},[t]);(0,v.useEffect)(()=>{let e=e=>{e.key===`Escape`&&a()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[a]);let o=new Date(e.publishedAt).toLocaleDateString(`en-US`,{month:`short`,day:`numeric`,year:`numeric`});return(0,q.jsx)(`div`,{className:`wn-overlay${n?` is-closing`:``}`,onClick:e=>e.target===e.currentTarget&&a(),children:(0,q.jsxs)(`div`,{className:`wn-card`,ref:i,children:[(0,q.jsx)(`div`,{className:`wn-particles`,"aria-hidden":`true`,children:jX.map(e=>(0,q.jsx)(`span`,{className:`wn-particle`,style:AX(e)},e))}),(0,q.jsx)(`div`,{className:`wn-glow`,"aria-hidden":`true`}),(0,q.jsx)(`button`,{className:`wn-close`,onClick:a,"aria-label":`Close`,children:(0,q.jsx)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 14 14`,fill:`none`,children:(0,q.jsx)(`path`,{d:`M1 1l12 12M13 1L1 13`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`})})}),(0,q.jsxs)(`div`,{className:`wn-hero`,children:[(0,q.jsx)(`span`,{className:`wn-badge`,children:e.isNewer?`NEW RELEASE`:`RELEASE NOTES`}),(0,q.jsxs)(`h2`,{className:`wn-version`,children:[`v`,e.version]}),(0,q.jsxs)(`p`,{className:`wn-date`,children:[`Released `,o,e.isNewer&&(0,q.jsxs)(q.Fragment,{children:[` · you’re on v`,e.currentVersion]})]})]}),(0,q.jsx)(`div`,{className:`wn-divider`,children:(0,q.jsx)(`span`,{className:`wn-dot`})}),(0,q.jsx)(`div`,{className:`wn-body`,dangerouslySetInnerHTML:{__html:kX(e.body)}}),(0,q.jsxs)(`div`,{className:`wn-footer`,children:[(0,q.jsxs)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:`wn-link`,children:[`View on GitHub`,(0,q.jsx)(`svg`,{width:`13`,height:`13`,viewBox:`0 0 13 13`,fill:`none`,children:(0,q.jsx)(`path`,{d:`M1 12L12 1M12 1H4M12 1v8`,stroke:`currentColor`,strokeWidth:`1.4`,strokeLinecap:`round`,strokeLinejoin:`round`})})]}),(0,q.jsx)(jc,{type:`default`,size:`sm`,onClick:a,children:`Got it`})]})]})})}Ri.registerPlugin(K);function FX(e,t,n){let r=URL.createObjectURL(new Blob([t],{type:`${n};charset=utf-8`})),i=document.createElement(`a`);i.href=r,i.download=e,document.body.append(i),i.click(),i.remove(),URL.revokeObjectURL(r)}var IX=[{id:`overview`,label:`Overview`,sub:`Calls, latency & risk at a glance`},{id:`devices`,label:`Devices`,sub:`Connectivity radar & system health`},{id:`clients`,label:`Clients`,sub:`Connected LAN devices — usage, block/allow, pin IP`},{id:`aaa`,label:`RADIUS & UM`,sub:`RADIUS client & User Manager RADIUS server`},{id:`topology`,label:`Topology`,sub:`Layer-2 neighbours via MNDP / CDP / LLDP`},{id:`packets`,label:`Packets`,sub:`Live TZSP capture & decode`},{id:`snapshots`,label:`Snapshots`,sub:`Config history & time-travel diff`},{id:`plan`,label:`Change Plan`,sub:`Dry-run intended RouterOS commands`},{id:`s3`,label:`S3 Backups`,sub:`List, download & delete S3 backup objects`},{id:`backups`,label:`Backups`,sub:`Local config vault — create, restore, manage`},{id:`modules`,label:`Modules`,sub:`Enable/disable tool modules — curate the surface`},{id:`config`,label:`Config`,sub:`Effective configuration & safe editor`},{id:`feed`,label:`Live Feed`,sub:`Every tool call, in real time`}],LX=new Set(IX.map(e=>e.id)),RX=`mt-view`;function zX(){try{let e=location.hash.replace(/^#\/?/,``);return LX.has(e)?e:null}catch{return null}}function BX(){let e=zX();if(e)return e;try{let e=localStorage.getItem(RX);if(e&&LX.has(e))return e}catch{}return`overview`}var VX=[`#ededed`,`#a1a1a1`],HX={overview:VX,devices:VX,clients:VX,aaa:VX,topology:VX,packets:VX,snapshots:VX,plan:VX,s3:VX,backups:VX,modules:VX,config:VX,feed:VX},UX={overview:{what:`A live pulse of all MCP tool activity: total calls, error rate, p50/p95 latency, the busiest tools, and a risk breakdown — over a time window you choose.`,tips:[`Change the time window (top-right) to zoom from the last 5 minutes out to 24 hours.`,`The risk donut splits calls by annotation: read · write · destructive · dangerous.`,`A rising error line usually points at one device or one tool — jump to Live Feed to see which.`]},devices:{what:`Every configured router with its live reachability (SSH or MAC-Telnet), latency, identity, and system health — CPU, memory and disk — refreshed continuously.`,tips:[`Each device gets a stable colour so you can track it across the connectivity radar.`,`Health (CPU/Mem/Disk) is probed periodically; MAC-Telnet devices are probed on a slower cadence.`,`Latency tiers are colour-coded green → amber → red; a grey node is currently unreachable.`,`The SSH Connection Pool panel shows persistent connections: green = idle/ready, blue = busy with inflight channels, red = reconnecting.`]},clients:{what:`The LAN devices connected to a router — merged from its DHCP leases and ARP table — with live Download/Upload charts, and one-click controls to block/allow a device, pin (reserve) its IP, change that IP, or relabel it.`,tips:[`Pick the router (top-right) to inspect its connected devices; filter by IP, MAC or name.`,`Click a device to open its live ↓/↑ traffic chart — needs a simple queue targeting its IP.`,`Block/allow is enforced by MAC, so it survives the device changing IP; “Pin IP” makes its lease static.`]},aaa:{what:"Full management of the router's RADIUS client (`/radius`) and the built-in User Manager RADIUS server (`/user-manager`): RADIUS servers + incoming CoA, and User Manager users, service profiles, rate/quota limitations, NAS clients, profile assignments, accounting sessions, and global settings.",tips:[`Pick the router (top-right), then switch tabs across RADIUS, Users, Profiles, Limitations, NAS, Assignments, Sessions and Settings.`,`Every tab is full CRUD: add, edit, enable/disable and remove — secrets are write-only and shown redacted.`,`The Usage & Heatmap tab shows each user's 3-month download/upload and a GitHub-style connection heatmap, persisted locally.`,`If a device lacks the user-manager package, the User Manager tabs explain how to install it; RADIUS-client tabs still work.`]},topology:{what:`A Layer-2 map of neighbours each router discovers via MNDP / CDP / LLDP — the physical adjacency of your network, drawn live.`,tips:[`Solid nodes are configured devices; faint nodes are discovered-but-unmanaged neighbours.`,`Use “Add to config →” on an unmanaged neighbour to pre-fill it in the Config editor.`,`Drag to pan; the layout settles automatically as new neighbours arrive.`]},packets:{what:`Live packet capture streamed from a router over TZSP — decode headers in real time without leaving the dashboard.`,tips:[`Pick a device and start the capture; packets decode as they arrive.`,`Stop the capture when done — it frees the router-side sniffer.`,`Great for debugging a protocol issue alongside the Live Feed of tool calls.`]},snapshots:{what:`Point-in-time captures of a device’s full configuration (/export), stored locally so you can diff any two and see exactly what changed.`,tips:[`Capture a snapshot before a risky change, then diff after to audit the delta.`,`The diff is line-level: green added, red removed.`,`Snapshots are device config exports — for the dashboard’s OWN config history see the Config page.`]},plan:{what:`Dry-run the exact RouterOS commands a change would run before it touches a device — a change plan you can review and trust.`,tips:[`Paste or build intended commands to see them validated and ordered.`,`Nothing is sent to the device from here — it’s a preview.`,`Pair with Safe Mode (auto-revert) when you do apply for real.`]},s3:{what:`Browse, download, and delete backup objects in your configured S3-compatible bucket — your off-box archive of device backups and exports.`,tips:[`Filter by key prefix to find a device’s backups quickly.`,`Download fetches the object through a presigned URL; delete is permanent.`,`For host-side .rsc backups instead, use the Backups page.`]},backups:{what:`A local config vault on the MCP server: capture a device’s /export as a timestamped .rsc file, then download, upload, rename, restore (via Safe Mode), or delete it.`,tips:[`Restore offers a dry-run (applies then rolls back) before you commit for real.`,`Edit the vault path inline in the header — it’s saved to your config.`,`Filenames are stamped in the device’s local 24-hour clock.`]},modules:{what:"Every tool module in the catalog with a live on/off switch. Toggling one writes your config file's `tools` block (disabledModules / enabledModules) and applies it immediately, so you can curate exactly which scopes the MCP server exposes.",tips:[`MCP clients search-rank tools and degrade past ~100; trim the surface below ~150–200 tools so every remaining tool is reliably findable.`,`Disable adds the module to tools.disabledModules; enable removes it (or adds it to an active allow-list) — your config file is updated live on each toggle.`,`Changes need an MCP client reconnect (or a server restart) to actually shrink/grow the visible tool list.`]},config:{what:`View the effective configuration, edit it safely with schema-aware validation and auto-rollback, browse a full field guide, and travel through config version history.`,tips:[`Every successful apply is auto-saved to the version timeline — restore any point in time.`,`Save a named checkpoint before a big change for an easy, labelled rollback.`,`The Field Guide documents every config option, its type, and default — straight from the schema.`]},feed:{what:`Every tool call as it happens — tool, device, risk, duration, and success/error — with full request/response detail on click.`,tips:[`Filter by status to isolate failures, or by tool/device to follow one thread.`,`Click any row to open the full (secret-redacted) request and response.`,`Pause the stream when you want to inspect without rows shifting under you.`]}};function WX({view:e}){let t=UX[e];return(0,q.jsxs)(`div`,{className:`pagehelp reveal`,role:`region`,"aria-label":`Page help`,children:[(0,q.jsx)(`div`,{className:`pagehelp__icon`,"aria-hidden":`true`,children:`?`}),(0,q.jsxs)(`div`,{className:`pagehelp__body`,children:[(0,q.jsx)(`p`,{className:`pagehelp__what`,children:t.what}),(0,q.jsx)(`ul`,{className:`pagehelp__tips`,children:t.tips.map((e,t)=>(0,q.jsx)(`li`,{children:e},t))})]})]})}function GX({name:e}){return(0,q.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.7`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:{overview:(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`rect`,{x:`3`,y:`3`,width:`8`,height:`8`,rx:`1.6`}),(0,q.jsx)(`rect`,{x:`13`,y:`3`,width:`8`,height:`5`,rx:`1.6`}),(0,q.jsx)(`rect`,{x:`13`,y:`10`,width:`8`,height:`11`,rx:`1.6`}),(0,q.jsx)(`rect`,{x:`3`,y:`13`,width:`8`,height:`8`,rx:`1.6`})]}),devices:(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`rect`,{x:`3`,y:`4`,width:`18`,height:`7`,rx:`2`}),(0,q.jsx)(`rect`,{x:`3`,y:`13`,width:`18`,height:`7`,rx:`2`}),(0,q.jsx)(`path`,{d:`M7 7.5h.01M7 16.5h.01`})]}),clients:(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`circle`,{cx:`9`,cy:`8`,r:`3`}),(0,q.jsx)(`path`,{d:`M3.5 19a5.5 5.5 0 0 1 11 0`}),(0,q.jsx)(`path`,{d:`M16 7.5a2.5 2.5 0 0 1 0 5M17.5 19a4.5 4.5 0 0 0-2-3.6`})]}),aaa:(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`path`,{d:`M12 3 4 6v5c0 4.4 3.2 7.6 8 9 4.8-1.4 8-4.6 8-9V6l-8-3Z`}),(0,q.jsx)(`path`,{d:`M9.5 11.5 11 13l3.5-3.5`})]}),topology:(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`circle`,{cx:`12`,cy:`5`,r:`2.4`}),(0,q.jsx)(`circle`,{cx:`5`,cy:`19`,r:`2.4`}),(0,q.jsx)(`circle`,{cx:`19`,cy:`19`,r:`2.4`}),(0,q.jsx)(`path`,{d:`M12 7.4 6.4 16.6M12 7.4 17.6 16.6`})]}),packets:(0,q.jsx)(`path`,{d:`M3 12h4l2-7 4 14 2-7h6`}),snapshots:(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`path`,{d:`M12 3 3 7.5 12 12 21 7.5 12 3Z`}),(0,q.jsx)(`path`,{d:`M3 12 12 16.5 21 12`}),(0,q.jsx)(`path`,{d:`M3 16.5 12 21 21 16.5`})]}),plan:(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`circle`,{cx:`6`,cy:`6`,r:`2.3`}),(0,q.jsx)(`circle`,{cx:`6`,cy:`18`,r:`2.3`}),(0,q.jsx)(`circle`,{cx:`18`,cy:`8`,r:`2.3`}),(0,q.jsx)(`path`,{d:`M6 8.3v7.4M8.3 6H13a3 3 0 0 1 3 3v0`})]}),s3:(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`ellipse`,{cx:`12`,cy:`6`,rx:`7`,ry:`2.6`}),(0,q.jsx)(`path`,{d:`M5 6v12c0 1.5 3.1 2.6 7 2.6s7-1.1 7-2.6V6`}),(0,q.jsx)(`path`,{d:`M5 12c0 1.5 3.1 2.6 7 2.6s7-1.1 7-2.6`})]}),backups:(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`path`,{d:`M3 6.5 5 3.5h14l2 3`}),(0,q.jsx)(`rect`,{x:`3`,y:`6.5`,width:`18`,height:`14`,rx:`2`}),(0,q.jsx)(`path`,{d:`M9.5 12h5`})]}),modules:(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`rect`,{x:`3`,y:`5`,width:`18`,height:`6`,rx:`3`}),(0,q.jsx)(`circle`,{cx:`8`,cy:`8`,r:`1.5`}),(0,q.jsx)(`rect`,{x:`3`,y:`13`,width:`18`,height:`6`,rx:`3`}),(0,q.jsx)(`circle`,{cx:`16`,cy:`16`,r:`1.5`})]}),config:(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`path`,{d:`M4 7h8M16 7h4M4 17h4M12 17h8`}),(0,q.jsx)(`circle`,{cx:`14`,cy:`7`,r:`2.2`}),(0,q.jsx)(`circle`,{cx:`10`,cy:`17`,r:`2.2`})]}),feed:(0,q.jsx)(`path`,{d:`M4 6h16M4 12h16M4 18h10`})}[e]})}function KX(){let[e,t]=(0,v.useState)(null),[n,r]=(0,v.useState)(null),[i,a]=(0,v.useState)(null),[o,s]=(0,v.useState)(null),c=NX(n?.version),[l,u]=(0,v.useState)(null),[d,f]=(0,v.useState)(null),[p,m]=(0,v.useState)(!1),[h,g]=(0,v.useState)(null),[_,y]=(0,v.useState)([]),[b,x]=(0,v.useState)(36e5),[S,C]=(0,v.useState)(!1),[w,T]=(0,v.useState)(`off`),[E,D]=(0,v.useState)(null),[O,k]=(0,v.useState)(()=>new Set),[A,j]=(0,v.useState)({}),[M,N]=(0,v.useState)({tool:``,risk:``,device:``,status:``,q:``}),P=(0,v.useRef)(S);P.current=S;let F=(0,v.useRef)(null);sX(F);let[I,L]=(0,v.useState)(BX),ee=(0,v.useCallback)(e=>{L(e);try{zX()!==e&&(location.hash=e),localStorage.setItem(RX,e)}catch{}},[]);(0,v.useEffect)(()=>{if(zX()!==I)try{location.hash=I}catch{}let e=()=>{let e=zX();e&&ee(e)};return window.addEventListener(`hashchange`,e),()=>window.removeEventListener(`hashchange`,e)},[]);let[te,R]=(0,v.useState)(()=>{try{let e=localStorage.getItem(`mt-help-open`);return new Set(e?JSON.parse(e):[])}catch{return new Set}}),z=e=>R(t=>{let n=new Set(t);n.has(e)?n.delete(e):n.add(e);try{localStorage.setItem(`mt-help-open`,JSON.stringify([...n]))}catch{}return n}),[ne,B]=(0,v.useState)(``),[V,re]=(0,v.useState)(`all`),ie=(0,v.useMemo)(()=>{let e=i?.devices??[];return{online:e.filter(e=>e.status.reachable===!0).length,offline:e.filter(e=>e.status.reachable===!1).length,total:e.length}},[i]),ae=(0,v.useMemo)(()=>{let e=i?.devices??[],t=ne.trim().toLowerCase();return e.filter(e=>!(V===`online`&&e.status.reachable!==!0||V===`offline`&&e.status.reachable!==!1||t&&!e.name.toLowerCase().includes(t)&&!(e.address??e.host??``).toLowerCase().includes(t)))},[i,ne,V]);oX((0,v.useCallback)(e=>{if(P.current)return;y(t=>[e,...t].slice(0,Ac));let t=e.device;t&&j(e=>({...e,[t]:(e[t]??0)+1}))},[]),(0,v.useCallback)(e=>T(e),[])),(0,v.useEffect)(()=>{pc(`/api/events?limit=${Ac}`).then(e=>y(e.events)).catch(()=>{})},[]);let oe=(0,v.useCallback)(()=>{pc(`/api/stats?window=${b}&buckets=60`).then(t).catch(()=>{})},[b]);(0,v.useEffect)(()=>{oe();let e=()=>{oe(),pc(`/api/meta`).then(r).catch(()=>{}),pc(`/api/devices`).then(a).catch(()=>{}),pc(`/api/ssh-pool`).then(s).catch(()=>{}),pc(`/api/topology`).then(u).catch(()=>{})};e();let t=setInterval(()=>{P.current||e()},4e3);return()=>clearInterval(t)},[oe]),(0,v.useEffect)(()=>{let e=()=>void pc(`/api/config`).then(f).catch(()=>{});e();let t=setInterval(e,3e4);return()=>clearInterval(t)},[]),(0,v.useEffect)(()=>{let e=e=>{e.key===`Escape`&&D(null)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]);let se=(0,v.useMemo)(()=>{let e=M.q.trim().toLowerCase();return _.filter(t=>!(M.tool&&t.tool!==M.tool||M.risk&&t.risk!==M.risk||M.device&&t.device!==M.device||M.status===`ok`&&t.isError||M.status===`error`&&!t.isError||e&&!t.tool.toLowerCase().includes(e)&&!t.input.toLowerCase().includes(e)&&!t.output.toLowerCase().includes(e)&&!(t.error??``).toLowerCase().includes(e))).sort((e,t)=>t.ts-e.ts)},[_,M]),H=!!(M.tool||M.risk||M.device||M.status||M.q),ce=(0,v.useMemo)(()=>_.filter(e=>e.isError),[_]),le=(0,v.useMemo)(()=>({ok:_.length-ce.length,error:ce.length}),[_,ce]),ue=(0,v.useCallback)(async e=>{try{D(await pc(`/api/event/${encodeURIComponent(e.id)}`))}catch{D(e)}},[]),de=(0,v.useMemo)(()=>se.slice(0,200),[se]),fe=(0,v.useMemo)(()=>de.map(e=>e.id),[de]),pe=fe.length>0&&fe.every(e=>O.has(e)),me=!pe&&fe.some(e=>O.has(e)),he=(0,v.useCallback)(e=>{k(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),ge=(0,v.useCallback)(()=>{k(e=>{let t=new Set(e);if(fe.length>0&&fe.every(e=>t.has(e)))for(let e of fe)t.delete(e);else for(let e of fe)t.add(e);return t})},[fe]),[_e,ve]=(0,v.useState)(!1),ye=(0,v.useCallback)(async()=>{let e=[...O];if(e.length!==0)try{await hc({ids:e});let t=new Set(e);y(e=>e.filter(e=>!t.has(e.id))),k(new Set)}catch{}finally{ve(!1)}},[O]),be=e=>{if(e===`json`){FX(`mcp-events.json`,JSON.stringify(se,null,2),`application/json`);return}let t=[`ts`,`tool`,`risk`,`device`,`durationMs`,`isError`,`error`,`reason`],n=e=>/[",\n]/.test(e)?`"${e.replace(/"/g,`""`)}"`:e,r=se.map(e=>[new Date(e.ts).toISOString(),e.tool,e.risk,e.device??``,String(e.durationMs),String(e.isError),e.error??``,e.reason??``].map(n).join(`,`)).join(`
87
88
  `);FX(`mcp-events.csv`,`${t.join(`,`)}\n${r}\n`,`text/csv`)},xe=e?e.errorRate>=.2?`is-bad`:e.errorRate>=.05?`is-warn`:`is-good`:``,Se=d?.mcp??{},Ce=d?.dashboard??{},we=d?.ssh??{},Te=(e,t,n)=>(0,q.jsxs)(`select`,{className:`btn`,value:M[e],onChange:t=>N(n=>({...n,[e]:t.target.value})),children:[(0,q.jsx)(`option`,{value:``,children:t}),n.map(e=>(0,q.jsx)(`option`,{value:e,children:e},e))]}),Ee=IX.find(e=>e.id===I)??IX[0];return(0,q.jsxs)(`div`,{className:`shell`,ref:F,"data-view":I,style:{"--page-accent":HX[I][0],"--page-accent-2":HX[I][1]},children:[(0,q.jsxs)(`aside`,{className:`nav`,children:[(0,q.jsxs)(`div`,{className:`nav__brand`,children:[(0,q.jsx)(`div`,{className:`nav__mark`,children:(0,q.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,"aria-hidden":`true`,children:(0,q.jsxs)(`g`,{stroke:`#18181b`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,q.jsx)(`path`,{d:`M12 12 L4 5 M12 12 L20 5 M12 12 L12 20`}),(0,q.jsx)(`circle`,{cx:`12`,cy:`12`,r:`3`,fill:`#18181b`,stroke:`none`}),(0,q.jsx)(`circle`,{cx:`4`,cy:`5`,r:`1.9`,fill:`#18181b`,stroke:`none`}),(0,q.jsx)(`circle`,{cx:`20`,cy:`5`,r:`1.9`,fill:`#18181b`,stroke:`none`}),(0,q.jsx)(`circle`,{cx:`12`,cy:`20`,r:`1.9`,fill:`#18181b`,stroke:`none`})]})})}),(0,q.jsxs)(`div`,{className:`nav__brandtext`,children:[(0,q.jsx)(`b`,{children:`MikroTik MCP`}),(0,q.jsxs)(`small`,{className:c.release?`nav__version-link`:void 0,title:c.release?`View release notes`:void 0,onClick:c.release?()=>c.openModal():void 0,children:[n?.version?`v${n.version}`:`Observability`,c.showIndicator&&(0,q.jsx)(`span`,{className:`nav__update-dot`,title:`v${c.release?.version} available`})]})]})]}),(0,q.jsx)(`nav`,{className:`nav__items`,children:IX.map(e=>(0,q.jsxs)(`button`,{className:`nav__item${I===e.id?` is-active`:``}`,onClick:()=>ee(e.id),children:[(0,q.jsx)(GX,{name:e.id}),(0,q.jsx)(`span`,{children:e.label}),e.id===`feed`&&_.length>0&&(0,q.jsx)(`span`,{className:`nav__badge`,children:_.length>999?`999+`:_.length},_.length)]},e.id))}),(0,q.jsxs)(`div`,{className:`nav__foot`,children:[(0,q.jsxs)(`span`,{className:`hero__live${w===`off`?``:` is-on`}${w===`ws`?` is-ws`:w===`sse`?` is-sse`:``}`,title:`Live transport: WebSocket (preferred) or SSE fallback`,children:[(0,q.jsx)(`span`,{className:`dot`}),w===`off`?`offline`:`live · ${w}`]}),(0,q.jsx)(`small`,{className:`muted`,children:n?`${Tc(n.total)} events · ${n.transport}`:`connecting…`})]})]}),(0,q.jsxs)(`main`,{className:`main`,"data-view":I,children:[(0,q.jsxs)(`header`,{className:`topline reveal`,children:[(0,q.jsxs)(`div`,{className:`topline__txt`,children:[(0,q.jsx)(`h1`,{children:Ee.label}),(0,q.jsx)(`small`,{children:Ee.sub})]}),(0,q.jsx)(`span`,{className:`topline__spacer`}),I===`overview`&&(0,q.jsx)(`select`,{className:`btn`,value:b,onChange:e=>x(Number(e.target.value)),title:`Stats time window`,children:kc.map(([e,t])=>(0,q.jsxs)(`option`,{value:t,children:[`window: `,e]},t))}),(0,q.jsxs)(`button`,{className:`help-toggle${te.has(I)?` is-on`:``}`,onClick:()=>z(I),"aria-expanded":te.has(I),title:`About this page`,children:[(0,q.jsx)(`span`,{className:`help-toggle__q`,"aria-hidden":`true`,children:`?`}),`Help`]})]}),te.has(I)&&(0,q.jsx)(WX,{view:I}),I===`overview`&&(0,q.jsxs)(`section`,{className:`view`,children:[(0,q.jsx)(`div`,{className:`cards reveal`,children:e?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(vc,{k:`Calls (window)`,v:Tc(e.total)}),(0,q.jsx)(vc,{k:`Calls / min`,v:e.callsPerMin.toFixed(1)}),(0,q.jsx)(vc,{k:`Error rate`,v:`${(e.errorRate*100).toFixed(1)}%`,sub:`${e.errors} err`,cls:xe}),(0,q.jsx)(vc,{k:`Avg latency`,v:Sc(e.latency.avg)}),(0,q.jsx)(vc,{k:`p95 latency`,v:Sc(e.latency.p95)}),(0,q.jsx)(vc,{k:`p99 latency`,v:Sc(e.latency.p99)}),(0,q.jsx)(vc,{k:`Distinct tools`,v:Tc(e.distinctTools)}),(0,q.jsx)(vc,{k:`Output volume`,v:Cc(e.outputBytes)})]}):(0,q.jsxs)(`div`,{className:`stat`,children:[(0,q.jsx)(`p`,{className:`k`,children:`Loading…`}),(0,q.jsx)(`div`,{className:`v`,children:`—`})]})}),(0,q.jsxs)(`div`,{className:`bento reveal`,children:[(0,q.jsx)(_c,{title:`Calls over time`,className:`b-series`,children:e?(0,q.jsx)(lY,{series:e.series}):(0,q.jsx)(`div`,{className:`muted`,children:`no data`})}),e&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(_c,{title:`By risk`,className:`b-risk`,children:(0,q.jsx)(uY,{segments:Object.keys(e.byRisk).map(t=>({label:t,value:e.byRisk[t],color:Oc[t]}))})}),(0,q.jsx)(_c,{title:`Top tools`,className:`b-tools`,children:(0,q.jsx)(yc,{rows:e.byTool.map(e=>({label:e.tool,value:e.count,sub:`${e.count}× · ${Sc(e.p95Ms)} p95${e.errors?` · ${e.errors} err`:``}`,color:e.errors?`var(--mt-bad)`:void 0}))})}),(0,q.jsx)(_c,{title:`Status`,className:`b-status`,children:(0,q.jsx)(uY,{centerLabel:`calls`,segments:[{label:`ok`,value:le.ok,color:`#a1a1a1`},{label:`error`,value:le.error,color:`#ff5c5c`}]})}),(0,q.jsx)(_c,{title:`By device`,className:`b-device`,children:e.byDevice.length?(0,q.jsx)(yc,{rows:e.byDevice.map(e=>({label:e.device,value:e.count}))}):(0,q.jsx)(`div`,{className:`muted`,children:`single device`})}),(0,q.jsx)(_c,{title:`Recent errors`,className:`b-errors`,children:ce.length?(0,q.jsx)(`div`,{className:`hbar`,children:ce.slice(0,8).map(e=>(0,q.jsxs)(`div`,{className:`hbar__row conn-errrow`,style:{gridTemplateColumns:`auto 1fr`},onClick:()=>void ue(e),children:[(0,q.jsx)(`span`,{className:`muted`,children:wc(e.ts)}),(0,q.jsxs)(`span`,{style:{color:`var(--mt-bad)`,whiteSpace:`nowrap`,overflow:`hidden`,textOverflow:`ellipsis`,minWidth:0},title:e.error??e.output,children:[e.tool,`: `,e.error??e.output??`error`]})]},e.id))}):(0,q.jsx)(`div`,{className:`muted`,children:`no errors 🎉`})})]})]})]}),I===`devices`&&(i&&i.devices.length>0?(0,q.jsxs)(`section`,{className:`view`,children:[(0,q.jsxs)(`div`,{className:`dev-toolbar reveal`,children:[(0,q.jsx)(`input`,{className:`search`,type:`search`,placeholder:`Search devices by name or address…`,value:ne,onChange:e=>B(e.target.value),style:{flex:1,minWidth:180}}),(0,q.jsx)(`div`,{className:`dev-filters`,children:[`all`,`online`,`offline`].map(e=>(0,q.jsx)(`button`,{className:`dev-fbtn${V===e?` is-active`:``}`,onClick:()=>re(e),children:e===`all`?`All ${ie.total}`:e===`online`?`Online ${ie.online}`:`Offline ${ie.offline}`},e))}),(0,q.jsxs)(`span`,{className:`muted`,children:[ae.length,`/`,ie.total,` shown`]})]}),(0,q.jsxs)(`details`,{className:`dev-collapse reveal`,open:ie.total<=8,children:[(0,q.jsxs)(`summary`,{children:[`Connectivity radar`,(0,q.jsxs)(`span`,{className:`muted`,children:[` `,`· `,ie.online,` online · `,ie.offline,` offline ·`,` `,ie.total,` total`]})]}),(0,q.jsx)(tX,{payload:i,pulses:A})]}),(0,q.jsx)(CX,{devices:ae,poolPayload:o}),ae.length===0?(0,q.jsxs)(`div`,{className:`feed-empty reveal`,children:[(0,q.jsx)(`div`,{className:`feed-empty__icon`,children:`🔍`}),(0,q.jsx)(`p`,{className:`feed-empty__title`,children:`No devices match`}),(0,q.jsx)(`p`,{className:`feed-empty__sub`,children:`Try a different search or status filter.`})]}):(0,q.jsx)(`div`,{className:`dev-grid-wide reveal`,children:ae.map(e=>(0,q.jsx)(nX,{d:e},e.name))}),ae.length>0&&(0,q.jsx)(_c,{title:`Device system health`,className:`reveal`,extra:(0,q.jsx)(`span`,{className:`muted`,children:`CPU · memory · disk · latency · live probe`}),children:(0,q.jsx)(`div`,{className:`health-grid`,children:ae.map(e=>(0,q.jsx)(aX,{d:e},e.name))})})]}):(0,q.jsxs)(`div`,{className:`feed-empty`,children:[(0,q.jsx)(`div`,{className:`feed-empty__icon`,children:`🖧`}),(0,q.jsx)(`p`,{className:`feed-empty__title`,children:`No devices configured`}),(0,q.jsx)(Mc,{type:`secondary`,label:`Tip`,children:`Add a device to your config to see connectivity and system health here.`})]})),I===`clients`&&(0,q.jsx)(wY,{}),I===`aaa`&&(0,q.jsx)(ml,{}),I===`topology`&&(l&&l.nodes.length>0?(0,q.jsx)(`section`,{className:`view`,children:(0,q.jsx)(_c,{title:`Network topology`,className:`reveal`,extra:(0,q.jsx)(`span`,{className:`muted`,children:`Layer-2 neighbours via MNDP/CDP/LLDP · click a neighbour to onboard it`}),children:(0,q.jsx)(gX,{topo:l,onOnboard:(e,t)=>{g({name:e,body:t}),m(!0),ee(`config`)}})})}):(0,q.jsxs)(`div`,{className:`feed-empty`,children:[(0,q.jsx)(`div`,{className:`feed-empty__icon`,children:`🛰️`}),(0,q.jsx)(`p`,{className:`feed-empty__title`,children:`No neighbours discovered yet`}),(0,q.jsx)(`p`,{className:`feed-empty__sub`,children:`Layer-2 neighbours (MNDP / CDP / LLDP) appear here as the device reports them.`})]})),I===`packets`&&(0,q.jsx)(`section`,{className:`view`,children:(0,q.jsx)(_c,{title:`Packet capture`,className:`reveal`,extra:(0,q.jsx)(`span`,{className:`muted`,children:`live TZSP decode · /tool sniffer streaming`}),children:(0,q.jsx)(fX,{})})}),I===`snapshots`&&(0,q.jsx)(mX,{}),I===`plan`&&(0,q.jsx)(gl,{}),I===`s3`&&(0,q.jsx)(pX,{}),I===`backups`&&(0,q.jsx)(Rc,{}),I===`modules`&&(0,q.jsx)(lX,{}),I===`config`&&(d?(0,q.jsxs)(`section`,{className:`view`,children:[(0,q.jsx)(_c,{title:`Configuration`,className:`reveal`,extra:(0,q.jsx)(`button`,{className:`btn`,onClick:()=>m(e=>!e),title:`Edit the config JSON with autocomplete, validation and safe-apply`,children:p?`View`:`✎ Edit config`}),children:p?(0,q.jsx)(HY,{initial:h?{...d,devices:{...d.devices,[h.name]:h.body}}:d,onClose:()=>{m(!1),g(null)},onReload:()=>{g(null),pc(`/api/config`).then(f).catch(()=>{})}},h?`seed-${h.name}`:`config`):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`div`,{className:`legend`,style:{margin:`0 0 10px`},children:[(0,q.jsxs)(`span`,{children:[`transport: `,Ec(Se.transport)]}),(0,q.jsxs)(`span`,{children:[`read-only: `,d.readOnly?`yes`:`no`]}),(0,q.jsxs)(`span`,{children:[`dashboard: `,Ec(Ce.host),`:`,Ec(Ce.port)]}),(0,q.jsxs)(`span`,{children:[`capture: `,Ce.captureBody?`on`:`off`]}),(0,q.jsxs)(`span`,{children:[`s3: `,d.s3?`configured`:`off`]}),(0,q.jsxs)(`span`,{children:[`ssh pool: `,we.keepAlive===!1?`off`:`on`]})]}),(0,q.jsxs)(`details`,{className:`cfg`,children:[(0,q.jsx)(`summary`,{children:`Full effective configuration (secrets redacted)`}),(0,q.jsx)(RY,{value:d,maxHeight:340})]})]})}),(0,q.jsx)(_c,{title:`Version history`,className:`reveal`,extra:(0,q.jsx)(`span`,{className:`muted`,children:`point-in-time snapshots · diff & restore`}),children:(0,q.jsx)(DY,{onRestored:()=>void pc(`/api/config`).then(f).catch(()=>{})})}),(0,q.jsx)(_c,{title:`Field guide`,className:`reveal`,extra:(0,q.jsx)(`span`,{className:`muted`,children:`every config option, documented from the schema`}),children:(0,q.jsx)(kY,{})})]}):(0,q.jsxs)(`div`,{className:`feed-empty`,children:[(0,q.jsx)(Fc,{}),(0,q.jsx)(`p`,{className:`feed-empty__title`,children:`Loading configuration…`})]})),I===`feed`&&(0,q.jsxs)(`div`,{className:`panel reveal`,children:[(0,q.jsxs)(`div`,{className:`sheet__hd`,style:{marginBottom:12},children:[(0,q.jsx)(`h2`,{style:{margin:0},children:`Live tool calls`}),(0,q.jsx)(`span`,{style:{flex:1}}),(0,q.jsxs)(`span`,{className:`muted`,children:[se.length,` shown · `,_.length,` buffered`]})]}),(0,q.jsxs)(`div`,{className:`toolbar`,style:{marginBottom:12},children:[(0,q.jsx)(`div`,{className:`grow`,style:{flex:1,minWidth:180},children:(0,q.jsx)(`input`,{className:`search`,type:`search`,placeholder:`Search tool / input / output / error…`,value:M.q,onChange:e=>N(t=>({...t,q:e.target.value}))})}),Te(`tool`,`all tools`,n?.tools??[]),Te(`risk`,`all risk`,[`READ`,`WRITE`,`WRITE_IDEMPOTENT`,`DESTRUCTIVE`,`DANGEROUS`]),Te(`device`,`all devices`,n?.devices??[]),Te(`status`,`all status`,[`ok`,`error`]),(0,q.jsx)(`button`,{className:`btn${S?` is-active`:``}`,onClick:()=>C(e=>!e),children:S?`▶ Resume`:`⏸ Pause`}),(0,q.jsx)(`button`,{className:`btn`,onClick:()=>be(`csv`),children:`CSV`}),(0,q.jsx)(`button`,{className:`btn`,onClick:()=>be(`json`),children:`JSON`}),(0,q.jsx)(`button`,{className:`btn`,onClick:()=>N({tool:``,risk:``,device:``,status:``,q:``}),children:`Clear`}),_e&&O.size>0?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`button`,{className:`btn btn-danger`,onClick:()=>void ye(),children:[`✓ Confirm delete (`,O.size,`)`]}),(0,q.jsx)(`button`,{className:`btn`,onClick:()=>ve(!1),children:`Cancel`})]}):(0,q.jsxs)(`button`,{className:`btn`,disabled:O.size===0,onClick:()=>ve(!0),title:`Delete the selected rows`,children:[`🗑 Delete`,O.size>0?` (${O.size})`:``]})]}),se.length===0?H?(0,q.jsxs)(`div`,{className:`feed-empty`,children:[(0,q.jsx)(`div`,{className:`feed-empty__icon`,children:`🔍`}),(0,q.jsx)(`p`,{className:`feed-empty__title`,children:`No calls match your filters`}),(0,q.jsxs)(`p`,{className:`feed-empty__sub`,children:[_.length,` call`,_.length===1?``:`s`,` buffered — try widening the search or the risk / device / status filters.`]}),(0,q.jsx)(`button`,{className:`btn`,onClick:()=>N({tool:``,risk:``,device:``,status:``,q:``}),children:`Clear filters`})]}):(0,q.jsxs)(`div`,{className:`feed-empty`,children:[(0,q.jsx)(`div`,{className:`feed-empty__pulse${w===`off`?``:` is-on`}`}),(0,q.jsx)(`p`,{className:`feed-empty__title`,children:w===`off`?`Not connected`:`Listening for tool calls…`}),(0,q.jsx)(`p`,{className:`feed-empty__sub`,children:w===`off`?`The live stream is offline — it will reconnect automatically.`:`Tool calls the LLM makes against this server stream in here in real time.`})]}):(0,q.jsx)(`div`,{className:`feedwrap`,children:(0,q.jsxs)(`table`,{className:`feed`,children:[(0,q.jsx)(`thead`,{children:(0,q.jsxs)(`tr`,{children:[(0,q.jsx)(`th`,{style:{width:28},children:(0,q.jsx)(`input`,{type:`checkbox`,"aria-label":`Select all shown rows`,checked:pe,ref:e=>{e&&(e.indeterminate=me)},onChange:ge})}),(0,q.jsx)(`th`,{children:`time`}),(0,q.jsx)(`th`,{children:`tool`}),(0,q.jsx)(`th`,{children:`risk`}),(0,q.jsx)(`th`,{children:`device`}),(0,q.jsx)(`th`,{className:`num`,children:`dur`}),(0,q.jsx)(`th`,{children:`status`}),(0,q.jsx)(`th`,{children:`output`})]})}),(0,q.jsx)(`tbody`,{children:de.map(e=>(0,q.jsxs)(`tr`,{className:`${e.isError?`is-err`:``}${O.has(e.id)?` is-selected`:``}`.trim()||void 0,onClick:()=>void ue(e),children:[(0,q.jsx)(`td`,{onClick:e=>e.stopPropagation(),children:(0,q.jsx)(`input`,{type:`checkbox`,"aria-label":`Select row`,checked:O.has(e.id),onChange:()=>he(e.id)})}),(0,q.jsx)(`td`,{children:wc(e.ts)}),(0,q.jsx)(`td`,{children:e.tool}),(0,q.jsx)(`td`,{children:(0,q.jsx)(`span`,{className:`risk risk-${e.risk}`,children:e.risk.replace(`WRITE_IDEMPOTENT`,`WRITE·I`)})}),(0,q.jsx)(`td`,{children:e.device??`—`}),(0,q.jsx)(`td`,{className:`num`,children:Sc(e.durationMs)}),(0,q.jsx)(`td`,{children:(0,q.jsx)(`span`,{className:e.isError?`status-err`:`status-ok`,children:e.isError?`error`:`ok`})}),(0,q.jsx)(`td`,{className:`preview`,children:e.isError?e.error??`error`:e.reason?(0,q.jsx)(`span`,{className:`reason-preview`,children:e.reason}):e.output||`—`})]},e.id))})]})})]})]}),c.showModal&&c.release&&(0,q.jsx)(PX,{release:c.release,onDismiss:c.dismissRelease}),E&&(0,q.jsx)(rX,{event:E,onClose:()=>D(null)})]})}var qX=document.getElementById(`root`);qX&&(0,y.createRoot)(qX).render((0,q.jsx)(KX,{}));
88
89
  </script>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@usex/mikrotik-mcp",
3
- "version": "3.48.0",
3
+ "version": "3.49.0",
4
4
  "description": "MCP server for MikroTik RouterOS — 660+ tools over SSH for firewall, NAT, routing, DHCP, DNS, WireGuard, wireless, QoS and more.",
5
5
  "keywords": [
6
6
  "ai",