diff --git a/frontend/dist/VERSION b/frontend/dist/VERSION index b64d2993..033115aa 100644 --- a/frontend/dist/VERSION +++ b/frontend/dist/VERSION @@ -1 +1 @@ -0.9.296 +0.9.297 diff --git a/frontend/dist/assets/AnalyzerFilterPanel-D0gvrDVF.js b/frontend/dist/assets/AnalyzerFilterPanel-CBw2MsnC.js similarity index 95% rename from frontend/dist/assets/AnalyzerFilterPanel-D0gvrDVF.js rename to frontend/dist/assets/AnalyzerFilterPanel-CBw2MsnC.js index 6f5b5f38..f5335adf 100644 --- a/frontend/dist/assets/AnalyzerFilterPanel-D0gvrDVF.js +++ b/frontend/dist/assets/AnalyzerFilterPanel-CBw2MsnC.js @@ -1,4 +1,4 @@ -import{d as U,$ as J,r as u,j as n,bc as K,R as q,bO as G,B as Q}from"./index-C1ZF7cAz.js";import{c as V}from"./node-types-BJeLdOcD.js";import{F as Y}from"./funnel-zG3cM6J7.js";import{M as Z}from"./monitor-smartphone-BQ_i3P0U.js";import{C as W}from"./circle-question-mark-CxqvWhsl.js";import{S as ee}from"./search-CtlrlrHK.js";/** +import{d as U,a2 as J,r as u,j as n,bf as K,R as q,bP as G,B as Q}from"./index-DhkG1Nx9.js";import{c as V}from"./node-types-CgBRFpS8.js";import{F as Y}from"./funnel-Dr2cCUci.js";import{M as Z}from"./monitor-smartphone-jV9bAwUA.js";import{C as W}from"./circle-question-mark--xh93QHC.js";import{S as ee}from"./search-BmkxxIVP.js";/** * @license lucide-react v0.559.0 - ISC * * This source code is licensed under the ISC license. @@ -8,7 +8,7 @@ import{d as U,$ as J,r as u,j as n,bc as K,R as q,bO as G,B as Q}from"./index-C1 * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const ne=[["path",{d:"M7 16.3c2.2 0 4-1.83 4-4.05 0-1.16-.57-2.26-1.71-3.19S7.29 6.75 7 5.3c-.29 1.45-1.14 2.84-2.29 3.76S3 11.1 3 12.25c0 2.22 1.8 4.05 4 4.05z",key:"1ptgy4"}],["path",{d:"M12.56 6.6A10.97 10.97 0 0 0 14 3.02c.5 2.5 2 4.9 4 6.5s3 3.5 3 5.5a6.98 6.98 0 0 1-11.91 4.97",key:"1sl1rz"}]],oe=U("droplets",ne);function xe(){return{timeStart:null,timeEnd:null,deviceTypes:new Set,nodeIds:new Set,disabledNodeIds:new Set,nodeFilterMode:"source"}}function re(d,l){const{timeStart:c,timeEnd:t,deviceTypes:o,nodeIds:x,disabledNodeIds:v,nodeFilterMode:w}=d,m=c!==null||t!==null,N=o.size>0;let h;if(v.size>0){h=new Set;for(const j of x)v.has(j)||h.add(j)}else h=x;const S=h.size>0;let k=null;if(S){k=new Set;for(const j of h)k.add(J(j))}return{hasTime:m,hasDevice:N,hasNode:S,tStart:c??l.start,tEnd:t??l.end,deviceTypes:o,effectiveNodeIds:h,nodeIdPrefixes:k,nodeFilterMode:w,needsDisambiguation:N||S}}function ae(d,l,c){if(l.hasTime&&(d.timestampl.tEnd))return!1;if(l.needsDisambiguation){const t=c(d);if(l.hasDevice&&!l.deviceTypes.has(t.type))return!1;if(l.hasNode){if(l.nodeFilterMode==="observed"){let o=!1;if(t.hash&&l.effectiveNodeIds.has(t.hash)&&(o=!0),!o&&d.dst_hash&&(l.effectiveNodeIds.has(d.dst_hash)||l.nodeIdPrefixes.has(J(d.dst_hash)))&&(o=!0),!o){const x=d.forwarded_path??d.original_path;if(x&&Array.isArray(x))for(const v of x){const w=String(v).toUpperCase();if(l.nodeIdPrefixes.has(w)){o=!0;break}}}if(!o)return!1}else if(!t.hash||!l.effectiveNodeIds.has(t.hash))return!1}}return!0}function he(d,l,c,t){const o=re(l,t);return!o.hasTime&&!o.hasDevice&&!o.hasNode?d:d.filter(x=>ae(x,o,c))}function X(d,l){const c=new Date(d*1e3),t=v=>v.toString().padStart(2,"0"),o=`${t(c.getHours())}:${t(c.getMinutes())}`;return l<24?o:`${["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][c.getMonth()]} ${c.getDate()} ${o}`}const le=[{type:"repeater",label:"Repeater",icon:q,buttonColor:"primary",iconColor:"text-sys-blue",hoverClass:"hover:border-sys-blue hover:text-sys-blue hover:!bg-transparent"},{type:"companion",label:"Companion",icon:Z,buttonColor:"indigo",iconColor:"text-sys-indigo",hoverClass:"hover:border-sys-indigo hover:text-sys-indigo hover:!bg-transparent"},{type:"room_server",label:"Room",icon:G,buttonColor:"purple",iconColor:"text-sys-purple",hoverClass:"hover:border-sys-purple hover:text-sys-purple hover:!bg-transparent"},{type:"unknown",label:"Unknown",icon:W,buttonColor:"zinc",iconColor:"text-zinc-400",hoverClass:"hover:border-zinc-400 hover:text-zinc-400 hover:!bg-transparent"}],D=60,E=.005;function ie({min:d,max:l,valueStart:c,valueEnd:t,onChange:o}){const x=u.useRef(null),[v,w]=u.useState(null),m=u.useRef({valueStart:c,valueEnd:t,min:d,max:l});m.current={valueStart:c,valueEnd:t,min:d,max:l};const N=u.useRef({offset:0,width:0}),h=l-d||1,S=h/3600,k=c??d,j=t??l,C=(k-d)/h*100,F=(j-d)/h*100,_=c!==null||t!==null,I=u.useCallback(i=>{const a=x.current.getBoundingClientRect(),e=Math.max(0,Math.min(1,(i-a.left)/a.width)),{min:s,max:r}=m.current;return Math.round(s+e*(r-s||1))},[]),T=u.useCallback((i,a)=>{a.preventDefault(),a.stopPropagation();const e=a.currentTarget;e.setPointerCapture(a.pointerId),w(i);const s=f=>{const g=I(f.clientX),{valueStart:y,valueEnd:b,min:p,max:L}=m.current,z=L-p||1;if(i==="start"){const M=Math.min(g,(b??L)-D);o(M<=p+z*E?null:M,b)}else{const M=Math.max(g,(y??p)+D);o(y,M>=L-z*E?null:M)}},r=()=>{w(null),e.removeEventListener("pointermove",s),e.removeEventListener("pointerup",r),e.removeEventListener("pointercancel",r)};e.addEventListener("pointermove",s),e.addEventListener("pointerup",r),e.addEventListener("pointercancel",r)},[I,o]),$=u.useCallback(i=>{i.preventDefault(),i.stopPropagation();const a=i.currentTarget;a.setPointerCapture(i.pointerId),w("range");const e=m.current.valueStart??m.current.min,s=m.current.valueEnd??m.current.max;N.current={offset:I(i.clientX)-e,width:s-e};const r=g=>{const y=I(g.clientX),{min:b,max:p}=m.current,{offset:L,width:z}=N.current;let M=y-L;M=Math.max(b,Math.min(p-z,M));const H=M+z;o(Math.round(M)<=b?null:Math.round(M),Math.round(H)>=p?null:Math.round(H))},f=()=>{w(null),a.removeEventListener("pointermove",r),a.removeEventListener("pointerup",f),a.removeEventListener("pointercancel",f)};a.addEventListener("pointermove",r),a.addEventListener("pointerup",f),a.addEventListener("pointercancel",f)},[I,o]),O=u.useCallback(i=>{const a=I(i.clientX),{valueStart:e,valueEnd:s,min:r,max:f}=m.current,g=f-r||1,y=e??r,b=s??f;if(Math.abs(a-y)<=Math.abs(a-b)){const p=Math.min(a,b-D);o(p<=r+g*E?null:p,s)}else{const p=Math.max(a,y+D);o(e,p>=f-g*E?null:p)}},[I,o]),R=u.useCallback(()=>o(null,null),[o]),A=u.useCallback((i,a)=>{const e=a.key==="ArrowRight"||a.key==="ArrowUp"?1:a.key==="ArrowLeft"||a.key==="ArrowDown"?-1:0;if(!e)return;a.preventDefault();const s=(a.shiftKey?.1:.01)*h,{valueStart:r,valueEnd:f,min:g,max:y}=m.current,b=y-g||1;if(i==="start"){const p=Math.max(g,Math.min((r??g)+e*s,(f??y)-D));o(p<=g+b*E?null:p,f)}else{const p=Math.min(y,Math.max((f??y)+e*s,(r??g)+D));o(r,p>=y-b*E?null:p)}},[h,o]),P=i=>{const a=i==="start"?c!==null:t!==null,e=v===i;return["absolute top-1/2 -translate-y-1/2 -translate-x-1/2 w-1 h-4 rounded-full","before:content-[''] before:absolute before:-inset-x-3 before:-inset-y-1","touch-none outline-none",e?"cursor-grabbing":"cursor-ew-resize",e?"bg-sys-blue shadow-[0_0_8px_var(--sys-blue)] scale-x-150 z-20":a?"bg-sys-blue shadow-[0_0_4px_var(--sys-blue)] hover:shadow-[0_0_8px_var(--sys-blue)] hover:scale-x-150 z-10":"bg-edge-subtle hover:bg-fg-muted hover:scale-x-150 z-10",e?"":"transition-[transform,box-shadow,background-color] duration-150 ease-out","focus-visible:ring-2 focus-visible:ring-sys-blue/50"].filter(Boolean).join(" ")};return n.jsxs("div",{className:"flex flex-col gap-0.5 min-w-[160px] sm:min-w-[220px]",children:[n.jsxs("div",{className:"flex items-center justify-between type-data-xs text-fg-muted tabular-nums select-none",children:[n.jsx("span",{className:_&&c!==null?"text-sys-blue":"",children:X(k,S)}),n.jsx("span",{className:_&&t!==null?"text-sys-blue":"",children:X(j,S)})]}),n.jsxs("div",{ref:x,className:"relative h-5 select-none",onPointerDown:O,onDoubleClick:R,children:[n.jsx("div",{className:"absolute inset-x-0 top-1/2 -translate-y-1/2 h-1.5 rounded-full bg-white/[0.06] pointer-events-none"}),_?n.jsx("div",{className:["group/band absolute inset-y-0 touch-none",v==="range"?"cursor-grabbing":"cursor-grab"].join(" "),style:{left:`${C}%`,right:`${100-F}%`},onPointerDown:$,children:n.jsx("div",{className:["absolute inset-x-0 top-1/2 -translate-y-1/2 h-1.5 rounded-full pointer-events-none transition-colors",v==="range"?"bg-sys-blue/40":"bg-sys-blue/25 group-hover/band:bg-sys-blue/35"].join(" ")})}):n.jsx("div",{className:"absolute inset-x-0 top-1/2 -translate-y-1/2 h-1.5 rounded-full bg-white/[0.04] pointer-events-none"}),n.jsx("div",{role:"slider",tabIndex:0,"aria-label":"Range start","aria-valuenow":k,className:P("start"),style:{left:`${C}%`},onPointerDown:i=>T("start",i),onKeyDown:i=>A("start",i)}),n.jsx("div",{role:"slider",tabIndex:0,"aria-label":"Range end","aria-valuenow":j,className:P("end"),style:{left:`${F}%`},onPointerDown:i=>T("end",i),onKeyDown:i=>A("end",i)})]})]})}function fe({parentStartTs:d,parentEndTs:l,neighbors:c,filter:t,onChange:o,scatterDotSize:x,onScatterDotSizeChange:v,scatterOpacity:w,onScatterOpacityChange:m}){const[N,h]=u.useState(""),[S,k]=u.useState(!1),j=u.useRef(null);u.useEffect(()=>{function e(s){j.current&&!j.current.contains(s.target)&&k(!1)}if(S)return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[S]);const C=u.useMemo(()=>Object.entries(c).map(([e,s])=>{const r=V(s);return{hash:e,name:s.name??s.node_name??e.slice(0,8),type:r.type,label:r.label}}).sort((e,s)=>e.name.localeCompare(s.name)),[c]),F=u.useMemo(()=>{if(!N)return C;const e=N.toLowerCase();return C.filter(s=>s.name.toLowerCase().includes(e)||s.hash.toLowerCase().includes(e))},[C,N]),_=t.timeStart!==null||t.timeEnd!==null||t.deviceTypes.size>0||t.nodeIds.size>0,I=u.useCallback((e,s)=>{o({...t,timeStart:e,timeEnd:s})},[t,o]),T=u.useCallback(e=>{const s=new Set(t.deviceTypes);s.has(e)?s.delete(e):s.add(e),o({...t,deviceTypes:s})},[t,o]),$=u.useCallback(e=>{const s=new Set(t.nodeIds);s.has(e)?s.delete(e):s.add(e),o({...t,nodeIds:s}),h("")},[t,o]),O=u.useCallback(e=>{const s=new Set(t.nodeIds);s.delete(e);const r=new Set(t.disabledNodeIds);r.delete(e),o({...t,nodeIds:s,disabledNodeIds:r})},[t,o]),R=u.useCallback(e=>{const s=new Set(t.disabledNodeIds);s.has(e)?s.delete(e):s.add(e),o({...t,disabledNodeIds:s})},[t,o]),A=u.useCallback(()=>{o({...t,nodeFilterMode:t.nodeFilterMode==="source"?"observed":"source"})},[t,o]),P=u.useCallback(()=>{o({timeStart:null,timeEnd:null,deviceTypes:new Set,nodeIds:new Set,disabledNodeIds:new Set,nodeFilterMode:"source"}),h("")},[o]),i=u.useMemo(()=>{const e=new Map;for(const s of t.nodeIds){const r=c[s];e.set(s,(r==null?void 0:r.name)??(r==null?void 0:r.node_name)??s.slice(0,8))}return e},[t.nodeIds,c]),a=!!(v&&m);return n.jsxs("div",{className:"flex flex-col gap-2 card-padding",children:[n.jsxs("div",{className:"flex items-center gap-3",children:[a&&n.jsxs(n.Fragment,{children:[n.jsx(B,{icon:n.jsx(se,{className:"w-3 h-3"}),label:"Size",value:x??.8,onChange:v,min:.3,max:3,step:.1,format:e=>e.toFixed(1)}),n.jsx(B,{icon:n.jsx(oe,{className:"w-3 h-3"}),label:"Opacity",value:w??50,onChange:m,min:5,max:100,step:5,format:e=>`${Math.round(e)}%`}),n.jsx("div",{className:"w-px h-4 bg-edge-subtle shrink-0 hidden sm:block"})]}),n.jsx("div",{className:"flex items-center gap-1.5 text-fg-muted shrink-0",children:n.jsx(Y,{className:"w-3.5 h-3.5"})}),n.jsx("div",{className:"flex-1 min-w-[120px]",children:n.jsx(ie,{min:d,max:l,valueStart:t.timeStart,valueEnd:t.timeEnd,onChange:I})}),_&&n.jsxs("button",{type:"button",onClick:P,className:"flex items-center gap-1 px-2 py-0.5 rounded-full type-data-xs text-fg-muted hover:text-fg-primary border border-edge-subtle hover:border-fg-muted/40 transition-colors shrink-0",title:"Clear all filters",children:[n.jsx(K,{className:"w-3 h-3"}),n.jsx("span",{className:"hidden sm:inline",children:"Clear"})]})]}),n.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[n.jsx("div",{className:"flex items-center gap-1.5 overflow-x-auto pb-0.5 -mb-0.5 shrink-0",children:le.map(({type:e,label:s,icon:r,buttonColor:f,iconColor:g,hoverClass:y})=>{const b=t.deviceTypes.has(e);return n.jsxs(Q,{color:b?f:"zinc",outline:!b,className:`!h-8 !py-0 ${b?"":y}`,onClick:()=>T(e),title:`Filter by ${s}`,children:[n.jsx(r,{"data-slot":"icon",className:b?"":g}),n.jsx("span",{className:`hidden sm:inline ${b?"":"text-fg-muted"}`,children:s})]},e)})}),n.jsx("div",{className:"w-px h-4 bg-edge-subtle shrink-0 hidden md:block"}),n.jsxs("div",{className:"relative flex items-center gap-1.5 flex-1 min-w-[120px] sm:min-w-[180px] h-8 px-2 rounded-md border border-edge-subtle bg-white/[0.03] transition-colors focus-within:border-sys-blue",ref:j,children:[n.jsx(ee,{className:"w-3 h-3 text-fg-muted/50 shrink-0"}),n.jsx("input",{type:"text",className:"flex-1 min-w-[60px] type-data-xs py-0.5 bg-transparent text-fg-secondary placeholder:text-fg-muted/40 border-none focus:outline-none",placeholder:"Search nodes...",value:N,onChange:e=>{h(e.target.value),k(!0)},onFocus:()=>k(!0)}),S&&F.length>0&&n.jsx("div",{className:"absolute top-full left-0 right-0 mt-1 z-[200] surface-popover border border-edge-subtle radius-inner max-h-48 overflow-y-auto",children:F.slice(0,20).map(e=>{const s=t.nodeIds.has(e.hash);return n.jsxs("button",{type:"button",onClick:()=>$(e.hash),className:` + */const ne=[["path",{d:"M7 16.3c2.2 0 4-1.83 4-4.05 0-1.16-.57-2.26-1.71-3.19S7.29 6.75 7 5.3c-.29 1.45-1.14 2.84-2.29 3.76S3 11.1 3 12.25c0 2.22 1.8 4.05 4 4.05z",key:"1ptgy4"}],["path",{d:"M12.56 6.6A10.97 10.97 0 0 0 14 3.02c.5 2.5 2 4.9 4 6.5s3 3.5 3 5.5a6.98 6.98 0 0 1-11.91 4.97",key:"1sl1rz"}]],oe=U("droplets",ne);function xe(){return{timeStart:null,timeEnd:null,deviceTypes:new Set,nodeIds:new Set,disabledNodeIds:new Set,nodeFilterMode:"source"}}function re(d,l){const{timeStart:c,timeEnd:t,deviceTypes:o,nodeIds:x,disabledNodeIds:v,nodeFilterMode:w}=d,m=c!==null||t!==null,N=o.size>0;let h;if(v.size>0){h=new Set;for(const j of x)v.has(j)||h.add(j)}else h=x;const S=h.size>0;let k=null;if(S){k=new Set;for(const j of h)k.add(J(j))}return{hasTime:m,hasDevice:N,hasNode:S,tStart:c??l.start,tEnd:t??l.end,deviceTypes:o,effectiveNodeIds:h,nodeIdPrefixes:k,nodeFilterMode:w,needsDisambiguation:N||S}}function ae(d,l,c){if(l.hasTime&&(d.timestampl.tEnd))return!1;if(l.needsDisambiguation){const t=c(d);if(l.hasDevice&&!l.deviceTypes.has(t.type))return!1;if(l.hasNode){if(l.nodeFilterMode==="observed"){let o=!1;if(t.hash&&l.effectiveNodeIds.has(t.hash)&&(o=!0),!o&&d.dst_hash&&(l.effectiveNodeIds.has(d.dst_hash)||l.nodeIdPrefixes.has(J(d.dst_hash)))&&(o=!0),!o){const x=d.forwarded_path??d.original_path;if(x&&Array.isArray(x))for(const v of x){const w=String(v).toUpperCase();if(l.nodeIdPrefixes.has(w)){o=!0;break}}}if(!o)return!1}else if(!t.hash||!l.effectiveNodeIds.has(t.hash))return!1}}return!0}function he(d,l,c,t){const o=re(l,t);return!o.hasTime&&!o.hasDevice&&!o.hasNode?d:d.filter(x=>ae(x,o,c))}function X(d,l){const c=new Date(d*1e3),t=v=>v.toString().padStart(2,"0"),o=`${t(c.getHours())}:${t(c.getMinutes())}`;return l<24?o:`${["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][c.getMonth()]} ${c.getDate()} ${o}`}const le=[{type:"repeater",label:"Repeater",icon:q,buttonColor:"primary",iconColor:"text-sys-blue",hoverClass:"hover:border-sys-blue hover:text-sys-blue hover:!bg-transparent"},{type:"companion",label:"Companion",icon:Z,buttonColor:"indigo",iconColor:"text-sys-indigo",hoverClass:"hover:border-sys-indigo hover:text-sys-indigo hover:!bg-transparent"},{type:"room_server",label:"Room",icon:G,buttonColor:"purple",iconColor:"text-sys-purple",hoverClass:"hover:border-sys-purple hover:text-sys-purple hover:!bg-transparent"},{type:"unknown",label:"Unknown",icon:W,buttonColor:"zinc",iconColor:"text-zinc-400",hoverClass:"hover:border-zinc-400 hover:text-zinc-400 hover:!bg-transparent"}],D=60,E=.005;function ie({min:d,max:l,valueStart:c,valueEnd:t,onChange:o}){const x=u.useRef(null),[v,w]=u.useState(null),m=u.useRef({valueStart:c,valueEnd:t,min:d,max:l});m.current={valueStart:c,valueEnd:t,min:d,max:l};const N=u.useRef({offset:0,width:0}),h=l-d||1,S=h/3600,k=c??d,j=t??l,C=(k-d)/h*100,F=(j-d)/h*100,_=c!==null||t!==null,I=u.useCallback(i=>{const a=x.current.getBoundingClientRect(),e=Math.max(0,Math.min(1,(i-a.left)/a.width)),{min:s,max:r}=m.current;return Math.round(s+e*(r-s||1))},[]),T=u.useCallback((i,a)=>{a.preventDefault(),a.stopPropagation();const e=a.currentTarget;e.setPointerCapture(a.pointerId),w(i);const s=f=>{const g=I(f.clientX),{valueStart:y,valueEnd:b,min:p,max:L}=m.current,z=L-p||1;if(i==="start"){const M=Math.min(g,(b??L)-D);o(M<=p+z*E?null:M,b)}else{const M=Math.max(g,(y??p)+D);o(y,M>=L-z*E?null:M)}},r=()=>{w(null),e.removeEventListener("pointermove",s),e.removeEventListener("pointerup",r),e.removeEventListener("pointercancel",r)};e.addEventListener("pointermove",s),e.addEventListener("pointerup",r),e.addEventListener("pointercancel",r)},[I,o]),$=u.useCallback(i=>{i.preventDefault(),i.stopPropagation();const a=i.currentTarget;a.setPointerCapture(i.pointerId),w("range");const e=m.current.valueStart??m.current.min,s=m.current.valueEnd??m.current.max;N.current={offset:I(i.clientX)-e,width:s-e};const r=g=>{const y=I(g.clientX),{min:b,max:p}=m.current,{offset:L,width:z}=N.current;let M=y-L;M=Math.max(b,Math.min(p-z,M));const O=M+z;o(Math.round(M)<=b?null:Math.round(M),Math.round(O)>=p?null:Math.round(O))},f=()=>{w(null),a.removeEventListener("pointermove",r),a.removeEventListener("pointerup",f),a.removeEventListener("pointercancel",f)};a.addEventListener("pointermove",r),a.addEventListener("pointerup",f),a.addEventListener("pointercancel",f)},[I,o]),H=u.useCallback(i=>{const a=I(i.clientX),{valueStart:e,valueEnd:s,min:r,max:f}=m.current,g=f-r||1,y=e??r,b=s??f;if(Math.abs(a-y)<=Math.abs(a-b)){const p=Math.min(a,b-D);o(p<=r+g*E?null:p,s)}else{const p=Math.max(a,y+D);o(e,p>=f-g*E?null:p)}},[I,o]),R=u.useCallback(()=>o(null,null),[o]),A=u.useCallback((i,a)=>{const e=a.key==="ArrowRight"||a.key==="ArrowUp"?1:a.key==="ArrowLeft"||a.key==="ArrowDown"?-1:0;if(!e)return;a.preventDefault();const s=(a.shiftKey?.1:.01)*h,{valueStart:r,valueEnd:f,min:g,max:y}=m.current,b=y-g||1;if(i==="start"){const p=Math.max(g,Math.min((r??g)+e*s,(f??y)-D));o(p<=g+b*E?null:p,f)}else{const p=Math.min(y,Math.max((f??y)+e*s,(r??g)+D));o(r,p>=y-b*E?null:p)}},[h,o]),P=i=>{const a=i==="start"?c!==null:t!==null,e=v===i;return["absolute top-1/2 -translate-y-1/2 -translate-x-1/2 w-1 h-4 rounded-full","before:content-[''] before:absolute before:-inset-x-3 before:-inset-y-1","touch-none outline-none",e?"cursor-grabbing":"cursor-ew-resize",e?"bg-sys-blue shadow-[0_0_8px_var(--sys-blue)] scale-x-150 z-20":a?"bg-sys-blue shadow-[0_0_4px_var(--sys-blue)] hover:shadow-[0_0_8px_var(--sys-blue)] hover:scale-x-150 z-10":"bg-edge-subtle hover:bg-fg-muted hover:scale-x-150 z-10",e?"":"transition-[transform,box-shadow,background-color] duration-150 ease-out","focus-visible:ring-2 focus-visible:ring-sys-blue/50"].filter(Boolean).join(" ")};return n.jsxs("div",{className:"flex flex-col gap-0.5 min-w-[160px] sm:min-w-[220px]",children:[n.jsxs("div",{className:"flex items-center justify-between type-data-xs text-fg-muted tabular-nums select-none",children:[n.jsx("span",{className:_&&c!==null?"text-sys-blue":"",children:X(k,S)}),n.jsx("span",{className:_&&t!==null?"text-sys-blue":"",children:X(j,S)})]}),n.jsxs("div",{ref:x,className:"relative h-5 select-none",onPointerDown:H,onDoubleClick:R,children:[n.jsx("div",{className:"absolute inset-x-0 top-1/2 -translate-y-1/2 h-1.5 rounded-full bg-white/[0.06] pointer-events-none"}),_?n.jsx("div",{className:["group/band absolute inset-y-0 touch-none",v==="range"?"cursor-grabbing":"cursor-grab"].join(" "),style:{left:`${C}%`,right:`${100-F}%`},onPointerDown:$,children:n.jsx("div",{className:["absolute inset-x-0 top-1/2 -translate-y-1/2 h-1.5 rounded-full pointer-events-none transition-colors",v==="range"?"bg-sys-blue/40":"bg-sys-blue/25 group-hover/band:bg-sys-blue/35"].join(" ")})}):n.jsx("div",{className:"absolute inset-x-0 top-1/2 -translate-y-1/2 h-1.5 rounded-full bg-white/[0.04] pointer-events-none"}),n.jsx("div",{role:"slider",tabIndex:0,"aria-label":"Range start","aria-valuenow":k,className:P("start"),style:{left:`${C}%`},onPointerDown:i=>T("start",i),onKeyDown:i=>A("start",i)}),n.jsx("div",{role:"slider",tabIndex:0,"aria-label":"Range end","aria-valuenow":j,className:P("end"),style:{left:`${F}%`},onPointerDown:i=>T("end",i),onKeyDown:i=>A("end",i)})]})]})}function fe({parentStartTs:d,parentEndTs:l,neighbors:c,filter:t,onChange:o,scatterDotSize:x,onScatterDotSizeChange:v,scatterOpacity:w,onScatterOpacityChange:m}){const[N,h]=u.useState(""),[S,k]=u.useState(!1),j=u.useRef(null);u.useEffect(()=>{function e(s){j.current&&!j.current.contains(s.target)&&k(!1)}if(S)return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[S]);const C=u.useMemo(()=>Object.entries(c).map(([e,s])=>{const r=V(s);return{hash:e,name:s.name??s.node_name??e.slice(0,8),type:r.type,label:r.label}}).sort((e,s)=>e.name.localeCompare(s.name)),[c]),F=u.useMemo(()=>{if(!N)return C;const e=N.toLowerCase();return C.filter(s=>s.name.toLowerCase().includes(e)||s.hash.toLowerCase().includes(e))},[C,N]),_=t.timeStart!==null||t.timeEnd!==null||t.deviceTypes.size>0||t.nodeIds.size>0,I=u.useCallback((e,s)=>{o({...t,timeStart:e,timeEnd:s})},[t,o]),T=u.useCallback(e=>{const s=new Set(t.deviceTypes);s.has(e)?s.delete(e):s.add(e),o({...t,deviceTypes:s})},[t,o]),$=u.useCallback(e=>{const s=new Set(t.nodeIds);s.has(e)?s.delete(e):s.add(e),o({...t,nodeIds:s}),h("")},[t,o]),H=u.useCallback(e=>{const s=new Set(t.nodeIds);s.delete(e);const r=new Set(t.disabledNodeIds);r.delete(e),o({...t,nodeIds:s,disabledNodeIds:r})},[t,o]),R=u.useCallback(e=>{const s=new Set(t.disabledNodeIds);s.has(e)?s.delete(e):s.add(e),o({...t,disabledNodeIds:s})},[t,o]),A=u.useCallback(()=>{o({...t,nodeFilterMode:t.nodeFilterMode==="source"?"observed":"source"})},[t,o]),P=u.useCallback(()=>{o({timeStart:null,timeEnd:null,deviceTypes:new Set,nodeIds:new Set,disabledNodeIds:new Set,nodeFilterMode:"source"}),h("")},[o]),i=u.useMemo(()=>{const e=new Map;for(const s of t.nodeIds){const r=c[s];e.set(s,(r==null?void 0:r.name)??(r==null?void 0:r.node_name)??s.slice(0,8))}return e},[t.nodeIds,c]),a=!!(v&&m);return n.jsxs("div",{className:"flex flex-col gap-2 card-padding",children:[n.jsxs("div",{className:"flex items-center gap-3",children:[a&&n.jsxs(n.Fragment,{children:[n.jsx(B,{icon:n.jsx(se,{className:"w-3 h-3"}),label:"Size",value:x??.8,onChange:v,min:.3,max:3,step:.1,format:e=>e.toFixed(1)}),n.jsx(B,{icon:n.jsx(oe,{className:"w-3 h-3"}),label:"Opacity",value:w??50,onChange:m,min:5,max:100,step:5,format:e=>`${Math.round(e)}%`}),n.jsx("div",{className:"w-px h-4 bg-edge-subtle shrink-0 hidden sm:block"})]}),n.jsx("div",{className:"flex items-center gap-1.5 text-fg-muted shrink-0",children:n.jsx(Y,{className:"w-3.5 h-3.5"})}),n.jsx("div",{className:"flex-1 min-w-[120px]",children:n.jsx(ie,{min:d,max:l,valueStart:t.timeStart,valueEnd:t.timeEnd,onChange:I})}),_&&n.jsxs("button",{type:"button",onClick:P,className:"flex items-center gap-1 px-2 py-0.5 rounded-full type-data-xs text-fg-muted hover:text-fg-primary border border-edge-subtle hover:border-fg-muted/40 transition-colors shrink-0",title:"Clear all filters",children:[n.jsx(K,{className:"w-3 h-3"}),n.jsx("span",{className:"hidden sm:inline",children:"Clear"})]})]}),n.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[n.jsx("div",{className:"flex items-center gap-1.5 overflow-x-auto pb-0.5 -mb-0.5 shrink-0",children:le.map(({type:e,label:s,icon:r,buttonColor:f,iconColor:g,hoverClass:y})=>{const b=t.deviceTypes.has(e);return n.jsxs(Q,{color:b?f:"zinc",outline:!b,className:`!h-8 !py-0 ${b?"":y}`,onClick:()=>T(e),title:`Filter by ${s}`,children:[n.jsx(r,{"data-slot":"icon",className:b?"":g}),n.jsx("span",{className:`hidden sm:inline ${b?"":"text-fg-muted"}`,children:s})]},e)})}),n.jsx("div",{className:"w-px h-4 bg-edge-subtle shrink-0 hidden md:block"}),n.jsxs("div",{className:"relative flex items-center gap-1.5 flex-1 min-w-[120px] sm:min-w-[180px] h-8 px-2 rounded-md border border-edge-subtle bg-white/[0.03] transition-colors focus-within:border-sys-blue",ref:j,children:[n.jsx(ee,{className:"w-3 h-3 text-fg-muted/50 shrink-0"}),n.jsx("input",{type:"text",className:"flex-1 min-w-[60px] type-data-xs py-0.5 bg-transparent text-fg-secondary placeholder:text-fg-muted/40 border-none focus:outline-none",placeholder:"Search nodes...",value:N,onChange:e=>{h(e.target.value),k(!0)},onFocus:()=>k(!0)}),S&&F.length>0&&n.jsx("div",{className:"absolute top-full left-0 right-0 mt-1 z-[200] surface-popover border border-edge-subtle radius-inner max-h-48 overflow-y-auto",children:F.slice(0,20).map(e=>{const s=t.nodeIds.has(e.hash);return n.jsxs("button",{type:"button",onClick:()=>$(e.hash),className:` w-full flex items-center gap-2 px-2.5 py-1.5 type-data-xs text-left transition-colors ${s?"bg-sys-indigo/15 text-sys-indigo":"text-fg-secondary hover:bg-subtle-fill"} - `,children:[n.jsx("span",{className:"flex-1 truncate",children:e.name}),n.jsx("span",{className:"text-fg-muted type-data-xs shrink-0",children:e.label})]},e.hash)})})]})]}),t.nodeIds.size>0&&n.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[Array.from(t.nodeIds).map(e=>{const s=t.disabledNodeIds.has(e);return n.jsxs("span",{role:"button",tabIndex:0,onClick:()=>R(e),onKeyDown:r=>{(r.key==="Enter"||r.key===" ")&&(r.preventDefault(),R(e))},className:`inline-flex items-center gap-1 px-2 py-0.5 rounded-full type-data-xs border transition-colors select-none ${s?"bg-zinc-500/10 text-fg-muted border-edge-subtle cursor-pointer hover:bg-zinc-500/15":"bg-sys-indigo/15 text-sys-indigo border-sys-indigo/25 cursor-pointer hover:bg-sys-indigo/25"}`,title:e,children:[i.get(e)??e.slice(0,8),n.jsx("button",{type:"button",onClick:r=>{r.stopPropagation(),O(e)},className:"hover:text-fg-primary transition-colors -mr-0.5",title:"Remove from filter",children:n.jsx(K,{className:"w-3 h-3"})})]},e)}),n.jsx("button",{type:"button",onClick:A,className:`inline-flex items-center gap-1 px-2 py-0.5 rounded-full type-data-xs border transition-colors ${t.nodeFilterMode==="observed"?"bg-sys-blue/15 text-sys-blue border-sys-blue/25 hover:bg-sys-blue/25":"bg-white/[0.04] text-fg-muted border-edge-subtle hover:text-fg-secondary hover:border-fg-muted/40"}`,title:t.nodeFilterMode==="source"?"Source Only — showing packets sent by selected node(s)":"Total Observed — showing all packets where selected node(s) appear (source, path, or destination)",children:t.nodeFilterMode==="source"?"Source Only":"Total Observed"})]})]})}const B=u.memo(function({icon:l,label:c,value:t,onChange:o,min:x,max:v,step:w,format:m}){return n.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[n.jsxs("div",{className:"flex items-center gap-1.5 text-fg-muted shrink-0",children:[l,n.jsx("span",{className:"type-data-xs font-medium hidden sm:inline",children:c})]}),n.jsx("input",{type:"range",min:x,max:v,step:w,value:t,onChange:N=>o(parseFloat(N.target.value)),className:"flex-1 h-1 min-w-[60px] bg-subtle-fill rounded appearance-none cursor-pointer [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-2.5 [&::-webkit-slider-thumb]:h-2.5 [&::-webkit-slider-thumb]:bg-sys-blue [&::-webkit-slider-thumb]:rounded-full [&::-webkit-slider-thumb]:cursor-pointer"}),n.jsx("span",{className:"type-data-xs text-fg-secondary tabular-nums shrink-0 w-8 text-right",children:m?m(t):t})]})});export{fe as A,he as a,xe as c}; + `,children:[n.jsx("span",{className:"flex-1 truncate",children:e.name}),n.jsx("span",{className:"text-fg-muted type-data-xs shrink-0",children:e.label})]},e.hash)})})]})]}),t.nodeIds.size>0&&n.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[Array.from(t.nodeIds).map(e=>{const s=t.disabledNodeIds.has(e);return n.jsxs("span",{role:"button",tabIndex:0,onClick:()=>R(e),onKeyDown:r=>{(r.key==="Enter"||r.key===" ")&&(r.preventDefault(),R(e))},className:`inline-flex items-center gap-1 px-2 py-0.5 rounded-full type-data-xs border transition-colors select-none ${s?"bg-zinc-500/10 text-fg-muted border-edge-subtle cursor-pointer hover:bg-zinc-500/15":"bg-sys-indigo/15 text-sys-indigo border-sys-indigo/25 cursor-pointer hover:bg-sys-indigo/25"}`,title:e,children:[i.get(e)??e.slice(0,8),n.jsx("button",{type:"button",onClick:r=>{r.stopPropagation(),H(e)},className:"hover:text-fg-primary transition-colors -mr-0.5",title:"Remove from filter",children:n.jsx(K,{className:"w-3 h-3"})})]},e)}),n.jsx("button",{type:"button",onClick:A,className:`inline-flex items-center gap-1 px-2 py-0.5 rounded-full type-data-xs border transition-colors ${t.nodeFilterMode==="observed"?"bg-sys-blue/15 text-sys-blue border-sys-blue/25 hover:bg-sys-blue/25":"bg-white/[0.04] text-fg-muted border-edge-subtle hover:text-fg-secondary hover:border-fg-muted/40"}`,title:t.nodeFilterMode==="source"?"Source Only — showing packets sent by selected node(s)":"Total Observed — showing all packets where selected node(s) appear (source, path, or destination)",children:t.nodeFilterMode==="source"?"Source Only":"Total Observed"})]})]})}const B=u.memo(function({icon:l,label:c,value:t,onChange:o,min:x,max:v,step:w,format:m}){return n.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[n.jsxs("div",{className:"flex items-center gap-1.5 text-fg-muted shrink-0",children:[l,n.jsx("span",{className:"type-data-xs font-medium hidden sm:inline",children:c})]}),n.jsx("input",{type:"range",min:x,max:v,step:w,value:t,onChange:N=>o(parseFloat(N.target.value)),className:"flex-1 h-1 min-w-[60px] bg-subtle-fill rounded appearance-none cursor-pointer [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-2.5 [&::-webkit-slider-thumb]:h-2.5 [&::-webkit-slider-thumb]:bg-sys-blue [&::-webkit-slider-thumb]:rounded-full [&::-webkit-slider-thumb]:cursor-pointer"}),n.jsx("span",{className:"type-data-xs text-fg-secondary tabular-nums shrink-0 w-8 text-right",children:m?m(t):t})]})});export{fe as A,he as a,xe as c}; diff --git a/frontend/dist/assets/AnimatedNumber-DdMz2uoH.js b/frontend/dist/assets/AnimatedNumber-DdMz2uoH.js deleted file mode 100644 index e2144b48..00000000 --- a/frontend/dist/assets/AnimatedNumber-DdMz2uoH.js +++ /dev/null @@ -1,6 +0,0 @@ -import{d as p,r as e,cl as f,j as m,cm as A}from"./index-C1ZF7cAz.js";import{A as h}from"./index-DCNWD5GU.js";/** - * @license lucide-react v0.559.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const y=[["path",{d:"M6 18.5a3.5 3.5 0 1 0 7 0c0-1.57.92-2.52 2.04-3.46",key:"1qngmn"}],["path",{d:"M6 8.5c0-.75.13-1.47.36-2.14",key:"b06bma"}],["path",{d:"M8.8 3.15A6.5 6.5 0 0 1 19 8.5c0 1.63-.44 2.81-1.09 3.76",key:"g10hsz"}],["path",{d:"M12.5 6A2.5 2.5 0 0 1 15 8.5M10 13a2 2 0 0 0 1.82-1.18",key:"ygzou7"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]],E=p("ear-off",y),j=e.memo(function({value:t,format:a,prefix:s,suffix:i,className:r,priority:c="medium"}){const[n,u]=e.useState(!1),[d,o]=e.useState(t);e.useEffect(()=>f(()=>{u(!0),o(0)},c),[c]),e.useEffect(()=>{n&&o(t)},[n,t]);const l=`${s??""}${t.toLocaleString(void 0,a)}${i??""}`;return n?m.jsx(h,{className:`${r??""} overflow-hidden`,format:a,prefix:s,suffix:i,transition:A.numberTicker,children:d}):m.jsx("span",{className:r,children:l})});export{j as A,E}; diff --git a/frontend/dist/assets/AnimatedNumber-VoU6jLG5.js b/frontend/dist/assets/AnimatedNumber-VoU6jLG5.js new file mode 100644 index 00000000..20371ec6 --- /dev/null +++ b/frontend/dist/assets/AnimatedNumber-VoU6jLG5.js @@ -0,0 +1,6 @@ +import{d as _,r as s,cj as A,j as f,ck as w}from"./index-DhkG1Nx9.js";import{A as x}from"./index-Bx_G2nLG.js";/** + * @license lucide-react v0.559.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const E=[["path",{d:"M6 18.5a3.5 3.5 0 1 0 7 0c0-1.57.92-2.52 2.04-3.46",key:"1qngmn"}],["path",{d:"M6 8.5c0-.75.13-1.47.36-2.14",key:"b06bma"}],["path",{d:"M8.8 3.15A6.5 6.5 0 0 1 19 8.5c0 1.63-.44 2.81-1.09 3.76",key:"g10hsz"}],["path",{d:"M12.5 6A2.5 2.5 0 0 1 15 8.5M10 13a2 2 0 0 0 1.82-1.18",key:"ygzou7"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]],$=_("ear-off",E),r={spreadingFactor:7,bandwidthHz:125e3,codingRate:5,preambleLength:8,crcEnabled:!0,explicitHeader:!0};function b(t){let e=2;const n=t.route??t.route_type;return(n===0||n===3)&&(e+=4),t.path_length!=null?e+=t.path_length:Array.isArray(t.original_path)&&(e+=t.original_path.length),e}function L(t){if(t._byteLength!==void 0)return t._byteLength;if(t.raw_packet){const e=t.raw_packet;if(/^[0-9a-fA-F]+$/.test(e)&&e.length%2===0)return e.length/2;if(/^[A-Za-z0-9+/=]+$/.test(e)){const n=(e.match(/=+$/)||[""])[0].length;return Math.floor(e.length*3/4)-n}return e.length}if(t.length&&t.length>0)return t.length+b(t);if(t.payload_length&&t.payload_length>0)return t.payload_length+b(t);if(t.payload){const e=t.payload;return/^[0-9a-fA-F]+$/.test(e)&&e.length%2===0?e.length/2:e.length}return 32}function z(t,e={}){const n=e.spreadingFactor??r.spreadingFactor,a=e.bandwidthHz??r.bandwidthHz,l=e.codingRate??r.codingRate,c=e.preambleLength??r.preambleLength??8,d=e.crcEnabled??r.crcEnabled?1:0,i=e.explicitHeader??r.explicitHeader?0:1,h=n>=11&&a<=125e3?1:0,u=a/1e3,o=Math.pow(2,n)/u,g=(c+4.25)*o,m=Math.max(8*t-4*n+28+16*d-20*i,0),p=4*(n-2*h),y=(8+Math.ceil(m/p)*l)*o;return g+y}function R(t,e={}){if(t.airtime_ms!==void 0&&t.airtime_ms>0)return t.airtime_ms;const n=L(t);return z(n,e)}function j(t){var n;const e=(n=t==null?void 0:t.config)==null?void 0:n.radio;return{spreadingFactor:(e==null?void 0:e.spreading_factor)??r.spreadingFactor,bandwidthHz:(e==null?void 0:e.bandwidth)??r.bandwidthHz,codingRate:(e==null?void 0:e.coding_rate)??r.codingRate,preambleLength:(e==null?void 0:e.preamble_length)??r.preambleLength,crcEnabled:!0,explicitHeader:!0}}const P=s.memo(function({value:e,format:n,prefix:a,suffix:l,className:c,priority:d="medium"}){const[i,h]=s.useState(!1),[u,o]=s.useState(e);s.useEffect(()=>A(()=>{h(!0),o(0)},d),[d]),s.useEffect(()=>{i&&o(e)},[i,e]);const g=`${a??""}${e.toLocaleString(void 0,n)}${l??""}`;return i?f.jsx(x,{className:`${c??""} overflow-hidden`,format:n,prefix:a,suffix:l,transition:w.numberTicker,children:u}):f.jsx("span",{className:c,children:g})});export{P as A,$ as E,L as a,R as g,j as r}; diff --git a/frontend/dist/assets/BasemapLayer-CfNM-FKA.js b/frontend/dist/assets/BasemapLayer-CfNM-FKA.js deleted file mode 100644 index de6e8db1..00000000 --- a/frontend/dist/assets/BasemapLayer-CfNM-FKA.js +++ /dev/null @@ -1,2 +0,0 @@ -const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-C1ZF7cAz.js","assets/index-DWhIzXT2.css"])))=>i.map(i=>d[i]); -import{r as i,bo as $,aD as B,bh as G}from"./index-C1ZF7cAz.js";const H=i.createContext(null);function K(){var s;const e=(s=i.useContext(H))==null?void 0:s.maps,t=i.useContext(w);return i.useMemo(()=>({...e,current:t==null?void 0:t.map}),[e,t])}function Y(e,t){const n=Array.isArray(e)?e[0]:e?e.x:0,s=Array.isArray(e)?e[1]:e?e.y:0,o=Array.isArray(t)?t[0]:t?t.x:0,r=Array.isArray(t)?t[1]:t?t.y:0;return n===o&&s===r}function v(e,t){if(e===t)return!0;if(!e||!t)return!1;if(Array.isArray(e)){if(!Array.isArray(t)||e.length!==t.length)return!1;for(let n=0;n{let o=null;"interactive"in s&&(o=Object.assign({},s),delete o.interactive);const r=t[s.ref];if(r){o=o||Object.assign({},s),delete o.ref;for(const a of J)a in r&&(o[a]=r[a])}return o||s});return{...e,layers:n}}const A={version:8,sources:{},layers:[]},U={mousedown:"onMouseDown",mouseup:"onMouseUp",mouseover:"onMouseOver",mousemove:"onMouseMove",click:"onClick",dblclick:"onDblClick",mouseenter:"onMouseEnter",mouseleave:"onMouseLeave",mouseout:"onMouseOut",contextmenu:"onContextMenu",touchstart:"onTouchStart",touchend:"onTouchEnd",touchmove:"onTouchMove",touchcancel:"onTouchCancel"},F={movestart:"onMoveStart",move:"onMove",moveend:"onMoveEnd",dragstart:"onDragStart",drag:"onDrag",dragend:"onDragEnd",zoomstart:"onZoomStart",zoom:"onZoom",zoomend:"onZoomEnd",rotatestart:"onRotateStart",rotate:"onRotate",rotateend:"onRotateEnd",pitchstart:"onPitchStart",pitch:"onPitch",pitchend:"onPitchEnd"},D={wheel:"onWheel",boxzoomstart:"onBoxZoomStart",boxzoomend:"onBoxZoomEnd",boxzoomcancel:"onBoxZoomCancel",resize:"onResize",load:"onLoad",render:"onRender",idle:"onIdle",remove:"onRemove",data:"onData",styledata:"onStyleData",sourcedata:"onSourceData",error:"onError"},X=["minZoom","maxZoom","minPitch","maxPitch","maxBounds","projection","renderWorldCopies"],Q=["scrollZoom","boxZoom","dragRotate","dragPan","keyboard","doubleClickZoom","touchZoomRotate","touchPitch"];class b{constructor(t,n,s){this._map=null,this._internalUpdate=!1,this._hoveredFeatures=null,this._propsedCameraUpdate=null,this._styleComponents={},this._onEvent=o=>{const r=this.props[D[o.type]];r?r(o):o.type==="error"&&console.error(o.error)},this._onCameraEvent=o=>{if(this._internalUpdate)return;o.viewState=this._propsedCameraUpdate||P(this._map.transform);const r=this.props[F[o.type]];r&&r(o)},this._onCameraUpdate=o=>this._internalUpdate?o:(this._propsedCameraUpdate=P(o),z(o,this.props)),this._onPointerEvent=o=>{(o.type==="mousemove"||o.type==="mouseout")&&this._updateHover(o);const r=this.props[U[o.type]];r&&(this.props.interactiveLayerIds&&o.type!=="mouseover"&&o.type!=="mouseout"&&(o.features=this._hoveredFeatures||this._queryRenderedFeatures(o.point)),r(o),delete o.features)},this._MapClass=t,this.props=n,this._initialize(s)}get map(){return this._map}setProps(t){const n=this.props;this.props=t;const s=this._updateSettings(t,n),o=this._updateSize(t),r=this._updateViewState(t);this._updateStyle(t,n),this._updateStyleComponents(t),this._updateHandlers(t,n),(s||o||r&&!this._map.isMoving())&&this.redraw()}static reuse(t,n){const s=b.savedMaps.pop();if(!s)return null;const o=s.map,r=o.getContainer();for(n.className=r.className;r.childNodes.length>0;)n.appendChild(r.childNodes[0]);o._container=n;const a=o._resizeObserver;a&&(a.disconnect(),a.observe(n)),s.setProps({...t,styleDiffing:!1}),o.resize();const{initialViewState:c}=t;return c&&(c.bounds?o.fitBounds(c.bounds,{...c.fitBoundsOptions,duration:0}):s._updateViewState(c)),o.isStyleLoaded()?o.fire("load"):o.once("style.load",()=>o.fire("load")),o._update(),s}_initialize(t){const{props:n}=this,{mapStyle:s=A}=n,o={...n,...n.initialViewState,container:t,style:O(s)},r=o.initialViewState||o.viewState||o;if(Object.assign(o,{center:[r.longitude||0,r.latitude||0],zoom:r.zoom||0,pitch:r.pitch||0,bearing:r.bearing||0}),n.gl){const c=HTMLCanvasElement.prototype.getContext;HTMLCanvasElement.prototype.getContext=()=>(HTMLCanvasElement.prototype.getContext=c,n.gl)}const a=new this._MapClass(o);r.padding&&a.setPadding(r.padding),n.cursor&&(a.getCanvas().style.cursor=n.cursor),a.transformCameraUpdate=this._onCameraUpdate,a.on("style.load",()=>{var c;this._styleComponents={light:a.getLight(),sky:a.getSky(),projection:(c=a.getProjection)==null?void 0:c.call(a),terrain:a.getTerrain()},this._updateStyleComponents(this.props)}),a.on("sourcedata",()=>{this._updateStyleComponents(this.props)});for(const c in U)a.on(c,this._onPointerEvent);for(const c in F)a.on(c,this._onCameraEvent);for(const c in D)a.on(c,this._onEvent);this._map=a}recycle(){const n=this.map.getContainer().querySelector("[mapboxgl-children]");n==null||n.remove(),b.savedMaps.push(this)}destroy(){this._map.remove()}redraw(){const t=this._map;t.style&&(t._frame&&(t._frame.cancel(),t._frame=null),t._render())}_updateSize(t){const{viewState:n}=t;if(n){const s=this._map;if(n.width!==s.transform.width||n.height!==s.transform.height)return s.resize(),!0}return!1}_updateViewState(t){const n=this._map,s=n.transform;if(!n.isMoving()){const r=z(s,t);if(Object.keys(r).length>0)return this._internalUpdate=!0,n.jumpTo(r),this._internalUpdate=!1,!0}return!1}_updateSettings(t,n){const s=this._map;let o=!1;for(const r of X)if(r in t&&!v(t[r],n[r])){o=!0;const a=s[`set${r[0].toUpperCase()}${r.slice(1)}`];a==null||a.call(s,t[r])}return o}_updateStyle(t,n){if(t.cursor!==n.cursor&&(this._map.getCanvas().style.cursor=t.cursor||""),t.mapStyle!==n.mapStyle){const{mapStyle:s=A,styleDiffing:o=!0}=t,r={diff:o};"localIdeographFontFamily"in t&&(r.localIdeographFontFamily=t.localIdeographFontFamily),this._map.setStyle(O(s),r)}}_updateStyleComponents({light:t,projection:n,sky:s,terrain:o}){var c,u;const r=this._map,a=this._styleComponents;r.style._loaded&&(t&&!v(t,a.light)&&(a.light=t,r.setLight(t)),n&&!v(n,a.projection)&&n!==((c=a.projection)==null?void 0:c.type)&&(a.projection=typeof n=="string"?{type:n}:n,(u=r.setProjection)==null||u.call(r,a.projection)),s&&!v(s,a.sky)&&(a.sky=s,r.setSky(s)),o!==void 0&&!v(o,a.terrain)&&(!o||r.getSource(o.source))&&(a.terrain=o,r.setTerrain(o)))}_updateHandlers(t,n){const s=this._map;for(const o of Q){const r=t[o]??!0,a=n[o]??!0;v(r,a)||(r?s[o].enable(r):s[o].disable())}}_queryRenderedFeatures(t){const n=this._map,{interactiveLayerIds:s=[]}=this.props;try{return n.queryRenderedFeatures(t,{layers:s.filter(n.getLayer.bind(n))})}catch{return[]}}_updateHover(t){var o;const{props:n}=this;if(n.interactiveLayerIds&&(n.onMouseMove||n.onMouseEnter||n.onMouseLeave)){const r=t.type,a=((o=this._hoveredFeatures)==null?void 0:o.length)>0,c=this._queryRenderedFeatures(t.point),u=c.length>0;!u&&a&&(t.type="mouseleave",this._onPointerEvent(t)),this._hoveredFeatures=c,u&&!a&&(t.type="mouseenter",this._onPointerEvent(t)),t.type=r}else this._hoveredFeatures=null}}b.savedMaps=[];const ee=["setMaxBounds","setMinZoom","setMaxZoom","setMinPitch","setMaxPitch","setRenderWorldCopies","setProjection","setStyle","addSource","removeSource","addLayer","removeLayer","setLayerZoomRange","setFilter","setPaintProperty","setLayoutProperty","setLight","setTerrain","setFog","remove"];function te(e){if(!e)return null;const t=e.map,n={getMap:()=>t};for(const s of ne(t))!(s in n)&&!ee.includes(s)&&(n[s]=t[s].bind(t));return n}function ne(e){const t=new Set;let n=e;for(;n;){for(const s of Object.getOwnPropertyNames(n))s[0]!=="_"&&typeof e[s]=="function"&&s!=="fire"&&s!=="setEventedParent"&&t.add(s);n=Object.getPrototypeOf(n)}return Array.from(t)}const oe=typeof document<"u"?i.useLayoutEffect:i.useEffect;function re(e,t){const{RTLTextPlugin:n,maxParallelImageRequests:s,workerCount:o,workerUrl:r}=t;if(n&&e.getRTLTextPluginStatus&&e.getRTLTextPluginStatus()==="unavailable"){const{pluginUrl:a,lazy:c=!0}=typeof n=="string"?{pluginUrl:n}:n;e.setRTLTextPlugin(a,u=>{u&&console.error(u)},c)}s!==void 0&&e.setMaxParallelImageRequests(s),o!==void 0&&e.setWorkerCount(o),r!==void 0&&e.setWorkerUrl(r)}const w=i.createContext(null);function se(e,t){const n=i.useContext(H),[s,o]=i.useState(null),r=i.useRef(),{current:a}=i.useRef({mapLib:null,map:null});i.useEffect(()=>{const l=e.mapLib;let d=!0,f;return Promise.resolve(l||$(()=>import("./maplibre-gl-CVNCKFEA.js").then(m=>m.m),__vite__mapDeps([0,1]))).then(m=>{if(!d)return;if(!m)throw new Error("Invalid mapLib");const y="Map"in m?m:m.default;if(!y.Map)throw new Error("Invalid mapLib");re(y,e),e.reuseMaps&&(f=b.reuse(e,r.current)),f||(f=new b(y.Map,e,r.current)),a.map=te(f),a.mapLib=y,o(f),n==null||n.onMapMount(a.map,e.id)}).catch(m=>{const{onError:y}=e;y?y({type:"error",target:null,originalEvent:null,error:m}):console.error(m)}),()=>{d=!1,f&&(n==null||n.onMapUnmount(e.id),e.reuseMaps?f.recycle():f.destroy())}},[]),oe(()=>{s&&s.setProps(e)}),i.useImperativeHandle(t,()=>a.map,[s]);const c=i.useMemo(()=>({position:"relative",width:"100%",height:"100%",...e.style}),[e.style]),u={height:"100%"};return i.createElement("div",{id:e.id,ref:r,style:c},s&&i.createElement(w.Provider,{value:a},i.createElement("div",{"mapboxgl-children":"",style:u},e.children)))}const Me=i.forwardRef(se),ae=/box|flex|grid|column|lineHeight|fontWeight|opacity|order|tabSize|zIndex/;function L(e,t){if(!e||!t)return;const n=e.style;for(const s in t){const o=t[s];Number.isFinite(o)&&!ae.test(s)?n[s]=`${o}px`:n[s]=o}}function Z(e,t){if(e===t)return null;const n=N(e),s=N(t),o=[];for(const r of s)n.has(r)||o.push(r);for(const r of n)s.has(r)||o.push(r);return o.length===0?null:o}function N(e){return new Set(e?e.trim().split(/\s+/):[])}const be=i.memo(i.forwardRef((e,t)=>{const{map:n,mapLib:s}=i.useContext(w),o=i.useRef({props:e}),r=i.useMemo(()=>{let E=!1;i.Children.forEach(e.children,h=>{h&&(E=!0)});const k={...e,element:E?document.createElement("div"):void 0},p=new s.Marker(k);return p.setLngLat([e.longitude,e.latitude]),p.getElement().addEventListener("click",h=>{var g,_;(_=(g=o.current.props).onClick)==null||_.call(g,{type:"click",target:p,originalEvent:h})}),p.on("dragstart",h=>{var _,S;const g=h;g.lngLat=r.getLngLat(),(S=(_=o.current.props).onDragStart)==null||S.call(_,g)}),p.on("drag",h=>{var _,S;const g=h;g.lngLat=r.getLngLat(),(S=(_=o.current.props).onDrag)==null||S.call(_,g)}),p.on("dragend",h=>{var _,S;const g=h;g.lngLat=r.getLngLat(),(S=(_=o.current.props).onDragEnd)==null||S.call(_,g)}),p},[]);i.useEffect(()=>(r.addTo(n.getMap()),()=>{r.remove()}),[]);const{longitude:a,latitude:c,offset:u,style:l,draggable:d=!1,popup:f=null,rotation:m=0,rotationAlignment:y="auto",pitchAlignment:C="auto"}=e;i.useEffect(()=>{L(r.getElement(),l)},[l]),i.useImperativeHandle(t,()=>r,[]);const T=o.current.props;(r.getLngLat().lng!==a||r.getLngLat().lat!==c)&&r.setLngLat([a,c]),u&&!Y(r.getOffset(),u)&&r.setOffset(u),r.isDraggable()!==d&&r.setDraggable(d),r.getRotation()!==m&&r.setRotation(m),r.getRotationAlignment()!==y&&r.setRotationAlignment(y),r.getPitchAlignment()!==C&&r.setPitchAlignment(C),r.getPopup()!==f&&r.setPopup(f);const x=Z(T.className,e.className);if(x)for(const E of x)r.toggleClassName(E);return o.current.props=e,B.createPortal(e.children,r.getElement())})),xe=i.memo(i.forwardRef((e,t)=>{const{map:n,mapLib:s}=i.useContext(w),o=i.useMemo(()=>document.createElement("div"),[]),r=i.useRef({props:e}),a=i.useMemo(()=>{const c={...e},u=new s.Popup(c);return u.setLngLat([e.longitude,e.latitude]),u.once("open",l=>{var d,f;(f=(d=r.current.props).onOpen)==null||f.call(d,l)}),u},[]);if(i.useEffect(()=>{const c=u=>{var l,d;(d=(l=r.current.props).onClose)==null||d.call(l,u)};return a.on("close",c),a.setDOMContent(o).addTo(n.getMap()),()=>{a.off("close",c),a.isOpen()&&a.remove()}},[]),i.useEffect(()=>{L(a.getElement(),e.style)},[e.style]),i.useImperativeHandle(t,()=>a,[]),a.isOpen()){const c=r.current.props;(a.getLngLat().lng!==e.longitude||a.getLngLat().lat!==e.latitude)&&a.setLngLat([e.longitude,e.latitude]),e.offset&&!v(c.offset,e.offset)&&a.setOffset(e.offset),(c.anchor!==e.anchor||c.maxWidth!==e.maxWidth)&&(a.options.anchor=e.anchor,a.setMaxWidth(e.maxWidth));const u=Z(c.className,e.className);if(u)for(const l of u)a.toggleClassName(l);r.current.props=e}return B.createPortal(e.children,o)}));function M(e,t,n,s){const o=i.useContext(w),r=i.useMemo(()=>e(o),[]);return i.useEffect(()=>{const a=t,c=null,u=typeof t=="function"?t:null,{map:l}=o;return l.hasControl(r)||(l.addControl(r,a==null?void 0:a.position),c&&c(o)),()=>{u&&u(o),l.hasControl(r)&&l.removeControl(r)}},[]),r}function ie(e){const t=M(({mapLib:n})=>new n.AttributionControl(e),{position:e.position});return i.useEffect(()=>{L(t._container,e.style)},[e.style]),null}i.memo(ie);function ce(e){const t=M(({mapLib:n})=>new n.FullscreenControl({container:e.containerId&&document.getElementById(e.containerId)}),{position:e.position});return i.useEffect(()=>{L(t._controlContainer,e.style)},[e.style]),null}i.memo(ce);function le(e,t){const n=i.useRef({props:e}),s=M(({mapLib:o})=>{const r=new o.GeolocateControl(e),a=r._setupUI;return r._setupUI=()=>{r._container.hasChildNodes()||a()},r.on("geolocate",c=>{var u,l;(l=(u=n.current.props).onGeolocate)==null||l.call(u,c)}),r.on("error",c=>{var u,l;(l=(u=n.current.props).onError)==null||l.call(u,c)}),r.on("outofmaxbounds",c=>{var u,l;(l=(u=n.current.props).onOutOfMaxBounds)==null||l.call(u,c)}),r.on("trackuserlocationstart",c=>{var u,l;(l=(u=n.current.props).onTrackUserLocationStart)==null||l.call(u,c)}),r.on("trackuserlocationend",c=>{var u,l;(l=(u=n.current.props).onTrackUserLocationEnd)==null||l.call(u,c)}),r},{position:e.position});return n.current.props=e,i.useImperativeHandle(t,()=>s,[]),i.useEffect(()=>{L(s._container,e.style)},[e.style]),null}i.memo(i.forwardRef(le));function ue(e){const t=M(({mapLib:n})=>new n.NavigationControl(e),{position:e.position});return i.useEffect(()=>{L(t._container,e.style)},[e.style]),null}i.memo(ue);function fe(e){const t=M(({mapLib:r})=>new r.ScaleControl(e),{position:e.position}),n=i.useRef(e),s=n.current;n.current=e;const{style:o}=e;return e.maxWidth!==void 0&&e.maxWidth!==s.maxWidth&&(t.options.maxWidth=e.maxWidth),e.unit!==void 0&&e.unit!==s.unit&&t.setUnit(e.unit),i.useEffect(()=>{L(t._container,o)},[o]),null}const ke=i.memo(fe);function de(e){const t=M(({mapLib:n})=>new n.TerrainControl(e),{position:e.position});return i.useEffect(()=>{L(t._container,e.style)},[e.style]),null}i.memo(de);function me(e){const t=M(({mapLib:n})=>new n.LogoControl(e),{position:e.position});return i.useEffect(()=>{L(t._container,e.style)},[e.style]),null}i.memo(me);function R(e,t){if(!e)throw new Error(t)}let ye=0;function ge(e,t,n){if(e.style&&e.style._loaded){const s={...n};return delete s.id,delete s.children,e.addSource(t,s),e.getSource(t)}return null}function he(e,t,n){var a,c,u;R(t.id===n.id,"source id changed"),R(t.type===n.type,"source type changed");let s="",o=0;for(const l in t)l!=="children"&&l!=="id"&&!v(n[l],t[l])&&(s=l,o++);if(!o)return;const r=t.type;if(r==="geojson")e.setData(t.data);else if(r==="image")e.updateImage({url:t.url,coordinates:t.coordinates});else switch(s){case"coordinates":(a=e.setCoordinates)==null||a.call(e,t.coordinates);break;case"url":(c=e.setUrl)==null||c.call(e,t.url);break;case"tiles":(u=e.setTiles)==null||u.call(e,t.tiles);break;default:console.warn(`Unable to update prop: ${s}`)}}function Re(e){const t=i.useContext(w).map.getMap(),n=i.useRef(e),[,s]=i.useState(0),o=i.useMemo(()=>e.id||`jsx-source-${ye++}`,[]);i.useEffect(()=>{if(t){const a=()=>setTimeout(()=>s(c=>c+1),0);return t.on("styledata",a),a(),()=>{var c;if(t.off("styledata",a),t.style&&t.style._loaded&&t.getSource(o)){const u=(c=t.getStyle())==null?void 0:c.layers;if(u)for(const l of u)l.source===o&&t.removeLayer(l.id);t.removeSource(o)}}}},[t]);let r=t&&t.style&&t.getSource(o);return r?he(r,e,n.current):r=ge(t,o,e),n.current=e,r&&i.Children.map(e.children,a=>a&&i.cloneElement(a,{source:o}))||null}function pe(e,t,n,s){if(R(n.id===s.id,"layer id changed"),R(n.type===s.type,"layer type changed"),n.type==="custom"||s.type==="custom")return;const{layout:o={},paint:r={},filter:a,minzoom:c,maxzoom:u,beforeId:l}=n;if(l!==s.beforeId&&e.moveLayer(t,l),o!==s.layout){const d=s.layout||{};for(const f in o)v(o[f],d[f])||e.setLayoutProperty(t,f,o[f]);for(const f in d)o.hasOwnProperty(f)||e.setLayoutProperty(t,f,void 0)}if(r!==s.paint){const d=s.paint||{};for(const f in r)v(r[f],d[f])||e.setPaintProperty(t,f,r[f]);for(const f in d)r.hasOwnProperty(f)||e.setPaintProperty(t,f,void 0)}v(a,s.filter)||e.setFilter(t,a),(c!==s.minzoom||u!==s.maxzoom)&&e.setLayerZoomRange(t,c,u)}function ve(e,t,n){if(e.style&&e.style._loaded&&(!("source"in n)||e.getSource(n.source))){const s={...n,id:t};delete s.beforeId,e.addLayer(s,n.beforeId)}}let _e=0;function Ie(e){const t=i.useContext(w).map.getMap(),n=i.useRef(e),[,s]=i.useState(0),o=i.useMemo(()=>e.id||`jsx-layer-${_e++}`,[]);if(i.useEffect(()=>{if(t){const a=()=>s(c=>c+1);return t.on("styledata",a),a(),()=>{t.off("styledata",a),t.style&&t.style._loaded&&t.getLayer(o)&&t.removeLayer(o)}}},[t]),t&&t.style&&t.getLayer(o))try{pe(t,o,e,n.current)}catch(a){console.warn(a)}else ve(t,o,e);return n.current=e,null}const V="pymc-basemap-mode",j="dark";function Le(){if(typeof window>"u")return j;try{const e=localStorage.getItem(V);if(e==="light"||e==="dark")return e}catch{}return j}function W(e){if(!(typeof window>"u"))try{localStorage.setItem(V,e)}catch{}}const q=G(e=>({mode:Le(),toggle:()=>e(t=>{const n=t.mode==="light"?"dark":"light";return W(n),{mode:n}}),setMode:t=>{W(t),e({mode:t})}})),Te=()=>q(e=>e.mode),Pe=()=>q(e=>e.toggle),Ce={light:"https://basemaps.cartocdn.com/gl/positron-gl-style/style.json",dark:"https://basemaps.cartocdn.com/gl/dark-matter-gl-style/style.json"},Se={light:"basemap-light-",dark:"basemap-dark-"},I={};async function Ee(e){if(I[e])return I[e];const n=await(await fetch(Ce[e])).json();return I[e]=n,n}function ze({mode:e}){const{current:t}=K(),[n,s]=i.useState(null),o=i.useRef({light:!1,dark:!1}),r=i.useRef({light:[],dark:[]});i.useEffect(()=>{const l=()=>{var y;const m=(y=t==null?void 0:t.getMap)==null?void 0:y.call(t);m&&!n&&s(m)};l();const d=setInterval(l,50),f=setTimeout(()=>clearInterval(d),5e3);return()=>{clearInterval(d),clearTimeout(f)}},[t,n]);const a=i.useCallback(async(l,d,f)=>{var E,k;if(o.current[d])return;const m=Se[d],y=await Ee(d),C=[];for(const[p,h]of Object.entries(y.sources||{})){const g=m+p;l.getSource(g)||l.addSource(g,h)}const x=(k=(((E=l.getStyle())==null?void 0:E.layers)||[]).find(p=>!p.id.startsWith("basemap-light-")&&!p.id.startsWith("basemap-dark-")))==null?void 0:k.id;for(const p of y.layers||[]){const h=m+p.id;if(C.push(h),l.getLayer(h))continue;const g={...p,id:h};"source"in g&&typeof g.source=="string"&&(g.source=m+g.source),g.layout||(g.layout={}),g.layout.visibility=f?"visible":"none";try{l.addLayer(g,x)}catch(_){console.warn(`[BasemapLayer] Failed to add layer ${h}:`,_)}}r.current[d]=C,o.current[d]=!0},[]),c=i.useCallback((l,d,f)=>{const m=r.current[d],y=f?"visible":"none";for(const C of m)if(l.getLayer(C))try{l.setLayoutProperty(C,"visibility",y)}catch{}},[]),u=i.useCallback(l=>{var m;const f=(((m=l.getStyle())==null?void 0:m.layers)||[]).filter(y=>!y.id.startsWith("basemap-light-")&&!y.id.startsWith("basemap-dark-"));for(const y of f)try{l.moveLayer(y.id)}catch{}},[]);return i.useEffect(()=>{if(!n)return;const l=d=>{n.hasImage(d.id)||n.addImage(d.id,{width:1,height:1,data:new Uint8Array([0,0,0,0])})};return n.on("styleimagemissing",l),()=>{n.off("styleimagemissing",l)}},[n]),i.useEffect(()=>{if(!n)return;let l=!1;const d=async()=>{if(!l)try{await Promise.all([a(n,"light",e==="light"),a(n,"dark",e==="dark")]),l||u(n)}catch(m){console.error("[BasemapLayer] Setup error:",m)}};n.isStyleLoaded()?d():(n.once("style.load",d),n.once("load",()=>{!l&&!o.current.light&&d()}));const f=()=>{l||setTimeout(()=>{!l&&o.current.light&&o.current.dark&&u(n)},100)};return n.on("styledata",f),()=>{l=!0,n.off("styledata",f)}},[n,a,u,e]),i.useEffect(()=>{n&&(!o.current.light||!o.current.dark||(c(n,"light",e==="light"),c(n,"dark",e==="dark")))},[n,e,c]),null}export{ze as B,Ie as L,Me as M,xe as P,Re as S,be as a,K as b,Pe as c,ke as d,Te as u}; diff --git a/frontend/dist/assets/BasemapLayer-CfNeG6Jg.js b/frontend/dist/assets/BasemapLayer-CfNeG6Jg.js new file mode 100644 index 00000000..ddcc4d6b --- /dev/null +++ b/frontend/dist/assets/BasemapLayer-CfNeG6Jg.js @@ -0,0 +1,2 @@ +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-DhkG1Nx9.js","assets/index-DySMpv2s.css"])))=>i.map(i=>d[i]); +import{r as i,_ as $,aG as B,e as G}from"./index-DhkG1Nx9.js";const H=i.createContext(null);function K(){var s;const e=(s=i.useContext(H))==null?void 0:s.maps,t=i.useContext(w);return i.useMemo(()=>({...e,current:t==null?void 0:t.map}),[e,t])}function Y(e,t){const n=Array.isArray(e)?e[0]:e?e.x:0,s=Array.isArray(e)?e[1]:e?e.y:0,o=Array.isArray(t)?t[0]:t?t.x:0,r=Array.isArray(t)?t[1]:t?t.y:0;return n===o&&s===r}function v(e,t){if(e===t)return!0;if(!e||!t)return!1;if(Array.isArray(e)){if(!Array.isArray(t)||e.length!==t.length)return!1;for(let n=0;n{let o=null;"interactive"in s&&(o=Object.assign({},s),delete o.interactive);const r=t[s.ref];if(r){o=o||Object.assign({},s),delete o.ref;for(const a of J)a in r&&(o[a]=r[a])}return o||s});return{...e,layers:n}}const A={version:8,sources:{},layers:[]},U={mousedown:"onMouseDown",mouseup:"onMouseUp",mouseover:"onMouseOver",mousemove:"onMouseMove",click:"onClick",dblclick:"onDblClick",mouseenter:"onMouseEnter",mouseleave:"onMouseLeave",mouseout:"onMouseOut",contextmenu:"onContextMenu",touchstart:"onTouchStart",touchend:"onTouchEnd",touchmove:"onTouchMove",touchcancel:"onTouchCancel"},F={movestart:"onMoveStart",move:"onMove",moveend:"onMoveEnd",dragstart:"onDragStart",drag:"onDrag",dragend:"onDragEnd",zoomstart:"onZoomStart",zoom:"onZoom",zoomend:"onZoomEnd",rotatestart:"onRotateStart",rotate:"onRotate",rotateend:"onRotateEnd",pitchstart:"onPitchStart",pitch:"onPitch",pitchend:"onPitchEnd"},N={wheel:"onWheel",boxzoomstart:"onBoxZoomStart",boxzoomend:"onBoxZoomEnd",boxzoomcancel:"onBoxZoomCancel",resize:"onResize",load:"onLoad",render:"onRender",idle:"onIdle",remove:"onRemove",data:"onData",styledata:"onStyleData",sourcedata:"onSourceData",error:"onError"},X=["minZoom","maxZoom","minPitch","maxPitch","maxBounds","projection","renderWorldCopies"],Q=["scrollZoom","boxZoom","dragRotate","dragPan","keyboard","doubleClickZoom","touchZoomRotate","touchPitch"];class b{constructor(t,n,s){this._map=null,this._internalUpdate=!1,this._hoveredFeatures=null,this._propsedCameraUpdate=null,this._styleComponents={},this._onEvent=o=>{const r=this.props[N[o.type]];r?r(o):o.type==="error"&&console.error(o.error)},this._onCameraEvent=o=>{if(this._internalUpdate)return;o.viewState=this._propsedCameraUpdate||P(this._map.transform);const r=this.props[F[o.type]];r&&r(o)},this._onCameraUpdate=o=>this._internalUpdate?o:(this._propsedCameraUpdate=P(o),z(o,this.props)),this._onPointerEvent=o=>{(o.type==="mousemove"||o.type==="mouseout")&&this._updateHover(o);const r=this.props[U[o.type]];r&&(this.props.interactiveLayerIds&&o.type!=="mouseover"&&o.type!=="mouseout"&&(o.features=this._hoveredFeatures||this._queryRenderedFeatures(o.point)),r(o),delete o.features)},this._MapClass=t,this.props=n,this._initialize(s)}get map(){return this._map}setProps(t){const n=this.props;this.props=t;const s=this._updateSettings(t,n),o=this._updateSize(t),r=this._updateViewState(t);this._updateStyle(t,n),this._updateStyleComponents(t),this._updateHandlers(t,n),(s||o||r&&!this._map.isMoving())&&this.redraw()}static reuse(t,n){const s=b.savedMaps.pop();if(!s)return null;const o=s.map,r=o.getContainer();for(n.className=r.className;r.childNodes.length>0;)n.appendChild(r.childNodes[0]);o._container=n;const a=o._resizeObserver;a&&(a.disconnect(),a.observe(n)),s.setProps({...t,styleDiffing:!1}),o.resize();const{initialViewState:c}=t;return c&&(c.bounds?o.fitBounds(c.bounds,{...c.fitBoundsOptions,duration:0}):s._updateViewState(c)),o.isStyleLoaded()?o.fire("load"):o.once("style.load",()=>o.fire("load")),o._update(),s}_initialize(t){const{props:n}=this,{mapStyle:s=A}=n,o={...n,...n.initialViewState,container:t,style:O(s)},r=o.initialViewState||o.viewState||o;if(Object.assign(o,{center:[r.longitude||0,r.latitude||0],zoom:r.zoom||0,pitch:r.pitch||0,bearing:r.bearing||0}),n.gl){const c=HTMLCanvasElement.prototype.getContext;HTMLCanvasElement.prototype.getContext=()=>(HTMLCanvasElement.prototype.getContext=c,n.gl)}const a=new this._MapClass(o);r.padding&&a.setPadding(r.padding),n.cursor&&(a.getCanvas().style.cursor=n.cursor),a.transformCameraUpdate=this._onCameraUpdate,a.on("style.load",()=>{var c;this._styleComponents={light:a.getLight(),sky:a.getSky(),projection:(c=a.getProjection)==null?void 0:c.call(a),terrain:a.getTerrain()},this._updateStyleComponents(this.props)}),a.on("sourcedata",()=>{this._updateStyleComponents(this.props)});for(const c in U)a.on(c,this._onPointerEvent);for(const c in F)a.on(c,this._onCameraEvent);for(const c in N)a.on(c,this._onEvent);this._map=a}recycle(){const n=this.map.getContainer().querySelector("[mapboxgl-children]");n==null||n.remove(),b.savedMaps.push(this)}destroy(){this._map.remove()}redraw(){const t=this._map;t.style&&(t._frame&&(t._frame.cancel(),t._frame=null),t._render())}_updateSize(t){const{viewState:n}=t;if(n){const s=this._map;if(n.width!==s.transform.width||n.height!==s.transform.height)return s.resize(),!0}return!1}_updateViewState(t){const n=this._map,s=n.transform;if(!n.isMoving()){const r=z(s,t);if(Object.keys(r).length>0)return this._internalUpdate=!0,n.jumpTo(r),this._internalUpdate=!1,!0}return!1}_updateSettings(t,n){const s=this._map;let o=!1;for(const r of X)if(r in t&&!v(t[r],n[r])){o=!0;const a=s[`set${r[0].toUpperCase()}${r.slice(1)}`];a==null||a.call(s,t[r])}return o}_updateStyle(t,n){if(t.cursor!==n.cursor&&(this._map.getCanvas().style.cursor=t.cursor||""),t.mapStyle!==n.mapStyle){const{mapStyle:s=A,styleDiffing:o=!0}=t,r={diff:o};"localIdeographFontFamily"in t&&(r.localIdeographFontFamily=t.localIdeographFontFamily),this._map.setStyle(O(s),r)}}_updateStyleComponents({light:t,projection:n,sky:s,terrain:o}){var c,u;const r=this._map,a=this._styleComponents;r.style._loaded&&(t&&!v(t,a.light)&&(a.light=t,r.setLight(t)),n&&!v(n,a.projection)&&n!==((c=a.projection)==null?void 0:c.type)&&(a.projection=typeof n=="string"?{type:n}:n,(u=r.setProjection)==null||u.call(r,a.projection)),s&&!v(s,a.sky)&&(a.sky=s,r.setSky(s)),o!==void 0&&!v(o,a.terrain)&&(!o||r.getSource(o.source))&&(a.terrain=o,r.setTerrain(o)))}_updateHandlers(t,n){const s=this._map;for(const o of Q){const r=t[o]??!0,a=n[o]??!0;v(r,a)||(r?s[o].enable(r):s[o].disable())}}_queryRenderedFeatures(t){const n=this._map,{interactiveLayerIds:s=[]}=this.props;try{return n.queryRenderedFeatures(t,{layers:s.filter(n.getLayer.bind(n))})}catch{return[]}}_updateHover(t){var o;const{props:n}=this;if(n.interactiveLayerIds&&(n.onMouseMove||n.onMouseEnter||n.onMouseLeave)){const r=t.type,a=((o=this._hoveredFeatures)==null?void 0:o.length)>0,c=this._queryRenderedFeatures(t.point),u=c.length>0;!u&&a&&(t.type="mouseleave",this._onPointerEvent(t)),this._hoveredFeatures=c,u&&!a&&(t.type="mouseenter",this._onPointerEvent(t)),t.type=r}else this._hoveredFeatures=null}}b.savedMaps=[];const ee=["setMaxBounds","setMinZoom","setMaxZoom","setMinPitch","setMaxPitch","setRenderWorldCopies","setProjection","setStyle","addSource","removeSource","addLayer","removeLayer","setLayerZoomRange","setFilter","setPaintProperty","setLayoutProperty","setLight","setTerrain","setFog","remove"];function te(e){if(!e)return null;const t=e.map,n={getMap:()=>t};for(const s of ne(t))!(s in n)&&!ee.includes(s)&&(n[s]=t[s].bind(t));return n}function ne(e){const t=new Set;let n=e;for(;n;){for(const s of Object.getOwnPropertyNames(n))s[0]!=="_"&&typeof e[s]=="function"&&s!=="fire"&&s!=="setEventedParent"&&t.add(s);n=Object.getPrototypeOf(n)}return Array.from(t)}const oe=typeof document<"u"?i.useLayoutEffect:i.useEffect;function re(e,t){const{RTLTextPlugin:n,maxParallelImageRequests:s,workerCount:o,workerUrl:r}=t;if(n&&e.getRTLTextPluginStatus&&e.getRTLTextPluginStatus()==="unavailable"){const{pluginUrl:a,lazy:c=!0}=typeof n=="string"?{pluginUrl:n}:n;e.setRTLTextPlugin(a,u=>{u&&console.error(u)},c)}s!==void 0&&e.setMaxParallelImageRequests(s),o!==void 0&&e.setWorkerCount(o),r!==void 0&&e.setWorkerUrl(r)}const w=i.createContext(null);function se(e,t){const n=i.useContext(H),[s,o]=i.useState(null),r=i.useRef(),{current:a}=i.useRef({mapLib:null,map:null});i.useEffect(()=>{const l=e.mapLib;let d=!0,f;return Promise.resolve(l||$(()=>import("./maplibre-gl-ytugn6B7.js").then(m=>m.m),__vite__mapDeps([0,1]))).then(m=>{if(!d)return;if(!m)throw new Error("Invalid mapLib");const y="Map"in m?m:m.default;if(!y.Map)throw new Error("Invalid mapLib");re(y,e),e.reuseMaps&&(f=b.reuse(e,r.current)),f||(f=new b(y.Map,e,r.current)),a.map=te(f),a.mapLib=y,o(f),n==null||n.onMapMount(a.map,e.id)}).catch(m=>{const{onError:y}=e;y?y({type:"error",target:null,originalEvent:null,error:m}):console.error(m)}),()=>{d=!1,f&&(n==null||n.onMapUnmount(e.id),e.reuseMaps?f.recycle():f.destroy())}},[]),oe(()=>{s&&s.setProps(e)}),i.useImperativeHandle(t,()=>a.map,[s]);const c=i.useMemo(()=>({position:"relative",width:"100%",height:"100%",...e.style}),[e.style]),u={height:"100%"};return i.createElement("div",{id:e.id,ref:r,style:c},s&&i.createElement(w.Provider,{value:a},i.createElement("div",{"mapboxgl-children":"",style:u},e.children)))}const Me=i.forwardRef(se),ae=/box|flex|grid|column|lineHeight|fontWeight|opacity|order|tabSize|zIndex/;function L(e,t){if(!e||!t)return;const n=e.style;for(const s in t){const o=t[s];Number.isFinite(o)&&!ae.test(s)?n[s]=`${o}px`:n[s]=o}}function Z(e,t){if(e===t)return null;const n=D(e),s=D(t),o=[];for(const r of s)n.has(r)||o.push(r);for(const r of n)s.has(r)||o.push(r);return o.length===0?null:o}function D(e){return new Set(e?e.trim().split(/\s+/):[])}const be=i.memo(i.forwardRef((e,t)=>{const{map:n,mapLib:s}=i.useContext(w),o=i.useRef({props:e}),r=i.useMemo(()=>{let E=!1;i.Children.forEach(e.children,h=>{h&&(E=!0)});const k={...e,element:E?document.createElement("div"):void 0},p=new s.Marker(k);return p.setLngLat([e.longitude,e.latitude]),p.getElement().addEventListener("click",h=>{var g,_;(_=(g=o.current.props).onClick)==null||_.call(g,{type:"click",target:p,originalEvent:h})}),p.on("dragstart",h=>{var _,S;const g=h;g.lngLat=r.getLngLat(),(S=(_=o.current.props).onDragStart)==null||S.call(_,g)}),p.on("drag",h=>{var _,S;const g=h;g.lngLat=r.getLngLat(),(S=(_=o.current.props).onDrag)==null||S.call(_,g)}),p.on("dragend",h=>{var _,S;const g=h;g.lngLat=r.getLngLat(),(S=(_=o.current.props).onDragEnd)==null||S.call(_,g)}),p},[]);i.useEffect(()=>(r.addTo(n.getMap()),()=>{r.remove()}),[]);const{longitude:a,latitude:c,offset:u,style:l,draggable:d=!1,popup:f=null,rotation:m=0,rotationAlignment:y="auto",pitchAlignment:C="auto"}=e;i.useEffect(()=>{L(r.getElement(),l)},[l]),i.useImperativeHandle(t,()=>r,[]);const T=o.current.props;(r.getLngLat().lng!==a||r.getLngLat().lat!==c)&&r.setLngLat([a,c]),u&&!Y(r.getOffset(),u)&&r.setOffset(u),r.isDraggable()!==d&&r.setDraggable(d),r.getRotation()!==m&&r.setRotation(m),r.getRotationAlignment()!==y&&r.setRotationAlignment(y),r.getPitchAlignment()!==C&&r.setPitchAlignment(C),r.getPopup()!==f&&r.setPopup(f);const x=Z(T.className,e.className);if(x)for(const E of x)r.toggleClassName(E);return o.current.props=e,B.createPortal(e.children,r.getElement())})),xe=i.memo(i.forwardRef((e,t)=>{const{map:n,mapLib:s}=i.useContext(w),o=i.useMemo(()=>document.createElement("div"),[]),r=i.useRef({props:e}),a=i.useMemo(()=>{const c={...e},u=new s.Popup(c);return u.setLngLat([e.longitude,e.latitude]),u.once("open",l=>{var d,f;(f=(d=r.current.props).onOpen)==null||f.call(d,l)}),u},[]);if(i.useEffect(()=>{const c=u=>{var l,d;(d=(l=r.current.props).onClose)==null||d.call(l,u)};return a.on("close",c),a.setDOMContent(o).addTo(n.getMap()),()=>{a.off("close",c),a.isOpen()&&a.remove()}},[]),i.useEffect(()=>{L(a.getElement(),e.style)},[e.style]),i.useImperativeHandle(t,()=>a,[]),a.isOpen()){const c=r.current.props;(a.getLngLat().lng!==e.longitude||a.getLngLat().lat!==e.latitude)&&a.setLngLat([e.longitude,e.latitude]),e.offset&&!v(c.offset,e.offset)&&a.setOffset(e.offset),(c.anchor!==e.anchor||c.maxWidth!==e.maxWidth)&&(a.options.anchor=e.anchor,a.setMaxWidth(e.maxWidth));const u=Z(c.className,e.className);if(u)for(const l of u)a.toggleClassName(l);r.current.props=e}return B.createPortal(e.children,o)}));function M(e,t,n,s){const o=i.useContext(w),r=i.useMemo(()=>e(o),[]);return i.useEffect(()=>{const a=t,c=null,u=typeof t=="function"?t:null,{map:l}=o;return l.hasControl(r)||(l.addControl(r,a==null?void 0:a.position),c&&c(o)),()=>{u&&u(o),l.hasControl(r)&&l.removeControl(r)}},[]),r}function ie(e){const t=M(({mapLib:n})=>new n.AttributionControl(e),{position:e.position});return i.useEffect(()=>{L(t._container,e.style)},[e.style]),null}i.memo(ie);function ce(e){const t=M(({mapLib:n})=>new n.FullscreenControl({container:e.containerId&&document.getElementById(e.containerId)}),{position:e.position});return i.useEffect(()=>{L(t._controlContainer,e.style)},[e.style]),null}i.memo(ce);function le(e,t){const n=i.useRef({props:e}),s=M(({mapLib:o})=>{const r=new o.GeolocateControl(e),a=r._setupUI;return r._setupUI=()=>{r._container.hasChildNodes()||a()},r.on("geolocate",c=>{var u,l;(l=(u=n.current.props).onGeolocate)==null||l.call(u,c)}),r.on("error",c=>{var u,l;(l=(u=n.current.props).onError)==null||l.call(u,c)}),r.on("outofmaxbounds",c=>{var u,l;(l=(u=n.current.props).onOutOfMaxBounds)==null||l.call(u,c)}),r.on("trackuserlocationstart",c=>{var u,l;(l=(u=n.current.props).onTrackUserLocationStart)==null||l.call(u,c)}),r.on("trackuserlocationend",c=>{var u,l;(l=(u=n.current.props).onTrackUserLocationEnd)==null||l.call(u,c)}),r},{position:e.position});return n.current.props=e,i.useImperativeHandle(t,()=>s,[]),i.useEffect(()=>{L(s._container,e.style)},[e.style]),null}i.memo(i.forwardRef(le));function ue(e){const t=M(({mapLib:n})=>new n.NavigationControl(e),{position:e.position});return i.useEffect(()=>{L(t._container,e.style)},[e.style]),null}i.memo(ue);function fe(e){const t=M(({mapLib:r})=>new r.ScaleControl(e),{position:e.position}),n=i.useRef(e),s=n.current;n.current=e;const{style:o}=e;return e.maxWidth!==void 0&&e.maxWidth!==s.maxWidth&&(t.options.maxWidth=e.maxWidth),e.unit!==void 0&&e.unit!==s.unit&&t.setUnit(e.unit),i.useEffect(()=>{L(t._container,o)},[o]),null}const ke=i.memo(fe);function de(e){const t=M(({mapLib:n})=>new n.TerrainControl(e),{position:e.position});return i.useEffect(()=>{L(t._container,e.style)},[e.style]),null}i.memo(de);function me(e){const t=M(({mapLib:n})=>new n.LogoControl(e),{position:e.position});return i.useEffect(()=>{L(t._container,e.style)},[e.style]),null}i.memo(me);function R(e,t){if(!e)throw new Error(t)}let ye=0;function ge(e,t,n){if(e.style&&e.style._loaded){const s={...n};return delete s.id,delete s.children,e.addSource(t,s),e.getSource(t)}return null}function he(e,t,n){var a,c,u;R(t.id===n.id,"source id changed"),R(t.type===n.type,"source type changed");let s="",o=0;for(const l in t)l!=="children"&&l!=="id"&&!v(n[l],t[l])&&(s=l,o++);if(!o)return;const r=t.type;if(r==="geojson")e.setData(t.data);else if(r==="image")e.updateImage({url:t.url,coordinates:t.coordinates});else switch(s){case"coordinates":(a=e.setCoordinates)==null||a.call(e,t.coordinates);break;case"url":(c=e.setUrl)==null||c.call(e,t.url);break;case"tiles":(u=e.setTiles)==null||u.call(e,t.tiles);break;default:console.warn(`Unable to update prop: ${s}`)}}function Re(e){const t=i.useContext(w).map.getMap(),n=i.useRef(e),[,s]=i.useState(0),o=i.useMemo(()=>e.id||`jsx-source-${ye++}`,[]);i.useEffect(()=>{if(t){const a=()=>setTimeout(()=>s(c=>c+1),0);return t.on("styledata",a),a(),()=>{var c;if(t.off("styledata",a),t.style&&t.style._loaded&&t.getSource(o)){const u=(c=t.getStyle())==null?void 0:c.layers;if(u)for(const l of u)l.source===o&&t.removeLayer(l.id);t.removeSource(o)}}}},[t]);let r=t&&t.style&&t.getSource(o);return r?he(r,e,n.current):r=ge(t,o,e),n.current=e,r&&i.Children.map(e.children,a=>a&&i.cloneElement(a,{source:o}))||null}function pe(e,t,n,s){if(R(n.id===s.id,"layer id changed"),R(n.type===s.type,"layer type changed"),n.type==="custom"||s.type==="custom")return;const{layout:o={},paint:r={},filter:a,minzoom:c,maxzoom:u,beforeId:l}=n;if(l!==s.beforeId&&e.moveLayer(t,l),o!==s.layout){const d=s.layout||{};for(const f in o)v(o[f],d[f])||e.setLayoutProperty(t,f,o[f]);for(const f in d)o.hasOwnProperty(f)||e.setLayoutProperty(t,f,void 0)}if(r!==s.paint){const d=s.paint||{};for(const f in r)v(r[f],d[f])||e.setPaintProperty(t,f,r[f]);for(const f in d)r.hasOwnProperty(f)||e.setPaintProperty(t,f,void 0)}v(a,s.filter)||e.setFilter(t,a),(c!==s.minzoom||u!==s.maxzoom)&&e.setLayerZoomRange(t,c,u)}function ve(e,t,n){if(e.style&&e.style._loaded&&(!("source"in n)||e.getSource(n.source))){const s={...n,id:t};delete s.beforeId,e.addLayer(s,n.beforeId)}}let _e=0;function Ie(e){const t=i.useContext(w).map.getMap(),n=i.useRef(e),[,s]=i.useState(0),o=i.useMemo(()=>e.id||`jsx-layer-${_e++}`,[]);if(i.useEffect(()=>{if(t){const a=()=>s(c=>c+1);return t.on("styledata",a),a(),()=>{t.off("styledata",a),t.style&&t.style._loaded&&t.getLayer(o)&&t.removeLayer(o)}}},[t]),t&&t.style&&t.getLayer(o))try{pe(t,o,e,n.current)}catch(a){console.warn(a)}else ve(t,o,e);return n.current=e,null}const V="pymc-basemap-mode",j="dark";function Le(){if(typeof window>"u")return j;try{const e=localStorage.getItem(V);if(e==="light"||e==="dark")return e}catch{}return j}function W(e){if(!(typeof window>"u"))try{localStorage.setItem(V,e)}catch{}}const q=G(e=>({mode:Le(),toggle:()=>e(t=>{const n=t.mode==="light"?"dark":"light";return W(n),{mode:n}}),setMode:t=>{W(t),e({mode:t})}})),Te=()=>q(e=>e.mode),Pe=()=>q(e=>e.toggle),Ce={light:"https://basemaps.cartocdn.com/gl/positron-gl-style/style.json",dark:"https://basemaps.cartocdn.com/gl/dark-matter-gl-style/style.json"},Se={light:"basemap-light-",dark:"basemap-dark-"},I={};async function Ee(e){if(I[e])return I[e];const n=await(await fetch(Ce[e])).json();return I[e]=n,n}function ze({mode:e}){const{current:t}=K(),[n,s]=i.useState(null),o=i.useRef({light:!1,dark:!1}),r=i.useRef({light:[],dark:[]});i.useEffect(()=>{const l=()=>{var y;const m=(y=t==null?void 0:t.getMap)==null?void 0:y.call(t);m&&!n&&s(m)};l();const d=setInterval(l,50),f=setTimeout(()=>clearInterval(d),5e3);return()=>{clearInterval(d),clearTimeout(f)}},[t,n]);const a=i.useCallback(async(l,d,f)=>{var E,k;if(o.current[d])return;const m=Se[d],y=await Ee(d),C=[];for(const[p,h]of Object.entries(y.sources||{})){const g=m+p;l.getSource(g)||l.addSource(g,h)}const x=(k=(((E=l.getStyle())==null?void 0:E.layers)||[]).find(p=>!p.id.startsWith("basemap-light-")&&!p.id.startsWith("basemap-dark-")))==null?void 0:k.id;for(const p of y.layers||[]){const h=m+p.id;if(C.push(h),l.getLayer(h))continue;const g={...p,id:h};"source"in g&&typeof g.source=="string"&&(g.source=m+g.source),g.layout||(g.layout={}),g.layout.visibility=f?"visible":"none";try{l.addLayer(g,x)}catch(_){console.warn(`[BasemapLayer] Failed to add layer ${h}:`,_)}}r.current[d]=C,o.current[d]=!0},[]),c=i.useCallback((l,d,f)=>{const m=r.current[d],y=f?"visible":"none";for(const C of m)if(l.getLayer(C))try{l.setLayoutProperty(C,"visibility",y)}catch{}},[]),u=i.useCallback(l=>{var m;const f=(((m=l.getStyle())==null?void 0:m.layers)||[]).filter(y=>!y.id.startsWith("basemap-light-")&&!y.id.startsWith("basemap-dark-"));for(const y of f)try{l.moveLayer(y.id)}catch{}},[]);return i.useEffect(()=>{if(!n)return;const l=d=>{n.hasImage(d.id)||n.addImage(d.id,{width:1,height:1,data:new Uint8Array([0,0,0,0])})};return n.on("styleimagemissing",l),()=>{n.off("styleimagemissing",l)}},[n]),i.useEffect(()=>{if(!n)return;let l=!1;const d=async()=>{if(!l)try{await Promise.all([a(n,"light",e==="light"),a(n,"dark",e==="dark")]),l||u(n)}catch(m){console.error("[BasemapLayer] Setup error:",m)}};n.isStyleLoaded()?d():(n.once("style.load",d),n.once("load",()=>{!l&&!o.current.light&&d()}));const f=()=>{l||setTimeout(()=>{!l&&o.current.light&&o.current.dark&&u(n)},100)};return n.on("styledata",f),()=>{l=!0,n.off("styledata",f)}},[n,a,u,e]),i.useEffect(()=>{n&&(!o.current.light||!o.current.dark||(c(n,"light",e==="light"),c(n,"dark",e==="dark")))},[n,e,c]),null}export{ze as B,Ie as L,Me as M,xe as P,Re as S,be as a,K as b,Pe as c,ke as d,Te as u}; diff --git a/frontend/dist/assets/ChatBubble-jJytaTX9.js b/frontend/dist/assets/ChatBubble-BP7NjdbB.js similarity index 93% rename from frontend/dist/assets/ChatBubble-jJytaTX9.js rename to frontend/dist/assets/ChatBubble-BP7NjdbB.js index 72c56a1e..e56436b1 100644 --- a/frontend/dist/assets/ChatBubble-jJytaTX9.js +++ b/frontend/dist/assets/ChatBubble-BP7NjdbB.js @@ -1,4 +1,4 @@ -import{d as h,r as u,j as e,c as t}from"./index-C1ZF7cAz.js";import{e as f,g as p,a as g,b as j,f as b}from"./chat-utils-BzC-Ehs-.js";/** +import{d as h,r as u,j as e,c as t}from"./index-DhkG1Nx9.js";import{e as f,g as p,a as g,b as j,f as b}from"./chat-utils-DA-kxQ-o.js";/** * @license lucide-react v0.559.0 - ISC * * This source code is licensed under the ISC license. diff --git a/frontend/dist/assets/CollisionExplorerModal-Bm7X5dgz.js b/frontend/dist/assets/CollisionExplorerModal-Cs8y9_83.js similarity index 86% rename from frontend/dist/assets/CollisionExplorerModal-Bm7X5dgz.js rename to frontend/dist/assets/CollisionExplorerModal-Cs8y9_83.js index 85e21b6e..5d117d64 100644 --- a/frontend/dist/assets/CollisionExplorerModal-Bm7X5dgz.js +++ b/frontend/dist/assets/CollisionExplorerModal-Cs8y9_83.js @@ -1,6 +1,6 @@ -import{d as k,r as c,E as L,bE as S,H,j as e,ac as R,ad as T,br as E,c as N,q as w,w as B,x as _,bO as D}from"./index-C1ZF7cAz.js";import{u as I,M as P,B as q,S as z,L as W,a as U}from"./BasemapLayer-CfNM-FKA.js";import{T as F}from"./triangle-alert-B3ZB2VPZ.js";import{M as A}from"./map-pin-DEktgLFN.js";import{M as Y}from"./monitor-smartphone-BQ_i3P0U.js";/** +import{d as k,r as c,G as L,bF as S,K as H,j as e,ag as R,ah as T,bs as B,c as N,v as w,y as E,z as _,bP as P}from"./index-DhkG1Nx9.js";import{u as z,M as D,B as I,S as W,L as q,a as F}from"./BasemapLayer-CfNeG6Jg.js";import{T as U}from"./triangle-alert-D8NErBXC.js";import{M as A}from"./map-pin-BHGohRD7.js";import{M as G}from"./monitor-smartphone-jV9bAwUA.js";/** * @license lucide-react v0.559.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const $=[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]],G=k("share-2",$);function J(n){var f;return(f=navigator.clipboard)!=null&&f.writeText?(navigator.clipboard.writeText(n).catch(()=>{}),!0):!1}const O={version:8,sources:{},layers:[],glyphs:"https://tiles.basemaps.cartocdn.com/fonts/{fontstack}/{range}.pbf"};function M({node:n,isHovered:f,onHover:g}){const[y,p]=c.useState(!1),j=c.useCallback(d=>{d.stopPropagation(),J(n.hash),p(!0),setTimeout(()=>p(!1),2e3)},[n.hash]),h=n.contactType.toLowerCase(),m=h.includes("room")||h.includes("server"),o=h==="companion"||h==="client";let r=G,l="text-sys-blue";return m?(r=D,l="text-signal-fair"):o?(r=Y,l="text-fg-muted"):n.isNeighbor&&(l="text-sys-green"),e.jsxs("div",{className:N("flex items-center gap-3 px-3 py-2.5 radius-inner transition-base cursor-pointer",f?"bg-sys-blue/10":"hover:bg-subtle-fill"),onMouseEnter:()=>g(n.hash),onMouseLeave:()=>g(null),children:[e.jsx(r,{className:N("w-4 h-4 flex-shrink-0",l)}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"type-label text-fg-primary truncate",children:n.name}),n.isNeighbor&&e.jsx(w,{color:"green",compact:!0,children:"NBR"}),n.isRepeater&&e.jsx(w,{color:"zinc",compact:!0,children:"RPT"}),n.isHub&&e.jsx(w,{color:"indigo",compact:!0,children:"HUB"})]}),e.jsxs("button",{onClick:j,className:N("mt-1 inline-flex items-center gap-1 type-data-xs px-1.5 py-0.5 rounded","border transition-all cursor-pointer",y?"border-sys-green/50 bg-sys-green/10 text-sys-green":"border-edge-subtle bg-subtle/50 text-fg-muted hover:border-edge-strong"),title:`Copy: ${n.hash}`,children:[n.hash.slice(0,12),"…",y?e.jsx(B,{className:"w-2.5 h-2.5"}):e.jsx(_,{className:"w-2.5 h-2.5 opacity-50"})]})]})]})}function C({nodes:n,hoveredHash:f,onHover:g}){const y=I(),p=c.useRef(null),j=E(),[h,m]=c.useState(!1),o=c.useMemo(()=>n.filter(a=>a.latitude!=null&&a.longitude!=null&&(a.latitude!==0||a.longitude!==0)),[n]),r=c.useMemo(()=>{if(o.length===0)return null;let a=1/0,s=-1/0,t=1/0,i=-1/0;for(const x of o)a=Math.min(a,x.longitude),s=Math.max(s,x.longitude),t=Math.min(t,x.latitude),i=Math.max(i,x.latitude);const u=.01;if(i-tr?{longitude:(r[0][0]+r[1][0])/2,latitude:(r[0][1]+r[1][1])/2}:{longitude:0,latitude:0},[r]),d=c.useMemo(()=>{if(o.length<2)return null;const a=[];for(let s=0;s{var s;const a=(s=p.current)==null?void 0:s.getMap();if(!a||!r){m(!0);return}a.fitBounds(r,{padding:{top:50,bottom:50,left:50,right:50},maxZoom:13,duration:0}),setTimeout(()=>m(!0),50)},[r]),b=j&&h;return o.length===0?e.jsx("div",{className:"h-full flex items-center justify-center bg-subtle/30 radius-inner",children:e.jsxs("div",{className:"text-center text-fg-secondary p-4",children:[e.jsx(A,{className:"w-8 h-8 mx-auto mb-2 opacity-40"}),e.jsx("p",{className:"text-sm",children:"No location data available"})]})}):e.jsxs("div",{className:"h-full w-full relative radius-inner overflow-hidden bg-elevated",children:[e.jsx("div",{className:N("absolute inset-0 flex items-center justify-center z-10","transition-opacity duration-200 pointer-events-none",b?"opacity-0":"opacity-100 bg-elevated"),children:e.jsx("div",{className:"w-5 h-5 border-2 border-text-muted/30 border-t-text-muted rounded-full animate-spin"})}),e.jsx("div",{className:N("h-full w-full transition-opacity duration-200",b?"opacity-100":"opacity-0"),children:e.jsxs(P,{ref:p,initialViewState:{longitude:l.longitude,latitude:l.latitude,zoom:10},style:{height:"100%",width:"100%"},mapStyle:O,attributionControl:!1,onLoad:v,children:[e.jsx(q,{mode:y}),d&&e.jsx(z,{id:"collision-edges",type:"geojson",data:d,children:e.jsx(W,{id:"collision-edges-line",type:"line",paint:{"line-color":"#3B3F4A","line-width":2,"line-opacity":.8},layout:{"line-cap":"round","line-join":"round"}})}),o.map(a=>{const s=a.hash===f,t=a.hash.startsWith("0x")?a.hash.slice(2,4).toUpperCase():a.hash.slice(0,2).toUpperCase();return e.jsx(U,{longitude:a.longitude,latitude:a.latitude,anchor:"center",children:e.jsx("div",{className:"cursor-pointer transition-all duration-150",onMouseEnter:()=>g(a.hash),onMouseLeave:()=>g(null),style:{pointerEvents:"auto"},children:e.jsxs(w,{color:"amber",filled:!0,className:"type-data-xs shadow-lg",children:[t,s&&e.jsx("span",{className:"ml-1 opacity-75 font-sans",children:a.name})]})})},a.hash)})]})})]})}function Q({isOpen:n,prefix:f,candidateHashes:g,onClose:y}){const p=L(),j=S(),h=H(),[m,o]=c.useState(null),r=c.useMemo(()=>new Set(h.map(s=>s.hash)),[h]),l=(p==null?void 0:p.neighbors)??{},d=c.useMemo(()=>{const s=t=>{if(l[t])return l[t];if(!t.startsWith("0x")&&l["0x"+t])return l["0x"+t];if(t.startsWith("0x")&&l[t.slice(2)])return l[t.slice(2)]};return g.map(t=>{var u;const i=s(t);return{hash:t,name:(i==null?void 0:i.node_name)||(i==null?void 0:i.name)||`Unknown (${t.slice(0,8)}…)`,contactType:(i==null?void 0:i.contact_type)||"",isRepeater:(i==null?void 0:i.is_repeater)||((u=i==null?void 0:i.contact_type)==null?void 0:u.toLowerCase())==="repeater"||!1,isNeighbor:r.has(t)||r.has("0x"+t)||r.has(t.replace(/^0x/,"")),isHub:j.has(t),latitude:i==null?void 0:i.latitude,longitude:i==null?void 0:i.longitude}}).sort((t,i)=>t.isNeighbor!==i.isNeighbor?t.isNeighbor?-1:1:t.isHub!==i.isHub?t.isHub?-1:1:t.name.localeCompare(i.name))},[g,l,r,j]),v=c.useMemo(()=>d.some(s=>s.latitude!=null&&s.longitude!=null&&(s.latitude!==0||s.longitude!==0)),[d]),b=c.useCallback(s=>{o(s)},[]),a=v?"4xl":"lg";return n?e.jsxs(R,{open:n,onClose:y,size:a,motionPlus:!0,className:v?"sm:h-[500px] sm:max-h-[600px]":"",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-edge-subtle",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 radius-inner bg-signal-fair/10",children:e.jsx(F,{className:"w-5 h-5 text-signal-fair"})}),e.jsxs("div",{children:[e.jsxs("div",{className:"type-micro",children:["Prefix Collision: ",e.jsx("span",{className:"font-mono text-sys-blue",children:f})]}),e.jsxs("p",{className:"text-xs text-fg-secondary",children:[d.length," nodes share this prefix"]})]})]}),e.jsx("button",{onClick:y,className:"sm:hidden min-h-[44px] min-w-[44px] px-3 flex items-center justify-center text-[15px] font-medium text-sys-blue active:text-sys-blue/70 transition-base radius-inner active:bg-subtle-fill",children:"Done"}),e.jsx("button",{onClick:y,className:"hidden sm:flex items-center justify-center p-2 text-fg-muted hover:text-fg-primary transition-base radius-inner hover:bg-subtle","aria-label":"Close",children:e.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]}),e.jsxs(T,{className:"p-0 overflow-hidden flex-1 flex flex-col min-h-0",children:[e.jsxs("div",{className:"sm:hidden flex-1 overflow-y-auto",children:[v&&e.jsx("div",{className:"h-64 p-2 border-b border-edge-subtle",children:e.jsx(C,{nodes:d,hoveredHash:m,onHover:b})}),e.jsx("div",{className:"p-2",children:d.map(s=>e.jsx(M,{node:s,isHovered:m===s.hash,onHover:b},s.hash))})]}),v?e.jsxs("div",{className:"hidden sm:grid sm:grid-cols-[280px_minmax(400px,1fr)] flex-1 overflow-hidden sm:min-w-[700px]",children:[e.jsx("div",{className:"overflow-y-auto border-r border-edge-subtle",children:e.jsx("div",{className:"p-2",children:d.map(s=>e.jsx(M,{node:s,isHovered:m===s.hash,onHover:b},s.hash))})}),e.jsx("div",{className:"overflow-hidden p-2",children:e.jsx(C,{nodes:d,hoveredHash:m,onHover:b})})]}):e.jsx("div",{className:"hidden sm:block flex-1 overflow-y-auto",children:e.jsx("div",{className:"p-2",children:d.map(s=>e.jsx(M,{node:s,isHovered:m===s.hash,onHover:b},s.hash))})})]})]}):null}const se=c.memo(Q);export{se as C,G as S}; + */const Y=[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]],$=k("share-2",Y);function J(n){var f;return(f=navigator.clipboard)!=null&&f.writeText?(navigator.clipboard.writeText(n).catch(()=>{}),!0):!1}const K={version:8,sources:{},layers:[],glyphs:"https://tiles.basemaps.cartocdn.com/fonts/{fontstack}/{range}.pbf"};function M({node:n,isHovered:f,onHover:g}){const[y,p]=c.useState(!1),j=c.useCallback(d=>{d.stopPropagation(),J(n.hash),p(!0),setTimeout(()=>p(!1),2e3)},[n.hash]),h=n.contactType.toLowerCase(),m=h.includes("room")||h.includes("server"),o=h==="companion"||h==="client";let r=$,l="text-sys-blue";return m?(r=P,l="text-signal-fair"):o?(r=G,l="text-fg-muted"):n.isNeighbor&&(l="text-sys-green"),e.jsxs("div",{className:N("flex items-center gap-3 px-3 py-2.5 radius-inner transition-base cursor-pointer",f?"bg-sys-blue/10":"hover:bg-subtle-fill"),onMouseEnter:()=>g(n.hash),onMouseLeave:()=>g(null),children:[e.jsx(r,{className:N("w-4 h-4 flex-shrink-0",l)}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"type-label text-fg-primary truncate",children:n.name}),n.isNeighbor&&e.jsx(w,{color:"green",compact:!0,children:"NBR"}),n.isRepeater&&e.jsx(w,{color:"zinc",compact:!0,children:"RPT"}),n.isHub&&e.jsx(w,{color:"indigo",compact:!0,children:"HUB"})]}),e.jsxs("button",{onClick:j,className:N("mt-1 inline-flex items-center gap-1 type-data-xs px-1.5 py-0.5 rounded","border transition-all cursor-pointer",y?"border-sys-green/50 bg-sys-green/10 text-sys-green":"border-edge-subtle bg-subtle/50 text-fg-muted hover:border-edge-strong"),title:`Copy: ${n.hash}`,children:[n.hash.slice(0,12),"…",y?e.jsx(E,{className:"w-2.5 h-2.5"}):e.jsx(_,{className:"w-2.5 h-2.5 opacity-50"})]})]})]})}function C({nodes:n,hoveredHash:f,onHover:g}){const y=z(),p=c.useRef(null),j=B(),[h,m]=c.useState(!1),o=c.useMemo(()=>n.filter(a=>a.latitude!=null&&a.longitude!=null&&(a.latitude!==0||a.longitude!==0)),[n]),r=c.useMemo(()=>{if(o.length===0)return null;let a=1/0,s=-1/0,t=1/0,i=-1/0;for(const x of o)a=Math.min(a,x.longitude),s=Math.max(s,x.longitude),t=Math.min(t,x.latitude),i=Math.max(i,x.latitude);const u=.01;if(i-tr?{longitude:(r[0][0]+r[1][0])/2,latitude:(r[0][1]+r[1][1])/2}:{longitude:0,latitude:0},[r]),d=c.useMemo(()=>{if(o.length<2)return null;const a=[];for(let s=0;s{var s;const a=(s=p.current)==null?void 0:s.getMap();if(!a||!r){m(!0);return}a.fitBounds(r,{padding:{top:50,bottom:50,left:50,right:50},maxZoom:13,duration:0}),setTimeout(()=>m(!0),50)},[r]),b=j&&h;return o.length===0?e.jsx("div",{className:"h-full flex items-center justify-center bg-subtle/30 radius-inner",children:e.jsxs("div",{className:"text-center text-fg-secondary p-4",children:[e.jsx(A,{className:"w-8 h-8 mx-auto mb-2 opacity-40"}),e.jsx("p",{className:"text-sm",children:"No location data available"})]})}):e.jsxs("div",{className:"h-full w-full relative radius-inner overflow-hidden bg-elevated",children:[e.jsx("div",{className:N("absolute inset-0 flex items-center justify-center z-10","transition-opacity duration-200 pointer-events-none",b?"opacity-0":"opacity-100 bg-elevated"),children:e.jsx("div",{className:"w-5 h-5 border-2 border-text-muted/30 border-t-text-muted rounded-full animate-spin"})}),e.jsx("div",{className:N("h-full w-full transition-opacity duration-200",b?"opacity-100":"opacity-0"),children:e.jsxs(D,{ref:p,initialViewState:{longitude:l.longitude,latitude:l.latitude,zoom:10},style:{height:"100%",width:"100%"},mapStyle:K,attributionControl:!1,onLoad:v,children:[e.jsx(I,{mode:y}),d&&e.jsx(W,{id:"collision-edges",type:"geojson",data:d,children:e.jsx(q,{id:"collision-edges-line",type:"line",paint:{"line-color":"#3B3F4A","line-width":2,"line-opacity":.8},layout:{"line-cap":"round","line-join":"round"}})}),o.map(a=>{const s=a.hash===f,t=a.hash.startsWith("0x")?a.hash.slice(2,4).toUpperCase():a.hash.slice(0,2).toUpperCase();return e.jsx(F,{longitude:a.longitude,latitude:a.latitude,anchor:"center",children:e.jsx("div",{className:"cursor-pointer transition-all duration-150",onMouseEnter:()=>g(a.hash),onMouseLeave:()=>g(null),style:{pointerEvents:"auto"},children:e.jsxs(w,{color:"amber",filled:!0,className:"type-data-xs shadow-lg",children:[t,s&&e.jsx("span",{className:"ml-1 opacity-75 font-sans",children:a.name})]})})},a.hash)})]})})]})}function Q({isOpen:n,prefix:f,candidateHashes:g,onClose:y}){const p=L(),j=S(),h=H(),[m,o]=c.useState(null),r=c.useMemo(()=>new Set(h.map(s=>s.hash)),[h]),l=(p==null?void 0:p.neighbors)??{},d=c.useMemo(()=>{const s=t=>{if(l[t])return l[t];if(!t.startsWith("0x")&&l["0x"+t])return l["0x"+t];if(t.startsWith("0x")&&l[t.slice(2)])return l[t.slice(2)]};return g.map(t=>{var u;const i=s(t);return{hash:t,name:(i==null?void 0:i.node_name)||(i==null?void 0:i.name)||`Unknown (${t.slice(0,8)}…)`,contactType:(i==null?void 0:i.contact_type)||"",isRepeater:(i==null?void 0:i.is_repeater)||((u=i==null?void 0:i.contact_type)==null?void 0:u.toLowerCase())==="repeater"||!1,isNeighbor:r.has(t)||r.has("0x"+t)||r.has(t.replace(/^0x/,"")),isHub:j.has(t),latitude:i==null?void 0:i.latitude,longitude:i==null?void 0:i.longitude}}).sort((t,i)=>t.isNeighbor!==i.isNeighbor?t.isNeighbor?-1:1:t.isHub!==i.isHub?t.isHub?-1:1:t.name.localeCompare(i.name))},[g,l,r,j]),v=c.useMemo(()=>d.some(s=>s.latitude!=null&&s.longitude!=null&&(s.latitude!==0||s.longitude!==0)),[d]),b=c.useCallback(s=>{o(s)},[]),a=v?"4xl":"lg";return n?e.jsxs(R,{open:n,onClose:y,size:a,motionPlus:!0,className:v?"sm:h-[500px] sm:max-h-[600px]":"",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-edge-subtle",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 radius-inner bg-signal-fair/10",children:e.jsx(U,{className:"w-5 h-5 text-signal-fair"})}),e.jsxs("div",{children:[e.jsxs("div",{className:"type-micro",children:["Prefix Collision: ",e.jsx("span",{className:"font-mono text-sys-blue",children:f})]}),e.jsxs("p",{className:"text-xs text-fg-secondary",children:[d.length," nodes share this prefix"]})]})]}),e.jsx("button",{onClick:y,className:"sm:hidden min-h-[44px] min-w-[44px] px-3 flex items-center justify-center text-[15px] font-medium text-sys-blue active:text-sys-blue/70 transition-base radius-inner active:bg-subtle-fill",children:"Done"}),e.jsx("button",{onClick:y,className:"hidden sm:flex items-center justify-center p-2 text-fg-muted hover:text-fg-primary transition-base radius-inner hover:bg-subtle","aria-label":"Close",children:e.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]}),e.jsxs(T,{className:"p-0 overflow-hidden flex-1 flex flex-col min-h-0",children:[e.jsxs("div",{className:"sm:hidden flex-1 overflow-y-auto",children:[v&&e.jsx("div",{className:"h-64 p-2 border-b border-edge-subtle",children:e.jsx(C,{nodes:d,hoveredHash:m,onHover:b})}),e.jsx("div",{className:"p-2",children:d.map(s=>e.jsx(M,{node:s,isHovered:m===s.hash,onHover:b},s.hash))})]}),v?e.jsxs("div",{className:"hidden sm:grid sm:grid-cols-[280px_minmax(400px,1fr)] flex-1 overflow-hidden sm:min-w-[700px]",children:[e.jsx("div",{className:"overflow-y-auto border-r border-edge-subtle",children:e.jsx("div",{className:"p-2",children:d.map(s=>e.jsx(M,{node:s,isHovered:m===s.hash,onHover:b},s.hash))})}),e.jsx("div",{className:"overflow-hidden p-2",children:e.jsx(C,{nodes:d,hoveredHash:m,onHover:b})})]}):e.jsx("div",{className:"hidden sm:block flex-1 overflow-y-auto",children:e.jsx("div",{className:"p-2",children:d.map(s=>e.jsx(M,{node:s,isHovered:m===s.hash,onHover:b},s.hash))})})]})]}):null}const se=c.memo(Q);export{se as C,$ as S}; diff --git a/frontend/dist/assets/Configuration-C84P-CXS.js b/frontend/dist/assets/Configuration-C84P-CXS.js new file mode 100644 index 00000000..15ccdc7a --- /dev/null +++ b/frontend/dist/assets/Configuration-C84P-CXS.js @@ -0,0 +1,32 @@ +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/latin-400-BcR6IdUc.css","assets/latin-500-DCnAHIrw.css","assets/latin-600-CnkPk-vb.css","assets/latin-700-UC1i-VSI.css"])))=>i.map(i=>d[i]); +import{d as ue,r as t,j as e,c as l,L as $,y as B,bf as J,ai as Ts,dC as Re,dD as ss,dE as Qe,_ as Te,T as ie,M as et,S as st,dF as tt,H as X,cc as Ze,bR as at,dG as nt,x as lt,dH as _s,dI as rt,dJ as it,dK as ot,R as ct,B as F,dL as qe,I as dt,z as ut}from"./index-DhkG1Nx9.js";import{g as mt,a as xt,c as ft,r as ht,s as pt,b as yt,u as gt,d as bt}from"./system-DPGbt46l.js";import{T as Ds,C as jt}from"./ConfirmModal-BoB1If6b.js";import{N as vt}from"./NodeInformationCard-Byom2o5k.js";import{i as Nt,g as kt,s as wt,a as Ct,k as St}from"./keycap-sfx-ByZp-njj.js";import{C as Y,P as Tt,a as _t,B as Ft}from"./PageLayout-BkUTZXJb.js";import{R as te,C as _e}from"./Grid-DknC4rR5.js";import{A as Et}from"./antenna-Dw5nF1O3.js";import{P as Fs}from"./plus-Pe5yI_FS.js";import{K as Ge}from"./key-round-pRzIhNB6.js";import{C as Rt}from"./circle-check-DJNUSJlu.js";import{T as Be}from"./triangle-alert-D8NErBXC.js";import{R as It}from"./refresh-cw-CA_1u8Jn.js";import{C as Pt}from"./chevron-right-na13OQfy.js";import"./DataBox-BMesbbaF.js";/** + * @license lucide-react v0.559.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Dt=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],Mt=ue("external-link",Dt);/** + * @license lucide-react v0.559.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const At=[["circle",{cx:"16",cy:"20",r:"2",key:"1vifvg"}],["path",{d:"M10 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v2",key:"3hgo9p"}],["path",{d:"m22 14-4.5 4.5",key:"1ef6z8"}],["path",{d:"m21 15 1 1",key:"1ejcpy"}]],Kt=ue("folder-key",At);/** + * @license lucide-react v0.559.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Lt=[["rect",{width:"8",height:"5",x:"14",y:"17",rx:"1",key:"19aais"}],["path",{d:"M10 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v2.5",key:"1w6v7t"}],["path",{d:"M20 17v-2a2 2 0 1 0-4 0v2",key:"pwaxnr"}]],Es=ue("folder-lock",Lt);/** + * @license lucide-react v0.559.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const zt=[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21",key:"1svkeh"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21",key:"vw1qmm"}]],Ot=ue("monitor",zt);/** + * @license lucide-react v0.559.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Vt=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]],es=ue("pencil",Vt);/** + * @license lucide-react v0.559.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Ht=[["path",{d:"M10.17 4.193a2 2 0 0 1 3.666.013",key:"pltmmw"}],["path",{d:"M14 21h2",key:"v4qezv"}],["path",{d:"m15.874 7.743 1 1.732",key:"10m0iw"}],["path",{d:"m18.849 12.952 1 1.732",key:"zadnam"}],["path",{d:"M21.824 18.18a2 2 0 0 1-1.835 2.824",key:"fvwuk4"}],["path",{d:"M4.024 21a2 2 0 0 1-1.839-2.839",key:"1e1kah"}],["path",{d:"m5.136 12.952-1 1.732",key:"1u4ldi"}],["path",{d:"M8 21h2",key:"i9zjee"}],["path",{d:"m8.102 7.743-1 1.732",key:"1zzo4u"}]],$t=ue("triangle-dashed",Ht),Ee=1500,oe={stacked:"h-[38px]",inline:"h-[32px]"},ce={stacked:"px-3",inline:"px-2.5"},de="rounded-lg";function H({label:a,value:c,editValue:r,onSave:f,type:o="text",suffix:d,placeholder:N,readOnly:u=!1,layout:g="stacked",min:i,max:n,step:h,maxLength:T,description:p,className:P}){const[w,k]=t.useState(!1),[y,E]=t.useState(""),[b,z]=t.useState("idle"),O=t.useRef(null),v=t.useRef(!0),_=t.useRef(null),I=!u&&!!f;t.useEffect(()=>(v.current=!0,()=>{v.current=!1,_.current&&clearTimeout(_.current)}),[]);const A=t.useCallback(()=>{I&&(E(r??c),k(!0),z("idle"),requestAnimationFrame(()=>{var C;return(C=O.current)==null?void 0:C.select()}))},[I,r,c]),S=t.useCallback(()=>{k(!1),E(""),z("idle")},[]),m=t.useCallback(async()=>{if(!f||b==="loading")return;if(y===(r??c)){S();return}_.current&&clearTimeout(_.current),z("loading");try{if(await f(y),!v.current)return;z("success"),k(!1),_.current=setTimeout(()=>{v.current&&z("idle")},Ee)}catch{if(!v.current)return;z("error"),_.current=setTimeout(()=>{v.current&&z("idle")},Ee)}},[f,y,r,c,S,b]),K=t.useCallback(C=>{C.key==="Enter"?(C.preventDefault(),m()):C.key==="Escape"&&(C.preventDefault(),S())},[m,S]);return g==="inline"?e.jsxs("div",{className:l("group flex items-center justify-between gap-3",P),children:[e.jsx("label",{className:"type-label text-fg-muted truncate",children:a}),w?e.jsxs("div",{className:l(oe.inline,de,ce.inline,"flex items-center transition-all","bg-transparent border border-sys-blue/50 ring-1 ring-sys-blue/20","min-w-[100px]"),children:[e.jsx("input",{ref:O,type:o,value:y,onChange:C=>E(C.target.value),onKeyDown:K,placeholder:N,min:i,max:n,step:h,maxLength:T,disabled:b==="loading",className:l("bg-transparent text-fg-primary focus:outline-none type-data flex-1 min-w-0",d?"w-12 text-right":"w-full")}),d&&e.jsx("span",{className:"text-fg-muted type-data ml-1 shrink-0",children:d}),e.jsx("div",{className:"flex items-center gap-0.5 ml-2 shrink-0",children:b==="loading"?e.jsx($,{className:"w-3.5 h-3.5 text-fg-muted animate-spin"}):e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:m,className:"p-0.5 rounded hover:bg-sys-green/15 text-sys-green transition-colors",title:"Save (Enter)",children:e.jsx(B,{className:"w-3 h-3"})}),e.jsx("button",{onClick:S,className:"p-0.5 rounded hover:bg-sys-red/15 text-fg-muted hover:text-sys-red transition-colors",title:"Cancel (Esc)",children:e.jsx(J,{className:"w-3 h-3"})})]})})]}):e.jsxs("div",{className:l(oe.inline,de,ce.inline,"flex items-center justify-end transition-all min-w-[80px]","bg-input-bg border border-input-border",I&&"cursor-pointer hover:border-edge-strong"),onClick:I?A:void 0,children:[e.jsx("span",{className:"type-data text-fg-primary",children:c}),b==="success"&&e.jsx(B,{className:"w-3 h-3 text-sys-green ml-1.5 shrink-0"}),b==="error"&&e.jsx(J,{className:"w-3 h-3 text-sys-red ml-1.5 shrink-0"}),b==="idle"&&I&&e.jsx(es,{className:"w-3 h-3 text-fg-muted ml-1.5 opacity-0 group-hover:opacity-100 transition-opacity shrink-0"})]})]}):e.jsxs("div",{className:l("group",P),children:[e.jsx("label",{className:"type-label text-fg-muted block mb-1",children:a}),w?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:l(oe.stacked,de,ce.stacked,"flex items-center transition-all","bg-transparent border border-sys-blue/50 ring-1 ring-sys-blue/20"),children:[e.jsx("input",{ref:O,type:o,value:y,onChange:C=>E(C.target.value),onKeyDown:K,placeholder:N,min:i,max:n,step:h,maxLength:T,disabled:b==="loading",className:"w-full bg-transparent text-fg-primary focus:outline-none type-data flex-1 min-w-0"}),d&&e.jsx("span",{className:"text-fg-muted type-data ml-1 shrink-0",children:d}),e.jsx("div",{className:"flex items-center gap-0.5 ml-2 shrink-0",children:b==="loading"?e.jsx($,{className:"w-3.5 h-3.5 text-fg-muted animate-spin"}):e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:m,className:"p-1 rounded hover:bg-sys-green/15 text-sys-green transition-colors",title:"Save (Enter)",children:e.jsx(B,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:S,className:"p-1 rounded hover:bg-sys-red/15 text-fg-muted hover:text-sys-red transition-colors",title:"Cancel (Esc)",children:e.jsx(J,{className:"w-3.5 h-3.5"})})]})})]}),p&&e.jsx("p",{className:"type-data-xs text-fg-muted mt-1 ml-3",children:p})]}):e.jsxs("div",{className:l(oe.stacked,de,ce.stacked,"flex items-center transition-all","bg-input-bg border border-input-border",I&&"cursor-pointer hover:border-edge-strong"),onClick:I?A:void 0,children:[e.jsx("span",{className:"type-data text-fg-primary flex-1 whitespace-nowrap",children:c}),b==="success"&&e.jsx(B,{className:"w-3.5 h-3.5 text-sys-green shrink-0"}),b==="error"&&e.jsx(J,{className:"w-3.5 h-3.5 text-sys-red shrink-0"}),b==="idle"&&I&&e.jsx(es,{className:"w-3.5 h-3.5 text-fg-muted opacity-0 group-hover:opacity-100 transition-opacity shrink-0"})]})]})}function Ue({label:a,value:c,editValue:r,options:f,onSave:o,readOnly:d=!1,layout:N="stacked",className:u}){const[g,i]=t.useState(!1),[n,h]=t.useState(""),[T,p]=t.useState("idle"),P=t.useRef(null),w=t.useRef(!0),k=t.useRef(null),y=!d&&!!o;t.useEffect(()=>(w.current=!0,()=>{w.current=!1,k.current&&clearTimeout(k.current)}),[]);const E=t.useCallback(()=>{y&&(h(String(r)),i(!0),p("idle"),requestAnimationFrame(()=>{var m;return(m=P.current)==null?void 0:m.focus()}))},[y,r]),b=t.useCallback(()=>{i(!1),h(""),p("idle")},[]),z=t.useCallback(async()=>{if(!(!o||T==="loading")){if(n===String(r)){b();return}k.current&&clearTimeout(k.current),p("loading");try{if(await o(n),!w.current)return;p("success"),i(!1),k.current=setTimeout(()=>{w.current&&p("idle")},Ee)}catch{if(!w.current)return;p("error"),k.current=setTimeout(()=>{w.current&&p("idle")},Ee)}}},[o,n,r,b,T]),O=t.useCallback(m=>{m.key==="Escape"&&(m.preventDefault(),b())},[b]),v=N==="inline",_=v?oe.inline:oe.stacked,I=v?ce.inline:ce.stacked,A=e.jsxs("div",{className:l(_,de,I,"flex items-center transition-all relative","bg-transparent border border-sys-blue/50 ring-1 ring-sys-blue/20",v&&"min-w-[100px]"),children:[e.jsx("select",{ref:P,value:n,onChange:m=>h(m.target.value),onKeyDown:O,disabled:T==="loading",className:l("bg-transparent text-fg-primary focus:outline-none appearance-none cursor-pointer type-data flex-1 min-w-0","pr-6"),children:f.map(m=>e.jsx("option",{value:m.value,children:m.label},String(m.value)))}),e.jsx(Ts,{className:"absolute right-auto w-3.5 h-3.5 text-fg-muted pointer-events-none",style:{right:T==="loading"?"2rem":"3.5rem"}}),e.jsx("div",{className:"flex items-center gap-0.5 ml-1 shrink-0",children:T==="loading"?e.jsx($,{className:l("text-fg-muted animate-spin",v?"w-3 h-3":"w-3.5 h-3.5")}):e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:z,className:l("rounded hover:bg-sys-green/15 text-sys-green transition-colors",v?"p-0.5":"p-1"),title:"Save",children:e.jsx(B,{className:v?"w-3 h-3":"w-3.5 h-3.5"})}),e.jsx("button",{onClick:b,className:l("rounded hover:bg-sys-red/15 text-fg-muted hover:text-sys-red transition-colors",v?"p-0.5":"p-1"),title:"Cancel (Esc)",children:e.jsx(J,{className:v?"w-3 h-3":"w-3.5 h-3.5"})})]})})]}),S=e.jsxs("div",{className:l(_,de,I,"flex items-center transition-all","bg-input-bg border border-input-border",y&&"cursor-pointer hover:border-edge-strong",v?"justify-end min-w-[80px]":""),onClick:y?E:void 0,children:[e.jsx("span",{className:l("type-data text-fg-primary",!v&&"flex-1"),children:c}),T==="success"&&e.jsx(B,{className:l("text-sys-green shrink-0",v?"w-3 h-3 ml-1.5":"w-3.5 h-3.5")}),T==="error"&&e.jsx(J,{className:l("text-sys-red shrink-0",v?"w-3 h-3 ml-1.5":"w-3.5 h-3.5")}),T==="idle"&&y&&e.jsx(Ts,{className:l("text-fg-muted opacity-0 group-hover:opacity-100 transition-opacity shrink-0",v?"w-3 h-3 ml-1.5":"w-3.5 h-3.5")})]});return v?e.jsxs("div",{className:l("group flex items-center justify-between",u),children:[e.jsx("label",{className:"type-label text-fg-muted shrink-0",children:a}),g?A:S]}):e.jsxs("div",{className:l("group",u),children:[e.jsx("label",{className:"type-label text-fg-muted block mb-1",children:a}),g?A:S]})}async function qt(){try{return await Re("/api/auth/tokens")}catch{return{tokens:[]}}}async function Gt(a){return Re("/api/auth/tokens",{method:"POST",body:JSON.stringify({name:a})})}async function Bt(a){return Re(`/api/auth/tokens/${a}`,{method:"DELETE"})}async function Rs(a){return Re("/api/update_web_config",{method:"POST",body:JSON.stringify(a)})}t.memo(function(){const{theme:c}=ss(),{themeId:r}=c,f=Qe.find(o=>o.meta.id===r)??Qe[0];return e.jsx("div",{className:"h-10 flex items-center justify-center",children:e.jsx("span",{className:"font-medium transition-all duration-300 leading-none text-center text-fg-secondary",style:{fontFamily:"Inter, system-ui, sans-serif",fontSize:"clamp(0.75rem, 0.6rem + 1.5vw, 1.1rem)",letterSpacing:"-0.02em"},children:f.meta.name})})});const We=t.memo(function({compact:c=!1}){const{theme:r,setTheme:f}=ss(),{themeId:o}=r;return e.jsx("div",{className:l("grid grid-cols-2 gap-2",c?"w-full min-w-0 self-stretch":"w-full"),children:[...Qe].reverse().map(d=>{const N=o===d.meta.id,u=d.meta.isDark;return e.jsxs("button",{type:"button",title:d.meta.name,className:l("flex flex-row items-stretch radius-inner transition-all duration-200 ease-out overflow-hidden cursor-pointer",c&&"h-6",N?"ring-2 ring-sys-blue scale-[1.02]":"opacity-70 hover:opacity-100"),onClick:()=>f(d.meta.id),children:[e.jsx("div",{className:l("flex-1 h-full",u?"bg-[#18181b]":"bg-[#EFF0F1]")}),e.jsx("div",{className:"flex flex-col h-full",children:d.display.palette.map((g,i)=>e.jsx("div",{className:"flex flex-1",children:g.map((n,h)=>e.jsx("div",{className:"w-2 h-full",style:{backgroundColor:n}},h))},i))})]},d.meta.id)})})});let Is=!1,Fe=null;async function Ut(){if(!Is)return Fe||(Fe=(async()=>{try{await Promise.all([Te(()=>Promise.resolve({}),__vite__mapDeps([0])),Te(()=>Promise.resolve({}),__vite__mapDeps([1])),Te(()=>Promise.resolve({}),__vite__mapDeps([2])),Te(()=>Promise.resolve({}),__vite__mapDeps([3]))]),Is=!0}catch(a){console.warn("Failed to load theme fonts:",a)}})(),Fe)}const Xe=t.memo(function(){const{theme:c,setTheme:r}=ss(),{themeId:f}=c,o=f==="breeze dark",d=t.useCallback(N=>{r(N?"breeze dark":"breeze light")},[r]);return e.jsx(ie,{enabled:o,onChange:d,label:e.jsxs(e.Fragment,{children:["Dark Mode: ",o?e.jsx(et,{className:"w-3.5 h-3.5 text-sys-blue inline"}):e.jsx(st,{className:"w-3.5 h-3.5 text-[#e8a517] inline"})]}),tooltip:"Switch between dark and light mode",size:"md"})}),Wt=t.memo(function({layout:c="horizontal"}){return t.useEffect(()=>{Ut()},[]),c==="toggle-only"?e.jsx(Xe,{}):c==="thumbnails-only"?e.jsx(We,{}):c==="vertical"?e.jsxs("div",{className:"flex flex-col items-start gap-3",children:[e.jsx(Xe,{}),e.jsx(We,{})]}):e.jsxs("div",{className:"flex items-stretch gap-4",children:[e.jsx("div",{className:"flex-shrink-0 flex items-start",children:e.jsx(Xe,{})}),e.jsx(We,{compact:!0})]})}),Xt=1e4,Ye=2e3;function Je(a,c,r){const[f,o]=t.useState("idle"),[d,N]=t.useState(null),u=t.useRef(!0),g=t.useRef(null),i=t.useRef(null),n=t.useRef(!1),h=t.useRef("idle"),T=t.useRef(a),p=t.useRef(c),P=t.useRef(r);h.current=f,T.current=a,p.current=c,P.current=r,t.useEffect(()=>(u.current=!0,()=>{u.current=!1,g.current&&clearTimeout(g.current),i.current&&clearTimeout(i.current)}),[]);const w=t.useCallback(async y=>{if(h.current==="loading")return;const E=T.current;g.current&&clearTimeout(g.current),i.current&&clearTimeout(i.current),n.current=!1,N(y),o("loading"),g.current=setTimeout(()=>{n.current||!u.current||(N(E),o("error"),i.current=setTimeout(()=>{u.current&&(o("idle"),N(null))},Ye))},Xt);try{if(await p.current(y),n.current=!0,g.current&&clearTimeout(g.current),!u.current)return;o("success"),i.current=setTimeout(()=>{var b;u.current&&(o("idle"),N(null),(b=P.current)==null||b.call(P))},Ye)}catch{if(n.current=!0,g.current&&clearTimeout(g.current),!u.current)return;N(E),o("error"),i.current=setTimeout(()=>{u.current&&(o("idle"),N(null))},Ye)}},[]);return{enabled:d!==null?d:a,status:f,toggle:w}}function Yt(){const{latitude:a,longitude:c,enabled:r,setLocation:f,enable:o,disable:d,clear:N}=tt(),[u,g]=t.useState(!1),[i,n]=t.useState(""),[h,T]=t.useState(""),[p,P]=t.useState("idle"),[w,k]=t.useState(null),y=t.useRef(null),E=t.useRef(null),b=t.useRef(!0);t.useEffect(()=>(b.current=!0,()=>{b.current=!1,E.current&&clearTimeout(E.current)}),[]);const z=()=>{n((a==null?void 0:a.toFixed(6))??""),T((c==null?void 0:c.toFixed(6))??""),k(null),g(!0)},O=()=>{g(!1),k(null)};t.useEffect(()=>{if(!u)return;const m=K=>{p!=="loading"&&y.current&&!y.current.contains(K.target)&&O()};return document.addEventListener("mouseup",m),()=>document.removeEventListener("mouseup",m)},[u,p]);const v=(m,K)=>{const C=parseFloat(m),G=parseFloat(K);return isNaN(C)||isNaN(G)?"Please enter valid numbers":C<-90||C>90?"Latitude must be between -90 and 90":G<-180||G>180?"Longitude must be between -180 and 180":C===0&&G===0?"Coordinates (0, 0) are invalid":null},_=()=>{if(p==="loading")return;E.current&&clearTimeout(E.current);const m=v(i,h);if(m){k(m);return}P("loading"),k(null);const K=parseFloat(i),C=parseFloat(h);f(K,C),r||o(),P("success"),E.current=setTimeout(()=>{b.current&&(P("idle"),g(!1))},1e3)},I=()=>{r?d():o()},A=()=>{N(),g(!1)},S=a!==null&&c!==null;return e.jsx(Y,{children:e.jsxs("div",{ref:y,children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx(X,{icon:e.jsx($t,{}),title:"Stealth"}),e.jsxs("div",{className:"flex items-center gap-1",children:[S&&!u&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:I,className:l("relative inline-flex h-6 w-11 items-center rounded-full transition-colors border-2 mr-2",r?"bg-toggle-on border-toggle-on":"bg-toggle-off border-edge-subtle"),title:r?"Disable stealth location":"Enable stealth location",children:e.jsx("span",{className:l("inline-block h-4 w-4 transform rounded-full bg-white transition-transform shadow-lg",r?"translate-x-5":"translate-x-0.5")})}),e.jsx("button",{onClick:A,className:"p-2 rounded-lg transition-colors text-fg-muted hover:text-sys-red hover:bg-sys-red/10",title:"Clear stealth location",children:e.jsx(Ds,{className:"w-4 h-4"})})]}),u?e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:O,disabled:p==="loading",className:l("p-2 rounded-lg transition-colors",p==="loading"?"text-fg-muted cursor-not-allowed":"text-fg-muted hover:text-sys-red hover:bg-sys-red/10"),title:"Cancel",children:e.jsx(J,{className:"w-4 h-4"})}),e.jsx("button",{onClick:_,disabled:p==="loading",className:l("p-2 rounded-lg transition-colors",p==="loading"?"text-sys-blue cursor-wait":p==="success"?"text-sys-green":p==="error"?"text-sys-red":"text-sys-green hover:bg-sys-green/10"),title:"Save",children:p==="loading"?e.jsx($,{className:"w-4 h-4 animate-spin"}):p==="success"?e.jsx(B,{className:"w-4 h-4"}):p==="error"?e.jsx(J,{className:"w-4 h-4"}):e.jsx(B,{className:"w-4 h-4"})})]}):e.jsx("button",{onClick:z,className:"p-2 rounded-lg transition-colors text-fg-muted hover:text-fg-primary hover:bg-subtle",title:S?"Edit stealth location":"Set stealth location",children:e.jsx(es,{className:"w-4 h-4"})})]})]}),e.jsx("div",{className:"bg-sys-cyan/5 rounded-xl p-3 mb-4",children:e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Ze,{className:"w-4 h-4 text-sys-cyan flex-shrink-0 mt-0.5"}),e.jsxs("p",{className:"type-body-sm text-fg-muted",children:[e.jsx("span",{className:"text-fg-secondary",children:"Stealth mode"})," allows you to appear on the map and in topology analysis without broadcasting your location. Coordinates are stored locally in your browser only — ",e.jsx("span",{className:"text-sys-cyan",children:"never sent to config.yaml or the mesh"}),"."]})]})}),w&&e.jsx("div",{className:"text-xs mb-3 px-2 py-1.5 rounded-md text-sys-red bg-sys-red/10",children:w}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"type-label text-fg-muted block mb-1",children:u?"Latitude (°)":"Latitude"}),e.jsx("div",{className:l("h-[38px] rounded-full px-4 flex items-center transition-colors","bg-subtle-fill"),children:u?e.jsx("input",{type:"number",value:i,onChange:m=>n(m.target.value),step:"0.000001",min:"-90",max:"90",placeholder:"e.g. 34.052234",className:"w-full bg-transparent text-fg-primary focus:outline-none type-data placeholder:text-fg-muted/50"}):e.jsx("span",{className:l("type-data",S&&r?"text-fg-primary":"text-fg-muted"),children:S?a.toFixed(6):"Not set"})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"type-label text-fg-muted block mb-1",children:u?"Longitude (°)":"Longitude"}),e.jsx("div",{className:l("h-[38px] rounded-full px-4 flex items-center transition-colors","bg-subtle-fill"),children:u?e.jsx("input",{type:"number",value:h,onChange:m=>T(m.target.value),step:"0.000001",min:"-180",max:"180",placeholder:"e.g. -118.243685",className:"w-full bg-transparent text-fg-primary focus:outline-none type-data placeholder:text-fg-muted/50"}):e.jsx("span",{className:l("type-data",S&&r?"text-fg-primary":"text-fg-muted"),children:S?c.toFixed(6):"Not set"})})]})]}),S&&!u&&e.jsx("div",{className:"mt-3 pt-3 border-t border-edge-subtle",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:l("w-2 h-2 rounded-full",r?"bg-sys-green":"bg-fg-muted")}),e.jsx("span",{className:"type-body-sm text-fg-muted",children:r?"Stealth location active — you appear on maps with these coordinates":"Stealth location disabled — coordinates saved but not in use"})]})})]})})}const Jt=[{value:7.8,label:"7.8 kHz"},{value:10.4,label:"10.4 kHz"},{value:15.6,label:"15.6 kHz"},{value:20.8,label:"20.8 kHz"},{value:31.25,label:"31.25 kHz"},{value:41.7,label:"41.7 kHz"},{value:62.5,label:"62.5 kHz"},{value:125,label:"125 kHz"},{value:250,label:"250 kHz"},{value:500,label:"500 kHz"}],Qt=[5,6,7,8,9,10,11,12],Zt=[{value:5,label:"4/5"},{value:6,label:"4/6"},{value:7,label:"4/7"},{value:8,label:"4/8"}],Ps={RADIO_CONFIG:"radioConfig"};function ea(a){if(!a)return"Never";const r=Date.now()-a*1e3,f=Math.floor(r/6e4),o=Math.floor(r/36e5),d=Math.floor(r/864e5);return f<1?"Just now":f<60?`${f}m ago`:o<24?`${o}h ago`:d<365?`${d}d ago`:`${Math.floor(d/365)}y ago`}function Ms({node:a,level:c,expandedKeys:r,selectedKeyId:f,globalFloodPolicy:o,onSelect:d,onToggle:N}){const u=r.has(a.id),g=f===a.id,i=a.children&&a.children.length>0,n=o==="allow";return e.jsxs("div",{children:[e.jsxs("div",{className:l("flex items-center gap-2 h-[36px] px-3 rounded-full cursor-pointer transition-colors",g?"bg-sys-blue/15":"hover:bg-subtle-fill",n&&"opacity-50 cursor-not-allowed"),style:{marginLeft:`${c*16}px`},onClick:()=>!n&&d(a.id),children:[i?e.jsx("button",{onClick:h=>{h.stopPropagation(),N(a.id)},className:"p-1 hover:bg-subtle-fill-hover rounded-full transition-colors",children:e.jsx(Pt,{className:l("w-3.5 h-3.5 text-fg-muted transition-transform",u&&"rotate-90")})}):e.jsx("span",{className:"w-5"}),e.jsx(Kt,{className:"w-4 h-4 text-sys-blue flex-shrink-0"}),e.jsx("span",{className:"type-data text-fg-primary flex-1 truncate",children:a.name}),e.jsx("span",{className:"type-data-xs text-fg-muted hidden sm:inline",title:a.last_used?new Date(a.last_used*1e3).toLocaleString():void 0,children:ea(a.last_used)}),e.jsx("span",{className:l("type-data-xs px-2 py-0.5 rounded-full",a.floodPolicy==="allow"?"bg-sys-green/15 text-sys-green":"bg-sys-red/15 text-sys-red"),children:a.floodPolicy==="allow"?"Allow":"Deny"})]}),i&&u&&e.jsx("div",{children:a.children.map(h=>e.jsx(Ms,{node:h,level:c+1,expandedKeys:r,selectedKeyId:f,globalFloodPolicy:o,onSelect:d,onToggle:N},h.id))})]})}function sa(){const[a,c]=t.useState(Nt),[r,f]=t.useState(kt),[o,d]=t.useState(!1),N=t.useCallback(i=>{c(i),wt(i)},[]),u=t.useCallback(i=>{const n=parseFloat(i.target.value);f(n),Ct(n)},[]),g=t.useCallback(async()=>{o||(d(!0),await St(),d(!1))},[o]);return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx(ie,{enabled:a,onChange:N,label:e.jsxs(e.Fragment,{children:["Sound: ",e.jsx("span",{className:a?"text-sys-green":"text-sys-red",children:a?"On":"Off"})]}),tooltip:"Enable or disable UI sound effects and haptic audio feedback",size:"md"}),e.jsx(F,{color:"primary",outline:!0,onClick:g,disabled:!a||o,className:"w-16 justify-center",children:o?"…":"Test"})]}),e.jsxs("div",{className:l("flex items-center gap-3",!a&&"opacity-40 pointer-events-none"),children:[e.jsx("span",{className:"type-label text-fg-muted w-14 shrink-0",children:"Volume"}),e.jsx("input",{type:"range",min:0,max:1,step:.05,value:r,onChange:u,className:"flex-1 accent-sys-blue h-1.5 cursor-pointer"}),e.jsxs("span",{className:"data-box w-16 justify-center",children:[Math.round(r*100),"%"]})]})]})}function ya(){var vs,Ns,ks,ws,Cs,Ss;const{stats:a,setMode:c,clearModeMutation:r,setDutyCycleConfig:f,clearDutyCycleMutation:o,fetchStats:d,startMutation:N,clearMutation:u}=at(),g=nt(),i=(vs=a==null?void 0:a.config)==null?void 0:vs.radio,n=(Ns=a==null?void 0:a.config)==null?void 0:Ns.repeater,h=(ks=a==null?void 0:a.config)==null?void 0:ks.duty_cycle,T=(a==null?void 0:a.node_name)||((ws=a==null?void 0:a.config)==null?void 0:ws.node_name)||"Unknown Node",p=(n==null?void 0:n.mode)??"forward",P=(h==null?void 0:h.enforcement_enabled)??!1,w=(Cs=a==null?void 0:a.config)==null?void 0:Cs.delays,k=t.useRef(!0);t.useEffect(()=>(k.current=!0,()=>{k.current=!1}),[]);const y=(Ss=a==null?void 0:a.config)==null?void 0:Ss.web,[E,b]=t.useState([]),[z,O]=t.useState(!1),[v,_]=t.useState(null),[I,A]=t.useState(!1),[S,m]=t.useState(""),[K,C]=t.useState(null),[G,ge]=t.useState(!1),[ae,Ie]=t.useState(null),[Pe,ts]=t.useState(!1),[as,ns]=t.useState(!1),[ls,rs]=t.useState(!1),[U,As]=t.useState([]),[Ks,is]=t.useState(!1),[os,D]=t.useState(null),[Q,Ls]=t.useState(()=>localStorage.getItem("pymc:globalFloodPolicy")==="allow"?"allow":"deny"),cs=t.useCallback(s=>{Ls(s),localStorage.setItem("pymc:globalFloodPolicy",s)},[]),[ds,us]=t.useState(!1),[L,De]=t.useState(null),[zs,Os]=t.useState(new Set),[be,me]=t.useState(!1),[je,ne]=t.useState(!1),[ve,le]=t.useState(!1),[M,W]=t.useState(null),[Z,xe]=t.useState(null),[Ne,ke]=t.useState(""),[Me,fe]=t.useState("allow"),[q,re]=t.useState(!1),[we,ms]=t.useState(!0),[he,Ae]=t.useState(!1),[Vs,xs]=t.useState(!0),[pe,ee]=t.useState("idle"),[Hs,Ke]=t.useState(!1),[Le,$s]=t.useState(!1),fs=t.useCallback(()=>{const s=w==null?void 0:w.tx_delay_factor;return s&&typeof s=="object"&&"parsedValue"in s?s.parsedValue??1:typeof s=="number"?s:1},[w]),hs=t.useCallback(()=>{const s=w==null?void 0:w.direct_tx_delay_factor;return typeof s=="number"?s:.5},[w]),ze=t.useCallback(()=>{const s=h==null?void 0:h.max_airtime_percent;return typeof s=="number"?s:s&&typeof s=="object"&&"parsedValue"in s?s.parsedValue??6:6},[h]),Oe=Je(p==="forward",async s=>{await c(s?"forward":"monitor")},r),Ve=Je(P,async s=>{await f({max_airtime_percent:ze(),enforcement_enabled:s})},o),He=Je((y==null?void 0:y.cors_enabled)??!1,async s=>{var j;const x=await Rs({web:{cors_enabled:s}});if(!x.success&&!((j=x.data)!=null&&j.persisted))throw new Error("CORS update failed");await d()}),V=t.useCallback(async s=>{N(Ps.RADIO_CONFIG);try{const x=await lt(s);if(!x.success)throw new Error(x.error||"Failed to save");await d({force:!0}).catch(()=>{})}finally{u(Ps.RADIO_CONFIG)}},[N,u,d]);t.useEffect(()=>{(async()=>{xs(!0);try{const x=await ft();x.success&&x.data?Ae(x.data.exists):Ae(!1);const j=y==null?void 0:y.web_path;ms(!j||j==="")}catch{Ae(!1)}finally{xs(!1)}})()},[y==null?void 0:y.web_path]);const ps=async s=>{var x;if(pe!=="loading"){ee("loading");try{const j=await Rs({web:{web_path:s?null:"/opt/pymc_console/web/html"}});if(!k.current)return;j.success||(x=j.data)!=null&&x.persisted?(ms(s),ee("success"),Ke(!0),setTimeout(()=>{k.current&&ee("idle")},2e3)):(ee("error"),setTimeout(()=>{k.current&&ee("idle")},2e3))}catch{if(!k.current)return;ee("error"),setTimeout(()=>{k.current&&ee("idle")},2e3)}}},qs=async()=>{if(!Le){$s(!0);try{await ht(),Ke(!1),setTimeout(()=>{window.location.reload()},2e3)}catch{Ke(!1),setTimeout(()=>{window.location.reload()},3e3)}}},Ce=t.useCallback(async()=>{O(!0),_(null);try{const s=await qt();b(s.tokens||[])}catch(s){_(s instanceof Error?s.message:"Failed to fetch tokens")}finally{O(!1)}},[]);t.useEffect(()=>{Ce()},[Ce]);const ys=async()=>{if(!S.trim()){_("Token name is required");return}ts(!0),_(null);try{const s=await Gt(S.trim());C(s.token||null),A(!1),ge(!0),m(""),await Ce()}catch(s){_(s instanceof Error?s.message:"Failed to create token")}finally{ts(!1)}},Gs=async()=>{if(ae){ns(!0),_(null);try{await Bt(ae.id),await Ce(),Ie(null)}catch(s){_(s instanceof Error?s.message:"Failed to revoke token")}finally{ns(!1)}}},Bs=()=>{K&&(navigator.clipboard.writeText(K),rs(!0),setTimeout(()=>rs(!1),2e3))},gs=s=>s?new Date(s*1e3).toLocaleString():"Never",bs=t.useCallback(s=>{const x=new Map,j=[];return s.forEach(R=>{const Se={id:R.id,name:R.name,floodPolicy:R.flood_policy,transport_key:R.transport_key,last_used:R.last_used,parent_id:R.parent_id,children:[]};x.set(R.id,Se)}),x.forEach(R=>{R.parent_id&&x.has(R.parent_id)?x.get(R.parent_id).children.push(R):j.push(R)}),j},[]),ye=t.useCallback(async()=>{is(!0),D(null);try{const s=await mt();if(s.success&&s.data){const x=bs(s.data);As(x),De(j=>{if(j===null)return null;const R=Se=>{for(const $e of Se)if($e.id===j||$e.children&&R($e.children))return!0;return!1};return R(x)?j:null})}else D(s.error||"Failed to load transport keys")}catch(s){D(s instanceof Error?s.message:"Unknown error occurred")}finally{is(!1)}},[bs]);t.useEffect(()=>{ye(),xt().then(s=>{s.success&&s.data&&cs(s.data.global_flood_allow?"allow":"deny")}).catch(()=>{})},[ye]);const se=t.useCallback((s,x)=>{for(const j of s){if(j.id===x)return j;if(j.children){const R=se(j.children,x);if(R)return R}}return null},[]),Us=t.useCallback(()=>{if(!L)return;const s=se(U,L);return s==null?void 0:s.name},[L,U,se]),Ws=t.useCallback(s=>{Os(x=>{const j=new Set(x);return j.has(s)?j.delete(s):j.add(s),j})},[]),Xs=async s=>{us(!0),D(null);try{const x=await pt(s==="allow");x.success?cs(s):D(x.error||"Failed to update global flood policy")}catch(x){D(x instanceof Error?x.message:"Failed to update global flood policy")}finally{us(!1)}},js=async()=>{if(!Ne.trim()){D("Key name is required");return}re(!0),D(null);try{const s=await yt({name:Ne.trim(),flood_policy:Me,parent_id:L??void 0});s.success?(await ye(),me(!1),ke(""),fe("allow")):D(s.error||"Failed to add transport key")}catch(s){D(s instanceof Error?s.message:"Failed to add transport key")}finally{re(!1)}},Ys=async()=>{if(M){re(!0),D(null);try{const s=await gt(M.id,{name:M.name,flood_policy:M.floodPolicy});s.success?(await ye(),ne(!1),W(null)):D(s.error||"Failed to update transport key")}catch(s){D(s instanceof Error?s.message:"Failed to update transport key")}finally{re(!1)}}},Js=async()=>{if(Z){re(!0),D(null);try{const s=await bt(Z.id);s.success?(await ye(),le(!1),xe(null),De(null)):D(s.error||"Failed to delete transport key")}catch(s){D(s instanceof Error?s.message:"Failed to delete transport key")}finally{re(!1)}}},Qs=t.useCallback(()=>{if(!L)return;const s=se(U,L);s&&(W({...s}),ne(!0))},[L,U,se]);t.useEffect(()=>{const s=j=>{j.key==="Escape"&&(be&&(me(!1),ke(""),fe("allow")),je&&(ne(!1),W(null)),ve&&(le(!1),xe(null)),I&&(A(!1),m("")),G&&(ge(!1),C(null)))};if(be||je||ve||I||G)return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[be,je,ve,I,G]);const Zs=t.useCallback(()=>{if(!L)return;const s=se(U,L);s&&(xe(s),le(!0))},[L,U,se]);return e.jsxs(Tt,{children:[e.jsx(_t,{title:"Configuration",icon:e.jsx(_s,{})}),e.jsxs(Ft,{ready:g,children:[e.jsxs(te,{template:"standard",children:[e.jsx(_e,{span:12,md:6,children:e.jsxs(Y,{neomorphic:!0,children:[e.jsx(X,{icon:e.jsx(rt,{}),title:"Repeater Settings"}),n?e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx("div",{className:"col-span-2",children:e.jsx(H,{label:"Node Name",value:T,onSave:async s=>V({node_name:s}),placeholder:"Enter node name",maxLength:50})}),e.jsx(H,{label:"Latitude",value:n.latitude!==0?n.latitude.toFixed(6):"Not set",editValue:String(n.latitude),type:"number",suffix:"°",step:1e-6,min:-90,max:90,onSave:async s=>V({latitude:parseFloat(s)})}),e.jsx(H,{label:"Longitude",value:n.longitude!==0?n.longitude.toFixed(6):"Not set",editValue:String(n.longitude),type:"number",suffix:"°",step:1e-6,min:-180,max:180,onSave:async s=>V({longitude:parseFloat(s)})}),e.jsx(H,{label:"Advert Interval",value:n.send_advert_interval_hours>0?`${n.send_advert_interval_hours}h`:"Disabled",editValue:String(n.send_advert_interval_hours),type:"number",suffix:"hours",min:0,max:48,description:"0 = disabled, 3-48 hours",onSave:async s=>V({flood_advert_interval_hours:parseInt(s,10)})}),e.jsx(H,{label:"Score-based TX",value:n.use_score_for_tx?"Enabled":"Disabled",readOnly:!0})]}):e.jsx("p",{className:"text-fg-muted",children:"Loading repeater settings..."})]})}),e.jsx(_e,{span:12,md:6,children:e.jsxs(Y,{neomorphic:!0,children:[e.jsx(X,{icon:e.jsx(Et,{}),title:"Radio Configuration"}),i?e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(H,{label:"Frequency",value:it(i.frequency),editValue:(i.frequency/1e6).toFixed(3),type:"number",suffix:"MHz",step:.001,min:400,max:930,onSave:async s=>V({frequency_mhz:parseFloat(s)})}),e.jsx(H,{label:"TX Power",value:`${i.tx_power} dBm`,editValue:String(i.tx_power),type:"number",suffix:"dBm",min:2,max:30,onSave:async s=>V({tx_power:parseInt(s,10)})}),e.jsx(Ue,{label:"Bandwidth",value:ot(i.bandwidth),editValue:i.bandwidth/1e3,options:Jt,onSave:async s=>V({bandwidth_khz:parseFloat(s)})}),e.jsx(Ue,{label:"Spreading Factor",value:`SF${i.spreading_factor}`,editValue:i.spreading_factor,options:Qt.map(s=>({value:s,label:`SF${s}`})),onSave:async s=>V({spreading_factor:parseInt(s,10)})}),e.jsx(Ue,{label:"Coding Rate",value:`4/${i.coding_rate}`,editValue:i.coding_rate,options:Zt,onSave:async s=>V({coding_rate:parseInt(s,10)})}),e.jsx(H,{label:"Preamble",value:`${i.preamble_length} symbols`,readOnly:!0})]}):e.jsx("p",{className:"text-fg-muted",children:"Loading radio configuration..."})]})})]}),e.jsxs(te,{template:"standard",children:[e.jsx(_e,{span:12,md:6,children:e.jsxs(Y,{neomorphic:!0,children:[e.jsx(X,{icon:e.jsx(ct,{}),title:"Operating Mode"}),e.jsx("p",{className:"type-label text-fg-muted mb-3",children:"Control how the repeater handles packets"}),e.jsxs("div",{className:"flex flex-col lg:flex-row gap-4",children:[e.jsxs("div",{className:"flex-1 space-y-4",children:[e.jsx(ie,{enabled:Oe.enabled,onChange:Oe.toggle,label:"Repeat",tooltip:"Toggles repeater or monitor mode. In monitor mode, the repeater will not repeat packets from the mesh.",status:Oe.status,size:"md"}),e.jsx(ie,{enabled:Ve.enabled,onChange:Ve.toggle,label:"Duty Cycle",tooltip:"Limit transmission time to comply with airtime utilization regulations",status:Ve.status,size:"md"}),e.jsx(H,{label:"Max Airtime",layout:"inline",value:`${ze().toFixed(1)}%`,editValue:String(ze()),type:"number",suffix:"%",step:.5,min:.1,max:100,onSave:async s=>{await f({max_airtime_percent:parseFloat(s),enforcement_enabled:P}),o()}})]}),e.jsx("div",{className:"hidden lg:block w-px bg-border-subtle"}),e.jsxs("div",{className:"flex-1 pt-4 lg:pt-0 border-t lg:border-t-0 border-edge-subtle",children:[e.jsx("label",{className:"type-label text-fg-muted block mb-3",children:"TX Delays"}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(H,{label:"Flood",layout:"inline",value:`${fs().toFixed(2)}x`,editValue:String(fs()),type:"number",suffix:"x",step:.1,min:0,max:5,onSave:async s=>V({tx_delay_factor:parseFloat(s)})}),e.jsx(H,{label:"Direct",layout:"inline",value:`${hs().toFixed(2)}s`,editValue:String(hs()),type:"number",suffix:"s",step:.1,min:0,max:5,onSave:async s=>V({direct_tx_delay_factor:parseFloat(s)})})]})]})]})]})}),e.jsx(_e,{span:12,md:6,children:e.jsxs(Y,{neomorphic:!0,children:[e.jsx(X,{icon:e.jsx(_s,{}),title:"App Settings"}),e.jsx("p",{className:"type-body-sm text-fg-muted mb-4",children:"Appearance and web server options."}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(ie,{enabled:He.enabled,onChange:He.toggle,label:"Enable CORS",tooltip:"Allow cross-origin API access",status:He.status,size:"md"}),e.jsx("div",{children:e.jsx(Wt,{})}),e.jsx(sa,{})]})]})})]}),e.jsx(te,{template:"auto",children:e.jsxs(Y,{neomorphic:!0,children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3 mb-4",children:[e.jsx(X,{icon:e.jsx(Es,{}),title:"Regions Transport Keys",subtitle:"Manage regional key hierarchy for flood control"}),e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsxs(F,{color:"primary",outline:!0,onClick:()=>me(!0),disabled:Q==="allow",children:[e.jsx(Fs,{"data-slot":"icon"}),"Add"]}),e.jsx(F,{color:"primary",outline:!0,onClick:Qs,disabled:!L||Q==="allow",children:"Edit"}),e.jsx(F,{color:"danger",outline:!0,onClick:Zs,disabled:!L||Q==="allow",children:"Delete"})]})]}),e.jsx("div",{className:"bg-subtle-fill radius-inner p-4 mb-4",children:e.jsx(ie,{enabled:Q==="deny",onChange:s=>Xs(s?"deny":"allow"),label:e.jsxs(e.Fragment,{children:["Require Transport Keys: ",e.jsx("span",{className:Q==="deny"?"text-sys-green":"text-sys-red",children:Q==="deny"?"On":"Off"})]}),tooltip:"When enabled, only packets with matching transport keys are forwarded. When disabled, all packets flood freely.",status:ds?"loading":"idle",disabled:ds,dangerOff:!0,size:"md",className:"flex-row-reverse justify-between w-full"})}),os&&e.jsx("div",{className:"type-body-sm mb-3 px-3 py-2 rounded-full text-sys-red bg-sys-red/10",children:os}),e.jsx("div",{className:"bg-subtle-fill radius-inner p-4 min-h-[120px]",children:Ks?e.jsxs("div",{className:"flex items-center justify-center py-6",children:[e.jsx($,{className:"w-5 h-5 animate-spin text-sys-blue mr-2"}),e.jsx("span",{className:"type-body-sm text-fg-muted",children:"Loading transport keys..."})]}):U.length===0?e.jsxs("div",{className:"text-center py-6",children:[e.jsx("div",{className:"w-12 h-12 rounded-full bg-subtle-fill mx-auto mb-3 flex items-center justify-center",children:e.jsx(Es,{className:"w-6 h-6 text-fg-muted/50"})}),e.jsx("p",{className:"type-body text-fg-muted",children:"No transport keys found"}),e.jsx("p",{className:"type-body-sm text-fg-muted/70 mt-1",children:"Add your first transport key to get started"})]}):e.jsx("div",{className:"space-y-1",children:U.map(s=>e.jsx(Ms,{node:s,level:0,expandedKeys:zs,selectedKeyId:L,globalFloodPolicy:Q,onSelect:De,onToggle:Ws},s.id))})})]})}),e.jsx(te,{template:"auto",children:e.jsxs(Y,{neomorphic:!0,children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3 mb-4",children:[e.jsx(X,{icon:e.jsx(Ge,{}),title:"API Tokens",subtitle:"Manage API tokens for machine-to-machine authentication"}),e.jsxs(F,{color:"primary",outline:!0,onClick:()=>A(!0),children:[e.jsx(Fs,{"data-slot":"icon"}),"Create Token"]})]}),e.jsx("div",{className:"bg-sys-blue/5 radius-inner p-4 mb-4",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-sys-blue/20 flex items-center justify-center flex-shrink-0",children:e.jsx(Ze,{className:"w-4 h-4 text-sys-blue"})}),e.jsxs("div",{className:"type-body-sm text-fg-muted",children:[e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-secondary",children:"API tokens"})," are used for machine-to-machine authentication. Include the token in the ",e.jsx("code",{className:"type-code bg-sys-blue/20 px-1.5 py-0.5 rounded-full text-sys-blue",children:"X-API-Key"})," header when making API requests."]}),e.jsx("p",{className:"mt-1 text-fg-muted/70",children:"Tokens are only shown once at creation. Store them securely."})]})]})}),v&&e.jsx("div",{className:"type-body-sm mb-3 px-3 py-2 rounded-full text-sys-red bg-sys-red/10",children:v}),z&&E.length===0?e.jsxs("div",{className:"flex items-center justify-center py-6",children:[e.jsx($,{className:"w-5 h-5 animate-spin text-sys-blue mr-2"}),e.jsx("span",{className:"type-body-sm text-fg-muted",children:"Loading tokens..."})]}):E.length>0?e.jsx("div",{className:"space-y-2",children:E.map(s=>e.jsx("div",{className:"bg-subtle-fill hover:bg-subtle-fill-strong radius-inner p-4 transition-base",children:e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:[e.jsx("div",{className:"w-10 h-10 rounded-full bg-sys-blue/10 flex items-center justify-center flex-shrink-0",children:e.jsx(Ge,{className:"w-5 h-5 text-sys-blue"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h3",{className:"type-body text-fg-primary font-medium truncate",children:s.name}),e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:gap-4 mt-0.5",children:[e.jsxs("span",{className:"type-data-sm text-fg-muted truncate",children:["Created: ",gs(s.created_at)]}),e.jsxs("span",{className:"type-data-sm text-fg-muted truncate",children:["Last used: ",gs(s.last_used)]})]})]})]}),e.jsxs(F,{color:"danger",outline:!0,onClick:()=>Ie({id:s.id,name:s.name}),disabled:as,children:[e.jsx(Ds,{"data-slot":"icon"}),"Revoke"]})]})},s.id))}):e.jsxs("div",{className:"bg-subtle-fill radius-inner p-6 text-center",children:[e.jsx("div",{className:"w-14 h-14 rounded-full bg-subtle-fill mx-auto mb-4 flex items-center justify-center",children:e.jsx(Ge,{className:"w-7 h-7 text-fg-muted/50"})}),e.jsx("h3",{className:"type-body text-fg-primary font-medium mb-1",children:"No API Tokens"}),e.jsx("p",{className:"type-body-sm text-fg-muted mb-4",children:"Create a token to enable API access"}),e.jsx(F,{color:"primary",outline:!0,onClick:()=>A(!0),children:"Create Your First Token"})]})]})}),e.jsx(te,{template:"auto",children:e.jsxs(Y,{neomorphic:!0,children:[e.jsx(X,{icon:e.jsx(Ot,{}),title:"Web Frontend",subtitle:"Choose which web interface to use",className:"mb-4"}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsxs("label",{className:l("flex items-start gap-3 p-4 bg-subtle-fill radius-card border-2 cursor-pointer transition-base",we?"border-sys-blue bg-sys-blue/5":"border-transparent hover:border-sys-blue/30",pe==="loading"&&"opacity-50 pointer-events-none"),children:[e.jsx("input",{type:"radio",name:"frontend",checked:we,onChange:()=>ps(!0),disabled:pe==="loading",className:"mt-1 h-4 w-4 text-sys-blue focus:ring-sys-blue focus:ring-offset-bg-elevated"}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"type-body text-fg-primary font-medium",children:"Default Frontend"}),e.jsx("a",{href:"https://github.com/rightup/pyMC_Repeater",target:"_blank",rel:"noopener noreferrer",onClick:s=>s.stopPropagation(),className:"type-data-xs bg-sys-cyan/15 text-sys-cyan px-2.5 py-0.5 rounded-full font-medium hover:bg-sys-cyan/25 transition-colors",children:"@RightUp"})]}),e.jsx("div",{className:"type-body-sm text-fg-muted mt-1",children:"Built-in pyMC Repeater web interface"}),e.jsx("div",{className:"type-data-xs text-fg-muted/60 mt-1",children:"/opt/pymc_repeater/repeater/web/html"})]})]}),e.jsxs("label",{className:l("flex items-start gap-3 p-4 bg-subtle-fill radius-card border-2 cursor-pointer transition-base",we?"border-transparent hover:border-sys-blue/30":"border-sys-blue bg-sys-blue/5",pe==="loading"&&"opacity-50 pointer-events-none"),children:[e.jsx("input",{type:"radio",name:"frontend",checked:!we,onChange:()=>ps(!1),disabled:pe==="loading",className:"mt-1 h-4 w-4 text-sys-blue focus:ring-sys-blue focus:ring-offset-bg-elevated"}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"type-body text-fg-primary font-medium",children:"PyMC Console"}),e.jsx("span",{className:"type-data-xs bg-sys-indigo/15 text-sys-indigo px-2.5 py-0.5 rounded-full font-medium",children:"@Treehouse ⚡"})]}),e.jsx("div",{className:"type-body-sm text-fg-muted mt-1",children:"Alternative web interface for pyMC Repeater"}),e.jsx("div",{className:"type-data-xs text-fg-muted/60 mt-1",children:"/opt/pymc_console/web/html"})]})]})]}),!Vs&&e.jsx("div",{className:l("bg-subtle-fill radius-card p-4",he?"border border-sys-green/20":"border border-sys-cyan/20"),children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:l("w-8 h-8 rounded-full flex items-center justify-center flex-shrink-0",he?"bg-sys-green/20":"bg-sys-cyan/20"),children:he?e.jsx(Rt,{className:"w-4 h-4 text-sys-green"}):e.jsx(Ze,{className:"w-4 h-4 text-sys-cyan"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h4",{className:"type-body text-fg-primary font-medium",children:he?"PyMC Console has been detected":"PyMC Console Not Installed"}),he?e.jsxs("p",{className:"type-body-sm text-fg-muted mt-1",children:["PyMC Console is installed at ",e.jsx("code",{className:"type-code bg-sys-green/10 px-1.5 py-0.5 rounded-full text-sys-green",children:"/opt/pymc_console/web/html"})]}):e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"type-body-sm text-fg-muted mt-1 mb-3",children:["PyMC Console must be installed at ",e.jsx("code",{className:"type-code bg-sys-cyan/10 px-1.5 py-0.5 rounded-full text-sys-cyan",children:"/opt/pymc_console/web/html"})," before selecting this option."]}),e.jsxs(F,{color:"primary",outline:!0,href:"https://github.com/dmduran12/pymc_console-dist",children:[e.jsx(Mt,{"data-slot":"icon"}),"PyMC Console Install Instructions"]})]})]})]})}),Hs&&e.jsx("div",{className:"bg-subtle-fill radius-card p-4 border border-sys-indigo/30",children:e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3",children:[e.jsxs("div",{className:"flex items-start gap-3 flex-1",children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-sys-indigo/20 flex items-center justify-center flex-shrink-0",children:e.jsx(Be,{className:"w-4 h-4 text-sys-indigo"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h4",{className:"type-body text-fg-primary font-medium",children:"Service restart required"}),e.jsx("p",{className:"type-body-sm text-fg-muted mt-1",children:"Web frontend changes will take effect after restarting the pymc-repeater service."})]})]}),e.jsx(F,{color:"warning",outline:!0,onClick:qs,disabled:Le,children:Le?e.jsxs(e.Fragment,{children:[e.jsx($,{"data-slot":"icon",className:"animate-spin"}),"Restarting..."]}):e.jsxs(e.Fragment,{children:[e.jsx(It,{"data-slot":"icon"}),"Restart Now"]})})]})})]})]})}),a&&e.jsx(te,{template:"auto",children:e.jsx(vt,{nodeName:T,repeaterVersion:a.version,coreVersion:a.core_version,localHash:a.local_hash,publicKey:a.public_key})}),a&&((n==null?void 0:n.latitude)===0||!(n!=null&&n.latitude))&&((n==null?void 0:n.longitude)===0||!(n!=null&&n.longitude))&&e.jsx(te,{template:"auto",children:e.jsx(Yt,{})})]}),I&&e.jsx("div",{className:"fixed inset-0 z-[10010] flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm",onClick:s=>s.target===s.currentTarget&&A(!1),role:"dialog","aria-modal":"true","aria-labelledby":"create-token-modal-title",children:e.jsxs("div",{className:"surface-modal radius-card p-6 max-w-md w-full",children:[e.jsx("h3",{id:"create-token-modal-title",className:"type-micro mb-4",children:"Create API Token"}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(qe,{label:"Token Name",type:"text",value:S,onChange:s=>m(s.target.value),placeholder:"e.g., Production Server, CI/CD Pipeline",description:"Give your token a descriptive name to identify its purpose",onKeyDown:s=>s.key==="Enter"&&ys(),autoFocus:!0}),e.jsxs("div",{className:"flex justify-end gap-3 mt-6",children:[e.jsx(F,{color:"muted",outline:!0,onClick:()=>{A(!1),m(""),_(null)},disabled:Pe,children:"Cancel"}),e.jsx(F,{color:"primary",onClick:ys,disabled:Pe||!S.trim(),children:Pe?e.jsxs(e.Fragment,{children:[e.jsx($,{"data-slot":"icon",className:"animate-spin"}),"Creating..."]}):"Create Token"})]})]})]})}),G&&K&&e.jsx("div",{className:"fixed inset-0 z-[10010] flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm",onClick:s=>s.target===s.currentTarget&&ge(!1),role:"dialog","aria-modal":"true","aria-labelledby":"show-token-modal-title",children:e.jsxs("div",{className:"surface-modal radius-card p-6 max-w-lg w-full",children:[e.jsx("h3",{id:"show-token-modal-title",className:"type-micro mb-4",children:"Token Created Successfully"}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"bg-sys-indigo/10 border border-sys-indigo/30 radius-inner p-3",children:e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Be,{className:"w-4 h-4 text-sys-indigo flex-shrink-0 mt-0.5"}),e.jsxs("div",{className:"text-sm text-fg-secondary",children:[e.jsx("strong",{children:"Save this token now!"})," For security reasons, it will not be shown again."]})]})}),e.jsxs("div",{children:[e.jsx("label",{className:"type-label text-fg-primary block mb-1.5",children:"Your API Token"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(dt,{value:K,readOnly:!0,className:"flex-1 font-mono"}),e.jsxs(F,{color:"primary",outline:!0,onClick:Bs,children:[ls?e.jsx(B,{"data-slot":"icon",className:"text-sys-green"}):e.jsx(ut,{"data-slot":"icon"}),ls?"Copied!":"Copy"]})]})]}),e.jsxs("div",{className:"bg-sys-cyan/10 border border-sys-cyan/30 radius-inner p-3",children:[e.jsx("p",{className:"text-sm text-fg-secondary mb-2",children:e.jsx("strong",{children:"Usage Example:"})}),e.jsxs("code",{className:"block bg-sys-cyan/20 px-3 py-2 rounded type-code text-sys-cyan overflow-x-auto",children:['curl -H "X-API-Key: ',K.slice(0,12),'..." ',window.location.origin,"/api/stats"]})]}),e.jsx("div",{className:"flex justify-end mt-6",children:e.jsx(F,{color:"primary",onClick:()=>{ge(!1),C(null)},children:"Done"})})]})]})}),e.jsx(jt,{isOpen:!!ae,title:"Revoke API Token",message:`Are you sure you want to revoke the token '${ae==null?void 0:ae.name}'? This action cannot be undone.`,confirmLabel:as?"Revoking...":"Revoke",cancelLabel:"Cancel",variant:"danger",onConfirm:Gs,onCancel:()=>Ie(null)}),be&&e.jsx("div",{className:"fixed inset-0 z-[10010] flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm",onClick:s=>s.target===s.currentTarget&&me(!1),role:"dialog","aria-modal":"true","aria-labelledby":"add-key-modal-title",children:e.jsxs("div",{className:"surface-modal radius-card p-6 max-w-md w-full",children:[e.jsx("h3",{id:"add-key-modal-title",className:"type-micro mb-4",children:"Add Transport Key"}),e.jsxs("div",{className:"space-y-4",children:[L&&e.jsxs("div",{className:"bg-sys-cyan/10 border border-sys-cyan/30 radius-inner p-3 text-sm text-fg-secondary",children:["Adding as child of: ",e.jsx("strong",{className:"text-fg-primary",children:Us()})]}),e.jsx(qe,{label:"Key Name",type:"text",value:Ne,onChange:s=>ke(s.target.value),placeholder:"e.g., Region Name, Group Key",onKeyDown:s=>s.key==="Enter"&&js(),autoFocus:!0}),e.jsxs("div",{children:[e.jsx("label",{className:"type-label text-fg-muted block mb-2",children:"Flood Policy"}),e.jsxs("div",{className:"toggle-group w-full",children:[e.jsx("button",{onClick:()=>fe("deny"),className:l("toggle-group-item flex-1",Me==="deny"&&"active !text-sys-red"),children:"Deny"}),e.jsx("button",{onClick:()=>fe("allow"),className:l("toggle-group-item flex-1",Me==="allow"&&"active !text-sys-green"),children:"Allow"})]})]}),e.jsxs("div",{className:"flex justify-end gap-3 mt-6",children:[e.jsx(F,{color:"muted",outline:!0,onClick:()=>{me(!1),ke(""),fe("allow")},disabled:q,children:"Cancel"}),e.jsx(F,{color:"primary",onClick:js,disabled:q||!Ne.trim(),children:q?e.jsxs(e.Fragment,{children:[e.jsx($,{"data-slot":"icon",className:"animate-spin"}),"Adding..."]}):"Add Key"})]})]})]})}),je&&M&&e.jsx("div",{className:"fixed inset-0 z-[10010] flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm",onClick:s=>s.target===s.currentTarget&&ne(!1),role:"dialog","aria-modal":"true","aria-labelledby":"edit-key-modal-title",children:e.jsxs("div",{className:"surface-modal radius-card p-6 max-w-md w-full",children:[e.jsx("h3",{id:"edit-key-modal-title",className:"type-micro mb-4",children:"Edit Transport Key"}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(qe,{label:"Key Name",type:"text",value:M.name,onChange:s=>W({...M,name:s.target.value}),autoFocus:!0}),e.jsxs("div",{children:[e.jsx("label",{className:"type-label text-fg-muted block mb-2",children:"Flood Policy"}),e.jsxs("div",{className:"toggle-group w-full",children:[e.jsx("button",{onClick:()=>W({...M,floodPolicy:"deny"}),className:l("toggle-group-item flex-1",M.floodPolicy==="deny"&&"active !text-sys-red"),children:"Deny"}),e.jsx("button",{onClick:()=>W({...M,floodPolicy:"allow"}),className:l("toggle-group-item flex-1",M.floodPolicy==="allow"&&"active !text-sys-green"),children:"Allow"})]})]}),M.transport_key&&e.jsxs("div",{children:[e.jsx("label",{className:"type-label text-fg-muted block mb-2",children:"Transport Key"}),e.jsx("code",{className:"block bg-input-bg px-3 py-2 radius-inner border border-input-border type-code text-fg-muted overflow-x-auto",children:M.transport_key})]}),e.jsxs("div",{className:"flex justify-between gap-3 mt-6",children:[e.jsx(F,{color:"danger",outline:!0,onClick:()=>{ne(!1),xe(M),le(!0),W(null)},disabled:q,children:"Delete"}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx(F,{color:"muted",outline:!0,onClick:()=>{ne(!1),W(null)},disabled:q,children:"Cancel"}),e.jsx(F,{color:"primary",onClick:Ys,disabled:q||!M.name.trim(),children:q?e.jsxs(e.Fragment,{children:[e.jsx($,{"data-slot":"icon",className:"animate-spin"}),"Saving..."]}):"Save"})]})]})]})]})}),ve&&Z&&e.jsx("div",{className:"fixed inset-0 z-[10010] flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm",onClick:s=>s.target===s.currentTarget&&le(!1),role:"dialog","aria-modal":"true","aria-labelledby":"delete-key-modal-title",children:e.jsxs("div",{className:"surface-modal radius-card p-6 max-w-md w-full",children:[e.jsx("h3",{id:"delete-key-modal-title",className:"type-micro mb-4",children:"Delete Transport Key"}),e.jsxs("p",{className:"text-fg-secondary mb-4",children:["Are you sure you want to delete ",e.jsxs("strong",{className:"text-fg-primary",children:["'",Z.name,"'"]}),"?"]}),Z.children&&Z.children.length>0&&e.jsx("div",{className:"bg-sys-indigo/10 border border-sys-indigo/30 radius-inner p-3 mb-4",children:e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Be,{className:"w-4 h-4 text-sys-indigo flex-shrink-0 mt-0.5"}),e.jsxs("div",{className:"text-sm text-fg-secondary",children:["This key has ",Z.children.length," child key(s). Deleting will also remove all children."]})]})}),e.jsxs("div",{className:"flex justify-end gap-3",children:[e.jsx(F,{color:"muted",outline:!0,onClick:()=>{le(!1),xe(null)},disabled:q,children:"Cancel"}),e.jsx(F,{color:"danger",onClick:Js,disabled:q,children:q?e.jsxs(e.Fragment,{children:[e.jsx($,{"data-slot":"icon",className:"animate-spin"}),"Deleting..."]}):"Delete"})]})]})})]})}export{ya as default}; diff --git a/frontend/dist/assets/Configuration-qL2GXo5a.js b/frontend/dist/assets/Configuration-qL2GXo5a.js deleted file mode 100644 index 02e51113..00000000 --- a/frontend/dist/assets/Configuration-qL2GXo5a.js +++ /dev/null @@ -1,32 +0,0 @@ -const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/latin-400-BcR6IdUc.css","assets/latin-500-DCnAHIrw.css","assets/latin-600-CnkPk-vb.css","assets/latin-700-UC1i-VSI.css"])))=>i.map(i=>d[i]); -import{d as ue,r as t,j as e,c as l,L as $,w as B,bc as J,ae as Ss,dF as Ee,dG as es,dH as Je,bo as Se,T as ie,M as Zs,S as et,dI as st,F as X,ce as Qe,bQ as tt,v as at,dJ as Ts,dK as nt,dL as lt,dM as rt,R as it,B as F,dN as $e,I as ot,x as ct}from"./index-C1ZF7cAz.js";import{g as dt,a as ut,c as mt,r as xt,s as ft,b as ht,u as pt,d as yt}from"./system-DraTG8R2.js";import{T as Ps,C as gt}from"./ConfirmModal-Cf30hpC_.js";import{N as bt}from"./NodeInformationCard-BUD0ZP9t.js";import{i as jt,g as vt,s as Nt,a as kt,k as wt}from"./keycap-sfx-ByZp-njj.js";import{C as Y,P as Ct,a as St,B as Tt}from"./PageLayout-sd81yog0.js";import{R as te,C as Te}from"./Grid-DrJ5vfLo.js";import{A as _t}from"./antenna-Bvc4sU0O.js";import{P as _s}from"./plus-BvRrZnfw.js";import{K as qe}from"./key-round-Chd2xrtI.js";import{C as Ft}from"./circle-check-DY6oislV.js";import{T as Ge}from"./triangle-alert-B3ZB2VPZ.js";import{R as Et}from"./refresh-cw-BjBvU2VX.js";import{C as Rt}from"./chevron-right-DzbDJf-i.js";import"./DataBox-BADtaCfB.js";/** - * @license lucide-react v0.559.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const It=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],Pt=ue("external-link",It);/** - * @license lucide-react v0.559.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const Dt=[["circle",{cx:"16",cy:"20",r:"2",key:"1vifvg"}],["path",{d:"M10 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v2",key:"3hgo9p"}],["path",{d:"m22 14-4.5 4.5",key:"1ef6z8"}],["path",{d:"m21 15 1 1",key:"1ejcpy"}]],Mt=ue("folder-key",Dt);/** - * @license lucide-react v0.559.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const At=[["rect",{width:"8",height:"5",x:"14",y:"17",rx:"1",key:"19aais"}],["path",{d:"M10 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v2.5",key:"1w6v7t"}],["path",{d:"M20 17v-2a2 2 0 1 0-4 0v2",key:"pwaxnr"}]],Fs=ue("folder-lock",At);/** - * @license lucide-react v0.559.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const Kt=[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21",key:"1svkeh"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21",key:"vw1qmm"}]],Lt=ue("monitor",Kt);/** - * @license lucide-react v0.559.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const zt=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]],Ze=ue("pencil",zt);/** - * @license lucide-react v0.559.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const Ot=[["path",{d:"M10.17 4.193a2 2 0 0 1 3.666.013",key:"pltmmw"}],["path",{d:"M14 21h2",key:"v4qezv"}],["path",{d:"m15.874 7.743 1 1.732",key:"10m0iw"}],["path",{d:"m18.849 12.952 1 1.732",key:"zadnam"}],["path",{d:"M21.824 18.18a2 2 0 0 1-1.835 2.824",key:"fvwuk4"}],["path",{d:"M4.024 21a2 2 0 0 1-1.839-2.839",key:"1e1kah"}],["path",{d:"m5.136 12.952-1 1.732",key:"1u4ldi"}],["path",{d:"M8 21h2",key:"i9zjee"}],["path",{d:"m8.102 7.743-1 1.732",key:"1zzo4u"}]],Vt=ue("triangle-dashed",Ot),Fe=1500,oe={stacked:"h-[38px]",inline:"h-[32px]"},ce={stacked:"px-3",inline:"px-2.5"},de="rounded-lg";function H({label:a,value:c,editValue:r,onSave:p,type:i="text",suffix:d,placeholder:v,readOnly:u=!1,layout:o="stacked",min:n,max:h,step:k,maxLength:E,description:y,className:w}){const[C,j]=t.useState(!1),[S,I]=t.useState(""),[g,A]=t.useState("idle"),O=t.useRef(null),x=t.useRef(!0),P=t.useRef(null),_=!u&&!!p;t.useEffect(()=>(x.current=!0,()=>{x.current=!1,P.current&&clearTimeout(P.current)}),[]);const L=t.useCallback(()=>{_&&(I(r??c),j(!0),A("idle"),requestAnimationFrame(()=>{var N;return(N=O.current)==null?void 0:N.select()}))},[_,r,c]),T=t.useCallback(()=>{j(!1),I(""),A("idle")},[]),m=t.useCallback(async()=>{if(!p||g==="loading")return;if(S===(r??c)){T();return}P.current&&clearTimeout(P.current),A("loading");try{if(await p(S),!x.current)return;A("success"),j(!1),P.current=setTimeout(()=>{x.current&&A("idle")},Fe)}catch{if(!x.current)return;A("error"),P.current=setTimeout(()=>{x.current&&A("idle")},Fe)}},[p,S,r,c,T,g]),z=t.useCallback(N=>{N.key==="Enter"?(N.preventDefault(),m()):N.key==="Escape"&&(N.preventDefault(),T())},[m,T]);return o==="inline"?e.jsxs("div",{className:l("group flex items-center justify-between gap-3",w),children:[e.jsx("label",{className:"type-label text-fg-muted truncate",children:a}),C?e.jsxs("div",{className:l(oe.inline,de,ce.inline,"flex items-center transition-all","bg-transparent border border-sys-blue/50 ring-1 ring-sys-blue/20","min-w-[100px]"),children:[e.jsx("input",{ref:O,type:i,value:S,onChange:N=>I(N.target.value),onKeyDown:z,placeholder:v,min:n,max:h,step:k,maxLength:E,disabled:g==="loading",className:l("bg-transparent text-fg-primary focus:outline-none type-data flex-1 min-w-0",d?"w-12 text-right":"w-full")}),d&&e.jsx("span",{className:"text-fg-muted type-data ml-1 shrink-0",children:d}),e.jsx("div",{className:"flex items-center gap-0.5 ml-2 shrink-0",children:g==="loading"?e.jsx($,{className:"w-3.5 h-3.5 text-fg-muted animate-spin"}):e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:m,className:"p-0.5 rounded hover:bg-sys-green/15 text-sys-green transition-colors",title:"Save (Enter)",children:e.jsx(B,{className:"w-3 h-3"})}),e.jsx("button",{onClick:T,className:"p-0.5 rounded hover:bg-sys-red/15 text-fg-muted hover:text-sys-red transition-colors",title:"Cancel (Esc)",children:e.jsx(J,{className:"w-3 h-3"})})]})})]}):e.jsxs("div",{className:l(oe.inline,de,ce.inline,"flex items-center justify-end transition-all min-w-[80px]","bg-input-bg border border-input-border",_&&"cursor-pointer hover:border-edge-strong"),onClick:_?L:void 0,children:[e.jsx("span",{className:"type-data text-fg-primary",children:c}),g==="success"&&e.jsx(B,{className:"w-3 h-3 text-sys-green ml-1.5 shrink-0"}),g==="error"&&e.jsx(J,{className:"w-3 h-3 text-sys-red ml-1.5 shrink-0"}),g==="idle"&&_&&e.jsx(Ze,{className:"w-3 h-3 text-fg-muted ml-1.5 opacity-0 group-hover:opacity-100 transition-opacity shrink-0"})]})]}):e.jsxs("div",{className:l("group",w),children:[e.jsx("label",{className:"type-label text-fg-muted block mb-1",children:a}),C?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:l(oe.stacked,de,ce.stacked,"flex items-center transition-all","bg-transparent border border-sys-blue/50 ring-1 ring-sys-blue/20"),children:[e.jsx("input",{ref:O,type:i,value:S,onChange:N=>I(N.target.value),onKeyDown:z,placeholder:v,min:n,max:h,step:k,maxLength:E,disabled:g==="loading",className:"w-full bg-transparent text-fg-primary focus:outline-none type-data flex-1 min-w-0"}),d&&e.jsx("span",{className:"text-fg-muted type-data ml-1 shrink-0",children:d}),e.jsx("div",{className:"flex items-center gap-0.5 ml-2 shrink-0",children:g==="loading"?e.jsx($,{className:"w-3.5 h-3.5 text-fg-muted animate-spin"}):e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:m,className:"p-1 rounded hover:bg-sys-green/15 text-sys-green transition-colors",title:"Save (Enter)",children:e.jsx(B,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:T,className:"p-1 rounded hover:bg-sys-red/15 text-fg-muted hover:text-sys-red transition-colors",title:"Cancel (Esc)",children:e.jsx(J,{className:"w-3.5 h-3.5"})})]})})]}),y&&e.jsx("p",{className:"type-data-xs text-fg-muted mt-1 ml-3",children:y})]}):e.jsxs("div",{className:l(oe.stacked,de,ce.stacked,"flex items-center transition-all","bg-input-bg border border-input-border",_&&"cursor-pointer hover:border-edge-strong"),onClick:_?L:void 0,children:[e.jsx("span",{className:"type-data text-fg-primary flex-1 whitespace-nowrap",children:c}),g==="success"&&e.jsx(B,{className:"w-3.5 h-3.5 text-sys-green shrink-0"}),g==="error"&&e.jsx(J,{className:"w-3.5 h-3.5 text-sys-red shrink-0"}),g==="idle"&&_&&e.jsx(Ze,{className:"w-3.5 h-3.5 text-fg-muted opacity-0 group-hover:opacity-100 transition-opacity shrink-0"})]})]})}function Be({label:a,value:c,editValue:r,options:p,onSave:i,readOnly:d=!1,layout:v="stacked",className:u}){const[o,n]=t.useState(!1),[h,k]=t.useState(""),[E,y]=t.useState("idle"),w=t.useRef(null),C=t.useRef(!0),j=t.useRef(null),S=!d&&!!i;t.useEffect(()=>(C.current=!0,()=>{C.current=!1,j.current&&clearTimeout(j.current)}),[]);const I=t.useCallback(()=>{S&&(k(String(r)),n(!0),y("idle"),requestAnimationFrame(()=>{var m;return(m=w.current)==null?void 0:m.focus()}))},[S,r]),g=t.useCallback(()=>{n(!1),k(""),y("idle")},[]),A=t.useCallback(async()=>{if(!(!i||E==="loading")){if(h===String(r)){g();return}j.current&&clearTimeout(j.current),y("loading");try{if(await i(h),!C.current)return;y("success"),n(!1),j.current=setTimeout(()=>{C.current&&y("idle")},Fe)}catch{if(!C.current)return;y("error"),j.current=setTimeout(()=>{C.current&&y("idle")},Fe)}}},[i,h,r,g,E]),O=t.useCallback(m=>{m.key==="Escape"&&(m.preventDefault(),g())},[g]),x=v==="inline",P=x?oe.inline:oe.stacked,_=x?ce.inline:ce.stacked,L=e.jsxs("div",{className:l(P,de,_,"flex items-center transition-all relative","bg-transparent border border-sys-blue/50 ring-1 ring-sys-blue/20",x&&"min-w-[100px]"),children:[e.jsx("select",{ref:w,value:h,onChange:m=>k(m.target.value),onKeyDown:O,disabled:E==="loading",className:l("bg-transparent text-fg-primary focus:outline-none appearance-none cursor-pointer type-data flex-1 min-w-0","pr-6"),children:p.map(m=>e.jsx("option",{value:m.value,children:m.label},String(m.value)))}),e.jsx(Ss,{className:"absolute right-auto w-3.5 h-3.5 text-fg-muted pointer-events-none",style:{right:E==="loading"?"2rem":"3.5rem"}}),e.jsx("div",{className:"flex items-center gap-0.5 ml-1 shrink-0",children:E==="loading"?e.jsx($,{className:l("text-fg-muted animate-spin",x?"w-3 h-3":"w-3.5 h-3.5")}):e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:A,className:l("rounded hover:bg-sys-green/15 text-sys-green transition-colors",x?"p-0.5":"p-1"),title:"Save",children:e.jsx(B,{className:x?"w-3 h-3":"w-3.5 h-3.5"})}),e.jsx("button",{onClick:g,className:l("rounded hover:bg-sys-red/15 text-fg-muted hover:text-sys-red transition-colors",x?"p-0.5":"p-1"),title:"Cancel (Esc)",children:e.jsx(J,{className:x?"w-3 h-3":"w-3.5 h-3.5"})})]})})]}),T=e.jsxs("div",{className:l(P,de,_,"flex items-center transition-all","bg-input-bg border border-input-border",S&&"cursor-pointer hover:border-edge-strong",x?"justify-end min-w-[80px]":""),onClick:S?I:void 0,children:[e.jsx("span",{className:l("type-data text-fg-primary",!x&&"flex-1"),children:c}),E==="success"&&e.jsx(B,{className:l("text-sys-green shrink-0",x?"w-3 h-3 ml-1.5":"w-3.5 h-3.5")}),E==="error"&&e.jsx(J,{className:l("text-sys-red shrink-0",x?"w-3 h-3 ml-1.5":"w-3.5 h-3.5")}),E==="idle"&&S&&e.jsx(Ss,{className:l("text-fg-muted opacity-0 group-hover:opacity-100 transition-opacity shrink-0",x?"w-3 h-3 ml-1.5":"w-3.5 h-3.5")})]});return x?e.jsxs("div",{className:l("group flex items-center justify-between",u),children:[e.jsx("label",{className:"type-label text-fg-muted shrink-0",children:a}),o?L:T]}):e.jsxs("div",{className:l("group",u),children:[e.jsx("label",{className:"type-label text-fg-muted block mb-1",children:a}),o?L:T]})}async function Ht(){try{return await Ee("/api/auth/tokens")}catch{return{tokens:[]}}}async function $t(a){return Ee("/api/auth/tokens",{method:"POST",body:JSON.stringify({name:a})})}async function qt(a){return Ee(`/api/auth/tokens/${a}`,{method:"DELETE"})}async function Es(a){return Ee("/api/update_web_config",{method:"POST",body:JSON.stringify(a)})}t.memo(function(){const{theme:c}=es(),{themeId:r}=c,p=Je.find(i=>i.meta.id===r)??Je[0];return e.jsx("div",{className:"h-10 flex items-center justify-center",children:e.jsx("span",{className:"font-medium transition-all duration-300 leading-none text-center text-fg-secondary",style:{fontFamily:"Inter, system-ui, sans-serif",fontSize:"clamp(0.75rem, 0.6rem + 1.5vw, 1.1rem)",letterSpacing:"-0.02em"},children:p.meta.name})})});const Ue=t.memo(function({compact:c=!1}){const{theme:r,setTheme:p}=es(),{themeId:i}=r;return e.jsx("div",{className:l("grid grid-cols-2 gap-2",c?"w-full min-w-0 self-stretch":"w-full"),children:[...Je].reverse().map(d=>{const v=i===d.meta.id,u=d.meta.isDark;return e.jsxs("button",{type:"button",title:d.meta.name,className:l("flex flex-row items-stretch radius-inner transition-all duration-200 ease-out overflow-hidden cursor-pointer",c&&"h-6",v?"ring-2 ring-sys-blue scale-[1.02]":"opacity-70 hover:opacity-100"),onClick:()=>p(d.meta.id),children:[e.jsx("div",{className:l("flex-1 h-full",u?"bg-[#18181b]":"bg-[#EFF0F1]")}),e.jsx("div",{className:"flex flex-col h-full",children:d.display.palette.map((o,n)=>e.jsx("div",{className:"flex flex-1",children:o.map((h,k)=>e.jsx("div",{className:"w-2 h-full",style:{backgroundColor:h}},k))},n))})]},d.meta.id)})})});let Rs=!1,_e=null;async function Gt(){if(!Rs)return _e||(_e=(async()=>{try{await Promise.all([Se(()=>Promise.resolve({}),__vite__mapDeps([0])),Se(()=>Promise.resolve({}),__vite__mapDeps([1])),Se(()=>Promise.resolve({}),__vite__mapDeps([2])),Se(()=>Promise.resolve({}),__vite__mapDeps([3]))]),Rs=!0}catch(a){console.warn("Failed to load theme fonts:",a)}})(),_e)}const We=t.memo(function(){const{theme:c,setTheme:r}=es(),{themeId:p}=c,i=p==="breeze dark",d=t.useCallback(v=>{r(v?"breeze dark":"breeze light")},[r]);return e.jsx(ie,{enabled:i,onChange:d,label:e.jsxs(e.Fragment,{children:["Dark Mode: ",i?e.jsx(Zs,{className:"w-3.5 h-3.5 text-sys-blue inline"}):e.jsx(et,{className:"w-3.5 h-3.5 text-[#e8a517] inline"})]}),tooltip:"Switch between dark and light mode",size:"md"})}),Bt=t.memo(function({layout:c="horizontal"}){return t.useEffect(()=>{Gt()},[]),c==="toggle-only"?e.jsx(We,{}):c==="thumbnails-only"?e.jsx(Ue,{}):c==="vertical"?e.jsxs("div",{className:"flex flex-col items-start gap-3",children:[e.jsx(We,{}),e.jsx(Ue,{})]}):e.jsxs("div",{className:"flex items-stretch gap-4",children:[e.jsx("div",{className:"flex-shrink-0 flex items-start",children:e.jsx(We,{})}),e.jsx(Ue,{compact:!0})]})}),Ut=1e4,Xe=2e3;function Ye(a,c,r){const[p,i]=t.useState("idle"),[d,v]=t.useState(null),u=t.useRef(!0),o=t.useRef(null),n=t.useRef(null),h=t.useRef(!1),k=t.useRef("idle"),E=t.useRef(a),y=t.useRef(c),w=t.useRef(r);k.current=p,E.current=a,y.current=c,w.current=r,t.useEffect(()=>(u.current=!0,()=>{u.current=!1,o.current&&clearTimeout(o.current),n.current&&clearTimeout(n.current)}),[]);const C=t.useCallback(async S=>{if(k.current==="loading")return;const I=E.current;o.current&&clearTimeout(o.current),n.current&&clearTimeout(n.current),h.current=!1,v(S),i("loading"),o.current=setTimeout(()=>{h.current||!u.current||(v(I),i("error"),n.current=setTimeout(()=>{u.current&&(i("idle"),v(null))},Xe))},Ut);try{if(await y.current(S),h.current=!0,o.current&&clearTimeout(o.current),!u.current)return;i("success"),n.current=setTimeout(()=>{var g;u.current&&(i("idle"),v(null),(g=w.current)==null||g.call(w))},Xe)}catch{if(h.current=!0,o.current&&clearTimeout(o.current),!u.current)return;v(I),i("error"),n.current=setTimeout(()=>{u.current&&(i("idle"),v(null))},Xe)}},[]);return{enabled:d!==null?d:a,status:p,toggle:C}}function Wt(){const{latitude:a,longitude:c,enabled:r,setLocation:p,enable:i,disable:d,clear:v}=st(),[u,o]=t.useState(!1),[n,h]=t.useState(""),[k,E]=t.useState(""),[y,w]=t.useState("idle"),[C,j]=t.useState(null),S=t.useRef(null),I=t.useRef(null),g=t.useRef(!0);t.useEffect(()=>(g.current=!0,()=>{g.current=!1,I.current&&clearTimeout(I.current)}),[]);const A=()=>{h((a==null?void 0:a.toFixed(6))??""),E((c==null?void 0:c.toFixed(6))??""),j(null),o(!0)},O=()=>{o(!1),j(null)};t.useEffect(()=>{if(!u)return;const m=z=>{y!=="loading"&&S.current&&!S.current.contains(z.target)&&O()};return document.addEventListener("mouseup",m),()=>document.removeEventListener("mouseup",m)},[u,y]);const x=(m,z)=>{const N=parseFloat(m),G=parseFloat(z);return isNaN(N)||isNaN(G)?"Please enter valid numbers":N<-90||N>90?"Latitude must be between -90 and 90":G<-180||G>180?"Longitude must be between -180 and 180":N===0&&G===0?"Coordinates (0, 0) are invalid":null},P=()=>{if(y==="loading")return;I.current&&clearTimeout(I.current);const m=x(n,k);if(m){j(m);return}w("loading"),j(null);const z=parseFloat(n),N=parseFloat(k);p(z,N),r||i(),w("success"),I.current=setTimeout(()=>{g.current&&(w("idle"),o(!1))},1e3)},_=()=>{r?d():i()},L=()=>{v(),o(!1)},T=a!==null&&c!==null;return e.jsx(Y,{children:e.jsxs("div",{ref:S,children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx(X,{icon:e.jsx(Vt,{}),title:"Stealth"}),e.jsxs("div",{className:"flex items-center gap-1",children:[T&&!u&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:_,className:l("relative inline-flex h-6 w-11 items-center rounded-full transition-colors border-2 mr-2",r?"bg-toggle-on border-toggle-on":"bg-toggle-off border-edge-subtle"),title:r?"Disable stealth location":"Enable stealth location",children:e.jsx("span",{className:l("inline-block h-4 w-4 transform rounded-full bg-white transition-transform shadow-lg",r?"translate-x-5":"translate-x-0.5")})}),e.jsx("button",{onClick:L,className:"p-2 rounded-lg transition-colors text-fg-muted hover:text-sys-red hover:bg-sys-red/10",title:"Clear stealth location",children:e.jsx(Ps,{className:"w-4 h-4"})})]}),u?e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:O,disabled:y==="loading",className:l("p-2 rounded-lg transition-colors",y==="loading"?"text-fg-muted cursor-not-allowed":"text-fg-muted hover:text-sys-red hover:bg-sys-red/10"),title:"Cancel",children:e.jsx(J,{className:"w-4 h-4"})}),e.jsx("button",{onClick:P,disabled:y==="loading",className:l("p-2 rounded-lg transition-colors",y==="loading"?"text-sys-blue cursor-wait":y==="success"?"text-sys-green":y==="error"?"text-sys-red":"text-sys-green hover:bg-sys-green/10"),title:"Save",children:y==="loading"?e.jsx($,{className:"w-4 h-4 animate-spin"}):y==="success"?e.jsx(B,{className:"w-4 h-4"}):y==="error"?e.jsx(J,{className:"w-4 h-4"}):e.jsx(B,{className:"w-4 h-4"})})]}):e.jsx("button",{onClick:A,className:"p-2 rounded-lg transition-colors text-fg-muted hover:text-fg-primary hover:bg-subtle",title:T?"Edit stealth location":"Set stealth location",children:e.jsx(Ze,{className:"w-4 h-4"})})]})]}),e.jsx("div",{className:"bg-sys-cyan/5 rounded-xl p-3 mb-4",children:e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Qe,{className:"w-4 h-4 text-sys-cyan flex-shrink-0 mt-0.5"}),e.jsxs("p",{className:"type-body-sm text-fg-muted",children:[e.jsx("span",{className:"text-fg-secondary",children:"Stealth mode"})," allows you to appear on the map and in topology analysis without broadcasting your location. Coordinates are stored locally in your browser only — ",e.jsx("span",{className:"text-sys-cyan",children:"never sent to config.yaml or the mesh"}),"."]})]})}),C&&e.jsx("div",{className:"text-xs mb-3 px-2 py-1.5 rounded-md text-sys-red bg-sys-red/10",children:C}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"type-label text-fg-muted block mb-1",children:u?"Latitude (°)":"Latitude"}),e.jsx("div",{className:l("h-[38px] rounded-full px-4 flex items-center transition-colors","bg-subtle-fill"),children:u?e.jsx("input",{type:"number",value:n,onChange:m=>h(m.target.value),step:"0.000001",min:"-90",max:"90",placeholder:"e.g. 34.052234",className:"w-full bg-transparent text-fg-primary focus:outline-none type-data placeholder:text-fg-muted/50"}):e.jsx("span",{className:l("type-data",T&&r?"text-fg-primary":"text-fg-muted"),children:T?a.toFixed(6):"Not set"})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"type-label text-fg-muted block mb-1",children:u?"Longitude (°)":"Longitude"}),e.jsx("div",{className:l("h-[38px] rounded-full px-4 flex items-center transition-colors","bg-subtle-fill"),children:u?e.jsx("input",{type:"number",value:k,onChange:m=>E(m.target.value),step:"0.000001",min:"-180",max:"180",placeholder:"e.g. -118.243685",className:"w-full bg-transparent text-fg-primary focus:outline-none type-data placeholder:text-fg-muted/50"}):e.jsx("span",{className:l("type-data",T&&r?"text-fg-primary":"text-fg-muted"),children:T?c.toFixed(6):"Not set"})})]})]}),T&&!u&&e.jsx("div",{className:"mt-3 pt-3 border-t border-edge-subtle",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:l("w-2 h-2 rounded-full",r?"bg-sys-green":"bg-fg-muted")}),e.jsx("span",{className:"type-body-sm text-fg-muted",children:r?"Stealth location active — you appear on maps with these coordinates":"Stealth location disabled — coordinates saved but not in use"})]})})]})})}const Xt=[{value:7.8,label:"7.8 kHz"},{value:10.4,label:"10.4 kHz"},{value:15.6,label:"15.6 kHz"},{value:20.8,label:"20.8 kHz"},{value:31.25,label:"31.25 kHz"},{value:41.7,label:"41.7 kHz"},{value:62.5,label:"62.5 kHz"},{value:125,label:"125 kHz"},{value:250,label:"250 kHz"},{value:500,label:"500 kHz"}],Yt=[5,6,7,8,9,10,11,12],Jt=[{value:5,label:"4/5"},{value:6,label:"4/6"},{value:7,label:"4/7"},{value:8,label:"4/8"}],Is={RADIO_CONFIG:"radioConfig"};function Qt(a){if(!a)return"Never";const r=Date.now()-a*1e3,p=Math.floor(r/6e4),i=Math.floor(r/36e5),d=Math.floor(r/864e5);return p<1?"Just now":p<60?`${p}m ago`:i<24?`${i}h ago`:d<365?`${d}d ago`:`${Math.floor(d/365)}y ago`}function Ds({node:a,level:c,expandedKeys:r,selectedKeyId:p,globalFloodPolicy:i,onSelect:d,onToggle:v}){const u=r.has(a.id),o=p===a.id,n=a.children&&a.children.length>0,h=i==="allow";return e.jsxs("div",{children:[e.jsxs("div",{className:l("flex items-center gap-2 h-[36px] px-3 rounded-full cursor-pointer transition-colors",o?"bg-sys-blue/15":"hover:bg-subtle-fill",h&&"opacity-50 cursor-not-allowed"),style:{marginLeft:`${c*16}px`},onClick:()=>!h&&d(a.id),children:[n?e.jsx("button",{onClick:k=>{k.stopPropagation(),v(a.id)},className:"p-1 hover:bg-subtle-fill-hover rounded-full transition-colors",children:e.jsx(Rt,{className:l("w-3.5 h-3.5 text-fg-muted transition-transform",u&&"rotate-90")})}):e.jsx("span",{className:"w-5"}),e.jsx(Mt,{className:"w-4 h-4 text-sys-blue flex-shrink-0"}),e.jsx("span",{className:"type-data text-fg-primary flex-1 truncate",children:a.name}),e.jsx("span",{className:"type-data-xs text-fg-muted hidden sm:inline",title:a.last_used?new Date(a.last_used*1e3).toLocaleString():void 0,children:Qt(a.last_used)}),e.jsx("span",{className:l("type-data-xs px-2 py-0.5 rounded-full",a.floodPolicy==="allow"?"bg-sys-green/15 text-sys-green":"bg-sys-red/15 text-sys-red"),children:a.floodPolicy==="allow"?"Allow":"Deny"})]}),n&&u&&e.jsx("div",{children:a.children.map(k=>e.jsx(Ds,{node:k,level:c+1,expandedKeys:r,selectedKeyId:p,globalFloodPolicy:i,onSelect:d,onToggle:v},k.id))})]})}function Zt(){const[a,c]=t.useState(jt),[r,p]=t.useState(vt),[i,d]=t.useState(!1),v=t.useCallback(n=>{c(n),Nt(n)},[]),u=t.useCallback(n=>{const h=parseFloat(n.target.value);p(h),kt(h)},[]),o=t.useCallback(async()=>{i||(d(!0),await wt(),d(!1))},[i]);return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx(ie,{enabled:a,onChange:v,label:e.jsxs(e.Fragment,{children:["Sound: ",e.jsx("span",{className:a?"text-sys-green":"text-sys-red",children:a?"On":"Off"})]}),tooltip:"Enable or disable UI sound effects and haptic audio feedback",size:"md"}),e.jsx(F,{color:"primary",outline:!0,onClick:o,disabled:!a||i,className:"w-16 justify-center",children:i?"…":"Test"})]}),e.jsxs("div",{className:l("flex items-center gap-3",!a&&"opacity-40 pointer-events-none"),children:[e.jsx("span",{className:"type-label text-fg-muted w-14 shrink-0",children:"Volume"}),e.jsx("input",{type:"range",min:0,max:1,step:.05,value:r,onChange:u,className:"flex-1 accent-sys-blue h-1.5 cursor-pointer"}),e.jsxs("span",{className:"data-box w-16 justify-center",children:[Math.round(r*100),"%"]})]})]})}function ha(){var js,vs,Ns,ks,ws,Cs;const{stats:a,setMode:c,clearModeMutation:r,setDutyCycleConfig:p,clearDutyCycleMutation:i,fetchStats:d,startMutation:v,clearMutation:u}=tt(),o=(js=a==null?void 0:a.config)==null?void 0:js.radio,n=(vs=a==null?void 0:a.config)==null?void 0:vs.repeater,h=(Ns=a==null?void 0:a.config)==null?void 0:Ns.duty_cycle,k=(a==null?void 0:a.node_name)||((ks=a==null?void 0:a.config)==null?void 0:ks.node_name)||"Unknown Node",E=(n==null?void 0:n.mode)??"forward",y=(h==null?void 0:h.enforcement_enabled)??!1,w=(ws=a==null?void 0:a.config)==null?void 0:ws.delays,C=t.useRef(!0);t.useEffect(()=>(C.current=!0,()=>{C.current=!1}),[]);const j=(Cs=a==null?void 0:a.config)==null?void 0:Cs.web,[S,I]=t.useState([]),[g,A]=t.useState(!1),[O,x]=t.useState(null),[P,_]=t.useState(!1),[L,T]=t.useState(""),[m,z]=t.useState(null),[N,G]=t.useState(!1),[ae,Re]=t.useState(null),[Ie,ss]=t.useState(!1),[ts,as]=t.useState(!1),[ns,ls]=t.useState(!1),[U,Ms]=t.useState([]),[As,rs]=t.useState(!1),[is,D]=t.useState(null),[Q,Ks]=t.useState(()=>localStorage.getItem("pymc:globalFloodPolicy")==="allow"?"allow":"deny"),os=t.useCallback(s=>{Ks(s),localStorage.setItem("pymc:globalFloodPolicy",s)},[]),[cs,ds]=t.useState(!1),[K,Pe]=t.useState(null),[Ls,zs]=t.useState(new Set),[ge,me]=t.useState(!1),[be,ne]=t.useState(!1),[je,le]=t.useState(!1),[M,W]=t.useState(null),[Z,xe]=t.useState(null),[ve,Ne]=t.useState(""),[De,fe]=t.useState("allow"),[q,re]=t.useState(!1),[ke,us]=t.useState(!0),[he,Me]=t.useState(!1),[Os,ms]=t.useState(!0),[pe,ee]=t.useState("idle"),[Vs,Ae]=t.useState(!1),[Ke,Hs]=t.useState(!1),xs=t.useCallback(()=>{const s=w==null?void 0:w.tx_delay_factor;return s&&typeof s=="object"&&"parsedValue"in s?s.parsedValue??1:typeof s=="number"?s:1},[w]),fs=t.useCallback(()=>{const s=w==null?void 0:w.direct_tx_delay_factor;return typeof s=="number"?s:.5},[w]),Le=t.useCallback(()=>{const s=h==null?void 0:h.max_airtime_percent;return typeof s=="number"?s:s&&typeof s=="object"&&"parsedValue"in s?s.parsedValue??6:6},[h]),ze=Ye(E==="forward",async s=>{await c(s?"forward":"monitor")},r),Oe=Ye(y,async s=>{await p({max_airtime_percent:Le(),enforcement_enabled:s})},i),Ve=Ye((j==null?void 0:j.cors_enabled)??!1,async s=>{var b;const f=await Es({web:{cors_enabled:s}});if(!f.success&&!((b=f.data)!=null&&b.persisted))throw new Error("CORS update failed");await d()}),V=t.useCallback(async s=>{v(Is.RADIO_CONFIG);try{const f=await at(s);if(!f.success)throw new Error(f.error||"Failed to save");await d({force:!0}).catch(()=>{})}finally{u(Is.RADIO_CONFIG)}},[v,u,d]);t.useEffect(()=>{(async()=>{ms(!0);try{const f=await mt();f.success&&f.data?Me(f.data.exists):Me(!1);const b=j==null?void 0:j.web_path;us(!b||b==="")}catch{Me(!1)}finally{ms(!1)}})()},[j==null?void 0:j.web_path]);const hs=async s=>{var f;if(pe!=="loading"){ee("loading");try{const b=await Es({web:{web_path:s?null:"/opt/pymc_console/web/html"}});if(!C.current)return;b.success||(f=b.data)!=null&&f.persisted?(us(s),ee("success"),Ae(!0),setTimeout(()=>{C.current&&ee("idle")},2e3)):(ee("error"),setTimeout(()=>{C.current&&ee("idle")},2e3))}catch{if(!C.current)return;ee("error"),setTimeout(()=>{C.current&&ee("idle")},2e3)}}},$s=async()=>{if(!Ke){Hs(!0);try{await xt(),Ae(!1),setTimeout(()=>{window.location.reload()},2e3)}catch{Ae(!1),setTimeout(()=>{window.location.reload()},3e3)}}},we=t.useCallback(async()=>{A(!0),x(null);try{const s=await Ht();I(s.tokens||[])}catch(s){x(s instanceof Error?s.message:"Failed to fetch tokens")}finally{A(!1)}},[]);t.useEffect(()=>{we()},[we]);const ps=async()=>{if(!L.trim()){x("Token name is required");return}ss(!0),x(null);try{const s=await $t(L.trim());z(s.token||null),_(!1),G(!0),T(""),await we()}catch(s){x(s instanceof Error?s.message:"Failed to create token")}finally{ss(!1)}},qs=async()=>{if(ae){as(!0),x(null);try{await qt(ae.id),await we(),Re(null)}catch(s){x(s instanceof Error?s.message:"Failed to revoke token")}finally{as(!1)}}},Gs=()=>{m&&(navigator.clipboard.writeText(m),ls(!0),setTimeout(()=>ls(!1),2e3))},ys=s=>s?new Date(s*1e3).toLocaleString():"Never",gs=t.useCallback(s=>{const f=new Map,b=[];return s.forEach(R=>{const Ce={id:R.id,name:R.name,floodPolicy:R.flood_policy,transport_key:R.transport_key,last_used:R.last_used,parent_id:R.parent_id,children:[]};f.set(R.id,Ce)}),f.forEach(R=>{R.parent_id&&f.has(R.parent_id)?f.get(R.parent_id).children.push(R):b.push(R)}),b},[]),ye=t.useCallback(async()=>{rs(!0),D(null);try{const s=await dt();if(s.success&&s.data){const f=gs(s.data);Ms(f),Pe(b=>{if(b===null)return null;const R=Ce=>{for(const He of Ce)if(He.id===b||He.children&&R(He.children))return!0;return!1};return R(f)?b:null})}else D(s.error||"Failed to load transport keys")}catch(s){D(s instanceof Error?s.message:"Unknown error occurred")}finally{rs(!1)}},[gs]);t.useEffect(()=>{ye(),ut().then(s=>{s.success&&s.data&&os(s.data.global_flood_allow?"allow":"deny")}).catch(()=>{})},[ye]);const se=t.useCallback((s,f)=>{for(const b of s){if(b.id===f)return b;if(b.children){const R=se(b.children,f);if(R)return R}}return null},[]),Bs=t.useCallback(()=>{if(!K)return;const s=se(U,K);return s==null?void 0:s.name},[K,U,se]),Us=t.useCallback(s=>{zs(f=>{const b=new Set(f);return b.has(s)?b.delete(s):b.add(s),b})},[]),Ws=async s=>{ds(!0),D(null);try{const f=await ft(s==="allow");f.success?os(s):D(f.error||"Failed to update global flood policy")}catch(f){D(f instanceof Error?f.message:"Failed to update global flood policy")}finally{ds(!1)}},bs=async()=>{if(!ve.trim()){D("Key name is required");return}re(!0),D(null);try{const s=await ht({name:ve.trim(),flood_policy:De,parent_id:K??void 0});s.success?(await ye(),me(!1),Ne(""),fe("allow")):D(s.error||"Failed to add transport key")}catch(s){D(s instanceof Error?s.message:"Failed to add transport key")}finally{re(!1)}},Xs=async()=>{if(M){re(!0),D(null);try{const s=await pt(M.id,{name:M.name,flood_policy:M.floodPolicy});s.success?(await ye(),ne(!1),W(null)):D(s.error||"Failed to update transport key")}catch(s){D(s instanceof Error?s.message:"Failed to update transport key")}finally{re(!1)}}},Ys=async()=>{if(Z){re(!0),D(null);try{const s=await yt(Z.id);s.success?(await ye(),le(!1),xe(null),Pe(null)):D(s.error||"Failed to delete transport key")}catch(s){D(s instanceof Error?s.message:"Failed to delete transport key")}finally{re(!1)}}},Js=t.useCallback(()=>{if(!K)return;const s=se(U,K);s&&(W({...s}),ne(!0))},[K,U,se]);t.useEffect(()=>{const s=b=>{b.key==="Escape"&&(ge&&(me(!1),Ne(""),fe("allow")),be&&(ne(!1),W(null)),je&&(le(!1),xe(null)),P&&(_(!1),T("")),N&&(G(!1),z(null)))};if(ge||be||je||P||N)return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[ge,be,je,P,N]);const Qs=t.useCallback(()=>{if(!K)return;const s=se(U,K);s&&(xe(s),le(!0))},[K,U,se]);return e.jsxs(Ct,{children:[e.jsx(St,{title:"Configuration",icon:e.jsx(Ts,{})}),e.jsxs(Tt,{children:[e.jsxs(te,{template:"standard",children:[e.jsx(Te,{span:12,md:6,children:e.jsxs(Y,{neomorphic:!0,children:[e.jsx(X,{icon:e.jsx(nt,{}),title:"Repeater Settings"}),n?e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx("div",{className:"col-span-2",children:e.jsx(H,{label:"Node Name",value:k,onSave:async s=>V({node_name:s}),placeholder:"Enter node name",maxLength:50})}),e.jsx(H,{label:"Latitude",value:n.latitude!==0?n.latitude.toFixed(6):"Not set",editValue:String(n.latitude),type:"number",suffix:"°",step:1e-6,min:-90,max:90,onSave:async s=>V({latitude:parseFloat(s)})}),e.jsx(H,{label:"Longitude",value:n.longitude!==0?n.longitude.toFixed(6):"Not set",editValue:String(n.longitude),type:"number",suffix:"°",step:1e-6,min:-180,max:180,onSave:async s=>V({longitude:parseFloat(s)})}),e.jsx(H,{label:"Advert Interval",value:n.send_advert_interval_hours>0?`${n.send_advert_interval_hours}h`:"Disabled",editValue:String(n.send_advert_interval_hours),type:"number",suffix:"hours",min:0,max:48,description:"0 = disabled, 3-48 hours",onSave:async s=>V({flood_advert_interval_hours:parseInt(s,10)})}),e.jsx(H,{label:"Score-based TX",value:n.use_score_for_tx?"Enabled":"Disabled",readOnly:!0})]}):e.jsx("p",{className:"text-fg-muted",children:"Loading repeater settings..."})]})}),e.jsx(Te,{span:12,md:6,children:e.jsxs(Y,{neomorphic:!0,children:[e.jsx(X,{icon:e.jsx(_t,{}),title:"Radio Configuration"}),o?e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(H,{label:"Frequency",value:lt(o.frequency),editValue:(o.frequency/1e6).toFixed(3),type:"number",suffix:"MHz",step:.001,min:400,max:930,onSave:async s=>V({frequency_mhz:parseFloat(s)})}),e.jsx(H,{label:"TX Power",value:`${o.tx_power} dBm`,editValue:String(o.tx_power),type:"number",suffix:"dBm",min:2,max:30,onSave:async s=>V({tx_power:parseInt(s,10)})}),e.jsx(Be,{label:"Bandwidth",value:rt(o.bandwidth),editValue:o.bandwidth/1e3,options:Xt,onSave:async s=>V({bandwidth_khz:parseFloat(s)})}),e.jsx(Be,{label:"Spreading Factor",value:`SF${o.spreading_factor}`,editValue:o.spreading_factor,options:Yt.map(s=>({value:s,label:`SF${s}`})),onSave:async s=>V({spreading_factor:parseInt(s,10)})}),e.jsx(Be,{label:"Coding Rate",value:`4/${o.coding_rate}`,editValue:o.coding_rate,options:Jt,onSave:async s=>V({coding_rate:parseInt(s,10)})}),e.jsx(H,{label:"Preamble",value:`${o.preamble_length} symbols`,readOnly:!0})]}):e.jsx("p",{className:"text-fg-muted",children:"Loading radio configuration..."})]})})]}),e.jsxs(te,{template:"standard",children:[e.jsx(Te,{span:12,md:6,children:e.jsxs(Y,{neomorphic:!0,children:[e.jsx(X,{icon:e.jsx(it,{}),title:"Operating Mode"}),e.jsx("p",{className:"type-label text-fg-muted mb-3",children:"Control how the repeater handles packets"}),e.jsxs("div",{className:"flex flex-col lg:flex-row gap-4",children:[e.jsxs("div",{className:"flex-1 space-y-4",children:[e.jsx(ie,{enabled:ze.enabled,onChange:ze.toggle,label:"Repeat",tooltip:"Toggles repeater or monitor mode. In monitor mode, the repeater will not repeat packets from the mesh.",status:ze.status,size:"md"}),e.jsx(ie,{enabled:Oe.enabled,onChange:Oe.toggle,label:"Duty Cycle",tooltip:"Limit transmission time to comply with airtime utilization regulations",status:Oe.status,size:"md"}),e.jsx(H,{label:"Max Airtime",layout:"inline",value:`${Le().toFixed(1)}%`,editValue:String(Le()),type:"number",suffix:"%",step:.5,min:.1,max:100,onSave:async s=>{await p({max_airtime_percent:parseFloat(s),enforcement_enabled:y}),i()}})]}),e.jsx("div",{className:"hidden lg:block w-px bg-border-subtle"}),e.jsxs("div",{className:"flex-1 pt-4 lg:pt-0 border-t lg:border-t-0 border-edge-subtle",children:[e.jsx("label",{className:"type-label text-fg-muted block mb-3",children:"TX Delays"}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(H,{label:"Flood",layout:"inline",value:`${xs().toFixed(2)}x`,editValue:String(xs()),type:"number",suffix:"x",step:.1,min:0,max:5,onSave:async s=>V({tx_delay_factor:parseFloat(s)})}),e.jsx(H,{label:"Direct",layout:"inline",value:`${fs().toFixed(2)}s`,editValue:String(fs()),type:"number",suffix:"s",step:.1,min:0,max:5,onSave:async s=>V({direct_tx_delay_factor:parseFloat(s)})})]})]})]})]})}),e.jsx(Te,{span:12,md:6,children:e.jsxs(Y,{neomorphic:!0,children:[e.jsx(X,{icon:e.jsx(Ts,{}),title:"App Settings"}),e.jsx("p",{className:"type-body-sm text-fg-muted mb-4",children:"Appearance and web server options."}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(ie,{enabled:Ve.enabled,onChange:Ve.toggle,label:"Enable CORS",tooltip:"Allow cross-origin API access",status:Ve.status,size:"md"}),e.jsx("div",{children:e.jsx(Bt,{})}),e.jsx(Zt,{})]})]})})]}),e.jsx(te,{template:"auto",children:e.jsxs(Y,{neomorphic:!0,children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3 mb-4",children:[e.jsx(X,{icon:e.jsx(Fs,{}),title:"Regions Transport Keys",subtitle:"Manage regional key hierarchy for flood control"}),e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsxs(F,{color:"primary",outline:!0,onClick:()=>me(!0),disabled:Q==="allow",children:[e.jsx(_s,{"data-slot":"icon"}),"Add"]}),e.jsx(F,{color:"primary",outline:!0,onClick:Js,disabled:!K||Q==="allow",children:"Edit"}),e.jsx(F,{color:"danger",outline:!0,onClick:Qs,disabled:!K||Q==="allow",children:"Delete"})]})]}),e.jsx("div",{className:"bg-subtle-fill radius-inner p-4 mb-4",children:e.jsx(ie,{enabled:Q==="deny",onChange:s=>Ws(s?"deny":"allow"),label:e.jsxs(e.Fragment,{children:["Require Transport Keys: ",e.jsx("span",{className:Q==="deny"?"text-sys-green":"text-sys-red",children:Q==="deny"?"On":"Off"})]}),tooltip:"When enabled, only packets with matching transport keys are forwarded. When disabled, all packets flood freely.",status:cs?"loading":"idle",disabled:cs,dangerOff:!0,size:"md",className:"flex-row-reverse justify-between w-full"})}),is&&e.jsx("div",{className:"type-body-sm mb-3 px-3 py-2 rounded-full text-sys-red bg-sys-red/10",children:is}),e.jsx("div",{className:"bg-subtle-fill radius-inner p-4 min-h-[120px]",children:As?e.jsxs("div",{className:"flex items-center justify-center py-6",children:[e.jsx($,{className:"w-5 h-5 animate-spin text-sys-blue mr-2"}),e.jsx("span",{className:"type-body-sm text-fg-muted",children:"Loading transport keys..."})]}):U.length===0?e.jsxs("div",{className:"text-center py-6",children:[e.jsx("div",{className:"w-12 h-12 rounded-full bg-subtle-fill mx-auto mb-3 flex items-center justify-center",children:e.jsx(Fs,{className:"w-6 h-6 text-fg-muted/50"})}),e.jsx("p",{className:"type-body text-fg-muted",children:"No transport keys found"}),e.jsx("p",{className:"type-body-sm text-fg-muted/70 mt-1",children:"Add your first transport key to get started"})]}):e.jsx("div",{className:"space-y-1",children:U.map(s=>e.jsx(Ds,{node:s,level:0,expandedKeys:Ls,selectedKeyId:K,globalFloodPolicy:Q,onSelect:Pe,onToggle:Us},s.id))})})]})}),e.jsx(te,{template:"auto",children:e.jsxs(Y,{neomorphic:!0,children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3 mb-4",children:[e.jsx(X,{icon:e.jsx(qe,{}),title:"API Tokens",subtitle:"Manage API tokens for machine-to-machine authentication"}),e.jsxs(F,{color:"primary",outline:!0,onClick:()=>_(!0),children:[e.jsx(_s,{"data-slot":"icon"}),"Create Token"]})]}),e.jsx("div",{className:"bg-sys-blue/5 radius-inner p-4 mb-4",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-sys-blue/20 flex items-center justify-center flex-shrink-0",children:e.jsx(Qe,{className:"w-4 h-4 text-sys-blue"})}),e.jsxs("div",{className:"type-body-sm text-fg-muted",children:[e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-secondary",children:"API tokens"})," are used for machine-to-machine authentication. Include the token in the ",e.jsx("code",{className:"type-code bg-sys-blue/20 px-1.5 py-0.5 rounded-full text-sys-blue",children:"X-API-Key"})," header when making API requests."]}),e.jsx("p",{className:"mt-1 text-fg-muted/70",children:"Tokens are only shown once at creation. Store them securely."})]})]})}),O&&e.jsx("div",{className:"type-body-sm mb-3 px-3 py-2 rounded-full text-sys-red bg-sys-red/10",children:O}),g&&S.length===0?e.jsxs("div",{className:"flex items-center justify-center py-6",children:[e.jsx($,{className:"w-5 h-5 animate-spin text-sys-blue mr-2"}),e.jsx("span",{className:"type-body-sm text-fg-muted",children:"Loading tokens..."})]}):S.length>0?e.jsx("div",{className:"space-y-2",children:S.map(s=>e.jsx("div",{className:"bg-subtle-fill hover:bg-subtle-fill-strong radius-inner p-4 transition-base",children:e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:[e.jsx("div",{className:"w-10 h-10 rounded-full bg-sys-blue/10 flex items-center justify-center flex-shrink-0",children:e.jsx(qe,{className:"w-5 h-5 text-sys-blue"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h3",{className:"type-body text-fg-primary font-medium truncate",children:s.name}),e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:gap-4 mt-0.5",children:[e.jsxs("span",{className:"type-data-sm text-fg-muted truncate",children:["Created: ",ys(s.created_at)]}),e.jsxs("span",{className:"type-data-sm text-fg-muted truncate",children:["Last used: ",ys(s.last_used)]})]})]})]}),e.jsxs(F,{color:"danger",outline:!0,onClick:()=>Re({id:s.id,name:s.name}),disabled:ts,children:[e.jsx(Ps,{"data-slot":"icon"}),"Revoke"]})]})},s.id))}):e.jsxs("div",{className:"bg-subtle-fill radius-inner p-6 text-center",children:[e.jsx("div",{className:"w-14 h-14 rounded-full bg-subtle-fill mx-auto mb-4 flex items-center justify-center",children:e.jsx(qe,{className:"w-7 h-7 text-fg-muted/50"})}),e.jsx("h3",{className:"type-body text-fg-primary font-medium mb-1",children:"No API Tokens"}),e.jsx("p",{className:"type-body-sm text-fg-muted mb-4",children:"Create a token to enable API access"}),e.jsx(F,{color:"primary",outline:!0,onClick:()=>_(!0),children:"Create Your First Token"})]})]})}),e.jsx(te,{template:"auto",children:e.jsxs(Y,{neomorphic:!0,children:[e.jsx(X,{icon:e.jsx(Lt,{}),title:"Web Frontend",subtitle:"Choose which web interface to use",className:"mb-4"}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsxs("label",{className:l("flex items-start gap-3 p-4 bg-subtle-fill radius-card border-2 cursor-pointer transition-base",ke?"border-sys-blue bg-sys-blue/5":"border-transparent hover:border-sys-blue/30",pe==="loading"&&"opacity-50 pointer-events-none"),children:[e.jsx("input",{type:"radio",name:"frontend",checked:ke,onChange:()=>hs(!0),disabled:pe==="loading",className:"mt-1 h-4 w-4 text-sys-blue focus:ring-sys-blue focus:ring-offset-bg-elevated"}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"type-body text-fg-primary font-medium",children:"Default Frontend"}),e.jsx("a",{href:"https://github.com/rightup/pyMC_Repeater",target:"_blank",rel:"noopener noreferrer",onClick:s=>s.stopPropagation(),className:"type-data-xs bg-sys-cyan/15 text-sys-cyan px-2.5 py-0.5 rounded-full font-medium hover:bg-sys-cyan/25 transition-colors",children:"@RightUp"})]}),e.jsx("div",{className:"type-body-sm text-fg-muted mt-1",children:"Built-in pyMC Repeater web interface"}),e.jsx("div",{className:"type-data-xs text-fg-muted/60 mt-1",children:"/opt/pymc_repeater/repeater/web/html"})]})]}),e.jsxs("label",{className:l("flex items-start gap-3 p-4 bg-subtle-fill radius-card border-2 cursor-pointer transition-base",ke?"border-transparent hover:border-sys-blue/30":"border-sys-blue bg-sys-blue/5",pe==="loading"&&"opacity-50 pointer-events-none"),children:[e.jsx("input",{type:"radio",name:"frontend",checked:!ke,onChange:()=>hs(!1),disabled:pe==="loading",className:"mt-1 h-4 w-4 text-sys-blue focus:ring-sys-blue focus:ring-offset-bg-elevated"}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"type-body text-fg-primary font-medium",children:"PyMC Console"}),e.jsx("span",{className:"type-data-xs bg-sys-indigo/15 text-sys-indigo px-2.5 py-0.5 rounded-full font-medium",children:"@Treehouse ⚡"})]}),e.jsx("div",{className:"type-body-sm text-fg-muted mt-1",children:"Alternative web interface for pyMC Repeater"}),e.jsx("div",{className:"type-data-xs text-fg-muted/60 mt-1",children:"/opt/pymc_console/web/html"})]})]})]}),!Os&&e.jsx("div",{className:l("bg-subtle-fill radius-card p-4",he?"border border-sys-green/20":"border border-sys-cyan/20"),children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:l("w-8 h-8 rounded-full flex items-center justify-center flex-shrink-0",he?"bg-sys-green/20":"bg-sys-cyan/20"),children:he?e.jsx(Ft,{className:"w-4 h-4 text-sys-green"}):e.jsx(Qe,{className:"w-4 h-4 text-sys-cyan"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h4",{className:"type-body text-fg-primary font-medium",children:he?"PyMC Console has been detected":"PyMC Console Not Installed"}),he?e.jsxs("p",{className:"type-body-sm text-fg-muted mt-1",children:["PyMC Console is installed at ",e.jsx("code",{className:"type-code bg-sys-green/10 px-1.5 py-0.5 rounded-full text-sys-green",children:"/opt/pymc_console/web/html"})]}):e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"type-body-sm text-fg-muted mt-1 mb-3",children:["PyMC Console must be installed at ",e.jsx("code",{className:"type-code bg-sys-cyan/10 px-1.5 py-0.5 rounded-full text-sys-cyan",children:"/opt/pymc_console/web/html"})," before selecting this option."]}),e.jsxs(F,{color:"primary",outline:!0,href:"https://github.com/dmduran12/pymc_console-dist",children:[e.jsx(Pt,{"data-slot":"icon"}),"PyMC Console Install Instructions"]})]})]})]})}),Vs&&e.jsx("div",{className:"bg-subtle-fill radius-card p-4 border border-sys-indigo/30",children:e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3",children:[e.jsxs("div",{className:"flex items-start gap-3 flex-1",children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-sys-indigo/20 flex items-center justify-center flex-shrink-0",children:e.jsx(Ge,{className:"w-4 h-4 text-sys-indigo"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h4",{className:"type-body text-fg-primary font-medium",children:"Service restart required"}),e.jsx("p",{className:"type-body-sm text-fg-muted mt-1",children:"Web frontend changes will take effect after restarting the pymc-repeater service."})]})]}),e.jsx(F,{color:"warning",outline:!0,onClick:$s,disabled:Ke,children:Ke?e.jsxs(e.Fragment,{children:[e.jsx($,{"data-slot":"icon",className:"animate-spin"}),"Restarting..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Et,{"data-slot":"icon"}),"Restart Now"]})})]})})]})]})}),a&&e.jsx(te,{template:"auto",children:e.jsx(bt,{nodeName:k,repeaterVersion:a.version,coreVersion:a.core_version,localHash:a.local_hash,publicKey:a.public_key})}),a&&((n==null?void 0:n.latitude)===0||!(n!=null&&n.latitude))&&((n==null?void 0:n.longitude)===0||!(n!=null&&n.longitude))&&e.jsx(te,{template:"auto",children:e.jsx(Wt,{})})]}),P&&e.jsx("div",{className:"fixed inset-0 z-[10010] flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm",onClick:s=>s.target===s.currentTarget&&_(!1),role:"dialog","aria-modal":"true","aria-labelledby":"create-token-modal-title",children:e.jsxs("div",{className:"surface-modal radius-card p-6 max-w-md w-full",children:[e.jsx("h3",{id:"create-token-modal-title",className:"type-micro mb-4",children:"Create API Token"}),e.jsxs("div",{className:"space-y-4",children:[e.jsx($e,{label:"Token Name",type:"text",value:L,onChange:s=>T(s.target.value),placeholder:"e.g., Production Server, CI/CD Pipeline",description:"Give your token a descriptive name to identify its purpose",onKeyDown:s=>s.key==="Enter"&&ps(),autoFocus:!0}),e.jsxs("div",{className:"flex justify-end gap-3 mt-6",children:[e.jsx(F,{color:"muted",outline:!0,onClick:()=>{_(!1),T(""),x(null)},disabled:Ie,children:"Cancel"}),e.jsx(F,{color:"primary",onClick:ps,disabled:Ie||!L.trim(),children:Ie?e.jsxs(e.Fragment,{children:[e.jsx($,{"data-slot":"icon",className:"animate-spin"}),"Creating..."]}):"Create Token"})]})]})]})}),N&&m&&e.jsx("div",{className:"fixed inset-0 z-[10010] flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm",onClick:s=>s.target===s.currentTarget&&G(!1),role:"dialog","aria-modal":"true","aria-labelledby":"show-token-modal-title",children:e.jsxs("div",{className:"surface-modal radius-card p-6 max-w-lg w-full",children:[e.jsx("h3",{id:"show-token-modal-title",className:"type-micro mb-4",children:"Token Created Successfully"}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"bg-sys-indigo/10 border border-sys-indigo/30 radius-inner p-3",children:e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Ge,{className:"w-4 h-4 text-sys-indigo flex-shrink-0 mt-0.5"}),e.jsxs("div",{className:"text-sm text-fg-secondary",children:[e.jsx("strong",{children:"Save this token now!"})," For security reasons, it will not be shown again."]})]})}),e.jsxs("div",{children:[e.jsx("label",{className:"type-label text-fg-primary block mb-1.5",children:"Your API Token"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ot,{value:m,readOnly:!0,className:"flex-1 font-mono"}),e.jsxs(F,{color:"primary",outline:!0,onClick:Gs,children:[ns?e.jsx(B,{"data-slot":"icon",className:"text-sys-green"}):e.jsx(ct,{"data-slot":"icon"}),ns?"Copied!":"Copy"]})]})]}),e.jsxs("div",{className:"bg-sys-cyan/10 border border-sys-cyan/30 radius-inner p-3",children:[e.jsx("p",{className:"text-sm text-fg-secondary mb-2",children:e.jsx("strong",{children:"Usage Example:"})}),e.jsxs("code",{className:"block bg-sys-cyan/20 px-3 py-2 rounded type-code text-sys-cyan overflow-x-auto",children:['curl -H "X-API-Key: ',m.slice(0,12),'..." ',window.location.origin,"/api/stats"]})]}),e.jsx("div",{className:"flex justify-end mt-6",children:e.jsx(F,{color:"primary",onClick:()=>{G(!1),z(null)},children:"Done"})})]})]})}),e.jsx(gt,{isOpen:!!ae,title:"Revoke API Token",message:`Are you sure you want to revoke the token '${ae==null?void 0:ae.name}'? This action cannot be undone.`,confirmLabel:ts?"Revoking...":"Revoke",cancelLabel:"Cancel",variant:"danger",onConfirm:qs,onCancel:()=>Re(null)}),ge&&e.jsx("div",{className:"fixed inset-0 z-[10010] flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm",onClick:s=>s.target===s.currentTarget&&me(!1),role:"dialog","aria-modal":"true","aria-labelledby":"add-key-modal-title",children:e.jsxs("div",{className:"surface-modal radius-card p-6 max-w-md w-full",children:[e.jsx("h3",{id:"add-key-modal-title",className:"type-micro mb-4",children:"Add Transport Key"}),e.jsxs("div",{className:"space-y-4",children:[K&&e.jsxs("div",{className:"bg-sys-cyan/10 border border-sys-cyan/30 radius-inner p-3 text-sm text-fg-secondary",children:["Adding as child of: ",e.jsx("strong",{className:"text-fg-primary",children:Bs()})]}),e.jsx($e,{label:"Key Name",type:"text",value:ve,onChange:s=>Ne(s.target.value),placeholder:"e.g., Region Name, Group Key",onKeyDown:s=>s.key==="Enter"&&bs(),autoFocus:!0}),e.jsxs("div",{children:[e.jsx("label",{className:"type-label text-fg-muted block mb-2",children:"Flood Policy"}),e.jsxs("div",{className:"toggle-group w-full",children:[e.jsx("button",{onClick:()=>fe("deny"),className:l("toggle-group-item flex-1",De==="deny"&&"active !text-sys-red"),children:"Deny"}),e.jsx("button",{onClick:()=>fe("allow"),className:l("toggle-group-item flex-1",De==="allow"&&"active !text-sys-green"),children:"Allow"})]})]}),e.jsxs("div",{className:"flex justify-end gap-3 mt-6",children:[e.jsx(F,{color:"muted",outline:!0,onClick:()=>{me(!1),Ne(""),fe("allow")},disabled:q,children:"Cancel"}),e.jsx(F,{color:"primary",onClick:bs,disabled:q||!ve.trim(),children:q?e.jsxs(e.Fragment,{children:[e.jsx($,{"data-slot":"icon",className:"animate-spin"}),"Adding..."]}):"Add Key"})]})]})]})}),be&&M&&e.jsx("div",{className:"fixed inset-0 z-[10010] flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm",onClick:s=>s.target===s.currentTarget&&ne(!1),role:"dialog","aria-modal":"true","aria-labelledby":"edit-key-modal-title",children:e.jsxs("div",{className:"surface-modal radius-card p-6 max-w-md w-full",children:[e.jsx("h3",{id:"edit-key-modal-title",className:"type-micro mb-4",children:"Edit Transport Key"}),e.jsxs("div",{className:"space-y-4",children:[e.jsx($e,{label:"Key Name",type:"text",value:M.name,onChange:s=>W({...M,name:s.target.value}),autoFocus:!0}),e.jsxs("div",{children:[e.jsx("label",{className:"type-label text-fg-muted block mb-2",children:"Flood Policy"}),e.jsxs("div",{className:"toggle-group w-full",children:[e.jsx("button",{onClick:()=>W({...M,floodPolicy:"deny"}),className:l("toggle-group-item flex-1",M.floodPolicy==="deny"&&"active !text-sys-red"),children:"Deny"}),e.jsx("button",{onClick:()=>W({...M,floodPolicy:"allow"}),className:l("toggle-group-item flex-1",M.floodPolicy==="allow"&&"active !text-sys-green"),children:"Allow"})]})]}),M.transport_key&&e.jsxs("div",{children:[e.jsx("label",{className:"type-label text-fg-muted block mb-2",children:"Transport Key"}),e.jsx("code",{className:"block bg-input-bg px-3 py-2 radius-inner border border-input-border type-code text-fg-muted overflow-x-auto",children:M.transport_key})]}),e.jsxs("div",{className:"flex justify-between gap-3 mt-6",children:[e.jsx(F,{color:"danger",outline:!0,onClick:()=>{ne(!1),xe(M),le(!0),W(null)},disabled:q,children:"Delete"}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx(F,{color:"muted",outline:!0,onClick:()=>{ne(!1),W(null)},disabled:q,children:"Cancel"}),e.jsx(F,{color:"primary",onClick:Xs,disabled:q||!M.name.trim(),children:q?e.jsxs(e.Fragment,{children:[e.jsx($,{"data-slot":"icon",className:"animate-spin"}),"Saving..."]}):"Save"})]})]})]})]})}),je&&Z&&e.jsx("div",{className:"fixed inset-0 z-[10010] flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm",onClick:s=>s.target===s.currentTarget&&le(!1),role:"dialog","aria-modal":"true","aria-labelledby":"delete-key-modal-title",children:e.jsxs("div",{className:"surface-modal radius-card p-6 max-w-md w-full",children:[e.jsx("h3",{id:"delete-key-modal-title",className:"type-micro mb-4",children:"Delete Transport Key"}),e.jsxs("p",{className:"text-fg-secondary mb-4",children:["Are you sure you want to delete ",e.jsxs("strong",{className:"text-fg-primary",children:["'",Z.name,"'"]}),"?"]}),Z.children&&Z.children.length>0&&e.jsx("div",{className:"bg-sys-indigo/10 border border-sys-indigo/30 radius-inner p-3 mb-4",children:e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Ge,{className:"w-4 h-4 text-sys-indigo flex-shrink-0 mt-0.5"}),e.jsxs("div",{className:"text-sm text-fg-secondary",children:["This key has ",Z.children.length," child key(s). Deleting will also remove all children."]})]})}),e.jsxs("div",{className:"flex justify-end gap-3",children:[e.jsx(F,{color:"muted",outline:!0,onClick:()=>{le(!1),xe(null)},disabled:q,children:"Cancel"}),e.jsx(F,{color:"danger",onClick:Ys,disabled:q,children:q?e.jsxs(e.Fragment,{children:[e.jsx($,{"data-slot":"icon",className:"animate-spin"}),"Deleting..."]}):"Delete"})]})]})})]})}export{ha as default}; diff --git a/frontend/dist/assets/ConfirmModal-Cf30hpC_.js b/frontend/dist/assets/ConfirmModal-BoB1If6b.js similarity index 68% rename from frontend/dist/assets/ConfirmModal-Cf30hpC_.js rename to frontend/dist/assets/ConfirmModal-BoB1If6b.js index 85608f5d..84c6cdcb 100644 --- a/frontend/dist/assets/ConfirmModal-Cf30hpC_.js +++ b/frontend/dist/assets/ConfirmModal-BoB1If6b.js @@ -1,6 +1,6 @@ -import{d as l,r as m,j as s,ac as x,dw as h,c as p,ad as f,dP as g,B as o}from"./index-C1ZF7cAz.js";import{T as j}from"./triangle-alert-B3ZB2VPZ.js";/** +import{d as l,r as m,j as s,ag as x,dt as h,c as g,ah as p,dN as f,B as o}from"./index-DhkG1Nx9.js";import{T as j}from"./triangle-alert-D8NErBXC.js";/** * @license lucide-react v0.559.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const u=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],M=l("trash-2",u),y={danger:"text-sys-red",warning:"text-sys-indigo",default:"text-sys-blue"},C={danger:"danger",warning:"warning",default:"primary"};function N({isOpen:t,title:n="Confirm",message:r,confirmLabel:i="Confirm",cancelLabel:c="Cancel",variant:e="default",onConfirm:d,onCancel:a}){return s.jsxs(x,{open:t,onClose:a,size:"sm",children:[s.jsx(h,{icon:s.jsx(j,{className:p("w-5 h-5",y[e])}),title:n,onClose:a}),s.jsx(f,{children:s.jsx("p",{className:"text-sm text-fg-secondary",children:r})}),s.jsxs(g,{children:[s.jsx(o,{color:"muted",onClick:a,className:"flex-1",children:c}),s.jsx(o,{color:C[e],onClick:d,className:"flex-1",children:i})]})]})}const w=m.memo(N);export{w as C,M as T}; + */const u=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],M=l("trash-2",u),y={danger:"text-sys-red",warning:"text-sys-indigo",default:"text-sys-blue"},C={danger:"danger",warning:"warning",default:"primary"};function N({isOpen:t,title:n="Confirm",message:r,confirmLabel:i="Confirm",cancelLabel:c="Cancel",variant:e="default",onConfirm:d,onCancel:a}){return s.jsxs(x,{open:t,onClose:a,size:"sm",children:[s.jsx(h,{icon:s.jsx(j,{className:g("w-5 h-5",y[e])}),title:n,onClose:a}),s.jsx(p,{children:s.jsx("p",{className:"text-sm text-fg-secondary",children:r})}),s.jsxs(f,{children:[s.jsx(o,{color:"muted",onClick:a,className:"flex-1",children:c}),s.jsx(o,{color:C[e],onClick:d,className:"flex-1",children:i})]})]})}const A=m.memo(N);export{A as C,M as T}; diff --git a/frontend/dist/assets/Contacts-BwzeErAl.js b/frontend/dist/assets/Contacts-BwzeErAl.js deleted file mode 100644 index ed3a63f7..00000000 --- a/frontend/dist/assets/Contacts-BwzeErAl.js +++ /dev/null @@ -1,52 +0,0 @@ -const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ContactsMapMapLibre-BEMNDe-F.js","assets/index-C1ZF7cAz.js","assets/BasemapLayer-CfNM-FKA.js","assets/consumer-registry-CFnLzQEu.js","assets/link-scoring-BoRGGDM6.js","assets/ConfirmModal-Cf30hpC_.js","assets/triangle-alert-B3ZB2VPZ.js","assets/DeepAnalysisModal-X0cTTPp0.js","assets/download-DbDw1ZiV.js","assets/database-CdKnhwkJ.js","assets/useMapViewStore-px_sYTaN.js","assets/index-DCNWD5GU.js","assets/refresh-cw-BjBvU2VX.js","assets/target-D0wbrQMn.js","assets/funnel-zG3cM6J7.js","assets/plus-BvRrZnfw.js","assets/easing-BGz60jqS.js","assets/wifi-BBDEuc94.js","assets/SignalIndicator-BDLlaquA.js","assets/chevron-right-DzbDJf-i.js","assets/node-types-BJeLdOcD.js","assets/badge-colors-BNUqIXCA.js","assets/LightSparkline-7x8sYJi9.js","assets/map-pin-DEktgLFN.js","assets/usePipelineStore-BEu0jDzA.js","assets/ping-C4M-6OVJ.js","assets/PageLayout-sd81yog0.js","assets/listbox-vfp6JG3P.js","assets/element-movement-CuySBNA6.js","assets/TimeRangeStepper-CxA2aT1o.js","assets/chat-utils-BzC-Ehs-.js","assets/CollisionExplorerModal-Bm7X5dgz.js","assets/monitor-smartphone-BQ_i3P0U.js","assets/DataBox-BADtaCfB.js","assets/circle-question-mark-CxqvWhsl.js","assets/network-4dDTHizq.js","assets/activity-Bmh45lNn.js","assets/search-CtlrlrHK.js","assets/index-DWhIzXT2.css","assets/BasemapLayer-B1CfjdFi.css","assets/ContactsMapMapLibre-BwWOEply.css"])))=>i.map(i=>d[i]); -import{d as L,j as e,r as n,bo as ss,bL as Ee,bM as Fe,$ as ne,w as Ce,a9 as Le,bN as ts,bO as fe,R as he,q as k,bP as as,L as Oe,bQ as ns,J as rs,bR as os,bS as is,bT as cs,H as ls,bU as ds,bV as ms,bW as xs,K as us,aa as ps,N as ve,bX as hs,bY as fs,b8 as ae,o as gs,I as js,bc as bs,c as ke}from"./index-C1ZF7cAz.js";import{useDiscoveredNodes as ys}from"./usePipelineStore-BEu0jDzA.js";import{p as Ns}from"./ping-C4M-6OVJ.js";import{c as Me}from"./node-types-BJeLdOcD.js";import{P as vs,a as ws,B as ks}from"./PageLayout-sd81yog0.js";import{L as Cs,a as pe}from"./listbox-vfp6JG3P.js";import{T as Te}from"./TimeRangeStepper-CxA2aT1o.js";import{u as Ms,e as Ss,f as _s,r as Ps}from"./consumer-registry-CFnLzQEu.js";import{e as Rs,g as Ls,a as Ts}from"./chat-utils-BzC-Ehs-.js";import{A as $s,b as Es,C as Fs}from"./SignalIndicator-BDLlaquA.js";import{C as Os,S as zs}from"./CollisionExplorerModal-Bm7X5dgz.js";import{E as Hs,T as Ds}from"./target-D0wbrQMn.js";import{D as As}from"./DataBox-BADtaCfB.js";import{C as G}from"./badge-colors-BNUqIXCA.js";import{C as ze}from"./circle-question-mark-CxqvWhsl.js";import{N as Is}from"./network-4dDTHizq.js";import{A as He}from"./activity-Bmh45lNn.js";import{T as Bs,C as Vs}from"./ConfirmModal-Cf30hpC_.js";import{M as $e}from"./monitor-smartphone-BQ_i3P0U.js";import{M as Us}from"./map-pin-DEktgLFN.js";import{S as qs}from"./search-CtlrlrHK.js";/** - * @license lucide-react v0.559.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const Ws=[["path",{d:"M17 7 7 17",key:"15tmo1"}],["path",{d:"M17 17H7V7",key:"1org7z"}]],Gs=L("arrow-down-left",Ws);/** - * @license lucide-react v0.559.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const Qs=[["path",{d:"m21 16-4 4-4-4",key:"f6ql7i"}],["path",{d:"M17 20V4",key:"1ejh1v"}],["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}]],Ks=L("arrow-up-down",Qs);/** - * @license lucide-react v0.559.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const Ys=[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}]],Xs=L("calendar",Ys);/** - * @license lucide-react v0.559.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const Js=[["path",{d:"M4 12V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2",key:"jrl274"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 16h2v6",key:"1bxocy"}],["path",{d:"M10 22h4",key:"ceow96"}],["rect",{x:"2",y:"16",width:"4",height:"6",rx:"2",key:"r45zd0"}]],Zs=L("file-digit",Js);/** - * @license lucide-react v0.559.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const et=[["path",{d:"M2 5h20",key:"1fs1ex"}],["path",{d:"M6 12h12",key:"8npq4p"}],["path",{d:"M9 19h6",key:"456am0"}]],st=L("list-filter",et);/** - * @license lucide-react v0.559.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const tt=[["path",{d:"M12.75 7.09a3 3 0 0 1 2.16 2.16",key:"1d4wjd"}],["path",{d:"M17.072 17.072c-1.634 2.17-3.527 3.912-4.471 4.727a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 1.432-4.568",key:"12yil7"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M8.475 2.818A8 8 0 0 1 20 10c0 1.183-.31 2.377-.81 3.533",key:"lhrkcz"}],["path",{d:"M9.13 9.13a3 3 0 0 0 3.74 3.74",key:"13wojd"}]],at=L("map-pin-off",tt);/** - * @license lucide-react v0.559.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const nt=[["path",{d:"M12 2v20",key:"t6zp3m"}],["path",{d:"m15 19-3 3-3-3",key:"11eu04"}],["path",{d:"m19 9 3 3-3 3",key:"1mg7y2"}],["path",{d:"M2 12h20",key:"9i4pu4"}],["path",{d:"m5 9-3 3 3 3",key:"j64kie"}],["path",{d:"m9 5 3-3 3 3",key:"l8vdw6"}]],rt=L("move",nt);/** - * @license lucide-react v0.559.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const ot=[["path",{d:"M4.9 16.1C1 12.2 1 5.8 4.9 1.9",key:"s0qx1y"}],["path",{d:"M7.8 4.7a6.14 6.14 0 0 0-.8 7.5",key:"1idnkw"}],["circle",{cx:"12",cy:"9",r:"2",key:"1092wv"}],["path",{d:"M16.2 4.8c2 2 2.26 5.11.8 7.47",key:"ojru2q"}],["path",{d:"M19.1 1.9a9.96 9.96 0 0 1 0 14.1",key:"rhi7fg"}],["path",{d:"M9.5 18h5",key:"mfy3pd"}],["path",{d:"m8 22 4-11 4 11",key:"25yftu"}]],it=L("radio-tower",ot);/** - * @license lucide-react v0.559.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const ct=[["path",{d:"M21.3 15.3a2.4 2.4 0 0 1 0 3.4l-2.6 2.6a2.4 2.4 0 0 1-3.4 0L2.7 8.7a2.41 2.41 0 0 1 0-3.4l2.6-2.6a2.41 2.41 0 0 1 3.4 0Z",key:"icamh8"}],["path",{d:"m14.5 12.5 2-2",key:"inckbg"}],["path",{d:"m11.5 9.5 2-2",key:"fmmyf7"}],["path",{d:"m8.5 6.5 2-2",key:"vc6u1g"}],["path",{d:"m17.5 15.5 2-2",key:"wo5hmg"}]],De=L("ruler",ct);/** - * @license lucide-react v0.559.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const lt=[["path",{d:"M16 17h6v-6",key:"t6n2it"}],["path",{d:"m22 17-8.5-8.5-5 5L2 7",key:"x473p"}]],dt=L("trending-down",lt);class mt extends n.Component{constructor(i){super(i),this.state={hasError:!1}}static getDerivedStateFromError(i){return{hasError:!0,error:i}}render(){var i;return this.state.hasError?e.jsx("div",{className:"map-container-16-9 flex items-center justify-center rounded-2xl surface-base",role:"alert","aria-live":"assertive",children:e.jsxs("div",{className:"text-center text-fg-muted p-4",children:[e.jsx("p",{className:"text-lg mb-2",children:"Map failed to load"}),e.jsx("p",{className:"text-sm text-fg-muted",children:((i=this.state.error)==null?void 0:i.message)||"Unknown error"}),e.jsx("p",{className:"text-xs text-fg-muted mt-2",children:"Try refreshing the page or check your browser's WebGL support."})]})}):this.props.children}}const xt=n.lazy(()=>ss(()=>import("./ContactsMapMapLibre-BEMNDe-F.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40])));function ut({neighbors:o,localNode:i,localHash:f,onRemoveNode:x,selectedNodeHash:g,onNodeSelected:y,highlightedEdgeKey:h,highlightedGhost:d}){return e.jsx(mt,{children:e.jsx(n.Suspense,{fallback:e.jsx("div",{className:"map-container-16-9 flex items-center justify-center rounded-2xl surface-base",role:"status","aria-live":"polite","aria-label":"Loading map",children:e.jsxs("div",{className:"text-fg-muted flex items-center gap-3",children:[e.jsx("div",{className:"w-5 h-5 border-2 border-sys-blue border-t-transparent rounded-full animate-spin","aria-hidden":"true"}),e.jsx("span",{children:"Loading map..."})]})}),children:e.jsx(xt,{neighbors:o,localNode:i,localHash:f,onRemoveNode:x,selectedNodeHash:g,onNodeSelected:y,highlightedEdgeKey:h,highlightedGhost:d})})})}function pt({hash:o,className:i="",size:f="sm",collisionInfo:x,isViterbiResolved:g}){const y=Ee(),h=Fe(),[d,H]=n.useState(!1),C=n.useMemo(()=>ne(o),[o]),T=n.useMemo(()=>x!==void 0?x:C?y.find(u=>u.prefix===C)??null:null,[C,y,x]),$=g??(h.totalPaths>0&&h.avgPathConfidence>=.7),z=n.useCallback(u=>{u.preventDefault(),u.stopPropagation(),H(!0)},[]),D=n.useCallback(()=>{H(!1)},[]);if(!T)return null;const N=f==="sm"?"w-3.5 h-3.5":"w-4 h-4",A=$?"text-sys-cyan hover:text-sys-cyan hover:bg-sys-cyan/10 focus:ring-sys-cyan/50":"text-signal-fair hover:text-sys-indigo hover:bg-signal-fair/10 focus:ring-signal-fair/50",Q=$?`Prefix conflict resolved by Viterbi HMM (${(h.avgPathConfidence*100).toFixed(0)}% confidence)`:`Prefix conflict: ${T.candidateCount} nodes share prefix "${C}"`;return e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:z,className:`inline-flex items-center justify-center p-0.5 rounded focus:outline-none focus:ring-2 transition-colors cursor-pointer touch-manipulation ${A} ${i}`,title:Q,"aria-label":`View prefix conflict for ${C}${$?" (Viterbi resolved)":""}`,children:$?e.jsxs("span",{className:"relative",children:[e.jsx(Hs,{className:N}),e.jsx(Ce,{className:"absolute -bottom-0.5 -right-0.5 w-2 h-2 text-sys-green"})]}):e.jsx(Zs,{className:N})}),e.jsx(Os,{isOpen:d,prefix:T.prefix,candidateHashes:T.candidateHashes,onClose:D})]})}const ht=n.memo(pt),Ae=[{target:"Contacts",fn:"name",minStage:1,when:Ss},{target:"Contacts",fn:"traceLinks.directed",minStage:2,when:_s}];Ps(Ae);function ft(o){return o<1e3?`${Math.round(o)}m`:`${(o/1e3).toFixed(1)}km`}function gt({hash:o,contact:i,isHub:f,isNeighbor:x,distance:g,centrality:y,sparklineData:h,neighborSignal:d,collisionInfo:H,isViterbiResolved:C,isPinging:T,isPingingThis:$,pingResult:z,pingError:D,gatewayInfo:N,lastForwarderPrefix:A,isMobile:Q,pathStability:u,onRowClick:K,onPing:E,onRemove:ge}){Ms(Ae);const I=i.latitude&&i.longitude&&i.latitude!==0&&i.longitude!==0,F=i.node_name||i.name||"Unknown",v=x&&d,re=Me(i),{isRepeater:_,isCompanion:Y,isRoomServer:j,isClient:X,label:J}=re,oe=x?`${J} — Direct RF contact (zero-hop neighbor)`:`${J} — Flood routing (multi-hop via mesh)`,Z=i.first_seen?Le(i.first_seen).replace(/ ago$/i," old"):null;return e.jsxs("div",{className:`contacts-grid-row ${f?"bg-sys-amber/5 border-l-2 border-l-sys-amber":""} ${I?"cursor-pointer hover:bg-subtle-fill":""}`,onClick:()=>K(o),children:[e.jsxs("div",{className:"contacts-col-node flex items-center gap-2 min-w-0",children:[v&&(d==null?void 0:d.avgSnr)!==null?e.jsx("div",{className:`w-2 h-2 rounded-full flex-shrink-0 self-center ${ts(d.avgSnr)}`}):e.jsx("div",{className:"w-2 flex-shrink-0"}),e.jsx("div",{className:"w-6 h-6 flex items-center justify-center flex-shrink-0",title:oe,children:(()=>{if(j&&_)return e.jsxs("div",{className:"relative w-5 h-5",children:[e.jsx(fe,{className:"w-5 h-5 absolute inset-0 text-sys-pink"}),e.jsx(zs,{className:"w-2.5 h-2.5 absolute -bottom-0.5 -right-0.5 text-sys-teal"})]});if(j)return e.jsx(fe,{className:"w-5 h-5 text-sys-pink"});if(_)return e.jsx("div",{className:"w-5 h-5 rounded-full flex items-center justify-center ring-[1.5px] ring-sys-blue",children:e.jsx(he,{className:"w-3.5 h-3.5 text-sys-blue"})});if((Y||X)&&F!=="Unknown"){const{emoji:w,cleanName:P}=Rs(F);return e.jsx("div",{className:"w-6 h-6 rounded-full flex items-center justify-center",style:{backgroundColor:Ls(P)},children:w?e.jsx("span",{className:"text-sm leading-none",children:w}):e.jsx("span",{className:"text-white text-[9px] font-bold tracking-tighter",children:Ts(F)})})}return e.jsx("div",{className:"w-6 h-6 rounded-full flex items-center justify-center bg-zinc-500/20",children:e.jsx(ze,{className:"w-3.5 h-3.5 text-sys-amber"})})})()}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-1.5 overflow-hidden",children:[e.jsx("span",{className:"roster-title truncate",title:F,children:F}),x&&e.jsx(k,{color:G.neighbor,compact:!0,className:"flex-shrink-0",children:"NBR"}),f&&e.jsxs(k,{color:G.hub,compact:!0,className:"flex items-center gap-1 flex-shrink-0",children:[e.jsx(Is,{className:"w-3 h-3"}),"HUB"]}),_&&e.jsx(k,{color:G.repeater,compact:!0,className:"flex-shrink-0",children:"RPT"}),j&&e.jsx(k,{color:G.room,compact:!0,className:"flex-shrink-0",children:"ROOM"}),Y&&e.jsx(k,{color:G.companion,compact:!0,className:"flex-shrink-0",children:"COMP"}),X&&e.jsx(k,{color:G.client,compact:!0,className:"flex-shrink-0",children:"CLIENT"}),Q&&e.jsxs(k,{color:"cyan",compact:!0,className:"flex items-center gap-0.5 flex-shrink-0",children:[e.jsx(rt,{className:"w-2.5 h-2.5"}),"MOBILE"]}),!I&&e.jsx("span",{className:"flex items-center gap-0.5 flex-shrink-0 text-fg-muted/50",title:"No GPS location provided",children:e.jsx(at,{className:"w-3 h-3"})})]}),e.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5",children:[e.jsx(As,{copy:!0,size:"compact",truncate:[8,6],children:o}),e.jsx(ht,{hash:o,collisionInfo:H,isViterbiResolved:C}),!x&&N&&e.jsxs(k,{color:"zinc",compact:!0,className:"flex items-center gap-0.5 flex-shrink-0",title:`Via ${N.name||N.prefix} (${N.hopCount} hop${N.hopCount!==1?"s":""})`,children:[e.jsx($s,{className:"w-2.5 h-2.5"}),e.jsx("span",{className:"font-mono",children:N.prefix}),N.hopCount>1&&e.jsxs("span",{className:"opacity-60",children:["+",N.hopCount-1]})]}),A&&!x&&e.jsxs(k,{color:"zinc",compact:!0,className:"flex items-center gap-0.5 flex-shrink-0",title:`Last forwarded by ${A}`,children:[e.jsx(Gs,{className:"w-2.5 h-2.5"}),e.jsx("span",{className:"font-mono",children:A})]}),u!=null&&u!==0&&e.jsx(k,{color:u>0?"green":"amber",compact:!0,className:"flex items-center gap-0.5 flex-shrink-0",title:u>0?"Path stability improving":"Path stability declining",children:u>0?e.jsx(as,{className:"w-2.5 h-2.5"}):e.jsx(dt,{className:"w-2.5 h-2.5"})}),h.length>0&&(()=>{const w=h.reduce((ie,je)=>ie+je.count,0);if(w===0)return null;const P=w/24;return e.jsxs(k,{color:"zinc",compact:!0,className:"flex items-center gap-0.5 flex-shrink-0",title:`${w} packets in last 24h (~${P.toFixed(1)}/hr)`,children:[e.jsx(it,{className:"w-2.5 h-2.5"}),e.jsxs("span",{children:[P<1?"<1":P.toFixed(0),"/hr"]})]})})(),Z&&e.jsxs(k,{color:"zinc",compact:!0,className:"flex items-center gap-0.5 flex-shrink-0 opacity-70",title:`First discovered ${Z}`,children:[e.jsx(Xs,{className:"w-2.5 h-2.5"}),e.jsx("span",{children:Z})]})]})]})]}),e.jsxs("div",{className:"contacts-col-signal flex items-center justify-end gap-2",children:[v&&(d==null?void 0:d.avgRssi)!==null&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Es,{rssi:d.avgRssi,className:"w-3.5 h-3.5"}),e.jsx("span",{className:"type-data-xs text-fg-muted",children:Math.round(d.avgRssi)})]}),v&&(d==null?void 0:d.avgSnr)!==null&&e.jsxs("span",{className:"type-data-xs text-fg-muted",children:[d.avgSnr.toFixed(1)," dB"]})]}),e.jsx("div",{className:"contacts-col-distance flex items-center justify-end gap-1 text-fg-muted",children:g!=null&&e.jsxs(e.Fragment,{children:[e.jsx(De,{className:"w-3 h-3"}),e.jsx("span",{className:"type-data-xs",children:ft(g)})]})}),e.jsx("div",{className:"contacts-col-centrality flex items-center justify-end gap-1",children:y>0&&e.jsxs(e.Fragment,{children:[e.jsx(He,{className:"w-3 h-3 text-sys-indigo"}),e.jsxs("span",{className:"type-data-xs text-fg-muted",children:[(y*100).toFixed(0),"%"]})]})}),e.jsx("div",{className:"contacts-col-seen flex items-center justify-end",children:e.jsx("span",{className:"type-data-xs text-fg-primary whitespace-nowrap",children:i.last_seen?Le(i.last_seen):"—"})}),e.jsxs("div",{className:"contacts-col-actions flex items-center justify-end gap-1",children:[x&&e.jsx(e.Fragment,{children:z?e.jsxs("div",{className:"flex items-center gap-1 text-sys-green",title:`RTT: ${z.rtt_ms.toFixed(0)}ms`,children:[e.jsx(Ce,{className:"w-3.5 h-3.5"}),e.jsxs("span",{className:"type-data-xs hidden sm:inline",children:[z.snr_db.toFixed(1),"dB"]})]}):D?e.jsx("span",{className:"text-sys-red text-xs",title:D,children:"✗"}):e.jsx("button",{onClick:w=>E(o,w),disabled:T,className:"p-1 sm:p-1.5 radius-inner text-fg-muted/50 hover:text-sys-blue hover:bg-sys-blue/10 transition-base disabled:opacity-50 disabled:cursor-not-allowed",title:"Ping neighbor for updated signal info",children:$?e.jsx(Oe,{className:"w-3.5 h-3.5 sm:w-4 sm:h-4 animate-spin"}):e.jsx(Ds,{className:"w-3.5 h-3.5 sm:w-4 sm:h-4"})})}),e.jsx("button",{onClick:w=>{w.stopPropagation(),ge(o,F)},className:"p-1 sm:p-1.5 radius-inner text-fg-muted/50 hover:text-sys-red hover:bg-sys-red/10 transition-base",title:"Remove contact",children:e.jsx(Bs,{className:"w-3.5 h-3.5 sm:w-4 sm:h-4"})})]})]})}const jt=n.memo(gt),bt=6371e3,yt=[],Nt=[{field:"lastHeard",icon:Fs,label:"Recent"},{field:"distance",icon:De,label:"Distance"},{field:"centrality",icon:He,label:"Centrality"}];function vt(o){switch(o){case"room_server":return"room";case"repeater":return"repeater";case"companion":return"companion";case"unknown":return"companion"}}function wt(o){const i=Me(o);return vt(i.type)}function we(o,i){const{color:f="primary",border:x=!1}=i??{};return ke("flex items-center gap-1.5 px-2 py-1.5 text-sm radius-inner transition-base",o?f==="success"?"bg-sys-green/20 text-sys-green":"bg-sys-blue/20 text-sys-blue":"text-fg-muted hover:text-fg-secondary hover-bg",x&&(o?f==="success"?"border border-sys-green/30":"border border-sys-blue/30":"border border-transparent"))}function kt(o,i,f,x){const g=(f-o)*Math.PI/180,y=(x-i)*Math.PI/180,h=Math.sin(g/2)*Math.sin(g/2)+Math.cos(o*Math.PI/180)*Math.cos(f*Math.PI/180)*Math.sin(y/2)*Math.sin(y/2),d=2*Math.atan2(Math.sqrt(h),Math.sqrt(1-h));return bt*d}function Ct(){const{stats:o}=ns(),i=rs(),f=os(),x=is(),g=cs(),y=ls(),h=ds(),d=ms(),H=xs(),C=us(),T=ps(),$=ve[C],z=Ee(),D=Fe(),N=hs(),A=D.totalPaths>0&&D.avgPathConfidence>=.7,Q=n.useMemo(()=>{const s=new Map;for(const t of z)s.set(t.prefix,t);return s},[z]),[u,K]=n.useState(null),[E,ge]=n.useState("lastHeard"),[I,F]=n.useState("desc"),[v,re]=n.useState(""),[_,Y]=n.useState(!1),[j,X]=n.useState(new Set),[J,oe]=n.useState(!1),[Z,w]=n.useState(null),[P,ie]=n.useState(null),[je,be]=n.useState(new Map),[Ie,ee]=n.useState(new Map),[M,Be]=n.useState(25),[U,ce]=n.useState(25),ye=n.useRef(null),se=n.useMemo(()=>(o==null?void 0:o.neighbors)??{},[o==null?void 0:o.neighbors]),Ne=ys(),le=n.useMemo(()=>{if(Ne.size===0)return se;const s=new Set;for(const a of Object.keys(se))s.add((a.startsWith("0x")?a.slice(2):a).toLowerCase());let t=null;for(const[a,r]of Ne){const c=(a.startsWith("0x")?a.slice(2):a).toLowerCase();s.has(c)||(t||(t={...se}),t[a]={last_seen:r.lastSeen,name:r.name??void 0,node_name:r.name??void 0,latitude:r.latitude,longitude:r.longitude,is_repeater:r.nodeType==="repeater",contact_type:r.nodeType==="repeater"?"Repeater":r.nodeType==="companion"?"Companion":r.nodeType==="room_server"?"Room Server":void 0})}return t??se},[se,Ne]),B=n.useMemo(()=>{const t=Date.now()/1e3-$.minutes*60;return Object.fromEntries(Object.entries(le).filter(([a,r])=>i.has(a)?!1:(r.last_seen??0)>=t))},[le,i,$.minutes]),R=fs(),q=o==null?void 0:o.local_hash,Ve=n.useMemo(()=>{const s=new Map;if(!q||h.size===0)return s;for(const[t,a]of h)if(t.endsWith(`→${q}`)&&a.hops.length>1){const r=t.split("→")[0],c=a.hops[a.hops.length-1];s.set(r,c)}return s},[h,q]),de=n.useMemo(()=>{const s=new Map;if(!(R!=null&&R.latitude)||!(R!=null&&R.longitude))return s;for(const[t,a]of Object.entries(B))a.latitude&&a.longitude&&a.latitude!==0&&a.longitude!==0?s.set(t,kt(R.latitude,R.longitude,a.latitude,a.longitude)):s.set(t,null);return s},[B,R]),{neighborHashSet:me,neighborSignalMap:Ue}=n.useMemo(()=>{const s=new Set,t=new Map;for(const a of y)s.add(a.hash),t.set(a.hash,{avgRssi:a.avgRssi,avgSnr:a.avgSnr});return{neighborHashSet:s,neighborSignalMap:t}},[y]),Se=n.useMemo(()=>{const s=v.toLowerCase().trim(),t=s==="neighbor"||s==="neighbors",a=_||t,r=j.size>0;return Object.fromEntries(Object.entries(B).filter(([c,l])=>{if(r){const S=wt(l);if(!j.has(S))return!1}if(a&&!me.has(c))return!1;if(t||!s)return!0;const V=(l.node_name||l.name||"").toLowerCase(),b=ne(c).toLowerCase();return V.includes(s)||b.includes(s)||c.toLowerCase().includes(s)}))},[B,v,_,me,j]),p=n.useMemo(()=>{const s=Object.entries(Se),t=v.toLowerCase().trim(),a=t.length===2&&/^[0-9a-f]{2}$/i.test(t);return s.sort(([r,c],[l,V])=>{if(a){const S=ne(r).toLowerCase(),O=ne(l).toLowerCase(),te=S===t,xe=O===t;if(te&&!xe)return-1;if(xe&&!te)return 1}let b=0;switch(E){case"lastHeard":b=(c.last_seen||0)-(V.last_seen||0);break;case"distance":{const S=de.get(r)??null,O=de.get(l)??null;S===null&&O===null?b=0:S===null?b=1:O===null?b=-1:b=S-O;break}case"centrality":{const S=g.get(r)||0,O=g.get(l)||0;b=S-O;break}}return I==="desc"?-b:b})},[Se,E,I,de,g,v]),m=n.useMemo(()=>{let s=0,t=0,a=0,r=0,c=0;for(const[,l]of p){const V=Me(l),b=l.latitude&&l.longitude&&l.latitude!==0&&l.longitude!==0;switch(V.type){case"room_server":a++;break;case"repeater":t++;break;case"companion":s++;break;case"unknown":c++;break}b&&r++}return{companions:s,repeaters:t,roomServers:a,total:p.length,withLocation:r,unknown:c}},[p]),qe=n.useMemo(()=>new Set(x),[x]),_e=n.useMemo(()=>M===0?p:p.slice(0,U),[p,U,M]);n.useEffect(()=>{ce(M||p.length)},[E,I,v,_,j,M,p.length]),n.useEffect(()=>{const s=t=>{t.target.closest("[data-dropdown]")||oe(!1)};return document.addEventListener("click",s),()=>document.removeEventListener("click",s)},[]),n.useEffect(()=>{if(M===0)return;const s=new IntersectionObserver(t=>{t[0].isIntersecting&&UMath.min(a+M,p.length))},{threshold:.1,rootMargin:"100px"});return ye.current&&s.observe(ye.current),()=>s.disconnect()},[M,U,p.length]);const We=n.useCallback(s=>{Be(s),ce(s||p.length)},[p.length]),Ge=n.useCallback(s=>{E===s?F(t=>t==="desc"?"asc":"desc"):(ge(s),F("desc"))},[E]),Qe=n.useCallback(s=>{const t=B[s];t!=null&&t.latitude&&(t!=null&&t.longitude)&&t.latitude!==0&&t.longitude!==0&&w(s)},[B]),Ke=n.useCallback(()=>{w(null)},[]),Ye=n.useCallback((s,t)=>{K({hash:s,name:t})},[]),Xe=n.useCallback(async(s,t)=>{if(t.stopPropagation(),!P){ie(s),be(a=>{const r=new Map(a);return r.delete(s),r}),ee(a=>{const r=new Map(a);return r.delete(s),r});try{const a=s.startsWith("0x")?s.slice(0,4):`0x${s.slice(0,2)}`,r=await Ns(a,30);r.success&&r.data?(be(c=>new Map(c).set(s,r.data)),setTimeout(()=>{be(c=>{const l=new Map(c);return l.delete(s),l})},1e4)):(ee(c=>new Map(c).set(s,r.error||"Ping failed")),setTimeout(()=>{ee(c=>{const l=new Map(c);return l.delete(s),l})},5e3))}catch(a){const r=a instanceof Error?a.message:"Ping failed";ee(c=>new Map(c).set(s,r)),setTimeout(()=>{ee(c=>{const l=new Map(c);return l.delete(s),l})},5e3)}finally{ie(null)}}},[P]);return e.jsxs(vs,{children:[e.jsx(ws,{title:"Contacts",icon:e.jsx(ae,{}),controls:e.jsxs("div",{className:"flex items-center gap-3 sm:gap-5",children:[e.jsxs("div",{className:"hidden sm:flex items-center gap-4",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-xs text-fg-muted",children:"Total:"}),e.jsxs("span",{className:"data-box flex items-center gap-1.5 cursor-default",title:`${m.total} discovered node${m.total!==1?"s":""} on the mesh network`,children:[e.jsx(ae,{className:"w-3.5 h-3.5 text-fg-secondary"}),e.jsx("span",{children:m.total})]})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-xs text-fg-muted",children:"Types:"}),m.repeaters>0&&e.jsxs("span",{className:"data-box flex items-center gap-1.5 cursor-default",title:"Repeaters",children:[e.jsx(he,{className:"w-3.5 h-3.5 text-sys-blue"}),e.jsx("span",{children:m.repeaters})]}),m.companions>0&&e.jsxs("span",{className:"data-box flex items-center gap-1.5 cursor-default",title:"Companions",children:[e.jsx($e,{className:"w-3.5 h-3.5 text-fg-muted"}),e.jsx("span",{children:m.companions})]}),m.roomServers>0&&e.jsxs("span",{className:"data-box flex items-center gap-1.5 cursor-default",title:"Room Servers",children:[e.jsx(fe,{className:"w-3.5 h-3.5 text-sys-pink"}),e.jsx("span",{children:m.roomServers})]}),m.withLocation>0&&e.jsxs("span",{className:"data-box flex items-center gap-1.5 cursor-default",title:"With GPS location",children:[e.jsx(Us,{className:"w-3.5 h-3.5 text-sys-green"}),e.jsx("span",{children:m.withLocation})]}),m.unknown>0&&e.jsxs("span",{className:"data-box flex items-center gap-1.5 cursor-default",title:"Unknown type",children:[e.jsx(ze,{className:"w-3.5 h-3.5 text-sys-amber"}),e.jsx("span",{children:m.unknown})]})]})]}),e.jsxs("div",{className:"flex sm:hidden items-center gap-1.5",children:[e.jsxs("span",{className:"data-box !px-1.5 !py-0.5 !text-[10px] flex items-center gap-1",children:[e.jsx(ae,{className:"w-3 h-3 text-fg-secondary"}),e.jsx("span",{children:m.total})]}),m.repeaters>0&&e.jsxs("span",{className:"data-box !px-1.5 !py-0.5 !text-[10px] flex items-center gap-1",children:[e.jsx(he,{className:"w-3 h-3 text-sys-blue"}),e.jsx("span",{children:m.repeaters})]}),m.companions>0&&e.jsxs("span",{className:"data-box !px-1.5 !py-0.5 !text-[10px] flex items-center gap-1",children:[e.jsx($e,{className:"w-3 h-3 text-fg-muted"}),e.jsx("span",{children:m.companions})]}),m.roomServers>0&&e.jsxs("span",{className:"data-box !px-1.5 !py-0.5 !text-[10px] flex items-center gap-1",children:[e.jsx(fe,{className:"w-3 h-3 text-sys-pink"}),e.jsx("span",{children:m.roomServers})]}),e.jsx(Te,{ranges:ve,selectedIndex:C,onSelect:T,size:"sm"})]}),e.jsx("div",{className:"hidden sm:block",children:e.jsx(Te,{ranges:ve,selectedIndex:C,onSelect:T})})]})}),e.jsxs(ks,{children:[H?e.jsx(ut,{neighbors:B,localNode:R??void 0,localHash:q,onRemoveNode:f,selectedNodeHash:Z,onNodeSelected:Ke}):e.jsx("div",{className:"surface-base radius-card aspect-video flex items-center justify-center",children:e.jsxs("div",{className:"flex flex-col items-center gap-3",children:[e.jsx("div",{className:"w-6 h-6 border-2 border-sys-blue border-t-transparent rounded-full animate-spin"}),e.jsx("span",{className:"text-sm text-fg-muted",children:"Loading map..."})]})}),e.jsx(gs,{noPadding:!0,children:H?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-1.5 sm:gap-2 px-3 sm:px-4 py-2.5 border-b border-edge-subtle",children:[e.jsx("span",{className:"icon-md flex items-center justify-center text-icon-card-title flex-shrink-0",children:e.jsx(ae,{})}),e.jsx("span",{className:"type-micro flex-shrink-0 mr-auto hidden sm:block",children:"Discovered Contacts"}),e.jsx(js,{type:"search",size:"sm",value:v,onChange:s=>re(s.target.value),placeholder:"Search...",leadingIcon:e.jsx(qs,{className:"w-3.5 h-3.5"}),trailingIcon:v?e.jsx("button",{onClick:()=>{re(""),(v.toLowerCase().trim()==="neighbor"||v.toLowerCase().trim()==="neighbors")&&Y(!1)},className:"text-fg-muted hover:text-fg-secondary",children:e.jsx(bs,{className:"w-3 h-3"})}):void 0,className:"w-24 sm:w-32 xl:w-44","aria-label":"Search contacts"}),e.jsx("div",{className:"h-4 w-px bg-border-subtle flex-shrink-0"}),e.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[e.jsxs("div",{className:"relative","data-dropdown":!0,children:[e.jsxs("button",{onClick:()=>oe(!J),className:we(j.size>0,{border:!0}),title:"Filter by contact type",children:[e.jsx(st,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"hidden xl:inline",children:"Filter"}),j.size>0&&e.jsx("span",{className:"tabular-nums text-xs bg-sys-blue/30 px-1 rounded",children:j.size})]}),J&&e.jsxs("div",{className:"absolute right-0 top-full mt-1 z-50 surface-elevated radius-inner py-1 min-w-[140px]",children:[[{key:"repeater",label:"Repeaters"},{key:"companion",label:"Companions"},{key:"room",label:"Rooms"}].map(({key:s,label:t})=>e.jsxs("button",{onClick:()=>{X(a=>{const r=new Set(a);return r.has(s)?r.delete(s):r.add(s),r})},className:"w-full px-3 py-1.5 text-sm text-left hover-bg transition-base flex items-center gap-2",children:[e.jsx("span",{className:ke("w-4 h-4 flex items-center justify-center radius-badge border",j.has(s)?"bg-sys-blue border-sys-blue text-white":"border-edge-subtle"),children:j.has(s)&&e.jsx(Ce,{className:"w-3 h-3"})}),e.jsx("span",{className:j.has(s)?"text-fg-primary":"text-fg-secondary",children:t})]},s)),j.size>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"border-t border-edge-subtle my-1"}),e.jsx("button",{onClick:()=>X(new Set),className:"w-full px-3 py-1.5 text-sm text-left text-fg-muted hover:text-fg-secondary hover-bg transition-base",children:"Clear filters"})]})]})]}),me.size>0&&e.jsxs("button",{onClick:()=>Y(!_),className:we(_,{color:"success",border:!0}),title:_?"Show all contacts":"Show only MeshCore neighbors (direct RF contact)",children:[e.jsx(he,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"hidden xl:inline",children:"Neighbors"})]})]}),e.jsx("div",{className:"h-4 w-px bg-border-subtle flex-shrink-0"}),e.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[Nt.map(({field:s,icon:t,label:a})=>e.jsxs("button",{onClick:()=>Ge(s),className:we(E===s),title:`Sort by ${a.toLowerCase()}`,children:[e.jsx(t,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"hidden xl:inline",children:a}),E===s&&e.jsx(Ks,{className:ke("w-3 h-3",I==="asc"&&"rotate-180")})]},s)),e.jsx("div",{className:"h-4 w-px bg-border-subtle"}),e.jsxs(Cs,{value:M,onChange:We,className:"w-auto min-w-[50px] [&_button]:py-1 [&_button]:px-2 [&_button]:text-xs [&_button]:min-h-0","aria-label":"Items per page",children:[e.jsx(pe,{value:25,children:"25"}),e.jsx(pe,{value:50,children:"50"}),e.jsx(pe,{value:100,children:"100"}),e.jsx(pe,{value:0,children:"All"})]})]})]}),p.length>0?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"hidden sm:grid contacts-grid-header border-b border-edge-subtle/50 px-3 py-2 type-micro text-fg-muted",children:[e.jsx("div",{className:"contacts-col-node",children:"Node"}),e.jsx("div",{className:"contacts-col-signal text-right",children:"Signal"}),e.jsx("div",{className:"contacts-col-distance text-right",children:"Distance"}),e.jsx("div",{className:"contacts-col-centrality text-right",children:"Centrality"}),e.jsx("div",{className:"contacts-col-seen text-right",children:"Last Seen"}),e.jsx("div",{className:"contacts-col-actions"})]}),e.jsx("div",{className:"divide-y divide-edge-subtle/30",children:_e.map(([s,t])=>{const a=ne(s),r=qe.has(s),c=me.has(s),l=de.get(s)??null,V=g.get(s)||0,b=c?Ue.get(s):void 0,S=a?Q.get(a)??null:null,O=N.get(s)??yt;let te=null;if(!c&&q&&h.size>0){const Ze=`${s}→${q}`,ue=h.get(Ze);if(ue&&ue.hops.length>0){const Pe=ue.hops[0],Re=Object.keys(le).find(es=>es.toUpperCase().startsWith(Pe.toUpperCase())),W=Re?le[Re]:null;te={prefix:Pe,name:(W==null?void 0:W.node_name)??(W==null?void 0:W.name)??null,hopCount:ue.hopCount}}}const xe=d.has(s),Je=Ve.get(s)??null;return e.jsx(jt,{hash:s,contact:t,isHub:r,isNeighbor:c,distance:l,centrality:V,sparklineData:O,neighborSignal:b,collisionInfo:S,isViterbiResolved:A,isPinging:P!==null,isPingingThis:P===s,pingResult:je.get(s),pingError:Ie.get(s),gatewayInfo:te,lastForwarderPrefix:Je,isMobile:xe,onRowClick:Qe,onPing:Xe,onRemove:Ye},s)})}),M>0&&U0&&Uce(s=>Math.min(s+M,p.length)),className:"text-sys-blue hover:text-sys-blue/80 transition-base",children:"Load more"})]})]}):e.jsxs("div",{className:"roster-empty",children:[e.jsx(ae,{className:"roster-empty-icon"}),e.jsx("div",{className:"type-label text-fg-secondary",children:"No Contacts Discovered"}),e.jsx("div",{className:"type-data-xs text-fg-muted mt-1",children:"Contacts will appear here as they advertise on the mesh network."})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center justify-between px-5 py-4 border-b border-edge-subtle",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-4 h-4 rounded bg-elevated animate-pulse"}),e.jsx("div",{className:"w-32 h-4 rounded bg-elevated animate-pulse"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-16 h-6 rounded bg-elevated animate-pulse"}),e.jsx("div",{className:"w-24 h-6 rounded bg-elevated animate-pulse"}),e.jsx("div",{className:"w-16 h-6 rounded bg-elevated animate-pulse"})]})]}),e.jsx("div",{className:"px-3 py-3 space-y-3",children:[...Array(5)].map((s,t)=>e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-5 h-5 rounded bg-elevated animate-pulse"}),e.jsxs("div",{className:"flex-1 space-y-1.5",children:[e.jsx("div",{className:"h-4 w-32 rounded bg-elevated animate-pulse"}),e.jsx("div",{className:"h-3 w-24 rounded bg-elevated animate-pulse"})]}),e.jsx("div",{className:"w-12 h-4 rounded bg-elevated animate-pulse"}),e.jsx("div",{className:"w-16 h-4 rounded bg-elevated animate-pulse"})]},t))})]})})]}),e.jsx(Vs,{isOpen:!!u,title:"Remove Contact",message:`Are you sure you would like to remove ${(u==null?void 0:u.name)||"this contact"}?`,confirmLabel:"Remove",cancelLabel:"Cancel",variant:"danger",onConfirm:()=>{u&&f(u.hash),K(null)},onCancel:()=>K(null)})]})}const Gt=Object.freeze(Object.defineProperty({__proto__:null,default:Ct},Symbol.toStringTag,{value:"Module"}));export{Gt as C,ht as P,De as R,dt as T}; diff --git a/frontend/dist/assets/Contacts-DPHkM_MR.js b/frontend/dist/assets/Contacts-DPHkM_MR.js new file mode 100644 index 00000000..02541c27 --- /dev/null +++ b/frontend/dist/assets/Contacts-DPHkM_MR.js @@ -0,0 +1,52 @@ +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ContactsMapMapLibre-Dy88OlAW.js","assets/index-DhkG1Nx9.js","assets/BasemapLayer-CfNeG6Jg.js","assets/consumer-registry-CTQIn0m9.js","assets/link-scoring-Ctdu509L.js","assets/ConfirmModal-BoB1If6b.js","assets/triangle-alert-D8NErBXC.js","assets/DeepAnalysisModal-DuvRb3Nu.js","assets/download-d0PZoGJ2.js","assets/database-DE8k8U0g.js","assets/useMapViewStore-BMqcaUNl.js","assets/index-Bx_G2nLG.js","assets/refresh-cw-CA_1u8Jn.js","assets/target-BiAgFlf5.js","assets/funnel-Dr2cCUci.js","assets/plus-Pe5yI_FS.js","assets/easing-Ch_Y3tms.js","assets/wifi-u03iIDZF.js","assets/SignalIndicator-DEXVYOhU.js","assets/chevron-right-na13OQfy.js","assets/node-types-CgBRFpS8.js","assets/badge-colors-BNUqIXCA.js","assets/LightSparkline-Bg_XrgTS.js","assets/map-pin-BHGohRD7.js","assets/usePipelineStore-B9ir1Xwp.js","assets/ping-CLlM2Uim.js","assets/PageLayout-BkUTZXJb.js","assets/listbox-CyP6uw8j.js","assets/element-movement-BPGrReFv.js","assets/TimeRangeStepper-RSPVaByt.js","assets/chat-utils-DA-kxQ-o.js","assets/CollisionExplorerModal-Cs8y9_83.js","assets/monitor-smartphone-jV9bAwUA.js","assets/DataBox-BMesbbaF.js","assets/circle-question-mark--xh93QHC.js","assets/network-DBF70fah.js","assets/activity-BG24yKp1.js","assets/search-BmkxxIVP.js","assets/index-DySMpv2s.css","assets/BasemapLayer-B1CfjdFi.css","assets/ContactsMapMapLibre-BwWOEply.css"])))=>i.map(i=>d[i]); +import{d as P,a5 as ss,j as e,r as a,_ as ts,bM as Ee,bN as Oe,a2 as oe,y as ke,ad as Pe,bO as ns,bP as he,R as pe,v as k,bQ as as,L as Fe,bR as rs,N as os,bS as is,bT as cs,bU as ls,K as ds,bV as ms,bW as xs,O as us,ae as ps,P as Ne,bX as hs,bY as fs,bb as re,q as gs,I as js,bf as bs,c as we}from"./index-DhkG1Nx9.js";import{useDiscoveredNodes as ys}from"./usePipelineStore-B9ir1Xwp.js";import{p as Ns}from"./ping-CLlM2Uim.js";import{c as Ce}from"./node-types-CgBRFpS8.js";import{P as vs,a as ws,B as ks}from"./PageLayout-BkUTZXJb.js";import{L as Cs,a as ue}from"./listbox-CyP6uw8j.js";import{T as Te}from"./TimeRangeStepper-RSPVaByt.js";import{u as Ms,e as Ss,f as _s,r as Rs}from"./consumer-registry-CTQIn0m9.js";import{e as Ps,g as Ts,a as Ls}from"./chat-utils-DA-kxQ-o.js";import{A as $s,b as Es,C as Os}from"./SignalIndicator-DEXVYOhU.js";import{C as Fs,S as zs}from"./CollisionExplorerModal-Cs8y9_83.js";import{E as Hs,T as Ds}from"./target-BiAgFlf5.js";import{D as As}from"./DataBox-BMesbbaF.js";import{C as X}from"./badge-colors-BNUqIXCA.js";import{C as ze}from"./circle-question-mark--xh93QHC.js";import{N as Is}from"./network-DBF70fah.js";import{A as He}from"./activity-BG24yKp1.js";import{T as Bs,C as Vs}from"./ConfirmModal-BoB1If6b.js";import{M as Le}from"./monitor-smartphone-jV9bAwUA.js";import{M as Us}from"./map-pin-BHGohRD7.js";import{S as qs}from"./search-BmkxxIVP.js";/** + * @license lucide-react v0.559.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Ws=[["path",{d:"M17 7 7 17",key:"15tmo1"}],["path",{d:"M17 17H7V7",key:"1org7z"}]],Gs=P("arrow-down-left",Ws);/** + * @license lucide-react v0.559.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Qs=[["path",{d:"m21 16-4 4-4-4",key:"f6ql7i"}],["path",{d:"M17 20V4",key:"1ejh1v"}],["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}]],Ks=P("arrow-up-down",Qs);/** + * @license lucide-react v0.559.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Ys=[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}]],Xs=P("calendar",Ys);/** + * @license lucide-react v0.559.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Zs=[["path",{d:"M4 12V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2",key:"jrl274"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 16h2v6",key:"1bxocy"}],["path",{d:"M10 22h4",key:"ceow96"}],["rect",{x:"2",y:"16",width:"4",height:"6",rx:"2",key:"r45zd0"}]],Js=P("file-digit",Zs);/** + * @license lucide-react v0.559.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const et=[["path",{d:"M2 5h20",key:"1fs1ex"}],["path",{d:"M6 12h12",key:"8npq4p"}],["path",{d:"M9 19h6",key:"456am0"}]],st=P("list-filter",et);/** + * @license lucide-react v0.559.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const tt=[["path",{d:"M12.75 7.09a3 3 0 0 1 2.16 2.16",key:"1d4wjd"}],["path",{d:"M17.072 17.072c-1.634 2.17-3.527 3.912-4.471 4.727a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 1.432-4.568",key:"12yil7"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M8.475 2.818A8 8 0 0 1 20 10c0 1.183-.31 2.377-.81 3.533",key:"lhrkcz"}],["path",{d:"M9.13 9.13a3 3 0 0 0 3.74 3.74",key:"13wojd"}]],nt=P("map-pin-off",tt);/** + * @license lucide-react v0.559.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const at=[["path",{d:"M12 2v20",key:"t6zp3m"}],["path",{d:"m15 19-3 3-3-3",key:"11eu04"}],["path",{d:"m19 9 3 3-3 3",key:"1mg7y2"}],["path",{d:"M2 12h20",key:"9i4pu4"}],["path",{d:"m5 9-3 3 3 3",key:"j64kie"}],["path",{d:"m9 5 3-3 3 3",key:"l8vdw6"}]],rt=P("move",at);/** + * @license lucide-react v0.559.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const ot=[["path",{d:"M4.9 16.1C1 12.2 1 5.8 4.9 1.9",key:"s0qx1y"}],["path",{d:"M7.8 4.7a6.14 6.14 0 0 0-.8 7.5",key:"1idnkw"}],["circle",{cx:"12",cy:"9",r:"2",key:"1092wv"}],["path",{d:"M16.2 4.8c2 2 2.26 5.11.8 7.47",key:"ojru2q"}],["path",{d:"M19.1 1.9a9.96 9.96 0 0 1 0 14.1",key:"rhi7fg"}],["path",{d:"M9.5 18h5",key:"mfy3pd"}],["path",{d:"m8 22 4-11 4 11",key:"25yftu"}]],it=P("radio-tower",ot);/** + * @license lucide-react v0.559.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const ct=[["path",{d:"M21.3 15.3a2.4 2.4 0 0 1 0 3.4l-2.6 2.6a2.4 2.4 0 0 1-3.4 0L2.7 8.7a2.41 2.41 0 0 1 0-3.4l2.6-2.6a2.41 2.41 0 0 1 3.4 0Z",key:"icamh8"}],["path",{d:"m14.5 12.5 2-2",key:"inckbg"}],["path",{d:"m11.5 9.5 2-2",key:"fmmyf7"}],["path",{d:"m8.5 6.5 2-2",key:"vc6u1g"}],["path",{d:"m17.5 15.5 2-2",key:"wo5hmg"}]],De=P("ruler",ct);/** + * @license lucide-react v0.559.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const lt=[["path",{d:"M16 17h6v-6",key:"t6n2it"}],["path",{d:"m22 17-8.5-8.5-5 5L2 7",key:"x473p"}]],dt=P("trending-down",lt);class mt extends a.Component{constructor(i){super(i),this.state={hasError:!1}}static getDerivedStateFromError(i){return{hasError:!0,error:i}}render(){var i;return this.state.hasError?e.jsx("div",{className:"map-container-16-9 flex items-center justify-center rounded-2xl surface-base",role:"alert","aria-live":"assertive",children:e.jsxs("div",{className:"text-center text-fg-muted p-4",children:[e.jsx("p",{className:"text-lg mb-2",children:"Map failed to load"}),e.jsx("p",{className:"text-sm text-fg-muted",children:((i=this.state.error)==null?void 0:i.message)||"Unknown error"}),e.jsx("p",{className:"text-xs text-fg-muted mt-2",children:"Try refreshing the page or check your browser's WebGL support."})]})}):this.props.children}}const xt=a.lazy(()=>ts(()=>import("./ContactsMapMapLibre-Dy88OlAW.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40]))),$e=()=>e.jsx("div",{className:"map-container-16-9 flex items-center justify-center rounded-2xl surface-base",role:"status","aria-live":"polite","aria-label":"Loading map",children:e.jsxs("div",{className:"text-fg-muted flex items-center gap-3",children:[e.jsx("div",{className:"w-5 h-5 border-2 border-sys-blue border-t-transparent rounded-full animate-spin","aria-hidden":"true"}),e.jsx("span",{children:"Loading map..."})]})});function ut({neighbors:o,localNode:i,localHash:f,onRemoveNode:x,selectedNodeHash:g,onNodeSelected:v,highlightedEdgeKey:p,highlightedGhost:d}){return ss()===!1?e.jsx($e,{}):e.jsx(mt,{children:e.jsx(a.Suspense,{fallback:e.jsx($e,{}),children:e.jsx(xt,{neighbors:o,localNode:i,localHash:f,onRemoveNode:x,selectedNodeHash:g,onNodeSelected:v,highlightedEdgeKey:p,highlightedGhost:d})})})}function pt({hash:o,className:i="",size:f="sm",collisionInfo:x,isViterbiResolved:g}){const v=Ee(),p=Oe(),[d,T]=a.useState(!1),S=a.useMemo(()=>oe(o),[o]),L=a.useMemo(()=>x!==void 0?x:S?v.find(j=>j.prefix===S)??null:null,[S,v,x]),$=g??(p.totalPaths>0&&p.avgPathConfidence>=.7),F=a.useCallback(j=>{j.preventDefault(),j.stopPropagation(),T(!0)},[]),B=a.useCallback(()=>{T(!1)},[]);if(!L)return null;const w=f==="sm"?"w-3.5 h-3.5":"w-4 h-4",D=$?"text-sys-cyan hover:text-sys-cyan hover:bg-sys-cyan/10 focus:ring-sys-cyan/50":"text-signal-fair hover:text-sys-indigo hover:bg-signal-fair/10 focus:ring-signal-fair/50",_=$?`Prefix conflict resolved by Viterbi HMM (${(p.avgPathConfidence*100).toFixed(0)}% confidence)`:`Prefix conflict: ${L.candidateCount} nodes share prefix "${S}"`;return e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:F,className:`inline-flex items-center justify-center p-0.5 rounded focus:outline-none focus:ring-2 transition-colors cursor-pointer touch-manipulation ${D} ${i}`,title:_,"aria-label":`View prefix conflict for ${S}${$?" (Viterbi resolved)":""}`,children:$?e.jsxs("span",{className:"relative",children:[e.jsx(Hs,{className:w}),e.jsx(ke,{className:"absolute -bottom-0.5 -right-0.5 w-2 h-2 text-sys-green"})]}):e.jsx(Js,{className:w})}),e.jsx(Fs,{isOpen:d,prefix:L.prefix,candidateHashes:L.candidateHashes,onClose:B})]})}const ht=a.memo(pt),Ae=[{target:"Contacts",fn:"name",minStage:1,when:Ss},{target:"Contacts",fn:"traceLinks.directed",minStage:2,when:_s}];Rs(Ae);function ft(o){return o<1e3?`${Math.round(o)}m`:`${(o/1e3).toFixed(1)}km`}function gt({hash:o,contact:i,isHub:f,isNeighbor:x,distance:g,centrality:v,sparklineData:p,neighborSignal:d,collisionInfo:T,isViterbiResolved:S,isPinging:L,isPingingThis:$,pingResult:F,pingError:B,gatewayInfo:w,lastForwarderPrefix:D,isMobile:_,pathStability:j,onRowClick:E,onPing:fe,onRemove:V}){Ms(Ae);const Z=i.latitude&&i.longitude&&i.latitude!==0&&i.longitude!==0,h=i.node_name||i.name||"Unknown",U=x&&d,z=Ce(i),{isRepeater:q,isCompanion:y,isRoomServer:W,isClient:J,label:ee}=z,ge=x?`${ee} — Direct RF contact (zero-hop neighbor)`:`${ee} — Flood routing (multi-hop via mesh)`,G=i.first_seen?Pe(i.first_seen).replace(/ ago$/i," old"):null;return e.jsxs("div",{className:`contacts-grid-row ${f?"bg-sys-amber/5 border-l-2 border-l-sys-amber":""} ${Z?"cursor-pointer hover:bg-subtle-fill":""}`,onClick:()=>E(o),children:[e.jsxs("div",{className:"contacts-col-node flex items-center gap-2 min-w-0",children:[U&&(d==null?void 0:d.avgSnr)!==null?e.jsx("div",{className:`w-2 h-2 rounded-full flex-shrink-0 self-center ${ns(d.avgSnr)}`}):e.jsx("div",{className:"w-2 flex-shrink-0"}),e.jsx("div",{className:"w-6 h-6 flex items-center justify-center flex-shrink-0",title:ge,children:(()=>{if(W&&q)return e.jsxs("div",{className:"relative w-5 h-5",children:[e.jsx(he,{className:"w-5 h-5 absolute inset-0 text-sys-pink"}),e.jsx(zs,{className:"w-2.5 h-2.5 absolute -bottom-0.5 -right-0.5 text-sys-teal"})]});if(W)return e.jsx(he,{className:"w-5 h-5 text-sys-pink"});if(q)return e.jsx("div",{className:"w-5 h-5 rounded-full flex items-center justify-center ring-[1.5px] ring-sys-blue",children:e.jsx(pe,{className:"w-3.5 h-3.5 text-sys-blue"})});if((y||J)&&h!=="Unknown"){const{emoji:b,cleanName:H}=Ps(h);return e.jsx("div",{className:"w-6 h-6 rounded-full flex items-center justify-center",style:{backgroundColor:Ts(H)},children:b?e.jsx("span",{className:"text-sm leading-none",children:b}):e.jsx("span",{className:"text-white text-[9px] font-bold tracking-tighter",children:Ls(h)})})}return e.jsx("div",{className:"w-6 h-6 rounded-full flex items-center justify-center bg-zinc-500/20",children:e.jsx(ze,{className:"w-3.5 h-3.5 text-sys-amber"})})})()}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-1.5 overflow-hidden",children:[e.jsx("span",{className:"roster-title truncate",title:h,children:h}),x&&e.jsx(k,{color:X.neighbor,compact:!0,className:"flex-shrink-0",children:"NBR"}),f&&e.jsxs(k,{color:X.hub,compact:!0,className:"flex items-center gap-1 flex-shrink-0",children:[e.jsx(Is,{className:"w-3 h-3"}),"HUB"]}),q&&e.jsx(k,{color:X.repeater,compact:!0,className:"flex-shrink-0",children:"RPT"}),W&&e.jsx(k,{color:X.room,compact:!0,className:"flex-shrink-0",children:"ROOM"}),y&&e.jsx(k,{color:X.companion,compact:!0,className:"flex-shrink-0",children:"COMP"}),J&&e.jsx(k,{color:X.client,compact:!0,className:"flex-shrink-0",children:"CLIENT"}),_&&e.jsxs(k,{color:"cyan",compact:!0,className:"flex items-center gap-0.5 flex-shrink-0",children:[e.jsx(rt,{className:"w-2.5 h-2.5"}),"MOBILE"]}),!Z&&e.jsx("span",{className:"flex items-center gap-0.5 flex-shrink-0 text-fg-muted/50",title:"No GPS location provided",children:e.jsx(nt,{className:"w-3 h-3"})})]}),e.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5",children:[e.jsx(As,{copy:!0,size:"compact",truncate:[8,6],children:o}),e.jsx(ht,{hash:o,collisionInfo:T,isViterbiResolved:S}),!x&&w&&e.jsxs(k,{color:"zinc",compact:!0,className:"flex items-center gap-0.5 flex-shrink-0",title:`Via ${w.name||w.prefix} (${w.hopCount} hop${w.hopCount!==1?"s":""})`,children:[e.jsx($s,{className:"w-2.5 h-2.5"}),e.jsx("span",{className:"font-mono",children:w.prefix}),w.hopCount>1&&e.jsxs("span",{className:"opacity-60",children:["+",w.hopCount-1]})]}),D&&!x&&e.jsxs(k,{color:"zinc",compact:!0,className:"flex items-center gap-0.5 flex-shrink-0",title:`Last forwarded by ${D}`,children:[e.jsx(Gs,{className:"w-2.5 h-2.5"}),e.jsx("span",{className:"font-mono",children:D})]}),j!=null&&j!==0&&e.jsx(k,{color:j>0?"green":"amber",compact:!0,className:"flex items-center gap-0.5 flex-shrink-0",title:j>0?"Path stability improving":"Path stability declining",children:j>0?e.jsx(as,{className:"w-2.5 h-2.5"}):e.jsx(dt,{className:"w-2.5 h-2.5"})}),p.length>0&&(()=>{const b=p.reduce((je,se)=>je+se.count,0);if(b===0)return null;const H=b/24;return e.jsxs(k,{color:"zinc",compact:!0,className:"flex items-center gap-0.5 flex-shrink-0",title:`${b} packets in last 24h (~${H.toFixed(1)}/hr)`,children:[e.jsx(it,{className:"w-2.5 h-2.5"}),e.jsxs("span",{children:[H<1?"<1":H.toFixed(0),"/hr"]})]})})(),G&&e.jsxs(k,{color:"zinc",compact:!0,className:"flex items-center gap-0.5 flex-shrink-0 opacity-70",title:`First discovered ${G}`,children:[e.jsx(Xs,{className:"w-2.5 h-2.5"}),e.jsx("span",{children:G})]})]})]})]}),e.jsxs("div",{className:"contacts-col-signal flex items-center justify-end gap-2",children:[U&&(d==null?void 0:d.avgRssi)!==null&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Es,{rssi:d.avgRssi,className:"w-3.5 h-3.5"}),e.jsx("span",{className:"type-data-xs text-fg-muted",children:Math.round(d.avgRssi)})]}),U&&(d==null?void 0:d.avgSnr)!==null&&e.jsxs("span",{className:"type-data-xs text-fg-muted",children:[d.avgSnr.toFixed(1)," dB"]})]}),e.jsx("div",{className:"contacts-col-distance flex items-center justify-end gap-1 text-fg-muted",children:g!=null&&e.jsxs(e.Fragment,{children:[e.jsx(De,{className:"w-3 h-3"}),e.jsx("span",{className:"type-data-xs",children:ft(g)})]})}),e.jsx("div",{className:"contacts-col-centrality flex items-center justify-end gap-1",children:v>0&&e.jsxs(e.Fragment,{children:[e.jsx(He,{className:"w-3 h-3 text-sys-indigo"}),e.jsxs("span",{className:"type-data-xs text-fg-muted",children:[(v*100).toFixed(0),"%"]})]})}),e.jsx("div",{className:"contacts-col-seen flex items-center justify-end",children:e.jsx("span",{className:"type-data-xs text-fg-primary whitespace-nowrap",children:i.last_seen?Pe(i.last_seen):"—"})}),e.jsxs("div",{className:"contacts-col-actions flex items-center justify-end gap-1",children:[x&&e.jsx(e.Fragment,{children:F?e.jsxs("div",{className:"flex items-center gap-1 text-sys-green",title:`RTT: ${F.rtt_ms.toFixed(0)}ms`,children:[e.jsx(ke,{className:"w-3.5 h-3.5"}),e.jsxs("span",{className:"type-data-xs hidden sm:inline",children:[F.snr_db.toFixed(1),"dB"]})]}):B?e.jsx("span",{className:"text-sys-red text-xs",title:B,children:"✗"}):e.jsx("button",{onClick:b=>fe(o,b),disabled:L,className:"p-1 sm:p-1.5 radius-inner text-fg-muted/50 hover:text-sys-blue hover:bg-sys-blue/10 transition-base disabled:opacity-50 disabled:cursor-not-allowed",title:"Ping neighbor for updated signal info",children:$?e.jsx(Fe,{className:"w-3.5 h-3.5 sm:w-4 sm:h-4 animate-spin"}):e.jsx(Ds,{className:"w-3.5 h-3.5 sm:w-4 sm:h-4"})})}),e.jsx("button",{onClick:b=>{b.stopPropagation(),V(o,h)},className:"p-1 sm:p-1.5 radius-inner text-fg-muted/50 hover:text-sys-red hover:bg-sys-red/10 transition-base",title:"Remove contact",children:e.jsx(Bs,{className:"w-3.5 h-3.5 sm:w-4 sm:h-4"})})]})]})}const jt=a.memo(gt),bt=6371e3,yt=[],Nt=[{field:"lastHeard",icon:Os,label:"Recent"},{field:"distance",icon:De,label:"Distance"},{field:"centrality",icon:He,label:"Centrality"}];function vt(o){switch(o){case"room_server":return"room";case"repeater":return"repeater";case"companion":return"companion";case"unknown":return"companion"}}function wt(o){const i=Ce(o);return vt(i.type)}function ve(o,i){const{color:f="primary",border:x=!1}=i??{};return we("flex items-center gap-1.5 px-2 py-1.5 text-sm radius-inner transition-base",o?f==="success"?"bg-sys-green/20 text-sys-green":"bg-sys-blue/20 text-sys-blue":"text-fg-muted hover:text-fg-secondary hover-bg",x&&(o?f==="success"?"border border-sys-green/30":"border border-sys-blue/30":"border border-transparent"))}function kt(o,i,f,x){const g=(f-o)*Math.PI/180,v=(x-i)*Math.PI/180,p=Math.sin(g/2)*Math.sin(g/2)+Math.cos(o*Math.PI/180)*Math.cos(f*Math.PI/180)*Math.sin(v/2)*Math.sin(v/2),d=2*Math.atan2(Math.sqrt(p),Math.sqrt(1-p));return bt*d}function Ct(){const{stats:o}=rs(),i=os(),f=is(),x=cs(),g=ls(),v=ds(),p=ms(),d=xs(),T=us(),S=ps(),L=Ne[T],$=Ee(),F=Oe(),B=hs(),w=F.totalPaths>0&&F.avgPathConfidence>=.7,D=a.useMemo(()=>{const s=new Map;for(const t of $)s.set(t.prefix,t);return s},[$]),[_,j]=a.useState(null),[E,fe]=a.useState("lastHeard"),[V,Z]=a.useState("desc"),[h,U]=a.useState(""),[z,q]=a.useState(!1),[y,W]=a.useState(new Set),[J,ee]=a.useState(!1),[ge,G]=a.useState(null),[b,H]=a.useState(null),[je,se]=a.useState(new Map),[Ie,te]=a.useState(new Map),[C,Be]=a.useState(25),[Q,ie]=a.useState(25),be=a.useRef(null),ne=a.useMemo(()=>(o==null?void 0:o.neighbors)??{},[o==null?void 0:o.neighbors]),ye=ys(),ce=a.useMemo(()=>{if(ye.size===0)return ne;const s=new Set;for(const n of Object.keys(ne))s.add((n.startsWith("0x")?n.slice(2):n).toLowerCase());let t=null;for(const[n,r]of ye){const c=(n.startsWith("0x")?n.slice(2):n).toLowerCase();s.has(c)||(t||(t={...ne}),t[n]={last_seen:r.lastSeen,name:r.name??void 0,node_name:r.name??void 0,latitude:r.latitude,longitude:r.longitude,is_repeater:r.nodeType==="repeater",contact_type:r.nodeType==="repeater"?"Repeater":r.nodeType==="companion"?"Companion":r.nodeType==="room_server"?"Room Server":void 0})}return t??ne},[ne,ye]),A=a.useMemo(()=>{const t=Date.now()/1e3-L.minutes*60;return Object.fromEntries(Object.entries(ce).filter(([n,r])=>i.has(n)?!1:(r.last_seen??0)>=t))},[ce,i,L.minutes]),R=fs(),K=o==null?void 0:o.local_hash,Ve=a.useMemo(()=>{const s=new Map;if(!K||p.size===0)return s;for(const[t,n]of p)if(t.endsWith(`→${K}`)&&n.hops.length>1){const r=t.split("→")[0],c=n.hops[n.hops.length-1];s.set(r,c)}return s},[p,K]),le=a.useMemo(()=>{const s=new Map;if(!(R!=null&&R.latitude)||!(R!=null&&R.longitude))return s;for(const[t,n]of Object.entries(A))n.latitude&&n.longitude&&n.latitude!==0&&n.longitude!==0?s.set(t,kt(R.latitude,R.longitude,n.latitude,n.longitude)):s.set(t,null);return s},[A,R]),{neighborHashSet:de,neighborSignalMap:Ue}=a.useMemo(()=>{const s=new Set,t=new Map;for(const n of v)s.add(n.hash),t.set(n.hash,{avgRssi:n.avgRssi,avgSnr:n.avgSnr});return{neighborHashSet:s,neighborSignalMap:t}},[v]),Me=a.useMemo(()=>{const s=h.toLowerCase().trim(),t=s==="neighbor"||s==="neighbors",n=z||t,r=y.size>0;return Object.fromEntries(Object.entries(A).filter(([c,l])=>{if(r){const M=wt(l);if(!y.has(M))return!1}if(n&&!de.has(c))return!1;if(t||!s)return!0;const I=(l.node_name||l.name||"").toLowerCase(),N=oe(c).toLowerCase();return I.includes(s)||N.includes(s)||c.toLowerCase().includes(s)}))},[A,h,z,de,y]),u=a.useMemo(()=>{const s=Object.entries(Me),t=h.toLowerCase().trim(),n=t.length===2&&/^[0-9a-f]{2}$/i.test(t);return s.sort(([r,c],[l,I])=>{if(n){const M=oe(r).toLowerCase(),O=oe(l).toLowerCase(),ae=M===t,me=O===t;if(ae&&!me)return-1;if(me&&!ae)return 1}let N=0;switch(E){case"lastHeard":N=(c.last_seen||0)-(I.last_seen||0);break;case"distance":{const M=le.get(r)??null,O=le.get(l)??null;M===null&&O===null?N=0:M===null?N=1:O===null?N=-1:N=M-O;break}case"centrality":{const M=g.get(r)||0,O=g.get(l)||0;N=M-O;break}}return V==="desc"?-N:N})},[Me,E,V,le,g,h]),m=a.useMemo(()=>{let s=0,t=0,n=0,r=0,c=0;for(const[,l]of u){const I=Ce(l),N=l.latitude&&l.longitude&&l.latitude!==0&&l.longitude!==0;switch(I.type){case"room_server":n++;break;case"repeater":t++;break;case"companion":s++;break;case"unknown":c++;break}N&&r++}return{companions:s,repeaters:t,roomServers:n,total:u.length,withLocation:r,unknown:c}},[u]),qe=a.useMemo(()=>new Set(x),[x]),Se=a.useMemo(()=>C===0?u:u.slice(0,Q),[u,Q,C]);a.useEffect(()=>{ie(C||u.length)},[E,V,h,z,y,C,u.length]),a.useEffect(()=>{const s=t=>{t.target.closest("[data-dropdown]")||ee(!1)};return document.addEventListener("click",s),()=>document.removeEventListener("click",s)},[]),a.useEffect(()=>{if(C===0)return;const s=new IntersectionObserver(t=>{t[0].isIntersecting&&QMath.min(n+C,u.length))},{threshold:.1,rootMargin:"100px"});return be.current&&s.observe(be.current),()=>s.disconnect()},[C,Q,u.length]);const We=a.useCallback(s=>{Be(s),ie(s||u.length)},[u.length]),Ge=a.useCallback(s=>{E===s?Z(t=>t==="desc"?"asc":"desc"):(fe(s),Z("desc"))},[E]),Qe=a.useCallback(s=>{const t=A[s];t!=null&&t.latitude&&(t!=null&&t.longitude)&&t.latitude!==0&&t.longitude!==0&&G(s)},[A]),Ke=a.useCallback(()=>{G(null)},[]),Ye=a.useCallback((s,t)=>{j({hash:s,name:t})},[]),Xe=a.useCallback(async(s,t)=>{if(t.stopPropagation(),!b){H(s),se(n=>{const r=new Map(n);return r.delete(s),r}),te(n=>{const r=new Map(n);return r.delete(s),r});try{const n=s.startsWith("0x")?s.slice(0,4):`0x${s.slice(0,2)}`,r=await Ns(n,30);r.success&&r.data?(se(c=>new Map(c).set(s,r.data)),setTimeout(()=>{se(c=>{const l=new Map(c);return l.delete(s),l})},1e4)):(te(c=>new Map(c).set(s,r.error||"Ping failed")),setTimeout(()=>{te(c=>{const l=new Map(c);return l.delete(s),l})},5e3))}catch(n){const r=n instanceof Error?n.message:"Ping failed";te(c=>new Map(c).set(s,r)),setTimeout(()=>{te(c=>{const l=new Map(c);return l.delete(s),l})},5e3)}finally{H(null)}}},[b]);return e.jsxs(vs,{children:[e.jsx(ws,{title:"Contacts",icon:e.jsx(re,{}),controls:e.jsxs("div",{className:"flex items-center gap-3 sm:gap-5",children:[e.jsxs("div",{className:"hidden sm:flex items-center gap-4",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-xs text-fg-muted",children:"Total:"}),e.jsxs("span",{className:"data-box flex items-center gap-1.5 cursor-default",title:`${m.total} discovered node${m.total!==1?"s":""} on the mesh network`,children:[e.jsx(re,{className:"w-3.5 h-3.5 text-fg-secondary"}),e.jsx("span",{children:m.total})]})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-xs text-fg-muted",children:"Types:"}),m.repeaters>0&&e.jsxs("span",{className:"data-box flex items-center gap-1.5 cursor-default",title:"Repeaters",children:[e.jsx(pe,{className:"w-3.5 h-3.5 text-sys-blue"}),e.jsx("span",{children:m.repeaters})]}),m.companions>0&&e.jsxs("span",{className:"data-box flex items-center gap-1.5 cursor-default",title:"Companions",children:[e.jsx(Le,{className:"w-3.5 h-3.5 text-fg-muted"}),e.jsx("span",{children:m.companions})]}),m.roomServers>0&&e.jsxs("span",{className:"data-box flex items-center gap-1.5 cursor-default",title:"Room Servers",children:[e.jsx(he,{className:"w-3.5 h-3.5 text-sys-pink"}),e.jsx("span",{children:m.roomServers})]}),m.withLocation>0&&e.jsxs("span",{className:"data-box flex items-center gap-1.5 cursor-default",title:"With GPS location",children:[e.jsx(Us,{className:"w-3.5 h-3.5 text-sys-green"}),e.jsx("span",{children:m.withLocation})]}),m.unknown>0&&e.jsxs("span",{className:"data-box flex items-center gap-1.5 cursor-default",title:"Unknown type",children:[e.jsx(ze,{className:"w-3.5 h-3.5 text-sys-amber"}),e.jsx("span",{children:m.unknown})]})]})]}),e.jsxs("div",{className:"flex sm:hidden items-center gap-1.5",children:[e.jsxs("span",{className:"data-box !px-1.5 !py-0.5 !text-[10px] flex items-center gap-1",children:[e.jsx(re,{className:"w-3 h-3 text-fg-secondary"}),e.jsx("span",{children:m.total})]}),m.repeaters>0&&e.jsxs("span",{className:"data-box !px-1.5 !py-0.5 !text-[10px] flex items-center gap-1",children:[e.jsx(pe,{className:"w-3 h-3 text-sys-blue"}),e.jsx("span",{children:m.repeaters})]}),m.companions>0&&e.jsxs("span",{className:"data-box !px-1.5 !py-0.5 !text-[10px] flex items-center gap-1",children:[e.jsx(Le,{className:"w-3 h-3 text-fg-muted"}),e.jsx("span",{children:m.companions})]}),m.roomServers>0&&e.jsxs("span",{className:"data-box !px-1.5 !py-0.5 !text-[10px] flex items-center gap-1",children:[e.jsx(he,{className:"w-3 h-3 text-sys-pink"}),e.jsx("span",{children:m.roomServers})]}),e.jsx(Te,{ranges:Ne,selectedIndex:T,onSelect:S,size:"sm"})]}),e.jsx("div",{className:"hidden sm:block",children:e.jsx(Te,{ranges:Ne,selectedIndex:T,onSelect:S})})]})}),e.jsxs(ks,{children:[e.jsx(ut,{neighbors:A,localNode:R??void 0,localHash:K,onRemoveNode:f,selectedNodeHash:ge,onNodeSelected:Ke}),e.jsxs(gs,{noPadding:!0,children:[e.jsxs("div",{className:"flex items-center gap-1.5 sm:gap-2 px-3 sm:px-4 py-2.5 border-b border-edge-subtle",children:[e.jsx("span",{className:"icon-md flex items-center justify-center text-icon-card-title flex-shrink-0",children:e.jsx(re,{})}),e.jsx("span",{className:"type-micro flex-shrink-0 mr-auto hidden sm:block",children:"Discovered Contacts"}),e.jsx(js,{type:"search",size:"sm",value:h,onChange:s=>U(s.target.value),placeholder:"Search...",leadingIcon:e.jsx(qs,{className:"w-3.5 h-3.5"}),trailingIcon:h?e.jsx("button",{onClick:()=>{U(""),(h.toLowerCase().trim()==="neighbor"||h.toLowerCase().trim()==="neighbors")&&q(!1)},className:"text-fg-muted hover:text-fg-secondary",children:e.jsx(bs,{className:"w-3 h-3"})}):void 0,className:"w-24 sm:w-32 xl:w-44","aria-label":"Search contacts"}),e.jsx("div",{className:"h-4 w-px bg-border-subtle flex-shrink-0"}),e.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[e.jsxs("div",{className:"relative","data-dropdown":!0,children:[e.jsxs("button",{onClick:()=>ee(!J),className:ve(y.size>0,{border:!0}),title:"Filter by contact type",children:[e.jsx(st,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"hidden xl:inline",children:"Filter"}),y.size>0&&e.jsx("span",{className:"tabular-nums text-xs bg-sys-blue/30 px-1 rounded",children:y.size})]}),J&&e.jsxs("div",{className:"absolute right-0 top-full mt-1 z-50 surface-elevated radius-inner py-1 min-w-[140px]",children:[[{key:"repeater",label:"Repeaters"},{key:"companion",label:"Companions"},{key:"room",label:"Rooms"}].map(({key:s,label:t})=>e.jsxs("button",{onClick:()=>{W(n=>{const r=new Set(n);return r.has(s)?r.delete(s):r.add(s),r})},className:"w-full px-3 py-1.5 text-sm text-left hover-bg transition-base flex items-center gap-2",children:[e.jsx("span",{className:we("w-4 h-4 flex items-center justify-center radius-badge border",y.has(s)?"bg-sys-blue border-sys-blue text-white":"border-edge-subtle"),children:y.has(s)&&e.jsx(ke,{className:"w-3 h-3"})}),e.jsx("span",{className:y.has(s)?"text-fg-primary":"text-fg-secondary",children:t})]},s)),y.size>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"border-t border-edge-subtle my-1"}),e.jsx("button",{onClick:()=>W(new Set),className:"w-full px-3 py-1.5 text-sm text-left text-fg-muted hover:text-fg-secondary hover-bg transition-base",children:"Clear filters"})]})]})]}),de.size>0&&e.jsxs("button",{onClick:()=>q(!z),className:ve(z,{color:"success",border:!0}),title:z?"Show all contacts":"Show only MeshCore neighbors (direct RF contact)",children:[e.jsx(pe,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"hidden xl:inline",children:"Neighbors"})]})]}),e.jsx("div",{className:"h-4 w-px bg-border-subtle flex-shrink-0"}),e.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[Nt.map(({field:s,icon:t,label:n})=>e.jsxs("button",{onClick:()=>Ge(s),className:ve(E===s),title:`Sort by ${n.toLowerCase()}`,children:[e.jsx(t,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"hidden xl:inline",children:n}),E===s&&e.jsx(Ks,{className:we("w-3 h-3",V==="asc"&&"rotate-180")})]},s)),e.jsx("div",{className:"h-4 w-px bg-border-subtle"}),e.jsxs(Cs,{value:C,onChange:We,className:"w-auto min-w-[50px] [&_button]:py-1 [&_button]:px-2 [&_button]:text-xs [&_button]:min-h-0","aria-label":"Items per page",children:[e.jsx(ue,{value:25,children:"25"}),e.jsx(ue,{value:50,children:"50"}),e.jsx(ue,{value:100,children:"100"}),e.jsx(ue,{value:0,children:"All"})]})]})]}),u.length>0?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"hidden sm:grid contacts-grid-header border-b border-edge-subtle/50 px-3 py-2 type-micro text-fg-muted",children:[e.jsx("div",{className:"contacts-col-node",children:"Node"}),e.jsx("div",{className:"contacts-col-signal text-right",children:"Signal"}),e.jsx("div",{className:"contacts-col-distance text-right",children:"Distance"}),e.jsx("div",{className:"contacts-col-centrality text-right",children:"Centrality"}),e.jsx("div",{className:"contacts-col-seen text-right",children:"Last Seen"}),e.jsx("div",{className:"contacts-col-actions"})]}),e.jsx("div",{className:"divide-y divide-edge-subtle/30",children:Se.map(([s,t])=>{const n=oe(s),r=qe.has(s),c=de.has(s),l=le.get(s)??null,I=g.get(s)||0,N=c?Ue.get(s):void 0,M=n?D.get(n)??null:null,O=B.get(s)??yt;let ae=null;if(!c&&K&&p.size>0){const Je=`${s}→${K}`,xe=p.get(Je);if(xe&&xe.hops.length>0){const _e=xe.hops[0],Re=Object.keys(ce).find(es=>es.toUpperCase().startsWith(_e.toUpperCase())),Y=Re?ce[Re]:null;ae={prefix:_e,name:(Y==null?void 0:Y.node_name)??(Y==null?void 0:Y.name)??null,hopCount:xe.hopCount}}}const me=d.has(s),Ze=Ve.get(s)??null;return e.jsx(jt,{hash:s,contact:t,isHub:r,isNeighbor:c,distance:l,centrality:I,sparklineData:O,neighborSignal:N,collisionInfo:M,isViterbiResolved:w,isPinging:b!==null,isPingingThis:b===s,pingResult:je.get(s),pingError:Ie.get(s),gatewayInfo:ae,lastForwarderPrefix:Ze,isMobile:me,onRowClick:Qe,onPing:Xe,onRemove:Ye},s)})}),C>0&&Q0&&Qie(s=>Math.min(s+C,u.length)),className:"text-sys-blue hover:text-sys-blue/80 transition-base",children:"Load more"})]})]}):e.jsxs("div",{className:"roster-empty",children:[e.jsx(re,{className:"roster-empty-icon"}),e.jsx("div",{className:"type-label text-fg-secondary",children:"No Contacts Discovered"}),e.jsx("div",{className:"type-data-xs text-fg-muted mt-1",children:"Contacts will appear here as they advertise on the mesh network."})]})]})]}),e.jsx(Vs,{isOpen:!!_,title:"Remove Contact",message:`Are you sure you would like to remove ${(_==null?void 0:_.name)||"this contact"}?`,confirmLabel:"Remove",cancelLabel:"Cancel",variant:"danger",onConfirm:()=>{_&&f(_.hash),j(null)},onCancel:()=>j(null)})]})}const Gt=Object.freeze(Object.defineProperty({__proto__:null,default:Ct},Symbol.toStringTag,{value:"Module"}));export{Gt as C,ht as P,De as R,dt as T}; diff --git a/frontend/dist/assets/ContactsMapMapLibre-BEMNDe-F.js b/frontend/dist/assets/ContactsMapMapLibre-Dy88OlAW.js similarity index 99% rename from frontend/dist/assets/ContactsMapMapLibre-BEMNDe-F.js rename to frontend/dist/assets/ContactsMapMapLibre-Dy88OlAW.js index abb3346c..f2f51e7d 100644 --- a/frontend/dist/assets/ContactsMapMapLibre-BEMNDe-F.js +++ b/frontend/dist/assets/ContactsMapMapLibre-Dy88OlAW.js @@ -1,4 +1,4 @@ -import{d as L0,_ as ta,r as R,fg as ra,cW as e0,Z as j0,fh as Fo,fi as gs,fj as na,bG as oa,bM as ia,j as p,bO as sa,c as I0,a0 as ps,m as u0,ae as ys,A as R0,b as Ur,B as Ot,cX as la,bI as so,M as Po,S as Qo,cN as xs,L as Oo,bh as ws,ac as aa,R as vs,bc as dn,ad as ua,w as zo,b8 as gi,fk as ks,y as ca,E as fa,cV as ha,fl as da,a9 as bs,bj as pi,bl as ma,x as Ho,bK as ga,aD as pa,ed as Cs,fm as ya,bP as xa,fn as wa,fo as Es,$ as hn,b_ as va,fp as Ss,fq as ka,fr as ba,ah as Ms,q as y0,fs as Bs,by as Ca,fe as Ea,bB as Sa,cL as Ds,cO as Ma,H as Ba,ft as Da,ep as _a,fu as lo}from"./index-C1ZF7cAz.js";import{u as _s,b as Ar,S as X0,L as t0,P as Ta,c as Ra,M as ja,d as Ia,B as La}from"./BasemapLayer-CfNM-FKA.js";import{u as Ts,r as Rs,e as yi,f as xi,g as Na}from"./consumer-registry-CFnLzQEu.js";import{L as On,c as Fa}from"./link-scoring-BoRGGDM6.js";import{T as Go,C as Pa}from"./ConfirmModal-Cf30hpC_.js";import{b as Qa,e as Oa,a as js,m as wi,f as za,d as Ha,M as Ga,g as Ua,E as Va,u as Wa,G as Ya,h as Ka,i as Za,j as $a,D as qa}from"./DeepAnalysisModal-X0cTTPp0.js";import{H as Ja,A as un,Z as Xa,D as vi,p as Au,c as eu,u as ur}from"./useMapViewStore-px_sYTaN.js";import{R as Is}from"./refresh-cw-BjBvU2VX.js";import{E as Ls}from"./target-D0wbrQMn.js";import{F as tu}from"./funnel-zG3cM6J7.js";import{P as ru}from"./plus-BvRrZnfw.js";import{C as nu,a as Ns,b as ko,c as ou}from"./easing-BGz60jqS.js";import{D as iu}from"./download-DbDw1ZiV.js";import{W as su}from"./wifi-BBDEuc94.js";import{C as Fs}from"./SignalIndicator-BDLlaquA.js";import{C as lu}from"./chevron-right-DzbDJf-i.js";import{T as au,P as uu,R as cu}from"./Contacts-BwzeErAl.js";import{c as fu}from"./node-types-BJeLdOcD.js";import{H as ki,C as Lr,N as hu,a as du}from"./badge-colors-BNUqIXCA.js";import{L as mu}from"./LightSparkline-7x8sYJi9.js";import{M as gu}from"./map-pin-DEktgLFN.js";import"./triangle-alert-B3ZB2VPZ.js";import"./database-CdKnhwkJ.js";import"./index-DCNWD5GU.js";import"./usePipelineStore-BEu0jDzA.js";import"./ping-C4M-6OVJ.js";import"./PageLayout-sd81yog0.js";import"./listbox-vfp6JG3P.js";import"./element-movement-CuySBNA6.js";import"./TimeRangeStepper-CxA2aT1o.js";import"./chat-utils-BzC-Ehs-.js";import"./CollisionExplorerModal-Bm7X5dgz.js";import"./monitor-smartphone-BQ_i3P0U.js";import"./DataBox-BADtaCfB.js";import"./circle-question-mark-CxqvWhsl.js";import"./network-4dDTHizq.js";import"./activity-Bmh45lNn.js";import"./search-CtlrlrHK.js";/** +import{d as L0,a1 as ta,r as R,ff as ra,cU as e0,Z as j0,fg as Fo,fh as gs,fi as na,bH as oa,bN as ia,j as p,bP as sa,c as I0,a3 as ps,m as u0,ai as ys,A as R0,b as Ur,B as Ot,cV as la,bJ as so,M as Po,S as Qo,cL as xs,L as Oo,e as ws,ag as aa,R as vs,bf as dn,ah as ua,y as zo,bb as gi,fj as ks,D as ca,G as fa,cT as ha,fk as da,ad as bs,bl as pi,bn as ma,z as Ho,bL as ga,aG as pa,eb as Cs,fl as ya,bQ as xa,fm as wa,fn as Es,a2 as hn,b_ as va,fo as Ss,fp as ka,fq as ba,al as Ms,v as y0,fr as Bs,bz as Ca,fd as Ea,bC as Sa,cJ as Ds,cM as Ma,K as Ba,fs as Da,en as _a,ft as lo}from"./index-DhkG1Nx9.js";import{u as _s,b as Ar,S as X0,L as t0,P as Ta,c as Ra,M as ja,d as Ia,B as La}from"./BasemapLayer-CfNeG6Jg.js";import{u as Ts,r as Rs,e as yi,f as xi,g as Na}from"./consumer-registry-CTQIn0m9.js";import{L as On,c as Fa}from"./link-scoring-Ctdu509L.js";import{T as Go,C as Pa}from"./ConfirmModal-BoB1If6b.js";import{b as Qa,e as Oa,a as js,m as wi,f as za,d as Ha,M as Ga,g as Ua,E as Va,u as Wa,G as Ya,h as Ka,i as Za,j as $a,D as qa}from"./DeepAnalysisModal-DuvRb3Nu.js";import{H as Ja,A as un,Z as Xa,D as vi,p as Au,c as eu,u as ur}from"./useMapViewStore-BMqcaUNl.js";import{R as Is}from"./refresh-cw-CA_1u8Jn.js";import{E as Ls}from"./target-BiAgFlf5.js";import{F as tu}from"./funnel-Dr2cCUci.js";import{P as ru}from"./plus-Pe5yI_FS.js";import{C as nu,a as Ns,b as ko,c as ou}from"./easing-Ch_Y3tms.js";import{D as iu}from"./download-d0PZoGJ2.js";import{W as su}from"./wifi-u03iIDZF.js";import{C as Fs}from"./SignalIndicator-DEXVYOhU.js";import{C as lu}from"./chevron-right-na13OQfy.js";import{T as au,P as uu,R as cu}from"./Contacts-DPHkM_MR.js";import{c as fu}from"./node-types-CgBRFpS8.js";import{H as ki,C as Lr,N as hu,a as du}from"./badge-colors-BNUqIXCA.js";import{L as mu}from"./LightSparkline-Bg_XrgTS.js";import{M as gu}from"./map-pin-BHGohRD7.js";import"./triangle-alert-D8NErBXC.js";import"./database-DE8k8U0g.js";import"./index-Bx_G2nLG.js";import"./usePipelineStore-B9ir1Xwp.js";import"./ping-CLlM2Uim.js";import"./PageLayout-BkUTZXJb.js";import"./listbox-CyP6uw8j.js";import"./element-movement-BPGrReFv.js";import"./TimeRangeStepper-RSPVaByt.js";import"./chat-utils-DA-kxQ-o.js";import"./CollisionExplorerModal-Cs8y9_83.js";import"./monitor-smartphone-jV9bAwUA.js";import"./DataBox-BMesbbaF.js";import"./circle-question-mark--xh93QHC.js";import"./network-DBF70fah.js";import"./activity-BG24yKp1.js";import"./search-BmkxxIVP.js";/** * @license lucide-react v0.559.0 - ISC * * This source code is licensed under the ISC license. diff --git a/frontend/dist/assets/Dashboard-C6Gfwl6I.js b/frontend/dist/assets/Dashboard-C6Gfwl6I.js deleted file mode 100644 index cc9d12e1..00000000 --- a/frontend/dist/assets/Dashboard-C6Gfwl6I.js +++ /dev/null @@ -1,54 +0,0 @@ -import{d as A,e as st,r as f,j as e,A as Re,m as Q,S as nt,M as at,U as ot,f as it,h as rt,k as lt,n as ct,o as H,p as ue,q as U,t as dt,v as mt,w as be,x as ut,L as ee,y as G,z as xt,D as ht,E as te,F as Be,T as ft,G as pt,B as je,R as Le,H as Fe,J as gt,K as X,N as P,O as yt,P as bt,Q as jt,V as Nt,W as vt,X as wt,Y as ne,u as xe,_ as kt,$ as Ne,a0 as ae,a1 as K,a2 as Mt,a3 as J,a4 as Ct,a5 as Tt,a6 as St,a7 as ve,a8 as _t,c as F,a9 as Dt,aa as Pe,ab as we,ac as Rt,ad as Bt,ae as Lt,af as Ft,ag as Pt,ah as At,ai as $t}from"./index-C1ZF7cAz.js";import{C as ke,P as Et,a as Ht,B as It}from"./PageLayout-sd81yog0.js";import{u as I,r as O,h as Ot,a as zt,b as Wt,i as qt}from"./consumer-registry-CFnLzQEu.js";import{A as V,E as Ut}from"./AnimatedNumber-DdMz2uoH.js";import{c as Vt}from"./node-types-BJeLdOcD.js";import{b as Ae,c as q,a as Gt,d as Xt,F as Z}from"./meshcore-tx-constants-DgpFTAmf.js";import{S as Yt,u as ce,P as Kt,T as Jt,C as $e,a as Zt}from"./PacketList-BiFMK9DR.js";import{useGetDecodedContent as Qt,useResolveSource as es}from"./usePipelineStore-BEu0jDzA.js";import{A as Me}from"./SignalIndicator-BDLlaquA.js";import{T as Ee}from"./TimeRangeStepper-CxA2aT1o.js";import{L as he}from"./LightSparkline-7x8sYJi9.js";import{c as ts}from"./link-scoring-BoRGGDM6.js";import{Z as ss,H as ns}from"./useMapViewStore-px_sYTaN.js";import{N as as}from"./NodeInformationCard-BUD0ZP9t.js";import{g as os,e as oe,a as is,f as rs}from"./chat-utils-BzC-Ehs-.js";import{M as He,C as ls}from"./ChatBubble-jJytaTX9.js";import{C as Ce}from"./chevron-right-DzbDJf-i.js";import{H as cs}from"./hash-2pKM_KWy.js";import{R as ie,C as re}from"./Grid-DrJ5vfLo.js";import"./index-DCNWD5GU.js";import"./primitives-DyUGjsV_.js";import"./payload-decoders-CmuRVuC0.js";import"./badge-colors-BNUqIXCA.js";import"./arrow-up-DhGrEgP7.js";import"./map-pin-DEktgLFN.js";import"./circle-question-mark-CxqvWhsl.js";import"./triangle-alert-B3ZB2VPZ.js";import"./DataBox-BADtaCfB.js";import"./layers-BNenbfjd.js";import"./activity-Bmh45lNn.js";import"./circle-check-DY6oislV.js";import"./database-CdKnhwkJ.js";import"./shield-BNyjVgrV.js";/** - * @license lucide-react v0.559.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const ds=[["path",{d:"M7 7h10v10",key:"1tivn9"}],["path",{d:"M7 17 17 7",key:"1vkiza"}]],ms=A("arrow-up-right",ds);/** - * @license lucide-react v0.559.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const us=[["path",{d:"M2 13a2 2 0 0 0 2-2V7a2 2 0 0 1 4 0v13a2 2 0 0 0 4 0V4a2 2 0 0 1 4 0v13a2 2 0 0 0 4 0v-4a2 2 0 0 1 2-2",key:"57tc96"}]],xs=A("audio-waveform",us);/** - * @license lucide-react v0.559.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const hs=[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M18 17V9",key:"2bz60n"}],["path",{d:"M13 17V5",key:"1frdt8"}],["path",{d:"M8 17v-3",key:"17ska0"}]],fs=A("chart-column",hs);/** - * @license lucide-react v0.559.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const ps=[["path",{d:"M6 8.5a6.5 6.5 0 1 1 13 0c0 6-6 6-6 10a3.5 3.5 0 1 1-7 0",key:"1dfaln"}],["path",{d:"M15 8.5a2.5 2.5 0 0 0-5 0v1a2 2 0 1 1 0 4",key:"1qnva7"}]],gs=A("ear",ps);/** - * @license lucide-react v0.559.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const ys=[["path",{d:"M11 6a13 13 0 0 0 8.4-2.8A1 1 0 0 1 21 4v12a1 1 0 0 1-1.6.8A13 13 0 0 0 11 14H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2z",key:"q8bfy3"}],["path",{d:"M6 14a12 12 0 0 0 2.4 7.2 2 2 0 0 0 3.2-2.4A8 8 0 0 1 10 14",key:"1853fq"}],["path",{d:"M8 6v8",key:"15ugcq"}]],bs=A("megaphone",ys);/** - * @license lucide-react v0.559.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const js=[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}]],Ns=A("message-square",js);/** - * @license lucide-react v0.559.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const vs=[["path",{d:"M18 11h-4a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1h4",key:"17ldeb"}],["path",{d:"M6 7v13a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V7",key:"nc37y6"}],["rect",{width:"16",height:"5",x:"4",y:"2",rx:"1",key:"3jeezo"}]],ws=A("pill-bottle",vs);/** - * @license lucide-react v0.559.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const ks=[["path",{d:"M4 10a7.31 7.31 0 0 0 10 10Z",key:"1fzpp3"}],["path",{d:"m9 15 3-3",key:"88sc13"}],["path",{d:"M17 13a6 6 0 0 0-6-6",key:"15cc6u"}],["path",{d:"M21 13A10 10 0 0 0 11 3",key:"11nf8s"}]],Ms=A("satellite-dish",ks);/** - * @license lucide-react v0.559.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const Cs=[["circle",{cx:"7",cy:"7",r:"5",key:"x29byf"}],["circle",{cx:"17",cy:"17",r:"5",key:"1op1d2"}],["path",{d:"M12 17h10",key:"ls21zv"}],["path",{d:"m3.46 10.54 7.08-7.08",key:"1rehiu"}]],Ts=A("tablets",Cs);/** - * @license lucide-react v0.559.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const Ss=[["line",{x1:"10",x2:"14",y1:"2",y2:"2",key:"14vaq8"}],["line",{x1:"12",x2:"15",y1:"14",y2:"11",key:"17fdiu"}],["circle",{cx:"12",cy:"14",r:"8",key:"1e1u0o"}]],_s=A("timer",Ss),Ie=[{target:"ReceivedChart",fn:"type",minStage:1},{target:"ReceivedChart",fn:"airtime",minStage:1,when:Ot}];O(Ie);function Ds(t,s,n){const a=Date.now()/1e3,o=s*60,i=a-o,l=o/n,m=[];for(let x=0;xa)continue;const g=Math.min(n-1,Math.floor((u-i)/l)),c=x.type??x.payload_type??0,h=x.length??x.payload_length??0,y=m[g];y.bytesByType[c]=(y.bytesByType[c]??0)+h,y.totalBytes+=h,d[c]=(d[c]??0)+h}const r=Object.keys(d).map(x=>parseInt(x,10)).filter(x=>d[x]>0).sort((x,u)=>d[u]-d[x]);return{buckets:m,activeTypes:r,totalByType:d}}function Rs(t){const n=new Date(t*1e3).getHours();return n>=6&&n<18}function Bs(t){return new Date(t*1e3).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!1})}function Ls({packets:t,rangeMinutes:s,bucketCount:n}){I(Ie);const a=st(),[o,i]=f.useState(null),[l,m]=f.useState(null),[d,r]=f.useState(null),{buckets:x,activeTypes:u,totalByType:g}=f.useMemo(()=>Ds(t,s,n),[t,s,n]),c=f.useCallback((j,N,w)=>{i(N),m(w)},[]),h=x.length>0&&u.length>0,y=o?Rs(o.start):null,v=o?Bs(o.start):"",k=d!==null&&y!==null&&d!==y;y!==d&&r(y);const M=48;return e.jsxs("div",{className:"flex flex-col h-full relative",children:[e.jsx("div",{className:"h-5 relative mb-1 shrink-0",children:o&&l!==null&&e.jsxs("div",{className:"absolute flex items-center gap-1.5 type-data-sm -translate-x-1/2",style:{left:`calc(${M}px + ${l*100}% * (1 - ${M}px / 100%))`},children:[e.jsx(Re,{mode:"wait",children:e.jsx(Q.span,{initial:k?{opacity:0,scale:.5,rotate:-90}:!1,animate:{opacity:1,scale:1,rotate:0},exit:{opacity:0,scale:.5,rotate:90},transition:{duration:.25,ease:"easeOut"},children:y?e.jsx(nt,{className:"w-4 h-4 text-sys-amber"}):e.jsx(at,{className:"w-4 h-4 text-sys-blue"})},y?"sun":"moon")}),e.jsx("span",{className:"text-fg-secondary",children:v})]})}),e.jsx("div",{className:"flex-1 min-h-0",children:h&&e.jsx(ot,{buckets:x,activeTypes:u,gridColor:a.grid,axisTickColor:a.axisTick,onHover:c})}),e.jsx("div",{className:"pt-2 px-1 pb-2 shrink-0",children:h&&e.jsx(it,{activeTypes:u,totalByType:g})})]})}function Fs(t,s,n){var i,l;if(t.length<=n)return t;const a=t.length/n,o=[];for(let m=0;m0&&(u.bytesByType[c]=(u.bytesByType[c]??0)+h)}}o.push(u)}return o}function Ps(t,s,n,a,o,i,l){if(s.length===0)return;const m=Fs(s,n,ct.statsCard),d=m.length,r=i/d,x=m.map(g=>g.totalBytes),u=Math.max(...x);if(u!==0){for(let g=0;g{const l=t.map(d=>d.start),m=t.map(()=>1);return[l,m]},[t]);return f.useEffect(()=>{if(!n.current||t.length===0)return;const l=n.current,m=l.getBoundingClientRect(),d=Math.floor(m.width)||200,r=Math.floor(m.height)||60,x={width:d,height:r,padding:[0,0,0,0],cursor:{show:!1},scales:{x:{time:!1},y:{range:[0,1]}},axes:[{show:!1},{show:!1}],series:[{},{show:!1}],legend:{show:!1},hooks:{draw:[c=>{const h=c.ctx,{left:y,top:v,width:k,height:M}=c.bbox;Ps(h,a.current,o.current,y,v,k,M)}]}},u=new rt(x,i,l),g=new ResizeObserver(()=>{const c=l.getBoundingClientRect();c.width>0&&c.height>0&&u.setSize({width:Math.floor(c.width),height:Math.floor(c.height)})});return g.observe(l),()=>{g.disconnect(),u.destroy()}},[i,t.length]),t.length===0?e.jsx("div",{className:"h-full flex items-center justify-center",children:e.jsx("div",{className:"w-full h-0.5 rounded-full bg-fg-muted/15"})}):e.jsx("div",{ref:n,className:"w-full h-full"})}const Oe=f.memo(As),ze=[{target:"ForwardedCard",fn:"type",minStage:1}];O(ze);function $s(t,s,n){const a=Date.now()/1e3,o=s*60,i=a-o,l=o/n,m=[];for(let c=0;ca)continue;const v=Math.min(n-1,Math.floor((y-i)/l)),k=c.type??c.payload_type??0,M=c.length??c.payload_length??0,j=m[v];j.bytesByType[k]=(j.bytesByType[k]??0)+M,j.totalBytes+=M,d[k]=(d[k]??0)+M,r++}const x=Object.keys(d).map(c=>parseInt(c,10)).filter(c=>d[c]>0).sort((c,h)=>d[h]-d[c]),u=s/60,g=u>0?Math.round(r/u):0;return{buckets:m,activeTypes:x,ratePerHour:g}}function Es({value:t,receivedCount:s,packets:n,rangeMinutes:a,bucketCount:o,timeRangeLabel:i,icon:l,isLoaded:m=!0}){I(ze);const{buckets:d,activeTypes:r,ratePerHour:x}=f.useMemo(()=>$s(n,a,o),[n,a,o]),u=s>0?(t/s*100).toFixed(1):null;return m?e.jsxs(H,{children:[e.jsxs("div",{className:"flex items-center gap-1.5 sm:gap-2 mb-2 sm:mb-3",children:[l&&e.jsx("span",{className:"icon-sm text-icon-card-title",children:l}),e.jsx("span",{className:"type-micro",children:"FORWARDED"}),i&&e.jsx(U,{color:"zinc",className:"hidden sm:inline-flex",children:i})]}),e.jsx("div",{className:"type-data-xl text-fg-primary",children:e.jsx(V,{value:t,className:"font-mono tabular-nums",priority:"high"})}),e.jsx("div",{className:"flex-1 mt-1 overflow-hidden min-h-[40px] sm:min-h-[60px]",children:r.length>0?e.jsx(Oe,{buckets:d,activeTypes:r}):e.jsx("div",{className:"w-full h-full flex items-center justify-center",children:e.jsx("div",{className:"w-full h-0.5 rounded-full bg-fg-muted/15"})})}),e.jsx("div",{className:"pt-1.5 sm:pt-2 mt-1",children:e.jsxs("div",{className:"flex gap-2 sm:gap-3",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"data-box-label",children:"Rate"}),e.jsxs("div",{className:"data-box data-box-fill data-box-left",children:[x,"/hr"]})]}),u!==null&&e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"data-box-label",children:"Ratio"}),e.jsxs("div",{className:"data-box data-box-fill data-box-left",children:[u,"%"]})]})]})})]}):e.jsx(H,{children:e.jsx(ue,{})})}const We=[{target:"DroppedCard",fn:"type",minStage:1}];O(We);function Hs(t,s,n){const a=Date.now()/1e3,o=s*60,i=a-o,l=o/n,m=[];for(let c=0;ca)continue;const y=Math.min(n-1,Math.floor((h-i)/l)),v=c.type??c.payload_type??0,k=c.length??c.payload_length??0,M=m[y];M.bytesByType[v]=(M.bytesByType[v]??0)+k,M.totalBytes+=k,d[v]=(d[v]??0)+k,r++}const x=Object.keys(d).map(c=>parseInt(c,10)).filter(c=>d[c]>0).sort((c,h)=>d[h]-d[c]),u=s/60,g=u>0?Math.round(r/u):0;return{buckets:m,activeTypes:x,ratePerHour:g}}function Is({value:t,receivedCount:s,packets:n,rangeMinutes:a,bucketCount:o,timeRangeLabel:i,icon:l,isLoaded:m=!0}){I(We);const{buckets:d,activeTypes:r,ratePerHour:x}=f.useMemo(()=>Hs(n,a,o),[n,a,o]),u=s>0?(t/s*100).toFixed(1):null;return m?e.jsxs(H,{children:[e.jsxs("div",{className:"flex items-center gap-1.5 sm:gap-2 mb-2 sm:mb-3",children:[l&&e.jsx("span",{className:"icon-sm text-icon-card-title",children:l}),e.jsx("span",{className:"type-micro",children:"DROPPED"}),i&&e.jsx(U,{color:"zinc",className:"hidden sm:inline-flex",children:i})]}),e.jsx("div",{className:"type-data-xl text-fg-primary",children:e.jsx(V,{value:t,className:"font-mono tabular-nums",priority:"high"})}),e.jsx("div",{className:"flex-1 mt-1 overflow-hidden min-h-[40px] sm:min-h-[60px]",children:r.length>0?e.jsx(Oe,{buckets:d,activeTypes:r}):e.jsx("div",{className:"w-full h-full flex items-center justify-center",children:e.jsx("div",{className:"w-full h-0.5 rounded-full bg-fg-muted/15"})})}),e.jsx("div",{className:"pt-1.5 sm:pt-2 mt-1",children:e.jsxs("div",{className:"flex gap-2 sm:gap-3",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"data-box-label",children:"Rate"}),e.jsxs("div",{className:"data-box data-box-fill data-box-left",children:[x,"/hr"]})]}),u!==null&&e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"data-box-label",children:"Drop %"}),e.jsxs("div",{className:"data-box data-box-fill data-box-left",children:[u,"%"]})]})]})})]}):e.jsx(H,{children:e.jsx(ue,{})})}const Os={",":"punc",".":"punc-period",":":"punc-colon","/":"punc-slash"},de=/([,\.:\/])/g;function zs(t){return t.split(de).map((n,a)=>{const o=Os[n];return o?e.jsx("span",{className:o,children:n},a):n})}const $=f.memo(function({children:s,className:n="",as:a="span"}){const o=f.useMemo(()=>{let i;return typeof s=="number"?i=s.toLocaleString():Array.isArray(s)?i=s.join(""):i=String(s??""),de.test(i)?(de.lastIndex=0,zs(i)):i},[s]);return e.jsx(a,{className:`data-tight ${n}`.trim(),children:o})}),Ws=2,qs=1;function Us(t,s,n){const a=d=>(d==null?void 0:d.reduce((r,x)=>r+x.count,0))??0,o=a(s),i=a(n),l=o||(t==null?void 0:t.rx_count)||1,m=i||(t==null?void 0:t.dropped_count)||0;return l>0?m/(l+m)*100:0}function Vs(t,s,n){const a=o=>(o==null?void 0:o.reduce((i,l)=>i+l.count,0))??0;if(s!=null&&s.length&&n){const i=a(s)*100,l=s.length*n*1e3;return i/l*100}if(t){const o=(t.uptime_seconds||1)*1e3;return(t.total_airtime_ms||t.airtime_used_ms||0)/o*100}return 0}function Te(t,s,n){return Gt(Math.max(s,Math.min(n,t)))}function Gs(t,s,n,a,o){let i=Ae(t);s>20?i+=Z*2:s>12&&(i+=Z),n>8&&(i+=Z);const l=Te(i,0,Ws);let m=Xt(t);n>8&&(m+=Z);const d=Te(m,0,qs),r=q(l),x=q(d),u=a!==null?q(a):null;let g="stable";return u!==null&&(r>u?g="increase":r{if(r!=="applying"){x("applying");try{const se=await mt({tx_delay_factor:L,direct_tx_delay_factor:E});se!=null&&se.success?(x("success"),setTimeout(()=>x("idle"),2e3)):(x("error"),setTimeout(()=>x("idle"),2500))}catch{x("error"),setTimeout(()=>x("idle"),2500)}}},[r]);if(!l)return e.jsx(H,{children:e.jsx(ue,{})});const c=10080*60,y=Math.floor(Date.now()/1e3)-c,v=Object.values((t==null?void 0:t.neighbors)??{}).filter(L=>L.zero_hop&&L.last_seen>=y&&Vt(L).isRepeater).length,k=u.filter(L=>L.status==="active"||L.lastSeen>=y).length,M=Math.max(v,k),j=Us(t,s,n),N=Vs(t,a,o),w=((pe=(fe=t==null?void 0:t.config)==null?void 0:fe.delays)==null?void 0:pe.tx_delay_factor)??null,C=((ye=(ge=t==null?void 0:t.config)==null?void 0:ge.delays)==null?void 0:ye.direct_tx_delay_factor)??null,p=Gs(M,j,N,w),D=M!==1,T=Ae(M),_=[`${M} repeater${D?"s":""} heard in the last 7 days (base ×${T.toFixed(1)}).`];p.floodFactor===T&&j<=12&&N<=8?_.push("No modifiers applied — network looks healthy."):(j>20?_.push(`High duplicate rate (${j.toFixed(1)}%) suggests frequent collisions — window widened.`):j>12&&_.push(`Elevated duplicate rate (${j.toFixed(1)}%) — window widened one step.`),N>8&&_.push(`Channel is busy (${N.toFixed(1)}% TX util) — extra spacing added.`));const b=[`Direct uses one forwarder — ×${p.directFactor.toFixed(1)} backoff for channel contention.`];N>8&&b.push("Busy channel — small extra backoff.");const S=[`Flood ×${p.floodFactor.toFixed(1)} (${p.floodSlots} slot${p.floodSlots!==1?"s":""})`,..._,"",`Direct ×${p.directFactor.toFixed(1)}`,...b,"","Click to copy CLI commands"].join(` -`),R=w!==null?q(w):null,B=C!==null?q(C):null,W=R!==null&&p.floodSlots!==R,Ze=B!==null&&p.directSlots!==B,Qe=W||Ze,et=async()=>{const L=`set txdelay ${p.floodFactor.toFixed(1)} -set direct.txdelay ${p.directFactor.toFixed(1)}`;try{await navigator.clipboard.writeText(L),d(!0),setTimeout(()=>d(!1),1500)}catch{const E=document.createElement("textarea");E.value=L,E.style.position="fixed",E.style.opacity="0",document.body.appendChild(E),E.select();try{document.execCommand("copy"),d(!0),setTimeout(()=>d(!1),1500)}catch{console.error("Failed to copy commands")}document.body.removeChild(E)}},tt=()=>g(p.floodFactor,p.directFactor);return e.jsxs(H,{children:[e.jsxs("div",{className:"flex items-center gap-1.5 sm:gap-2 mb-2 sm:mb-3 flex-wrap",children:[e.jsx(Yt,{className:"w-4 h-4 text-icon-card-title flex-shrink-0"}),e.jsx("span",{className:"type-micro",children:"DELAY DOCTOR"}),i&&e.jsx(U,{color:"zinc",className:"hidden sm:inline-flex",children:i})]}),e.jsxs("button",{onClick:et,className:"flex gap-3 mb-2 sm:mb-3 w-full text-left hover:bg-subtle-fill radius-inner transition-base p-1 -m-1 group",title:S,children:[e.jsxs("div",{className:"flex-1 flex flex-col",children:[e.jsx("span",{className:"type-data-xl text-fg-primary",children:e.jsxs($,{children:["×",p.floodFactor.toFixed(1)]})}),e.jsx("span",{className:"type-micro text-fg-muted mt-0.5 sm:mt-1",children:"Flood"})]}),e.jsxs("div",{className:"flex-1 flex flex-col",children:[e.jsx("span",{className:"type-data-xl text-sys-blue",children:e.jsxs($,{children:["×",p.directFactor.toFixed(1)]})}),e.jsx("span",{className:"type-micro text-fg-muted mt-0.5 sm:mt-1",children:"Direct"})]}),e.jsx("div",{className:"flex items-center self-center opacity-0 group-hover:opacity-100 transition-opacity",children:m?e.jsx(be,{className:"w-4 h-4 text-sys-green"}):e.jsx(ut,{className:"w-4 h-4 text-fg-muted"})})]}),e.jsx("div",{className:"flex-1 py-2",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"data-box-label",children:"Dupe"}),e.jsxs("div",{className:`data-box data-box-fill data-box-left ${p.duplicateRate>8?"text-status-warning":""}`,children:[p.duplicateRate.toFixed(1),"%"]})]}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"data-box-label",children:"TX Util"}),e.jsxs("div",{className:"data-box data-box-fill data-box-left",children:[p.txUtilization.toFixed(2),"%"]})]})]})}),e.jsx("div",{className:"pt-2 mt-auto",children:e.jsxs("div",{className:"flex items-end justify-between gap-2",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"data-box-label",children:"Current"}),e.jsx("div",{className:"flex gap-2",children:w!==null?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"data-box",children:["×",w.toFixed(2)]}),e.jsxs("div",{className:"data-box",style:{color:"var(--sys-blue)"},children:["×",(C==null?void 0:C.toFixed(2))??"—"]})]}):e.jsx("span",{className:"text-sm text-fg-muted",children:"No config"})})]}),Qe&&e.jsxs("button",{onClick:tt,disabled:r==="applying"||r==="success",className:`flex items-center gap-1.5 px-2.5 py-1.5 radius-inner type-micro font-medium transition-base - ${r==="success"?"bg-sys-green/15 text-sys-green":r==="error"?"bg-sys-red/15 text-sys-red":r==="applying"?"bg-subtle-fill text-fg-muted":"bg-sys-blue/10 text-sys-blue hover:bg-sys-blue/20"}`,title:`Apply ×${p.floodFactor.toFixed(1)} flood, ×${p.directFactor.toFixed(1)} direct`,children:[r==="success"?"Rx'd":r==="error"?"Failed":"Apply",r==="applying"?e.jsx(ee,{className:"w-3.5 h-3.5 animate-spin"}):r==="success"?e.jsx(be,{className:"w-3.5 h-3.5"}):e.jsxs("span",{className:"relative inline-flex items-end w-6 h-3.5",children:[e.jsx(ws,{className:"w-3.5 h-3.5 absolute left-0 bottom-0"}),e.jsx(Ts,{className:"w-3 h-3 absolute right-0 bottom-0"})]})]})]})})]})}const qe=[{target:"RecentPackets",fn:"rssi",minStage:1},{target:"RecentPackets",fn:"snr",minStage:1}];O(qe);const Ys=25;function Ks(){I(qe);const t=G(),s=xt(),n=ht(),a=te(),o=Qt(),i=ce(c=>c.requestChannel),[l,m]=f.useState(!0),d=f.useCallback(c=>m(c),[]),r=f.useMemo(()=>[...t.length<=100?t:t.slice(-100)].sort((h,y)=>(y.timestamp??0)-(h.timestamp??0)),[t]),x=a==null?void 0:a.local_hash,u=a==null?void 0:a.neighbors,g=es();return e.jsxs(H,{noPadding:!0,className:"!overflow-visible",children:[e.jsx(Be,{listHeader:!0,icon:e.jsx(Le,{}),title:"Recent Packets",actions:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(ft,{enabled:l,onChange:d,label:"Hide Dupes",size:"sm"}),n&&e.jsx(pt,{showLabel:!0}),e.jsxs(je,{color:"primary",outline:!0,href:"/packets",children:["View all",e.jsx(Me,{"data-slot":"icon"})]})]})}),e.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto px-1",children:e.jsx(Kt,{packets:r,allPackets:t,localHash:x,neighbors:u,resolveSource:g,getDecodedContent:o,onChannelClick:i,loading:s,maxPackets:Ys,showPagination:!1,flashNewest:!0,hideDupes:l,emptyMessage:"No packets received",footerAction:e.jsxs(je,{color:"primary",outline:!0,href:"/packets",children:["View all",e.jsx(Me,{"data-slot":"icon"})]})})})]})}const Js={stable:"M5 12h14",up:"M5 15l7-7 7 7",down:"M19 9l-7 7-7-7"};function Zs({trend:t}){return e.jsx("span",{className:`mini-widget-trend ${t}`,children:e.jsx("svg",{className:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:Js[t]})})})}function Qs(){return e.jsx("div",{className:"mini-widget-loading",children:e.jsx("div",{className:"mini-widget-loading-spinner"})})}function en({message:t}){return e.jsx("div",{className:"mini-widget-error",children:e.jsx("span",{title:t,children:"No data"})})}function z({title:t,icon:s,value:n,unit:a,valueSize:o="md",status:i,subtitle:l,trend:m,children:d,isLoading:r=!1,error:x,className:u="",onClick:g}){const c=["mini-widget-value",o==="lg"&&"mini-widget-value-lg",o==="sm"&&"mini-widget-value-sm"].filter(Boolean).join(" "),h=["mini-widget",u].filter(Boolean).join(" ");return e.jsxs(H,{noPadding:!0,className:h,onClick:g,children:[e.jsxs("div",{className:"mini-widget-header",children:[s,e.jsx("span",{className:"mini-widget-title",children:t}),i&&i!=="unknown"&&e.jsx("div",{className:`mini-widget-status-dot ${i}`}),m&&e.jsx(Zs,{trend:m})]}),r?e.jsx(Qs,{}):x?e.jsx(en,{message:x}):e.jsxs(e.Fragment,{children:[n!==void 0&&e.jsxs("div",{className:c,children:[typeof n=="number"?e.jsx(V,{value:n,className:"font-mono tabular-nums",priority:"medium",format:Number.isInteger(n)?void 0:{minimumFractionDigits:1,maximumFractionDigits:1}}):e.jsx($,{children:n}),a&&e.jsx("span",{className:"mini-widget-unit",children:a})]}),l&&e.jsx("div",{className:"mini-widget-subtitle",children:l}),d]})]})}const tn={DELTA_CRITICAL:10,SLOPE_CRITICAL:4,JITTER_CRITICAL:6,DELTA_WARNING:5,SLOPE_WARNING:2,JITTER_WARNING:4},Ue={baselineMedian:null,baselineP10:null,baselineP90:null,currentMedian:null,currentSampleCount:0,delta:0,slope:0,jitter:0,penalty:0,penaltyReason:null,computedAt:0,isReliable:!1};function me(t,s){if(t.length===0)return null;const n=[...t].sort((l,m)=>l-m),a=s/100*(n.length-1),o=Math.floor(a),i=Math.ceil(a);return o===i?n[o]:n[o]+(n[i]-n[o])*(a-o)}function Se(t){return me(t,50)}function sn(t){if(t.length<2)return 0;const s=t.reduce((o,i)=>o+i,0)/t.length,a=t.map(o=>Math.pow(o-s,2)).reduce((o,i)=>o+i,0)/t.length;return Math.sqrt(a)}function nn(t){if(t.length<2)return 0;const s=t.length;let n=0,a=0,o=0,i=0;const l=t[0].timestamp;for(const d of t){const r=(d.timestamp-l)/3600,x=d.value;n+=r,a+=x,o+=r*x,i+=r*r}const m=s*i-n*n;return Math.abs(m)<1e-4?0:(s*o-n*a)/m}function an(t,s,n){const a=tn;return t>=a.DELTA_CRITICAL?[2,`Noise floor ${t.toFixed(1)} dB above baseline`]:s>=a.SLOPE_CRITICAL?[2,`Noise floor rising ${s.toFixed(1)} dB/hour`]:n>=a.JITTER_CRITICAL?[2,`Noise floor unstable (±${n.toFixed(1)} dB)`]:t>=a.DELTA_WARNING?[1,`Noise floor ${t.toFixed(1)} dB above baseline`]:s>=a.SLOPE_WARNING?[1,`Noise floor rising ${s.toFixed(1)} dB/hour`]:n>=a.JITTER_WARNING?[1,`Noise floor variable (±${n.toFixed(1)} dB)`]:[0,null]}function on(t){if(t.length===0)return{...Ue,computedAt:Math.floor(Date.now()/1e3)};const s=Math.floor(Date.now()/1e3),n=t.filter(v=>Number.isFinite(v)),a=t.length>0?[t[t.length-1]]:[],o=t.slice(-4).filter(v=>Number.isFinite(v)),i=Se(n),l=me(n,10),m=me(n,90),d=Se(a),r=d!==null&&l!==null?d-l:0,x=o.map((v,k)=>({timestamp:s-(o.length-1-k)*3600,value:v})),u=nn(x),g=sn(o),c=n.length>=12,[h,y]=c?an(r,u,g):[0,null];return{baselineMedian:i,baselineP10:l,baselineP90:m,currentMedian:d,currentSampleCount:a.length,delta:r,slope:u,jitter:g,penalty:h,penaltyReason:y,computedAt:s,isReliable:c}}const rn={lbtStats:null,noiseFloor:null,sparklineNoiseFloor:[],noiseFloorWindowHistory:[],linkQuality:null,channelHealth:null,nfTrend:Ue,radioConfig:null,trends:null,stats:null,recentPackets:[],quickNeighbors:[],isLoading:!0,error:null,refresh:async()=>{}},Ve=f.createContext(rn);function ln({children:t}){var b;const s=te(),n=G(),a=Fe(),o=gt(),i=X(),l=P[i],m=Math.max(1,l.minutes/60),d=s===null,r=f.useMemo(()=>yt(n,m),[n,m]),x=(s==null?void 0:s.noise_floor_dbm)??null,u=f.useMemo(()=>bt(x)?x:null,[x]),g=f.useMemo(()=>{var R;const S=(R=s==null?void 0:s.config)==null?void 0:R.radio;return S?{sf:S.spreading_factor??7,bwHz:S.bandwidth??125e3}:null},[(b=s==null?void 0:s.config)==null?void 0:b.radio]),c=jt(m),h=Nt(m),y=s==null?void 0:s.neighbors,v=f.useMemo(()=>Object.fromEntries(Object.entries(y??{}).filter(([R])=>!o.has(R))),[y,o]),k=f.useMemo(()=>a.filter(S=>!o.has(S.hash)),[a,o]),M=f.useMemo(()=>on(c),[c]),j=f.useMemo(()=>vt(k,v,g),[k,v,g]),N=f.useMemo(()=>wt(r,u,j),[r,u,j]),[w,C]=f.useState({noiseFloor:null,networkScore:null,channelHealth:null}),p=f.useRef(0);f.useEffect(()=>{const S=()=>{const B=Date.now();B-p.current>3e4&&(p.current=B,C({noiseFloor:u,networkScore:(j==null?void 0:j.networkScore)??null,channelHealth:(N==null?void 0:N.score)??null}))};S();const R=setInterval(S,5e3);return()=>clearInterval(R)},[u,j==null?void 0:j.networkScore,N==null?void 0:N.score]);const D=f.useMemo(()=>({noiseFloor:{current:u,previous:w.noiseFloor,trend:u!==null?ne(u,w.noiseFloor,2,!0):"stable"},networkScore:{current:(j==null?void 0:j.networkScore)??0,previous:w.networkScore,trend:ne((j==null?void 0:j.networkScore)??0,w.networkScore,3,!1)},channelHealth:{current:(N==null?void 0:N.score)??0,previous:w.channelHealth,trend:ne((N==null?void 0:N.score)??0,w.channelHealth,3,!1)}}),[u,j==null?void 0:j.networkScore,N==null?void 0:N.score,w]),_={lbtStats:r,noiseFloor:u,sparklineNoiseFloor:c,noiseFloorWindowHistory:h,linkQuality:j,channelHealth:N,nfTrend:M,radioConfig:g,trends:D,stats:s,recentPackets:n,quickNeighbors:a,isLoading:d,error:null,refresh:async()=>{}};return e.jsx(Ve.Provider,{value:_,children:t})}function Y(){const t=f.useContext(Ve);if(t===void 0)throw new Error("useLBTData must be used within an LBTDataProvider");return t}function cn(t){return t<100?"excellent":t<250?"good":t<500?"fair":t<1e3?"congested":"critical"}function dn(t,s){return t===0?"No backoffs":`${s.toFixed(0)}% retry rate`}function mn(){const{lbtStats:t,isLoading:s,error:n}=Y(),a=xe(),o=(t==null?void 0:t.avgBackoffMs)??0,i=(t==null?void 0:t.retryRate)??0,l=t?cn(o):"unknown",m=t==null?void 0:t.sparklineBackoff,d=f.useMemo(()=>!m||m.length<2?[]:m.map((r,x)=>({timestamp:Date.now()-(m.length-1-x)*36e5,count:r})),[m]);return e.jsx(z,{title:"LBT Backoff",icon:e.jsx(_s,{className:"mini-widget-icon"}),value:Math.round(o),unit:"ms",status:l,subtitle:t?dn(o,i):void 0,isLoading:s,error:n,onClick:()=>a("/packets"),children:e.jsx("div",{className:"mini-widget-sparkline w-full",children:e.jsx(he,{data:d,width:9999,height:24,color:"var(--sys-blue)",isLoading:s,className:"w-full"})})})}function le(t){return t===0?"—":t<1?"<1":Math.round(t).toString()}function un(){const{lbtStats:t,isLoading:s,error:n}=Y(),a=xe(),o=(t==null?void 0:t.channelBusyCount)??0,i=(t==null?void 0:t.totalPacketsWithLBT)??0,l=(t==null?void 0:t.channelBusyRate)??0,m=(t==null?void 0:t.retryRate)??0,d=(t==null?void 0:t.avgBackoffMs)??0,r=(t==null?void 0:t.minBackoffMs)??0,x=(t==null?void 0:t.maxBackoffMs)??0,u=m>0?Math.max(0,(m-l)/m*100):100;return e.jsx(z,{title:"Ch. Busy",icon:e.jsx(Ut,{className:"mini-widget-icon"}),isLoading:s,error:n,onClick:()=>a("/packets"),children:e.jsx("div",{className:"flex-1 flex items-end",children:e.jsxs("div",{className:"grid grid-cols-[auto_minmax(0,1fr)] sm:grid-cols-[auto_minmax(0,1fr)_auto_minmax(0,1fr)] gap-x-2 gap-y-1 sm:gap-y-2 w-full items-baseline",children:[e.jsx("span",{className:"data-box-label mb-0 text-[10px] sm:text-sm",title:`${o} packets exceeded max CAD attempts (5) out of ${i} total transmissions.`,children:"Failed:"}),e.jsxs("div",{className:"data-box data-box-compact sm:data-box justify-self-start",title:`${o} packets exceeded max CAD attempts (5) out of ${i} total transmissions.`,children:[e.jsx($,{children:o}),e.jsx("span",{className:"text-fg-muted punc-slash",children:"/"}),e.jsx($,{children:i})]}),e.jsx("span",{className:"data-box-label mb-0 text-[10px] sm:text-sm",title:`${u.toFixed(1)}% of packets that needed LBT retries were sent successfully.`,children:"Sent:"}),e.jsx("div",{className:"data-box data-box-compact sm:data-box justify-self-start",title:`${u.toFixed(1)}% of packets that needed LBT retries were sent successfully.`,children:e.jsxs($,{children:[u.toFixed(0),"%"]})}),e.jsx("span",{className:"data-box-label mb-0 text-[10px] sm:text-sm",title:`Average LBT backoff delay: ${d.toFixed(0)}ms.`,children:"Mean:"}),e.jsxs("div",{className:"data-box data-box-compact sm:data-box justify-self-start",title:`Average LBT backoff delay: ${d.toFixed(0)}ms.`,children:[e.jsx($,{children:le(d)}),e.jsx("span",{className:"text-fg-muted text-xs",children:"ms"})]}),e.jsx("span",{className:"data-box-label mb-0 text-[10px] sm:text-sm",title:`Backoff range: ${r.toFixed(0)}ms min, ${x.toFixed(0)}ms max.`,children:"Range:"}),e.jsxs("div",{className:"data-box data-box-compact sm:data-box justify-self-start",title:`Backoff range: ${r.toFixed(0)}ms min, ${x.toFixed(0)}ms max.`,children:[e.jsx($,{children:le(r)}),e.jsx("span",{className:"text-fg-muted punc-slash",children:"/"}),e.jsx($,{children:le(x)})]})]})})})}const xn=.25,_e=48;function hn(t,s,n,a){const o=t.length;if(o===0)return[];if(o===1)return new Array(a).fill(s[0]);if(o===2){const u=new Array(a);for(let g=0;gw-C),h=Math.max(c[i-1],1e-10);let y=0,v=0,k=0,M=0,j=0;for(let w=0;w=1)continue;const p=C*C*C,D=(1-p)*(1-p)*(1-p),T=t[w]-g;y+=D,v+=D*T,k+=D*s[w],M+=D*T*T,j+=D*T*s[w]}if(y===0){r[u]=s[Math.round(u/(a-1)*(o-1))];continue}const N=y*M-v*v;r[u]=Math.abs(N)<1e-10?k/y:(M*k-v*j)/N}return r}function fn(t){return t===null||t<-110?"excellent":t<-100?"good":t<-90?"fair":t<-80?"congested":"critical"}function pn(t){return t===null?"No reading":t<-115?"Very quiet":t<-105?"Quiet":t<-95?"Moderate":t<-85?"Elevated":"High interference"}function gn(){const{noiseFloor:t,noiseFloorWindowHistory:s,trends:n,isLoading:a,error:o}=Y(),i=fn(t),l=n==null?void 0:n.noiseFloor.trend,m=f.useMemo(()=>{if(!s||s.length<2)return[];const r=s.map(g=>g.timestamp),x=s.map(g=>-g.noise_floor_dbm);return hn(r,x,xn,_e).map((g,c)=>({timestamp:Date.now()-(_e-1-c)*36e5,count:g}))},[s]),d=t!==null?Math.round(t):"—";return e.jsx(z,{title:"Noise Floor",icon:e.jsx(xs,{className:"mini-widget-icon"}),value:d,unit:t!==null?"dBm":void 0,status:i,trend:l,subtitle:pn(t),isLoading:a,error:o,children:e.jsx("div",{className:"mini-widget-sparkline w-full",children:e.jsx(he,{data:m,width:9999,height:22,color:"var(--sys-blue)",isLoading:a,className:"w-full"})})})}const Ge=[{target:"LinkLeaders",fn:"path",minStage:1,when:zt},{target:"LinkLeaders",fn:"src_hash",minStage:1,when:Wt}];O(Ge);function yn(){I(Ge);const t=xe(),s=Fe(),n=G(),a=te(),o=X(),l=P[o].minutes*60,m=kt(),d=f.useMemo(()=>{if(m===0)return n;const p=m-l;return n.filter(D=>D.timestamp>=p)},[n,l,m]),r=a===null,x=a!=null&&a.local_hash?Ne(a.local_hash):"",u=(a==null?void 0:a.neighbors)??{},{neighborHashes:g,neighborNames:c}=f.useMemo(()=>{const p=new Set,D=new Map;for(const T of s){p.add(T.hash);const _=u[T.hash],b=(_==null?void 0:_.name)||(_==null?void 0:_.node_name)||T.prefix;D.set(T.hash,b)}return{neighborHashes:p,neighborNames:D}},[s,u]),h=f.useMemo(()=>{if(g.size===0||d.length===0||!x)return{champion:null,listener:null,loudest:null};const{scores:p}=ts(d,g,x),D=[];for(const[S,R]of p)R.blendedScore!==0&&D.push({...R,name:c.get(S)??Ne(S)});let T=null,_=null,b=null;for(const S of D)(!T||S.blendedScore>T.blendedScore)&&(T=S),(!_||S.listenerScore>_.listenerScore)&&(_=S),(!b||S.loudScore>b.loudScore)&&(b=S);return{champion:T,listener:_,loudest:b}},[d,g,x,c]),y=p=>e.jsxs("div",{className:"max-w-[220px]",children:[e.jsxs("div",{className:"font-semibold mb-1",children:["🏆 Champion: ",p.name]}),e.jsxs("div",{className:"text-fg-muted mb-1",children:["Blended Score: ",p.blendedScore,e.jsx("span",{className:"text-fg-muted/60 ml-1",children:"(Listener + Loud)"})]}),e.jsxs("div",{className:"border-t border-edge-subtle pt-1 mt-1 space-y-0.5",children:[e.jsxs("div",{children:["Listener: ",p.listenerScore,"/100 (",p.listenerCount," shared paths)"]}),e.jsxs("div",{children:["Loud: ",p.loudScore,"/100 (",p.loudCount," packets relayed)"]})]})]}),v=p=>e.jsxs("div",{className:"max-w-[220px]",children:[e.jsxs("div",{className:"font-semibold mb-1",children:["👂 Best Listener: ",p.name]}),e.jsxs("div",{className:"text-fg-muted mb-1",children:["Score: ",p.listenerScore,"/100"]}),e.jsx("div",{className:"border-t border-edge-subtle pt-1 mt-1",children:e.jsxs("div",{children:[p.listenerCount," packets where they heard your transmissions"]})})]}),k=p=>e.jsxs("div",{className:"max-w-[220px]",children:[e.jsxs("div",{className:"font-semibold mb-1",children:["📢 Loudest: ",p.name]}),e.jsxs("div",{className:"text-fg-muted mb-1",children:["Score: ",p.loudScore,"/100"]}),e.jsx("div",{className:"border-t border-edge-subtle pt-1 mt-1",children:e.jsxs("div",{children:[p.loudCount," packets they relayed directly to you"]})})]}),{champion:M,listener:j,loudest:N}=h,C=M||j||N?e.jsxs("div",{className:"flex flex-col gap-0 sm:gap-0.5 mt-auto",children:[M&&e.jsx(ae,{content:y(M),children:e.jsxs("div",{className:"flex items-center gap-1 text-xs sm:text-sm radius-badge px-1 -mx-1 hover-bg transition-base cursor-default",children:[e.jsx(Jt,{className:"w-2.5 h-2.5 sm:w-3 sm:h-3 text-map-neighbor-color flex-shrink-0"}),e.jsx("span",{className:"font-semibold text-map-neighbor-color font-mono truncate flex-1 min-w-0",children:M.name}),e.jsx("span",{className:"text-map-neighbor-color pl-1 sm:pl-2 tabular-nums flex-shrink-0 w-7 sm:w-9 text-right",children:M.blendedScore})]})}),j&&e.jsx(ae,{content:v(j),children:e.jsxs("div",{className:"flex items-center gap-1 text-xs sm:text-sm radius-badge px-1 -mx-1 hover-bg transition-base cursor-default",children:[e.jsx(gs,{className:"w-2.5 h-2.5 sm:w-3 sm:h-3 text-fg-muted flex-shrink-0"}),e.jsx("span",{className:"text-fg-muted font-mono truncate flex-1 min-w-0",children:j.name}),e.jsx("span",{className:"text-fg-muted pl-1 sm:pl-2 tabular-nums flex-shrink-0 w-7 sm:w-9 text-right",children:j.listenerScore})]})}),N&&e.jsx(ae,{content:k(N),children:e.jsxs("div",{className:"flex items-center gap-1 text-xs sm:text-sm radius-badge px-1 -mx-1 hover-bg transition-base cursor-default",children:[e.jsx(bs,{className:"w-2.5 h-2.5 sm:w-3 sm:h-3 text-fg-muted flex-shrink-0"}),e.jsx("span",{className:"text-fg-muted font-mono truncate flex-1 min-w-0",children:N.name}),e.jsx("span",{className:"text-fg-muted pl-1 sm:pl-2 tabular-nums flex-shrink-0 w-7 sm:w-9 text-right",children:N.loudScore})]})})]}):s.length===0?e.jsx("div",{className:"flex items-center justify-center text-xs sm:text-sm text-fg-muted mt-auto",children:"No direct neighbors"}):e.jsx("div",{className:"flex items-center justify-center text-xs sm:text-sm text-fg-muted mt-auto",children:"No routing data yet"});return e.jsx(z,{title:"Link Leaders",icon:e.jsx(Ms,{className:"mini-widget-icon"}),isLoading:r,onClick:()=>t("/contacts"),children:C})}function bn(t){const{retryRate:s,channelBusyCount:n,totalPacketsWithLBT:a,avgBackoffMs:o,maxBackoffMs:i}=t;if(a===0)return 0;const l=Math.min(a/10,1),m=.15,d=Math.log(1+s*m)/Math.log(1+100*m)*40,r=n/a*100,x=Math.min(r*.5,25);let u=0;o>100&&(u=Math.min(Math.log10(o/100)*8,15));let g=0;i>500&&o>0&&i>o*2&&(g=Math.min((i-500)/200,5));const h=(d+x+u+g)*l;return Math.min(h,85)}function jn(t){return t<15?"excellent":t<30?"good":t<45?"fair":t<60?"congested":"critical"}function Nn(t){return t<15?"Clear channel":t<30?"Light traffic":t<45?"Moderate traffic":t<60?"Heavy traffic":t<75?"Congested":"Severe congestion"}function vn(){const{lbtStats:t,isLoading:s,error:n}=Y(),a=t?bn(t):0,o=t?jn(a):"unknown",i=(t==null?void 0:t.maxBackoffMs)??0,l=t?i>200?`Max backoff: ${Math.round(i)}ms`:Nn(a):void 0,m=t==null?void 0:t.sparklineCollisionRisk,d=f.useMemo(()=>!m||m.length<2?[]:m.map((x,u)=>({timestamp:Date.now()-(m.length-1-u)*36e5,count:x})),[m]),r=Math.round(a*10)/10;return e.jsx(z,{title:"Collision Risk",icon:e.jsx(ss,{className:"mini-widget-icon"}),value:r,unit:"%",status:o,subtitle:l,isLoading:s,error:n,children:e.jsx("div",{className:"mini-widget-sparkline w-full",children:e.jsx(he,{data:d,width:9999,height:24,color:"var(--sys-blue)",isLoading:s,className:"w-full"})})})}function wn(t){return t<30?"excellent":t<50?"good":t<70?"fair":t<90?"congested":"critical"}function kn(t){return t<1e3?`${Math.round(t)}ms`:t<6e4?`${(t/1e3).toFixed(1)}s`:`${(t/6e4).toFixed(1)}m`}function Mn(){const[t,s]=f.useState(!1),[n]=f.useState(0),{stats:a,lbtStats:o,isLoading:i}=Y(),l=f.useMemo(()=>{if(!a)return null;const c=a.airtime_used_ms??0,h=a.max_airtime_ms??1,y=a.airtime_remaining_ms??0,v=a.utilization_percent??(h>0?c/h*100:0);return{usedMs:c,maxMs:h,remainingMs:y,utilizationPercent:v}},[a]),m=f.useMemo(()=>{if(!o||o.totalPacketsWithLBT===0)return 100;const c=o.totalPacketsWithLBT-o.packetsWithRetries,h=o.totalPacketsWithLBT;return c/h*100},[o]),d=(l==null?void 0:l.utilizationPercent)??0,r=wn(d),x=(l==null?void 0:l.remainingMs)??0,u=m<95?`${m.toFixed(0)}% clean TX`:`${kn(x)} remaining`,g=l?e.jsx("div",{className:"mini-widget-progress mt-auto",children:e.jsx("div",{className:`mini-widget-progress-bar ${r}`,style:{width:`${Math.min(d,100)}%`}})}):null;return e.jsx(z,{title:"Duty Cycle",icon:e.jsx(Le,{className:"mini-widget-icon"}),value:d.toFixed(1),unit:"%",status:r,subtitle:u,isLoading:i,children:g})}function Cn(){return e.jsxs("div",{className:"mini-widget",children:[e.jsxs("div",{className:"mini-widget-header",children:[e.jsx(K,{className:"w-4 h-4"}),e.jsx(K,{className:"h-3 w-16"})]}),e.jsx(K,{className:"h-7 w-12 mt-2"}),e.jsx(K,{className:"h-3 w-20 mt-2"})]})}function Tn(){return e.jsx("div",{className:"widget-row",children:Array.from({length:6}).map((t,s)=>e.jsx(Cn,{},s))})}const Xe=[{target:"MeshHealth",fn:"type",minStage:1}];O(Xe);function Sn({className:t="",isLoaded:s=!0}){return I(Xe),e.jsxs("div",{className:`mesh-health-container relative ${t}`,children:[e.jsxs("div",{className:"mesh-health-header",children:[e.jsx(Mt,{className:"w-4 h-4 text-sys-blue"}),e.jsx("span",{className:"type-label text-fg-muted",children:"MESH HEALTH"})]}),s?e.jsx(ln,{children:e.jsxs("div",{className:"widget-row",children:[e.jsx(mn,{}),e.jsx(vn,{}),e.jsx(gn,{}),e.jsx(Mn,{}),e.jsx(un,{}),e.jsx(yn,{})]})}):e.jsx(Tn,{})]})}const Ye=[{target:"PublicChannel",fn:"decrypt",minStage:2,when:qt}];O(Ye);let Ke="",Je="",De="";function _n(){const t=new Date,s=t.toDateString();if(s!==De){De=s,Ke=s;const n=new Date(t);n.setDate(n.getDate()-1),Je=n.toDateString()}}function Dn(t){_n();const s=new Date(t*1e3).toDateString();return s===Ke?"Today":s===Je?"Yesterday":new Date(t*1e3).toLocaleDateString([],{weekday:"short",month:"short",day:"numeric"})}function Rn(t,s,n){return`${t||""}|${s}|${n}`}function Bn(t,s){const n=t.message,a=s.message;return n.timestamp===a.timestamp&&n.text===a.text&&n.senderName===a.senderName&&n.channelHash===a.channelHash&&n.channelName===a.channelName&&t.isChannelSelected===s.isChannelSelected&&t.onChannelClick===s.onChannelClick}const Ln=f.memo(function({message:s,onChannelClick:n,isChannelSelected:a}){const o=s.channelName||s.channelHash.slice(0,6);return e.jsx("div",{style:{transform:"translateZ(0)",willChange:"transform"},children:e.jsx(ls,{senderName:s.senderName||"Unknown",text:s.text,timestamp:s.timestamp,nameAccessory:e.jsx($e,{channelName:o,active:a,onClick:()=>n==null?void 0:n(s.channelHash)})})})},Bn);function Fn({open:t,onClose:s,messages:n,onLoadMore:a,hasMoreToLoad:o,isDecoding:i,initialChannel:l}){const m=f.useRef(null),d=f.useRef(!0),r=X(),x=Pe(),u=f.useRef(!1);f.useEffect(()=>{t?(u.current=!0,we.resume()):u.current&&we.pause()},[t]);const g=f.useMemo(()=>{const b=Date.now()/1e3,S=P[r].minutes,R=b-S*60;return[...n].filter(B=>B.timestamp>=R).sort((B,W)=>B.timestamp-W.timestamp)},[n,r]),c=f.useCallback(()=>{const b=m.current;b&&(d.current=b.scrollTop>=-50)},[]),h=f.useMemo(()=>{const b=new Map;for(const S of g){const R=S.channelHash,B=b.get(R);B?B.count++:b.set(R,{name:S.channelName||S.channelHash.slice(0,6),hash:S.channelHash,count:1})}return Array.from(b.values()).sort((S,R)=>R.count-S.count)},[g]),y=h.length,[v,k]=f.useState(null),[M,j]=f.useState(!1);f.useEffect(()=>{t&&l&&k(l)},[t,l]);const N=f.useCallback(()=>{a(v,h)},[a,v,h]),w=f.useMemo(()=>v?g.filter(b=>b.channelHash===v):g,[g,v]),C=f.useMemo(()=>{const b=[];let S="";for(const R of w){const B=Dn(R.timestamp);B!==S&&(b.push({type:"date",date:B}),S=B),b.push({type:"message",message:R})}return b},[w]);f.useLayoutEffect(()=>{const b=m.current;b&&d.current&&(b.scrollTop=0)},[w.length]);const p=19,D=h.slice(0,p),T=h.slice(p),_=T.length>0;return e.jsx(Rt,{open:t,onClose:s,size:"lg",motionPlus:!0,solid:!0,children:e.jsxs(Bt,{className:"p-0 flex flex-col h-[80vh] max-h-[700px] rounded-2xl",children:[e.jsx("div",{className:"flex-shrink-0 px-4 sm:px-5 py-3 sm:py-4",children:e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(He,{className:"size-5 text-icon-card-title flex-shrink-0"}),e.jsx("h2",{className:"type-micro",children:"Public Channels"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ee,{ranges:P,selectedIndex:r,onSelect:x,size:"sm"}),e.jsx("button",{onClick:s,className:"sm:hidden min-h-[44px] min-w-[44px] px-3 flex items-center justify-center text-[15px] font-medium text-sys-blue active:text-sys-blue/70 transition-base radius-inner active:bg-subtle-fill",children:"Done"}),e.jsx("button",{onClick:s,className:"hidden sm:flex items-center justify-center p-2 text-fg-muted hover:text-fg-primary transition-base radius-inner hover:bg-subtle","aria-label":"Close",children:e.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]})]})}),e.jsx("div",{className:"flex-shrink-0 px-3 pb-2 relative z-10 isolate",style:{minHeight:y>0?void 0:0},children:y>0&&e.jsxs("div",{className:"flex flex-wrap gap-1",children:[e.jsxs("button",{onClick:()=>k(null),className:F("px-2 py-0.5 rounded text-xs font-medium transition-all","ring-1 ring-inset",v===null?"bg-sys-blue/20 text-sys-blue ring-sys-blue/30":"bg-subtle-fill text-fg-secondary ring-edge-subtle hover:bg-subtle-fill-strong"),children:["All ",y]}),D.map(b=>e.jsx("button",{onClick:()=>k(b.hash),className:F("flex items-center gap-1 px-2 py-0.5 rounded text-xs font-medium transition-all","ring-1 ring-inset",v===b.hash?"bg-sys-blue/20 text-sys-blue ring-sys-blue/30":"bg-subtle-fill text-fg-secondary ring-edge-subtle hover:bg-subtle-fill-strong"),children:e.jsx("span",{className:"truncate max-w-[80px]",children:b.name})},b.hash)),_&&e.jsxs("div",{className:"relative",children:[e.jsxs("button",{onClick:()=>j(!M),className:F("flex items-center gap-0.5 px-2 py-0.5 rounded text-xs font-medium transition-all","ring-1 ring-inset",M||T.some(b=>b.hash===v)?"bg-sys-blue/20 text-sys-blue ring-sys-blue/30":"bg-subtle-fill text-fg-secondary ring-edge-subtle hover:bg-subtle-fill-strong"),children:["+",T.length,e.jsx(Lt,{className:F("size-3 transition-transform",M&&"rotate-180")})]}),M&&e.jsx("div",{className:F("absolute top-full left-0 mt-1 z-50","min-w-[140px] max-h-[200px] overflow-y-auto","p-1 rounded-lg","bg-elevated backdrop-blur-xl","ring-1 ring-edge-subtle shadow-xl"),children:T.map(b=>e.jsxs("button",{onClick:()=>{k(b.hash),j(!1)},className:F("w-full flex items-center gap-1.5 px-2 py-1 rounded text-xs font-medium transition-all text-left",v===b.hash?"bg-sys-blue/20 text-sys-blue":"text-fg-secondary hover:bg-subtle-fill-strong"),children:[e.jsx(cs,{className:"size-2.5 opacity-60 flex-shrink-0"}),e.jsx("span",{className:"truncate",children:b.name}),e.jsxs("span",{className:"opacity-60 ml-auto",children:["(",b.count,")"]})]},b.hash))})]})]})}),e.jsx("div",{ref:m,onScroll:c,className:F("flex-1 overflow-y-auto overflow-x-hidden","mx-3 mb-3 rounded-md","bg-body","ring-1 ring-inset ring-edge-subtle","flex flex-col-reverse"),children:i&&w.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center h-full min-h-[300px] text-fg-muted px-4 py-4",children:[e.jsx(ee,{className:"size-12 mb-4 text-sys-indigo animate-spin"}),e.jsx("p",{className:"text-lg font-medium",children:"Loading messages..."})]}):w.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center h-full min-h-[300px] text-fg-muted px-4 py-4",children:[e.jsx(Ns,{className:"size-16 mb-4 opacity-20"}),e.jsx("p",{className:"text-lg font-medium",children:"No messages yet"}),e.jsx("p",{className:"text-sm mt-1 opacity-70",children:v?"No messages in this channel":"Public channel messages will appear here"})]}):e.jsxs("div",{className:"px-4 py-4",children:[o&&e.jsx("div",{className:"flex justify-center mb-4",children:e.jsx("button",{onClick:N,disabled:i,className:F("px-4 py-1.5 rounded-full","text-[11px] font-medium","ring-1 ring-inset",i?"bg-subtle-fill text-fg-muted ring-edge-subtle cursor-wait":"bg-sys-blue/10 text-sys-blue ring-sys-blue/20 hover:bg-sys-blue/20 hover:ring-sys-blue/30"),children:i?e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(ee,{className:"size-3 animate-spin"}),"Loading..."]}):"Load older messages"})}),C.map((b,S)=>{if(b.type==="date")return e.jsx("div",{className:"flex justify-center my-4",children:e.jsx("span",{className:F("px-3.5 py-1.5 rounded-full","bg-subtle-fill backdrop-blur-sm","text-[11px] text-fg-muted/80 font-medium","ring-1 ring-edge-subtle"),children:b.date})},`date-${b.date}-${S}`);const R=`msg-${b.message.timestamp}-${b.message.senderName||"anon"}-${b.message.channelHash}`;return e.jsx("div",{className:"mb-3",children:e.jsx(Ln,{message:b.message,onChannelClick:k,isChannelSelected:v===b.message.channelHash})},R)})]})}),e.jsx("div",{className:"flex-shrink-0 px-5 py-2 text-center",children:e.jsxs("p",{className:"text-[11px] text-fg-muted",children:[w.length," messages · ",y," ",y===1?"channel":"channels",i&&e.jsxs("span",{className:"ml-2 text-sys-indigo",children:[e.jsx(ee,{className:"inline size-3 animate-spin mr-1"}),"Decrypting..."]})]})})]})})}function Pn(t){const s=[],n=new Set;for(const a of t.values()){const o=a.decoded;if(!o||!o.decrypted||o.macCorrupted||!o.text)continue;const i=Rn(o.senderName,o.channelHash,o.text);n.has(i)||(n.add(i),s.push({timestamp:a.timestamp,channelName:o.channelName,channelHash:o.channelHash,senderName:o.senderName,text:o.text,rssi:a.rssi,snr:a.snr}))}return s}function An({isLoaded:t=!0}){I(Ye);const s=G(),[n,a]=f.useState(!1),[o,i]=f.useState(null),l=X(),m=f.useCallback(()=>{i(null),a(!0),J.getState().queueDecryption(s)},[s]),d=ce(C=>C.requestedHash),r=ce(C=>C.clearRequest);f.useEffect(()=>{d&&(i(d),a(!0),J.getState().queueDecryption(s),r())},[d,r,s]);const x=Ct(),u=Tt(),g=St(),c=f.useMemo(()=>Pn(x),[x]),h=f.useMemo(()=>{const C=Date.now()/1e3,p=P[l].minutes,D=C-p*60;return c.filter(T=>T.timestamp>=D)},[c,l]),y=f.useMemo(()=>h.length===0?null:h.reduce((C,p)=>p.timestamp>C.timestamp?p:C),[h]),v=u.isDecoding,M=f.useMemo(()=>{const C=Date.now()/1e3,p=P[l].minutes,D=C-p*60,T=new Set;let _=0;for(const b of s)(b.type??b.payload_type)===ve.GRP_TXT&&((b.timestamp??0){const C=Date.now()/1e3,p=P[l].minutes,D=C-p*60;for(const T of s)if((T.type??T.payload_type)===ve.GRP_TXT&&!((T.timestamp??0){if(!v){if(C){const D=p.find(T=>T.hash===C);if(D){console.log(`[PublicChannelCard] Fast-path load for #${D.name}`),J.getState().queueChannelDecryption(s,D.name);return}}J.getState().queueDecryption(s)}},[s,v]);return t?e.jsxs(e.Fragment,{children:[e.jsx("div",{onClick:m,className:F("group cursor-pointer rounded-2xl transition-all duration-150","bg-surface/80 backdrop-blur-lg depth-raised","hover:bg-subtle-fill","px-3 py-2.5 sm:px-4 sm:py-3"),children:e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2 sm:gap-3 flex-shrink-0",children:[e.jsx(He,{className:"size-4 text-icon-card-title flex-shrink-0"}),e.jsx("span",{className:"type-micro",children:"CHAT ACTIVITY"}),M>0&&e.jsx("span",{className:"inline-flex items-center px-2 py-1 rounded-md bg-subtle-fill ring-1 ring-inset ring-edge-subtle text-sm tabular-nums text-fg-secondary",children:M}),e.jsx(Ce,{className:"size-4 text-fg-muted group-hover:text-sys-indigo transition-colors ml-auto sm:hidden"})]}),e.jsxs("div",{className:"flex items-center gap-2 sm:gap-1.5 min-w-0 overflow-hidden",children:[e.jsx(Re,{mode:"wait",initial:!1,children:y?e.jsxs(Q.div,{initial:{opacity:0,y:16},animate:{opacity:1,y:0},exit:{opacity:0,y:-16},transition:{duration:.2,ease:[.4,0,.2,1]},className:"flex items-center gap-2 sm:gap-1.5 min-w-0",children:[y.channelName&&e.jsx("span",{className:"hidden sm:inline-flex",children:e.jsx($e,{channelName:y.channelName})}),e.jsx("div",{className:"hidden sm:flex w-[30px] h-[30px] rounded-full items-center justify-center flex-shrink-0 ring-1 ring-edge-subtle",style:{backgroundColor:os(oe(y.senderName||"").cleanName)},children:oe(y.senderName||"").emoji?e.jsx("span",{className:"text-base",children:oe(y.senderName||"").emoji}):e.jsx("span",{className:"text-white text-xs font-bold tracking-tighter",children:is(y.senderName||"")})}),e.jsx("div",{className:"inline-flex items-center px-3 py-1.5 rounded-2xl rounded-tr-md bg-[#007AFF] shadow-sm min-w-0 flex-1 sm:flex-initial sm:max-w-xs sm:-ml-px",children:e.jsx("span",{className:"text-sm text-white truncate tracking-wide",children:rs(y.text)})}),e.jsx("span",{className:"inline-flex items-center px-2 py-1 rounded-md bg-subtle-fill ring-1 ring-inset ring-edge-subtle text-sm tabular-nums text-fg-secondary flex-shrink-0",children:Dt(y.timestamp)})]},`msg-${y.timestamp}-${y.senderName}-${y.channelHash}`):g?e.jsx(Q.span,{initial:{opacity:0},animate:{opacity:1},className:"text-sm text-fg-muted italic",children:"No messages yet"},"empty"):e.jsxs(Q.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0,y:-16},transition:{duration:.15},className:"flex items-center gap-2 sm:gap-1.5",children:[e.jsx("div",{className:"hidden sm:block w-8 h-4 rounded bg-subtle-fill-strong animate-pulse"}),e.jsx("div",{className:"hidden sm:block w-[30px] h-[30px] rounded-full bg-subtle-fill-strong animate-pulse"}),e.jsx("div",{className:"h-8 w-32 sm:w-48 rounded-2xl bg-subtle-fill-strong animate-pulse"}),e.jsx("div",{className:"w-12 h-6 rounded-md bg-subtle-fill-strong animate-pulse"})]},"skeleton")}),e.jsx(Ce,{className:"size-4 text-fg-muted group-hover:text-sys-indigo transition-colors flex-shrink-0 hidden sm:block ml-1"})]})]})}),e.jsx(Fn,{open:n,onClose:()=>a(!1),messages:c,onLoadMore:w,hasMoreToLoad:N,isDecoding:v,initialChannel:o})]}):e.jsx("div",{className:"h-14 rounded-xl bg-elevated/50 animate-pulse"})}function pa(){var M,j;const t=te(),s=Ft(),n=G(),a=Pt(),o=f.useRef(!1);a&&!o.current&&(o.current=!0);const i=o.current,l=X(),m=Pe(),d=At(),r=P[l]??P[4],x=d.isBackgroundLoading&&l>=5,u=(M=t==null?void 0:t.config)==null?void 0:M.radio,g=f.useMemo(()=>u?{sf:u.spreading_factor??10,bw:u.bandwidth??25e4,cr:u.coding_rate??5,preamble:u.preamble_length??8}:null,[u]),c=n.length,h=f.useMemo(()=>c?$t(r.minutes,r.buckets,n,t):null,[c,r.minutes,r.buckets,g]),y=f.useMemo(()=>{const N=R=>(R==null?void 0:R.reduce((B,W)=>B+W.count,0))??0,w=N(h==null?void 0:h.received),C=N(h==null?void 0:h.unique_received),p=N(h==null?void 0:h.forwarded),D=N(h==null?void 0:h.dropped),T=N(h==null?void 0:h.transmitted),_=((h==null?void 0:h.time_range_minutes)??r.minutes)/60,b=_>0?Math.round(w/_):0,S=_>0?Math.round(p/_):0;return{received:w,uniqueReceived:C,forwarded:p,dropped:D,transmitted:T,rxPerHour:b,fwdPerHour:S}},[h,r.minutes]),v=f.useMemo(()=>{if(!n.length)return{totalBytes:0,kbPerHour:0};const N=Date.now()/1e3,w=r.minutes*60,C=N-w;let p=0;for(const _ of n)_.transmitted||_.timestampN||(p+=_.length??_.payload_length??0);const D=r.minutes/60,T=D>0?Math.round(p/1024/D):0;return{totalBytes:p,kbPerHour:T}},[n,r.minutes]),k=(t==null?void 0:t.node_name)??((j=t==null?void 0:t.config)==null?void 0:j.node_name)??"Unknown Node";return f.useEffect(()=>{k&&k!=="Unknown Node"&&(document.title=`pyMC: ${k}`)},[k]),s?e.jsxs(ke,{neomorphic:!0,className:"p-8 text-center",children:[e.jsx("p",{className:"type-subheading text-sys-red mb-2",children:"Failed to connect to backend"}),e.jsx("p",{className:"type-body text-fg-muted",children:s}),e.jsx("p",{className:"type-data-sm text-fg-muted mt-4",children:"Make sure the backend is running on port 8000"})]}):e.jsxs(Et,{children:[e.jsx(Ht,{title:k,icon:e.jsx(ns,{}),controls:e.jsx(Ee,{ranges:P,selectedIndex:l,onSelect:m,isPending:x})}),e.jsxs(It,{children:[e.jsx(An,{isLoaded:i}),e.jsx(ie,{template:"hero-auto",children:e.jsxs(ke,{neomorphic:!0,children:[e.jsx(Be,{icon:e.jsx(fs,{}),title:"PACKETS RECEIVED",badge:r.label,badgeColor:"zinc",actions:i?e.jsxs("div",{className:"data-box",children:[v.kbPerHour," KB/hr"]}):e.jsx("div",{className:"data-box opacity-0",children:"0 KB/hr"})}),e.jsxs("div",{className:"flex flex-wrap gap-4 sm:gap-8",children:[e.jsxs("div",{className:"flex items-end gap-2",children:[e.jsx("div",{className:"type-data-xl text-fg-primary",children:i?e.jsx(V,{value:y.received,className:"font-mono tabular-nums",priority:"high"}):e.jsx("span",{className:"opacity-30",children:"—"})}),e.jsx(U,{color:"zinc",className:"mb-0.5 sm:mb-1",children:"Total Rx"})]}),e.jsxs("div",{className:"flex items-end gap-2",children:[e.jsx("div",{className:"type-data-xl text-fg-primary",children:i?e.jsx(V,{value:y.uniqueReceived,className:"font-mono tabular-nums",priority:"high"}):e.jsx("span",{className:"opacity-30",children:"—"})}),e.jsx(U,{color:"zinc",className:"mb-0.5 sm:mb-1",children:"Unique"})]})]}),e.jsxs("div",{className:"mt-2 flex-1 min-h-0 relative",children:[e.jsx("div",{className:`absolute inset-0 flex items-end gap-1 transition-opacity duration-300 ${i?"opacity-0 pointer-events-none":"opacity-100"}`,"aria-hidden":i,children:[45,72,33,58,80,42,65,28,55,75,38,62].map((N,w)=>e.jsx("div",{className:"flex-1 bg-subtle-fill rounded-sm animate-pulse",style:{height:`${N}%`}},w))}),e.jsx("div",{className:`h-full transition-opacity duration-300 ${i?"opacity-100":"opacity-0"}`,children:e.jsx(Ls,{packets:n,rangeMinutes:r.minutes,bucketCount:r.buckets})})]})]})}),e.jsxs(ie,{template:"compact",children:[e.jsx(re,{span:6,lg:4,children:e.jsx(Es,{value:y.forwarded,receivedCount:y.received,packets:n,rangeMinutes:r.minutes,bucketCount:r.buckets,timeRangeLabel:r.label,icon:e.jsx(ms,{className:"w-4 h-4"}),isLoaded:i})}),e.jsx(re,{span:6,lg:4,children:e.jsx(Is,{value:y.dropped,receivedCount:y.received,packets:n,rangeMinutes:r.minutes,bucketCount:r.buckets,timeRangeLabel:r.label,icon:e.jsx(Zt,{className:"w-4 h-4"}),isLoaded:i})}),e.jsx(re,{span:12,lg:4,children:e.jsx(Xs,{stats:t,localHash:t==null?void 0:t.local_hash,receivedBuckets:h==null?void 0:h.received,droppedBuckets:h==null?void 0:h.dropped,forwardedBuckets:h==null?void 0:h.forwarded,bucketDurationSeconds:h==null?void 0:h.bucket_duration_seconds,timeRangeLabel:r.label,isLoaded:i})})]}),e.jsx(Sn,{isLoaded:i}),e.jsx(Ks,{}),t&&e.jsx(ie,{template:"auto",children:e.jsx(as,{nodeName:k,repeaterVersion:t.version,coreVersion:t.core_version,localHash:t.local_hash,publicKey:t.public_key})})]})]})}export{pa as default}; diff --git a/frontend/dist/assets/Dashboard-VS1_KFKN.js b/frontend/dist/assets/Dashboard-VS1_KFKN.js new file mode 100644 index 00000000..409ef2e7 --- /dev/null +++ b/frontend/dist/assets/Dashboard-VS1_KFKN.js @@ -0,0 +1,55 @@ +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-DhkG1Nx9.js","assets/index-DySMpv2s.css"])))=>i.map(i=>d[i]); +import{d as L,e as dt,_ as we,f as mt,r as h,j as e,A as Ee,m as ee,S as ut,M as xt,U as ft,h as ht,k as pt,n as gt,o as yt,p as bt,q as H,t as pe,v as V,w as jt,x as Nt,y as ke,z as vt,L as te,D as se,E as wt,F as kt,G as ne,H as $e,T as Ct,J as Tt,B as Ce,R as He,K as Ie,N as Mt,O as X,P as F,Q as _t,V as St,W as Bt,X as Dt,Y as Rt,$ as Pt,a0 as ie,u as ge,a1 as At,a2 as Te,a3 as re,a4 as K,a5 as Oe,a6 as Ft,a7 as J,a8 as Lt,a9 as Et,aa as $t,ab as Me,ac as Ht,c as A,ad as It,ae as We,af as _e,ag as Ot,ah as Wt,ai as zt,aj as qt,ak as Ut,al as Vt}from"./index-DhkG1Nx9.js";import{r as Se,g as ze,A as G,E as Gt}from"./AnimatedNumber-VoU6jLG5.js";import{C as Be,P as Xt,a as Yt,B as Kt}from"./PageLayout-BkUTZXJb.js";import{u as O,r as W,h as Jt,a as Zt,b as Qt,i as es}from"./consumer-registry-CTQIn0m9.js";import{c as ts}from"./node-types-CgBRFpS8.js";import{b as qe,c as U,a as ss,d as ns,F as Z}from"./meshcore-tx-constants-DgpFTAmf.js";import{S as as,u as xe,P as os,T as is,C as Ue,a as rs}from"./PacketList-Dd7PQV7H.js";import{useGetDecodedContent as ls,useResolveSource as cs}from"./usePipelineStore-B9ir1Xwp.js";import{A as De}from"./SignalIndicator-DEXVYOhU.js";import{T as Ve}from"./TimeRangeStepper-RSPVaByt.js";import{L as ye}from"./LightSparkline-Bg_XrgTS.js";import{c as ds}from"./link-scoring-Ctdu509L.js";import{Z as ms,H as us}from"./useMapViewStore-BMqcaUNl.js";import{N as xs}from"./NodeInformationCard-Byom2o5k.js";import{g as fs,e as le,a as hs,f as ps}from"./chat-utils-DA-kxQ-o.js";import{M as Ge,C as gs}from"./ChatBubble-BP7NjdbB.js";import{C as Re}from"./chevron-right-na13OQfy.js";import{H as ys}from"./hash-KLxvul5e.js";import{R as ce,C as de}from"./Grid-DknC4rR5.js";import"./index-Bx_G2nLG.js";import"./primitives-nqGDyTiB.js";import"./payload-decoders-DC2sHkKr.js";import"./badge-colors-BNUqIXCA.js";import"./arrow-up-Bg1A345J.js";import"./map-pin-BHGohRD7.js";import"./circle-question-mark--xh93QHC.js";import"./triangle-alert-D8NErBXC.js";import"./DataBox-BMesbbaF.js";import"./layers-BxF7oyms.js";import"./activity-BG24yKp1.js";import"./circle-check-DJNUSJlu.js";import"./database-DE8k8U0g.js";import"./shield-XXZtlreW.js";/** + * @license lucide-react v0.559.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const bs=[["path",{d:"M7 7h10v10",key:"1tivn9"}],["path",{d:"M7 17 17 7",key:"1vkiza"}]],js=L("arrow-up-right",bs);/** + * @license lucide-react v0.559.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Ns=[["path",{d:"M2 13a2 2 0 0 0 2-2V7a2 2 0 0 1 4 0v13a2 2 0 0 0 4 0V4a2 2 0 0 1 4 0v13a2 2 0 0 0 4 0v-4a2 2 0 0 1 2-2",key:"57tc96"}]],vs=L("audio-waveform",Ns);/** + * @license lucide-react v0.559.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const ws=[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M18 17V9",key:"2bz60n"}],["path",{d:"M13 17V5",key:"1frdt8"}],["path",{d:"M8 17v-3",key:"17ska0"}]],ks=L("chart-column",ws);/** + * @license lucide-react v0.559.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Cs=[["path",{d:"M6 8.5a6.5 6.5 0 1 1 13 0c0 6-6 6-6 10a3.5 3.5 0 1 1-7 0",key:"1dfaln"}],["path",{d:"M15 8.5a2.5 2.5 0 0 0-5 0v1a2 2 0 1 1 0 4",key:"1qnva7"}]],Ts=L("ear",Cs);/** + * @license lucide-react v0.559.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Ms=[["path",{d:"M11 6a13 13 0 0 0 8.4-2.8A1 1 0 0 1 21 4v12a1 1 0 0 1-1.6.8A13 13 0 0 0 11 14H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2z",key:"q8bfy3"}],["path",{d:"M6 14a12 12 0 0 0 2.4 7.2 2 2 0 0 0 3.2-2.4A8 8 0 0 1 10 14",key:"1853fq"}],["path",{d:"M8 6v8",key:"15ugcq"}]],_s=L("megaphone",Ms);/** + * @license lucide-react v0.559.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Ss=[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}]],Bs=L("message-square",Ss);/** + * @license lucide-react v0.559.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Ds=[["path",{d:"M18 11h-4a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1h4",key:"17ldeb"}],["path",{d:"M6 7v13a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V7",key:"nc37y6"}],["rect",{width:"16",height:"5",x:"4",y:"2",rx:"1",key:"3jeezo"}]],Rs=L("pill-bottle",Ds);/** + * @license lucide-react v0.559.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Ps=[["path",{d:"M4 10a7.31 7.31 0 0 0 10 10Z",key:"1fzpp3"}],["path",{d:"m9 15 3-3",key:"88sc13"}],["path",{d:"M17 13a6 6 0 0 0-6-6",key:"15cc6u"}],["path",{d:"M21 13A10 10 0 0 0 11 3",key:"11nf8s"}]],As=L("satellite-dish",Ps);/** + * @license lucide-react v0.559.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Fs=[["circle",{cx:"7",cy:"7",r:"5",key:"x29byf"}],["circle",{cx:"17",cy:"17",r:"5",key:"1op1d2"}],["path",{d:"M12 17h10",key:"ls21zv"}],["path",{d:"m3.46 10.54 7.08-7.08",key:"1rehiu"}]],Ls=L("tablets",Fs);/** + * @license lucide-react v0.559.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Es=[["line",{x1:"10",x2:"14",y1:"2",y2:"2",key:"14vaq8"}],["line",{x1:"12",x2:"15",y1:"14",y2:"11",key:"17fdiu"}],["circle",{cx:"12",cy:"14",r:"8",key:"1e1u0o"}]],$s=L("timer",Es),I=dt(()=>({result:null,isComputing:!1})),Hs=500,Is=300;let z=null,Q=null;function Os(t){var a;const n=(a=t==null?void 0:t.config)==null?void 0:a.radio;return`${(n==null?void 0:n.spreading_factor)??7}:${(n==null?void 0:n.bandwidth)??125e3}:${(n==null?void 0:n.coding_rate)??5}:${(n==null?void 0:n.preamble_length)??8}`}function Ws(){if(z)return z;if(typeof window>"u")return null;try{z=new Worker(new URL("/assets/dashboard-bucketing.worker-RVncOvX0.js",import.meta.url),{type:"module"}),z.onmessage=t=>{if(t.data.type==="error"){console.error("[DashboardBucketing] Worker error:",t.data.error),I.setState({isComputing:!1});return}I.setState({result:t.data.payload,isComputing:!1})},z.onerror=t=>{console.error("[DashboardBucketing] Worker error:",t),I.setState({isComputing:!1})}}catch(t){console.error("[DashboardBucketing] Failed to init worker:",t)}return z}function zs(t,n,a,s){const o=Ws();if(!o)return;const i=t.length,c=new Float64Array(i),l=new Float64Array(i),d=new Uint16Array(i),m=new Uint8Array(i),u=new Uint8Array(i),x=new Uint8Array(i),r=new Uint8Array(i),y=new Float32Array(i),b=new Float32Array(i),p=new Uint32Array(i),w=new Map;let k=0;for(let j=0;jparseInt(n,10)).filter(n=>t[n]>0).sort((n,a)=>t[a]-t[n])}function qs(t,n,a){const s={...t,received:[...t.received],unique_received:[...t.unique_received],transmitted:[...t.transmitted],forwarded:[...t.forwarded],dropped:[...t.dropped],receivedBytesBuckets:t.receivedBytesBuckets.map(u=>({...u,bytesByType:{...u.bytesByType}})),forwardedBytesBuckets:t.forwardedBytesBuckets.map(u=>({...u,bytesByType:{...u.bytesByType}})),droppedBytesBuckets:t.droppedBytesBuckets.map(u=>({...u,bytesByType:{...u.bytesByType}})),receivedTotalByType:{...t.receivedTotalByType},forwardedTotalByType:{...t.forwardedTotalByType},droppedTotalByType:{...t.droppedTotalByType}},{start_time:o,end_time:i,bucket_duration_seconds:c,bucket_count:l}=t,d=new Set;for(const u of n){const x=u.timestamp??0;if(xi)continue;const r=Math.floor((x-o)/c);if(r<0||r>=l)continue;d.has(r)||(d.add(r),s.received[r]={...s.received[r]},s.unique_received[r]={...s.unique_received[r]},s.transmitted[r]={...s.transmitted[r]},s.forwarded[r]={...s.forwarded[r]},s.dropped[r]={...s.dropped[r]});const y=ze(u,a),b=u.length??u.payload_length??0,p=u.type??u.payload_type??0,w=u.packet_origin;w==="tx_local"?(s.transmitted[r].count++,s.transmitted[r].airtime_ms+=y):w==="tx_forward"||u.transmitted?(s.forwarded[r].count++,s.forwarded[r].airtime_ms+=y,s.forwardedBytesBuckets[r].bytesByType[p]=(s.forwardedBytesBuckets[r].bytesByType[p]??0)+b,s.forwardedBytesBuckets[r].totalBytes+=b,s.forwardedTotalByType[p]=(s.forwardedTotalByType[p]??0)+b,s.totalForwardedCount++):u.drop_reason&&(s.dropped[r].count++,s.dropped[r].airtime_ms+=y,s.droppedBytesBuckets[r].bytesByType[p]=(s.droppedBytesBuckets[r].bytesByType[p]??0)+b,s.droppedBytesBuckets[r].totalBytes+=b,s.droppedTotalByType[p]=(s.droppedTotalByType[p]??0)+b,s.totalDroppedCount++),w!=="tx_local"&&(s.received[r].count++,s.received[r].airtime_ms+=y,s.unique_received[r].count++,s.unique_received[r].airtime_ms+=y,s.receivedBytesBuckets[r].bytesByType[p]=(s.receivedBytesBuckets[r].bytesByType[p]??0)+b,s.receivedBytesBuckets[r].totalBytes+=b,s.receivedTotalByType[p]=(s.receivedTotalByType[p]??0)+b,s.totalReceivedBytes+=b)}const m=s.time_range_minutes/60;return s.kbPerHour=m>0?Math.round(s.totalReceivedBytes/1024/m):0,s.forwardedRatePerHour=m>0?Math.round(s.totalForwardedCount/m):0,s.droppedRatePerHour=m>0?Math.round(s.totalDroppedCount/m):0,s.receivedActiveTypes=me(s.receivedTotalByType),s.forwardedActiveTypes=me(s.forwardedTotalByType),s.droppedActiveTypes=me(s.droppedTotalByType),s}typeof window<"u"&&Promise.all([we(()=>import("./index-DhkG1Nx9.js").then(t=>t.g1),__vite__mapDeps([0,1])),we(()=>import("./index-DhkG1Nx9.js").then(t=>t.g0),__vite__mapDeps([0,1]))]).then(([t,n])=>{const{DASHBOARD_TIME_RANGES:a}=n;let s=0,o=-1,i="";t.useStore.subscribe(c=>{const l=c.packets.length,d=c.globalTimeRangeIndex,m=Os(c.stats);if(l===s&&d===o&&m===i)return;const u=s,x=o,r=i;if(s=l,o=d,i=m,l===0)return;const y=a[d]??a[4],b=y.minutes,p=y.buckets,w=c.stats,k=Se(w),T=l-u,j=d!==x,N=m!==r,v=I.getState().result;if(!j&&!N&&T>0&&T{Q=null;const f=t.useStore.getState();if(f.packets.length===0||!f.stats)return;const C=a[f.globalTimeRangeIndex]??a[4],M=Se(f.stats);zs(f.packets,C.minutes,C.buckets,M)},Is)})});const Us=()=>I(t=>t.result),Xe=[{target:"ReceivedChart",fn:"type",minStage:1},{target:"ReceivedChart",fn:"airtime",minStage:1,when:Jt}];W(Xe);function Vs(t){const a=new Date(t*1e3).getHours();return a>=6&&a<18}function Gs(t){return new Date(t*1e3).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!1})}function Xs({buckets:t,activeTypes:n,totalByType:a}){O(Xe);const s=mt(),[o,i]=h.useState(null),[c,l]=h.useState(null),[d,m]=h.useState(null),u=h.useCallback((w,k,T)=>{i(k),l(T)},[]),x=t.length>0&&n.length>0,r=o?Vs(o.start):null,y=o?Gs(o.start):"",b=d!==null&&r!==null&&d!==r;r!==d&&m(r);const p=48;return e.jsxs("div",{className:"flex flex-col h-full relative",children:[e.jsx("div",{className:"h-5 relative mb-1 shrink-0",children:o&&c!==null&&e.jsxs("div",{className:"absolute flex items-center gap-1.5 type-data-sm -translate-x-1/2",style:{left:`calc(${p}px + ${c*100}% * (1 - ${p}px / 100%))`},children:[e.jsx(Ee,{mode:"wait",children:e.jsx(ee.span,{initial:b?{opacity:0,scale:.5,rotate:-90}:!1,animate:{opacity:1,scale:1,rotate:0},exit:{opacity:0,scale:.5,rotate:90},transition:{duration:.25,ease:"easeOut"},children:r?e.jsx(ut,{className:"w-4 h-4 text-sys-amber"}):e.jsx(xt,{className:"w-4 h-4 text-sys-blue"})},r?"sun":"moon")}),e.jsx("span",{className:"text-fg-secondary",children:y})]})}),e.jsx("div",{className:"flex-1 min-h-0",children:x&&e.jsx(ft,{buckets:t,activeTypes:n,gridColor:s.grid,axisTickColor:s.axisTick,onHover:u})}),e.jsx("div",{className:"pt-2 px-1 pb-2 shrink-0",children:x&&e.jsx(ht,{activeTypes:n,totalByType:a})})]})}function Ys(t,n,a){var i,c;if(t.length<=a)return t;const s=t.length/a,o=[];for(let l=0;l0&&(x.bytesByType[y]=(x.bytesByType[y]??0)+b)}}o.push(x)}return o}function Ks(t,n,a,s,o,i,c){if(n.length===0)return;const l=Ys(n,a,yt.statsCard),d=l.length,m=i/d,u=l.map(r=>r.totalBytes),x=Math.max(...u);if(x!==0){for(let r=0;r{const c=t.map(d=>d.start),l=t.map(()=>1);return[c,l]},[t]);return h.useEffect(()=>{if(!a.current||t.length===0)return;const c=a.current;let l=null,d=null;const m=pt(()=>{const u=c.getBoundingClientRect(),x=Math.floor(u.width)||200,r=Math.floor(u.height)||60,y={width:x,height:r,padding:[0,0,0,0],cursor:{show:!1},scales:{x:{time:!1},y:{range:[0,1]}},axes:[{show:!1},{show:!1}],series:[{},{show:!1}],legend:{show:!1},hooks:{draw:[b=>{const p=b.ctx,{left:w,top:k,width:T,height:j}=b.bbox;Ks(p,s.current,o.current,w,k,T,j)}]}};l=new gt(y,i,c),d=new ResizeObserver(()=>{const b=c.getBoundingClientRect();b.width>0&&b.height>0&&(l==null||l.setSize({width:Math.floor(b.width),height:Math.floor(b.height)}))}),d.observe(c)});return()=>{m(),d==null||d.disconnect(),l==null||l.destroy()}},[i,t.length]),t.length===0?e.jsx("div",{className:"h-full flex items-center justify-center",children:e.jsx("div",{className:"w-full h-0.5 rounded-full bg-fg-muted/15"})}):e.jsx("div",{ref:a,className:"w-full h-full"})}const Ye=h.memo(Js),Ke=[{target:"ForwardedCard",fn:"type",minStage:1}];W(Ke);function Zs({value:t,receivedCount:n,buckets:a,activeTypes:s,ratePerHour:o,timeRangeLabel:i,icon:c,isLoaded:l=!0}){O(Ke);const d=n>0?(t/n*100).toFixed(1):null;return l?e.jsxs(H,{children:[e.jsxs("div",{className:"flex items-center gap-1.5 sm:gap-2 mb-2 sm:mb-3",children:[c&&e.jsx("span",{className:"icon-sm text-icon-card-title",children:c}),e.jsx("span",{className:"type-micro",children:"FORWARDED"}),i&&e.jsx(V,{color:"zinc",className:"hidden sm:inline-flex",children:i})]}),e.jsx("div",{className:"type-data-xl text-fg-primary",children:e.jsx(G,{value:t,className:"font-mono tabular-nums",priority:"high"})}),e.jsx("div",{className:"flex-1 mt-1 overflow-hidden min-h-[40px] sm:min-h-[60px]",children:s.length>0?e.jsx(Ye,{buckets:a,activeTypes:s}):e.jsx("div",{className:"w-full h-full flex items-center justify-center",children:e.jsx("div",{className:"w-full h-0.5 rounded-full bg-fg-muted/15"})})}),e.jsx("div",{className:"pt-1.5 sm:pt-2 mt-1",children:e.jsxs("div",{className:"flex gap-2 sm:gap-3",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"data-box-label",children:"Rate"}),e.jsxs("div",{className:"data-box data-box-fill data-box-left",children:[o,"/hr"]})]}),d!==null&&e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"data-box-label",children:"Ratio"}),e.jsxs("div",{className:"data-box data-box-fill data-box-left",children:[d,"%"]})]})]})})]}):e.jsx(H,{children:e.jsx(pe,{})})}const Je=[{target:"DroppedCard",fn:"type",minStage:1}];W(Je);function Qs({value:t,receivedCount:n,buckets:a,activeTypes:s,ratePerHour:o,timeRangeLabel:i,icon:c,isLoaded:l=!0}){O(Je);const d=n>0?(t/n*100).toFixed(1):null;return l?e.jsxs(H,{children:[e.jsxs("div",{className:"flex items-center gap-1.5 sm:gap-2 mb-2 sm:mb-3",children:[c&&e.jsx("span",{className:"icon-sm text-icon-card-title",children:c}),e.jsx("span",{className:"type-micro",children:"DROPPED"}),i&&e.jsx(V,{color:"zinc",className:"hidden sm:inline-flex",children:i})]}),e.jsx("div",{className:"type-data-xl text-fg-primary",children:e.jsx(G,{value:t,className:"font-mono tabular-nums",priority:"high"})}),e.jsx("div",{className:"flex-1 mt-1 overflow-hidden min-h-[40px] sm:min-h-[60px]",children:s.length>0?e.jsx(Ye,{buckets:a,activeTypes:s}):e.jsx("div",{className:"w-full h-full flex items-center justify-center",children:e.jsx("div",{className:"w-full h-0.5 rounded-full bg-fg-muted/15"})})}),e.jsx("div",{className:"pt-1.5 sm:pt-2 mt-1",children:e.jsxs("div",{className:"flex gap-2 sm:gap-3",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"data-box-label",children:"Rate"}),e.jsxs("div",{className:"data-box data-box-fill data-box-left",children:[o,"/hr"]})]}),d!==null&&e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"data-box-label",children:"Drop %"}),e.jsxs("div",{className:"data-box data-box-fill data-box-left",children:[d,"%"]})]})]})})]}):e.jsx(H,{children:e.jsx(pe,{})})}const en={",":"punc",".":"punc-period",":":"punc-colon","/":"punc-slash"},fe=/([,\.:\/])/g;function tn(t){return t.split(fe).map((a,s)=>{const o=en[a];return o?e.jsx("span",{className:o,children:a},s):a})}const E=h.memo(function({children:n,className:a="",as:s="span"}){const o=h.useMemo(()=>{let i;return typeof n=="number"?i=n.toLocaleString():Array.isArray(n)?i=n.join(""):i=String(n??""),fe.test(i)?(fe.lastIndex=0,tn(i)):i},[n]);return e.jsx(s,{className:`data-tight ${a}`.trim(),children:o})}),sn=2,nn=1;function an(t,n,a){const s=d=>(d==null?void 0:d.reduce((m,u)=>m+u.count,0))??0,o=s(n),i=s(a),c=o||(t==null?void 0:t.rx_count)||1,l=i||(t==null?void 0:t.dropped_count)||0;return c>0?l/(c+l)*100:0}function on(t,n,a){const s=o=>(o==null?void 0:o.reduce((i,c)=>i+c.count,0))??0;if(n!=null&&n.length&&a){const i=s(n)*100,c=n.length*a*1e3;return i/c*100}if(t){const o=(t.uptime_seconds||1)*1e3;return(t.total_airtime_ms||t.airtime_used_ms||0)/o*100}return 0}function Pe(t,n,a){return ss(Math.max(n,Math.min(a,t)))}function rn(t,n,a,s,o){let i=qe(t);n>20?i+=Z*2:n>12&&(i+=Z),a>8&&(i+=Z);const c=Pe(i,0,sn);let l=ns(t);a>8&&(l+=Z);const d=Pe(l,0,nn),m=U(c),u=U(d),x=s!==null?U(s):null;let r="stable";return x!==null&&(m>x?r="increase":m{if(m!=="applying"){u("applying");try{const oe=await Nt({tx_delay_factor:P,direct_tx_delay_factor:$});oe!=null&&oe.success?(u("success"),setTimeout(()=>u("idle"),2e3)):(u("error"),setTimeout(()=>u("idle"),2500))}catch{u("error"),setTimeout(()=>u("idle"),2500)}}},[m]);if(!c)return e.jsx(H,{children:e.jsx(pe,{})});const y=10080*60,p=Math.floor(Date.now()/1e3)-y,w=Object.values((t==null?void 0:t.neighbors)??{}).filter(P=>P.zero_hop&&P.last_seen>=p&&ts(P).isRepeater).length,k=x.filter(P=>P.status==="active"||P.lastSeen>=p).length,T=Math.max(w,k),j=an(t,n,a),N=on(t,s,o),v=((je=(be=t==null?void 0:t.config)==null?void 0:be.delays)==null?void 0:je.tx_delay_factor)??null,D=((ve=(Ne=t==null?void 0:t.config)==null?void 0:Ne.delays)==null?void 0:ve.direct_tx_delay_factor)??null,f=rn(T,j,N,v),C=T!==1,M=qe(T),S=[`${T} repeater${C?"s":""} heard in the last 7 days (base ×${M.toFixed(1)}).`];f.floodFactor===M&&j<=12&&N<=8?S.push("No modifiers applied — network looks healthy."):(j>20?S.push(`High duplicate rate (${j.toFixed(1)}%) suggests frequent collisions — window widened.`):j>12&&S.push(`Elevated duplicate rate (${j.toFixed(1)}%) — window widened one step.`),N>8&&S.push(`Channel is busy (${N.toFixed(1)}% TX util) — extra spacing added.`));const g=[`Direct uses one forwarder — ×${f.directFactor.toFixed(1)} backoff for channel contention.`];N>8&&g.push("Busy channel — small extra backoff.");const _=[`Flood ×${f.floodFactor.toFixed(1)} (${f.floodSlots} slot${f.floodSlots!==1?"s":""})`,...S,"",`Direct ×${f.directFactor.toFixed(1)}`,...g,"","Click to copy CLI commands"].join(` +`),B=v!==null?U(v):null,R=D!==null?U(D):null,ae=B!==null&&f.floodSlots!==B,it=R!==null&&f.directSlots!==R,rt=ae||it,lt=async()=>{const P=`set txdelay ${f.floodFactor.toFixed(1)} +set direct.txdelay ${f.directFactor.toFixed(1)}`;try{await navigator.clipboard.writeText(P),d(!0),setTimeout(()=>d(!1),1500)}catch{const $=document.createElement("textarea");$.value=P,$.style.position="fixed",$.style.opacity="0",document.body.appendChild($),$.select();try{document.execCommand("copy"),d(!0),setTimeout(()=>d(!1),1500)}catch{console.error("Failed to copy commands")}document.body.removeChild($)}},ct=()=>r(f.floodFactor,f.directFactor);return e.jsxs(H,{children:[e.jsxs("div",{className:"flex items-center gap-1.5 sm:gap-2 mb-2 sm:mb-3 flex-wrap",children:[e.jsx(as,{className:"w-4 h-4 text-icon-card-title flex-shrink-0"}),e.jsx("span",{className:"type-micro",children:"DELAY DOCTOR"}),i&&e.jsx(V,{color:"zinc",className:"hidden sm:inline-flex",children:i})]}),e.jsxs("button",{onClick:lt,className:"flex gap-3 mb-2 sm:mb-3 w-full text-left hover:bg-subtle-fill radius-inner transition-base p-1 -m-1 group",title:_,children:[e.jsxs("div",{className:"flex-1 flex flex-col",children:[e.jsx("span",{className:"type-data-xl text-fg-primary",children:e.jsxs(E,{children:["×",f.floodFactor.toFixed(1)]})}),e.jsx("span",{className:"type-micro text-fg-muted mt-0.5 sm:mt-1",children:"Flood"})]}),e.jsxs("div",{className:"flex-1 flex flex-col",children:[e.jsx("span",{className:"type-data-xl text-sys-blue",children:e.jsxs(E,{children:["×",f.directFactor.toFixed(1)]})}),e.jsx("span",{className:"type-micro text-fg-muted mt-0.5 sm:mt-1",children:"Direct"})]}),e.jsx("div",{className:"flex items-center self-center opacity-0 group-hover:opacity-100 transition-opacity",children:l?e.jsx(ke,{className:"w-4 h-4 text-sys-green"}):e.jsx(vt,{className:"w-4 h-4 text-fg-muted"})})]}),e.jsx("div",{className:"flex-1 py-2",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"data-box-label",children:"Dupe"}),e.jsxs("div",{className:`data-box data-box-fill data-box-left ${f.duplicateRate>8?"text-status-warning":""}`,children:[f.duplicateRate.toFixed(1),"%"]})]}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"data-box-label",children:"TX Util"}),e.jsxs("div",{className:"data-box data-box-fill data-box-left",children:[f.txUtilization.toFixed(2),"%"]})]})]})}),e.jsx("div",{className:"pt-2 mt-auto",children:e.jsxs("div",{className:"flex items-end justify-between gap-2",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"data-box-label",children:"Current"}),e.jsx("div",{className:"flex gap-2",children:v!==null?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"data-box",children:["×",v.toFixed(2)]}),e.jsxs("div",{className:"data-box",style:{color:"var(--sys-blue)"},children:["×",(D==null?void 0:D.toFixed(2))??"—"]})]}):e.jsx("span",{className:"text-sm text-fg-muted",children:"No config"})})]}),rt&&e.jsxs("button",{onClick:ct,disabled:m==="applying"||m==="success",className:`flex items-center gap-1.5 px-2.5 py-1.5 radius-inner type-micro font-medium transition-base + ${m==="success"?"bg-sys-green/15 text-sys-green":m==="error"?"bg-sys-red/15 text-sys-red":m==="applying"?"bg-subtle-fill text-fg-muted":"bg-sys-blue/10 text-sys-blue hover:bg-sys-blue/20"}`,title:`Apply ×${f.floodFactor.toFixed(1)} flood, ×${f.directFactor.toFixed(1)} direct`,children:[m==="success"?"Rx'd":m==="error"?"Failed":"Apply",m==="applying"?e.jsx(te,{className:"w-3.5 h-3.5 animate-spin"}):m==="success"?e.jsx(ke,{className:"w-3.5 h-3.5"}):e.jsxs("span",{className:"relative inline-flex items-end w-6 h-3.5",children:[e.jsx(Rs,{className:"w-3.5 h-3.5 absolute left-0 bottom-0"}),e.jsx(Ls,{className:"w-3 h-3 absolute right-0 bottom-0"})]})]})]})})]})}const Ze=[{target:"RecentPackets",fn:"rssi",minStage:1},{target:"RecentPackets",fn:"snr",minStage:1}];W(Ze);const cn=25;function dn(){O(Ze);const t=se(),n=wt(),a=kt(),s=ne(),o=ls(),i=xe(y=>y.requestChannel),[c,l]=h.useState(!0),d=h.useCallback(y=>l(y),[]),m=h.useMemo(()=>[...t.length<=100?t:t.slice(-100)].sort((b,p)=>(p.timestamp??0)-(b.timestamp??0)),[t]),u=s==null?void 0:s.local_hash,x=s==null?void 0:s.neighbors,r=cs();return e.jsxs(H,{noPadding:!0,className:"!overflow-visible",children:[e.jsx($e,{listHeader:!0,icon:e.jsx(He,{}),title:"Recent Packets",actions:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Ct,{enabled:c,onChange:d,label:"Hide Dupes",size:"sm"}),a&&e.jsx(Tt,{showLabel:!0}),e.jsxs(Ce,{color:"primary",outline:!0,href:"/packets",children:["View all",e.jsx(De,{"data-slot":"icon"})]})]})}),e.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto px-1",children:e.jsx(os,{packets:m,allPackets:t,localHash:u,neighbors:x,resolveSource:r,getDecodedContent:o,onChannelClick:i,loading:n,maxPackets:cn,showPagination:!1,flashNewest:!0,hideDupes:c,emptyMessage:"No packets received",footerAction:e.jsxs(Ce,{color:"primary",outline:!0,href:"/packets",children:["View all",e.jsx(De,{"data-slot":"icon"})]})})})]})}const mn={stable:"M5 12h14",up:"M5 15l7-7 7 7",down:"M19 9l-7 7-7-7"};function un({trend:t}){return e.jsx("span",{className:`mini-widget-trend ${t}`,children:e.jsx("svg",{className:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:mn[t]})})})}function xn(){return e.jsx("div",{className:"mini-widget-loading",children:e.jsx("div",{className:"mini-widget-loading-spinner"})})}function fn({message:t}){return e.jsx("div",{className:"mini-widget-error",children:e.jsx("span",{title:t,children:"No data"})})}function q({title:t,icon:n,value:a,unit:s,valueSize:o="md",status:i,subtitle:c,trend:l,children:d,isLoading:m=!1,error:u,className:x="",onClick:r}){const y=["mini-widget-value",o==="lg"&&"mini-widget-value-lg",o==="sm"&&"mini-widget-value-sm"].filter(Boolean).join(" "),b=["mini-widget",x].filter(Boolean).join(" ");return e.jsxs(H,{noPadding:!0,className:b,onClick:r,children:[e.jsxs("div",{className:"mini-widget-header",children:[n,e.jsx("span",{className:"mini-widget-title",children:t}),i&&i!=="unknown"&&e.jsx("div",{className:`mini-widget-status-dot ${i}`}),l&&e.jsx(un,{trend:l})]}),m?e.jsx(xn,{}):u?e.jsx(fn,{message:u}):e.jsxs(e.Fragment,{children:[a!==void 0&&e.jsxs("div",{className:y,children:[typeof a=="number"?e.jsx(G,{value:a,className:"font-mono tabular-nums",priority:"medium",format:Number.isInteger(a)?void 0:{minimumFractionDigits:1,maximumFractionDigits:1}}):e.jsx(E,{children:a}),s&&e.jsx("span",{className:"mini-widget-unit",children:s})]}),c&&e.jsx("div",{className:"mini-widget-subtitle",children:c}),d]})]})}const hn={DELTA_CRITICAL:10,SLOPE_CRITICAL:4,JITTER_CRITICAL:6,DELTA_WARNING:5,SLOPE_WARNING:2,JITTER_WARNING:4},Qe={baselineMedian:null,baselineP10:null,baselineP90:null,currentMedian:null,currentSampleCount:0,delta:0,slope:0,jitter:0,penalty:0,penaltyReason:null,computedAt:0,isReliable:!1};function he(t,n){if(t.length===0)return null;const a=[...t].sort((c,l)=>c-l),s=n/100*(a.length-1),o=Math.floor(s),i=Math.ceil(s);return o===i?a[o]:a[o]+(a[i]-a[o])*(s-o)}function Ae(t){return he(t,50)}function pn(t){if(t.length<2)return 0;const n=t.reduce((o,i)=>o+i,0)/t.length,s=t.map(o=>Math.pow(o-n,2)).reduce((o,i)=>o+i,0)/t.length;return Math.sqrt(s)}function gn(t){if(t.length<2)return 0;const n=t.length;let a=0,s=0,o=0,i=0;const c=t[0].timestamp;for(const d of t){const m=(d.timestamp-c)/3600,u=d.value;a+=m,s+=u,o+=m*u,i+=m*m}const l=n*i-a*a;return Math.abs(l)<1e-4?0:(n*o-a*s)/l}function yn(t,n,a){const s=hn;return t>=s.DELTA_CRITICAL?[2,`Noise floor ${t.toFixed(1)} dB above baseline`]:n>=s.SLOPE_CRITICAL?[2,`Noise floor rising ${n.toFixed(1)} dB/hour`]:a>=s.JITTER_CRITICAL?[2,`Noise floor unstable (±${a.toFixed(1)} dB)`]:t>=s.DELTA_WARNING?[1,`Noise floor ${t.toFixed(1)} dB above baseline`]:n>=s.SLOPE_WARNING?[1,`Noise floor rising ${n.toFixed(1)} dB/hour`]:a>=s.JITTER_WARNING?[1,`Noise floor variable (±${a.toFixed(1)} dB)`]:[0,null]}function bn(t){if(t.length===0)return{...Qe,computedAt:Math.floor(Date.now()/1e3)};const n=Math.floor(Date.now()/1e3),a=t.filter(w=>Number.isFinite(w)),s=t.length>0?[t[t.length-1]]:[],o=t.slice(-4).filter(w=>Number.isFinite(w)),i=Ae(a),c=he(a,10),l=he(a,90),d=Ae(s),m=d!==null&&c!==null?d-c:0,u=o.map((w,k)=>({timestamp:n-(o.length-1-k)*3600,value:w})),x=gn(u),r=pn(o),y=a.length>=12,[b,p]=y?yn(m,x,r):[0,null];return{baselineMedian:i,baselineP10:c,baselineP90:l,currentMedian:d,currentSampleCount:s.length,delta:m,slope:x,jitter:r,penalty:b,penaltyReason:p,computedAt:n,isReliable:y}}const jn={lbtStats:null,noiseFloor:null,sparklineNoiseFloor:[],noiseFloorWindowHistory:[],linkQuality:null,channelHealth:null,nfTrend:Qe,radioConfig:null,trends:null,stats:null,recentPackets:[],quickNeighbors:[],isLoading:!0,error:null,refresh:async()=>{}},et=h.createContext(jn);function Nn({children:t}){var g;const n=ne(),a=se(),s=Ie(),o=Mt(),i=X(),c=F[i],l=Math.max(1,c.minutes/60),d=n===null,m=h.useMemo(()=>_t(a,l),[a,l]),u=(n==null?void 0:n.noise_floor_dbm)??null,x=h.useMemo(()=>St(u)?u:null,[u]),r=h.useMemo(()=>{var B;const _=(B=n==null?void 0:n.config)==null?void 0:B.radio;return _?{sf:_.spreading_factor??7,bwHz:_.bandwidth??125e3}:null},[(g=n==null?void 0:n.config)==null?void 0:g.radio]),y=Bt(l),b=Dt(l),p=n==null?void 0:n.neighbors,w=h.useMemo(()=>Object.fromEntries(Object.entries(p??{}).filter(([B])=>!o.has(B))),[p,o]),k=h.useMemo(()=>s.filter(_=>!o.has(_.hash)),[s,o]),T=h.useMemo(()=>bn(y),[y]),j=h.useMemo(()=>Rt(k,w,r),[k,w,r]),N=h.useMemo(()=>Pt(m,x,j),[m,x,j]),[v,D]=h.useState({noiseFloor:null,networkScore:null,channelHealth:null}),f=h.useRef(0);h.useEffect(()=>{const _=()=>{const R=Date.now();R-f.current>3e4&&(f.current=R,D({noiseFloor:x,networkScore:(j==null?void 0:j.networkScore)??null,channelHealth:(N==null?void 0:N.score)??null}))};_();const B=setInterval(_,5e3);return()=>clearInterval(B)},[x,j==null?void 0:j.networkScore,N==null?void 0:N.score]);const C=h.useMemo(()=>({noiseFloor:{current:x,previous:v.noiseFloor,trend:x!==null?ie(x,v.noiseFloor,2,!0):"stable"},networkScore:{current:(j==null?void 0:j.networkScore)??0,previous:v.networkScore,trend:ie((j==null?void 0:j.networkScore)??0,v.networkScore,3,!1)},channelHealth:{current:(N==null?void 0:N.score)??0,previous:v.channelHealth,trend:ie((N==null?void 0:N.score)??0,v.channelHealth,3,!1)}}),[x,j==null?void 0:j.networkScore,N==null?void 0:N.score,v]),S={lbtStats:m,noiseFloor:x,sparklineNoiseFloor:y,noiseFloorWindowHistory:b,linkQuality:j,channelHealth:N,nfTrend:T,radioConfig:r,trends:C,stats:n,recentPackets:a,quickNeighbors:s,isLoading:d,error:null,refresh:async()=>{}};return e.jsx(et.Provider,{value:S,children:t})}function Y(){const t=h.useContext(et);if(t===void 0)throw new Error("useLBTData must be used within an LBTDataProvider");return t}function vn(t){return t<100?"excellent":t<250?"good":t<500?"fair":t<1e3?"congested":"critical"}function wn(t,n){return t===0?"No backoffs":`${n.toFixed(0)}% retry rate`}function kn(){const{lbtStats:t,isLoading:n,error:a}=Y(),s=ge(),o=(t==null?void 0:t.avgBackoffMs)??0,i=(t==null?void 0:t.retryRate)??0,c=t?vn(o):"unknown",l=t==null?void 0:t.sparklineBackoff,d=h.useMemo(()=>!l||l.length<2?[]:l.map((m,u)=>({timestamp:Date.now()-(l.length-1-u)*36e5,count:m})),[l]);return e.jsx(q,{title:"LBT Backoff",icon:e.jsx($s,{className:"mini-widget-icon"}),value:Math.round(o),unit:"ms",status:c,subtitle:t?wn(o,i):void 0,isLoading:n,error:a,onClick:()=>s("/packets"),children:e.jsx("div",{className:"mini-widget-sparkline w-full",children:e.jsx(ye,{data:d,width:9999,height:24,color:"var(--sys-blue)",isLoading:n,className:"w-full"})})})}function ue(t){return t===0?"—":t<1?"<1":Math.round(t).toString()}function Cn(){const{lbtStats:t,isLoading:n,error:a}=Y(),s=ge(),o=(t==null?void 0:t.channelBusyCount)??0,i=(t==null?void 0:t.totalPacketsWithLBT)??0,c=(t==null?void 0:t.channelBusyRate)??0,l=(t==null?void 0:t.retryRate)??0,d=(t==null?void 0:t.avgBackoffMs)??0,m=(t==null?void 0:t.minBackoffMs)??0,u=(t==null?void 0:t.maxBackoffMs)??0,x=l>0?Math.max(0,(l-c)/l*100):100;return e.jsx(q,{title:"Ch. Busy",icon:e.jsx(Gt,{className:"mini-widget-icon"}),isLoading:n,error:a,onClick:()=>s("/packets"),children:e.jsx("div",{className:"flex-1 flex items-end",children:e.jsxs("div",{className:"grid grid-cols-[auto_minmax(0,1fr)] sm:grid-cols-[auto_minmax(0,1fr)_auto_minmax(0,1fr)] gap-x-2 gap-y-1 sm:gap-y-2 w-full items-baseline",children:[e.jsx("span",{className:"data-box-label mb-0 text-[10px] sm:text-sm",title:`${o} packets exceeded max CAD attempts (5) out of ${i} total transmissions.`,children:"Failed:"}),e.jsxs("div",{className:"data-box data-box-compact sm:data-box justify-self-start",title:`${o} packets exceeded max CAD attempts (5) out of ${i} total transmissions.`,children:[e.jsx(E,{children:o}),e.jsx("span",{className:"text-fg-muted punc-slash",children:"/"}),e.jsx(E,{children:i})]}),e.jsx("span",{className:"data-box-label mb-0 text-[10px] sm:text-sm",title:`${x.toFixed(1)}% of packets that needed LBT retries were sent successfully.`,children:"Sent:"}),e.jsx("div",{className:"data-box data-box-compact sm:data-box justify-self-start",title:`${x.toFixed(1)}% of packets that needed LBT retries were sent successfully.`,children:e.jsxs(E,{children:[x.toFixed(0),"%"]})}),e.jsx("span",{className:"data-box-label mb-0 text-[10px] sm:text-sm",title:`Average LBT backoff delay: ${d.toFixed(0)}ms.`,children:"Mean:"}),e.jsxs("div",{className:"data-box data-box-compact sm:data-box justify-self-start",title:`Average LBT backoff delay: ${d.toFixed(0)}ms.`,children:[e.jsx(E,{children:ue(d)}),e.jsx("span",{className:"text-fg-muted text-xs",children:"ms"})]}),e.jsx("span",{className:"data-box-label mb-0 text-[10px] sm:text-sm",title:`Backoff range: ${m.toFixed(0)}ms min, ${u.toFixed(0)}ms max.`,children:"Range:"}),e.jsxs("div",{className:"data-box data-box-compact sm:data-box justify-self-start",title:`Backoff range: ${m.toFixed(0)}ms min, ${u.toFixed(0)}ms max.`,children:[e.jsx(E,{children:ue(m)}),e.jsx("span",{className:"text-fg-muted punc-slash",children:"/"}),e.jsx(E,{children:ue(u)})]})]})})})}const Tn=.25,Fe=48;function Mn(t,n,a,s){const o=t.length;if(o===0)return[];if(o===1)return new Array(s).fill(n[0]);if(o===2){const x=new Array(s);for(let r=0;rv-D),b=Math.max(y[i-1],1e-10);let p=0,w=0,k=0,T=0,j=0;for(let v=0;v=1)continue;const f=D*D*D,C=(1-f)*(1-f)*(1-f),M=t[v]-r;p+=C,w+=C*M,k+=C*n[v],T+=C*M*M,j+=C*M*n[v]}if(p===0){m[x]=n[Math.round(x/(s-1)*(o-1))];continue}const N=p*T-w*w;m[x]=Math.abs(N)<1e-10?k/p:(T*k-w*j)/N}return m}function _n(t){return t===null||t<-110?"excellent":t<-100?"good":t<-90?"fair":t<-80?"congested":"critical"}function Sn(t){return t===null?"No reading":t<-115?"Very quiet":t<-105?"Quiet":t<-95?"Moderate":t<-85?"Elevated":"High interference"}function Bn(){const{noiseFloor:t,noiseFloorWindowHistory:n,trends:a,isLoading:s,error:o}=Y(),i=_n(t),c=a==null?void 0:a.noiseFloor.trend,l=h.useMemo(()=>{if(!n||n.length<2)return[];const m=n.map(r=>r.timestamp),u=n.map(r=>-r.noise_floor_dbm);return Mn(m,u,Tn,Fe).map((r,y)=>({timestamp:Date.now()-(Fe-1-y)*36e5,count:r}))},[n]),d=t!==null?Math.round(t):"—";return e.jsx(q,{title:"Noise Floor",icon:e.jsx(vs,{className:"mini-widget-icon"}),value:d,unit:t!==null?"dBm":void 0,status:i,trend:c,subtitle:Sn(t),isLoading:s,error:o,children:e.jsx("div",{className:"mini-widget-sparkline w-full",children:e.jsx(ye,{data:l,width:9999,height:22,color:"var(--sys-blue)",isLoading:s,className:"w-full"})})})}const tt=[{target:"LinkLeaders",fn:"path",minStage:1,when:Zt},{target:"LinkLeaders",fn:"src_hash",minStage:1,when:Qt}];W(tt);function Dn(){O(tt);const t=ge(),n=Ie(),a=se(),s=ne(),o=X(),c=F[o].minutes*60,l=At(),d=h.useMemo(()=>{if(l===0)return a;const f=l-c;return a.filter(C=>C.timestamp>=f)},[a,c,l]),m=s===null,u=s!=null&&s.local_hash?Te(s.local_hash):"",x=(s==null?void 0:s.neighbors)??{},{neighborHashes:r,neighborNames:y}=h.useMemo(()=>{const f=new Set,C=new Map;for(const M of n){f.add(M.hash);const S=x[M.hash],g=(S==null?void 0:S.name)||(S==null?void 0:S.node_name)||M.prefix;C.set(M.hash,g)}return{neighborHashes:f,neighborNames:C}},[n,x]),b=h.useMemo(()=>{if(r.size===0||d.length===0||!u)return{champion:null,listener:null,loudest:null};const{scores:f}=ds(d,r,u),C=[];for(const[_,B]of f)B.blendedScore!==0&&C.push({...B,name:y.get(_)??Te(_)});let M=null,S=null,g=null;for(const _ of C)(!M||_.blendedScore>M.blendedScore)&&(M=_),(!S||_.listenerScore>S.listenerScore)&&(S=_),(!g||_.loudScore>g.loudScore)&&(g=_);return{champion:M,listener:S,loudest:g}},[d,r,u,y]),p=f=>e.jsxs("div",{className:"max-w-[220px]",children:[e.jsxs("div",{className:"font-semibold mb-1",children:["🏆 Champion: ",f.name]}),e.jsxs("div",{className:"text-fg-muted mb-1",children:["Blended Score: ",f.blendedScore,e.jsx("span",{className:"text-fg-muted/60 ml-1",children:"(Listener + Loud)"})]}),e.jsxs("div",{className:"border-t border-edge-subtle pt-1 mt-1 space-y-0.5",children:[e.jsxs("div",{children:["Listener: ",f.listenerScore,"/100 (",f.listenerCount," shared paths)"]}),e.jsxs("div",{children:["Loud: ",f.loudScore,"/100 (",f.loudCount," packets relayed)"]})]})]}),w=f=>e.jsxs("div",{className:"max-w-[220px]",children:[e.jsxs("div",{className:"font-semibold mb-1",children:["👂 Best Listener: ",f.name]}),e.jsxs("div",{className:"text-fg-muted mb-1",children:["Score: ",f.listenerScore,"/100"]}),e.jsx("div",{className:"border-t border-edge-subtle pt-1 mt-1",children:e.jsxs("div",{children:[f.listenerCount," packets where they heard your transmissions"]})})]}),k=f=>e.jsxs("div",{className:"max-w-[220px]",children:[e.jsxs("div",{className:"font-semibold mb-1",children:["📢 Loudest: ",f.name]}),e.jsxs("div",{className:"text-fg-muted mb-1",children:["Score: ",f.loudScore,"/100"]}),e.jsx("div",{className:"border-t border-edge-subtle pt-1 mt-1",children:e.jsxs("div",{children:[f.loudCount," packets they relayed directly to you"]})})]}),{champion:T,listener:j,loudest:N}=b,D=T||j||N?e.jsxs("div",{className:"flex flex-col gap-0 sm:gap-0.5 mt-auto",children:[T&&e.jsx(re,{content:p(T),children:e.jsxs("div",{className:"flex items-center gap-1 text-xs sm:text-sm radius-badge px-1 -mx-1 hover-bg transition-base cursor-default",children:[e.jsx(is,{className:"w-2.5 h-2.5 sm:w-3 sm:h-3 text-map-neighbor-color flex-shrink-0"}),e.jsx("span",{className:"font-semibold text-map-neighbor-color font-mono truncate flex-1 min-w-0",children:T.name}),e.jsx("span",{className:"text-map-neighbor-color pl-1 sm:pl-2 tabular-nums flex-shrink-0 w-7 sm:w-9 text-right",children:T.blendedScore})]})}),j&&e.jsx(re,{content:w(j),children:e.jsxs("div",{className:"flex items-center gap-1 text-xs sm:text-sm radius-badge px-1 -mx-1 hover-bg transition-base cursor-default",children:[e.jsx(Ts,{className:"w-2.5 h-2.5 sm:w-3 sm:h-3 text-fg-muted flex-shrink-0"}),e.jsx("span",{className:"text-fg-muted font-mono truncate flex-1 min-w-0",children:j.name}),e.jsx("span",{className:"text-fg-muted pl-1 sm:pl-2 tabular-nums flex-shrink-0 w-7 sm:w-9 text-right",children:j.listenerScore})]})}),N&&e.jsx(re,{content:k(N),children:e.jsxs("div",{className:"flex items-center gap-1 text-xs sm:text-sm radius-badge px-1 -mx-1 hover-bg transition-base cursor-default",children:[e.jsx(_s,{className:"w-2.5 h-2.5 sm:w-3 sm:h-3 text-fg-muted flex-shrink-0"}),e.jsx("span",{className:"text-fg-muted font-mono truncate flex-1 min-w-0",children:N.name}),e.jsx("span",{className:"text-fg-muted pl-1 sm:pl-2 tabular-nums flex-shrink-0 w-7 sm:w-9 text-right",children:N.loudScore})]})})]}):n.length===0?e.jsx("div",{className:"flex items-center justify-center text-xs sm:text-sm text-fg-muted mt-auto",children:"No direct neighbors"}):e.jsx("div",{className:"flex items-center justify-center text-xs sm:text-sm text-fg-muted mt-auto",children:"No routing data yet"});return e.jsx(q,{title:"Link Leaders",icon:e.jsx(As,{className:"mini-widget-icon"}),isLoading:m,onClick:()=>t("/contacts"),children:D})}function Rn(t){const{retryRate:n,channelBusyCount:a,totalPacketsWithLBT:s,avgBackoffMs:o,maxBackoffMs:i}=t;if(s===0)return 0;const c=Math.min(s/10,1),l=.15,d=Math.log(1+n*l)/Math.log(1+100*l)*40,m=a/s*100,u=Math.min(m*.5,25);let x=0;o>100&&(x=Math.min(Math.log10(o/100)*8,15));let r=0;i>500&&o>0&&i>o*2&&(r=Math.min((i-500)/200,5));const b=(d+u+x+r)*c;return Math.min(b,85)}function Pn(t){return t<15?"excellent":t<30?"good":t<45?"fair":t<60?"congested":"critical"}function An(t){return t<15?"Clear channel":t<30?"Light traffic":t<45?"Moderate traffic":t<60?"Heavy traffic":t<75?"Congested":"Severe congestion"}function Fn(){const{lbtStats:t,isLoading:n,error:a}=Y(),s=t?Rn(t):0,o=t?Pn(s):"unknown",i=(t==null?void 0:t.maxBackoffMs)??0,c=t?i>200?`Max backoff: ${Math.round(i)}ms`:An(s):void 0,l=t==null?void 0:t.sparklineCollisionRisk,d=h.useMemo(()=>!l||l.length<2?[]:l.map((u,x)=>({timestamp:Date.now()-(l.length-1-x)*36e5,count:u})),[l]),m=Math.round(s*10)/10;return e.jsx(q,{title:"Collision Risk",icon:e.jsx(ms,{className:"mini-widget-icon"}),value:m,unit:"%",status:o,subtitle:c,isLoading:n,error:a,children:e.jsx("div",{className:"mini-widget-sparkline w-full",children:e.jsx(ye,{data:d,width:9999,height:24,color:"var(--sys-blue)",isLoading:n,className:"w-full"})})})}function Ln(t){return t<30?"excellent":t<50?"good":t<70?"fair":t<90?"congested":"critical"}function En(t){return t<1e3?`${Math.round(t)}ms`:t<6e4?`${(t/1e3).toFixed(1)}s`:`${(t/6e4).toFixed(1)}m`}function $n(){const[t,n]=h.useState(!1),[a]=h.useState(0),{stats:s,lbtStats:o,isLoading:i}=Y(),c=h.useMemo(()=>{if(!s)return null;const y=s.airtime_used_ms??0,b=s.max_airtime_ms??1,p=s.airtime_remaining_ms??0,w=s.utilization_percent??(b>0?y/b*100:0);return{usedMs:y,maxMs:b,remainingMs:p,utilizationPercent:w}},[s]),l=h.useMemo(()=>{if(!o||o.totalPacketsWithLBT===0)return 100;const y=o.totalPacketsWithLBT-o.packetsWithRetries,b=o.totalPacketsWithLBT;return y/b*100},[o]),d=(c==null?void 0:c.utilizationPercent)??0,m=Ln(d),u=(c==null?void 0:c.remainingMs)??0,x=l<95?`${l.toFixed(0)}% clean TX`:`${En(u)} remaining`,r=c?e.jsx("div",{className:"mini-widget-progress mt-auto",children:e.jsx("div",{className:`mini-widget-progress-bar ${m}`,style:{width:`${Math.min(d,100)}%`}})}):null;return e.jsx(q,{title:"Duty Cycle",icon:e.jsx(He,{className:"mini-widget-icon"}),value:d.toFixed(1),unit:"%",status:m,subtitle:x,isLoading:i,children:r})}function Hn(){return e.jsxs("div",{className:"mini-widget",children:[e.jsxs("div",{className:"mini-widget-header",children:[e.jsx(K,{className:"w-4 h-4"}),e.jsx(K,{className:"h-3 w-16"})]}),e.jsx(K,{className:"h-7 w-12 mt-2"}),e.jsx(K,{className:"h-3 w-20 mt-2"})]})}function In(){return e.jsx("div",{className:"widget-row",children:Array.from({length:6}).map((t,n)=>e.jsx(Hn,{},n))})}const st=[{target:"MeshHealth",fn:"type",minStage:1}];W(st);function On({className:t="",isLoaded:n}){O(st);const a=Oe(),s=n??a??!0;return e.jsxs("div",{className:`mesh-health-container relative ${t}`,children:[e.jsxs("div",{className:"mesh-health-header",children:[e.jsx(Ft,{className:"w-4 h-4 text-sys-blue"}),e.jsx("span",{className:"type-label text-fg-muted",children:"MESH HEALTH"})]}),s?e.jsx(Nn,{children:e.jsxs("div",{className:"widget-row",children:[e.jsx(kn,{}),e.jsx(Fn,{}),e.jsx(Bn,{}),e.jsx($n,{}),e.jsx(Cn,{}),e.jsx(Dn,{})]})}):e.jsx(In,{})]})}const nt=[{target:"PublicChannel",fn:"decrypt",minStage:2,when:es}];W(nt);let at="",ot="",Le="";function Wn(){const t=new Date,n=t.toDateString();if(n!==Le){Le=n,at=n;const a=new Date(t);a.setDate(a.getDate()-1),ot=a.toDateString()}}function zn(t){Wn();const n=new Date(t*1e3).toDateString();return n===at?"Today":n===ot?"Yesterday":new Date(t*1e3).toLocaleDateString([],{weekday:"short",month:"short",day:"numeric"})}function qn(t,n,a){return`${t||""}|${n}|${a}`}function Un(t,n){const a=t.message,s=n.message;return a.timestamp===s.timestamp&&a.text===s.text&&a.senderName===s.senderName&&a.channelHash===s.channelHash&&a.channelName===s.channelName&&t.isChannelSelected===n.isChannelSelected&&t.onChannelClick===n.onChannelClick}const Vn=h.memo(function({message:n,onChannelClick:a,isChannelSelected:s}){const o=n.channelName||n.channelHash.slice(0,6);return e.jsx("div",{style:{transform:"translateZ(0)",willChange:"transform"},children:e.jsx(gs,{senderName:n.senderName||"Unknown",text:n.text,timestamp:n.timestamp,nameAccessory:e.jsx(Ue,{channelName:o,active:s,onClick:()=>a==null?void 0:a(n.channelHash)})})})},Un);function Gn({open:t,onClose:n,messages:a,onLoadMore:s,hasMoreToLoad:o,isDecoding:i,initialChannel:c}){const l=h.useRef(null),d=h.useRef(!0),m=X(),u=We(),x=h.useRef(!1);h.useEffect(()=>{t?(x.current=!0,_e.resume()):x.current&&_e.pause()},[t]);const r=h.useMemo(()=>{const g=Date.now()/1e3,_=F[m].minutes,B=g-_*60;return[...a].filter(R=>R.timestamp>=B).sort((R,ae)=>R.timestamp-ae.timestamp)},[a,m]),y=h.useCallback(()=>{const g=l.current;g&&(d.current=g.scrollTop>=-50)},[]),b=h.useMemo(()=>{const g=new Map;for(const _ of r){const B=_.channelHash,R=g.get(B);R?R.count++:g.set(B,{name:_.channelName||_.channelHash.slice(0,6),hash:_.channelHash,count:1})}return Array.from(g.values()).sort((_,B)=>B.count-_.count)},[r]),p=b.length,[w,k]=h.useState(null),[T,j]=h.useState(!1);h.useEffect(()=>{t&&c&&k(c)},[t,c]);const N=h.useCallback(()=>{s(w,b)},[s,w,b]),v=h.useMemo(()=>w?r.filter(g=>g.channelHash===w):r,[r,w]),D=h.useMemo(()=>{const g=[];let _="";for(const B of v){const R=zn(B.timestamp);R!==_&&(g.push({type:"date",date:R}),_=R),g.push({type:"message",message:B})}return g},[v]);h.useLayoutEffect(()=>{const g=l.current;g&&d.current&&(g.scrollTop=0)},[v.length]);const f=19,C=b.slice(0,f),M=b.slice(f),S=M.length>0;return e.jsx(Ot,{open:t,onClose:n,size:"lg",motionPlus:!0,solid:!0,children:e.jsxs(Wt,{className:"p-0 flex flex-col h-[80vh] max-h-[700px] rounded-2xl",children:[e.jsx("div",{className:"flex-shrink-0 px-4 sm:px-5 py-3 sm:py-4",children:e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Ge,{className:"size-5 text-icon-card-title flex-shrink-0"}),e.jsx("h2",{className:"type-micro",children:"Public Channels"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ve,{ranges:F,selectedIndex:m,onSelect:u,size:"sm"}),e.jsx("button",{onClick:n,className:"sm:hidden min-h-[44px] min-w-[44px] px-3 flex items-center justify-center text-[15px] font-medium text-sys-blue active:text-sys-blue/70 transition-base radius-inner active:bg-subtle-fill",children:"Done"}),e.jsx("button",{onClick:n,className:"hidden sm:flex items-center justify-center p-2 text-fg-muted hover:text-fg-primary transition-base radius-inner hover:bg-subtle","aria-label":"Close",children:e.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]})]})}),e.jsx("div",{className:"flex-shrink-0 px-3 pb-2 relative z-10 isolate",style:{minHeight:p>0?void 0:0},children:p>0&&e.jsxs("div",{className:"flex flex-wrap gap-1",children:[e.jsxs("button",{onClick:()=>k(null),className:A("px-2 py-0.5 rounded text-xs font-medium transition-all","ring-1 ring-inset",w===null?"bg-sys-blue/20 text-sys-blue ring-sys-blue/30":"bg-subtle-fill text-fg-secondary ring-edge-subtle hover:bg-subtle-fill-strong"),children:["All ",p]}),C.map(g=>e.jsx("button",{onClick:()=>k(g.hash),className:A("flex items-center gap-1 px-2 py-0.5 rounded text-xs font-medium transition-all","ring-1 ring-inset",w===g.hash?"bg-sys-blue/20 text-sys-blue ring-sys-blue/30":"bg-subtle-fill text-fg-secondary ring-edge-subtle hover:bg-subtle-fill-strong"),children:e.jsx("span",{className:"truncate max-w-[80px]",children:g.name})},g.hash)),S&&e.jsxs("div",{className:"relative",children:[e.jsxs("button",{onClick:()=>j(!T),className:A("flex items-center gap-0.5 px-2 py-0.5 rounded text-xs font-medium transition-all","ring-1 ring-inset",T||M.some(g=>g.hash===w)?"bg-sys-blue/20 text-sys-blue ring-sys-blue/30":"bg-subtle-fill text-fg-secondary ring-edge-subtle hover:bg-subtle-fill-strong"),children:["+",M.length,e.jsx(zt,{className:A("size-3 transition-transform",T&&"rotate-180")})]}),T&&e.jsx("div",{className:A("absolute top-full left-0 mt-1 z-50","min-w-[140px] max-h-[200px] overflow-y-auto","p-1 rounded-lg","bg-elevated backdrop-blur-xl","ring-1 ring-edge-subtle shadow-xl"),children:M.map(g=>e.jsxs("button",{onClick:()=>{k(g.hash),j(!1)},className:A("w-full flex items-center gap-1.5 px-2 py-1 rounded text-xs font-medium transition-all text-left",w===g.hash?"bg-sys-blue/20 text-sys-blue":"text-fg-secondary hover:bg-subtle-fill-strong"),children:[e.jsx(ys,{className:"size-2.5 opacity-60 flex-shrink-0"}),e.jsx("span",{className:"truncate",children:g.name}),e.jsxs("span",{className:"opacity-60 ml-auto",children:["(",g.count,")"]})]},g.hash))})]})]})}),e.jsx("div",{ref:l,onScroll:y,className:A("flex-1 overflow-y-auto overflow-x-hidden","mx-3 mb-3 rounded-md","bg-body","ring-1 ring-inset ring-edge-subtle","flex flex-col-reverse"),children:i&&v.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center h-full min-h-[300px] text-fg-muted px-4 py-4",children:[e.jsx(te,{className:"size-12 mb-4 text-sys-indigo animate-spin"}),e.jsx("p",{className:"text-lg font-medium",children:"Loading messages..."})]}):v.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center h-full min-h-[300px] text-fg-muted px-4 py-4",children:[e.jsx(Bs,{className:"size-16 mb-4 opacity-20"}),e.jsx("p",{className:"text-lg font-medium",children:"No messages yet"}),e.jsx("p",{className:"text-sm mt-1 opacity-70",children:w?"No messages in this channel":"Public channel messages will appear here"})]}):e.jsxs("div",{className:"px-4 py-4",children:[o&&e.jsx("div",{className:"flex justify-center mb-4",children:e.jsx("button",{onClick:N,disabled:i,className:A("px-4 py-1.5 rounded-full","text-[11px] font-medium","ring-1 ring-inset",i?"bg-subtle-fill text-fg-muted ring-edge-subtle cursor-wait":"bg-sys-blue/10 text-sys-blue ring-sys-blue/20 hover:bg-sys-blue/20 hover:ring-sys-blue/30"),children:i?e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(te,{className:"size-3 animate-spin"}),"Loading..."]}):"Load older messages"})}),D.map((g,_)=>{if(g.type==="date")return e.jsx("div",{className:"flex justify-center my-4",children:e.jsx("span",{className:A("px-3.5 py-1.5 rounded-full","bg-subtle-fill backdrop-blur-sm","text-[11px] text-fg-muted/80 font-medium","ring-1 ring-edge-subtle"),children:g.date})},`date-${g.date}-${_}`);const B=`msg-${g.message.timestamp}-${g.message.senderName||"anon"}-${g.message.channelHash}`;return e.jsx("div",{className:"mb-3",children:e.jsx(Vn,{message:g.message,onChannelClick:k,isChannelSelected:w===g.message.channelHash})},B)})]})}),e.jsx("div",{className:"flex-shrink-0 px-5 py-2 text-center",children:e.jsxs("p",{className:"text-[11px] text-fg-muted",children:[v.length," messages · ",p," ",p===1?"channel":"channels",i&&e.jsxs("span",{className:"ml-2 text-sys-indigo",children:[e.jsx(te,{className:"inline size-3 animate-spin mr-1"}),"Decrypting..."]})]})})]})})}function Xn(t){const n=[],a=new Set;for(const s of t.values()){const o=s.decoded;if(!o||!o.decrypted||o.macCorrupted||!o.text)continue;const i=qn(o.senderName,o.channelHash,o.text);a.has(i)||(a.add(i),n.push({timestamp:s.timestamp,channelName:o.channelName,channelHash:o.channelHash,senderName:o.senderName,text:o.text,rssi:s.rssi,snr:s.snr}))}return n}function Yn({isLoaded:t}){const n=Oe(),a=t??n??!0;O(nt);const s=se(),[o,i]=h.useState(!1),[c,l]=h.useState(null),d=X(),m=h.useCallback(()=>{l(null),i(!0),J.getState().queueDecryption(s)},[s]),u=xe(C=>C.requestedHash),x=xe(C=>C.clearRequest);h.useEffect(()=>{u&&(l(u),i(!0),J.getState().queueDecryption(s),x())},[u,x,s]);const r=Lt(),y=Et(),b=$t(),p=h.useMemo(()=>Xn(r),[r]),w=h.useMemo(()=>{const C=Date.now()/1e3,M=F[d].minutes,S=C-M*60;return p.filter(g=>g.timestamp>=S)},[p,d]),k=h.useMemo(()=>w.length===0?null:w.reduce((C,M)=>M.timestamp>C.timestamp?M:C),[w]),T=y.isDecoding,N=h.useMemo(()=>{const C=Date.now()/1e3,M=F[d].minutes,S=C-M*60,g=new Set;let _=0;for(const B of s)(B.type??B.payload_type)===Me.GRP_TXT&&((B.timestamp??0){const C=Date.now()/1e3,M=F[d].minutes,S=C-M*60;for(const g of s)if((g.type??g.payload_type)===Me.GRP_TXT&&!((g.timestamp??0){if(!T){if(C){const S=M.find(g=>g.hash===C);if(S){console.log(`[PublicChannelCard] Fast-path load for #${S.name}`),J.getState().queueChannelDecryption(s,S.name);return}}J.getState().queueDecryption(s)}},[s,T]);return a?e.jsxs(e.Fragment,{children:[e.jsx("div",{onClick:m,className:A("group cursor-pointer rounded-2xl transition-all duration-150","bg-surface/80 backdrop-blur-lg depth-raised","hover:bg-subtle-fill","px-3 py-2.5 sm:px-4 sm:py-3"),children:e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2 sm:gap-3 flex-shrink-0",children:[e.jsx(Ge,{className:"size-4 text-icon-card-title flex-shrink-0"}),e.jsx("span",{className:"type-micro",children:"CHAT ACTIVITY"}),N>0&&e.jsx("span",{className:"inline-flex items-center px-2 py-1 rounded-md bg-subtle-fill ring-1 ring-inset ring-edge-subtle text-sm tabular-nums text-fg-secondary",children:N}),e.jsx(Re,{className:"size-4 text-fg-muted group-hover:text-sys-indigo transition-colors ml-auto sm:hidden"})]}),e.jsxs("div",{className:"flex items-center gap-2 sm:gap-1.5 min-w-0 overflow-hidden",children:[e.jsx(Ee,{mode:"wait",initial:!1,children:k?e.jsxs(ee.div,{initial:{opacity:0,y:16},animate:{opacity:1,y:0},exit:{opacity:0,y:-16},transition:{duration:.2,ease:[.4,0,.2,1]},className:"flex items-center gap-2 sm:gap-1.5 min-w-0",children:[k.channelName&&e.jsx("span",{className:"hidden sm:inline-flex",children:e.jsx(Ue,{channelName:k.channelName})}),e.jsx("div",{className:"hidden sm:flex w-[30px] h-[30px] rounded-full items-center justify-center flex-shrink-0 ring-1 ring-edge-subtle",style:{backgroundColor:fs(le(k.senderName||"").cleanName)},children:le(k.senderName||"").emoji?e.jsx("span",{className:"text-base",children:le(k.senderName||"").emoji}):e.jsx("span",{className:"text-white text-xs font-bold tracking-tighter",children:hs(k.senderName||"")})}),e.jsx("div",{className:"inline-flex items-center px-3 py-1.5 rounded-2xl rounded-tr-md bg-[#007AFF] shadow-sm min-w-0 flex-1 sm:flex-initial sm:max-w-xs sm:-ml-px",children:e.jsx("span",{className:"text-sm text-white truncate tracking-wide",children:ps(k.text)})}),e.jsx("span",{className:"inline-flex items-center px-2 py-1 rounded-md bg-subtle-fill ring-1 ring-inset ring-edge-subtle text-sm tabular-nums text-fg-secondary flex-shrink-0",children:It(k.timestamp)})]},`msg-${k.timestamp}-${k.senderName}-${k.channelHash}`):b?e.jsx(ee.span,{initial:{opacity:0},animate:{opacity:1},className:"text-sm text-fg-muted italic",children:"No messages yet"},"empty"):e.jsxs(ee.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0,y:-16},transition:{duration:.15},className:"flex items-center gap-2 sm:gap-1.5",children:[e.jsx("div",{className:"hidden sm:block w-8 h-4 rounded bg-subtle-fill-strong animate-pulse"}),e.jsx("div",{className:"hidden sm:block w-[30px] h-[30px] rounded-full bg-subtle-fill-strong animate-pulse"}),e.jsx("div",{className:"h-8 w-32 sm:w-48 rounded-2xl bg-subtle-fill-strong animate-pulse"}),e.jsx("div",{className:"w-12 h-6 rounded-md bg-subtle-fill-strong animate-pulse"})]},"skeleton")}),e.jsx(Re,{className:"size-4 text-fg-muted group-hover:text-sys-indigo transition-colors flex-shrink-0 hidden sm:block ml-1"})]})]})}),e.jsx(Gn,{open:o,onClose:()=>i(!1),messages:p,onLoadMore:f,hasMoreToLoad:D,isDecoding:T,initialChannel:c})]}):e.jsx("div",{className:"h-14 rounded-xl bg-elevated/50 animate-pulse"})}function Sa(){var b;const t=ne(),n=qt(),a=Ut(),s=Us(),o=h.useRef(!1);a&&!o.current&&(o.current=!0);const i=o.current,c=X(),l=We(),d=Vt(),m=F[c]??F[4],u=d.isBackgroundLoading&&c>=5,x=h.useMemo(()=>{const p=C=>(C==null?void 0:C.reduce((M,S)=>M+S.count,0))??0,w=p(s==null?void 0:s.received),k=p(s==null?void 0:s.unique_received),T=p(s==null?void 0:s.forwarded),j=p(s==null?void 0:s.dropped),N=p(s==null?void 0:s.transmitted),v=((s==null?void 0:s.time_range_minutes)??m.minutes)/60,D=v>0?Math.round(w/v):0,f=v>0?Math.round(T/v):0;return{received:w,uniqueReceived:k,forwarded:T,dropped:j,transmitted:N,rxPerHour:D,fwdPerHour:f}},[s,m.minutes]),r=h.useMemo(()=>s?{totalBytes:s.totalReceivedBytes,kbPerHour:s.kbPerHour}:{totalBytes:0,kbPerHour:0},[s]),y=(t==null?void 0:t.node_name)??((b=t==null?void 0:t.config)==null?void 0:b.node_name)??"Unknown Node";return h.useEffect(()=>{y&&y!=="Unknown Node"&&(document.title=`pyMC: ${y}`)},[y]),n?e.jsxs(Be,{neomorphic:!0,className:"p-8 text-center",children:[e.jsx("p",{className:"type-subheading text-sys-red mb-2",children:"Failed to connect to backend"}),e.jsx("p",{className:"type-body text-fg-muted",children:n}),e.jsx("p",{className:"type-data-sm text-fg-muted mt-4",children:"Make sure the backend is running on port 8000"})]}):e.jsxs(Xt,{children:[e.jsx(Yt,{title:y,icon:e.jsx(us,{}),controls:e.jsx(Ve,{ranges:F,selectedIndex:c,onSelect:l,isPending:u})}),e.jsxs(Kt,{ready:i,children:[e.jsx(Yn,{}),e.jsx(ce,{template:"hero-auto",children:e.jsxs(Be,{neomorphic:!0,children:[e.jsx($e,{icon:e.jsx(ks,{}),title:"PACKETS RECEIVED",badge:m.label,badgeColor:"zinc",actions:i?e.jsxs("div",{className:"data-box",children:[r.kbPerHour," KB/hr"]}):e.jsx("div",{className:"data-box opacity-0",children:"0 KB/hr"})}),e.jsxs("div",{className:"flex flex-wrap gap-4 sm:gap-8",children:[e.jsxs("div",{className:"flex items-end gap-2",children:[e.jsx("div",{className:"type-data-xl text-fg-primary",children:i?e.jsx(G,{value:x.received,className:"font-mono tabular-nums",priority:"high"}):e.jsx("span",{className:"opacity-30",children:"—"})}),e.jsx(V,{color:"zinc",className:"mb-0.5 sm:mb-1",children:"Total Rx"})]}),e.jsxs("div",{className:"flex items-end gap-2",children:[e.jsx("div",{className:"type-data-xl text-fg-primary",children:i?e.jsx(G,{value:x.uniqueReceived,className:"font-mono tabular-nums",priority:"high"}):e.jsx("span",{className:"opacity-30",children:"—"})}),e.jsx(V,{color:"zinc",className:"mb-0.5 sm:mb-1",children:"Unique"})]})]}),e.jsxs("div",{className:"mt-2 flex-1 min-h-0 relative",children:[e.jsx("div",{className:`absolute inset-0 flex items-end gap-1 transition-opacity duration-300 ${i?"opacity-0 pointer-events-none":"opacity-100"}`,"aria-hidden":i,children:[45,72,33,58,80,42,65,28,55,75,38,62].map((p,w)=>e.jsx("div",{className:"flex-1 bg-subtle-fill rounded-sm animate-pulse",style:{height:`${p}%`}},w))}),e.jsx("div",{className:`h-full transition-opacity duration-300 ${i?"opacity-100":"opacity-0"}`,children:e.jsx(Xs,{buckets:(s==null?void 0:s.receivedBytesBuckets)??[],activeTypes:(s==null?void 0:s.receivedActiveTypes)??[],totalByType:(s==null?void 0:s.receivedTotalByType)??{}})})]})]})}),e.jsxs(ce,{template:"compact",children:[e.jsx(de,{span:6,lg:4,children:e.jsx(Zs,{value:x.forwarded,receivedCount:x.received,buckets:(s==null?void 0:s.forwardedBytesBuckets)??[],activeTypes:(s==null?void 0:s.forwardedActiveTypes)??[],ratePerHour:(s==null?void 0:s.forwardedRatePerHour)??0,timeRangeLabel:m.label,icon:e.jsx(js,{className:"w-4 h-4"})})}),e.jsx(de,{span:6,lg:4,children:e.jsx(Qs,{value:x.dropped,receivedCount:x.received,buckets:(s==null?void 0:s.droppedBytesBuckets)??[],activeTypes:(s==null?void 0:s.droppedActiveTypes)??[],ratePerHour:(s==null?void 0:s.droppedRatePerHour)??0,timeRangeLabel:m.label,icon:e.jsx(rs,{className:"w-4 h-4"})})}),e.jsx(de,{span:12,lg:4,children:e.jsx(ln,{stats:t,localHash:t==null?void 0:t.local_hash,receivedBuckets:s==null?void 0:s.received,droppedBuckets:s==null?void 0:s.dropped,forwardedBuckets:s==null?void 0:s.forwarded,bucketDurationSeconds:s==null?void 0:s.bucket_duration_seconds,timeRangeLabel:m.label})})]}),e.jsx(On,{}),e.jsx(dn,{}),t&&e.jsx(ce,{template:"auto",children:e.jsx(xs,{nodeName:y,repeaterVersion:t.version,coreVersion:t.core_version,localHash:t.local_hash,publicKey:t.public_key})})]})]})}export{Sa as default}; diff --git a/frontend/dist/assets/DataBox-BADtaCfB.js b/frontend/dist/assets/DataBox-BMesbbaF.js similarity index 97% rename from frontend/dist/assets/DataBox-BADtaCfB.js rename to frontend/dist/assets/DataBox-BMesbbaF.js index d868aa12..1ae7ae15 100644 --- a/frontend/dist/assets/DataBox-BADtaCfB.js +++ b/frontend/dist/assets/DataBox-BMesbbaF.js @@ -1 +1 @@ -import{r as u,j as a,c as r,w as T,x as N}from"./index-C1ZF7cAz.js";const E={standard:"w-3 h-3",compact:"w-2.5 h-2.5",responsive:"w-2.5 h-2.5 sm:w-3 sm:h-3"};function k(t){var s;if(typeof window<"u"&&(window.isSecureContext||window.location.protocol==="https:"||window.location.hostname==="localhost")&&((s=navigator.clipboard)!=null&&s.writeText))return navigator.clipboard.writeText(t).catch(()=>{}),!0;try{const{scrollX:o,scrollY:i}=window,e=document.createElement("textarea");e.value=t,e.style.cssText="position:fixed;left:-9999px;top:-9999px;opacity:0;pointer-events:none",e.setAttribute("readonly",""),document.body.appendChild(e),e.focus({preventScroll:!0}),e.select(),e.setSelectionRange(0,t.length);const l=document.execCommand("copy");return document.body.removeChild(e),window.scrollTo(o,i),l}catch(o){return console.error("Copy failed:",o),!1}}function $({children:t,copyValue:x,copy:s=!1,size:o="standard",className:i,title:e,color:l,truncate:d}){const[m,y]=u.useState(!1),[S,w]=u.useState(!1),f=u.useRef(null),c=x??(typeof t=="string"?t:""),C=E[o],h=(()=>{if(!d||typeof t!="string")return t;const n=t,[p,g]=d===!0?[6,4]:d;return n.length<=p+g+3?n:`${n.slice(0,p)}…${n.slice(-g)}`})(),j=u.useCallback(n=>{if(!s)return;n.preventDefault(),n.stopPropagation(),f.current&&clearTimeout(f.current);const p=k(c);y(!0),f.current=setTimeout(()=>y(!1),2e3),p||console.warn("Copy may have failed for:",c.slice(0,16)+"...")},[s,c]),v=o==="compact"?"data-box-compact":o==="responsive"?"data-box-responsive":"",b=s?e||`Click to copy: ${c}`:e;return s?a.jsxs("button",{type:"button",onClick:j,onMouseEnter:()=>w(!0),onMouseLeave:()=>w(!1),className:r("data-box interactive",v,"cursor-pointer select-none gap-1","hover-bg",l,i),title:b,"aria-label":`Copy ${c}`,children:[a.jsx("span",{className:r("transition-colors duration-200",m?"text-sys-green":""),children:h}),a.jsx("span",{className:r("flex items-center justify-center",o==="compact"?"w-3 h-3":"w-3.5 h-3.5"),children:m?a.jsx(T,{className:r("text-sys-green",C)}):a.jsx(N,{className:r("transition-opacity duration-200",S?"opacity-70":"opacity-40",C)})})]}):a.jsx("span",{className:r("data-box",v,l,i),title:b,children:h})}export{$ as D}; +import{r as u,j as a,c as r,y as T,z as N}from"./index-DhkG1Nx9.js";const E={standard:"w-3 h-3",compact:"w-2.5 h-2.5",responsive:"w-2.5 h-2.5 sm:w-3 sm:h-3"};function k(t){var s;if(typeof window<"u"&&(window.isSecureContext||window.location.protocol==="https:"||window.location.hostname==="localhost")&&((s=navigator.clipboard)!=null&&s.writeText))return navigator.clipboard.writeText(t).catch(()=>{}),!0;try{const{scrollX:o,scrollY:i}=window,e=document.createElement("textarea");e.value=t,e.style.cssText="position:fixed;left:-9999px;top:-9999px;opacity:0;pointer-events:none",e.setAttribute("readonly",""),document.body.appendChild(e),e.focus({preventScroll:!0}),e.select(),e.setSelectionRange(0,t.length);const l=document.execCommand("copy");return document.body.removeChild(e),window.scrollTo(o,i),l}catch(o){return console.error("Copy failed:",o),!1}}function $({children:t,copyValue:x,copy:s=!1,size:o="standard",className:i,title:e,color:l,truncate:d}){const[m,y]=u.useState(!1),[S,w]=u.useState(!1),f=u.useRef(null),c=x??(typeof t=="string"?t:""),C=E[o],h=(()=>{if(!d||typeof t!="string")return t;const n=t,[p,g]=d===!0?[6,4]:d;return n.length<=p+g+3?n:`${n.slice(0,p)}…${n.slice(-g)}`})(),j=u.useCallback(n=>{if(!s)return;n.preventDefault(),n.stopPropagation(),f.current&&clearTimeout(f.current);const p=k(c);y(!0),f.current=setTimeout(()=>y(!1),2e3),p||console.warn("Copy may have failed for:",c.slice(0,16)+"...")},[s,c]),v=o==="compact"?"data-box-compact":o==="responsive"?"data-box-responsive":"",b=s?e||`Click to copy: ${c}`:e;return s?a.jsxs("button",{type:"button",onClick:j,onMouseEnter:()=>w(!0),onMouseLeave:()=>w(!1),className:r("data-box interactive",v,"cursor-pointer select-none gap-1","hover-bg",l,i),title:b,"aria-label":`Copy ${c}`,children:[a.jsx("span",{className:r("transition-colors duration-200",m?"text-sys-green":""),children:h}),a.jsx("span",{className:r("flex items-center justify-center",o==="compact"?"w-3 h-3":"w-3.5 h-3.5"),children:m?a.jsx(T,{className:r("text-sys-green",C)}):a.jsx(N,{className:r("transition-opacity duration-200",S?"opacity-70":"opacity-40",C)})})]}):a.jsx("span",{className:r("data-box",v,l,i),title:b,children:h})}export{$ as D}; diff --git a/frontend/dist/assets/DeepAnalysisModal-X0cTTPp0.js b/frontend/dist/assets/DeepAnalysisModal-DuvRb3Nu.js similarity index 89% rename from frontend/dist/assets/DeepAnalysisModal-X0cTTPp0.js rename to frontend/dist/assets/DeepAnalysisModal-DuvRb3Nu.js index 95478a04..3373d45c 100644 --- a/frontend/dist/assets/DeepAnalysisModal-X0cTTPp0.js +++ b/frontend/dist/assets/DeepAnalysisModal-DuvRb3Nu.js @@ -1,4 +1,4 @@ -import{d as b,bf as G,dx as q,dy as D,cL as L,r as M,bQ as F,fY as P,fZ as W,j as f,ac as $,f_ as B,ad as Y,m as H,w as R,c as w,L as U}from"./index-C1ZF7cAz.js";import{D as K}from"./download-DbDw1ZiV.js";import{D as X}from"./database-CdKnhwkJ.js";/** +import{d as b,bi as G,du as q,dv as D,cJ as L,r as M,bR as F,fX as P,fY as W,j as f,ag as $,fZ as B,ah as Y,m as H,y as R,c as k,L as U}from"./index-DhkG1Nx9.js";import{D as K}from"./download-d0PZoGJ2.js";import{D as X}from"./database-DE8k8U0g.js";/** * @license lucide-react v0.559.0 - ISC * * This source code is licensed under the ISC license. @@ -8,12 +8,12 @@ import{d as b,bf as G,dx as q,dy as D,cL as L,r as M,bQ as F,fY as P,fZ as W,j a * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const Q=[["path",{d:"M9 10h.01",key:"qbtxuw"}],["path",{d:"M15 10h.01",key:"1qmjsl"}],["path",{d:"M12 2a8 8 0 0 0-8 8v12l3-3 2.5 2.5L12 19l2.5 2.5L17 19l3 3V10a8 8 0 0 0-8-8z",key:"uwwb07"}]],J=b("ghost",Q);/** + */const J=[["path",{d:"M9 10h.01",key:"qbtxuw"}],["path",{d:"M15 10h.01",key:"1qmjsl"}],["path",{d:"M12 2a8 8 0 0 0-8 8v12l3-3 2.5 2.5L12 19l2.5 2.5L17 19l3 3V10a8 8 0 0 0-8-8z",key:"uwwb07"}]],Q=b("ghost",J);/** * @license lucide-react v0.559.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const ee=[["line",{x1:"6",x2:"6",y1:"3",y2:"15",key:"17qcm7"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M18 9a9 9 0 0 1-9 9",key:"n2h4wq"}]],_=b("git-branch",ee);/** + */const ee=[["line",{x1:"6",x2:"6",y1:"3",y2:"15",key:"17qcm7"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M18 9a9 9 0 0 1-9 9",key:"n2h4wq"}]],C=b("git-branch",ee);/** * @license lucide-react v0.559.0 - ISC * * This source code is licensed under the ISC license. @@ -28,4 +28,4 @@ import{d as b,bf as G,dx as q,dy as D,cL as L,r as M,bQ as F,fY as P,fZ as W,j a * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const ie=[["path",{d:"m14 10 7-7",key:"oa77jy"}],["path",{d:"M20 10h-6V4",key:"mjg0md"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M4 14h6v6",key:"rmj7iw"}]],De=b("minimize-2",ie);class se{constructor(){this.componentControls=new Set}subscribe(e){return this.componentControls.add(e),()=>this.componentControls.delete(e)}start(e,t){this.componentControls.forEach(i=>{i.start(e.nativeEvent||e,t)})}cancel(){this.componentControls.forEach(e=>{e.cancel()})}stop(){this.componentControls.forEach(e=>{e.stop()})}}const oe=()=>new se;function Le(){return G(oe)}const ce={hidden:{opacity:0,scale:.9},visible:{opacity:1,scale:1,transition:{type:"spring",stiffness:400,damping:15}},exit:{opacity:0,scale:.9,transition:{duration:D.fast}}},Re={hidden:{opacity:0,y:"100%"},visible:{opacity:1,y:0,transition:{type:"spring",stiffness:400,damping:30}},exit:{opacity:0,y:"100%",transition:{duration:D.medium,ease:q.easeIn}}},re=1e-8,ae=100,E=3,le=4,k=5,fe=20,ue=.001,C=.3,me=30,de=.05,he=.7,T=.3;function v(n,e){let t=0;for(let i=0;i0)for(let t=0;t[a,r])),l=Array(o).fill(null).map(()=>Array(o).fill(0));for(const a of n){const r=c.get(a.fromHash),s=c.get(a.toHash);if(r!==void 0&&s!==void 0&&r!==s){const m=a.strength*a.certainCount;let u=1;if(t){const y=t.get(a.fromHash),x=t.get(a.toHash);if(y&&x){const V=L(y[0],y[1],x[0],x[1])/1e3;u=ye(V)}}let d=1;if(i){const y=[a.fromHash,a.toHash].sort().join("-");d=1-(i.get(y)??0)*he}const h=a.symmetryRatio??0,p=T+(1-T)*h,g=Math.pow(m,1-C)*Math.pow(u,C)*d*p;l[r][s]=g,l[s][r]=g}}return l}function O(n){const e=n.length,t=Array(e).fill(null).map(()=>Array(e).fill(0));for(let i=0;iArray(e).fill(0));for(let r=0;rMath.sin(s*12.9898)*43758.5453%1-.5);S(c,t),I(c);let l=0;for(let r=0;r=n.length)return n;const t=[],i=n.length/e;for(let o=0;oc.has(h.fromHash)&&c.has(h.toHash));if(l.length===0)return null;const a=xe(l,e,t,i),r=O(a),{vector:s,eigenvalue:m}=z(r);if(m({hash:u,community:0,fiedlerValue:0})),numCommunities:1,fiedlerValue:0,isConnected:o<=1};const c=[];let l=1/0;const a=[[e,0]];for(;a.length>0;){const[u,d]=a.shift();if((t?be(u,t):0)>fe&&d=k*2){const g=je(n,u,t,i);if(g){l=Math.min(l,g.fiedlerValue),a.push([g.group0,d+1]),a.push([g.group1,d+1]);continue}}c.push(u)}const r=new Map,s=[],m=new Map;for(let u=0;u[a,r])),o=Array(t).fill(null).map(()=>Array(t).fill(0));for(const a of n){const r=i.get(a.fromHash),s=i.get(a.toHash);r!==void 0&&s!==void 0&&r!==s&&(o[r][s]=1,o[s][r]=1)}const c=O(o),{eigenvalue:l}=z(c);return Math.max(0,l)}function Ge(n){const e=["rgba(139, 92, 246, 0.6)","rgba(16, 185, 129, 0.6)","rgba(245, 158, 11, 0.6)","rgba(239, 68, 68, 0.6)","rgba(59, 130, 246, 0.6)","rgba(236, 72, 153, 0.6)","rgba(20, 184, 166, 0.6)","rgba(249, 115, 22, 0.6)"];return e[n%e.length]}function qe(n,e){let t,i;if(e===void 0)for(const o of n)o!=null&&(t===void 0?o>=o&&(t=i=o):(t>o&&(t=o),i=c&&(t=i=c):(t>c&&(t=c),i=ve?10:c>=Ne?5:c>=we?2:1;let a,r,s;return o<0?(s=Math.pow(10,-o)/l,a=Math.round(n*s),r=Math.round(e*s),a/se&&--r,s=-s):(s=Math.pow(10,o)*l,a=Math.round(n/s),r=Math.round(e/s),a*se&&--r),r0))return[];if(n===e)return[n];const i=e=o))return[];const a=c-o+1,r=new Array(a);if(i)if(l<0)for(let s=0;s=i)&&(t=i);return t}function j({label:n,icon:e,status:t,detail:i}){return f.jsxs("div",{className:w("flex items-center gap-3 py-3 px-4 radius-inset transition-base",t==="active"&&"bg-sys-blue/10",t==="complete"&&"bg-sys-blue/10 ring-2 ring-inset ring-sys-blue",t==="pending"&&"opacity-40"),children:[f.jsx("div",{className:w("w-8 h-8 rounded-full flex items-center justify-center flex-shrink-0 transition-all duration-300",t==="active"&&"bg-sys-blue/20",t==="complete"&&"bg-sys-blue/20",t==="pending"&&"bg-subtle-fill"),children:t==="complete"?f.jsx(R,{className:"w-4 h-4 text-sys-blue"}):t==="active"?f.jsx(U,{className:"w-4 h-4 animate-spin text-sys-blue"}):f.jsx("span",{className:"text-fg-muted",children:e})}),f.jsxs("div",{className:"flex-1 min-w-0",children:[f.jsx("div",{className:w("text-sm font-medium transition-colors",t==="active"&&"text-sys-blue",t==="complete"&&"text-sys-blue",t==="pending"&&"text-fg-muted"),children:n}),i&&t!=="pending"&&f.jsx("div",{className:"text-xs text-fg-muted mt-0.5 truncate",children:i})]})]})}function ke({isOpen:n,onClose:e}){const{packetCacheState:t,triggerDeepAnalysis:i}=F(),o=P(),c=W(),l=t.packetCount,[a,r]=M.useState("fetching");M.useEffect(()=>{n&&i()},[n,i]),M.useEffect(()=>{if(n){if(t.isTopologyLoading)r("fetching");else if(o)r("analyzing"),setTimeout(()=>r("building"),500),setTimeout(()=>r("discovering"),1e3);else if(c>0&&!t.isTopologyLoading){r("complete");const p=setTimeout(()=>{e()},1500);return()=>clearTimeout(p)}}},[n,t.isTopologyLoading,o,c,e]);const s=a==="complete",m=t.loadProgress,u=M.useMemo(()=>{if(m&&m.target>0){const p=(m.loaded/1e3).toFixed(1),g=(m.target/1e3).toFixed(1);return`Loading... ${p}k / ${g}k packets (${m.percent}%)`}return l>0?`${l.toLocaleString()} packets loaded`:"Connecting to database..."},[m,l]),d=p=>{const g=["fetching","analyzing","building","discovering","complete"],y=g.indexOf(a),x=g.indexOf(p);return x{};return f.jsx($,{open:n,onClose:h,size:"sm",bottomSheet:!1,children:f.jsx(B,{isLoading:!s,borderRadius:16,children:f.jsx(Y,{className:"p-6 radius-card overflow-hidden",children:s?f.jsxs("div",{className:"flex flex-col items-center py-6",children:[f.jsx(H.div,{variants:ce,initial:"hidden",animate:"visible",className:"w-16 h-16 rounded-full flex items-center justify-center mb-4 bg-sys-blue/20",children:f.jsx(R,{className:"w-8 h-8 text-sys-blue"})}),f.jsx("h3",{className:"type-micro text-sys-blue",children:"Ready!"}),f.jsx("button",{onClick:e,className:"mt-3 sm:hidden min-h-[44px] min-w-[44px] px-4 flex items-center justify-center text-[15px] font-medium text-sys-blue active:text-sys-blue/70 transition-base radius-inner active:bg-subtle-fill",children:"Done"})]}):f.jsxs(f.Fragment,{children:[f.jsxs("div",{className:"flex items-center gap-3 mb-5",children:[f.jsx("div",{className:"w-10 h-10 radius-inset flex items-center justify-center bg-sys-blue/15",children:f.jsx(_,{className:"w-5 h-5 text-sys-blue"})}),f.jsxs("div",{children:[f.jsx("h3",{className:"type-micro",children:"Deep Analysis"}),f.jsx("p",{className:"text-xs text-fg-muted",children:"Building mesh topology"})]})]}),f.jsxs("div",{className:"space-y-2",children:[f.jsx(j,{label:"Fetching Packets",icon:f.jsx(K,{className:"w-4 h-4"}),status:d("fetching"),detail:u}),f.jsx(j,{label:"Analyzing Database",icon:f.jsx(X,{className:"w-4 h-4"}),status:d("analyzing"),detail:"Processing packet paths"}),f.jsx(j,{label:"Building Topology",icon:f.jsx(_,{className:"w-4 h-4"}),status:d("building"),detail:"Computing mesh edges"}),f.jsx(j,{label:"Discovering Nodes",icon:f.jsx(J,{className:"w-4 h-4"}),status:d("discovering"),detail:"Viterbi HMM ghost detection"})]}),f.jsx("p",{className:"text-xs text-fg-muted text-center mt-5",children:"This may take a few seconds..."})]})})})})}const $e=M.memo(ke);export{$e as D,Ie as E,Se as G,Ae as M,Fe as a,A as b,Ve as c,De as d,qe as e,J as f,_ as g,Ge as h,ze as i,Oe as j,We as m,Re as s,Pe as t,Le as u}; + */const ie=[["path",{d:"m14 10 7-7",key:"oa77jy"}],["path",{d:"M20 10h-6V4",key:"mjg0md"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M4 14h6v6",key:"rmj7iw"}]],De=b("minimize-2",ie);class se{constructor(){this.componentControls=new Set}subscribe(e){return this.componentControls.add(e),()=>this.componentControls.delete(e)}start(e,t){this.componentControls.forEach(i=>{i.start(e.nativeEvent||e,t)})}cancel(){this.componentControls.forEach(e=>{e.cancel()})}stop(){this.componentControls.forEach(e=>{e.stop()})}}const oe=()=>new se;function Le(){return G(oe)}const ce={hidden:{opacity:0,scale:.9},visible:{opacity:1,scale:1,transition:{type:"spring",stiffness:400,damping:15}},exit:{opacity:0,scale:.9,transition:{duration:D.fast}}},Re={hidden:{opacity:0,y:"100%"},visible:{opacity:1,y:0,transition:{type:"spring",stiffness:400,damping:30}},exit:{opacity:0,y:"100%",transition:{duration:D.medium,ease:q.easeIn}}},re=1e-8,ae=100,E=3,le=4,w=5,fe=20,ue=.001,_=.3,me=30,de=.05,he=.7,T=.3;function v(n,e){let t=0;for(let i=0;i0)for(let t=0;t[a,r])),l=Array(o).fill(null).map(()=>Array(o).fill(0));for(const a of n){const r=c.get(a.fromHash),s=c.get(a.toHash);if(r!==void 0&&s!==void 0&&r!==s){const m=a.strength*a.certainCount;let u=1;if(t){const y=t.get(a.fromHash),x=t.get(a.toHash);if(y&&x){const V=L(y[0],y[1],x[0],x[1])/1e3;u=ye(V)}}let d=1;if(i){const y=[a.fromHash,a.toHash].sort().join("-");d=1-(i.get(y)??0)*he}const h=a.symmetryRatio??0,p=T+(1-T)*h,g=Math.pow(m,1-_)*Math.pow(u,_)*d*p;l[r][s]=g,l[s][r]=g}}return l}function O(n){const e=n.length,t=Array(e).fill(null).map(()=>Array(e).fill(0));for(let i=0;iArray(e).fill(0));for(let r=0;rMath.sin(s*12.9898)*43758.5453%1-.5);S(c,t),I(c);let l=0;for(let r=0;r=n.length)return n;const t=[],i=n.length/e;for(let o=0;oc.has(h.fromHash)&&c.has(h.toHash));if(l.length===0)return null;const a=xe(l,e,t,i),r=O(a),{vector:s,eigenvalue:m}=z(r);if(m({hash:u,community:0,fiedlerValue:0})),numCommunities:1,fiedlerValue:0,isConnected:o<=1};const c=[];let l=1/0;const a=[[e,0]];for(;a.length>0;){const[u,d]=a.shift();if((t?be(u,t):0)>fe&&d=w*2){const g=je(n,u,t,i);if(g){l=Math.min(l,g.fiedlerValue),a.push([g.group0,d+1]),a.push([g.group1,d+1]);continue}}c.push(u)}const r=new Map,s=[],m=new Map;for(let u=0;u[a,r])),o=Array(t).fill(null).map(()=>Array(t).fill(0));for(const a of n){const r=i.get(a.fromHash),s=i.get(a.toHash);r!==void 0&&s!==void 0&&r!==s&&(o[r][s]=1,o[s][r]=1)}const c=O(o),{eigenvalue:l}=z(c);return Math.max(0,l)}function Ge(n){const e=["rgba(139, 92, 246, 0.6)","rgba(16, 185, 129, 0.6)","rgba(245, 158, 11, 0.6)","rgba(239, 68, 68, 0.6)","rgba(59, 130, 246, 0.6)","rgba(236, 72, 153, 0.6)","rgba(20, 184, 166, 0.6)","rgba(249, 115, 22, 0.6)"];return e[n%e.length]}function qe(n,e){let t,i;if(e===void 0)for(const o of n)o!=null&&(t===void 0?o>=o&&(t=i=o):(t>o&&(t=o),i=c&&(t=i=c):(t>c&&(t=c),i=ve?10:c>=Ne?5:c>=ke?2:1;let a,r,s;return o<0?(s=Math.pow(10,-o)/l,a=Math.round(n*s),r=Math.round(e*s),a/se&&--r,s=-s):(s=Math.pow(10,o)*l,a=Math.round(n/s),r=Math.round(e/s),a*se&&--r),r0))return[];if(n===e)return[n];const i=e=o))return[];const a=c-o+1,r=new Array(a);if(i)if(l<0)for(let s=0;s=i)&&(t=i);return t}function j({label:n,icon:e,status:t,detail:i}){return f.jsxs("div",{className:k("flex items-center gap-3 py-3 px-4 radius-inset transition-base",t==="active"&&"bg-sys-blue/10",t==="complete"&&"bg-sys-blue/10 ring-2 ring-inset ring-sys-blue",t==="pending"&&"opacity-40"),children:[f.jsx("div",{className:k("w-8 h-8 rounded-full flex items-center justify-center flex-shrink-0 transition-all duration-300",t==="active"&&"bg-sys-blue/20",t==="complete"&&"bg-sys-blue/20",t==="pending"&&"bg-subtle-fill"),children:t==="complete"?f.jsx(R,{className:"w-4 h-4 text-sys-blue"}):t==="active"?f.jsx(U,{className:"w-4 h-4 animate-spin text-sys-blue"}):f.jsx("span",{className:"text-fg-muted",children:e})}),f.jsxs("div",{className:"flex-1 min-w-0",children:[f.jsx("div",{className:k("text-sm font-medium transition-colors",t==="active"&&"text-sys-blue",t==="complete"&&"text-sys-blue",t==="pending"&&"text-fg-muted"),children:n}),i&&t!=="pending"&&f.jsx("div",{className:"text-xs text-fg-muted mt-0.5 truncate",children:i})]})]})}function we({isOpen:n,onClose:e}){const{packetCacheState:t,triggerDeepAnalysis:i}=F(),o=P(),c=W(),l=t.packetCount,[a,r]=M.useState("fetching");M.useEffect(()=>{n&&i()},[n,i]),M.useEffect(()=>{if(n){if(t.isTopologyLoading)r("fetching");else if(o)r("analyzing"),setTimeout(()=>r("building"),500),setTimeout(()=>r("discovering"),1e3);else if(c>0&&!t.isTopologyLoading){r("complete");const p=setTimeout(()=>{e()},1500);return()=>clearTimeout(p)}}},[n,t.isTopologyLoading,o,c,e]);const s=a==="complete",m=t.loadProgress,u=M.useMemo(()=>{if(m&&m.target>0){const p=(m.loaded/1e3).toFixed(1),g=(m.target/1e3).toFixed(1);return`Loading... ${p}k / ${g}k packets (${m.percent}%)`}return l>0?`${l.toLocaleString()} packets loaded`:"Connecting to database..."},[m,l]),d=p=>{const g=["fetching","analyzing","building","discovering","complete"],y=g.indexOf(a),x=g.indexOf(p);return x{};return f.jsx($,{open:n,onClose:h,size:"sm",bottomSheet:!1,children:f.jsx(B,{isLoading:!s,borderRadius:16,children:f.jsx(Y,{className:"p-6 radius-card overflow-hidden",children:s?f.jsxs("div",{className:"flex flex-col items-center py-6",children:[f.jsx(H.div,{variants:ce,initial:"hidden",animate:"visible",className:"w-16 h-16 rounded-full flex items-center justify-center mb-4 bg-sys-blue/20",children:f.jsx(R,{className:"w-8 h-8 text-sys-blue"})}),f.jsx("h3",{className:"type-micro text-sys-blue",children:"Ready!"}),f.jsx("button",{onClick:e,className:"mt-3 sm:hidden min-h-[44px] min-w-[44px] px-4 flex items-center justify-center text-[15px] font-medium text-sys-blue active:text-sys-blue/70 transition-base radius-inner active:bg-subtle-fill",children:"Done"})]}):f.jsxs(f.Fragment,{children:[f.jsxs("div",{className:"flex items-center gap-3 mb-5",children:[f.jsx("div",{className:"w-10 h-10 radius-inset flex items-center justify-center bg-sys-blue/15",children:f.jsx(C,{className:"w-5 h-5 text-sys-blue"})}),f.jsxs("div",{children:[f.jsx("h3",{className:"type-micro",children:"Deep Analysis"}),f.jsx("p",{className:"text-xs text-fg-muted",children:"Building mesh topology"})]})]}),f.jsxs("div",{className:"space-y-2",children:[f.jsx(j,{label:"Fetching Packets",icon:f.jsx(K,{className:"w-4 h-4"}),status:d("fetching"),detail:u}),f.jsx(j,{label:"Analyzing Database",icon:f.jsx(X,{className:"w-4 h-4"}),status:d("analyzing"),detail:"Processing packet paths"}),f.jsx(j,{label:"Building Topology",icon:f.jsx(C,{className:"w-4 h-4"}),status:d("building"),detail:"Computing mesh edges"}),f.jsx(j,{label:"Discovering Nodes",icon:f.jsx(Q,{className:"w-4 h-4"}),status:d("discovering"),detail:"Viterbi HMM ghost detection"})]}),f.jsx("p",{className:"text-xs text-fg-muted text-center mt-5",children:"This may take a few seconds..."})]})})})})}const $e=M.memo(we);export{$e as D,Ie as E,Se as G,Ae as M,Fe as a,A as b,Ve as c,De as d,qe as e,Q as f,C as g,Ge as h,ze as i,Oe as j,We as m,Re as s,Pe as t,Le as u}; diff --git a/frontend/dist/assets/Grid-DrJ5vfLo.js b/frontend/dist/assets/Grid-DknC4rR5.js similarity index 95% rename from frontend/dist/assets/Grid-DrJ5vfLo.js rename to frontend/dist/assets/Grid-DknC4rR5.js index 00092a51..67ba8dec 100644 --- a/frontend/dist/assets/Grid-DrJ5vfLo.js +++ b/frontend/dist/assets/Grid-DknC4rR5.js @@ -1 +1 @@ -import{r as b,j as c,c as d}from"./index-C1ZF7cAz.js";const g={hero:{mobile:12},"hero-tall":{mobile:12},"hero-auto":{mobile:12},panel:{mobile:12,md:6},feature:{mobile:12,md:6,lg:4},standard:{mobile:12,sm:6,lg:4,xl:3},compact:{mobile:6,lg:3},widget:{mobile:6,sm:4,md:3,lg:2},auto:{mobile:12}},p={hero:"bento-row-hero","hero-tall":"bento-row-hero-tall","hero-auto":"bento-row-hero-auto",panel:"bento-row-panel",feature:"bento-row-feature",standard:"bento-row-standard",compact:"bento-row-compact",widget:"bento-row-widget",auto:"bento-row-auto"};function w({template:o,children:r,className:e,gap:n}){const t=g[o],m=p[o],a=n==="none"?"gap-0":n==="sm"?"bento-gap-sm":n==="lg"?"bento-gap-lg":"bento-gap",i=b.Children.map(r,l=>!b.isValidElement(l)||l.type===u?l:c.jsx(u,{span:t.mobile,sm:t.sm,md:t.md,lg:t.lg,xl:t.xl,children:l}));return c.jsx("div",{className:d("bento-row",m,a,e),children:i})}function s(o,r=""){const e=r?`${r}:`:"";return o==="full"?`${e}col-span-full`:o==="auto"?`${e}col-auto`:o===1.5?`${e}bento-col-1-5`:`${e}bento-col-${o}`}function u({children:o,span:r,sm:e,md:n,lg:t,xl:m,ratio:a,className:i}){const l=d("bento-cell",s(r),e&&s(e,"sm"),n&&s(n,"md"),t&&s(t,"lg"),m&&s(m,"xl"),i);return c.jsx("div",{className:l,"data-ratio":a??void 0,style:a?{"--cell-ratio":a}:void 0,children:o})}export{u as C,w as R}; +import{r as b,j as c,c as d}from"./index-DhkG1Nx9.js";const g={hero:{mobile:12},"hero-tall":{mobile:12},"hero-auto":{mobile:12},panel:{mobile:12,md:6},feature:{mobile:12,md:6,lg:4},standard:{mobile:12,sm:6,lg:4,xl:3},compact:{mobile:6,lg:3},widget:{mobile:6,sm:4,md:3,lg:2},auto:{mobile:12}},p={hero:"bento-row-hero","hero-tall":"bento-row-hero-tall","hero-auto":"bento-row-hero-auto",panel:"bento-row-panel",feature:"bento-row-feature",standard:"bento-row-standard",compact:"bento-row-compact",widget:"bento-row-widget",auto:"bento-row-auto"};function w({template:o,children:r,className:e,gap:n}){const t=g[o],m=p[o],a=n==="none"?"gap-0":n==="sm"?"bento-gap-sm":n==="lg"?"bento-gap-lg":"bento-gap",i=b.Children.map(r,l=>!b.isValidElement(l)||l.type===u?l:c.jsx(u,{span:t.mobile,sm:t.sm,md:t.md,lg:t.lg,xl:t.xl,children:l}));return c.jsx("div",{className:d("bento-row",m,a,e),children:i})}function s(o,r=""){const e=r?`${r}:`:"";return o==="full"?`${e}col-span-full`:o==="auto"?`${e}col-auto`:o===1.5?`${e}bento-col-1-5`:`${e}bento-col-${o}`}function u({children:o,span:r,sm:e,md:n,lg:t,xl:m,ratio:a,className:i}){const l=d("bento-cell",s(r),e&&s(e,"sm"),n&&s(n,"md"),t&&s(t,"lg"),m&&s(m,"xl"),i);return c.jsx("div",{className:l,"data-ratio":a??void 0,style:a?{"--cell-ratio":a}:void 0,children:o})}export{u as C,w as R}; diff --git a/frontend/dist/assets/KeycapButton-DkbJ4iVA.js b/frontend/dist/assets/KeycapButton-xjzZCjhU.js similarity index 98% rename from frontend/dist/assets/KeycapButton-DkbJ4iVA.js rename to frontend/dist/assets/KeycapButton-xjzZCjhU.js index 756832ff..e9b0c01d 100644 --- a/frontend/dist/assets/KeycapButton-DkbJ4iVA.js +++ b/frontend/dist/assets/KeycapButton-xjzZCjhU.js @@ -1 +1 @@ -import{r as l,j as t,Z as O}from"./index-C1ZF7cAz.js";import{b as F,c as x}from"./keycap-sfx-ByZp-njj.js";const R={a:"24,3 76,3 83,7 76,11 24,11 17,7",b:"88,22 93,27 93,71 88,76 83,71 83,27",c:"88,106 93,111 93,155 88,160 83,155 83,111",d:"24,171 76,171 83,175 76,179 24,179 17,175",e:"12,106 17,111 17,155 12,160 7,155 7,111",f:"12,22 17,27 17,71 12,76 7,71 7,27",g:"24,86 76,86 83,91 76,96 24,96 17,91"},w=Object.keys(R),N={0:"abcdef",1:"bc",2:"abdeg",3:"abcdg",4:"bcfg",5:"acdfg",6:"acdefg",7:"abc",8:"abcdefg",9:"abcdfg",A:"abcefg",B:"cdefg",C:"adef",D:"bcdeg",E:"adefg",F:"aefg",G:"acdef",H:"bcefg",I:"ef",J:"bcde",L:"def",M:"abcefg",N:"ceg",O:"abcdef",P:"abefg",Q:"abcfg",R:"eg",S:"acdfg",T:"defg",U:"bcdef",V:"cde",Y:"bcdfg",Z:"abdeg",a:"abcefg",b:"cdefg",c:"deg",d:"bcdeg",e:"adefg",f:"aefg",g:"abcdfg",h:"cefg",i:"c",j:"bcde",l:"def",m:"abcef",n:"ceg",o:"cdeg",p:"abefg",r:"eg",s:"acdfg",t:"defg",u:"cde",v:"cde",y:"bcdfg"," ":"",_:"d","-":"g","=":"dg","°":"abfg",'"':"bf","'":"f","(":"adef",")":"abcd","[":"adef","]":"abcd","!":"bc",".":"d"},C=6,D=56,L=2;function B(){return w.filter(()=>Math.random()>.45).join("")}function $(r,i){const n=Array.from(r).map(a=>N[a.toUpperCase()]??N[a]??""),d=Math.max(0,(i??0)-r.length);for(let a=0;a{if(a)return;const e=$(r,d),o=e.length,g=C+(o-1)*L;let y=0,b,E=!1;const k=()=>{if(!E){if(y++,y>=g){f(null);return}f(e.map((j,_)=>{const v=C+_*L;return y>=v?j:B()})),b=setTimeout(k,D)}};return k(),()=>{E=!0,clearTimeout(b)}},[r,d,a]);const c=(e,o)=>t.jsx("svg",{viewBox:"0 0 100 182",width:h,height:n,className:"seven-seg__char","aria-hidden":"true",children:w.map(g=>t.jsx("polygon",{points:R[g],fill:i,stroke:i,strokeWidth:4,strokeLinejoin:"round",opacity:e.includes(g)?1:M},g))},o),s=$(r,d),u=T??s;return t.jsxs("span",{className:`seven-seg${S?` ${S}`:""}`,children:[u.map((e,o)=>c(e,`${o}-${e}`)),t.jsx("span",{className:"sr-only",children:r})]})}const G={grey:"/assets/keycap.svg",red:"/assets/keycap-red.svg"},I=O[900],P="#FFDEB0";function Z({icon:r,variant:i="grey",onClick:n,onPress:d,sentDuration:a=2e3,title:S,disabled:h=!1,className:m,iconColor:M=I,iconActiveColor:T=P,indicators:f}){const c=!!d,[s,u]=l.useState("idle"),[e,o]=l.useState(!1),g=l.useRef(),y=c?s==="held":e,b=c&&(s==="sending"||s==="sent"),E=c?s==="held"||s==="sending":e;l.useEffect(()=>()=>clearTimeout(g.current),[]);const k=l.useCallback(()=>{h||b||(F(),c?u("held"):o(!0))},[h,b,c]),j=l.useCallback(async()=>{if(c){if(s!=="held")return;x(),u("sending");const p=await d();u(p?"sent":"idle"),p&&(g.current=setTimeout(()=>u("idle"),a))}else{if(!e)return;o(!1),x(),n==null||n()}},[c,s,d,a,e,n]),_=l.useCallback(()=>{c?s==="held"&&(x(),u("idle")):(e&&x(),o(!1))},[c,s,e]),v=t.jsx("button",{onMouseDown:k,onMouseUp:j,onMouseLeave:_,onTouchStart:k,onTouchEnd:j,onTouchCancel:_,disabled:h||b,className:`keycap-btn${i==="red"?" keycap-btn--red-cap":""}${E?" keycap-btn--pressed":""}${m&&!f?` ${m}`:""}`,title:S,children:t.jsxs("div",{className:"keycap-wrap",children:[t.jsx("img",{src:G[i],alt:"",className:"keycap-btn__img",draggable:!1}),t.jsx("span",{className:"keycap-icon-overlay",style:{color:y||s==="sending"?T:M},children:r})]})});return f!=null&&f.length?t.jsxs("div",{className:`keycap-group${m?` ${m}`:""}`,children:[v,t.jsx("div",{className:"indicator-key-pair",children:f.map(p=>{const A=p.trackPress?s:p.active?"active":"idle";return t.jsxs("div",{className:`indicator-key${A!=="idle"?` indicator-key--${A}`:""}`,children:[t.jsx("span",{className:"indicator-key__label",children:p.label}),t.jsx("span",{className:"indicator-key__led"})]},p.label)})})]}):v}export{Z as K,Y as S}; +import{r as l,j as t,Z as O}from"./index-DhkG1Nx9.js";import{b as F,c as x}from"./keycap-sfx-ByZp-njj.js";const R={a:"24,3 76,3 83,7 76,11 24,11 17,7",b:"88,22 93,27 93,71 88,76 83,71 83,27",c:"88,106 93,111 93,155 88,160 83,155 83,111",d:"24,171 76,171 83,175 76,179 24,179 17,175",e:"12,106 17,111 17,155 12,160 7,155 7,111",f:"12,22 17,27 17,71 12,76 7,71 7,27",g:"24,86 76,86 83,91 76,96 24,96 17,91"},w=Object.keys(R),N={0:"abcdef",1:"bc",2:"abdeg",3:"abcdg",4:"bcfg",5:"acdfg",6:"acdefg",7:"abc",8:"abcdefg",9:"abcdfg",A:"abcefg",B:"cdefg",C:"adef",D:"bcdeg",E:"adefg",F:"aefg",G:"acdef",H:"bcefg",I:"ef",J:"bcde",L:"def",M:"abcefg",N:"ceg",O:"abcdef",P:"abefg",Q:"abcfg",R:"eg",S:"acdfg",T:"defg",U:"bcdef",V:"cde",Y:"bcdfg",Z:"abdeg",a:"abcefg",b:"cdefg",c:"deg",d:"bcdeg",e:"adefg",f:"aefg",g:"abcdfg",h:"cefg",i:"c",j:"bcde",l:"def",m:"abcef",n:"ceg",o:"cdeg",p:"abefg",r:"eg",s:"acdfg",t:"defg",u:"cde",v:"cde",y:"bcdfg"," ":"",_:"d","-":"g","=":"dg","°":"abfg",'"':"bf","'":"f","(":"adef",")":"abcd","[":"adef","]":"abcd","!":"bc",".":"d"},C=6,D=56,L=2;function B(){return w.filter(()=>Math.random()>.45).join("")}function $(r,i){const n=Array.from(r).map(a=>N[a.toUpperCase()]??N[a]??""),d=Math.max(0,(i??0)-r.length);for(let a=0;a{if(a)return;const e=$(r,d),o=e.length,g=C+(o-1)*L;let y=0,b,E=!1;const k=()=>{if(!E){if(y++,y>=g){f(null);return}f(e.map((j,_)=>{const v=C+_*L;return y>=v?j:B()})),b=setTimeout(k,D)}};return k(),()=>{E=!0,clearTimeout(b)}},[r,d,a]);const c=(e,o)=>t.jsx("svg",{viewBox:"0 0 100 182",width:h,height:n,className:"seven-seg__char","aria-hidden":"true",children:w.map(g=>t.jsx("polygon",{points:R[g],fill:i,stroke:i,strokeWidth:4,strokeLinejoin:"round",opacity:e.includes(g)?1:M},g))},o),s=$(r,d),u=T??s;return t.jsxs("span",{className:`seven-seg${S?` ${S}`:""}`,children:[u.map((e,o)=>c(e,`${o}-${e}`)),t.jsx("span",{className:"sr-only",children:r})]})}const G={grey:"/assets/keycap.svg",red:"/assets/keycap-red.svg"},I=O[900],P="#FFDEB0";function Z({icon:r,variant:i="grey",onClick:n,onPress:d,sentDuration:a=2e3,title:S,disabled:h=!1,className:m,iconColor:M=I,iconActiveColor:T=P,indicators:f}){const c=!!d,[s,u]=l.useState("idle"),[e,o]=l.useState(!1),g=l.useRef(),y=c?s==="held":e,b=c&&(s==="sending"||s==="sent"),E=c?s==="held"||s==="sending":e;l.useEffect(()=>()=>clearTimeout(g.current),[]);const k=l.useCallback(()=>{h||b||(F(),c?u("held"):o(!0))},[h,b,c]),j=l.useCallback(async()=>{if(c){if(s!=="held")return;x(),u("sending");const p=await d();u(p?"sent":"idle"),p&&(g.current=setTimeout(()=>u("idle"),a))}else{if(!e)return;o(!1),x(),n==null||n()}},[c,s,d,a,e,n]),_=l.useCallback(()=>{c?s==="held"&&(x(),u("idle")):(e&&x(),o(!1))},[c,s,e]),v=t.jsx("button",{onMouseDown:k,onMouseUp:j,onMouseLeave:_,onTouchStart:k,onTouchEnd:j,onTouchCancel:_,disabled:h||b,className:`keycap-btn${i==="red"?" keycap-btn--red-cap":""}${E?" keycap-btn--pressed":""}${m&&!f?` ${m}`:""}`,title:S,children:t.jsxs("div",{className:"keycap-wrap",children:[t.jsx("img",{src:G[i],alt:"",className:"keycap-btn__img",draggable:!1}),t.jsx("span",{className:"keycap-icon-overlay",style:{color:y||s==="sending"?T:M},children:r})]})});return f!=null&&f.length?t.jsxs("div",{className:`keycap-group${m?` ${m}`:""}`,children:[v,t.jsx("div",{className:"indicator-key-pair",children:f.map(p=>{const A=p.trackPress?s:p.active?"active":"idle";return t.jsxs("div",{className:`indicator-key${A!=="idle"?` indicator-key--${A}`:""}`,children:[t.jsx("span",{className:"indicator-key__label",children:p.label}),t.jsx("span",{className:"indicator-key__led"})]},p.label)})})]}):v}export{Z as K,Y as S}; diff --git a/frontend/dist/assets/LightSparkline-7x8sYJi9.js b/frontend/dist/assets/LightSparkline-Bg_XrgTS.js similarity index 96% rename from frontend/dist/assets/LightSparkline-7x8sYJi9.js rename to frontend/dist/assets/LightSparkline-Bg_XrgTS.js index fbcbed8a..b8a4a9eb 100644 --- a/frontend/dist/assets/LightSparkline-7x8sYJi9.js +++ b/frontend/dist/assets/LightSparkline-Bg_XrgTS.js @@ -1 +1 @@ -import{r as m,j as u}from"./index-C1ZF7cAz.js";const a="var(--sparkline-critical)",C="var(--sparkline-poor)",L="var(--sparkline-fair)",g="var(--sparkline-good)",y="var(--sparkline-excellent)",$="var(--fg-muted)";function j(o){if(o.length===0)return a;const r=o.slice(-4),e=r.reduce((t,c)=>t+c.count,0),n=e/r.length,l=o.reduce((t,c)=>t+c.count,0)/o.length;if(e===0)return a;if(l>0){const t=n/l;return t>=1.2?y:t>=.8?g:t>=.4?L:t>=.1?C:a}return e>=10?y:e>=5?g:e>=2?L:e>=1?C:a}function h(o,r,e,n=2){if(o.length<2)return"";const s=o.map(i=>i.count),l=Math.max(...s,1),t=Math.min(...s),c=l-t||1,p=r-n*2,O=e-n*2,x=s.map((i,f)=>({x:n+f/(s.length-1)*p,y:n+O-(i-t)/c*O}));let k=`M ${x[0].x.toFixed(1)} ${x[0].y.toFixed(1)}`;for(let i=1;ih(r,e,n),[r,e,n]),p=m.useMemo(()=>s??(r.length>0?j(r):$),[s,r]);return l&&r.length<2?u.jsx("div",{className:`flex items-center justify-center ${t}`,style:{width:e,height:n},children:u.jsx("div",{className:"rounded animate-pulse bg-subtle-fill-hover",style:{width:e-8,height:n-6}})}):r.length<2?u.jsx("svg",{width:e,height:n,viewBox:`0 0 ${e} ${n}`,className:t,"aria-hidden":"true",children:u.jsx("line",{x1:4,y1:n/2,x2:e-4,y2:n/2,stroke:a,strokeWidth:1.5,strokeDasharray:"3,2"})}):u.jsx("svg",{width:e,height:n,viewBox:`0 0 ${e} ${n}`,preserveAspectRatio:"none",className:t,"aria-hidden":"true",style:{maxWidth:"100%"},children:u.jsx("path",{d:c,fill:"none",stroke:p,strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round",vectorEffect:"non-scaling-stroke"})})});export{A as L}; +import{r as m,j as u}from"./index-DhkG1Nx9.js";const a="var(--sparkline-critical)",C="var(--sparkline-poor)",L="var(--sparkline-fair)",g="var(--sparkline-good)",y="var(--sparkline-excellent)",$="var(--fg-muted)";function j(o){if(o.length===0)return a;const r=o.slice(-4),e=r.reduce((t,c)=>t+c.count,0),n=e/r.length,l=o.reduce((t,c)=>t+c.count,0)/o.length;if(e===0)return a;if(l>0){const t=n/l;return t>=1.2?y:t>=.8?g:t>=.4?L:t>=.1?C:a}return e>=10?y:e>=5?g:e>=2?L:e>=1?C:a}function h(o,r,e,n=2){if(o.length<2)return"";const s=o.map(i=>i.count),l=Math.max(...s,1),t=Math.min(...s),c=l-t||1,p=r-n*2,O=e-n*2,x=s.map((i,f)=>({x:n+f/(s.length-1)*p,y:n+O-(i-t)/c*O}));let k=`M ${x[0].x.toFixed(1)} ${x[0].y.toFixed(1)}`;for(let i=1;ih(r,e,n),[r,e,n]),p=m.useMemo(()=>s??(r.length>0?j(r):$),[s,r]);return l&&r.length<2?u.jsx("div",{className:`flex items-center justify-center ${t}`,style:{width:e,height:n},children:u.jsx("div",{className:"rounded animate-pulse bg-subtle-fill-hover",style:{width:e-8,height:n-6}})}):r.length<2?u.jsx("svg",{width:e,height:n,viewBox:`0 0 ${e} ${n}`,className:t,"aria-hidden":"true",children:u.jsx("line",{x1:4,y1:n/2,x2:e-4,y2:n/2,stroke:a,strokeWidth:1.5,strokeDasharray:"3,2"})}):u.jsx("svg",{width:e,height:n,viewBox:`0 0 ${e} ${n}`,preserveAspectRatio:"none",className:t,"aria-hidden":"true",style:{maxWidth:"100%"},children:u.jsx("path",{d:c,fill:"none",stroke:p,strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round",vectorEffect:"non-scaling-stroke"})})});export{A as L}; diff --git a/frontend/dist/assets/Login-D-EHt21j.js b/frontend/dist/assets/Login-CuxVgn1B.js similarity index 99% rename from frontend/dist/assets/Login-D-EHt21j.js rename to frontend/dist/assets/Login-CuxVgn1B.js index 0a249cb5..66078e6c 100644 --- a/frontend/dist/assets/Login-D-EHt21j.js +++ b/frontend/dist/assets/Login-CuxVgn1B.js @@ -1,3 +1,3 @@ -import{r as o,j as e,u as F,g as Y,i as $,s as Z,l as X,m as L,a as q,b as S,c as H,I as A,C as O,A as z,B as U,Z as V}from"./index-C1ZF7cAz.js";import{g as T,B as G,r as K,T as J}from"./ascii-burst-DN6etEs5.js";const w=["@@@@@@@ @@@ @@@ @@@@@@@@@@ @@@@@@@ ","@@@@@@@@ @@@ @@@ @@@@@@@@@@@ @@@@@@@@ ","@@! @@@ @@! !@@ @@! @@! @@! !@@ ","!@! @!@ !@! @!! !@! !@! !@! !@! ","@!@@!@! !@!@! @!! !!@ @!@ !@! ","!!@!!! @!!! !@! ! !@! !!! ","!!: !!: !!: !!: :!! ",":!: :!: :!: :!: :!: "," :: :: ::: :: ::: ::: "," : : : : :: :: : "],Q=J-1,ee=w.length,te=Math.max(...w.map(s=>s.length)),se=.994,ne=.08,re=.25,ae=8,oe=9.6,ie=20,W=.008,k=20,_=" . ˙·∙⁺˚°:;~*+✧✩×✴░✦✶✳oO▒#%&xX▓@MW8B█████",ce={" ":0,".":.08,":":.15,"!":.5,"@":.85,"#":.6,$:.7,"%":.65,"&":.6,"*":.3,"+":.25,"-":.1,"=":.2,_:.05,"~":.2,"^":.15,"|":.4,"/":.3,"\\":.3,"(":.35,")":.35,"[":.4,"]":.4,"{":.45,"}":.45,"<":.3,">":.3,"?":.4,";":.2,"'":.1,'"':.15,",":.08,"`":.05};function le(s){let t="",n=0,a=!1,x="",p=!1,l=!1,g=!1;for(;n",a=!1),x="",p=!1,l=!1,g=!1;else if(u==="1")p=!0,g=!0;else if(u==="2")l=!0,g=!0;else if(u.startsWith("38;2;")){const C=u.split(";");x=`rgb(${C[2]},${C[3]},${C[4]})`,g=!0}}else{if(g){a&&(t+="");const u=[];x&&u.push(`color:${x}`),p&&u.push("font-weight:700"),l&&u.push("opacity:0.6"),u.length>0?(t+=``,a=!0):a=!1,g=!1}const h=s[n];h==="<"?t+="<":h===">"?t+=">":h==="&"?t+="&":t+=h,n++}return a&&(t+=""),t}function P(s){let t="";for(let n=0;n0&&(t+=` +import{r as o,j as e,u as F,g as Y,i as $,s as Z,l as X,m as L,a as q,b as S,c as H,I as A,C as O,A as z,B as U,Z as V}from"./index-DhkG1Nx9.js";import{g as T,B as G,r as K,T as J}from"./ascii-burst-DN6etEs5.js";const w=["@@@@@@@ @@@ @@@ @@@@@@@@@@ @@@@@@@ ","@@@@@@@@ @@@ @@@ @@@@@@@@@@@ @@@@@@@@ ","@@! @@@ @@! !@@ @@! @@! @@! !@@ ","!@! @!@ !@! @!! !@! !@! !@! !@! ","@!@@!@! !@!@! @!! !!@ @!@ !@! ","!!@!!! @!!! !@! ! !@! !!! ","!!: !!: !!: !!: :!! ",":!: :!: :!: :!: :!: "," :: :: ::: :: ::: ::: "," : : : : :: :: : "],Q=J-1,ee=w.length,te=Math.max(...w.map(s=>s.length)),se=.994,ne=.08,re=.25,ae=8,oe=9.6,ie=20,W=.008,k=20,_=" . ˙·∙⁺˚°:;~*+✧✩×✴░✦✶✳oO▒#%&xX▓@MW8B█████",ce={" ":0,".":.08,":":.15,"!":.5,"@":.85,"#":.6,$:.7,"%":.65,"&":.6,"*":.3,"+":.25,"-":.1,"=":.2,_:.05,"~":.2,"^":.15,"|":.4,"/":.3,"\\":.3,"(":.35,")":.35,"[":.4,"]":.4,"{":.45,"}":.45,"<":.3,">":.3,"?":.4,";":.2,"'":.1,'"':.15,",":.08,"`":.05};function le(s){let t="",n=0,a=!1,x="",p=!1,l=!1,g=!1;for(;n",a=!1),x="",p=!1,l=!1,g=!1;else if(u==="1")p=!0,g=!0;else if(u==="2")l=!0,g=!0;else if(u.startsWith("38;2;")){const C=u.split(";");x=`rgb(${C[2]},${C[3]},${C[4]})`,g=!0}}else{if(g){a&&(t+="");const u=[];x&&u.push(`color:${x}`),p&&u.push("font-weight:700"),l&&u.push("opacity:0.6"),u.length>0?(t+=``,a=!0):a=!1,g=!1}const h=s[n];h==="<"?t+="<":h===">"?t+=">":h==="&"?t+="&":t+=h,n++}return a&&(t+=""),t}function P(s){let t="";for(let n=0;n0&&(t+=` `),t+=le(s[n]);return t}const ue="rgb(91,91,214)",y=[[91,91,214],[72,70,200],[110,110,230],[150,150,245],[190,210,255],[0,240,255],[255,50,180],[80,255,180]];function R(s,t,n){return`rgb(${Math.round(s[0]+(t[0]-s[0])*n)},${Math.round(s[1]+(t[1]-s[1])*n)},${Math.round(s[2]+(t[2]-s[2])*n)})`}function de(s){const t=Math.max(0,Math.min(.999,s));return _[Math.floor(t*_.length)]}function me(s){return ce[s]??.5}function he(s,t){const n=Math.abs(s);if(n<.3)return R(y[0],y[2],n/.3);if(n<.6){const a=(n-.3)/.3;return R(y[3],y[4],a)}else{const a=Math.sin(t*17.3)*.5+.5;return a<.4?R(y[4],y[5],(n-.6)/.4):a<.6?`rgb(${y[6].join(",")})`:a<.7?`rgb(${y[7].join(",")})`:"rgb(255,252,255)"}}function I(s){let t="";for(let n=0;n0&&(t+=` `);const a=w[n]||"";for(let x=0;x0?Math.exp(-m*m/2):Math.exp(-m*m/12),j=c*re-C.radius*.4,M=Math.sin(j*Math.PI),d=b*C.strength;l+=b*M*C.strength,d>h&&(h=d,g=j+n*.1+x*.05)}if(l=Math.max(-1,Math.min(1,l)),Math.abs(l)${p}`;else{const r=me(p)+l*.5,i=Math.max(.02,Math.min(.98,r)),c=de(i),f=he(l,g);t+=`${c}`}}}return t}function Ce(){const s=o.useRef(null),t=o.useRef([]),n=o.useRef(0),[a,x]=o.useState(!1);o.useEffect(()=>{const r=s.current;if(!r)return;let i=0;r.innerHTML=P(T(w,0));const c=setInterval(()=>{if(i++,i>Q){clearInterval(c),x(!0);return}r.innerHTML=P(T(w,i))},G);return()=>{clearInterval(c),K()}},[]),o.useEffect(()=>{if(!a)return;const r=s.current;if(!r)return;let i=!0;const c=()=>{if(!i)return;const f=t.current;for(const m of f)m.radius+=ne,m.strength*=se;t.current=f.filter(m=>m.strength>W),t.current.length>0?r.innerHTML=I(t.current):r.innerHTML=I([]),n.current=requestAnimationFrame(c)};return n.current=requestAnimationFrame(c),()=>{i=!1,cancelAnimationFrame(n.current)}},[a]);const p=o.useRef(null),l=o.useCallback((r,i,c=1)=>{const f=s.current;if(!f||!a)return;const m=f.getBoundingClientRect(),b=r-m.left,j=i-m.top,M=b/oe,d=j/ie;t.current.length>=ae&&t.current.shift(),t.current.push({cx:M,cy:d,radius:0,strength:c}),p.current={x:r,y:i}},[a]),g=o.useCallback(r=>{const i=p.current;if(i){const c=r.clientX-i.x,f=r.clientY-i.y;if(Math.sqrt(c*c+f*f){l(r.clientX,r.clientY,1)},[l]),u=o.useCallback(r=>{p.current=null,l(r.clientX,r.clientY,.6)},[l]),C=o.useCallback(r=>{if(r.touches.length>0){const i=r.touches[0],c=p.current;if(c){const f=i.clientX-c.x,m=i.clientY-c.y;if(Math.sqrt(f*f+m*m)e.jsx("span",{className:"text-white/20 text-xs","aria-hidden":"true",children:"•"}),be=o.memo(function(){return e.jsx("div",{className:"fixed inset-0 -z-10",style:{backgroundColor:V[950]},"aria-hidden":"true"})}),ve=o.memo(function(){return e.jsxs(L.footer,{variants:v.footer,initial:"hidden",animate:"visible",className:"fixed bottom-0 inset-x-0 px-4 py-6",children:[e.jsx("p",{className:"text-center type-badge text-white/40 mb-3",children:"Powered By"}),e.jsx("div",{className:"mx-auto max-w-xs",children:e.jsxs("div",{className:"flex items-center justify-center gap-4",children:[e.jsx(E,{href:"https://github.com/rightup/pyMC_Repeater",children:e.jsx("img",{src:Le,alt:"pyMC",className:"h-14"})}),e.jsx(D,{}),e.jsx(E,{href:"https://meshcore.co.uk",children:e.jsx(xe,{height:12,className:"text-white"})}),e.jsx(D,{}),e.jsxs(E,{href:"https://wcmesh.com",children:[e.jsx("div",{className:"size-14 overflow-hidden radius-badge border border-white/10 -translate-y-1",children:e.jsx("img",{src:ge,alt:"",className:"size-full object-cover"})}),e.jsx("span",{className:"font-mono text-sm font-semibold tracking-tight text-white",children:"WCM"})]})]})})]})}),je={session_expired:"Your session has expired. Please sign in again.",no_token:"Authentication required. Please sign in.",token_expired_away:"Your session expired while you were away."};function Ne(){const s=F(),[t,n]=o.useState("admin"),[a,x]=o.useState(""),[p,l]=o.useState(Y),[g,h]=o.useState(!1),[u,C]=o.useState(null),[r]=o.useState(()=>{try{const d=sessionStorage.getItem("auth_redirect_reason");return sessionStorage.removeItem("auth_redirect_reason"),d?je[d]??null:null}catch{return null}}),i=t.length>0&&a.length>0&&!g;o.useEffect(()=>{$()&&s("/",{replace:!0})},[s]);const c=o.useCallback(()=>C(null),[]),f=o.useCallback(d=>{n(d.target.value),u&&c()},[u,c]),m=o.useCallback(d=>{x(d.target.value),u&&c()},[u,c]),b=o.useCallback(d=>{l(d),Z(d)},[]),j=o.useCallback(async d=>{if(d.preventDefault(),!i)return;h(!0),C(null);const N=await X(t,a,p);h(!1),N.success?window.location.href="/":C(N.error??"Login failed")},[i,t,a,p]),M=o.useCallback(d=>{d.key==="Enter"&&i&&d.target.tagName==="INPUT"&&(d.preventDefault(),d.currentTarget.requestSubmit())},[i]);return e.jsxs(e.Fragment,{children:[e.jsx(be,{}),e.jsx("main",{className:"flex min-h-svh items-center justify-center px-4 py-6 sm:px-6 lg:px-8 -mt-6",children:e.jsxs(L.div,{variants:v.container,initial:"hidden",animate:"visible",className:"w-full max-w-sm space-y-10",children:[e.jsx(L.div,{variants:v.item,className:"flex justify-center",children:e.jsx(fe,{})}),r&&!u&&e.jsx(L.div,{variants:v.item,className:"rounded-md bg-sys-amber/10 px-3 py-2.5 text-center",children:e.jsx("p",{className:"text-sm text-sys-amber",children:r})}),e.jsxs(L.form,{variants:v.item,onSubmit:j,onKeyDown:M,className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"username",className:B,children:"Username"}),e.jsx("div",{className:"mt-2",children:e.jsx(A,{id:"username",name:"username",type:"text",value:t,onChange:f,required:!0,autoComplete:"username",className:"font-mono text-sm font-semibold"})})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"password",className:B,children:"Password"}),e.jsx("div",{className:"mt-2",children:e.jsx(A,{id:"password",name:"password",type:"password",value:a,onChange:m,required:!0,autoComplete:"current-password",autoFocus:!0,className:"font-mono text-sm font-semibold"})})]}),e.jsx("div",{className:"-mt-2",children:e.jsx(O,{checked:p,onChange:b,label:e.jsx("span",{className:"type-badge text-fg-secondary",children:"Remember me"}),size:"sm"})}),e.jsx(z,{mode:"wait",children:u&&e.jsx(L.div,{variants:v.error,initial:"hidden",animate:"visible",exit:"exit",role:"alert",className:"rounded-md bg-sys-red/10 p-3 overflow-hidden",children:e.jsx("p",{className:"text-sm text-sys-red text-center",children:u})},"error")}),e.jsx(L.div,{whileTap:i?{scale:.98}:void 0,children:e.jsx(U,{type:"submit",disabled:!i,className:"w-full py-3 radius-pill font-mono text-sm font-semibold uppercase tracking-wide text-white bg-sys-indigo hover:bg-sys-blue shadow-sm transition-colors",children:g?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(ye,{className:"size-4"}),"Signing in…"]}):"Sign in"})})]}),e.jsxs(L.p,{variants:v.item,className:"text-center text-sm/6 text-fg-muted",children:["A ",e.jsx("span",{className:"text-sys-blue",children:"@RightUp"})," X"," ",e.jsx("span",{className:"text-sys-blue",children:"@Treehouse⚡"})," Collab"]})]})}),e.jsx(ve,{})]})}export{Ne as default}; diff --git a/frontend/dist/assets/Logs-DCoWCYrQ.js b/frontend/dist/assets/Logs-DCoWCYrQ.js deleted file mode 100644 index d938424c..00000000 --- a/frontend/dist/assets/Logs-DCoWCYrQ.js +++ /dev/null @@ -1,11 +0,0 @@ -import{d as g,db as y,dc as f,D as j,dd as L,de as v,r as o,df as N,j as e,dg as m,F as w,B as b,c as n,dh as k,d0 as C,m as S,di as E}from"./index-C1ZF7cAz.js";import{P,a as R,B,C as I}from"./PageLayout-sd81yog0.js";/** - * @license lucide-react v0.559.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const D=[["path",{d:"M9 9.003a1 1 0 0 1 1.517-.859l4.997 2.997a1 1 0 0 1 0 1.718l-4.997 2.997A1 1 0 0 1 9 14.996z",key:"kmsa83"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],M=g("circle-play",D);/** - * @license lucide-react v0.559.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const T=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["rect",{x:"9",y:"9",width:"6",height:"6",rx:"1",key:"1ssd4o"}]],_=g("circle-stop",T),F=o.memo(function({log:t}){return e.jsx(S.div,{initial:{opacity:0,y:6},animate:{opacity:1,y:0},transition:{duration:.15,ease:"easeOut"},className:"p-3 bg-subtle-fill/80 radius-inner depth-stroke-raised hover:bg-subtle-fill-strong transition-base",children:e.jsxs("div",{className:"flex items-baseline gap-3",children:[e.jsx("span",{className:n("type-data-sm w-14 shrink-0",E(t.level)),children:t.level}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"type-data-sm text-fg-primary break-words whitespace-pre-wrap",children:t.message}),e.jsx("p",{className:"type-data-xs text-fg-muted mt-1",children:new Date(t.timestamp).toLocaleString()})]})]})})});function G({showDebug:s,onToggle:t}){return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:n("type-data-sm",s?"text-sys-orange":"text-sys-cyan"),children:s?"DEBUG":"INFO"}),e.jsx(C,{enabled:s,onChange:t,size:"sm"})]})}function $(){const s=y(),t=f(),c=j(),i=L(),x=v(),[r,h]=o.useState(!1),u=o.useCallback(()=>{h(a=>!a)},[]),d=r?s:s.filter(a=>a.level!=="DEBUG"),l=o.useRef(i);return l.current=i,o.useEffect(()=>{if(!c)return;l.current();const a=setInterval(()=>l.current(),N.logs);return()=>clearInterval(a)},[c]),e.jsxs(P,{children:[e.jsx(R,{title:"System Logs",icon:e.jsx(m,{}),controls:e.jsx(G,{showDebug:r,onToggle:u})}),e.jsx(B,{children:e.jsxs(I,{neomorphic:!0,noPadding:!0,children:[e.jsx(w,{listHeader:!0,icon:e.jsx(m,{className:"icon-sm"}),title:"Log Entries",actions:e.jsx(b,{plain:!0,color:c?"danger":"primary",onClick:()=>x(!c),title:c?"Pause":"Resume",className:n(!c&&"animate-pulse-slow"),children:c?e.jsx(_,{"data-slot":"icon",className:"!w-5 !h-5"}):e.jsx(M,{"data-slot":"icon",className:"!w-5 !h-5"})})}),e.jsx("div",{className:"space-y-2 max-h-[calc(100dvh-226px)] sm:max-h-[calc(100dvh-234px)] lg:max-h-[calc(100vh-194px)] overflow-y-auto p-4",children:t&&s.length===0?e.jsx(k,{count:10}):d.length===0?e.jsx("div",{className:"text-center py-12 text-fg-muted",children:s.length===0?"No logs available":"No logs match selected filters"}):d.map((a,p)=>e.jsx(F,{log:a},`${a.timestamp}-${p}`))})]})})]})}export{$ as default}; diff --git a/frontend/dist/assets/Logs-QOsvXA_J.js b/frontend/dist/assets/Logs-QOsvXA_J.js new file mode 100644 index 00000000..e3a21b1e --- /dev/null +++ b/frontend/dist/assets/Logs-QOsvXA_J.js @@ -0,0 +1,11 @@ +import{d as g,d8 as y,d9 as f,F as j,da as L,db as v,r as o,dc as N,j as e,dd as m,H as w,B as b,c as n,de as k,c_ as C,m as S,df as E}from"./index-DhkG1Nx9.js";import{P,a as R,B,C as I}from"./PageLayout-BkUTZXJb.js";/** + * @license lucide-react v0.559.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const _=[["path",{d:"M9 9.003a1 1 0 0 1 1.517-.859l4.997 2.997a1 1 0 0 1 0 1.718l-4.997 2.997A1 1 0 0 1 9 14.996z",key:"kmsa83"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],M=g("circle-play",_);/** + * @license lucide-react v0.559.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const T=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["rect",{x:"9",y:"9",width:"6",height:"6",rx:"1",key:"1ssd4o"}]],D=g("circle-stop",T),F=o.memo(function({log:a}){return e.jsx(S.div,{initial:{opacity:0,y:6},animate:{opacity:1,y:0},transition:{duration:.15,ease:"easeOut"},className:"p-3 bg-subtle-fill/80 radius-inner depth-stroke-raised hover:bg-subtle-fill-strong transition-base",children:e.jsxs("div",{className:"flex items-baseline gap-3",children:[e.jsx("span",{className:n("type-data-sm w-14 shrink-0",E(a.level)),children:a.level}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"type-data-sm text-fg-primary break-words whitespace-pre-wrap",children:a.message}),e.jsx("p",{className:"type-data-xs text-fg-muted mt-1",children:new Date(a.timestamp).toLocaleString()})]})]})})});function H({showDebug:s,onToggle:a}){return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:n("type-data-sm",s?"text-sys-orange":"text-sys-cyan"),children:s?"DEBUG":"INFO"}),e.jsx(C,{enabled:s,onChange:a,size:"sm"})]})}function $(){const s=y(),a=f(),c=j(),i=L(),x=v(),[r,u]=o.useState(!1),h=o.useCallback(()=>{u(t=>!t)},[]),d=r?s:s.filter(t=>t.level!=="DEBUG"),l=o.useRef(i);return l.current=i,o.useEffect(()=>{if(!c)return;l.current();const t=setInterval(()=>l.current(),N.logs);return()=>clearInterval(t)},[c]),e.jsxs(P,{children:[e.jsx(R,{title:"System Logs",icon:e.jsx(m,{}),controls:e.jsx(H,{showDebug:r,onToggle:h})}),e.jsx(B,{ready:!0,children:e.jsxs(I,{neomorphic:!0,noPadding:!0,children:[e.jsx(w,{listHeader:!0,icon:e.jsx(m,{className:"icon-sm"}),title:"Log Entries",actions:e.jsx(b,{plain:!0,color:c?"danger":"primary",onClick:()=>x(!c),title:c?"Pause":"Resume",className:n(!c&&"animate-pulse-slow"),children:c?e.jsx(D,{"data-slot":"icon",className:"!w-5 !h-5"}):e.jsx(M,{"data-slot":"icon",className:"!w-5 !h-5"})})}),e.jsx("div",{className:"space-y-2 max-h-[calc(100dvh-226px)] sm:max-h-[calc(100dvh-234px)] lg:max-h-[calc(100vh-194px)] overflow-y-auto p-4",children:a&&s.length===0?e.jsx(k,{count:10}):d.length===0?e.jsx("div",{className:"text-center py-12 text-fg-muted",children:s.length===0?"No logs available":"No logs match selected filters"}):d.map((t,p)=>e.jsx(F,{log:t},`${t.timestamp}-${p}`))})]})})]})}export{$ as default}; diff --git a/frontend/dist/assets/MeshGraph-BrJ2t6jK.js b/frontend/dist/assets/MeshGraph-Ds1Lg4dq.js similarity index 99% rename from frontend/dist/assets/MeshGraph-BrJ2t6jK.js rename to frontend/dist/assets/MeshGraph-Ds1Lg4dq.js index 1d27ec3c..f72e7c75 100644 --- a/frontend/dist/assets/MeshGraph-BrJ2t6jK.js +++ b/frontend/dist/assets/MeshGraph-Ds1Lg4dq.js @@ -1,5 +1,5 @@ -const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/webgl-device-QoBMYpnS-BpXBJEpQ.js","assets/index-C1ZF7cAz.js","assets/DeepAnalysisModal-X0cTTPp0.js","assets/download-DbDw1ZiV.js","assets/database-CdKnhwkJ.js","assets/consumer-registry-CFnLzQEu.js","assets/DataBox-BADtaCfB.js","assets/badge-colors-BNUqIXCA.js","assets/meshcore-tx-constants-DgpFTAmf.js","assets/target-D0wbrQMn.js","assets/layers-BNenbfjd.js","assets/search-CtlrlrHK.js","assets/settings-2-fZXt90fn.js","assets/chevron-right-DzbDJf-i.js","assets/network-4dDTHizq.js","assets/index-DWhIzXT2.css"])))=>i.map(i=>d[i]); -var tL=Object.defineProperty;var iL=(i,e,t)=>e in i?tL(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t;var b=(i,e,t)=>iL(i,typeof e!="symbol"?e+"":e,t);import{d as Vl,r as $,bo as l0,aX as cn,cJ as CS,cK as Uh,cL as TS,cM as nL,b_ as sL,j as f,A as Qc,m as Sl,cN as rL,bc as $u,bW as oL,cO as aL,cP as lL,cQ as cL,cR as uL,cS as dL,cT as hL,cU as fL,E as pL,ca as mL,cV as gL,cW as Ge,Z as qt,cX as c0,q as Di,a0 as be,cY as _L,cZ as yL,R as dg,c_ as bL,ae as Rc,L as u0,c$ as vL,aw as xL,d0 as wL,d1 as SL,B as q_,w as EL,x as CL,d2 as TL,bQ as d0}from"./index-C1ZF7cAz.js";import{m as h0,t as hg,a as kL,b as AL,e as Rn,u as IL,G as LL,M as kS,c as RL,E as PL,d as f0,D as NL,s as X_}from"./DeepAnalysisModal-X0cTTPp0.js";import{u as DL,r as ML,f as p0,g as OL,e as BL}from"./consumer-registry-CFnLzQEu.js";import{D as FL}from"./DataBox-BADtaCfB.js";import{N as zL,a as UL}from"./badge-colors-BNUqIXCA.js";import{e as $L,f as m0,g as jL}from"./meshcore-tx-constants-DgpFTAmf.js";import{E as HL,T as VL}from"./target-D0wbrQMn.js";import{L as g0}from"./layers-BNenbfjd.js";import{S as _0}from"./search-CtlrlrHK.js";import{D as y0}from"./download-DbDw1ZiV.js";import{S as b0}from"./settings-2-fZXt90fn.js";import{C as Hp}from"./chevron-right-DzbDJf-i.js";import{N as GL}from"./network-4dDTHizq.js";/** +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/webgl-device-QoBMYpnS-CdBaG8Is.js","assets/index-DhkG1Nx9.js","assets/DeepAnalysisModal-DuvRb3Nu.js","assets/download-d0PZoGJ2.js","assets/database-DE8k8U0g.js","assets/consumer-registry-CTQIn0m9.js","assets/DataBox-BMesbbaF.js","assets/badge-colors-BNUqIXCA.js","assets/meshcore-tx-constants-DgpFTAmf.js","assets/target-BiAgFlf5.js","assets/layers-BxF7oyms.js","assets/search-BmkxxIVP.js","assets/settings-2-Bgw7gOTp.js","assets/chevron-right-na13OQfy.js","assets/network-DBF70fah.js","assets/index-DySMpv2s.css"])))=>i.map(i=>d[i]); +var tL=Object.defineProperty;var iL=(i,e,t)=>e in i?tL(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t;var b=(i,e,t)=>iL(i,typeof e!="symbol"?e+"":e,t);import{d as Vl,r as $,_ as l0,a_ as cn,cH as CS,cI as Uh,cJ as TS,cK as nL,b_ as sL,j as f,A as Qc,m as Sl,cL as rL,bf as $u,ak as oL,cM as aL,cN as lL,cO as cL,cP as uL,cQ as dL,cR as hL,cS as fL,G as pL,c8 as mL,cT as gL,cU as Ge,Z as qt,cV as c0,v as Di,a3 as be,cW as _L,cX as yL,R as dg,cY as bL,ai as Rc,L as u0,cZ as vL,az as xL,c_ as wL,c$ as SL,B as q_,y as EL,z as CL,d0 as TL,bR as d0}from"./index-DhkG1Nx9.js";import{m as h0,t as hg,a as kL,b as AL,e as Rn,u as IL,G as LL,M as kS,c as RL,E as PL,d as f0,D as NL,s as X_}from"./DeepAnalysisModal-DuvRb3Nu.js";import{u as DL,r as ML,f as p0,g as OL,e as BL}from"./consumer-registry-CTQIn0m9.js";import{D as FL}from"./DataBox-BMesbbaF.js";import{N as zL,a as UL}from"./badge-colors-BNUqIXCA.js";import{e as $L,f as m0,g as jL}from"./meshcore-tx-constants-DgpFTAmf.js";import{E as HL,T as VL}from"./target-BiAgFlf5.js";import{L as g0}from"./layers-BxF7oyms.js";import{S as _0}from"./search-BmkxxIVP.js";import{D as y0}from"./download-d0PZoGJ2.js";import{S as b0}from"./settings-2-Bgw7gOTp.js";import{C as Hp}from"./chevron-right-na13OQfy.js";import{N as GL}from"./network-DBF70fah.js";/** * @license lucide-react v0.559.0 - ISC * * This source code is licensed under the ISC license. @@ -39,7 +39,7 @@ ${r}${o}${i.type.toUpperCase()}: ${i.message}

Compilation error in ${r}



 ${o}
-
`,l.style.top="10px",l.style.left="10px",l.style.position="absolute",l.style.zIndex="9999",l.style.width="100%",l.style.textAlign="left",document.body.appendChild(l),(n=document.getElementsByClassName("luma-compiler-log-error")[0])==null||n.scrollIntoView(),l.onclick=()=>{const c=`data:text/plain,${encodeURIComponent(this.source)}`;navigator.clipboard.writeText(c)}}};U(p2,"defaultProps",{..._n.defaultProps,language:"auto",stage:void 0,source:"",sourceMap:null,entryPoint:"main",debugShaders:void 0});let SN=p2;function EN(i){return CN(i.source)||i.id||oy(`unnamed ${i.stage}-shader`)}function CN(i,e="unnamed"){const t=/#define[\s*]SHADER_NAME[\s*]([A-Za-z0-9_-]+)[\s*]/.exec(i);return t?t[1]:e}const g2=class _2 extends _n{constructor(e,t){super(e,t,_2.defaultProps),U(this,"shaderLayout"),U(this,"bufferLayout"),U(this,"linkStatus","pending"),U(this,"hash",""),this.shaderLayout=this.props.shaderLayout,this.bufferLayout=this.props.bufferLayout||[]}get[Symbol.toStringTag](){return"RenderPipeline"}};U(g2,"defaultProps",{..._n.defaultProps,vs:null,vertexEntryPoint:"vertexMain",vsConstants:{},fs:null,fragmentEntryPoint:"fragmentMain",fsConstants:{},shaderLayout:null,bufferLayout:[],topology:"triangle-list",colorAttachmentFormats:void 0,depthStencilAttachmentFormat:void 0,parameters:{},bindings:{},uniforms:{}});let Xh=g2;const y2=class b2 extends _n{constructor(e,t){super(e,t,b2.defaultProps),U(this,"hash",""),U(this,"shaderLayout"),this.shaderLayout=t.shaderLayout}get[Symbol.toStringTag](){return"ComputePipeline"}};U(y2,"defaultProps",{..._n.defaultProps,shader:void 0,entryPoint:void 0,constants:{},shaderLayout:void 0});let W0=y2;function TN(i){return LN[i]}function kN(i){const[e,t]=IN[i],n=e==="i32"||e==="u32",s=e!=="u32",r=AN[e]*t;return{primitiveType:e,components:t,byteLength:r,integer:n,signed:s}}const AN={f32:4,f16:2,i32:4,u32:4},IN={f32:["f32",1],"vec2":["f32",2],"vec3":["f32",3],"vec4":["f32",4],f16:["f16",1],"vec2":["f16",2],"vec3":["f16",3],"vec4":["f16",4],i32:["i32",1],"vec2":["i32",2],"vec3":["i32",3],"vec4":["i32",4],u32:["u32",1],"vec2":["u32",2],"vec3":["u32",3],"vec4":["u32",4]},LN={f32:{type:"f32",components:1},f16:{type:"f16",components:1},i32:{type:"i32",components:1},u32:{type:"u32",components:1},"vec2":{type:"f32",components:2},"vec3":{type:"f32",components:3},"vec4":{type:"f32",components:4},"vec2":{type:"f16",components:2},"vec3":{type:"f16",components:3},"vec4":{type:"f16",components:4},"vec2":{type:"i32",components:2},"vec3":{type:"i32",components:3},"vec4":{type:"i32",components:4},"vec2":{type:"u32",components:2},"vec3":{type:"u32",components:3},"vec4":{type:"u32",components:4},"mat2x2":{type:"f32",components:4},"mat2x3":{type:"f32",components:6},"mat2x4":{type:"f32",components:8},"mat3x2":{type:"f32",components:6},"mat3x3":{type:"f32",components:9},"mat3x4":{type:"f32",components:12},"mat4x2":{type:"f32",components:8},"mat4x3":{type:"f32",components:12},"mat4x4":{type:"f32",components:16},"mat2x2":{type:"f16",components:4},"mat2x3":{type:"f16",components:6},"mat2x4":{type:"f16",components:8},"mat3x2":{type:"f16",components:6},"mat3x3":{type:"f16",components:9},"mat3x4":{type:"f16",components:12},"mat4x2":{type:"f16",components:8},"mat4x3":{type:"f16",components:12},"mat4x4":{type:"f16",components:16},"mat2x2":{type:"i32",components:4},"mat2x3":{type:"i32",components:6},"mat2x4":{type:"i32",components:8},"mat3x2":{type:"i32",components:6},"mat3x3":{type:"i32",components:9},"mat3x4":{type:"i32",components:12},"mat4x2":{type:"i32",components:8},"mat4x3":{type:"i32",components:12},"mat4x4":{type:"i32",components:16},"mat2x2":{type:"u32",components:4},"mat2x3":{type:"u32",components:6},"mat2x4":{type:"u32",components:8},"mat3x2":{type:"u32",components:6},"mat3x3":{type:"u32",components:9},"mat3x4":{type:"u32",components:12},"mat4x2":{type:"u32",components:8},"mat4x3":{type:"u32",components:12},"mat4x4":{type:"u32",components:16}};function v2(i,e){const t={};for(const n of i.attributes){const s=RN(i,e,n.name);s&&(t[n.name]=s)}return t}function fte(i,e,t=16){const n=v2(i,e),s=new Array(t).fill(null);for(const r of Object.values(n))s[r.location]=r;return s}function RN(i,e,t){const n=PN(i,t),s=NN(e,t);if(!n)return null;const r=kN(n.type),o=ZP(r),a=(s==null?void 0:s.vertexFormat)||o,l=ly(a);return{attributeName:(s==null?void 0:s.attributeName)||n.name,bufferName:(s==null?void 0:s.bufferName)||n.name,location:n.location,shaderType:n.type,primitiveType:r.primitiveType,shaderComponents:r.components,vertexFormat:a,bufferDataType:l.type,bufferComponents:l.components,normalized:l.normalized,integer:r.integer,stepMode:(s==null?void 0:s.stepMode)||n.stepMode||"vertex",byteOffset:(s==null?void 0:s.byteOffset)||0,byteStride:(s==null?void 0:s.byteStride)||0}}function PN(i,e){const t=i.attributes.find(n=>n.name===e);return t||le.warn(`shader layout attribute "${e}" not present in shader`),t||null}function NN(i,e){DN(i);let t=MN(i,e);return t||(t=ON(i,e),t)?t:(le.warn(`layout for attribute "${e}" not present in buffer layout`),null)}function DN(i){for(const e of i)(e.attributes&&e.format||!e.attributes&&!e.format)&&le.warn(`BufferLayout ${name} must have either 'attributes' or 'format' field`)}function MN(i,e){for(const t of i)if(t.format&&t.name===e)return{attributeName:t.name,bufferName:e,stepMode:t.stepMode,vertexFormat:t.format,byteOffset:0,byteStride:t.byteStride||0};return null}function ON(i,e){var t;for(const n of i){let s=n.byteStride;if(typeof n.byteStride!="number")for(const o of n.attributes||[]){const a=ly(o.format);s+=a.byteLength}const r=(t=n.attributes)==null?void 0:t.find(o=>o.attribute===e);if(r)return{attributeName:r.attribute,bufferName:n.name,stepMode:n.stepMode,vertexFormat:r.format,byteOffset:r.byteOffset,byteStride:s}}return null}let xd;function x2(i){return(!xd||xd.byteLengthr.type==="uniform"&&r.name===(e==null?void 0:e.name));if(!n)throw new Error(e==null?void 0:e.name);const s=n;for(const r of s.uniforms||[])this.bindingLayout[r.name]=r}}setUniforms(e){for(const[t,n]of Object.entries(e))this._setUniform(t,n),this.needsRedraw||this.setNeedsRedraw(`${this.name}.${t}=${n}`)}setNeedsRedraw(e){this.needsRedraw=this.needsRedraw||e}getAllUniforms(){return this.modifiedUniforms={},this.needsRedraw=!1,this.uniforms||{}}_setUniform(e,t){UN(this.uniforms[e],t)||(this.uniforms[e]=$N(t),this.modifiedUniforms[e]=!0,this.modified=!0)}}let ri=class{constructor(e){U(this,"uniformBlocks",new Map),U(this,"uniformBufferLayouts",new Map),U(this,"uniformBuffers",new Map);for(const[t,n]of Object.entries(e)){const s=t,r=new zN(n.uniformTypes??{},n.uniformSizes??{});this.uniformBufferLayouts.set(s,r);const o=new jN({name:t});o.setUniforms(n.defaultUniforms||{}),this.uniformBlocks.set(s,o)}}destroy(){for(const e of this.uniformBuffers.values())e.destroy()}setUniforms(e){var t;for(const[n,s]of Object.entries(e))(t=this.uniformBlocks.get(n))==null||t.setUniforms(s);this.updateUniformBuffers()}getUniformBufferByteLength(e){var t;return((t=this.uniformBufferLayouts.get(e))==null?void 0:t.byteLength)||0}getUniformBufferData(e){var t,n;const s=((t=this.uniformBlocks.get(e))==null?void 0:t.getAllUniforms())||{};return(n=this.uniformBufferLayouts.get(e))==null?void 0:n.getData(s)}createUniformBuffer(e,t,n){n&&this.setUniforms(n);const s=this.getUniformBufferByteLength(t),r=e.createBuffer({usage:ge.UNIFORM|ge.COPY_DST,byteLength:s}),o=this.getUniformBufferData(t);return r.write(o),r}getManagedUniformBuffer(e,t){if(!this.uniformBuffers.get(t)){const n=this.getUniformBufferByteLength(t),s=e.createBuffer({usage:ge.UNIFORM|ge.COPY_DST,byteLength:n});this.uniformBuffers.set(t,s)}return this.uniformBuffers.get(t)}updateUniformBuffers(){let e=!1;for(const t of this.uniformBlocks.keys()){const n=this.updateUniformBuffer(t);e||(e=n)}return e&&le.log(3,`UniformStore.updateUniformBuffers(): ${e}`)(),e}updateUniformBuffer(e){var t;const n=this.uniformBlocks.get(e);let s=this.uniformBuffers.get(e),r=!1;if(s&&n!=null&&n.needsRedraw){r||(r=n.needsRedraw);const o=this.getUniformBufferData(e);s=this.uniformBuffers.get(e),s==null||s.write(o);const a=(t=this.uniformBlocks.get(e))==null?void 0:t.getAllUniforms();le.log(4,`Writing to uniform buffer ${String(e)}`,o,a)()}return r}};var Do;(function(i){i[i.DEPTH_BUFFER_BIT=256]="DEPTH_BUFFER_BIT",i[i.STENCIL_BUFFER_BIT=1024]="STENCIL_BUFFER_BIT",i[i.COLOR_BUFFER_BIT=16384]="COLOR_BUFFER_BIT",i[i.POINTS=0]="POINTS",i[i.LINES=1]="LINES",i[i.LINE_LOOP=2]="LINE_LOOP",i[i.LINE_STRIP=3]="LINE_STRIP",i[i.TRIANGLES=4]="TRIANGLES",i[i.TRIANGLE_STRIP=5]="TRIANGLE_STRIP",i[i.TRIANGLE_FAN=6]="TRIANGLE_FAN",i[i.ZERO=0]="ZERO",i[i.ONE=1]="ONE",i[i.SRC_COLOR=768]="SRC_COLOR",i[i.ONE_MINUS_SRC_COLOR=769]="ONE_MINUS_SRC_COLOR",i[i.SRC_ALPHA=770]="SRC_ALPHA",i[i.ONE_MINUS_SRC_ALPHA=771]="ONE_MINUS_SRC_ALPHA",i[i.DST_ALPHA=772]="DST_ALPHA",i[i.ONE_MINUS_DST_ALPHA=773]="ONE_MINUS_DST_ALPHA",i[i.DST_COLOR=774]="DST_COLOR",i[i.ONE_MINUS_DST_COLOR=775]="ONE_MINUS_DST_COLOR",i[i.SRC_ALPHA_SATURATE=776]="SRC_ALPHA_SATURATE",i[i.CONSTANT_COLOR=32769]="CONSTANT_COLOR",i[i.ONE_MINUS_CONSTANT_COLOR=32770]="ONE_MINUS_CONSTANT_COLOR",i[i.CONSTANT_ALPHA=32771]="CONSTANT_ALPHA",i[i.ONE_MINUS_CONSTANT_ALPHA=32772]="ONE_MINUS_CONSTANT_ALPHA",i[i.FUNC_ADD=32774]="FUNC_ADD",i[i.FUNC_SUBTRACT=32778]="FUNC_SUBTRACT",i[i.FUNC_REVERSE_SUBTRACT=32779]="FUNC_REVERSE_SUBTRACT",i[i.BLEND_EQUATION=32777]="BLEND_EQUATION",i[i.BLEND_EQUATION_RGB=32777]="BLEND_EQUATION_RGB",i[i.BLEND_EQUATION_ALPHA=34877]="BLEND_EQUATION_ALPHA",i[i.BLEND_DST_RGB=32968]="BLEND_DST_RGB",i[i.BLEND_SRC_RGB=32969]="BLEND_SRC_RGB",i[i.BLEND_DST_ALPHA=32970]="BLEND_DST_ALPHA",i[i.BLEND_SRC_ALPHA=32971]="BLEND_SRC_ALPHA",i[i.BLEND_COLOR=32773]="BLEND_COLOR",i[i.ARRAY_BUFFER_BINDING=34964]="ARRAY_BUFFER_BINDING",i[i.ELEMENT_ARRAY_BUFFER_BINDING=34965]="ELEMENT_ARRAY_BUFFER_BINDING",i[i.LINE_WIDTH=2849]="LINE_WIDTH",i[i.ALIASED_POINT_SIZE_RANGE=33901]="ALIASED_POINT_SIZE_RANGE",i[i.ALIASED_LINE_WIDTH_RANGE=33902]="ALIASED_LINE_WIDTH_RANGE",i[i.CULL_FACE_MODE=2885]="CULL_FACE_MODE",i[i.FRONT_FACE=2886]="FRONT_FACE",i[i.DEPTH_RANGE=2928]="DEPTH_RANGE",i[i.DEPTH_WRITEMASK=2930]="DEPTH_WRITEMASK",i[i.DEPTH_CLEAR_VALUE=2931]="DEPTH_CLEAR_VALUE",i[i.DEPTH_FUNC=2932]="DEPTH_FUNC",i[i.STENCIL_CLEAR_VALUE=2961]="STENCIL_CLEAR_VALUE",i[i.STENCIL_FUNC=2962]="STENCIL_FUNC",i[i.STENCIL_FAIL=2964]="STENCIL_FAIL",i[i.STENCIL_PASS_DEPTH_FAIL=2965]="STENCIL_PASS_DEPTH_FAIL",i[i.STENCIL_PASS_DEPTH_PASS=2966]="STENCIL_PASS_DEPTH_PASS",i[i.STENCIL_REF=2967]="STENCIL_REF",i[i.STENCIL_VALUE_MASK=2963]="STENCIL_VALUE_MASK",i[i.STENCIL_WRITEMASK=2968]="STENCIL_WRITEMASK",i[i.STENCIL_BACK_FUNC=34816]="STENCIL_BACK_FUNC",i[i.STENCIL_BACK_FAIL=34817]="STENCIL_BACK_FAIL",i[i.STENCIL_BACK_PASS_DEPTH_FAIL=34818]="STENCIL_BACK_PASS_DEPTH_FAIL",i[i.STENCIL_BACK_PASS_DEPTH_PASS=34819]="STENCIL_BACK_PASS_DEPTH_PASS",i[i.STENCIL_BACK_REF=36003]="STENCIL_BACK_REF",i[i.STENCIL_BACK_VALUE_MASK=36004]="STENCIL_BACK_VALUE_MASK",i[i.STENCIL_BACK_WRITEMASK=36005]="STENCIL_BACK_WRITEMASK",i[i.VIEWPORT=2978]="VIEWPORT",i[i.SCISSOR_BOX=3088]="SCISSOR_BOX",i[i.COLOR_CLEAR_VALUE=3106]="COLOR_CLEAR_VALUE",i[i.COLOR_WRITEMASK=3107]="COLOR_WRITEMASK",i[i.UNPACK_ALIGNMENT=3317]="UNPACK_ALIGNMENT",i[i.PACK_ALIGNMENT=3333]="PACK_ALIGNMENT",i[i.MAX_TEXTURE_SIZE=3379]="MAX_TEXTURE_SIZE",i[i.MAX_VIEWPORT_DIMS=3386]="MAX_VIEWPORT_DIMS",i[i.SUBPIXEL_BITS=3408]="SUBPIXEL_BITS",i[i.RED_BITS=3410]="RED_BITS",i[i.GREEN_BITS=3411]="GREEN_BITS",i[i.BLUE_BITS=3412]="BLUE_BITS",i[i.ALPHA_BITS=3413]="ALPHA_BITS",i[i.DEPTH_BITS=3414]="DEPTH_BITS",i[i.STENCIL_BITS=3415]="STENCIL_BITS",i[i.POLYGON_OFFSET_UNITS=10752]="POLYGON_OFFSET_UNITS",i[i.POLYGON_OFFSET_FACTOR=32824]="POLYGON_OFFSET_FACTOR",i[i.TEXTURE_BINDING_2D=32873]="TEXTURE_BINDING_2D",i[i.SAMPLE_BUFFERS=32936]="SAMPLE_BUFFERS",i[i.SAMPLES=32937]="SAMPLES",i[i.SAMPLE_COVERAGE_VALUE=32938]="SAMPLE_COVERAGE_VALUE",i[i.SAMPLE_COVERAGE_INVERT=32939]="SAMPLE_COVERAGE_INVERT",i[i.COMPRESSED_TEXTURE_FORMATS=34467]="COMPRESSED_TEXTURE_FORMATS",i[i.VENDOR=7936]="VENDOR",i[i.RENDERER=7937]="RENDERER",i[i.VERSION=7938]="VERSION",i[i.IMPLEMENTATION_COLOR_READ_TYPE=35738]="IMPLEMENTATION_COLOR_READ_TYPE",i[i.IMPLEMENTATION_COLOR_READ_FORMAT=35739]="IMPLEMENTATION_COLOR_READ_FORMAT",i[i.BROWSER_DEFAULT_WEBGL=37444]="BROWSER_DEFAULT_WEBGL",i[i.STATIC_DRAW=35044]="STATIC_DRAW",i[i.STREAM_DRAW=35040]="STREAM_DRAW",i[i.DYNAMIC_DRAW=35048]="DYNAMIC_DRAW",i[i.ARRAY_BUFFER=34962]="ARRAY_BUFFER",i[i.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",i[i.BUFFER_SIZE=34660]="BUFFER_SIZE",i[i.BUFFER_USAGE=34661]="BUFFER_USAGE",i[i.CURRENT_VERTEX_ATTRIB=34342]="CURRENT_VERTEX_ATTRIB",i[i.VERTEX_ATTRIB_ARRAY_ENABLED=34338]="VERTEX_ATTRIB_ARRAY_ENABLED",i[i.VERTEX_ATTRIB_ARRAY_SIZE=34339]="VERTEX_ATTRIB_ARRAY_SIZE",i[i.VERTEX_ATTRIB_ARRAY_STRIDE=34340]="VERTEX_ATTRIB_ARRAY_STRIDE",i[i.VERTEX_ATTRIB_ARRAY_TYPE=34341]="VERTEX_ATTRIB_ARRAY_TYPE",i[i.VERTEX_ATTRIB_ARRAY_NORMALIZED=34922]="VERTEX_ATTRIB_ARRAY_NORMALIZED",i[i.VERTEX_ATTRIB_ARRAY_POINTER=34373]="VERTEX_ATTRIB_ARRAY_POINTER",i[i.VERTEX_ATTRIB_ARRAY_BUFFER_BINDING=34975]="VERTEX_ATTRIB_ARRAY_BUFFER_BINDING",i[i.CULL_FACE=2884]="CULL_FACE",i[i.FRONT=1028]="FRONT",i[i.BACK=1029]="BACK",i[i.FRONT_AND_BACK=1032]="FRONT_AND_BACK",i[i.BLEND=3042]="BLEND",i[i.DEPTH_TEST=2929]="DEPTH_TEST",i[i.DITHER=3024]="DITHER",i[i.POLYGON_OFFSET_FILL=32823]="POLYGON_OFFSET_FILL",i[i.SAMPLE_ALPHA_TO_COVERAGE=32926]="SAMPLE_ALPHA_TO_COVERAGE",i[i.SAMPLE_COVERAGE=32928]="SAMPLE_COVERAGE",i[i.SCISSOR_TEST=3089]="SCISSOR_TEST",i[i.STENCIL_TEST=2960]="STENCIL_TEST",i[i.NO_ERROR=0]="NO_ERROR",i[i.INVALID_ENUM=1280]="INVALID_ENUM",i[i.INVALID_VALUE=1281]="INVALID_VALUE",i[i.INVALID_OPERATION=1282]="INVALID_OPERATION",i[i.OUT_OF_MEMORY=1285]="OUT_OF_MEMORY",i[i.CONTEXT_LOST_WEBGL=37442]="CONTEXT_LOST_WEBGL",i[i.CW=2304]="CW",i[i.CCW=2305]="CCW",i[i.DONT_CARE=4352]="DONT_CARE",i[i.FASTEST=4353]="FASTEST",i[i.NICEST=4354]="NICEST",i[i.GENERATE_MIPMAP_HINT=33170]="GENERATE_MIPMAP_HINT",i[i.BYTE=5120]="BYTE",i[i.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",i[i.SHORT=5122]="SHORT",i[i.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",i[i.INT=5124]="INT",i[i.UNSIGNED_INT=5125]="UNSIGNED_INT",i[i.FLOAT=5126]="FLOAT",i[i.DOUBLE=5130]="DOUBLE",i[i.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",i[i.ALPHA=6406]="ALPHA",i[i.RGB=6407]="RGB",i[i.RGBA=6408]="RGBA",i[i.LUMINANCE=6409]="LUMINANCE",i[i.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",i[i.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",i[i.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",i[i.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",i[i.FRAGMENT_SHADER=35632]="FRAGMENT_SHADER",i[i.VERTEX_SHADER=35633]="VERTEX_SHADER",i[i.COMPILE_STATUS=35713]="COMPILE_STATUS",i[i.DELETE_STATUS=35712]="DELETE_STATUS",i[i.LINK_STATUS=35714]="LINK_STATUS",i[i.VALIDATE_STATUS=35715]="VALIDATE_STATUS",i[i.ATTACHED_SHADERS=35717]="ATTACHED_SHADERS",i[i.ACTIVE_ATTRIBUTES=35721]="ACTIVE_ATTRIBUTES",i[i.ACTIVE_UNIFORMS=35718]="ACTIVE_UNIFORMS",i[i.MAX_VERTEX_ATTRIBS=34921]="MAX_VERTEX_ATTRIBS",i[i.MAX_VERTEX_UNIFORM_VECTORS=36347]="MAX_VERTEX_UNIFORM_VECTORS",i[i.MAX_VARYING_VECTORS=36348]="MAX_VARYING_VECTORS",i[i.MAX_COMBINED_TEXTURE_IMAGE_UNITS=35661]="MAX_COMBINED_TEXTURE_IMAGE_UNITS",i[i.MAX_VERTEX_TEXTURE_IMAGE_UNITS=35660]="MAX_VERTEX_TEXTURE_IMAGE_UNITS",i[i.MAX_TEXTURE_IMAGE_UNITS=34930]="MAX_TEXTURE_IMAGE_UNITS",i[i.MAX_FRAGMENT_UNIFORM_VECTORS=36349]="MAX_FRAGMENT_UNIFORM_VECTORS",i[i.SHADER_TYPE=35663]="SHADER_TYPE",i[i.SHADING_LANGUAGE_VERSION=35724]="SHADING_LANGUAGE_VERSION",i[i.CURRENT_PROGRAM=35725]="CURRENT_PROGRAM",i[i.NEVER=512]="NEVER",i[i.LESS=513]="LESS",i[i.EQUAL=514]="EQUAL",i[i.LEQUAL=515]="LEQUAL",i[i.GREATER=516]="GREATER",i[i.NOTEQUAL=517]="NOTEQUAL",i[i.GEQUAL=518]="GEQUAL",i[i.ALWAYS=519]="ALWAYS",i[i.KEEP=7680]="KEEP",i[i.REPLACE=7681]="REPLACE",i[i.INCR=7682]="INCR",i[i.DECR=7683]="DECR",i[i.INVERT=5386]="INVERT",i[i.INCR_WRAP=34055]="INCR_WRAP",i[i.DECR_WRAP=34056]="DECR_WRAP",i[i.NEAREST=9728]="NEAREST",i[i.LINEAR=9729]="LINEAR",i[i.NEAREST_MIPMAP_NEAREST=9984]="NEAREST_MIPMAP_NEAREST",i[i.LINEAR_MIPMAP_NEAREST=9985]="LINEAR_MIPMAP_NEAREST",i[i.NEAREST_MIPMAP_LINEAR=9986]="NEAREST_MIPMAP_LINEAR",i[i.LINEAR_MIPMAP_LINEAR=9987]="LINEAR_MIPMAP_LINEAR",i[i.TEXTURE_MAG_FILTER=10240]="TEXTURE_MAG_FILTER",i[i.TEXTURE_MIN_FILTER=10241]="TEXTURE_MIN_FILTER",i[i.TEXTURE_WRAP_S=10242]="TEXTURE_WRAP_S",i[i.TEXTURE_WRAP_T=10243]="TEXTURE_WRAP_T",i[i.TEXTURE_2D=3553]="TEXTURE_2D",i[i.TEXTURE=5890]="TEXTURE",i[i.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",i[i.TEXTURE_BINDING_CUBE_MAP=34068]="TEXTURE_BINDING_CUBE_MAP",i[i.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",i[i.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",i[i.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",i[i.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",i[i.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",i[i.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z",i[i.MAX_CUBE_MAP_TEXTURE_SIZE=34076]="MAX_CUBE_MAP_TEXTURE_SIZE",i[i.TEXTURE0=33984]="TEXTURE0",i[i.ACTIVE_TEXTURE=34016]="ACTIVE_TEXTURE",i[i.REPEAT=10497]="REPEAT",i[i.CLAMP_TO_EDGE=33071]="CLAMP_TO_EDGE",i[i.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",i[i.TEXTURE_WIDTH=4096]="TEXTURE_WIDTH",i[i.TEXTURE_HEIGHT=4097]="TEXTURE_HEIGHT",i[i.FLOAT_VEC2=35664]="FLOAT_VEC2",i[i.FLOAT_VEC3=35665]="FLOAT_VEC3",i[i.FLOAT_VEC4=35666]="FLOAT_VEC4",i[i.INT_VEC2=35667]="INT_VEC2",i[i.INT_VEC3=35668]="INT_VEC3",i[i.INT_VEC4=35669]="INT_VEC4",i[i.BOOL=35670]="BOOL",i[i.BOOL_VEC2=35671]="BOOL_VEC2",i[i.BOOL_VEC3=35672]="BOOL_VEC3",i[i.BOOL_VEC4=35673]="BOOL_VEC4",i[i.FLOAT_MAT2=35674]="FLOAT_MAT2",i[i.FLOAT_MAT3=35675]="FLOAT_MAT3",i[i.FLOAT_MAT4=35676]="FLOAT_MAT4",i[i.SAMPLER_2D=35678]="SAMPLER_2D",i[i.SAMPLER_CUBE=35680]="SAMPLER_CUBE",i[i.LOW_FLOAT=36336]="LOW_FLOAT",i[i.MEDIUM_FLOAT=36337]="MEDIUM_FLOAT",i[i.HIGH_FLOAT=36338]="HIGH_FLOAT",i[i.LOW_INT=36339]="LOW_INT",i[i.MEDIUM_INT=36340]="MEDIUM_INT",i[i.HIGH_INT=36341]="HIGH_INT",i[i.FRAMEBUFFER=36160]="FRAMEBUFFER",i[i.RENDERBUFFER=36161]="RENDERBUFFER",i[i.RGBA4=32854]="RGBA4",i[i.RGB5_A1=32855]="RGB5_A1",i[i.RGB565=36194]="RGB565",i[i.DEPTH_COMPONENT16=33189]="DEPTH_COMPONENT16",i[i.STENCIL_INDEX=6401]="STENCIL_INDEX",i[i.STENCIL_INDEX8=36168]="STENCIL_INDEX8",i[i.DEPTH_STENCIL=34041]="DEPTH_STENCIL",i[i.RENDERBUFFER_WIDTH=36162]="RENDERBUFFER_WIDTH",i[i.RENDERBUFFER_HEIGHT=36163]="RENDERBUFFER_HEIGHT",i[i.RENDERBUFFER_INTERNAL_FORMAT=36164]="RENDERBUFFER_INTERNAL_FORMAT",i[i.RENDERBUFFER_RED_SIZE=36176]="RENDERBUFFER_RED_SIZE",i[i.RENDERBUFFER_GREEN_SIZE=36177]="RENDERBUFFER_GREEN_SIZE",i[i.RENDERBUFFER_BLUE_SIZE=36178]="RENDERBUFFER_BLUE_SIZE",i[i.RENDERBUFFER_ALPHA_SIZE=36179]="RENDERBUFFER_ALPHA_SIZE",i[i.RENDERBUFFER_DEPTH_SIZE=36180]="RENDERBUFFER_DEPTH_SIZE",i[i.RENDERBUFFER_STENCIL_SIZE=36181]="RENDERBUFFER_STENCIL_SIZE",i[i.FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE=36048]="FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE",i[i.FRAMEBUFFER_ATTACHMENT_OBJECT_NAME=36049]="FRAMEBUFFER_ATTACHMENT_OBJECT_NAME",i[i.FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL=36050]="FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL",i[i.FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE=36051]="FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE",i[i.COLOR_ATTACHMENT0=36064]="COLOR_ATTACHMENT0",i[i.DEPTH_ATTACHMENT=36096]="DEPTH_ATTACHMENT",i[i.STENCIL_ATTACHMENT=36128]="STENCIL_ATTACHMENT",i[i.DEPTH_STENCIL_ATTACHMENT=33306]="DEPTH_STENCIL_ATTACHMENT",i[i.NONE=0]="NONE",i[i.FRAMEBUFFER_COMPLETE=36053]="FRAMEBUFFER_COMPLETE",i[i.FRAMEBUFFER_INCOMPLETE_ATTACHMENT=36054]="FRAMEBUFFER_INCOMPLETE_ATTACHMENT",i[i.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT=36055]="FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT",i[i.FRAMEBUFFER_INCOMPLETE_DIMENSIONS=36057]="FRAMEBUFFER_INCOMPLETE_DIMENSIONS",i[i.FRAMEBUFFER_UNSUPPORTED=36061]="FRAMEBUFFER_UNSUPPORTED",i[i.FRAMEBUFFER_BINDING=36006]="FRAMEBUFFER_BINDING",i[i.RENDERBUFFER_BINDING=36007]="RENDERBUFFER_BINDING",i[i.READ_FRAMEBUFFER=36008]="READ_FRAMEBUFFER",i[i.DRAW_FRAMEBUFFER=36009]="DRAW_FRAMEBUFFER",i[i.MAX_RENDERBUFFER_SIZE=34024]="MAX_RENDERBUFFER_SIZE",i[i.INVALID_FRAMEBUFFER_OPERATION=1286]="INVALID_FRAMEBUFFER_OPERATION",i[i.UNPACK_FLIP_Y_WEBGL=37440]="UNPACK_FLIP_Y_WEBGL",i[i.UNPACK_PREMULTIPLY_ALPHA_WEBGL=37441]="UNPACK_PREMULTIPLY_ALPHA_WEBGL",i[i.UNPACK_COLORSPACE_CONVERSION_WEBGL=37443]="UNPACK_COLORSPACE_CONVERSION_WEBGL",i[i.READ_BUFFER=3074]="READ_BUFFER",i[i.UNPACK_ROW_LENGTH=3314]="UNPACK_ROW_LENGTH",i[i.UNPACK_SKIP_ROWS=3315]="UNPACK_SKIP_ROWS",i[i.UNPACK_SKIP_PIXELS=3316]="UNPACK_SKIP_PIXELS",i[i.PACK_ROW_LENGTH=3330]="PACK_ROW_LENGTH",i[i.PACK_SKIP_ROWS=3331]="PACK_SKIP_ROWS",i[i.PACK_SKIP_PIXELS=3332]="PACK_SKIP_PIXELS",i[i.TEXTURE_BINDING_3D=32874]="TEXTURE_BINDING_3D",i[i.UNPACK_SKIP_IMAGES=32877]="UNPACK_SKIP_IMAGES",i[i.UNPACK_IMAGE_HEIGHT=32878]="UNPACK_IMAGE_HEIGHT",i[i.MAX_3D_TEXTURE_SIZE=32883]="MAX_3D_TEXTURE_SIZE",i[i.MAX_ELEMENTS_VERTICES=33e3]="MAX_ELEMENTS_VERTICES",i[i.MAX_ELEMENTS_INDICES=33001]="MAX_ELEMENTS_INDICES",i[i.MAX_TEXTURE_LOD_BIAS=34045]="MAX_TEXTURE_LOD_BIAS",i[i.MAX_FRAGMENT_UNIFORM_COMPONENTS=35657]="MAX_FRAGMENT_UNIFORM_COMPONENTS",i[i.MAX_VERTEX_UNIFORM_COMPONENTS=35658]="MAX_VERTEX_UNIFORM_COMPONENTS",i[i.MAX_ARRAY_TEXTURE_LAYERS=35071]="MAX_ARRAY_TEXTURE_LAYERS",i[i.MIN_PROGRAM_TEXEL_OFFSET=35076]="MIN_PROGRAM_TEXEL_OFFSET",i[i.MAX_PROGRAM_TEXEL_OFFSET=35077]="MAX_PROGRAM_TEXEL_OFFSET",i[i.MAX_VARYING_COMPONENTS=35659]="MAX_VARYING_COMPONENTS",i[i.FRAGMENT_SHADER_DERIVATIVE_HINT=35723]="FRAGMENT_SHADER_DERIVATIVE_HINT",i[i.RASTERIZER_DISCARD=35977]="RASTERIZER_DISCARD",i[i.VERTEX_ARRAY_BINDING=34229]="VERTEX_ARRAY_BINDING",i[i.MAX_VERTEX_OUTPUT_COMPONENTS=37154]="MAX_VERTEX_OUTPUT_COMPONENTS",i[i.MAX_FRAGMENT_INPUT_COMPONENTS=37157]="MAX_FRAGMENT_INPUT_COMPONENTS",i[i.MAX_SERVER_WAIT_TIMEOUT=37137]="MAX_SERVER_WAIT_TIMEOUT",i[i.MAX_ELEMENT_INDEX=36203]="MAX_ELEMENT_INDEX",i[i.RED=6403]="RED",i[i.RGB8=32849]="RGB8",i[i.RGBA8=32856]="RGBA8",i[i.RGB10_A2=32857]="RGB10_A2",i[i.TEXTURE_3D=32879]="TEXTURE_3D",i[i.TEXTURE_WRAP_R=32882]="TEXTURE_WRAP_R",i[i.TEXTURE_MIN_LOD=33082]="TEXTURE_MIN_LOD",i[i.TEXTURE_MAX_LOD=33083]="TEXTURE_MAX_LOD",i[i.TEXTURE_BASE_LEVEL=33084]="TEXTURE_BASE_LEVEL",i[i.TEXTURE_MAX_LEVEL=33085]="TEXTURE_MAX_LEVEL",i[i.TEXTURE_COMPARE_MODE=34892]="TEXTURE_COMPARE_MODE",i[i.TEXTURE_COMPARE_FUNC=34893]="TEXTURE_COMPARE_FUNC",i[i.SRGB=35904]="SRGB",i[i.SRGB8=35905]="SRGB8",i[i.SRGB8_ALPHA8=35907]="SRGB8_ALPHA8",i[i.COMPARE_REF_TO_TEXTURE=34894]="COMPARE_REF_TO_TEXTURE",i[i.RGBA32F=34836]="RGBA32F",i[i.RGB32F=34837]="RGB32F",i[i.RGBA16F=34842]="RGBA16F",i[i.RGB16F=34843]="RGB16F",i[i.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY",i[i.TEXTURE_BINDING_2D_ARRAY=35869]="TEXTURE_BINDING_2D_ARRAY",i[i.R11F_G11F_B10F=35898]="R11F_G11F_B10F",i[i.RGB9_E5=35901]="RGB9_E5",i[i.RGBA32UI=36208]="RGBA32UI",i[i.RGB32UI=36209]="RGB32UI",i[i.RGBA16UI=36214]="RGBA16UI",i[i.RGB16UI=36215]="RGB16UI",i[i.RGBA8UI=36220]="RGBA8UI",i[i.RGB8UI=36221]="RGB8UI",i[i.RGBA32I=36226]="RGBA32I",i[i.RGB32I=36227]="RGB32I",i[i.RGBA16I=36232]="RGBA16I",i[i.RGB16I=36233]="RGB16I",i[i.RGBA8I=36238]="RGBA8I",i[i.RGB8I=36239]="RGB8I",i[i.RED_INTEGER=36244]="RED_INTEGER",i[i.RGB_INTEGER=36248]="RGB_INTEGER",i[i.RGBA_INTEGER=36249]="RGBA_INTEGER",i[i.R8=33321]="R8",i[i.RG8=33323]="RG8",i[i.R16F=33325]="R16F",i[i.R32F=33326]="R32F",i[i.RG16F=33327]="RG16F",i[i.RG32F=33328]="RG32F",i[i.R8I=33329]="R8I",i[i.R8UI=33330]="R8UI",i[i.R16I=33331]="R16I",i[i.R16UI=33332]="R16UI",i[i.R32I=33333]="R32I",i[i.R32UI=33334]="R32UI",i[i.RG8I=33335]="RG8I",i[i.RG8UI=33336]="RG8UI",i[i.RG16I=33337]="RG16I",i[i.RG16UI=33338]="RG16UI",i[i.RG32I=33339]="RG32I",i[i.RG32UI=33340]="RG32UI",i[i.R8_SNORM=36756]="R8_SNORM",i[i.RG8_SNORM=36757]="RG8_SNORM",i[i.RGB8_SNORM=36758]="RGB8_SNORM",i[i.RGBA8_SNORM=36759]="RGBA8_SNORM",i[i.RGB10_A2UI=36975]="RGB10_A2UI",i[i.TEXTURE_IMMUTABLE_FORMAT=37167]="TEXTURE_IMMUTABLE_FORMAT",i[i.TEXTURE_IMMUTABLE_LEVELS=33503]="TEXTURE_IMMUTABLE_LEVELS",i[i.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",i[i.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",i[i.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",i[i.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV",i[i.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",i[i.HALF_FLOAT=5131]="HALF_FLOAT",i[i.RG=33319]="RG",i[i.RG_INTEGER=33320]="RG_INTEGER",i[i.INT_2_10_10_10_REV=36255]="INT_2_10_10_10_REV",i[i.CURRENT_QUERY=34917]="CURRENT_QUERY",i[i.QUERY_RESULT=34918]="QUERY_RESULT",i[i.QUERY_RESULT_AVAILABLE=34919]="QUERY_RESULT_AVAILABLE",i[i.ANY_SAMPLES_PASSED=35887]="ANY_SAMPLES_PASSED",i[i.ANY_SAMPLES_PASSED_CONSERVATIVE=36202]="ANY_SAMPLES_PASSED_CONSERVATIVE",i[i.MAX_DRAW_BUFFERS=34852]="MAX_DRAW_BUFFERS",i[i.DRAW_BUFFER0=34853]="DRAW_BUFFER0",i[i.DRAW_BUFFER1=34854]="DRAW_BUFFER1",i[i.DRAW_BUFFER2=34855]="DRAW_BUFFER2",i[i.DRAW_BUFFER3=34856]="DRAW_BUFFER3",i[i.DRAW_BUFFER4=34857]="DRAW_BUFFER4",i[i.DRAW_BUFFER5=34858]="DRAW_BUFFER5",i[i.DRAW_BUFFER6=34859]="DRAW_BUFFER6",i[i.DRAW_BUFFER7=34860]="DRAW_BUFFER7",i[i.DRAW_BUFFER8=34861]="DRAW_BUFFER8",i[i.DRAW_BUFFER9=34862]="DRAW_BUFFER9",i[i.DRAW_BUFFER10=34863]="DRAW_BUFFER10",i[i.DRAW_BUFFER11=34864]="DRAW_BUFFER11",i[i.DRAW_BUFFER12=34865]="DRAW_BUFFER12",i[i.DRAW_BUFFER13=34866]="DRAW_BUFFER13",i[i.DRAW_BUFFER14=34867]="DRAW_BUFFER14",i[i.DRAW_BUFFER15=34868]="DRAW_BUFFER15",i[i.MAX_COLOR_ATTACHMENTS=36063]="MAX_COLOR_ATTACHMENTS",i[i.COLOR_ATTACHMENT1=36065]="COLOR_ATTACHMENT1",i[i.COLOR_ATTACHMENT2=36066]="COLOR_ATTACHMENT2",i[i.COLOR_ATTACHMENT3=36067]="COLOR_ATTACHMENT3",i[i.COLOR_ATTACHMENT4=36068]="COLOR_ATTACHMENT4",i[i.COLOR_ATTACHMENT5=36069]="COLOR_ATTACHMENT5",i[i.COLOR_ATTACHMENT6=36070]="COLOR_ATTACHMENT6",i[i.COLOR_ATTACHMENT7=36071]="COLOR_ATTACHMENT7",i[i.COLOR_ATTACHMENT8=36072]="COLOR_ATTACHMENT8",i[i.COLOR_ATTACHMENT9=36073]="COLOR_ATTACHMENT9",i[i.COLOR_ATTACHMENT10=36074]="COLOR_ATTACHMENT10",i[i.COLOR_ATTACHMENT11=36075]="COLOR_ATTACHMENT11",i[i.COLOR_ATTACHMENT12=36076]="COLOR_ATTACHMENT12",i[i.COLOR_ATTACHMENT13=36077]="COLOR_ATTACHMENT13",i[i.COLOR_ATTACHMENT14=36078]="COLOR_ATTACHMENT14",i[i.COLOR_ATTACHMENT15=36079]="COLOR_ATTACHMENT15",i[i.SAMPLER_3D=35679]="SAMPLER_3D",i[i.SAMPLER_2D_SHADOW=35682]="SAMPLER_2D_SHADOW",i[i.SAMPLER_2D_ARRAY=36289]="SAMPLER_2D_ARRAY",i[i.SAMPLER_2D_ARRAY_SHADOW=36292]="SAMPLER_2D_ARRAY_SHADOW",i[i.SAMPLER_CUBE_SHADOW=36293]="SAMPLER_CUBE_SHADOW",i[i.INT_SAMPLER_2D=36298]="INT_SAMPLER_2D",i[i.INT_SAMPLER_3D=36299]="INT_SAMPLER_3D",i[i.INT_SAMPLER_CUBE=36300]="INT_SAMPLER_CUBE",i[i.INT_SAMPLER_2D_ARRAY=36303]="INT_SAMPLER_2D_ARRAY",i[i.UNSIGNED_INT_SAMPLER_2D=36306]="UNSIGNED_INT_SAMPLER_2D",i[i.UNSIGNED_INT_SAMPLER_3D=36307]="UNSIGNED_INT_SAMPLER_3D",i[i.UNSIGNED_INT_SAMPLER_CUBE=36308]="UNSIGNED_INT_SAMPLER_CUBE",i[i.UNSIGNED_INT_SAMPLER_2D_ARRAY=36311]="UNSIGNED_INT_SAMPLER_2D_ARRAY",i[i.MAX_SAMPLES=36183]="MAX_SAMPLES",i[i.SAMPLER_BINDING=35097]="SAMPLER_BINDING",i[i.PIXEL_PACK_BUFFER=35051]="PIXEL_PACK_BUFFER",i[i.PIXEL_UNPACK_BUFFER=35052]="PIXEL_UNPACK_BUFFER",i[i.PIXEL_PACK_BUFFER_BINDING=35053]="PIXEL_PACK_BUFFER_BINDING",i[i.PIXEL_UNPACK_BUFFER_BINDING=35055]="PIXEL_UNPACK_BUFFER_BINDING",i[i.COPY_READ_BUFFER=36662]="COPY_READ_BUFFER",i[i.COPY_WRITE_BUFFER=36663]="COPY_WRITE_BUFFER",i[i.COPY_READ_BUFFER_BINDING=36662]="COPY_READ_BUFFER_BINDING",i[i.COPY_WRITE_BUFFER_BINDING=36663]="COPY_WRITE_BUFFER_BINDING",i[i.FLOAT_MAT2x3=35685]="FLOAT_MAT2x3",i[i.FLOAT_MAT2x4=35686]="FLOAT_MAT2x4",i[i.FLOAT_MAT3x2=35687]="FLOAT_MAT3x2",i[i.FLOAT_MAT3x4=35688]="FLOAT_MAT3x4",i[i.FLOAT_MAT4x2=35689]="FLOAT_MAT4x2",i[i.FLOAT_MAT4x3=35690]="FLOAT_MAT4x3",i[i.UNSIGNED_INT_VEC2=36294]="UNSIGNED_INT_VEC2",i[i.UNSIGNED_INT_VEC3=36295]="UNSIGNED_INT_VEC3",i[i.UNSIGNED_INT_VEC4=36296]="UNSIGNED_INT_VEC4",i[i.UNSIGNED_NORMALIZED=35863]="UNSIGNED_NORMALIZED",i[i.SIGNED_NORMALIZED=36764]="SIGNED_NORMALIZED",i[i.VERTEX_ATTRIB_ARRAY_INTEGER=35069]="VERTEX_ATTRIB_ARRAY_INTEGER",i[i.VERTEX_ATTRIB_ARRAY_DIVISOR=35070]="VERTEX_ATTRIB_ARRAY_DIVISOR",i[i.TRANSFORM_FEEDBACK_BUFFER_MODE=35967]="TRANSFORM_FEEDBACK_BUFFER_MODE",i[i.MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS=35968]="MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS",i[i.TRANSFORM_FEEDBACK_VARYINGS=35971]="TRANSFORM_FEEDBACK_VARYINGS",i[i.TRANSFORM_FEEDBACK_BUFFER_START=35972]="TRANSFORM_FEEDBACK_BUFFER_START",i[i.TRANSFORM_FEEDBACK_BUFFER_SIZE=35973]="TRANSFORM_FEEDBACK_BUFFER_SIZE",i[i.TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN=35976]="TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN",i[i.MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS=35978]="MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS",i[i.MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS=35979]="MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS",i[i.INTERLEAVED_ATTRIBS=35980]="INTERLEAVED_ATTRIBS",i[i.SEPARATE_ATTRIBS=35981]="SEPARATE_ATTRIBS",i[i.TRANSFORM_FEEDBACK_BUFFER=35982]="TRANSFORM_FEEDBACK_BUFFER",i[i.TRANSFORM_FEEDBACK_BUFFER_BINDING=35983]="TRANSFORM_FEEDBACK_BUFFER_BINDING",i[i.TRANSFORM_FEEDBACK=36386]="TRANSFORM_FEEDBACK",i[i.TRANSFORM_FEEDBACK_PAUSED=36387]="TRANSFORM_FEEDBACK_PAUSED",i[i.TRANSFORM_FEEDBACK_ACTIVE=36388]="TRANSFORM_FEEDBACK_ACTIVE",i[i.TRANSFORM_FEEDBACK_BINDING=36389]="TRANSFORM_FEEDBACK_BINDING",i[i.FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING=33296]="FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING",i[i.FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE=33297]="FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE",i[i.FRAMEBUFFER_ATTACHMENT_RED_SIZE=33298]="FRAMEBUFFER_ATTACHMENT_RED_SIZE",i[i.FRAMEBUFFER_ATTACHMENT_GREEN_SIZE=33299]="FRAMEBUFFER_ATTACHMENT_GREEN_SIZE",i[i.FRAMEBUFFER_ATTACHMENT_BLUE_SIZE=33300]="FRAMEBUFFER_ATTACHMENT_BLUE_SIZE",i[i.FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE=33301]="FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE",i[i.FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE=33302]="FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE",i[i.FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE=33303]="FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE",i[i.FRAMEBUFFER_DEFAULT=33304]="FRAMEBUFFER_DEFAULT",i[i.DEPTH24_STENCIL8=35056]="DEPTH24_STENCIL8",i[i.DRAW_FRAMEBUFFER_BINDING=36006]="DRAW_FRAMEBUFFER_BINDING",i[i.READ_FRAMEBUFFER_BINDING=36010]="READ_FRAMEBUFFER_BINDING",i[i.RENDERBUFFER_SAMPLES=36011]="RENDERBUFFER_SAMPLES",i[i.FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER=36052]="FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER",i[i.FRAMEBUFFER_INCOMPLETE_MULTISAMPLE=36182]="FRAMEBUFFER_INCOMPLETE_MULTISAMPLE",i[i.UNIFORM_BUFFER=35345]="UNIFORM_BUFFER",i[i.UNIFORM_BUFFER_BINDING=35368]="UNIFORM_BUFFER_BINDING",i[i.UNIFORM_BUFFER_START=35369]="UNIFORM_BUFFER_START",i[i.UNIFORM_BUFFER_SIZE=35370]="UNIFORM_BUFFER_SIZE",i[i.MAX_VERTEX_UNIFORM_BLOCKS=35371]="MAX_VERTEX_UNIFORM_BLOCKS",i[i.MAX_FRAGMENT_UNIFORM_BLOCKS=35373]="MAX_FRAGMENT_UNIFORM_BLOCKS",i[i.MAX_COMBINED_UNIFORM_BLOCKS=35374]="MAX_COMBINED_UNIFORM_BLOCKS",i[i.MAX_UNIFORM_BUFFER_BINDINGS=35375]="MAX_UNIFORM_BUFFER_BINDINGS",i[i.MAX_UNIFORM_BLOCK_SIZE=35376]="MAX_UNIFORM_BLOCK_SIZE",i[i.MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS=35377]="MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS",i[i.MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS=35379]="MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS",i[i.UNIFORM_BUFFER_OFFSET_ALIGNMENT=35380]="UNIFORM_BUFFER_OFFSET_ALIGNMENT",i[i.ACTIVE_UNIFORM_BLOCKS=35382]="ACTIVE_UNIFORM_BLOCKS",i[i.UNIFORM_TYPE=35383]="UNIFORM_TYPE",i[i.UNIFORM_SIZE=35384]="UNIFORM_SIZE",i[i.UNIFORM_BLOCK_INDEX=35386]="UNIFORM_BLOCK_INDEX",i[i.UNIFORM_OFFSET=35387]="UNIFORM_OFFSET",i[i.UNIFORM_ARRAY_STRIDE=35388]="UNIFORM_ARRAY_STRIDE",i[i.UNIFORM_MATRIX_STRIDE=35389]="UNIFORM_MATRIX_STRIDE",i[i.UNIFORM_IS_ROW_MAJOR=35390]="UNIFORM_IS_ROW_MAJOR",i[i.UNIFORM_BLOCK_BINDING=35391]="UNIFORM_BLOCK_BINDING",i[i.UNIFORM_BLOCK_DATA_SIZE=35392]="UNIFORM_BLOCK_DATA_SIZE",i[i.UNIFORM_BLOCK_ACTIVE_UNIFORMS=35394]="UNIFORM_BLOCK_ACTIVE_UNIFORMS",i[i.UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES=35395]="UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES",i[i.UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER=35396]="UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER",i[i.UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER=35398]="UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER",i[i.OBJECT_TYPE=37138]="OBJECT_TYPE",i[i.SYNC_CONDITION=37139]="SYNC_CONDITION",i[i.SYNC_STATUS=37140]="SYNC_STATUS",i[i.SYNC_FLAGS=37141]="SYNC_FLAGS",i[i.SYNC_FENCE=37142]="SYNC_FENCE",i[i.SYNC_GPU_COMMANDS_COMPLETE=37143]="SYNC_GPU_COMMANDS_COMPLETE",i[i.UNSIGNALED=37144]="UNSIGNALED",i[i.SIGNALED=37145]="SIGNALED",i[i.ALREADY_SIGNALED=37146]="ALREADY_SIGNALED",i[i.TIMEOUT_EXPIRED=37147]="TIMEOUT_EXPIRED",i[i.CONDITION_SATISFIED=37148]="CONDITION_SATISFIED",i[i.WAIT_FAILED=37149]="WAIT_FAILED",i[i.SYNC_FLUSH_COMMANDS_BIT=1]="SYNC_FLUSH_COMMANDS_BIT",i[i.COLOR=6144]="COLOR",i[i.DEPTH=6145]="DEPTH",i[i.STENCIL=6146]="STENCIL",i[i.MIN=32775]="MIN",i[i.MAX=32776]="MAX",i[i.DEPTH_COMPONENT24=33190]="DEPTH_COMPONENT24",i[i.STREAM_READ=35041]="STREAM_READ",i[i.STREAM_COPY=35042]="STREAM_COPY",i[i.STATIC_READ=35045]="STATIC_READ",i[i.STATIC_COPY=35046]="STATIC_COPY",i[i.DYNAMIC_READ=35049]="DYNAMIC_READ",i[i.DYNAMIC_COPY=35050]="DYNAMIC_COPY",i[i.DEPTH_COMPONENT32F=36012]="DEPTH_COMPONENT32F",i[i.DEPTH32F_STENCIL8=36013]="DEPTH32F_STENCIL8",i[i.INVALID_INDEX=4294967295]="INVALID_INDEX",i[i.TIMEOUT_IGNORED=-1]="TIMEOUT_IGNORED",i[i.MAX_CLIENT_WAIT_TIMEOUT_WEBGL=37447]="MAX_CLIENT_WAIT_TIMEOUT_WEBGL",i[i.UNMASKED_VENDOR_WEBGL=37445]="UNMASKED_VENDOR_WEBGL",i[i.UNMASKED_RENDERER_WEBGL=37446]="UNMASKED_RENDERER_WEBGL",i[i.MAX_TEXTURE_MAX_ANISOTROPY_EXT=34047]="MAX_TEXTURE_MAX_ANISOTROPY_EXT",i[i.TEXTURE_MAX_ANISOTROPY_EXT=34046]="TEXTURE_MAX_ANISOTROPY_EXT",i[i.R16_EXT=33322]="R16_EXT",i[i.RG16_EXT=33324]="RG16_EXT",i[i.RGB16_EXT=32852]="RGB16_EXT",i[i.RGBA16_EXT=32859]="RGBA16_EXT",i[i.R16_SNORM_EXT=36760]="R16_SNORM_EXT",i[i.RG16_SNORM_EXT=36761]="RG16_SNORM_EXT",i[i.RGB16_SNORM_EXT=36762]="RGB16_SNORM_EXT",i[i.RGBA16_SNORM_EXT=36763]="RGBA16_SNORM_EXT",i[i.COMPRESSED_RGB_S3TC_DXT1_EXT=33776]="COMPRESSED_RGB_S3TC_DXT1_EXT",i[i.COMPRESSED_RGBA_S3TC_DXT1_EXT=33777]="COMPRESSED_RGBA_S3TC_DXT1_EXT",i[i.COMPRESSED_RGBA_S3TC_DXT3_EXT=33778]="COMPRESSED_RGBA_S3TC_DXT3_EXT",i[i.COMPRESSED_RGBA_S3TC_DXT5_EXT=33779]="COMPRESSED_RGBA_S3TC_DXT5_EXT",i[i.COMPRESSED_SRGB_S3TC_DXT1_EXT=35916]="COMPRESSED_SRGB_S3TC_DXT1_EXT",i[i.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT=35917]="COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT",i[i.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT=35918]="COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT",i[i.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT=35919]="COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT",i[i.COMPRESSED_RED_RGTC1_EXT=36283]="COMPRESSED_RED_RGTC1_EXT",i[i.COMPRESSED_SIGNED_RED_RGTC1_EXT=36284]="COMPRESSED_SIGNED_RED_RGTC1_EXT",i[i.COMPRESSED_RED_GREEN_RGTC2_EXT=36285]="COMPRESSED_RED_GREEN_RGTC2_EXT",i[i.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT=36286]="COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT",i[i.COMPRESSED_RGBA_BPTC_UNORM_EXT=36492]="COMPRESSED_RGBA_BPTC_UNORM_EXT",i[i.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT=36493]="COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT",i[i.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT=36494]="COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT",i[i.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT=36495]="COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT",i[i.COMPRESSED_R11_EAC=37488]="COMPRESSED_R11_EAC",i[i.COMPRESSED_SIGNED_R11_EAC=37489]="COMPRESSED_SIGNED_R11_EAC",i[i.COMPRESSED_RG11_EAC=37490]="COMPRESSED_RG11_EAC",i[i.COMPRESSED_SIGNED_RG11_EAC=37491]="COMPRESSED_SIGNED_RG11_EAC",i[i.COMPRESSED_RGB8_ETC2=37492]="COMPRESSED_RGB8_ETC2",i[i.COMPRESSED_RGBA8_ETC2_EAC=37493]="COMPRESSED_RGBA8_ETC2_EAC",i[i.COMPRESSED_SRGB8_ETC2=37494]="COMPRESSED_SRGB8_ETC2",i[i.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC=37495]="COMPRESSED_SRGB8_ALPHA8_ETC2_EAC",i[i.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2=37496]="COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2",i[i.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2=37497]="COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2",i[i.COMPRESSED_RGB_PVRTC_4BPPV1_IMG=35840]="COMPRESSED_RGB_PVRTC_4BPPV1_IMG",i[i.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG=35842]="COMPRESSED_RGBA_PVRTC_4BPPV1_IMG",i[i.COMPRESSED_RGB_PVRTC_2BPPV1_IMG=35841]="COMPRESSED_RGB_PVRTC_2BPPV1_IMG",i[i.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG=35843]="COMPRESSED_RGBA_PVRTC_2BPPV1_IMG",i[i.COMPRESSED_RGB_ETC1_WEBGL=36196]="COMPRESSED_RGB_ETC1_WEBGL",i[i.COMPRESSED_RGB_ATC_WEBGL=35986]="COMPRESSED_RGB_ATC_WEBGL",i[i.COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL=35986]="COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL",i[i.COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL=34798]="COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL",i[i.COMPRESSED_RGBA_ASTC_4x4_KHR=37808]="COMPRESSED_RGBA_ASTC_4x4_KHR",i[i.COMPRESSED_RGBA_ASTC_5x4_KHR=37809]="COMPRESSED_RGBA_ASTC_5x4_KHR",i[i.COMPRESSED_RGBA_ASTC_5x5_KHR=37810]="COMPRESSED_RGBA_ASTC_5x5_KHR",i[i.COMPRESSED_RGBA_ASTC_6x5_KHR=37811]="COMPRESSED_RGBA_ASTC_6x5_KHR",i[i.COMPRESSED_RGBA_ASTC_6x6_KHR=37812]="COMPRESSED_RGBA_ASTC_6x6_KHR",i[i.COMPRESSED_RGBA_ASTC_8x5_KHR=37813]="COMPRESSED_RGBA_ASTC_8x5_KHR",i[i.COMPRESSED_RGBA_ASTC_8x6_KHR=37814]="COMPRESSED_RGBA_ASTC_8x6_KHR",i[i.COMPRESSED_RGBA_ASTC_8x8_KHR=37815]="COMPRESSED_RGBA_ASTC_8x8_KHR",i[i.COMPRESSED_RGBA_ASTC_10x5_KHR=37816]="COMPRESSED_RGBA_ASTC_10x5_KHR",i[i.COMPRESSED_RGBA_ASTC_10x6_KHR=37817]="COMPRESSED_RGBA_ASTC_10x6_KHR",i[i.COMPRESSED_RGBA_ASTC_10x8_KHR=37818]="COMPRESSED_RGBA_ASTC_10x8_KHR",i[i.COMPRESSED_RGBA_ASTC_10x10_KHR=37819]="COMPRESSED_RGBA_ASTC_10x10_KHR",i[i.COMPRESSED_RGBA_ASTC_12x10_KHR=37820]="COMPRESSED_RGBA_ASTC_12x10_KHR",i[i.COMPRESSED_RGBA_ASTC_12x12_KHR=37821]="COMPRESSED_RGBA_ASTC_12x12_KHR",i[i.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR=37840]="COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR",i[i.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR=37841]="COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR",i[i.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR=37842]="COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR",i[i.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR=37843]="COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR",i[i.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR=37844]="COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR",i[i.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR=37845]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR",i[i.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR=37846]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR",i[i.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR=37847]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR",i[i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR=37848]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR",i[i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR=37849]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR",i[i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR=37850]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR",i[i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR=37851]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR",i[i.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR=37852]="COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR",i[i.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR=37853]="COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR",i[i.QUERY_COUNTER_BITS_EXT=34916]="QUERY_COUNTER_BITS_EXT",i[i.CURRENT_QUERY_EXT=34917]="CURRENT_QUERY_EXT",i[i.QUERY_RESULT_EXT=34918]="QUERY_RESULT_EXT",i[i.QUERY_RESULT_AVAILABLE_EXT=34919]="QUERY_RESULT_AVAILABLE_EXT",i[i.TIME_ELAPSED_EXT=35007]="TIME_ELAPSED_EXT",i[i.TIMESTAMP_EXT=36392]="TIMESTAMP_EXT",i[i.GPU_DISJOINT_EXT=36795]="GPU_DISJOINT_EXT",i[i.COMPLETION_STATUS_KHR=37297]="COMPLETION_STATUS_KHR",i[i.DEPTH_CLAMP_EXT=34383]="DEPTH_CLAMP_EXT",i[i.FIRST_VERTEX_CONVENTION_WEBGL=36429]="FIRST_VERTEX_CONVENTION_WEBGL",i[i.LAST_VERTEX_CONVENTION_WEBGL=36430]="LAST_VERTEX_CONVENTION_WEBGL",i[i.PROVOKING_VERTEX_WEBL=36431]="PROVOKING_VERTEX_WEBL",i[i.POLYGON_MODE_WEBGL=2880]="POLYGON_MODE_WEBGL",i[i.POLYGON_OFFSET_LINE_WEBGL=10754]="POLYGON_OFFSET_LINE_WEBGL",i[i.LINE_WEBGL=6913]="LINE_WEBGL",i[i.FILL_WEBGL=6914]="FILL_WEBGL",i[i.MAX_CLIP_DISTANCES_WEBGL=3378]="MAX_CLIP_DISTANCES_WEBGL",i[i.MAX_CULL_DISTANCES_WEBGL=33529]="MAX_CULL_DISTANCES_WEBGL",i[i.MAX_COMBINED_CLIP_AND_CULL_DISTANCES_WEBGL=33530]="MAX_COMBINED_CLIP_AND_CULL_DISTANCES_WEBGL",i[i.CLIP_DISTANCE0_WEBGL=12288]="CLIP_DISTANCE0_WEBGL",i[i.CLIP_DISTANCE1_WEBGL=12289]="CLIP_DISTANCE1_WEBGL",i[i.CLIP_DISTANCE2_WEBGL=12290]="CLIP_DISTANCE2_WEBGL",i[i.CLIP_DISTANCE3_WEBGL=12291]="CLIP_DISTANCE3_WEBGL",i[i.CLIP_DISTANCE4_WEBGL=12292]="CLIP_DISTANCE4_WEBGL",i[i.CLIP_DISTANCE5_WEBGL=12293]="CLIP_DISTANCE5_WEBGL",i[i.CLIP_DISTANCE6_WEBGL=12294]="CLIP_DISTANCE6_WEBGL",i[i.CLIP_DISTANCE7_WEBGL=12295]="CLIP_DISTANCE7_WEBGL",i[i.POLYGON_OFFSET_CLAMP_EXT=36379]="POLYGON_OFFSET_CLAMP_EXT",i[i.LOWER_LEFT_EXT=36001]="LOWER_LEFT_EXT",i[i.UPPER_LEFT_EXT=36002]="UPPER_LEFT_EXT",i[i.NEGATIVE_ONE_TO_ONE_EXT=37726]="NEGATIVE_ONE_TO_ONE_EXT",i[i.ZERO_TO_ONE_EXT=37727]="ZERO_TO_ONE_EXT",i[i.CLIP_ORIGIN_EXT=37724]="CLIP_ORIGIN_EXT",i[i.CLIP_DEPTH_MODE_EXT=37725]="CLIP_DEPTH_MODE_EXT",i[i.SRC1_COLOR_WEBGL=35065]="SRC1_COLOR_WEBGL",i[i.SRC1_ALPHA_WEBGL=34185]="SRC1_ALPHA_WEBGL",i[i.ONE_MINUS_SRC1_COLOR_WEBGL=35066]="ONE_MINUS_SRC1_COLOR_WEBGL",i[i.ONE_MINUS_SRC1_ALPHA_WEBGL=35067]="ONE_MINUS_SRC1_ALPHA_WEBGL",i[i.MAX_DUAL_SOURCE_DRAW_BUFFERS_WEBGL=35068]="MAX_DUAL_SOURCE_DRAW_BUFFERS_WEBGL",i[i.MIRROR_CLAMP_TO_EDGE_EXT=34627]="MIRROR_CLAMP_TO_EDGE_EXT"})(Do||(Do={}));const HN={WEBGL_depth_texture:{UNSIGNED_INT_24_8_WEBGL:34042},OES_element_index_uint:{},OES_texture_float:{},OES_texture_half_float:{HALF_FLOAT_OES:5131},EXT_color_buffer_float:{},OES_standard_derivatives:{FRAGMENT_SHADER_DERIVATIVE_HINT_OES:35723},EXT_frag_depth:{},EXT_blend_minmax:{MIN_EXT:32775,MAX_EXT:32776},EXT_shader_texture_lod:{}},VN=i=>({drawBuffersWEBGL(e){return i.drawBuffers(e)},COLOR_ATTACHMENT0_WEBGL:36064,COLOR_ATTACHMENT1_WEBGL:36065,COLOR_ATTACHMENT2_WEBGL:36066,COLOR_ATTACHMENT3_WEBGL:36067}),GN=i=>({VERTEX_ARRAY_BINDING_OES:34229,createVertexArrayOES(){return i.createVertexArray()},deleteVertexArrayOES(e){return i.deleteVertexArray(e)},isVertexArrayOES(e){return i.isVertexArray(e)},bindVertexArrayOES(e){return i.bindVertexArray(e)}}),WN=i=>({VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE:35070,drawArraysInstancedANGLE(...e){return i.drawArraysInstanced(...e)},drawElementsInstancedANGLE(...e){return i.drawElementsInstanced(...e)},vertexAttribDivisorANGLE(...e){return i.vertexAttribDivisor(...e)}});function YN(i=!0){const e=HTMLCanvasElement.prototype;if(!i&&e.originalGetContext){e.getContext=e.originalGetContext,e.originalGetContext=void 0;return}e.originalGetContext=e.getContext,e.getContext=function(t,n){if(t==="webgl"||t==="experimental-webgl"){const s=this.originalGetContext("webgl2",n);return s instanceof HTMLElement&&qN(s),s}return this.originalGetContext(t,n)}}function qN(i){i.getExtension("EXT_color_buffer_float");const e={...HN,WEBGL_disjoint_timer_query:i.getExtension("EXT_disjoint_timer_query_webgl2"),WEBGL_draw_buffers:VN(i),OES_vertex_array_object:GN(i),ANGLE_instanced_arrays:WN(i)},t=i.getExtension;i.getExtension=function(s){return t.call(i,s)||(s in e?e[s]:null)};const n=i.getSupportedExtensions;i.getSupportedExtensions=function(){const s=n.apply(i)||[];return s==null?void 0:s.concat(Object.keys(e))}}async function w2(i,e){const t=document.getElementsByTagName("head")[0];if(!t)throw new Error("loadScript");const n=document.createElement("script");return n.setAttribute("type","text/javascript"),n.setAttribute("src",i),new Promise((s,r)=>{n.onload=s,n.onerror=o=>r(new Error(`Unable to load script '${i}': ${o}`)),t.appendChild(n)})}const XN=1;let hi=null,Y0=!1;const uy={debugSpectorJS:le.get("debug-spectorjs"),debugSpectorJSUrl:"https://cdn.jsdelivr.net/npm/spectorjs@0.9.30/dist/spector.bundle.js",gl:void 0};async function KN(i){if(!globalThis.SPECTOR)try{await w2(i.debugSpectorJSUrl||uy.debugSpectorJSUrl)}catch(e){le.warn(String(e))}}function gte(i){var e;if(i={...uy,...i},!i.debugSpectorJS)return null;if(!hi&&globalThis.SPECTOR&&!((e=globalThis.luma)!=null&&e.spector)){le.probe(XN,"SPECTOR found and initialized. Start with `luma.spector.displayUI()`")();const{Spector:t}=globalThis.SPECTOR;hi=new t,globalThis.luma&&(globalThis.luma.spector=hi)}if(!hi)return null;if(Y0||(Y0=!0,hi.spyCanvases(),hi==null||hi.onCaptureStarted.add(t=>le.info("Spector capture started:",t)()),hi==null||hi.onCapture.add(t=>{le.info("Spector capture complete:",t)(),hi==null||hi.getResultUI(),hi==null||hi.resultView.display(),hi==null||hi.resultView.addCapture(t)})),i.gl){const t=i.gl,n=t.device;hi==null||hi.startCapture(i.gl,500),t.device=n,new Promise(s=>setTimeout(s,2e3)).then(s=>{le.info("Spector capture stopped after 2 seconds")(),hi==null||hi.stopCapture()})}return hi}const ZN="https://unpkg.com/webgl-debug@2.0.1/index.js";function S2(i){return i.luma=i.luma||{},i.luma}async function QN(){Vu()&&!globalThis.WebGLDebugUtils&&(globalThis.global=globalThis.global||globalThis,globalThis.global.module={},await w2(ZN))}function _te(i,e={}){return e.debugWebGL||e.traceWebGL?eD(i,e):JN(i)}function JN(i){const e=S2(i);return e.realContext?e.realContext:i}function eD(i,e){if(!globalThis.WebGLDebugUtils)return le.warn("webgl-debug not loaded")(),i;const t=S2(i);if(t.debugContext)return t.debugContext;globalThis.WebGLDebugUtils.init({...Do,...i});const n=globalThis.WebGLDebugUtils.makeDebugContext(i,tD.bind(null,e),iD.bind(null,e));for(const o in Do)!(o in n)&&typeof Do[o]=="number"&&(n[o]=Do[o]);class s{}Object.setPrototypeOf(n,Object.getPrototypeOf(i)),Object.setPrototypeOf(s,n);const r=Object.create(s);return t.realContext=i,t.debugContext=r,r.debug=!0,r}function q0(i,e){e=Array.from(e).map(n=>n===void 0?"undefined":n);let t=globalThis.WebGLDebugUtils.glFunctionArgsToString(i,e);return t=`${t.slice(0,100)}${t.length>100?"...":""}`,`gl.${i}(${t})`}function tD(i,e,t,n){n=Array.from(n).map(a=>a===void 0?"undefined":a);const s=globalThis.WebGLDebugUtils.glEnumToString(e),r=globalThis.WebGLDebugUtils.glFunctionArgsToString(t,n),o=`${s} in gl.${t}(${r})`;le.error(o)();debugger}function iD(i,e,t){let n="";le.level>=1&&(n=q0(e,t),i.traceWebGL&&le.log(1,n)());for(const s of t)if(s===void 0){n=n||q0(e,t);debugger}}const wd=1;class nD extends fN{constructor(){super(),U(this,"type","webgl"),bg.defaultProps={...bg.defaultProps,...uy}}enforceWebGL2(e){YN(e)}isSupported(){return typeof WebGL2RenderingContext<"u"}isDeviceHandle(e){return typeof WebGL2RenderingContext<"u"&&e instanceof WebGL2RenderingContext?!0:(typeof WebGLRenderingContext<"u"&&e instanceof WebGLRenderingContext&&le.warn("WebGL1 is not supported",e)(),!1)}async attach(e,t={}){const{WebGLDevice:n}=await l0(async()=>{const{WebGLDevice:r}=await import("./webgl-device-QoBMYpnS-BpXBJEpQ.js");return{WebGLDevice:r}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]));if(e instanceof n)return e;if((e==null?void 0:e.device)instanceof n)return e.device;if(!sD(e))throw new Error("Invalid WebGL2RenderingContext");const s=t.createCanvasContext===!0?{}:t.createCanvasContext;return new n({...t,_handle:e,createCanvasContext:{canvas:e.canvas,autoResize:!1,...s}})}async create(e={}){const{WebGLDevice:t}=await l0(async()=>{const{WebGLDevice:n}=await import("./webgl-device-QoBMYpnS-BpXBJEpQ.js");return{WebGLDevice:n}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]));le.groupCollapsed(wd,"WebGLDevice created")();try{const n=[];(e.debugWebGL||e.debug)&&n.push(QN()),e.debugSpectorJS&&n.push(KN(e));const s=await Promise.allSettled(n);for(const a of s)a.status==="rejected"&&le.error(`Failed to initialize debug libraries ${a.reason}`)();const r=new t(e),o=`${r._reused?"Reusing":"Created"} device with WebGL2 ${r.props.debug?"debug ":""}context: ${r.info.vendor}, ${r.info.renderer} for canvas: ${r.canvasContext.id}`;return le.probe(wd,o)(),le.table(wd,r.info)(),r}finally{le.groupEnd(wd)()}}}function sD(i){return typeof WebGL2RenderingContext<"u"&&i instanceof WebGL2RenderingContext?!0:!!(i&&Number.isFinite(i._version))}const rD=new nD,oD="#b3b3b3",aD=void 0,wg=void 0,lD=1,cD=4,uD="#666666",dD=.1,hD=1,fD=1,E2="#222222",pe={enableSimulation:!0,spaceSize:8192,pointSizeScale:1,linkWidthScale:1,linkArrowsSizeScale:1,renderLinks:!0,curvedLinks:!1,curvedLinkSegments:19,curvedLinkWeight:.8,curvedLinkControlPointDistance:.5,linkArrows:!1,linkVisibilityDistanceRange:[50,150],linkVisibilityMinTransparency:.25,hoveredPointCursor:"auto",hoveredLinkCursor:"auto",renderHoveredPointRing:!1,hoveredPointRingColor:"white",hoveredLinkColor:void 0,hoveredLinkWidthIncrease:5,focusedPointRingColor:"white",focusedPointIndex:void 0,simulation:{decay:5e3,gravity:.25,center:0,repulsion:1,repulsionTheta:1.15,linkSpring:1,linkDistance:10,linkDistRandomVariationRange:[1,1.2],repulsionFromMouse:2,friction:.85,cluster:.1},showFPSMonitor:!1,pixelRatio:typeof window<"u"&&window.devicePixelRatio||2,scalePointsOnZoom:!1,scaleLinksOnZoom:!1,enableZoom:!0,enableSimulationDuringZoom:!1,enableDrag:!1,fitViewOnInit:!0,fitViewDelay:250,fitViewPadding:.1,fitViewDuration:250,pointSamplingDistance:150,attribution:"",rescalePositions:void 0,enableRightClickRepulsion:!1},pD=.7,mD=.95,gD=3;/*! @license DOMPurify 3.2.6 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.2.6/LICENSE */const{entries:C2,setPrototypeOf:X0,isFrozen:_D,getPrototypeOf:yD,getOwnPropertyDescriptor:bD}=Object;let{freeze:hn,seal:_s,create:T2}=Object,{apply:Sg,construct:Eg}=typeof Reflect<"u"&&Reflect;hn||(hn=function(i){return i});_s||(_s=function(i){return i});Sg||(Sg=function(i,e,t){return i.apply(e,t)});Eg||(Eg=function(i,e){return new i(...e)});const Sd=fn(Array.prototype.forEach),vD=fn(Array.prototype.lastIndexOf),K0=fn(Array.prototype.pop),ac=fn(Array.prototype.push),xD=fn(Array.prototype.splice),uh=fn(String.prototype.toLowerCase),Jp=fn(String.prototype.toString),Z0=fn(String.prototype.match),lc=fn(String.prototype.replace),wD=fn(String.prototype.indexOf),SD=fn(String.prototype.trim),Ms=fn(Object.prototype.hasOwnProperty),sn=fn(RegExp.prototype.test),cc=ED(TypeError);function fn(i){return function(e){e instanceof RegExp&&(e.lastIndex=0);for(var t=arguments.length,n=new Array(t>1?t-1:0),s=1;s2&&arguments[2]!==void 0?arguments[2]:uh;X0&&X0(i,null);let n=e.length;for(;n--;){let s=e[n];if(typeof s=="string"){const r=t(s);r!==s&&(_D(e)||(e[n]=r),s=r)}i[s]=!0}return i}function CD(i){for(let e=0;e/gm),LD=_s(/\$\{[\w\W]*/gm),RD=_s(/^data-[\-\w.\u00B7-\uFFFF]+$/),PD=_s(/^aria-[\-\w]+$/),k2=_s(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),ND=_s(/^(?:\w+script|data):/i),DD=_s(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),A2=_s(/^html$/i),MD=_s(/^[a-z][.\w]*(-[.\w]+)+$/i);var ix=Object.freeze({__proto__:null,ARIA_ATTR:PD,ATTR_WHITESPACE:DD,CUSTOM_ELEMENT:MD,DATA_ATTR:RD,DOCTYPE_NAME:A2,ERB_EXPR:ID,IS_ALLOWED_URI:k2,IS_SCRIPT_OR_DATA:ND,MUSTACHE_EXPR:AD,TMPLIT_EXPR:LD});const dc={element:1,text:3,progressingInstruction:7,comment:8,document:9},OD=function(){return typeof window>"u"?null:window},BD=function(i,e){if(typeof i!="object"||typeof i.createPolicy!="function")return null;let t=null;const n="data-tt-policy-suffix";e&&e.hasAttribute(n)&&(t=e.getAttribute(n));const s="dompurify"+(t?"#"+t:"");try{return i.createPolicy(s,{createHTML(r){return r},createScriptURL(r){return r}})}catch{return console.warn("TrustedTypes policy "+s+" could not be created."),null}},nx=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function I2(){let i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:OD();const e=I=>I2(I);if(e.version="3.2.6",e.removed=[],!i||!i.document||i.document.nodeType!==dc.document||!i.Element)return e.isSupported=!1,e;let{document:t}=i;const n=t,s=n.currentScript,{DocumentFragment:r,HTMLTemplateElement:o,Node:a,Element:l,NodeFilter:c,NamedNodeMap:u=i.NamedNodeMap||i.MozNamedAttrMap,HTMLFormElement:d,DOMParser:h,trustedTypes:p}=i,m=l.prototype,y=uc(m,"cloneNode"),g=uc(m,"remove"),_=uc(m,"nextSibling"),S=uc(m,"childNodes"),C=uc(m,"parentNode");if(typeof o=="function"){const I=t.createElement("template");I.content&&I.content.ownerDocument&&(t=I.content.ownerDocument)}let x,A="";const{implementation:L,createNodeIterator:B,createDocumentFragment:H,getElementsByTagName:Q}=t,{importNode:te}=n;let M=nx();e.isSupported=typeof C2=="function"&&typeof C=="function"&&L&&L.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:he,ERB_EXPR:se,TMPLIT_EXPR:R,DATA_ATTR:J,ARIA_ATTR:F,IS_SCRIPT_OR_DATA:X,ATTR_WHITESPACE:ie,CUSTOM_ELEMENT:ee}=ix;let{IS_ALLOWED_URI:ae}=ix,Z=null;const Se=ot({},[...Q0,...em,...tm,...im,...J0]);let xe=null;const Je=ot({},[...ex,...nm,...tx,...Ed]);let de=Object.seal(T2(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),bt=null,Xe=null,ht=!0,re=!0,Te=!1,Pe=!0,q=!1,We=!0,He=!1,it=!1,Vt=!1,me=!1,nt=!1,ui=!1,_i=!0,Zn=!1;const Qo="user-content-";let Zs=!0,Li=!1,en={},Ri=null;const ai=ot({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let vo=null;const Es=ot({},["audio","video","img","source","image","track"]);let Qn=null;const Jn=ot({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Cs="http://www.w3.org/1998/Math/MathML",zi="http://www.w3.org/2000/svg",Ei="http://www.w3.org/1999/xhtml";let ii=Ei,bn=!1,vn=null;const Ts=ot({},[Cs,zi,Ei],Jp);let On=ot({},["mi","mo","mn","ms","mtext"]),es=ot({},["annotation-xml"]);const Dr=ot({},["title","style","font","a","script"]);let xn=null;const Qs=["application/xhtml+xml","text/html"],Jo="text/html";let Zt=null,Ot=null;const ks=t.createElement("form"),xo=function(I){return I instanceof RegExp||I instanceof Function},Js=function(){let I=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(Ot&&Ot===I)){if((!I||typeof I!="object")&&(I={}),I=Hr(I),xn=Qs.indexOf(I.PARSER_MEDIA_TYPE)===-1?Jo:I.PARSER_MEDIA_TYPE,Zt=xn==="application/xhtml+xml"?Jp:uh,Z=Ms(I,"ALLOWED_TAGS")?ot({},I.ALLOWED_TAGS,Zt):Se,xe=Ms(I,"ALLOWED_ATTR")?ot({},I.ALLOWED_ATTR,Zt):Je,vn=Ms(I,"ALLOWED_NAMESPACES")?ot({},I.ALLOWED_NAMESPACES,Jp):Ts,Qn=Ms(I,"ADD_URI_SAFE_ATTR")?ot(Hr(Jn),I.ADD_URI_SAFE_ATTR,Zt):Jn,vo=Ms(I,"ADD_DATA_URI_TAGS")?ot(Hr(Es),I.ADD_DATA_URI_TAGS,Zt):Es,Ri=Ms(I,"FORBID_CONTENTS")?ot({},I.FORBID_CONTENTS,Zt):ai,bt=Ms(I,"FORBID_TAGS")?ot({},I.FORBID_TAGS,Zt):Hr({}),Xe=Ms(I,"FORBID_ATTR")?ot({},I.FORBID_ATTR,Zt):Hr({}),en=Ms(I,"USE_PROFILES")?I.USE_PROFILES:!1,ht=I.ALLOW_ARIA_ATTR!==!1,re=I.ALLOW_DATA_ATTR!==!1,Te=I.ALLOW_UNKNOWN_PROTOCOLS||!1,Pe=I.ALLOW_SELF_CLOSE_IN_ATTR!==!1,q=I.SAFE_FOR_TEMPLATES||!1,We=I.SAFE_FOR_XML!==!1,He=I.WHOLE_DOCUMENT||!1,me=I.RETURN_DOM||!1,nt=I.RETURN_DOM_FRAGMENT||!1,ui=I.RETURN_TRUSTED_TYPE||!1,Vt=I.FORCE_BODY||!1,_i=I.SANITIZE_DOM!==!1,Zn=I.SANITIZE_NAMED_PROPS||!1,Zs=I.KEEP_CONTENT!==!1,Li=I.IN_PLACE||!1,ae=I.ALLOWED_URI_REGEXP||k2,ii=I.NAMESPACE||Ei,On=I.MATHML_TEXT_INTEGRATION_POINTS||On,es=I.HTML_INTEGRATION_POINTS||es,de=I.CUSTOM_ELEMENT_HANDLING||{},I.CUSTOM_ELEMENT_HANDLING&&xo(I.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(de.tagNameCheck=I.CUSTOM_ELEMENT_HANDLING.tagNameCheck),I.CUSTOM_ELEMENT_HANDLING&&xo(I.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(de.attributeNameCheck=I.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),I.CUSTOM_ELEMENT_HANDLING&&typeof I.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(de.allowCustomizedBuiltInElements=I.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),q&&(re=!1),nt&&(me=!0),en&&(Z=ot({},J0),xe=[],en.html===!0&&(ot(Z,Q0),ot(xe,ex)),en.svg===!0&&(ot(Z,em),ot(xe,nm),ot(xe,Ed)),en.svgFilters===!0&&(ot(Z,tm),ot(xe,nm),ot(xe,Ed)),en.mathMl===!0&&(ot(Z,im),ot(xe,tx),ot(xe,Ed))),I.ADD_TAGS&&(Z===Se&&(Z=Hr(Z)),ot(Z,I.ADD_TAGS,Zt)),I.ADD_ATTR&&(xe===Je&&(xe=Hr(xe)),ot(xe,I.ADD_ATTR,Zt)),I.ADD_URI_SAFE_ATTR&&ot(Qn,I.ADD_URI_SAFE_ATTR,Zt),I.FORBID_CONTENTS&&(Ri===ai&&(Ri=Hr(Ri)),ot(Ri,I.FORBID_CONTENTS,Zt)),Zs&&(Z["#text"]=!0),He&&ot(Z,["html","head","body"]),Z.table&&(ot(Z,["tbody"]),delete bt.tbody),I.TRUSTED_TYPES_POLICY){if(typeof I.TRUSTED_TYPES_POLICY.createHTML!="function")throw cc('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof I.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw cc('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');x=I.TRUSTED_TYPES_POLICY,A=x.createHTML("")}else x===void 0&&(x=BD(p,s)),x!==null&&typeof A=="string"&&(A=x.createHTML(""));hn&&hn(I),Ot=I}},Rt=ot({},[...em,...tm,...TD]),Mr=ot({},[...im,...kD]),ea=function(I){let V=C(I);(!V||!V.tagName)&&(V={namespaceURI:ii,tagName:"template"});const E=uh(I.tagName),G=uh(V.tagName);return vn[I.namespaceURI]?I.namespaceURI===zi?V.namespaceURI===Ei?E==="svg":V.namespaceURI===Cs?E==="svg"&&(G==="annotation-xml"||On[G]):!!Rt[E]:I.namespaceURI===Cs?V.namespaceURI===Ei?E==="math":V.namespaceURI===zi?E==="math"&&es[G]:!!Mr[E]:I.namespaceURI===Ei?V.namespaceURI===zi&&!es[G]||V.namespaceURI===Cs&&!On[G]?!1:!Mr[E]&&(Dr[E]||!Rt[E]):!!(xn==="application/xhtml+xml"&&vn[I.namespaceURI]):!1},ts=function(I){ac(e.removed,{element:I});try{C(I).removeChild(I)}catch{g(I)}},di=function(I,V){try{ac(e.removed,{attribute:V.getAttributeNode(I),from:V})}catch{ac(e.removed,{attribute:null,from:V})}if(V.removeAttribute(I),I==="is")if(me||nt)try{ts(V)}catch{}else try{V.setAttribute(I,"")}catch{}},Bn=function(I){let V=null,E=null;if(Vt)I=""+I;else{const Ce=Z0(I,/^[\r\n\t ]+/);E=Ce&&Ce[0]}xn==="application/xhtml+xml"&&ii===Ei&&(I=''+I+"");const G=x?x.createHTML(I):I;if(ii===Ei)try{V=new h().parseFromString(G,xn)}catch{}if(!V||!V.documentElement){V=L.createDocument(ii,"template",null);try{V.documentElement.innerHTML=bn?A:G}catch{}}const ne=V.body||V.documentElement;return I&&E&&ne.insertBefore(t.createTextNode(E),ne.childNodes[0]||null),ii===Ei?Q.call(V,He?"html":"body")[0]:He?V.documentElement:ne},wo=function(I){return B.call(I.ownerDocument||I,I,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},ut=function(I){return I instanceof d&&(typeof I.nodeName!="string"||typeof I.textContent!="string"||typeof I.removeChild!="function"||!(I.attributes instanceof u)||typeof I.removeAttribute!="function"||typeof I.setAttribute!="function"||typeof I.namespaceURI!="string"||typeof I.insertBefore!="function"||typeof I.hasChildNodes!="function")},Or=function(I){return typeof a=="function"&&I instanceof a};function st(I,V,E){Sd(I,G=>{G.call(e,V,E,Ot)})}const wn=function(I){let V=null;if(st(M.beforeSanitizeElements,I,null),ut(I))return ts(I),!0;const E=Zt(I.nodeName);if(st(M.uponSanitizeElement,I,{tagName:E,allowedTags:Z}),We&&I.hasChildNodes()&&!Or(I.firstElementChild)&&sn(/<[/\w!]/g,I.innerHTML)&&sn(/<[/\w!]/g,I.textContent)||I.nodeType===dc.progressingInstruction||We&&I.nodeType===dc.comment&&sn(/<[/\w]/g,I.data))return ts(I),!0;if(!Z[E]||bt[E]){if(!bt[E]&&er(E)&&(de.tagNameCheck instanceof RegExp&&sn(de.tagNameCheck,E)||de.tagNameCheck instanceof Function&&de.tagNameCheck(E)))return!1;if(Zs&&!Ri[E]){const G=C(I)||I.parentNode,ne=S(I)||I.childNodes;if(ne&&G){const Ce=ne.length;for(let At=Ce-1;At>=0;--At){const rt=y(ne[At],!0);rt.__removalCount=(I.__removalCount||0)+1,G.insertBefore(rt,_(I))}}}return ts(I),!0}return I instanceof l&&!ea(I)||(E==="noscript"||E==="noembed"||E==="noframes")&&sn(/<\/no(script|embed|frames)/i,I.innerHTML)?(ts(I),!0):(q&&I.nodeType===dc.text&&(V=I.textContent,Sd([he,se,R],G=>{V=lc(V,G," ")}),I.textContent!==V&&(ac(e.removed,{element:I.cloneNode()}),I.textContent=V)),st(M.afterSanitizeElements,I,null),!1)},Br=function(I,V,E){if(_i&&(V==="id"||V==="name")&&(E in t||E in ks))return!1;if(!(re&&!Xe[V]&&sn(J,V))&&!(ht&&sn(F,V))){if(!xe[V]||Xe[V]){if(!(er(I)&&(de.tagNameCheck instanceof RegExp&&sn(de.tagNameCheck,I)||de.tagNameCheck instanceof Function&&de.tagNameCheck(I))&&(de.attributeNameCheck instanceof RegExp&&sn(de.attributeNameCheck,V)||de.attributeNameCheck instanceof Function&&de.attributeNameCheck(V))||V==="is"&&de.allowCustomizedBuiltInElements&&(de.tagNameCheck instanceof RegExp&&sn(de.tagNameCheck,E)||de.tagNameCheck instanceof Function&&de.tagNameCheck(E))))return!1}else if(!Qn[V]&&!sn(ae,lc(E,ie,""))&&!((V==="src"||V==="xlink:href"||V==="href")&&I!=="script"&&wD(E,"data:")===0&&vo[I])&&!(Te&&!sn(X,lc(E,ie,"")))&&E)return!1}return!0},er=function(I){return I!=="annotation-xml"&&Z0(I,ee)},Fn=function(I){st(M.beforeSanitizeAttributes,I,null);const{attributes:V}=I;if(!V||ut(I))return;const E={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:xe,forceKeepAttr:void 0};let G=V.length;for(;G--;){const ne=V[G],{name:Ce,namespaceURI:At,value:rt}=ne,et=Zt(Ce),yi=rt;let ft=Ce==="value"?yi:SD(yi);if(E.attrName=et,E.attrValue=ft,E.keepAttr=!0,E.forceKeepAttr=void 0,st(M.uponSanitizeAttribute,I,E),ft=E.attrValue,Zn&&(et==="id"||et==="name")&&(di(Ce,I),ft=Qo+ft),We&&sn(/((--!?|])>)|<\/(style|title)/i,ft)){di(Ce,I);continue}if(E.forceKeepAttr)continue;if(!E.keepAttr){di(Ce,I);continue}if(!Pe&&sn(/\/>/i,ft)){di(Ce,I);continue}q&&Sd([he,se,R],Bt=>{ft=lc(ft,Bt," ")});const tr=Zt(I.nodeName);if(!Br(tr,et,ft)){di(Ce,I);continue}if(x&&typeof p=="object"&&typeof p.getAttributeType=="function"&&!At)switch(p.getAttributeType(tr,et)){case"TrustedHTML":{ft=x.createHTML(ft);break}case"TrustedScriptURL":{ft=x.createScriptURL(ft);break}}if(ft!==yi)try{At?I.setAttributeNS(At,Ce,ft):I.setAttribute(Ce,ft),ut(I)?ts(I):K0(e.removed)}catch{di(Ce,I)}}st(M.afterSanitizeAttributes,I,null)},tn=function I(V){let E=null;const G=wo(V);for(st(M.beforeSanitizeShadowDOM,V,null);E=G.nextNode();)st(M.uponSanitizeShadowNode,E,null),wn(E),Fn(E),E.content instanceof r&&I(E.content);st(M.afterSanitizeShadowDOM,V,null)};return e.sanitize=function(I){let V=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},E=null,G=null,ne=null,Ce=null;if(bn=!I,bn&&(I=""),typeof I!="string"&&!Or(I))if(typeof I.toString=="function"){if(I=I.toString(),typeof I!="string")throw cc("dirty is not a string, aborting")}else throw cc("toString is not a function");if(!e.isSupported)return I;if(it||Js(V),e.removed=[],typeof I=="string"&&(Li=!1),Li){if(I.nodeName){const et=Zt(I.nodeName);if(!Z[et]||bt[et])throw cc("root node is forbidden and cannot be sanitized in-place")}}else if(I instanceof a)E=Bn(""),G=E.ownerDocument.importNode(I,!0),G.nodeType===dc.element&&G.nodeName==="BODY"||G.nodeName==="HTML"?E=G:E.appendChild(G);else{if(!me&&!q&&!He&&I.indexOf("<")===-1)return x&&ui?x.createHTML(I):I;if(E=Bn(I),!E)return me?null:ui?A:""}E&&Vt&&ts(E.firstChild);const At=wo(Li?I:E);for(;ne=At.nextNode();)wn(ne),Fn(ne),ne.content instanceof r&&tn(ne.content);if(Li)return I;if(me){if(nt)for(Ce=H.call(E.ownerDocument);E.firstChild;)Ce.appendChild(E.firstChild);else Ce=E;return(xe.shadowroot||xe.shadowrootmode)&&(Ce=te.call(n,Ce,!0)),Ce}let rt=He?E.outerHTML:E.innerHTML;return He&&Z["!doctype"]&&E.ownerDocument&&E.ownerDocument.doctype&&E.ownerDocument.doctype.name&&sn(A2,E.ownerDocument.doctype.name)&&(rt=" +`,l.style.top="10px",l.style.left="10px",l.style.position="absolute",l.style.zIndex="9999",l.style.width="100%",l.style.textAlign="left",document.body.appendChild(l),(n=document.getElementsByClassName("luma-compiler-log-error")[0])==null||n.scrollIntoView(),l.onclick=()=>{const c=`data:text/plain,${encodeURIComponent(this.source)}`;navigator.clipboard.writeText(c)}}};U(p2,"defaultProps",{..._n.defaultProps,language:"auto",stage:void 0,source:"",sourceMap:null,entryPoint:"main",debugShaders:void 0});let SN=p2;function EN(i){return CN(i.source)||i.id||oy(`unnamed ${i.stage}-shader`)}function CN(i,e="unnamed"){const t=/#define[\s*]SHADER_NAME[\s*]([A-Za-z0-9_-]+)[\s*]/.exec(i);return t?t[1]:e}const g2=class _2 extends _n{constructor(e,t){super(e,t,_2.defaultProps),U(this,"shaderLayout"),U(this,"bufferLayout"),U(this,"linkStatus","pending"),U(this,"hash",""),this.shaderLayout=this.props.shaderLayout,this.bufferLayout=this.props.bufferLayout||[]}get[Symbol.toStringTag](){return"RenderPipeline"}};U(g2,"defaultProps",{..._n.defaultProps,vs:null,vertexEntryPoint:"vertexMain",vsConstants:{},fs:null,fragmentEntryPoint:"fragmentMain",fsConstants:{},shaderLayout:null,bufferLayout:[],topology:"triangle-list",colorAttachmentFormats:void 0,depthStencilAttachmentFormat:void 0,parameters:{},bindings:{},uniforms:{}});let Xh=g2;const y2=class b2 extends _n{constructor(e,t){super(e,t,b2.defaultProps),U(this,"hash",""),U(this,"shaderLayout"),this.shaderLayout=t.shaderLayout}get[Symbol.toStringTag](){return"ComputePipeline"}};U(y2,"defaultProps",{..._n.defaultProps,shader:void 0,entryPoint:void 0,constants:{},shaderLayout:void 0});let W0=y2;function TN(i){return LN[i]}function kN(i){const[e,t]=IN[i],n=e==="i32"||e==="u32",s=e!=="u32",r=AN[e]*t;return{primitiveType:e,components:t,byteLength:r,integer:n,signed:s}}const AN={f32:4,f16:2,i32:4,u32:4},IN={f32:["f32",1],"vec2":["f32",2],"vec3":["f32",3],"vec4":["f32",4],f16:["f16",1],"vec2":["f16",2],"vec3":["f16",3],"vec4":["f16",4],i32:["i32",1],"vec2":["i32",2],"vec3":["i32",3],"vec4":["i32",4],u32:["u32",1],"vec2":["u32",2],"vec3":["u32",3],"vec4":["u32",4]},LN={f32:{type:"f32",components:1},f16:{type:"f16",components:1},i32:{type:"i32",components:1},u32:{type:"u32",components:1},"vec2":{type:"f32",components:2},"vec3":{type:"f32",components:3},"vec4":{type:"f32",components:4},"vec2":{type:"f16",components:2},"vec3":{type:"f16",components:3},"vec4":{type:"f16",components:4},"vec2":{type:"i32",components:2},"vec3":{type:"i32",components:3},"vec4":{type:"i32",components:4},"vec2":{type:"u32",components:2},"vec3":{type:"u32",components:3},"vec4":{type:"u32",components:4},"mat2x2":{type:"f32",components:4},"mat2x3":{type:"f32",components:6},"mat2x4":{type:"f32",components:8},"mat3x2":{type:"f32",components:6},"mat3x3":{type:"f32",components:9},"mat3x4":{type:"f32",components:12},"mat4x2":{type:"f32",components:8},"mat4x3":{type:"f32",components:12},"mat4x4":{type:"f32",components:16},"mat2x2":{type:"f16",components:4},"mat2x3":{type:"f16",components:6},"mat2x4":{type:"f16",components:8},"mat3x2":{type:"f16",components:6},"mat3x3":{type:"f16",components:9},"mat3x4":{type:"f16",components:12},"mat4x2":{type:"f16",components:8},"mat4x3":{type:"f16",components:12},"mat4x4":{type:"f16",components:16},"mat2x2":{type:"i32",components:4},"mat2x3":{type:"i32",components:6},"mat2x4":{type:"i32",components:8},"mat3x2":{type:"i32",components:6},"mat3x3":{type:"i32",components:9},"mat3x4":{type:"i32",components:12},"mat4x2":{type:"i32",components:8},"mat4x3":{type:"i32",components:12},"mat4x4":{type:"i32",components:16},"mat2x2":{type:"u32",components:4},"mat2x3":{type:"u32",components:6},"mat2x4":{type:"u32",components:8},"mat3x2":{type:"u32",components:6},"mat3x3":{type:"u32",components:9},"mat3x4":{type:"u32",components:12},"mat4x2":{type:"u32",components:8},"mat4x3":{type:"u32",components:12},"mat4x4":{type:"u32",components:16}};function v2(i,e){const t={};for(const n of i.attributes){const s=RN(i,e,n.name);s&&(t[n.name]=s)}return t}function fte(i,e,t=16){const n=v2(i,e),s=new Array(t).fill(null);for(const r of Object.values(n))s[r.location]=r;return s}function RN(i,e,t){const n=PN(i,t),s=NN(e,t);if(!n)return null;const r=kN(n.type),o=ZP(r),a=(s==null?void 0:s.vertexFormat)||o,l=ly(a);return{attributeName:(s==null?void 0:s.attributeName)||n.name,bufferName:(s==null?void 0:s.bufferName)||n.name,location:n.location,shaderType:n.type,primitiveType:r.primitiveType,shaderComponents:r.components,vertexFormat:a,bufferDataType:l.type,bufferComponents:l.components,normalized:l.normalized,integer:r.integer,stepMode:(s==null?void 0:s.stepMode)||n.stepMode||"vertex",byteOffset:(s==null?void 0:s.byteOffset)||0,byteStride:(s==null?void 0:s.byteStride)||0}}function PN(i,e){const t=i.attributes.find(n=>n.name===e);return t||le.warn(`shader layout attribute "${e}" not present in shader`),t||null}function NN(i,e){DN(i);let t=MN(i,e);return t||(t=ON(i,e),t)?t:(le.warn(`layout for attribute "${e}" not present in buffer layout`),null)}function DN(i){for(const e of i)(e.attributes&&e.format||!e.attributes&&!e.format)&&le.warn(`BufferLayout ${name} must have either 'attributes' or 'format' field`)}function MN(i,e){for(const t of i)if(t.format&&t.name===e)return{attributeName:t.name,bufferName:e,stepMode:t.stepMode,vertexFormat:t.format,byteOffset:0,byteStride:t.byteStride||0};return null}function ON(i,e){var t;for(const n of i){let s=n.byteStride;if(typeof n.byteStride!="number")for(const o of n.attributes||[]){const a=ly(o.format);s+=a.byteLength}const r=(t=n.attributes)==null?void 0:t.find(o=>o.attribute===e);if(r)return{attributeName:r.attribute,bufferName:n.name,stepMode:n.stepMode,vertexFormat:r.format,byteOffset:r.byteOffset,byteStride:s}}return null}let xd;function x2(i){return(!xd||xd.byteLengthr.type==="uniform"&&r.name===(e==null?void 0:e.name));if(!n)throw new Error(e==null?void 0:e.name);const s=n;for(const r of s.uniforms||[])this.bindingLayout[r.name]=r}}setUniforms(e){for(const[t,n]of Object.entries(e))this._setUniform(t,n),this.needsRedraw||this.setNeedsRedraw(`${this.name}.${t}=${n}`)}setNeedsRedraw(e){this.needsRedraw=this.needsRedraw||e}getAllUniforms(){return this.modifiedUniforms={},this.needsRedraw=!1,this.uniforms||{}}_setUniform(e,t){UN(this.uniforms[e],t)||(this.uniforms[e]=$N(t),this.modifiedUniforms[e]=!0,this.modified=!0)}}let ri=class{constructor(e){U(this,"uniformBlocks",new Map),U(this,"uniformBufferLayouts",new Map),U(this,"uniformBuffers",new Map);for(const[t,n]of Object.entries(e)){const s=t,r=new zN(n.uniformTypes??{},n.uniformSizes??{});this.uniformBufferLayouts.set(s,r);const o=new jN({name:t});o.setUniforms(n.defaultUniforms||{}),this.uniformBlocks.set(s,o)}}destroy(){for(const e of this.uniformBuffers.values())e.destroy()}setUniforms(e){var t;for(const[n,s]of Object.entries(e))(t=this.uniformBlocks.get(n))==null||t.setUniforms(s);this.updateUniformBuffers()}getUniformBufferByteLength(e){var t;return((t=this.uniformBufferLayouts.get(e))==null?void 0:t.byteLength)||0}getUniformBufferData(e){var t,n;const s=((t=this.uniformBlocks.get(e))==null?void 0:t.getAllUniforms())||{};return(n=this.uniformBufferLayouts.get(e))==null?void 0:n.getData(s)}createUniformBuffer(e,t,n){n&&this.setUniforms(n);const s=this.getUniformBufferByteLength(t),r=e.createBuffer({usage:ge.UNIFORM|ge.COPY_DST,byteLength:s}),o=this.getUniformBufferData(t);return r.write(o),r}getManagedUniformBuffer(e,t){if(!this.uniformBuffers.get(t)){const n=this.getUniformBufferByteLength(t),s=e.createBuffer({usage:ge.UNIFORM|ge.COPY_DST,byteLength:n});this.uniformBuffers.set(t,s)}return this.uniformBuffers.get(t)}updateUniformBuffers(){let e=!1;for(const t of this.uniformBlocks.keys()){const n=this.updateUniformBuffer(t);e||(e=n)}return e&&le.log(3,`UniformStore.updateUniformBuffers(): ${e}`)(),e}updateUniformBuffer(e){var t;const n=this.uniformBlocks.get(e);let s=this.uniformBuffers.get(e),r=!1;if(s&&n!=null&&n.needsRedraw){r||(r=n.needsRedraw);const o=this.getUniformBufferData(e);s=this.uniformBuffers.get(e),s==null||s.write(o);const a=(t=this.uniformBlocks.get(e))==null?void 0:t.getAllUniforms();le.log(4,`Writing to uniform buffer ${String(e)}`,o,a)()}return r}};var Do;(function(i){i[i.DEPTH_BUFFER_BIT=256]="DEPTH_BUFFER_BIT",i[i.STENCIL_BUFFER_BIT=1024]="STENCIL_BUFFER_BIT",i[i.COLOR_BUFFER_BIT=16384]="COLOR_BUFFER_BIT",i[i.POINTS=0]="POINTS",i[i.LINES=1]="LINES",i[i.LINE_LOOP=2]="LINE_LOOP",i[i.LINE_STRIP=3]="LINE_STRIP",i[i.TRIANGLES=4]="TRIANGLES",i[i.TRIANGLE_STRIP=5]="TRIANGLE_STRIP",i[i.TRIANGLE_FAN=6]="TRIANGLE_FAN",i[i.ZERO=0]="ZERO",i[i.ONE=1]="ONE",i[i.SRC_COLOR=768]="SRC_COLOR",i[i.ONE_MINUS_SRC_COLOR=769]="ONE_MINUS_SRC_COLOR",i[i.SRC_ALPHA=770]="SRC_ALPHA",i[i.ONE_MINUS_SRC_ALPHA=771]="ONE_MINUS_SRC_ALPHA",i[i.DST_ALPHA=772]="DST_ALPHA",i[i.ONE_MINUS_DST_ALPHA=773]="ONE_MINUS_DST_ALPHA",i[i.DST_COLOR=774]="DST_COLOR",i[i.ONE_MINUS_DST_COLOR=775]="ONE_MINUS_DST_COLOR",i[i.SRC_ALPHA_SATURATE=776]="SRC_ALPHA_SATURATE",i[i.CONSTANT_COLOR=32769]="CONSTANT_COLOR",i[i.ONE_MINUS_CONSTANT_COLOR=32770]="ONE_MINUS_CONSTANT_COLOR",i[i.CONSTANT_ALPHA=32771]="CONSTANT_ALPHA",i[i.ONE_MINUS_CONSTANT_ALPHA=32772]="ONE_MINUS_CONSTANT_ALPHA",i[i.FUNC_ADD=32774]="FUNC_ADD",i[i.FUNC_SUBTRACT=32778]="FUNC_SUBTRACT",i[i.FUNC_REVERSE_SUBTRACT=32779]="FUNC_REVERSE_SUBTRACT",i[i.BLEND_EQUATION=32777]="BLEND_EQUATION",i[i.BLEND_EQUATION_RGB=32777]="BLEND_EQUATION_RGB",i[i.BLEND_EQUATION_ALPHA=34877]="BLEND_EQUATION_ALPHA",i[i.BLEND_DST_RGB=32968]="BLEND_DST_RGB",i[i.BLEND_SRC_RGB=32969]="BLEND_SRC_RGB",i[i.BLEND_DST_ALPHA=32970]="BLEND_DST_ALPHA",i[i.BLEND_SRC_ALPHA=32971]="BLEND_SRC_ALPHA",i[i.BLEND_COLOR=32773]="BLEND_COLOR",i[i.ARRAY_BUFFER_BINDING=34964]="ARRAY_BUFFER_BINDING",i[i.ELEMENT_ARRAY_BUFFER_BINDING=34965]="ELEMENT_ARRAY_BUFFER_BINDING",i[i.LINE_WIDTH=2849]="LINE_WIDTH",i[i.ALIASED_POINT_SIZE_RANGE=33901]="ALIASED_POINT_SIZE_RANGE",i[i.ALIASED_LINE_WIDTH_RANGE=33902]="ALIASED_LINE_WIDTH_RANGE",i[i.CULL_FACE_MODE=2885]="CULL_FACE_MODE",i[i.FRONT_FACE=2886]="FRONT_FACE",i[i.DEPTH_RANGE=2928]="DEPTH_RANGE",i[i.DEPTH_WRITEMASK=2930]="DEPTH_WRITEMASK",i[i.DEPTH_CLEAR_VALUE=2931]="DEPTH_CLEAR_VALUE",i[i.DEPTH_FUNC=2932]="DEPTH_FUNC",i[i.STENCIL_CLEAR_VALUE=2961]="STENCIL_CLEAR_VALUE",i[i.STENCIL_FUNC=2962]="STENCIL_FUNC",i[i.STENCIL_FAIL=2964]="STENCIL_FAIL",i[i.STENCIL_PASS_DEPTH_FAIL=2965]="STENCIL_PASS_DEPTH_FAIL",i[i.STENCIL_PASS_DEPTH_PASS=2966]="STENCIL_PASS_DEPTH_PASS",i[i.STENCIL_REF=2967]="STENCIL_REF",i[i.STENCIL_VALUE_MASK=2963]="STENCIL_VALUE_MASK",i[i.STENCIL_WRITEMASK=2968]="STENCIL_WRITEMASK",i[i.STENCIL_BACK_FUNC=34816]="STENCIL_BACK_FUNC",i[i.STENCIL_BACK_FAIL=34817]="STENCIL_BACK_FAIL",i[i.STENCIL_BACK_PASS_DEPTH_FAIL=34818]="STENCIL_BACK_PASS_DEPTH_FAIL",i[i.STENCIL_BACK_PASS_DEPTH_PASS=34819]="STENCIL_BACK_PASS_DEPTH_PASS",i[i.STENCIL_BACK_REF=36003]="STENCIL_BACK_REF",i[i.STENCIL_BACK_VALUE_MASK=36004]="STENCIL_BACK_VALUE_MASK",i[i.STENCIL_BACK_WRITEMASK=36005]="STENCIL_BACK_WRITEMASK",i[i.VIEWPORT=2978]="VIEWPORT",i[i.SCISSOR_BOX=3088]="SCISSOR_BOX",i[i.COLOR_CLEAR_VALUE=3106]="COLOR_CLEAR_VALUE",i[i.COLOR_WRITEMASK=3107]="COLOR_WRITEMASK",i[i.UNPACK_ALIGNMENT=3317]="UNPACK_ALIGNMENT",i[i.PACK_ALIGNMENT=3333]="PACK_ALIGNMENT",i[i.MAX_TEXTURE_SIZE=3379]="MAX_TEXTURE_SIZE",i[i.MAX_VIEWPORT_DIMS=3386]="MAX_VIEWPORT_DIMS",i[i.SUBPIXEL_BITS=3408]="SUBPIXEL_BITS",i[i.RED_BITS=3410]="RED_BITS",i[i.GREEN_BITS=3411]="GREEN_BITS",i[i.BLUE_BITS=3412]="BLUE_BITS",i[i.ALPHA_BITS=3413]="ALPHA_BITS",i[i.DEPTH_BITS=3414]="DEPTH_BITS",i[i.STENCIL_BITS=3415]="STENCIL_BITS",i[i.POLYGON_OFFSET_UNITS=10752]="POLYGON_OFFSET_UNITS",i[i.POLYGON_OFFSET_FACTOR=32824]="POLYGON_OFFSET_FACTOR",i[i.TEXTURE_BINDING_2D=32873]="TEXTURE_BINDING_2D",i[i.SAMPLE_BUFFERS=32936]="SAMPLE_BUFFERS",i[i.SAMPLES=32937]="SAMPLES",i[i.SAMPLE_COVERAGE_VALUE=32938]="SAMPLE_COVERAGE_VALUE",i[i.SAMPLE_COVERAGE_INVERT=32939]="SAMPLE_COVERAGE_INVERT",i[i.COMPRESSED_TEXTURE_FORMATS=34467]="COMPRESSED_TEXTURE_FORMATS",i[i.VENDOR=7936]="VENDOR",i[i.RENDERER=7937]="RENDERER",i[i.VERSION=7938]="VERSION",i[i.IMPLEMENTATION_COLOR_READ_TYPE=35738]="IMPLEMENTATION_COLOR_READ_TYPE",i[i.IMPLEMENTATION_COLOR_READ_FORMAT=35739]="IMPLEMENTATION_COLOR_READ_FORMAT",i[i.BROWSER_DEFAULT_WEBGL=37444]="BROWSER_DEFAULT_WEBGL",i[i.STATIC_DRAW=35044]="STATIC_DRAW",i[i.STREAM_DRAW=35040]="STREAM_DRAW",i[i.DYNAMIC_DRAW=35048]="DYNAMIC_DRAW",i[i.ARRAY_BUFFER=34962]="ARRAY_BUFFER",i[i.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",i[i.BUFFER_SIZE=34660]="BUFFER_SIZE",i[i.BUFFER_USAGE=34661]="BUFFER_USAGE",i[i.CURRENT_VERTEX_ATTRIB=34342]="CURRENT_VERTEX_ATTRIB",i[i.VERTEX_ATTRIB_ARRAY_ENABLED=34338]="VERTEX_ATTRIB_ARRAY_ENABLED",i[i.VERTEX_ATTRIB_ARRAY_SIZE=34339]="VERTEX_ATTRIB_ARRAY_SIZE",i[i.VERTEX_ATTRIB_ARRAY_STRIDE=34340]="VERTEX_ATTRIB_ARRAY_STRIDE",i[i.VERTEX_ATTRIB_ARRAY_TYPE=34341]="VERTEX_ATTRIB_ARRAY_TYPE",i[i.VERTEX_ATTRIB_ARRAY_NORMALIZED=34922]="VERTEX_ATTRIB_ARRAY_NORMALIZED",i[i.VERTEX_ATTRIB_ARRAY_POINTER=34373]="VERTEX_ATTRIB_ARRAY_POINTER",i[i.VERTEX_ATTRIB_ARRAY_BUFFER_BINDING=34975]="VERTEX_ATTRIB_ARRAY_BUFFER_BINDING",i[i.CULL_FACE=2884]="CULL_FACE",i[i.FRONT=1028]="FRONT",i[i.BACK=1029]="BACK",i[i.FRONT_AND_BACK=1032]="FRONT_AND_BACK",i[i.BLEND=3042]="BLEND",i[i.DEPTH_TEST=2929]="DEPTH_TEST",i[i.DITHER=3024]="DITHER",i[i.POLYGON_OFFSET_FILL=32823]="POLYGON_OFFSET_FILL",i[i.SAMPLE_ALPHA_TO_COVERAGE=32926]="SAMPLE_ALPHA_TO_COVERAGE",i[i.SAMPLE_COVERAGE=32928]="SAMPLE_COVERAGE",i[i.SCISSOR_TEST=3089]="SCISSOR_TEST",i[i.STENCIL_TEST=2960]="STENCIL_TEST",i[i.NO_ERROR=0]="NO_ERROR",i[i.INVALID_ENUM=1280]="INVALID_ENUM",i[i.INVALID_VALUE=1281]="INVALID_VALUE",i[i.INVALID_OPERATION=1282]="INVALID_OPERATION",i[i.OUT_OF_MEMORY=1285]="OUT_OF_MEMORY",i[i.CONTEXT_LOST_WEBGL=37442]="CONTEXT_LOST_WEBGL",i[i.CW=2304]="CW",i[i.CCW=2305]="CCW",i[i.DONT_CARE=4352]="DONT_CARE",i[i.FASTEST=4353]="FASTEST",i[i.NICEST=4354]="NICEST",i[i.GENERATE_MIPMAP_HINT=33170]="GENERATE_MIPMAP_HINT",i[i.BYTE=5120]="BYTE",i[i.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",i[i.SHORT=5122]="SHORT",i[i.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",i[i.INT=5124]="INT",i[i.UNSIGNED_INT=5125]="UNSIGNED_INT",i[i.FLOAT=5126]="FLOAT",i[i.DOUBLE=5130]="DOUBLE",i[i.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",i[i.ALPHA=6406]="ALPHA",i[i.RGB=6407]="RGB",i[i.RGBA=6408]="RGBA",i[i.LUMINANCE=6409]="LUMINANCE",i[i.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",i[i.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",i[i.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",i[i.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",i[i.FRAGMENT_SHADER=35632]="FRAGMENT_SHADER",i[i.VERTEX_SHADER=35633]="VERTEX_SHADER",i[i.COMPILE_STATUS=35713]="COMPILE_STATUS",i[i.DELETE_STATUS=35712]="DELETE_STATUS",i[i.LINK_STATUS=35714]="LINK_STATUS",i[i.VALIDATE_STATUS=35715]="VALIDATE_STATUS",i[i.ATTACHED_SHADERS=35717]="ATTACHED_SHADERS",i[i.ACTIVE_ATTRIBUTES=35721]="ACTIVE_ATTRIBUTES",i[i.ACTIVE_UNIFORMS=35718]="ACTIVE_UNIFORMS",i[i.MAX_VERTEX_ATTRIBS=34921]="MAX_VERTEX_ATTRIBS",i[i.MAX_VERTEX_UNIFORM_VECTORS=36347]="MAX_VERTEX_UNIFORM_VECTORS",i[i.MAX_VARYING_VECTORS=36348]="MAX_VARYING_VECTORS",i[i.MAX_COMBINED_TEXTURE_IMAGE_UNITS=35661]="MAX_COMBINED_TEXTURE_IMAGE_UNITS",i[i.MAX_VERTEX_TEXTURE_IMAGE_UNITS=35660]="MAX_VERTEX_TEXTURE_IMAGE_UNITS",i[i.MAX_TEXTURE_IMAGE_UNITS=34930]="MAX_TEXTURE_IMAGE_UNITS",i[i.MAX_FRAGMENT_UNIFORM_VECTORS=36349]="MAX_FRAGMENT_UNIFORM_VECTORS",i[i.SHADER_TYPE=35663]="SHADER_TYPE",i[i.SHADING_LANGUAGE_VERSION=35724]="SHADING_LANGUAGE_VERSION",i[i.CURRENT_PROGRAM=35725]="CURRENT_PROGRAM",i[i.NEVER=512]="NEVER",i[i.LESS=513]="LESS",i[i.EQUAL=514]="EQUAL",i[i.LEQUAL=515]="LEQUAL",i[i.GREATER=516]="GREATER",i[i.NOTEQUAL=517]="NOTEQUAL",i[i.GEQUAL=518]="GEQUAL",i[i.ALWAYS=519]="ALWAYS",i[i.KEEP=7680]="KEEP",i[i.REPLACE=7681]="REPLACE",i[i.INCR=7682]="INCR",i[i.DECR=7683]="DECR",i[i.INVERT=5386]="INVERT",i[i.INCR_WRAP=34055]="INCR_WRAP",i[i.DECR_WRAP=34056]="DECR_WRAP",i[i.NEAREST=9728]="NEAREST",i[i.LINEAR=9729]="LINEAR",i[i.NEAREST_MIPMAP_NEAREST=9984]="NEAREST_MIPMAP_NEAREST",i[i.LINEAR_MIPMAP_NEAREST=9985]="LINEAR_MIPMAP_NEAREST",i[i.NEAREST_MIPMAP_LINEAR=9986]="NEAREST_MIPMAP_LINEAR",i[i.LINEAR_MIPMAP_LINEAR=9987]="LINEAR_MIPMAP_LINEAR",i[i.TEXTURE_MAG_FILTER=10240]="TEXTURE_MAG_FILTER",i[i.TEXTURE_MIN_FILTER=10241]="TEXTURE_MIN_FILTER",i[i.TEXTURE_WRAP_S=10242]="TEXTURE_WRAP_S",i[i.TEXTURE_WRAP_T=10243]="TEXTURE_WRAP_T",i[i.TEXTURE_2D=3553]="TEXTURE_2D",i[i.TEXTURE=5890]="TEXTURE",i[i.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",i[i.TEXTURE_BINDING_CUBE_MAP=34068]="TEXTURE_BINDING_CUBE_MAP",i[i.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",i[i.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",i[i.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",i[i.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",i[i.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",i[i.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z",i[i.MAX_CUBE_MAP_TEXTURE_SIZE=34076]="MAX_CUBE_MAP_TEXTURE_SIZE",i[i.TEXTURE0=33984]="TEXTURE0",i[i.ACTIVE_TEXTURE=34016]="ACTIVE_TEXTURE",i[i.REPEAT=10497]="REPEAT",i[i.CLAMP_TO_EDGE=33071]="CLAMP_TO_EDGE",i[i.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",i[i.TEXTURE_WIDTH=4096]="TEXTURE_WIDTH",i[i.TEXTURE_HEIGHT=4097]="TEXTURE_HEIGHT",i[i.FLOAT_VEC2=35664]="FLOAT_VEC2",i[i.FLOAT_VEC3=35665]="FLOAT_VEC3",i[i.FLOAT_VEC4=35666]="FLOAT_VEC4",i[i.INT_VEC2=35667]="INT_VEC2",i[i.INT_VEC3=35668]="INT_VEC3",i[i.INT_VEC4=35669]="INT_VEC4",i[i.BOOL=35670]="BOOL",i[i.BOOL_VEC2=35671]="BOOL_VEC2",i[i.BOOL_VEC3=35672]="BOOL_VEC3",i[i.BOOL_VEC4=35673]="BOOL_VEC4",i[i.FLOAT_MAT2=35674]="FLOAT_MAT2",i[i.FLOAT_MAT3=35675]="FLOAT_MAT3",i[i.FLOAT_MAT4=35676]="FLOAT_MAT4",i[i.SAMPLER_2D=35678]="SAMPLER_2D",i[i.SAMPLER_CUBE=35680]="SAMPLER_CUBE",i[i.LOW_FLOAT=36336]="LOW_FLOAT",i[i.MEDIUM_FLOAT=36337]="MEDIUM_FLOAT",i[i.HIGH_FLOAT=36338]="HIGH_FLOAT",i[i.LOW_INT=36339]="LOW_INT",i[i.MEDIUM_INT=36340]="MEDIUM_INT",i[i.HIGH_INT=36341]="HIGH_INT",i[i.FRAMEBUFFER=36160]="FRAMEBUFFER",i[i.RENDERBUFFER=36161]="RENDERBUFFER",i[i.RGBA4=32854]="RGBA4",i[i.RGB5_A1=32855]="RGB5_A1",i[i.RGB565=36194]="RGB565",i[i.DEPTH_COMPONENT16=33189]="DEPTH_COMPONENT16",i[i.STENCIL_INDEX=6401]="STENCIL_INDEX",i[i.STENCIL_INDEX8=36168]="STENCIL_INDEX8",i[i.DEPTH_STENCIL=34041]="DEPTH_STENCIL",i[i.RENDERBUFFER_WIDTH=36162]="RENDERBUFFER_WIDTH",i[i.RENDERBUFFER_HEIGHT=36163]="RENDERBUFFER_HEIGHT",i[i.RENDERBUFFER_INTERNAL_FORMAT=36164]="RENDERBUFFER_INTERNAL_FORMAT",i[i.RENDERBUFFER_RED_SIZE=36176]="RENDERBUFFER_RED_SIZE",i[i.RENDERBUFFER_GREEN_SIZE=36177]="RENDERBUFFER_GREEN_SIZE",i[i.RENDERBUFFER_BLUE_SIZE=36178]="RENDERBUFFER_BLUE_SIZE",i[i.RENDERBUFFER_ALPHA_SIZE=36179]="RENDERBUFFER_ALPHA_SIZE",i[i.RENDERBUFFER_DEPTH_SIZE=36180]="RENDERBUFFER_DEPTH_SIZE",i[i.RENDERBUFFER_STENCIL_SIZE=36181]="RENDERBUFFER_STENCIL_SIZE",i[i.FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE=36048]="FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE",i[i.FRAMEBUFFER_ATTACHMENT_OBJECT_NAME=36049]="FRAMEBUFFER_ATTACHMENT_OBJECT_NAME",i[i.FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL=36050]="FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL",i[i.FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE=36051]="FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE",i[i.COLOR_ATTACHMENT0=36064]="COLOR_ATTACHMENT0",i[i.DEPTH_ATTACHMENT=36096]="DEPTH_ATTACHMENT",i[i.STENCIL_ATTACHMENT=36128]="STENCIL_ATTACHMENT",i[i.DEPTH_STENCIL_ATTACHMENT=33306]="DEPTH_STENCIL_ATTACHMENT",i[i.NONE=0]="NONE",i[i.FRAMEBUFFER_COMPLETE=36053]="FRAMEBUFFER_COMPLETE",i[i.FRAMEBUFFER_INCOMPLETE_ATTACHMENT=36054]="FRAMEBUFFER_INCOMPLETE_ATTACHMENT",i[i.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT=36055]="FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT",i[i.FRAMEBUFFER_INCOMPLETE_DIMENSIONS=36057]="FRAMEBUFFER_INCOMPLETE_DIMENSIONS",i[i.FRAMEBUFFER_UNSUPPORTED=36061]="FRAMEBUFFER_UNSUPPORTED",i[i.FRAMEBUFFER_BINDING=36006]="FRAMEBUFFER_BINDING",i[i.RENDERBUFFER_BINDING=36007]="RENDERBUFFER_BINDING",i[i.READ_FRAMEBUFFER=36008]="READ_FRAMEBUFFER",i[i.DRAW_FRAMEBUFFER=36009]="DRAW_FRAMEBUFFER",i[i.MAX_RENDERBUFFER_SIZE=34024]="MAX_RENDERBUFFER_SIZE",i[i.INVALID_FRAMEBUFFER_OPERATION=1286]="INVALID_FRAMEBUFFER_OPERATION",i[i.UNPACK_FLIP_Y_WEBGL=37440]="UNPACK_FLIP_Y_WEBGL",i[i.UNPACK_PREMULTIPLY_ALPHA_WEBGL=37441]="UNPACK_PREMULTIPLY_ALPHA_WEBGL",i[i.UNPACK_COLORSPACE_CONVERSION_WEBGL=37443]="UNPACK_COLORSPACE_CONVERSION_WEBGL",i[i.READ_BUFFER=3074]="READ_BUFFER",i[i.UNPACK_ROW_LENGTH=3314]="UNPACK_ROW_LENGTH",i[i.UNPACK_SKIP_ROWS=3315]="UNPACK_SKIP_ROWS",i[i.UNPACK_SKIP_PIXELS=3316]="UNPACK_SKIP_PIXELS",i[i.PACK_ROW_LENGTH=3330]="PACK_ROW_LENGTH",i[i.PACK_SKIP_ROWS=3331]="PACK_SKIP_ROWS",i[i.PACK_SKIP_PIXELS=3332]="PACK_SKIP_PIXELS",i[i.TEXTURE_BINDING_3D=32874]="TEXTURE_BINDING_3D",i[i.UNPACK_SKIP_IMAGES=32877]="UNPACK_SKIP_IMAGES",i[i.UNPACK_IMAGE_HEIGHT=32878]="UNPACK_IMAGE_HEIGHT",i[i.MAX_3D_TEXTURE_SIZE=32883]="MAX_3D_TEXTURE_SIZE",i[i.MAX_ELEMENTS_VERTICES=33e3]="MAX_ELEMENTS_VERTICES",i[i.MAX_ELEMENTS_INDICES=33001]="MAX_ELEMENTS_INDICES",i[i.MAX_TEXTURE_LOD_BIAS=34045]="MAX_TEXTURE_LOD_BIAS",i[i.MAX_FRAGMENT_UNIFORM_COMPONENTS=35657]="MAX_FRAGMENT_UNIFORM_COMPONENTS",i[i.MAX_VERTEX_UNIFORM_COMPONENTS=35658]="MAX_VERTEX_UNIFORM_COMPONENTS",i[i.MAX_ARRAY_TEXTURE_LAYERS=35071]="MAX_ARRAY_TEXTURE_LAYERS",i[i.MIN_PROGRAM_TEXEL_OFFSET=35076]="MIN_PROGRAM_TEXEL_OFFSET",i[i.MAX_PROGRAM_TEXEL_OFFSET=35077]="MAX_PROGRAM_TEXEL_OFFSET",i[i.MAX_VARYING_COMPONENTS=35659]="MAX_VARYING_COMPONENTS",i[i.FRAGMENT_SHADER_DERIVATIVE_HINT=35723]="FRAGMENT_SHADER_DERIVATIVE_HINT",i[i.RASTERIZER_DISCARD=35977]="RASTERIZER_DISCARD",i[i.VERTEX_ARRAY_BINDING=34229]="VERTEX_ARRAY_BINDING",i[i.MAX_VERTEX_OUTPUT_COMPONENTS=37154]="MAX_VERTEX_OUTPUT_COMPONENTS",i[i.MAX_FRAGMENT_INPUT_COMPONENTS=37157]="MAX_FRAGMENT_INPUT_COMPONENTS",i[i.MAX_SERVER_WAIT_TIMEOUT=37137]="MAX_SERVER_WAIT_TIMEOUT",i[i.MAX_ELEMENT_INDEX=36203]="MAX_ELEMENT_INDEX",i[i.RED=6403]="RED",i[i.RGB8=32849]="RGB8",i[i.RGBA8=32856]="RGBA8",i[i.RGB10_A2=32857]="RGB10_A2",i[i.TEXTURE_3D=32879]="TEXTURE_3D",i[i.TEXTURE_WRAP_R=32882]="TEXTURE_WRAP_R",i[i.TEXTURE_MIN_LOD=33082]="TEXTURE_MIN_LOD",i[i.TEXTURE_MAX_LOD=33083]="TEXTURE_MAX_LOD",i[i.TEXTURE_BASE_LEVEL=33084]="TEXTURE_BASE_LEVEL",i[i.TEXTURE_MAX_LEVEL=33085]="TEXTURE_MAX_LEVEL",i[i.TEXTURE_COMPARE_MODE=34892]="TEXTURE_COMPARE_MODE",i[i.TEXTURE_COMPARE_FUNC=34893]="TEXTURE_COMPARE_FUNC",i[i.SRGB=35904]="SRGB",i[i.SRGB8=35905]="SRGB8",i[i.SRGB8_ALPHA8=35907]="SRGB8_ALPHA8",i[i.COMPARE_REF_TO_TEXTURE=34894]="COMPARE_REF_TO_TEXTURE",i[i.RGBA32F=34836]="RGBA32F",i[i.RGB32F=34837]="RGB32F",i[i.RGBA16F=34842]="RGBA16F",i[i.RGB16F=34843]="RGB16F",i[i.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY",i[i.TEXTURE_BINDING_2D_ARRAY=35869]="TEXTURE_BINDING_2D_ARRAY",i[i.R11F_G11F_B10F=35898]="R11F_G11F_B10F",i[i.RGB9_E5=35901]="RGB9_E5",i[i.RGBA32UI=36208]="RGBA32UI",i[i.RGB32UI=36209]="RGB32UI",i[i.RGBA16UI=36214]="RGBA16UI",i[i.RGB16UI=36215]="RGB16UI",i[i.RGBA8UI=36220]="RGBA8UI",i[i.RGB8UI=36221]="RGB8UI",i[i.RGBA32I=36226]="RGBA32I",i[i.RGB32I=36227]="RGB32I",i[i.RGBA16I=36232]="RGBA16I",i[i.RGB16I=36233]="RGB16I",i[i.RGBA8I=36238]="RGBA8I",i[i.RGB8I=36239]="RGB8I",i[i.RED_INTEGER=36244]="RED_INTEGER",i[i.RGB_INTEGER=36248]="RGB_INTEGER",i[i.RGBA_INTEGER=36249]="RGBA_INTEGER",i[i.R8=33321]="R8",i[i.RG8=33323]="RG8",i[i.R16F=33325]="R16F",i[i.R32F=33326]="R32F",i[i.RG16F=33327]="RG16F",i[i.RG32F=33328]="RG32F",i[i.R8I=33329]="R8I",i[i.R8UI=33330]="R8UI",i[i.R16I=33331]="R16I",i[i.R16UI=33332]="R16UI",i[i.R32I=33333]="R32I",i[i.R32UI=33334]="R32UI",i[i.RG8I=33335]="RG8I",i[i.RG8UI=33336]="RG8UI",i[i.RG16I=33337]="RG16I",i[i.RG16UI=33338]="RG16UI",i[i.RG32I=33339]="RG32I",i[i.RG32UI=33340]="RG32UI",i[i.R8_SNORM=36756]="R8_SNORM",i[i.RG8_SNORM=36757]="RG8_SNORM",i[i.RGB8_SNORM=36758]="RGB8_SNORM",i[i.RGBA8_SNORM=36759]="RGBA8_SNORM",i[i.RGB10_A2UI=36975]="RGB10_A2UI",i[i.TEXTURE_IMMUTABLE_FORMAT=37167]="TEXTURE_IMMUTABLE_FORMAT",i[i.TEXTURE_IMMUTABLE_LEVELS=33503]="TEXTURE_IMMUTABLE_LEVELS",i[i.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",i[i.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",i[i.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",i[i.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV",i[i.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",i[i.HALF_FLOAT=5131]="HALF_FLOAT",i[i.RG=33319]="RG",i[i.RG_INTEGER=33320]="RG_INTEGER",i[i.INT_2_10_10_10_REV=36255]="INT_2_10_10_10_REV",i[i.CURRENT_QUERY=34917]="CURRENT_QUERY",i[i.QUERY_RESULT=34918]="QUERY_RESULT",i[i.QUERY_RESULT_AVAILABLE=34919]="QUERY_RESULT_AVAILABLE",i[i.ANY_SAMPLES_PASSED=35887]="ANY_SAMPLES_PASSED",i[i.ANY_SAMPLES_PASSED_CONSERVATIVE=36202]="ANY_SAMPLES_PASSED_CONSERVATIVE",i[i.MAX_DRAW_BUFFERS=34852]="MAX_DRAW_BUFFERS",i[i.DRAW_BUFFER0=34853]="DRAW_BUFFER0",i[i.DRAW_BUFFER1=34854]="DRAW_BUFFER1",i[i.DRAW_BUFFER2=34855]="DRAW_BUFFER2",i[i.DRAW_BUFFER3=34856]="DRAW_BUFFER3",i[i.DRAW_BUFFER4=34857]="DRAW_BUFFER4",i[i.DRAW_BUFFER5=34858]="DRAW_BUFFER5",i[i.DRAW_BUFFER6=34859]="DRAW_BUFFER6",i[i.DRAW_BUFFER7=34860]="DRAW_BUFFER7",i[i.DRAW_BUFFER8=34861]="DRAW_BUFFER8",i[i.DRAW_BUFFER9=34862]="DRAW_BUFFER9",i[i.DRAW_BUFFER10=34863]="DRAW_BUFFER10",i[i.DRAW_BUFFER11=34864]="DRAW_BUFFER11",i[i.DRAW_BUFFER12=34865]="DRAW_BUFFER12",i[i.DRAW_BUFFER13=34866]="DRAW_BUFFER13",i[i.DRAW_BUFFER14=34867]="DRAW_BUFFER14",i[i.DRAW_BUFFER15=34868]="DRAW_BUFFER15",i[i.MAX_COLOR_ATTACHMENTS=36063]="MAX_COLOR_ATTACHMENTS",i[i.COLOR_ATTACHMENT1=36065]="COLOR_ATTACHMENT1",i[i.COLOR_ATTACHMENT2=36066]="COLOR_ATTACHMENT2",i[i.COLOR_ATTACHMENT3=36067]="COLOR_ATTACHMENT3",i[i.COLOR_ATTACHMENT4=36068]="COLOR_ATTACHMENT4",i[i.COLOR_ATTACHMENT5=36069]="COLOR_ATTACHMENT5",i[i.COLOR_ATTACHMENT6=36070]="COLOR_ATTACHMENT6",i[i.COLOR_ATTACHMENT7=36071]="COLOR_ATTACHMENT7",i[i.COLOR_ATTACHMENT8=36072]="COLOR_ATTACHMENT8",i[i.COLOR_ATTACHMENT9=36073]="COLOR_ATTACHMENT9",i[i.COLOR_ATTACHMENT10=36074]="COLOR_ATTACHMENT10",i[i.COLOR_ATTACHMENT11=36075]="COLOR_ATTACHMENT11",i[i.COLOR_ATTACHMENT12=36076]="COLOR_ATTACHMENT12",i[i.COLOR_ATTACHMENT13=36077]="COLOR_ATTACHMENT13",i[i.COLOR_ATTACHMENT14=36078]="COLOR_ATTACHMENT14",i[i.COLOR_ATTACHMENT15=36079]="COLOR_ATTACHMENT15",i[i.SAMPLER_3D=35679]="SAMPLER_3D",i[i.SAMPLER_2D_SHADOW=35682]="SAMPLER_2D_SHADOW",i[i.SAMPLER_2D_ARRAY=36289]="SAMPLER_2D_ARRAY",i[i.SAMPLER_2D_ARRAY_SHADOW=36292]="SAMPLER_2D_ARRAY_SHADOW",i[i.SAMPLER_CUBE_SHADOW=36293]="SAMPLER_CUBE_SHADOW",i[i.INT_SAMPLER_2D=36298]="INT_SAMPLER_2D",i[i.INT_SAMPLER_3D=36299]="INT_SAMPLER_3D",i[i.INT_SAMPLER_CUBE=36300]="INT_SAMPLER_CUBE",i[i.INT_SAMPLER_2D_ARRAY=36303]="INT_SAMPLER_2D_ARRAY",i[i.UNSIGNED_INT_SAMPLER_2D=36306]="UNSIGNED_INT_SAMPLER_2D",i[i.UNSIGNED_INT_SAMPLER_3D=36307]="UNSIGNED_INT_SAMPLER_3D",i[i.UNSIGNED_INT_SAMPLER_CUBE=36308]="UNSIGNED_INT_SAMPLER_CUBE",i[i.UNSIGNED_INT_SAMPLER_2D_ARRAY=36311]="UNSIGNED_INT_SAMPLER_2D_ARRAY",i[i.MAX_SAMPLES=36183]="MAX_SAMPLES",i[i.SAMPLER_BINDING=35097]="SAMPLER_BINDING",i[i.PIXEL_PACK_BUFFER=35051]="PIXEL_PACK_BUFFER",i[i.PIXEL_UNPACK_BUFFER=35052]="PIXEL_UNPACK_BUFFER",i[i.PIXEL_PACK_BUFFER_BINDING=35053]="PIXEL_PACK_BUFFER_BINDING",i[i.PIXEL_UNPACK_BUFFER_BINDING=35055]="PIXEL_UNPACK_BUFFER_BINDING",i[i.COPY_READ_BUFFER=36662]="COPY_READ_BUFFER",i[i.COPY_WRITE_BUFFER=36663]="COPY_WRITE_BUFFER",i[i.COPY_READ_BUFFER_BINDING=36662]="COPY_READ_BUFFER_BINDING",i[i.COPY_WRITE_BUFFER_BINDING=36663]="COPY_WRITE_BUFFER_BINDING",i[i.FLOAT_MAT2x3=35685]="FLOAT_MAT2x3",i[i.FLOAT_MAT2x4=35686]="FLOAT_MAT2x4",i[i.FLOAT_MAT3x2=35687]="FLOAT_MAT3x2",i[i.FLOAT_MAT3x4=35688]="FLOAT_MAT3x4",i[i.FLOAT_MAT4x2=35689]="FLOAT_MAT4x2",i[i.FLOAT_MAT4x3=35690]="FLOAT_MAT4x3",i[i.UNSIGNED_INT_VEC2=36294]="UNSIGNED_INT_VEC2",i[i.UNSIGNED_INT_VEC3=36295]="UNSIGNED_INT_VEC3",i[i.UNSIGNED_INT_VEC4=36296]="UNSIGNED_INT_VEC4",i[i.UNSIGNED_NORMALIZED=35863]="UNSIGNED_NORMALIZED",i[i.SIGNED_NORMALIZED=36764]="SIGNED_NORMALIZED",i[i.VERTEX_ATTRIB_ARRAY_INTEGER=35069]="VERTEX_ATTRIB_ARRAY_INTEGER",i[i.VERTEX_ATTRIB_ARRAY_DIVISOR=35070]="VERTEX_ATTRIB_ARRAY_DIVISOR",i[i.TRANSFORM_FEEDBACK_BUFFER_MODE=35967]="TRANSFORM_FEEDBACK_BUFFER_MODE",i[i.MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS=35968]="MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS",i[i.TRANSFORM_FEEDBACK_VARYINGS=35971]="TRANSFORM_FEEDBACK_VARYINGS",i[i.TRANSFORM_FEEDBACK_BUFFER_START=35972]="TRANSFORM_FEEDBACK_BUFFER_START",i[i.TRANSFORM_FEEDBACK_BUFFER_SIZE=35973]="TRANSFORM_FEEDBACK_BUFFER_SIZE",i[i.TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN=35976]="TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN",i[i.MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS=35978]="MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS",i[i.MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS=35979]="MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS",i[i.INTERLEAVED_ATTRIBS=35980]="INTERLEAVED_ATTRIBS",i[i.SEPARATE_ATTRIBS=35981]="SEPARATE_ATTRIBS",i[i.TRANSFORM_FEEDBACK_BUFFER=35982]="TRANSFORM_FEEDBACK_BUFFER",i[i.TRANSFORM_FEEDBACK_BUFFER_BINDING=35983]="TRANSFORM_FEEDBACK_BUFFER_BINDING",i[i.TRANSFORM_FEEDBACK=36386]="TRANSFORM_FEEDBACK",i[i.TRANSFORM_FEEDBACK_PAUSED=36387]="TRANSFORM_FEEDBACK_PAUSED",i[i.TRANSFORM_FEEDBACK_ACTIVE=36388]="TRANSFORM_FEEDBACK_ACTIVE",i[i.TRANSFORM_FEEDBACK_BINDING=36389]="TRANSFORM_FEEDBACK_BINDING",i[i.FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING=33296]="FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING",i[i.FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE=33297]="FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE",i[i.FRAMEBUFFER_ATTACHMENT_RED_SIZE=33298]="FRAMEBUFFER_ATTACHMENT_RED_SIZE",i[i.FRAMEBUFFER_ATTACHMENT_GREEN_SIZE=33299]="FRAMEBUFFER_ATTACHMENT_GREEN_SIZE",i[i.FRAMEBUFFER_ATTACHMENT_BLUE_SIZE=33300]="FRAMEBUFFER_ATTACHMENT_BLUE_SIZE",i[i.FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE=33301]="FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE",i[i.FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE=33302]="FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE",i[i.FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE=33303]="FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE",i[i.FRAMEBUFFER_DEFAULT=33304]="FRAMEBUFFER_DEFAULT",i[i.DEPTH24_STENCIL8=35056]="DEPTH24_STENCIL8",i[i.DRAW_FRAMEBUFFER_BINDING=36006]="DRAW_FRAMEBUFFER_BINDING",i[i.READ_FRAMEBUFFER_BINDING=36010]="READ_FRAMEBUFFER_BINDING",i[i.RENDERBUFFER_SAMPLES=36011]="RENDERBUFFER_SAMPLES",i[i.FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER=36052]="FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER",i[i.FRAMEBUFFER_INCOMPLETE_MULTISAMPLE=36182]="FRAMEBUFFER_INCOMPLETE_MULTISAMPLE",i[i.UNIFORM_BUFFER=35345]="UNIFORM_BUFFER",i[i.UNIFORM_BUFFER_BINDING=35368]="UNIFORM_BUFFER_BINDING",i[i.UNIFORM_BUFFER_START=35369]="UNIFORM_BUFFER_START",i[i.UNIFORM_BUFFER_SIZE=35370]="UNIFORM_BUFFER_SIZE",i[i.MAX_VERTEX_UNIFORM_BLOCKS=35371]="MAX_VERTEX_UNIFORM_BLOCKS",i[i.MAX_FRAGMENT_UNIFORM_BLOCKS=35373]="MAX_FRAGMENT_UNIFORM_BLOCKS",i[i.MAX_COMBINED_UNIFORM_BLOCKS=35374]="MAX_COMBINED_UNIFORM_BLOCKS",i[i.MAX_UNIFORM_BUFFER_BINDINGS=35375]="MAX_UNIFORM_BUFFER_BINDINGS",i[i.MAX_UNIFORM_BLOCK_SIZE=35376]="MAX_UNIFORM_BLOCK_SIZE",i[i.MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS=35377]="MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS",i[i.MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS=35379]="MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS",i[i.UNIFORM_BUFFER_OFFSET_ALIGNMENT=35380]="UNIFORM_BUFFER_OFFSET_ALIGNMENT",i[i.ACTIVE_UNIFORM_BLOCKS=35382]="ACTIVE_UNIFORM_BLOCKS",i[i.UNIFORM_TYPE=35383]="UNIFORM_TYPE",i[i.UNIFORM_SIZE=35384]="UNIFORM_SIZE",i[i.UNIFORM_BLOCK_INDEX=35386]="UNIFORM_BLOCK_INDEX",i[i.UNIFORM_OFFSET=35387]="UNIFORM_OFFSET",i[i.UNIFORM_ARRAY_STRIDE=35388]="UNIFORM_ARRAY_STRIDE",i[i.UNIFORM_MATRIX_STRIDE=35389]="UNIFORM_MATRIX_STRIDE",i[i.UNIFORM_IS_ROW_MAJOR=35390]="UNIFORM_IS_ROW_MAJOR",i[i.UNIFORM_BLOCK_BINDING=35391]="UNIFORM_BLOCK_BINDING",i[i.UNIFORM_BLOCK_DATA_SIZE=35392]="UNIFORM_BLOCK_DATA_SIZE",i[i.UNIFORM_BLOCK_ACTIVE_UNIFORMS=35394]="UNIFORM_BLOCK_ACTIVE_UNIFORMS",i[i.UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES=35395]="UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES",i[i.UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER=35396]="UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER",i[i.UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER=35398]="UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER",i[i.OBJECT_TYPE=37138]="OBJECT_TYPE",i[i.SYNC_CONDITION=37139]="SYNC_CONDITION",i[i.SYNC_STATUS=37140]="SYNC_STATUS",i[i.SYNC_FLAGS=37141]="SYNC_FLAGS",i[i.SYNC_FENCE=37142]="SYNC_FENCE",i[i.SYNC_GPU_COMMANDS_COMPLETE=37143]="SYNC_GPU_COMMANDS_COMPLETE",i[i.UNSIGNALED=37144]="UNSIGNALED",i[i.SIGNALED=37145]="SIGNALED",i[i.ALREADY_SIGNALED=37146]="ALREADY_SIGNALED",i[i.TIMEOUT_EXPIRED=37147]="TIMEOUT_EXPIRED",i[i.CONDITION_SATISFIED=37148]="CONDITION_SATISFIED",i[i.WAIT_FAILED=37149]="WAIT_FAILED",i[i.SYNC_FLUSH_COMMANDS_BIT=1]="SYNC_FLUSH_COMMANDS_BIT",i[i.COLOR=6144]="COLOR",i[i.DEPTH=6145]="DEPTH",i[i.STENCIL=6146]="STENCIL",i[i.MIN=32775]="MIN",i[i.MAX=32776]="MAX",i[i.DEPTH_COMPONENT24=33190]="DEPTH_COMPONENT24",i[i.STREAM_READ=35041]="STREAM_READ",i[i.STREAM_COPY=35042]="STREAM_COPY",i[i.STATIC_READ=35045]="STATIC_READ",i[i.STATIC_COPY=35046]="STATIC_COPY",i[i.DYNAMIC_READ=35049]="DYNAMIC_READ",i[i.DYNAMIC_COPY=35050]="DYNAMIC_COPY",i[i.DEPTH_COMPONENT32F=36012]="DEPTH_COMPONENT32F",i[i.DEPTH32F_STENCIL8=36013]="DEPTH32F_STENCIL8",i[i.INVALID_INDEX=4294967295]="INVALID_INDEX",i[i.TIMEOUT_IGNORED=-1]="TIMEOUT_IGNORED",i[i.MAX_CLIENT_WAIT_TIMEOUT_WEBGL=37447]="MAX_CLIENT_WAIT_TIMEOUT_WEBGL",i[i.UNMASKED_VENDOR_WEBGL=37445]="UNMASKED_VENDOR_WEBGL",i[i.UNMASKED_RENDERER_WEBGL=37446]="UNMASKED_RENDERER_WEBGL",i[i.MAX_TEXTURE_MAX_ANISOTROPY_EXT=34047]="MAX_TEXTURE_MAX_ANISOTROPY_EXT",i[i.TEXTURE_MAX_ANISOTROPY_EXT=34046]="TEXTURE_MAX_ANISOTROPY_EXT",i[i.R16_EXT=33322]="R16_EXT",i[i.RG16_EXT=33324]="RG16_EXT",i[i.RGB16_EXT=32852]="RGB16_EXT",i[i.RGBA16_EXT=32859]="RGBA16_EXT",i[i.R16_SNORM_EXT=36760]="R16_SNORM_EXT",i[i.RG16_SNORM_EXT=36761]="RG16_SNORM_EXT",i[i.RGB16_SNORM_EXT=36762]="RGB16_SNORM_EXT",i[i.RGBA16_SNORM_EXT=36763]="RGBA16_SNORM_EXT",i[i.COMPRESSED_RGB_S3TC_DXT1_EXT=33776]="COMPRESSED_RGB_S3TC_DXT1_EXT",i[i.COMPRESSED_RGBA_S3TC_DXT1_EXT=33777]="COMPRESSED_RGBA_S3TC_DXT1_EXT",i[i.COMPRESSED_RGBA_S3TC_DXT3_EXT=33778]="COMPRESSED_RGBA_S3TC_DXT3_EXT",i[i.COMPRESSED_RGBA_S3TC_DXT5_EXT=33779]="COMPRESSED_RGBA_S3TC_DXT5_EXT",i[i.COMPRESSED_SRGB_S3TC_DXT1_EXT=35916]="COMPRESSED_SRGB_S3TC_DXT1_EXT",i[i.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT=35917]="COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT",i[i.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT=35918]="COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT",i[i.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT=35919]="COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT",i[i.COMPRESSED_RED_RGTC1_EXT=36283]="COMPRESSED_RED_RGTC1_EXT",i[i.COMPRESSED_SIGNED_RED_RGTC1_EXT=36284]="COMPRESSED_SIGNED_RED_RGTC1_EXT",i[i.COMPRESSED_RED_GREEN_RGTC2_EXT=36285]="COMPRESSED_RED_GREEN_RGTC2_EXT",i[i.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT=36286]="COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT",i[i.COMPRESSED_RGBA_BPTC_UNORM_EXT=36492]="COMPRESSED_RGBA_BPTC_UNORM_EXT",i[i.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT=36493]="COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT",i[i.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT=36494]="COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT",i[i.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT=36495]="COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT",i[i.COMPRESSED_R11_EAC=37488]="COMPRESSED_R11_EAC",i[i.COMPRESSED_SIGNED_R11_EAC=37489]="COMPRESSED_SIGNED_R11_EAC",i[i.COMPRESSED_RG11_EAC=37490]="COMPRESSED_RG11_EAC",i[i.COMPRESSED_SIGNED_RG11_EAC=37491]="COMPRESSED_SIGNED_RG11_EAC",i[i.COMPRESSED_RGB8_ETC2=37492]="COMPRESSED_RGB8_ETC2",i[i.COMPRESSED_RGBA8_ETC2_EAC=37493]="COMPRESSED_RGBA8_ETC2_EAC",i[i.COMPRESSED_SRGB8_ETC2=37494]="COMPRESSED_SRGB8_ETC2",i[i.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC=37495]="COMPRESSED_SRGB8_ALPHA8_ETC2_EAC",i[i.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2=37496]="COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2",i[i.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2=37497]="COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2",i[i.COMPRESSED_RGB_PVRTC_4BPPV1_IMG=35840]="COMPRESSED_RGB_PVRTC_4BPPV1_IMG",i[i.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG=35842]="COMPRESSED_RGBA_PVRTC_4BPPV1_IMG",i[i.COMPRESSED_RGB_PVRTC_2BPPV1_IMG=35841]="COMPRESSED_RGB_PVRTC_2BPPV1_IMG",i[i.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG=35843]="COMPRESSED_RGBA_PVRTC_2BPPV1_IMG",i[i.COMPRESSED_RGB_ETC1_WEBGL=36196]="COMPRESSED_RGB_ETC1_WEBGL",i[i.COMPRESSED_RGB_ATC_WEBGL=35986]="COMPRESSED_RGB_ATC_WEBGL",i[i.COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL=35986]="COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL",i[i.COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL=34798]="COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL",i[i.COMPRESSED_RGBA_ASTC_4x4_KHR=37808]="COMPRESSED_RGBA_ASTC_4x4_KHR",i[i.COMPRESSED_RGBA_ASTC_5x4_KHR=37809]="COMPRESSED_RGBA_ASTC_5x4_KHR",i[i.COMPRESSED_RGBA_ASTC_5x5_KHR=37810]="COMPRESSED_RGBA_ASTC_5x5_KHR",i[i.COMPRESSED_RGBA_ASTC_6x5_KHR=37811]="COMPRESSED_RGBA_ASTC_6x5_KHR",i[i.COMPRESSED_RGBA_ASTC_6x6_KHR=37812]="COMPRESSED_RGBA_ASTC_6x6_KHR",i[i.COMPRESSED_RGBA_ASTC_8x5_KHR=37813]="COMPRESSED_RGBA_ASTC_8x5_KHR",i[i.COMPRESSED_RGBA_ASTC_8x6_KHR=37814]="COMPRESSED_RGBA_ASTC_8x6_KHR",i[i.COMPRESSED_RGBA_ASTC_8x8_KHR=37815]="COMPRESSED_RGBA_ASTC_8x8_KHR",i[i.COMPRESSED_RGBA_ASTC_10x5_KHR=37816]="COMPRESSED_RGBA_ASTC_10x5_KHR",i[i.COMPRESSED_RGBA_ASTC_10x6_KHR=37817]="COMPRESSED_RGBA_ASTC_10x6_KHR",i[i.COMPRESSED_RGBA_ASTC_10x8_KHR=37818]="COMPRESSED_RGBA_ASTC_10x8_KHR",i[i.COMPRESSED_RGBA_ASTC_10x10_KHR=37819]="COMPRESSED_RGBA_ASTC_10x10_KHR",i[i.COMPRESSED_RGBA_ASTC_12x10_KHR=37820]="COMPRESSED_RGBA_ASTC_12x10_KHR",i[i.COMPRESSED_RGBA_ASTC_12x12_KHR=37821]="COMPRESSED_RGBA_ASTC_12x12_KHR",i[i.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR=37840]="COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR",i[i.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR=37841]="COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR",i[i.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR=37842]="COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR",i[i.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR=37843]="COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR",i[i.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR=37844]="COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR",i[i.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR=37845]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR",i[i.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR=37846]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR",i[i.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR=37847]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR",i[i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR=37848]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR",i[i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR=37849]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR",i[i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR=37850]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR",i[i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR=37851]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR",i[i.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR=37852]="COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR",i[i.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR=37853]="COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR",i[i.QUERY_COUNTER_BITS_EXT=34916]="QUERY_COUNTER_BITS_EXT",i[i.CURRENT_QUERY_EXT=34917]="CURRENT_QUERY_EXT",i[i.QUERY_RESULT_EXT=34918]="QUERY_RESULT_EXT",i[i.QUERY_RESULT_AVAILABLE_EXT=34919]="QUERY_RESULT_AVAILABLE_EXT",i[i.TIME_ELAPSED_EXT=35007]="TIME_ELAPSED_EXT",i[i.TIMESTAMP_EXT=36392]="TIMESTAMP_EXT",i[i.GPU_DISJOINT_EXT=36795]="GPU_DISJOINT_EXT",i[i.COMPLETION_STATUS_KHR=37297]="COMPLETION_STATUS_KHR",i[i.DEPTH_CLAMP_EXT=34383]="DEPTH_CLAMP_EXT",i[i.FIRST_VERTEX_CONVENTION_WEBGL=36429]="FIRST_VERTEX_CONVENTION_WEBGL",i[i.LAST_VERTEX_CONVENTION_WEBGL=36430]="LAST_VERTEX_CONVENTION_WEBGL",i[i.PROVOKING_VERTEX_WEBL=36431]="PROVOKING_VERTEX_WEBL",i[i.POLYGON_MODE_WEBGL=2880]="POLYGON_MODE_WEBGL",i[i.POLYGON_OFFSET_LINE_WEBGL=10754]="POLYGON_OFFSET_LINE_WEBGL",i[i.LINE_WEBGL=6913]="LINE_WEBGL",i[i.FILL_WEBGL=6914]="FILL_WEBGL",i[i.MAX_CLIP_DISTANCES_WEBGL=3378]="MAX_CLIP_DISTANCES_WEBGL",i[i.MAX_CULL_DISTANCES_WEBGL=33529]="MAX_CULL_DISTANCES_WEBGL",i[i.MAX_COMBINED_CLIP_AND_CULL_DISTANCES_WEBGL=33530]="MAX_COMBINED_CLIP_AND_CULL_DISTANCES_WEBGL",i[i.CLIP_DISTANCE0_WEBGL=12288]="CLIP_DISTANCE0_WEBGL",i[i.CLIP_DISTANCE1_WEBGL=12289]="CLIP_DISTANCE1_WEBGL",i[i.CLIP_DISTANCE2_WEBGL=12290]="CLIP_DISTANCE2_WEBGL",i[i.CLIP_DISTANCE3_WEBGL=12291]="CLIP_DISTANCE3_WEBGL",i[i.CLIP_DISTANCE4_WEBGL=12292]="CLIP_DISTANCE4_WEBGL",i[i.CLIP_DISTANCE5_WEBGL=12293]="CLIP_DISTANCE5_WEBGL",i[i.CLIP_DISTANCE6_WEBGL=12294]="CLIP_DISTANCE6_WEBGL",i[i.CLIP_DISTANCE7_WEBGL=12295]="CLIP_DISTANCE7_WEBGL",i[i.POLYGON_OFFSET_CLAMP_EXT=36379]="POLYGON_OFFSET_CLAMP_EXT",i[i.LOWER_LEFT_EXT=36001]="LOWER_LEFT_EXT",i[i.UPPER_LEFT_EXT=36002]="UPPER_LEFT_EXT",i[i.NEGATIVE_ONE_TO_ONE_EXT=37726]="NEGATIVE_ONE_TO_ONE_EXT",i[i.ZERO_TO_ONE_EXT=37727]="ZERO_TO_ONE_EXT",i[i.CLIP_ORIGIN_EXT=37724]="CLIP_ORIGIN_EXT",i[i.CLIP_DEPTH_MODE_EXT=37725]="CLIP_DEPTH_MODE_EXT",i[i.SRC1_COLOR_WEBGL=35065]="SRC1_COLOR_WEBGL",i[i.SRC1_ALPHA_WEBGL=34185]="SRC1_ALPHA_WEBGL",i[i.ONE_MINUS_SRC1_COLOR_WEBGL=35066]="ONE_MINUS_SRC1_COLOR_WEBGL",i[i.ONE_MINUS_SRC1_ALPHA_WEBGL=35067]="ONE_MINUS_SRC1_ALPHA_WEBGL",i[i.MAX_DUAL_SOURCE_DRAW_BUFFERS_WEBGL=35068]="MAX_DUAL_SOURCE_DRAW_BUFFERS_WEBGL",i[i.MIRROR_CLAMP_TO_EDGE_EXT=34627]="MIRROR_CLAMP_TO_EDGE_EXT"})(Do||(Do={}));const HN={WEBGL_depth_texture:{UNSIGNED_INT_24_8_WEBGL:34042},OES_element_index_uint:{},OES_texture_float:{},OES_texture_half_float:{HALF_FLOAT_OES:5131},EXT_color_buffer_float:{},OES_standard_derivatives:{FRAGMENT_SHADER_DERIVATIVE_HINT_OES:35723},EXT_frag_depth:{},EXT_blend_minmax:{MIN_EXT:32775,MAX_EXT:32776},EXT_shader_texture_lod:{}},VN=i=>({drawBuffersWEBGL(e){return i.drawBuffers(e)},COLOR_ATTACHMENT0_WEBGL:36064,COLOR_ATTACHMENT1_WEBGL:36065,COLOR_ATTACHMENT2_WEBGL:36066,COLOR_ATTACHMENT3_WEBGL:36067}),GN=i=>({VERTEX_ARRAY_BINDING_OES:34229,createVertexArrayOES(){return i.createVertexArray()},deleteVertexArrayOES(e){return i.deleteVertexArray(e)},isVertexArrayOES(e){return i.isVertexArray(e)},bindVertexArrayOES(e){return i.bindVertexArray(e)}}),WN=i=>({VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE:35070,drawArraysInstancedANGLE(...e){return i.drawArraysInstanced(...e)},drawElementsInstancedANGLE(...e){return i.drawElementsInstanced(...e)},vertexAttribDivisorANGLE(...e){return i.vertexAttribDivisor(...e)}});function YN(i=!0){const e=HTMLCanvasElement.prototype;if(!i&&e.originalGetContext){e.getContext=e.originalGetContext,e.originalGetContext=void 0;return}e.originalGetContext=e.getContext,e.getContext=function(t,n){if(t==="webgl"||t==="experimental-webgl"){const s=this.originalGetContext("webgl2",n);return s instanceof HTMLElement&&qN(s),s}return this.originalGetContext(t,n)}}function qN(i){i.getExtension("EXT_color_buffer_float");const e={...HN,WEBGL_disjoint_timer_query:i.getExtension("EXT_disjoint_timer_query_webgl2"),WEBGL_draw_buffers:VN(i),OES_vertex_array_object:GN(i),ANGLE_instanced_arrays:WN(i)},t=i.getExtension;i.getExtension=function(s){return t.call(i,s)||(s in e?e[s]:null)};const n=i.getSupportedExtensions;i.getSupportedExtensions=function(){const s=n.apply(i)||[];return s==null?void 0:s.concat(Object.keys(e))}}async function w2(i,e){const t=document.getElementsByTagName("head")[0];if(!t)throw new Error("loadScript");const n=document.createElement("script");return n.setAttribute("type","text/javascript"),n.setAttribute("src",i),new Promise((s,r)=>{n.onload=s,n.onerror=o=>r(new Error(`Unable to load script '${i}': ${o}`)),t.appendChild(n)})}const XN=1;let hi=null,Y0=!1;const uy={debugSpectorJS:le.get("debug-spectorjs"),debugSpectorJSUrl:"https://cdn.jsdelivr.net/npm/spectorjs@0.9.30/dist/spector.bundle.js",gl:void 0};async function KN(i){if(!globalThis.SPECTOR)try{await w2(i.debugSpectorJSUrl||uy.debugSpectorJSUrl)}catch(e){le.warn(String(e))}}function gte(i){var e;if(i={...uy,...i},!i.debugSpectorJS)return null;if(!hi&&globalThis.SPECTOR&&!((e=globalThis.luma)!=null&&e.spector)){le.probe(XN,"SPECTOR found and initialized. Start with `luma.spector.displayUI()`")();const{Spector:t}=globalThis.SPECTOR;hi=new t,globalThis.luma&&(globalThis.luma.spector=hi)}if(!hi)return null;if(Y0||(Y0=!0,hi.spyCanvases(),hi==null||hi.onCaptureStarted.add(t=>le.info("Spector capture started:",t)()),hi==null||hi.onCapture.add(t=>{le.info("Spector capture complete:",t)(),hi==null||hi.getResultUI(),hi==null||hi.resultView.display(),hi==null||hi.resultView.addCapture(t)})),i.gl){const t=i.gl,n=t.device;hi==null||hi.startCapture(i.gl,500),t.device=n,new Promise(s=>setTimeout(s,2e3)).then(s=>{le.info("Spector capture stopped after 2 seconds")(),hi==null||hi.stopCapture()})}return hi}const ZN="https://unpkg.com/webgl-debug@2.0.1/index.js";function S2(i){return i.luma=i.luma||{},i.luma}async function QN(){Vu()&&!globalThis.WebGLDebugUtils&&(globalThis.global=globalThis.global||globalThis,globalThis.global.module={},await w2(ZN))}function _te(i,e={}){return e.debugWebGL||e.traceWebGL?eD(i,e):JN(i)}function JN(i){const e=S2(i);return e.realContext?e.realContext:i}function eD(i,e){if(!globalThis.WebGLDebugUtils)return le.warn("webgl-debug not loaded")(),i;const t=S2(i);if(t.debugContext)return t.debugContext;globalThis.WebGLDebugUtils.init({...Do,...i});const n=globalThis.WebGLDebugUtils.makeDebugContext(i,tD.bind(null,e),iD.bind(null,e));for(const o in Do)!(o in n)&&typeof Do[o]=="number"&&(n[o]=Do[o]);class s{}Object.setPrototypeOf(n,Object.getPrototypeOf(i)),Object.setPrototypeOf(s,n);const r=Object.create(s);return t.realContext=i,t.debugContext=r,r.debug=!0,r}function q0(i,e){e=Array.from(e).map(n=>n===void 0?"undefined":n);let t=globalThis.WebGLDebugUtils.glFunctionArgsToString(i,e);return t=`${t.slice(0,100)}${t.length>100?"...":""}`,`gl.${i}(${t})`}function tD(i,e,t,n){n=Array.from(n).map(a=>a===void 0?"undefined":a);const s=globalThis.WebGLDebugUtils.glEnumToString(e),r=globalThis.WebGLDebugUtils.glFunctionArgsToString(t,n),o=`${s} in gl.${t}(${r})`;le.error(o)();debugger}function iD(i,e,t){let n="";le.level>=1&&(n=q0(e,t),i.traceWebGL&&le.log(1,n)());for(const s of t)if(s===void 0){n=n||q0(e,t);debugger}}const wd=1;class nD extends fN{constructor(){super(),U(this,"type","webgl"),bg.defaultProps={...bg.defaultProps,...uy}}enforceWebGL2(e){YN(e)}isSupported(){return typeof WebGL2RenderingContext<"u"}isDeviceHandle(e){return typeof WebGL2RenderingContext<"u"&&e instanceof WebGL2RenderingContext?!0:(typeof WebGLRenderingContext<"u"&&e instanceof WebGLRenderingContext&&le.warn("WebGL1 is not supported",e)(),!1)}async attach(e,t={}){const{WebGLDevice:n}=await l0(async()=>{const{WebGLDevice:r}=await import("./webgl-device-QoBMYpnS-CdBaG8Is.js");return{WebGLDevice:r}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]));if(e instanceof n)return e;if((e==null?void 0:e.device)instanceof n)return e.device;if(!sD(e))throw new Error("Invalid WebGL2RenderingContext");const s=t.createCanvasContext===!0?{}:t.createCanvasContext;return new n({...t,_handle:e,createCanvasContext:{canvas:e.canvas,autoResize:!1,...s}})}async create(e={}){const{WebGLDevice:t}=await l0(async()=>{const{WebGLDevice:n}=await import("./webgl-device-QoBMYpnS-CdBaG8Is.js");return{WebGLDevice:n}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]));le.groupCollapsed(wd,"WebGLDevice created")();try{const n=[];(e.debugWebGL||e.debug)&&n.push(QN()),e.debugSpectorJS&&n.push(KN(e));const s=await Promise.allSettled(n);for(const a of s)a.status==="rejected"&&le.error(`Failed to initialize debug libraries ${a.reason}`)();const r=new t(e),o=`${r._reused?"Reusing":"Created"} device with WebGL2 ${r.props.debug?"debug ":""}context: ${r.info.vendor}, ${r.info.renderer} for canvas: ${r.canvasContext.id}`;return le.probe(wd,o)(),le.table(wd,r.info)(),r}finally{le.groupEnd(wd)()}}}function sD(i){return typeof WebGL2RenderingContext<"u"&&i instanceof WebGL2RenderingContext?!0:!!(i&&Number.isFinite(i._version))}const rD=new nD,oD="#b3b3b3",aD=void 0,wg=void 0,lD=1,cD=4,uD="#666666",dD=.1,hD=1,fD=1,E2="#222222",pe={enableSimulation:!0,spaceSize:8192,pointSizeScale:1,linkWidthScale:1,linkArrowsSizeScale:1,renderLinks:!0,curvedLinks:!1,curvedLinkSegments:19,curvedLinkWeight:.8,curvedLinkControlPointDistance:.5,linkArrows:!1,linkVisibilityDistanceRange:[50,150],linkVisibilityMinTransparency:.25,hoveredPointCursor:"auto",hoveredLinkCursor:"auto",renderHoveredPointRing:!1,hoveredPointRingColor:"white",hoveredLinkColor:void 0,hoveredLinkWidthIncrease:5,focusedPointRingColor:"white",focusedPointIndex:void 0,simulation:{decay:5e3,gravity:.25,center:0,repulsion:1,repulsionTheta:1.15,linkSpring:1,linkDistance:10,linkDistRandomVariationRange:[1,1.2],repulsionFromMouse:2,friction:.85,cluster:.1},showFPSMonitor:!1,pixelRatio:typeof window<"u"&&window.devicePixelRatio||2,scalePointsOnZoom:!1,scaleLinksOnZoom:!1,enableZoom:!0,enableSimulationDuringZoom:!1,enableDrag:!1,fitViewOnInit:!0,fitViewDelay:250,fitViewPadding:.1,fitViewDuration:250,pointSamplingDistance:150,attribution:"",rescalePositions:void 0,enableRightClickRepulsion:!1},pD=.7,mD=.95,gD=3;/*! @license DOMPurify 3.2.6 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.2.6/LICENSE */const{entries:C2,setPrototypeOf:X0,isFrozen:_D,getPrototypeOf:yD,getOwnPropertyDescriptor:bD}=Object;let{freeze:hn,seal:_s,create:T2}=Object,{apply:Sg,construct:Eg}=typeof Reflect<"u"&&Reflect;hn||(hn=function(i){return i});_s||(_s=function(i){return i});Sg||(Sg=function(i,e,t){return i.apply(e,t)});Eg||(Eg=function(i,e){return new i(...e)});const Sd=fn(Array.prototype.forEach),vD=fn(Array.prototype.lastIndexOf),K0=fn(Array.prototype.pop),ac=fn(Array.prototype.push),xD=fn(Array.prototype.splice),uh=fn(String.prototype.toLowerCase),Jp=fn(String.prototype.toString),Z0=fn(String.prototype.match),lc=fn(String.prototype.replace),wD=fn(String.prototype.indexOf),SD=fn(String.prototype.trim),Ms=fn(Object.prototype.hasOwnProperty),sn=fn(RegExp.prototype.test),cc=ED(TypeError);function fn(i){return function(e){e instanceof RegExp&&(e.lastIndex=0);for(var t=arguments.length,n=new Array(t>1?t-1:0),s=1;s2&&arguments[2]!==void 0?arguments[2]:uh;X0&&X0(i,null);let n=e.length;for(;n--;){let s=e[n];if(typeof s=="string"){const r=t(s);r!==s&&(_D(e)||(e[n]=r),s=r)}i[s]=!0}return i}function CD(i){for(let e=0;e/gm),LD=_s(/\$\{[\w\W]*/gm),RD=_s(/^data-[\-\w.\u00B7-\uFFFF]+$/),PD=_s(/^aria-[\-\w]+$/),k2=_s(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),ND=_s(/^(?:\w+script|data):/i),DD=_s(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),A2=_s(/^html$/i),MD=_s(/^[a-z][.\w]*(-[.\w]+)+$/i);var ix=Object.freeze({__proto__:null,ARIA_ATTR:PD,ATTR_WHITESPACE:DD,CUSTOM_ELEMENT:MD,DATA_ATTR:RD,DOCTYPE_NAME:A2,ERB_EXPR:ID,IS_ALLOWED_URI:k2,IS_SCRIPT_OR_DATA:ND,MUSTACHE_EXPR:AD,TMPLIT_EXPR:LD});const dc={element:1,text:3,progressingInstruction:7,comment:8,document:9},OD=function(){return typeof window>"u"?null:window},BD=function(i,e){if(typeof i!="object"||typeof i.createPolicy!="function")return null;let t=null;const n="data-tt-policy-suffix";e&&e.hasAttribute(n)&&(t=e.getAttribute(n));const s="dompurify"+(t?"#"+t:"");try{return i.createPolicy(s,{createHTML(r){return r},createScriptURL(r){return r}})}catch{return console.warn("TrustedTypes policy "+s+" could not be created."),null}},nx=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function I2(){let i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:OD();const e=I=>I2(I);if(e.version="3.2.6",e.removed=[],!i||!i.document||i.document.nodeType!==dc.document||!i.Element)return e.isSupported=!1,e;let{document:t}=i;const n=t,s=n.currentScript,{DocumentFragment:r,HTMLTemplateElement:o,Node:a,Element:l,NodeFilter:c,NamedNodeMap:u=i.NamedNodeMap||i.MozNamedAttrMap,HTMLFormElement:d,DOMParser:h,trustedTypes:p}=i,m=l.prototype,y=uc(m,"cloneNode"),g=uc(m,"remove"),_=uc(m,"nextSibling"),S=uc(m,"childNodes"),C=uc(m,"parentNode");if(typeof o=="function"){const I=t.createElement("template");I.content&&I.content.ownerDocument&&(t=I.content.ownerDocument)}let x,A="";const{implementation:L,createNodeIterator:B,createDocumentFragment:H,getElementsByTagName:Q}=t,{importNode:te}=n;let M=nx();e.isSupported=typeof C2=="function"&&typeof C=="function"&&L&&L.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:he,ERB_EXPR:se,TMPLIT_EXPR:R,DATA_ATTR:J,ARIA_ATTR:F,IS_SCRIPT_OR_DATA:X,ATTR_WHITESPACE:ie,CUSTOM_ELEMENT:ee}=ix;let{IS_ALLOWED_URI:ae}=ix,Z=null;const Se=ot({},[...Q0,...em,...tm,...im,...J0]);let xe=null;const Je=ot({},[...ex,...nm,...tx,...Ed]);let de=Object.seal(T2(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),bt=null,Xe=null,ht=!0,re=!0,Te=!1,Pe=!0,q=!1,We=!0,He=!1,it=!1,Vt=!1,me=!1,nt=!1,ui=!1,_i=!0,Zn=!1;const Qo="user-content-";let Zs=!0,Li=!1,en={},Ri=null;const ai=ot({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let vo=null;const Es=ot({},["audio","video","img","source","image","track"]);let Qn=null;const Jn=ot({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Cs="http://www.w3.org/1998/Math/MathML",zi="http://www.w3.org/2000/svg",Ei="http://www.w3.org/1999/xhtml";let ii=Ei,bn=!1,vn=null;const Ts=ot({},[Cs,zi,Ei],Jp);let On=ot({},["mi","mo","mn","ms","mtext"]),es=ot({},["annotation-xml"]);const Dr=ot({},["title","style","font","a","script"]);let xn=null;const Qs=["application/xhtml+xml","text/html"],Jo="text/html";let Zt=null,Ot=null;const ks=t.createElement("form"),xo=function(I){return I instanceof RegExp||I instanceof Function},Js=function(){let I=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(Ot&&Ot===I)){if((!I||typeof I!="object")&&(I={}),I=Hr(I),xn=Qs.indexOf(I.PARSER_MEDIA_TYPE)===-1?Jo:I.PARSER_MEDIA_TYPE,Zt=xn==="application/xhtml+xml"?Jp:uh,Z=Ms(I,"ALLOWED_TAGS")?ot({},I.ALLOWED_TAGS,Zt):Se,xe=Ms(I,"ALLOWED_ATTR")?ot({},I.ALLOWED_ATTR,Zt):Je,vn=Ms(I,"ALLOWED_NAMESPACES")?ot({},I.ALLOWED_NAMESPACES,Jp):Ts,Qn=Ms(I,"ADD_URI_SAFE_ATTR")?ot(Hr(Jn),I.ADD_URI_SAFE_ATTR,Zt):Jn,vo=Ms(I,"ADD_DATA_URI_TAGS")?ot(Hr(Es),I.ADD_DATA_URI_TAGS,Zt):Es,Ri=Ms(I,"FORBID_CONTENTS")?ot({},I.FORBID_CONTENTS,Zt):ai,bt=Ms(I,"FORBID_TAGS")?ot({},I.FORBID_TAGS,Zt):Hr({}),Xe=Ms(I,"FORBID_ATTR")?ot({},I.FORBID_ATTR,Zt):Hr({}),en=Ms(I,"USE_PROFILES")?I.USE_PROFILES:!1,ht=I.ALLOW_ARIA_ATTR!==!1,re=I.ALLOW_DATA_ATTR!==!1,Te=I.ALLOW_UNKNOWN_PROTOCOLS||!1,Pe=I.ALLOW_SELF_CLOSE_IN_ATTR!==!1,q=I.SAFE_FOR_TEMPLATES||!1,We=I.SAFE_FOR_XML!==!1,He=I.WHOLE_DOCUMENT||!1,me=I.RETURN_DOM||!1,nt=I.RETURN_DOM_FRAGMENT||!1,ui=I.RETURN_TRUSTED_TYPE||!1,Vt=I.FORCE_BODY||!1,_i=I.SANITIZE_DOM!==!1,Zn=I.SANITIZE_NAMED_PROPS||!1,Zs=I.KEEP_CONTENT!==!1,Li=I.IN_PLACE||!1,ae=I.ALLOWED_URI_REGEXP||k2,ii=I.NAMESPACE||Ei,On=I.MATHML_TEXT_INTEGRATION_POINTS||On,es=I.HTML_INTEGRATION_POINTS||es,de=I.CUSTOM_ELEMENT_HANDLING||{},I.CUSTOM_ELEMENT_HANDLING&&xo(I.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(de.tagNameCheck=I.CUSTOM_ELEMENT_HANDLING.tagNameCheck),I.CUSTOM_ELEMENT_HANDLING&&xo(I.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(de.attributeNameCheck=I.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),I.CUSTOM_ELEMENT_HANDLING&&typeof I.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(de.allowCustomizedBuiltInElements=I.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),q&&(re=!1),nt&&(me=!0),en&&(Z=ot({},J0),xe=[],en.html===!0&&(ot(Z,Q0),ot(xe,ex)),en.svg===!0&&(ot(Z,em),ot(xe,nm),ot(xe,Ed)),en.svgFilters===!0&&(ot(Z,tm),ot(xe,nm),ot(xe,Ed)),en.mathMl===!0&&(ot(Z,im),ot(xe,tx),ot(xe,Ed))),I.ADD_TAGS&&(Z===Se&&(Z=Hr(Z)),ot(Z,I.ADD_TAGS,Zt)),I.ADD_ATTR&&(xe===Je&&(xe=Hr(xe)),ot(xe,I.ADD_ATTR,Zt)),I.ADD_URI_SAFE_ATTR&&ot(Qn,I.ADD_URI_SAFE_ATTR,Zt),I.FORBID_CONTENTS&&(Ri===ai&&(Ri=Hr(Ri)),ot(Ri,I.FORBID_CONTENTS,Zt)),Zs&&(Z["#text"]=!0),He&&ot(Z,["html","head","body"]),Z.table&&(ot(Z,["tbody"]),delete bt.tbody),I.TRUSTED_TYPES_POLICY){if(typeof I.TRUSTED_TYPES_POLICY.createHTML!="function")throw cc('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof I.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw cc('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');x=I.TRUSTED_TYPES_POLICY,A=x.createHTML("")}else x===void 0&&(x=BD(p,s)),x!==null&&typeof A=="string"&&(A=x.createHTML(""));hn&&hn(I),Ot=I}},Rt=ot({},[...em,...tm,...TD]),Mr=ot({},[...im,...kD]),ea=function(I){let V=C(I);(!V||!V.tagName)&&(V={namespaceURI:ii,tagName:"template"});const E=uh(I.tagName),G=uh(V.tagName);return vn[I.namespaceURI]?I.namespaceURI===zi?V.namespaceURI===Ei?E==="svg":V.namespaceURI===Cs?E==="svg"&&(G==="annotation-xml"||On[G]):!!Rt[E]:I.namespaceURI===Cs?V.namespaceURI===Ei?E==="math":V.namespaceURI===zi?E==="math"&&es[G]:!!Mr[E]:I.namespaceURI===Ei?V.namespaceURI===zi&&!es[G]||V.namespaceURI===Cs&&!On[G]?!1:!Mr[E]&&(Dr[E]||!Rt[E]):!!(xn==="application/xhtml+xml"&&vn[I.namespaceURI]):!1},ts=function(I){ac(e.removed,{element:I});try{C(I).removeChild(I)}catch{g(I)}},di=function(I,V){try{ac(e.removed,{attribute:V.getAttributeNode(I),from:V})}catch{ac(e.removed,{attribute:null,from:V})}if(V.removeAttribute(I),I==="is")if(me||nt)try{ts(V)}catch{}else try{V.setAttribute(I,"")}catch{}},Bn=function(I){let V=null,E=null;if(Vt)I=""+I;else{const Ce=Z0(I,/^[\r\n\t ]+/);E=Ce&&Ce[0]}xn==="application/xhtml+xml"&&ii===Ei&&(I=''+I+"");const G=x?x.createHTML(I):I;if(ii===Ei)try{V=new h().parseFromString(G,xn)}catch{}if(!V||!V.documentElement){V=L.createDocument(ii,"template",null);try{V.documentElement.innerHTML=bn?A:G}catch{}}const ne=V.body||V.documentElement;return I&&E&&ne.insertBefore(t.createTextNode(E),ne.childNodes[0]||null),ii===Ei?Q.call(V,He?"html":"body")[0]:He?V.documentElement:ne},wo=function(I){return B.call(I.ownerDocument||I,I,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},ut=function(I){return I instanceof d&&(typeof I.nodeName!="string"||typeof I.textContent!="string"||typeof I.removeChild!="function"||!(I.attributes instanceof u)||typeof I.removeAttribute!="function"||typeof I.setAttribute!="function"||typeof I.namespaceURI!="string"||typeof I.insertBefore!="function"||typeof I.hasChildNodes!="function")},Or=function(I){return typeof a=="function"&&I instanceof a};function st(I,V,E){Sd(I,G=>{G.call(e,V,E,Ot)})}const wn=function(I){let V=null;if(st(M.beforeSanitizeElements,I,null),ut(I))return ts(I),!0;const E=Zt(I.nodeName);if(st(M.uponSanitizeElement,I,{tagName:E,allowedTags:Z}),We&&I.hasChildNodes()&&!Or(I.firstElementChild)&&sn(/<[/\w!]/g,I.innerHTML)&&sn(/<[/\w!]/g,I.textContent)||I.nodeType===dc.progressingInstruction||We&&I.nodeType===dc.comment&&sn(/<[/\w]/g,I.data))return ts(I),!0;if(!Z[E]||bt[E]){if(!bt[E]&&er(E)&&(de.tagNameCheck instanceof RegExp&&sn(de.tagNameCheck,E)||de.tagNameCheck instanceof Function&&de.tagNameCheck(E)))return!1;if(Zs&&!Ri[E]){const G=C(I)||I.parentNode,ne=S(I)||I.childNodes;if(ne&&G){const Ce=ne.length;for(let At=Ce-1;At>=0;--At){const rt=y(ne[At],!0);rt.__removalCount=(I.__removalCount||0)+1,G.insertBefore(rt,_(I))}}}return ts(I),!0}return I instanceof l&&!ea(I)||(E==="noscript"||E==="noembed"||E==="noframes")&&sn(/<\/no(script|embed|frames)/i,I.innerHTML)?(ts(I),!0):(q&&I.nodeType===dc.text&&(V=I.textContent,Sd([he,se,R],G=>{V=lc(V,G," ")}),I.textContent!==V&&(ac(e.removed,{element:I.cloneNode()}),I.textContent=V)),st(M.afterSanitizeElements,I,null),!1)},Br=function(I,V,E){if(_i&&(V==="id"||V==="name")&&(E in t||E in ks))return!1;if(!(re&&!Xe[V]&&sn(J,V))&&!(ht&&sn(F,V))){if(!xe[V]||Xe[V]){if(!(er(I)&&(de.tagNameCheck instanceof RegExp&&sn(de.tagNameCheck,I)||de.tagNameCheck instanceof Function&&de.tagNameCheck(I))&&(de.attributeNameCheck instanceof RegExp&&sn(de.attributeNameCheck,V)||de.attributeNameCheck instanceof Function&&de.attributeNameCheck(V))||V==="is"&&de.allowCustomizedBuiltInElements&&(de.tagNameCheck instanceof RegExp&&sn(de.tagNameCheck,E)||de.tagNameCheck instanceof Function&&de.tagNameCheck(E))))return!1}else if(!Qn[V]&&!sn(ae,lc(E,ie,""))&&!((V==="src"||V==="xlink:href"||V==="href")&&I!=="script"&&wD(E,"data:")===0&&vo[I])&&!(Te&&!sn(X,lc(E,ie,"")))&&E)return!1}return!0},er=function(I){return I!=="annotation-xml"&&Z0(I,ee)},Fn=function(I){st(M.beforeSanitizeAttributes,I,null);const{attributes:V}=I;if(!V||ut(I))return;const E={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:xe,forceKeepAttr:void 0};let G=V.length;for(;G--;){const ne=V[G],{name:Ce,namespaceURI:At,value:rt}=ne,et=Zt(Ce),yi=rt;let ft=Ce==="value"?yi:SD(yi);if(E.attrName=et,E.attrValue=ft,E.keepAttr=!0,E.forceKeepAttr=void 0,st(M.uponSanitizeAttribute,I,E),ft=E.attrValue,Zn&&(et==="id"||et==="name")&&(di(Ce,I),ft=Qo+ft),We&&sn(/((--!?|])>)|<\/(style|title)/i,ft)){di(Ce,I);continue}if(E.forceKeepAttr)continue;if(!E.keepAttr){di(Ce,I);continue}if(!Pe&&sn(/\/>/i,ft)){di(Ce,I);continue}q&&Sd([he,se,R],Bt=>{ft=lc(ft,Bt," ")});const tr=Zt(I.nodeName);if(!Br(tr,et,ft)){di(Ce,I);continue}if(x&&typeof p=="object"&&typeof p.getAttributeType=="function"&&!At)switch(p.getAttributeType(tr,et)){case"TrustedHTML":{ft=x.createHTML(ft);break}case"TrustedScriptURL":{ft=x.createScriptURL(ft);break}}if(ft!==yi)try{At?I.setAttributeNS(At,Ce,ft):I.setAttribute(Ce,ft),ut(I)?ts(I):K0(e.removed)}catch{di(Ce,I)}}st(M.afterSanitizeAttributes,I,null)},tn=function I(V){let E=null;const G=wo(V);for(st(M.beforeSanitizeShadowDOM,V,null);E=G.nextNode();)st(M.uponSanitizeShadowNode,E,null),wn(E),Fn(E),E.content instanceof r&&I(E.content);st(M.afterSanitizeShadowDOM,V,null)};return e.sanitize=function(I){let V=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},E=null,G=null,ne=null,Ce=null;if(bn=!I,bn&&(I=""),typeof I!="string"&&!Or(I))if(typeof I.toString=="function"){if(I=I.toString(),typeof I!="string")throw cc("dirty is not a string, aborting")}else throw cc("toString is not a function");if(!e.isSupported)return I;if(it||Js(V),e.removed=[],typeof I=="string"&&(Li=!1),Li){if(I.nodeName){const et=Zt(I.nodeName);if(!Z[et]||bt[et])throw cc("root node is forbidden and cannot be sanitized in-place")}}else if(I instanceof a)E=Bn(""),G=E.ownerDocument.importNode(I,!0),G.nodeType===dc.element&&G.nodeName==="BODY"||G.nodeName==="HTML"?E=G:E.appendChild(G);else{if(!me&&!q&&!He&&I.indexOf("<")===-1)return x&&ui?x.createHTML(I):I;if(E=Bn(I),!E)return me?null:ui?A:""}E&&Vt&&ts(E.firstChild);const At=wo(Li?I:E);for(;ne=At.nextNode();)wn(ne),Fn(ne),ne.content instanceof r&&tn(ne.content);if(Li)return I;if(me){if(nt)for(Ce=H.call(E.ownerDocument);E.firstChild;)Ce.appendChild(E.firstChild);else Ce=E;return(xe.shadowroot||xe.shadowrootmode)&&(Ce=te.call(n,Ce,!0)),Ce}let rt=He?E.outerHTML:E.innerHTML;return He&&Z["!doctype"]&&E.ownerDocument&&E.ownerDocument.doctype&&E.ownerDocument.doctype.name&&sn(A2,E.ownerDocument.doctype.name)&&(rt=" `+rt),q&&Sd([he,se,R],et=>{rt=lc(rt,et," ")}),x&&ui?x.createHTML(rt):rt},e.setConfig=function(){let I=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Js(I),it=!0},e.clearConfig=function(){Ot=null,it=!1},e.isValidAttribute=function(I,V,E){Ot||Js({});const G=Zt(I),ne=Zt(V);return Br(G,ne,E)},e.addHook=function(I,V){typeof V=="function"&&ac(M[I],V)},e.removeHook=function(I,V){if(V!==void 0){const E=vD(M[I],V);return E===-1?void 0:xD(M[I],E,1)[0]}return K0(M[I])},e.removeHooks=function(I){M[I]=[]},e.removeAllHooks=function(){M=nx()},e}var FD=I2();const zD=i=>typeof i=="function",L2=i=>Array.isArray(i),UD=i=>i instanceof Object,$D=i=>i instanceof Object?i.constructor.name!=="Function"&&i.constructor.name!=="Object":!1,sx=i=>UD(i)&&!L2(i)&&!zD(i)&&!$D(i);function Mo(i){let e;if(L2(i))e=i;else{const t=Uo(i),n=t==null?void 0:t.rgb();e=[(n==null?void 0:n.r)||0,(n==null?void 0:n.g)||0,(n==null?void 0:n.b)||0,(t==null?void 0:t.opacity)??1]}return[e[0]/255,e[1]/255,e[2]/255,e[3]]}function jD(i,e,t){return .2126*i+.7152*e+.0722*t}function jn(i,e,t=0,n=0,s,r){return i.readPixelsToArrayWebGL(e,{sourceX:t,sourceY:n,sourceWidth:s,sourceHeight:r})}function HD(i,e,t){return Math.min(Math.max(i,e),t)}function rs(i){return i!=null&&!Number.isNaN(i)}function VD(i,e){return FD.sanitize(i,{ALLOWED_TAGS:["a","b","i","em","strong","span","div","p","br"],ALLOWED_ATTR:["href","target","class","id","style"],ALLOW_DATA_ATTR:!1,...e})}class GD{constructor(){this.enableSimulation=pe.enableSimulation,this.backgroundColor=E2,this.spaceSize=pe.spaceSize,this.pointColor=oD,this.pointDefaultColor=void 0,this.pointGreyoutOpacity=aD,this.pointGreyoutColor=wg,this.pointSize=cD,this.pointDefaultSize=void 0,this.pointOpacity=lD,this.pointSizeScale=pe.pointSizeScale,this.hoveredPointCursor=pe.hoveredPointCursor,this.hoveredLinkCursor=pe.hoveredLinkCursor,this.renderHoveredPointRing=pe.renderHoveredPointRing,this.hoveredPointRingColor=pe.hoveredPointRingColor,this.focusedPointRingColor=pe.focusedPointRingColor,this.focusedPointIndex=pe.focusedPointIndex,this.linkColor=uD,this.linkDefaultColor=void 0,this.linkOpacity=hD,this.linkGreyoutOpacity=dD,this.linkWidth=fD,this.linkDefaultWidth=void 0,this.linkWidthScale=pe.linkWidthScale,this.hoveredLinkColor=pe.hoveredLinkColor,this.hoveredLinkWidthIncrease=pe.hoveredLinkWidthIncrease,this.renderLinks=pe.renderLinks,this.curvedLinks=pe.curvedLinks,this.curvedLinkSegments=pe.curvedLinkSegments,this.curvedLinkWeight=pe.curvedLinkWeight,this.curvedLinkControlPointDistance=pe.curvedLinkControlPointDistance,this.linkArrows=pe.linkArrows,this.linkDefaultArrows=void 0,this.linkArrowsSizeScale=pe.linkArrowsSizeScale,this.scaleLinksOnZoom=pe.scaleLinksOnZoom,this.linkVisibilityDistanceRange=pe.linkVisibilityDistanceRange,this.linkVisibilityMinTransparency=pe.linkVisibilityMinTransparency,this.simulationDecay=pe.simulation.decay,this.simulationGravity=pe.simulation.gravity,this.simulationCenter=pe.simulation.center,this.simulationRepulsion=pe.simulation.repulsion,this.simulationRepulsionTheta=pe.simulation.repulsionTheta,this.simulationLinkSpring=pe.simulation.linkSpring,this.simulationLinkDistance=pe.simulation.linkDistance,this.simulationLinkDistRandomVariationRange=pe.simulation.linkDistRandomVariationRange,this.simulationRepulsionFromMouse=pe.simulation.repulsionFromMouse,this.enableRightClickRepulsion=pe.enableRightClickRepulsion,this.simulationFriction=pe.simulation.friction,this.simulationCluster=pe.simulation.cluster,this.onSimulationStart=void 0,this.onSimulationTick=void 0,this.onSimulationEnd=void 0,this.onSimulationPause=void 0,this.onSimulationRestart=void 0,this.onSimulationUnpause=void 0,this.onClick=void 0,this.onPointClick=void 0,this.onLinkClick=void 0,this.onBackgroundClick=void 0,this.onMouseMove=void 0,this.onPointMouseOver=void 0,this.onPointMouseOut=void 0,this.onLinkMouseOver=void 0,this.onLinkMouseOut=void 0,this.onZoomStart=void 0,this.onZoom=void 0,this.onZoomEnd=void 0,this.onDragStart=void 0,this.onDrag=void 0,this.onDragEnd=void 0,this.showFPSMonitor=pe.showFPSMonitor,this.pixelRatio=pe.pixelRatio,this.scalePointsOnZoom=pe.scalePointsOnZoom,this.initialZoomLevel=void 0,this.enableZoom=pe.enableZoom,this.enableSimulationDuringZoom=pe.enableSimulationDuringZoom,this.enableDrag=pe.enableDrag,this.fitViewOnInit=pe.fitViewOnInit,this.fitViewDelay=pe.fitViewDelay,this.fitViewPadding=pe.fitViewPadding,this.fitViewDuration=pe.fitViewDuration,this.fitViewByPointsInRect=void 0,this.fitViewByPointIndices=void 0,this.randomSeed=void 0,this.pointSamplingDistance=pe.pointSamplingDistance,this.attribution=pe.attribution,this.rescalePositions=pe.rescalePositions}init(e){Object.keys(e).forEach(t=>{this.deepMergeConfig(this.getConfig(),e,t)})}deepMergeConfig(e,t,n){sx(e[n])&&sx(t[n])?Object.keys(t[n]).forEach(s=>{this.deepMergeConfig(e[n],t[n],s)}):e[n]=t[n]}getConfig(){return this}}function dy(i,e){if(!i)throw new Error(e||"shadertools: assertion failed.")}const sm={number:{type:"number",validate(i,e){return Number.isFinite(i)&&typeof e=="object"&&(e.max===void 0||i<=e.max)&&(e.min===void 0||i>=e.min)}},array:{type:"array",validate(i,e){return Array.isArray(i)||ArrayBuffer.isView(i)}}};function WD(i){const e={};for(const[t,n]of Object.entries(i))e[t]=YD(n);return e}function YD(i){let e=rx(i);if(e!=="object")return{value:i,...sm[e],type:e};if(typeof i=="object")return i?i.type!==void 0?{...i,...sm[i.type],type:i.type}:i.value===void 0?{type:"object",value:i}:(e=rx(i.value),{...i,...sm[e],type:e}):{type:"object",value:null};throw new Error("props")}function rx(i){return Array.isArray(i)||ArrayBuffer.isView(i)?"array":typeof i}const qD=`#ifdef MODULE_LOGDEPTH logdepth_adjustPosition(gl_Position); #endif diff --git a/frontend/dist/assets/NodeInformationCard-BUD0ZP9t.js b/frontend/dist/assets/NodeInformationCard-Byom2o5k.js similarity index 90% rename from frontend/dist/assets/NodeInformationCard-BUD0ZP9t.js rename to frontend/dist/assets/NodeInformationCard-Byom2o5k.js index 3779edd2..d88cfdbd 100644 --- a/frontend/dist/assets/NodeInformationCard-BUD0ZP9t.js +++ b/frontend/dist/assets/NodeInformationCard-Byom2o5k.js @@ -1 +1 @@ -import{j as s,F as i,R as d,cJ as c}from"./index-C1ZF7cAz.js";import{C as n}from"./PageLayout-sd81yog0.js";import{D as m}from"./DataBox-BADtaCfB.js";function j({nodeName:e,repeaterVersion:a,coreVersion:t,localHash:r,publicKey:l}){return s.jsxs(n,{neomorphic:!0,children:[s.jsx(i,{icon:s.jsx(d,{}),title:"Node Information"}),s.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-5 gap-3 sm:gap-4",children:[s.jsxs("div",{className:"min-w-0 col-span-2 sm:col-span-1",children:[s.jsx("span",{className:"type-label text-fg-secondary",children:"Node Name"}),s.jsx("p",{className:"type-body text-fg-primary mt-0.5 sm:mt-1 truncate",title:e,children:e})]}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("span",{className:"type-label text-fg-secondary",children:"Repeater"}),s.jsxs("p",{className:"type-data text-fg-primary mt-0.5 sm:mt-1 truncate",title:`v${a}`,children:["v",a]})]}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("span",{className:"type-label text-fg-secondary",children:"Core"}),s.jsxs("p",{className:"type-data text-fg-primary mt-0.5 sm:mt-1 truncate",title:`v${t}`,children:["v",t]})]}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("span",{className:"type-label text-fg-secondary",children:"Console"}),s.jsxs("p",{className:"type-data text-fg-primary mt-0.5 sm:mt-1 truncate",title:`v${c}`,children:["v",c]})]}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("span",{className:"type-label text-fg-secondary",children:"Local Hash"}),s.jsx("div",{className:"mt-0.5 sm:mt-1",children:r?s.jsx(m,{copy:!0,size:"compact",children:r}):s.jsx("span",{className:"type-data-sm text-fg-secondary",children:"N/A"})})]})]}),l&&s.jsxs("div",{className:"mt-3 sm:mt-4 pt-3 sm:pt-4 border-t border-edge-subtle",children:[s.jsx("span",{className:"type-label text-fg-secondary",children:"Public Key"}),s.jsx("div",{className:"mt-0.5 sm:mt-1",children:s.jsx(m,{copy:!0,size:"responsive",children:l})})]})]})}export{j as N}; +import{j as s,H as i,R as d,cH as c}from"./index-DhkG1Nx9.js";import{C as n}from"./PageLayout-BkUTZXJb.js";import{D as m}from"./DataBox-BMesbbaF.js";function j({nodeName:e,repeaterVersion:a,coreVersion:t,localHash:r,publicKey:l}){return s.jsxs(n,{neomorphic:!0,children:[s.jsx(i,{icon:s.jsx(d,{}),title:"Node Information"}),s.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-5 gap-3 sm:gap-4",children:[s.jsxs("div",{className:"min-w-0 col-span-2 sm:col-span-1",children:[s.jsx("span",{className:"type-label text-fg-secondary",children:"Node Name"}),s.jsx("p",{className:"type-body text-fg-primary mt-0.5 sm:mt-1 truncate",title:e,children:e})]}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("span",{className:"type-label text-fg-secondary",children:"Repeater"}),s.jsxs("p",{className:"type-data text-fg-primary mt-0.5 sm:mt-1 truncate",title:`v${a}`,children:["v",a]})]}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("span",{className:"type-label text-fg-secondary",children:"Core"}),s.jsxs("p",{className:"type-data text-fg-primary mt-0.5 sm:mt-1 truncate",title:`v${t}`,children:["v",t]})]}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("span",{className:"type-label text-fg-secondary",children:"Console"}),s.jsxs("p",{className:"type-data text-fg-primary mt-0.5 sm:mt-1 truncate",title:`v${c}`,children:["v",c]})]}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("span",{className:"type-label text-fg-secondary",children:"Local Hash"}),s.jsx("div",{className:"mt-0.5 sm:mt-1",children:r?s.jsx(m,{copy:!0,size:"compact",children:r}):s.jsx("span",{className:"type-data-sm text-fg-secondary",children:"N/A"})})]})]}),l&&s.jsxs("div",{className:"mt-3 sm:mt-4 pt-3 sm:pt-4 border-t border-edge-subtle",children:[s.jsx("span",{className:"type-label text-fg-secondary",children:"Public Key"}),s.jsx("div",{className:"mt-0.5 sm:mt-1",children:s.jsx(m,{copy:!0,size:"responsive",children:l})})]})]})}export{j as N}; diff --git a/frontend/dist/assets/PacketList-BiFMK9DR.js b/frontend/dist/assets/PacketList-BiFMK9DR.js deleted file mode 100644 index fdfd5f6c..00000000 --- a/frontend/dist/assets/PacketList-BiFMK9DR.js +++ /dev/null @@ -1,67 +0,0 @@ -const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/PathMapMapLibre-B3ia8Mj4.js","assets/index-C1ZF7cAz.js","assets/BasemapLayer-CfNM-FKA.js","assets/useMapViewStore-px_sYTaN.js","assets/index-DCNWD5GU.js","assets/index-DWhIzXT2.css","assets/BasemapLayer-B1CfjdFi.css"])))=>i.map(i=>d[i]); -import{r as p,aD as ds,d as me,bd as xs,be as zt,bf as ms,bg as hs,j as e,c as R,B as rt,bh as us,x as it,q as B,bi as Ft,R as de,bj as It,bk as At,bl as Dt,bm as ue,bn as Ze,$ as De,bo as ps,bp as fs,bq as gs,br as ys,bs as js,m as oe,a7 as re,w as bs,bt as Ns,bu as ie,bv as ut,bw as vs,bx as ws,by as ks,bz as Cs,bA as Ss,bB as _s,bC as Je,bD as Ms,a3 as Ts,E as Ht,bE as Ps,bF as Bs,bG as Ls,bH as Rs,ac as Ot,ad as $t,A as Ke,bI as Es,ae as zs,bJ as Fs,bK as lt}from"./index-C1ZF7cAz.js";import{p as Is,d as As,e as Ut,g as Ds,b as Hs}from"./primitives-DyUGjsV_.js";import{u as Os,r as $s,a as Us,b as Vs,c as Ws,d as Gs,i as Qs}from"./consumer-registry-CFnLzQEu.js";import{D as Pe,R as He,P as Be,g as qs}from"./badge-colors-BNUqIXCA.js";import{g as Vt,e as _e,a as Wt}from"./chat-utils-BzC-Ehs-.js";import{P as Gt,d as Qt,a as Ks,b as Ys}from"./payload-decoders-CmuRVuC0.js";import{A as pe,S as Oe,i as $e,C as xe,a as Xs,g as pt}from"./SignalIndicator-BDLlaquA.js";import{a as Zs,A as qt}from"./arrow-up-DhGrEgP7.js";import{C as ct}from"./chevron-right-DzbDJf-i.js";import{M as Ue}from"./map-pin-DEktgLFN.js";import{C as Js}from"./circle-question-mark-CxqvWhsl.js";import{T as et}from"./triangle-alert-B3ZB2VPZ.js";import{D as X}from"./DataBox-BADtaCfB.js";import{L as ea}from"./layers-BNenbfjd.js";import{H as Kt}from"./hash-2pKM_KWy.js";import{A as ta}from"./activity-Bmh45lNn.js";import{C as sa}from"./circle-check-DY6oislV.js";import{D as aa}from"./database-CdKnhwkJ.js";import{H as na,D as tt,Z as ft,u as ra}from"./useMapViewStore-px_sYTaN.js";import{S as we}from"./shield-BNyjVgrV.js";import{C as Yt}from"./TimeRangeStepper-CxA2aT1o.js";function ke(t,n,s){let a=s.initialDeps??[],r,i=!0;function l(){var c,o,u;let x;s.key&&((c=s.debug)!=null&&c.call(s))&&(x=Date.now());const g=t();if(!(g.length!==a.length||g.some((m,v)=>a[v]!==m)))return r;a=g;let y;if(s.key&&((o=s.debug)!=null&&o.call(s))&&(y=Date.now()),r=n(...g),s.key&&((u=s.debug)!=null&&u.call(s))){const m=Math.round((Date.now()-x)*100)/100,v=Math.round((Date.now()-y)*100)/100,T=v/16,h=(N,j)=>{for(N=String(N);N.length{a=c},l}function gt(t,n){if(t===void 0)throw new Error("Unexpected undefined");return t}const ia=(t,n)=>Math.abs(t-n)<1.01,la=(t,n,s)=>{let a;return function(...r){t.clearTimeout(a),a=t.setTimeout(()=>n.apply(this,r),s)}},yt=t=>{const{offsetWidth:n,offsetHeight:s}=t;return{width:n,height:s}},ca=t=>t,oa=t=>{const n=Math.max(t.startIndex-t.overscan,0),s=Math.min(t.endIndex+t.overscan,t.count-1),a=[];for(let r=n;r<=s;r++)a.push(r);return a},da=(t,n)=>{const s=t.scrollElement;if(!s)return;const a=t.targetWindow;if(!a)return;const r=l=>{const{width:c,height:o}=l;n({width:Math.round(c),height:Math.round(o)})};if(r(yt(s)),!a.ResizeObserver)return()=>{};const i=new a.ResizeObserver(l=>{const c=()=>{const o=l[0];if(o!=null&&o.borderBoxSize){const u=o.borderBoxSize[0];if(u){r({width:u.inlineSize,height:u.blockSize});return}}r(yt(s))};t.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(c):c()});return i.observe(s,{box:"border-box"}),()=>{i.unobserve(s)}},jt={passive:!0},bt=typeof window>"u"?!0:"onscrollend"in window,xa=(t,n)=>{const s=t.scrollElement;if(!s)return;const a=t.targetWindow;if(!a)return;let r=0;const i=t.options.useScrollendEvent&&bt?()=>{}:la(a,()=>{n(r,!1)},t.options.isScrollingResetDelay),l=x=>()=>{const{horizontal:g,isRtl:f}=t.options;r=g?s.scrollLeft*(f&&-1||1):s.scrollTop,i(),n(r,x)},c=l(!0),o=l(!1);s.addEventListener("scroll",c,jt);const u=t.options.useScrollendEvent&&bt;return u&&s.addEventListener("scrollend",o,jt),()=>{s.removeEventListener("scroll",c),u&&s.removeEventListener("scrollend",o)}},ma=(t,n,s)=>{if(n!=null&&n.borderBoxSize){const a=n.borderBoxSize[0];if(a)return Math.round(a[s.options.horizontal?"inlineSize":"blockSize"])}return t[s.options.horizontal?"offsetWidth":"offsetHeight"]},ha=(t,{adjustments:n=0,behavior:s},a)=>{var r,i;const l=t+n;(i=(r=a.scrollElement)==null?void 0:r.scrollTo)==null||i.call(r,{[a.options.horizontal?"left":"top"]:l,behavior:s})};class ua{constructor(n){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.currentScrollToIndex=null,this.measurementsCache=[],this.itemSizeCache=new Map,this.laneAssignments=new Map,this.pendingMeasuredCacheIndexes=[],this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this.elementsCache=new Map,this.observer=(()=>{let s=null;const a=()=>s||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:s=new this.targetWindow.ResizeObserver(r=>{r.forEach(i=>{const l=()=>{this._measureElement(i.target,i)};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(l):l()})}));return{disconnect:()=>{var r;(r=a())==null||r.disconnect(),s=null},observe:r=>{var i;return(i=a())==null?void 0:i.observe(r,{box:"border-box"})},unobserve:r=>{var i;return(i=a())==null?void 0:i.unobserve(r)}}})(),this.range=null,this.setOptions=s=>{Object.entries(s).forEach(([a,r])=>{typeof r>"u"&&delete s[a]}),this.options={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:ca,rangeExtractor:oa,onChange:()=>{},measureElement:ma,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:"data-index",initialMeasurementsCache:[],lanes:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,...s}},this.notify=s=>{var a,r;(r=(a=this.options).onChange)==null||r.call(a,this,s)},this.maybeNotify=ke(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),s=>{this.notify(s)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(s=>s()),this.unsubs=[],this.observer.disconnect(),this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var s;const a=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==a){if(this.cleanup(),!a){this.maybeNotify();return}this.scrollElement=a,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=((s=this.scrollElement)==null?void 0:s.window)??null,this.elementsCache.forEach(r=>{this.observer.observe(r)}),this.unsubs.push(this.options.observeElementRect(this,r=>{this.scrollRect=r,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(r,i)=>{this.scrollAdjustments=0,this.scrollDirection=i?this.getScrollOffset()this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?"width":"height"]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset=="function"?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getFurthestMeasurement=(s,a)=>{const r=new Map,i=new Map;for(let l=a-1;l>=0;l--){const c=s[l];if(r.has(c.lane))continue;const o=i.get(c.lane);if(o==null||c.end>o.end?i.set(c.lane,c):c.endl.end===c.end?l.index-c.index:l.end-c.end)[0]:void 0},this.getMeasurementOptions=ke(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes],(s,a,r,i,l,c)=>(this.prevLanes!==void 0&&this.prevLanes!==c&&(this.lanesChangedFlag=!0),this.prevLanes=c,this.pendingMeasuredCacheIndexes=[],{count:s,paddingStart:a,scrollMargin:r,getItemKey:i,enabled:l,lanes:c}),{key:!1}),this.getMeasurements=ke(()=>[this.getMeasurementOptions(),this.itemSizeCache],({count:s,paddingStart:a,scrollMargin:r,getItemKey:i,enabled:l,lanes:c},o)=>{if(!l)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>s)for(const f of this.laneAssignments.keys())f>=s&&this.laneAssignments.delete(f);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMeasuredCacheIndexes=[]),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(f=>{this.itemSizeCache.set(f.key,f.size)}));const u=this.lanesSettling?0:this.pendingMeasuredCacheIndexes.length>0?Math.min(...this.pendingMeasuredCacheIndexes):0;this.pendingMeasuredCacheIndexes=[],this.lanesSettling&&this.measurementsCache.length===s&&(this.lanesSettling=!1);const x=this.measurementsCache.slice(0,u),g=new Array(c).fill(void 0);for(let f=0;f1){v=m;const C=g[v],k=C!==void 0?x[C]:void 0;T=k?k.end+this.options.gap:a+r}else{const C=this.options.lanes===1?x[f-1]:this.getFurthestMeasurement(x,f);T=C?C.end+this.options.gap:a+r,v=C?C.lane:f%this.options.lanes,this.options.lanes>1&&this.laneAssignments.set(f,v)}const h=o.get(y),N=typeof h=="number"?h:this.options.estimateSize(f),j=T+N;x[f]={index:f,start:T,size:N,end:j,key:y,lane:v},g[v]=f}return this.measurementsCache=x,x},{key:!1,debug:()=>this.options.debug}),this.calculateRange=ke(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(s,a,r,i)=>this.range=s.length>0&&a>0?pa({measurements:s,outerSize:a,scrollOffset:r,lanes:i}):null,{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=ke(()=>{let s=null,a=null;const r=this.calculateRange();return r&&(s=r.startIndex,a=r.endIndex),this.maybeNotify.updateDeps([this.isScrolling,s,a]),[this.options.rangeExtractor,this.options.overscan,this.options.count,s,a]},(s,a,r,i,l)=>i===null||l===null?[]:s({startIndex:i,endIndex:l,overscan:a,count:r}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=s=>{const a=this.options.indexAttribute,r=s.getAttribute(a);return r?parseInt(r,10):(console.warn(`Missing attribute name '${a}={index}' on measured element.`),-1)},this._measureElement=(s,a)=>{const r=this.indexFromElement(s),i=this.measurementsCache[r];if(!i)return;const l=i.key,c=this.elementsCache.get(l);c!==s&&(c&&this.observer.unobserve(c),this.observer.observe(s),this.elementsCache.set(l,s)),s.isConnected&&this.resizeItem(r,this.options.measureElement(s,a,this))},this.resizeItem=(s,a)=>{const r=this.measurementsCache[s];if(!r)return;const i=this.itemSizeCache.get(r.key)??r.size,l=a-i;l!==0&&((this.shouldAdjustScrollPositionOnItemSizeChange!==void 0?this.shouldAdjustScrollPositionOnItemSizeChange(r,l,this):r.start{if(!s){this.elementsCache.forEach((a,r)=>{a.isConnected||(this.observer.unobserve(a),this.elementsCache.delete(r))});return}this._measureElement(s,void 0)},this.getVirtualItems=ke(()=>[this.getVirtualIndexes(),this.getMeasurements()],(s,a)=>{const r=[];for(let i=0,l=s.length;ithis.options.debug}),this.getVirtualItemForOffset=s=>{const a=this.getMeasurements();if(a.length!==0)return gt(a[Xt(0,a.length-1,r=>gt(a[r]).start,s)])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if("scrollHeight"in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{const s=this.scrollElement.document.documentElement;return this.options.horizontal?s.scrollWidth-this.scrollElement.innerWidth:s.scrollHeight-this.scrollElement.innerHeight}},this.getOffsetForAlignment=(s,a,r=0)=>{if(!this.scrollElement)return 0;const i=this.getSize(),l=this.getScrollOffset();a==="auto"&&(a=s>=l+i?"end":"start"),a==="center"?s+=(r-i)/2:a==="end"&&(s-=i);const c=this.getMaxScrollOffset();return Math.max(Math.min(c,s),0)},this.getOffsetForIndex=(s,a="auto")=>{s=Math.max(0,Math.min(s,this.options.count-1));const r=this.measurementsCache[s];if(!r)return;const i=this.getSize(),l=this.getScrollOffset();if(a==="auto")if(r.end>=l+i-this.options.scrollPaddingEnd)a="end";else if(r.start<=l+this.options.scrollPaddingStart)a="start";else return[l,a];if(a==="end"&&s===this.options.count-1)return[this.getMaxScrollOffset(),a];const c=a==="end"?r.end+this.options.scrollPaddingEnd:r.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(c,a,r.size),a]},this.isDynamicMode=()=>this.elementsCache.size>0,this.scrollToOffset=(s,{align:a="start",behavior:r}={})=>{r==="smooth"&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size."),this._scrollToOffset(this.getOffsetForAlignment(s,a),{adjustments:void 0,behavior:r})},this.scrollToIndex=(s,{align:a="auto",behavior:r}={})=>{r==="smooth"&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size."),s=Math.max(0,Math.min(s,this.options.count-1)),this.currentScrollToIndex=s;let i=0;const l=10,c=u=>{if(!this.targetWindow)return;const x=this.getOffsetForIndex(s,u);if(!x){console.warn("Failed to get offset for index:",s);return}const[g,f]=x;this._scrollToOffset(g,{adjustments:void 0,behavior:r}),this.targetWindow.requestAnimationFrame(()=>{const y=()=>{if(this.currentScrollToIndex!==s)return;const m=this.getScrollOffset(),v=this.getOffsetForIndex(s,f);if(!v){console.warn("Failed to get offset for index:",s);return}ia(v[0],m)||o(f)};this.isDynamicMode()?this.targetWindow.requestAnimationFrame(y):y()})},o=u=>{this.targetWindow&&this.currentScrollToIndex===s&&(i++,ic(u)):console.warn(`Failed to scroll to index ${s} after ${l} attempts.`))};c(a)},this.scrollBy=(s,{behavior:a}={})=>{a==="smooth"&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size."),this._scrollToOffset(this.getScrollOffset()+s,{adjustments:void 0,behavior:a})},this.getTotalSize=()=>{var s;const a=this.getMeasurements();let r;if(a.length===0)r=this.options.paddingStart;else if(this.options.lanes===1)r=((s=a[a.length-1])==null?void 0:s.end)??0;else{const i=Array(this.options.lanes).fill(null);let l=a.length-1;for(;l>=0&&i.some(c=>c===null);){const c=a[l];i[c.lane]===null&&(i[c.lane]=c.end),l--}r=Math.max(...i.filter(c=>c!==null))}return Math.max(r-this.options.scrollMargin+this.options.paddingEnd,0)},this._scrollToOffset=(s,{adjustments:a,behavior:r})=>{this.options.scrollToFn(s,{behavior:r,adjustments:a},this)},this.measure=()=>{this.itemSizeCache=new Map,this.laneAssignments=new Map,this.notify(!1)},this.setOptions(n)}}const Xt=(t,n,s,a)=>{for(;t<=n;){const r=(t+n)/2|0,i=s(r);if(ia)n=r-1;else return r}return t>0?t-1:0};function pa({measurements:t,outerSize:n,scrollOffset:s,lanes:a}){const r=t.length-1,i=o=>t[o].start;if(t.length<=a)return{startIndex:0,endIndex:r};let l=Xt(0,r,i,s),c=l;if(a===1)for(;c1){const o=Array(a).fill(0);for(;cx=0&&u.some(x=>x>=s);){const x=t[l];u[x.lane]=x.start,l--}l=Math.max(0,l-l%a),c=Math.min(r,c+(a-1-c%a))}return{startIndex:l,endIndex:c}}const Nt=typeof document<"u"?p.useLayoutEffect:p.useEffect;function fa({useFlushSync:t=!0,...n}){const s=p.useReducer(()=>({}),{})[1],a={...n,onChange:(i,l)=>{var c;t&&l?ds.flushSync(s):s(),(c=n.onChange)==null||c.call(n,i,l)}},[r]=p.useState(()=>new ua(a));return r.setOptions(a),Nt(()=>r._didMount(),[]),Nt(()=>r._willUpdate()),r}function ga(t){return fa({observeElementRect:da,observeElementOffset:xa,scrollToFn:ha,...t})}/** - * @license lucide-react v0.559.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const ya=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],ja=me("chevron-up",ya);/** - * @license lucide-react v0.559.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const ba=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]],Tr=me("circle-x",ba);/** - * @license lucide-react v0.559.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const Na=[["path",{d:"m15 10 5 5-5 5",key:"qqa56n"}],["path",{d:"M4 4v7a4 4 0 0 0 4 4h12",key:"z08zvw"}]],va=me("corner-down-right",Na);/** - * @license lucide-react v0.559.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const wa=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]],ot=me("lock",wa);/** - * @license lucide-react v0.559.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const ka=[["path",{d:"M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719",key:"1sd12s"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]],Zt=me("message-circle-question-mark",ka);/** - * @license lucide-react v0.559.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const Ca=[["path",{d:"M20 18v-2a4 4 0 0 0-4-4H4",key:"5vmcpk"}],["path",{d:"m9 17-5-5 5-5",key:"nvlc11"}]],Sa=me("reply",Ca);/** - * @license lucide-react v0.559.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const _a=[["circle",{cx:"6",cy:"19",r:"3",key:"1kj8tv"}],["path",{d:"M9 19h8.5a3.5 3.5 0 0 0 0-7h-11a3.5 3.5 0 0 1 0-7H15",key:"1d8sl"}],["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}]],Ma=me("route",_a);/** - * @license lucide-react v0.559.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const Ta=[["path",{d:"M11 2v2",key:"1539x4"}],["path",{d:"M5 2v2",key:"1yf1q8"}],["path",{d:"M5 3H4a2 2 0 0 0-2 2v4a6 6 0 0 0 12 0V5a2 2 0 0 0-2-2h-1",key:"rb5t3r"}],["path",{d:"M8 15a6 6 0 0 0 12 0v-3",key:"x18d4x"}],["circle",{cx:"20",cy:"10",r:"2",key:"ts1r5v"}]],vt=me("stethoscope",Ta);/** - * @license lucide-react v0.559.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const Pa=[["path",{d:"M10 14.66v1.626a2 2 0 0 1-.976 1.696A5 5 0 0 0 7 21.978",key:"1n3hpd"}],["path",{d:"M14 14.66v1.626a2 2 0 0 0 .976 1.696A5 5 0 0 1 17 21.978",key:"rfe1zi"}],["path",{d:"M18 9h1.5a1 1 0 0 0 0-5H18",key:"7xy6bh"}],["path",{d:"M4 22h16",key:"57wxv0"}],["path",{d:"M6 9a6 6 0 0 0 12 0V3a1 1 0 0 0-1-1H7a1 1 0 0 0-1 1z",key:"1mhfuq"}],["path",{d:"M6 9H4.5a1 1 0 0 1 0-5H6",key:"tex48p"}]],wt=me("trophy",Pa);/** - * @license lucide-react v0.559.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const Ba=[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]],Ce=me("user",Ba);function La(t){t.values.forEach(n=>n.stop())}function st(t,n){[...n].reverse().forEach(a=>{const r=t.getVariant(a);r&&zt(t,r),t.variantChildren&&t.variantChildren.forEach(i=>{st(i,n)})})}function Ra(t,n){if(Array.isArray(n))return st(t,n);if(typeof n=="string")return st(t,[n]);zt(t,n)}function Ea(){const t=new Set,n={subscribe(s){return t.add(s),()=>void t.delete(s)},start(s,a){const r=[];return t.forEach(i=>{r.push(xs(i,s,{transitionOverride:a}))}),Promise.all(r)},set(s){return t.forEach(a=>{Ra(a,s)})},stop(){t.forEach(s=>{La(s)})},mount(){return()=>{n.stop()}}};return n}function za(){const t=ms(Ea);return hs(t.mount,[]),t}function Fa({"aria-label":t="Page navigation",className:n,...s}){return e.jsx("nav",{"aria-label":t,...s,className:R("flex gap-x-2",n)})}function Ia({onClick:t,disabled:n=!1,className:s,children:a="Previous"}){return e.jsx("span",{className:R("grow basis-0",s),children:e.jsxs(rt,{plain:!0,onClick:t,disabled:n,"aria-label":"Previous page",className:R("gap-1",n&&"invisible"),children:[e.jsx("svg",{className:"size-4 stroke-current",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:e.jsx("path",{d:"M2.75 8H13.25M2.75 8L5.25 5.5M2.75 8L5.25 10.5",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round"})}),a]})})}function Aa({onClick:t,disabled:n=!1,className:s,children:a="Next"}){return e.jsx("span",{className:R("flex grow basis-0 justify-end",s),children:e.jsxs(rt,{plain:!0,onClick:t,disabled:n,"aria-label":"Next page",className:R("gap-1",n&&"invisible"),children:[a,e.jsx("svg",{className:"size-4 stroke-current",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:e.jsx("path",{d:"M13.25 8L2.75 8M13.25 8L10.75 10.5M13.25 8L10.75 5.5",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round"})})]})})}function Da({className:t,...n}){return e.jsx("span",{...n,className:R("hidden items-baseline gap-x-2 sm:flex",t)})}function Ha({page:t,current:n=!1,onClick:s,className:a,children:r}){return e.jsx(rt,{plain:!n,outline:n,onClick:()=>s==null?void 0:s(t),"aria-label":`Page ${t}`,"aria-current":n?"page":void 0,className:R("min-w-[2.25rem] before:absolute before:-inset-px before:rounded-lg",n&&"before:bg-subtle-fill",a),children:r??t})}function Oa({className:t,...n}){return e.jsx("span",{"aria-hidden":"true",...n,className:R("w-[2.25rem] select-none text-center text-sm text-fg-muted",t),children:"…"})}function $a(t,n,s=1){if(n<=7)return Array.from({length:n},(o,u)=>u+1);const a=Math.max(t-s,1),r=Math.min(t+s,n),i=a>2,l=rg+1),"gap",n]}if(i&&!l){const o=3+2*s;return[1,"gap",...Array.from({length:o},(x,g)=>n-o+g+1)]}return[1,"gap",...Array.from({length:r-a+1},(o,u)=>a+u),"gap",n]}const Pr=us(t=>({requestedHash:null,requestChannel:n=>t({requestedHash:n}),clearRequest:()=>t({requestedHash:null})}));function Ua(t){if(t.length===0)return[];const n=[];let s=0;for(;s{const l=i===t.length-1,c=a&&r.toUpperCase()===a;return e.jsxs("span",{className:"flex items-center flex-shrink-0",children:[c?e.jsx("span",{className:"px-1 py-0.5 rounded bg-sys-amber/20 text-sys-amber text-[9px] font-medium",children:"You"}):e.jsx("span",{className:"px-1 py-0.5 rounded bg-subtle-fill-hover text-fg-secondary",children:r.toUpperCase()}),!l&&e.jsx(ct,{className:"w-2.5 h-2.5 text-fg-muted mx-0.5 flex-shrink-0"})]},`${r}-${i}`)})})}const es=p.memo(qa);function ts({channelName:t,onClick:n,active:s,compact:a,className:r}){const i=t.startsWith("#")?t:`#${t}`,l=R("inline-flex items-center flex-shrink-0","font-medium",a?"px-1.5 h-4 leading-4 rounded text-[10px]":"px-2 h-5 leading-5 rounded text-xs",s?"bg-sys-blue/20 text-sys-blue":"bg-sys-blue/10 text-sys-blue",n&&!s&&"hover:bg-sys-blue/20 cursor-pointer",r);return n?e.jsx("button",{type:"button",onClick:n,className:l,children:i}):e.jsx("span",{className:l,children:i})}function Me(t){return{"--data-box-accent":ue[t]}}function ss(t){const n=t.payload_type_name||At(t.payload_type??t.type),s=t.route_type_name||Dt(t.route_type??t.route),a=Be[n]??"zinc",r=He[s]??"zinc";return{payloadType:n,routeType:s,payloadColor:a,routeColor:r}}function Ve(t){if(!t)return[];if(Array.isArray(t))return t;try{const n=JSON.parse(t);return Array.isArray(n)?n:[]}catch{return[]}}function as(t,n){if(n){const s=n(t);return{name:s.name,isCompanion:s.isCompanion,isRepeater:s.isRepeater}}return{name:null,isCompanion:!1,isRepeater:!1}}function Ka({packet:t,onClick:n,localHash:s,neighbors:a,resolveSource:r,isFlashing:i=!1,isTraceHighlighted:l,onTraceHover:c,traceTag:o,onViewTraceReport:u,dupeGroupPosition:x,isDupeGroupHovered:g=!1,onDupeGroupHover:f,dupeCount:y,getDecodedContent:m,onChannelClick:v}){const T=y?!1:Ft(t.is_duplicate),h=x!==void 0,{payloadType:N,routeType:j,payloadColor:C,routeColor:k}=ss(t),b=t.packet_origin==="tx_local",A=N==="TRACE",U=Ve(t.original_path),W=Ve(t.forwarded_path),K=W.length>0?W:U,F=t.src_hash?(t.src_hash.startsWith("0x")?t.src_hash.slice(2,6):t.src_hash.slice(0,4)).toUpperCase():null,{name:Y,isRepeater:D}=as(t,r);let E=null,O=null,$=null,J=null;if(N==="GRP_TXT"&&m){const _=m(t);_!=null&&_.decrypted&&(O=_.senderName,$=_.channelName,J=_.channelHash,_.text&&(E=_.text))}else if(N==="TXT_MSG"&&t.raw_packet)try{const _=Gt.fromHex(t.raw_packet);if(_.success&&_.packet){const ce=Qt(_.packet.payload);ce&&!ce.encrypted&&(E=ce.text)}}catch{}const M=O||(D?null:Y),H=!!M,te=!H&&D&&!!Y,se=!H&&!te&&N==="GRP_TXT"&&!E,d=t.payload_length??t.length??0;t.lbt_attempts;const Z=p.useCallback(()=>{A&&o&&u?u(o):n(t)},[A,o,u,n,t]),q=p.useCallback(()=>{A&&o&&c&&c(o),h&&f&&t.packet_hash&&f(t.packet_hash)},[A,o,c,h,f,t.packet_hash]),le=p.useCallback(()=>{c&&c(null),f&&f(null)},[c,f]),P=ue[C]||ue.zinc,z=g,ae=()=>{const _={pointerEvents:"none"};return x==="first"?{..._,borderTop:`2px solid ${P}`,borderLeft:`2px solid ${P}`,borderRight:`2px solid ${P}`,borderBottom:"none",borderRadius:"8px 8px 0 0",inset:"-2px -2px 0 -2px"}:x==="middle"?{..._,borderTop:"none",borderLeft:`2px solid ${P}`,borderRight:`2px solid ${P}`,borderBottom:"none",borderRadius:0,inset:"0 -2px"}:x==="last"?{..._,borderTop:"none",borderLeft:`2px solid ${P}`,borderRight:`2px solid ${P}`,borderBottom:`2px solid ${P}`,borderRadius:"0 0 8px 8px",inset:"0 -2px -2px -2px"}:{..._,border:`2px solid ${P}`,borderRadius:"8px",inset:"-2px"}};return e.jsxs("div",{onClick:Z,onMouseEnter:q,onMouseLeave:le,className:R("group relative cursor-pointer","hover:bg-subtle-fill",T&&!g&&"opacity-40",i&&"flash-row",b&&"bg-sys-indigo/5",l&&"bg-sys-teal/10"),children:[e.jsx("div",{className:R("absolute pointer-events-none transition-opacity duration-75",h?z?"opacity-100":"opacity-0":"opacity-0 group-hover:opacity-100"),style:ae()}),e.jsxs("div",{className:"relative flex items-center gap-2 min-[600px]:gap-3 px-2 py-2 min-[600px]:px-3 min-[600px]:py-2.5",children:[e.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[e.jsx("div",{className:"relative flex-shrink-0",children:H?e.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center ring-1 ring-edge-subtle",style:{backgroundColor:Vt(_e(M).cleanName)},children:_e(M).emoji?e.jsx("span",{className:"text-base leading-none",children:_e(M).emoji}):e.jsx("span",{className:"text-white text-[10px] font-bold tracking-tighter",children:Wt(M)})}):te?e.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center ring-[1.5px] ring-sys-blue",children:e.jsx(de,{className:"size-5 text-sys-blue"})}):se?e.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center bg-zinc-500/20 ring-1 ring-edge-subtle",children:e.jsx(Zt,{className:"size-4 text-fg-muted"})}):e.jsx(Jt,{packet:t,variant:"avatar",size:"sm"})}),e.jsx("div",{className:"min-w-0",children:H?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"font-semibold text-[13px] text-fg-primary font-sans truncate max-w-[90px]",children:M}),F&&e.jsx("div",{className:"hidden min-[900px]:block text-[9px] text-fg-muted truncate",children:F})]}):te?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"font-semibold text-[13px] text-fg-primary font-sans truncate max-w-[90px]",children:Y}),F&&e.jsx("div",{className:"hidden min-[900px]:block text-[9px] text-fg-muted truncate",children:F})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"font-bold text-[13px] text-fg-primary font-sans truncate",children:F||"—"}),Y&&e.jsx("div",{className:"hidden min-[900px]:block text-[9px] text-fg-muted truncate max-w-[70px]",children:Y})]})})]}),e.jsxs("div",{className:"flex-1 flex items-center gap-1 min-[600px]:gap-1.5 min-[900px]:gap-2 min-w-0",children:[e.jsx("span",{className:"data-box data-box-compact data-box-outlined flex-shrink-0",style:Me(C),children:N}),b&&e.jsx("span",{className:"data-box data-box-compact data-box-outlined flex-shrink-0",style:Me("indigo"),children:"LOCAL"}),y&&y>1&&e.jsxs("span",{className:"data-box data-box-compact flex-shrink-0",children:["×",y]}),e.jsx("span",{className:"data-box data-box-compact data-box-outlined flex-shrink-0",style:Me(k),children:j}),e.jsxs("span",{className:"hidden min-[520px]:inline type-data-xs text-fg-muted flex-shrink-0",children:[d,"B"]}),e.jsx("div",{className:"flex-1 min-w-0 overflow-hidden",children:E||$?e.jsxs("span",{className:"text-[11px] text-fg-secondary truncate block flex items-center gap-1",children:[$&&e.jsx(ts,{channelName:$,compact:!0,onClick:v&&J?_=>{_.stopPropagation(),v(J)}:void 0}),E&&e.jsx("span",{className:"italic truncate",children:E})]}):e.jsx(es,{path:K,localHash:s})})]}),e.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[e.jsx("span",{className:"data-box data-box-compact",children:It(t.timestamp)}),e.jsx(Oe,{rssi:t.rssi,snr:t.snr,compact:!0,showValues:!0,validated:$e(t)})]})]})]})}function Ya({packet:t,onClick:n,localHash:s,neighbors:a,resolveSource:r,isFlashing:i=!1,isTraceHighlighted:l,traceTag:c,onViewTraceReport:o,dupeGroupPosition:u,isDupeGroupHovered:x=!1,onDupeGroupHover:g,dupeCount:f,getDecodedContent:y,onChannelClick:m}){const{payloadType:v,routeType:T,payloadColor:h,routeColor:N}=ss(t),j=t.packet_origin==="tx_local",C=v==="TRACE",k=f?!1:Ft(t.is_duplicate),b=Ve(t.original_path),A=Ve(t.forwarded_path),U=A.length>0?A:b,W=t._hopCount??U.length,K=t.src_hash?(t.src_hash.startsWith("0x")?t.src_hash.slice(2,6):t.src_hash.slice(0,4)).toUpperCase():null,{name:F,isRepeater:Y}=as(t,r);let D=null,E=null,O=null,$=null;if(v==="GRP_TXT"&&y){const P=y(t);P!=null&&P.decrypted&&(E=P.senderName,O=P.channelName,$=P.channelHash,P.text&&(D=P.text))}else if(v==="TXT_MSG"&&t.raw_packet)try{const P=Gt.fromHex(t.raw_packet);if(P.success&&P.packet){const z=Qt(P.packet.payload);z&&!z.encrypted&&(D=z.text)}}catch{}const J=E||(Y?null:F),M=!!J,H=!M&&Y&&!!F,te=!M&&!H&&v==="GRP_TXT"&&!D,se=t.payload_length??t.length??0,d=t.lbt_attempts??0,Z=()=>{C&&c&&o?o(c):n(t)},q=ue[h]||ue.zinc,le=()=>{if(!u)return{opacity:0};const P=x?1:.4,z=x?"3px":"2px";return u==="first"?{backgroundColor:q,opacity:P,width:z,top:"6px",bottom:0,borderRadius:"0 9999px 0 0"}:u==="middle"?{backgroundColor:q,opacity:P,width:z,top:0,bottom:0,borderRadius:0}:u==="last"?{backgroundColor:q,opacity:P,width:z,top:0,bottom:"6px",borderRadius:"0 0 9999px 0"}:{backgroundColor:q,opacity:P,width:z,top:"6px",bottom:"6px",borderRadius:"9999px"}};return e.jsxs("div",{onClick:Z,className:R("relative pl-3 pr-2.5 py-2 cursor-pointer","active:bg-subtle-fill-hover",k&&"opacity-40",i&&"flash-row",j&&"bg-sys-indigo/5",l&&"bg-sys-teal/10"),children:[e.jsx("div",{className:"absolute left-0 transition-all",style:le()}),e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("div",{className:"relative flex-shrink-0 mt-0.5",children:M?e.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center ring-1 ring-edge-subtle",style:{backgroundColor:Vt(_e(J).cleanName)},children:_e(J).emoji?e.jsx("span",{className:"text-base leading-none",children:_e(J).emoji}):e.jsx("span",{className:"text-white text-[10px] font-bold tracking-tighter",children:Wt(J)})}):H?e.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center ring-[1.5px] ring-sys-blue",children:e.jsx(de,{className:"size-5 text-sys-blue"})}):te?e.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center bg-zinc-500/20 ring-1 ring-edge-subtle",children:e.jsx(Zt,{className:"size-4 text-fg-muted"})}):e.jsx(Jt,{packet:t,variant:"avatar",size:"sm"})}),e.jsxs("div",{className:"flex-1 min-w-0 space-y-0.5",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[M?e.jsx("span",{className:"font-medium text-[14px] text-fg-primary tracking-tight truncate min-w-0",children:J}):H?e.jsx("span",{className:"font-medium text-[14px] text-fg-primary tracking-tight truncate min-w-0",children:F}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"font-semibold text-[14px] text-fg-primary tracking-tight flex-shrink-0",children:K||"—"}),F&&e.jsx("span",{className:"text-[12px] text-fg-muted truncate min-w-0",children:F})]}),e.jsx("div",{className:"flex-1"}),e.jsx("span",{className:"data-box data-box-compact data-box-outlined flex-shrink-0",style:Me(h),children:v}),j&&e.jsx("span",{className:"data-box data-box-compact data-box-outlined flex-shrink-0",style:Me("indigo"),children:"LOCAL"}),e.jsx("span",{className:"data-box data-box-compact data-box-outlined flex-shrink-0",style:Me(N),children:T}),f&&f>1&&e.jsxs("span",{className:"data-box data-box-compact flex-shrink-0",children:["×",f]}),e.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[e.jsx("span",{className:"type-data-xs text-fg-muted w-[28px] text-right",children:t.rssi}),e.jsx(Oe,{rssi:t.rssi,compact:!0,showValues:!1,validated:$e(t)})]})]}),e.jsxs("div",{className:"flex items-center gap-1 type-data-xs text-fg-muted",children:[e.jsx("span",{className:"data-box data-box-compact flex-shrink-0",children:It(t.timestamp)}),se>0&&e.jsxs("span",{children:[se,"B"]}),d>0&&e.jsxs("span",{className:d>1?"text-sys-amber/60":void 0,children:["LBT:",d]}),t.snr!=null&&e.jsxs("span",{children:[t.snr.toFixed(0),"dB"]}),D||O?e.jsxs("span",{className:"text-[11px] text-fg-secondary truncate flex items-center gap-1 min-w-0",children:[O&&e.jsx(ts,{channelName:O,compact:!0,onClick:m&&$?P=>{P.stopPropagation(),m($)}:void 0}),D&&e.jsx("span",{className:"italic truncate",children:D})]}):W>0?e.jsx(es,{path:U,localHash:s}):null]})]})]})]})}const Xa=p.memo(Ka),Za=p.memo(Ya);function Ja(t,n,s,a,r=!1){const i=t.toUpperCase(),l=[],c=s&&Ze(i,s);c&&l.push(s);for(const y of Object.keys(n))Ze(i,y)&&l.push(y);if(r&&c&&s&&l.length===1)return{matches:l,probability:1,bestMatch:s};if(r&&c&&l.length>1){const y=l.filter(m=>m!==s);if(y.length===1)return{matches:l,probability:1,bestMatch:y[0]}}const o=l.length>0?1/l.length:0,u=[...l].sort();let x=null,g=-1;if(u.length===1)x=u[0];else if(u.length>1&&a){for(const y of u){const m=a.get(y),v=m?typeof m=="number"?m:m.combinedScore:0;v>g&&(g=v,x=y)}x||(x=u[0])}else u.length>0&&(x=u[0]);let f=o;if(l.length>1&&a&&g>0){let y=0;for(const m of l){const v=a.get(m);y+=v?typeof v=="number"?v:v.combinedScore:0}y>0&&(f=Math.min(.95,g/y))}return{matches:l,probability:f,bestMatch:x}}function en(t,n,s,a){const i=(s-t)*Math.PI/180,l=(a-n)*Math.PI/180,c=Math.sin(i/2)*Math.sin(i/2)+Math.cos(t*Math.PI/180)*Math.cos(s*Math.PI/180)*Math.sin(l/2)*Math.sin(l/2);return 6371e3*(2*Math.atan2(Math.sqrt(c),Math.sqrt(1-c)))}function tn(t){return t<100?1:t<500?.9:t<1e3?.7:t<5e3?.5:t<1e4?.3:.1}const sn=p.lazy(()=>ps(()=>import("./PathMapMapLibre-B3ia8Mj4.js"),__vite__mapDeps([0,1,2,3,4,5,6])));function an(t,n,s,a,r=!1,i,l,c){const o=fs(n);let u;l&&(u=gs(l,t,{position:c,isLastHop:r}).confidence);const{matches:x,probability:g}=Ja(t,o,a,i,r),f=x.length,y=[],m=t.toUpperCase(),v=s&&s.latitude!==void 0&&s.longitude!==void 0&&(s.latitude!==0||s.longitude!==0);for(const h of x){if(a&&Ze(m,a)&&h===a&&v&&s){y.push({hash:h,name:s.name||"Local Node",latitude:s.latitude,longitude:s.longitude,probability:r?1:g,isLocal:!0});continue}const N=o[h];N!=null&&N.latitude&&(N!=null&&N.longitude)&&!(N.latitude===0&&N.longitude===0)&&y.push({hash:h,name:N.node_name||N.name||"Unknown",latitude:N.latitude,longitude:N.longitude,probability:g,isLocal:!1,isDirectNeighbor:N.zero_hop===!0})}const T=y.length;if(T===1)y[0].probability=u??1;else if(T>1)if(u!==void 0&&u>0){const h=y[0];h.probability=u;const N=1-u,j=T-1;y.slice(1).forEach(C=>{C.probability=N/j})}else{let h=0;const N=y.map(j=>{if(j.isLocal)return{candidate:j,score:1};const C=i==null?void 0:i.get(j.hash);let k=.5;if(v&&s){const A=en(s.latitude,s.longitude,j.latitude,j.longitude);k=tn(A)}let b;return C?b=k*.3+C.hopConsistencyScore*.3+C.frequencyScore*.4:(b=k,j.isDirectNeighbor&&(b=Math.max(b,.8))),h+=b,{candidate:j,score:b}});if(h>0)N.forEach(({candidate:j,score:C})=>{j.probability=Math.min(.95,C/h)});else{const j=1/T;y.forEach(C=>C.probability=j)}}return{candidates:y,totalMatches:f}}function nn(t,n,s,a,r,i){if(!t||t.length===0)return{hops:[],overallConfidence:0,hasValidPath:!1};const l=t.length-1,c=t.map((x,g)=>{const f=g===l,y=t.length-g,{candidates:m,totalMatches:v}=an(x,n,s,a,f,r,i,y),T=m.length>0?Math.max(...m.map(h=>h.probability)):0;return{prefix:x,candidates:m,confidence:T,totalMatches:v}}),o=c.reduce((x,g)=>g.confidence===0?0:x*g.confidence,1),u=c.some(x=>x.candidates.length>0);return{hops:c,overallConfidence:o,hasValidPath:u}}function rn(t){return`${(t*100).toFixed(0)}%`}function ln(t){return t>=1?"text-sys-green":t>=.5?"text-sys-indigo":t>=.25?"text-signal-poor":t>0?"text-sys-red":"text-fg-muted"}function cn(t,n,s){let a;return n===0?a=s.muted:t>=1?a=s.success:t>=.5?a=s.secondary:t>=.25?a=s.poor:t>0?a=s.danger:a=s.muted,{color:a}}class on extends p.Component{constructor(n){super(n),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}render(){return this.state.hasError?e.jsxs("div",{className:"h-[200px] flex items-center justify-center text-fg-muted",children:[e.jsx(et,{className:"w-4 h-4 mr-2"}),"Map failed to load"]}):this.props.children}}function We({path:t,neighbors:n,localNode:s,localHash:a,srcHash:r,dstHash:i,neighborAffinity:l,prefixLookup:c,hubNodes:o,traceSnr:u,advertiserSource:x}){const[g,f]=p.useState(null),y=p.useMemo(()=>{if(!x)return null;const j=x.nodeType==="wardrive";return{prefix:x.prefix||"??",candidates:[{hash:x.publicKey||x.prefix||"source",name:x.name,latitude:x.latitude,longitude:x.longitude,probability:1,isLocal:!1,isWardrive:j}],confidence:1,totalMatches:1,isSource:!0}},[x]),m=p.useMemo(()=>{if(x||!r)return null;const j=De(r),C=n[r];if((C==null?void 0:C.latitude)&&(C==null?void 0:C.longitude)&&!(C.latitude===0&&C.longitude===0))return{prefix:j,candidates:[{hash:r,name:C.node_name||C.name||"Source",latitude:C.latitude,longitude:C.longitude,probability:1,isLocal:!1,isDirectNeighbor:C.zero_hop===!0}],confidence:1,totalMatches:1,isSource:!0};const b=(C==null?void 0:C.node_name)||(C==null?void 0:C.name)||r.slice(0,8);return{prefix:j,candidates:[{hash:r,name:b,latitude:0,longitude:0,probability:1,isLocal:!1}],confidence:1,totalMatches:1,isSource:!0}},[x,r,n]),v=p.useMemo(()=>{const j=i!=null&&i.startsWith("0x")?i.slice(2):i;if((!j||j==="00"||j==="0000000000000000")&&s&&a){const W=De(a),K=s.latitude!==0||s.longitude!==0;return{prefix:W,candidates:[{hash:a,name:s.name||"Local Node",latitude:K?s.latitude:0,longitude:K?s.longitude:0,probability:1,isLocal:!0}],confidence:1,totalMatches:1,isDestination:!0}}if(!i)return null;const k=De(i);if(a&&i===a&&s){const W=s.latitude!==0||s.longitude!==0;return{prefix:k,candidates:[{hash:i,name:s.name||"Local Node",latitude:W?s.latitude:0,longitude:W?s.longitude:0,probability:1,isLocal:!0}],confidence:1,totalMatches:1,isDestination:!0}}const b=n[i];if((b==null?void 0:b.latitude)&&(b==null?void 0:b.longitude)&&!(b.latitude===0&&b.longitude===0))return{prefix:k,candidates:[{hash:i,name:b.node_name||b.name||"Destination",latitude:b.latitude,longitude:b.longitude,probability:1,isLocal:!1,isDirectNeighbor:b.zero_hop===!0}],confidence:1,totalMatches:1,isDestination:!0};const U=(b==null?void 0:b.node_name)||(b==null?void 0:b.name)||i.slice(0,8);return{prefix:k,candidates:[{hash:i,name:U,latitude:0,longitude:0,probability:1,isLocal:!1}],confidence:1,totalMatches:1,isDestination:!0}},[i,n,s,a]),T=p.useMemo(()=>nn(t,n,s,a,l,c),[t,n,s,a,l,c]),h=p.useMemo(()=>{const j=[];y?j.push(y):m&&j.push(m),j.push(...T.hops),v&&j.push(v);const C=j.reduce((b,A)=>A.confidence===0?0:b*A.confidence,1),k=j.some(b=>b.candidates.some(A=>A.latitude!==0||A.longitude!==0));return{hops:j,overallConfidence:C,hasValidPath:k}},[y,m,T,v]),N=p.useMemo(()=>{const j=getComputedStyle(document.documentElement);return{success:j.getPropertyValue("--sys-green").trim()||"#39D98A",secondary:j.getPropertyValue("--sys-indigo").trim()||"#F9D26F",poor:j.getPropertyValue("--signal-poor").trim()||"#FF8A5C",danger:j.getPropertyValue("--sys-red").trim()||"#FF5C7A",muted:j.getPropertyValue("--text-muted").trim()||"#767688"}},[]);return h.hasValidPath?e.jsxs("div",{className:"h-full flex flex-col space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-fg-muted",children:"Path Confidence:"}),e.jsx("span",{className:ln(h.overallConfidence),children:rn(h.overallConfidence)}),e.jsx("button",{className:"text-fg-muted hover:text-fg-secondary transition-colors",title:"Confidence is calculated based on how many known nodes match each path prefix. Multiple matches reduce confidence due to collision probability.",children:e.jsx(Js,{className:"w-3 h-3"})})]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("div",{className:"w-2 h-2 rounded-full bg-sys-green"}),e.jsx("span",{className:"text-fg-muted",children:"Exact"})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("div",{className:"w-2 h-2 rounded-full bg-sys-indigo"}),e.jsx("span",{className:"text-fg-muted",children:"Multi"})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("div",{className:"w-2 h-2 rounded-full bg-fg-muted"}),e.jsx("span",{className:"text-fg-muted",children:"Unknown"})]})]})]}),e.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:e.jsx(on,{children:e.jsx(p.Suspense,{fallback:e.jsx("div",{className:"h-full bg-elevated flex items-center justify-center text-fg-muted text-sm",children:"Loading map..."}),children:e.jsx(sn,{resolvedPath:h,localNode:s,hubNodes:o,hoveredHopIndex:g,onHoverHop:f,traceSnr:u})})})}),e.jsx("div",{className:"flex flex-wrap items-center gap-1.5",children:h.hops.map((j,C)=>{var W,K,F;const k=j.isSource===!0,b=j.isDestination===!0,A=g===C;let U;return k?U=`Source: ${((W=j.candidates[0])==null?void 0:W.name)||"Unknown"}`:b?U=`Destination: ${((K=j.candidates[0])==null?void 0:K.name)||"Unknown"}`:j.totalMatches===0?U="No matching nodes found":j.totalMatches===1?U=`Exact match: ${((F=j.candidates[0])==null?void 0:F.name)||"Unknown"}`:U=`${j.totalMatches} possible matches (${(j.confidence*100).toFixed(0)}% confidence)`,e.jsxs("div",{className:R("flex items-center gap-1 px-1.5 py-0.5 rounded type-data-xs cursor-pointer transition-all",A?"bg-sys-blue/20 ring-1 ring-sys-blue/50":"bg-elevated hover:bg-subtle",k&&"border border-sys-green/30",b&&"border border-sys-blue/30"),title:U,onMouseEnter:()=>f(C),onMouseLeave:()=>f(null),children:[k&&e.jsx("span",{className:"text-sys-green text-[8px] mr-0.5",children:"SRC"}),b&&e.jsx("span",{className:"text-sys-blue text-[8px] mr-0.5",children:"DST"}),e.jsx("span",{style:cn(j.confidence,j.totalMatches,N),children:j.prefix}),!k&&!b&&j.totalMatches>1&&e.jsxs("span",{className:"text-fg-muted",children:["×",j.totalMatches]}),!k&&!b&&j.totalMatches===0&&e.jsx("span",{className:"text-fg-muted",children:"?"})]},C)})})]}):e.jsxs("div",{className:"flex items-center justify-center text-fg-muted text-xs py-4",children:[e.jsx(Ue,{className:"w-3.5 h-3.5 mr-1.5 opacity-50"}),"No location data available for path nodes"]})}const Ye=16;function Ge(t){return t.match(/.{1,2}/g)||[]}function je(t){return t!==null&&t.startsWith("payload:")}const Te={hexRestOpacity:15,cardRestBg:"color-mix(in srgb, var(--elevated) 60%, var(--body))",cardRestShadow:` - inset 0 0 0 1px color-mix(in srgb, var(--fg-primary) 6%, transparent), - inset 0 1px 0 color-mix(in srgb, white 3%, transparent), - 0 1px 2px color-mix(in srgb, black 5%, transparent) - `,selectionBorderWidth:2},at={type:"tween",duration:.25,ease:[.25,.1,.25,1]};function dn(t,n){return t?`inset 0 0 0 ${Te.selectionBorderWidth}px ${ue[n]}`:Te.cardRestShadow}function xn(t,n){return t?n:`color-mix(in srgb, ${n} ${Te.hexRestOpacity}%, transparent)`}function mn({segments:t,selectedSegment:n,onSegmentClick:s}){const[a,r]=p.useState(null),[i,l]=p.useState(null),c=t.some(x=>x.id!==void 0)&&s,o=[];for(const x of t){const g=Ge(x.hex);for(const f of g)o.push({byte:f.toUpperCase(),color:x.color,id:x.id})}const u=[];for(let x=0;x{const f=x.length{const h=T===x.length-1,N=f&&h,j=ue[m],b=(v?a===v:i===m)||!!(v&&n===v);return e.jsx("span",{className:`w-[1.75rem] text-xs text-center py-0.5 font-mono select-text ${c?"cursor-pointer":""}`,style:{backgroundColor:xn(b,j),color:b?"rgba(255,255,255,0.95)":j,transition:b?"none":"background-color 0.15s ease-out, color 0.15s ease-out",touchAction:"manipulation",...N?{borderRadius:"0 0.375rem 0.375rem 0"}:{}},onMouseEnter:()=>{v?r(v):l(m)},onMouseLeave:()=>{r(null),l(null)},onClick:()=>v&&(s==null?void 0:s(v)),onTouchStart:()=>{v?r(v):l(m)},onTouchEnd:()=>{r(null),l(null)},children:y},T)})},g)})})}function hn({rawHex:t,hexSegments:n,selectedSegment:s,onSegmentClick:a}){const[r,i]=p.useState(!1),l=p.useCallback(async()=>{try{await navigator.clipboard.writeText(t.toUpperCase()),i(!0),setTimeout(()=>i(!1),2e3)}catch(c){console.error("Failed to copy:",c)}},[t]);return e.jsxs("div",{className:"bg-black rounded-2xl p-6 relative",children:[e.jsx(mn,{segments:n,selectedSegment:s,onSegmentClick:a}),e.jsx("button",{onClick:l,className:"absolute bottom-3 right-3 flex items-center gap-1.5 px-2.5 py-1.5 rounded-lg bg-subtle-fill-hover hover:bg-subtle-fill-strong text-fg-muted hover:text-fg-secondary transition-all text-xs font-sans",title:"Copy raw packet hex",children:r?e.jsxs(e.Fragment,{children:[e.jsx(bs,{className:"w-3.5 h-3.5 text-sys-green"}),e.jsx("span",{className:"text-sys-green",children:"Copied"})]}):e.jsxs(e.Fragment,{children:[e.jsx(it,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"Copy"})]})})]})}function un(t,n){const s=[];let a=0;const r=n.slice(0,64);s.push({id:"payload:publicKey",title:"Public Key",color:"pink",hex:r,startByte:a,endByte:a+31,decoded:e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-[11px] text-fg-secondary break-all p-2 rounded bg-body/50 font-mono",children:t.publicKey.toUpperCase()}),e.jsx("p",{className:"text-xs text-fg-muted mt-1",children:"Ed25519 public key (32 bytes)"})]})}),a+=32;const i=n.slice(64,72);s.push({id:"payload:timestamp",title:"Timestamp",color:"orange",hex:i,startByte:a,endByte:a+3,decoded:e.jsxs(e.Fragment,{children:[e.jsx(X,{size:"standard",copy:!0,children:i.toUpperCase()}),e.jsxs("p",{className:"text-xs text-fg-primary mt-1",children:[t.timestamp," (",ie(t.timestamp),")"]})]})}),a+=4;const l=n.slice(72,200);s.push({id:"payload:signature",title:"Signature",color:"teal",hex:l,startByte:a,endByte:a+63,decoded:e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-[11px] text-fg-secondary break-all p-2 rounded bg-body/50 font-mono",children:t.signature.toUpperCase()}),e.jsx("p",{className:"text-xs text-fg-muted mt-1",children:"Ed25519 signature (64 bytes)"})]})}),a+=64;const c=n.slice(200,202);if(s.push({id:"payload:flags",title:"Flags",color:"blue",hex:c,startByte:a,endByte:a,decoded:e.jsxs(e.Fragment,{children:[e.jsxs(X,{size:"standard",copy:!0,children:["0x",t.flags.toString(16).padStart(2,"0").toUpperCase()]}),e.jsx("p",{className:"text-xs text-fg-primary mt-1",children:t.flagsDescription}),e.jsxs("p",{className:"text-xs text-fg-muted",children:["Node Type: ",t.nodeType]})]})}),a+=1,t.latitude!==void 0){const o=n.slice(a*2,a*2+8);s.push({id:"payload:latitude",title:"Latitude",color:"green",hex:o,startByte:a,endByte:a+3,decoded:e.jsxs(e.Fragment,{children:[e.jsx(X,{size:"standard",copy:!0,children:o.toUpperCase()}),e.jsxs("p",{className:"text-xs text-fg-primary mt-1",children:[t.latitude.toFixed(6),"°"]})]})}),a+=4}if(t.longitude!==void 0){const o=n.slice(a*2,a*2+8);s.push({id:"payload:longitude",title:"Longitude",color:"indigo",hex:o,startByte:a,endByte:a+3,decoded:e.jsxs(e.Fragment,{children:[e.jsx(X,{size:"standard",copy:!0,children:o.toUpperCase()}),e.jsxs("p",{className:"text-xs text-fg-primary mt-1",children:[t.longitude.toFixed(6),"°"]})]})}),a+=4}if(t.name){const o=n.slice(a*2),u=o.length/2;s.push({id:"payload:name",title:"Name",color:"amber",hex:o,startByte:a,endByte:a+u-1,decoded:e.jsxs(e.Fragment,{children:[e.jsx(X,{size:"standard",copy:!0,children:o.toUpperCase()}),e.jsxs("p",{className:"text-xs text-fg-primary mt-1",children:['"',t.name,'"']})]})})}return s}function pn(t,n){return[{id:"payload:crc",title:"CRC",color:"green",hex:n.slice(0,8),startByte:0,endByte:3,decoded:e.jsxs(e.Fragment,{children:[e.jsxs(X,{size:"standard",copy:!0,children:["0x",t.crc]}),e.jsx("p",{className:"text-xs text-fg-muted mt-1",children:"CRC32 of acknowledged packet"})]})}]}function fn(t,n){const s=[];s.push({id:"payload:channelHash",title:"Channel Hash",color:"blue",hex:n.slice(0,2),startByte:0,endByte:0,decoded:e.jsxs(e.Fragment,{children:[e.jsxs(X,{size:"standard",copy:!0,children:["0x",t.channelHash]}),t.channelName&&e.jsxs("p",{className:"text-xs text-fg-primary mt-1",children:["Channel: ",t.channelName]})]})}),t.macHex&&s.push({id:"payload:mac",title:"MAC",color:"indigo",hex:n.slice(2,6),startByte:1,endByte:2,decoded:e.jsxs(e.Fragment,{children:[e.jsx(X,{size:"standard",copy:!0,children:t.macHex.toUpperCase()}),e.jsx("p",{className:"text-xs text-fg-muted mt-1",children:"Truncated HMAC-SHA256"})]})});const a=n.slice(6);return a&&s.push({id:"payload:ciphertext",title:t.decrypted?"Message":"Ciphertext",color:t.decrypted?"green":"zinc",hex:a,startByte:3,endByte:3+a.length/2-1,decoded:t.decrypted?e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"text-sm text-fg-primary",children:['"',t.text,'"']}),t.senderName&&e.jsxs("p",{className:"text-xs text-fg-muted mt-1",children:["From: ",t.senderName]})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-[11px] text-fg-secondary break-all p-2 rounded bg-body/50 font-mono",children:a.toUpperCase()}),e.jsx("p",{className:"text-xs text-fg-muted mt-1",children:"AES-128-ECB encrypted"})]})}),s}function gn(t,n){const s=[];s.push({id:"payload:channelHash",title:"Channel Hash",color:"blue",hex:n.slice(0,2),startByte:0,endByte:0,decoded:e.jsxs(e.Fragment,{children:[e.jsxs(X,{size:"standard",copy:!0,children:["0x",t.channelHash]}),t.channelName&&e.jsxs("p",{className:"text-xs text-fg-primary mt-1",children:["Channel: ",t.channelName]})]})}),t.macHex&&s.push({id:"payload:mac",title:"MAC",color:"indigo",hex:n.slice(2,6),startByte:1,endByte:2,decoded:e.jsxs(e.Fragment,{children:[e.jsx(X,{size:"standard",copy:!0,children:t.macHex.toUpperCase()}),e.jsx("p",{className:"text-xs text-fg-muted mt-1",children:"Truncated HMAC-SHA256"})]})});const a=n.slice(6);return a&&s.push({id:"payload:ciphertext",title:t.decrypted?"Decrypted Data":"Encrypted Data",color:t.decrypted?"green":"zinc",hex:a,startByte:3,endByte:3+a.length/2-1,decoded:e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-[11px] text-fg-secondary break-all p-2 rounded bg-body/50 font-mono",children:(t.decryptedHex||a).toUpperCase()}),e.jsxs("p",{className:"text-xs text-fg-muted mt-1",children:[t.dataLength," bytes",t.decrypted?"":" (AES-128-ECB encrypted)"]})]})}),s}function yn(t,n){const s=[];if(s.push({id:"payload:pathLength",title:"Path Length",color:"blue",hex:n.slice(0,2),startByte:0,endByte:0,decoded:e.jsxs(e.Fragment,{children:[e.jsx(X,{size:"standard",children:t.pathLength}),e.jsxs("p",{className:"text-xs text-fg-muted mt-1",children:[t.pathLength," hop",t.pathLength!==1?"s":""]})]})}),t.path.length>0){const a=n.slice(2,2+t.pathLength*2);s.push({id:"payload:path",title:"Path Hops",color:"amber",hex:a,startByte:1,endByte:t.pathLength,decoded:e.jsx(e.Fragment,{children:e.jsx("div",{className:"flex flex-wrap items-center gap-1",children:t.path.map((r,i)=>e.jsxs("span",{className:"flex items-center gap-1",children:[i>0&&e.jsx(pe,{className:"w-3 h-3 text-fg-muted"}),e.jsx(B,{color:"amber",className:"font-mono",children:r})]},i))})})})}if(t.extraType!=null){const a=1+t.pathLength;s.push({id:"payload:extraType",title:"Extra Type",color:"indigo",hex:n.slice(a*2,a*2+2),startByte:a,endByte:a,decoded:e.jsxs(e.Fragment,{children:[e.jsx(X,{size:"standard",children:t.extraTypeName??`0x${t.extraType.toString(16).padStart(2,"0")}`}),e.jsx("p",{className:"text-xs text-fg-muted mt-1",children:"Bundled payload type"})]})})}if(t.extraData){const a=1+t.pathLength+1,r=n.slice(a*2);r&&s.push({id:"payload:extraData",title:"Extra Data",color:"indigo",hex:r,startByte:a,endByte:a+r.length/2-1,decoded:e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-[11px] text-fg-secondary break-all p-2 rounded bg-body/50 font-mono",children:r.toUpperCase()}),e.jsxs("p",{className:"text-xs text-fg-muted mt-1",children:[r.length/2," bytes"]})]})})}return s}function jn(t,n){const s=[];s.push({id:"payload:crc",title:"Trace Tag",color:"blue",hex:n.slice(0,8),startByte:0,endByte:3,decoded:e.jsxs(e.Fragment,{children:[e.jsxs(X,{size:"standard",copy:!0,children:["0x",t.traceTag]}),e.jsx("p",{className:"text-xs text-fg-muted mt-1",children:"Unique trace request identifier"})]})}),s.push({id:"payload:mac",title:"Auth Code",color:"indigo",hex:n.slice(8,16),startByte:4,endByte:7,decoded:e.jsxs(e.Fragment,{children:[e.jsx(X,{size:"standard",copy:!0,children:t.authCode}),e.jsx("p",{className:"text-xs text-fg-muted mt-1",children:"Authentication/verification code"})]})}),s.push({id:"payload:flags",title:"Flags",color:"amber",hex:n.slice(16,18),startByte:8,endByte:8,decoded:e.jsxs(e.Fragment,{children:[e.jsxs(X,{size:"standard",copy:!0,children:["0x",t.flags.toString(16).toUpperCase().padStart(2,"0")]}),e.jsx("p",{className:"text-xs text-fg-muted mt-1",children:t.flags===0?"No flags set":`Flags: ${t.flags.toString(2).padStart(8,"0")}b`})]})});const a=n.slice(18);return a&&s.push({id:"payload:path",title:"Target Path",color:"indigo",hex:a,startByte:9,endByte:9+a.length/2-1,decoded:e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex flex-wrap items-center gap-1",children:t.pathHashes.map((r,i)=>{const l=t.snrValues[i],c=l!==void 0?qs(l):"zinc";return e.jsxs("span",{className:"flex items-center gap-1",children:[i>0&&e.jsx(pe,{className:"w-3 h-3 text-fg-muted"}),e.jsx(B,{color:"indigo",className:"font-mono",children:r}),l!==void 0&&e.jsxs(B,{color:c,className:"font-mono",children:[l>=0?"+":"",Number.isInteger(l)?l:l.toFixed(1),"dB"]})]},i)})}),e.jsxs("p",{className:"text-xs text-fg-muted mt-1",children:[t.pathHashes.length," target ",t.pathHashes.length===1?"hop":"hops",t.snrValues.length>0&&` • ${t.snrValues.length} SNR ${t.snrValues.length===1?"value":"values"} collected`,t.isComplete&&" • ✓ Complete"]})]})}),s}function bn(t,n){const s=[];s.push({id:"payload:msgId",title:"Message ID",color:"blue",hex:n.slice(0,4),startByte:0,endByte:1,decoded:e.jsxs(e.Fragment,{children:[e.jsx(X,{size:"standard",copy:!0,children:t.messageId.toUpperCase()}),e.jsx("p",{className:"text-xs text-fg-muted mt-1",children:"Unique message identifier"})]})}),s.push({id:"payload:partNum",title:"Part Number",color:"amber",hex:n.slice(4,6),startByte:2,endByte:2,decoded:e.jsxs(e.Fragment,{children:[e.jsx(X,{size:"standard",copy:!0,children:t.partNumber}),e.jsx("p",{className:"text-xs text-fg-muted mt-1",children:"0-indexed part number"})]})}),s.push({id:"payload:totalParts",title:"Total Parts",color:"orange",hex:n.slice(6,8),startByte:3,endByte:3,decoded:e.jsxs(e.Fragment,{children:[e.jsx(X,{size:"standard",copy:!0,children:t.totalParts}),e.jsxs("p",{className:"text-xs text-fg-muted mt-1",children:["Part ",t.partNumber+1," of ",t.totalParts]})]})});const a=n.slice(8);return a&&s.push({id:"payload:partData",title:"Part Data",color:"cyan",hex:a,startByte:4,endByte:4+a.length/2-1,decoded:e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-[11px] text-fg-secondary break-all p-2 rounded bg-body/50 font-mono",children:a.toUpperCase()}),e.jsxs("p",{className:"text-xs text-fg-muted mt-1",children:[a.length/2," bytes"]})]})}),s}function Nn(t,n){switch(t.type){case"advert":return un(t,n);case"ack":return pn(t,n);case"grp_txt":return fn(t,n);case"grp_data":return gn(t,n);case"path":return yn(t,n);case"trace":return jn(t,n);case"multipart":return bn(t,n);default:return[{id:"payload:ciphertext",title:"Raw Data",color:"zinc",hex:n,startByte:0,endByte:n.length/2-1,decoded:e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-[11px] text-fg-secondary break-all p-2 rounded bg-body/50 font-mono",children:n.toUpperCase()}),e.jsxs("p",{className:"text-xs text-fg-muted mt-1",children:[n.length/2," bytes"]})]})}]}}function vn(t){return t.map(n=>({id:n.id,hex:n.hex,color:n.color}))}function wn({bits:t,field:n,value:s,binary:a}){const r=()=>{if(n==="Payload Type"){const i=Be[s]||"zinc";return e.jsx(B,{color:i,children:s})}if(n==="Route Type"){const i=He[s]||"zinc";return e.jsx(B,{color:i,children:s})}return e.jsx("span",{className:"text-sm text-fg-primary",children:s})};return e.jsxs("tr",{children:[e.jsx("td",{className:"py-1.5 text-xs text-fg-muted tabular-nums",children:t}),e.jsx("td",{className:"py-1.5 text-sm text-fg-secondary",children:n}),e.jsx("td",{className:"py-1.5",children:r()}),e.jsx("td",{className:"py-1.5 type-data-xs text-sys-cyan",children:a})]})}function Ct({id:t,title:n,color:s,hexBytes:a,startByte:r,endByte:i,isSelected:l,children:c}){const o=a?Ge(a):[];return e.jsxs(oe.div,{layout:"position",layoutId:t,transition:at,className:"w-full min-w-0 overflow-hidden rounded-xl p-4 sm:p-5 space-y-4",style:{backgroundColor:Te.cardRestBg,boxShadow:dn(l,s)},children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-0.5 min-w-0",children:[e.jsx(B,{color:s,children:n}),o.length>0&&o.length<=16&&o.map((u,x)=>e.jsx(B,{color:s,className:"font-mono",children:u.toUpperCase()},x))]}),e.jsxs("span",{className:"type-data-xs text-fg-muted flex-shrink-0",children:["Bytes ",r,"-",i]})]}),e.jsx("div",{className:"min-w-0 overflow-hidden",children:c})]})}function kn({advert:t,timestamp:n}){const s=n?ie(n):ie(t.timestamp);return e.jsx("div",{className:"mb-4",children:e.jsxs("div",{className:"rounded-2xl overflow-hidden bg-sys-indigo/10",style:{backdropFilter:"blur(20px)",WebkitBackdropFilter:"blur(20px)"},children:[e.jsxs("div",{className:"px-4 pt-4 pb-3 flex items-center gap-3",children:[e.jsx("div",{className:"w-12 h-12 rounded-xl flex items-center justify-center shadow-lg",style:{background:"linear-gradient(135deg, var(--sys-indigo) 0%, var(--sys-blue) 100%)"},children:e.jsx(de,{className:"w-6 h-6 text-white"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"text-lg font-semibold text-fg-primary font-sans truncate leading-tight",children:t.name||"Unknown Node"}),e.jsx("p",{className:"text-sm text-fg-muted font-sans mt-0.5",children:t.nodeType})]})]}),e.jsx("div",{className:"mx-4 border-t border-edge-subtle"}),e.jsxs("div",{className:"px-4 py-3 space-y-2",children:[t.latitude!==void 0&&t.longitude!==void 0&&e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Ue,{className:"w-4 h-4 text-sys-indigo flex-shrink-0"}),e.jsxs("span",{className:"text-sm text-fg-secondary font-mono",children:[t.latitude.toFixed(5),"°, ",t.longitude.toFixed(5),"°"]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(xe,{className:"w-4 h-4 text-sys-indigo flex-shrink-0"}),e.jsx("span",{className:"text-sm text-fg-secondary font-sans",children:s})]})]})]})})}function Cn({decoded:t,timestamp:n}){const s=n?ie(n):"Unknown";return e.jsx("div",{className:"mb-4",children:e.jsxs("div",{className:"rounded-2xl overflow-hidden bg-sys-teal/10",style:{backdropFilter:"blur(20px)",WebkitBackdropFilter:"blur(20px)"},children:[e.jsxs("div",{className:"px-4 pt-4 pb-3 flex items-center gap-3",children:[e.jsx("div",{className:"w-12 h-12 rounded-xl flex items-center justify-center shadow-lg",style:{background:"linear-gradient(135deg, var(--sys-teal) 0%, var(--sys-cyan) 100%)"},children:e.jsx(aa,{className:"w-6 h-6 text-white"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"text-lg font-semibold text-fg-primary font-sans truncate leading-tight",children:t.channelName||"Channel Data"}),e.jsxs("p",{className:"text-sm text-fg-muted font-sans mt-0.5",children:[t.dataLength," bytes • ",t.decrypted?"Decrypted":"Encrypted"]})]})]}),e.jsx("div",{className:"mx-4 border-t border-edge-subtle"}),e.jsxs("div",{className:"px-4 py-3 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Kt,{className:"w-4 h-4 text-sys-teal flex-shrink-0"}),e.jsxs("span",{className:"text-sm text-fg-secondary font-sans",children:["Channel: ",e.jsxs("span",{className:"font-mono",children:["0x",t.channelHash]})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(xe,{className:"w-4 h-4 text-sys-teal flex-shrink-0"}),e.jsx("span",{className:"text-sm text-fg-secondary font-sans",children:s})]}),t.decrypted&&t.decryptedHex&&e.jsxs("div",{className:"mt-2 pt-2 border-t border-edge-subtle",children:[e.jsx("p",{className:"type-micro text-fg-muted mb-1 font-sans",children:"Decrypted Data"}),e.jsx("div",{className:"max-w-full overflow-x-auto",children:e.jsx(X,{size:"compact",copy:!0,className:"inline-block",children:e.jsx("span",{className:"break-all text-xs",children:t.decryptedHex.toUpperCase()})})})]})]})]})})}function Sn({decoded:t,timestamp:n,isLoading:s=!1,onDecrypted:a}){const r=n?ie(n):"Unknown",[i,l]=p.useState(""),[c,o]=p.useState(!1),[u,x]=p.useState(null),[g,f]=p.useState(!1),y=p.useCallback(async()=>{if(!(!i.trim()||!t.ciphertextHex||!t.macHex)){o(!0),x(null);try{const m=parseInt(t.channelHash,16),v=ut(t.macHex),T=ut(t.ciphertextHex),h=await vs(i.trim(),m,v,T);if(h.success){const N=h.result.plaintext,j=new TextDecoder("utf-8",{fatal:!1}).decode(N.slice(5)),C=j.indexOf(": "),k={...t,channelName:h.result.channelName,decrypted:!0,timestamp:N[0]|N[1]<<8|N[2]<<16|N[3]<<24,flags:N[4],senderName:C>0?j.slice(0,C):void 0,text:C>0?j.slice(C+2):j};a==null||a(k),l(""),f(!1)}else x(h.error)}catch(m){x(m instanceof Error?m.message:"Unknown error")}finally{o(!1)}}},[i,t,a]);return s?e.jsx("div",{className:"mb-4",children:e.jsxs("div",{className:"rounded-xl p-4 sm:p-5",style:{backgroundColor:"color-mix(in srgb, var(--elevated) 60%, var(--body))",boxShadow:` - inset 0 0 0 1px color-mix(in srgb, var(--fg-primary) 6%, transparent), - inset 0 1px 0 color-mix(in srgb, white 3%, transparent), - 0 1px 2px color-mix(in srgb, black 5%, transparent) - `},children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3 h-[15px]",children:[e.jsx("div",{className:"h-2.5 w-12 rounded bg-subtle-fill-hover animate-pulse"}),e.jsx("div",{className:"h-2.5 w-16 rounded bg-subtle-fill-hover animate-pulse"})]}),e.jsx("div",{className:"inline-block max-w-[85%] px-3.5 py-2 rounded-2xl rounded-tl-md",style:{background:"color-mix(in srgb, var(--sys-blue) 30%, transparent)"},children:e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("div",{className:"h-3.5 w-48 rounded bg-subtle-fill-strong animate-pulse"}),e.jsx("div",{className:"h-3.5 w-32 rounded bg-subtle-fill-strong animate-pulse"})]})})]})}):t.decrypted?e.jsx("div",{className:"mb-4",children:e.jsxs("div",{className:"rounded-xl p-4 sm:p-5",style:{backgroundColor:"color-mix(in srgb, var(--elevated) 60%, var(--body))",boxShadow:` - inset 0 0 0 1px color-mix(in srgb, var(--fg-primary) 6%, transparent), - inset 0 1px 0 color-mix(in srgb, white 3%, transparent), - 0 1px 2px color-mix(in srgb, black 5%, transparent) - `},children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[t.senderName&&e.jsxs("span",{className:"text-[11px] text-fg-muted font-sans",children:["From ",e.jsx("span",{className:"text-fg-secondary font-medium",children:t.senderName})]}),t.channelName&&e.jsxs("span",{className:"text-[11px] text-fg-muted font-sans",children:["in ",e.jsx("span",{className:"text-sys-cyan font-medium",children:t.channelName})]})]}),e.jsx("div",{className:"inline-block max-w-[85%] px-3.5 py-2 rounded-2xl rounded-tl-md",style:{background:"linear-gradient(135deg, var(--sys-blue) 0%, color-mix(in srgb, var(--sys-blue) 85%, var(--sys-cyan)) 100%)"},children:e.jsx("p",{className:"text-sm text-white font-sans leading-relaxed whitespace-pre-wrap break-words",children:t.text})})]})}):e.jsx("div",{className:"mb-4",children:e.jsxs("div",{className:"rounded-2xl overflow-hidden bg-zinc-500/10",style:{backdropFilter:"blur(20px)",WebkitBackdropFilter:"blur(20px)"},children:[e.jsxs("div",{className:"px-4 pt-4 pb-3 flex items-center gap-3",children:[e.jsx("div",{className:"w-12 h-12 rounded-xl flex items-center justify-center shadow-lg",style:{background:"linear-gradient(135deg, var(--zinc-500) 0%, color-mix(in srgb, var(--zinc-500) 70%, black) 100%)"},children:e.jsx(ot,{className:"w-6 h-6 text-white"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"text-lg font-semibold text-fg-primary font-sans truncate leading-tight",children:t.isPublicHashChannel?"Public Hash Channel":"Encrypted Message"}),e.jsxs("p",{className:"text-sm text-fg-muted font-sans mt-0.5",children:["Channel hash: ",e.jsxs("span",{className:"font-mono",children:["0x",t.channelHash]})]})]})]}),e.jsx("div",{className:"mx-4 border-t border-edge-subtle"}),e.jsxs("div",{className:"px-4 py-3 space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(xe,{className:"w-4 h-4 text-zinc-400 flex-shrink-0"}),e.jsx("span",{className:"text-sm text-fg-secondary font-sans",children:r})]}),t.ciphertextHex&&t.macHex&&e.jsx("div",{className:"space-y-2",children:g?e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",value:i,onChange:m=>l(m.target.value),placeholder:"Channel name (e.g. south-bay)",className:"flex-1 px-3 py-1.5 text-sm rounded-lg bg-subtle-fill-strong border border-edge-subtle text-fg-primary placeholder:text-fg-muted focus:outline-none focus:border-zinc-500",onKeyDown:m=>m.key==="Enter"&&y(),disabled:c}),e.jsx("button",{onClick:y,disabled:c||!i.trim(),className:"px-3 py-1.5 text-sm font-medium rounded-lg bg-zinc-600 hover:bg-zinc-500 text-white disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:c?"Testing...":"Try"}),e.jsx("button",{onClick:()=>{f(!1),x(null),l("")},className:"px-2 py-1.5 text-sm rounded-lg hover:bg-subtle-fill-strong text-fg-muted transition-colors",children:"×"})]}),u&&e.jsx("p",{className:"text-xs text-sys-red",children:u})]}):e.jsx("button",{onClick:()=>f(!0),className:"text-xs text-zinc-400 hover:text-zinc-300 underline underline-offset-2 transition-colors",children:"Know the channel name? Try to decrypt"})}),!g&&e.jsx("p",{className:"text-xs text-fg-muted",children:t.isPublicHashChannel?"Public hash channel message. Key not in common channel list.":"Unknown hash channel. Channel name required for decryption."})]})]})})}function _n({decoded:t,timestamp:n}){const s=n?ie(n):"Unknown";return e.jsxs("div",{className:"mb-4 flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl flex items-center justify-center shadow-md",style:{background:"linear-gradient(135deg, var(--sys-green) 0%, var(--sys-teal) 100%)"},children:e.jsx(sa,{className:"w-5 h-5 text-white"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-semibold text-fg-primary font-sans",children:"Acknowledgment"}),e.jsxs("p",{className:"text-xs text-fg-muted font-sans mt-0.5",children:["CRC: ",e.jsxs("span",{className:"font-mono text-sys-green",children:["0x",t.crc]})," · ",s]})]})]})}function Mn({decoded:t,timestamp:n}){const s=n?ie(n):"Unknown",a=t.path.length;return e.jsx("div",{className:"mb-4",children:e.jsxs("div",{className:"rounded-2xl overflow-hidden bg-sys-amber/10",style:{backdropFilter:"blur(20px)",WebkitBackdropFilter:"blur(20px)"},children:[e.jsxs("div",{className:"px-4 pt-4 pb-3 flex items-center gap-3",children:[e.jsx("div",{className:"w-12 h-12 rounded-xl flex items-center justify-center shadow-lg",style:{background:"linear-gradient(135deg, var(--sys-amber) 0%, var(--sys-orange) 100%)"},children:e.jsx(Ma,{className:"w-6 h-6 text-white"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"text-lg font-semibold text-fg-primary font-sans truncate leading-tight",children:"Path Response"}),e.jsxs("p",{className:"text-sm text-fg-muted font-sans mt-0.5",children:[a," ",a===1?"hop":"hops"]})]})]}),e.jsx("div",{className:"mx-4 border-t border-edge-subtle"}),e.jsxs("div",{className:"px-4 py-3 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(xe,{className:"w-4 h-4 text-sys-amber flex-shrink-0"}),e.jsx("span",{className:"text-sm text-fg-secondary font-sans",children:s})]}),t.path.length>0&&e.jsx("div",{className:"mt-2 pt-2 border-t border-edge-subtle",children:e.jsx("div",{className:"flex flex-wrap items-center gap-2",children:t.path.map((r,i)=>e.jsxs("div",{className:"flex items-center gap-2",children:[i>0&&e.jsx(pe,{className:"w-4 h-4 text-sys-amber"}),e.jsx(B,{color:"amber",className:"font-mono",children:r})]},i))})})]})]})})}function Tn({decoded:t,timestamp:n}){const s=n?ie(n):"Unknown",a=t.pathHashes.length,r=t.snrValues.length,i=l=>l>=7?"green":l>=0?"yellow":l>=-5?"orange":"red";return e.jsx("div",{className:"mb-4",children:e.jsxs("div",{className:"rounded-2xl overflow-hidden bg-sys-blue/10",style:{backdropFilter:"blur(20px)",WebkitBackdropFilter:"blur(20px)"},children:[e.jsxs("div",{className:"px-4 pt-4 pb-3 flex items-center gap-3",children:[e.jsx("div",{className:"w-12 h-12 rounded-xl flex items-center justify-center shadow-lg",style:{background:"linear-gradient(135deg, var(--sys-blue) 0%, var(--sys-indigo) 100%)"},children:e.jsx(ta,{className:"w-6 h-6 text-white"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("h3",{className:"text-lg font-semibold text-fg-primary font-sans truncate leading-tight",children:["Trace ",t.isComplete?"Complete":"In Progress"]}),e.jsxs("p",{className:"text-sm text-fg-muted mt-0.5",children:["Tag: 0x",t.traceTag.slice(0,8),t.isComplete&&" • ✓"]})]})]}),e.jsx("div",{className:"mx-4 border-t border-edge-subtle"}),e.jsxs("div",{className:"px-4 py-3 space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(xe,{className:"w-4 h-4 text-sys-blue flex-shrink-0"}),e.jsx("span",{className:"text-sm text-fg-secondary",children:s})]}),e.jsxs("div",{className:"flex items-center gap-4 text-xs text-fg-muted",children:[e.jsxs("span",{children:[a," target ",a===1?"hop":"hops"]}),e.jsx("span",{children:"•"}),e.jsxs("span",{children:[r," SNR ",r===1?"sample":"samples"]}),t.authCode!==0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"•"}),e.jsxs("span",{children:["Auth: ",t.authCode]})]})]}),t.pathHashes.length>0&&e.jsx("div",{className:"flex flex-wrap items-center gap-2 pt-1",children:t.pathHashes.map((l,c)=>{const o=t.snrValues[c],u=o!==void 0?i(o):"zinc",x=o!==void 0;return e.jsxs("div",{className:"flex items-center gap-2",children:[c>0&&e.jsx(pe,{className:"w-4 h-4 text-sys-blue flex-shrink-0"}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(B,{color:x?"blue":"zinc",className:"font-mono",children:l}),x&&e.jsxs(B,{color:u,className:"font-mono",children:[o>=0?"+":"",Number.isInteger(o)?o:o.toFixed(1),"dB"]})]})]},c)})})]})]})})}function Pn({decoded:t,timestamp:n}){const s=n?ie(n):"Unknown";return t.encrypted?e.jsxs("div",{className:"mb-4 flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl flex items-center justify-center shadow-md",style:{background:"linear-gradient(135deg, var(--sys-indigo) 0%, var(--sys-blue) 100%)"},children:e.jsx(ot,{className:"w-5 h-5 text-white"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-semibold text-fg-primary font-sans",children:"Encrypted Message"}),e.jsxs("p",{className:"text-xs text-fg-muted font-sans mt-0.5",children:[t.srcHash," → ",t.destHash," · ",s]})]})]}):e.jsxs("div",{className:"mb-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1.5 px-1",children:[e.jsxs("span",{className:"text-[11px] text-fg-muted font-sans",children:[e.jsx("span",{className:"font-mono text-fg-secondary",children:t.srcHash})," → ",e.jsx("span",{className:"font-mono text-fg-secondary",children:t.destHash})]}),e.jsxs("span",{className:"text-[11px] text-fg-muted font-sans",children:["· ",s]})]}),e.jsx("div",{className:"inline-block max-w-[85%] px-3.5 py-2 rounded-2xl rounded-tr-md ml-auto",style:{background:"linear-gradient(135deg, var(--sys-green) 0%, var(--sys-teal) 100%)"},children:e.jsx("p",{className:"text-sm text-white font-sans leading-relaxed whitespace-pre-wrap break-words",children:t.text})})]})}function Bn({decoded:t,timestamp:n}){const s=n?ie(n):"Unknown",a=(t.partNumber+1)/t.totalParts*100;return e.jsx("div",{className:"mb-4",children:e.jsxs("div",{className:"rounded-2xl overflow-hidden bg-sys-yellow/10",style:{backdropFilter:"blur(20px)",WebkitBackdropFilter:"blur(20px)"},children:[e.jsxs("div",{className:"px-4 pt-4 pb-3 flex items-center gap-3",children:[e.jsx("div",{className:"w-12 h-12 rounded-xl flex items-center justify-center shadow-lg",style:{background:"linear-gradient(135deg, var(--sys-yellow) 0%, var(--sys-amber) 100%)"},children:e.jsx(ea,{className:"w-6 h-6 text-white"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"text-lg font-semibold text-fg-primary font-sans truncate leading-tight",children:"Multipart Segment"}),e.jsxs("p",{className:"text-sm text-fg-muted font-sans mt-0.5",children:["Part ",t.partNumber+1," of ",t.totalParts]})]})]}),e.jsx("div",{className:"mx-4 border-t border-edge-subtle"}),e.jsxs("div",{className:"px-4 py-3 space-y-3",children:[e.jsx("div",{children:e.jsx("div",{className:"h-2 bg-subtle-fill-strong rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${a}%`,background:"linear-gradient(90deg, var(--sys-yellow), var(--sys-amber))"}})})}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Kt,{className:"w-4 h-4 text-sys-yellow flex-shrink-0"}),e.jsxs("span",{className:"text-sm text-fg-secondary font-sans",children:["Message ID: ",e.jsx("span",{className:"font-mono",children:t.messageId})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(xe,{className:"w-4 h-4 text-sys-yellow flex-shrink-0"}),e.jsx("span",{className:"text-sm text-fg-secondary font-sans",children:s})]})]})]})})}function Ln({decoded:t,timestamp:n,payloadType:s}){const a=n?ie(n):"Unknown",i=(()=>{switch(s){case re.REQ:return{icon:ws,gradient:"var(--sys-orange), var(--sys-red)",bg:"rgba(249, 115, 22, 0.15)",label:"Request"};case re.RESPONSE:return{icon:Sa,gradient:"var(--sys-green), var(--sys-teal)",bg:"rgba(34, 197, 94, 0.15)",label:"Response"};case re.ANON_REQ:return{icon:ot,gradient:"var(--sys-indigo), var(--sys-pink)",bg:"rgba(91, 91, 214, 0.15)",label:"Anonymous Request"};default:return{icon:Xs,gradient:"var(--sys-gray), var(--sys-slate)",bg:"rgba(107, 114, 128, 0.15)",label:t.payloadTypeName}}})(),l=i.icon;return e.jsxs("div",{className:"mb-4 flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl flex items-center justify-center shadow-md",style:{background:`linear-gradient(135deg, ${i.gradient})`},children:e.jsx(l,{className:"w-5 h-5 text-white"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-semibold text-fg-primary font-sans",children:i.label}),e.jsxs("p",{className:"text-xs text-fg-muted font-sans mt-0.5",children:[t.length," bytes · ",a]})]})]})}function Rn({pathHex:t}){if(!t)return null;const n=Ge(t);return e.jsx("div",{className:"flex flex-wrap items-center gap-2 py-2",children:n.map((s,a)=>e.jsxs("div",{className:"flex items-center gap-2",children:[a>0&&e.jsx(pe,{className:"w-4 h-4 text-sys-amber flex-shrink-0"}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(X,{size:"compact",copy:!0,children:s.toUpperCase()}),e.jsx("span",{className:"text-xs text-fg-muted font-sans tabular-nums w-4 text-left",children:a+1})]})]},a))})}function En({decoded:t,payloadType:n}){const s=Ns[n]||`TYPE_${n}`;switch(t.type){case"advert":{const a=t.nodeType==="chat"?"companion":t.nodeType.replace("_"," "),r=t.latitude!==void 0&&t.longitude!==void 0&&!(t.latitude===0&&t.longitude===0);return e.jsxs("div",{className:"text-xs text-fg-primary space-y-0.5",children:[e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Role:"})," ",a]}),t.name&&e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Name:"})," ",t.name]}),r&&e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Location:"})," ",t.latitude.toFixed(4),"°, ",t.longitude.toFixed(4),"°"]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Time:"})," ",ie(t.timestamp)]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Flags:"})," ",t.flagsDescription]})]})}case"ack":return e.jsx("div",{className:"text-xs text-fg-primary space-y-0.5",children:e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"CRC:"})," 0x",t.crc]})});case"path":return e.jsx("div",{className:"text-xs text-fg-primary space-y-1",children:e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Path:"})," ",t.pathString||"(empty)"]})});case"trace":return e.jsxs("div",{className:"text-xs text-fg-primary space-y-1",children:[e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Tag:"})," 0x",t.traceTag]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Target Path:"})," ",t.pathString||"(empty)"]}),t.snrValues.length>0&&e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"SNR:"})," ",t.snrValues.map(a=>`${a>=0?"+":""}${Number.isInteger(a)?a:a.toFixed(1)}dB`).join(" → ")]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Status:"})," ",t.isComplete?"✓ Complete":`In progress (${t.snrValues.length}/${t.pathHashes.length})`]})]});case"txt_msg":return e.jsxs("div",{className:"text-xs text-fg-primary space-y-0.5",children:[e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Dest:"})," ",t.destHash]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Src:"})," ",t.srcHash]}),t.encrypted?e.jsx("p",{className:"text-fg-muted italic",children:"Encrypted content"}):e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Text:"})," ",t.text]})]});case"grp_txt":return e.jsxs("div",{className:"text-xs text-fg-primary space-y-0.5",children:[e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Channel:"})," ",t.channelName?e.jsx("span",{className:"text-sys-green",children:t.channelName}):t.isPublicHashChannel?e.jsx("span",{className:"text-sys-indigo",children:"Public Hash Channel"}):e.jsxs("span",{className:"font-mono",children:["0x",t.channelHash]})]}),t.decrypted?e.jsxs(e.Fragment,{children:[t.senderName&&e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"From:"})," ",t.senderName]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Text:"})," ",t.text]})]}):t.isPublicHashChannel?e.jsx("p",{className:"text-fg-muted italic",children:"Encrypted (public hash channel)"}):e.jsx("p",{className:"text-fg-muted italic",children:"Encrypted (unknown channel)"})]});case"grp_data":return e.jsxs("div",{className:"text-xs text-fg-primary space-y-0.5",children:[e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Channel:"})," ",t.channelName?e.jsx("span",{className:"text-sys-teal",children:t.channelName}):e.jsxs("span",{className:"font-mono",children:["0x",t.channelHash]})]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Data:"})," ",t.dataLength," bytes ",t.decrypted?"(decrypted)":"(encrypted)"]})]});case"multipart":return e.jsxs("div",{className:"text-xs text-fg-primary space-y-0.5",children:[e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Part:"})," ",t.partNumber+1,"/",t.totalParts]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Message ID:"})," ",t.messageId]})]});case"control":return e.jsxs("div",{className:"text-xs text-fg-primary space-y-0.5",children:[e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Control:"})," ",t.subtypeName]}),t.dataLength>0&&e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Data:"})," ",t.dataLength," bytes"]})]});case"req":case"response":return e.jsxs("div",{className:"text-xs text-fg-primary space-y-0.5",children:[e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Dest:"})," ",t.destHash]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Src:"})," ",t.srcHash]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Ciphertext:"})," ",t.ciphertextLength," bytes"]})]});case"anon_req":return e.jsxs("div",{className:"text-xs text-fg-primary space-y-0.5",children:[e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Dest:"})," ",t.destHash]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Pub Key:"})," ",e.jsxs("span",{className:"font-mono break-all",children:[t.senderPublicKey.slice(0,16),"…"]})]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Ciphertext:"})," ",t.ciphertextLength," bytes"]})]});default:return e.jsxs("p",{className:"text-xs text-fg-secondary",children:[s," (","length"in t?t.length:0," bytes)"]})}}function zn({packet:t,decodedGrpTxt:n}){var F,Y;const s=t.raw_packet||"",a=s.length/2,r=ys(),[i,l]=p.useState(null),[c,o]=p.useState(null),[u,x]=p.useState(!1),[g,f]=p.useState(null),y=p.useCallback(D=>{f(E=>E===D?null:D)},[]),m=p.useMemo(()=>Is(s),[s]),v=(F=m==null?void 0:m.packet)==null?void 0:F.payloadType,T=(m==null?void 0:m.payloadHex)||"",h=(Y=m==null?void 0:m.packet)==null?void 0:Y.payload,N=v===re.GRP_TXT,j=v===re.GRP_DATA,C=N&&!n&&(!r||u);if(p.useEffect(()=>{if(l(null),x(!1),n||!N||!h||h.length<4)return;if(!r){x(!0);return}x(!0);let D=!1;return Ks(h).then(E=>{D||(l(E),x(!1))}),()=>{D=!0}},[T,N,r,n]),p.useEffect(()=>{if(o(null),!j||!h||h.length<4||!r)return;let D=!1;return Ys(h).then(E=>{D||o(E)}),()=>{D=!0}},[T,j,r]),!m||s.length===0)return e.jsx("div",{className:"p-4 text-center text-fg-muted",children:e.jsx("p",{className:"text-sm",children:"No raw packet data available"})});const{packet:k}=m;let b=m.decoded;n&&m.decoded.type==="grp_txt"?b=n:i&&m.decoded.type==="grp_txt"?b=i:c&&m.decoded.type==="grp_data"&&(b=c);const A=()=>{switch(b.type){case"advert":return e.jsx(kn,{advert:b,timestamp:t.timestamp});case"grp_data":return e.jsx(Cn,{decoded:b,timestamp:t.timestamp});case"grp_txt":return e.jsx(Sn,{decoded:b,timestamp:t.timestamp,isLoading:C,onDecrypted:l});case"ack":return e.jsx(_n,{decoded:b,timestamp:t.timestamp});case"path":return e.jsx(Mn,{decoded:b,timestamp:t.timestamp});case"trace":return e.jsx(Tn,{decoded:b,timestamp:t.timestamp});case"txt_msg":return e.jsx(Pn,{decoded:b,timestamp:t.timestamp});case"multipart":return e.jsx(Bn,{decoded:b,timestamp:t.timestamp});case"generic":return k.payloadType===re.REQ||k.payloadType===re.RESPONSE||k.payloadType===re.ANON_REQ?e.jsx(Ln,{decoded:b,timestamp:t.timestamp,payloadType:k.payloadType}):null;default:return null}},U=p.useMemo(()=>Nn(b,m.payloadHex),[b,m.payloadHex]),W=g==="payload"||je(g),K=p.useMemo(()=>{const D=[{id:"header",hex:m.headerHex,color:"red"},...m.transportCodesHex?[{id:"transportCodes",hex:m.transportCodesHex,color:"indigo"}]:[],{id:"pathLength",hex:m.pathLengthHex,color:"green"},...m.pathDataHex?[{id:"pathData",hex:m.pathDataHex,color:"amber"}]:[]];return W?[...D,...vn(U)]:[...D,{id:"payload",hex:m.payloadHex,color:"cyan"}]},[m,W,U]);return e.jsxs("div",{className:"font-mono space-y-2 min-w-0 overflow-hidden",children:[A(),e.jsx(hn,{rawHex:s,hexSegments:K,selectedSegment:g,onSegmentClick:y}),e.jsx(js,{children:e.jsx(oe.div,{layout:!0,transition:at,className:"space-y-2 min-w-0",children:(()=>{var M,H,te,se;const E=[{id:"header",title:"Header",color:"red",startByte:0,endByte:0,hexBytes:`0x${m.headerHex.toUpperCase()}`,condition:!0,content:e.jsxs("table",{className:"w-full text-left",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"type-micro text-fg-muted border-b border-edge-subtle font-sans",children:[e.jsx("th",{className:"py-1 font-medium",children:"Bits"}),e.jsx("th",{className:"py-1 font-medium",children:"Field"}),e.jsx("th",{className:"py-1 font-medium",children:"Value"}),e.jsx("th",{className:"py-1 font-medium",children:"Binary"})]})}),e.jsx("tbody",{children:m.headerFields.map(d=>e.jsx(wn,{...d},d.bits))})]})},{id:"transportCodes",title:"Transport Codes",color:"indigo",startByte:1,endByte:4,hexBytes:((M=m.transportCodesHex)==null?void 0:M.toUpperCase())||"",condition:!!m.transportCodesHex,content:e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-xs text-fg-muted",children:"Two 16-bit transport codes for encrypted routing"}),e.jsxs("div",{className:"mt-1 text-xs text-fg-secondary",children:["Code 1: 0x",(H=m.transportCodesHex)==null?void 0:H.slice(0,4).toUpperCase()," | Code 2: 0x",(te=m.transportCodesHex)==null?void 0:te.slice(4,8).toUpperCase()]})]})},{id:"pathLength",title:"Path Length",color:"green",startByte:m.transportCodesHex?5:1,endByte:m.transportCodesHex?5:1,hexBytes:`0x${m.pathLengthHex.toUpperCase()}`,condition:!0,content:e.jsxs("p",{className:"text-xs text-fg-muted pt-1",children:[k.pathLen," bytes showing route taken (increases as packet floods)"]})},{id:"pathData",title:"Path Data",color:"amber",startByte:m.transportCodesHex?6:2,endByte:(m.transportCodesHex?5:1)+k.pathLen,hexBytes:((se=m.pathDataHex)==null?void 0:se.toUpperCase())||"",condition:k.pathLen>0,content:e.jsxs("div",{className:"space-y-3",children:[e.jsx(Rn,{pathHex:m.pathDataHex}),e.jsx("p",{className:"text-xs text-fg-muted",children:"Historical route taken (bytes are added as packet floods through network)"})]})},{id:"payload",title:"Payload",color:"cyan",startByte:m.payloadStartByte,endByte:a-1,hexBytes:m.payloadHex.toUpperCase(),condition:!0,content:e.jsxs(e.Fragment,{children:[!je(g)&&e.jsxs("div",{className:"p-3 rounded-lg bg-black",children:[e.jsx("p",{className:"type-micro text-fg-muted mb-1.5 font-sans",children:"Decoded"}),e.jsx(En,{decoded:b,payloadType:k.payloadType})]}),!je(g)&&U.length>0&&e.jsx("p",{className:"type-micro text-fg-muted mt-3 font-sans",children:"Click a field below to highlight its bytes"}),je(g)&&e.jsx("p",{className:"type-micro text-fg-muted font-sans",children:"↑ Selected field above • Other fields below ↓"})]})}].filter(d=>d.condition),O=je(g)?U.find(d=>d.id===g):null,$=je(g)?[...E].sort((d,Z)=>d.id==="payload"?-1:Z.id==="payload"?1:0):[...E].sort((d,Z)=>d.id===g?-1:Z.id===g?1:0),J=je(g)?U.filter(d=>d.id!==g):[];return e.jsxs(e.Fragment,{children:[O&&e.jsx(Ct,{id:`subfield-${O.id}`,title:O.title,color:O.color,startByte:m.payloadStartByte+O.startByte,endByte:m.payloadStartByte+O.endByte,hexBytes:O.hex.toUpperCase(),isSelected:!0,children:O.decoded},O.id),$.map(d=>e.jsx(Ct,{id:`section-${d.id}`,title:d.title,color:d.color,startByte:d.startByte,endByte:d.endByte,hexBytes:d.hexBytes,isSelected:d.id===g,children:d.content},d.id)),J.map(d=>e.jsxs(oe.div,{layout:"position",layoutId:`subfield-${d.id}`,transition:at,className:"w-full min-w-0 overflow-hidden rounded-xl p-4 sm:p-5 space-y-4",style:{backgroundColor:Te.cardRestBg,boxShadow:Te.cardRestShadow},children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-0.5 min-w-0",children:[e.jsx(B,{color:d.color,children:d.title}),d.hex.length<=32&&Ge(d.hex).map((Z,q)=>e.jsx(B,{color:d.color,className:"font-mono",children:Z.toUpperCase()},q))]}),e.jsxs("span",{className:"type-data-xs text-fg-muted flex-shrink-0",children:["Bytes ",m.payloadStartByte+d.startByte,"-",m.payloadStartByte+d.endByte]})]}),e.jsx("div",{className:"min-w-0 overflow-hidden p-3 rounded-lg bg-black",children:d.decoded})]},d.id))]})})()})})]})}const St=p.memo(zn);function _t(t){if(!t)return[];if(Array.isArray(t))return t;try{const n=JSON.parse(t);return Array.isArray(n)?n:[]}catch{return[]}}function nt({hop:t,compact:n=!1,index:s=0,highlightIndex:a=-1,isTrace:r=!1}){var c;const i=s===a,l=za();return p.useEffect(()=>{i&&r&&l.start({boxShadow:["0 0 0 0px rgba(113, 156, 223, 0)","0 0 0 2px rgba(113, 156, 223, 0.5)","0 0 0 2px rgba(113, 156, 223, 0.5)","0 0 0 0px rgba(113, 156, 223, 0)"],transition:{duration:.5,times:[0,.2,.7,1],ease:"easeInOut"}})},[i,r,l]),e.jsxs(oe.div,{className:R("flex items-center gap-1.5",n?"flex-row":"flex-col"),animate:{scale:i?1.05:1,opacity:i?1:.85},transition:{duration:.3,ease:"easeInOut"},children:[e.jsxs(oe.div,{className:R("flex items-center gap-1.5 px-2.5 py-1 rounded-md","font-mono text-xs font-semibold",t.isLocal?"bg-sys-amber/20 text-sys-amber ring-1 ring-sys-amber/30":"bg-elevated/50 text-fg-primary ring-1 ring-edge-strong/50"),animate:l,initial:{boxShadow:"0 0 0 0px rgba(113, 156, 223, 0)"},children:[t.isLocal&&e.jsx(na,{className:"w-3 h-3"}),e.jsx("span",{children:t.prefix}),t.confidence!==void 0&&t.confidence<.9&&e.jsxs("span",{className:"text-[9px] opacity-70",children:[(t.confidence*100).toFixed(0),"%"]})]}),!n&&((c=t.neighborInfo)==null?void 0:c.name)&&e.jsx("span",{className:"text-xs text-fg-muted truncate max-w-[80px]",children:t.neighborInfo.name})]})}function Fn({snr:t,sf:n}){const s=_s(t,n),r=Ss()[s]||"#6b7280",i=Number.isInteger(t)?t.toString():t.toFixed(1);return e.jsxs(B,{customColor:r,compact:!0,className:"font-mono",children:[t>=0?"+":"",i,"dB"]})}function In({hops:t,compact:n,isTrace:s=!1,sf:a}){const[r,i]=p.useState(-1);return p.useEffect(()=>{if(t.length===0)return;const l=setTimeout(()=>{i(0)},400),c=setInterval(()=>{i(o=>{const u=o+1;return u>=t.length?(clearInterval(c),-1):u})},s?500:600);return()=>{clearTimeout(l),clearInterval(c)}},[t.length,s]),e.jsx("div",{className:"p-6",style:{display:"grid",gridTemplateColumns:"1fr auto 1fr",gap:"4px 8px"},children:t.map((l,c)=>{const o=c%2===0,u=c===t.length-1;return e.jsxs("div",{className:"contents",children:[e.jsx("div",{className:R("flex items-center","justify-end"),children:o&&e.jsx(nt,{hop:l,compact:n,index:c,highlightIndex:r,isTrace:s})}),e.jsx("div",{className:"flex flex-col items-center justify-center min-h-[28px]",children:!u&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-px flex-1 bg-border-strong/40 min-h-[8px]"}),l.snr!==void 0&&e.jsx(Fn,{snr:l.snr,sf:a}),e.jsx("svg",{className:"w-3 h-3 text-fg-muted flex-shrink-0",viewBox:"0 0 12 12",fill:"none",children:e.jsx("path",{d:"M6 2v8M3 7l3 3 3-3",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})]})}),e.jsx("div",{className:R("flex items-center","justify-start"),children:!o&&e.jsx(nt,{hop:l,compact:n,index:c,highlightIndex:r,isTrace:s})})]},`${l.prefix}-${c}`)})})}function An({packet:t,neighbors:n,localHash:s,neighborAffinity:a,ghostPrefixes:r,direction:i="horizontal",compact:l=!1,traceSnr:c,overridePath:o}){const u=c!==void 0&&c.length>0,x=ks(),g=_t(t.original_path),f=_t(t.forwarded_path),y=o??(f.length>0?f:g),m=s?De(s):"",v=p.useMemo(()=>y.map((h,N)=>{const j=h.toUpperCase(),C=j===m,k=(r==null?void 0:r.has(j))??!1,b=Cs(j,n,a);return{prefix:j,fullHash:b==null?void 0:b.hash,neighborInfo:b==null?void 0:b.info,isLocal:C,isGhost:k,confidence:b==null?void 0:b.confidence,snr:c==null?void 0:c[N]}}),[y,n,a,m,r,c]);if(v.length===0)return e.jsxs("div",{className:"flex items-center gap-2 text-fg-muted text-xs",children:[e.jsx(de,{className:"w-4 h-4 opacity-50"}),e.jsx("span",{children:"Direct / No path data"})]});if(i==="flowchart")return e.jsx(In,{hops:v,compact:l,isTrace:u,sf:x});const T=i==="horizontal"?pe:qt;return e.jsx("div",{className:R("flex gap-1.5",i==="horizontal"?"flex-row flex-wrap items-center":"flex-col items-start"),children:v.map((h,N)=>e.jsxs("div",{className:R("flex items-center gap-1.5",i==="vertical"&&"flex-col"),children:[e.jsx(nt,{hop:h,compact:l}),N"blue",Dn=[{fn:"id",group:"identity",fmt:"int",read:t=>ee(t.id),color:V},{fn:"packet_hash",group:"identity",fmt:"hex",read:t=>t.packet_hash||void 0,color:V},{fn:"timestamp",group:"identity",fmt:"epoch",read:t=>t.timestamp?String(t.timestamp):void 0,color:V,annotate:t=>t.timestamp>0?Je(t.timestamp):void 0},{fn:"type",group:"classification",fmt:"enum",read:t=>ee(t.type??t.payload_type),color:V},{fn:"route",group:"classification",fmt:"enum",read:t=>ee(t.route??t.route_type),color:V},{fn:"rssi",group:"signal",fmt:"int",read:t=>ee(t.rssi,"dBm"),color:V},{fn:"snr",group:"signal",fmt:"float",read:t=>ee(t.snr,"dB"),color:V},{fn:"path_length",group:"size",fmt:"int",read:t=>{if(t.path_length!=null)return t.path_length===0?"zero-hop":`${t.path_length} hops`},color:V},{fn:"payload_length",group:"size",fmt:"int",read:t=>ee(t.payload_length,"B"),color:V},{fn:"airtime",group:"size",fmt:"float",read:t=>ee(t.airtime_ms,"ms"),color:V},{fn:"src_hash",group:"addressing",fmt:"hex<2>",read:t=>t.src_hash??void 0,color:V},{fn:"dst_hash",group:"addressing",fmt:"hex<2>",read:t=>t.dst_hash??void 0,color:V},{fn:"path_hash",group:"addressing",fmt:"hex[]|hex",read:t=>Array.isArray(t.path_hash)?`[${t.path_hash.join(", ")}]`:ee(t.path_hash),color:V,renderValue:t=>Array.isArray(t.path_hash)?Xe(t.path_hash):null},{fn:"score",group:"addressing",fmt:"int",read:t=>ee(t.score),color:V},{fn:"original_path",group:"paths",fmt:"hex[]",read:t=>Array.isArray(t.original_path)?`[${t.original_path.join(", ")}]`:void 0,color:V,renderValue:t=>Array.isArray(t.original_path)&&t.original_path.length>0?Xe(t.original_path,t.src_hash||void 0,t.dst_hash||void 0,!0):null},{fn:"forwarded_path",group:"paths",fmt:"hex[]",read:t=>Array.isArray(t.forwarded_path)?`[${t.forwarded_path.join(", ")}]`:void 0,color:V,renderValue:t=>Array.isArray(t.forwarded_path)&&t.forwarded_path.length>0?Xe(t.forwarded_path):null},{fn:"transmitted",group:"status",fmt:"bool",read:t=>ee(t.transmitted),color:V},{fn:"is_duplicate",group:"status",fmt:"bool",read:t=>ee(t.is_duplicate),color:V},{fn:"drop_reason",group:"status",fmt:"string|null",read:t=>t.drop_reason??void 0,color:V},{fn:"tx_delay",group:"status",fmt:"int",read:t=>ee(t.tx_delay_ms,"ms"),color:V},{fn:"origin",group:"status",fmt:"enum",read:t=>t.packet_origin??void 0,color:V},{fn:"duplicates",group:"status",fmt:"PacketDuplicate[]",read:t=>t.duplicates!=null&&t.duplicates.length>0?`${t.duplicates.length}`:ee(t.duplicates),color:V},{fn:"lbt_attempts",group:"lbt",fmt:"int",read:t=>ee(t.lbt_attempts),color:V},{fn:"lbt_backoff",group:"lbt",fmt:"json",read:t=>ee(t.lbt_backoff_delays_ms),color:V},{fn:"lbt_busy",group:"lbt",fmt:"bool|int",read:t=>ee(t.lbt_channel_busy),color:V}];function Xe(t,n,s,a){const r=t.length>0,i=n||a,l=s||a;return e.jsxs("span",{className:"inline-flex items-center gap-1 flex-wrap",children:[i&&e.jsxs(e.Fragment,{children:[n?e.jsx("span",{className:"inline-block border border-edge-subtle rounded px-1.5 py-0.5 font-mono text-[11px] text-sys-blue",children:n}):e.jsx("span",{className:"inline-block border border-edge-subtle/50 rounded px-1.5 py-0.5 font-mono text-[11px] text-fg-muted/30",children:"XX"}),(r||l)&&e.jsx("span",{className:"text-fg-muted/40 text-[10px]",children:"→"})]}),t.map((c,o)=>e.jsxs(p.Fragment,{children:[o>0&&e.jsx("span",{className:"text-fg-muted/40 text-[10px]",children:"→"}),e.jsx("span",{className:"inline-block border border-edge-subtle rounded px-1.5 py-0.5 font-mono text-[11px] text-sys-blue",children:c})]},o)),l&&e.jsxs(e.Fragment,{children:[r&&e.jsx("span",{className:"text-fg-muted/40 text-[10px]",children:"→"}),s?e.jsx("span",{className:"inline-block border border-edge-subtle rounded px-1.5 py-0.5 font-mono text-[11px] text-sys-blue",children:s}):e.jsx("span",{className:"inline-block border border-edge-subtle/50 rounded px-1.5 py-0.5 font-mono text-[11px] text-fg-muted/30",children:"XX"})]})]})}let Ie=null;function Hn(){if(!Ie){Ie=new Map;for(const t of Dn)Ie.set(t.fn,t)}return Ie}function Mt(t,n){var l;const s=Hn().get(n);if(!s)return null;const a=s.read(t);if(a===void 0)return null;const r=s.color(t),i=(l=s.annotate)==null?void 0:l.call(s,t);return i?{text:a,color:r,annotation:i}:{text:a,color:r}}function Tt(t){if(!t)return[];if(Array.isArray(t))return t;try{const n=JSON.parse(t);return Array.isArray(n)?n:[]}catch{return[]}}function Pt({packets:t,selectedIndex:n,onSelect:s,compact:a=!1}){if(t.length<=1)return null;const r=n>0,i=nr&&s(n-1),disabled:!r,className:R("p-0.5 radius-badge transition-base",r?"text-fg-muted hover:text-fg-primary hover-bg":"text-fg-muted cursor-not-allowed"),"aria-label":"Previous observation",children:e.jsx(Yt,{className:a?"size-3":"size-4"})}),e.jsx("div",{className:"flex items-center gap-0.5",children:t.map((l,c)=>{const o=c===n,x=new Date(l.timestamp*1e3).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"});return e.jsx(Es,{color:o?"cyan":"zinc",filled:o,compact:a,onClick:()=>s(c),title:`Observation ${c+1} at ${x}`,className:R("transition-all duration-150",!o&&"opacity-60 hover:opacity-100"),children:a?e.jsx("span",{className:"tabular-nums",children:c+1}):e.jsxs("span",{className:"tabular-nums text-xs",children:["#",c+1,l.rssi!=null&&e.jsx("span",{className:"ml-1 opacity-70",children:l.rssi})]})},`${l.timestamp}_${c}`)})}),e.jsx("button",{onClick:()=>i&&s(n+1),disabled:!i,className:R("p-0.5 radius-badge transition-base",i?"text-fg-muted hover:text-fg-primary hover-bg":"text-fg-muted cursor-not-allowed"),"aria-label":"Next observation",children:e.jsx(ct,{className:a?"size-3":"size-4"})}),e.jsxs("span",{className:R("text-fg-muted ml-1",a?"text-[9px]":"text-xs"),children:[e.jsx(it,{className:"inline size-3 mr-0.5 opacity-50"}),t.length]})]})}function Ae({icon:t,label:n,disabled:s=!1}){return e.jsx(oe.div,{className:"flex items-center gap-1 text-xs",title:n,animate:{opacity:s?.25:.6},transition:{duration:.15,ease:[.4,0,.2,1]},children:e.jsx("span",{className:R("flex items-center justify-center size-5 radius-badge border-control transition-base",s?"bg-subtle-fill border-edge-subtle":"bg-subtle-fill"),children:t})})}function On({hasDuplicates:t,hasPrev:n,hasNext:s,canPrevDupe:a,canNextDupe:r}){return e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs("div",{className:"flex items-center gap-0.5",children:[e.jsx(Ae,{icon:e.jsx(ja,{className:"size-3"}),label:"Previous packet (↑)",disabled:!n}),e.jsx(Ae,{icon:e.jsx(zs,{className:"size-3"}),label:"Next packet (↓)",disabled:!s})]}),t&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-px h-3 bg-subtle-fill-strong"}),e.jsxs("div",{className:"flex items-center gap-0.5",children:[e.jsx(Ae,{icon:e.jsx(Yt,{className:"size-3"}),label:"Previous observation (←)",disabled:!a}),e.jsx(Ae,{icon:e.jsx(ct,{className:"size-3"}),label:"Next observation (→)",disabled:!r})]})]})]})}function $n({packets:t,initialIndex:n=0,onClose:s,onNavigatePrev:a,onNavigateNext:r,hasPrev:i=!1,hasNext:l=!1,resolveSource:c,getDecodedContent:o}){var ze;const[u,x]=p.useState(n),g=t[u]??t[0],f=t.length>1,[y,m]=p.useState(null),[v,T]=p.useState(!1);p.useEffect(()=>{if(!g._stripped){m(null);return}let G=!1;T(!0);const w=g.packet_hash;if(!w){T(!1);return}return Ms(w).then(S=>{G||(S.success&&S.data&&(m(S.data),(S.data.type??S.data.payload_type)===re.GRP_TXT&&S.data.raw_packet&&Ts.getState().queueDecryption([S.data])),T(!1))}).catch(()=>{G||T(!1)}),()=>{G=!0}},[g]);const h=y??g,N=u>0,j=u{x(Math.max(0,Math.min(G,t.length-1)))},[t.length]);p.useEffect(()=>{const G=w=>{if(!(w.target instanceof HTMLInputElement||w.target instanceof HTMLTextAreaElement))switch(w.key){case"ArrowUp":w.preventDefault(),a==null||a();break;case"ArrowDown":w.preventDefault(),r==null||r();break;case"ArrowLeft":w.preventDefault(),N&&x(S=>S-1);break;case"ArrowRight":w.preventDefault(),j&&x(S=>S+1);break}};return window.addEventListener("keydown",G),()=>window.removeEventListener("keydown",G)},[a,r,N,j]);const k=Ht(),b=Ps(),A=Bs(),U=Ls(),W=p.useMemo(()=>new Set(U.map(G=>G.prefix.toUpperCase())),[U]),K=h.payload_type_name||At(h.payload_type??h.type),F=h.route_type_name||Dt(h.route_type??h.route),Y=h.payload_length??h.length??0,D=Tt(h.original_path),E=Tt(h.forwarded_path),O=D.length>0||E.length>0,$=E.length>0?E:D,J=p.useMemo(()=>{var G;if((G=k==null?void 0:k.config)!=null&&G.repeater)return{latitude:k.config.repeater.latitude,longitude:k.config.repeater.longitude,name:k.config.node_name||"Local Node"}},[k]),M=(k==null?void 0:k.neighbors)??{},H=A.size>0?A:void 0,te=h.raw_packet&&h.raw_packet.length>0,se=g._stripped&&v,d=p.useMemo(()=>c?c(h):null,[c,h]),Z=Rs(h.packet_hash),q=p.useMemo(()=>!o||(h.payload_type??h.type)!==re.GRP_TXT?null:o(h),[o,h]),le=p.useMemo(()=>{if((h.payload_type??h.type)!==re.GRP_TXT)return null;if(Z!=null&&Z.decoded){const w=Z.decoded;return{type:"grp_txt",channelHash:w.channelHash,channelName:w.channelName,text:w.text??"",decrypted:w.decrypted,senderName:w.senderName,timestamp:w.timestamp,flags:w.flags,macCorrupted:w.macCorrupted}}return q!=null&&q.decrypted?{type:"grp_txt",channelHash:q.channelHash??"",channelName:q.channelName??"",text:q.text??"",decrypted:!0,senderName:q.senderName??"",timestamp:0,flags:0,macCorrupted:q.corrupted}:null},[h,Z,q]),P=p.useMemo(()=>As(h,le),[h,le]),z=P.kind==="trace"?P.data:null,ae=P.kind==="trace"?P.snrValues:void 0,_=P.kind==="advert"?P.data:null,ce=P.kind==="advert"?P.sourceNode:void 0,fe=P.kind==="grp_txt"?P.wardriveSourceNode??void 0:void 0,ne=P.kind==="anon_req"?P.data:null,Le=G=>!G||G===0?"Unknown":new Date(G*1e3).toLocaleString(),be=(h.payload_type??h.type)===re.ADVERT&&(ce!==void 0||O),Re=fe!==void 0,Ne=ce??fe,qe=Be[K]??"zinc",Ee=ue[qe]||ue.zinc;return e.jsxs(Ot,{open:!0,onClose:s,size:"5xl",motionPlus:!0,className:"sm:h-[85vh] sm:max-h-[800px] md:h-[80vh] md:max-h-[900px]",children:[e.jsxs("div",{className:"sm:hidden",children:[e.jsx("div",{className:"flex justify-center pt-2 pb-1",children:e.jsx("div",{className:"w-9 h-1 rounded-full bg-fg-muted","aria-hidden":"true"})}),e.jsxs("div",{className:"flex items-center justify-between px-3 pb-2",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(B,{color:Be[K]??"zinc",className:"!text-[9px] !px-1.5 !py-0",children:K}),e.jsx(B,{color:He[F]??"zinc",className:"!text-[9px] !px-1.5 !py-0",children:F}),e.jsxs(B,{color:"zinc",className:"!text-[9px] !px-1.5 !py-0",children:[Y,"B"]})]}),e.jsx("button",{onClick:s,className:"px-3 py-1.5 text-[15px] font-medium text-sys-blue active:text-sys-blue/80 transition-base flex-shrink-0 radius-inner active:bg-subtle-fill",children:"Done"})]}),f&&e.jsx("div",{className:"px-3 pb-2",children:e.jsx(Pt,{packets:t,selectedIndex:u,onSelect:C,compact:!0})})]}),e.jsx("div",{className:"hidden sm:block px-6 pt-5 pb-4",children:e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(B,{color:Be[K]??"zinc",children:K}),e.jsx(B,{color:He[F]??"zinc",children:F}),e.jsxs(B,{color:"zinc",children:[Y,"B"]}),f&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-px h-4 bg-subtle-fill-strong"}),e.jsx(Pt,{packets:t,selectedIndex:u,onSelect:C})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(On,{hasDuplicates:f,hasPrev:i,hasNext:l,canPrevDupe:N,canNextDupe:j}),e.jsx("button",{onClick:s,className:"p-1.5 -m-1.5 text-fg-muted hover:text-fg-primary transition-base radius-inner hover:bg-elevated flex-shrink-0",children:e.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]})]})}),e.jsx("div",{className:"sm:hidden h-[2px]",style:{backgroundColor:Ee,opacity:.6}}),e.jsxs($t,{className:"p-0 overflow-hidden flex-1 flex flex-col min-h-0",children:[e.jsx("div",{className:"md:hidden flex-1 overflow-y-auto overflow-x-hidden",children:e.jsxs("div",{className:"p-2 space-y-2",children:[(h.rssi!=null||h.snr!=null)&&e.jsxs("div",{className:"relative flex items-center justify-between px-2 py-1.5 radius-inner bg-subtle-fill",children:[e.jsx(Ke,{mode:"popLayout",initial:!1,children:e.jsxs(oe.div,{className:"flex items-center gap-3",initial:{opacity:0,scale:.96},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.96},transition:{duration:.15,ease:[.4,0,.2,1]},children:[e.jsx(Oe,{rssi:h.rssi,snr:h.snr,compact:!0,showValues:!0,validated:$e(h)}),e.jsx("span",{className:"text-[11px] text-fg-muted",children:pt(h.rssi)})]},u)}),$.length>0&&e.jsxs("span",{className:"type-data-xs text-fg-muted",children:[$.length," hop",$.length!==1?"s":""]})]}),(O&&$.length>0||be||Re)&&e.jsx("div",{className:"overflow-hidden radius-inset",children:e.jsx("div",{className:"aspect-[4/3] w-full",children:e.jsx(We,{path:$,neighbors:M,localNode:J,localHash:k==null?void 0:k.local_hash,srcHash:h.src_hash,dstHash:h.dst_hash,neighborAffinity:H,hubNodes:[...b],traceSnr:ae,advertiserSource:Ne})})}),z&&z.pathHashes.length>0&&e.jsxs("div",{className:"radius-inset bg-black overflow-hidden",children:[e.jsx("div",{className:"px-3 py-2 space-y-1.5",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"type-micro text-fg-muted",children:"Trace Route"}),e.jsx("div",{className:"flex items-center gap-1.5",children:e.jsx(B,{color:z.isComplete?"green":"amber",compact:!0,children:z.isComplete?"Complete":"In Progress"})})]})}),e.jsx(Se,{packet:h,neighbors:M,localHash:k==null?void 0:k.local_hash,neighborAffinity:H,ghostPrefixes:W,direction:"flowchart",compact:!0,overridePath:z.pathHashes,traceSnr:z.snrValues})]}),O&&!z&&e.jsxs("div",{className:"radius-inset bg-black overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-2",children:[e.jsx("span",{className:"type-micro text-fg-muted",children:"Path"}),e.jsxs(B,{color:"zinc",compact:!0,children:[$.length," hop",$.length!==1?"s":""]})]}),e.jsx(Se,{packet:h,neighbors:M,localHash:k==null?void 0:k.local_hash,neighborAffinity:H,ghostPrefixes:W,direction:"flowchart",compact:!0,traceSnr:ae})]}),d&&(d.name||d.hash)&&!_&&!ne&&e.jsxs("div",{className:"radius-inset bg-subtle-fill overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-2 border-b border-edge-subtle",children:[e.jsx("span",{className:"type-micro text-fg-muted",children:"Source"}),e.jsx(B,{color:d.isRepeater?"blue":d.isCompanion?"violet":d.type==="room_server"?"lime":"zinc",compact:!0,children:d.type==="room_server"?"room server":d.type})]}),e.jsxs("div",{className:"p-3 space-y-1.5",children:[d.name&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ce,{className:"w-3.5 h-3.5 text-fg-muted flex-shrink-0"}),e.jsx("span",{className:"type-label text-fg-primary truncate",children:d.name}),!d.confident&&e.jsx("span",{className:"text-[9px] text-fg-muted/60 italic",children:"ambiguous"})]}),d.hash&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(we,{className:"w-3.5 h-3.5 text-fg-muted flex-shrink-0"}),e.jsx("span",{className:"type-data-xs text-fg-muted truncate font-mono",children:d.hash.length>16?`${d.hash.slice(0,16)}…${d.hash.slice(-8)}`:d.hash.startsWith("0x")?d.hash.slice(2,10)+"…":d.hash.slice(0,8)+"…"})]})]})]}),ne&&e.jsxs("div",{className:"radius-inset bg-subtle-fill overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-2 border-b border-edge-subtle",children:[e.jsx("span",{className:"type-micro text-fg-muted",children:"Sender Identity"}),e.jsx(B,{color:d!=null&&d.isRepeater?"blue":d!=null&&d.isCompanion?"violet":(d==null?void 0:d.type)==="room_server"?"lime":"amber",compact:!0,children:d!=null&&d.type&&d.type!=="unknown"?d.type==="room_server"?"room server":d.type:"companion"})]}),e.jsxs("div",{className:"p-3 space-y-2",children:[(d==null?void 0:d.name)&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ce,{className:"w-3.5 h-3.5 text-fg-muted flex-shrink-0"}),e.jsx("span",{className:"type-label text-fg-primary truncate",children:d.name}),!d.confident&&e.jsx("span",{className:"text-[9px] text-fg-muted/60 italic",children:"ambiguous"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(de,{className:"w-3.5 h-3.5 text-fg-muted flex-shrink-0"}),e.jsxs("span",{className:"text-xs text-fg-muted",children:["Dest: ",e.jsx("span",{className:"font-mono",children:ne.destHash})]})]}),e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(we,{className:"w-3.5 h-3.5 text-fg-muted flex-shrink-0 mt-0.5"}),e.jsx("span",{className:"type-data-xs text-fg-muted break-all font-mono leading-relaxed",children:ne.senderPublicKey})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(xe,{className:"w-3.5 h-3.5 text-fg-muted flex-shrink-0"}),e.jsxs("span",{className:"text-xs text-fg-muted",children:[ne.ciphertextLength,"B encrypted payload"]})]})]})]}),_&&e.jsxs("div",{className:"radius-inset bg-subtle-fill overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-2 border-b border-edge-subtle",children:[e.jsx("span",{className:"type-micro text-fg-muted",children:"Advertiser Info"}),e.jsx(B,{color:"lime",compact:!0,children:_.nodeType})]}),e.jsxs("div",{className:"p-3 space-y-2",children:[_.name&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ce,{className:"w-3.5 h-3.5 text-fg-muted flex-shrink-0"}),e.jsx("span",{className:"type-label text-fg-primary truncate",children:_.name})]}),_.latitude&&_.longitude&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ue,{className:"w-3.5 h-3.5 text-fg-muted flex-shrink-0"}),e.jsxs("span",{className:"type-data-xs text-fg-secondary",children:[_.latitude.toFixed(5),", ",_.longitude.toFixed(5)]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(we,{className:"w-3.5 h-3.5 text-fg-muted flex-shrink-0"}),e.jsxs("span",{className:"type-data-xs text-fg-muted truncate",children:[_.publicKey.slice(0,16),"...",_.publicKey.slice(-8)]})]}),_.timestamp>0&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(xe,{className:"w-3.5 h-3.5 text-fg-muted flex-shrink-0"}),e.jsx("span",{className:"text-xs text-fg-muted",children:Le(_.timestamp)})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(de,{className:"w-3.5 h-3.5 text-fg-muted flex-shrink-0"}),e.jsx("span",{className:"text-xs text-fg-muted",children:_.flagsDescription||`Flags: 0x${_.flags.toString(16).padStart(2,"0")}`})]})]})]}),se?e.jsx("div",{className:"pt-1 px-3 py-6 text-center",children:e.jsx("span",{className:"text-xs text-fg-muted animate-pulse",children:"Loading packet details…"})}):te?e.jsx("div",{className:"pt-1",children:e.jsx(St,{packet:h,decodedGrpTxt:le})}):null]})}),e.jsxs("div",{className:"hidden md:grid md:grid-cols-2 flex-1 overflow-hidden",children:[e.jsx("div",{className:"overflow-y-auto overflow-x-hidden scrollbar-none p-4 border-r border-edge-subtle",children:se?e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsx("span",{className:"text-sm text-fg-muted animate-pulse",children:"Loading packet details…"})}):te?e.jsx(St,{packet:h,decodedGrpTxt:le}):null}),e.jsxs("div",{className:"grid overflow-hidden",style:{gridTemplateRows:"minmax(280px, 1fr) auto"},children:[e.jsx("div",{className:"overflow-hidden p-2",children:O&&$.length>0||be||Re?e.jsx("div",{className:"h-full w-full",children:e.jsx(We,{path:$,neighbors:M,localNode:J,localHash:k==null?void 0:k.local_hash,srcHash:h.src_hash,dstHash:h.dst_hash,neighborAffinity:H,hubNodes:[...b],traceSnr:ae,advertiserSource:Ne})}):e.jsxs("div",{className:"h-full w-full flex flex-col items-center justify-center text-center px-4",children:[e.jsx(de,{className:"w-8 h-8 text-fg-muted/50 mb-2"}),e.jsx("span",{className:"text-sm text-fg-muted",children:"Direct Reception"}),e.jsx("span",{className:"text-xs text-fg-muted/70 mt-1",children:"Zero-hop packet — received directly from sender"})]})}),e.jsxs("div",{className:"overflow-y-auto max-h-[200px] p-2 space-y-2",children:[!z&&$.length<=1&&(h.rssi!=null||h.snr!=null)&&e.jsx("div",{className:"surface-base radius-inset p-4",children:e.jsxs("dl",{className:"text-xs grid grid-cols-2 gap-2",children:[e.jsxs("div",{children:[e.jsx("dt",{className:"text-fg-muted mb-1",children:"Signal"}),e.jsx(Ke,{mode:"popLayout",initial:!1,children:e.jsxs(oe.dd,{className:"flex items-center gap-2",initial:{opacity:0,scale:.96},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.96},transition:{duration:.15,ease:[.4,0,.2,1]},children:[e.jsx(Oe,{rssi:h.rssi,snr:h.snr,validated:$e(h)}),e.jsx("span",{className:"font-medium text-fg-primary",children:pt(h.rssi)})]},u)})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-fg-muted mb-1",children:"RF"}),e.jsx(Ke,{mode:"popLayout",initial:!1,children:e.jsxs(oe.dd,{className:"type-data text-fg-secondary",initial:{opacity:0,scale:.96},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.96},transition:{duration:.15,ease:[.4,0,.2,1]},children:[(ze=Mt(h,"rssi"))==null?void 0:ze.text,(()=>{const G=Mt(h,"snr");return G?` · ${G.text}`:null})()]},u)})]})]})}),d&&(d.name||d.hash)&&!_&&!ne&&e.jsxs("div",{className:"radius-inset bg-subtle-fill overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-b border-edge-subtle",children:[e.jsx("span",{className:"type-micro text-fg-muted",children:"Source"}),e.jsx(B,{color:d.isRepeater?"blue":d.isCompanion?"violet":d.type==="room_server"?"lime":"zinc",compact:!0,children:d.type==="room_server"?"room server":d.type})]}),e.jsxs("div",{className:"p-4 space-y-2",children:[d.name&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ce,{className:"w-4 h-4 text-fg-muted flex-shrink-0"}),e.jsx("span",{className:"type-label text-fg-primary truncate",children:d.name}),!d.confident&&e.jsx("span",{className:"text-[10px] text-fg-muted/60 italic",children:"ambiguous"})]}),d.hash&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(we,{className:"w-4 h-4 text-fg-muted flex-shrink-0"}),e.jsx("span",{className:"text-[11px] font-mono text-fg-muted truncate",children:d.hash.length>16?`${d.hash.slice(0,16)}…${d.hash.slice(-8)}`:d.hash.startsWith("0x")?d.hash.slice(2,10)+"…":d.hash.slice(0,8)+"…"})]})]})]}),ne&&e.jsxs("div",{className:"radius-inset bg-subtle-fill overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-b border-edge-subtle",children:[e.jsx("span",{className:"type-micro text-fg-muted",children:"Sender Identity"}),e.jsx(B,{color:d!=null&&d.isRepeater?"blue":d!=null&&d.isCompanion?"violet":(d==null?void 0:d.type)==="room_server"?"lime":"amber",compact:!0,children:d!=null&&d.type&&d.type!=="unknown"?d.type==="room_server"?"room server":d.type:"companion"})]}),e.jsxs("div",{className:"p-4 space-y-2.5",children:[(d==null?void 0:d.name)&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ce,{className:"w-4 h-4 text-fg-muted flex-shrink-0"}),e.jsx("span",{className:"type-label text-fg-primary truncate",children:d.name}),!d.confident&&e.jsx("span",{className:"text-[10px] text-fg-muted/60 italic",children:"ambiguous"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(de,{className:"w-4 h-4 text-fg-muted flex-shrink-0"}),e.jsxs("span",{className:"text-xs text-fg-muted",children:["Dest: ",e.jsx("span",{className:"font-mono",children:ne.destHash})]})]}),e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(we,{className:"w-4 h-4 text-fg-muted flex-shrink-0 mt-0.5"}),e.jsx("span",{className:"text-[11px] font-mono text-fg-muted break-all leading-relaxed",children:ne.senderPublicKey})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(xe,{className:"w-4 h-4 text-fg-muted flex-shrink-0"}),e.jsxs("span",{className:"text-xs text-fg-muted",children:[ne.ciphertextLength,"B encrypted payload"]})]})]})]}),_&&e.jsxs("div",{className:"radius-inset bg-subtle-fill overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-b border-edge-subtle",children:[e.jsx("span",{className:"type-micro text-fg-muted",children:"Advertiser"}),e.jsx(B,{color:"lime",compact:!0,children:_.nodeType})]}),e.jsxs("div",{className:"p-4 space-y-2.5",children:[_.name&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ce,{className:"w-4 h-4 text-fg-muted flex-shrink-0"}),e.jsx("span",{className:"type-label text-fg-primary truncate",children:_.name})]}),_.latitude&&_.longitude&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ue,{className:"w-4 h-4 text-fg-muted flex-shrink-0"}),e.jsxs("span",{className:"type-data-xs text-fg-secondary",children:[_.latitude.toFixed(5),", ",_.longitude.toFixed(5)]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(we,{className:"w-4 h-4 text-fg-muted flex-shrink-0"}),e.jsxs("span",{className:"text-[11px] font-mono text-fg-muted truncate",children:[_.publicKey.slice(0,16),"...",_.publicKey.slice(-8)]})]}),_.timestamp>0&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(xe,{className:"w-4 h-4 text-fg-muted flex-shrink-0"}),e.jsx("span",{className:"text-xs text-fg-muted",children:Le(_.timestamp)})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(de,{className:"w-4 h-4 text-fg-muted flex-shrink-0"}),e.jsx("span",{className:"text-[11px] text-fg-muted",children:_.flagsDescription||`Flags: 0x${_.flags.toString(16).padStart(2,"0")}`})]})]})]}),z&&z.pathHashes.length>0&&e.jsxs("div",{className:"radius-inset bg-black overflow-hidden",children:[e.jsxs("div",{className:"px-4 py-2 flex items-center justify-between",children:[e.jsx("span",{className:"type-micro text-fg-muted",children:"Trace Route"}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(B,{color:z.isComplete?"green":"amber",compact:!0,children:z.isComplete?"Complete":"In Progress"}),e.jsxs(B,{color:"teal",compact:!0,children:[z.pathHashes.length,"h"]})]})]}),e.jsx(Se,{packet:h,neighbors:M,localHash:k==null?void 0:k.local_hash,neighborAffinity:H,ghostPrefixes:W,direction:"flowchart",compact:!0,overridePath:z.pathHashes,traceSnr:z.snrValues})]}),O&&!z&&e.jsxs("div",{className:"radius-inset bg-black overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-2",children:[e.jsx("span",{className:"type-micro text-fg-muted",children:"Path"}),e.jsxs(B,{color:"zinc",compact:!0,children:[$.length,"h"]})]}),e.jsx(Se,{packet:h,neighbors:M,localHash:k==null?void 0:k.local_hash,neighborAffinity:H,ghostPrefixes:W,direction:"flowchart",compact:!0,traceSnr:ae})]})]})]})]})]})]})}const Un=p.memo($n);function Bt({label:t,numericValue:n,unit:s,icon:a,subtext:r,showSign:i=!1}){return e.jsxs("div",{className:"radius-inner p-3 sm:radius-inset sm:p-4 bg-subtle-fill ring-1 ring-inset ring-edge-subtle",children:[e.jsx("div",{className:"mb-1.5 sm:mb-2",children:e.jsx("span",{className:"text-xs sm:type-micro text-fg-muted",children:t})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(tt,{value:n,format:{minimumFractionDigits:1,maximumFractionDigits:1,signDisplay:i?"always":"auto"},className:"type-data-hero tracking-tight text-fg-primary"}),e.jsxs("div",{className:"flex flex-col items-center justify-center",children:[e.jsx(a,{className:"w-[14px] h-[14px] text-fg-muted"}),s&&e.jsx("span",{className:"text-xs font-medium leading-tight text-fg-muted",children:s})]})]}),r&&e.jsx("p",{className:"mt-1.5 sm:mt-2 type-data-xs sm:text-[11px] text-fg-muted/80 truncate",children:r})]})}function Vn({snr:t}){const n=t>=5?"bg-sys-teal":t>=0?"bg-sys-green":t>=-5?"bg-sys-amber":t>=-10?"bg-sys-orange":"bg-sys-red";return e.jsx("span",{className:R("w-1.5 h-1.5 rounded-full flex-shrink-0",n),title:`SNR: ${t.toFixed(1)} dB`})}function Lt({fromPrefix:t,toPrefix:n,fromName:s,toName:a,snr:r,maxSnr:i,isWeakest:l,isStrongest:c,index:o=0}){const x=Math.max(i+5,15),g=Math.max(0,Math.min(100,(r- -20)/(x- -20)*100)),f="bg-[#0074BE]",y=r>=5?"bg-sys-teal":r>=0?"bg-sys-green":r>=-5?"bg-sys-amber":r>=-10?"bg-sys-orange":"bg-sys-red",m=.3+o*.15;return e.jsxs("div",{className:"relative p-3 pl-5 radius-inner bg-subtle-fill ring-1 ring-inset ring-edge-subtle",children:[e.jsx("span",{className:R("absolute left-0 top-1/2 -translate-y-1/2 h-4 w-0.5 rounded-full",y)}),e.jsx("span",{className:"absolute -top-0.5 -right-0.5",children:e.jsx(Vn,{snr:r})}),e.jsxs("div",{className:"sm:hidden",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[e.jsx("span",{className:"text-[13px] font-medium text-fg-secondary truncate",children:s||t}),e.jsx(pe,{className:"w-3 h-3 text-fg-muted flex-shrink-0"}),e.jsx("span",{className:"text-[13px] font-semibold text-fg-primary truncate",children:a||n})]}),e.jsxs("div",{className:"flex items-center gap-1.5 ml-2 flex-shrink-0",children:[l&&e.jsx(B,{color:"red",compact:!0,children:"Low"}),c&&!l&&e.jsxs(B,{color:"amber",compact:!0,children:[e.jsx(wt,{className:"w-2.5 h-2.5"}),"Best"]}),e.jsxs("span",{className:"inline-flex items-center px-1.5 py-0.5 rounded text-[12px] font-mono font-bold tabular-nums bg-subtle-fill-hover text-fg-primary ring-1 ring-inset ring-edge-subtle",children:[r>=0?"+":"−",Math.abs(r).toFixed(1)]})]})]}),e.jsx("div",{className:"h-1.5 bg-subtle-fill-strong rounded-full overflow-hidden",children:e.jsx(oe.div,{className:R("h-full rounded-full",f),initial:{width:0},animate:{width:`${g}%`},transition:{duration:1.5,delay:m,ease:[.25,.1,.25,1]}})})]}),e.jsxs("div",{className:"hidden sm:block",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[e.jsx("code",{className:"type-data-xs text-fg-muted",children:t}),s&&e.jsx("span",{className:"text-xs text-fg-secondary truncate max-w-[100px]",children:s})]}),e.jsx(pe,{className:"w-3 h-3 text-fg-muted/40 flex-shrink-0"}),e.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[e.jsx("code",{className:"font-mono text-xs font-semibold text-fg-primary",children:n}),a&&e.jsx("span",{className:"text-xs text-fg-secondary truncate max-w-[100px]",children:a})]})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[l&&e.jsx(B,{color:"red",compact:!0,children:"Bottleneck"}),c&&!l&&e.jsxs(B,{color:"amber",compact:!0,children:[e.jsx(wt,{className:"w-3 h-3"}),"Strongest"]}),e.jsxs("span",{className:"inline-flex items-center px-2 py-0.5 rounded text-sm font-mono font-semibold tabular-nums bg-subtle-fill-hover text-fg-primary ring-1 ring-inset ring-edge-subtle",children:[r>=0?"+":"−",Math.abs(r).toFixed(1)]})]})]}),e.jsx("div",{className:"h-1.5 bg-elevated rounded-full overflow-hidden",children:e.jsx(oe.div,{className:R("h-full rounded-full",f),initial:{width:0},animate:{width:`${g}%`},transition:{duration:1.5,delay:m,ease:[.25,.1,.25,1]}})})]})]})}function ye(t,n){if(t==="You")return"You";const s=t.toUpperCase();for(const[a,r]of Object.entries(n))if((a.startsWith("0x")?a.slice(2,4):a.slice(0,2)).toUpperCase()===s)return r.name||r.node_name||void 0}function Wn({report:t,onClose:n}){var u,x;const s=Ht(),a=(s==null?void 0:s.neighbors)??{},r=(u=s==null?void 0:s.config)!=null&&u.repeater?{latitude:s.config.repeater.latitude,longitude:s.config.repeater.longitude,name:s.config.node_name||"Local Node"}:void 0,i=(x=t.bestObservation)==null?void 0:x.decoded.snrValues,l=t.linkQuality?t.linkQuality.avgSnr>=5?"excellent":t.linkQuality.avgSnr>=0?"good":t.linkQuality.avgSnr>=-5?"fair":"poor":"unknown",o={excellent:"var(--signal-excellent)",good:"var(--signal-good)",fair:"var(--signal-fair)",poor:"var(--signal-poor)",unknown:"var(--fg-muted)"}[l];return e.jsxs(Ot,{open:!0,onClose:n,size:"5xl",motionPlus:!0,children:[e.jsxs("div",{className:"sm:hidden",children:[e.jsx("div",{className:"flex justify-center pt-2 pb-1",children:e.jsx("div",{className:"w-9 h-1 rounded-full bg-fg-primary/30","aria-hidden":"true"})}),e.jsxs("div",{className:"flex items-center justify-between px-4 pb-2",children:[e.jsx("h2",{className:"font-semibold text-[17px] text-fg-primary",children:"Trace Report"}),e.jsx("button",{onClick:n,className:"text-[17px] font-medium text-sys-blue active:text-sys-blue/80",children:"Done"})]})]}),e.jsx("div",{className:"sm:hidden h-[2px]",style:{backgroundColor:o,opacity:.6}}),e.jsx("div",{className:"hidden sm:block px-6 pt-5 pb-4",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 sm:gap-3",children:[e.jsx("h2",{className:"type-micro",children:"Trace Report"}),e.jsxs(B,{color:l==="excellent"||l==="good"?"green":l==="fair"?"amber":"red",children:[e.jsx(vt,{className:"w-3 h-3 mr-1"}),l==="excellent"?"Excellent":l==="good"?"Good":l==="fair"?"Fair":"Poor"]})]}),e.jsx("p",{className:"mt-1 text-xs sm:text-sm font-mono text-fg-muted tabular-nums",children:t.traceTag})]}),e.jsx("button",{onClick:n,className:"p-1.5 -m-1.5 text-fg-muted hover:text-fg-primary transition-base radius-inner hover:bg-elevated flex-shrink-0",children:e.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]})}),e.jsxs("div",{className:"hidden sm:flex flex-wrap items-center gap-1.5 sm:gap-2 px-4 sm:px-6 pb-3 sm:pb-4 border-b border-edge-subtle",children:[e.jsxs(B,{color:"teal",children:[e.jsx("span",{className:"font-mono tabular-nums",children:t.targetHopCount}),e.jsxs("span",{className:"ml-1",children:["hop",t.targetHopCount!==1?"s":""]})]}),e.jsxs(B,{color:"zinc",children:[e.jsx("span",{className:"font-mono tabular-nums",children:t.observationCount}),e.jsx("span",{className:"ml-1",children:"obs"})]}),t.linkQuality&&e.jsxs(B,{color:"indigo",children:[e.jsx("span",{className:"font-mono tabular-nums",children:t.linkQuality.avgSnr.toFixed(1)}),e.jsx("span",{className:"ml-1",children:"dB avg"})]}),e.jsx("span",{className:"type-data-xs text-fg-muted",children:Fs(t.duration)}),t.linkQuality&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-fg-muted/40",children:"•"}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-xs font-medium bg-sys-red/15 text-sys-red ring-1 ring-inset ring-sys-red/25",children:[e.jsx("span",{className:"opacity-70",children:"Min"}),e.jsx("span",{className:"font-mono tabular-nums",children:t.linkQuality.minSnr.toFixed(1)})]}),e.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-xs font-medium bg-sys-teal/15 text-sys-teal ring-1 ring-inset ring-sys-teal/25",children:[e.jsx("span",{className:"opacity-70",children:"Max"}),e.jsx("span",{className:"font-mono tabular-nums",children:t.linkQuality.maxSnr.toFixed(1)})]})]})]})]}),e.jsxs($t,{className:"p-0 overflow-hidden",children:[e.jsx("div",{className:"md:hidden h-[75vh] max-h-[calc(100vh-80px)] overflow-y-auto overflow-x-hidden",children:e.jsxs("div",{className:"px-4 py-3 space-y-3",children:[t.linkQuality&&e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"radius-inner bg-subtle-fill ring-1 ring-inset ring-edge-subtle p-2.5 text-center",children:[e.jsx(tt,{value:Math.abs(t.linkQuality.minSnr),format:{maximumFractionDigits:0,signDisplay:"never"},prefix:t.linkQuality.minSnr<0?"-":"",className:"text-[20px] font-bold font-mono tabular-nums flex items-center justify-center text-fg-primary"}),e.jsxs("div",{className:"flex items-center justify-center gap-1 mt-1",children:[e.jsx(et,{className:"w-2.5 h-2.5 text-fg-muted"}),e.jsx("span",{className:"text-xs text-fg-muted",children:"Min dB"})]})]}),e.jsxs("div",{className:"radius-inner bg-subtle-fill ring-1 ring-inset ring-edge-subtle p-2.5 text-center",children:[e.jsx(tt,{value:t.linkQuality.maxSnr,format:{maximumFractionDigits:0,signDisplay:"always"},className:"text-[20px] font-bold font-mono text-fg-primary tabular-nums flex items-center justify-center"}),e.jsxs("div",{className:"flex items-center justify-center gap-1 mt-1",children:[e.jsx(ft,{className:"w-2.5 h-2.5 text-fg-muted"}),e.jsx("span",{className:"text-xs text-fg-muted",children:"Max dB"})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs(B,{color:l==="excellent"||l==="good"?"green":l==="fair"?"amber":"red",compact:!0,children:[e.jsx(vt,{className:"w-2.5 h-2.5 mr-0.5"}),l==="excellent"?"Excellent":l==="good"?"Good":l==="fair"?"Fair":"Poor"]}),e.jsxs(B,{color:"teal",compact:!0,children:[t.targetHopCount," hops"]}),e.jsxs(B,{color:"zinc",compact:!0,children:[t.observationCount," obs"]}),e.jsx("span",{className:"type-data-xs text-fg-muted ml-auto",children:t.traceTag.slice(0,8)})]}),t.targetPath.length>0&&e.jsx("div",{className:"overflow-hidden radius-inset",children:e.jsx("div",{className:"aspect-[4/3] w-full",children:e.jsx(We,{path:t.targetPath,neighbors:a,localNode:r,localHash:s==null?void 0:s.local_hash,srcHash:t.srcHash,dstHash:t.dstHash,traceSnr:i})})}),e.jsxs("div",{className:"radius-inset bg-body overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-2 border-b border-edge-subtle",children:[e.jsx("span",{className:"text-[11px] font-medium text-fg-secondary",children:"Route Path"}),t.linkQuality&&e.jsxs("span",{className:"type-data-xs text-fg-muted",children:["SNR ",t.linkQuality.minSnr.toFixed(1)," → ",t.linkQuality.maxSnr.toFixed(1)," dB"]})]}),t.bestObservation?e.jsx(Se,{packet:t.bestObservation.packet,neighbors:a,localHash:s==null?void 0:s.local_hash,direction:"flowchart",compact:!0,overridePath:t.targetPath,traceSnr:t.bestObservation.decoded.snrValues}):e.jsx("div",{className:"p-6 text-center text-fg-muted text-xs",children:"No path data available"})]}),e.jsxs("div",{children:[e.jsxs("h3",{className:"type-micro text-fg-muted mb-2",children:["Link Quality · ",t.hopStats.length," hops"]}),e.jsx("div",{className:"space-y-1.5",children:t.hopStats.length>0?t.hopStats.map((g,f)=>{var T,h,N;const y=f{const g=t.targetPath[t.linkQuality.weakestLinkPosition],f=t.targetPath[t.linkQuality.weakestLinkPosition+1]||"You",y=ye(g,a),m=ye(f,a),v=t.targetPath[t.linkQuality.strongestLinkPosition],T=t.targetPath[t.linkQuality.strongestLinkPosition+1]||"You",h=ye(v,a),N=ye(T,a);return e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(Bt,{label:"Weakest Link",numericValue:t.linkQuality.minSnr,unit:"dB",icon:et,subtext:`${y||g} → ${m||f}`}),e.jsx(Bt,{label:"Best Link",numericValue:t.linkQuality.maxSnr,showSign:!0,unit:"dB",icon:ft,subtext:`${h||v} → ${N||T}`})]})})(),e.jsxs("div",{children:[e.jsx("h3",{className:"type-micro text-fg-muted mb-3",children:"Link Details"}),e.jsx("div",{className:"space-y-2",children:t.hopStats.length>0?t.hopStats.map((g,f)=>{var T,h,N;const y=f0&&e.jsx("div",{className:"overflow-hidden",children:e.jsx("div",{className:"aspect-square w-full",children:e.jsx(We,{path:t.targetPath,neighbors:a,localNode:r,localHash:s==null?void 0:s.local_hash,srcHash:t.srcHash,dstHash:t.dstHash,traceSnr:i})})}),e.jsxs("div",{className:"radius-inset bg-black overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-3",children:[e.jsx("span",{className:"type-micro text-fg-muted",children:"Trace Route"}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(B,{color:t.isComplete?"green":"amber",compact:!0,children:t.isComplete?"Complete":`${t.maxHopsObserved}/${t.targetHopCount}`}),e.jsxs(B,{color:"teal",compact:!0,children:[t.targetHopCount," hop",t.targetHopCount!==1?"s":""]})]})]}),t.linkQuality&&t.bestObservation&&e.jsxs("div",{className:"flex items-center gap-4 px-4 pb-2 type-data-xs text-fg-muted",children:[e.jsxs("span",{children:[e.jsx("span",{className:"opacity-60",children:"Tag"})," ",e.jsx("code",{className:"text-sys-teal tabular-nums",children:t.traceTag.slice(0,8)})]}),e.jsxs("span",{children:[e.jsx("span",{className:"opacity-60",children:"SNR"})," ",e.jsxs("code",{className:"text-sys-indigo tabular-nums",children:[t.linkQuality.minSnr.toFixed(1),"–",t.linkQuality.maxSnr.toFixed(1)]}),e.jsx("span",{className:"opacity-60",children:" dB"})]})]}),t.bestObservation?e.jsx(Se,{packet:t.bestObservation.packet,neighbors:a,localHash:s==null?void 0:s.local_hash,direction:"flowchart",compact:!0,overridePath:t.targetPath,traceSnr:t.bestObservation.decoded.snrValues}):e.jsx("div",{className:"p-8 text-center text-fg-muted text-xs",children:"No path data available"})]})]})]})]})]})}const Gn=p.memo(Wn),ns=[{target:"PacketList",fn:"type",minStage:1},{target:"PacketList",fn:"route",minStage:1},{target:"PacketList",fn:"rssi",minStage:1},{target:"PacketList",fn:"snr",minStage:1},{target:"PacketList",fn:"path",minStage:1,when:Us},{target:"PacketList",fn:"src_hash",minStage:1,when:Vs},{target:"PacketList",fn:"text",minStage:1,when:Ws},{target:"PacketList",fn:"ack",minStage:1,when:Gs},{target:"PacketList",fn:"decrypt",minStage:2,when:Qs},{target:"PacketList",fn:"duplicates",minStage:1}];$s(ns);const Qn=48,qn=72,Kn=100,Yn=5,Xn=600,rs="(min-width: 640px)";let he=null;function Zn(t){return typeof window>"u"?()=>{}:(he||(he=window.matchMedia(rs)),he.addEventListener("change",t),()=>he==null?void 0:he.removeEventListener("change",t))}function Jn(){return typeof window>"u"?!0:(he||(he=window.matchMedia(rs)),he.matches)}function er(){return p.useSyncExternalStore(Zn,Jn,()=>!0)}function tr(t,n,s){const[a,r]=p.useState(1),i=s?Math.ceil(t/n):1;p.useEffect(()=>{a>i&&i>0&&queueMicrotask(()=>r(1))},[i,a]);const l=p.useCallback(o=>r(Math.max(1,Math.min(o,i))),[i]),c=p.useMemo(()=>$a(a,i),[a,i]);return{currentPage:a,totalPages:i,goToPage:l,pageRange:c}}function sr(t,n){const[s,a]=p.useState(null),r=p.useRef(0);return p.useEffect(()=>{var x,g;if(!n||!t.length)return;const i=((x=t[0])==null?void 0:x.timestamp)??0,l=i>r.current&&r.current>0;if(r.current=i,!l)return;const c=(g=t[0])==null?void 0:g.packet_hash;if(!c)return;const o=requestAnimationFrame(()=>a(c)),u=setTimeout(()=>a(null),600);return()=>{cancelAnimationFrame(o),clearTimeout(u)}},[t,n]),s}function ar(t){if(!t||t.length<6)return null;const n=t,s=parseInt(n.slice(0,2),16);if(isNaN(s))return null;const a=s&3;let r=2;if((a===0||a===3)&&(r=10),r+2>n.length)return null;const i=parseInt(n.slice(r,r+2),16);if(isNaN(i)||(r+=2+i*2,r>=n.length))return null;const l=n.slice(r);return l.length>=38?l.slice(0,38):l}function nr(t){if(t.length<=1)return t;const n=new Map,s=new Map,a=new Map;for(let l=0;l0?{packet:t[l].packet,dupeCount:t[l].dupeCount+c}:t[l])}return i}function rr(t){const n=new Map;for(const s of t)if((s.payload_type??s.type)===lt.TRACE&&s.packet_hash){const r=s._traceTag??(s.payload?Ut(s.payload):null);r&&n.set(s.packet_hash,r)}return n}function ir(t){const n=new Map;if(t.length===0)return n;for(let s=0;sw.setModalMapOpen);p.useEffect(()=>(W(!!N),()=>W(!1)),[N,W]),p.useLayoutEffect(()=>{A({traceTag:null,dupeGroup:null})},[t]);const K=n??t,F=p.useMemo(()=>i&&i>0&&!y?t.slice(0,i):t,[t,i,y]),Y=p.useMemo(()=>{if(!y)return null;const w=Ua(F),S=nr(w);return i&&i>0?S.slice(0,i):S},[F,y,i]),D=Y?Y.length:F.length,{currentPage:E,totalPages:O,goToPage:$,pageRange:J}=tr(D,l,c),M=p.useMemo(()=>{if(y||!c)return F;const w=(E-1)*l;return F.slice(w,w+l)},[F,c,E,l,y]),H=p.useMemo(()=>{if(!Y)return null;if(!c)return Y;const w=(E-1)*l;return Y.slice(w,w+l)},[Y,c,E,l]),te=p.useMemo(()=>rr(M),[M]),se=p.useMemo(()=>ir(M),[M]),d=sr(t,u),Z=er(),q=p.useMemo(()=>y&&H?H:M,[y,H,M]),le=h&&q.length>Kn,P=Z?Qn:qn,z=ga({count:le?q.length:0,getScrollElement:()=>U.current,estimateSize:()=>P,overscan:Yn}),ae=p.useCallback((w,S)=>{var ve,Fe;const L=w.packet_hash;if(!L)return[w];let I=S;for(;I>0&&((ve=M[I-1])==null?void 0:ve.packet_hash)===L;)I--;let Q=S;for(;Q{var I,Q;const S=(I=M[w])==null?void 0:I.packet_hash;if(!S)return w;let L=w;for(;L>0&&((Q=M[L-1])==null?void 0:Q.packet_hash)===S;)L--;return L},[M]),ce=p.useCallback(w=>{var I,Q;const S=(I=M[w])==null?void 0:I.packet_hash;if(!S)return w;let L=w;for(;L{if(o){o(w);return}if(S!==void 0){const L=ae(w,S),I=L.indexOf(w);j({packets:L,initialIndex:I>=0?I:0,rowIndex:S})}else j({packets:[w],initialIndex:0,rowIndex:0})},[o,ae]),ne=p.useCallback(()=>{if(!N)return;const S=_(N.rowIndex)-1;if(S<0)return;const L=M[S];if(!L)return;const I=ae(L,S);j({packets:I,initialIndex:0,rowIndex:S})},[N,M,_,ae]),Le=p.useCallback(()=>{if(!N)return;const S=ce(N.rowIndex)+1;if(S>=M.length)return;const L=M[S];if(!L)return;const I=ae(L,S);j({packets:I,initialIndex:0,rowIndex:S})},[N,M,ce,ae]),dt=p.useMemo(()=>N?_(N.rowIndex)>0:!1,[N,_]),xt=p.useMemo(()=>N?ce(N.rowIndex)A(S=>({...S,traceTag:w})),[]),Qe=p.useCallback(w=>A(S=>({...S,dupeGroup:w})),[]),Re=p.useCallback(()=>{A({traceTag:null,dupeGroup:null})},[]),Ne=p.useCallback(w=>{const S=K.filter(Q=>(Q.payload_type??Q.type)===lt.TRACE&&Q.payload&&Ut(Q.payload)===w);if(S.length===0)return;const I=Ds(S).get(w);I!=null&&I.length&&k(Hs(w,I))},[K]),qe=p.useCallback(w=>{const S=K.find(L=>L.packet_hash===w);S&&(k(null),fe(S))},[K,fe]),Ee=p.useCallback((w,S,L)=>{const I=Z?Xa:Za;if(L){const{packet:ge,dupeCount:ls}=w,ht=ge.packet_hash?te.get(ge.packet_hash):void 0,cs=b.traceTag!==null&&ht===b.traceTag;return e.jsx(I,{packet:ge,onClick:os=>fe(os,S),localHash:s,neighbors:a,resolveSource:T,isFlashing:u&&d===ge.packet_hash,traceTag:ht,isTraceHighlighted:cs,onTraceHover:be,onViewTraceReport:Ne,dupeCount:ls,getDecodedContent:m,onChannelClick:v},`${ge.packet_hash}_${ge.timestamp}_${S}`)}const Q=w,ve=Q.packet_hash?te.get(Q.packet_hash):void 0,Fe=b.traceTag!==null&&ve===b.traceTag,mt=se.get(S),is=mt!==void 0&&b.dupeGroup!==null&&Q.packet_hash===b.dupeGroup;return e.jsx(I,{packet:Q,onClick:ge=>fe(ge,S),localHash:s,neighbors:a,resolveSource:T,isFlashing:u&&d===Q.packet_hash,traceTag:ve,isTraceHighlighted:Fe,onTraceHover:be,onViewTraceReport:Ne,dupeGroupPosition:mt,isDupeGroupHovered:is,onDupeGroupHover:Qe,getDecodedContent:m,onChannelClick:v},`${Q.packet_hash}_${Q.timestamp}_${S}`)},[Z,te,b.traceTag,b.dupeGroup,fe,s,a,T,u,d,be,Ne,se,Qe,m,v]),ze=()=>{if(r&&t.length===0)return e.jsx(Et,{});if(M.length===0)return e.jsx(Rt,{message:x});const w=y&&H!==null;return(w?H:M).map((L,I)=>Ee(L,I,w))},G=()=>{if(r&&t.length===0)return e.jsx(Et,{});if(q.length===0)return e.jsx(Rt,{message:x});const w=y&&H!==null,S=z.getVirtualItems();return e.jsx("div",{style:{height:`${z.getTotalSize()}px`,width:"100%",position:"relative"},children:S.map(L=>{const I=q[L.index];return e.jsx("div",{"data-index":L.index,ref:z.measureElement,style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${L.start}px)`},children:Ee(I,L.index,w)},L.key)})})};return e.jsxs("div",{className:R("flex flex-col",g),onMouseLeave:Re,children:[le?e.jsx("div",{ref:U,className:"divide-y divide-edge-subtle overflow-auto",style:{maxHeight:Xn},children:G()}):e.jsx("div",{className:"divide-y divide-edge-subtle py-1",children:ze()}),c&&O>1&&e.jsx("nav",{className:"border-t border-edge-subtle px-4 py-3",children:e.jsxs(Fa,{className:"justify-center",children:[e.jsx(Ia,{onClick:()=>$(E-1),disabled:E===1}),e.jsx(Da,{children:J.map((w,S)=>w==="gap"?e.jsx(Oa,{},`gap-${S}`):e.jsx(Ha,{page:w,current:w===E,onClick:$},w))}),e.jsx(Aa,{onClick:()=>$(E+1),disabled:E===O})]})}),e.jsx(lr,{showPagination:c,currentPage:E,perPage:l,displayCount:H?H.length:M.length,totalCount:c?D:t.length,action:f}),!o&&N&&e.jsx(Un,{packets:N.packets,initialIndex:N.initialIndex,onClose:()=>j(null),onNavigatePrev:ne,onNavigateNext:Le,hasPrev:dt,hasNext:xt,resolveSource:T,getDecodedContent:m}),C&&e.jsx(Gn,{report:C,onClose:()=>k(null),onViewPacket:qe})]})}export{ts as C,Br as P,vt as S,wt as T,Tr as a,ga as b,Ga as g,Pr as u}; diff --git a/frontend/dist/assets/PacketList-Dd7PQV7H.js b/frontend/dist/assets/PacketList-Dd7PQV7H.js new file mode 100644 index 00000000..7aa1bb18 --- /dev/null +++ b/frontend/dist/assets/PacketList-Dd7PQV7H.js @@ -0,0 +1,66 @@ +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/PathMapMapLibre-AZaGoHLu.js","assets/index-DhkG1Nx9.js","assets/BasemapLayer-CfNeG6Jg.js","assets/useMapViewStore-BMqcaUNl.js","assets/index-Bx_G2nLG.js","assets/index-DySMpv2s.css","assets/BasemapLayer-B1CfjdFi.css"])))=>i.map(i=>d[i]); +import{r as p,aG as ds,d as he,bg as xs,bh as zt,bi as hs,bj as ms,j as e,c as R,B as rt,e as us,z as it,v as B,bk as Ft,R as de,bl as It,bm as At,bn as Ht,bo as ue,bp as Ze,a2 as He,_ as ps,bq as fs,br as gs,bs as ys,bt as js,m as oe,ab as re,y as bs,bu as Ns,bv as ie,bw as ut,bx as vs,by as ws,bz as ks,bA as Cs,bB as Ss,bC as _s,bD as Je,bE as Ms,a7 as Ts,G as Dt,bF as Ps,bG as Bs,bH as Ls,bI as Rs,ag as Ot,ah as $t,A as Ke,bJ as Es,ai as zs,bK as Fs,bL as lt}from"./index-DhkG1Nx9.js";import{p as Is,d as As,e as Ut,g as Hs,b as Ds}from"./primitives-nqGDyTiB.js";import{u as Os,r as $s,a as Us,b as Vs,c as Ws,d as Gs,i as Qs}from"./consumer-registry-CTQIn0m9.js";import{D as Pe,R as De,P as Be,g as qs}from"./badge-colors-BNUqIXCA.js";import{g as Vt,e as _e,a as Wt}from"./chat-utils-DA-kxQ-o.js";import{P as Gt,d as Qt,a as Ks,b as Ys}from"./payload-decoders-DC2sHkKr.js";import{A as pe,S as Oe,i as $e,C as xe,a as Xs,g as pt}from"./SignalIndicator-DEXVYOhU.js";import{a as Zs,A as qt}from"./arrow-up-Bg1A345J.js";import{C as ct}from"./chevron-right-na13OQfy.js";import{M as Ue}from"./map-pin-BHGohRD7.js";import{C as Js}from"./circle-question-mark--xh93QHC.js";import{T as et}from"./triangle-alert-D8NErBXC.js";import{D as X}from"./DataBox-BMesbbaF.js";import{L as en}from"./layers-BxF7oyms.js";import{H as Kt}from"./hash-KLxvul5e.js";import{A as tn}from"./activity-BG24yKp1.js";import{C as sn}from"./circle-check-DJNUSJlu.js";import{D as nn}from"./database-DE8k8U0g.js";import{H as an,D as tt,Z as ft,u as rn}from"./useMapViewStore-BMqcaUNl.js";import{S as we}from"./shield-XXZtlreW.js";import{C as Yt}from"./TimeRangeStepper-RSPVaByt.js";function ke(t,a,s){let n=s.initialDeps??[],r,i=!0;function l(){var c,o,u;let x;s.key&&((c=s.debug)!=null&&c.call(s))&&(x=Date.now());const g=t();if(!(g.length!==n.length||g.some((h,v)=>n[v]!==h)))return r;n=g;let y;if(s.key&&((o=s.debug)!=null&&o.call(s))&&(y=Date.now()),r=a(...g),s.key&&((u=s.debug)!=null&&u.call(s))){const h=Math.round((Date.now()-x)*100)/100,v=Math.round((Date.now()-y)*100)/100,T=v/16,m=(N,j)=>{for(N=String(N);N.length{n=c},l}function gt(t,a){if(t===void 0)throw new Error("Unexpected undefined");return t}const ln=(t,a)=>Math.abs(t-a)<1.01,cn=(t,a,s)=>{let n;return function(...r){t.clearTimeout(n),n=t.setTimeout(()=>a.apply(this,r),s)}},yt=t=>{const{offsetWidth:a,offsetHeight:s}=t;return{width:a,height:s}},on=t=>t,dn=t=>{const a=Math.max(t.startIndex-t.overscan,0),s=Math.min(t.endIndex+t.overscan,t.count-1),n=[];for(let r=a;r<=s;r++)n.push(r);return n},xn=(t,a)=>{const s=t.scrollElement;if(!s)return;const n=t.targetWindow;if(!n)return;const r=l=>{const{width:c,height:o}=l;a({width:Math.round(c),height:Math.round(o)})};if(r(yt(s)),!n.ResizeObserver)return()=>{};const i=new n.ResizeObserver(l=>{const c=()=>{const o=l[0];if(o!=null&&o.borderBoxSize){const u=o.borderBoxSize[0];if(u){r({width:u.inlineSize,height:u.blockSize});return}}r(yt(s))};t.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(c):c()});return i.observe(s,{box:"border-box"}),()=>{i.unobserve(s)}},jt={passive:!0},bt=typeof window>"u"?!0:"onscrollend"in window,hn=(t,a)=>{const s=t.scrollElement;if(!s)return;const n=t.targetWindow;if(!n)return;let r=0;const i=t.options.useScrollendEvent&&bt?()=>{}:cn(n,()=>{a(r,!1)},t.options.isScrollingResetDelay),l=x=>()=>{const{horizontal:g,isRtl:f}=t.options;r=g?s.scrollLeft*(f&&-1||1):s.scrollTop,i(),a(r,x)},c=l(!0),o=l(!1);s.addEventListener("scroll",c,jt);const u=t.options.useScrollendEvent&&bt;return u&&s.addEventListener("scrollend",o,jt),()=>{s.removeEventListener("scroll",c),u&&s.removeEventListener("scrollend",o)}},mn=(t,a,s)=>{if(a!=null&&a.borderBoxSize){const n=a.borderBoxSize[0];if(n)return Math.round(n[s.options.horizontal?"inlineSize":"blockSize"])}return t[s.options.horizontal?"offsetWidth":"offsetHeight"]},un=(t,{adjustments:a=0,behavior:s},n)=>{var r,i;const l=t+a;(i=(r=n.scrollElement)==null?void 0:r.scrollTo)==null||i.call(r,{[n.options.horizontal?"left":"top"]:l,behavior:s})};class pn{constructor(a){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.currentScrollToIndex=null,this.measurementsCache=[],this.itemSizeCache=new Map,this.laneAssignments=new Map,this.pendingMeasuredCacheIndexes=[],this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this.elementsCache=new Map,this.observer=(()=>{let s=null;const n=()=>s||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:s=new this.targetWindow.ResizeObserver(r=>{r.forEach(i=>{const l=()=>{this._measureElement(i.target,i)};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(l):l()})}));return{disconnect:()=>{var r;(r=n())==null||r.disconnect(),s=null},observe:r=>{var i;return(i=n())==null?void 0:i.observe(r,{box:"border-box"})},unobserve:r=>{var i;return(i=n())==null?void 0:i.unobserve(r)}}})(),this.range=null,this.setOptions=s=>{Object.entries(s).forEach(([n,r])=>{typeof r>"u"&&delete s[n]}),this.options={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:on,rangeExtractor:dn,onChange:()=>{},measureElement:mn,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:"data-index",initialMeasurementsCache:[],lanes:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,...s}},this.notify=s=>{var n,r;(r=(n=this.options).onChange)==null||r.call(n,this,s)},this.maybeNotify=ke(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),s=>{this.notify(s)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(s=>s()),this.unsubs=[],this.observer.disconnect(),this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var s;const n=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==n){if(this.cleanup(),!n){this.maybeNotify();return}this.scrollElement=n,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=((s=this.scrollElement)==null?void 0:s.window)??null,this.elementsCache.forEach(r=>{this.observer.observe(r)}),this.unsubs.push(this.options.observeElementRect(this,r=>{this.scrollRect=r,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(r,i)=>{this.scrollAdjustments=0,this.scrollDirection=i?this.getScrollOffset()this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?"width":"height"]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset=="function"?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getFurthestMeasurement=(s,n)=>{const r=new Map,i=new Map;for(let l=n-1;l>=0;l--){const c=s[l];if(r.has(c.lane))continue;const o=i.get(c.lane);if(o==null||c.end>o.end?i.set(c.lane,c):c.endl.end===c.end?l.index-c.index:l.end-c.end)[0]:void 0},this.getMeasurementOptions=ke(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes],(s,n,r,i,l,c)=>(this.prevLanes!==void 0&&this.prevLanes!==c&&(this.lanesChangedFlag=!0),this.prevLanes=c,this.pendingMeasuredCacheIndexes=[],{count:s,paddingStart:n,scrollMargin:r,getItemKey:i,enabled:l,lanes:c}),{key:!1}),this.getMeasurements=ke(()=>[this.getMeasurementOptions(),this.itemSizeCache],({count:s,paddingStart:n,scrollMargin:r,getItemKey:i,enabled:l,lanes:c},o)=>{if(!l)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>s)for(const f of this.laneAssignments.keys())f>=s&&this.laneAssignments.delete(f);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMeasuredCacheIndexes=[]),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(f=>{this.itemSizeCache.set(f.key,f.size)}));const u=this.lanesSettling?0:this.pendingMeasuredCacheIndexes.length>0?Math.min(...this.pendingMeasuredCacheIndexes):0;this.pendingMeasuredCacheIndexes=[],this.lanesSettling&&this.measurementsCache.length===s&&(this.lanesSettling=!1);const x=this.measurementsCache.slice(0,u),g=new Array(c).fill(void 0);for(let f=0;f1){v=h;const C=g[v],k=C!==void 0?x[C]:void 0;T=k?k.end+this.options.gap:n+r}else{const C=this.options.lanes===1?x[f-1]:this.getFurthestMeasurement(x,f);T=C?C.end+this.options.gap:n+r,v=C?C.lane:f%this.options.lanes,this.options.lanes>1&&this.laneAssignments.set(f,v)}const m=o.get(y),N=typeof m=="number"?m:this.options.estimateSize(f),j=T+N;x[f]={index:f,start:T,size:N,end:j,key:y,lane:v},g[v]=f}return this.measurementsCache=x,x},{key:!1,debug:()=>this.options.debug}),this.calculateRange=ke(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(s,n,r,i)=>this.range=s.length>0&&n>0?fn({measurements:s,outerSize:n,scrollOffset:r,lanes:i}):null,{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=ke(()=>{let s=null,n=null;const r=this.calculateRange();return r&&(s=r.startIndex,n=r.endIndex),this.maybeNotify.updateDeps([this.isScrolling,s,n]),[this.options.rangeExtractor,this.options.overscan,this.options.count,s,n]},(s,n,r,i,l)=>i===null||l===null?[]:s({startIndex:i,endIndex:l,overscan:n,count:r}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=s=>{const n=this.options.indexAttribute,r=s.getAttribute(n);return r?parseInt(r,10):(console.warn(`Missing attribute name '${n}={index}' on measured element.`),-1)},this._measureElement=(s,n)=>{const r=this.indexFromElement(s),i=this.measurementsCache[r];if(!i)return;const l=i.key,c=this.elementsCache.get(l);c!==s&&(c&&this.observer.unobserve(c),this.observer.observe(s),this.elementsCache.set(l,s)),s.isConnected&&this.resizeItem(r,this.options.measureElement(s,n,this))},this.resizeItem=(s,n)=>{const r=this.measurementsCache[s];if(!r)return;const i=this.itemSizeCache.get(r.key)??r.size,l=n-i;l!==0&&((this.shouldAdjustScrollPositionOnItemSizeChange!==void 0?this.shouldAdjustScrollPositionOnItemSizeChange(r,l,this):r.start{if(!s){this.elementsCache.forEach((n,r)=>{n.isConnected||(this.observer.unobserve(n),this.elementsCache.delete(r))});return}this._measureElement(s,void 0)},this.getVirtualItems=ke(()=>[this.getVirtualIndexes(),this.getMeasurements()],(s,n)=>{const r=[];for(let i=0,l=s.length;ithis.options.debug}),this.getVirtualItemForOffset=s=>{const n=this.getMeasurements();if(n.length!==0)return gt(n[Xt(0,n.length-1,r=>gt(n[r]).start,s)])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if("scrollHeight"in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{const s=this.scrollElement.document.documentElement;return this.options.horizontal?s.scrollWidth-this.scrollElement.innerWidth:s.scrollHeight-this.scrollElement.innerHeight}},this.getOffsetForAlignment=(s,n,r=0)=>{if(!this.scrollElement)return 0;const i=this.getSize(),l=this.getScrollOffset();n==="auto"&&(n=s>=l+i?"end":"start"),n==="center"?s+=(r-i)/2:n==="end"&&(s-=i);const c=this.getMaxScrollOffset();return Math.max(Math.min(c,s),0)},this.getOffsetForIndex=(s,n="auto")=>{s=Math.max(0,Math.min(s,this.options.count-1));const r=this.measurementsCache[s];if(!r)return;const i=this.getSize(),l=this.getScrollOffset();if(n==="auto")if(r.end>=l+i-this.options.scrollPaddingEnd)n="end";else if(r.start<=l+this.options.scrollPaddingStart)n="start";else return[l,n];if(n==="end"&&s===this.options.count-1)return[this.getMaxScrollOffset(),n];const c=n==="end"?r.end+this.options.scrollPaddingEnd:r.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(c,n,r.size),n]},this.isDynamicMode=()=>this.elementsCache.size>0,this.scrollToOffset=(s,{align:n="start",behavior:r}={})=>{r==="smooth"&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size."),this._scrollToOffset(this.getOffsetForAlignment(s,n),{adjustments:void 0,behavior:r})},this.scrollToIndex=(s,{align:n="auto",behavior:r}={})=>{r==="smooth"&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size."),s=Math.max(0,Math.min(s,this.options.count-1)),this.currentScrollToIndex=s;let i=0;const l=10,c=u=>{if(!this.targetWindow)return;const x=this.getOffsetForIndex(s,u);if(!x){console.warn("Failed to get offset for index:",s);return}const[g,f]=x;this._scrollToOffset(g,{adjustments:void 0,behavior:r}),this.targetWindow.requestAnimationFrame(()=>{const y=()=>{if(this.currentScrollToIndex!==s)return;const h=this.getScrollOffset(),v=this.getOffsetForIndex(s,f);if(!v){console.warn("Failed to get offset for index:",s);return}ln(v[0],h)||o(f)};this.isDynamicMode()?this.targetWindow.requestAnimationFrame(y):y()})},o=u=>{this.targetWindow&&this.currentScrollToIndex===s&&(i++,ic(u)):console.warn(`Failed to scroll to index ${s} after ${l} attempts.`))};c(n)},this.scrollBy=(s,{behavior:n}={})=>{n==="smooth"&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size."),this._scrollToOffset(this.getScrollOffset()+s,{adjustments:void 0,behavior:n})},this.getTotalSize=()=>{var s;const n=this.getMeasurements();let r;if(n.length===0)r=this.options.paddingStart;else if(this.options.lanes===1)r=((s=n[n.length-1])==null?void 0:s.end)??0;else{const i=Array(this.options.lanes).fill(null);let l=n.length-1;for(;l>=0&&i.some(c=>c===null);){const c=n[l];i[c.lane]===null&&(i[c.lane]=c.end),l--}r=Math.max(...i.filter(c=>c!==null))}return Math.max(r-this.options.scrollMargin+this.options.paddingEnd,0)},this._scrollToOffset=(s,{adjustments:n,behavior:r})=>{this.options.scrollToFn(s,{behavior:r,adjustments:n},this)},this.measure=()=>{this.itemSizeCache=new Map,this.laneAssignments=new Map,this.notify(!1)},this.setOptions(a)}}const Xt=(t,a,s,n)=>{for(;t<=a;){const r=(t+a)/2|0,i=s(r);if(in)a=r-1;else return r}return t>0?t-1:0};function fn({measurements:t,outerSize:a,scrollOffset:s,lanes:n}){const r=t.length-1,i=o=>t[o].start;if(t.length<=n)return{startIndex:0,endIndex:r};let l=Xt(0,r,i,s),c=l;if(n===1)for(;c1){const o=Array(n).fill(0);for(;cx=0&&u.some(x=>x>=s);){const x=t[l];u[x.lane]=x.start,l--}l=Math.max(0,l-l%n),c=Math.min(r,c+(n-1-c%n))}return{startIndex:l,endIndex:c}}const Nt=typeof document<"u"?p.useLayoutEffect:p.useEffect;function gn({useFlushSync:t=!0,...a}){const s=p.useReducer(()=>({}),{})[1],n={...a,onChange:(i,l)=>{var c;t&&l?ds.flushSync(s):s(),(c=a.onChange)==null||c.call(a,i,l)}},[r]=p.useState(()=>new pn(n));return r.setOptions(n),Nt(()=>r._didMount(),[]),Nt(()=>r._willUpdate()),r}function yn(t){return gn({observeElementRect:xn,observeElementOffset:hn,scrollToFn:un,...t})}/** + * @license lucide-react v0.559.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const jn=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],bn=he("chevron-up",jn);/** + * @license lucide-react v0.559.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Nn=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]],Tr=he("circle-x",Nn);/** + * @license lucide-react v0.559.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const vn=[["path",{d:"m15 10 5 5-5 5",key:"qqa56n"}],["path",{d:"M4 4v7a4 4 0 0 0 4 4h12",key:"z08zvw"}]],wn=he("corner-down-right",vn);/** + * @license lucide-react v0.559.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const kn=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]],ot=he("lock",kn);/** + * @license lucide-react v0.559.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Cn=[["path",{d:"M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719",key:"1sd12s"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]],Zt=he("message-circle-question-mark",Cn);/** + * @license lucide-react v0.559.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Sn=[["path",{d:"M20 18v-2a4 4 0 0 0-4-4H4",key:"5vmcpk"}],["path",{d:"m9 17-5-5 5-5",key:"nvlc11"}]],_n=he("reply",Sn);/** + * @license lucide-react v0.559.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Mn=[["circle",{cx:"6",cy:"19",r:"3",key:"1kj8tv"}],["path",{d:"M9 19h8.5a3.5 3.5 0 0 0 0-7h-11a3.5 3.5 0 0 1 0-7H15",key:"1d8sl"}],["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}]],Tn=he("route",Mn);/** + * @license lucide-react v0.559.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Pn=[["path",{d:"M11 2v2",key:"1539x4"}],["path",{d:"M5 2v2",key:"1yf1q8"}],["path",{d:"M5 3H4a2 2 0 0 0-2 2v4a6 6 0 0 0 12 0V5a2 2 0 0 0-2-2h-1",key:"rb5t3r"}],["path",{d:"M8 15a6 6 0 0 0 12 0v-3",key:"x18d4x"}],["circle",{cx:"20",cy:"10",r:"2",key:"ts1r5v"}]],vt=he("stethoscope",Pn);/** + * @license lucide-react v0.559.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Bn=[["path",{d:"M10 14.66v1.626a2 2 0 0 1-.976 1.696A5 5 0 0 0 7 21.978",key:"1n3hpd"}],["path",{d:"M14 14.66v1.626a2 2 0 0 0 .976 1.696A5 5 0 0 1 17 21.978",key:"rfe1zi"}],["path",{d:"M18 9h1.5a1 1 0 0 0 0-5H18",key:"7xy6bh"}],["path",{d:"M4 22h16",key:"57wxv0"}],["path",{d:"M6 9a6 6 0 0 0 12 0V3a1 1 0 0 0-1-1H7a1 1 0 0 0-1 1z",key:"1mhfuq"}],["path",{d:"M6 9H4.5a1 1 0 0 1 0-5H6",key:"tex48p"}]],wt=he("trophy",Bn);/** + * @license lucide-react v0.559.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Ln=[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]],Ce=he("user",Ln);function Rn(t){t.values.forEach(a=>a.stop())}function st(t,a){[...a].reverse().forEach(n=>{const r=t.getVariant(n);r&&zt(t,r),t.variantChildren&&t.variantChildren.forEach(i=>{st(i,a)})})}function En(t,a){if(Array.isArray(a))return st(t,a);if(typeof a=="string")return st(t,[a]);zt(t,a)}function zn(){const t=new Set,a={subscribe(s){return t.add(s),()=>void t.delete(s)},start(s,n){const r=[];return t.forEach(i=>{r.push(xs(i,s,{transitionOverride:n}))}),Promise.all(r)},set(s){return t.forEach(n=>{En(n,s)})},stop(){t.forEach(s=>{Rn(s)})},mount(){return()=>{a.stop()}}};return a}function Fn(){const t=hs(zn);return ms(t.mount,[]),t}function In({"aria-label":t="Page navigation",className:a,...s}){return e.jsx("nav",{"aria-label":t,...s,className:R("flex gap-x-2",a)})}function An({onClick:t,disabled:a=!1,className:s,children:n="Previous"}){return e.jsx("span",{className:R("grow basis-0",s),children:e.jsxs(rt,{plain:!0,onClick:t,disabled:a,"aria-label":"Previous page",className:R("gap-1",a&&"invisible"),children:[e.jsx("svg",{className:"size-4 stroke-current",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:e.jsx("path",{d:"M2.75 8H13.25M2.75 8L5.25 5.5M2.75 8L5.25 10.5",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round"})}),n]})})}function Hn({onClick:t,disabled:a=!1,className:s,children:n="Next"}){return e.jsx("span",{className:R("flex grow basis-0 justify-end",s),children:e.jsxs(rt,{plain:!0,onClick:t,disabled:a,"aria-label":"Next page",className:R("gap-1",a&&"invisible"),children:[n,e.jsx("svg",{className:"size-4 stroke-current",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:e.jsx("path",{d:"M13.25 8L2.75 8M13.25 8L10.75 10.5M13.25 8L10.75 5.5",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round"})})]})})}function Dn({className:t,...a}){return e.jsx("span",{...a,className:R("hidden items-baseline gap-x-2 sm:flex",t)})}function On({page:t,current:a=!1,onClick:s,className:n,children:r}){return e.jsx(rt,{plain:!a,outline:a,onClick:()=>s==null?void 0:s(t),"aria-label":`Page ${t}`,"aria-current":a?"page":void 0,className:R("min-w-[2.25rem] before:absolute before:-inset-px before:rounded-lg",a&&"before:bg-subtle-fill",n),children:r??t})}function $n({className:t,...a}){return e.jsx("span",{"aria-hidden":"true",...a,className:R("w-[2.25rem] select-none text-center text-sm text-fg-muted",t),children:"…"})}function Un(t,a,s=1){if(a<=7)return Array.from({length:a},(o,u)=>u+1);const n=Math.max(t-s,1),r=Math.min(t+s,a),i=n>2,l=rg+1),"gap",a]}if(i&&!l){const o=3+2*s;return[1,"gap",...Array.from({length:o},(x,g)=>a-o+g+1)]}return[1,"gap",...Array.from({length:r-n+1},(o,u)=>n+u),"gap",a]}const Pr=us(t=>({requestedHash:null,requestChannel:a=>t({requestedHash:a}),clearRequest:()=>t({requestedHash:null})}));function Vn(t){if(t.length===0)return[];const a=[];let s=0;for(;s{const l=i===t.length-1,c=n&&r.toUpperCase()===n;return e.jsxs("span",{className:"flex items-center flex-shrink-0",children:[c?e.jsx("span",{className:"px-1 py-0.5 rounded bg-sys-amber/20 text-sys-amber text-[9px] font-medium",children:"You"}):e.jsx("span",{className:"px-1 py-0.5 rounded bg-subtle-fill-hover text-fg-secondary",children:r.toUpperCase()}),!l&&e.jsx(ct,{className:"w-2.5 h-2.5 text-fg-muted mx-0.5 flex-shrink-0"})]},`${r}-${i}`)})})}const es=p.memo(Kn);function ts({channelName:t,onClick:a,active:s,compact:n,className:r}){const i=t.startsWith("#")?t:`#${t}`,l=R("inline-flex items-center flex-shrink-0","font-medium",n?"px-1.5 h-4 leading-4 rounded text-[10px]":"px-2 h-5 leading-5 rounded text-xs",s?"bg-sys-blue/20 text-sys-blue":"bg-sys-blue/10 text-sys-blue",a&&!s&&"hover:bg-sys-blue/20 cursor-pointer",r);return a?e.jsx("button",{type:"button",onClick:a,className:l,children:i}):e.jsx("span",{className:l,children:i})}function Me(t){return{"--data-box-accent":ue[t]}}function ss(t){const a=t.payload_type_name||At(t.payload_type??t.type),s=t.route_type_name||Ht(t.route_type??t.route),n=Be[a]??"zinc",r=De[s]??"zinc";return{payloadType:a,routeType:s,payloadColor:n,routeColor:r}}function Ve(t){if(!t)return[];if(Array.isArray(t))return t;try{const a=JSON.parse(t);return Array.isArray(a)?a:[]}catch{return[]}}function ns(t,a){if(a){const s=a(t);return{name:s.name,isCompanion:s.isCompanion,isRepeater:s.isRepeater}}return{name:null,isCompanion:!1,isRepeater:!1}}function Yn({packet:t,onClick:a,localHash:s,neighbors:n,resolveSource:r,isFlashing:i=!1,isTraceHighlighted:l,onTraceHover:c,traceTag:o,onViewTraceReport:u,dupeGroupPosition:x,isDupeGroupHovered:g=!1,onDupeGroupHover:f,dupeCount:y,getDecodedContent:h,onChannelClick:v}){const T=y?!1:Ft(t.is_duplicate),m=x!==void 0,{payloadType:N,routeType:j,payloadColor:C,routeColor:k}=ss(t),b=t.packet_origin==="tx_local",A=N==="TRACE",U=Ve(t.original_path),W=Ve(t.forwarded_path),K=W.length>0?W:U,F=t.src_hash?(t.src_hash.startsWith("0x")?t.src_hash.slice(2,6):t.src_hash.slice(0,4)).toUpperCase():null,{name:Y,isRepeater:H}=ns(t,r);let E=null,O=null,$=null,J=null;if(N==="GRP_TXT"&&h){const _=h(t);_!=null&&_.decrypted&&(O=_.senderName,$=_.channelName,J=_.channelHash,_.text&&(E=_.text))}else if(N==="TXT_MSG"&&t.raw_packet)try{const _=Gt.fromHex(t.raw_packet);if(_.success&&_.packet){const ce=Qt(_.packet.payload);ce&&!ce.encrypted&&(E=ce.text)}}catch{}const M=O||(H?null:Y),D=!!M,te=!D&&H&&!!Y,se=!D&&!te&&N==="GRP_TXT"&&!E,d=t.payload_length??t.length??0;t.lbt_attempts;const Z=p.useCallback(()=>{A&&o&&u?u(o):a(t)},[A,o,u,a,t]),q=p.useCallback(()=>{A&&o&&c&&c(o),m&&f&&t.packet_hash&&f(t.packet_hash)},[A,o,c,m,f,t.packet_hash]),le=p.useCallback(()=>{c&&c(null),f&&f(null)},[c,f]),P=ue[C]||ue.zinc,z=g,ne=()=>{const _={pointerEvents:"none"};return x==="first"?{..._,borderTop:`2px solid ${P}`,borderLeft:`2px solid ${P}`,borderRight:`2px solid ${P}`,borderBottom:"none",borderRadius:"8px 8px 0 0",inset:"-2px -2px 0 -2px"}:x==="middle"?{..._,borderTop:"none",borderLeft:`2px solid ${P}`,borderRight:`2px solid ${P}`,borderBottom:"none",borderRadius:0,inset:"0 -2px"}:x==="last"?{..._,borderTop:"none",borderLeft:`2px solid ${P}`,borderRight:`2px solid ${P}`,borderBottom:`2px solid ${P}`,borderRadius:"0 0 8px 8px",inset:"0 -2px -2px -2px"}:{..._,border:`2px solid ${P}`,borderRadius:"8px",inset:"-2px"}};return e.jsxs("div",{onClick:Z,onMouseEnter:q,onMouseLeave:le,className:R("group relative cursor-pointer","hover:bg-subtle-fill",T&&!g&&"opacity-40",i&&"flash-row",b&&"bg-sys-indigo/5",l&&"bg-sys-teal/10"),children:[e.jsx("div",{className:R("absolute pointer-events-none transition-opacity duration-75",m?z?"opacity-100":"opacity-0":"opacity-0 group-hover:opacity-100"),style:ne()}),e.jsxs("div",{className:"relative flex items-center gap-2 min-[600px]:gap-3 px-2 py-2 min-[600px]:px-3 min-[600px]:py-2.5",children:[e.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[e.jsx("div",{className:"relative flex-shrink-0",children:D?e.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center ring-1 ring-edge-subtle",style:{backgroundColor:Vt(_e(M).cleanName)},children:_e(M).emoji?e.jsx("span",{className:"text-base leading-none",children:_e(M).emoji}):e.jsx("span",{className:"text-white text-[10px] font-bold tracking-tighter",children:Wt(M)})}):te?e.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center ring-[1.5px] ring-sys-blue",children:e.jsx(de,{className:"size-5 text-sys-blue"})}):se?e.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center bg-zinc-500/20 ring-1 ring-edge-subtle",children:e.jsx(Zt,{className:"size-4 text-fg-muted"})}):e.jsx(Jt,{packet:t,variant:"avatar",size:"sm"})}),e.jsx("div",{className:"min-w-0",children:D?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"font-semibold text-[13px] text-fg-primary font-sans truncate max-w-[90px]",children:M}),F&&e.jsx("div",{className:"hidden min-[900px]:block text-[9px] text-fg-muted truncate",children:F})]}):te?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"font-semibold text-[13px] text-fg-primary font-sans truncate max-w-[90px]",children:Y}),F&&e.jsx("div",{className:"hidden min-[900px]:block text-[9px] text-fg-muted truncate",children:F})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"font-bold text-[13px] text-fg-primary font-sans truncate",children:F||"—"}),Y&&e.jsx("div",{className:"hidden min-[900px]:block text-[9px] text-fg-muted truncate max-w-[70px]",children:Y})]})})]}),e.jsxs("div",{className:"flex-1 flex items-center gap-1 min-[600px]:gap-1.5 min-[900px]:gap-2 min-w-0",children:[e.jsx("span",{className:"data-box data-box-compact data-box-outlined flex-shrink-0",style:Me(C),children:N}),b&&e.jsx("span",{className:"data-box data-box-compact data-box-outlined flex-shrink-0",style:Me("indigo"),children:"LOCAL"}),y&&y>1&&e.jsxs("span",{className:"data-box data-box-compact flex-shrink-0",children:["×",y]}),e.jsx("span",{className:"data-box data-box-compact data-box-outlined flex-shrink-0",style:Me(k),children:j}),e.jsxs("span",{className:"hidden min-[520px]:inline type-data-xs text-fg-muted flex-shrink-0",children:[d,"B"]}),e.jsx("div",{className:"flex-1 min-w-0 overflow-hidden",children:E||$?e.jsxs("span",{className:"text-[11px] text-fg-secondary truncate block flex items-center gap-1",children:[$&&e.jsx(ts,{channelName:$,compact:!0,onClick:v&&J?_=>{_.stopPropagation(),v(J)}:void 0}),E&&e.jsx("span",{className:"italic truncate",children:E})]}):e.jsx(es,{path:K,localHash:s})})]}),e.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[e.jsx("span",{className:"data-box data-box-compact",children:It(t.timestamp)}),e.jsx(Oe,{rssi:t.rssi,snr:t.snr,compact:!0,showValues:!0,validated:$e(t)})]})]})]})}function Xn({packet:t,onClick:a,localHash:s,neighbors:n,resolveSource:r,isFlashing:i=!1,isTraceHighlighted:l,traceTag:c,onViewTraceReport:o,dupeGroupPosition:u,isDupeGroupHovered:x=!1,onDupeGroupHover:g,dupeCount:f,getDecodedContent:y,onChannelClick:h}){const{payloadType:v,routeType:T,payloadColor:m,routeColor:N}=ss(t),j=t.packet_origin==="tx_local",C=v==="TRACE",k=f?!1:Ft(t.is_duplicate),b=Ve(t.original_path),A=Ve(t.forwarded_path),U=A.length>0?A:b,W=t._hopCount??U.length,K=t.src_hash?(t.src_hash.startsWith("0x")?t.src_hash.slice(2,6):t.src_hash.slice(0,4)).toUpperCase():null,{name:F,isRepeater:Y}=ns(t,r);let H=null,E=null,O=null,$=null;if(v==="GRP_TXT"&&y){const P=y(t);P!=null&&P.decrypted&&(E=P.senderName,O=P.channelName,$=P.channelHash,P.text&&(H=P.text))}else if(v==="TXT_MSG"&&t.raw_packet)try{const P=Gt.fromHex(t.raw_packet);if(P.success&&P.packet){const z=Qt(P.packet.payload);z&&!z.encrypted&&(H=z.text)}}catch{}const J=E||(Y?null:F),M=!!J,D=!M&&Y&&!!F,te=!M&&!D&&v==="GRP_TXT"&&!H,se=t.payload_length??t.length??0,d=t.lbt_attempts??0,Z=()=>{C&&c&&o?o(c):a(t)},q=ue[m]||ue.zinc,le=()=>{if(!u)return{opacity:0};const P=x?1:.4,z=x?"3px":"2px";return u==="first"?{backgroundColor:q,opacity:P,width:z,top:"6px",bottom:0,borderRadius:"0 9999px 0 0"}:u==="middle"?{backgroundColor:q,opacity:P,width:z,top:0,bottom:0,borderRadius:0}:u==="last"?{backgroundColor:q,opacity:P,width:z,top:0,bottom:"6px",borderRadius:"0 0 9999px 0"}:{backgroundColor:q,opacity:P,width:z,top:"6px",bottom:"6px",borderRadius:"9999px"}};return e.jsxs("div",{onClick:Z,className:R("relative pl-3 pr-2.5 py-2 cursor-pointer","active:bg-subtle-fill-hover",k&&"opacity-40",i&&"flash-row",j&&"bg-sys-indigo/5",l&&"bg-sys-teal/10"),children:[e.jsx("div",{className:"absolute left-0 transition-all",style:le()}),e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("div",{className:"relative flex-shrink-0 mt-0.5",children:M?e.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center ring-1 ring-edge-subtle",style:{backgroundColor:Vt(_e(J).cleanName)},children:_e(J).emoji?e.jsx("span",{className:"text-base leading-none",children:_e(J).emoji}):e.jsx("span",{className:"text-white text-[10px] font-bold tracking-tighter",children:Wt(J)})}):D?e.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center ring-[1.5px] ring-sys-blue",children:e.jsx(de,{className:"size-5 text-sys-blue"})}):te?e.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center bg-zinc-500/20 ring-1 ring-edge-subtle",children:e.jsx(Zt,{className:"size-4 text-fg-muted"})}):e.jsx(Jt,{packet:t,variant:"avatar",size:"sm"})}),e.jsxs("div",{className:"flex-1 min-w-0 space-y-0.5",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[M?e.jsx("span",{className:"font-medium text-[14px] text-fg-primary tracking-tight truncate min-w-0",children:J}):D?e.jsx("span",{className:"font-medium text-[14px] text-fg-primary tracking-tight truncate min-w-0",children:F}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"font-semibold text-[14px] text-fg-primary tracking-tight flex-shrink-0",children:K||"—"}),F&&e.jsx("span",{className:"text-[12px] text-fg-muted truncate min-w-0",children:F})]}),e.jsx("div",{className:"flex-1"}),e.jsx("span",{className:"data-box data-box-compact data-box-outlined flex-shrink-0",style:Me(m),children:v}),j&&e.jsx("span",{className:"data-box data-box-compact data-box-outlined flex-shrink-0",style:Me("indigo"),children:"LOCAL"}),e.jsx("span",{className:"data-box data-box-compact data-box-outlined flex-shrink-0",style:Me(N),children:T}),f&&f>1&&e.jsxs("span",{className:"data-box data-box-compact flex-shrink-0",children:["×",f]}),e.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[e.jsx("span",{className:"type-data-xs text-fg-muted w-[28px] text-right",children:t.rssi}),e.jsx(Oe,{rssi:t.rssi,compact:!0,showValues:!1,validated:$e(t)})]})]}),e.jsxs("div",{className:"flex items-center gap-1 type-data-xs text-fg-muted",children:[e.jsx("span",{className:"data-box data-box-compact flex-shrink-0",children:It(t.timestamp)}),se>0&&e.jsxs("span",{children:[se,"B"]}),d>0&&e.jsxs("span",{className:d>1?"text-sys-amber/60":void 0,children:["LBT:",d]}),t.snr!=null&&e.jsxs("span",{children:[t.snr.toFixed(0),"dB"]}),H||O?e.jsxs("span",{className:"text-[11px] text-fg-secondary truncate flex items-center gap-1 min-w-0",children:[O&&e.jsx(ts,{channelName:O,compact:!0,onClick:h&&$?P=>{P.stopPropagation(),h($)}:void 0}),H&&e.jsx("span",{className:"italic truncate",children:H})]}):W>0?e.jsx(es,{path:U,localHash:s}):null]})]})]})]})}const Zn=p.memo(Yn),Jn=p.memo(Xn);function ea(t,a,s,n,r=!1){const i=t.toUpperCase(),l=[],c=s&&Ze(i,s);c&&l.push(s);for(const y of Object.keys(a))Ze(i,y)&&l.push(y);if(r&&c&&s&&l.length===1)return{matches:l,probability:1,bestMatch:s};if(r&&c&&l.length>1){const y=l.filter(h=>h!==s);if(y.length===1)return{matches:l,probability:1,bestMatch:y[0]}}const o=l.length>0?1/l.length:0,u=[...l].sort();let x=null,g=-1;if(u.length===1)x=u[0];else if(u.length>1&&n){for(const y of u){const h=n.get(y),v=h?typeof h=="number"?h:h.combinedScore:0;v>g&&(g=v,x=y)}x||(x=u[0])}else u.length>0&&(x=u[0]);let f=o;if(l.length>1&&n&&g>0){let y=0;for(const h of l){const v=n.get(h);y+=v?typeof v=="number"?v:v.combinedScore:0}y>0&&(f=Math.min(.95,g/y))}return{matches:l,probability:f,bestMatch:x}}function ta(t,a,s,n){const i=(s-t)*Math.PI/180,l=(n-a)*Math.PI/180,c=Math.sin(i/2)*Math.sin(i/2)+Math.cos(t*Math.PI/180)*Math.cos(s*Math.PI/180)*Math.sin(l/2)*Math.sin(l/2);return 6371e3*(2*Math.atan2(Math.sqrt(c),Math.sqrt(1-c)))}function sa(t){return t<100?1:t<500?.9:t<1e3?.7:t<5e3?.5:t<1e4?.3:.1}const na=p.lazy(()=>ps(()=>import("./PathMapMapLibre-AZaGoHLu.js"),__vite__mapDeps([0,1,2,3,4,5,6])));function aa(t,a,s,n,r=!1,i,l,c){const o=fs(a);let u;l&&(u=gs(l,t,{position:c,isLastHop:r}).confidence);const{matches:x,probability:g}=ea(t,o,n,i,r),f=x.length,y=[],h=t.toUpperCase(),v=s&&s.latitude!==void 0&&s.longitude!==void 0&&(s.latitude!==0||s.longitude!==0);for(const m of x){if(n&&Ze(h,n)&&m===n&&v&&s){y.push({hash:m,name:s.name||"Local Node",latitude:s.latitude,longitude:s.longitude,probability:r?1:g,isLocal:!0});continue}const N=o[m];N!=null&&N.latitude&&(N!=null&&N.longitude)&&!(N.latitude===0&&N.longitude===0)&&y.push({hash:m,name:N.node_name||N.name||"Unknown",latitude:N.latitude,longitude:N.longitude,probability:g,isLocal:!1,isDirectNeighbor:N.zero_hop===!0})}const T=y.length;if(T===1)y[0].probability=u??1;else if(T>1)if(u!==void 0&&u>0){const m=y[0];m.probability=u;const N=1-u,j=T-1;y.slice(1).forEach(C=>{C.probability=N/j})}else{let m=0;const N=y.map(j=>{if(j.isLocal)return{candidate:j,score:1};const C=i==null?void 0:i.get(j.hash);let k=.5;if(v&&s){const A=ta(s.latitude,s.longitude,j.latitude,j.longitude);k=sa(A)}let b;return C?b=k*.3+C.hopConsistencyScore*.3+C.frequencyScore*.4:(b=k,j.isDirectNeighbor&&(b=Math.max(b,.8))),m+=b,{candidate:j,score:b}});if(m>0)N.forEach(({candidate:j,score:C})=>{j.probability=Math.min(.95,C/m)});else{const j=1/T;y.forEach(C=>C.probability=j)}}return{candidates:y,totalMatches:f}}function ra(t,a,s,n,r,i){if(!t||t.length===0)return{hops:[],overallConfidence:0,hasValidPath:!1};const l=t.length-1,c=t.map((x,g)=>{const f=g===l,y=t.length-g,{candidates:h,totalMatches:v}=aa(x,a,s,n,f,r,i,y),T=h.length>0?Math.max(...h.map(m=>m.probability)):0;return{prefix:x,candidates:h,confidence:T,totalMatches:v}}),o=c.reduce((x,g)=>g.confidence===0?0:x*g.confidence,1),u=c.some(x=>x.candidates.length>0);return{hops:c,overallConfidence:o,hasValidPath:u}}function ia(t){return`${(t*100).toFixed(0)}%`}function la(t){return t>=1?"text-sys-green":t>=.5?"text-sys-indigo":t>=.25?"text-signal-poor":t>0?"text-sys-red":"text-fg-muted"}function ca(t,a,s){let n;return a===0?n=s.muted:t>=1?n=s.success:t>=.5?n=s.secondary:t>=.25?n=s.poor:t>0?n=s.danger:n=s.muted,{color:n}}class oa extends p.Component{constructor(a){super(a),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}render(){return this.state.hasError?e.jsxs("div",{className:"h-[200px] flex items-center justify-center text-fg-muted",children:[e.jsx(et,{className:"w-4 h-4 mr-2"}),"Map failed to load"]}):this.props.children}}function We({path:t,neighbors:a,localNode:s,localHash:n,srcHash:r,dstHash:i,neighborAffinity:l,prefixLookup:c,hubNodes:o,traceSnr:u,advertiserSource:x}){const[g,f]=p.useState(null),y=p.useMemo(()=>{if(!x)return null;const j=x.nodeType==="wardrive";return{prefix:x.prefix||"??",candidates:[{hash:x.publicKey||x.prefix||"source",name:x.name,latitude:x.latitude,longitude:x.longitude,probability:1,isLocal:!1,isWardrive:j}],confidence:1,totalMatches:1,isSource:!0}},[x]),h=p.useMemo(()=>{if(x||!r)return null;const j=He(r),C=a[r];if((C==null?void 0:C.latitude)&&(C==null?void 0:C.longitude)&&!(C.latitude===0&&C.longitude===0))return{prefix:j,candidates:[{hash:r,name:C.node_name||C.name||"Source",latitude:C.latitude,longitude:C.longitude,probability:1,isLocal:!1,isDirectNeighbor:C.zero_hop===!0}],confidence:1,totalMatches:1,isSource:!0};const b=(C==null?void 0:C.node_name)||(C==null?void 0:C.name)||r.slice(0,8);return{prefix:j,candidates:[{hash:r,name:b,latitude:0,longitude:0,probability:1,isLocal:!1}],confidence:1,totalMatches:1,isSource:!0}},[x,r,a]),v=p.useMemo(()=>{const j=i!=null&&i.startsWith("0x")?i.slice(2):i;if((!j||j==="00"||j==="0000000000000000")&&s&&n){const W=He(n),K=s.latitude!==0||s.longitude!==0;return{prefix:W,candidates:[{hash:n,name:s.name||"Local Node",latitude:K?s.latitude:0,longitude:K?s.longitude:0,probability:1,isLocal:!0}],confidence:1,totalMatches:1,isDestination:!0}}if(!i)return null;const k=He(i);if(n&&i===n&&s){const W=s.latitude!==0||s.longitude!==0;return{prefix:k,candidates:[{hash:i,name:s.name||"Local Node",latitude:W?s.latitude:0,longitude:W?s.longitude:0,probability:1,isLocal:!0}],confidence:1,totalMatches:1,isDestination:!0}}const b=a[i];if((b==null?void 0:b.latitude)&&(b==null?void 0:b.longitude)&&!(b.latitude===0&&b.longitude===0))return{prefix:k,candidates:[{hash:i,name:b.node_name||b.name||"Destination",latitude:b.latitude,longitude:b.longitude,probability:1,isLocal:!1,isDirectNeighbor:b.zero_hop===!0}],confidence:1,totalMatches:1,isDestination:!0};const U=(b==null?void 0:b.node_name)||(b==null?void 0:b.name)||i.slice(0,8);return{prefix:k,candidates:[{hash:i,name:U,latitude:0,longitude:0,probability:1,isLocal:!1}],confidence:1,totalMatches:1,isDestination:!0}},[i,a,s,n]),T=p.useMemo(()=>ra(t,a,s,n,l,c),[t,a,s,n,l,c]),m=p.useMemo(()=>{const j=[];y?j.push(y):h&&j.push(h),j.push(...T.hops),v&&j.push(v);const C=j.reduce((b,A)=>A.confidence===0?0:b*A.confidence,1),k=j.some(b=>b.candidates.some(A=>A.latitude!==0||A.longitude!==0));return{hops:j,overallConfidence:C,hasValidPath:k}},[y,h,T,v]),N=p.useMemo(()=>{const j=getComputedStyle(document.documentElement);return{success:j.getPropertyValue("--sys-green").trim()||"#39D98A",secondary:j.getPropertyValue("--sys-indigo").trim()||"#F9D26F",poor:j.getPropertyValue("--signal-poor").trim()||"#FF8A5C",danger:j.getPropertyValue("--sys-red").trim()||"#FF5C7A",muted:j.getPropertyValue("--text-muted").trim()||"#767688"}},[]);return m.hasValidPath?e.jsxs("div",{className:"h-full flex flex-col space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-fg-muted",children:"Path Confidence:"}),e.jsx("span",{className:la(m.overallConfidence),children:ia(m.overallConfidence)}),e.jsx("button",{className:"text-fg-muted hover:text-fg-secondary transition-colors",title:"Confidence is calculated based on how many known nodes match each path prefix. Multiple matches reduce confidence due to collision probability.",children:e.jsx(Js,{className:"w-3 h-3"})})]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("div",{className:"w-2 h-2 rounded-full bg-sys-green"}),e.jsx("span",{className:"text-fg-muted",children:"Exact"})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("div",{className:"w-2 h-2 rounded-full bg-sys-indigo"}),e.jsx("span",{className:"text-fg-muted",children:"Multi"})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("div",{className:"w-2 h-2 rounded-full bg-fg-muted"}),e.jsx("span",{className:"text-fg-muted",children:"Unknown"})]})]})]}),e.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:e.jsx(oa,{children:e.jsx(p.Suspense,{fallback:e.jsx("div",{className:"h-full bg-elevated flex items-center justify-center text-fg-muted text-sm",children:"Loading map..."}),children:e.jsx(na,{resolvedPath:m,localNode:s,hubNodes:o,hoveredHopIndex:g,onHoverHop:f,traceSnr:u})})})}),e.jsx("div",{className:"flex flex-wrap items-center gap-1.5",children:m.hops.map((j,C)=>{var W,K,F;const k=j.isSource===!0,b=j.isDestination===!0,A=g===C;let U;return k?U=`Source: ${((W=j.candidates[0])==null?void 0:W.name)||"Unknown"}`:b?U=`Destination: ${((K=j.candidates[0])==null?void 0:K.name)||"Unknown"}`:j.totalMatches===0?U="No matching nodes found":j.totalMatches===1?U=`Exact match: ${((F=j.candidates[0])==null?void 0:F.name)||"Unknown"}`:U=`${j.totalMatches} possible matches (${(j.confidence*100).toFixed(0)}% confidence)`,e.jsxs("div",{className:R("flex items-center gap-1 px-1.5 py-0.5 rounded type-data-xs cursor-pointer transition-all",A?"bg-sys-blue/20 ring-1 ring-sys-blue/50":"bg-elevated hover:bg-subtle",k&&"border border-sys-green/30",b&&"border border-sys-blue/30"),title:U,onMouseEnter:()=>f(C),onMouseLeave:()=>f(null),children:[k&&e.jsx("span",{className:"text-sys-green text-[8px] mr-0.5",children:"SRC"}),b&&e.jsx("span",{className:"text-sys-blue text-[8px] mr-0.5",children:"DST"}),e.jsx("span",{style:ca(j.confidence,j.totalMatches,N),children:j.prefix}),!k&&!b&&j.totalMatches>1&&e.jsxs("span",{className:"text-fg-muted",children:["×",j.totalMatches]}),!k&&!b&&j.totalMatches===0&&e.jsx("span",{className:"text-fg-muted",children:"?"})]},C)})})]}):e.jsxs("div",{className:"flex items-center justify-center text-fg-muted text-xs py-4",children:[e.jsx(Ue,{className:"w-3.5 h-3.5 mr-1.5 opacity-50"}),"No location data available for path nodes"]})}const Ye=16;function Ge(t){return t.match(/.{1,2}/g)||[]}function je(t){return t!==null&&t.startsWith("payload:")}const Te={hexRestOpacity:15,cardRestBg:"color-mix(in srgb, var(--elevated) 60%, var(--body))",cardRestShadow:` + var(--depth-stroke-tl), + var(--depth-stroke-br) + `,selectionBorderWidth:2},nt={type:"tween",duration:.25,ease:[.25,.1,.25,1]};function da(t,a){return t?`inset 0 0 0 ${Te.selectionBorderWidth}px ${ue[a]}`:Te.cardRestShadow}function xa(t,a){return t?a:`color-mix(in srgb, ${a} ${Te.hexRestOpacity}%, transparent)`}function ha({segments:t,selectedSegment:a,onSegmentClick:s}){const[n,r]=p.useState(null),[i,l]=p.useState(null),c=t.some(x=>x.id!==void 0)&&s,o=[];for(const x of t){const g=Ge(x.hex);for(const f of g)o.push({byte:f.toUpperCase(),color:x.color,id:x.id})}const u=[];for(let x=0;x{const f=x.length{const m=T===x.length-1,N=f&&m,j=ue[h],b=(v?n===v:i===h)||!!(v&&a===v);return e.jsx("span",{className:`w-[1.75rem] text-xs text-center py-0.5 font-mono select-text ${c?"cursor-pointer":""}`,style:{backgroundColor:xa(b,j),color:b?"rgba(255,255,255,0.95)":j,transition:b?"none":"background-color 0.15s ease-out, color 0.15s ease-out",touchAction:"manipulation",...N?{borderRadius:"0 0.375rem 0.375rem 0"}:{}},onMouseEnter:()=>{v?r(v):l(h)},onMouseLeave:()=>{r(null),l(null)},onClick:()=>v&&(s==null?void 0:s(v)),onTouchStart:()=>{v?r(v):l(h)},onTouchEnd:()=>{r(null),l(null)},children:y},T)})},g)})})}function ma({rawHex:t,hexSegments:a,selectedSegment:s,onSegmentClick:n}){const[r,i]=p.useState(!1),l=p.useCallback(async()=>{try{await navigator.clipboard.writeText(t.toUpperCase()),i(!0),setTimeout(()=>i(!1),2e3)}catch(c){console.error("Failed to copy:",c)}},[t]);return e.jsxs("div",{className:"bg-inset radius-inner p-6 relative depth-stroke-inset",children:[e.jsx(ha,{segments:a,selectedSegment:s,onSegmentClick:n}),e.jsx("button",{onClick:l,className:"absolute bottom-3 right-3 flex items-center gap-1.5 px-2.5 py-1.5 rounded-lg bg-subtle-fill-hover hover:bg-subtle-fill-strong text-fg-muted hover:text-fg-secondary transition-all text-xs font-sans",title:"Copy raw packet hex",children:r?e.jsxs(e.Fragment,{children:[e.jsx(bs,{className:"w-3.5 h-3.5 text-sys-green"}),e.jsx("span",{className:"text-sys-green",children:"Copied"})]}):e.jsxs(e.Fragment,{children:[e.jsx(it,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"Copy"})]})})]})}function ua(t,a){const s=[];let n=0;const r=a.slice(0,64);s.push({id:"payload:publicKey",title:"Public Key",color:"pink",hex:r,startByte:n,endByte:n+31,decoded:e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-[11px] text-fg-secondary break-all p-2 rounded bg-body/50 font-mono",children:t.publicKey.toUpperCase()}),e.jsx("p",{className:"text-xs text-fg-muted mt-1",children:"Ed25519 public key (32 bytes)"})]})}),n+=32;const i=a.slice(64,72);s.push({id:"payload:timestamp",title:"Timestamp",color:"orange",hex:i,startByte:n,endByte:n+3,decoded:e.jsxs(e.Fragment,{children:[e.jsx(X,{size:"standard",copy:!0,children:i.toUpperCase()}),e.jsxs("p",{className:"text-xs text-fg-primary mt-1",children:[t.timestamp," (",ie(t.timestamp),")"]})]})}),n+=4;const l=a.slice(72,200);s.push({id:"payload:signature",title:"Signature",color:"teal",hex:l,startByte:n,endByte:n+63,decoded:e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-[11px] text-fg-secondary break-all p-2 rounded bg-body/50 font-mono",children:t.signature.toUpperCase()}),e.jsx("p",{className:"text-xs text-fg-muted mt-1",children:"Ed25519 signature (64 bytes)"})]})}),n+=64;const c=a.slice(200,202);if(s.push({id:"payload:flags",title:"Flags",color:"blue",hex:c,startByte:n,endByte:n,decoded:e.jsxs(e.Fragment,{children:[e.jsxs(X,{size:"standard",copy:!0,children:["0x",t.flags.toString(16).padStart(2,"0").toUpperCase()]}),e.jsx("p",{className:"text-xs text-fg-primary mt-1",children:t.flagsDescription}),e.jsxs("p",{className:"text-xs text-fg-muted",children:["Node Type: ",t.nodeType]})]})}),n+=1,t.latitude!==void 0){const o=a.slice(n*2,n*2+8);s.push({id:"payload:latitude",title:"Latitude",color:"green",hex:o,startByte:n,endByte:n+3,decoded:e.jsxs(e.Fragment,{children:[e.jsx(X,{size:"standard",copy:!0,children:o.toUpperCase()}),e.jsxs("p",{className:"text-xs text-fg-primary mt-1",children:[t.latitude.toFixed(6),"°"]})]})}),n+=4}if(t.longitude!==void 0){const o=a.slice(n*2,n*2+8);s.push({id:"payload:longitude",title:"Longitude",color:"indigo",hex:o,startByte:n,endByte:n+3,decoded:e.jsxs(e.Fragment,{children:[e.jsx(X,{size:"standard",copy:!0,children:o.toUpperCase()}),e.jsxs("p",{className:"text-xs text-fg-primary mt-1",children:[t.longitude.toFixed(6),"°"]})]})}),n+=4}if(t.name){const o=a.slice(n*2),u=o.length/2;s.push({id:"payload:name",title:"Name",color:"amber",hex:o,startByte:n,endByte:n+u-1,decoded:e.jsxs(e.Fragment,{children:[e.jsx(X,{size:"standard",copy:!0,children:o.toUpperCase()}),e.jsxs("p",{className:"text-xs text-fg-primary mt-1",children:['"',t.name,'"']})]})})}return s}function pa(t,a){return[{id:"payload:crc",title:"CRC",color:"green",hex:a.slice(0,8),startByte:0,endByte:3,decoded:e.jsxs(e.Fragment,{children:[e.jsxs(X,{size:"standard",copy:!0,children:["0x",t.crc]}),e.jsx("p",{className:"text-xs text-fg-muted mt-1",children:"CRC32 of acknowledged packet"})]})}]}function fa(t,a){const s=[];s.push({id:"payload:channelHash",title:"Channel Hash",color:"blue",hex:a.slice(0,2),startByte:0,endByte:0,decoded:e.jsxs(e.Fragment,{children:[e.jsxs(X,{size:"standard",copy:!0,children:["0x",t.channelHash]}),t.channelName&&e.jsxs("p",{className:"text-xs text-fg-primary mt-1",children:["Channel: ",t.channelName]})]})}),t.macHex&&s.push({id:"payload:mac",title:"MAC",color:"indigo",hex:a.slice(2,6),startByte:1,endByte:2,decoded:e.jsxs(e.Fragment,{children:[e.jsx(X,{size:"standard",copy:!0,children:t.macHex.toUpperCase()}),e.jsx("p",{className:"text-xs text-fg-muted mt-1",children:"Truncated HMAC-SHA256"})]})});const n=a.slice(6);return n&&s.push({id:"payload:ciphertext",title:t.decrypted?"Message":"Ciphertext",color:t.decrypted?"green":"zinc",hex:n,startByte:3,endByte:3+n.length/2-1,decoded:t.decrypted?e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"text-sm text-fg-primary",children:['"',t.text,'"']}),t.senderName&&e.jsxs("p",{className:"text-xs text-fg-muted mt-1",children:["From: ",t.senderName]})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-[11px] text-fg-secondary break-all p-2 rounded bg-body/50 font-mono",children:n.toUpperCase()}),e.jsx("p",{className:"text-xs text-fg-muted mt-1",children:"AES-128-ECB encrypted"})]})}),s}function ga(t,a){const s=[];s.push({id:"payload:channelHash",title:"Channel Hash",color:"blue",hex:a.slice(0,2),startByte:0,endByte:0,decoded:e.jsxs(e.Fragment,{children:[e.jsxs(X,{size:"standard",copy:!0,children:["0x",t.channelHash]}),t.channelName&&e.jsxs("p",{className:"text-xs text-fg-primary mt-1",children:["Channel: ",t.channelName]})]})}),t.macHex&&s.push({id:"payload:mac",title:"MAC",color:"indigo",hex:a.slice(2,6),startByte:1,endByte:2,decoded:e.jsxs(e.Fragment,{children:[e.jsx(X,{size:"standard",copy:!0,children:t.macHex.toUpperCase()}),e.jsx("p",{className:"text-xs text-fg-muted mt-1",children:"Truncated HMAC-SHA256"})]})});const n=a.slice(6);return n&&s.push({id:"payload:ciphertext",title:t.decrypted?"Decrypted Data":"Encrypted Data",color:t.decrypted?"green":"zinc",hex:n,startByte:3,endByte:3+n.length/2-1,decoded:e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-[11px] text-fg-secondary break-all p-2 rounded bg-body/50 font-mono",children:(t.decryptedHex||n).toUpperCase()}),e.jsxs("p",{className:"text-xs text-fg-muted mt-1",children:[t.dataLength," bytes",t.decrypted?"":" (AES-128-ECB encrypted)"]})]})}),s}function ya(t,a){const s=[];if(s.push({id:"payload:pathLength",title:"Path Length",color:"blue",hex:a.slice(0,2),startByte:0,endByte:0,decoded:e.jsxs(e.Fragment,{children:[e.jsx(X,{size:"standard",children:t.pathLength}),e.jsxs("p",{className:"text-xs text-fg-muted mt-1",children:[t.pathLength," hop",t.pathLength!==1?"s":""]})]})}),t.path.length>0){const n=a.slice(2,2+t.pathLength*2);s.push({id:"payload:path",title:"Path Hops",color:"amber",hex:n,startByte:1,endByte:t.pathLength,decoded:e.jsx(e.Fragment,{children:e.jsx("div",{className:"flex flex-wrap items-center gap-1",children:t.path.map((r,i)=>e.jsxs("span",{className:"flex items-center gap-1",children:[i>0&&e.jsx(pe,{className:"w-3 h-3 text-fg-muted"}),e.jsx(B,{color:"amber",className:"font-mono",children:r})]},i))})})})}if(t.extraType!=null){const n=1+t.pathLength;s.push({id:"payload:extraType",title:"Extra Type",color:"indigo",hex:a.slice(n*2,n*2+2),startByte:n,endByte:n,decoded:e.jsxs(e.Fragment,{children:[e.jsx(X,{size:"standard",children:t.extraTypeName??`0x${t.extraType.toString(16).padStart(2,"0")}`}),e.jsx("p",{className:"text-xs text-fg-muted mt-1",children:"Bundled payload type"})]})})}if(t.extraData){const n=1+t.pathLength+1,r=a.slice(n*2);r&&s.push({id:"payload:extraData",title:"Extra Data",color:"indigo",hex:r,startByte:n,endByte:n+r.length/2-1,decoded:e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-[11px] text-fg-secondary break-all p-2 rounded bg-body/50 font-mono",children:r.toUpperCase()}),e.jsxs("p",{className:"text-xs text-fg-muted mt-1",children:[r.length/2," bytes"]})]})})}return s}function ja(t,a){const s=[];s.push({id:"payload:crc",title:"Trace Tag",color:"blue",hex:a.slice(0,8),startByte:0,endByte:3,decoded:e.jsxs(e.Fragment,{children:[e.jsxs(X,{size:"standard",copy:!0,children:["0x",t.traceTag]}),e.jsx("p",{className:"text-xs text-fg-muted mt-1",children:"Unique trace request identifier"})]})}),s.push({id:"payload:mac",title:"Auth Code",color:"indigo",hex:a.slice(8,16),startByte:4,endByte:7,decoded:e.jsxs(e.Fragment,{children:[e.jsx(X,{size:"standard",copy:!0,children:t.authCode}),e.jsx("p",{className:"text-xs text-fg-muted mt-1",children:"Authentication/verification code"})]})}),s.push({id:"payload:flags",title:"Flags",color:"amber",hex:a.slice(16,18),startByte:8,endByte:8,decoded:e.jsxs(e.Fragment,{children:[e.jsxs(X,{size:"standard",copy:!0,children:["0x",t.flags.toString(16).toUpperCase().padStart(2,"0")]}),e.jsx("p",{className:"text-xs text-fg-muted mt-1",children:t.flags===0?"No flags set":`Flags: ${t.flags.toString(2).padStart(8,"0")}b`})]})});const n=a.slice(18);return n&&s.push({id:"payload:path",title:"Target Path",color:"indigo",hex:n,startByte:9,endByte:9+n.length/2-1,decoded:e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex flex-wrap items-center gap-1",children:t.pathHashes.map((r,i)=>{const l=t.snrValues[i],c=l!==void 0?qs(l):"zinc";return e.jsxs("span",{className:"flex items-center gap-1",children:[i>0&&e.jsx(pe,{className:"w-3 h-3 text-fg-muted"}),e.jsx(B,{color:"indigo",className:"font-mono",children:r}),l!==void 0&&e.jsxs(B,{color:c,className:"font-mono",children:[l>=0?"+":"",Number.isInteger(l)?l:l.toFixed(1),"dB"]})]},i)})}),e.jsxs("p",{className:"text-xs text-fg-muted mt-1",children:[t.pathHashes.length," target ",t.pathHashes.length===1?"hop":"hops",t.snrValues.length>0&&` • ${t.snrValues.length} SNR ${t.snrValues.length===1?"value":"values"} collected`,t.isComplete&&" • ✓ Complete"]})]})}),s}function ba(t,a){const s=[];s.push({id:"payload:msgId",title:"Message ID",color:"blue",hex:a.slice(0,4),startByte:0,endByte:1,decoded:e.jsxs(e.Fragment,{children:[e.jsx(X,{size:"standard",copy:!0,children:t.messageId.toUpperCase()}),e.jsx("p",{className:"text-xs text-fg-muted mt-1",children:"Unique message identifier"})]})}),s.push({id:"payload:partNum",title:"Part Number",color:"amber",hex:a.slice(4,6),startByte:2,endByte:2,decoded:e.jsxs(e.Fragment,{children:[e.jsx(X,{size:"standard",copy:!0,children:t.partNumber}),e.jsx("p",{className:"text-xs text-fg-muted mt-1",children:"0-indexed part number"})]})}),s.push({id:"payload:totalParts",title:"Total Parts",color:"orange",hex:a.slice(6,8),startByte:3,endByte:3,decoded:e.jsxs(e.Fragment,{children:[e.jsx(X,{size:"standard",copy:!0,children:t.totalParts}),e.jsxs("p",{className:"text-xs text-fg-muted mt-1",children:["Part ",t.partNumber+1," of ",t.totalParts]})]})});const n=a.slice(8);return n&&s.push({id:"payload:partData",title:"Part Data",color:"cyan",hex:n,startByte:4,endByte:4+n.length/2-1,decoded:e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-[11px] text-fg-secondary break-all p-2 rounded bg-body/50 font-mono",children:n.toUpperCase()}),e.jsxs("p",{className:"text-xs text-fg-muted mt-1",children:[n.length/2," bytes"]})]})}),s}function Na(t,a){switch(t.type){case"advert":return ua(t,a);case"ack":return pa(t,a);case"grp_txt":return fa(t,a);case"grp_data":return ga(t,a);case"path":return ya(t,a);case"trace":return ja(t,a);case"multipart":return ba(t,a);default:return[{id:"payload:ciphertext",title:"Raw Data",color:"zinc",hex:a,startByte:0,endByte:a.length/2-1,decoded:e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-[11px] text-fg-secondary break-all p-2 rounded bg-body/50 font-mono",children:a.toUpperCase()}),e.jsxs("p",{className:"text-xs text-fg-muted mt-1",children:[a.length/2," bytes"]})]})}]}}function va(t){return t.map(a=>({id:a.id,hex:a.hex,color:a.color}))}function wa({bits:t,field:a,value:s,binary:n}){const r=()=>{if(a==="Payload Type"){const i=Be[s]||"zinc";return e.jsx(B,{color:i,children:s})}if(a==="Route Type"){const i=De[s]||"zinc";return e.jsx(B,{color:i,children:s})}return e.jsx("span",{className:"text-sm text-fg-primary",children:s})};return e.jsxs("tr",{children:[e.jsx("td",{className:"py-1.5 text-xs text-fg-muted tabular-nums",children:t}),e.jsx("td",{className:"py-1.5 text-sm text-fg-secondary",children:a}),e.jsx("td",{className:"py-1.5",children:r()}),e.jsx("td",{className:"py-1.5 type-data-xs text-sys-cyan",children:n})]})}function Ct({id:t,title:a,color:s,hexBytes:n,startByte:r,endByte:i,isSelected:l,children:c}){const o=n?Ge(n):[];return e.jsxs(oe.div,{layout:"position",layoutId:t,transition:nt,className:"w-full min-w-0 overflow-hidden radius-inner p-4 sm:p-5 space-y-4",style:{backgroundColor:Te.cardRestBg,boxShadow:da(l,s)},children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-0.5 min-w-0",children:[e.jsx(B,{color:s,children:a}),o.length>0&&o.length<=16&&o.map((u,x)=>e.jsx(B,{color:s,className:"font-mono",children:u.toUpperCase()},x))]}),e.jsxs("span",{className:"type-data-xs text-fg-muted flex-shrink-0",children:["Bytes ",r,"-",i]})]}),e.jsx("div",{className:"min-w-0 overflow-hidden",children:c})]})}function ka({advert:t,timestamp:a}){const s=a?ie(a):ie(t.timestamp);return e.jsx("div",{className:"mb-4",children:e.jsxs("div",{className:"rounded-2xl overflow-hidden bg-sys-indigo/10",style:{backdropFilter:"blur(20px)",WebkitBackdropFilter:"blur(20px)"},children:[e.jsxs("div",{className:"px-4 pt-4 pb-3 flex items-center gap-3",children:[e.jsx("div",{className:"w-12 h-12 rounded-xl flex items-center justify-center shadow-lg",style:{background:"linear-gradient(135deg, var(--sys-indigo) 0%, var(--sys-blue) 100%)"},children:e.jsx(de,{className:"w-6 h-6 text-white"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"text-lg font-semibold text-fg-primary font-sans truncate leading-tight",children:t.name||"Unknown Node"}),e.jsx("p",{className:"text-sm text-fg-muted font-sans mt-0.5",children:t.nodeType})]})]}),e.jsx("div",{className:"mx-4 border-t border-edge-subtle"}),e.jsxs("div",{className:"px-4 py-3 space-y-2",children:[t.latitude!==void 0&&t.longitude!==void 0&&e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Ue,{className:"w-4 h-4 text-sys-indigo flex-shrink-0"}),e.jsxs("span",{className:"text-sm text-fg-secondary font-mono",children:[t.latitude.toFixed(5),"°, ",t.longitude.toFixed(5),"°"]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(xe,{className:"w-4 h-4 text-sys-indigo flex-shrink-0"}),e.jsx("span",{className:"text-sm text-fg-secondary font-sans",children:s})]})]})]})})}function Ca({decoded:t,timestamp:a}){const s=a?ie(a):"Unknown";return e.jsx("div",{className:"mb-4",children:e.jsxs("div",{className:"rounded-2xl overflow-hidden bg-sys-teal/10",style:{backdropFilter:"blur(20px)",WebkitBackdropFilter:"blur(20px)"},children:[e.jsxs("div",{className:"px-4 pt-4 pb-3 flex items-center gap-3",children:[e.jsx("div",{className:"w-12 h-12 rounded-xl flex items-center justify-center shadow-lg",style:{background:"linear-gradient(135deg, var(--sys-teal) 0%, var(--sys-cyan) 100%)"},children:e.jsx(nn,{className:"w-6 h-6 text-white"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"text-lg font-semibold text-fg-primary font-sans truncate leading-tight",children:t.channelName||"Channel Data"}),e.jsxs("p",{className:"text-sm text-fg-muted font-sans mt-0.5",children:[t.dataLength," bytes • ",t.decrypted?"Decrypted":"Encrypted"]})]})]}),e.jsx("div",{className:"mx-4 border-t border-edge-subtle"}),e.jsxs("div",{className:"px-4 py-3 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Kt,{className:"w-4 h-4 text-sys-teal flex-shrink-0"}),e.jsxs("span",{className:"text-sm text-fg-secondary font-sans",children:["Channel: ",e.jsxs("span",{className:"font-mono",children:["0x",t.channelHash]})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(xe,{className:"w-4 h-4 text-sys-teal flex-shrink-0"}),e.jsx("span",{className:"text-sm text-fg-secondary font-sans",children:s})]}),t.decrypted&&t.decryptedHex&&e.jsxs("div",{className:"mt-2 pt-2 border-t border-edge-subtle",children:[e.jsx("p",{className:"type-micro text-fg-muted mb-1 font-sans",children:"Decrypted Data"}),e.jsx("div",{className:"max-w-full overflow-x-auto",children:e.jsx(X,{size:"compact",copy:!0,className:"inline-block",children:e.jsx("span",{className:"break-all text-xs",children:t.decryptedHex.toUpperCase()})})})]})]})]})})}function Sa({decoded:t,timestamp:a,isLoading:s=!1,onDecrypted:n}){const r=a?ie(a):"Unknown",[i,l]=p.useState(""),[c,o]=p.useState(!1),[u,x]=p.useState(null),[g,f]=p.useState(!1),y=p.useCallback(async()=>{if(!(!i.trim()||!t.ciphertextHex||!t.macHex)){o(!0),x(null);try{const h=parseInt(t.channelHash,16),v=ut(t.macHex),T=ut(t.ciphertextHex),m=await vs(i.trim(),h,v,T);if(m.success){const N=m.result.plaintext,j=new TextDecoder("utf-8",{fatal:!1}).decode(N.slice(5)),C=j.indexOf(": "),k={...t,channelName:m.result.channelName,decrypted:!0,timestamp:N[0]|N[1]<<8|N[2]<<16|N[3]<<24,flags:N[4],senderName:C>0?j.slice(0,C):void 0,text:C>0?j.slice(C+2):j};n==null||n(k),l(""),f(!1)}else x(m.error)}catch(h){x(h instanceof Error?h.message:"Unknown error")}finally{o(!1)}}},[i,t,n]);return s?e.jsx("div",{className:"mb-4",children:e.jsxs("div",{className:"rounded-xl p-4 sm:p-5",style:{backgroundColor:"color-mix(in srgb, var(--elevated) 60%, var(--body))",boxShadow:` + inset 0 0 0 1px color-mix(in srgb, var(--fg-primary) 6%, transparent), + inset 0 1px 0 color-mix(in srgb, white 3%, transparent), + 0 1px 2px color-mix(in srgb, black 5%, transparent) + `},children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3 h-[15px]",children:[e.jsx("div",{className:"h-2.5 w-12 rounded bg-subtle-fill-hover animate-pulse"}),e.jsx("div",{className:"h-2.5 w-16 rounded bg-subtle-fill-hover animate-pulse"})]}),e.jsx("div",{className:"inline-block max-w-[85%] px-3.5 py-2 rounded-2xl rounded-tl-md",style:{background:"color-mix(in srgb, var(--sys-blue) 30%, transparent)"},children:e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("div",{className:"h-3.5 w-48 rounded bg-subtle-fill-strong animate-pulse"}),e.jsx("div",{className:"h-3.5 w-32 rounded bg-subtle-fill-strong animate-pulse"})]})})]})}):t.decrypted?e.jsx("div",{className:"mb-4",children:e.jsxs("div",{className:"rounded-xl p-4 sm:p-5",style:{backgroundColor:"color-mix(in srgb, var(--elevated) 60%, var(--body))",boxShadow:` + inset 0 0 0 1px color-mix(in srgb, var(--fg-primary) 6%, transparent), + inset 0 1px 0 color-mix(in srgb, white 3%, transparent), + 0 1px 2px color-mix(in srgb, black 5%, transparent) + `},children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[t.senderName&&e.jsxs("span",{className:"text-[11px] text-fg-muted font-sans",children:["From ",e.jsx("span",{className:"text-fg-secondary font-medium",children:t.senderName})]}),t.channelName&&e.jsxs("span",{className:"text-[11px] text-fg-muted font-sans",children:["in ",e.jsx("span",{className:"text-sys-cyan font-medium",children:t.channelName})]})]}),e.jsx("div",{className:"inline-block max-w-[85%] px-3.5 py-2 rounded-2xl rounded-tl-md",style:{background:"linear-gradient(135deg, var(--sys-blue) 0%, color-mix(in srgb, var(--sys-blue) 85%, var(--sys-cyan)) 100%)"},children:e.jsx("p",{className:"text-sm text-white font-sans leading-relaxed whitespace-pre-wrap break-words",children:t.text})})]})}):e.jsx("div",{className:"mb-4",children:e.jsxs("div",{className:"rounded-2xl overflow-hidden bg-zinc-500/10",style:{backdropFilter:"blur(20px)",WebkitBackdropFilter:"blur(20px)"},children:[e.jsxs("div",{className:"px-4 pt-4 pb-3 flex items-center gap-3",children:[e.jsx("div",{className:"w-12 h-12 rounded-xl flex items-center justify-center shadow-lg",style:{background:"linear-gradient(135deg, var(--zinc-500) 0%, color-mix(in srgb, var(--zinc-500) 70%, black) 100%)"},children:e.jsx(ot,{className:"w-6 h-6 text-white"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"text-lg font-semibold text-fg-primary font-sans truncate leading-tight",children:t.isPublicHashChannel?"Public Hash Channel":"Encrypted Message"}),e.jsxs("p",{className:"text-sm text-fg-muted font-sans mt-0.5",children:["Channel hash: ",e.jsxs("span",{className:"font-mono",children:["0x",t.channelHash]})]})]})]}),e.jsx("div",{className:"mx-4 border-t border-edge-subtle"}),e.jsxs("div",{className:"px-4 py-3 space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(xe,{className:"w-4 h-4 text-zinc-400 flex-shrink-0"}),e.jsx("span",{className:"text-sm text-fg-secondary font-sans",children:r})]}),t.ciphertextHex&&t.macHex&&e.jsx("div",{className:"space-y-2",children:g?e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",value:i,onChange:h=>l(h.target.value),placeholder:"Channel name (e.g. south-bay)",className:"flex-1 px-3 py-1.5 text-sm rounded-lg bg-subtle-fill-strong border border-edge-subtle text-fg-primary placeholder:text-fg-muted focus:outline-none focus:border-zinc-500",onKeyDown:h=>h.key==="Enter"&&y(),disabled:c}),e.jsx("button",{onClick:y,disabled:c||!i.trim(),className:"px-3 py-1.5 text-sm font-medium rounded-lg bg-zinc-600 hover:bg-zinc-500 text-white disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:c?"Testing...":"Try"}),e.jsx("button",{onClick:()=>{f(!1),x(null),l("")},className:"px-2 py-1.5 text-sm rounded-lg hover:bg-subtle-fill-strong text-fg-muted transition-colors",children:"×"})]}),u&&e.jsx("p",{className:"text-xs text-sys-red",children:u})]}):e.jsx("button",{onClick:()=>f(!0),className:"text-xs text-zinc-400 hover:text-zinc-300 underline underline-offset-2 transition-colors",children:"Know the channel name? Try to decrypt"})}),!g&&e.jsx("p",{className:"text-xs text-fg-muted",children:t.isPublicHashChannel?"Public hash channel message. Key not in common channel list.":"Unknown hash channel. Channel name required for decryption."})]})]})})}function _a({decoded:t,timestamp:a}){const s=a?ie(a):"Unknown";return e.jsxs("div",{className:"mb-4 flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl flex items-center justify-center shadow-md",style:{background:"linear-gradient(135deg, var(--sys-green) 0%, var(--sys-teal) 100%)"},children:e.jsx(sn,{className:"w-5 h-5 text-white"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-semibold text-fg-primary font-sans",children:"Acknowledgment"}),e.jsxs("p",{className:"text-xs text-fg-muted font-sans mt-0.5",children:["CRC: ",e.jsxs("span",{className:"font-mono text-sys-green",children:["0x",t.crc]})," · ",s]})]})]})}function Ma({decoded:t,timestamp:a}){const s=a?ie(a):"Unknown",n=t.path.length;return e.jsx("div",{className:"mb-4",children:e.jsxs("div",{className:"rounded-2xl overflow-hidden bg-sys-amber/10",style:{backdropFilter:"blur(20px)",WebkitBackdropFilter:"blur(20px)"},children:[e.jsxs("div",{className:"px-4 pt-4 pb-3 flex items-center gap-3",children:[e.jsx("div",{className:"w-12 h-12 rounded-xl flex items-center justify-center shadow-lg",style:{background:"linear-gradient(135deg, var(--sys-amber) 0%, var(--sys-orange) 100%)"},children:e.jsx(Tn,{className:"w-6 h-6 text-white"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"text-lg font-semibold text-fg-primary font-sans truncate leading-tight",children:"Path Response"}),e.jsxs("p",{className:"text-sm text-fg-muted font-sans mt-0.5",children:[n," ",n===1?"hop":"hops"]})]})]}),e.jsx("div",{className:"mx-4 border-t border-edge-subtle"}),e.jsxs("div",{className:"px-4 py-3 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(xe,{className:"w-4 h-4 text-sys-amber flex-shrink-0"}),e.jsx("span",{className:"text-sm text-fg-secondary font-sans",children:s})]}),t.path.length>0&&e.jsx("div",{className:"mt-2 pt-2 border-t border-edge-subtle",children:e.jsx("div",{className:"flex flex-wrap items-center gap-2",children:t.path.map((r,i)=>e.jsxs("div",{className:"flex items-center gap-2",children:[i>0&&e.jsx(pe,{className:"w-4 h-4 text-sys-amber"}),e.jsx(B,{color:"amber",className:"font-mono",children:r})]},i))})})]})]})})}function Ta({decoded:t,timestamp:a}){const s=a?ie(a):"Unknown",n=t.pathHashes.length,r=t.snrValues.length,i=l=>l>=7?"green":l>=0?"yellow":l>=-5?"orange":"red";return e.jsx("div",{className:"mb-4",children:e.jsxs("div",{className:"rounded-2xl overflow-hidden bg-sys-blue/10",style:{backdropFilter:"blur(20px)",WebkitBackdropFilter:"blur(20px)"},children:[e.jsxs("div",{className:"px-4 pt-4 pb-3 flex items-center gap-3",children:[e.jsx("div",{className:"w-12 h-12 rounded-xl flex items-center justify-center shadow-lg",style:{background:"linear-gradient(135deg, var(--sys-blue) 0%, var(--sys-indigo) 100%)"},children:e.jsx(tn,{className:"w-6 h-6 text-white"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("h3",{className:"text-lg font-semibold text-fg-primary font-sans truncate leading-tight",children:["Trace ",t.isComplete?"Complete":"In Progress"]}),e.jsxs("p",{className:"text-sm text-fg-muted mt-0.5",children:["Tag: 0x",t.traceTag.slice(0,8),t.isComplete&&" • ✓"]})]})]}),e.jsx("div",{className:"mx-4 border-t border-edge-subtle"}),e.jsxs("div",{className:"px-4 py-3 space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(xe,{className:"w-4 h-4 text-sys-blue flex-shrink-0"}),e.jsx("span",{className:"text-sm text-fg-secondary",children:s})]}),e.jsxs("div",{className:"flex items-center gap-4 text-xs text-fg-muted",children:[e.jsxs("span",{children:[n," target ",n===1?"hop":"hops"]}),e.jsx("span",{children:"•"}),e.jsxs("span",{children:[r," SNR ",r===1?"sample":"samples"]}),t.authCode!==0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"•"}),e.jsxs("span",{children:["Auth: ",t.authCode]})]})]}),t.pathHashes.length>0&&e.jsx("div",{className:"flex flex-wrap items-center gap-2 pt-1",children:t.pathHashes.map((l,c)=>{const o=t.snrValues[c],u=o!==void 0?i(o):"zinc",x=o!==void 0;return e.jsxs("div",{className:"flex items-center gap-2",children:[c>0&&e.jsx(pe,{className:"w-4 h-4 text-sys-blue flex-shrink-0"}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(B,{color:x?"blue":"zinc",className:"font-mono",children:l}),x&&e.jsxs(B,{color:u,className:"font-mono",children:[o>=0?"+":"",Number.isInteger(o)?o:o.toFixed(1),"dB"]})]})]},c)})})]})]})})}function Pa({decoded:t,timestamp:a}){const s=a?ie(a):"Unknown";return t.encrypted?e.jsxs("div",{className:"mb-4 flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl flex items-center justify-center shadow-md",style:{background:"linear-gradient(135deg, var(--sys-indigo) 0%, var(--sys-blue) 100%)"},children:e.jsx(ot,{className:"w-5 h-5 text-white"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-semibold text-fg-primary font-sans",children:"Encrypted Message"}),e.jsxs("p",{className:"text-xs text-fg-muted font-sans mt-0.5",children:[t.srcHash," → ",t.destHash," · ",s]})]})]}):e.jsxs("div",{className:"mb-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1.5 px-1",children:[e.jsxs("span",{className:"text-[11px] text-fg-muted font-sans",children:[e.jsx("span",{className:"font-mono text-fg-secondary",children:t.srcHash})," → ",e.jsx("span",{className:"font-mono text-fg-secondary",children:t.destHash})]}),e.jsxs("span",{className:"text-[11px] text-fg-muted font-sans",children:["· ",s]})]}),e.jsx("div",{className:"inline-block max-w-[85%] px-3.5 py-2 rounded-2xl rounded-tr-md ml-auto",style:{background:"linear-gradient(135deg, var(--sys-green) 0%, var(--sys-teal) 100%)"},children:e.jsx("p",{className:"text-sm text-white font-sans leading-relaxed whitespace-pre-wrap break-words",children:t.text})})]})}function Ba({decoded:t,timestamp:a}){const s=a?ie(a):"Unknown",n=(t.partNumber+1)/t.totalParts*100;return e.jsx("div",{className:"mb-4",children:e.jsxs("div",{className:"rounded-2xl overflow-hidden bg-sys-yellow/10",style:{backdropFilter:"blur(20px)",WebkitBackdropFilter:"blur(20px)"},children:[e.jsxs("div",{className:"px-4 pt-4 pb-3 flex items-center gap-3",children:[e.jsx("div",{className:"w-12 h-12 rounded-xl flex items-center justify-center shadow-lg",style:{background:"linear-gradient(135deg, var(--sys-yellow) 0%, var(--sys-amber) 100%)"},children:e.jsx(en,{className:"w-6 h-6 text-white"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"text-lg font-semibold text-fg-primary font-sans truncate leading-tight",children:"Multipart Segment"}),e.jsxs("p",{className:"text-sm text-fg-muted font-sans mt-0.5",children:["Part ",t.partNumber+1," of ",t.totalParts]})]})]}),e.jsx("div",{className:"mx-4 border-t border-edge-subtle"}),e.jsxs("div",{className:"px-4 py-3 space-y-3",children:[e.jsx("div",{children:e.jsx("div",{className:"h-2 bg-subtle-fill-strong rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${n}%`,background:"linear-gradient(90deg, var(--sys-yellow), var(--sys-amber))"}})})}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Kt,{className:"w-4 h-4 text-sys-yellow flex-shrink-0"}),e.jsxs("span",{className:"text-sm text-fg-secondary font-sans",children:["Message ID: ",e.jsx("span",{className:"font-mono",children:t.messageId})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(xe,{className:"w-4 h-4 text-sys-yellow flex-shrink-0"}),e.jsx("span",{className:"text-sm text-fg-secondary font-sans",children:s})]})]})]})})}function La({decoded:t,timestamp:a,payloadType:s}){const n=a?ie(a):"Unknown",i=(()=>{switch(s){case re.REQ:return{icon:ws,gradient:"var(--sys-orange), var(--sys-red)",bg:"rgba(249, 115, 22, 0.15)",label:"Request"};case re.RESPONSE:return{icon:_n,gradient:"var(--sys-green), var(--sys-teal)",bg:"rgba(34, 197, 94, 0.15)",label:"Response"};case re.ANON_REQ:return{icon:ot,gradient:"var(--sys-indigo), var(--sys-pink)",bg:"rgba(91, 91, 214, 0.15)",label:"Anonymous Request"};default:return{icon:Xs,gradient:"var(--sys-gray), var(--sys-slate)",bg:"rgba(107, 114, 128, 0.15)",label:t.payloadTypeName}}})(),l=i.icon;return e.jsxs("div",{className:"mb-4 flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl flex items-center justify-center shadow-md",style:{background:`linear-gradient(135deg, ${i.gradient})`},children:e.jsx(l,{className:"w-5 h-5 text-white"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-semibold text-fg-primary font-sans",children:i.label}),e.jsxs("p",{className:"text-xs text-fg-muted font-sans mt-0.5",children:[t.length," bytes · ",n]})]})]})}function Ra({pathHex:t}){if(!t)return null;const a=Ge(t);return e.jsx("div",{className:"flex flex-wrap items-center gap-2 py-2",children:a.map((s,n)=>e.jsxs("div",{className:"flex items-center gap-2",children:[n>0&&e.jsx(pe,{className:"w-4 h-4 text-sys-amber flex-shrink-0"}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(X,{size:"compact",copy:!0,children:s.toUpperCase()}),e.jsx("span",{className:"text-xs text-fg-muted font-sans tabular-nums w-4 text-left",children:n+1})]})]},n))})}function Ea({decoded:t,payloadType:a}){const s=Ns[a]||`TYPE_${a}`;switch(t.type){case"advert":{const n=t.nodeType==="chat"?"companion":t.nodeType.replace("_"," "),r=t.latitude!==void 0&&t.longitude!==void 0&&!(t.latitude===0&&t.longitude===0);return e.jsxs("div",{className:"text-xs text-fg-primary space-y-0.5",children:[e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Role:"})," ",n]}),t.name&&e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Name:"})," ",t.name]}),r&&e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Location:"})," ",t.latitude.toFixed(4),"°, ",t.longitude.toFixed(4),"°"]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Time:"})," ",ie(t.timestamp)]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Flags:"})," ",t.flagsDescription]})]})}case"ack":return e.jsx("div",{className:"text-xs text-fg-primary space-y-0.5",children:e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"CRC:"})," 0x",t.crc]})});case"path":return e.jsx("div",{className:"text-xs text-fg-primary space-y-1",children:e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Path:"})," ",t.pathString||"(empty)"]})});case"trace":return e.jsxs("div",{className:"text-xs text-fg-primary space-y-1",children:[e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Tag:"})," 0x",t.traceTag]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Target Path:"})," ",t.pathString||"(empty)"]}),t.snrValues.length>0&&e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"SNR:"})," ",t.snrValues.map(n=>`${n>=0?"+":""}${Number.isInteger(n)?n:n.toFixed(1)}dB`).join(" → ")]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Status:"})," ",t.isComplete?"✓ Complete":`In progress (${t.snrValues.length}/${t.pathHashes.length})`]})]});case"txt_msg":return e.jsxs("div",{className:"text-xs text-fg-primary space-y-0.5",children:[e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Dest:"})," ",t.destHash]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Src:"})," ",t.srcHash]}),t.encrypted?e.jsx("p",{className:"text-fg-muted italic",children:"Encrypted content"}):e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Text:"})," ",t.text]})]});case"grp_txt":return e.jsxs("div",{className:"text-xs text-fg-primary space-y-0.5",children:[e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Channel:"})," ",t.channelName?e.jsx("span",{className:"text-sys-green",children:t.channelName}):t.isPublicHashChannel?e.jsx("span",{className:"text-sys-indigo",children:"Public Hash Channel"}):e.jsxs("span",{className:"font-mono",children:["0x",t.channelHash]})]}),t.decrypted?e.jsxs(e.Fragment,{children:[t.senderName&&e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"From:"})," ",t.senderName]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Text:"})," ",t.text]})]}):t.isPublicHashChannel?e.jsx("p",{className:"text-fg-muted italic",children:"Encrypted (public hash channel)"}):e.jsx("p",{className:"text-fg-muted italic",children:"Encrypted (unknown channel)"})]});case"grp_data":return e.jsxs("div",{className:"text-xs text-fg-primary space-y-0.5",children:[e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Channel:"})," ",t.channelName?e.jsx("span",{className:"text-sys-teal",children:t.channelName}):e.jsxs("span",{className:"font-mono",children:["0x",t.channelHash]})]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Data:"})," ",t.dataLength," bytes ",t.decrypted?"(decrypted)":"(encrypted)"]})]});case"multipart":return e.jsxs("div",{className:"text-xs text-fg-primary space-y-0.5",children:[e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Part:"})," ",t.partNumber+1,"/",t.totalParts]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Message ID:"})," ",t.messageId]})]});case"control":return e.jsxs("div",{className:"text-xs text-fg-primary space-y-0.5",children:[e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Control:"})," ",t.subtypeName]}),t.dataLength>0&&e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Data:"})," ",t.dataLength," bytes"]})]});case"req":case"response":return e.jsxs("div",{className:"text-xs text-fg-primary space-y-0.5",children:[e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Dest:"})," ",t.destHash]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Src:"})," ",t.srcHash]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Ciphertext:"})," ",t.ciphertextLength," bytes"]})]});case"anon_req":return e.jsxs("div",{className:"text-xs text-fg-primary space-y-0.5",children:[e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Dest:"})," ",t.destHash]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Pub Key:"})," ",e.jsxs("span",{className:"font-mono break-all",children:[t.senderPublicKey.slice(0,16),"…"]})]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Ciphertext:"})," ",t.ciphertextLength," bytes"]})]});default:return e.jsxs("p",{className:"text-xs text-fg-secondary",children:[s," (","length"in t?t.length:0," bytes)"]})}}function za({packet:t,decodedGrpTxt:a}){var F,Y;const s=t.raw_packet||"",n=s.length/2,r=ys(),[i,l]=p.useState(null),[c,o]=p.useState(null),[u,x]=p.useState(!1),[g,f]=p.useState(null),y=p.useCallback(H=>{f(E=>E===H?null:H)},[]),h=p.useMemo(()=>Is(s),[s]),v=(F=h==null?void 0:h.packet)==null?void 0:F.payloadType,T=(h==null?void 0:h.payloadHex)||"",m=(Y=h==null?void 0:h.packet)==null?void 0:Y.payload,N=v===re.GRP_TXT,j=v===re.GRP_DATA,C=N&&!a&&(!r||u);if(p.useEffect(()=>{if(l(null),x(!1),a||!N||!m||m.length<4)return;if(!r){x(!0);return}x(!0);let H=!1;return Ks(m).then(E=>{H||(l(E),x(!1))}),()=>{H=!0}},[T,N,r,a]),p.useEffect(()=>{if(o(null),!j||!m||m.length<4||!r)return;let H=!1;return Ys(m).then(E=>{H||o(E)}),()=>{H=!0}},[T,j,r]),!h||s.length===0)return e.jsx("div",{className:"p-4 text-center text-fg-muted",children:e.jsx("p",{className:"text-sm",children:"No raw packet data available"})});const{packet:k}=h;let b=h.decoded;a&&h.decoded.type==="grp_txt"?b=a:i&&h.decoded.type==="grp_txt"?b=i:c&&h.decoded.type==="grp_data"&&(b=c);const A=()=>{switch(b.type){case"advert":return e.jsx(ka,{advert:b,timestamp:t.timestamp});case"grp_data":return e.jsx(Ca,{decoded:b,timestamp:t.timestamp});case"grp_txt":return e.jsx(Sa,{decoded:b,timestamp:t.timestamp,isLoading:C,onDecrypted:l});case"ack":return e.jsx(_a,{decoded:b,timestamp:t.timestamp});case"path":return e.jsx(Ma,{decoded:b,timestamp:t.timestamp});case"trace":return e.jsx(Ta,{decoded:b,timestamp:t.timestamp});case"txt_msg":return e.jsx(Pa,{decoded:b,timestamp:t.timestamp});case"multipart":return e.jsx(Ba,{decoded:b,timestamp:t.timestamp});case"generic":return k.payloadType===re.REQ||k.payloadType===re.RESPONSE||k.payloadType===re.ANON_REQ?e.jsx(La,{decoded:b,timestamp:t.timestamp,payloadType:k.payloadType}):null;default:return null}},U=p.useMemo(()=>Na(b,h.payloadHex),[b,h.payloadHex]),W=g==="payload"||je(g),K=p.useMemo(()=>{const H=[{id:"header",hex:h.headerHex,color:"red"},...h.transportCodesHex?[{id:"transportCodes",hex:h.transportCodesHex,color:"indigo"}]:[],{id:"pathLength",hex:h.pathLengthHex,color:"green"},...h.pathDataHex?[{id:"pathData",hex:h.pathDataHex,color:"amber"}]:[]];return W?[...H,...va(U)]:[...H,{id:"payload",hex:h.payloadHex,color:"cyan"}]},[h,W,U]);return e.jsxs("div",{className:"font-mono space-y-2 min-w-0 overflow-hidden",children:[A(),e.jsx(ma,{rawHex:s,hexSegments:K,selectedSegment:g,onSegmentClick:y}),e.jsx(js,{children:e.jsx(oe.div,{layout:!0,transition:nt,className:"space-y-2 min-w-0",children:(()=>{var M,D,te,se;const E=[{id:"header",title:"Header",color:"red",startByte:0,endByte:0,hexBytes:`0x${h.headerHex.toUpperCase()}`,condition:!0,content:e.jsxs("table",{className:"w-full text-left",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"type-micro text-fg-muted font-sans",children:[e.jsx("th",{className:"py-1 font-medium",children:e.jsx("span",{className:"underline underline-offset-4 decoration-edge-subtle",children:"Bits"})}),e.jsx("th",{className:"py-1 font-medium",children:e.jsx("span",{className:"underline underline-offset-4 decoration-edge-subtle",children:"Field"})}),e.jsx("th",{className:"py-1 font-medium",children:e.jsx("span",{className:"underline underline-offset-4 decoration-edge-subtle",children:"Value"})}),e.jsx("th",{className:"py-1 font-medium",children:e.jsx("span",{className:"underline underline-offset-4 decoration-edge-subtle",children:"Binary"})})]})}),e.jsx("tbody",{children:h.headerFields.map(d=>e.jsx(wa,{...d},d.bits))})]})},{id:"transportCodes",title:"Transport Codes",color:"indigo",startByte:1,endByte:4,hexBytes:((M=h.transportCodesHex)==null?void 0:M.toUpperCase())||"",condition:!!h.transportCodesHex,content:e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-xs text-fg-muted",children:"Two 16-bit transport codes for encrypted routing"}),e.jsxs("div",{className:"mt-1 text-xs text-fg-secondary",children:["Code 1: 0x",(D=h.transportCodesHex)==null?void 0:D.slice(0,4).toUpperCase()," | Code 2: 0x",(te=h.transportCodesHex)==null?void 0:te.slice(4,8).toUpperCase()]})]})},{id:"pathLength",title:"Path Length",color:"green",startByte:h.transportCodesHex?5:1,endByte:h.transportCodesHex?5:1,hexBytes:`0x${h.pathLengthHex.toUpperCase()}`,condition:!0,content:e.jsxs("p",{className:"text-xs text-fg-muted pt-1",children:[k.pathLen," bytes showing route taken (increases as packet floods)"]})},{id:"pathData",title:"Path Data",color:"amber",startByte:h.transportCodesHex?6:2,endByte:(h.transportCodesHex?5:1)+k.pathLen,hexBytes:((se=h.pathDataHex)==null?void 0:se.toUpperCase())||"",condition:k.pathLen>0,content:e.jsxs("div",{className:"space-y-3",children:[e.jsx(Ra,{pathHex:h.pathDataHex}),e.jsx("p",{className:"text-xs text-fg-muted",children:"Historical route taken (bytes are added as packet floods through network)"})]})},{id:"payload",title:"Payload",color:"cyan",startByte:h.payloadStartByte,endByte:n-1,hexBytes:h.payloadHex.toUpperCase(),condition:!0,content:e.jsxs(e.Fragment,{children:[!je(g)&&e.jsxs("div",{className:"p-3 radius-inner bg-inset depth-stroke-inset",children:[e.jsx("p",{className:"type-micro text-fg-muted mb-1.5 font-sans",children:"Decoded"}),e.jsx(Ea,{decoded:b,payloadType:k.payloadType})]}),!je(g)&&U.length>0&&e.jsx("p",{className:"type-micro text-fg-muted mt-3 font-sans",children:"Click a field below to highlight its bytes"}),je(g)&&e.jsx("p",{className:"type-micro text-fg-muted font-sans",children:"↑ Selected field above • Other fields below ↓"})]})}].filter(d=>d.condition),O=je(g)?U.find(d=>d.id===g):null,$=je(g)?[...E].sort((d,Z)=>d.id==="payload"?-1:Z.id==="payload"?1:0):[...E].sort((d,Z)=>d.id===g?-1:Z.id===g?1:0),J=je(g)?U.filter(d=>d.id!==g):[];return e.jsxs(e.Fragment,{children:[O&&e.jsx(Ct,{id:`subfield-${O.id}`,title:O.title,color:O.color,startByte:h.payloadStartByte+O.startByte,endByte:h.payloadStartByte+O.endByte,hexBytes:O.hex.toUpperCase(),isSelected:!0,children:O.decoded},O.id),$.map(d=>e.jsx(Ct,{id:`section-${d.id}`,title:d.title,color:d.color,startByte:d.startByte,endByte:d.endByte,hexBytes:d.hexBytes,isSelected:d.id===g,children:d.content},d.id)),J.map(d=>e.jsxs(oe.div,{layout:"position",layoutId:`subfield-${d.id}`,transition:nt,className:"w-full min-w-0 overflow-hidden radius-inner p-4 sm:p-5 space-y-4",style:{backgroundColor:Te.cardRestBg,boxShadow:Te.cardRestShadow},children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-0.5 min-w-0",children:[e.jsx(B,{color:d.color,children:d.title}),d.hex.length<=32&&Ge(d.hex).map((Z,q)=>e.jsx(B,{color:d.color,className:"font-mono",children:Z.toUpperCase()},q))]}),e.jsxs("span",{className:"type-data-xs text-fg-muted flex-shrink-0",children:["Bytes ",h.payloadStartByte+d.startByte,"-",h.payloadStartByte+d.endByte]})]}),e.jsx("div",{className:"min-w-0 overflow-hidden p-3 radius-inner bg-inset depth-stroke-inset",children:d.decoded})]},d.id))]})})()})})]})}const St=p.memo(za);function _t(t){if(!t)return[];if(Array.isArray(t))return t;try{const a=JSON.parse(t);return Array.isArray(a)?a:[]}catch{return[]}}function at({hop:t,compact:a=!1,index:s=0,highlightIndex:n=-1,isTrace:r=!1}){var c;const i=s===n,l=Fn();return p.useEffect(()=>{i&&r&&l.start({boxShadow:["0 0 0 0px rgba(113, 156, 223, 0)","0 0 0 2px rgba(113, 156, 223, 0.5)","0 0 0 2px rgba(113, 156, 223, 0.5)","0 0 0 0px rgba(113, 156, 223, 0)"],transition:{duration:.5,times:[0,.2,.7,1],ease:"easeInOut"}})},[i,r,l]),e.jsxs(oe.div,{className:R("flex items-center gap-1.5",a?"flex-row":"flex-col"),animate:{scale:i?1.05:1,opacity:i?1:.85},transition:{duration:.3,ease:"easeInOut"},children:[e.jsxs(oe.div,{className:R("flex items-center gap-1.5 px-2.5 py-1 rounded-md","font-mono text-xs font-semibold",t.isLocal?"bg-sys-amber/20 text-sys-amber ring-1 ring-sys-amber/30":"bg-elevated/50 text-fg-primary ring-1 ring-edge-strong/50"),animate:l,initial:{boxShadow:"0 0 0 0px rgba(113, 156, 223, 0)"},children:[t.isLocal&&e.jsx(an,{className:"w-3 h-3"}),e.jsx("span",{children:t.prefix}),t.confidence!==void 0&&t.confidence<.9&&e.jsxs("span",{className:"text-[9px] opacity-70",children:[(t.confidence*100).toFixed(0),"%"]})]}),!a&&((c=t.neighborInfo)==null?void 0:c.name)&&e.jsx("span",{className:"text-xs text-fg-muted truncate max-w-[80px]",children:t.neighborInfo.name})]})}function Fa({snr:t,sf:a}){const s=_s(t,a),r=Ss()[s]||"#6b7280",i=Number.isInteger(t)?t.toString():t.toFixed(1);return e.jsxs(B,{customColor:r,compact:!0,className:"font-mono",children:[t>=0?"+":"",i,"dB"]})}function Ia({hops:t,compact:a,isTrace:s=!1,sf:n}){const[r,i]=p.useState(-1);return p.useEffect(()=>{if(t.length===0)return;const l=setTimeout(()=>{i(0)},400),c=setInterval(()=>{i(o=>{const u=o+1;return u>=t.length?(clearInterval(c),-1):u})},s?500:600);return()=>{clearTimeout(l),clearInterval(c)}},[t.length,s]),e.jsx("div",{className:"p-6",style:{display:"grid",gridTemplateColumns:"1fr auto 1fr",gap:"4px 8px"},children:t.map((l,c)=>{const o=c%2===0,u=c===t.length-1;return e.jsxs("div",{className:"contents",children:[e.jsx("div",{className:R("flex items-center","justify-end"),children:o&&e.jsx(at,{hop:l,compact:a,index:c,highlightIndex:r,isTrace:s})}),e.jsx("div",{className:"flex flex-col items-center justify-center min-h-[28px]",children:!u&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-px flex-1 bg-border-strong/40 min-h-[8px]"}),l.snr!==void 0&&e.jsx(Fa,{snr:l.snr,sf:n}),e.jsx("svg",{className:"w-3 h-3 text-fg-muted flex-shrink-0",viewBox:"0 0 12 12",fill:"none",children:e.jsx("path",{d:"M6 2v8M3 7l3 3 3-3",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})]})}),e.jsx("div",{className:R("flex items-center","justify-start"),children:!o&&e.jsx(at,{hop:l,compact:a,index:c,highlightIndex:r,isTrace:s})})]},`${l.prefix}-${c}`)})})}function Aa({packet:t,neighbors:a,localHash:s,neighborAffinity:n,ghostPrefixes:r,direction:i="horizontal",compact:l=!1,traceSnr:c,overridePath:o}){const u=c!==void 0&&c.length>0,x=ks(),g=_t(t.original_path),f=_t(t.forwarded_path),y=o??(f.length>0?f:g),h=s?He(s):"",v=p.useMemo(()=>y.map((m,N)=>{const j=m.toUpperCase(),C=j===h,k=(r==null?void 0:r.has(j))??!1,b=Cs(j,a,n);return{prefix:j,fullHash:b==null?void 0:b.hash,neighborInfo:b==null?void 0:b.info,isLocal:C,isGhost:k,confidence:b==null?void 0:b.confidence,snr:c==null?void 0:c[N]}}),[y,a,n,h,r,c]);if(v.length===0)return e.jsxs("div",{className:"flex items-center gap-2 text-fg-muted text-xs",children:[e.jsx(de,{className:"w-4 h-4 opacity-50"}),e.jsx("span",{children:"Direct / No path data"})]});if(i==="flowchart")return e.jsx(Ia,{hops:v,compact:l,isTrace:u,sf:x});const T=i==="horizontal"?pe:qt;return e.jsx("div",{className:R("flex gap-1.5",i==="horizontal"?"flex-row flex-wrap items-center":"flex-col items-start"),children:v.map((m,N)=>e.jsxs("div",{className:R("flex items-center gap-1.5",i==="vertical"&&"flex-col"),children:[e.jsx(at,{hop:m,compact:l}),N"blue",Ha=[{fn:"id",group:"identity",fmt:"int",read:t=>ee(t.id),color:V},{fn:"packet_hash",group:"identity",fmt:"hex",read:t=>t.packet_hash||void 0,color:V},{fn:"timestamp",group:"identity",fmt:"epoch",read:t=>t.timestamp?String(t.timestamp):void 0,color:V,annotate:t=>t.timestamp>0?Je(t.timestamp):void 0},{fn:"type",group:"classification",fmt:"enum",read:t=>ee(t.type??t.payload_type),color:V},{fn:"route",group:"classification",fmt:"enum",read:t=>ee(t.route??t.route_type),color:V},{fn:"rssi",group:"signal",fmt:"int",read:t=>ee(t.rssi,"dBm"),color:V},{fn:"snr",group:"signal",fmt:"float",read:t=>ee(t.snr,"dB"),color:V},{fn:"path_length",group:"size",fmt:"int",read:t=>{if(t.path_length!=null)return t.path_length===0?"zero-hop":`${t.path_length} hops`},color:V},{fn:"payload_length",group:"size",fmt:"int",read:t=>ee(t.payload_length,"B"),color:V},{fn:"airtime",group:"size",fmt:"float",read:t=>ee(t.airtime_ms,"ms"),color:V},{fn:"src_hash",group:"addressing",fmt:"hex<2>",read:t=>t.src_hash??void 0,color:V},{fn:"dst_hash",group:"addressing",fmt:"hex<2>",read:t=>t.dst_hash??void 0,color:V},{fn:"path_hash",group:"addressing",fmt:"hex[]|hex",read:t=>Array.isArray(t.path_hash)?`[${t.path_hash.join(", ")}]`:ee(t.path_hash),color:V,renderValue:t=>Array.isArray(t.path_hash)?Xe(t.path_hash):null},{fn:"score",group:"addressing",fmt:"int",read:t=>ee(t.score),color:V},{fn:"original_path",group:"paths",fmt:"hex[]",read:t=>Array.isArray(t.original_path)?`[${t.original_path.join(", ")}]`:void 0,color:V,renderValue:t=>Array.isArray(t.original_path)&&t.original_path.length>0?Xe(t.original_path,t.src_hash||void 0,t.dst_hash||void 0,!0):null},{fn:"forwarded_path",group:"paths",fmt:"hex[]",read:t=>Array.isArray(t.forwarded_path)?`[${t.forwarded_path.join(", ")}]`:void 0,color:V,renderValue:t=>Array.isArray(t.forwarded_path)&&t.forwarded_path.length>0?Xe(t.forwarded_path):null},{fn:"transmitted",group:"status",fmt:"bool",read:t=>ee(t.transmitted),color:V},{fn:"is_duplicate",group:"status",fmt:"bool",read:t=>ee(t.is_duplicate),color:V},{fn:"drop_reason",group:"status",fmt:"string|null",read:t=>t.drop_reason??void 0,color:V},{fn:"tx_delay",group:"status",fmt:"int",read:t=>ee(t.tx_delay_ms,"ms"),color:V},{fn:"origin",group:"status",fmt:"enum",read:t=>t.packet_origin??void 0,color:V},{fn:"duplicates",group:"status",fmt:"PacketDuplicate[]",read:t=>t.duplicates!=null&&t.duplicates.length>0?`${t.duplicates.length}`:ee(t.duplicates),color:V},{fn:"lbt_attempts",group:"lbt",fmt:"int",read:t=>ee(t.lbt_attempts),color:V},{fn:"lbt_backoff",group:"lbt",fmt:"json",read:t=>ee(t.lbt_backoff_delays_ms),color:V},{fn:"lbt_busy",group:"lbt",fmt:"bool|int",read:t=>ee(t.lbt_channel_busy),color:V}];function Xe(t,a,s,n){const r=t.length>0,i=a||n,l=s||n;return e.jsxs("span",{className:"inline-flex items-center gap-1 flex-wrap",children:[i&&e.jsxs(e.Fragment,{children:[a?e.jsx("span",{className:"inline-block border border-edge-subtle rounded px-1.5 py-0.5 font-mono text-[11px] text-sys-blue",children:a}):e.jsx("span",{className:"inline-block border border-edge-subtle/50 rounded px-1.5 py-0.5 font-mono text-[11px] text-fg-muted/30",children:"XX"}),(r||l)&&e.jsx("span",{className:"text-fg-muted/40 text-[10px]",children:"→"})]}),t.map((c,o)=>e.jsxs(p.Fragment,{children:[o>0&&e.jsx("span",{className:"text-fg-muted/40 text-[10px]",children:"→"}),e.jsx("span",{className:"inline-block border border-edge-subtle rounded px-1.5 py-0.5 font-mono text-[11px] text-sys-blue",children:c})]},o)),l&&e.jsxs(e.Fragment,{children:[r&&e.jsx("span",{className:"text-fg-muted/40 text-[10px]",children:"→"}),s?e.jsx("span",{className:"inline-block border border-edge-subtle rounded px-1.5 py-0.5 font-mono text-[11px] text-sys-blue",children:s}):e.jsx("span",{className:"inline-block border border-edge-subtle/50 rounded px-1.5 py-0.5 font-mono text-[11px] text-fg-muted/30",children:"XX"})]})]})}let Ie=null;function Da(){if(!Ie){Ie=new Map;for(const t of Ha)Ie.set(t.fn,t)}return Ie}function Mt(t,a){var l;const s=Da().get(a);if(!s)return null;const n=s.read(t);if(n===void 0)return null;const r=s.color(t),i=(l=s.annotate)==null?void 0:l.call(s,t);return i?{text:n,color:r,annotation:i}:{text:n,color:r}}function Tt(t){if(!t)return[];if(Array.isArray(t))return t;try{const a=JSON.parse(t);return Array.isArray(a)?a:[]}catch{return[]}}function Pt({packets:t,selectedIndex:a,onSelect:s,compact:n=!1}){if(t.length<=1)return null;const r=a>0,i=ar&&s(a-1),disabled:!r,className:R("p-0.5 radius-badge transition-base",r?"text-fg-muted hover:text-fg-primary hover-bg":"text-fg-muted cursor-not-allowed"),"aria-label":"Previous observation",children:e.jsx(Yt,{className:n?"size-3":"size-4"})}),e.jsx("div",{className:"flex items-center gap-0.5",children:t.map((l,c)=>{const o=c===a,x=new Date(l.timestamp*1e3).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"});return e.jsx(Es,{color:o?"cyan":"zinc",filled:o,compact:n,onClick:()=>s(c),title:`Observation ${c+1} at ${x}`,className:R("transition-all duration-150",!o&&"opacity-60 hover:opacity-100"),children:n?e.jsx("span",{className:"tabular-nums",children:c+1}):e.jsxs("span",{className:"tabular-nums text-xs",children:["#",c+1,l.rssi!=null&&e.jsx("span",{className:"ml-1 opacity-70",children:l.rssi})]})},`${l.timestamp}_${c}`)})}),e.jsx("button",{onClick:()=>i&&s(a+1),disabled:!i,className:R("p-0.5 radius-badge transition-base",i?"text-fg-muted hover:text-fg-primary hover-bg":"text-fg-muted cursor-not-allowed"),"aria-label":"Next observation",children:e.jsx(ct,{className:n?"size-3":"size-4"})}),e.jsxs("span",{className:R("text-fg-muted ml-1",n?"text-[9px]":"text-xs"),children:[e.jsx(it,{className:"inline size-3 mr-0.5 opacity-50"}),t.length]})]})}function Ae({icon:t,label:a,disabled:s=!1}){return e.jsx(oe.div,{className:"flex items-center gap-1 text-xs",title:a,animate:{opacity:s?.25:.6},transition:{duration:.15,ease:[.4,0,.2,1]},children:e.jsx("span",{className:R("flex items-center justify-center size-5 radius-badge border-control transition-base",s?"bg-subtle-fill border-edge-subtle":"bg-subtle-fill"),children:t})})}function Oa({hasDuplicates:t,hasPrev:a,hasNext:s,canPrevDupe:n,canNextDupe:r}){return e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs("div",{className:"flex items-center gap-0.5",children:[e.jsx(Ae,{icon:e.jsx(bn,{className:"size-3"}),label:"Previous packet (↑)",disabled:!a}),e.jsx(Ae,{icon:e.jsx(zs,{className:"size-3"}),label:"Next packet (↓)",disabled:!s})]}),t&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-px h-3 bg-subtle-fill-strong"}),e.jsxs("div",{className:"flex items-center gap-0.5",children:[e.jsx(Ae,{icon:e.jsx(Yt,{className:"size-3"}),label:"Previous observation (←)",disabled:!n}),e.jsx(Ae,{icon:e.jsx(ct,{className:"size-3"}),label:"Next observation (→)",disabled:!r})]})]})]})}function $a({packets:t,initialIndex:a=0,onClose:s,onNavigatePrev:n,onNavigateNext:r,hasPrev:i=!1,hasNext:l=!1,resolveSource:c,getDecodedContent:o}){var ze;const[u,x]=p.useState(a),g=t[u]??t[0],f=t.length>1,[y,h]=p.useState(null),[v,T]=p.useState(!1);p.useEffect(()=>{if(!g._stripped){h(null);return}let G=!1;T(!0);const w=g.packet_hash;if(!w){T(!1);return}return Ms(w).then(S=>{G||(S.success&&S.data&&(h(S.data),(S.data.type??S.data.payload_type)===re.GRP_TXT&&S.data.raw_packet&&Ts.getState().queueDecryption([S.data])),T(!1))}).catch(()=>{G||T(!1)}),()=>{G=!0}},[g]);const m=y??g,N=u>0,j=u{x(Math.max(0,Math.min(G,t.length-1)))},[t.length]);p.useEffect(()=>{const G=w=>{if(!(w.target instanceof HTMLInputElement||w.target instanceof HTMLTextAreaElement))switch(w.key){case"ArrowUp":w.preventDefault(),n==null||n();break;case"ArrowDown":w.preventDefault(),r==null||r();break;case"ArrowLeft":w.preventDefault(),N&&x(S=>S-1);break;case"ArrowRight":w.preventDefault(),j&&x(S=>S+1);break}};return window.addEventListener("keydown",G),()=>window.removeEventListener("keydown",G)},[n,r,N,j]);const k=Dt(),b=Ps(),A=Bs(),U=Ls(),W=p.useMemo(()=>new Set(U.map(G=>G.prefix.toUpperCase())),[U]),K=m.payload_type_name||At(m.payload_type??m.type),F=m.route_type_name||Ht(m.route_type??m.route),Y=m.payload_length??m.length??0,H=Tt(m.original_path),E=Tt(m.forwarded_path),O=H.length>0||E.length>0,$=E.length>0?E:H,J=p.useMemo(()=>{var G;if((G=k==null?void 0:k.config)!=null&&G.repeater)return{latitude:k.config.repeater.latitude,longitude:k.config.repeater.longitude,name:k.config.node_name||"Local Node"}},[k]),M=(k==null?void 0:k.neighbors)??{},D=A.size>0?A:void 0,te=m.raw_packet&&m.raw_packet.length>0,se=g._stripped&&v,d=p.useMemo(()=>c?c(m):null,[c,m]),Z=Rs(m.packet_hash),q=p.useMemo(()=>!o||(m.payload_type??m.type)!==re.GRP_TXT?null:o(m),[o,m]),le=p.useMemo(()=>{if((m.payload_type??m.type)!==re.GRP_TXT)return null;if(Z!=null&&Z.decoded){const w=Z.decoded;return{type:"grp_txt",channelHash:w.channelHash,channelName:w.channelName,text:w.text??"",decrypted:w.decrypted,senderName:w.senderName,timestamp:w.timestamp,flags:w.flags,macCorrupted:w.macCorrupted}}return q!=null&&q.decrypted?{type:"grp_txt",channelHash:q.channelHash??"",channelName:q.channelName??"",text:q.text??"",decrypted:!0,senderName:q.senderName??"",timestamp:0,flags:0,macCorrupted:q.corrupted}:null},[m,Z,q]),P=p.useMemo(()=>As(m,le),[m,le]),z=P.kind==="trace"?P.data:null,ne=P.kind==="trace"?P.snrValues:void 0,_=P.kind==="advert"?P.data:null,ce=P.kind==="advert"?P.sourceNode:void 0,fe=P.kind==="grp_txt"?P.wardriveSourceNode??void 0:void 0,ae=P.kind==="anon_req"?P.data:null,Le=G=>!G||G===0?"Unknown":new Date(G*1e3).toLocaleString(),be=(m.payload_type??m.type)===re.ADVERT&&(ce!==void 0||O),Re=fe!==void 0,Ne=ce??fe,qe=Be[K]??"zinc",Ee=ue[qe]||ue.zinc;return e.jsxs(Ot,{open:!0,onClose:s,size:"5xl",motionPlus:!0,solid:!0,className:"sm:h-[85vh] sm:max-h-[800px] md:h-[80vh] md:max-h-[900px]",children:[e.jsxs("div",{className:"sm:hidden",children:[e.jsx("div",{className:"flex justify-center pt-2 pb-1",children:e.jsx("div",{className:"w-9 h-1 rounded-full bg-fg-muted","aria-hidden":"true"})}),e.jsxs("div",{className:"flex items-center justify-between px-3 pb-2",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(B,{color:Be[K]??"zinc",className:"!text-[9px] !px-1.5 !py-0",children:K}),e.jsx(B,{color:De[F]??"zinc",className:"!text-[9px] !px-1.5 !py-0",children:F}),e.jsxs(B,{color:"zinc",className:"!text-[9px] !px-1.5 !py-0",children:[Y,"B"]})]}),e.jsx("button",{onClick:s,className:"px-3 py-1.5 text-[15px] font-medium text-sys-blue active:text-sys-blue/80 transition-base flex-shrink-0 radius-inner active:bg-subtle-fill",children:"Done"})]}),f&&e.jsx("div",{className:"px-3 pb-2",children:e.jsx(Pt,{packets:t,selectedIndex:u,onSelect:C,compact:!0})})]}),e.jsx("div",{className:"hidden sm:block px-6 pt-5 pb-4",children:e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(B,{color:Be[K]??"zinc",children:K}),e.jsx(B,{color:De[F]??"zinc",children:F}),e.jsxs(B,{color:"zinc",children:[Y,"B"]}),f&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-px h-4 bg-subtle-fill-strong"}),e.jsx(Pt,{packets:t,selectedIndex:u,onSelect:C})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Oa,{hasDuplicates:f,hasPrev:i,hasNext:l,canPrevDupe:N,canNextDupe:j}),e.jsx("button",{onClick:s,className:"p-1.5 -m-1.5 text-fg-muted hover:text-fg-primary transition-base radius-inner hover:bg-elevated flex-shrink-0",children:e.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]})]})}),e.jsx("div",{className:"sm:hidden h-[2px]",style:{backgroundColor:Ee,opacity:.6}}),e.jsxs($t,{className:"p-0 overflow-hidden flex-1 flex flex-col min-h-0",children:[e.jsx("div",{className:"md:hidden flex-1 overflow-y-auto overflow-x-hidden",children:e.jsxs("div",{className:"px-2 pt-2 space-y-2",children:[(m.rssi!=null||m.snr!=null)&&e.jsxs("div",{className:"relative flex items-center justify-between px-2 py-1.5 radius-inner bg-subtle-fill depth-stroke",children:[e.jsx(Ke,{mode:"popLayout",initial:!1,children:e.jsxs(oe.div,{className:"flex items-center gap-3",initial:{opacity:0,scale:.96},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.96},transition:{duration:.15,ease:[.4,0,.2,1]},children:[e.jsx(Oe,{rssi:m.rssi,snr:m.snr,compact:!0,showValues:!0,validated:$e(m)}),e.jsx("span",{className:"text-[11px] text-fg-muted",children:pt(m.rssi)})]},u)}),$.length>0&&e.jsxs("span",{className:"type-data-xs text-fg-muted",children:[$.length," hop",$.length!==1?"s":""]})]}),(O&&$.length>0||be||Re)&&e.jsx("div",{className:"overflow-hidden",children:e.jsx("div",{className:"aspect-[4/3] w-full",children:e.jsx(We,{path:$,neighbors:M,localNode:J,localHash:k==null?void 0:k.local_hash,srcHash:m.src_hash,dstHash:m.dst_hash,neighborAffinity:D,hubNodes:[...b],traceSnr:ne,advertiserSource:Ne})})}),z&&z.pathHashes.length>0&&e.jsxs("div",{className:"radius-inner bg-inset overflow-hidden depth-stroke-inset",children:[e.jsx("div",{className:"px-3 py-2 space-y-1.5",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"type-micro text-fg-muted",children:"Trace Route"}),e.jsx("div",{className:"flex items-center gap-1.5",children:e.jsx(B,{color:z.isComplete?"green":"amber",compact:!0,children:z.isComplete?"Complete":"In Progress"})})]})}),e.jsx(Se,{packet:m,neighbors:M,localHash:k==null?void 0:k.local_hash,neighborAffinity:D,ghostPrefixes:W,direction:"flowchart",compact:!0,overridePath:z.pathHashes,traceSnr:z.snrValues})]}),O&&!z&&e.jsxs("div",{className:"radius-inner bg-inset overflow-hidden depth-stroke-inset",children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-2",children:[e.jsx("span",{className:"type-micro text-fg-muted",children:"Path"}),e.jsxs(B,{color:"zinc",compact:!0,children:[$.length," hop",$.length!==1?"s":""]})]}),e.jsx(Se,{packet:m,neighbors:M,localHash:k==null?void 0:k.local_hash,neighborAffinity:D,ghostPrefixes:W,direction:"flowchart",compact:!0,traceSnr:ne})]}),d&&(d.name||d.hash)&&!_&&!ae&&e.jsxs("div",{className:"radius-inner bg-subtle-fill overflow-hidden depth-stroke",children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-2",children:[e.jsx("span",{className:"type-micro text-fg-muted",children:"Source"}),e.jsx(B,{color:d.isRepeater?"blue":d.isCompanion?"violet":d.type==="room_server"?"lime":"zinc",compact:!0,children:d.type==="room_server"?"room server":d.type})]}),e.jsxs("div",{className:"p-3 space-y-1.5",children:[d.name&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ce,{className:"w-3.5 h-3.5 text-fg-muted flex-shrink-0"}),e.jsx("span",{className:"type-label text-fg-primary truncate",children:d.name}),!d.confident&&e.jsx("span",{className:"text-[9px] text-fg-muted/60 italic",children:"ambiguous"})]}),d.hash&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(we,{className:"w-3.5 h-3.5 text-fg-muted flex-shrink-0"}),e.jsx("span",{className:"type-data-xs text-fg-muted truncate font-mono",children:d.hash.length>16?`${d.hash.slice(0,16)}…${d.hash.slice(-8)}`:d.hash.startsWith("0x")?d.hash.slice(2,10)+"…":d.hash.slice(0,8)+"…"})]})]})]}),ae&&e.jsxs("div",{className:"radius-inner bg-subtle-fill overflow-hidden depth-stroke",children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-2",children:[e.jsx("span",{className:"type-micro text-fg-muted",children:"Sender Identity"}),e.jsx(B,{color:d!=null&&d.isRepeater?"blue":d!=null&&d.isCompanion?"violet":(d==null?void 0:d.type)==="room_server"?"lime":"amber",compact:!0,children:d!=null&&d.type&&d.type!=="unknown"?d.type==="room_server"?"room server":d.type:"companion"})]}),e.jsxs("div",{className:"p-3 space-y-2",children:[(d==null?void 0:d.name)&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ce,{className:"w-3.5 h-3.5 text-fg-muted flex-shrink-0"}),e.jsx("span",{className:"type-label text-fg-primary truncate",children:d.name}),!d.confident&&e.jsx("span",{className:"text-[9px] text-fg-muted/60 italic",children:"ambiguous"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(de,{className:"w-3.5 h-3.5 text-fg-muted flex-shrink-0"}),e.jsxs("span",{className:"text-xs text-fg-muted",children:["Dest: ",e.jsx("span",{className:"font-mono",children:ae.destHash})]})]}),e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(we,{className:"w-3.5 h-3.5 text-fg-muted flex-shrink-0 mt-0.5"}),e.jsx("span",{className:"type-data-xs text-fg-muted break-all font-mono leading-relaxed",children:ae.senderPublicKey})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(xe,{className:"w-3.5 h-3.5 text-fg-muted flex-shrink-0"}),e.jsxs("span",{className:"text-xs text-fg-muted",children:[ae.ciphertextLength,"B encrypted payload"]})]})]})]}),_&&e.jsxs("div",{className:"radius-inner bg-subtle-fill overflow-hidden depth-stroke",children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-2",children:[e.jsx("span",{className:"type-micro text-fg-muted",children:"Advertiser Info"}),e.jsx(B,{color:"lime",compact:!0,children:_.nodeType})]}),e.jsxs("div",{className:"p-3 space-y-2",children:[_.name&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ce,{className:"w-3.5 h-3.5 text-fg-muted flex-shrink-0"}),e.jsx("span",{className:"type-label text-fg-primary truncate",children:_.name})]}),_.latitude&&_.longitude&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ue,{className:"w-3.5 h-3.5 text-fg-muted flex-shrink-0"}),e.jsxs("span",{className:"type-data-xs text-fg-secondary",children:[_.latitude.toFixed(5),", ",_.longitude.toFixed(5)]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(we,{className:"w-3.5 h-3.5 text-fg-muted flex-shrink-0"}),e.jsxs("span",{className:"type-data-xs text-fg-muted truncate",children:[_.publicKey.slice(0,16),"...",_.publicKey.slice(-8)]})]}),_.timestamp>0&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(xe,{className:"w-3.5 h-3.5 text-fg-muted flex-shrink-0"}),e.jsx("span",{className:"text-xs text-fg-muted",children:Le(_.timestamp)})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(de,{className:"w-3.5 h-3.5 text-fg-muted flex-shrink-0"}),e.jsx("span",{className:"text-xs text-fg-muted",children:_.flagsDescription||`Flags: 0x${_.flags.toString(16).padStart(2,"0")}`})]})]})]}),se?e.jsx("div",{className:"pt-1 px-3 py-6 text-center",children:e.jsx("span",{className:"text-xs text-fg-muted animate-pulse",children:"Loading packet details…"})}):te?e.jsx("div",{className:"pt-1",children:e.jsx(St,{packet:m,decodedGrpTxt:le})}):null]})}),e.jsxs("div",{className:"hidden md:grid md:grid-cols-2 flex-1 overflow-hidden",children:[e.jsx("div",{className:"overflow-y-auto overflow-x-hidden scrollbar-none px-4 pt-4",children:se?e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsx("span",{className:"text-sm text-fg-muted animate-pulse",children:"Loading packet details…"})}):te?e.jsx(St,{packet:m,decodedGrpTxt:le}):null}),e.jsxs("div",{className:"grid overflow-hidden",style:{gridTemplateRows:"minmax(280px, 1fr) auto"},children:[e.jsx("div",{className:"overflow-hidden p-2",children:O&&$.length>0||be||Re?e.jsx("div",{className:"h-full w-full overflow-hidden",children:e.jsx(We,{path:$,neighbors:M,localNode:J,localHash:k==null?void 0:k.local_hash,srcHash:m.src_hash,dstHash:m.dst_hash,neighborAffinity:D,hubNodes:[...b],traceSnr:ne,advertiserSource:Ne})}):e.jsxs("div",{className:"h-full w-full flex flex-col items-center justify-center text-center px-4",children:[e.jsx(de,{className:"w-8 h-8 text-fg-muted/50 mb-2"}),e.jsx("span",{className:"text-sm text-fg-muted",children:"Direct Reception"}),e.jsx("span",{className:"text-xs text-fg-muted/70 mt-1",children:"Zero-hop packet — received directly from sender"})]})}),e.jsxs("div",{className:"overflow-y-auto max-h-[200px] p-2 space-y-2",children:[!z&&$.length<=1&&(m.rssi!=null||m.snr!=null)&&e.jsx("div",{className:"surface-base radius-inner p-4 depth-stroke",children:e.jsxs("dl",{className:"text-xs grid grid-cols-2 gap-2",children:[e.jsxs("div",{children:[e.jsx("dt",{className:"text-fg-muted mb-1",children:"Signal"}),e.jsx(Ke,{mode:"popLayout",initial:!1,children:e.jsxs(oe.dd,{className:"flex items-center gap-2",initial:{opacity:0,scale:.96},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.96},transition:{duration:.15,ease:[.4,0,.2,1]},children:[e.jsx(Oe,{rssi:m.rssi,snr:m.snr,validated:$e(m)}),e.jsx("span",{className:"font-medium text-fg-primary",children:pt(m.rssi)})]},u)})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-fg-muted mb-1",children:"RF"}),e.jsx(Ke,{mode:"popLayout",initial:!1,children:e.jsxs(oe.dd,{className:"type-data text-fg-secondary",initial:{opacity:0,scale:.96},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.96},transition:{duration:.15,ease:[.4,0,.2,1]},children:[(ze=Mt(m,"rssi"))==null?void 0:ze.text,(()=>{const G=Mt(m,"snr");return G?` · ${G.text}`:null})()]},u)})]})]})}),d&&(d.name||d.hash)&&!_&&!ae&&e.jsxs("div",{className:"radius-inner bg-subtle-fill overflow-hidden depth-stroke",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-2",children:[e.jsx("span",{className:"type-micro text-fg-muted",children:"Source"}),e.jsx(B,{color:d.isRepeater?"blue":d.isCompanion?"violet":d.type==="room_server"?"lime":"zinc",compact:!0,children:d.type==="room_server"?"room server":d.type})]}),e.jsxs("div",{className:"p-4 space-y-2",children:[d.name&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ce,{className:"w-4 h-4 text-fg-muted flex-shrink-0"}),e.jsx("span",{className:"type-label text-fg-primary truncate",children:d.name}),!d.confident&&e.jsx("span",{className:"text-[10px] text-fg-muted/60 italic",children:"ambiguous"})]}),d.hash&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(we,{className:"w-4 h-4 text-fg-muted flex-shrink-0"}),e.jsx("span",{className:"text-[11px] font-mono text-fg-muted truncate",children:d.hash.length>16?`${d.hash.slice(0,16)}…${d.hash.slice(-8)}`:d.hash.startsWith("0x")?d.hash.slice(2,10)+"…":d.hash.slice(0,8)+"…"})]})]})]}),ae&&e.jsxs("div",{className:"radius-inner bg-subtle-fill overflow-hidden depth-stroke",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-2",children:[e.jsx("span",{className:"type-micro text-fg-muted",children:"Sender Identity"}),e.jsx(B,{color:d!=null&&d.isRepeater?"blue":d!=null&&d.isCompanion?"violet":(d==null?void 0:d.type)==="room_server"?"lime":"amber",compact:!0,children:d!=null&&d.type&&d.type!=="unknown"?d.type==="room_server"?"room server":d.type:"companion"})]}),e.jsxs("div",{className:"p-4 space-y-2.5",children:[(d==null?void 0:d.name)&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ce,{className:"w-4 h-4 text-fg-muted flex-shrink-0"}),e.jsx("span",{className:"type-label text-fg-primary truncate",children:d.name}),!d.confident&&e.jsx("span",{className:"text-[10px] text-fg-muted/60 italic",children:"ambiguous"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(de,{className:"w-4 h-4 text-fg-muted flex-shrink-0"}),e.jsxs("span",{className:"text-xs text-fg-muted",children:["Dest: ",e.jsx("span",{className:"font-mono",children:ae.destHash})]})]}),e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(we,{className:"w-4 h-4 text-fg-muted flex-shrink-0 mt-0.5"}),e.jsx("span",{className:"text-[11px] font-mono text-fg-muted break-all leading-relaxed",children:ae.senderPublicKey})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(xe,{className:"w-4 h-4 text-fg-muted flex-shrink-0"}),e.jsxs("span",{className:"text-xs text-fg-muted",children:[ae.ciphertextLength,"B encrypted payload"]})]})]})]}),_&&e.jsxs("div",{className:"radius-inner bg-subtle-fill overflow-hidden depth-stroke",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-2",children:[e.jsx("span",{className:"type-micro text-fg-muted",children:"Advertiser"}),e.jsx(B,{color:"lime",compact:!0,children:_.nodeType})]}),e.jsxs("div",{className:"p-4 space-y-2.5",children:[_.name&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ce,{className:"w-4 h-4 text-fg-muted flex-shrink-0"}),e.jsx("span",{className:"type-label text-fg-primary truncate",children:_.name})]}),_.latitude&&_.longitude&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ue,{className:"w-4 h-4 text-fg-muted flex-shrink-0"}),e.jsxs("span",{className:"type-data-xs text-fg-secondary",children:[_.latitude.toFixed(5),", ",_.longitude.toFixed(5)]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(we,{className:"w-4 h-4 text-fg-muted flex-shrink-0"}),e.jsxs("span",{className:"text-[11px] font-mono text-fg-muted truncate",children:[_.publicKey.slice(0,16),"...",_.publicKey.slice(-8)]})]}),_.timestamp>0&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(xe,{className:"w-4 h-4 text-fg-muted flex-shrink-0"}),e.jsx("span",{className:"text-xs text-fg-muted",children:Le(_.timestamp)})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(de,{className:"w-4 h-4 text-fg-muted flex-shrink-0"}),e.jsx("span",{className:"text-[11px] text-fg-muted",children:_.flagsDescription||`Flags: 0x${_.flags.toString(16).padStart(2,"0")}`})]})]})]}),z&&z.pathHashes.length>0&&e.jsxs("div",{className:"radius-inner bg-inset overflow-hidden depth-stroke-inset",children:[e.jsxs("div",{className:"px-4 py-2 flex items-center justify-between",children:[e.jsx("span",{className:"type-micro text-fg-muted",children:"Trace Route"}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(B,{color:z.isComplete?"green":"amber",compact:!0,children:z.isComplete?"Complete":"In Progress"}),e.jsxs(B,{color:"teal",compact:!0,children:[z.pathHashes.length,"h"]})]})]}),e.jsx(Se,{packet:m,neighbors:M,localHash:k==null?void 0:k.local_hash,neighborAffinity:D,ghostPrefixes:W,direction:"flowchart",compact:!0,overridePath:z.pathHashes,traceSnr:z.snrValues})]}),O&&!z&&e.jsxs("div",{className:"radius-inner bg-inset overflow-hidden depth-stroke-inset",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-2",children:[e.jsx("span",{className:"type-micro text-fg-muted",children:"Path"}),e.jsxs(B,{color:"zinc",compact:!0,children:[$.length,"h"]})]}),e.jsx(Se,{packet:m,neighbors:M,localHash:k==null?void 0:k.local_hash,neighborAffinity:D,ghostPrefixes:W,direction:"flowchart",compact:!0,traceSnr:ne})]})]})]})]})]})]})}const Ua=p.memo($a);function Bt({label:t,numericValue:a,unit:s,icon:n,subtext:r,showSign:i=!1}){return e.jsxs("div",{className:"radius-inner p-3 sm:radius-inset sm:p-4 bg-subtle-fill ring-1 ring-inset ring-edge-subtle",children:[e.jsx("div",{className:"mb-1.5 sm:mb-2",children:e.jsx("span",{className:"text-xs sm:type-micro text-fg-muted",children:t})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(tt,{value:a,format:{minimumFractionDigits:1,maximumFractionDigits:1,signDisplay:i?"always":"auto"},className:"type-data-hero tracking-tight text-fg-primary"}),e.jsxs("div",{className:"flex flex-col items-center justify-center",children:[e.jsx(n,{className:"w-[14px] h-[14px] text-fg-muted"}),s&&e.jsx("span",{className:"text-xs font-medium leading-tight text-fg-muted",children:s})]})]}),r&&e.jsx("p",{className:"mt-1.5 sm:mt-2 type-data-xs sm:text-[11px] text-fg-muted/80 truncate",children:r})]})}function Va({snr:t}){const a=t>=5?"bg-sys-teal":t>=0?"bg-sys-green":t>=-5?"bg-sys-amber":t>=-10?"bg-sys-orange":"bg-sys-red";return e.jsx("span",{className:R("w-1.5 h-1.5 rounded-full flex-shrink-0",a),title:`SNR: ${t.toFixed(1)} dB`})}function Lt({fromPrefix:t,toPrefix:a,fromName:s,toName:n,snr:r,maxSnr:i,isWeakest:l,isStrongest:c,index:o=0}){const x=Math.max(i+5,15),g=Math.max(0,Math.min(100,(r- -20)/(x- -20)*100)),f="bg-[#0074BE]",y=r>=5?"bg-sys-teal":r>=0?"bg-sys-green":r>=-5?"bg-sys-amber":r>=-10?"bg-sys-orange":"bg-sys-red",h=.3+o*.15;return e.jsxs("div",{className:"relative p-3 pl-5 radius-inner bg-subtle-fill ring-1 ring-inset ring-edge-subtle",children:[e.jsx("span",{className:R("absolute left-0 top-1/2 -translate-y-1/2 h-4 w-0.5 rounded-full",y)}),e.jsx("span",{className:"absolute -top-0.5 -right-0.5",children:e.jsx(Va,{snr:r})}),e.jsxs("div",{className:"sm:hidden",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[e.jsx("span",{className:"text-[13px] font-medium text-fg-secondary truncate",children:s||t}),e.jsx(pe,{className:"w-3 h-3 text-fg-muted flex-shrink-0"}),e.jsx("span",{className:"text-[13px] font-semibold text-fg-primary truncate",children:n||a})]}),e.jsxs("div",{className:"flex items-center gap-1.5 ml-2 flex-shrink-0",children:[l&&e.jsx(B,{color:"red",compact:!0,children:"Low"}),c&&!l&&e.jsxs(B,{color:"amber",compact:!0,children:[e.jsx(wt,{className:"w-2.5 h-2.5"}),"Best"]}),e.jsxs("span",{className:"inline-flex items-center px-1.5 py-0.5 rounded text-[12px] font-mono font-bold tabular-nums bg-subtle-fill-hover text-fg-primary ring-1 ring-inset ring-edge-subtle",children:[r>=0?"+":"−",Math.abs(r).toFixed(1)]})]})]}),e.jsx("div",{className:"h-1.5 bg-subtle-fill-strong rounded-full overflow-hidden",children:e.jsx(oe.div,{className:R("h-full rounded-full",f),initial:{width:0},animate:{width:`${g}%`},transition:{duration:1.5,delay:h,ease:[.25,.1,.25,1]}})})]}),e.jsxs("div",{className:"hidden sm:block",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[e.jsx("code",{className:"type-data-xs text-fg-muted",children:t}),s&&e.jsx("span",{className:"text-xs text-fg-secondary truncate max-w-[100px]",children:s})]}),e.jsx(pe,{className:"w-3 h-3 text-fg-muted/40 flex-shrink-0"}),e.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[e.jsx("code",{className:"font-mono text-xs font-semibold text-fg-primary",children:a}),n&&e.jsx("span",{className:"text-xs text-fg-secondary truncate max-w-[100px]",children:n})]})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[l&&e.jsx(B,{color:"red",compact:!0,children:"Bottleneck"}),c&&!l&&e.jsxs(B,{color:"amber",compact:!0,children:[e.jsx(wt,{className:"w-3 h-3"}),"Strongest"]}),e.jsxs("span",{className:"inline-flex items-center px-2 py-0.5 rounded text-sm font-mono font-semibold tabular-nums bg-subtle-fill-hover text-fg-primary ring-1 ring-inset ring-edge-subtle",children:[r>=0?"+":"−",Math.abs(r).toFixed(1)]})]})]}),e.jsx("div",{className:"h-1.5 bg-elevated rounded-full overflow-hidden",children:e.jsx(oe.div,{className:R("h-full rounded-full",f),initial:{width:0},animate:{width:`${g}%`},transition:{duration:1.5,delay:h,ease:[.25,.1,.25,1]}})})]})]})}function ye(t,a){if(t==="You")return"You";const s=t.toUpperCase();for(const[n,r]of Object.entries(a))if((n.startsWith("0x")?n.slice(2,4):n.slice(0,2)).toUpperCase()===s)return r.name||r.node_name||void 0}function Wa({report:t,onClose:a}){var u,x;const s=Dt(),n=(s==null?void 0:s.neighbors)??{},r=(u=s==null?void 0:s.config)!=null&&u.repeater?{latitude:s.config.repeater.latitude,longitude:s.config.repeater.longitude,name:s.config.node_name||"Local Node"}:void 0,i=(x=t.bestObservation)==null?void 0:x.decoded.snrValues,l=t.linkQuality?t.linkQuality.avgSnr>=5?"excellent":t.linkQuality.avgSnr>=0?"good":t.linkQuality.avgSnr>=-5?"fair":"poor":"unknown",o={excellent:"var(--signal-excellent)",good:"var(--signal-good)",fair:"var(--signal-fair)",poor:"var(--signal-poor)",unknown:"var(--fg-muted)"}[l];return e.jsxs(Ot,{open:!0,onClose:a,size:"5xl",motionPlus:!0,children:[e.jsxs("div",{className:"sm:hidden",children:[e.jsx("div",{className:"flex justify-center pt-2 pb-1",children:e.jsx("div",{className:"w-9 h-1 rounded-full bg-fg-primary/30","aria-hidden":"true"})}),e.jsxs("div",{className:"flex items-center justify-between px-4 pb-2",children:[e.jsx("h2",{className:"font-semibold text-[17px] text-fg-primary",children:"Trace Report"}),e.jsx("button",{onClick:a,className:"text-[17px] font-medium text-sys-blue active:text-sys-blue/80",children:"Done"})]})]}),e.jsx("div",{className:"sm:hidden h-[2px]",style:{backgroundColor:o,opacity:.6}}),e.jsx("div",{className:"hidden sm:block px-6 pt-5 pb-4",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 sm:gap-3",children:[e.jsx("h2",{className:"type-micro",children:"Trace Report"}),e.jsxs(B,{color:l==="excellent"||l==="good"?"green":l==="fair"?"amber":"red",children:[e.jsx(vt,{className:"w-3 h-3 mr-1"}),l==="excellent"?"Excellent":l==="good"?"Good":l==="fair"?"Fair":"Poor"]})]}),e.jsx("p",{className:"mt-1 text-xs sm:text-sm font-mono text-fg-muted tabular-nums",children:t.traceTag})]}),e.jsx("button",{onClick:a,className:"p-1.5 -m-1.5 text-fg-muted hover:text-fg-primary transition-base radius-inner hover:bg-elevated flex-shrink-0",children:e.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]})}),e.jsxs("div",{className:"hidden sm:flex flex-wrap items-center gap-1.5 sm:gap-2 px-4 sm:px-6 pb-3 sm:pb-4 border-b border-edge-subtle",children:[e.jsxs(B,{color:"teal",children:[e.jsx("span",{className:"font-mono tabular-nums",children:t.targetHopCount}),e.jsxs("span",{className:"ml-1",children:["hop",t.targetHopCount!==1?"s":""]})]}),e.jsxs(B,{color:"zinc",children:[e.jsx("span",{className:"font-mono tabular-nums",children:t.observationCount}),e.jsx("span",{className:"ml-1",children:"obs"})]}),t.linkQuality&&e.jsxs(B,{color:"indigo",children:[e.jsx("span",{className:"font-mono tabular-nums",children:t.linkQuality.avgSnr.toFixed(1)}),e.jsx("span",{className:"ml-1",children:"dB avg"})]}),e.jsx("span",{className:"type-data-xs text-fg-muted",children:Fs(t.duration)}),t.linkQuality&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-fg-muted/40",children:"•"}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-xs font-medium bg-sys-red/15 text-sys-red ring-1 ring-inset ring-sys-red/25",children:[e.jsx("span",{className:"opacity-70",children:"Min"}),e.jsx("span",{className:"font-mono tabular-nums",children:t.linkQuality.minSnr.toFixed(1)})]}),e.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-xs font-medium bg-sys-teal/15 text-sys-teal ring-1 ring-inset ring-sys-teal/25",children:[e.jsx("span",{className:"opacity-70",children:"Max"}),e.jsx("span",{className:"font-mono tabular-nums",children:t.linkQuality.maxSnr.toFixed(1)})]})]})]})]}),e.jsxs($t,{className:"p-0 overflow-hidden",children:[e.jsx("div",{className:"md:hidden h-[75vh] max-h-[calc(100vh-80px)] overflow-y-auto overflow-x-hidden",children:e.jsxs("div",{className:"px-4 py-3 space-y-3",children:[t.linkQuality&&e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"radius-inner bg-subtle-fill ring-1 ring-inset ring-edge-subtle p-2.5 text-center",children:[e.jsx(tt,{value:Math.abs(t.linkQuality.minSnr),format:{maximumFractionDigits:0,signDisplay:"never"},prefix:t.linkQuality.minSnr<0?"-":"",className:"text-[20px] font-bold font-mono tabular-nums flex items-center justify-center text-fg-primary"}),e.jsxs("div",{className:"flex items-center justify-center gap-1 mt-1",children:[e.jsx(et,{className:"w-2.5 h-2.5 text-fg-muted"}),e.jsx("span",{className:"text-xs text-fg-muted",children:"Min dB"})]})]}),e.jsxs("div",{className:"radius-inner bg-subtle-fill ring-1 ring-inset ring-edge-subtle p-2.5 text-center",children:[e.jsx(tt,{value:t.linkQuality.maxSnr,format:{maximumFractionDigits:0,signDisplay:"always"},className:"text-[20px] font-bold font-mono text-fg-primary tabular-nums flex items-center justify-center"}),e.jsxs("div",{className:"flex items-center justify-center gap-1 mt-1",children:[e.jsx(ft,{className:"w-2.5 h-2.5 text-fg-muted"}),e.jsx("span",{className:"text-xs text-fg-muted",children:"Max dB"})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs(B,{color:l==="excellent"||l==="good"?"green":l==="fair"?"amber":"red",compact:!0,children:[e.jsx(vt,{className:"w-2.5 h-2.5 mr-0.5"}),l==="excellent"?"Excellent":l==="good"?"Good":l==="fair"?"Fair":"Poor"]}),e.jsxs(B,{color:"teal",compact:!0,children:[t.targetHopCount," hops"]}),e.jsxs(B,{color:"zinc",compact:!0,children:[t.observationCount," obs"]}),e.jsx("span",{className:"type-data-xs text-fg-muted ml-auto",children:t.traceTag.slice(0,8)})]}),t.targetPath.length>0&&e.jsx("div",{className:"overflow-hidden radius-inset",children:e.jsx("div",{className:"aspect-[4/3] w-full",children:e.jsx(We,{path:t.targetPath,neighbors:n,localNode:r,localHash:s==null?void 0:s.local_hash,srcHash:t.srcHash,dstHash:t.dstHash,traceSnr:i})})}),e.jsxs("div",{className:"radius-inset bg-body overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-2 border-b border-edge-subtle",children:[e.jsx("span",{className:"text-[11px] font-medium text-fg-secondary",children:"Route Path"}),t.linkQuality&&e.jsxs("span",{className:"type-data-xs text-fg-muted",children:["SNR ",t.linkQuality.minSnr.toFixed(1)," → ",t.linkQuality.maxSnr.toFixed(1)," dB"]})]}),t.bestObservation?e.jsx(Se,{packet:t.bestObservation.packet,neighbors:n,localHash:s==null?void 0:s.local_hash,direction:"flowchart",compact:!0,overridePath:t.targetPath,traceSnr:t.bestObservation.decoded.snrValues}):e.jsx("div",{className:"p-6 text-center text-fg-muted text-xs",children:"No path data available"})]}),e.jsxs("div",{children:[e.jsxs("h3",{className:"type-micro text-fg-muted mb-2",children:["Link Quality · ",t.hopStats.length," hops"]}),e.jsx("div",{className:"space-y-1.5",children:t.hopStats.length>0?t.hopStats.map((g,f)=>{var T,m,N;const y=f{const g=t.targetPath[t.linkQuality.weakestLinkPosition],f=t.targetPath[t.linkQuality.weakestLinkPosition+1]||"You",y=ye(g,n),h=ye(f,n),v=t.targetPath[t.linkQuality.strongestLinkPosition],T=t.targetPath[t.linkQuality.strongestLinkPosition+1]||"You",m=ye(v,n),N=ye(T,n);return e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(Bt,{label:"Weakest Link",numericValue:t.linkQuality.minSnr,unit:"dB",icon:et,subtext:`${y||g} → ${h||f}`}),e.jsx(Bt,{label:"Best Link",numericValue:t.linkQuality.maxSnr,showSign:!0,unit:"dB",icon:ft,subtext:`${m||v} → ${N||T}`})]})})(),e.jsxs("div",{children:[e.jsx("h3",{className:"type-micro text-fg-muted mb-3",children:"Link Details"}),e.jsx("div",{className:"space-y-2",children:t.hopStats.length>0?t.hopStats.map((g,f)=>{var T,m,N;const y=f0&&e.jsx("div",{className:"overflow-hidden",children:e.jsx("div",{className:"aspect-square w-full",children:e.jsx(We,{path:t.targetPath,neighbors:n,localNode:r,localHash:s==null?void 0:s.local_hash,srcHash:t.srcHash,dstHash:t.dstHash,traceSnr:i})})}),e.jsxs("div",{className:"radius-inset bg-black overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-3",children:[e.jsx("span",{className:"type-micro text-fg-muted",children:"Trace Route"}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(B,{color:t.isComplete?"green":"amber",compact:!0,children:t.isComplete?"Complete":`${t.maxHopsObserved}/${t.targetHopCount}`}),e.jsxs(B,{color:"teal",compact:!0,children:[t.targetHopCount," hop",t.targetHopCount!==1?"s":""]})]})]}),t.linkQuality&&t.bestObservation&&e.jsxs("div",{className:"flex items-center gap-4 px-4 pb-2 type-data-xs text-fg-muted",children:[e.jsxs("span",{children:[e.jsx("span",{className:"opacity-60",children:"Tag"})," ",e.jsx("code",{className:"text-sys-teal tabular-nums",children:t.traceTag.slice(0,8)})]}),e.jsxs("span",{children:[e.jsx("span",{className:"opacity-60",children:"SNR"})," ",e.jsxs("code",{className:"text-sys-indigo tabular-nums",children:[t.linkQuality.minSnr.toFixed(1),"–",t.linkQuality.maxSnr.toFixed(1)]}),e.jsx("span",{className:"opacity-60",children:" dB"})]})]}),t.bestObservation?e.jsx(Se,{packet:t.bestObservation.packet,neighbors:n,localHash:s==null?void 0:s.local_hash,direction:"flowchart",compact:!0,overridePath:t.targetPath,traceSnr:t.bestObservation.decoded.snrValues}):e.jsx("div",{className:"p-8 text-center text-fg-muted text-xs",children:"No path data available"})]})]})]})]})]})}const Ga=p.memo(Wa),as=[{target:"PacketList",fn:"type",minStage:1},{target:"PacketList",fn:"route",minStage:1},{target:"PacketList",fn:"rssi",minStage:1},{target:"PacketList",fn:"snr",minStage:1},{target:"PacketList",fn:"path",minStage:1,when:Us},{target:"PacketList",fn:"src_hash",minStage:1,when:Vs},{target:"PacketList",fn:"text",minStage:1,when:Ws},{target:"PacketList",fn:"ack",minStage:1,when:Gs},{target:"PacketList",fn:"decrypt",minStage:2,when:Qs},{target:"PacketList",fn:"duplicates",minStage:1}];$s(as);const Qa=48,qa=72,Ka=100,Ya=5,Xa=600,rs="(min-width: 640px)";let me=null;function Za(t){return typeof window>"u"?()=>{}:(me||(me=window.matchMedia(rs)),me.addEventListener("change",t),()=>me==null?void 0:me.removeEventListener("change",t))}function Ja(){return typeof window>"u"?!0:(me||(me=window.matchMedia(rs)),me.matches)}function er(){return p.useSyncExternalStore(Za,Ja,()=>!0)}function tr(t,a,s){const[n,r]=p.useState(1),i=s?Math.ceil(t/a):1;p.useEffect(()=>{n>i&&i>0&&queueMicrotask(()=>r(1))},[i,n]);const l=p.useCallback(o=>r(Math.max(1,Math.min(o,i))),[i]),c=p.useMemo(()=>Un(n,i),[n,i]);return{currentPage:n,totalPages:i,goToPage:l,pageRange:c}}function sr(t,a){const[s,n]=p.useState(null),r=p.useRef(0);return p.useEffect(()=>{var x,g;if(!a||!t.length)return;const i=((x=t[0])==null?void 0:x.timestamp)??0,l=i>r.current&&r.current>0;if(r.current=i,!l)return;const c=(g=t[0])==null?void 0:g.packet_hash;if(!c)return;const o=requestAnimationFrame(()=>n(c)),u=setTimeout(()=>n(null),600);return()=>{cancelAnimationFrame(o),clearTimeout(u)}},[t,a]),s}function nr(t){if(!t||t.length<6)return null;const a=t,s=parseInt(a.slice(0,2),16);if(isNaN(s))return null;const n=s&3;let r=2;if((n===0||n===3)&&(r=10),r+2>a.length)return null;const i=parseInt(a.slice(r,r+2),16);if(isNaN(i)||(r+=2+i*2,r>=a.length))return null;const l=a.slice(r);return l.length>=38?l.slice(0,38):l}function ar(t){if(t.length<=1)return t;const a=new Map,s=new Map,n=new Map;for(let l=0;l0?{packet:t[l].packet,dupeCount:t[l].dupeCount+c}:t[l])}return i}function rr(t){const a=new Map;for(const s of t)if((s.payload_type??s.type)===lt.TRACE&&s.packet_hash){const r=s._traceTag??(s.payload?Ut(s.payload):null);r&&a.set(s.packet_hash,r)}return a}function ir(t){const a=new Map;if(t.length===0)return a;for(let s=0;sw.setModalMapOpen);p.useEffect(()=>(W(!!N),()=>W(!1)),[N,W]),p.useLayoutEffect(()=>{A({traceTag:null,dupeGroup:null})},[t]);const K=a??t,F=p.useMemo(()=>i&&i>0&&!y?t.slice(0,i):t,[t,i,y]),Y=p.useMemo(()=>{if(!y)return null;const w=Vn(F),S=ar(w);return i&&i>0?S.slice(0,i):S},[F,y,i]),H=Y?Y.length:F.length,{currentPage:E,totalPages:O,goToPage:$,pageRange:J}=tr(H,l,c),M=p.useMemo(()=>{if(y||!c)return F;const w=(E-1)*l;return F.slice(w,w+l)},[F,c,E,l,y]),D=p.useMemo(()=>{if(!Y)return null;if(!c)return Y;const w=(E-1)*l;return Y.slice(w,w+l)},[Y,c,E,l]),te=p.useMemo(()=>rr(M),[M]),se=p.useMemo(()=>ir(M),[M]),d=sr(t,u),Z=er(),q=p.useMemo(()=>y&&D?D:M,[y,D,M]),le=m&&q.length>Ka,P=Z?Qa:qa,z=yn({count:le?q.length:0,getScrollElement:()=>U.current,estimateSize:()=>P,overscan:Ya}),ne=p.useCallback((w,S)=>{var ve,Fe;const L=w.packet_hash;if(!L)return[w];let I=S;for(;I>0&&((ve=M[I-1])==null?void 0:ve.packet_hash)===L;)I--;let Q=S;for(;Q{var I,Q;const S=(I=M[w])==null?void 0:I.packet_hash;if(!S)return w;let L=w;for(;L>0&&((Q=M[L-1])==null?void 0:Q.packet_hash)===S;)L--;return L},[M]),ce=p.useCallback(w=>{var I,Q;const S=(I=M[w])==null?void 0:I.packet_hash;if(!S)return w;let L=w;for(;L{if(o){o(w);return}if(S!==void 0){const L=ne(w,S),I=L.indexOf(w);j({packets:L,initialIndex:I>=0?I:0,rowIndex:S})}else j({packets:[w],initialIndex:0,rowIndex:0})},[o,ne]),ae=p.useCallback(()=>{if(!N)return;const S=_(N.rowIndex)-1;if(S<0)return;const L=M[S];if(!L)return;const I=ne(L,S);j({packets:I,initialIndex:0,rowIndex:S})},[N,M,_,ne]),Le=p.useCallback(()=>{if(!N)return;const S=ce(N.rowIndex)+1;if(S>=M.length)return;const L=M[S];if(!L)return;const I=ne(L,S);j({packets:I,initialIndex:0,rowIndex:S})},[N,M,ce,ne]),dt=p.useMemo(()=>N?_(N.rowIndex)>0:!1,[N,_]),xt=p.useMemo(()=>N?ce(N.rowIndex)A(S=>({...S,traceTag:w})),[]),Qe=p.useCallback(w=>A(S=>({...S,dupeGroup:w})),[]),Re=p.useCallback(()=>{A({traceTag:null,dupeGroup:null})},[]),Ne=p.useCallback(w=>{const S=K.filter(Q=>(Q.payload_type??Q.type)===lt.TRACE&&Q.payload&&Ut(Q.payload)===w);if(S.length===0)return;const I=Hs(S).get(w);I!=null&&I.length&&k(Ds(w,I))},[K]),qe=p.useCallback(w=>{const S=K.find(L=>L.packet_hash===w);S&&(k(null),fe(S))},[K,fe]),Ee=p.useCallback((w,S,L)=>{const I=Z?Zn:Jn;if(L){const{packet:ge,dupeCount:ls}=w,mt=ge.packet_hash?te.get(ge.packet_hash):void 0,cs=b.traceTag!==null&&mt===b.traceTag;return e.jsx(I,{packet:ge,onClick:os=>fe(os,S),localHash:s,neighbors:n,resolveSource:T,isFlashing:u&&d===ge.packet_hash,traceTag:mt,isTraceHighlighted:cs,onTraceHover:be,onViewTraceReport:Ne,dupeCount:ls,getDecodedContent:h,onChannelClick:v},`${ge.packet_hash}_${ge.timestamp}_${S}`)}const Q=w,ve=Q.packet_hash?te.get(Q.packet_hash):void 0,Fe=b.traceTag!==null&&ve===b.traceTag,ht=se.get(S),is=ht!==void 0&&b.dupeGroup!==null&&Q.packet_hash===b.dupeGroup;return e.jsx(I,{packet:Q,onClick:ge=>fe(ge,S),localHash:s,neighbors:n,resolveSource:T,isFlashing:u&&d===Q.packet_hash,traceTag:ve,isTraceHighlighted:Fe,onTraceHover:be,onViewTraceReport:Ne,dupeGroupPosition:ht,isDupeGroupHovered:is,onDupeGroupHover:Qe,getDecodedContent:h,onChannelClick:v},`${Q.packet_hash}_${Q.timestamp}_${S}`)},[Z,te,b.traceTag,b.dupeGroup,fe,s,n,T,u,d,be,Ne,se,Qe,h,v]),ze=()=>{if(r&&t.length===0)return e.jsx(Et,{});if(M.length===0)return e.jsx(Rt,{message:x});const w=y&&D!==null;return(w?D:M).map((L,I)=>Ee(L,I,w))},G=()=>{if(r&&t.length===0)return e.jsx(Et,{});if(q.length===0)return e.jsx(Rt,{message:x});const w=y&&D!==null,S=z.getVirtualItems();return e.jsx("div",{style:{height:`${z.getTotalSize()}px`,width:"100%",position:"relative"},children:S.map(L=>{const I=q[L.index];return e.jsx("div",{"data-index":L.index,ref:z.measureElement,style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${L.start}px)`},children:Ee(I,L.index,w)},L.key)})})};return e.jsxs("div",{className:R("flex flex-col",g),onMouseLeave:Re,children:[le?e.jsx("div",{ref:U,className:"divide-y divide-edge-subtle overflow-auto",style:{maxHeight:Xa},children:G()}):e.jsx("div",{className:"divide-y divide-edge-subtle py-1",children:ze()}),c&&O>1&&e.jsx("nav",{className:"border-t border-edge-subtle px-4 py-3",children:e.jsxs(In,{className:"justify-center",children:[e.jsx(An,{onClick:()=>$(E-1),disabled:E===1}),e.jsx(Dn,{children:J.map((w,S)=>w==="gap"?e.jsx($n,{},`gap-${S}`):e.jsx(On,{page:w,current:w===E,onClick:$},w))}),e.jsx(Hn,{onClick:()=>$(E+1),disabled:E===O})]})}),e.jsx(lr,{showPagination:c,currentPage:E,perPage:l,displayCount:D?D.length:M.length,totalCount:c?H:t.length,action:f}),!o&&N&&e.jsx(Ua,{packets:N.packets,initialIndex:N.initialIndex,onClose:()=>j(null),onNavigatePrev:ae,onNavigateNext:Le,hasPrev:dt,hasNext:xt,resolveSource:T,getDecodedContent:h}),C&&e.jsx(Ga,{report:C,onClose:()=>k(null),onViewPacket:qe})]})}export{ts as C,Br as P,vt as S,wt as T,Tr as a,yn as b,Qn as g,Pr as u}; diff --git a/frontend/dist/assets/PacketObservatory-B0qfKgdh.js b/frontend/dist/assets/PacketObservatory-B0qfKgdh.js new file mode 100644 index 00000000..320e4767 --- /dev/null +++ b/frontend/dist/assets/PacketObservatory-B0qfKgdh.js @@ -0,0 +1,5 @@ +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/usePipelineStore-B9ir1Xwp.js","assets/index-DhkG1Nx9.js","assets/node-types-CgBRFpS8.js","assets/index-DySMpv2s.css"])))=>i.map(i=>d[i]); +import{bL as O,r as T,e2 as Fe,e3 as Ee,e4 as Oe,e5 as ze,bn as Be,e6 as Ie,e7 as Ge,e8 as Ke,e9 as Ve,bm as Ne,_ as ue,ea as Ue,eb as we,br as pe,j as e,ec as G,ed as K,ee as V,dB as xe,ef as qe,v as M,bx as We,bI as Ce,bR as Ye,eg as Ze,eh as Xe,ei as Qe,ej as Je,ek as et,el as J,em as tt,en as st,eo as nt,ep as he,a7 as me,a2 as Se,e as rt,eq as at,D as lt,G as ot,er as ct,bc as it,cY as dt}from"./index-DhkG1Nx9.js";import{usePipelineStore as Y}from"./usePipelineStore-B9ir1Xwp.js";import{e as Te,p as ut,a as pt,A as I,S as U,c as se,f as E,K as i,H as A,B as xt,R as F,T as d,P as re,h as ht,i as S,C as _e,s as ee,j as mt}from"./primitives-nqGDyTiB.js";import{m as ke,i as gt}from"./node-types-CgBRFpS8.js";import"./payload-decoders-DC2sHkKr.js";function ft(t){const s=t.type??t.payload_type,r=t.duplicates??[],c=t.is_duplicate,a=r.length;let n=null,l=null;if(a>0){const x=[t.rssi,...r.map(g=>g.rssi).filter(g=>g!=null)],m=[t.snr,...r.map(g=>g.snr).filter(g=>g!=null)];x.length>1&&(n=[Math.min(...x),Math.max(...x)]),m.length>1&&(l=[Math.min(...m),Math.max(...m)])}const o=s===O.TRACE;return{isDuplicate:c,dupeCount:a,rssiRange:n,snrRange:l,hashIncludesPathLen:o}}function bt(t,s,r){const c={traceTag:null,siblingCount:0,isLocallyOriginated:!1,method:"none",confidence:"none",inferredSrc:null,inferredName:null,evidence:[],thisPathLen:0,minPathLen:0,firstHopPrefix:null};let a=t._traceTag;if(!a&&t.payload&&(a=Te(t.payload)),!a)return{...c,evidence:["no traceTag — cannot correlate"]};const n=s.get(a)??[],l=N=>N.path_length!=null?N.path_length:Array.isArray(N.original_path)?N.original_path.length:0,o=l(t),x=n.length>0?Math.min(...n.map(l)):o,m=t.payload?t.payload.slice(18):"",g=m.length>=2?m.slice(0,2).toUpperCase():null,u=[];if(u.push(`traceTag: ${a}`),u.push(`siblings: ${n.length} observation${n.length!==1?"s":""}`),t.packet_origin==="tx_local")return u.push("packet_origin = tx_local → we initiated this trace"),{traceTag:a,siblingCount:n.length,isLocallyOriginated:!0,method:"tx_local",confidence:"certain",inferredSrc:"LOCAL",inferredName:null,evidence:u,thisPathLen:o,minPathLen:x,firstHopPrefix:g};const v=n.find(N=>N.packet_origin==="tx_local");if(v)return u.push(`sibling (hash ${v.packet_hash}) has packet_origin = tx_local`),{traceTag:a,siblingCount:n.length,isLocallyOriginated:!0,method:"tx_local",confidence:"certain",inferredSrc:"LOCAL",inferredName:null,evidence:u,thisPathLen:o,minPathLen:x,firstHopPrefix:g};if(u.push(`this observation: path_len=${o}, min across siblings: ${x}`),g){if(u.push(`first hop in target path: ${g}`),o===0)return u.push("path_len = 0 → heard directly from initiator (no SNR appended yet)"),u.push("initiator is a direct RF neighbor"),{traceTag:a,siblingCount:n.length,isLocallyOriginated:!1,method:"min_path_len",confidence:"speculative",inferredSrc:null,inferredName:null,evidence:[...u,"initiator is within direct RF range (zero forwarding hops)"],thisPathLen:o,minPathLen:x,firstHopPrefix:g};const f=Object.entries(r).filter(([k])=>k.replace(/^0x/i,"").slice(0,2).toUpperCase()===g);if(f.length===1){const[k,$]=f[0],h=$.name||$.node_name||null;return u.push(`first hop ${g} → unique neighbor: ${h??k}`),u.push("initiator is whoever sent TO this first hop"),{traceTag:a,siblingCount:n.length,isLocallyOriginated:!1,method:"first_hop_neighbor",confidence:"likely",inferredSrc:g,inferredName:h,evidence:u,thisPathLen:o,minPathLen:x,firstHopPrefix:g}}else f.length>1?u.push(`first hop ${g} matches ${f.length} neighbors (ambiguous)`):u.push(`first hop ${g} is not a known neighbor`)}return u.push("insufficient data to identify initiator"),{traceTag:a,siblingCount:n.length,isLocallyOriginated:!1,method:"none",confidence:"none",inferredSrc:null,inferredName:null,evidence:u,thisPathLen:o,minPathLen:x,firstHopPrefix:g}}let ne=null,ce=null;typeof window<"u"&&setTimeout(()=>{ue(()=>import("./usePipelineStore-B9ir1Xwp.js"),__vite__mapDeps([0,1,2,3])).then(t=>{ne=t}),ue(()=>import("./index-DhkG1Nx9.js").then(t=>t.g1),__vite__mapDeps([1,3])).then(t=>{ce=t})},0);const He={advertSender:null,advertNodeType:null,advertFlags:null,advertHasLocation:null,advertHasName:null,advertName:null,advertLatitude:null,advertLongitude:null,channelHash:null,byteLength:void 0,hopCount:0,isZeroHop:!0,preComputed:!1};function yt(t,s){const r=t.type??t.payload_type,c=Ne(r),a=Be(t.route),n=r===O.ADVERT,l=r===O.TRACE,o=r===O.PATH,x=r===O.GRP_TXT||r===O.GRP_DATA,m=Ie(t.snr,t.rssi),g=(m==null?void 0:m.finalGrade)??"critical",u=Ge(t.route),v=Ke(t.route),N=Ve(t.route),f=t.route==null?"unknown":u?"flood":v?"direct":"unknown",k=N?`transport-${f}`:f,$=!!s.advertSender;let h="none";$?h="pubkey":x?h="encrypted":t.src_hash&&(h="prefix");const y=gt(r),p=s.advertNodeType!=null?ke(s.advertNodeType):"unknown",_=y!=="unknown"?y:p,H=t.packet_origin??"rx",C=Math.floor(Date.now()/1e3)-t.timestamp,D=C<10?"live":C<300?"recent":C<3600?"warm":C<86400?"stale":"historic",L=t.path_length??(Array.isArray(t.original_path)?t.original_path.length:void 0),P=Array.isArray(t.original_path)&&t.original_path.length>0,R=L??0,b=s.byteLength??(t.raw_packet?Math.floor(t.raw_packet.length/2):0),w=ft(t);return{pType:r,payloadTypeName:c,routeTypeName:a,isAdvert:n,isTrace:l,isPath:o,isGrp:x,signalClass:g,routeClass:k,isFlood:u,isDirect:v,hasTransport:N,senderTier:h,hasPubkey:$,inferredType:y,advertType:p,effectiveType:_,origin:H,age:D,pathLen:L,pathAvail:P,pathHopCount:R,byteLen:b,dupeAnalysis:w}}function jt(t){var f,k,$,h,y,p;const s=pt(t);if(!s||s.pathHashes.length===0)return null;const{pathHashes:r,snrValues:c}=s;if(r.length<2||!ne||!ce)return null;const a=ne.usePipelineStore.getState().srcHashResolverMap,n=ne.usePipelineStore.getState().neighborContext,l=(n==null?void 0:n.hashToName)??new Map,o=ce.useStore.getState().stats,x=(o==null?void 0:o.neighbors)??{},m=o==null?void 0:o.local_hash,g=(k=(f=o==null?void 0:o.config)==null?void 0:f.repeater)==null?void 0:k.latitude,u=(h=($=o==null?void 0:o.config)==null?void 0:$.repeater)==null?void 0:h.longitude,v=Object.keys(x).length>0?Ue([],x,m,g,u):null,N=[];for(let _=0;_0?[r[_-1].toUpperCase()]:[]],P=ge(H,_,L,a,v),R=[H,..._+20?N:null}function ge(t,s,r,c,a){if(s===0){const l=c==null?void 0:c.get(t);if(l)return{hash:l,confidence:.8};if(a){const o=pe(a,t,{position:s,adjacentPrefixes:r});if(o.hash)return{hash:o.hash,confidence:o.confidence}}}else{if(a){const o=pe(a,t,{position:s,adjacentPrefixes:r});if(o.hash)return{hash:o.hash,confidence:o.confidence}}const l=c==null?void 0:c.get(t);if(l)return{hash:l,confidence:.6}}return{hash:null,confidence:0}}function vt(t){var l;const s=t.raw_packet;if(!s||s.length<2)return null;const r=s.replace(/\s/g,""),c=Math.floor(r.length/2),a=((l=r.match(/.{1,2}/g))==null?void 0:l.join(" "))??"";let n="";for(let o=0;o=32&&x<=126?String.fromCharCode(x):"·"}return{hexBytes:a,utf8:n,byteCount:c}}function Nt(t){const s=new Map;let r=0,c="";for(const a of t){if((a.type??a.payload_type)!==O.TRACE)continue;r++,c=a.packet_hash;const l=a._traceTag??(a.payload?Te(a.payload):null);if(!l)continue;let o=s.get(l);o||(o=[],s.set(l,o)),o.push(a)}return{index:s,fingerprint:`${r}:${c}`}}function wt(t,s,r){const c=T.useRef({parse:0,decode:0,enrich:0,traceIndex:0,total:0}),a=T.useMemo(()=>t?vt(t):null,[t]),n=T.useMemo(()=>{if(!s||s.length<4)return c.current.parse=0,c.current.decode=0,null;const h=performance.now(),y=ut(s),p=performance.now()-h;return y?(c.current.parse=p,c.current.decode=0,{protocolPacket:y.packet,display:{headerFields:y.headerFields,transportCodesHex:y.transportCodesHex,pathLengthHex:y.pathLengthHex,pathDataHex:y.pathDataHex,payloadHex:y.payloadHex,payloadByteOffset:y.payloadStartByte,pathByteOffset:y.pathByteOffset,pathLenByteOffset:y.pathLenByteOffset},decoded:y.decoded,error:null}):(c.current.parse=p,c.current.decode=0,{protocolPacket:null,display:null,decoded:null,error:"Packet.fromHex() returned failure"})},[s]),l=T.useMemo(()=>{if(!t)return c.current.enrich=0,He;const h=performance.now();if(t._advertSender!==void 0)return c.current.enrich=performance.now()-h,{advertSender:t._advertSender??null,advertNodeType:t._advertNodeType??null,advertFlags:t._advertFlags??null,advertHasLocation:t._advertHasLocation??null,advertHasName:t._advertHasName??null,advertName:t._advertName??null,advertLatitude:t._advertLatitude??null,advertLongitude:t._advertLongitude??null,channelHash:t._channelHash??null,byteLength:t._byteLength,hopCount:t._hopCount??0,isZeroHop:t._isZeroHop??!0,preComputed:!0};const y=t.type??t.payload_type,p=Fe(s,y),_=Ee(s,y),H=Oe(s,t),C=ze(t);return c.current.enrich=performance.now()-h,{...p,channelHash:_,byteLength:H,...C,preComputed:!1}},[t,s]),o=T.useRef({fingerprint:"",index:new Map}),x=T.useMemo(()=>{const h=performance.now(),{index:y,fingerprint:p}=Nt(r);return c.current.traceIndex=performance.now()-h,p===o.current.fingerprint?o.current.index:(o.current={fingerprint:p,index:y},y)},[r]),m=T.useMemo(()=>{const h=c.current;return{parse:h.parse,decode:h.decode,enrich:h.enrich,traceIndex:h.traceIndex,total:h.parse+h.decode+h.enrich+h.traceIndex}},[n,l,x]);if(!t)return null;const g=s?n?n.error:"rawHex too short":"No raw_packet (warm-tier)",u=(n==null?void 0:n.protocolPacket)??null,v=u?u.payloadVersion:null,N=v===0,f=v===1,k=yt(t,l);let $=null;return k.isTrace&&($=jt(t)),{wire:a,display:(n==null?void 0:n.display)??null,parseError:g,protocolPacket:u,decoded:(n==null?void 0:n.decoded)??null,payloadVersion:v,isV1:N,isV2:f,enrichment:l,traceTagIndex:x,analysis:k,traceHopDetail:$,timing:m}}function ae({options:t,nextFn:s}){var n;const r=t.find(l=>l.active),c=(r==null?void 0:r.color)??"green",a=((n=I[c])==null?void 0:n.stem)??"bg-edge-subtle";return e.jsxs("div",{className:"flex flex-col items-start py-1 gap-0 px-2",children:[e.jsx("div",{className:`w-px h-2 ml-4 ${a}`}),e.jsxs("div",{className:"border border-dashed border-edge-subtle rounded-md overflow-hidden w-full",children:[t.map((l,o)=>{const x=I[l.color??"green"]??I.green;return e.jsxs("div",{className:`flex items-center gap-1.5 px-2 py-px font-mono text-[10px] leading-relaxed transition-opacity ${l.active?x.row:"opacity-25"}`,children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${l.active?x.dot:"border border-zinc-500/40"}`}),e.jsx("span",{className:`w-16 shrink-0 font-medium ${l.active?"text-fg-primary":"text-fg-muted"}`,children:l.label}),l.detail&&e.jsx("span",{className:l.active?"text-fg-primary/70":"text-fg-muted",children:l.detail})]},o)}),s&&e.jsx("div",{className:"flex items-center px-2 py-0.5 border-t border-edge-subtle",children:e.jsxs("span",{className:"text-[10px] text-fg-muted font-mono",children:["→ ",s]})})]}),e.jsx("div",{className:`w-px h-2 ml-4 ${a}`})]})}function Ct({tokens:t,nextFn:s}){var n;const r=t.find(l=>l.active),c=(r==null?void 0:r.color)??"green",a=((n=I[c])==null?void 0:n.stem)??"bg-edge-subtle";return e.jsxs("div",{className:"flex flex-col items-start py-1 gap-0 px-2",children:[e.jsx("div",{className:`w-px h-2 ml-4 ${a}`}),e.jsxs("div",{className:"border border-dashed border-edge-subtle rounded-md overflow-hidden w-full",children:[t.map((l,o)=>{const x=I[l.color??"green"]??I.green;return e.jsxs("div",{className:`flex items-center gap-1 px-2 py-px font-mono text-[10px] leading-relaxed transition-opacity ${l.active?x.row:"opacity-25"}`,children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${l.active?x.dot:"border border-zinc-500/40"}`}),e.jsx("span",{className:"text-fg-muted shrink-0",children:l.fn}),e.jsxs("span",{className:l.active?"text-fg-primary":"text-fg-muted",children:["(",l.value??"",")"]})]},o)}),s&&e.jsx("div",{className:"flex items-center px-2 py-0.5 border-t border-edge-subtle",children:e.jsxs("span",{className:"text-[10px] text-fg-muted font-mono",children:["→ ",s]})})]}),e.jsx("div",{className:`w-px h-2 ml-4 ${a}`})]})}const St={0:"border-l-sys-green",1:"border-l-sys-blue",2:"border-l-sys-teal",3:"border-l-sys-purple"};function le({stage:t,name:s,fn:r,verdict:c,timeMs:a,skipped:n,skipReason:l,children:o}){const x=St[t]??"";return e.jsx(e.Fragment,{children:e.jsx(G,{defaultOpen:!n,children:e.jsxs("div",{className:`surface-base rounded-lg border border-edge-subtle overflow-hidden border-l-2 ${x}`,children:[e.jsxs(K,{className:"px-3 py-2 w-full",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("span",{className:"font-mono text-xs font-bold text-sys-blue shrink-0",children:t}),e.jsx("span",{className:"font-mono text-xs font-medium text-fg-primary truncate",children:s}),r&&!c&&e.jsx("span",{className:"font-mono text-[11px] text-fg-muted truncate hidden sm:inline",children:r}),c&&e.jsx("span",{className:"font-mono text-[11px] text-fg-muted/70 truncate hidden sm:inline",children:c})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[n&&e.jsx("span",{className:"font-mono text-[10px] px-1.5 py-0.5 rounded bg-zinc-500/20 text-fg-muted",children:"N/A"}),a!=null&&!n&&e.jsx("span",{className:"font-mono text-[10px] px-1.5 py-0.5 rounded bg-sys-green/15 text-sys-green",children:a<1?`${(a*1e3).toFixed(0)}µs`:`${a.toFixed(2)}ms`})]})]}),e.jsx(V,{children:e.jsx("div",{className:"px-3 pb-3 font-mono text-xs",children:n?e.jsx("p",{className:"text-fg-muted italic",children:l??"Not applicable for this packet type"}):o})})]})})})}function Tt(t,s){return s?"manual":t._stripped?"bulk-tier":qe.isConnected()?"ws-push":"rest-poll"}const _t={connected:"green",degraded:"amber",offline:"red"};function kt({packet:t,isSynthetic:s}){const r=xe(g=>g.wsState),c=xe(g=>g.health),a=Tt(t,s),l=!!t._stripped?"WARM":"HOT",o=[{label:"ws-push",detail:"wsConnected && onPacket()",active:a==="ws-push",color:"green"},{label:"rest-poll",detail:"!wsConnected, 3s interval",active:a==="rest-poll",color:"amber"},{label:"catchup",detail:"wsReconnected, delta > 50",active:a==="catchup",color:"amber"},{label:"bulk-tier",detail:"user extends time range → gzip",active:a==="bulk-tier",color:"blue"},{label:"manual",detail:"hex input — no transport",active:a==="manual",color:"zinc"}],x=[{fn:"transport",value:a,group:"transport",color:a==="ws-push"?"green":a==="bulk-tier"?"blue":"amber"},{fn:"tier",value:l,group:"transport",color:"blue"},{fn:"wsState",value:r,group:"transport",color:r==="connected"?"green":"amber"},{fn:"health",value:c,group:"transport",color:_t[c]}],m=s?"manual hex input":`${a} (${c})`;return e.jsx(le,{stage:0,name:"TRANSPORT",fn:"websocketService / useStore.startPolling",verdict:m,children:s?e.jsx("p",{className:"text-fg-muted italic",children:"Manual hex input — no transport context"}):e.jsx(U,{prefix:"transport",children:e.jsxs("div",{className:"space-y-0",children:[e.jsx(ae,{options:o,nextFn:"ingest()"}),e.jsx(se,{tokens:x})]})})})}function q({start:t,end:s}){const r=s!=null&&s!==t?`[${t}..${s}]`:`[${t}]`;return e.jsx("span",{className:"text-fg-muted text-[9px] font-mono mr-1 select-none",children:r})}const Ht={advert:"decodeAdvert()",ack:"decodeAck()",path:"decodePath()",trace:"decodeTraceWithSnr()",txt_msg:"decodeTextMessage()",grp_txt:"decodeGroupText()",grp_data:"decodeGroupData()",multipart:"decodeMultipart()",control:"decodeControl()",req:"decodeRequest()",response:"decodeResponse()",anon_req:"decodeAnonReq()",generic:"decodeGeneric()"};function $t({rawHex:t,display:s,protocolPacket:r,parseError:c,parseTimeMs:a,payloadVersion:n,isV1:l,isV2:o}){return e.jsx("dl",{className:"space-y-0.5",children:s&&r&&t?e.jsxs(e.Fragment,{children:[e.jsx(E,{title:"A. Parse — Packet.fromHex()"}),a>0&&e.jsx("div",{className:"flex justify-end",children:e.jsx("span",{className:"font-mono text-[10px] px-1.5 py-0.5 rounded bg-sys-green/15 text-sys-green",children:a<1?`${(a*1e3).toFixed(0)}µs`:`${a.toFixed(2)}ms`})}),e.jsxs(i,{label:"header byte",children:[e.jsx(q,{start:0}),e.jsx(A,{value:t.slice(0,2)})," ",e.jsx(xt,{value:parseInt(t.slice(0,2),16)})]}),s.headerFields.map(x=>e.jsx(i,{label:` ${x.field}`,children:e.jsx(F,{raw:e.jsxs("span",{className:"text-[10px]",children:["bits[",x.bits,"] = ",x.binary]}),children:e.jsx("span",{className:"inline-block border border-edge-subtle rounded px-2 py-0.5 font-mono text-[11px] text-sys-amber",children:x.value})})},x.field)),e.jsx(i,{label:" version",children:n!=null?e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx(d,{fn:"payloadVer",value:`${n}`,color:"amber"}),e.jsx(M,{color:l?"green":o?"blue":"zinc",children:l?"v1":o?"v2":`v${n}`}),l&&e.jsx("span",{className:"text-fg-muted text-[10px]",children:"1-byte hashes, 2-byte MAC"}),o&&e.jsx("span",{className:"text-sys-blue text-[10px]",children:"2-byte hashes, 4-byte MAC (speculative)"})]}):e.jsx("span",{className:"text-fg-muted",children:"unknown"})}),e.jsx(E,{title:"Wire Framing"}),e.jsx(i,{label:"transportCodes",children:s.transportCodesHex?e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(q,{start:1,end:4}),e.jsx(d,{fn:"transport",value:s.transportCodesHex,color:"amber"})]}):e.jsx("span",{className:"text-fg-muted",children:"N/A (non-transport route)"})}),e.jsx(i,{label:"pathLen",children:e.jsx(F,{raw:e.jsxs(e.Fragment,{children:[e.jsx(q,{start:s.pathLenByteOffset}),e.jsx(A,{value:s.pathLengthHex})]}),children:e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(q,{start:s.pathLenByteOffset}),e.jsx(d,{fn:"pathLen",value:`${r.pathLen} hop${r.pathLen!==1?"s":""}`,color:"amber"})]})})}),e.jsx(i,{label:"path",children:e.jsxs("span",{className:"inline-flex items-center gap-1",children:[r.pathLen>0&&e.jsx(q,{start:s.pathByteOffset,end:s.pathByteOffset+r.pathLen-1}),e.jsx(re,{hops:r.pathHexArray,hexPrefix:s.pathDataHex||void 0})]})}),e.jsx(i,{label:"payloadLen",children:e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(q,{start:s.payloadByteOffset,end:s.payloadByteOffset+s.payloadHex.length/2-1}),e.jsx(d,{fn:"payloadLen",value:`${s.payloadHex.length/2} bytes`,color:"amber"})]})}),e.jsx(i,{label:"payloadHex",children:e.jsx("span",{className:"inline-block border border-edge-subtle rounded px-2 py-0.5 font-mono text-[11px] text-sys-amber break-all",children:s.payloadHex})})]}):e.jsxs(e.Fragment,{children:[e.jsx(E,{title:"A. Parse"}),e.jsxs(i,{label:"result",children:[e.jsx("span",{className:"inline-block border border-edge-subtle rounded px-2 py-0.5 font-mono text-[11px] text-sys-amber",children:"Skipped"}),e.jsx("span",{className:"ml-1 text-fg-muted",children:c??"No raw_packet (warm-tier)"})]})]})})}function Dt({decoded:t,packet:s}){if(!t)return e.jsxs(e.Fragment,{children:[e.jsx(E,{title:"B. Decode"}),e.jsx("p",{className:"text-fg-muted italic text-[10px]",children:"No decoded payload"})]});const r=Ht[t.type]??`decode${t.type}()`;return e.jsxs(e.Fragment,{children:[e.jsx(E,{title:"B. Decode — decodePayload()"}),e.jsx(U,{prefix:"decodePayload",children:e.jsxs("dl",{className:"space-y-0.5",children:[e.jsx(i,{label:"dispatched",children:r}),e.jsx(E,{}),e.jsx(Lt,{decoded:t,packet:s})]})})]})}function Lt({decoded:t,packet:s}){var r;switch(t.type){case"advert":return e.jsxs(e.Fragment,{children:[e.jsx(i,{label:"publicKey",children:e.jsx(F,{raw:e.jsx("span",{className:"text-[10px] break-all",children:t.publicKey}),children:e.jsx(d,{fn:"publicKey",value:t.publicKey,color:"green"})})}),e.jsx(i,{label:"timestamp",children:e.jsx(d,{fn:"timestamp",value:String(t.timestamp),color:"green"})}),e.jsx(i,{label:"flags",children:e.jsx(F,{raw:e.jsx(A,{value:t.flags}),children:e.jsx(d,{fn:"flags",value:t.flagsDescription,color:"green"})})}),e.jsx(i,{label:"nodeType",children:e.jsx(d,{fn:"nodeType",value:t.nodeType,color:"green"})}),t.latitude!=null&&e.jsx(i,{label:"latitude",children:e.jsx(d,{fn:"lat",value:t.latitude.toFixed(6),color:"green"})}),t.longitude!=null&&e.jsx(i,{label:"longitude",children:e.jsx(d,{fn:"lon",value:t.longitude.toFixed(6),color:"green"})}),t.name&&e.jsx(i,{label:"name",children:e.jsx(d,{fn:"name",value:t.name,color:"green"})})]});case"ack":return e.jsx(i,{label:"crc",children:e.jsx(F,{raw:e.jsx("span",{className:"text-[10px]",children:t.crc}),children:e.jsx(d,{fn:"crc",value:t.crc,color:"green"})})});case"trace":{const c=s!=null&&s.src_hash?s.src_hash.replace(/^0x/i,"").slice(0,2).toUpperCase():null;return e.jsxs(e.Fragment,{children:[e.jsx(i,{label:"traceTag",children:e.jsx(d,{fn:"traceTag",value:t.traceTag,color:"green"})}),e.jsx(i,{label:"authCode",children:e.jsx(d,{fn:"authCode",value:String(t.authCode),color:"green"})}),e.jsx(i,{label:"flags",children:e.jsx(A,{value:t.flags})}),e.jsx(i,{label:"target path",children:t.pathHashes.length>0?e.jsx(re,{hops:t.pathHashes.map(a=>a.toUpperCase()),color:"green"}):e.jsx("span",{className:"text-fg-muted italic",children:"∅ empty"})}),e.jsx(i,{label:"complete",children:t.isComplete?e.jsxs("span",{className:"text-sys-green",children:["✓ all ",t.pathHashes.length," hops reported SNR"]}):e.jsxs("span",{className:"text-sys-amber",children:["✗ ",t.snrValues.length,"/",t.pathHashes.length," hops reported"]})}),e.jsx(E,{}),e.jsxs("div",{children:[e.jsx("p",{className:"text-fg-muted mb-1 text-[10px]",children:"Directional Edge SNR — per-hop link quality"}),t.snrValues.length===0?e.jsx("p",{className:"text-fg-muted italic text-[11px] ml-2",children:"No SNR values in path field"}):e.jsx("div",{className:"space-y-0.5 ml-2",children:t.snrValues.map((a,n)=>{var g,u,v,N,f;const l=((g=t.pathHashes[n])==null?void 0:g.toUpperCase())??"??",o=n===0?c??"SRC":((u=t.pathHashes[n-1])==null?void 0:u.toUpperCase())??"??",x=(f=(N=(v=Ye.getState().stats)==null?void 0:v.config)==null?void 0:N.radio)==null?void 0:f.spreading_factor,m=we(a,x);return e.jsxs("div",{className:"flex items-center gap-1.5 text-[11px] font-mono",children:[e.jsx("span",{className:"text-fg-muted w-3 text-right",children:n}),e.jsx("span",{className:"text-fg-primary",children:o}),e.jsx("span",{className:"text-fg-muted",children:"→"}),e.jsx("span",{className:"text-fg-primary",children:l}),e.jsx("span",{className:"text-fg-muted",children:"@"}),e.jsxs("span",{className:"font-bold text-sys-green",children:[a>0?"+":"",a.toFixed(1)," dB"]}),e.jsx(M,{color:"green",children:m})]},n)})})]})]})}case"path":return e.jsxs(e.Fragment,{children:[e.jsx(i,{label:"pathLength",children:e.jsx(d,{fn:"pathLength",value:String(t.pathLength),color:"green"})}),e.jsx(i,{label:"path",children:t.path&&t.path.length>0?e.jsx(re,{hops:t.path.map(c=>c.toUpperCase()),color:"green"}):e.jsx("span",{className:"text-fg-muted italic",children:"∅ empty"})}),t.extraType!=null&&e.jsx(i,{label:"extraType",children:e.jsx(d,{fn:"extraType",value:t.extraTypeName??String(t.extraType),color:"purple"})}),t.extraData&&e.jsxs(i,{label:"extraData",children:[e.jsx("span",{className:"break-all text-[10px] font-mono",children:t.extraData}),e.jsxs("span",{className:"text-fg-muted ml-1",children:["(",t.extraData.length/2,"B)"]})]})]});case"txt_msg":return e.jsxs(e.Fragment,{children:[e.jsx(i,{label:"destHash",children:e.jsx(F,{raw:e.jsx(A,{value:t.destHash}),children:e.jsx(d,{fn:"destHash",value:t.destHash,color:"green"})})}),e.jsx(i,{label:"srcHash",children:e.jsx(F,{raw:e.jsx(A,{value:t.srcHash}),children:e.jsx(d,{fn:"srcHash",value:t.srcHash,color:"green"})})}),e.jsx(i,{label:"cipherMac",children:e.jsx(d,{fn:"cipherMac",value:t.cipherMac,color:"purple"})}),e.jsx(i,{label:"timestamp",children:e.jsx(d,{fn:"timestamp",value:String(t.timestamp),color:"green"})}),e.jsx(i,{label:"text",children:e.jsx(d,{fn:"text",value:t.text,color:"green"})}),e.jsx(i,{label:"encrypted",children:e.jsx(d,{fn:"encrypted",value:String(t.encrypted),color:"green"})})]});case"grp_txt":return e.jsxs(e.Fragment,{children:[e.jsx(i,{label:"channelHash",children:e.jsx(A,{value:t.channelHash})}),t.channelName&&e.jsx(i,{label:"channelName",children:e.jsx(d,{fn:"channel",value:t.channelName,color:"green"})}),e.jsx(i,{label:"decrypted",children:e.jsx(d,{fn:"decrypted",value:String(t.decrypted),color:"green"})}),t.text&&e.jsx(i,{label:"text",children:e.jsx(d,{fn:"text",value:t.text,color:"green"})}),t.senderName&&e.jsx(i,{label:"senderName",children:e.jsx(d,{fn:"sender",value:t.senderName,color:"green"})}),t.macCorrupted&&e.jsx(i,{label:"macCorrupted",children:e.jsx(d,{fn:"macCorrupted",value:"true",color:"green"})})]});case"grp_data":return e.jsxs(e.Fragment,{children:[e.jsx(i,{label:"channelHash",children:e.jsx(A,{value:t.channelHash})}),e.jsx(i,{label:"dataLength",children:t.dataLength}),e.jsx(i,{label:"decrypted",children:String(t.decrypted)})]});case"multipart":return e.jsxs(e.Fragment,{children:[e.jsx(i,{label:"messageId",children:t.messageId}),e.jsxs(i,{label:"part",children:[t.partNumber+1," / ",t.totalParts]})]});case"control":return e.jsxs(e.Fragment,{children:[e.jsx(i,{label:"controlType",children:e.jsx(F,{raw:e.jsx(A,{value:t.controlType}),children:e.jsx(d,{fn:"controlType",value:t.subtypeName,color:"green"})})}),e.jsx(i,{label:"subtype",children:e.jsx(d,{fn:"subtype",value:`0x${t.subtype.toString(16).padStart(2,"0")}`,color:"green"})}),t.nodeTypeName&&e.jsxs(i,{label:"nodeType",children:[e.jsx(d,{fn:"nodeType",value:t.nodeTypeName,color:"green"}),e.jsxs("span",{className:"text-fg-muted text-[10px] ml-1",children:["(flags & 0x0F = 0x",(r=t.nodeType)==null?void 0:r.toString(16).padStart(2,"0"),")"]})]}),t.snrDb!=null&&e.jsxs(i,{label:"snr",children:[e.jsxs("span",{className:"font-bold text-sys-green",children:[t.snrDb>0?"+":"",t.snrDb.toFixed(1)," dB"]}),e.jsx(M,{color:"green",children:t.snrDb>=5?"strong":t.snrDb>=0?"fair":"weak"})]}),t.tag&&e.jsx(i,{label:"tag",children:e.jsx(d,{fn:"tag",value:t.tag,color:"green"})}),t.publicKey&&e.jsxs(i,{label:"publicKey",children:[e.jsx("span",{className:"break-all text-[10px] font-mono text-sys-green",children:t.publicKey}),e.jsx(M,{color:t.publicKeyFull?"green":"amber",children:t.publicKeyFull?"32B full":`${t.publicKey.length/2}B prefix`})]}),t.typeFilter!=null&&e.jsx(i,{label:"typeFilter",children:e.jsx(F,{raw:e.jsx(A,{value:t.typeFilter}),children:e.jsx(d,{fn:"typeFilter",value:t.typeFilterDescription??"none",color:"green"})})}),t.prefixOnly!=null&&e.jsx(i,{label:"prefixOnly",children:e.jsx(d,{fn:"prefixOnly",value:String(t.prefixOnly),color:"green"})}),t.since!=null&&e.jsx(i,{label:"since",children:e.jsx(d,{fn:"since",value:t.since===0?"all (0)":String(t.since),color:"green"})}),!t.nodeTypeName&&t.typeFilter==null&&t.dataLength>0&&e.jsxs(i,{label:"data",children:[e.jsx("span",{className:"break-all text-[10px] font-mono",children:t.dataHex}),e.jsxs("span",{className:"text-fg-muted ml-1",children:["(",t.dataLength,"B)"]})]})]});case"req":return e.jsxs(e.Fragment,{children:[e.jsx(i,{label:"destHash",children:e.jsx(F,{raw:e.jsx(A,{value:t.destHash}),children:e.jsx(d,{fn:"destHash",value:t.destHash,color:"green"})})}),e.jsx(i,{label:"srcHash",children:e.jsx(F,{raw:e.jsx(A,{value:t.srcHash}),children:e.jsx(d,{fn:"srcHash",value:t.srcHash,color:"green"})})}),e.jsx(i,{label:"cipherMac",children:e.jsx(d,{fn:"cipherMac",value:t.cipherMac,color:"purple"})}),e.jsxs(i,{label:"ciphertext",children:[e.jsx("span",{className:"break-all text-[10px] font-mono",children:t.ciphertextHex}),e.jsxs("span",{className:"text-fg-muted ml-1",children:["(",t.ciphertextLength,"B)"]})]})]});case"response":return e.jsxs(e.Fragment,{children:[e.jsx(i,{label:"destHash",children:e.jsx(F,{raw:e.jsx(A,{value:t.destHash}),children:e.jsx(d,{fn:"destHash",value:t.destHash,color:"green"})})}),e.jsx(i,{label:"srcHash",children:e.jsx(F,{raw:e.jsx(A,{value:t.srcHash}),children:e.jsx(d,{fn:"srcHash",value:t.srcHash,color:"green"})})}),e.jsx(i,{label:"cipherMac",children:e.jsx(d,{fn:"cipherMac",value:t.cipherMac,color:"purple"})}),e.jsxs(i,{label:"ciphertext",children:[e.jsx("span",{className:"break-all text-[10px] font-mono",children:t.ciphertextHex}),e.jsxs("span",{className:"text-fg-muted ml-1",children:["(",t.ciphertextLength,"B)"]})]})]});case"anon_req":return e.jsxs(e.Fragment,{children:[e.jsx(i,{label:"destHash",children:e.jsx(F,{raw:e.jsx(A,{value:t.destHash}),children:e.jsx(d,{fn:"destHash",value:t.destHash,color:"green"})})}),e.jsx(i,{label:"senderPubKey",children:e.jsx("span",{className:"break-all text-[10px] font-mono text-sys-green",children:t.senderPublicKey})}),e.jsx(i,{label:"cipherMac",children:e.jsx(d,{fn:"cipherMac",value:t.cipherMac,color:"purple"})}),e.jsxs(i,{label:"ciphertext",children:[e.jsx("span",{className:"break-all text-[10px] font-mono",children:t.ciphertextHex}),e.jsxs("span",{className:"text-fg-muted ml-1",children:["(",t.ciphertextLength,"B)"]})]})]});case"generic":return e.jsxs(e.Fragment,{children:[e.jsxs(i,{label:"payloadType",children:[e.jsx(ht,{value:t.payloadType})," (",t.payloadTypeName,")"]}),e.jsx(i,{label:"length",children:t.length}),e.jsx(i,{label:"rawHex",children:e.jsx("span",{className:"break-all",children:t.rawHex})})]});default:return e.jsx("p",{className:"text-fg-muted",children:"Unknown decoded type"})}}function Pt({protocolPacket:t,packetHash:s}){const r=t==null?void 0:t.payloadType,c=r===Ze||r===Xe,a=T.useMemo(()=>{if(!c||!t)return null;const p=t.payload;return p.length<4?null:{channelHash:p[0],mac:p.slice(1,3),ciphertext:p.slice(3)}},[t,c]),[n,l]=T.useState("pending"),[o,x]=T.useState([]),[m,g]=T.useState(0);T.useEffect(()=>{if(!a){l(null);return}let p=!1;return(async()=>{const H=performance.now(),C=await Qe(a.channelHash,a.mac,a.ciphertext);p||(l(C),g(performance.now()-H));const D=await Je(a.channelHash);p||x(D)})(),()=>{p=!0}},[a]);const[u,v]=T.useState(""),[N,f]=T.useState(null),[k,$]=T.useState(!1),h=T.useCallback(async()=>{if(!(!a||!u.trim())){$(!0);try{const p=await We(u.trim(),a.channelHash,a.mac,a.ciphertext);if(p.success){const _=new TextDecoder("utf-8",{fatal:!1}).decode(p.result.plaintext.slice(5));f({success:!0,text:_})}else f({success:!1,error:p.error})}catch(p){f({success:!1,error:String(p)})}finally{$(!1)}}},[a,u]),y=Ce(s);return!c||!a?null:e.jsxs(e.Fragment,{children:[e.jsx(E,{title:"C. Decrypt — tryDecryptGroupMessage()"}),m>0&&e.jsx("div",{className:"flex justify-end",children:e.jsx("span",{className:"font-mono text-[10px] px-1.5 py-0.5 rounded bg-sys-green/15 text-sys-green",children:m<1?`${(m*1e3).toFixed(0)}µs`:`${m.toFixed(2)}ms`})}),e.jsx(U,{prefix:"tryDecryptGroupMessage",children:e.jsxs("dl",{className:"space-y-0.5",children:[e.jsx(i,{label:"channelHash",children:e.jsx(d,{fn:"channelHash",value:`0x${a.channelHash.toString(16).toUpperCase().padStart(2,"0")}`,color:"teal"})}),e.jsx(i,{label:"mac",children:e.jsx(d,{fn:"mac",value:Array.from(a.mac).map(p=>p.toString(16).padStart(2,"0")).join(""),color:"teal"})}),e.jsx(i,{label:"cipherLen",children:e.jsx(d,{fn:"cipherLen",value:`${a.ciphertext.length}B`,color:"teal"})}),e.jsx(i,{label:"candidates",children:e.jsx(d,{fn:"candidates",value:o.length>0?`${o.length} names`:"0",color:o.length>0?"teal":"zinc"})}),o.length>0&&e.jsxs("details",{className:"mt-1",children:[e.jsx("summary",{className:"text-fg-muted cursor-pointer hover:text-fg-primary text-[10px]",children:"show candidate names"}),e.jsx("div",{className:"mt-1 text-[10px] text-fg-muted break-all max-h-24 overflow-y-auto",children:o.join(", ")})]}),e.jsx(E,{}),e.jsxs("div",{children:[e.jsx("p",{className:"text-fg-muted mb-1",children:"Result:"}),n==="pending"?e.jsx("p",{className:"text-fg-muted italic",children:"decrypting…"}):n?e.jsxs(e.Fragment,{children:[e.jsx(i,{label:"channel",children:e.jsx(d,{fn:"channel",value:n.channelName,color:"teal"})}),e.jsx(i,{label:"plaintext",children:e.jsx(d,{fn:"plaintext",value:new TextDecoder("utf-8",{fatal:!1}).decode(n.plaintext.slice(5)).trim()||"(empty)",color:"teal"})}),e.jsx(i,{label:"macValid",children:e.jsx(d,{fn:"macValid",value:n.macCorrupted?"false":"true",color:"teal"})})]}):e.jsxs(i,{label:"decrypt",children:[e.jsx(d,{fn:"decrypt",value:"failed",color:"red"}),e.jsx("span",{className:"text-fg-muted ml-1",children:"channel not in known list"})]})]}),e.jsx(E,{}),e.jsxs("div",{children:[e.jsx("p",{className:"text-fg-muted mb-1",children:"testChannelName() — manual test:"}),e.jsxs("div",{className:"flex gap-1.5 items-center",children:[e.jsx("input",{type:"text",value:u,onChange:p=>{v(p.target.value),f(null)},onKeyDown:p=>p.key==="Enter"&&h(),placeholder:"channel name",className:"surface-input px-2 py-1 rounded text-[11px] font-mono text-fg-primary w-40"}),e.jsx("button",{onClick:h,disabled:k||!u.trim(),className:"px-2 py-1 rounded text-[10px] font-mono bg-sys-blue/20 text-sys-blue hover:bg-sys-blue/30 disabled:opacity-40 transition-colors",children:k?"…":"Try"})]}),N&&e.jsx("div",{className:"mt-1",children:N.success?e.jsx(i,{label:"result",children:e.jsx(d,{fn:"plaintext",value:N.text??"(empty)",color:"teal"})}):e.jsx(i,{label:"error",children:e.jsx(d,{fn:"error",value:N.error??"unknown",color:"red"})})})]}),e.jsx(E,{}),e.jsxs("div",{children:[e.jsx("p",{className:"text-fg-muted mb-1",children:"useDecodedMessage() store result:"}),y?y.decoded?e.jsxs(e.Fragment,{children:[e.jsx(i,{label:"channel",children:e.jsx(d,{fn:"channel",value:y.decoded.channelName??"?",color:"teal"})}),e.jsx(i,{label:"text",children:e.jsx(d,{fn:"text",value:y.decoded.text,color:"teal"})})]}):e.jsx(i,{label:"decrypt",children:e.jsx(d,{fn:"decrypt",value:"failed",color:"red"})}):e.jsx(i,{label:"decrypt",children:e.jsx(d,{fn:"decrypt",value:"pending",color:"zinc"})})]})]})})]})}function Mt(t){const{rawHex:s,display:r,protocolPacket:c,decoded:a,parseError:n,parseTimeMs:l,payloadVersion:o,isV1:x,isV2:m,packetHash:g,packet:u}=t,v=!!s&&s.length>=4;return e.jsxs(G,{children:[e.jsx(K,{className:"w-full mt-2 mb-1",children:e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("span",{className:"text-[10px] font-mono text-fg-muted",children:"🔬"}),e.jsx("span",{className:"text-[10px] font-mono font-medium text-fg-muted",children:"Wire Inspection"}),e.jsx("span",{className:"text-[9px] text-fg-muted/50",children:"observatory diagnostic — not a runtime stage"})]})}),e.jsx(V,{children:e.jsxs("div",{className:"border border-dashed border-edge-subtle rounded-lg p-3 space-y-1 bg-surface/30",children:[e.jsx("p",{className:"text-[9px] text-fg-muted/50 mb-2",children:"The backend parsed these fields server-side. This panel verifies the wire-level encoding client-side."}),v?e.jsxs(e.Fragment,{children:[e.jsx($t,{rawHex:s,display:r,protocolPacket:c,parseError:n,parseTimeMs:l,payloadVersion:o,isV1:x,isV2:m}),e.jsx(Dt,{decoded:a,packet:u}),e.jsx(Pt,{protocolPacket:c,packetHash:g})]}):e.jsx("p",{className:"text-fg-muted italic text-[10px]",children:n??"No raw_packet — wire inspection unavailable (warm-tier packet)"})]})})]})}function fe(t){if(!t)return[{fn:"decode",value:"no raw_packet",group:"decode",color:"zinc"}];switch(t.type){case"advert":{const s=t,r=[{fn:"decode.nodeType",value:s.nodeType,group:"decode",color:"blue"}];return s.name&&r.push({fn:"decode.name",value:s.name,group:"decode",color:"blue"}),s.latitude!=null&&s.longitude!=null&&r.push({fn:"decode.location",value:`${s.latitude.toFixed(4)}, ${s.longitude.toFixed(4)}`,group:"decode",color:"blue"}),r.push({fn:"decode.publicKey",value:s.publicKey,group:"decode",color:"blue"}),r}case"trace":{const s=t;return[{fn:"decode.traceTag",value:s.traceTag,group:"decode",color:"blue"},{fn:"decode.hops",value:s.pathHashes.length>0?s.pathString:"empty",group:"decode",color:"blue"},{fn:"decode.snr",value:s.snrValues.length>0?`${s.snrValues.length} values`:"none",group:"decode",color:s.snrValues.length>0?"blue":"zinc"},{fn:"decode.complete",value:s.isComplete?"yes":"partial",group:"decode",color:s.isComplete?"green":"amber"}]}case"path":{const s=t,r=[{fn:"decode.pathLength",value:String(s.pathLength),group:"decode",color:"blue"},{fn:"decode.path",value:s.path.length>0?s.pathString:"empty",group:"decode",color:"blue"}];return s.extraType!=null&&r.push({fn:"decode.extraType",value:s.extraTypeName??String(s.extraType),group:"decode",color:"purple"}),s.extraData&&r.push({fn:"decode.extraData",value:`${s.extraData.length/2}B`,group:"decode",color:"purple"}),r}case"ack":return[{fn:"decode.crc",value:t.crc,group:"decode",color:"blue"}];case"grp_txt":return[{fn:"decode.channelHash",value:t.channelHash,group:"decode",color:"blue"},{fn:"decode.encrypted",value:"true — decrypt at cascade",group:"decode",color:"zinc"}];case"grp_data":{const s=t;return[{fn:"decode.channelHash",value:s.channelHash,group:"decode",color:"blue"},{fn:"decode.dataLength",value:`${s.dataLength}B`,group:"decode",color:"blue"}]}case"txt_msg":{const s=t;return[{fn:"decode.srcHash",value:s.srcHash,group:"decode",color:"blue"},{fn:"decode.destHash",value:s.destHash,group:"decode",color:"blue"},{fn:"decode.encrypted",value:s.encrypted?"true":"false",group:"decode",color:s.encrypted?"zinc":"green"},...s.encrypted?[]:[{fn:"decode.text",value:s.text,group:"decode",color:"blue"}]]}case"multipart":{const s=t;return[{fn:"decode.part",value:`${s.partNumber+1}/${s.totalParts}`,group:"decode",color:"blue"},{fn:"decode.msgId",value:s.messageId,group:"decode",color:"blue"}]}case"control":{const s=t,r=[{fn:"decode.subtype",value:s.subtypeName,group:"decode",color:"blue"}];return s.nodeTypeName&&r.push({fn:"decode.nodeType",value:s.nodeTypeName,group:"decode",color:"blue"}),s.snrDb!=null&&r.push({fn:"decode.snr",value:`${s.snrDb>0?"+":""}${s.snrDb.toFixed(1)} dB`,group:"decode",color:"blue"}),s.tag&&r.push({fn:"decode.tag",value:s.tag,group:"decode",color:"blue"}),s.publicKey&&r.push({fn:"decode.publicKey",value:s.publicKey,group:"decode",color:s.publicKeyFull?"green":"blue"}),s.typeFilter!=null&&r.push({fn:"decode.typeFilter",value:s.typeFilterDescription??`0x${s.typeFilter.toString(16)}`,group:"decode",color:"blue"}),s.prefixOnly!=null&&r.push({fn:"decode.prefixOnly",value:String(s.prefixOnly),group:"decode",color:"blue"}),!s.nodeTypeName&&!s.tag&&(r.push({fn:"decode.subtypeFlags",value:`0x${s.subtypeFlags.toString(16)}`,group:"decode",color:"blue"}),r.push({fn:"decode.dataLength",value:`${s.dataLength}B`,group:"decode",color:"blue"})),r}case"req":{const s=t;return[{fn:"decode.destHash",value:s.destHash,group:"decode",color:"blue"},{fn:"decode.srcHash",value:s.srcHash,group:"decode",color:"blue"},{fn:"decode.cipherMac",value:s.cipherMac,group:"decode",color:"purple"},{fn:"decode.ciphertext",value:`${s.ciphertextLength}B`,group:"decode",color:"zinc"}]}case"response":{const s=t;return[{fn:"decode.destHash",value:s.destHash,group:"decode",color:"blue"},{fn:"decode.srcHash",value:s.srcHash,group:"decode",color:"blue"},{fn:"decode.cipherMac",value:s.cipherMac,group:"decode",color:"purple"},{fn:"decode.ciphertext",value:`${s.ciphertextLength}B`,group:"decode",color:"zinc"}]}case"anon_req":{const s=t;return[{fn:"decode.destHash",value:s.destHash,group:"decode",color:"blue"},{fn:"decode.senderPubKey",value:s.senderPublicKey,group:"decode",color:"green"},{fn:"decode.cipherMac",value:s.cipherMac,group:"decode",color:"purple"},{fn:"decode.ciphertext",value:`${s.ciphertextLength}B`,group:"decode",color:"zinc"}]}case"generic":return[{fn:"decode.raw",value:`${t.length}B`,group:"decode",color:"zinc"}];default:return[]}}function Rt({packet:t,pipeline:s,rawHex:r,traceTagIndex:c,neighbors:a}){const{enrichment:n,timing:l,display:o,protocolPacket:x,decoded:m,parseError:g,payloadVersion:u,isV1:v,isV2:N,analysis:f}=s,$=(t.type??t.payload_type)===et,h=f.dupeAnalysis,y=T.useRef(0),p=T.useMemo(()=>{if(!$)return null;const D=performance.now(),L=bt(t,c,a);return y.current=performance.now()-D,L},[t,c,a,$]),_=l.enrich+y.current,H=[];f.byteLen&&H.push(`${f.byteLen}B`),H.push(f.payloadTypeName),n.advertName&&H.push(`"${n.advertName}"`),n.isZeroHop?H.push("zero-hop"):f.pathHopCount>0&&H.push(`${f.pathHopCount}h`),H.push(`${t.rssi}dBm`),h.isDuplicate&&H.push("DUPE");const C=H.join(" — ");return e.jsxs(le,{stage:1,name:"INGEST",fn:n.preComputed?"PacketCache.mergePackets()":"extractAdvertData() + extractHopData() + ...",verdict:C,timeMs:_,children:[e.jsx(Mt,{rawHex:r,display:o,protocolPacket:x,decoded:m,parseError:g,parseTimeMs:l.parse,payloadVersion:u,isV1:v,isV2:N,packetHash:t.packet_hash,packet:t}),e.jsx(E,{title:"Cache Enrichment"}),e.jsx(U,{prefix:"packetCache",children:e.jsxs("dl",{className:"space-y-0.5",children:[e.jsxs("div",{className:"mb-1.5",children:[n.preComputed?e.jsx(M,{color:"green",children:"PacketCache"}):e.jsx(M,{color:"amber",children:"computed"}),e.jsx("span",{className:"text-[10px] text-fg-muted ml-1.5",children:n.preComputed?"pre-enriched by real pipeline":"synthetic — computed on the fly"})]}),e.jsxs("div",{className:"flex flex-wrap gap-x-2 gap-y-1 mb-1",children:[e.jsx(d,{fn:"_byteLength",value:n.byteLength!=null?`${n.byteLength}B`:void 0,color:"blue"}),e.jsx(d,{fn:"_hopCount",value:String(n.hopCount),color:"blue"}),e.jsx(d,{fn:"_isZeroHop",value:String(n.isZeroHop),color:n.isZeroHop?"green":"blue"}),n.isZeroHop&&e.jsx(M,{color:"blue",children:"direct"}),n.channelHash!=null&&e.jsx(d,{fn:"_channelHash",value:n.channelHash,color:"blue"}),$&&t._traceTag&&e.jsx(d,{fn:"_traceTag",value:t._traceTag,color:"blue"})]}),n.advertSender||n.advertNodeType!=null||n.advertName!=null?e.jsxs("div",{className:"mt-1 mb-1",children:[e.jsx("p",{className:"text-[10px] text-sys-blue font-medium mb-0.5",children:"ADVERT Enrichment"}),e.jsxs("div",{className:"flex flex-wrap gap-x-2 gap-y-1",children:[n.advertSender&&e.jsx(d,{fn:"_advertSender",value:n.advertSender.slice(0,16)+"…",color:"blue"}),n.advertNodeType!=null&&e.jsx(d,{fn:"_advertNodeType",value:ke(n.advertNodeType),color:"blue"}),n.advertName!=null&&e.jsx(d,{fn:"_advertName",value:n.advertName,color:"blue"}),n.advertFlags!=null&&e.jsx(d,{fn:"_advertFlags",value:`0x${n.advertFlags.toString(16).padStart(2,"0")}`,color:"blue"}),n.advertHasLocation!=null&&e.jsx(d,{fn:"_advertHasLocation",value:String(n.advertHasLocation),color:"blue"}),n.advertHasName!=null&&e.jsx(d,{fn:"_advertHasName",value:String(n.advertHasName),color:"blue"}),n.advertLatitude!=null&&n.advertLongitude!=null&&e.jsx(d,{fn:"location",value:`${n.advertLatitude.toFixed(4)}, ${n.advertLongitude.toFixed(4)}`,color:"blue"})]})]}):e.jsx("p",{className:"text-[10px] text-fg-muted/30 mb-1",children:"ADVERT fields: N/A (non-ADVERT packet)"}),e.jsx(E,{title:"Payload Decode"}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-1",children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${m?"bg-sys-blue":"bg-zinc-500/40"}`}),e.jsx("span",{className:"font-mono text-[10px] font-medium text-fg-primary",children:"decodePayload()"}),e.jsx("span",{className:"text-[9px] text-fg-muted",children:"sync — wire data only, no crypto"})]}),e.jsx("div",{className:"ml-3",children:m?e.jsx("div",{className:"flex flex-wrap gap-x-1.5 gap-y-1",children:fe(m).map((D,L)=>e.jsx("span",{className:"inline-block border border-edge-subtle rounded px-1.5 py-0.5",children:e.jsx(d,{fn:D.fn,value:D.value,color:D.color})},L))}):e.jsx(S,{children:"no raw_packet — warm-tier packet, decode unavailable"})})]}),e.jsx(E,{}),e.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 text-[11px] font-mono",children:[e.jsx("span",{className:"text-fg-muted",children:"dupe:"}),h.isDuplicate?e.jsx(d,{fn:"is_duplicate",value:"true",color:"purple"}):e.jsx(S,{children:"none"}),h.dupeCount>0&&e.jsx(d,{fn:"dupeCount",value:`×${h.dupeCount}`,color:"purple"}),h.rssiRange&&e.jsxs(S,{c:"text-fg-primary",children:["Δ",Math.abs(h.rssiRange[1]-h.rssiRange[0]),"dB RSSI"]})]}),p&&e.jsxs(e.Fragment,{children:[e.jsx(E,{}),e.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 text-[11px] font-mono",children:[e.jsx("span",{className:"text-fg-muted",children:"TRACE SRC:"}),p.inferredSrc?e.jsxs(e.Fragment,{children:[e.jsx(d,{fn:"inferredSrc",value:p.inferredSrc,color:"purple"}),p.inferredName&&e.jsx(d,{fn:"name",value:p.inferredName,color:"purple"})]}):e.jsx(S,{children:"unresolvable"}),e.jsx(_e,{color:"purple",children:p.method}),e.jsxs(S,{children:["(",p.confidence,")"]}),e.jsxs(S,{children:["siblings=",p.siblingCount]})]})]}),(()=>{const D=f.pType!=null?`0x${f.pType.toString(16).toUpperCase().padStart(2,"0")}`:void 0,L=t.route!=null?`0x${t.route.toString(16).toUpperCase().padStart(2,"0")}`:void 0,P=fe(m),R=f.signalClass==="excellent"||f.signalClass==="good"?"green":f.signalClass==="fair"?"amber":"red",b=f.senderTier==="pubkey"?"green":f.senderTier==="prefix"?"amber":f.senderTier==="encrypted"?"teal":"zinc",w=[{fn:"type",value:f.payloadTypeName,raw:D,group:"wire",color:"blue"},{fn:"route",value:f.routeTypeName,raw:L,group:"wire",color:"blue"},{fn:"src_hash",value:t.src_hash||void 0,group:"wire",color:"blue"},{fn:"rssi",value:`${t.rssi}dBm`,group:"wire",color:"blue"},{fn:"snr",value:`${t.snr}dB`,group:"wire",color:"blue"},{fn:"_byteLength",value:f.byteLen?`${f.byteLen}B`:void 0,group:"enrichment",color:"blue"},{fn:"_hopCount",value:String(n.hopCount),group:"enrichment",color:"blue"},{fn:"_isZeroHop",value:String(n.isZeroHop),group:"enrichment",color:"blue"},{fn:"_advertSender",value:n.advertSender||void 0,group:"enrichment",color:"blue"},{fn:"_advertNodeType",value:f.advertType!=="unknown"?f.advertType:void 0,group:"enrichment",color:"blue"},{fn:"_advertName",value:n.advertName||void 0,group:"enrichment",color:"blue"},{fn:"_channelHash",value:n.channelHash||void 0,group:"enrichment",color:"blue"},...P,{fn:"is_duplicate",value:String(h.isDuplicate),group:"analysis",color:"purple"},p!=null&&p.inferredSrc?{fn:"traceSrc",value:p.inferredSrc,group:"analysis",color:"purple"}:{fn:"traceSrc"},{fn:"_signalClass",value:f.signalClass,group:"analysis",color:R},{fn:"_routeClass",value:f.routeClass,group:"analysis",color:"purple"},{fn:"_senderTier",value:f.senderTier,group:"analysis",color:b},{fn:"_origin",value:f.origin,group:"analysis",color:f.origin==="tx_local"?"green":f.origin==="tx_forward"?"amber":"purple"},{fn:"_pathAvail",value:f.pathAvail?`${f.pathHopCount} hops`:"none",group:"analysis",color:f.pathAvail?"green":"zinc"},{fn:"_age",value:f.age,group:"analysis",color:f.age==="live"||f.age==="recent"?"green":"zinc"},...h.dupeCount>0?[{fn:"_dupeCount",value:`×${h.dupeCount}`,group:"analysis",color:"purple"},...h.rssiRange?[{fn:"_multipath",value:`Δ${Math.abs(h.rssiRange[1]-h.rssiRange[0])}dB`,group:"analysis",color:Math.abs(h.rssiRange[1]-h.rssiRange[0])>6?"amber":"green"}]:[]]:[],...t.lbt_attempts!=null?[{fn:"_lbt",value:`${t.lbt_attempts} attempt${t.lbt_attempts!==1?"s":""}`,group:"analysis",color:(t.lbt_attempts??0)>1?"amber":"green"}]:[],...t.drop_reason?[{fn:"_dropReason",value:t.drop_reason,group:"analysis",color:"red"}]:[]];return e.jsx(se,{tokens:w})})()]})})]})}function be(t){switch(t){case"excellent":return"green";case"good":return"green";case"fair":return"amber";case"poor":return"red";case"critical":return"red";default:return"zinc"}}function ye(t){return`${Math.round(t*100)}%`}function je(t,s,r){return t||(s?s.slice(0,12):`~${r}`)}function At({hops:t}){return t.length===0?null:e.jsxs("div",{className:"mt-2 pt-2 border-t border-edge-subtle/40",children:[e.jsx("p",{className:"text-[9px] text-fg-muted/40 uppercase tracking-widest font-mono mb-1.5",children:"per-hop trace inspection"}),e.jsx("div",{className:"space-y-1",children:t.map(s=>e.jsx(U,{prefix:`trace.hop[${s.hopIndex}]`,children:e.jsxs("div",{className:"border border-edge-subtle/40 rounded px-2 py-1.5",children:[e.jsxs(i,{label:"link",children:[e.jsx(re,{hops:[s.fromPrefix,s.toPrefix],color:"blue"}),e.jsx("span",{className:"ml-1.5",children:e.jsx(_e,{color:be(s.quality),children:s.quality})})]}),e.jsx(i,{label:"snr",children:e.jsx(F,{raw:e.jsx("span",{className:"text-sys-blue",children:s.snrRaw}),children:e.jsx(d,{fn:"snr",value:`${s.snrRaw.toFixed(1)} dB`,color:be(s.quality)})})}),e.jsxs(i,{label:"from",children:[e.jsx(d,{fn:"resolve",value:je(s.fromName,s.fromHash,s.fromPrefix),color:s.fromHash?s.fromConfidence>=.8?"green":"amber":"purple"}),e.jsx("span",{className:"ml-1",children:e.jsx(d,{fn:"conf",value:ye(s.fromConfidence),color:"zinc"})})]}),e.jsxs(i,{label:"to",children:[e.jsx(d,{fn:"resolve",value:je(s.toName,s.toHash,s.toPrefix),color:s.toHash?s.toConfidence>=.8?"green":"amber":"purple"}),e.jsx("span",{className:"ml-1",children:e.jsx(d,{fn:"conf",value:ye(s.toConfidence),color:"zinc"})})]})]})},s.hopIndex))}),e.jsx(se,{label:"trace contributes",tokens:Ft(t)})]})}function Ft(t){const s=t.reduce((n,l)=>n+(l.fromHash?1:0)+(l.toHash?1:0),0),r=t.length*2,c=r-s,a=t.length>0?t.reduce((n,l)=>n+l.snrRaw,0)/t.length:0;return[{fn:"hops",value:String(t.length),group:"wire",color:"blue"},{fn:"resolved",value:`${s}/${r}`,group:"worker",color:"green"},...c>0?[{fn:"ghosts",value:String(c),group:"worker",color:"purple"}]:[],{fn:"avgSnr",value:`${a.toFixed(1)} dB`,group:"analysis",color:a>=5?"green":a>=0?"amber":"red"}]}function Et(t){if(!t)return"never";const s=Math.floor((Date.now()-t)/1e3);return s<60?`${s}s ago`:s<3600?`${Math.floor(s/60)}m ago`:`${Math.floor(s/3600)}h ago`}function Ot(t){if(!t)return[];const s=t.decoded;if(!s)return[{fn:"decrypt.result",value:"failed",group:"crypto",color:"red"}];if(!s.decrypted)return[{fn:"decrypt.result",value:"no key match",group:"crypto",color:"zinc"}];const r=[];return s.channelName&&r.push({fn:"decrypt.channelName",value:s.channelName,group:"crypto",color:"teal"}),s.senderName&&r.push({fn:"decrypt.senderName",value:s.senderName,group:"crypto",color:"teal"}),s.text&&r.push({fn:"decrypt.text",value:s.text,group:"crypto",color:"teal"}),s.timestamp&&r.push({fn:"decrypt.timestamp",value:new Date(s.timestamp*1e3).toISOString().slice(11,19),group:"crypto",color:"teal"}),s.macCorrupted&&r.push({fn:"decrypt.macCorrupted",value:"true",group:"crypto",color:"amber"}),r}function zt({packet:t,decrypted:s,pipeline:r}){var b;const c=J(w=>w.isComputing),a=J(w=>w.lastUpdated),n=J(w=>w.lastComputeTimeMs),l=J(w=>w.topology.edges.length),o=J(w=>w.topology.discoveredNodes.length),x=tt(),m=st(),g=nt(),u=he(w=>w.isComputing),v=he(w=>w.nodeCount),N=me(w=>w.progress),f=me(w=>w.initialDecodeComplete),k=t.type??t.payload_type,$=k===O.GRP_TXT||k===O.GRP_DATA,h=k===O.TRACE,y=k===O.PATH,p=$,_=[{label:"full",detail:"all GRP_TXT → decryption worker",active:p&&f,color:"teal"},{label:"quick",detail:"100 most recent (initial load)",active:p&&!f,color:"amber"},{label:"skip",detail:"non-GRP or catchup path",active:!p,color:"zinc"}],H=Ot(s),C=((b=s==null?void 0:s.decoded)==null?void 0:b.decrypted)===!0,D=c?"running":`${l}e ${o}g`,L=u?"running":`${v}n`,P=p?C?"decrypted":N.isDecoding?`${N.percent}%`:"pending":"N/A",R=`topo ${c?"○":"✓"} ${D} · spark ${u?"○":"✓"} ${L} · decrypt ${P}`;return e.jsx(le,{stage:2,name:"CASCADE",fn:"hydrateDownstream()",verdict:R,children:e.jsx(U,{prefix:"cascade",children:e.jsxs("div",{className:"space-y-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-1 py-1.5 text-[11px] font-mono",children:[e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${c?"bg-sys-amber animate-pulse":"bg-sys-green"}`}),e.jsx("span",{className:"text-fg-primary",children:"topology"}),e.jsxs("span",{className:"text-fg-muted",children:[l,"e ",o,"g"]}),(h||y)&&e.jsx("span",{className:"text-sys-green text-[9px]",children:"↑signal"})]}),e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${u?"bg-sys-amber animate-pulse":"bg-sys-green"}`}),e.jsx("span",{className:"text-fg-primary",children:"sparkline"}),e.jsxs("span",{className:"text-fg-muted",children:[v,"n"]})]}),e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${N.isDecoding?"bg-sys-amber animate-pulse":p?"bg-sys-teal":"bg-zinc-500/40"}`}),e.jsx("span",{className:"text-fg-primary",children:"decrypt"}),e.jsx("span",{className:p?"text-sys-teal":"text-fg-muted",children:p?C?"decrypted":N.isDecoding?`${N.percent}%`:"pending":"N/A"})]})]}),e.jsxs(G,{defaultOpen:h||y,children:[e.jsx(K,{className:"text-[10px] w-full border-t border-edge-subtle pt-1.5",children:e.jsx("span",{className:"font-mono text-fg-muted/50",children:"topology detail…"})}),e.jsx(V,{children:e.jsxs("div",{className:"ml-3 pb-2",children:[e.jsx(i,{label:"status",children:e.jsx(d,{fn:"isComputing",value:c?"running":"idle",color:c?"amber":"green"})}),e.jsxs(i,{label:"last",children:[e.jsx(d,{fn:"lastUpdated",value:Et(a),color:"zinc"}),n>0&&e.jsxs("span",{className:"ml-2 text-fg-muted text-[10px]",children:["(",n<1e3?`${n.toFixed(0)}ms`:`${(n/1e3).toFixed(1)}s`,")"]})]}),e.jsxs(i,{label:"output",children:[e.jsx(d,{fn:"edges",value:String(l),color:"green"}),e.jsx(d,{fn:"ghostNodes",value:String(o),color:"purple"})]}),m&&e.jsxs(e.Fragment,{children:[e.jsxs(i,{label:"trace links",children:[e.jsx(d,{fn:"directed",value:String(x.totalDirectedLinks),color:"teal"}),e.jsx(d,{fn:"bidir",value:String(x.bidirectionalLinks),color:"teal"}),e.jsx(d,{fn:"traces",value:String(x.totalTraces),color:"zinc"})]}),e.jsxs(i,{label:"trace SNR",children:[e.jsx(d,{fn:"mean",value:`${x.meanSnr.toFixed(1)} dB`,color:x.meanSnr>=5?"green":x.meanSnr>=0?"amber":"red"}),e.jsx(d,{fn:"median",value:`${x.medianSnr.toFixed(1)} dB`,color:"zinc"}),e.jsx(d,{fn:"confidence",value:`${Math.round(x.avgConfidence*100)}%`,color:"zinc"})]}),h&&e.jsxs(i,{label:"quality",children:[e.jsx(d,{fn:"excellent",value:String(x.qualityCounts.excellent),color:"green"}),e.jsx(d,{fn:"good",value:String(x.qualityCounts.good),color:"green"}),e.jsx(d,{fn:"fair",value:String(x.qualityCounts.fair),color:"amber"}),e.jsx(d,{fn:"poor",value:String(x.qualityCounts.poor),color:"red"}),e.jsx(d,{fn:"critical",value:String(x.qualityCounts.critical),color:"red"})]}),g.confirmedResolutions.size>0&&e.jsxs(i,{label:"feedback",children:[e.jsx(d,{fn:"feedback.confirmed",value:String(g.confirmedResolutions.size),color:"teal"}),e.jsx(d,{fn:"feedback.links",value:String(g.confirmedLinks.length),color:"teal"})]})]}),h&&(r==null?void 0:r.traceHopDetail)&&e.jsx(At,{hops:r.traceHopDetail})]})})]}),p&&e.jsx("div",{className:"border-t border-edge-subtle pt-2 pb-2",children:e.jsxs("div",{className:"ml-3",children:[e.jsx(i,{label:"mode",children:e.jsx(ae,{options:_,nextFn:"queueDecryption()"})}),e.jsx(i,{label:"result",children:e.jsx(d,{fn:"decrypt",value:C?"decrypted":s?"failed":"pending",color:C?"teal":s?"red":"zinc"})}),C&&e.jsx("div",{className:"mt-1 flex flex-wrap gap-x-1.5 gap-y-1",children:H.map((w,oe)=>e.jsx("span",{className:"inline-block border border-edge-subtle rounded px-1.5 py-0.5",children:e.jsx(d,{fn:w.fn,value:w.value,color:w.color})},oe))})]})}),(()=>{const w=[{fn:"topology.edges",value:String(l),group:"worker",color:"green"},{fn:"topology.ghostNodes",value:String(o),group:"worker",color:"purple"},{fn:"sparkline.nodes",value:`${v}`,group:"worker",color:"green"},...m?[{fn:"trace.directedLinks",value:String(x.totalDirectedLinks),group:"worker",color:"teal"},{fn:"trace.meanSnr",value:`${x.meanSnr.toFixed(1)} dB`,group:"worker",color:"teal"}]:[],...H];return e.jsx(se,{tokens:w})})()]})})})}function Bt(t,s,r,c){var n;const a=t.src_hash?Se(t.src_hash):"";if(t._advertSender&&s.hash&&s.confident)return{tier:1,label:"_advertSender → pubkey",detail:"ADVERT carried full 32-byte public key — definitive match"};if(c&&s.confident&&((n=s.name)==null?void 0:n.toLowerCase())===c.toLowerCase())return{tier:1.5,label:"decrypt.senderName → nameToHash",detail:`Decrypted sender name “${c}” matched neighbor — high-confidence`};if(a&&r.crossClassPrefixes.has(a))return{tier:2,label:"cross-class prefix",detail:"Prefix has mixed types (repeater + non-repeater); payload type narrows to one class"};if(s.confident){const l=r.prefixIndex.get(a);return(l==null?void 0:l.length)===1?{tier:3,label:"single candidate",detail:"Only one node matches this prefix — unambiguous"}:{tier:3,label:"resolver",detail:"Multi-signal scoring selected best candidate from collision set"}}return{tier:4,label:"ambiguous",detail:"Cannot confidently resolve — multiple same-class candidates, insufficient scoring separation"}}function It(t,s){const r=t.original_path??t.forwarded_path,c=new Set;if(r&&Array.isArray(r))for(const a of r){const n=String(a).toUpperCase().slice(0,2);n.length>=2&&n!==s&&c.add(n)}return c}function Gt(t,s,r,c,a,n,l){const o=Math.floor(Date.now()/1e3),x=new Map(r.map(m=>[m.hash,m]));return t.map(m=>{const g=s[m.hash],u=x.get(m.hash);let v=!0,N="";c!=="unknown"?m.type!=="unknown"&&m.type!==c?(v=!1,N=`${m.type} ≠ required ${c}`):m.type===c?N="type matches":N="type unknown — not ruled out":N="payload ambiguous — all types eligible";const f=!!(g!=null&&g.zero_hop),k=(g==null?void 0:g.last_seen)??0;let $=0;if(f&&k>0){const b=(o-k)/3600;$=50*Math.exp(-b/l)}let h=0;if(k>0){const b=(o-k)/3600;h=Math.exp(-b/n)}const y=h*20,p=!!(g!=null&&g.latitude&&(g!=null&&g.longitude)&&(g.latitude!==0||g.longitude!==0)),_=p?5:0,H=(u==null?void 0:u.advertCount)??0,C=Math.min(H*2,30),D=(u==null?void 0:u.forwarderPrefixes.size)??0,L=Math.min(D*3,15);let P=0;if(u&&u.totalForwarderObservations>0&&a.size>0){let b=0;for(const w of a)u.forwarderPrefixes.has(w)&&b++;P=b/a.size}const R=$+y+_+C+L;return{hash:m.hash,name:m.name,type:m.type,roleCompatible:v,roleReason:N,zeroHop:f,zeroHopScore:$,lastSeen:k,recencyScore:h,recencyPoints:y,hasGps:p,gpsScore:_,advertCount:H,advertScore:C,topoWidth:D,topoScore:L,affinity:P,total:R}}).sort((m,g)=>g.total-m.total)}function Kt({packet:t,pipeline:s,resolved:r,resolveTimeMs:c,advertName:a,neighbors:n,decrypted:l}){var ie,de;const o=Y(j=>j.neighborContext),x=Y(j=>j.topologyProfiles),m=Y(j=>j.config),{analysis:g}=s,u=r??{hash:null,type:"unknown",name:null,confident:!1},v=t.src_hash?Se(t.src_hash):"",N=v?o.prefixIndex.get(v)??[]:[],f=v?x.get(v)??[]:[],k=g.pType??-1,$=k>=0?k.toString(16).toUpperCase().padStart(2,"0"):"??",h=g.inferredType,y=g.advertType,p=g.effectiveType,_=t._advertNodeType!=null?t._advertNodeType.toString(16).padStart(2,"0").toUpperCase():"",H=((ie=l==null?void 0:l.decoded)==null?void 0:ie.senderName)??null,C=Bt(t,u,o,H),D=T.useMemo(()=>It(t,v),[t,v]),L=g.pathLen,P=T.useMemo(()=>Gt(N,n,f,p,D,m.recencyDecayHours,m.zeroHopDecayHours),[N,n,f,p,D,m.recencyDecayHours,m.zeroHopDecayHours]),R=P.filter(j=>!j.roleCompatible),b=P.filter(j=>j.roleCompatible),w=t._advertSender?o.pubKeyMap.get(t._advertSender)??null:null,oe=C.tier===1,De=[{fn:"src_hash",value:v||"",active:!!v,color:"blue"},{fn:"_advertSender",value:t._advertSender?t._advertSender.slice(0,12)+"…":"",active:!!t._advertSender,color:"blue"},{fn:"_advertNodeType",value:_?`0x${_}`:"",active:t._advertNodeType!=null,color:"blue"},{fn:"path_length",value:L!=null?L===0?"zero-hop":String(L):"",active:L!=null,color:"blue"},{fn:"decrypt.senderName",value:H??"",active:!!H,color:"teal"}],Le=[{label:"hit",detail:"pubKeyMap.get(_advertSender) → definitive",active:!!w,color:"green"},{label:"miss",detail:t._advertSender?"pubkey not in neighbor table":"no _advertSender",active:!w,color:"zinc"}],Pe=[{label:"payload",detail:`inferDeviceType(0x${$}) → ${h}`,active:h!=="unknown",color:"amber"},{label:"flags",detail:_?`mapAdvertTypeCode(0x${_}) → ${y}`:"no _advertNodeType",active:h==="unknown"&&y!=="unknown",color:"green"},{label:"ambiguous",detail:"all types eligible",active:p==="unknown",color:"zinc"}],Me=u.name??((de=u.hash)==null?void 0:de.slice(0,12))??"?",Re=u.confident?"confident":"ambiguous",Ae=`→ ${Me} (${Re}, Tier ${C.tier})`;return e.jsx(le,{stage:3,name:"RESOLVE",fn:"usePipelineStore.resolveSource()",verdict:Ae,timeMs:c,children:e.jsx(U,{prefix:"resolvePacketSource",children:e.jsxs("div",{className:"space-y-0",children:[e.jsx("div",{className:"pt-1 pb-1",children:e.jsx(Ct,{tokens:De,nextFn:"resolvePacketSource()"})}),t.src_hash?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"border-t border-edge-subtle pt-2 pb-2",children:[e.jsxs("p",{className:"text-fg-muted mb-1",children:[e.jsx(S,{c:"text-sys-blue font-bold",children:"1"})," ","PUBKEY LOOKUP"]}),e.jsx(ae,{options:Le,nextFn:"pubKeyMap.get()"}),e.jsx("div",{className:"ml-3 mt-1",children:w?e.jsxs(e.Fragment,{children:[e.jsx(i,{label:"resolved",children:e.jsx(d,{fn:"hash",value:w,color:"green"})}),a&&e.jsxs(i,{label:"name",children:[e.jsx(d,{fn:"name",value:a,color:"green"}),u.name&&a===u.name&&e.jsx(S,{c:"text-sys-green ml-1",children:"✓ neighbor match"})]}),e.jsxs(i,{label:"result",children:[e.jsx(M,{color:"green",children:"Tier 1"}),e.jsx(S,{c:"text-fg-primary ml-1",children:"definitive — scoring bypassed"})]})]}):t._advertSender?e.jsx(i,{label:"status",children:e.jsx(S,{c:"text-sys-amber",children:"✗ pubkey not in neighbor table"})}):e.jsx(i,{label:"status",children:e.jsx(S,{children:"no _advertSender — skip to prefix resolution"})})})]}),oe?e.jsx("div",{className:"border-t border-edge-subtle py-2",children:e.jsx("p",{className:"text-[11px] text-fg-muted/40 font-mono ml-3",children:"Steps 2–5 bypassed — pubkey definitive"})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"border-t border-edge-subtle pt-2 pb-2",children:[e.jsxs("p",{className:"text-fg-muted mb-1",children:[e.jsx(S,{c:"text-sys-blue font-bold",children:"2"})," ","CANDIDATE POOL — ",N.length," node",N.length!==1?"s":"",' match "',v,'"']}),e.jsxs("div",{className:"space-y-0.5 ml-3",children:[P.map(j=>e.jsxs("div",{className:"flex gap-2 items-center text-[11px]",children:[e.jsx("span",{className:"break-all text-[10px]",children:j.hash}),e.jsx(M,{color:"zinc",children:j.type||"unknown"}),j.name&&e.jsx(S,{children:j.name})]},j.hash)),N.length===0&&e.jsx(S,{children:"no known nodes for this prefix"})]})]}),e.jsxs("div",{className:"border-t border-edge-subtle pt-2 pb-2",children:[e.jsxs("p",{className:"text-fg-muted mb-1",children:[e.jsx(S,{c:"text-sys-blue font-bold",children:"3"})," ","TYPE INFERENCE"]}),e.jsx(ae,{options:Pe,nextFn:"effectiveType()"}),e.jsx("div",{className:"ml-3 mt-1",children:e.jsx(i,{label:"effective",children:e.jsx(d,{fn:"effectiveType",value:p,color:p!=="unknown"?h!=="unknown"?"amber":"green":"zinc"})})})]}),e.jsxs("div",{className:"border-t border-edge-subtle pt-2 pb-2",children:[e.jsxs("p",{className:"text-fg-muted mb-1",children:[e.jsx(S,{c:"text-sys-blue font-bold",children:"4"})," ","ROLE-TYPE SCRUB"]}),e.jsx("div",{className:"space-y-0.5 ml-3",children:P.map(j=>e.jsxs("div",{className:"flex gap-2 items-center text-[11px]",children:[e.jsx("span",{className:j.roleCompatible?"text-sys-green":"text-sys-red",children:j.roleCompatible?"✓":"✗"}),e.jsx("span",{className:`break-all text-[10px] ${j.roleCompatible?"":"line-through text-fg-muted"}`,children:j.hash}),e.jsx(M,{color:j.roleCompatible?"zinc":"red",children:j.type||"unknown"}),e.jsx(S,{c:j.roleCompatible?"text-fg-muted":"text-sys-red",children:j.roleReason})]},j.hash))}),R.length>0&&e.jsxs("p",{className:"text-[10px] text-fg-muted mt-1 ml-3",children:[R.length," eliminated, ",b.length," surviving"]})]}),e.jsxs("div",{className:"border-t border-edge-subtle pt-2 pb-2",children:[e.jsxs("p",{className:"text-fg-muted mb-1",children:[e.jsx(S,{c:"text-sys-blue font-bold",children:"5"})," ","CANDIDATE SCORING"]}),b.length===0?e.jsx("p",{className:"text-fg-muted italic ml-3",children:"No surviving candidates"}):b.length===1?e.jsxs("div",{className:"ml-3 text-[11px]",children:[e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsx(S,{c:"text-sys-green",children:"→"}),e.jsx("span",{className:"break-all text-[10px]",children:b[0].hash}),b[0].name&&e.jsx(S,{c:"text-fg-muted ml-1",children:b[0].name})]}),e.jsx("p",{className:"text-fg-muted ml-4",children:"single survivor — scoring not needed"})]}):e.jsxs(G,{children:[e.jsx(K,{className:"text-[10px] ml-3",children:e.jsxs("span",{className:"font-mono text-fg-muted/50",children:[b.length," candidates scored…"]})}),e.jsx(V,{children:e.jsx("div",{className:"space-y-2 ml-3 mt-1",children:b.map(j=>{const Q=j.hash===u.hash;return e.jsxs("div",{className:`text-[11px] leading-relaxed rounded px-2 py-1 ${Q?"bg-sys-green/8 border border-sys-green/20":"bg-zinc-500/5"}`,children:[e.jsxs("div",{className:"flex gap-2 items-center mb-0.5",children:[e.jsx(S,{c:Q?"text-sys-green":"text-fg-muted",children:Q?"→":" "}),e.jsx("span",{className:`break-all text-[10px] ${Q?"text-fg-primary":"text-fg-muted"}`,children:j.hash}),e.jsx(M,{color:Q?"green":"zinc",children:j.type||"unknown"}),j.name&&e.jsx(S,{children:j.name})]}),e.jsxs("div",{className:"ml-4 flex flex-wrap gap-x-3 gap-y-0.5",children:[e.jsxs("span",{children:[e.jsx(S,{children:"zero_hop:"})," ",e.jsx(S,{c:j.zeroHop?"text-sys-green":"text-fg-muted",children:j.zeroHop?"✓":"✗"})," ",e.jsxs(M,{color:ee(j.zeroHopScore),children:["+",j.zeroHopScore]})]}),e.jsxs("span",{children:[e.jsx(S,{children:"recency:"})," ",e.jsx(S,{c:"text-fg-primary",children:mt(j.lastSeen)})," ",e.jsxs(M,{color:ee(j.recencyPoints),children:["+",j.recencyPoints.toFixed(1)]})]}),e.jsxs("span",{children:[e.jsx(S,{children:"gps:"})," ",e.jsx(S,{c:j.hasGps?"text-sys-green":"text-fg-muted",children:j.hasGps?"✓":"✗"})," ",e.jsxs(M,{color:ee(j.gpsScore),children:["+",j.gpsScore]})]}),e.jsxs("span",{children:[e.jsx(S,{children:"adverts:"})," ",e.jsx(S,{c:"text-fg-primary",children:j.advertCount})," ",e.jsxs(M,{color:ee(j.advertScore),children:["+",j.advertScore]})]}),e.jsxs("span",{children:[e.jsx(S,{children:"topo:"})," ",e.jsx(S,{c:"text-fg-primary",children:j.topoWidth})," ",e.jsxs(M,{color:ee(j.topoScore),children:["+",j.topoScore]})]})]}),e.jsxs("div",{className:"ml-4 mt-0.5",children:[e.jsx(S,{children:"score ≈"})," ",e.jsx(S,{c:"text-fg-primary font-bold",children:j.total.toFixed(1)})]})]},j.hash)})})})]})]})]}),e.jsxs("div",{className:"border-t border-edge-subtle pt-2 pb-2",children:[e.jsxs("p",{className:"text-fg-muted mb-1",children:[e.jsx(S,{c:"text-sys-green font-bold",children:"✓"})," ","RESOLUTION"]}),e.jsxs("div",{className:"ml-3",children:[e.jsx(i,{label:"hash",children:u.hash?e.jsx(d,{fn:"resolved.hash",value:u.hash,color:"green"}):e.jsx(S,{children:"null"})}),e.jsx(i,{label:"type",children:e.jsx(d,{fn:"resolved.type",value:u.type,color:u.confident?"green":"zinc"})}),e.jsx(i,{label:"name",children:u.name?e.jsx(d,{fn:"resolved.name",value:u.name,color:u.confident?"green":"amber"}):e.jsx(S,{children:"null"})}),e.jsx(i,{label:"confident",children:e.jsx(S,{c:u.confident?"text-sys-green":"text-sys-red",children:String(u.confident)})}),e.jsxs(i,{label:"tier",children:[e.jsx(M,{color:C.tier<=2?"green":C.tier===3?"amber":"red",children:C.tier}),e.jsx(S,{c:"text-fg-primary ml-1",children:C.label})]})]})]})]}):e.jsx("div",{className:"border-t border-edge-subtle pt-2 pb-2",children:e.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 text-[11px] font-mono",children:[e.jsx(S,{c:"text-sys-amber",children:"⚠ no src_hash"}),H&&e.jsx(d,{fn:"decrypt.senderName",value:H,color:"teal"}),u.confident?e.jsxs(S,{c:"text-sys-green",children:["→ resolved via ",C.label]}):e.jsx(S,{c:"text-sys-red",children:"ambiguous"})]})}),(()=>{const j=[{fn:"resolved.hash",value:u.hash??"null",group:"resolution",color:u.confident?"green":"zinc"},{fn:"resolved.type",value:u.type,group:"resolution",color:u.type!=="unknown"?u.confident?"green":"amber":"zinc"},{fn:"resolved.name",value:u.name??"null",group:"resolution",color:u.confident?"green":u.name?"amber":"zinc"},{fn:"resolved.confident",value:String(u.confident),group:"resolution",color:u.confident?"green":"red"}];return e.jsx(se,{tokens:j})})()]})})})}const Vt={id:"packet-parse",label:"Packet Parse",inputs:["rawPacket"],outputs:["parsedPacket","decoded","headerFields"],emits:[{fn:"routeType",group:"wire",color:"blue"},{fn:"payloadType",group:"wire",color:"blue"},{fn:"pathLength",group:"wire",color:"blue"},{fn:"version",group:"wire",color:"blue"}],async:!1,observatoryStage:0},Ut={id:"enrichment",label:"Ingestion Enrichment",inputs:["parsedPacket"],outputs:["advertSender","channelHash","hopData","byteLength"],emits:[{fn:"_advertSender",group:"enrichment",color:"blue"},{fn:"_advertNodeType",group:"enrichment",color:"blue"},{fn:"_channelHash",group:"enrichment",color:"blue"},{fn:"_hopCount",group:"enrichment",color:"blue"},{fn:"_isZeroHop",group:"enrichment",color:"blue"},{fn:"_byteLength",group:"enrichment",color:"blue"}],async:!1,observatoryStage:1},qt={id:"topology",label:"Topology Analysis",inputs:["packets","neighbors","srcHashResolver"],outputs:["edges","nodeMetrics","pathHealth","ghostNodes","centrality","loops"],emits:[{fn:"edges",group:"worker",color:"green"},{fn:"ghostNodes",group:"worker",color:"purple"},{fn:"loops",group:"analysis",color:"amber"},{fn:"nodeMetrics",group:"worker",color:"green"},{fn:"pathHealth",group:"worker",color:"green"},{fn:"centrality",group:"worker",color:"green"}],async:!0,worker:"topology.worker.ts",observatoryStage:2},Wt={id:"trace-enrichment",label:"Trace Link Quality",inputs:["packets","prefixLookup","srcHashResolver","edges","pathHealth","nodeMetrics"],outputs:["traceLinks","traceLinkSummary","traceDisambiguationFeedback"],emits:[{fn:"traceLinks.directed",group:"worker",color:"teal"},{fn:"traceLinks.bidir",group:"worker",color:"teal"},{fn:"traceSummary.meanSnr",group:"analysis",color:"green"},{fn:"traceSummary.medianSnr",group:"analysis",color:"zinc"},{fn:"traceSummary.confidence",group:"analysis",color:"zinc"},{fn:"feedback.confirmed",group:"worker",color:"teal"},{fn:"feedback.links",group:"worker",color:"teal"}],async:!1,observatoryStage:2},Yt={id:"disambiguation",label:"Source Disambiguation",inputs:["packets","neighbors","decodedMessages"],outputs:["srcHashResolverMap","neighborContext"],emits:[{fn:"resolvedHash",group:"resolution",color:"purple"},{fn:"resolvedName",group:"resolution",color:"purple"},{fn:"resolvedType",group:"resolution",color:"purple"},{fn:"confidence",group:"resolution",color:"green"}],async:!1,observatoryStage:3},Zt={id:"sparkline",label:"Sparkline Computation",inputs:["packets","neighbors"],outputs:["sparklineData"],emits:[{fn:"sparklines",group:"worker",color:"blue"}],async:!1},Xt={id:"decryption",label:"Channel Decryption",inputs:["packets","channelKeys"],outputs:["decodedMessages"],emits:[{fn:"decrypt.text",group:"crypto",color:"teal"},{fn:"decrypt.senderName",group:"crypto",color:"teal"},{fn:"decrypt.channelName",group:"crypto",color:"teal"},{fn:"decrypt.macCorrupted",group:"crypto",color:"amber"}],async:!0,worker:"decryption.worker.ts",observatoryStage:2},Qt={id:"decoded-content",label:"Decoded Content Policy",inputs:["decodedMessages","packets"],outputs:["decodedContent","contentInheritance"],emits:[{fn:"content.senderName",group:"crypto",color:"teal"},{fn:"content.text",group:"crypto",color:"teal"},{fn:"content.channelName",group:"crypto",color:"teal"},{fn:"content.corrupted",group:"crypto",color:"amber"},{fn:"content.inherited",group:"analysis",color:"purple"}],async:!1},Z=[Vt,Ut,qt,Wt,Yt,Zt,Xt,Qt],Jt=new Map(Z.map(t=>[t.id,t])),es=new Map;for(const t of Z)for(const s of t.emits)es.set(s.fn,t);const $e=new Map;for(const t of Z)for(const s of t.outputs)$e.set(s,t);function ts(){const t=new Map,s=new Map;for(const a of Z)t.has(a.id)||t.set(a.id,0),s.has(a.id)||s.set(a.id,new Set);for(const a of Z)for(const n of a.inputs){const l=$e.get(n);if(l&&l.id!==a.id){const o=s.get(l.id);o.has(a.id)||(o.add(a.id),t.set(a.id,(t.get(a.id)??0)+1))}}const r=[];for(const[a,n]of t)n===0&&r.push(a);const c=[];for(;r.length>0;){const a=r.shift(),n=Jt.get(a);n&&c.push(n);for(const l of s.get(a)??[]){const o=(t.get(l)??1)-1;t.set(l,o),o===0&&r.push(l)}}for(const a of Z)c.includes(a)||c.push(a);return c}const ss={0:"text-sys-green",1:"text-sys-blue",2:"text-sys-teal",3:"text-sys-purple"};function ns({stage:t,isActive:s,onClick:r}){const c=t.observatoryStage!=null?ss[t.observatoryStage]??"text-fg-muted":"text-fg-muted/40";return e.jsxs("button",{type:"button",onClick:r,className:` + flex items-center gap-1.5 w-full px-1.5 py-1 rounded transition-base text-left + ${s?"bg-sys-blue/10 ring-1 ring-sys-blue/30":"hover:bg-zinc-500/5"} + `,children:[e.jsx("span",{className:`font-mono text-[9px] font-bold w-3 shrink-0 text-center ${c}`,children:t.observatoryStage??"·"}),e.jsx("span",{className:"font-mono text-[9px] text-fg-primary truncate flex-1",children:t.label}),t.async&&e.jsx("span",{className:"font-mono text-[7px] px-1 py-px rounded bg-sys-amber/15 text-sys-amber shrink-0 leading-tight",children:"⚡"}),t.emits.length>0&&e.jsxs("span",{className:"flex items-center gap-px shrink-0",children:[t.emits.slice(0,6).map(a=>{var n;return e.jsx("span",{className:`inline-block w-1 h-1 rounded-full ${((n=I[a.color])==null?void 0:n.dot)??"bg-zinc-500"}`,title:`${a.fn} [${a.group}]`},a.fn)}),t.emits.length>6&&e.jsxs("span",{className:"font-mono text-[7px] text-fg-muted/40 ml-0.5",children:["+",t.emits.length-6]})]})]})}function rs({activeStageId:t,onStageClick:s}){const r=T.useMemo(()=>ts(),[]),c=T.useMemo(()=>{const a=new Map;for(const l of r){const o=l.observatoryStage??"other";let x=a.get(o);x||(x=[],a.set(o,x)),x.push(l)}const n=[];for(const l of[0,1,2,3,"other"]){const o=a.get(l);o!=null&&o.length&&n.push({key:l,stages:o})}return n},[r]);return e.jsxs("div",{className:"surface-base rounded-lg border border-edge-subtle p-2",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"font-mono text-[8px] text-fg-muted/40 uppercase tracking-widest",children:"Pipeline DAG"}),e.jsxs("span",{className:"font-mono text-[8px] text-fg-muted/30",children:[r.length," stages"]})]}),e.jsx("div",{className:"space-y-px",children:c.map((a,n)=>e.jsxs("div",{children:[n>0&&e.jsx("div",{className:"flex items-center pl-2.5 py-px",children:e.jsx("svg",{width:"6",height:"8",viewBox:"0 0 6 8",className:"text-fg-muted/20",children:e.jsx("path",{d:"M3 0 L3 6 M1 4 L3 6 L5 4",fill:"none",stroke:"currentColor",strokeWidth:"1"})})}),a.stages.map(l=>e.jsx(ns,{stage:l,isActive:t===l.id,onClick:s?()=>s(l.id):void 0},l.id))]},String(a.key)))})]})}const ve=200,z={status:"idle",lastDurationMs:null,lastTs:null,runCount:0};function as(t,s,r){var c,a,n;switch(t.type){case"transport:ws:state":s.wsState=((c=t.data)==null?void 0:c.state)??r.wsState;break;case"transport:ws:packet":s.wsPacketCount=(s.wsPacketCount??r.wsPacketCount)+1;break;case"transport:ws:stats":s.wsStatsCount=(s.wsStatsCount??r.wsStatsCount)+1;break;case"transport:rest:stats":s.restStatsCount=(s.restStatsCount??r.restStatsCount)+1;break;case"transport:rest:packets":s.restPacketsCount=(s.restPacketsCount??r.restPacketsCount)+1;break;case"store:packets:ws-merge":s.wsMergeCount=(s.wsMergeCount??r.wsMergeCount)+1;break;case"cascade:hydrate":s.lastHydrateTs=t.ts,s.hydrateCount=(s.hydrateCount??r.hydrateCount)+1;break;case"worker:topology:start":case"worker:sparkline:start":{const l=t.type.split(":")[1],o=s.workers??r.workers,x=o[l]??{...z};s.workers={...o,[l]:{...x,status:"running",lastTs:t.ts}}}break;case"worker:topology:done":case"worker:sparkline:done":{const l=t.type.split(":")[1],o=s.workers??r.workers,x=o[l]??{...z},m=((a=t.data)==null?void 0:a.ms)??null;s.workers={...o,[l]:{...x,status:"done",lastDurationMs:m,lastTs:t.ts,runCount:x.runCount+1}}}break;case"worker:decryption:batch":{const l=s.workers??r.workers,o=l.decryption??{...z},x=((n=t.data)==null?void 0:n.ms)??null;s.workers={...l,decryption:{...o,status:"done",lastDurationMs:x,lastTs:t.ts,runCount:o.runCount+1}}}break;case"pipeline:disambig:recompute":s.disambigCount=(s.disambigCount??r.disambigCount)+1;break}}const te=rt(t=>({events:[],eventCount:0,wsState:"disconnected",wsPacketCount:0,wsStatsCount:0,restStatsCount:0,restPacketsCount:0,workers:{topology:{...z},sparkline:{...z},decryption:{...z}},wsMergeCount:0,lastHydrateTs:null,hydrateCount:0,disambigCount:0,lastDisambigMs:null,_pushBatch:s=>t(r=>{if(s.length===0)return r;let c=[...r.events,...s];c.length>ve&&(c=c.slice(c.length-ve));const a={events:c,eventCount:r.eventCount+s.length};for(const n of s)as(n,a,r);return a}),clear:()=>t({events:[],eventCount:0,wsState:"disconnected",wsPacketCount:0,wsStatsCount:0,restStatsCount:0,restPacketsCount:0,workers:{topology:{...z},sparkline:{...z},decryption:{...z}},wsMergeCount:0,lastHydrateTs:null,hydrateCount:0,disambigCount:0,lastDisambigMs:null})}));let W=null,B=[],X=null;function ls(){if(X=null,B.length===0)return;const t=B;B=[],te.getState()._pushBatch(t)}function os(){W||(B=[],W=at.subscribe(t=>{B.push(t),X===null&&(X=requestAnimationFrame(ls))}))}function cs(){if(W==null||W(),W=null,X!==null&&(cancelAnimationFrame(X),X=null),B.length>0){const t=B;B=[],te.getState()._pushBatch(t)}}function is(t){switch(t){case"active":return"●";case"skipped":return"○";case"inferred":return"◌"}}function ds(t){switch(t){case"active":return"text-sys-green";case"skipped":return"text-fg-muted/30";case"inferred":return"text-sys-amber"}}function us(t){switch(t){case"transport":return"text-sys-blue";case"store":return"text-sys-amber";case"worker":return"text-sys-violet";case"pipeline":return"text-sys-green";case"consumer":return"text-sys-teal"}}function ps(t,s,r,c,a){var m,g;const n=[];if(a?n.push({label:"Hex Input",detail:"Manual hex — no transport",status:"skipped",lane:"transport"}):s.age==="live"||s.age==="recent"?n.push({label:"WebSocket",detail:"ws:packet → real-time push",status:"active",lane:"transport"}):n.push({label:"REST Poll",detail:"fetchPackets → packetCache.poll()",status:"inferred",lane:"transport"}),!a){n.push({label:"Cache Merge",detail:"packetCache.mergePacketsDirectly()",status:"active",lane:"store"});const u=s.age==="live"||s.age==="recent";n.push({label:"Flash",detail:u?"flashReceived++ → sidebar blink":"Not newest — no flash",status:u?"active":"skipped",lane:"store"}),n.push({label:"Hydrate Cascade",detail:"hydrateDownstream() → schedule workers",status:"active",lane:"store"})}const l=s.pathAvail||s.pathHopCount>0;n.push({label:"Topology Worker",detail:l?`Path data (${s.pathHopCount} hops) → edge extraction`:"No path data — still included in batch recompute",status:"active",lane:"worker"}),n.push({label:"Sparkline Worker",detail:`Contributes to sparkline for src ${((m=t.src_hash)==null?void 0:m.slice(0,4))??"??"}`,status:"active",lane:"worker"});const o=s.isGrp;n.push({label:"Decryption Worker",detail:o?`GRP_TXT → queued for channel key search${c?" → decrypted ✓":""}`:`${s.payloadTypeName} — not encrypted, skipped`,status:o?"active":"skipped",lane:"worker"}),n.push({label:"Source Disambiguation",detail:r?`→ ${r.name??((g=r.hash)==null?void 0:g.slice(0,8))??"?"} (${r.type}${r.confident?", confident":", ambiguous"})`:"Pending recompute",status:r?"active":"inferred",lane:"pipeline"}),s.isAdvert&&n.push({label:"ADVERT Discovery",detail:"pubkey → extended hash-to-type + name extraction",status:"active",lane:"pipeline"}),o&&(c!=null&&c.decoded)&&n.push({label:"Decoded Content Policy",detail:`macCorrupted=${c.decoded.macCorrupted?"true":"false"} → cross-hash inheritance`,status:"active",lane:"pipeline"});const x=["Packets","Dashboard","Statistics"];return l&&x.push("Map","Graph"),s.isTrace&&x.push("Trace Detail"),n.push({label:"Page Hydration",detail:x.join(", "),status:"active",lane:"consumer"}),n}const xs=[],hs=["transport","store","worker","pipeline","consumer"],ms={transport:"Transport",store:"Store",worker:"Workers",pipeline:"Pipeline",consumer:"Consumers"};function gs(t){return t.replace("transport:","").replace("store:packets:","").replace("cascade:","").replace("worker:","w:").replace("pipeline:","p:").replace("packet","pkt").replace("sparkline","spark").replace("topology","topo").replace("decryption","dec").replace("disambig","dis").replace("recompute","recomp")}function fs(t){return t.startsWith("transport:")?"text-sys-blue":t.startsWith("store:")||t.startsWith("cascade:")?"text-sys-amber":t.startsWith("worker:")?"text-sys-violet":t.startsWith("pipeline:")?"text-sys-green":"text-fg-muted"}const bs=T.memo(function({event:s}){const r=`${(s.ts/1e3).toFixed(1)}s`,c=s.data?Object.entries(s.data).map(([a,n])=>{var l;return`${a}=${typeof n=="number"?((l=n.toFixed)==null?void 0:l.call(n,1))??n:n}`}).join(" "):"";return e.jsxs("div",{className:"flex gap-2 text-[9px] font-mono leading-tight",children:[e.jsx("span",{className:"text-fg-muted/40 w-12 shrink-0 text-right",children:r}),e.jsx("span",{className:`w-20 shrink-0 ${fs(s.type)}`,children:gs(s.type)}),e.jsx("span",{className:"text-fg-muted/60 truncate",children:c})]})});function ys({packet:t,pipeline:s,resolved:r,decrypted:c,isSynthetic:a,liveMode:n}){const[l,o]=T.useState(!1);T.useEffect(()=>{if(l)return os(),()=>{cs()}},[l]);const x=s==null?void 0:s.analysis,m=T.useMemo(()=>!t||!x?null:ps(t,x,r,c,a),[t,x,r,c,a]),g=T.useMemo(()=>{if(!m)return null;const h=new Map;for(const y of m){let p=h.get(y.lane);p||(p=[],h.set(y.lane,p)),p.push(y)}return h},[m]),u=te(h=>l?h.events:xs),v=te(h=>l?h.eventCount:0),N=te(h=>h.clear),f=T.useRef(null);T.useEffect(()=>{l&&f.current&&(f.current.scrollTop=f.current.scrollHeight)},[v,l]);const k=(m==null?void 0:m.filter(h=>h.status==="active").length)??0,$=(m==null?void 0:m.length)??0;return e.jsxs(G,{defaultOpen:!0,children:[e.jsx(K,{className:"text-[10px]",children:e.jsxs("span",{className:"flex items-center gap-2 font-mono",children:[e.jsx("span",{className:"text-sys-green",children:"CFT"}),e.jsx("span",{className:"text-fg-muted/40",children:"Control Flow Trace"}),t&&e.jsxs("span",{className:"text-fg-muted/30",children:["— ",k,"/",$," stages active"]})]})}),e.jsx(V,{children:e.jsxs("div",{className:"surface-base rounded-lg border border-edge-subtle p-3 space-y-3",children:[t?g?e.jsx("div",{className:"space-y-2",children:hs.map(h=>{const y=g.get(h);return y?e.jsxs("div",{children:[e.jsx("div",{className:`text-[8px] uppercase tracking-widest font-mono mb-0.5 ${us(h)}`,children:ms[h]}),y.map((p,_)=>e.jsxs("div",{className:"flex items-start gap-1.5 text-[10px] font-mono leading-snug ml-1",children:[e.jsx("span",{className:`shrink-0 ${ds(p.status)}`,children:is(p.status)}),e.jsx("span",{className:"text-fg-primary",children:p.label}),e.jsx("span",{className:"text-fg-muted/50 truncate",children:p.detail})]},_))]},h):null})}):null:e.jsx("div",{className:"text-[9px] text-fg-muted/30 font-mono py-2 text-center",children:"Select a packet to trace its flow"}),e.jsxs("div",{className:"border-t border-edge-subtle pt-2 flex items-center gap-2",children:[e.jsx("button",{onClick:()=>o(h=>!h),className:`px-2 py-0.5 rounded text-[9px] font-mono transition-colors ${l?"bg-sys-green/20 text-sys-green":"bg-zinc-500/20 text-fg-muted hover:text-fg-primary"}`,children:l?"● LIVE":"○ LIVE"}),e.jsx("span",{className:"text-[9px] text-fg-muted/40 font-mono",children:l?`${v} events`:"Subscribe to all pipeline events"}),l&&e.jsx("button",{onClick:N,className:"text-[9px] text-fg-muted/40 hover:text-fg-muted font-mono transition-colors ml-auto",children:"clear"})]}),l&&e.jsx("div",{ref:f,className:"max-h-32 overflow-y-auto space-y-px",children:u.length===0?e.jsx("div",{className:"text-[9px] text-fg-muted/30 font-mono py-1 text-center",children:"Waiting for events…"}):u.map((h,y)=>e.jsx(bs,{event:h},`${h.ts}-${y}`))})]})})]})}function js(t){const s=Ne(t.type??t.payload_type??-1).padEnd(7),r=t.packet_hash.slice(0,8),c=(t.src_hash??"—").replace(/^0x/i,"").slice(0,4).toUpperCase(),a=t._hopCount!=null?`${t._hopCount}h`:"",n=dt(t.timestamp);return`${r} ${s} ←${c} ${t.rssi}dBm ${a} ${n}`}function Ts(){const t=lt(),s=ot(),r=ct(),c=(s==null?void 0:s.neighbors)??{},a=Y(b=>b.resolveSource),n=Y(b=>b.config),l=Y(b=>b.setConfig),[o,x]=T.useState(-1),m=T.useMemo(()=>{let b=t;return o!==-1&&(b=t.filter(w=>(w.type??w.payload_type)===o)),b.slice(-50).reverse()},[t,o]),[g,u]=T.useState(""),[v,N]=T.useState(""),[f,k]=T.useState(!1),$=T.useRef(r);T.useEffect(()=>{f&&r!==$.current&&m.length>0&&(u(m[0].packet_hash),N("")),$.current=r},[r,f,m]),T.useEffect(()=>{!g&&m.length>0&&!v&&u(m[0].packet_hash)},[g,m,v]);const h=T.useMemo(()=>v.trim()?null:m.find(b=>b.packet_hash===g)??null,[g,m,v]),y=T.useMemo(()=>{const b=v.replace(/\s+/g,"").trim();return b?{packet_hash:"manual-hex-input",timestamp:0,rssi:0,snr:0,transmitted:!1,drop_reason:null,is_duplicate:!1,raw_packet:b}:null},[v]),p=h??y,_=!!v.trim(),H=v.trim().replace(/\s+/g,"")||(p==null?void 0:p.raw_packet),C=wt(p,H,t),D=(C==null?void 0:C.enrichment)??He,L=Ce((p==null?void 0:p.packet_hash)??""),P=T.useRef(0),R=T.useMemo(()=>{if(!p)return null;const b=performance.now(),w=a(p);return P.current=performance.now()-b,w},[p,a]);return e.jsxs("div",{className:"max-w-[960px] mx-auto",children:[e.jsxs("div",{className:"mb-3",children:[e.jsx("h1",{className:"text-sm font-bold text-fg-primary tracking-wide font-mono",children:"PACKET OBSERVATORY"}),e.jsx("p",{className:"text-[11px] text-fg-muted font-mono",children:"Pipeline introspection — select a packet to trace its journey"})]}),e.jsxs("div",{className:"surface-base rounded-lg border border-edge-subtle p-3 mb-3",children:[e.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[e.jsxs("select",{value:o,onChange:b=>{x(Number(b.target.value)),u("")},className:"surface-input px-2 py-1 rounded text-[11px] font-mono text-fg-primary w-36",children:[e.jsx("option",{value:-1,children:"ALL TYPES"}),Object.entries(it).map(([b,w])=>e.jsxs("option",{value:Number(b),children:["0x",Number(b).toString(16).toUpperCase().padStart(2,"0")," ",w]},b))]}),e.jsxs("select",{value:g,onChange:b=>{u(b.target.value),N("")},className:"surface-input flex-1 min-w-0 px-2 py-1 rounded text-[11px] font-mono text-fg-primary truncate",children:[m.map((b,w)=>e.jsx("option",{value:b.packet_hash,children:js(b)},`${b.packet_hash}-${w}`)),m.length===0&&e.jsxs("option",{value:"",children:["No packets",o!==-1?" matching filter":" loaded"]})]}),e.jsx("button",{onClick:()=>k(b=>!b),className:`px-2 py-1 rounded text-[11px] font-mono transition-colors shrink-0 ${f?"bg-sys-green/20 text-sys-green":"bg-zinc-500/20 text-fg-muted hover:text-fg-primary"}`,children:f?"● LIVE":"○ LIVE"})]}),e.jsxs(G,{children:[e.jsx(K,{className:"text-[10px] text-fg-muted/50 hover:text-fg-muted mt-1.5",children:e.jsx("span",{className:"font-mono",children:"Paste hex…"})}),e.jsx(V,{children:e.jsx("textarea",{value:v,onChange:b=>N(b.target.value),placeholder:"Paste raw packet hex (overrides dropdown)",rows:2,className:"surface-input w-full mt-1 px-2 py-1 rounded text-[11px] font-mono text-fg-primary resize-y"})})]})]}),e.jsxs(G,{children:[e.jsx(K,{className:"text-[11px] mb-3 w-full",children:e.jsxs("span",{className:"flex items-center gap-2 font-mono",children:[e.jsx("span",{className:"text-fg-muted/50",children:"⚙"}),e.jsx("span",{className:"text-fg-muted/50",children:"Pipeline Config & Dev Tools"}),e.jsxs("span",{className:"text-fg-muted/30 text-[10px]",children:["disambig=",n.disambiguationEnabled?"on":"off"," mac=",n.macCorruptedPolicy," decay=",n.recencyDecayHours,"h"]})]})}),e.jsx(V,{children:e.jsxs("div",{className:"space-y-3 mb-4",children:[e.jsxs("div",{className:"surface-base rounded-lg border border-edge-subtle p-3",children:[e.jsx("h2",{className:"text-[10px] text-fg-muted/50 uppercase tracking-widest font-mono mb-2",children:"Pipeline Config"}),e.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("label",{className:"text-[11px] text-fg-muted w-24 shrink-0",children:"Disambiguation"}),e.jsx("button",{onClick:()=>l({disambiguationEnabled:!n.disambiguationEnabled}),className:`px-2 py-0.5 rounded text-[11px] font-mono transition-colors ${n.disambiguationEnabled?"bg-sys-green/20 text-sys-green":"bg-sys-red/20 text-sys-red"}`,children:n.disambiguationEnabled?"● ON":"○ OFF"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("label",{className:"text-[11px] text-fg-muted w-24 shrink-0",children:"MAC policy"}),e.jsxs("select",{value:n.macCorruptedPolicy,onChange:b=>l({macCorruptedPolicy:b.target.value}),className:"surface-input px-1.5 py-0.5 rounded text-[11px] font-mono text-fg-primary",children:[e.jsx("option",{value:"strict",children:"strict (drop)"}),e.jsx("option",{value:"name-only",children:"name-only"}),e.jsx("option",{value:"permissive",children:"permissive"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("label",{className:"text-[11px] text-fg-muted w-24 shrink-0",children:"Recency decay"}),e.jsx("input",{type:"range",min:1,max:48,step:1,value:n.recencyDecayHours,onChange:b=>l({recencyDecayHours:Number(b.target.value)}),className:"flex-1 h-1 accent-sys-blue"}),e.jsxs("span",{className:"text-[11px] font-mono text-fg-primary w-8 text-right",children:[n.recencyDecayHours,"h"]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("label",{className:"text-[11px] text-fg-muted w-24 shrink-0",children:"Zero-hop decay"}),e.jsx("input",{type:"range",min:12,max:168,step:6,value:n.zeroHopDecayHours,onChange:b=>l({zeroHopDecayHours:Number(b.target.value)}),className:"flex-1 h-1 accent-sys-blue"}),e.jsxs("span",{className:"text-[11px] font-mono text-fg-primary w-10 text-right",children:[n.zeroHopDecayHours,"h"]})]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[e.jsx(ys,{packet:p,pipeline:C,resolved:R,decrypted:L??null,isSynthetic:_,liveMode:f}),e.jsx(rs,{})]})]})})]}),p?e.jsxs("div",{className:"space-y-1",children:[e.jsx(kt,{packet:p,isSynthetic:_}),e.jsx(Rt,{packet:p,pipeline:C,rawHex:H,traceTagIndex:(C==null?void 0:C.traceTagIndex)??new Map,neighbors:c}),e.jsx(zt,{packet:p,decrypted:L??void 0,pipeline:C}),e.jsx(Kt,{packet:p,pipeline:C,resolved:R,decrypted:L??void 0,resolveTimeMs:P.current,neighbors:c,advertName:D.advertName})]}):e.jsx("div",{className:"surface-base rounded-lg border border-edge-subtle p-8 text-center",children:e.jsx("p",{className:"text-fg-muted text-xs",children:"Select a packet from the dropdown or paste hex above"})})]})}export{Ts as default}; diff --git a/frontend/dist/assets/PacketObservatory-DaStIp3L.js b/frontend/dist/assets/PacketObservatory-DaStIp3L.js deleted file mode 100644 index 95af15dc..00000000 --- a/frontend/dist/assets/PacketObservatory-DaStIp3L.js +++ /dev/null @@ -1,5 +0,0 @@ -const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/usePipelineStore-BEu0jDzA.js","assets/index-C1ZF7cAz.js","assets/node-types-BJeLdOcD.js","assets/index-DWhIzXT2.css"])))=>i.map(i=>d[i]); -import{bK as O,r as T,e4 as Fe,e5 as Ee,e6 as Oe,e7 as ze,bl as Be,e8 as Ie,e9 as Ge,ea as Ke,eb as Ve,bk as Ne,bo as ue,ec as qe,ed as we,bq as pe,j as e,ee as G,ef as K,eg as V,dE as xe,eh as Ue,q as M,bw as We,bH as Ce,bQ as Ye,ei as Ze,ej as Xe,ek as Qe,el as Je,em as et,en as J,eo as tt,ep as st,eq as nt,er as he,a3 as me,$ as Se,bh as rt,es as at,y as lt,E as ot,et as ct,b9 as it,c_ as dt}from"./index-C1ZF7cAz.js";import{usePipelineStore as Y}from"./usePipelineStore-BEu0jDzA.js";import{e as Te,p as ut,a as pt,A as I,S as q,c as se,f as E,K as i,H as A,B as xt,R as F,T as d,P as re,h as ht,i as S,C as _e,s as ee,j as mt}from"./primitives-DyUGjsV_.js";import{m as ke,i as gt}from"./node-types-BJeLdOcD.js";import"./payload-decoders-CmuRVuC0.js";function ft(t){const s=t.type??t.payload_type,r=t.duplicates??[],c=t.is_duplicate,a=r.length;let n=null,l=null;if(a>0){const x=[t.rssi,...r.map(g=>g.rssi).filter(g=>g!=null)],m=[t.snr,...r.map(g=>g.snr).filter(g=>g!=null)];x.length>1&&(n=[Math.min(...x),Math.max(...x)]),m.length>1&&(l=[Math.min(...m),Math.max(...m)])}const o=s===O.TRACE;return{isDuplicate:c,dupeCount:a,rssiRange:n,snrRange:l,hashIncludesPathLen:o}}function bt(t,s,r){const c={traceTag:null,siblingCount:0,isLocallyOriginated:!1,method:"none",confidence:"none",inferredSrc:null,inferredName:null,evidence:[],thisPathLen:0,minPathLen:0,firstHopPrefix:null};let a=t._traceTag;if(!a&&t.payload&&(a=Te(t.payload)),!a)return{...c,evidence:["no traceTag — cannot correlate"]};const n=s.get(a)??[],l=N=>N.path_length!=null?N.path_length:Array.isArray(N.original_path)?N.original_path.length:0,o=l(t),x=n.length>0?Math.min(...n.map(l)):o,m=t.payload?t.payload.slice(18):"",g=m.length>=2?m.slice(0,2).toUpperCase():null,u=[];if(u.push(`traceTag: ${a}`),u.push(`siblings: ${n.length} observation${n.length!==1?"s":""}`),t.packet_origin==="tx_local")return u.push("packet_origin = tx_local → we initiated this trace"),{traceTag:a,siblingCount:n.length,isLocallyOriginated:!0,method:"tx_local",confidence:"certain",inferredSrc:"LOCAL",inferredName:null,evidence:u,thisPathLen:o,minPathLen:x,firstHopPrefix:g};const v=n.find(N=>N.packet_origin==="tx_local");if(v)return u.push(`sibling (hash ${v.packet_hash}) has packet_origin = tx_local`),{traceTag:a,siblingCount:n.length,isLocallyOriginated:!0,method:"tx_local",confidence:"certain",inferredSrc:"LOCAL",inferredName:null,evidence:u,thisPathLen:o,minPathLen:x,firstHopPrefix:g};if(u.push(`this observation: path_len=${o}, min across siblings: ${x}`),g){if(u.push(`first hop in target path: ${g}`),o===0)return u.push("path_len = 0 → heard directly from initiator (no SNR appended yet)"),u.push("initiator is a direct RF neighbor"),{traceTag:a,siblingCount:n.length,isLocallyOriginated:!1,method:"min_path_len",confidence:"speculative",inferredSrc:null,inferredName:null,evidence:[...u,"initiator is within direct RF range (zero forwarding hops)"],thisPathLen:o,minPathLen:x,firstHopPrefix:g};const f=Object.entries(r).filter(([k])=>k.replace(/^0x/i,"").slice(0,2).toUpperCase()===g);if(f.length===1){const[k,$]=f[0],h=$.name||$.node_name||null;return u.push(`first hop ${g} → unique neighbor: ${h??k}`),u.push("initiator is whoever sent TO this first hop"),{traceTag:a,siblingCount:n.length,isLocallyOriginated:!1,method:"first_hop_neighbor",confidence:"likely",inferredSrc:g,inferredName:h,evidence:u,thisPathLen:o,minPathLen:x,firstHopPrefix:g}}else f.length>1?u.push(`first hop ${g} matches ${f.length} neighbors (ambiguous)`):u.push(`first hop ${g} is not a known neighbor`)}return u.push("insufficient data to identify initiator"),{traceTag:a,siblingCount:n.length,isLocallyOriginated:!1,method:"none",confidence:"none",inferredSrc:null,inferredName:null,evidence:u,thisPathLen:o,minPathLen:x,firstHopPrefix:g}}let ne=null,ce=null;typeof window<"u"&&setTimeout(()=>{ue(()=>import("./usePipelineStore-BEu0jDzA.js"),__vite__mapDeps([0,1,2,3])).then(t=>{ne=t}),ue(()=>import("./index-C1ZF7cAz.js").then(t=>t.g1),__vite__mapDeps([1,3])).then(t=>{ce=t})},0);const He={advertSender:null,advertNodeType:null,advertFlags:null,advertHasLocation:null,advertHasName:null,advertName:null,advertLatitude:null,advertLongitude:null,channelHash:null,byteLength:void 0,hopCount:0,isZeroHop:!0,preComputed:!1};function yt(t,s){const r=t.type??t.payload_type,c=Ne(r),a=Be(t.route),n=r===O.ADVERT,l=r===O.TRACE,o=r===O.PATH,x=r===O.GRP_TXT||r===O.GRP_DATA,m=Ie(t.snr,t.rssi),g=(m==null?void 0:m.finalGrade)??"critical",u=Ge(t.route),v=Ke(t.route),N=Ve(t.route),f=t.route==null?"unknown":u?"flood":v?"direct":"unknown",k=N?`transport-${f}`:f,$=!!s.advertSender;let h="none";$?h="pubkey":x?h="encrypted":t.src_hash&&(h="prefix");const y=gt(r),p=s.advertNodeType!=null?ke(s.advertNodeType):"unknown",_=y!=="unknown"?y:p,H=t.packet_origin??"rx",C=Math.floor(Date.now()/1e3)-t.timestamp,D=C<10?"live":C<300?"recent":C<3600?"warm":C<86400?"stale":"historic",L=t.path_length??(Array.isArray(t.original_path)?t.original_path.length:void 0),P=Array.isArray(t.original_path)&&t.original_path.length>0,R=L??0,b=s.byteLength??(t.raw_packet?Math.floor(t.raw_packet.length/2):0),w=ft(t);return{pType:r,payloadTypeName:c,routeTypeName:a,isAdvert:n,isTrace:l,isPath:o,isGrp:x,signalClass:g,routeClass:k,isFlood:u,isDirect:v,hasTransport:N,senderTier:h,hasPubkey:$,inferredType:y,advertType:p,effectiveType:_,origin:H,age:D,pathLen:L,pathAvail:P,pathHopCount:R,byteLen:b,dupeAnalysis:w}}function jt(t){var f,k,$,h,y,p;const s=pt(t);if(!s||s.pathHashes.length===0)return null;const{pathHashes:r,snrValues:c}=s;if(r.length<2||!ne||!ce)return null;const a=ne.usePipelineStore.getState().srcHashResolverMap,n=ne.usePipelineStore.getState().neighborContext,l=(n==null?void 0:n.hashToName)??new Map,o=ce.useStore.getState().stats,x=(o==null?void 0:o.neighbors)??{},m=o==null?void 0:o.local_hash,g=(k=(f=o==null?void 0:o.config)==null?void 0:f.repeater)==null?void 0:k.latitude,u=(h=($=o==null?void 0:o.config)==null?void 0:$.repeater)==null?void 0:h.longitude,v=Object.keys(x).length>0?qe([],x,m,g,u):null,N=[];for(let _=0;_0?[r[_-1].toUpperCase()]:[]],P=ge(H,_,L,a,v),R=[H,..._+20?N:null}function ge(t,s,r,c,a){if(s===0){const l=c==null?void 0:c.get(t);if(l)return{hash:l,confidence:.8};if(a){const o=pe(a,t,{position:s,adjacentPrefixes:r});if(o.hash)return{hash:o.hash,confidence:o.confidence}}}else{if(a){const o=pe(a,t,{position:s,adjacentPrefixes:r});if(o.hash)return{hash:o.hash,confidence:o.confidence}}const l=c==null?void 0:c.get(t);if(l)return{hash:l,confidence:.6}}return{hash:null,confidence:0}}function vt(t){var l;const s=t.raw_packet;if(!s||s.length<2)return null;const r=s.replace(/\s/g,""),c=Math.floor(r.length/2),a=((l=r.match(/.{1,2}/g))==null?void 0:l.join(" "))??"";let n="";for(let o=0;o=32&&x<=126?String.fromCharCode(x):"·"}return{hexBytes:a,utf8:n,byteCount:c}}function Nt(t){const s=new Map;let r=0,c="";for(const a of t){if((a.type??a.payload_type)!==O.TRACE)continue;r++,c=a.packet_hash;const l=a._traceTag??(a.payload?Te(a.payload):null);if(!l)continue;let o=s.get(l);o||(o=[],s.set(l,o)),o.push(a)}return{index:s,fingerprint:`${r}:${c}`}}function wt(t,s,r){const c=T.useRef({parse:0,decode:0,enrich:0,traceIndex:0,total:0}),a=T.useMemo(()=>t?vt(t):null,[t]),n=T.useMemo(()=>{if(!s||s.length<4)return c.current.parse=0,c.current.decode=0,null;const h=performance.now(),y=ut(s),p=performance.now()-h;return y?(c.current.parse=p,c.current.decode=0,{protocolPacket:y.packet,display:{headerFields:y.headerFields,transportCodesHex:y.transportCodesHex,pathLengthHex:y.pathLengthHex,pathDataHex:y.pathDataHex,payloadHex:y.payloadHex,payloadByteOffset:y.payloadStartByte,pathByteOffset:y.pathByteOffset,pathLenByteOffset:y.pathLenByteOffset},decoded:y.decoded,error:null}):(c.current.parse=p,c.current.decode=0,{protocolPacket:null,display:null,decoded:null,error:"Packet.fromHex() returned failure"})},[s]),l=T.useMemo(()=>{if(!t)return c.current.enrich=0,He;const h=performance.now();if(t._advertSender!==void 0)return c.current.enrich=performance.now()-h,{advertSender:t._advertSender??null,advertNodeType:t._advertNodeType??null,advertFlags:t._advertFlags??null,advertHasLocation:t._advertHasLocation??null,advertHasName:t._advertHasName??null,advertName:t._advertName??null,advertLatitude:t._advertLatitude??null,advertLongitude:t._advertLongitude??null,channelHash:t._channelHash??null,byteLength:t._byteLength,hopCount:t._hopCount??0,isZeroHop:t._isZeroHop??!0,preComputed:!0};const y=t.type??t.payload_type,p=Fe(s,y),_=Ee(s,y),H=Oe(s,t),C=ze(t);return c.current.enrich=performance.now()-h,{...p,channelHash:_,byteLength:H,...C,preComputed:!1}},[t,s]),o=T.useRef({fingerprint:"",index:new Map}),x=T.useMemo(()=>{const h=performance.now(),{index:y,fingerprint:p}=Nt(r);return c.current.traceIndex=performance.now()-h,p===o.current.fingerprint?o.current.index:(o.current={fingerprint:p,index:y},y)},[r]),m=T.useMemo(()=>{const h=c.current;return{parse:h.parse,decode:h.decode,enrich:h.enrich,traceIndex:h.traceIndex,total:h.parse+h.decode+h.enrich+h.traceIndex}},[n,l,x]);if(!t)return null;const g=s?n?n.error:"rawHex too short":"No raw_packet (warm-tier)",u=(n==null?void 0:n.protocolPacket)??null,v=u?u.payloadVersion:null,N=v===0,f=v===1,k=yt(t,l);let $=null;return k.isTrace&&($=jt(t)),{wire:a,display:(n==null?void 0:n.display)??null,parseError:g,protocolPacket:u,decoded:(n==null?void 0:n.decoded)??null,payloadVersion:v,isV1:N,isV2:f,enrichment:l,traceTagIndex:x,analysis:k,traceHopDetail:$,timing:m}}function ae({options:t,nextFn:s}){var n;const r=t.find(l=>l.active),c=(r==null?void 0:r.color)??"green",a=((n=I[c])==null?void 0:n.stem)??"bg-edge-subtle";return e.jsxs("div",{className:"flex flex-col items-start py-1 gap-0 px-2",children:[e.jsx("div",{className:`w-px h-2 ml-4 ${a}`}),e.jsxs("div",{className:"border border-dashed border-edge-subtle rounded-md overflow-hidden w-full",children:[t.map((l,o)=>{const x=I[l.color??"green"]??I.green;return e.jsxs("div",{className:`flex items-center gap-1.5 px-2 py-px font-mono text-[10px] leading-relaxed transition-opacity ${l.active?x.row:"opacity-25"}`,children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${l.active?x.dot:"border border-zinc-500/40"}`}),e.jsx("span",{className:`w-16 shrink-0 font-medium ${l.active?"text-fg-primary":"text-fg-muted"}`,children:l.label}),l.detail&&e.jsx("span",{className:l.active?"text-fg-primary/70":"text-fg-muted",children:l.detail})]},o)}),s&&e.jsx("div",{className:"flex items-center px-2 py-0.5 border-t border-edge-subtle",children:e.jsxs("span",{className:"text-[10px] text-fg-muted font-mono",children:["→ ",s]})})]}),e.jsx("div",{className:`w-px h-2 ml-4 ${a}`})]})}function Ct({tokens:t,nextFn:s}){var n;const r=t.find(l=>l.active),c=(r==null?void 0:r.color)??"green",a=((n=I[c])==null?void 0:n.stem)??"bg-edge-subtle";return e.jsxs("div",{className:"flex flex-col items-start py-1 gap-0 px-2",children:[e.jsx("div",{className:`w-px h-2 ml-4 ${a}`}),e.jsxs("div",{className:"border border-dashed border-edge-subtle rounded-md overflow-hidden w-full",children:[t.map((l,o)=>{const x=I[l.color??"green"]??I.green;return e.jsxs("div",{className:`flex items-center gap-1 px-2 py-px font-mono text-[10px] leading-relaxed transition-opacity ${l.active?x.row:"opacity-25"}`,children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${l.active?x.dot:"border border-zinc-500/40"}`}),e.jsx("span",{className:"text-fg-muted shrink-0",children:l.fn}),e.jsxs("span",{className:l.active?"text-fg-primary":"text-fg-muted",children:["(",l.value??"",")"]})]},o)}),s&&e.jsx("div",{className:"flex items-center px-2 py-0.5 border-t border-edge-subtle",children:e.jsxs("span",{className:"text-[10px] text-fg-muted font-mono",children:["→ ",s]})})]}),e.jsx("div",{className:`w-px h-2 ml-4 ${a}`})]})}const St={0:"border-l-sys-green",1:"border-l-sys-blue",2:"border-l-sys-teal",3:"border-l-sys-purple"};function le({stage:t,name:s,fn:r,verdict:c,timeMs:a,skipped:n,skipReason:l,children:o}){const x=St[t]??"";return e.jsx(e.Fragment,{children:e.jsx(G,{defaultOpen:!n,children:e.jsxs("div",{className:`surface-base rounded-lg border border-edge-subtle overflow-hidden border-l-2 ${x}`,children:[e.jsxs(K,{className:"px-3 py-2 w-full",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("span",{className:"font-mono text-xs font-bold text-sys-blue shrink-0",children:t}),e.jsx("span",{className:"font-mono text-xs font-medium text-fg-primary truncate",children:s}),r&&!c&&e.jsx("span",{className:"font-mono text-[11px] text-fg-muted truncate hidden sm:inline",children:r}),c&&e.jsx("span",{className:"font-mono text-[11px] text-fg-muted/70 truncate hidden sm:inline",children:c})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[n&&e.jsx("span",{className:"font-mono text-[10px] px-1.5 py-0.5 rounded bg-zinc-500/20 text-fg-muted",children:"N/A"}),a!=null&&!n&&e.jsx("span",{className:"font-mono text-[10px] px-1.5 py-0.5 rounded bg-sys-green/15 text-sys-green",children:a<1?`${(a*1e3).toFixed(0)}µs`:`${a.toFixed(2)}ms`})]})]}),e.jsx(V,{children:e.jsx("div",{className:"px-3 pb-3 font-mono text-xs",children:n?e.jsx("p",{className:"text-fg-muted italic",children:l??"Not applicable for this packet type"}):o})})]})})})}function Tt(t,s){return s?"manual":t._stripped?"bulk-tier":Ue.isConnected()?"ws-push":"rest-poll"}const _t={connected:"green",degraded:"amber",offline:"red"};function kt({packet:t,isSynthetic:s}){const r=xe(g=>g.wsState),c=xe(g=>g.health),a=Tt(t,s),l=!!t._stripped?"WARM":"HOT",o=[{label:"ws-push",detail:"wsConnected && onPacket()",active:a==="ws-push",color:"green"},{label:"rest-poll",detail:"!wsConnected, 3s interval",active:a==="rest-poll",color:"amber"},{label:"catchup",detail:"wsReconnected, delta > 50",active:a==="catchup",color:"amber"},{label:"bulk-tier",detail:"user extends time range → gzip",active:a==="bulk-tier",color:"blue"},{label:"manual",detail:"hex input — no transport",active:a==="manual",color:"zinc"}],x=[{fn:"transport",value:a,group:"transport",color:a==="ws-push"?"green":a==="bulk-tier"?"blue":"amber"},{fn:"tier",value:l,group:"transport",color:"blue"},{fn:"wsState",value:r,group:"transport",color:r==="connected"?"green":"amber"},{fn:"health",value:c,group:"transport",color:_t[c]}],m=s?"manual hex input":`${a} (${c})`;return e.jsx(le,{stage:0,name:"TRANSPORT",fn:"websocketService / useStore.startPolling",verdict:m,children:s?e.jsx("p",{className:"text-fg-muted italic",children:"Manual hex input — no transport context"}):e.jsx(q,{prefix:"transport",children:e.jsxs("div",{className:"space-y-0",children:[e.jsx(ae,{options:o,nextFn:"ingest()"}),e.jsx(se,{tokens:x})]})})})}function U({start:t,end:s}){const r=s!=null&&s!==t?`[${t}..${s}]`:`[${t}]`;return e.jsx("span",{className:"text-fg-muted text-[9px] font-mono mr-1 select-none",children:r})}const Ht={advert:"decodeAdvert()",ack:"decodeAck()",path:"decodePath()",trace:"decodeTraceWithSnr()",txt_msg:"decodeTextMessage()",grp_txt:"decodeGroupText()",grp_data:"decodeGroupData()",multipart:"decodeMultipart()",control:"decodeControl()",req:"decodeRequest()",response:"decodeResponse()",anon_req:"decodeAnonReq()",generic:"decodeGeneric()"};function $t({rawHex:t,display:s,protocolPacket:r,parseError:c,parseTimeMs:a,payloadVersion:n,isV1:l,isV2:o}){return e.jsx("dl",{className:"space-y-0.5",children:s&&r&&t?e.jsxs(e.Fragment,{children:[e.jsx(E,{title:"A. Parse — Packet.fromHex()"}),a>0&&e.jsx("div",{className:"flex justify-end",children:e.jsx("span",{className:"font-mono text-[10px] px-1.5 py-0.5 rounded bg-sys-green/15 text-sys-green",children:a<1?`${(a*1e3).toFixed(0)}µs`:`${a.toFixed(2)}ms`})}),e.jsxs(i,{label:"header byte",children:[e.jsx(U,{start:0}),e.jsx(A,{value:t.slice(0,2)})," ",e.jsx(xt,{value:parseInt(t.slice(0,2),16)})]}),s.headerFields.map(x=>e.jsx(i,{label:` ${x.field}`,children:e.jsx(F,{raw:e.jsxs("span",{className:"text-[10px]",children:["bits[",x.bits,"] = ",x.binary]}),children:e.jsx("span",{className:"inline-block border border-edge-subtle rounded px-2 py-0.5 font-mono text-[11px] text-sys-amber",children:x.value})})},x.field)),e.jsx(i,{label:" version",children:n!=null?e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx(d,{fn:"payloadVer",value:`${n}`,color:"amber"}),e.jsx(M,{color:l?"green":o?"blue":"zinc",children:l?"v1":o?"v2":`v${n}`}),l&&e.jsx("span",{className:"text-fg-muted text-[10px]",children:"1-byte hashes, 2-byte MAC"}),o&&e.jsx("span",{className:"text-sys-blue text-[10px]",children:"2-byte hashes, 4-byte MAC (speculative)"})]}):e.jsx("span",{className:"text-fg-muted",children:"unknown"})}),e.jsx(E,{title:"Wire Framing"}),e.jsx(i,{label:"transportCodes",children:s.transportCodesHex?e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(U,{start:1,end:4}),e.jsx(d,{fn:"transport",value:s.transportCodesHex,color:"amber"})]}):e.jsx("span",{className:"text-fg-muted",children:"N/A (non-transport route)"})}),e.jsx(i,{label:"pathLen",children:e.jsx(F,{raw:e.jsxs(e.Fragment,{children:[e.jsx(U,{start:s.pathLenByteOffset}),e.jsx(A,{value:s.pathLengthHex})]}),children:e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(U,{start:s.pathLenByteOffset}),e.jsx(d,{fn:"pathLen",value:`${r.pathLen} hop${r.pathLen!==1?"s":""}`,color:"amber"})]})})}),e.jsx(i,{label:"path",children:e.jsxs("span",{className:"inline-flex items-center gap-1",children:[r.pathLen>0&&e.jsx(U,{start:s.pathByteOffset,end:s.pathByteOffset+r.pathLen-1}),e.jsx(re,{hops:r.pathHexArray,hexPrefix:s.pathDataHex||void 0})]})}),e.jsx(i,{label:"payloadLen",children:e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(U,{start:s.payloadByteOffset,end:s.payloadByteOffset+s.payloadHex.length/2-1}),e.jsx(d,{fn:"payloadLen",value:`${s.payloadHex.length/2} bytes`,color:"amber"})]})}),e.jsx(i,{label:"payloadHex",children:e.jsx("span",{className:"inline-block border border-edge-subtle rounded px-2 py-0.5 font-mono text-[11px] text-sys-amber break-all",children:s.payloadHex})})]}):e.jsxs(e.Fragment,{children:[e.jsx(E,{title:"A. Parse"}),e.jsxs(i,{label:"result",children:[e.jsx("span",{className:"inline-block border border-edge-subtle rounded px-2 py-0.5 font-mono text-[11px] text-sys-amber",children:"Skipped"}),e.jsx("span",{className:"ml-1 text-fg-muted",children:c??"No raw_packet (warm-tier)"})]})]})})}function Dt({decoded:t,packet:s}){if(!t)return e.jsxs(e.Fragment,{children:[e.jsx(E,{title:"B. Decode"}),e.jsx("p",{className:"text-fg-muted italic text-[10px]",children:"No decoded payload"})]});const r=Ht[t.type]??`decode${t.type}()`;return e.jsxs(e.Fragment,{children:[e.jsx(E,{title:"B. Decode — decodePayload()"}),e.jsx(q,{prefix:"decodePayload",children:e.jsxs("dl",{className:"space-y-0.5",children:[e.jsx(i,{label:"dispatched",children:r}),e.jsx(E,{}),e.jsx(Lt,{decoded:t,packet:s})]})})]})}function Lt({decoded:t,packet:s}){var r;switch(t.type){case"advert":return e.jsxs(e.Fragment,{children:[e.jsx(i,{label:"publicKey",children:e.jsx(F,{raw:e.jsx("span",{className:"text-[10px] break-all",children:t.publicKey}),children:e.jsx(d,{fn:"publicKey",value:t.publicKey,color:"green"})})}),e.jsx(i,{label:"timestamp",children:e.jsx(d,{fn:"timestamp",value:String(t.timestamp),color:"green"})}),e.jsx(i,{label:"flags",children:e.jsx(F,{raw:e.jsx(A,{value:t.flags}),children:e.jsx(d,{fn:"flags",value:t.flagsDescription,color:"green"})})}),e.jsx(i,{label:"nodeType",children:e.jsx(d,{fn:"nodeType",value:t.nodeType,color:"green"})}),t.latitude!=null&&e.jsx(i,{label:"latitude",children:e.jsx(d,{fn:"lat",value:t.latitude.toFixed(6),color:"green"})}),t.longitude!=null&&e.jsx(i,{label:"longitude",children:e.jsx(d,{fn:"lon",value:t.longitude.toFixed(6),color:"green"})}),t.name&&e.jsx(i,{label:"name",children:e.jsx(d,{fn:"name",value:t.name,color:"green"})})]});case"ack":return e.jsx(i,{label:"crc",children:e.jsx(F,{raw:e.jsx("span",{className:"text-[10px]",children:t.crc}),children:e.jsx(d,{fn:"crc",value:t.crc,color:"green"})})});case"trace":{const c=s!=null&&s.src_hash?s.src_hash.replace(/^0x/i,"").slice(0,2).toUpperCase():null;return e.jsxs(e.Fragment,{children:[e.jsx(i,{label:"traceTag",children:e.jsx(d,{fn:"traceTag",value:t.traceTag,color:"green"})}),e.jsx(i,{label:"authCode",children:e.jsx(d,{fn:"authCode",value:String(t.authCode),color:"green"})}),e.jsx(i,{label:"flags",children:e.jsx(A,{value:t.flags})}),e.jsx(i,{label:"target path",children:t.pathHashes.length>0?e.jsx(re,{hops:t.pathHashes.map(a=>a.toUpperCase()),color:"green"}):e.jsx("span",{className:"text-fg-muted italic",children:"∅ empty"})}),e.jsx(i,{label:"complete",children:t.isComplete?e.jsxs("span",{className:"text-sys-green",children:["✓ all ",t.pathHashes.length," hops reported SNR"]}):e.jsxs("span",{className:"text-sys-amber",children:["✗ ",t.snrValues.length,"/",t.pathHashes.length," hops reported"]})}),e.jsx(E,{}),e.jsxs("div",{children:[e.jsx("p",{className:"text-fg-muted mb-1 text-[10px]",children:"Directional Edge SNR — per-hop link quality"}),t.snrValues.length===0?e.jsx("p",{className:"text-fg-muted italic text-[11px] ml-2",children:"No SNR values in path field"}):e.jsx("div",{className:"space-y-0.5 ml-2",children:t.snrValues.map((a,n)=>{var g,u,v,N,f;const l=((g=t.pathHashes[n])==null?void 0:g.toUpperCase())??"??",o=n===0?c??"SRC":((u=t.pathHashes[n-1])==null?void 0:u.toUpperCase())??"??",x=(f=(N=(v=Ye.getState().stats)==null?void 0:v.config)==null?void 0:N.radio)==null?void 0:f.spreading_factor,m=we(a,x);return e.jsxs("div",{className:"flex items-center gap-1.5 text-[11px] font-mono",children:[e.jsx("span",{className:"text-fg-muted w-3 text-right",children:n}),e.jsx("span",{className:"text-fg-primary",children:o}),e.jsx("span",{className:"text-fg-muted",children:"→"}),e.jsx("span",{className:"text-fg-primary",children:l}),e.jsx("span",{className:"text-fg-muted",children:"@"}),e.jsxs("span",{className:"font-bold text-sys-green",children:[a>0?"+":"",a.toFixed(1)," dB"]}),e.jsx(M,{color:"green",children:m})]},n)})})]})]})}case"path":return e.jsxs(e.Fragment,{children:[e.jsx(i,{label:"pathLength",children:e.jsx(d,{fn:"pathLength",value:String(t.pathLength),color:"green"})}),e.jsx(i,{label:"path",children:t.path&&t.path.length>0?e.jsx(re,{hops:t.path.map(c=>c.toUpperCase()),color:"green"}):e.jsx("span",{className:"text-fg-muted italic",children:"∅ empty"})}),t.extraType!=null&&e.jsx(i,{label:"extraType",children:e.jsx(d,{fn:"extraType",value:t.extraTypeName??String(t.extraType),color:"purple"})}),t.extraData&&e.jsxs(i,{label:"extraData",children:[e.jsx("span",{className:"break-all text-[10px] font-mono",children:t.extraData}),e.jsxs("span",{className:"text-fg-muted ml-1",children:["(",t.extraData.length/2,"B)"]})]})]});case"txt_msg":return e.jsxs(e.Fragment,{children:[e.jsx(i,{label:"destHash",children:e.jsx(F,{raw:e.jsx(A,{value:t.destHash}),children:e.jsx(d,{fn:"destHash",value:t.destHash,color:"green"})})}),e.jsx(i,{label:"srcHash",children:e.jsx(F,{raw:e.jsx(A,{value:t.srcHash}),children:e.jsx(d,{fn:"srcHash",value:t.srcHash,color:"green"})})}),e.jsx(i,{label:"cipherMac",children:e.jsx(d,{fn:"cipherMac",value:t.cipherMac,color:"purple"})}),e.jsx(i,{label:"timestamp",children:e.jsx(d,{fn:"timestamp",value:String(t.timestamp),color:"green"})}),e.jsx(i,{label:"text",children:e.jsx(d,{fn:"text",value:t.text,color:"green"})}),e.jsx(i,{label:"encrypted",children:e.jsx(d,{fn:"encrypted",value:String(t.encrypted),color:"green"})})]});case"grp_txt":return e.jsxs(e.Fragment,{children:[e.jsx(i,{label:"channelHash",children:e.jsx(A,{value:t.channelHash})}),t.channelName&&e.jsx(i,{label:"channelName",children:e.jsx(d,{fn:"channel",value:t.channelName,color:"green"})}),e.jsx(i,{label:"decrypted",children:e.jsx(d,{fn:"decrypted",value:String(t.decrypted),color:"green"})}),t.text&&e.jsx(i,{label:"text",children:e.jsx(d,{fn:"text",value:t.text,color:"green"})}),t.senderName&&e.jsx(i,{label:"senderName",children:e.jsx(d,{fn:"sender",value:t.senderName,color:"green"})}),t.macCorrupted&&e.jsx(i,{label:"macCorrupted",children:e.jsx(d,{fn:"macCorrupted",value:"true",color:"green"})})]});case"grp_data":return e.jsxs(e.Fragment,{children:[e.jsx(i,{label:"channelHash",children:e.jsx(A,{value:t.channelHash})}),e.jsx(i,{label:"dataLength",children:t.dataLength}),e.jsx(i,{label:"decrypted",children:String(t.decrypted)})]});case"multipart":return e.jsxs(e.Fragment,{children:[e.jsx(i,{label:"messageId",children:t.messageId}),e.jsxs(i,{label:"part",children:[t.partNumber+1," / ",t.totalParts]})]});case"control":return e.jsxs(e.Fragment,{children:[e.jsx(i,{label:"controlType",children:e.jsx(F,{raw:e.jsx(A,{value:t.controlType}),children:e.jsx(d,{fn:"controlType",value:t.subtypeName,color:"green"})})}),e.jsx(i,{label:"subtype",children:e.jsx(d,{fn:"subtype",value:`0x${t.subtype.toString(16).padStart(2,"0")}`,color:"green"})}),t.nodeTypeName&&e.jsxs(i,{label:"nodeType",children:[e.jsx(d,{fn:"nodeType",value:t.nodeTypeName,color:"green"}),e.jsxs("span",{className:"text-fg-muted text-[10px] ml-1",children:["(flags & 0x0F = 0x",(r=t.nodeType)==null?void 0:r.toString(16).padStart(2,"0"),")"]})]}),t.snrDb!=null&&e.jsxs(i,{label:"snr",children:[e.jsxs("span",{className:"font-bold text-sys-green",children:[t.snrDb>0?"+":"",t.snrDb.toFixed(1)," dB"]}),e.jsx(M,{color:"green",children:t.snrDb>=5?"strong":t.snrDb>=0?"fair":"weak"})]}),t.tag&&e.jsx(i,{label:"tag",children:e.jsx(d,{fn:"tag",value:t.tag,color:"green"})}),t.publicKey&&e.jsxs(i,{label:"publicKey",children:[e.jsx("span",{className:"break-all text-[10px] font-mono text-sys-green",children:t.publicKey}),e.jsx(M,{color:t.publicKeyFull?"green":"amber",children:t.publicKeyFull?"32B full":`${t.publicKey.length/2}B prefix`})]}),t.typeFilter!=null&&e.jsx(i,{label:"typeFilter",children:e.jsx(F,{raw:e.jsx(A,{value:t.typeFilter}),children:e.jsx(d,{fn:"typeFilter",value:t.typeFilterDescription??"none",color:"green"})})}),t.prefixOnly!=null&&e.jsx(i,{label:"prefixOnly",children:e.jsx(d,{fn:"prefixOnly",value:String(t.prefixOnly),color:"green"})}),t.since!=null&&e.jsx(i,{label:"since",children:e.jsx(d,{fn:"since",value:t.since===0?"all (0)":String(t.since),color:"green"})}),!t.nodeTypeName&&t.typeFilter==null&&t.dataLength>0&&e.jsxs(i,{label:"data",children:[e.jsx("span",{className:"break-all text-[10px] font-mono",children:t.dataHex}),e.jsxs("span",{className:"text-fg-muted ml-1",children:["(",t.dataLength,"B)"]})]})]});case"req":return e.jsxs(e.Fragment,{children:[e.jsx(i,{label:"destHash",children:e.jsx(F,{raw:e.jsx(A,{value:t.destHash}),children:e.jsx(d,{fn:"destHash",value:t.destHash,color:"green"})})}),e.jsx(i,{label:"srcHash",children:e.jsx(F,{raw:e.jsx(A,{value:t.srcHash}),children:e.jsx(d,{fn:"srcHash",value:t.srcHash,color:"green"})})}),e.jsx(i,{label:"cipherMac",children:e.jsx(d,{fn:"cipherMac",value:t.cipherMac,color:"purple"})}),e.jsxs(i,{label:"ciphertext",children:[e.jsx("span",{className:"break-all text-[10px] font-mono",children:t.ciphertextHex}),e.jsxs("span",{className:"text-fg-muted ml-1",children:["(",t.ciphertextLength,"B)"]})]})]});case"response":return e.jsxs(e.Fragment,{children:[e.jsx(i,{label:"destHash",children:e.jsx(F,{raw:e.jsx(A,{value:t.destHash}),children:e.jsx(d,{fn:"destHash",value:t.destHash,color:"green"})})}),e.jsx(i,{label:"srcHash",children:e.jsx(F,{raw:e.jsx(A,{value:t.srcHash}),children:e.jsx(d,{fn:"srcHash",value:t.srcHash,color:"green"})})}),e.jsx(i,{label:"cipherMac",children:e.jsx(d,{fn:"cipherMac",value:t.cipherMac,color:"purple"})}),e.jsxs(i,{label:"ciphertext",children:[e.jsx("span",{className:"break-all text-[10px] font-mono",children:t.ciphertextHex}),e.jsxs("span",{className:"text-fg-muted ml-1",children:["(",t.ciphertextLength,"B)"]})]})]});case"anon_req":return e.jsxs(e.Fragment,{children:[e.jsx(i,{label:"destHash",children:e.jsx(F,{raw:e.jsx(A,{value:t.destHash}),children:e.jsx(d,{fn:"destHash",value:t.destHash,color:"green"})})}),e.jsx(i,{label:"senderPubKey",children:e.jsx("span",{className:"break-all text-[10px] font-mono text-sys-green",children:t.senderPublicKey})}),e.jsx(i,{label:"cipherMac",children:e.jsx(d,{fn:"cipherMac",value:t.cipherMac,color:"purple"})}),e.jsxs(i,{label:"ciphertext",children:[e.jsx("span",{className:"break-all text-[10px] font-mono",children:t.ciphertextHex}),e.jsxs("span",{className:"text-fg-muted ml-1",children:["(",t.ciphertextLength,"B)"]})]})]});case"generic":return e.jsxs(e.Fragment,{children:[e.jsxs(i,{label:"payloadType",children:[e.jsx(ht,{value:t.payloadType})," (",t.payloadTypeName,")"]}),e.jsx(i,{label:"length",children:t.length}),e.jsx(i,{label:"rawHex",children:e.jsx("span",{className:"break-all",children:t.rawHex})})]});default:return e.jsx("p",{className:"text-fg-muted",children:"Unknown decoded type"})}}function Pt({protocolPacket:t,packetHash:s}){const r=t==null?void 0:t.payloadType,c=r===Ze||r===Xe,a=T.useMemo(()=>{if(!c||!t)return null;const p=t.payload;return p.length<4?null:{channelHash:p[0],mac:p.slice(1,3),ciphertext:p.slice(3)}},[t,c]),[n,l]=T.useState("pending"),[o,x]=T.useState([]),[m,g]=T.useState(0);T.useEffect(()=>{if(!a){l(null);return}let p=!1;return(async()=>{const H=performance.now(),C=await Qe(a.channelHash,a.mac,a.ciphertext);p||(l(C),g(performance.now()-H));const D=await Je(a.channelHash);p||x(D)})(),()=>{p=!0}},[a]);const[u,v]=T.useState(""),[N,f]=T.useState(null),[k,$]=T.useState(!1),h=T.useCallback(async()=>{if(!(!a||!u.trim())){$(!0);try{const p=await We(u.trim(),a.channelHash,a.mac,a.ciphertext);if(p.success){const _=new TextDecoder("utf-8",{fatal:!1}).decode(p.result.plaintext.slice(5));f({success:!0,text:_})}else f({success:!1,error:p.error})}catch(p){f({success:!1,error:String(p)})}finally{$(!1)}}},[a,u]),y=Ce(s);return!c||!a?null:e.jsxs(e.Fragment,{children:[e.jsx(E,{title:"C. Decrypt — tryDecryptGroupMessage()"}),m>0&&e.jsx("div",{className:"flex justify-end",children:e.jsx("span",{className:"font-mono text-[10px] px-1.5 py-0.5 rounded bg-sys-green/15 text-sys-green",children:m<1?`${(m*1e3).toFixed(0)}µs`:`${m.toFixed(2)}ms`})}),e.jsx(q,{prefix:"tryDecryptGroupMessage",children:e.jsxs("dl",{className:"space-y-0.5",children:[e.jsx(i,{label:"channelHash",children:e.jsx(d,{fn:"channelHash",value:`0x${a.channelHash.toString(16).toUpperCase().padStart(2,"0")}`,color:"teal"})}),e.jsx(i,{label:"mac",children:e.jsx(d,{fn:"mac",value:Array.from(a.mac).map(p=>p.toString(16).padStart(2,"0")).join(""),color:"teal"})}),e.jsx(i,{label:"cipherLen",children:e.jsx(d,{fn:"cipherLen",value:`${a.ciphertext.length}B`,color:"teal"})}),e.jsx(i,{label:"candidates",children:e.jsx(d,{fn:"candidates",value:o.length>0?`${o.length} names`:"0",color:o.length>0?"teal":"zinc"})}),o.length>0&&e.jsxs("details",{className:"mt-1",children:[e.jsx("summary",{className:"text-fg-muted cursor-pointer hover:text-fg-primary text-[10px]",children:"show candidate names"}),e.jsx("div",{className:"mt-1 text-[10px] text-fg-muted break-all max-h-24 overflow-y-auto",children:o.join(", ")})]}),e.jsx(E,{}),e.jsxs("div",{children:[e.jsx("p",{className:"text-fg-muted mb-1",children:"Result:"}),n==="pending"?e.jsx("p",{className:"text-fg-muted italic",children:"decrypting…"}):n?e.jsxs(e.Fragment,{children:[e.jsx(i,{label:"channel",children:e.jsx(d,{fn:"channel",value:n.channelName,color:"teal"})}),e.jsx(i,{label:"plaintext",children:e.jsx(d,{fn:"plaintext",value:new TextDecoder("utf-8",{fatal:!1}).decode(n.plaintext.slice(5)).trim()||"(empty)",color:"teal"})}),e.jsx(i,{label:"macValid",children:e.jsx(d,{fn:"macValid",value:n.macCorrupted?"false":"true",color:"teal"})})]}):e.jsxs(i,{label:"decrypt",children:[e.jsx(d,{fn:"decrypt",value:"failed",color:"red"}),e.jsx("span",{className:"text-fg-muted ml-1",children:"channel not in known list"})]})]}),e.jsx(E,{}),e.jsxs("div",{children:[e.jsx("p",{className:"text-fg-muted mb-1",children:"testChannelName() — manual test:"}),e.jsxs("div",{className:"flex gap-1.5 items-center",children:[e.jsx("input",{type:"text",value:u,onChange:p=>{v(p.target.value),f(null)},onKeyDown:p=>p.key==="Enter"&&h(),placeholder:"channel name",className:"surface-input px-2 py-1 rounded text-[11px] font-mono text-fg-primary w-40"}),e.jsx("button",{onClick:h,disabled:k||!u.trim(),className:"px-2 py-1 rounded text-[10px] font-mono bg-sys-blue/20 text-sys-blue hover:bg-sys-blue/30 disabled:opacity-40 transition-colors",children:k?"…":"Try"})]}),N&&e.jsx("div",{className:"mt-1",children:N.success?e.jsx(i,{label:"result",children:e.jsx(d,{fn:"plaintext",value:N.text??"(empty)",color:"teal"})}):e.jsx(i,{label:"error",children:e.jsx(d,{fn:"error",value:N.error??"unknown",color:"red"})})})]}),e.jsx(E,{}),e.jsxs("div",{children:[e.jsx("p",{className:"text-fg-muted mb-1",children:"useDecodedMessage() store result:"}),y?y.decoded?e.jsxs(e.Fragment,{children:[e.jsx(i,{label:"channel",children:e.jsx(d,{fn:"channel",value:y.decoded.channelName??"?",color:"teal"})}),e.jsx(i,{label:"text",children:e.jsx(d,{fn:"text",value:y.decoded.text,color:"teal"})})]}):e.jsx(i,{label:"decrypt",children:e.jsx(d,{fn:"decrypt",value:"failed",color:"red"})}):e.jsx(i,{label:"decrypt",children:e.jsx(d,{fn:"decrypt",value:"pending",color:"zinc"})})]})]})})]})}function Mt(t){const{rawHex:s,display:r,protocolPacket:c,decoded:a,parseError:n,parseTimeMs:l,payloadVersion:o,isV1:x,isV2:m,packetHash:g,packet:u}=t,v=!!s&&s.length>=4;return e.jsxs(G,{children:[e.jsx(K,{className:"w-full mt-2 mb-1",children:e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("span",{className:"text-[10px] font-mono text-fg-muted",children:"🔬"}),e.jsx("span",{className:"text-[10px] font-mono font-medium text-fg-muted",children:"Wire Inspection"}),e.jsx("span",{className:"text-[9px] text-fg-muted/50",children:"observatory diagnostic — not a runtime stage"})]})}),e.jsx(V,{children:e.jsxs("div",{className:"border border-dashed border-edge-subtle rounded-lg p-3 space-y-1 bg-surface/30",children:[e.jsx("p",{className:"text-[9px] text-fg-muted/50 mb-2",children:"The backend parsed these fields server-side. This panel verifies the wire-level encoding client-side."}),v?e.jsxs(e.Fragment,{children:[e.jsx($t,{rawHex:s,display:r,protocolPacket:c,parseError:n,parseTimeMs:l,payloadVersion:o,isV1:x,isV2:m}),e.jsx(Dt,{decoded:a,packet:u}),e.jsx(Pt,{protocolPacket:c,packetHash:g})]}):e.jsx("p",{className:"text-fg-muted italic text-[10px]",children:n??"No raw_packet — wire inspection unavailable (warm-tier packet)"})]})})]})}function fe(t){if(!t)return[{fn:"decode",value:"no raw_packet",group:"decode",color:"zinc"}];switch(t.type){case"advert":{const s=t,r=[{fn:"decode.nodeType",value:s.nodeType,group:"decode",color:"blue"}];return s.name&&r.push({fn:"decode.name",value:s.name,group:"decode",color:"blue"}),s.latitude!=null&&s.longitude!=null&&r.push({fn:"decode.location",value:`${s.latitude.toFixed(4)}, ${s.longitude.toFixed(4)}`,group:"decode",color:"blue"}),r.push({fn:"decode.publicKey",value:s.publicKey,group:"decode",color:"blue"}),r}case"trace":{const s=t;return[{fn:"decode.traceTag",value:s.traceTag,group:"decode",color:"blue"},{fn:"decode.hops",value:s.pathHashes.length>0?s.pathString:"empty",group:"decode",color:"blue"},{fn:"decode.snr",value:s.snrValues.length>0?`${s.snrValues.length} values`:"none",group:"decode",color:s.snrValues.length>0?"blue":"zinc"},{fn:"decode.complete",value:s.isComplete?"yes":"partial",group:"decode",color:s.isComplete?"green":"amber"}]}case"path":{const s=t,r=[{fn:"decode.pathLength",value:String(s.pathLength),group:"decode",color:"blue"},{fn:"decode.path",value:s.path.length>0?s.pathString:"empty",group:"decode",color:"blue"}];return s.extraType!=null&&r.push({fn:"decode.extraType",value:s.extraTypeName??String(s.extraType),group:"decode",color:"purple"}),s.extraData&&r.push({fn:"decode.extraData",value:`${s.extraData.length/2}B`,group:"decode",color:"purple"}),r}case"ack":return[{fn:"decode.crc",value:t.crc,group:"decode",color:"blue"}];case"grp_txt":return[{fn:"decode.channelHash",value:t.channelHash,group:"decode",color:"blue"},{fn:"decode.encrypted",value:"true — decrypt at cascade",group:"decode",color:"zinc"}];case"grp_data":{const s=t;return[{fn:"decode.channelHash",value:s.channelHash,group:"decode",color:"blue"},{fn:"decode.dataLength",value:`${s.dataLength}B`,group:"decode",color:"blue"}]}case"txt_msg":{const s=t;return[{fn:"decode.srcHash",value:s.srcHash,group:"decode",color:"blue"},{fn:"decode.destHash",value:s.destHash,group:"decode",color:"blue"},{fn:"decode.encrypted",value:s.encrypted?"true":"false",group:"decode",color:s.encrypted?"zinc":"green"},...s.encrypted?[]:[{fn:"decode.text",value:s.text,group:"decode",color:"blue"}]]}case"multipart":{const s=t;return[{fn:"decode.part",value:`${s.partNumber+1}/${s.totalParts}`,group:"decode",color:"blue"},{fn:"decode.msgId",value:s.messageId,group:"decode",color:"blue"}]}case"control":{const s=t,r=[{fn:"decode.subtype",value:s.subtypeName,group:"decode",color:"blue"}];return s.nodeTypeName&&r.push({fn:"decode.nodeType",value:s.nodeTypeName,group:"decode",color:"blue"}),s.snrDb!=null&&r.push({fn:"decode.snr",value:`${s.snrDb>0?"+":""}${s.snrDb.toFixed(1)} dB`,group:"decode",color:"blue"}),s.tag&&r.push({fn:"decode.tag",value:s.tag,group:"decode",color:"blue"}),s.publicKey&&r.push({fn:"decode.publicKey",value:s.publicKey,group:"decode",color:s.publicKeyFull?"green":"blue"}),s.typeFilter!=null&&r.push({fn:"decode.typeFilter",value:s.typeFilterDescription??`0x${s.typeFilter.toString(16)}`,group:"decode",color:"blue"}),s.prefixOnly!=null&&r.push({fn:"decode.prefixOnly",value:String(s.prefixOnly),group:"decode",color:"blue"}),!s.nodeTypeName&&!s.tag&&(r.push({fn:"decode.subtypeFlags",value:`0x${s.subtypeFlags.toString(16)}`,group:"decode",color:"blue"}),r.push({fn:"decode.dataLength",value:`${s.dataLength}B`,group:"decode",color:"blue"})),r}case"req":{const s=t;return[{fn:"decode.destHash",value:s.destHash,group:"decode",color:"blue"},{fn:"decode.srcHash",value:s.srcHash,group:"decode",color:"blue"},{fn:"decode.cipherMac",value:s.cipherMac,group:"decode",color:"purple"},{fn:"decode.ciphertext",value:`${s.ciphertextLength}B`,group:"decode",color:"zinc"}]}case"response":{const s=t;return[{fn:"decode.destHash",value:s.destHash,group:"decode",color:"blue"},{fn:"decode.srcHash",value:s.srcHash,group:"decode",color:"blue"},{fn:"decode.cipherMac",value:s.cipherMac,group:"decode",color:"purple"},{fn:"decode.ciphertext",value:`${s.ciphertextLength}B`,group:"decode",color:"zinc"}]}case"anon_req":{const s=t;return[{fn:"decode.destHash",value:s.destHash,group:"decode",color:"blue"},{fn:"decode.senderPubKey",value:s.senderPublicKey,group:"decode",color:"green"},{fn:"decode.cipherMac",value:s.cipherMac,group:"decode",color:"purple"},{fn:"decode.ciphertext",value:`${s.ciphertextLength}B`,group:"decode",color:"zinc"}]}case"generic":return[{fn:"decode.raw",value:`${t.length}B`,group:"decode",color:"zinc"}];default:return[]}}function Rt({packet:t,pipeline:s,rawHex:r,traceTagIndex:c,neighbors:a}){const{enrichment:n,timing:l,display:o,protocolPacket:x,decoded:m,parseError:g,payloadVersion:u,isV1:v,isV2:N,analysis:f}=s,$=(t.type??t.payload_type)===et,h=f.dupeAnalysis,y=T.useRef(0),p=T.useMemo(()=>{if(!$)return null;const D=performance.now(),L=bt(t,c,a);return y.current=performance.now()-D,L},[t,c,a,$]),_=l.enrich+y.current,H=[];f.byteLen&&H.push(`${f.byteLen}B`),H.push(f.payloadTypeName),n.advertName&&H.push(`"${n.advertName}"`),n.isZeroHop?H.push("zero-hop"):f.pathHopCount>0&&H.push(`${f.pathHopCount}h`),H.push(`${t.rssi}dBm`),h.isDuplicate&&H.push("DUPE");const C=H.join(" — ");return e.jsxs(le,{stage:1,name:"INGEST",fn:n.preComputed?"PacketCache.mergePackets()":"extractAdvertData() + extractHopData() + ...",verdict:C,timeMs:_,children:[e.jsx(Mt,{rawHex:r,display:o,protocolPacket:x,decoded:m,parseError:g,parseTimeMs:l.parse,payloadVersion:u,isV1:v,isV2:N,packetHash:t.packet_hash,packet:t}),e.jsx(E,{title:"Cache Enrichment"}),e.jsx(q,{prefix:"packetCache",children:e.jsxs("dl",{className:"space-y-0.5",children:[e.jsxs("div",{className:"mb-1.5",children:[n.preComputed?e.jsx(M,{color:"green",children:"PacketCache"}):e.jsx(M,{color:"amber",children:"computed"}),e.jsx("span",{className:"text-[10px] text-fg-muted ml-1.5",children:n.preComputed?"pre-enriched by real pipeline":"synthetic — computed on the fly"})]}),e.jsxs("div",{className:"flex flex-wrap gap-x-2 gap-y-1 mb-1",children:[e.jsx(d,{fn:"_byteLength",value:n.byteLength!=null?`${n.byteLength}B`:void 0,color:"blue"}),e.jsx(d,{fn:"_hopCount",value:String(n.hopCount),color:"blue"}),e.jsx(d,{fn:"_isZeroHop",value:String(n.isZeroHop),color:n.isZeroHop?"green":"blue"}),n.isZeroHop&&e.jsx(M,{color:"blue",children:"direct"}),n.channelHash!=null&&e.jsx(d,{fn:"_channelHash",value:n.channelHash,color:"blue"}),$&&t._traceTag&&e.jsx(d,{fn:"_traceTag",value:t._traceTag,color:"blue"})]}),n.advertSender||n.advertNodeType!=null||n.advertName!=null?e.jsxs("div",{className:"mt-1 mb-1",children:[e.jsx("p",{className:"text-[10px] text-sys-blue font-medium mb-0.5",children:"ADVERT Enrichment"}),e.jsxs("div",{className:"flex flex-wrap gap-x-2 gap-y-1",children:[n.advertSender&&e.jsx(d,{fn:"_advertSender",value:n.advertSender.slice(0,16)+"…",color:"blue"}),n.advertNodeType!=null&&e.jsx(d,{fn:"_advertNodeType",value:ke(n.advertNodeType),color:"blue"}),n.advertName!=null&&e.jsx(d,{fn:"_advertName",value:n.advertName,color:"blue"}),n.advertFlags!=null&&e.jsx(d,{fn:"_advertFlags",value:`0x${n.advertFlags.toString(16).padStart(2,"0")}`,color:"blue"}),n.advertHasLocation!=null&&e.jsx(d,{fn:"_advertHasLocation",value:String(n.advertHasLocation),color:"blue"}),n.advertHasName!=null&&e.jsx(d,{fn:"_advertHasName",value:String(n.advertHasName),color:"blue"}),n.advertLatitude!=null&&n.advertLongitude!=null&&e.jsx(d,{fn:"location",value:`${n.advertLatitude.toFixed(4)}, ${n.advertLongitude.toFixed(4)}`,color:"blue"})]})]}):e.jsx("p",{className:"text-[10px] text-fg-muted/30 mb-1",children:"ADVERT fields: N/A (non-ADVERT packet)"}),e.jsx(E,{title:"Payload Decode"}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-1",children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${m?"bg-sys-blue":"bg-zinc-500/40"}`}),e.jsx("span",{className:"font-mono text-[10px] font-medium text-fg-primary",children:"decodePayload()"}),e.jsx("span",{className:"text-[9px] text-fg-muted",children:"sync — wire data only, no crypto"})]}),e.jsx("div",{className:"ml-3",children:m?e.jsx("div",{className:"flex flex-wrap gap-x-1.5 gap-y-1",children:fe(m).map((D,L)=>e.jsx("span",{className:"inline-block border border-edge-subtle rounded px-1.5 py-0.5",children:e.jsx(d,{fn:D.fn,value:D.value,color:D.color})},L))}):e.jsx(S,{children:"no raw_packet — warm-tier packet, decode unavailable"})})]}),e.jsx(E,{}),e.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 text-[11px] font-mono",children:[e.jsx("span",{className:"text-fg-muted",children:"dupe:"}),h.isDuplicate?e.jsx(d,{fn:"is_duplicate",value:"true",color:"purple"}):e.jsx(S,{children:"none"}),h.dupeCount>0&&e.jsx(d,{fn:"dupeCount",value:`×${h.dupeCount}`,color:"purple"}),h.rssiRange&&e.jsxs(S,{c:"text-fg-primary",children:["Δ",Math.abs(h.rssiRange[1]-h.rssiRange[0]),"dB RSSI"]})]}),p&&e.jsxs(e.Fragment,{children:[e.jsx(E,{}),e.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 text-[11px] font-mono",children:[e.jsx("span",{className:"text-fg-muted",children:"TRACE SRC:"}),p.inferredSrc?e.jsxs(e.Fragment,{children:[e.jsx(d,{fn:"inferredSrc",value:p.inferredSrc,color:"purple"}),p.inferredName&&e.jsx(d,{fn:"name",value:p.inferredName,color:"purple"})]}):e.jsx(S,{children:"unresolvable"}),e.jsx(_e,{color:"purple",children:p.method}),e.jsxs(S,{children:["(",p.confidence,")"]}),e.jsxs(S,{children:["siblings=",p.siblingCount]})]})]}),(()=>{const D=f.pType!=null?`0x${f.pType.toString(16).toUpperCase().padStart(2,"0")}`:void 0,L=t.route!=null?`0x${t.route.toString(16).toUpperCase().padStart(2,"0")}`:void 0,P=fe(m),R=f.signalClass==="excellent"||f.signalClass==="good"?"green":f.signalClass==="fair"?"amber":"red",b=f.senderTier==="pubkey"?"green":f.senderTier==="prefix"?"amber":f.senderTier==="encrypted"?"teal":"zinc",w=[{fn:"type",value:f.payloadTypeName,raw:D,group:"wire",color:"blue"},{fn:"route",value:f.routeTypeName,raw:L,group:"wire",color:"blue"},{fn:"src_hash",value:t.src_hash||void 0,group:"wire",color:"blue"},{fn:"rssi",value:`${t.rssi}dBm`,group:"wire",color:"blue"},{fn:"snr",value:`${t.snr}dB`,group:"wire",color:"blue"},{fn:"_byteLength",value:f.byteLen?`${f.byteLen}B`:void 0,group:"enrichment",color:"blue"},{fn:"_hopCount",value:String(n.hopCount),group:"enrichment",color:"blue"},{fn:"_isZeroHop",value:String(n.isZeroHop),group:"enrichment",color:"blue"},{fn:"_advertSender",value:n.advertSender||void 0,group:"enrichment",color:"blue"},{fn:"_advertNodeType",value:f.advertType!=="unknown"?f.advertType:void 0,group:"enrichment",color:"blue"},{fn:"_advertName",value:n.advertName||void 0,group:"enrichment",color:"blue"},{fn:"_channelHash",value:n.channelHash||void 0,group:"enrichment",color:"blue"},...P,{fn:"is_duplicate",value:String(h.isDuplicate),group:"analysis",color:"purple"},p!=null&&p.inferredSrc?{fn:"traceSrc",value:p.inferredSrc,group:"analysis",color:"purple"}:{fn:"traceSrc"},{fn:"_signalClass",value:f.signalClass,group:"analysis",color:R},{fn:"_routeClass",value:f.routeClass,group:"analysis",color:"purple"},{fn:"_senderTier",value:f.senderTier,group:"analysis",color:b},{fn:"_origin",value:f.origin,group:"analysis",color:f.origin==="tx_local"?"green":f.origin==="tx_forward"?"amber":"purple"},{fn:"_pathAvail",value:f.pathAvail?`${f.pathHopCount} hops`:"none",group:"analysis",color:f.pathAvail?"green":"zinc"},{fn:"_age",value:f.age,group:"analysis",color:f.age==="live"||f.age==="recent"?"green":"zinc"},...h.dupeCount>0?[{fn:"_dupeCount",value:`×${h.dupeCount}`,group:"analysis",color:"purple"},...h.rssiRange?[{fn:"_multipath",value:`Δ${Math.abs(h.rssiRange[1]-h.rssiRange[0])}dB`,group:"analysis",color:Math.abs(h.rssiRange[1]-h.rssiRange[0])>6?"amber":"green"}]:[]]:[],...t.lbt_attempts!=null?[{fn:"_lbt",value:`${t.lbt_attempts} attempt${t.lbt_attempts!==1?"s":""}`,group:"analysis",color:(t.lbt_attempts??0)>1?"amber":"green"}]:[],...t.drop_reason?[{fn:"_dropReason",value:t.drop_reason,group:"analysis",color:"red"}]:[]];return e.jsx(se,{tokens:w})})()]})})]})}function be(t){switch(t){case"excellent":return"green";case"good":return"green";case"fair":return"amber";case"poor":return"red";case"critical":return"red";default:return"zinc"}}function ye(t){return`${Math.round(t*100)}%`}function je(t,s,r){return t||(s?s.slice(0,12):`~${r}`)}function At({hops:t}){return t.length===0?null:e.jsxs("div",{className:"mt-2 pt-2 border-t border-edge-subtle/40",children:[e.jsx("p",{className:"text-[9px] text-fg-muted/40 uppercase tracking-widest font-mono mb-1.5",children:"per-hop trace inspection"}),e.jsx("div",{className:"space-y-1",children:t.map(s=>e.jsx(q,{prefix:`trace.hop[${s.hopIndex}]`,children:e.jsxs("div",{className:"border border-edge-subtle/40 rounded px-2 py-1.5",children:[e.jsxs(i,{label:"link",children:[e.jsx(re,{hops:[s.fromPrefix,s.toPrefix],color:"blue"}),e.jsx("span",{className:"ml-1.5",children:e.jsx(_e,{color:be(s.quality),children:s.quality})})]}),e.jsx(i,{label:"snr",children:e.jsx(F,{raw:e.jsx("span",{className:"text-sys-blue",children:s.snrRaw}),children:e.jsx(d,{fn:"snr",value:`${s.snrRaw.toFixed(1)} dB`,color:be(s.quality)})})}),e.jsxs(i,{label:"from",children:[e.jsx(d,{fn:"resolve",value:je(s.fromName,s.fromHash,s.fromPrefix),color:s.fromHash?s.fromConfidence>=.8?"green":"amber":"purple"}),e.jsx("span",{className:"ml-1",children:e.jsx(d,{fn:"conf",value:ye(s.fromConfidence),color:"zinc"})})]}),e.jsxs(i,{label:"to",children:[e.jsx(d,{fn:"resolve",value:je(s.toName,s.toHash,s.toPrefix),color:s.toHash?s.toConfidence>=.8?"green":"amber":"purple"}),e.jsx("span",{className:"ml-1",children:e.jsx(d,{fn:"conf",value:ye(s.toConfidence),color:"zinc"})})]})]})},s.hopIndex))}),e.jsx(se,{label:"trace contributes",tokens:Ft(t)})]})}function Ft(t){const s=t.reduce((n,l)=>n+(l.fromHash?1:0)+(l.toHash?1:0),0),r=t.length*2,c=r-s,a=t.length>0?t.reduce((n,l)=>n+l.snrRaw,0)/t.length:0;return[{fn:"hops",value:String(t.length),group:"wire",color:"blue"},{fn:"resolved",value:`${s}/${r}`,group:"worker",color:"green"},...c>0?[{fn:"ghosts",value:String(c),group:"worker",color:"purple"}]:[],{fn:"avgSnr",value:`${a.toFixed(1)} dB`,group:"analysis",color:a>=5?"green":a>=0?"amber":"red"}]}function Et(t){if(!t)return"never";const s=Math.floor((Date.now()-t)/1e3);return s<60?`${s}s ago`:s<3600?`${Math.floor(s/60)}m ago`:`${Math.floor(s/3600)}h ago`}function Ot(t){if(!t)return[];const s=t.decoded;if(!s)return[{fn:"decrypt.result",value:"failed",group:"crypto",color:"red"}];if(!s.decrypted)return[{fn:"decrypt.result",value:"no key match",group:"crypto",color:"zinc"}];const r=[];return s.channelName&&r.push({fn:"decrypt.channelName",value:s.channelName,group:"crypto",color:"teal"}),s.senderName&&r.push({fn:"decrypt.senderName",value:s.senderName,group:"crypto",color:"teal"}),s.text&&r.push({fn:"decrypt.text",value:s.text,group:"crypto",color:"teal"}),s.timestamp&&r.push({fn:"decrypt.timestamp",value:new Date(s.timestamp*1e3).toISOString().slice(11,19),group:"crypto",color:"teal"}),s.macCorrupted&&r.push({fn:"decrypt.macCorrupted",value:"true",group:"crypto",color:"amber"}),r}function zt({packet:t,decrypted:s,pipeline:r}){var b;const c=J(w=>w.isComputing),a=J(w=>w.lastUpdated),n=J(w=>w.lastComputeTimeMs),l=J(w=>w.topology.edges.length),o=J(w=>w.topology.discoveredNodes.length),x=tt(),m=st(),g=nt(),u=he(w=>w.isComputing),v=he(w=>w.nodeCount),N=me(w=>w.progress),f=me(w=>w.initialDecodeComplete),k=t.type??t.payload_type,$=k===O.GRP_TXT||k===O.GRP_DATA,h=k===O.TRACE,y=k===O.PATH,p=$,_=[{label:"full",detail:"all GRP_TXT → decryption worker",active:p&&f,color:"teal"},{label:"quick",detail:"100 most recent (initial load)",active:p&&!f,color:"amber"},{label:"skip",detail:"non-GRP or catchup path",active:!p,color:"zinc"}],H=Ot(s),C=((b=s==null?void 0:s.decoded)==null?void 0:b.decrypted)===!0,D=c?"running":`${l}e ${o}g`,L=u?"running":`${v}n`,P=p?C?"decrypted":N.isDecoding?`${N.percent}%`:"pending":"N/A",R=`topo ${c?"○":"✓"} ${D} · spark ${u?"○":"✓"} ${L} · decrypt ${P}`;return e.jsx(le,{stage:2,name:"CASCADE",fn:"hydrateDownstream()",verdict:R,children:e.jsx(q,{prefix:"cascade",children:e.jsxs("div",{className:"space-y-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-1 py-1.5 text-[11px] font-mono",children:[e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${c?"bg-sys-amber animate-pulse":"bg-sys-green"}`}),e.jsx("span",{className:"text-fg-primary",children:"topology"}),e.jsxs("span",{className:"text-fg-muted",children:[l,"e ",o,"g"]}),(h||y)&&e.jsx("span",{className:"text-sys-green text-[9px]",children:"↑signal"})]}),e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${u?"bg-sys-amber animate-pulse":"bg-sys-green"}`}),e.jsx("span",{className:"text-fg-primary",children:"sparkline"}),e.jsxs("span",{className:"text-fg-muted",children:[v,"n"]})]}),e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${N.isDecoding?"bg-sys-amber animate-pulse":p?"bg-sys-teal":"bg-zinc-500/40"}`}),e.jsx("span",{className:"text-fg-primary",children:"decrypt"}),e.jsx("span",{className:p?"text-sys-teal":"text-fg-muted",children:p?C?"decrypted":N.isDecoding?`${N.percent}%`:"pending":"N/A"})]})]}),e.jsxs(G,{defaultOpen:h||y,children:[e.jsx(K,{className:"text-[10px] w-full border-t border-edge-subtle pt-1.5",children:e.jsx("span",{className:"font-mono text-fg-muted/50",children:"topology detail…"})}),e.jsx(V,{children:e.jsxs("div",{className:"ml-3 pb-2",children:[e.jsx(i,{label:"status",children:e.jsx(d,{fn:"isComputing",value:c?"running":"idle",color:c?"amber":"green"})}),e.jsxs(i,{label:"last",children:[e.jsx(d,{fn:"lastUpdated",value:Et(a),color:"zinc"}),n>0&&e.jsxs("span",{className:"ml-2 text-fg-muted text-[10px]",children:["(",n<1e3?`${n.toFixed(0)}ms`:`${(n/1e3).toFixed(1)}s`,")"]})]}),e.jsxs(i,{label:"output",children:[e.jsx(d,{fn:"edges",value:String(l),color:"green"}),e.jsx(d,{fn:"ghostNodes",value:String(o),color:"purple"})]}),m&&e.jsxs(e.Fragment,{children:[e.jsxs(i,{label:"trace links",children:[e.jsx(d,{fn:"directed",value:String(x.totalDirectedLinks),color:"teal"}),e.jsx(d,{fn:"bidir",value:String(x.bidirectionalLinks),color:"teal"}),e.jsx(d,{fn:"traces",value:String(x.totalTraces),color:"zinc"})]}),e.jsxs(i,{label:"trace SNR",children:[e.jsx(d,{fn:"mean",value:`${x.meanSnr.toFixed(1)} dB`,color:x.meanSnr>=5?"green":x.meanSnr>=0?"amber":"red"}),e.jsx(d,{fn:"median",value:`${x.medianSnr.toFixed(1)} dB`,color:"zinc"}),e.jsx(d,{fn:"confidence",value:`${Math.round(x.avgConfidence*100)}%`,color:"zinc"})]}),h&&e.jsxs(i,{label:"quality",children:[e.jsx(d,{fn:"excellent",value:String(x.qualityCounts.excellent),color:"green"}),e.jsx(d,{fn:"good",value:String(x.qualityCounts.good),color:"green"}),e.jsx(d,{fn:"fair",value:String(x.qualityCounts.fair),color:"amber"}),e.jsx(d,{fn:"poor",value:String(x.qualityCounts.poor),color:"red"}),e.jsx(d,{fn:"critical",value:String(x.qualityCounts.critical),color:"red"})]}),g.confirmedResolutions.size>0&&e.jsxs(i,{label:"feedback",children:[e.jsx(d,{fn:"feedback.confirmed",value:String(g.confirmedResolutions.size),color:"teal"}),e.jsx(d,{fn:"feedback.links",value:String(g.confirmedLinks.length),color:"teal"})]})]}),h&&(r==null?void 0:r.traceHopDetail)&&e.jsx(At,{hops:r.traceHopDetail})]})})]}),p&&e.jsx("div",{className:"border-t border-edge-subtle pt-2 pb-2",children:e.jsxs("div",{className:"ml-3",children:[e.jsx(i,{label:"mode",children:e.jsx(ae,{options:_,nextFn:"queueDecryption()"})}),e.jsx(i,{label:"result",children:e.jsx(d,{fn:"decrypt",value:C?"decrypted":s?"failed":"pending",color:C?"teal":s?"red":"zinc"})}),C&&e.jsx("div",{className:"mt-1 flex flex-wrap gap-x-1.5 gap-y-1",children:H.map((w,oe)=>e.jsx("span",{className:"inline-block border border-edge-subtle rounded px-1.5 py-0.5",children:e.jsx(d,{fn:w.fn,value:w.value,color:w.color})},oe))})]})}),(()=>{const w=[{fn:"topology.edges",value:String(l),group:"worker",color:"green"},{fn:"topology.ghostNodes",value:String(o),group:"worker",color:"purple"},{fn:"sparkline.nodes",value:`${v}`,group:"worker",color:"green"},...m?[{fn:"trace.directedLinks",value:String(x.totalDirectedLinks),group:"worker",color:"teal"},{fn:"trace.meanSnr",value:`${x.meanSnr.toFixed(1)} dB`,group:"worker",color:"teal"}]:[],...H];return e.jsx(se,{tokens:w})})()]})})})}function Bt(t,s,r,c){var n;const a=t.src_hash?Se(t.src_hash):"";if(t._advertSender&&s.hash&&s.confident)return{tier:1,label:"_advertSender → pubkey",detail:"ADVERT carried full 32-byte public key — definitive match"};if(c&&s.confident&&((n=s.name)==null?void 0:n.toLowerCase())===c.toLowerCase())return{tier:1.5,label:"decrypt.senderName → nameToHash",detail:`Decrypted sender name “${c}” matched neighbor — high-confidence`};if(a&&r.crossClassPrefixes.has(a))return{tier:2,label:"cross-class prefix",detail:"Prefix has mixed types (repeater + non-repeater); payload type narrows to one class"};if(s.confident){const l=r.prefixIndex.get(a);return(l==null?void 0:l.length)===1?{tier:3,label:"single candidate",detail:"Only one node matches this prefix — unambiguous"}:{tier:3,label:"resolver",detail:"Multi-signal scoring selected best candidate from collision set"}}return{tier:4,label:"ambiguous",detail:"Cannot confidently resolve — multiple same-class candidates, insufficient scoring separation"}}function It(t,s){const r=t.original_path??t.forwarded_path,c=new Set;if(r&&Array.isArray(r))for(const a of r){const n=String(a).toUpperCase().slice(0,2);n.length>=2&&n!==s&&c.add(n)}return c}function Gt(t,s,r,c,a,n,l){const o=Math.floor(Date.now()/1e3),x=new Map(r.map(m=>[m.hash,m]));return t.map(m=>{const g=s[m.hash],u=x.get(m.hash);let v=!0,N="";c!=="unknown"?m.type!=="unknown"&&m.type!==c?(v=!1,N=`${m.type} ≠ required ${c}`):m.type===c?N="type matches":N="type unknown — not ruled out":N="payload ambiguous — all types eligible";const f=!!(g!=null&&g.zero_hop),k=(g==null?void 0:g.last_seen)??0;let $=0;if(f&&k>0){const b=(o-k)/3600;$=50*Math.exp(-b/l)}let h=0;if(k>0){const b=(o-k)/3600;h=Math.exp(-b/n)}const y=h*20,p=!!(g!=null&&g.latitude&&(g!=null&&g.longitude)&&(g.latitude!==0||g.longitude!==0)),_=p?5:0,H=(u==null?void 0:u.advertCount)??0,C=Math.min(H*2,30),D=(u==null?void 0:u.forwarderPrefixes.size)??0,L=Math.min(D*3,15);let P=0;if(u&&u.totalForwarderObservations>0&&a.size>0){let b=0;for(const w of a)u.forwarderPrefixes.has(w)&&b++;P=b/a.size}const R=$+y+_+C+L;return{hash:m.hash,name:m.name,type:m.type,roleCompatible:v,roleReason:N,zeroHop:f,zeroHopScore:$,lastSeen:k,recencyScore:h,recencyPoints:y,hasGps:p,gpsScore:_,advertCount:H,advertScore:C,topoWidth:D,topoScore:L,affinity:P,total:R}}).sort((m,g)=>g.total-m.total)}function Kt({packet:t,pipeline:s,resolved:r,resolveTimeMs:c,advertName:a,neighbors:n,decrypted:l}){var ie,de;const o=Y(j=>j.neighborContext),x=Y(j=>j.topologyProfiles),m=Y(j=>j.config),{analysis:g}=s,u=r??{hash:null,type:"unknown",name:null,confident:!1},v=t.src_hash?Se(t.src_hash):"",N=v?o.prefixIndex.get(v)??[]:[],f=v?x.get(v)??[]:[],k=g.pType??-1,$=k>=0?k.toString(16).toUpperCase().padStart(2,"0"):"??",h=g.inferredType,y=g.advertType,p=g.effectiveType,_=t._advertNodeType!=null?t._advertNodeType.toString(16).padStart(2,"0").toUpperCase():"",H=((ie=l==null?void 0:l.decoded)==null?void 0:ie.senderName)??null,C=Bt(t,u,o,H),D=T.useMemo(()=>It(t,v),[t,v]),L=g.pathLen,P=T.useMemo(()=>Gt(N,n,f,p,D,m.recencyDecayHours,m.zeroHopDecayHours),[N,n,f,p,D,m.recencyDecayHours,m.zeroHopDecayHours]),R=P.filter(j=>!j.roleCompatible),b=P.filter(j=>j.roleCompatible),w=t._advertSender?o.pubKeyMap.get(t._advertSender)??null:null,oe=C.tier===1,De=[{fn:"src_hash",value:v||"",active:!!v,color:"blue"},{fn:"_advertSender",value:t._advertSender?t._advertSender.slice(0,12)+"…":"",active:!!t._advertSender,color:"blue"},{fn:"_advertNodeType",value:_?`0x${_}`:"",active:t._advertNodeType!=null,color:"blue"},{fn:"path_length",value:L!=null?L===0?"zero-hop":String(L):"",active:L!=null,color:"blue"},{fn:"decrypt.senderName",value:H??"",active:!!H,color:"teal"}],Le=[{label:"hit",detail:"pubKeyMap.get(_advertSender) → definitive",active:!!w,color:"green"},{label:"miss",detail:t._advertSender?"pubkey not in neighbor table":"no _advertSender",active:!w,color:"zinc"}],Pe=[{label:"payload",detail:`inferDeviceType(0x${$}) → ${h}`,active:h!=="unknown",color:"amber"},{label:"flags",detail:_?`mapAdvertTypeCode(0x${_}) → ${y}`:"no _advertNodeType",active:h==="unknown"&&y!=="unknown",color:"green"},{label:"ambiguous",detail:"all types eligible",active:p==="unknown",color:"zinc"}],Me=u.name??((de=u.hash)==null?void 0:de.slice(0,12))??"?",Re=u.confident?"confident":"ambiguous",Ae=`→ ${Me} (${Re}, Tier ${C.tier})`;return e.jsx(le,{stage:3,name:"RESOLVE",fn:"usePipelineStore.resolveSource()",verdict:Ae,timeMs:c,children:e.jsx(q,{prefix:"resolvePacketSource",children:e.jsxs("div",{className:"space-y-0",children:[e.jsx("div",{className:"pt-1 pb-1",children:e.jsx(Ct,{tokens:De,nextFn:"resolvePacketSource()"})}),t.src_hash?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"border-t border-edge-subtle pt-2 pb-2",children:[e.jsxs("p",{className:"text-fg-muted mb-1",children:[e.jsx(S,{c:"text-sys-blue font-bold",children:"1"})," ","PUBKEY LOOKUP"]}),e.jsx(ae,{options:Le,nextFn:"pubKeyMap.get()"}),e.jsx("div",{className:"ml-3 mt-1",children:w?e.jsxs(e.Fragment,{children:[e.jsx(i,{label:"resolved",children:e.jsx(d,{fn:"hash",value:w,color:"green"})}),a&&e.jsxs(i,{label:"name",children:[e.jsx(d,{fn:"name",value:a,color:"green"}),u.name&&a===u.name&&e.jsx(S,{c:"text-sys-green ml-1",children:"✓ neighbor match"})]}),e.jsxs(i,{label:"result",children:[e.jsx(M,{color:"green",children:"Tier 1"}),e.jsx(S,{c:"text-fg-primary ml-1",children:"definitive — scoring bypassed"})]})]}):t._advertSender?e.jsx(i,{label:"status",children:e.jsx(S,{c:"text-sys-amber",children:"✗ pubkey not in neighbor table"})}):e.jsx(i,{label:"status",children:e.jsx(S,{children:"no _advertSender — skip to prefix resolution"})})})]}),oe?e.jsx("div",{className:"border-t border-edge-subtle py-2",children:e.jsx("p",{className:"text-[11px] text-fg-muted/40 font-mono ml-3",children:"Steps 2–5 bypassed — pubkey definitive"})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"border-t border-edge-subtle pt-2 pb-2",children:[e.jsxs("p",{className:"text-fg-muted mb-1",children:[e.jsx(S,{c:"text-sys-blue font-bold",children:"2"})," ","CANDIDATE POOL — ",N.length," node",N.length!==1?"s":"",' match "',v,'"']}),e.jsxs("div",{className:"space-y-0.5 ml-3",children:[P.map(j=>e.jsxs("div",{className:"flex gap-2 items-center text-[11px]",children:[e.jsx("span",{className:"break-all text-[10px]",children:j.hash}),e.jsx(M,{color:"zinc",children:j.type||"unknown"}),j.name&&e.jsx(S,{children:j.name})]},j.hash)),N.length===0&&e.jsx(S,{children:"no known nodes for this prefix"})]})]}),e.jsxs("div",{className:"border-t border-edge-subtle pt-2 pb-2",children:[e.jsxs("p",{className:"text-fg-muted mb-1",children:[e.jsx(S,{c:"text-sys-blue font-bold",children:"3"})," ","TYPE INFERENCE"]}),e.jsx(ae,{options:Pe,nextFn:"effectiveType()"}),e.jsx("div",{className:"ml-3 mt-1",children:e.jsx(i,{label:"effective",children:e.jsx(d,{fn:"effectiveType",value:p,color:p!=="unknown"?h!=="unknown"?"amber":"green":"zinc"})})})]}),e.jsxs("div",{className:"border-t border-edge-subtle pt-2 pb-2",children:[e.jsxs("p",{className:"text-fg-muted mb-1",children:[e.jsx(S,{c:"text-sys-blue font-bold",children:"4"})," ","ROLE-TYPE SCRUB"]}),e.jsx("div",{className:"space-y-0.5 ml-3",children:P.map(j=>e.jsxs("div",{className:"flex gap-2 items-center text-[11px]",children:[e.jsx("span",{className:j.roleCompatible?"text-sys-green":"text-sys-red",children:j.roleCompatible?"✓":"✗"}),e.jsx("span",{className:`break-all text-[10px] ${j.roleCompatible?"":"line-through text-fg-muted"}`,children:j.hash}),e.jsx(M,{color:j.roleCompatible?"zinc":"red",children:j.type||"unknown"}),e.jsx(S,{c:j.roleCompatible?"text-fg-muted":"text-sys-red",children:j.roleReason})]},j.hash))}),R.length>0&&e.jsxs("p",{className:"text-[10px] text-fg-muted mt-1 ml-3",children:[R.length," eliminated, ",b.length," surviving"]})]}),e.jsxs("div",{className:"border-t border-edge-subtle pt-2 pb-2",children:[e.jsxs("p",{className:"text-fg-muted mb-1",children:[e.jsx(S,{c:"text-sys-blue font-bold",children:"5"})," ","CANDIDATE SCORING"]}),b.length===0?e.jsx("p",{className:"text-fg-muted italic ml-3",children:"No surviving candidates"}):b.length===1?e.jsxs("div",{className:"ml-3 text-[11px]",children:[e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsx(S,{c:"text-sys-green",children:"→"}),e.jsx("span",{className:"break-all text-[10px]",children:b[0].hash}),b[0].name&&e.jsx(S,{c:"text-fg-muted ml-1",children:b[0].name})]}),e.jsx("p",{className:"text-fg-muted ml-4",children:"single survivor — scoring not needed"})]}):e.jsxs(G,{children:[e.jsx(K,{className:"text-[10px] ml-3",children:e.jsxs("span",{className:"font-mono text-fg-muted/50",children:[b.length," candidates scored…"]})}),e.jsx(V,{children:e.jsx("div",{className:"space-y-2 ml-3 mt-1",children:b.map(j=>{const Q=j.hash===u.hash;return e.jsxs("div",{className:`text-[11px] leading-relaxed rounded px-2 py-1 ${Q?"bg-sys-green/8 border border-sys-green/20":"bg-zinc-500/5"}`,children:[e.jsxs("div",{className:"flex gap-2 items-center mb-0.5",children:[e.jsx(S,{c:Q?"text-sys-green":"text-fg-muted",children:Q?"→":" "}),e.jsx("span",{className:`break-all text-[10px] ${Q?"text-fg-primary":"text-fg-muted"}`,children:j.hash}),e.jsx(M,{color:Q?"green":"zinc",children:j.type||"unknown"}),j.name&&e.jsx(S,{children:j.name})]}),e.jsxs("div",{className:"ml-4 flex flex-wrap gap-x-3 gap-y-0.5",children:[e.jsxs("span",{children:[e.jsx(S,{children:"zero_hop:"})," ",e.jsx(S,{c:j.zeroHop?"text-sys-green":"text-fg-muted",children:j.zeroHop?"✓":"✗"})," ",e.jsxs(M,{color:ee(j.zeroHopScore),children:["+",j.zeroHopScore]})]}),e.jsxs("span",{children:[e.jsx(S,{children:"recency:"})," ",e.jsx(S,{c:"text-fg-primary",children:mt(j.lastSeen)})," ",e.jsxs(M,{color:ee(j.recencyPoints),children:["+",j.recencyPoints.toFixed(1)]})]}),e.jsxs("span",{children:[e.jsx(S,{children:"gps:"})," ",e.jsx(S,{c:j.hasGps?"text-sys-green":"text-fg-muted",children:j.hasGps?"✓":"✗"})," ",e.jsxs(M,{color:ee(j.gpsScore),children:["+",j.gpsScore]})]}),e.jsxs("span",{children:[e.jsx(S,{children:"adverts:"})," ",e.jsx(S,{c:"text-fg-primary",children:j.advertCount})," ",e.jsxs(M,{color:ee(j.advertScore),children:["+",j.advertScore]})]}),e.jsxs("span",{children:[e.jsx(S,{children:"topo:"})," ",e.jsx(S,{c:"text-fg-primary",children:j.topoWidth})," ",e.jsxs(M,{color:ee(j.topoScore),children:["+",j.topoScore]})]})]}),e.jsxs("div",{className:"ml-4 mt-0.5",children:[e.jsx(S,{children:"score ≈"})," ",e.jsx(S,{c:"text-fg-primary font-bold",children:j.total.toFixed(1)})]})]},j.hash)})})})]})]})]}),e.jsxs("div",{className:"border-t border-edge-subtle pt-2 pb-2",children:[e.jsxs("p",{className:"text-fg-muted mb-1",children:[e.jsx(S,{c:"text-sys-green font-bold",children:"✓"})," ","RESOLUTION"]}),e.jsxs("div",{className:"ml-3",children:[e.jsx(i,{label:"hash",children:u.hash?e.jsx(d,{fn:"resolved.hash",value:u.hash,color:"green"}):e.jsx(S,{children:"null"})}),e.jsx(i,{label:"type",children:e.jsx(d,{fn:"resolved.type",value:u.type,color:u.confident?"green":"zinc"})}),e.jsx(i,{label:"name",children:u.name?e.jsx(d,{fn:"resolved.name",value:u.name,color:u.confident?"green":"amber"}):e.jsx(S,{children:"null"})}),e.jsx(i,{label:"confident",children:e.jsx(S,{c:u.confident?"text-sys-green":"text-sys-red",children:String(u.confident)})}),e.jsxs(i,{label:"tier",children:[e.jsx(M,{color:C.tier<=2?"green":C.tier===3?"amber":"red",children:C.tier}),e.jsx(S,{c:"text-fg-primary ml-1",children:C.label})]})]})]})]}):e.jsx("div",{className:"border-t border-edge-subtle pt-2 pb-2",children:e.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 text-[11px] font-mono",children:[e.jsx(S,{c:"text-sys-amber",children:"⚠ no src_hash"}),H&&e.jsx(d,{fn:"decrypt.senderName",value:H,color:"teal"}),u.confident?e.jsxs(S,{c:"text-sys-green",children:["→ resolved via ",C.label]}):e.jsx(S,{c:"text-sys-red",children:"ambiguous"})]})}),(()=>{const j=[{fn:"resolved.hash",value:u.hash??"null",group:"resolution",color:u.confident?"green":"zinc"},{fn:"resolved.type",value:u.type,group:"resolution",color:u.type!=="unknown"?u.confident?"green":"amber":"zinc"},{fn:"resolved.name",value:u.name??"null",group:"resolution",color:u.confident?"green":u.name?"amber":"zinc"},{fn:"resolved.confident",value:String(u.confident),group:"resolution",color:u.confident?"green":"red"}];return e.jsx(se,{tokens:j})})()]})})})}const Vt={id:"packet-parse",label:"Packet Parse",inputs:["rawPacket"],outputs:["parsedPacket","decoded","headerFields"],emits:[{fn:"routeType",group:"wire",color:"blue"},{fn:"payloadType",group:"wire",color:"blue"},{fn:"pathLength",group:"wire",color:"blue"},{fn:"version",group:"wire",color:"blue"}],async:!1,observatoryStage:0},qt={id:"enrichment",label:"Ingestion Enrichment",inputs:["parsedPacket"],outputs:["advertSender","channelHash","hopData","byteLength"],emits:[{fn:"_advertSender",group:"enrichment",color:"blue"},{fn:"_advertNodeType",group:"enrichment",color:"blue"},{fn:"_channelHash",group:"enrichment",color:"blue"},{fn:"_hopCount",group:"enrichment",color:"blue"},{fn:"_isZeroHop",group:"enrichment",color:"blue"},{fn:"_byteLength",group:"enrichment",color:"blue"}],async:!1,observatoryStage:1},Ut={id:"topology",label:"Topology Analysis",inputs:["packets","neighbors","srcHashResolver"],outputs:["edges","nodeMetrics","pathHealth","ghostNodes","centrality","loops"],emits:[{fn:"edges",group:"worker",color:"green"},{fn:"ghostNodes",group:"worker",color:"purple"},{fn:"loops",group:"analysis",color:"amber"},{fn:"nodeMetrics",group:"worker",color:"green"},{fn:"pathHealth",group:"worker",color:"green"},{fn:"centrality",group:"worker",color:"green"}],async:!0,worker:"topology.worker.ts",observatoryStage:2},Wt={id:"trace-enrichment",label:"Trace Link Quality",inputs:["packets","prefixLookup","srcHashResolver","edges","pathHealth","nodeMetrics"],outputs:["traceLinks","traceLinkSummary","traceDisambiguationFeedback"],emits:[{fn:"traceLinks.directed",group:"worker",color:"teal"},{fn:"traceLinks.bidir",group:"worker",color:"teal"},{fn:"traceSummary.meanSnr",group:"analysis",color:"green"},{fn:"traceSummary.medianSnr",group:"analysis",color:"zinc"},{fn:"traceSummary.confidence",group:"analysis",color:"zinc"},{fn:"feedback.confirmed",group:"worker",color:"teal"},{fn:"feedback.links",group:"worker",color:"teal"}],async:!1,observatoryStage:2},Yt={id:"disambiguation",label:"Source Disambiguation",inputs:["packets","neighbors","decodedMessages"],outputs:["srcHashResolverMap","neighborContext"],emits:[{fn:"resolvedHash",group:"resolution",color:"purple"},{fn:"resolvedName",group:"resolution",color:"purple"},{fn:"resolvedType",group:"resolution",color:"purple"},{fn:"confidence",group:"resolution",color:"green"}],async:!1,observatoryStage:3},Zt={id:"sparkline",label:"Sparkline Computation",inputs:["packets","neighbors"],outputs:["sparklineData"],emits:[{fn:"sparklines",group:"worker",color:"blue"}],async:!0,worker:"sparkline.worker.ts"},Xt={id:"decryption",label:"Channel Decryption",inputs:["packets","channelKeys"],outputs:["decodedMessages"],emits:[{fn:"decrypt.text",group:"crypto",color:"teal"},{fn:"decrypt.senderName",group:"crypto",color:"teal"},{fn:"decrypt.channelName",group:"crypto",color:"teal"},{fn:"decrypt.macCorrupted",group:"crypto",color:"amber"}],async:!0,worker:"decryption.worker.ts",observatoryStage:2},Qt={id:"decoded-content",label:"Decoded Content Policy",inputs:["decodedMessages","packets"],outputs:["decodedContent","contentInheritance"],emits:[{fn:"content.senderName",group:"crypto",color:"teal"},{fn:"content.text",group:"crypto",color:"teal"},{fn:"content.channelName",group:"crypto",color:"teal"},{fn:"content.corrupted",group:"crypto",color:"amber"},{fn:"content.inherited",group:"analysis",color:"purple"}],async:!1},Z=[Vt,qt,Ut,Wt,Yt,Zt,Xt,Qt],Jt=new Map(Z.map(t=>[t.id,t])),es=new Map;for(const t of Z)for(const s of t.emits)es.set(s.fn,t);const $e=new Map;for(const t of Z)for(const s of t.outputs)$e.set(s,t);function ts(){const t=new Map,s=new Map;for(const a of Z)t.has(a.id)||t.set(a.id,0),s.has(a.id)||s.set(a.id,new Set);for(const a of Z)for(const n of a.inputs){const l=$e.get(n);if(l&&l.id!==a.id){const o=s.get(l.id);o.has(a.id)||(o.add(a.id),t.set(a.id,(t.get(a.id)??0)+1))}}const r=[];for(const[a,n]of t)n===0&&r.push(a);const c=[];for(;r.length>0;){const a=r.shift(),n=Jt.get(a);n&&c.push(n);for(const l of s.get(a)??[]){const o=(t.get(l)??1)-1;t.set(l,o),o===0&&r.push(l)}}for(const a of Z)c.includes(a)||c.push(a);return c}const ss={0:"text-sys-green",1:"text-sys-blue",2:"text-sys-teal",3:"text-sys-purple"};function ns({stage:t,isActive:s,onClick:r}){const c=t.observatoryStage!=null?ss[t.observatoryStage]??"text-fg-muted":"text-fg-muted/40";return e.jsxs("button",{type:"button",onClick:r,className:` - flex items-center gap-1.5 w-full px-1.5 py-1 rounded transition-base text-left - ${s?"bg-sys-blue/10 ring-1 ring-sys-blue/30":"hover:bg-zinc-500/5"} - `,children:[e.jsx("span",{className:`font-mono text-[9px] font-bold w-3 shrink-0 text-center ${c}`,children:t.observatoryStage??"·"}),e.jsx("span",{className:"font-mono text-[9px] text-fg-primary truncate flex-1",children:t.label}),t.async&&e.jsx("span",{className:"font-mono text-[7px] px-1 py-px rounded bg-sys-amber/15 text-sys-amber shrink-0 leading-tight",children:"⚡"}),t.emits.length>0&&e.jsxs("span",{className:"flex items-center gap-px shrink-0",children:[t.emits.slice(0,6).map(a=>{var n;return e.jsx("span",{className:`inline-block w-1 h-1 rounded-full ${((n=I[a.color])==null?void 0:n.dot)??"bg-zinc-500"}`,title:`${a.fn} [${a.group}]`},a.fn)}),t.emits.length>6&&e.jsxs("span",{className:"font-mono text-[7px] text-fg-muted/40 ml-0.5",children:["+",t.emits.length-6]})]})]})}function rs({activeStageId:t,onStageClick:s}){const r=T.useMemo(()=>ts(),[]),c=T.useMemo(()=>{const a=new Map;for(const l of r){const o=l.observatoryStage??"other";let x=a.get(o);x||(x=[],a.set(o,x)),x.push(l)}const n=[];for(const l of[0,1,2,3,"other"]){const o=a.get(l);o!=null&&o.length&&n.push({key:l,stages:o})}return n},[r]);return e.jsxs("div",{className:"surface-base rounded-lg border border-edge-subtle p-2",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"font-mono text-[8px] text-fg-muted/40 uppercase tracking-widest",children:"Pipeline DAG"}),e.jsxs("span",{className:"font-mono text-[8px] text-fg-muted/30",children:[r.length," stages"]})]}),e.jsx("div",{className:"space-y-px",children:c.map((a,n)=>e.jsxs("div",{children:[n>0&&e.jsx("div",{className:"flex items-center pl-2.5 py-px",children:e.jsx("svg",{width:"6",height:"8",viewBox:"0 0 6 8",className:"text-fg-muted/20",children:e.jsx("path",{d:"M3 0 L3 6 M1 4 L3 6 L5 4",fill:"none",stroke:"currentColor",strokeWidth:"1"})})}),a.stages.map(l=>e.jsx(ns,{stage:l,isActive:t===l.id,onClick:s?()=>s(l.id):void 0},l.id))]},String(a.key)))})]})}const ve=200,z={status:"idle",lastDurationMs:null,lastTs:null,runCount:0};function as(t,s,r){var c,a,n;switch(t.type){case"transport:ws:state":s.wsState=((c=t.data)==null?void 0:c.state)??r.wsState;break;case"transport:ws:packet":s.wsPacketCount=(s.wsPacketCount??r.wsPacketCount)+1;break;case"transport:ws:stats":s.wsStatsCount=(s.wsStatsCount??r.wsStatsCount)+1;break;case"transport:rest:stats":s.restStatsCount=(s.restStatsCount??r.restStatsCount)+1;break;case"transport:rest:packets":s.restPacketsCount=(s.restPacketsCount??r.restPacketsCount)+1;break;case"store:packets:ws-merge":s.wsMergeCount=(s.wsMergeCount??r.wsMergeCount)+1;break;case"cascade:hydrate":s.lastHydrateTs=t.ts,s.hydrateCount=(s.hydrateCount??r.hydrateCount)+1;break;case"worker:topology:start":case"worker:sparkline:start":{const l=t.type.split(":")[1],o=s.workers??r.workers,x=o[l]??{...z};s.workers={...o,[l]:{...x,status:"running",lastTs:t.ts}}}break;case"worker:topology:done":case"worker:sparkline:done":{const l=t.type.split(":")[1],o=s.workers??r.workers,x=o[l]??{...z},m=((a=t.data)==null?void 0:a.ms)??null;s.workers={...o,[l]:{...x,status:"done",lastDurationMs:m,lastTs:t.ts,runCount:x.runCount+1}}}break;case"worker:decryption:batch":{const l=s.workers??r.workers,o=l.decryption??{...z},x=((n=t.data)==null?void 0:n.ms)??null;s.workers={...l,decryption:{...o,status:"done",lastDurationMs:x,lastTs:t.ts,runCount:o.runCount+1}}}break;case"pipeline:disambig:recompute":s.disambigCount=(s.disambigCount??r.disambigCount)+1;break}}const te=rt(t=>({events:[],eventCount:0,wsState:"disconnected",wsPacketCount:0,wsStatsCount:0,restStatsCount:0,restPacketsCount:0,workers:{topology:{...z},sparkline:{...z},decryption:{...z}},wsMergeCount:0,lastHydrateTs:null,hydrateCount:0,disambigCount:0,lastDisambigMs:null,_pushBatch:s=>t(r=>{if(s.length===0)return r;let c=[...r.events,...s];c.length>ve&&(c=c.slice(c.length-ve));const a={events:c,eventCount:r.eventCount+s.length};for(const n of s)as(n,a,r);return a}),clear:()=>t({events:[],eventCount:0,wsState:"disconnected",wsPacketCount:0,wsStatsCount:0,restStatsCount:0,restPacketsCount:0,workers:{topology:{...z},sparkline:{...z},decryption:{...z}},wsMergeCount:0,lastHydrateTs:null,hydrateCount:0,disambigCount:0,lastDisambigMs:null})}));let W=null,B=[],X=null;function ls(){if(X=null,B.length===0)return;const t=B;B=[],te.getState()._pushBatch(t)}function os(){W||(B=[],W=at.subscribe(t=>{B.push(t),X===null&&(X=requestAnimationFrame(ls))}))}function cs(){if(W==null||W(),W=null,X!==null&&(cancelAnimationFrame(X),X=null),B.length>0){const t=B;B=[],te.getState()._pushBatch(t)}}function is(t){switch(t){case"active":return"●";case"skipped":return"○";case"inferred":return"◌"}}function ds(t){switch(t){case"active":return"text-sys-green";case"skipped":return"text-fg-muted/30";case"inferred":return"text-sys-amber"}}function us(t){switch(t){case"transport":return"text-sys-blue";case"store":return"text-sys-amber";case"worker":return"text-sys-violet";case"pipeline":return"text-sys-green";case"consumer":return"text-sys-teal"}}function ps(t,s,r,c,a){var m,g;const n=[];if(a?n.push({label:"Hex Input",detail:"Manual hex — no transport",status:"skipped",lane:"transport"}):s.age==="live"||s.age==="recent"?n.push({label:"WebSocket",detail:"ws:packet → real-time push",status:"active",lane:"transport"}):n.push({label:"REST Poll",detail:"fetchPackets → packetCache.poll()",status:"inferred",lane:"transport"}),!a){n.push({label:"Cache Merge",detail:"packetCache.mergePacketsDirectly()",status:"active",lane:"store"});const u=s.age==="live"||s.age==="recent";n.push({label:"Flash",detail:u?"flashReceived++ → sidebar blink":"Not newest — no flash",status:u?"active":"skipped",lane:"store"}),n.push({label:"Hydrate Cascade",detail:"hydrateDownstream() → schedule workers",status:"active",lane:"store"})}const l=s.pathAvail||s.pathHopCount>0;n.push({label:"Topology Worker",detail:l?`Path data (${s.pathHopCount} hops) → edge extraction`:"No path data — still included in batch recompute",status:"active",lane:"worker"}),n.push({label:"Sparkline Worker",detail:`Contributes to sparkline for src ${((m=t.src_hash)==null?void 0:m.slice(0,4))??"??"}`,status:"active",lane:"worker"});const o=s.isGrp;n.push({label:"Decryption Worker",detail:o?`GRP_TXT → queued for channel key search${c?" → decrypted ✓":""}`:`${s.payloadTypeName} — not encrypted, skipped`,status:o?"active":"skipped",lane:"worker"}),n.push({label:"Source Disambiguation",detail:r?`→ ${r.name??((g=r.hash)==null?void 0:g.slice(0,8))??"?"} (${r.type}${r.confident?", confident":", ambiguous"})`:"Pending recompute",status:r?"active":"inferred",lane:"pipeline"}),s.isAdvert&&n.push({label:"ADVERT Discovery",detail:"pubkey → extended hash-to-type + name extraction",status:"active",lane:"pipeline"}),o&&(c!=null&&c.decoded)&&n.push({label:"Decoded Content Policy",detail:`macCorrupted=${c.decoded.macCorrupted?"true":"false"} → cross-hash inheritance`,status:"active",lane:"pipeline"});const x=["Packets","Dashboard","Statistics"];return l&&x.push("Map","Graph"),s.isTrace&&x.push("Trace Detail"),n.push({label:"Page Hydration",detail:x.join(", "),status:"active",lane:"consumer"}),n}const xs=[],hs=["transport","store","worker","pipeline","consumer"],ms={transport:"Transport",store:"Store",worker:"Workers",pipeline:"Pipeline",consumer:"Consumers"};function gs(t){return t.replace("transport:","").replace("store:packets:","").replace("cascade:","").replace("worker:","w:").replace("pipeline:","p:").replace("packet","pkt").replace("sparkline","spark").replace("topology","topo").replace("decryption","dec").replace("disambig","dis").replace("recompute","recomp")}function fs(t){return t.startsWith("transport:")?"text-sys-blue":t.startsWith("store:")||t.startsWith("cascade:")?"text-sys-amber":t.startsWith("worker:")?"text-sys-violet":t.startsWith("pipeline:")?"text-sys-green":"text-fg-muted"}const bs=T.memo(function({event:s}){const r=`${(s.ts/1e3).toFixed(1)}s`,c=s.data?Object.entries(s.data).map(([a,n])=>{var l;return`${a}=${typeof n=="number"?((l=n.toFixed)==null?void 0:l.call(n,1))??n:n}`}).join(" "):"";return e.jsxs("div",{className:"flex gap-2 text-[9px] font-mono leading-tight",children:[e.jsx("span",{className:"text-fg-muted/40 w-12 shrink-0 text-right",children:r}),e.jsx("span",{className:`w-20 shrink-0 ${fs(s.type)}`,children:gs(s.type)}),e.jsx("span",{className:"text-fg-muted/60 truncate",children:c})]})});function ys({packet:t,pipeline:s,resolved:r,decrypted:c,isSynthetic:a,liveMode:n}){const[l,o]=T.useState(!1);T.useEffect(()=>{if(l)return os(),()=>{cs()}},[l]);const x=s==null?void 0:s.analysis,m=T.useMemo(()=>!t||!x?null:ps(t,x,r,c,a),[t,x,r,c,a]),g=T.useMemo(()=>{if(!m)return null;const h=new Map;for(const y of m){let p=h.get(y.lane);p||(p=[],h.set(y.lane,p)),p.push(y)}return h},[m]),u=te(h=>l?h.events:xs),v=te(h=>l?h.eventCount:0),N=te(h=>h.clear),f=T.useRef(null);T.useEffect(()=>{l&&f.current&&(f.current.scrollTop=f.current.scrollHeight)},[v,l]);const k=(m==null?void 0:m.filter(h=>h.status==="active").length)??0,$=(m==null?void 0:m.length)??0;return e.jsxs(G,{defaultOpen:!0,children:[e.jsx(K,{className:"text-[10px]",children:e.jsxs("span",{className:"flex items-center gap-2 font-mono",children:[e.jsx("span",{className:"text-sys-green",children:"CFT"}),e.jsx("span",{className:"text-fg-muted/40",children:"Control Flow Trace"}),t&&e.jsxs("span",{className:"text-fg-muted/30",children:["— ",k,"/",$," stages active"]})]})}),e.jsx(V,{children:e.jsxs("div",{className:"surface-base rounded-lg border border-edge-subtle p-3 space-y-3",children:[t?g?e.jsx("div",{className:"space-y-2",children:hs.map(h=>{const y=g.get(h);return y?e.jsxs("div",{children:[e.jsx("div",{className:`text-[8px] uppercase tracking-widest font-mono mb-0.5 ${us(h)}`,children:ms[h]}),y.map((p,_)=>e.jsxs("div",{className:"flex items-start gap-1.5 text-[10px] font-mono leading-snug ml-1",children:[e.jsx("span",{className:`shrink-0 ${ds(p.status)}`,children:is(p.status)}),e.jsx("span",{className:"text-fg-primary",children:p.label}),e.jsx("span",{className:"text-fg-muted/50 truncate",children:p.detail})]},_))]},h):null})}):null:e.jsx("div",{className:"text-[9px] text-fg-muted/30 font-mono py-2 text-center",children:"Select a packet to trace its flow"}),e.jsxs("div",{className:"border-t border-edge-subtle pt-2 flex items-center gap-2",children:[e.jsx("button",{onClick:()=>o(h=>!h),className:`px-2 py-0.5 rounded text-[9px] font-mono transition-colors ${l?"bg-sys-green/20 text-sys-green":"bg-zinc-500/20 text-fg-muted hover:text-fg-primary"}`,children:l?"● LIVE":"○ LIVE"}),e.jsx("span",{className:"text-[9px] text-fg-muted/40 font-mono",children:l?`${v} events`:"Subscribe to all pipeline events"}),l&&e.jsx("button",{onClick:N,className:"text-[9px] text-fg-muted/40 hover:text-fg-muted font-mono transition-colors ml-auto",children:"clear"})]}),l&&e.jsx("div",{ref:f,className:"max-h-32 overflow-y-auto space-y-px",children:u.length===0?e.jsx("div",{className:"text-[9px] text-fg-muted/30 font-mono py-1 text-center",children:"Waiting for events…"}):u.map((h,y)=>e.jsx(bs,{event:h},`${h.ts}-${y}`))})]})})]})}function js(t){const s=Ne(t.type??t.payload_type??-1).padEnd(7),r=t.packet_hash.slice(0,8),c=(t.src_hash??"—").replace(/^0x/i,"").slice(0,4).toUpperCase(),a=t._hopCount!=null?`${t._hopCount}h`:"",n=dt(t.timestamp);return`${r} ${s} ←${c} ${t.rssi}dBm ${a} ${n}`}function Ts(){const t=lt(),s=ot(),r=ct(),c=(s==null?void 0:s.neighbors)??{},a=Y(b=>b.resolveSource),n=Y(b=>b.config),l=Y(b=>b.setConfig),[o,x]=T.useState(-1),m=T.useMemo(()=>{let b=t;return o!==-1&&(b=t.filter(w=>(w.type??w.payload_type)===o)),b.slice(-50).reverse()},[t,o]),[g,u]=T.useState(""),[v,N]=T.useState(""),[f,k]=T.useState(!1),$=T.useRef(r);T.useEffect(()=>{f&&r!==$.current&&m.length>0&&(u(m[0].packet_hash),N("")),$.current=r},[r,f,m]),T.useEffect(()=>{!g&&m.length>0&&!v&&u(m[0].packet_hash)},[g,m,v]);const h=T.useMemo(()=>v.trim()?null:m.find(b=>b.packet_hash===g)??null,[g,m,v]),y=T.useMemo(()=>{const b=v.replace(/\s+/g,"").trim();return b?{packet_hash:"manual-hex-input",timestamp:0,rssi:0,snr:0,transmitted:!1,drop_reason:null,is_duplicate:!1,raw_packet:b}:null},[v]),p=h??y,_=!!v.trim(),H=v.trim().replace(/\s+/g,"")||(p==null?void 0:p.raw_packet),C=wt(p,H,t),D=(C==null?void 0:C.enrichment)??He,L=Ce((p==null?void 0:p.packet_hash)??""),P=T.useRef(0),R=T.useMemo(()=>{if(!p)return null;const b=performance.now(),w=a(p);return P.current=performance.now()-b,w},[p,a]);return e.jsxs("div",{className:"max-w-[960px] mx-auto",children:[e.jsxs("div",{className:"mb-3",children:[e.jsx("h1",{className:"text-sm font-bold text-fg-primary tracking-wide font-mono",children:"PACKET OBSERVATORY"}),e.jsx("p",{className:"text-[11px] text-fg-muted font-mono",children:"Pipeline introspection — select a packet to trace its journey"})]}),e.jsxs("div",{className:"surface-base rounded-lg border border-edge-subtle p-3 mb-3",children:[e.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[e.jsxs("select",{value:o,onChange:b=>{x(Number(b.target.value)),u("")},className:"surface-input px-2 py-1 rounded text-[11px] font-mono text-fg-primary w-36",children:[e.jsx("option",{value:-1,children:"ALL TYPES"}),Object.entries(it).map(([b,w])=>e.jsxs("option",{value:Number(b),children:["0x",Number(b).toString(16).toUpperCase().padStart(2,"0")," ",w]},b))]}),e.jsxs("select",{value:g,onChange:b=>{u(b.target.value),N("")},className:"surface-input flex-1 min-w-0 px-2 py-1 rounded text-[11px] font-mono text-fg-primary truncate",children:[m.map((b,w)=>e.jsx("option",{value:b.packet_hash,children:js(b)},`${b.packet_hash}-${w}`)),m.length===0&&e.jsxs("option",{value:"",children:["No packets",o!==-1?" matching filter":" loaded"]})]}),e.jsx("button",{onClick:()=>k(b=>!b),className:`px-2 py-1 rounded text-[11px] font-mono transition-colors shrink-0 ${f?"bg-sys-green/20 text-sys-green":"bg-zinc-500/20 text-fg-muted hover:text-fg-primary"}`,children:f?"● LIVE":"○ LIVE"})]}),e.jsxs(G,{children:[e.jsx(K,{className:"text-[10px] text-fg-muted/50 hover:text-fg-muted mt-1.5",children:e.jsx("span",{className:"font-mono",children:"Paste hex…"})}),e.jsx(V,{children:e.jsx("textarea",{value:v,onChange:b=>N(b.target.value),placeholder:"Paste raw packet hex (overrides dropdown)",rows:2,className:"surface-input w-full mt-1 px-2 py-1 rounded text-[11px] font-mono text-fg-primary resize-y"})})]})]}),e.jsxs(G,{children:[e.jsx(K,{className:"text-[11px] mb-3 w-full",children:e.jsxs("span",{className:"flex items-center gap-2 font-mono",children:[e.jsx("span",{className:"text-fg-muted/50",children:"⚙"}),e.jsx("span",{className:"text-fg-muted/50",children:"Pipeline Config & Dev Tools"}),e.jsxs("span",{className:"text-fg-muted/30 text-[10px]",children:["disambig=",n.disambiguationEnabled?"on":"off"," mac=",n.macCorruptedPolicy," decay=",n.recencyDecayHours,"h"]})]})}),e.jsx(V,{children:e.jsxs("div",{className:"space-y-3 mb-4",children:[e.jsxs("div",{className:"surface-base rounded-lg border border-edge-subtle p-3",children:[e.jsx("h2",{className:"text-[10px] text-fg-muted/50 uppercase tracking-widest font-mono mb-2",children:"Pipeline Config"}),e.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("label",{className:"text-[11px] text-fg-muted w-24 shrink-0",children:"Disambiguation"}),e.jsx("button",{onClick:()=>l({disambiguationEnabled:!n.disambiguationEnabled}),className:`px-2 py-0.5 rounded text-[11px] font-mono transition-colors ${n.disambiguationEnabled?"bg-sys-green/20 text-sys-green":"bg-sys-red/20 text-sys-red"}`,children:n.disambiguationEnabled?"● ON":"○ OFF"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("label",{className:"text-[11px] text-fg-muted w-24 shrink-0",children:"MAC policy"}),e.jsxs("select",{value:n.macCorruptedPolicy,onChange:b=>l({macCorruptedPolicy:b.target.value}),className:"surface-input px-1.5 py-0.5 rounded text-[11px] font-mono text-fg-primary",children:[e.jsx("option",{value:"strict",children:"strict (drop)"}),e.jsx("option",{value:"name-only",children:"name-only"}),e.jsx("option",{value:"permissive",children:"permissive"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("label",{className:"text-[11px] text-fg-muted w-24 shrink-0",children:"Recency decay"}),e.jsx("input",{type:"range",min:1,max:48,step:1,value:n.recencyDecayHours,onChange:b=>l({recencyDecayHours:Number(b.target.value)}),className:"flex-1 h-1 accent-sys-blue"}),e.jsxs("span",{className:"text-[11px] font-mono text-fg-primary w-8 text-right",children:[n.recencyDecayHours,"h"]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("label",{className:"text-[11px] text-fg-muted w-24 shrink-0",children:"Zero-hop decay"}),e.jsx("input",{type:"range",min:12,max:168,step:6,value:n.zeroHopDecayHours,onChange:b=>l({zeroHopDecayHours:Number(b.target.value)}),className:"flex-1 h-1 accent-sys-blue"}),e.jsxs("span",{className:"text-[11px] font-mono text-fg-primary w-10 text-right",children:[n.zeroHopDecayHours,"h"]})]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[e.jsx(ys,{packet:p,pipeline:C,resolved:R,decrypted:L??null,isSynthetic:_,liveMode:f}),e.jsx(rs,{})]})]})})]}),p?e.jsxs("div",{className:"space-y-1",children:[e.jsx(kt,{packet:p,isSynthetic:_}),e.jsx(Rt,{packet:p,pipeline:C,rawHex:H,traceTagIndex:(C==null?void 0:C.traceTagIndex)??new Map,neighbors:c}),e.jsx(zt,{packet:p,decrypted:L??void 0,pipeline:C}),e.jsx(Kt,{packet:p,pipeline:C,resolved:R,decrypted:L??void 0,resolveTimeMs:P.current,neighbors:c,advertName:D.advertName})]}):e.jsx("div",{className:"surface-base rounded-lg border border-edge-subtle p-8 text-center",children:e.jsx("p",{className:"text-fg-muted text-xs",children:"Select a packet from the dropdown or paste hex above"})})]})}export{Ts as default}; diff --git a/frontend/dist/assets/Packets-QitEk45M.js b/frontend/dist/assets/Packets-COYrsmYr.js similarity index 83% rename from frontend/dist/assets/Packets-QitEk45M.js rename to frontend/dist/assets/Packets-COYrsmYr.js index c6fb1424..14f6d0df 100644 --- a/frontend/dist/assets/Packets-QitEk45M.js +++ b/frontend/dist/assets/Packets-COYrsmYr.js @@ -1 +1 @@ -import{r as d,aj as D,ak as at,al as Ve,am as Pe,an as te,ao as ot,ap as nt,aq as le,ar as Be,as as st,at as lt,au as it,av as me,aw as rt,ax as ut,ay as xe,az as B,aA as ct,aB as Ee,aC as W,aD as se,aE as Te,aF as Se,aG as dt,aH as ze,aI as He,aJ as be,aK as Ce,aL as ve,aM as pt,aN as mt,aO as bt,aP as Re,aQ as vt,aR as ft,aS as ge,aT as gt,aU as xt,aV as ht,aW as yt,aX as G,aY as St,aZ as Ct,a_ as Ot,a$ as Pt,b0 as Et,b1 as Tt,b2 as Rt,b3 as $t,b4 as wt,b5 as jt,b6 as It,b7 as $e,j as l,c as ne,ae as Nt,w as kt,x as Mt,b8 as Ft,y as Dt,E as At,J as _t,K as Lt,aa as Vt,ah as Bt,N as we,b9 as je,ba as Ie,B as Ne,bb as ke,F as Me,bc as zt,T as Ht}from"./index-C1ZF7cAz.js";import{b as Ut,g as Ue,a as Kt,u as Gt,P as qt}from"./PacketList-BiFMK9DR.js";import{c as V,p as Wt,a as de,f as Fe,b as Yt,L as Xt,S as ue,s as Jt,u as De,d as Qt,g as Zt,e as ea,h as ta}from"./element-movement-CuySBNA6.js";import{F as aa,y as oa,R as na,T as sa,w as Ae,A as la}from"./map-pin-DEktgLFN.js";import{useGetDecodedContent as ia,useResolveSource as ra}from"./usePipelineStore-BEu0jDzA.js";import{c as ua,a as ca,A as da}from"./AnalyzerFilterPanel-D0gvrDVF.js";import{u as pa,r as ma}from"./consumer-registry-CFnLzQEu.js";import{A as ba}from"./arrow-up-DhGrEgP7.js";import{A as va}from"./SignalIndicator-BDLlaquA.js";import{P as fa,a as ga,B as xa,C as he}from"./PageLayout-sd81yog0.js";import{T as ha}from"./TimeRangeStepper-CxA2aT1o.js";import{F as _e}from"./funnel-zG3cM6J7.js";import{R as ya}from"./Grid-DrJ5vfLo.js";import"./primitives-DyUGjsV_.js";import"./payload-decoders-CmuRVuC0.js";import"./badge-colors-BNUqIXCA.js";import"./chat-utils-BzC-Ehs-.js";import"./chevron-right-DzbDJf-i.js";import"./circle-question-mark-CxqvWhsl.js";import"./triangle-alert-B3ZB2VPZ.js";import"./DataBox-BADtaCfB.js";import"./layers-BNenbfjd.js";import"./hash-2pKM_KWy.js";import"./activity-Bmh45lNn.js";import"./circle-check-DY6oislV.js";import"./database-CdKnhwkJ.js";import"./useMapViewStore-px_sYTaN.js";import"./index-DCNWD5GU.js";import"./shield-BNyjVgrV.js";import"./node-types-BJeLdOcD.js";import"./monitor-smartphone-BQ_i3P0U.js";import"./search-CtlrlrHK.js";function Ke(e){let a=d.useRef({value:"",selectionStart:null,selectionEnd:null});return at(e,"blur",t=>{let n=t.target;Pe(n)&&(a.current={value:n.value,selectionStart:n.selectionStart,selectionEnd:n.selectionEnd})}),D(()=>{if(!Ve(e)&&Pe(e)&&e.isConnected){if(e.focus({preventScroll:!0}),e.value!==a.current.value)e.setSelectionRange(e.value.length,e.value.length);else{let{selectionStart:t,selectionEnd:n}=a.current;t!==null&&n!==null&&e.setSelectionRange(t,n)}a.current={value:"",selectionStart:null,selectionEnd:null}}})}function Sa(e,{container:a,accept:t,walk:n}){let o=d.useRef(t),s=d.useRef(n);d.useEffect(()=>{o.current=t,s.current=n},[t,n]),te(()=>{if(!a||!e)return;let i=ot(a);if(!i)return;let v=o.current,c=s.current,m=Object.assign(y=>v(y),{acceptNode:v}),g=i.createTreeWalker(a,NodeFilter.SHOW_ELEMENT,m,!1);for(;g.nextNode();)c(g.currentNode)},[a,e,o,s])}var Ca=Object.defineProperty,Oa=(e,a,t)=>a in e?Ca(e,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[a]=t,Le=(e,a,t)=>(Oa(e,typeof a!="symbol"?a+"":a,t),t),x=(e=>(e[e.Open=0]="Open",e[e.Closed=1]="Closed",e))(x||{}),J=(e=>(e[e.Single=0]="Single",e[e.Multi=1]="Multi",e))(J||{}),ee=(e=>(e[e.Pointer=0]="Pointer",e[e.Focus=1]="Focus",e[e.Other=2]="Other",e))(ee||{}),Ge=(e=>(e[e.OpenCombobox=0]="OpenCombobox",e[e.CloseCombobox=1]="CloseCombobox",e[e.GoToOption=2]="GoToOption",e[e.SetTyping=3]="SetTyping",e[e.RegisterOption=4]="RegisterOption",e[e.UnregisterOption=5]="UnregisterOption",e[e.DefaultToFirstOption=6]="DefaultToFirstOption",e[e.SetActivationTrigger=7]="SetActivationTrigger",e[e.UpdateVirtualConfiguration=8]="UpdateVirtualConfiguration",e[e.SetInputElement=9]="SetInputElement",e[e.SetButtonElement=10]="SetButtonElement",e[e.SetOptionsElement=11]="SetOptionsElement",e[e.MarkInputAsMoved=12]="MarkInputAsMoved",e))(Ge||{});function ye(e,a=t=>t){let t=e.activeOptionIndex!==null?e.options[e.activeOptionIndex]:null,n=a(e.options.slice()),o=n.length>0&&n[0].dataRef.current.order!==null?n.sort((i,v)=>i.dataRef.current.order-v.dataRef.current.order):lt(n,i=>i.dataRef.current.domRef.current),s=t?o.indexOf(t):null;return s===-1&&(s=null),{options:o,activeOptionIndex:s}}let Pa={1(e){var a;if((a=e.dataRef.current)!=null&&a.disabled||e.comboboxState===1)return e;let t=e.inputElement?de.Tracked(Yt(e.inputElement)):e.inputPositionState;return{...e,activeOptionIndex:null,comboboxState:1,isTyping:!1,activationTrigger:2,inputPositionState:t,__demoMode:!1}},0(e){var a,t;if((a=e.dataRef.current)!=null&&a.disabled||e.comboboxState===0)return e;if((t=e.dataRef.current)!=null&&t.value){let n=e.dataRef.current.calculateIndex(e.dataRef.current.value);if(n!==-1)return{...e,activeOptionIndex:n,comboboxState:0,__demoMode:!1,inputPositionState:de.Idle}}return{...e,comboboxState:0,inputPositionState:de.Idle,__demoMode:!1}},3(e,a){return e.isTyping===a.isTyping?e:{...e,isTyping:a.isTyping}},2(e,a){var t,n,o,s;if((t=e.dataRef.current)!=null&&t.disabled||e.optionsElement&&!((n=e.dataRef.current)!=null&&n.optionsPropsRef.current.static)&&e.comboboxState===1)return e;if(e.virtual){let{options:m,disabled:g}=e.virtual,y=a.focus===V.Specific?a.idx:Fe(a,{resolveItems:()=>m,resolveActiveIndex:()=>{var b,p;return(p=(b=e.activeOptionIndex)!=null?b:m.findIndex(P=>!g(P)))!=null?p:null},resolveDisabled:g,resolveId(){throw new Error("Function not implemented.")}}),h=(o=a.trigger)!=null?o:2;return e.activeOptionIndex===y&&e.activationTrigger===h?e:{...e,activeOptionIndex:y,activationTrigger:h,isTyping:!1,__demoMode:!1}}let i=ye(e);if(i.activeOptionIndex===null){let m=i.options.findIndex(g=>!g.dataRef.current.disabled);m!==-1&&(i.activeOptionIndex=m)}let v=a.focus===V.Specific?a.idx:Fe(a,{resolveItems:()=>i.options,resolveActiveIndex:()=>i.activeOptionIndex,resolveId:m=>m.id,resolveDisabled:m=>m.dataRef.current.disabled}),c=(s=a.trigger)!=null?s:2;return e.activeOptionIndex===v&&e.activationTrigger===c?e:{...e,...i,isTyping:!1,activeOptionIndex:v,activationTrigger:c,__demoMode:!1}},4:(e,a)=>{var t,n,o,s;if((t=e.dataRef.current)!=null&&t.virtual)return{...e,options:[...e.options,a.payload]};let i=a.payload,v=ye(e,m=>(m.push(i),m));e.activeOptionIndex===null&&(o=(n=e.dataRef.current).isSelected)!=null&&o.call(n,a.payload.dataRef.current.value)&&(v.activeOptionIndex=v.options.indexOf(i));let c={...e,...v,activationTrigger:2};return(s=e.dataRef.current)!=null&&s.__demoMode&&e.dataRef.current.value===void 0&&(c.activeOptionIndex=0),c},5:(e,a)=>{var t;if((t=e.dataRef.current)!=null&&t.virtual)return{...e,options:e.options.filter(o=>o.id!==a.id)};let n=ye(e,o=>{let s=o.findIndex(i=>i.id===a.id);return s!==-1&&o.splice(s,1),o});return{...e,...n,activationTrigger:2}},6:(e,a)=>e.defaultToFirstOption===a.value?e:{...e,defaultToFirstOption:a.value},7:(e,a)=>e.activationTrigger===a.trigger?e:{...e,activationTrigger:a.trigger},8:(e,a)=>{var t,n;if(e.virtual===null)return{...e,virtual:{options:a.options,disabled:(t=a.disabled)!=null?t:()=>!1}};if(e.virtual.options===a.options&&e.virtual.disabled===a.disabled)return e;let o=e.activeOptionIndex;if(e.activeOptionIndex!==null){let s=a.options.indexOf(e.virtual.options[e.activeOptionIndex]);s!==-1?o=s:o=null}return{...e,activeOptionIndex:o,virtual:{options:a.options,disabled:(n=a.disabled)!=null?n:()=>!1}}},9:(e,a)=>e.inputElement===a.element?e:{...e,inputElement:a.element},10:(e,a)=>e.buttonElement===a.element?e:{...e,buttonElement:a.element},11:(e,a)=>e.optionsElement===a.element?e:{...e,optionsElement:a.element},12(e){return e.inputPositionState.kind!=="Tracked"?e:{...e,inputPositionState:de.Moved}}};class Oe extends nt{constructor(a){super(a),Le(this,"actions",{onChange:t=>{let{onChange:n,compare:o,mode:s,value:i}=this.state.dataRef.current;return le(s,{0:()=>n==null?void 0:n(t),1:()=>{let v=i.slice(),c=v.findIndex(m=>o(m,t));return c===-1?v.push(t):v.splice(c,1),n==null?void 0:n(v)}})},registerOption:(t,n)=>(this.send({type:4,payload:{id:t,dataRef:n}}),()=>{this.state.activeOptionIndex===this.state.dataRef.current.calculateIndex(n.current.value)&&this.send({type:6,value:!0}),this.send({type:5,id:t})}),goToOption:(t,n)=>(this.send({type:6,value:!1}),this.send({type:2,...t,trigger:n})),setIsTyping:t=>{this.send({type:3,isTyping:t})},closeCombobox:()=>{var t,n;this.send({type:1}),this.send({type:6,value:!1}),(n=(t=this.state.dataRef.current).onClose)==null||n.call(t)},openCombobox:()=>{this.send({type:0}),this.send({type:6,value:!0})},setActivationTrigger:t=>{this.send({type:7,trigger:t})},selectActiveOption:()=>{let t=this.selectors.activeOptionIndex(this.state);if(t!==null){if(this.actions.setIsTyping(!1),this.state.virtual)this.actions.onChange(this.state.virtual.options[t]);else{let{dataRef:n}=this.state.options[t];this.actions.onChange(n.current.value)}this.actions.goToOption({focus:V.Specific,idx:t})}},setInputElement:t=>{this.send({type:9,element:t})},setButtonElement:t=>{this.send({type:10,element:t})},setOptionsElement:t=>{this.send({type:11,element:t})}}),Le(this,"selectors",{activeDescendantId:t=>{var n,o;let s=this.selectors.activeOptionIndex(t);if(s!==null)return t.virtual?(o=t.options.find(i=>!i.dataRef.current.disabled&&t.dataRef.current.compare(i.dataRef.current.value,t.virtual.options[s])))==null?void 0:o.id:(n=t.options[s])==null?void 0:n.id},activeOptionIndex:t=>{if(t.defaultToFirstOption&&t.activeOptionIndex===null&&(t.virtual?t.virtual.options.length>0:t.options.length>0)){if(t.virtual){let{options:o,disabled:s}=t.virtual,i=o.findIndex(v=>{var c;return!((c=s==null?void 0:s(v))!=null&&c)});if(i!==-1)return i}let n=t.options.findIndex(o=>!o.dataRef.current.disabled);if(n!==-1)return n}return t.activeOptionIndex},activeOption:t=>{var n,o;let s=this.selectors.activeOptionIndex(t);return s===null?null:t.virtual?t.virtual.options[s??0]:(o=(n=t.options[s])==null?void 0:n.dataRef.current.value)!=null?o:null},isActive:(t,n,o)=>{var s;let i=this.selectors.activeOptionIndex(t);return i===null?!1:t.virtual?i===t.dataRef.current.calculateIndex(n):((s=t.options[i])==null?void 0:s.id)===o},shouldScrollIntoView:(t,n,o)=>!(t.virtual||t.__demoMode||t.comboboxState!==0||t.activationTrigger===0||!this.selectors.isActive(t,n,o)),didInputMove(t){return t.inputPositionState.kind==="Moved"}});{let t=this.state.id,n=Be.get(null);this.disposables.add(n.on(st.Push,o=>{!n.selectors.isTop(o,t)&&this.state.comboboxState===0&&this.actions.closeCombobox()})),this.on(0,()=>n.actions.push(t)),this.on(1,()=>n.actions.pop(t))}this.disposables.group(t=>{this.on(1,n=>{n.inputElement&&(t.dispose(),t.add(Wt(n.inputElement,n.inputPositionState,()=>{this.send({type:12})})))})})}static new({id:a,virtual:t=null,__demoMode:n=!1}){var o;return new Oe({id:a,dataRef:{current:{}},comboboxState:n?0:1,isTyping:!1,options:[],virtual:t?{options:t.options,disabled:(o=t.disabled)!=null?o:()=>!1}:null,activeOptionIndex:null,activationTrigger:2,inputElement:null,buttonElement:null,optionsElement:null,__demoMode:n,inputPositionState:de.Idle})}reduce(a,t){return le(t.type,Pa,a,t)}}const qe=d.createContext(null);function fe(e){let a=d.useContext(qe);if(a===null){let t=new Error(`<${e} /> is missing a parent component.`);throw Error.captureStackTrace&&Error.captureStackTrace(t,We),t}return a}function We({id:e,virtual:a=null,__demoMode:t=!1}){let n=d.useMemo(()=>Oe.new({id:e,virtual:a,__demoMode:t}),[]);return it(()=>n.dispose()),n}let pe=d.createContext(null);pe.displayName="ComboboxDataContext";function ie(e){let a=d.useContext(pe);if(a===null){let t=new Error(`<${e} /> is missing a parent component.`);throw Error.captureStackTrace&&Error.captureStackTrace(t,ie),t}return a}let Ye=d.createContext(null);function Ea(e){let a=fe("VirtualProvider"),t=ie("VirtualProvider"),{options:n}=t.virtual,o=B(a,b=>b.optionsElement),[s,i]=d.useMemo(()=>{let b=o;if(!b)return[0,0];let p=window.getComputedStyle(b);return[parseFloat(p.paddingBlockStart||p.paddingTop),parseFloat(p.paddingBlockEnd||p.paddingBottom)]},[o]),v=Ut({enabled:n.length!==0,scrollPaddingStart:s,scrollPaddingEnd:i,count:n.length,estimateSize(){return 40},getScrollElement(){return a.state.optionsElement},overscan:12}),[c,m]=d.useState(0);te(()=>{m(b=>b+1)},[n]);let g=v.getVirtualItems(),y=B(a,b=>b.activationTrigger===ee.Pointer),h=B(a,a.selectors.activeOptionIndex);return g.length===0?null:G.createElement(Ye.Provider,{value:v},G.createElement("div",{style:{position:"relative",width:"100%",height:`${v.getTotalSize()}px`},ref:b=>{b&&(y||h!==null&&n.length>h&&v.scrollToIndex(h))}},g.map(b=>{var p;return G.createElement(d.Fragment,{key:b.key},G.cloneElement((p=e.children)==null?void 0:p.call(e,{...e.slot,option:n[b.index]}),{key:`${c}-${b.key}`,"data-index":b.index,"aria-setsize":n.length,"aria-posinset":b.index+1,style:{position:"absolute",top:0,left:0,transform:`translateY(${b.start}px)`,overflowAnchor:"none"}}))})))}let Ta=d.Fragment;function Ra(e,a){let t=d.useId(),n=Et(),{value:o,defaultValue:s,onChange:i,form:v,name:c,by:m,invalid:g=!1,disabled:y=n||!1,onClose:h,__demoMode:b=!1,multiple:p=!1,immediate:P=!1,virtual:r=null,nullable:M,...A}=e,E=Tt(s),[T=p?[]:void 0,z]=Rt(o,i,E),S=We({id:t,virtual:r,__demoMode:b}),_=d.useRef({static:!1,hold:!1}),I=ta(m),F=D($=>r?m===null?r.options.indexOf($):r.options.findIndex(ae=>I(ae,$)):S.state.options.findIndex(ae=>I(ae.dataRef.current.value,$))),q=d.useCallback($=>le(w.mode,{[J.Multi]:()=>T.some(ae=>I(ae,$)),[J.Single]:()=>I(T,$)}),[T]),Y=B(S,$=>$.virtual),C=D(()=>h==null?void 0:h()),w=d.useMemo(()=>({__demoMode:b,immediate:P,optionsPropsRef:_,value:T,defaultValue:E,disabled:y,invalid:g,mode:p?J.Multi:J.Single,virtual:r?Y:null,onChange:z,isSelected:q,calculateIndex:F,compare:I,onClose:C}),[b,P,_,T,E,y,g,p,r,Y,z,q,F,I,C]);te(()=>{var $;r&&S.send({type:Ge.UpdateVirtualConfiguration,options:r.options,disabled:($=r.disabled)!=null?$:null})},[r,r==null?void 0:r.options,r==null?void 0:r.disabled]),te(()=>{S.state.dataRef.current=w},[w]);let[H,O,u,R]=B(S,$=>[$.comboboxState,$.buttonElement,$.inputElement,$.optionsElement]),N=Be.get(null),Q=B(N,d.useCallback($=>N.selectors.isTop($,t),[N,t]));$t(Q,[O,u,R],()=>S.actions.closeCombobox());let Z=B(S,S.selectors.activeOptionIndex),re=B(S,S.selectors.activeOption),f=be({open:H===x.Open,disabled:y,invalid:g,activeIndex:Z,activeOption:re,value:T}),[X,k]=wt(),U=a===null?{}:{ref:a},j=d.useCallback(()=>{if(E!==void 0)return z==null?void 0:z(E)},[z,E]),K=ve();return G.createElement(k,{value:X,props:{htmlFor:u==null?void 0:u.id},slot:{open:H===x.Open,disabled:y}},G.createElement(la,null,G.createElement(pe.Provider,{value:w},G.createElement(qe.Provider,{value:S},G.createElement(jt,{value:le(H,{[x.Open]:ge.Open,[x.Closed]:ge.Closed})},c!=null&&G.createElement(It,{disabled:y,data:T!=null?{[c]:T}:{},form:v,onReset:j}),K({ourProps:U,theirProps:A,slot:f,defaultTag:Ta,name:"Combobox"}))))))}let $a="input";function wa(e,a){var t,n;let o=fe("Combobox.Input"),s=ie("Combobox.Input"),i=d.useId(),v=ut(),{id:c=v||`headlessui-combobox-input-${i}`,onChange:m,displayValue:g,disabled:y=s.disabled||!1,autoFocus:h=!1,type:b="text",...p}=e,P=d.useRef(null),r=xe(P,a,aa(),o.actions.setInputElement),[M,A]=B(o,f=>[f.comboboxState,f.isTyping]),E=ct(),T=D(()=>{o.actions.onChange(null),o.state.optionsElement&&(o.state.optionsElement.scrollTop=0),o.actions.goToOption({focus:V.Nothing})}),z=d.useMemo(()=>{var f;return typeof g=="function"&&s.value!==void 0?(f=g(s.value))!=null?f:"":typeof s.value=="string"?s.value:""},[s.value,g]);Ee(([f,X],[k,U])=>{if(o.state.isTyping)return;let j=P.current;j&&((U===x.Open&&X===x.Closed||f!==k)&&(j.value=f),requestAnimationFrame(()=>{if(o.state.isTyping||!j||Ve(j))return;let{selectionStart:K,selectionEnd:$}=j;Math.abs(($??0)-(K??0))===0&&K===0&&j.setSelectionRange(j.value.length,j.value.length)}))},[z,M,A]),Ee(([f],[X])=>{if(f===x.Open&&X===x.Closed){if(o.state.isTyping)return;let k=P.current;if(!k)return;let U=k.value,{selectionStart:j,selectionEnd:K,selectionDirection:$}=k;k.value="",k.value=U,$!==null?k.setSelectionRange(j,K,$):k.setSelectionRange(j,K)}},[M]);let S=d.useRef(!1),_=D(()=>{S.current=!0}),I=D(()=>{E.nextFrame(()=>{S.current=!1})}),F=D(f=>{switch(o.actions.setIsTyping(!0),f.key){case W.Enter:if(o.state.comboboxState!==x.Open||S.current)return;if(f.preventDefault(),f.stopPropagation(),o.selectors.activeOptionIndex(o.state)===null){o.actions.closeCombobox();return}o.actions.selectActiveOption(),s.mode===J.Single&&o.actions.closeCombobox();break;case W.ArrowDown:return f.preventDefault(),f.stopPropagation(),le(o.state.comboboxState,{[x.Open]:()=>o.actions.goToOption({focus:V.Next}),[x.Closed]:()=>o.actions.openCombobox()});case W.ArrowUp:return f.preventDefault(),f.stopPropagation(),le(o.state.comboboxState,{[x.Open]:()=>o.actions.goToOption({focus:V.Previous}),[x.Closed]:()=>{se.flushSync(()=>o.actions.openCombobox()),s.value||o.actions.goToOption({focus:V.Last})}});case W.Home:if(o.state.comboboxState===x.Closed||f.shiftKey)break;return f.preventDefault(),f.stopPropagation(),o.actions.goToOption({focus:V.First});case W.PageUp:return f.preventDefault(),f.stopPropagation(),o.actions.goToOption({focus:V.First});case W.End:if(o.state.comboboxState===x.Closed||f.shiftKey)break;return f.preventDefault(),f.stopPropagation(),o.actions.goToOption({focus:V.Last});case W.PageDown:return f.preventDefault(),f.stopPropagation(),o.actions.goToOption({focus:V.Last});case W.Escape:return o.state.comboboxState!==x.Open?void 0:(f.preventDefault(),o.state.optionsElement&&!s.optionsPropsRef.current.static&&f.stopPropagation(),s.mode===J.Single&&s.value===null&&T(),o.actions.closeCombobox());case W.Tab:if(o.actions.setIsTyping(!1),o.state.comboboxState!==x.Open)return;s.mode===J.Single&&o.state.activationTrigger!==ee.Focus&&o.actions.selectActiveOption(),o.actions.closeCombobox();break}}),q=D(f=>{m==null||m(f),s.mode===J.Single&&f.target.value===""&&T(),o.actions.openCombobox()}),Y=D(f=>{var X,k,U;let j=(X=f.relatedTarget)!=null?X:Te.find(K=>K!==f.currentTarget);if(!((k=o.state.optionsElement)!=null&&k.contains(j))&&!((U=o.state.buttonElement)!=null&&U.contains(j))&&o.state.comboboxState===x.Open)return f.preventDefault(),s.mode===J.Single&&s.value===null&&T(),o.actions.closeCombobox()}),C=D(f=>{var X,k,U;let j=(X=f.relatedTarget)!=null?X:Te.find(K=>K!==f.currentTarget);(k=o.state.buttonElement)!=null&&k.contains(j)||(U=o.state.optionsElement)!=null&&U.contains(j)||s.disabled||s.immediate&&o.state.comboboxState!==x.Open&&E.microTask(()=>{se.flushSync(()=>o.actions.openCombobox()),o.actions.setActivationTrigger(ee.Focus)})}),w=Se(),H=dt(),{isFocused:O,focusProps:u}=ze({autoFocus:h}),{isHovered:R,hoverProps:N}=He({isDisabled:y}),Q=B(o,f=>f.optionsElement),Z=be({open:M===x.Open,disabled:y,invalid:s.invalid,hover:R,focus:O,autofocus:h}),re=Ce({ref:r,id:c,role:"combobox",type:b,"aria-controls":Q==null?void 0:Q.id,"aria-expanded":M===x.Open,"aria-activedescendant":B(o,o.selectors.activeDescendantId),"aria-labelledby":w,"aria-describedby":H,"aria-autocomplete":"list",defaultValue:(n=(t=e.defaultValue)!=null?t:s.defaultValue!==void 0?g==null?void 0:g(s.defaultValue):null)!=null?n:s.defaultValue,disabled:y||void 0,autoFocus:h,onCompositionStart:_,onCompositionEnd:I,onKeyDown:F,onChange:q,onFocus:C,onBlur:Y},u,N);return ve()({ourProps:re,theirProps:p,slot:Z,defaultTag:$a,name:"Combobox.Input"})}let ja="button";function Ia(e,a){let t=fe("Combobox.Button"),n=ie("Combobox.Button"),[o,s]=d.useState(null),i=xe(a,s,t.actions.setButtonElement),v=d.useId(),{id:c=`headlessui-combobox-button-${v}`,disabled:m=n.disabled||!1,autoFocus:g=!1,...y}=e,[h,b,p]=B(t,C=>[C.comboboxState,C.inputElement,C.optionsElement]),P=Ke(b),r=h===x.Open;Xt(r,{trigger:o,action:d.useCallback(C=>{if(o!=null&&o.contains(C.target))return ue.Ignore;if(b!=null&&b.contains(C.target))return ue.Ignore;let w=C.target.closest('[role="option"]:not([data-disabled])');return pt(w)?ue.Select(w):p!=null&&p.contains(C.target)?ue.Ignore:ue.Close},[o,b,p]),close:t.actions.closeCombobox,select:t.actions.selectActiveOption});let M=D(C=>{switch(C.key){case W.Space:case W.Enter:C.preventDefault(),C.stopPropagation(),t.state.comboboxState===x.Closed&&se.flushSync(()=>t.actions.openCombobox()),P();return;case W.ArrowDown:C.preventDefault(),C.stopPropagation(),t.state.comboboxState===x.Closed&&(se.flushSync(()=>t.actions.openCombobox()),t.state.dataRef.current.value||t.actions.goToOption({focus:V.First})),P();return;case W.ArrowUp:C.preventDefault(),C.stopPropagation(),t.state.comboboxState===x.Closed&&(se.flushSync(()=>t.actions.openCombobox()),t.state.dataRef.current.value||t.actions.goToOption({focus:V.Last})),P();return;case W.Escape:if(t.state.comboboxState!==x.Open)return;C.preventDefault(),t.state.optionsElement&&!n.optionsPropsRef.current.static&&C.stopPropagation(),se.flushSync(()=>t.actions.closeCombobox()),P();return;default:return}}),A=Jt(()=>{t.state.comboboxState===x.Open?t.actions.closeCombobox():t.actions.openCombobox(),P()}),E=Se([c]),{isFocusVisible:T,focusProps:z}=ze({autoFocus:g}),{isHovered:S,hoverProps:_}=He({isDisabled:m}),{pressed:I,pressProps:F}=mt({disabled:m}),q=be({open:h===x.Open,active:I||h===x.Open,disabled:m,invalid:n.invalid,value:n.value,hover:S,focus:T}),Y=Ce({ref:i,id:c,type:bt(e,o),tabIndex:-1,"aria-haspopup":"listbox","aria-controls":p==null?void 0:p.id,"aria-expanded":h===x.Open,"aria-labelledby":E,disabled:m||void 0,autoFocus:g,onKeyDown:M},A,z,_,F);return ve()({ourProps:Y,theirProps:y,slot:q,defaultTag:ja,name:"Combobox.Button"})}let Na="div",ka=$e.RenderStrategy|$e.Static;function Ma(e,a){var t,n,o;let s=d.useId(),{id:i=`headlessui-combobox-options-${s}`,hold:v=!1,anchor:c,portal:m=!1,modal:g=!0,transition:y=!1,...h}=e,b=fe("Combobox.Options"),p=ie("Combobox.Options"),P=oa(c);P&&(m=!0);let[r,M]=na(P),[A,E]=d.useState(null),T=sa(),z=xe(a,P?r:null,b.actions.setOptionsElement,E),[S,_,I,F,q]=B(b,L=>[L.comboboxState,L.inputElement,L.buttonElement,L.optionsElement,L.activationTrigger]),Y=Re(_||I),C=Re(F),w=vt(),[H,O]=ft(y,A,w!==null?(w&ge.Open)===ge.Open:S===x.Open);gt(H,_,b.actions.closeCombobox);let u=p.__demoMode?!1:g&&S===x.Open;xt(u,C);let R=p.__demoMode?!1:g&&S===x.Open;ht(R,{allowed:d.useCallback(()=>[_,I,F],[_,I,F])});let N=B(b,b.selectors.didInputMove)?!1:H;te(()=>{var L;p.optionsPropsRef.current.static=(L=e.static)!=null?L:!1},[p.optionsPropsRef,e.static]),te(()=>{p.optionsPropsRef.current.hold=v},[p.optionsPropsRef,v]),Sa(S===x.Open,{container:F,accept(L){return L.getAttribute("role")==="option"?NodeFilter.FILTER_REJECT:L.hasAttribute("role")?NodeFilter.FILTER_SKIP:NodeFilter.FILTER_ACCEPT},walk(L){L.setAttribute("role","none")}});let Q=Se([I==null?void 0:I.id]),Z=be({open:S===x.Open,option:void 0}),re=D(()=>{b.actions.setActivationTrigger(ee.Pointer)}),f=D(L=>{L.preventDefault(),b.actions.setActivationTrigger(ee.Pointer)}),X=Ce(P?T():{},{"aria-labelledby":Q,role:"listbox","aria-multiselectable":p.mode===J.Multi?!0:void 0,id:i,ref:z,style:{...h.style,...M,"--input-width":Ae(H,_,!0).width,"--button-width":Ae(H,I,!0).width},onWheel:q===ee.Pointer?void 0:re,onMouseDown:f,...yt(O)}),k=H&&S===x.Closed&&!e.static,U=De(k,(t=p.virtual)==null?void 0:t.options),j=De(k,p.value),K=d.useCallback(L=>p.compare(j,L),[p.compare,j]),$=d.useMemo(()=>{if(!p.virtual)return p;if(U===void 0)throw new Error("Missing `options` in virtual mode");return U!==p.virtual.options?{...p,virtual:{...p.virtual,options:U}}:p},[p,U,(n=p.virtual)==null?void 0:n.options]);p.virtual&&Object.assign(h,{children:G.createElement(pe.Provider,{value:$},G.createElement(Ea,{slot:Z},h.children))});let ae=ve(),tt=d.useMemo(()=>p.mode===J.Multi?p:{...p,isSelected:K},[p,K]);return G.createElement(St,{enabled:m?e.static||H:!1,ownerDocument:Y},G.createElement(pe.Provider,{value:tt},ae({ourProps:X,theirProps:{...h,children:G.createElement(Qt,{freeze:k},typeof h.children=="function"?(o=h.children)==null?void 0:o.call(h,Z):h.children)},slot:Z,defaultTag:Na,features:ka,visible:N,name:"Combobox.Options"})))}let Fa="div";function Da(e,a){var t,n,o;let s=ie("Combobox.Option"),i=fe("Combobox.Option"),v=d.useId(),{id:c=`headlessui-combobox-option-${v}`,value:m,disabled:g=(o=(n=(t=s.virtual)==null?void 0:t.disabled)==null?void 0:n.call(t,m))!=null?o:!1,order:y=null,...h}=e,[b]=B(i,O=>[O.inputElement]),p=Ke(b),P=B(i,d.useCallback(O=>i.selectors.isActive(O,m,c),[m,c])),r=s.isSelected(m),M=d.useRef(null),A=Ct({disabled:g,value:m,domRef:M,order:y}),E=d.useContext(Ye),T=xe(a,M,E?E.measureElement:null),z=D(()=>{i.actions.setIsTyping(!1),i.actions.onChange(m)});te(()=>i.actions.registerOption(c,A),[A,c]);let S=B(i,d.useCallback(O=>i.selectors.shouldScrollIntoView(O,m,c),[m,c]));te(()=>{if(S)return Ot().requestAnimationFrame(()=>{var O,u;(u=(O=M.current)==null?void 0:O.scrollIntoView)==null||u.call(O,{block:"nearest"})})},[S,M]);let _=D(O=>{O.preventDefault(),O.button===Zt.Left&&(g||(z(),Pt()||requestAnimationFrame(()=>p()),s.mode===J.Single&&i.actions.closeCombobox()))}),I=D(()=>{if(g)return i.actions.goToOption({focus:V.Nothing});let O=s.calculateIndex(m);i.actions.goToOption({focus:V.Specific,idx:O})}),F=ea(),q=D(O=>F.update(O)),Y=D(O=>{if(!F.wasMoved(O)||g||P&&i.state.activationTrigger===ee.Pointer)return;let u=s.calculateIndex(m);i.actions.goToOption({focus:V.Specific,idx:u},ee.Pointer)}),C=D(O=>{F.wasMoved(O)&&(g||P&&(s.optionsPropsRef.current.hold||i.state.activationTrigger===ee.Pointer&&i.actions.goToOption({focus:V.Nothing})))}),w=be({active:P,focus:P,selected:r,disabled:g}),H={id:c,ref:T,role:"option",tabIndex:g===!0?void 0:-1,"aria-disabled":g===!0?!0:void 0,"aria-selected":r,disabled:void 0,onMouseDown:_,onFocus:I,onPointerEnter:q,onMouseEnter:q,onPointerMove:Y,onMouseMove:Y,onPointerLeave:C,onMouseLeave:C};return ve()({ourProps:H,theirProps:h,slot:w,defaultTag:Fa,name:"Combobox.Option"})}let Aa=me(Ra),Xe=me(Ia),Je=me(wa),_a=rt,Qe=me(Ma),Ze=me(Da),La=Object.assign(Aa,{Input:Je,Button:Xe,Label:_a,Options:Qe,Option:Ze});function Va({options:e,value:a,onChange:t,defaultValue:n,displayValue:o,filter:s,placeholder:i,disabled:v,invalid:c,name:m,"aria-label":g,className:y,children:h}){const[b,p]=d.useState(""),P=o??(E=>E!=null?String(E):""),M=s??((E,T)=>P(E).toLowerCase().includes(T.toLowerCase())),A=d.useMemo(()=>b?e.filter(E=>M(E,b)):e,[e,b,M]);return l.jsx(La,{value:a,onChange:t,defaultValue:n,disabled:v,name:m,onClose:()=>p(""),children:l.jsxs("div",{className:ne("relative",y),children:[l.jsxs("div",{className:"relative",children:[l.jsx(Je,{"aria-label":g,displayValue:P,onChange:E=>p(E.target.value),placeholder:i,className:ne(["w-full radius-inner py-2 pl-3 pr-10","text-sm text-fg-primary placeholder:text-fg-muted","bg-input-bg",c?"border border-sys-red":"border border-input-border","ring-focus-inset","hover:border-edge-strong","disabled:opacity-40 disabled:pointer-events-none disabled:cursor-not-allowed","transition-colors"])}),l.jsx(Xe,{className:"absolute inset-y-0 right-0 flex items-center pr-3 group",children:l.jsx(Nt,{className:"w-4 h-4 text-fg-muted transition-transform duration-200 group-data-[open]:rotate-180"})})]}),l.jsx(Qe,{anchor:"bottom start",transition:!0,className:ne(["w-[var(--input-width)] min-w-[180px]","max-h-60 overflow-y-auto overscroll-contain scroll-py-1","radius-inset p-1 mt-1","surface-elevated","focus:outline-none","transition-opacity","data-[closed]:opacity-0","data-[enter]:duration-150 data-[leave]:duration-100","z-50"]),children:A.length===0&&b!==""?l.jsx("div",{className:"px-3 py-2 text-sm text-fg-muted",children:"No results found"}):A.map((E,T)=>l.jsx(d.Fragment,{children:h(E)},T))})]})})}function Ba({value:e,disabled:a,className:t,children:n}){return l.jsx(Ze,{as:d.Fragment,value:e,disabled:a,children:({selected:o,focus:s})=>l.jsxs("div",{className:ne("flex items-center gap-2 px-3 py-2 radius-control cursor-default","text-sm",s&&"bg-sys-blue text-white",!s&&"text-fg-primary",o&&!s&&"text-sys-blue",a&&"opacity-50 cursor-not-allowed",t),children:[l.jsx("span",{className:"w-4 flex-shrink-0",children:o&&l.jsx(kt,{className:"w-4 h-4"})}),l.jsx("span",{className:"truncate flex-1",children:n})]})})}function za({className:e,...a}){return l.jsx("span",{...a,className:ne("truncate",e)})}function oe({value:e,onChange:a,options:t,placeholder:n,disabled:o,className:s,"aria-label":i}){const v=t.find(c=>c.value===e);return l.jsx(Va,{options:t,value:v,onChange:c=>{c&&a(c.value)},displayValue:c=>(c==null?void 0:c.label)??"",filter:(c,m)=>c.label.toLowerCase().includes(m.toLowerCase()),placeholder:n,disabled:o,className:s,"aria-label":i,children:c=>l.jsx(Ba,{value:c,disabled:c.disabled,children:l.jsx(za,{children:c.label})})})}const et=[{target:"PacketStats",fn:"type",minStage:1}];ma(et);function ce({icon:e,label:a,value:t,color:n,percentage:o}){return l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("div",{className:ne("p-1.5 rounded-md",n),children:e}),l.jsxs("div",{className:"flex flex-col",children:[l.jsx("span",{className:"text-sm font-semibold text-fg-primary",children:t.toLocaleString()}),l.jsxs("span",{className:"text-xs text-fg-muted leading-tight",children:[a,o!==void 0&&l.jsxs("span",{className:"ml-1 opacity-70",children:["(",o,"%)"]})]})]})]})}function Ha({packets:e}){pa(et);const a=d.useMemo(()=>{let t=0,n=0,o=0;const s=new Set;let i=0,v=0;for(const y of e){switch(Ue(y)){case"forward":t++;break;case"dropped":n++;break;case"duplicate":o++;break}y.src_hash&&s.add(y.src_hash),y.rssi&&(i+=y.rssi,v++)}const c=e.length,m=v>0?Math.round(i/v):0;return{total:c,rx:c,fwd:t,dropped:n,duplicate:o,uniqueSources:s.size,avgRssi:m,rxPercent:100,fwdPercent:c>0?Math.round(t/c*100):0,droppedPercent:c>0?Math.round(n/c*100):0}},[e]);return e.length===0?null:l.jsx("div",{className:"surface-base depth-raised rounded-2xl p-3 pr-4",children:l.jsxs("div",{className:"grid grid-cols-2 gap-3 sm:flex sm:items-center sm:justify-between sm:gap-6",children:[l.jsx(ce,{icon:l.jsx(ba,{className:"w-3.5 h-3.5 text-sys-blue"}),label:"Received",value:a.rx,color:"bg-sys-blue/10",percentage:a.rxPercent}),l.jsx(ce,{icon:l.jsx(va,{className:"w-3.5 h-3.5 text-sys-green"}),label:"Forwarded",value:a.fwd,color:"bg-sys-green/10",percentage:a.fwdPercent}),l.jsx(ce,{icon:l.jsx(Kt,{className:"w-3.5 h-3.5 text-sys-red"}),label:"Dropped",value:a.dropped,color:"bg-sys-red/10",percentage:a.droppedPercent}),l.jsx(ce,{icon:l.jsx(Mt,{className:"w-3.5 h-3.5 text-fg-muted"}),label:"Duplicates",value:a.duplicate,color:"bg-subtle-fill"}),l.jsxs("div",{className:"hidden sm:flex items-center gap-6 ml-auto",children:[l.jsx(ce,{icon:l.jsx(Ft,{className:"w-3.5 h-3.5 text-sys-indigo"}),label:"Sources",value:a.uniqueSources,color:"bg-sys-indigo/10"}),l.jsxs("div",{className:"flex flex-col items-end pr-1",children:[l.jsxs("span",{className:"type-data-sm text-fg-secondary",children:[a.avgRssi," dBm"]}),l.jsx("span",{className:"text-xs text-fg-muted",children:"Avg Signal"})]})]})]})})}const Ua=d.memo(Ha);function Po(){const e=Dt(),a=At(),t=ia(),n=Gt(u=>u.requestChannel),o=_t(),s=a==null?void 0:a.local_hash,i=a==null?void 0:a.neighbors,v=Lt(),c=Vt(),g=Bt().isBackgroundLoading&&v>=5,[y,h]=d.useState(!1),[b,p]=d.useState(!0),P=d.useCallback(u=>p(u),[]),[r,M]=d.useState({limit:500,status:"all"}),[A,E]=d.useState(ua),T=d.useMemo(()=>{const u=Math.floor(Date.now()/1e3),R=we[v].minutes;return{start:u-R*60,end:u}},[v]),z=d.useMemo(()=>{const u=(a==null?void 0:a.neighbors)??{};return Object.fromEntries(Object.entries(u).filter(([R])=>!o.has(R)))},[a==null?void 0:a.neighbors,o]),S=ra(),[_,I]=d.useState(Date.now);d.useEffect(()=>{r.timeRange&&r.timeRange>0&&queueMicrotask(()=>I(Date.now()))},[r.timeRange,e]);const F=d.useMemo(()=>ca(e,A,S,T),[e,A,S,T]),q=d.useMemo(()=>{const u=r.limit??500;return[...F.length<=u?F:F.slice(-u)].sort((N,Q)=>(Q.timestamp??0)-(N.timestamp??0))},[F,r.limit]),Y=e.length===0,C=d.useMemo(()=>{let u=q;if(r.type!==void 0){const R=je[r.type];u=u.filter(N=>{const Q=N.type??N.payload_type,Z=N.payload_type_name;return Q===r.type||Z===R})}if(r.route!==void 0){const R=Ie[r.route];u=u.filter(N=>{const Q=N.route??N.route_type,Z=N.route_type_name;return Q===r.route||Z===R})}if(r.status&&r.status!=="all"&&(u=u.filter(R=>Ue(R)===r.status)),r.signalMin!==void 0&&(u=u.filter(R=>R.rssi>=r.signalMin)),r.timeRange&&r.timeRange>0){const R=_/1e3-r.timeRange*3600;u=u.filter(N=>N.timestamp>=R)}return u},[q,r.type,r.route,r.status,r.signalMin,r.timeRange,_]),w=(u,R)=>M(N=>({...N,[u]:R})),H=()=>M({limit:r.limit,status:"all"}),O=r.type!==void 0||r.route!==void 0||r.status&&r.status!=="all"||r.signalMin!==void 0||r.timeRange&&r.timeRange>0;return l.jsxs(fa,{children:[l.jsx(ga,{title:"Packet History",icon:l.jsx(ke,{}),controls:l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsxs(Ne,{outline:!0,color:O?"primary":"muted",onClick:()=>h(!y),className:"sm:hidden",children:[l.jsx(_e,{"data-slot":"icon"}),O&&l.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-sys-blue"})]}),l.jsx(ha,{ranges:we,selectedIndex:v,onSelect:c,isPending:g})]})}),l.jsxs(xa,{children:[l.jsx(ya,{template:"auto",className:"relative z-10",children:l.jsx(he,{neomorphic:!0,className:"overflow-visible",children:l.jsx(da,{parentStartTs:T.start,parentEndTs:T.end,neighbors:z,filter:A,onChange:E})})}),l.jsxs(he,{neomorphic:!0,noPadding:!0,className:ne("overflow-hidden transition-all duration-200",y?"max-h-96 opacity-100":"max-h-0 opacity-0 sm:max-h-96 sm:opacity-100"),children:[l.jsx(Me,{listHeader:!0,icon:l.jsx(_e,{className:"icon-sm"}),title:"Filters",actions:O?l.jsxs(Ne,{plain:!0,color:"muted",onClick:H,className:"!text-xs !py-0.5 !px-1.5",children:[l.jsx(zt,{"data-slot":"icon",className:"!w-3 !h-3"}),"Clear"]}):void 0}),l.jsx("div",{className:"p-3 sm:p-4",children:l.jsxs("div",{className:"grid grid-cols-2 sm:flex sm:flex-wrap gap-3",children:[l.jsxs("div",{className:"flex-1 min-w-[140px]",children:[l.jsx("label",{className:"type-micro block mb-1",children:"Type"}),l.jsx(oe,{value:r.type??"",onChange:u=>w("type",u===""?void 0:Number(u)),options:[{value:"",label:"All Types"},...Object.entries(je).map(([u,R])=>({value:Number(u),label:R}))],placeholder:"Search types...","aria-label":"Filter by packet type"})]}),l.jsxs("div",{className:"flex-1 min-w-[140px]",children:[l.jsx("label",{className:"type-micro block mb-1",children:"Route"}),l.jsx(oe,{value:r.route??"",onChange:u=>w("route",u===""?void 0:Number(u)),options:[{value:"",label:"All Routes"},...Object.entries(Ie).map(([u,R])=>({value:Number(u),label:R}))],placeholder:"Search routes...","aria-label":"Filter by route type"})]}),l.jsxs("div",{className:"flex-1 min-w-[140px]",children:[l.jsx("label",{className:"type-micro block mb-1",children:"Status"}),l.jsx(oe,{value:r.status??"all",onChange:u=>w("status",u),options:[{value:"all",label:"All Status"},{value:"rx",label:"Received"},{value:"forward",label:"Forwarded"},{value:"dropped",label:"Dropped"},{value:"duplicate",label:"Duplicate"}],placeholder:"Search status...","aria-label":"Filter by status"})]}),l.jsxs("div",{className:"flex-1 min-w-[120px]",children:[l.jsx("label",{className:"type-micro block mb-1",children:"Time"}),l.jsx(oe,{value:r.timeRange??0,onChange:u=>w("timeRange",u===0?void 0:u),options:[{value:0,label:"All Time"},{value:1,label:"Last 1h"},{value:6,label:"Last 6h"},{value:24,label:"Last 24h"},{value:168,label:"Last 7d"}],placeholder:"Search time...","aria-label":"Filter by time range"})]}),l.jsxs("div",{className:"flex-1 min-w-[130px]",children:[l.jsx("label",{className:"type-micro block mb-1",children:"Signal"}),l.jsx(oe,{value:r.signalMin??"",onChange:u=>w("signalMin",u===""?void 0:Number(u)),options:[{value:"",label:"Any Signal"},{value:-90,label:"Strong (≥-90)"},{value:-100,label:"Good (≥-100)"},{value:-110,label:"Fair (≥-110)"},{value:-120,label:"Weak (≥-120)"}],placeholder:"Search signal...","aria-label":"Filter by signal strength"})]}),l.jsxs("div",{className:"flex-1 min-w-[100px]",children:[l.jsx("label",{className:"type-micro block mb-1",children:"Limit"}),l.jsx(oe,{value:r.limit??500,onChange:u=>w("limit",u),options:[{value:100,label:"100"},{value:200,label:"200"},{value:500,label:"500"},{value:1e3,label:"1K"},{value:2e3,label:"2K"},{value:5e3,label:"5K"},{value:1e4,label:"10K"}],placeholder:"Limit...","aria-label":"Packet limit"})]}),l.jsxs("div",{className:"flex-1 min-w-[100px]",children:[l.jsx("label",{className:"type-micro block mb-1",children:"Per Page"}),l.jsx(oe,{value:r.perPage??50,onChange:u=>w("perPage",u),options:[{value:25,label:"25"},{value:50,label:"50"},{value:100,label:"100"},{value:200,label:"200"},{value:500,label:"500"}],placeholder:"Per page...","aria-label":"Packets per page"})]})]})})]}),l.jsx(Ua,{packets:C}),l.jsxs(he,{neomorphic:!0,noPadding:!0,className:"!overflow-visible",children:[l.jsx(Me,{listHeader:!0,icon:l.jsx(ke,{className:"icon-sm"}),title:"Packet History",actions:l.jsx(Ht,{enabled:b,onChange:P,label:"Hide Dupes",size:"sm"})}),l.jsx(qt,{packets:C,allPackets:e,localHash:s,neighbors:i,resolveSource:S,getDecodedContent:t,onChannelClick:n,loading:Y,showPagination:!0,perPage:r.perPage??50,hideDupes:b,emptyMessage:"No packets found"})]})]})]})}export{Po as default}; +import{r as d,am as D,an as at,ao as Ve,ap as Pe,aq as te,ar as ot,as as nt,at as le,au as ze,av as st,aw as lt,ax as it,ay as me,az as rt,aA as ut,aB as xe,aC as z,aD as ct,aE as Ee,aF as W,aG as se,aH as Te,aI as Se,aJ as dt,aK as Be,aL as He,aM as be,aN as Ce,aO as ve,aP as pt,aQ as mt,aR as bt,aS as Re,aT as vt,aU as ft,aV as ge,aW as gt,aX as xt,aY as ht,aZ as yt,a_ as K,a$ as St,b0 as Ct,b1 as Ot,b2 as Pt,b3 as Et,b4 as Tt,b5 as Rt,b6 as $t,b7 as wt,b8 as jt,b9 as It,ba as $e,j as l,c as ne,ai as Nt,y as kt,z as Mt,bb as Ft,D as Dt,G as At,N as _t,O as Lt,ae as Vt,al as zt,P as we,bc as je,bd as Ie,B as Ne,be as ke,H as Me,bf as Bt,T as Ht}from"./index-DhkG1Nx9.js";import{b as Ut,g as Ue,a as Gt,u as Kt,P as qt}from"./PacketList-Dd7PQV7H.js";import{c as V,p as Wt,a as de,f as Fe,b as Yt,L as Xt,S as ue,s as Jt,u as De,d as Qt,g as Zt,e as ea,h as ta}from"./element-movement-BPGrReFv.js";import{F as aa,y as oa,R as na,T as sa,w as Ae,A as la}from"./map-pin-BHGohRD7.js";import{useGetDecodedContent as ia,useResolveSource as ra}from"./usePipelineStore-B9ir1Xwp.js";import{c as ua,a as ca,A as da}from"./AnalyzerFilterPanel-CBw2MsnC.js";import{u as pa,r as ma}from"./consumer-registry-CTQIn0m9.js";import{A as ba}from"./arrow-up-Bg1A345J.js";import{A as va}from"./SignalIndicator-DEXVYOhU.js";import{P as fa,a as ga,B as xa,C as he}from"./PageLayout-BkUTZXJb.js";import{T as ha}from"./TimeRangeStepper-RSPVaByt.js";import{F as _e}from"./funnel-Dr2cCUci.js";import{R as ya}from"./Grid-DknC4rR5.js";import"./primitives-nqGDyTiB.js";import"./payload-decoders-DC2sHkKr.js";import"./badge-colors-BNUqIXCA.js";import"./chat-utils-DA-kxQ-o.js";import"./chevron-right-na13OQfy.js";import"./circle-question-mark--xh93QHC.js";import"./triangle-alert-D8NErBXC.js";import"./DataBox-BMesbbaF.js";import"./layers-BxF7oyms.js";import"./hash-KLxvul5e.js";import"./activity-BG24yKp1.js";import"./circle-check-DJNUSJlu.js";import"./database-DE8k8U0g.js";import"./useMapViewStore-BMqcaUNl.js";import"./index-Bx_G2nLG.js";import"./shield-XXZtlreW.js";import"./node-types-CgBRFpS8.js";import"./monitor-smartphone-jV9bAwUA.js";import"./search-BmkxxIVP.js";function Ge(e){let a=d.useRef({value:"",selectionStart:null,selectionEnd:null});return at(e,"blur",t=>{let n=t.target;Pe(n)&&(a.current={value:n.value,selectionStart:n.selectionStart,selectionEnd:n.selectionEnd})}),D(()=>{if(!Ve(e)&&Pe(e)&&e.isConnected){if(e.focus({preventScroll:!0}),e.value!==a.current.value)e.setSelectionRange(e.value.length,e.value.length);else{let{selectionStart:t,selectionEnd:n}=a.current;t!==null&&n!==null&&e.setSelectionRange(t,n)}a.current={value:"",selectionStart:null,selectionEnd:null}}})}function Sa(e,{container:a,accept:t,walk:n}){let o=d.useRef(t),s=d.useRef(n);d.useEffect(()=>{o.current=t,s.current=n},[t,n]),te(()=>{if(!a||!e)return;let i=ot(a);if(!i)return;let v=o.current,c=s.current,m=Object.assign(y=>v(y),{acceptNode:v}),g=i.createTreeWalker(a,NodeFilter.SHOW_ELEMENT,m,!1);for(;g.nextNode();)c(g.currentNode)},[a,e,o,s])}var Ca=Object.defineProperty,Oa=(e,a,t)=>a in e?Ca(e,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[a]=t,Le=(e,a,t)=>(Oa(e,typeof a!="symbol"?a+"":a,t),t),x=(e=>(e[e.Open=0]="Open",e[e.Closed=1]="Closed",e))(x||{}),J=(e=>(e[e.Single=0]="Single",e[e.Multi=1]="Multi",e))(J||{}),ee=(e=>(e[e.Pointer=0]="Pointer",e[e.Focus=1]="Focus",e[e.Other=2]="Other",e))(ee||{}),Ke=(e=>(e[e.OpenCombobox=0]="OpenCombobox",e[e.CloseCombobox=1]="CloseCombobox",e[e.GoToOption=2]="GoToOption",e[e.SetTyping=3]="SetTyping",e[e.RegisterOption=4]="RegisterOption",e[e.UnregisterOption=5]="UnregisterOption",e[e.DefaultToFirstOption=6]="DefaultToFirstOption",e[e.SetActivationTrigger=7]="SetActivationTrigger",e[e.UpdateVirtualConfiguration=8]="UpdateVirtualConfiguration",e[e.SetInputElement=9]="SetInputElement",e[e.SetButtonElement=10]="SetButtonElement",e[e.SetOptionsElement=11]="SetOptionsElement",e[e.MarkInputAsMoved=12]="MarkInputAsMoved",e))(Ke||{});function ye(e,a=t=>t){let t=e.activeOptionIndex!==null?e.options[e.activeOptionIndex]:null,n=a(e.options.slice()),o=n.length>0&&n[0].dataRef.current.order!==null?n.sort((i,v)=>i.dataRef.current.order-v.dataRef.current.order):lt(n,i=>i.dataRef.current.domRef.current),s=t?o.indexOf(t):null;return s===-1&&(s=null),{options:o,activeOptionIndex:s}}let Pa={1(e){var a;if((a=e.dataRef.current)!=null&&a.disabled||e.comboboxState===1)return e;let t=e.inputElement?de.Tracked(Yt(e.inputElement)):e.inputPositionState;return{...e,activeOptionIndex:null,comboboxState:1,isTyping:!1,activationTrigger:2,inputPositionState:t,__demoMode:!1}},0(e){var a,t;if((a=e.dataRef.current)!=null&&a.disabled||e.comboboxState===0)return e;if((t=e.dataRef.current)!=null&&t.value){let n=e.dataRef.current.calculateIndex(e.dataRef.current.value);if(n!==-1)return{...e,activeOptionIndex:n,comboboxState:0,__demoMode:!1,inputPositionState:de.Idle}}return{...e,comboboxState:0,inputPositionState:de.Idle,__demoMode:!1}},3(e,a){return e.isTyping===a.isTyping?e:{...e,isTyping:a.isTyping}},2(e,a){var t,n,o,s;if((t=e.dataRef.current)!=null&&t.disabled||e.optionsElement&&!((n=e.dataRef.current)!=null&&n.optionsPropsRef.current.static)&&e.comboboxState===1)return e;if(e.virtual){let{options:m,disabled:g}=e.virtual,y=a.focus===V.Specific?a.idx:Fe(a,{resolveItems:()=>m,resolveActiveIndex:()=>{var b,p;return(p=(b=e.activeOptionIndex)!=null?b:m.findIndex(P=>!g(P)))!=null?p:null},resolveDisabled:g,resolveId(){throw new Error("Function not implemented.")}}),h=(o=a.trigger)!=null?o:2;return e.activeOptionIndex===y&&e.activationTrigger===h?e:{...e,activeOptionIndex:y,activationTrigger:h,isTyping:!1,__demoMode:!1}}let i=ye(e);if(i.activeOptionIndex===null){let m=i.options.findIndex(g=>!g.dataRef.current.disabled);m!==-1&&(i.activeOptionIndex=m)}let v=a.focus===V.Specific?a.idx:Fe(a,{resolveItems:()=>i.options,resolveActiveIndex:()=>i.activeOptionIndex,resolveId:m=>m.id,resolveDisabled:m=>m.dataRef.current.disabled}),c=(s=a.trigger)!=null?s:2;return e.activeOptionIndex===v&&e.activationTrigger===c?e:{...e,...i,isTyping:!1,activeOptionIndex:v,activationTrigger:c,__demoMode:!1}},4:(e,a)=>{var t,n,o,s;if((t=e.dataRef.current)!=null&&t.virtual)return{...e,options:[...e.options,a.payload]};let i=a.payload,v=ye(e,m=>(m.push(i),m));e.activeOptionIndex===null&&(o=(n=e.dataRef.current).isSelected)!=null&&o.call(n,a.payload.dataRef.current.value)&&(v.activeOptionIndex=v.options.indexOf(i));let c={...e,...v,activationTrigger:2};return(s=e.dataRef.current)!=null&&s.__demoMode&&e.dataRef.current.value===void 0&&(c.activeOptionIndex=0),c},5:(e,a)=>{var t;if((t=e.dataRef.current)!=null&&t.virtual)return{...e,options:e.options.filter(o=>o.id!==a.id)};let n=ye(e,o=>{let s=o.findIndex(i=>i.id===a.id);return s!==-1&&o.splice(s,1),o});return{...e,...n,activationTrigger:2}},6:(e,a)=>e.defaultToFirstOption===a.value?e:{...e,defaultToFirstOption:a.value},7:(e,a)=>e.activationTrigger===a.trigger?e:{...e,activationTrigger:a.trigger},8:(e,a)=>{var t,n;if(e.virtual===null)return{...e,virtual:{options:a.options,disabled:(t=a.disabled)!=null?t:()=>!1}};if(e.virtual.options===a.options&&e.virtual.disabled===a.disabled)return e;let o=e.activeOptionIndex;if(e.activeOptionIndex!==null){let s=a.options.indexOf(e.virtual.options[e.activeOptionIndex]);s!==-1?o=s:o=null}return{...e,activeOptionIndex:o,virtual:{options:a.options,disabled:(n=a.disabled)!=null?n:()=>!1}}},9:(e,a)=>e.inputElement===a.element?e:{...e,inputElement:a.element},10:(e,a)=>e.buttonElement===a.element?e:{...e,buttonElement:a.element},11:(e,a)=>e.optionsElement===a.element?e:{...e,optionsElement:a.element},12(e){return e.inputPositionState.kind!=="Tracked"?e:{...e,inputPositionState:de.Moved}}};class Oe extends nt{constructor(a){super(a),Le(this,"actions",{onChange:t=>{let{onChange:n,compare:o,mode:s,value:i}=this.state.dataRef.current;return le(s,{0:()=>n==null?void 0:n(t),1:()=>{let v=i.slice(),c=v.findIndex(m=>o(m,t));return c===-1?v.push(t):v.splice(c,1),n==null?void 0:n(v)}})},registerOption:(t,n)=>(this.send({type:4,payload:{id:t,dataRef:n}}),()=>{this.state.activeOptionIndex===this.state.dataRef.current.calculateIndex(n.current.value)&&this.send({type:6,value:!0}),this.send({type:5,id:t})}),goToOption:(t,n)=>(this.send({type:6,value:!1}),this.send({type:2,...t,trigger:n})),setIsTyping:t=>{this.send({type:3,isTyping:t})},closeCombobox:()=>{var t,n;this.send({type:1}),this.send({type:6,value:!1}),(n=(t=this.state.dataRef.current).onClose)==null||n.call(t)},openCombobox:()=>{this.send({type:0}),this.send({type:6,value:!0})},setActivationTrigger:t=>{this.send({type:7,trigger:t})},selectActiveOption:()=>{let t=this.selectors.activeOptionIndex(this.state);if(t!==null){if(this.actions.setIsTyping(!1),this.state.virtual)this.actions.onChange(this.state.virtual.options[t]);else{let{dataRef:n}=this.state.options[t];this.actions.onChange(n.current.value)}this.actions.goToOption({focus:V.Specific,idx:t})}},setInputElement:t=>{this.send({type:9,element:t})},setButtonElement:t=>{this.send({type:10,element:t})},setOptionsElement:t=>{this.send({type:11,element:t})}}),Le(this,"selectors",{activeDescendantId:t=>{var n,o;let s=this.selectors.activeOptionIndex(t);if(s!==null)return t.virtual?(o=t.options.find(i=>!i.dataRef.current.disabled&&t.dataRef.current.compare(i.dataRef.current.value,t.virtual.options[s])))==null?void 0:o.id:(n=t.options[s])==null?void 0:n.id},activeOptionIndex:t=>{if(t.defaultToFirstOption&&t.activeOptionIndex===null&&(t.virtual?t.virtual.options.length>0:t.options.length>0)){if(t.virtual){let{options:o,disabled:s}=t.virtual,i=o.findIndex(v=>{var c;return!((c=s==null?void 0:s(v))!=null&&c)});if(i!==-1)return i}let n=t.options.findIndex(o=>!o.dataRef.current.disabled);if(n!==-1)return n}return t.activeOptionIndex},activeOption:t=>{var n,o;let s=this.selectors.activeOptionIndex(t);return s===null?null:t.virtual?t.virtual.options[s??0]:(o=(n=t.options[s])==null?void 0:n.dataRef.current.value)!=null?o:null},isActive:(t,n,o)=>{var s;let i=this.selectors.activeOptionIndex(t);return i===null?!1:t.virtual?i===t.dataRef.current.calculateIndex(n):((s=t.options[i])==null?void 0:s.id)===o},shouldScrollIntoView:(t,n,o)=>!(t.virtual||t.__demoMode||t.comboboxState!==0||t.activationTrigger===0||!this.selectors.isActive(t,n,o)),didInputMove(t){return t.inputPositionState.kind==="Moved"}});{let t=this.state.id,n=ze.get(null);this.disposables.add(n.on(st.Push,o=>{!n.selectors.isTop(o,t)&&this.state.comboboxState===0&&this.actions.closeCombobox()})),this.on(0,()=>n.actions.push(t)),this.on(1,()=>n.actions.pop(t))}this.disposables.group(t=>{this.on(1,n=>{n.inputElement&&(t.dispose(),t.add(Wt(n.inputElement,n.inputPositionState,()=>{this.send({type:12})})))})})}static new({id:a,virtual:t=null,__demoMode:n=!1}){var o;return new Oe({id:a,dataRef:{current:{}},comboboxState:n?0:1,isTyping:!1,options:[],virtual:t?{options:t.options,disabled:(o=t.disabled)!=null?o:()=>!1}:null,activeOptionIndex:null,activationTrigger:2,inputElement:null,buttonElement:null,optionsElement:null,__demoMode:n,inputPositionState:de.Idle})}reduce(a,t){return le(t.type,Pa,a,t)}}const qe=d.createContext(null);function fe(e){let a=d.useContext(qe);if(a===null){let t=new Error(`<${e} /> is missing a parent component.`);throw Error.captureStackTrace&&Error.captureStackTrace(t,We),t}return a}function We({id:e,virtual:a=null,__demoMode:t=!1}){let n=d.useMemo(()=>Oe.new({id:e,virtual:a,__demoMode:t}),[]);return it(()=>n.dispose()),n}let pe=d.createContext(null);pe.displayName="ComboboxDataContext";function ie(e){let a=d.useContext(pe);if(a===null){let t=new Error(`<${e} /> is missing a parent component.`);throw Error.captureStackTrace&&Error.captureStackTrace(t,ie),t}return a}let Ye=d.createContext(null);function Ea(e){let a=fe("VirtualProvider"),t=ie("VirtualProvider"),{options:n}=t.virtual,o=z(a,b=>b.optionsElement),[s,i]=d.useMemo(()=>{let b=o;if(!b)return[0,0];let p=window.getComputedStyle(b);return[parseFloat(p.paddingBlockStart||p.paddingTop),parseFloat(p.paddingBlockEnd||p.paddingBottom)]},[o]),v=Ut({enabled:n.length!==0,scrollPaddingStart:s,scrollPaddingEnd:i,count:n.length,estimateSize(){return 40},getScrollElement(){return a.state.optionsElement},overscan:12}),[c,m]=d.useState(0);te(()=>{m(b=>b+1)},[n]);let g=v.getVirtualItems(),y=z(a,b=>b.activationTrigger===ee.Pointer),h=z(a,a.selectors.activeOptionIndex);return g.length===0?null:K.createElement(Ye.Provider,{value:v},K.createElement("div",{style:{position:"relative",width:"100%",height:`${v.getTotalSize()}px`},ref:b=>{b&&(y||h!==null&&n.length>h&&v.scrollToIndex(h))}},g.map(b=>{var p;return K.createElement(d.Fragment,{key:b.key},K.cloneElement((p=e.children)==null?void 0:p.call(e,{...e.slot,option:n[b.index]}),{key:`${c}-${b.key}`,"data-index":b.index,"aria-setsize":n.length,"aria-posinset":b.index+1,style:{position:"absolute",top:0,left:0,transform:`translateY(${b.start}px)`,overflowAnchor:"none"}}))})))}let Ta=d.Fragment;function Ra(e,a){let t=d.useId(),n=Et(),{value:o,defaultValue:s,onChange:i,form:v,name:c,by:m,invalid:g=!1,disabled:y=n||!1,onClose:h,__demoMode:b=!1,multiple:p=!1,immediate:P=!1,virtual:r=null,nullable:M,...A}=e,E=Tt(s),[T=p?[]:void 0,B]=Rt(o,i,E),S=We({id:t,virtual:r,__demoMode:b}),_=d.useRef({static:!1,hold:!1}),I=ta(m),F=D($=>r?m===null?r.options.indexOf($):r.options.findIndex(ae=>I(ae,$)):S.state.options.findIndex(ae=>I(ae.dataRef.current.value,$))),q=d.useCallback($=>le(w.mode,{[J.Multi]:()=>T.some(ae=>I(ae,$)),[J.Single]:()=>I(T,$)}),[T]),Y=z(S,$=>$.virtual),C=D(()=>h==null?void 0:h()),w=d.useMemo(()=>({__demoMode:b,immediate:P,optionsPropsRef:_,value:T,defaultValue:E,disabled:y,invalid:g,mode:p?J.Multi:J.Single,virtual:r?Y:null,onChange:B,isSelected:q,calculateIndex:F,compare:I,onClose:C}),[b,P,_,T,E,y,g,p,r,Y,B,q,F,I,C]);te(()=>{var $;r&&S.send({type:Ke.UpdateVirtualConfiguration,options:r.options,disabled:($=r.disabled)!=null?$:null})},[r,r==null?void 0:r.options,r==null?void 0:r.disabled]),te(()=>{S.state.dataRef.current=w},[w]);let[H,O,u,R]=z(S,$=>[$.comboboxState,$.buttonElement,$.inputElement,$.optionsElement]),N=ze.get(null),Q=z(N,d.useCallback($=>N.selectors.isTop($,t),[N,t]));$t(Q,[O,u,R],()=>S.actions.closeCombobox());let Z=z(S,S.selectors.activeOptionIndex),re=z(S,S.selectors.activeOption),f=be({open:H===x.Open,disabled:y,invalid:g,activeIndex:Z,activeOption:re,value:T}),[X,k]=wt(),U=a===null?{}:{ref:a},j=d.useCallback(()=>{if(E!==void 0)return B==null?void 0:B(E)},[B,E]),G=ve();return K.createElement(k,{value:X,props:{htmlFor:u==null?void 0:u.id},slot:{open:H===x.Open,disabled:y}},K.createElement(la,null,K.createElement(pe.Provider,{value:w},K.createElement(qe.Provider,{value:S},K.createElement(jt,{value:le(H,{[x.Open]:ge.Open,[x.Closed]:ge.Closed})},c!=null&&K.createElement(It,{disabled:y,data:T!=null?{[c]:T}:{},form:v,onReset:j}),G({ourProps:U,theirProps:A,slot:f,defaultTag:Ta,name:"Combobox"}))))))}let $a="input";function wa(e,a){var t,n;let o=fe("Combobox.Input"),s=ie("Combobox.Input"),i=d.useId(),v=ut(),{id:c=v||`headlessui-combobox-input-${i}`,onChange:m,displayValue:g,disabled:y=s.disabled||!1,autoFocus:h=!1,type:b="text",...p}=e,P=d.useRef(null),r=xe(P,a,aa(),o.actions.setInputElement),[M,A]=z(o,f=>[f.comboboxState,f.isTyping]),E=ct(),T=D(()=>{o.actions.onChange(null),o.state.optionsElement&&(o.state.optionsElement.scrollTop=0),o.actions.goToOption({focus:V.Nothing})}),B=d.useMemo(()=>{var f;return typeof g=="function"&&s.value!==void 0?(f=g(s.value))!=null?f:"":typeof s.value=="string"?s.value:""},[s.value,g]);Ee(([f,X],[k,U])=>{if(o.state.isTyping)return;let j=P.current;j&&((U===x.Open&&X===x.Closed||f!==k)&&(j.value=f),requestAnimationFrame(()=>{if(o.state.isTyping||!j||Ve(j))return;let{selectionStart:G,selectionEnd:$}=j;Math.abs(($??0)-(G??0))===0&&G===0&&j.setSelectionRange(j.value.length,j.value.length)}))},[B,M,A]),Ee(([f],[X])=>{if(f===x.Open&&X===x.Closed){if(o.state.isTyping)return;let k=P.current;if(!k)return;let U=k.value,{selectionStart:j,selectionEnd:G,selectionDirection:$}=k;k.value="",k.value=U,$!==null?k.setSelectionRange(j,G,$):k.setSelectionRange(j,G)}},[M]);let S=d.useRef(!1),_=D(()=>{S.current=!0}),I=D(()=>{E.nextFrame(()=>{S.current=!1})}),F=D(f=>{switch(o.actions.setIsTyping(!0),f.key){case W.Enter:if(o.state.comboboxState!==x.Open||S.current)return;if(f.preventDefault(),f.stopPropagation(),o.selectors.activeOptionIndex(o.state)===null){o.actions.closeCombobox();return}o.actions.selectActiveOption(),s.mode===J.Single&&o.actions.closeCombobox();break;case W.ArrowDown:return f.preventDefault(),f.stopPropagation(),le(o.state.comboboxState,{[x.Open]:()=>o.actions.goToOption({focus:V.Next}),[x.Closed]:()=>o.actions.openCombobox()});case W.ArrowUp:return f.preventDefault(),f.stopPropagation(),le(o.state.comboboxState,{[x.Open]:()=>o.actions.goToOption({focus:V.Previous}),[x.Closed]:()=>{se.flushSync(()=>o.actions.openCombobox()),s.value||o.actions.goToOption({focus:V.Last})}});case W.Home:if(o.state.comboboxState===x.Closed||f.shiftKey)break;return f.preventDefault(),f.stopPropagation(),o.actions.goToOption({focus:V.First});case W.PageUp:return f.preventDefault(),f.stopPropagation(),o.actions.goToOption({focus:V.First});case W.End:if(o.state.comboboxState===x.Closed||f.shiftKey)break;return f.preventDefault(),f.stopPropagation(),o.actions.goToOption({focus:V.Last});case W.PageDown:return f.preventDefault(),f.stopPropagation(),o.actions.goToOption({focus:V.Last});case W.Escape:return o.state.comboboxState!==x.Open?void 0:(f.preventDefault(),o.state.optionsElement&&!s.optionsPropsRef.current.static&&f.stopPropagation(),s.mode===J.Single&&s.value===null&&T(),o.actions.closeCombobox());case W.Tab:if(o.actions.setIsTyping(!1),o.state.comboboxState!==x.Open)return;s.mode===J.Single&&o.state.activationTrigger!==ee.Focus&&o.actions.selectActiveOption(),o.actions.closeCombobox();break}}),q=D(f=>{m==null||m(f),s.mode===J.Single&&f.target.value===""&&T(),o.actions.openCombobox()}),Y=D(f=>{var X,k,U;let j=(X=f.relatedTarget)!=null?X:Te.find(G=>G!==f.currentTarget);if(!((k=o.state.optionsElement)!=null&&k.contains(j))&&!((U=o.state.buttonElement)!=null&&U.contains(j))&&o.state.comboboxState===x.Open)return f.preventDefault(),s.mode===J.Single&&s.value===null&&T(),o.actions.closeCombobox()}),C=D(f=>{var X,k,U;let j=(X=f.relatedTarget)!=null?X:Te.find(G=>G!==f.currentTarget);(k=o.state.buttonElement)!=null&&k.contains(j)||(U=o.state.optionsElement)!=null&&U.contains(j)||s.disabled||s.immediate&&o.state.comboboxState!==x.Open&&E.microTask(()=>{se.flushSync(()=>o.actions.openCombobox()),o.actions.setActivationTrigger(ee.Focus)})}),w=Se(),H=dt(),{isFocused:O,focusProps:u}=Be({autoFocus:h}),{isHovered:R,hoverProps:N}=He({isDisabled:y}),Q=z(o,f=>f.optionsElement),Z=be({open:M===x.Open,disabled:y,invalid:s.invalid,hover:R,focus:O,autofocus:h}),re=Ce({ref:r,id:c,role:"combobox",type:b,"aria-controls":Q==null?void 0:Q.id,"aria-expanded":M===x.Open,"aria-activedescendant":z(o,o.selectors.activeDescendantId),"aria-labelledby":w,"aria-describedby":H,"aria-autocomplete":"list",defaultValue:(n=(t=e.defaultValue)!=null?t:s.defaultValue!==void 0?g==null?void 0:g(s.defaultValue):null)!=null?n:s.defaultValue,disabled:y||void 0,autoFocus:h,onCompositionStart:_,onCompositionEnd:I,onKeyDown:F,onChange:q,onFocus:C,onBlur:Y},u,N);return ve()({ourProps:re,theirProps:p,slot:Z,defaultTag:$a,name:"Combobox.Input"})}let ja="button";function Ia(e,a){let t=fe("Combobox.Button"),n=ie("Combobox.Button"),[o,s]=d.useState(null),i=xe(a,s,t.actions.setButtonElement),v=d.useId(),{id:c=`headlessui-combobox-button-${v}`,disabled:m=n.disabled||!1,autoFocus:g=!1,...y}=e,[h,b,p]=z(t,C=>[C.comboboxState,C.inputElement,C.optionsElement]),P=Ge(b),r=h===x.Open;Xt(r,{trigger:o,action:d.useCallback(C=>{if(o!=null&&o.contains(C.target))return ue.Ignore;if(b!=null&&b.contains(C.target))return ue.Ignore;let w=C.target.closest('[role="option"]:not([data-disabled])');return pt(w)?ue.Select(w):p!=null&&p.contains(C.target)?ue.Ignore:ue.Close},[o,b,p]),close:t.actions.closeCombobox,select:t.actions.selectActiveOption});let M=D(C=>{switch(C.key){case W.Space:case W.Enter:C.preventDefault(),C.stopPropagation(),t.state.comboboxState===x.Closed&&se.flushSync(()=>t.actions.openCombobox()),P();return;case W.ArrowDown:C.preventDefault(),C.stopPropagation(),t.state.comboboxState===x.Closed&&(se.flushSync(()=>t.actions.openCombobox()),t.state.dataRef.current.value||t.actions.goToOption({focus:V.First})),P();return;case W.ArrowUp:C.preventDefault(),C.stopPropagation(),t.state.comboboxState===x.Closed&&(se.flushSync(()=>t.actions.openCombobox()),t.state.dataRef.current.value||t.actions.goToOption({focus:V.Last})),P();return;case W.Escape:if(t.state.comboboxState!==x.Open)return;C.preventDefault(),t.state.optionsElement&&!n.optionsPropsRef.current.static&&C.stopPropagation(),se.flushSync(()=>t.actions.closeCombobox()),P();return;default:return}}),A=Jt(()=>{t.state.comboboxState===x.Open?t.actions.closeCombobox():t.actions.openCombobox(),P()}),E=Se([c]),{isFocusVisible:T,focusProps:B}=Be({autoFocus:g}),{isHovered:S,hoverProps:_}=He({isDisabled:m}),{pressed:I,pressProps:F}=mt({disabled:m}),q=be({open:h===x.Open,active:I||h===x.Open,disabled:m,invalid:n.invalid,value:n.value,hover:S,focus:T}),Y=Ce({ref:i,id:c,type:bt(e,o),tabIndex:-1,"aria-haspopup":"listbox","aria-controls":p==null?void 0:p.id,"aria-expanded":h===x.Open,"aria-labelledby":E,disabled:m||void 0,autoFocus:g,onKeyDown:M},A,B,_,F);return ve()({ourProps:Y,theirProps:y,slot:q,defaultTag:ja,name:"Combobox.Button"})}let Na="div",ka=$e.RenderStrategy|$e.Static;function Ma(e,a){var t,n,o;let s=d.useId(),{id:i=`headlessui-combobox-options-${s}`,hold:v=!1,anchor:c,portal:m=!1,modal:g=!0,transition:y=!1,...h}=e,b=fe("Combobox.Options"),p=ie("Combobox.Options"),P=oa(c);P&&(m=!0);let[r,M]=na(P),[A,E]=d.useState(null),T=sa(),B=xe(a,P?r:null,b.actions.setOptionsElement,E),[S,_,I,F,q]=z(b,L=>[L.comboboxState,L.inputElement,L.buttonElement,L.optionsElement,L.activationTrigger]),Y=Re(_||I),C=Re(F),w=vt(),[H,O]=ft(y,A,w!==null?(w&ge.Open)===ge.Open:S===x.Open);gt(H,_,b.actions.closeCombobox);let u=p.__demoMode?!1:g&&S===x.Open;xt(u,C);let R=p.__demoMode?!1:g&&S===x.Open;ht(R,{allowed:d.useCallback(()=>[_,I,F],[_,I,F])});let N=z(b,b.selectors.didInputMove)?!1:H;te(()=>{var L;p.optionsPropsRef.current.static=(L=e.static)!=null?L:!1},[p.optionsPropsRef,e.static]),te(()=>{p.optionsPropsRef.current.hold=v},[p.optionsPropsRef,v]),Sa(S===x.Open,{container:F,accept(L){return L.getAttribute("role")==="option"?NodeFilter.FILTER_REJECT:L.hasAttribute("role")?NodeFilter.FILTER_SKIP:NodeFilter.FILTER_ACCEPT},walk(L){L.setAttribute("role","none")}});let Q=Se([I==null?void 0:I.id]),Z=be({open:S===x.Open,option:void 0}),re=D(()=>{b.actions.setActivationTrigger(ee.Pointer)}),f=D(L=>{L.preventDefault(),b.actions.setActivationTrigger(ee.Pointer)}),X=Ce(P?T():{},{"aria-labelledby":Q,role:"listbox","aria-multiselectable":p.mode===J.Multi?!0:void 0,id:i,ref:B,style:{...h.style,...M,"--input-width":Ae(H,_,!0).width,"--button-width":Ae(H,I,!0).width},onWheel:q===ee.Pointer?void 0:re,onMouseDown:f,...yt(O)}),k=H&&S===x.Closed&&!e.static,U=De(k,(t=p.virtual)==null?void 0:t.options),j=De(k,p.value),G=d.useCallback(L=>p.compare(j,L),[p.compare,j]),$=d.useMemo(()=>{if(!p.virtual)return p;if(U===void 0)throw new Error("Missing `options` in virtual mode");return U!==p.virtual.options?{...p,virtual:{...p.virtual,options:U}}:p},[p,U,(n=p.virtual)==null?void 0:n.options]);p.virtual&&Object.assign(h,{children:K.createElement(pe.Provider,{value:$},K.createElement(Ea,{slot:Z},h.children))});let ae=ve(),tt=d.useMemo(()=>p.mode===J.Multi?p:{...p,isSelected:G},[p,G]);return K.createElement(St,{enabled:m?e.static||H:!1,ownerDocument:Y},K.createElement(pe.Provider,{value:tt},ae({ourProps:X,theirProps:{...h,children:K.createElement(Qt,{freeze:k},typeof h.children=="function"?(o=h.children)==null?void 0:o.call(h,Z):h.children)},slot:Z,defaultTag:Na,features:ka,visible:N,name:"Combobox.Options"})))}let Fa="div";function Da(e,a){var t,n,o;let s=ie("Combobox.Option"),i=fe("Combobox.Option"),v=d.useId(),{id:c=`headlessui-combobox-option-${v}`,value:m,disabled:g=(o=(n=(t=s.virtual)==null?void 0:t.disabled)==null?void 0:n.call(t,m))!=null?o:!1,order:y=null,...h}=e,[b]=z(i,O=>[O.inputElement]),p=Ge(b),P=z(i,d.useCallback(O=>i.selectors.isActive(O,m,c),[m,c])),r=s.isSelected(m),M=d.useRef(null),A=Ct({disabled:g,value:m,domRef:M,order:y}),E=d.useContext(Ye),T=xe(a,M,E?E.measureElement:null),B=D(()=>{i.actions.setIsTyping(!1),i.actions.onChange(m)});te(()=>i.actions.registerOption(c,A),[A,c]);let S=z(i,d.useCallback(O=>i.selectors.shouldScrollIntoView(O,m,c),[m,c]));te(()=>{if(S)return Ot().requestAnimationFrame(()=>{var O,u;(u=(O=M.current)==null?void 0:O.scrollIntoView)==null||u.call(O,{block:"nearest"})})},[S,M]);let _=D(O=>{O.preventDefault(),O.button===Zt.Left&&(g||(B(),Pt()||requestAnimationFrame(()=>p()),s.mode===J.Single&&i.actions.closeCombobox()))}),I=D(()=>{if(g)return i.actions.goToOption({focus:V.Nothing});let O=s.calculateIndex(m);i.actions.goToOption({focus:V.Specific,idx:O})}),F=ea(),q=D(O=>F.update(O)),Y=D(O=>{if(!F.wasMoved(O)||g||P&&i.state.activationTrigger===ee.Pointer)return;let u=s.calculateIndex(m);i.actions.goToOption({focus:V.Specific,idx:u},ee.Pointer)}),C=D(O=>{F.wasMoved(O)&&(g||P&&(s.optionsPropsRef.current.hold||i.state.activationTrigger===ee.Pointer&&i.actions.goToOption({focus:V.Nothing})))}),w=be({active:P,focus:P,selected:r,disabled:g}),H={id:c,ref:T,role:"option",tabIndex:g===!0?void 0:-1,"aria-disabled":g===!0?!0:void 0,"aria-selected":r,disabled:void 0,onMouseDown:_,onFocus:I,onPointerEnter:q,onMouseEnter:q,onPointerMove:Y,onMouseMove:Y,onPointerLeave:C,onMouseLeave:C};return ve()({ourProps:H,theirProps:h,slot:w,defaultTag:Fa,name:"Combobox.Option"})}let Aa=me(Ra),Xe=me(Ia),Je=me(wa),_a=rt,Qe=me(Ma),Ze=me(Da),La=Object.assign(Aa,{Input:Je,Button:Xe,Label:_a,Options:Qe,Option:Ze});function Va({options:e,value:a,onChange:t,defaultValue:n,displayValue:o,filter:s,placeholder:i,disabled:v,invalid:c,name:m,"aria-label":g,className:y,children:h}){const[b,p]=d.useState(""),P=o??(E=>E!=null?String(E):""),M=s??((E,T)=>P(E).toLowerCase().includes(T.toLowerCase())),A=d.useMemo(()=>b?e.filter(E=>M(E,b)):e,[e,b,M]);return l.jsx(La,{value:a,onChange:t,defaultValue:n,disabled:v,name:m,onClose:()=>p(""),children:l.jsxs("div",{className:ne("relative",y),children:[l.jsxs("div",{className:"relative",children:[l.jsx(Je,{"aria-label":g,displayValue:P,onChange:E=>p(E.target.value),placeholder:i,className:ne(["w-full radius-inner py-2 pl-3 pr-10","text-sm text-fg-primary placeholder:text-fg-muted","bg-input-bg",c?"border border-sys-red":"border border-input-border","ring-focus-inset","hover:border-edge-strong","disabled:opacity-40 disabled:pointer-events-none disabled:cursor-not-allowed","transition-colors"])}),l.jsx(Xe,{className:"absolute inset-y-0 right-0 flex items-center pr-3 group",children:l.jsx(Nt,{className:"w-4 h-4 text-fg-muted transition-transform duration-200 group-data-[open]:rotate-180"})})]}),l.jsx(Qe,{anchor:"bottom start",transition:!0,className:ne(["w-[var(--input-width)] min-w-[180px]","max-h-60 overflow-y-auto overscroll-contain scroll-py-1","radius-inset p-1 mt-1","surface-elevated","focus:outline-none","transition-opacity","data-[closed]:opacity-0","data-[enter]:duration-150 data-[leave]:duration-100","z-50"]),children:A.length===0&&b!==""?l.jsx("div",{className:"px-3 py-2 text-sm text-fg-muted",children:"No results found"}):A.map((E,T)=>l.jsx(d.Fragment,{children:h(E)},T))})]})})}function za({value:e,disabled:a,className:t,children:n}){return l.jsx(Ze,{as:d.Fragment,value:e,disabled:a,children:({selected:o,focus:s})=>l.jsxs("div",{className:ne("flex items-center gap-2 px-3 py-2 radius-control cursor-default","text-sm",s&&"bg-sys-blue text-white",!s&&"text-fg-primary",o&&!s&&"text-sys-blue",a&&"opacity-50 cursor-not-allowed",t),children:[l.jsx("span",{className:"w-4 flex-shrink-0",children:o&&l.jsx(kt,{className:"w-4 h-4"})}),l.jsx("span",{className:"truncate flex-1",children:n})]})})}function Ba({className:e,...a}){return l.jsx("span",{...a,className:ne("truncate",e)})}function oe({value:e,onChange:a,options:t,placeholder:n,disabled:o,className:s,"aria-label":i}){const v=t.find(c=>c.value===e);return l.jsx(Va,{options:t,value:v,onChange:c=>{c&&a(c.value)},displayValue:c=>(c==null?void 0:c.label)??"",filter:(c,m)=>c.label.toLowerCase().includes(m.toLowerCase()),placeholder:n,disabled:o,className:s,"aria-label":i,children:c=>l.jsx(za,{value:c,disabled:c.disabled,children:l.jsx(Ba,{children:c.label})})})}const et=[{target:"PacketStats",fn:"type",minStage:1}];ma(et);function ce({icon:e,label:a,value:t,color:n,percentage:o}){return l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("div",{className:ne("p-1.5 rounded-md",n),children:e}),l.jsxs("div",{className:"flex flex-col",children:[l.jsx("span",{className:"text-sm font-semibold text-fg-primary",children:t.toLocaleString()}),l.jsxs("span",{className:"text-xs text-fg-muted leading-tight",children:[a,o!==void 0&&l.jsxs("span",{className:"ml-1 opacity-70",children:["(",o,"%)"]})]})]})]})}function Ha({packets:e}){pa(et);const a=d.useMemo(()=>{let t=0,n=0,o=0;const s=new Set;let i=0,v=0;for(const y of e){switch(Ue(y)){case"forward":t++;break;case"dropped":n++;break;case"duplicate":o++;break}y.src_hash&&s.add(y.src_hash),y.rssi&&(i+=y.rssi,v++)}const c=e.length,m=v>0?Math.round(i/v):0;return{total:c,rx:c,fwd:t,dropped:n,duplicate:o,uniqueSources:s.size,avgRssi:m,rxPercent:100,fwdPercent:c>0?Math.round(t/c*100):0,droppedPercent:c>0?Math.round(n/c*100):0}},[e]);return e.length===0?null:l.jsx("div",{className:"surface-base depth-raised rounded-2xl p-3 pr-4",children:l.jsxs("div",{className:"grid grid-cols-2 gap-3 sm:flex sm:items-center sm:justify-between sm:gap-6",children:[l.jsx(ce,{icon:l.jsx(ba,{className:"w-3.5 h-3.5 text-sys-blue"}),label:"Received",value:a.rx,color:"bg-sys-blue/10",percentage:a.rxPercent}),l.jsx(ce,{icon:l.jsx(va,{className:"w-3.5 h-3.5 text-sys-green"}),label:"Forwarded",value:a.fwd,color:"bg-sys-green/10",percentage:a.fwdPercent}),l.jsx(ce,{icon:l.jsx(Gt,{className:"w-3.5 h-3.5 text-sys-red"}),label:"Dropped",value:a.dropped,color:"bg-sys-red/10",percentage:a.droppedPercent}),l.jsx(ce,{icon:l.jsx(Mt,{className:"w-3.5 h-3.5 text-fg-muted"}),label:"Duplicates",value:a.duplicate,color:"bg-subtle-fill"}),l.jsxs("div",{className:"hidden sm:flex items-center gap-6 ml-auto",children:[l.jsx(ce,{icon:l.jsx(Ft,{className:"w-3.5 h-3.5 text-sys-indigo"}),label:"Sources",value:a.uniqueSources,color:"bg-sys-indigo/10"}),l.jsxs("div",{className:"flex flex-col items-end pr-1",children:[l.jsxs("span",{className:"type-data-sm text-fg-secondary",children:[a.avgRssi," dBm"]}),l.jsx("span",{className:"text-xs text-fg-muted",children:"Avg Signal"})]})]})]})})}const Ua=d.memo(Ha);function Po(){const e=Dt(),a=At(),t=ia(),n=Kt(u=>u.requestChannel),o=_t(),s=a==null?void 0:a.local_hash,i=a==null?void 0:a.neighbors,v=Lt(),c=Vt(),g=zt().isBackgroundLoading&&v>=5,[y,h]=d.useState(!1),[b,p]=d.useState(!0),P=d.useCallback(u=>p(u),[]),[r,M]=d.useState({limit:500,status:"all"}),[A,E]=d.useState(ua),T=d.useMemo(()=>{const u=Math.floor(Date.now()/1e3),R=we[v].minutes;return{start:u-R*60,end:u}},[v]),B=d.useMemo(()=>{const u=(a==null?void 0:a.neighbors)??{};return Object.fromEntries(Object.entries(u).filter(([R])=>!o.has(R)))},[a==null?void 0:a.neighbors,o]),S=ra(),[_,I]=d.useState(Date.now);d.useEffect(()=>{r.timeRange&&r.timeRange>0&&queueMicrotask(()=>I(Date.now()))},[r.timeRange,e]);const F=d.useMemo(()=>ca(e,A,S,T),[e,A,S,T]),q=d.useMemo(()=>{const u=r.limit??500;return[...F.length<=u?F:F.slice(-u)].sort((N,Q)=>(Q.timestamp??0)-(N.timestamp??0))},[F,r.limit]),Y=e.length===0,C=d.useMemo(()=>{let u=q;if(r.type!==void 0){const R=je[r.type];u=u.filter(N=>{const Q=N.type??N.payload_type,Z=N.payload_type_name;return Q===r.type||Z===R})}if(r.route!==void 0){const R=Ie[r.route];u=u.filter(N=>{const Q=N.route??N.route_type,Z=N.route_type_name;return Q===r.route||Z===R})}if(r.status&&r.status!=="all"&&(u=u.filter(R=>Ue(R)===r.status)),r.signalMin!==void 0&&(u=u.filter(R=>R.rssi>=r.signalMin)),r.timeRange&&r.timeRange>0){const R=_/1e3-r.timeRange*3600;u=u.filter(N=>N.timestamp>=R)}return u},[q,r.type,r.route,r.status,r.signalMin,r.timeRange,_]),w=(u,R)=>M(N=>({...N,[u]:R})),H=()=>M({limit:r.limit,status:"all"}),O=r.type!==void 0||r.route!==void 0||r.status&&r.status!=="all"||r.signalMin!==void 0||r.timeRange&&r.timeRange>0;return l.jsxs(fa,{children:[l.jsx(ga,{title:"Packet History",icon:l.jsx(ke,{}),controls:l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsxs(Ne,{outline:!0,color:O?"primary":"muted",onClick:()=>h(!y),className:"sm:hidden",children:[l.jsx(_e,{"data-slot":"icon"}),O&&l.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-sys-blue"})]}),l.jsx(ha,{ranges:we,selectedIndex:v,onSelect:c,isPending:g})]})}),l.jsxs(xa,{children:[l.jsx(ya,{template:"auto",className:"relative z-10",children:l.jsx(he,{neomorphic:!0,className:"overflow-visible",children:l.jsx(da,{parentStartTs:T.start,parentEndTs:T.end,neighbors:B,filter:A,onChange:E})})}),l.jsxs(he,{neomorphic:!0,noPadding:!0,className:ne("overflow-hidden transition-all duration-200",y?"max-h-96 opacity-100":"max-h-0 opacity-0 sm:max-h-96 sm:opacity-100"),children:[l.jsx(Me,{listHeader:!0,icon:l.jsx(_e,{className:"icon-sm"}),title:"Filters",actions:O?l.jsxs(Ne,{plain:!0,color:"muted",onClick:H,className:"!text-xs !py-0.5 !px-1.5",children:[l.jsx(Bt,{"data-slot":"icon",className:"!w-3 !h-3"}),"Clear"]}):void 0}),l.jsx("div",{className:"p-3 sm:p-4",children:l.jsxs("div",{className:"grid grid-cols-2 sm:flex sm:flex-wrap gap-3",children:[l.jsxs("div",{className:"flex-1 min-w-[140px]",children:[l.jsx("label",{className:"type-micro block mb-1",children:"Type"}),l.jsx(oe,{value:r.type??"",onChange:u=>w("type",u===""?void 0:Number(u)),options:[{value:"",label:"All Types"},...Object.entries(je).map(([u,R])=>({value:Number(u),label:R}))],placeholder:"Search types...","aria-label":"Filter by packet type"})]}),l.jsxs("div",{className:"flex-1 min-w-[140px]",children:[l.jsx("label",{className:"type-micro block mb-1",children:"Route"}),l.jsx(oe,{value:r.route??"",onChange:u=>w("route",u===""?void 0:Number(u)),options:[{value:"",label:"All Routes"},...Object.entries(Ie).map(([u,R])=>({value:Number(u),label:R}))],placeholder:"Search routes...","aria-label":"Filter by route type"})]}),l.jsxs("div",{className:"flex-1 min-w-[140px]",children:[l.jsx("label",{className:"type-micro block mb-1",children:"Status"}),l.jsx(oe,{value:r.status??"all",onChange:u=>w("status",u),options:[{value:"all",label:"All Status"},{value:"rx",label:"Received"},{value:"forward",label:"Forwarded"},{value:"dropped",label:"Dropped"},{value:"duplicate",label:"Duplicate"}],placeholder:"Search status...","aria-label":"Filter by status"})]}),l.jsxs("div",{className:"flex-1 min-w-[120px]",children:[l.jsx("label",{className:"type-micro block mb-1",children:"Time"}),l.jsx(oe,{value:r.timeRange??0,onChange:u=>w("timeRange",u===0?void 0:u),options:[{value:0,label:"All Time"},{value:1,label:"Last 1h"},{value:6,label:"Last 6h"},{value:24,label:"Last 24h"},{value:168,label:"Last 7d"}],placeholder:"Search time...","aria-label":"Filter by time range"})]}),l.jsxs("div",{className:"flex-1 min-w-[130px]",children:[l.jsx("label",{className:"type-micro block mb-1",children:"Signal"}),l.jsx(oe,{value:r.signalMin??"",onChange:u=>w("signalMin",u===""?void 0:Number(u)),options:[{value:"",label:"Any Signal"},{value:-90,label:"Strong (≥-90)"},{value:-100,label:"Good (≥-100)"},{value:-110,label:"Fair (≥-110)"},{value:-120,label:"Weak (≥-120)"}],placeholder:"Search signal...","aria-label":"Filter by signal strength"})]}),l.jsxs("div",{className:"flex-1 min-w-[100px]",children:[l.jsx("label",{className:"type-micro block mb-1",children:"Limit"}),l.jsx(oe,{value:r.limit??500,onChange:u=>w("limit",u),options:[{value:100,label:"100"},{value:200,label:"200"},{value:500,label:"500"},{value:1e3,label:"1K"},{value:2e3,label:"2K"},{value:5e3,label:"5K"},{value:1e4,label:"10K"}],placeholder:"Limit...","aria-label":"Packet limit"})]}),l.jsxs("div",{className:"flex-1 min-w-[100px]",children:[l.jsx("label",{className:"type-micro block mb-1",children:"Per Page"}),l.jsx(oe,{value:r.perPage??50,onChange:u=>w("perPage",u),options:[{value:25,label:"25"},{value:50,label:"50"},{value:100,label:"100"},{value:200,label:"200"},{value:500,label:"500"}],placeholder:"Per page...","aria-label":"Packets per page"})]})]})})]}),l.jsx(Ua,{packets:C}),l.jsxs(he,{neomorphic:!0,noPadding:!0,className:"!overflow-visible",children:[l.jsx(Me,{listHeader:!0,icon:l.jsx(ke,{className:"icon-sm"}),title:"Packet History",actions:l.jsx(Ht,{enabled:b,onChange:P,label:"Hide Dupes",size:"sm"})}),l.jsx(qt,{packets:C,allPackets:e,localHash:s,neighbors:i,resolveSource:S,getDecodedContent:t,onChannelClick:n,loading:Y,showPagination:!0,perPage:r.perPage??50,hideDupes:b,emptyMessage:"No packets found"})]})]})]})}export{Po as default}; diff --git a/frontend/dist/assets/PageLayout-BkUTZXJb.js b/frontend/dist/assets/PageLayout-BkUTZXJb.js new file mode 100644 index 00000000..5b00dfc4 --- /dev/null +++ b/frontend/dist/assets/PageLayout-BkUTZXJb.js @@ -0,0 +1 @@ +import{j as e,q as o,c as x,ak as d,r,fc as f}from"./index-DhkG1Nx9.js";function p({children:a,className:s}){return e.jsx("div",{className:x("section-gap",s),children:a})}function j({children:a,className:s,ready:t}){const n=d(),i=t??n,[m,c]=r.useState(!1);return r.useEffect(()=>{if(!i){c(!1);return}let l=!1;return requestAnimationFrame(()=>{requestAnimationFrame(()=>{l||r.startTransition(()=>c(!0))})}),()=>{l=!0}},[i]),e.jsx(f.Provider,{value:m,children:e.jsx("div",{className:x("bento-section",s),children:a})})}function g({title:a,icon:s,controls:t,subtitle:n}){return e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 min-h-9",children:[e.jsxs("h1",{className:"type-title text-fg-primary flex items-baseline gap-2 sm:gap-3 min-w-0",children:[s&&e.jsx("span",{className:"text-icon-page-title flex-shrink-0 translate-y-[0.1em] [&>svg]:h-[1em] [&>svg]:w-[1em] [&>svg]:stroke-[1.5]",children:s}),e.jsx("span",{className:"truncate",children:a})]}),t&&e.jsx("div",{className:"flex items-center gap-2 flex-shrink-0",children:t})]}),n&&e.jsx("div",{children:n})]})}function h({size:a,...s}){return e.jsx(o,{...s})}export{j as B,h as C,p as P,g as a}; diff --git a/frontend/dist/assets/PageLayout-sd81yog0.js b/frontend/dist/assets/PageLayout-sd81yog0.js deleted file mode 100644 index 46ecf322..00000000 --- a/frontend/dist/assets/PageLayout-sd81yog0.js +++ /dev/null @@ -1 +0,0 @@ -import{j as e,o as r,c as t}from"./index-C1ZF7cAz.js";function l({children:a,className:s}){return e.jsx("div",{className:t("section-gap",s),children:a})}function x({children:a,className:s}){return e.jsx("div",{className:t("bento-section",s),children:a})}function m({title:a,icon:s,controls:n,subtitle:i}){return e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 min-h-9",children:[e.jsxs("h1",{className:"type-title text-fg-primary flex items-baseline gap-2 sm:gap-3 min-w-0",children:[s&&e.jsx("span",{className:"text-icon-page-title flex-shrink-0 translate-y-[0.1em] [&>svg]:h-[1em] [&>svg]:w-[1em] [&>svg]:stroke-[1.5]",children:s}),e.jsx("span",{className:"truncate",children:a})]}),n&&e.jsx("div",{className:"flex items-center gap-2 flex-shrink-0",children:n})]}),i&&e.jsx("div",{children:i})]})}function d({size:a,...s}){return e.jsx(r,{...s})}export{x as B,d as C,l as P,m as a}; diff --git a/frontend/dist/assets/PathMapMapLibre-AZaGoHLu.js b/frontend/dist/assets/PathMapMapLibre-AZaGoHLu.js new file mode 100644 index 00000000..a7e3a6bb --- /dev/null +++ b/frontend/dist/assets/PathMapMapLibre-AZaGoHLu.js @@ -0,0 +1,6 @@ +import{d as ae,r as a,bz as ie,bs as le,fd as de,Z as q,bC as ce,j as t,v as K,c as z,fe as ue}from"./index-DhkG1Nx9.js";import{u as pe,M as me,B as fe,S as ge,L as he,a as Y,P as xe}from"./BasemapLayer-CfNeG6Jg.js";import{H as ye}from"./useMapViewStore-BMqcaUNl.js";import"./index-Bx_G2nLG.js";/** + * @license lucide-react v0.559.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const be=[["path",{d:"M19 17h2c.6 0 1-.4 1-1v-3c0-.9-.7-1.7-1.5-1.9C18.7 10.6 16 10 16 10s-1.3-1.4-2.2-2.3c-.5-.4-1.1-.7-1.8-.7H5c-.6 0-1.1.4-1.4.9l-1.4 2.9A3.7 3.7 0 0 0 2 12v4c0 .6.4 1 1 1h2",key:"5owen"}],["circle",{cx:"7",cy:"17",r:"2",key:"u2ysq9"}],["path",{d:"M9 17h6",key:"r8uit2"}],["circle",{cx:"17",cy:"17",r:"2",key:"axvx0g"}]],Ce=ae("car",be),ve={version:8,sources:{},layers:[],glyphs:"https://tiles.basemaps.cartocdn.com/fonts/{fontstack}/{range}.pbf"},x={nodeColor:"#4338CA",localColor:"#4F46E5",hubColor:"#6366F1",edgeColor:"#3B3F4A",ambiguousColor:"#F9D26F",highlightColor:"#B49DFF",sourceColor:"#39D98A",destinationColor:"#B49DFF"};function C(c,r){if(!c)return r;if(c.startsWith("#"))return c;const m=ue(c);return m?`#${m.r.toString(16).padStart(2,"0")}${m.g.toString(16).padStart(2,"0")}${m.b.toString(16).padStart(2,"0")}`:r}function G(){if(typeof document>"u")return x;const c=document.documentElement,r=getComputedStyle(c);return{nodeColor:C(r.getPropertyValue("--map-node-stroke").trim(),x.nodeColor),localColor:C(r.getPropertyValue("--map-local-color").trim(),x.localColor),hubColor:C(r.getPropertyValue("--map-hub-color").trim(),x.hubColor),edgeColor:C(r.getPropertyValue("--map-edge-rest").trim(),x.edgeColor),ambiguousColor:C(r.getPropertyValue("--sys-indigo").trim(),x.ambiguousColor),highlightColor:C(r.getPropertyValue("--sys-blue").trim(),x.highlightColor),sourceColor:C(r.getPropertyValue("--sys-green").trim(),x.sourceColor),destinationColor:C(r.getPropertyValue("--sys-blue").trim(),x.destinationColor)}}function je({prefix:c,isLocal:r,isSource:m,isDestination:W,isLastHop:y,isHighlighted:g,isWardrive:F,candidate:h,onHover:E,onLeave:N,onClick:S}){const[n,k]=a.useState(!1),I=a.useCallback(()=>{k(!0),E()},[E]),v=a.useCallback(()=>{k(!1),N()},[N]),P=()=>F?"orange":r?"amber":m?"green":y?"amber":W?"purple":"blue";return F?t.jsxs("div",{className:z("flex items-center cursor-pointer","transition-all duration-150",g&&"ring-2 ring-sys-blue/50 rounded-full",n&&"relative z-50"),onMouseEnter:I,onMouseLeave:v,onClick:S,style:{pointerEvents:"auto"},children:[t.jsx("div",{className:z("flex items-center justify-center","w-7 h-7 rounded-full","bg-sys-orange text-white","shadow-lg border-2 border-sys-orange/50","transition-transform duration-150",n&&"scale-110"),children:t.jsx(Ce,{className:"w-4 h-4",strokeWidth:2.5})}),n&&t.jsxs(K,{color:"orange",filled:!0,className:"ml-1 type-data-xs shadow-lg",children:[c,h.name&&t.jsx("span",{className:"ml-1 opacity-75",children:h.name})]})]}):t.jsx("div",{className:z("flex items-center cursor-pointer","transition-all duration-150",g&&"ring-2 ring-sys-blue/50 rounded",n&&"relative z-50"),onMouseEnter:I,onMouseLeave:v,onClick:S,style:{pointerEvents:"auto"},children:t.jsxs(K,{color:P(),filled:!0,className:"type-data-xs shadow-lg border border-current/30",children:[r&&t.jsx(ye,{className:"w-2.5 h-2.5 mr-1"}),c,n&&h.name&&t.jsx("span",{className:"ml-1 opacity-75",children:h.name})]})})}function Le({hopNumber:c,snr:r,edgeColor:m}){return t.jsxs("div",{className:"flex flex-col items-center gap-0.5 pointer-events-none",children:[t.jsx("span",{className:"w-3.5 h-3.5 rounded-full flex items-center justify-center font-mono font-bold tabular-nums shadow-md",style:{backgroundColor:m||q[500],color:"#fff",fontSize:"8px",lineHeight:1,textShadow:"0 1px 1px rgba(0,0,0,0.4)"},children:c}),r!==void 0&&t.jsx(K,{color:"zinc",compact:!0,className:"!text-[9px] font-mono tabular-nums shadow-sm",children:r.toFixed(1)})]})}function Fe({resolvedPath:c,localNode:r,hubNodes:m=[],hoveredHopIndex:W,onHoverHop:y,traceSnr:g}){const F=g!==void 0&&g.length>0,h=a.useRef(null),E=pe(),N=ie(),S=a.useMemo(()=>new Set(m),[m]),[n,k]=a.useState(null),I=le(),[v,P]=a.useState(!1),[Z,H]=a.useState(0);a.useEffect(()=>{var f;const e=(f=h.current)==null?void 0:f.getMap();if(!e)return;const o=e.getCanvas();if(!o)return;const s=l=>{l.preventDefault(),console.warn("[PathMapMapLibre] WebGL context lost")},i=()=>{console.info("[PathMapMapLibre] WebGL context restored, remounting..."),H(l=>l+1)};return o.addEventListener("webglcontextlost",s),o.addEventListener("webglcontextrestored",i),()=>{o.removeEventListener("webglcontextlost",s),o.removeEventListener("webglcontextrestored",i)}},[Z]);const{positions:j,markers:$,edges:D}=a.useMemo(()=>{const e=[],o=[],s=[],i=[],f=(p,R)=>p!==0||R!==0;let l=0,b=!1;return c.hops.forEach((p,R)=>{const Q=p.candidates.filter(d=>f(d.latitude,d.longitude));if(Q.length===0)return;const V=[...Q].sort((d,w)=>w.probability-d.probability),A=V[0],L=[A.longitude,A.latitude];if(i.push(L),i.length>=2){const d=i[i.length-2],w=i.length-2,M=g==null?void 0:g[w],T=L[0]-d[0],se=L[1]-d[1],ne=Math.atan2(T,se)*(180/Math.PI),re=G();let B;b?B="#F97316":M!==void 0?B=de()[ce(M,N)]||q[500]:B=re.edgeColor,s.push({from:d,to:L,snrFwd:M,midpoint:[(d[0]+L[0])/2,(d[1]+L[1])/2],bearing:ne,color:B,isFromWardrive:b})}const te=p.isSource===!0,oe=p.isDestination===!0;b=A.isWardrive===!0,V.forEach((d,w)=>{const M=[d.latitude,d.longitude];e.push(M);const T=w===0;o.push({position:M,prefix:p.prefix,confidence:p.confidence,candidateCount:V.length,hopIndex:R,candidate:d,isHub:S.has(d.hash),isPrimary:T,isSource:te,isDestination:oe,validIndex:l})}),l++}),{positions:e,markers:o,edges:s}},[c,S,g,N]),J=a.useMemo(()=>D.map(e=>({type:"FeatureCollection",features:[{type:"Feature",properties:{},geometry:{type:"LineString",coordinates:[e.from,e.to]}}]})),[D]),u=a.useMemo(()=>{const e=$.filter(l=>l.isPrimary&&(l.confidence>=.5||l.isSource||l.isDestination));if(e.length===0)return null;let o=1/0,s=-1/0,i=1/0,f=-1/0;for(const l of e){const[b,p]=l.position;bs&&(s=b),pf&&(f=p)}return[[i,o],[f,s]]},[$]),_=a.useMemo(()=>{if(j.length===0)return r?[r.longitude,r.latitude]:[0,0];let e=0,o=0;for(const[s,i]of j)e+=s,o+=i;return[o/j.length,e/j.length]},[j,r]),U=a.useCallback(()=>{var o;const e=(o=h.current)==null?void 0:o.getMap();if(!e||!u){P(!0);return}e.fitBounds(u,{padding:{top:50,bottom:50,left:50,right:50},maxZoom:15,duration:0}),setTimeout(()=>{P(!0)},50)},[u]),X=a.useMemo(()=>u?`${u[0][0].toFixed(5)},${u[0][1].toFixed(5)},${u[1][0].toFixed(5)},${u[1][1].toFixed(5)}`:"",[u]);a.useEffect(()=>{var o;if(!v)return;const e=(o=h.current)==null?void 0:o.getMap();!e||!u||e.fitBounds(u,{padding:{top:50,bottom:50,left:50,right:50},maxZoom:15,duration:300})},[X,v,u]);const O=I&&v,ee=a.useCallback(e=>{k({longitude:e.position[1],latitude:e.position[0],marker:e})},[]);return j.length===0?t.jsx("div",{className:"h-full flex items-center justify-center text-fg-muted text-sm bg-elevated",children:"No mappable path data"}):t.jsxs("div",{className:"h-full w-full relative radius-inner overflow-hidden depth-stroke-inset",children:[!O&&t.jsx("div",{className:"absolute inset-0 bg-elevated flex items-center justify-center pointer-events-none",children:t.jsx("div",{className:"w-5 h-5 border-2 border-text-muted/30 border-t-text-muted rounded-full animate-spin"})}),t.jsx("div",{className:"h-full w-full transition-opacity duration-300 ease-out",style:{opacity:O?1:0},children:t.jsxs(me,{ref:h,initialViewState:{longitude:_[0],latitude:_[1],zoom:10},onLoad:U,style:{height:"100%",width:"100%"},mapStyle:ve,attributionControl:!1,children:[t.jsx(fe,{mode:E}),D.map((e,o)=>t.jsx(ge,{id:`edge-${o}`,type:"geojson",data:J[o],children:t.jsx(he,{id:`edge-line-${o}`,type:"line",paint:{"line-color":e.color,"line-width":4,"line-opacity":1},layout:{"line-cap":"round","line-join":"round"}})},`edge-${o}`)),D.map((e,o)=>t.jsx(Y,{longitude:e.midpoint[0],latitude:e.midpoint[1],anchor:"center",children:t.jsx(Le,{hopNumber:o+1,snr:F?e.snrFwd:void 0,edgeColor:e.color})},`hop-${o}`)),(()=>{const e=$.filter(s=>s.isPrimary),o=e.length>1?e.length-2:-1;return e.map((s,i)=>{const f=W===s.hopIndex,l=i===o&&!s.candidate.isLocal&&!s.isDestination;return t.jsx(Y,{longitude:s.position[1],latitude:s.position[0],anchor:"center",children:t.jsx(je,{prefix:s.prefix,isLocal:s.candidate.isLocal||!1,isSource:s.isSource,isDestination:s.isDestination,isLastHop:l,isHighlighted:f,isWardrive:s.candidate.isWardrive||!1,candidate:s.candidate,onHover:()=>y==null?void 0:y(s.hopIndex),onLeave:()=>y==null?void 0:y(null),onClick:()=>ee(s)})},`${s.hopIndex}-${s.candidate.hash}`)})})(),n&&t.jsx(xe,{longitude:n.longitude,latitude:n.latitude,anchor:"bottom",offset:[0,-12],closeOnClick:!1,onClose:()=>k(null),className:"maplibre-popup",children:t.jsxs("div",{className:"text-xs",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:"font-semibold",children:n.marker.candidate.name}),(()=>{const e=G();return t.jsxs(t.Fragment,{children:[n.marker.isSource&&t.jsx("span",{className:"px-1 py-0.5 text-[8px] font-bold rounded",style:{backgroundColor:e.sourceColor,color:"#000"},children:"SRC"}),n.marker.isDestination&&t.jsx("span",{className:"px-1 py-0.5 text-[8px] font-bold rounded",style:{backgroundColor:e.destinationColor,color:"#000"},children:"DST"}),n.marker.isHub&&t.jsx("span",{className:"px-1 py-0.5 text-[8px] font-bold rounded",style:{backgroundColor:e.hubColor,color:"#000"},children:"HUB"}),n.marker.candidate.isLocal&&t.jsx("span",{className:"px-1 py-0.5 text-[8px] font-bold rounded",style:{backgroundColor:e.localColor,color:"#fff"},children:"LOCAL"}),n.marker.candidate.isWardrive&&t.jsx("span",{className:"px-1 py-0.5 text-[8px] font-bold rounded",style:{backgroundColor:"#F97316",color:"#fff"},children:"WARDRIVE"})]})})()]}),t.jsxs("div",{className:"text-fg-muted type-data-xs",children:[n.marker.prefix," • ",n.marker.candidate.hash.slice(0,10),"..."]}),!n.marker.isPrimary&&n.marker.candidateCount>1&&t.jsxs("div",{style:{color:G().ambiguousColor},children:["Alternative (",(n.marker.candidate.probability*100).toFixed(0),"%)"]}),n.marker.isPrimary&&n.marker.candidateCount>1&&t.jsxs("div",{className:"text-fg-muted",children:[n.marker.candidateCount," candidates"]})]})})]},Z)})]})}export{Fe as default}; diff --git a/frontend/dist/assets/PathMapMapLibre-B3ia8Mj4.js b/frontend/dist/assets/PathMapMapLibre-B3ia8Mj4.js deleted file mode 100644 index 7edd36fc..00000000 --- a/frontend/dist/assets/PathMapMapLibre-B3ia8Mj4.js +++ /dev/null @@ -1,6 +0,0 @@ -import{d as ae,r as a,by as ie,br as le,fe as de,Z as Y,bB as ce,j as t,q as K,c as G,ff as ue}from"./index-C1ZF7cAz.js";import{u as pe,M as me,B as fe,S as ge,L as xe,a as Q,P as he}from"./BasemapLayer-CfNM-FKA.js";import{H as ye}from"./useMapViewStore-px_sYTaN.js";import"./index-DCNWD5GU.js";/** - * @license lucide-react v0.559.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const be=[["path",{d:"M19 17h2c.6 0 1-.4 1-1v-3c0-.9-.7-1.7-1.5-1.9C18.7 10.6 16 10 16 10s-1.3-1.4-2.2-2.3c-.5-.4-1.1-.7-1.8-.7H5c-.6 0-1.1.4-1.4.9l-1.4 2.9A3.7 3.7 0 0 0 2 12v4c0 .6.4 1 1 1h2",key:"5owen"}],["circle",{cx:"7",cy:"17",r:"2",key:"u2ysq9"}],["path",{d:"M9 17h6",key:"r8uit2"}],["circle",{cx:"17",cy:"17",r:"2",key:"axvx0g"}]],Ce=ae("car",be),ve={version:8,sources:{},layers:[],glyphs:"https://tiles.basemaps.cartocdn.com/fonts/{fontstack}/{range}.pbf"},h={nodeColor:"#4338CA",localColor:"#4F46E5",hubColor:"#6366F1",edgeColor:"#3B3F4A",ambiguousColor:"#F9D26F",highlightColor:"#B49DFF",sourceColor:"#39D98A",destinationColor:"#B49DFF"};function C(c,r){if(!c)return r;if(c.startsWith("#"))return c;const m=ue(c);return m?`#${m.r.toString(16).padStart(2,"0")}${m.g.toString(16).padStart(2,"0")}${m.b.toString(16).padStart(2,"0")}`:r}function z(){if(typeof document>"u")return h;const c=document.documentElement,r=getComputedStyle(c);return{nodeColor:C(r.getPropertyValue("--map-node-stroke").trim(),h.nodeColor),localColor:C(r.getPropertyValue("--map-local-color").trim(),h.localColor),hubColor:C(r.getPropertyValue("--map-hub-color").trim(),h.hubColor),edgeColor:C(r.getPropertyValue("--map-edge-rest").trim(),h.edgeColor),ambiguousColor:C(r.getPropertyValue("--sys-indigo").trim(),h.ambiguousColor),highlightColor:C(r.getPropertyValue("--sys-blue").trim(),h.highlightColor),sourceColor:C(r.getPropertyValue("--sys-green").trim(),h.sourceColor),destinationColor:C(r.getPropertyValue("--sys-blue").trim(),h.destinationColor)}}function je({prefix:c,isLocal:r,isSource:m,isDestination:W,isLastHop:y,isHighlighted:g,isWardrive:F,candidate:x,onHover:E,onLeave:N,onClick:S}){const[n,k]=a.useState(!1),I=a.useCallback(()=>{k(!0),E()},[E]),v=a.useCallback(()=>{k(!1),N()},[N]),P=()=>F?"orange":r?"amber":m?"green":y?"amber":W?"purple":"blue";return F?t.jsxs("div",{className:G("flex items-center cursor-pointer","transition-all duration-150",g&&"ring-2 ring-sys-blue/50 rounded-full",n&&"relative z-50"),onMouseEnter:I,onMouseLeave:v,onClick:S,style:{pointerEvents:"auto"},children:[t.jsx("div",{className:G("flex items-center justify-center","w-7 h-7 rounded-full","bg-sys-orange text-white","shadow-lg border-2 border-sys-orange/50","transition-transform duration-150",n&&"scale-110"),children:t.jsx(Ce,{className:"w-4 h-4",strokeWidth:2.5})}),n&&t.jsxs(K,{color:"orange",filled:!0,className:"ml-1 type-data-xs shadow-lg",children:[c,x.name&&t.jsx("span",{className:"ml-1 opacity-75",children:x.name})]})]}):t.jsx("div",{className:G("flex items-center cursor-pointer","transition-all duration-150",g&&"ring-2 ring-sys-blue/50 rounded",n&&"relative z-50"),onMouseEnter:I,onMouseLeave:v,onClick:S,style:{pointerEvents:"auto"},children:t.jsxs(K,{color:P(),filled:!0,className:"type-data-xs shadow-lg border border-current/30",children:[r&&t.jsx(ye,{className:"w-2.5 h-2.5 mr-1"}),c,n&&x.name&&t.jsx("span",{className:"ml-1 opacity-75",children:x.name})]})})}function Le({hopNumber:c,snr:r,edgeColor:m}){return t.jsxs("div",{className:"flex flex-col items-center gap-0.5 pointer-events-none",children:[t.jsx("span",{className:"w-3.5 h-3.5 rounded-full flex items-center justify-center font-mono font-bold tabular-nums shadow-md",style:{backgroundColor:m||Y[500],color:"#fff",fontSize:"8px",lineHeight:1,textShadow:"0 1px 1px rgba(0,0,0,0.4)"},children:c}),r!==void 0&&t.jsx(K,{color:"zinc",compact:!0,className:"!text-[9px] font-mono tabular-nums shadow-sm",children:r.toFixed(1)})]})}function Fe({resolvedPath:c,localNode:r,hubNodes:m=[],hoveredHopIndex:W,onHoverHop:y,traceSnr:g}){const F=g!==void 0&&g.length>0,x=a.useRef(null),E=pe(),N=ie(),S=a.useMemo(()=>new Set(m),[m]),[n,k]=a.useState(null),I=le(),[v,P]=a.useState(!1),[Z,H]=a.useState(0);a.useEffect(()=>{var f;const e=(f=x.current)==null?void 0:f.getMap();if(!e)return;const o=e.getCanvas();if(!o)return;const s=l=>{l.preventDefault(),console.warn("[PathMapMapLibre] WebGL context lost")},i=()=>{console.info("[PathMapMapLibre] WebGL context restored, remounting..."),H(l=>l+1)};return o.addEventListener("webglcontextlost",s),o.addEventListener("webglcontextrestored",i),()=>{o.removeEventListener("webglcontextlost",s),o.removeEventListener("webglcontextrestored",i)}},[Z]);const{positions:j,markers:$,edges:D}=a.useMemo(()=>{const e=[],o=[],s=[],i=[],f=(p,R)=>p!==0||R!==0;let l=0,b=!1;return c.hops.forEach((p,R)=>{const O=p.candidates.filter(d=>f(d.latitude,d.longitude));if(O.length===0)return;const V=[...O].sort((d,w)=>w.probability-d.probability),A=V[0],L=[A.longitude,A.latitude];if(i.push(L),i.length>=2){const d=i[i.length-2],w=i.length-2,M=g==null?void 0:g[w],T=L[0]-d[0],se=L[1]-d[1],ne=Math.atan2(T,se)*(180/Math.PI),re=z();let B;b?B="#F97316":M!==void 0?B=de()[ce(M,N)]||Y[500]:B=re.edgeColor,s.push({from:d,to:L,snrFwd:M,midpoint:[(d[0]+L[0])/2,(d[1]+L[1])/2],bearing:ne,color:B,isFromWardrive:b})}const te=p.isSource===!0,oe=p.isDestination===!0;b=A.isWardrive===!0,V.forEach((d,w)=>{const M=[d.latitude,d.longitude];e.push(M);const T=w===0;o.push({position:M,prefix:p.prefix,confidence:p.confidence,candidateCount:V.length,hopIndex:R,candidate:d,isHub:S.has(d.hash),isPrimary:T,isSource:te,isDestination:oe,validIndex:l})}),l++}),{positions:e,markers:o,edges:s}},[c,S,g,N]),J=a.useMemo(()=>D.map(e=>({type:"FeatureCollection",features:[{type:"Feature",properties:{},geometry:{type:"LineString",coordinates:[e.from,e.to]}}]})),[D]),u=a.useMemo(()=>{const e=$.filter(l=>l.isPrimary&&(l.confidence>=.5||l.isSource||l.isDestination));if(e.length===0)return null;let o=1/0,s=-1/0,i=1/0,f=-1/0;for(const l of e){const[b,p]=l.position;bs&&(s=b),pf&&(f=p)}return[[i,o],[f,s]]},[$]),_=a.useMemo(()=>{if(j.length===0)return r?[r.longitude,r.latitude]:[0,0];let e=0,o=0;for(const[s,i]of j)e+=s,o+=i;return[o/j.length,e/j.length]},[j,r]),U=a.useCallback(()=>{var o;const e=(o=x.current)==null?void 0:o.getMap();if(!e||!u){P(!0);return}e.fitBounds(u,{padding:{top:50,bottom:50,left:50,right:50},maxZoom:15,duration:0}),setTimeout(()=>{P(!0)},50)},[u]),X=a.useMemo(()=>u?`${u[0][0].toFixed(5)},${u[0][1].toFixed(5)},${u[1][0].toFixed(5)},${u[1][1].toFixed(5)}`:"",[u]);a.useEffect(()=>{var o;if(!v)return;const e=(o=x.current)==null?void 0:o.getMap();!e||!u||e.fitBounds(u,{padding:{top:50,bottom:50,left:50,right:50},maxZoom:15,duration:300})},[X,v,u]);const q=I&&v,ee=a.useCallback(e=>{k({longitude:e.position[1],latitude:e.position[0],marker:e})},[]);return j.length===0?t.jsx("div",{className:"h-full flex items-center justify-center text-fg-muted text-sm bg-elevated",children:"No mappable path data"}):t.jsxs("div",{className:"h-full w-full relative",children:[!q&&t.jsx("div",{className:"absolute inset-0 bg-elevated flex items-center justify-center pointer-events-none",children:t.jsx("div",{className:"w-5 h-5 border-2 border-text-muted/30 border-t-text-muted rounded-full animate-spin"})}),t.jsx("div",{className:"h-full w-full transition-opacity duration-300 ease-out",style:{opacity:q?1:0},children:t.jsxs(me,{ref:x,initialViewState:{longitude:_[0],latitude:_[1],zoom:10},onLoad:U,style:{height:"100%",width:"100%"},mapStyle:ve,attributionControl:!1,children:[t.jsx(fe,{mode:E}),D.map((e,o)=>t.jsx(ge,{id:`edge-${o}`,type:"geojson",data:J[o],children:t.jsx(xe,{id:`edge-line-${o}`,type:"line",paint:{"line-color":e.color,"line-width":4,"line-opacity":1},layout:{"line-cap":"round","line-join":"round"}})},`edge-${o}`)),D.map((e,o)=>t.jsx(Q,{longitude:e.midpoint[0],latitude:e.midpoint[1],anchor:"center",children:t.jsx(Le,{hopNumber:o+1,snr:F?e.snrFwd:void 0,edgeColor:e.color})},`hop-${o}`)),(()=>{const e=$.filter(s=>s.isPrimary),o=e.length>1?e.length-2:-1;return e.map((s,i)=>{const f=W===s.hopIndex,l=i===o&&!s.candidate.isLocal&&!s.isDestination;return t.jsx(Q,{longitude:s.position[1],latitude:s.position[0],anchor:"center",children:t.jsx(je,{prefix:s.prefix,isLocal:s.candidate.isLocal||!1,isSource:s.isSource,isDestination:s.isDestination,isLastHop:l,isHighlighted:f,isWardrive:s.candidate.isWardrive||!1,candidate:s.candidate,onHover:()=>y==null?void 0:y(s.hopIndex),onLeave:()=>y==null?void 0:y(null),onClick:()=>ee(s)})},`${s.hopIndex}-${s.candidate.hash}`)})})(),n&&t.jsx(he,{longitude:n.longitude,latitude:n.latitude,anchor:"bottom",offset:[0,-12],closeOnClick:!1,onClose:()=>k(null),className:"maplibre-popup",children:t.jsxs("div",{className:"text-xs",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:"font-semibold",children:n.marker.candidate.name}),(()=>{const e=z();return t.jsxs(t.Fragment,{children:[n.marker.isSource&&t.jsx("span",{className:"px-1 py-0.5 text-[8px] font-bold rounded",style:{backgroundColor:e.sourceColor,color:"#000"},children:"SRC"}),n.marker.isDestination&&t.jsx("span",{className:"px-1 py-0.5 text-[8px] font-bold rounded",style:{backgroundColor:e.destinationColor,color:"#000"},children:"DST"}),n.marker.isHub&&t.jsx("span",{className:"px-1 py-0.5 text-[8px] font-bold rounded",style:{backgroundColor:e.hubColor,color:"#000"},children:"HUB"}),n.marker.candidate.isLocal&&t.jsx("span",{className:"px-1 py-0.5 text-[8px] font-bold rounded",style:{backgroundColor:e.localColor,color:"#fff"},children:"LOCAL"}),n.marker.candidate.isWardrive&&t.jsx("span",{className:"px-1 py-0.5 text-[8px] font-bold rounded",style:{backgroundColor:"#F97316",color:"#fff"},children:"WARDRIVE"})]})})()]}),t.jsxs("div",{className:"text-fg-muted type-data-xs",children:[n.marker.prefix," • ",n.marker.candidate.hash.slice(0,10),"..."]}),!n.marker.isPrimary&&n.marker.candidateCount>1&&t.jsxs("div",{style:{color:z().ambiguousColor},children:["Alternative (",(n.marker.candidate.probability*100).toFixed(0),"%)"]}),n.marker.isPrimary&&n.marker.candidateCount>1&&t.jsxs("div",{className:"text-fg-muted",children:[n.marker.candidateCount," candidates"]})]})})]},Z)})]})}export{Fe as default}; diff --git a/frontend/dist/assets/RoomServer-C_iTtq7Y.js b/frontend/dist/assets/RoomServer-DiyUSElG.js similarity index 86% rename from frontend/dist/assets/RoomServer-C_iTtq7Y.js rename to frontend/dist/assets/RoomServer-DiyUSElG.js index 2c707752..dbf41b3b 100644 --- a/frontend/dist/assets/RoomServer-C_iTtq7Y.js +++ b/frontend/dist/assets/RoomServer-DiyUSElG.js @@ -1,9 +1,9 @@ -import{d as V,j as e,c$ as Ke,c as L,aw as Fe,dO as Oe,r as o,bO as Y,R as qe,ac as Be,dw as ze,ad as He,q as W,I as B,dP as Ue,B as F,bx as Me,ae as ue,cW as Ve,F as se,w as G,x as We,dQ as Re,dR as Ge,b8 as Te,dS as Ye,dT as Ie,dU as Qe,dV as Xe,dW as Ze,dX as Je,dY as es,dZ as ss,E as ts,y as as,dJ as ns,bQ as xe}from"./index-C1ZF7cAz.js";import{C as U,P as pe,a as he,B as rs}from"./PageLayout-sd81yog0.js";import{R as ls,C as ge}from"./Grid-DrJ5vfLo.js";import{c as os,m as is}from"./node-types-BJeLdOcD.js";import{L as cs,a as ds,b as ms}from"./listbox-vfp6JG3P.js";import{P as us}from"./plus-BvRrZnfw.js";import{M as Z}from"./map-pin-DEktgLFN.js";import{T as Le,C as fe}from"./ConfirmModal-Cf30hpC_.js";import{S as J,K as I}from"./KeycapButton-DkbJ4iVA.js";import{S as xs,C as ps,M as hs}from"./ChatBubble-jJytaTX9.js";import{e as gs,g as fs,a as js}from"./chat-utils-BzC-Ehs-.js";import{W as ee}from"./wifi-BBDEuc94.js";import{K as vs}from"./key-round-Chd2xrtI.js";import"./element-movement-CuySBNA6.js";import"./triangle-alert-B3ZB2VPZ.js";import"./keycap-sfx-ByZp-njj.js";/** +import{d as V,j as e,cZ as Ke,c as L,az as Fe,dM as Oe,r as o,bP as Y,R as ze,ag as Be,dt as He,ah as qe,v as G,I as B,dN as Ue,B as F,by as Me,ai as ue,cU as Ve,H as se,y as W,z as Ge,dO as Re,dP as We,bb as Te,dQ as Ye,dR as Ie,dS as Xe,dT as Ze,dU as Qe,dV as Je,dW as es,dX as ss,G as ts,D as as,dH as ns,bR as xe}from"./index-DhkG1Nx9.js";import{C as U,P as pe,a as he,B as rs}from"./PageLayout-BkUTZXJb.js";import{R as ls,C as ge}from"./Grid-DknC4rR5.js";import{c as os,m as is}from"./node-types-CgBRFpS8.js";import{L as cs,a as ds,b as ms}from"./listbox-CyP6uw8j.js";import{P as us}from"./plus-Pe5yI_FS.js";import{M as Q}from"./map-pin-BHGohRD7.js";import{T as Le,C as fe}from"./ConfirmModal-BoB1If6b.js";import{S as J,K as I}from"./KeycapButton-xjzZCjhU.js";import{S as xs,C as ps,M as hs}from"./ChatBubble-BP7NjdbB.js";import{e as gs,g as fs,a as js}from"./chat-utils-DA-kxQ-o.js";import{W as ee}from"./wifi-u03iIDZF.js";import{K as vs}from"./key-round-pRzIhNB6.js";import"./element-movement-BPGrReFv.js";import"./triangle-alert-D8NErBXC.js";import"./keycap-sfx-ByZp-njj.js";/** * @license lucide-react v0.559.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const ys=[["path",{d:"M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719",key:"1sd12s"}]],Ee=V("message-circle",ys);/** + */const ys=[["path",{d:"M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719",key:"1sd12s"}]],Pe=V("message-circle",ys);/** * @license lucide-react v0.559.0 - ISC * * This source code is licensed under the ISC license. @@ -23,4 +23,4 @@ import{d as V,j as e,c$ as Ke,c as L,aw as Fe,dO as Oe,r as o,bO as Y,R as qe,ac * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const Ss=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"17",x2:"22",y1:"8",y2:"13",key:"3nzzx3"}],["line",{x1:"22",x2:"17",y1:"8",y2:"13",key:"1swrse"}]],_s=V("user-x",Ss);function z({disabled:s,className:t,children:l}){return e.jsx(Ke,{disabled:s,className:L("flex flex-col gap-2",t),children:l})}function H({required:s,className:t,children:l,...a}){return e.jsxs(Fe,{className:L("text-sm font-medium text-fg-primary select-none","data-[disabled]:opacity-50",a.title&&"cursor-help",t),...a,children:[l,s&&e.jsx("span",{className:"text-sys-red ml-0.5","aria-hidden":"true",children:"*"})]})}function Ms({className:s,children:t,...l}){return e.jsx(Oe,{className:L("text-sm text-fg-muted","data-[disabled]:opacity-50",s),...l,children:t})}function Rs(s,t){return o.useMemo(()=>{const a=new Map;for(const[n,c]of Object.entries(s)){const m=c.name||c.node_name||null,{type:d}=os(c);a.set(n.toLowerCase(),{name:m,type:d})}const r=new Map;for(let n=t.length-1;n>=0;n--){const c=t[n];if(!c._advertSender)continue;const m=c._advertSender.toLowerCase();if(r.has(m))continue;const d=c._advertName??null,i=c._advertNodeType!=null?is(c._advertNodeType):"companion";r.set(m,{name:d,type:i})}return function(c){const m=c.toLowerCase(),d=a.get(m);if(d!=null&&d.name)return d;const i=r.get(m);return i!=null&&i.name?i:d||i||{name:null,type:"companion"}}},[s,t])}function ve({icon:s,title:t,description:l,onClick:a,accent:r}){return e.jsxs("button",{onClick:a,className:L("flex flex-col items-center gap-3 p-6 rounded-2xl text-center","ring-1 ring-edge-subtle hover:ring-2 transition-all duration-150","w-full max-w-[260px]",r==="primary"?"hover:ring-sys-blue hover:bg-sys-blue/5":"hover:ring-sys-indigo hover:bg-sys-indigo/5"),children:[e.jsx("div",{className:L("p-3 rounded-xl",r==="primary"?"bg-sys-blue/10 text-sys-blue":"bg-sys-indigo/10 text-sys-indigo"),children:s}),e.jsx("p",{className:"type-body-sm font-medium text-fg-primary",children:t}),e.jsx("p",{className:"type-data-xs text-fg-muted leading-relaxed",children:l})]})}function Ts({onCreateRoom:s}){return e.jsxs("div",{className:"flex flex-col items-center justify-center py-16 px-4",children:[e.jsx(Y,{className:"w-12 h-12 text-fg-muted opacity-30 mb-4"}),e.jsx("p",{className:"type-subheading text-fg-secondary mb-1",children:"Add a Room Server"}),e.jsx("p",{className:"type-body-sm text-fg-muted mb-8",children:"Choose how this device should operate."}),e.jsxs("div",{className:"flex flex-col sm:flex-row items-center gap-4",children:[e.jsx(ve,{icon:e.jsx(ws,{className:"w-6 h-6"}),title:"Repeater + Room Server",description:"Keep forwarding packets and add group messaging.",onClick:()=>s("hybrid"),accent:"primary"}),e.jsx(ve,{icon:e.jsx(qe,{className:"w-6 h-6"}),title:"Dedicated Room Server",description:"Stop repeating. Focus entirely on room server duties.",onClick:()=>s("dedicated"),accent:"secondary"})]})]})}function Ls({rooms:s,selected:t,onSelect:l,onAdd:a}){const r=a?e.jsx("button",{onClick:a,className:L("flex items-center justify-center px-2 py-1 rounded-md","text-fg-muted hover:text-fg-primary hover:bg-surface/60","transition-all duration-150"),title:"Add room server",children:e.jsx(us,{className:"w-4 h-4"})}):null;return s.length<=1?r:s.length<=3?e.jsxs("div",{className:"flex items-center gap-0.5 p-0.5 rounded-lg bg-subtle-fill",children:[s.map(n=>e.jsx("button",{onClick:()=>l(n.room_name),className:L("px-3 py-1 rounded-md text-sm font-medium transition-all duration-150",n.room_name===t?"bg-surface text-fg-primary shadow-sm":"text-fg-muted hover:text-fg-secondary"),children:n.room_name},n.room_name)),r]}):e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(cs,{value:t??"",onChange:l,children:s.map(n=>e.jsx(ds,{value:n.room_name,children:e.jsx(ms,{children:n.room_name})},n.room_name))}),r]})}function Es(s){if(!s)return"";const t=s.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"");return t?`${t}-room`:""}function ye({open:s,onClose:t,mode:l,identity:a,repeaterConfig:r,onCreate:n,onUpdate:c,onDelete:m,onSendAdvert:d}){var te,ae,ne,re,le,oe,ie,ce,de;const i=l==="edit"&&a,u=`${s}-${(a==null?void 0:a.name)??""}-${l}`,[x,f]=o.useState(""),[j,y]=o.useState(""),[g,E]=o.useState(!1),[C,S]=o.useState(""),[b,_]=o.useState(""),[N,M]=o.useState(""),[k,R]=o.useState(""),[w,P]=o.useState(!1),[D,A]=o.useState(!1),[O,$]=o.useState(!1),[K,T]=o.useState(null),[q,h]=o.useState(u);if(u!==q)if(h(u),T(null),P(!1),A(!1),$(!1),i)f(((te=a.settings)==null?void 0:te.node_name)??a.name),y(a.identity_key??""),E(!1),S(((ae=a.settings)==null?void 0:ae.admin_password)??""),_(((ne=a.settings)==null?void 0:ne.guest_password)??""),M(((le=(re=a.settings)==null?void 0:re.latitude)==null?void 0:le.toString())??""),R(((ie=(oe=a.settings)==null?void 0:oe.longitude)==null?void 0:ie.toString())??"");else{const p=r;f(""),y(""),E(!1),S(""),_(""),M(((ce=p==null?void 0:p.repeater)==null?void 0:ce.latitude)!=null?p.repeater.latitude.toString():""),R(((de=p==null?void 0:p.repeater)==null?void 0:de.longitude)!=null?p.repeater.longitude.toString():"")}const v=o.useCallback(()=>{const p={};return x&&(p.node_name=x),C&&(p.admin_password=C),b&&(p.guest_password=b),N!==""&&(p.latitude=parseFloat(N)),k!==""&&(p.longitude=parseFloat(k)),p},[x,C,b,N,k]),De=o.useCallback(async()=>{if(!x.trim()){T("Room name is required");return}P(!0),T(null);const p=i?a.name:Es(x);let X;if(i)X=await c({name:a.name,settings:v()});else{const me={name:p,type:"room_server",settings:v()};j.trim()&&(me.identity_key=j.trim()),X=await n(me)}P(!1),X?t():T("Failed to save. Check that the name is unique and passwords differ.")},[x,i,a,v,n,c,t]),Ae=o.useCallback(async()=>{if(!i)return;A(!0);const p=await m(a.name);A(!1),p&&t()},[i,a,m,t]),$e=o.useCallback(async()=>{i&&($(!0),await d(a.name),$(!1))},[i,a,d]);return e.jsxs(Be,{open:s,onClose:t,size:"md",children:[e.jsx(ze,{icon:i?void 0:e.jsx(bs,{className:"w-5 h-5"}),title:i?"Edit Room Server":"Add Room Server",onClose:t}),e.jsx(He,{children:e.jsxs("div",{className:"space-y-5",children:[i&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(W,{color:a.registered?"green":"red",children:a.registered?"Active":"Inactive"}),a.identity_key&&e.jsxs("span",{className:"type-data-xs text-fg-muted truncate",title:a.identity_key,children:["Key: ",a.identity_key.slice(0,16),"…"]})]}),e.jsxs(z,{children:[e.jsx(H,{title:"What people see on the mesh",children:"Room Name"}),e.jsx(B,{value:x,onChange:p=>f(p.target.value),placeholder:"Room Name"})]}),!i&&e.jsxs(z,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(H,{title:"The unique hex public ID",children:["Identity Key ",e.jsx("span",{className:"text-fg-muted font-normal",children:"(Optional)"})]}),e.jsx("button",{type:"button",onClick:()=>E(p=>!p),className:"type-data-xs text-fg-muted underline hover:text-fg-secondary",children:g?"Hide":"Show"})]}),g&&e.jsxs(e.Fragment,{children:[e.jsx(B,{value:j,onChange:p=>y(p.target.value),placeholder:"Leave empty to auto-generate"}),e.jsx(Ms,{children:"Leave empty to automatically generate a secure key"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs(z,{children:[e.jsxs(H,{children:[e.jsx(Z,{className:"inline w-3.5 h-3.5 -mt-0.5 mr-1 text-fg-muted"}),"Latitude"]}),e.jsx(B,{type:"number",step:"any",value:N,onChange:p=>M(p.target.value),placeholder:"0"})]}),e.jsxs(z,{children:[e.jsxs(H,{children:[e.jsx(Z,{className:"inline w-3.5 h-3.5 -mt-0.5 mr-1 text-fg-muted"}),"Longitude"]}),e.jsx(B,{type:"number",step:"any",value:k,onChange:p=>R(p.target.value),placeholder:"0"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs(z,{children:[e.jsxs(H,{title:"Full access to room server",children:["Admin Password ",e.jsx("span",{className:"text-fg-muted font-normal",children:"(Optional)"})]}),e.jsx(B,{type:"password",value:C,onChange:p=>S(p.target.value),placeholder:"None Set"})]}),e.jsxs(z,{children:[e.jsxs(H,{title:"Can post and read, but not administer the room",children:["Guest Password ",e.jsx("span",{className:"text-fg-muted font-normal",children:"(Optional)"})]}),e.jsx(B,{type:"password",value:b,onChange:p=>_(p.target.value),placeholder:"None Set"})]})]}),K&&e.jsx("p",{className:"type-data-xs text-sys-red",children:K})]})}),e.jsxs(Ue,{children:[i&&e.jsxs("div",{className:"flex items-center gap-2 mr-auto",children:[e.jsxs(F,{color:"danger",plain:!0,onClick:Ae,disabled:D,children:[e.jsx(Le,{"data-slot":"icon"}),D?"Deleting…":"Delete"]}),e.jsxs(F,{color:"primary",plain:!0,onClick:$e,disabled:O,children:[e.jsx(Me,{"data-slot":"icon"}),O?"Sending…":"Send Advert"]})]}),e.jsx(F,{plain:!0,onClick:t,children:"Cancel"}),e.jsx(F,{color:"primary",onClick:De,disabled:w,children:w?"Saving…":i?"Save Changes":"Create"})]})]})}const Pe=o.createContext(null),Ne="room-tui";function be({children:s}){const[t,l]=o.useState(()=>localStorage.getItem(Ne)!=="0"),a=o.useCallback(()=>{l(r=>{const n=!r;return localStorage.setItem(Ne,n?"1":"0"),n})},[]);return e.jsx(Pe.Provider,{value:{terminalMode:t,toggleTerminalMode:a},children:s})}function Q(){const s=o.useContext(Pe);if(!s)throw new Error("useTerminalMode must be used within RoomTerminalProvider");return s}const ke=s=>s.author_pubkey==="server"||s.author_pubkey==="system";function we({messages:s,onDelete:t,terminalMode:l,serverName:a}){const r=o.useRef(null),[n,c]=o.useState(!1),m=o.useMemo(()=>[...s].sort((u,x)=>u.post_timestamp-x.post_timestamp),[s]);o.useEffect(()=>{!n&&r.current&&(r.current.scrollTop=0)},[m.length,n]);const d=o.useCallback(()=>{r.current&&c(r.current.scrollTop<-100)},[]),i=o.useCallback(()=>{r.current&&r.current.scrollTo({top:0,behavior:"smooth"}),c(!1)},[]);return m.length===0?e.jsx("div",{className:`flex-1 flex flex-col items-center justify-center py-12 min-h-0${l?" font-mono":""}`,children:l?e.jsx("p",{className:"text-sm font-mono",style:{color:"var(--tui-accent)",opacity:.4},children:"> no messages in buffer_"}):e.jsxs(e.Fragment,{children:[e.jsx(Y,{className:"w-10 h-10 text-fg-muted opacity-20 mb-2"}),e.jsx("p",{className:"type-data-sm text-fg-muted",children:"No messages yet"})]})}):l?e.jsxs("div",{className:"relative flex-1 min-h-0",children:[e.jsx("div",{ref:r,onScroll:d,className:"h-full overflow-y-auto scroll-smooth p-4 font-mono text-sm leading-relaxed flex flex-col-reverse",children:e.jsx("div",{children:m.map(u=>{const x=ke(u),f=new Date(u.post_timestamp*1e3).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}),j=x?"SYS":u.author_name||u.author_prefix,y=!x&&a&&j===a;return e.jsxs("div",{className:"group flex items-start gap-0 -mx-4 px-4 py-px",style:{"--tw-hover-bg":"var(--tui-hover-bg)"},onMouseEnter:g=>g.currentTarget.style.background="var(--tui-hover-bg)",onMouseLeave:g=>g.currentTarget.style.background="",children:[e.jsxs("span",{className:"select-none shrink-0",style:{color:"var(--tui-muted)"},children:["[",f,"]"]}),e.jsxs("span",{className:"mx-1.5 shrink-0",style:{color:y?"var(--tui-accent-local)":"var(--tui-accent)"},children:["<",j,">"]}),e.jsx("span",{style:{color:x?"var(--tui-system)":y?"var(--tui-body)":"var(--tui-accent)"},className:x?"italic":"",children:u.message_text}),e.jsx("button",{onClick:()=>t(u.id),className:"opacity-0 group-hover:opacity-100 ml-auto pl-2 shrink-0 transition-colors",style:{color:"var(--tui-muted)"},onMouseEnter:g=>g.currentTarget.style.color="var(--tui-danger)",onMouseLeave:g=>g.currentTarget.style.color="var(--tui-muted)",title:"Delete",children:"×"})]},u.id)})})}),n&&e.jsxs("button",{onClick:i,className:"absolute bottom-3 left-1/2 -translate-x-1/2 flex items-center gap-1.5 px-3 py-1 font-mono text-xs transition-colors duration-150",style:{background:"var(--tui-hover-bg)",border:"1px solid var(--tui-muted)",color:"var(--tui-accent)"},children:[e.jsx(ue,{className:"w-3 h-3"}),"↓ scroll"]})]}):e.jsxs("div",{className:"relative flex-1 min-h-0",children:[e.jsx("div",{ref:r,onScroll:d,className:"h-full overflow-y-auto scroll-smooth flex flex-col-reverse",children:e.jsx("div",{className:"space-y-3 p-4",children:m.map(u=>ke(u)?e.jsx(xs,{text:u.message_text},u.id):e.jsx(ps,{senderName:u.author_name||u.author_prefix,text:u.message_text,timestamp:u.post_timestamp,bubbleAccessory:e.jsx("button",{onClick:()=>t(u.id),className:"opacity-0 group-hover:opacity-100 transition-opacity duration-150 p-1 text-fg-muted hover:text-sys-red flex-shrink-0",title:"Delete message",children:e.jsx(Le,{className:"w-3.5 h-3.5"})})},u.id))})}),n&&e.jsxs("button",{onClick:i,className:"absolute bottom-3 left-1/2 -translate-x-1/2 flex items-center gap-1.5 px-3 py-1.5 rounded-full bg-surface/90 backdrop-blur-sm ring-1 ring-edge-subtle shadow-md text-fg-secondary hover:text-fg-primary transition-colors duration-150",children:[e.jsx(ue,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"type-data-xs",children:"New messages"})]})]})}function Ce({roomName:s,onSend:t,disabled:l,terminalMode:a}){const[r,n]=o.useState(""),[c,m]=o.useState(!1),d=o.useRef(null),i=o.useCallback(async()=>{var j;const x=r.trim();if(!x||c)return;m(!0);const f=await t(x);m(!1),f&&(n(""),(j=d.current)==null||j.focus())},[r,c,t]),u=o.useCallback(x=>{x.key==="Enter"&&!x.shiftKey&&(x.preventDefault(),i())},[i]);return a?e.jsxs("div",{className:"flex items-center gap-0 px-4 py-2 type-data-sm",children:[e.jsx("input",{ref:d,type:"text",value:r,onChange:x=>n(x.target.value),onKeyDown:u,placeholder:"type message...",disabled:l||c,className:"flex-1 bg-transparent outline-none ring-0 shadow-none border-none focus:outline-none focus:ring-0 font-mono tui-input",style:{color:"var(--tui-body)"}}),e.jsx("button",{onClick:i,disabled:!r.trim()||c||l,className:"transition-colors duration-100 px-1 font-mono text-xs disabled:opacity-30",style:{color:"var(--tui-accent)"},title:"Send",children:"[↵]"})]}):e.jsxs("div",{className:"flex items-center gap-2 p-3 border-t border-edge-subtle",children:[e.jsx("input",{ref:d,type:"text",value:r,onChange:x=>n(x.target.value),onKeyDown:u,placeholder:`Message ${s}…`,disabled:l||c,className:"flex-1 surface-input radius-inner px-3 py-2 type-body-sm text-fg-primary placeholder:text-fg-muted outline-none ring-focus"}),e.jsx("button",{onClick:i,disabled:!r.trim()||c||l,className:"p-2 rounded-lg text-sys-blue hover:bg-sys-blue/10 disabled:opacity-30 disabled:hover:bg-transparent transition-colors duration-150",title:"Send message",children:e.jsx(Me,{className:"w-4.5 h-4.5"})})]})}function Ps({selectedName:s,selectedIdentity:t,messages:l,onSend:a,onDelete:r,onClear:n}){var f;const{terminalMode:c,toggleTerminalMode:m}=Q(),[d,i]=o.useState(!1),u=((f=t==null?void 0:t.settings)==null?void 0:f.node_name)??s??void 0,x=o.useCallback(()=>{i(!1),n()},[n]);return c?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-col h-full gap-1.5",children:[e.jsxs("div",{className:"card-terminal-header flex-shrink-0",children:[e.jsx("span",{className:"seven-seg-panel",children:e.jsx(J,{text:"chat",minChars:7,size:24})}),e.jsx("div",{className:"card-terminal-ridge flex-1"}),e.jsxs("div",{className:"header-well",children:[e.jsx(I,{icon:e.jsx(je,{className:"!w-5.5 !h-5.5 translate-y-px"}),onClick:m,title:"Exit terminal mode"}),l.length>0&&e.jsx(I,{icon:e.jsx("span",{className:"text-[13px] font-bold font-mono leading-none translate-y-px",children:"DEL"}),onClick:()=>i(!0),title:"Clear all messages",variant:"red",iconActiveColor:Ve.red})]})]}),e.jsx(U,{noPadding:!0,className:"flex flex-col flex-1 min-h-0 overflow-hidden card-terminal",children:e.jsxs("div",{className:"card-terminal-well flex-1 min-h-0 flex flex-col overflow-hidden",children:[e.jsx(we,{messages:l,onDelete:r,terminalMode:!0,serverName:u}),e.jsx("div",{className:"card-terminal-divider"}),s&&e.jsx(Ce,{roomName:s,onSend:a,disabled:!(t!=null&&t.registered),terminalMode:!0})]})})]}),e.jsx(fe,{isOpen:d,title:"Clear All Messages",message:`This will permanently delete all ${l.length} message${l.length===1?"":"s"} from this room. This cannot be undone.`,confirmLabel:"Clear Messages",variant:"danger",onConfirm:x,onCancel:()=>i(!1)})]}):e.jsxs(e.Fragment,{children:[e.jsxs(U,{noPadding:!0,className:"flex flex-col h-full overflow-hidden",children:[e.jsx(se,{listHeader:!0,icon:e.jsx(Ee,{className:"icon-sm"}),title:"Messages",actions:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(F,{plain:!0,onClick:m,title:"Terminal mode",children:e.jsx(je,{"data-slot":"icon",className:"!w-5 !h-5 translate-y-px"})}),l.length>0&&e.jsx(F,{plain:!0,onClick:()=>i(!0),title:"Clear all messages",children:e.jsx("span",{"data-slot":"icon",className:"text-[12px] font-bold font-mono leading-none translate-y-px text-sys-red",children:"DEL"})})]})}),e.jsx(we,{messages:l,onDelete:r,terminalMode:!1,serverName:u}),s&&e.jsx(Ce,{roomName:s,onSend:a,disabled:!(t!=null&&t.registered),terminalMode:!1})]}),e.jsx(fe,{isOpen:d,title:"Clear All Messages",message:`This will permanently delete all ${l.length} message${l.length===1?"":"s"} from this room. This cannot be undone.`,confirmLabel:"Clear Messages",variant:"danger",onConfirm:x,onCancel:()=>i(!1)})]})}function Ds({pubkey:s,className:t}){const[l,a]=o.useState(!1),r=o.useCallback(()=>{navigator.clipboard.writeText(s),a(!0),setTimeout(()=>a(!1),1500)},[s]);return e.jsxs("button",{onClick:r,title:l?"Copied!":"Copy public key",className:`inline-flex items-center gap-1 type-data-xs leading-tight text-fg-muted hover:text-fg-secondary transition-colors duration-150 cursor-copy ${t??""}`,children:[e.jsx("span",{className:"truncate min-w-0",children:s.slice(0,8)}),l&&e.jsx(G,{className:"w-2.5 h-2.5 text-sys-green flex-shrink-0"})]})}const As=o.memo(function({client:t,resolvedName:l,onRemove:a}){const r=t.name||l,n=t.unsynced_count===0,c=t.last_activity?new Date(t.last_activity*1e3).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}):"Never",{emoji:m,cleanName:d}=r?gs(r):{emoji:null,cleanName:t.pubkey_prefix},i=r?fs(d):void 0,u=r?js(r):t.pubkey_prefix.slice(0,2).toUpperCase();return e.jsxs("div",{className:"group flex items-center gap-3 px-3 py-2.5 radius-inner row-hover transition-base",children:[e.jsxs("div",{className:"relative flex-shrink-0",children:[e.jsx("div",{className:L("w-8 h-8 rounded-full flex items-center justify-center",!i&&"bg-sys-blue/12"),style:i?{backgroundColor:i}:void 0,children:m?e.jsx("span",{className:"text-base leading-none",children:m}):e.jsx("span",{className:L("leading-none",i?"text-white text-[11px] font-bold tracking-tight":"text-sys-blue font-mono text-[11px]"),children:u})}),e.jsx("span",{className:`absolute -bottom-0.5 -right-0.5 w-2.5 h-2.5 rounded-sm ring-2 ring-surface ${n?"bg-sys-green":"bg-sys-indigo"}`})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[r?e.jsx("p",{className:"text-[13px] font-medium leading-tight text-fg-primary truncate",children:r}):e.jsx("p",{className:"font-mono text-[13px] leading-tight text-fg-primary truncate",children:t.pubkey_prefix}),e.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5",children:[r&&e.jsx(Ds,{pubkey:t.pubkey}),r&&e.jsx("span",{className:"text-xs text-fg-muted/40",children:"·"}),e.jsxs("span",{className:"text-xs leading-tight text-fg-muted truncate",children:[!n&&e.jsxs("span",{className:"text-sys-indigo",children:[t.unsynced_count," unsynced · "]}),c]})]})]}),e.jsx("button",{onClick:()=>a(t.pubkey),className:"opacity-0 group-hover:opacity-100 transition-opacity duration-150 p-1.5 -mr-1 rounded-md text-fg-muted hover:text-sys-red hover:bg-sys-red/8",title:"Remove client",children:e.jsx(_s,{className:"w-3.5 h-3.5"})})]})});function Se({clients:s,onRemove:t,messages:l,terminalMode:a}){const r=o.useMemo(()=>{const n=new Map;if(!l)return n;for(let c=l.length-1;c>=0;c--){const m=l[c];m.author_name&&m.author_pubkey&&m.author_pubkey!=="server"&&m.author_pubkey!=="system"&&n.set(m.author_pubkey,m.author_name)}return n},[l]);return s.length===0?a?e.jsx("p",{className:"type-data-sm text-left px-4 py-4",style:{color:"var(--tui-accent)"},children:"< NO CLIENTS CONNECTED >"}):e.jsx("p",{className:"type-data-xs text-fg-muted text-center py-4",children:"No clients connected"}):a?e.jsx("div",{className:"type-data-sm pt-2",children:s.map(n=>{const c=n.name||r.get(n.pubkey),m=n.unsynced_count===0,d=n.pubkey_prefix;return e.jsxs("div",{className:"group flex items-center gap-0 -mx-0 px-4 py-0.5",onMouseEnter:i=>i.currentTarget.style.background="var(--tui-hover-bg)",onMouseLeave:i=>i.currentTarget.style.background="",children:[e.jsx("span",{style:{color:m?"var(--tui-accent)":"var(--tui-warn)"},children:"■"}),e.jsx("span",{className:"ml-2 shrink-0",style:{color:"var(--tui-accent)"},children:c||d}),c&&e.jsxs("span",{className:"ml-1.5 shrink-0",style:{color:"var(--tui-accent)"},children:["[",d,"]"]}),!m&&e.jsxs("span",{className:"ml-1.5",style:{color:"var(--tui-warn)"},children:[n.unsynced_count,"unsync"]}),e.jsx("button",{onClick:()=>t(n.pubkey),className:"opacity-0 group-hover:opacity-100 ml-auto pl-2 shrink-0 transition-colors",style:{color:"var(--tui-muted)"},onMouseEnter:i=>i.currentTarget.style.color="var(--tui-danger)",onMouseLeave:i=>i.currentTarget.style.color="var(--tui-muted)",title:"Remove",children:"×"})]},n.pubkey)})}):e.jsx("div",{className:"space-y-0.5 pt-1",children:s.map(n=>e.jsx(As,{client:n,resolvedName:r.get(n.pubkey),onRemove:t},n.pubkey))})}function $s({name:s,onSend:t}){const{terminalMode:l}=Q(),[a,r]=o.useState("idle"),n=o.useRef(),c=o.useCallback(async()=>{if(a==="sending")return;r("sending");const m=await t(s);r(m?"sent":"idle"),m&&(n.current=setTimeout(()=>r("idle"),2e3))},[s,t,a]);return o.useEffect(()=>()=>clearTimeout(n.current),[]),l?e.jsxs("button",{className:"btn-terminal",onClick:c,disabled:a==="sending",children:[a==="idle"&&"[ send_advert ]",a==="sending"&&"[ broadcasting... ]",a==="sent"&&"[ sent ✓ ]"]}):e.jsxs(F,{color:a==="sent"?"success":"primary",className:"w-full",onClick:c,disabled:a==="sending",children:[e.jsx(ee,{"data-slot":"icon"}),a==="idle"&&"Send Advert",a==="sending"&&"Broadcasting…",a==="sent"&&"Advert Sent"]})}function _e({identity:s,onSendAdvert:t}){var c,m,d,i,u,x,f,j,y,g,E,C,S,b,_,N,M,k,R,w,P,D,A,O,$,K,T,q,h,v;const{terminalMode:l}=Q(),[a,r]=o.useState(!1),n=o.useCallback(()=>{s!=null&&s.identity_key&&(navigator.clipboard.writeText(s.identity_key),r(!0),setTimeout(()=>r(!1),1500))},[s==null?void 0:s.identity_key]);return l?s?e.jsxs("div",{className:"space-y-1",children:[((c=s.settings)==null?void 0:c.node_name)&&e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{style:{color:"var(--tui-muted)"},children:"node"}),e.jsx("span",{style:{color:"var(--tui-accent)"},children:s.settings.node_name})]}),(s.address||((m=s.runtime)==null?void 0:m.address))&&e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{style:{color:"var(--tui-muted)"},children:"addr"}),e.jsx("span",{style:{color:"var(--tui-accent)"},children:s.address||((d=s.runtime)==null?void 0:d.address)})]}),s.identity_key&&e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{style:{color:"var(--tui-muted)"},children:"key"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"truncate max-w-[140px]",style:{color:"var(--tui-accent)"},title:s.identity_key,children:[s.identity_key.slice(0,16),"…"]}),e.jsx("button",{type:"button",onClick:n,className:"text-xs",style:{color:"var(--tui-muted)"},children:a?"[copied ✓]":"[copy]"})]})]}),(((i=s.settings)==null?void 0:i.latitude)!=null||((u=s.settings)==null?void 0:u.longitude)!=null)&&e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{style:{color:"var(--tui-muted)"},children:"loc"}),e.jsxs("span",{style:{color:"var(--tui-accent)"},title:`${((x=s.settings)==null?void 0:x.latitude)??"—"}, ${((f=s.settings)==null?void 0:f.longitude)??"—"}`,children:[((y=(j=s.settings)==null?void 0:j.latitude)==null?void 0:y.toFixed(4))??"—",", ",((E=(g=s.settings)==null?void 0:g.longitude)==null?void 0:E.toFixed(4))??"—"]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{style:{color:"var(--tui-muted)"},children:"pass"}),e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx("span",{style:{color:(C=s.settings)!=null&&C.admin_password?"var(--tui-accent)":"var(--tui-muted)"},children:(S=s.settings)!=null&&S.admin_password?"[✓ admin]":"[— admin]"}),e.jsx("span",{style:{color:(b=s.settings)!=null&&b.guest_password?"var(--tui-accent)":"var(--tui-muted)"},children:(_=s.settings)!=null&&_.guest_password?"[✓ guest]":"[— guest]"})]})]})]}):e.jsx("span",{style:{color:"var(--tui-muted)"},children:"no identity configured"}):e.jsxs("div",{className:"flex-shrink-0 border-t border-edge-subtle",children:[e.jsx(se,{listHeader:!0,icon:e.jsx(hs,{className:"icon-sm"}),title:"Room Info"}),s?e.jsxs("div",{className:"space-y-2 px-4 py-3",children:[((N=s.settings)==null?void 0:N.node_name)&&e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"type-data-xs text-fg-muted",children:"Node"}),e.jsx("span",{className:"type-data-sm text-fg-primary",children:s.settings.node_name})]}),(s.address||((M=s.runtime)==null?void 0:M.address))&&e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"type-data-xs text-fg-muted",children:"Address"}),e.jsx("span",{className:"type-data-sm font-mono text-fg-primary",children:s.address||((k=s.runtime)==null?void 0:k.address)})]}),s.identity_key&&e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"type-data-xs text-fg-muted flex items-center gap-1",title:"The unique hex public ID",children:[e.jsx(vs,{className:"w-3 h-3"}),"Key"]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs("span",{className:"type-data-sm font-mono text-fg-primary truncate max-w-[140px]",title:s.identity_key,children:[s.identity_key.slice(0,16),"…"]}),e.jsx("button",{type:"button",onClick:n,className:"inline-flex items-center gap-0.5",children:e.jsx(W,{color:a?"green":"zinc",children:a?e.jsxs(e.Fragment,{children:[e.jsx(G,{className:"w-3 h-3"}),"Copied"]}):e.jsxs(e.Fragment,{children:[e.jsx(We,{className:"w-3 h-3"}),"Copy"]})})})]})]}),(((R=s.settings)==null?void 0:R.latitude)!=null||((w=s.settings)==null?void 0:w.longitude)!=null)&&e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"type-data-xs text-fg-muted flex items-center gap-1",children:[e.jsx(Z,{className:"w-3 h-3"}),"Location"]}),e.jsxs("span",{className:"type-data-sm font-mono text-fg-primary",title:`${((P=s.settings)==null?void 0:P.latitude)??"—"}, ${((D=s.settings)==null?void 0:D.longitude)??"—"}`,children:[((O=(A=s.settings)==null?void 0:A.latitude)==null?void 0:O.toFixed(4))??"—",", ",((K=($=s.settings)==null?void 0:$.longitude)==null?void 0:K.toFixed(4))??"—"]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"type-data-xs text-fg-muted",children:"Passwords"}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs(W,{color:(T=s.settings)!=null&&T.admin_password?"green":"zinc",children:[((q=s.settings)==null?void 0:q.admin_password)&&e.jsx(G,{className:"w-3 h-3"}),"Admin"]}),e.jsxs(W,{color:(h=s.settings)!=null&&h.guest_password?"green":"zinc",children:[((v=s.settings)==null?void 0:v.guest_password)&&e.jsx(G,{className:"w-3 h-3"}),"Guest"]})]})]}),e.jsx("div",{className:"pt-3",children:e.jsx($s,{name:s.name,onSend:t})})]}):e.jsx("p",{className:"type-data-xs text-fg-muted text-center py-3",children:"No identity configured"})]})}function Ks({selectedIdentity:s,clients:t,messages:l,onSendAdvert:a}){const{terminalMode:r}=Q(),n=o.useCallback(async c=>{Re.setState(m=>({clients:m.clients.filter(d=>d.pubkey!==c)})),await Ge({public_key:c})},[]);return r?e.jsxs("div",{className:"flex flex-col h-full gap-1.5",children:[s&&e.jsx("div",{className:"hidden lg:block",children:e.jsx("div",{className:"card-terminal-header flex-shrink-0",children:e.jsx("div",{className:"header-well flex-1",children:e.jsx(I,{icon:e.jsx(ee,{}),onPress:()=>a(s.name),title:"Send room server advert",indicators:[{label:"ADVERTISE",trackPress:!0},{label:"ACTIVE",active:s.registered}]})})})}),e.jsxs("div",{className:"flex flex-col flex-1 min-h-0 gap-1.5",children:[e.jsx("div",{className:"card-terminal-header flex-shrink-0",children:e.jsx("span",{className:"seven-seg-panel",children:e.jsx(J,{text:`OnLInE ${String(t.length).padStart(3,"0")}`,size:24})})}),e.jsx(U,{noPadding:!0,className:"!h-auto flex flex-col flex-1 min-h-0 overflow-hidden card-terminal",children:e.jsx("div",{className:"card-terminal-well flex-1 min-h-0 overflow-y-auto",children:e.jsx(Se,{clients:t,onRemove:n,messages:l,terminalMode:!0})})}),e.jsxs("div",{className:"card-terminal-header flex-shrink-0",children:[e.jsx("span",{className:"seven-seg-panel",children:e.jsx(J,{text:`StAtUS ${s!=null&&s.registered?"On":"OFF"}`,size:24})}),s&&e.jsx("div",{className:"lg:hidden flex-1 flex min-w-0",children:e.jsx("div",{className:"header-well flex-1 !flex-shrink",children:e.jsx(I,{icon:e.jsx(ee,{}),onPress:()=>a(s.name),title:"Send room server advert",className:"flex-row-reverse",indicators:[{label:"ACTIVE",active:s.registered},{label:"ADVERTISE",trackPress:!0}]})})})]}),e.jsx(U,{noPadding:!0,className:"!h-auto flex-shrink-0 overflow-hidden card-terminal",children:e.jsx("div",{className:"card-terminal-well px-4 py-3 type-data-sm",children:e.jsx(_e,{identity:s,onSendAdvert:a})})})]})]}):e.jsxs(U,{compact:!0,className:"flex-1 min-h-0 flex flex-col overflow-hidden",children:[e.jsx(se,{listHeader:!0,icon:e.jsx(Te,{className:"icon-sm"}),title:"Clients",actions:t.length>0?e.jsx("span",{className:"type-data-xs text-fg-muted",children:t.length}):void 0}),e.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto",children:e.jsx(Se,{clients:t,onRemove:n,messages:l,terminalMode:!1})}),e.jsx(_e,{identity:s,onSendAdvert:a})]})}function et(){const s=Ye(),t=Ie(),l=Qe(),a=Xe(),r=Ze(),n=Je(),c=es(),m=ss(),d=ts(),i=as(),u=o.useMemo(()=>(d==null?void 0:d.neighbors)??{},[d==null?void 0:d.neighbors]),x=Rs(u,i),f=o.useMemo(()=>n.map(h=>{if(h.name)return h;const v=x(h.pubkey);return v.name?{...h,name:v.name}:h}),[n,x]),j=o.useMemo(()=>r.map(h=>{if(h.author_name||h.author_pubkey==="server"||h.author_pubkey==="system")return h;const v=x(h.author_pubkey);return v.name?{...h,author_name:v.name}:h}),[r,x]),{selectRoom:y,postMessage:g,deleteMessage:E,clearMessages:C,createRoom:S,updateRoom:b,deleteRoom:_,sendAdvert:N,markAsRead:M,startActivePolling:k}=Re.getState(),[R,w]=o.useState(!1),[P,D]=o.useState("create"),[A,O]=o.useState("hybrid");o.useEffect(()=>{M()},[t,M]),o.useEffect(()=>k(),[k]);const $=o.useCallback(async h=>t?g({room_name:t,message:h,author_pubkey:"server"}):!1,[t,g]),K=o.useCallback((h="hybrid")=>{O(h),D("create"),w(!0)},[]),T=o.useCallback(()=>{D("edit"),w(!0)},[]),q=e.jsxs("div",{className:"flex items-center gap-2 sm:gap-4 flex-shrink-0",children:[l&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"data-box flex items-center gap-1.5 cursor-default",title:`${l.total_messages} message${l.total_messages!==1?"s":""} in this room`,children:[e.jsx(Ee,{className:"w-3.5 h-3.5 text-fg-secondary"}),e.jsx("span",{children:l.total_messages})]}),e.jsxs("span",{className:"data-box flex items-center gap-1.5 cursor-default",title:`${l.total_clients} client${l.total_clients!==1?"s":""} connected`,children:[e.jsx(Te,{className:"w-3.5 h-3.5 text-fg-secondary"}),e.jsx("span",{children:l.total_clients})]})]}),e.jsx(Ls,{rooms:s,selected:t,onSelect:y,onAdd:()=>K("hybrid")}),s.length>0&&e.jsx(F,{plain:!0,onClick:T,title:"Manage room server",children:e.jsx(ns,{"data-slot":"icon"})})]});return s.length===0&&c.length===0&&!m?e.jsx(be,{children:e.jsxs(pe,{children:[e.jsx(he,{title:"Room Server",icon:e.jsx(Y,{})}),e.jsx(Ts,{onCreateRoom:h=>K(h)}),e.jsx(ye,{open:R,onClose:()=>w(!1),mode:"create",repeaterConfig:d==null?void 0:d.config,onCreate:async h=>{const v=await S(h);return v&&A==="dedicated"&&(await xe.getState().setMode("monitor"),xe.getState().clearModeMutation()),v},onUpdate:b,onDelete:_,onSendAdvert:N})]})}):e.jsx(be,{children:e.jsxs(pe,{children:[e.jsx(he,{title:"Room Server",icon:e.jsx(Y,{}),controls:q}),e.jsx(rs,{children:e.jsxs(ls,{template:"hero-tall",className:"!h-[calc(100vh-11rem)] !min-h-[400px]",children:[e.jsx(ge,{span:12,lg:8,className:"h-full",children:e.jsx(Ps,{selectedName:t,selectedIdentity:a,messages:j,onSend:$,onDelete:E,onClear:C})}),e.jsx(ge,{span:12,lg:4,className:"h-full",children:e.jsx(Ks,{selectedIdentity:a,clients:f,messages:j,onSendAdvert:N})})]})}),e.jsx(ye,{open:R,onClose:()=>w(!1),mode:P,identity:a,repeaterConfig:d==null?void 0:d.config,onCreate:S,onUpdate:b,onDelete:_,onSendAdvert:N})]})})}export{et as default}; + */const Ss=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"17",x2:"22",y1:"8",y2:"13",key:"3nzzx3"}],["line",{x1:"22",x2:"17",y1:"8",y2:"13",key:"1swrse"}]],_s=V("user-x",Ss);function H({disabled:s,className:t,children:l}){return e.jsx(Ke,{disabled:s,className:L("flex flex-col gap-2",t),children:l})}function q({required:s,className:t,children:l,...a}){return e.jsxs(Fe,{className:L("text-sm font-medium text-fg-primary select-none","data-[disabled]:opacity-50",a.title&&"cursor-help",t),...a,children:[l,s&&e.jsx("span",{className:"text-sys-red ml-0.5","aria-hidden":"true",children:"*"})]})}function Ms({className:s,children:t,...l}){return e.jsx(Oe,{className:L("text-sm text-fg-muted","data-[disabled]:opacity-50",s),...l,children:t})}function Rs(s,t){return o.useMemo(()=>{const a=new Map;for(const[n,c]of Object.entries(s)){const m=c.name||c.node_name||null,{type:d}=os(c);a.set(n.toLowerCase(),{name:m,type:d})}const r=new Map;for(let n=t.length-1;n>=0;n--){const c=t[n];if(!c._advertSender)continue;const m=c._advertSender.toLowerCase();if(r.has(m))continue;const d=c._advertName??null,i=c._advertNodeType!=null?is(c._advertNodeType):"companion";r.set(m,{name:d,type:i})}return function(c){const m=c.toLowerCase(),d=a.get(m);if(d!=null&&d.name)return d;const i=r.get(m);return i!=null&&i.name?i:d||i||{name:null,type:"companion"}}},[s,t])}function ve({icon:s,title:t,description:l,onClick:a,accent:r}){return e.jsxs("button",{onClick:a,className:L("flex flex-col items-center gap-3 p-6 rounded-2xl text-center","ring-1 ring-edge-subtle hover:ring-2 transition-all duration-150","w-full max-w-[260px]",r==="primary"?"hover:ring-sys-blue hover:bg-sys-blue/5":"hover:ring-sys-indigo hover:bg-sys-indigo/5"),children:[e.jsx("div",{className:L("p-3 rounded-xl",r==="primary"?"bg-sys-blue/10 text-sys-blue":"bg-sys-indigo/10 text-sys-indigo"),children:s}),e.jsx("p",{className:"type-body-sm font-medium text-fg-primary",children:t}),e.jsx("p",{className:"type-data-xs text-fg-muted leading-relaxed",children:l})]})}function Ts({onCreateRoom:s}){return e.jsxs("div",{className:"flex flex-col items-center justify-center py-16 px-4",children:[e.jsx(Y,{className:"w-12 h-12 text-fg-muted opacity-30 mb-4"}),e.jsx("p",{className:"type-subheading text-fg-secondary mb-1",children:"Add a Room Server"}),e.jsx("p",{className:"type-body-sm text-fg-muted mb-8",children:"Choose how this device should operate."}),e.jsxs("div",{className:"flex flex-col sm:flex-row items-center gap-4",children:[e.jsx(ve,{icon:e.jsx(ws,{className:"w-6 h-6"}),title:"Repeater + Room Server",description:"Keep forwarding packets and add group messaging.",onClick:()=>s("hybrid"),accent:"primary"}),e.jsx(ve,{icon:e.jsx(ze,{className:"w-6 h-6"}),title:"Dedicated Room Server",description:"Stop repeating. Focus entirely on room server duties.",onClick:()=>s("dedicated"),accent:"secondary"})]})]})}function Ls({rooms:s,selected:t,onSelect:l,onAdd:a}){const r=a?e.jsx("button",{onClick:a,className:L("flex items-center justify-center px-2 py-1 rounded-md","text-fg-muted hover:text-fg-primary hover:bg-surface/60","transition-all duration-150"),title:"Add room server",children:e.jsx(us,{className:"w-4 h-4"})}):null;return s.length<=1?r:s.length<=3?e.jsxs("div",{className:"flex items-center gap-0.5 p-0.5 rounded-lg bg-subtle-fill",children:[s.map(n=>e.jsx("button",{onClick:()=>l(n.room_name),className:L("px-3 py-1 rounded-md text-sm font-medium transition-all duration-150",n.room_name===t?"bg-surface text-fg-primary shadow-sm":"text-fg-muted hover:text-fg-secondary"),children:n.room_name},n.room_name)),r]}):e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(cs,{value:t??"",onChange:l,children:s.map(n=>e.jsx(ds,{value:n.room_name,children:e.jsx(ms,{children:n.room_name})},n.room_name))}),r]})}function Ps(s){if(!s)return"";const t=s.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"");return t?`${t}-room`:""}function ye({open:s,onClose:t,mode:l,identity:a,repeaterConfig:r,onCreate:n,onUpdate:c,onDelete:m,onSendAdvert:d}){var te,ae,ne,re,le,oe,ie,ce,de;const i=l==="edit"&&a,u=`${s}-${(a==null?void 0:a.name)??""}-${l}`,[x,f]=o.useState(""),[j,y]=o.useState(""),[g,P]=o.useState(!1),[C,S]=o.useState(""),[b,_]=o.useState(""),[N,M]=o.useState(""),[k,R]=o.useState(""),[w,E]=o.useState(!1),[D,A]=o.useState(!1),[O,$]=o.useState(!1),[K,T]=o.useState(null),[z,h]=o.useState(u);if(u!==z)if(h(u),T(null),E(!1),A(!1),$(!1),i)f(((te=a.settings)==null?void 0:te.node_name)??a.name),y(a.identity_key??""),P(!1),S(((ae=a.settings)==null?void 0:ae.admin_password)??""),_(((ne=a.settings)==null?void 0:ne.guest_password)??""),M(((le=(re=a.settings)==null?void 0:re.latitude)==null?void 0:le.toString())??""),R(((ie=(oe=a.settings)==null?void 0:oe.longitude)==null?void 0:ie.toString())??"");else{const p=r;f(""),y(""),P(!1),S(""),_(""),M(((ce=p==null?void 0:p.repeater)==null?void 0:ce.latitude)!=null?p.repeater.latitude.toString():""),R(((de=p==null?void 0:p.repeater)==null?void 0:de.longitude)!=null?p.repeater.longitude.toString():"")}const v=o.useCallback(()=>{const p={};return x&&(p.node_name=x),C&&(p.admin_password=C),b&&(p.guest_password=b),N!==""&&(p.latitude=parseFloat(N)),k!==""&&(p.longitude=parseFloat(k)),p},[x,C,b,N,k]),De=o.useCallback(async()=>{if(!x.trim()){T("Room name is required");return}E(!0),T(null);const p=i?a.name:Ps(x);let Z;if(i)Z=await c({name:a.name,settings:v()});else{const me={name:p,type:"room_server",settings:v()};j.trim()&&(me.identity_key=j.trim()),Z=await n(me)}E(!1),Z?t():T("Failed to save. Check that the name is unique and passwords differ.")},[x,i,a,v,n,c,t]),Ae=o.useCallback(async()=>{if(!i)return;A(!0);const p=await m(a.name);A(!1),p&&t()},[i,a,m,t]),$e=o.useCallback(async()=>{i&&($(!0),await d(a.name),$(!1))},[i,a,d]);return e.jsxs(Be,{open:s,onClose:t,size:"md",children:[e.jsx(He,{icon:i?void 0:e.jsx(bs,{className:"w-5 h-5"}),title:i?"Edit Room Server":"Add Room Server",onClose:t}),e.jsx(qe,{children:e.jsxs("div",{className:"space-y-5",children:[i&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(G,{color:a.registered?"green":"red",children:a.registered?"Active":"Inactive"}),a.identity_key&&e.jsxs("span",{className:"type-data-xs text-fg-muted truncate",title:a.identity_key,children:["Key: ",a.identity_key.slice(0,16),"…"]})]}),e.jsxs(H,{children:[e.jsx(q,{title:"What people see on the mesh",children:"Room Name"}),e.jsx(B,{value:x,onChange:p=>f(p.target.value),placeholder:"Room Name"})]}),!i&&e.jsxs(H,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(q,{title:"The unique hex public ID",children:["Identity Key ",e.jsx("span",{className:"text-fg-muted font-normal",children:"(Optional)"})]}),e.jsx("button",{type:"button",onClick:()=>P(p=>!p),className:"type-data-xs text-fg-muted underline hover:text-fg-secondary",children:g?"Hide":"Show"})]}),g&&e.jsxs(e.Fragment,{children:[e.jsx(B,{value:j,onChange:p=>y(p.target.value),placeholder:"Leave empty to auto-generate"}),e.jsx(Ms,{children:"Leave empty to automatically generate a secure key"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs(H,{children:[e.jsxs(q,{children:[e.jsx(Q,{className:"inline w-3.5 h-3.5 -mt-0.5 mr-1 text-fg-muted"}),"Latitude"]}),e.jsx(B,{type:"number",step:"any",value:N,onChange:p=>M(p.target.value),placeholder:"0"})]}),e.jsxs(H,{children:[e.jsxs(q,{children:[e.jsx(Q,{className:"inline w-3.5 h-3.5 -mt-0.5 mr-1 text-fg-muted"}),"Longitude"]}),e.jsx(B,{type:"number",step:"any",value:k,onChange:p=>R(p.target.value),placeholder:"0"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs(H,{children:[e.jsxs(q,{title:"Full access to room server",children:["Admin Password ",e.jsx("span",{className:"text-fg-muted font-normal",children:"(Optional)"})]}),e.jsx(B,{type:"password",value:C,onChange:p=>S(p.target.value),placeholder:"None Set"})]}),e.jsxs(H,{children:[e.jsxs(q,{title:"Can post and read, but not administer the room",children:["Guest Password ",e.jsx("span",{className:"text-fg-muted font-normal",children:"(Optional)"})]}),e.jsx(B,{type:"password",value:b,onChange:p=>_(p.target.value),placeholder:"None Set"})]})]}),K&&e.jsx("p",{className:"type-data-xs text-sys-red",children:K})]})}),e.jsxs(Ue,{children:[i&&e.jsxs("div",{className:"flex items-center gap-2 mr-auto",children:[e.jsxs(F,{color:"danger",plain:!0,onClick:Ae,disabled:D,children:[e.jsx(Le,{"data-slot":"icon"}),D?"Deleting…":"Delete"]}),e.jsxs(F,{color:"primary",plain:!0,onClick:$e,disabled:O,children:[e.jsx(Me,{"data-slot":"icon"}),O?"Sending…":"Send Advert"]})]}),e.jsx(F,{plain:!0,onClick:t,children:"Cancel"}),e.jsx(F,{color:"primary",onClick:De,disabled:w,children:w?"Saving…":i?"Save Changes":"Create"})]})]})}const Ee=o.createContext(null),Ne="room-tui";function be({children:s}){const[t,l]=o.useState(()=>localStorage.getItem(Ne)!=="0"),a=o.useCallback(()=>{l(r=>{const n=!r;return localStorage.setItem(Ne,n?"1":"0"),n})},[]);return e.jsx(Ee.Provider,{value:{terminalMode:t,toggleTerminalMode:a},children:s})}function X(){const s=o.useContext(Ee);if(!s)throw new Error("useTerminalMode must be used within RoomTerminalProvider");return s}const ke=s=>s.author_pubkey==="server"||s.author_pubkey==="system";function we({messages:s,onDelete:t,terminalMode:l,serverName:a}){const r=o.useRef(null),[n,c]=o.useState(!1),m=o.useMemo(()=>[...s].sort((u,x)=>u.post_timestamp-x.post_timestamp),[s]);o.useEffect(()=>{!n&&r.current&&(r.current.scrollTop=0)},[m.length,n]);const d=o.useCallback(()=>{r.current&&c(r.current.scrollTop<-100)},[]),i=o.useCallback(()=>{r.current&&r.current.scrollTo({top:0,behavior:"smooth"}),c(!1)},[]);return m.length===0?e.jsx("div",{className:`flex-1 flex flex-col items-center justify-center py-12 min-h-0${l?" font-mono":""}`,children:l?e.jsx("p",{className:"text-sm font-mono",style:{color:"var(--tui-accent)",opacity:.4},children:"> no messages in buffer_"}):e.jsxs(e.Fragment,{children:[e.jsx(Y,{className:"w-10 h-10 text-fg-muted opacity-20 mb-2"}),e.jsx("p",{className:"type-data-sm text-fg-muted",children:"No messages yet"})]})}):l?e.jsxs("div",{className:"relative flex-1 min-h-0",children:[e.jsx("div",{ref:r,onScroll:d,className:"h-full overflow-y-auto scroll-smooth p-4 font-mono text-sm leading-relaxed flex flex-col-reverse",children:e.jsx("div",{children:m.map(u=>{const x=ke(u),f=new Date(u.post_timestamp*1e3).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}),j=x?"SYS":u.author_name||u.author_prefix,y=!x&&a&&j===a;return e.jsxs("div",{className:"group flex items-start gap-0 -mx-4 px-4 py-px",style:{"--tw-hover-bg":"var(--tui-hover-bg)"},onMouseEnter:g=>g.currentTarget.style.background="var(--tui-hover-bg)",onMouseLeave:g=>g.currentTarget.style.background="",children:[e.jsxs("span",{className:"select-none shrink-0",style:{color:"var(--tui-muted)"},children:["[",f,"]"]}),e.jsxs("span",{className:"mx-1.5 shrink-0",style:{color:y?"var(--tui-accent-local)":"var(--tui-accent)"},children:["<",j,">"]}),e.jsx("span",{style:{color:x?"var(--tui-system)":y?"var(--tui-body)":"var(--tui-accent)"},className:x?"italic":"",children:u.message_text}),e.jsx("button",{onClick:()=>t(u.id),className:"opacity-0 group-hover:opacity-100 ml-auto pl-2 shrink-0 transition-colors",style:{color:"var(--tui-muted)"},onMouseEnter:g=>g.currentTarget.style.color="var(--tui-danger)",onMouseLeave:g=>g.currentTarget.style.color="var(--tui-muted)",title:"Delete",children:"×"})]},u.id)})})}),n&&e.jsxs("button",{onClick:i,className:"absolute bottom-3 left-1/2 -translate-x-1/2 flex items-center gap-1.5 px-3 py-1 font-mono text-xs transition-colors duration-150",style:{background:"var(--tui-hover-bg)",border:"1px solid var(--tui-muted)",color:"var(--tui-accent)"},children:[e.jsx(ue,{className:"w-3 h-3"}),"↓ scroll"]})]}):e.jsxs("div",{className:"relative flex-1 min-h-0",children:[e.jsx("div",{ref:r,onScroll:d,className:"h-full overflow-y-auto scroll-smooth flex flex-col-reverse",children:e.jsx("div",{className:"space-y-3 p-4",children:m.map(u=>ke(u)?e.jsx(xs,{text:u.message_text},u.id):e.jsx(ps,{senderName:u.author_name||u.author_prefix,text:u.message_text,timestamp:u.post_timestamp,bubbleAccessory:e.jsx("button",{onClick:()=>t(u.id),className:"opacity-0 group-hover:opacity-100 transition-opacity duration-150 p-1 text-fg-muted hover:text-sys-red flex-shrink-0",title:"Delete message",children:e.jsx(Le,{className:"w-3.5 h-3.5"})})},u.id))})}),n&&e.jsxs("button",{onClick:i,className:"absolute bottom-3 left-1/2 -translate-x-1/2 flex items-center gap-1.5 px-3 py-1.5 rounded-full bg-surface/90 backdrop-blur-sm ring-1 ring-edge-subtle shadow-md text-fg-secondary hover:text-fg-primary transition-colors duration-150",children:[e.jsx(ue,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"type-data-xs",children:"New messages"})]})]})}function Ce({roomName:s,onSend:t,disabled:l,terminalMode:a}){const[r,n]=o.useState(""),[c,m]=o.useState(!1),d=o.useRef(null),i=o.useCallback(async()=>{var j;const x=r.trim();if(!x||c)return;m(!0);const f=await t(x);m(!1),f&&(n(""),(j=d.current)==null||j.focus())},[r,c,t]),u=o.useCallback(x=>{x.key==="Enter"&&!x.shiftKey&&(x.preventDefault(),i())},[i]);return a?e.jsxs("div",{className:"flex items-center gap-0 px-4 py-2 type-data-sm",children:[e.jsx("input",{ref:d,type:"text",value:r,onChange:x=>n(x.target.value),onKeyDown:u,placeholder:"type message...",disabled:l||c,className:"flex-1 bg-transparent outline-none ring-0 shadow-none border-none focus:outline-none focus:ring-0 font-mono tui-input",style:{color:"var(--tui-body)"}}),e.jsx("button",{onClick:i,disabled:!r.trim()||c||l,className:"transition-colors duration-100 px-1 font-mono text-xs disabled:opacity-30",style:{color:"var(--tui-accent)"},title:"Send",children:"[↵]"})]}):e.jsxs("div",{className:"flex items-center gap-2 p-3 border-t border-edge-subtle",children:[e.jsx("input",{ref:d,type:"text",value:r,onChange:x=>n(x.target.value),onKeyDown:u,placeholder:`Message ${s}…`,disabled:l||c,className:"flex-1 surface-input radius-inner px-3 py-2 type-body-sm text-fg-primary placeholder:text-fg-muted outline-none ring-focus"}),e.jsx("button",{onClick:i,disabled:!r.trim()||c||l,className:"p-2 rounded-lg text-sys-blue hover:bg-sys-blue/10 disabled:opacity-30 disabled:hover:bg-transparent transition-colors duration-150",title:"Send message",children:e.jsx(Me,{className:"w-4.5 h-4.5"})})]})}function Es({selectedName:s,selectedIdentity:t,messages:l,onSend:a,onDelete:r,onClear:n}){var f;const{terminalMode:c,toggleTerminalMode:m}=X(),[d,i]=o.useState(!1),u=((f=t==null?void 0:t.settings)==null?void 0:f.node_name)??s??void 0,x=o.useCallback(()=>{i(!1),n()},[n]);return c?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-col h-full gap-1.5",children:[e.jsxs("div",{className:"card-terminal-header flex-shrink-0",children:[e.jsx("span",{className:"seven-seg-panel",children:e.jsx(J,{text:"chat",minChars:7,size:24})}),e.jsx("div",{className:"card-terminal-ridge flex-1"}),e.jsxs("div",{className:"header-well",children:[e.jsx(I,{icon:e.jsx(je,{className:"!w-5.5 !h-5.5 translate-y-px"}),onClick:m,title:"Exit terminal mode"}),l.length>0&&e.jsx(I,{icon:e.jsx("span",{className:"text-[13px] font-bold font-mono leading-none translate-y-px",children:"DEL"}),onClick:()=>i(!0),title:"Clear all messages",variant:"red",iconActiveColor:Ve.red})]})]}),e.jsx(U,{noPadding:!0,className:"flex flex-col flex-1 min-h-0 overflow-hidden card-terminal",children:e.jsxs("div",{className:"card-terminal-well flex-1 min-h-0 flex flex-col overflow-hidden",children:[e.jsx(we,{messages:l,onDelete:r,terminalMode:!0,serverName:u}),e.jsx("div",{className:"card-terminal-divider"}),s&&e.jsx(Ce,{roomName:s,onSend:a,disabled:!(t!=null&&t.registered),terminalMode:!0})]})})]}),e.jsx(fe,{isOpen:d,title:"Clear All Messages",message:`This will permanently delete all ${l.length} message${l.length===1?"":"s"} from this room. This cannot be undone.`,confirmLabel:"Clear Messages",variant:"danger",onConfirm:x,onCancel:()=>i(!1)})]}):e.jsxs(e.Fragment,{children:[e.jsxs(U,{noPadding:!0,className:"flex flex-col h-full overflow-hidden",children:[e.jsx(se,{listHeader:!0,icon:e.jsx(Pe,{className:"icon-sm"}),title:"Messages",actions:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(F,{plain:!0,onClick:m,title:"Terminal mode",children:e.jsx(je,{"data-slot":"icon",className:"!w-5 !h-5 translate-y-px"})}),l.length>0&&e.jsx(F,{plain:!0,onClick:()=>i(!0),title:"Clear all messages",children:e.jsx("span",{"data-slot":"icon",className:"text-[12px] font-bold font-mono leading-none translate-y-px text-sys-red",children:"DEL"})})]})}),e.jsx(we,{messages:l,onDelete:r,terminalMode:!1,serverName:u}),s&&e.jsx(Ce,{roomName:s,onSend:a,disabled:!(t!=null&&t.registered),terminalMode:!1})]}),e.jsx(fe,{isOpen:d,title:"Clear All Messages",message:`This will permanently delete all ${l.length} message${l.length===1?"":"s"} from this room. This cannot be undone.`,confirmLabel:"Clear Messages",variant:"danger",onConfirm:x,onCancel:()=>i(!1)})]})}function Ds({pubkey:s,className:t}){const[l,a]=o.useState(!1),r=o.useCallback(()=>{navigator.clipboard.writeText(s),a(!0),setTimeout(()=>a(!1),1500)},[s]);return e.jsxs("button",{onClick:r,title:l?"Copied!":"Copy public key",className:`inline-flex items-center gap-1 type-data-xs leading-tight text-fg-muted hover:text-fg-secondary transition-colors duration-150 cursor-copy ${t??""}`,children:[e.jsx("span",{className:"truncate min-w-0",children:s.slice(0,8)}),l&&e.jsx(W,{className:"w-2.5 h-2.5 text-sys-green flex-shrink-0"})]})}const As=o.memo(function({client:t,resolvedName:l,onRemove:a}){const r=t.name||l,n=t.unsynced_count===0,c=t.last_activity?new Date(t.last_activity*1e3).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}):"Never",{emoji:m,cleanName:d}=r?gs(r):{emoji:null,cleanName:t.pubkey_prefix},i=r?fs(d):void 0,u=r?js(r):t.pubkey_prefix.slice(0,2).toUpperCase();return e.jsxs("div",{className:"group flex items-center gap-3 px-3 py-2.5 radius-inner row-hover transition-base",children:[e.jsxs("div",{className:"relative flex-shrink-0",children:[e.jsx("div",{className:L("w-8 h-8 rounded-full flex items-center justify-center",!i&&"bg-sys-blue/12"),style:i?{backgroundColor:i}:void 0,children:m?e.jsx("span",{className:"text-base leading-none",children:m}):e.jsx("span",{className:L("leading-none",i?"text-white text-[11px] font-bold tracking-tight":"text-sys-blue font-mono text-[11px]"),children:u})}),e.jsx("span",{className:`absolute -bottom-0.5 -right-0.5 w-2.5 h-2.5 rounded-sm ring-2 ring-surface ${n?"bg-sys-green":"bg-sys-indigo"}`})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[r?e.jsx("p",{className:"text-[13px] font-medium leading-tight text-fg-primary truncate",children:r}):e.jsx("p",{className:"font-mono text-[13px] leading-tight text-fg-primary truncate",children:t.pubkey_prefix}),e.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5",children:[r&&e.jsx(Ds,{pubkey:t.pubkey}),r&&e.jsx("span",{className:"text-xs text-fg-muted/40",children:"·"}),e.jsxs("span",{className:"text-xs leading-tight text-fg-muted truncate",children:[!n&&e.jsxs("span",{className:"text-sys-indigo",children:[t.unsynced_count," unsynced · "]}),c]})]})]}),e.jsx("button",{onClick:()=>a(t.pubkey),className:"opacity-0 group-hover:opacity-100 transition-opacity duration-150 p-1.5 -mr-1 rounded-md text-fg-muted hover:text-sys-red hover:bg-sys-red/8",title:"Remove client",children:e.jsx(_s,{className:"w-3.5 h-3.5"})})]})});function Se({clients:s,onRemove:t,messages:l,terminalMode:a}){const r=o.useMemo(()=>{const n=new Map;if(!l)return n;for(let c=l.length-1;c>=0;c--){const m=l[c];m.author_name&&m.author_pubkey&&m.author_pubkey!=="server"&&m.author_pubkey!=="system"&&n.set(m.author_pubkey,m.author_name)}return n},[l]);return s.length===0?a?e.jsx("p",{className:"type-data-sm text-left px-4 py-4",style:{color:"var(--tui-accent)"},children:"< NO CLIENTS CONNECTED >"}):e.jsx("p",{className:"type-data-xs text-fg-muted text-center py-4",children:"No clients connected"}):a?e.jsx("div",{className:"type-data-sm pt-2",children:s.map(n=>{const c=n.name||r.get(n.pubkey),m=n.unsynced_count===0,d=n.pubkey_prefix;return e.jsxs("div",{className:"group flex items-center gap-0 -mx-0 px-4 py-0.5",onMouseEnter:i=>i.currentTarget.style.background="var(--tui-hover-bg)",onMouseLeave:i=>i.currentTarget.style.background="",children:[e.jsx("span",{style:{color:m?"var(--tui-accent)":"var(--tui-warn)"},children:"■"}),e.jsx("span",{className:"ml-2 shrink-0",style:{color:"var(--tui-accent)"},children:c||d}),c&&e.jsxs("span",{className:"ml-1.5 shrink-0",style:{color:"var(--tui-accent)"},children:["[",d,"]"]}),!m&&e.jsxs("span",{className:"ml-1.5",style:{color:"var(--tui-warn)"},children:[n.unsynced_count,"unsync"]}),e.jsx("button",{onClick:()=>t(n.pubkey),className:"opacity-0 group-hover:opacity-100 ml-auto pl-2 shrink-0 transition-colors",style:{color:"var(--tui-muted)"},onMouseEnter:i=>i.currentTarget.style.color="var(--tui-danger)",onMouseLeave:i=>i.currentTarget.style.color="var(--tui-muted)",title:"Remove",children:"×"})]},n.pubkey)})}):e.jsx("div",{className:"space-y-0.5 pt-1",children:s.map(n=>e.jsx(As,{client:n,resolvedName:r.get(n.pubkey),onRemove:t},n.pubkey))})}function $s({name:s,onSend:t}){const{terminalMode:l}=X(),[a,r]=o.useState("idle"),n=o.useRef(),c=o.useCallback(async()=>{if(a==="sending")return;r("sending");const m=await t(s);r(m?"sent":"idle"),m&&(n.current=setTimeout(()=>r("idle"),2e3))},[s,t,a]);return o.useEffect(()=>()=>clearTimeout(n.current),[]),l?e.jsxs("button",{className:"btn-terminal",onClick:c,disabled:a==="sending",children:[a==="idle"&&"[ send_advert ]",a==="sending"&&"[ broadcasting... ]",a==="sent"&&"[ sent ✓ ]"]}):e.jsxs(F,{color:a==="sent"?"success":"primary",className:"w-full",onClick:c,disabled:a==="sending",children:[e.jsx(ee,{"data-slot":"icon"}),a==="idle"&&"Send Advert",a==="sending"&&"Broadcasting…",a==="sent"&&"Advert Sent"]})}function _e({identity:s,onSendAdvert:t}){var c,m,d,i,u,x,f,j,y,g,P,C,S,b,_,N,M,k,R,w,E,D,A,O,$,K,T,z,h,v;const{terminalMode:l}=X(),[a,r]=o.useState(!1),n=o.useCallback(()=>{s!=null&&s.identity_key&&(navigator.clipboard.writeText(s.identity_key),r(!0),setTimeout(()=>r(!1),1500))},[s==null?void 0:s.identity_key]);return l?s?e.jsxs("div",{className:"space-y-1",children:[((c=s.settings)==null?void 0:c.node_name)&&e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{style:{color:"var(--tui-muted)"},children:"node"}),e.jsx("span",{style:{color:"var(--tui-accent)"},children:s.settings.node_name})]}),(s.address||((m=s.runtime)==null?void 0:m.address))&&e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{style:{color:"var(--tui-muted)"},children:"addr"}),e.jsx("span",{style:{color:"var(--tui-accent)"},children:s.address||((d=s.runtime)==null?void 0:d.address)})]}),s.identity_key&&e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{style:{color:"var(--tui-muted)"},children:"key"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"truncate max-w-[140px]",style:{color:"var(--tui-accent)"},title:s.identity_key,children:[s.identity_key.slice(0,16),"…"]}),e.jsx("button",{type:"button",onClick:n,className:"text-xs",style:{color:"var(--tui-muted)"},children:a?"[copied ✓]":"[copy]"})]})]}),(((i=s.settings)==null?void 0:i.latitude)!=null||((u=s.settings)==null?void 0:u.longitude)!=null)&&e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{style:{color:"var(--tui-muted)"},children:"loc"}),e.jsxs("span",{style:{color:"var(--tui-accent)"},title:`${((x=s.settings)==null?void 0:x.latitude)??"—"}, ${((f=s.settings)==null?void 0:f.longitude)??"—"}`,children:[((y=(j=s.settings)==null?void 0:j.latitude)==null?void 0:y.toFixed(4))??"—",", ",((P=(g=s.settings)==null?void 0:g.longitude)==null?void 0:P.toFixed(4))??"—"]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{style:{color:"var(--tui-muted)"},children:"pass"}),e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx("span",{style:{color:(C=s.settings)!=null&&C.admin_password?"var(--tui-accent)":"var(--tui-muted)"},children:(S=s.settings)!=null&&S.admin_password?"[✓ admin]":"[— admin]"}),e.jsx("span",{style:{color:(b=s.settings)!=null&&b.guest_password?"var(--tui-accent)":"var(--tui-muted)"},children:(_=s.settings)!=null&&_.guest_password?"[✓ guest]":"[— guest]"})]})]})]}):e.jsx("span",{style:{color:"var(--tui-muted)"},children:"no identity configured"}):e.jsxs("div",{className:"flex-shrink-0 border-t border-edge-subtle",children:[e.jsx(se,{listHeader:!0,icon:e.jsx(hs,{className:"icon-sm"}),title:"Room Info"}),s?e.jsxs("div",{className:"space-y-2 px-4 py-3",children:[((N=s.settings)==null?void 0:N.node_name)&&e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"type-data-xs text-fg-muted",children:"Node"}),e.jsx("span",{className:"type-data-sm text-fg-primary",children:s.settings.node_name})]}),(s.address||((M=s.runtime)==null?void 0:M.address))&&e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"type-data-xs text-fg-muted",children:"Address"}),e.jsx("span",{className:"type-data-sm font-mono text-fg-primary",children:s.address||((k=s.runtime)==null?void 0:k.address)})]}),s.identity_key&&e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"type-data-xs text-fg-muted flex items-center gap-1",title:"The unique hex public ID",children:[e.jsx(vs,{className:"w-3 h-3"}),"Key"]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs("span",{className:"type-data-sm font-mono text-fg-primary truncate max-w-[140px]",title:s.identity_key,children:[s.identity_key.slice(0,16),"…"]}),e.jsx("button",{type:"button",onClick:n,className:"inline-flex items-center gap-0.5",children:e.jsx(G,{color:a?"green":"zinc",children:a?e.jsxs(e.Fragment,{children:[e.jsx(W,{className:"w-3 h-3"}),"Copied"]}):e.jsxs(e.Fragment,{children:[e.jsx(Ge,{className:"w-3 h-3"}),"Copy"]})})})]})]}),(((R=s.settings)==null?void 0:R.latitude)!=null||((w=s.settings)==null?void 0:w.longitude)!=null)&&e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"type-data-xs text-fg-muted flex items-center gap-1",children:[e.jsx(Q,{className:"w-3 h-3"}),"Location"]}),e.jsxs("span",{className:"type-data-sm font-mono text-fg-primary",title:`${((E=s.settings)==null?void 0:E.latitude)??"—"}, ${((D=s.settings)==null?void 0:D.longitude)??"—"}`,children:[((O=(A=s.settings)==null?void 0:A.latitude)==null?void 0:O.toFixed(4))??"—",", ",((K=($=s.settings)==null?void 0:$.longitude)==null?void 0:K.toFixed(4))??"—"]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"type-data-xs text-fg-muted",children:"Passwords"}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs(G,{color:(T=s.settings)!=null&&T.admin_password?"green":"zinc",children:[((z=s.settings)==null?void 0:z.admin_password)&&e.jsx(W,{className:"w-3 h-3"}),"Admin"]}),e.jsxs(G,{color:(h=s.settings)!=null&&h.guest_password?"green":"zinc",children:[((v=s.settings)==null?void 0:v.guest_password)&&e.jsx(W,{className:"w-3 h-3"}),"Guest"]})]})]}),e.jsx("div",{className:"pt-3",children:e.jsx($s,{name:s.name,onSend:t})})]}):e.jsx("p",{className:"type-data-xs text-fg-muted text-center py-3",children:"No identity configured"})]})}function Ks({selectedIdentity:s,clients:t,messages:l,onSendAdvert:a}){const{terminalMode:r}=X(),n=o.useCallback(async c=>{Re.setState(m=>({clients:m.clients.filter(d=>d.pubkey!==c)})),await We({public_key:c})},[]);return r?e.jsxs("div",{className:"flex flex-col h-full gap-1.5",children:[s&&e.jsx("div",{className:"hidden lg:block",children:e.jsx("div",{className:"card-terminal-header flex-shrink-0",children:e.jsx("div",{className:"header-well flex-1",children:e.jsx(I,{icon:e.jsx(ee,{}),onPress:()=>a(s.name),title:"Send room server advert",indicators:[{label:"ADVERTISE",trackPress:!0},{label:"ACTIVE",active:s.registered}]})})})}),e.jsxs("div",{className:"flex flex-col flex-1 min-h-0 gap-1.5",children:[e.jsx("div",{className:"card-terminal-header flex-shrink-0",children:e.jsx("span",{className:"seven-seg-panel",children:e.jsx(J,{text:`OnLInE ${String(t.length).padStart(3,"0")}`,size:24})})}),e.jsx(U,{noPadding:!0,className:"!h-auto flex flex-col flex-1 min-h-0 overflow-hidden card-terminal",children:e.jsx("div",{className:"card-terminal-well flex-1 min-h-0 overflow-y-auto",children:e.jsx(Se,{clients:t,onRemove:n,messages:l,terminalMode:!0})})}),e.jsxs("div",{className:"card-terminal-header flex-shrink-0",children:[e.jsx("span",{className:"seven-seg-panel",children:e.jsx(J,{text:`StAtUS ${s!=null&&s.registered?"On":"OFF"}`,size:24})}),s&&e.jsx("div",{className:"lg:hidden flex-1 flex min-w-0",children:e.jsx("div",{className:"header-well flex-1 !flex-shrink",children:e.jsx(I,{icon:e.jsx(ee,{}),onPress:()=>a(s.name),title:"Send room server advert",className:"flex-row-reverse",indicators:[{label:"ACTIVE",active:s.registered},{label:"ADVERTISE",trackPress:!0}]})})})]}),e.jsx(U,{noPadding:!0,className:"!h-auto flex-shrink-0 overflow-hidden card-terminal",children:e.jsx("div",{className:"card-terminal-well px-4 py-3 type-data-sm",children:e.jsx(_e,{identity:s,onSendAdvert:a})})})]})]}):e.jsxs(U,{compact:!0,className:"flex-1 min-h-0 flex flex-col overflow-hidden",children:[e.jsx(se,{listHeader:!0,icon:e.jsx(Te,{className:"icon-sm"}),title:"Clients",actions:t.length>0?e.jsx("span",{className:"type-data-xs text-fg-muted",children:t.length}):void 0}),e.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto",children:e.jsx(Se,{clients:t,onRemove:n,messages:l,terminalMode:!1})}),e.jsx(_e,{identity:s,onSendAdvert:a})]})}function et(){const s=Ye(),t=Ie(),l=Xe(),a=Ze(),r=Qe(),n=Je(),c=es(),m=ss(),d=ts(),i=as(),u=o.useMemo(()=>(d==null?void 0:d.neighbors)??{},[d==null?void 0:d.neighbors]),x=Rs(u,i),f=o.useMemo(()=>n.map(h=>{if(h.name)return h;const v=x(h.pubkey);return v.name?{...h,name:v.name}:h}),[n,x]),j=o.useMemo(()=>r.map(h=>{if(h.author_name||h.author_pubkey==="server"||h.author_pubkey==="system")return h;const v=x(h.author_pubkey);return v.name?{...h,author_name:v.name}:h}),[r,x]),{selectRoom:y,postMessage:g,deleteMessage:P,clearMessages:C,createRoom:S,updateRoom:b,deleteRoom:_,sendAdvert:N,markAsRead:M,startActivePolling:k}=Re.getState(),[R,w]=o.useState(!1),[E,D]=o.useState("create"),[A,O]=o.useState("hybrid");o.useEffect(()=>{M()},[t,M]),o.useEffect(()=>k(),[k]);const $=o.useCallback(async h=>t?g({room_name:t,message:h,author_pubkey:"server"}):!1,[t,g]),K=o.useCallback((h="hybrid")=>{O(h),D("create"),w(!0)},[]),T=o.useCallback(()=>{D("edit"),w(!0)},[]),z=e.jsxs("div",{className:"flex items-center gap-2 sm:gap-4 flex-shrink-0",children:[l&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"data-box flex items-center gap-1.5 cursor-default",title:`${l.total_messages} message${l.total_messages!==1?"s":""} in this room`,children:[e.jsx(Pe,{className:"w-3.5 h-3.5 text-fg-secondary"}),e.jsx("span",{children:l.total_messages})]}),e.jsxs("span",{className:"data-box flex items-center gap-1.5 cursor-default",title:`${l.total_clients} client${l.total_clients!==1?"s":""} connected`,children:[e.jsx(Te,{className:"w-3.5 h-3.5 text-fg-secondary"}),e.jsx("span",{children:l.total_clients})]})]}),e.jsx(Ls,{rooms:s,selected:t,onSelect:y,onAdd:()=>K("hybrid")}),s.length>0&&e.jsx(F,{plain:!0,onClick:T,title:"Manage room server",children:e.jsx(ns,{"data-slot":"icon"})})]});return s.length===0&&c.length===0&&!m?e.jsx(be,{children:e.jsxs(pe,{children:[e.jsx(he,{title:"Room Server",icon:e.jsx(Y,{})}),e.jsx(Ts,{onCreateRoom:h=>K(h)}),e.jsx(ye,{open:R,onClose:()=>w(!1),mode:"create",repeaterConfig:d==null?void 0:d.config,onCreate:async h=>{const v=await S(h);return v&&A==="dedicated"&&(await xe.getState().setMode("monitor"),xe.getState().clearModeMutation()),v},onUpdate:b,onDelete:_,onSendAdvert:N})]})}):e.jsx(be,{children:e.jsxs(pe,{children:[e.jsx(he,{title:"Room Server",icon:e.jsx(Y,{}),controls:z}),e.jsx(rs,{children:e.jsxs(ls,{template:"hero-tall",className:"!h-[calc(100vh-11rem)] !min-h-[400px]",children:[e.jsx(ge,{span:12,lg:8,className:"h-full",children:e.jsx(Es,{selectedName:t,selectedIdentity:a,messages:j,onSend:$,onDelete:P,onClear:C})}),e.jsx(ge,{span:12,lg:4,className:"h-full",children:e.jsx(Ks,{selectedIdentity:a,clients:f,messages:j,onSendAdvert:N})})]})}),e.jsx(ye,{open:R,onClose:()=>w(!1),mode:E,identity:a,repeaterConfig:d==null?void 0:d.config,onCreate:S,onUpdate:b,onDelete:_,onSendAdvert:N})]})})}export{et as default}; diff --git a/frontend/dist/assets/Sessions-CZB52dVP.js b/frontend/dist/assets/Sessions-BHExs4jS.js similarity index 85% rename from frontend/dist/assets/Sessions-CZB52dVP.js rename to frontend/dist/assets/Sessions-BHExs4jS.js index acdce590..922e98c7 100644 --- a/frontend/dist/assets/Sessions-CZB52dVP.js +++ b/frontend/dist/assets/Sessions-BHExs4jS.js @@ -1,4 +1,4 @@ -import{d as x,r as l,fc as O,fd as G,dt as U,j as e,B as b,L as M,w as V,b8 as C,c as N,dR as J,cg as Q,bO as Z}from"./index-C1ZF7cAz.js";import{C as W,T as P}from"./ConfirmModal-Cf30hpC_.js";import{D as X}from"./DataBox-BADtaCfB.js";import{P as Y,a as ee,B as se,C as D}from"./PageLayout-sd81yog0.js";import{R as ae}from"./refresh-cw-BjBvU2VX.js";import{R as T,C as j}from"./Grid-DrJ5vfLo.js";import{C as te}from"./circle-question-mark-CxqvWhsl.js";import{T as le}from"./triangle-alert-B3ZB2VPZ.js";import{S as ie}from"./shield-BNyjVgrV.js";import{A as ne}from"./antenna-Bvc4sU0O.js";/** +import{d as x,r as l,fa as G,fb as O,dq as U,j as e,B as g,L as M,y as V,bb as C,c as N,dP as J,ce as Q,bP as Z}from"./index-DhkG1Nx9.js";import{C as W,T as B}from"./ConfirmModal-BoB1If6b.js";import{D as X}from"./DataBox-BMesbbaF.js";import{P as Y,a as ee,B as se,C as D}from"./PageLayout-BkUTZXJb.js";import{R as ae}from"./refresh-cw-CA_1u8Jn.js";import{R as T,C as j}from"./Grid-DknC4rR5.js";import{C as te}from"./circle-question-mark--xh93QHC.js";import{T as le}from"./triangle-alert-D8NErBXC.js";import{S as ie}from"./shield-XXZtlreW.js";import{A as ne}from"./antenna-Dw5nF1O3.js";/** * @license lucide-react v0.559.0 - ISC * * This source code is licensed under the ISC license. @@ -18,9 +18,9 @@ import{d as x,r as l,fc as O,fd as G,dt as U,j as e,B as b,L as M,w as V,b8 as C * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const he=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],$=x("shield-check",he);/** + */const he=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],P=x("shield-check",he);/** * @license lucide-react v0.559.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const ue=[["path",{d:"m16 11 2 2 4-4",key:"9rsbq5"}],["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}]],pe=x("user-check",ue),fe=[{id:"overview",label:"Overview",icon:oe},{id:"clients",label:"Authenticated Clients",icon:pe},{id:"identities",label:"By Identity",icon:de}];function B(s){return s?new Date(s*1e3).toLocaleString():"Never"}function ye(s){if(!s)return"Never";const t=Date.now()-s*1e3,i=Math.floor(t/6e4),h=Math.floor(t/36e5),d=Math.floor(t/864e5);return i<1?"Just now":i<60?`${i}m ago`:h<24?`${h}h ago`:d<365?`${d}d ago`:`${Math.floor(d/365)}y ago`}function g({label:s,value:t,icon:i}){return e.jsxs(D,{neomorphic:!0,children:[e.jsxs("div",{className:"flex items-center gap-1.5 sm:gap-2 mb-2 sm:mb-3",children:[i&&e.jsx("span",{className:"icon-sm text-icon-card-title",children:i}),e.jsx("span",{className:"type-micro",children:s})]}),e.jsx(Q,{centered:!0,children:e.jsx("span",{className:"type-data-xl text-fg-primary font-mono font-normal tabular-nums",children:t})})]})}function je({identity:s}){const t=s.type==="repeater";return e.jsxs("div",{className:"bg-subtle-fill/80 radius-inner depth-stroke-raised p-4",children:[e.jsxs("div",{className:"flex items-center gap-1.5 sm:gap-2 mb-3",children:[e.jsx("span",{className:"icon-sm text-icon-card-title",children:t?e.jsx(ne,{className:"w-4 h-4"}):e.jsx(Z,{className:"w-4 h-4"})}),e.jsx("span",{className:"type-micro",children:s.name}),e.jsx(X,{copy:!0,size:"compact",truncate:[8,6],color:"text-fg-muted",children:s.hash}),e.jsx("span",{className:"data-box data-box-compact data-box-outlined ml-auto",style:{"--data-box-accent":t?"var(--sys-blue)":"var(--sys-pink)"},children:s.type})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"data-box-label",children:"Max Clients"}),e.jsx("div",{className:"data-box data-box-fill data-box-left",children:s.max_clients})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"data-box-label",children:"Authenticated"}),e.jsx("div",{className:"data-box data-box-fill data-box-left",children:s.authenticated_clients})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"data-box-label",children:"Admin Password"}),e.jsx("div",{className:"data-box data-box-fill data-box-left",style:{"--data-box-color":s.has_admin_password?"var(--sys-green)":"var(--sys-red)"},children:s.has_admin_password?"✓ Set":"✗ Not Set"})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"data-box-label",children:"Guest Password"}),e.jsx("div",{className:"data-box data-box-fill data-box-left",style:{"--data-box-color":s.has_guest_password?"var(--sys-green)":"var(--sys-red)"},children:s.has_guest_password?"✓ Set":"✗ Not Set"})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"data-box-label",children:"Read-Only Access"}),e.jsx("div",{className:N("data-box data-box-fill data-box-left",s.allow_read_only?"text-sys-green":"text-sys-red"),children:s.allow_read_only?"Allowed":"Disabled"})]})]})]})}function ge({client:s,onRemove:t}){return e.jsx("div",{className:"bg-subtle-fill/80 radius-inner depth-stroke-raised p-4 transition-base hover:bg-subtle-fill-strong",children:e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3",children:[e.jsxs("div",{className:"flex-1 min-w-0 grid grid-cols-1 sm:grid-cols-5 gap-2 sm:gap-4 items-center",children:[e.jsxs("div",{className:"sm:col-span-1",children:[e.jsx("span",{className:"type-data-xs text-fg-muted block sm:hidden mb-0.5",children:"Client"}),e.jsx("span",{className:"type-data-sm text-fg-primary font-mono truncate block",children:s.public_key})]}),e.jsxs("div",{className:"sm:col-span-1",children:[e.jsx("span",{className:"type-data-xs text-fg-muted block sm:hidden mb-0.5",children:"Address"}),e.jsx("span",{className:"type-data-xs text-fg-muted font-mono truncate block",children:s.address})]}),e.jsxs("div",{className:"sm:col-span-1",children:[e.jsx("span",{className:"type-data-xs text-fg-muted block sm:hidden mb-0.5",children:"Identity"}),e.jsx("span",{className:"type-data-sm text-fg-primary block truncate",children:s.identity_name}),e.jsx("span",{className:"type-data-xs text-fg-muted block truncate",children:s.identity_hash})]}),e.jsxs("div",{className:"sm:col-span-1",children:[e.jsx("span",{className:"type-data-xs text-fg-muted block sm:hidden mb-0.5",children:"Permissions"}),e.jsx("span",{className:N("type-data-xs px-2 py-0.5 rounded-full font-medium inline-block",s.permissions==="admin"?"bg-sys-green/15 text-sys-green":"bg-sys-amber/15 text-sys-amber"),children:s.permissions})]}),e.jsxs("div",{className:"sm:col-span-1",children:[e.jsx("span",{className:"type-data-xs text-fg-muted block sm:hidden mb-0.5",children:"Last Activity"}),e.jsx("span",{className:"type-data-xs text-fg-muted",children:ye(s.last_activity)})]})]}),e.jsxs(b,{color:"danger",outline:!0,onClick:t,className:"flex-shrink-0",children:[e.jsx(P,{"data-slot":"icon"}),"Remove"]})]})})}function be({client:s,onRemove:t}){return e.jsx("div",{className:"bg-subtle-fill/80 radius-inner depth-stroke-raised p-4 transition-base hover:bg-subtle-fill-strong",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx("span",{className:N("type-data-xs px-2 py-0.5 rounded-full font-medium",s.permissions==="admin"?"bg-sys-green/15 text-sys-green":"bg-sys-amber/15 text-sys-amber"),children:s.permissions}),e.jsx("span",{className:"type-data-sm text-fg-primary font-mono truncate",children:s.public_key})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2 text-sm",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-fg-muted",children:"Address: "}),e.jsx("span",{className:"text-fg-primary/90 font-mono",children:s.address})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-fg-muted",children:"Identity: "}),e.jsxs("span",{className:"text-fg-primary/90",children:[s.identity_name," (",s.identity_hash,")"]})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-fg-muted",children:"Last Activity: "}),e.jsx("span",{className:"text-fg-primary/90",children:B(s.last_activity)})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-fg-muted",children:"Last Login: "}),e.jsx("span",{className:"text-fg-primary/90",children:B(s.last_login_success)})]})]})]}),e.jsx(b,{color:"danger",outline:!0,onClick:t,className:"flex-shrink-0",children:e.jsx(P,{"data-slot":"icon"})})]})})}function Ie(){const[s,t]=l.useState("overview"),[i,h]=l.useState(!0),[d,S]=l.useState(!1),[u,v]=l.useState("idle"),[A,p]=l.useState(null),[w,K]=l.useState(null),[c,E]=l.useState([]),[r,F]=l.useState(null),[o,H]=l.useState(null),[n,f]=l.useState(null),[q,R]=l.useState(!1),k=(w==null?void 0:w.acls)??[],L=l.useMemo(()=>o?c.filter(a=>a.identity_name===o):c,[c,o]),y=l.useCallback(async()=>{p(null);try{const[a,m,_]=await Promise.all([O(),G(),U()]);a.success&&a.data&&K(a.data),m.success&&m.data&&E(m.data.clients||[]),_.success&&_.data&&F(_.data)}catch(a){p(a instanceof Error?a.message:"Failed to load session data")}},[]);l.useEffect(()=>{y().finally(()=>h(!1))},[y]);const I=async()=>{S(!0),v("loading"),await y(),S(!1),v("success"),setTimeout(()=>v("idle"),1500)},z=async()=>{if(n){R(!0);try{const a=await J({public_key:n.publicKey,identity_hash:n.identityHash});a.success?await y():p(`Failed to remove client: ${a.error}`)}catch(a){p(a instanceof Error?a.message:"Failed to remove client")}finally{R(!1),f(null)}}};return e.jsxs(Y,{children:[e.jsx(ee,{title:"Sessions",icon:e.jsx(C,{}),controls:e.jsxs(b,{color:u==="success"?"success":"primary",outline:!0,onClick:I,disabled:d,children:[u==="loading"?e.jsx(M,{"data-slot":"icon",className:"animate-spin"}):u==="success"?e.jsx(V,{"data-slot":"icon"}):e.jsx(ae,{"data-slot":"icon"}),u==="success"?"Done":"Refresh"]}),subtitle:e.jsx("p",{className:"type-body-sm text-fg-muted",children:"Manage authenticated clients and access control lists"})}),e.jsxs(se,{children:[r&&e.jsxs(T,{template:"widget",children:[e.jsx(j,{span:6,md:3,children:e.jsx(g,{label:"Identities",value:r.total_identities,icon:e.jsx(C,{className:"w-4 h-4"})})}),e.jsx(j,{span:6,md:3,children:e.jsx(g,{label:"Authenticated",value:r.total_clients,icon:e.jsx(xe,{className:"w-4 h-4"})})}),e.jsx(j,{span:6,md:3,children:e.jsx(g,{label:"Admin",value:r.admin_clients,icon:e.jsx($,{className:"w-4 h-4"})})}),e.jsx(j,{span:6,md:3,children:e.jsx(g,{label:"Guest",value:r.guest_clients,icon:e.jsx(te,{className:"w-4 h-4"})})})]}),e.jsx(T,{template:"auto",children:e.jsxs(D,{neomorphic:!0,children:[e.jsx("div",{className:"flex flex-wrap gap-1 mb-5",children:e.jsx("div",{className:"toggle-group",children:fe.map(a=>{const m=s===a.id;return e.jsxs("button",{onClick:()=>t(a.id),className:N("toggle-group-item flex items-center gap-1.5",m&&"active"),children:[e.jsx(a.icon,{className:"w-3.5 h-3.5"}),a.label]},a.id)})})}),e.jsx("div",{className:"min-h-[300px]",children:i?e.jsxs("div",{className:"flex items-center justify-center py-12",children:[e.jsx(M,{className:"w-6 h-6 animate-spin text-sys-blue mr-3"}),e.jsx("span",{className:"type-body text-fg-muted",children:"Loading session data..."})]}):A?e.jsxs("div",{className:"text-center py-12",children:[e.jsx("div",{className:"w-12 h-12 rounded-full bg-sys-red/10 mx-auto mb-3 flex items-center justify-center",children:e.jsx(le,{className:"w-6 h-6 text-sys-red"})}),e.jsx("p",{className:"type-body text-sys-red mb-2",children:"Failed to load session data"}),e.jsx("p",{className:"type-body-sm text-fg-muted mb-4",children:A}),e.jsx(b,{color:"primary",outline:!0,onClick:I,children:"Retry"})]}):e.jsxs(e.Fragment,{children:[s==="overview"&&e.jsx("div",{className:"space-y-4",children:k.length===0?e.jsxs("div",{className:"text-center py-12",children:[e.jsx("div",{className:"w-14 h-14 rounded-full bg-subtle-fill mx-auto mb-4 flex items-center justify-center",children:e.jsx($,{className:"w-7 h-7 text-fg-muted/50"})}),e.jsx("p",{className:"type-body text-fg-muted",children:"No identities configured"})]}):k.map(a=>e.jsx(je,{identity:a},a.hash))}),s==="clients"&&e.jsxs("div",{className:"space-y-3",children:[c.length>0&&e.jsxs("div",{className:"hidden sm:grid grid-cols-5 gap-4 px-4 pb-2 border-b border-edge-subtle",children:[e.jsx("span",{className:"type-data-xs text-fg-muted font-medium",children:"Client"}),e.jsx("span",{className:"type-data-xs text-fg-muted font-medium",children:"Address"}),e.jsx("span",{className:"type-data-xs text-fg-muted font-medium",children:"Identity"}),e.jsx("span",{className:"type-data-xs text-fg-muted font-medium",children:"Permissions"}),e.jsx("span",{className:"type-data-xs text-fg-muted font-medium",children:"Last Activity"})]}),c.length===0?e.jsxs("div",{className:"text-center py-12",children:[e.jsx("div",{className:"w-14 h-14 rounded-full bg-subtle-fill mx-auto mb-4 flex items-center justify-center",children:e.jsx(C,{className:"w-7 h-7 text-fg-muted/50"})}),e.jsx("p",{className:"type-body text-fg-muted",children:"No authenticated clients"})]}):c.map(a=>e.jsx(ge,{client:a,onRemove:()=>f({publicKey:a.public_key_full,identityHash:a.identity_hash,displayKey:a.public_key})},a.public_key_full))]}),s==="identities"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"type-label text-fg-muted block mb-2",children:"Filter by Identity"}),e.jsxs("select",{value:o??"",onChange:a=>H(a.target.value||null),className:"w-full sm:w-auto bg-subtle-fill border border-edge-subtle radius-inner px-4 py-2 type-data text-fg-primary focus:outline-none focus:border-sys-blue/50 transition-colors",children:[e.jsx("option",{value:"",children:"All Identities"}),k.map(a=>e.jsxs("option",{value:a.name,children:[a.name," (",a.authenticated_clients," clients)"]},a.name))]})]}),L.length===0?e.jsxs("div",{className:"text-center py-12",children:[e.jsx("div",{className:"w-14 h-14 rounded-full bg-subtle-fill mx-auto mb-4 flex items-center justify-center",children:e.jsx(ie,{className:"w-7 h-7 text-fg-muted/50"})}),e.jsx("p",{className:"type-body text-fg-muted",children:o?"No clients for selected identity":"No clients found"})]}):e.jsx("div",{className:"space-y-3",children:L.map(a=>e.jsx(be,{client:a,onRemove:()=>f({publicKey:a.public_key_full,identityHash:a.identity_hash,displayKey:a.public_key})},a.public_key_full))})]})]})})]})})]}),e.jsx(W,{isOpen:!!n,title:"Remove Client",message:`Are you sure you want to remove client '${n==null?void 0:n.displayKey}' from the ACL? This will disconnect the client.`,confirmLabel:q?"Removing...":"Remove",cancelLabel:"Cancel",variant:"danger",onConfirm:z,onCancel:()=>f(null)})]})}export{Ie as default}; + */const ue=[["path",{d:"m16 11 2 2 4-4",key:"9rsbq5"}],["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}]],pe=x("user-check",ue),fe=[{id:"overview",label:"Overview",icon:oe},{id:"clients",label:"Authenticated Clients",icon:pe},{id:"identities",label:"By Identity",icon:de}];function $(s){return s?new Date(s*1e3).toLocaleString():"Never"}function ye(s){if(!s)return"Never";const t=Date.now()-s*1e3,i=Math.floor(t/6e4),h=Math.floor(t/36e5),d=Math.floor(t/864e5);return i<1?"Just now":i<60?`${i}m ago`:h<24?`${h}h ago`:d<365?`${d}d ago`:`${Math.floor(d/365)}y ago`}function b({label:s,value:t,icon:i}){return e.jsxs(D,{neomorphic:!0,children:[e.jsxs("div",{className:"flex items-center gap-1.5 sm:gap-2 mb-2 sm:mb-3",children:[i&&e.jsx("span",{className:"icon-sm text-icon-card-title",children:i}),e.jsx("span",{className:"type-micro",children:s})]}),e.jsx(Q,{centered:!0,children:e.jsx("span",{className:"type-data-xl text-fg-primary font-mono font-normal tabular-nums",children:t})})]})}function je({identity:s}){const t=s.type==="repeater";return e.jsxs("div",{className:"bg-subtle-fill/80 radius-inner depth-stroke-raised p-4",children:[e.jsxs("div",{className:"flex items-center gap-1.5 sm:gap-2 mb-3",children:[e.jsx("span",{className:"icon-sm text-icon-card-title",children:t?e.jsx(ne,{className:"w-4 h-4"}):e.jsx(Z,{className:"w-4 h-4"})}),e.jsx("span",{className:"type-micro",children:s.name}),e.jsx(X,{copy:!0,size:"compact",truncate:[8,6],color:"text-fg-muted",children:s.hash}),e.jsx("span",{className:"data-box data-box-compact data-box-outlined ml-auto",style:{"--data-box-accent":t?"var(--sys-blue)":"var(--sys-pink)"},children:s.type})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"data-box-label",children:"Max Clients"}),e.jsx("div",{className:"data-box data-box-fill data-box-left",children:s.max_clients})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"data-box-label",children:"Authenticated"}),e.jsx("div",{className:"data-box data-box-fill data-box-left",children:s.authenticated_clients})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"data-box-label",children:"Admin Password"}),e.jsx("div",{className:"data-box data-box-fill data-box-left",style:{"--data-box-color":s.has_admin_password?"var(--sys-green)":"var(--sys-red)"},children:s.has_admin_password?"✓ Set":"✗ Not Set"})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"data-box-label",children:"Guest Password"}),e.jsx("div",{className:"data-box data-box-fill data-box-left",style:{"--data-box-color":s.has_guest_password?"var(--sys-green)":"var(--sys-red)"},children:s.has_guest_password?"✓ Set":"✗ Not Set"})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"data-box-label",children:"Read-Only Access"}),e.jsx("div",{className:N("data-box data-box-fill data-box-left",s.allow_read_only?"text-sys-green":"text-sys-red"),children:s.allow_read_only?"Allowed":"Disabled"})]})]})]})}function be({client:s,onRemove:t}){return e.jsx("div",{className:"bg-subtle-fill/80 radius-inner depth-stroke-raised p-4 transition-base hover:bg-subtle-fill-strong",children:e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3",children:[e.jsxs("div",{className:"flex-1 min-w-0 grid grid-cols-1 sm:grid-cols-5 gap-2 sm:gap-4 items-center",children:[e.jsxs("div",{className:"sm:col-span-1",children:[e.jsx("span",{className:"type-data-xs text-fg-muted block sm:hidden mb-0.5",children:"Client"}),e.jsx("span",{className:"type-data-sm text-fg-primary font-mono truncate block",children:s.public_key})]}),e.jsxs("div",{className:"sm:col-span-1",children:[e.jsx("span",{className:"type-data-xs text-fg-muted block sm:hidden mb-0.5",children:"Address"}),e.jsx("span",{className:"type-data-xs text-fg-muted font-mono truncate block",children:s.address})]}),e.jsxs("div",{className:"sm:col-span-1",children:[e.jsx("span",{className:"type-data-xs text-fg-muted block sm:hidden mb-0.5",children:"Identity"}),e.jsx("span",{className:"type-data-sm text-fg-primary block truncate",children:s.identity_name}),e.jsx("span",{className:"type-data-xs text-fg-muted block truncate",children:s.identity_hash})]}),e.jsxs("div",{className:"sm:col-span-1",children:[e.jsx("span",{className:"type-data-xs text-fg-muted block sm:hidden mb-0.5",children:"Permissions"}),e.jsx("span",{className:N("type-data-xs px-2 py-0.5 rounded-full font-medium inline-block",s.permissions==="admin"?"bg-sys-green/15 text-sys-green":"bg-sys-amber/15 text-sys-amber"),children:s.permissions})]}),e.jsxs("div",{className:"sm:col-span-1",children:[e.jsx("span",{className:"type-data-xs text-fg-muted block sm:hidden mb-0.5",children:"Last Activity"}),e.jsx("span",{className:"type-data-xs text-fg-muted",children:ye(s.last_activity)})]})]}),e.jsxs(g,{color:"danger",outline:!0,onClick:t,className:"flex-shrink-0",children:[e.jsx(B,{"data-slot":"icon"}),"Remove"]})]})})}function ge({client:s,onRemove:t}){return e.jsx("div",{className:"bg-subtle-fill/80 radius-inner depth-stroke-raised p-4 transition-base hover:bg-subtle-fill-strong",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx("span",{className:N("type-data-xs px-2 py-0.5 rounded-full font-medium",s.permissions==="admin"?"bg-sys-green/15 text-sys-green":"bg-sys-amber/15 text-sys-amber"),children:s.permissions}),e.jsx("span",{className:"type-data-sm text-fg-primary font-mono truncate",children:s.public_key})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2 text-sm",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-fg-muted",children:"Address: "}),e.jsx("span",{className:"text-fg-primary/90 font-mono",children:s.address})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-fg-muted",children:"Identity: "}),e.jsxs("span",{className:"text-fg-primary/90",children:[s.identity_name," (",s.identity_hash,")"]})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-fg-muted",children:"Last Activity: "}),e.jsx("span",{className:"text-fg-primary/90",children:$(s.last_activity)})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-fg-muted",children:"Last Login: "}),e.jsx("span",{className:"text-fg-primary/90",children:$(s.last_login_success)})]})]})]}),e.jsx(g,{color:"danger",outline:!0,onClick:t,className:"flex-shrink-0",children:e.jsx(B,{"data-slot":"icon"})})]})})}function Ie(){const[s,t]=l.useState("overview"),[i,h]=l.useState(!0),[d,S]=l.useState(!1),[u,v]=l.useState("idle"),[A,p]=l.useState(null),[w,K]=l.useState(null),[c,E]=l.useState([]),[r,F]=l.useState(null),[o,q]=l.useState(null),[n,f]=l.useState(null),[H,R]=l.useState(!1),k=(w==null?void 0:w.acls)??[],L=l.useMemo(()=>o?c.filter(a=>a.identity_name===o):c,[c,o]),y=l.useCallback(async()=>{p(null);try{const[a,m,_]=await Promise.all([G(),O(),U()]);a.success&&a.data&&K(a.data),m.success&&m.data&&E(m.data.clients||[]),_.success&&_.data&&F(_.data)}catch(a){p(a instanceof Error?a.message:"Failed to load session data")}},[]);l.useEffect(()=>{y().finally(()=>h(!1))},[y]);const I=async()=>{S(!0),v("loading"),await y(),S(!1),v("success"),setTimeout(()=>v("idle"),1500)},z=async()=>{if(n){R(!0);try{const a=await J({public_key:n.publicKey,identity_hash:n.identityHash});a.success?await y():p(`Failed to remove client: ${a.error}`)}catch(a){p(a instanceof Error?a.message:"Failed to remove client")}finally{R(!1),f(null)}}};return e.jsxs(Y,{children:[e.jsx(ee,{title:"Sessions",icon:e.jsx(C,{}),controls:e.jsxs(g,{color:u==="success"?"success":"primary",outline:!0,onClick:I,disabled:d,children:[u==="loading"?e.jsx(M,{"data-slot":"icon",className:"animate-spin"}):u==="success"?e.jsx(V,{"data-slot":"icon"}):e.jsx(ae,{"data-slot":"icon"}),u==="success"?"Done":"Refresh"]}),subtitle:e.jsx("p",{className:"type-body-sm text-fg-muted",children:"Manage authenticated clients and access control lists"})}),e.jsxs(se,{children:[r&&e.jsxs(T,{template:"widget",children:[e.jsx(j,{span:6,md:3,children:e.jsx(b,{label:"Identities",value:r.total_identities,icon:e.jsx(C,{className:"w-4 h-4"})})}),e.jsx(j,{span:6,md:3,children:e.jsx(b,{label:"Authenticated",value:r.total_clients,icon:e.jsx(xe,{className:"w-4 h-4"})})}),e.jsx(j,{span:6,md:3,children:e.jsx(b,{label:"Admin",value:r.admin_clients,icon:e.jsx(P,{className:"w-4 h-4"})})}),e.jsx(j,{span:6,md:3,children:e.jsx(b,{label:"Guest",value:r.guest_clients,icon:e.jsx(te,{className:"w-4 h-4"})})})]}),e.jsx(T,{template:"auto",children:e.jsxs(D,{neomorphic:!0,children:[e.jsx("div",{className:"flex flex-wrap gap-1 mb-5",children:e.jsx("div",{className:"toggle-group",children:fe.map(a=>{const m=s===a.id;return e.jsxs("button",{onClick:()=>t(a.id),className:N("toggle-group-item flex items-center gap-1.5",m&&"active"),children:[e.jsx(a.icon,{className:"w-3.5 h-3.5"}),a.label]},a.id)})})}),e.jsx("div",{className:"min-h-[300px]",children:i?e.jsxs("div",{className:"flex items-center justify-center py-12",children:[e.jsx(M,{className:"w-6 h-6 animate-spin text-sys-blue mr-3"}),e.jsx("span",{className:"type-body text-fg-muted",children:"Loading session data..."})]}):A?e.jsxs("div",{className:"text-center py-12",children:[e.jsx("div",{className:"w-12 h-12 rounded-full bg-sys-red/10 mx-auto mb-3 flex items-center justify-center",children:e.jsx(le,{className:"w-6 h-6 text-sys-red"})}),e.jsx("p",{className:"type-body text-sys-red mb-2",children:"Failed to load session data"}),e.jsx("p",{className:"type-body-sm text-fg-muted mb-4",children:A}),e.jsx(g,{color:"primary",outline:!0,onClick:I,children:"Retry"})]}):e.jsxs(e.Fragment,{children:[s==="overview"&&e.jsx("div",{className:"space-y-4",children:k.length===0?e.jsxs("div",{className:"text-center py-12",children:[e.jsx("div",{className:"w-14 h-14 rounded-full bg-subtle-fill mx-auto mb-4 flex items-center justify-center",children:e.jsx(P,{className:"w-7 h-7 text-fg-muted/50"})}),e.jsx("p",{className:"type-body text-fg-muted",children:"No identities configured"})]}):k.map(a=>e.jsx(je,{identity:a},a.hash))}),s==="clients"&&e.jsxs("div",{className:"space-y-3",children:[c.length>0&&e.jsxs("div",{className:"hidden sm:grid grid-cols-5 gap-4 px-4 pb-2 border-b border-edge-subtle",children:[e.jsx("span",{className:"type-data-xs text-fg-muted font-medium",children:"Client"}),e.jsx("span",{className:"type-data-xs text-fg-muted font-medium",children:"Address"}),e.jsx("span",{className:"type-data-xs text-fg-muted font-medium",children:"Identity"}),e.jsx("span",{className:"type-data-xs text-fg-muted font-medium",children:"Permissions"}),e.jsx("span",{className:"type-data-xs text-fg-muted font-medium",children:"Last Activity"})]}),c.length===0?e.jsxs("div",{className:"text-center py-12",children:[e.jsx("div",{className:"w-14 h-14 rounded-full bg-subtle-fill mx-auto mb-4 flex items-center justify-center",children:e.jsx(C,{className:"w-7 h-7 text-fg-muted/50"})}),e.jsx("p",{className:"type-body text-fg-muted",children:"No authenticated clients"})]}):c.map(a=>e.jsx(be,{client:a,onRemove:()=>f({publicKey:a.public_key_full,identityHash:a.identity_hash,displayKey:a.public_key})},a.public_key_full))]}),s==="identities"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"type-label text-fg-muted block mb-2",children:"Filter by Identity"}),e.jsxs("select",{value:o??"",onChange:a=>q(a.target.value||null),className:"w-full sm:w-auto bg-subtle-fill border border-edge-subtle radius-inner px-4 py-2 type-data text-fg-primary focus:outline-none focus:border-sys-blue/50 transition-colors",children:[e.jsx("option",{value:"",children:"All Identities"}),k.map(a=>e.jsxs("option",{value:a.name,children:[a.name," (",a.authenticated_clients," clients)"]},a.name))]})]}),L.length===0?e.jsxs("div",{className:"text-center py-12",children:[e.jsx("div",{className:"w-14 h-14 rounded-full bg-subtle-fill mx-auto mb-4 flex items-center justify-center",children:e.jsx(ie,{className:"w-7 h-7 text-fg-muted/50"})}),e.jsx("p",{className:"type-body text-fg-muted",children:o?"No clients for selected identity":"No clients found"})]}):e.jsx("div",{className:"space-y-3",children:L.map(a=>e.jsx(ge,{client:a,onRemove:()=>f({publicKey:a.public_key_full,identityHash:a.identity_hash,displayKey:a.public_key})},a.public_key_full))})]})]})})]})})]}),e.jsx(W,{isOpen:!!n,title:"Remove Client",message:`Are you sure you want to remove client '${n==null?void 0:n.displayKey}' from the ACL? This will disconnect the client.`,confirmLabel:H?"Removing...":"Remove",cancelLabel:"Cancel",variant:"danger",onConfirm:z,onCancel:()=>f(null)})]})}export{Ie as default}; diff --git a/frontend/dist/assets/SignalIndicator-BDLlaquA.js b/frontend/dist/assets/SignalIndicator-DEXVYOhU.js similarity index 99% rename from frontend/dist/assets/SignalIndicator-BDLlaquA.js rename to frontend/dist/assets/SignalIndicator-DEXVYOhU.js index a9791cd7..909532e7 100644 --- a/frontend/dist/assets/SignalIndicator-BDLlaquA.js +++ b/frontend/dist/assets/SignalIndicator-DEXVYOhU.js @@ -1,4 +1,4 @@ -import{d as s,r as m,c as l,j as r,bZ as j,b_ as k,b$ as _}from"./index-C1ZF7cAz.js";/** +import{d as s,r as m,c as l,j as r,bZ as j,b_ as k,b$ as _}from"./index-DhkG1Nx9.js";/** * @license lucide-react v0.559.0 - ISC * * This source code is licensed under the ISC license. diff --git a/frontend/dist/assets/Statistics-Dzfzapmt.js b/frontend/dist/assets/Statistics-Dzfzapmt.js deleted file mode 100644 index e28d6915..00000000 --- a/frontend/dist/assets/Statistics-Dzfzapmt.js +++ /dev/null @@ -1,41 +0,0 @@ -var Mt=Object.defineProperty;var Ct=(t,n,s)=>n in t?Mt(t,n,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[n]=s;var xe=(t,n,s)=>Ct(t,typeof n!="symbol"?n+"":n,s);import{d as Ae,r as c,j as e,k as Ce,c as nt,b9 as yt,c0 as bt,c1 as Je,c2 as ve,c3 as At,q as Fe,c4 as _t,c5 as Rt,e as Lt,c6 as Dt,c7 as Et,c8 as Tt,c9 as It,ca as Pt,by as Ot,cb as Be,bB as Ft,cc as Ht,cd as Bt,F as Ne,ce as $t,cf as zt,cg as Wt,E as Ut,J as Gt,H as qt,y as Vt,ag as Kt,ah as Yt,K as Xt,aa as Zt,ch as Qt,ci as $e,cj as at,a2 as Jt,R as es,ck as ts}from"./index-C1ZF7cAz.js";import{L as Se}from"./layers-BNenbfjd.js";import{u as et,h as ss,r as tt}from"./consumer-registry-CFnLzQEu.js";import{C as ze,e as ns}from"./easing-BGz60jqS.js";import{T as as}from"./TimeRangeStepper-CxA2aT1o.js";import{C as le,P as rs,a as is,B as os}from"./PageLayout-sd81yog0.js";import{D as ls}from"./DataBox-BADtaCfB.js";import{E as cs,A as Oe}from"./AnimatedNumber-DdMz2uoH.js";import{C as ms}from"./CollisionExplorerModal-Bm7X5dgz.js";import{H as rt}from"./hash-2pKM_KWy.js";import{T as Ze}from"./triangle-alert-B3ZB2VPZ.js";import{L as ds}from"./LightSparkline-7x8sYJi9.js";import{A as us}from"./activity-Bmh45lNn.js";import{c as hs,a as xs,A as ps}from"./AnalyzerFilterPanel-D0gvrDVF.js";import{useResolveSource as fs}from"./usePipelineStore-BEu0jDzA.js";import{R as ge,C as we}from"./Grid-DrJ5vfLo.js";import{S as gs}from"./settings-2-fZXt90fn.js";import{N as ys}from"./network-4dDTHizq.js";import"./chevron-right-DzbDJf-i.js";import"./map-pin-DEktgLFN.js";import"./index-DCNWD5GU.js";import"./BasemapLayer-CfNM-FKA.js";import"./monitor-smartphone-BQ_i3P0U.js";import"./node-types-BJeLdOcD.js";import"./funnel-zG3cM6J7.js";import"./circle-question-mark-CxqvWhsl.js";import"./search-CtlrlrHK.js";/** - * @license lucide-react v0.559.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const bs=[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"m19 9-5 5-4-4-3 3",key:"2osh9i"}]],js=Ae("chart-line",bs);/** - * @license lucide-react v0.559.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const Ns=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],it=Ae("circle-check-big",Ns);/** - * @license lucide-react v0.559.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const vs=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M3 15h18",key:"5xshup"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"M15 3v18",key:"14nvp0"}]],Ss=Ae("grid-3x3",vs);/** - * @license lucide-react v0.559.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const ks=[["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["circle",{cx:"19",cy:"5",r:"1",key:"w8mnmm"}],["circle",{cx:"5",cy:"5",r:"1",key:"lttvr7"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}],["circle",{cx:"12",cy:"19",r:"1",key:"lyex9k"}],["circle",{cx:"19",cy:"19",r:"1",key:"shf9b7"}],["circle",{cx:"5",cy:"19",r:"1",key:"bfqh0e"}]],ws=Ae("grip",ks);/** - * @license lucide-react v0.559.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const Ms=[["path",{d:"M2 6c.6.5 1.2 1 2.5 1C7 7 7 5 9.5 5c2.6 0 2.4 2 5 2 2.5 0 2.5-2 5-2 1.3 0 1.9.5 2.5 1",key:"knzxuh"}],["path",{d:"M2 12c.6.5 1.2 1 2.5 1 2.5 0 2.5-2 5-2 2.6 0 2.4 2 5 2 2.5 0 2.5-2 5-2 1.3 0 1.9.5 2.5 1",key:"2jd2cc"}],["path",{d:"M2 18c.6.5 1.2 1 2.5 1 2.5 0 2.5-2 5-2 2.6 0 2.4 2 5 2 2.5 0 2.5-2 5-2 1.3 0 1.9.5 2.5 1",key:"rd2r6e"}]],Cs=Ae("waves",Ms),jt={useAbsoluteThresholds:!0,baselinePercentile:6,spikePercentile:50,baselineDbm:-107,spikeDbm:-100,mergeGapSeconds:45,minSequenceLength:16,similarityToleranceDbm:5};function je(t,n){if(t.length===0)return 0;const s=n/100*(t.length-1),a=Math.floor(s),i=Math.ceil(s);return a===i?t[a]:t[a]+(t[i]-t[a])*(s-a)}function ot(t){if(t.length===0)return{median:0,p90:0,p95:0,p99:0,max:0,min:0};const n=[...t].sort((s,a)=>s-a);return{median:je(n,50),p90:je(n,90),p95:je(n,95),p99:je(n,99),max:n[n.length-1],min:n[0]}}function As(t,n={}){const s={...jt,...n};if(t.length<10)return{anomalies:[],thresholds:ot([]),totalSamples:t.length,anomalySamples:0};const a=t.map(g=>g.noise_floor_dbm),i=ot(a),r=[...a].sort((g,j)=>g-j);let l,x;s.useAbsoluteThresholds?(l=s.baselineDbm,x=s.spikeDbm):(l=je(r,s.baselinePercentile),x=je(r,s.spikePercentile));const o=[...t].sort((g,j)=>g.timestamp-j.timestamp),p=[];let d=null,h=0;for(const g of o)if(g.noise_floor_dbm>l&&g.noise_floor_dbmP+z,0)/d.values.length):(d.values.length>=s.minSequenceLength&&p.push(d),d={startTs:g.timestamp,endTs:g.timestamp,values:[g.noise_floor_dbm],timestamps:[g.timestamp],rollingAvg:g.noise_floor_dbm})}else d&&d.values.length>=s.minSequenceLength&&p.push(d),d=null;return d&&d.values.length>=s.minSequenceLength&&p.push(d),p.length===0?{anomalies:[],thresholds:i,totalSamples:t.length,anomalySamples:h,debug:{baselineCutoff:l,spikeCutoff:x,midBandSamples:h}}:{anomalies:p.map(g=>{const j=Math.max(...g.values),b=g.values.reduce((k,L)=>k+L,0)/g.values.length;return{startTs:g.startTs,endTs:g.endTs,peakValue:j,avgValue:b,severity:_s(b,l,x),sampleCount:g.values.length}}),thresholds:i,totalSamples:t.length,anomalySamples:h,debug:{baselineCutoff:l,spikeCutoff:x,midBandSamples:h}}}function _s(t,n,s){const a=s-n;if(a===0)return"moderate";const i=(t-n)/a;return i>.66?"critical":i>.33?"severe":"moderate"}const Rs=Object.entries(yt).map(([t,n])=>{const s=parseInt(t,10);return{typeNum:s,key:`TYPE_${s}`,label:n}});function st({sortedTypes:t,highlightedType:n,onTypeHover:s,aggregateShares:a,hoverData:i}){const r=c.useMemo(()=>{if(!i)return null;const o=new Map;for(const p of i.items)o.set(p.key,p.value);return o},[i]),l=r!==null,x=c.useMemo(()=>{const o=new Set(t.map(h=>h.key)),p=t.map(h=>({typeNum:h.typeNum,key:h.key,label:h.label})),d=Rs.filter(h=>!o.has(h.key));return[...p,...d]},[t]);return e.jsxs("div",{className:"flex-shrink-0 pt-2 sm:pt-3 mt-1 sm:mt-2 px-0 sm:pr-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mx-0 sm:ml-9 sm:mr-0 mb-1 sm:mb-1.5 type-data-xs",children:[e.jsx("span",{className:"text-fg-muted",children:"Packet Types"}),l&&(i==null?void 0:i.timeLabel)&&e.jsx("span",{className:"text-sys-indigo tabular-nums",children:i.timeLabel})]}),e.jsx("div",{className:"flex flex-wrap gap-x-3 sm:gap-x-4 gap-y-1 type-data-xs mx-0 sm:ml-9 sm:mr-0",onMouseLeave:()=>s(null),children:x.map(o=>{const p=Ce(o.typeNum),d=(r==null?void 0:r.get(o.key))??0,h=a.get(o.key)??0,w=l?d:h,g=w>1e-4,j=a.has(o.key),b=n===o.key,k=n&&!b||l&&d<=1e-4||!l&&!n&&!j;return e.jsxs("div",{className:nt("flex items-center gap-1.5 transition-opacity cursor-pointer hover:opacity-80",k&&"opacity-30"),onMouseEnter:()=>s(o.key),children:[e.jsx("div",{className:"shrink-0 w-3 h-3 rounded-xs",style:{backgroundColor:p}}),e.jsx("span",{className:"text-fg-secondary whitespace-nowrap",children:o.label}),g&&e.jsxs("span",{className:nt("tabular-nums",l?"text-fg-primary":"text-fg-muted"),children:[(w*100).toFixed(1),"%"]})]},o.key)})})]})}const lt='ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace',Ls=2,Ds=3,Es=32,Ts=20,Is=80;function ct(t,n,s,a,i){const r=t.reduce((p,d)=>p+d,0);if(r<=0||t.length===0)return[];const l=t.map((p,d)=>d).sort((p,d)=>t[d]-t[p]),x=l.map(p=>t[p]),o=new Array(t.length);return Qe(x,l,r,n,s,a,i,o),o}function Qe(t,n,s,a,i,r,l,x){if(t.length===0)return;if(t.length===1){x[n[0]]={x:a,y:i,w:r,h:l,index:n[0]};return}const o=r*l/s,p=r>=l,d=p?l:r;let h=0,w=1/0,g=0;for(let z=0;zV?O/V:V/O,N>V?N/V:V/N);if(m<=w)w=m,g=z+1,h=H;else break}const j=d>0?h*o/d:0;let b=0;for(let z=0;z0?t[z]/h:0)*d;p?x[n[z]]={x:a,y:i+b,w:j,h:V,index:n[z]}:x[n[z]]={x:a+b,y:i,w:V,h:j,index:n[z]},b+=V}const k=t.slice(g),L=n.slice(g),P=s-h;p?Qe(k,L,P,a+j,i,r-j,l,x):Qe(k,L,P,a,i+j,r,l-j,x)}function mt(t,n,s,a,i,r){for(const l of n){const x=s[l.index];if(!x)continue;const o=Ls*r,p=l.x*r+o/2,d=l.y*r+o/2,h=l.w*r-o,w=l.h*r-o;if(h<=0||w<=0)continue;const g=Ce(x.typeNum),j=i!==null&&i!==l.index;t.save(),t.globalAlpha=j?.4:1;const b=Ds*r;t.beginPath(),t.moveTo(p+b,d),t.lineTo(p+h-b,d),t.quadraticCurveTo(p+h,d,p+h,d+b),t.lineTo(p+h,d+w-b),t.quadraticCurveTo(p+h,d+w,p+h-b,d+w),t.lineTo(p+b,d+w),t.quadraticCurveTo(p,d+w,p,d+w-b),t.lineTo(p,d+b),t.quadraticCurveTo(p,d,p+b,d),t.closePath(),t.fillStyle=g,t.fill(),t.strokeStyle="rgba(0,0,0,0.2)",t.lineWidth=1*r,t.stroke();const k=4*r,L=l.w>36&&l.h>20,P=l.w>36&&l.h>32;if(L){const z=11*r;if(P){const H=a>0?x.size/a*100:0;t.font=`500 ${8*r}px ${lt}`,t.fillStyle="rgba(0,0,0,0.6)",t.textBaseline="alphabetic",t.textAlign="left",t.fillText(`${H.toFixed(1)}%`,p+k,d+w-k-z)}t.font=`600 ${9*r}px ${lt}`,t.fillStyle="rgba(0,0,0,0.85)",t.textBaseline="alphabetic",t.textAlign="left",t.fillText(x.name,p+k,d+w-k)}t.restore()}}function Ps(t,n,s){for(const a of t)if(n>=a.x&&n<=a.x+a.w&&s>=a.y&&s<=a.y+a.h)return a.index;return null}function Os({data:t,total:n,color:s,position:a,containerWidth:i,isAirtime:r}){if(!t||!a)return null;const l=(t.value/n*100).toFixed(1),x=160,d=i-a.x=6e4?`${(t/6e4).toFixed(1)}m`:t>=1e3?`${(t/1e3).toFixed(1)}s`:`${Math.round(t)}ms`}function Fs({sortedTypes:t,aggregateShares:n,mode:s="share"}){var O,N,m;const[a,i]=c.useState(null),[r,l]=c.useState(null),[x,o]=c.useState(0),[p,d]=c.useState(null),h=c.useRef(null),w=c.useRef(null),g=c.useRef([]),j=s==="airtime",b=c.useMemo(()=>t.reduce((f,v)=>f+(j?v.totalAirtime:v.totalCount),0),[t,j]),k=c.useMemo(()=>t.map((f,v)=>({name:f.label,size:j?f.totalAirtime:f.totalCount,index:v,typeNum:f.typeNum,key:f.key})),[t,j]);c.useEffect(()=>{const f=w.current;if(!f)return;const v=f.parentElement;if(!v)return;const T=v.getBoundingClientRect(),B=T.width,R=T.height;if(B<=0||R<=0)return;const W=window.devicePixelRatio||1;f.width=Math.floor(B*W),f.height=Math.floor(R*W),f.style.width=`${B}px`,f.style.height=`${R}px`;const q=k.map(U=>U.size),te=ct(q,0,0,B,R);g.current=te;const J=f.getContext("2d");J&&(J.clearRect(0,0,f.width,f.height),mt(J,te,k,b,a,W))},[k,b,a]),c.useEffect(()=>{const f=h.current;if(!f)return;const v=new ResizeObserver(()=>{const T=w.current;if(!T)return;const B=f.getBoundingClientRect(),R=B.width,W=B.height;if(R<=0||W<=0)return;const q=window.devicePixelRatio||1;T.width=Math.floor(R*q),T.height=Math.floor(W*q),T.style.width=`${R}px`,T.style.height=`${W}px`;const te=k.map(D=>D.size),J=ct(te,0,0,R,W);g.current=J;const U=T.getContext("2d");U&&(U.clearRect(0,0,T.width,T.height),mt(U,J,k,b,a,q))});return v.observe(f),()=>v.disconnect()},[k,b]);const L=c.useCallback(f=>{const v=h.current;if(!v)return;const T=v.getBoundingClientRect(),B=f.clientX-T.left,R=f.clientY-T.top,W=Ps(g.current,B,R);i(W),W!==null?(o(T.width),l({x:B,y:R})):l(null)},[]),P=c.useCallback(()=>{i(null),l(null)},[]),z=c.useCallback(f=>{if(d(f),f){const v=k.findIndex(T=>T.key===f);i(v>=0?v:null)}else i(null)},[k]),H=a!==null?{name:((O=k[a])==null?void 0:O.name)??"",value:((N=k[a])==null?void 0:N.size)??0}:null,V=a!==null?Ce((m=k[a])==null?void 0:m.typeNum):"";return t.length===0||b===0?e.jsxs("div",{className:"h-full flex items-center justify-center text-fg-muted",children:[e.jsx(Se,{className:"w-6 h-6 mr-2 opacity-50"}),e.jsx("span",{children:"No packet type data available"})]}):e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsx("div",{className:"flex-1 min-h-0 relative",children:e.jsxs("div",{className:"absolute overflow-hidden radius-inner ring-1 ring-inset ring-edge-subtle bg-chart-inner",style:{left:Es,right:0,top:0,bottom:Ts},ref:h,onMouseMove:L,onMouseLeave:P,children:[e.jsx("canvas",{ref:w,className:"absolute inset-0",style:{cursor:"default"}}),e.jsx(Os,{data:H,total:b,color:V,position:r,containerWidth:x,isAirtime:j})]})}),e.jsx("div",{style:{minHeight:Is},children:e.jsx(st,{sortedTypes:t,highlightedType:p,onTypeHover:z,aggregateShares:n})})]})}const We=32,Ue=20,Hs=300;function be(t){return t>=1e9?`${(t/1e9).toFixed(1)} Gb`:t>=1e6?`${(t/1e6).toFixed(1)} Mb`:t>=1e3?`${(t/1e3).toFixed(1)} Kb`:`${t.toFixed(0)} B`}function Bs({packets:t,mode:n,startTs:s,endTs:a,radioConfig:i,bucketCount:r,lockedYMax:l,legendMinH:x}){const o=c.useMemo(()=>bt(),[]),p=o.blue,d=o.red,h=o.yellow,[w,g]=c.useState(null),{trendData:j,totals:b}=c.useMemo(()=>{if(t.length===0)return{trendData:[],totals:{rxBytes:0,txBytes:0,rxAirtime:0,txAirtime:0}};const N=a-s,m=Math.min(Math.ceil(N/Hs),r),f=N/m,v=[];let T=0,B=0,R=0,W=0;for(const $ of t){const y=$.timestamp;if(y=a)continue;const S=Je($),A=ve($,{spreadingFactor:i.sf,bandwidthHz:i.bw,codingRate:i.cr,preambleLength:i.preamble}),I={timestamp:y,rxAirtime:0,txAirtime:0,rxBytes:0,txBytes:0};$.transmitted?(I.txAirtime=A,I.txBytes=S,B+=S,W+=A):(I.rxAirtime=A,I.rxBytes=S,T+=S,R+=A),v.push(I)}v.sort(($,y)=>$.timestamp-y.timestamp);const q=new Float64Array(v.length+1),te=new Float64Array(v.length+1),J=new Float64Array(v.length+1),U=new Float64Array(v.length+1),D=new Float64Array(v.length);for(let $=0;${let y=0,S=D.length;for(;y>>1;D[A]<$?y=A+1:S=A}return y},se=[],re=f*1e3;for(let $=0;$0?Q:null,tx:ue>0?ue:null})}else{const Q=q[I]-q[A],ue=te[I]-te[A],pe=Q/re*100,fe=ue/re*100;se.push({timestamp:y,rx:pe>0?pe:null,tx:fe>0?fe:null})}}const ae=2/31;let ne=null;return{trendData:se.map($=>{const y=$.rx;return y!==null&&y>0&&(ne===null?ne=y:ne=ae*y+(1-ae)*ne),{...$,rxSmooth:ne!==null&&ne>0?ne:null}}),totals:{rxBytes:T,txBytes:B,rxAirtime:R,txAirtime:W}}},[t,s,a,r,n,i]),k=c.useMemo(()=>{if(j.length===0)return n==="share"?100:10;let N=0;for(const f of j){const v=f.rx??0,T=f.tx??0;v>N&&(N=v),T>N&&(N=T)}const m=N*1.1;return n==="share"?m<=100?100:m<=500?Math.ceil(m/100)*100:m<=1e3?Math.ceil(m/200)*200:m<=5e3?Math.ceil(m/500)*500:m<=1e4?Math.ceil(m/1e3)*1e3:Math.ceil(m/5e3)*5e3:Math.max(1,Math.ceil(m))},[j,n]),L=l??k,P=c.useMemo(()=>{if(w!==null&&j[w]){const N=j[w],m=N.rx??0,f=N.tx??0;return n==="share"?{rx:be(m),tx:be(f),total:be(m+f),isHovered:!0}:{rx:`${m.toFixed(2)}%`,tx:`${f.toFixed(2)}%`,total:`${(m+f).toFixed(2)}%`,isHovered:!0}}if(n==="share")return{rx:be(b.rxBytes),tx:be(b.txBytes),total:be(b.rxBytes+b.txBytes),isHovered:!1};{let N=0,m=0,f=0;for(const B of j)(B.rx!==null||B.tx!==null)&&(N+=B.rx??0,m+=B.tx??0,f++);const v=f>0?N/f:0,T=f>0?m/f:0;return{rx:`${v.toFixed(2)}%`,tx:`${T.toFixed(2)}%`,total:`${(v+T).toFixed(2)}%`,isHovered:!1}}},[w,j,b,n]),z=c.useMemo(()=>{const N=a-s,m=N/3600;return[0,.25,.5,.75,1].map(v=>{const T=s+N*v,B=new Date(T*1e3),R=B.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!1}),W=B.toLocaleDateString([],{weekday:"short"}),q=v===.25||v===.75;return{pct:v,label:m>=24?`${W} ${R}`:R,mobileHidden:q}})},[s,a]),H=c.useCallback(N=>{g(N)},[]);if(j.length===0)return e.jsxs("div",{className:"h-full flex items-center justify-center text-fg-muted",children:[e.jsx(Se,{className:"w-6 h-6 mr-2 opacity-50"}),e.jsx("span",{children:"No packet data available"})]});const V=c.useMemo(()=>n==="airtime"?L<=5?1:L<=10?2:L<=20?5:Math.ceil(L/5):L<=100?25:L<=500?100:L<=1e3?200:L<=5e3?1e3:L<=1e4?2e3:Math.ceil(L/5e3)*1e3,[L,n]),O=c.useMemo(()=>{const N=[];for(let m=0;m<=L;m+=V){const f=(1-m/L)*100;let v;n==="airtime"?v=`${m}%`:m>=1e6?v=`${(m/1e6).toFixed(1)}M`:m>=1e3?v=`${(m/1e3).toFixed(0)}K`:v=`${m}`,N.push({pos:f,label:v})}return N},[L,V,n]);return e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsxs("div",{className:"flex-1 min-h-0 relative",children:[e.jsx("div",{className:"absolute top-0 left-0 flex flex-col justify-between",style:{width:We,bottom:Ue},children:O.map((N,m)=>e.jsx("span",{className:"type-data-xs text-fg-secondary text-right pr-1.5",style:{position:"absolute",top:`${N.pos}%`,transform:m===0?"translateY(-100%)":m===O.length-1?"none":"translateY(-50%)",right:0},children:N.label},m))}),e.jsx("div",{className:"absolute overflow-hidden radius-inner ring-1 ring-inset ring-edge-subtle bg-chart-inner",style:{left:We,right:0,top:0,bottom:Ue},children:e.jsx(At,{data:j,yAxisMode:n==="share"?"share":"airtime",yMax:L,onHover:H,startTs:s,endTs:a,externalAxes:!0})}),e.jsx("div",{className:"absolute left-0 right-0 bottom-0 flex items-center pointer-events-none",style:{left:We,height:Ue,paddingTop:4},children:z.map((N,m)=>e.jsx("span",{className:`absolute type-data-xs text-fg-muted/60 tabular-nums ${N.mobileHidden?"hidden sm:inline":""}`,style:{left:`${N.pct*100}%`,transform:N.pct===0?"translateX(0)":N.pct===1?"translateX(-100%)":"translateX(-50%)"},children:N.label},m))})]}),e.jsxs("div",{className:"flex items-end justify-between pb-1",style:{minHeight:x},children:[e.jsxs("div",{className:"flex items-center gap-3 sm:gap-5 type-data-sm pl-2 sm:pl-11",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("div",{className:"w-4 sm:w-5 h-[2px] rounded-full",style:{backgroundColor:p}}),e.jsx("span",{className:"text-fg-secondary",children:"RX"})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("div",{className:"w-4 sm:w-5 h-[2px] rounded-full",style:{backgroundColor:d}}),e.jsx("span",{className:"text-fg-secondary",children:"TX"})]}),e.jsxs("div",{className:"hidden sm:flex items-center gap-1.5",children:[e.jsx("div",{className:"w-5 h-[2px] rounded-full",style:{backgroundColor:h}}),e.jsx("span",{className:"text-fg-secondary",children:"Avg"})]})]}),e.jsxs("div",{className:"flex flex-wrap gap-4 sm:gap-8",children:[e.jsxs("div",{className:"flex items-end gap-2",children:[e.jsx("div",{className:"type-data-xl text-fg-primary",children:P.rx}),e.jsx(Fe,{color:"zinc",className:"mb-0.5 sm:mb-1",children:"RX"})]}),e.jsxs("div",{className:"flex items-end gap-2",children:[e.jsx("div",{className:"type-data-xl text-fg-primary",children:P.tx}),e.jsx(Fe,{color:"zinc",className:"mb-0.5 sm:mb-1",children:"TX"})]})]})]})]})}const ut=_t;class $s{constructor(){xe(this,"worker",null);xe(this,"listeners",new Set);xe(this,"currentResult",null);xe(this,"isComputing",!1);xe(this,"debounceTimer",null);xe(this,"debounceMs",250);xe(this,"lastCacheKey",null)}ensureWorker(){if(this.worker)return this.worker;if(typeof window>"u")return null;try{this.worker=new Worker(new URL("/assets/bucketing.worker-D2Fn452R.js",import.meta.url),{type:"module"}),this.worker.onmessage=n=>{this.handleWorkerMessage(n.data)},this.worker.onerror=n=>{console.error("[BucketingService] Worker error:",n),this.isComputing=!1,this.notifyListeners()}}catch(n){console.error("[BucketingService] Failed to initialize worker:",n)}return this.worker}handleWorkerMessage(n){if(this.isComputing=!1,n.type==="error"){this.currentResult=null,this.notifyListeners();return}const s=n.payload;this.currentResult={points:s.points,rawValues:s.rawValues,packetTypes:s.packetTypes,timestamps:s.timestamps,count:s.count,minTime:s.minTime,maxTime:s.maxTime,minValue:s.minValue,maxValue:s.maxValue,rawMinValue:s.rawMinValue,rawMaxValue:s.rawMaxValue,unit:"%",stats:{p5:s.p5,p50:s.p50,p95:s.p95,uniqueValues:s.uniqueValues,topValues:s.topValues}},this.notifyListeners()}notifyListeners(){for(const n of this.listeners)try{n(this.currentResult,this.isComputing)}catch(s){console.error("[BucketingService] Listener error:",s)}}isCacheHit(n){return!this.lastCacheKey||!this.currentResult?!1:this.lastCacheKey.startTs===n.startTs&&this.lastCacheKey.endTs===n.endTs&&this.lastCacheKey.mode===n.mode&&this.lastCacheKey.packetCount===n.packetCount}compute(n,s,a,i,r){if(n.length===0||!r){this.currentResult=null,this.notifyListeners();return}const l={startTs:s,endTs:a,mode:i,packetCount:n.length};this.isCacheHit(l)||(this.debounceTimer&&clearTimeout(this.debounceTimer),this.debounceTimer=setTimeout(()=>{this.debounceTimer=null,this.computeInternal(n,s,a,i,r,l)},this.debounceMs))}computeInternal(n,s,a,i,r,l){const x=this.ensureWorker();if(!x)return;const o=n.length,p=new Float64Array(o),d=new Float64Array(o),h=new Uint16Array(o),w=new Uint8Array(o),g={spreadingFactor:r.sf,bandwidthHz:r.bw,codingRate:r.cr,preambleLength:r.preamble};for(let b=0;b{this.listeners.delete(n)}}clear(){this.currentResult=null,this.lastCacheKey=null,this.notifyListeners()}terminate(){this.debounceTimer&&clearTimeout(this.debounceTimer),this.worker&&(this.worker.terminate(),this.worker=null),this.listeners.clear()}}const Ge=new $s;function zs(t,n,s,a,i){const[r,l]=c.useState(()=>Ge.getResult());return c.useEffect(()=>Ge.subscribe(x=>{l(x)}),[]),c.useEffect(()=>{Ge.compute(t,n,s,a,i)},[t,n,s,a,i]),r}function Ws({mode:t,packets:n,startTs:s,endTs:a,radioConfig:i,sortedTypes:r,aggregateShares:l,noiseFloorAnomalies:x,showNoiseFloorOverlay:o,overlayOpacity:p=.5,startLabel:d,endLabel:h,lockedYMax:w,legendMinH:g,dotSize:j,dotOpacity:b}){const[k,L]=c.useState(null),[P,z]=c.useState(null),H=c.useMemo(()=>(a-s)/3600,[s,a]),V=c.useCallback(U=>{z(U)},[]),N=zs(n,s,a,t==="share"?"share":"airtime",i),[m,f]=c.useState(null),v=c.useCallback((U,D)=>{L(U),f(D??null)},[]),T=c.useMemo(()=>{if(m===null||!N||N.count===0)return null;const U=s+m*(a-s);let D;H>=168?D=75:H>=72?D=35:H>=24?D=15:H>=3?D=10:D=5;const Y=D*60/2;return{start:U-Y,end:U+Y}},[m,N,s,a,H]),B=c.useMemo(()=>T?new Date((T.start+T.end)/2*1e3).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!1}):null,[T]),R=c.useMemo(()=>{if(k===null||!T)return null;const U=B??"",{start:D,end:Y}=T,se=n.filter(y=>y.timestamp>=D&&y.timestamp({key:y.key,label:y.label,value:0,color:ut(y.typeNum)}))};const re=new Map,ae=new Map;let ne=0,ce=0;for(const y of se){const A=`TYPE_${y.type??y.payload_type??-1}`;if(re.set(A,(re.get(A)??0)+1),ne++,i){const I=ve(y,{spreadingFactor:i.sf,bandwidthHz:i.bw,codingRate:i.cr,preambleLength:i.preamble});ae.set(A,(ae.get(A)??0)+I),ce+=I}}const $=r.map(y=>{let S;return t==="airtime"?S=ce>0?(ae.get(y.key)??0)/ce:0:S=ne>0?(re.get(y.key)??0)/ne:0,{key:y.key,label:y.label,value:S,color:ut(y.typeNum)}});return{timestamp:(D+Y)/2,timeLabel:U,items:$}},[k,T,B,n,r,t,i]),W=t==="share",q=w??(N==null?void 0:N.maxValue)??(W?200:10),te=c.useMemo(()=>{if(!W)return 5;const U=[10,20,25,50,100,200,250,500,1e3],D=q/4.5;for(const Y of U)if(Y>=D)return Y;return q>5e3?Math.ceil(D/1e3)*1e3:Math.ceil(D/100)*100},[q,W]),J=c.useMemo(()=>{const U=[];for(let D=0;D<=q;D+=te){const Y=(1-D/q)*100;U.push({pos:Y,label:W?`${D}B`:`${D}%`})}return U},[q,te,W]);return!N||N.count===0?e.jsxs("div",{className:"h-full flex items-center justify-center text-fg-muted",children:[e.jsx(Se,{className:"w-6 h-6 mr-2 opacity-50"}),e.jsx("span",{children:"No packet data available"})]}):e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsxs("div",{className:"flex-1 min-h-0 relative",children:[e.jsx("div",{className:"absolute top-0 left-0 flex flex-col justify-between",style:{width:32,bottom:20},children:J.map((U,D)=>e.jsx("span",{className:"type-data-xs text-fg-secondary text-right pr-1.5",style:{position:"absolute",top:`${U.pos}%`,transform:D===0?"translateY(-100%)":D===J.length-1?"none":"translateY(-50%)",right:0},children:U.label},D))}),e.jsxs("div",{className:"absolute overflow-hidden radius-inner ring-1 ring-inset ring-edge-subtle bg-chart-inner",style:{left:32,right:0,top:0,bottom:20},children:[e.jsx(Rt,{scatterData:N,yAxisMode:t==="share"?"share":"airtime",onHover:v,noiseFloorAnomalies:x,showNoiseFloorOverlay:o,overlayOpacity:p,highlightedType:P,timeRangeHours:H,yAxisMaxOverride:w,dotSize:j,dotOpacity:b,startTs:s,endTs:a,externalAxes:!0}),B&&e.jsx("div",{className:"absolute top-1 right-1 px-2 py-0.5 bg-elevated/90 rounded type-data-xs text-sys-indigo pointer-events-none z-10",children:B})]}),d&&h&&e.jsxs("div",{className:"absolute left-0 right-0 bottom-0 flex justify-between pointer-events-none type-data-xs text-fg-muted/60",style:{left:32,height:20,paddingTop:4},children:[e.jsx("span",{children:d}),e.jsx("span",{children:h})]})]}),e.jsx("div",{style:{minHeight:g},children:e.jsx(st,{sortedTypes:r,highlightedType:P,onTypeHover:V,aggregateShares:l,hoverData:R})})]})}function Us({mode:t,onChange:n}){return e.jsxs("div",{className:"toggle-group toggle-group-sm",children:[e.jsx("button",{onClick:()=>n("share"),className:`toggle-group-item ${t==="share"?"active":""}`,children:"Total"}),e.jsx("button",{onClick:()=>n("airtime"),className:`toggle-group-item ${t==="airtime"?"active":""}`,children:"Airtime"})]})}function Gs({smoothing:t,onChange:n}){return e.jsxs("div",{className:"toggle-group toggle-group-sm",children:[e.jsx("button",{onClick:()=>n("stats"),className:`toggle-group-item ${t==="stats"?"active":""}`,title:"Statistics view (scatter plot)",children:e.jsx(ws,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:()=>n("trend"),className:`toggle-group-item ${t==="trend"?"active":""}`,title:"Trend line chart",children:e.jsx(js,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:()=>n("ema"),className:`toggle-group-item ${t==="ema"?"active":""}`,title:"Stacked area (moderate smoothing)",children:e.jsx(Se,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:()=>n("ultra"),className:`toggle-group-item ${t==="ultra"?"active":""}`,title:"Stacked area (heavy smoothing)",children:e.jsx(Cs,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:()=>n("mosaic"),className:`toggle-group-item ${t==="mosaic"?"active":""}`,title:"Mosaic view (treemap)",children:e.jsx(Ss,{className:"w-3.5 h-3.5"})})]})}function qs({enabled:t,onChange:n,anomalyCount:s=0,showTuning:a=!1,onTuningChange:i}){return e.jsxs("div",{className:"relative inline-flex items-center gap-1",children:[t&&i&&e.jsx("button",{onClick:()=>i(!a),className:`toggle-group toggle-group-sm ${a?"active":""}`,title:a?"Hide tuning panel":"Show tuning panel",children:e.jsx("span",{className:`toggle-group-item ${a?"active":""}`,children:e.jsx(gs,{className:"w-3.5 h-3.5"})})}),e.jsx("button",{onClick:()=>n(!t),className:`toggle-group toggle-group-sm ${t?"active":""}`,title:t?"Hide noise floor anomalies":"Show noise floor anomalies",children:e.jsx("span",{className:`toggle-group-item ${t?"active":""}`,children:e.jsx(cs,{className:"w-3.5 h-3.5"})})}),s>0&&e.jsx("span",{className:"absolute -top-2 -right-2 min-w-[18px] h-[18px] px-1 rounded-full bg-sys-red text-white text-xs font-bold flex items-center justify-center pointer-events-none z-10",children:s>99?"99+":s})]})}const Nt=[{target:"PacketAnalyzer",fn:"type",minStage:1},{target:"PacketAnalyzer",fn:"airtime",minStage:1,when:ss}];tt(Nt);const ht=360,Vs=500,Ks={sf:10,bw:25e4,cr:5,preamble:8},qe=32;function xt(t,n){const s=new Date(t*1e3),a=l=>l.toString().padStart(2,"0"),i=`${a(s.getHours())}:${a(s.getMinutes())}`;return n<24?i:`${["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][s.getMonth()]} ${s.getDate()} ${i}`}function Ys(t){return yt[t]??`TYPE_${t.toString(16).toUpperCase()}`}function Xs(t,n){const s=new Map;for(const i of t){const r=i.type??i.payload_type??-1,l=ve(i,{spreadingFactor:n.sf,bandwidthHz:n.bw,codingRate:n.cr,preambleLength:n.preamble}),x=s.get(r)??{count:0,airtime:0};s.set(r,{count:x.count+1,airtime:x.airtime+l})}const a=[];for(const[i,r]of s)a.push({typeNum:i,key:`TYPE_${i}`,label:Ys(i),totalCount:r.count,totalAirtime:r.airtime});return a.sort((i,r)=>r.totalCount-i.totalCount)}function Zs(t,n,s,a,i,r,l=0){const x=s-n,o=x/a,p=o*1e3,d=x/3600,h=n-l*o,w=s+l*o,g=a+2*l,j=[];for(let b=0;b=24?L.toLocaleDateString([],{weekday:"short",hour:"2-digit",minute:"2-digit",hour12:!1}):L.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!1}),z={timestamp:k,time:P,counts:{},shares:{},airtimes:{},total:0,totalAirtime:0,bucketDurationMs:p};for(const H of r)z.counts[H.key]=0,z.airtimes[H.key]=0;j.push(z)}for(const b of t){const k=b.timestamp;if(k=w)continue;const L=Math.min(Math.floor((k-h)/o),g-1),P=`TYPE_${b.type??b.payload_type??-1}`;j[L].counts[P]=(j[L].counts[P]??0)+1,j[L].total++;const z=ve(b,{spreadingFactor:i.sf,bandwidthHz:i.bw,codingRate:i.cr,preambleLength:i.preamble});j[L].airtimes[P]=(j[L].airtimes[P]??0)+z,j[L].totalAirtime+=z}for(const b of j)for(const k of r)b.shares[k.key]=b.total>0?b.counts[k.key]/b.total*100:0;return{buckets:j,visibleStart:l,visibleEnd:l+a}}function Qs(t,n){const s=t.length;if(s===0)return[];if(n<.5)return[...t];const a=Math.sqrt(12*n*n/3+1);let i=Math.floor(a);i%2===0&&i--;const r=i+2,l=(12*n*n-3*i*i-12*i-9)/(-4*i-4),x=Math.round(l),o=[x>0?i:r,x>1?i:r,x>2?i:r];let p=new Float32Array(t);const d=new Float32Array(s);for(const h of o){const w=(h-1)/2;Js(p,d,s,w);const g=p;p=d,d.set(g)}return Array.from(p)}function Js(t,n,s,a){const i=a*2+1;let r=0;for(let l=0;l<=a;l++)r+=t[Math.min(l,s-1)];for(let l=0;l=0&&(r-=t[o],l--),pnew Array(d).fill(0));for(let O=0;O0)for(let m=0;m0)for(let f=0;f0?L=j.map(O=>Qs(O,b)):L=j.map(O=>en(O,k));for(let O=0;O0){const m=1/N;for(let f=0;fht?Math.ceil(w/ht):1,z=Math.ceil(w/P),H=[];for(let O=0;O0){const R=1/T;for(let W=0;W=s)continue;const w=Math.min(Math.floor((h-n)/300),x-1);o[w]+=ve(d,{spreadingFactor:i.sf,bandwidthHz:i.bw,codingRate:i.cr,preambleLength:i.preamble})}let p=0;for(let d=0;dp&&(p=h)}return Math.max(1,Math.ceil(p*1.1))}else{let o=0;for(const p of t){const d=p.timestamp;if(d=s)continue;const h=Je(p);h>o&&(o=h)}return o<=200?200:Math.ceil(o*1.1/50)*50}}function rn({packets:t,allPackets:n,startTs:s,endTs:a,parentStartTs:i,parentEndTs:r,bucketCount:l,radioConfig:x=Ks,mode:o="share",smoothing:p="stats",noiseFloorAnomalies:d=null,showNoiseFloorOverlay:h=!1,overlayOpacity:w=.5,dotSize:g,dotOpacity:j}){et(Nt);const b=Lt(),[k,L]=c.useState(null),[P,z]=c.useState(null),[H,V]=c.useState([]),O=c.useRef(null),N=c.useRef(0);c.useEffect(()=>{const y=Math.abs(t.length-N.current);if(y===0&&H.length>0)return;O.current&&clearTimeout(O.current);const S=y>100?50:Vs;return O.current=setTimeout(()=>{N.current=t.length,V(t)},S),()=>{O.current&&clearTimeout(O.current)}},[t,H.length]);const m=c.useMemo(()=>Xs(H,x),[H,x]),f=c.useMemo(()=>{if(p!=="ema"&&p!=="ultra")return 0;const S=(a-s)/l,{handleSize:A}=vt(p,S,l);return A},[p,s,a,l]),v=c.useMemo(()=>Zs(H,s,a,l,x,m,f),[H,s,a,l,x,m,f]),T=c.useMemo(()=>m.reduce((y,S)=>y+S.totalCount,0),[m]),B=c.useMemo(()=>m.reduce((y,S)=>y+S.totalAirtime,0),[m]),{sortedTypes:R,aggregateShares:W}=c.useMemo(()=>{const y=new Map,S=o==="share"?T:B;if(S>0)for(const I of m){const Q=o==="share"?I.totalCount:I.totalAirtime;y.set(I.key,Q/S)}return{sortedTypes:[...m].sort((I,Q)=>(y.get(Q.key)??0)-(y.get(I.key)??0)),aggregateShares:y}},[m,T,B,o]),q=c.useMemo(()=>nn(v,o,R,p,s,a,l),[v,o,R,p,s,a,l]),te=c.useCallback(y=>L(y),[]),J=c.useCallback(y=>z(y),[]),U=c.useCallback(y=>L(y),[]),D=c.useMemo(()=>{if(P===null||!q[P])return null;const y=q[P];return{timestamp:y.timestamp,timeLabel:y.time,items:R.map(S=>({key:S.key,label:S.label,value:y[S.key]??0,color:Ce(S.typeNum)}))}},[P,q,R]),Y=c.useMemo(()=>{const y=q.map(A=>A.timestamp),S=R.map(A=>({key:A.key,label:A.label,color:Ce(A.typeNum),values:q.map(I=>I[A.key]??0)}));return{timestamps:y,series:S}},[q,R]),se=null,re=n&&i!==void 0&&r!==void 0&&(s!==i||a!==r),ae=c.useMemo(()=>{if(!(!re||!n||i===void 0||r===void 0))return an(n,i,r,o,x)},[re,n,i,r,o,x]);if(H.length===0)return t.length===0?e.jsxs("div",{className:"h-full flex items-center justify-center text-fg-muted",children:[e.jsx(Se,{className:"w-6 h-6 mr-2 opacity-50"}),e.jsx("span",{children:"No packet data available"})]}):null;if(p==="mosaic")return e.jsx(Fs,{sortedTypes:R,aggregateShares:W,mode:o});const ne=(a-s)/3600,ce=xt(s,ne),$=xt(a,ne);return p==="stats"?e.jsx(Ws,{mode:o,packets:H,startTs:s,endTs:a,radioConfig:x,sortedTypes:R,aggregateShares:W,noiseFloorAnomalies:d,showNoiseFloorOverlay:h,overlayOpacity:w,startLabel:ce,endLabel:$,lockedYMax:ae,legendMinH:Ve,dotSize:g,dotOpacity:j}):p==="trend"?e.jsx(Bs,{packets:H,mode:o,startTs:s,endTs:a,radioConfig:x,bucketCount:l,lockedYMax:ae,legendMinH:Ve}):e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsxs("div",{className:"flex-1 min-h-0 relative",children:[e.jsx("div",{className:"absolute top-0 left-0 flex flex-col justify-between",style:{width:qe,bottom:20},children:[0,20,40,60,80,100].map((y,S,A)=>e.jsxs("span",{className:"type-data-xs text-fg-secondary text-right pr-1.5",style:{position:"absolute",top:`${(1-y/100)*100}%`,transform:S===0?"translateY(-100%)":S===A.length-1?"none":"translateY(-50%)",right:0},children:[y,"%"]},y))}),e.jsx("div",{className:"absolute overflow-hidden radius-inner ring-1 ring-inset ring-edge-subtle bg-chart-inner",style:{left:qe,right:0,top:0,bottom:20},children:e.jsx(Dt,{timestamps:Y.timestamps,series:Y.series,highlightedKey:k,cursorColor:b.cursor,onHover:J,onSeriesHover:U,overlayLine:se,startTs:s,endTs:a,externalAxes:!0})}),e.jsxs("div",{className:"absolute left-0 right-0 bottom-0 flex justify-between pointer-events-none type-data-xs text-fg-muted/60",style:{left:qe,height:20,paddingTop:4},children:[e.jsx("span",{children:ce}),e.jsx("span",{children:$})]})]}),e.jsx("div",{style:{minHeight:Ve},children:e.jsx(st,{sortedTypes:R,highlightedType:k,onTypeHover:te,aggregateShares:W,hoverData:D})})]})}const on=c.memo(rn),Ke={ZOOM_DURATION:400,BLINK_DURATION:600},oe={PADDING:6,DOT_RADIUS:5,DOT_RADIUS_HOVERED:7,LOCAL_DOT_RADIUS:5,CARDINAL_FONT_SIZE:10,INTERCARDINAL_FONT_SIZE:9,LABEL_INSET:8,DATA_HEADROOM:1.08},ln={"1x":1,"2x":2,"4x":4,"8x":8,"16x":16,"36x":36},cn=[1,5,10,25,50,100,150],mn=22.5,St=mn*Math.PI/180,pt=Math.sin(St),ft=Math.cos(St);function dn(t,n,s,a){const i=Math.PI/180,r=(a-n)*i,l=t*i,x=s*i,o=Math.sin(r)*Math.cos(x),p=Math.cos(l)*Math.sin(x)-Math.sin(l)*Math.cos(x)*Math.cos(r);return(Math.atan2(o,p)*180/Math.PI+360)%360}function un(t,n,s,a){const r=Math.PI/180,l=(s-t)*r,x=(a-n)*r,o=Math.sin(l/2)**2+Math.cos(t*r)*Math.cos(s*r)*Math.sin(x/2)**2;return 6371*2*Math.atan2(Math.sqrt(o),Math.sqrt(1-o))}const hn=[{min:10,label:"Excellent"},{min:7,label:"Very Good"},{min:4,label:"Good"},{min:1,label:"Fair+"},{min:-2,label:"Fair"},{min:-5,label:"Fair-"},{min:-8,label:"Poor"},{min:-11,label:"Bad"},{min:-1/0,label:"Critical"}];function xn(t){var n;return((n=hn.find(s=>t>=s.min))==null?void 0:n.label)??"Critical"}function gt(t,n,s){const a=Ft(t,s);return n[a]||"#808080"}function pn({neighbors:t,quickNeighbors:n,localLat:s,localLon:a,onStatsChange:i,title:r,badge:l,stats:x}){const[o,p]=c.useState(null),[d,h]=c.useState(new Set),[w,g]=c.useState({width:0,height:0}),[j,b]=c.useState("1x"),[k,L]=c.useState(1),P=c.useRef(null),z=c.useRef({}),H=c.useRef(null),V=c.useRef(k);V.current=k;const O=Et(),N=Tt(),m=It(),f=Pt(),v=bt(),T=Ot(),B=f?m.primary:m.secondary,R=f?.15:.4,W=f?.08:.25,q=f?v.blue:m.primary;c.useEffect(()=>{const u=H.current;if(!u)return;const E=new ResizeObserver(_=>{for(const F of _){const{width:X,height:K}=F.contentRect;X>0&&K>0&&g({width:X,height:K})}});E.observe(u);const C=u.getBoundingClientRect();return C.width>0&&C.height>0&&g({width:C.width,height:C.height}),()=>E.disconnect()},[]);const te=c.useMemo(()=>{const u=new Set;if(n)for(const E of n)u.add(E.hash);return u},[n]),J=c.useMemo(()=>{const u=new Map;if(n)for(const E of n)u.set(E.hash,{snr:E.avgSnr,rssi:E.avgRssi});return u},[n]),{processedNeighbors:U,maxDistance:D,totalNeighbors:Y,zeroHopCount:se}=c.useMemo(()=>{const u=[];for(const[_,F]of Object.entries(t)){if(!F.latitude||!F.longitude||F.latitude===0||F.longitude===0||!te.has(_))continue;const K=dn(s,a,F.latitude,F.longitude),ee=un(s,a,F.latitude,F.longitude),Z=J.get(_);u.push({hash:_.slice(0,8),name:F.node_name||F.name||"Unknown",snr:(Z==null?void 0:Z.snr)??F.snr??null,rssi:(Z==null?void 0:Z.rssi)??F.rssi??null,bearing:K,distance:ee,normalizedDistance:0,lastSeen:F.last_seen,isZeroHop:!0})}const C=(u.length>0?Math.max(...u.map(_=>_.distance)):0)*oe.DATA_HEADROOM;return u.sort((_,F)=>(_.snr??-1/0)-(F.snr??-1/0)),{processedNeighbors:u,maxDistance:C,totalNeighbors:u.length,zeroHopCount:u.length}},[t,s,a,te,J]);c.useEffect(()=>{i==null||i({zeroHopCount:se,totalCount:Y,maxDistanceKm:D})},[se,Y,D]),c.useEffect(()=>{const u=ln[j],E=V.current;P.current&&cancelAnimationFrame(P.current);const C=performance.now(),_=F=>{const X=F-C,K=Math.min(X/Ke.ZOOM_DURATION,1),ee=ns(K),Z=E+(u-E)*ee;L(Z),K<1?P.current=requestAnimationFrame(_):P.current=null};return P.current=requestAnimationFrame(_),()=>{P.current&&cancelAnimationFrame(P.current)}},[j]);const re=D/k,ae=c.useMemo(()=>cn.filter(u=>u<=re*1.1),[re]);c.useEffect(()=>{const u=[];for(const C of U){const _=z.current[C.hash];_!==void 0&&_!==C.lastSeen&&u.push(C.hash),z.current[C.hash]=C.lastSeen}if(u.length===0)return;queueMicrotask(()=>{h(C=>new Set([...C,...u]))});const E=setTimeout(()=>{h(C=>{const _=new Set(C);return u.forEach(F=>_.delete(F)),_})},Ke.BLINK_DURATION);return()=>clearTimeout(E)},[U]);const ne=s!==0&&a!==0,ce=c.useMemo(()=>{const{width:u,height:E}=w,C=u/2,_=E/2,F=Math.min(u,E),X=Math.max(10,F/2-oe.PADDING),K=Math.max(10,X-oe.LABEL_INSET);return{width:u,height:E,centerX:C,centerY:_,radius:K,labelRadius:X}},[w]),{width:$,height:y,centerX:S,centerY:A,radius:I,labelRadius:Q}=ce,ue=c.useId(),pe=c.useCallback((u,E)=>{const C=u*Math.PI/180;return{x:S+I*E*Math.sin(C),y:A-I*E*Math.cos(C)}},[S,A,I]),fe=c.useCallback(u=>{const C={N:0,NE:45,E:90,SE:135,S:180,SW:225,W:270,NW:315}[u]*Math.PI/180;return{x:S+Q*Math.sin(C),y:A-Q*Math.cos(C)}},[S,A,Q]),_e=c.useCallback(u=>{p(u)},[]),Re=c.useCallback(u=>{b(u)},[]),Le=c.useCallback(u=>D<=0?0:u/D*k,[D,k]),De=u=>`${u}km`,ke=28,Ee=c.useMemo(()=>{const u=[{x:S,y:A-Q},{x:S+Q*Math.SQRT1_2,y:A-Q*Math.SQRT1_2}],E=ae.map(_=>{const F=_/D*k,X=S+I*F*pt,K=A-I*F*ft;return{km:_,scale:F,lx:X,ly:K}}).filter(_=>_.scale<=1.05&&_.scale>=.02).sort((_,F)=>F.km-_.km),C=[];for(const _ of E){const F=C.some(K=>{const ee=K.lx-_.lx,Z=K.ly-_.ly;return Math.sqrt(ee*ee+Z*Z){const ee=K.x-_.lx,Z=K.y-_.ly;return Math.sqrt(ee*ee+Z*Z)0&&w.height>0;return ne?Y===0?e.jsxs("div",{ref:H,className:"flex flex-col items-center justify-center h-full text-fg-secondary",children:[e.jsx(ze,{className:"w-8 h-8 mb-2 opacity-50"}),e.jsx("p",{children:"No nodes with location data"})]}):e.jsxs("div",{className:"flex h-full w-full overflow-visible",children:[e.jsxs("div",{ref:H,className:"relative flex-1 min-w-0 h-full overflow-visible -ml-4 sm:-ml-5",children:[Te&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"absolute depth-raised",style:{left:S-I-oe.LABEL_INSET-4,top:A-I-oe.LABEL_INSET-4,width:(I+oe.LABEL_INSET)*2+8,height:(I+oe.LABEL_INSET)*2+8,borderRadius:"50%",padding:4,boxSizing:"border-box",backgroundColor:f?"var(--zinc-925)":"var(--zinc-75)"}}),e.jsxs("svg",{width:$,height:y,className:"absolute inset-0 z-0",style:{overflow:"visible"},children:[e.jsxs("defs",{children:[e.jsx("style",{children:` - @keyframes neighbor-blink-scale { - 0%, 100% { - transform: scale(1); - opacity: 0; - } - 50% { - transform: scale(1.3); - opacity: 0.8; - } - } - .neighbor-blink-ring { - transform-origin: center; - animation: neighbor-blink-scale ${Ke.BLINK_DURATION}ms ease-out forwards; - } - `}),e.jsx("clipPath",{id:ue,children:e.jsx("circle",{cx:S,cy:A,r:I})})]}),(()=>{const u=I+oe.LABEL_INSET+12,E=f?"rgba(255, 255, 255, 0.12)":"rgba(0, 0, 0, 0.15)",C=f?"rgba(59, 130, 246, 0.4)":"rgba(59, 130, 246, 0.5)",_=6,F=16,X=4,K=[0,90,180,270],ee=[45,135,225,315];return e.jsxs("g",{className:"radar-frame","aria-hidden":"true",children:[e.jsx("circle",{cx:S,cy:A,r:u,fill:"none",stroke:E,strokeWidth:1,strokeDasharray:"2 6"}),ee.map(Z=>{const ie=Z*Math.PI/180,me=Math.cos(ie),de=Math.sin(ie),he=u+X,M=u+X+F,G=S+he*de,ye=A-he*me,Ie=S+M*de,He=A-M*me;return e.jsxs("g",{children:[e.jsx("line",{x1:G,y1:ye,x2:Ie,y2:He,stroke:C,strokeWidth:1}),e.jsx("line",{x1:Ie-4*me,y1:He-4*de,x2:Ie+4*me,y2:He+4*de,stroke:C,strokeWidth:1})]},`corner-${Z}`)}),K.map(Z=>{const ie=Z*Math.PI/180,me=S+(u-_)*Math.sin(ie),de=A-(u-_)*Math.cos(ie),he=S+(u+2)*Math.sin(ie),M=A-(u+2)*Math.cos(ie);return e.jsx("line",{x1:me,y1:de,x2:he,y2:M,stroke:E,strokeWidth:1},`tick-cardinal-${Z}`)}),ee.map(Z=>{const ie=Z*Math.PI/180,me=S+(u-4)*Math.sin(ie),de=A-(u-4)*Math.cos(ie),he=S+(u+1)*Math.sin(ie),M=A-(u+1)*Math.cos(ie);return e.jsx("line",{x1:me,y1:de,x2:he,y2:M,stroke:E,strokeWidth:1},`tick-intercardinal-${Z}`)})]})})(),(()=>{const E=[(I+oe.LABEL_INSET+4)/I,...ae.map(C=>Le(C)).filter(C=>C>.02&&C<=1.05).sort((C,_)=>_-C),0];return E.slice(0,-1).map((C,_)=>{const F=E[_+1],X=I*C,K=I*F,ee=X-K;return ee<=0||_%2!==0?null:e.jsx("circle",{cx:S,cy:A,r:(X+K)/2,fill:"none",stroke:"var(--subtle-fill)",strokeWidth:ee,opacity:.8},`band-${_}`)})})(),ae.map(u=>{const E=Le(u);if(E>1.05||E<.02)return null;const C=Ee.some(X=>X.km===u),_=S+I*E*pt,F=A-I*E*ft;return e.jsxs("g",{children:[e.jsx("circle",{cx:S,cy:A,r:I*E,fill:"none",stroke:B,strokeOpacity:R,strokeWidth:1}),C&&e.jsx("text",{x:_+4,y:F-2,textAnchor:"start",dominantBaseline:"auto",fill:m.secondary,fontSize:10,fontFamily:Be,children:De(u)})]},`ring-${u}`)}),["N","E","S","W"].map(u=>{const C={N:0,E:90,S:180,W:270}[u]*Math.PI/180;return e.jsx("line",{x1:S,y1:A,x2:S+I*Math.sin(C),y2:A-I*Math.cos(C),stroke:B,strokeOpacity:R,strokeWidth:1,strokeDasharray:"4 4"},u)}),["NE","SE","SW","NW"].map(u=>{const C={NE:45,SE:135,SW:225,NW:315}[u]*Math.PI/180;return e.jsx("line",{x1:S,y1:A,x2:S+I*Math.sin(C),y2:A-I*Math.cos(C),stroke:B,strokeOpacity:W,strokeWidth:1,strokeDasharray:"4 4"},`diag-${u}`)}),["N","E","S","W"].map(u=>{const E=fe(u),C=u==="E"?"end":u==="W"?"start":"middle",_=u==="N"?"hanging":u==="S"?"auto":"middle";return e.jsx("text",{x:E.x,y:E.y,textAnchor:C,dominantBaseline:_,fill:q,fontSize:oe.CARDINAL_FONT_SIZE,fontWeight:700,fontFamily:Be,"aria-hidden":"true",children:u},u)}),["NE","SE","SW","NW"].map(u=>{const E=fe(u),C=u==="NE"||u==="SE"?"end":"start",_=u==="NE"||u==="NW"?"hanging":"auto";return e.jsx("text",{x:E.x,y:E.y,textAnchor:C,dominantBaseline:_,fill:q,fontSize:oe.INTERCARDINAL_FONT_SIZE,fontWeight:600,fontFamily:Be,"aria-hidden":"true",children:u},u)}),e.jsx("circle",{cx:S,cy:A,r:oe.LOCAL_DOT_RADIUS,fill:N.chart6,stroke:f?"rgba(255,255,255,0.3)":"rgba(0,0,0,0.2)",strokeWidth:1,role:"img","aria-label":"Local node"}),e.jsx("g",{clipPath:`url(#${ue})`,children:U.map(u=>{const E=D>0?u.distance/D*k:0;if(E>1)return null;const{x:C,y:_}=pe(u.bearing,E),F=u.snr!==null?gt(u.snr,O,T):"#808080",X=(o==null?void 0:o.hash)===u.hash,K=d.has(u.hash),ee=oe.DOT_RADIUS_HOVERED*1.5;return e.jsxs("g",{role:"img","aria-label":`${u.name}: ${u.distance.toFixed(1)}km ${u.bearing.toFixed(0)}°`,children:[K&&e.jsx("circle",{cx:C,cy:_,r:ee,fill:"none",stroke:f?"rgba(255,255,255,0.9)":"rgba(0,0,0,0.7)",strokeWidth:2,className:"neighbor-blink-ring"}),X&&e.jsx("circle",{cx:C,cy:_,r:ee,fill:F,opacity:.3}),e.jsx("circle",{cx:C,cy:_,r:X?oe.DOT_RADIUS_HOVERED:oe.DOT_RADIUS,fill:F,stroke:f?"rgba(0,0,0,0.5)":"rgba(0,0,0,0.25)",strokeWidth:1,style:{cursor:"pointer",transition:"r 0.15s"},onMouseEnter:()=>_e(u),onMouseLeave:()=>_e(null)})]},u.hash)})})]})]}),o&&e.jsxs("div",{className:"absolute bg-tooltip-bg border border-edge-subtle rounded-lg px-3 py-2 text-sm pointer-events-none z-10 shadow-xl",style:{left:"50%",bottom:8,transform:"translateX(-50%)"},children:[e.jsx("div",{className:"font-medium text-fg-primary",children:o.name}),e.jsx("div",{className:"type-data-xs text-fg-secondary",children:o.hash}),o.snr!==null?e.jsx("div",{className:"flex gap-3 mt-1 text-xs",children:e.jsxs("span",{children:[e.jsx("span",{className:"text-fg-secondary",children:"SNR:"})," ",e.jsxs("span",{className:"tabular-nums",style:{color:gt(o.snr,O,T)},children:[o.snr.toFixed(1)," dB"]}),e.jsxs("span",{className:"text-fg-secondary ml-1",children:["(",xn(o.snr),")"]})]})}):e.jsx("div",{className:"text-xs text-fg-secondary mt-1",children:"No SNR data"}),e.jsxs("div",{className:"flex gap-3 text-xs",children:[e.jsxs("span",{children:[e.jsx("span",{className:"text-fg-secondary",children:"Distance:"})," ",e.jsxs("span",{className:"tabular-nums text-fg-primary",children:[o.distance.toFixed(2)," km"]})]}),e.jsxs("span",{children:[e.jsx("span",{className:"text-fg-secondary",children:"Bearing:"})," ",e.jsxs("span",{className:"tabular-nums text-fg-primary",children:[o.bearing.toFixed(0),"°"]})]})]})]})]}),e.jsxs("div",{className:"flex flex-col gap-1 px-1.5 py-2 flex-shrink-0 depth-raised radius-inset self-stretch",style:{width:"calc(100% / 6)"},children:[r&&e.jsxs("div",{className:"flex flex-col items-center gap-1 pb-2 border-b border-edge-subtle mb-1",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"icon-md flex items-center justify-center text-icon-card-title",children:e.jsx(ze,{className:"w-3.5 h-3.5"})}),l&&e.jsx(Fe,{color:"zinc",children:l})]}),e.jsx("span",{className:"type-micro text-center text-[10px] leading-tight",children:r})]}),e.jsx("div",{className:"flex flex-col gap-1 flex-1",role:"group","aria-label":"Zoom level",children:["1x","2x","4x","8x","16x","36x"].map(u=>e.jsx("button",{onClick:()=>Re(u),"aria-pressed":j===u,className:`flex flex-1 items-center justify-center min-w-[44px] sm:min-w-[32px] text-xs font-medium radius-inner depth-stroke-raised transition-colors ${j===u?"bg-sys-blue/20 text-sys-blue":"bg-subtle-fill/80 text-fg-secondary hover:bg-subtle-fill-strong hover:text-fg-primary"}`,children:u},u))})]})]}):e.jsxs("div",{ref:H,className:"flex flex-col items-center justify-center h-full text-fg-secondary",children:[e.jsx(ze,{className:"w-8 h-8 mb-2 opacity-50"}),e.jsx("p",{children:"Local node coordinates not configured"}),e.jsx("p",{className:"text-xs mt-1",children:"Set latitude/longitude in config to enable"})]})}const fn=c.memo(pn),Ye={repeater:"var(--sys-blue)",companion:"var(--sys-cyan)",room_server:"var(--sys-indigo)"};function gn(t){if(t.contact_type){const n=t.contact_type.toLowerCase();if(n==="repeater"||n==="rep")return"repeater";if(n==="room server"||n==="room_server"||n==="room"||n==="server")return"room_server";if(n==="companion"||n==="client"||n==="cli")return"companion"}return t.is_repeater?"repeater":"companion"}function yn({neighbors:t}){const n=c.useMemo(()=>{const s={repeater:0,companion:0,room_server:0};for(const r of Object.values(t)){const l=gn(r);s[l]=(s[l]||0)+1}const a=Object.values(s).reduce((r,l)=>r+l,0);return{items:[{label:"Repeaters",count:s.repeater,percent:0,color:Ye.repeater},{label:"Companions",count:s.companion,percent:0,color:Ye.companion},{label:"Room Servers",count:s.room_server,percent:0,color:Ye.room_server}].map(r=>({...r,percent:a>0?r.count/a*100:0})).filter(r=>r.count>0).sort((r,l)=>l.count-r.count),total:a}},[t]);return n.total===0?e.jsx("div",{className:"h-full flex items-center justify-center text-fg-muted type-body-sm",children:"No neighbors discovered yet"}):e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsx("div",{className:"flex-1 flex flex-col justify-evenly",children:n.items.map(s=>e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"type-data-sm text-fg-secondary",children:s.label}),e.jsxs("span",{className:"type-data-sm text-fg-secondary tabular-nums",children:[s.count," ",e.jsxs("span",{className:"text-fg-secondary/60",children:["(",s.percent.toFixed(0),"%)"]})]})]}),e.jsx("div",{className:"h-2.5 bg-subtle-fill/80 overflow-hidden rounded-full depth-stroke-inset",children:e.jsx("div",{className:"h-full rounded-full transition-all duration-500 ease-out",style:{width:`${s.percent}%`,backgroundColor:s.color,minWidth:s.count>0?"4px":"0"}})})]},s.label))}),e.jsxs("div",{className:"flex items-center justify-between pt-2 border-t border-edge-subtle",children:[e.jsx("span",{className:"type-data-xs text-fg-secondary",children:"Total Nodes"}),e.jsx("span",{className:"type-data-sm text-fg-primary font-medium tabular-nums",children:n.total})]})]})}const bn=c.memo(yn);function Xe({children:t,minHeight:n="100%",rootMargin:s="200px 0px",keepMounted:a=!0,className:i=""}){const r=c.useRef(null),[l,x]=c.useState(!1),[o,p]=c.useState(!1);c.useEffect(()=>{const h=r.current;if(!h)return;const w=new IntersectionObserver(([g])=>{const j=g.isIntersecting;p(j),j&&x(!0)},{rootMargin:s,threshold:0});return w.observe(h),()=>{w.disconnect()}},[s]);const d=o||a&&l;return e.jsx("div",{ref:r,className:`h-full w-full ${i}`,style:{minHeight:n},children:d?t:e.jsx("div",{className:"h-full w-full flex items-center justify-center text-fg-muted/50",children:e.jsx("div",{className:"animate-pulse text-xs",children:"Loading chart..."})})})}const kt=[{target:"DisambiguationCard",fn:"disambiguation.collisions",minStage:2}];tt(kt);const jn=.9,Nn=.7,vn=.5,Sn=10,kn=25,Pe={excellent:"text-signal-excellent",good:"text-signal-good",fair:"text-signal-fair",poor:"text-sys-blue"},wn={excellent:"bg-signal-excellent/10",good:"bg-signal-good/10",fair:"bg-signal-fair/10",poor:"bg-sys-blue/10"};function Mn(t){return t>=jn?"excellent":t>=Nn?"good":t>=vn?"fair":"poor"}function Cn(t){return t<=Sn?"excellent":t<=kn?"good":"poor"}function An(){et(kt);const t=Ht(),n=Bt(),[s,a]=c.useState(null),i=c.useCallback((d,h)=>{a({prefix:d,candidateHashes:h})},[]),r=c.useCallback(()=>{a(null)},[]);if(!n)return e.jsxs(le,{neomorphic:!0,children:[e.jsx(Ne,{icon:e.jsx(rt,{}),title:"Prefix Conflicts"}),e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"text-center text-fg-secondary",children:[e.jsx($t,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),e.jsx("p",{className:"type-data-xs",children:"No topology data available"}),e.jsx("p",{className:"type-data-xs opacity-70",children:"Run deep analysis to see stats"})]})})]});const l=Mn(t.avgConfidence),x=Cn(t.collisionRate),o=l==="poor"||x==="poor"?"poor":l==="fair"||x==="fair"?"fair":l==="good"||x==="good"?"good":"excellent",p=o==="excellent"||o==="good"?it:Ze;return e.jsxs(le,{neomorphic:!0,className:"flex flex-col overflow-hidden",children:[e.jsx(Ne,{icon:e.jsx(rt,{}),title:"Prefix Conflicts",badgeColor:"zinc",actions:o==="poor"?e.jsxs(Fe,{color:"red",children:[e.jsx(Ze,{className:"w-3 h-3"}),"Needs Attention"]}):e.jsxs("div",{className:`flex items-center gap-1.5 px-2.5 py-1 rounded-full ${wn[o]}`,children:[e.jsx(p,{className:`w-3.5 h-3.5 ${Pe[o]}`}),e.jsx("span",{className:`type-data-xs font-medium ${Pe[o]}`,children:o==="excellent"?"Excellent":o==="good"?"Good":"Fair"})]})}),e.jsxs("div",{className:"flex-1 flex flex-col min-h-0",children:[e.jsxs("div",{className:"flex gap-2 sm:gap-3 py-3 sm:py-4",children:[e.jsxs("div",{className:"flex-1 flex flex-col radius-inner depth-stroke-raised bg-subtle-fill/80 px-3 py-2.5 sm:py-3 cursor-help",title:"Total unique 2-character prefixes observed in packet paths.",children:[e.jsx("span",{className:"type-data-xl text-fg-primary",children:e.jsx(Oe,{value:t.totalPrefixes,priority:"low"})}),e.jsx("span",{className:"type-micro text-fg-muted mt-0.5 sm:mt-1",children:"Prefixes"})]}),e.jsxs("div",{className:"flex-1 flex flex-col radius-inner depth-stroke-raised bg-subtle-fill/80 px-3 py-2.5 sm:py-3 cursor-help",title:"Prefixes that map to exactly one known node. No disambiguation needed.",children:[e.jsx("span",{className:"type-data-xl text-fg-primary",children:e.jsx(Oe,{value:t.unambiguousPrefixes,priority:"low"})}),e.jsx("span",{className:"type-micro text-fg-muted mt-0.5 sm:mt-1",children:"Unique"})]}),e.jsxs("div",{className:"flex-1 flex flex-col radius-inner depth-stroke-raised bg-subtle-fill/80 px-3 py-2.5 sm:py-3 cursor-help",title:"Prefixes matching multiple known nodes. Click a prefix below to explore candidates.",children:[e.jsx("span",{className:`type-data-xl ${t.collisionPrefixes>0?"text-sys-blue":"text-fg-primary"}`,children:e.jsx(Oe,{value:t.collisionPrefixes,priority:"low"})}),e.jsx("span",{className:`type-micro mt-0.5 sm:mt-1 ${t.collisionPrefixes>0?"text-sys-blue":"text-fg-muted"}`,children:"Conflicts"})]})]}),t.highCollisionPrefixes.length>0&&e.jsxs("div",{className:"pt-2",children:[e.jsx("div",{className:"type-data-xs text-fg-secondary mb-1.5",children:"Problem Prefixes"}),e.jsx("div",{className:"flex flex-wrap gap-1.5 content-start",children:t.highCollisionPrefixes.map(({prefix:d,candidateCount:h,candidateHashes:w})=>e.jsxs("button",{type:"button",onClick:()=>i(d,w),className:"inline-flex items-center gap-0.5 group",title:`${h} candidates - click to explore`,children:[e.jsx(ls,{children:d}),e.jsxs("span",{className:"text-fg-muted type-data-xs group-hover:text-fg-secondary transition-colors",children:["×",h]})]},d))})]}),t.lowConfidencePrefixes.length===0&&t.collisionPrefixes===0&&e.jsx("div",{className:"flex-1 flex items-center",children:e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(it,{className:"w-3.5 h-3.5 text-signal-excellent"}),e.jsx("span",{className:"type-data-xs text-signal-excellent",children:"All prefixes uniquely identified"})]})}),e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center gap-2 sm:gap-4 mt-auto pt-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2 cursor-help",title:"Average confidence score across all disambiguated prefixes. Higher = more certain node identification.",children:[e.jsx("span",{className:"type-data-xs text-fg-secondary",children:"Confidence"}),e.jsxs("span",{className:`data-box ${Pe[l]}`,children:[(t.avgConfidence*100).toFixed(1),"%"]})]}),e.jsxs("div",{className:"flex items-center gap-2 cursor-help",title:"Percentage of 2-character prefixes that match multiple known nodes. Lower is better.",children:[e.jsx("span",{className:"type-data-xs text-fg-secondary",children:"Collisions"}),e.jsxs("span",{className:`data-box ${Pe[x]}`,children:[t.collisionRate.toFixed(1),"%"]})]})]})]}),e.jsx(ms,{isOpen:!!s,prefix:(s==null?void 0:s.prefix)||"",candidateHashes:(s==null?void 0:s.candidateHashes)||[],onClose:r})]})}const wt=[{target:"PacketHealth",fn:"type",minStage:1},{target:"PacketHealth",fn:"duplicates",minStage:1}];tt(wt);const _n=new Set(["Duplicate","Empty payload","Path too long","Unknown"]),Me=24;function Rn(t,n){const s=Date.now()/1e3,a=n*60,i=s-a,r=a/Me,l=new Array(Me).fill(0),x=new Array(Me).fill(0);let o=0,p=0,d=0,h=0;for(const g of t){if(g.packet_origin==="tx_local")continue;const j=g.timestamp;if(js)continue;o++;const b=Math.min(Me-1,Math.floor((j-i)/r));x[b]++,g.transmitted||g.packet_origin==="tx_forward"?(p++,l[b]++):(g.is_duplicate||g.drop_reason==="Duplicate")&&d++,g.drop_reason&&_n.has(g.drop_reason)&&h++}const w=[];for(let g=0;g0?Math.round(b/j*100):0,timestamp:(i+g*r)*1e3})}return{totalRx:o,forwarded:p,duplicates:d,waste:h,efficiency:o>0?p/o*100:0,duplicateRate:o>0?d/o*100:0,wasteRate:o>0?h/o*100:0,sparkline:w}}function Ln(t){return t>=90?"excellent":t>=75?"good":t>=60?"fair":"poor"}const Dn={excellent:"bg-status-success",good:"bg-sys-blue",fair:"bg-status-warning",poor:"bg-status-danger"};function En({packets:t,rangeMinutes:n,rangeHours:s,timeRangeLabel:a,isLoaded:i=!0}){et(wt);const r=c.useMemo(()=>Rn(t,n),[t,n]),[l,x]=c.useState(null),o=c.useCallback(async()=>{try{const h=await zt(s);h.success&&h.data&&x(h.data.count)}catch{}},[s]);c.useEffect(()=>{o()},[o]);const p=Ln(r.efficiency),d=r.totalRx>0;return e.jsx(le,{neomorphic:!0,isLoaded:i,skeletonType:"chart",children:i&&e.jsxs(e.Fragment,{children:[e.jsx(Ne,{icon:e.jsx(us,{}),title:"Packet Health",badge:a,badgeColor:"zinc"}),e.jsx(Wt,{children:e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsxs("div",{className:"flex items-baseline gap-2",children:[e.jsxs("div",{className:"type-data-xl text-fg-primary",children:[d?e.jsx(Oe,{value:Math.round(r.efficiency*10)/10,className:"font-mono tabular-nums",priority:"medium",format:{minimumFractionDigits:1,maximumFractionDigits:1}}):e.jsx("span",{className:"opacity-30",children:"—"}),e.jsx("span",{className:"type-data-sm text-fg-muted ml-0.5",children:"%"})]}),d&&e.jsx("div",{className:`w-2 h-2 rounded-full ${Dn[p]}`})]}),e.jsx("div",{className:"type-micro mb-2 cursor-help",title:"Forwarded packets / total received. CRC failures, garbled packets, and RF collisions that destroy packets before reaching software are not included in this ratio — see CRC Errors for hardware-level failures.",children:"FORWARDING RATE"}),e.jsx("div",{className:"flex-1 min-h-[28px] max-h-[48px] mb-2",children:e.jsx(ds,{data:r.sparkline,width:9999,height:36,color:"var(--sys-blue)",className:"w-full"})}),e.jsxs("div",{className:"flex gap-2 sm:gap-3 mt-auto",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"data-box-label",children:"Dupes"}),e.jsx("div",{className:"data-box data-box-fill data-box-left",children:d?`${r.duplicateRate.toFixed(1)}%`:"—"})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"data-box-label",children:"Waste"}),e.jsx("div",{className:"data-box data-box-fill data-box-left",children:d?`${r.wasteRate.toFixed(1)}%`:"—"})]}),l!==null&&l>0&&e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"data-box-label flex items-center gap-1",children:[e.jsx(Ze,{className:"w-3 h-3 text-status-warning"}),"CRC"]}),e.jsx("div",{className:"data-box data-box-fill data-box-left text-status-warning",children:l})]})]})]})})]})})}function la(){var De,ke,Ee,Te,u,E,C,_,F,X,K,ee,Z,ie,me,de,he;const t=Ut(),n=Gt(),s=qt(),a=Vt(),i=Kt(),r=Yt(),l=t!==null&&i,x=c.useRef(!1);l&&!x.current&&(x.current=!0);const o=x.current,p=Xt(),d=Zt(),h=Qt(),[w,g]=c.useState(null),[,j]=c.useState(null),[b]=c.useState(null),[k,L]=c.useState(()=>{const M=localStorage.getItem("statistics-view-mode");return M==="share"||M==="airtime"?M:"airtime"});c.useEffect(()=>{localStorage.setItem("statistics-view-mode",k)},[k]);const[P,z]=c.useState(()=>{const M=localStorage.getItem("statistics-smoothing-mode");return["ema","ultra","mosaic","stats","trend"].includes(M)?M:"stats"});c.useEffect(()=>{localStorage.setItem("statistics-smoothing-mode",P)},[P]);const[H,V]=c.useState(!1),[O,N]=c.useState(!1),[m,f]=c.useState(jt),[v,T]=c.useState(.5),[B,R]=c.useState(hs),[W,q]=c.useState(.8),[te,J]=c.useState(50),U=c.useMemo(()=>({0:0,1:0,2:1,3:2,4:3,5:4,6:5,7:6,8:7,9:8,10:9})[p]??3,[p]),D=$e[U].hours,Y=D*60,se=$e[U],re=at(D),ae=r.isBackgroundLoading,ne=c.useCallback(M=>{const ye={0:1,1:2,2:3,3:4,4:5,5:6,6:7,7:8,8:9,9:10}[M]??4;d(ye)},[d]),ce=c.useMemo(()=>{var G;if(!((G=t==null?void 0:t.config)!=null&&G.radio))return null;const M=t.config.radio;return{sf:M.spreading_factor??10,bw:M.bandwidth??25e4,cr:M.coding_rate??5,preamble:M.preamble_length??8}},[(ke=(De=t==null?void 0:t.config)==null?void 0:De.radio)==null?void 0:ke.spreading_factor,(Te=(Ee=t==null?void 0:t.config)==null?void 0:Ee.radio)==null?void 0:Te.bandwidth,(E=(u=t==null?void 0:t.config)==null?void 0:u.radio)==null?void 0:E.coding_rate,(_=(C=t==null?void 0:t.config)==null?void 0:C.radio)==null?void 0:_.preamble_length]),$=c.useMemo(()=>h.length===0?{timestamps:[],values:[]}:{timestamps:h.map(M=>M.timestamp),values:h.map(M=>M.noise_floor_dbm)},[h]),y=c.useMemo(()=>{if(h.length<10)return{anomalies:[],debug:void 0};const M=As(h,m);return{anomalies:M.anomalies,debug:M.debug}},[h,m]),S=y.anomalies,A=c.useMemo(()=>{const M=(t==null?void 0:t.neighbors)??{};return Object.fromEntries(Object.entries(M).filter(([G])=>!n.has(G)))},[t==null?void 0:t.neighbors,n]),I=c.useMemo(()=>{const M=Date.now()/1e3-D*3600;return Object.fromEntries(Object.entries(A).filter(([,G])=>G.last_seen>=M))},[A,D]),Q=c.useMemo(()=>{const M=Y*60/re,G=Math.floor(Date.now()/1e3),ye=Math.floor(G/M)*M;return{start:ye-Y*60,end:ye}},[Y,re]),ue=B.timeStart??Q.start,pe=B.timeEnd??Q.end,fe=(pe-ue)/3600,_e=at(fe),Re=fs(),Le=c.useMemo(()=>xs(a,B,Re,Q),[a,B,Re,Q]);return e.jsxs(rs,{children:[e.jsx(is,{title:"Statistics",icon:e.jsx(Jt,{}),controls:e.jsx(as,{ranges:$e,selectedIndex:U,onSelect:ne,isPending:ae})}),b&&e.jsx(le,{className:"border border-sys-red/50 bg-sys-red/10",children:e.jsx("p",{className:"text-sys-red",children:b})}),H&&O&&e.jsxs(le,{className:"border border-sys-indigo/30 bg-surface/50",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"type-label",children:"Anomaly Detection Tuning"}),e.jsxs("span",{className:"type-data-xs text-fg-muted",children:["(",se.label,")"]})]}),e.jsx("button",{onClick:()=>f(M=>({...M,useAbsoluteThresholds:!M.useAbsoluteThresholds})),className:`type-data-xs px-2 py-1 rounded transition-colors ${m.useAbsoluteThresholds?"bg-sys-indigo/30 text-sys-indigo":"bg-elevated text-fg-muted hover:text-fg-secondary"}`,children:m.useAbsoluteThresholds?"Absolute dBm":"Percentile"})]}),e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-4",children:[e.jsxs("div",{children:[e.jsx("span",{className:"type-micro",children:"Baseline"}),e.jsxs("span",{className:"ml-2 type-data-sm text-status-warning",children:[((X=(F=y.debug)==null?void 0:F.baselineCutoff)==null?void 0:X.toFixed(1))??"—"," dBm"]})]}),e.jsxs("div",{children:[e.jsx("span",{className:"type-micro",children:"Spike"}),e.jsxs("span",{className:"ml-2 type-data-sm text-status-warning",children:[((ee=(K=y.debug)==null?void 0:K.spikeCutoff)==null?void 0:ee.toFixed(1))??"—"," dBm"]})]}),e.jsxs("div",{children:[e.jsx("span",{className:"type-micro",children:"Mid-band"}),e.jsx("span",{className:"ml-2 type-data-sm text-sys-indigo",children:((Z=y.debug)==null?void 0:Z.midBandSamples)??0})]}),e.jsxs("div",{children:[e.jsx("span",{className:"type-micro",children:"Anomalies"}),e.jsx("span",{className:"ml-2 type-data-sm text-status-danger",children:S.length})]})]}),e.jsxs("div",{className:"mt-4 pt-4 border-t border-edge-subtle space-y-4",children:[m.useAbsoluteThresholds?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"type-micro block mb-1",children:["Baseline (",m.baselineDbm," dBm)"]}),e.jsx("input",{type:"range",min:"-120",max:"-60",value:m.baselineDbm,onChange:M=>f(G=>({...G,baselineDbm:Number(M.target.value)})),className:"w-full accent-sys-indigo"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"type-micro block mb-1",children:["Spike (",m.spikeDbm," dBm)"]}),e.jsx("input",{type:"range",min:"-100",max:"-20",value:m.spikeDbm,onChange:M=>f(G=>({...G,spikeDbm:Number(M.target.value)})),className:"w-full accent-sys-indigo"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"type-micro block mb-1",children:["Merge Gap (",m.mergeGapSeconds,"s)"]}),e.jsx("input",{type:"range",min:"5",max:"120",step:"5",value:m.mergeGapSeconds,onChange:M=>f(G=>({...G,mergeGapSeconds:Number(M.target.value)})),className:"w-full accent-sys-indigo"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"type-micro block mb-1",children:["Min Sequence (",m.minSequenceLength,")"]}),e.jsx("input",{type:"range",min:"2",max:"20",value:m.minSequenceLength,onChange:M=>f(G=>({...G,minSequenceLength:Number(M.target.value)})),className:"w-full accent-sys-indigo"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"type-micro block mb-1",children:["Similarity (±",m.similarityToleranceDbm," dBm)"]}),e.jsx("input",{type:"range",min:"1",max:"15",value:m.similarityToleranceDbm,onChange:M=>f(G=>({...G,similarityToleranceDbm:Number(M.target.value)})),className:"w-full accent-sys-indigo"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"type-micro block mb-1",children:["Opacity (",Math.round(v*100),"%)"]}),e.jsx("input",{type:"range",min:"0.1",max:"1",step:"0.05",value:v,onChange:M=>T(Number(M.target.value)),className:"w-full accent-sys-indigo"})]})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"type-micro block mb-1",children:["Baseline (P",m.baselinePercentile,")"]}),e.jsx("input",{type:"range",min:"1",max:"50",value:m.baselinePercentile,onChange:M=>f(G=>({...G,baselinePercentile:Number(M.target.value)})),className:"w-full accent-sys-indigo"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"type-micro block mb-1",children:["Spike (P",m.spikePercentile,")"]}),e.jsx("input",{type:"range",min:"50",max:"99",value:m.spikePercentile,onChange:M=>f(G=>({...G,spikePercentile:Number(M.target.value)})),className:"w-full accent-sys-indigo"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"type-micro block mb-1",children:["Merge Gap (",m.mergeGapSeconds,"s)"]}),e.jsx("input",{type:"range",min:"5",max:"120",step:"5",value:m.mergeGapSeconds,onChange:M=>f(G=>({...G,mergeGapSeconds:Number(M.target.value)})),className:"w-full accent-sys-indigo"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"type-micro block mb-1",children:["Min Sequence (",m.minSequenceLength,")"]}),e.jsx("input",{type:"range",min:"2",max:"20",value:m.minSequenceLength,onChange:M=>f(G=>({...G,minSequenceLength:Number(M.target.value)})),className:"w-full accent-sys-indigo"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"type-micro block mb-1",children:["Similarity (±",m.similarityToleranceDbm," dBm)"]}),e.jsx("input",{type:"range",min:"1",max:"15",value:m.similarityToleranceDbm,onChange:M=>f(G=>({...G,similarityToleranceDbm:Number(M.target.value)})),className:"w-full accent-sys-indigo"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"type-micro block mb-1",children:["Opacity (",Math.round(v*100),"%)"]}),e.jsx("input",{type:"range",min:"0.1",max:"1",step:"0.05",value:v,onChange:M=>T(Number(M.target.value)),className:"w-full accent-sys-indigo"})]})]})]}),e.jsxs("div",{className:"mt-4 p-3 bg-elevated radius-inner",children:[e.jsx("div",{className:"type-micro mb-1",children:"Config output"}),e.jsxs("div",{className:"type-data-sm text-status-success",children:[m.useAbsoluteThresholds?`useAbsoluteThresholds: true, baselineDbm: ${m.baselineDbm}, spikeDbm: ${m.spikeDbm}`:`useAbsoluteThresholds: false, baselinePercentile: ${m.baselinePercentile}, spikePercentile: ${m.spikePercentile}`,", mergeGapSeconds: ",m.mergeGapSeconds,", minSequenceLength: ",m.minSequenceLength,", similarityToleranceDbm: ",m.similarityToleranceDbm]})]})]})]}),e.jsxs(os,{children:[e.jsx("div",{className:"sm:hidden",children:ae&&e.jsx(ge,{template:"auto",children:e.jsx(le,{className:"border border-sys-blue/30 bg-sys-blue/5",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"relative flex h-3 w-3",children:[e.jsx("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full bg-sys-blue opacity-75"}),e.jsx("span",{className:"relative inline-flex rounded-full h-3 w-3 bg-sys-blue"})]}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("p",{className:"type-body-sm text-fg-primary",children:["Loading ",se.label," data..."]}),r.loadProgress&&e.jsxs("p",{className:"type-data-xs text-fg-muted mt-0.5",children:[r.loadProgress.loaded.toLocaleString()," packets (",r.loadProgress.percent,"%)"]})]})]})})})}),o?e.jsxs(e.Fragment,{children:[e.jsx(ge,{template:"hero-auto",children:e.jsx(le,{neomorphic:!0,isLoaded:o,skeletonType:"chart",children:o&&e.jsxs(e.Fragment,{children:[e.jsx(Ne,{icon:e.jsx(Se,{}),title:"Packet Analyzer",badge:se.label,badgeColor:"zinc",stackActionsOnMobile:!0,actions:e.jsxs("div",{className:"flex flex-wrap items-center gap-2 justify-end",children:[P==="stats"&&e.jsx(qs,{enabled:H,onChange:V,anomalyCount:S.length,showTuning:O,onTuningChange:N}),e.jsx(Gs,{smoothing:P,onChange:z}),e.jsx(Us,{mode:k,onChange:L})]})}),e.jsx("div",{className:"flex-1 min-h-0",children:e.jsx(on,{packets:Le,allPackets:a,startTs:ue,endTs:pe,parentStartTs:Q.start,parentEndTs:Q.end,bucketCount:_e,radioConfig:ce??void 0,mode:k,smoothing:P,noiseFloorAnomalies:S,showNoiseFloorOverlay:H,overlayOpacity:v,dotSize:W,dotOpacity:te/100})})]})})}),e.jsx(ge,{template:"auto",className:"relative z-10",children:e.jsx(le,{neomorphic:!0,noPadding:!0,isLoaded:o,className:"overflow-visible",children:o&&e.jsx(ps,{parentStartTs:Q.start,parentEndTs:Q.end,neighbors:A,filter:B,onChange:R,...P==="stats"?{scatterDotSize:W,onScatterDotSizeChange:q,scatterOpacity:te,onScatterOpacityChange:J}:{}})})}),e.jsxs(ge,{template:"panel",children:[e.jsx(we,{span:12,md:6,children:e.jsx(le,{neomorphic:!1,isLoaded:o,skeletonType:"chart",noPadding:o,className:"!bg-transparent !ring-0 !shadow-none !overflow-visible -mx-4 sm:mx-0 !px-0 !pr-0",children:o&&e.jsx(Xe,{children:e.jsx(fn,{neighbors:I,quickNeighbors:s,localLat:((me=(ie=t==null?void 0:t.config)==null?void 0:ie.repeater)==null?void 0:me.latitude)??0,localLon:((he=(de=t==null?void 0:t.config)==null?void 0:de.repeater)==null?void 0:he.longitude)??0,onStatsChange:j,title:"Link Quality",badge:se.label})})})}),e.jsx(we,{span:12,md:6,children:e.jsx(le,{neomorphic:!0,isLoaded:o,skeletonType:"chart",children:o&&e.jsxs(e.Fragment,{children:[e.jsx(Ne,{icon:e.jsx(ys,{}),title:"Network Composition",badge:se.label,badgeColor:"zinc"}),e.jsx("div",{className:"flex-1 min-h-0",children:e.jsx(Xe,{children:e.jsx(bn,{neighbors:I})})})]})})})]}),e.jsxs(ge,{template:"panel",children:[e.jsx(we,{span:12,md:6,children:e.jsx(An,{})}),e.jsx(we,{span:12,md:6,children:e.jsx(En,{packets:a,rangeMinutes:Y,rangeHours:D,timeRangeLabel:se.label,isLoaded:o})})]}),e.jsx(ge,{template:"panel",children:e.jsx(we,{span:12,children:e.jsx(le,{neomorphic:!0,isLoaded:o,skeletonType:"chart",children:o&&e.jsxs(e.Fragment,{children:[e.jsx(Ne,{icon:e.jsx(es,{}),title:"NOISE FLOOR dBm",stackActionsOnMobile:!0,actions:w?e.jsxs("div",{className:"flex items-center gap-2 sm:gap-3",children:[e.jsxs("span",{className:"type-data-xs text-fg-muted whitespace-nowrap",children:["min ",e.jsx("span",{className:"data-box",children:w.min.toFixed(0)})]}),e.jsxs("span",{className:"type-data-xs text-fg-muted whitespace-nowrap",children:["avg ",e.jsx("span",{className:"data-box",children:w.avg.toFixed(0)})]}),e.jsxs("span",{className:"type-data-xs text-fg-muted whitespace-nowrap",children:["max ",e.jsx("span",{className:"data-box",children:w.max.toFixed(0)})]})]}):null}),e.jsx("div",{className:"flex-1 min-h-0",children:e.jsx(Xe,{children:e.jsx(ts,{timestamps:$.timestamps,values:$.values,onStatsChange:g})})})]})})})})]}):e.jsx(ge,{template:"auto",children:e.jsx(le,{neomorphic:!0,className:"text-center py-12",children:e.jsx("div",{className:"animate-pulse text-fg-muted",children:"Loading statistics..."})})})]})]})}export{la as default}; diff --git a/frontend/dist/assets/Statistics-Okhl24tB.js b/frontend/dist/assets/Statistics-Okhl24tB.js new file mode 100644 index 00000000..603888ae --- /dev/null +++ b/frontend/dist/assets/Statistics-Okhl24tB.js @@ -0,0 +1,41 @@ +var Ct=Object.defineProperty;var At=(t,n,s)=>n in t?Ct(t,n,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[n]=s;var xe=(t,n,s)=>At(t,typeof n!="symbol"?n+"":n,s);import{d as Ae,r as c,j as e,p as Ce,c as nt,bc as yt,c0 as jt,c1 as _t,v as Fe,c2 as Rt,c3 as Tt,f as Dt,c4 as Et,c5 as Lt,c6 as It,c7 as Pt,c8 as Ot,bz as Ft,c9 as Be,bC as Ht,ca as Bt,cb as $t,H as Ne,cc as zt,cd as Wt,ce as Ut,G as Gt,N as Vt,K as qt,D as Kt,ak as Yt,al as Xt,O as Zt,ae as Qt,cf as Jt,cg as $e,ch as at,a6 as es,R as ts,ci as ss}from"./index-DhkG1Nx9.js";import{L as ve}from"./layers-BxF7oyms.js";import{a as Je,g as ke,E as ns,A as Oe}from"./AnimatedNumber-VoU6jLG5.js";import{u as et,h as as,r as tt}from"./consumer-registry-CTQIn0m9.js";import{C as ze,e as rs}from"./easing-Ch_Y3tms.js";import{T as is}from"./TimeRangeStepper-RSPVaByt.js";import{C as ue,P as os,a as ls,B as cs}from"./PageLayout-BkUTZXJb.js";import{D as ms}from"./DataBox-BMesbbaF.js";import{C as us}from"./CollisionExplorerModal-Cs8y9_83.js";import{H as rt}from"./hash-KLxvul5e.js";import{T as Ze}from"./triangle-alert-D8NErBXC.js";import{L as ds}from"./LightSparkline-Bg_XrgTS.js";import{A as hs}from"./activity-BG24yKp1.js";import{c as xs,a as ps,A as fs}from"./AnalyzerFilterPanel-CBw2MsnC.js";import{useResolveSource as gs}from"./usePipelineStore-B9ir1Xwp.js";import{R as be,C as we}from"./Grid-DknC4rR5.js";import{S as bs}from"./settings-2-Bgw7gOTp.js";import{N as ys}from"./network-DBF70fah.js";import"./index-Bx_G2nLG.js";import"./chevron-right-na13OQfy.js";import"./map-pin-BHGohRD7.js";import"./BasemapLayer-CfNeG6Jg.js";import"./monitor-smartphone-jV9bAwUA.js";import"./node-types-CgBRFpS8.js";import"./funnel-Dr2cCUci.js";import"./circle-question-mark--xh93QHC.js";import"./search-BmkxxIVP.js";/** + * @license lucide-react v0.559.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const js=[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"m19 9-5 5-4-4-3 3",key:"2osh9i"}]],Ns=Ae("chart-line",js);/** + * @license lucide-react v0.559.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const vs=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],it=Ae("circle-check-big",vs);/** + * @license lucide-react v0.559.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const ks=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M3 15h18",key:"5xshup"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"M15 3v18",key:"14nvp0"}]],Ss=Ae("grid-3x3",ks);/** + * @license lucide-react v0.559.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const ws=[["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["circle",{cx:"19",cy:"5",r:"1",key:"w8mnmm"}],["circle",{cx:"5",cy:"5",r:"1",key:"lttvr7"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}],["circle",{cx:"12",cy:"19",r:"1",key:"lyex9k"}],["circle",{cx:"19",cy:"19",r:"1",key:"shf9b7"}],["circle",{cx:"5",cy:"19",r:"1",key:"bfqh0e"}]],Ms=Ae("grip",ws);/** + * @license lucide-react v0.559.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Cs=[["path",{d:"M2 6c.6.5 1.2 1 2.5 1C7 7 7 5 9.5 5c2.6 0 2.4 2 5 2 2.5 0 2.5-2 5-2 1.3 0 1.9.5 2.5 1",key:"knzxuh"}],["path",{d:"M2 12c.6.5 1.2 1 2.5 1 2.5 0 2.5-2 5-2 2.6 0 2.4 2 5 2 2.5 0 2.5-2 5-2 1.3 0 1.9.5 2.5 1",key:"2jd2cc"}],["path",{d:"M2 18c.6.5 1.2 1 2.5 1 2.5 0 2.5-2 5-2 2.6 0 2.4 2 5 2 2.5 0 2.5-2 5-2 1.3 0 1.9.5 2.5 1",key:"rd2r6e"}]],As=Ae("waves",Cs),Nt={useAbsoluteThresholds:!0,baselinePercentile:6,spikePercentile:50,baselineDbm:-107,spikeDbm:-100,mergeGapSeconds:45,minSequenceLength:16,similarityToleranceDbm:5};function je(t,n){if(t.length===0)return 0;const s=n/100*(t.length-1),a=Math.floor(s),i=Math.ceil(s);return a===i?t[a]:t[a]+(t[i]-t[a])*(s-a)}function ot(t){if(t.length===0)return{median:0,p90:0,p95:0,p99:0,max:0,min:0};const n=[...t].sort((s,a)=>s-a);return{median:je(n,50),p90:je(n,90),p95:je(n,95),p99:je(n,99),max:n[n.length-1],min:n[0]}}function _s(t,n={}){const s={...Nt,...n};if(t.length<10)return{anomalies:[],thresholds:ot([]),totalSamples:t.length,anomalySamples:0};const a=t.map(g=>g.noise_floor_dbm),i=ot(a),r=[...a].sort((g,j)=>g-j);let l,x;s.useAbsoluteThresholds?(l=s.baselineDbm,x=s.spikeDbm):(l=je(r,s.baselinePercentile),x=je(r,s.spikePercentile));const o=[...t].sort((g,j)=>g.timestamp-j.timestamp),p=[];let u=null,h=0;for(const g of o)if(g.noise_floor_dbm>l&&g.noise_floor_dbmI+z,0)/u.values.length):(u.values.length>=s.minSequenceLength&&p.push(u),u={startTs:g.timestamp,endTs:g.timestamp,values:[g.noise_floor_dbm],timestamps:[g.timestamp],rollingAvg:g.noise_floor_dbm})}else u&&u.values.length>=s.minSequenceLength&&p.push(u),u=null;return u&&u.values.length>=s.minSequenceLength&&p.push(u),p.length===0?{anomalies:[],thresholds:i,totalSamples:t.length,anomalySamples:h,debug:{baselineCutoff:l,spikeCutoff:x,midBandSamples:h}}:{anomalies:p.map(g=>{const j=Math.max(...g.values),y=g.values.reduce((k,R)=>k+R,0)/g.values.length;return{startTs:g.startTs,endTs:g.endTs,peakValue:j,avgValue:y,severity:Rs(y,l,x),sampleCount:g.values.length}}),thresholds:i,totalSamples:t.length,anomalySamples:h,debug:{baselineCutoff:l,spikeCutoff:x,midBandSamples:h}}}function Rs(t,n,s){const a=s-n;if(a===0)return"moderate";const i=(t-n)/a;return i>.66?"critical":i>.33?"severe":"moderate"}const Ts=Object.entries(yt).map(([t,n])=>{const s=parseInt(t,10);return{typeNum:s,key:`TYPE_${s}`,label:n}});function st({sortedTypes:t,highlightedType:n,onTypeHover:s,aggregateShares:a,hoverData:i}){const r=c.useMemo(()=>{if(!i)return null;const o=new Map;for(const p of i.items)o.set(p.key,p.value);return o},[i]),l=r!==null,x=c.useMemo(()=>{const o=new Set(t.map(h=>h.key)),p=t.map(h=>({typeNum:h.typeNum,key:h.key,label:h.label})),u=Ts.filter(h=>!o.has(h.key));return[...p,...u]},[t]);return e.jsxs("div",{className:"flex-shrink-0 pt-2 sm:pt-3 mt-1 sm:mt-2 px-0 sm:pr-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mx-0 sm:ml-9 sm:mr-0 mb-1 sm:mb-1.5 type-data-xs",children:[e.jsx("span",{className:"text-fg-muted",children:"Packet Types"}),l&&(i==null?void 0:i.timeLabel)&&e.jsx("span",{className:"text-sys-indigo tabular-nums",children:i.timeLabel})]}),e.jsx("div",{className:"flex flex-wrap gap-x-3 sm:gap-x-4 gap-y-1 type-data-xs mx-0 sm:ml-9 sm:mr-0",onMouseLeave:()=>s(null),children:x.map(o=>{const p=Ce(o.typeNum),u=(r==null?void 0:r.get(o.key))??0,h=a.get(o.key)??0,w=l?u:h,g=w>1e-4,j=a.has(o.key),y=n===o.key,k=n&&!y||l&&u<=1e-4||!l&&!n&&!j;return e.jsxs("div",{className:nt("flex items-center gap-1.5 transition-opacity cursor-pointer hover:opacity-80",k&&"opacity-30"),onMouseEnter:()=>s(o.key),children:[e.jsx("div",{className:"shrink-0 w-3 h-3 rounded-xs",style:{backgroundColor:p}}),e.jsx("span",{className:"text-fg-secondary whitespace-nowrap",children:o.label}),g&&e.jsxs("span",{className:nt("tabular-nums",l?"text-fg-primary":"text-fg-muted"),children:[(w*100).toFixed(1),"%"]})]},o.key)})})]})}const lt='ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace',Ds=2,Es=3,Ls=32,Is=20,Ps=80;function ct(t,n,s,a,i){const r=t.reduce((p,u)=>p+u,0);if(r<=0||t.length===0)return[];const l=t.map((p,u)=>u).sort((p,u)=>t[u]-t[p]),x=l.map(p=>t[p]),o=new Array(t.length);return Qe(x,l,r,n,s,a,i,o),o}function Qe(t,n,s,a,i,r,l,x){if(t.length===0)return;if(t.length===1){x[n[0]]={x:a,y:i,w:r,h:l,index:n[0]};return}const o=r*l/s,p=r>=l,u=p?l:r;let h=0,w=1/0,g=0;for(let z=0;zq?O/q:q/O,N>q?N/q:q/N);if(m<=w)w=m,g=z+1,h=H;else break}const j=u>0?h*o/u:0;let y=0;for(let z=0;z0?t[z]/h:0)*u;p?x[n[z]]={x:a,y:i+y,w:j,h:q,index:n[z]}:x[n[z]]={x:a+y,y:i,w:q,h:j,index:n[z]},y+=q}const k=t.slice(g),R=n.slice(g),I=s-h;p?Qe(k,R,I,a+j,i,r-j,l,x):Qe(k,R,I,a,i+j,r,l-j,x)}function mt(t,n,s,a,i,r){for(const l of n){const x=s[l.index];if(!x)continue;const o=Ds*r,p=l.x*r+o/2,u=l.y*r+o/2,h=l.w*r-o,w=l.h*r-o;if(h<=0||w<=0)continue;const g=Ce(x.typeNum),j=i!==null&&i!==l.index;t.save(),t.globalAlpha=j?.4:1;const y=Es*r;t.beginPath(),t.moveTo(p+y,u),t.lineTo(p+h-y,u),t.quadraticCurveTo(p+h,u,p+h,u+y),t.lineTo(p+h,u+w-y),t.quadraticCurveTo(p+h,u+w,p+h-y,u+w),t.lineTo(p+y,u+w),t.quadraticCurveTo(p,u+w,p,u+w-y),t.lineTo(p,u+y),t.quadraticCurveTo(p,u,p+y,u),t.closePath(),t.fillStyle=g,t.fill(),t.strokeStyle="rgba(0,0,0,0.2)",t.lineWidth=1*r,t.stroke();const k=4*r,R=l.w>36&&l.h>20,I=l.w>36&&l.h>32;if(R){const z=11*r;if(I){const H=a>0?x.size/a*100:0;t.font=`500 ${8*r}px ${lt}`,t.fillStyle="rgba(0,0,0,0.6)",t.textBaseline="alphabetic",t.textAlign="left",t.fillText(`${H.toFixed(1)}%`,p+k,u+w-k-z)}t.font=`600 ${9*r}px ${lt}`,t.fillStyle="rgba(0,0,0,0.85)",t.textBaseline="alphabetic",t.textAlign="left",t.fillText(x.name,p+k,u+w-k)}t.restore()}}function Os(t,n,s){for(const a of t)if(n>=a.x&&n<=a.x+a.w&&s>=a.y&&s<=a.y+a.h)return a.index;return null}function Fs({data:t,total:n,color:s,position:a,containerWidth:i,isAirtime:r}){if(!t||!a)return null;const l=(t.value/n*100).toFixed(1),x=160,u=i-a.x=6e4?`${(t/6e4).toFixed(1)}m`:t>=1e3?`${(t/1e3).toFixed(1)}s`:`${Math.round(t)}ms`}function Hs({sortedTypes:t,aggregateShares:n,mode:s="share"}){var O,N,m;const[a,i]=c.useState(null),[r,l]=c.useState(null),[x,o]=c.useState(0),[p,u]=c.useState(null),h=c.useRef(null),w=c.useRef(null),g=c.useRef([]),j=s==="airtime",y=c.useMemo(()=>t.reduce((f,v)=>f+(j?v.totalAirtime:v.totalCount),0),[t,j]),k=c.useMemo(()=>t.map((f,v)=>({name:f.label,size:j?f.totalAirtime:f.totalCount,index:v,typeNum:f.typeNum,key:f.key})),[t,j]);c.useEffect(()=>{const f=w.current;if(!f)return;const v=f.parentElement;if(!v)return;const E=v.getBoundingClientRect(),$=E.width,T=E.height;if($<=0||T<=0)return;const W=window.devicePixelRatio||1;f.width=Math.floor($*W),f.height=Math.floor(T*W),f.style.width=`${$}px`,f.style.height=`${T}px`;const V=k.map(U=>U.size),ee=ct(V,0,0,$,T);g.current=ee;const J=f.getContext("2d");J&&(J.clearRect(0,0,f.width,f.height),mt(J,ee,k,y,a,W))},[k,y,a]),c.useEffect(()=>{const f=h.current;if(!f)return;const v=new ResizeObserver(()=>{const E=w.current;if(!E)return;const $=f.getBoundingClientRect(),T=$.width,W=$.height;if(T<=0||W<=0)return;const V=window.devicePixelRatio||1;E.width=Math.floor(T*V),E.height=Math.floor(W*V),E.style.width=`${T}px`,E.style.height=`${W}px`;const ee=k.map(D=>D.size),J=ct(ee,0,0,T,W);g.current=J;const U=E.getContext("2d");U&&(U.clearRect(0,0,E.width,E.height),mt(U,J,k,y,a,V))});return v.observe(f),()=>v.disconnect()},[k,y]);const R=c.useCallback(f=>{const v=h.current;if(!v)return;const E=v.getBoundingClientRect(),$=f.clientX-E.left,T=f.clientY-E.top,W=Os(g.current,$,T);i(W),W!==null?(o(E.width),l({x:$,y:T})):l(null)},[]),I=c.useCallback(()=>{i(null),l(null)},[]),z=c.useCallback(f=>{if(u(f),f){const v=k.findIndex(E=>E.key===f);i(v>=0?v:null)}else i(null)},[k]),H=a!==null?{name:((O=k[a])==null?void 0:O.name)??"",value:((N=k[a])==null?void 0:N.size)??0}:null,q=a!==null?Ce((m=k[a])==null?void 0:m.typeNum):"";return t.length===0||y===0?e.jsxs("div",{className:"h-full flex items-center justify-center text-fg-muted",children:[e.jsx(ve,{className:"w-6 h-6 mr-2 opacity-50"}),e.jsx("span",{children:"No packet type data available"})]}):e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsx("div",{className:"flex-1 min-h-0 relative",children:e.jsxs("div",{className:"absolute overflow-hidden radius-inner depth-stroke-inset bg-chart-inner",style:{left:Ls,right:0,top:0,bottom:Is},ref:h,onMouseMove:R,onMouseLeave:I,children:[e.jsx("canvas",{ref:w,className:"absolute inset-0",style:{cursor:"default"}}),e.jsx(Fs,{data:H,total:y,color:q,position:r,containerWidth:x,isAirtime:j})]})}),e.jsx("div",{style:{minHeight:Ps},children:e.jsx(st,{sortedTypes:t,highlightedType:p,onTypeHover:z,aggregateShares:n})})]})}const We=32,Ue=20,Bs=300;function ye(t){return t>=1e9?`${(t/1e9).toFixed(1)} Gb`:t>=1e6?`${(t/1e6).toFixed(1)} Mb`:t>=1e3?`${(t/1e3).toFixed(1)} Kb`:`${t.toFixed(0)} B`}function $s({packets:t,mode:n,startTs:s,endTs:a,radioConfig:i,bucketCount:r,lockedYMax:l,legendMinH:x}){const o=c.useMemo(()=>jt(),[]),p=o.blue,u=o.red,h=o.yellow,[w,g]=c.useState(null),{trendData:j,totals:y}=c.useMemo(()=>{if(t.length===0)return{trendData:[],totals:{rxBytes:0,txBytes:0,rxAirtime:0,txAirtime:0}};const N=a-s,m=Math.min(Math.ceil(N/Bs),r),f=N/m,v=[];let E=0,$=0,T=0,W=0;for(const B of t){const b=B.timestamp;if(b=a)continue;const S=Je(B),C=ke(B,{spreadingFactor:i.sf,bandwidthHz:i.bw,codingRate:i.cr,preambleLength:i.preamble}),P={timestamp:b,rxAirtime:0,txAirtime:0,rxBytes:0,txBytes:0};B.transmitted?(P.txAirtime=C,P.txBytes=S,$+=S,W+=C):(P.rxAirtime=C,P.rxBytes=S,E+=S,T+=C),v.push(P)}v.sort((B,b)=>B.timestamp-b.timestamp);const V=new Float64Array(v.length+1),ee=new Float64Array(v.length+1),J=new Float64Array(v.length+1),U=new Float64Array(v.length+1),D=new Float64Array(v.length);for(let B=0;B{let b=0,S=D.length;for(;b>>1;D[C]0?Z:null,tx:de>0?de:null})}else{const Z=V[P]-V[C],de=ee[P]-ee[C],pe=Z/re*100,fe=de/re*100;te.push({timestamp:b,rx:pe>0?pe:null,tx:fe>0?fe:null})}}const ae=2/31;let se=null;return{trendData:te.map(B=>{const b=B.rx;return b!==null&&b>0&&(se===null?se=b:se=ae*b+(1-ae)*se),{...B,rxSmooth:se!==null&&se>0?se:null}}),totals:{rxBytes:E,txBytes:$,rxAirtime:T,txAirtime:W}}},[t,s,a,r,n,i]),k=c.useMemo(()=>{if(j.length===0)return n==="share"?100:10;let N=0;for(const f of j){const v=f.rx??0,E=f.tx??0;v>N&&(N=v),E>N&&(N=E)}const m=N*1.1;return n==="share"?m<=100?100:m<=500?Math.ceil(m/100)*100:m<=1e3?Math.ceil(m/200)*200:m<=5e3?Math.ceil(m/500)*500:m<=1e4?Math.ceil(m/1e3)*1e3:Math.ceil(m/5e3)*5e3:Math.max(1,Math.ceil(m))},[j,n]),R=l??k,I=c.useMemo(()=>{if(w!==null&&j[w]){const N=j[w],m=N.rx??0,f=N.tx??0;return n==="share"?{rx:ye(m),tx:ye(f),total:ye(m+f),isHovered:!0}:{rx:`${m.toFixed(2)}%`,tx:`${f.toFixed(2)}%`,total:`${(m+f).toFixed(2)}%`,isHovered:!0}}if(n==="share")return{rx:ye(y.rxBytes),tx:ye(y.txBytes),total:ye(y.rxBytes+y.txBytes),isHovered:!1};{let N=0,m=0,f=0;for(const $ of j)($.rx!==null||$.tx!==null)&&(N+=$.rx??0,m+=$.tx??0,f++);const v=f>0?N/f:0,E=f>0?m/f:0;return{rx:`${v.toFixed(2)}%`,tx:`${E.toFixed(2)}%`,total:`${(v+E).toFixed(2)}%`,isHovered:!1}}},[w,j,y,n]),z=c.useMemo(()=>{const N=a-s,m=N/3600;return[0,.25,.5,.75,1].map(v=>{const E=s+N*v,$=new Date(E*1e3),T=$.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!1}),W=$.toLocaleDateString([],{weekday:"short"}),V=v===.25||v===.75;return{pct:v,label:m>=24?`${W} ${T}`:T,mobileHidden:V}})},[s,a]),H=c.useCallback(N=>{g(N)},[]);if(j.length===0)return e.jsxs("div",{className:"h-full flex items-center justify-center text-fg-muted",children:[e.jsx(ve,{className:"w-6 h-6 mr-2 opacity-50"}),e.jsx("span",{children:"No packet data available"})]});const q=c.useMemo(()=>n==="airtime"?R<=5?1:R<=10?2:R<=20?5:Math.ceil(R/5):R<=100?25:R<=500?100:R<=1e3?200:R<=5e3?1e3:R<=1e4?2e3:Math.ceil(R/5e3)*1e3,[R,n]),O=c.useMemo(()=>{const N=[];for(let m=0;m<=R;m+=q){const f=(1-m/R)*100;let v;n==="airtime"?v=`${m}%`:m>=1e6?v=`${(m/1e6).toFixed(1)}M`:m>=1e3?v=`${(m/1e3).toFixed(0)}K`:v=`${m}`,N.push({pos:f,label:v})}return N},[R,q,n]);return e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsxs("div",{className:"flex-1 min-h-0 relative",children:[e.jsx("div",{className:"absolute top-0 left-0 flex flex-col justify-between",style:{width:We,bottom:Ue},children:O.map((N,m)=>e.jsx("span",{className:"type-data-xs text-fg-secondary text-right pr-1.5",style:{position:"absolute",top:`${N.pos}%`,transform:m===0?"translateY(-100%)":m===O.length-1?"none":"translateY(-50%)",right:0},children:N.label},m))}),e.jsx("div",{className:"absolute overflow-hidden radius-inner depth-stroke-inset bg-chart-inner",style:{left:We,right:0,top:0,bottom:Ue},children:e.jsx(_t,{data:j,yAxisMode:n==="share"?"share":"airtime",yMax:R,onHover:H,startTs:s,endTs:a,externalAxes:!0})}),e.jsx("div",{className:"absolute left-0 right-0 bottom-0 flex items-center pointer-events-none",style:{left:We,height:Ue,paddingTop:4},children:z.map((N,m)=>e.jsx("span",{className:`absolute type-data-xs text-fg-muted/60 tabular-nums ${N.mobileHidden?"hidden sm:inline":""}`,style:{left:`${N.pct*100}%`,transform:N.pct===0?"translateX(0)":N.pct===1?"translateX(-100%)":"translateX(-50%)"},children:N.label},m))})]}),e.jsxs("div",{className:"flex items-end justify-between pb-1",style:{minHeight:x},children:[e.jsxs("div",{className:"flex items-center gap-3 sm:gap-5 type-data-sm pl-2 sm:pl-11",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("div",{className:"w-4 sm:w-5 h-[2px] rounded-full",style:{backgroundColor:p}}),e.jsx("span",{className:"text-fg-secondary",children:"RX"})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("div",{className:"w-4 sm:w-5 h-[2px] rounded-full",style:{backgroundColor:u}}),e.jsx("span",{className:"text-fg-secondary",children:"TX"})]}),e.jsxs("div",{className:"hidden sm:flex items-center gap-1.5",children:[e.jsx("div",{className:"w-5 h-[2px] rounded-full",style:{backgroundColor:h}}),e.jsx("span",{className:"text-fg-secondary",children:"Avg"})]})]}),e.jsxs("div",{className:"flex flex-wrap gap-4 sm:gap-8",children:[e.jsxs("div",{className:"flex items-end gap-2",children:[e.jsx("div",{className:"type-data-xl text-fg-primary",children:I.rx}),e.jsx(Fe,{color:"zinc",className:"mb-0.5 sm:mb-1",children:"RX"})]}),e.jsxs("div",{className:"flex items-end gap-2",children:[e.jsx("div",{className:"type-data-xl text-fg-primary",children:I.tx}),e.jsx(Fe,{color:"zinc",className:"mb-0.5 sm:mb-1",children:"TX"})]})]})]})]})}const dt=Rt;class zs{constructor(){xe(this,"worker",null);xe(this,"listeners",new Set);xe(this,"currentResult",null);xe(this,"isComputing",!1);xe(this,"debounceTimer",null);xe(this,"debounceMs",250);xe(this,"lastCacheKey",null)}ensureWorker(){if(this.worker)return this.worker;if(typeof window>"u")return null;try{this.worker=new Worker(new URL("/assets/bucketing.worker-D0TT0k8y.js",import.meta.url),{type:"module"}),this.worker.onmessage=n=>{this.handleWorkerMessage(n.data)},this.worker.onerror=n=>{console.error("[BucketingService] Worker error:",n),this.isComputing=!1,this.notifyListeners()}}catch(n){console.error("[BucketingService] Failed to initialize worker:",n)}return this.worker}handleWorkerMessage(n){if(this.isComputing=!1,n.type==="error"){this.currentResult=null,this.notifyListeners();return}const s=n.payload;this.currentResult={points:s.points,rawValues:s.rawValues,packetTypes:s.packetTypes,timestamps:s.timestamps,count:s.count,minTime:s.minTime,maxTime:s.maxTime,minValue:s.minValue,maxValue:s.maxValue,rawMinValue:s.rawMinValue,rawMaxValue:s.rawMaxValue,unit:"%",stats:{p5:s.p5,p50:s.p50,p95:s.p95,uniqueValues:s.uniqueValues,topValues:s.topValues}},this.notifyListeners()}notifyListeners(){for(const n of this.listeners)try{n(this.currentResult,this.isComputing)}catch(s){console.error("[BucketingService] Listener error:",s)}}isCacheHit(n){return!this.lastCacheKey||!this.currentResult?!1:this.lastCacheKey.startTs===n.startTs&&this.lastCacheKey.endTs===n.endTs&&this.lastCacheKey.mode===n.mode&&this.lastCacheKey.packetCount===n.packetCount}compute(n,s,a,i,r){if(n.length===0||!r){this.currentResult=null,this.notifyListeners();return}const l={startTs:s,endTs:a,mode:i,packetCount:n.length};this.isCacheHit(l)||(this.debounceTimer&&clearTimeout(this.debounceTimer),this.debounceTimer=setTimeout(()=>{this.debounceTimer=null,this.computeInternal(n,s,a,i,r,l)},this.debounceMs))}computeInternal(n,s,a,i,r,l){const x=this.ensureWorker();if(!x)return;const o=n.length,p=new Float64Array(o),u=new Float64Array(o),h=new Uint16Array(o),w=new Uint8Array(o),g={spreadingFactor:r.sf,bandwidthHz:r.bw,codingRate:r.cr,preambleLength:r.preamble};for(let y=0;y{this.listeners.delete(n)}}clear(){this.currentResult=null,this.lastCacheKey=null,this.notifyListeners()}terminate(){this.debounceTimer&&clearTimeout(this.debounceTimer),this.worker&&(this.worker.terminate(),this.worker=null),this.listeners.clear()}}const Ge=new zs;function Ws(t,n,s,a,i){const[r,l]=c.useState(()=>Ge.getResult());return c.useEffect(()=>Ge.subscribe(x=>{l(x)}),[]),c.useEffect(()=>{Ge.compute(t,n,s,a,i)},[t,n,s,a,i]),r}function Us({mode:t,packets:n,startTs:s,endTs:a,radioConfig:i,sortedTypes:r,aggregateShares:l,noiseFloorAnomalies:x,showNoiseFloorOverlay:o,overlayOpacity:p=.5,startLabel:u,endLabel:h,lockedYMax:w,legendMinH:g,dotSize:j,dotOpacity:y}){const[k,R]=c.useState(null),[I,z]=c.useState(null),H=c.useMemo(()=>(a-s)/3600,[s,a]),q=c.useCallback(U=>{z(U)},[]),N=Ws(n,s,a,t==="share"?"share":"airtime",i),[m,f]=c.useState(null),v=c.useCallback((U,D)=>{R(U),f(D??null)},[]),E=c.useMemo(()=>{if(m===null||!N||N.count===0)return null;const U=s+m*(a-s);let D;H>=168?D=75:H>=72?D=35:H>=24?D=15:H>=3?D=10:D=5;const K=D*60/2;return{start:U-K,end:U+K}},[m,N,s,a,H]),$=c.useMemo(()=>E?new Date((E.start+E.end)/2*1e3).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!1}):null,[E]),T=c.useMemo(()=>{if(k===null||!E)return null;const U=$??"",{start:D,end:K}=E,te=n.filter(b=>b.timestamp>=D&&b.timestamp({key:b.key,label:b.label,value:0,color:dt(b.typeNum)}))};const re=new Map,ae=new Map;let se=0,le=0;for(const b of te){const C=`TYPE_${b.type??b.payload_type??-1}`;if(re.set(C,(re.get(C)??0)+1),se++,i){const P=ke(b,{spreadingFactor:i.sf,bandwidthHz:i.bw,codingRate:i.cr,preambleLength:i.preamble});ae.set(C,(ae.get(C)??0)+P),le+=P}}const B=r.map(b=>{let S;return t==="airtime"?S=le>0?(ae.get(b.key)??0)/le:0:S=se>0?(re.get(b.key)??0)/se:0,{key:b.key,label:b.label,value:S,color:dt(b.typeNum)}});return{timestamp:(D+K)/2,timeLabel:U,items:B}},[k,E,$,n,r,t,i]),W=t==="share",V=w??(N==null?void 0:N.maxValue)??(W?240:10),ee=c.useMemo(()=>{if(!W)return 5;const U=[10,20,25,50,100,200,250,500,1e3],D=V/4.5;for(const K of U)if(K>=D)return K;return V>5e3?Math.ceil(D/1e3)*1e3:Math.ceil(D/100)*100},[V,W]),J=c.useMemo(()=>{const U=[];for(let D=0;D<=V;D+=ee){const K=(1-D/V)*100;U.push({pos:K,label:W?`${D}B`:`${D}%`})}return U},[V,ee,W]);return!N||N.count===0?e.jsxs("div",{className:"h-full flex items-center justify-center text-fg-muted",children:[e.jsx(ve,{className:"w-6 h-6 mr-2 opacity-50"}),e.jsx("span",{children:"No packet data available"})]}):e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsxs("div",{className:"flex-1 min-h-0 relative",children:[e.jsx("div",{className:"absolute top-0 left-0 flex flex-col justify-between",style:{width:32,bottom:20},children:J.map((U,D)=>e.jsx("span",{className:"type-data-xs text-fg-secondary text-right pr-1.5",style:{position:"absolute",top:`${U.pos}%`,transform:D===0?"translateY(-100%)":D===J.length-1?"none":"translateY(-50%)",right:0},children:U.label},D))}),e.jsxs("div",{className:"absolute overflow-hidden radius-inner depth-stroke-inset bg-chart-inner",style:{left:32,right:0,top:0,bottom:20},children:[e.jsx(Tt,{scatterData:N,yAxisMode:t==="share"?"share":"airtime",onHover:v,noiseFloorAnomalies:x,showNoiseFloorOverlay:o,overlayOpacity:p,highlightedType:I,timeRangeHours:H,yAxisMaxOverride:w,dotSize:j,dotOpacity:y,startTs:s,endTs:a,externalAxes:!0}),$&&e.jsx("div",{className:"absolute top-1 right-1 px-2 py-0.5 bg-elevated/90 rounded type-data-xs text-sys-indigo pointer-events-none z-10",children:$})]}),u&&h&&e.jsxs("div",{className:"absolute left-0 right-0 bottom-0 flex justify-between pointer-events-none type-data-xs text-fg-muted/60",style:{left:32,height:20,paddingTop:4},children:[e.jsx("span",{children:u}),e.jsx("span",{children:h})]})]}),e.jsx("div",{style:{minHeight:g},children:e.jsx(st,{sortedTypes:r,highlightedType:I,onTypeHover:q,aggregateShares:l,hoverData:T})})]})}function Gs({mode:t,onChange:n}){return e.jsxs("div",{className:"toggle-group toggle-group-sm",children:[e.jsx("button",{onClick:()=>n("share"),className:`toggle-group-item ${t==="share"?"active":""}`,children:"Total"}),e.jsx("button",{onClick:()=>n("airtime"),className:`toggle-group-item ${t==="airtime"?"active":""}`,children:"Airtime"})]})}function Vs({smoothing:t,onChange:n}){return e.jsxs("div",{className:"toggle-group toggle-group-sm",children:[e.jsx("button",{onClick:()=>n("stats"),className:`toggle-group-item ${t==="stats"?"active":""}`,title:"Statistics view (scatter plot)",children:e.jsx(Ms,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:()=>n("trend"),className:`toggle-group-item ${t==="trend"?"active":""}`,title:"Trend line chart",children:e.jsx(Ns,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:()=>n("ema"),className:`toggle-group-item ${t==="ema"?"active":""}`,title:"Stacked area (moderate smoothing)",children:e.jsx(ve,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:()=>n("ultra"),className:`toggle-group-item ${t==="ultra"?"active":""}`,title:"Stacked area (heavy smoothing)",children:e.jsx(As,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:()=>n("mosaic"),className:`toggle-group-item ${t==="mosaic"?"active":""}`,title:"Mosaic view (treemap)",children:e.jsx(Ss,{className:"w-3.5 h-3.5"})})]})}function qs({enabled:t,onChange:n,anomalyCount:s=0,showTuning:a=!1,onTuningChange:i}){return e.jsxs("div",{className:"relative inline-flex items-center gap-1",children:[t&&i&&e.jsx("button",{onClick:()=>i(!a),className:`toggle-group toggle-group-sm ${a?"active":""}`,title:a?"Hide tuning panel":"Show tuning panel",children:e.jsx("span",{className:`toggle-group-item ${a?"active":""}`,children:e.jsx(bs,{className:"w-3.5 h-3.5"})})}),e.jsx("button",{onClick:()=>n(!t),className:`toggle-group toggle-group-sm ${t?"active":""}`,title:t?"Hide noise floor anomalies":"Show noise floor anomalies",children:e.jsx("span",{className:`toggle-group-item ${t?"active":""}`,children:e.jsx(ns,{className:"w-3.5 h-3.5"})})}),s>0&&e.jsx("span",{className:"absolute -top-2 -right-2 min-w-[18px] h-[18px] px-1 rounded-full bg-sys-red text-white text-xs font-bold flex items-center justify-center pointer-events-none z-10",children:s>99?"99+":s})]})}const vt=[{target:"PacketAnalyzer",fn:"type",minStage:1},{target:"PacketAnalyzer",fn:"airtime",minStage:1,when:as}];tt(vt);const ht=360,Ks=500,Ys={sf:10,bw:25e4,cr:5,preamble:8},Ve=32;function xt(t,n){const s=new Date(t*1e3),a=l=>l.toString().padStart(2,"0"),i=`${a(s.getHours())}:${a(s.getMinutes())}`;return n<24?i:`${["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][s.getMonth()]} ${s.getDate()} ${i}`}function Xs(t){return yt[t]??`TYPE_${t.toString(16).toUpperCase()}`}function Zs(t,n){const s=new Map;for(const i of t){const r=i.type??i.payload_type??-1,l=ke(i,{spreadingFactor:n.sf,bandwidthHz:n.bw,codingRate:n.cr,preambleLength:n.preamble}),x=s.get(r)??{count:0,airtime:0};s.set(r,{count:x.count+1,airtime:x.airtime+l})}const a=[];for(const[i,r]of s)a.push({typeNum:i,key:`TYPE_${i}`,label:Xs(i),totalCount:r.count,totalAirtime:r.airtime});return a.sort((i,r)=>r.totalCount-i.totalCount)}function Qs(t,n,s,a,i,r,l=0){const x=s-n,o=x/a,p=o*1e3,u=x/3600,h=n-l*o,w=s+l*o,g=a+2*l,j=[];for(let y=0;y=24?R.toLocaleDateString([],{weekday:"short",hour:"2-digit",minute:"2-digit",hour12:!1}):R.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!1}),z={timestamp:k,time:I,counts:{},shares:{},airtimes:{},total:0,totalAirtime:0,bucketDurationMs:p};for(const H of r)z.counts[H.key]=0,z.airtimes[H.key]=0;j.push(z)}for(const y of t){const k=y.timestamp;if(k=w)continue;const R=Math.min(Math.floor((k-h)/o),g-1),I=`TYPE_${y.type??y.payload_type??-1}`;j[R].counts[I]=(j[R].counts[I]??0)+1,j[R].total++;const z=ke(y,{spreadingFactor:i.sf,bandwidthHz:i.bw,codingRate:i.cr,preambleLength:i.preamble});j[R].airtimes[I]=(j[R].airtimes[I]??0)+z,j[R].totalAirtime+=z}for(const y of j)for(const k of r)y.shares[k.key]=y.total>0?y.counts[k.key]/y.total*100:0;return{buckets:j,visibleStart:l,visibleEnd:l+a}}function Js(t,n){const s=t.length;if(s===0)return[];if(n<.5)return[...t];const a=Math.sqrt(12*n*n/3+1);let i=Math.floor(a);i%2===0&&i--;const r=i+2,l=(12*n*n-3*i*i-12*i-9)/(-4*i-4),x=Math.round(l),o=[x>0?i:r,x>1?i:r,x>2?i:r];let p=new Float32Array(t);const u=new Float32Array(s);for(const h of o){const w=(h-1)/2;en(p,u,s,w);const g=p;p=u,u.set(g)}return Array.from(p)}function en(t,n,s,a){const i=a*2+1;let r=0;for(let l=0;l<=a;l++)r+=t[Math.min(l,s-1)];for(let l=0;l=0&&(r-=t[o],l--),pnew Array(u).fill(0));for(let O=0;O0)for(let m=0;m0)for(let f=0;f0?R=j.map(O=>Js(O,y)):R=j.map(O=>tn(O,k));for(let O=0;O0){const m=1/N;for(let f=0;fht?Math.ceil(w/ht):1,z=Math.ceil(w/I),H=[];for(let O=0;O0){const T=1/E;for(let W=0;W=s)continue;const w=Math.min(Math.floor((h-n)/300),x-1);o[w]+=ke(u,{spreadingFactor:i.sf,bandwidthHz:i.bw,codingRate:i.cr,preambleLength:i.preamble})}let p=0;for(let u=0;up&&(p=h)}return Math.max(1,Math.ceil(p*1.1))}else{let o=0;for(const p of t){const u=p.timestamp;if(u=s)continue;const h=Je(p);h>o&&(o=h)}return o<=240?240:Math.ceil(o*1.1/50)*50}}function on({packets:t,allPackets:n,startTs:s,endTs:a,parentStartTs:i,parentEndTs:r,bucketCount:l,radioConfig:x=Ys,mode:o="share",smoothing:p="stats",noiseFloorAnomalies:u=null,showNoiseFloorOverlay:h=!1,overlayOpacity:w=.5,dotSize:g,dotOpacity:j}){et(vt);const y=Dt(),[k,R]=c.useState(null),[I,z]=c.useState(null),[H,q]=c.useState([]),O=c.useRef(null),N=c.useRef(0);c.useEffect(()=>{const b=Math.abs(t.length-N.current);if(b===0&&H.length>0)return;O.current&&clearTimeout(O.current);const S=b>100?50:Ks;return O.current=setTimeout(()=>{N.current=t.length,q(t)},S),()=>{O.current&&clearTimeout(O.current)}},[t,H.length]);const m=c.useMemo(()=>Zs(H,x),[H,x]),f=c.useMemo(()=>{if(p!=="ema"&&p!=="ultra")return 0;const S=(a-s)/l,{handleSize:C}=kt(p,S,l);return C},[p,s,a,l]),v=c.useMemo(()=>Qs(H,s,a,l,x,m,f),[H,s,a,l,x,m,f]),E=c.useMemo(()=>m.reduce((b,S)=>b+S.totalCount,0),[m]),$=c.useMemo(()=>m.reduce((b,S)=>b+S.totalAirtime,0),[m]),{sortedTypes:T,aggregateShares:W}=c.useMemo(()=>{const b=new Map,S=o==="share"?E:$;if(S>0)for(const P of m){const Z=o==="share"?P.totalCount:P.totalAirtime;b.set(P.key,Z/S)}return{sortedTypes:[...m].sort((P,Z)=>(b.get(Z.key)??0)-(b.get(P.key)??0)),aggregateShares:b}},[m,E,$,o]),V=c.useMemo(()=>an(v,o,T,p,s,a,l),[v,o,T,p,s,a,l]),ee=c.useCallback(b=>R(b),[]),J=c.useCallback(b=>z(b),[]),U=c.useCallback(b=>R(b),[]),D=c.useMemo(()=>{if(I===null||!V[I])return null;const b=V[I];return{timestamp:b.timestamp,timeLabel:b.time,items:T.map(S=>({key:S.key,label:S.label,value:b[S.key]??0,color:Ce(S.typeNum)}))}},[I,V,T]),K=c.useMemo(()=>{const b=V.map(C=>C.timestamp),S=T.map(C=>({key:C.key,label:C.label,color:Ce(C.typeNum),values:V.map(P=>P[C.key]??0)}));return{timestamps:b,series:S}},[V,T]),te=null,re=n&&i!==void 0&&r!==void 0&&(s!==i||a!==r),ae=c.useMemo(()=>{if(!(!re||!n||i===void 0||r===void 0))return rn(n,i,r,o,x)},[re,n,i,r,o,x]);if(H.length===0)return t.length===0?e.jsxs("div",{className:"h-full flex items-center justify-center text-fg-muted",children:[e.jsx(ve,{className:"w-6 h-6 mr-2 opacity-50"}),e.jsx("span",{children:"No packet data available"})]}):null;if(p==="mosaic")return e.jsx(Hs,{sortedTypes:T,aggregateShares:W,mode:o});const se=(a-s)/3600,le=xt(s,se),B=xt(a,se);return p==="stats"?e.jsx(Us,{mode:o,packets:H,startTs:s,endTs:a,radioConfig:x,sortedTypes:T,aggregateShares:W,noiseFloorAnomalies:u,showNoiseFloorOverlay:h,overlayOpacity:w,startLabel:le,endLabel:B,lockedYMax:ae,legendMinH:qe,dotSize:g,dotOpacity:j}):p==="trend"?e.jsx($s,{packets:H,mode:o,startTs:s,endTs:a,radioConfig:x,bucketCount:l,lockedYMax:ae,legendMinH:qe}):e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsxs("div",{className:"flex-1 min-h-0 relative",children:[e.jsx("div",{className:"absolute top-0 left-0 flex flex-col justify-between",style:{width:Ve,bottom:20},children:[0,20,40,60,80,100].map((b,S,C)=>e.jsxs("span",{className:"type-data-xs text-fg-secondary text-right pr-1.5",style:{position:"absolute",top:`${(1-b/100)*100}%`,transform:S===0?"translateY(-100%)":S===C.length-1?"none":"translateY(-50%)",right:0},children:[b,"%"]},b))}),e.jsx("div",{className:"absolute overflow-hidden radius-inner depth-stroke-inset bg-chart-inner",style:{left:Ve,right:0,top:0,bottom:20},children:e.jsx(Et,{timestamps:K.timestamps,series:K.series,highlightedKey:k,cursorColor:y.cursor,onHover:J,onSeriesHover:U,overlayLine:te,startTs:s,endTs:a,externalAxes:!0})}),e.jsxs("div",{className:"absolute left-0 right-0 bottom-0 flex justify-between pointer-events-none type-data-xs text-fg-muted/60",style:{left:Ve,height:20,paddingTop:4},children:[e.jsx("span",{children:le}),e.jsx("span",{children:B})]})]}),e.jsx("div",{style:{minHeight:qe},children:e.jsx(st,{sortedTypes:T,highlightedType:k,onTypeHover:ee,aggregateShares:W,hoverData:D})})]})}const ln=c.memo(on),Ke={ZOOM_DURATION:400,BLINK_DURATION:600},oe={PADDING:6,DOT_RADIUS:5,DOT_RADIUS_HOVERED:7,LOCAL_DOT_RADIUS:5,CARDINAL_FONT_SIZE:10,INTERCARDINAL_FONT_SIZE:9,LABEL_INSET:8,DATA_HEADROOM:1.08},cn={"1x":1,"2x":2,"4x":4,"8x":8,"16x":16,"36x":36},pt=[1,5,10,25,50,100,150],mn=22.5,St=mn*Math.PI/180,ft=Math.sin(St),gt=Math.cos(St);function un(t,n,s,a){const i=Math.PI/180,r=(a-n)*i,l=t*i,x=s*i,o=Math.sin(r)*Math.cos(x),p=Math.cos(l)*Math.sin(x)-Math.sin(l)*Math.cos(x)*Math.cos(r);return(Math.atan2(o,p)*180/Math.PI+360)%360}function dn(t,n,s,a){const r=Math.PI/180,l=(s-t)*r,x=(a-n)*r,o=Math.sin(l/2)**2+Math.cos(t*r)*Math.cos(s*r)*Math.sin(x/2)**2;return 6371*2*Math.atan2(Math.sqrt(o),Math.sqrt(1-o))}const hn=[{min:10,label:"Excellent"},{min:7,label:"Very Good"},{min:4,label:"Good"},{min:1,label:"Fair+"},{min:-2,label:"Fair"},{min:-5,label:"Fair-"},{min:-8,label:"Poor"},{min:-11,label:"Bad"},{min:-1/0,label:"Critical"}];function xn(t){var n;return((n=hn.find(s=>t>=s.min))==null?void 0:n.label)??"Critical"}function bt(t,n,s){const a=Ht(t,s);return n[a]||"#808080"}function pn({neighbors:t,quickNeighbors:n,localLat:s,localLon:a,onStatsChange:i,title:r,badge:l,stats:x}){const[o,p]=c.useState(null),[u,h]=c.useState(new Set),[w,g]=c.useState({width:0,height:0}),[j,y]=c.useState("1x"),[k,R]=c.useState(1),I=c.useRef(null),z=c.useRef({}),H=c.useRef(null),q=c.useRef(k);q.current=k;const O=Lt(),N=It(),m=Pt(),f=Ot(),v=jt(),E=Ft(),$=f?m.primary:m.secondary,T=f?.15:.4,W=f?.08:.25,V=f?v.blue:m.primary;c.useEffect(()=>{const d=H.current;if(!d)return;const L=new ResizeObserver(_=>{for(const F of _){const{width:Y,height:Q}=F.contentRect;Y>0&&Q>0&&g({width:Y,height:Q})}});L.observe(d);const A=d.getBoundingClientRect();return A.width>0&&A.height>0&&g({width:A.width,height:A.height}),()=>L.disconnect()},[]);const ee=c.useMemo(()=>{const d=new Set;if(n)for(const L of n)d.add(L.hash);return d},[n]),J=c.useMemo(()=>{const d=new Map;if(n)for(const L of n)d.set(L.hash,{snr:L.avgSnr,rssi:L.avgRssi});return d},[n]),{processedNeighbors:U,maxDistance:D,totalNeighbors:K,zeroHopCount:te}=c.useMemo(()=>{const d=[];for(const[_,F]of Object.entries(t)){if(!F.latitude||!F.longitude||F.latitude===0||F.longitude===0||!ee.has(_))continue;const Q=un(s,a,F.latitude,F.longitude),ne=dn(s,a,F.latitude,F.longitude),X=J.get(_);d.push({hash:_.slice(0,8),name:F.node_name||F.name||"Unknown",snr:(X==null?void 0:X.snr)??F.snr??null,rssi:(X==null?void 0:X.rssi)??F.rssi??null,bearing:Q,distance:ne,normalizedDistance:0,lastSeen:F.last_seen,isZeroHop:!0})}const A=(d.length>0?Math.max(...d.map(_=>_.distance)):0)*oe.DATA_HEADROOM;return d.sort((_,F)=>(_.snr??-1/0)-(F.snr??-1/0)),{processedNeighbors:d,maxDistance:A,totalNeighbors:d.length,zeroHopCount:d.length}},[t,s,a,ee,J]);c.useEffect(()=>{i==null||i({zeroHopCount:te,totalCount:K,maxDistanceKm:D})},[te,K,D]),c.useEffect(()=>{const d=cn[j],L=q.current;I.current&&cancelAnimationFrame(I.current);const A=performance.now(),_=F=>{const Y=F-A,Q=Math.min(Y/Ke.ZOOM_DURATION,1),ne=rs(Q),X=L+(d-L)*ne;R(X),Q<1?I.current=requestAnimationFrame(_):I.current=null};return I.current=requestAnimationFrame(_),()=>{I.current&&cancelAnimationFrame(I.current)}},[j]);const re=D/k,ae=c.useMemo(()=>pt.filter(d=>d<=re*1.1),[re]);c.useEffect(()=>{const d=[];for(const A of U){const _=z.current[A.hash];_!==void 0&&_!==A.lastSeen&&d.push(A.hash),z.current[A.hash]=A.lastSeen}if(d.length===0)return;queueMicrotask(()=>{h(A=>new Set([...A,...d]))});const L=setTimeout(()=>{h(A=>{const _=new Set(A);return d.forEach(F=>_.delete(F)),_})},Ke.BLINK_DURATION);return()=>clearTimeout(L)},[U]);const se=s!==0&&a!==0,le=c.useMemo(()=>{const{width:d,height:L}=w,A=d/2,_=L/2,F=Math.min(d,L),Y=Math.max(10,F/2-oe.PADDING),Q=Math.max(10,Y-oe.LABEL_INSET);return{width:d,height:L,centerX:A,centerY:_,radius:Q,labelRadius:Y}},[w]),{width:B,height:b,centerX:S,centerY:C,radius:P,labelRadius:Z}=le,de=c.useId(),pe=c.useCallback((d,L)=>{const A=d*Math.PI/180;return{x:S+P*L*Math.sin(A),y:C-P*L*Math.cos(A)}},[S,C,P]),fe=c.useCallback(d=>{const A={N:0,NE:45,E:90,SE:135,S:180,SW:225,W:270,NW:315}[d]*Math.PI/180;return{x:S+Z*Math.sin(A),y:C-Z*Math.cos(A)}},[S,C,Z]),_e=c.useCallback(d=>{p(d)},[]),Re=c.useCallback(d=>{y(d)},[]),Te=c.useCallback(d=>D<=0?0:d/D*k,[D,k]),De=d=>`${d}km`,Se=28,Ee=c.useMemo(()=>{const d=[{x:S,y:C-Z},{x:S+Z*Math.SQRT1_2,y:C-Z*Math.SQRT1_2}],L=ae.map(_=>{const F=_/D*k,Y=S+P*F*ft,Q=C-P*F*gt;return{km:_,scale:F,lx:Y,ly:Q}}).filter(_=>_.scale>=.02).sort((_,F)=>F.km-_.km),A=[];for(const _ of L){const F=A.some(Q=>{const ne=Q.lx-_.lx,X=Q.ly-_.ly;return Math.sqrt(ne*ne+X*X){const ne=Q.x-_.lx,X=Q.y-_.ly;return Math.sqrt(ne*ne+X*X)0&&w.height>0;return se?K===0?e.jsxs("div",{ref:H,className:"flex flex-col items-center justify-center h-full text-fg-secondary",children:[e.jsx(ze,{className:"w-8 h-8 mb-2 opacity-50"}),e.jsx("p",{children:"No nodes with location data"})]}):e.jsxs("div",{className:"flex h-full w-full overflow-visible",children:[e.jsxs("div",{ref:H,className:"relative flex-1 min-w-0 h-full overflow-visible -ml-4 sm:-ml-5",children:[Le&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"absolute depth-stroke-inset",style:{left:S-P-oe.LABEL_INSET-4,top:C-P-oe.LABEL_INSET-4,width:(P+oe.LABEL_INSET)*2+8,height:(P+oe.LABEL_INSET)*2+8,borderRadius:"50%",padding:4,boxSizing:"border-box",backgroundColor:f?"var(--zinc-925)":"var(--zinc-75)"}}),e.jsxs("svg",{width:B,height:b,className:"absolute inset-0 z-0",style:{overflow:"visible"},children:[e.jsxs("defs",{children:[e.jsx("style",{children:` + @keyframes neighbor-blink-scale { + 0%, 100% { + transform: scale(1); + opacity: 0; + } + 50% { + transform: scale(1.3); + opacity: 0.8; + } + } + .neighbor-blink-ring { + transform-origin: center; + animation: neighbor-blink-scale ${Ke.BLINK_DURATION}ms ease-out forwards; + } + `}),e.jsx("clipPath",{id:de,children:e.jsx("circle",{cx:S,cy:C,r:P})})]}),(()=>{const d=P+oe.LABEL_INSET+12,L=f?"rgba(255, 255, 255, 0.12)":"rgba(0, 0, 0, 0.15)",A=f?"rgba(59, 130, 246, 0.4)":"rgba(59, 130, 246, 0.5)",_=6,F=16,Y=4,Q=[0,90,180,270],ne=[45,135,225,315];return e.jsxs("g",{className:"radar-frame","aria-hidden":"true",children:[e.jsx("circle",{cx:S,cy:C,r:d,fill:"none",stroke:L,strokeWidth:1,strokeDasharray:"2 6"}),ne.map(X=>{const ie=X*Math.PI/180,ce=Math.cos(ie),me=Math.sin(ie),he=d+Y,M=d+Y+F,G=S+he*me,ge=C-he*ce,Ie=S+M*me,He=C-M*ce;return e.jsxs("g",{children:[e.jsx("line",{x1:G,y1:ge,x2:Ie,y2:He,stroke:A,strokeWidth:1}),e.jsx("line",{x1:Ie-4*ce,y1:He-4*me,x2:Ie+4*ce,y2:He+4*me,stroke:A,strokeWidth:1})]},`corner-${X}`)}),Q.map(X=>{const ie=X*Math.PI/180,ce=S+(d-_)*Math.sin(ie),me=C-(d-_)*Math.cos(ie),he=S+(d+2)*Math.sin(ie),M=C-(d+2)*Math.cos(ie);return e.jsx("line",{x1:ce,y1:me,x2:he,y2:M,stroke:L,strokeWidth:1},`tick-cardinal-${X}`)}),ne.map(X=>{const ie=X*Math.PI/180,ce=S+(d-4)*Math.sin(ie),me=C-(d-4)*Math.cos(ie),he=S+(d+1)*Math.sin(ie),M=C-(d+1)*Math.cos(ie);return e.jsx("line",{x1:ce,y1:me,x2:he,y2:M,stroke:L,strokeWidth:1},`tick-intercardinal-${X}`)})]})})(),(()=>{const d=P+oe.LABEL_INSET+4,L=[0,...pt.map(A=>{const _=Te(A);return _<=0?0:Math.min(P*_,d)}),d];return L.slice(0,-1).map((A,_)=>{const F=L[_+1],Y=F-A;return Y<.5||_%2!==0?null:e.jsx("circle",{cx:S,cy:C,r:(F+A)/2,fill:"none",stroke:"var(--subtle-fill)",strokeWidth:Y},`band-${_}`)})})(),ae.map(d=>{const L=Te(d);if(L<.02)return null;const A=Ee.some(Y=>Y.km===d),_=S+P*L*ft,F=C-P*L*gt;return e.jsx("g",{children:A&&e.jsx("text",{x:_+4,y:F-2,textAnchor:"start",dominantBaseline:"auto",fill:m.secondary,fontSize:10,fontFamily:Be,children:De(d)})},`ring-${d}`)}),["N","E","S","W"].map(d=>{const A={N:0,E:90,S:180,W:270}[d]*Math.PI/180;return e.jsx("line",{x1:S,y1:C,x2:S+P*Math.sin(A),y2:C-P*Math.cos(A),stroke:$,strokeOpacity:T,strokeWidth:1,strokeDasharray:"4 4"},d)}),["NE","SE","SW","NW"].map(d=>{const A={NE:45,SE:135,SW:225,NW:315}[d]*Math.PI/180;return e.jsx("line",{x1:S,y1:C,x2:S+P*Math.sin(A),y2:C-P*Math.cos(A),stroke:$,strokeOpacity:W,strokeWidth:1,strokeDasharray:"4 4"},`diag-${d}`)}),["N","E","S","W"].map(d=>{const L=fe(d),A=d==="E"?"end":d==="W"?"start":"middle",_=d==="N"?"hanging":d==="S"?"auto":"middle";return e.jsx("text",{x:L.x,y:L.y,textAnchor:A,dominantBaseline:_,fill:V,fontSize:oe.CARDINAL_FONT_SIZE,fontWeight:700,fontFamily:Be,"aria-hidden":"true",children:d},d)}),["NE","SE","SW","NW"].map(d=>{const L=fe(d),A=d==="NE"||d==="SE"?"end":"start",_=d==="NE"||d==="NW"?"hanging":"auto";return e.jsx("text",{x:L.x,y:L.y,textAnchor:A,dominantBaseline:_,fill:V,fontSize:oe.INTERCARDINAL_FONT_SIZE,fontWeight:600,fontFamily:Be,"aria-hidden":"true",children:d},d)}),e.jsx("circle",{cx:S,cy:C,r:oe.LOCAL_DOT_RADIUS,fill:N.chart6,stroke:f?"rgba(255,255,255,0.3)":"rgba(0,0,0,0.2)",strokeWidth:1,role:"img","aria-label":"Local node"}),e.jsx("g",{clipPath:`url(#${de})`,children:U.map(d=>{const L=D>0?d.distance/D*k:0;if(L>1)return null;const{x:A,y:_}=pe(d.bearing,L),F=d.snr!==null?bt(d.snr,O,E):"#808080",Y=(o==null?void 0:o.hash)===d.hash,Q=u.has(d.hash),ne=oe.DOT_RADIUS_HOVERED*1.5;return e.jsxs("g",{role:"img","aria-label":`${d.name}: ${d.distance.toFixed(1)}km ${d.bearing.toFixed(0)}°`,children:[Q&&e.jsx("circle",{cx:A,cy:_,r:ne,fill:"none",stroke:f?"rgba(255,255,255,0.9)":"rgba(0,0,0,0.7)",strokeWidth:2,className:"neighbor-blink-ring"}),Y&&e.jsx("circle",{cx:A,cy:_,r:ne,fill:F,opacity:.3}),e.jsx("circle",{cx:A,cy:_,r:Y?oe.DOT_RADIUS_HOVERED:oe.DOT_RADIUS,fill:F,stroke:f?"rgba(0,0,0,0.5)":"rgba(0,0,0,0.25)",strokeWidth:1,style:{cursor:"pointer",transition:"r 0.15s"},onMouseEnter:()=>_e(d),onMouseLeave:()=>_e(null)})]},d.hash)})})]})]}),o&&e.jsxs("div",{className:"absolute bg-tooltip-bg border border-edge-subtle rounded-lg px-3 py-2 text-sm pointer-events-none z-10 shadow-xl",style:{left:"50%",bottom:8,transform:"translateX(-50%)"},children:[e.jsx("div",{className:"font-medium text-fg-primary",children:o.name}),e.jsx("div",{className:"type-data-xs text-fg-secondary",children:o.hash}),o.snr!==null?e.jsx("div",{className:"flex gap-3 mt-1 text-xs",children:e.jsxs("span",{children:[e.jsx("span",{className:"text-fg-secondary",children:"SNR:"})," ",e.jsxs("span",{className:"tabular-nums",style:{color:bt(o.snr,O,E)},children:[o.snr.toFixed(1)," dB"]}),e.jsxs("span",{className:"text-fg-secondary ml-1",children:["(",xn(o.snr),")"]})]})}):e.jsx("div",{className:"text-xs text-fg-secondary mt-1",children:"No SNR data"}),e.jsxs("div",{className:"flex gap-3 text-xs",children:[e.jsxs("span",{children:[e.jsx("span",{className:"text-fg-secondary",children:"Distance:"})," ",e.jsxs("span",{className:"tabular-nums text-fg-primary",children:[o.distance.toFixed(2)," km"]})]}),e.jsxs("span",{children:[e.jsx("span",{className:"text-fg-secondary",children:"Bearing:"})," ",e.jsxs("span",{className:"tabular-nums text-fg-primary",children:[o.bearing.toFixed(0),"°"]})]})]})]})]}),e.jsxs("div",{className:"flex flex-col gap-1 px-1.5 pt-4 sm:pt-5 pb-2 flex-shrink-0 depth-raised radius-inset self-stretch",style:{width:"calc(100% / 6)"},children:[r&&e.jsxs("div",{className:"flex flex-col items-start gap-1 pb-2 mb-1",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"icon-md flex items-center justify-center text-icon-card-title",children:e.jsx(ze,{className:"w-3.5 h-3.5"})}),l&&e.jsx(Fe,{color:"zinc",children:l})]}),e.jsx("span",{className:"type-micro text-left text-[10px] leading-tight px-1",children:r})]}),e.jsx("div",{className:"flex flex-col gap-1 flex-1",role:"group","aria-label":"Zoom level",children:["1x","2x","4x","8x","16x","36x"].map(d=>e.jsx("button",{onClick:()=>Re(d),"aria-pressed":j===d,className:`flex flex-1 items-center justify-center min-w-[44px] sm:min-w-[32px] text-xs font-medium radius-inner depth-stroke-raised transition-colors ${j===d?"bg-sys-blue/20 text-sys-blue":"bg-subtle-fill/80 text-fg-secondary hover:bg-subtle-fill-strong hover:text-fg-primary"}`,children:d},d))})]})]}):e.jsxs("div",{ref:H,className:"flex flex-col items-center justify-center h-full text-fg-secondary",children:[e.jsx(ze,{className:"w-8 h-8 mb-2 opacity-50"}),e.jsx("p",{children:"Local node coordinates not configured"}),e.jsx("p",{className:"text-xs mt-1",children:"Set latitude/longitude in config to enable"})]})}const fn=c.memo(pn),Ye={repeater:"var(--sys-blue)",companion:"var(--sys-cyan)",room_server:"var(--sys-indigo)"};function gn(t){if(t.contact_type){const n=t.contact_type.toLowerCase();if(n==="repeater"||n==="rep")return"repeater";if(n==="room server"||n==="room_server"||n==="room"||n==="server")return"room_server";if(n==="companion"||n==="client"||n==="cli")return"companion"}return t.is_repeater?"repeater":"companion"}function bn({neighbors:t}){const n=c.useMemo(()=>{const s={repeater:0,companion:0,room_server:0};for(const r of Object.values(t)){const l=gn(r);s[l]=(s[l]||0)+1}const a=Object.values(s).reduce((r,l)=>r+l,0);return{items:[{label:"Repeaters",count:s.repeater,percent:0,color:Ye.repeater},{label:"Companions",count:s.companion,percent:0,color:Ye.companion},{label:"Room Servers",count:s.room_server,percent:0,color:Ye.room_server}].map(r=>({...r,percent:a>0?r.count/a*100:0})).filter(r=>r.count>0).sort((r,l)=>l.count-r.count),total:a}},[t]);return n.total===0?e.jsx("div",{className:"h-full flex items-center justify-center text-fg-muted type-body-sm",children:"No neighbors discovered yet"}):e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsx("div",{className:"flex-1 flex flex-col justify-evenly",children:n.items.map(s=>e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"type-data-sm text-fg-secondary",children:s.label}),e.jsxs("span",{className:"type-data-sm text-fg-secondary tabular-nums",children:[s.count," ",e.jsxs("span",{className:"text-fg-secondary/60",children:["(",s.percent.toFixed(0),"%)"]})]})]}),e.jsx("div",{className:"h-2.5 bg-subtle-fill/80 overflow-hidden rounded-full depth-stroke-inset",children:e.jsx("div",{className:"h-full rounded-full transition-all duration-500 ease-out",style:{width:`${s.percent}%`,backgroundColor:s.color,minWidth:s.count>0?"4px":"0"}})})]},s.label))}),e.jsxs("div",{className:"flex items-center justify-between pt-2 border-t border-edge-subtle",children:[e.jsx("span",{className:"type-data-xs text-fg-secondary",children:"Total Nodes"}),e.jsx("span",{className:"type-data-sm text-fg-primary font-medium tabular-nums",children:n.total})]})]})}const yn=c.memo(bn);function Xe({children:t,minHeight:n="100%",rootMargin:s="200px 0px",keepMounted:a=!0,className:i=""}){const r=c.useRef(null),[l,x]=c.useState(!1),[o,p]=c.useState(!1);c.useEffect(()=>{const h=r.current;if(!h)return;const w=new IntersectionObserver(([g])=>{const j=g.isIntersecting;p(j),j&&x(!0)},{rootMargin:s,threshold:0});return w.observe(h),()=>{w.disconnect()}},[s]);const u=o||a&&l;return e.jsx("div",{ref:r,className:`h-full w-full ${i}`,style:{minHeight:n},children:u?t:e.jsx("div",{className:"h-full w-full flex items-center justify-center text-fg-muted/50",children:e.jsx("div",{className:"animate-pulse text-xs",children:"Loading chart..."})})})}const wt=[{target:"DisambiguationCard",fn:"disambiguation.collisions",minStage:2}];tt(wt);const jn=.9,Nn=.7,vn=.5,kn=10,Sn=25,Pe={excellent:"text-signal-excellent",good:"text-signal-good",fair:"text-signal-fair",poor:"text-sys-blue"},wn={excellent:"bg-signal-excellent/10",good:"bg-signal-good/10",fair:"bg-signal-fair/10",poor:"bg-sys-blue/10"};function Mn(t){return t>=jn?"excellent":t>=Nn?"good":t>=vn?"fair":"poor"}function Cn(t){return t<=kn?"excellent":t<=Sn?"good":"poor"}function An(){et(wt);const t=Bt(),n=$t(),[s,a]=c.useState(null),i=c.useCallback((u,h)=>{a({prefix:u,candidateHashes:h})},[]),r=c.useCallback(()=>{a(null)},[]);if(!n)return e.jsxs(ue,{neomorphic:!0,children:[e.jsx(Ne,{icon:e.jsx(rt,{}),title:"Prefix Conflicts"}),e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"text-center text-fg-secondary",children:[e.jsx(zt,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),e.jsx("p",{className:"type-data-xs",children:"No topology data available"}),e.jsx("p",{className:"type-data-xs opacity-70",children:"Run deep analysis to see stats"})]})})]});const l=Mn(t.avgConfidence),x=Cn(t.collisionRate),o=l==="poor"||x==="poor"?"poor":l==="fair"||x==="fair"?"fair":l==="good"||x==="good"?"good":"excellent",p=o==="excellent"||o==="good"?it:Ze;return e.jsxs(ue,{neomorphic:!0,className:"flex flex-col overflow-hidden",children:[e.jsx(Ne,{icon:e.jsx(rt,{}),title:"Prefix Conflicts",badgeColor:"zinc",actions:o==="poor"?e.jsxs(Fe,{color:"red",children:[e.jsx(Ze,{className:"w-3 h-3"}),"Needs Attention"]}):e.jsxs("div",{className:`flex items-center gap-1.5 px-2.5 py-1 rounded-full ${wn[o]}`,children:[e.jsx(p,{className:`w-3.5 h-3.5 ${Pe[o]}`}),e.jsx("span",{className:`type-data-xs font-medium ${Pe[o]}`,children:o==="excellent"?"Excellent":o==="good"?"Good":"Fair"})]})}),e.jsxs("div",{className:"flex-1 flex flex-col min-h-0",children:[e.jsxs("div",{className:"flex gap-2 sm:gap-3",children:[e.jsxs("div",{className:"flex-1 flex flex-col radius-inner depth-stroke-inset px-3 py-2.5 sm:py-3 cursor-help",title:"Total unique 2-character prefixes observed in packet paths.",children:[e.jsx("span",{className:"type-data-xl text-fg-primary",children:e.jsx(Oe,{value:t.totalPrefixes,priority:"low"})}),e.jsx("span",{className:"type-micro text-fg-muted mt-0.5 sm:mt-1",children:"Prefixes"})]}),e.jsxs("div",{className:"flex-1 flex flex-col radius-inner depth-stroke-inset px-3 py-2.5 sm:py-3 cursor-help",title:"Prefixes that map to exactly one known node. No disambiguation needed.",children:[e.jsx("span",{className:"type-data-xl text-fg-primary",children:e.jsx(Oe,{value:t.unambiguousPrefixes,priority:"low"})}),e.jsx("span",{className:"type-micro text-fg-muted mt-0.5 sm:mt-1",children:"Unique"})]}),e.jsxs("div",{className:"flex-1 flex flex-col radius-inner depth-stroke-inset px-3 py-2.5 sm:py-3 cursor-help",title:"Prefixes matching multiple known nodes. Click a prefix below to explore candidates.",children:[e.jsx("span",{className:`type-data-xl ${t.collisionPrefixes>0?"text-sys-blue":"text-fg-primary"}`,children:e.jsx(Oe,{value:t.collisionPrefixes,priority:"low"})}),e.jsx("span",{className:`type-micro mt-0.5 sm:mt-1 ${t.collisionPrefixes>0?"text-sys-blue":"text-fg-muted"}`,children:"Conflicts"})]})]}),t.highCollisionPrefixes.length>0&&e.jsxs("div",{className:"pt-3",children:[e.jsx("div",{className:"data-box-label",children:"Problem Prefixes"}),e.jsx("div",{className:"flex flex-wrap gap-1.5 content-start",children:t.highCollisionPrefixes.map(({prefix:u,candidateCount:h,candidateHashes:w})=>e.jsxs("button",{type:"button",onClick:()=>i(u,w),className:"inline-flex items-center gap-0.5 group",title:`${h} candidates - click to explore`,children:[e.jsx(ms,{children:u}),e.jsxs("span",{className:"text-fg-muted type-data-xs group-hover:text-fg-secondary transition-colors",children:["×",h]})]},u))})]}),t.lowConfidencePrefixes.length===0&&t.collisionPrefixes===0&&e.jsx("div",{className:"flex-1 flex items-center",children:e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(it,{className:"w-3.5 h-3.5 text-signal-excellent"}),e.jsx("span",{className:"type-data-xs text-signal-excellent",children:"All prefixes uniquely identified"})]})}),e.jsxs("div",{className:"flex gap-2 sm:gap-3 mt-auto pt-3",children:[e.jsxs("div",{className:"flex-1 min-w-0 cursor-help",title:"Average confidence score across all disambiguated prefixes. Higher = more certain node identification.",children:[e.jsx("div",{className:"data-box-label",children:"Confidence"}),e.jsxs("div",{className:`data-box data-box-fill data-box-left ${Pe[l]}`,children:[(t.avgConfidence*100).toFixed(1),"%"]})]}),e.jsxs("div",{className:"flex-1 min-w-0 cursor-help",title:"Percentage of 2-character prefixes that match multiple known nodes. Lower is better.",children:[e.jsx("div",{className:"data-box-label",children:"Collisions"}),e.jsxs("div",{className:`data-box data-box-fill data-box-left ${Pe[x]}`,children:[t.collisionRate.toFixed(1),"%"]})]})]})]}),e.jsx(us,{isOpen:!!s,prefix:(s==null?void 0:s.prefix)||"",candidateHashes:(s==null?void 0:s.candidateHashes)||[],onClose:r})]})}const Mt=[{target:"PacketHealth",fn:"type",minStage:1},{target:"PacketHealth",fn:"duplicates",minStage:1}];tt(Mt);const _n=new Set(["Duplicate","Empty payload","Path too long","Unknown"]),Me=24;function Rn(t,n){const s=Date.now()/1e3,a=n*60,i=s-a,r=a/Me,l=new Array(Me).fill(0),x=new Array(Me).fill(0);let o=0,p=0,u=0,h=0;for(const g of t){if(g.packet_origin==="tx_local")continue;const j=g.timestamp;if(js)continue;o++;const y=Math.min(Me-1,Math.floor((j-i)/r));x[y]++,g.transmitted||g.packet_origin==="tx_forward"?(p++,l[y]++):(g.is_duplicate||g.drop_reason==="Duplicate")&&u++,g.drop_reason&&_n.has(g.drop_reason)&&h++}const w=[];for(let g=0;g0?Math.round(y/j*100):0,timestamp:(i+g*r)*1e3})}return{totalRx:o,forwarded:p,duplicates:u,waste:h,efficiency:o>0?p/o*100:0,duplicateRate:o>0?u/o*100:0,wasteRate:o>0?h/o*100:0,sparkline:w}}function Tn(t){return t>=90?"excellent":t>=75?"good":t>=60?"fair":"poor"}const Dn={excellent:"bg-status-success",good:"bg-sys-blue",fair:"bg-status-warning",poor:"bg-status-danger"};function En({packets:t,rangeMinutes:n,rangeHours:s,timeRangeLabel:a,isLoaded:i=!0}){et(Mt);const r=c.useMemo(()=>Rn(t,n),[t,n]),[l,x]=c.useState(null),o=c.useCallback(async()=>{try{const h=await Wt(s);h.success&&h.data&&x(h.data.count)}catch{}},[s]);c.useEffect(()=>{o()},[o]);const p=Tn(r.efficiency),u=r.totalRx>0;return e.jsx(ue,{neomorphic:!0,isLoaded:i,skeletonType:"chart",children:i&&e.jsxs(e.Fragment,{children:[e.jsx(Ne,{icon:e.jsx(hs,{}),title:"Packet Health",badge:a,badgeColor:"zinc"}),e.jsx(Ut,{children:e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsxs("div",{className:"flex items-baseline gap-2",children:[e.jsxs("div",{className:"type-data-xl text-fg-primary",children:[u?e.jsx(Oe,{value:Math.round(r.efficiency*10)/10,className:"font-mono tabular-nums",priority:"medium",format:{minimumFractionDigits:1,maximumFractionDigits:1}}):e.jsx("span",{className:"opacity-30",children:"—"}),e.jsx("span",{className:"type-data-sm text-fg-muted ml-0.5",children:"%"})]}),u&&e.jsx("div",{className:`w-2 h-2 rounded-full ${Dn[p]}`})]}),e.jsx("div",{className:"type-micro mb-2 cursor-help",title:"Forwarded packets / total received. CRC failures, garbled packets, and RF collisions that destroy packets before reaching software are not included in this ratio — see CRC Errors for hardware-level failures.",children:"FORWARDING RATE"}),e.jsx("div",{className:"flex-1 min-h-[28px] max-h-[48px] mb-2",children:e.jsx(ds,{data:r.sparkline,width:9999,height:36,color:"var(--sys-blue)",className:"w-full"})}),e.jsxs("div",{className:"flex gap-2 sm:gap-3 mt-auto",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"data-box-label",children:"Dupes"}),e.jsx("div",{className:"data-box data-box-fill data-box-left",children:u?`${r.duplicateRate.toFixed(1)}%`:"—"})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"data-box-label",children:"Waste"}),e.jsx("div",{className:"data-box data-box-fill data-box-left",children:u?`${r.wasteRate.toFixed(1)}%`:"—"})]}),l!==null&&l>0&&e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"data-box-label flex items-center gap-1",children:[e.jsx(Ze,{className:"w-3 h-3 text-status-warning"}),"CRC"]}),e.jsx("div",{className:"data-box data-box-fill data-box-left text-status-warning",children:l})]})]})]})})]})})}function la(){var De,Se,Ee,Le,d,L,A,_,F,Y,Q,ne,X,ie,ce,me,he;const t=Gt(),n=Vt(),s=qt(),a=Kt(),i=Yt(),r=Xt(),l=t!==null&&i,x=c.useRef(!1);l&&!x.current&&(x.current=!0);const o=x.current,p=Zt(),u=Qt(),h=Jt(),[w,g]=c.useState(null),[,j]=c.useState(null),[y]=c.useState(null),[k,R]=c.useState(()=>{const M=localStorage.getItem("statistics-view-mode");return M==="share"||M==="airtime"?M:"airtime"});c.useEffect(()=>{localStorage.setItem("statistics-view-mode",k)},[k]);const[I,z]=c.useState(()=>{const M=localStorage.getItem("statistics-smoothing-mode");return["ema","ultra","mosaic","stats","trend"].includes(M)?M:"stats"});c.useEffect(()=>{localStorage.setItem("statistics-smoothing-mode",I)},[I]);const[H,q]=c.useState(!1),[O,N]=c.useState(!1),[m,f]=c.useState(Nt),[v,E]=c.useState(.5),[$,T]=c.useState(xs),[W,V]=c.useState(.8),[ee,J]=c.useState(50),U=c.useMemo(()=>({0:0,1:0,2:1,3:2,4:3,5:4,6:5,7:6,8:7,9:8,10:9})[p]??3,[p]),D=$e[U].hours,K=D*60,te=$e[U],re=at(D),ae=r.isBackgroundLoading,se=c.useCallback(M=>{const ge={0:1,1:2,2:3,3:4,4:5,5:6,6:7,7:8,8:9,9:10}[M]??4;u(ge)},[u]),le=c.useMemo(()=>{var G;if(!((G=t==null?void 0:t.config)!=null&&G.radio))return null;const M=t.config.radio;return{sf:M.spreading_factor??10,bw:M.bandwidth??25e4,cr:M.coding_rate??5,preamble:M.preamble_length??8}},[(Se=(De=t==null?void 0:t.config)==null?void 0:De.radio)==null?void 0:Se.spreading_factor,(Le=(Ee=t==null?void 0:t.config)==null?void 0:Ee.radio)==null?void 0:Le.bandwidth,(L=(d=t==null?void 0:t.config)==null?void 0:d.radio)==null?void 0:L.coding_rate,(_=(A=t==null?void 0:t.config)==null?void 0:A.radio)==null?void 0:_.preamble_length]),B=c.useMemo(()=>h.length===0?{timestamps:[],values:[]}:{timestamps:h.map(M=>M.timestamp),values:h.map(M=>M.noise_floor_dbm)},[h]),b=c.useMemo(()=>{if(h.length<10)return{anomalies:[],debug:void 0};const M=_s(h,m);return{anomalies:M.anomalies,debug:M.debug}},[h,m]),S=b.anomalies,C=c.useMemo(()=>{const M=(t==null?void 0:t.neighbors)??{};return Object.fromEntries(Object.entries(M).filter(([G])=>!n.has(G)))},[t==null?void 0:t.neighbors,n]),P=c.useMemo(()=>{const M=Date.now()/1e3-D*3600;return Object.fromEntries(Object.entries(C).filter(([,G])=>G.last_seen>=M))},[C,D]),Z=c.useMemo(()=>{const M=K*60/re,G=Math.floor(Date.now()/1e3),ge=Math.floor(G/M)*M;return{start:ge-K*60,end:ge}},[K,re]),de=$.timeStart??Z.start,pe=$.timeEnd??Z.end,fe=(pe-de)/3600,_e=at(fe),Re=gs(),Te=c.useMemo(()=>ps(a,$,Re,Z),[a,$,Re,Z]);return e.jsxs(os,{children:[e.jsx(ls,{title:"Statistics",icon:e.jsx(es,{}),controls:e.jsx(is,{ranges:$e,selectedIndex:U,onSelect:se,isPending:ae})}),y&&e.jsx(ue,{className:"border border-sys-red/50 bg-sys-red/10",children:e.jsx("p",{className:"text-sys-red",children:y})}),H&&O&&e.jsxs(ue,{className:"border border-sys-indigo/30 bg-surface/50",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"type-label",children:"Anomaly Detection Tuning"}),e.jsxs("span",{className:"type-data-xs text-fg-muted",children:["(",te.label,")"]})]}),e.jsx("button",{onClick:()=>f(M=>({...M,useAbsoluteThresholds:!M.useAbsoluteThresholds})),className:`type-data-xs px-2 py-1 rounded transition-colors ${m.useAbsoluteThresholds?"bg-sys-indigo/30 text-sys-indigo":"bg-elevated text-fg-muted hover:text-fg-secondary"}`,children:m.useAbsoluteThresholds?"Absolute dBm":"Percentile"})]}),e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-4",children:[e.jsxs("div",{children:[e.jsx("span",{className:"type-micro",children:"Baseline"}),e.jsxs("span",{className:"ml-2 type-data-sm text-status-warning",children:[((Y=(F=b.debug)==null?void 0:F.baselineCutoff)==null?void 0:Y.toFixed(1))??"—"," dBm"]})]}),e.jsxs("div",{children:[e.jsx("span",{className:"type-micro",children:"Spike"}),e.jsxs("span",{className:"ml-2 type-data-sm text-status-warning",children:[((ne=(Q=b.debug)==null?void 0:Q.spikeCutoff)==null?void 0:ne.toFixed(1))??"—"," dBm"]})]}),e.jsxs("div",{children:[e.jsx("span",{className:"type-micro",children:"Mid-band"}),e.jsx("span",{className:"ml-2 type-data-sm text-sys-indigo",children:((X=b.debug)==null?void 0:X.midBandSamples)??0})]}),e.jsxs("div",{children:[e.jsx("span",{className:"type-micro",children:"Anomalies"}),e.jsx("span",{className:"ml-2 type-data-sm text-status-danger",children:S.length})]})]}),e.jsxs("div",{className:"mt-4 pt-4 border-t border-edge-subtle space-y-4",children:[m.useAbsoluteThresholds?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"type-micro block mb-1",children:["Baseline (",m.baselineDbm," dBm)"]}),e.jsx("input",{type:"range",min:"-120",max:"-60",value:m.baselineDbm,onChange:M=>f(G=>({...G,baselineDbm:Number(M.target.value)})),className:"w-full accent-sys-indigo"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"type-micro block mb-1",children:["Spike (",m.spikeDbm," dBm)"]}),e.jsx("input",{type:"range",min:"-100",max:"-20",value:m.spikeDbm,onChange:M=>f(G=>({...G,spikeDbm:Number(M.target.value)})),className:"w-full accent-sys-indigo"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"type-micro block mb-1",children:["Merge Gap (",m.mergeGapSeconds,"s)"]}),e.jsx("input",{type:"range",min:"5",max:"120",step:"5",value:m.mergeGapSeconds,onChange:M=>f(G=>({...G,mergeGapSeconds:Number(M.target.value)})),className:"w-full accent-sys-indigo"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"type-micro block mb-1",children:["Min Sequence (",m.minSequenceLength,")"]}),e.jsx("input",{type:"range",min:"2",max:"20",value:m.minSequenceLength,onChange:M=>f(G=>({...G,minSequenceLength:Number(M.target.value)})),className:"w-full accent-sys-indigo"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"type-micro block mb-1",children:["Similarity (±",m.similarityToleranceDbm," dBm)"]}),e.jsx("input",{type:"range",min:"1",max:"15",value:m.similarityToleranceDbm,onChange:M=>f(G=>({...G,similarityToleranceDbm:Number(M.target.value)})),className:"w-full accent-sys-indigo"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"type-micro block mb-1",children:["Opacity (",Math.round(v*100),"%)"]}),e.jsx("input",{type:"range",min:"0.1",max:"1",step:"0.05",value:v,onChange:M=>E(Number(M.target.value)),className:"w-full accent-sys-indigo"})]})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"type-micro block mb-1",children:["Baseline (P",m.baselinePercentile,")"]}),e.jsx("input",{type:"range",min:"1",max:"50",value:m.baselinePercentile,onChange:M=>f(G=>({...G,baselinePercentile:Number(M.target.value)})),className:"w-full accent-sys-indigo"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"type-micro block mb-1",children:["Spike (P",m.spikePercentile,")"]}),e.jsx("input",{type:"range",min:"50",max:"99",value:m.spikePercentile,onChange:M=>f(G=>({...G,spikePercentile:Number(M.target.value)})),className:"w-full accent-sys-indigo"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"type-micro block mb-1",children:["Merge Gap (",m.mergeGapSeconds,"s)"]}),e.jsx("input",{type:"range",min:"5",max:"120",step:"5",value:m.mergeGapSeconds,onChange:M=>f(G=>({...G,mergeGapSeconds:Number(M.target.value)})),className:"w-full accent-sys-indigo"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"type-micro block mb-1",children:["Min Sequence (",m.minSequenceLength,")"]}),e.jsx("input",{type:"range",min:"2",max:"20",value:m.minSequenceLength,onChange:M=>f(G=>({...G,minSequenceLength:Number(M.target.value)})),className:"w-full accent-sys-indigo"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"type-micro block mb-1",children:["Similarity (±",m.similarityToleranceDbm," dBm)"]}),e.jsx("input",{type:"range",min:"1",max:"15",value:m.similarityToleranceDbm,onChange:M=>f(G=>({...G,similarityToleranceDbm:Number(M.target.value)})),className:"w-full accent-sys-indigo"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"type-micro block mb-1",children:["Opacity (",Math.round(v*100),"%)"]}),e.jsx("input",{type:"range",min:"0.1",max:"1",step:"0.05",value:v,onChange:M=>E(Number(M.target.value)),className:"w-full accent-sys-indigo"})]})]})]}),e.jsxs("div",{className:"mt-4 p-3 bg-elevated radius-inner",children:[e.jsx("div",{className:"type-micro mb-1",children:"Config output"}),e.jsxs("div",{className:"type-data-sm text-status-success",children:[m.useAbsoluteThresholds?`useAbsoluteThresholds: true, baselineDbm: ${m.baselineDbm}, spikeDbm: ${m.spikeDbm}`:`useAbsoluteThresholds: false, baselinePercentile: ${m.baselinePercentile}, spikePercentile: ${m.spikePercentile}`,", mergeGapSeconds: ",m.mergeGapSeconds,", minSequenceLength: ",m.minSequenceLength,", similarityToleranceDbm: ",m.similarityToleranceDbm]})]})]})]}),e.jsxs(cs,{ready:o,children:[e.jsx("div",{className:"sm:hidden",children:ae&&e.jsx(be,{template:"auto",children:e.jsx(ue,{className:"border border-sys-blue/30 bg-sys-blue/5",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"relative flex h-3 w-3",children:[e.jsx("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full bg-sys-blue opacity-75"}),e.jsx("span",{className:"relative inline-flex rounded-full h-3 w-3 bg-sys-blue"})]}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("p",{className:"type-body-sm text-fg-primary",children:["Loading ",te.label," data..."]}),r.loadProgress&&e.jsxs("p",{className:"type-data-xs text-fg-muted mt-0.5",children:[r.loadProgress.loaded.toLocaleString()," packets (",r.loadProgress.percent,"%)"]})]})]})})})}),e.jsxs(e.Fragment,{children:[e.jsx(be,{template:"hero-auto",children:e.jsx(ue,{neomorphic:!0,skeletonType:"chart",children:o&&e.jsxs(e.Fragment,{children:[e.jsx(Ne,{icon:e.jsx(ve,{}),title:"Packet Analyzer",badge:te.label,badgeColor:"zinc",stackActionsOnMobile:!0,actions:e.jsxs("div",{className:"flex flex-wrap items-center gap-2 justify-end",children:[I==="stats"&&e.jsx(qs,{enabled:H,onChange:q,anomalyCount:S.length,showTuning:O,onTuningChange:N}),e.jsx(Vs,{smoothing:I,onChange:z}),e.jsx(Gs,{mode:k,onChange:R})]})}),e.jsx("div",{className:"flex-1 min-h-0",children:e.jsx(ln,{packets:Te,allPackets:a,startTs:de,endTs:pe,parentStartTs:Z.start,parentEndTs:Z.end,bucketCount:_e,radioConfig:le??void 0,mode:k,smoothing:I,noiseFloorAnomalies:S,showNoiseFloorOverlay:H,overlayOpacity:v,dotSize:W,dotOpacity:ee/100})})]})})}),e.jsx(be,{template:"auto",className:"relative z-10",children:e.jsx(ue,{neomorphic:!0,noPadding:!0,className:"overflow-visible",children:o&&e.jsx(fs,{parentStartTs:Z.start,parentEndTs:Z.end,neighbors:C,filter:$,onChange:T,...I==="stats"?{scatterDotSize:W,onScatterDotSizeChange:V,scatterOpacity:ee,onScatterOpacityChange:J}:{}})})}),e.jsxs(be,{template:"panel",children:[e.jsx(we,{span:12,md:6,children:e.jsx(ue,{neomorphic:!1,skeletonType:"chart",noPadding:o,className:"!bg-transparent !ring-0 !shadow-none !overflow-visible -mx-4 sm:mx-0 !px-0 !pr-0",children:o&&e.jsx(Xe,{children:e.jsx(fn,{neighbors:P,quickNeighbors:s,localLat:((ce=(ie=t==null?void 0:t.config)==null?void 0:ie.repeater)==null?void 0:ce.latitude)??0,localLon:((he=(me=t==null?void 0:t.config)==null?void 0:me.repeater)==null?void 0:he.longitude)??0,onStatsChange:j,title:"Link Quality",badge:te.label})})})}),e.jsx(we,{span:12,md:6,children:e.jsx(ue,{neomorphic:!0,skeletonType:"chart",children:o&&e.jsxs(e.Fragment,{children:[e.jsx(Ne,{icon:e.jsx(ys,{}),title:"Network Composition",badge:te.label,badgeColor:"zinc"}),e.jsx("div",{className:"flex-1 min-h-0",children:e.jsx(Xe,{children:e.jsx(yn,{neighbors:P})})})]})})})]}),e.jsxs(be,{template:"panel",children:[e.jsx(we,{span:12,md:6,children:e.jsx(An,{})}),e.jsx(we,{span:12,md:6,children:e.jsx(En,{packets:a,rangeMinutes:K,rangeHours:D,timeRangeLabel:te.label})})]}),e.jsx(be,{template:"panel",children:e.jsx(we,{span:12,children:e.jsx(ue,{neomorphic:!0,skeletonType:"chart",children:o&&e.jsxs(e.Fragment,{children:[e.jsx(Ne,{icon:e.jsx(ts,{}),title:"NOISE FLOOR dBm",stackActionsOnMobile:!0,actions:w?e.jsxs("div",{className:"flex items-center gap-2 sm:gap-3",children:[e.jsxs("span",{className:"type-data-xs text-fg-muted whitespace-nowrap",children:["min ",e.jsx("span",{className:"data-box",children:w.min.toFixed(0)})]}),e.jsxs("span",{className:"type-data-xs text-fg-muted whitespace-nowrap",children:["avg ",e.jsx("span",{className:"data-box",children:w.avg.toFixed(0)})]}),e.jsxs("span",{className:"type-data-xs text-fg-muted whitespace-nowrap",children:["max ",e.jsx("span",{className:"data-box",children:w.max.toFixed(0)})]})]}):null}),e.jsx("div",{className:"flex-1 min-h-0",children:e.jsx(Xe,{children:e.jsx(ss,{timestamps:B.timestamps,values:B.values,onStatsChange:g})})})]})})})})]})]})]})}export{la as default}; diff --git a/frontend/dist/assets/System-BjnR6rPq.js b/frontend/dist/assets/System-BjnR6rPq.js deleted file mode 100644 index 63ff37e0..00000000 --- a/frontend/dist/assets/System-BjnR6rPq.js +++ /dev/null @@ -1,16 +0,0 @@ -import{d as Y,d3 as A,cW as F,r as l,h as J,j as e,n as G,c as H,F as B,d4 as te,d5 as se,d6 as ne,d7 as re,d8 as ae,c0 as oe,B as le,d9 as ce,da as W}from"./index-C1ZF7cAz.js";import{C as E,P as ie,a as de,B as me}from"./PageLayout-sd81yog0.js";import{T as ue}from"./triangle-alert-B3ZB2VPZ.js";import{a as xe,A as pe}from"./arrow-up-DhGrEgP7.js";import{N as fe}from"./network-4dDTHizq.js";import{A as O}from"./activity-Bmh45lNn.js";import{R as he}from"./refresh-cw-BjBvU2VX.js";import{R as $,C as L}from"./Grid-DrJ5vfLo.js";/** - * @license lucide-react v0.559.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const ge=[["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M17 20v2",key:"1rnc9c"}],["path",{d:"M17 2v2",key:"11trls"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M2 17h2",key:"7oei6x"}],["path",{d:"M2 7h2",key:"asdhe0"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"M20 17h2",key:"1fpfkl"}],["path",{d:"M20 7h2",key:"1o8tra"}],["path",{d:"M7 20v2",key:"4gnj0m"}],["path",{d:"M7 2v2",key:"1i4yhu"}],["rect",{x:"4",y:"4",width:"16",height:"16",rx:"2",key:"1vbyd7"}],["rect",{x:"8",y:"8",width:"8",height:"8",rx:"1",key:"z9xiuo"}]],ye=Y("cpu",ge);/** - * @license lucide-react v0.559.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const je=[["line",{x1:"22",x2:"2",y1:"12",y2:"12",key:"1y58io"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}],["line",{x1:"6",x2:"6.01",y1:"16",y2:"16",key:"sgf278"}],["line",{x1:"10",x2:"10.01",y1:"16",y2:"16",key:"1l4acy"}]],we=Y("hard-drive",je);/** - * @license lucide-react v0.559.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const be=[["path",{d:"M14 4v10.54a4 4 0 1 1-4 0V4a2 2 0 0 1 4 0Z",key:"17jzev"}]],Ne=Y("thermometer",be),P=[{pos:0,color:A(F.purple)},{pos:.25,color:A(F.indigo)},{pos:.5,color:A(F.cyan)},{pos:.75,color:A(F.amber)},{pos:1,color:A(F.red)}];function ve(t,s,o){const r=.45454545454545453,n=Math.pow(t.r/255,2.2),i=Math.pow(t.g/255,2.2),x=Math.pow(t.b/255,2.2),d=Math.pow(s.r/255,2.2),m=Math.pow(s.g/255,2.2),c=Math.pow(s.b/255,2.2);return{r:Math.round(Math.pow(n+o*(d-n),r)*255),g:Math.round(Math.pow(i+o*(m-i),r)*255),b:Math.round(Math.pow(x+o*(c-x),r)*255)}}function Q(t){const s=Math.max(0,Math.min(1,t));let o=P[0],a=P[P.length-1];for(let i=0;i=P[i].pos&&s<=P[i+1].pos){o=P[i],a=P[i+1];break}const r=a.pos-o.pos,n=r>0?(s-o.pos)/r:0;return ve(o.color,a.color,n)}const V=G.hero,Me=36;function X(){const t=getComputedStyle(document.documentElement);return{fontFamily:t.getPropertyValue("--font-data").trim()||'"JetBrains Mono", ui-monospace, monospace',textPrimary:t.getPropertyValue("--text-primary").trim()||"#FFFFFF",textMuted:t.getPropertyValue("--text-muted").trim()||"#727272",gridColor:t.getPropertyValue("--chart-grid").trim()||"rgba(255, 255, 255, 0.06)"}}function Re(t){const s=[],o=Math.max(0,V-t.length);for(let r=0;ri+(u+.5)*R,f=u=>{const y=Math.min(Math.max(u/100,0),1);return x+m*(1-y)};n.save(),n.strokeStyle=r.textPrimary,n.globalAlpha=.1,n.lineWidth=1*c,n.setLineDash([4*c,4*c]);for(const u of[25,50,75]){const y=Math.round(f(u))+.5;n.beginPath(),n.moveTo(Math.round(i),y),n.lineTo(Math.round(i+d),y),n.stroke()}n.restore(),n.save(),n.font=`bold ${10*c}px ${r.fontFamily}`,n.fillStyle=r.textMuted,n.textBaseline="middle",n.textAlign="left";const p=8*c;for(const u of[0,25,50,75,100]){const y=f(u),v=Math.max(x+p,Math.min(x+m-p,y));n.fillText(`${u}%`,4*c,v)}n.restore(),n.save();for(let u=0;u0){const u=s[g-1];u!=null&&u.time&&(n.textAlign="right",n.fillText(u.time,j(g-1),N))}n.restore()}function Ce({data:t,cpuColor:s,memoryColor:o}){const a=l.useRef(null),r=l.useRef(null),n=l.useRef([]),i=l.useRef(s),x=l.useRef(o),d=l.useRef(null),m=l.useRef(t.length);l.useLayoutEffect(()=>{i.current=s,x.current=o}),l.useEffect(()=>{d.current=X()},[]);const c=l.useMemo(()=>Re(t),[t]);l.useLayoutEffect(()=>{n.current=c},[c]);const g=l.useMemo(()=>{const f=c.map(h=>h.timestamp),p=new Array(c.length).fill(1);return[f,p]},[c]),R=l.useMemo(()=>({hooks:{draw:f=>{const p=d.current||X();ke(f,n.current,i.current,x.current,p)}}}),[]),j=l.useMemo(()=>({width:400,height:240,padding:[4,8,4,Me],cursor:{show:!1,x:!1,y:!1,drag:{x:!1,y:!1},points:{show:!1}},scales:{x:{time:!1},y:{range:[0,100]}},axes:[{show:!1},{show:!1}],series:[{},{show:!1}],plugins:[R]}),[R]);return l.useEffect(()=>{const f=a.current;if(!f||c.length===0)return;const p=m.current,h=t.length,w=Math.abs(h-p);if(!(!r.current||w>50||p>0&&w/p>.2)&&r.current){r.current.setData(g),m.current=h;return}r.current&&r.current.destroy();const k=f.getBoundingClientRect(),u=Math.floor(k.width)||400,y=Math.floor(k.height)||240,v=new J({...j,width:u,height:y},g,f);return r.current=v,m.current=h,()=>{v.destroy(),r.current=null}},[j,g,c.length,t.length]),l.useEffect(()=>{const f=a.current;if(!f)return;const p=new ResizeObserver(h=>{const w=h[0];if(!w||!r.current)return;const{width:N,height:k}=w.contentRect;N>0&&k>0&&r.current.setSize({width:Math.floor(N),height:Math.floor(k)})});return p.observe(f),()=>{p.disconnect()}},[]),l.useEffect(()=>{r.current&&r.current.redraw()},[s,o,c]),t.length===0?e.jsx("div",{className:"flex-1 min-h-[180px] flex items-center justify-center text-fg-muted",children:"Collecting data..."}):e.jsx("div",{className:"relative flex-1 min-h-[180px]",children:e.jsx("div",{ref:a,className:"absolute inset-0 radius-inner overflow-hidden"})})}const Se=l.memo(Ce),_e=1024*1024;function Te(t,s,o,a,r){const n=t.ctx,{left:i,top:x,width:d,height:m}=t.bbox;if(d<=0||m<=0)return;const c=[...Array(Math.max(0,r-s.length)).fill(0),...s.slice(-r)],g=Math.max(...c,1),R=c.length,j=d/R,f=m*.03;n.save();for(let p=0;p{i.current=t,x.current=s,d.current=o,m.current=a});const c=l.useMemo(()=>{const j=Array.from({length:a},(p,h)=>h),f=new Array(a).fill(1);return[j,f]},[a]),g=l.useMemo(()=>({hooks:{draw:j=>{Te(j,i.current,x.current,d.current,m.current)}}}),[]),R=l.useMemo(()=>({width:400,height:40,padding:[0,0,0,0],legend:{show:!1},cursor:{show:!1,x:!1,y:!1,drag:{x:!1,y:!1},points:{show:!1}},scales:{x:{time:!1},y:{range:[0,1]}},axes:[{show:!1},{show:!1}],series:[{},{show:!1,label:""}],plugins:[g]}),[g]);return l.useEffect(()=>{const j=r.current;if(!j)return;n.current&&n.current.destroy();const f=j.getBoundingClientRect(),p=Math.floor(f.width)||400,h=Math.floor(f.height)||40,w=new J({...R,width:p,height:h},c,j);return n.current=w,()=>{w.destroy(),n.current=null}},[R,c]),l.useEffect(()=>{const j=r.current;if(!j)return;const f=new ResizeObserver(p=>{const h=p[0];if(!h||!n.current)return;const{width:w,height:N}=h.contentRect;w>0&&N>0&&n.current.setSize({width:Math.floor(w),height:Math.floor(N)})});return f.observe(j),()=>{f.disconnect()}},[]),l.useEffect(()=>{n.current&&n.current.redraw()},[t,s,o]),e.jsx("div",{ref:r,className:"w-full h-full"})}const K=l.memo(Pe),C={cold:30,normal:50,warm:65,hot:80},I={cpu:{warning:80,danger:95},memory:{warning:85,danger:95},temp:{warning:70,danger:85}},Ee=[{threshold:C.cold,color:"var(--sys-cyan)"},{threshold:C.normal,color:"var(--sys-blue)"},{threshold:C.warm,color:"var(--sys-indigo)"},{threshold:C.hot,color:"var(--signal-poor)"}];function Be(t){return t{const d=t>0?x.pos/t*100:0;return`${x.color} ${Math.min(d,100)}%`}).join(", ")})`}function U(t,s){return t>=s.danger?"danger":t>=s.warning?"warning":"none"}function Fe(t){let s="none";for(const o of Object.values(t)){const a=U(o,I.temp);if(a==="danger")return"danger";a==="warning"&&(s="warning")}return s}function Z(t){let s,o;t>=1024*1024*1024?(s=t/(1024*1024*1024),o="GB/s"):t>=1024*1024?(s=t/(1024*1024),o="MB/s"):t>=1024?(s=t/1024,o="KB/s"):(s=t,o="B/s");let a;return s>=100?a=s.toFixed(0):(s>=10,a=s.toFixed(1)),`${a} ${o}`}function D(t){return t>=1024*1024*1024?{value:(t/(1024*1024*1024)).toFixed(1),unit:"GiB"}:t>=1024*1024?{value:(t/(1024*1024)).toFixed(1),unit:"MiB"}:t>=1024?{value:(t/1024).toFixed(1),unit:"KiB"}:{value:String(t),unit:"B"}}const z=l.memo(function({level:s}){return s==="none"?null:e.jsxs("span",{className:H("inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-xs font-medium",s==="danger"&&"bg-sys-red/20 text-sys-red",s==="warning"&&"bg-sys-indigo/20 text-sys-indigo"),children:[e.jsx(ue,{className:"w-3 h-3"}),s==="danger"?"High":"Warn"]})}),ee=l.memo(function({value:s,max:o=100,width:a=10,color:r="primary"}){const n=Math.min(s/o,1),i=Math.round(n*a),x=a-i,d="■".repeat(i),m="·".repeat(x),c={primary:"text-sys-blue",secondary:"text-sys-indigo",success:"text-sys-green",danger:"text-sys-red"}[r];return e.jsxs("span",{className:"font-mono text-[10px] tracking-tight",children:[e.jsx("span",{className:c,children:d}),e.jsx("span",{className:"text-fg-muted/40",children:m})]})}),He=l.memo(function({index:s,usage:o}){const a=o>90?"danger":o>70?"secondary":"primary";return e.jsxs("div",{className:"flex items-center gap-1 type-data-xs",children:[e.jsxs("span",{className:"text-fg-muted w-5",children:["C",s]}),e.jsx(ee,{value:o,width:8,color:a}),e.jsxs("span",{className:H("w-7 text-right tabular-nums",o>90?"text-sys-red":o>70?"text-sys-indigo":"text-sys-green"),children:[o.toFixed(0),"%"]})]})}),$e=l.memo(function({pid:s,name:o,cpu:a,mem:r,isTopCpu:n=!1,isTopMem:i=!1}){return e.jsxs("div",{className:"flex items-center gap-2 py-1 type-data-sm hover:bg-subtle-fill -mx-1 px-1 rounded",children:[e.jsx("span",{className:"text-fg-muted w-10 sm:w-14 tabular-nums",children:s}),e.jsx("span",{className:"flex-1 truncate text-fg-primary",children:o}),e.jsx("span",{className:"hidden sm:inline-flex",children:e.jsx(ee,{value:a,max:100,width:6,color:a>50?"danger":a>20?"secondary":"success"})}),e.jsx("span",{className:H("w-10 sm:w-12 text-right tabular-nums",n?"text-fg-primary":a>50?"text-sys-red":a>20?"text-sys-indigo":"text-fg-muted"),children:a.toFixed(1)}),e.jsx("span",{className:H("w-10 sm:w-12 text-right tabular-nums",i?"text-fg-primary":r>50?"text-sys-red":r>20?"text-sys-indigo":"text-fg-muted"),children:r.toFixed(1)})]})}),q=l.memo(function({value:s,label:o,min:a=20,max:r=100}){const n=Math.min(Math.max((s-a)/(r-a)*100,0),100),i=Be(s),x=r-a;return e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"type-data-sm text-fg-muted",children:o}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"type-data-sm text-fg-muted",children:i.text}),e.jsxs("span",{className:"px-1.5 py-0.5 bg-subtle-fill-strong rounded type-data-sm",children:[e.jsx("span",{className:i.color,children:s.toFixed(1)}),e.jsx("span",{className:"text-fg-primary",children:"°C"})]})]})]}),e.jsxs("div",{className:"relative h-3 rounded-full bg-subtle-fill/80 depth-stroke-inset overflow-hidden",children:[e.jsx("div",{className:"absolute inset-y-0 left-0 rounded-full transition-all duration-300 ease-out",style:{background:Ae(n,a,r),width:`${n}%`}}),e.jsx("div",{className:"absolute inset-0 flex items-center pointer-events-none",children:Ee.map(({threshold:d,color:m})=>{const c=(d-a)/x*100;return c<0||c>100?null:e.jsx("div",{className:"absolute w-px h-full",style:{left:`${c}%`,backgroundColor:m}},d)})})]})]})});l.memo(function({data:s,color:o,flipped:a=!1,fixedSlots:r}){const n=[...Array(Math.max(0,r-s.length)).fill(0),...s.slice(-r)],i=Math.max(...n,1),x=n.map(d=>d===0?0:Math.max(d/i*100,3));return e.jsx("div",{className:"w-full h-full flex items-end",style:{transform:a?"scaleY(-1)":void 0},children:x.map((d,m)=>e.jsx("div",{className:"flex-1 min-w-0",style:{height:d>0?`${d}%`:"0%",backgroundColor:d>0?o:"transparent"}},m))})});function Le({networkHistory:t,txRate:s,rxRate:o,totalBytesSent:a,totalBytesRecv:r,cpuColor:n,memoryColor:i,networkSlots:x}){return e.jsxs(E,{neomorphic:!0,className:"flex flex-col",children:[e.jsx(B,{icon:e.jsx(fe,{}),title:"Network",actions:e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(xe,{className:"w-3.5 h-3.5",style:{color:i}}),e.jsx("span",{className:"type-data-xs",style:{color:i},children:"TX"}),e.jsx("span",{className:"px-2 py-1 bg-subtle-fill-strong rounded type-data-sm text-fg-primary",children:Z(s)})]})}),e.jsxs("div",{className:"flex flex-col h-[120px]",children:[e.jsx("div",{className:"h-[60px]",children:e.jsx(K,{data:t.map((d,m,c)=>{if(m===0)return 0;const g=(d.timestamp-c[m-1].timestamp)/1e3;return g>0?(d.bytesSent-c[m-1].bytesSent)/g:0}),color:i,fixedSlots:x})}),e.jsx("div",{className:"h-[60px]",children:e.jsx(K,{data:t.map((d,m,c)=>{if(m===0)return 0;const g=(d.timestamp-c[m-1].timestamp)/1e3;return g>0?(d.bytesRecv-c[m-1].bytesRecv)/g:0}),color:n,flipped:!0,fixedSlots:x})})]}),e.jsxs("div",{className:"pt-2 flex flex-wrap justify-between items-center gap-2 type-data-sm",children:[e.jsxs("div",{className:"flex items-center gap-1.5 sm:gap-2",children:[e.jsx("span",{className:"text-fg-muted",children:"Total"}),e.jsxs("span",{className:"px-1.5 sm:px-2 py-1 bg-subtle-fill-strong rounded tabular-nums",children:[e.jsx("span",{style:{color:i},children:D(a).value})," ",e.jsx("span",{className:"text-fg-muted",children:D(a).unit})]}),e.jsxs("span",{className:"px-1.5 sm:px-2 py-1 bg-subtle-fill-strong rounded tabular-nums",children:[e.jsx("span",{style:{color:n},children:D(r).value})," ",e.jsx("span",{className:"text-fg-muted",children:D(r).unit})]})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(pe,{className:"w-3.5 h-3.5",style:{color:n}}),e.jsx("span",{className:"type-data-xs",style:{color:n},children:"RX"}),e.jsx("span",{className:"px-1.5 sm:px-2 py-1 bg-subtle-fill-strong rounded tabular-nums text-fg-primary",children:Z(o)})]})]})]})}const De=l.memo(Le);function Oe({temperatures:t}){return e.jsxs(E,{neomorphic:!0,className:"flex flex-col",children:[e.jsx(B,{icon:e.jsx(Ne,{}),title:"Temperature",actions:t&&e.jsx(z,{level:Fe(t)})}),e.jsx("div",{className:"flex-1 flex flex-col justify-center min-h-0",children:t&&Object.keys(t).length>0?e.jsxs("div",{className:"space-y-3",children:[t.cpu_thermal!==void 0&&e.jsx(q,{value:t.cpu_thermal,label:"CPU",min:20,max:100}),Object.entries(t).filter(([s])=>s!=="cpu_thermal").slice(0,2).map(([s,o])=>e.jsx(q,{value:o,label:s.replace(/_/g," ").replace(/\b\w/g,a=>a.toUpperCase()),min:20,max:100},s))]}):e.jsxs("div",{className:"flex items-center justify-center text-fg-muted text-sm",children:[e.jsx(O,{className:"w-4 h-4 mr-2"}),"No sensors"]})})]})}const Ie=l.memo(Oe);function Ue({usagePercent:t,used:s,available:o,memoryColor:a}){return e.jsxs(E,{neomorphic:!0,className:"flex flex-col",children:[e.jsx(B,{icon:e.jsx(O,{}),title:"Memory",actions:e.jsxs("span",{className:"px-2 py-0.5 bg-subtle-fill-strong rounded type-data",style:{color:a},children:[t.toFixed(0),"%"]})}),e.jsxs("div",{className:"flex-1 flex flex-col justify-center min-h-0",children:[e.jsxs("div",{className:"flex gap-1 h-12 radius-inner bg-subtle-fill/80 depth-stroke-inset overflow-hidden",children:[e.jsx("div",{className:"h-full transition-all duration-300 bg-sys-blue",style:{width:`${t}%`}}),e.jsx("div",{className:"h-full transition-all duration-300 bg-subtle-fill/80",style:{width:`${100-t}%`}})]}),e.jsxs("div",{className:"flex items-center justify-between type-data-xs pt-2",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("div",{className:"w-2.5 h-2.5 rounded-sm bg-sys-blue"}),e.jsx("span",{className:"text-fg-muted",children:"Used"}),e.jsxs("span",{className:"px-1.5 py-0.5 bg-subtle-fill-strong rounded tabular-nums text-fg-primary",children:[(s/(1024*1024)).toFixed(0)," MB"]})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("div",{className:"w-2.5 h-2.5 rounded-sm bg-subtle-fill-strong depth-stroke-raised"}),e.jsx("span",{className:"text-fg-muted",children:"Avail"}),e.jsxs("span",{className:"px-1.5 py-0.5 bg-subtle-fill-strong rounded tabular-nums text-fg-muted",children:[(o/(1024*1024)).toFixed(0)," MB"]})]})]})]})]})}const ze=l.memo(Ue);function Ye({usagePercent:t,used:s,free:o,cpuColor:a}){return e.jsxs(E,{neomorphic:!0,className:"flex flex-col",children:[e.jsx(B,{icon:e.jsx(we,{}),title:"Disk",actions:e.jsxs("span",{className:"px-2 py-0.5 bg-subtle-fill-strong rounded type-data",style:{color:a},children:[t.toFixed(0),"%"]})}),e.jsxs("div",{className:"flex-1 flex flex-col justify-center min-h-0",children:[e.jsxs("div",{className:"flex gap-1 h-12 radius-inner bg-subtle-fill/80 depth-stroke-inset overflow-hidden",children:[e.jsx("div",{className:"h-full transition-all duration-300 bg-sys-blue",style:{width:`${t}%`}}),e.jsx("div",{className:"h-full transition-all duration-300 bg-subtle-fill/80",style:{width:`${100-t}%`}})]}),e.jsxs("div",{className:"flex items-center justify-between type-data-xs pt-2",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("div",{className:"w-2.5 h-2.5 rounded-sm bg-sys-blue"}),e.jsx("span",{className:"text-fg-muted",children:"Used"}),e.jsxs("span",{className:"px-1.5 py-0.5 bg-subtle-fill-strong rounded tabular-nums text-fg-primary",children:[(s/(1024*1024*1024)).toFixed(1)," GB"]})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("div",{className:"w-2.5 h-2.5 rounded-sm bg-subtle-fill-strong depth-stroke-raised"}),e.jsx("span",{className:"text-fg-muted",children:"Free"}),e.jsxs("span",{className:"px-1.5 py-0.5 bg-subtle-fill-strong rounded tabular-nums text-fg-muted",children:[(o/(1024*1024*1024)).toFixed(1)," GB"]})]})]})]})]})}const Ge=l.memo(Ye);function We({processes:t}){if(t.length===0)return null;const s=t.slice(0,10),o=Math.max(...s.map(r=>r.cpu_percent)),a=Math.max(...s.map(r=>r.memory_percent));return e.jsx(E,{neomorphic:!0,noPadding:!0,children:e.jsxs("div",{className:"px-4 py-3",children:[e.jsx(B,{icon:e.jsx(O,{}),title:"Processes"}),e.jsxs("div",{className:"flex items-center gap-2 py-1.5 type-data-sm text-fg-muted",children:[e.jsx("span",{className:"w-10 sm:w-14",children:"PID"}),e.jsx("span",{className:"flex-1",children:"Program"}),e.jsx("span",{className:"hidden sm:block w-[52px]"}),e.jsx("span",{className:"w-10 sm:w-12 text-right",children:"CPU%"}),e.jsx("span",{className:"w-10 sm:w-12 text-right",children:"MEM%"})]}),s.map(r=>e.jsx($e,{pid:r.pid,name:r.name,cpu:r.cpu_percent,mem:r.memory_percent,isTopCpu:r.cpu_percent===o&&o>0,isTopMem:r.memory_percent===a&&a>0},r.pid))]})})}const Ve=l.memo(We),Xe=G.hero;function Ke(){const[t,s]=l.useState(typeof window<"u"?window.matchMedia("(max-width: 767px)").matches:!1);return l.useEffect(()=>{const o=window.matchMedia("(max-width: 767px)");s(o.matches);const a=r=>s(r.matches);return o.addEventListener("change",a),()=>o.removeEventListener("change",a)},[]),t?G.hero:40}function rt(){var v;const t=te(),s=se(),o=ne(),a=re(),r=ae(),[n,i]=l.useState([]),[x,d]=l.useState(!1),[m,c]=l.useState([]),[g,R]=l.useState(0),[j,f]=l.useState(0),p=l.useRef(null),h=oe(),w=h.blue,N=h.amber,k=Ke();l.useEffect(()=>{if(!t)return;const b=Date.now(),M={timestamp:b,bytesRecv:t.network.bytes_recv,bytesSent:t.network.bytes_sent};if(p.current){const S=(b-p.current.timestamp)/1e3;if(S>0){const _=(M.bytesRecv-p.current.bytesRecv)/S,T=(M.bytesSent-p.current.bytesSent)/S;_>=0&&T>=0&&(R(_),f(T))}}p.current=M,c(S=>[...S,M].slice(-Xe))},[t]);const u=5e3;l.useEffect(()=>{let b=!0;const M=async()=>{var T;const _=await W();b&&_.success&&((T=_.data)!=null&&T.processes)&&i(_.data.processes)};M();const S=setInterval(M,u);return()=>{b=!1,clearInterval(S)}},[]);const y=async()=>{var M;d(!0),await a();const b=await W();b.success&&((M=b.data)!=null&&M.processes)&&i(b.data.processes),d(!1)};return e.jsxs(ie,{children:[e.jsx(de,{title:"System Stats",icon:e.jsx(ye,{}),controls:e.jsxs(le,{color:"muted",onClick:y,disabled:x,children:[e.jsx(he,{"data-slot":"icon",className:H(x&&"animate-spin")}),"Refresh"]})}),e.jsxs(me,{children:[o&&e.jsx(E,{className:"border border-sys-red/50 bg-sys-red/10",children:e.jsx("p",{className:"text-sys-red",children:o})}),s?e.jsx(E,{neomorphic:!0,className:"p-12 text-center",children:e.jsx("div",{className:"animate-pulse text-fg-muted",children:"Loading system stats..."})}):t?e.jsxs(e.Fragment,{children:[e.jsx($,{template:"hero",children:e.jsxs(E,{neomorphic:!0,className:"pb-2 sm:pb-3",children:[e.jsx(B,{icon:e.jsx(O,{}),title:"System Resources",stackActionsOnMobile:!0,actions:e.jsxs("div",{className:"flex items-center gap-2 sm:gap-4 flex-wrap",children:[((v=t.system)==null?void 0:v.uptime)&&e.jsx("span",{className:"px-2 py-0.5 bg-subtle-fill rounded type-data-sm text-fg-primary",children:ce(t.system.uptime)}),e.jsx(z,{level:U(t.cpu.usage_percent,I.cpu)}),e.jsx(z,{level:U(t.memory.usage_percent,I.memory)}),e.jsxs("div",{className:"flex items-center gap-1.5 sm:gap-2",children:[e.jsx("span",{className:"type-data-sm text-fg-muted",children:"CPU"}),e.jsxs("span",{className:"text-sm sm:text-base font-mono font-semibold tabular-nums",style:{color:w},children:[t.cpu.usage_percent.toFixed(0),"%"]})]}),e.jsxs("div",{className:"flex items-center gap-1.5 sm:gap-2",children:[e.jsx("span",{className:"type-data-sm text-fg-muted",children:"MEM"}),e.jsxs("span",{className:"text-sm sm:text-base font-mono font-semibold tabular-nums",style:{color:N},children:[t.memory.usage_percent.toFixed(0),"%"]})]})]})}),e.jsx("div",{className:"flex-1 min-h-0 flex flex-col",children:e.jsx(Se,{data:r,cpuColor:w,memoryColor:N})}),t.cpu.per_core_percent&&t.cpu.per_core_percent.length>0&&e.jsx("div",{className:"mt-3 pt-3 border-t border-edge-subtle",children:e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-4 lg:grid-cols-8 gap-x-3 gap-y-0.5",children:t.cpu.per_core_percent.map((b,M)=>e.jsx(He,{index:M,usage:b},M))})})]})}),e.jsxs($,{template:"compact",children:[e.jsx(L,{span:12,md:6,children:e.jsx(De,{networkHistory:m,txRate:j,rxRate:g,totalBytesSent:t.network.bytes_sent,totalBytesRecv:t.network.bytes_recv,cpuColor:w,memoryColor:N,networkSlots:k})}),e.jsx(L,{span:12,md:6,children:e.jsx(Ie,{temperatures:t.temperatures})})]}),e.jsxs($,{template:"compact",children:[e.jsx(L,{span:12,sm:6,children:e.jsx(ze,{usagePercent:t.memory.usage_percent,used:t.memory.used,available:t.memory.available,memoryColor:N})}),e.jsx(L,{span:12,sm:6,children:e.jsx(Ge,{usagePercent:t.disk.usage_percent,used:t.disk.used,free:t.disk.free,cpuColor:w})})]}),e.jsx($,{template:"auto",children:e.jsx(Ve,{processes:n})})]}):null]})]})}export{rt as default}; diff --git a/frontend/dist/assets/System-CQp_kzBU.js b/frontend/dist/assets/System-CQp_kzBU.js new file mode 100644 index 00000000..2c70af99 --- /dev/null +++ b/frontend/dist/assets/System-CQp_kzBU.js @@ -0,0 +1,16 @@ +import{d as Y,d1 as B,cU as A,r as l,n as J,j as e,o as G,c as F,H as E,d2 as te,d3 as se,d4 as re,d5 as ne,c0 as ae,B as oe,d6 as le,d7 as W}from"./index-DhkG1Nx9.js";import{C as P,P as ce,a as ie,B as de}from"./PageLayout-BkUTZXJb.js";import{T as me}from"./triangle-alert-D8NErBXC.js";import{a as ue,A as xe}from"./arrow-up-Bg1A345J.js";import{N as fe}from"./network-DBF70fah.js";import{A as L}from"./activity-BG24yKp1.js";import{R as pe}from"./refresh-cw-CA_1u8Jn.js";import{R as H,C as $}from"./Grid-DknC4rR5.js";/** + * @license lucide-react v0.559.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const he=[["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M17 20v2",key:"1rnc9c"}],["path",{d:"M17 2v2",key:"11trls"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M2 17h2",key:"7oei6x"}],["path",{d:"M2 7h2",key:"asdhe0"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"M20 17h2",key:"1fpfkl"}],["path",{d:"M20 7h2",key:"1o8tra"}],["path",{d:"M7 20v2",key:"4gnj0m"}],["path",{d:"M7 2v2",key:"1i4yhu"}],["rect",{x:"4",y:"4",width:"16",height:"16",rx:"2",key:"1vbyd7"}],["rect",{x:"8",y:"8",width:"8",height:"8",rx:"1",key:"z9xiuo"}]],ge=Y("cpu",he);/** + * @license lucide-react v0.559.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const ye=[["line",{x1:"22",x2:"2",y1:"12",y2:"12",key:"1y58io"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}],["line",{x1:"6",x2:"6.01",y1:"16",y2:"16",key:"sgf278"}],["line",{x1:"10",x2:"10.01",y1:"16",y2:"16",key:"1l4acy"}]],je=Y("hard-drive",ye);/** + * @license lucide-react v0.559.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const we=[["path",{d:"M14 4v10.54a4 4 0 1 1-4 0V4a2 2 0 0 1 4 0Z",key:"17jzev"}]],be=Y("thermometer",we),_=[{pos:0,color:B(A.purple)},{pos:.25,color:B(A.indigo)},{pos:.5,color:B(A.cyan)},{pos:.75,color:B(A.amber)},{pos:1,color:B(A.red)}];function Ne(t,s,o){const n=.45454545454545453,r=Math.pow(t.r/255,2.2),i=Math.pow(t.g/255,2.2),x=Math.pow(t.b/255,2.2),d=Math.pow(s.r/255,2.2),m=Math.pow(s.g/255,2.2),c=Math.pow(s.b/255,2.2);return{r:Math.round(Math.pow(r+o*(d-r),n)*255),g:Math.round(Math.pow(i+o*(m-i),n)*255),b:Math.round(Math.pow(x+o*(c-x),n)*255)}}function Q(t){const s=Math.max(0,Math.min(1,t));let o=_[0],a=_[_.length-1];for(let i=0;i<_.length-1;i++)if(s>=_[i].pos&&s<=_[i+1].pos){o=_[i],a=_[i+1];break}const n=a.pos-o.pos,r=n>0?(s-o.pos)/n:0;return Ne(o.color,a.color,r)}const V=G.hero,ve=36;function X(){const t=getComputedStyle(document.documentElement);return{fontFamily:t.getPropertyValue("--font-data").trim()||'"JetBrains Mono", ui-monospace, monospace',textPrimary:t.getPropertyValue("--text-primary").trim()||"#FFFFFF",textMuted:t.getPropertyValue("--text-muted").trim()||"#727272",gridColor:t.getPropertyValue("--chart-grid").trim()||"rgba(255, 255, 255, 0.06)"}}function Me(t){const s=[],o=Math.max(0,V-t.length);for(let n=0;ni+(u+.5)*v,f=u=>{const y=Math.min(Math.max(u/100,0),1);return x+m*(1-y)};r.save(),r.strokeStyle=n.textPrimary,r.globalAlpha=.1,r.lineWidth=1*c,r.setLineDash([4*c,4*c]);for(const u of[25,50,75]){const y=Math.round(f(u))+.5;r.beginPath(),r.moveTo(Math.round(i),y),r.lineTo(Math.round(i+d),y),r.stroke()}r.restore(),r.save(),r.font=`bold ${10*c}px ${n.fontFamily}`,r.fillStyle=n.textMuted,r.textBaseline="middle",r.textAlign="left";const g=8*c;for(const u of[0,25,50,75,100]){const y=f(u),j=Math.max(x+g,Math.min(x+m-g,y));r.fillText(`${u}%`,4*c,j)}r.restore(),r.save();for(let u=0;u0){const u=s[h-1];u!=null&&u.time&&(r.textAlign="right",r.fillText(u.time,w(h-1),M))}r.restore()}function ke({data:t,cpuColor:s,memoryColor:o}){const a=l.useRef(null),n=l.useRef(null),r=l.useRef([]),i=l.useRef(s),x=l.useRef(o),d=l.useRef(null),m=l.useRef(t.length);l.useLayoutEffect(()=>{i.current=s,x.current=o}),l.useEffect(()=>{d.current=X()},[]);const c=l.useMemo(()=>Me(t),[t]);l.useLayoutEffect(()=>{r.current=c},[c]);const h=l.useMemo(()=>{const f=c.map(p=>p.timestamp),g=new Array(c.length).fill(1);return[f,g]},[c]),v=l.useMemo(()=>({hooks:{draw:f=>{const g=d.current||X();Re(f,r.current,i.current,x.current,g)}}}),[]),w=l.useMemo(()=>({width:400,height:240,padding:[4,8,4,ve],cursor:{show:!1,x:!1,y:!1,drag:{x:!1,y:!1},points:{show:!1}},scales:{x:{time:!1},y:{range:[0,100]}},axes:[{show:!1},{show:!1}],series:[{},{show:!1}],plugins:[v]}),[v]);return l.useEffect(()=>{const f=a.current;if(!f||c.length===0)return;const g=m.current,p=t.length,b=Math.abs(p-g);if(!(!n.current||b>50||g>0&&b/g>.2)&&n.current){n.current.setData(h),m.current=p;return}n.current&&n.current.destroy();const R=f.getBoundingClientRect(),u=Math.floor(R.width)||400,y=Math.floor(R.height)||240,j=new J({...w,width:u,height:y},h,f);return n.current=j,m.current=p,()=>{j.destroy(),n.current=null}},[w,h,c.length,t.length]),l.useEffect(()=>{const f=a.current;if(!f)return;const g=new ResizeObserver(p=>{const b=p[0];if(!b||!n.current)return;const{width:M,height:R}=b.contentRect;M>0&&R>0&&n.current.setSize({width:Math.floor(M),height:Math.floor(R)})});return g.observe(f),()=>{g.disconnect()}},[]),l.useEffect(()=>{n.current&&n.current.redraw()},[s,o,c]),t.length===0?e.jsx("div",{className:"flex-1 min-h-[180px] flex items-center justify-center text-fg-muted",children:"Collecting data..."}):e.jsx("div",{className:"relative flex-1 min-h-[180px]",children:e.jsx("div",{ref:a,className:"absolute inset-0 radius-inner overflow-hidden"})})}const Ce=l.memo(ke),Se=1024*1024;function _e(t,s,o,a,n){const r=t.ctx,{left:i,top:x,width:d,height:m}=t.bbox;if(d<=0||m<=0)return;const c=[...Array(Math.max(0,n-s.length)).fill(0),...s.slice(-n)],h=Math.max(...c,1),v=c.length,w=d/v,f=m*.03;r.save();for(let g=0;g{i.current=t,x.current=s,d.current=o,m.current=a});const c=l.useMemo(()=>{const w=Array.from({length:a},(g,p)=>p),f=new Array(a).fill(1);return[w,f]},[a]),h=l.useMemo(()=>({hooks:{draw:w=>{_e(w,i.current,x.current,d.current,m.current)}}}),[]),v=l.useMemo(()=>({width:400,height:40,padding:[0,0,0,0],legend:{show:!1},cursor:{show:!1,x:!1,y:!1,drag:{x:!1,y:!1},points:{show:!1}},scales:{x:{time:!1},y:{range:[0,1]}},axes:[{show:!1},{show:!1}],series:[{},{show:!1,label:""}],plugins:[h]}),[h]);return l.useEffect(()=>{const w=n.current;if(!w)return;r.current&&r.current.destroy();const f=w.getBoundingClientRect(),g=Math.floor(f.width)||400,p=Math.floor(f.height)||40,b=new J({...v,width:g,height:p},c,w);return r.current=b,()=>{b.destroy(),r.current=null}},[v,c]),l.useEffect(()=>{const w=n.current;if(!w)return;const f=new ResizeObserver(g=>{const p=g[0];if(!p||!r.current)return;const{width:b,height:M}=p.contentRect;b>0&&M>0&&r.current.setSize({width:Math.floor(b),height:Math.floor(M)})});return f.observe(w),()=>{f.disconnect()}},[]),l.useEffect(()=>{r.current&&r.current.redraw()},[t,s,o]),e.jsx("div",{ref:n,className:"w-full h-full"})}const K=l.memo(Te),k={cold:30,normal:50,warm:65,hot:80},I={cpu:{warning:80,danger:95},memory:{warning:85,danger:95},temp:{warning:70,danger:85}},Pe=[{threshold:k.cold,color:"var(--sys-cyan)"},{threshold:k.normal,color:"var(--sys-blue)"},{threshold:k.warm,color:"var(--sys-indigo)"},{threshold:k.hot,color:"var(--signal-poor)"}];function Ee(t){return t{const d=t>0?x.pos/t*100:0;return`${x.color} ${Math.min(d,100)}%`}).join(", ")})`}function U(t,s){return t>=s.danger?"danger":t>=s.warning?"warning":"none"}function Ae(t){let s="none";for(const o of Object.values(t)){const a=U(o,I.temp);if(a==="danger")return"danger";a==="warning"&&(s="warning")}return s}function Z(t){let s,o;t>=1024*1024*1024?(s=t/(1024*1024*1024),o="GB/s"):t>=1024*1024?(s=t/(1024*1024),o="MB/s"):t>=1024?(s=t/1024,o="KB/s"):(s=t,o="B/s");let a;return s>=100?a=s.toFixed(0):(s>=10,a=s.toFixed(1)),`${a} ${o}`}function D(t){return t>=1024*1024*1024?{value:(t/(1024*1024*1024)).toFixed(1),unit:"GiB"}:t>=1024*1024?{value:(t/(1024*1024)).toFixed(1),unit:"MiB"}:t>=1024?{value:(t/1024).toFixed(1),unit:"KiB"}:{value:String(t),unit:"B"}}const z=l.memo(function({level:s}){return s==="none"?null:e.jsxs("span",{className:F("inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-xs font-medium",s==="danger"&&"bg-sys-red/20 text-sys-red",s==="warning"&&"bg-sys-indigo/20 text-sys-indigo"),children:[e.jsx(me,{className:"w-3 h-3"}),s==="danger"?"High":"Warn"]})}),ee=l.memo(function({value:s,max:o=100,width:a=10,color:n="primary"}){const r=Math.min(s/o,1),i=Math.round(r*a),x=a-i,d="■".repeat(i),m="·".repeat(x),c={primary:"text-sys-blue",secondary:"text-sys-indigo",success:"text-sys-green",danger:"text-sys-red"}[n];return e.jsxs("span",{className:"font-mono text-[10px] tracking-tight",children:[e.jsx("span",{className:c,children:d}),e.jsx("span",{className:"text-fg-muted/40",children:m})]})}),Fe=l.memo(function({index:s,usage:o}){const a=o>90?"danger":o>70?"secondary":"primary";return e.jsxs("div",{className:"flex items-center gap-1 type-data-xs",children:[e.jsxs("span",{className:"text-fg-muted w-5",children:["C",s]}),e.jsx(ee,{value:o,width:8,color:a}),e.jsxs("span",{className:F("w-7 text-right tabular-nums",o>90?"text-sys-red":o>70?"text-sys-indigo":"text-sys-green"),children:[o.toFixed(0),"%"]})]})}),He=l.memo(function({pid:s,name:o,cpu:a,mem:n,isTopCpu:r=!1,isTopMem:i=!1}){return e.jsxs("div",{className:"flex items-center gap-2 py-1 type-data-sm hover:bg-subtle-fill -mx-1 px-1 rounded",children:[e.jsx("span",{className:"text-fg-muted w-10 sm:w-14 tabular-nums",children:s}),e.jsx("span",{className:"flex-1 truncate text-fg-primary",children:o}),e.jsx("span",{className:"hidden sm:inline-flex",children:e.jsx(ee,{value:a,max:100,width:6,color:a>50?"danger":a>20?"secondary":"success"})}),e.jsx("span",{className:F("w-10 sm:w-12 text-right tabular-nums",r?"text-fg-primary":a>50?"text-sys-red":a>20?"text-sys-indigo":"text-fg-muted"),children:a.toFixed(1)}),e.jsx("span",{className:F("w-10 sm:w-12 text-right tabular-nums",i?"text-fg-primary":n>50?"text-sys-red":n>20?"text-sys-indigo":"text-fg-muted"),children:n.toFixed(1)})]})}),q=l.memo(function({value:s,label:o,min:a=20,max:n=100}){const r=Math.min(Math.max((s-a)/(n-a)*100,0),100),i=Ee(s),x=n-a;return e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"type-data-sm text-fg-muted",children:o}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"type-data-sm text-fg-muted",children:i.text}),e.jsxs("span",{className:"px-1.5 py-0.5 bg-subtle-fill-strong rounded type-data-sm",children:[e.jsx("span",{className:i.color,children:s.toFixed(1)}),e.jsx("span",{className:"text-fg-primary",children:"°C"})]})]})]}),e.jsxs("div",{className:"relative h-3 rounded-full bg-subtle-fill/80 depth-stroke-inset overflow-hidden",children:[e.jsx("div",{className:"absolute inset-y-0 left-0 rounded-full transition-all duration-300 ease-out",style:{background:Be(r,a,n),width:`${r}%`}}),e.jsx("div",{className:"absolute inset-0 flex items-center pointer-events-none",children:Pe.map(({threshold:d,color:m})=>{const c=(d-a)/x*100;return c<0||c>100?null:e.jsx("div",{className:"absolute w-px h-full",style:{left:`${c}%`,backgroundColor:m}},d)})})]})]})});l.memo(function({data:s,color:o,flipped:a=!1,fixedSlots:n}){const r=[...Array(Math.max(0,n-s.length)).fill(0),...s.slice(-n)],i=Math.max(...r,1),x=r.map(d=>d===0?0:Math.max(d/i*100,3));return e.jsx("div",{className:"w-full h-full flex items-end",style:{transform:a?"scaleY(-1)":void 0},children:x.map((d,m)=>e.jsx("div",{className:"flex-1 min-w-0",style:{height:d>0?`${d}%`:"0%",backgroundColor:d>0?o:"transparent"}},m))})});function $e({networkHistory:t,txRate:s,rxRate:o,totalBytesSent:a,totalBytesRecv:n,cpuColor:r,memoryColor:i,networkSlots:x}){return e.jsxs(P,{neomorphic:!0,className:"flex flex-col",children:[e.jsx(E,{icon:e.jsx(fe,{}),title:"Network",actions:e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(ue,{className:"w-3.5 h-3.5",style:{color:i}}),e.jsx("span",{className:"type-data-xs",style:{color:i},children:"TX"}),e.jsx("span",{className:"px-2 py-1 bg-subtle-fill-strong rounded type-data-sm text-fg-primary",children:Z(s)})]})}),e.jsxs("div",{className:"flex flex-col h-[120px]",children:[e.jsx("div",{className:"h-[60px]",children:e.jsx(K,{data:t.map((d,m,c)=>{if(m===0)return 0;const h=(d.timestamp-c[m-1].timestamp)/1e3;return h>0?(d.bytesSent-c[m-1].bytesSent)/h:0}),color:i,fixedSlots:x})}),e.jsx("div",{className:"h-[60px]",children:e.jsx(K,{data:t.map((d,m,c)=>{if(m===0)return 0;const h=(d.timestamp-c[m-1].timestamp)/1e3;return h>0?(d.bytesRecv-c[m-1].bytesRecv)/h:0}),color:r,flipped:!0,fixedSlots:x})})]}),e.jsxs("div",{className:"pt-2 flex flex-wrap justify-between items-center gap-2 type-data-sm",children:[e.jsxs("div",{className:"flex items-center gap-1.5 sm:gap-2",children:[e.jsx("span",{className:"text-fg-muted",children:"Total"}),e.jsxs("span",{className:"px-1.5 sm:px-2 py-1 bg-subtle-fill-strong rounded tabular-nums",children:[e.jsx("span",{style:{color:i},children:D(a).value})," ",e.jsx("span",{className:"text-fg-muted",children:D(a).unit})]}),e.jsxs("span",{className:"px-1.5 sm:px-2 py-1 bg-subtle-fill-strong rounded tabular-nums",children:[e.jsx("span",{style:{color:r},children:D(n).value})," ",e.jsx("span",{className:"text-fg-muted",children:D(n).unit})]})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(xe,{className:"w-3.5 h-3.5",style:{color:r}}),e.jsx("span",{className:"type-data-xs",style:{color:r},children:"RX"}),e.jsx("span",{className:"px-1.5 sm:px-2 py-1 bg-subtle-fill-strong rounded tabular-nums text-fg-primary",children:Z(o)})]})]})]})}const De=l.memo($e);function Le({temperatures:t}){return e.jsxs(P,{neomorphic:!0,className:"flex flex-col",children:[e.jsx(E,{icon:e.jsx(be,{}),title:"Temperature",actions:t&&e.jsx(z,{level:Ae(t)})}),e.jsx("div",{className:"flex-1 flex flex-col justify-center min-h-0",children:t&&Object.keys(t).length>0?e.jsxs("div",{className:"space-y-3",children:[t.cpu_thermal!==void 0&&e.jsx(q,{value:t.cpu_thermal,label:"CPU",min:20,max:100}),Object.entries(t).filter(([s])=>s!=="cpu_thermal").slice(0,2).map(([s,o])=>e.jsx(q,{value:o,label:s.replace(/_/g," ").replace(/\b\w/g,a=>a.toUpperCase()),min:20,max:100},s))]}):e.jsxs("div",{className:"flex items-center justify-center text-fg-muted text-sm",children:[e.jsx(L,{className:"w-4 h-4 mr-2"}),"No sensors"]})})]})}const Oe=l.memo(Le);function Ie({usagePercent:t,used:s,available:o,memoryColor:a}){return e.jsxs(P,{neomorphic:!0,className:"flex flex-col",children:[e.jsx(E,{icon:e.jsx(L,{}),title:"Memory",actions:e.jsxs("span",{className:"px-2 py-0.5 bg-subtle-fill-strong rounded type-data",style:{color:a},children:[t.toFixed(0),"%"]})}),e.jsxs("div",{className:"flex-1 flex flex-col justify-center min-h-0",children:[e.jsxs("div",{className:"flex gap-1 h-12 radius-inner bg-subtle-fill/80 depth-stroke-inset overflow-hidden",children:[e.jsx("div",{className:"h-full transition-all duration-300 bg-sys-blue",style:{width:`${t}%`}}),e.jsx("div",{className:"h-full transition-all duration-300 bg-subtle-fill/80",style:{width:`${100-t}%`}})]}),e.jsxs("div",{className:"flex items-center justify-between type-data-xs pt-2",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("div",{className:"w-2.5 h-2.5 rounded-sm bg-sys-blue"}),e.jsx("span",{className:"text-fg-muted",children:"Used"}),e.jsxs("span",{className:"px-1.5 py-0.5 bg-subtle-fill-strong rounded tabular-nums text-fg-primary",children:[(s/(1024*1024)).toFixed(0)," MB"]})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("div",{className:"w-2.5 h-2.5 rounded-sm bg-subtle-fill-strong depth-stroke-raised"}),e.jsx("span",{className:"text-fg-muted",children:"Avail"}),e.jsxs("span",{className:"px-1.5 py-0.5 bg-subtle-fill-strong rounded tabular-nums text-fg-muted",children:[(o/(1024*1024)).toFixed(0)," MB"]})]})]})]})]})}const Ue=l.memo(Ie);function ze({usagePercent:t,used:s,free:o,cpuColor:a}){return e.jsxs(P,{neomorphic:!0,className:"flex flex-col",children:[e.jsx(E,{icon:e.jsx(je,{}),title:"Disk",actions:e.jsxs("span",{className:"px-2 py-0.5 bg-subtle-fill-strong rounded type-data",style:{color:a},children:[t.toFixed(0),"%"]})}),e.jsxs("div",{className:"flex-1 flex flex-col justify-center min-h-0",children:[e.jsxs("div",{className:"flex gap-1 h-12 radius-inner bg-subtle-fill/80 depth-stroke-inset overflow-hidden",children:[e.jsx("div",{className:"h-full transition-all duration-300 bg-sys-blue",style:{width:`${t}%`}}),e.jsx("div",{className:"h-full transition-all duration-300 bg-subtle-fill/80",style:{width:`${100-t}%`}})]}),e.jsxs("div",{className:"flex items-center justify-between type-data-xs pt-2",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("div",{className:"w-2.5 h-2.5 rounded-sm bg-sys-blue"}),e.jsx("span",{className:"text-fg-muted",children:"Used"}),e.jsxs("span",{className:"px-1.5 py-0.5 bg-subtle-fill-strong rounded tabular-nums text-fg-primary",children:[(s/(1024*1024*1024)).toFixed(1)," GB"]})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("div",{className:"w-2.5 h-2.5 rounded-sm bg-subtle-fill-strong depth-stroke-raised"}),e.jsx("span",{className:"text-fg-muted",children:"Free"}),e.jsxs("span",{className:"px-1.5 py-0.5 bg-subtle-fill-strong rounded tabular-nums text-fg-muted",children:[(o/(1024*1024*1024)).toFixed(1)," GB"]})]})]})]})]})}const Ye=l.memo(ze);function Ge({processes:t}){if(t.length===0)return null;const s=t.slice(0,10),o=Math.max(...s.map(n=>n.cpu_percent)),a=Math.max(...s.map(n=>n.memory_percent));return e.jsx(P,{neomorphic:!0,noPadding:!0,children:e.jsxs("div",{className:"px-4 py-3",children:[e.jsx(E,{icon:e.jsx(L,{}),title:"Processes"}),e.jsxs("div",{className:"flex items-center gap-2 py-1.5 type-data-sm text-fg-muted",children:[e.jsx("span",{className:"w-10 sm:w-14",children:"PID"}),e.jsx("span",{className:"flex-1",children:"Program"}),e.jsx("span",{className:"hidden sm:block w-[52px]"}),e.jsx("span",{className:"w-10 sm:w-12 text-right",children:"CPU%"}),e.jsx("span",{className:"w-10 sm:w-12 text-right",children:"MEM%"})]}),s.map(n=>e.jsx(He,{pid:n.pid,name:n.name,cpu:n.cpu_percent,mem:n.memory_percent,isTopCpu:n.cpu_percent===o&&o>0,isTopMem:n.memory_percent===a&&a>0},n.pid))]})})}const We=l.memo(Ge),Ve=G.hero;function Xe(){const[t,s]=l.useState(typeof window<"u"?window.matchMedia("(max-width: 767px)").matches:!1);return l.useEffect(()=>{const o=window.matchMedia("(max-width: 767px)");s(o.matches);const a=n=>s(n.matches);return o.addEventListener("change",a),()=>o.removeEventListener("change",a)},[]),t?G.hero:40}function rt(){var y;const t=te(),s=se(),o=re(),a=ne(),[n,r]=l.useState([]),[i,x]=l.useState(!1),[d,m]=l.useState([]),[c,h]=l.useState(0),[v,w]=l.useState(0),f=l.useRef(null),g=ae(),p=g.blue,b=g.amber,M=Xe();l.useEffect(()=>{if(!t)return;const j=Date.now(),N={timestamp:j,bytesRecv:t.network.bytes_recv,bytesSent:t.network.bytes_sent};if(f.current){const C=(j-f.current.timestamp)/1e3;if(C>0){const S=(N.bytesRecv-f.current.bytesRecv)/C,T=(N.bytesSent-f.current.bytesSent)/C;S>=0&&T>=0&&(h(S),w(T))}}f.current=N,m(C=>[...C,N].slice(-Ve))},[t]);const R=5e3;l.useEffect(()=>{let j=!0;const N=async()=>{var T;const S=await W();j&&S.success&&((T=S.data)!=null&&T.processes)&&r(S.data.processes)};N();const C=setInterval(N,R);return()=>{j=!1,clearInterval(C)}},[]);const u=async()=>{var N;x(!0),await o();const j=await W();j.success&&((N=j.data)!=null&&N.processes)&&r(j.data.processes),x(!1)};return e.jsxs(ce,{children:[e.jsx(ie,{title:"System Stats",icon:e.jsx(ge,{}),controls:e.jsxs(oe,{color:"muted",onClick:u,disabled:i,children:[e.jsx(pe,{"data-slot":"icon",className:F(i&&"animate-spin")}),"Refresh"]})}),e.jsxs(de,{ready:!!t,children:[s&&e.jsx(P,{className:"border border-sys-red/50 bg-sys-red/10",children:e.jsx("p",{className:"text-sys-red",children:s})}),e.jsx(H,{template:"hero",children:e.jsxs(P,{neomorphic:!0,className:"pb-2 sm:pb-3",children:[e.jsx(E,{icon:e.jsx(L,{}),title:"System Resources",stackActionsOnMobile:!0,actions:t&&e.jsxs("div",{className:"flex items-center gap-2 sm:gap-4 flex-wrap",children:[((y=t.system)==null?void 0:y.uptime)&&e.jsx("span",{className:"px-2 py-0.5 bg-subtle-fill rounded type-data-sm text-fg-primary",children:le(t.system.uptime)}),e.jsx(z,{level:U(t.cpu.usage_percent,I.cpu)}),e.jsx(z,{level:U(t.memory.usage_percent,I.memory)}),e.jsxs("div",{className:"flex items-center gap-1.5 sm:gap-2",children:[e.jsx("span",{className:"type-data-sm text-fg-muted",children:"CPU"}),e.jsxs("span",{className:"text-sm sm:text-base font-mono font-semibold tabular-nums",style:{color:p},children:[t.cpu.usage_percent.toFixed(0),"%"]})]}),e.jsxs("div",{className:"flex items-center gap-1.5 sm:gap-2",children:[e.jsx("span",{className:"type-data-sm text-fg-muted",children:"MEM"}),e.jsxs("span",{className:"text-sm sm:text-base font-mono font-semibold tabular-nums",style:{color:b},children:[t.memory.usage_percent.toFixed(0),"%"]})]})]})}),t&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex-1 min-h-0 flex flex-col",children:e.jsx(Ce,{data:a,cpuColor:p,memoryColor:b})}),t.cpu.per_core_percent&&t.cpu.per_core_percent.length>0&&e.jsx("div",{className:"mt-3 pt-3 border-t border-edge-subtle",children:e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-4 lg:grid-cols-8 gap-x-3 gap-y-0.5",children:t.cpu.per_core_percent.map((j,N)=>e.jsx(Fe,{index:N,usage:j},N))})})]})]})}),t&&e.jsxs(e.Fragment,{children:[e.jsxs(H,{template:"compact",children:[e.jsx($,{span:12,md:6,children:e.jsx(De,{networkHistory:d,txRate:v,rxRate:c,totalBytesSent:t.network.bytes_sent,totalBytesRecv:t.network.bytes_recv,cpuColor:p,memoryColor:b,networkSlots:M})}),e.jsx($,{span:12,md:6,children:e.jsx(Oe,{temperatures:t.temperatures})})]}),e.jsxs(H,{template:"compact",children:[e.jsx($,{span:12,sm:6,children:e.jsx(Ue,{usagePercent:t.memory.usage_percent,used:t.memory.used,available:t.memory.available,memoryColor:b})}),e.jsx($,{span:12,sm:6,children:e.jsx(Ye,{usagePercent:t.disk.usage_percent,used:t.disk.used,free:t.disk.free,cpuColor:p})})]}),e.jsx(H,{template:"auto",children:e.jsx(We,{processes:n})})]})]})]})}export{rt as default}; diff --git a/frontend/dist/assets/Terminal-CkzES_px.js b/frontend/dist/assets/Terminal-D9XPO05V.js similarity index 93% rename from frontend/dist/assets/Terminal-CkzES_px.js rename to frontend/dist/assets/Terminal-D9XPO05V.js index c70eba3a..614cc2e6 100644 --- a/frontend/dist/assets/Terminal-CkzES_px.js +++ b/frontend/dist/assets/Terminal-D9XPO05V.js @@ -1,9 +1,9 @@ -var za=Object.defineProperty;var Ua=(e,t,i)=>t in e?za(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i;var D=(e,t,i)=>Ua(e,typeof t!="symbol"?t+"":t,i);import{d as as,Z as ii,cW as pe,dj as ja,dk as rt,dl as Qi,dm as Ka,b$ as wo,cK as Co,cL as qa,v as xo,dn as Va,dp as Ga,dq as Ya,bh as ko,cJ as Xa,bv as Eo,dr as ge,ba as Ja,b9 as Za,bQ as wt,ds as Qa,dt as el,du as tl,dv as il,da as Wr,j as m,ac as Ro,dw as Bo,ad as Mo,B as sl,r as U,A as _s,m as Ti,dx as zr,dy as Ur,cm as rl,dz as nl,c as es,dA as ol,dB as al,E as ll,dC as hl,dD as cl,dE as dl}from"./index-C1ZF7cAz.js";import{a as ul}from"./ping-C4M-6OVJ.js";import{P as _l,c as fl}from"./payload-decoders-CmuRVuC0.js";import{g as pl,r as ml}from"./system-DraTG8R2.js";import{g as gi,B as Do,r as Lo,T as To}from"./ascii-burst-DN6etEs5.js";import{P as gl,B as vl,C as Sl}from"./PageLayout-sd81yog0.js";import{K as $o,S as yl}from"./KeycapButton-DkbJ4iVA.js";import{D as jr}from"./download-DbDw1ZiV.js";import{S as Kr}from"./search-CtlrlrHK.js";import{C as bl}from"./chevron-right-DzbDJf-i.js";import"./keycap-sfx-ByZp-njj.js";/** +var za=Object.defineProperty;var Ua=(e,t,i)=>t in e?za(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i;var D=(e,t,i)=>Ua(e,typeof t!="symbol"?t+"":t,i);import{d as as,Z as ii,cU as pe,dg as ja,dh as rt,di as Qi,dj as Ka,b$ as bo,cI as Co,cJ as qa,x as xo,dk as Va,dl as Ga,dm as Ya,e as ko,cH as Xa,bw as Eo,dn as ge,bd as Ja,bc as Za,bR as bt,dp as Qa,dq as el,dr as tl,ds as il,d7 as Wr,j as m,ag as Ro,dt as Bo,ah as Mo,B as sl,r as U,A as _s,m as Ti,du as zr,dv as Ur,ck as rl,dw as nl,c as es,dx as ol,dy as al,G as ll,dz as hl,dA as cl,dB as dl}from"./index-DhkG1Nx9.js";import{a as ul}from"./ping-CLlM2Uim.js";import{P as _l,c as fl}from"./payload-decoders-DC2sHkKr.js";import{g as pl,r as ml}from"./system-DPGbt46l.js";import{g as gi,B as Do,r as Lo,T as To}from"./ascii-burst-DN6etEs5.js";import{P as gl,B as vl,C as Sl}from"./PageLayout-BkUTZXJb.js";import{K as $o,S as yl}from"./KeycapButton-xjzZCjhU.js";import{D as jr}from"./download-d0PZoGJ2.js";import{S as Kr}from"./search-BmkxxIVP.js";import{C as wl}from"./chevron-right-na13OQfy.js";import"./keycap-sfx-ByZp-njj.js";/** * @license lucide-react v0.559.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const wl=[["path",{d:"M12 7v14",key:"1akyts"}],["path",{d:"M16 12h2",key:"7q9ll5"}],["path",{d:"M16 8h2",key:"msurwy"}],["path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z",key:"ruj8y"}],["path",{d:"M6 12h2",key:"32wvfc"}],["path",{d:"M6 8h2",key:"30oboj"}]],Ao=as("book-open-text",wl);/** + */const bl=[["path",{d:"M12 7v14",key:"1akyts"}],["path",{d:"M16 12h2",key:"7q9ll5"}],["path",{d:"M16 8h2",key:"msurwy"}],["path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z",key:"ruj8y"}],["path",{d:"M6 12h2",key:"32wvfc"}],["path",{d:"M6 8h2",key:"30oboj"}]],Ao=as("book-open-text",bl);/** * @license lucide-react v0.559.0 - ISC * * This source code is licensed under the ISC license. @@ -29,21 +29,21 @@ var za=Object.defineProperty;var Ua=(e,t,i)=>t in e?za(e,t,{enumerable:!0,config * Fabrice Bellard's javascript vt100 for jslinux: * http://bellard.org/jslinux/ * Copyright (c) 2011 Fabrice Bellard - */var Po=Object.defineProperty,Ml=Object.getOwnPropertyDescriptor,Dl=(e,t)=>{for(var i in t)Po(e,i,{get:t[i],enumerable:!0})},_e=(e,t,i,s)=>{for(var r=s>1?void 0:s?Ml(t,i):t,n=e.length-1,o;n>=0;n--)(o=e[n])&&(r=(s?o(t,i,r):o(r))||r);return s&&r&&Po(t,i,r),r},T=(e,t)=>(i,s)=>t(i,s,e),qr="Terminal input",Is={get:()=>qr,set:e=>qr=e},Vr="Too much output to announce, navigate to rows manually to read",Os={get:()=>Vr,set:e=>Vr=e};function Ll(e){return e.replace(/\r?\n/g,"\r")}function Tl(e,t){return t?"\x1B[200~"+e+"\x1B[201~":e}function $l(e,t){e.clipboardData&&e.clipboardData.setData("text/plain",t.selectionText),e.preventDefault()}function Al(e,t,i,s){if(e.stopPropagation(),e.clipboardData){let r=e.clipboardData.getData("text/plain");No(r,t,i,s)}}function No(e,t,i,s){e=Ll(e),e=Tl(e,i.decPrivateModes.bracketedPasteMode&&s.rawOptions.ignoreBracketedPasteMode!==!0),i.triggerDataEvent(e,!0),t.value=""}function Io(e,t,i){let s=i.getBoundingClientRect(),r=e.clientX-s.left-10,n=e.clientY-s.top-10;t.style.width="20px",t.style.height="20px",t.style.left=`${r}px`,t.style.top=`${n}px`,t.style.zIndex="1000",t.focus()}function Gr(e,t,i,s,r){Io(e,t,i),r&&s.rightClickSelect(e),t.value=s.selectionText,t.select()}function bt(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function ls(e,t=0,i=e.length){let s="";for(let r=t;r65535?(n-=65536,s+=String.fromCharCode((n>>10)+55296)+String.fromCharCode(n%1024+56320)):s+=String.fromCharCode(n)}return s}var Pl=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let i=e.length;if(!i)return 0;let s=0,r=0;if(this._interim){let n=e.charCodeAt(r++);56320<=n&&n<=57343?t[s++]=(this._interim-55296)*1024+n-56320+65536:(t[s++]=this._interim,t[s++]=n),this._interim=0}for(let n=r;n=i)return this._interim=o,s;let a=e.charCodeAt(n);56320<=a&&a<=57343?t[s++]=(o-55296)*1024+a-56320+65536:(t[s++]=o,t[s++]=a);continue}o!==65279&&(t[s++]=o)}return s}},Nl=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let i=e.length;if(!i)return 0;let s=0,r,n,o,a,h=0,l=0;if(this.interim[0]){let u=!1,f=this.interim[0];f&=(f&224)===192?31:(f&240)===224?15:7;let _=0,p;for(;(p=this.interim[++_]&63)&&_<4;)f<<=6,f|=p;let g=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,E=g-_;for(;l=i)return 0;if(p=e[l++],(p&192)!==128){l--,u=!0;break}else this.interim[_++]=p,f<<=6,f|=p&63}u||(g===2?f<128?l--:t[s++]=f:g===3?f<2048||f>=55296&&f<=57343||f===65279||(t[s++]=f):f<65536||f>1114111||(t[s++]=f)),this.interim.fill(0)}let c=i-4,d=l;for(;d=i)return this.interim[0]=r,s;if(n=e[d++],(n&192)!==128){d--;continue}if(h=(r&31)<<6|n&63,h<128){d--;continue}t[s++]=h}else if((r&240)===224){if(d>=i)return this.interim[0]=r,s;if(n=e[d++],(n&192)!==128){d--;continue}if(d>=i)return this.interim[0]=r,this.interim[1]=n,s;if(o=e[d++],(o&192)!==128){d--;continue}if(h=(r&15)<<12|(n&63)<<6|o&63,h<2048||h>=55296&&h<=57343||h===65279)continue;t[s++]=h}else if((r&248)===240){if(d>=i)return this.interim[0]=r,s;if(n=e[d++],(n&192)!==128){d--;continue}if(d>=i)return this.interim[0]=r,this.interim[1]=n,s;if(o=e[d++],(o&192)!==128){d--;continue}if(d>=i)return this.interim[0]=r,this.interim[1]=n,this.interim[2]=o,s;if(a=e[d++],(a&192)!==128){d--;continue}if(h=(r&7)<<18|(n&63)<<12|(o&63)<<6|a&63,h<65536||h>1114111)continue;t[s++]=h}}return s}},Oo="",Ct=" ",Ci=class Fo{constructor(){this.fg=0,this.bg=0,this.extended=new ts}static toColorRGB(t){return[t>>>16&255,t>>>8&255,t&255]}static fromColorRGB(t){return(t[0]&255)<<16|(t[1]&255)<<8|t[2]&255}clone(){let t=new Fo;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)===50331648}isBgRGB(){return(this.bg&50331648)===50331648}isFgPalette(){return(this.fg&50331648)===16777216||(this.fg&50331648)===33554432}isBgPalette(){return(this.bg&50331648)===16777216||(this.bg&50331648)===33554432}isFgDefault(){return(this.fg&50331648)===0}isBgDefault(){return(this.bg&50331648)===0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===16777216||(this.extended.underlineColor&50331648)===33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===0:this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},ts=class Ho{constructor(t=0,i=0){this._ext=0,this._urlId=0,this._ext=t,this._urlId=i}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(t){this._ext=t}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(t){this._ext&=-469762049,this._ext|=t<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(t){this._ext&=-67108864,this._ext|=t&67108863}get urlId(){return this._urlId}set urlId(t){this._urlId=t}get underlineVariantOffset(){let t=(this._ext&3758096384)>>29;return t<0?t^4294967288:t}set underlineVariantOffset(t){this._ext&=536870911,this._ext|=t<<29&3758096384}clone(){return new Ho(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},Je=class Wo extends Ci{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new ts,this.combinedData=""}static fromCharData(t){let i=new Wo;return i.setFromCharData(t),i}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?bt(this.content&2097151):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(t){this.fg=t[0],this.bg=0;let i=!1;if(t[1].length>2)i=!0;else if(t[1].length===2){let s=t[1].charCodeAt(0);if(55296<=s&&s<=56319){let r=t[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(s-55296)*1024+r-56320+65536|t[2]<<22:i=!0}else i=!0}else this.content=t[1].charCodeAt(0)|t[2]<<22;i&&(this.combinedData=t[1],this.content=2097152|t[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},Yr="di$target",Fs="di$dependencies",fs=new Map;function Il(e){return e[Fs]||[]}function Me(e){if(fs.has(e))return fs.get(e);let t=function(i,s,r){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");Ol(t,i,r)};return t._id=e,fs.set(e,t),t}function Ol(e,t,i){t[Yr]===t?t[Fs].push({id:e,index:i}):(t[Fs]=[{id:e,index:i}],t[Yr]=t)}var Ie=Me("BufferService"),zo=Me("CoreMouseService"),Nt=Me("CoreService"),Fl=Me("CharsetService"),Er=Me("InstantiationService"),Uo=Me("LogService"),Oe=Me("OptionsService"),jo=Me("OscLinkService"),Hl=Me("UnicodeService"),xi=Me("DecorationService"),Hs=class{constructor(e,t,i){this._bufferService=e,this._optionsService=t,this._oscLinkService=i}provideLinks(e,t){var c;let i=this._bufferService.buffer.lines.get(e-1);if(!i){t(void 0);return}let s=[],r=this._optionsService.rawOptions.linkHandler,n=new Je,o=i.getTrimmedLength(),a=-1,h=-1,l=!1;for(let d=0;dr?r.activate(p,g,f):Wl(p,g),hover:(p,g)=>{var E;return(E=r==null?void 0:r.hover)==null?void 0:E.call(r,p,g,f)},leave:(p,g)=>{var E;return(E=r==null?void 0:r.leave)==null?void 0:E.call(r,p,g,f)}})}l=!1,n.hasExtendedAttrs()&&n.extended.urlId?(h=d,a=n.extended.urlId):(h=-1,a=-1)}}t(s)}};Hs=_e([T(0,Ie),T(1,Oe),T(2,jo)],Hs);function Wl(e,t){if(confirm(`Do you want to navigate to ${t}? + */var Po=Object.defineProperty,Ml=Object.getOwnPropertyDescriptor,Dl=(e,t)=>{for(var i in t)Po(e,i,{get:t[i],enumerable:!0})},_e=(e,t,i,s)=>{for(var r=s>1?void 0:s?Ml(t,i):t,n=e.length-1,o;n>=0;n--)(o=e[n])&&(r=(s?o(t,i,r):o(r))||r);return s&&r&&Po(t,i,r),r},T=(e,t)=>(i,s)=>t(i,s,e),qr="Terminal input",Is={get:()=>qr,set:e=>qr=e},Vr="Too much output to announce, navigate to rows manually to read",Os={get:()=>Vr,set:e=>Vr=e};function Ll(e){return e.replace(/\r?\n/g,"\r")}function Tl(e,t){return t?"\x1B[200~"+e+"\x1B[201~":e}function $l(e,t){e.clipboardData&&e.clipboardData.setData("text/plain",t.selectionText),e.preventDefault()}function Al(e,t,i,s){if(e.stopPropagation(),e.clipboardData){let r=e.clipboardData.getData("text/plain");No(r,t,i,s)}}function No(e,t,i,s){e=Ll(e),e=Tl(e,i.decPrivateModes.bracketedPasteMode&&s.rawOptions.ignoreBracketedPasteMode!==!0),i.triggerDataEvent(e,!0),t.value=""}function Io(e,t,i){let s=i.getBoundingClientRect(),r=e.clientX-s.left-10,n=e.clientY-s.top-10;t.style.width="20px",t.style.height="20px",t.style.left=`${r}px`,t.style.top=`${n}px`,t.style.zIndex="1000",t.focus()}function Gr(e,t,i,s,r){Io(e,t,i),r&&s.rightClickSelect(e),t.value=s.selectionText,t.select()}function wt(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function ls(e,t=0,i=e.length){let s="";for(let r=t;r65535?(n-=65536,s+=String.fromCharCode((n>>10)+55296)+String.fromCharCode(n%1024+56320)):s+=String.fromCharCode(n)}return s}var Pl=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let i=e.length;if(!i)return 0;let s=0,r=0;if(this._interim){let n=e.charCodeAt(r++);56320<=n&&n<=57343?t[s++]=(this._interim-55296)*1024+n-56320+65536:(t[s++]=this._interim,t[s++]=n),this._interim=0}for(let n=r;n=i)return this._interim=o,s;let a=e.charCodeAt(n);56320<=a&&a<=57343?t[s++]=(o-55296)*1024+a-56320+65536:(t[s++]=o,t[s++]=a);continue}o!==65279&&(t[s++]=o)}return s}},Nl=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let i=e.length;if(!i)return 0;let s=0,r,n,o,a,h=0,l=0;if(this.interim[0]){let u=!1,f=this.interim[0];f&=(f&224)===192?31:(f&240)===224?15:7;let _=0,p;for(;(p=this.interim[++_]&63)&&_<4;)f<<=6,f|=p;let g=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,E=g-_;for(;l=i)return 0;if(p=e[l++],(p&192)!==128){l--,u=!0;break}else this.interim[_++]=p,f<<=6,f|=p&63}u||(g===2?f<128?l--:t[s++]=f:g===3?f<2048||f>=55296&&f<=57343||f===65279||(t[s++]=f):f<65536||f>1114111||(t[s++]=f)),this.interim.fill(0)}let c=i-4,d=l;for(;d=i)return this.interim[0]=r,s;if(n=e[d++],(n&192)!==128){d--;continue}if(h=(r&31)<<6|n&63,h<128){d--;continue}t[s++]=h}else if((r&240)===224){if(d>=i)return this.interim[0]=r,s;if(n=e[d++],(n&192)!==128){d--;continue}if(d>=i)return this.interim[0]=r,this.interim[1]=n,s;if(o=e[d++],(o&192)!==128){d--;continue}if(h=(r&15)<<12|(n&63)<<6|o&63,h<2048||h>=55296&&h<=57343||h===65279)continue;t[s++]=h}else if((r&248)===240){if(d>=i)return this.interim[0]=r,s;if(n=e[d++],(n&192)!==128){d--;continue}if(d>=i)return this.interim[0]=r,this.interim[1]=n,s;if(o=e[d++],(o&192)!==128){d--;continue}if(d>=i)return this.interim[0]=r,this.interim[1]=n,this.interim[2]=o,s;if(a=e[d++],(a&192)!==128){d--;continue}if(h=(r&7)<<18|(n&63)<<12|(o&63)<<6|a&63,h<65536||h>1114111)continue;t[s++]=h}}return s}},Oo="",Ct=" ",Ci=class Ho{constructor(){this.fg=0,this.bg=0,this.extended=new ts}static toColorRGB(t){return[t>>>16&255,t>>>8&255,t&255]}static fromColorRGB(t){return(t[0]&255)<<16|(t[1]&255)<<8|t[2]&255}clone(){let t=new Ho;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)===50331648}isBgRGB(){return(this.bg&50331648)===50331648}isFgPalette(){return(this.fg&50331648)===16777216||(this.fg&50331648)===33554432}isBgPalette(){return(this.bg&50331648)===16777216||(this.bg&50331648)===33554432}isFgDefault(){return(this.fg&50331648)===0}isBgDefault(){return(this.bg&50331648)===0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===16777216||(this.extended.underlineColor&50331648)===33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===0:this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},ts=class Fo{constructor(t=0,i=0){this._ext=0,this._urlId=0,this._ext=t,this._urlId=i}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(t){this._ext=t}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(t){this._ext&=-469762049,this._ext|=t<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(t){this._ext&=-67108864,this._ext|=t&67108863}get urlId(){return this._urlId}set urlId(t){this._urlId=t}get underlineVariantOffset(){let t=(this._ext&3758096384)>>29;return t<0?t^4294967288:t}set underlineVariantOffset(t){this._ext&=536870911,this._ext|=t<<29&3758096384}clone(){return new Fo(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},Je=class Wo extends Ci{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new ts,this.combinedData=""}static fromCharData(t){let i=new Wo;return i.setFromCharData(t),i}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?wt(this.content&2097151):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(t){this.fg=t[0],this.bg=0;let i=!1;if(t[1].length>2)i=!0;else if(t[1].length===2){let s=t[1].charCodeAt(0);if(55296<=s&&s<=56319){let r=t[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(s-55296)*1024+r-56320+65536|t[2]<<22:i=!0}else i=!0}else this.content=t[1].charCodeAt(0)|t[2]<<22;i&&(this.combinedData=t[1],this.content=2097152|t[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},Yr="di$target",Hs="di$dependencies",fs=new Map;function Il(e){return e[Hs]||[]}function Me(e){if(fs.has(e))return fs.get(e);let t=function(i,s,r){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");Ol(t,i,r)};return t._id=e,fs.set(e,t),t}function Ol(e,t,i){t[Yr]===t?t[Hs].push({id:e,index:i}):(t[Hs]=[{id:e,index:i}],t[Yr]=t)}var Ie=Me("BufferService"),zo=Me("CoreMouseService"),Nt=Me("CoreService"),Hl=Me("CharsetService"),Er=Me("InstantiationService"),Uo=Me("LogService"),Oe=Me("OptionsService"),jo=Me("OscLinkService"),Fl=Me("UnicodeService"),xi=Me("DecorationService"),Fs=class{constructor(e,t,i){this._bufferService=e,this._optionsService=t,this._oscLinkService=i}provideLinks(e,t){var c;let i=this._bufferService.buffer.lines.get(e-1);if(!i){t(void 0);return}let s=[],r=this._optionsService.rawOptions.linkHandler,n=new Je,o=i.getTrimmedLength(),a=-1,h=-1,l=!1;for(let d=0;dr?r.activate(p,g,f):Wl(p,g),hover:(p,g)=>{var E;return(E=r==null?void 0:r.hover)==null?void 0:E.call(r,p,g,f)},leave:(p,g)=>{var E;return(E=r==null?void 0:r.leave)==null?void 0:E.call(r,p,g,f)}})}l=!1,n.hasExtendedAttrs()&&n.extended.urlId?(h=d,a=n.extended.urlId):(h=-1,a=-1)}}t(s)}};Fs=_e([T(0,Ie),T(1,Oe),T(2,jo)],Fs);function Wl(e,t){if(confirm(`Do you want to navigate to ${t}? WARNING: This link could potentially be dangerous`)){let i=window.open();if(i){try{i.opener=null}catch{}i.location.href=t}else console.warn("Opening link blocked as opener could not be cleared")}}var hs=Me("CharSizeService"),ft=Me("CoreBrowserService"),Rr=Me("MouseService"),pt=Me("RenderService"),zl=Me("SelectionService"),Ko=Me("CharacterJoinerService"),Jt=Me("ThemeService"),qo=Me("LinkProviderService"),Ul=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?Xr.isErrorNoTelemetry(e)?new Xr(e.message+` `+e.stack):new Error(e.message+` -`+e.stack):e},0)}}addListener(e){return this.listeners.push(e),()=>{this._removeListener(e)}}emit(e){this.listeners.forEach(t=>{t(e)})}_removeListener(e){this.listeners.splice(this.listeners.indexOf(e),1)}setUnexpectedErrorHandler(e){this.unexpectedErrorHandler=e}getUnexpectedErrorHandler(){return this.unexpectedErrorHandler}onUnexpectedError(e){this.unexpectedErrorHandler(e),this.emit(e)}onUnexpectedExternalError(e){this.unexpectedErrorHandler(e)}},jl=new Ul;function Wi(e){Kl(e)||jl.onUnexpectedError(e)}var Ws="Canceled";function Kl(e){return e instanceof ql?!0:e instanceof Error&&e.name===Ws&&e.message===Ws}var ql=class extends Error{constructor(){super(Ws),this.name=this.message}};function Vl(e){return new Error(`Illegal argument: ${e}`)}var Xr=class zs extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(t){if(t instanceof zs)return t;let i=new zs;return i.message=t.message,i.stack=t.stack,i}static isErrorNoTelemetry(t){return t.name==="CodeExpectedError"}},Us=class Vo extends Error{constructor(t){super(t||"An unexpected bug occurred."),Object.setPrototypeOf(this,Vo.prototype)}};function je(e,t=0){return e[e.length-(1+t)]}var Gl;(e=>{function t(n){return n<0}e.isLessThan=t;function i(n){return n<=0}e.isLessThanOrEqual=i;function s(n){return n>0}e.isGreaterThan=s;function r(n){return n===0}e.isNeitherLessOrGreaterThan=r,e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})(Gl||(Gl={}));function Yl(e,t){let i=this,s=!1,r;return function(){return s||(s=!0,t||(r=e.apply(i,arguments))),r}}var Go;(e=>{function t(M){return M&&typeof M=="object"&&typeof M[Symbol.iterator]=="function"}e.is=t;let i=Object.freeze([]);function s(){return i}e.empty=s;function*r(M){yield M}e.single=r;function n(M){return t(M)?M:r(M)}e.wrap=n;function o(M){return M||i}e.from=o;function*a(M){for(let $=M.length-1;$>=0;$--)yield M[$]}e.reverse=a;function h(M){return!M||M[Symbol.iterator]().next().done===!0}e.isEmpty=h;function l(M){return M[Symbol.iterator]().next().value}e.first=l;function c(M,$){let K=0;for(let ae of M)if($(ae,K++))return!0;return!1}e.some=c;function d(M,$){for(let K of M)if($(K))return K}e.find=d;function*u(M,$){for(let K of M)$(K)&&(yield K)}e.filter=u;function*f(M,$){let K=0;for(let ae of M)yield $(ae,K++)}e.map=f;function*_(M,$){let K=0;for(let ae of M)yield*$(ae,K++)}e.flatMap=_;function*p(...M){for(let $ of M)yield*$}e.concat=p;function g(M,$,K){let ae=K;for(let ne of M)ae=$(ae,ne);return ae}e.reduce=g;function*E(M,$,K=M.length){for($<0&&($+=M.length),K<0?K+=M.length:K>M.length&&(K=M.length);$1)throw new AggregateError(t,"Encountered errors while disposing of store");return Array.isArray(e)?[]:e}else if(e)return e.dispose(),e}function Xl(...e){return oe(()=>At(e))}function oe(e){return{dispose:Yl(()=>{e()})}}var Yo=class Xo{constructor(){this._toDispose=new Set,this._isDisposed=!1}dispose(){this._isDisposed||(this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(this._toDispose.size!==0)try{At(this._toDispose)}finally{this._toDispose.clear()}}add(t){if(!t)return t;if(t===this)throw new Error("Cannot register a disposable on itself!");return this._isDisposed?Xo.DISABLE_DISPOSED_WARNING||console.warn(new Error("Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!").stack):this._toDispose.add(t),t}delete(t){if(t){if(t===this)throw new Error("Cannot dispose a disposable on itself!");this._toDispose.delete(t),t.dispose()}}deleteAndLeak(t){t&&this._toDispose.has(t)&&(this._toDispose.delete(t),void 0)}};Yo.DISABLE_DISPOSED_WARNING=!1;var xt=Yo,G=class{constructor(){this._store=new xt,this._store}dispose(){this._store.dispose()}_register(e){if(e===this)throw new Error("Cannot register a disposable on itself!");return this._store.add(e)}};G.None=Object.freeze({dispose(){}});var Yt=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(e){var t;this._isDisposed||e===this._value||((t=this._value)==null||t.dispose(),this._value=e)}clear(){this.value=void 0}dispose(){var e;this._isDisposed=!0,(e=this._value)==null||e.dispose(),this._value=void 0}clearAndLeak(){let e=this._value;return this._value=void 0,e}},_t=typeof window=="object"?window:globalThis,js=class Ks{constructor(t){this.element=t,this.next=Ks.Undefined,this.prev=Ks.Undefined}};js.Undefined=new js(void 0);var he=js,Jr=class{constructor(){this._first=he.Undefined,this._last=he.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===he.Undefined}clear(){let e=this._first;for(;e!==he.Undefined;){let t=e.next;e.prev=he.Undefined,e.next=he.Undefined,e=t}this._first=he.Undefined,this._last=he.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let i=new he(e);if(this._first===he.Undefined)this._first=i,this._last=i;else if(t){let r=this._last;this._last=i,i.prev=r,r.next=i}else{let r=this._first;this._first=i,i.next=r,r.prev=i}this._size+=1;let s=!1;return()=>{s||(s=!0,this._remove(i))}}shift(){if(this._first!==he.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==he.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==he.Undefined&&e.next!==he.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===he.Undefined&&e.next===he.Undefined?(this._first=he.Undefined,this._last=he.Undefined):e.next===he.Undefined?(this._last=this._last.prev,this._last.next=he.Undefined):e.prev===he.Undefined&&(this._first=this._first.next,this._first.prev=he.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==he.Undefined;)yield e.element,e=e.next}},Jl=globalThis.performance&&typeof globalThis.performance.now=="function",Zl=class Jo{static create(t){return new Jo(t)}constructor(t){this._now=Jl&&t===!1?Date.now:globalThis.performance.now.bind(globalThis.performance),this._startTime=this._now(),this._stopTime=-1}stop(){this._stopTime=this._now()}reset(){this._startTime=this._now(),this._stopTime=-1}elapsed(){return this._stopTime!==-1?this._stopTime-this._startTime:this._now()-this._startTime}},Le;(e=>{e.None=()=>G.None;function t(N,S){return d(N,()=>{},0,void 0,!0,void 0,S)}e.defer=t;function i(N){return(S,L=null,x)=>{let A=!1,F;return F=N(B=>{if(!A)return F?F.dispose():A=!0,S.call(L,B)},null,x),A&&F.dispose(),F}}e.once=i;function s(N,S,L){return l((x,A=null,F)=>N(B=>x.call(A,S(B)),null,F),L)}e.map=s;function r(N,S,L){return l((x,A=null,F)=>N(B=>{S(B),x.call(A,B)},null,F),L)}e.forEach=r;function n(N,S,L){return l((x,A=null,F)=>N(B=>S(B)&&x.call(A,B),null,F),L)}e.filter=n;function o(N){return N}e.signal=o;function a(...N){return(S,L=null,x)=>{let A=Xl(...N.map(F=>F(B=>S.call(L,B))));return c(A,x)}}e.any=a;function h(N,S,L,x){let A=L;return s(N,F=>(A=S(A,F),A),x)}e.reduce=h;function l(N,S){let L,x={onWillAddFirstListener(){L=N(A.fire,A)},onDidRemoveLastListener(){L==null||L.dispose()}},A=new k(x);return S==null||S.add(A),A.event}function c(N,S){return S instanceof Array?S.push(N):S&&S.add(N),N}function d(N,S,L=100,x=!1,A=!1,F,B){let X,te,He,Qe=0,le,Te={leakWarningThreshold:F,onWillAddFirstListener(){X=N(We=>{Qe++,te=S(te,We),x&&!He&&(Ve.fire(te),te=void 0),le=()=>{let dt=te;te=void 0,He=void 0,(!x||Qe>1)&&Ve.fire(dt),Qe=0},typeof L=="number"?(clearTimeout(He),He=setTimeout(le,L)):He===void 0&&(He=0,queueMicrotask(le))})},onWillRemoveListener(){A&&Qe>0&&(le==null||le())},onDidRemoveLastListener(){le=void 0,X.dispose()}},Ve=new k(Te);return B==null||B.add(Ve),Ve.event}e.debounce=d;function u(N,S=0,L){return e.debounce(N,(x,A)=>x?(x.push(A),x):[A],S,void 0,!0,void 0,L)}e.accumulate=u;function f(N,S=(x,A)=>x===A,L){let x=!0,A;return n(N,F=>{let B=x||!S(F,A);return x=!1,A=F,B},L)}e.latch=f;function _(N,S,L){return[e.filter(N,S,L),e.filter(N,x=>!S(x),L)]}e.split=_;function p(N,S=!1,L=[],x){let A=L.slice(),F=N(te=>{A?A.push(te):X.fire(te)});x&&x.add(F);let B=()=>{A==null||A.forEach(te=>X.fire(te)),A=null},X=new k({onWillAddFirstListener(){F||(F=N(te=>X.fire(te)),x&&x.add(F))},onDidAddFirstListener(){A&&(S?setTimeout(B):B())},onDidRemoveLastListener(){F&&F.dispose(),F=null}});return x&&x.add(X),X.event}e.buffer=p;function g(N,S){return(L,x,A)=>{let F=S(new z);return N(function(B){let X=F.evaluate(B);X!==E&&L.call(x,X)},void 0,A)}}e.chain=g;let E=Symbol("HaltChainable");class z{constructor(){this.steps=[]}map(S){return this.steps.push(S),this}forEach(S){return this.steps.push(L=>(S(L),L)),this}filter(S){return this.steps.push(L=>S(L)?L:E),this}reduce(S,L){let x=L;return this.steps.push(A=>(x=S(x,A),x)),this}latch(S=(L,x)=>L===x){let L=!0,x;return this.steps.push(A=>{let F=L||!S(A,x);return L=!1,x=A,F?A:E}),this}evaluate(S){for(let L of this.steps)if(S=L(S),S===E)break;return S}}function O(N,S,L=x=>x){let x=(...X)=>B.fire(L(...X)),A=()=>N.on(S,x),F=()=>N.removeListener(S,x),B=new k({onWillAddFirstListener:A,onDidRemoveLastListener:F});return B.event}e.fromNodeEventEmitter=O;function M(N,S,L=x=>x){let x=(...X)=>B.fire(L(...X)),A=()=>N.addEventListener(S,x),F=()=>N.removeEventListener(S,x),B=new k({onWillAddFirstListener:A,onDidRemoveLastListener:F});return B.event}e.fromDOMEventEmitter=M;function $(N){return new Promise(S=>i(N)(S))}e.toPromise=$;function K(N){let S=new k;return N.then(L=>{S.fire(L)},()=>{S.fire(void 0)}).finally(()=>{S.dispose()}),S.event}e.fromPromise=K;function ae(N,S){return N(L=>S.fire(L))}e.forward=ae;function ne(N,S,L){return S(L),N(x=>S(x))}e.runAndSubscribe=ne;class J{constructor(S,L){this._observable=S,this._counter=0,this._hasChanged=!1;let x={onWillAddFirstListener:()=>{S.addObserver(this)},onDidRemoveLastListener:()=>{S.removeObserver(this)}};this.emitter=new k(x),L&&L.add(this.emitter)}beginUpdate(S){this._counter++}handlePossibleChange(S){}handleChange(S,L){this._hasChanged=!0}endUpdate(S){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function Fe(N,S){return new J(N,S).emitter.event}e.fromObservable=Fe;function Y(N){return(S,L,x)=>{let A=0,F=!1,B={beginUpdate(){A++},endUpdate(){A--,A===0&&(N.reportChanges(),F&&(F=!1,S.call(L)))},handlePossibleChange(){},handleChange(){F=!0}};N.addObserver(B),N.reportChanges();let X={dispose(){N.removeObserver(B)}};return x instanceof xt?x.add(X):Array.isArray(x)&&x.push(X),X}}e.fromObservableLight=Y})(Le||(Le={}));var qs=class Vs{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${Vs._idPool++}`,Vs.all.add(this)}start(t){this._stopWatch=new Zl,this.listenerCount=t}stop(){if(this._stopWatch){let t=this._stopWatch.elapsed();this.durations.push(t),this.elapsedOverall+=t,this.invocationCount+=1,this._stopWatch=void 0}}};qs.all=new Set,qs._idPool=0;var Ql=qs,eh=-1,Zo=class Qo{constructor(t,i,s=(Qo._idPool++).toString(16).padStart(3,"0")){this._errorHandler=t,this.threshold=i,this.name=s,this._warnCountdown=0}dispose(){var t;(t=this._stacks)==null||t.clear()}check(t,i){let s=this.threshold;if(s<=0||i{let n=this._stacks.get(t.value)||0;this._stacks.set(t.value,n-1)}}getMostFrequentStack(){if(!this._stacks)return;let t,i=0;for(let[s,r]of this._stacks)(!t||i{this._removeListener(e)}}emit(e){this.listeners.forEach(t=>{t(e)})}_removeListener(e){this.listeners.splice(this.listeners.indexOf(e),1)}setUnexpectedErrorHandler(e){this.unexpectedErrorHandler=e}getUnexpectedErrorHandler(){return this.unexpectedErrorHandler}onUnexpectedError(e){this.unexpectedErrorHandler(e),this.emit(e)}onUnexpectedExternalError(e){this.unexpectedErrorHandler(e)}},jl=new Ul;function Wi(e){Kl(e)||jl.onUnexpectedError(e)}var Ws="Canceled";function Kl(e){return e instanceof ql?!0:e instanceof Error&&e.name===Ws&&e.message===Ws}var ql=class extends Error{constructor(){super(Ws),this.name=this.message}};function Vl(e){return new Error(`Illegal argument: ${e}`)}var Xr=class zs extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(t){if(t instanceof zs)return t;let i=new zs;return i.message=t.message,i.stack=t.stack,i}static isErrorNoTelemetry(t){return t.name==="CodeExpectedError"}},Us=class Vo extends Error{constructor(t){super(t||"An unexpected bug occurred."),Object.setPrototypeOf(this,Vo.prototype)}};function je(e,t=0){return e[e.length-(1+t)]}var Gl;(e=>{function t(n){return n<0}e.isLessThan=t;function i(n){return n<=0}e.isLessThanOrEqual=i;function s(n){return n>0}e.isGreaterThan=s;function r(n){return n===0}e.isNeitherLessOrGreaterThan=r,e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})(Gl||(Gl={}));function Yl(e,t){let i=this,s=!1,r;return function(){return s||(s=!0,t||(r=e.apply(i,arguments))),r}}var Go;(e=>{function t(M){return M&&typeof M=="object"&&typeof M[Symbol.iterator]=="function"}e.is=t;let i=Object.freeze([]);function s(){return i}e.empty=s;function*r(M){yield M}e.single=r;function n(M){return t(M)?M:r(M)}e.wrap=n;function o(M){return M||i}e.from=o;function*a(M){for(let $=M.length-1;$>=0;$--)yield M[$]}e.reverse=a;function h(M){return!M||M[Symbol.iterator]().next().done===!0}e.isEmpty=h;function l(M){return M[Symbol.iterator]().next().value}e.first=l;function c(M,$){let K=0;for(let ae of M)if($(ae,K++))return!0;return!1}e.some=c;function d(M,$){for(let K of M)if($(K))return K}e.find=d;function*u(M,$){for(let K of M)$(K)&&(yield K)}e.filter=u;function*f(M,$){let K=0;for(let ae of M)yield $(ae,K++)}e.map=f;function*_(M,$){let K=0;for(let ae of M)yield*$(ae,K++)}e.flatMap=_;function*p(...M){for(let $ of M)yield*$}e.concat=p;function g(M,$,K){let ae=K;for(let ne of M)ae=$(ae,ne);return ae}e.reduce=g;function*E(M,$,K=M.length){for($<0&&($+=M.length),K<0?K+=M.length:K>M.length&&(K=M.length);$1)throw new AggregateError(t,"Encountered errors while disposing of store");return Array.isArray(e)?[]:e}else if(e)return e.dispose(),e}function Xl(...e){return oe(()=>At(e))}function oe(e){return{dispose:Yl(()=>{e()})}}var Yo=class Xo{constructor(){this._toDispose=new Set,this._isDisposed=!1}dispose(){this._isDisposed||(this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(this._toDispose.size!==0)try{At(this._toDispose)}finally{this._toDispose.clear()}}add(t){if(!t)return t;if(t===this)throw new Error("Cannot register a disposable on itself!");return this._isDisposed?Xo.DISABLE_DISPOSED_WARNING||console.warn(new Error("Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!").stack):this._toDispose.add(t),t}delete(t){if(t){if(t===this)throw new Error("Cannot dispose a disposable on itself!");this._toDispose.delete(t),t.dispose()}}deleteAndLeak(t){t&&this._toDispose.has(t)&&(this._toDispose.delete(t),void 0)}};Yo.DISABLE_DISPOSED_WARNING=!1;var xt=Yo,G=class{constructor(){this._store=new xt,this._store}dispose(){this._store.dispose()}_register(e){if(e===this)throw new Error("Cannot register a disposable on itself!");return this._store.add(e)}};G.None=Object.freeze({dispose(){}});var Yt=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(e){var t;this._isDisposed||e===this._value||((t=this._value)==null||t.dispose(),this._value=e)}clear(){this.value=void 0}dispose(){var e;this._isDisposed=!0,(e=this._value)==null||e.dispose(),this._value=void 0}clearAndLeak(){let e=this._value;return this._value=void 0,e}},_t=typeof window=="object"?window:globalThis,js=class Ks{constructor(t){this.element=t,this.next=Ks.Undefined,this.prev=Ks.Undefined}};js.Undefined=new js(void 0);var he=js,Jr=class{constructor(){this._first=he.Undefined,this._last=he.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===he.Undefined}clear(){let e=this._first;for(;e!==he.Undefined;){let t=e.next;e.prev=he.Undefined,e.next=he.Undefined,e=t}this._first=he.Undefined,this._last=he.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let i=new he(e);if(this._first===he.Undefined)this._first=i,this._last=i;else if(t){let r=this._last;this._last=i,i.prev=r,r.next=i}else{let r=this._first;this._first=i,i.next=r,r.prev=i}this._size+=1;let s=!1;return()=>{s||(s=!0,this._remove(i))}}shift(){if(this._first!==he.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==he.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==he.Undefined&&e.next!==he.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===he.Undefined&&e.next===he.Undefined?(this._first=he.Undefined,this._last=he.Undefined):e.next===he.Undefined?(this._last=this._last.prev,this._last.next=he.Undefined):e.prev===he.Undefined&&(this._first=this._first.next,this._first.prev=he.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==he.Undefined;)yield e.element,e=e.next}},Jl=globalThis.performance&&typeof globalThis.performance.now=="function",Zl=class Jo{static create(t){return new Jo(t)}constructor(t){this._now=Jl&&t===!1?Date.now:globalThis.performance.now.bind(globalThis.performance),this._startTime=this._now(),this._stopTime=-1}stop(){this._stopTime=this._now()}reset(){this._startTime=this._now(),this._stopTime=-1}elapsed(){return this._stopTime!==-1?this._stopTime-this._startTime:this._now()-this._startTime}},Le;(e=>{e.None=()=>G.None;function t(N,S){return d(N,()=>{},0,void 0,!0,void 0,S)}e.defer=t;function i(N){return(S,L=null,x)=>{let A=!1,H;return H=N(B=>{if(!A)return H?H.dispose():A=!0,S.call(L,B)},null,x),A&&H.dispose(),H}}e.once=i;function s(N,S,L){return l((x,A=null,H)=>N(B=>x.call(A,S(B)),null,H),L)}e.map=s;function r(N,S,L){return l((x,A=null,H)=>N(B=>{S(B),x.call(A,B)},null,H),L)}e.forEach=r;function n(N,S,L){return l((x,A=null,H)=>N(B=>S(B)&&x.call(A,B),null,H),L)}e.filter=n;function o(N){return N}e.signal=o;function a(...N){return(S,L=null,x)=>{let A=Xl(...N.map(H=>H(B=>S.call(L,B))));return c(A,x)}}e.any=a;function h(N,S,L,x){let A=L;return s(N,H=>(A=S(A,H),A),x)}e.reduce=h;function l(N,S){let L,x={onWillAddFirstListener(){L=N(A.fire,A)},onDidRemoveLastListener(){L==null||L.dispose()}},A=new k(x);return S==null||S.add(A),A.event}function c(N,S){return S instanceof Array?S.push(N):S&&S.add(N),N}function d(N,S,L=100,x=!1,A=!1,H,B){let X,te,Fe,Qe=0,le,Te={leakWarningThreshold:H,onWillAddFirstListener(){X=N(We=>{Qe++,te=S(te,We),x&&!Fe&&(Ve.fire(te),te=void 0),le=()=>{let dt=te;te=void 0,Fe=void 0,(!x||Qe>1)&&Ve.fire(dt),Qe=0},typeof L=="number"?(clearTimeout(Fe),Fe=setTimeout(le,L)):Fe===void 0&&(Fe=0,queueMicrotask(le))})},onWillRemoveListener(){A&&Qe>0&&(le==null||le())},onDidRemoveLastListener(){le=void 0,X.dispose()}},Ve=new k(Te);return B==null||B.add(Ve),Ve.event}e.debounce=d;function u(N,S=0,L){return e.debounce(N,(x,A)=>x?(x.push(A),x):[A],S,void 0,!0,void 0,L)}e.accumulate=u;function f(N,S=(x,A)=>x===A,L){let x=!0,A;return n(N,H=>{let B=x||!S(H,A);return x=!1,A=H,B},L)}e.latch=f;function _(N,S,L){return[e.filter(N,S,L),e.filter(N,x=>!S(x),L)]}e.split=_;function p(N,S=!1,L=[],x){let A=L.slice(),H=N(te=>{A?A.push(te):X.fire(te)});x&&x.add(H);let B=()=>{A==null||A.forEach(te=>X.fire(te)),A=null},X=new k({onWillAddFirstListener(){H||(H=N(te=>X.fire(te)),x&&x.add(H))},onDidAddFirstListener(){A&&(S?setTimeout(B):B())},onDidRemoveLastListener(){H&&H.dispose(),H=null}});return x&&x.add(X),X.event}e.buffer=p;function g(N,S){return(L,x,A)=>{let H=S(new z);return N(function(B){let X=H.evaluate(B);X!==E&&L.call(x,X)},void 0,A)}}e.chain=g;let E=Symbol("HaltChainable");class z{constructor(){this.steps=[]}map(S){return this.steps.push(S),this}forEach(S){return this.steps.push(L=>(S(L),L)),this}filter(S){return this.steps.push(L=>S(L)?L:E),this}reduce(S,L){let x=L;return this.steps.push(A=>(x=S(x,A),x)),this}latch(S=(L,x)=>L===x){let L=!0,x;return this.steps.push(A=>{let H=L||!S(A,x);return L=!1,x=A,H?A:E}),this}evaluate(S){for(let L of this.steps)if(S=L(S),S===E)break;return S}}function O(N,S,L=x=>x){let x=(...X)=>B.fire(L(...X)),A=()=>N.on(S,x),H=()=>N.removeListener(S,x),B=new k({onWillAddFirstListener:A,onDidRemoveLastListener:H});return B.event}e.fromNodeEventEmitter=O;function M(N,S,L=x=>x){let x=(...X)=>B.fire(L(...X)),A=()=>N.addEventListener(S,x),H=()=>N.removeEventListener(S,x),B=new k({onWillAddFirstListener:A,onDidRemoveLastListener:H});return B.event}e.fromDOMEventEmitter=M;function $(N){return new Promise(S=>i(N)(S))}e.toPromise=$;function K(N){let S=new k;return N.then(L=>{S.fire(L)},()=>{S.fire(void 0)}).finally(()=>{S.dispose()}),S.event}e.fromPromise=K;function ae(N,S){return N(L=>S.fire(L))}e.forward=ae;function ne(N,S,L){return S(L),N(x=>S(x))}e.runAndSubscribe=ne;class J{constructor(S,L){this._observable=S,this._counter=0,this._hasChanged=!1;let x={onWillAddFirstListener:()=>{S.addObserver(this)},onDidRemoveLastListener:()=>{S.removeObserver(this)}};this.emitter=new k(x),L&&L.add(this.emitter)}beginUpdate(S){this._counter++}handlePossibleChange(S){}handleChange(S,L){this._hasChanged=!0}endUpdate(S){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function He(N,S){return new J(N,S).emitter.event}e.fromObservable=He;function Y(N){return(S,L,x)=>{let A=0,H=!1,B={beginUpdate(){A++},endUpdate(){A--,A===0&&(N.reportChanges(),H&&(H=!1,S.call(L)))},handlePossibleChange(){},handleChange(){H=!0}};N.addObserver(B),N.reportChanges();let X={dispose(){N.removeObserver(B)}};return x instanceof xt?x.add(X):Array.isArray(x)&&x.push(X),X}}e.fromObservableLight=Y})(Le||(Le={}));var qs=class Vs{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${Vs._idPool++}`,Vs.all.add(this)}start(t){this._stopWatch=new Zl,this.listenerCount=t}stop(){if(this._stopWatch){let t=this._stopWatch.elapsed();this.durations.push(t),this.elapsedOverall+=t,this.invocationCount+=1,this._stopWatch=void 0}}};qs.all=new Set,qs._idPool=0;var Ql=qs,eh=-1,Zo=class Qo{constructor(t,i,s=(Qo._idPool++).toString(16).padStart(3,"0")){this._errorHandler=t,this.threshold=i,this.name=s,this._warnCountdown=0}dispose(){var t;(t=this._stacks)==null||t.clear()}check(t,i){let s=this.threshold;if(s<=0||i{let n=this._stacks.get(t.value)||0;this._stacks.set(t.value,n-1)}}getMostFrequentStack(){if(!this._stacks)return;let t,i=0;for(let[s,r]of this._stacks)(!t||i{var a,h,l,c,d;if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let u=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(u);let f=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],_=new rh(`${u}. HINT: Stack shows most frequent listener (${f[1]}-times)`,f[0]);return(((a=this._options)==null?void 0:a.onListenerError)||Wi)(_),G.None}if(this._disposed)return G.None;i&&(t=t.bind(i));let r=new ps(t),n;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(r.stack=ih.create(),n=this._leakageMon.check(r.stack,this._size+1)),this._listeners?this._listeners instanceof ps?(this._deliveryQueue??(this._deliveryQueue=new lh),this._listeners=[this._listeners,r]):this._listeners.push(r):((l=(h=this._options)==null?void 0:h.onWillAddFirstListener)==null||l.call(h,this),this._listeners=r,(d=(c=this._options)==null?void 0:c.onDidAddFirstListener)==null||d.call(c,this)),this._size++;let o=oe(()=>{n==null||n(),this._removeListener(r)});return s instanceof xt?s.add(o):Array.isArray(s)&&s.push(o),o}),this._event}_removeListener(t){var n,o,a,h;if((o=(n=this._options)==null?void 0:n.onWillRemoveListener)==null||o.call(n,this),!this._listeners)return;if(this._size===1){this._listeners=void 0,(h=(a=this._options)==null?void 0:a.onDidRemoveLastListener)==null||h.call(a,this),this._size=0;return}let i=this._listeners,s=i.indexOf(t);if(s===-1)throw console.log("disposed?",this._disposed),console.log("size?",this._size),console.log("arr?",JSON.stringify(this._listeners)),new Error("Attempted to dispose unknown listener");this._size--,i[s]=void 0;let r=this._deliveryQueue.current===this;if(this._size*oh<=i.length){let l=0;for(let c=0;c0}},lh=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,i){this.i=0,this.end=i,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},Gs=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new k,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new k,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(t){return this.mapWindowIdToZoomLevel.get(this.getWindowId(t))??0}setZoomLevel(t,i){if(this.getZoomLevel(i)===t)return;let s=this.getWindowId(i);this.mapWindowIdToZoomLevel.set(s,t),this._onDidChangeZoomLevel.fire(s)}getZoomFactor(t){return this.mapWindowIdToZoomFactor.get(this.getWindowId(t))??1}setZoomFactor(t,i){this.mapWindowIdToZoomFactor.set(this.getWindowId(i),t)}setFullscreen(t,i){if(this.isFullscreen(i)===t)return;let s=this.getWindowId(i);this.mapWindowIdToFullScreen.set(s,t),this._onDidChangeFullscreen.fire(s)}isFullscreen(t){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(t))}getWindowId(t){return t.vscodeWindowId}};Gs.INSTANCE=new Gs;var Br=Gs;function hh(e,t,i){typeof t=="string"&&(t=e.matchMedia(t)),t.addEventListener("change",i)}Br.INSTANCE.onDidChangeZoomLevel;function ch(e){return Br.INSTANCE.getZoomFactor(e)}Br.INSTANCE.onDidChangeFullscreen;var Zt=typeof navigator=="object"?navigator.userAgent:"",Ys=Zt.indexOf("Firefox")>=0,dh=Zt.indexOf("AppleWebKit")>=0,Mr=Zt.indexOf("Chrome")>=0,uh=!Mr&&Zt.indexOf("Safari")>=0;Zt.indexOf("Electron/")>=0;Zt.indexOf("Android")>=0;var ms=!1;if(typeof _t.matchMedia=="function"){let e=_t.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),t=_t.matchMedia("(display-mode: fullscreen)");ms=e.matches,hh(_t,e,({matches:i})=>{ms&&t.matches||(ms=i)})}var Kt="en",Xs=!1,Js=!1,zi=!1,ta=!1,$i,Ui=Kt,Zr=Kt,_h,tt,$t=globalThis,De,So;typeof $t.vscode<"u"&&typeof $t.vscode.process<"u"?De=$t.vscode.process:typeof process<"u"&&typeof((So=process==null?void 0:process.versions)==null?void 0:So.node)=="string"&&(De=process);var yo,fh=typeof((yo=De==null?void 0:De.versions)==null?void 0:yo.electron)=="string",ph=fh&&(De==null?void 0:De.type)==="renderer",bo;if(typeof De=="object"){Xs=De.platform==="win32",Js=De.platform==="darwin",zi=De.platform==="linux",zi&&De.env.SNAP&&De.env.SNAP_REVISION,De.env.CI||De.env.BUILD_ARTIFACTSTAGINGDIRECTORY,$i=Kt,Ui=Kt;let e=De.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);$i=t.userLocale,Zr=t.osLocale,Ui=t.resolvedLanguage||Kt,_h=(bo=t.languagePack)==null?void 0:bo.translationsConfigFile}catch{}ta=!0}else typeof navigator=="object"&&!ph?(tt=navigator.userAgent,Xs=tt.indexOf("Windows")>=0,Js=tt.indexOf("Macintosh")>=0,(tt.indexOf("Macintosh")>=0||tt.indexOf("iPad")>=0||tt.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,zi=tt.indexOf("Linux")>=0,(tt==null?void 0:tt.indexOf("Mobi"))>=0,Ui=globalThis._VSCODE_NLS_LANGUAGE||Kt,$i=navigator.language.toLowerCase(),Zr=$i):console.error("Unable to resolve platform.");var ia=Xs,ht=Js,mh=zi,Qr=ta,ct=tt,mt=Ui,gh;(e=>{function t(){return mt}e.value=t;function i(){return mt.length===2?mt==="en":mt.length>=3?mt[0]==="e"&&mt[1]==="n"&&mt[2]==="-":!1}e.isDefaultVariant=i;function s(){return mt==="en"}e.isDefault=s})(gh||(gh={}));var vh=typeof $t.postMessage=="function"&&!$t.importScripts;(()=>{if(vh){let e=[];$t.addEventListener("message",i=>{if(i.data&&i.data.vscodeScheduleAsyncWork)for(let s=0,r=e.length;s{let s=++t;e.push({id:s,callback:i}),$t.postMessage({vscodeScheduleAsyncWork:s},"*")}}return e=>setTimeout(e)})();var Sh=!!(ct&&ct.indexOf("Chrome")>=0);ct&&ct.indexOf("Firefox")>=0;!Sh&&ct&&ct.indexOf("Safari")>=0;ct&&ct.indexOf("Edg/")>=0;ct&&ct.indexOf("Android")>=0;var Ht=typeof navigator=="object"?navigator:{};Qr||document.queryCommandSupported&&document.queryCommandSupported("copy")||Ht&&Ht.clipboard&&Ht.clipboard.writeText,Qr||Ht&&Ht.clipboard&&Ht.clipboard.readText;var Dr=class{constructor(){this._keyCodeToStr=[],this._strToKeyCode=Object.create(null)}define(e,t){this._keyCodeToStr[e]=t,this._strToKeyCode[t.toLowerCase()]=e}keyCodeToStr(e){return this._keyCodeToStr[e]}strToKeyCode(e){return this._strToKeyCode[e.toLowerCase()]||0}},gs=new Dr,en=new Dr,tn=new Dr,yh=new Array(230),sa;(e=>{function t(a){return gs.keyCodeToStr(a)}e.toString=t;function i(a){return gs.strToKeyCode(a)}e.fromString=i;function s(a){return en.keyCodeToStr(a)}e.toUserSettingsUS=s;function r(a){return tn.keyCodeToStr(a)}e.toUserSettingsGeneral=r;function n(a){return en.strToKeyCode(a)||tn.strToKeyCode(a)}e.fromUserSettings=n;function o(a){if(a>=98&&a<=113)return null;switch(a){case 16:return"Up";case 18:return"Down";case 15:return"Left";case 17:return"Right"}return gs.keyCodeToStr(a)}e.toElectronAccelerator=o})(sa||(sa={}));var bh=class ra{constructor(t,i,s,r,n){this.ctrlKey=t,this.shiftKey=i,this.altKey=s,this.metaKey=r,this.keyCode=n}equals(t){return t instanceof ra&&this.ctrlKey===t.ctrlKey&&this.shiftKey===t.shiftKey&&this.altKey===t.altKey&&this.metaKey===t.metaKey&&this.keyCode===t.keyCode}getHashCode(){let t=this.ctrlKey?"1":"0",i=this.shiftKey?"1":"0",s=this.altKey?"1":"0",r=this.metaKey?"1":"0";return`K${t}${i}${s}${r}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new wh([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},wh=class{constructor(e){if(e.length===0)throw Vl("chords");this.chords=e}getHashCode(){let e="";for(let t=0,i=this.chords.length;t{function t(i){return i===e.None||i===e.Cancelled||i instanceof Lh?!0:!i||typeof i!="object"?!1:typeof i.isCancellationRequested=="boolean"&&typeof i.onCancellationRequested=="function"}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:Le.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:na})})(Dh||(Dh={}));var Lh=class{constructor(){this._isCancelled=!1,this._emitter=null}cancel(){this._isCancelled||(this._isCancelled=!0,this._emitter&&(this._emitter.fire(void 0),this.dispose()))}get isCancellationRequested(){return this._isCancelled}get onCancellationRequested(){return this._isCancelled?na:(this._emitter||(this._emitter=new k),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},Lr=class{constructor(e,t){this._isDisposed=!1,this._token=-1,typeof e=="function"&&typeof t=="number"&&this.setIfNotSet(e,t)}dispose(){this.cancel(),this._isDisposed=!0}cancel(){this._token!==-1&&(clearTimeout(this._token),this._token=-1)}cancelAndSet(e,t){if(this._isDisposed)throw new Us("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new Us("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},Th=class{constructor(){this.disposable=void 0,this.isDisposed=!1}cancel(){var e;(e=this.disposable)==null||e.dispose(),this.disposable=void 0}cancelAndSet(e,t,i=globalThis){if(this.isDisposed)throw new Us("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let s=i.setInterval(()=>{e()},t);this.disposable=oe(()=>{i.clearInterval(s),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},$h;(e=>{async function t(s){let r,n=await Promise.all(s.map(o=>o.then(a=>a,a=>{r||(r=a)})));if(typeof r<"u")throw r;return n}e.settled=t;function i(s){return new Promise(async(r,n)=>{try{await s(r,n)}catch(o){n(o)}})}e.withAsyncBody=i})($h||($h={}));var on=class Ye{static fromArray(t){return new Ye(i=>{i.emitMany(t)})}static fromPromise(t){return new Ye(async i=>{i.emitMany(await t)})}static fromPromises(t){return new Ye(async i=>{await Promise.all(t.map(async s=>i.emitOne(await s)))})}static merge(t){return new Ye(async i=>{await Promise.all(t.map(async s=>{for await(let r of s)i.emitOne(r)}))})}constructor(t,i){this._state=0,this._results=[],this._error=null,this._onReturn=i,this._onStateChanged=new k,queueMicrotask(async()=>{let s={emitOne:r=>this.emitOne(r),emitMany:r=>this.emitMany(r),reject:r=>this.reject(r)};try{await Promise.resolve(t(s)),this.resolve()}catch(r){this.reject(r)}finally{s.emitOne=void 0,s.emitMany=void 0,s.reject=void 0}})}[Symbol.asyncIterator](){let t=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(t{var i;return(i=this._onReturn)==null||i.call(this),{done:!0,value:void 0}}}}static map(t,i){return new Ye(async s=>{for await(let r of t)s.emitOne(i(r))})}map(t){return Ye.map(this,t)}static filter(t,i){return new Ye(async s=>{for await(let r of t)i(r)&&s.emitOne(r)})}filter(t){return Ye.filter(this,t)}static coalesce(t){return Ye.filter(t,i=>!!i)}coalesce(){return Ye.coalesce(this)}static async toPromise(t){let i=[];for await(let s of t)i.push(s);return i}toPromise(){return Ye.toPromise(this)}emitOne(t){this._state===0&&(this._results.push(t),this._onStateChanged.fire())}emitMany(t){this._state===0&&(this._results=this._results.concat(t),this._onStateChanged.fire())}resolve(){this._state===0&&(this._state=1,this._onStateChanged.fire())}reject(t){this._state===0&&(this._state=2,this._error=t,this._onStateChanged.fire())}};on.EMPTY=on.fromArray([]);var{getWindow:lt,getWindowId:Ah,onDidRegisterWindow:Ph}=(function(){let e=new Map,t={window:_t,disposables:new xt};e.set(_t.vscodeWindowId,t);let i=new k,s=new k,r=new k;function n(o,a){return(typeof o=="number"?e.get(o):void 0)??(a?t:void 0)}return{onDidRegisterWindow:i.event,onWillUnregisterWindow:r.event,onDidUnregisterWindow:s.event,registerWindow(o){if(e.has(o.vscodeWindowId))return G.None;let a=new xt,h={window:o,disposables:a.add(new xt)};return e.set(o.vscodeWindowId,h),a.add(oe(()=>{e.delete(o.vscodeWindowId),s.fire(o)})),a.add(j(o,ke.BEFORE_UNLOAD,()=>{r.fire(o)})),i.fire(h),a},getWindows(){return e.values()},getWindowsCount(){return e.size},getWindowId(o){return o.vscodeWindowId},hasWindow(o){return e.has(o)},getWindowById:n,getWindow(o){var l;let a=o;if((l=a==null?void 0:a.ownerDocument)!=null&&l.defaultView)return a.ownerDocument.defaultView.window;let h=o;return h!=null&&h.view?h.view.window:_t},getDocument(o){return lt(o).document}}})(),Nh=class{constructor(e,t,i,s){this._node=e,this._type=t,this._handler=i,this._options=s||!1,this._node.addEventListener(this._type,this._handler,this._options)}dispose(){this._handler&&(this._node.removeEventListener(this._type,this._handler,this._options),this._node=null,this._handler=null)}};function j(e,t,i,s){return new Nh(e,t,i,s)}var an=function(e,t,i,s){return j(e,t,i,s)},Tr,Ih=class extends Th{constructor(e){super(),this.defaultTarget=e&<(e)}cancelAndSet(e,t,i){return super.cancelAndSet(e,t,i??this.defaultTarget)}},ln=class{constructor(e,t=0){this._runner=e,this.priority=t,this._canceled=!1}dispose(){this._canceled=!0}execute(){if(!this._canceled)try{this._runner()}catch(e){Wi(e)}}static sort(e,t){return t.priority-e.priority}};(function(){let e=new Map,t=new Map,i=new Map,s=new Map,r=n=>{i.set(n,!1);let o=e.get(n)??[];for(t.set(n,o),e.set(n,[]),s.set(n,!0);o.length>0;)o.sort(ln.sort),o.shift().execute();s.set(n,!1)};Tr=(n,o,a=0)=>{let h=Ah(n),l=new ln(o,a),c=e.get(h);return c||(c=[],e.set(h,c)),c.push(l),i.get(h)||(i.set(h,!0),n.requestAnimationFrame(()=>r(h))),l}})();function Oh(e){let t=e.getBoundingClientRect(),i=lt(e);return{left:t.left+i.scrollX,top:t.top+i.scrollY,width:t.width,height:t.height}}var ke={CLICK:"click",MOUSE_DOWN:"mousedown",MOUSE_OVER:"mouseover",MOUSE_LEAVE:"mouseleave",MOUSE_WHEEL:"wheel",POINTER_UP:"pointerup",POINTER_DOWN:"pointerdown",POINTER_MOVE:"pointermove",KEY_DOWN:"keydown",KEY_UP:"keyup",BEFORE_UNLOAD:"beforeunload",CHANGE:"change",FOCUS:"focus",BLUR:"blur",INPUT:"input"},Fh=class{constructor(e){this.domNode=e,this._maxWidth="",this._width="",this._height="",this._top="",this._left="",this._bottom="",this._right="",this._paddingTop="",this._paddingLeft="",this._paddingBottom="",this._paddingRight="",this._fontFamily="",this._fontWeight="",this._fontSize="",this._fontStyle="",this._fontFeatureSettings="",this._fontVariationSettings="",this._textDecoration="",this._lineHeight="",this._letterSpacing="",this._className="",this._display="",this._position="",this._visibility="",this._color="",this._backgroundColor="",this._layerHint=!1,this._contain="none",this._boxShadow=""}setMaxWidth(e){let t=ze(e);this._maxWidth!==t&&(this._maxWidth=t,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let t=ze(e);this._width!==t&&(this._width=t,this.domNode.style.width=this._width)}setHeight(e){let t=ze(e);this._height!==t&&(this._height=t,this.domNode.style.height=this._height)}setTop(e){let t=ze(e);this._top!==t&&(this._top=t,this.domNode.style.top=this._top)}setLeft(e){let t=ze(e);this._left!==t&&(this._left=t,this.domNode.style.left=this._left)}setBottom(e){let t=ze(e);this._bottom!==t&&(this._bottom=t,this.domNode.style.bottom=this._bottom)}setRight(e){let t=ze(e);this._right!==t&&(this._right=t,this.domNode.style.right=this._right)}setPaddingTop(e){let t=ze(e);this._paddingTop!==t&&(this._paddingTop=t,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let t=ze(e);this._paddingLeft!==t&&(this._paddingLeft=t,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let t=ze(e);this._paddingBottom!==t&&(this._paddingBottom=t,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let t=ze(e);this._paddingRight!==t&&(this._paddingRight=t,this.domNode.style.paddingRight=this._paddingRight)}setFontFamily(e){this._fontFamily!==e&&(this._fontFamily=e,this.domNode.style.fontFamily=this._fontFamily)}setFontWeight(e){this._fontWeight!==e&&(this._fontWeight=e,this.domNode.style.fontWeight=this._fontWeight)}setFontSize(e){let t=ze(e);this._fontSize!==t&&(this._fontSize=t,this.domNode.style.fontSize=this._fontSize)}setFontStyle(e){this._fontStyle!==e&&(this._fontStyle=e,this.domNode.style.fontStyle=this._fontStyle)}setFontFeatureSettings(e){this._fontFeatureSettings!==e&&(this._fontFeatureSettings=e,this.domNode.style.fontFeatureSettings=this._fontFeatureSettings)}setFontVariationSettings(e){this._fontVariationSettings!==e&&(this._fontVariationSettings=e,this.domNode.style.fontVariationSettings=this._fontVariationSettings)}setTextDecoration(e){this._textDecoration!==e&&(this._textDecoration=e,this.domNode.style.textDecoration=this._textDecoration)}setLineHeight(e){let t=ze(e);this._lineHeight!==t&&(this._lineHeight=t,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let t=ze(e);this._letterSpacing!==t&&(this._letterSpacing=t,this.domNode.style.letterSpacing=this._letterSpacing)}setClassName(e){this._className!==e&&(this._className=e,this.domNode.className=this._className)}toggleClassName(e,t){this.domNode.classList.toggle(e,t),this._className=this.domNode.className}setDisplay(e){this._display!==e&&(this._display=e,this.domNode.style.display=this._display)}setPosition(e){this._position!==e&&(this._position=e,this.domNode.style.position=this._position)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this.domNode.style.visibility=this._visibility)}setColor(e){this._color!==e&&(this._color=e,this.domNode.style.color=this._color)}setBackgroundColor(e){this._backgroundColor!==e&&(this._backgroundColor=e,this.domNode.style.backgroundColor=this._backgroundColor)}setLayerHinting(e){this._layerHint!==e&&(this._layerHint=e,this.domNode.style.transform=this._layerHint?"translate3d(0px, 0px, 0px)":"")}setBoxShadow(e){this._boxShadow!==e&&(this._boxShadow=e,this.domNode.style.boxShadow=e)}setContain(e){this._contain!==e&&(this._contain=e,this.domNode.style.contain=this._contain)}setAttribute(e,t){this.domNode.setAttribute(e,t)}removeAttribute(e){this.domNode.removeAttribute(e)}appendChild(e){this.domNode.appendChild(e.domNode)}removeChild(e){this.domNode.removeChild(e.domNode)}};function ze(e){return typeof e=="number"?`${e}px`:e}function vi(e){return new Fh(e)}var oa=class{constructor(){this._hooks=new xt,this._pointerMoveCallback=null,this._onStopCallback=null}dispose(){this.stopMonitoring(!1),this._hooks.dispose()}stopMonitoring(e,t){if(!this.isMonitoring())return;this._hooks.clear(),this._pointerMoveCallback=null;let i=this._onStopCallback;this._onStopCallback=null,e&&i&&i(t)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(e,t,i,s,r){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=s,this._onStopCallback=r;let n=e;try{e.setPointerCapture(t),this._hooks.add(oe(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{n=lt(e)}this._hooks.add(j(n,ke.POINTER_MOVE,o=>{if(o.buttons!==i){this.stopMonitoring(!0);return}o.preventDefault(),this._pointerMoveCallback(o)})),this._hooks.add(j(n,ke.POINTER_UP,o=>this.stopMonitoring(!0)))}};function Hh(e,t,i){let s=null,r=null;if(typeof i.value=="function"?(s="value",r=i.value,r.length!==0&&console.warn("Memoize should only be used in functions with zero parameters")):typeof i.get=="function"&&(s="get",r=i.get),!r)throw new Error("not supported");let n=`$memoize$${t}`;i[s]=function(...o){return this.hasOwnProperty(n)||Object.defineProperty(this,n,{configurable:!1,enumerable:!1,writable:!1,value:r.apply(this,o)}),this[n]}}var at;(e=>(e.Tap="-xterm-gesturetap",e.Change="-xterm-gesturechange",e.Start="-xterm-gesturestart",e.End="-xterm-gesturesend",e.Contextmenu="-xterm-gesturecontextmenu"))(at||(at={}));var di=class $e extends G{constructor(){super(),this.dispatched=!1,this.targets=new Jr,this.ignoreTargets=new Jr,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(Le.runAndSubscribe(Ph,({window:t,disposables:i})=>{i.add(j(t.document,"touchstart",s=>this.onTouchStart(s),{passive:!1})),i.add(j(t.document,"touchend",s=>this.onTouchEnd(t,s))),i.add(j(t.document,"touchmove",s=>this.onTouchMove(s),{passive:!1}))},{window:_t,disposables:this._store}))}static addTarget(t){if(!$e.isTouchDevice())return G.None;$e.INSTANCE||($e.INSTANCE=new $e);let i=$e.INSTANCE.targets.push(t);return oe(i)}static ignoreTarget(t){if(!$e.isTouchDevice())return G.None;$e.INSTANCE||($e.INSTANCE=new $e);let i=$e.INSTANCE.ignoreTargets.push(t);return oe(i)}static isTouchDevice(){return"ontouchstart"in _t||navigator.maxTouchPoints>0}dispose(){this.handle&&(this.handle.dispose(),this.handle=null),super.dispose()}onTouchStart(t){let i=Date.now();this.handle&&(this.handle.dispose(),this.handle=null);for(let s=0,r=t.targetTouches.length;s=$e.HOLD_DELAY&&Math.abs(h.initialPageX-je(h.rollingPageX))<30&&Math.abs(h.initialPageY-je(h.rollingPageY))<30){let c=this.newGestureEvent(at.Contextmenu,h.initialTarget);c.pageX=je(h.rollingPageX),c.pageY=je(h.rollingPageY),this.dispatchEvent(c)}else if(r===1){let c=je(h.rollingPageX),d=je(h.rollingPageY),u=je(h.rollingTimestamps)-h.rollingTimestamps[0],f=c-h.rollingPageX[0],_=d-h.rollingPageY[0],p=[...this.targets].filter(g=>h.initialTarget instanceof Node&&g.contains(h.initialTarget));this.inertia(t,p,s,Math.abs(f)/u,f>0?1:-1,c,Math.abs(_)/u,_>0?1:-1,d)}this.dispatchEvent(this.newGestureEvent(at.End,h.initialTarget)),delete this.activeTouches[a.identifier]}this.dispatched&&(i.preventDefault(),i.stopPropagation(),this.dispatched=!1)}newGestureEvent(t,i){let s=document.createEvent("CustomEvent");return s.initEvent(t,!1,!0),s.initialTarget=i,s.tapCount=0,s}dispatchEvent(t){if(t.type===at.Tap){let i=new Date().getTime(),s=0;i-this._lastSetTapCountTime>$e.CLEAR_TAP_COUNT_TIME?s=1:s=2,this._lastSetTapCountTime=i,t.tapCount=s}else(t.type===at.Change||t.type===at.Contextmenu)&&(this._lastSetTapCountTime=0);if(t.initialTarget instanceof Node){for(let s of this.ignoreTargets)if(s.contains(t.initialTarget))return;let i=[];for(let s of this.targets)if(s.contains(t.initialTarget)){let r=0,n=t.initialTarget;for(;n&&n!==s;)r++,n=n.parentElement;i.push([r,s])}i.sort((s,r)=>s[0]-r[0]);for(let[s,r]of i)r.dispatchEvent(t),this.dispatched=!0}}inertia(t,i,s,r,n,o,a,h,l){this.handle=Tr(t,()=>{let c=Date.now(),d=c-s,u=0,f=0,_=!0;r+=$e.SCROLL_FRICTION*d,a+=$e.SCROLL_FRICTION*d,r>0&&(_=!1,u=n*r*d),a>0&&(_=!1,f=h*a*d);let p=this.newGestureEvent(at.Change);p.translationX=u,p.translationY=f,i.forEach(g=>g.dispatchEvent(p)),_||this.inertia(t,i,c,r,n,o+u,a,h,l+f)})}onTouchMove(t){let i=Date.now();for(let s=0,r=t.changedTouches.length;s3&&(o.rollingPageX.shift(),o.rollingPageY.shift(),o.rollingTimestamps.shift()),o.rollingPageX.push(n.pageX),o.rollingPageY.push(n.pageY),o.rollingTimestamps.push(i)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}};di.SCROLL_FRICTION=-.005,di.HOLD_DELAY=700,di.CLEAR_TAP_COUNT_TIME=400,_e([Hh],di,"isTouchDevice",1);var Wh=di,$r=class extends G{onclick(e,t){this._register(j(e,ke.CLICK,i=>t(new Ai(lt(e),i))))}onmousedown(e,t){this._register(j(e,ke.MOUSE_DOWN,i=>t(new Ai(lt(e),i))))}onmouseover(e,t){this._register(j(e,ke.MOUSE_OVER,i=>t(new Ai(lt(e),i))))}onmouseleave(e,t){this._register(j(e,ke.MOUSE_LEAVE,i=>t(new Ai(lt(e),i))))}onkeydown(e,t){this._register(j(e,ke.KEY_DOWN,i=>t(new sn(i))))}onkeyup(e,t){this._register(j(e,ke.KEY_UP,i=>t(new sn(i))))}oninput(e,t){this._register(j(e,ke.INPUT,t))}onblur(e,t){this._register(j(e,ke.BLUR,t))}onfocus(e,t){this._register(j(e,ke.FOCUS,t))}onchange(e,t){this._register(j(e,ke.CHANGE,t))}ignoreGesture(e){return Wh.ignoreTarget(e)}},hn=11,zh=class extends $r{constructor(e){super(),this._onActivate=e.onActivate,this.bgDomNode=document.createElement("div"),this.bgDomNode.className="arrow-background",this.bgDomNode.style.position="absolute",this.bgDomNode.style.width=e.bgWidth+"px",this.bgDomNode.style.height=e.bgHeight+"px",typeof e.top<"u"&&(this.bgDomNode.style.top="0px"),typeof e.left<"u"&&(this.bgDomNode.style.left="0px"),typeof e.bottom<"u"&&(this.bgDomNode.style.bottom="0px"),typeof e.right<"u"&&(this.bgDomNode.style.right="0px"),this.domNode=document.createElement("div"),this.domNode.className=e.className,this.domNode.style.position="absolute",this.domNode.style.width=hn+"px",this.domNode.style.height=hn+"px",typeof e.top<"u"&&(this.domNode.style.top=e.top+"px"),typeof e.left<"u"&&(this.domNode.style.left=e.left+"px"),typeof e.bottom<"u"&&(this.domNode.style.bottom=e.bottom+"px"),typeof e.right<"u"&&(this.domNode.style.right=e.right+"px"),this._pointerMoveMonitor=this._register(new oa),this._register(an(this.bgDomNode,ke.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._register(an(this.domNode,ke.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._pointerdownRepeatTimer=this._register(new Ih),this._pointerdownScheduleRepeatTimer=this._register(new Lr)}_arrowPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,lt(e))};this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(t,200),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,i=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),e.preventDefault()}},Uh=class Zs{constructor(t,i,s,r,n,o,a){this._forceIntegerValues=t,this._scrollStateBrand=void 0,this._forceIntegerValues&&(i=i|0,s=s|0,r=r|0,n=n|0,o=o|0,a=a|0),this.rawScrollLeft=r,this.rawScrollTop=a,i<0&&(i=0),r+i>s&&(r=s-i),r<0&&(r=0),n<0&&(n=0),a+n>o&&(a=o-n),a<0&&(a=0),this.width=i,this.scrollWidth=s,this.scrollLeft=r,this.height=n,this.scrollHeight=o,this.scrollTop=a}equals(t){return this.rawScrollLeft===t.rawScrollLeft&&this.rawScrollTop===t.rawScrollTop&&this.width===t.width&&this.scrollWidth===t.scrollWidth&&this.scrollLeft===t.scrollLeft&&this.height===t.height&&this.scrollHeight===t.scrollHeight&&this.scrollTop===t.scrollTop}withScrollDimensions(t,i){return new Zs(this._forceIntegerValues,typeof t.width<"u"?t.width:this.width,typeof t.scrollWidth<"u"?t.scrollWidth:this.scrollWidth,i?this.rawScrollLeft:this.scrollLeft,typeof t.height<"u"?t.height:this.height,typeof t.scrollHeight<"u"?t.scrollHeight:this.scrollHeight,i?this.rawScrollTop:this.scrollTop)}withScrollPosition(t){return new Zs(this._forceIntegerValues,this.width,this.scrollWidth,typeof t.scrollLeft<"u"?t.scrollLeft:this.rawScrollLeft,this.height,this.scrollHeight,typeof t.scrollTop<"u"?t.scrollTop:this.rawScrollTop)}createScrollEvent(t,i){let s=this.width!==t.width,r=this.scrollWidth!==t.scrollWidth,n=this.scrollLeft!==t.scrollLeft,o=this.height!==t.height,a=this.scrollHeight!==t.scrollHeight,h=this.scrollTop!==t.scrollTop;return{inSmoothScrolling:i,oldWidth:t.width,oldScrollWidth:t.scrollWidth,oldScrollLeft:t.scrollLeft,width:this.width,scrollWidth:this.scrollWidth,scrollLeft:this.scrollLeft,oldHeight:t.height,oldScrollHeight:t.scrollHeight,oldScrollTop:t.scrollTop,height:this.height,scrollHeight:this.scrollHeight,scrollTop:this.scrollTop,widthChanged:s,scrollWidthChanged:r,scrollLeftChanged:n,heightChanged:o,scrollHeightChanged:a,scrollTopChanged:h}}},jh=class extends G{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new k),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new Uh(e.forceIntegerValues,0,0,0,0,0,0),this._smoothScrolling=null}dispose(){this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),super.dispose()}setSmoothScrollDuration(e){this._smoothScrollDuration=e}validateScrollPosition(e){return this._state.withScrollPosition(e)}getScrollDimensions(){return this._state}setScrollDimensions(e,t){var s;let i=this._state.withScrollDimensions(e,t);this._setState(i,!!this._smoothScrolling),(s=this._smoothScrolling)==null||s.acceptScrollDimensions(this._state)}getFutureScrollPosition(){return this._smoothScrolling?this._smoothScrolling.to:this._state}getCurrentScrollPosition(){return this._state}setScrollPositionNow(e){let t=this._state.withScrollPosition(e);this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),this._setState(t,!1)}setScrollPositionSmooth(e,t){if(this._smoothScrollDuration===0)return this.setScrollPositionNow(e);if(this._smoothScrolling){e={scrollLeft:typeof e.scrollLeft>"u"?this._smoothScrolling.to.scrollLeft:e.scrollLeft,scrollTop:typeof e.scrollTop>"u"?this._smoothScrolling.to.scrollTop:e.scrollTop};let i=this._state.withScrollPosition(e);if(this._smoothScrolling.to.scrollLeft===i.scrollLeft&&this._smoothScrolling.to.scrollTop===i.scrollTop)return;let s;t?s=new dn(this._smoothScrolling.from,i,this._smoothScrolling.startTime,this._smoothScrolling.duration):s=this._smoothScrolling.combine(this._state,i,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=s}else{let i=this._state.withScrollPosition(e);this._smoothScrolling=dn.start(this._state,i,this._smoothScrollDuration)}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}hasPendingScrollAnimation(){return!!this._smoothScrolling}_performSmoothScrolling(){if(!this._smoothScrolling)return;let e=this._smoothScrolling.tick(),t=this._state.withScrollPosition(e);if(this._setState(t,!0),!!this._smoothScrolling){if(e.isDone){this._smoothScrolling.dispose(),this._smoothScrolling=null;return}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}}_setState(e,t){let i=this._state;i.equals(e)||(this._state=e,this._onScroll.fire(this._state.createScrollEvent(i,t)))}},cn=class{constructor(e,t,i){this.scrollLeft=e,this.scrollTop=t,this.isDone=i}};function vs(e,t){let i=t-e;return function(s){return e+i*Vh(s)}}function Kh(e,t,i){return function(s){return s2.5*s){let r,n;return t{var e;(e=this._domNode)==null||e.setClassName(this._visibleClassName)},0))}_hide(e){var t;this._revealTimer.cancel(),this._isVisible&&(this._isVisible=!1,(t=this._domNode)==null||t.setClassName(this._invisibleClassName+(e?" fade":"")))}},Yh=140,aa=class extends $r{constructor(e){super(),this._lazyRender=e.lazyRender,this._host=e.host,this._scrollable=e.scrollable,this._scrollByPage=e.scrollByPage,this._scrollbarState=e.scrollbarState,this._visibilityController=this._register(new Gh(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new oa),this._shouldRender=!0,this.domNode=vi(document.createElement("div")),this.domNode.setAttribute("role","presentation"),this.domNode.setAttribute("aria-hidden","true"),this._visibilityController.setDomNode(this.domNode),this.domNode.setPosition("absolute"),this._register(j(this.domNode.domNode,ke.POINTER_DOWN,t=>this._domNodePointerDown(t)))}_createArrow(e){let t=this._register(new zh(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,i,s){this.slider=vi(document.createElement("div")),this.slider.setClassName("slider"),this.slider.setPosition("absolute"),this.slider.setTop(e),this.slider.setLeft(t),typeof i=="number"&&this.slider.setWidth(i),typeof s=="number"&&this.slider.setHeight(s),this.slider.setLayerHinting(!0),this.slider.setContain("strict"),this.domNode.domNode.appendChild(this.slider.domNode),this._register(j(this.slider.domNode,ke.POINTER_DOWN,r=>{r.button===0&&(r.preventDefault(),this._sliderPointerDown(r))})),this.onclick(this.slider.domNode,r=>{r.leftButton&&r.stopPropagation()})}_onElementSize(e){return this._scrollbarState.setVisibleSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollSize(e){return this._scrollbarState.setScrollSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollPosition(e){return this._scrollbarState.setScrollPosition(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}beginReveal(){this._visibilityController.setShouldBeVisible(!0)}beginHide(){this._visibilityController.setShouldBeVisible(!1)}render(){this._shouldRender&&(this._shouldRender=!1,this._renderDomNode(this._scrollbarState.getRectangleLargeSize(),this._scrollbarState.getRectangleSmallSize()),this._updateSlider(this._scrollbarState.getSliderSize(),this._scrollbarState.getArrowSize()+this._scrollbarState.getSliderPosition()))}_domNodePointerDown(e){e.target===this.domNode.domNode&&this._onPointerDown(e)}delegatePointerDown(e){let t=this.domNode.domNode.getClientRects()[0].top,i=t+this._scrollbarState.getSliderPosition(),s=t+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),r=this._sliderPointerPosition(e);i<=r&&r<=s?e.button===0&&(e.preventDefault(),this._sliderPointerDown(e)):this._onPointerDown(e)}_onPointerDown(e){let t,i;if(e.target===this.domNode.domNode&&typeof e.offsetX=="number"&&typeof e.offsetY=="number")t=e.offsetX,i=e.offsetY;else{let r=Oh(this.domNode.domNode);t=e.pageX-r.left,i=e.pageY-r.top}let s=this._pointerDownRelativePosition(t,i);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(s):this._scrollbarState.getDesiredScrollPositionFromOffset(s)),e.button===0&&(e.preventDefault(),this._sliderPointerDown(e))}_sliderPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=this._sliderPointerPosition(e),i=this._sliderOrthogonalPointerPosition(e),s=this._scrollbarState.clone();this.slider.toggleClassName("active",!0),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,r=>{let n=this._sliderOrthogonalPointerPosition(r),o=Math.abs(n-i);if(ia&&o>Yh){this._setDesiredScrollPositionNow(s.getScrollPosition());return}let a=this._sliderPointerPosition(r)-t;this._setDesiredScrollPositionNow(s.getDesiredScrollPositionFromDelta(a))},()=>{this.slider.toggleClassName("active",!1),this._host.onDragEnd()}),this._host.onDragStart()}_setDesiredScrollPositionNow(e){let t={};this.writeScrollPosition(t,e),this._scrollable.setScrollPositionNow(t)}updateScrollbarSize(e){this._updateScrollbarSize(e),this._scrollbarState.setScrollbarSize(e),this._shouldRender=!0,this._lazyRender||this.render()}isNeeded(){return this._scrollbarState.isNeeded()}},la=class er{constructor(t,i,s,r,n,o){this._scrollbarSize=Math.round(i),this._oppositeScrollbarSize=Math.round(s),this._arrowSize=Math.round(t),this._visibleSize=r,this._scrollSize=n,this._scrollPosition=o,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new er(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(t){let i=Math.round(t);return this._visibleSize!==i?(this._visibleSize=i,this._refreshComputedValues(),!0):!1}setScrollSize(t){let i=Math.round(t);return this._scrollSize!==i?(this._scrollSize=i,this._refreshComputedValues(),!0):!1}setScrollPosition(t){let i=Math.round(t);return this._scrollPosition!==i?(this._scrollPosition=i,this._refreshComputedValues(),!0):!1}setScrollbarSize(t){this._scrollbarSize=Math.round(t)}setOppositeScrollbarSize(t){this._oppositeScrollbarSize=Math.round(t)}static _computeValues(t,i,s,r,n){let o=Math.max(0,s-t),a=Math.max(0,o-2*i),h=r>0&&r>s;if(!h)return{computedAvailableSize:Math.round(o),computedIsNeeded:h,computedSliderSize:Math.round(a),computedSliderRatio:0,computedSliderPosition:0};let l=Math.round(Math.max(20,Math.floor(s*a/r))),c=(a-l)/(r-s),d=n*c;return{computedAvailableSize:Math.round(o),computedIsNeeded:h,computedSliderSize:Math.round(l),computedSliderRatio:c,computedSliderPosition:Math.round(d)}}_refreshComputedValues(){let t=er._computeValues(this._oppositeScrollbarSize,this._arrowSize,this._visibleSize,this._scrollSize,this._scrollPosition);this._computedAvailableSize=t.computedAvailableSize,this._computedIsNeeded=t.computedIsNeeded,this._computedSliderSize=t.computedSliderSize,this._computedSliderRatio=t.computedSliderRatio,this._computedSliderPosition=t.computedSliderPosition}getArrowSize(){return this._arrowSize}getScrollPosition(){return this._scrollPosition}getRectangleLargeSize(){return this._computedAvailableSize}getRectangleSmallSize(){return this._scrollbarSize}isNeeded(){return this._computedIsNeeded}getSliderSize(){return this._computedSliderSize}getSliderPosition(){return this._computedSliderPosition}getDesiredScrollPositionFromOffset(t){if(!this._computedIsNeeded)return 0;let i=t-this._arrowSize-this._computedSliderSize/2;return Math.round(i/this._computedSliderRatio)}getDesiredScrollPositionFromOffsetPaged(t){if(!this._computedIsNeeded)return 0;let i=t-this._arrowSize,s=this._scrollPosition;return i0&&Math.abs(t.deltaY)>0)return 1;let s=.5;if((!this._isAlmostInt(t.deltaX)||!this._isAlmostInt(t.deltaY))&&(s+=.25),i){let r=Math.abs(t.deltaX),n=Math.abs(t.deltaY),o=Math.abs(i.deltaX),a=Math.abs(i.deltaY),h=Math.max(Math.min(r,o),1),l=Math.max(Math.min(n,a),1),c=Math.max(r,o),d=Math.max(n,a);c%h===0&&d%l===0&&(s-=.5)}return Math.min(Math.max(s,0),1)}_isAlmostInt(t){return Math.abs(Math.round(t)-t)<.01}};tr.INSTANCE=new tr;var ec=tr,tc=class extends $r{constructor(e,t,i){super(),this._onScroll=this._register(new k),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new k),this.onWillScroll=this._onWillScroll.event,this._options=sc(t),this._scrollable=i,this._register(this._scrollable.onScroll(r=>{this._onWillScroll.fire(r),this._onDidScroll(r),this._onScroll.fire(r)}));let s={onMouseWheel:r=>this._onMouseWheel(r),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new Jh(this._scrollable,this._options,s)),this._horizontalScrollbar=this._register(new Xh(this._scrollable,this._options,s)),this._domNode=document.createElement("div"),this._domNode.className="xterm-scrollable-element "+this._options.className,this._domNode.setAttribute("role","presentation"),this._domNode.style.position="relative",this._domNode.appendChild(e),this._domNode.appendChild(this._horizontalScrollbar.domNode.domNode),this._domNode.appendChild(this._verticalScrollbar.domNode.domNode),this._options.useShadows?(this._leftShadowDomNode=vi(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=vi(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=vi(document.createElement("div")),this._topLeftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topLeftShadowDomNode.domNode)):(this._leftShadowDomNode=null,this._topShadowDomNode=null,this._topLeftShadowDomNode=null),this._listenOnDomNode=this._options.listenOnDomNode||this._domNode,this._mouseWheelToDispose=[],this._setListeningToMouseWheel(this._options.handleMouseWheel),this.onmouseover(this._listenOnDomNode,r=>this._onMouseOver(r)),this.onmouseleave(this._listenOnDomNode,r=>this._onMouseLeave(r)),this._hideTimeout=this._register(new Lr),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=At(this._mouseWheelToDispose),super.dispose()}getDomNode(){return this._domNode}getOverviewRulerLayoutInfo(){return{parent:this._domNode,insertBefore:this._verticalScrollbar.domNode.domNode}}delegateVerticalScrollbarPointerDown(e){this._verticalScrollbar.delegatePointerDown(e)}getScrollDimensions(){return this._scrollable.getScrollDimensions()}setScrollDimensions(e){this._scrollable.setScrollDimensions(e,!1)}updateClassName(e){this._options.className=e,ht&&(this._options.className+=" mac"),this._domNode.className="xterm-scrollable-element "+this._options.className}updateOptions(e){typeof e.handleMouseWheel<"u"&&(this._options.handleMouseWheel=e.handleMouseWheel,this._setListeningToMouseWheel(this._options.handleMouseWheel)),typeof e.mouseWheelScrollSensitivity<"u"&&(this._options.mouseWheelScrollSensitivity=e.mouseWheelScrollSensitivity),typeof e.fastScrollSensitivity<"u"&&(this._options.fastScrollSensitivity=e.fastScrollSensitivity),typeof e.scrollPredominantAxis<"u"&&(this._options.scrollPredominantAxis=e.scrollPredominantAxis),typeof e.horizontal<"u"&&(this._options.horizontal=e.horizontal),typeof e.vertical<"u"&&(this._options.vertical=e.vertical),typeof e.horizontalScrollbarSize<"u"&&(this._options.horizontalScrollbarSize=e.horizontalScrollbarSize),typeof e.verticalScrollbarSize<"u"&&(this._options.verticalScrollbarSize=e.verticalScrollbarSize),typeof e.scrollByPage<"u"&&(this._options.scrollByPage=e.scrollByPage),this._horizontalScrollbar.updateOptions(this._options),this._verticalScrollbar.updateOptions(this._options),this._options.lazyRender||this._render()}setRevealOnScroll(e){this._revealOnScroll=e}delegateScrollFromMouseWheelEvent(e){this._onMouseWheel(new nn(e))}_setListeningToMouseWheel(e){if(this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=At(this._mouseWheelToDispose),e)){let t=i=>{this._onMouseWheel(new nn(i))};this._mouseWheelToDispose.push(j(this._listenOnDomNode,ke.MOUSE_WHEEL,t,{passive:!1}))}}_onMouseWheel(e){var r;if((r=e.browserEvent)!=null&&r.defaultPrevented)return;let t=ec.INSTANCE;t.acceptStandardWheelEvent(e);let i=!1;if(e.deltaY||e.deltaX){let n=e.deltaY*this._options.mouseWheelScrollSensitivity,o=e.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&o+n===0?o=n=0:Math.abs(n)>=Math.abs(o)?o=0:n=0),this._options.flipAxes&&([n,o]=[o,n]);let a=!ht&&e.browserEvent&&e.browserEvent.shiftKey;(this._options.scrollYToX||a)&&!o&&(o=n,n=0),e.browserEvent&&e.browserEvent.altKey&&(o=o*this._options.fastScrollSensitivity,n=n*this._options.fastScrollSensitivity);let h=this._scrollable.getFutureScrollPosition(),l={};if(n){let c=un*n,d=h.scrollTop-(c<0?Math.floor(c):Math.ceil(c));this._verticalScrollbar.writeScrollPosition(l,d)}if(o){let c=un*o,d=h.scrollLeft-(c<0?Math.floor(c):Math.ceil(c));this._horizontalScrollbar.writeScrollPosition(l,d)}l=this._scrollable.validateScrollPosition(l),(h.scrollLeft!==l.scrollLeft||h.scrollTop!==l.scrollTop)&&(this._options.mouseWheelSmoothScroll&&t.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(l):this._scrollable.setScrollPositionNow(l),i=!0)}let s=i;!s&&this._options.alwaysConsumeMouseWheel&&(s=!0),!s&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(s=!0),s&&(e.preventDefault(),e.stopPropagation())}_onDidScroll(e){this._shouldRender=this._horizontalScrollbar.onDidScroll(e)||this._shouldRender,this._shouldRender=this._verticalScrollbar.onDidScroll(e)||this._shouldRender,this._options.useShadows&&(this._shouldRender=!0),this._revealOnScroll&&this._reveal(),this._options.lazyRender||this._render()}renderNow(){if(!this._options.lazyRender)throw new Error("Please use `lazyRender` together with `renderNow`!");this._render()}_render(){if(this._shouldRender&&(this._shouldRender=!1,this._horizontalScrollbar.render(),this._verticalScrollbar.render(),this._options.useShadows)){let e=this._scrollable.getCurrentScrollPosition(),t=e.scrollTop>0,i=e.scrollLeft>0,s=i?" left":"",r=t?" top":"",n=i||t?" top-left-corner":"";this._leftShadowDomNode.setClassName(`shadow${s}`),this._topShadowDomNode.setClassName(`shadow${r}`),this._topLeftShadowDomNode.setClassName(`shadow${n}${r}${s}`)}}_onDragStart(){this._isDragging=!0,this._reveal()}_onDragEnd(){this._isDragging=!1,this._hide()}_onMouseLeave(e){this._mouseIsOver=!1,this._hide()}_onMouseOver(e){this._mouseIsOver=!0,this._reveal()}_reveal(){this._verticalScrollbar.beginReveal(),this._horizontalScrollbar.beginReveal(),this._scheduleHide()}_hide(){!this._mouseIsOver&&!this._isDragging&&(this._verticalScrollbar.beginHide(),this._horizontalScrollbar.beginHide())}_scheduleHide(){!this._mouseIsOver&&!this._isDragging&&this._hideTimeout.cancelAndSet(()=>this._hide(),Zh)}},ic=class extends tc{constructor(e,t,i){super(e,t,i)}setScrollPosition(e){e.reuseAnimation?this._scrollable.setScrollPositionSmooth(e,e.reuseAnimation):this._scrollable.setScrollPositionNow(e)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}};function sc(e){let t={lazyRender:typeof e.lazyRender<"u"?e.lazyRender:!1,className:typeof e.className<"u"?e.className:"",useShadows:typeof e.useShadows<"u"?e.useShadows:!0,handleMouseWheel:typeof e.handleMouseWheel<"u"?e.handleMouseWheel:!0,flipAxes:typeof e.flipAxes<"u"?e.flipAxes:!1,consumeMouseWheelIfScrollbarIsNeeded:typeof e.consumeMouseWheelIfScrollbarIsNeeded<"u"?e.consumeMouseWheelIfScrollbarIsNeeded:!1,alwaysConsumeMouseWheel:typeof e.alwaysConsumeMouseWheel<"u"?e.alwaysConsumeMouseWheel:!1,scrollYToX:typeof e.scrollYToX<"u"?e.scrollYToX:!1,mouseWheelScrollSensitivity:typeof e.mouseWheelScrollSensitivity<"u"?e.mouseWheelScrollSensitivity:1,fastScrollSensitivity:typeof e.fastScrollSensitivity<"u"?e.fastScrollSensitivity:5,scrollPredominantAxis:typeof e.scrollPredominantAxis<"u"?e.scrollPredominantAxis:!0,mouseWheelSmoothScroll:typeof e.mouseWheelSmoothScroll<"u"?e.mouseWheelSmoothScroll:!0,arrowSize:typeof e.arrowSize<"u"?e.arrowSize:11,listenOnDomNode:typeof e.listenOnDomNode<"u"?e.listenOnDomNode:null,horizontal:typeof e.horizontal<"u"?e.horizontal:1,horizontalScrollbarSize:typeof e.horizontalScrollbarSize<"u"?e.horizontalScrollbarSize:10,horizontalSliderSize:typeof e.horizontalSliderSize<"u"?e.horizontalSliderSize:0,horizontalHasArrows:typeof e.horizontalHasArrows<"u"?e.horizontalHasArrows:!1,vertical:typeof e.vertical<"u"?e.vertical:1,verticalScrollbarSize:typeof e.verticalScrollbarSize<"u"?e.verticalScrollbarSize:10,verticalHasArrows:typeof e.verticalHasArrows<"u"?e.verticalHasArrows:!1,verticalSliderSize:typeof e.verticalSliderSize<"u"?e.verticalSliderSize:0,scrollByPage:typeof e.scrollByPage<"u"?e.scrollByPage:!1};return t.horizontalSliderSize=typeof e.horizontalSliderSize<"u"?e.horizontalSliderSize:t.horizontalScrollbarSize,t.verticalSliderSize=typeof e.verticalSliderSize<"u"?e.verticalSliderSize:t.verticalScrollbarSize,ht&&(t.className+=" mac"),t}var ir=class extends G{constructor(e,t,i,s,r,n,o,a){super(),this._bufferService=i,this._optionsService=o,this._renderService=a,this._onRequestScrollLines=this._register(new k),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let h=this._register(new jh({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:l=>Tr(s.window,l)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{h.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new ic(t,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},h)),this._register(this._optionsService.onMultipleOptionChange(["scrollSensitivity","fastScrollSensitivity","overviewRuler"],()=>this._scrollableElement.updateOptions(this._getChangeOptions()))),this._register(r.onProtocolChange(l=>{this._scrollableElement.updateOptions({handleMouseWheel:!(l&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(Le.runAndSubscribe(n.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=n.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(oe(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=s.mainDocument.createElement("style"),t.appendChild(this._styleElement),this._register(oe(()=>this._styleElement.remove())),this._register(Le.runAndSubscribe(n.onChangeColors,()=>{this._styleElement.textContent=[".xterm .xterm-scrollable-element > .scrollbar > .slider {",` background: ${n.colors.scrollbarSliderBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider:hover {",` background: ${n.colors.scrollbarSliderHoverBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider.active {",` background: ${n.colors.scrollbarSliderActiveBackground.css};`,"}"].join(` +`))}},sh=class extends Error{constructor(e,t){super(e),this.name="ListenerLeakError",this.stack=t}},rh=class extends Error{constructor(e,t){super(e),this.name="ListenerRefusalError",this.stack=t}},nh=0,ps=class{constructor(e){this.value=e,this.id=nh++}},oh=2,ah,k=class{constructor(t){var i,s,r,n;this._size=0,this._options=t,this._leakageMon=(i=this._options)!=null&&i.leakWarningThreshold?new th((t==null?void 0:t.onListenerError)??Wi,((s=this._options)==null?void 0:s.leakWarningThreshold)??eh):void 0,this._perfMon=(r=this._options)!=null&&r._profName?new Ql(this._options._profName):void 0,this._deliveryQueue=(n=this._options)==null?void 0:n.deliveryQueue}dispose(){var t,i,s,r;this._disposed||(this._disposed=!0,((t=this._deliveryQueue)==null?void 0:t.current)===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),(s=(i=this._options)==null?void 0:i.onDidRemoveLastListener)==null||s.call(i),(r=this._leakageMon)==null||r.dispose())}get event(){return this._event??(this._event=(t,i,s)=>{var a,h,l,c,d;if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let u=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(u);let f=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],_=new rh(`${u}. HINT: Stack shows most frequent listener (${f[1]}-times)`,f[0]);return(((a=this._options)==null?void 0:a.onListenerError)||Wi)(_),G.None}if(this._disposed)return G.None;i&&(t=t.bind(i));let r=new ps(t),n;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(r.stack=ih.create(),n=this._leakageMon.check(r.stack,this._size+1)),this._listeners?this._listeners instanceof ps?(this._deliveryQueue??(this._deliveryQueue=new lh),this._listeners=[this._listeners,r]):this._listeners.push(r):((l=(h=this._options)==null?void 0:h.onWillAddFirstListener)==null||l.call(h,this),this._listeners=r,(d=(c=this._options)==null?void 0:c.onDidAddFirstListener)==null||d.call(c,this)),this._size++;let o=oe(()=>{n==null||n(),this._removeListener(r)});return s instanceof xt?s.add(o):Array.isArray(s)&&s.push(o),o}),this._event}_removeListener(t){var n,o,a,h;if((o=(n=this._options)==null?void 0:n.onWillRemoveListener)==null||o.call(n,this),!this._listeners)return;if(this._size===1){this._listeners=void 0,(h=(a=this._options)==null?void 0:a.onDidRemoveLastListener)==null||h.call(a,this),this._size=0;return}let i=this._listeners,s=i.indexOf(t);if(s===-1)throw console.log("disposed?",this._disposed),console.log("size?",this._size),console.log("arr?",JSON.stringify(this._listeners)),new Error("Attempted to dispose unknown listener");this._size--,i[s]=void 0;let r=this._deliveryQueue.current===this;if(this._size*oh<=i.length){let l=0;for(let c=0;c0}},lh=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,i){this.i=0,this.end=i,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},Gs=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new k,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new k,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(t){return this.mapWindowIdToZoomLevel.get(this.getWindowId(t))??0}setZoomLevel(t,i){if(this.getZoomLevel(i)===t)return;let s=this.getWindowId(i);this.mapWindowIdToZoomLevel.set(s,t),this._onDidChangeZoomLevel.fire(s)}getZoomFactor(t){return this.mapWindowIdToZoomFactor.get(this.getWindowId(t))??1}setZoomFactor(t,i){this.mapWindowIdToZoomFactor.set(this.getWindowId(i),t)}setFullscreen(t,i){if(this.isFullscreen(i)===t)return;let s=this.getWindowId(i);this.mapWindowIdToFullScreen.set(s,t),this._onDidChangeFullscreen.fire(s)}isFullscreen(t){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(t))}getWindowId(t){return t.vscodeWindowId}};Gs.INSTANCE=new Gs;var Br=Gs;function hh(e,t,i){typeof t=="string"&&(t=e.matchMedia(t)),t.addEventListener("change",i)}Br.INSTANCE.onDidChangeZoomLevel;function ch(e){return Br.INSTANCE.getZoomFactor(e)}Br.INSTANCE.onDidChangeFullscreen;var Zt=typeof navigator=="object"?navigator.userAgent:"",Ys=Zt.indexOf("Firefox")>=0,dh=Zt.indexOf("AppleWebKit")>=0,Mr=Zt.indexOf("Chrome")>=0,uh=!Mr&&Zt.indexOf("Safari")>=0;Zt.indexOf("Electron/")>=0;Zt.indexOf("Android")>=0;var ms=!1;if(typeof _t.matchMedia=="function"){let e=_t.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),t=_t.matchMedia("(display-mode: fullscreen)");ms=e.matches,hh(_t,e,({matches:i})=>{ms&&t.matches||(ms=i)})}var Kt="en",Xs=!1,Js=!1,zi=!1,ta=!1,$i,Ui=Kt,Zr=Kt,_h,tt,$t=globalThis,De,So;typeof $t.vscode<"u"&&typeof $t.vscode.process<"u"?De=$t.vscode.process:typeof process<"u"&&typeof((So=process==null?void 0:process.versions)==null?void 0:So.node)=="string"&&(De=process);var yo,fh=typeof((yo=De==null?void 0:De.versions)==null?void 0:yo.electron)=="string",ph=fh&&(De==null?void 0:De.type)==="renderer",wo;if(typeof De=="object"){Xs=De.platform==="win32",Js=De.platform==="darwin",zi=De.platform==="linux",zi&&De.env.SNAP&&De.env.SNAP_REVISION,De.env.CI||De.env.BUILD_ARTIFACTSTAGINGDIRECTORY,$i=Kt,Ui=Kt;let e=De.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);$i=t.userLocale,Zr=t.osLocale,Ui=t.resolvedLanguage||Kt,_h=(wo=t.languagePack)==null?void 0:wo.translationsConfigFile}catch{}ta=!0}else typeof navigator=="object"&&!ph?(tt=navigator.userAgent,Xs=tt.indexOf("Windows")>=0,Js=tt.indexOf("Macintosh")>=0,(tt.indexOf("Macintosh")>=0||tt.indexOf("iPad")>=0||tt.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,zi=tt.indexOf("Linux")>=0,(tt==null?void 0:tt.indexOf("Mobi"))>=0,Ui=globalThis._VSCODE_NLS_LANGUAGE||Kt,$i=navigator.language.toLowerCase(),Zr=$i):console.error("Unable to resolve platform.");var ia=Xs,ht=Js,mh=zi,Qr=ta,ct=tt,mt=Ui,gh;(e=>{function t(){return mt}e.value=t;function i(){return mt.length===2?mt==="en":mt.length>=3?mt[0]==="e"&&mt[1]==="n"&&mt[2]==="-":!1}e.isDefaultVariant=i;function s(){return mt==="en"}e.isDefault=s})(gh||(gh={}));var vh=typeof $t.postMessage=="function"&&!$t.importScripts;(()=>{if(vh){let e=[];$t.addEventListener("message",i=>{if(i.data&&i.data.vscodeScheduleAsyncWork)for(let s=0,r=e.length;s{let s=++t;e.push({id:s,callback:i}),$t.postMessage({vscodeScheduleAsyncWork:s},"*")}}return e=>setTimeout(e)})();var Sh=!!(ct&&ct.indexOf("Chrome")>=0);ct&&ct.indexOf("Firefox")>=0;!Sh&&ct&&ct.indexOf("Safari")>=0;ct&&ct.indexOf("Edg/")>=0;ct&&ct.indexOf("Android")>=0;var Ft=typeof navigator=="object"?navigator:{};Qr||document.queryCommandSupported&&document.queryCommandSupported("copy")||Ft&&Ft.clipboard&&Ft.clipboard.writeText,Qr||Ft&&Ft.clipboard&&Ft.clipboard.readText;var Dr=class{constructor(){this._keyCodeToStr=[],this._strToKeyCode=Object.create(null)}define(e,t){this._keyCodeToStr[e]=t,this._strToKeyCode[t.toLowerCase()]=e}keyCodeToStr(e){return this._keyCodeToStr[e]}strToKeyCode(e){return this._strToKeyCode[e.toLowerCase()]||0}},gs=new Dr,en=new Dr,tn=new Dr,yh=new Array(230),sa;(e=>{function t(a){return gs.keyCodeToStr(a)}e.toString=t;function i(a){return gs.strToKeyCode(a)}e.fromString=i;function s(a){return en.keyCodeToStr(a)}e.toUserSettingsUS=s;function r(a){return tn.keyCodeToStr(a)}e.toUserSettingsGeneral=r;function n(a){return en.strToKeyCode(a)||tn.strToKeyCode(a)}e.fromUserSettings=n;function o(a){if(a>=98&&a<=113)return null;switch(a){case 16:return"Up";case 18:return"Down";case 15:return"Left";case 17:return"Right"}return gs.keyCodeToStr(a)}e.toElectronAccelerator=o})(sa||(sa={}));var wh=class ra{constructor(t,i,s,r,n){this.ctrlKey=t,this.shiftKey=i,this.altKey=s,this.metaKey=r,this.keyCode=n}equals(t){return t instanceof ra&&this.ctrlKey===t.ctrlKey&&this.shiftKey===t.shiftKey&&this.altKey===t.altKey&&this.metaKey===t.metaKey&&this.keyCode===t.keyCode}getHashCode(){let t=this.ctrlKey?"1":"0",i=this.shiftKey?"1":"0",s=this.altKey?"1":"0",r=this.metaKey?"1":"0";return`K${t}${i}${s}${r}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new bh([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},bh=class{constructor(e){if(e.length===0)throw Vl("chords");this.chords=e}getHashCode(){let e="";for(let t=0,i=this.chords.length;t{function t(i){return i===e.None||i===e.Cancelled||i instanceof Lh?!0:!i||typeof i!="object"?!1:typeof i.isCancellationRequested=="boolean"&&typeof i.onCancellationRequested=="function"}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:Le.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:na})})(Dh||(Dh={}));var Lh=class{constructor(){this._isCancelled=!1,this._emitter=null}cancel(){this._isCancelled||(this._isCancelled=!0,this._emitter&&(this._emitter.fire(void 0),this.dispose()))}get isCancellationRequested(){return this._isCancelled}get onCancellationRequested(){return this._isCancelled?na:(this._emitter||(this._emitter=new k),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},Lr=class{constructor(e,t){this._isDisposed=!1,this._token=-1,typeof e=="function"&&typeof t=="number"&&this.setIfNotSet(e,t)}dispose(){this.cancel(),this._isDisposed=!0}cancel(){this._token!==-1&&(clearTimeout(this._token),this._token=-1)}cancelAndSet(e,t){if(this._isDisposed)throw new Us("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new Us("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},Th=class{constructor(){this.disposable=void 0,this.isDisposed=!1}cancel(){var e;(e=this.disposable)==null||e.dispose(),this.disposable=void 0}cancelAndSet(e,t,i=globalThis){if(this.isDisposed)throw new Us("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let s=i.setInterval(()=>{e()},t);this.disposable=oe(()=>{i.clearInterval(s),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},$h;(e=>{async function t(s){let r,n=await Promise.all(s.map(o=>o.then(a=>a,a=>{r||(r=a)})));if(typeof r<"u")throw r;return n}e.settled=t;function i(s){return new Promise(async(r,n)=>{try{await s(r,n)}catch(o){n(o)}})}e.withAsyncBody=i})($h||($h={}));var on=class Ye{static fromArray(t){return new Ye(i=>{i.emitMany(t)})}static fromPromise(t){return new Ye(async i=>{i.emitMany(await t)})}static fromPromises(t){return new Ye(async i=>{await Promise.all(t.map(async s=>i.emitOne(await s)))})}static merge(t){return new Ye(async i=>{await Promise.all(t.map(async s=>{for await(let r of s)i.emitOne(r)}))})}constructor(t,i){this._state=0,this._results=[],this._error=null,this._onReturn=i,this._onStateChanged=new k,queueMicrotask(async()=>{let s={emitOne:r=>this.emitOne(r),emitMany:r=>this.emitMany(r),reject:r=>this.reject(r)};try{await Promise.resolve(t(s)),this.resolve()}catch(r){this.reject(r)}finally{s.emitOne=void 0,s.emitMany=void 0,s.reject=void 0}})}[Symbol.asyncIterator](){let t=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(t{var i;return(i=this._onReturn)==null||i.call(this),{done:!0,value:void 0}}}}static map(t,i){return new Ye(async s=>{for await(let r of t)s.emitOne(i(r))})}map(t){return Ye.map(this,t)}static filter(t,i){return new Ye(async s=>{for await(let r of t)i(r)&&s.emitOne(r)})}filter(t){return Ye.filter(this,t)}static coalesce(t){return Ye.filter(t,i=>!!i)}coalesce(){return Ye.coalesce(this)}static async toPromise(t){let i=[];for await(let s of t)i.push(s);return i}toPromise(){return Ye.toPromise(this)}emitOne(t){this._state===0&&(this._results.push(t),this._onStateChanged.fire())}emitMany(t){this._state===0&&(this._results=this._results.concat(t),this._onStateChanged.fire())}resolve(){this._state===0&&(this._state=1,this._onStateChanged.fire())}reject(t){this._state===0&&(this._state=2,this._error=t,this._onStateChanged.fire())}};on.EMPTY=on.fromArray([]);var{getWindow:lt,getWindowId:Ah,onDidRegisterWindow:Ph}=(function(){let e=new Map,t={window:_t,disposables:new xt};e.set(_t.vscodeWindowId,t);let i=new k,s=new k,r=new k;function n(o,a){return(typeof o=="number"?e.get(o):void 0)??(a?t:void 0)}return{onDidRegisterWindow:i.event,onWillUnregisterWindow:r.event,onDidUnregisterWindow:s.event,registerWindow(o){if(e.has(o.vscodeWindowId))return G.None;let a=new xt,h={window:o,disposables:a.add(new xt)};return e.set(o.vscodeWindowId,h),a.add(oe(()=>{e.delete(o.vscodeWindowId),s.fire(o)})),a.add(j(o,ke.BEFORE_UNLOAD,()=>{r.fire(o)})),i.fire(h),a},getWindows(){return e.values()},getWindowsCount(){return e.size},getWindowId(o){return o.vscodeWindowId},hasWindow(o){return e.has(o)},getWindowById:n,getWindow(o){var l;let a=o;if((l=a==null?void 0:a.ownerDocument)!=null&&l.defaultView)return a.ownerDocument.defaultView.window;let h=o;return h!=null&&h.view?h.view.window:_t},getDocument(o){return lt(o).document}}})(),Nh=class{constructor(e,t,i,s){this._node=e,this._type=t,this._handler=i,this._options=s||!1,this._node.addEventListener(this._type,this._handler,this._options)}dispose(){this._handler&&(this._node.removeEventListener(this._type,this._handler,this._options),this._node=null,this._handler=null)}};function j(e,t,i,s){return new Nh(e,t,i,s)}var an=function(e,t,i,s){return j(e,t,i,s)},Tr,Ih=class extends Th{constructor(e){super(),this.defaultTarget=e&<(e)}cancelAndSet(e,t,i){return super.cancelAndSet(e,t,i??this.defaultTarget)}},ln=class{constructor(e,t=0){this._runner=e,this.priority=t,this._canceled=!1}dispose(){this._canceled=!0}execute(){if(!this._canceled)try{this._runner()}catch(e){Wi(e)}}static sort(e,t){return t.priority-e.priority}};(function(){let e=new Map,t=new Map,i=new Map,s=new Map,r=n=>{i.set(n,!1);let o=e.get(n)??[];for(t.set(n,o),e.set(n,[]),s.set(n,!0);o.length>0;)o.sort(ln.sort),o.shift().execute();s.set(n,!1)};Tr=(n,o,a=0)=>{let h=Ah(n),l=new ln(o,a),c=e.get(h);return c||(c=[],e.set(h,c)),c.push(l),i.get(h)||(i.set(h,!0),n.requestAnimationFrame(()=>r(h))),l}})();function Oh(e){let t=e.getBoundingClientRect(),i=lt(e);return{left:t.left+i.scrollX,top:t.top+i.scrollY,width:t.width,height:t.height}}var ke={CLICK:"click",MOUSE_DOWN:"mousedown",MOUSE_OVER:"mouseover",MOUSE_LEAVE:"mouseleave",MOUSE_WHEEL:"wheel",POINTER_UP:"pointerup",POINTER_DOWN:"pointerdown",POINTER_MOVE:"pointermove",KEY_DOWN:"keydown",KEY_UP:"keyup",BEFORE_UNLOAD:"beforeunload",CHANGE:"change",FOCUS:"focus",BLUR:"blur",INPUT:"input"},Hh=class{constructor(e){this.domNode=e,this._maxWidth="",this._width="",this._height="",this._top="",this._left="",this._bottom="",this._right="",this._paddingTop="",this._paddingLeft="",this._paddingBottom="",this._paddingRight="",this._fontFamily="",this._fontWeight="",this._fontSize="",this._fontStyle="",this._fontFeatureSettings="",this._fontVariationSettings="",this._textDecoration="",this._lineHeight="",this._letterSpacing="",this._className="",this._display="",this._position="",this._visibility="",this._color="",this._backgroundColor="",this._layerHint=!1,this._contain="none",this._boxShadow=""}setMaxWidth(e){let t=ze(e);this._maxWidth!==t&&(this._maxWidth=t,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let t=ze(e);this._width!==t&&(this._width=t,this.domNode.style.width=this._width)}setHeight(e){let t=ze(e);this._height!==t&&(this._height=t,this.domNode.style.height=this._height)}setTop(e){let t=ze(e);this._top!==t&&(this._top=t,this.domNode.style.top=this._top)}setLeft(e){let t=ze(e);this._left!==t&&(this._left=t,this.domNode.style.left=this._left)}setBottom(e){let t=ze(e);this._bottom!==t&&(this._bottom=t,this.domNode.style.bottom=this._bottom)}setRight(e){let t=ze(e);this._right!==t&&(this._right=t,this.domNode.style.right=this._right)}setPaddingTop(e){let t=ze(e);this._paddingTop!==t&&(this._paddingTop=t,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let t=ze(e);this._paddingLeft!==t&&(this._paddingLeft=t,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let t=ze(e);this._paddingBottom!==t&&(this._paddingBottom=t,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let t=ze(e);this._paddingRight!==t&&(this._paddingRight=t,this.domNode.style.paddingRight=this._paddingRight)}setFontFamily(e){this._fontFamily!==e&&(this._fontFamily=e,this.domNode.style.fontFamily=this._fontFamily)}setFontWeight(e){this._fontWeight!==e&&(this._fontWeight=e,this.domNode.style.fontWeight=this._fontWeight)}setFontSize(e){let t=ze(e);this._fontSize!==t&&(this._fontSize=t,this.domNode.style.fontSize=this._fontSize)}setFontStyle(e){this._fontStyle!==e&&(this._fontStyle=e,this.domNode.style.fontStyle=this._fontStyle)}setFontFeatureSettings(e){this._fontFeatureSettings!==e&&(this._fontFeatureSettings=e,this.domNode.style.fontFeatureSettings=this._fontFeatureSettings)}setFontVariationSettings(e){this._fontVariationSettings!==e&&(this._fontVariationSettings=e,this.domNode.style.fontVariationSettings=this._fontVariationSettings)}setTextDecoration(e){this._textDecoration!==e&&(this._textDecoration=e,this.domNode.style.textDecoration=this._textDecoration)}setLineHeight(e){let t=ze(e);this._lineHeight!==t&&(this._lineHeight=t,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let t=ze(e);this._letterSpacing!==t&&(this._letterSpacing=t,this.domNode.style.letterSpacing=this._letterSpacing)}setClassName(e){this._className!==e&&(this._className=e,this.domNode.className=this._className)}toggleClassName(e,t){this.domNode.classList.toggle(e,t),this._className=this.domNode.className}setDisplay(e){this._display!==e&&(this._display=e,this.domNode.style.display=this._display)}setPosition(e){this._position!==e&&(this._position=e,this.domNode.style.position=this._position)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this.domNode.style.visibility=this._visibility)}setColor(e){this._color!==e&&(this._color=e,this.domNode.style.color=this._color)}setBackgroundColor(e){this._backgroundColor!==e&&(this._backgroundColor=e,this.domNode.style.backgroundColor=this._backgroundColor)}setLayerHinting(e){this._layerHint!==e&&(this._layerHint=e,this.domNode.style.transform=this._layerHint?"translate3d(0px, 0px, 0px)":"")}setBoxShadow(e){this._boxShadow!==e&&(this._boxShadow=e,this.domNode.style.boxShadow=e)}setContain(e){this._contain!==e&&(this._contain=e,this.domNode.style.contain=this._contain)}setAttribute(e,t){this.domNode.setAttribute(e,t)}removeAttribute(e){this.domNode.removeAttribute(e)}appendChild(e){this.domNode.appendChild(e.domNode)}removeChild(e){this.domNode.removeChild(e.domNode)}};function ze(e){return typeof e=="number"?`${e}px`:e}function vi(e){return new Hh(e)}var oa=class{constructor(){this._hooks=new xt,this._pointerMoveCallback=null,this._onStopCallback=null}dispose(){this.stopMonitoring(!1),this._hooks.dispose()}stopMonitoring(e,t){if(!this.isMonitoring())return;this._hooks.clear(),this._pointerMoveCallback=null;let i=this._onStopCallback;this._onStopCallback=null,e&&i&&i(t)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(e,t,i,s,r){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=s,this._onStopCallback=r;let n=e;try{e.setPointerCapture(t),this._hooks.add(oe(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{n=lt(e)}this._hooks.add(j(n,ke.POINTER_MOVE,o=>{if(o.buttons!==i){this.stopMonitoring(!0);return}o.preventDefault(),this._pointerMoveCallback(o)})),this._hooks.add(j(n,ke.POINTER_UP,o=>this.stopMonitoring(!0)))}};function Fh(e,t,i){let s=null,r=null;if(typeof i.value=="function"?(s="value",r=i.value,r.length!==0&&console.warn("Memoize should only be used in functions with zero parameters")):typeof i.get=="function"&&(s="get",r=i.get),!r)throw new Error("not supported");let n=`$memoize$${t}`;i[s]=function(...o){return this.hasOwnProperty(n)||Object.defineProperty(this,n,{configurable:!1,enumerable:!1,writable:!1,value:r.apply(this,o)}),this[n]}}var at;(e=>(e.Tap="-xterm-gesturetap",e.Change="-xterm-gesturechange",e.Start="-xterm-gesturestart",e.End="-xterm-gesturesend",e.Contextmenu="-xterm-gesturecontextmenu"))(at||(at={}));var di=class $e extends G{constructor(){super(),this.dispatched=!1,this.targets=new Jr,this.ignoreTargets=new Jr,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(Le.runAndSubscribe(Ph,({window:t,disposables:i})=>{i.add(j(t.document,"touchstart",s=>this.onTouchStart(s),{passive:!1})),i.add(j(t.document,"touchend",s=>this.onTouchEnd(t,s))),i.add(j(t.document,"touchmove",s=>this.onTouchMove(s),{passive:!1}))},{window:_t,disposables:this._store}))}static addTarget(t){if(!$e.isTouchDevice())return G.None;$e.INSTANCE||($e.INSTANCE=new $e);let i=$e.INSTANCE.targets.push(t);return oe(i)}static ignoreTarget(t){if(!$e.isTouchDevice())return G.None;$e.INSTANCE||($e.INSTANCE=new $e);let i=$e.INSTANCE.ignoreTargets.push(t);return oe(i)}static isTouchDevice(){return"ontouchstart"in _t||navigator.maxTouchPoints>0}dispose(){this.handle&&(this.handle.dispose(),this.handle=null),super.dispose()}onTouchStart(t){let i=Date.now();this.handle&&(this.handle.dispose(),this.handle=null);for(let s=0,r=t.targetTouches.length;s=$e.HOLD_DELAY&&Math.abs(h.initialPageX-je(h.rollingPageX))<30&&Math.abs(h.initialPageY-je(h.rollingPageY))<30){let c=this.newGestureEvent(at.Contextmenu,h.initialTarget);c.pageX=je(h.rollingPageX),c.pageY=je(h.rollingPageY),this.dispatchEvent(c)}else if(r===1){let c=je(h.rollingPageX),d=je(h.rollingPageY),u=je(h.rollingTimestamps)-h.rollingTimestamps[0],f=c-h.rollingPageX[0],_=d-h.rollingPageY[0],p=[...this.targets].filter(g=>h.initialTarget instanceof Node&&g.contains(h.initialTarget));this.inertia(t,p,s,Math.abs(f)/u,f>0?1:-1,c,Math.abs(_)/u,_>0?1:-1,d)}this.dispatchEvent(this.newGestureEvent(at.End,h.initialTarget)),delete this.activeTouches[a.identifier]}this.dispatched&&(i.preventDefault(),i.stopPropagation(),this.dispatched=!1)}newGestureEvent(t,i){let s=document.createEvent("CustomEvent");return s.initEvent(t,!1,!0),s.initialTarget=i,s.tapCount=0,s}dispatchEvent(t){if(t.type===at.Tap){let i=new Date().getTime(),s=0;i-this._lastSetTapCountTime>$e.CLEAR_TAP_COUNT_TIME?s=1:s=2,this._lastSetTapCountTime=i,t.tapCount=s}else(t.type===at.Change||t.type===at.Contextmenu)&&(this._lastSetTapCountTime=0);if(t.initialTarget instanceof Node){for(let s of this.ignoreTargets)if(s.contains(t.initialTarget))return;let i=[];for(let s of this.targets)if(s.contains(t.initialTarget)){let r=0,n=t.initialTarget;for(;n&&n!==s;)r++,n=n.parentElement;i.push([r,s])}i.sort((s,r)=>s[0]-r[0]);for(let[s,r]of i)r.dispatchEvent(t),this.dispatched=!0}}inertia(t,i,s,r,n,o,a,h,l){this.handle=Tr(t,()=>{let c=Date.now(),d=c-s,u=0,f=0,_=!0;r+=$e.SCROLL_FRICTION*d,a+=$e.SCROLL_FRICTION*d,r>0&&(_=!1,u=n*r*d),a>0&&(_=!1,f=h*a*d);let p=this.newGestureEvent(at.Change);p.translationX=u,p.translationY=f,i.forEach(g=>g.dispatchEvent(p)),_||this.inertia(t,i,c,r,n,o+u,a,h,l+f)})}onTouchMove(t){let i=Date.now();for(let s=0,r=t.changedTouches.length;s3&&(o.rollingPageX.shift(),o.rollingPageY.shift(),o.rollingTimestamps.shift()),o.rollingPageX.push(n.pageX),o.rollingPageY.push(n.pageY),o.rollingTimestamps.push(i)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}};di.SCROLL_FRICTION=-.005,di.HOLD_DELAY=700,di.CLEAR_TAP_COUNT_TIME=400,_e([Fh],di,"isTouchDevice",1);var Wh=di,$r=class extends G{onclick(e,t){this._register(j(e,ke.CLICK,i=>t(new Ai(lt(e),i))))}onmousedown(e,t){this._register(j(e,ke.MOUSE_DOWN,i=>t(new Ai(lt(e),i))))}onmouseover(e,t){this._register(j(e,ke.MOUSE_OVER,i=>t(new Ai(lt(e),i))))}onmouseleave(e,t){this._register(j(e,ke.MOUSE_LEAVE,i=>t(new Ai(lt(e),i))))}onkeydown(e,t){this._register(j(e,ke.KEY_DOWN,i=>t(new sn(i))))}onkeyup(e,t){this._register(j(e,ke.KEY_UP,i=>t(new sn(i))))}oninput(e,t){this._register(j(e,ke.INPUT,t))}onblur(e,t){this._register(j(e,ke.BLUR,t))}onfocus(e,t){this._register(j(e,ke.FOCUS,t))}onchange(e,t){this._register(j(e,ke.CHANGE,t))}ignoreGesture(e){return Wh.ignoreTarget(e)}},hn=11,zh=class extends $r{constructor(e){super(),this._onActivate=e.onActivate,this.bgDomNode=document.createElement("div"),this.bgDomNode.className="arrow-background",this.bgDomNode.style.position="absolute",this.bgDomNode.style.width=e.bgWidth+"px",this.bgDomNode.style.height=e.bgHeight+"px",typeof e.top<"u"&&(this.bgDomNode.style.top="0px"),typeof e.left<"u"&&(this.bgDomNode.style.left="0px"),typeof e.bottom<"u"&&(this.bgDomNode.style.bottom="0px"),typeof e.right<"u"&&(this.bgDomNode.style.right="0px"),this.domNode=document.createElement("div"),this.domNode.className=e.className,this.domNode.style.position="absolute",this.domNode.style.width=hn+"px",this.domNode.style.height=hn+"px",typeof e.top<"u"&&(this.domNode.style.top=e.top+"px"),typeof e.left<"u"&&(this.domNode.style.left=e.left+"px"),typeof e.bottom<"u"&&(this.domNode.style.bottom=e.bottom+"px"),typeof e.right<"u"&&(this.domNode.style.right=e.right+"px"),this._pointerMoveMonitor=this._register(new oa),this._register(an(this.bgDomNode,ke.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._register(an(this.domNode,ke.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._pointerdownRepeatTimer=this._register(new Ih),this._pointerdownScheduleRepeatTimer=this._register(new Lr)}_arrowPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,lt(e))};this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(t,200),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,i=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),e.preventDefault()}},Uh=class Zs{constructor(t,i,s,r,n,o,a){this._forceIntegerValues=t,this._scrollStateBrand=void 0,this._forceIntegerValues&&(i=i|0,s=s|0,r=r|0,n=n|0,o=o|0,a=a|0),this.rawScrollLeft=r,this.rawScrollTop=a,i<0&&(i=0),r+i>s&&(r=s-i),r<0&&(r=0),n<0&&(n=0),a+n>o&&(a=o-n),a<0&&(a=0),this.width=i,this.scrollWidth=s,this.scrollLeft=r,this.height=n,this.scrollHeight=o,this.scrollTop=a}equals(t){return this.rawScrollLeft===t.rawScrollLeft&&this.rawScrollTop===t.rawScrollTop&&this.width===t.width&&this.scrollWidth===t.scrollWidth&&this.scrollLeft===t.scrollLeft&&this.height===t.height&&this.scrollHeight===t.scrollHeight&&this.scrollTop===t.scrollTop}withScrollDimensions(t,i){return new Zs(this._forceIntegerValues,typeof t.width<"u"?t.width:this.width,typeof t.scrollWidth<"u"?t.scrollWidth:this.scrollWidth,i?this.rawScrollLeft:this.scrollLeft,typeof t.height<"u"?t.height:this.height,typeof t.scrollHeight<"u"?t.scrollHeight:this.scrollHeight,i?this.rawScrollTop:this.scrollTop)}withScrollPosition(t){return new Zs(this._forceIntegerValues,this.width,this.scrollWidth,typeof t.scrollLeft<"u"?t.scrollLeft:this.rawScrollLeft,this.height,this.scrollHeight,typeof t.scrollTop<"u"?t.scrollTop:this.rawScrollTop)}createScrollEvent(t,i){let s=this.width!==t.width,r=this.scrollWidth!==t.scrollWidth,n=this.scrollLeft!==t.scrollLeft,o=this.height!==t.height,a=this.scrollHeight!==t.scrollHeight,h=this.scrollTop!==t.scrollTop;return{inSmoothScrolling:i,oldWidth:t.width,oldScrollWidth:t.scrollWidth,oldScrollLeft:t.scrollLeft,width:this.width,scrollWidth:this.scrollWidth,scrollLeft:this.scrollLeft,oldHeight:t.height,oldScrollHeight:t.scrollHeight,oldScrollTop:t.scrollTop,height:this.height,scrollHeight:this.scrollHeight,scrollTop:this.scrollTop,widthChanged:s,scrollWidthChanged:r,scrollLeftChanged:n,heightChanged:o,scrollHeightChanged:a,scrollTopChanged:h}}},jh=class extends G{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new k),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new Uh(e.forceIntegerValues,0,0,0,0,0,0),this._smoothScrolling=null}dispose(){this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),super.dispose()}setSmoothScrollDuration(e){this._smoothScrollDuration=e}validateScrollPosition(e){return this._state.withScrollPosition(e)}getScrollDimensions(){return this._state}setScrollDimensions(e,t){var s;let i=this._state.withScrollDimensions(e,t);this._setState(i,!!this._smoothScrolling),(s=this._smoothScrolling)==null||s.acceptScrollDimensions(this._state)}getFutureScrollPosition(){return this._smoothScrolling?this._smoothScrolling.to:this._state}getCurrentScrollPosition(){return this._state}setScrollPositionNow(e){let t=this._state.withScrollPosition(e);this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),this._setState(t,!1)}setScrollPositionSmooth(e,t){if(this._smoothScrollDuration===0)return this.setScrollPositionNow(e);if(this._smoothScrolling){e={scrollLeft:typeof e.scrollLeft>"u"?this._smoothScrolling.to.scrollLeft:e.scrollLeft,scrollTop:typeof e.scrollTop>"u"?this._smoothScrolling.to.scrollTop:e.scrollTop};let i=this._state.withScrollPosition(e);if(this._smoothScrolling.to.scrollLeft===i.scrollLeft&&this._smoothScrolling.to.scrollTop===i.scrollTop)return;let s;t?s=new dn(this._smoothScrolling.from,i,this._smoothScrolling.startTime,this._smoothScrolling.duration):s=this._smoothScrolling.combine(this._state,i,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=s}else{let i=this._state.withScrollPosition(e);this._smoothScrolling=dn.start(this._state,i,this._smoothScrollDuration)}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}hasPendingScrollAnimation(){return!!this._smoothScrolling}_performSmoothScrolling(){if(!this._smoothScrolling)return;let e=this._smoothScrolling.tick(),t=this._state.withScrollPosition(e);if(this._setState(t,!0),!!this._smoothScrolling){if(e.isDone){this._smoothScrolling.dispose(),this._smoothScrolling=null;return}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}}_setState(e,t){let i=this._state;i.equals(e)||(this._state=e,this._onScroll.fire(this._state.createScrollEvent(i,t)))}},cn=class{constructor(e,t,i){this.scrollLeft=e,this.scrollTop=t,this.isDone=i}};function vs(e,t){let i=t-e;return function(s){return e+i*Vh(s)}}function Kh(e,t,i){return function(s){return s2.5*s){let r,n;return t{var e;(e=this._domNode)==null||e.setClassName(this._visibleClassName)},0))}_hide(e){var t;this._revealTimer.cancel(),this._isVisible&&(this._isVisible=!1,(t=this._domNode)==null||t.setClassName(this._invisibleClassName+(e?" fade":"")))}},Yh=140,aa=class extends $r{constructor(e){super(),this._lazyRender=e.lazyRender,this._host=e.host,this._scrollable=e.scrollable,this._scrollByPage=e.scrollByPage,this._scrollbarState=e.scrollbarState,this._visibilityController=this._register(new Gh(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new oa),this._shouldRender=!0,this.domNode=vi(document.createElement("div")),this.domNode.setAttribute("role","presentation"),this.domNode.setAttribute("aria-hidden","true"),this._visibilityController.setDomNode(this.domNode),this.domNode.setPosition("absolute"),this._register(j(this.domNode.domNode,ke.POINTER_DOWN,t=>this._domNodePointerDown(t)))}_createArrow(e){let t=this._register(new zh(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,i,s){this.slider=vi(document.createElement("div")),this.slider.setClassName("slider"),this.slider.setPosition("absolute"),this.slider.setTop(e),this.slider.setLeft(t),typeof i=="number"&&this.slider.setWidth(i),typeof s=="number"&&this.slider.setHeight(s),this.slider.setLayerHinting(!0),this.slider.setContain("strict"),this.domNode.domNode.appendChild(this.slider.domNode),this._register(j(this.slider.domNode,ke.POINTER_DOWN,r=>{r.button===0&&(r.preventDefault(),this._sliderPointerDown(r))})),this.onclick(this.slider.domNode,r=>{r.leftButton&&r.stopPropagation()})}_onElementSize(e){return this._scrollbarState.setVisibleSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollSize(e){return this._scrollbarState.setScrollSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollPosition(e){return this._scrollbarState.setScrollPosition(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}beginReveal(){this._visibilityController.setShouldBeVisible(!0)}beginHide(){this._visibilityController.setShouldBeVisible(!1)}render(){this._shouldRender&&(this._shouldRender=!1,this._renderDomNode(this._scrollbarState.getRectangleLargeSize(),this._scrollbarState.getRectangleSmallSize()),this._updateSlider(this._scrollbarState.getSliderSize(),this._scrollbarState.getArrowSize()+this._scrollbarState.getSliderPosition()))}_domNodePointerDown(e){e.target===this.domNode.domNode&&this._onPointerDown(e)}delegatePointerDown(e){let t=this.domNode.domNode.getClientRects()[0].top,i=t+this._scrollbarState.getSliderPosition(),s=t+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),r=this._sliderPointerPosition(e);i<=r&&r<=s?e.button===0&&(e.preventDefault(),this._sliderPointerDown(e)):this._onPointerDown(e)}_onPointerDown(e){let t,i;if(e.target===this.domNode.domNode&&typeof e.offsetX=="number"&&typeof e.offsetY=="number")t=e.offsetX,i=e.offsetY;else{let r=Oh(this.domNode.domNode);t=e.pageX-r.left,i=e.pageY-r.top}let s=this._pointerDownRelativePosition(t,i);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(s):this._scrollbarState.getDesiredScrollPositionFromOffset(s)),e.button===0&&(e.preventDefault(),this._sliderPointerDown(e))}_sliderPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=this._sliderPointerPosition(e),i=this._sliderOrthogonalPointerPosition(e),s=this._scrollbarState.clone();this.slider.toggleClassName("active",!0),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,r=>{let n=this._sliderOrthogonalPointerPosition(r),o=Math.abs(n-i);if(ia&&o>Yh){this._setDesiredScrollPositionNow(s.getScrollPosition());return}let a=this._sliderPointerPosition(r)-t;this._setDesiredScrollPositionNow(s.getDesiredScrollPositionFromDelta(a))},()=>{this.slider.toggleClassName("active",!1),this._host.onDragEnd()}),this._host.onDragStart()}_setDesiredScrollPositionNow(e){let t={};this.writeScrollPosition(t,e),this._scrollable.setScrollPositionNow(t)}updateScrollbarSize(e){this._updateScrollbarSize(e),this._scrollbarState.setScrollbarSize(e),this._shouldRender=!0,this._lazyRender||this.render()}isNeeded(){return this._scrollbarState.isNeeded()}},la=class er{constructor(t,i,s,r,n,o){this._scrollbarSize=Math.round(i),this._oppositeScrollbarSize=Math.round(s),this._arrowSize=Math.round(t),this._visibleSize=r,this._scrollSize=n,this._scrollPosition=o,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new er(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(t){let i=Math.round(t);return this._visibleSize!==i?(this._visibleSize=i,this._refreshComputedValues(),!0):!1}setScrollSize(t){let i=Math.round(t);return this._scrollSize!==i?(this._scrollSize=i,this._refreshComputedValues(),!0):!1}setScrollPosition(t){let i=Math.round(t);return this._scrollPosition!==i?(this._scrollPosition=i,this._refreshComputedValues(),!0):!1}setScrollbarSize(t){this._scrollbarSize=Math.round(t)}setOppositeScrollbarSize(t){this._oppositeScrollbarSize=Math.round(t)}static _computeValues(t,i,s,r,n){let o=Math.max(0,s-t),a=Math.max(0,o-2*i),h=r>0&&r>s;if(!h)return{computedAvailableSize:Math.round(o),computedIsNeeded:h,computedSliderSize:Math.round(a),computedSliderRatio:0,computedSliderPosition:0};let l=Math.round(Math.max(20,Math.floor(s*a/r))),c=(a-l)/(r-s),d=n*c;return{computedAvailableSize:Math.round(o),computedIsNeeded:h,computedSliderSize:Math.round(l),computedSliderRatio:c,computedSliderPosition:Math.round(d)}}_refreshComputedValues(){let t=er._computeValues(this._oppositeScrollbarSize,this._arrowSize,this._visibleSize,this._scrollSize,this._scrollPosition);this._computedAvailableSize=t.computedAvailableSize,this._computedIsNeeded=t.computedIsNeeded,this._computedSliderSize=t.computedSliderSize,this._computedSliderRatio=t.computedSliderRatio,this._computedSliderPosition=t.computedSliderPosition}getArrowSize(){return this._arrowSize}getScrollPosition(){return this._scrollPosition}getRectangleLargeSize(){return this._computedAvailableSize}getRectangleSmallSize(){return this._scrollbarSize}isNeeded(){return this._computedIsNeeded}getSliderSize(){return this._computedSliderSize}getSliderPosition(){return this._computedSliderPosition}getDesiredScrollPositionFromOffset(t){if(!this._computedIsNeeded)return 0;let i=t-this._arrowSize-this._computedSliderSize/2;return Math.round(i/this._computedSliderRatio)}getDesiredScrollPositionFromOffsetPaged(t){if(!this._computedIsNeeded)return 0;let i=t-this._arrowSize,s=this._scrollPosition;return i0&&Math.abs(t.deltaY)>0)return 1;let s=.5;if((!this._isAlmostInt(t.deltaX)||!this._isAlmostInt(t.deltaY))&&(s+=.25),i){let r=Math.abs(t.deltaX),n=Math.abs(t.deltaY),o=Math.abs(i.deltaX),a=Math.abs(i.deltaY),h=Math.max(Math.min(r,o),1),l=Math.max(Math.min(n,a),1),c=Math.max(r,o),d=Math.max(n,a);c%h===0&&d%l===0&&(s-=.5)}return Math.min(Math.max(s,0),1)}_isAlmostInt(t){return Math.abs(Math.round(t)-t)<.01}};tr.INSTANCE=new tr;var ec=tr,tc=class extends $r{constructor(e,t,i){super(),this._onScroll=this._register(new k),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new k),this.onWillScroll=this._onWillScroll.event,this._options=sc(t),this._scrollable=i,this._register(this._scrollable.onScroll(r=>{this._onWillScroll.fire(r),this._onDidScroll(r),this._onScroll.fire(r)}));let s={onMouseWheel:r=>this._onMouseWheel(r),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new Jh(this._scrollable,this._options,s)),this._horizontalScrollbar=this._register(new Xh(this._scrollable,this._options,s)),this._domNode=document.createElement("div"),this._domNode.className="xterm-scrollable-element "+this._options.className,this._domNode.setAttribute("role","presentation"),this._domNode.style.position="relative",this._domNode.appendChild(e),this._domNode.appendChild(this._horizontalScrollbar.domNode.domNode),this._domNode.appendChild(this._verticalScrollbar.domNode.domNode),this._options.useShadows?(this._leftShadowDomNode=vi(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=vi(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=vi(document.createElement("div")),this._topLeftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topLeftShadowDomNode.domNode)):(this._leftShadowDomNode=null,this._topShadowDomNode=null,this._topLeftShadowDomNode=null),this._listenOnDomNode=this._options.listenOnDomNode||this._domNode,this._mouseWheelToDispose=[],this._setListeningToMouseWheel(this._options.handleMouseWheel),this.onmouseover(this._listenOnDomNode,r=>this._onMouseOver(r)),this.onmouseleave(this._listenOnDomNode,r=>this._onMouseLeave(r)),this._hideTimeout=this._register(new Lr),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=At(this._mouseWheelToDispose),super.dispose()}getDomNode(){return this._domNode}getOverviewRulerLayoutInfo(){return{parent:this._domNode,insertBefore:this._verticalScrollbar.domNode.domNode}}delegateVerticalScrollbarPointerDown(e){this._verticalScrollbar.delegatePointerDown(e)}getScrollDimensions(){return this._scrollable.getScrollDimensions()}setScrollDimensions(e){this._scrollable.setScrollDimensions(e,!1)}updateClassName(e){this._options.className=e,ht&&(this._options.className+=" mac"),this._domNode.className="xterm-scrollable-element "+this._options.className}updateOptions(e){typeof e.handleMouseWheel<"u"&&(this._options.handleMouseWheel=e.handleMouseWheel,this._setListeningToMouseWheel(this._options.handleMouseWheel)),typeof e.mouseWheelScrollSensitivity<"u"&&(this._options.mouseWheelScrollSensitivity=e.mouseWheelScrollSensitivity),typeof e.fastScrollSensitivity<"u"&&(this._options.fastScrollSensitivity=e.fastScrollSensitivity),typeof e.scrollPredominantAxis<"u"&&(this._options.scrollPredominantAxis=e.scrollPredominantAxis),typeof e.horizontal<"u"&&(this._options.horizontal=e.horizontal),typeof e.vertical<"u"&&(this._options.vertical=e.vertical),typeof e.horizontalScrollbarSize<"u"&&(this._options.horizontalScrollbarSize=e.horizontalScrollbarSize),typeof e.verticalScrollbarSize<"u"&&(this._options.verticalScrollbarSize=e.verticalScrollbarSize),typeof e.scrollByPage<"u"&&(this._options.scrollByPage=e.scrollByPage),this._horizontalScrollbar.updateOptions(this._options),this._verticalScrollbar.updateOptions(this._options),this._options.lazyRender||this._render()}setRevealOnScroll(e){this._revealOnScroll=e}delegateScrollFromMouseWheelEvent(e){this._onMouseWheel(new nn(e))}_setListeningToMouseWheel(e){if(this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=At(this._mouseWheelToDispose),e)){let t=i=>{this._onMouseWheel(new nn(i))};this._mouseWheelToDispose.push(j(this._listenOnDomNode,ke.MOUSE_WHEEL,t,{passive:!1}))}}_onMouseWheel(e){var r;if((r=e.browserEvent)!=null&&r.defaultPrevented)return;let t=ec.INSTANCE;t.acceptStandardWheelEvent(e);let i=!1;if(e.deltaY||e.deltaX){let n=e.deltaY*this._options.mouseWheelScrollSensitivity,o=e.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&o+n===0?o=n=0:Math.abs(n)>=Math.abs(o)?o=0:n=0),this._options.flipAxes&&([n,o]=[o,n]);let a=!ht&&e.browserEvent&&e.browserEvent.shiftKey;(this._options.scrollYToX||a)&&!o&&(o=n,n=0),e.browserEvent&&e.browserEvent.altKey&&(o=o*this._options.fastScrollSensitivity,n=n*this._options.fastScrollSensitivity);let h=this._scrollable.getFutureScrollPosition(),l={};if(n){let c=un*n,d=h.scrollTop-(c<0?Math.floor(c):Math.ceil(c));this._verticalScrollbar.writeScrollPosition(l,d)}if(o){let c=un*o,d=h.scrollLeft-(c<0?Math.floor(c):Math.ceil(c));this._horizontalScrollbar.writeScrollPosition(l,d)}l=this._scrollable.validateScrollPosition(l),(h.scrollLeft!==l.scrollLeft||h.scrollTop!==l.scrollTop)&&(this._options.mouseWheelSmoothScroll&&t.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(l):this._scrollable.setScrollPositionNow(l),i=!0)}let s=i;!s&&this._options.alwaysConsumeMouseWheel&&(s=!0),!s&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(s=!0),s&&(e.preventDefault(),e.stopPropagation())}_onDidScroll(e){this._shouldRender=this._horizontalScrollbar.onDidScroll(e)||this._shouldRender,this._shouldRender=this._verticalScrollbar.onDidScroll(e)||this._shouldRender,this._options.useShadows&&(this._shouldRender=!0),this._revealOnScroll&&this._reveal(),this._options.lazyRender||this._render()}renderNow(){if(!this._options.lazyRender)throw new Error("Please use `lazyRender` together with `renderNow`!");this._render()}_render(){if(this._shouldRender&&(this._shouldRender=!1,this._horizontalScrollbar.render(),this._verticalScrollbar.render(),this._options.useShadows)){let e=this._scrollable.getCurrentScrollPosition(),t=e.scrollTop>0,i=e.scrollLeft>0,s=i?" left":"",r=t?" top":"",n=i||t?" top-left-corner":"";this._leftShadowDomNode.setClassName(`shadow${s}`),this._topShadowDomNode.setClassName(`shadow${r}`),this._topLeftShadowDomNode.setClassName(`shadow${n}${r}${s}`)}}_onDragStart(){this._isDragging=!0,this._reveal()}_onDragEnd(){this._isDragging=!1,this._hide()}_onMouseLeave(e){this._mouseIsOver=!1,this._hide()}_onMouseOver(e){this._mouseIsOver=!0,this._reveal()}_reveal(){this._verticalScrollbar.beginReveal(),this._horizontalScrollbar.beginReveal(),this._scheduleHide()}_hide(){!this._mouseIsOver&&!this._isDragging&&(this._verticalScrollbar.beginHide(),this._horizontalScrollbar.beginHide())}_scheduleHide(){!this._mouseIsOver&&!this._isDragging&&this._hideTimeout.cancelAndSet(()=>this._hide(),Zh)}},ic=class extends tc{constructor(e,t,i){super(e,t,i)}setScrollPosition(e){e.reuseAnimation?this._scrollable.setScrollPositionSmooth(e,e.reuseAnimation):this._scrollable.setScrollPositionNow(e)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}};function sc(e){let t={lazyRender:typeof e.lazyRender<"u"?e.lazyRender:!1,className:typeof e.className<"u"?e.className:"",useShadows:typeof e.useShadows<"u"?e.useShadows:!0,handleMouseWheel:typeof e.handleMouseWheel<"u"?e.handleMouseWheel:!0,flipAxes:typeof e.flipAxes<"u"?e.flipAxes:!1,consumeMouseWheelIfScrollbarIsNeeded:typeof e.consumeMouseWheelIfScrollbarIsNeeded<"u"?e.consumeMouseWheelIfScrollbarIsNeeded:!1,alwaysConsumeMouseWheel:typeof e.alwaysConsumeMouseWheel<"u"?e.alwaysConsumeMouseWheel:!1,scrollYToX:typeof e.scrollYToX<"u"?e.scrollYToX:!1,mouseWheelScrollSensitivity:typeof e.mouseWheelScrollSensitivity<"u"?e.mouseWheelScrollSensitivity:1,fastScrollSensitivity:typeof e.fastScrollSensitivity<"u"?e.fastScrollSensitivity:5,scrollPredominantAxis:typeof e.scrollPredominantAxis<"u"?e.scrollPredominantAxis:!0,mouseWheelSmoothScroll:typeof e.mouseWheelSmoothScroll<"u"?e.mouseWheelSmoothScroll:!0,arrowSize:typeof e.arrowSize<"u"?e.arrowSize:11,listenOnDomNode:typeof e.listenOnDomNode<"u"?e.listenOnDomNode:null,horizontal:typeof e.horizontal<"u"?e.horizontal:1,horizontalScrollbarSize:typeof e.horizontalScrollbarSize<"u"?e.horizontalScrollbarSize:10,horizontalSliderSize:typeof e.horizontalSliderSize<"u"?e.horizontalSliderSize:0,horizontalHasArrows:typeof e.horizontalHasArrows<"u"?e.horizontalHasArrows:!1,vertical:typeof e.vertical<"u"?e.vertical:1,verticalScrollbarSize:typeof e.verticalScrollbarSize<"u"?e.verticalScrollbarSize:10,verticalHasArrows:typeof e.verticalHasArrows<"u"?e.verticalHasArrows:!1,verticalSliderSize:typeof e.verticalSliderSize<"u"?e.verticalSliderSize:0,scrollByPage:typeof e.scrollByPage<"u"?e.scrollByPage:!1};return t.horizontalSliderSize=typeof e.horizontalSliderSize<"u"?e.horizontalSliderSize:t.horizontalScrollbarSize,t.verticalSliderSize=typeof e.verticalSliderSize<"u"?e.verticalSliderSize:t.verticalScrollbarSize,ht&&(t.className+=" mac"),t}var ir=class extends G{constructor(e,t,i,s,r,n,o,a){super(),this._bufferService=i,this._optionsService=o,this._renderService=a,this._onRequestScrollLines=this._register(new k),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let h=this._register(new jh({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:l=>Tr(s.window,l)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{h.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new ic(t,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},h)),this._register(this._optionsService.onMultipleOptionChange(["scrollSensitivity","fastScrollSensitivity","overviewRuler"],()=>this._scrollableElement.updateOptions(this._getChangeOptions()))),this._register(r.onProtocolChange(l=>{this._scrollableElement.updateOptions({handleMouseWheel:!(l&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(Le.runAndSubscribe(n.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=n.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(oe(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=s.mainDocument.createElement("style"),t.appendChild(this._styleElement),this._register(oe(()=>this._styleElement.remove())),this._register(Le.runAndSubscribe(n.onChangeColors,()=>{this._styleElement.textContent=[".xterm .xterm-scrollable-element > .scrollbar > .slider {",` background: ${n.colors.scrollbarSliderBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider:hover {",` background: ${n.colors.scrollbarSliderHoverBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider.active {",` background: ${n.colors.scrollbarSliderActiveBackground.css};`,"}"].join(` `)})),this._register(this._bufferService.onResize(()=>this.queueSync())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._latestYDisp=void 0,this.queueSync()})),this._register(this._bufferService.onScroll(()=>this._sync())),this._register(this._scrollableElement.onScroll(l=>this._handleScroll(l)))}scrollLines(e){let t=this._scrollableElement.getScrollPosition();this._scrollableElement.setScrollPosition({reuseAnimation:!0,scrollTop:t.scrollTop+e*this._renderService.dimensions.css.cell.height})}scrollToLine(e,t){t&&(this._latestYDisp=e),this._scrollableElement.setScrollPosition({reuseAnimation:!t,scrollTop:e*this._renderService.dimensions.css.cell.height})}_getChangeOptions(){var e;return{mouseWheelScrollSensitivity:this._optionsService.rawOptions.scrollSensitivity,fastScrollSensitivity:this._optionsService.rawOptions.fastScrollSensitivity,verticalScrollbarSize:((e=this._optionsService.rawOptions.overviewRuler)==null?void 0:e.width)||14}}queueSync(e){e!==void 0&&(this._latestYDisp=e),this._queuedAnimationFrame===void 0&&(this._queuedAnimationFrame=this._renderService.addRefreshCallback(()=>{this._queuedAnimationFrame=void 0,this._sync(this._latestYDisp)}))}_sync(e=this._bufferService.buffer.ydisp){!this._renderService||this._isSyncing||(this._isSyncing=!0,this._suppressOnScrollHandler=!0,this._scrollableElement.setScrollDimensions({height:this._renderService.dimensions.css.canvas.height,scrollHeight:this._renderService.dimensions.css.cell.height*this._bufferService.buffer.lines.length}),this._suppressOnScrollHandler=!1,e!==this._latestYDisp&&this._scrollableElement.setScrollPosition({scrollTop:e*this._renderService.dimensions.css.cell.height}),this._isSyncing=!1)}_handleScroll(e){if(!this._renderService||this._isHandlingScroll||this._suppressOnScrollHandler)return;this._isHandlingScroll=!0;let t=Math.round(e.scrollTop/this._renderService.dimensions.css.cell.height),i=t-this._bufferService.buffer.ydisp;i!==0&&(this._latestYDisp=t,this._onRequestScrollLines.fire(i)),this._isHandlingScroll=!1}};ir=_e([T(2,Ie),T(3,ft),T(4,zo),T(5,Jt),T(6,Oe),T(7,pt)],ir);var sr=class extends G{constructor(e,t,i,s,r){super(),this._screenElement=e,this._bufferService=t,this._coreBrowserService=i,this._decorationService=s,this._renderService=r,this._decorationElements=new Map,this._altBufferIsActive=!1,this._dimensionsChanged=!1,this._container=document.createElement("div"),this._container.classList.add("xterm-decoration-container"),this._screenElement.appendChild(this._container),this._register(this._renderService.onRenderedViewportChange(()=>this._doRefreshDecorations())),this._register(this._renderService.onDimensionsChange(()=>{this._dimensionsChanged=!0,this._queueRefresh()})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._altBufferIsActive=this._bufferService.buffer===this._bufferService.buffers.alt})),this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh())),this._register(this._decorationService.onDecorationRemoved(n=>this._removeDecoration(n))),this._register(oe(()=>{this._container.remove(),this._decorationElements.clear()}))}_queueRefresh(){this._animationFrame===void 0&&(this._animationFrame=this._renderService.addRefreshCallback(()=>{this._doRefreshDecorations(),this._animationFrame=void 0}))}_doRefreshDecorations(){for(let e of this._decorationService.decorations)this._renderDecoration(e);this._dimensionsChanged=!1}_renderDecoration(e){this._refreshStyle(e),this._dimensionsChanged&&this._refreshXPosition(e)}_createElement(e){var s;let t=this._coreBrowserService.mainDocument.createElement("div");t.classList.add("xterm-decoration"),t.classList.toggle("xterm-decoration-top-layer",((s=e==null?void 0:e.options)==null?void 0:s.layer)==="top"),t.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,t.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,t.style.top=`${(e.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height}px`,t.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;let i=e.options.x??0;return i&&i>this._bufferService.cols&&(t.style.display="none"),this._refreshXPosition(e,t),t}_refreshStyle(e){let t=e.marker.line-this._bufferService.buffers.active.ydisp;if(t<0||t>=this._bufferService.rows)e.element&&(e.element.style.display="none",e.onRenderEmitter.fire(e.element));else{let i=this._decorationElements.get(e);i||(i=this._createElement(e),e.element=i,this._decorationElements.set(e,i),this._container.appendChild(i),e.onDispose(()=>{this._decorationElements.delete(e),i.remove()})),i.style.display=this._altBufferIsActive?"none":"block",this._altBufferIsActive||(i.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,i.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,i.style.top=`${t*this._renderService.dimensions.css.cell.height}px`,i.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`),e.onRenderEmitter.fire(i)}}_refreshXPosition(e,t=e.element){if(!t)return;let i=e.options.x??0;(e.options.anchor||"left")==="right"?t.style.right=i?`${i*this._renderService.dimensions.css.cell.width}px`:"":t.style.left=i?`${i*this._renderService.dimensions.css.cell.width}px`:""}_removeDecoration(e){var t;(t=this._decorationElements.get(e))==null||t.remove(),this._decorationElements.delete(e),e.dispose()}};sr=_e([T(1,Ie),T(2,ft),T(3,xi),T(4,pt)],sr);var rc=class{constructor(){this._zones=[],this._zonePool=[],this._zonePoolIndex=0,this._linePadding={full:0,left:0,center:0,right:0}}get zones(){return this._zonePool.length=Math.min(this._zonePool.length,this._zones.length),this._zones}clear(){this._zones.length=0,this._zonePoolIndex=0}addDecoration(e){if(e.options.overviewRulerOptions){for(let t of this._zones)if(t.color===e.options.overviewRulerOptions.color&&t.position===e.options.overviewRulerOptions.position){if(this._lineIntersectsZone(t,e.marker.line))return;if(this._lineAdjacentToZone(t,e.marker.line,e.options.overviewRulerOptions.position)){this._addLineToZone(t,e.marker.line);return}}if(this._zonePoolIndex=e.startBufferLine&&t<=e.endBufferLine}_lineAdjacentToZone(e,t,i){return t>=e.startBufferLine-this._linePadding[i||"full"]&&t<=e.endBufferLine+this._linePadding[i||"full"]}_addLineToZone(e,t){e.startBufferLine=Math.min(e.startBufferLine,t),e.endBufferLine=Math.max(e.endBufferLine,t)}},nt={full:0,left:0,center:0,right:0},gt={full:0,left:0,center:0,right:0},si={full:0,left:0,center:0,right:0},is=class extends G{constructor(e,t,i,s,r,n,o,a){var l;super(),this._viewportElement=e,this._screenElement=t,this._bufferService=i,this._decorationService=s,this._renderService=r,this._optionsService=n,this._themeService=o,this._coreBrowserService=a,this._colorZoneStore=new rc,this._shouldUpdateDimensions=!0,this._shouldUpdateAnchor=!0,this._lastKnownBufferLength=0,this._canvas=this._coreBrowserService.mainDocument.createElement("canvas"),this._canvas.classList.add("xterm-decoration-overview-ruler"),this._refreshCanvasDimensions(),(l=this._viewportElement.parentElement)==null||l.insertBefore(this._canvas,this._viewportElement),this._register(oe(()=>{var c;return(c=this._canvas)==null?void 0:c.remove()}));let h=this._canvas.getContext("2d");if(h)this._ctx=h;else throw new Error("Ctx cannot be null");this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh(void 0,!0))),this._register(this._decorationService.onDecorationRemoved(()=>this._queueRefresh(void 0,!0))),this._register(this._renderService.onRenderedViewportChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._canvas.style.display=this._bufferService.buffer===this._bufferService.buffers.alt?"none":"block"})),this._register(this._bufferService.onScroll(()=>{this._lastKnownBufferLength!==this._bufferService.buffers.normal.lines.length&&(this._refreshDrawHeightConstants(),this._refreshColorZonePadding())})),this._register(this._renderService.onRender(()=>{(!this._containerHeight||this._containerHeight!==this._screenElement.clientHeight)&&(this._queueRefresh(!0),this._containerHeight=this._screenElement.clientHeight)})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh(!0))),this._register(this._optionsService.onSpecificOptionChange("overviewRuler",()=>this._queueRefresh(!0))),this._register(this._themeService.onChangeColors(()=>this._queueRefresh())),this._queueRefresh(!0)}get _width(){var e;return((e=this._optionsService.options.overviewRuler)==null?void 0:e.width)||0}_refreshDrawConstants(){let e=Math.floor((this._canvas.width-1)/3),t=Math.ceil((this._canvas.width-1)/3);gt.full=this._canvas.width,gt.left=e,gt.center=t,gt.right=e,this._refreshDrawHeightConstants(),si.full=1,si.left=1,si.center=1+gt.left,si.right=1+gt.left+gt.center}_refreshDrawHeightConstants(){nt.full=Math.round(2*this._coreBrowserService.dpr);let e=this._canvas.height/this._bufferService.buffer.lines.length,t=Math.round(Math.max(Math.min(e,12),6)*this._coreBrowserService.dpr);nt.left=t,nt.center=t,nt.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*nt.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*nt.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*nt.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*nt.right)}),this._lastKnownBufferLength=this._bufferService.buffers.normal.lines.length}_refreshCanvasDimensions(){this._canvas.style.width=`${this._width}px`,this._canvas.width=Math.round(this._width*this._coreBrowserService.dpr),this._canvas.style.height=`${this._screenElement.clientHeight}px`,this._canvas.height=Math.round(this._screenElement.clientHeight*this._coreBrowserService.dpr),this._refreshDrawConstants(),this._refreshColorZonePadding()}_refreshDecorations(){this._shouldUpdateDimensions&&this._refreshCanvasDimensions(),this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height),this._colorZoneStore.clear();for(let t of this._decorationService.decorations)this._colorZoneStore.addDecoration(t);this._ctx.lineWidth=1,this._renderRulerOutline();let e=this._colorZoneStore.zones;for(let t of e)t.position!=="full"&&this._renderColorZone(t);for(let t of e)t.position==="full"&&this._renderColorZone(t);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderRulerOutline(){this._ctx.fillStyle=this._themeService.colors.overviewRulerBorder.css,this._ctx.fillRect(0,0,1,this._canvas.height),this._optionsService.rawOptions.overviewRuler.showTopBorder&&this._ctx.fillRect(1,0,this._canvas.width-1,1),this._optionsService.rawOptions.overviewRuler.showBottomBorder&&this._ctx.fillRect(1,this._canvas.height-1,this._canvas.width-1,this._canvas.height)}_renderColorZone(e){this._ctx.fillStyle=e.color,this._ctx.fillRect(si[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-nt[e.position||"full"]/2),gt[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+nt[e.position||"full"]))}_queueRefresh(e,t){this._shouldUpdateDimensions=e||this._shouldUpdateDimensions,this._shouldUpdateAnchor=t||this._shouldUpdateAnchor,this._animationFrame===void 0&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._refreshDecorations(),this._animationFrame=void 0}))}};is=_e([T(2,Ie),T(3,xi),T(4,pt),T(5,Oe),T(6,Jt),T(7,ft)],is);var v;(e=>(e.NUL="\0",e.SOH="",e.STX="",e.ETX="",e.EOT="",e.ENQ="",e.ACK="",e.BEL="\x07",e.BS="\b",e.HT=" ",e.LF=` -`,e.VT="\v",e.FF="\f",e.CR="\r",e.SO="",e.SI="",e.DLE="",e.DC1="",e.DC2="",e.DC3="",e.DC4="",e.NAK="",e.SYN="",e.ETB="",e.CAN="",e.EM="",e.SUB="",e.ESC="\x1B",e.FS="",e.GS="",e.RS="",e.US="",e.SP=" ",e.DEL=""))(v||(v={}));var ji;(e=>(e.PAD="€",e.HOP="",e.BPH="‚",e.NBH="ƒ",e.IND="„",e.NEL="…",e.SSA="†",e.ESA="‡",e.HTS="ˆ",e.HTJ="‰",e.VTS="Š",e.PLD="‹",e.PLU="Œ",e.RI="",e.SS2="Ž",e.SS3="",e.DCS="",e.PU1="‘",e.PU2="’",e.STS="“",e.CCH="”",e.MW="•",e.SPA="–",e.EPA="—",e.SOS="˜",e.SGCI="™",e.SCI="š",e.CSI="›",e.ST="œ",e.OSC="",e.PM="ž",e.APC="Ÿ"))(ji||(ji={}));var ha;(e=>e.ST=`${v.ESC}\\`)(ha||(ha={}));var rr=class{constructor(e,t,i,s,r,n){this._textarea=e,this._compositionView=t,this._bufferService=i,this._optionsService=s,this._coreService=r,this._renderService=n,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=""}get isComposing(){return this._isComposing}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent="",this._dataAlreadySent="",this._compositionView.classList.add("active")}compositionupdate(e){this._compositionView.textContent=e.data,this.updateCompositionElements(),setTimeout(()=>{this._compositionPosition.end=this._textarea.value.length},0)}compositionend(){this._finalizeComposition(!0)}keydown(e){if(this._isComposing||this._isSendingComposition){if(e.keyCode===20||e.keyCode===229||e.keyCode===16||e.keyCode===17||e.keyCode===18)return!1;this._finalizeComposition(!1)}return e.keyCode===229?(this._handleAnyTextareaChanges(),!1):!0}_finalizeComposition(e){if(this._compositionView.classList.remove("active"),this._isComposing=!1,e){let t={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout(()=>{if(this._isSendingComposition){this._isSendingComposition=!1;let i;t.start+=this._dataAlreadySent.length,this._isComposing?i=this._textarea.value.substring(t.start,this._compositionPosition.start):i=this._textarea.value.substring(t.start),i.length>0&&this._coreService.triggerDataEvent(i,!0)}},0)}else{this._isSendingComposition=!1;let t=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(t,!0)}}_handleAnyTextareaChanges(){let e=this._textarea.value;setTimeout(()=>{if(!this._isComposing){let t=this._textarea.value,i=t.replace(e,"");this._dataAlreadySent=i,t.length>e.length?this._coreService.triggerDataEvent(i,!0):t.lengththis.updateCompositionElements(!0),0)}}};rr=_e([T(2,Ie),T(3,Oe),T(4,Nt),T(5,pt)],rr);var Ee=0,Re=0,Be=0,ue=0,_n={css:"#00000000",rgba:0},ve;(e=>{function t(r,n,o,a){return a!==void 0?`#${Mt(r)}${Mt(n)}${Mt(o)}${Mt(a)}`:`#${Mt(r)}${Mt(n)}${Mt(o)}`}e.toCss=t;function i(r,n,o,a=255){return(r<<24|n<<16|o<<8|a)>>>0}e.toRgba=i;function s(r,n,o,a){return{css:e.toCss(r,n,o,a),rgba:e.toRgba(r,n,o,a)}}e.toColor=s})(ve||(ve={}));var re;(e=>{function t(h,l){if(ue=(l.rgba&255)/255,ue===1)return{css:l.css,rgba:l.rgba};let c=l.rgba>>24&255,d=l.rgba>>16&255,u=l.rgba>>8&255,f=h.rgba>>24&255,_=h.rgba>>16&255,p=h.rgba>>8&255;Ee=f+Math.round((c-f)*ue),Re=_+Math.round((d-_)*ue),Be=p+Math.round((u-p)*ue);let g=ve.toCss(Ee,Re,Be),E=ve.toRgba(Ee,Re,Be);return{css:g,rgba:E}}e.blend=t;function i(h){return(h.rgba&255)===255}e.isOpaque=i;function s(h,l,c){let d=Ki.ensureContrastRatio(h.rgba,l.rgba,c);if(d)return ve.toColor(d>>24&255,d>>16&255,d>>8&255)}e.ensureContrastRatio=s;function r(h){let l=(h.rgba|255)>>>0;return[Ee,Re,Be]=Ki.toChannels(l),{css:ve.toCss(Ee,Re,Be),rgba:l}}e.opaque=r;function n(h,l){return ue=Math.round(l*255),[Ee,Re,Be]=Ki.toChannels(h.rgba),{css:ve.toCss(Ee,Re,Be,ue),rgba:ve.toRgba(Ee,Re,Be,ue)}}e.opacity=n;function o(h,l){return ue=h.rgba&255,n(h,ue*l/255)}e.multiplyOpacity=o;function a(h){return[h.rgba>>24&255,h.rgba>>16&255,h.rgba>>8&255]}e.toColorRGB=a})(re||(re={}));var ce;(e=>{let t,i;try{let r=document.createElement("canvas");r.width=1,r.height=1;let n=r.getContext("2d",{willReadFrequently:!0});n&&(t=n,t.globalCompositeOperation="copy",i=t.createLinearGradient(0,0,1,1))}catch{}function s(r){if(r.match(/#[\da-f]{3,8}/i))switch(r.length){case 4:return Ee=parseInt(r.slice(1,2).repeat(2),16),Re=parseInt(r.slice(2,3).repeat(2),16),Be=parseInt(r.slice(3,4).repeat(2),16),ve.toColor(Ee,Re,Be);case 5:return Ee=parseInt(r.slice(1,2).repeat(2),16),Re=parseInt(r.slice(2,3).repeat(2),16),Be=parseInt(r.slice(3,4).repeat(2),16),ue=parseInt(r.slice(4,5).repeat(2),16),ve.toColor(Ee,Re,Be,ue);case 7:return{css:r,rgba:(parseInt(r.slice(1),16)<<8|255)>>>0};case 9:return{css:r,rgba:parseInt(r.slice(1),16)>>>0}}let n=r.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(n)return Ee=parseInt(n[1]),Re=parseInt(n[2]),Be=parseInt(n[3]),ue=Math.round((n[5]===void 0?1:parseFloat(n[5]))*255),ve.toColor(Ee,Re,Be,ue);if(!t||!i)throw new Error("css.toColor: Unsupported css format");if(t.fillStyle=i,t.fillStyle=r,typeof t.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(t.fillRect(0,0,1,1),[Ee,Re,Be,ue]=t.getImageData(0,0,1,1).data,ue!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:ve.toRgba(Ee,Re,Be,ue),css:r}}e.toColor=s})(ce||(ce={}));var Pe;(e=>{function t(s){return i(s>>16&255,s>>8&255,s&255)}e.relativeLuminance=t;function i(s,r,n){let o=s/255,a=r/255,h=n/255,l=o<=.03928?o/12.92:Math.pow((o+.055)/1.055,2.4),c=a<=.03928?a/12.92:Math.pow((a+.055)/1.055,2.4),d=h<=.03928?h/12.92:Math.pow((h+.055)/1.055,2.4);return l*.2126+c*.7152+d*.0722}e.relativeLuminance2=i})(Pe||(Pe={}));var Ki;(e=>{function t(o,a){if(ue=(a&255)/255,ue===1)return a;let h=a>>24&255,l=a>>16&255,c=a>>8&255,d=o>>24&255,u=o>>16&255,f=o>>8&255;return Ee=d+Math.round((h-d)*ue),Re=u+Math.round((l-u)*ue),Be=f+Math.round((c-f)*ue),ve.toRgba(Ee,Re,Be)}e.blend=t;function i(o,a,h){let l=Pe.relativeLuminance(o>>8),c=Pe.relativeLuminance(a>>8);if(ut(l,c)>8));if(_>8));return _>g?f:p}return f}let d=r(o,a,h),u=ut(l,Pe.relativeLuminance(d>>8));if(u>8));return u>_?d:f}return d}}e.ensureContrastRatio=i;function s(o,a,h){let l=o>>24&255,c=o>>16&255,d=o>>8&255,u=a>>24&255,f=a>>16&255,_=a>>8&255,p=ut(Pe.relativeLuminance2(u,f,_),Pe.relativeLuminance2(l,c,d));for(;p0||f>0||_>0);)u-=Math.max(0,Math.ceil(u*.1)),f-=Math.max(0,Math.ceil(f*.1)),_-=Math.max(0,Math.ceil(_*.1)),p=ut(Pe.relativeLuminance2(u,f,_),Pe.relativeLuminance2(l,c,d));return(u<<24|f<<16|_<<8|255)>>>0}e.reduceLuminance=s;function r(o,a,h){let l=o>>24&255,c=o>>16&255,d=o>>8&255,u=a>>24&255,f=a>>16&255,_=a>>8&255,p=ut(Pe.relativeLuminance2(u,f,_),Pe.relativeLuminance2(l,c,d));for(;p>>0}e.increaseLuminance=r;function n(o){return[o>>24&255,o>>16&255,o>>8&255,o&255]}e.toChannels=n})(Ki||(Ki={}));function Mt(e){let t=e.toString(16);return t.length<2?"0"+t:t}function ut(e,t){return e1){let c=this._getJoinedRanges(s,o,n,t,r);for(let d=0;d1){let l=this._getJoinedRanges(s,o,n,t,r);for(let c=0;c=Fe,F=S,B=this._workCell;if(u.length>0&&S===u[0][0]&&A){let I=u.shift(),ie=this._isCellInSelection(I[0],t);for(z=I[0]+1;z=I[1]),A?(x=!0,B=new nc(this._workCell,e.translateToString(!0,I[0],I[1]),I[1]-I[0]),F=I[1]-1,L=B.getWidth()):Fe=I[1]}let X=this._isCellInSelection(S,t),te=i&&S===n,He=N&&S>=l&&S<=c,Qe=!1;this._decorationService.forEachDecorationAtCell(S,t,void 0,I=>{Qe=!0});let le=B.getChars()||Ct;if(le===" "&&(B.isUnderline()||B.isOverline())&&(le=" "),J=L*a-h.get(le,B.isBold(),B.isItalic()),!p)p=this._document.createElement("span");else if(g&&(X&&ne||!X&&!ne&&B.bg===O)&&(X&&ne&&f.selectionForeground||B.fg===M)&&B.extended.ext===$&&He===K&&J===ae&&!te&&!x&&!Qe&&A){B.isInvisible()?E+=Ct:E+=le,g++;continue}else g&&(p.textContent=E),p=this._document.createElement("span"),g=0,E="";if(O=B.bg,M=B.fg,$=B.extended.ext,K=He,ae=J,ne=X,x&&n>=S&&n<=F&&(n=S),!this._coreService.isCursorHidden&&te&&this._coreService.isCursorInitialized){if(Y.push("xterm-cursor"),this._coreBrowserService.isFocused)o&&Y.push("xterm-cursor-blink"),Y.push(s==="bar"?"xterm-cursor-bar":s==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(r)switch(r){case"outline":Y.push("xterm-cursor-outline");break;case"block":Y.push("xterm-cursor-block");break;case"bar":Y.push("xterm-cursor-bar");break;case"underline":Y.push("xterm-cursor-underline");break}}if(B.isBold()&&Y.push("xterm-bold"),B.isItalic()&&Y.push("xterm-italic"),B.isDim()&&Y.push("xterm-dim"),B.isInvisible()?E=Ct:E=B.getChars()||Ct,B.isUnderline()&&(Y.push(`xterm-underline-${B.extended.underlineStyle}`),E===" "&&(E=" "),!B.isUnderlineColorDefault()))if(B.isUnderlineColorRGB())p.style.textDecorationColor=`rgb(${Ci.toColorRGB(B.getUnderlineColor()).join(",")})`;else{let I=B.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&B.isBold()&&I<8&&(I+=8),p.style.textDecorationColor=f.ansi[I].css}B.isOverline()&&(Y.push("xterm-overline"),E===" "&&(E=" ")),B.isStrikethrough()&&Y.push("xterm-strikethrough"),He&&(p.style.textDecoration="underline");let Te=B.getFgColor(),Ve=B.getFgColorMode(),We=B.getBgColor(),dt=B.getBgColorMode(),Qt=!!B.isInverse();if(Qt){let I=Te;Te=We,We=I;let ie=Ve;Ve=dt,dt=ie}let C,P,H=!1;this._decorationService.forEachDecorationAtCell(S,t,void 0,I=>{I.options.layer!=="top"&&H||(I.backgroundColorRGB&&(dt=50331648,We=I.backgroundColorRGB.rgba>>8&16777215,C=I.backgroundColorRGB),I.foregroundColorRGB&&(Ve=50331648,Te=I.foregroundColorRGB.rgba>>8&16777215,P=I.foregroundColorRGB),H=I.options.layer==="top")}),!H&&X&&(C=this._coreBrowserService.isFocused?f.selectionBackgroundOpaque:f.selectionInactiveBackgroundOpaque,We=C.rgba>>8&16777215,dt=50331648,H=!0,f.selectionForeground&&(Ve=50331648,Te=f.selectionForeground.rgba>>8&16777215,P=f.selectionForeground)),H&&Y.push("xterm-decoration-top");let q;switch(dt){case 16777216:case 33554432:q=f.ansi[We],Y.push(`xterm-bg-${We}`);break;case 50331648:q=ve.toColor(We>>16,We>>8&255,We&255),this._addStyle(p,`background-color:#${fn((We>>>0).toString(16),"0",6)}`);break;case 0:default:Qt?(q=f.foreground,Y.push("xterm-bg-257")):q=f.background}switch(C||B.isDim()&&(C=re.multiplyOpacity(q,.5)),Ve){case 16777216:case 33554432:B.isBold()&&Te<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(Te+=8),this._applyMinimumContrast(p,q,f.ansi[Te],B,C,void 0)||Y.push(`xterm-fg-${Te}`);break;case 50331648:let I=ve.toColor(Te>>16&255,Te>>8&255,Te&255);this._applyMinimumContrast(p,q,I,B,C,P)||this._addStyle(p,`color:#${fn(Te.toString(16),"0",6)}`);break;case 0:default:this._applyMinimumContrast(p,q,f.foreground,B,C,P)||Qt&&Y.push("xterm-fg-257")}Y.length&&(p.className=Y.join(" "),Y.length=0),!te&&!x&&!Qe&&A?g++:p.textContent=E,J!==this.defaultSpacing&&(p.style.letterSpacing=`${J}px`),d.push(p),S=F}return p&&g&&(p.textContent=E),d}_applyMinimumContrast(e,t,i,s,r,n){if(this._optionsService.rawOptions.minimumContrastRatio===1||lc(s.getCode()))return!1;let o=this._getContrastCache(s),a;if(!r&&!n&&(a=o.getColor(t.rgba,i.rgba)),a===void 0){let h=this._optionsService.rawOptions.minimumContrastRatio/(s.isDim()?2:1);a=re.ensureContrastRatio(r||t,n||i,h),o.setColor((r||t).rgba,(n||i).rgba,a??null)}return a?(this._addStyle(e,`color:${a.css}`),!0):!1}_getContrastCache(e){return e.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(e,t){e.setAttribute("style",`${e.getAttribute("style")||""}${t};`)}_isCellInSelection(e,t){let i=this._selectionStart,s=this._selectionEnd;return!i||!s?!1:this._columnSelectMode?i[0]<=s[0]?e>=i[0]&&t>=i[1]&&e=i[1]&&e>=s[0]&&t<=s[1]:t>i[1]&&t=i[0]&&e=i[0]}};nr=_e([T(1,Ko),T(2,Oe),T(3,ft),T(4,Nt),T(5,xi),T(6,Jt)],nr);function fn(e,t,i){for(;e.length0&&(this._flat[s]=o),o}let r=e;t&&(r+="B"),i&&(r+="I");let n=this._holey.get(r);if(n===void 0){let o=0;t&&(o|=1),i&&(o|=2),n=this._measure(e,o),n>0&&this._holey.set(r,n)}return n}_measure(e,t){let i=this._measureElements[t];return i.textContent=e.repeat(32),i.offsetWidth/32}},dc=class{constructor(){this.clear()}clear(){this.hasSelection=!1,this.columnSelectMode=!1,this.viewportStartRow=0,this.viewportEndRow=0,this.viewportCappedStartRow=0,this.viewportCappedEndRow=0,this.startCol=0,this.endCol=0,this.selectionStart=void 0,this.selectionEnd=void 0}update(e,t,i,s=!1){if(this.selectionStart=t,this.selectionEnd=i,!t||!i||t[0]===i[0]&&t[1]===i[1]){this.clear();return}let r=e.buffers.active.ydisp,n=t[1]-r,o=i[1]-r,a=Math.max(n,0),h=Math.min(o,e.rows-1);if(a>=e.rows||h<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=s,this.viewportStartRow=n,this.viewportEndRow=o,this.viewportCappedStartRow=a,this.viewportCappedEndRow=h,this.startCol=t[0],this.endCol=i[0]}isCellSelected(e,t,i){return this.hasSelection?(i-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?t>=this.startCol&&i>=this.viewportCappedStartRow&&t=this.viewportCappedStartRow&&t>=this.endCol&&i<=this.viewportCappedEndRow:i>this.viewportStartRow&&i=this.startCol&&t=this.startCol):!1}};function uc(){return new dc}var Ss="xterm-dom-renderer-owner-",Ge="xterm-rows",Ni="xterm-fg-",pn="xterm-bg-",ri="xterm-focus",Ii="xterm-selection",_c=1,or=class extends G{constructor(e,t,i,s,r,n,o,a,h,l,c,d,u,f){super(),this._terminal=e,this._document=t,this._element=i,this._screenElement=s,this._viewportElement=r,this._helperContainer=n,this._linkifier2=o,this._charSizeService=h,this._optionsService=l,this._bufferService=c,this._coreService=d,this._coreBrowserService=u,this._themeService=f,this._terminalClass=_c++,this._rowElements=[],this._selectionRenderModel=uc(),this.onRequestRedraw=this._register(new k).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(Ge),this._rowContainer.style.lineHeight="normal",this._rowContainer.setAttribute("aria-hidden","true"),this._refreshRowElements(this._bufferService.cols,this._bufferService.rows),this._selectionContainer=this._document.createElement("div"),this._selectionContainer.classList.add(Ii),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=hc(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(_=>this._injectCss(_))),this._injectCss(this._themeService.colors),this._rowFactory=a.createInstance(nr,document),this._element.classList.add(Ss+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(_=>this._handleLinkHover(_))),this._register(this._linkifier2.onHideLinkUnderline(_=>this._handleLinkLeave(_))),this._register(oe(()=>{this._element.classList.remove(Ss+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new cc(this._document,this._helperContainer),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}_updateDimensions(){let e=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*e,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*e),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.left=0,this.dimensions.device.char.top=0,this.dimensions.device.canvas.width=this.dimensions.device.cell.width*this._bufferService.cols,this.dimensions.device.canvas.height=this.dimensions.device.cell.height*this._bufferService.rows,this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/e),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/e),this.dimensions.css.cell.width=this.dimensions.css.canvas.width/this._bufferService.cols,this.dimensions.css.cell.height=this.dimensions.css.canvas.height/this._bufferService.rows;for(let i of this._rowElements)i.style.width=`${this.dimensions.css.canvas.width}px`,i.style.height=`${this.dimensions.css.cell.height}px`,i.style.lineHeight=`${this.dimensions.css.cell.height}px`,i.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));let t=`${this._terminalSelector} .${Ge} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=t,this._selectionContainer.style.height=this._viewportElement.style.height,this._screenElement.style.width=`${this.dimensions.css.canvas.width}px`,this._screenElement.style.height=`${this.dimensions.css.canvas.height}px`}_injectCss(e){this._themeStyleElement||(this._themeStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._themeStyleElement));let t=`${this._terminalSelector} .${Ge} { pointer-events: none; color: ${e.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;t+=`${this._terminalSelector} .${Ge} .xterm-dim { color: ${re.multiplyOpacity(e.foreground,.5).css};}`,t+=`${this._terminalSelector} span:not(.xterm-bold) { font-weight: ${this._optionsService.rawOptions.fontWeight};}${this._terminalSelector} span.xterm-bold { font-weight: ${this._optionsService.rawOptions.fontWeightBold};}${this._terminalSelector} span.xterm-italic { font-style: italic;}`;let i=`blink_underline_${this._terminalClass}`,s=`blink_bar_${this._terminalClass}`,r=`blink_block_${this._terminalClass}`;t+=`@keyframes ${i} { 50% { border-bottom-style: hidden; }}`,t+=`@keyframes ${s} { 50% { box-shadow: none; }}`,t+=`@keyframes ${r} { 0% { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css}; } 50% { background-color: inherit; color: ${e.cursor.css}; }}`,t+=`${this._terminalSelector} .${Ge}.${ri} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${i} 1s step-end infinite;}${this._terminalSelector} .${Ge}.${ri} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${Ge}.${ri} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${r} 1s step-end infinite;}${this._terminalSelector} .${Ge} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${Ge} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${Ge} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${Ge} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${Ge} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${Ii} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${Ii} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${Ii} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[n,o]of e.ansi.entries())t+=`${this._terminalSelector} .${Ni}${n} { color: ${o.css}; }${this._terminalSelector} .${Ni}${n}.xterm-dim { color: ${re.multiplyOpacity(o,.5).css}; }${this._terminalSelector} .${pn}${n} { background-color: ${o.css}; }`;t+=`${this._terminalSelector} .${Ni}257 { color: ${re.opaque(e.background).css}; }${this._terminalSelector} .${Ni}257.xterm-dim { color: ${re.multiplyOpacity(re.opaque(e.background),.5).css}; }${this._terminalSelector} .${pn}257 { background-color: ${e.foreground.css}; }`,this._themeStyleElement.textContent=t}_setDefaultSpacing(){let e=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${e}px`,this._rowFactory.defaultSpacing=e}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(e,t){for(let i=this._rowElements.length;i<=t;i++){let s=this._document.createElement("div");this._rowContainer.appendChild(s),this._rowElements.push(s)}for(;this._rowElements.length>t;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(e,t){this._refreshRowElements(e,t),this._updateDimensions(),this.handleSelectionChanged(this._selectionRenderModel.selectionStart,this._selectionRenderModel.selectionEnd,this._selectionRenderModel.columnSelectMode)}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(ri),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(ri),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,t,i){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,t,i),this.renderRows(0,this._bufferService.rows-1),!e||!t||(this._selectionRenderModel.update(this._terminal,e,t,i),!this._selectionRenderModel.hasSelection))return;let s=this._selectionRenderModel.viewportStartRow,r=this._selectionRenderModel.viewportEndRow,n=this._selectionRenderModel.viewportCappedStartRow,o=this._selectionRenderModel.viewportCappedEndRow,a=this._document.createDocumentFragment();if(i){let h=e[0]>t[0];a.appendChild(this._createSelectionElement(n,h?t[0]:e[0],h?e[0]:t[0],o-n+1))}else{let h=s===n?e[0]:0,l=n===r?t[0]:this._bufferService.cols;a.appendChild(this._createSelectionElement(n,h,l));let c=o-n-1;if(a.appendChild(this._createSelectionElement(n+1,0,this._bufferService.cols,c)),n!==o){let d=r===o?t[0]:this._bufferService.cols;a.appendChild(this._createSelectionElement(o,0,d))}}this._selectionContainer.appendChild(a)}_createSelectionElement(e,t,i,s=1){let r=this._document.createElement("div"),n=t*this.dimensions.css.cell.width,o=this.dimensions.css.cell.width*(i-t);return n+o>this.dimensions.css.canvas.width&&(o=this.dimensions.css.canvas.width-n),r.style.height=`${s*this.dimensions.css.cell.height}px`,r.style.top=`${e*this.dimensions.css.cell.height}px`,r.style.left=`${n}px`,r.style.width=`${o}px`,r}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(let e of this._rowElements)e.replaceChildren()}renderRows(e,t){let i=this._bufferService.buffer,s=i.ybase+i.y,r=Math.min(i.x,this._bufferService.cols-1),n=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,o=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,a=this._optionsService.rawOptions.cursorInactiveStyle;for(let h=e;h<=t;h++){let l=h+i.ydisp,c=this._rowElements[h],d=i.lines.get(l);if(!c||!d)break;c.replaceChildren(...this._rowFactory.createRow(d,l,l===s,o,a,r,n,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${Ss}${this._terminalClass}`}_handleLinkHover(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!0)}_handleLinkLeave(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!1)}_setCellUnderline(e,t,i,s,r,n){i<0&&(e=0),s<0&&(t=0);let o=this._bufferService.rows-1;i=Math.max(Math.min(i,o),0),s=Math.max(Math.min(s,o),0),r=Math.min(r,this._bufferService.cols);let a=this._bufferService.buffer,h=a.ybase+a.y,l=Math.min(a.x,r-1),c=this._optionsService.rawOptions.cursorBlink,d=this._optionsService.rawOptions.cursorStyle,u=this._optionsService.rawOptions.cursorInactiveStyle;for(let f=i;f<=s;++f){let _=f+a.ydisp,p=this._rowElements[f],g=a.lines.get(_);if(!p||!g)break;p.replaceChildren(...this._rowFactory.createRow(g,_,_===h,d,u,l,c,this.dimensions.css.cell.width,this._widthCache,n?f===i?e:0:-1,n?(f===s?t:r)-1:-1))}}};or=_e([T(7,Er),T(8,hs),T(9,Oe),T(10,Ie),T(11,Nt),T(12,ft),T(13,Jt)],or);var ar=class extends G{constructor(e,t,i){super(),this._optionsService=i,this.width=0,this.height=0,this._onCharSizeChange=this._register(new k),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new pc(this._optionsService))}catch{this._measureStrategy=this._register(new fc(e,t,this._optionsService))}this._register(this._optionsService.onMultipleOptionChange(["fontFamily","fontSize"],()=>this.measure()))}get hasValidSize(){return this.width>0&&this.height>0}measure(){let e=this._measureStrategy.measure();(e.width!==this.width||e.height!==this.height)&&(this.width=e.width,this.height=e.height,this._onCharSizeChange.fire())}};ar=_e([T(2,Oe)],ar);var ca=class extends G{constructor(){super(...arguments),this._result={width:0,height:0}}_validateAndSet(e,t){e!==void 0&&e>0&&t!==void 0&&t>0&&(this._result.width=e,this._result.height=t)}},fc=class extends ca{constructor(e,t,i){super(),this._document=e,this._parentElement=t,this._optionsService=i,this._measureElement=this._document.createElement("span"),this._measureElement.classList.add("xterm-char-measure-element"),this._measureElement.textContent="W".repeat(32),this._measureElement.setAttribute("aria-hidden","true"),this._measureElement.style.whiteSpace="pre",this._measureElement.style.fontKerning="none",this._parentElement.appendChild(this._measureElement)}measure(){return this._measureElement.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._measureElement.style.fontSize=`${this._optionsService.rawOptions.fontSize}px`,this._validateAndSet(Number(this._measureElement.offsetWidth)/32,Number(this._measureElement.offsetHeight)),this._result}},pc=class extends ca{constructor(e){super(),this._optionsService=e,this._canvas=new OffscreenCanvas(100,100),this._ctx=this._canvas.getContext("2d");let t=this._ctx.measureText("W");if(!("width"in t&&"fontBoundingBoxAscent"in t&&"fontBoundingBoxDescent"in t))throw new Error("Required font metrics not supported")}measure(){this._ctx.font=`${this._optionsService.rawOptions.fontSize}px ${this._optionsService.rawOptions.fontFamily}`;let e=this._ctx.measureText("W");return this._validateAndSet(e.width,e.fontBoundingBoxAscent+e.fontBoundingBoxDescent),this._result}},mc=class extends G{constructor(e,t,i){super(),this._textarea=e,this._window=t,this.mainDocument=i,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new gc(this._window)),this._onDprChange=this._register(new k),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new k),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(s=>this._screenDprMonitor.setWindow(s))),this._register(Le.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(j(this._textarea,"focus",()=>this._isFocused=!0)),this._register(j(this._textarea,"blur",()=>this._isFocused=!1))}get window(){return this._window}set window(e){this._window!==e&&(this._window=e,this._onWindowChange.fire(this._window))}get dpr(){return this.window.devicePixelRatio}get isFocused(){return this._cachedIsFocused===void 0&&(this._cachedIsFocused=this._isFocused&&this._textarea.ownerDocument.hasFocus(),queueMicrotask(()=>this._cachedIsFocused=void 0)),this._cachedIsFocused}},gc=class extends G{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new Yt),this._onDprChange=this._register(new k),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(oe(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=j(this._parentWindow,"resize",()=>this._setDprAndFireIfDiffers())}_setDprAndFireIfDiffers(){this._parentWindow.devicePixelRatio!==this._currentDevicePixelRatio&&this._onDprChange.fire(this._parentWindow.devicePixelRatio),this._updateDpr()}_updateDpr(){var e;this._outerListener&&((e=this._resolutionMediaMatchList)==null||e.removeListener(this._outerListener),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._resolutionMediaMatchList=this._parentWindow.matchMedia(`screen and (resolution: ${this._parentWindow.devicePixelRatio}dppx)`),this._resolutionMediaMatchList.addListener(this._outerListener))}clearListener(){!this._resolutionMediaMatchList||!this._outerListener||(this._resolutionMediaMatchList.removeListener(this._outerListener),this._resolutionMediaMatchList=void 0,this._outerListener=void 0)}},vc=class extends G{constructor(){super(),this.linkProviders=[],this._register(oe(()=>this.linkProviders.length=0))}registerLinkProvider(e){return this.linkProviders.push(e),{dispose:()=>{let t=this.linkProviders.indexOf(e);t!==-1&&this.linkProviders.splice(t,1)}}}};function Ar(e,t,i){let s=i.getBoundingClientRect(),r=e.getComputedStyle(i),n=parseInt(r.getPropertyValue("padding-left")),o=parseInt(r.getPropertyValue("padding-top"));return[t.clientX-s.left-n,t.clientY-s.top-o]}function Sc(e,t,i,s,r,n,o,a,h){if(!n)return;let l=Ar(e,t,i);if(l)return l[0]=Math.ceil((l[0]+(h?o/2:0))/o),l[1]=Math.ceil(l[1]/a),l[0]=Math.min(Math.max(l[0],1),s+(h?1:0)),l[1]=Math.min(Math.max(l[1],1),r),l}var lr=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,i,s,r){return Sc(window,e,t,i,s,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,r)}getMouseReportCoords(e,t){let i=Ar(window,e,t);if(this._charSizeService.hasValidSize)return i[0]=Math.min(Math.max(i[0],0),this._renderService.dimensions.css.canvas.width-1),i[1]=Math.min(Math.max(i[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(i[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(i[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(i[0]),y:Math.floor(i[1])}}};lr=_e([T(0,pt),T(1,hs)],lr);var yc=class{constructor(e,t){this._renderCallback=e,this._coreBrowserService=t,this._refreshCallbacks=[]}dispose(){this._animationFrame&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}addRefreshCallback(e){return this._refreshCallbacks.push(e),this._animationFrame||(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh())),this._animationFrame}refresh(e,t,i){this._rowCount=i,e=e!==void 0?e:0,t=t!==void 0?t:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,e):e,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,t):t,!this._animationFrame&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh()))}_innerRefresh(){if(this._animationFrame=void 0,this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0){this._runRefreshCallbacks();return}let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(let e of this._refreshCallbacks)e(0);this._refreshCallbacks=[]}},da={};Dl(da,{getSafariVersion:()=>wc,isChromeOS:()=>pa,isFirefox:()=>ua,isIpad:()=>Cc,isIphone:()=>xc,isLegacyEdge:()=>bc,isLinux:()=>Pr,isMac:()=>rs,isNode:()=>cs,isSafari:()=>_a,isWindows:()=>fa});var cs=typeof process<"u"&&"title"in process,ki=cs?"node":navigator.userAgent,Ei=cs?"node":navigator.platform,ua=ki.includes("Firefox"),bc=ki.includes("Edge"),_a=/^((?!chrome|android).)*safari/i.test(ki);function wc(){if(!_a)return 0;let e=ki.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var rs=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(Ei),Cc=Ei==="iPad",xc=Ei==="iPhone",fa=["Windows","Win16","Win32","WinCE"].includes(Ei),Pr=Ei.indexOf("Linux")>=0,pa=/\bCrOS\b/.test(ki),ma=class{constructor(){this._tasks=[],this._i=0}enqueue(e){this._tasks.push(e),this._start()}flush(){for(;this._ir){s-t<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(s-t))}ms`),this._start();return}s=r}this.clear()}},kc=class extends ma{_requestCallback(e){return setTimeout(()=>e(this._createDeadline(16)))}_cancelCallback(e){clearTimeout(e)}_createDeadline(e){let t=performance.now()+e;return{timeRemaining:()=>Math.max(0,t-performance.now())}}},Ec=class extends ma{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},ns=!cs&&"requestIdleCallback"in window?Ec:kc,Rc=class{constructor(){this._queue=new ns}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},hr=class extends G{constructor(e,t,i,s,r,n,o,a,h){super(),this._rowCount=e,this._optionsService=i,this._charSizeService=s,this._coreService=r,this._coreBrowserService=a,this._renderer=this._register(new Yt),this._pausedResizeTask=new Rc,this._observerDisposable=this._register(new Yt),this._isPaused=!1,this._needsFullRefresh=!1,this._isNextRenderRedrawOnly=!0,this._needsSelectionRefresh=!1,this._canvasWidth=0,this._canvasHeight=0,this._selectionState={start:void 0,end:void 0,columnSelectMode:!1},this._onDimensionsChange=this._register(new k),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new k),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new k),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new k),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new yc((l,c)=>this._renderRows(l,c),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new Bc(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(oe(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(o.onResize(()=>this._fullRefresh())),this._register(o.buffers.onBufferActivate(()=>{var l;return(l=this._renderer.value)==null?void 0:l.clear()})),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._charSizeService.onCharSizeChange(()=>this.handleCharSizeChanged())),this._register(n.onDecorationRegistered(()=>this._fullRefresh())),this._register(n.onDecorationRemoved(()=>this._fullRefresh())),this._register(this._optionsService.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio","rescaleOverlappingGlyphs"],()=>{this.clear(),this.handleResize(o.cols,o.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange(["cursorBlink","cursorStyle"],()=>this.refreshRows(o.buffer.y,o.buffer.y,!0))),this._register(h.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,t),this._register(this._coreBrowserService.onWindowChange(l=>this._registerIntersectionObserver(l,t)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(e,t){if("IntersectionObserver"in e){let i=new e.IntersectionObserver(s=>this._handleIntersectionChange(s[s.length-1]),{threshold:0});i.observe(t),this._observerDisposable.value=oe(()=>i.disconnect())}}_handleIntersectionChange(e){this._isPaused=e.isIntersecting===void 0?e.intersectionRatio===0:!e.isIntersecting,!this._isPaused&&!this._charSizeService.hasValidSize&&this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(e,t,i=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}let s=this._syncOutputHandler.flush();s&&(e=Math.min(e,s.start),t=Math.max(t,s.end)),i||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(e,t,this._rowCount)}_renderRows(e,t){if(this._renderer.value){if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}e=Math.min(e,this._rowCount-1),t=Math.min(t,this._rowCount-1),this._renderer.value.renderRows(e,t),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),this._needsSelectionRefresh=!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:e,end:t}),this._onRender.fire({start:e,end:t}),this._isNextRenderRedrawOnly=!0}}resize(e,t){this._rowCount=t,this._fireOnCanvasResize()}_handleOptionsChanged(){this._renderer.value&&(this.refreshRows(0,this._rowCount-1),this._fireOnCanvasResize())}_fireOnCanvasResize(){this._renderer.value&&(this._renderer.value.dimensions.css.canvas.width===this._canvasWidth&&this._renderer.value.dimensions.css.canvas.height===this._canvasHeight||this._onDimensionsChange.fire(this._renderer.value.dimensions))}hasRenderer(){return!!this._renderer.value}setRenderer(e){this._renderer.value=e,this._renderer.value&&(this._renderer.value.onRequestRedraw(t=>this.refreshRows(t.start,t.end,!0)),this._needsSelectionRefresh=!0,this._fullRefresh())}addRefreshCallback(e){return this._renderDebouncer.addRefreshCallback(e)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){var e,t;this._renderer.value&&((t=(e=this._renderer.value).clearTextureAtlas)==null||t.call(e),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(e,t){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set(()=>{var i;return(i=this._renderer.value)==null?void 0:i.handleResize(e,t)}):this._renderer.value.handleResize(e,t),this._fullRefresh())}handleCharSizeChanged(){var e;(e=this._renderer.value)==null||e.handleCharSizeChanged()}handleBlur(){var e;(e=this._renderer.value)==null||e.handleBlur()}handleFocus(){var e;(e=this._renderer.value)==null||e.handleFocus()}handleSelectionChanged(e,t,i){var s;this._selectionState.start=e,this._selectionState.end=t,this._selectionState.columnSelectMode=i,(s=this._renderer.value)==null||s.handleSelectionChanged(e,t,i)}handleCursorMove(){var e;(e=this._renderer.value)==null||e.handleCursorMove()}clear(){var e;(e=this._renderer.value)==null||e.clear()}};hr=_e([T(2,Oe),T(3,hs),T(4,Nt),T(5,xi),T(6,Ie),T(7,ft),T(8,Jt)],hr);var Bc=class{constructor(e,t,i){this._coreBrowserService=e,this._coreService=t,this._onTimeout=i,this._start=0,this._end=0,this._isBuffering=!1}bufferRows(e,t){this._isBuffering?(this._start=Math.min(this._start,e),this._end=Math.max(this._end,t)):(this._start=e,this._end=t,this._isBuffering=!0),this._timeout===void 0&&(this._timeout=this._coreBrowserService.window.setTimeout(()=>{this._timeout=void 0,this._coreService.decPrivateModes.synchronizedOutput=!1,this._onTimeout()},1e3))}flush(){if(this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0),!this._isBuffering)return;let e={start:this._start,end:this._end};return this._isBuffering=!1,e}dispose(){this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0)}};function Mc(e,t,i,s){let r=i.buffer.x,n=i.buffer.y;if(!i.buffer.hasScrollback)return Tc(r,n,e,t,i,s)+ds(n,t,i,s)+$c(r,n,e,t,i,s);let o;if(n===t)return o=r>e?"D":"C",yi(Math.abs(r-e),Si(o,s));o=n>t?"D":"C";let a=Math.abs(n-t),h=Lc(n>t?e:r,i)+(a-1)*i.cols+1+Dc(n>t?r:e);return yi(h,Si(o,s))}function Dc(e,t){return e-1}function Lc(e,t){return t.cols-e}function Tc(e,t,i,s,r,n){return ds(t,s,r,n).length===0?"":yi(va(e,t,e,t-Pt(t,r),!1,r).length,Si("D",n))}function ds(e,t,i,s){let r=e-Pt(e,i),n=t-Pt(t,i),o=Math.abs(r-n)-Ac(e,t,i);return yi(o,Si(ga(e,t),s))}function $c(e,t,i,s,r,n){let o;ds(t,s,r,n).length>0?o=s-Pt(s,r):o=t;let a=s,h=Pc(e,t,i,s,r,n);return yi(va(e,o,i,a,h==="C",r).length,Si(h,n))}function Ac(e,t,i){var o;let s=0,r=e-Pt(e,i),n=t-Pt(t,i);for(let a=0;a=0&&e0?o=s-Pt(s,r):o=t,e=i&&ot?"A":"B"}function va(e,t,i,s,r,n){let o=e,a=t,h="";for(;(o!==i||a!==s)&&a>=0&&an.cols-1?(h+=n.buffer.translateBufferLineToString(a,!1,e,o),o=0,e=0,a++):!r&&o<0&&(h+=n.buffer.translateBufferLineToString(a,!1,0,e+1),o=n.cols-1,e=o,a--);return h+n.buffer.translateBufferLineToString(a,!1,e,o)}function Si(e,t){let i=t?"O":"[";return v.ESC+i+e}function yi(e,t){e=Math.floor(e);let i="";for(let s=0;sthis._bufferService.cols?e%this._bufferService.cols===0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)-1]:[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[e,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[Math.max(e,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){let e=this.selectionStart,t=this.selectionEnd;return!e||!t?!1:e[1]>t[1]||e[1]===t[1]&&e[0]>t[0]}handleTrim(e){return this.selectionStart&&(this.selectionStart[1]-=e),this.selectionEnd&&(this.selectionEnd[1]-=e),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}};function mn(e,t){if(e.start.y>e.end.y)throw new Error(`Buffer range end (${e.end.x}, ${e.end.y}) cannot be before start (${e.start.x}, ${e.start.y})`);return t*(e.end.y-e.start.y)+(e.end.x-e.start.x+1)}var ys=50,Ic=15,Oc=50,Fc=500,Hc=" ",Wc=new RegExp(Hc,"g"),cr=class extends G{constructor(e,t,i,s,r,n,o,a,h){super(),this._element=e,this._screenElement=t,this._linkifier=i,this._bufferService=s,this._coreService=r,this._mouseService=n,this._optionsService=o,this._renderService=a,this._coreBrowserService=h,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new Je,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new k),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new k),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new k),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new k),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=l=>this._handleMouseMove(l),this._mouseUpListener=l=>this._handleMouseUp(l),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(l=>this._handleTrim(l)),this._register(this._bufferService.buffers.onBufferActivate(l=>this._handleBufferActivate(l))),this.enable(),this._model=new Nc(this._bufferService),this._activeSelectionMode=0,this._register(oe(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(l=>{l.rowsChanged&&this.clearSelection()}))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;return!e||!t?!1:e[0]!==t[0]||e[1]!==t[1]}get selectionText(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;if(!e||!t)return"";let i=this._bufferService.buffer,s=[];if(this._activeSelectionMode===3){if(e[0]===t[0])return"";let r=e[0]r.replace(Wc," ")).join(fa?`\r +`,e.VT="\v",e.FF="\f",e.CR="\r",e.SO="",e.SI="",e.DLE="",e.DC1="",e.DC2="",e.DC3="",e.DC4="",e.NAK="",e.SYN="",e.ETB="",e.CAN="",e.EM="",e.SUB="",e.ESC="\x1B",e.FS="",e.GS="",e.RS="",e.US="",e.SP=" ",e.DEL=""))(v||(v={}));var ji;(e=>(e.PAD="€",e.HOP="",e.BPH="‚",e.NBH="ƒ",e.IND="„",e.NEL="…",e.SSA="†",e.ESA="‡",e.HTS="ˆ",e.HTJ="‰",e.VTS="Š",e.PLD="‹",e.PLU="Œ",e.RI="",e.SS2="Ž",e.SS3="",e.DCS="",e.PU1="‘",e.PU2="’",e.STS="“",e.CCH="”",e.MW="•",e.SPA="–",e.EPA="—",e.SOS="˜",e.SGCI="™",e.SCI="š",e.CSI="›",e.ST="œ",e.OSC="",e.PM="ž",e.APC="Ÿ"))(ji||(ji={}));var ha;(e=>e.ST=`${v.ESC}\\`)(ha||(ha={}));var rr=class{constructor(e,t,i,s,r,n){this._textarea=e,this._compositionView=t,this._bufferService=i,this._optionsService=s,this._coreService=r,this._renderService=n,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=""}get isComposing(){return this._isComposing}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent="",this._dataAlreadySent="",this._compositionView.classList.add("active")}compositionupdate(e){this._compositionView.textContent=e.data,this.updateCompositionElements(),setTimeout(()=>{this._compositionPosition.end=this._textarea.value.length},0)}compositionend(){this._finalizeComposition(!0)}keydown(e){if(this._isComposing||this._isSendingComposition){if(e.keyCode===20||e.keyCode===229||e.keyCode===16||e.keyCode===17||e.keyCode===18)return!1;this._finalizeComposition(!1)}return e.keyCode===229?(this._handleAnyTextareaChanges(),!1):!0}_finalizeComposition(e){if(this._compositionView.classList.remove("active"),this._isComposing=!1,e){let t={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout(()=>{if(this._isSendingComposition){this._isSendingComposition=!1;let i;t.start+=this._dataAlreadySent.length,this._isComposing?i=this._textarea.value.substring(t.start,this._compositionPosition.start):i=this._textarea.value.substring(t.start),i.length>0&&this._coreService.triggerDataEvent(i,!0)}},0)}else{this._isSendingComposition=!1;let t=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(t,!0)}}_handleAnyTextareaChanges(){let e=this._textarea.value;setTimeout(()=>{if(!this._isComposing){let t=this._textarea.value,i=t.replace(e,"");this._dataAlreadySent=i,t.length>e.length?this._coreService.triggerDataEvent(i,!0):t.lengththis.updateCompositionElements(!0),0)}}};rr=_e([T(2,Ie),T(3,Oe),T(4,Nt),T(5,pt)],rr);var Ee=0,Re=0,Be=0,ue=0,_n={css:"#00000000",rgba:0},ve;(e=>{function t(r,n,o,a){return a!==void 0?`#${Mt(r)}${Mt(n)}${Mt(o)}${Mt(a)}`:`#${Mt(r)}${Mt(n)}${Mt(o)}`}e.toCss=t;function i(r,n,o,a=255){return(r<<24|n<<16|o<<8|a)>>>0}e.toRgba=i;function s(r,n,o,a){return{css:e.toCss(r,n,o,a),rgba:e.toRgba(r,n,o,a)}}e.toColor=s})(ve||(ve={}));var re;(e=>{function t(h,l){if(ue=(l.rgba&255)/255,ue===1)return{css:l.css,rgba:l.rgba};let c=l.rgba>>24&255,d=l.rgba>>16&255,u=l.rgba>>8&255,f=h.rgba>>24&255,_=h.rgba>>16&255,p=h.rgba>>8&255;Ee=f+Math.round((c-f)*ue),Re=_+Math.round((d-_)*ue),Be=p+Math.round((u-p)*ue);let g=ve.toCss(Ee,Re,Be),E=ve.toRgba(Ee,Re,Be);return{css:g,rgba:E}}e.blend=t;function i(h){return(h.rgba&255)===255}e.isOpaque=i;function s(h,l,c){let d=Ki.ensureContrastRatio(h.rgba,l.rgba,c);if(d)return ve.toColor(d>>24&255,d>>16&255,d>>8&255)}e.ensureContrastRatio=s;function r(h){let l=(h.rgba|255)>>>0;return[Ee,Re,Be]=Ki.toChannels(l),{css:ve.toCss(Ee,Re,Be),rgba:l}}e.opaque=r;function n(h,l){return ue=Math.round(l*255),[Ee,Re,Be]=Ki.toChannels(h.rgba),{css:ve.toCss(Ee,Re,Be,ue),rgba:ve.toRgba(Ee,Re,Be,ue)}}e.opacity=n;function o(h,l){return ue=h.rgba&255,n(h,ue*l/255)}e.multiplyOpacity=o;function a(h){return[h.rgba>>24&255,h.rgba>>16&255,h.rgba>>8&255]}e.toColorRGB=a})(re||(re={}));var ce;(e=>{let t,i;try{let r=document.createElement("canvas");r.width=1,r.height=1;let n=r.getContext("2d",{willReadFrequently:!0});n&&(t=n,t.globalCompositeOperation="copy",i=t.createLinearGradient(0,0,1,1))}catch{}function s(r){if(r.match(/#[\da-f]{3,8}/i))switch(r.length){case 4:return Ee=parseInt(r.slice(1,2).repeat(2),16),Re=parseInt(r.slice(2,3).repeat(2),16),Be=parseInt(r.slice(3,4).repeat(2),16),ve.toColor(Ee,Re,Be);case 5:return Ee=parseInt(r.slice(1,2).repeat(2),16),Re=parseInt(r.slice(2,3).repeat(2),16),Be=parseInt(r.slice(3,4).repeat(2),16),ue=parseInt(r.slice(4,5).repeat(2),16),ve.toColor(Ee,Re,Be,ue);case 7:return{css:r,rgba:(parseInt(r.slice(1),16)<<8|255)>>>0};case 9:return{css:r,rgba:parseInt(r.slice(1),16)>>>0}}let n=r.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(n)return Ee=parseInt(n[1]),Re=parseInt(n[2]),Be=parseInt(n[3]),ue=Math.round((n[5]===void 0?1:parseFloat(n[5]))*255),ve.toColor(Ee,Re,Be,ue);if(!t||!i)throw new Error("css.toColor: Unsupported css format");if(t.fillStyle=i,t.fillStyle=r,typeof t.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(t.fillRect(0,0,1,1),[Ee,Re,Be,ue]=t.getImageData(0,0,1,1).data,ue!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:ve.toRgba(Ee,Re,Be,ue),css:r}}e.toColor=s})(ce||(ce={}));var Pe;(e=>{function t(s){return i(s>>16&255,s>>8&255,s&255)}e.relativeLuminance=t;function i(s,r,n){let o=s/255,a=r/255,h=n/255,l=o<=.03928?o/12.92:Math.pow((o+.055)/1.055,2.4),c=a<=.03928?a/12.92:Math.pow((a+.055)/1.055,2.4),d=h<=.03928?h/12.92:Math.pow((h+.055)/1.055,2.4);return l*.2126+c*.7152+d*.0722}e.relativeLuminance2=i})(Pe||(Pe={}));var Ki;(e=>{function t(o,a){if(ue=(a&255)/255,ue===1)return a;let h=a>>24&255,l=a>>16&255,c=a>>8&255,d=o>>24&255,u=o>>16&255,f=o>>8&255;return Ee=d+Math.round((h-d)*ue),Re=u+Math.round((l-u)*ue),Be=f+Math.round((c-f)*ue),ve.toRgba(Ee,Re,Be)}e.blend=t;function i(o,a,h){let l=Pe.relativeLuminance(o>>8),c=Pe.relativeLuminance(a>>8);if(ut(l,c)>8));if(_>8));return _>g?f:p}return f}let d=r(o,a,h),u=ut(l,Pe.relativeLuminance(d>>8));if(u>8));return u>_?d:f}return d}}e.ensureContrastRatio=i;function s(o,a,h){let l=o>>24&255,c=o>>16&255,d=o>>8&255,u=a>>24&255,f=a>>16&255,_=a>>8&255,p=ut(Pe.relativeLuminance2(u,f,_),Pe.relativeLuminance2(l,c,d));for(;p0||f>0||_>0);)u-=Math.max(0,Math.ceil(u*.1)),f-=Math.max(0,Math.ceil(f*.1)),_-=Math.max(0,Math.ceil(_*.1)),p=ut(Pe.relativeLuminance2(u,f,_),Pe.relativeLuminance2(l,c,d));return(u<<24|f<<16|_<<8|255)>>>0}e.reduceLuminance=s;function r(o,a,h){let l=o>>24&255,c=o>>16&255,d=o>>8&255,u=a>>24&255,f=a>>16&255,_=a>>8&255,p=ut(Pe.relativeLuminance2(u,f,_),Pe.relativeLuminance2(l,c,d));for(;p>>0}e.increaseLuminance=r;function n(o){return[o>>24&255,o>>16&255,o>>8&255,o&255]}e.toChannels=n})(Ki||(Ki={}));function Mt(e){let t=e.toString(16);return t.length<2?"0"+t:t}function ut(e,t){return e1){let c=this._getJoinedRanges(s,o,n,t,r);for(let d=0;d1){let l=this._getJoinedRanges(s,o,n,t,r);for(let c=0;c=He,H=S,B=this._workCell;if(u.length>0&&S===u[0][0]&&A){let I=u.shift(),ie=this._isCellInSelection(I[0],t);for(z=I[0]+1;z=I[1]),A?(x=!0,B=new nc(this._workCell,e.translateToString(!0,I[0],I[1]),I[1]-I[0]),H=I[1]-1,L=B.getWidth()):He=I[1]}let X=this._isCellInSelection(S,t),te=i&&S===n,Fe=N&&S>=l&&S<=c,Qe=!1;this._decorationService.forEachDecorationAtCell(S,t,void 0,I=>{Qe=!0});let le=B.getChars()||Ct;if(le===" "&&(B.isUnderline()||B.isOverline())&&(le=" "),J=L*a-h.get(le,B.isBold(),B.isItalic()),!p)p=this._document.createElement("span");else if(g&&(X&&ne||!X&&!ne&&B.bg===O)&&(X&&ne&&f.selectionForeground||B.fg===M)&&B.extended.ext===$&&Fe===K&&J===ae&&!te&&!x&&!Qe&&A){B.isInvisible()?E+=Ct:E+=le,g++;continue}else g&&(p.textContent=E),p=this._document.createElement("span"),g=0,E="";if(O=B.bg,M=B.fg,$=B.extended.ext,K=Fe,ae=J,ne=X,x&&n>=S&&n<=H&&(n=S),!this._coreService.isCursorHidden&&te&&this._coreService.isCursorInitialized){if(Y.push("xterm-cursor"),this._coreBrowserService.isFocused)o&&Y.push("xterm-cursor-blink"),Y.push(s==="bar"?"xterm-cursor-bar":s==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(r)switch(r){case"outline":Y.push("xterm-cursor-outline");break;case"block":Y.push("xterm-cursor-block");break;case"bar":Y.push("xterm-cursor-bar");break;case"underline":Y.push("xterm-cursor-underline");break}}if(B.isBold()&&Y.push("xterm-bold"),B.isItalic()&&Y.push("xterm-italic"),B.isDim()&&Y.push("xterm-dim"),B.isInvisible()?E=Ct:E=B.getChars()||Ct,B.isUnderline()&&(Y.push(`xterm-underline-${B.extended.underlineStyle}`),E===" "&&(E=" "),!B.isUnderlineColorDefault()))if(B.isUnderlineColorRGB())p.style.textDecorationColor=`rgb(${Ci.toColorRGB(B.getUnderlineColor()).join(",")})`;else{let I=B.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&B.isBold()&&I<8&&(I+=8),p.style.textDecorationColor=f.ansi[I].css}B.isOverline()&&(Y.push("xterm-overline"),E===" "&&(E=" ")),B.isStrikethrough()&&Y.push("xterm-strikethrough"),Fe&&(p.style.textDecoration="underline");let Te=B.getFgColor(),Ve=B.getFgColorMode(),We=B.getBgColor(),dt=B.getBgColorMode(),Qt=!!B.isInverse();if(Qt){let I=Te;Te=We,We=I;let ie=Ve;Ve=dt,dt=ie}let C,P,F=!1;this._decorationService.forEachDecorationAtCell(S,t,void 0,I=>{I.options.layer!=="top"&&F||(I.backgroundColorRGB&&(dt=50331648,We=I.backgroundColorRGB.rgba>>8&16777215,C=I.backgroundColorRGB),I.foregroundColorRGB&&(Ve=50331648,Te=I.foregroundColorRGB.rgba>>8&16777215,P=I.foregroundColorRGB),F=I.options.layer==="top")}),!F&&X&&(C=this._coreBrowserService.isFocused?f.selectionBackgroundOpaque:f.selectionInactiveBackgroundOpaque,We=C.rgba>>8&16777215,dt=50331648,F=!0,f.selectionForeground&&(Ve=50331648,Te=f.selectionForeground.rgba>>8&16777215,P=f.selectionForeground)),F&&Y.push("xterm-decoration-top");let q;switch(dt){case 16777216:case 33554432:q=f.ansi[We],Y.push(`xterm-bg-${We}`);break;case 50331648:q=ve.toColor(We>>16,We>>8&255,We&255),this._addStyle(p,`background-color:#${fn((We>>>0).toString(16),"0",6)}`);break;case 0:default:Qt?(q=f.foreground,Y.push("xterm-bg-257")):q=f.background}switch(C||B.isDim()&&(C=re.multiplyOpacity(q,.5)),Ve){case 16777216:case 33554432:B.isBold()&&Te<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(Te+=8),this._applyMinimumContrast(p,q,f.ansi[Te],B,C,void 0)||Y.push(`xterm-fg-${Te}`);break;case 50331648:let I=ve.toColor(Te>>16&255,Te>>8&255,Te&255);this._applyMinimumContrast(p,q,I,B,C,P)||this._addStyle(p,`color:#${fn(Te.toString(16),"0",6)}`);break;case 0:default:this._applyMinimumContrast(p,q,f.foreground,B,C,P)||Qt&&Y.push("xterm-fg-257")}Y.length&&(p.className=Y.join(" "),Y.length=0),!te&&!x&&!Qe&&A?g++:p.textContent=E,J!==this.defaultSpacing&&(p.style.letterSpacing=`${J}px`),d.push(p),S=H}return p&&g&&(p.textContent=E),d}_applyMinimumContrast(e,t,i,s,r,n){if(this._optionsService.rawOptions.minimumContrastRatio===1||lc(s.getCode()))return!1;let o=this._getContrastCache(s),a;if(!r&&!n&&(a=o.getColor(t.rgba,i.rgba)),a===void 0){let h=this._optionsService.rawOptions.minimumContrastRatio/(s.isDim()?2:1);a=re.ensureContrastRatio(r||t,n||i,h),o.setColor((r||t).rgba,(n||i).rgba,a??null)}return a?(this._addStyle(e,`color:${a.css}`),!0):!1}_getContrastCache(e){return e.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(e,t){e.setAttribute("style",`${e.getAttribute("style")||""}${t};`)}_isCellInSelection(e,t){let i=this._selectionStart,s=this._selectionEnd;return!i||!s?!1:this._columnSelectMode?i[0]<=s[0]?e>=i[0]&&t>=i[1]&&e=i[1]&&e>=s[0]&&t<=s[1]:t>i[1]&&t=i[0]&&e=i[0]}};nr=_e([T(1,Ko),T(2,Oe),T(3,ft),T(4,Nt),T(5,xi),T(6,Jt)],nr);function fn(e,t,i){for(;e.length0&&(this._flat[s]=o),o}let r=e;t&&(r+="B"),i&&(r+="I");let n=this._holey.get(r);if(n===void 0){let o=0;t&&(o|=1),i&&(o|=2),n=this._measure(e,o),n>0&&this._holey.set(r,n)}return n}_measure(e,t){let i=this._measureElements[t];return i.textContent=e.repeat(32),i.offsetWidth/32}},dc=class{constructor(){this.clear()}clear(){this.hasSelection=!1,this.columnSelectMode=!1,this.viewportStartRow=0,this.viewportEndRow=0,this.viewportCappedStartRow=0,this.viewportCappedEndRow=0,this.startCol=0,this.endCol=0,this.selectionStart=void 0,this.selectionEnd=void 0}update(e,t,i,s=!1){if(this.selectionStart=t,this.selectionEnd=i,!t||!i||t[0]===i[0]&&t[1]===i[1]){this.clear();return}let r=e.buffers.active.ydisp,n=t[1]-r,o=i[1]-r,a=Math.max(n,0),h=Math.min(o,e.rows-1);if(a>=e.rows||h<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=s,this.viewportStartRow=n,this.viewportEndRow=o,this.viewportCappedStartRow=a,this.viewportCappedEndRow=h,this.startCol=t[0],this.endCol=i[0]}isCellSelected(e,t,i){return this.hasSelection?(i-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?t>=this.startCol&&i>=this.viewportCappedStartRow&&t=this.viewportCappedStartRow&&t>=this.endCol&&i<=this.viewportCappedEndRow:i>this.viewportStartRow&&i=this.startCol&&t=this.startCol):!1}};function uc(){return new dc}var Ss="xterm-dom-renderer-owner-",Ge="xterm-rows",Ni="xterm-fg-",pn="xterm-bg-",ri="xterm-focus",Ii="xterm-selection",_c=1,or=class extends G{constructor(e,t,i,s,r,n,o,a,h,l,c,d,u,f){super(),this._terminal=e,this._document=t,this._element=i,this._screenElement=s,this._viewportElement=r,this._helperContainer=n,this._linkifier2=o,this._charSizeService=h,this._optionsService=l,this._bufferService=c,this._coreService=d,this._coreBrowserService=u,this._themeService=f,this._terminalClass=_c++,this._rowElements=[],this._selectionRenderModel=uc(),this.onRequestRedraw=this._register(new k).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(Ge),this._rowContainer.style.lineHeight="normal",this._rowContainer.setAttribute("aria-hidden","true"),this._refreshRowElements(this._bufferService.cols,this._bufferService.rows),this._selectionContainer=this._document.createElement("div"),this._selectionContainer.classList.add(Ii),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=hc(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(_=>this._injectCss(_))),this._injectCss(this._themeService.colors),this._rowFactory=a.createInstance(nr,document),this._element.classList.add(Ss+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(_=>this._handleLinkHover(_))),this._register(this._linkifier2.onHideLinkUnderline(_=>this._handleLinkLeave(_))),this._register(oe(()=>{this._element.classList.remove(Ss+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new cc(this._document,this._helperContainer),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}_updateDimensions(){let e=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*e,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*e),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.left=0,this.dimensions.device.char.top=0,this.dimensions.device.canvas.width=this.dimensions.device.cell.width*this._bufferService.cols,this.dimensions.device.canvas.height=this.dimensions.device.cell.height*this._bufferService.rows,this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/e),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/e),this.dimensions.css.cell.width=this.dimensions.css.canvas.width/this._bufferService.cols,this.dimensions.css.cell.height=this.dimensions.css.canvas.height/this._bufferService.rows;for(let i of this._rowElements)i.style.width=`${this.dimensions.css.canvas.width}px`,i.style.height=`${this.dimensions.css.cell.height}px`,i.style.lineHeight=`${this.dimensions.css.cell.height}px`,i.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));let t=`${this._terminalSelector} .${Ge} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=t,this._selectionContainer.style.height=this._viewportElement.style.height,this._screenElement.style.width=`${this.dimensions.css.canvas.width}px`,this._screenElement.style.height=`${this.dimensions.css.canvas.height}px`}_injectCss(e){this._themeStyleElement||(this._themeStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._themeStyleElement));let t=`${this._terminalSelector} .${Ge} { pointer-events: none; color: ${e.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;t+=`${this._terminalSelector} .${Ge} .xterm-dim { color: ${re.multiplyOpacity(e.foreground,.5).css};}`,t+=`${this._terminalSelector} span:not(.xterm-bold) { font-weight: ${this._optionsService.rawOptions.fontWeight};}${this._terminalSelector} span.xterm-bold { font-weight: ${this._optionsService.rawOptions.fontWeightBold};}${this._terminalSelector} span.xterm-italic { font-style: italic;}`;let i=`blink_underline_${this._terminalClass}`,s=`blink_bar_${this._terminalClass}`,r=`blink_block_${this._terminalClass}`;t+=`@keyframes ${i} { 50% { border-bottom-style: hidden; }}`,t+=`@keyframes ${s} { 50% { box-shadow: none; }}`,t+=`@keyframes ${r} { 0% { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css}; } 50% { background-color: inherit; color: ${e.cursor.css}; }}`,t+=`${this._terminalSelector} .${Ge}.${ri} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${i} 1s step-end infinite;}${this._terminalSelector} .${Ge}.${ri} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${Ge}.${ri} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${r} 1s step-end infinite;}${this._terminalSelector} .${Ge} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${Ge} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${Ge} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${Ge} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${Ge} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${Ii} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${Ii} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${Ii} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[n,o]of e.ansi.entries())t+=`${this._terminalSelector} .${Ni}${n} { color: ${o.css}; }${this._terminalSelector} .${Ni}${n}.xterm-dim { color: ${re.multiplyOpacity(o,.5).css}; }${this._terminalSelector} .${pn}${n} { background-color: ${o.css}; }`;t+=`${this._terminalSelector} .${Ni}257 { color: ${re.opaque(e.background).css}; }${this._terminalSelector} .${Ni}257.xterm-dim { color: ${re.multiplyOpacity(re.opaque(e.background),.5).css}; }${this._terminalSelector} .${pn}257 { background-color: ${e.foreground.css}; }`,this._themeStyleElement.textContent=t}_setDefaultSpacing(){let e=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${e}px`,this._rowFactory.defaultSpacing=e}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(e,t){for(let i=this._rowElements.length;i<=t;i++){let s=this._document.createElement("div");this._rowContainer.appendChild(s),this._rowElements.push(s)}for(;this._rowElements.length>t;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(e,t){this._refreshRowElements(e,t),this._updateDimensions(),this.handleSelectionChanged(this._selectionRenderModel.selectionStart,this._selectionRenderModel.selectionEnd,this._selectionRenderModel.columnSelectMode)}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(ri),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(ri),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,t,i){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,t,i),this.renderRows(0,this._bufferService.rows-1),!e||!t||(this._selectionRenderModel.update(this._terminal,e,t,i),!this._selectionRenderModel.hasSelection))return;let s=this._selectionRenderModel.viewportStartRow,r=this._selectionRenderModel.viewportEndRow,n=this._selectionRenderModel.viewportCappedStartRow,o=this._selectionRenderModel.viewportCappedEndRow,a=this._document.createDocumentFragment();if(i){let h=e[0]>t[0];a.appendChild(this._createSelectionElement(n,h?t[0]:e[0],h?e[0]:t[0],o-n+1))}else{let h=s===n?e[0]:0,l=n===r?t[0]:this._bufferService.cols;a.appendChild(this._createSelectionElement(n,h,l));let c=o-n-1;if(a.appendChild(this._createSelectionElement(n+1,0,this._bufferService.cols,c)),n!==o){let d=r===o?t[0]:this._bufferService.cols;a.appendChild(this._createSelectionElement(o,0,d))}}this._selectionContainer.appendChild(a)}_createSelectionElement(e,t,i,s=1){let r=this._document.createElement("div"),n=t*this.dimensions.css.cell.width,o=this.dimensions.css.cell.width*(i-t);return n+o>this.dimensions.css.canvas.width&&(o=this.dimensions.css.canvas.width-n),r.style.height=`${s*this.dimensions.css.cell.height}px`,r.style.top=`${e*this.dimensions.css.cell.height}px`,r.style.left=`${n}px`,r.style.width=`${o}px`,r}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(let e of this._rowElements)e.replaceChildren()}renderRows(e,t){let i=this._bufferService.buffer,s=i.ybase+i.y,r=Math.min(i.x,this._bufferService.cols-1),n=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,o=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,a=this._optionsService.rawOptions.cursorInactiveStyle;for(let h=e;h<=t;h++){let l=h+i.ydisp,c=this._rowElements[h],d=i.lines.get(l);if(!c||!d)break;c.replaceChildren(...this._rowFactory.createRow(d,l,l===s,o,a,r,n,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${Ss}${this._terminalClass}`}_handleLinkHover(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!0)}_handleLinkLeave(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!1)}_setCellUnderline(e,t,i,s,r,n){i<0&&(e=0),s<0&&(t=0);let o=this._bufferService.rows-1;i=Math.max(Math.min(i,o),0),s=Math.max(Math.min(s,o),0),r=Math.min(r,this._bufferService.cols);let a=this._bufferService.buffer,h=a.ybase+a.y,l=Math.min(a.x,r-1),c=this._optionsService.rawOptions.cursorBlink,d=this._optionsService.rawOptions.cursorStyle,u=this._optionsService.rawOptions.cursorInactiveStyle;for(let f=i;f<=s;++f){let _=f+a.ydisp,p=this._rowElements[f],g=a.lines.get(_);if(!p||!g)break;p.replaceChildren(...this._rowFactory.createRow(g,_,_===h,d,u,l,c,this.dimensions.css.cell.width,this._widthCache,n?f===i?e:0:-1,n?(f===s?t:r)-1:-1))}}};or=_e([T(7,Er),T(8,hs),T(9,Oe),T(10,Ie),T(11,Nt),T(12,ft),T(13,Jt)],or);var ar=class extends G{constructor(e,t,i){super(),this._optionsService=i,this.width=0,this.height=0,this._onCharSizeChange=this._register(new k),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new pc(this._optionsService))}catch{this._measureStrategy=this._register(new fc(e,t,this._optionsService))}this._register(this._optionsService.onMultipleOptionChange(["fontFamily","fontSize"],()=>this.measure()))}get hasValidSize(){return this.width>0&&this.height>0}measure(){let e=this._measureStrategy.measure();(e.width!==this.width||e.height!==this.height)&&(this.width=e.width,this.height=e.height,this._onCharSizeChange.fire())}};ar=_e([T(2,Oe)],ar);var ca=class extends G{constructor(){super(...arguments),this._result={width:0,height:0}}_validateAndSet(e,t){e!==void 0&&e>0&&t!==void 0&&t>0&&(this._result.width=e,this._result.height=t)}},fc=class extends ca{constructor(e,t,i){super(),this._document=e,this._parentElement=t,this._optionsService=i,this._measureElement=this._document.createElement("span"),this._measureElement.classList.add("xterm-char-measure-element"),this._measureElement.textContent="W".repeat(32),this._measureElement.setAttribute("aria-hidden","true"),this._measureElement.style.whiteSpace="pre",this._measureElement.style.fontKerning="none",this._parentElement.appendChild(this._measureElement)}measure(){return this._measureElement.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._measureElement.style.fontSize=`${this._optionsService.rawOptions.fontSize}px`,this._validateAndSet(Number(this._measureElement.offsetWidth)/32,Number(this._measureElement.offsetHeight)),this._result}},pc=class extends ca{constructor(e){super(),this._optionsService=e,this._canvas=new OffscreenCanvas(100,100),this._ctx=this._canvas.getContext("2d");let t=this._ctx.measureText("W");if(!("width"in t&&"fontBoundingBoxAscent"in t&&"fontBoundingBoxDescent"in t))throw new Error("Required font metrics not supported")}measure(){this._ctx.font=`${this._optionsService.rawOptions.fontSize}px ${this._optionsService.rawOptions.fontFamily}`;let e=this._ctx.measureText("W");return this._validateAndSet(e.width,e.fontBoundingBoxAscent+e.fontBoundingBoxDescent),this._result}},mc=class extends G{constructor(e,t,i){super(),this._textarea=e,this._window=t,this.mainDocument=i,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new gc(this._window)),this._onDprChange=this._register(new k),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new k),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(s=>this._screenDprMonitor.setWindow(s))),this._register(Le.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(j(this._textarea,"focus",()=>this._isFocused=!0)),this._register(j(this._textarea,"blur",()=>this._isFocused=!1))}get window(){return this._window}set window(e){this._window!==e&&(this._window=e,this._onWindowChange.fire(this._window))}get dpr(){return this.window.devicePixelRatio}get isFocused(){return this._cachedIsFocused===void 0&&(this._cachedIsFocused=this._isFocused&&this._textarea.ownerDocument.hasFocus(),queueMicrotask(()=>this._cachedIsFocused=void 0)),this._cachedIsFocused}},gc=class extends G{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new Yt),this._onDprChange=this._register(new k),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(oe(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=j(this._parentWindow,"resize",()=>this._setDprAndFireIfDiffers())}_setDprAndFireIfDiffers(){this._parentWindow.devicePixelRatio!==this._currentDevicePixelRatio&&this._onDprChange.fire(this._parentWindow.devicePixelRatio),this._updateDpr()}_updateDpr(){var e;this._outerListener&&((e=this._resolutionMediaMatchList)==null||e.removeListener(this._outerListener),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._resolutionMediaMatchList=this._parentWindow.matchMedia(`screen and (resolution: ${this._parentWindow.devicePixelRatio}dppx)`),this._resolutionMediaMatchList.addListener(this._outerListener))}clearListener(){!this._resolutionMediaMatchList||!this._outerListener||(this._resolutionMediaMatchList.removeListener(this._outerListener),this._resolutionMediaMatchList=void 0,this._outerListener=void 0)}},vc=class extends G{constructor(){super(),this.linkProviders=[],this._register(oe(()=>this.linkProviders.length=0))}registerLinkProvider(e){return this.linkProviders.push(e),{dispose:()=>{let t=this.linkProviders.indexOf(e);t!==-1&&this.linkProviders.splice(t,1)}}}};function Ar(e,t,i){let s=i.getBoundingClientRect(),r=e.getComputedStyle(i),n=parseInt(r.getPropertyValue("padding-left")),o=parseInt(r.getPropertyValue("padding-top"));return[t.clientX-s.left-n,t.clientY-s.top-o]}function Sc(e,t,i,s,r,n,o,a,h){if(!n)return;let l=Ar(e,t,i);if(l)return l[0]=Math.ceil((l[0]+(h?o/2:0))/o),l[1]=Math.ceil(l[1]/a),l[0]=Math.min(Math.max(l[0],1),s+(h?1:0)),l[1]=Math.min(Math.max(l[1],1),r),l}var lr=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,i,s,r){return Sc(window,e,t,i,s,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,r)}getMouseReportCoords(e,t){let i=Ar(window,e,t);if(this._charSizeService.hasValidSize)return i[0]=Math.min(Math.max(i[0],0),this._renderService.dimensions.css.canvas.width-1),i[1]=Math.min(Math.max(i[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(i[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(i[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(i[0]),y:Math.floor(i[1])}}};lr=_e([T(0,pt),T(1,hs)],lr);var yc=class{constructor(e,t){this._renderCallback=e,this._coreBrowserService=t,this._refreshCallbacks=[]}dispose(){this._animationFrame&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}addRefreshCallback(e){return this._refreshCallbacks.push(e),this._animationFrame||(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh())),this._animationFrame}refresh(e,t,i){this._rowCount=i,e=e!==void 0?e:0,t=t!==void 0?t:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,e):e,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,t):t,!this._animationFrame&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh()))}_innerRefresh(){if(this._animationFrame=void 0,this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0){this._runRefreshCallbacks();return}let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(let e of this._refreshCallbacks)e(0);this._refreshCallbacks=[]}},da={};Dl(da,{getSafariVersion:()=>bc,isChromeOS:()=>pa,isFirefox:()=>ua,isIpad:()=>Cc,isIphone:()=>xc,isLegacyEdge:()=>wc,isLinux:()=>Pr,isMac:()=>rs,isNode:()=>cs,isSafari:()=>_a,isWindows:()=>fa});var cs=typeof process<"u"&&"title"in process,ki=cs?"node":navigator.userAgent,Ei=cs?"node":navigator.platform,ua=ki.includes("Firefox"),wc=ki.includes("Edge"),_a=/^((?!chrome|android).)*safari/i.test(ki);function bc(){if(!_a)return 0;let e=ki.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var rs=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(Ei),Cc=Ei==="iPad",xc=Ei==="iPhone",fa=["Windows","Win16","Win32","WinCE"].includes(Ei),Pr=Ei.indexOf("Linux")>=0,pa=/\bCrOS\b/.test(ki),ma=class{constructor(){this._tasks=[],this._i=0}enqueue(e){this._tasks.push(e),this._start()}flush(){for(;this._ir){s-t<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(s-t))}ms`),this._start();return}s=r}this.clear()}},kc=class extends ma{_requestCallback(e){return setTimeout(()=>e(this._createDeadline(16)))}_cancelCallback(e){clearTimeout(e)}_createDeadline(e){let t=performance.now()+e;return{timeRemaining:()=>Math.max(0,t-performance.now())}}},Ec=class extends ma{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},ns=!cs&&"requestIdleCallback"in window?Ec:kc,Rc=class{constructor(){this._queue=new ns}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},hr=class extends G{constructor(e,t,i,s,r,n,o,a,h){super(),this._rowCount=e,this._optionsService=i,this._charSizeService=s,this._coreService=r,this._coreBrowserService=a,this._renderer=this._register(new Yt),this._pausedResizeTask=new Rc,this._observerDisposable=this._register(new Yt),this._isPaused=!1,this._needsFullRefresh=!1,this._isNextRenderRedrawOnly=!0,this._needsSelectionRefresh=!1,this._canvasWidth=0,this._canvasHeight=0,this._selectionState={start:void 0,end:void 0,columnSelectMode:!1},this._onDimensionsChange=this._register(new k),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new k),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new k),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new k),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new yc((l,c)=>this._renderRows(l,c),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new Bc(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(oe(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(o.onResize(()=>this._fullRefresh())),this._register(o.buffers.onBufferActivate(()=>{var l;return(l=this._renderer.value)==null?void 0:l.clear()})),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._charSizeService.onCharSizeChange(()=>this.handleCharSizeChanged())),this._register(n.onDecorationRegistered(()=>this._fullRefresh())),this._register(n.onDecorationRemoved(()=>this._fullRefresh())),this._register(this._optionsService.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio","rescaleOverlappingGlyphs"],()=>{this.clear(),this.handleResize(o.cols,o.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange(["cursorBlink","cursorStyle"],()=>this.refreshRows(o.buffer.y,o.buffer.y,!0))),this._register(h.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,t),this._register(this._coreBrowserService.onWindowChange(l=>this._registerIntersectionObserver(l,t)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(e,t){if("IntersectionObserver"in e){let i=new e.IntersectionObserver(s=>this._handleIntersectionChange(s[s.length-1]),{threshold:0});i.observe(t),this._observerDisposable.value=oe(()=>i.disconnect())}}_handleIntersectionChange(e){this._isPaused=e.isIntersecting===void 0?e.intersectionRatio===0:!e.isIntersecting,!this._isPaused&&!this._charSizeService.hasValidSize&&this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(e,t,i=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}let s=this._syncOutputHandler.flush();s&&(e=Math.min(e,s.start),t=Math.max(t,s.end)),i||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(e,t,this._rowCount)}_renderRows(e,t){if(this._renderer.value){if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}e=Math.min(e,this._rowCount-1),t=Math.min(t,this._rowCount-1),this._renderer.value.renderRows(e,t),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),this._needsSelectionRefresh=!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:e,end:t}),this._onRender.fire({start:e,end:t}),this._isNextRenderRedrawOnly=!0}}resize(e,t){this._rowCount=t,this._fireOnCanvasResize()}_handleOptionsChanged(){this._renderer.value&&(this.refreshRows(0,this._rowCount-1),this._fireOnCanvasResize())}_fireOnCanvasResize(){this._renderer.value&&(this._renderer.value.dimensions.css.canvas.width===this._canvasWidth&&this._renderer.value.dimensions.css.canvas.height===this._canvasHeight||this._onDimensionsChange.fire(this._renderer.value.dimensions))}hasRenderer(){return!!this._renderer.value}setRenderer(e){this._renderer.value=e,this._renderer.value&&(this._renderer.value.onRequestRedraw(t=>this.refreshRows(t.start,t.end,!0)),this._needsSelectionRefresh=!0,this._fullRefresh())}addRefreshCallback(e){return this._renderDebouncer.addRefreshCallback(e)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){var e,t;this._renderer.value&&((t=(e=this._renderer.value).clearTextureAtlas)==null||t.call(e),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(e,t){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set(()=>{var i;return(i=this._renderer.value)==null?void 0:i.handleResize(e,t)}):this._renderer.value.handleResize(e,t),this._fullRefresh())}handleCharSizeChanged(){var e;(e=this._renderer.value)==null||e.handleCharSizeChanged()}handleBlur(){var e;(e=this._renderer.value)==null||e.handleBlur()}handleFocus(){var e;(e=this._renderer.value)==null||e.handleFocus()}handleSelectionChanged(e,t,i){var s;this._selectionState.start=e,this._selectionState.end=t,this._selectionState.columnSelectMode=i,(s=this._renderer.value)==null||s.handleSelectionChanged(e,t,i)}handleCursorMove(){var e;(e=this._renderer.value)==null||e.handleCursorMove()}clear(){var e;(e=this._renderer.value)==null||e.clear()}};hr=_e([T(2,Oe),T(3,hs),T(4,Nt),T(5,xi),T(6,Ie),T(7,ft),T(8,Jt)],hr);var Bc=class{constructor(e,t,i){this._coreBrowserService=e,this._coreService=t,this._onTimeout=i,this._start=0,this._end=0,this._isBuffering=!1}bufferRows(e,t){this._isBuffering?(this._start=Math.min(this._start,e),this._end=Math.max(this._end,t)):(this._start=e,this._end=t,this._isBuffering=!0),this._timeout===void 0&&(this._timeout=this._coreBrowserService.window.setTimeout(()=>{this._timeout=void 0,this._coreService.decPrivateModes.synchronizedOutput=!1,this._onTimeout()},1e3))}flush(){if(this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0),!this._isBuffering)return;let e={start:this._start,end:this._end};return this._isBuffering=!1,e}dispose(){this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0)}};function Mc(e,t,i,s){let r=i.buffer.x,n=i.buffer.y;if(!i.buffer.hasScrollback)return Tc(r,n,e,t,i,s)+ds(n,t,i,s)+$c(r,n,e,t,i,s);let o;if(n===t)return o=r>e?"D":"C",yi(Math.abs(r-e),Si(o,s));o=n>t?"D":"C";let a=Math.abs(n-t),h=Lc(n>t?e:r,i)+(a-1)*i.cols+1+Dc(n>t?r:e);return yi(h,Si(o,s))}function Dc(e,t){return e-1}function Lc(e,t){return t.cols-e}function Tc(e,t,i,s,r,n){return ds(t,s,r,n).length===0?"":yi(va(e,t,e,t-Pt(t,r),!1,r).length,Si("D",n))}function ds(e,t,i,s){let r=e-Pt(e,i),n=t-Pt(t,i),o=Math.abs(r-n)-Ac(e,t,i);return yi(o,Si(ga(e,t),s))}function $c(e,t,i,s,r,n){let o;ds(t,s,r,n).length>0?o=s-Pt(s,r):o=t;let a=s,h=Pc(e,t,i,s,r,n);return yi(va(e,o,i,a,h==="C",r).length,Si(h,n))}function Ac(e,t,i){var o;let s=0,r=e-Pt(e,i),n=t-Pt(t,i);for(let a=0;a=0&&e0?o=s-Pt(s,r):o=t,e=i&&ot?"A":"B"}function va(e,t,i,s,r,n){let o=e,a=t,h="";for(;(o!==i||a!==s)&&a>=0&&an.cols-1?(h+=n.buffer.translateBufferLineToString(a,!1,e,o),o=0,e=0,a++):!r&&o<0&&(h+=n.buffer.translateBufferLineToString(a,!1,0,e+1),o=n.cols-1,e=o,a--);return h+n.buffer.translateBufferLineToString(a,!1,e,o)}function Si(e,t){let i=t?"O":"[";return v.ESC+i+e}function yi(e,t){e=Math.floor(e);let i="";for(let s=0;sthis._bufferService.cols?e%this._bufferService.cols===0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)-1]:[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[e,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[Math.max(e,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){let e=this.selectionStart,t=this.selectionEnd;return!e||!t?!1:e[1]>t[1]||e[1]===t[1]&&e[0]>t[0]}handleTrim(e){return this.selectionStart&&(this.selectionStart[1]-=e),this.selectionEnd&&(this.selectionEnd[1]-=e),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}};function mn(e,t){if(e.start.y>e.end.y)throw new Error(`Buffer range end (${e.end.x}, ${e.end.y}) cannot be before start (${e.start.x}, ${e.start.y})`);return t*(e.end.y-e.start.y)+(e.end.x-e.start.x+1)}var ys=50,Ic=15,Oc=50,Hc=500,Fc=" ",Wc=new RegExp(Fc,"g"),cr=class extends G{constructor(e,t,i,s,r,n,o,a,h){super(),this._element=e,this._screenElement=t,this._linkifier=i,this._bufferService=s,this._coreService=r,this._mouseService=n,this._optionsService=o,this._renderService=a,this._coreBrowserService=h,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new Je,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new k),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new k),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new k),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new k),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=l=>this._handleMouseMove(l),this._mouseUpListener=l=>this._handleMouseUp(l),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(l=>this._handleTrim(l)),this._register(this._bufferService.buffers.onBufferActivate(l=>this._handleBufferActivate(l))),this.enable(),this._model=new Nc(this._bufferService),this._activeSelectionMode=0,this._register(oe(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(l=>{l.rowsChanged&&this.clearSelection()}))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;return!e||!t?!1:e[0]!==t[0]||e[1]!==t[1]}get selectionText(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;if(!e||!t)return"";let i=this._bufferService.buffer,s=[];if(this._activeSelectionMode===3){if(e[0]===t[0])return"";let r=e[0]r.replace(Wc," ")).join(fa?`\r `:` -`)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),Pr&&e&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:this._activeSelectionMode===3})}_isClickInSelection(e){let t=this._getMouseBufferCoords(e),i=this._model.finalSelectionStart,s=this._model.finalSelectionEnd;return!i||!s||!t?!1:this._areCoordsInSelection(t,i,s)}isCellInSelection(e,t){let i=this._model.finalSelectionStart,s=this._model.finalSelectionEnd;return!i||!s?!1:this._areCoordsInSelection([e,t],i,s)}_areCoordsInSelection(e,t,i){return e[1]>t[1]&&e[1]=t[0]&&e[0]=t[0]}_selectWordAtCursor(e,t){var r,n;let i=(n=(r=this._linkifier.currentLink)==null?void 0:r.link)==null?void 0:n.range;if(i)return this._model.selectionStart=[i.start.x-1,i.start.y-1],this._model.selectionStartLength=mn(i,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let s=this._getMouseBufferCoords(e);return s?(this._selectWordAt(s,t),this._model.selectionEnd=void 0,!0):!1}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(e,t){this._model.clearSelection(),e=Math.max(e,0),t=Math.min(t,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,e],this._model.selectionEnd=[this._bufferService.cols,t],this.refresh(),this._onSelectionChange.fire()}_handleTrim(e){this._model.handleTrim(e)&&this.refresh()}_getMouseBufferCoords(e){let t=this._mouseService.getCoords(e,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(t)return t[0]--,t[1]--,t[1]+=this._bufferService.buffer.ydisp,t}_getMouseEventScrollAmount(e){let t=Ar(this._coreBrowserService.window,e,this._screenElement)[1],i=this._renderService.dimensions.css.canvas.height;return t>=0&&t<=i?0:(t>i&&(t-=i),t=Math.min(Math.max(t,-ys),ys),t/=ys,t/Math.abs(t)+Math.round(t*(Ic-1)))}shouldForceSelection(e){return rs?e.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:e.shiftKey}handleMouseDown(e){if(this._mouseDownTimeStamp=e.timeStamp,!(e.button===2&&this.hasSelection)&&e.button===0){if(!this._enabled){if(!this.shouldForceSelection(e))return;e.stopPropagation()}e.preventDefault(),this._dragScrollAmount=0,this._enabled&&e.shiftKey?this._handleIncrementalClick(e):e.detail===1?this._handleSingleClick(e):e.detail===2?this._handleDoubleClick(e):e.detail===3&&this._handleTripleClick(e),this._addMouseDownListeners(),this.refresh(!0)}}_addMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.addEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.addEventListener("mouseup",this._mouseUpListener)),this._dragScrollIntervalTimer=this._coreBrowserService.window.setInterval(()=>this._dragScroll(),Oc)}_removeMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.removeEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.removeEventListener("mouseup",this._mouseUpListener)),this._coreBrowserService.window.clearInterval(this._dragScrollIntervalTimer),this._dragScrollIntervalTimer=void 0}_handleIncrementalClick(e){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(e))}_handleSingleClick(e){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(e)?3:0,this._model.selectionStart=this._getMouseBufferCoords(e),!this._model.selectionStart)return;this._model.selectionEnd=void 0;let t=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);t&&t.length!==this._model.selectionStart[0]&&t.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(e){this._selectWordAtCursor(e,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(e){let t=this._getMouseBufferCoords(e);t&&(this._activeSelectionMode=2,this._selectLineAt(t[1]))}shouldColumnSelect(e){return e.altKey&&!(rs&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(e){if(e.stopImmediatePropagation(),!this._model.selectionStart)return;let t=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(e),!this._model.selectionEnd){this.refresh(!0);return}this._activeSelectionMode===2?this._model.selectionEnd[1]0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));let i=this._bufferService.buffer;if(this._model.selectionEnd[1]0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(e.ydisp+this._bufferService.rows,e.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=e.ydisp),this.refresh()}}_handleMouseUp(e){let t=e.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&tthis._handleTrim(t))}_convertViewportColToCharacterIndex(e,t){let i=t;for(let s=0;t>=s;s++){let r=e.loadCell(s,this._workCell).getChars().length;this._workCell.getWidth()===0?i--:r>1&&t!==s&&(i+=r-1)}return i}setSelection(e,t,i){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=i,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,t,i=!0,s=!0){if(e[0]>=this._bufferService.cols)return;let r=this._bufferService.buffer,n=r.lines.get(e[1]);if(!n)return;let o=r.translateBufferLineToString(e[1],!1),a=this._convertViewportColToCharacterIndex(n,e[0]),h=a,l=e[0]-a,c=0,d=0,u=0,f=0;if(o.charAt(a)===" "){for(;a>0&&o.charAt(a-1)===" ";)a--;for(;h1&&(f+=z-1,h+=z-1);g>0&&a>0&&!this._isCharWordSeparator(n.loadCell(g-1,this._workCell));){n.loadCell(g-1,this._workCell);let O=this._workCell.getChars().length;this._workCell.getWidth()===0?(c++,g--):O>1&&(u+=O-1,a-=O-1),a--,g--}for(;E1&&(f+=O-1,h+=O-1),h++,E++}}h++;let _=a+l-c+u,p=Math.min(this._bufferService.cols,h-a+c+d-u-f);if(!(!t&&o.slice(a,h).trim()==="")){if(i&&_===0&&n.getCodePoint(0)!==32){let g=r.lines.get(e[1]-1);if(g&&n.isWrapped&&g.getCodePoint(this._bufferService.cols-1)!==32){let E=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(E){let z=this._bufferService.cols-E.start;_-=z,p+=z}}}if(s&&_+p===this._bufferService.cols&&n.getCodePoint(this._bufferService.cols-1)!==32){let g=r.lines.get(e[1]+1);if(g!=null&&g.isWrapped&&g.getCodePoint(0)!==32){let E=this._getWordAt([0,e[1]+1],!1,!1,!0);E&&(p+=E.length)}}return{start:_,length:p}}}_selectWordAt(e,t){let i=this._getWordAt(e,t);if(i){for(;i.start<0;)i.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[i.start,e[1]],this._model.selectionStartLength=i.length}}_selectToWordAt(e){let t=this._getWordAt(e,!0);if(t){let i=e[1];for(;t.start<0;)t.start+=this._bufferService.cols,i--;if(!this._model.areSelectionValuesReversed())for(;t.start+t.length>this._bufferService.cols;)t.length-=this._bufferService.cols,i++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?t.start:t.start+t.length,i]}}_isCharWordSeparator(e){return e.getWidth()===0?!1:this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let t=this._bufferService.buffer.getWrappedRangeForLine(e),i={start:{x:0,y:t.first},end:{x:this._bufferService.cols-1,y:t.last}};this._model.selectionStart=[0,t.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=mn(i,this._bufferService.cols)}};cr=_e([T(3,Ie),T(4,Nt),T(5,Rr),T(6,Oe),T(7,pt),T(8,ft)],cr);var gn=class{constructor(){this._data={}}set(e,t,i){this._data[e]||(this._data[e]={}),this._data[e][t]=i}get(e,t){return this._data[e]?this._data[e][t]:void 0}clear(){this._data={}}},vn=class{constructor(){this._color=new gn,this._css=new gn}setCss(e,t,i){this._css.set(e,t,i)}getCss(e,t){return this._css.get(e,t)}setColor(e,t,i){this._color.set(e,t,i)}getColor(e,t){return this._color.get(e,t)}clear(){this._color.clear(),this._css.clear()}},ye=Object.freeze((()=>{let e=[ce.toColor("#2e3436"),ce.toColor("#cc0000"),ce.toColor("#4e9a06"),ce.toColor("#c4a000"),ce.toColor("#3465a4"),ce.toColor("#75507b"),ce.toColor("#06989a"),ce.toColor("#d3d7cf"),ce.toColor("#555753"),ce.toColor("#ef2929"),ce.toColor("#8ae234"),ce.toColor("#fce94f"),ce.toColor("#729fcf"),ce.toColor("#ad7fa8"),ce.toColor("#34e2e2"),ce.toColor("#eeeeec")],t=[0,95,135,175,215,255];for(let i=0;i<216;i++){let s=t[i/36%6|0],r=t[i/6%6|0],n=t[i%6];e.push({css:ve.toCss(s,r,n),rgba:ve.toRgba(s,r,n)})}for(let i=0;i<24;i++){let s=8+i*10;e.push({css:ve.toCss(s,s,s),rgba:ve.toRgba(s,s,s)})}return e})()),Dt=ce.toColor("#ffffff"),ui=ce.toColor("#000000"),Sn=ce.toColor("#ffffff"),yn=ui,ni={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},zc=Dt,dr=class extends G{constructor(e){super(),this._optionsService=e,this._contrastCache=new vn,this._halfContrastCache=new vn,this._onChangeColors=this._register(new k),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:Dt,background:ui,cursor:Sn,cursorAccent:yn,selectionForeground:void 0,selectionBackgroundTransparent:ni,selectionBackgroundOpaque:re.blend(ui,ni),selectionInactiveBackgroundTransparent:ni,selectionInactiveBackgroundOpaque:re.blend(ui,ni),scrollbarSliderBackground:re.opacity(Dt,.2),scrollbarSliderHoverBackground:re.opacity(Dt,.4),scrollbarSliderActiveBackground:re.opacity(Dt,.5),overviewRulerBorder:Dt,ansi:ye.slice(),contrastCache:this._contrastCache,halfContrastCache:this._halfContrastCache},this._updateRestoreColors(),this._setTheme(this._optionsService.rawOptions.theme),this._register(this._optionsService.onSpecificOptionChange("minimumContrastRatio",()=>this._contrastCache.clear())),this._register(this._optionsService.onSpecificOptionChange("theme",()=>this._setTheme(this._optionsService.rawOptions.theme)))}get colors(){return this._colors}_setTheme(e={}){let t=this._colors;if(t.foreground=Z(e.foreground,Dt),t.background=Z(e.background,ui),t.cursor=re.blend(t.background,Z(e.cursor,Sn)),t.cursorAccent=re.blend(t.background,Z(e.cursorAccent,yn)),t.selectionBackgroundTransparent=Z(e.selectionBackground,ni),t.selectionBackgroundOpaque=re.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=Z(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=re.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?Z(e.selectionForeground,_n):void 0,t.selectionForeground===_n&&(t.selectionForeground=void 0),re.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=re.opacity(t.selectionBackgroundTransparent,.3)),re.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=re.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=Z(e.scrollbarSliderBackground,re.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=Z(e.scrollbarSliderHoverBackground,re.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=Z(e.scrollbarSliderActiveBackground,re.opacity(t.foreground,.5)),t.overviewRulerBorder=Z(e.overviewRulerBorder,zc),t.ansi=ye.slice(),t.ansi[0]=Z(e.black,ye[0]),t.ansi[1]=Z(e.red,ye[1]),t.ansi[2]=Z(e.green,ye[2]),t.ansi[3]=Z(e.yellow,ye[3]),t.ansi[4]=Z(e.blue,ye[4]),t.ansi[5]=Z(e.magenta,ye[5]),t.ansi[6]=Z(e.cyan,ye[6]),t.ansi[7]=Z(e.white,ye[7]),t.ansi[8]=Z(e.brightBlack,ye[8]),t.ansi[9]=Z(e.brightRed,ye[9]),t.ansi[10]=Z(e.brightGreen,ye[10]),t.ansi[11]=Z(e.brightYellow,ye[11]),t.ansi[12]=Z(e.brightBlue,ye[12]),t.ansi[13]=Z(e.brightMagenta,ye[13]),t.ansi[14]=Z(e.brightCyan,ye[14]),t.ansi[15]=Z(e.brightWhite,ye[15]),e.extendedAnsi){let i=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let s=0;sn.index-o.index),s=[];for(let n of i){let o=this._services.get(n.id);if(!o)throw new Error(`[createInstance] ${e.name} depends on UNKNOWN service ${n.id._id}.`);s.push(o)}let r=i.length>0?i[0].index:t.length;if(t.length!==r)throw new Error(`[createInstance] First service dependency of ${e.name} at position ${r+1} conflicts with ${t.length} static arguments`);return new e(...t,...s)}},Kc={trace:0,debug:1,info:2,warn:3,error:4,off:5},qc="xterm.js: ",ur=class extends G{constructor(e){super(),this._optionsService=e,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange("logLevel",()=>this._updateLogLevel()))}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=Kc[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(e){for(let t=0;tthis._length)for(let t=this._length;t=e;s--)this._array[this._getCyclicIndex(s+i.length)]=this._array[this._getCyclicIndex(s)];for(let s=0;sthis._maxLength){let s=this._length+i.length-this._maxLength;this._startIndex+=s,this._length=this._maxLength,this.onTrimEmitter.fire(s)}else this._length+=i.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,t,i){if(!(t<=0)){if(e<0||e>=this._length)throw new Error("start argument out of range");if(e+i<0)throw new Error("Cannot shift elements in list beyond index 0");if(i>0){for(let r=t-1;r>=0;r--)this.set(e+r+i,this.get(e+r));let s=e+t+i-this._length;if(s>0)for(this._length+=s;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let s=0;s>22,i&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):s]}set(t,i){this._data[t*V+1]=i[0],i[1].length>1?(this._combined[t]=i[1],this._data[t*V+0]=t|2097152|i[2]<<22):this._data[t*V+0]=i[1].charCodeAt(0)|i[2]<<22}getWidth(t){return this._data[t*V+0]>>22}hasWidth(t){return this._data[t*V+0]&12582912}getFg(t){return this._data[t*V+1]}getBg(t){return this._data[t*V+2]}hasContent(t){return this._data[t*V+0]&4194303}getCodePoint(t){let i=this._data[t*V+0];return i&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):i&2097151}isCombined(t){return this._data[t*V+0]&2097152}getString(t){let i=this._data[t*V+0];return i&2097152?this._combined[t]:i&2097151?bt(i&2097151):""}isProtected(t){return this._data[t*V+2]&536870912}loadCell(t,i){return Oi=t*V,i.content=this._data[Oi+0],i.fg=this._data[Oi+1],i.bg=this._data[Oi+2],i.content&2097152&&(i.combinedData=this._combined[t]),i.bg&268435456&&(i.extended=this._extendedAttrs[t]),i}setCell(t,i){i.content&2097152&&(this._combined[t]=i.combinedData),i.bg&268435456&&(this._extendedAttrs[t]=i.extended),this._data[t*V+0]=i.content,this._data[t*V+1]=i.fg,this._data[t*V+2]=i.bg}setCellFromCodepoint(t,i,s,r){r.bg&268435456&&(this._extendedAttrs[t]=r.extended),this._data[t*V+0]=i|s<<22,this._data[t*V+1]=r.fg,this._data[t*V+2]=r.bg}addCodepointToCell(t,i,s){let r=this._data[t*V+0];r&2097152?this._combined[t]+=bt(i):r&2097151?(this._combined[t]=bt(r&2097151)+bt(i),r&=-2097152,r|=2097152):r=i|1<<22,s&&(r&=-12582913,r|=s<<22),this._data[t*V+0]=r}insertCells(t,i,s){if(t%=this.length,t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,s),i=0;--n)this.setCell(t+i+n,this.loadCell(t+n,r));for(let n=0;nthis.length){if(this._data.buffer.byteLength>=s*4)this._data=new Uint32Array(this._data.buffer,0,s);else{let r=new Uint32Array(s);r.set(this._data),this._data=r}for(let r=this.length;r=t&&delete this._combined[a]}let n=Object.keys(this._extendedAttrs);for(let o=0;o=t&&delete this._extendedAttrs[a]}}return this.length=t,s*4*bs=0;--t)if(this._data[t*V+0]&4194303)return t+(this._data[t*V+0]>>22);return 0}getNoBgTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*V+0]&4194303||this._data[t*V+2]&50331648)return t+(this._data[t*V+0]>>22);return 0}copyCellsFrom(t,i,s,r,n){let o=t._data;if(n)for(let h=r-1;h>=0;h--){for(let l=0;l=i&&(this._combined[l-i+s]=t._combined[l])}}translateToString(t,i,s,r){i=i??0,s=s??this.length,t&&(s=Math.min(s,this.getTrimmedLength())),r&&(r.length=0);let n="";for(;i>22||1}return r&&r.push(i),n}};function Vc(e,t,i,s,r,n){let o=[];for(let a=0;a=a&&s0&&(g>d||c[g].getTrimmedLength()===0);g--)p++;p>0&&(o.push(a+c.length-p),o.push(p)),a+=c.length-1}return o}function Gc(e,t){let i=[],s=0,r=t[s],n=0;for(let o=0;obi(e,l,t)).reduce((h,l)=>h+l),n=0,o=0,a=0;for(;ah&&(n-=h,o++);let l=e[o].getWidth(n-1)===2;l&&n--;let c=l?i-1:i;s.push(c),a+=c}return s}function bi(e,t,i){if(t===e.length-1)return e[t].getTrimmedLength();let s=!e[t].hasContent(i-1)&&e[t].getWidth(i-1)===1,r=e[t+1].getWidth(0)===2;return s&&r?i-1:i}var ya=class ba{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=ba._nextId++,this._onDispose=this.register(new k),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),At(this._disposables),this._disposables.length=0)}register(t){return this._disposables.push(t),t}};ya._nextId=1;var Jc=ya,we={},Lt=we.B;we[0]={"`":"◆",a:"▒",b:"␉",c:"␌",d:"␍",e:"␊",f:"°",g:"±",h:"␤",i:"␋",j:"┘",k:"┐",l:"┌",m:"└",n:"┼",o:"⎺",p:"⎻",q:"─",r:"⎼",s:"⎽",t:"├",u:"┤",v:"┴",w:"┬",x:"│",y:"≤",z:"≥","{":"π","|":"≠","}":"£","~":"·"};we.A={"#":"£"};we.B=void 0;we[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};we.C=we[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};we.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};we.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};we.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};we.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};we.E=we[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};we.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};we.H=we[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};we["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var wn=4294967295,Cn=class{constructor(e,t,i){this._hasScrollback=e,this._optionsService=t,this._bufferService=i,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=me.clone(),this.savedCharset=Lt,this.markers=[],this._nullCell=Je.fromCharData([0,Oo,1,0]),this._whitespaceCell=Je.fromCharData([0,Ct,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new ns,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new bn(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(e){return e?(this._nullCell.fg=e.fg,this._nullCell.bg=e.bg,this._nullCell.extended=e.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new ts),this._nullCell}getWhitespaceCell(e){return e?(this._whitespaceCell.fg=e.fg,this._whitespaceCell.bg=e.bg,this._whitespaceCell.extended=e.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new ts),this._whitespaceCell}getBlankLine(e,t){return new _i(this._bufferService.cols,this.getNullCell(e),t)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){let e=this.ybase+this.y-this.ydisp;return e>=0&&ewn?wn:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=me);let t=this._rows;for(;t--;)this.lines.push(this.getBlankLine(e))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new bn(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let i=this.getNullCell(me),s=0,r=this._getCorrectBufferLength(t);if(r>this.lines.maxLength&&(this.lines.maxLength=r),this.lines.length>0){if(this._cols0&&this.lines.length<=this.ybase+this.y+n+1?(this.ybase--,n++,this.ydisp>0&&this.ydisp--):this.lines.push(new _i(e,i)));else for(let o=this._rows;o>t;o--)this.lines.length>t+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(r0&&(this.lines.trimStart(o),this.ybase=Math.max(this.ybase-o,0),this.ydisp=Math.max(this.ydisp-o,0),this.savedY=Math.max(this.savedY-o,0)),this.lines.maxLength=r}this.x=Math.min(this.x,e-1),this.y=Math.min(this.y,t-1),n&&(this.y+=n),this.savedX=Math.min(this.savedX,e-1),this.scrollTop=0}if(this.scrollBottom=t-1,this._isReflowEnabled&&(this._reflow(e,t),this._cols>e))for(let n=0;n.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let e=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,e=!1);let t=0;for(;this._memoryCleanupPosition100)return!0;return e}get _isReflowEnabled(){let e=this._optionsService.rawOptions.windowsPty;return e&&e.buildNumber?this._hasScrollback&&e.backend==="conpty"&&e.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(e,t){this._cols!==e&&(e>this._cols?this._reflowLarger(e,t):this._reflowSmaller(e,t))}_reflowLarger(e,t){let i=this._optionsService.rawOptions.reflowCursorLine,s=Vc(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(me),i);if(s.length>0){let r=Gc(this.lines,s);Yc(this.lines,r.layout),this._reflowLargerAdjustViewport(e,t,r.countRemoved)}}_reflowLargerAdjustViewport(e,t,i){let s=this.getNullCell(me),r=i;for(;r-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length=0;o--){let a=this.lines.get(o);if(!a||!a.isWrapped&&a.getTrimmedLength()<=e)continue;let h=[a];for(;a.isWrapped&&o>0;)a=this.lines.get(--o),h.unshift(a);if(!i){let O=this.ybase+this.y;if(O>=o&&O0&&(r.push({start:o+h.length+n,newLines:f}),n+=f.length),h.push(...f);let _=c.length-1,p=c[_];p===0&&(_--,p=c[_]);let g=h.length-d-1,E=l;for(;g>=0;){let O=Math.min(E,p);if(h[_]===void 0)break;if(h[_].copyCellsFrom(h[g],E-O,p-O,O,!0),p-=O,p===0&&(_--,p=c[_]),E-=O,E===0){g--;let M=Math.max(g,0);E=bi(h,M,this._cols)}}for(let O=0;O0;)this.ybase===0?this.y0){let o=[],a=[];for(let p=0;p=0;p--)if(d&&d.start>l+u){for(let g=d.newLines.length-1;g>=0;g--)this.lines.set(p--,d.newLines[g]);p++,o.push({index:l+1,amount:d.newLines.length}),u+=d.newLines.length,d=r[++c]}else this.lines.set(p,a[l--]);let f=0;for(let p=o.length-1;p>=0;p--)o[p].index+=f,this.lines.onInsertEmitter.fire(o[p]),f+=o[p].amount;let _=Math.max(0,h+n-this.lines.maxLength);_>0&&this.lines.onTrimEmitter.fire(_)}}translateBufferLineToString(e,t,i=0,s){let r=this.lines.get(e);return r?r.translateToString(t,i,s):""}getWrappedRangeForLine(e){let t=e,i=e;for(;t>0&&this.lines.get(t).isWrapped;)t--;for(;i+10;);return e>=this._cols?this._cols-1:e<0?0:e}nextStop(e){for(e==null&&(e=this.x);!this.tabs[++e]&&e=this._cols?this._cols-1:e<0?0:e}clearMarkers(e){this._isClearing=!0;for(let t=0;t{t.line-=i,t.line<0&&t.dispose()})),t.register(this.lines.onInsert(i=>{t.line>=i.index&&(t.line+=i.amount)})),t.register(this.lines.onDelete(i=>{t.line>=i.index&&t.linei.index&&(t.line-=i.amount)})),t.register(t.onDispose(()=>this._removeMarker(t))),t}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}},Zc=class extends G{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new k),this.onBufferActivate=this._onBufferActivate.event,this.reset(),this._register(this._optionsService.onSpecificOptionChange("scrollback",()=>this.resize(this._bufferService.cols,this._bufferService.rows))),this._register(this._optionsService.onSpecificOptionChange("tabStopWidth",()=>this.setupTabStops()))}reset(){this._normal=new Cn(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new Cn(!1,this._optionsService,this._bufferService),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}),this.setupTabStops()}get alt(){return this._alt}get active(){return this._activeBuffer}get normal(){return this._normal}activateNormalBuffer(){this._activeBuffer!==this._normal&&(this._normal.x=this._alt.x,this._normal.y=this._alt.y,this._alt.clearAllMarkers(),this._alt.clear(),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}))}activateAltBuffer(e){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(e),this._alt.x=this._normal.x,this._alt.y=this._normal.y,this._activeBuffer=this._alt,this._onBufferActivate.fire({activeBuffer:this._alt,inactiveBuffer:this._normal}))}resize(e,t){this._normal.resize(e,t),this._alt.resize(e,t),this.setupTabStops(e)}setupTabStops(e){this._normal.setupTabStops(e),this._alt.setupTabStops(e)}},wa=2,Ca=1,_r=class extends G{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new k),this.onResize=this._onResize.event,this._onScroll=this._register(new k),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,wa),this.rows=Math.max(e.rawOptions.rows||0,Ca),this.buffers=this._register(new Zc(e,this)),this._register(this.buffers.onBufferActivate(t=>{this._onScroll.fire(t.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(e,t){let i=this.cols!==e,s=this.rows!==t;this.cols=e,this.rows=t,this.buffers.resize(e,t),this._onResize.fire({cols:e,rows:t,colsChanged:i,rowsChanged:s})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,t=!1){let i=this.buffer,s;s=this._cachedBlankLine,(!s||s.length!==this.cols||s.getFg(0)!==e.fg||s.getBg(0)!==e.bg)&&(s=i.getBlankLine(e,t),this._cachedBlankLine=s),s.isWrapped=t;let r=i.ybase+i.scrollTop,n=i.ybase+i.scrollBottom;if(i.scrollTop===0){let o=i.lines.isFull;n===i.lines.length-1?o?i.lines.recycle().copyFrom(s):i.lines.push(s.clone()):i.lines.splice(n+1,0,s.clone()),o?this.isUserScrolling&&(i.ydisp=Math.max(i.ydisp-1,0)):(i.ybase++,this.isUserScrolling||i.ydisp++)}else{let o=n-r+1;i.lines.shiftElements(r+1,o-1,-1),i.lines.set(n,s.clone())}this.isUserScrolling||(i.ydisp=i.ybase),this._onScroll.fire(i.ydisp)}scrollLines(e,t){let i=this.buffer;if(e<0){if(i.ydisp===0)return;this.isUserScrolling=!0}else e+i.ydisp>=i.ybase&&(this.isUserScrolling=!1);let s=i.ydisp;i.ydisp=Math.max(Math.min(i.ydisp+e,i.ybase),0),s!==i.ydisp&&(t||this._onScroll.fire(i.ydisp))}};_r=_e([T(0,Oe)],_r);var Wt={cols:80,rows:24,cursorBlink:!1,cursorStyle:"block",cursorWidth:1,cursorInactiveStyle:"outline",customGlyphs:!0,drawBoldTextInBrightColors:!0,documentOverride:null,fastScrollModifier:"alt",fastScrollSensitivity:5,fontFamily:"monospace",fontSize:15,fontWeight:"normal",fontWeightBold:"bold",ignoreBracketedPasteMode:!1,lineHeight:1,letterSpacing:0,linkHandler:null,logLevel:"info",logger:null,scrollback:1e3,scrollOnEraseInDisplay:!1,scrollOnUserInput:!0,scrollSensitivity:1,screenReaderMode:!1,smoothScrollDuration:0,macOptionIsMeta:!1,macOptionClickForcesSelection:!1,minimumContrastRatio:1,disableStdin:!1,allowProposedApi:!1,allowTransparency:!1,tabStopWidth:8,theme:{},reflowCursorLine:!1,rescaleOverlappingGlyphs:!1,rightClickSelectsWord:rs,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},Qc=["normal","bold","100","200","300","400","500","600","700","800","900"],ed=class extends G{constructor(e){super(),this._onOptionChange=this._register(new k),this.onOptionChange=this._onOptionChange.event;let t={...Wt};for(let i in e)if(i in t)try{let s=e[i];t[i]=this._sanitizeAndValidateOption(i,s)}catch(s){console.error(s)}this.rawOptions=t,this.options={...t},this._setupOptions(),this._register(oe(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,t){return this.onOptionChange(i=>{i===e&&t(this.rawOptions[e])})}onMultipleOptionChange(e,t){return this.onOptionChange(i=>{e.indexOf(i)!==-1&&t()})}_setupOptions(){let e=i=>{if(!(i in Wt))throw new Error(`No option with key "${i}"`);return this.rawOptions[i]},t=(i,s)=>{if(!(i in Wt))throw new Error(`No option with key "${i}"`);s=this._sanitizeAndValidateOption(i,s),this.rawOptions[i]!==s&&(this.rawOptions[i]=s,this._onOptionChange.fire(i))};for(let i in this.rawOptions){let s={get:e.bind(this,i),set:t.bind(this,i)};Object.defineProperty(this.options,i,s)}}_sanitizeAndValidateOption(e,t){switch(e){case"cursorStyle":if(t||(t=Wt[e]),!td(t))throw new Error(`"${t}" is not a valid value for ${e}`);break;case"wordSeparator":t||(t=Wt[e]);break;case"fontWeight":case"fontWeightBold":if(typeof t=="number"&&1<=t&&t<=1e3)break;t=Qc.includes(t)?t:Wt[e];break;case"cursorWidth":t=Math.floor(t);case"lineHeight":case"tabStopWidth":if(t<1)throw new Error(`${e} cannot be less than 1, value: ${t}`);break;case"minimumContrastRatio":t=Math.max(1,Math.min(21,Math.round(t*10)/10));break;case"scrollback":if(t=Math.min(t,4294967295),t<0)throw new Error(`${e} cannot be less than 0, value: ${t}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(t<=0)throw new Error(`${e} cannot be less than or equal to 0, value: ${t}`);break;case"rows":case"cols":if(!t&&t!==0)throw new Error(`${e} must be numeric, value: ${t}`);break;case"windowsPty":t=t??{};break}return t}};function td(e){return e==="block"||e==="underline"||e==="bar"}function fi(e,t=5){if(typeof e!="object")return e;let i=Array.isArray(e)?[]:{};for(let s in e)i[s]=t<=1?e[s]:e[s]&&fi(e[s],t-1);return i}var xn=Object.freeze({insertMode:!1}),kn=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),fr=class extends G{constructor(e,t,i){super(),this._bufferService=e,this._logService=t,this._optionsService=i,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new k),this.onData=this._onData.event,this._onUserInput=this._register(new k),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new k),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new k),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=fi(xn),this.decPrivateModes=fi(kn)}reset(){this.modes=fi(xn),this.decPrivateModes=fi(kn)}triggerDataEvent(e,t=!1){if(this._optionsService.rawOptions.disableStdin)return;let i=this._bufferService.buffer;t&&this._optionsService.rawOptions.scrollOnUserInput&&i.ybase!==i.ydisp&&this._onRequestScrollToBottom.fire(),t&&this._onUserInput.fire(),this._logService.debug(`sending data "${e}"`),this._logService.trace("sending data (codes)",()=>e.split("").map(s=>s.charCodeAt(0))),this._onData.fire(e)}triggerBinaryEvent(e){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${e}"`),this._logService.trace("sending binary (codes)",()=>e.split("").map(t=>t.charCodeAt(0))),this._onBinary.fire(e))}};fr=_e([T(0,Ie),T(1,Uo),T(2,Oe)],fr);var En={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:e=>e.button===4||e.action!==1?!1:(e.ctrl=!1,e.alt=!1,e.shift=!1,!0)},VT200:{events:19,restrict:e=>e.action!==32},DRAG:{events:23,restrict:e=>!(e.action===32&&e.button===3)},ANY:{events:31,restrict:e=>!0}};function ws(e,t){let i=(e.ctrl?16:0)|(e.shift?4:0)|(e.alt?8:0);return e.button===4?(i|=64,i|=e.action):(i|=e.button&3,e.button&4&&(i|=64),e.button&8&&(i|=128),e.action===32?i|=32:e.action===0&&!t&&(i|=3)),i}var Cs=String.fromCharCode,Rn={DEFAULT:e=>{let t=[ws(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?"":`\x1B[M${Cs(t[0])}${Cs(t[1])}${Cs(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${ws(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${ws(e,!0)};${e.x};${e.y}${t}`}},pr=class extends G{constructor(e,t,i){super(),this._bufferService=e,this._coreService=t,this._optionsService=i,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new k),this.onProtocolChange=this._onProtocolChange.event;for(let s of Object.keys(En))this.addProtocol(s,En[s]);for(let s of Object.keys(Rn))this.addEncoding(s,Rn[s]);this.reset()}addProtocol(e,t){this._protocols[e]=t}addEncoding(e,t){this._encodings[e]=t}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(e){if(!this._protocols[e])throw new Error(`unknown protocol "${e}"`);this._activeProtocol=e,this._onProtocolChange.fire(this._protocols[e].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(e){if(!this._encodings[e])throw new Error(`unknown encoding "${e}"`);this._activeEncoding=e}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(e,t,i){if(e.deltaY===0||e.shiftKey||t===void 0||i===void 0)return 0;let s=t/i,r=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(r/=s+0,Math.abs(e.deltaY)<50&&(r*=.3),this._wheelPartialScroll+=r,r=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(r*=this._bufferService.rows),r}_applyScrollModifier(e,t){return t.altKey||t.ctrlKey||t.shiftKey?e*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:e*this._optionsService.rawOptions.scrollSensitivity}triggerMouseEvent(e){if(e.col<0||e.col>=this._bufferService.cols||e.row<0||e.row>=this._bufferService.rows||e.button===4&&e.action===32||e.button===3&&e.action!==32||e.button!==4&&(e.action===2||e.action===3)||(e.col++,e.row++,e.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,e,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(e))return!1;let t=this._encodings[this._activeEncoding](e);return t&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(t):this._coreService.triggerDataEvent(t,!0)),this._lastEvent=e,!0}explainEvents(e){return{down:!!(e&1),up:!!(e&2),drag:!!(e&4),move:!!(e&8),wheel:!!(e&16)}}_equalEvents(e,t,i){if(i){if(e.x!==t.x||e.y!==t.y)return!1}else if(e.col!==t.col||e.row!==t.row)return!1;return!(e.button!==t.button||e.action!==t.action||e.ctrl!==t.ctrl||e.alt!==t.alt||e.shift!==t.shift)}};pr=_e([T(0,Ie),T(1,Nt),T(2,Oe)],pr);var xs=[[768,879],[1155,1158],[1160,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1539],[1552,1557],[1611,1630],[1648,1648],[1750,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2305,2306],[2364,2364],[2369,2376],[2381,2381],[2385,2388],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2672,2673],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2817,2817],[2876,2876],[2879,2879],[2881,2883],[2893,2893],[2902,2902],[2946,2946],[3008,3008],[3021,3021],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3393,3395],[3405,3405],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3769],[3771,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3984,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4146],[4150,4151],[4153,4153],[4184,4185],[4448,4607],[4959,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6157],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7616,7626],[7678,7679],[8203,8207],[8234,8238],[8288,8291],[8298,8303],[8400,8431],[12330,12335],[12441,12442],[43014,43014],[43019,43019],[43045,43046],[64286,64286],[65024,65039],[65056,65059],[65279,65279],[65529,65531]],id=[[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[917505,917505],[917536,917631],[917760,917999]],be;function sd(e,t){let i=0,s=t.length-1,r;if(et[s][1])return!1;for(;s>=i;)if(r=i+s>>1,e>t[r][1])i=r+1;else if(e=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let i=this.wcwidth(e),s=i===0&&t!==0;if(s){let r=Tt.extractWidth(t);r===0?s=!1:r>i&&(i=r)}return Tt.createPropertyValue(0,i,s)}},Tt=class qi{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new k,this.onChange=this._onChange.event;let t=new rd;this.register(t),this._active=t.version,this._activeProvider=t}static extractShouldJoin(t){return(t&1)!==0}static extractWidth(t){return t>>1&3}static extractCharKind(t){return t>>3}static createPropertyValue(t,i,s=!1){return(t&16777215)<<3|(i&3)<<1|(s?1:0)}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(t){if(!this._providers[t])throw new Error(`unknown Unicode version "${t}"`);this._active=t,this._activeProvider=this._providers[t],this._onChange.fire(t)}register(t){this._providers[t.version]=t}wcwidth(t){return this._activeProvider.wcwidth(t)}getStringCellWidth(t){let i=0,s=0,r=t.length;for(let n=0;n=r)return i+this.wcwidth(o);let l=t.charCodeAt(n);56320<=l&&l<=57343?o=(o-55296)*1024+l-56320+65536:i+=this.wcwidth(l)}let a=this.charProperties(o,s),h=qi.extractWidth(a);qi.extractShouldJoin(a)&&(h-=qi.extractWidth(s)),i+=h,s=a}return i}charProperties(t,i){return this._activeProvider.charProperties(t,i)}},nd=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(e){this.glevel=e,this.charset=this._charsets[e]}setgCharset(e,t){this._charsets[e]=t,this.glevel===e&&(this.charset=t)}};function Bn(e){var s;let t=(s=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1))==null?void 0:s.get(e.cols-1),i=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);i&&t&&(i.isWrapped=t[3]!==0&&t[3]!==32)}var oi=2147483647,od=256,xa=class mr{constructor(t=32,i=32){if(this.maxLength=t,this.maxSubParamsLength=i,i>od)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(t),this.length=0,this._subParams=new Int32Array(i),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(t),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(t){let i=new mr;if(!t.length)return i;for(let s=Array.isArray(t[0])?1:0;s>8,r=this._subParamsIdx[i]&255;r-s>0&&t.push(Array.prototype.slice.call(this._subParams,s,r))}return t}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(t){if(this._digitIsSub=!1,this.length>=this.maxLength){this._rejectDigits=!0;return}if(t<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=t>oi?oi:t}addSubParam(t){if(this._digitIsSub=!0,!!this.length){if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength){this._rejectSubDigits=!0;return}if(t<-1)throw new Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=t>oi?oi:t,this._subParamsIdx[this.length-1]++}}hasSubParams(t){return(this._subParamsIdx[t]&255)-(this._subParamsIdx[t]>>8)>0}getSubParams(t){let i=this._subParamsIdx[t]>>8,s=this._subParamsIdx[t]&255;return s-i>0?this._subParams.subarray(i,s):null}getSubParamsAll(){let t={};for(let i=0;i>8,r=this._subParamsIdx[i]&255;r-s>0&&(t[i]=this._subParams.slice(s,r))}return t}addDigit(t){let i;if(this._rejectDigits||!(i=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let s=this._digitIsSub?this._subParams:this.params,r=s[i-1];s[i-1]=~r?Math.min(r*10+t,oi):t}},ai=[],ad=class{constructor(){this._state=0,this._active=ai,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let i=this._handlers[e];return i.push(t),{dispose:()=>{let s=i.indexOf(t);s!==-1&&i.splice(s,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=ai}reset(){if(this._state===2)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].end(!1);this._stack.paused=!1,this._active=ai,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||ai,!this._active.length)this._handlerFb(this._id,"START");else for(let e=this._active.length-1;e>=0;e--)this._active[e].start()}_put(e,t,i){if(!this._active.length)this._handlerFb(this._id,"PUT",ls(e,t,i));else for(let s=this._active.length-1;s>=0;s--)this._active[s].put(e,t,i)}start(){this.reset(),this._state=1}put(e,t,i){if(this._state!==3){if(this._state===1)for(;t0&&this._put(e,t,i)}}end(e,t=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),!this._active.length)this._handlerFb(this._id,"END",e);else{let i=!1,s=this._active.length-1,r=!1;if(this._stack.paused&&(s=this._stack.loopPosition-1,i=t,r=this._stack.fallThrough,this._stack.paused=!1),!r&&i===!1){for(;s>=0&&(i=this._active[s].end(e),i!==!0);s--)if(i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!1,i;s--}for(;s>=0;s--)if(i=this._active[s].end(!1),i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!0,i}this._active=ai,this._id=-1,this._state=0}}},Ke=class{constructor(e){this._handler=e,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(e,t,i){this._hitLimit||(this._data+=ls(e,t,i),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}end(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data),t instanceof Promise))return t.then(i=>(this._data="",this._hitLimit=!1,i));return this._data="",this._hitLimit=!1,t}},li=[],ld=class{constructor(){this._handlers=Object.create(null),this._active=li,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=li}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let i=this._handlers[e];return i.push(t),{dispose:()=>{let s=i.indexOf(t);s!==-1&&i.splice(s,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}reset(){if(this._active.length)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].unhook(!1);this._stack.paused=!1,this._active=li,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||li,!this._active.length)this._handlerFb(this._ident,"HOOK",t);else for(let i=this._active.length-1;i>=0;i--)this._active[i].hook(t)}put(e,t,i){if(!this._active.length)this._handlerFb(this._ident,"PUT",ls(e,t,i));else for(let s=this._active.length-1;s>=0;s--)this._active[s].put(e,t,i)}unhook(e,t=!0){if(!this._active.length)this._handlerFb(this._ident,"UNHOOK",e);else{let i=!1,s=this._active.length-1,r=!1;if(this._stack.paused&&(s=this._stack.loopPosition-1,i=t,r=this._stack.fallThrough,this._stack.paused=!1),!r&&i===!1){for(;s>=0&&(i=this._active[s].unhook(e),i!==!0);s--)if(i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!1,i;s--}for(;s>=0;s--)if(i=this._active[s].unhook(!1),i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!0,i}this._active=li,this._ident=0}},pi=new xa;pi.addParam(0);var Mn=class{constructor(e){this._handler=e,this._data="",this._params=pi,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():pi,this._data="",this._hitLimit=!1}put(e,t,i){this._hitLimit||(this._data+=ls(e,t,i),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}unhook(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data,this._params),t instanceof Promise))return t.then(i=>(this._params=pi,this._data="",this._hitLimit=!1,i));return this._params=pi,this._data="",this._hitLimit=!1,t}},hd=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,t){this.table.fill(e<<4|t)}add(e,t,i,s){this.table[t<<8|e]=i<<4|s}addMany(e,t,i,s){for(let r=0;rh),i=(a,h)=>t.slice(a,h),s=i(32,127),r=i(0,24);r.push(25),r.push.apply(r,i(28,32));let n=i(0,14),o;e.setDefault(1,0),e.addMany(s,0,2,0);for(o in n)e.addMany([24,26,153,154],o,3,0),e.addMany(i(128,144),o,3,0),e.addMany(i(144,152),o,3,0),e.add(156,o,0,0),e.add(27,o,11,1),e.add(157,o,4,8),e.addMany([152,158,159],o,0,7),e.add(155,o,11,3),e.add(144,o,11,9);return e.addMany(r,0,3,0),e.addMany(r,1,3,1),e.add(127,1,0,1),e.addMany(r,8,0,8),e.addMany(r,3,3,3),e.add(127,3,0,3),e.addMany(r,4,3,4),e.add(127,4,0,4),e.addMany(r,6,3,6),e.addMany(r,5,3,5),e.add(127,5,0,5),e.addMany(r,2,3,2),e.add(127,2,0,2),e.add(93,1,4,8),e.addMany(s,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(i(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(s,7,0,7),e.addMany(r,7,0,7),e.add(156,7,0,0),e.add(127,7,0,7),e.add(91,1,11,3),e.addMany(i(64,127),3,7,0),e.addMany(i(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(i(48,60),4,8,4),e.addMany(i(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(i(32,64),6,0,6),e.add(127,6,0,6),e.addMany(i(64,127),6,0,0),e.addMany(i(32,48),3,9,5),e.addMany(i(32,48),5,9,5),e.addMany(i(48,64),5,0,6),e.addMany(i(64,127),5,7,0),e.addMany(i(32,48),4,9,5),e.addMany(i(32,48),1,9,2),e.addMany(i(32,48),2,9,2),e.addMany(i(48,127),2,10,0),e.addMany(i(48,80),1,10,0),e.addMany(i(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(i(96,127),1,10,0),e.add(80,1,11,9),e.addMany(r,9,0,9),e.add(127,9,0,9),e.addMany(i(28,32),9,0,9),e.addMany(i(32,48),9,9,12),e.addMany(i(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(r,11,0,11),e.addMany(i(32,128),11,0,11),e.addMany(i(28,32),11,0,11),e.addMany(r,10,0,10),e.add(127,10,0,10),e.addMany(i(28,32),10,0,10),e.addMany(i(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(i(32,48),10,9,12),e.addMany(r,12,0,12),e.add(127,12,0,12),e.addMany(i(28,32),12,0,12),e.addMany(i(32,48),12,9,12),e.addMany(i(48,64),12,0,11),e.addMany(i(64,127),12,12,13),e.addMany(i(64,127),10,12,13),e.addMany(i(64,127),9,12,13),e.addMany(r,13,13,13),e.addMany(s,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(Xe,0,2,0),e.add(Xe,8,5,8),e.add(Xe,6,0,6),e.add(Xe,11,0,11),e.add(Xe,13,13,13),e})(),dd=class extends G{constructor(e=cd){super(),this._transitions=e,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new xa,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(t,i,s)=>{},this._executeHandlerFb=t=>{},this._csiHandlerFb=(t,i)=>{},this._escHandlerFb=t=>{},this._errorHandlerFb=t=>t,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this._register(oe(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new ad),this._dcsParser=this._register(new ld),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(e,t=[64,126]){let i=0;if(e.prefix){if(e.prefix.length>1)throw new Error("only one byte as prefix supported");if(i=e.prefix.charCodeAt(0),i&&60>i||i>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(e.intermediates){if(e.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let r=0;rn||n>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");i<<=8,i|=n}}if(e.final.length!==1)throw new Error("final must be a single byte");let s=e.final.charCodeAt(0);if(t[0]>s||s>t[1])throw new Error(`final must be in range ${t[0]} .. ${t[1]}`);return i<<=8,i|=s,i}identToString(e){let t=[];for(;e;)t.push(String.fromCharCode(e&255)),e>>=8;return t.reverse().join("")}setPrintHandler(e){this._printHandler=e}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(e,t){let i=this._identifier(e,[48,126]);this._escHandlers[i]===void 0&&(this._escHandlers[i]=[]);let s=this._escHandlers[i];return s.push(t),{dispose:()=>{let r=s.indexOf(t);r!==-1&&s.splice(r,1)}}}clearEscHandler(e){this._escHandlers[this._identifier(e,[48,126])]&&delete this._escHandlers[this._identifier(e,[48,126])]}setEscHandlerFallback(e){this._escHandlerFb=e}setExecuteHandler(e,t){this._executeHandlers[e.charCodeAt(0)]=t}clearExecuteHandler(e){this._executeHandlers[e.charCodeAt(0)]&&delete this._executeHandlers[e.charCodeAt(0)]}setExecuteHandlerFallback(e){this._executeHandlerFb=e}registerCsiHandler(e,t){let i=this._identifier(e);this._csiHandlers[i]===void 0&&(this._csiHandlers[i]=[]);let s=this._csiHandlers[i];return s.push(t),{dispose:()=>{let r=s.indexOf(t);r!==-1&&s.splice(r,1)}}}clearCsiHandler(e){this._csiHandlers[this._identifier(e)]&&delete this._csiHandlers[this._identifier(e)]}setCsiHandlerFallback(e){this._csiHandlerFb=e}registerDcsHandler(e,t){return this._dcsParser.registerHandler(this._identifier(e),t)}clearDcsHandler(e){this._dcsParser.clearHandler(this._identifier(e))}setDcsHandlerFallback(e){this._dcsParser.setHandlerFallback(e)}registerOscHandler(e,t){return this._oscParser.registerHandler(e,t)}clearOscHandler(e){this._oscParser.clearHandler(e)}setOscHandlerFallback(e){this._oscParser.setHandlerFallback(e)}setErrorHandler(e){this._errorHandler=e}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(e,t,i,s,r){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=i,this._parseStack.transition=s,this._parseStack.chunkPos=r}parse(e,t,i){let s=0,r=0,n=0,o;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,n=this._parseStack.chunkPos+1;else{if(i===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");let a=this._parseStack.handlers,h=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(i===!1&&h>-1){for(;h>=0&&(o=a[h](this._params),o!==!0);h--)if(o instanceof Promise)return this._parseStack.handlerPos=h,o}this._parseStack.handlers=[];break;case 4:if(i===!1&&h>-1){for(;h>=0&&(o=a[h](),o!==!0);h--)if(o instanceof Promise)return this._parseStack.handlerPos=h,o}this._parseStack.handlers=[];break;case 6:if(s=e[this._parseStack.chunkPos],o=this._dcsParser.unhook(s!==24&&s!==26,i),o)return o;s===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(s=e[this._parseStack.chunkPos],o=this._oscParser.end(s!==24&&s!==26,i),o)return o;s===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break}this._parseStack.state=0,n=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&15}for(let a=n;a>4){case 2:for(let u=a+1;;++u){if(u>=t||(s=e[u])<32||s>126&&s=t||(s=e[u])<32||s>126&&s=t||(s=e[u])<32||s>126&&s=t||(s=e[u])<32||s>126&&s=0&&(o=h[l](this._params),o!==!0);l--)if(o instanceof Promise)return this._preserveStack(3,h,l,r,a),o;l<0&&this._csiHandlerFb(this._collect<<8|s,this._params),this.precedingJoinState=0;break;case 8:do switch(s){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(s-48)}while(++a47&&s<60);a--;break;case 9:this._collect<<=8,this._collect|=s;break;case 10:let c=this._escHandlers[this._collect<<8|s],d=c?c.length-1:-1;for(;d>=0&&(o=c[d](),o!==!0);d--)if(o instanceof Promise)return this._preserveStack(4,c,d,r,a),o;d<0&&this._escHandlerFb(this._collect<<8|s),this.precedingJoinState=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|s,this._params);break;case 13:for(let u=a+1;;++u)if(u>=t||(s=e[u])===24||s===26||s===27||s>127&&s=t||(s=e[u])<32||s>127&&s>4:n>>8}return s}}function ks(e,t){let i=e.toString(16),s=i.length<2?"0"+i:i;switch(t){case 4:return i[0];case 8:return s;case 12:return(s+s).slice(0,3);default:return s+s}}function fd(e,t=16){let[i,s,r]=e;return`rgb:${ks(i,t)}/${ks(s,t)}/${ks(r,t)}`}var pd={"(":0,")":1,"*":2,"+":3,"-":1,".":2},vt=131072,Ln=10;function Tn(e,t){if(e>24)return t.setWinLines||!1;switch(e){case 1:return!!t.restoreWin;case 2:return!!t.minimizeWin;case 3:return!!t.setWinPosition;case 4:return!!t.setWinSizePixels;case 5:return!!t.raiseWin;case 6:return!!t.lowerWin;case 7:return!!t.refreshWin;case 8:return!!t.setWinSizeChars;case 9:return!!t.maximizeWin;case 10:return!!t.fullscreenWin;case 11:return!!t.getWinState;case 13:return!!t.getWinPosition;case 14:return!!t.getWinSizePixels;case 15:return!!t.getScreenSizePixels;case 16:return!!t.getCellSizePixels;case 18:return!!t.getWinSizeChars;case 19:return!!t.getScreenSizeChars;case 20:return!!t.getIconTitle;case 21:return!!t.getWinTitle;case 22:return!!t.pushTitle;case 23:return!!t.popTitle;case 24:return!!t.setWinLines}return!1}var $n=5e3,An=0,md=class extends G{constructor(e,t,i,s,r,n,o,a,h=new dd){super(),this._bufferService=e,this._charsetService=t,this._coreService=i,this._logService=s,this._optionsService=r,this._oscLinkService=n,this._coreMouseService=o,this._unicodeService=a,this._parser=h,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new Pl,this._utf8Decoder=new Nl,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=me.clone(),this._eraseAttrDataInternal=me.clone(),this._onRequestBell=this._register(new k),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new k),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new k),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new k),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new k),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new k),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new k),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new k),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new k),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new k),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new k),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new k),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new k),this.onColor=this._onColor.event,this._parseStack={paused:!1,cursorStartX:0,cursorStartY:0,decodedLength:0,position:0},this._specialColors=[256,257,258],this._register(this._parser),this._dirtyRowTracker=new gr(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(l=>this._activeBuffer=l.activeBuffer)),this._parser.setCsiHandlerFallback((l,c)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(l),params:c.toArray()})}),this._parser.setEscHandlerFallback(l=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(l)})}),this._parser.setExecuteHandlerFallback(l=>{this._logService.debug("Unknown EXECUTE code: ",{code:l})}),this._parser.setOscHandlerFallback((l,c,d)=>{this._logService.debug("Unknown OSC code: ",{identifier:l,action:c,data:d})}),this._parser.setDcsHandlerFallback((l,c,d)=>{c==="HOOK"&&(d=d.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(l),action:c,payload:d})}),this._parser.setPrintHandler((l,c,d)=>this.print(l,c,d)),this._parser.registerCsiHandler({final:"@"},l=>this.insertChars(l)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},l=>this.scrollLeft(l)),this._parser.registerCsiHandler({final:"A"},l=>this.cursorUp(l)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},l=>this.scrollRight(l)),this._parser.registerCsiHandler({final:"B"},l=>this.cursorDown(l)),this._parser.registerCsiHandler({final:"C"},l=>this.cursorForward(l)),this._parser.registerCsiHandler({final:"D"},l=>this.cursorBackward(l)),this._parser.registerCsiHandler({final:"E"},l=>this.cursorNextLine(l)),this._parser.registerCsiHandler({final:"F"},l=>this.cursorPrecedingLine(l)),this._parser.registerCsiHandler({final:"G"},l=>this.cursorCharAbsolute(l)),this._parser.registerCsiHandler({final:"H"},l=>this.cursorPosition(l)),this._parser.registerCsiHandler({final:"I"},l=>this.cursorForwardTab(l)),this._parser.registerCsiHandler({final:"J"},l=>this.eraseInDisplay(l,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},l=>this.eraseInDisplay(l,!0)),this._parser.registerCsiHandler({final:"K"},l=>this.eraseInLine(l,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},l=>this.eraseInLine(l,!0)),this._parser.registerCsiHandler({final:"L"},l=>this.insertLines(l)),this._parser.registerCsiHandler({final:"M"},l=>this.deleteLines(l)),this._parser.registerCsiHandler({final:"P"},l=>this.deleteChars(l)),this._parser.registerCsiHandler({final:"S"},l=>this.scrollUp(l)),this._parser.registerCsiHandler({final:"T"},l=>this.scrollDown(l)),this._parser.registerCsiHandler({final:"X"},l=>this.eraseChars(l)),this._parser.registerCsiHandler({final:"Z"},l=>this.cursorBackwardTab(l)),this._parser.registerCsiHandler({final:"`"},l=>this.charPosAbsolute(l)),this._parser.registerCsiHandler({final:"a"},l=>this.hPositionRelative(l)),this._parser.registerCsiHandler({final:"b"},l=>this.repeatPrecedingCharacter(l)),this._parser.registerCsiHandler({final:"c"},l=>this.sendDeviceAttributesPrimary(l)),this._parser.registerCsiHandler({prefix:">",final:"c"},l=>this.sendDeviceAttributesSecondary(l)),this._parser.registerCsiHandler({final:"d"},l=>this.linePosAbsolute(l)),this._parser.registerCsiHandler({final:"e"},l=>this.vPositionRelative(l)),this._parser.registerCsiHandler({final:"f"},l=>this.hVPosition(l)),this._parser.registerCsiHandler({final:"g"},l=>this.tabClear(l)),this._parser.registerCsiHandler({final:"h"},l=>this.setMode(l)),this._parser.registerCsiHandler({prefix:"?",final:"h"},l=>this.setModePrivate(l)),this._parser.registerCsiHandler({final:"l"},l=>this.resetMode(l)),this._parser.registerCsiHandler({prefix:"?",final:"l"},l=>this.resetModePrivate(l)),this._parser.registerCsiHandler({final:"m"},l=>this.charAttributes(l)),this._parser.registerCsiHandler({final:"n"},l=>this.deviceStatus(l)),this._parser.registerCsiHandler({prefix:"?",final:"n"},l=>this.deviceStatusPrivate(l)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},l=>this.softReset(l)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},l=>this.setCursorStyle(l)),this._parser.registerCsiHandler({final:"r"},l=>this.setScrollRegion(l)),this._parser.registerCsiHandler({final:"s"},l=>this.saveCursor(l)),this._parser.registerCsiHandler({final:"t"},l=>this.windowOptions(l)),this._parser.registerCsiHandler({final:"u"},l=>this.restoreCursor(l)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},l=>this.insertColumns(l)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},l=>this.deleteColumns(l)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},l=>this.selectProtected(l)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},l=>this.requestMode(l,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},l=>this.requestMode(l,!1)),this._parser.setExecuteHandler(v.BEL,()=>this.bell()),this._parser.setExecuteHandler(v.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(v.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(v.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(v.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(v.BS,()=>this.backspace()),this._parser.setExecuteHandler(v.HT,()=>this.tab()),this._parser.setExecuteHandler(v.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(v.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(ji.IND,()=>this.index()),this._parser.setExecuteHandler(ji.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(ji.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new Ke(l=>(this.setTitle(l),this.setIconName(l),!0))),this._parser.registerOscHandler(1,new Ke(l=>this.setIconName(l))),this._parser.registerOscHandler(2,new Ke(l=>this.setTitle(l))),this._parser.registerOscHandler(4,new Ke(l=>this.setOrReportIndexedColor(l))),this._parser.registerOscHandler(8,new Ke(l=>this.setHyperlink(l))),this._parser.registerOscHandler(10,new Ke(l=>this.setOrReportFgColor(l))),this._parser.registerOscHandler(11,new Ke(l=>this.setOrReportBgColor(l))),this._parser.registerOscHandler(12,new Ke(l=>this.setOrReportCursorColor(l))),this._parser.registerOscHandler(104,new Ke(l=>this.restoreIndexedColor(l))),this._parser.registerOscHandler(110,new Ke(l=>this.restoreFgColor(l))),this._parser.registerOscHandler(111,new Ke(l=>this.restoreBgColor(l))),this._parser.registerOscHandler(112,new Ke(l=>this.restoreCursorColor(l))),this._parser.registerEscHandler({final:"7"},()=>this.saveCursor()),this._parser.registerEscHandler({final:"8"},()=>this.restoreCursor()),this._parser.registerEscHandler({final:"D"},()=>this.index()),this._parser.registerEscHandler({final:"E"},()=>this.nextLine()),this._parser.registerEscHandler({final:"H"},()=>this.tabSet()),this._parser.registerEscHandler({final:"M"},()=>this.reverseIndex()),this._parser.registerEscHandler({final:"="},()=>this.keypadApplicationMode()),this._parser.registerEscHandler({final:">"},()=>this.keypadNumericMode()),this._parser.registerEscHandler({final:"c"},()=>this.fullReset()),this._parser.registerEscHandler({final:"n"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"o"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"|"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"}"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"~"},()=>this.setgLevel(1)),this._parser.registerEscHandler({intermediates:"%",final:"@"},()=>this.selectDefaultCharset()),this._parser.registerEscHandler({intermediates:"%",final:"G"},()=>this.selectDefaultCharset());for(let l in we)this._parser.registerEscHandler({intermediates:"(",final:l},()=>this.selectCharset("("+l)),this._parser.registerEscHandler({intermediates:")",final:l},()=>this.selectCharset(")"+l)),this._parser.registerEscHandler({intermediates:"*",final:l},()=>this.selectCharset("*"+l)),this._parser.registerEscHandler({intermediates:"+",final:l},()=>this.selectCharset("+"+l)),this._parser.registerEscHandler({intermediates:"-",final:l},()=>this.selectCharset("-"+l)),this._parser.registerEscHandler({intermediates:".",final:l},()=>this.selectCharset("."+l)),this._parser.registerEscHandler({intermediates:"/",final:l},()=>this.selectCharset("/"+l));this._parser.registerEscHandler({intermediates:"#",final:"8"},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(l=>(this._logService.error("Parsing error: ",l),l)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new Mn((l,c)=>this.requestStatusString(l,c)))}getAttrData(){return this._curAttrData}_preserveStack(e,t,i,s){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=t,this._parseStack.decodedLength=i,this._parseStack.position=s}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((t,i)=>setTimeout(()=>i("#SLOW_TIMEOUT"),$n))]).catch(t=>{if(t!=="#SLOW_TIMEOUT")throw t;console.warn(`async parser handler taking longer than ${$n} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let i,s=this._activeBuffer.x,r=this._activeBuffer.y,n=0,o=this._parseStack.paused;if(o){if(i=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t))return this._logSlowResolvingAsync(i),i;s=this._parseStack.cursorStartX,r=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>vt&&(n=this._parseStack.position+vt)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof e=="string"?` "${e}"`:` "${Array.prototype.map.call(e,l=>String.fromCharCode(l)).join("")}"`}`),this._logService.logLevel===0&&this._logService.trace("parsing data (codes)",typeof e=="string"?e.split("").map(l=>l.charCodeAt(0)):e),this._parseBuffer.lengthvt)for(let l=n;l0&&d.getWidth(this._activeBuffer.x-1)===2&&d.setCellFromCodepoint(this._activeBuffer.x-1,0,1,c);let u=this._parser.precedingJoinState;for(let f=t;fa){if(h){let E=d,z=this._activeBuffer.x-g;for(this._activeBuffer.x=g,this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData(),!0)):(this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!0),d=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),g>0&&d instanceof _i&&d.copyCellsFrom(E,z,0,g,!1);z=0;)d.setCellFromCodepoint(this._activeBuffer.x++,0,0,c);continue}if(l&&(d.insertCells(this._activeBuffer.x,r-g,this._activeBuffer.getNullCell(c)),d.getWidth(a-1)===2&&d.setCellFromCodepoint(a-1,0,1,c)),d.setCellFromCodepoint(this._activeBuffer.x++,s,r,c),r>0)for(;--r;)d.setCellFromCodepoint(this._activeBuffer.x++,0,0,c)}this._parser.precedingJoinState=u,this._activeBuffer.x0&&d.getWidth(this._activeBuffer.x)===0&&!d.hasContent(this._activeBuffer.x)&&d.setCellFromCodepoint(this._activeBuffer.x,0,1,c),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,t){return e.final==="t"&&!e.prefix&&!e.intermediates?this._parser.registerCsiHandler(e,i=>Tn(i.params[0],this._optionsService.rawOptions.windowOptions)?t(i):!0):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new Mn(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new Ke(t))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){var e;if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&((e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y))!=null&&e.isWrapped)){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);t.hasWidth(this._activeBuffer.x)&&!t.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-e),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(e=this._bufferService.cols-1){this._activeBuffer.x=Math.min(e,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(e,t){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=e,this._activeBuffer.y=this._activeBuffer.scrollTop+t):(this._activeBuffer.x=e,this._activeBuffer.y=t),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(e,t){this._restrictCursor(),this._setCursor(this._activeBuffer.x+e,this._activeBuffer.y+t)}cursorUp(e){let t=this._activeBuffer.y-this._activeBuffer.scrollTop;return t>=0?this._moveCursor(0,-Math.min(t,e.params[0]||1)):this._moveCursor(0,-(e.params[0]||1)),!0}cursorDown(e){let t=this._activeBuffer.scrollBottom-this._activeBuffer.y;return t>=0?this._moveCursor(0,Math.min(t,e.params[0]||1)):this._moveCursor(0,e.params[0]||1),!0}cursorForward(e){return this._moveCursor(e.params[0]||1,0),!0}cursorBackward(e){return this._moveCursor(-(e.params[0]||1),0),!0}cursorNextLine(e){return this.cursorDown(e),this._activeBuffer.x=0,!0}cursorPrecedingLine(e){return this.cursorUp(e),this._activeBuffer.x=0,!0}cursorCharAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(e){return this._setCursor(e.length>=2?(e.params[1]||1)-1:0,(e.params[0]||1)-1),!0}charPosAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(e){return this._moveCursor(e.params[0]||1,0),!0}linePosAbsolute(e){return this._setCursor(this._activeBuffer.x,(e.params[0]||1)-1),!0}vPositionRelative(e){return this._moveCursor(0,e.params[0]||1),!0}hVPosition(e){return this.cursorPosition(e),!0}tabClear(e){let t=e.params[0];return t===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:t===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(e){let t=e.params[0];return t===1&&(this._curAttrData.bg|=536870912),(t===2||t===0)&&(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(e,t,i,s=!1,r=!1){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n.replaceCells(t,i,this._activeBuffer.getNullCell(this._eraseAttrData()),r),s&&(n.isWrapped=!1)}_resetBufferLine(e,t=!1){let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);i&&(i.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),t),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),i.isWrapped=!1)}eraseInDisplay(e,t=!1){var s;this._restrictCursor(this._bufferService.cols);let i;switch(e.params[0]){case 0:for(i=this._activeBuffer.y,this._dirtyRowTracker.markDirty(i),this._eraseInBufferLine(i++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);i=this._bufferService.cols&&(this._activeBuffer.lines.get(i+1).isWrapped=!1);i--;)this._resetBufferLine(i,t);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(i=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,i-1);i--&&!((s=this._activeBuffer.lines.get(this._activeBuffer.ybase+i))!=null&&s.getTrimmedLength()););for(;i>=0;i--)this._bufferService.scroll(this._eraseAttrData())}else{for(i=this._bufferService.rows,this._dirtyRowTracker.markDirty(i-1);i--;)this._resetBufferLine(i,t);this._dirtyRowTracker.markDirty(0)}break;case 3:let r=this._activeBuffer.lines.length-this._bufferService.rows;r>0&&(this._activeBuffer.lines.trimStart(r),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-r,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-r,0),this._onScroll.fire(0));break}return!0}eraseInLine(e,t=!1){switch(this._restrictCursor(this._bufferService.cols),e.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,t);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,t);break}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.ythis._activeBuffer.scrollBottom||this._activeBuffer.ythis._activeBuffer.scrollBottom||this._activeBuffer.ythis._activeBuffer.scrollBottom||this._activeBuffer.ythis._activeBuffer.scrollBottom||this._activeBuffer.ythis._activeBuffer.scrollBottom||this._activeBuffer.y65535?2:1}let h=a;for(let l=1;l0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(v.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(v.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(v.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(v.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(v.ESC+"[>83;40003;0c")),!0}_is(e){return(this._optionsService.rawOptions.termName+"").indexOf(e)===0}setMode(e){for(let t=0;t(p[p.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",p[p.SET=1]="SET",p[p.RESET=2]="RESET",p[p.PERMANENTLY_SET=3]="PERMANENTLY_SET",p[p.PERMANENTLY_RESET=4]="PERMANENTLY_RESET"))(void 0||(i={}));let s=this._coreService.decPrivateModes,{activeProtocol:r,activeEncoding:n}=this._coreMouseService,o=this._coreService,{buffers:a,cols:h}=this._bufferService,{active:l,alt:c}=a,d=this._optionsService.rawOptions,u=(p,g)=>(o.triggerDataEvent(`${v.ESC}[${t?"":"?"}${p};${g}$y`),!0),f=p=>p?1:2,_=e.params[0];return t?_===2?u(_,4):_===4?u(_,f(o.modes.insertMode)):_===12?u(_,3):_===20?u(_,f(d.convertEol)):u(_,0):_===1?u(_,f(s.applicationCursorKeys)):_===3?u(_,d.windowOptions.setWinLines?h===80?2:h===132?1:0:0):_===6?u(_,f(s.origin)):_===7?u(_,f(s.wraparound)):_===8?u(_,3):_===9?u(_,f(r==="X10")):_===12?u(_,f(d.cursorBlink)):_===25?u(_,f(!o.isCursorHidden)):_===45?u(_,f(s.reverseWraparound)):_===66?u(_,f(s.applicationKeypad)):_===67?u(_,4):_===1e3?u(_,f(r==="VT200")):_===1002?u(_,f(r==="DRAG")):_===1003?u(_,f(r==="ANY")):_===1004?u(_,f(s.sendFocus)):_===1005?u(_,4):_===1006?u(_,f(n==="SGR")):_===1015?u(_,4):_===1016?u(_,f(n==="SGR_PIXELS")):_===1048?u(_,1):_===47||_===1047||_===1049?u(_,f(l===c)):_===2004?u(_,f(s.bracketedPasteMode)):_===2026?u(_,f(s.synchronizedOutput)):u(_,0)}_updateAttrColor(e,t,i,s,r){return t===2?(e|=50331648,e&=-16777216,e|=Ci.fromColorRGB([i,s,r])):t===5&&(e&=-50331904,e|=33554432|i&255),e}_extractColor(e,t,i){let s=[0,0,-1,0,0,0],r=0,n=0;do{if(s[n+r]=e.params[t+n],e.hasSubParams(t+n)){let o=e.getSubParams(t+n),a=0;do s[1]===5&&(r=1),s[n+a+1+r]=o[a];while(++a=2||s[1]===2&&n+r>=5)break;s[1]&&(r=1)}while(++n+t5)&&(e=1),t.extended.underlineStyle=e,t.fg|=268435456,e===0&&(t.fg&=-268435457),t.updateExtended()}_processSGR0(e){e.fg=me.fg,e.bg=me.bg,e.extended=e.extended.clone(),e.extended.underlineStyle=0,e.extended.underlineColor&=-67108864,e.updateExtended()}charAttributes(e){if(e.length===1&&e.params[0]===0)return this._processSGR0(this._curAttrData),!0;let t=e.length,i,s=this._curAttrData;for(let r=0;r=30&&i<=37?(s.fg&=-50331904,s.fg|=16777216|i-30):i>=40&&i<=47?(s.bg&=-50331904,s.bg|=16777216|i-40):i>=90&&i<=97?(s.fg&=-50331904,s.fg|=16777216|i-90|8):i>=100&&i<=107?(s.bg&=-50331904,s.bg|=16777216|i-100|8):i===0?this._processSGR0(s):i===1?s.fg|=134217728:i===3?s.bg|=67108864:i===4?(s.fg|=268435456,this._processUnderline(e.hasSubParams(r)?e.getSubParams(r)[0]:1,s)):i===5?s.fg|=536870912:i===7?s.fg|=67108864:i===8?s.fg|=1073741824:i===9?s.fg|=2147483648:i===2?s.bg|=134217728:i===21?this._processUnderline(2,s):i===22?(s.fg&=-134217729,s.bg&=-134217729):i===23?s.bg&=-67108865:i===24?(s.fg&=-268435457,this._processUnderline(0,s)):i===25?s.fg&=-536870913:i===27?s.fg&=-67108865:i===28?s.fg&=-1073741825:i===29?s.fg&=2147483647:i===39?(s.fg&=-67108864,s.fg|=me.fg&16777215):i===49?(s.bg&=-67108864,s.bg|=me.bg&16777215):i===38||i===48||i===58?r+=this._extractColor(e,r,s):i===53?s.bg|=1073741824:i===55?s.bg&=-1073741825:i===59?(s.extended=s.extended.clone(),s.extended.underlineColor=-1,s.updateExtended()):i===100?(s.fg&=-67108864,s.fg|=me.fg&16777215,s.bg&=-67108864,s.bg|=me.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",i);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${v.ESC}[0n`);break;case 6:let t=this._activeBuffer.y+1,i=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${v.ESC}[${t};${i}R`);break}return!0}deviceStatusPrivate(e){switch(e.params[0]){case 6:let t=this._activeBuffer.y+1,i=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${v.ESC}[?${t};${i}R`);break}return!0}softReset(e){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=me.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(e){let t=e.length===0?1:e.params[0];if(t===0)this._coreService.decPrivateModes.cursorStyle=void 0,this._coreService.decPrivateModes.cursorBlink=void 0;else{switch(t){case 1:case 2:this._coreService.decPrivateModes.cursorStyle="block";break;case 3:case 4:this._coreService.decPrivateModes.cursorStyle="underline";break;case 5:case 6:this._coreService.decPrivateModes.cursorStyle="bar";break}let i=t%2===1;this._coreService.decPrivateModes.cursorBlink=i}return!0}setScrollRegion(e){let t=e.params[0]||1,i;return(e.length<2||(i=e.params[1])>this._bufferService.rows||i===0)&&(i=this._bufferService.rows),i>t&&(this._activeBuffer.scrollTop=t-1,this._activeBuffer.scrollBottom=i-1,this._setCursor(0,0)),!0}windowOptions(e){if(!Tn(e.params[0],this._optionsService.rawOptions.windowOptions))return!0;let t=e.length>1?e.params[1]:0;switch(e.params[0]){case 14:t!==2&&this._onRequestWindowsOptionsReport.fire(0);break;case 16:this._onRequestWindowsOptionsReport.fire(1);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${v.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>Ln&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>Ln&&this._iconNameStack.shift());break;case 23:(t===0||t===2)&&this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),(t===0||t===1)&&this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop());break}return!0}saveCursor(e){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(e){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(e){return this._windowTitle=e,this._onTitleChange.fire(e),!0}setIconName(e){return this._iconName=e,!0}setOrReportIndexedColor(e){let t=[],i=e.split(";");for(;i.length>1;){let s=i.shift(),r=i.shift();if(/^\d+$/.exec(s)){let n=parseInt(s);if(Pn(n))if(r==="?")t.push({type:0,index:n});else{let o=Dn(r);o&&t.push({type:1,index:n,color:o})}}}return t.length&&this._onColor.fire(t),!0}setHyperlink(e){let t=e.indexOf(";");if(t===-1)return!0;let i=e.slice(0,t).trim(),s=e.slice(t+1);return s?this._createHyperlink(i,s):i.trim()?!1:this._finishHyperlink()}_createHyperlink(e,t){this._getCurrentLinkId()&&this._finishHyperlink();let i=e.split(":"),s,r=i.findIndex(n=>n.startsWith("id="));return r!==-1&&(s=i[r].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:s,uri:t}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(e,t){let i=e.split(";");for(let s=0;s=this._specialColors.length);++s,++t)if(i[s]==="?")this._onColor.fire([{type:0,index:this._specialColors[t]}]);else{let r=Dn(i[s]);r&&this._onColor.fire([{type:1,index:this._specialColors[t],color:r}])}return!0}setOrReportFgColor(e){return this._setOrReportSpecialColor(e,0)}setOrReportBgColor(e){return this._setOrReportSpecialColor(e,1)}setOrReportCursorColor(e){return this._setOrReportSpecialColor(e,2)}restoreIndexedColor(e){if(!e)return this._onColor.fire([{type:2}]),!0;let t=[],i=e.split(";");for(let s=0;s=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._restrictCursor(),!0}tabSet(){return this._activeBuffer.tabs[this._activeBuffer.x]=!0,!0}reverseIndex(){if(this._restrictCursor(),this._activeBuffer.y===this._activeBuffer.scrollTop){let e=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,e,1),this._activeBuffer.lines.set(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.getBlankLine(this._eraseAttrData())),this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom)}else this._activeBuffer.y--,this._restrictCursor();return!0}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),!0}reset(){this._curAttrData=me.clone(),this._eraseAttrDataInternal=me.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=this._curAttrData.bg&67108863,this._eraseAttrDataInternal}setgLevel(e){return this._charsetService.setgLevel(e),!0}screenAlignmentPattern(){let e=new Je;e.content=1<<22|69,e.fg=this._curAttrData.fg,e.bg=this._curAttrData.bg,this._setCursor(0,0);for(let t=0;t(this._coreService.triggerDataEvent(`${v.ESC}${o}${v.ESC}\\`),!0),s=this._bufferService.buffer,r=this._optionsService.rawOptions;return i(e==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:e==='"p'?'P1$r61;1"p':e==="r"?`P1$r${s.scrollTop+1};${s.scrollBottom+1}r`:e==="m"?"P1$r0m":e===" q"?`P1$r${{block:2,underline:4,bar:6}[r.cursorStyle]-(r.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(e,t){this._dirtyRowTracker.markRangeDirty(e,t)}},gr=class{constructor(e){this._bufferService=e,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(e){ethis.end&&(this.end=e)}markRangeDirty(e,t){e>t&&(An=e,e=t,t=An),ethis.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};gr=_e([T(0,Ie)],gr);function Pn(e){return 0<=e&&e<256}var gd=5e7,Nn=12,vd=50,Sd=class extends G{constructor(e){super(),this._action=e,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this._register(new k),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(e,t){if(t!==void 0&&this._syncCalls>t){this._syncCalls=0;return}if(this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;this._isSyncWriting=!0;let i;for(;i=this._writeBuffer.shift();){this._action(i);let s=this._callbacks.shift();s&&s()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,t){if(this._pendingData>gd)throw new Error("write data discarded, use flow control to avoid losing data");if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput){this._didUserInput=!1,this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t),this._innerWrite();return}setTimeout(()=>this._innerWrite())}this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t)}_innerWrite(e=0,t=!0){let i=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let s=this._writeBuffer[this._bufferOffset],r=this._action(s,t);if(r){let o=a=>performance.now()-i>=Nn?setTimeout(()=>this._innerWrite(0,a)):this._innerWrite(i,a);r.catch(a=>(queueMicrotask(()=>{throw a}),Promise.resolve(!1))).then(o);return}let n=this._callbacks[this._bufferOffset];if(n&&n(),this._bufferOffset++,this._pendingData-=s.length,performance.now()-i>=Nn)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>vd&&(this._writeBuffer=this._writeBuffer.slice(this._bufferOffset),this._callbacks=this._callbacks.slice(this._bufferOffset),this._bufferOffset=0),setTimeout(()=>this._innerWrite())):(this._writeBuffer.length=0,this._callbacks.length=0,this._pendingData=0,this._bufferOffset=0),this._onWriteParsed.fire()}},vr=class{constructor(e){this._bufferService=e,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(e){let t=this._bufferService.buffer;if(e.id===void 0){let a=t.addMarker(t.ybase+t.y),h={data:e,id:this._nextId++,lines:[a]};return a.onDispose(()=>this._removeMarkerFromLink(h,a)),this._dataByLinkId.set(h.id,h),h.id}let i=e,s=this._getEntryIdKey(i),r=this._entriesWithId.get(s);if(r)return this.addLineToLink(r.id,t.ybase+t.y),r.id;let n=t.addMarker(t.ybase+t.y),o={id:this._nextId++,key:this._getEntryIdKey(i),data:i,lines:[n]};return n.onDispose(()=>this._removeMarkerFromLink(o,n)),this._entriesWithId.set(o.key,o),this._dataByLinkId.set(o.id,o),o.id}addLineToLink(e,t){let i=this._dataByLinkId.get(e);if(i&&i.lines.every(s=>s.line!==t)){let s=this._bufferService.buffer.addMarker(t);i.lines.push(s),s.onDispose(()=>this._removeMarkerFromLink(i,s))}}getLinkData(e){var t;return(t=this._dataByLinkId.get(e))==null?void 0:t.data}_getEntryIdKey(e){return`${e.id};;${e.uri}`}_removeMarkerFromLink(e,t){let i=e.lines.indexOf(t);i!==-1&&(e.lines.splice(i,1),e.lines.length===0&&(e.data.id!==void 0&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};vr=_e([T(0,Ie)],vr);var In=!1,yd=class extends G{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new Yt),this._onBinary=this._register(new k),this.onBinary=this._onBinary.event,this._onData=this._register(new k),this.onData=this._onData.event,this._onLineFeed=this._register(new k),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new k),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new k),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new k),this._instantiationService=new jc,this.optionsService=this._register(new ed(e)),this._instantiationService.setService(Oe,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(_r)),this._instantiationService.setService(Ie,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(ur)),this._instantiationService.setService(Uo,this._logService),this.coreService=this._register(this._instantiationService.createInstance(fr)),this._instantiationService.setService(Nt,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(pr)),this._instantiationService.setService(zo,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(Tt)),this._instantiationService.setService(Hl,this.unicodeService),this._charsetService=this._instantiationService.createInstance(nd),this._instantiationService.setService(Fl,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(vr),this._instantiationService.setService(jo,this._oscLinkService),this._inputHandler=this._register(new md(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(Le.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(Le.forward(this._bufferService.onResize,this._onResize)),this._register(Le.forward(this.coreService.onData,this._onData)),this._register(Le.forward(this.coreService.onBinary,this._onBinary)),this._register(this.coreService.onRequestScrollToBottom(()=>this.scrollToBottom(!0))),this._register(this.coreService.onUserInput(()=>this._writeBuffer.handleUserInput())),this._register(this.optionsService.onMultipleOptionChange(["windowsMode","windowsPty"],()=>this._handleWindowsPtyOptionChange())),this._register(this._bufferService.onScroll(()=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)})),this._writeBuffer=this._register(new Sd((t,i)=>this._inputHandler.parse(t,i))),this._register(Le.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new k),this._onScroll.event(e=>{var t;(t=this._onScrollApi)==null||t.fire(e.position)})),this._onScrollApi.event}get cols(){return this._bufferService.cols}get rows(){return this._bufferService.rows}get buffers(){return this._bufferService.buffers}get options(){return this.optionsService.options}set options(e){for(let t in e)this.optionsService.options[t]=e[t]}write(e,t){this._writeBuffer.write(e,t)}writeSync(e,t){this._logService.logLevel<=3&&!In&&(this._logService.warn("writeSync is unreliable and will be removed soon."),In=!0),this._writeBuffer.writeSync(e,t)}input(e,t=!0){this.coreService.triggerDataEvent(e,t)}resize(e,t){isNaN(e)||isNaN(t)||(e=Math.max(e,wa),t=Math.max(t,Ca),this._bufferService.resize(e,t))}scroll(e,t=!1){this._bufferService.scroll(e,t)}scrollLines(e,t){this._bufferService.scrollLines(e,t)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}registerEscHandler(e,t){return this._inputHandler.registerEscHandler(e,t)}registerDcsHandler(e,t){return this._inputHandler.registerDcsHandler(e,t)}registerCsiHandler(e,t){return this._inputHandler.registerCsiHandler(e,t)}registerOscHandler(e,t){return this._inputHandler.registerOscHandler(e,t)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let e=!1,t=this.optionsService.rawOptions.windowsPty;t&&t.buildNumber!==void 0&&t.buildNumber!==void 0?e=t.backend==="conpty"&&t.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(e=!0),e?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){let e=[];e.push(this.onLineFeed(Bn.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(Bn(this._bufferService),!1))),this._windowsWrappingHeuristics.value=oe(()=>{for(let t of e)t.dispose()})}}},bd={48:["0",")"],49:["1","!"],50:["2","@"],51:["3","#"],52:["4","$"],53:["5","%"],54:["6","^"],55:["7","&"],56:["8","*"],57:["9","("],186:[";",":"],187:["=","+"],188:[",","<"],189:["-","_"],190:[".",">"],191:["/","?"],192:["`","~"],219:["[","{"],220:["\\","|"],221:["]","}"],222:["'",'"']};function wd(e,t,i,s){var o;let r={type:0,cancel:!1,key:void 0},n=(e.shiftKey?1:0)|(e.altKey?2:0)|(e.ctrlKey?4:0)|(e.metaKey?8:0);switch(e.keyCode){case 0:e.key==="UIKeyInputUpArrow"?t?r.key=v.ESC+"OA":r.key=v.ESC+"[A":e.key==="UIKeyInputLeftArrow"?t?r.key=v.ESC+"OD":r.key=v.ESC+"[D":e.key==="UIKeyInputRightArrow"?t?r.key=v.ESC+"OC":r.key=v.ESC+"[C":e.key==="UIKeyInputDownArrow"&&(t?r.key=v.ESC+"OB":r.key=v.ESC+"[B");break;case 8:r.key=e.ctrlKey?"\b":v.DEL,e.altKey&&(r.key=v.ESC+r.key);break;case 9:if(e.shiftKey){r.key=v.ESC+"[Z";break}r.key=v.HT,r.cancel=!0;break;case 13:r.key=e.altKey?v.ESC+v.CR:v.CR,r.cancel=!0;break;case 27:r.key=v.ESC,e.altKey&&(r.key=v.ESC+v.ESC),r.cancel=!0;break;case 37:if(e.metaKey)break;n?r.key=v.ESC+"[1;"+(n+1)+"D":t?r.key=v.ESC+"OD":r.key=v.ESC+"[D";break;case 39:if(e.metaKey)break;n?r.key=v.ESC+"[1;"+(n+1)+"C":t?r.key=v.ESC+"OC":r.key=v.ESC+"[C";break;case 38:if(e.metaKey)break;n?r.key=v.ESC+"[1;"+(n+1)+"A":t?r.key=v.ESC+"OA":r.key=v.ESC+"[A";break;case 40:if(e.metaKey)break;n?r.key=v.ESC+"[1;"+(n+1)+"B":t?r.key=v.ESC+"OB":r.key=v.ESC+"[B";break;case 45:!e.shiftKey&&!e.ctrlKey&&(r.key=v.ESC+"[2~");break;case 46:n?r.key=v.ESC+"[3;"+(n+1)+"~":r.key=v.ESC+"[3~";break;case 36:n?r.key=v.ESC+"[1;"+(n+1)+"H":t?r.key=v.ESC+"OH":r.key=v.ESC+"[H";break;case 35:n?r.key=v.ESC+"[1;"+(n+1)+"F":t?r.key=v.ESC+"OF":r.key=v.ESC+"[F";break;case 33:e.shiftKey?r.type=2:e.ctrlKey?r.key=v.ESC+"[5;"+(n+1)+"~":r.key=v.ESC+"[5~";break;case 34:e.shiftKey?r.type=3:e.ctrlKey?r.key=v.ESC+"[6;"+(n+1)+"~":r.key=v.ESC+"[6~";break;case 112:n?r.key=v.ESC+"[1;"+(n+1)+"P":r.key=v.ESC+"OP";break;case 113:n?r.key=v.ESC+"[1;"+(n+1)+"Q":r.key=v.ESC+"OQ";break;case 114:n?r.key=v.ESC+"[1;"+(n+1)+"R":r.key=v.ESC+"OR";break;case 115:n?r.key=v.ESC+"[1;"+(n+1)+"S":r.key=v.ESC+"OS";break;case 116:n?r.key=v.ESC+"[15;"+(n+1)+"~":r.key=v.ESC+"[15~";break;case 117:n?r.key=v.ESC+"[17;"+(n+1)+"~":r.key=v.ESC+"[17~";break;case 118:n?r.key=v.ESC+"[18;"+(n+1)+"~":r.key=v.ESC+"[18~";break;case 119:n?r.key=v.ESC+"[19;"+(n+1)+"~":r.key=v.ESC+"[19~";break;case 120:n?r.key=v.ESC+"[20;"+(n+1)+"~":r.key=v.ESC+"[20~";break;case 121:n?r.key=v.ESC+"[21;"+(n+1)+"~":r.key=v.ESC+"[21~";break;case 122:n?r.key=v.ESC+"[23;"+(n+1)+"~":r.key=v.ESC+"[23~";break;case 123:n?r.key=v.ESC+"[24;"+(n+1)+"~":r.key=v.ESC+"[24~";break;default:if(e.ctrlKey&&!e.shiftKey&&!e.altKey&&!e.metaKey)e.keyCode>=65&&e.keyCode<=90?r.key=String.fromCharCode(e.keyCode-64):e.keyCode===32?r.key=v.NUL:e.keyCode>=51&&e.keyCode<=55?r.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?r.key=v.DEL:e.keyCode===219?r.key=v.ESC:e.keyCode===220?r.key=v.FS:e.keyCode===221&&(r.key=v.GS);else if((!i||s)&&e.altKey&&!e.metaKey){let a=(o=bd[e.keyCode])==null?void 0:o[e.shiftKey?1:0];if(a)r.key=v.ESC+a;else if(e.keyCode>=65&&e.keyCode<=90){let h=e.ctrlKey?e.keyCode-64:e.keyCode+32,l=String.fromCharCode(h);e.shiftKey&&(l=l.toUpperCase()),r.key=v.ESC+l}else if(e.keyCode===32)r.key=v.ESC+(e.ctrlKey?v.NUL:" ");else if(e.key==="Dead"&&e.code.startsWith("Key")){let h=e.code.slice(3,4);e.shiftKey||(h=h.toLowerCase()),r.key=v.ESC+h,r.cancel=!0}}else i&&!e.altKey&&!e.ctrlKey&&!e.shiftKey&&e.metaKey?e.keyCode===65&&(r.type=1):e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.keyCode>=48&&e.key.length===1?r.key=e.key:e.key&&e.ctrlKey&&(e.key==="_"&&(r.key=v.US),e.key==="@"&&(r.key=v.NUL));break}return r}var fe=0,Cd=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new ns,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new ns,this._isFlushingDeleted=!1}clear(){this._array.length=0,this._insertedValues.length=0,this._flushInsertedTask.clear(),this._isFlushingInserted=!1,this._deletedIndices.length=0,this._flushDeletedTask.clear(),this._isFlushingDeleted=!1}insert(e){this._flushCleanupDeleted(),this._insertedValues.length===0&&this._flushInsertedTask.enqueue(()=>this._flushInserted()),this._insertedValues.push(e)}_flushInserted(){let e=this._insertedValues.sort((r,n)=>this._getKey(r)-this._getKey(n)),t=0,i=0,s=new Array(this._array.length+this._insertedValues.length);for(let r=0;r=this._array.length||this._getKey(e[t])<=this._getKey(this._array[i])?(s[r]=e[t],t++):s[r]=this._array[i++];this._array=s,this._insertedValues.length=0}_flushCleanupInserted(){!this._isFlushingInserted&&this._insertedValues.length>0&&this._flushInsertedTask.flush()}delete(e){if(this._flushCleanupInserted(),this._array.length===0)return!1;let t=this._getKey(e);if(t===void 0||(fe=this._search(t),fe===-1)||this._getKey(this._array[fe])!==t)return!1;do if(this._array[fe]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(fe),!0;while(++fer-n),t=0,i=new Array(this._array.length-e.length),s=0;for(let r=0;r0&&this._flushDeletedTask.flush()}*getKeyIterator(e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(fe=this._search(e),!(fe<0||fe>=this._array.length)&&this._getKey(this._array[fe])===e))do yield this._array[fe];while(++fe=this._array.length)&&this._getKey(this._array[fe])===e))do t(this._array[fe]);while(++fe=t;){let s=t+i>>1,r=this._getKey(this._array[s]);if(r>e)i=s-1;else if(r0&&this._getKey(this._array[s-1])===e;)s--;return s}}return t}},Es=0,On=0,xd=class extends G{constructor(){super(),this._decorations=new Cd(e=>e==null?void 0:e.marker.line),this._onDecorationRegistered=this._register(new k),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new k),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(oe(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new kd(e);if(t){let i=t.marker.onDispose(()=>t.dispose()),s=t.onDispose(()=>{s.dispose(),t&&(this._decorations.delete(t)&&this._onDecorationRemoved.fire(t),i.dispose())});this._decorations.insert(t),this._onDecorationRegistered.fire(t)}return t}reset(){for(let e of this._decorations.values())e.dispose();this._decorations.clear()}*getDecorationsAtCell(e,t,i){let s=0,r=0;for(let n of this._decorations.getKeyIterator(t))s=n.options.x??0,r=s+(n.options.width??1),e>=s&&e{Es=r.options.x??0,On=Es+(r.options.width??1),e>=Es&&e=this._debounceThresholdMS)this._lastRefreshMs=s,this._innerRefresh();else if(!this._additionalRefreshRequested){let r=s-this._lastRefreshMs,n=this._debounceThresholdMS-r;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},n)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t)}},Fn=20,os=class extends G{constructor(e,t,i,s){super(),this._terminal=e,this._coreBrowserService=i,this._renderService=s,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="";let r=this._coreBrowserService.mainDocument;this._accessibilityContainer=r.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=r.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let n=0;nthis._handleBoundaryFocus(n,0),this._bottomBoundaryFocusListener=n=>this._handleBoundaryFocus(n,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=r.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new Rd(this._renderRows.bind(this))),!this._terminal.element)throw new Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this._register(this._terminal.onResize(n=>this._handleResize(n.rows))),this._register(this._terminal.onRender(n=>this._refreshRows(n.start,n.end))),this._register(this._terminal.onScroll(()=>this._refreshRows())),this._register(this._terminal.onA11yChar(n=>this._handleChar(n))),this._register(this._terminal.onLineFeed(()=>this._handleChar(` -`))),this._register(this._terminal.onA11yTab(n=>this._handleTab(n))),this._register(this._terminal.onKey(n=>this._handleKey(n.key))),this._register(this._terminal.onBlur(()=>this._clearLiveRegion())),this._register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._register(j(r,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(oe(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let t=0;t0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===` -`&&(this._liveRegionLineCount++,this._liveRegionLineCount===Fn+1&&(this._liveRegion.textContent+=Os.get())))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(e){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(e)||this._charsToConsume.push(e)}_refreshRows(e,t){this._liveRegionDebouncer.refresh(e,t,this._terminal.rows)}_renderRows(e,t){let i=this._terminal.buffer,s=i.lines.length.toString();for(let r=e;r<=t;r++){let n=i.lines.get(i.ydisp+r),o=[],a=(n==null?void 0:n.translateToString(!0,void 0,void 0,o))||"",h=(i.ydisp+r+1).toString(),l=this._rowElements[r];l&&(a.length===0?(l.textContent=" ",this._rowColumns.set(l,[0,1])):(l.textContent=a,this._rowColumns.set(l,o)),l.setAttribute("aria-posinset",h),l.setAttribute("aria-setsize",s),this._alignRowWidth(l))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(e,t){let i=e.target,s=this._rowElements[t===0?1:this._rowElements.length-2],r=i.getAttribute("aria-posinset"),n=t===0?"1":`${this._terminal.buffer.lines.length}`;if(r===n||e.relatedTarget!==s)return;let o,a;if(t===0?(o=i,a=this._rowElements.pop(),this._rowContainer.removeChild(a)):(o=this._rowElements.shift(),a=i,this._rowContainer.removeChild(o)),o.removeEventListener("focus",this._topBoundaryFocusListener),a.removeEventListener("focus",this._bottomBoundaryFocusListener),t===0){let h=this._createAccessibilityTreeNode();this._rowElements.unshift(h),this._rowContainer.insertAdjacentElement("afterbegin",h)}else{let h=this._createAccessibilityTreeNode();this._rowElements.push(h),this._rowContainer.appendChild(h)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(t===0?-1:1),this._rowElements[t===0?1:this._rowElements.length-2].focus(),e.preventDefault(),e.stopImmediatePropagation()}_handleSelectionChange(){var a;if(this._rowElements.length===0)return;let e=this._coreBrowserService.mainDocument.getSelection();if(!e)return;if(e.isCollapsed){this._rowContainer.contains(e.anchorNode)&&this._terminal.clearSelection();return}if(!e.anchorNode||!e.focusNode){console.error("anchorNode and/or focusNode are null");return}let t={node:e.anchorNode,offset:e.anchorOffset},i={node:e.focusNode,offset:e.focusOffset};if((t.node.compareDocumentPosition(i.node)&Node.DOCUMENT_POSITION_PRECEDING||t.node===i.node&&t.offset>i.offset)&&([t,i]=[i,t]),t.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(t={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(t.node))return;let s=this._rowElements.slice(-1)[0];if(i.node.compareDocumentPosition(s)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(i={node:s,offset:((a=s.textContent)==null?void 0:a.length)??0}),!this._rowContainer.contains(i.node))return;let r=({node:h,offset:l})=>{let c=h instanceof Text?h.parentNode:h,d=parseInt(c==null?void 0:c.getAttribute("aria-posinset"),10)-1;if(isNaN(d))return console.warn("row is invalid. Race condition?"),null;let u=this._rowColumns.get(c);if(!u)return console.warn("columns is null. Race condition?"),null;let f=l=this._terminal.cols&&(++d,f=0),{row:d,column:f}},n=r(t),o=r(i);if(!(!n||!o)){if(n.row>o.row||n.row===o.row&&n.column>=o.column)throw new Error("invalid range");this._terminal.select(n.column,n.row,(o.row-n.row)*this._terminal.cols-n.column+o.column)}}_handleResize(e){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let t=this._rowContainer.children.length;te;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){let e=this._coreBrowserService.mainDocument.createElement("div");return e.setAttribute("role","listitem"),e.tabIndex=-1,this._refreshRowDimensions(e),e}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){Object.assign(this._accessibilityContainer.style,{width:`${this._renderService.dimensions.css.canvas.width}px`,fontSize:`${this._terminal.options.fontSize}px`}),this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let e=0;e{var n;At(this._linkCacheDisposables),this._linkCacheDisposables.length=0,this._lastMouseEvent=void 0,(n=this._activeProviderReplies)==null||n.clear()})),this._register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0})),this._register(j(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(j(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(j(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(j(this._element,"mouseup",this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(e){this._lastMouseEvent=e;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);if(!t)return;this._isMouseOut=!1;let i=e.composedPath();for(let s=0;s{n==null||n.forEach(o=>{o.link.dispose&&o.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let i=!1;for(let[n,o]of this._linkProviderService.linkProviders.entries())t?(r=this._activeProviderReplies)!=null&&r.get(n)&&(i=this._checkLinkProviderResult(n,e,i)):o.provideLinks(e.y,a=>{var l,c;if(this._isMouseOut)return;let h=a==null?void 0:a.map(d=>({link:d}));(l=this._activeProviderReplies)==null||l.set(n,h),i=this._checkLinkProviderResult(n,e,i),((c=this._activeProviderReplies)==null?void 0:c.size)===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,t){let i=new Set;for(let s=0;se?this._bufferService.cols:o.link.range.end.x;for(let l=a;l<=h;l++){if(i.has(l)){r.splice(n--,1);break}i.add(l)}}}}_checkLinkProviderResult(e,t,i){var n;if(!this._activeProviderReplies)return i;let s=this._activeProviderReplies.get(e),r=!1;for(let o=0;othis._linkAtPosition(a.link,t));o&&(i=!0,this._handleNewLink(o))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!i)for(let o=0;othis._linkAtPosition(h.link,t));if(a){i=!0,this._handleNewLink(a);break}}return i}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._mouseDownLink&&Bd(this._mouseDownLink.link,this._currentLink.link)&&this._linkAtPosition(this._currentLink.link,t)&&this._currentLink.link.activate(e,this._currentLink.link.text)}_clearCurrentLink(e,t){!this._currentLink||!this._lastMouseEvent||(!e||!t||this._currentLink.link.range.start.y>=e&&this._currentLink.link.range.end.y<=t)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,At(this._linkCacheDisposables),this._linkCacheDisposables.length=0)}_handleNewLink(e){if(!this._lastMouseEvent)return;let t=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);t&&this._linkAtPosition(e.link,t)&&(this._currentLink=e,this._currentLink.state={decorations:{underline:e.link.decorations===void 0?!0:e.link.decorations.underline,pointerCursor:e.link.decorations===void 0?!0:e.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,e.link,this._lastMouseEvent),e.link.decorations={},Object.defineProperties(e.link.decorations,{pointerCursor:{get:()=>{var i,s;return(s=(i=this._currentLink)==null?void 0:i.state)==null?void 0:s.decorations.pointerCursor},set:i=>{var s;(s=this._currentLink)!=null&&s.state&&this._currentLink.state.decorations.pointerCursor!==i&&(this._currentLink.state.decorations.pointerCursor=i,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",i))}},underline:{get:()=>{var i,s;return(s=(i=this._currentLink)==null?void 0:i.state)==null?void 0:s.decorations.underline},set:i=>{var s,r,n;(s=this._currentLink)!=null&&s.state&&((n=(r=this._currentLink)==null?void 0:r.state)==null?void 0:n.decorations.underline)!==i&&(this._currentLink.state.decorations.underline=i,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,i))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(i=>{if(!this._currentLink)return;let s=i.start===0?0:i.start+1+this._bufferService.buffer.ydisp,r=this._bufferService.buffer.ydisp+1+i.end;if(this._currentLink.link.range.start.y>=s&&this._currentLink.link.range.end.y<=r&&(this._clearCurrentLink(s,r),this._lastMouseEvent)){let n=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);n&&this._askForLink(n,!1)}})))}_linkHover(e,t,i){var s;(s=this._currentLink)!=null&&s.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!0),this._currentLink.state.decorations.pointerCursor&&e.classList.add("xterm-cursor-pointer")),t.hover&&t.hover(i,t.text)}_fireUnderlineEvent(e,t){let i=e.range,s=this._bufferService.buffer.ydisp,r=this._createLinkUnderlineEvent(i.start.x-1,i.start.y-s-1,i.end.x,i.end.y-s-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(r)}_linkLeave(e,t,i){var s;(s=this._currentLink)!=null&&s.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!1),this._currentLink.state.decorations.pointerCursor&&e.classList.remove("xterm-cursor-pointer")),t.leave&&t.leave(i,t.text)}_linkAtPosition(e,t){let i=e.range.start.y*this._bufferService.cols+e.range.start.x,s=e.range.end.y*this._bufferService.cols+e.range.end.x,r=t.y*this._bufferService.cols+t.x;return i<=r&&r<=s}_positionFromMouseEvent(e,t,i){let s=i.getCoords(e,t,this._bufferService.cols,this._bufferService.rows);if(s)return{x:s[0],y:s[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,t,i,s,r){return{x1:e,y1:t,x2:i,y2:s,cols:this._bufferService.cols,fg:r}}};Sr=_e([T(1,Rr),T(2,pt),T(3,Ie),T(4,qo)],Sr);function Bd(e,t){return e.text===t.text&&e.range.start.x===t.range.start.x&&e.range.start.y===t.range.start.y&&e.range.end.x===t.range.end.x&&e.range.end.y===t.range.end.y}var Md=class extends yd{constructor(e={}){super(e),this._linkifier=this._register(new Yt),this.browser=da,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new Yt),this._onCursorMove=this._register(new k),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new k),this.onKey=this._onKey.event,this._onRender=this._register(new k),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new k),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new k),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new k),this.onBell=this._onBell.event,this._onFocus=this._register(new k),this._onBlur=this._register(new k),this._onA11yCharEmitter=this._register(new k),this._onA11yTabEmitter=this._register(new k),this._onWillOpen=this._register(new k),this._setup(),this._decorationService=this._instantiationService.createInstance(xd),this._instantiationService.setService(xi,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(vc),this._instantiationService.setService(qo,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(Hs)),this._register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this._register(this._inputHandler.onRequestRefreshRows(t=>this.refresh((t==null?void 0:t.start)??0,(t==null?void 0:t.end)??this.rows-1))),this._register(this._inputHandler.onRequestSendFocus(()=>this._reportFocus())),this._register(this._inputHandler.onRequestReset(()=>this.reset())),this._register(this._inputHandler.onRequestWindowsOptionsReport(t=>this._reportWindowsOptions(t))),this._register(this._inputHandler.onColor(t=>this._handleColorEvent(t))),this._register(Le.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(Le.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(Le.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(Le.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(t=>this._afterResize(t.cols,t.rows))),this._register(oe(()=>{var t,i;this._customKeyEventHandler=void 0,(i=(t=this.element)==null?void 0:t.parentNode)==null||i.removeChild(this.element)}))}get linkifier(){return this._linkifier.value}get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}_handleColorEvent(e){if(this._themeService)for(let t of e){let i,s="";switch(t.index){case 256:i="foreground",s="10";break;case 257:i="background",s="11";break;case 258:i="cursor",s="12";break;default:i="ansi",s="4;"+t.index}switch(t.type){case 0:let r=re.toColorRGB(i==="ansi"?this._themeService.colors.ansi[t.index]:this._themeService.colors[i]);this.coreService.triggerDataEvent(`${v.ESC}]${s};${fd(r)}${ha.ST}`);break;case 1:if(i==="ansi")this._themeService.modifyColors(n=>n.ansi[t.index]=ve.toColor(...t.color));else{let n=i;this._themeService.modifyColors(o=>o[n]=ve.toColor(...t.color))}break;case 2:this._themeService.restoreColor(t.index);break}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(e){e?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(os,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(v.ESC+"[I"),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()}blur(){var e;return(e=this.textarea)==null?void 0:e.blur()}_handleTextAreaBlur(){this.textarea.value="",this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(v.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let e=this.buffer.ybase+this.buffer.y,t=this.buffer.lines.get(e);if(!t)return;let i=Math.min(this.buffer.x,this.cols-1),s=this._renderService.dimensions.css.cell.height,r=t.getWidth(i),n=this._renderService.dimensions.css.cell.width*r,o=this.buffer.y*this._renderService.dimensions.css.cell.height,a=i*this._renderService.dimensions.css.cell.width;this.textarea.style.left=a+"px",this.textarea.style.top=o+"px",this.textarea.style.width=n+"px",this.textarea.style.height=s+"px",this.textarea.style.lineHeight=s+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(j(this.element,"copy",t=>{this.hasSelection()&&$l(t,this._selectionService)}));let e=t=>Al(t,this.textarea,this.coreService,this.optionsService);this._register(j(this.textarea,"paste",e)),this._register(j(this.element,"paste",e)),ua?this._register(j(this.element,"mousedown",t=>{t.button===2&&Gr(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(j(this.element,"contextmenu",t=>{Gr(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),Pr&&this._register(j(this.element,"auxclick",t=>{t.button===1&&Io(t,this.textarea,this.screenElement)}))}_bindKeys(){this._register(j(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(j(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(j(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(j(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(j(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(j(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(j(this.textarea,"input",e=>this._inputEvent(e),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(e){var r;if(!e)throw new Error("Terminal requires a parent element.");if(e.isConnected||this._logService.debug("Terminal.open was called on an element that was not attached to the DOM"),((r=this.element)==null?void 0:r.ownerDocument.defaultView)&&this._coreBrowserService){this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView);return}this._document=e.ownerDocument,this.options.documentOverride&&this.options.documentOverride instanceof Document&&(this._document=this.optionsService.rawOptions.documentOverride),this.element=this._document.createElement("div"),this.element.dir="ltr",this.element.classList.add("terminal"),this.element.classList.add("xterm"),e.appendChild(this.element);let t=this._document.createDocumentFragment();this._viewportElement=this._document.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),t.appendChild(this._viewportElement),this.screenElement=this._document.createElement("div"),this.screenElement.classList.add("xterm-screen"),this._register(j(this.screenElement,"mousemove",n=>this.updateCursorStyle(n))),this._helperContainer=this._document.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),t.appendChild(this.screenElement);let i=this.textarea=this._document.createElement("textarea");this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",Is.get()),pa||this.textarea.setAttribute("aria-multiline","false"),this.textarea.setAttribute("autocorrect","off"),this.textarea.setAttribute("autocapitalize","off"),this.textarea.setAttribute("spellcheck","false"),this.textarea.tabIndex=0,this._register(this.optionsService.onSpecificOptionChange("disableStdin",()=>i.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(mc,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(ft,this._coreBrowserService),this._register(j(this.textarea,"focus",n=>this._handleTextAreaFocus(n))),this._register(j(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(ar,this._document,this._helperContainer),this._instantiationService.setService(hs,this._charSizeService),this._themeService=this._instantiationService.createInstance(dr),this._instantiationService.setService(Jt,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(ss),this._instantiationService.setService(Ko,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(hr,this.rows,this.screenElement)),this._instantiationService.setService(pt,this._renderService),this._register(this._renderService.onRenderedViewportChange(n=>this._onRender.fire(n))),this.onResize(n=>this._renderService.resize(n.cols,n.rows)),this._compositionView=this._document.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(rr,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(lr),this._instantiationService.setService(Rr,this._mouseService);let s=this._linkifier.value=this._register(this._instantiationService.createInstance(Sr,this.screenElement));this.element.appendChild(t);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this._register(this.onCursorMove(()=>{this._renderService.handleCursorMove(),this._syncTextArea()})),this._register(this.onResize(()=>this._renderService.handleResize(this.cols,this.rows))),this._register(this.onBlur(()=>this._renderService.handleBlur())),this._register(this.onFocus(()=>this._renderService.handleFocus())),this._viewport=this._register(this._instantiationService.createInstance(ir,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(n=>{super.scrollLines(n,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(cr,this.element,this.screenElement,s)),this._instantiationService.setService(zl,this._selectionService),this._register(this._selectionService.onRequestScrollLines(n=>this.scrollLines(n.amount,n.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(n=>this._renderService.handleSelectionChanged(n.start,n.end,n.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(n=>{this.textarea.value=n,this.textarea.focus(),this.textarea.select()})),this._register(Le.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{var n;this._selectionService.refresh(),(n=this._viewport)==null||n.queueSync()})),this._register(this._instantiationService.createInstance(sr,this.screenElement)),this._register(j(this.element,"mousedown",n=>this._selectionService.handleMouseDown(n))),this.coreMouseService.areMouseEventsActive?(this._selectionService.disable(),this.element.classList.add("enable-mouse-events")):this._selectionService.enable(),this.options.screenReaderMode&&(this._accessibilityManager.value=this._instantiationService.createInstance(os,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",n=>this._handleScreenReaderModeOptionChange(n))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(is,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",n=>{!this._overviewRulerRenderer&&n&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(is,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(or,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function i(n){var l,c,d,u,f;let o=e._mouseService.getMouseReportCoords(n,e.screenElement);if(!o)return!1;let a,h;switch(n.overrideType||n.type){case"mousemove":h=32,n.buttons===void 0?(a=3,n.button!==void 0&&(a=n.button<3?n.button:3)):a=n.buttons&1?0:n.buttons&4?1:n.buttons&2?2:3;break;case"mouseup":h=0,a=n.button<3?n.button:3;break;case"mousedown":h=1,a=n.button<3?n.button:3;break;case"wheel":if(e._customWheelEventHandler&&e._customWheelEventHandler(n)===!1)return!1;let _=n.deltaY;if(_===0||e.coreMouseService.consumeWheelEvent(n,(u=(d=(c=(l=e._renderService)==null?void 0:l.dimensions)==null?void 0:c.device)==null?void 0:d.cell)==null?void 0:u.height,(f=e._coreBrowserService)==null?void 0:f.dpr)===0)return!1;h=_<0?0:1,a=4;break;default:return!1}return h===void 0||a===void 0||a>4?!1:e.coreMouseService.triggerMouseEvent({col:o.col,row:o.row,x:o.x,y:o.y,button:a,action:h,ctrl:n.ctrlKey,alt:n.altKey,shift:n.shiftKey})}let s={mouseup:null,wheel:null,mousedrag:null,mousemove:null},r={mouseup:n=>(i(n),n.buttons||(this._document.removeEventListener("mouseup",s.mouseup),s.mousedrag&&this._document.removeEventListener("mousemove",s.mousedrag)),this.cancel(n)),wheel:n=>(i(n),this.cancel(n,!0)),mousedrag:n=>{n.buttons&&i(n)},mousemove:n=>{n.buttons||i(n)}};this._register(this.coreMouseService.onProtocolChange(n=>{n?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(n)),this.element.classList.add("enable-mouse-events"),this._selectionService.disable()):(this._logService.debug("Unbinding from mouse events."),this.element.classList.remove("enable-mouse-events"),this._selectionService.enable()),n&8?s.mousemove||(t.addEventListener("mousemove",r.mousemove),s.mousemove=r.mousemove):(t.removeEventListener("mousemove",s.mousemove),s.mousemove=null),n&16?s.wheel||(t.addEventListener("wheel",r.wheel,{passive:!1}),s.wheel=r.wheel):(t.removeEventListener("wheel",s.wheel),s.wheel=null),n&2?s.mouseup||(s.mouseup=r.mouseup):(this._document.removeEventListener("mouseup",s.mouseup),s.mouseup=null),n&4?s.mousedrag||(s.mousedrag=r.mousedrag):(this._document.removeEventListener("mousemove",s.mousedrag),s.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(j(t,"mousedown",n=>{if(n.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(n)))return i(n),s.mouseup&&this._document.addEventListener("mouseup",s.mouseup),s.mousedrag&&this._document.addEventListener("mousemove",s.mousedrag),this.cancel(n)})),this._register(j(t,"wheel",n=>{var o,a,h,l,c;if(!s.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(n)===!1)return!1;if(!this.buffer.hasScrollback){if(n.deltaY===0)return!1;if(e.coreMouseService.consumeWheelEvent(n,(l=(h=(a=(o=e._renderService)==null?void 0:o.dimensions)==null?void 0:a.device)==null?void 0:h.cell)==null?void 0:l.height,(c=e._coreBrowserService)==null?void 0:c.dpr)===0)return this.cancel(n,!0);let d=v.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(n.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(d,!0),this.cancel(n,!0)}}},{passive:!1}))}refresh(e,t){var i;(i=this._renderService)==null||i.refreshRows(e,t)}updateCursorStyle(e){var t;(t=this._selectionService)!=null&&t.shouldColumnSelect(e)?this.element.classList.add("column-select"):this.element.classList.remove("column-select")}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))}scrollLines(e,t){this._viewport?this._viewport.scrollLines(e):super.scrollLines(e,t),this.refresh(0,this.rows-1)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){e&&this._viewport?this._viewport.scrollToLine(this.buffer.ybase,!0):this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}paste(e){No(e,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(e){this._customKeyEventHandler=e}attachCustomWheelEventHandler(e){this._customWheelEventHandler=e}registerLinkProvider(e){return this._linkProviderService.registerLinkProvider(e)}registerCharacterJoiner(e){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");let t=this._characterJoinerService.register(e);return this.refresh(0,this.rows-1),t}deregisterCharacterJoiner(e){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");this._characterJoinerService.deregister(e)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(e){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+e)}registerDecoration(e){return this._decorationService.registerDecoration(e)}hasSelection(){return this._selectionService?this._selectionService.hasSelection:!1}select(e,t,i){this._selectionService.setSelection(e,t,i)}getSelection(){return this._selectionService?this._selectionService.selectionText:""}getSelectionPosition(){if(!(!this._selectionService||!this._selectionService.hasSelection))return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){var e;(e=this._selectionService)==null||e.clearSelection()}selectAll(){var e;(e=this._selectionService)==null||e.selectAll()}selectLines(e,t){var i;(i=this._selectionService)==null||i.selectLines(e,t)}_keyDown(e){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;let t=this.browser.isMac&&this.options.macOptionIsMeta&&e.altKey;if(!t&&!this._compositionHelper.keydown(e))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(!0),!1;!t&&(e.key==="Dead"||e.key==="AltGraph")&&(this._unprocessedDeadKey=!0);let i=wd(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),i.type===3||i.type===2){let s=this.rows-1;return this.scrollLines(i.type===2?-s:s),this.cancel(e,!0)}if(i.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,e)||(i.cancel&&this.cancel(e,!0),!i.key)||e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.key.length===1&&e.key.charCodeAt(0)>=65&&e.key.charCodeAt(0)<=90)return!0;if(this._unprocessedDeadKey)return this._unprocessedDeadKey=!1,!0;if((i.key===v.ETX||i.key===v.CR)&&(this.textarea.value=""),this._onKey.fire({key:i.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(i.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)return this.cancel(e,!0);this._keyDownHandled=!0}_isThirdLevelShift(e,t){let i=e.isMac&&!this.options.macOptionIsMeta&&t.altKey&&!t.ctrlKey&&!t.metaKey||e.isWindows&&t.altKey&&t.ctrlKey&&!t.metaKey||e.isWindows&&t.getModifierState("AltGraph");return t.type==="keypress"?i:i&&(!t.keyCode||t.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)&&(Dd(e)||this.focus(),this.updateCursorStyle(e),this._keyPressHandled=!1)}_keyPress(e){let t;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;if(this.cancel(e),e.charCode)t=e.charCode;else if(e.which===null||e.which===void 0)t=e.keyCode;else if(e.which!==0&&e.charCode!==0)t=e.which;else return!1;return!t||(e.altKey||e.ctrlKey||e.metaKey)&&!this._isThirdLevelShift(this.browser,e)?!1:(t=String.fromCharCode(t),this._onKey.fire({key:t,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(t,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,!0)}_inputEvent(e){if(e.data&&e.inputType==="insertText"&&(!e.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;let t=e.data;return this.coreService.triggerDataEvent(t,!0),this.cancel(e),!0}return!1}resize(e,t){if(e===this.cols&&t===this.rows){this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure();return}super.resize(e,t)}_afterResize(e,t){var i;(i=this._charSizeService)==null||i.measure()}clear(){if(!(this.buffer.ybase===0&&this.buffer.y===0)){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let e=1;e=0;e--)this._addons[e].instance.dispose()}loadAddon(e,t){let i={instance:t,dispose:t.dispose,isDisposed:!1};this._addons.push(i),t.dispose=()=>this._wrappedAddonDispose(i),t.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let t=-1;for(let i=0;i=this._line.length))return t?(this._line.loadCell(e,t),t):this._line.loadCell(e,new Je)}translateToString(e,t,i){return this._line.translateToString(e,t,i)}},Hn=class{constructor(e,t){this._buffer=e,this.type=t}init(e){return this._buffer=e,this}get cursorY(){return this._buffer.y}get cursorX(){return this._buffer.x}get viewportY(){return this._buffer.ydisp}get baseY(){return this._buffer.ybase}get length(){return this._buffer.lines.length}getLine(e){let t=this._buffer.lines.get(e);if(t)return new Td(t)}getNullCell(){return new Je}},$d=class extends G{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new k),this.onBufferChange=this._onBufferChange.event,this._normal=new Hn(this._core.buffers.normal,"normal"),this._alternate=new Hn(this._core.buffers.alt,"alternate"),this._core.buffers.onBufferActivate(()=>this._onBufferChange.fire(this.active))}get active(){if(this._core.buffers.active===this._core.buffers.normal)return this.normal;if(this._core.buffers.active===this._core.buffers.alt)return this.alternate;throw new Error("Active buffer is neither normal nor alternate")}get normal(){return this._normal.init(this._core.buffers.normal)}get alternate(){return this._alternate.init(this._core.buffers.alt)}},Ad=class{constructor(e){this._core=e}registerCsiHandler(e,t){return this._core.registerCsiHandler(e,i=>t(i.toArray()))}addCsiHandler(e,t){return this.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._core.registerDcsHandler(e,(i,s)=>t(i,s.toArray()))}addDcsHandler(e,t){return this.registerDcsHandler(e,t)}registerEscHandler(e,t){return this._core.registerEscHandler(e,t)}addEscHandler(e,t){return this.registerEscHandler(e,t)}registerOscHandler(e,t){return this._core.registerOscHandler(e,t)}addOscHandler(e,t){return this.registerOscHandler(e,t)}},Pd=class{constructor(e){this._core=e}register(e){this._core.unicodeService.register(e)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(e){this._core.unicodeService.activeVersion=e}},Nd=["cols","rows"],ot=0,Id=class extends G{constructor(e){super(),this._core=this._register(new Md(e)),this._addonManager=this._register(new Ld),this._publicOptions={...this._core.options};let t=s=>this._core.options[s],i=(s,r)=>{this._checkReadonlyOptions(s),this._core.options[s]=r};for(let s in this._core.options){let r={get:t.bind(this,s),set:i.bind(this,s)};Object.defineProperty(this._publicOptions,s,r)}}_checkReadonlyOptions(e){if(Nd.includes(e))throw new Error(`Option "${e}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw new Error("You must set the allowProposedApi option to true to use proposed API")}get onBell(){return this._core.onBell}get onBinary(){return this._core.onBinary}get onCursorMove(){return this._core.onCursorMove}get onData(){return this._core.onData}get onKey(){return this._core.onKey}get onLineFeed(){return this._core.onLineFeed}get onRender(){return this._core.onRender}get onResize(){return this._core.onResize}get onScroll(){return this._core.onScroll}get onSelectionChange(){return this._core.onSelectionChange}get onTitleChange(){return this._core.onTitleChange}get onWriteParsed(){return this._core.onWriteParsed}get element(){return this._core.element}get parser(){return this._parser||(this._parser=new Ad(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new Pd(this._core)}get textarea(){return this._core.textarea}get rows(){return this._core.rows}get cols(){return this._core.cols}get buffer(){return this._buffer||(this._buffer=this._register(new $d(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let e=this._core.coreService.decPrivateModes,t="none";switch(this._core.coreMouseService.activeProtocol){case"X10":t="x10";break;case"VT200":t="vt200";break;case"DRAG":t="drag";break;case"ANY":t="any";break}return{applicationCursorKeysMode:e.applicationCursorKeys,applicationKeypadMode:e.applicationKeypad,bracketedPasteMode:e.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:t,originMode:e.origin,reverseWraparoundMode:e.reverseWraparound,sendFocusMode:e.sendFocus,synchronizedOutputMode:e.synchronizedOutput,wraparoundMode:e.wraparound}}get options(){return this._publicOptions}set options(e){for(let t in e)this._publicOptions[t]=e[t]}blur(){this._core.blur()}focus(){this._core.focus()}input(e,t=!0){this._core.input(e,t)}resize(e,t){this._verifyIntegers(e,t),this._core.resize(e,t)}open(e){this._core.open(e)}attachCustomKeyEventHandler(e){this._core.attachCustomKeyEventHandler(e)}attachCustomWheelEventHandler(e){this._core.attachCustomWheelEventHandler(e)}registerLinkProvider(e){return this._core.registerLinkProvider(e)}registerCharacterJoiner(e){return this._checkProposedApi(),this._core.registerCharacterJoiner(e)}deregisterCharacterJoiner(e){this._checkProposedApi(),this._core.deregisterCharacterJoiner(e)}registerMarker(e=0){return this._verifyIntegers(e),this._core.registerMarker(e)}registerDecoration(e){return this._checkProposedApi(),this._verifyPositiveIntegers(e.x??0,e.width??0,e.height??0),this._core.registerDecoration(e)}hasSelection(){return this._core.hasSelection()}select(e,t,i){this._verifyIntegers(e,t,i),this._core.select(e,t,i)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(e,t){this._verifyIntegers(e,t),this._core.selectLines(e,t)}dispose(){super.dispose()}scrollLines(e){this._verifyIntegers(e),this._core.scrollLines(e)}scrollPages(e){this._verifyIntegers(e),this._core.scrollPages(e)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(e){this._verifyIntegers(e),this._core.scrollToLine(e)}clear(){this._core.clear()}write(e,t){this._core.write(e,t)}writeln(e,t){this._core.write(e),this._core.write(`\r +`)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),Pr&&e&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:this._activeSelectionMode===3})}_isClickInSelection(e){let t=this._getMouseBufferCoords(e),i=this._model.finalSelectionStart,s=this._model.finalSelectionEnd;return!i||!s||!t?!1:this._areCoordsInSelection(t,i,s)}isCellInSelection(e,t){let i=this._model.finalSelectionStart,s=this._model.finalSelectionEnd;return!i||!s?!1:this._areCoordsInSelection([e,t],i,s)}_areCoordsInSelection(e,t,i){return e[1]>t[1]&&e[1]=t[0]&&e[0]=t[0]}_selectWordAtCursor(e,t){var r,n;let i=(n=(r=this._linkifier.currentLink)==null?void 0:r.link)==null?void 0:n.range;if(i)return this._model.selectionStart=[i.start.x-1,i.start.y-1],this._model.selectionStartLength=mn(i,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let s=this._getMouseBufferCoords(e);return s?(this._selectWordAt(s,t),this._model.selectionEnd=void 0,!0):!1}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(e,t){this._model.clearSelection(),e=Math.max(e,0),t=Math.min(t,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,e],this._model.selectionEnd=[this._bufferService.cols,t],this.refresh(),this._onSelectionChange.fire()}_handleTrim(e){this._model.handleTrim(e)&&this.refresh()}_getMouseBufferCoords(e){let t=this._mouseService.getCoords(e,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(t)return t[0]--,t[1]--,t[1]+=this._bufferService.buffer.ydisp,t}_getMouseEventScrollAmount(e){let t=Ar(this._coreBrowserService.window,e,this._screenElement)[1],i=this._renderService.dimensions.css.canvas.height;return t>=0&&t<=i?0:(t>i&&(t-=i),t=Math.min(Math.max(t,-ys),ys),t/=ys,t/Math.abs(t)+Math.round(t*(Ic-1)))}shouldForceSelection(e){return rs?e.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:e.shiftKey}handleMouseDown(e){if(this._mouseDownTimeStamp=e.timeStamp,!(e.button===2&&this.hasSelection)&&e.button===0){if(!this._enabled){if(!this.shouldForceSelection(e))return;e.stopPropagation()}e.preventDefault(),this._dragScrollAmount=0,this._enabled&&e.shiftKey?this._handleIncrementalClick(e):e.detail===1?this._handleSingleClick(e):e.detail===2?this._handleDoubleClick(e):e.detail===3&&this._handleTripleClick(e),this._addMouseDownListeners(),this.refresh(!0)}}_addMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.addEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.addEventListener("mouseup",this._mouseUpListener)),this._dragScrollIntervalTimer=this._coreBrowserService.window.setInterval(()=>this._dragScroll(),Oc)}_removeMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.removeEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.removeEventListener("mouseup",this._mouseUpListener)),this._coreBrowserService.window.clearInterval(this._dragScrollIntervalTimer),this._dragScrollIntervalTimer=void 0}_handleIncrementalClick(e){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(e))}_handleSingleClick(e){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(e)?3:0,this._model.selectionStart=this._getMouseBufferCoords(e),!this._model.selectionStart)return;this._model.selectionEnd=void 0;let t=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);t&&t.length!==this._model.selectionStart[0]&&t.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(e){this._selectWordAtCursor(e,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(e){let t=this._getMouseBufferCoords(e);t&&(this._activeSelectionMode=2,this._selectLineAt(t[1]))}shouldColumnSelect(e){return e.altKey&&!(rs&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(e){if(e.stopImmediatePropagation(),!this._model.selectionStart)return;let t=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(e),!this._model.selectionEnd){this.refresh(!0);return}this._activeSelectionMode===2?this._model.selectionEnd[1]0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));let i=this._bufferService.buffer;if(this._model.selectionEnd[1]0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(e.ydisp+this._bufferService.rows,e.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=e.ydisp),this.refresh()}}_handleMouseUp(e){let t=e.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&tthis._handleTrim(t))}_convertViewportColToCharacterIndex(e,t){let i=t;for(let s=0;t>=s;s++){let r=e.loadCell(s,this._workCell).getChars().length;this._workCell.getWidth()===0?i--:r>1&&t!==s&&(i+=r-1)}return i}setSelection(e,t,i){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=i,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,t,i=!0,s=!0){if(e[0]>=this._bufferService.cols)return;let r=this._bufferService.buffer,n=r.lines.get(e[1]);if(!n)return;let o=r.translateBufferLineToString(e[1],!1),a=this._convertViewportColToCharacterIndex(n,e[0]),h=a,l=e[0]-a,c=0,d=0,u=0,f=0;if(o.charAt(a)===" "){for(;a>0&&o.charAt(a-1)===" ";)a--;for(;h1&&(f+=z-1,h+=z-1);g>0&&a>0&&!this._isCharWordSeparator(n.loadCell(g-1,this._workCell));){n.loadCell(g-1,this._workCell);let O=this._workCell.getChars().length;this._workCell.getWidth()===0?(c++,g--):O>1&&(u+=O-1,a-=O-1),a--,g--}for(;E1&&(f+=O-1,h+=O-1),h++,E++}}h++;let _=a+l-c+u,p=Math.min(this._bufferService.cols,h-a+c+d-u-f);if(!(!t&&o.slice(a,h).trim()==="")){if(i&&_===0&&n.getCodePoint(0)!==32){let g=r.lines.get(e[1]-1);if(g&&n.isWrapped&&g.getCodePoint(this._bufferService.cols-1)!==32){let E=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(E){let z=this._bufferService.cols-E.start;_-=z,p+=z}}}if(s&&_+p===this._bufferService.cols&&n.getCodePoint(this._bufferService.cols-1)!==32){let g=r.lines.get(e[1]+1);if(g!=null&&g.isWrapped&&g.getCodePoint(0)!==32){let E=this._getWordAt([0,e[1]+1],!1,!1,!0);E&&(p+=E.length)}}return{start:_,length:p}}}_selectWordAt(e,t){let i=this._getWordAt(e,t);if(i){for(;i.start<0;)i.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[i.start,e[1]],this._model.selectionStartLength=i.length}}_selectToWordAt(e){let t=this._getWordAt(e,!0);if(t){let i=e[1];for(;t.start<0;)t.start+=this._bufferService.cols,i--;if(!this._model.areSelectionValuesReversed())for(;t.start+t.length>this._bufferService.cols;)t.length-=this._bufferService.cols,i++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?t.start:t.start+t.length,i]}}_isCharWordSeparator(e){return e.getWidth()===0?!1:this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let t=this._bufferService.buffer.getWrappedRangeForLine(e),i={start:{x:0,y:t.first},end:{x:this._bufferService.cols-1,y:t.last}};this._model.selectionStart=[0,t.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=mn(i,this._bufferService.cols)}};cr=_e([T(3,Ie),T(4,Nt),T(5,Rr),T(6,Oe),T(7,pt),T(8,ft)],cr);var gn=class{constructor(){this._data={}}set(e,t,i){this._data[e]||(this._data[e]={}),this._data[e][t]=i}get(e,t){return this._data[e]?this._data[e][t]:void 0}clear(){this._data={}}},vn=class{constructor(){this._color=new gn,this._css=new gn}setCss(e,t,i){this._css.set(e,t,i)}getCss(e,t){return this._css.get(e,t)}setColor(e,t,i){this._color.set(e,t,i)}getColor(e,t){return this._color.get(e,t)}clear(){this._color.clear(),this._css.clear()}},ye=Object.freeze((()=>{let e=[ce.toColor("#2e3436"),ce.toColor("#cc0000"),ce.toColor("#4e9a06"),ce.toColor("#c4a000"),ce.toColor("#3465a4"),ce.toColor("#75507b"),ce.toColor("#06989a"),ce.toColor("#d3d7cf"),ce.toColor("#555753"),ce.toColor("#ef2929"),ce.toColor("#8ae234"),ce.toColor("#fce94f"),ce.toColor("#729fcf"),ce.toColor("#ad7fa8"),ce.toColor("#34e2e2"),ce.toColor("#eeeeec")],t=[0,95,135,175,215,255];for(let i=0;i<216;i++){let s=t[i/36%6|0],r=t[i/6%6|0],n=t[i%6];e.push({css:ve.toCss(s,r,n),rgba:ve.toRgba(s,r,n)})}for(let i=0;i<24;i++){let s=8+i*10;e.push({css:ve.toCss(s,s,s),rgba:ve.toRgba(s,s,s)})}return e})()),Dt=ce.toColor("#ffffff"),ui=ce.toColor("#000000"),Sn=ce.toColor("#ffffff"),yn=ui,ni={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},zc=Dt,dr=class extends G{constructor(e){super(),this._optionsService=e,this._contrastCache=new vn,this._halfContrastCache=new vn,this._onChangeColors=this._register(new k),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:Dt,background:ui,cursor:Sn,cursorAccent:yn,selectionForeground:void 0,selectionBackgroundTransparent:ni,selectionBackgroundOpaque:re.blend(ui,ni),selectionInactiveBackgroundTransparent:ni,selectionInactiveBackgroundOpaque:re.blend(ui,ni),scrollbarSliderBackground:re.opacity(Dt,.2),scrollbarSliderHoverBackground:re.opacity(Dt,.4),scrollbarSliderActiveBackground:re.opacity(Dt,.5),overviewRulerBorder:Dt,ansi:ye.slice(),contrastCache:this._contrastCache,halfContrastCache:this._halfContrastCache},this._updateRestoreColors(),this._setTheme(this._optionsService.rawOptions.theme),this._register(this._optionsService.onSpecificOptionChange("minimumContrastRatio",()=>this._contrastCache.clear())),this._register(this._optionsService.onSpecificOptionChange("theme",()=>this._setTheme(this._optionsService.rawOptions.theme)))}get colors(){return this._colors}_setTheme(e={}){let t=this._colors;if(t.foreground=Z(e.foreground,Dt),t.background=Z(e.background,ui),t.cursor=re.blend(t.background,Z(e.cursor,Sn)),t.cursorAccent=re.blend(t.background,Z(e.cursorAccent,yn)),t.selectionBackgroundTransparent=Z(e.selectionBackground,ni),t.selectionBackgroundOpaque=re.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=Z(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=re.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?Z(e.selectionForeground,_n):void 0,t.selectionForeground===_n&&(t.selectionForeground=void 0),re.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=re.opacity(t.selectionBackgroundTransparent,.3)),re.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=re.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=Z(e.scrollbarSliderBackground,re.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=Z(e.scrollbarSliderHoverBackground,re.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=Z(e.scrollbarSliderActiveBackground,re.opacity(t.foreground,.5)),t.overviewRulerBorder=Z(e.overviewRulerBorder,zc),t.ansi=ye.slice(),t.ansi[0]=Z(e.black,ye[0]),t.ansi[1]=Z(e.red,ye[1]),t.ansi[2]=Z(e.green,ye[2]),t.ansi[3]=Z(e.yellow,ye[3]),t.ansi[4]=Z(e.blue,ye[4]),t.ansi[5]=Z(e.magenta,ye[5]),t.ansi[6]=Z(e.cyan,ye[6]),t.ansi[7]=Z(e.white,ye[7]),t.ansi[8]=Z(e.brightBlack,ye[8]),t.ansi[9]=Z(e.brightRed,ye[9]),t.ansi[10]=Z(e.brightGreen,ye[10]),t.ansi[11]=Z(e.brightYellow,ye[11]),t.ansi[12]=Z(e.brightBlue,ye[12]),t.ansi[13]=Z(e.brightMagenta,ye[13]),t.ansi[14]=Z(e.brightCyan,ye[14]),t.ansi[15]=Z(e.brightWhite,ye[15]),e.extendedAnsi){let i=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let s=0;sn.index-o.index),s=[];for(let n of i){let o=this._services.get(n.id);if(!o)throw new Error(`[createInstance] ${e.name} depends on UNKNOWN service ${n.id._id}.`);s.push(o)}let r=i.length>0?i[0].index:t.length;if(t.length!==r)throw new Error(`[createInstance] First service dependency of ${e.name} at position ${r+1} conflicts with ${t.length} static arguments`);return new e(...t,...s)}},Kc={trace:0,debug:1,info:2,warn:3,error:4,off:5},qc="xterm.js: ",ur=class extends G{constructor(e){super(),this._optionsService=e,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange("logLevel",()=>this._updateLogLevel()))}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=Kc[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(e){for(let t=0;tthis._length)for(let t=this._length;t=e;s--)this._array[this._getCyclicIndex(s+i.length)]=this._array[this._getCyclicIndex(s)];for(let s=0;sthis._maxLength){let s=this._length+i.length-this._maxLength;this._startIndex+=s,this._length=this._maxLength,this.onTrimEmitter.fire(s)}else this._length+=i.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,t,i){if(!(t<=0)){if(e<0||e>=this._length)throw new Error("start argument out of range");if(e+i<0)throw new Error("Cannot shift elements in list beyond index 0");if(i>0){for(let r=t-1;r>=0;r--)this.set(e+r+i,this.get(e+r));let s=e+t+i-this._length;if(s>0)for(this._length+=s;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let s=0;s>22,i&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):s]}set(t,i){this._data[t*V+1]=i[0],i[1].length>1?(this._combined[t]=i[1],this._data[t*V+0]=t|2097152|i[2]<<22):this._data[t*V+0]=i[1].charCodeAt(0)|i[2]<<22}getWidth(t){return this._data[t*V+0]>>22}hasWidth(t){return this._data[t*V+0]&12582912}getFg(t){return this._data[t*V+1]}getBg(t){return this._data[t*V+2]}hasContent(t){return this._data[t*V+0]&4194303}getCodePoint(t){let i=this._data[t*V+0];return i&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):i&2097151}isCombined(t){return this._data[t*V+0]&2097152}getString(t){let i=this._data[t*V+0];return i&2097152?this._combined[t]:i&2097151?wt(i&2097151):""}isProtected(t){return this._data[t*V+2]&536870912}loadCell(t,i){return Oi=t*V,i.content=this._data[Oi+0],i.fg=this._data[Oi+1],i.bg=this._data[Oi+2],i.content&2097152&&(i.combinedData=this._combined[t]),i.bg&268435456&&(i.extended=this._extendedAttrs[t]),i}setCell(t,i){i.content&2097152&&(this._combined[t]=i.combinedData),i.bg&268435456&&(this._extendedAttrs[t]=i.extended),this._data[t*V+0]=i.content,this._data[t*V+1]=i.fg,this._data[t*V+2]=i.bg}setCellFromCodepoint(t,i,s,r){r.bg&268435456&&(this._extendedAttrs[t]=r.extended),this._data[t*V+0]=i|s<<22,this._data[t*V+1]=r.fg,this._data[t*V+2]=r.bg}addCodepointToCell(t,i,s){let r=this._data[t*V+0];r&2097152?this._combined[t]+=wt(i):r&2097151?(this._combined[t]=wt(r&2097151)+wt(i),r&=-2097152,r|=2097152):r=i|1<<22,s&&(r&=-12582913,r|=s<<22),this._data[t*V+0]=r}insertCells(t,i,s){if(t%=this.length,t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,s),i=0;--n)this.setCell(t+i+n,this.loadCell(t+n,r));for(let n=0;nthis.length){if(this._data.buffer.byteLength>=s*4)this._data=new Uint32Array(this._data.buffer,0,s);else{let r=new Uint32Array(s);r.set(this._data),this._data=r}for(let r=this.length;r=t&&delete this._combined[a]}let n=Object.keys(this._extendedAttrs);for(let o=0;o=t&&delete this._extendedAttrs[a]}}return this.length=t,s*4*ws=0;--t)if(this._data[t*V+0]&4194303)return t+(this._data[t*V+0]>>22);return 0}getNoBgTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*V+0]&4194303||this._data[t*V+2]&50331648)return t+(this._data[t*V+0]>>22);return 0}copyCellsFrom(t,i,s,r,n){let o=t._data;if(n)for(let h=r-1;h>=0;h--){for(let l=0;l=i&&(this._combined[l-i+s]=t._combined[l])}}translateToString(t,i,s,r){i=i??0,s=s??this.length,t&&(s=Math.min(s,this.getTrimmedLength())),r&&(r.length=0);let n="";for(;i>22||1}return r&&r.push(i),n}};function Vc(e,t,i,s,r,n){let o=[];for(let a=0;a=a&&s0&&(g>d||c[g].getTrimmedLength()===0);g--)p++;p>0&&(o.push(a+c.length-p),o.push(p)),a+=c.length-1}return o}function Gc(e,t){let i=[],s=0,r=t[s],n=0;for(let o=0;owi(e,l,t)).reduce((h,l)=>h+l),n=0,o=0,a=0;for(;ah&&(n-=h,o++);let l=e[o].getWidth(n-1)===2;l&&n--;let c=l?i-1:i;s.push(c),a+=c}return s}function wi(e,t,i){if(t===e.length-1)return e[t].getTrimmedLength();let s=!e[t].hasContent(i-1)&&e[t].getWidth(i-1)===1,r=e[t+1].getWidth(0)===2;return s&&r?i-1:i}var ya=class wa{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=wa._nextId++,this._onDispose=this.register(new k),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),At(this._disposables),this._disposables.length=0)}register(t){return this._disposables.push(t),t}};ya._nextId=1;var Jc=ya,be={},Lt=be.B;be[0]={"`":"◆",a:"▒",b:"␉",c:"␌",d:"␍",e:"␊",f:"°",g:"±",h:"␤",i:"␋",j:"┘",k:"┐",l:"┌",m:"└",n:"┼",o:"⎺",p:"⎻",q:"─",r:"⎼",s:"⎽",t:"├",u:"┤",v:"┴",w:"┬",x:"│",y:"≤",z:"≥","{":"π","|":"≠","}":"£","~":"·"};be.A={"#":"£"};be.B=void 0;be[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};be.C=be[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};be.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};be.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};be.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};be.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};be.E=be[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};be.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};be.H=be[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};be["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var bn=4294967295,Cn=class{constructor(e,t,i){this._hasScrollback=e,this._optionsService=t,this._bufferService=i,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=me.clone(),this.savedCharset=Lt,this.markers=[],this._nullCell=Je.fromCharData([0,Oo,1,0]),this._whitespaceCell=Je.fromCharData([0,Ct,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new ns,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new wn(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(e){return e?(this._nullCell.fg=e.fg,this._nullCell.bg=e.bg,this._nullCell.extended=e.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new ts),this._nullCell}getWhitespaceCell(e){return e?(this._whitespaceCell.fg=e.fg,this._whitespaceCell.bg=e.bg,this._whitespaceCell.extended=e.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new ts),this._whitespaceCell}getBlankLine(e,t){return new _i(this._bufferService.cols,this.getNullCell(e),t)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){let e=this.ybase+this.y-this.ydisp;return e>=0&&ebn?bn:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=me);let t=this._rows;for(;t--;)this.lines.push(this.getBlankLine(e))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new wn(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let i=this.getNullCell(me),s=0,r=this._getCorrectBufferLength(t);if(r>this.lines.maxLength&&(this.lines.maxLength=r),this.lines.length>0){if(this._cols0&&this.lines.length<=this.ybase+this.y+n+1?(this.ybase--,n++,this.ydisp>0&&this.ydisp--):this.lines.push(new _i(e,i)));else for(let o=this._rows;o>t;o--)this.lines.length>t+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(r0&&(this.lines.trimStart(o),this.ybase=Math.max(this.ybase-o,0),this.ydisp=Math.max(this.ydisp-o,0),this.savedY=Math.max(this.savedY-o,0)),this.lines.maxLength=r}this.x=Math.min(this.x,e-1),this.y=Math.min(this.y,t-1),n&&(this.y+=n),this.savedX=Math.min(this.savedX,e-1),this.scrollTop=0}if(this.scrollBottom=t-1,this._isReflowEnabled&&(this._reflow(e,t),this._cols>e))for(let n=0;n.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let e=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,e=!1);let t=0;for(;this._memoryCleanupPosition100)return!0;return e}get _isReflowEnabled(){let e=this._optionsService.rawOptions.windowsPty;return e&&e.buildNumber?this._hasScrollback&&e.backend==="conpty"&&e.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(e,t){this._cols!==e&&(e>this._cols?this._reflowLarger(e,t):this._reflowSmaller(e,t))}_reflowLarger(e,t){let i=this._optionsService.rawOptions.reflowCursorLine,s=Vc(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(me),i);if(s.length>0){let r=Gc(this.lines,s);Yc(this.lines,r.layout),this._reflowLargerAdjustViewport(e,t,r.countRemoved)}}_reflowLargerAdjustViewport(e,t,i){let s=this.getNullCell(me),r=i;for(;r-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length=0;o--){let a=this.lines.get(o);if(!a||!a.isWrapped&&a.getTrimmedLength()<=e)continue;let h=[a];for(;a.isWrapped&&o>0;)a=this.lines.get(--o),h.unshift(a);if(!i){let O=this.ybase+this.y;if(O>=o&&O0&&(r.push({start:o+h.length+n,newLines:f}),n+=f.length),h.push(...f);let _=c.length-1,p=c[_];p===0&&(_--,p=c[_]);let g=h.length-d-1,E=l;for(;g>=0;){let O=Math.min(E,p);if(h[_]===void 0)break;if(h[_].copyCellsFrom(h[g],E-O,p-O,O,!0),p-=O,p===0&&(_--,p=c[_]),E-=O,E===0){g--;let M=Math.max(g,0);E=wi(h,M,this._cols)}}for(let O=0;O0;)this.ybase===0?this.y0){let o=[],a=[];for(let p=0;p=0;p--)if(d&&d.start>l+u){for(let g=d.newLines.length-1;g>=0;g--)this.lines.set(p--,d.newLines[g]);p++,o.push({index:l+1,amount:d.newLines.length}),u+=d.newLines.length,d=r[++c]}else this.lines.set(p,a[l--]);let f=0;for(let p=o.length-1;p>=0;p--)o[p].index+=f,this.lines.onInsertEmitter.fire(o[p]),f+=o[p].amount;let _=Math.max(0,h+n-this.lines.maxLength);_>0&&this.lines.onTrimEmitter.fire(_)}}translateBufferLineToString(e,t,i=0,s){let r=this.lines.get(e);return r?r.translateToString(t,i,s):""}getWrappedRangeForLine(e){let t=e,i=e;for(;t>0&&this.lines.get(t).isWrapped;)t--;for(;i+10;);return e>=this._cols?this._cols-1:e<0?0:e}nextStop(e){for(e==null&&(e=this.x);!this.tabs[++e]&&e=this._cols?this._cols-1:e<0?0:e}clearMarkers(e){this._isClearing=!0;for(let t=0;t{t.line-=i,t.line<0&&t.dispose()})),t.register(this.lines.onInsert(i=>{t.line>=i.index&&(t.line+=i.amount)})),t.register(this.lines.onDelete(i=>{t.line>=i.index&&t.linei.index&&(t.line-=i.amount)})),t.register(t.onDispose(()=>this._removeMarker(t))),t}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}},Zc=class extends G{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new k),this.onBufferActivate=this._onBufferActivate.event,this.reset(),this._register(this._optionsService.onSpecificOptionChange("scrollback",()=>this.resize(this._bufferService.cols,this._bufferService.rows))),this._register(this._optionsService.onSpecificOptionChange("tabStopWidth",()=>this.setupTabStops()))}reset(){this._normal=new Cn(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new Cn(!1,this._optionsService,this._bufferService),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}),this.setupTabStops()}get alt(){return this._alt}get active(){return this._activeBuffer}get normal(){return this._normal}activateNormalBuffer(){this._activeBuffer!==this._normal&&(this._normal.x=this._alt.x,this._normal.y=this._alt.y,this._alt.clearAllMarkers(),this._alt.clear(),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}))}activateAltBuffer(e){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(e),this._alt.x=this._normal.x,this._alt.y=this._normal.y,this._activeBuffer=this._alt,this._onBufferActivate.fire({activeBuffer:this._alt,inactiveBuffer:this._normal}))}resize(e,t){this._normal.resize(e,t),this._alt.resize(e,t),this.setupTabStops(e)}setupTabStops(e){this._normal.setupTabStops(e),this._alt.setupTabStops(e)}},ba=2,Ca=1,_r=class extends G{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new k),this.onResize=this._onResize.event,this._onScroll=this._register(new k),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,ba),this.rows=Math.max(e.rawOptions.rows||0,Ca),this.buffers=this._register(new Zc(e,this)),this._register(this.buffers.onBufferActivate(t=>{this._onScroll.fire(t.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(e,t){let i=this.cols!==e,s=this.rows!==t;this.cols=e,this.rows=t,this.buffers.resize(e,t),this._onResize.fire({cols:e,rows:t,colsChanged:i,rowsChanged:s})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,t=!1){let i=this.buffer,s;s=this._cachedBlankLine,(!s||s.length!==this.cols||s.getFg(0)!==e.fg||s.getBg(0)!==e.bg)&&(s=i.getBlankLine(e,t),this._cachedBlankLine=s),s.isWrapped=t;let r=i.ybase+i.scrollTop,n=i.ybase+i.scrollBottom;if(i.scrollTop===0){let o=i.lines.isFull;n===i.lines.length-1?o?i.lines.recycle().copyFrom(s):i.lines.push(s.clone()):i.lines.splice(n+1,0,s.clone()),o?this.isUserScrolling&&(i.ydisp=Math.max(i.ydisp-1,0)):(i.ybase++,this.isUserScrolling||i.ydisp++)}else{let o=n-r+1;i.lines.shiftElements(r+1,o-1,-1),i.lines.set(n,s.clone())}this.isUserScrolling||(i.ydisp=i.ybase),this._onScroll.fire(i.ydisp)}scrollLines(e,t){let i=this.buffer;if(e<0){if(i.ydisp===0)return;this.isUserScrolling=!0}else e+i.ydisp>=i.ybase&&(this.isUserScrolling=!1);let s=i.ydisp;i.ydisp=Math.max(Math.min(i.ydisp+e,i.ybase),0),s!==i.ydisp&&(t||this._onScroll.fire(i.ydisp))}};_r=_e([T(0,Oe)],_r);var Wt={cols:80,rows:24,cursorBlink:!1,cursorStyle:"block",cursorWidth:1,cursorInactiveStyle:"outline",customGlyphs:!0,drawBoldTextInBrightColors:!0,documentOverride:null,fastScrollModifier:"alt",fastScrollSensitivity:5,fontFamily:"monospace",fontSize:15,fontWeight:"normal",fontWeightBold:"bold",ignoreBracketedPasteMode:!1,lineHeight:1,letterSpacing:0,linkHandler:null,logLevel:"info",logger:null,scrollback:1e3,scrollOnEraseInDisplay:!1,scrollOnUserInput:!0,scrollSensitivity:1,screenReaderMode:!1,smoothScrollDuration:0,macOptionIsMeta:!1,macOptionClickForcesSelection:!1,minimumContrastRatio:1,disableStdin:!1,allowProposedApi:!1,allowTransparency:!1,tabStopWidth:8,theme:{},reflowCursorLine:!1,rescaleOverlappingGlyphs:!1,rightClickSelectsWord:rs,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},Qc=["normal","bold","100","200","300","400","500","600","700","800","900"],ed=class extends G{constructor(e){super(),this._onOptionChange=this._register(new k),this.onOptionChange=this._onOptionChange.event;let t={...Wt};for(let i in e)if(i in t)try{let s=e[i];t[i]=this._sanitizeAndValidateOption(i,s)}catch(s){console.error(s)}this.rawOptions=t,this.options={...t},this._setupOptions(),this._register(oe(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,t){return this.onOptionChange(i=>{i===e&&t(this.rawOptions[e])})}onMultipleOptionChange(e,t){return this.onOptionChange(i=>{e.indexOf(i)!==-1&&t()})}_setupOptions(){let e=i=>{if(!(i in Wt))throw new Error(`No option with key "${i}"`);return this.rawOptions[i]},t=(i,s)=>{if(!(i in Wt))throw new Error(`No option with key "${i}"`);s=this._sanitizeAndValidateOption(i,s),this.rawOptions[i]!==s&&(this.rawOptions[i]=s,this._onOptionChange.fire(i))};for(let i in this.rawOptions){let s={get:e.bind(this,i),set:t.bind(this,i)};Object.defineProperty(this.options,i,s)}}_sanitizeAndValidateOption(e,t){switch(e){case"cursorStyle":if(t||(t=Wt[e]),!td(t))throw new Error(`"${t}" is not a valid value for ${e}`);break;case"wordSeparator":t||(t=Wt[e]);break;case"fontWeight":case"fontWeightBold":if(typeof t=="number"&&1<=t&&t<=1e3)break;t=Qc.includes(t)?t:Wt[e];break;case"cursorWidth":t=Math.floor(t);case"lineHeight":case"tabStopWidth":if(t<1)throw new Error(`${e} cannot be less than 1, value: ${t}`);break;case"minimumContrastRatio":t=Math.max(1,Math.min(21,Math.round(t*10)/10));break;case"scrollback":if(t=Math.min(t,4294967295),t<0)throw new Error(`${e} cannot be less than 0, value: ${t}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(t<=0)throw new Error(`${e} cannot be less than or equal to 0, value: ${t}`);break;case"rows":case"cols":if(!t&&t!==0)throw new Error(`${e} must be numeric, value: ${t}`);break;case"windowsPty":t=t??{};break}return t}};function td(e){return e==="block"||e==="underline"||e==="bar"}function fi(e,t=5){if(typeof e!="object")return e;let i=Array.isArray(e)?[]:{};for(let s in e)i[s]=t<=1?e[s]:e[s]&&fi(e[s],t-1);return i}var xn=Object.freeze({insertMode:!1}),kn=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),fr=class extends G{constructor(e,t,i){super(),this._bufferService=e,this._logService=t,this._optionsService=i,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new k),this.onData=this._onData.event,this._onUserInput=this._register(new k),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new k),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new k),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=fi(xn),this.decPrivateModes=fi(kn)}reset(){this.modes=fi(xn),this.decPrivateModes=fi(kn)}triggerDataEvent(e,t=!1){if(this._optionsService.rawOptions.disableStdin)return;let i=this._bufferService.buffer;t&&this._optionsService.rawOptions.scrollOnUserInput&&i.ybase!==i.ydisp&&this._onRequestScrollToBottom.fire(),t&&this._onUserInput.fire(),this._logService.debug(`sending data "${e}"`),this._logService.trace("sending data (codes)",()=>e.split("").map(s=>s.charCodeAt(0))),this._onData.fire(e)}triggerBinaryEvent(e){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${e}"`),this._logService.trace("sending binary (codes)",()=>e.split("").map(t=>t.charCodeAt(0))),this._onBinary.fire(e))}};fr=_e([T(0,Ie),T(1,Uo),T(2,Oe)],fr);var En={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:e=>e.button===4||e.action!==1?!1:(e.ctrl=!1,e.alt=!1,e.shift=!1,!0)},VT200:{events:19,restrict:e=>e.action!==32},DRAG:{events:23,restrict:e=>!(e.action===32&&e.button===3)},ANY:{events:31,restrict:e=>!0}};function bs(e,t){let i=(e.ctrl?16:0)|(e.shift?4:0)|(e.alt?8:0);return e.button===4?(i|=64,i|=e.action):(i|=e.button&3,e.button&4&&(i|=64),e.button&8&&(i|=128),e.action===32?i|=32:e.action===0&&!t&&(i|=3)),i}var Cs=String.fromCharCode,Rn={DEFAULT:e=>{let t=[bs(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?"":`\x1B[M${Cs(t[0])}${Cs(t[1])}${Cs(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${bs(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${bs(e,!0)};${e.x};${e.y}${t}`}},pr=class extends G{constructor(e,t,i){super(),this._bufferService=e,this._coreService=t,this._optionsService=i,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new k),this.onProtocolChange=this._onProtocolChange.event;for(let s of Object.keys(En))this.addProtocol(s,En[s]);for(let s of Object.keys(Rn))this.addEncoding(s,Rn[s]);this.reset()}addProtocol(e,t){this._protocols[e]=t}addEncoding(e,t){this._encodings[e]=t}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(e){if(!this._protocols[e])throw new Error(`unknown protocol "${e}"`);this._activeProtocol=e,this._onProtocolChange.fire(this._protocols[e].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(e){if(!this._encodings[e])throw new Error(`unknown encoding "${e}"`);this._activeEncoding=e}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(e,t,i){if(e.deltaY===0||e.shiftKey||t===void 0||i===void 0)return 0;let s=t/i,r=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(r/=s+0,Math.abs(e.deltaY)<50&&(r*=.3),this._wheelPartialScroll+=r,r=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(r*=this._bufferService.rows),r}_applyScrollModifier(e,t){return t.altKey||t.ctrlKey||t.shiftKey?e*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:e*this._optionsService.rawOptions.scrollSensitivity}triggerMouseEvent(e){if(e.col<0||e.col>=this._bufferService.cols||e.row<0||e.row>=this._bufferService.rows||e.button===4&&e.action===32||e.button===3&&e.action!==32||e.button!==4&&(e.action===2||e.action===3)||(e.col++,e.row++,e.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,e,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(e))return!1;let t=this._encodings[this._activeEncoding](e);return t&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(t):this._coreService.triggerDataEvent(t,!0)),this._lastEvent=e,!0}explainEvents(e){return{down:!!(e&1),up:!!(e&2),drag:!!(e&4),move:!!(e&8),wheel:!!(e&16)}}_equalEvents(e,t,i){if(i){if(e.x!==t.x||e.y!==t.y)return!1}else if(e.col!==t.col||e.row!==t.row)return!1;return!(e.button!==t.button||e.action!==t.action||e.ctrl!==t.ctrl||e.alt!==t.alt||e.shift!==t.shift)}};pr=_e([T(0,Ie),T(1,Nt),T(2,Oe)],pr);var xs=[[768,879],[1155,1158],[1160,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1539],[1552,1557],[1611,1630],[1648,1648],[1750,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2305,2306],[2364,2364],[2369,2376],[2381,2381],[2385,2388],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2672,2673],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2817,2817],[2876,2876],[2879,2879],[2881,2883],[2893,2893],[2902,2902],[2946,2946],[3008,3008],[3021,3021],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3393,3395],[3405,3405],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3769],[3771,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3984,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4146],[4150,4151],[4153,4153],[4184,4185],[4448,4607],[4959,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6157],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7616,7626],[7678,7679],[8203,8207],[8234,8238],[8288,8291],[8298,8303],[8400,8431],[12330,12335],[12441,12442],[43014,43014],[43019,43019],[43045,43046],[64286,64286],[65024,65039],[65056,65059],[65279,65279],[65529,65531]],id=[[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[917505,917505],[917536,917631],[917760,917999]],we;function sd(e,t){let i=0,s=t.length-1,r;if(et[s][1])return!1;for(;s>=i;)if(r=i+s>>1,e>t[r][1])i=r+1;else if(e=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let i=this.wcwidth(e),s=i===0&&t!==0;if(s){let r=Tt.extractWidth(t);r===0?s=!1:r>i&&(i=r)}return Tt.createPropertyValue(0,i,s)}},Tt=class qi{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new k,this.onChange=this._onChange.event;let t=new rd;this.register(t),this._active=t.version,this._activeProvider=t}static extractShouldJoin(t){return(t&1)!==0}static extractWidth(t){return t>>1&3}static extractCharKind(t){return t>>3}static createPropertyValue(t,i,s=!1){return(t&16777215)<<3|(i&3)<<1|(s?1:0)}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(t){if(!this._providers[t])throw new Error(`unknown Unicode version "${t}"`);this._active=t,this._activeProvider=this._providers[t],this._onChange.fire(t)}register(t){this._providers[t.version]=t}wcwidth(t){return this._activeProvider.wcwidth(t)}getStringCellWidth(t){let i=0,s=0,r=t.length;for(let n=0;n=r)return i+this.wcwidth(o);let l=t.charCodeAt(n);56320<=l&&l<=57343?o=(o-55296)*1024+l-56320+65536:i+=this.wcwidth(l)}let a=this.charProperties(o,s),h=qi.extractWidth(a);qi.extractShouldJoin(a)&&(h-=qi.extractWidth(s)),i+=h,s=a}return i}charProperties(t,i){return this._activeProvider.charProperties(t,i)}},nd=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(e){this.glevel=e,this.charset=this._charsets[e]}setgCharset(e,t){this._charsets[e]=t,this.glevel===e&&(this.charset=t)}};function Bn(e){var s;let t=(s=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1))==null?void 0:s.get(e.cols-1),i=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);i&&t&&(i.isWrapped=t[3]!==0&&t[3]!==32)}var oi=2147483647,od=256,xa=class mr{constructor(t=32,i=32){if(this.maxLength=t,this.maxSubParamsLength=i,i>od)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(t),this.length=0,this._subParams=new Int32Array(i),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(t),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(t){let i=new mr;if(!t.length)return i;for(let s=Array.isArray(t[0])?1:0;s>8,r=this._subParamsIdx[i]&255;r-s>0&&t.push(Array.prototype.slice.call(this._subParams,s,r))}return t}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(t){if(this._digitIsSub=!1,this.length>=this.maxLength){this._rejectDigits=!0;return}if(t<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=t>oi?oi:t}addSubParam(t){if(this._digitIsSub=!0,!!this.length){if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength){this._rejectSubDigits=!0;return}if(t<-1)throw new Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=t>oi?oi:t,this._subParamsIdx[this.length-1]++}}hasSubParams(t){return(this._subParamsIdx[t]&255)-(this._subParamsIdx[t]>>8)>0}getSubParams(t){let i=this._subParamsIdx[t]>>8,s=this._subParamsIdx[t]&255;return s-i>0?this._subParams.subarray(i,s):null}getSubParamsAll(){let t={};for(let i=0;i>8,r=this._subParamsIdx[i]&255;r-s>0&&(t[i]=this._subParams.slice(s,r))}return t}addDigit(t){let i;if(this._rejectDigits||!(i=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let s=this._digitIsSub?this._subParams:this.params,r=s[i-1];s[i-1]=~r?Math.min(r*10+t,oi):t}},ai=[],ad=class{constructor(){this._state=0,this._active=ai,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let i=this._handlers[e];return i.push(t),{dispose:()=>{let s=i.indexOf(t);s!==-1&&i.splice(s,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=ai}reset(){if(this._state===2)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].end(!1);this._stack.paused=!1,this._active=ai,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||ai,!this._active.length)this._handlerFb(this._id,"START");else for(let e=this._active.length-1;e>=0;e--)this._active[e].start()}_put(e,t,i){if(!this._active.length)this._handlerFb(this._id,"PUT",ls(e,t,i));else for(let s=this._active.length-1;s>=0;s--)this._active[s].put(e,t,i)}start(){this.reset(),this._state=1}put(e,t,i){if(this._state!==3){if(this._state===1)for(;t0&&this._put(e,t,i)}}end(e,t=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),!this._active.length)this._handlerFb(this._id,"END",e);else{let i=!1,s=this._active.length-1,r=!1;if(this._stack.paused&&(s=this._stack.loopPosition-1,i=t,r=this._stack.fallThrough,this._stack.paused=!1),!r&&i===!1){for(;s>=0&&(i=this._active[s].end(e),i!==!0);s--)if(i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!1,i;s--}for(;s>=0;s--)if(i=this._active[s].end(!1),i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!0,i}this._active=ai,this._id=-1,this._state=0}}},Ke=class{constructor(e){this._handler=e,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(e,t,i){this._hitLimit||(this._data+=ls(e,t,i),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}end(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data),t instanceof Promise))return t.then(i=>(this._data="",this._hitLimit=!1,i));return this._data="",this._hitLimit=!1,t}},li=[],ld=class{constructor(){this._handlers=Object.create(null),this._active=li,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=li}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let i=this._handlers[e];return i.push(t),{dispose:()=>{let s=i.indexOf(t);s!==-1&&i.splice(s,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}reset(){if(this._active.length)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].unhook(!1);this._stack.paused=!1,this._active=li,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||li,!this._active.length)this._handlerFb(this._ident,"HOOK",t);else for(let i=this._active.length-1;i>=0;i--)this._active[i].hook(t)}put(e,t,i){if(!this._active.length)this._handlerFb(this._ident,"PUT",ls(e,t,i));else for(let s=this._active.length-1;s>=0;s--)this._active[s].put(e,t,i)}unhook(e,t=!0){if(!this._active.length)this._handlerFb(this._ident,"UNHOOK",e);else{let i=!1,s=this._active.length-1,r=!1;if(this._stack.paused&&(s=this._stack.loopPosition-1,i=t,r=this._stack.fallThrough,this._stack.paused=!1),!r&&i===!1){for(;s>=0&&(i=this._active[s].unhook(e),i!==!0);s--)if(i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!1,i;s--}for(;s>=0;s--)if(i=this._active[s].unhook(!1),i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!0,i}this._active=li,this._ident=0}},pi=new xa;pi.addParam(0);var Mn=class{constructor(e){this._handler=e,this._data="",this._params=pi,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():pi,this._data="",this._hitLimit=!1}put(e,t,i){this._hitLimit||(this._data+=ls(e,t,i),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}unhook(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data,this._params),t instanceof Promise))return t.then(i=>(this._params=pi,this._data="",this._hitLimit=!1,i));return this._params=pi,this._data="",this._hitLimit=!1,t}},hd=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,t){this.table.fill(e<<4|t)}add(e,t,i,s){this.table[t<<8|e]=i<<4|s}addMany(e,t,i,s){for(let r=0;rh),i=(a,h)=>t.slice(a,h),s=i(32,127),r=i(0,24);r.push(25),r.push.apply(r,i(28,32));let n=i(0,14),o;e.setDefault(1,0),e.addMany(s,0,2,0);for(o in n)e.addMany([24,26,153,154],o,3,0),e.addMany(i(128,144),o,3,0),e.addMany(i(144,152),o,3,0),e.add(156,o,0,0),e.add(27,o,11,1),e.add(157,o,4,8),e.addMany([152,158,159],o,0,7),e.add(155,o,11,3),e.add(144,o,11,9);return e.addMany(r,0,3,0),e.addMany(r,1,3,1),e.add(127,1,0,1),e.addMany(r,8,0,8),e.addMany(r,3,3,3),e.add(127,3,0,3),e.addMany(r,4,3,4),e.add(127,4,0,4),e.addMany(r,6,3,6),e.addMany(r,5,3,5),e.add(127,5,0,5),e.addMany(r,2,3,2),e.add(127,2,0,2),e.add(93,1,4,8),e.addMany(s,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(i(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(s,7,0,7),e.addMany(r,7,0,7),e.add(156,7,0,0),e.add(127,7,0,7),e.add(91,1,11,3),e.addMany(i(64,127),3,7,0),e.addMany(i(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(i(48,60),4,8,4),e.addMany(i(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(i(32,64),6,0,6),e.add(127,6,0,6),e.addMany(i(64,127),6,0,0),e.addMany(i(32,48),3,9,5),e.addMany(i(32,48),5,9,5),e.addMany(i(48,64),5,0,6),e.addMany(i(64,127),5,7,0),e.addMany(i(32,48),4,9,5),e.addMany(i(32,48),1,9,2),e.addMany(i(32,48),2,9,2),e.addMany(i(48,127),2,10,0),e.addMany(i(48,80),1,10,0),e.addMany(i(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(i(96,127),1,10,0),e.add(80,1,11,9),e.addMany(r,9,0,9),e.add(127,9,0,9),e.addMany(i(28,32),9,0,9),e.addMany(i(32,48),9,9,12),e.addMany(i(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(r,11,0,11),e.addMany(i(32,128),11,0,11),e.addMany(i(28,32),11,0,11),e.addMany(r,10,0,10),e.add(127,10,0,10),e.addMany(i(28,32),10,0,10),e.addMany(i(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(i(32,48),10,9,12),e.addMany(r,12,0,12),e.add(127,12,0,12),e.addMany(i(28,32),12,0,12),e.addMany(i(32,48),12,9,12),e.addMany(i(48,64),12,0,11),e.addMany(i(64,127),12,12,13),e.addMany(i(64,127),10,12,13),e.addMany(i(64,127),9,12,13),e.addMany(r,13,13,13),e.addMany(s,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(Xe,0,2,0),e.add(Xe,8,5,8),e.add(Xe,6,0,6),e.add(Xe,11,0,11),e.add(Xe,13,13,13),e})(),dd=class extends G{constructor(e=cd){super(),this._transitions=e,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new xa,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(t,i,s)=>{},this._executeHandlerFb=t=>{},this._csiHandlerFb=(t,i)=>{},this._escHandlerFb=t=>{},this._errorHandlerFb=t=>t,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this._register(oe(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new ad),this._dcsParser=this._register(new ld),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(e,t=[64,126]){let i=0;if(e.prefix){if(e.prefix.length>1)throw new Error("only one byte as prefix supported");if(i=e.prefix.charCodeAt(0),i&&60>i||i>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(e.intermediates){if(e.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let r=0;rn||n>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");i<<=8,i|=n}}if(e.final.length!==1)throw new Error("final must be a single byte");let s=e.final.charCodeAt(0);if(t[0]>s||s>t[1])throw new Error(`final must be in range ${t[0]} .. ${t[1]}`);return i<<=8,i|=s,i}identToString(e){let t=[];for(;e;)t.push(String.fromCharCode(e&255)),e>>=8;return t.reverse().join("")}setPrintHandler(e){this._printHandler=e}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(e,t){let i=this._identifier(e,[48,126]);this._escHandlers[i]===void 0&&(this._escHandlers[i]=[]);let s=this._escHandlers[i];return s.push(t),{dispose:()=>{let r=s.indexOf(t);r!==-1&&s.splice(r,1)}}}clearEscHandler(e){this._escHandlers[this._identifier(e,[48,126])]&&delete this._escHandlers[this._identifier(e,[48,126])]}setEscHandlerFallback(e){this._escHandlerFb=e}setExecuteHandler(e,t){this._executeHandlers[e.charCodeAt(0)]=t}clearExecuteHandler(e){this._executeHandlers[e.charCodeAt(0)]&&delete this._executeHandlers[e.charCodeAt(0)]}setExecuteHandlerFallback(e){this._executeHandlerFb=e}registerCsiHandler(e,t){let i=this._identifier(e);this._csiHandlers[i]===void 0&&(this._csiHandlers[i]=[]);let s=this._csiHandlers[i];return s.push(t),{dispose:()=>{let r=s.indexOf(t);r!==-1&&s.splice(r,1)}}}clearCsiHandler(e){this._csiHandlers[this._identifier(e)]&&delete this._csiHandlers[this._identifier(e)]}setCsiHandlerFallback(e){this._csiHandlerFb=e}registerDcsHandler(e,t){return this._dcsParser.registerHandler(this._identifier(e),t)}clearDcsHandler(e){this._dcsParser.clearHandler(this._identifier(e))}setDcsHandlerFallback(e){this._dcsParser.setHandlerFallback(e)}registerOscHandler(e,t){return this._oscParser.registerHandler(e,t)}clearOscHandler(e){this._oscParser.clearHandler(e)}setOscHandlerFallback(e){this._oscParser.setHandlerFallback(e)}setErrorHandler(e){this._errorHandler=e}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(e,t,i,s,r){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=i,this._parseStack.transition=s,this._parseStack.chunkPos=r}parse(e,t,i){let s=0,r=0,n=0,o;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,n=this._parseStack.chunkPos+1;else{if(i===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");let a=this._parseStack.handlers,h=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(i===!1&&h>-1){for(;h>=0&&(o=a[h](this._params),o!==!0);h--)if(o instanceof Promise)return this._parseStack.handlerPos=h,o}this._parseStack.handlers=[];break;case 4:if(i===!1&&h>-1){for(;h>=0&&(o=a[h](),o!==!0);h--)if(o instanceof Promise)return this._parseStack.handlerPos=h,o}this._parseStack.handlers=[];break;case 6:if(s=e[this._parseStack.chunkPos],o=this._dcsParser.unhook(s!==24&&s!==26,i),o)return o;s===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(s=e[this._parseStack.chunkPos],o=this._oscParser.end(s!==24&&s!==26,i),o)return o;s===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break}this._parseStack.state=0,n=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&15}for(let a=n;a>4){case 2:for(let u=a+1;;++u){if(u>=t||(s=e[u])<32||s>126&&s=t||(s=e[u])<32||s>126&&s=t||(s=e[u])<32||s>126&&s=t||(s=e[u])<32||s>126&&s=0&&(o=h[l](this._params),o!==!0);l--)if(o instanceof Promise)return this._preserveStack(3,h,l,r,a),o;l<0&&this._csiHandlerFb(this._collect<<8|s,this._params),this.precedingJoinState=0;break;case 8:do switch(s){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(s-48)}while(++a47&&s<60);a--;break;case 9:this._collect<<=8,this._collect|=s;break;case 10:let c=this._escHandlers[this._collect<<8|s],d=c?c.length-1:-1;for(;d>=0&&(o=c[d](),o!==!0);d--)if(o instanceof Promise)return this._preserveStack(4,c,d,r,a),o;d<0&&this._escHandlerFb(this._collect<<8|s),this.precedingJoinState=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|s,this._params);break;case 13:for(let u=a+1;;++u)if(u>=t||(s=e[u])===24||s===26||s===27||s>127&&s=t||(s=e[u])<32||s>127&&s>4:n>>8}return s}}function ks(e,t){let i=e.toString(16),s=i.length<2?"0"+i:i;switch(t){case 4:return i[0];case 8:return s;case 12:return(s+s).slice(0,3);default:return s+s}}function fd(e,t=16){let[i,s,r]=e;return`rgb:${ks(i,t)}/${ks(s,t)}/${ks(r,t)}`}var pd={"(":0,")":1,"*":2,"+":3,"-":1,".":2},vt=131072,Ln=10;function Tn(e,t){if(e>24)return t.setWinLines||!1;switch(e){case 1:return!!t.restoreWin;case 2:return!!t.minimizeWin;case 3:return!!t.setWinPosition;case 4:return!!t.setWinSizePixels;case 5:return!!t.raiseWin;case 6:return!!t.lowerWin;case 7:return!!t.refreshWin;case 8:return!!t.setWinSizeChars;case 9:return!!t.maximizeWin;case 10:return!!t.fullscreenWin;case 11:return!!t.getWinState;case 13:return!!t.getWinPosition;case 14:return!!t.getWinSizePixels;case 15:return!!t.getScreenSizePixels;case 16:return!!t.getCellSizePixels;case 18:return!!t.getWinSizeChars;case 19:return!!t.getScreenSizeChars;case 20:return!!t.getIconTitle;case 21:return!!t.getWinTitle;case 22:return!!t.pushTitle;case 23:return!!t.popTitle;case 24:return!!t.setWinLines}return!1}var $n=5e3,An=0,md=class extends G{constructor(e,t,i,s,r,n,o,a,h=new dd){super(),this._bufferService=e,this._charsetService=t,this._coreService=i,this._logService=s,this._optionsService=r,this._oscLinkService=n,this._coreMouseService=o,this._unicodeService=a,this._parser=h,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new Pl,this._utf8Decoder=new Nl,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=me.clone(),this._eraseAttrDataInternal=me.clone(),this._onRequestBell=this._register(new k),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new k),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new k),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new k),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new k),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new k),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new k),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new k),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new k),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new k),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new k),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new k),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new k),this.onColor=this._onColor.event,this._parseStack={paused:!1,cursorStartX:0,cursorStartY:0,decodedLength:0,position:0},this._specialColors=[256,257,258],this._register(this._parser),this._dirtyRowTracker=new gr(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(l=>this._activeBuffer=l.activeBuffer)),this._parser.setCsiHandlerFallback((l,c)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(l),params:c.toArray()})}),this._parser.setEscHandlerFallback(l=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(l)})}),this._parser.setExecuteHandlerFallback(l=>{this._logService.debug("Unknown EXECUTE code: ",{code:l})}),this._parser.setOscHandlerFallback((l,c,d)=>{this._logService.debug("Unknown OSC code: ",{identifier:l,action:c,data:d})}),this._parser.setDcsHandlerFallback((l,c,d)=>{c==="HOOK"&&(d=d.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(l),action:c,payload:d})}),this._parser.setPrintHandler((l,c,d)=>this.print(l,c,d)),this._parser.registerCsiHandler({final:"@"},l=>this.insertChars(l)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},l=>this.scrollLeft(l)),this._parser.registerCsiHandler({final:"A"},l=>this.cursorUp(l)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},l=>this.scrollRight(l)),this._parser.registerCsiHandler({final:"B"},l=>this.cursorDown(l)),this._parser.registerCsiHandler({final:"C"},l=>this.cursorForward(l)),this._parser.registerCsiHandler({final:"D"},l=>this.cursorBackward(l)),this._parser.registerCsiHandler({final:"E"},l=>this.cursorNextLine(l)),this._parser.registerCsiHandler({final:"F"},l=>this.cursorPrecedingLine(l)),this._parser.registerCsiHandler({final:"G"},l=>this.cursorCharAbsolute(l)),this._parser.registerCsiHandler({final:"H"},l=>this.cursorPosition(l)),this._parser.registerCsiHandler({final:"I"},l=>this.cursorForwardTab(l)),this._parser.registerCsiHandler({final:"J"},l=>this.eraseInDisplay(l,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},l=>this.eraseInDisplay(l,!0)),this._parser.registerCsiHandler({final:"K"},l=>this.eraseInLine(l,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},l=>this.eraseInLine(l,!0)),this._parser.registerCsiHandler({final:"L"},l=>this.insertLines(l)),this._parser.registerCsiHandler({final:"M"},l=>this.deleteLines(l)),this._parser.registerCsiHandler({final:"P"},l=>this.deleteChars(l)),this._parser.registerCsiHandler({final:"S"},l=>this.scrollUp(l)),this._parser.registerCsiHandler({final:"T"},l=>this.scrollDown(l)),this._parser.registerCsiHandler({final:"X"},l=>this.eraseChars(l)),this._parser.registerCsiHandler({final:"Z"},l=>this.cursorBackwardTab(l)),this._parser.registerCsiHandler({final:"`"},l=>this.charPosAbsolute(l)),this._parser.registerCsiHandler({final:"a"},l=>this.hPositionRelative(l)),this._parser.registerCsiHandler({final:"b"},l=>this.repeatPrecedingCharacter(l)),this._parser.registerCsiHandler({final:"c"},l=>this.sendDeviceAttributesPrimary(l)),this._parser.registerCsiHandler({prefix:">",final:"c"},l=>this.sendDeviceAttributesSecondary(l)),this._parser.registerCsiHandler({final:"d"},l=>this.linePosAbsolute(l)),this._parser.registerCsiHandler({final:"e"},l=>this.vPositionRelative(l)),this._parser.registerCsiHandler({final:"f"},l=>this.hVPosition(l)),this._parser.registerCsiHandler({final:"g"},l=>this.tabClear(l)),this._parser.registerCsiHandler({final:"h"},l=>this.setMode(l)),this._parser.registerCsiHandler({prefix:"?",final:"h"},l=>this.setModePrivate(l)),this._parser.registerCsiHandler({final:"l"},l=>this.resetMode(l)),this._parser.registerCsiHandler({prefix:"?",final:"l"},l=>this.resetModePrivate(l)),this._parser.registerCsiHandler({final:"m"},l=>this.charAttributes(l)),this._parser.registerCsiHandler({final:"n"},l=>this.deviceStatus(l)),this._parser.registerCsiHandler({prefix:"?",final:"n"},l=>this.deviceStatusPrivate(l)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},l=>this.softReset(l)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},l=>this.setCursorStyle(l)),this._parser.registerCsiHandler({final:"r"},l=>this.setScrollRegion(l)),this._parser.registerCsiHandler({final:"s"},l=>this.saveCursor(l)),this._parser.registerCsiHandler({final:"t"},l=>this.windowOptions(l)),this._parser.registerCsiHandler({final:"u"},l=>this.restoreCursor(l)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},l=>this.insertColumns(l)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},l=>this.deleteColumns(l)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},l=>this.selectProtected(l)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},l=>this.requestMode(l,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},l=>this.requestMode(l,!1)),this._parser.setExecuteHandler(v.BEL,()=>this.bell()),this._parser.setExecuteHandler(v.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(v.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(v.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(v.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(v.BS,()=>this.backspace()),this._parser.setExecuteHandler(v.HT,()=>this.tab()),this._parser.setExecuteHandler(v.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(v.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(ji.IND,()=>this.index()),this._parser.setExecuteHandler(ji.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(ji.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new Ke(l=>(this.setTitle(l),this.setIconName(l),!0))),this._parser.registerOscHandler(1,new Ke(l=>this.setIconName(l))),this._parser.registerOscHandler(2,new Ke(l=>this.setTitle(l))),this._parser.registerOscHandler(4,new Ke(l=>this.setOrReportIndexedColor(l))),this._parser.registerOscHandler(8,new Ke(l=>this.setHyperlink(l))),this._parser.registerOscHandler(10,new Ke(l=>this.setOrReportFgColor(l))),this._parser.registerOscHandler(11,new Ke(l=>this.setOrReportBgColor(l))),this._parser.registerOscHandler(12,new Ke(l=>this.setOrReportCursorColor(l))),this._parser.registerOscHandler(104,new Ke(l=>this.restoreIndexedColor(l))),this._parser.registerOscHandler(110,new Ke(l=>this.restoreFgColor(l))),this._parser.registerOscHandler(111,new Ke(l=>this.restoreBgColor(l))),this._parser.registerOscHandler(112,new Ke(l=>this.restoreCursorColor(l))),this._parser.registerEscHandler({final:"7"},()=>this.saveCursor()),this._parser.registerEscHandler({final:"8"},()=>this.restoreCursor()),this._parser.registerEscHandler({final:"D"},()=>this.index()),this._parser.registerEscHandler({final:"E"},()=>this.nextLine()),this._parser.registerEscHandler({final:"H"},()=>this.tabSet()),this._parser.registerEscHandler({final:"M"},()=>this.reverseIndex()),this._parser.registerEscHandler({final:"="},()=>this.keypadApplicationMode()),this._parser.registerEscHandler({final:">"},()=>this.keypadNumericMode()),this._parser.registerEscHandler({final:"c"},()=>this.fullReset()),this._parser.registerEscHandler({final:"n"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"o"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"|"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"}"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"~"},()=>this.setgLevel(1)),this._parser.registerEscHandler({intermediates:"%",final:"@"},()=>this.selectDefaultCharset()),this._parser.registerEscHandler({intermediates:"%",final:"G"},()=>this.selectDefaultCharset());for(let l in be)this._parser.registerEscHandler({intermediates:"(",final:l},()=>this.selectCharset("("+l)),this._parser.registerEscHandler({intermediates:")",final:l},()=>this.selectCharset(")"+l)),this._parser.registerEscHandler({intermediates:"*",final:l},()=>this.selectCharset("*"+l)),this._parser.registerEscHandler({intermediates:"+",final:l},()=>this.selectCharset("+"+l)),this._parser.registerEscHandler({intermediates:"-",final:l},()=>this.selectCharset("-"+l)),this._parser.registerEscHandler({intermediates:".",final:l},()=>this.selectCharset("."+l)),this._parser.registerEscHandler({intermediates:"/",final:l},()=>this.selectCharset("/"+l));this._parser.registerEscHandler({intermediates:"#",final:"8"},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(l=>(this._logService.error("Parsing error: ",l),l)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new Mn((l,c)=>this.requestStatusString(l,c)))}getAttrData(){return this._curAttrData}_preserveStack(e,t,i,s){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=t,this._parseStack.decodedLength=i,this._parseStack.position=s}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((t,i)=>setTimeout(()=>i("#SLOW_TIMEOUT"),$n))]).catch(t=>{if(t!=="#SLOW_TIMEOUT")throw t;console.warn(`async parser handler taking longer than ${$n} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let i,s=this._activeBuffer.x,r=this._activeBuffer.y,n=0,o=this._parseStack.paused;if(o){if(i=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t))return this._logSlowResolvingAsync(i),i;s=this._parseStack.cursorStartX,r=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>vt&&(n=this._parseStack.position+vt)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof e=="string"?` "${e}"`:` "${Array.prototype.map.call(e,l=>String.fromCharCode(l)).join("")}"`}`),this._logService.logLevel===0&&this._logService.trace("parsing data (codes)",typeof e=="string"?e.split("").map(l=>l.charCodeAt(0)):e),this._parseBuffer.lengthvt)for(let l=n;l0&&d.getWidth(this._activeBuffer.x-1)===2&&d.setCellFromCodepoint(this._activeBuffer.x-1,0,1,c);let u=this._parser.precedingJoinState;for(let f=t;fa){if(h){let E=d,z=this._activeBuffer.x-g;for(this._activeBuffer.x=g,this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData(),!0)):(this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!0),d=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),g>0&&d instanceof _i&&d.copyCellsFrom(E,z,0,g,!1);z=0;)d.setCellFromCodepoint(this._activeBuffer.x++,0,0,c);continue}if(l&&(d.insertCells(this._activeBuffer.x,r-g,this._activeBuffer.getNullCell(c)),d.getWidth(a-1)===2&&d.setCellFromCodepoint(a-1,0,1,c)),d.setCellFromCodepoint(this._activeBuffer.x++,s,r,c),r>0)for(;--r;)d.setCellFromCodepoint(this._activeBuffer.x++,0,0,c)}this._parser.precedingJoinState=u,this._activeBuffer.x0&&d.getWidth(this._activeBuffer.x)===0&&!d.hasContent(this._activeBuffer.x)&&d.setCellFromCodepoint(this._activeBuffer.x,0,1,c),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,t){return e.final==="t"&&!e.prefix&&!e.intermediates?this._parser.registerCsiHandler(e,i=>Tn(i.params[0],this._optionsService.rawOptions.windowOptions)?t(i):!0):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new Mn(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new Ke(t))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){var e;if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&((e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y))!=null&&e.isWrapped)){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);t.hasWidth(this._activeBuffer.x)&&!t.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-e),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(e=this._bufferService.cols-1){this._activeBuffer.x=Math.min(e,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(e,t){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=e,this._activeBuffer.y=this._activeBuffer.scrollTop+t):(this._activeBuffer.x=e,this._activeBuffer.y=t),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(e,t){this._restrictCursor(),this._setCursor(this._activeBuffer.x+e,this._activeBuffer.y+t)}cursorUp(e){let t=this._activeBuffer.y-this._activeBuffer.scrollTop;return t>=0?this._moveCursor(0,-Math.min(t,e.params[0]||1)):this._moveCursor(0,-(e.params[0]||1)),!0}cursorDown(e){let t=this._activeBuffer.scrollBottom-this._activeBuffer.y;return t>=0?this._moveCursor(0,Math.min(t,e.params[0]||1)):this._moveCursor(0,e.params[0]||1),!0}cursorForward(e){return this._moveCursor(e.params[0]||1,0),!0}cursorBackward(e){return this._moveCursor(-(e.params[0]||1),0),!0}cursorNextLine(e){return this.cursorDown(e),this._activeBuffer.x=0,!0}cursorPrecedingLine(e){return this.cursorUp(e),this._activeBuffer.x=0,!0}cursorCharAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(e){return this._setCursor(e.length>=2?(e.params[1]||1)-1:0,(e.params[0]||1)-1),!0}charPosAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(e){return this._moveCursor(e.params[0]||1,0),!0}linePosAbsolute(e){return this._setCursor(this._activeBuffer.x,(e.params[0]||1)-1),!0}vPositionRelative(e){return this._moveCursor(0,e.params[0]||1),!0}hVPosition(e){return this.cursorPosition(e),!0}tabClear(e){let t=e.params[0];return t===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:t===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(e){let t=e.params[0];return t===1&&(this._curAttrData.bg|=536870912),(t===2||t===0)&&(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(e,t,i,s=!1,r=!1){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n.replaceCells(t,i,this._activeBuffer.getNullCell(this._eraseAttrData()),r),s&&(n.isWrapped=!1)}_resetBufferLine(e,t=!1){let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);i&&(i.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),t),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),i.isWrapped=!1)}eraseInDisplay(e,t=!1){var s;this._restrictCursor(this._bufferService.cols);let i;switch(e.params[0]){case 0:for(i=this._activeBuffer.y,this._dirtyRowTracker.markDirty(i),this._eraseInBufferLine(i++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);i=this._bufferService.cols&&(this._activeBuffer.lines.get(i+1).isWrapped=!1);i--;)this._resetBufferLine(i,t);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(i=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,i-1);i--&&!((s=this._activeBuffer.lines.get(this._activeBuffer.ybase+i))!=null&&s.getTrimmedLength()););for(;i>=0;i--)this._bufferService.scroll(this._eraseAttrData())}else{for(i=this._bufferService.rows,this._dirtyRowTracker.markDirty(i-1);i--;)this._resetBufferLine(i,t);this._dirtyRowTracker.markDirty(0)}break;case 3:let r=this._activeBuffer.lines.length-this._bufferService.rows;r>0&&(this._activeBuffer.lines.trimStart(r),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-r,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-r,0),this._onScroll.fire(0));break}return!0}eraseInLine(e,t=!1){switch(this._restrictCursor(this._bufferService.cols),e.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,t);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,t);break}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.ythis._activeBuffer.scrollBottom||this._activeBuffer.ythis._activeBuffer.scrollBottom||this._activeBuffer.ythis._activeBuffer.scrollBottom||this._activeBuffer.ythis._activeBuffer.scrollBottom||this._activeBuffer.ythis._activeBuffer.scrollBottom||this._activeBuffer.y65535?2:1}let h=a;for(let l=1;l0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(v.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(v.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(v.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(v.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(v.ESC+"[>83;40003;0c")),!0}_is(e){return(this._optionsService.rawOptions.termName+"").indexOf(e)===0}setMode(e){for(let t=0;t(p[p.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",p[p.SET=1]="SET",p[p.RESET=2]="RESET",p[p.PERMANENTLY_SET=3]="PERMANENTLY_SET",p[p.PERMANENTLY_RESET=4]="PERMANENTLY_RESET"))(void 0||(i={}));let s=this._coreService.decPrivateModes,{activeProtocol:r,activeEncoding:n}=this._coreMouseService,o=this._coreService,{buffers:a,cols:h}=this._bufferService,{active:l,alt:c}=a,d=this._optionsService.rawOptions,u=(p,g)=>(o.triggerDataEvent(`${v.ESC}[${t?"":"?"}${p};${g}$y`),!0),f=p=>p?1:2,_=e.params[0];return t?_===2?u(_,4):_===4?u(_,f(o.modes.insertMode)):_===12?u(_,3):_===20?u(_,f(d.convertEol)):u(_,0):_===1?u(_,f(s.applicationCursorKeys)):_===3?u(_,d.windowOptions.setWinLines?h===80?2:h===132?1:0:0):_===6?u(_,f(s.origin)):_===7?u(_,f(s.wraparound)):_===8?u(_,3):_===9?u(_,f(r==="X10")):_===12?u(_,f(d.cursorBlink)):_===25?u(_,f(!o.isCursorHidden)):_===45?u(_,f(s.reverseWraparound)):_===66?u(_,f(s.applicationKeypad)):_===67?u(_,4):_===1e3?u(_,f(r==="VT200")):_===1002?u(_,f(r==="DRAG")):_===1003?u(_,f(r==="ANY")):_===1004?u(_,f(s.sendFocus)):_===1005?u(_,4):_===1006?u(_,f(n==="SGR")):_===1015?u(_,4):_===1016?u(_,f(n==="SGR_PIXELS")):_===1048?u(_,1):_===47||_===1047||_===1049?u(_,f(l===c)):_===2004?u(_,f(s.bracketedPasteMode)):_===2026?u(_,f(s.synchronizedOutput)):u(_,0)}_updateAttrColor(e,t,i,s,r){return t===2?(e|=50331648,e&=-16777216,e|=Ci.fromColorRGB([i,s,r])):t===5&&(e&=-50331904,e|=33554432|i&255),e}_extractColor(e,t,i){let s=[0,0,-1,0,0,0],r=0,n=0;do{if(s[n+r]=e.params[t+n],e.hasSubParams(t+n)){let o=e.getSubParams(t+n),a=0;do s[1]===5&&(r=1),s[n+a+1+r]=o[a];while(++a=2||s[1]===2&&n+r>=5)break;s[1]&&(r=1)}while(++n+t5)&&(e=1),t.extended.underlineStyle=e,t.fg|=268435456,e===0&&(t.fg&=-268435457),t.updateExtended()}_processSGR0(e){e.fg=me.fg,e.bg=me.bg,e.extended=e.extended.clone(),e.extended.underlineStyle=0,e.extended.underlineColor&=-67108864,e.updateExtended()}charAttributes(e){if(e.length===1&&e.params[0]===0)return this._processSGR0(this._curAttrData),!0;let t=e.length,i,s=this._curAttrData;for(let r=0;r=30&&i<=37?(s.fg&=-50331904,s.fg|=16777216|i-30):i>=40&&i<=47?(s.bg&=-50331904,s.bg|=16777216|i-40):i>=90&&i<=97?(s.fg&=-50331904,s.fg|=16777216|i-90|8):i>=100&&i<=107?(s.bg&=-50331904,s.bg|=16777216|i-100|8):i===0?this._processSGR0(s):i===1?s.fg|=134217728:i===3?s.bg|=67108864:i===4?(s.fg|=268435456,this._processUnderline(e.hasSubParams(r)?e.getSubParams(r)[0]:1,s)):i===5?s.fg|=536870912:i===7?s.fg|=67108864:i===8?s.fg|=1073741824:i===9?s.fg|=2147483648:i===2?s.bg|=134217728:i===21?this._processUnderline(2,s):i===22?(s.fg&=-134217729,s.bg&=-134217729):i===23?s.bg&=-67108865:i===24?(s.fg&=-268435457,this._processUnderline(0,s)):i===25?s.fg&=-536870913:i===27?s.fg&=-67108865:i===28?s.fg&=-1073741825:i===29?s.fg&=2147483647:i===39?(s.fg&=-67108864,s.fg|=me.fg&16777215):i===49?(s.bg&=-67108864,s.bg|=me.bg&16777215):i===38||i===48||i===58?r+=this._extractColor(e,r,s):i===53?s.bg|=1073741824:i===55?s.bg&=-1073741825:i===59?(s.extended=s.extended.clone(),s.extended.underlineColor=-1,s.updateExtended()):i===100?(s.fg&=-67108864,s.fg|=me.fg&16777215,s.bg&=-67108864,s.bg|=me.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",i);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${v.ESC}[0n`);break;case 6:let t=this._activeBuffer.y+1,i=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${v.ESC}[${t};${i}R`);break}return!0}deviceStatusPrivate(e){switch(e.params[0]){case 6:let t=this._activeBuffer.y+1,i=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${v.ESC}[?${t};${i}R`);break}return!0}softReset(e){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=me.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(e){let t=e.length===0?1:e.params[0];if(t===0)this._coreService.decPrivateModes.cursorStyle=void 0,this._coreService.decPrivateModes.cursorBlink=void 0;else{switch(t){case 1:case 2:this._coreService.decPrivateModes.cursorStyle="block";break;case 3:case 4:this._coreService.decPrivateModes.cursorStyle="underline";break;case 5:case 6:this._coreService.decPrivateModes.cursorStyle="bar";break}let i=t%2===1;this._coreService.decPrivateModes.cursorBlink=i}return!0}setScrollRegion(e){let t=e.params[0]||1,i;return(e.length<2||(i=e.params[1])>this._bufferService.rows||i===0)&&(i=this._bufferService.rows),i>t&&(this._activeBuffer.scrollTop=t-1,this._activeBuffer.scrollBottom=i-1,this._setCursor(0,0)),!0}windowOptions(e){if(!Tn(e.params[0],this._optionsService.rawOptions.windowOptions))return!0;let t=e.length>1?e.params[1]:0;switch(e.params[0]){case 14:t!==2&&this._onRequestWindowsOptionsReport.fire(0);break;case 16:this._onRequestWindowsOptionsReport.fire(1);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${v.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>Ln&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>Ln&&this._iconNameStack.shift());break;case 23:(t===0||t===2)&&this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),(t===0||t===1)&&this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop());break}return!0}saveCursor(e){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(e){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(e){return this._windowTitle=e,this._onTitleChange.fire(e),!0}setIconName(e){return this._iconName=e,!0}setOrReportIndexedColor(e){let t=[],i=e.split(";");for(;i.length>1;){let s=i.shift(),r=i.shift();if(/^\d+$/.exec(s)){let n=parseInt(s);if(Pn(n))if(r==="?")t.push({type:0,index:n});else{let o=Dn(r);o&&t.push({type:1,index:n,color:o})}}}return t.length&&this._onColor.fire(t),!0}setHyperlink(e){let t=e.indexOf(";");if(t===-1)return!0;let i=e.slice(0,t).trim(),s=e.slice(t+1);return s?this._createHyperlink(i,s):i.trim()?!1:this._finishHyperlink()}_createHyperlink(e,t){this._getCurrentLinkId()&&this._finishHyperlink();let i=e.split(":"),s,r=i.findIndex(n=>n.startsWith("id="));return r!==-1&&(s=i[r].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:s,uri:t}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(e,t){let i=e.split(";");for(let s=0;s=this._specialColors.length);++s,++t)if(i[s]==="?")this._onColor.fire([{type:0,index:this._specialColors[t]}]);else{let r=Dn(i[s]);r&&this._onColor.fire([{type:1,index:this._specialColors[t],color:r}])}return!0}setOrReportFgColor(e){return this._setOrReportSpecialColor(e,0)}setOrReportBgColor(e){return this._setOrReportSpecialColor(e,1)}setOrReportCursorColor(e){return this._setOrReportSpecialColor(e,2)}restoreIndexedColor(e){if(!e)return this._onColor.fire([{type:2}]),!0;let t=[],i=e.split(";");for(let s=0;s=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._restrictCursor(),!0}tabSet(){return this._activeBuffer.tabs[this._activeBuffer.x]=!0,!0}reverseIndex(){if(this._restrictCursor(),this._activeBuffer.y===this._activeBuffer.scrollTop){let e=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,e,1),this._activeBuffer.lines.set(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.getBlankLine(this._eraseAttrData())),this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom)}else this._activeBuffer.y--,this._restrictCursor();return!0}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),!0}reset(){this._curAttrData=me.clone(),this._eraseAttrDataInternal=me.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=this._curAttrData.bg&67108863,this._eraseAttrDataInternal}setgLevel(e){return this._charsetService.setgLevel(e),!0}screenAlignmentPattern(){let e=new Je;e.content=1<<22|69,e.fg=this._curAttrData.fg,e.bg=this._curAttrData.bg,this._setCursor(0,0);for(let t=0;t(this._coreService.triggerDataEvent(`${v.ESC}${o}${v.ESC}\\`),!0),s=this._bufferService.buffer,r=this._optionsService.rawOptions;return i(e==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:e==='"p'?'P1$r61;1"p':e==="r"?`P1$r${s.scrollTop+1};${s.scrollBottom+1}r`:e==="m"?"P1$r0m":e===" q"?`P1$r${{block:2,underline:4,bar:6}[r.cursorStyle]-(r.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(e,t){this._dirtyRowTracker.markRangeDirty(e,t)}},gr=class{constructor(e){this._bufferService=e,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(e){ethis.end&&(this.end=e)}markRangeDirty(e,t){e>t&&(An=e,e=t,t=An),ethis.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};gr=_e([T(0,Ie)],gr);function Pn(e){return 0<=e&&e<256}var gd=5e7,Nn=12,vd=50,Sd=class extends G{constructor(e){super(),this._action=e,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this._register(new k),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(e,t){if(t!==void 0&&this._syncCalls>t){this._syncCalls=0;return}if(this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;this._isSyncWriting=!0;let i;for(;i=this._writeBuffer.shift();){this._action(i);let s=this._callbacks.shift();s&&s()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,t){if(this._pendingData>gd)throw new Error("write data discarded, use flow control to avoid losing data");if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput){this._didUserInput=!1,this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t),this._innerWrite();return}setTimeout(()=>this._innerWrite())}this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t)}_innerWrite(e=0,t=!0){let i=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let s=this._writeBuffer[this._bufferOffset],r=this._action(s,t);if(r){let o=a=>performance.now()-i>=Nn?setTimeout(()=>this._innerWrite(0,a)):this._innerWrite(i,a);r.catch(a=>(queueMicrotask(()=>{throw a}),Promise.resolve(!1))).then(o);return}let n=this._callbacks[this._bufferOffset];if(n&&n(),this._bufferOffset++,this._pendingData-=s.length,performance.now()-i>=Nn)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>vd&&(this._writeBuffer=this._writeBuffer.slice(this._bufferOffset),this._callbacks=this._callbacks.slice(this._bufferOffset),this._bufferOffset=0),setTimeout(()=>this._innerWrite())):(this._writeBuffer.length=0,this._callbacks.length=0,this._pendingData=0,this._bufferOffset=0),this._onWriteParsed.fire()}},vr=class{constructor(e){this._bufferService=e,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(e){let t=this._bufferService.buffer;if(e.id===void 0){let a=t.addMarker(t.ybase+t.y),h={data:e,id:this._nextId++,lines:[a]};return a.onDispose(()=>this._removeMarkerFromLink(h,a)),this._dataByLinkId.set(h.id,h),h.id}let i=e,s=this._getEntryIdKey(i),r=this._entriesWithId.get(s);if(r)return this.addLineToLink(r.id,t.ybase+t.y),r.id;let n=t.addMarker(t.ybase+t.y),o={id:this._nextId++,key:this._getEntryIdKey(i),data:i,lines:[n]};return n.onDispose(()=>this._removeMarkerFromLink(o,n)),this._entriesWithId.set(o.key,o),this._dataByLinkId.set(o.id,o),o.id}addLineToLink(e,t){let i=this._dataByLinkId.get(e);if(i&&i.lines.every(s=>s.line!==t)){let s=this._bufferService.buffer.addMarker(t);i.lines.push(s),s.onDispose(()=>this._removeMarkerFromLink(i,s))}}getLinkData(e){var t;return(t=this._dataByLinkId.get(e))==null?void 0:t.data}_getEntryIdKey(e){return`${e.id};;${e.uri}`}_removeMarkerFromLink(e,t){let i=e.lines.indexOf(t);i!==-1&&(e.lines.splice(i,1),e.lines.length===0&&(e.data.id!==void 0&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};vr=_e([T(0,Ie)],vr);var In=!1,yd=class extends G{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new Yt),this._onBinary=this._register(new k),this.onBinary=this._onBinary.event,this._onData=this._register(new k),this.onData=this._onData.event,this._onLineFeed=this._register(new k),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new k),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new k),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new k),this._instantiationService=new jc,this.optionsService=this._register(new ed(e)),this._instantiationService.setService(Oe,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(_r)),this._instantiationService.setService(Ie,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(ur)),this._instantiationService.setService(Uo,this._logService),this.coreService=this._register(this._instantiationService.createInstance(fr)),this._instantiationService.setService(Nt,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(pr)),this._instantiationService.setService(zo,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(Tt)),this._instantiationService.setService(Fl,this.unicodeService),this._charsetService=this._instantiationService.createInstance(nd),this._instantiationService.setService(Hl,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(vr),this._instantiationService.setService(jo,this._oscLinkService),this._inputHandler=this._register(new md(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(Le.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(Le.forward(this._bufferService.onResize,this._onResize)),this._register(Le.forward(this.coreService.onData,this._onData)),this._register(Le.forward(this.coreService.onBinary,this._onBinary)),this._register(this.coreService.onRequestScrollToBottom(()=>this.scrollToBottom(!0))),this._register(this.coreService.onUserInput(()=>this._writeBuffer.handleUserInput())),this._register(this.optionsService.onMultipleOptionChange(["windowsMode","windowsPty"],()=>this._handleWindowsPtyOptionChange())),this._register(this._bufferService.onScroll(()=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)})),this._writeBuffer=this._register(new Sd((t,i)=>this._inputHandler.parse(t,i))),this._register(Le.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new k),this._onScroll.event(e=>{var t;(t=this._onScrollApi)==null||t.fire(e.position)})),this._onScrollApi.event}get cols(){return this._bufferService.cols}get rows(){return this._bufferService.rows}get buffers(){return this._bufferService.buffers}get options(){return this.optionsService.options}set options(e){for(let t in e)this.optionsService.options[t]=e[t]}write(e,t){this._writeBuffer.write(e,t)}writeSync(e,t){this._logService.logLevel<=3&&!In&&(this._logService.warn("writeSync is unreliable and will be removed soon."),In=!0),this._writeBuffer.writeSync(e,t)}input(e,t=!0){this.coreService.triggerDataEvent(e,t)}resize(e,t){isNaN(e)||isNaN(t)||(e=Math.max(e,ba),t=Math.max(t,Ca),this._bufferService.resize(e,t))}scroll(e,t=!1){this._bufferService.scroll(e,t)}scrollLines(e,t){this._bufferService.scrollLines(e,t)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}registerEscHandler(e,t){return this._inputHandler.registerEscHandler(e,t)}registerDcsHandler(e,t){return this._inputHandler.registerDcsHandler(e,t)}registerCsiHandler(e,t){return this._inputHandler.registerCsiHandler(e,t)}registerOscHandler(e,t){return this._inputHandler.registerOscHandler(e,t)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let e=!1,t=this.optionsService.rawOptions.windowsPty;t&&t.buildNumber!==void 0&&t.buildNumber!==void 0?e=t.backend==="conpty"&&t.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(e=!0),e?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){let e=[];e.push(this.onLineFeed(Bn.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(Bn(this._bufferService),!1))),this._windowsWrappingHeuristics.value=oe(()=>{for(let t of e)t.dispose()})}}},wd={48:["0",")"],49:["1","!"],50:["2","@"],51:["3","#"],52:["4","$"],53:["5","%"],54:["6","^"],55:["7","&"],56:["8","*"],57:["9","("],186:[";",":"],187:["=","+"],188:[",","<"],189:["-","_"],190:[".",">"],191:["/","?"],192:["`","~"],219:["[","{"],220:["\\","|"],221:["]","}"],222:["'",'"']};function bd(e,t,i,s){var o;let r={type:0,cancel:!1,key:void 0},n=(e.shiftKey?1:0)|(e.altKey?2:0)|(e.ctrlKey?4:0)|(e.metaKey?8:0);switch(e.keyCode){case 0:e.key==="UIKeyInputUpArrow"?t?r.key=v.ESC+"OA":r.key=v.ESC+"[A":e.key==="UIKeyInputLeftArrow"?t?r.key=v.ESC+"OD":r.key=v.ESC+"[D":e.key==="UIKeyInputRightArrow"?t?r.key=v.ESC+"OC":r.key=v.ESC+"[C":e.key==="UIKeyInputDownArrow"&&(t?r.key=v.ESC+"OB":r.key=v.ESC+"[B");break;case 8:r.key=e.ctrlKey?"\b":v.DEL,e.altKey&&(r.key=v.ESC+r.key);break;case 9:if(e.shiftKey){r.key=v.ESC+"[Z";break}r.key=v.HT,r.cancel=!0;break;case 13:r.key=e.altKey?v.ESC+v.CR:v.CR,r.cancel=!0;break;case 27:r.key=v.ESC,e.altKey&&(r.key=v.ESC+v.ESC),r.cancel=!0;break;case 37:if(e.metaKey)break;n?r.key=v.ESC+"[1;"+(n+1)+"D":t?r.key=v.ESC+"OD":r.key=v.ESC+"[D";break;case 39:if(e.metaKey)break;n?r.key=v.ESC+"[1;"+(n+1)+"C":t?r.key=v.ESC+"OC":r.key=v.ESC+"[C";break;case 38:if(e.metaKey)break;n?r.key=v.ESC+"[1;"+(n+1)+"A":t?r.key=v.ESC+"OA":r.key=v.ESC+"[A";break;case 40:if(e.metaKey)break;n?r.key=v.ESC+"[1;"+(n+1)+"B":t?r.key=v.ESC+"OB":r.key=v.ESC+"[B";break;case 45:!e.shiftKey&&!e.ctrlKey&&(r.key=v.ESC+"[2~");break;case 46:n?r.key=v.ESC+"[3;"+(n+1)+"~":r.key=v.ESC+"[3~";break;case 36:n?r.key=v.ESC+"[1;"+(n+1)+"H":t?r.key=v.ESC+"OH":r.key=v.ESC+"[H";break;case 35:n?r.key=v.ESC+"[1;"+(n+1)+"F":t?r.key=v.ESC+"OF":r.key=v.ESC+"[F";break;case 33:e.shiftKey?r.type=2:e.ctrlKey?r.key=v.ESC+"[5;"+(n+1)+"~":r.key=v.ESC+"[5~";break;case 34:e.shiftKey?r.type=3:e.ctrlKey?r.key=v.ESC+"[6;"+(n+1)+"~":r.key=v.ESC+"[6~";break;case 112:n?r.key=v.ESC+"[1;"+(n+1)+"P":r.key=v.ESC+"OP";break;case 113:n?r.key=v.ESC+"[1;"+(n+1)+"Q":r.key=v.ESC+"OQ";break;case 114:n?r.key=v.ESC+"[1;"+(n+1)+"R":r.key=v.ESC+"OR";break;case 115:n?r.key=v.ESC+"[1;"+(n+1)+"S":r.key=v.ESC+"OS";break;case 116:n?r.key=v.ESC+"[15;"+(n+1)+"~":r.key=v.ESC+"[15~";break;case 117:n?r.key=v.ESC+"[17;"+(n+1)+"~":r.key=v.ESC+"[17~";break;case 118:n?r.key=v.ESC+"[18;"+(n+1)+"~":r.key=v.ESC+"[18~";break;case 119:n?r.key=v.ESC+"[19;"+(n+1)+"~":r.key=v.ESC+"[19~";break;case 120:n?r.key=v.ESC+"[20;"+(n+1)+"~":r.key=v.ESC+"[20~";break;case 121:n?r.key=v.ESC+"[21;"+(n+1)+"~":r.key=v.ESC+"[21~";break;case 122:n?r.key=v.ESC+"[23;"+(n+1)+"~":r.key=v.ESC+"[23~";break;case 123:n?r.key=v.ESC+"[24;"+(n+1)+"~":r.key=v.ESC+"[24~";break;default:if(e.ctrlKey&&!e.shiftKey&&!e.altKey&&!e.metaKey)e.keyCode>=65&&e.keyCode<=90?r.key=String.fromCharCode(e.keyCode-64):e.keyCode===32?r.key=v.NUL:e.keyCode>=51&&e.keyCode<=55?r.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?r.key=v.DEL:e.keyCode===219?r.key=v.ESC:e.keyCode===220?r.key=v.FS:e.keyCode===221&&(r.key=v.GS);else if((!i||s)&&e.altKey&&!e.metaKey){let a=(o=wd[e.keyCode])==null?void 0:o[e.shiftKey?1:0];if(a)r.key=v.ESC+a;else if(e.keyCode>=65&&e.keyCode<=90){let h=e.ctrlKey?e.keyCode-64:e.keyCode+32,l=String.fromCharCode(h);e.shiftKey&&(l=l.toUpperCase()),r.key=v.ESC+l}else if(e.keyCode===32)r.key=v.ESC+(e.ctrlKey?v.NUL:" ");else if(e.key==="Dead"&&e.code.startsWith("Key")){let h=e.code.slice(3,4);e.shiftKey||(h=h.toLowerCase()),r.key=v.ESC+h,r.cancel=!0}}else i&&!e.altKey&&!e.ctrlKey&&!e.shiftKey&&e.metaKey?e.keyCode===65&&(r.type=1):e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.keyCode>=48&&e.key.length===1?r.key=e.key:e.key&&e.ctrlKey&&(e.key==="_"&&(r.key=v.US),e.key==="@"&&(r.key=v.NUL));break}return r}var fe=0,Cd=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new ns,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new ns,this._isFlushingDeleted=!1}clear(){this._array.length=0,this._insertedValues.length=0,this._flushInsertedTask.clear(),this._isFlushingInserted=!1,this._deletedIndices.length=0,this._flushDeletedTask.clear(),this._isFlushingDeleted=!1}insert(e){this._flushCleanupDeleted(),this._insertedValues.length===0&&this._flushInsertedTask.enqueue(()=>this._flushInserted()),this._insertedValues.push(e)}_flushInserted(){let e=this._insertedValues.sort((r,n)=>this._getKey(r)-this._getKey(n)),t=0,i=0,s=new Array(this._array.length+this._insertedValues.length);for(let r=0;r=this._array.length||this._getKey(e[t])<=this._getKey(this._array[i])?(s[r]=e[t],t++):s[r]=this._array[i++];this._array=s,this._insertedValues.length=0}_flushCleanupInserted(){!this._isFlushingInserted&&this._insertedValues.length>0&&this._flushInsertedTask.flush()}delete(e){if(this._flushCleanupInserted(),this._array.length===0)return!1;let t=this._getKey(e);if(t===void 0||(fe=this._search(t),fe===-1)||this._getKey(this._array[fe])!==t)return!1;do if(this._array[fe]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(fe),!0;while(++fer-n),t=0,i=new Array(this._array.length-e.length),s=0;for(let r=0;r0&&this._flushDeletedTask.flush()}*getKeyIterator(e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(fe=this._search(e),!(fe<0||fe>=this._array.length)&&this._getKey(this._array[fe])===e))do yield this._array[fe];while(++fe=this._array.length)&&this._getKey(this._array[fe])===e))do t(this._array[fe]);while(++fe=t;){let s=t+i>>1,r=this._getKey(this._array[s]);if(r>e)i=s-1;else if(r0&&this._getKey(this._array[s-1])===e;)s--;return s}}return t}},Es=0,On=0,xd=class extends G{constructor(){super(),this._decorations=new Cd(e=>e==null?void 0:e.marker.line),this._onDecorationRegistered=this._register(new k),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new k),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(oe(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new kd(e);if(t){let i=t.marker.onDispose(()=>t.dispose()),s=t.onDispose(()=>{s.dispose(),t&&(this._decorations.delete(t)&&this._onDecorationRemoved.fire(t),i.dispose())});this._decorations.insert(t),this._onDecorationRegistered.fire(t)}return t}reset(){for(let e of this._decorations.values())e.dispose();this._decorations.clear()}*getDecorationsAtCell(e,t,i){let s=0,r=0;for(let n of this._decorations.getKeyIterator(t))s=n.options.x??0,r=s+(n.options.width??1),e>=s&&e{Es=r.options.x??0,On=Es+(r.options.width??1),e>=Es&&e=this._debounceThresholdMS)this._lastRefreshMs=s,this._innerRefresh();else if(!this._additionalRefreshRequested){let r=s-this._lastRefreshMs,n=this._debounceThresholdMS-r;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},n)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t)}},Hn=20,os=class extends G{constructor(e,t,i,s){super(),this._terminal=e,this._coreBrowserService=i,this._renderService=s,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="";let r=this._coreBrowserService.mainDocument;this._accessibilityContainer=r.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=r.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let n=0;nthis._handleBoundaryFocus(n,0),this._bottomBoundaryFocusListener=n=>this._handleBoundaryFocus(n,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=r.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new Rd(this._renderRows.bind(this))),!this._terminal.element)throw new Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this._register(this._terminal.onResize(n=>this._handleResize(n.rows))),this._register(this._terminal.onRender(n=>this._refreshRows(n.start,n.end))),this._register(this._terminal.onScroll(()=>this._refreshRows())),this._register(this._terminal.onA11yChar(n=>this._handleChar(n))),this._register(this._terminal.onLineFeed(()=>this._handleChar(` +`))),this._register(this._terminal.onA11yTab(n=>this._handleTab(n))),this._register(this._terminal.onKey(n=>this._handleKey(n.key))),this._register(this._terminal.onBlur(()=>this._clearLiveRegion())),this._register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._register(j(r,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(oe(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let t=0;t0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===` +`&&(this._liveRegionLineCount++,this._liveRegionLineCount===Hn+1&&(this._liveRegion.textContent+=Os.get())))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(e){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(e)||this._charsToConsume.push(e)}_refreshRows(e,t){this._liveRegionDebouncer.refresh(e,t,this._terminal.rows)}_renderRows(e,t){let i=this._terminal.buffer,s=i.lines.length.toString();for(let r=e;r<=t;r++){let n=i.lines.get(i.ydisp+r),o=[],a=(n==null?void 0:n.translateToString(!0,void 0,void 0,o))||"",h=(i.ydisp+r+1).toString(),l=this._rowElements[r];l&&(a.length===0?(l.textContent=" ",this._rowColumns.set(l,[0,1])):(l.textContent=a,this._rowColumns.set(l,o)),l.setAttribute("aria-posinset",h),l.setAttribute("aria-setsize",s),this._alignRowWidth(l))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(e,t){let i=e.target,s=this._rowElements[t===0?1:this._rowElements.length-2],r=i.getAttribute("aria-posinset"),n=t===0?"1":`${this._terminal.buffer.lines.length}`;if(r===n||e.relatedTarget!==s)return;let o,a;if(t===0?(o=i,a=this._rowElements.pop(),this._rowContainer.removeChild(a)):(o=this._rowElements.shift(),a=i,this._rowContainer.removeChild(o)),o.removeEventListener("focus",this._topBoundaryFocusListener),a.removeEventListener("focus",this._bottomBoundaryFocusListener),t===0){let h=this._createAccessibilityTreeNode();this._rowElements.unshift(h),this._rowContainer.insertAdjacentElement("afterbegin",h)}else{let h=this._createAccessibilityTreeNode();this._rowElements.push(h),this._rowContainer.appendChild(h)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(t===0?-1:1),this._rowElements[t===0?1:this._rowElements.length-2].focus(),e.preventDefault(),e.stopImmediatePropagation()}_handleSelectionChange(){var a;if(this._rowElements.length===0)return;let e=this._coreBrowserService.mainDocument.getSelection();if(!e)return;if(e.isCollapsed){this._rowContainer.contains(e.anchorNode)&&this._terminal.clearSelection();return}if(!e.anchorNode||!e.focusNode){console.error("anchorNode and/or focusNode are null");return}let t={node:e.anchorNode,offset:e.anchorOffset},i={node:e.focusNode,offset:e.focusOffset};if((t.node.compareDocumentPosition(i.node)&Node.DOCUMENT_POSITION_PRECEDING||t.node===i.node&&t.offset>i.offset)&&([t,i]=[i,t]),t.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(t={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(t.node))return;let s=this._rowElements.slice(-1)[0];if(i.node.compareDocumentPosition(s)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(i={node:s,offset:((a=s.textContent)==null?void 0:a.length)??0}),!this._rowContainer.contains(i.node))return;let r=({node:h,offset:l})=>{let c=h instanceof Text?h.parentNode:h,d=parseInt(c==null?void 0:c.getAttribute("aria-posinset"),10)-1;if(isNaN(d))return console.warn("row is invalid. Race condition?"),null;let u=this._rowColumns.get(c);if(!u)return console.warn("columns is null. Race condition?"),null;let f=l=this._terminal.cols&&(++d,f=0),{row:d,column:f}},n=r(t),o=r(i);if(!(!n||!o)){if(n.row>o.row||n.row===o.row&&n.column>=o.column)throw new Error("invalid range");this._terminal.select(n.column,n.row,(o.row-n.row)*this._terminal.cols-n.column+o.column)}}_handleResize(e){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let t=this._rowContainer.children.length;te;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){let e=this._coreBrowserService.mainDocument.createElement("div");return e.setAttribute("role","listitem"),e.tabIndex=-1,this._refreshRowDimensions(e),e}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){Object.assign(this._accessibilityContainer.style,{width:`${this._renderService.dimensions.css.canvas.width}px`,fontSize:`${this._terminal.options.fontSize}px`}),this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let e=0;e{var n;At(this._linkCacheDisposables),this._linkCacheDisposables.length=0,this._lastMouseEvent=void 0,(n=this._activeProviderReplies)==null||n.clear()})),this._register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0})),this._register(j(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(j(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(j(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(j(this._element,"mouseup",this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(e){this._lastMouseEvent=e;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);if(!t)return;this._isMouseOut=!1;let i=e.composedPath();for(let s=0;s{n==null||n.forEach(o=>{o.link.dispose&&o.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let i=!1;for(let[n,o]of this._linkProviderService.linkProviders.entries())t?(r=this._activeProviderReplies)!=null&&r.get(n)&&(i=this._checkLinkProviderResult(n,e,i)):o.provideLinks(e.y,a=>{var l,c;if(this._isMouseOut)return;let h=a==null?void 0:a.map(d=>({link:d}));(l=this._activeProviderReplies)==null||l.set(n,h),i=this._checkLinkProviderResult(n,e,i),((c=this._activeProviderReplies)==null?void 0:c.size)===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,t){let i=new Set;for(let s=0;se?this._bufferService.cols:o.link.range.end.x;for(let l=a;l<=h;l++){if(i.has(l)){r.splice(n--,1);break}i.add(l)}}}}_checkLinkProviderResult(e,t,i){var n;if(!this._activeProviderReplies)return i;let s=this._activeProviderReplies.get(e),r=!1;for(let o=0;othis._linkAtPosition(a.link,t));o&&(i=!0,this._handleNewLink(o))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!i)for(let o=0;othis._linkAtPosition(h.link,t));if(a){i=!0,this._handleNewLink(a);break}}return i}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._mouseDownLink&&Bd(this._mouseDownLink.link,this._currentLink.link)&&this._linkAtPosition(this._currentLink.link,t)&&this._currentLink.link.activate(e,this._currentLink.link.text)}_clearCurrentLink(e,t){!this._currentLink||!this._lastMouseEvent||(!e||!t||this._currentLink.link.range.start.y>=e&&this._currentLink.link.range.end.y<=t)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,At(this._linkCacheDisposables),this._linkCacheDisposables.length=0)}_handleNewLink(e){if(!this._lastMouseEvent)return;let t=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);t&&this._linkAtPosition(e.link,t)&&(this._currentLink=e,this._currentLink.state={decorations:{underline:e.link.decorations===void 0?!0:e.link.decorations.underline,pointerCursor:e.link.decorations===void 0?!0:e.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,e.link,this._lastMouseEvent),e.link.decorations={},Object.defineProperties(e.link.decorations,{pointerCursor:{get:()=>{var i,s;return(s=(i=this._currentLink)==null?void 0:i.state)==null?void 0:s.decorations.pointerCursor},set:i=>{var s;(s=this._currentLink)!=null&&s.state&&this._currentLink.state.decorations.pointerCursor!==i&&(this._currentLink.state.decorations.pointerCursor=i,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",i))}},underline:{get:()=>{var i,s;return(s=(i=this._currentLink)==null?void 0:i.state)==null?void 0:s.decorations.underline},set:i=>{var s,r,n;(s=this._currentLink)!=null&&s.state&&((n=(r=this._currentLink)==null?void 0:r.state)==null?void 0:n.decorations.underline)!==i&&(this._currentLink.state.decorations.underline=i,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,i))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(i=>{if(!this._currentLink)return;let s=i.start===0?0:i.start+1+this._bufferService.buffer.ydisp,r=this._bufferService.buffer.ydisp+1+i.end;if(this._currentLink.link.range.start.y>=s&&this._currentLink.link.range.end.y<=r&&(this._clearCurrentLink(s,r),this._lastMouseEvent)){let n=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);n&&this._askForLink(n,!1)}})))}_linkHover(e,t,i){var s;(s=this._currentLink)!=null&&s.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!0),this._currentLink.state.decorations.pointerCursor&&e.classList.add("xterm-cursor-pointer")),t.hover&&t.hover(i,t.text)}_fireUnderlineEvent(e,t){let i=e.range,s=this._bufferService.buffer.ydisp,r=this._createLinkUnderlineEvent(i.start.x-1,i.start.y-s-1,i.end.x,i.end.y-s-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(r)}_linkLeave(e,t,i){var s;(s=this._currentLink)!=null&&s.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!1),this._currentLink.state.decorations.pointerCursor&&e.classList.remove("xterm-cursor-pointer")),t.leave&&t.leave(i,t.text)}_linkAtPosition(e,t){let i=e.range.start.y*this._bufferService.cols+e.range.start.x,s=e.range.end.y*this._bufferService.cols+e.range.end.x,r=t.y*this._bufferService.cols+t.x;return i<=r&&r<=s}_positionFromMouseEvent(e,t,i){let s=i.getCoords(e,t,this._bufferService.cols,this._bufferService.rows);if(s)return{x:s[0],y:s[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,t,i,s,r){return{x1:e,y1:t,x2:i,y2:s,cols:this._bufferService.cols,fg:r}}};Sr=_e([T(1,Rr),T(2,pt),T(3,Ie),T(4,qo)],Sr);function Bd(e,t){return e.text===t.text&&e.range.start.x===t.range.start.x&&e.range.start.y===t.range.start.y&&e.range.end.x===t.range.end.x&&e.range.end.y===t.range.end.y}var Md=class extends yd{constructor(e={}){super(e),this._linkifier=this._register(new Yt),this.browser=da,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new Yt),this._onCursorMove=this._register(new k),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new k),this.onKey=this._onKey.event,this._onRender=this._register(new k),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new k),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new k),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new k),this.onBell=this._onBell.event,this._onFocus=this._register(new k),this._onBlur=this._register(new k),this._onA11yCharEmitter=this._register(new k),this._onA11yTabEmitter=this._register(new k),this._onWillOpen=this._register(new k),this._setup(),this._decorationService=this._instantiationService.createInstance(xd),this._instantiationService.setService(xi,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(vc),this._instantiationService.setService(qo,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(Fs)),this._register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this._register(this._inputHandler.onRequestRefreshRows(t=>this.refresh((t==null?void 0:t.start)??0,(t==null?void 0:t.end)??this.rows-1))),this._register(this._inputHandler.onRequestSendFocus(()=>this._reportFocus())),this._register(this._inputHandler.onRequestReset(()=>this.reset())),this._register(this._inputHandler.onRequestWindowsOptionsReport(t=>this._reportWindowsOptions(t))),this._register(this._inputHandler.onColor(t=>this._handleColorEvent(t))),this._register(Le.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(Le.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(Le.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(Le.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(t=>this._afterResize(t.cols,t.rows))),this._register(oe(()=>{var t,i;this._customKeyEventHandler=void 0,(i=(t=this.element)==null?void 0:t.parentNode)==null||i.removeChild(this.element)}))}get linkifier(){return this._linkifier.value}get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}_handleColorEvent(e){if(this._themeService)for(let t of e){let i,s="";switch(t.index){case 256:i="foreground",s="10";break;case 257:i="background",s="11";break;case 258:i="cursor",s="12";break;default:i="ansi",s="4;"+t.index}switch(t.type){case 0:let r=re.toColorRGB(i==="ansi"?this._themeService.colors.ansi[t.index]:this._themeService.colors[i]);this.coreService.triggerDataEvent(`${v.ESC}]${s};${fd(r)}${ha.ST}`);break;case 1:if(i==="ansi")this._themeService.modifyColors(n=>n.ansi[t.index]=ve.toColor(...t.color));else{let n=i;this._themeService.modifyColors(o=>o[n]=ve.toColor(...t.color))}break;case 2:this._themeService.restoreColor(t.index);break}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(e){e?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(os,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(v.ESC+"[I"),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()}blur(){var e;return(e=this.textarea)==null?void 0:e.blur()}_handleTextAreaBlur(){this.textarea.value="",this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(v.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let e=this.buffer.ybase+this.buffer.y,t=this.buffer.lines.get(e);if(!t)return;let i=Math.min(this.buffer.x,this.cols-1),s=this._renderService.dimensions.css.cell.height,r=t.getWidth(i),n=this._renderService.dimensions.css.cell.width*r,o=this.buffer.y*this._renderService.dimensions.css.cell.height,a=i*this._renderService.dimensions.css.cell.width;this.textarea.style.left=a+"px",this.textarea.style.top=o+"px",this.textarea.style.width=n+"px",this.textarea.style.height=s+"px",this.textarea.style.lineHeight=s+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(j(this.element,"copy",t=>{this.hasSelection()&&$l(t,this._selectionService)}));let e=t=>Al(t,this.textarea,this.coreService,this.optionsService);this._register(j(this.textarea,"paste",e)),this._register(j(this.element,"paste",e)),ua?this._register(j(this.element,"mousedown",t=>{t.button===2&&Gr(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(j(this.element,"contextmenu",t=>{Gr(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),Pr&&this._register(j(this.element,"auxclick",t=>{t.button===1&&Io(t,this.textarea,this.screenElement)}))}_bindKeys(){this._register(j(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(j(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(j(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(j(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(j(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(j(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(j(this.textarea,"input",e=>this._inputEvent(e),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(e){var r;if(!e)throw new Error("Terminal requires a parent element.");if(e.isConnected||this._logService.debug("Terminal.open was called on an element that was not attached to the DOM"),((r=this.element)==null?void 0:r.ownerDocument.defaultView)&&this._coreBrowserService){this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView);return}this._document=e.ownerDocument,this.options.documentOverride&&this.options.documentOverride instanceof Document&&(this._document=this.optionsService.rawOptions.documentOverride),this.element=this._document.createElement("div"),this.element.dir="ltr",this.element.classList.add("terminal"),this.element.classList.add("xterm"),e.appendChild(this.element);let t=this._document.createDocumentFragment();this._viewportElement=this._document.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),t.appendChild(this._viewportElement),this.screenElement=this._document.createElement("div"),this.screenElement.classList.add("xterm-screen"),this._register(j(this.screenElement,"mousemove",n=>this.updateCursorStyle(n))),this._helperContainer=this._document.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),t.appendChild(this.screenElement);let i=this.textarea=this._document.createElement("textarea");this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",Is.get()),pa||this.textarea.setAttribute("aria-multiline","false"),this.textarea.setAttribute("autocorrect","off"),this.textarea.setAttribute("autocapitalize","off"),this.textarea.setAttribute("spellcheck","false"),this.textarea.tabIndex=0,this._register(this.optionsService.onSpecificOptionChange("disableStdin",()=>i.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(mc,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(ft,this._coreBrowserService),this._register(j(this.textarea,"focus",n=>this._handleTextAreaFocus(n))),this._register(j(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(ar,this._document,this._helperContainer),this._instantiationService.setService(hs,this._charSizeService),this._themeService=this._instantiationService.createInstance(dr),this._instantiationService.setService(Jt,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(ss),this._instantiationService.setService(Ko,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(hr,this.rows,this.screenElement)),this._instantiationService.setService(pt,this._renderService),this._register(this._renderService.onRenderedViewportChange(n=>this._onRender.fire(n))),this.onResize(n=>this._renderService.resize(n.cols,n.rows)),this._compositionView=this._document.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(rr,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(lr),this._instantiationService.setService(Rr,this._mouseService);let s=this._linkifier.value=this._register(this._instantiationService.createInstance(Sr,this.screenElement));this.element.appendChild(t);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this._register(this.onCursorMove(()=>{this._renderService.handleCursorMove(),this._syncTextArea()})),this._register(this.onResize(()=>this._renderService.handleResize(this.cols,this.rows))),this._register(this.onBlur(()=>this._renderService.handleBlur())),this._register(this.onFocus(()=>this._renderService.handleFocus())),this._viewport=this._register(this._instantiationService.createInstance(ir,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(n=>{super.scrollLines(n,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(cr,this.element,this.screenElement,s)),this._instantiationService.setService(zl,this._selectionService),this._register(this._selectionService.onRequestScrollLines(n=>this.scrollLines(n.amount,n.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(n=>this._renderService.handleSelectionChanged(n.start,n.end,n.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(n=>{this.textarea.value=n,this.textarea.focus(),this.textarea.select()})),this._register(Le.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{var n;this._selectionService.refresh(),(n=this._viewport)==null||n.queueSync()})),this._register(this._instantiationService.createInstance(sr,this.screenElement)),this._register(j(this.element,"mousedown",n=>this._selectionService.handleMouseDown(n))),this.coreMouseService.areMouseEventsActive?(this._selectionService.disable(),this.element.classList.add("enable-mouse-events")):this._selectionService.enable(),this.options.screenReaderMode&&(this._accessibilityManager.value=this._instantiationService.createInstance(os,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",n=>this._handleScreenReaderModeOptionChange(n))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(is,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",n=>{!this._overviewRulerRenderer&&n&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(is,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(or,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function i(n){var l,c,d,u,f;let o=e._mouseService.getMouseReportCoords(n,e.screenElement);if(!o)return!1;let a,h;switch(n.overrideType||n.type){case"mousemove":h=32,n.buttons===void 0?(a=3,n.button!==void 0&&(a=n.button<3?n.button:3)):a=n.buttons&1?0:n.buttons&4?1:n.buttons&2?2:3;break;case"mouseup":h=0,a=n.button<3?n.button:3;break;case"mousedown":h=1,a=n.button<3?n.button:3;break;case"wheel":if(e._customWheelEventHandler&&e._customWheelEventHandler(n)===!1)return!1;let _=n.deltaY;if(_===0||e.coreMouseService.consumeWheelEvent(n,(u=(d=(c=(l=e._renderService)==null?void 0:l.dimensions)==null?void 0:c.device)==null?void 0:d.cell)==null?void 0:u.height,(f=e._coreBrowserService)==null?void 0:f.dpr)===0)return!1;h=_<0?0:1,a=4;break;default:return!1}return h===void 0||a===void 0||a>4?!1:e.coreMouseService.triggerMouseEvent({col:o.col,row:o.row,x:o.x,y:o.y,button:a,action:h,ctrl:n.ctrlKey,alt:n.altKey,shift:n.shiftKey})}let s={mouseup:null,wheel:null,mousedrag:null,mousemove:null},r={mouseup:n=>(i(n),n.buttons||(this._document.removeEventListener("mouseup",s.mouseup),s.mousedrag&&this._document.removeEventListener("mousemove",s.mousedrag)),this.cancel(n)),wheel:n=>(i(n),this.cancel(n,!0)),mousedrag:n=>{n.buttons&&i(n)},mousemove:n=>{n.buttons||i(n)}};this._register(this.coreMouseService.onProtocolChange(n=>{n?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(n)),this.element.classList.add("enable-mouse-events"),this._selectionService.disable()):(this._logService.debug("Unbinding from mouse events."),this.element.classList.remove("enable-mouse-events"),this._selectionService.enable()),n&8?s.mousemove||(t.addEventListener("mousemove",r.mousemove),s.mousemove=r.mousemove):(t.removeEventListener("mousemove",s.mousemove),s.mousemove=null),n&16?s.wheel||(t.addEventListener("wheel",r.wheel,{passive:!1}),s.wheel=r.wheel):(t.removeEventListener("wheel",s.wheel),s.wheel=null),n&2?s.mouseup||(s.mouseup=r.mouseup):(this._document.removeEventListener("mouseup",s.mouseup),s.mouseup=null),n&4?s.mousedrag||(s.mousedrag=r.mousedrag):(this._document.removeEventListener("mousemove",s.mousedrag),s.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(j(t,"mousedown",n=>{if(n.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(n)))return i(n),s.mouseup&&this._document.addEventListener("mouseup",s.mouseup),s.mousedrag&&this._document.addEventListener("mousemove",s.mousedrag),this.cancel(n)})),this._register(j(t,"wheel",n=>{var o,a,h,l,c;if(!s.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(n)===!1)return!1;if(!this.buffer.hasScrollback){if(n.deltaY===0)return!1;if(e.coreMouseService.consumeWheelEvent(n,(l=(h=(a=(o=e._renderService)==null?void 0:o.dimensions)==null?void 0:a.device)==null?void 0:h.cell)==null?void 0:l.height,(c=e._coreBrowserService)==null?void 0:c.dpr)===0)return this.cancel(n,!0);let d=v.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(n.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(d,!0),this.cancel(n,!0)}}},{passive:!1}))}refresh(e,t){var i;(i=this._renderService)==null||i.refreshRows(e,t)}updateCursorStyle(e){var t;(t=this._selectionService)!=null&&t.shouldColumnSelect(e)?this.element.classList.add("column-select"):this.element.classList.remove("column-select")}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))}scrollLines(e,t){this._viewport?this._viewport.scrollLines(e):super.scrollLines(e,t),this.refresh(0,this.rows-1)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){e&&this._viewport?this._viewport.scrollToLine(this.buffer.ybase,!0):this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}paste(e){No(e,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(e){this._customKeyEventHandler=e}attachCustomWheelEventHandler(e){this._customWheelEventHandler=e}registerLinkProvider(e){return this._linkProviderService.registerLinkProvider(e)}registerCharacterJoiner(e){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");let t=this._characterJoinerService.register(e);return this.refresh(0,this.rows-1),t}deregisterCharacterJoiner(e){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");this._characterJoinerService.deregister(e)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(e){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+e)}registerDecoration(e){return this._decorationService.registerDecoration(e)}hasSelection(){return this._selectionService?this._selectionService.hasSelection:!1}select(e,t,i){this._selectionService.setSelection(e,t,i)}getSelection(){return this._selectionService?this._selectionService.selectionText:""}getSelectionPosition(){if(!(!this._selectionService||!this._selectionService.hasSelection))return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){var e;(e=this._selectionService)==null||e.clearSelection()}selectAll(){var e;(e=this._selectionService)==null||e.selectAll()}selectLines(e,t){var i;(i=this._selectionService)==null||i.selectLines(e,t)}_keyDown(e){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;let t=this.browser.isMac&&this.options.macOptionIsMeta&&e.altKey;if(!t&&!this._compositionHelper.keydown(e))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(!0),!1;!t&&(e.key==="Dead"||e.key==="AltGraph")&&(this._unprocessedDeadKey=!0);let i=bd(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),i.type===3||i.type===2){let s=this.rows-1;return this.scrollLines(i.type===2?-s:s),this.cancel(e,!0)}if(i.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,e)||(i.cancel&&this.cancel(e,!0),!i.key)||e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.key.length===1&&e.key.charCodeAt(0)>=65&&e.key.charCodeAt(0)<=90)return!0;if(this._unprocessedDeadKey)return this._unprocessedDeadKey=!1,!0;if((i.key===v.ETX||i.key===v.CR)&&(this.textarea.value=""),this._onKey.fire({key:i.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(i.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)return this.cancel(e,!0);this._keyDownHandled=!0}_isThirdLevelShift(e,t){let i=e.isMac&&!this.options.macOptionIsMeta&&t.altKey&&!t.ctrlKey&&!t.metaKey||e.isWindows&&t.altKey&&t.ctrlKey&&!t.metaKey||e.isWindows&&t.getModifierState("AltGraph");return t.type==="keypress"?i:i&&(!t.keyCode||t.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)&&(Dd(e)||this.focus(),this.updateCursorStyle(e),this._keyPressHandled=!1)}_keyPress(e){let t;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;if(this.cancel(e),e.charCode)t=e.charCode;else if(e.which===null||e.which===void 0)t=e.keyCode;else if(e.which!==0&&e.charCode!==0)t=e.which;else return!1;return!t||(e.altKey||e.ctrlKey||e.metaKey)&&!this._isThirdLevelShift(this.browser,e)?!1:(t=String.fromCharCode(t),this._onKey.fire({key:t,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(t,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,!0)}_inputEvent(e){if(e.data&&e.inputType==="insertText"&&(!e.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;let t=e.data;return this.coreService.triggerDataEvent(t,!0),this.cancel(e),!0}return!1}resize(e,t){if(e===this.cols&&t===this.rows){this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure();return}super.resize(e,t)}_afterResize(e,t){var i;(i=this._charSizeService)==null||i.measure()}clear(){if(!(this.buffer.ybase===0&&this.buffer.y===0)){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let e=1;e=0;e--)this._addons[e].instance.dispose()}loadAddon(e,t){let i={instance:t,dispose:t.dispose,isDisposed:!1};this._addons.push(i),t.dispose=()=>this._wrappedAddonDispose(i),t.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let t=-1;for(let i=0;i=this._line.length))return t?(this._line.loadCell(e,t),t):this._line.loadCell(e,new Je)}translateToString(e,t,i){return this._line.translateToString(e,t,i)}},Fn=class{constructor(e,t){this._buffer=e,this.type=t}init(e){return this._buffer=e,this}get cursorY(){return this._buffer.y}get cursorX(){return this._buffer.x}get viewportY(){return this._buffer.ydisp}get baseY(){return this._buffer.ybase}get length(){return this._buffer.lines.length}getLine(e){let t=this._buffer.lines.get(e);if(t)return new Td(t)}getNullCell(){return new Je}},$d=class extends G{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new k),this.onBufferChange=this._onBufferChange.event,this._normal=new Fn(this._core.buffers.normal,"normal"),this._alternate=new Fn(this._core.buffers.alt,"alternate"),this._core.buffers.onBufferActivate(()=>this._onBufferChange.fire(this.active))}get active(){if(this._core.buffers.active===this._core.buffers.normal)return this.normal;if(this._core.buffers.active===this._core.buffers.alt)return this.alternate;throw new Error("Active buffer is neither normal nor alternate")}get normal(){return this._normal.init(this._core.buffers.normal)}get alternate(){return this._alternate.init(this._core.buffers.alt)}},Ad=class{constructor(e){this._core=e}registerCsiHandler(e,t){return this._core.registerCsiHandler(e,i=>t(i.toArray()))}addCsiHandler(e,t){return this.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._core.registerDcsHandler(e,(i,s)=>t(i,s.toArray()))}addDcsHandler(e,t){return this.registerDcsHandler(e,t)}registerEscHandler(e,t){return this._core.registerEscHandler(e,t)}addEscHandler(e,t){return this.registerEscHandler(e,t)}registerOscHandler(e,t){return this._core.registerOscHandler(e,t)}addOscHandler(e,t){return this.registerOscHandler(e,t)}},Pd=class{constructor(e){this._core=e}register(e){this._core.unicodeService.register(e)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(e){this._core.unicodeService.activeVersion=e}},Nd=["cols","rows"],ot=0,Id=class extends G{constructor(e){super(),this._core=this._register(new Md(e)),this._addonManager=this._register(new Ld),this._publicOptions={...this._core.options};let t=s=>this._core.options[s],i=(s,r)=>{this._checkReadonlyOptions(s),this._core.options[s]=r};for(let s in this._core.options){let r={get:t.bind(this,s),set:i.bind(this,s)};Object.defineProperty(this._publicOptions,s,r)}}_checkReadonlyOptions(e){if(Nd.includes(e))throw new Error(`Option "${e}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw new Error("You must set the allowProposedApi option to true to use proposed API")}get onBell(){return this._core.onBell}get onBinary(){return this._core.onBinary}get onCursorMove(){return this._core.onCursorMove}get onData(){return this._core.onData}get onKey(){return this._core.onKey}get onLineFeed(){return this._core.onLineFeed}get onRender(){return this._core.onRender}get onResize(){return this._core.onResize}get onScroll(){return this._core.onScroll}get onSelectionChange(){return this._core.onSelectionChange}get onTitleChange(){return this._core.onTitleChange}get onWriteParsed(){return this._core.onWriteParsed}get element(){return this._core.element}get parser(){return this._parser||(this._parser=new Ad(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new Pd(this._core)}get textarea(){return this._core.textarea}get rows(){return this._core.rows}get cols(){return this._core.cols}get buffer(){return this._buffer||(this._buffer=this._register(new $d(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let e=this._core.coreService.decPrivateModes,t="none";switch(this._core.coreMouseService.activeProtocol){case"X10":t="x10";break;case"VT200":t="vt200";break;case"DRAG":t="drag";break;case"ANY":t="any";break}return{applicationCursorKeysMode:e.applicationCursorKeys,applicationKeypadMode:e.applicationKeypad,bracketedPasteMode:e.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:t,originMode:e.origin,reverseWraparoundMode:e.reverseWraparound,sendFocusMode:e.sendFocus,synchronizedOutputMode:e.synchronizedOutput,wraparoundMode:e.wraparound}}get options(){return this._publicOptions}set options(e){for(let t in e)this._publicOptions[t]=e[t]}blur(){this._core.blur()}focus(){this._core.focus()}input(e,t=!0){this._core.input(e,t)}resize(e,t){this._verifyIntegers(e,t),this._core.resize(e,t)}open(e){this._core.open(e)}attachCustomKeyEventHandler(e){this._core.attachCustomKeyEventHandler(e)}attachCustomWheelEventHandler(e){this._core.attachCustomWheelEventHandler(e)}registerLinkProvider(e){return this._core.registerLinkProvider(e)}registerCharacterJoiner(e){return this._checkProposedApi(),this._core.registerCharacterJoiner(e)}deregisterCharacterJoiner(e){this._checkProposedApi(),this._core.deregisterCharacterJoiner(e)}registerMarker(e=0){return this._verifyIntegers(e),this._core.registerMarker(e)}registerDecoration(e){return this._checkProposedApi(),this._verifyPositiveIntegers(e.x??0,e.width??0,e.height??0),this._core.registerDecoration(e)}hasSelection(){return this._core.hasSelection()}select(e,t,i){this._verifyIntegers(e,t,i),this._core.select(e,t,i)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(e,t){this._verifyIntegers(e,t),this._core.selectLines(e,t)}dispose(){super.dispose()}scrollLines(e){this._verifyIntegers(e),this._core.scrollLines(e)}scrollPages(e){this._verifyIntegers(e),this._core.scrollPages(e)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(e){this._verifyIntegers(e),this._core.scrollToLine(e)}clear(){this._core.clear()}write(e,t){this._core.write(e,t)}writeln(e,t){this._core.write(e),this._core.write(`\r `,t)}paste(e){this._core.paste(e)}refresh(e,t){this._verifyIntegers(e,t),this._core.refresh(e,t)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(e){this._addonManager.loadAddon(this,e)}static get strings(){return{get promptLabel(){return Is.get()},set promptLabel(e){Is.set(e)},get tooMuchOutput(){return Os.get()},set tooMuchOutput(e){Os.set(e)}}}_verifyIntegers(...e){for(ot of e)if(ot===1/0||isNaN(ot)||ot%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...e){for(ot of e)if(ot&&(ot===1/0||isNaN(ot)||ot%1!==0||ot<0))throw new Error("This API only accepts positive integers")}};/** * Copyright (c) 2014-2024 The xterm.js authors. All rights reserved. * @license MIT @@ -55,7 +55,7 @@ WARNING: This link could potentially be dangerous`)){let i=window.open();if(i){t * Fabrice Bellard's javascript vt100 for jslinux: * http://bellard.org/jslinux/ * Copyright (c) 2011 Fabrice Bellard - */var Od=2,Fd=1,Hd=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){var d;if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:((d=this._terminal.options.overviewRuler)==null?void 0:d.width)||14,i=window.getComputedStyle(this._terminal.element.parentElement),s=parseInt(i.getPropertyValue("height")),r=Math.max(0,parseInt(i.getPropertyValue("width"))),n=window.getComputedStyle(this._terminal.element),o={top:parseInt(n.getPropertyValue("padding-top")),bottom:parseInt(n.getPropertyValue("padding-bottom")),right:parseInt(n.getPropertyValue("padding-right")),left:parseInt(n.getPropertyValue("padding-left"))},a=o.top+o.bottom,h=o.right+o.left,l=s-a,c=r-h-t;return{cols:Math.max(Od,Math.floor(c/e.css.cell.width)),rows:Math.max(Fd,Math.floor(l/e.css.cell.height))}}};/** + */var Od=2,Hd=1,Fd=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){var d;if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:((d=this._terminal.options.overviewRuler)==null?void 0:d.width)||14,i=window.getComputedStyle(this._terminal.element.parentElement),s=parseInt(i.getPropertyValue("height")),r=Math.max(0,parseInt(i.getPropertyValue("width"))),n=window.getComputedStyle(this._terminal.element),o={top:parseInt(n.getPropertyValue("padding-top")),bottom:parseInt(n.getPropertyValue("padding-bottom")),right:parseInt(n.getPropertyValue("padding-right")),left:parseInt(n.getPropertyValue("padding-left"))},a=o.top+o.bottom,h=o.right+o.left,l=s-a,c=r-h-t;return{cols:Math.max(Od,Math.floor(c/e.css.cell.width)),rows:Math.max(Hd,Math.floor(l/e.css.cell.height))}}};/** * Copyright (c) 2014-2024 The xterm.js authors. All rights reserved. * @license MIT * @@ -66,30 +66,30 @@ WARNING: This link could potentially be dangerous`)){let i=window.open();if(i){t * Fabrice Bellard's javascript vt100 for jslinux: * http://bellard.org/jslinux/ * Copyright (c) 2011 Fabrice Bellard - */var Wd=class{constructor(e,t,i,s={}){this._terminal=e,this._regex=t,this._handler=i,this._options=s}provideLinks(e,t){let i=Ud.computeLink(e,this._regex,this._terminal,this._handler);t(this._addCallbacks(i))}_addCallbacks(e){return e.map(t=>(t.leave=this._options.leave,t.hover=(i,s)=>{if(this._options.hover){let{range:r}=t;this._options.hover(i,s,r)}},t))}};function zd(e){try{let t=new URL(e),i=t.password&&t.username?`${t.protocol}//${t.username}:${t.password}@${t.host}`:t.username?`${t.protocol}//${t.username}@${t.host}`:`${t.protocol}//${t.host}`;return e.toLocaleLowerCase().startsWith(i.toLocaleLowerCase())}catch{return!1}}var Ud=class Vi{static computeLink(t,i,s,r){let n=new RegExp(i.source,(i.flags||"")+"g"),[o,a]=Vi._getWindowedLineStrings(t-1,s),h=o.join(""),l,c=[];for(;l=n.exec(h);){let d=l[0];if(!zd(d))continue;let[u,f]=Vi._mapStrIdx(s,a,0,l.index),[_,p]=Vi._mapStrIdx(s,u,f,d.length);if(u===-1||f===-1||_===-1||p===-1)continue;let g={start:{x:f+1,y:u+1},end:{x:p,y:_+1}};c.push({range:g,text:d,activate:r})}return c}static _getWindowedLineStrings(t,i){let s,r=t,n=t,o=0,a="",h=[];if(s=i.buffer.active.getLine(t)){let l=s.translateToString(!0);if(s.isWrapped&&l[0]!==" "){for(o=0;(s=i.buffer.active.getLine(--r))&&o<2048&&(a=s.translateToString(!0),o+=a.length,h.push(a),!(!s.isWrapped||a.indexOf(" ")!==-1)););h.reverse()}for(h.push(l),o=0;(s=i.buffer.active.getLine(++n))&&s.isWrapped&&o<2048&&(a=s.translateToString(!0),o+=a.length,h.push(a),a.indexOf(" ")===-1););}return[h,r]}static _mapStrIdx(t,i,s,r){let n=t.buffer.active,o=n.getNullCell(),a=s;for(;r;){let h=n.getLine(i);if(!h)return[-1,-1];for(let l=a;l`]*[^\s"':,.!?{}|\\\^~\[\]`()<>]/;function Kd(e,t){let i=window.open();if(i){try{i.opener=null}catch{}i.location.href=t}else console.warn("Opening link blocked as opener could not be cleared")}var qd=class{constructor(t=Kd,i={}){this._handler=t,this._options=i}activate(t){this._terminal=t;let i=this._options,s=i.urlRegex||jd;this._linkProvider=this._terminal.registerLinkProvider(new Wd(this._terminal,s,this._handler,i))}dispose(){var t;(t=this._linkProvider)==null||t.dispose()}};class Vd{constructor(){D(this,"commands",[])}register(...t){this.commands.push(...t)}find(t){let i;for(const s of this.commands)s.matches(t)&&(!i||s.name.length>i.name.length)&&(i=s);return i}all(){return this.commands}}class ee{constructor(){D(this,"aliases",[]);D(this,"params")}matches(t){const i=t.toLowerCase().trim(),s=r=>i===r||i.startsWith(r+" ");return s(this.name)||this.aliases.some(s)}argsAfterName(t){const i=t.toLowerCase().trim(),s=[this.name,...this.aliases].sort((r,n)=>n.length-r.length);for(const r of s)if(i.startsWith(r))return t.trim().slice(r.length).trim();return t.trim()}}const Ze="\x1B[",Q=`${Ze}0m`,kt=`${Ze}1m`,Gd=`${Ze}2m`,Yd=`${Ze}3m`,us=`${Ze}32m`,Xt=`${Ze}31m`,Ri=`${Ze}33m`,ka=`${Ze}36m`,Bi=`${Ze}34m`,It=`${Ze}90m`,Xd=`${Ze}92m`,Jd=`${Ze}96m`;function Wn(e,t){switch(t){case"success":return`${us}${e}${Q}`;case"error":return`${Xt}${e}${Q}`;case"warning":return`${Ri}${e}${Q}`;case"info":return`${ka}${e}${Q}`;case"value":return`${Bi}${e}${Q}`;case"system":return`${It}${e}${Q}`;default:return e}}function it(e){return`${kt}${e}${Q}`}function Ae(e){return`${Gd}${e}${Q}`}function Zd(e){return`${Ri}${e}${Q}`}function y(e){return`${Bi}${e}${Q}`}function b(e){return`${It}${e}${Q}`}function w(e,t){return`${It}${e}: ${Q}${Bi}${kt}${t}${Q}`}function R(e,t,i=22){const s=e.split(" "),r=s[0];let n=ka;r==="get"?n=us:r==="set"&&(n=Ri);const o=s.length>1?`${n}${kt}${r}${Q} ${Bi}${s.slice(1).join(" ")}${Q}`:`${n}${kt}${e}${Q}`,a=" ".repeat(Math.max(1,i-e.length));return` ${o}${a}${It}${t}${Q}`}function W(e){return`${kt}${Bi}${e}${Q}`}function st(e){return`${It}${Yd}${e}${Q}`}function Qd(e){return`\x1B[1;92m${e||"user"}@pyMC${Q}: \x1B[38;2;91;91;214m$${Q} `}function Rs(e){return`${Xt}${kt}●${Q} ${It}${e}${Q}`}function eu(e){return e<1500?Xd:e<4e3?us:e<8e3?Ri:e<15e3?Xt:`${Xt}${kt}`}function tu(e){const t=e<1e3?`${e.toFixed(0)}ms`:`${(e/1e3).toFixed(1)}s`;return`${eu(e)}${t}${Q}`}function Nr(e){switch(e){case"excellent":return Jd;case"good":return us;case"fair":return Ri;case"poor":return Xt;case"critical":return`${Xt}${kt}`;default:return It}}function iu(e,t){return`${Nr(t)}${e}${Q}`}function zn(e){return e.replace(/[\p{Emoji_Presentation}\p{Extended_Pictographic}\uFE0F\u200D]/gu,"").trim()}const Fi="\x1B[2K\r";function su(e=1){return`\x1B[${e}A`}const ru="\x1B[K",nu="\x1B[H",ou="\x1B[J",au="\x1B[?1049h",Un="\x1B[?1049l",lu="\x1B[?25l",jn="\x1B[?25h";function Ea(e){return e.replace(/\x1b\[[0-9;]*m/g,"")}function hu(e){return Ea(e).length}function yr(e,t){let i=0;for(const s of e){const r=Ea(s).length;i+=r===0?1:Math.ceil(r/t)}return i}function cu(e){return getComputedStyle(document.documentElement).getPropertyValue(e).trim()}function et(e,t){return cu(e)||t}function du(){return document.documentElement.dataset.mode==="light"}function Ra(){const e=du(),t=et("--terminal-bg","#0d0d0d"),i=et("--sys-blue",pe.blue);if(e){const f="#EFF0F1";return{background:f,foreground:"#111314",cursor:pe.blue,cursorAccent:f,selectionBackground:`${pe.blue}30`,selectionForeground:"#111314",black:"#111314",red:pe.red,green:pe.green,yellow:pe.amber,blue:pe.blue,magenta:pe.purple,cyan:pe.cyan,white:f,brightBlack:ii[500],brightRed:pe.red,brightGreen:pe.green,brightYellow:pe.orange,brightBlue:pe.indigo,brightMagenta:pe.pink,brightCyan:pe.teal,brightWhite:ii[600]}}const s=et("--text-primary","#e0e0e0"),r=i+"40",n=et("--sys-red",pe.red),o=et("--sys-green",pe.green),a=et("--sys-purple",pe.purple),h=et("--sys-blue",pe.blue),l=et("--sys-cyan",pe.cyan),c=et("--text-muted",ii[500]),d=et("--text-secondary",ii[400]),u=et("--bg-surface",ii[900]);return{background:t,foreground:s,cursor:i,cursorAccent:t,selectionBackground:r,selectionForeground:s,black:u,red:n,green:o,yellow:a,blue:h,magenta:a,cyan:l,white:s,brightBlack:c,brightRed:n,brightGreen:"#4ADE80",brightYellow:a,brightBlue:h,brightMagenta:a,brightCyan:l,brightWhite:d}}function uu(e){return ja.subscribe(()=>{e.options.theme=Ra()})}const Mi="\x1B[",Et=`${Mi}0m`,_u=`${Mi}1m`,fu=`${Mi}2m`,Ba=`${Mi}34m`,Di=`${Mi}90m`,Bs=24,Ms=13,Kn=" ",qn=" ",pu=[{label:"INFORMATION",entries:[{cmd:"status",desc:"Repeater status summary",alias:"st"},{cmd:"top",desc:"Live system overview (Ctrl+C to exit)",alias:"htop"},{cmd:"ver",desc:"Version info",alias:"version"},{cmd:"clock",desc:"System UTC time"},{cmd:"uptime",desc:"System uptime"},{cmd:"board",desc:"Board / platform info"},{cmd:"packets",desc:"Packet statistics"},{cmd:"stats-packets",desc:"Packet counters (firmware compat)"},{cmd:"stats-radio",desc:"Radio health stats (firmware compat)"},{cmd:"stats-core",desc:"Engine vitals (firmware compat)"}]},{label:"NETWORK",entries:[{cmd:"neighbors [sort]",desc:"Direct RF neighbors",alias:"nb",sub:"sig · name · rssi · snr · dist · heard"},{cmd:"ping {name}",desc:"Ping neighbor (name or 0xXX)"},{cmd:"identities",desc:"List configured identities",alias:"id ids"},{cmd:"keys",desc:"Transport keys"},{cmd:"acl",desc:"ACL statistics"},{cmd:"rooms",desc:"Room statistics"}]},{label:"RADIO",entries:[{cmd:"get {param}",desc:"Read parameter"},{cmd:"set {param} {value}",desc:"Write parameter"},{cmd:"advert",desc:"Send advertisement"}]},{label:"SYSTEM",entries:[{cmd:"restart",desc:"Restart service",alias:"reboot"},{cmd:"start cap [seconds]",desc:"Start packet capture"},{cmd:"end cap",desc:"Stop capture"},{cmd:"list cap",desc:"List captures"},{cmd:"export cap [id]",desc:"Download capture"}]},{label:"TOOLS",entries:[{cmd:"convert hex {value}",desc:"Hex → base64"},{cmd:"convert base64 {value}",desc:"Base64 → hex"},{cmd:"clear",desc:"Clear terminal",alias:"cls"},{cmd:"help [command]",desc:"Show this help",alias:"? h"}]}],mu=[{cat:"Identity",params:["name","role","lat","lon","public.key"]},{cat:"Radio",params:["radio","freq","tx","bw","sf","cr"]},{cat:"Timing",params:["txdelay","direct.txdelay","rxdelay"]},{cat:"Repeater",params:["mode","duty","repeat","flood.max","advert.interval"]},{cat:"Advanced",params:["multi.acks","int.thresh","agc.reset.interval"]},{cat:"set only",params:["log","prv.key"]}];function Ma(e){return`${Di}${"─".repeat(e)}${Et}`}function gu(e){const t="pymc console",i="terminal",s=Math.max(3,e-t.length-i.length-6);return` ${Ba}${_u}${t}${Et} ${Ma(s)} ${Di}${i}${Et}`}function Da(e){return` ${Di}${e}${Et}`}function vu(e,t){const i=[],s=e.alias?` ${fu}${e.alias}${Et}`:"";return 4+Math.max(e.cmd.length,Bs)+e.desc.length+(e.alias?2+e.alias.length:0)<=t?i.push(Kn+R(e.cmd,e.desc,Bs)+s):(i.push(Kn+R(e.cmd,"",Bs)),i.push(qn+b(e.desc)+s)),e.sub&&i.push(`${qn}${Ae("└ "+e.sub)}`),i}function Vn(e){return e.split(" · ").map(t=>`${Ba}${t}${Et}`).join(`${Di} · ${Et}`)}function Su(e,t){const s=[];let r=[],n=0;for(const o of e){const a=r.length>0?3+o.length:o.length;n+a>t&&r.length>0?(s.push(r),r=[o],n=o.length):(r.push(o),n+=a)}return r.length>0&&s.push(r),s}function yu(e){const t=["",Da("GET/SET QUALIFIERS")],i=Math.max(20,e-4-Ms);for(const s of mu){const r=`${Di}${s.cat.padEnd(Ms)}${Et}`,n=Su(s.params,i),o=" ".repeat(4+Ms);t.push(` ${r}${Vn(n[0].join(" · "))}`);for(let a=1;a help for detailed usage")}`]}class wu extends ee{constructor(i){super();D(this,"name","help");D(this,"description","Show available commands");D(this,"aliases",["?","h"]);this.registry=i}execute({output:i,rawInput:s,cols:r}){const n=this.argsAfterName(s).toLowerCase().trim();if(n&&n!=="help"){const a=this.registry.find(n+" help")||this.registry.find(n);if(a){a.execute({output:i,rawInput:a.name+" help",args:[a.name,"help"],cols:r,signal:new AbortController().signal});return}i.write(`Unknown command: ${y(n)}`,"warning");return}const o=[gu(r),""];for(const a of pu){o.push(Da(a.label));for(const h of a.entries)o.push(...vu(h,r));a.label==="RADIO"&&o.push(...yu(r)),o.push("")}o.push(...bu(r)),i.write(o.join(` -`))}}class Cu extends ee{constructor(){super(...arguments);D(this,"name","clear");D(this,"description","Clear terminal screen");D(this,"aliases",["cls"])}execute({output:i,rawInput:s}){if(this.argsAfterName(s).toLowerCase().trim()==="help"){i.write([W("clear"),` ${b("Clear all terminal output.")}`,"",R("clear","clear the screen"),"",W("Aliases"),` ${b("cls")}`].join(` -`));return}i.clear()}}function Ir(e){const t=Math.floor(e/86400),i=Math.floor(e%86400/3600),s=Math.floor(e%3600/60);return t>0?`${t}d ${i}h ${s}m`:i>0?`${i}h ${s}m`:`${s}m`}class xu extends ee{constructor(){super(...arguments);D(this,"name","status");D(this,"description","Get repeater status summary");D(this,"aliases",["st"])}async execute({output:i,rawInput:s}){var n,o,a;if(this.argsAfterName(s).toLowerCase().trim()==="help"){i.write([W("status"),` ${b("Show a quick summary of mode, neighbor count, and uptime.")}`,"",R("status","show summary"),"",W("Aliases"),` ${b("st")}`].join(` -`));return}const r=i.write("processing...","system");try{const h=await rt(),l=((o=(n=h.config)==null?void 0:n.repeater)==null?void 0:o.mode)||"unknown",c=Object.keys(h.neighbors||{}).length,d=Object.values(h.neighbors||{}).filter(_=>_.zero_hop).length,u=((a=h.config)==null?void 0:a.node_name)||h.node_name||"unknown",f=Ir(h.uptime_seconds||0);i.update(r,[`${it(u)} ${b("repeater")}`,"",` ${w("Mode",y(l))}`,` ${w("Neighbors",`${y(String(d))} direct ${b(`${c} total`)}`)}`,` ${w("RX / TX",`${y(String(h.rx_count??0))} / ${y(String(h.tx_count??0))}`)}`,` ${w("Uptime",y(f))}`].join(` -`))}catch(h){i.update(r,`Error: ${h instanceof Error?h.message:"Command failed"}`,"error")}}}class ku extends ee{constructor(){super(...arguments);D(this,"name","uptime");D(this,"description","Show system uptime")}async execute({output:i,rawInput:s}){if(this.argsAfterName(s).toLowerCase().trim()==="help"){i.write([W("uptime"),` ${b("Display how long the repeater service has been running.")}`,"",R("uptime","show uptime")].join(` -`));return}const r=i.write("processing...","system");try{const n=await rt();i.update(r,w("Uptime",y(Ir(n.uptime_seconds||0))))}catch(n){i.update(r,`Error: ${n instanceof Error?n.message:"Command failed"}`,"error")}}}class Eu extends ee{constructor(){super(...arguments);D(this,"name","packets");D(this,"description","Show packet statistics")}async execute({output:i,rawInput:s}){if(this.argsAfterName(s).toLowerCase().trim()==="help"){i.write([W("packets"),` ${b("Display packet counters (received, transmitted, forwarded, dropped).")}`,"",R("packets","show packet stats")].join(` -`));return}const r=i.write("processing...","system");try{const n=await rt(),o=(n.rx_count??0)+(n.tx_count??0);i.update(r,[W("Packet Stats")+` ${b(`${o} total`)}`,"",` ${w("Received",y(String(n.rx_count??0)))}`,` ${w("Transmitted",y(String(n.tx_count??0)))}`,` ${w("Forwarded",y(String(n.forwarded_count??0)))}`,` ${w("Dropped",y(String(n.dropped_count??0)))}`].join(` -`))}catch(n){i.update(r,`Error: ${n instanceof Error?n.message:"Command failed"}`,"error")}}}function zt(e){return e>=1073741824?`${(e/1073741824).toFixed(1)} GB`:e>=1048576?`${(e/1048576).toFixed(0)} MB`:`${(e/1024).toFixed(0)} KB`}function Ds(e){const t=Math.floor(e/86400),i=Math.floor(e%86400/3600),s=Math.floor(e%3600/60);return t>0?`${t}d ${i}h ${s}m`:i>0?`${i}h ${s}m`:`${s}m`}class Ru extends ee{constructor(){super(...arguments);D(this,"name","board");D(this,"description","Show board/platform info")}async execute({output:i,rawInput:s}){var n;if(this.argsAfterName(s).toLowerCase().trim()==="help"){i.write([W("board"),` ${b("Display platform and hardware information.")}`,"",R("board","show board info")].join(` -`));return}const r=i.write("loading...","system");try{const[o,a]=await Promise.all([Qi(),rt()]),h=[];if(h.push(` ${w("Node",y(a.node_name||"Unknown"))}`),h.push(` ${w("Runtime",y(`pyMC_Repeater v${a.version||"?"}`))}`),a.core_version&&h.push(` ${w("Core",y(a.core_version))}`),h.push(""),o.success&&o.data){const l=o.data;h.push(` ${w("CPU",y(`${l.cpu.usage_percent.toFixed(1)}%`))} ${b(`${l.cpu.count} core${l.cpu.count>1?"s":""}`)}`),l.cpu.load_avg&&h.push(` ${w("Load",y(`${l.cpu.load_avg["1min"].toFixed(2)} / ${l.cpu.load_avg["5min"].toFixed(2)} / ${l.cpu.load_avg["15min"].toFixed(2)}`))}`);const c=Object.entries(l.temperatures||{});if(c.length>0){const d=c[0];h.push(` ${w("Temp",y(`${d[1].toFixed(1)}°C`))}${c.length>1?` ${b(c.slice(1).map(([u,f])=>`${u}: ${f.toFixed(1)}°C`).join(", "))}`:""}`)}h.push(""),h.push(` ${w("Memory",y(`${zt(l.memory.used)} / ${zt(l.memory.total)}`))} ${b(`${l.memory.usage_percent.toFixed(0)}%`)}`),h.push(` ${w("Disk",y(`${zt(l.disk.used)} / ${zt(l.disk.total)}`))} ${b(`${l.disk.usage_percent.toFixed(0)}%`)}`),h.push(""),(n=l.system)!=null&&n.uptime&&h.push(` ${w("System uptime",y(Ds(l.system.uptime)))}`),h.push(` ${w("Service uptime",y(Ds(a.uptime_seconds)))}`),l.network&&h.push(` ${w("Net TX/RX",y(`${zt(l.network.bytes_sent)} / ${zt(l.network.bytes_recv)}`))}`)}else h.push(` ${w("Platform",y("Linux"))}`),h.push(` ${w("Service uptime",y(Ds(a.uptime_seconds)))}`),h.push(` ${b("Hardware stats unavailable")}`);i.update(r,h.join(` -`),"value")}catch(o){i.update(r,`Error: ${o instanceof Error?o.message:"Failed to load hardware stats"}`,"error")}}}const Gi="\x1B[0m",Yi="\x1B[1m",br="\x1B[2m",Gn="\x1B[36m",Yn="\x1B[96m",Bu="\x1B[97m",Mu="\x1B[93m",qe=48,Du=14,St=22,mi=5,Xi=22,Lu=5,Tu=St+mi+Xi+Lu,$u=50;function La(e,t,i,s){return r=>{if(r<=0)return 0;if(r>=1)return 1;let n=r;for(let o=0;o<8;o++){const a=3*(1-n)*(1-n)*n*e+3*(1-n)*n*n*i+n*n*n-r,h=3*(1-n)*(1-n)*e+6*(1-n)*n*(i-e)+3*n*n*(1-i);if(Math.abs(h)<1e-7)break;n=Math.max(0,Math.min(1,n-a/h))}return 3*(1-n)*(1-n)*n*t+3*(1-n)*n*n*s+n*n*n}}const Au=La(.25,1,.5,1),Pu=La(.4,0,1,1);function Nu(e,t){const i=e%Du;return Math.sin(.45*i+.04*i*i+t*.25)}const Iu=[1,2,4,64],Ou=[8,16,32,128],Xn=Iu.map((e,t)=>e|Ou[t]);function qt(e,t,i,s){s<4?e[i]|=Xn[s]:t[i]|=Xn[s-4]}function Fu(e){return e>.8?Bu+Yi:e>.6?Mu+Yi:e>.4?Yn+Yi:e>.2?Yn:e>.08?Gn:Gn+br}function Jn(e,t,i){const s=new Uint8Array(qe),r=new Uint8Array(qe),n=new Float32Array(qe),o=e*.35;for(let a=0;a=t)continue;const l=t-h,c=Math.min(1,l/3),d=Math.min(1,h/2),u=l<5?1+.3*(1-l/5):1,f=Math.min(1,c*d*u);if(f<.04)continue;const _=1+.06*Math.sin(e*.7+h*.3),g=Nu(h,o)*f*_*3.5+3.5,E=Math.abs(g-3.5)/3.5,z=l<6?1-l/6:0;n[a]=Math.min(1,E*.65+z*.35)*f;const O=Math.max(0,Math.min(7,Math.round(g)));if(g>=3.5){for(let $=3;$<=O;$++)qt(s,r,a,$);const M=Math.round((g-3.5)*.4);for(let $=Math.max(0,3-M);$<3;$++)qt(s,r,a,$)}else{for(let $=O;$<=4;$++)qt(s,r,a,$);const M=Math.round((3.5-g)*.4);for(let $=5;$<=Math.min(7,4+M);$++)qt(s,r,a,$)}}return{top:s,bot:r,heat:n}}function Zn(e,t,i){const s=new Uint8Array(qe),r=new Uint8Array(qe),n=new Float32Array(qe),o=Math.exp(-t*.5),a=Math.max(0,10-t*2.5),h=.7+t*.2;for(let l=0;l=qe)continue;const d=o*(1-l/a);if(d<.04)continue;n[c]=d;const f=Math.sin(l*h+i*.6)*d*3.5+3.5,_=Math.max(0,Math.min(7,Math.round(f)));if(f>=3.5)for(let p=3;p<=_;p++)qt(s,r,c,p);else for(let p=_;p<=4;p++)qt(s,r,c,p)}return{top:s,bot:r,heat:n}}function Qn(e,t){let i="",s="";for(let r=0;r(t.leave=this._options.leave,t.hover=(i,s)=>{if(this._options.hover){let{range:r}=t;this._options.hover(i,s,r)}},t))}};function zd(e){try{let t=new URL(e),i=t.password&&t.username?`${t.protocol}//${t.username}:${t.password}@${t.host}`:t.username?`${t.protocol}//${t.username}@${t.host}`:`${t.protocol}//${t.host}`;return e.toLocaleLowerCase().startsWith(i.toLocaleLowerCase())}catch{return!1}}var Ud=class Vi{static computeLink(t,i,s,r){let n=new RegExp(i.source,(i.flags||"")+"g"),[o,a]=Vi._getWindowedLineStrings(t-1,s),h=o.join(""),l,c=[];for(;l=n.exec(h);){let d=l[0];if(!zd(d))continue;let[u,f]=Vi._mapStrIdx(s,a,0,l.index),[_,p]=Vi._mapStrIdx(s,u,f,d.length);if(u===-1||f===-1||_===-1||p===-1)continue;let g={start:{x:f+1,y:u+1},end:{x:p,y:_+1}};c.push({range:g,text:d,activate:r})}return c}static _getWindowedLineStrings(t,i){let s,r=t,n=t,o=0,a="",h=[];if(s=i.buffer.active.getLine(t)){let l=s.translateToString(!0);if(s.isWrapped&&l[0]!==" "){for(o=0;(s=i.buffer.active.getLine(--r))&&o<2048&&(a=s.translateToString(!0),o+=a.length,h.push(a),!(!s.isWrapped||a.indexOf(" ")!==-1)););h.reverse()}for(h.push(l),o=0;(s=i.buffer.active.getLine(++n))&&s.isWrapped&&o<2048&&(a=s.translateToString(!0),o+=a.length,h.push(a),a.indexOf(" ")===-1););}return[h,r]}static _mapStrIdx(t,i,s,r){let n=t.buffer.active,o=n.getNullCell(),a=s;for(;r;){let h=n.getLine(i);if(!h)return[-1,-1];for(let l=a;l`]*[^\s"':,.!?{}|\\\^~\[\]`()<>]/;function Kd(e,t){let i=window.open();if(i){try{i.opener=null}catch{}i.location.href=t}else console.warn("Opening link blocked as opener could not be cleared")}var qd=class{constructor(t=Kd,i={}){this._handler=t,this._options=i}activate(t){this._terminal=t;let i=this._options,s=i.urlRegex||jd;this._linkProvider=this._terminal.registerLinkProvider(new Wd(this._terminal,s,this._handler,i))}dispose(){var t;(t=this._linkProvider)==null||t.dispose()}};class Vd{constructor(){D(this,"commands",[])}register(...t){this.commands.push(...t)}find(t){let i;for(const s of this.commands)s.matches(t)&&(!i||s.name.length>i.name.length)&&(i=s);return i}all(){return this.commands}}class ee{constructor(){D(this,"aliases",[]);D(this,"params")}matches(t){const i=t.toLowerCase().trim(),s=r=>i===r||i.startsWith(r+" ");return s(this.name)||this.aliases.some(s)}argsAfterName(t){const i=t.toLowerCase().trim(),s=[this.name,...this.aliases].sort((r,n)=>n.length-r.length);for(const r of s)if(i.startsWith(r))return t.trim().slice(r.length).trim();return t.trim()}}const Ze="\x1B[",Q=`${Ze}0m`,kt=`${Ze}1m`,Gd=`${Ze}2m`,Yd=`${Ze}3m`,us=`${Ze}32m`,Xt=`${Ze}31m`,Ri=`${Ze}33m`,ka=`${Ze}36m`,Bi=`${Ze}34m`,It=`${Ze}90m`,Xd=`${Ze}92m`,Jd=`${Ze}96m`;function Wn(e,t){switch(t){case"success":return`${us}${e}${Q}`;case"error":return`${Xt}${e}${Q}`;case"warning":return`${Ri}${e}${Q}`;case"info":return`${ka}${e}${Q}`;case"value":return`${Bi}${e}${Q}`;case"system":return`${It}${e}${Q}`;default:return e}}function it(e){return`${kt}${e}${Q}`}function Ae(e){return`${Gd}${e}${Q}`}function Zd(e){return`${Ri}${e}${Q}`}function y(e){return`${Bi}${e}${Q}`}function w(e){return`${It}${e}${Q}`}function b(e,t){return`${It}${e}: ${Q}${Bi}${kt}${t}${Q}`}function R(e,t,i=22){const s=e.split(" "),r=s[0];let n=ka;r==="get"?n=us:r==="set"&&(n=Ri);const o=s.length>1?`${n}${kt}${r}${Q} ${Bi}${s.slice(1).join(" ")}${Q}`:`${n}${kt}${e}${Q}`,a=" ".repeat(Math.max(1,i-e.length));return` ${o}${a}${It}${t}${Q}`}function W(e){return`${kt}${Bi}${e}${Q}`}function st(e){return`${It}${Yd}${e}${Q}`}function Qd(e){return`\x1B[1;92m${e||"user"}@pyMC${Q}: \x1B[38;2;91;91;214m$${Q} `}function Rs(e){return`${Xt}${kt}●${Q} ${It}${e}${Q}`}function eu(e){return e<1500?Xd:e<4e3?us:e<8e3?Ri:e<15e3?Xt:`${Xt}${kt}`}function tu(e){const t=e<1e3?`${e.toFixed(0)}ms`:`${(e/1e3).toFixed(1)}s`;return`${eu(e)}${t}${Q}`}function Nr(e){switch(e){case"excellent":return Jd;case"good":return us;case"fair":return Ri;case"poor":return Xt;case"critical":return`${Xt}${kt}`;default:return It}}function iu(e,t){return`${Nr(t)}${e}${Q}`}function zn(e){return e.replace(/[\p{Emoji_Presentation}\p{Extended_Pictographic}\uFE0F\u200D]/gu,"").trim()}const Hi="\x1B[2K\r";function su(e=1){return`\x1B[${e}A`}const ru="\x1B[K",nu="\x1B[H",ou="\x1B[J",au="\x1B[?1049h",Un="\x1B[?1049l",lu="\x1B[?25l",jn="\x1B[?25h";function Ea(e){return e.replace(/\x1b\[[0-9;]*m/g,"")}function hu(e){return Ea(e).length}function yr(e,t){let i=0;for(const s of e){const r=Ea(s).length;i+=r===0?1:Math.ceil(r/t)}return i}function cu(e){return getComputedStyle(document.documentElement).getPropertyValue(e).trim()}function et(e,t){return cu(e)||t}function du(){return document.documentElement.dataset.mode==="light"}function Ra(){const e=du(),t=et("--terminal-bg","#0d0d0d"),i=et("--sys-blue",pe.blue);if(e){const f="#EFF0F1";return{background:f,foreground:"#111314",cursor:pe.blue,cursorAccent:f,selectionBackground:`${pe.blue}30`,selectionForeground:"#111314",black:"#111314",red:pe.red,green:pe.green,yellow:pe.amber,blue:pe.blue,magenta:pe.purple,cyan:pe.cyan,white:f,brightBlack:ii[500],brightRed:pe.red,brightGreen:pe.green,brightYellow:pe.orange,brightBlue:pe.indigo,brightMagenta:pe.pink,brightCyan:pe.teal,brightWhite:ii[600]}}const s=et("--text-primary","#e0e0e0"),r=i+"40",n=et("--sys-red",pe.red),o=et("--sys-green",pe.green),a=et("--sys-purple",pe.purple),h=et("--sys-blue",pe.blue),l=et("--sys-cyan",pe.cyan),c=et("--text-muted",ii[500]),d=et("--text-secondary",ii[400]),u=et("--bg-surface",ii[900]);return{background:t,foreground:s,cursor:i,cursorAccent:t,selectionBackground:r,selectionForeground:s,black:u,red:n,green:o,yellow:a,blue:h,magenta:a,cyan:l,white:s,brightBlack:c,brightRed:n,brightGreen:"#4ADE80",brightYellow:a,brightBlue:h,brightMagenta:a,brightCyan:l,brightWhite:d}}function uu(e){return ja.subscribe(()=>{e.options.theme=Ra()})}const Mi="\x1B[",Et=`${Mi}0m`,_u=`${Mi}1m`,fu=`${Mi}2m`,Ba=`${Mi}34m`,Di=`${Mi}90m`,Bs=24,Ms=13,Kn=" ",qn=" ",pu=[{label:"INFORMATION",entries:[{cmd:"status",desc:"Repeater status summary",alias:"st"},{cmd:"top",desc:"Live system overview (Ctrl+C to exit)",alias:"htop"},{cmd:"ver",desc:"Version info",alias:"version"},{cmd:"clock",desc:"System UTC time"},{cmd:"uptime",desc:"System uptime"},{cmd:"board",desc:"Board / platform info"},{cmd:"packets",desc:"Packet statistics"},{cmd:"stats-packets",desc:"Packet counters (firmware compat)"},{cmd:"stats-radio",desc:"Radio health stats (firmware compat)"},{cmd:"stats-core",desc:"Engine vitals (firmware compat)"}]},{label:"NETWORK",entries:[{cmd:"neighbors [sort]",desc:"Direct RF neighbors",alias:"nb",sub:"sig · name · rssi · snr · dist · heard"},{cmd:"ping {name}",desc:"Ping neighbor (name or 0xXX)"},{cmd:"identities",desc:"List configured identities",alias:"id ids"},{cmd:"keys",desc:"Transport keys"},{cmd:"acl",desc:"ACL statistics"},{cmd:"rooms",desc:"Room statistics"}]},{label:"RADIO",entries:[{cmd:"get {param}",desc:"Read parameter"},{cmd:"set {param} {value}",desc:"Write parameter"},{cmd:"advert",desc:"Send advertisement"}]},{label:"SYSTEM",entries:[{cmd:"restart",desc:"Restart service",alias:"reboot"},{cmd:"start cap [seconds]",desc:"Start packet capture"},{cmd:"end cap",desc:"Stop capture"},{cmd:"list cap",desc:"List captures"},{cmd:"export cap [id]",desc:"Download capture"}]},{label:"TOOLS",entries:[{cmd:"convert hex {value}",desc:"Hex → base64"},{cmd:"convert base64 {value}",desc:"Base64 → hex"},{cmd:"clear",desc:"Clear terminal",alias:"cls"},{cmd:"help [command]",desc:"Show this help",alias:"? h"}]}],mu=[{cat:"Identity",params:["name","role","lat","lon","public.key"]},{cat:"Radio",params:["radio","freq","tx","bw","sf","cr"]},{cat:"Timing",params:["txdelay","direct.txdelay","rxdelay"]},{cat:"Repeater",params:["mode","duty","repeat","flood.max","advert.interval"]},{cat:"Advanced",params:["multi.acks","int.thresh","agc.reset.interval"]},{cat:"set only",params:["log","prv.key"]}];function Ma(e){return`${Di}${"─".repeat(e)}${Et}`}function gu(e){const t="pymc console",i="terminal",s=Math.max(3,e-t.length-i.length-6);return` ${Ba}${_u}${t}${Et} ${Ma(s)} ${Di}${i}${Et}`}function Da(e){return` ${Di}${e}${Et}`}function vu(e,t){const i=[],s=e.alias?` ${fu}${e.alias}${Et}`:"";return 4+Math.max(e.cmd.length,Bs)+e.desc.length+(e.alias?2+e.alias.length:0)<=t?i.push(Kn+R(e.cmd,e.desc,Bs)+s):(i.push(Kn+R(e.cmd,"",Bs)),i.push(qn+w(e.desc)+s)),e.sub&&i.push(`${qn}${Ae("└ "+e.sub)}`),i}function Vn(e){return e.split(" · ").map(t=>`${Ba}${t}${Et}`).join(`${Di} · ${Et}`)}function Su(e,t){const s=[];let r=[],n=0;for(const o of e){const a=r.length>0?3+o.length:o.length;n+a>t&&r.length>0?(s.push(r),r=[o],n=o.length):(r.push(o),n+=a)}return r.length>0&&s.push(r),s}function yu(e){const t=["",Da("GET/SET QUALIFIERS")],i=Math.max(20,e-4-Ms);for(const s of mu){const r=`${Di}${s.cat.padEnd(Ms)}${Et}`,n=Su(s.params,i),o=" ".repeat(4+Ms);t.push(` ${r}${Vn(n[0].join(" · "))}`);for(let a=1;a help for detailed usage")}`]}class bu extends ee{constructor(i){super();D(this,"name","help");D(this,"description","Show available commands");D(this,"aliases",["?","h"]);this.registry=i}execute({output:i,rawInput:s,cols:r}){const n=this.argsAfterName(s).toLowerCase().trim();if(n&&n!=="help"){const a=this.registry.find(n+" help")||this.registry.find(n);if(a){a.execute({output:i,rawInput:a.name+" help",args:[a.name,"help"],cols:r,signal:new AbortController().signal});return}i.write(`Unknown command: ${y(n)}`,"warning");return}const o=[gu(r),""];for(const a of pu){o.push(Da(a.label));for(const h of a.entries)o.push(...vu(h,r));a.label==="RADIO"&&o.push(...yu(r)),o.push("")}o.push(...wu(r)),i.write(o.join(` +`))}}class Cu extends ee{constructor(){super(...arguments);D(this,"name","clear");D(this,"description","Clear terminal screen");D(this,"aliases",["cls"])}execute({output:i,rawInput:s}){if(this.argsAfterName(s).toLowerCase().trim()==="help"){i.write([W("clear"),` ${w("Clear all terminal output.")}`,"",R("clear","clear the screen"),"",W("Aliases"),` ${w("cls")}`].join(` +`));return}i.clear()}}function Ir(e){const t=Math.floor(e/86400),i=Math.floor(e%86400/3600),s=Math.floor(e%3600/60);return t>0?`${t}d ${i}h ${s}m`:i>0?`${i}h ${s}m`:`${s}m`}class xu extends ee{constructor(){super(...arguments);D(this,"name","status");D(this,"description","Get repeater status summary");D(this,"aliases",["st"])}async execute({output:i,rawInput:s}){var n,o,a;if(this.argsAfterName(s).toLowerCase().trim()==="help"){i.write([W("status"),` ${w("Show a quick summary of mode, neighbor count, and uptime.")}`,"",R("status","show summary"),"",W("Aliases"),` ${w("st")}`].join(` +`));return}const r=i.write("processing...","system");try{const h=await rt(),l=((o=(n=h.config)==null?void 0:n.repeater)==null?void 0:o.mode)||"unknown",c=Object.keys(h.neighbors||{}).length,d=Object.values(h.neighbors||{}).filter(_=>_.zero_hop).length,u=((a=h.config)==null?void 0:a.node_name)||h.node_name||"unknown",f=Ir(h.uptime_seconds||0);i.update(r,[`${it(u)} ${w("repeater")}`,"",` ${b("Mode",y(l))}`,` ${b("Neighbors",`${y(String(d))} direct ${w(`${c} total`)}`)}`,` ${b("RX / TX",`${y(String(h.rx_count??0))} / ${y(String(h.tx_count??0))}`)}`,` ${b("Uptime",y(f))}`].join(` +`))}catch(h){i.update(r,`Error: ${h instanceof Error?h.message:"Command failed"}`,"error")}}}class ku extends ee{constructor(){super(...arguments);D(this,"name","uptime");D(this,"description","Show system uptime")}async execute({output:i,rawInput:s}){if(this.argsAfterName(s).toLowerCase().trim()==="help"){i.write([W("uptime"),` ${w("Display how long the repeater service has been running.")}`,"",R("uptime","show uptime")].join(` +`));return}const r=i.write("processing...","system");try{const n=await rt();i.update(r,b("Uptime",y(Ir(n.uptime_seconds||0))))}catch(n){i.update(r,`Error: ${n instanceof Error?n.message:"Command failed"}`,"error")}}}class Eu extends ee{constructor(){super(...arguments);D(this,"name","packets");D(this,"description","Show packet statistics")}async execute({output:i,rawInput:s}){if(this.argsAfterName(s).toLowerCase().trim()==="help"){i.write([W("packets"),` ${w("Display packet counters (received, transmitted, forwarded, dropped).")}`,"",R("packets","show packet stats")].join(` +`));return}const r=i.write("processing...","system");try{const n=await rt(),o=(n.rx_count??0)+(n.tx_count??0);i.update(r,[W("Packet Stats")+` ${w(`${o} total`)}`,"",` ${b("Received",y(String(n.rx_count??0)))}`,` ${b("Transmitted",y(String(n.tx_count??0)))}`,` ${b("Forwarded",y(String(n.forwarded_count??0)))}`,` ${b("Dropped",y(String(n.dropped_count??0)))}`].join(` +`))}catch(n){i.update(r,`Error: ${n instanceof Error?n.message:"Command failed"}`,"error")}}}function zt(e){return e>=1073741824?`${(e/1073741824).toFixed(1)} GB`:e>=1048576?`${(e/1048576).toFixed(0)} MB`:`${(e/1024).toFixed(0)} KB`}function Ds(e){const t=Math.floor(e/86400),i=Math.floor(e%86400/3600),s=Math.floor(e%3600/60);return t>0?`${t}d ${i}h ${s}m`:i>0?`${i}h ${s}m`:`${s}m`}class Ru extends ee{constructor(){super(...arguments);D(this,"name","board");D(this,"description","Show board/platform info")}async execute({output:i,rawInput:s}){var n;if(this.argsAfterName(s).toLowerCase().trim()==="help"){i.write([W("board"),` ${w("Display platform and hardware information.")}`,"",R("board","show board info")].join(` +`));return}const r=i.write("loading...","system");try{const[o,a]=await Promise.all([Qi(),rt()]),h=[];if(h.push(` ${b("Node",y(a.node_name||"Unknown"))}`),h.push(` ${b("Runtime",y(`pyMC_Repeater v${a.version||"?"}`))}`),a.core_version&&h.push(` ${b("Core",y(a.core_version))}`),h.push(""),o.success&&o.data){const l=o.data;h.push(` ${b("CPU",y(`${l.cpu.usage_percent.toFixed(1)}%`))} ${w(`${l.cpu.count} core${l.cpu.count>1?"s":""}`)}`),l.cpu.load_avg&&h.push(` ${b("Load",y(`${l.cpu.load_avg["1min"].toFixed(2)} / ${l.cpu.load_avg["5min"].toFixed(2)} / ${l.cpu.load_avg["15min"].toFixed(2)}`))}`);const c=Object.entries(l.temperatures||{});if(c.length>0){const d=c[0];h.push(` ${b("Temp",y(`${d[1].toFixed(1)}°C`))}${c.length>1?` ${w(c.slice(1).map(([u,f])=>`${u}: ${f.toFixed(1)}°C`).join(", "))}`:""}`)}h.push(""),h.push(` ${b("Memory",y(`${zt(l.memory.used)} / ${zt(l.memory.total)}`))} ${w(`${l.memory.usage_percent.toFixed(0)}%`)}`),h.push(` ${b("Disk",y(`${zt(l.disk.used)} / ${zt(l.disk.total)}`))} ${w(`${l.disk.usage_percent.toFixed(0)}%`)}`),h.push(""),(n=l.system)!=null&&n.uptime&&h.push(` ${b("System uptime",y(Ds(l.system.uptime)))}`),h.push(` ${b("Service uptime",y(Ds(a.uptime_seconds)))}`),l.network&&h.push(` ${b("Net TX/RX",y(`${zt(l.network.bytes_sent)} / ${zt(l.network.bytes_recv)}`))}`)}else h.push(` ${b("Platform",y("Linux"))}`),h.push(` ${b("Service uptime",y(Ds(a.uptime_seconds)))}`),h.push(` ${w("Hardware stats unavailable")}`);i.update(r,h.join(` +`),"value")}catch(o){i.update(r,`Error: ${o instanceof Error?o.message:"Failed to load hardware stats"}`,"error")}}}const Gi="\x1B[0m",Yi="\x1B[1m",wr="\x1B[2m",Gn="\x1B[36m",Yn="\x1B[96m",Bu="\x1B[97m",Mu="\x1B[93m",qe=48,Du=14,St=22,mi=5,Xi=22,Lu=5,Tu=St+mi+Xi+Lu,$u=50;function La(e,t,i,s){return r=>{if(r<=0)return 0;if(r>=1)return 1;let n=r;for(let o=0;o<8;o++){const a=3*(1-n)*(1-n)*n*e+3*(1-n)*n*n*i+n*n*n-r,h=3*(1-n)*(1-n)*e+6*(1-n)*n*(i-e)+3*n*n*(1-i);if(Math.abs(h)<1e-7)break;n=Math.max(0,Math.min(1,n-a/h))}return 3*(1-n)*(1-n)*n*t+3*(1-n)*n*n*s+n*n*n}}const Au=La(.25,1,.5,1),Pu=La(.4,0,1,1);function Nu(e,t){const i=e%Du;return Math.sin(.45*i+.04*i*i+t*.25)}const Iu=[1,2,4,64],Ou=[8,16,32,128],Xn=Iu.map((e,t)=>e|Ou[t]);function qt(e,t,i,s){s<4?e[i]|=Xn[s]:t[i]|=Xn[s-4]}function Hu(e){return e>.8?Bu+Yi:e>.6?Mu+Yi:e>.4?Yn+Yi:e>.2?Yn:e>.08?Gn:Gn+wr}function Jn(e,t,i){const s=new Uint8Array(qe),r=new Uint8Array(qe),n=new Float32Array(qe),o=e*.35;for(let a=0;a=t)continue;const l=t-h,c=Math.min(1,l/3),d=Math.min(1,h/2),u=l<5?1+.3*(1-l/5):1,f=Math.min(1,c*d*u);if(f<.04)continue;const _=1+.06*Math.sin(e*.7+h*.3),g=Nu(h,o)*f*_*3.5+3.5,E=Math.abs(g-3.5)/3.5,z=l<6?1-l/6:0;n[a]=Math.min(1,E*.65+z*.35)*f;const O=Math.max(0,Math.min(7,Math.round(g)));if(g>=3.5){for(let $=3;$<=O;$++)qt(s,r,a,$);const M=Math.round((g-3.5)*.4);for(let $=Math.max(0,3-M);$<3;$++)qt(s,r,a,$)}else{for(let $=O;$<=4;$++)qt(s,r,a,$);const M=Math.round((3.5-g)*.4);for(let $=5;$<=Math.min(7,4+M);$++)qt(s,r,a,$)}}return{top:s,bot:r,heat:n}}function Zn(e,t,i){const s=new Uint8Array(qe),r=new Uint8Array(qe),n=new Float32Array(qe),o=Math.exp(-t*.5),a=Math.max(0,10-t*2.5),h=.7+t*.2;for(let l=0;l=qe)continue;const d=o*(1-l/a);if(d<.04)continue;n[c]=d;const f=Math.sin(l*h+i*.6)*d*3.5+3.5,_=Math.max(0,Math.min(7,Math.round(f)));if(f>=3.5)for(let p=3;p<=_;p++)qt(s,r,c,p);else for(let p=_;p<=4;p++)qt(s,r,c,p)}return{top:s,bot:r,heat:n}}function Qn(e,t){let i="",s="";for(let r=0;r{s++,e.update(r,eo(s,t,Date.now()-i).join(` -`))},$u);return{id:r,stop:()=>clearInterval(n)}}class Hu extends ee{constructor(){super(...arguments);D(this,"name","advert");D(this,"description","Send repeater advertisement")}async execute({output:i,rawInput:s}){if(this.argsAfterName(s).toLowerCase().trim()==="help"){i.write([W("advert"),` ${b("Broadcast a repeater advertisement to the mesh network.")}`,"",R("advert","send advert now"),"",st("Adverts announce this repeater's presence to neighbors.")].join(` -`));return}const r=Ta(i,"broadcast");try{const n=await Ka();r.stop(),n.success?i.update(r.id,`✓ ${y("Advert sent")}`,"success"):i.update(r.id,`Error: ${n.error||"Failed"}`,"error")}catch(n){r.stop(),i.update(r.id,`Error: ${n instanceof Error?n.message:"Command failed"}`,"error")}}}const Wu=["sig","name","rssi","snr","dist","heard"],to={excellent:5,good:4,fair:3,poor:2,critical:1};function io(e){const t=Math.floor(Date.now()/1e3-e);return t<60?`${t}s ago`:t<3600?`${Math.floor(t/60)}m ago`:t<86400?`${Math.floor(t/3600)}h ago`:`${Math.floor(t/86400)}d ago`}function zu(e,t){return e.length>=t?e.slice(0,t):e+" ".repeat(t-e.length)}function so(e){return e<1e3?`${Math.round(e)}m`:`${(e/1e3).toFixed(1)}km`}const Uu={excellent:5,good:4,fair:3,poor:2,critical:1};function ro(e){const t=Uu[e]??0,i=Nr(e),s=t>0?`${i}${"█".repeat(t)}${Q}`:"",r=b("⣿".repeat(5-t));return s+r}const no=3.5;function ju(e){var i;const t=(i=e.config)==null?void 0:i.radio;return!(t!=null&&t.spreading_factor)||!(t!=null&&t.bandwidth)?null:{sf:t.spreading_factor,bwHz:t.bandwidth}}function Ku(e){var i;const t=(i=e.config)==null?void 0:i.repeater;return!t||!Co(t.latitude,t.longitude)?null:{lat:t.latitude,lon:t.longitude}}function Ut(e,t=i=>i){return{text:e,color:t}}function qu(e,t){return{text:e,color:i=>i,rendered:t}}function Ls(e){return b("+"+e.map(t=>"-".repeat(t+2)).join("+")+"+")}function oo(e,t){const i=e.map((s,r)=>{if(s.rendered!=null){const n=Math.max(0,t[r]-s.text.length);return" "+s.rendered+" ".repeat(n)+" "}return" "+s.color(zu(s.text,t[r]))+" "});return b("|")+i.join(b("|"))+b("|")}const Vu=70,Gu=55;class Yu extends ee{constructor(){super(...arguments);D(this,"name","neighbors");D(this,"description","Show direct RF neighbors with signal stats");D(this,"aliases",["nb","get neighbors","get neighbor"]);D(this,"params","[sig|name|rssi|snr|dist|heard]")}async execute(i){const{output:s,cols:r}=i,n=this.argsAfterName(i.rawInput).toLowerCase().trim();if(n==="help"){this.printUsage(s);return}const o=Wu.includes(n)?n:null,a=s.write("processing...","system");try{const h=await rt(),l=h.neighbors||{},c=Object.entries(l).filter(([,g])=>g.zero_hop);if(c.length===0){const g=Object.keys(l).length;s.update(a,g>0?`No direct neighbors. ${g} relayed neighbor${g!==1?"s":""} known.`:"No neighbors discovered yet.","warning");return}const d=ju(h),u=Ku(h),f=h.noise_floor_dbm;this.sortNeighbors(c,o,d,u,f);const _=o?` ${Ae(`sorted by ${o}`)}`:"",p=[W(`Direct Neighbors (${c.length})`)+_,""];if(r=Vu&&u!=null,E=c.map(([J,Fe])=>this.buildRow(J,Fe,d,u,f,g)),z=g?["SIG","NAME","RSSI","SNR","DIST","HEARD"]:["SIG","NAME","RSSI","SNR","HEARD"],O=z.slice(1).map((J,Fe)=>Math.max(J.length,...E.map(Y=>Y[Fe+1].text.length))),M=5,$=O.reduce((J,Fe)=>J+Fe+3,0),K=Math.max(4,r-$-M-7),ae=Math.min(K,Math.max(4,...E.map(J=>J[1].text.length))),ne=[M,ae,...O.slice(1)];p.push(Ls(ne),...E.map(J=>oo(J,ne)),Ls(ne),oo(z.map(J=>Ut(J,it)),ne),Ls(ne)),p.push(this.footer(d,f))}s.update(a,p.join(` -`))}catch(h){s.update(a,`Error: ${h instanceof Error?h.message:"Command failed"}`,"error")}}sortNeighbors(i,s,r,n,o){switch(s){case"sig":i.sort(([,a],[,h])=>{const l=to[this.gradeNeighbor(a,r,o)]??0,c=to[this.gradeNeighbor(h,r,o)]??0;return l-c});break;case"name":i.sort(([a,h],[l,c])=>{const d=(h.name||h.node_name||a.slice(0,8)).toLowerCase(),u=(c.name||c.node_name||l.slice(0,8)).toLowerCase();return d.localeCompare(u)});break;case"rssi":i.sort(([,a],[,h])=>(a.rssi??-999)-(h.rssi??-999));break;case"snr":i.sort(([,a],[,h])=>(a.snr??-999)-(h.snr??-999));break;case"dist":i.sort(([,a],[,h])=>{const l=this.distTo(a,n)??1/0,c=this.distTo(h,n)??1/0;return l-c});break;case"heard":i.sort(([,a],[,h])=>(a.last_seen||0)-(h.last_seen||0));break;default:i.sort(([,a],[,h])=>(h.last_seen||0)-(a.last_seen||0))}}gradeNeighbor(i,s,r){const n=i.rssi!=null?i.rssi-no:null,o=r!=null&&r>-100?1:0,a=wo(i.snr??null,n,s,o);return(a==null?void 0:a.finalGrade)??"critical"}distTo(i,s){return!s||!Co(i.latitude,i.longitude)?null:qa(s.lat,s.lon,i.latitude,i.longitude)}buildRow(i,s,r,n,o,a){const h=this.gradeNeighbor(s,r,o),l=zn(s.name||s.node_name||i.slice(0,8))||i.slice(0,8),c=s.rssi!=null?`${s.rssi} dBm`:"-",d=s.snr!=null?`${s.snr} dB`:"-",u=s.last_seen?io(s.last_seen):"-",f=ro(h),_=[qu("|||||",f),Ut(l,it),Ut(c,y),Ut(d,y)];if(a){const p=this.distTo(s,n);_.push(Ut(p!=null?so(p):"-",Ae))}return _.push(Ut(u,Ae)),_}cardLayout(i,s,r,n,o){const a=this.gradeNeighbor(s,r,o),h=zn(s.name||s.node_name||i.slice(0,8))||i.slice(0,8),l=s.rssi!=null?`${s.rssi}`:"-",c=s.snr!=null?`${s.snr}`:"-",d=s.last_seen?io(s.last_seen):"-",u=this.distTo(s,n),f=u!=null?` ${b("dist")} ${y(so(u))}`:"";return[`${ro(a)} ${it(h)}`,` ${b("rssi")} ${y(l)} ${b("snr")} ${y(c)}${f} ${Ae(d)}`,""]}footer(i,s){const r=[];return i&&r.push(`SF${i.sf}/${i.bwHz>=1e3?i.bwHz/1e3+"kHz":i.bwHz+"Hz"}`),r.push(`ant ${no}dBi`),s!=null&&r.push(`nf ${s}dBm`),b(r.join(" "))}printUsage(i){const s=[W("neighbors"),` ${b("Show direct RF neighbors with signal quality, RSSI, SNR, and distance.")}`,"",W("Usage"),R("neighbors","default sort (most recent)"),R("neighbors sig","sort by signal grade (weakest first)"),R("neighbors name","sort alphabetically"),R("neighbors rssi","sort by RSSI (weakest first)"),R("neighbors snr","sort by SNR (lowest first)"),R("neighbors dist","sort by distance (closest first)"),R("neighbors heard","sort by last seen (oldest first)"),R("neighbors help","show this help"),"",W("Aliases"),` ${b("nb, get neighbors, get neighbor")}`,"",st("Signal bars factor radio config, noise floor, and 3.5 dBi antenna gain."),st("Only zero-hop (direct RF) neighbors are shown.")];i.write(s.join(` -`))}}class Xu extends ee{constructor(){super(...arguments);D(this,"name","get");D(this,"description","Get repeater parameter");D(this,"params","{parameter}")}async execute({output:i,rawInput:s}){const r=this.argsAfterName(s).toLowerCase().trim();if(r==="help"||!r){i.write([W("get"),` ${b("Read a repeater configuration parameter.")}`,"",W("Identity"),R("get name","node name"),R("get role","node role"),R("get public.key","public key"),"",W("Location"),R("get lat","latitude"),R("get lon","longitude"),"",W("Radio"),R("get radio","full radio summary"),R("get freq","frequency (MHz)"),R("get tx","TX power (dBm)"),R("get bw","bandwidth (kHz)"),R("get sf","spreading factor"),R("get cr","coding rate"),"",W("Timing"),R("get af","airtime factor (pending backend)"),R("get txdelay","TX delay factor"),R("get direct.txdelay","direct TX delay"),R("get rxdelay","RX delay base"),"",W("Repeater"),R("get mode","forward or monitor"),R("get flood.max","max flood hops"),R("get advert.interval","advert interval"),R("get duty","duty cycle state"),"",W("Advanced"),R("get multi.acks","multi-ack count"),R("get int.thresh","interference threshold (dBm)"),R("get agc.reset.interval","AGC reset interval")].join(` -`));return}const n=i.write("processing...","system");try{const o=await rt(),{result:a,type:h}=Ju(r,o);i.update(n,a,h)}catch(o){i.update(n,`Error: ${o instanceof Error?o.message:"Command failed"}`,"error")}}}function Ju(e,t){const i=t.config||{},s=i.radio||{},r=i.repeater||{},n=i.delays||{},o=i.duty_cycle||{},a=(h,l)=>({result:w(h,y(l)),type:"value"});switch(e){case"name":return a("name",i.node_name||"Unknown");case"role":return a("role","repeater");case"lat":return a("lat",r.latitude!=null?String(r.latitude):"not set");case"lon":return a("lon",r.longitude!=null?String(r.longitude):"not set");case"freq":return a("freq",s.frequency?`${(s.frequency/1e6).toFixed(3)} MHz`:"?");case"tx":return a("tx",s.tx_power!=null?`${s.tx_power} dBm`:"?");case"bw":return a("bw",s.bandwidth?`${s.bandwidth/1e3} kHz`:"?");case"sf":return a("sf",String(s.spreading_factor??"?"));case"cr":return a("cr",s.coding_rate?`4/${s.coding_rate}`:"?");case"radio":return s.frequency?{result:[` ${w("freq",y(`${(s.frequency/1e6).toFixed(3)} MHz`))}`,` ${w("bw",y(`${s.bandwidth/1e3} kHz`))}`,` ${w("sf",y(String(s.spreading_factor)))}`,` ${w("cr",y(`4/${s.coding_rate}`))}`,` ${w("tx",y(`${s.tx_power} dBm`))}`].join(` -`),type:"value"}:a("radio","?");case"af":case"airtime.factor":return{result:`${b("airtime_factor is not yet exposed by the pyMC_Repeater API.")} -${b("Firmware range: 0-9. Controls airtime budget fraction.")} -${b("Tracked in CLI-Alignment.md — needs backend support.")}`,type:"warning"};case"txdelay":return a("txdelay",String(n.tx_delay_factor??"1.0"));case"direct.txdelay":return a("direct.txdelay",String(n.direct_tx_delay_factor??"0.5"));case"rxdelay":return a("rxdelay",String(n.rx_delay_base??"0.0"));case"mode":return a("mode",r.mode||"forward");case"repeat":return a("repeat",r.mode==="forward"?"on":"off");case"flood.max":return a("flood.max",String(r.max_flood_hops??"3"));case"flood.advert.interval":return a("flood.advert.interval",r.send_advert_interval_hours!=null?`${r.send_advert_interval_hours}h`:"?");case"advert.interval":return a("advert.interval",r.advert_interval_minutes!=null?`${r.advert_interval_minutes}m`:"120m");case"duty":case"duty.enabled":return a("duty",o.enforcement_enabled?"on":"off");case"duty.max":return a("duty.max",o.max_airtime_percent!=null?`${o.max_airtime_percent}%`:"?");case"multi.acks":return a("multi.acks",String(r.multi_acks??"0"));case"int.thresh":return a("int.thresh",`${r.interference_threshold??-120} dBm`);case"agc.reset.interval":return a("agc.reset.interval",String(r.agc_reset_interval??"0"));case"public.key":return a("public.key",t.public_key||"not available");case"prv.key":return{result:`${b("Private key stored in /etc/pymc_repeater/config.yaml")} +`))},$u);return{id:r,stop:()=>clearInterval(n)}}class Fu extends ee{constructor(){super(...arguments);D(this,"name","advert");D(this,"description","Send repeater advertisement")}async execute({output:i,rawInput:s}){if(this.argsAfterName(s).toLowerCase().trim()==="help"){i.write([W("advert"),` ${w("Broadcast a repeater advertisement to the mesh network.")}`,"",R("advert","send advert now"),"",st("Adverts announce this repeater's presence to neighbors.")].join(` +`));return}const r=Ta(i,"broadcast");try{const n=await Ka();r.stop(),n.success?i.update(r.id,`✓ ${y("Advert sent")}`,"success"):i.update(r.id,`Error: ${n.error||"Failed"}`,"error")}catch(n){r.stop(),i.update(r.id,`Error: ${n instanceof Error?n.message:"Command failed"}`,"error")}}}const Wu=["sig","name","rssi","snr","dist","heard"],to={excellent:5,good:4,fair:3,poor:2,critical:1};function io(e){const t=Math.floor(Date.now()/1e3-e);return t<60?`${t}s ago`:t<3600?`${Math.floor(t/60)}m ago`:t<86400?`${Math.floor(t/3600)}h ago`:`${Math.floor(t/86400)}d ago`}function zu(e,t){return e.length>=t?e.slice(0,t):e+" ".repeat(t-e.length)}function so(e){return e<1e3?`${Math.round(e)}m`:`${(e/1e3).toFixed(1)}km`}const Uu={excellent:5,good:4,fair:3,poor:2,critical:1};function ro(e){const t=Uu[e]??0,i=Nr(e),s=t>0?`${i}${"█".repeat(t)}${Q}`:"",r=w("⣿".repeat(5-t));return s+r}const no=3.5;function ju(e){var i;const t=(i=e.config)==null?void 0:i.radio;return!(t!=null&&t.spreading_factor)||!(t!=null&&t.bandwidth)?null:{sf:t.spreading_factor,bwHz:t.bandwidth}}function Ku(e){var i;const t=(i=e.config)==null?void 0:i.repeater;return!t||!Co(t.latitude,t.longitude)?null:{lat:t.latitude,lon:t.longitude}}function Ut(e,t=i=>i){return{text:e,color:t}}function qu(e,t){return{text:e,color:i=>i,rendered:t}}function Ls(e){return w("+"+e.map(t=>"-".repeat(t+2)).join("+")+"+")}function oo(e,t){const i=e.map((s,r)=>{if(s.rendered!=null){const n=Math.max(0,t[r]-s.text.length);return" "+s.rendered+" ".repeat(n)+" "}return" "+s.color(zu(s.text,t[r]))+" "});return w("|")+i.join(w("|"))+w("|")}const Vu=70,Gu=55;class Yu extends ee{constructor(){super(...arguments);D(this,"name","neighbors");D(this,"description","Show direct RF neighbors with signal stats");D(this,"aliases",["nb","get neighbors","get neighbor"]);D(this,"params","[sig|name|rssi|snr|dist|heard]")}async execute(i){const{output:s,cols:r}=i,n=this.argsAfterName(i.rawInput).toLowerCase().trim();if(n==="help"){this.printUsage(s);return}const o=Wu.includes(n)?n:null,a=s.write("processing...","system");try{const h=await rt(),l=h.neighbors||{},c=Object.entries(l).filter(([,g])=>g.zero_hop);if(c.length===0){const g=Object.keys(l).length;s.update(a,g>0?`No direct neighbors. ${g} relayed neighbor${g!==1?"s":""} known.`:"No neighbors discovered yet.","warning");return}const d=ju(h),u=Ku(h),f=h.noise_floor_dbm;this.sortNeighbors(c,o,d,u,f);const _=o?` ${Ae(`sorted by ${o}`)}`:"",p=[W(`Direct Neighbors (${c.length})`)+_,""];if(r=Vu&&u!=null,E=c.map(([J,He])=>this.buildRow(J,He,d,u,f,g)),z=g?["SIG","NAME","RSSI","SNR","DIST","HEARD"]:["SIG","NAME","RSSI","SNR","HEARD"],O=z.slice(1).map((J,He)=>Math.max(J.length,...E.map(Y=>Y[He+1].text.length))),M=5,$=O.reduce((J,He)=>J+He+3,0),K=Math.max(4,r-$-M-7),ae=Math.min(K,Math.max(4,...E.map(J=>J[1].text.length))),ne=[M,ae,...O.slice(1)];p.push(Ls(ne),...E.map(J=>oo(J,ne)),Ls(ne),oo(z.map(J=>Ut(J,it)),ne),Ls(ne)),p.push(this.footer(d,f))}s.update(a,p.join(` +`))}catch(h){s.update(a,`Error: ${h instanceof Error?h.message:"Command failed"}`,"error")}}sortNeighbors(i,s,r,n,o){switch(s){case"sig":i.sort(([,a],[,h])=>{const l=to[this.gradeNeighbor(a,r,o)]??0,c=to[this.gradeNeighbor(h,r,o)]??0;return l-c});break;case"name":i.sort(([a,h],[l,c])=>{const d=(h.name||h.node_name||a.slice(0,8)).toLowerCase(),u=(c.name||c.node_name||l.slice(0,8)).toLowerCase();return d.localeCompare(u)});break;case"rssi":i.sort(([,a],[,h])=>(a.rssi??-999)-(h.rssi??-999));break;case"snr":i.sort(([,a],[,h])=>(a.snr??-999)-(h.snr??-999));break;case"dist":i.sort(([,a],[,h])=>{const l=this.distTo(a,n)??1/0,c=this.distTo(h,n)??1/0;return l-c});break;case"heard":i.sort(([,a],[,h])=>(a.last_seen||0)-(h.last_seen||0));break;default:i.sort(([,a],[,h])=>(h.last_seen||0)-(a.last_seen||0))}}gradeNeighbor(i,s,r){const n=i.rssi!=null?i.rssi-no:null,o=r!=null&&r>-100?1:0,a=bo(i.snr??null,n,s,o);return(a==null?void 0:a.finalGrade)??"critical"}distTo(i,s){return!s||!Co(i.latitude,i.longitude)?null:qa(s.lat,s.lon,i.latitude,i.longitude)}buildRow(i,s,r,n,o,a){const h=this.gradeNeighbor(s,r,o),l=zn(s.name||s.node_name||i.slice(0,8))||i.slice(0,8),c=s.rssi!=null?`${s.rssi} dBm`:"-",d=s.snr!=null?`${s.snr} dB`:"-",u=s.last_seen?io(s.last_seen):"-",f=ro(h),_=[qu("|||||",f),Ut(l,it),Ut(c,y),Ut(d,y)];if(a){const p=this.distTo(s,n);_.push(Ut(p!=null?so(p):"-",Ae))}return _.push(Ut(u,Ae)),_}cardLayout(i,s,r,n,o){const a=this.gradeNeighbor(s,r,o),h=zn(s.name||s.node_name||i.slice(0,8))||i.slice(0,8),l=s.rssi!=null?`${s.rssi}`:"-",c=s.snr!=null?`${s.snr}`:"-",d=s.last_seen?io(s.last_seen):"-",u=this.distTo(s,n),f=u!=null?` ${w("dist")} ${y(so(u))}`:"";return[`${ro(a)} ${it(h)}`,` ${w("rssi")} ${y(l)} ${w("snr")} ${y(c)}${f} ${Ae(d)}`,""]}footer(i,s){const r=[];return i&&r.push(`SF${i.sf}/${i.bwHz>=1e3?i.bwHz/1e3+"kHz":i.bwHz+"Hz"}`),r.push(`ant ${no}dBi`),s!=null&&r.push(`nf ${s}dBm`),w(r.join(" "))}printUsage(i){const s=[W("neighbors"),` ${w("Show direct RF neighbors with signal quality, RSSI, SNR, and distance.")}`,"",W("Usage"),R("neighbors","default sort (most recent)"),R("neighbors sig","sort by signal grade (weakest first)"),R("neighbors name","sort alphabetically"),R("neighbors rssi","sort by RSSI (weakest first)"),R("neighbors snr","sort by SNR (lowest first)"),R("neighbors dist","sort by distance (closest first)"),R("neighbors heard","sort by last seen (oldest first)"),R("neighbors help","show this help"),"",W("Aliases"),` ${w("nb, get neighbors, get neighbor")}`,"",st("Signal bars factor radio config, noise floor, and 3.5 dBi antenna gain."),st("Only zero-hop (direct RF) neighbors are shown.")];i.write(s.join(` +`))}}class Xu extends ee{constructor(){super(...arguments);D(this,"name","get");D(this,"description","Get repeater parameter");D(this,"params","{parameter}")}async execute({output:i,rawInput:s}){const r=this.argsAfterName(s).toLowerCase().trim();if(r==="help"||!r){i.write([W("get"),` ${w("Read a repeater configuration parameter.")}`,"",W("Identity"),R("get name","node name"),R("get role","node role"),R("get public.key","public key"),"",W("Location"),R("get lat","latitude"),R("get lon","longitude"),"",W("Radio"),R("get radio","full radio summary"),R("get freq","frequency (MHz)"),R("get tx","TX power (dBm)"),R("get bw","bandwidth (kHz)"),R("get sf","spreading factor"),R("get cr","coding rate"),"",W("Timing"),R("get af","airtime factor (pending backend)"),R("get txdelay","TX delay factor"),R("get direct.txdelay","direct TX delay"),R("get rxdelay","RX delay base"),"",W("Repeater"),R("get mode","forward or monitor"),R("get flood.max","max flood hops"),R("get advert.interval","advert interval"),R("get duty","duty cycle state"),"",W("Advanced"),R("get multi.acks","multi-ack count"),R("get int.thresh","interference threshold (dBm)"),R("get agc.reset.interval","AGC reset interval")].join(` +`));return}const n=i.write("processing...","system");try{const o=await rt(),{result:a,type:h}=Ju(r,o);i.update(n,a,h)}catch(o){i.update(n,`Error: ${o instanceof Error?o.message:"Command failed"}`,"error")}}}function Ju(e,t){const i=t.config||{},s=i.radio||{},r=i.repeater||{},n=i.delays||{},o=i.duty_cycle||{},a=(h,l)=>({result:b(h,y(l)),type:"value"});switch(e){case"name":return a("name",i.node_name||"Unknown");case"role":return a("role","repeater");case"lat":return a("lat",r.latitude!=null?String(r.latitude):"not set");case"lon":return a("lon",r.longitude!=null?String(r.longitude):"not set");case"freq":return a("freq",s.frequency?`${(s.frequency/1e6).toFixed(3)} MHz`:"?");case"tx":return a("tx",s.tx_power!=null?`${s.tx_power} dBm`:"?");case"bw":return a("bw",s.bandwidth?`${s.bandwidth/1e3} kHz`:"?");case"sf":return a("sf",String(s.spreading_factor??"?"));case"cr":return a("cr",s.coding_rate?`4/${s.coding_rate}`:"?");case"radio":return s.frequency?{result:[` ${b("freq",y(`${(s.frequency/1e6).toFixed(3)} MHz`))}`,` ${b("bw",y(`${s.bandwidth/1e3} kHz`))}`,` ${b("sf",y(String(s.spreading_factor)))}`,` ${b("cr",y(`4/${s.coding_rate}`))}`,` ${b("tx",y(`${s.tx_power} dBm`))}`].join(` +`),type:"value"}:a("radio","?");case"af":case"airtime.factor":return{result:`${w("airtime_factor is not yet exposed by the pyMC_Repeater API.")} +${w("Firmware range: 0-9. Controls airtime budget fraction.")} +${w("Tracked in CLI-Alignment.md — needs backend support.")}`,type:"warning"};case"txdelay":return a("txdelay",String(n.tx_delay_factor??"1.0"));case"direct.txdelay":return a("direct.txdelay",String(n.direct_tx_delay_factor??"0.5"));case"rxdelay":return a("rxdelay",String(n.rx_delay_base??"0.0"));case"mode":return a("mode",r.mode||"forward");case"repeat":return a("repeat",r.mode==="forward"?"on":"off");case"flood.max":return a("flood.max",String(r.max_flood_hops??"3"));case"flood.advert.interval":return a("flood.advert.interval",r.send_advert_interval_hours!=null?`${r.send_advert_interval_hours}h`:"?");case"advert.interval":return a("advert.interval",r.advert_interval_minutes!=null?`${r.advert_interval_minutes}m`:"120m");case"duty":case"duty.enabled":return a("duty",o.enforcement_enabled?"on":"off");case"duty.max":return a("duty.max",o.max_airtime_percent!=null?`${o.max_airtime_percent}%`:"?");case"multi.acks":return a("multi.acks",String(r.multi_acks??"0"));case"int.thresh":return a("int.thresh",`${r.interference_threshold??-120} dBm`);case"agc.reset.interval":return a("agc.reset.interval",String(r.agc_reset_interval??"0"));case"public.key":return a("public.key",t.public_key||"not available");case"prv.key":return{result:`${w("Private key stored in /etc/pymc_repeater/config.yaml")} - ${w("view",y("sudo grep identity_key /etc/pymc_repeater/config.yaml"))} - ${w("set",y("sudo ./convert_firmware_key.sh <64-byte-hex>"))}`,type:"info"};case"guest.password":case"allow.read.only":return{result:`${b("Security settings not exposed via stats API.")} -${b("Check /etc/pymc_repeater/config.yaml")}`,type:"warning"};default:return{result:`Unknown parameter: ${y(e)} -${b('Run "get help" to see available parameters.')}`,type:"error"}}}class Zu extends ee{constructor(){super(...arguments);D(this,"name","set");D(this,"description","Set repeater parameter");D(this,"params","{parameter} {value}")}async execute({output:i,rawInput:s}){var l;const n=this.argsAfterName(s).split(/\s+/),o=(l=n[0])==null?void 0:l.toLowerCase(),a=n.slice(1).join(" ");if(o==="help"||!o){i.write([W("set"),` ${b("Write a repeater configuration parameter.")}`,"",W("Identity"),R("set name ","node name"),R("set lat ","latitude (-90 to 90)"),R("set lon ","longitude (-180 to 180)"),"",W("Radio"),R("set freq ","frequency"),R("set tx ","TX power (2-22)"),R("set bw ","bandwidth"),R("set sf <5-12>","spreading factor"),R("set cr <5-8>","coding rate"),"",W("Timing"),R("set af <0-9>","airtime factor (pending backend)"),R("set txdelay <0-5>","TX delay factor"),R("set direct.txdelay <0-5>","direct TX delay"),R("set rxdelay ","RX delay base"),"",W("Repeater"),R("set mode ","forward or monitor"),R("set flood.max <0-64>","max flood hops"),R("set advert.interval ","advert interval (min)"),R("set duty ","duty cycle enforcement"),R("set log ","log level"),"",W("Advanced"),R("set multi.acks ","multi-ack count"),R("set int.thresh ","interference threshold"),R("set agc.reset.interval ","AGC reset interval (x4)"),"",st("Some changes require a service restart.")].join(` + ${b("view",y("sudo grep identity_key /etc/pymc_repeater/config.yaml"))} + ${b("set",y("sudo ./convert_firmware_key.sh <64-byte-hex>"))}`,type:"info"};case"guest.password":case"allow.read.only":return{result:`${w("Security settings not exposed via stats API.")} +${w("Check /etc/pymc_repeater/config.yaml")}`,type:"warning"};default:return{result:`Unknown parameter: ${y(e)} +${w('Run "get help" to see available parameters.')}`,type:"error"}}}class Zu extends ee{constructor(){super(...arguments);D(this,"name","set");D(this,"description","Set repeater parameter");D(this,"params","{parameter} {value}")}async execute({output:i,rawInput:s}){var l;const n=this.argsAfterName(s).split(/\s+/),o=(l=n[0])==null?void 0:l.toLowerCase(),a=n.slice(1).join(" ");if(o==="help"||!o){i.write([W("set"),` ${w("Write a repeater configuration parameter.")}`,"",W("Identity"),R("set name ","node name"),R("set lat ","latitude (-90 to 90)"),R("set lon ","longitude (-180 to 180)"),"",W("Radio"),R("set freq ","frequency"),R("set tx ","TX power (2-22)"),R("set bw ","bandwidth"),R("set sf <5-12>","spreading factor"),R("set cr <5-8>","coding rate"),"",W("Timing"),R("set af <0-9>","airtime factor (pending backend)"),R("set txdelay <0-5>","TX delay factor"),R("set direct.txdelay <0-5>","direct TX delay"),R("set rxdelay ","RX delay base"),"",W("Repeater"),R("set mode ","forward or monitor"),R("set flood.max <0-64>","max flood hops"),R("set advert.interval ","advert interval (min)"),R("set duty ","duty cycle enforcement"),R("set log ","log level"),"",W("Advanced"),R("set multi.acks ","multi-ack count"),R("set int.thresh ","interference threshold"),R("set agc.reset.interval ","AGC reset interval (x4)"),"",st("Some changes require a service restart.")].join(` `));return}const h=i.write("processing...","system");try{const{result:c,type:d}=await Qu(o,a,s);i.update(h,c,d)}catch(c){i.update(h,`Error: ${c instanceof Error?c.message:"Command failed"}`,"error")}}}async function Qu(e,t,i){switch(e){case"mode":return e_(t);case"duty":return t_(t);case"tx":return Ue("tx_power",jt(t,2,22,"TX power must be 2-22 dBm"));case"sf":return Ue("spreading_factor",jt(t,5,12,"SF must be 5-12"));case"af":case"airtime.factor":return{result:`Error: airtime_factor is not yet exposed by the pyMC_Repeater API. Firmware range: 0-9. Tracked in CLI-Alignment.md — needs backend support.`,type:"info"};case"txdelay":return Ue("tx_delay_factor",hi(t,0,5,"TX delay must be 0.0-5.0"));case"direct.txdelay":return Ue("direct_tx_delay_factor",hi(t,0,5,"Direct TX delay must be 0.0-5.0"));case"rxdelay":return Ue("rx_delay_base",s_(t,0,"RX delay must be >= 0"));case"flood.max":return Ue("max_flood_hops",jt(t,0,64,"Max flood hops must be 0-64"));case"log":return i_(t);case"multi.acks":return Ue("multi_acks",jt(t,0,255,"Multi-acks must be 0-255"));case"int.thresh":return Ue("interference_threshold",jt(t,-200,0,"Interference threshold must be -200 to 0 dBm"));case"agc.reset.interval":{const s=$s(t);if(!s.ok)return de(s.error);if(s.value<0)return de("AGC reset interval must be >= 0");const r=Math.floor(s.value/4)*4;return Ts("agc_reset_interval",r,`OK - AGC reset interval set to ${r}${r!==s.value?` (rounded from ${s.value})`:""}`)}case"name":{const s=i.trim().substring(i.toLowerCase().indexOf("name")+5).trim();return s?/[\[\]\\/\\:,?*]/.test(s)?de("Name contains invalid characters: [ ] \\ / : , ? * are not allowed"):Ue("node_name",{ok:!0,value:s}):de("Node name cannot be empty")}case"lat":return Ue("latitude",hi(t,-90,90,"Latitude must be -90 to 90"));case"lon":return Ue("longitude",hi(t,-180,180,"Longitude must be -180 to 180"));case"freq":{const s=hi(t,100,1e3,"Frequency must be 100-1000 MHz");return s.ok?Ue("frequency",{ok:!0,value:s.value*1e6}):de(s.error)}case"bw":{const s=[7.8,10.4,15.6,20.8,31.25,41.7,62.5,125,250,500],r=parseFloat(t);return isNaN(r)||!s.includes(r)?de(`BW must be one of: ${s.join(", ")} kHz`):Ue("bandwidth",{ok:!0,value:r*1e3})}case"cr":return Ue("coding_rate",jt(t,5,8,"Coding rate must be 5-8"));case"advert.interval":{const s=$s(t);return s.ok?s.value!==0&&(s.value<1||s.value>10080)?de("Advert interval must be 0 (off) or 1-10080 minutes"):Ts("advert_interval_minutes",s.value,s.value===0?"OK - Local adverts disabled":`OK - Local advert interval set to ${s.value}m`):de(s.error)}case"flood.advert.interval":{const s=$s(t);return s.ok?s.value!==0&&(s.value<3||s.value>168)?de("Flood advert interval must be 0 (off) or 3-168 hours"):Ts("flood_advert_interval_hours",s.value,s.value===0?"OK - Flood adverts disabled":`OK - Flood advert interval set to ${s.value}h`):de(s.error)}case"prv.key":{const s=t.trim();return s?/^[0-9a-fA-F]+$/.test(s)?s.length!==128?de(`Key must be 64 bytes (128 hex chars), got ${s.length} chars`):{result:`To set this key, run on the Pi: @@ -99,21 +99,21 @@ Then restart: sudo systemctl restart pymc-repeater`,type:"info"}:de("Private key ⚠ Service restart required for changes to take effect Run: sudo systemctl restart pymc_repeater`),Li(s)}async function Ts(e,t,i){const s=await xo({[e]:t});if(!s.success)return de(s.error||"Failed");let r=i;return s.restart_required&&(r+=` ⚠ Service restart required for changes to take effect -Run: sudo systemctl restart pymc_repeater`),Li(r)}function jt(e,t,i,s){const r=parseInt(e);return isNaN(r)||ri?{ok:!1,error:`Error: ${s}`}:{ok:!0,value:r}}function hi(e,t,i,s){const r=parseFloat(e);return isNaN(r)||ri?{ok:!1,error:`Error: ${s}`}:{ok:!0,value:r}}function s_(e,t,i){const s=parseFloat(e);return isNaN(s)||s0?`${i}${"█".repeat(t)}${Q}`:"")+b("·".repeat(5-t))}const ao=3.5;class o_ extends ee{constructor(){super(...arguments);D(this,"name","ping");D(this,"description","Ping neighbor (name or 0xXX)");D(this,"params","{target} [timeout]")}async execute({output:i,rawInput:s}){var u,f,_,p;const r=this.argsAfterName(s).trim(),n=r.split(/\s+/);if(((u=n[0])==null?void 0:u.toLowerCase())==="help"){i.write([W("ping"),` ${b("Send a ping to a neighbor and measure round-trip time, signal quality, and path.")}`,"",R("ping ","ping by node name"),R("ping 0xAB","ping by hex prefix"),R("ping 60","ping with custom timeout (seconds)"),"",st("Default timeout: 30s. Signal bars factor radio config and noise floor.")].join(` -`));return}const o=n[n.length-1],a=parseInt(o),h=n.length>1&&!isNaN(a)&&a>0,l=h?n.slice(0,-1).join(" "):r,c=h?a:30;if(!l){i.write([W("ping"),` ${b("Send a ping to a neighbor and measure round-trip time.")}`,"",R("ping ","ping by node name"),R("ping 60","with custom timeout"),"",st('Run "ping help" for full usage.')].join(` -`));return}const d=Ta(i,l);try{const[g,E]=await Promise.all([ul(l,c),rt()]);if(d.stop(),g.success&&g.data){const z=g.data,O=(f=E.config)==null?void 0:f.radio,M=O!=null&&O.spreading_factor&&(O!=null&&O.bandwidth)?{sf:O.spreading_factor,bwHz:O.bandwidth}:null,$=E.noise_floor_dbm,K=$!=null&&$>-100?1:0,ae=z.rssi-ao,ne=wo(z.snr_db,ae,M,K),J=(ne==null?void 0:ne.finalGrade)??"critical",Fe=n_(J),Y=(_=z.path)!=null&&_.length?z.path.length:0,N=(p=z.path)!=null&&p.length?z.path.join(" > "):"direct",S=J.charAt(0).toUpperCase()+J.slice(1),L=[`${Fe} ${it("Reply from")} ${y(z.target_id)}`,"",` ${w("RTT",tu(z.rtt_ms))}`,` ${w("RSSI",`${z.rssi} dBm`)}`,` ${w("SNR",`${z.snr_db} dB`)}`,` ${w("Path",N)}${Y>0?b(` (${Y} hop${Y!==1?"s":""})`):""}`,` ${w("Quality",iu(S,J))}`],x=[];M&&x.push(`SF${M.sf}/${M.bwHz>=1e3?M.bwHz/1e3+"kHz":M.bwHz+"Hz"}`),x.push(`ant ${ao}dBi`),$!=null&&x.push(`nf ${$}dBm`),L.push("",b(x.join(" "))),i.update(d.id,L.join(` -`))}else i.update(d.id,g.error||"Ping failed","error")}catch(g){d.stop(),i.update(d.id,`Error: ${g instanceof Error?g.message:"Ping failed"}`,"error")}}}class a_ extends ee{constructor(){super(...arguments);D(this,"name","convert");D(this,"description","Convert between hex and base64");D(this,"params","hex|base64 {value}")}execute({output:i,args:s}){var o;const r=(o=s[1])==null?void 0:o.toLowerCase(),n=s.slice(2).join(" ").trim();if(r==="help"||!r&&!n){i.write([W("convert"),` ${b("Convert between hex and base64 encodings.")}`,"",R("convert hex ","hex → base64"),R("convert base64 ","base64 → hex"),"",st("Example: convert hex 48656C6C6F")].join(` -`));return}r==="hex"?this.hexToBase64(i,n):r==="base64"?this.base64ToHex(i,n):i.write([W("convert"),` ${b("Convert between hex and base64 encodings.")}`,"",R("convert hex ","hex → base64"),R("convert base64 ","base64 → hex")].join(` -`))}hexToBase64(i,s){if(!s){i.write("Usage: convert hex ","error");return}if(!/^[0-9a-fA-F]+$/.test(s)){i.write("Error: Input must be a hex string","error");return}if(s.length%2!==0){i.write("Error: Hex string must have even length","error");return}try{const r=new Uint8Array(s.length/2);for(let h=0;h","error");return}try{const r=typeof globalThis.atob=="function"?globalThis.atob(s):Buffer.from(s,"base64").toString("binary");let n="";for(let o=0;o({isCapturing:!1,captureStartTime:null,captureStartPacketHashes:new Set,captureTimer:null,reports:[],startCapture:i=>{const{captureTimer:s}=t();s&&clearTimeout(s),e({isCapturing:!0,captureStartTime:new Date,captureStartPacketHashes:new Set(i.map(r=>r.packet_hash))})},stopCapture:i=>{const{isCapturing:s,captureStartTime:r,captureStartPacketHashes:n,captureTimer:o}=t();if(!s||!r)return null;o&&clearTimeout(o);const a=new Date,h=Math.round((a.getTime()-r.getTime())/1e3),l=r.getTime()/1e3,c=i.filter(u=>!n.has(u.packet_hash)&&u.timestamp>=l).sort((u,f)=>u.timestamp-f.timestamp),d={id:c_(),filename:d_(r,h),startTime:r,endTime:a,durationSec:h,packetCount:c.length,packets:c,sizeBytes:c.length*h_};return e(u=>({isCapturing:!1,captureStartTime:null,captureStartPacketHashes:new Set,captureTimer:null,reports:[d,...u.reports].slice(0,l_)})),d},getReport:i=>t().reports.find(s=>s.id===i),_setTimer:i=>e({captureTimer:i})})),$a=()=>yt(e=>e.reports);function Se(e){var t;return((t=e.match(/.{1,2}/g))==null?void 0:t.join(" ").toUpperCase())||""}function Aa(e){return e===void 0?"UNKNOWN":Za[e]??`TYPE_${e}`}function Pa(e){return e===void 0?"UNKNOWN":Ja[e]??`ROUTE_${e}`}function u_(e){const t=[];let i=0;if(e.length>=32&&(t.push({name:"public_key",offset:i,length:32,bytes:Se(ge(e.slice(i,i+32))),decoded:{value:ge(e.slice(i,i+32))}}),i+=32),e.length>=i+4){const s=e.slice(i,i+4),r=s[0]|s[1]<<8|s[2]<<16|s[3]<<24;t.push({name:"timestamp",offset:i,length:4,bytes:Se(ge(s)),decoded:{value:r>>>0,iso:new Date(r*1e3).toISOString()}}),i+=4}if(e.length>=i+64&&(t.push({name:"signature",offset:i,length:64,bytes:Se(ge(e.slice(i,i+64))),decoded:{value:ge(e.slice(i,i+64))}}),i+=64),e.length>i){const s=e[i],r=[];if(s&1&&r.push("CHAT_NODE"),s&2&&r.push("REPEATER"),s&3&&r.push("ROOM_SERVER"),s&16&&r.push("HAS_LOCATION"),s&128&&r.push("HAS_NAME"),t.push({name:"flags",offset:i,length:1,bytes:Se(ge(e.slice(i,i+1))),decoded:{value:s,binary:s.toString(2).padStart(8,"0"),flags:r}}),i+=1,s&16&&e.length>=i+8){const n=e.slice(i,i+8),o=new ArrayBuffer(8);new Uint8Array(o).set(n);const a=new DataView(o),h=a.getInt32(0,!0),l=a.getInt32(4,!0);t.push({name:"location",offset:i,length:8,bytes:Se(ge(n)),decoded:{lat_raw:h,lon_raw:l,latitude:h/1e6,longitude:l/1e6}}),i+=8}if(s&128&&e.length>i){const n=e.slice(i);let o=n.indexOf(0);o===-1&&(o=n.length);const a=new TextDecoder().decode(n.slice(0,o));t.push({name:"name",offset:i,length:o+(n[o]===0?1:0),bytes:Se(ge(n.slice(0,o+1))),decoded:{value:a,encoding:"utf-8",null_terminated:n[o]===0}})}}return t}function __(e){if(e.length<4)return[];const t=e.slice(0,4),i=t[0]|t[1]<<8|t[2]<<16|t[3]<<24;return[{name:"crc",offset:0,length:4,bytes:Se(ge(t)),decoded:{value:i>>>0,hex:(i>>>0).toString(16).toUpperCase().padStart(8,"0"),note:"CRC of the acknowledged packet (little-endian)"}}]}function f_(e){const t=[];if(e.length<9)return t;const i=e.slice(0,4),s=i[0]|i[1]<<8|i[2]<<16|i[3]<<24;t.push({name:"trace_tag",offset:0,length:4,bytes:Se(ge(i)),decoded:{value:s>>>0,hex:(s>>>0).toString(16).toUpperCase().padStart(8,"0")}});const r=e.slice(4,8),n=r[0]|r[1]<<8|r[2]<<16|r[3]<<24;if(t.push({name:"auth_code",offset:4,length:4,bytes:Se(ge(r)),decoded:{value:n>>>0}}),t.push({name:"flags",offset:8,length:1,bytes:Se(ge(e.slice(8,9))),decoded:{value:e[8],binary:e[8].toString(2).padStart(8,"0")}}),e.length>9){const o=e.slice(9),a=Array.from(o).map(h=>h.toString(16).toUpperCase().padStart(2,"0"));t.push({name:"target_path",offset:9,length:o.length,bytes:Se(ge(o)),decoded:{hops:a,path_string:a.join("->")}})}return t}function p_(e){if(e.length===0)return[];const t=Array.from(e).map(i=>i.toString(16).toUpperCase().padStart(2,"0"));return[{name:"path_hops",offset:0,length:e.length,bytes:Se(ge(e)),decoded:{hops:t,path_string:t.join("->")}}]}function m_(e){const t=[];if(e.length<1)return t;if(t.push({name:"channel_hash",offset:0,length:1,bytes:Se(ge(e.slice(0,1))),decoded:{value:e[0].toString(16).toUpperCase().padStart(2,"0")}}),e.length>13){const s=e.length-1-12;t.push({name:"ciphertext",offset:1,length:s,bytes:Se(ge(e.slice(1,1+s))),decoded:{length:s,note:"Encrypted message content"}}),t.push({name:"mac",offset:1+s,length:12,bytes:Se(ge(e.slice(-12))),decoded:{note:"Message authentication code"}})}return t}function g_(e){return e.length===0?[]:[{name:"raw_data",offset:0,length:e.length,bytes:Se(ge(e)),decoded:{length:e.length}}]}function Na(e,t){switch(e){case 4:return u_(t);case 3:return __(t);case 9:return f_(t);case 8:return p_(t);case 5:return m_(t);default:return g_(t)}}function v_(e){const t=e.type??e.payload_type??0,i=e.route??e.route_type??0,s=e.raw_packet||"";let r,n=null;if(s){const o=_l.fromHex(s);if(o.success&&o.packet){const a=o.packet;try{n=fl(a)}catch{n=null}const h=Eo(s);let l=0;const c={offset:0,length:1,bytes:Se(s.slice(0,2)),decoded:{route_type:a.routeType,route_name:a.routeTypeName,payload_type:a.payloadType,payload_name:a.payloadTypeName,version:a.payloadVersion}};l+=1,a.hasTransportCodes()&&(l+=4);const u={offset:l,length:1,bytes:Se(ge(h.slice(l,l+1))),decoded:{value:a.pathLen}};l+=1;const f=l,_=h.slice(l,l+a.pathLen),p=Array.from(a.path).map(M=>M.toString(16).toUpperCase().padStart(2,"0")),g=a.payloadType===9,E={offset:f,length:a.pathLen,bytes:Se(ge(_)),decoded:{hops:p,path_string:p.length>0?p.join("->"):"(direct)",...g&&{note:"For TRACE packets, path bytes are SNR×4 values, not node hashes",snr_values:Array.from(a.path).map(M=>{let $=M;return $>127&&($-=256),$/4})}}};l+=a.pathLen;const O={offset:l,length:a.payload.length,bytes:Se(a.payloadHex),sections:Na(a.payloadType,a.payload)};r={header:c,path_length:u,path:E,payload:O}}else r=lo(e)}else r=lo(e);return{timestamp:e.timestamp,packet_hash:e.packet_hash,type:t,type_name:Aa(t),route:i,route_name:Pa(i),rssi:e.rssi,snr:e.snr,length:e.length??0,src_hash:e.src_hash,dst_hash:e.dst_hash,transmitted:e.transmitted,drop_reason:e.drop_reason,is_duplicate:e.is_duplicate,lbt_attempts:e.lbt_attempts,lbt_backoff_delays_ms:e.lbt_backoff_delays_ms,lbt_channel_busy:e.lbt_channel_busy,raw_packet:s,structure:r,decoded:n}}function lo(e){var r;const t=e.type??e.payload_type??0,i=e.route??e.route_type??0,s=e.original_path??e.forwarded_path??[];return{header:{offset:0,length:1,bytes:"??",decoded:{route_type:i,route_name:Pa(i),payload_type:t,payload_name:Aa(t),version:0}},path_length:{offset:1,length:1,bytes:s.length.toString(16).toUpperCase().padStart(2,"0"),decoded:{value:s.length}},path:{offset:2,length:s.length,bytes:s.join(" "),decoded:{hops:s,path_string:s.length>0?s.join("->"):"(direct)"}},payload:{offset:2+s.length,length:((r=e.payload)==null?void 0:r.length)??0,bytes:e.payload??"",sections:e.payload?Na(t,Eo(e.payload)):[]}}}function S_(e,t){var i;return{capture:{start:e.startTime.toISOString(),end:e.endTime.toISOString(),duration_sec:e.durationSec,packet_count:e.packetCount,node_name:(t==null?void 0:t.node_name)??"unknown",local_hash:(t==null?void 0:t.local_hash)??"unknown",pymc_console_version:Xa,pymc_repeater_version:(t==null?void 0:t.version)??"unknown",radio_config:(i=t==null?void 0:t.config)!=null&&i.radio?{frequency:t.config.radio.frequency,tx_power:t.config.radio.tx_power,bandwidth:t.config.radio.bandwidth,spreading_factor:t.config.radio.spreading_factor}:null},packets:e.packets.map(v_)}}function Ia(e,t){const i=S_(e,t),s=JSON.stringify(i,null,2),r=new Blob([s],{type:"application/json"}),n=URL.createObjectURL(r),o=document.createElement("a");o.href=n,o.download=e.filename,document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(n)}function Ji(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}class y_ extends ee{constructor(){super(...arguments);D(this,"name","cap");D(this,"description","Packet capture (start/end/list/export)")}matches(i){const s=i.toLowerCase().trim();return s==="cap"||s==="cap help"||s.startsWith("start cap")||s.startsWith("end cap")||s.startsWith("list cap")||s.startsWith("export cap")}async execute({output:i,rawInput:s}){const r=s.toLowerCase().trim();if(r==="cap"||r==="cap help")return this.showHelp(i);if(r.startsWith("start cap"))return this.startCapture(i,r);if(r==="end cap")return this.endCapture(i);if(r==="list cap")return this.listCaptures(i);if(r.startsWith("export cap"))return this.exportCapture(i,r);this.showHelp(i)}showHelp(i){const s=yt.getState(),r=s.isCapturing?` +Run: sudo systemctl restart pymc_repeater`),Li(r)}function jt(e,t,i,s){const r=parseInt(e);return isNaN(r)||ri?{ok:!1,error:`Error: ${s}`}:{ok:!0,value:r}}function hi(e,t,i,s){const r=parseFloat(e);return isNaN(r)||ri?{ok:!1,error:`Error: ${s}`}:{ok:!0,value:r}}function s_(e,t,i){const s=parseFloat(e);return isNaN(s)||s0?`${i}${"█".repeat(t)}${Q}`:"")+w("·".repeat(5-t))}const ao=3.5;class o_ extends ee{constructor(){super(...arguments);D(this,"name","ping");D(this,"description","Ping neighbor (name or 0xXX)");D(this,"params","{target} [timeout]")}async execute({output:i,rawInput:s}){var u,f,_,p;const r=this.argsAfterName(s).trim(),n=r.split(/\s+/);if(((u=n[0])==null?void 0:u.toLowerCase())==="help"){i.write([W("ping"),` ${w("Send a ping to a neighbor and measure round-trip time, signal quality, and path.")}`,"",R("ping ","ping by node name"),R("ping 0xAB","ping by hex prefix"),R("ping 60","ping with custom timeout (seconds)"),"",st("Default timeout: 30s. Signal bars factor radio config and noise floor.")].join(` +`));return}const o=n[n.length-1],a=parseInt(o),h=n.length>1&&!isNaN(a)&&a>0,l=h?n.slice(0,-1).join(" "):r,c=h?a:30;if(!l){i.write([W("ping"),` ${w("Send a ping to a neighbor and measure round-trip time.")}`,"",R("ping ","ping by node name"),R("ping 60","with custom timeout"),"",st('Run "ping help" for full usage.')].join(` +`));return}const d=Ta(i,l);try{const[g,E]=await Promise.all([ul(l,c),rt()]);if(d.stop(),g.success&&g.data){const z=g.data,O=(f=E.config)==null?void 0:f.radio,M=O!=null&&O.spreading_factor&&(O!=null&&O.bandwidth)?{sf:O.spreading_factor,bwHz:O.bandwidth}:null,$=E.noise_floor_dbm,K=$!=null&&$>-100?1:0,ae=z.rssi-ao,ne=bo(z.snr_db,ae,M,K),J=(ne==null?void 0:ne.finalGrade)??"critical",He=n_(J),Y=(_=z.path)!=null&&_.length?z.path.length:0,N=(p=z.path)!=null&&p.length?z.path.join(" > "):"direct",S=J.charAt(0).toUpperCase()+J.slice(1),L=[`${He} ${it("Reply from")} ${y(z.target_id)}`,"",` ${b("RTT",tu(z.rtt_ms))}`,` ${b("RSSI",`${z.rssi} dBm`)}`,` ${b("SNR",`${z.snr_db} dB`)}`,` ${b("Path",N)}${Y>0?w(` (${Y} hop${Y!==1?"s":""})`):""}`,` ${b("Quality",iu(S,J))}`],x=[];M&&x.push(`SF${M.sf}/${M.bwHz>=1e3?M.bwHz/1e3+"kHz":M.bwHz+"Hz"}`),x.push(`ant ${ao}dBi`),$!=null&&x.push(`nf ${$}dBm`),L.push("",w(x.join(" "))),i.update(d.id,L.join(` +`))}else i.update(d.id,g.error||"Ping failed","error")}catch(g){d.stop(),i.update(d.id,`Error: ${g instanceof Error?g.message:"Ping failed"}`,"error")}}}class a_ extends ee{constructor(){super(...arguments);D(this,"name","convert");D(this,"description","Convert between hex and base64");D(this,"params","hex|base64 {value}")}execute({output:i,args:s}){var o;const r=(o=s[1])==null?void 0:o.toLowerCase(),n=s.slice(2).join(" ").trim();if(r==="help"||!r&&!n){i.write([W("convert"),` ${w("Convert between hex and base64 encodings.")}`,"",R("convert hex ","hex → base64"),R("convert base64 ","base64 → hex"),"",st("Example: convert hex 48656C6C6F")].join(` +`));return}r==="hex"?this.hexToBase64(i,n):r==="base64"?this.base64ToHex(i,n):i.write([W("convert"),` ${w("Convert between hex and base64 encodings.")}`,"",R("convert hex ","hex → base64"),R("convert base64 ","base64 → hex")].join(` +`))}hexToBase64(i,s){if(!s){i.write("Usage: convert hex ","error");return}if(!/^[0-9a-fA-F]+$/.test(s)){i.write("Error: Input must be a hex string","error");return}if(s.length%2!==0){i.write("Error: Hex string must have even length","error");return}try{const r=new Uint8Array(s.length/2);for(let h=0;h","error");return}try{const r=typeof globalThis.atob=="function"?globalThis.atob(s):Buffer.from(s,"base64").toString("binary");let n="";for(let o=0;o({isCapturing:!1,captureStartTime:null,captureStartPacketHashes:new Set,captureTimer:null,reports:[],startCapture:i=>{const{captureTimer:s}=t();s&&clearTimeout(s),e({isCapturing:!0,captureStartTime:new Date,captureStartPacketHashes:new Set(i.map(r=>r.packet_hash))})},stopCapture:i=>{const{isCapturing:s,captureStartTime:r,captureStartPacketHashes:n,captureTimer:o}=t();if(!s||!r)return null;o&&clearTimeout(o);const a=new Date,h=Math.round((a.getTime()-r.getTime())/1e3),l=r.getTime()/1e3,c=i.filter(u=>!n.has(u.packet_hash)&&u.timestamp>=l).sort((u,f)=>u.timestamp-f.timestamp),d={id:c_(),filename:d_(r,h),startTime:r,endTime:a,durationSec:h,packetCount:c.length,packets:c,sizeBytes:c.length*h_};return e(u=>({isCapturing:!1,captureStartTime:null,captureStartPacketHashes:new Set,captureTimer:null,reports:[d,...u.reports].slice(0,l_)})),d},getReport:i=>t().reports.find(s=>s.id===i),_setTimer:i=>e({captureTimer:i})})),$a=()=>yt(e=>e.reports);function Se(e){var t;return((t=e.match(/.{1,2}/g))==null?void 0:t.join(" ").toUpperCase())||""}function Aa(e){return e===void 0?"UNKNOWN":Za[e]??`TYPE_${e}`}function Pa(e){return e===void 0?"UNKNOWN":Ja[e]??`ROUTE_${e}`}function u_(e){const t=[];let i=0;if(e.length>=32&&(t.push({name:"public_key",offset:i,length:32,bytes:Se(ge(e.slice(i,i+32))),decoded:{value:ge(e.slice(i,i+32))}}),i+=32),e.length>=i+4){const s=e.slice(i,i+4),r=s[0]|s[1]<<8|s[2]<<16|s[3]<<24;t.push({name:"timestamp",offset:i,length:4,bytes:Se(ge(s)),decoded:{value:r>>>0,iso:new Date(r*1e3).toISOString()}}),i+=4}if(e.length>=i+64&&(t.push({name:"signature",offset:i,length:64,bytes:Se(ge(e.slice(i,i+64))),decoded:{value:ge(e.slice(i,i+64))}}),i+=64),e.length>i){const s=e[i],r=[];if(s&1&&r.push("CHAT_NODE"),s&2&&r.push("REPEATER"),s&3&&r.push("ROOM_SERVER"),s&16&&r.push("HAS_LOCATION"),s&128&&r.push("HAS_NAME"),t.push({name:"flags",offset:i,length:1,bytes:Se(ge(e.slice(i,i+1))),decoded:{value:s,binary:s.toString(2).padStart(8,"0"),flags:r}}),i+=1,s&16&&e.length>=i+8){const n=e.slice(i,i+8),o=new ArrayBuffer(8);new Uint8Array(o).set(n);const a=new DataView(o),h=a.getInt32(0,!0),l=a.getInt32(4,!0);t.push({name:"location",offset:i,length:8,bytes:Se(ge(n)),decoded:{lat_raw:h,lon_raw:l,latitude:h/1e6,longitude:l/1e6}}),i+=8}if(s&128&&e.length>i){const n=e.slice(i);let o=n.indexOf(0);o===-1&&(o=n.length);const a=new TextDecoder().decode(n.slice(0,o));t.push({name:"name",offset:i,length:o+(n[o]===0?1:0),bytes:Se(ge(n.slice(0,o+1))),decoded:{value:a,encoding:"utf-8",null_terminated:n[o]===0}})}}return t}function __(e){if(e.length<4)return[];const t=e.slice(0,4),i=t[0]|t[1]<<8|t[2]<<16|t[3]<<24;return[{name:"crc",offset:0,length:4,bytes:Se(ge(t)),decoded:{value:i>>>0,hex:(i>>>0).toString(16).toUpperCase().padStart(8,"0"),note:"CRC of the acknowledged packet (little-endian)"}}]}function f_(e){const t=[];if(e.length<9)return t;const i=e.slice(0,4),s=i[0]|i[1]<<8|i[2]<<16|i[3]<<24;t.push({name:"trace_tag",offset:0,length:4,bytes:Se(ge(i)),decoded:{value:s>>>0,hex:(s>>>0).toString(16).toUpperCase().padStart(8,"0")}});const r=e.slice(4,8),n=r[0]|r[1]<<8|r[2]<<16|r[3]<<24;if(t.push({name:"auth_code",offset:4,length:4,bytes:Se(ge(r)),decoded:{value:n>>>0}}),t.push({name:"flags",offset:8,length:1,bytes:Se(ge(e.slice(8,9))),decoded:{value:e[8],binary:e[8].toString(2).padStart(8,"0")}}),e.length>9){const o=e.slice(9),a=Array.from(o).map(h=>h.toString(16).toUpperCase().padStart(2,"0"));t.push({name:"target_path",offset:9,length:o.length,bytes:Se(ge(o)),decoded:{hops:a,path_string:a.join("->")}})}return t}function p_(e){if(e.length===0)return[];const t=Array.from(e).map(i=>i.toString(16).toUpperCase().padStart(2,"0"));return[{name:"path_hops",offset:0,length:e.length,bytes:Se(ge(e)),decoded:{hops:t,path_string:t.join("->")}}]}function m_(e){const t=[];if(e.length<1)return t;if(t.push({name:"channel_hash",offset:0,length:1,bytes:Se(ge(e.slice(0,1))),decoded:{value:e[0].toString(16).toUpperCase().padStart(2,"0")}}),e.length>13){const s=e.length-1-12;t.push({name:"ciphertext",offset:1,length:s,bytes:Se(ge(e.slice(1,1+s))),decoded:{length:s,note:"Encrypted message content"}}),t.push({name:"mac",offset:1+s,length:12,bytes:Se(ge(e.slice(-12))),decoded:{note:"Message authentication code"}})}return t}function g_(e){return e.length===0?[]:[{name:"raw_data",offset:0,length:e.length,bytes:Se(ge(e)),decoded:{length:e.length}}]}function Na(e,t){switch(e){case 4:return u_(t);case 3:return __(t);case 9:return f_(t);case 8:return p_(t);case 5:return m_(t);default:return g_(t)}}function v_(e){const t=e.type??e.payload_type??0,i=e.route??e.route_type??0,s=e.raw_packet||"";let r,n=null;if(s){const o=_l.fromHex(s);if(o.success&&o.packet){const a=o.packet;try{n=fl(a)}catch{n=null}const h=Eo(s);let l=0;const c={offset:0,length:1,bytes:Se(s.slice(0,2)),decoded:{route_type:a.routeType,route_name:a.routeTypeName,payload_type:a.payloadType,payload_name:a.payloadTypeName,version:a.payloadVersion}};l+=1,a.hasTransportCodes()&&(l+=4);const u={offset:l,length:1,bytes:Se(ge(h.slice(l,l+1))),decoded:{value:a.pathLen}};l+=1;const f=l,_=h.slice(l,l+a.pathLen),p=Array.from(a.path).map(M=>M.toString(16).toUpperCase().padStart(2,"0")),g=a.payloadType===9,E={offset:f,length:a.pathLen,bytes:Se(ge(_)),decoded:{hops:p,path_string:p.length>0?p.join("->"):"(direct)",...g&&{note:"For TRACE packets, path bytes are SNR×4 values, not node hashes",snr_values:Array.from(a.path).map(M=>{let $=M;return $>127&&($-=256),$/4})}}};l+=a.pathLen;const O={offset:l,length:a.payload.length,bytes:Se(a.payloadHex),sections:Na(a.payloadType,a.payload)};r={header:c,path_length:u,path:E,payload:O}}else r=lo(e)}else r=lo(e);return{timestamp:e.timestamp,packet_hash:e.packet_hash,type:t,type_name:Aa(t),route:i,route_name:Pa(i),rssi:e.rssi,snr:e.snr,length:e.length??0,src_hash:e.src_hash,dst_hash:e.dst_hash,transmitted:e.transmitted,drop_reason:e.drop_reason,is_duplicate:e.is_duplicate,lbt_attempts:e.lbt_attempts,lbt_backoff_delays_ms:e.lbt_backoff_delays_ms,lbt_channel_busy:e.lbt_channel_busy,raw_packet:s,structure:r,decoded:n}}function lo(e){var r;const t=e.type??e.payload_type??0,i=e.route??e.route_type??0,s=e.original_path??e.forwarded_path??[];return{header:{offset:0,length:1,bytes:"??",decoded:{route_type:i,route_name:Pa(i),payload_type:t,payload_name:Aa(t),version:0}},path_length:{offset:1,length:1,bytes:s.length.toString(16).toUpperCase().padStart(2,"0"),decoded:{value:s.length}},path:{offset:2,length:s.length,bytes:s.join(" "),decoded:{hops:s,path_string:s.length>0?s.join("->"):"(direct)"}},payload:{offset:2+s.length,length:((r=e.payload)==null?void 0:r.length)??0,bytes:e.payload??"",sections:e.payload?Na(t,Eo(e.payload)):[]}}}function S_(e,t){var i;return{capture:{start:e.startTime.toISOString(),end:e.endTime.toISOString(),duration_sec:e.durationSec,packet_count:e.packetCount,node_name:(t==null?void 0:t.node_name)??"unknown",local_hash:(t==null?void 0:t.local_hash)??"unknown",pymc_console_version:Xa,pymc_repeater_version:(t==null?void 0:t.version)??"unknown",radio_config:(i=t==null?void 0:t.config)!=null&&i.radio?{frequency:t.config.radio.frequency,tx_power:t.config.radio.tx_power,bandwidth:t.config.radio.bandwidth,spreading_factor:t.config.radio.spreading_factor}:null},packets:e.packets.map(v_)}}function Ia(e,t){const i=S_(e,t),s=JSON.stringify(i,null,2),r=new Blob([s],{type:"application/json"}),n=URL.createObjectURL(r),o=document.createElement("a");o.href=n,o.download=e.filename,document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(n)}function Ji(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}class y_ extends ee{constructor(){super(...arguments);D(this,"name","cap");D(this,"description","Packet capture (start/end/list/export)")}matches(i){const s=i.toLowerCase().trim();return s==="cap"||s==="cap help"||s.startsWith("start cap")||s.startsWith("end cap")||s.startsWith("list cap")||s.startsWith("export cap")}async execute({output:i,rawInput:s}){const r=s.toLowerCase().trim();if(r==="cap"||r==="cap help")return this.showHelp(i);if(r.startsWith("start cap"))return this.startCapture(i,r);if(r==="end cap")return this.endCapture(i);if(r==="list cap")return this.listCaptures(i);if(r.startsWith("export cap"))return this.exportCapture(i,r);this.showHelp(i)}showHelp(i){const s=yt.getState(),r=s.isCapturing?` ${Rs('Recording in progress... use "end cap" to stop')}`:"",n=s.reports.length,o=n>0?` (${n} saved)`:"",a=[W("Packet Capture"),"",R("start cap","Start capture (default: 120s)"),R("end cap","Stop capture early"),R("list cap",`List saved captures${o}`),R("export cap","Download capture by ID"),"",st("Captures stored in session memory. JSON includes decoded payloads."),r].filter(Boolean);i.write(a.join(` -`))}startCapture(i,s){const r=s.slice(9).trim(),n=r?parseInt(r):120;if(isNaN(n)||n<1||n>3600){i.write("Error: Duration must be 1-3600 seconds","error");return}const o=yt.getState();if(o.isCapturing){i.write('Error: Capture already in progress. Use "end cap" first.',"error");return}const a=wt.getState().packets;o.startCapture(a);let h=n;const l=i.write(Rs(`Capturing... ${h}s remaining`),"system"),c=setInterval(()=>{h--;const u=yt.getState();if(h>=0&&u.isCapturing){const _=wt.getState().packets.filter(g=>{if(!u.captureStartTime)return!1;const E=u.captureStartTime.getTime()/1e3;return g.timestamp>=E&&!u.captureStartPacketHashes.has(g.packet_hash)}).length,p=h>0?`${h}s remaining`:"finishing...";i.update(l,Rs(`Capturing... ${p} (${_} captured)`),"system")}},1e3),d=setTimeout(()=>{clearInterval(c);const u=yt.getState();if(u.isCapturing){const f=wt.getState().packets,_=u.stopCapture(f);_?i.write(`✓ Capture complete! +`))}startCapture(i,s){const r=s.slice(9).trim(),n=r?parseInt(r):120;if(isNaN(n)||n<1||n>3600){i.write("Error: Duration must be 1-3600 seconds","error");return}const o=yt.getState();if(o.isCapturing){i.write('Error: Capture already in progress. Use "end cap" first.',"error");return}const a=bt.getState().packets;o.startCapture(a);let h=n;const l=i.write(Rs(`Capturing... ${h}s remaining`),"system"),c=setInterval(()=>{h--;const u=yt.getState();if(h>=0&&u.isCapturing){const _=bt.getState().packets.filter(g=>{if(!u.captureStartTime)return!1;const E=u.captureStartTime.getTime()/1e3;return g.timestamp>=E&&!u.captureStartPacketHashes.has(g.packet_hash)}).length,p=h>0?`${h}s remaining`:"finishing...";i.update(l,Rs(`Capturing... ${p} (${_} captured)`),"system")}},1e3),d=setTimeout(()=>{clearInterval(c);const u=yt.getState();if(u.isCapturing){const f=bt.getState().packets,_=u.stopCapture(f);_?i.write(`✓ Capture complete! Captured: ${_.packetCount} packets Duration: ${_.durationSec}s Size: ~${Ji(_.sizeBytes)} -Run \`export cap ${_.id}\` to download.`,"value"):i.write("Capture completed with no packets.","warning")}},n*1e3);o._setTimer(d)}endCapture(i){const s=yt.getState();if(!s.isCapturing){i.write("No capture in progress.","warning");return}const r=wt.getState().packets,n=s.stopCapture(r);n?i.write(`✓ Capture stopped! +Run \`export cap ${_.id}\` to download.`,"value"):i.write("Capture completed with no packets.","warning")}},n*1e3);o._setTimer(d)}endCapture(i){const s=yt.getState();if(!s.isCapturing){i.write("No capture in progress.","warning");return}const r=bt.getState().packets,n=s.stopCapture(r);n?i.write(`✓ Capture stopped! Captured: ${n.packetCount} packets Duration: ${n.durationSec}s Size: ~${Ji(n.sizeBytes)} @@ -121,42 +121,42 @@ Run \`export cap ${_.id}\` to download.`,"value"):i.write("Capture completed wit Run \`export cap ${n.id}\` to download.`,"value"):i.write("Capture stopped with no packets.","warning")}listCaptures(i){const{reports:s}=yt.getState();if(s.length===0){i.write(`No capture reports available. Start a capture with: start cap [seconds]`,"info");return}const r=s.map((n,o)=>` ${o+1}. ${n.packetCount} pkts • ${n.durationSec}s • ~${Ji(n.sizeBytes)} (id: ${n.id})`);i.write(`Capture Reports (${s.length}): ${r.join(` -`)}`,"info")}exportCapture(i,s){const r=s.slice(10).trim(),n=yt.getState(),o=wt.getState().stats;if(!r){if(n.reports.length===0)i.write(`No capture reports available. +`)}`,"info")}exportCapture(i,s){const r=s.slice(10).trim(),n=yt.getState(),o=bt.getState().stats;if(!r){if(n.reports.length===0)i.write(`No capture reports available. Start a capture with: start cap [seconds]`,"info");else{const h=n.reports.map((l,c)=>` ${c+1}. ${l.id}`);i.write(`Usage: export cap Available reports: ${h.join(` `)}`,"info")}return}let a=n.getReport(r);if(!a){const h=parseInt(r)-1;a=n.reports[h]}if(!a){i.write(`Error: Report "${r}" not found. -Use "list cap" to see available reports.`,"error");return}Ia(a,o),i.write(`✓ Downloading ${a.filename}...`,"value")}}class b_ extends ee{constructor(){super(...arguments);D(this,"name","identities");D(this,"description","List configured identities");D(this,"aliases",["id","ids"])}async execute({output:i,rawInput:s}){var n;if(this.argsAfterName(s).toLowerCase().trim()==="help"){i.write([W("identities"),` ${b("List all configured repeater and room server identities.")}`,"",R("identities","list identities"),"",W("Aliases"),` ${b("id, ids")}`].join(` -`));return}const r=i.write("processing...","system");try{const o=await Qa();if(!o.success||!o.data){i.update(r,o.error||"Failed to fetch identities","error");return}const a=o.data,h=(n=a.configured)!=null&&n.length?a.configured:a.registered||[];if(h.length===0){i.update(r,"No identities configured.","warning");return}const l=[W(`Identities (${h.length})`),"",...h.map((c,d)=>{var p;const u=c.name||"Unnamed",f=c.type||"unknown",_=((p=c.hash)==null?void 0:p.slice(0,8))||"—";return` ${b(`${d+1}.`)} ${it(u)} ${Ae(f)} ${y(_)}`})];i.update(r,l.join(` -`))}catch(o){i.update(r,`Error: ${o instanceof Error?o.message:"Command failed"}`,"error")}}}class w_ extends ee{constructor(){super(...arguments);D(this,"name","keys");D(this,"description","List transport keys")}async execute({output:i,rawInput:s}){if(this.argsAfterName(s).toLowerCase().trim()==="help"){i.write([W("keys"),` ${b("List configured transport encryption keys.")}`,"",R("keys","list transport keys")].join(` -`));return}const r=i.write("processing...","system");try{const n=await pl();if(!n.success||!n.data){i.update(r,n.error||"Failed to fetch transport keys","error");return}const o=n.data;if(o.length===0){i.update(r,"No transport keys configured.","warning");return}const a=[W(`Transport Keys (${o.length})`),"",...o.map(h=>{const l=h.parent_id?` ${Ae(`parent: ${h.parent_id}`)}`:"";return` ${it(h.name)} ${w("flood",y(h.flood_policy))}${l}`})];i.update(r,a.join(` -`))}catch(n){i.update(r,`Error: ${n instanceof Error?n.message:"Command failed"}`,"error")}}}class C_ extends ee{constructor(){super(...arguments);D(this,"name","acl");D(this,"description","Show ACL statistics")}async execute({output:i,rawInput:s}){if(this.argsAfterName(s).toLowerCase().trim()==="help"){i.write([W("acl"),` ${b("Display access control list statistics.")}`,"",R("acl","show ACL stats")].join(` -`));return}const r=i.write("processing...","system");try{const n=await el();if(!n.success||!n.data){i.update(r,n.error||"Failed to fetch ACL stats","error");return}const o=n.data,a=[W("ACL Stats"),"",` ${w("Identities",y(String(o.total_identities)))}`,` ${w("Total clients",y(String(o.total_clients)))}`,` ${w("Admin",y(String(o.admin_clients)))}`,` ${w("Guest",y(String(o.guest_clients)))}`];if(o.by_identity_type){const h=o.by_identity_type.repeater,l=o.by_identity_type.room_server;h&&a.push(` ${w("Repeater",`${y(String(h.count))} ids ${b(`${h.clients} clients`)}`)}`),l&&a.push(` ${w("Room Server",`${y(String(l.count))} ids ${b(`${l.clients} clients`)}`)}`)}i.update(r,a.join(` -`))}catch(n){i.update(r,`Error: ${n instanceof Error?n.message:"Command failed"}`,"error")}}}class x_ extends ee{constructor(){super(...arguments);D(this,"name","rooms");D(this,"description","Show room server statistics")}async execute({output:i,rawInput:s}){if(this.argsAfterName(s).toLowerCase().trim()==="help"){i.write([W("rooms"),` ${b("Display room server statistics and sync status.")}`,"",R("rooms","list rooms")].join(` -`));return}const r=i.write("processing...","system");try{const n=await tl();if(!n.success||!n.data){i.update(r,n.error||"Failed to fetch room stats","error");return}const o=n.data.rooms||[];if(o.length===0){i.update(r,"No room servers configured.","warning");return}const a=[W(`Rooms (${o.length})`),"",...o.map(h=>[` ${it(h.room_name)}`,` ${w("msgs",y(String(h.total_messages)))} ${w("clients",`${y(String(h.active_clients))}${Ae(`/${h.total_clients}`)}`)} ${w("sync",h.sync_running?y("running"):Ae("idle"))}`]).flat()];i.update(r,a.join(` -`))}catch(n){i.update(r,`Error: ${n instanceof Error?n.message:"Command failed"}`,"error")}}}class k_ extends ee{constructor(){super(...arguments);D(this,"name","restart");D(this,"description","Restart pymc-repeater service");D(this,"aliases",["reboot"])}async execute({output:i,rawInput:s}){if(this.argsAfterName(s).toLowerCase().trim()==="help"){i.write([W("restart"),` ${b("Restart the pymc-repeater systemd service.")}`,"",R("restart","restart the service"),"",W("Aliases"),` ${b("reboot")}`,"",st("Requires polkit permissions for the web user."),st("The page will need a manual refresh after restart.")].join(` +Use "list cap" to see available reports.`,"error");return}Ia(a,o),i.write(`✓ Downloading ${a.filename}...`,"value")}}class w_ extends ee{constructor(){super(...arguments);D(this,"name","identities");D(this,"description","List configured identities");D(this,"aliases",["id","ids"])}async execute({output:i,rawInput:s}){var n;if(this.argsAfterName(s).toLowerCase().trim()==="help"){i.write([W("identities"),` ${w("List all configured repeater and room server identities.")}`,"",R("identities","list identities"),"",W("Aliases"),` ${w("id, ids")}`].join(` +`));return}const r=i.write("processing...","system");try{const o=await Qa();if(!o.success||!o.data){i.update(r,o.error||"Failed to fetch identities","error");return}const a=o.data,h=(n=a.configured)!=null&&n.length?a.configured:a.registered||[];if(h.length===0){i.update(r,"No identities configured.","warning");return}const l=[W(`Identities (${h.length})`),"",...h.map((c,d)=>{var p;const u=c.name||"Unnamed",f=c.type||"unknown",_=((p=c.hash)==null?void 0:p.slice(0,8))||"—";return` ${w(`${d+1}.`)} ${it(u)} ${Ae(f)} ${y(_)}`})];i.update(r,l.join(` +`))}catch(o){i.update(r,`Error: ${o instanceof Error?o.message:"Command failed"}`,"error")}}}class b_ extends ee{constructor(){super(...arguments);D(this,"name","keys");D(this,"description","List transport keys")}async execute({output:i,rawInput:s}){if(this.argsAfterName(s).toLowerCase().trim()==="help"){i.write([W("keys"),` ${w("List configured transport encryption keys.")}`,"",R("keys","list transport keys")].join(` +`));return}const r=i.write("processing...","system");try{const n=await pl();if(!n.success||!n.data){i.update(r,n.error||"Failed to fetch transport keys","error");return}const o=n.data;if(o.length===0){i.update(r,"No transport keys configured.","warning");return}const a=[W(`Transport Keys (${o.length})`),"",...o.map(h=>{const l=h.parent_id?` ${Ae(`parent: ${h.parent_id}`)}`:"";return` ${it(h.name)} ${b("flood",y(h.flood_policy))}${l}`})];i.update(r,a.join(` +`))}catch(n){i.update(r,`Error: ${n instanceof Error?n.message:"Command failed"}`,"error")}}}class C_ extends ee{constructor(){super(...arguments);D(this,"name","acl");D(this,"description","Show ACL statistics")}async execute({output:i,rawInput:s}){if(this.argsAfterName(s).toLowerCase().trim()==="help"){i.write([W("acl"),` ${w("Display access control list statistics.")}`,"",R("acl","show ACL stats")].join(` +`));return}const r=i.write("processing...","system");try{const n=await el();if(!n.success||!n.data){i.update(r,n.error||"Failed to fetch ACL stats","error");return}const o=n.data,a=[W("ACL Stats"),"",` ${b("Identities",y(String(o.total_identities)))}`,` ${b("Total clients",y(String(o.total_clients)))}`,` ${b("Admin",y(String(o.admin_clients)))}`,` ${b("Guest",y(String(o.guest_clients)))}`];if(o.by_identity_type){const h=o.by_identity_type.repeater,l=o.by_identity_type.room_server;h&&a.push(` ${b("Repeater",`${y(String(h.count))} ids ${w(`${h.clients} clients`)}`)}`),l&&a.push(` ${b("Room Server",`${y(String(l.count))} ids ${w(`${l.clients} clients`)}`)}`)}i.update(r,a.join(` +`))}catch(n){i.update(r,`Error: ${n instanceof Error?n.message:"Command failed"}`,"error")}}}class x_ extends ee{constructor(){super(...arguments);D(this,"name","rooms");D(this,"description","Show room server statistics")}async execute({output:i,rawInput:s}){if(this.argsAfterName(s).toLowerCase().trim()==="help"){i.write([W("rooms"),` ${w("Display room server statistics and sync status.")}`,"",R("rooms","list rooms")].join(` +`));return}const r=i.write("processing...","system");try{const n=await tl();if(!n.success||!n.data){i.update(r,n.error||"Failed to fetch room stats","error");return}const o=n.data.rooms||[];if(o.length===0){i.update(r,"No room servers configured.","warning");return}const a=[W(`Rooms (${o.length})`),"",...o.map(h=>[` ${it(h.room_name)}`,` ${b("msgs",y(String(h.total_messages)))} ${b("clients",`${y(String(h.active_clients))}${Ae(`/${h.total_clients}`)}`)} ${b("sync",h.sync_running?y("running"):Ae("idle"))}`]).flat()];i.update(r,a.join(` +`))}catch(n){i.update(r,`Error: ${n instanceof Error?n.message:"Command failed"}`,"error")}}}class k_ extends ee{constructor(){super(...arguments);D(this,"name","restart");D(this,"description","Restart pymc-repeater service");D(this,"aliases",["reboot"])}async execute({output:i,rawInput:s}){if(this.argsAfterName(s).toLowerCase().trim()==="help"){i.write([W("restart"),` ${w("Restart the pymc-repeater systemd service.")}`,"",R("restart","restart the service"),"",W("Aliases"),` ${w("reboot")}`,"",st("Requires polkit permissions for the web user."),st("The page will need a manual refresh after restart.")].join(` `));return}const r=i.write("Restarting service...","system");try{const n=await ml(AbortSignal.timeout(8e3));if(n.success){i.update(r,"Service restart initiated.","success"),await this.waitForService(i);return}const o=n.status;if(o===403||o===401){i.update(r,`Error: Permission denied. The web user needs polkit permissions to restart the service. -See: /etc/polkit-1/localauthority/50-local.d/pymc-repeater.pkla`,"error");return}i.update(r,n.error||"Restart failed","error")}catch(n){const o=n instanceof Error?n.message:"";o.includes("ERR_NETWORK")||o.includes("ECONNRESET")||o.includes("Failed to fetch")||o.includes("Load failed")||o.includes("network connection was lost")||o.includes("abort")||o.includes("timeout")||n instanceof DOMException&&n.name==="TimeoutError"||n instanceof DOMException&&n.name==="AbortError"?(i.update(r,"Service is restarting (connection dropped).","success"),await this.waitForService(i)):i.update(r,`Error: ${o||"Restart failed"}`,"error")}}waitForService(i){return new Promise(s=>{const r=i.write("Waiting for service...","system");let n=0;const o=30;setTimeout(()=>{const a=setInterval(async()=>{n++,i.update(r,`Waiting for service... ${n}s`,"system");try{const h=new AbortController,l=setTimeout(()=>h.abort(),3e3);await fetch(`${il}/api/stats`,{signal:h.signal}),clearTimeout(l),clearInterval(a),i.update(r,`Service connected. (${n+4}s)`,"success"),s();return}catch{}n>=o&&(clearInterval(a),i.update(r,`Service did not respond within ${o+4}s. Check manually.`,"warning"),s())},1e3)},4e3)})}}const Ot="\x1B[",Ne=`${Ot}0m`,Oa=`${Ot}32m`,Or=`${Ot}33m`,Fr=`${Ot}31m`,E_=`${Ot}36m`,Rt=`${Ot}90m`,Fa=`${Ot}1m`;function Vt(e){return e>=1073741824?`${(e/1073741824).toFixed(1)}G`:e>=1048576?`${(e/1048576).toFixed(0)}M`:e>=1024?`${(e/1024).toFixed(0)}K`:`${e}B`}function ho(e){const t=Math.floor(e/86400),i=Math.floor(e%86400/3600),s=Math.floor(e%3600/60);return t>0?`${t}d ${i}h ${s}m`:i>0?`${i}h ${s}m`:`${s}m`}function R_(e,t){const i=Math.max(0,Math.min(100,e)),s=Math.round(i/100*t),r=t-s,n=i>=90?Fr:i>=70?Or:Oa,o=`${n}${"█".repeat(s)}${Ne}${Rt}${"░".repeat(r)}${Ne}`,a=`${i.toFixed(1)}%`.padStart(6);return`[${o}] ${n}${a}${Ne}`}function B_(e){return e>=80?`${Fr}${Fa}${e.toFixed(1)}°C${Ne}`:e>=60?`${Or}${e.toFixed(1)}°C${Ne}`:`${Oa}${e.toFixed(1)}°C${Ne}`}const wi=2,co=" ";function Gt(e,t){const i=" ".repeat(wi),s=t-wi,r=co.length,n=[];let o="",a=0;for(const h of e){const l=hu(h);a===0?(o=h,a=l):a+r+l<=s?(o+=co+h,a+=r+l):(n.push(i+o),o=h,a=l)}return a>0&&n.push(i+o),n}function M_(e,t,i){var d,u;const s=e.node_name||"unknown",r=e.version?`v${e.version}`:"",n=(d=t.system)!=null&&d.uptime?ho(t.system.uptime):"?",o=ho(e.uptime_seconds||0),a=Math.max(3,i-wi*2),h=((u=t.cpu.load_avg)==null?void 0:u["1min"].toFixed(2))??"?",l=t.cpu.load_avg?`${h} ${t.cpu.load_avg["5min"].toFixed(2)} ${t.cpu.load_avg["15min"].toFixed(2)}`:"?",c=i>=60?l:h;return[` ${E_}${Fa}${s}${Ne} ${Rt}${r}${Ne}`,` ${Rt}${"─".repeat(a)}${Ne}`,...Gt([w("Sys",y(n)),w("Svc",y(o)),w("Load",y(c))],i)]}function D_(e,t){const s=wi+4+1+2+6,r=Math.max(6,Math.min(30,t-s)),n=s+r,o=t-n-2,a=[""],h=`${e.cpu.count} core${e.cpu.count>1?"s":""}`,l=`${Vt(e.memory.used)}/${Vt(e.memory.total)}`,c=`${Vt(e.disk.used)}/${Vt(e.disk.total)}`,d=(f,_,p)=>{const g=R_(_,r),E=o>=p.length?` ${Ae(p)}`:"";return` ${b(f.padEnd(4))}${g}${E}`};a.push(d("CPU",e.cpu.usage_percent,h)),a.push(d("Mem",e.memory.usage_percent,l)),a.push(d("Dsk",e.disk.usage_percent,c));const u=Object.entries(e.temperatures||{});if(u.length>0){const f=u.map(([_,p])=>`${Ae(_+":")} ${B_(p)}`);a.push(...Gt(f,t))}return a}function L_(e,t){var l,c;const i=e.neighbors||{},s=Object.keys(i).length,r=Object.values(i).filter(d=>d.zero_hop).length,n=((c=(l=e.config)==null?void 0:l.repeater)==null?void 0:c.mode)||"?",o=e.noise_floor_dbm!=null?`${e.noise_floor_dbm}dBm`:"?",a=e.duty_cycle_percent??0,h=["",` ${Rt}MESH${Ne}`];return h.push(...Gt([w("Mode",y(n)),w("Nbrs",`${y(String(r))}${Ae(`/${s}`)}`),w("Noise",y(o)),w("Air",y(`${a.toFixed(1)}%`))],t)),h.push(...Gt([w("RX",y(String(e.rx_count??0))),w("TX",y(String(e.tx_count??0))),w("FWD",y(String(e.forwarded_count??0))),w("Drop",y(String(e.dropped_count??0)))],t)),h.push(...Gt([w("RX/h",y(String(Math.round(e.rx_per_hour??0)))),w("FWD/h",y(String(Math.round(e.forwarded_per_hour??0))))],t)),h}function T_(e,t){if(!e.network)return[];const i=["",` ${Rt}NET${Ne}`];return i.push(...Gt([w("TX",y(Vt(e.network.bytes_sent))),w("RX",y(Vt(e.network.bytes_recv))),w("Pkt",`${y(String(e.network.packets_sent))}${Ae("/")}${y(String(e.network.packets_recv))}`)],t)),i}function $_(e,t,i){if(e.length===0)return[];const s=t>=50,r=t>=50?6:5,n=t>=50?6:5,o=s?7:0,a=wi+0,h=Math.max(4,t-a-o-r-n-4),l=3,c=t>=50?8:5,d=i!=null?Math.max(0,Math.min(c,i-l)):c;if(d<=0)return[];const u=["",` ${Rt}PROCS${Ne}`],f=(s?"PID".padEnd(o):"")+"CPU".padStart(r)+"MEM".padStart(n)+" NAME";u.push(` ${Ae(f)}`);for(const _ of e.slice(0,d)){const p=s?Ae(String(_.pid).padEnd(o)):"",g=(t>=50?_.cpu_percent.toFixed(1):_.cpu_percent.toFixed(0)).padStart(r),E=(t>=50?_.memory_percent.toFixed(1):_.memory_percent.toFixed(0)).padStart(n),z=_.name.length>h?_.name.slice(0,h-1)+"…":_.name,O=_.cpu_percent>=50?Fr:_.cpu_percent>=20?Or:"",M=O?`${O}${g}${Ne}`:g;u.push(` ${p}${M}${Ae(E)} ${z}`)}return u}function A_(){return new Date().toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1})}function uo(e,t,i,s,r){if(!e||!t)return` ${Rt}Waiting for data…${Ne}`;const n=M_(e,t,s),o=D_(t,s),a=L_(e,s),h=T_(t,s),l=["",` ${Rt}${A_()} · Ctrl+C to exit${Ne}`],c=[...n,...o,...a,...h,...l],d=r?yr(c,s):0,u=r?Math.max(0,r-d):void 0,f=$_(i,s,u),_=[...c.slice(0,-l.length),...f,...l];return r&&_.length>r&&(_.length=r),_.join(` -`)}const P_=3e3;class N_ extends ee{constructor(){super(...arguments);D(this,"name","top");D(this,"description","Live system overview (Ctrl+C to exit)");D(this,"aliases",["htop"])}async execute({output:i,rawInput:s,cols:r,signal:n}){var l,c;if(this.argsAfterName(s).toLowerCase().trim()==="help"){i.write([W("top"),` ${b("Live-updating system overview combining hardware")}`,` ${b("stats, mesh metrics, and running processes.")}`,` ${b("Refreshes every 3s. Press Ctrl+C to exit.")}`,"",R("top","start live display"),"",W("Sections"),` ${b("Header Node name, version, uptime, load average")}`,` ${b("Gauges CPU, memory, disk usage with bar charts")}`,` ${b("Mesh Mode, neighbors, packet counts, airtime")}`,` ${b("Network TCP/IP bytes and packet counters")}`,` ${b("Processes Top 8 processes by CPU usage")}`,"",W("Aliases"),` ${b("htop")}`].join(` -`));return}let o=null,a=[],h=wt.getState().stats;try{const[d,u]=await Promise.all([Qi(),Wr()]);d.success&&d.data&&(o=d.data),u.success&&u.data&&(a=u.data.processes.sort((f,_)=>_.cpu_percent-f.cpu_percent))}catch{}if(!n.aborted){(l=i.enterFullscreen)==null||l.call(i);try{const d=i.write(uo(h,o,a,i.cols??r,i.rows));await new Promise(u=>{if(n.aborted){u();return}const f=async()=>{h=wt.getState().stats;try{const[p,g]=await Promise.all([Qi(),Wr()]);p.success&&p.data&&(o=p.data),g.success&&g.data&&(a=g.data.processes.sort((E,z)=>z.cpu_percent-E.cpu_percent))}catch{}n.aborted||i.update(d,uo(h,o,a,i.cols??r,i.rows))},_=setInterval(()=>{if(n.aborted){clearInterval(_),u();return}f()},P_);n.addEventListener("abort",()=>{clearInterval(_),u()},{once:!0})})}finally{(c=i.exitFullscreen)==null||c.call(i)}}}}const _o=["DONT PANIC","C0FFEE","FEED C0DE","LOL","I CANNOT DO THAT"];function Hr(){return _o[Math.floor(Math.random()*_o.length)]}const wr=new EventTarget,Cr="shell-phrase";function Ha(e){wr.dispatchEvent(new CustomEvent(Cr,{detail:e??Hr()}))}function I_(e){const t=i=>e(i.detail);return wr.addEventListener(Cr,t),()=>wr.removeEventListener(Cr,t)}class O_ extends ee{constructor(){super(...arguments);D(this,"name","fortune");D(this,"description","Display a fortune on the header");D(this,"aliases",["lol"])}execute({output:i}){const s=Hr();Ha(s),i.write(b(` ${s}`))}}const xr=new EventTarget,kr="party-time";function F_(){xr.dispatchEvent(new Event(kr))}function H_(e){return xr.addEventListener(kr,e),()=>xr.removeEventListener(kr,e)}class W_ extends ee{constructor(){super(...arguments);D(this,"name","partytime");D(this,"description","Party on, Garth!");D(this,"aliases",["party","excellent","waynesworld"])}execute({output:i}){F_(),Ha("PARTY 0N GARTH"),i.write(b(" SCHWING!"))}}class z_ extends ee{constructor(){super(...arguments);D(this,"name","ver");D(this,"description","Show version info");D(this,"aliases",["version"])}async execute({output:i,rawInput:s}){if(this.argsAfterName(s).toLowerCase().trim()==="help"){i.write([W("ver"),` ${b("Display pyMC_Repeater, core, and console version.")}`,` ${b('Equivalent to firmware serial CLI "ver" command.')}`,"",R("ver","show version"),"",W("Aliases"),` ${b("version")}`].join(` -`));return}const r=i.write("processing...","system");try{const n=await rt();i.update(r,[` ${w("pyMC_Repeater",y(`v${n.version||"?"}`))}`,` ${w("pyMC_Core",y(n.core_version||"?"))}`,` ${w("pyMC_Console",y("v0.9.296"))}`].join(` -`),"value")}catch(n){i.update(r,`Error: ${n instanceof Error?n.message:"Command failed"}`,"error")}}}class U_ extends ee{constructor(){super(...arguments);D(this,"name","clock");D(this,"description","Show system UTC time")}execute({output:i,rawInput:s}){if(this.argsAfterName(s).toLowerCase().trim()==="help"){i.write([W("clock"),` ${b("Display the current system UTC time.")}`,` ${b('Equivalent to firmware serial CLI "clock" command.')}`,` ${b("Use to verify NTP sync and correlate packet timestamps.")}`,"",R("clock","show UTC time")].join(` -`));return}const r=new Date;i.write([` ${w("UTC",y(r.toUTCString()))}`,` ${w("ISO",y(r.toISOString()))}`,` ${w("Unix",y(String(Math.floor(r.getTime()/1e3))))}`].join(` -`),"value")}}class j_ extends ee{constructor(){super(...arguments);D(this,"name","stats-packets");D(this,"description","Packet counters")}async execute({output:i,rawInput:s}){if(this.argsAfterName(s).toLowerCase().trim()==="help"){i.write([W("stats-packets"),` ${b("Display packet counters: sent, received, forwarded, dropped.")}`,` ${b('Equivalent to firmware serial CLI "stats-packets" command.')}`,"",R("stats-packets","show packet counters")].join(` -`));return}const r=i.write("processing...","system");try{const n=await rt(),o=n.rx_count??0,a=n.tx_count??0,h=n.forwarded_count??0,l=n.dropped_count??0,c=n.rx_per_hour??0,d=n.forwarded_per_hour??0,u=n.duplicate_cache_size??0;i.update(r,[` ${it("Packet Counters")}`,"",` ${w("RX",y(String(o)))} ${b(`${c.toFixed(1)}/hr`)}`,` ${w("TX",y(String(a)))}`,` ${w("Forwarded",y(String(h)))} ${b(`${d.toFixed(1)}/hr`)}`,` ${w("Dropped",y(String(l)))}`,"",` ${w("Dup cache",y(String(u)))}`].join(` -`),"value")}catch(n){i.update(r,`Error: ${n instanceof Error?n.message:"Command failed"}`,"error")}}}function As(e){return e>=6e4?`${(e/6e4).toFixed(1)}m`:e>=1e3?`${(e/1e3).toFixed(1)}s`:`${e.toFixed(0)}ms`}class K_ extends ee{constructor(){super(...arguments);D(this,"name","stats-radio");D(this,"description","Radio health stats")}async execute({output:i,rawInput:s}){var n;if(this.argsAfterName(s).toLowerCase().trim()==="help"){i.write([W("stats-radio"),` ${b("Display radio health: airtime, noise floor, duty cycle.")}`,` ${b('Equivalent to firmware serial CLI "stats-radio" command.')}`,"",R("stats-radio","show radio stats")].join(` -`));return}const r=i.write("processing...","system");try{const o=await rt(),a=(n=o.config)==null?void 0:n.radio,h=o.noise_floor_dbm,l=o.airtime_used_ms??0,c=o.airtime_remaining_ms??0,d=o.duty_cycle_percent??0,u=o.utilization_percent??0,f=o.total_airtime_ms??0,_=[` ${it("Radio Stats")}`,""];if(a){const p=a.frequency?`${(a.frequency/1e6).toFixed(3)} MHz`:"?",g=a.bandwidth?`${a.bandwidth/1e3} kHz`:"?";_.push(` ${w("Radio",y(`${p} SF${a.spreading_factor??"?"} BW ${g} CR 4/${a.coding_rate??"?"} ${a.tx_power??"?"} dBm`))}`),_.push("")}_.push(` ${w("Noise floor",h!=null?y(`${h} dBm`):b("N/A"))}`),_.push(` ${w("Airtime used",y(As(l)))} ${b(`remaining: ${As(c)}`)}`),_.push(` ${w("Total airtime",y(As(f)))}`),_.push(` ${w("Duty cycle",y(`${d.toFixed(1)}%`))}`),_.push(` ${w("Utilization",y(`${u.toFixed(1)}%`))}`),i.update(r,_.join(` -`),"value")}catch(o){i.update(r,`Error: ${o instanceof Error?o.message:"Command failed"}`,"error")}}}function fo(e){return e>=1073741824?`${(e/1073741824).toFixed(1)} GB`:e>=1048576?`${(e/1048576).toFixed(0)} MB`:`${(e/1024).toFixed(0)} KB`}class q_ extends ee{constructor(){super(...arguments);D(this,"name","stats-core");D(this,"description","Engine vitals")}async execute({output:i,rawInput:s}){if(this.argsAfterName(s).toLowerCase().trim()==="help"){i.write([W("stats-core"),` ${b("Display engine vitals: uptime, memory, CPU, queue depth.")}`,` ${b('Equivalent to firmware serial CLI "stats-core" command.')}`,` ${b("On firmware this shows free heap — here we show Linux process health.")}`,"",R("stats-core","show core stats")].join(` -`));return}const r=i.write("processing...","system");try{const[n,o]=await Promise.all([rt(),Qi()]),a=[` ${it("Core Stats")}`,"",` ${w("Uptime",y(Ir(n.uptime_seconds??0)))}`,` ${w("Dup cache",y(`${n.duplicate_cache_size??0} entries`))} ${b(`TTL ${n.cache_ttl??"?"}s`)}`];if(o.success&&o.data){const h=o.data;a.push(""),a.push(` ${w("CPU",y(`${h.cpu.usage_percent.toFixed(1)}%`))} ${b(`${h.cpu.count} core${h.cpu.count>1?"s":""}`)}`),h.cpu.load_avg&&a.push(` ${w("Load",y(`${h.cpu.load_avg["1min"].toFixed(2)} / ${h.cpu.load_avg["5min"].toFixed(2)} / ${h.cpu.load_avg["15min"].toFixed(2)}`))}`),a.push(` ${w("Memory",y(`${fo(h.memory.used)} / ${fo(h.memory.total)}`))} ${b(`${h.memory.usage_percent.toFixed(0)}%`)}`);const l=Object.entries(h.temperatures||{});l.length>0&&a.push(` ${w("Temp",y(`${l[0][1].toFixed(1)}°C`))}`)}i.update(r,a.join(` +See: /etc/polkit-1/localauthority/50-local.d/pymc-repeater.pkla`,"error");return}i.update(r,n.error||"Restart failed","error")}catch(n){const o=n instanceof Error?n.message:"";o.includes("ERR_NETWORK")||o.includes("ECONNRESET")||o.includes("Failed to fetch")||o.includes("Load failed")||o.includes("network connection was lost")||o.includes("abort")||o.includes("timeout")||n instanceof DOMException&&n.name==="TimeoutError"||n instanceof DOMException&&n.name==="AbortError"?(i.update(r,"Service is restarting (connection dropped).","success"),await this.waitForService(i)):i.update(r,`Error: ${o||"Restart failed"}`,"error")}}waitForService(i){return new Promise(s=>{const r=i.write("Waiting for service...","system");let n=0;const o=30;setTimeout(()=>{const a=setInterval(async()=>{n++,i.update(r,`Waiting for service... ${n}s`,"system");try{const h=new AbortController,l=setTimeout(()=>h.abort(),3e3);await fetch(`${il}/api/stats`,{signal:h.signal}),clearTimeout(l),clearInterval(a),i.update(r,`Service connected. (${n+4}s)`,"success"),s();return}catch{}n>=o&&(clearInterval(a),i.update(r,`Service did not respond within ${o+4}s. Check manually.`,"warning"),s())},1e3)},4e3)})}}const Ot="\x1B[",Ne=`${Ot}0m`,Oa=`${Ot}32m`,Or=`${Ot}33m`,Hr=`${Ot}31m`,E_=`${Ot}36m`,Rt=`${Ot}90m`,Ha=`${Ot}1m`;function Vt(e){return e>=1073741824?`${(e/1073741824).toFixed(1)}G`:e>=1048576?`${(e/1048576).toFixed(0)}M`:e>=1024?`${(e/1024).toFixed(0)}K`:`${e}B`}function ho(e){const t=Math.floor(e/86400),i=Math.floor(e%86400/3600),s=Math.floor(e%3600/60);return t>0?`${t}d ${i}h ${s}m`:i>0?`${i}h ${s}m`:`${s}m`}function R_(e,t){const i=Math.max(0,Math.min(100,e)),s=Math.round(i/100*t),r=t-s,n=i>=90?Hr:i>=70?Or:Oa,o=`${n}${"█".repeat(s)}${Ne}${Rt}${"░".repeat(r)}${Ne}`,a=`${i.toFixed(1)}%`.padStart(6);return`[${o}] ${n}${a}${Ne}`}function B_(e){return e>=80?`${Hr}${Ha}${e.toFixed(1)}°C${Ne}`:e>=60?`${Or}${e.toFixed(1)}°C${Ne}`:`${Oa}${e.toFixed(1)}°C${Ne}`}const bi=2,co=" ";function Gt(e,t){const i=" ".repeat(bi),s=t-bi,r=co.length,n=[];let o="",a=0;for(const h of e){const l=hu(h);a===0?(o=h,a=l):a+r+l<=s?(o+=co+h,a+=r+l):(n.push(i+o),o=h,a=l)}return a>0&&n.push(i+o),n}function M_(e,t,i){var d,u;const s=e.node_name||"unknown",r=e.version?`v${e.version}`:"",n=(d=t.system)!=null&&d.uptime?ho(t.system.uptime):"?",o=ho(e.uptime_seconds||0),a=Math.max(3,i-bi*2),h=((u=t.cpu.load_avg)==null?void 0:u["1min"].toFixed(2))??"?",l=t.cpu.load_avg?`${h} ${t.cpu.load_avg["5min"].toFixed(2)} ${t.cpu.load_avg["15min"].toFixed(2)}`:"?",c=i>=60?l:h;return[` ${E_}${Ha}${s}${Ne} ${Rt}${r}${Ne}`,` ${Rt}${"─".repeat(a)}${Ne}`,...Gt([b("Sys",y(n)),b("Svc",y(o)),b("Load",y(c))],i)]}function D_(e,t){const s=bi+4+1+2+6,r=Math.max(6,Math.min(30,t-s)),n=s+r,o=t-n-2,a=[""],h=`${e.cpu.count} core${e.cpu.count>1?"s":""}`,l=`${Vt(e.memory.used)}/${Vt(e.memory.total)}`,c=`${Vt(e.disk.used)}/${Vt(e.disk.total)}`,d=(f,_,p)=>{const g=R_(_,r),E=o>=p.length?` ${Ae(p)}`:"";return` ${w(f.padEnd(4))}${g}${E}`};a.push(d("CPU",e.cpu.usage_percent,h)),a.push(d("Mem",e.memory.usage_percent,l)),a.push(d("Dsk",e.disk.usage_percent,c));const u=Object.entries(e.temperatures||{});if(u.length>0){const f=u.map(([_,p])=>`${Ae(_+":")} ${B_(p)}`);a.push(...Gt(f,t))}return a}function L_(e,t){var l,c;const i=e.neighbors||{},s=Object.keys(i).length,r=Object.values(i).filter(d=>d.zero_hop).length,n=((c=(l=e.config)==null?void 0:l.repeater)==null?void 0:c.mode)||"?",o=e.noise_floor_dbm!=null?`${e.noise_floor_dbm}dBm`:"?",a=e.duty_cycle_percent??0,h=["",` ${Rt}MESH${Ne}`];return h.push(...Gt([b("Mode",y(n)),b("Nbrs",`${y(String(r))}${Ae(`/${s}`)}`),b("Noise",y(o)),b("Air",y(`${a.toFixed(1)}%`))],t)),h.push(...Gt([b("RX",y(String(e.rx_count??0))),b("TX",y(String(e.tx_count??0))),b("FWD",y(String(e.forwarded_count??0))),b("Drop",y(String(e.dropped_count??0)))],t)),h.push(...Gt([b("RX/h",y(String(Math.round(e.rx_per_hour??0)))),b("FWD/h",y(String(Math.round(e.forwarded_per_hour??0))))],t)),h}function T_(e,t){if(!e.network)return[];const i=["",` ${Rt}NET${Ne}`];return i.push(...Gt([b("TX",y(Vt(e.network.bytes_sent))),b("RX",y(Vt(e.network.bytes_recv))),b("Pkt",`${y(String(e.network.packets_sent))}${Ae("/")}${y(String(e.network.packets_recv))}`)],t)),i}function $_(e,t,i){if(e.length===0)return[];const s=t>=50,r=t>=50?6:5,n=t>=50?6:5,o=s?7:0,a=bi+0,h=Math.max(4,t-a-o-r-n-4),l=3,c=t>=50?8:5,d=i!=null?Math.max(0,Math.min(c,i-l)):c;if(d<=0)return[];const u=["",` ${Rt}PROCS${Ne}`],f=(s?"PID".padEnd(o):"")+"CPU".padStart(r)+"MEM".padStart(n)+" NAME";u.push(` ${Ae(f)}`);for(const _ of e.slice(0,d)){const p=s?Ae(String(_.pid).padEnd(o)):"",g=(t>=50?_.cpu_percent.toFixed(1):_.cpu_percent.toFixed(0)).padStart(r),E=(t>=50?_.memory_percent.toFixed(1):_.memory_percent.toFixed(0)).padStart(n),z=_.name.length>h?_.name.slice(0,h-1)+"…":_.name,O=_.cpu_percent>=50?Hr:_.cpu_percent>=20?Or:"",M=O?`${O}${g}${Ne}`:g;u.push(` ${p}${M}${Ae(E)} ${z}`)}return u}function A_(){return new Date().toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1})}function uo(e,t,i,s,r){if(!e||!t)return` ${Rt}Waiting for data…${Ne}`;const n=M_(e,t,s),o=D_(t,s),a=L_(e,s),h=T_(t,s),l=["",` ${Rt}${A_()} · Ctrl+C to exit${Ne}`],c=[...n,...o,...a,...h,...l],d=r?yr(c,s):0,u=r?Math.max(0,r-d):void 0,f=$_(i,s,u),_=[...c.slice(0,-l.length),...f,...l];return r&&_.length>r&&(_.length=r),_.join(` +`)}const P_=3e3;class N_ extends ee{constructor(){super(...arguments);D(this,"name","top");D(this,"description","Live system overview (Ctrl+C to exit)");D(this,"aliases",["htop"])}async execute({output:i,rawInput:s,cols:r,signal:n}){var l,c;if(this.argsAfterName(s).toLowerCase().trim()==="help"){i.write([W("top"),` ${w("Live-updating system overview combining hardware")}`,` ${w("stats, mesh metrics, and running processes.")}`,` ${w("Refreshes every 3s. Press Ctrl+C to exit.")}`,"",R("top","start live display"),"",W("Sections"),` ${w("Header Node name, version, uptime, load average")}`,` ${w("Gauges CPU, memory, disk usage with bar charts")}`,` ${w("Mesh Mode, neighbors, packet counts, airtime")}`,` ${w("Network TCP/IP bytes and packet counters")}`,` ${w("Processes Top 8 processes by CPU usage")}`,"",W("Aliases"),` ${w("htop")}`].join(` +`));return}let o=null,a=[],h=bt.getState().stats;try{const[d,u]=await Promise.all([Qi(),Wr()]);d.success&&d.data&&(o=d.data),u.success&&u.data&&(a=u.data.processes.sort((f,_)=>_.cpu_percent-f.cpu_percent))}catch{}if(!n.aborted){(l=i.enterFullscreen)==null||l.call(i);try{const d=i.write(uo(h,o,a,i.cols??r,i.rows));await new Promise(u=>{if(n.aborted){u();return}const f=async()=>{h=bt.getState().stats;try{const[p,g]=await Promise.all([Qi(),Wr()]);p.success&&p.data&&(o=p.data),g.success&&g.data&&(a=g.data.processes.sort((E,z)=>z.cpu_percent-E.cpu_percent))}catch{}n.aborted||i.update(d,uo(h,o,a,i.cols??r,i.rows))},_=setInterval(()=>{if(n.aborted){clearInterval(_),u();return}f()},P_);n.addEventListener("abort",()=>{clearInterval(_),u()},{once:!0})})}finally{(c=i.exitFullscreen)==null||c.call(i)}}}}const _o=["DONT PANIC","C0FFEE","FEED C0DE","LOL","I CANNOT DO THAT"];function Fr(){return _o[Math.floor(Math.random()*_o.length)]}const br=new EventTarget,Cr="shell-phrase";function Fa(e){br.dispatchEvent(new CustomEvent(Cr,{detail:e??Fr()}))}function I_(e){const t=i=>e(i.detail);return br.addEventListener(Cr,t),()=>br.removeEventListener(Cr,t)}class O_ extends ee{constructor(){super(...arguments);D(this,"name","fortune");D(this,"description","Display a fortune on the header");D(this,"aliases",["lol"])}execute({output:i}){const s=Fr();Fa(s),i.write(w(` ${s}`))}}const xr=new EventTarget,kr="party-time";function H_(){xr.dispatchEvent(new Event(kr))}function F_(e){return xr.addEventListener(kr,e),()=>xr.removeEventListener(kr,e)}class W_ extends ee{constructor(){super(...arguments);D(this,"name","partytime");D(this,"description","Party on, Garth!");D(this,"aliases",["party","excellent","waynesworld"])}execute({output:i}){H_(),Fa("PARTY 0N GARTH"),i.write(w(" SCHWING!"))}}class z_ extends ee{constructor(){super(...arguments);D(this,"name","ver");D(this,"description","Show version info");D(this,"aliases",["version"])}async execute({output:i,rawInput:s}){if(this.argsAfterName(s).toLowerCase().trim()==="help"){i.write([W("ver"),` ${w("Display pyMC_Repeater, core, and console version.")}`,` ${w('Equivalent to firmware serial CLI "ver" command.')}`,"",R("ver","show version"),"",W("Aliases"),` ${w("version")}`].join(` +`));return}const r=i.write("processing...","system");try{const n=await rt();i.update(r,[` ${b("pyMC_Repeater",y(`v${n.version||"?"}`))}`,` ${b("pyMC_Core",y(n.core_version||"?"))}`,` ${b("pyMC_Console",y("v0.9.297"))}`].join(` +`),"value")}catch(n){i.update(r,`Error: ${n instanceof Error?n.message:"Command failed"}`,"error")}}}class U_ extends ee{constructor(){super(...arguments);D(this,"name","clock");D(this,"description","Show system UTC time")}execute({output:i,rawInput:s}){if(this.argsAfterName(s).toLowerCase().trim()==="help"){i.write([W("clock"),` ${w("Display the current system UTC time.")}`,` ${w('Equivalent to firmware serial CLI "clock" command.')}`,` ${w("Use to verify NTP sync and correlate packet timestamps.")}`,"",R("clock","show UTC time")].join(` +`));return}const r=new Date;i.write([` ${b("UTC",y(r.toUTCString()))}`,` ${b("ISO",y(r.toISOString()))}`,` ${b("Unix",y(String(Math.floor(r.getTime()/1e3))))}`].join(` +`),"value")}}class j_ extends ee{constructor(){super(...arguments);D(this,"name","stats-packets");D(this,"description","Packet counters")}async execute({output:i,rawInput:s}){if(this.argsAfterName(s).toLowerCase().trim()==="help"){i.write([W("stats-packets"),` ${w("Display packet counters: sent, received, forwarded, dropped.")}`,` ${w('Equivalent to firmware serial CLI "stats-packets" command.')}`,"",R("stats-packets","show packet counters")].join(` +`));return}const r=i.write("processing...","system");try{const n=await rt(),o=n.rx_count??0,a=n.tx_count??0,h=n.forwarded_count??0,l=n.dropped_count??0,c=n.rx_per_hour??0,d=n.forwarded_per_hour??0,u=n.duplicate_cache_size??0;i.update(r,[` ${it("Packet Counters")}`,"",` ${b("RX",y(String(o)))} ${w(`${c.toFixed(1)}/hr`)}`,` ${b("TX",y(String(a)))}`,` ${b("Forwarded",y(String(h)))} ${w(`${d.toFixed(1)}/hr`)}`,` ${b("Dropped",y(String(l)))}`,"",` ${b("Dup cache",y(String(u)))}`].join(` +`),"value")}catch(n){i.update(r,`Error: ${n instanceof Error?n.message:"Command failed"}`,"error")}}}function As(e){return e>=6e4?`${(e/6e4).toFixed(1)}m`:e>=1e3?`${(e/1e3).toFixed(1)}s`:`${e.toFixed(0)}ms`}class K_ extends ee{constructor(){super(...arguments);D(this,"name","stats-radio");D(this,"description","Radio health stats")}async execute({output:i,rawInput:s}){var n;if(this.argsAfterName(s).toLowerCase().trim()==="help"){i.write([W("stats-radio"),` ${w("Display radio health: airtime, noise floor, duty cycle.")}`,` ${w('Equivalent to firmware serial CLI "stats-radio" command.')}`,"",R("stats-radio","show radio stats")].join(` +`));return}const r=i.write("processing...","system");try{const o=await rt(),a=(n=o.config)==null?void 0:n.radio,h=o.noise_floor_dbm,l=o.airtime_used_ms??0,c=o.airtime_remaining_ms??0,d=o.duty_cycle_percent??0,u=o.utilization_percent??0,f=o.total_airtime_ms??0,_=[` ${it("Radio Stats")}`,""];if(a){const p=a.frequency?`${(a.frequency/1e6).toFixed(3)} MHz`:"?",g=a.bandwidth?`${a.bandwidth/1e3} kHz`:"?";_.push(` ${b("Radio",y(`${p} SF${a.spreading_factor??"?"} BW ${g} CR 4/${a.coding_rate??"?"} ${a.tx_power??"?"} dBm`))}`),_.push("")}_.push(` ${b("Noise floor",h!=null?y(`${h} dBm`):w("N/A"))}`),_.push(` ${b("Airtime used",y(As(l)))} ${w(`remaining: ${As(c)}`)}`),_.push(` ${b("Total airtime",y(As(f)))}`),_.push(` ${b("Duty cycle",y(`${d.toFixed(1)}%`))}`),_.push(` ${b("Utilization",y(`${u.toFixed(1)}%`))}`),i.update(r,_.join(` +`),"value")}catch(o){i.update(r,`Error: ${o instanceof Error?o.message:"Command failed"}`,"error")}}}function fo(e){return e>=1073741824?`${(e/1073741824).toFixed(1)} GB`:e>=1048576?`${(e/1048576).toFixed(0)} MB`:`${(e/1024).toFixed(0)} KB`}class q_ extends ee{constructor(){super(...arguments);D(this,"name","stats-core");D(this,"description","Engine vitals")}async execute({output:i,rawInput:s}){if(this.argsAfterName(s).toLowerCase().trim()==="help"){i.write([W("stats-core"),` ${w("Display engine vitals: uptime, memory, CPU, queue depth.")}`,` ${w('Equivalent to firmware serial CLI "stats-core" command.')}`,` ${w("On firmware this shows free heap — here we show Linux process health.")}`,"",R("stats-core","show core stats")].join(` +`));return}const r=i.write("processing...","system");try{const[n,o]=await Promise.all([rt(),Qi()]),a=[` ${it("Core Stats")}`,"",` ${b("Uptime",y(Ir(n.uptime_seconds??0)))}`,` ${b("Dup cache",y(`${n.duplicate_cache_size??0} entries`))} ${w(`TTL ${n.cache_ttl??"?"}s`)}`];if(o.success&&o.data){const h=o.data;a.push(""),a.push(` ${b("CPU",y(`${h.cpu.usage_percent.toFixed(1)}%`))} ${w(`${h.cpu.count} core${h.cpu.count>1?"s":""}`)}`),h.cpu.load_avg&&a.push(` ${b("Load",y(`${h.cpu.load_avg["1min"].toFixed(2)} / ${h.cpu.load_avg["5min"].toFixed(2)} / ${h.cpu.load_avg["15min"].toFixed(2)}`))}`),a.push(` ${b("Memory",y(`${fo(h.memory.used)} / ${fo(h.memory.total)}`))} ${w(`${h.memory.usage_percent.toFixed(0)}%`)}`);const l=Object.entries(h.temperatures||{});l.length>0&&a.push(` ${b("Temp",y(`${l[0][1].toFixed(1)}°C`))}`)}i.update(r,a.join(` `),"value")}catch(n){i.update(r,`Error: ${n instanceof Error?n.message:"Command failed"}`,"error")}}}const Ps=["@@@@@@@ @@@ @@@ @@@@@@@@@@ @@@@@@@ ","@@@@@@@@ @@@ @@@ @@@@@@@@@@@ @@@@@@@@ ","@@! @@@ @@! !@@ @@! @@! @@! !@@ ","!@! @!@ !@! @!! !@! !@! !@! !@! ","@!@@!@! !@!@! @!! !!@ @!@ !@! ","!!@!!! @!!! !@! ! !@! !!! ","!!: !!: !!: !!: :!! ",":!: :!: :!: :!: :!: "," :: :: ::: :: ::: ::: "," : : : : :: :: : "],po=To-1;class V_ extends ee{constructor(){super(...arguments);D(this,"name","hello");D(this,"description","Play the PYMC burst intro");D(this,"aliases",["hi","intro"])}async execute({output:i,signal:s}){if(s.aborted)return;let r=0;const n=i.write(gi(Ps,0).join(` `));try{await new Promise(o=>{const a=setInterval(()=>{if(s.aborted||r>=po){clearInterval(a),s.aborted||i.update(n,gi(Ps,po).join(` `)),o();return}r++,i.update(n,gi(Ps,r).join(` -`))},Do);s.addEventListener("abort",()=>{clearInterval(a),o()},{once:!0})})}finally{Lo()}}}function G_(){const e=new Vd,t=new wu(e);return e.register(t,new Cu,new xu,new z_,new U_,new ku,new Eu,new Ru,new j_,new K_,new q_,new Hu,new Yu,new o_,new Xu,new Zu,new a_,new y_,new b_,new w_,new C_,new x_,new k_,new N_,new O_,new W_,new V_),e}const Y_=()=>typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)}),mo=ko(e=>({entries:[],commandHistory:[],isInitialized:!1,addEntry:t=>{const i=Y_(),s={...t,id:i,timestamp:Date.now()};return e(r=>({entries:[...r.entries,s]})),i},updateEntry:(t,i)=>{e(s=>({entries:s.entries.map(r=>r.id===t?{...r,...i}:r)}))},addCommand:t=>{e(i=>({commandHistory:[...i.commandHistory,t]}))},clearEntries:()=>{e({entries:[],commandHistory:[]})},setInitialized:t=>{e({isInitialized:t})}}));function X_({isOpen:e,onClose:t}){const i=$a(),s=wt(n=>n.stats),r=n=>{const o=i.find(a=>a.id===n);o&&Ia(o,s)};return m.jsxs(Ro,{open:e,onClose:t,size:"sm",children:[m.jsx(Bo,{icon:m.jsx(jr,{size:20}),title:"Download Captures",onClose:t}),m.jsx(Mo,{className:"flex flex-col gap-2",children:i.length===0?m.jsxs("div",{className:"flex flex-col items-center gap-2 py-6 text-fg-muted",children:[m.jsx(Bl,{className:"w-8 h-8 opacity-40"}),m.jsx("p",{className:"text-sm",children:"No captures available."})]}):i.map(n=>m.jsxs("div",{className:"flex items-center gap-3 px-4 py-3 radius-inset bg-elevated/50 border border-edge-subtle",children:[m.jsxs("div",{className:"flex-1 min-w-0",children:[m.jsx("p",{className:"type-label text-fg-primary truncate",children:n.filename}),m.jsxs("p",{className:"text-xs text-fg-muted mt-0.5",children:[n.packetCount," packets · ",n.durationSec,"s · ~",Ji(n.sizeBytes)]})]}),m.jsx(sl,{plain:!0,color:"primary",onClick:()=>r(n.id),title:"Download",className:"flex-shrink-0",children:m.jsx(jr,{"data-slot":"icon"})})]},n.id))})]})}function J_(){const e=$a(),[t,i]=U.useState(!1);return m.jsxs(m.Fragment,{children:[m.jsx($o,{icon:m.jsx(El,{size:20}),onClick:()=>i(!0),title:e.length>0?`Download captures (${e.length})`:"Captures",variant:"red",iconActiveColor:pe.red}),m.jsx(X_,{isOpen:t,onClose:()=>i(!1)})]})}const go=[{name:"acl",description:"Access control list statistics — identity and client counts.",body:["```","> acl","ACL Stats",""," Identities 2"," Total clients 5"," Admin 2"," Guest 3"," Repeater 1 ids 3 clients"," Room Server 1 ids 2 clients","```"],searchText:"acl access control list statistics identity client"},{name:"advert",description:"Broadcast a repeater advertisement to the mesh.",body:["```","> advert","✓ Advert sent","```"],searchText:"advert advertisement broadcast mesh"},{name:"board",description:"Hardware and platform info — CPU, memory, disk, temperatures, network I/O.",body:["```","> board"," Node Local-Node"," Runtime pyMC_Repeater v1.0.0"," Core v1.12.0",""," CPU 12.3% 4 cores"," Load 0.42 / 0.38 / 0.35"," Temp 48.2°C",""," Memory 412 MB / 664 MB 62%"," Disk 5.2 GB / 28.7 GB 18%",""," System uptime 14d 3h 22m"," Service uptime 2d 14h 32m"," Net TX/RX 128 MB / 342 MB","```"],searchText:"board hardware platform cpu memory disk temperature network"},{name:"cap",description:"Packet capture — start, stop, list, and export captures.",body:["**Sub-commands:** `start cap [sec]` · `end cap` · `list cap` · `export cap [id]`","","**`start cap [seconds]`** — Begin capture (default 120s, max 3600):","```","> start cap","Capturing... 118s remaining (4 captured)","","✓ Capture complete!"," Captured: 23 packets"," Duration: 120s"," Size: ~14.2 KB","```","","**`end cap`** — Stop capture early:","```","> end cap","✓ Capture stopped!"," Captured: 12 packets","```","","**`list cap`** — List saved captures:","```","> list cap","Capture Reports (2):"," 1. 23 pkts • 120s • ~14.2 KB (id: abc123)"," 2. 12 pkts • 34s • ~7.1 KB (id: def456)","```","","**`export cap [id]`** — Download by ID or index:","```","> export cap 1","✓ Downloading capture-abc123.json...","```"],searchText:"cap capture packet start end list export download diagnostic"},{name:"clear",description:"Clear the terminal screen.",body:["**Alias:** `cls`","```","> clear","```"],searchText:"clear cls screen"},{name:"clock",description:"Current system UTC time. Useful for NTP sync and packet timestamp correlation.",body:["```","> clock"," UTC Wed, 12 Feb 2026 00:01:34 GMT"," ISO 2026-02-12T00:01:34.000Z"," Unix 1770768094","```"],searchText:"clock time utc ntp unix iso timestamp"},{name:"convert",description:"Convert between hex and base64 encodings.",body:["**Usage:** `convert hex ` · `convert base64 `","```","> convert hex 48656C6C6F"," hex 48656C6C6F"," base64 SGVsbG8=","","> convert base64 SGVsbG8="," base64 SGVsbG8="," hex 48656C6C6F","```"],searchText:"convert hex base64 encoding decode"},{name:"get",description:"Read a configuration parameter.",body:[],interactive:"get",searchText:"get read config parameter name role lat lon radio freq tx bw sf cr txdelay mode duty flood advert"},{name:"help",description:"Show all commands, or detailed help for a specific command.",body:["**Alias:** `?` · `h`","```","> help Full command listing","> help ping Detailed help for ping","> ping help Same thing","```"],searchText:"help commands reference guide"},{name:"identities",description:"List all configured repeater and room server identities.",body:["**Alias:** `id` · `ids`","```","> identities","Identities (2)",""," 1. Local-Node repeater 0A1B2C3D"," 2. local-room room_server 0E5F6A7B","```"],searchText:"identities id ids repeater room server identity"},{name:"keys",description:"List configured transport encryption keys.",body:["```","> keys","Transport Keys (1)",""," main-transport flood: allow","```"],searchText:"keys transport encryption"},{name:"neighbors",description:"Direct RF neighbors with signal quality, RSSI, SNR, distance, and last-heard.",body:["**Alias:** `nb`","","**Sort qualifiers:** `sig` · `name` · `rssi` · `snr` · `dist` · `heard`","```","> neighbors","Direct Neighbors (4)","","+-------+-----------+-----------+--------+-------+--------+","| ▁▃▅▇█ | Node-1 | -87 dBm | 8.5 dB | 2.1km | 3m ago |","| ▁▃▅▇. | Relay-2 | -94 dBm | 5.2 dB | 4.8km | 1m ago |","| ▁▃▅.. | Node-3 | -108 dBm | 1.0 dB | 8.3km | 5m ago |","| ▁▃... | Node-4 | -118 dBm | -3 dB | 14km | 12m ago|","+-------+-----------+-----------+--------+-------+--------+","| SIG | NAME | RSSI | SNR | DIST | HEARD |","+-------+-----------+-----------+--------+-------+--------+","SF11/250kHz ant 3.5dBi nf -112dBm","```","","- **sig** — signal grade (weakest first)","- **name** — alphabetical","- **rssi** — RSSI (weakest first)","- **snr** — SNR (lowest first)","- **dist** — distance (closest first)","- **heard** — last seen (oldest first)"],searchText:"neighbors nb signal rssi snr distance sort direct rf"},{name:"packets",description:"Packet counters — received, transmitted, forwarded, dropped.",body:["```","> packets","Packet Stats 1321 total",""," Received 1284"," Transmitted 37"," Forwarded 891"," Dropped 14","```"],searchText:"packets received transmitted forwarded dropped counter"},{name:"ping",description:"Ping a neighbor by name or hex prefix. Shows RTT, signal quality, and path.",body:["**Usage:** `ping [timeout]`","```","> ping Node-1","▁▃▅▇█ Reply from Node-1",""," RTT 342ms"," RSSI -87 dBm"," SNR 8.5 dB"," Path direct"," Quality Excellent","```","","Custom timeout (default 30s):","```","> ping Node-4 60","```"],searchText:"ping rtt round trip time signal quality path neighbor"},{name:"restart",description:"Restart the pymc-repeater systemd service.",body:["**Alias:** `reboot`","```","> restart","Service is restarting (connection dropped).","Waiting for service... 8s","Service connected. (12s)","```","","The terminal polls automatically until the service comes back up."],searchText:"restart reboot service systemd"},{name:"rooms",description:"Room server statistics — message counts, active clients, sync status.",body:["```","> rooms","Rooms (1)",""," Local Room"," msgs 142 clients 3/5 sync running","```"],searchText:"rooms room server messages clients sync"},{name:"set",description:"Write a configuration parameter.",body:[],interactive:"set",searchText:"set write config parameter name lat lon freq tx bw sf cr txdelay mode duty log flood advert"},{name:"stats-core",description:"Engine vitals — uptime, duplicate cache, CPU, memory, temperature.",body:["```","> stats-core"," Core Stats",""," Uptime 2d 14h 32m"," Dup cache 128 entries TTL 900s",""," CPU 12.3% 4 cores"," Load 0.42 / 0.38 / 0.35"," Memory 412 MB / 664 MB 62%"," Temp 48.2°C","```"],searchText:"stats core engine vitals uptime cache cpu memory temperature"},{name:"stats-packets",description:"Firmware-compatible packet counters with rates and duplicate cache depth.",body:["```","> stats-packets"," Packet Counters",""," RX 1284 22.4/hr"," TX 37"," Forwarded 891 15.2/hr"," Dropped 14",""," Dup cache 128","```"],searchText:"stats packets firmware counter rate duplicate cache"},{name:"stats-radio",description:"Radio health — noise floor, airtime, duty cycle, and radio configuration.",body:["```","> stats-radio"," Radio Stats",""," Radio 906.875 MHz SF11 BW 250 kHz CR 4/5 22 dBm",""," Noise floor -112 dBm"," Airtime used 4.2s remaining: 55.8m"," Total airtime 1.2m"," Duty cycle 1.2%"," Utilization 0.8%","```"],searchText:"stats radio noise floor airtime duty cycle utilization"},{name:"status",description:"Quick summary of mode, neighbors, and uptime.",body:["**Alias:** `st`","```","> status","Local-Node repeater",""," Mode forward"," Neighbors 4 direct 12 total"," RX / TX 1284 / 37"," Uptime 2d 14h 32m","```"],searchText:"status st summary mode neighbors uptime"},{name:"top",description:"Live-updating system overview — CPU/memory gauges, mesh counters, processes.",body:["**Alias:** `htop`","","Refreshes every 3s. Press **Ctrl+C** to exit.","```","> top","Local-Node v1.0.0","──────────────────────────────────"," Sys 14d 3h 22m Svc 2d 14h 32m Load 0.42 0.38 0.35",""," CPU [████░░░░░░░░░░░░] 12.3% 4 cores"," Mem [██████████░░░░░░] 62.1% 412M/664M"," Dsk [███░░░░░░░░░░░░░] 18.4% 5.2G/28.7G"," cpu_thermal: 48.2°C",""," MESH"," Mode forward Nbrs 4/12 Noise -112dBm Air 1.2%"," RX 1284 TX 37 FWD 891 Drop 14"," RX/h 22 FWD/h 15",""," PROCS"," CPU MEM NAME"," 8.2 3.1 python3"," 2.1 1.4 cherrypy",""," 14:32:08 · Ctrl+C to exit","```","","Uses alternate screen buffer — scrollback is preserved."],searchText:"top htop live system overview cpu memory gauges mesh processes"},{name:"uptime",description:"How long the repeater service has been running.",body:["```","> uptime","Uptime 2d 14h 32m","```"],searchText:"uptime service running duration"},{name:"ver",description:"Version info for all three components.",body:["**Alias:** `version`","```","> ver"," pyMC_Repeater v1.0.0"," pyMC_Core v1.12.0"," pyMC_Console v1.0.0","```"],searchText:"ver version pymc repeater core console"}],Z_=[{param:"name",category:"Identity",example:["> get name","name Local-Node"]},{param:"role",category:"Identity",example:["> get role","role repeater"]},{param:"lat",category:"Identity",example:["> get lat","lat 34.0522"],range:"-90 to 90"},{param:"lon",category:"Identity",example:["> get lon","lon -118.2437"],range:"-180 to 180"},{param:"public.key",category:"Identity",example:["> get public.key","public.key 0A1B2C3D4E5F..."]},{param:"radio",category:"Radio",example:["> get radio"," freq 906.875 MHz"," bw 250 kHz"," sf 11"," cr 4/5"," tx 22 dBm"]},{param:"freq",category:"Radio",example:["> get freq","freq 906.875 MHz"],range:"100–1000 MHz"},{param:"tx",category:"Radio",example:["> get tx","tx 22 dBm"],range:"2–22 dBm"},{param:"bw",category:"Radio",example:["> get bw","bw 250 kHz"],range:"7.8–500 kHz"},{param:"sf",category:"Radio",example:["> get sf","sf 11"],range:"5–12"},{param:"cr",category:"Radio",example:["> get cr","cr 4/5"],range:"5–8"},{param:"af",category:"Timing",example:["> get af","⚠ airtime_factor not yet exposed by pyMC_Repeater API."," Firmware range: 0-9. Tracked in CLI-Alignment.md."],range:"0–9 (pending)"},{param:"txdelay",category:"Timing",example:["> get txdelay","txdelay 1.0"],range:"0.0–5.0"},{param:"direct.txdelay",category:"Timing",example:["> get direct.txdelay","direct.txdelay 0.5"],range:"0.0–5.0"},{param:"rxdelay",category:"Timing",example:["> get rxdelay","rxdelay 0.0"],range:"≥ 0"},{param:"mode",category:"Repeater",example:["> get mode","mode forward"],range:"forward / monitor"},{param:"duty",category:"Repeater",example:["> get duty","duty on"],range:"on / off"},{param:"flood.max",category:"Repeater",example:["> get flood.max","flood.max 3"],range:"0–64"},{param:"advert.interval",category:"Repeater",example:["> get advert.interval","advert.interval 120m"],range:"0 (off) or 1–10080 min"},{param:"multi.acks",category:"Advanced",example:["> get multi.acks","multi.acks 0"],range:"0–255"},{param:"int.thresh",category:"Advanced",example:["> get int.thresh","int.thresh -120 dBm"],range:"-200 to 0 dBm"},{param:"agc.reset.interval",category:"Advanced",example:["> get agc.reset.interval","agc.reset.interval 0"],range:"≥ 0 (×4)"}],Q_=[{param:"name",category:"Identity",example:["> set name Local-Node","OK - node_name set to Local-Node"],range:"text (no [ ] \\ / : , ? *)"},{param:"lat",category:"Identity",example:["> set lat 34.0522","OK - latitude set to 34.0522"],range:"-90 to 90"},{param:"lon",category:"Identity",example:["> set lon -118.2437","OK - longitude set to -118.2437"],range:"-180 to 180"},{param:"freq",category:"Radio",example:["> set freq 906.875","OK - frequency set to 906875000"],range:"100–1000 MHz"},{param:"tx",category:"Radio",example:["> set tx 22","OK - tx_power set to 22"],range:"2–22 dBm"},{param:"bw",category:"Radio",example:["> set bw 250","OK - bandwidth set to 250000"],range:"7.8, 10.4, 15.6, 20.8, 31.25, 41.7, 62.5, 125, 250, 500 kHz"},{param:"sf",category:"Radio",example:["> set sf 11","OK - spreading_factor set to 11"],range:"5–12"},{param:"cr",category:"Radio",example:["> set cr 5","OK - coding_rate set to 5"],range:"5–8"},{param:"af",category:"Timing",example:["> set af 2","⚠ airtime_factor not yet exposed by pyMC_Repeater API."," Firmware range: 0-9. Needs backend support."],range:"0–9 (pending)"},{param:"txdelay",category:"Timing",example:["> set txdelay 1.0","OK - tx_delay_factor set to 1"],range:"0.0–5.0"},{param:"direct.txdelay",category:"Timing",example:["> set direct.txdelay 0.5","OK - direct_tx_delay_factor set to 0.5"],range:"0.0–5.0"},{param:"rxdelay",category:"Timing",example:["> set rxdelay 0","OK - rx_delay_base set to 0"],range:"≥ 0"},{param:"mode",category:"Repeater",example:["> set mode forward","OK - Mode set to forward"],range:"forward / monitor"},{param:"flood.max",category:"Repeater",example:["> set flood.max 3","OK - max_flood_hops set to 3"],range:"0–64"},{param:"advert.interval",category:"Repeater",example:["> set advert.interval 120","OK - Local advert interval set to 120m"],range:"0 (off) or 1–10080 min"},{param:"duty",category:"Repeater",example:["> set duty on","OK - Duty cycle enabled"],range:"on / off"},{param:"log",category:"Repeater",example:["> set log info","OK - Log level set to INFO"],range:"debug, info, warning, error"},{param:"multi.acks",category:"Advanced",example:["> set multi.acks 0","OK - multi_acks set to 0"],range:"0–255"},{param:"int.thresh",category:"Advanced",example:["> set int.thresh -120","OK - interference_threshold set to -120"],range:"-200 to 0 dBm"},{param:"agc.reset.interval",category:"Advanced",example:["> set agc.reset.interval 8","OK - AGC reset interval set to 8"],range:"≥ 0 (rounded to ×4)"},{param:"prv.key",category:"Advanced",example:["> set prv.key <128-hex>","To set this key, run on the Pi:",""," sudo ./convert_firmware_key.sh ","","Then restart: sudo systemctl restart pymc-repeater"],range:"128-char hex (SSH only)"}];function ef({mode:e}){const t=e==="get"?Z_:Q_,[i,s]=U.useState(0),r=t[i],n=U.useMemo(()=>{const o=new Map;for(const a of t){const h=o.get(a.category)||[];h.push(a),o.set(a.category,h)}return Array.from(o.entries())},[t]);return m.jsxs("div",{className:"flex flex-col gap-2",children:[m.jsx("div",{className:"flex flex-col gap-1.5",children:n.map(([o,a])=>m.jsxs("div",{className:"flex flex-wrap items-center gap-1",children:[m.jsx("span",{className:"text-xs text-fg-muted w-16 shrink-0 text-right pr-1",children:o}),a.map(h=>{const l=t.indexOf(h),c=l===i;return m.jsx("button",{onClick:()=>s(l),className:es("px-1.5 py-0.5 type-data-xs radius-badge transition-colors cursor-pointer",c?"bg-sys-blue text-fg-invert font-semibold":"bg-elevated text-fg-secondary hover:bg-elevated/80 hover:text-sys-blue"),children:h.param},h.param)})]},o))}),m.jsx("pre",{className:"px-3 py-2.5 radius-inner bg-body text-fg-secondary type-code overflow-x-auto border border-edge-subtle",children:r.example.map((o,a)=>m.jsx("div",{children:o||" "},a))}),r.range&&m.jsxs("p",{className:"text-xs text-fg-muted",children:[m.jsx("span",{className:"text-fg-secondary font-medium",children:r.param})," — ",r.range]})]})}function vo(e,t){const i=e.split(/(\*\*[^*]+\*\*)/g);return m.jsx("span",{children:i.map((s,r)=>s.startsWith("**")&&s.endsWith("**")?m.jsx("strong",{className:"text-fg-primary font-semibold",children:s.slice(2,-2)},r):s.split(/(`[^`]+`)/g).map((o,a)=>o.startsWith("`")&&o.endsWith("`")?m.jsx("code",{className:"px-1 py-0.5 radius-badge bg-elevated text-sys-blue type-data-xs",children:o.slice(1,-1)},`${r}-${a}`):m.jsx("span",{children:o},`${r}-${a}`)))},t)}function tf({lines:e}){const t=[];let i=0;for(;im.jsx("div",{children:n||" "},o))},t.length));continue}if(!s.trim()){t.push(m.jsx("div",{className:"h-1.5"},t.length)),i++;continue}if(s.startsWith("- ")){t.push(m.jsxs("div",{className:"flex gap-2 text-sm text-fg-secondary pl-2 py-0.5",children:[m.jsx("span",{className:"text-fg-muted shrink-0",children:"•"}),m.jsx("span",{children:vo(s.slice(2),0)})]},t.length)),i++;continue}t.push(m.jsx("p",{className:"text-sm text-fg-secondary py-0.5",children:vo(s,0)},t.length)),i++}return m.jsx(m.Fragment,{children:t})}function sf({isOpen:e,onClose:t,onUseCommand:i}){const[s,r]=U.useState(""),n=U.useMemo(()=>{if(!s.trim())return go;const a=s.toLowerCase();return go.filter(h=>h.name.includes(a)||h.searchText.includes(a)||h.description.toLowerCase().includes(a))},[s]),o=s.trim().length>0;return m.jsxs(Ro,{open:e,onClose:t,size:"3xl",motionPlus:!0,className:"sm:min-w-[540px] md:min-w-[680px]",children:[m.jsx(Bo,{icon:m.jsx(Ao,{size:20}),title:"Terminal Command Guide",onClose:t}),m.jsxs(Mo,{className:"flex flex-col gap-0 !px-0 !py-0",children:[m.jsx("div",{className:"sticky top-0 z-10 px-5 py-3 border-b border-edge-subtle bg-surface/95 backdrop-blur-sm",children:m.jsxs("div",{className:"relative",children:[m.jsx(Kr,{size:14,className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-fg-muted"}),m.jsx("input",{type:"text",value:s,onChange:a=>r(a.target.value),placeholder:"Search commands...",className:"w-full pl-8 pr-3 py-1.5 text-sm bg-elevated border border-edge-subtle radius-inner text-fg-primary placeholder:text-fg-muted focus:outline-none focus:ring-1 focus:ring-sys-blue/50",autoFocus:!0})]})}),m.jsxs("div",{className:"overflow-y-auto px-5 py-3 h-[420px] sm:h-[520px] md:h-[600px]",children:[m.jsx(_s,{mode:"popLayout",children:n.length===0?m.jsxs(Ti.div,{initial:{opacity:0,scale:.96},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.96},transition:{duration:Ur.normal,ease:zr.easeOut},className:"flex flex-col items-center gap-2 py-10 text-fg-muted",children:[m.jsx(Kr,{className:"w-6 h-6 opacity-40"}),m.jsxs("p",{className:"text-sm",children:['No commands match "',s,'"']})]},"empty"):m.jsx(Ti.div,{initial:!1,className:"flex flex-col gap-1",children:m.jsx(_s,{initial:!1,children:n.map(a=>m.jsx(Ti.div,{layout:"position",initial:{opacity:0,y:-4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},transition:rl.fade,className:"min-w-0",children:m.jsx(nl,{children:({open:h})=>m.jsxs("div",{className:es("radius-inner border transition-colors",h?"border-edge-subtle bg-elevated/50":"border-transparent hover:bg-elevated/30"),children:[m.jsxs("div",{className:"flex items-center w-full min-w-0",children:[m.jsxs(ol,{className:"flex items-center gap-3 flex-1 min-w-0 px-3 py-2 text-left cursor-pointer",children:[m.jsx(bl,{size:14,className:es("shrink-0 text-fg-muted transition-transform duration-150",h&&"rotate-90")}),m.jsx("code",{className:"text-sm font-semibold text-sys-blue font-mono shrink-0",children:a.name}),m.jsx("span",{className:"text-xs text-fg-muted truncate min-w-0",children:a.description})]}),i&&m.jsx("button",{onClick:l=>{l.stopPropagation(),i(a.name)},className:"shrink-0 mr-2 px-2 py-0.5 text-xs font-semibold uppercase tracking-wider radius-badge bg-elevated text-fg-muted hover:text-sys-blue hover:bg-elevated/80 transition-colors cursor-pointer",title:`Use "${a.name}" in terminal`,children:"use"})]}),m.jsx(al,{className:"px-3 pb-3 pt-0 pl-9",children:a.interactive?m.jsx(ef,{mode:a.interactive}):m.jsx(tf,{lines:a.body})})]})})},a.name))})},"list")}),m.jsx(_s,{children:!o&&m.jsxs(Ti.div,{initial:{opacity:0,y:6},animate:{opacity:1,y:0},exit:{opacity:0,y:6},transition:{duration:Ur.normal,ease:zr.easeOut},className:"mt-4 px-3 py-3 radius-inner border border-edge-subtle bg-elevated/30",children:[m.jsx("p",{className:"text-xs font-semibold text-fg-muted mb-2",children:"Tips"}),m.jsxs("div",{className:"flex flex-col gap-1 text-xs text-fg-muted",children:[m.jsxs("p",{children:["Type ",m.jsx("code",{className:"px-1 py-0.5 radius-badge bg-elevated text-sys-blue font-mono",children:" help"})," in the terminal for detailed usage."]}),m.jsxs("p",{children:["Most commands have shorter aliases (e.g. ",m.jsx("code",{className:"px-1 py-0.5 radius-badge bg-elevated text-sys-blue font-mono",children:"st"}),", ",m.jsx("code",{className:"px-1 py-0.5 radius-badge bg-elevated text-sys-blue font-mono",children:"nb"}),", ",m.jsx("code",{className:"px-1 py-0.5 radius-badge bg-elevated text-sys-blue font-mono",children:"id"}),")."]}),m.jsxs("p",{children:["Signal bars ",m.jsx("span",{className:"font-mono",children:"▁▃▅▇█"})," are colored by link quality grade based on RSSI, SNR, and radio config."]}),m.jsx("p",{children:"Captures are stored in browser session only — export before closing the tab."})]})]})})]})]})]})}function rf({onUseCommand:e}){const[t,i]=U.useState(!1),s=e?r=>{i(!1),e(r)}:void 0;return m.jsxs(m.Fragment,{children:[m.jsx($o,{icon:m.jsx(Ao,{size:17,className:"translate-y-px"}),onClick:()=>i(!0),title:"CLI Command Guide"}),m.jsx(sf,{isOpen:t,onClose:()=>i(!1),onUseCommand:s})]})}const Wa=G_(),Zi=Wa.all().flatMap(e=>[{cmd:e.name,desc:e.description,params:e.params,required:!!e.params},...e.aliases.filter(t=>t.includes(" ")).map(t=>({cmd:t,desc:e.description,params:e.params,required:!!e.params}))]);Zi.push({cmd:"start cap",desc:"Start packet capture",params:"[seconds]",required:!0},{cmd:"end cap",desc:"Stop capture"},{cmd:"list cap",desc:"List captures"},{cmd:"export cap",desc:"Download capture",params:"[id]",required:!0});const Hi=["sig","name","rssi","snr","dist","heard"],nf={get:["name","role","lat","lon","radio","freq","tx","bw","sf","cr","af","txdelay","direct.txdelay","rxdelay","mode","repeat","flood.max","flood.advert.interval","advert.interval","duty","duty.max","multi.acks","int.thresh","agc.reset.interval","public.key","prv.key"],set:["name","lat","lon","freq","tx","bw","sf","cr","af","txdelay","direct.txdelay","rxdelay","mode","repeat","flood.max","flood.advert.interval","advert.interval","duty","log","multi.acks","int.thresh","agc.reset.interval","prv.key"],convert:["hex","base64"],neighbors:Hi,nb:Hi,"get neighbors":Hi,"get neighbor":Hi,"set mode":["forward","monitor"],"set duty":["on","off"],"set repeat":["on","off"],"set tx":["10","14","17","20","22"],"set sf":["7","8","9","10","11","12"],"set bw":["125","250","500"],"set cr":["5","6","7","8"],"set af":["0.5","1.0","1.5","2.0"],"set txdelay":["0.5","0.7","1.0","1.5"],"set direct.txdelay":["0.3","0.5","0.7"],"set log":["debug","info","warning","error"],"start cap":["30","60","120","300"]},Ns=["@@@@@@@ @@@ @@@ @@@@@@@@@@ @@@@@@@ ","@@@@@@@@ @@@ @@@ @@@@@@@@@@@ @@@@@@@@ ","@@! @@@ @@! !@@ @@! @@! @@! !@@ ","!@! @!@ !@! @!! !@! !@! !@! !@! ","@!@@!@! !@!@! @!! !!@ @!@ !@! ","!!@!!! @!!! !@! ! !@! !!! ","!!: !!: !!: !!: :!! ",":!: :!: :!: :!: :!: "," :: :: ::: :: ::: ::: "," : : : : :: :: : "];function ci(){return/Android|iPhone|iPad|iPod/i.test(navigator.userAgent)||window.innerWidth<640}function of(e,t){const i=e.toLowerCase(),s=i.trim();if(!s)return[];const r=i.length>s.length&&i.endsWith(" ");if(!s.includes(" ")&&!r)return Zi.filter(h=>h.cmd.toLowerCase().startsWith(s));const n=r?s:s.substring(0,s.lastIndexOf(" ")),o=r?"":s.substring(s.lastIndexOf(" ")+1);if(n==="ping"&&t.length>0)return t.filter(h=>h.toLowerCase().startsWith(o)).slice(0,10).map(h=>({cmd:`ping ${h}`,desc:`→ ${h}`}));const a=nf[n];if(a){const h=a.filter(l=>l.toLowerCase().startsWith(o)).map(l=>({cmd:`${n} ${l}`,desc:`→ ${l}`}));if(!r&&o){const l=new Set(h.map(c=>c.cmd));for(const c of Zi){const d=c.cmd.toLowerCase();d.startsWith(s)&&!l.has(d)&&(h.push(c),l.add(d))}}return h}return Zi.filter(h=>h.cmd.toLowerCase().startsWith(s))}function Cf(){const e=ll(),{addCommand:t}=mo(),i=U.useRef(null),s=U.useRef(null),r=U.useRef(null),n=U.useRef(null),o=U.useRef(""),a=U.useRef(-1),h=U.useRef(""),l=U.useRef(!1),c=U.useRef(null),d=U.useRef(!1),u=U.useRef(!1),f=U.useRef(!1),_=U.useRef([]),p=U.useRef(()=>{}),g=hl(),[E,z]=U.useState("C0dE"),[O,M]=U.useState(!1),$=U.useRef(null),K=7,ae=280,ne="C0dE",J=U.useCallback(C=>{$.current&&(clearInterval($.current),$.current=null);const P=ne.padEnd(K),H=P+" "+C+" "+P;let q=0;const I=H.length-K;M(!0),z(H.slice(0,K)),$.current=setInterval(()=>{if(q++,q>I){clearInterval($.current),$.current=null,M(!1),z(ne);return}z(H.slice(q,q+K))},ae)},[]);U.useEffect(()=>{const C=I_(J),P=setInterval(()=>{Math.random()<.02&&J(Hr())},45e3);return()=>{C(),clearInterval(P),$.current&&clearInterval($.current)}},[J]);const[Fe,Y]=U.useState(!1),N=U.useRef(null);U.useEffect(()=>{const C=H_(()=>{N.current&&clearTimeout(N.current),Y(!0),N.current=setTimeout(()=>Y(!1),5e3)});return()=>{C(),N.current&&clearTimeout(N.current)}},[]);const[S,L]=U.useState({show:!1,options:[],selectedIndex:0,input:""}),x=U.useRef([]),A=U.useRef(0);U.useEffect(()=>{e!=null&&e.neighbors&&(_.current=Object.values(e.neighbors).map(C=>C.node_name||C.name).filter(C=>!!C).sort())},[e==null?void 0:e.neighbors]);const F=U.useCallback(()=>{var C;(C=s.current)==null||C.write(Qd(cl()))},[]),B=U.useCallback(()=>{const C=s.current;C&&(C.write(Fi),F(),C.write(o.current))},[F]),X=U.useCallback(C=>{const P=of(C,_.current);x.current=P,A.current=0;const H=P.length>0&&C.trim().length>0;L({show:H,options:P,selectedIndex:0,input:C.trim()})},[]),te=U.useCallback(()=>{x.current=[],A.current=0,L({show:!1,options:[],selectedIndex:0,input:""})},[]),He=U.useCallback(C=>{var H;const P=x.current[C];P&&(o.current=P.required?P.cmd+" ":P.cmd,B(),P.required?X(o.current):te(),(H=s.current)==null||H.focus())},[B,X,te]),Qe=U.useCallback(async C=>{const P=s.current;if(!P)return;const H=C.trim();if(!H){F();return}l.current=!0;const q=new AbortController;c.current=q,t(H),a.current=-1;let I=0;const ie={get cols(){return P.cols},get rows(){return P.rows},write(se,xe="default"){const ti=(xe==="default"?se:Wn(se,xe)).split(` -`);for(const Bt of ti)P.writeln(Bt);return I=yr(ti,P.cols),String(I)},update(se,xe,ei){if(f.current)P.write(nu);else if(I>0)for(let Ft=0;Ft{const P=s.current;if(!P||!u.current)return;if(l.current){for(let I=0;IrequestAnimationFrame(()=>{var ie;return(ie=document.querySelector(`[data-ac-index="${I}"]`))==null?void 0:ie.scrollIntoView({block:"nearest"})});for(let I=0;I0){const se=x.current[A.current];se&&(o.current=se.cmd,B())}te();const Ce=o.current;o.current="",P.writeln(""),Qe(Ce);continue}if(ie===127||ie===8){o.current.length>0&&(o.current=o.current.slice(0,-1),P.write("\b \b"),X(o.current));continue}if(ie===3){o.current="",te(),P.writeln("^C"),F();continue}if(ie===12){P.clear(),te(),B();continue}if(ie===9){x.current.length>0&&He(A.current);continue}if(ie===27){if(C.charCodeAt(I+1)===91){const Ce=C.charCodeAt(I+2);if(I+=2,Ce===65){if(x.current.length>0){const se=Math.max(A.current-1,0);A.current=se,L(xe=>({...xe,selectedIndex:se})),q(se)}else H.length>0&&(a.current===-1&&(h.current=o.current),a.current0){const se=Math.min(A.current+1,x.current.length-1);A.current=se,L(xe=>({...xe,selectedIndex:se})),q(se)}else a.current>0?(a.current--,o.current=H[H.length-1-a.current]||"",B()):a.current===0&&(a.current=-1,o.current=h.current,B());continue}if(Ce===67||Ce===68)continue;continue}x.current.length>0&&te();continue}ie>=32&&(o.current+=C[I],P.write(C[I]),a.current=-1,X(o.current))}},[te,X,He,F,B,Qe]);U.useEffect(()=>{p.current=le},[le]);const Te=U.useCallback(async()=>{const C=s.current;if(!C||d.current)return;d.current=!0;const P="\x1B[94m",H="\x1B[0m",q=Ns.length,I=To-1;try{const Ce=gi(Ns,0);for(const se of Ce)C.writeln(se);await new Promise(se=>{let xe=0;const ei=setInterval(()=>{if(xe>=I){clearInterval(ei),se();return}xe++,C.write(`\x1B[${q}F`);const ti=gi(Ns,xe);for(const Bt of ti)C.write(`\x1B[2K${Bt} -`)},Do)})}finally{Lo()}C.writeln(""),C.write(b("● Initializing terminal...")),await new Promise(Ce=>setTimeout(Ce,300)),C.write(Fi),C.writeln(`${P}✓ Initializing terminal...${H}`),C.write(b("● Connecting to repeater...")),await new Promise(Ce=>setTimeout(Ce,500)),C.write(Fi),dl.getState().health==="connected"?C.writeln(`${P}✓ Connected to repeater${H}`):C.writeln(Zd("~ Connection status unknown")),C.writeln(b("Ready. Type 'help' for commands.")),C.writeln(""),F(),u.current=!0},[F]);U.useEffect(()=>{const C=i.current;if(!C)return;const P=ci()?12:13,H=new Id({theme:Ra(),fontFamily:'"JetBrains Mono", "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace',fontSize:P,lineHeight:ci()?1.1:.65,cursorBlink:!1,cursorStyle:"underline",scrollback:1e4,convertEol:!0,allowTransparency:!0,rightClickSelectsWord:!1}),q=new Hd;H.loadAddon(q),H.loadAddon(new qd),H.open(C),q.fit(),s.current=H,r.current=q;const I=H.onData(se=>p.current(se)),ie=uu(H),Ce=new ResizeObserver(()=>{requestAnimationFrame(()=>q.fit())});return Ce.observe(C),Te(),ci()||H.focus(),()=>{var se;(se=c.current)==null||se.abort(),f.current&&(H.write(jn+Un),f.current=!1),I.dispose(),ie(),Ce.disconnect(),H.dispose(),s.current=null,r.current=null}},[]);const Ve=U.useCallback(C=>{const P=C.target.value;P.length>0&&(le(P),C.target.value="")},[le]),We=U.useCallback(C=>{C.key==="Enter"?(C.preventDefault(),le("\r")):C.key==="Backspace"?(C.preventDefault(),le("")):C.key==="ArrowUp"?(C.preventDefault(),le("\x1B[A")):C.key==="ArrowDown"&&(C.preventDefault(),le("\x1B[B"))},[le]),dt=U.useCallback(()=>{var C,P;ci()?(C=n.current)==null||C.focus():(P=s.current)==null||P.focus()},[]);U.useEffect(()=>{if(!ci())return;const C=()=>{var I;const q=(I=i.current)==null?void 0:I.querySelector(".xterm-viewport");q&&(q.scrollTop=q.scrollHeight),requestAnimationFrame(()=>{var ie;return(ie=r.current)==null?void 0:ie.fit()})},P=window.visualViewport;if(P){const q=()=>{P.heightP.removeEventListener("resize",q)}const H=n.current;if(H){const q=()=>setTimeout(C,300);return H.addEventListener("focus",q),()=>H.removeEventListener("focus",q)}},[]);const Qt=U.useCallback(C=>{o.current=C+" ",B(),X(o.current),setTimeout(()=>{var P;(P=i.current)==null||P.click()},400)},[B,X]);return m.jsx(gl,{children:m.jsx(vl,{children:m.jsxs("div",{className:"terminal-card flex flex-col gap-1 sm:gap-1.5",children:[m.jsxs("div",{className:"card-terminal-header flex-wrap",children:[m.jsx("span",{className:"seven-seg-panel",children:m.jsx(yl,{text:E,minChars:7,size:24,noCycle:O})}),m.jsx("div",{className:"header-well self-stretch flex-col sm:order-first",children:m.jsxs("div",{className:`indicator-key${g==="connected"?" indicator-key--active":g==="degraded"?" indicator-key--sending":""}`,children:[m.jsx("span",{className:"indicator-key__label",children:"ONLINE"}),m.jsx("span",{className:"indicator-key__led"})]})}),m.jsx("div",{className:"card-terminal-ridge flex-1 min-w-4 sm:hidden"}),m.jsxs("div",{className:"header-well flex items-center gap-1 sm:order-last",children:[m.jsx(rf,{onUseCommand:Qt}),m.jsx(J_,{})]}),m.jsx("div",{className:"card-terminal-ridge flex-1 min-w-8 hidden sm:block"})]}),m.jsx(Sl,{noPadding:!0,className:"flex flex-col flex-1 min-h-0 overflow-hidden card-terminal",onClick:dt,children:m.jsxs("div",{className:"card-terminal-well flex-1 min-h-0 flex flex-col overflow-hidden",children:[m.jsxs("div",{className:"flex-1 min-h-0 terminal-gutter relative",children:[m.jsx("div",{ref:i,className:"h-full w-full"}),Fe&&m.jsxs("div",{className:"absolute inset-0 z-10 flex items-center justify-center",onClick:()=>Y(!1),children:[m.jsx("div",{className:"absolute inset-0 animate-[partytime-bg_5s_ease-out_forwards]",style:{background:"rgba(0,0,0,0.82)"}}),m.jsxs("div",{className:"relative z-10 animate-[partytime-crt_5s_ease-out_forwards] partytime-glow",children:[m.jsx("img",{src:"/assets/partytime.gif",alt:"No way.",className:"max-h-[60vh] max-w-[70vw] object-contain rounded"}),m.jsx("div",{className:"absolute inset-0 pointer-events-none rounded partytime-scanlines"})]})]})]}),S.show&&S.options.length>0&&m.jsxs("div",{className:"flex-shrink-0 overflow-hidden terminal-completions",style:{borderTop:"1px solid var(--terminal-border)",background:"var(--terminal-bg-input)"},children:[m.jsx("div",{className:"overflow-y-auto",style:{maxHeight:"176px"},children:S.options.map((C,P)=>{const H=P===S.selectedIndex,q=S.input.length;return m.jsxs("div",{"data-ac-index":P,onClick:()=>He(P),className:es("terminal-ac-option",H?"text-sys-blue":"text-fg-primary"),style:{background:H?"var(--terminal-autocomplete-hover)":void 0},onMouseEnter:I=>{H||(I.currentTarget.style.background="var(--terminal-autocomplete-hover)")},onMouseLeave:I=>{H||(I.currentTarget.style.background="")},children:[m.jsx("span",{className:"terminal-ac-option__indicator",children:H?"▸":""}),m.jsxs("span",{className:"terminal-ac-option__cmd",children:[m.jsx("span",{className:"font-semibold text-sys-blue",children:C.cmd.substring(0,q)}),C.cmd.substring(q)]}),m.jsx("span",{className:"terminal-ac-option__desc",children:C.desc})]},C.cmd)})}),m.jsxs("div",{className:"terminal-ac-hints",children:[m.jsx("span",{className:"hidden sm:inline",children:"Tab · ↑↓ · Esc"}),m.jsx("span",{className:"sm:hidden",children:"Tap to select"}),m.jsxs("span",{children:[S.options.length," match",S.options.length!==1?"es":""]})]})]}),m.jsxs("div",{className:"terminal-mobile-input-bar sm:hidden",children:[m.jsx("input",{ref:n,type:"text",className:"terminal-mobile-input",onChange:Ve,onKeyDown:We,autoComplete:"off",autoCorrect:"off",autoCapitalize:"off",spellCheck:!1,enterKeyHint:"send","aria-label":"Terminal input",placeholder:"Type command..."}),m.jsx("button",{type:"button",className:"terminal-send-btn",onClick:()=>le("\r"),"aria-label":"Run command",children:m.jsx(xl,{})})]}),m.jsxs("div",{className:"terminal-status-bar",children:[m.jsx("span",{className:"hidden sm:inline",children:"↑↓ History · Tab · Esc"}),m.jsx("span",{className:"sm:hidden",children:"Tap input to type"}),(e==null?void 0:e.version)&&m.jsxs("span",{children:["pyMC v",e.version]})]})]})})]})})})}export{Cf as default}; +`))},Do);s.addEventListener("abort",()=>{clearInterval(a),o()},{once:!0})})}finally{Lo()}}}function G_(){const e=new Vd,t=new bu(e);return e.register(t,new Cu,new xu,new z_,new U_,new ku,new Eu,new Ru,new j_,new K_,new q_,new Fu,new Yu,new o_,new Xu,new Zu,new a_,new y_,new w_,new b_,new C_,new x_,new k_,new N_,new O_,new W_,new V_),e}const Y_=()=>typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)}),mo=ko(e=>({entries:[],commandHistory:[],isInitialized:!1,addEntry:t=>{const i=Y_(),s={...t,id:i,timestamp:Date.now()};return e(r=>({entries:[...r.entries,s]})),i},updateEntry:(t,i)=>{e(s=>({entries:s.entries.map(r=>r.id===t?{...r,...i}:r)}))},addCommand:t=>{e(i=>({commandHistory:[...i.commandHistory,t]}))},clearEntries:()=>{e({entries:[],commandHistory:[]})},setInitialized:t=>{e({isInitialized:t})}}));function X_({isOpen:e,onClose:t}){const i=$a(),s=bt(n=>n.stats),r=n=>{const o=i.find(a=>a.id===n);o&&Ia(o,s)};return m.jsxs(Ro,{open:e,onClose:t,size:"sm",children:[m.jsx(Bo,{icon:m.jsx(jr,{size:20}),title:"Download Captures",onClose:t}),m.jsx(Mo,{className:"flex flex-col gap-2",children:i.length===0?m.jsxs("div",{className:"flex flex-col items-center gap-2 py-6 text-fg-muted",children:[m.jsx(Bl,{className:"w-8 h-8 opacity-40"}),m.jsx("p",{className:"text-sm",children:"No captures available."})]}):i.map(n=>m.jsxs("div",{className:"flex items-center gap-3 px-4 py-3 radius-inset bg-elevated/50 border border-edge-subtle",children:[m.jsxs("div",{className:"flex-1 min-w-0",children:[m.jsx("p",{className:"type-label text-fg-primary truncate",children:n.filename}),m.jsxs("p",{className:"text-xs text-fg-muted mt-0.5",children:[n.packetCount," packets · ",n.durationSec,"s · ~",Ji(n.sizeBytes)]})]}),m.jsx(sl,{plain:!0,color:"primary",onClick:()=>r(n.id),title:"Download",className:"flex-shrink-0",children:m.jsx(jr,{"data-slot":"icon"})})]},n.id))})]})}function J_(){const e=$a(),[t,i]=U.useState(!1);return m.jsxs(m.Fragment,{children:[m.jsx($o,{icon:m.jsx(El,{size:20}),onClick:()=>i(!0),title:e.length>0?`Download captures (${e.length})`:"Captures",variant:"red",iconActiveColor:pe.red}),m.jsx(X_,{isOpen:t,onClose:()=>i(!1)})]})}const go=[{name:"acl",description:"Access control list statistics — identity and client counts.",body:["```","> acl","ACL Stats",""," Identities 2"," Total clients 5"," Admin 2"," Guest 3"," Repeater 1 ids 3 clients"," Room Server 1 ids 2 clients","```"],searchText:"acl access control list statistics identity client"},{name:"advert",description:"Broadcast a repeater advertisement to the mesh.",body:["```","> advert","✓ Advert sent","```"],searchText:"advert advertisement broadcast mesh"},{name:"board",description:"Hardware and platform info — CPU, memory, disk, temperatures, network I/O.",body:["```","> board"," Node Local-Node"," Runtime pyMC_Repeater v1.0.0"," Core v1.12.0",""," CPU 12.3% 4 cores"," Load 0.42 / 0.38 / 0.35"," Temp 48.2°C",""," Memory 412 MB / 664 MB 62%"," Disk 5.2 GB / 28.7 GB 18%",""," System uptime 14d 3h 22m"," Service uptime 2d 14h 32m"," Net TX/RX 128 MB / 342 MB","```"],searchText:"board hardware platform cpu memory disk temperature network"},{name:"cap",description:"Packet capture — start, stop, list, and export captures.",body:["**Sub-commands:** `start cap [sec]` · `end cap` · `list cap` · `export cap [id]`","","**`start cap [seconds]`** — Begin capture (default 120s, max 3600):","```","> start cap","Capturing... 118s remaining (4 captured)","","✓ Capture complete!"," Captured: 23 packets"," Duration: 120s"," Size: ~14.2 KB","```","","**`end cap`** — Stop capture early:","```","> end cap","✓ Capture stopped!"," Captured: 12 packets","```","","**`list cap`** — List saved captures:","```","> list cap","Capture Reports (2):"," 1. 23 pkts • 120s • ~14.2 KB (id: abc123)"," 2. 12 pkts • 34s • ~7.1 KB (id: def456)","```","","**`export cap [id]`** — Download by ID or index:","```","> export cap 1","✓ Downloading capture-abc123.json...","```"],searchText:"cap capture packet start end list export download diagnostic"},{name:"clear",description:"Clear the terminal screen.",body:["**Alias:** `cls`","```","> clear","```"],searchText:"clear cls screen"},{name:"clock",description:"Current system UTC time. Useful for NTP sync and packet timestamp correlation.",body:["```","> clock"," UTC Wed, 12 Feb 2026 00:01:34 GMT"," ISO 2026-02-12T00:01:34.000Z"," Unix 1770768094","```"],searchText:"clock time utc ntp unix iso timestamp"},{name:"convert",description:"Convert between hex and base64 encodings.",body:["**Usage:** `convert hex ` · `convert base64 `","```","> convert hex 48656C6C6F"," hex 48656C6C6F"," base64 SGVsbG8=","","> convert base64 SGVsbG8="," base64 SGVsbG8="," hex 48656C6C6F","```"],searchText:"convert hex base64 encoding decode"},{name:"get",description:"Read a configuration parameter.",body:[],interactive:"get",searchText:"get read config parameter name role lat lon radio freq tx bw sf cr txdelay mode duty flood advert"},{name:"help",description:"Show all commands, or detailed help for a specific command.",body:["**Alias:** `?` · `h`","```","> help Full command listing","> help ping Detailed help for ping","> ping help Same thing","```"],searchText:"help commands reference guide"},{name:"identities",description:"List all configured repeater and room server identities.",body:["**Alias:** `id` · `ids`","```","> identities","Identities (2)",""," 1. Local-Node repeater 0A1B2C3D"," 2. local-room room_server 0E5F6A7B","```"],searchText:"identities id ids repeater room server identity"},{name:"keys",description:"List configured transport encryption keys.",body:["```","> keys","Transport Keys (1)",""," main-transport flood: allow","```"],searchText:"keys transport encryption"},{name:"neighbors",description:"Direct RF neighbors with signal quality, RSSI, SNR, distance, and last-heard.",body:["**Alias:** `nb`","","**Sort qualifiers:** `sig` · `name` · `rssi` · `snr` · `dist` · `heard`","```","> neighbors","Direct Neighbors (4)","","+-------+-----------+-----------+--------+-------+--------+","| ▁▃▅▇█ | Node-1 | -87 dBm | 8.5 dB | 2.1km | 3m ago |","| ▁▃▅▇. | Relay-2 | -94 dBm | 5.2 dB | 4.8km | 1m ago |","| ▁▃▅.. | Node-3 | -108 dBm | 1.0 dB | 8.3km | 5m ago |","| ▁▃... | Node-4 | -118 dBm | -3 dB | 14km | 12m ago|","+-------+-----------+-----------+--------+-------+--------+","| SIG | NAME | RSSI | SNR | DIST | HEARD |","+-------+-----------+-----------+--------+-------+--------+","SF11/250kHz ant 3.5dBi nf -112dBm","```","","- **sig** — signal grade (weakest first)","- **name** — alphabetical","- **rssi** — RSSI (weakest first)","- **snr** — SNR (lowest first)","- **dist** — distance (closest first)","- **heard** — last seen (oldest first)"],searchText:"neighbors nb signal rssi snr distance sort direct rf"},{name:"packets",description:"Packet counters — received, transmitted, forwarded, dropped.",body:["```","> packets","Packet Stats 1321 total",""," Received 1284"," Transmitted 37"," Forwarded 891"," Dropped 14","```"],searchText:"packets received transmitted forwarded dropped counter"},{name:"ping",description:"Ping a neighbor by name or hex prefix. Shows RTT, signal quality, and path.",body:["**Usage:** `ping [timeout]`","```","> ping Node-1","▁▃▅▇█ Reply from Node-1",""," RTT 342ms"," RSSI -87 dBm"," SNR 8.5 dB"," Path direct"," Quality Excellent","```","","Custom timeout (default 30s):","```","> ping Node-4 60","```"],searchText:"ping rtt round trip time signal quality path neighbor"},{name:"restart",description:"Restart the pymc-repeater systemd service.",body:["**Alias:** `reboot`","```","> restart","Service is restarting (connection dropped).","Waiting for service... 8s","Service connected. (12s)","```","","The terminal polls automatically until the service comes back up."],searchText:"restart reboot service systemd"},{name:"rooms",description:"Room server statistics — message counts, active clients, sync status.",body:["```","> rooms","Rooms (1)",""," Local Room"," msgs 142 clients 3/5 sync running","```"],searchText:"rooms room server messages clients sync"},{name:"set",description:"Write a configuration parameter.",body:[],interactive:"set",searchText:"set write config parameter name lat lon freq tx bw sf cr txdelay mode duty log flood advert"},{name:"stats-core",description:"Engine vitals — uptime, duplicate cache, CPU, memory, temperature.",body:["```","> stats-core"," Core Stats",""," Uptime 2d 14h 32m"," Dup cache 128 entries TTL 900s",""," CPU 12.3% 4 cores"," Load 0.42 / 0.38 / 0.35"," Memory 412 MB / 664 MB 62%"," Temp 48.2°C","```"],searchText:"stats core engine vitals uptime cache cpu memory temperature"},{name:"stats-packets",description:"Firmware-compatible packet counters with rates and duplicate cache depth.",body:["```","> stats-packets"," Packet Counters",""," RX 1284 22.4/hr"," TX 37"," Forwarded 891 15.2/hr"," Dropped 14",""," Dup cache 128","```"],searchText:"stats packets firmware counter rate duplicate cache"},{name:"stats-radio",description:"Radio health — noise floor, airtime, duty cycle, and radio configuration.",body:["```","> stats-radio"," Radio Stats",""," Radio 906.875 MHz SF11 BW 250 kHz CR 4/5 22 dBm",""," Noise floor -112 dBm"," Airtime used 4.2s remaining: 55.8m"," Total airtime 1.2m"," Duty cycle 1.2%"," Utilization 0.8%","```"],searchText:"stats radio noise floor airtime duty cycle utilization"},{name:"status",description:"Quick summary of mode, neighbors, and uptime.",body:["**Alias:** `st`","```","> status","Local-Node repeater",""," Mode forward"," Neighbors 4 direct 12 total"," RX / TX 1284 / 37"," Uptime 2d 14h 32m","```"],searchText:"status st summary mode neighbors uptime"},{name:"top",description:"Live-updating system overview — CPU/memory gauges, mesh counters, processes.",body:["**Alias:** `htop`","","Refreshes every 3s. Press **Ctrl+C** to exit.","```","> top","Local-Node v1.0.0","──────────────────────────────────"," Sys 14d 3h 22m Svc 2d 14h 32m Load 0.42 0.38 0.35",""," CPU [████░░░░░░░░░░░░] 12.3% 4 cores"," Mem [██████████░░░░░░] 62.1% 412M/664M"," Dsk [███░░░░░░░░░░░░░] 18.4% 5.2G/28.7G"," cpu_thermal: 48.2°C",""," MESH"," Mode forward Nbrs 4/12 Noise -112dBm Air 1.2%"," RX 1284 TX 37 FWD 891 Drop 14"," RX/h 22 FWD/h 15",""," PROCS"," CPU MEM NAME"," 8.2 3.1 python3"," 2.1 1.4 cherrypy",""," 14:32:08 · Ctrl+C to exit","```","","Uses alternate screen buffer — scrollback is preserved."],searchText:"top htop live system overview cpu memory gauges mesh processes"},{name:"uptime",description:"How long the repeater service has been running.",body:["```","> uptime","Uptime 2d 14h 32m","```"],searchText:"uptime service running duration"},{name:"ver",description:"Version info for all three components.",body:["**Alias:** `version`","```","> ver"," pyMC_Repeater v1.0.0"," pyMC_Core v1.12.0"," pyMC_Console v1.0.0","```"],searchText:"ver version pymc repeater core console"}],Z_=[{param:"name",category:"Identity",example:["> get name","name Local-Node"]},{param:"role",category:"Identity",example:["> get role","role repeater"]},{param:"lat",category:"Identity",example:["> get lat","lat 34.0522"],range:"-90 to 90"},{param:"lon",category:"Identity",example:["> get lon","lon -118.2437"],range:"-180 to 180"},{param:"public.key",category:"Identity",example:["> get public.key","public.key 0A1B2C3D4E5F..."]},{param:"radio",category:"Radio",example:["> get radio"," freq 906.875 MHz"," bw 250 kHz"," sf 11"," cr 4/5"," tx 22 dBm"]},{param:"freq",category:"Radio",example:["> get freq","freq 906.875 MHz"],range:"100–1000 MHz"},{param:"tx",category:"Radio",example:["> get tx","tx 22 dBm"],range:"2–22 dBm"},{param:"bw",category:"Radio",example:["> get bw","bw 250 kHz"],range:"7.8–500 kHz"},{param:"sf",category:"Radio",example:["> get sf","sf 11"],range:"5–12"},{param:"cr",category:"Radio",example:["> get cr","cr 4/5"],range:"5–8"},{param:"af",category:"Timing",example:["> get af","⚠ airtime_factor not yet exposed by pyMC_Repeater API."," Firmware range: 0-9. Tracked in CLI-Alignment.md."],range:"0–9 (pending)"},{param:"txdelay",category:"Timing",example:["> get txdelay","txdelay 1.0"],range:"0.0–5.0"},{param:"direct.txdelay",category:"Timing",example:["> get direct.txdelay","direct.txdelay 0.5"],range:"0.0–5.0"},{param:"rxdelay",category:"Timing",example:["> get rxdelay","rxdelay 0.0"],range:"≥ 0"},{param:"mode",category:"Repeater",example:["> get mode","mode forward"],range:"forward / monitor"},{param:"duty",category:"Repeater",example:["> get duty","duty on"],range:"on / off"},{param:"flood.max",category:"Repeater",example:["> get flood.max","flood.max 3"],range:"0–64"},{param:"advert.interval",category:"Repeater",example:["> get advert.interval","advert.interval 120m"],range:"0 (off) or 1–10080 min"},{param:"multi.acks",category:"Advanced",example:["> get multi.acks","multi.acks 0"],range:"0–255"},{param:"int.thresh",category:"Advanced",example:["> get int.thresh","int.thresh -120 dBm"],range:"-200 to 0 dBm"},{param:"agc.reset.interval",category:"Advanced",example:["> get agc.reset.interval","agc.reset.interval 0"],range:"≥ 0 (×4)"}],Q_=[{param:"name",category:"Identity",example:["> set name Local-Node","OK - node_name set to Local-Node"],range:"text (no [ ] \\ / : , ? *)"},{param:"lat",category:"Identity",example:["> set lat 34.0522","OK - latitude set to 34.0522"],range:"-90 to 90"},{param:"lon",category:"Identity",example:["> set lon -118.2437","OK - longitude set to -118.2437"],range:"-180 to 180"},{param:"freq",category:"Radio",example:["> set freq 906.875","OK - frequency set to 906875000"],range:"100–1000 MHz"},{param:"tx",category:"Radio",example:["> set tx 22","OK - tx_power set to 22"],range:"2–22 dBm"},{param:"bw",category:"Radio",example:["> set bw 250","OK - bandwidth set to 250000"],range:"7.8, 10.4, 15.6, 20.8, 31.25, 41.7, 62.5, 125, 250, 500 kHz"},{param:"sf",category:"Radio",example:["> set sf 11","OK - spreading_factor set to 11"],range:"5–12"},{param:"cr",category:"Radio",example:["> set cr 5","OK - coding_rate set to 5"],range:"5–8"},{param:"af",category:"Timing",example:["> set af 2","⚠ airtime_factor not yet exposed by pyMC_Repeater API."," Firmware range: 0-9. Needs backend support."],range:"0–9 (pending)"},{param:"txdelay",category:"Timing",example:["> set txdelay 1.0","OK - tx_delay_factor set to 1"],range:"0.0–5.0"},{param:"direct.txdelay",category:"Timing",example:["> set direct.txdelay 0.5","OK - direct_tx_delay_factor set to 0.5"],range:"0.0–5.0"},{param:"rxdelay",category:"Timing",example:["> set rxdelay 0","OK - rx_delay_base set to 0"],range:"≥ 0"},{param:"mode",category:"Repeater",example:["> set mode forward","OK - Mode set to forward"],range:"forward / monitor"},{param:"flood.max",category:"Repeater",example:["> set flood.max 3","OK - max_flood_hops set to 3"],range:"0–64"},{param:"advert.interval",category:"Repeater",example:["> set advert.interval 120","OK - Local advert interval set to 120m"],range:"0 (off) or 1–10080 min"},{param:"duty",category:"Repeater",example:["> set duty on","OK - Duty cycle enabled"],range:"on / off"},{param:"log",category:"Repeater",example:["> set log info","OK - Log level set to INFO"],range:"debug, info, warning, error"},{param:"multi.acks",category:"Advanced",example:["> set multi.acks 0","OK - multi_acks set to 0"],range:"0–255"},{param:"int.thresh",category:"Advanced",example:["> set int.thresh -120","OK - interference_threshold set to -120"],range:"-200 to 0 dBm"},{param:"agc.reset.interval",category:"Advanced",example:["> set agc.reset.interval 8","OK - AGC reset interval set to 8"],range:"≥ 0 (rounded to ×4)"},{param:"prv.key",category:"Advanced",example:["> set prv.key <128-hex>","To set this key, run on the Pi:",""," sudo ./convert_firmware_key.sh ","","Then restart: sudo systemctl restart pymc-repeater"],range:"128-char hex (SSH only)"}];function ef({mode:e}){const t=e==="get"?Z_:Q_,[i,s]=U.useState(0),r=t[i],n=U.useMemo(()=>{const o=new Map;for(const a of t){const h=o.get(a.category)||[];h.push(a),o.set(a.category,h)}return Array.from(o.entries())},[t]);return m.jsxs("div",{className:"flex flex-col gap-2",children:[m.jsx("div",{className:"flex flex-col gap-1.5",children:n.map(([o,a])=>m.jsxs("div",{className:"flex flex-wrap items-center gap-1",children:[m.jsx("span",{className:"text-xs text-fg-muted w-16 shrink-0 text-right pr-1",children:o}),a.map(h=>{const l=t.indexOf(h),c=l===i;return m.jsx("button",{onClick:()=>s(l),className:es("px-1.5 py-0.5 type-data-xs radius-badge transition-colors cursor-pointer",c?"bg-sys-blue text-fg-invert font-semibold":"bg-elevated text-fg-secondary hover:bg-elevated/80 hover:text-sys-blue"),children:h.param},h.param)})]},o))}),m.jsx("pre",{className:"px-3 py-2.5 radius-inner bg-body text-fg-secondary type-code overflow-x-auto border border-edge-subtle",children:r.example.map((o,a)=>m.jsx("div",{children:o||" "},a))}),r.range&&m.jsxs("p",{className:"text-xs text-fg-muted",children:[m.jsx("span",{className:"text-fg-secondary font-medium",children:r.param})," — ",r.range]})]})}function vo(e,t){const i=e.split(/(\*\*[^*]+\*\*)/g);return m.jsx("span",{children:i.map((s,r)=>s.startsWith("**")&&s.endsWith("**")?m.jsx("strong",{className:"text-fg-primary font-semibold",children:s.slice(2,-2)},r):s.split(/(`[^`]+`)/g).map((o,a)=>o.startsWith("`")&&o.endsWith("`")?m.jsx("code",{className:"px-1 py-0.5 radius-badge bg-elevated text-sys-blue type-data-xs",children:o.slice(1,-1)},`${r}-${a}`):m.jsx("span",{children:o},`${r}-${a}`)))},t)}function tf({lines:e}){const t=[];let i=0;for(;im.jsx("div",{children:n||" "},o))},t.length));continue}if(!s.trim()){t.push(m.jsx("div",{className:"h-1.5"},t.length)),i++;continue}if(s.startsWith("- ")){t.push(m.jsxs("div",{className:"flex gap-2 text-sm text-fg-secondary pl-2 py-0.5",children:[m.jsx("span",{className:"text-fg-muted shrink-0",children:"•"}),m.jsx("span",{children:vo(s.slice(2),0)})]},t.length)),i++;continue}t.push(m.jsx("p",{className:"text-sm text-fg-secondary py-0.5",children:vo(s,0)},t.length)),i++}return m.jsx(m.Fragment,{children:t})}function sf({isOpen:e,onClose:t,onUseCommand:i}){const[s,r]=U.useState(""),n=U.useMemo(()=>{if(!s.trim())return go;const a=s.toLowerCase();return go.filter(h=>h.name.includes(a)||h.searchText.includes(a)||h.description.toLowerCase().includes(a))},[s]),o=s.trim().length>0;return m.jsxs(Ro,{open:e,onClose:t,size:"3xl",motionPlus:!0,className:"sm:min-w-[540px] md:min-w-[680px]",children:[m.jsx(Bo,{icon:m.jsx(Ao,{size:20}),title:"Terminal Command Guide",onClose:t}),m.jsxs(Mo,{className:"flex flex-col gap-0 !px-0 !py-0",children:[m.jsx("div",{className:"sticky top-0 z-10 px-5 py-3 border-b border-edge-subtle bg-surface/95 backdrop-blur-sm",children:m.jsxs("div",{className:"relative",children:[m.jsx(Kr,{size:14,className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-fg-muted"}),m.jsx("input",{type:"text",value:s,onChange:a=>r(a.target.value),placeholder:"Search commands...",className:"w-full pl-8 pr-3 py-1.5 text-sm bg-elevated border border-edge-subtle radius-inner text-fg-primary placeholder:text-fg-muted focus:outline-none focus:ring-1 focus:ring-sys-blue/50",autoFocus:!0})]})}),m.jsxs("div",{className:"overflow-y-auto px-5 py-3 h-[420px] sm:h-[520px] md:h-[600px]",children:[m.jsx(_s,{mode:"popLayout",children:n.length===0?m.jsxs(Ti.div,{initial:{opacity:0,scale:.96},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.96},transition:{duration:Ur.normal,ease:zr.easeOut},className:"flex flex-col items-center gap-2 py-10 text-fg-muted",children:[m.jsx(Kr,{className:"w-6 h-6 opacity-40"}),m.jsxs("p",{className:"text-sm",children:['No commands match "',s,'"']})]},"empty"):m.jsx(Ti.div,{initial:!1,className:"flex flex-col gap-1",children:m.jsx(_s,{initial:!1,children:n.map(a=>m.jsx(Ti.div,{layout:"position",initial:{opacity:0,y:-4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},transition:rl.fade,className:"min-w-0",children:m.jsx(nl,{children:({open:h})=>m.jsxs("div",{className:es("radius-inner border transition-colors",h?"border-edge-subtle bg-elevated/50":"border-transparent hover:bg-elevated/30"),children:[m.jsxs("div",{className:"flex items-center w-full min-w-0",children:[m.jsxs(ol,{className:"flex items-center gap-3 flex-1 min-w-0 px-3 py-2 text-left cursor-pointer",children:[m.jsx(wl,{size:14,className:es("shrink-0 text-fg-muted transition-transform duration-150",h&&"rotate-90")}),m.jsx("code",{className:"text-sm font-semibold text-sys-blue font-mono shrink-0",children:a.name}),m.jsx("span",{className:"text-xs text-fg-muted truncate min-w-0",children:a.description})]}),i&&m.jsx("button",{onClick:l=>{l.stopPropagation(),i(a.name)},className:"shrink-0 mr-2 px-2 py-0.5 text-xs font-semibold uppercase tracking-wider radius-badge bg-elevated text-fg-muted hover:text-sys-blue hover:bg-elevated/80 transition-colors cursor-pointer",title:`Use "${a.name}" in terminal`,children:"use"})]}),m.jsx(al,{className:"px-3 pb-3 pt-0 pl-9",children:a.interactive?m.jsx(ef,{mode:a.interactive}):m.jsx(tf,{lines:a.body})})]})})},a.name))})},"list")}),m.jsx(_s,{children:!o&&m.jsxs(Ti.div,{initial:{opacity:0,y:6},animate:{opacity:1,y:0},exit:{opacity:0,y:6},transition:{duration:Ur.normal,ease:zr.easeOut},className:"mt-4 px-3 py-3 radius-inner border border-edge-subtle bg-elevated/30",children:[m.jsx("p",{className:"text-xs font-semibold text-fg-muted mb-2",children:"Tips"}),m.jsxs("div",{className:"flex flex-col gap-1 text-xs text-fg-muted",children:[m.jsxs("p",{children:["Type ",m.jsx("code",{className:"px-1 py-0.5 radius-badge bg-elevated text-sys-blue font-mono",children:" help"})," in the terminal for detailed usage."]}),m.jsxs("p",{children:["Most commands have shorter aliases (e.g. ",m.jsx("code",{className:"px-1 py-0.5 radius-badge bg-elevated text-sys-blue font-mono",children:"st"}),", ",m.jsx("code",{className:"px-1 py-0.5 radius-badge bg-elevated text-sys-blue font-mono",children:"nb"}),", ",m.jsx("code",{className:"px-1 py-0.5 radius-badge bg-elevated text-sys-blue font-mono",children:"id"}),")."]}),m.jsxs("p",{children:["Signal bars ",m.jsx("span",{className:"font-mono",children:"▁▃▅▇█"})," are colored by link quality grade based on RSSI, SNR, and radio config."]}),m.jsx("p",{children:"Captures are stored in browser session only — export before closing the tab."})]})]})})]})]})]})}function rf({onUseCommand:e}){const[t,i]=U.useState(!1),s=e?r=>{i(!1),e(r)}:void 0;return m.jsxs(m.Fragment,{children:[m.jsx($o,{icon:m.jsx(Ao,{size:17,className:"translate-y-px"}),onClick:()=>i(!0),title:"CLI Command Guide"}),m.jsx(sf,{isOpen:t,onClose:()=>i(!1),onUseCommand:s})]})}const Wa=G_(),Zi=Wa.all().flatMap(e=>[{cmd:e.name,desc:e.description,params:e.params,required:!!e.params},...e.aliases.filter(t=>t.includes(" ")).map(t=>({cmd:t,desc:e.description,params:e.params,required:!!e.params}))]);Zi.push({cmd:"start cap",desc:"Start packet capture",params:"[seconds]",required:!0},{cmd:"end cap",desc:"Stop capture"},{cmd:"list cap",desc:"List captures"},{cmd:"export cap",desc:"Download capture",params:"[id]",required:!0});const Fi=["sig","name","rssi","snr","dist","heard"],nf={get:["name","role","lat","lon","radio","freq","tx","bw","sf","cr","af","txdelay","direct.txdelay","rxdelay","mode","repeat","flood.max","flood.advert.interval","advert.interval","duty","duty.max","multi.acks","int.thresh","agc.reset.interval","public.key","prv.key"],set:["name","lat","lon","freq","tx","bw","sf","cr","af","txdelay","direct.txdelay","rxdelay","mode","repeat","flood.max","flood.advert.interval","advert.interval","duty","log","multi.acks","int.thresh","agc.reset.interval","prv.key"],convert:["hex","base64"],neighbors:Fi,nb:Fi,"get neighbors":Fi,"get neighbor":Fi,"set mode":["forward","monitor"],"set duty":["on","off"],"set repeat":["on","off"],"set tx":["10","14","17","20","22"],"set sf":["7","8","9","10","11","12"],"set bw":["125","250","500"],"set cr":["5","6","7","8"],"set af":["0.5","1.0","1.5","2.0"],"set txdelay":["0.5","0.7","1.0","1.5"],"set direct.txdelay":["0.3","0.5","0.7"],"set log":["debug","info","warning","error"],"start cap":["30","60","120","300"]},Ns=["@@@@@@@ @@@ @@@ @@@@@@@@@@ @@@@@@@ ","@@@@@@@@ @@@ @@@ @@@@@@@@@@@ @@@@@@@@ ","@@! @@@ @@! !@@ @@! @@! @@! !@@ ","!@! @!@ !@! @!! !@! !@! !@! !@! ","@!@@!@! !@!@! @!! !!@ @!@ !@! ","!!@!!! @!!! !@! ! !@! !!! ","!!: !!: !!: !!: :!! ",":!: :!: :!: :!: :!: "," :: :: ::: :: ::: ::: "," : : : : :: :: : "];function ci(){return/Android|iPhone|iPad|iPod/i.test(navigator.userAgent)||window.innerWidth<640}function of(e,t){const i=e.toLowerCase(),s=i.trim();if(!s)return[];const r=i.length>s.length&&i.endsWith(" ");if(!s.includes(" ")&&!r)return Zi.filter(h=>h.cmd.toLowerCase().startsWith(s));const n=r?s:s.substring(0,s.lastIndexOf(" ")),o=r?"":s.substring(s.lastIndexOf(" ")+1);if(n==="ping"&&t.length>0)return t.filter(h=>h.toLowerCase().startsWith(o)).slice(0,10).map(h=>({cmd:`ping ${h}`,desc:`→ ${h}`}));const a=nf[n];if(a){const h=a.filter(l=>l.toLowerCase().startsWith(o)).map(l=>({cmd:`${n} ${l}`,desc:`→ ${l}`}));if(!r&&o){const l=new Set(h.map(c=>c.cmd));for(const c of Zi){const d=c.cmd.toLowerCase();d.startsWith(s)&&!l.has(d)&&(h.push(c),l.add(d))}}return h}return Zi.filter(h=>h.cmd.toLowerCase().startsWith(s))}function Cf(){const e=ll(),{addCommand:t}=mo(),i=U.useRef(null),s=U.useRef(null),r=U.useRef(null),n=U.useRef(null),o=U.useRef(""),a=U.useRef(-1),h=U.useRef(""),l=U.useRef(!1),c=U.useRef(null),d=U.useRef(!1),u=U.useRef(!1),f=U.useRef(!1),_=U.useRef([]),p=U.useRef(()=>{}),g=hl(),[E,z]=U.useState("C0dE"),[O,M]=U.useState(!1),$=U.useRef(null),K=7,ae=280,ne="C0dE",J=U.useCallback(C=>{$.current&&(clearInterval($.current),$.current=null);const P=ne.padEnd(K),F=P+" "+C+" "+P;let q=0;const I=F.length-K;M(!0),z(F.slice(0,K)),$.current=setInterval(()=>{if(q++,q>I){clearInterval($.current),$.current=null,M(!1),z(ne);return}z(F.slice(q,q+K))},ae)},[]);U.useEffect(()=>{const C=I_(J),P=setInterval(()=>{Math.random()<.02&&J(Fr())},45e3);return()=>{C(),clearInterval(P),$.current&&clearInterval($.current)}},[J]);const[He,Y]=U.useState(!1),N=U.useRef(null);U.useEffect(()=>{const C=F_(()=>{N.current&&clearTimeout(N.current),Y(!0),N.current=setTimeout(()=>Y(!1),5e3)});return()=>{C(),N.current&&clearTimeout(N.current)}},[]);const[S,L]=U.useState({show:!1,options:[],selectedIndex:0,input:""}),x=U.useRef([]),A=U.useRef(0);U.useEffect(()=>{e!=null&&e.neighbors&&(_.current=Object.values(e.neighbors).map(C=>C.node_name||C.name).filter(C=>!!C).sort())},[e==null?void 0:e.neighbors]);const H=U.useCallback(()=>{var C;(C=s.current)==null||C.write(Qd(cl()))},[]),B=U.useCallback(()=>{const C=s.current;C&&(C.write(Hi),H(),C.write(o.current))},[H]),X=U.useCallback(C=>{const P=of(C,_.current);x.current=P,A.current=0;const F=P.length>0&&C.trim().length>0;L({show:F,options:P,selectedIndex:0,input:C.trim()})},[]),te=U.useCallback(()=>{x.current=[],A.current=0,L({show:!1,options:[],selectedIndex:0,input:""})},[]),Fe=U.useCallback(C=>{var F;const P=x.current[C];P&&(o.current=P.required?P.cmd+" ":P.cmd,B(),P.required?X(o.current):te(),(F=s.current)==null||F.focus())},[B,X,te]),Qe=U.useCallback(async C=>{const P=s.current;if(!P)return;const F=C.trim();if(!F){H();return}l.current=!0;const q=new AbortController;c.current=q,t(F),a.current=-1;let I=0;const ie={get cols(){return P.cols},get rows(){return P.rows},write(se,xe="default"){const ti=(xe==="default"?se:Wn(se,xe)).split(` +`);for(const Bt of ti)P.writeln(Bt);return I=yr(ti,P.cols),String(I)},update(se,xe,ei){if(f.current)P.write(nu);else if(I>0)for(let Ht=0;Ht{const P=s.current;if(!P||!u.current)return;if(l.current){for(let I=0;IrequestAnimationFrame(()=>{var ie;return(ie=document.querySelector(`[data-ac-index="${I}"]`))==null?void 0:ie.scrollIntoView({block:"nearest"})});for(let I=0;I0){const se=x.current[A.current];se&&(o.current=se.cmd,B())}te();const Ce=o.current;o.current="",P.writeln(""),Qe(Ce);continue}if(ie===127||ie===8){o.current.length>0&&(o.current=o.current.slice(0,-1),P.write("\b \b"),X(o.current));continue}if(ie===3){o.current="",te(),P.writeln("^C"),H();continue}if(ie===12){P.clear(),te(),B();continue}if(ie===9){x.current.length>0&&Fe(A.current);continue}if(ie===27){if(C.charCodeAt(I+1)===91){const Ce=C.charCodeAt(I+2);if(I+=2,Ce===65){if(x.current.length>0){const se=Math.max(A.current-1,0);A.current=se,L(xe=>({...xe,selectedIndex:se})),q(se)}else F.length>0&&(a.current===-1&&(h.current=o.current),a.current0){const se=Math.min(A.current+1,x.current.length-1);A.current=se,L(xe=>({...xe,selectedIndex:se})),q(se)}else a.current>0?(a.current--,o.current=F[F.length-1-a.current]||"",B()):a.current===0&&(a.current=-1,o.current=h.current,B());continue}if(Ce===67||Ce===68)continue;continue}x.current.length>0&&te();continue}ie>=32&&(o.current+=C[I],P.write(C[I]),a.current=-1,X(o.current))}},[te,X,Fe,H,B,Qe]);U.useEffect(()=>{p.current=le},[le]);const Te=U.useCallback(async()=>{const C=s.current;if(!C||d.current)return;d.current=!0;const P="\x1B[94m",F="\x1B[0m",q=Ns.length,I=To-1;try{const Ce=gi(Ns,0);for(const se of Ce)C.writeln(se);await new Promise(se=>{let xe=0;const ei=setInterval(()=>{if(xe>=I){clearInterval(ei),se();return}xe++,C.write(`\x1B[${q}F`);const ti=gi(Ns,xe);for(const Bt of ti)C.write(`\x1B[2K${Bt} +`)},Do)})}finally{Lo()}C.writeln(""),C.write(w("● Initializing terminal...")),await new Promise(Ce=>setTimeout(Ce,300)),C.write(Hi),C.writeln(`${P}✓ Initializing terminal...${F}`),C.write(w("● Connecting to repeater...")),await new Promise(Ce=>setTimeout(Ce,500)),C.write(Hi),dl.getState().health==="connected"?C.writeln(`${P}✓ Connected to repeater${F}`):C.writeln(Zd("~ Connection status unknown")),C.writeln(w("Ready. Type 'help' for commands.")),C.writeln(""),H(),u.current=!0},[H]);U.useEffect(()=>{const C=i.current;if(!C)return;const P=ci()?12:13,F=new Id({theme:Ra(),fontFamily:'"JetBrains Mono", "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace',fontSize:P,lineHeight:ci()?1.1:.65,cursorBlink:!1,cursorStyle:"underline",scrollback:1e4,convertEol:!0,allowTransparency:!0,rightClickSelectsWord:!1}),q=new Fd;F.loadAddon(q),F.loadAddon(new qd),F.open(C),q.fit(),s.current=F,r.current=q;const I=F.onData(se=>p.current(se)),ie=uu(F),Ce=new ResizeObserver(()=>{requestAnimationFrame(()=>q.fit())});return Ce.observe(C),Te(),ci()||F.focus(),()=>{var se;(se=c.current)==null||se.abort(),f.current&&(F.write(jn+Un),f.current=!1),I.dispose(),ie(),Ce.disconnect(),F.dispose(),s.current=null,r.current=null}},[]);const Ve=U.useCallback(C=>{const P=C.target.value;P.length>0&&(le(P),C.target.value="")},[le]),We=U.useCallback(C=>{C.key==="Enter"?(C.preventDefault(),le("\r")):C.key==="Backspace"?(C.preventDefault(),le("")):C.key==="ArrowUp"?(C.preventDefault(),le("\x1B[A")):C.key==="ArrowDown"&&(C.preventDefault(),le("\x1B[B"))},[le]),dt=U.useCallback(()=>{var C,P;ci()?(C=n.current)==null||C.focus():(P=s.current)==null||P.focus()},[]);U.useEffect(()=>{if(!ci())return;const C=()=>{var I;const q=(I=i.current)==null?void 0:I.querySelector(".xterm-viewport");q&&(q.scrollTop=q.scrollHeight),requestAnimationFrame(()=>{var ie;return(ie=r.current)==null?void 0:ie.fit()})},P=window.visualViewport;if(P){const q=()=>{P.heightP.removeEventListener("resize",q)}const F=n.current;if(F){const q=()=>setTimeout(C,300);return F.addEventListener("focus",q),()=>F.removeEventListener("focus",q)}},[]);const Qt=U.useCallback(C=>{o.current=C+" ",B(),X(o.current),setTimeout(()=>{var P;(P=i.current)==null||P.click()},400)},[B,X]);return m.jsx(gl,{children:m.jsx(vl,{ready:!0,children:m.jsxs("div",{className:"terminal-card flex flex-col gap-1 sm:gap-1.5",children:[m.jsxs("div",{className:"card-terminal-header flex-wrap",children:[m.jsx("span",{className:"seven-seg-panel",children:m.jsx(yl,{text:E,minChars:7,size:24,noCycle:O})}),m.jsx("div",{className:"header-well self-stretch flex-col sm:order-first",children:m.jsxs("div",{className:`indicator-key${g==="connected"?" indicator-key--active":g==="degraded"?" indicator-key--sending":""}`,children:[m.jsx("span",{className:"indicator-key__label",children:"ONLINE"}),m.jsx("span",{className:"indicator-key__led"})]})}),m.jsx("div",{className:"card-terminal-ridge flex-1 min-w-4 sm:hidden"}),m.jsxs("div",{className:"header-well flex items-center gap-1 sm:order-last",children:[m.jsx(rf,{onUseCommand:Qt}),m.jsx(J_,{})]}),m.jsx("div",{className:"card-terminal-ridge flex-1 min-w-8 hidden sm:block"})]}),m.jsx(Sl,{noPadding:!0,className:"flex flex-col flex-1 min-h-0 overflow-hidden card-terminal",onClick:dt,children:m.jsxs("div",{className:"card-terminal-well flex-1 min-h-0 flex flex-col overflow-hidden",children:[m.jsxs("div",{className:"flex-1 min-h-0 terminal-gutter relative",children:[m.jsx("div",{ref:i,className:"h-full w-full"}),He&&m.jsxs("div",{className:"absolute inset-0 z-10 flex items-center justify-center",onClick:()=>Y(!1),children:[m.jsx("div",{className:"absolute inset-0 animate-[partytime-bg_5s_ease-out_forwards]",style:{background:"rgba(0,0,0,0.82)"}}),m.jsxs("div",{className:"relative z-10 animate-[partytime-crt_5s_ease-out_forwards] partytime-glow",children:[m.jsx("img",{src:"/assets/partytime.gif",alt:"No way.",className:"max-h-[60vh] max-w-[70vw] object-contain rounded"}),m.jsx("div",{className:"absolute inset-0 pointer-events-none rounded partytime-scanlines"})]})]})]}),S.show&&S.options.length>0&&m.jsxs("div",{className:"flex-shrink-0 overflow-hidden terminal-completions",style:{borderTop:"1px solid var(--terminal-border)",background:"var(--terminal-bg-input)"},children:[m.jsx("div",{className:"overflow-y-auto",style:{maxHeight:"176px"},children:S.options.map((C,P)=>{const F=P===S.selectedIndex,q=S.input.length;return m.jsxs("div",{"data-ac-index":P,onClick:()=>Fe(P),className:es("terminal-ac-option",F?"text-sys-blue":"text-fg-primary"),style:{background:F?"var(--terminal-autocomplete-hover)":void 0},onMouseEnter:I=>{F||(I.currentTarget.style.background="var(--terminal-autocomplete-hover)")},onMouseLeave:I=>{F||(I.currentTarget.style.background="")},children:[m.jsx("span",{className:"terminal-ac-option__indicator",children:F?"▸":""}),m.jsxs("span",{className:"terminal-ac-option__cmd",children:[m.jsx("span",{className:"font-semibold text-sys-blue",children:C.cmd.substring(0,q)}),C.cmd.substring(q)]}),m.jsx("span",{className:"terminal-ac-option__desc",children:C.desc})]},C.cmd)})}),m.jsxs("div",{className:"terminal-ac-hints",children:[m.jsx("span",{className:"hidden sm:inline",children:"Tab · ↑↓ · Esc"}),m.jsx("span",{className:"sm:hidden",children:"Tap to select"}),m.jsxs("span",{children:[S.options.length," match",S.options.length!==1?"es":""]})]})]}),m.jsxs("div",{className:"terminal-mobile-input-bar sm:hidden",children:[m.jsx("input",{ref:n,type:"text",className:"terminal-mobile-input",onChange:Ve,onKeyDown:We,autoComplete:"off",autoCorrect:"off",autoCapitalize:"off",spellCheck:!1,enterKeyHint:"send","aria-label":"Terminal input",placeholder:"Type command..."}),m.jsx("button",{type:"button",className:"terminal-send-btn",onClick:()=>le("\r"),"aria-label":"Run command",children:m.jsx(xl,{})})]}),m.jsxs("div",{className:"terminal-status-bar",children:[m.jsx("span",{className:"hidden sm:inline",children:"↑↓ History · Tab · Esc"}),m.jsx("span",{className:"sm:hidden",children:"Tap input to type"}),(e==null?void 0:e.version)&&m.jsxs("span",{children:["pyMC v",e.version]})]})]})})]})})})}export{Cf as default}; diff --git a/frontend/dist/assets/TimeRangeStepper-CxA2aT1o.js b/frontend/dist/assets/TimeRangeStepper-RSPVaByt.js similarity index 74% rename from frontend/dist/assets/TimeRangeStepper-CxA2aT1o.js rename to frontend/dist/assets/TimeRangeStepper-RSPVaByt.js index e7a2cf1f..78f77551 100644 --- a/frontend/dist/assets/TimeRangeStepper-CxA2aT1o.js +++ b/frontend/dist/assets/TimeRangeStepper-RSPVaByt.js @@ -1,6 +1,6 @@ -import{ap as Ge,aM as be,ao as Le,cn as $e,ar as He,aq as q,r as l,au as Ke,av as ee,az as z,ay as U,aj as k,aC as K,co as se,cp as Be,aH as We,aI as Ye,aN as Ve,aJ as re,aO as Xe,aK as me,cq as _e,cr as W,cs as M,ct as he,cu as A,cv as xe,aL as le,aX as g,cw as ye,cx as Pe,aP as we,an as Qe,aQ as Fe,aR as Oe,aT as Ze,aU as qe,aW as Ee,cy as ze,cz as Te,aY as Ue,cA as Je,cB as et,aZ as Ie,cC as tt,cD as nt,cE as at,ak as ot,b3 as st,aS as J,cF as je,b5 as rt,b7 as ie,cG as lt,cH as ut,cI as ct,d as it,j as I,c as H,A as pt,m as dt,cm as ft}from"./index-C1ZF7cAz.js";import{C as vt}from"./chevron-right-DzbDJf-i.js";import{F as bt,y as mt,R as ht,T as yt,w as Pt,A as $t}from"./map-pin-DEktgLFN.js";var xt=Object.defineProperty,gt=(e,n,t)=>n in e?xt(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t,ke=(e,n,t)=>(gt(e,typeof n!="symbol"?n+"":n,t),t),$=(e=>(e[e.Open=0]="Open",e[e.Closed=1]="Closed",e))($||{}),St=(e=>(e[e.OpenPopover=0]="OpenPopover",e[e.ClosePopover=1]="ClosePopover",e[e.SetButton=2]="SetButton",e[e.SetButtonId=3]="SetButtonId",e[e.SetPanel=4]="SetPanel",e[e.SetPanelId=5]="SetPanelId",e))(St||{});let Ct={0:e=>e.popoverState===0?e:{...e,popoverState:0,__demoMode:!1},1(e){return e.popoverState===1?e:{...e,popoverState:1,__demoMode:!1}},2(e,n){return e.button===n.button?e:{...e,button:n.button}},3(e,n){return e.buttonId===n.buttonId?e:{...e,buttonId:n.buttonId}},4(e,n){return e.panel===n.panel?e:{...e,panel:n.panel}},5(e,n){return e.panelId===n.panelId?e:{...e,panelId:n.panelId}}};class ge extends Ge{constructor(n){super(n),ke(this,"actions",{close:()=>this.send({type:1}),refocusableClose:t=>{this.actions.close();let v=t?be(t)?t:"current"in t&&be(t.current)?t.current:this.state.button:this.state.button;v==null||v.focus()},open:()=>this.send({type:0}),setButtonId:t=>this.send({type:3,buttonId:t}),setButton:t=>this.send({type:2,button:t}),setPanelId:t=>this.send({type:5,panelId:t}),setPanel:t=>this.send({type:4,panel:t})}),ke(this,"selectors",{isPortalled:t=>{var v;if(!t.button||!t.panel)return!1;let h=(v=Le(t.button))!=null?v:document;for(let x of h.querySelectorAll("body > *"))if(Number(x==null?void 0:x.contains(t.button))^Number(x==null?void 0:x.contains(t.panel)))return!0;let b=$e(h),r=b.indexOf(t.button),a=(r+b.length-1)%b.length,C=(r+1)%b.length,y=b[a],s=b[C];return!t.panel.contains(y)&&!t.panel.contains(s)}});{let t=this.state.id,v=He.get(null);this.on(0,()=>v.actions.push(t)),this.on(1,()=>v.actions.pop(t))}}static new({id:n,__demoMode:t=!1}){return new ge({id:n,__demoMode:t,popoverState:t?0:1,buttons:{current:[]},button:null,buttonId:null,panel:null,panelId:null,beforePanelSentinel:{current:null},afterPanelSentinel:{current:null},afterButtonSentinel:{current:null}})}reduce(n,t){return q(t.type,Ct,n,t)}}const Ne=l.createContext(null);function pe(e){let n=l.useContext(Ne);if(n===null){let t=new Error(`<${e} /> is missing a parent component.`);throw Error.captureStackTrace&&Error.captureStackTrace(t,pe),t}return n}function wt({id:e,__demoMode:n=!1}){let t=l.useMemo(()=>ge.new({id:e,__demoMode:n}),[]);return Ke(()=>t.dispose()),t}let Se=l.createContext(null);Se.displayName="PopoverGroupContext";function De(){return l.useContext(Se)}let de=l.createContext(null);de.displayName="PopoverPanelContext";function It(){return l.useContext(de)}let kt="div";function Bt(e,n){var t;let v=l.useId(),{__demoMode:h=!1,...b}=e,r=wt({id:v,__demoMode:h}),a=l.useRef(null),C=U(n,Je(u=>{a.current=u})),[y,s,x,S,B]=z(r,l.useCallback(u=>[u.popoverState,u.button,u.panel,u.buttonId,u.panelId],[])),w=et((t=a.current)!=null?t:s),d=Ie(S),p=Ie(B),f=l.useMemo(()=>({buttonId:d,panelId:p,close:r.actions.close}),[d,p,r]),P=De(),c=P==null?void 0:P.registerPopover,_=k(()=>{var u,F;let E=se((u=a.current)!=null?u:s);return(F=P==null?void 0:P.isFocusWithinPopoverGroup())!=null?F:E&&((s==null?void 0:s.contains(E))||(x==null?void 0:x.contains(E)))});l.useEffect(()=>c==null?void 0:c(f),[c,f]);let[te,ne]=tt(),G=nt(s),D=at({mainTreeNode:G,portals:te,defaultContainers:[{get current(){return r.state.button}},{get current(){return r.state.panel}}]});ot(w,"focus",u=>{var F,E,j,Q,N,Z;u.target!==window&<(u.target)&&r.state.popoverState===$.Open&&(_()||r.state.button&&r.state.panel&&(D.contains(u.target)||(E=(F=r.state.beforePanelSentinel.current)==null?void 0:F.contains)!=null&&E.call(F,u.target)||(Q=(j=r.state.afterPanelSentinel.current)==null?void 0:j.contains)!=null&&Q.call(j,u.target)||(Z=(N=r.state.afterButtonSentinel.current)==null?void 0:N.contains)!=null&&Z.call(N,u.target)||r.actions.close()))},!0);let Y=y===$.Open;st(Y,D.resolveContainers,(u,F)=>{r.actions.close(),ut(F,ct.Loose)||(u.preventDefault(),s==null||s.focus())});let ae=re({open:y===$.Open,close:r.actions.refocusableClose}),oe=z(r,l.useCallback(u=>q(u.popoverState,{[$.Open]:J.Open,[$.Closed]:J.Closed}),[])),V={ref:C},X=le();return g.createElement(je,{node:G},g.createElement($t,null,g.createElement(de.Provider,{value:null},g.createElement(Ne.Provider,{value:r},g.createElement(Te,{value:r.actions.refocusableClose},g.createElement(rt,{value:oe},g.createElement(ne,null,X({ourProps:V,theirProps:b,slot:ae,defaultTag:kt,name:"Popover"}))))))))}let _t="button";function Ft(e,n){let t=l.useId(),{id:v=`headlessui-popover-button-${t}`,disabled:h=!1,autoFocus:b=!1,...r}=e,a=pe("Popover.Button"),[C,y,s,x,S,B,w]=z(a,l.useCallback(o=>[o.popoverState,a.selectors.isPortalled(o),o.button,o.buttonId,o.panel,o.panelId,o.afterButtonSentinel],[])),d=l.useRef(null),p=`headlessui-focus-sentinel-${l.useId()}`,f=De(),P=f==null?void 0:f.closeOthers,c=It()!==null;l.useEffect(()=>{if(!c)return a.actions.setButtonId(v),()=>a.actions.setButtonId(null)},[c,v,a]);let[_]=l.useState(()=>Symbol()),te=U(d,n,bt(),k(o=>{if(!c){if(o)a.state.buttons.current.push(_);else{let i=a.state.buttons.current.indexOf(_);i!==-1&&a.state.buttons.current.splice(i,1)}a.state.buttons.current.length>1&&console.warn("You are already using a but only 1 is supported."),o&&a.actions.setButton(o)}})),ne=U(d,n),G=k(o=>{var i,O,T;if(c){if(a.state.popoverState===$.Closed)return;switch(o.key){case K.Space:case K.Enter:o.preventDefault(),(O=(i=o.target).click)==null||O.call(i),a.actions.close(),(T=a.state.button)==null||T.focus();break}}else switch(o.key){case K.Space:case K.Enter:o.preventDefault(),o.stopPropagation(),a.state.popoverState===$.Closed?(P==null||P(a.state.buttonId),a.actions.open()):a.actions.close();break;case K.Escape:if(a.state.popoverState!==$.Open)return P==null?void 0:P(a.state.buttonId);if(!d.current)return;let R=se(d.current);if(R&&!d.current.contains(R))return;o.preventDefault(),o.stopPropagation(),a.actions.close();break}}),D=k(o=>{c||o.key===K.Space&&o.preventDefault()}),Y=k(o=>{var i,O;Be(o.currentTarget)||h||(c?(a.actions.close(),(i=a.state.button)==null||i.focus()):(o.preventDefault(),o.stopPropagation(),a.state.popoverState===$.Closed?(P==null||P(a.state.buttonId),a.actions.open()):a.actions.close(),(O=a.state.button)==null||O.focus()))}),ae=k(o=>{o.preventDefault(),o.stopPropagation()}),{isFocusVisible:oe,focusProps:V}=We({autoFocus:b}),{isHovered:X,hoverProps:u}=Ye({isDisabled:h}),{pressed:F,pressProps:E}=Ve({disabled:h}),j=C===$.Open,Q=re({open:j,active:F||j,disabled:h,hover:X,focus:oe,autofocus:b}),N=Xe(e,s),Z=c?me({ref:ne,type:N,onKeyDown:G,onClick:Y,disabled:h||void 0,autoFocus:b},V,u,E):me({ref:te,id:x,type:N,"aria-expanded":C===$.Open,"aria-controls":S?B:void 0,disabled:h||void 0,autoFocus:b,onKeyDown:G,onKeyUp:D,onClick:Y,onMouseDown:ae},V,u,E),ue=_e(),fe=k(()=>{if(!be(a.state.panel))return;let o=a.state.panel;function i(){q(ue.current,{[M.Forwards]:()=>W(o,A.First),[M.Backwards]:()=>W(o,A.Last)})===he.Error&&W($e(xe(a.state.button)).filter(O=>O.dataset.headlessuiFocusGuard!=="true"),q(ue.current,{[M.Forwards]:A.Next,[M.Backwards]:A.Previous}),{relativeTo:a.state.button})}i()}),m=le();return g.createElement(g.Fragment,null,m({ourProps:Z,theirProps:r,slot:Q,defaultTag:_t,name:"Popover.Button"}),j&&!c&&y&&g.createElement(ye,{id:p,ref:w,features:Pe.Focusable,"data-headlessui-focus-guard":!0,as:"button",type:"button",onFocus:fe}))}let Ot="div",Et=ie.RenderStrategy|ie.Static;function Re(e,n){let t=l.useId(),{id:v=`headlessui-popover-backdrop-${t}`,transition:h=!1,...b}=e,r=pe("Popover.Backdrop"),a=z(r,l.useCallback(f=>f.popoverState,[])),[C,y]=l.useState(null),s=U(n,y),x=Fe(),[S,B]=Oe(h,C,x!==null?(x&J.Open)===J.Open:a===$.Open),w=k(f=>{if(Be(f.currentTarget))return f.preventDefault();r.actions.close()}),d=re({open:a===$.Open}),p={ref:s,id:v,"aria-hidden":!0,onClick:w,...Ee(B)};return le()({ourProps:p,theirProps:b,slot:d,defaultTag:Ot,features:Et,visible:S,name:"Popover.Backdrop"})}let Tt="div",jt=ie.RenderStrategy|ie.Static;function Nt(e,n){let t=l.useId(),{id:v=`headlessui-popover-panel-${t}`,focus:h=!1,anchor:b,portal:r=!1,modal:a=!1,transition:C=!1,...y}=e,s=pe("Popover.Panel"),x=z(s,s.selectors.isPortalled),[S,B,w,d,p]=z(s,l.useCallback(m=>[m.popoverState,m.button,m.__demoMode,m.beforePanelSentinel,m.afterPanelSentinel],[])),f=`headlessui-focus-sentinel-before-${t}`,P=`headlessui-focus-sentinel-after-${t}`,c=l.useRef(null),_=mt(b),[te,ne]=ht(_),G=yt();_&&(r=!0);let[D,Y]=l.useState(null),ae=U(c,n,_?te:null,s.actions.setPanel,Y),oe=we(B),V=we(c.current);Qe(()=>(s.actions.setPanelId(v),()=>s.actions.setPanelId(null)),[v,s]);let X=Fe(),[u,F]=Oe(C,D,X!==null?(X&J.Open)===J.Open:S===$.Open);Ze(u,B,s.actions.close),qe(w?!1:a&&u,V);let E=k(m=>{var o;switch(m.key){case K.Escape:if(s.state.popoverState!==$.Open||!c.current)return;let i=se(c.current);if(i&&!c.current.contains(i))return;m.preventDefault(),m.stopPropagation(),s.actions.close(),(o=s.state.button)==null||o.focus();break}});l.useEffect(()=>{var m;e.static||S===$.Closed&&((m=e.unmount)==null||m)&&s.actions.setPanel(null)},[S,e.unmount,e.static,s]),l.useEffect(()=>{if(w||!h||S!==$.Open||!c.current)return;let m=se(c.current);c.current.contains(m)||W(c.current,A.First)},[w,h,c.current,S]);let j=re({open:S===$.Open,close:s.actions.refocusableClose}),Q=me(_?G():{},{ref:ae,id:v,onKeyDown:E,onBlur:h&&S===$.Open?m=>{var o,i,O,T,R;let L=m.relatedTarget;L&&c.current&&((o=c.current)!=null&&o.contains(L)||(s.actions.close(),((O=(i=d.current)==null?void 0:i.contains)!=null&&O.call(i,L)||(R=(T=p.current)==null?void 0:T.contains)!=null&&R.call(T,L))&&L.focus({preventScroll:!0})))}:void 0,tabIndex:-1,style:{...y.style,...ne,"--button-width":Pt(u,B,!0).width},...Ee(F)}),N=_e(),Z=k(()=>{let m=c.current;if(!m)return;function o(){q(N.current,{[M.Forwards]:()=>{var i;W(m,A.First)===he.Error&&((i=s.state.afterPanelSentinel.current)==null||i.focus())},[M.Backwards]:()=>{var i;(i=s.state.button)==null||i.focus({preventScroll:!0})}})}o()}),ue=k(()=>{let m=c.current;if(!m)return;function o(){q(N.current,{[M.Forwards]:()=>{var i;if(!s.state.button)return;let O=(i=xe(s.state.button))!=null?i:document.body,T=$e(O),R=T.indexOf(s.state.button),L=T.slice(0,R+1),ce=[...T.slice(R+1),...L];for(let ve of ce.slice())if(ve.dataset.headlessuiFocusGuard==="true"||D!=null&&D.contains(ve)){let Ce=ce.indexOf(ve);Ce!==-1&&ce.splice(Ce,1)}W(ce,A.First,{sorted:!1})},[M.Backwards]:()=>{var i;W(m,A.Previous)===he.Error&&((i=s.state.button)==null||i.focus())}})}o()}),fe=le();return g.createElement(ze,null,g.createElement(de.Provider,{value:v},g.createElement(Te,{value:s.actions.refocusableClose},g.createElement(Ue,{enabled:r?e.static||u:!1,ownerDocument:oe},u&&x&&g.createElement(ye,{id:f,ref:d,features:Pe.Focusable,"data-headlessui-focus-guard":!0,as:"button",type:"button",onFocus:Z}),fe({ourProps:Q,theirProps:y,slot:j,defaultTag:Tt,features:jt,visible:u,name:"Popover.Panel"}),u&&x&&g.createElement(ye,{id:P,ref:p,features:Pe.Focusable,"data-headlessui-focus-guard":!0,as:"button",type:"button",onFocus:ue})))))}let Dt="div";function Rt(e,n){let t=l.useRef(null),v=U(t,n),[h,b]=l.useState([]),r=k(d=>{b(p=>{let f=p.indexOf(d);if(f!==-1){let P=p.slice();return P.splice(f,1),P}return p})}),a=k(d=>(b(p=>[...p,d]),()=>r(d))),C=k(()=>{var d;let p=xe(t.current);if(!p)return!1;let f=se(t.current);return(d=t.current)!=null&&d.contains(f)?!0:h.some(P=>{var c,_;return((c=p.getElementById(P.buttonId.current))==null?void 0:c.contains(f))||((_=p.getElementById(P.panelId.current))==null?void 0:_.contains(f))})}),y=k(d=>{for(let p of h)p.buttonId.current!==d&&p.close()}),s=l.useMemo(()=>({registerPopover:a,unregisterPopover:r,isFocusWithinPopoverGroup:C,closeOthers:y}),[a,r,C,y]),x=re({}),S=e,B={ref:v},w=le();return g.createElement(je,null,g.createElement(Se.Provider,{value:s},w({ourProps:B,theirProps:S,slot:x,defaultTag:Dt,name:"Popover.Group"})))}let Mt=ee(Bt),Me=ee(Ft),At=ee(Re),Gt=ee(Re),Ae=ee(Nt),Lt=ee(Rt),Ht=Object.assign(Mt,{Button:Me,Backdrop:Gt,Overlay:At,Panel:Ae,Group:Lt});/** +import{as as Ge,aP as be,ar as Le,cl as $e,au as Ke,at as q,r as l,ax as Ve,ay as ee,aC as z,aB as U,am as k,aF as V,cm as se,cn as Be,aK as We,aL as He,aQ as Xe,aM as re,aR as Ye,aN as me,co as _e,cp as W,cq as M,cr as he,cs as A,ct as xe,aO as le,a_ as g,cu as ye,cv as Pe,aS as we,aq as Qe,aT as Fe,aU as Oe,aW as Ze,aX as qe,aZ as Ee,cw as ze,cx as Te,a$ as Ue,cy as Je,cz as et,b0 as Ie,cA as tt,cB as nt,cC as at,an as ot,b6 as st,aV as J,cD as Ne,b8 as rt,ba as ie,cE as lt,cF as ut,cG as ct,d as it,j as I,c as K,A as pt,m as dt,ck as ft}from"./index-DhkG1Nx9.js";import{C as vt}from"./chevron-right-na13OQfy.js";import{F as bt,y as mt,R as ht,T as yt,w as Pt,A as $t}from"./map-pin-BHGohRD7.js";var xt=Object.defineProperty,gt=(e,n,t)=>n in e?xt(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t,ke=(e,n,t)=>(gt(e,typeof n!="symbol"?n+"":n,t),t),$=(e=>(e[e.Open=0]="Open",e[e.Closed=1]="Closed",e))($||{}),St=(e=>(e[e.OpenPopover=0]="OpenPopover",e[e.ClosePopover=1]="ClosePopover",e[e.SetButton=2]="SetButton",e[e.SetButtonId=3]="SetButtonId",e[e.SetPanel=4]="SetPanel",e[e.SetPanelId=5]="SetPanelId",e))(St||{});let Ct={0:e=>e.popoverState===0?e:{...e,popoverState:0,__demoMode:!1},1(e){return e.popoverState===1?e:{...e,popoverState:1,__demoMode:!1}},2(e,n){return e.button===n.button?e:{...e,button:n.button}},3(e,n){return e.buttonId===n.buttonId?e:{...e,buttonId:n.buttonId}},4(e,n){return e.panel===n.panel?e:{...e,panel:n.panel}},5(e,n){return e.panelId===n.panelId?e:{...e,panelId:n.panelId}}};class ge extends Ge{constructor(n){super(n),ke(this,"actions",{close:()=>this.send({type:1}),refocusableClose:t=>{this.actions.close();let v=t?be(t)?t:"current"in t&&be(t.current)?t.current:this.state.button:this.state.button;v==null||v.focus()},open:()=>this.send({type:0}),setButtonId:t=>this.send({type:3,buttonId:t}),setButton:t=>this.send({type:2,button:t}),setPanelId:t=>this.send({type:5,panelId:t}),setPanel:t=>this.send({type:4,panel:t})}),ke(this,"selectors",{isPortalled:t=>{var v;if(!t.button||!t.panel)return!1;let h=(v=Le(t.button))!=null?v:document;for(let x of h.querySelectorAll("body > *"))if(Number(x==null?void 0:x.contains(t.button))^Number(x==null?void 0:x.contains(t.panel)))return!0;let b=$e(h),r=b.indexOf(t.button),a=(r+b.length-1)%b.length,C=(r+1)%b.length,y=b[a],s=b[C];return!t.panel.contains(y)&&!t.panel.contains(s)}});{let t=this.state.id,v=Ke.get(null);this.on(0,()=>v.actions.push(t)),this.on(1,()=>v.actions.pop(t))}}static new({id:n,__demoMode:t=!1}){return new ge({id:n,__demoMode:t,popoverState:t?0:1,buttons:{current:[]},button:null,buttonId:null,panel:null,panelId:null,beforePanelSentinel:{current:null},afterPanelSentinel:{current:null},afterButtonSentinel:{current:null}})}reduce(n,t){return q(t.type,Ct,n,t)}}const je=l.createContext(null);function pe(e){let n=l.useContext(je);if(n===null){let t=new Error(`<${e} /> is missing a parent component.`);throw Error.captureStackTrace&&Error.captureStackTrace(t,pe),t}return n}function wt({id:e,__demoMode:n=!1}){let t=l.useMemo(()=>ge.new({id:e,__demoMode:n}),[]);return Ve(()=>t.dispose()),t}let Se=l.createContext(null);Se.displayName="PopoverGroupContext";function De(){return l.useContext(Se)}let de=l.createContext(null);de.displayName="PopoverPanelContext";function It(){return l.useContext(de)}let kt="div";function Bt(e,n){var t;let v=l.useId(),{__demoMode:h=!1,...b}=e,r=wt({id:v,__demoMode:h}),a=l.useRef(null),C=U(n,Je(u=>{a.current=u})),[y,s,x,S,B]=z(r,l.useCallback(u=>[u.popoverState,u.button,u.panel,u.buttonId,u.panelId],[])),w=et((t=a.current)!=null?t:s),d=Ie(S),p=Ie(B),f=l.useMemo(()=>({buttonId:d,panelId:p,close:r.actions.close}),[d,p,r]),P=De(),c=P==null?void 0:P.registerPopover,_=k(()=>{var u,F;let E=se((u=a.current)!=null?u:s);return(F=P==null?void 0:P.isFocusWithinPopoverGroup())!=null?F:E&&((s==null?void 0:s.contains(E))||(x==null?void 0:x.contains(E)))});l.useEffect(()=>c==null?void 0:c(f),[c,f]);let[te,ne]=tt(),G=nt(s),D=at({mainTreeNode:G,portals:te,defaultContainers:[{get current(){return r.state.button}},{get current(){return r.state.panel}}]});ot(w,"focus",u=>{var F,E,N,Q,j,Z;u.target!==window&<(u.target)&&r.state.popoverState===$.Open&&(_()||r.state.button&&r.state.panel&&(D.contains(u.target)||(E=(F=r.state.beforePanelSentinel.current)==null?void 0:F.contains)!=null&&E.call(F,u.target)||(Q=(N=r.state.afterPanelSentinel.current)==null?void 0:N.contains)!=null&&Q.call(N,u.target)||(Z=(j=r.state.afterButtonSentinel.current)==null?void 0:j.contains)!=null&&Z.call(j,u.target)||r.actions.close()))},!0);let H=y===$.Open;st(H,D.resolveContainers,(u,F)=>{r.actions.close(),ut(F,ct.Loose)||(u.preventDefault(),s==null||s.focus())});let ae=re({open:y===$.Open,close:r.actions.refocusableClose}),oe=z(r,l.useCallback(u=>q(u.popoverState,{[$.Open]:J.Open,[$.Closed]:J.Closed}),[])),X={ref:C},Y=le();return g.createElement(Ne,{node:G},g.createElement($t,null,g.createElement(de.Provider,{value:null},g.createElement(je.Provider,{value:r},g.createElement(Te,{value:r.actions.refocusableClose},g.createElement(rt,{value:oe},g.createElement(ne,null,Y({ourProps:X,theirProps:b,slot:ae,defaultTag:kt,name:"Popover"}))))))))}let _t="button";function Ft(e,n){let t=l.useId(),{id:v=`headlessui-popover-button-${t}`,disabled:h=!1,autoFocus:b=!1,...r}=e,a=pe("Popover.Button"),[C,y,s,x,S,B,w]=z(a,l.useCallback(o=>[o.popoverState,a.selectors.isPortalled(o),o.button,o.buttonId,o.panel,o.panelId,o.afterButtonSentinel],[])),d=l.useRef(null),p=`headlessui-focus-sentinel-${l.useId()}`,f=De(),P=f==null?void 0:f.closeOthers,c=It()!==null;l.useEffect(()=>{if(!c)return a.actions.setButtonId(v),()=>a.actions.setButtonId(null)},[c,v,a]);let[_]=l.useState(()=>Symbol()),te=U(d,n,bt(),k(o=>{if(!c){if(o)a.state.buttons.current.push(_);else{let i=a.state.buttons.current.indexOf(_);i!==-1&&a.state.buttons.current.splice(i,1)}a.state.buttons.current.length>1&&console.warn("You are already using a but only 1 is supported."),o&&a.actions.setButton(o)}})),ne=U(d,n),G=k(o=>{var i,O,T;if(c){if(a.state.popoverState===$.Closed)return;switch(o.key){case V.Space:case V.Enter:o.preventDefault(),(O=(i=o.target).click)==null||O.call(i),a.actions.close(),(T=a.state.button)==null||T.focus();break}}else switch(o.key){case V.Space:case V.Enter:o.preventDefault(),o.stopPropagation(),a.state.popoverState===$.Closed?(P==null||P(a.state.buttonId),a.actions.open()):a.actions.close();break;case V.Escape:if(a.state.popoverState!==$.Open)return P==null?void 0:P(a.state.buttonId);if(!d.current)return;let R=se(d.current);if(R&&!d.current.contains(R))return;o.preventDefault(),o.stopPropagation(),a.actions.close();break}}),D=k(o=>{c||o.key===V.Space&&o.preventDefault()}),H=k(o=>{var i,O;Be(o.currentTarget)||h||(c?(a.actions.close(),(i=a.state.button)==null||i.focus()):(o.preventDefault(),o.stopPropagation(),a.state.popoverState===$.Closed?(P==null||P(a.state.buttonId),a.actions.open()):a.actions.close(),(O=a.state.button)==null||O.focus()))}),ae=k(o=>{o.preventDefault(),o.stopPropagation()}),{isFocusVisible:oe,focusProps:X}=We({autoFocus:b}),{isHovered:Y,hoverProps:u}=He({isDisabled:h}),{pressed:F,pressProps:E}=Xe({disabled:h}),N=C===$.Open,Q=re({open:N,active:F||N,disabled:h,hover:Y,focus:oe,autofocus:b}),j=Ye(e,s),Z=c?me({ref:ne,type:j,onKeyDown:G,onClick:H,disabled:h||void 0,autoFocus:b},X,u,E):me({ref:te,id:x,type:j,"aria-expanded":C===$.Open,"aria-controls":S?B:void 0,disabled:h||void 0,autoFocus:b,onKeyDown:G,onKeyUp:D,onClick:H,onMouseDown:ae},X,u,E),ue=_e(),fe=k(()=>{if(!be(a.state.panel))return;let o=a.state.panel;function i(){q(ue.current,{[M.Forwards]:()=>W(o,A.First),[M.Backwards]:()=>W(o,A.Last)})===he.Error&&W($e(xe(a.state.button)).filter(O=>O.dataset.headlessuiFocusGuard!=="true"),q(ue.current,{[M.Forwards]:A.Next,[M.Backwards]:A.Previous}),{relativeTo:a.state.button})}i()}),m=le();return g.createElement(g.Fragment,null,m({ourProps:Z,theirProps:r,slot:Q,defaultTag:_t,name:"Popover.Button"}),N&&!c&&y&&g.createElement(ye,{id:p,ref:w,features:Pe.Focusable,"data-headlessui-focus-guard":!0,as:"button",type:"button",onFocus:fe}))}let Ot="div",Et=ie.RenderStrategy|ie.Static;function Re(e,n){let t=l.useId(),{id:v=`headlessui-popover-backdrop-${t}`,transition:h=!1,...b}=e,r=pe("Popover.Backdrop"),a=z(r,l.useCallback(f=>f.popoverState,[])),[C,y]=l.useState(null),s=U(n,y),x=Fe(),[S,B]=Oe(h,C,x!==null?(x&J.Open)===J.Open:a===$.Open),w=k(f=>{if(Be(f.currentTarget))return f.preventDefault();r.actions.close()}),d=re({open:a===$.Open}),p={ref:s,id:v,"aria-hidden":!0,onClick:w,...Ee(B)};return le()({ourProps:p,theirProps:b,slot:d,defaultTag:Ot,features:Et,visible:S,name:"Popover.Backdrop"})}let Tt="div",Nt=ie.RenderStrategy|ie.Static;function jt(e,n){let t=l.useId(),{id:v=`headlessui-popover-panel-${t}`,focus:h=!1,anchor:b,portal:r=!1,modal:a=!1,transition:C=!1,...y}=e,s=pe("Popover.Panel"),x=z(s,s.selectors.isPortalled),[S,B,w,d,p]=z(s,l.useCallback(m=>[m.popoverState,m.button,m.__demoMode,m.beforePanelSentinel,m.afterPanelSentinel],[])),f=`headlessui-focus-sentinel-before-${t}`,P=`headlessui-focus-sentinel-after-${t}`,c=l.useRef(null),_=mt(b),[te,ne]=ht(_),G=yt();_&&(r=!0);let[D,H]=l.useState(null),ae=U(c,n,_?te:null,s.actions.setPanel,H),oe=we(B),X=we(c.current);Qe(()=>(s.actions.setPanelId(v),()=>s.actions.setPanelId(null)),[v,s]);let Y=Fe(),[u,F]=Oe(C,D,Y!==null?(Y&J.Open)===J.Open:S===$.Open);Ze(u,B,s.actions.close),qe(w?!1:a&&u,X);let E=k(m=>{var o;switch(m.key){case V.Escape:if(s.state.popoverState!==$.Open||!c.current)return;let i=se(c.current);if(i&&!c.current.contains(i))return;m.preventDefault(),m.stopPropagation(),s.actions.close(),(o=s.state.button)==null||o.focus();break}});l.useEffect(()=>{var m;e.static||S===$.Closed&&((m=e.unmount)==null||m)&&s.actions.setPanel(null)},[S,e.unmount,e.static,s]),l.useEffect(()=>{if(w||!h||S!==$.Open||!c.current)return;let m=se(c.current);c.current.contains(m)||W(c.current,A.First)},[w,h,c.current,S]);let N=re({open:S===$.Open,close:s.actions.refocusableClose}),Q=me(_?G():{},{ref:ae,id:v,onKeyDown:E,onBlur:h&&S===$.Open?m=>{var o,i,O,T,R;let L=m.relatedTarget;L&&c.current&&((o=c.current)!=null&&o.contains(L)||(s.actions.close(),((O=(i=d.current)==null?void 0:i.contains)!=null&&O.call(i,L)||(R=(T=p.current)==null?void 0:T.contains)!=null&&R.call(T,L))&&L.focus({preventScroll:!0})))}:void 0,tabIndex:-1,style:{...y.style,...ne,"--button-width":Pt(u,B,!0).width},...Ee(F)}),j=_e(),Z=k(()=>{let m=c.current;if(!m)return;function o(){q(j.current,{[M.Forwards]:()=>{var i;W(m,A.First)===he.Error&&((i=s.state.afterPanelSentinel.current)==null||i.focus())},[M.Backwards]:()=>{var i;(i=s.state.button)==null||i.focus({preventScroll:!0})}})}o()}),ue=k(()=>{let m=c.current;if(!m)return;function o(){q(j.current,{[M.Forwards]:()=>{var i;if(!s.state.button)return;let O=(i=xe(s.state.button))!=null?i:document.body,T=$e(O),R=T.indexOf(s.state.button),L=T.slice(0,R+1),ce=[...T.slice(R+1),...L];for(let ve of ce.slice())if(ve.dataset.headlessuiFocusGuard==="true"||D!=null&&D.contains(ve)){let Ce=ce.indexOf(ve);Ce!==-1&&ce.splice(Ce,1)}W(ce,A.First,{sorted:!1})},[M.Backwards]:()=>{var i;W(m,A.Previous)===he.Error&&((i=s.state.button)==null||i.focus())}})}o()}),fe=le();return g.createElement(ze,null,g.createElement(de.Provider,{value:v},g.createElement(Te,{value:s.actions.refocusableClose},g.createElement(Ue,{enabled:r?e.static||u:!1,ownerDocument:oe},u&&x&&g.createElement(ye,{id:f,ref:d,features:Pe.Focusable,"data-headlessui-focus-guard":!0,as:"button",type:"button",onFocus:Z}),fe({ourProps:Q,theirProps:y,slot:N,defaultTag:Tt,features:Nt,visible:u,name:"Popover.Panel"}),u&&x&&g.createElement(ye,{id:P,ref:p,features:Pe.Focusable,"data-headlessui-focus-guard":!0,as:"button",type:"button",onFocus:ue})))))}let Dt="div";function Rt(e,n){let t=l.useRef(null),v=U(t,n),[h,b]=l.useState([]),r=k(d=>{b(p=>{let f=p.indexOf(d);if(f!==-1){let P=p.slice();return P.splice(f,1),P}return p})}),a=k(d=>(b(p=>[...p,d]),()=>r(d))),C=k(()=>{var d;let p=xe(t.current);if(!p)return!1;let f=se(t.current);return(d=t.current)!=null&&d.contains(f)?!0:h.some(P=>{var c,_;return((c=p.getElementById(P.buttonId.current))==null?void 0:c.contains(f))||((_=p.getElementById(P.panelId.current))==null?void 0:_.contains(f))})}),y=k(d=>{for(let p of h)p.buttonId.current!==d&&p.close()}),s=l.useMemo(()=>({registerPopover:a,unregisterPopover:r,isFocusWithinPopoverGroup:C,closeOthers:y}),[a,r,C,y]),x=re({}),S=e,B={ref:v},w=le();return g.createElement(Ne,null,g.createElement(Se.Provider,{value:s},w({ourProps:B,theirProps:S,slot:x,defaultTag:Dt,name:"Popover.Group"})))}let Mt=ee(Bt),Me=ee(Ft),At=ee(Re),Gt=ee(Re),Ae=ee(jt),Lt=ee(Rt),Kt=Object.assign(Mt,{Button:Me,Backdrop:Gt,Overlay:At,Panel:Ae,Group:Lt});/** * @license lucide-react v0.559.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const Kt=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],Wt=it("chevron-left",Kt);function Yt({ranges:e,selectedIndex:n,onSelect:t,isPending:v,size:h="default"}){var B;const b=l.useRef(null),r=n>0,a=n{var f;const p=w==="left"?6:-6;(f=b.current)==null||f.animate([{opacity:1,transform:"translateX(0)"},{opacity:0,transform:`translateX(${p}px)`}],{duration:80,easing:"ease-out"}),setTimeout(()=>{var P;d(),(P=b.current)==null||P.animate([{opacity:0,transform:`translateX(${-p}px)`},{opacity:1,transform:"translateX(0)"}],{duration:80,easing:"ease-out"})},80)},x=()=>r&&s("left",()=>t(n-1)),S=()=>a&&s("right",()=>t(n+1));return I.jsx(Ht,{className:"relative inline-flex",children:({open:w,close:d})=>I.jsxs(I.Fragment,{children:[I.jsxs("div",{className:H("inline-flex items-center rounded-full bg-surface","shadow-[var(--neo-outer-sm)]",y?"gap-0.5 p-0.5":"gap-0.5 p-1",v&&"opacity-70"),children:[I.jsx("button",{type:"button",onClick:x,disabled:!r,"aria-label":"Previous",className:H("flex items-center justify-center rounded-full transition-all duration-100","text-fg-muted hover:text-fg-primary active:scale-90","disabled:opacity-25 disabled:pointer-events-none",y?"w-5 h-5":"w-6 h-6"),children:I.jsx(Wt,{className:y?"w-3 h-3":"w-3.5 h-3.5"})}),I.jsx(Me,{className:H("rounded-full cursor-pointer transition-all","bg-surface shadow-[inset_0_0_0_1.5px_var(--sys-blue)]",y?"px-2.5 py-1":"px-3 py-1.5"),children:I.jsx("span",{ref:b,className:H("block font-semibold text-fg-primary tabular-nums select-none",y?"min-w-[1.5rem] text-[11px]":"min-w-[2rem] text-xs","text-center"),children:C})}),I.jsx("button",{type:"button",onClick:S,disabled:!a,"aria-label":"Next",className:H("flex items-center justify-center rounded-full transition-all duration-100","text-fg-muted hover:text-fg-primary active:scale-90","disabled:opacity-25 disabled:pointer-events-none",y?"w-5 h-5":"w-6 h-6"),children:I.jsx(vt,{className:y?"w-3 h-3":"w-3.5 h-3.5"})})]}),I.jsx(pt,{children:w&&I.jsx(Ae,{static:!0,anchor:"bottom",className:"z-50 mt-2",children:I.jsx(dt.div,{initial:{opacity:0,y:-4,scale:.98},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-4,scale:.98},transition:ft.dropdown,className:H("surface-elevated radius-inset p-1","shadow-[var(--neo-outer)]"),children:I.jsx("div",{className:"grid grid-cols-4 gap-0.5",children:e.map((p,f)=>I.jsx("button",{type:"button",onClick:()=>{f!==n&&t(f),d()},className:H("px-2.5 py-1.5 radius-control text-xs font-medium transition-colors",f===n?"shadow-[inset_0_0_0_1.5px_var(--sys-blue)] text-fg-primary":"text-fg-secondary hover:bg-overlay-soft"),children:p.label},p.label))})})})})]})})}const Zt=l.memo(Yt);export{Wt as C,Zt as T}; + */const Vt=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],Wt=it("chevron-left",Vt);function Ht({ranges:e,selectedIndex:n,onSelect:t,isPending:v,size:h="default"}){var B;const b=l.useRef(null),r=n>0,a=n{var f;const p=w==="left"?6:-6;(f=b.current)==null||f.animate([{opacity:1,transform:"translateX(0)"},{opacity:0,transform:`translateX(${p}px)`}],{duration:80,easing:"ease-out"}),setTimeout(()=>{var P;d(),(P=b.current)==null||P.animate([{opacity:0,transform:`translateX(${-p}px)`},{opacity:1,transform:"translateX(0)"}],{duration:80,easing:"ease-out"})},80)},x=()=>r&&s("left",()=>t(n-1)),S=()=>a&&s("right",()=>t(n+1));return I.jsx(Kt,{className:"relative inline-flex",children:({open:w,close:d})=>I.jsxs(I.Fragment,{children:[I.jsxs("div",{className:K("inline-flex items-center rounded-full bg-surface","shadow-[var(--neo-outer-sm)]",y?"gap-0.5 p-0.5":"gap-0.5 p-1",v&&"opacity-70"),children:[I.jsx("button",{type:"button",onClick:x,disabled:!r,"aria-label":"Previous",className:K("flex items-center justify-center rounded-full transition-all duration-100","text-fg-muted hover:text-fg-primary active:scale-90","disabled:opacity-25 disabled:pointer-events-none",y?"w-5 h-5":"w-6 h-6"),children:I.jsx(Wt,{className:y?"w-3 h-3":"w-3.5 h-3.5"})}),I.jsx(Me,{className:K("rounded-full cursor-pointer transition-all","bg-surface shadow-[inset_0_0_0_1.5px_var(--sys-blue)]",y?"px-2.5 py-1":"px-3 py-1.5"),children:I.jsx("span",{ref:b,className:K("block font-semibold text-fg-primary tabular-nums select-none",y?"min-w-[1.5rem] text-[11px]":"min-w-[2rem] text-xs","text-center"),children:C})}),I.jsx("button",{type:"button",onClick:S,disabled:!a,"aria-label":"Next",className:K("flex items-center justify-center rounded-full transition-all duration-100","text-fg-muted hover:text-fg-primary active:scale-90","disabled:opacity-25 disabled:pointer-events-none",y?"w-5 h-5":"w-6 h-6"),children:I.jsx(vt,{className:y?"w-3 h-3":"w-3.5 h-3.5"})})]}),I.jsx(pt,{children:w&&I.jsx(Ae,{static:!0,anchor:"bottom",className:"z-50 mt-2",children:I.jsx(dt.div,{initial:{opacity:0,y:-4,scale:.98},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-4,scale:.98},transition:ft.dropdown,className:K("surface-elevated radius-inset p-1","shadow-[var(--neo-outer)]"),children:I.jsx("div",{className:"grid grid-cols-4 gap-0.5",children:e.map((p,f)=>I.jsx("button",{type:"button",onClick:()=>{f!==n&&t(f),d()},className:K("px-2.5 py-1.5 radius-control text-xs font-medium transition-colors",f===n?"shadow-[inset_0_0_0_1.5px_var(--sys-blue)] text-fg-primary":"text-fg-secondary hover:bg-overlay-soft"),children:p.label},p.label))})})})})]})})}const Zt=l.memo(Ht);export{Wt as C,Zt as T}; diff --git a/frontend/dist/assets/activity-Bmh45lNn.js b/frontend/dist/assets/activity-BG24yKp1.js similarity index 89% rename from frontend/dist/assets/activity-Bmh45lNn.js rename to frontend/dist/assets/activity-BG24yKp1.js index fb24eb05..eb9a7426 100644 --- a/frontend/dist/assets/activity-Bmh45lNn.js +++ b/frontend/dist/assets/activity-BG24yKp1.js @@ -1,4 +1,4 @@ -import{d as t}from"./index-C1ZF7cAz.js";/** +import{d as t}from"./index-DhkG1Nx9.js";/** * @license lucide-react v0.559.0 - ISC * * This source code is licensed under the ISC license. diff --git a/frontend/dist/assets/antenna-Bvc4sU0O.js b/frontend/dist/assets/antenna-Dw5nF1O3.js similarity index 90% rename from frontend/dist/assets/antenna-Bvc4sU0O.js rename to frontend/dist/assets/antenna-Dw5nF1O3.js index c7c646e9..9a770002 100644 --- a/frontend/dist/assets/antenna-Bvc4sU0O.js +++ b/frontend/dist/assets/antenna-Dw5nF1O3.js @@ -1,4 +1,4 @@ -import{d as e}from"./index-C1ZF7cAz.js";/** +import{d as e}from"./index-DhkG1Nx9.js";/** * @license lucide-react v0.559.0 - ISC * * This source code is licensed under the ISC license. diff --git a/frontend/dist/assets/arrow-up-DhGrEgP7.js b/frontend/dist/assets/arrow-up-Bg1A345J.js similarity index 92% rename from frontend/dist/assets/arrow-up-DhGrEgP7.js rename to frontend/dist/assets/arrow-up-Bg1A345J.js index af9f6cf1..d0c9b1b0 100644 --- a/frontend/dist/assets/arrow-up-DhGrEgP7.js +++ b/frontend/dist/assets/arrow-up-Bg1A345J.js @@ -1,4 +1,4 @@ -import{d as o}from"./index-C1ZF7cAz.js";/** +import{d as o}from"./index-DhkG1Nx9.js";/** * @license lucide-react v0.559.0 - ISC * * This source code is licensed under the ISC license. diff --git a/frontend/dist/assets/bucketing.worker-D2Fn452R.js b/frontend/dist/assets/bucketing.worker-D0TT0k8y.js similarity index 96% rename from frontend/dist/assets/bucketing.worker-D2Fn452R.js rename to frontend/dist/assets/bucketing.worker-D0TT0k8y.js index aa9532e5..ee293bf2 100644 --- a/frontend/dist/assets/bucketing.worker-D2Fn452R.js +++ b/frontend/dist/assets/bucketing.worker-D0TT0k8y.js @@ -1 +1 @@ -(function(){"use strict";function C(c,y,r,M,n,f,T){const i=c.length;if(i===0)return null;const a=new Uint32Array(i),I=new Int32Array(i);let o=0;for(let e=0;e=n&&t<=f&&r[e]>0&&(a[o]=e,I[o]=Math.floor((t-n)/300),o++)}if(o===0)return null;const d=new Map;for(let e=0;es&&(s=g)}const b=t/3e5*100;if(s>0)for(const m of e)u[m]=y[a[m]]/s*b}let h=c[a[0]],A=c[a[0]];for(let e=1;eA&&(A=t)}const k=f-n||1,l=new Float64Array(o);for(let e=0;et[1]-e[1]).slice(0,5).map(([e,t])=>({value:e,count:t,percent:t/o*100})),D=0;let p;if(T==="share")p=200;else{const t=Math.ceil(V/5)*5;t<=10?p=10:p=t+5}const S=new Float32Array(o*2),_=new Float32Array(o),E=new Uint8Array(o),U=new Float32Array(o);for(let e=0;e{const{type:y,payload:r}=c.data;if(y!=="compute")return;const M=performance.now();try{const n=C(r.timestamps,r.airtimeMs,r.byteSizes,r.packetTypes,r.startTs,r.endTs,r.mode);if(!n){const a={type:"error",error:"No packets in time range"};self.postMessage(a);return}const f=performance.now()-M,T={type:"result",payload:n,computeTimeMs:f},i=[n.points.buffer,n.rawValues.buffer,n.packetTypes.buffer,n.timestamps.buffer];self.postMessage(T,i)}catch(n){const f={type:"error",error:n instanceof Error?n.message:String(n)};self.postMessage(f)}}})(); +(function(){"use strict";function C(c,y,r,M,n,f,T){const i=c.length;if(i===0)return null;const a=new Uint32Array(i),I=new Int32Array(i);let o=0;for(let e=0;e=n&&t<=f&&r[e]>0&&(a[o]=e,I[o]=Math.floor((t-n)/300),o++)}if(o===0)return null;const d=new Map;for(let e=0;es&&(s=g)}const b=t/3e5*100;if(s>0)for(const m of e)u[m]=y[a[m]]/s*b}let h=c[a[0]],A=c[a[0]];for(let e=1;eA&&(A=t)}const k=f-n||1,l=new Float64Array(o);for(let e=0;et[1]-e[1]).slice(0,5).map(([e,t])=>({value:e,count:t,percent:t/o*100})),D=0;let p;if(T==="share")p=240;else{const t=Math.ceil(V/5)*5;t<=10?p=10:p=t+5}const S=new Float32Array(o*2),_=new Float32Array(o),E=new Uint8Array(o),U=new Float32Array(o);for(let e=0;e{const{type:y,payload:r}=c.data;if(y!=="compute")return;const M=performance.now();try{const n=C(r.timestamps,r.airtimeMs,r.byteSizes,r.packetTypes,r.startTs,r.endTs,r.mode);if(!n){const a={type:"error",error:"No packets in time range"};self.postMessage(a);return}const f=performance.now()-M,T={type:"result",payload:n,computeTimeMs:f},i=[n.points.buffer,n.rawValues.buffer,n.packetTypes.buffer,n.timestamps.buffer];self.postMessage(T,i)}catch(n){const f={type:"error",error:n instanceof Error?n.message:String(n)};self.postMessage(f)}}})(); diff --git a/frontend/dist/assets/chat-utils-BzC-Ehs-.js b/frontend/dist/assets/chat-utils-DA-kxQ-o.js similarity index 94% rename from frontend/dist/assets/chat-utils-BzC-Ehs-.js rename to frontend/dist/assets/chat-utils-DA-kxQ-o.js index 143341c7..956401b7 100644 --- a/frontend/dist/assets/chat-utils-BzC-Ehs-.js +++ b/frontend/dist/assets/chat-utils-DA-kxQ-o.js @@ -1 +1 @@ -import{cW as a,r as l}from"./index-C1ZF7cAz.js";const s=[a.green,a.blue,a.amber,a.pink,a.purple,a.cyan,a.orange,a.teal];function m(e){let n=0;for(let t=0;t0){const t=n[0],o=e.replace(i,"").trim();return{emoji:t,cleanName:o||e}}return{emoji:null,cleanName:e}}function f(e){const{cleanName:n}=u(e),t=n.split(/[\s-_]+/).filter(Boolean);if(t.length>=2){const r=Array.from(t[0])[0]||"",c=Array.from(t[1])[0]||"";return(r+c).toUpperCase()}return Array.from(n).slice(0,2).join("").toUpperCase()}function p(e){return new Date(e*1e3).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!1})}function g(e){const n=/@\[([^\]]+)\]/g,t=[];let o=0,r;for(;(r=n.exec(e))!==null;)r.index>o&&t.push(e.slice(o,r.index)),t.push(l.createElement("span",{key:r.index,className:"font-extrabold text-white"},r[1])),o=r.index+r[0].length;return o0?t:e}export{f as a,p as b,u as e,g as f,m as g}; +import{cU as a,r as l}from"./index-DhkG1Nx9.js";const s=[a.green,a.blue,a.amber,a.pink,a.purple,a.cyan,a.orange,a.teal];function m(e){let n=0;for(let t=0;t0){const t=n[0],o=e.replace(i,"").trim();return{emoji:t,cleanName:o||e}}return{emoji:null,cleanName:e}}function f(e){const{cleanName:n}=u(e),t=n.split(/[\s-_]+/).filter(Boolean);if(t.length>=2){const r=Array.from(t[0])[0]||"",c=Array.from(t[1])[0]||"";return(r+c).toUpperCase()}return Array.from(n).slice(0,2).join("").toUpperCase()}function p(e){return new Date(e*1e3).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!1})}function g(e){const n=/@\[([^\]]+)\]/g,t=[];let o=0,r;for(;(r=n.exec(e))!==null;)r.index>o&&t.push(e.slice(o,r.index)),t.push(l.createElement("span",{key:r.index,className:"font-extrabold text-white"},r[1])),o=r.index+r[0].length;return o0?t:e}export{f as a,p as b,u as e,g as f,m as g}; diff --git a/frontend/dist/assets/chevron-right-DzbDJf-i.js b/frontend/dist/assets/chevron-right-na13OQfy.js similarity index 85% rename from frontend/dist/assets/chevron-right-DzbDJf-i.js rename to frontend/dist/assets/chevron-right-na13OQfy.js index e153ba73..66bf0c28 100644 --- a/frontend/dist/assets/chevron-right-DzbDJf-i.js +++ b/frontend/dist/assets/chevron-right-na13OQfy.js @@ -1,4 +1,4 @@ -import{d as o}from"./index-C1ZF7cAz.js";/** +import{d as o}from"./index-DhkG1Nx9.js";/** * @license lucide-react v0.559.0 - ISC * * This source code is licensed under the ISC license. diff --git a/frontend/dist/assets/circle-check-DY6oislV.js b/frontend/dist/assets/circle-check-DJNUSJlu.js similarity index 87% rename from frontend/dist/assets/circle-check-DY6oislV.js rename to frontend/dist/assets/circle-check-DJNUSJlu.js index 68aa854b..809f8723 100644 --- a/frontend/dist/assets/circle-check-DY6oislV.js +++ b/frontend/dist/assets/circle-check-DJNUSJlu.js @@ -1,4 +1,4 @@ -import{d as c}from"./index-C1ZF7cAz.js";/** +import{d as c}from"./index-DhkG1Nx9.js";/** * @license lucide-react v0.559.0 - ISC * * This source code is licensed under the ISC license. diff --git a/frontend/dist/assets/circle-question-mark-CxqvWhsl.js b/frontend/dist/assets/circle-question-mark--xh93QHC.js similarity index 89% rename from frontend/dist/assets/circle-question-mark-CxqvWhsl.js rename to frontend/dist/assets/circle-question-mark--xh93QHC.js index 38c1747f..1b23a8f1 100644 --- a/frontend/dist/assets/circle-question-mark-CxqvWhsl.js +++ b/frontend/dist/assets/circle-question-mark--xh93QHC.js @@ -1,4 +1,4 @@ -import{d as c}from"./index-C1ZF7cAz.js";/** +import{d as c}from"./index-DhkG1Nx9.js";/** * @license lucide-react v0.559.0 - ISC * * This source code is licensed under the ISC license. diff --git a/frontend/dist/assets/consumer-registry-CFnLzQEu.js b/frontend/dist/assets/consumer-registry-CTQIn0m9.js similarity index 92% rename from frontend/dist/assets/consumer-registry-CFnLzQEu.js rename to frontend/dist/assets/consumer-registry-CTQIn0m9.js index be11e527..1b56fe96 100644 --- a/frontend/dist/assets/consumer-registry-CFnLzQEu.js +++ b/frontend/dist/assets/consumer-registry-CTQIn0m9.js @@ -1 +1 @@ -import{a7 as n,r as i}from"./index-C1ZF7cAz.js";const p=t=>(t.type??t.payload_type)===n.ADVERT,l=t=>(t.type??t.payload_type)===n.TRACE,h=t=>(t.type??t.payload_type)===n.TXT_MSG,_=t=>(t.type??t.payload_type)===n.PATH,d=t=>(t.type??t.payload_type)===n.ACK,g=t=>{const e=t.type??t.payload_type;return e===n.GRP_TXT||e===n.GRP_DATA},m=t=>(t.path_length??(Array.isArray(t.original_path)?t.original_path.length:0))>0,A=t=>!!t.src_hash,T=t=>t.airtime_ms!=null,c=new Set,o=new Map;function a(t,e){return`${t}|${e}`}function u(t,e){const s=a(t,e);o.set(s,(o.get(s)??0)+1)}function y(t,e){const s=a(t,e),r=o.get(s)??0;r>1?o.set(s,r-1):o.delete(s)}function C(t){for(const e of t){const s=a(e.target,e.fn);c.has(s)||c.add(s)}}function P(t){i.useEffect(()=>{for(const e of t)u(e.target,e.fn);return()=>{for(const e of t)y(e.target,e.fn)}},[t])}export{m as a,A as b,h as c,d,p as e,l as f,_ as g,T as h,g as i,C as r,P as u}; +import{ab as n,r as i}from"./index-DhkG1Nx9.js";const p=t=>(t.type??t.payload_type)===n.ADVERT,l=t=>(t.type??t.payload_type)===n.TRACE,h=t=>(t.type??t.payload_type)===n.TXT_MSG,_=t=>(t.type??t.payload_type)===n.PATH,d=t=>(t.type??t.payload_type)===n.ACK,g=t=>{const e=t.type??t.payload_type;return e===n.GRP_TXT||e===n.GRP_DATA},m=t=>(t.path_length??(Array.isArray(t.original_path)?t.original_path.length:0))>0,A=t=>!!t.src_hash,T=t=>t.airtime_ms!=null,c=new Set,o=new Map;function a(t,e){return`${t}|${e}`}function u(t,e){const s=a(t,e);o.set(s,(o.get(s)??0)+1)}function y(t,e){const s=a(t,e),r=o.get(s)??0;r>1?o.set(s,r-1):o.delete(s)}function C(t){for(const e of t){const s=a(e.target,e.fn);c.has(s)||c.add(s)}}function P(t){i.useEffect(()=>{for(const e of t)u(e.target,e.fn);return()=>{for(const e of t)y(e.target,e.fn)}},[t])}export{m as a,A as b,h as c,d,p as e,l as f,_ as g,T as h,g as i,C as r,P as u}; diff --git a/frontend/dist/assets/dashboard-bucketing.worker-RVncOvX0.js b/frontend/dist/assets/dashboard-bucketing.worker-RVncOvX0.js new file mode 100644 index 00000000..3b7df9d5 --- /dev/null +++ b/frontend/dist/assets/dashboard-bucketing.worker-RVncOvX0.js @@ -0,0 +1 @@ +(function(){"use strict";function k(f,g,o,L,i,B,N,z,E,U,m,s){const d=m*60/s,J=Math.floor(Date.now()/1e3),x=Math.floor(J/d)*d,_=x-m*60,p=new Array(s),w=new Array(s),A=new Array(s),u=new Array(s),I=new Array(s),W=new Float64Array(s),q=new Float64Array(s),R=new Uint32Array(s),D=new Array(s),F=new Array(s),G=new Array(s),M=new Array(s),O={},h={},v={};let X=0,b=0,S=0;for(let e=0;ex)continue;const t=Math.floor((r-_)/d);if(t<0||t>=s)continue;const a=g[e],T=i[e],V=B[e],j=N[e],n=L[e],y=o[e];if(T===1?(A[t].count++,A[t].airtime_ms+=a):T===2||V&&T!==1?(u[t].count++,u[t].airtime_ms+=a):j&&(I[t].count++,I[t].airtime_ms+=a),T!==1){p[t].count++,p[t].airtime_ms+=a,W[t]+=z[e],q[t]+=E[e],R[t]++;const c=U[e];D[t].has(c)||(D[t].add(c),w[t].count++,w[t].airtime_ms+=a);const P=F[t];P.bytesByType[n]=(P.bytesByType[n]??0)+y,P.totalBytes+=y,O[n]=(O[n]??0)+y,S+=y}if(T===2||V&&T!==1){const c=G[t];c.bytesByType[n]=(c.bytesByType[n]??0)+y,c.totalBytes+=y,h[n]=(h[n]??0)+y,X++}if(j){const c=M[t];c.bytesByType[n]=(c.bytesByType[n]??0)+y,c.totalBytes+=y,v[n]=(v[n]??0)+y,b++}}for(let e=0;e0&&(p[e].avg_snr=W[e]/R[e],p[e].avg_rssi=q[e]/R[e]);const H=e=>Object.keys(e).map(r=>parseInt(r,10)).filter(r=>e[r]>0).sort((r,t)=>e[t]-e[r]),l=m/60;return{time_range_minutes:m,bucket_count:s,bucket_duration_seconds:d,start_time:_,end_time:x,received:p,unique_received:w,transmitted:A,forwarded:u,dropped:I,receivedBytesBuckets:F,receivedActiveTypes:H(O),receivedTotalByType:O,forwardedBytesBuckets:G,forwardedActiveTypes:H(h),forwardedTotalByType:h,forwardedRatePerHour:l>0?Math.round(X/l):0,totalForwardedCount:X,droppedBytesBuckets:M,droppedActiveTypes:H(v),droppedTotalByType:v,droppedRatePerHour:l>0?Math.round(b/l):0,totalDroppedCount:b,totalReceivedBytes:S,kbPerHour:l>0?Math.round(S/1024/l):0}}self.onmessage=f=>{const{type:g,payload:o}=f.data;if(g!=="compute")return;const L=performance.now();try{const i=k(o.timestamps,o.airtimeMs,o.byteSizes,o.payloadTypes,o.origins,o.transmitted,o.dropped,o.snrValues,o.rssiValues,o.hashIndices,o.rangeMinutes,o.bucketCount),B=performance.now()-L,N={type:"result",payload:i,computeTimeMs:B};self.postMessage(N)}catch(i){const B={type:"error",error:i instanceof Error?i.message:String(i)};self.postMessage(B)}}})(); diff --git a/frontend/dist/assets/database-CdKnhwkJ.js b/frontend/dist/assets/database-DE8k8U0g.js similarity index 89% rename from frontend/dist/assets/database-CdKnhwkJ.js rename to frontend/dist/assets/database-DE8k8U0g.js index 4b4475b3..db09d5fb 100644 --- a/frontend/dist/assets/database-CdKnhwkJ.js +++ b/frontend/dist/assets/database-DE8k8U0g.js @@ -1,4 +1,4 @@ -import{d as e}from"./index-C1ZF7cAz.js";/** +import{d as e}from"./index-DhkG1Nx9.js";/** * @license lucide-react v0.559.0 - ISC * * This source code is licensed under the ISC license. diff --git a/frontend/dist/assets/download-DbDw1ZiV.js b/frontend/dist/assets/download-d0PZoGJ2.js similarity index 89% rename from frontend/dist/assets/download-DbDw1ZiV.js rename to frontend/dist/assets/download-d0PZoGJ2.js index c1f8bfdd..142cf83a 100644 --- a/frontend/dist/assets/download-DbDw1ZiV.js +++ b/frontend/dist/assets/download-d0PZoGJ2.js @@ -1,4 +1,4 @@ -import{d as o}from"./index-C1ZF7cAz.js";/** +import{d as o}from"./index-DhkG1Nx9.js";/** * @license lucide-react v0.559.0 - ISC * * This source code is licensed under the ISC license. diff --git a/frontend/dist/assets/easing-BGz60jqS.js b/frontend/dist/assets/easing-Ch_Y3tms.js similarity index 67% rename from frontend/dist/assets/easing-BGz60jqS.js rename to frontend/dist/assets/easing-Ch_Y3tms.js index 3f073f93..db302b26 100644 --- a/frontend/dist/assets/easing-BGz60jqS.js +++ b/frontend/dist/assets/easing-Ch_Y3tms.js @@ -1,6 +1,6 @@ -import{d as s,fv as a}from"./index-C1ZF7cAz.js";/** +import{d as s,fu as a}from"./index-DhkG1Nx9.js";/** * @license lucide-react v0.559.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const c=[["path",{d:"m16.24 7.76-1.804 5.411a2 2 0 0 1-1.265 1.265L7.76 16.24l1.804-5.411a2 2 0 0 1 1.265-1.265z",key:"9ktpf1"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],t=s("compass",c),o=a(.65,0,.35,1),n=a(.33,1,.68,1),u=a(.33,.67,.67,1),i=a(.76,0,.24,1);export{t as C,n as a,o as b,u as c,i as e}; + */const c=[["path",{d:"m16.24 7.76-1.804 5.411a2 2 0 0 1-1.265 1.265L7.76 16.24l1.804-5.411a2 2 0 0 1 1.265-1.265z",key:"9ktpf1"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],t=s("compass",c),o=a(.65,0,.35,1),u=a(.33,1,.68,1),n=a(.33,.67,.67,1),i=a(.76,0,.24,1);export{t as C,u as a,o as b,n as c,i as e}; diff --git a/frontend/dist/assets/element-movement-CuySBNA6.js b/frontend/dist/assets/element-movement-BPGrReFv.js similarity index 57% rename from frontend/dist/assets/element-movement-CuySBNA6.js rename to frontend/dist/assets/element-movement-BPGrReFv.js index b3f302d6..ede2d01d 100644 --- a/frontend/dist/assets/element-movement-CuySBNA6.js +++ b/frontend/dist/assets/element-movement-BPGrReFv.js @@ -1 +1 @@ -import{r as o,aj as v,cp as h,e1 as b,e2 as w,cG as x,aX as c,a_ as R}from"./index-C1ZF7cAz.js";function y(e,t){return e!==null&&t!==null&&typeof e=="object"&&typeof t=="object"&&"id"in e&&"id"in t?e.id===t.id:e===t}function j(e=y){return o.useCallback((t,r)=>{if(typeof e=="string"){let u=e;return(t==null?void 0:t[u])===(r==null?void 0:r[u])}return e(t,r)},[e])}var $=(e=>(e[e.Left=0]="Left",e[e.Right=2]="Right",e))($||{});function N(e){let t=o.useRef(null),r=v(l=>{t.current=l.pointerType,!h(l.currentTarget)&&l.pointerType==="mouse"&&l.button===$.Left&&(l.preventDefault(),e(l))}),u=v(l=>{t.current!=="mouse"&&(h(l.currentTarget)||e(l))});return{onPointerDown:r,onClick:u}}var S=(e=>(e[e.Ignore=0]="Ignore",e[e.Select=1]="Select",e[e.Close=2]="Close",e))(S||{});const z={Ignore:{kind:0},Select:e=>({kind:1,target:e}),Close:{kind:2}},I=200,k=5;function F(e,{trigger:t,action:r,close:u,select:l}){let n=o.useRef(null),i=o.useRef(null),a=o.useRef(null);b(e&&t!==null,"pointerdown",s=>{w(s==null?void 0:s.target)&&t!=null&&t.contains(s.target)&&(i.current=s.x,a.current=s.y,n.current=s.timeStamp)}),b(e&&t!==null,"pointerup",s=>{var d,f;let p=n.current;if(p===null||(n.current=null,!x(s.target))||Math.abs(s.x-((d=i.current)!=null?d:s.x))I&&(l(g.target),u());break}case 2:{u();break}}},{capture:!0})}function m(e){return[e.screenX,e.screenY]}function P(){let e=o.useRef([-1,-1]);return{wasMoved(t){let r=m(t);return e.current[0]===r[0]&&e.current[1]===r[1]?!1:(e.current=r,!0)},update(t){e.current=m(t)}}}function L({children:e,freeze:t},r){let u=E(t,e);return o.isValidElement(u)?o.cloneElement(u,{ref:r}):c.createElement(c.Fragment,null,u)}const X=c.forwardRef(L);function E(e,t){let[r,u]=o.useState(t);return!e&&r!==t&&u(t),e?r:t}function T(e){throw new Error("Unexpected object: "+e)}var C=(e=>(e[e.First=0]="First",e[e.Previous=1]="Previous",e[e.Next=2]="Next",e[e.Last=3]="Last",e[e.Specific=4]="Specific",e[e.Nothing=5]="Nothing",e))(C||{});function A(e,t){let r=t.resolveItems();if(r.length<=0)return null;let u=t.resolveActiveIndex(),l=u??-1;switch(e.focus){case 0:{for(let n=0;n=0;--n)if(!t.resolveDisabled(r[n],n,r))return n;return u}case 2:{for(let n=l+1;n=0;--n)if(!t.resolveDisabled(r[n],n,r))return n;return u}case 4:{for(let n=0;n({kind:"Tracked",position:e}),Moved:{kind:"Moved"}};function D(e){let t=e.getBoundingClientRect();return`${t.x},${t.y}`}function G(e,t,r){let u=R();if(t.kind==="Tracked"){let l=function(){n!==D(e)&&(u.dispose(),r())},{position:n}=t,i=new ResizeObserver(l);i.observe(e),u.add(()=>i.disconnect()),u.addEventListener(window,"scroll",l,{passive:!0}),u.addEventListener(window,"resize",l)}return()=>u.dispose()}export{F as L,z as S,B as a,D as b,C as c,X as d,P as e,A as f,$ as g,j as h,G as p,N as s,E as u}; +import{r as o,am as v,cn as b,d$ as h,e0 as w,cE as x,a_ as c,b1 as R}from"./index-DhkG1Nx9.js";function y(e,t){return e!==null&&t!==null&&typeof e=="object"&&typeof t=="object"&&"id"in e&&"id"in t?e.id===t.id:e===t}function N(e=y){return o.useCallback((t,r)=>{if(typeof e=="string"){let u=e;return(t==null?void 0:t[u])===(r==null?void 0:r[u])}return e(t,r)},[e])}var $=(e=>(e[e.Left=0]="Left",e[e.Right=2]="Right",e))($||{});function j(e){let t=o.useRef(null),r=v(l=>{t.current=l.pointerType,!b(l.currentTarget)&&l.pointerType==="mouse"&&l.button===$.Left&&(l.preventDefault(),e(l))}),u=v(l=>{t.current!=="mouse"&&(b(l.currentTarget)||e(l))});return{onPointerDown:r,onClick:u}}var S=(e=>(e[e.Ignore=0]="Ignore",e[e.Select=1]="Select",e[e.Close=2]="Close",e))(S||{});const z={Ignore:{kind:0},Select:e=>({kind:1,target:e}),Close:{kind:2}},E=200,k=5;function F(e,{trigger:t,action:r,close:u,select:l}){let n=o.useRef(null),i=o.useRef(null),a=o.useRef(null);h(e&&t!==null,"pointerdown",s=>{w(s==null?void 0:s.target)&&t!=null&&t.contains(s.target)&&(i.current=s.x,a.current=s.y,n.current=s.timeStamp)}),h(e&&t!==null,"pointerup",s=>{var d,f;let g=n.current;if(g===null||(n.current=null,!x(s.target))||Math.abs(s.x-((d=i.current)!=null?d:s.x))E&&(l(p.target),u());break}case 2:{u();break}}},{capture:!0})}function m(e){return[e.screenX,e.screenY]}function P(){let e=o.useRef([-1,-1]);return{wasMoved(t){let r=m(t);return e.current[0]===r[0]&&e.current[1]===r[1]?!1:(e.current=r,!0)},update(t){e.current=m(t)}}}function I({children:e,freeze:t},r){let u=L(t,e);return o.isValidElement(u)?o.cloneElement(u,{ref:r}):c.createElement(c.Fragment,null,u)}const A=c.forwardRef(I);function L(e,t){let[r,u]=o.useState(t);return!e&&r!==t&&u(t),e?r:t}function T(e){throw new Error("Unexpected object: "+e)}var C=(e=>(e[e.First=0]="First",e[e.Previous=1]="Previous",e[e.Next=2]="Next",e[e.Last=3]="Last",e[e.Specific=4]="Specific",e[e.Nothing=5]="Nothing",e))(C||{});function B(e,t){let r=t.resolveItems();if(r.length<=0)return null;let u=t.resolveActiveIndex(),l=u??-1;switch(e.focus){case 0:{for(let n=0;n=0;--n)if(!t.resolveDisabled(r[n],n,r))return n;return u}case 2:{for(let n=l+1;n=0;--n)if(!t.resolveDisabled(r[n],n,r))return n;return u}case 4:{for(let n=0;n({kind:"Tracked",position:e}),Moved:{kind:"Moved"}};function D(e){let t=e.getBoundingClientRect();return`${t.x},${t.y}`}function O(e,t,r){let u=R();if(t.kind==="Tracked"){let l=function(){n!==D(e)&&(u.dispose(),r())},{position:n}=t,i=new ResizeObserver(l);i.observe(e),u.add(()=>i.disconnect()),u.addEventListener(window,"scroll",l,{passive:!0}),u.addEventListener(window,"resize",l)}return()=>u.dispose()}export{F as L,z as S,H as a,D as b,C as c,A as d,P as e,B as f,$ as g,N as h,O as p,j as s,L as u}; diff --git a/frontend/dist/assets/funnel-zG3cM6J7.js b/frontend/dist/assets/funnel-Dr2cCUci.js similarity index 89% rename from frontend/dist/assets/funnel-zG3cM6J7.js rename to frontend/dist/assets/funnel-Dr2cCUci.js index 6d8f1c7f..1dc6ef0e 100644 --- a/frontend/dist/assets/funnel-zG3cM6J7.js +++ b/frontend/dist/assets/funnel-Dr2cCUci.js @@ -1,4 +1,4 @@ -import{d as e}from"./index-C1ZF7cAz.js";/** +import{d as e}from"./index-DhkG1Nx9.js";/** * @license lucide-react v0.559.0 - ISC * * This source code is licensed under the ISC license. diff --git a/frontend/dist/assets/hash-2pKM_KWy.js b/frontend/dist/assets/hash-KLxvul5e.js similarity index 90% rename from frontend/dist/assets/hash-2pKM_KWy.js rename to frontend/dist/assets/hash-KLxvul5e.js index 0a7201ba..49685117 100644 --- a/frontend/dist/assets/hash-2pKM_KWy.js +++ b/frontend/dist/assets/hash-KLxvul5e.js @@ -1,4 +1,4 @@ -import{d as e}from"./index-C1ZF7cAz.js";/** +import{d as e}from"./index-DhkG1Nx9.js";/** * @license lucide-react v0.559.0 - ISC * * This source code is licensed under the ISC license. diff --git a/frontend/dist/assets/index-DCNWD5GU.js b/frontend/dist/assets/index-Bx_G2nLG.js similarity index 91% rename from frontend/dist/assets/index-DCNWD5GU.js rename to frontend/dist/assets/index-Bx_G2nLG.js index 8a57ff64..54d6750a 100644 --- a/frontend/dist/assets/index-DCNWD5GU.js +++ b/frontend/dist/assets/index-Bx_G2nLG.js @@ -1 +1 @@ -import{fw as ve,fx as Ae,fy as we,fz as Ee,r as l,fA as B,bf as oe,j as S,fB as Ie,fC as je,fD as Me,fE as De,fF as le,fG as Re,fH as ke,fI as $e,fJ as Ce,fK as Ve,fL as Ne,fM as Te,fN as We,fO as Le,fP as Pe,fQ as _,fR as Oe,fS as Be,fT as Fe,m as R,fU as Ge,fV as ue,A as ce,bs as Ke,fW as ze,fX as _e}from"./index-C1ZF7cAz.js";const He=(t,e,n)=>{const i=e-t;return((n-t)%i+i)%i+t};function fe(t,e){return ve(t)?t[He(0,t.length,e)]:t}class Xe{constructor(e){this.stop=()=>this.runAll("stop"),this.animations=e.filter(Boolean)}get finished(){return Promise.all(this.animations.map(e=>e.finished))}getAll(e){return this.animations[0][e]}setAll(e,n){for(let i=0;ii.attachTimeline(e));return()=>{n.forEach((i,r)=>{i&&i(),this.animations[r].stop()})}}get time(){return this.getAll("time")}set time(e){this.setAll("time",e)}get speed(){return this.getAll("speed")}set speed(e){this.setAll("speed",e)}get state(){return this.getAll("state")}get startTime(){return this.getAll("startTime")}get duration(){return ne(this.animations,"duration")}get iterationDuration(){return ne(this.animations,"iterationDuration")}runAll(e){this.animations.forEach(n=>n[e]())}play(){this.runAll("play")}pause(){this.runAll("pause")}cancel(){this.runAll("cancel")}complete(){this.runAll("complete")}}function ne(t,e){let n=0;for(let i=0;in&&(n=r)}return n}class Je extends Xe{then(e,n){return this.finished.finally(e).then(()=>{})}}function Ue(t,e){return t in e}class Ye extends Ae{constructor(){super(...arguments),this.type="object"}readValueFromInstance(e,n){if(Ue(n,e)){const i=e[n];if(typeof i=="string"||typeof i=="number")return i}}getBaseTargetFromProps(){}removeValueFromRenderState(e,n){delete n.output[e]}measureInstanceViewportBox(){return we()}build(e,n){Object.assign(e.output,n)}renderInstance(e,{output:n}){Object.assign(e,n)}sortInstanceNodePosition(){return 0}}function Qe({children:t,isValidProp:e,...n}){e&&Ee(e),n={...l.useContext(B),...n},n.isStatic=oe(()=>n.isStatic);const i=l.useMemo(()=>n,[JSON.stringify(n.transition),n.transformPagePoint,n.reducedMotion]);return S.jsx(B.Provider,{value:i,children:t})}function qe(t){const e=oe(()=>Ie(t)),{isStatic:n}=l.useContext(B);if(n){const[,i]=l.useState(t);l.useEffect(()=>e.on("change",i),[])}return e}function U(t){return typeof t=="object"&&!Array.isArray(t)}function de(t,e,n,i){return t==null?[]:typeof t=="string"&&U(e)?je(t,n,i):t instanceof NodeList?Array.from(t):Array.isArray(t)?t.filter(r=>r!=null):[t]}function Ze(t,e,n){return t*(e+1)}function ie(t,e,n,i){return typeof e=="number"?e:e.startsWith("-")||e.startsWith("+")?Math.max(0,t+parseFloat(e)):e==="<"?n:e.startsWith("<")?Math.max(0,n+parseFloat(e.slice(1))):i.get(e)??t}function et(t,e,n){for(let i=0;ie&&r.at{const v=at(A),{delay:C=0,times:E=Re(v),type:W=e.type||"keyframes",repeat:N,repeatType:X,repeatDelay:$t=0,...be}=I;let{ease:V=e.ease||"easeOut",duration:k}=I;const Y=typeof C=="function"?C(D,$):C,Q=v.length,q=Ce(W)?W:r==null?void 0:r[W||"keyframes"];if(Q<=2&&q){let L=100;if(Q===2&&ut(v)){const P=v[1]-v[0];L=Math.abs(P)}const F={...e,...be};k!==void 0&&(F.duration=Ve(k));const G=ke(F,L,q);V=G.ease,k=G.duration}k??(k=y);const Z=p+Y;E.length===1&&E[0]===0&&(E[1]=1);const ee=E.length-v.length;if(ee>0&&$e(E,ee),v.length===1&&v.unshift(null),N){k=Ze(k,N);const L=[...v],F=[...E];V=Array.isArray(V)?[...V]:[V];const G=[...V];for(let P=0;P{for(const c in x){const f=x[c];f.sort(it);const s=[],a=[],w=[];for(let D=0;Dtypeof t=="number",ut=t=>t.every(lt);function ct(t){const e={presenceContext:null,props:{},visualState:{renderState:{transform:{},transformOrigin:{},style:{},vars:{},attrs:{}},latestValues:{}}},n=Te(t)&&!We(t)?new Le(e):new Pe(e);n.mount(t),_.set(t,n)}function ft(t){const e={presenceContext:null,props:{},visualState:{renderState:{output:{}},latestValues:{}}},n=new Ye(e);n.mount(t),_.set(t,n)}function dt(t,e){return le(t)||typeof t=="number"||typeof t=="string"&&!U(e)}function pe(t,e,n,i){const r=[];if(dt(t,e))r.push(Oe(t,U(e)&&e.default||e,n&&(n.default||n)));else{if(t==null)return r;const y=de(t,e,i),u=y.length;for(let g=0;g{i.push(...pe(g,y,u))}),i}function mt(t){return Array.isArray(t)&&t.some(Array.isArray)}function yt(t){function e(n,i,r){let y=[],u;if(mt(n))y=pt(n,i,t);else{const{onComplete:o,...h}=r||{};typeof o=="function"&&(u=o),y=pe(n,i,h,t)}const g=new Je(y);return u&&g.finished.then(u),g}return e}const me=yt(),j="var(--mask-height, 0.15em)",J="var(--mask-width, 0.5em)",T=`calc(${J} / var(--invert-x, 1))`,K="#000 0, transparent 71%",ht=`linear-gradient(to right, transparent 0, #000 ${T}, #000 calc(100% - ${T}), transparent),linear-gradient(to bottom, transparent 0, #000 ${j}, #000 calc(100% - ${j}), transparent 100%),radial-gradient(at bottom right, ${K}),radial-gradient(at bottom left, ${K}), radial-gradient(at top left, ${K}), radial-gradient(at top right, ${K})`,gt=`100% calc(100% - ${j} * 2),calc(100% - ${T} * 2) 100%,${T} ${j},${T} ${j},${T} ${j},${T} ${j}`;Ge({"--invert-x":{correct:(t,{treeScale:e,projectionDelta:n})=>n.x.scale*e.x}});function xt({children:t,layoutDependency:e}){return S.jsx(R.span,{layout:!0,layoutDependency:e,"aria-hidden":!0,style:{display:"inline-flex","--invert-x":1,margin:`0 calc(-1*${J})`,padding:`calc(${j}/2) ${J}`,position:"relative",zIndex:-1,overflow:"clip",WebkitMaskImage:ht,WebkitMaskSize:gt,WebkitMaskPosition:"center, center, top left, top right, bottom right, bottom left",WebkitMaskRepeat:"no-repeat"},children:t})}function ye(){const t=l.useRef(!0);return l.useEffect(()=>{t.current=!1},[]),t.current}function H(t){const{width:e,fontSize:n}=getComputedStyle(t);return`${parseFloat(e)/parseFloat(n)}em`}const he=new WeakMap,St=l.forwardRef(function({value:e,initialValue:n=e,...i},r){const{transition:y}=l.useContext(B),u=l.useRef(n).current,g=ye(),o=l.useRef(null),h=l.useRef(null);l.useImperativeHandle(r,()=>h.current,[]);const b=l.useRef(new Array(10)),p=ue(),m=p?e:0;l.useLayoutEffect(()=>{!o.current||!b.current[u]||(o.current.style.width=H(b.current[u]))},[]);const x=l.useRef(n);l.useLayoutEffect(()=>{var A;if(!o.current||m===x.current)return;const s=o.current.getBoundingClientRect(),a=(A=h.current)==null?void 0:A.getBoundingClientRect(),w=s.height*(m-x.current)+(s.top-(a?a.top||0:s.top));return me(o.current,{y:[w,0]},y),()=>{x.current=m}},[m]);const[d,c]=l.useState();l.useEffect(()=>{if(g&&u===m||!b.current[m])return;const s=H(b.current[m]);h.current&&he.set(h.current,s),c(s)},[m]);const f=s=>S.jsx("span",{style:{display:"inline-block",padding:`calc(${j}/2) 0`},ref:a=>void(b.current[s]=a),children:s},s);return S.jsx(R.span,{...i,ref:h,layout:"position","data-state":p?void 0:"exiting",style:{display:"inline-flex",justifyContent:"center",width:d},children:S.jsxs("span",{ref:o,style:{display:"inline-flex",justifyContent:"center",flexDirection:"column",alignItems:"center",position:"relative"},children:[m!==0&&S.jsx("span",{style:{...ae,bottom:"100%",left:0},children:new Array(m).fill(null).map((s,a)=>f(a))}),f(m),m!==9&&S.jsx("span",{style:{...ae,top:"100%",left:0},children:new Array(9-m).fill(null).map((s,a)=>f(m+a+1))})]})})}),ae={display:"flex",flexDirection:"column",alignItems:"center",position:"absolute",width:"100%"},ge=l.createContext({justify:"left"}),bt=l.forwardRef(function({partKey:e,type:n,children:i,layoutDependency:r,...y},u){const g=ue(),{justify:o}=l.useContext(ge);return S.jsx(R.span,{...y,"data-state":g?void 0:"exiting",style:{display:"inline-flex",justifyContent:o,padding:`calc(${j}/2) 0`,position:"relative"},layout:"position",layoutDependency:r,ref:u,children:S.jsx(ce,{mode:"popLayout",anchorX:o,initial:!1,children:S.jsx(R.span,{layout:o==="right"?"position":!1,layoutDependency:r,initial:{opacity:0},animate:{opacity:[null,1]},exit:{opacity:[null,0]},style:{display:"inline-block",whiteSpace:"pre"},children:i},i)})})}),z=l.forwardRef(function({parts:e,justify:n="left",mode:i,style:r,name:y,layoutDependency:u,...g},o){const h=l.useRef(null);l.useImperativeHandle(o,()=>h.current,[]);const b=l.useMemo(()=>({justify:n}),[n]),p=l.useRef(null),m=ye(),[x,d]=l.useState();return l.useEffect(()=>{if(!p.current)return;if(m){h.current&&(h.current.style.width=H(p.current));return}const c=Array.from(p.current.children).map(f=>{if(!(f instanceof HTMLElement))return;if(f.dataset.state==="exiting"){const w=f.nextSibling;return f.remove(),()=>{p.current&&p.current.insertBefore(f,w)}}const s=he.get(f);if(!s)return;const a=f.style.width;return f.style.width=s,()=>{f.style.width=a}});d(H(p.current));for(let f=c.length-1;f>=0;f--){const s=c[f];s&&s()}},[e.map(c=>c.value).join("")]),S.jsx(ge.Provider,{value:b,children:S.jsx(R.span,{layoutDependency:u,...g,ref:h,className:`number-section-${y}`,style:{...r,display:"inline-flex",justifyContent:n,width:x},children:S.jsxs("span",{ref:p,style:{display:"inline-flex",justifyContent:"inherit",position:"relative"},children:["​",S.jsx(ce,{mode:i,anchorX:n,initial:!1,children:e.map(c=>c.type==="integer"||c.type==="fraction"?S.jsx(St,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},value:c.value,initialValue:m?void 0:0,layoutDependency:u},c.key):S.jsx(bt,{type:c.type,partKey:c.key,initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},layoutDependency:u,children:c.value},c.type==="literal"?`${c.key}:${c.value}`:c.key))})]})})})}),vt=(t,{locales:e,format:n},i,r)=>{const u=new Intl.NumberFormat(e,n).formatToParts(Number(t));i&&u.unshift({type:"prefix",value:i}),r&&u.push({type:"suffix",value:r});const g=[],o=[],h=[],b=[],p={},m=s=>`${s}:${p[s]=(p[s]??-1)+1}`;let x="",d=!1,c=!1;for(const s of u){x+=s.value;const a=s.type==="minusSign"||s.type==="plusSign"?"sign":s.type;switch(a){case"integer":d=!0,o.push(...s.value.split("").map(w=>({type:a,value:parseInt(w)})));break;case"group":o.push({type:a,value:s.value});break;case"decimal":c=!0,h.push({type:a,value:s.value,key:m(a)});break;case"fraction":h.push(...s.value.split("").map(w=>({type:a,value:parseInt(w),key:m(a)})));break;default:(d||c?b:g).push({type:a,value:s.value,key:m(a)})}}const f=[];for(let s=o.length-1;s>=0;s--)f.unshift({...o[s],key:m(o[s].type)});return{pre:g,integer:f,fraction:h,post:b,formatted:x}},At={opacity:{duration:1,ease:ze},layout:{type:"spring",duration:1,bounce:0},y:{type:"spring",duration:1,bounce:0}},Vt=l.forwardRef(function({children:e,locales:n,format:i,transition:r,style:y,suffix:u,prefix:g,...o},h){const b=l.useMemo(()=>vt(e,{locales:n,format:i},g,u),[e,n,i]),{pre:p,integer:m,fraction:x,post:d,formatted:c}=b,f=l.useContext(B).transition;r=r??f??At;const{layoutDependency:s}=o,a=l.useMemo(()=>{if(s!==void 0)return{layoutDependency:s,value:e}},[s,e]);return S.jsx(Ke,{children:S.jsx(Qe,{transition:r,children:S.jsx(R.div,{...o,ref:h,layout:!0,layoutDependency:a,style:{lineHeight:1,...y,display:"inline-flex",isolation:"isolate",whiteSpace:"nowrap"},children:S.jsxs(R.div,{layout:!0,layoutDependency:a,"aria-label":c,style:{display:"inline-flex",direction:"ltr",isolation:"isolate",position:"relative",zIndex:-1},children:[S.jsx(z,{style:{padding:`calc(${j}/2) 0`},layoutDependency:a,"aria-hidden":!0,justify:"right",mode:"popLayout",parts:p,name:"pre"}),S.jsxs(xt,{layoutDependency:a,children:[S.jsx(z,{layoutDependency:a,justify:"right",parts:m,name:"integer"}),S.jsx(z,{layout:"position",layoutDependency:a,parts:x,name:"fraction"})]}),S.jsx(z,{style:{padding:`calc(${j}/2) 0`},"aria-hidden":!0,layout:"position",layoutDependency:a,mode:"popLayout",parts:d,name:"post"})]})})})})});R.create(l.Fragment);function xe(t,e){return t.length>e.length||t.length>0&&!e.startsWith(t)}function Se(t,e,n){return t+(e-t)*n}function wt(t,e,n,i,r){if(xe(e,t))return n*r;if(i==="natural")return Et(t,e,n);if(typeof i=="number"&&i>0){const y=n*(i/100);return n+Se(-y,y,Math.random())}return n}function Et(t,e,n){const i=e.length,r=t[i],y=t[i-1];if(!r)return n;const g=t.slice(0,i).lastIndexOf(" "),o=i-g-1,h=g+1,p=t.slice(i).indexOf(" "),x=(p===-1?t.length:i+p)-h;let d=1;if(y&&/[.!?]/.test(y)&&r===" "&&(d*=3),x<=3?d*=.7:(o===0&&r!==" "&&(d*=1.5),o===x-1&&(d*=1.4)),o>0&&o3){const a=Math.min(o/x,.4);d*=1-a}It.has(r)&&(d*=1.5),jt.has(r)&&(d*=1.5),/\d/.test(r)&&(d*=1.3),x>8&&(d*=1.3),r!==r.toLowerCase()&&(d*=1.25);const c=200;if(i>c){const a=Math.min((i-c)/1e3,.3);d*=1+a}const f=Se(-.25,.25,Math.random());d*=1+f;const s=n*d;return Math.max(n*.2,s)}const It=new Set([".",",","!","?",":",";","'",'"',"-","(",")"]),jt=new Set(["!","@","#","$","%","^","&","*","(",")","_","+","{","}","|",":",'"',"<",">","?"]);function Mt(t,e){let n=e-1;for(;n>=0&&/\s/.test(t[n]);)n--;for(;n>=0&&!/\s/.test(t[n]);)n--;return Math.max(0,n+1)}function Dt(t,e){const n=Math.min(t.length,e.length);let i=0;for(let r=0;r{var E;(E=I.current)==null||E.call(I),I.current=null},C=()=>{M.current=me(D.current,{opacity:[1,1,0,0]},{duration:g,times:[0,.5,.5,1],ease:"linear",repeat:1/0,repeatType:"reverse"})};return l.useEffect(()=>{x==="all"&&e!==w.current&&A.set(""),w.current=e},[e,x]),l.useEffect(()=>{var N;if(!h){C(),v();return}(N=M.current)==null||N.cancel();const E=()=>{const X=Rt(A.get(),e,x,d);A.set(X),X!==e?W():(C(),o==null||o())},W=()=>{I.current=_e(E,wt(e,A.get(),$,r,c))};return I.current||W(),v},[h,o,e,$,r,c,d]),S.jsxs(a,{ref:s,...f,"aria-label":b||e,children:[S.jsx(R.span,{className:p,style:m,children:A}),S.jsx(R.span,{ref:D,className:y,style:{display:"inline-block",width:"2px",height:"1em",backgroundColor:"currentColor",position:"relative",top:"0.1em",left:"0.2em",...u}})]})});export{Vt as A}; +import{fv as ve,fw as Ae,fx as we,fy as Ee,r as l,fz as B,bi as oe,j as S,fA as Ie,fB as je,fC as Me,fD as De,fE as le,fF as Re,fG as ke,fH as $e,fI as Ce,fJ as Ve,fK as Ne,fL as Te,fM as We,fN as Le,fO as Pe,fP as _,fQ as Oe,fR as Be,fS as Fe,m as R,fT as Ge,fU as ue,A as ce,bt as Ke,fV as ze,fW as _e}from"./index-DhkG1Nx9.js";const He=(t,e,n)=>{const i=e-t;return((n-t)%i+i)%i+t};function fe(t,e){return ve(t)?t[He(0,t.length,e)]:t}class Je{constructor(e){this.stop=()=>this.runAll("stop"),this.animations=e.filter(Boolean)}get finished(){return Promise.all(this.animations.map(e=>e.finished))}getAll(e){return this.animations[0][e]}setAll(e,n){for(let i=0;ii.attachTimeline(e));return()=>{n.forEach((i,r)=>{i&&i(),this.animations[r].stop()})}}get time(){return this.getAll("time")}set time(e){this.setAll("time",e)}get speed(){return this.getAll("speed")}set speed(e){this.setAll("speed",e)}get state(){return this.getAll("state")}get startTime(){return this.getAll("startTime")}get duration(){return ne(this.animations,"duration")}get iterationDuration(){return ne(this.animations,"iterationDuration")}runAll(e){this.animations.forEach(n=>n[e]())}play(){this.runAll("play")}pause(){this.runAll("pause")}cancel(){this.runAll("cancel")}complete(){this.runAll("complete")}}function ne(t,e){let n=0;for(let i=0;in&&(n=r)}return n}class Ue extends Je{then(e,n){return this.finished.finally(e).then(()=>{})}}function Xe(t,e){return t in e}class Ye extends Ae{constructor(){super(...arguments),this.type="object"}readValueFromInstance(e,n){if(Xe(n,e)){const i=e[n];if(typeof i=="string"||typeof i=="number")return i}}getBaseTargetFromProps(){}removeValueFromRenderState(e,n){delete n.output[e]}measureInstanceViewportBox(){return we()}build(e,n){Object.assign(e.output,n)}renderInstance(e,{output:n}){Object.assign(e,n)}sortInstanceNodePosition(){return 0}}function Qe({children:t,isValidProp:e,...n}){e&&Ee(e),n={...l.useContext(B),...n},n.isStatic=oe(()=>n.isStatic);const i=l.useMemo(()=>n,[JSON.stringify(n.transition),n.transformPagePoint,n.reducedMotion]);return S.jsx(B.Provider,{value:i,children:t})}function qe(t){const e=oe(()=>Ie(t)),{isStatic:n}=l.useContext(B);if(n){const[,i]=l.useState(t);l.useEffect(()=>e.on("change",i),[])}return e}function X(t){return typeof t=="object"&&!Array.isArray(t)}function de(t,e,n,i){return t==null?[]:typeof t=="string"&&X(e)?je(t,n,i):t instanceof NodeList?Array.from(t):Array.isArray(t)?t.filter(r=>r!=null):[t]}function Ze(t,e,n){return t*(e+1)}function ie(t,e,n,i){return typeof e=="number"?e:e.startsWith("-")||e.startsWith("+")?Math.max(0,t+parseFloat(e)):e==="<"?n:e.startsWith("<")?Math.max(0,n+parseFloat(e.slice(1))):i.get(e)??t}function et(t,e,n){for(let i=0;ie&&r.at{const v=at(A),{delay:C=0,times:E=Re(v),type:W=e.type||"keyframes",repeat:N,repeatType:J,repeatDelay:$t=0,...be}=I;let{ease:V=e.ease||"easeOut",duration:k}=I;const Y=typeof C=="function"?C(D,$):C,Q=v.length,q=Ce(W)?W:r==null?void 0:r[W||"keyframes"];if(Q<=2&&q){let L=100;if(Q===2&&ut(v)){const P=v[1]-v[0];L=Math.abs(P)}const F={...e,...be};k!==void 0&&(F.duration=Ve(k));const G=ke(F,L,q);V=G.ease,k=G.duration}k??(k=y);const Z=p+Y;E.length===1&&E[0]===0&&(E[1]=1);const ee=E.length-v.length;if(ee>0&&$e(E,ee),v.length===1&&v.unshift(null),N){k=Ze(k,N);const L=[...v],F=[...E];V=Array.isArray(V)?[...V]:[V];const G=[...V];for(let P=0;P{for(const c in x){const f=x[c];f.sort(it);const s=[],a=[],w=[];for(let D=0;Dtypeof t=="number",ut=t=>t.every(lt);function ct(t){const e={presenceContext:null,props:{},visualState:{renderState:{transform:{},transformOrigin:{},style:{},vars:{},attrs:{}},latestValues:{}}},n=Te(t)&&!We(t)?new Le(e):new Pe(e);n.mount(t),_.set(t,n)}function ft(t){const e={presenceContext:null,props:{},visualState:{renderState:{output:{}},latestValues:{}}},n=new Ye(e);n.mount(t),_.set(t,n)}function dt(t,e){return le(t)||typeof t=="number"||typeof t=="string"&&!X(e)}function pe(t,e,n,i){const r=[];if(dt(t,e))r.push(Oe(t,X(e)&&e.default||e,n&&(n.default||n)));else{if(t==null)return r;const y=de(t,e,i),u=y.length;for(let g=0;g{i.push(...pe(g,y,u))}),i}function mt(t){return Array.isArray(t)&&t.some(Array.isArray)}function yt(t){function e(n,i,r){let y=[],u;if(mt(n))y=pt(n,i,t);else{const{onComplete:o,...h}=r||{};typeof o=="function"&&(u=o),y=pe(n,i,h,t)}const g=new Ue(y);return u&&g.finished.then(u),g}return e}const me=yt(),j="var(--mask-height, 0.15em)",U="var(--mask-width, 0.5em)",T=`calc(${U} / var(--invert-x, 1))`,K="#000 0, transparent 71%",ht=`linear-gradient(to right, transparent 0, #000 ${T}, #000 calc(100% - ${T}), transparent),linear-gradient(to bottom, transparent 0, #000 ${j}, #000 calc(100% - ${j}), transparent 100%),radial-gradient(at bottom right, ${K}),radial-gradient(at bottom left, ${K}), radial-gradient(at top left, ${K}), radial-gradient(at top right, ${K})`,gt=`100% calc(100% - ${j} * 2),calc(100% - ${T} * 2) 100%,${T} ${j},${T} ${j},${T} ${j},${T} ${j}`;Ge({"--invert-x":{correct:(t,{treeScale:e,projectionDelta:n})=>n.x.scale*e.x}});function xt({children:t,layoutDependency:e}){return S.jsx(R.span,{layout:!0,layoutDependency:e,"aria-hidden":!0,style:{display:"inline-flex","--invert-x":1,margin:`0 calc(-1*${U})`,padding:`calc(${j}/2) ${U}`,position:"relative",zIndex:-1,overflow:"clip",WebkitMaskImage:ht,WebkitMaskSize:gt,WebkitMaskPosition:"center, center, top left, top right, bottom right, bottom left",WebkitMaskRepeat:"no-repeat"},children:t})}function ye(){const t=l.useRef(!0);return l.useEffect(()=>{t.current=!1},[]),t.current}function H(t){const{width:e,fontSize:n}=getComputedStyle(t);return`${parseFloat(e)/parseFloat(n)}em`}const he=new WeakMap,St=l.forwardRef(function({value:e,initialValue:n=e,...i},r){const{transition:y}=l.useContext(B),u=l.useRef(n).current,g=ye(),o=l.useRef(null),h=l.useRef(null);l.useImperativeHandle(r,()=>h.current,[]);const b=l.useRef(new Array(10)),p=ue(),m=p?e:0;l.useLayoutEffect(()=>{!o.current||!b.current[u]||(o.current.style.width=H(b.current[u]))},[]);const x=l.useRef(n);l.useLayoutEffect(()=>{var A;if(!o.current||m===x.current)return;const s=o.current.getBoundingClientRect(),a=(A=h.current)==null?void 0:A.getBoundingClientRect(),w=s.height*(m-x.current)+(s.top-(a?a.top||0:s.top));return me(o.current,{y:[w,0]},y),()=>{x.current=m}},[m]);const[d,c]=l.useState();l.useEffect(()=>{if(g&&u===m||!b.current[m])return;const s=H(b.current[m]);h.current&&he.set(h.current,s),c(s)},[m]);const f=s=>S.jsx("span",{style:{display:"inline-block",padding:`calc(${j}/2) 0`},ref:a=>void(b.current[s]=a),children:s},s);return S.jsx(R.span,{...i,ref:h,layout:"position","data-state":p?void 0:"exiting",style:{display:"inline-flex",justifyContent:"center",width:d},children:S.jsxs("span",{ref:o,style:{display:"inline-flex",justifyContent:"center",flexDirection:"column",alignItems:"center",position:"relative"},children:[m!==0&&S.jsx("span",{style:{...ae,bottom:"100%",left:0},children:new Array(m).fill(null).map((s,a)=>f(a))}),f(m),m!==9&&S.jsx("span",{style:{...ae,top:"100%",left:0},children:new Array(9-m).fill(null).map((s,a)=>f(m+a+1))})]})})}),ae={display:"flex",flexDirection:"column",alignItems:"center",position:"absolute",width:"100%"},ge=l.createContext({justify:"left"}),bt=l.forwardRef(function({partKey:e,type:n,children:i,layoutDependency:r,...y},u){const g=ue(),{justify:o}=l.useContext(ge);return S.jsx(R.span,{...y,"data-state":g?void 0:"exiting",style:{display:"inline-flex",justifyContent:o,padding:`calc(${j}/2) 0`,position:"relative"},layout:"position",layoutDependency:r,ref:u,children:S.jsx(ce,{mode:"popLayout",anchorX:o,initial:!1,children:S.jsx(R.span,{layout:o==="right"?"position":!1,layoutDependency:r,initial:{opacity:0},animate:{opacity:[null,1]},exit:{opacity:[null,0]},style:{display:"inline-block",whiteSpace:"pre"},children:i},i)})})}),z=l.forwardRef(function({parts:e,justify:n="left",mode:i,style:r,name:y,layoutDependency:u,...g},o){const h=l.useRef(null);l.useImperativeHandle(o,()=>h.current,[]);const b=l.useMemo(()=>({justify:n}),[n]),p=l.useRef(null),m=ye(),[x,d]=l.useState();return l.useEffect(()=>{if(!p.current)return;if(m){h.current&&(h.current.style.width=H(p.current));return}const c=Array.from(p.current.children).map(f=>{if(!(f instanceof HTMLElement))return;if(f.dataset.state==="exiting"){const w=f.nextSibling;return f.remove(),()=>{p.current&&p.current.insertBefore(f,w)}}const s=he.get(f);if(!s)return;const a=f.style.width;return f.style.width=s,()=>{f.style.width=a}});d(H(p.current));for(let f=c.length-1;f>=0;f--){const s=c[f];s&&s()}},[e.map(c=>c.value).join("")]),S.jsx(ge.Provider,{value:b,children:S.jsx(R.span,{layoutDependency:u,...g,ref:h,className:`number-section-${y}`,style:{...r,display:"inline-flex",justifyContent:n,width:x},children:S.jsxs("span",{ref:p,style:{display:"inline-flex",justifyContent:"inherit",position:"relative"},children:["​",S.jsx(ce,{mode:i,anchorX:n,initial:!1,children:e.map(c=>c.type==="integer"||c.type==="fraction"?S.jsx(St,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},value:c.value,initialValue:m?void 0:0,layoutDependency:u},c.key):S.jsx(bt,{type:c.type,partKey:c.key,initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},layoutDependency:u,children:c.value},c.type==="literal"?`${c.key}:${c.value}`:c.key))})]})})})}),vt=(t,{locales:e,format:n},i,r)=>{const u=new Intl.NumberFormat(e,n).formatToParts(Number(t));i&&u.unshift({type:"prefix",value:i}),r&&u.push({type:"suffix",value:r});const g=[],o=[],h=[],b=[],p={},m=s=>`${s}:${p[s]=(p[s]??-1)+1}`;let x="",d=!1,c=!1;for(const s of u){x+=s.value;const a=s.type==="minusSign"||s.type==="plusSign"?"sign":s.type;switch(a){case"integer":d=!0,o.push(...s.value.split("").map(w=>({type:a,value:parseInt(w)})));break;case"group":o.push({type:a,value:s.value});break;case"decimal":c=!0,h.push({type:a,value:s.value,key:m(a)});break;case"fraction":h.push(...s.value.split("").map(w=>({type:a,value:parseInt(w),key:m(a)})));break;default:(d||c?b:g).push({type:a,value:s.value,key:m(a)})}}const f=[];for(let s=o.length-1;s>=0;s--)f.unshift({...o[s],key:m(o[s].type)});return{pre:g,integer:f,fraction:h,post:b,formatted:x}},At={opacity:{duration:1,ease:ze},layout:{type:"spring",duration:1,bounce:0},y:{type:"spring",duration:1,bounce:0}},Vt=l.forwardRef(function({children:e,locales:n,format:i,transition:r,style:y,suffix:u,prefix:g,...o},h){const b=l.useMemo(()=>vt(e,{locales:n,format:i},g,u),[e,n,i]),{pre:p,integer:m,fraction:x,post:d,formatted:c}=b,f=l.useContext(B).transition;r=r??f??At;const{layoutDependency:s}=o,a=l.useMemo(()=>{if(s!==void 0)return{layoutDependency:s,value:e}},[s,e]);return S.jsx(Ke,{children:S.jsx(Qe,{transition:r,children:S.jsx(R.div,{...o,ref:h,layout:!0,layoutDependency:a,style:{lineHeight:1,...y,display:"inline-flex",isolation:"isolate",whiteSpace:"nowrap"},children:S.jsxs(R.div,{layout:!0,layoutDependency:a,"aria-label":c,style:{display:"inline-flex",direction:"ltr",isolation:"isolate",position:"relative",zIndex:-1},children:[S.jsx(z,{style:{padding:`calc(${j}/2) 0`},layoutDependency:a,"aria-hidden":!0,justify:"right",mode:"popLayout",parts:p,name:"pre"}),S.jsxs(xt,{layoutDependency:a,children:[S.jsx(z,{layoutDependency:a,justify:"right",parts:m,name:"integer"}),S.jsx(z,{layout:"position",layoutDependency:a,parts:x,name:"fraction"})]}),S.jsx(z,{style:{padding:`calc(${j}/2) 0`},"aria-hidden":!0,layout:"position",layoutDependency:a,mode:"popLayout",parts:d,name:"post"})]})})})})});R.create(l.Fragment);function xe(t,e){return t.length>e.length||t.length>0&&!e.startsWith(t)}function Se(t,e,n){return t+(e-t)*n}function wt(t,e,n,i,r){if(xe(e,t))return n*r;if(i==="natural")return Et(t,e,n);if(typeof i=="number"&&i>0){const y=n*(i/100);return n+Se(-y,y,Math.random())}return n}function Et(t,e,n){const i=e.length,r=t[i],y=t[i-1];if(!r)return n;const g=t.slice(0,i).lastIndexOf(" "),o=i-g-1,h=g+1,p=t.slice(i).indexOf(" "),x=(p===-1?t.length:i+p)-h;let d=1;if(y&&/[.!?]/.test(y)&&r===" "&&(d*=3),x<=3?d*=.7:(o===0&&r!==" "&&(d*=1.5),o===x-1&&(d*=1.4)),o>0&&o3){const a=Math.min(o/x,.4);d*=1-a}It.has(r)&&(d*=1.5),jt.has(r)&&(d*=1.5),/\d/.test(r)&&(d*=1.3),x>8&&(d*=1.3),r!==r.toLowerCase()&&(d*=1.25);const c=200;if(i>c){const a=Math.min((i-c)/1e3,.3);d*=1+a}const f=Se(-.25,.25,Math.random());d*=1+f;const s=n*d;return Math.max(n*.2,s)}const It=new Set([".",",","!","?",":",";","'",'"',"-","(",")"]),jt=new Set(["!","@","#","$","%","^","&","*","(",")","_","+","{","}","|",":",'"',"<",">","?"]);function Mt(t,e){let n=e-1;for(;n>=0&&/\s/.test(t[n]);)n--;for(;n>=0&&!/\s/.test(t[n]);)n--;return Math.max(0,n+1)}function Dt(t,e){const n=Math.min(t.length,e.length);let i=0;for(let r=0;r{var E;(E=I.current)==null||E.call(I),I.current=null},C=()=>{M.current=me(D.current,{opacity:[1,1,0,0]},{duration:g,times:[0,.5,.5,1],ease:"linear",repeat:1/0,repeatType:"reverse"})};return l.useEffect(()=>{x==="all"&&e!==w.current&&A.set(""),w.current=e},[e,x]),l.useEffect(()=>{var N;if(!h){C(),v();return}(N=M.current)==null||N.cancel();const E=()=>{const J=Rt(A.get(),e,x,d);A.set(J),J!==e?W():(C(),o==null||o())},W=()=>{I.current=_e(E,wt(e,A.get(),$,r,c))};return I.current||W(),v},[h,o,e,$,r,c,d]),S.jsxs(a,{ref:s,...f,"aria-label":b||e,children:[S.jsx(R.span,{className:p,style:m,children:A}),S.jsx(R.span,{ref:D,className:y,style:{display:"inline-block",width:"2px",height:"1em",backgroundColor:"currentColor",position:"relative",top:"0.1em",left:"0.2em",...u}})]})});export{Vt as A}; diff --git a/frontend/dist/assets/index-C1ZF7cAz.js b/frontend/dist/assets/index-C1ZF7cAz.js deleted file mode 100644 index a847f08b..00000000 --- a/frontend/dist/assets/index-C1ZF7cAz.js +++ /dev/null @@ -1,271 +0,0 @@ -const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/Login-D-EHt21j.js","assets/ascii-burst-DN6etEs5.js","assets/Dashboard-C6Gfwl6I.js","assets/PageLayout-sd81yog0.js","assets/consumer-registry-CFnLzQEu.js","assets/AnimatedNumber-DdMz2uoH.js","assets/index-DCNWD5GU.js","assets/node-types-BJeLdOcD.js","assets/meshcore-tx-constants-DgpFTAmf.js","assets/PacketList-BiFMK9DR.js","assets/primitives-DyUGjsV_.js","assets/payload-decoders-CmuRVuC0.js","assets/badge-colors-BNUqIXCA.js","assets/chat-utils-BzC-Ehs-.js","assets/SignalIndicator-BDLlaquA.js","assets/arrow-up-DhGrEgP7.js","assets/chevron-right-DzbDJf-i.js","assets/map-pin-DEktgLFN.js","assets/circle-question-mark-CxqvWhsl.js","assets/triangle-alert-B3ZB2VPZ.js","assets/DataBox-BADtaCfB.js","assets/layers-BNenbfjd.js","assets/hash-2pKM_KWy.js","assets/activity-Bmh45lNn.js","assets/circle-check-DY6oislV.js","assets/database-CdKnhwkJ.js","assets/useMapViewStore-px_sYTaN.js","assets/shield-BNyjVgrV.js","assets/TimeRangeStepper-CxA2aT1o.js","assets/usePipelineStore-BEu0jDzA.js","assets/LightSparkline-7x8sYJi9.js","assets/link-scoring-BoRGGDM6.js","assets/NodeInformationCard-BUD0ZP9t.js","assets/ChatBubble-jJytaTX9.js","assets/Grid-DrJ5vfLo.js","assets/Packets-QitEk45M.js","assets/element-movement-CuySBNA6.js","assets/AnalyzerFilterPanel-D0gvrDVF.js","assets/funnel-zG3cM6J7.js","assets/monitor-smartphone-BQ_i3P0U.js","assets/search-CtlrlrHK.js","assets/Contacts-BwzeErAl.js","assets/ping-C4M-6OVJ.js","assets/listbox-vfp6JG3P.js","assets/CollisionExplorerModal-Bm7X5dgz.js","assets/BasemapLayer-CfNM-FKA.js","assets/target-D0wbrQMn.js","assets/network-4dDTHizq.js","assets/ConfirmModal-Cf30hpC_.js","assets/BasemapLayer-B1CfjdFi.css","assets/Statistics-Dzfzapmt.js","assets/easing-BGz60jqS.js","assets/settings-2-fZXt90fn.js","assets/MeshGraph-BrJ2t6jK.js","assets/DeepAnalysisModal-X0cTTPp0.js","assets/download-DbDw1ZiV.js","assets/System-BjnR6rPq.js","assets/refresh-cw-BjBvU2VX.js","assets/Logs-DCoWCYrQ.js","assets/Terminal-CkzES_px.js","assets/system-DraTG8R2.js","assets/KeycapButton-DkbJ4iVA.js","assets/keycap-sfx-ByZp-njj.js","assets/Terminal-6GBZ9nXN.css","assets/Configuration-qL2GXo5a.js","assets/antenna-Bvc4sU0O.js","assets/plus-BvRrZnfw.js","assets/key-round-Chd2xrtI.js","assets/RoomServer-C_iTtq7Y.js","assets/wifi-BBDEuc94.js","assets/PacketObservatory-DaStIp3L.js","assets/Sessions-CZB52dVP.js"])))=>i.map(i=>d[i]); -var G6=Object.defineProperty;var K6=(e,t,n)=>t in e?G6(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Be=(e,t,n)=>K6(e,typeof t!="symbol"?t+"":t,n);function Y6(e,t){for(var n=0;nr[s]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))r(s);new MutationObserver(s=>{for(const i of s)if(i.type==="childList")for(const l of i.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&r(l)}).observe(document,{childList:!0,subtree:!0});function n(s){const i={};return s.integrity&&(i.integrity=s.integrity),s.referrerPolicy&&(i.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?i.credentials="include":s.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function r(s){if(s.ep)return;s.ep=!0;const i=n(s);fetch(s.href,i)}})();function X6(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var cm={exports:{}},wc={},um={exports:{}},Xe={};/** - * @license React - * react.production.min.js - * - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */var db;function Q6(){if(db)return Xe;db=1;var e=Symbol.for("react.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),i=Symbol.for("react.provider"),l=Symbol.for("react.context"),c=Symbol.for("react.forward_ref"),d=Symbol.for("react.suspense"),f=Symbol.for("react.memo"),h=Symbol.for("react.lazy"),m=Symbol.iterator;function g(N){return N===null||typeof N!="object"?null:(N=m&&N[m]||N["@@iterator"],typeof N=="function"?N:null)}var b={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},C=Object.assign,w={};function x(N,Y,$){this.props=N,this.context=Y,this.refs=w,this.updater=$||b}x.prototype.isReactComponent={},x.prototype.setState=function(N,Y){if(typeof N!="object"&&typeof N!="function"&&N!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,N,Y,"setState")},x.prototype.forceUpdate=function(N){this.updater.enqueueForceUpdate(this,N,"forceUpdate")};function D(){}D.prototype=x.prototype;function S(N,Y,$){this.props=N,this.context=Y,this.refs=w,this.updater=$||b}var F=S.prototype=new D;F.constructor=S,C(F,x.prototype),F.isPureReactComponent=!0;var P=Array.isArray,M=Object.prototype.hasOwnProperty,L={current:null},O={key:!0,ref:!0,__self:!0,__source:!0};function _(N,Y,$){var ae,he={},me=null,ie=null;if(Y!=null)for(ae in Y.ref!==void 0&&(ie=Y.ref),Y.key!==void 0&&(me=""+Y.key),Y)M.call(Y,ae)&&!O.hasOwnProperty(ae)&&(he[ae]=Y[ae]);var we=arguments.length-2;if(we===1)he.children=$;else if(1>>1,Y=re[N];if(0>>1;N<$;){var ae=2*(N+1)-1,he=re[ae],me=ae+1,ie=re[me];if(0>s(he,te))mes(ie,he)?(re[N]=ie,re[me]=te,N=me):(re[N]=he,re[ae]=te,N=ae);else if(mes(ie,te))re[N]=ie,re[me]=te,N=me;else break e}}return le}function s(re,le){var te=re.sortIndex-le.sortIndex;return te!==0?te:re.id-le.id}if(typeof performance=="object"&&typeof performance.now=="function"){var i=performance;e.unstable_now=function(){return i.now()}}else{var l=Date,c=l.now();e.unstable_now=function(){return l.now()-c}}var d=[],f=[],h=1,m=null,g=3,b=!1,C=!1,w=!1,x=typeof setTimeout=="function"?setTimeout:null,D=typeof clearTimeout=="function"?clearTimeout:null,S=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function F(re){for(var le=n(f);le!==null;){if(le.callback===null)r(f);else if(le.startTime<=re)r(f),le.sortIndex=le.expirationTime,t(d,le);else break;le=n(f)}}function P(re){if(w=!1,F(re),!C)if(n(d)!==null)C=!0,fe(M);else{var le=n(f);le!==null&&ne(P,le.startTime-re)}}function M(re,le){C=!1,w&&(w=!1,D(_),_=-1),b=!0;var te=g;try{for(F(le),m=n(d);m!==null&&(!(m.expirationTime>le)||re&&!U());){var N=m.callback;if(typeof N=="function"){m.callback=null,g=m.priorityLevel;var Y=N(m.expirationTime<=le);le=e.unstable_now(),typeof Y=="function"?m.callback=Y:m===n(d)&&r(d),F(le)}else r(d);m=n(d)}if(m!==null)var $=!0;else{var ae=n(f);ae!==null&&ne(P,ae.startTime-le),$=!1}return $}finally{m=null,g=te,b=!1}}var L=!1,O=null,_=-1,j=5,H=-1;function U(){return!(e.unstable_now()-Hre||125N?(re.sortIndex=te,t(f,re),n(d)===null&&re===n(f)&&(w?(D(_),_=-1):w=!0,ne(P,te-N))):(re.sortIndex=Y,t(d,re),C||b||(C=!0,fe(M))),re},e.unstable_shouldYield=U,e.unstable_wrapCallback=function(re){var le=g;return function(){var te=g;g=le;try{return re.apply(this,arguments)}finally{g=te}}}})(hm)),hm}var yb;function t4(){return yb||(yb=1,fm.exports=e4()),fm.exports}/** - * @license React - * react-dom.production.min.js - * - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */var vb;function n4(){if(vb)return Ar;vb=1;var e=ch(),t=t4();function n(o){for(var a="https://reactjs.org/docs/error-decoder.html?invariant="+o,u=1;u"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),d=Object.prototype.hasOwnProperty,f=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,h={},m={};function g(o){return d.call(m,o)?!0:d.call(h,o)?!1:f.test(o)?m[o]=!0:(h[o]=!0,!1)}function b(o,a,u,p){if(u!==null&&u.type===0)return!1;switch(typeof a){case"function":case"symbol":return!0;case"boolean":return p?!1:u!==null?!u.acceptsBooleans:(o=o.toLowerCase().slice(0,5),o!=="data-"&&o!=="aria-");default:return!1}}function C(o,a,u,p){if(a===null||typeof a>"u"||b(o,a,u,p))return!0;if(p)return!1;if(u!==null)switch(u.type){case 3:return!a;case 4:return a===!1;case 5:return isNaN(a);case 6:return isNaN(a)||1>a}return!1}function w(o,a,u,p,y,E,B){this.acceptsBooleans=a===2||a===3||a===4,this.attributeName=p,this.attributeNamespace=y,this.mustUseProperty=u,this.propertyName=o,this.type=a,this.sanitizeURL=E,this.removeEmptyString=B}var x={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(o){x[o]=new w(o,0,!1,o,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(o){var a=o[0];x[a]=new w(a,1,!1,o[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(o){x[o]=new w(o,2,!1,o.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(o){x[o]=new w(o,2,!1,o,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(o){x[o]=new w(o,3,!1,o.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(o){x[o]=new w(o,3,!0,o,null,!1,!1)}),["capture","download"].forEach(function(o){x[o]=new w(o,4,!1,o,null,!1,!1)}),["cols","rows","size","span"].forEach(function(o){x[o]=new w(o,6,!1,o,null,!1,!1)}),["rowSpan","start"].forEach(function(o){x[o]=new w(o,5,!1,o.toLowerCase(),null,!1,!1)});var D=/[\-:]([a-z])/g;function S(o){return o[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(o){var a=o.replace(D,S);x[a]=new w(a,1,!1,o,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(o){var a=o.replace(D,S);x[a]=new w(a,1,!1,o,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(o){var a=o.replace(D,S);x[a]=new w(a,1,!1,o,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(o){x[o]=new w(o,1,!1,o.toLowerCase(),null,!1,!1)}),x.xlinkHref=new w("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(o){x[o]=new w(o,1,!1,o.toLowerCase(),null,!0,!0)});function F(o,a,u,p){var y=x.hasOwnProperty(a)?x[a]:null;(y!==null?y.type!==0:p||!(2z||y[B]!==E[z]){var W=` -`+y[B].replace(" at new "," at ");return o.displayName&&W.includes("")&&(W=W.replace("",o.displayName)),W}while(1<=B&&0<=z);break}}}finally{$=!1,Error.prepareStackTrace=u}return(o=o?o.displayName||o.name:"")?Y(o):""}function he(o){switch(o.tag){case 5:return Y(o.type);case 16:return Y("Lazy");case 13:return Y("Suspense");case 19:return Y("SuspenseList");case 0:case 2:case 15:return o=ae(o.type,!1),o;case 11:return o=ae(o.type.render,!1),o;case 1:return o=ae(o.type,!0),o;default:return""}}function me(o){if(o==null)return null;if(typeof o=="function")return o.displayName||o.name||null;if(typeof o=="string")return o;switch(o){case O:return"Fragment";case L:return"Portal";case j:return"Profiler";case _:return"StrictMode";case V:return"Suspense";case G:return"SuspenseList"}if(typeof o=="object")switch(o.$$typeof){case U:return(o.displayName||"Context")+".Consumer";case H:return(o._context.displayName||"Context")+".Provider";case X:var a=o.render;return o=o.displayName,o||(o=a.displayName||a.name||"",o=o!==""?"ForwardRef("+o+")":"ForwardRef"),o;case se:return a=o.displayName||null,a!==null?a:me(o.type)||"Memo";case fe:a=o._payload,o=o._init;try{return me(o(a))}catch{}}return null}function ie(o){var a=o.type;switch(o.tag){case 24:return"Cache";case 9:return(a.displayName||"Context")+".Consumer";case 10:return(a._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return o=a.render,o=o.displayName||o.name||"",a.displayName||(o!==""?"ForwardRef("+o+")":"ForwardRef");case 7:return"Fragment";case 5:return a;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return me(a);case 8:return a===_?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof a=="function")return a.displayName||a.name||null;if(typeof a=="string")return a}return null}function we(o){switch(typeof o){case"boolean":case"number":case"string":case"undefined":return o;case"object":return o;default:return""}}function Fe(o){var a=o.type;return(o=o.nodeName)&&o.toLowerCase()==="input"&&(a==="checkbox"||a==="radio")}function xe(o){var a=Fe(o)?"checked":"value",u=Object.getOwnPropertyDescriptor(o.constructor.prototype,a),p=""+o[a];if(!o.hasOwnProperty(a)&&typeof u<"u"&&typeof u.get=="function"&&typeof u.set=="function"){var y=u.get,E=u.set;return Object.defineProperty(o,a,{configurable:!0,get:function(){return y.call(this)},set:function(B){p=""+B,E.call(this,B)}}),Object.defineProperty(o,a,{enumerable:u.enumerable}),{getValue:function(){return p},setValue:function(B){p=""+B},stopTracking:function(){o._valueTracker=null,delete o[a]}}}}function Ke(o){o._valueTracker||(o._valueTracker=xe(o))}function xt(o){if(!o)return!1;var a=o._valueTracker;if(!a)return!0;var u=a.getValue(),p="";return o&&(p=Fe(o)?o.checked?"true":"false":o.value),o=p,o!==u?(a.setValue(o),!0):!1}function et(o){if(o=o||(typeof document<"u"?document:void 0),typeof o>"u")return null;try{return o.activeElement||o.body}catch{return o.body}}function pt(o,a){var u=a.checked;return te({},a,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:u??o._wrapperState.initialChecked})}function Ct(o,a){var u=a.defaultValue==null?"":a.defaultValue,p=a.checked!=null?a.checked:a.defaultChecked;u=we(a.value!=null?a.value:u),o._wrapperState={initialChecked:p,initialValue:u,controlled:a.type==="checkbox"||a.type==="radio"?a.checked!=null:a.value!=null}}function Ie(o,a){a=a.checked,a!=null&&F(o,"checked",a,!1)}function tt(o,a){Ie(o,a);var u=we(a.value),p=a.type;if(u!=null)p==="number"?(u===0&&o.value===""||o.value!=u)&&(o.value=""+u):o.value!==""+u&&(o.value=""+u);else if(p==="submit"||p==="reset"){o.removeAttribute("value");return}a.hasOwnProperty("value")?$t(o,a.type,u):a.hasOwnProperty("defaultValue")&&$t(o,a.type,we(a.defaultValue)),a.checked==null&&a.defaultChecked!=null&&(o.defaultChecked=!!a.defaultChecked)}function gn(o,a,u){if(a.hasOwnProperty("value")||a.hasOwnProperty("defaultValue")){var p=a.type;if(!(p!=="submit"&&p!=="reset"||a.value!==void 0&&a.value!==null))return;a=""+o._wrapperState.initialValue,u||a===o.value||(o.value=a),o.defaultValue=a}u=o.name,u!==""&&(o.name=""),o.defaultChecked=!!o._wrapperState.initialChecked,u!==""&&(o.name=u)}function $t(o,a,u){(a!=="number"||et(o.ownerDocument)!==o)&&(u==null?o.defaultValue=""+o._wrapperState.initialValue:o.defaultValue!==""+u&&(o.defaultValue=""+u))}var nt=Array.isArray;function en(o,a,u,p){if(o=o.options,a){a={};for(var y=0;y"+a.valueOf().toString()+"",a=nn.firstChild;o.firstChild;)o.removeChild(o.firstChild);for(;a.firstChild;)o.appendChild(a.firstChild)}});function it(o,a){if(a){var u=o.firstChild;if(u&&u===o.lastChild&&u.nodeType===3){u.nodeValue=a;return}}o.textContent=a}var rn={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},Gt=["Webkit","ms","Moz","O"];Object.keys(rn).forEach(function(o){Gt.forEach(function(a){a=a+o.charAt(0).toUpperCase()+o.substring(1),rn[a]=rn[o]})});function Sn(o,a,u){return a==null||typeof a=="boolean"||a===""?"":u||typeof a!="number"||a===0||rn.hasOwnProperty(o)&&rn[o]?(""+a).trim():a+"px"}function Ln(o,a){o=o.style;for(var u in a)if(a.hasOwnProperty(u)){var p=u.indexOf("--")===0,y=Sn(u,a[u],p);u==="float"&&(u="cssFloat"),p?o.setProperty(u,y):o[u]=y}}var Br=te({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function Ca(o,a){if(a){if(Br[o]&&(a.children!=null||a.dangerouslySetInnerHTML!=null))throw Error(n(137,o));if(a.dangerouslySetInnerHTML!=null){if(a.children!=null)throw Error(n(60));if(typeof a.dangerouslySetInnerHTML!="object"||!("__html"in a.dangerouslySetInnerHTML))throw Error(n(61))}if(a.style!=null&&typeof a.style!="object")throw Error(n(62))}}function Ss(o,a){if(o.indexOf("-")===-1)return typeof a.is=="string";switch(o){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Po=null;function fo(o){return o=o.target||o.srcElement||window,o.correspondingUseElement&&(o=o.correspondingUseElement),o.nodeType===3?o.parentNode:o}var Fs=null,vn=null,Mo=null;function Ol(o){if(o=sc(o)){if(typeof Fs!="function")throw Error(n(280));var a=o.stateNode;a&&(a=sd(a),Fs(o.stateNode,o.type,a))}}function Fu(o){vn?Mo?Mo.push(o):Mo=[o]:vn=o}function Bu(){if(vn){var o=vn,a=Mo;if(Mo=vn=null,Ol(o),a)for(o=0;o>>=0,o===0?32:31-(Hl(o)/In|0)|0}var xa=64,Ms=4194304;function Ls(o){switch(o&-o){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return o&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return o&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return o}}function wi(o,a){var u=o.pendingLanes;if(u===0)return 0;var p=0,y=o.suspendedLanes,E=o.pingedLanes,B=u&268435455;if(B!==0){var z=B&~y;z!==0?p=Ls(z):(E&=B,E!==0&&(p=Ls(E)))}else B=u&~y,B!==0?p=Ls(B):E!==0&&(p=Ls(E));if(p===0)return 0;if(a!==0&&a!==p&&(a&y)===0&&(y=p&-p,E=a&-a,y>=E||y===16&&(E&4194240)!==0))return a;if((p&4)!==0&&(p|=u&16),a=o.entangledLanes,a!==0)for(o=o.entanglements,a&=p;0u;u++)a.push(o);return a}function _s(o,a,u){o.pendingLanes|=a,a!==536870912&&(o.suspendedLanes=0,o.pingedLanes=0),o=o.eventTimes,a=31-Yn(a),o[a]=u}function ql(o,a){var u=o.pendingLanes&~a;o.pendingLanes=a,o.suspendedLanes=0,o.pingedLanes=0,o.expiredLanes&=a,o.mutableReadLanes&=a,o.entangledLanes&=a,a=o.entanglements;var p=o.eventTimes;for(o=o.expirationTimes;0=as),Ju=" ",Ti=!1;function A(o,a){switch(o){case"keyup":return Xt.indexOf(a.keyCode)!==-1;case"keydown":return a.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function T(o){return o=o.detail,typeof o=="object"&&"data"in o?o.data:null}var R=!1;function I(o,a){switch(o){case"compositionend":return T(a);case"keypress":return a.which!==32?null:(Ti=!0,Ju);case"textInput":return o=a.data,o===Ju&&Ti?null:o;default:return null}}function q(o,a){if(R)return o==="compositionend"||!Bi&&A(o,a)?(o=Lr(),Mr=Xl=Pr=null,R=!1,o):null;switch(o){case"paste":return null;case"keypress":if(!(a.ctrlKey||a.altKey||a.metaKey)||a.ctrlKey&&a.altKey){if(a.char&&1=a)return{node:u,offset:a-o};o=p}e:{for(;u;){if(u.nextSibling){u=u.nextSibling;break e}u=u.parentNode}u=void 0}u=br(u)}}function $n(o,a){return o&&a?o===a?!0:o&&o.nodeType===3?!1:a&&a.nodeType===3?$n(o,a.parentNode):"contains"in o?o.contains(a):o.compareDocumentPosition?!!(o.compareDocumentPosition(a)&16):!1:!1}function Zn(){for(var o=window,a=et();a instanceof o.HTMLIFrameElement;){try{var u=typeof a.contentWindow.location.href=="string"}catch{u=!1}if(u)o=a.contentWindow;else break;a=et(o.document)}return a}function er(o){var a=o&&o.nodeName&&o.nodeName.toLowerCase();return a&&(a==="input"&&(o.type==="text"||o.type==="search"||o.type==="tel"||o.type==="url"||o.type==="password")||a==="textarea"||o.contentEditable==="true")}function Gr(o){var a=Zn(),u=o.focusedElem,p=o.selectionRange;if(a!==u&&u&&u.ownerDocument&&$n(u.ownerDocument.documentElement,u)){if(p!==null&&er(u)){if(a=p.start,o=p.end,o===void 0&&(o=a),"selectionStart"in u)u.selectionStart=a,u.selectionEnd=Math.min(o,u.value.length);else if(o=(a=u.ownerDocument||document)&&a.defaultView||window,o.getSelection){o=o.getSelection();var y=u.textContent.length,E=Math.min(p.start,y);p=p.end===void 0?E:Math.min(p.end,y),!o.extend&&E>p&&(y=p,p=E,E=y),y=Rr(u,E);var B=Rr(u,p);y&&B&&(o.rangeCount!==1||o.anchorNode!==y.node||o.anchorOffset!==y.offset||o.focusNode!==B.node||o.focusOffset!==B.offset)&&(a=a.createRange(),a.setStart(y.node,y.offset),o.removeAllRanges(),E>p?(o.addRange(a),o.extend(B.node,B.offset)):(a.setEnd(B.node,B.offset),o.addRange(a)))}}for(a=[],o=u;o=o.parentNode;)o.nodeType===1&&a.push({element:o,left:o.scrollLeft,top:o.scrollTop});for(typeof u.focus=="function"&&u.focus(),u=0;u=document.documentMode,fn=null,yo=null,an=null,Pi=!1;function v1(o,a,u){var p=u.window===u?u.document:u.nodeType===9?u:u.ownerDocument;Pi||fn==null||fn!==et(p)||(p=fn,"selectionStart"in p&&er(p)?p={start:p.selectionStart,end:p.selectionEnd}:(p=(p.ownerDocument&&p.ownerDocument.defaultView||window).getSelection(),p={anchorNode:p.anchorNode,anchorOffset:p.anchorOffset,focusNode:p.focusNode,focusOffset:p.focusOffset}),an&&Bn(an,p)||(an=p,p=nd(yo,"onSelect"),0Ni||(o.current=ap[Ni],ap[Ni]=null,Ni--)}function Bt(o,a){Ni++,ap[Ni]=o.current,o.current=a}var Ks={},zn=Gs(Ks),wr=Gs(!1),Ra=Ks;function ji(o,a){var u=o.type.contextTypes;if(!u)return Ks;var p=o.stateNode;if(p&&p.__reactInternalMemoizedUnmaskedChildContext===a)return p.__reactInternalMemoizedMaskedChildContext;var y={},E;for(E in u)y[E]=a[E];return p&&(o=o.stateNode,o.__reactInternalMemoizedUnmaskedChildContext=a,o.__reactInternalMemoizedMaskedChildContext=y),y}function Cr(o){return o=o.childContextTypes,o!=null}function ad(){Lt(wr),Lt(zn)}function L1(o,a,u){if(zn.current!==Ks)throw Error(n(168));Bt(zn,a),Bt(wr,u)}function _1(o,a,u){var p=o.stateNode;if(a=a.childContextTypes,typeof p.getChildContext!="function")return u;p=p.getChildContext();for(var y in p)if(!(y in a))throw Error(n(108,ie(o)||"Unknown",y));return te({},u,p)}function id(o){return o=(o=o.stateNode)&&o.__reactInternalMemoizedMergedChildContext||Ks,Ra=zn.current,Bt(zn,o),Bt(wr,wr.current),!0}function R1(o,a,u){var p=o.stateNode;if(!p)throw Error(n(169));u?(o=_1(o,a,Ra),p.__reactInternalMemoizedMergedChildContext=o,Lt(wr),Lt(zn),Bt(zn,o)):Lt(wr),Bt(wr,u)}var ls=null,ld=!1,ip=!1;function N1(o){ls===null?ls=[o]:ls.push(o)}function f6(o){ld=!0,N1(o)}function Ys(){if(!ip&&ls!==null){ip=!0;var o=0,a=rt;try{var u=ls;for(rt=1;o>=B,y-=B,cs=1<<32-Yn(a)+y|u<We?(Mn=ze,ze=null):Mn=ze.sibling;var ct=pe(Q,ze,ee[We],Ce);if(ct===null){ze===null&&(ze=Mn);break}o&&ze&&ct.alternate===null&&a(Q,ze),K=E(ct,K,We),$e===null?Ne=ct:$e.sibling=ct,$e=ct,ze=Mn}if(We===ee.length)return u(Q,ze),jt&&ja(Q,We),Ne;if(ze===null){for(;WeWe?(Mn=ze,ze=null):Mn=ze.sibling;var oa=pe(Q,ze,ct.value,Ce);if(oa===null){ze===null&&(ze=Mn);break}o&&ze&&oa.alternate===null&&a(Q,ze),K=E(oa,K,We),$e===null?Ne=oa:$e.sibling=oa,$e=oa,ze=Mn}if(ct.done)return u(Q,ze),jt&&ja(Q,We),Ne;if(ze===null){for(;!ct.done;We++,ct=ee.next())ct=ve(Q,ct.value,Ce),ct!==null&&(K=E(ct,K,We),$e===null?Ne=ct:$e.sibling=ct,$e=ct);return jt&&ja(Q,We),Ne}for(ze=p(Q,ze);!ct.done;We++,ct=ee.next())ct=Se(ze,Q,We,ct.value,Ce),ct!==null&&(o&&ct.alternate!==null&&ze.delete(ct.key===null?We:ct.key),K=E(ct,K,We),$e===null?Ne=ct:$e.sibling=ct,$e=ct);return o&&ze.forEach(function(q6){return a(Q,q6)}),jt&&ja(Q,We),Ne}function ln(Q,K,ee,Ce){if(typeof ee=="object"&&ee!==null&&ee.type===O&&ee.key===null&&(ee=ee.props.children),typeof ee=="object"&&ee!==null){switch(ee.$$typeof){case M:e:{for(var Ne=ee.key,$e=K;$e!==null;){if($e.key===Ne){if(Ne=ee.type,Ne===O){if($e.tag===7){u(Q,$e.sibling),K=y($e,ee.props.children),K.return=Q,Q=K;break e}}else if($e.elementType===Ne||typeof Ne=="object"&&Ne!==null&&Ne.$$typeof===fe&&V1(Ne)===$e.type){u(Q,$e.sibling),K=y($e,ee.props),K.ref=ac(Q,$e,ee),K.return=Q,Q=K;break e}u(Q,$e);break}else a(Q,$e);$e=$e.sibling}ee.type===O?(K=Wa(ee.props.children,Q.mode,Ce,ee.key),K.return=Q,Q=K):(Ce=Nd(ee.type,ee.key,ee.props,null,Q.mode,Ce),Ce.ref=ac(Q,K,ee),Ce.return=Q,Q=Ce)}return B(Q);case L:e:{for($e=ee.key;K!==null;){if(K.key===$e)if(K.tag===4&&K.stateNode.containerInfo===ee.containerInfo&&K.stateNode.implementation===ee.implementation){u(Q,K.sibling),K=y(K,ee.children||[]),K.return=Q,Q=K;break e}else{u(Q,K);break}else a(Q,K);K=K.sibling}K=om(ee,Q.mode,Ce),K.return=Q,Q=K}return B(Q);case fe:return $e=ee._init,ln(Q,K,$e(ee._payload),Ce)}if(nt(ee))return Me(Q,K,ee,Ce);if(le(ee))return _e(Q,K,ee,Ce);fd(Q,ee)}return typeof ee=="string"&&ee!==""||typeof ee=="number"?(ee=""+ee,K!==null&&K.tag===6?(u(Q,K.sibling),K=y(K,ee),K.return=Q,Q=K):(u(Q,K),K=rm(ee,Q.mode,Ce),K.return=Q,Q=K),B(Q)):u(Q,K)}return ln}var zi=H1(!0),U1=H1(!1),hd=Gs(null),pd=null,Vi=null,hp=null;function pp(){hp=Vi=pd=null}function mp(o){var a=hd.current;Lt(hd),o._currentValue=a}function gp(o,a,u){for(;o!==null;){var p=o.alternate;if((o.childLanes&a)!==a?(o.childLanes|=a,p!==null&&(p.childLanes|=a)):p!==null&&(p.childLanes&a)!==a&&(p.childLanes|=a),o===u)break;o=o.return}}function Hi(o,a){pd=o,hp=Vi=null,o=o.dependencies,o!==null&&o.firstContext!==null&&((o.lanes&a)!==0&&(Er=!0),o.firstContext=null)}function Xr(o){var a=o._currentValue;if(hp!==o)if(o={context:o,memoizedValue:a,next:null},Vi===null){if(pd===null)throw Error(n(308));Vi=o,pd.dependencies={lanes:0,firstContext:o}}else Vi=Vi.next=o;return a}var Ia=null;function yp(o){Ia===null?Ia=[o]:Ia.push(o)}function W1(o,a,u,p){var y=a.interleaved;return y===null?(u.next=u,yp(a)):(u.next=y.next,y.next=u),a.interleaved=u,ds(o,p)}function ds(o,a){o.lanes|=a;var u=o.alternate;for(u!==null&&(u.lanes|=a),u=o,o=o.return;o!==null;)o.childLanes|=a,u=o.alternate,u!==null&&(u.childLanes|=a),u=o,o=o.return;return u.tag===3?u.stateNode:null}var Xs=!1;function vp(o){o.updateQueue={baseState:o.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function q1(o,a){o=o.updateQueue,a.updateQueue===o&&(a.updateQueue={baseState:o.baseState,firstBaseUpdate:o.firstBaseUpdate,lastBaseUpdate:o.lastBaseUpdate,shared:o.shared,effects:o.effects})}function fs(o,a){return{eventTime:o,lane:a,tag:0,payload:null,callback:null,next:null}}function Qs(o,a,u){var p=o.updateQueue;if(p===null)return null;if(p=p.shared,(st&2)!==0){var y=p.pending;return y===null?a.next=a:(a.next=y.next,y.next=a),p.pending=a,ds(o,u)}return y=p.interleaved,y===null?(a.next=a,yp(p)):(a.next=y.next,y.next=a),p.interleaved=a,ds(o,u)}function md(o,a,u){if(a=a.updateQueue,a!==null&&(a=a.shared,(u&4194240)!==0)){var p=a.lanes;p&=o.pendingLanes,u|=p,a.lanes=u,Rs(o,u)}}function G1(o,a){var u=o.updateQueue,p=o.alternate;if(p!==null&&(p=p.updateQueue,u===p)){var y=null,E=null;if(u=u.firstBaseUpdate,u!==null){do{var B={eventTime:u.eventTime,lane:u.lane,tag:u.tag,payload:u.payload,callback:u.callback,next:null};E===null?y=E=B:E=E.next=B,u=u.next}while(u!==null);E===null?y=E=a:E=E.next=a}else y=E=a;u={baseState:p.baseState,firstBaseUpdate:y,lastBaseUpdate:E,shared:p.shared,effects:p.effects},o.updateQueue=u;return}o=u.lastBaseUpdate,o===null?u.firstBaseUpdate=a:o.next=a,u.lastBaseUpdate=a}function gd(o,a,u,p){var y=o.updateQueue;Xs=!1;var E=y.firstBaseUpdate,B=y.lastBaseUpdate,z=y.shared.pending;if(z!==null){y.shared.pending=null;var W=z,oe=W.next;W.next=null,B===null?E=oe:B.next=oe,B=W;var ye=o.alternate;ye!==null&&(ye=ye.updateQueue,z=ye.lastBaseUpdate,z!==B&&(z===null?ye.firstBaseUpdate=oe:z.next=oe,ye.lastBaseUpdate=W))}if(E!==null){var ve=y.baseState;B=0,ye=oe=W=null,z=E;do{var pe=z.lane,Se=z.eventTime;if((p&pe)===pe){ye!==null&&(ye=ye.next={eventTime:Se,lane:0,tag:z.tag,payload:z.payload,callback:z.callback,next:null});e:{var Me=o,_e=z;switch(pe=a,Se=u,_e.tag){case 1:if(Me=_e.payload,typeof Me=="function"){ve=Me.call(Se,ve,pe);break e}ve=Me;break e;case 3:Me.flags=Me.flags&-65537|128;case 0:if(Me=_e.payload,pe=typeof Me=="function"?Me.call(Se,ve,pe):Me,pe==null)break e;ve=te({},ve,pe);break e;case 2:Xs=!0}}z.callback!==null&&z.lane!==0&&(o.flags|=64,pe=y.effects,pe===null?y.effects=[z]:pe.push(z))}else Se={eventTime:Se,lane:pe,tag:z.tag,payload:z.payload,callback:z.callback,next:null},ye===null?(oe=ye=Se,W=ve):ye=ye.next=Se,B|=pe;if(z=z.next,z===null){if(z=y.shared.pending,z===null)break;pe=z,z=pe.next,pe.next=null,y.lastBaseUpdate=pe,y.shared.pending=null}}while(!0);if(ye===null&&(W=ve),y.baseState=W,y.firstBaseUpdate=oe,y.lastBaseUpdate=ye,a=y.shared.interleaved,a!==null){y=a;do B|=y.lane,y=y.next;while(y!==a)}else E===null&&(y.shared.lanes=0);za|=B,o.lanes=B,o.memoizedState=ve}}function K1(o,a,u){if(o=a.effects,a.effects=null,o!==null)for(a=0;au?u:4,o(!0);var p=kp.transition;kp.transition={};try{o(!1),a()}finally{rt=u,kp.transition=p}}function hv(){return Qr().memoizedState}function g6(o,a,u){var p=ta(o);if(u={lane:p,action:u,hasEagerState:!1,eagerState:null,next:null},pv(o))mv(a,u);else if(u=W1(o,a,u,p),u!==null){var y=nr();Eo(u,o,p,y),gv(u,a,p)}}function y6(o,a,u){var p=ta(o),y={lane:p,action:u,hasEagerState:!1,eagerState:null,next:null};if(pv(o))mv(a,y);else{var E=o.alternate;if(o.lanes===0&&(E===null||E.lanes===0)&&(E=a.lastRenderedReducer,E!==null))try{var B=a.lastRenderedState,z=E(B,u);if(y.hasEagerState=!0,y.eagerState=z,Dt(z,B)){var W=a.interleaved;W===null?(y.next=y,yp(a)):(y.next=W.next,W.next=y),a.interleaved=y;return}}catch{}finally{}u=W1(o,a,y,p),u!==null&&(y=nr(),Eo(u,o,p,y),gv(u,a,p))}}function pv(o){var a=o.alternate;return o===Ht||a!==null&&a===Ht}function mv(o,a){uc=bd=!0;var u=o.pending;u===null?a.next=a:(a.next=u.next,u.next=a),o.pending=a}function gv(o,a,u){if((u&4194240)!==0){var p=a.lanes;p&=o.pendingLanes,u|=p,a.lanes=u,Rs(o,u)}}var Ed={readContext:Xr,useCallback:Vn,useContext:Vn,useEffect:Vn,useImperativeHandle:Vn,useInsertionEffect:Vn,useLayoutEffect:Vn,useMemo:Vn,useReducer:Vn,useRef:Vn,useState:Vn,useDebugValue:Vn,useDeferredValue:Vn,useTransition:Vn,useMutableSource:Vn,useSyncExternalStore:Vn,useId:Vn,unstable_isNewReconciler:!1},v6={readContext:Xr,useCallback:function(o,a){return Oo().memoizedState=[o,a===void 0?null:a],o},useContext:Xr,useEffect:sv,useImperativeHandle:function(o,a,u){return u=u!=null?u.concat([o]):null,wd(4194308,4,lv.bind(null,a,o),u)},useLayoutEffect:function(o,a){return wd(4194308,4,o,a)},useInsertionEffect:function(o,a){return wd(4,2,o,a)},useMemo:function(o,a){var u=Oo();return a=a===void 0?null:a,o=o(),u.memoizedState=[o,a],o},useReducer:function(o,a,u){var p=Oo();return a=u!==void 0?u(a):a,p.memoizedState=p.baseState=a,o={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:o,lastRenderedState:a},p.queue=o,o=o.dispatch=g6.bind(null,Ht,o),[p.memoizedState,o]},useRef:function(o){var a=Oo();return o={current:o},a.memoizedState=o},useState:rv,useDebugValue:Tp,useDeferredValue:function(o){return Oo().memoizedState=o},useTransition:function(){var o=rv(!1),a=o[0];return o=m6.bind(null,o[1]),Oo().memoizedState=o,[a,o]},useMutableSource:function(){},useSyncExternalStore:function(o,a,u){var p=Ht,y=Oo();if(jt){if(u===void 0)throw Error(n(407));u=u()}else{if(u=a(),Pn===null)throw Error(n(349));($a&30)!==0||J1(p,a,u)}y.memoizedState=u;var E={value:u,getSnapshot:a};return y.queue=E,sv(ev.bind(null,p,E,o),[o]),p.flags|=2048,hc(9,Z1.bind(null,p,E,u,a),void 0,null),u},useId:function(){var o=Oo(),a=Pn.identifierPrefix;if(jt){var u=us,p=cs;u=(p&~(1<<32-Yn(p)-1)).toString(32)+u,a=":"+a+"R"+u,u=dc++,0<\/script>",o=o.removeChild(o.firstChild)):typeof p.is=="string"?o=B.createElement(u,{is:p.is}):(o=B.createElement(u),u==="select"&&(B=o,p.multiple?B.multiple=!0:p.size&&(B.size=p.size))):o=B.createElementNS(o,u),o[jo]=a,o[oc]=p,Nv(o,a,!1,!1),a.stateNode=o;e:{switch(B=Ss(u,p),u){case"dialog":Mt("cancel",o),Mt("close",o),y=p;break;case"iframe":case"object":case"embed":Mt("load",o),y=p;break;case"video":case"audio":for(y=0;yKi&&(a.flags|=128,p=!0,pc(E,!1),a.lanes=4194304)}else{if(!p)if(o=yd(B),o!==null){if(a.flags|=128,p=!0,u=o.updateQueue,u!==null&&(a.updateQueue=u,a.flags|=4),pc(E,!0),E.tail===null&&E.tailMode==="hidden"&&!B.alternate&&!jt)return Hn(a),null}else 2*At()-E.renderingStartTime>Ki&&u!==1073741824&&(a.flags|=128,p=!0,pc(E,!1),a.lanes=4194304);E.isBackwards?(B.sibling=a.child,a.child=B):(u=E.last,u!==null?u.sibling=B:a.child=B,E.last=B)}return E.tail!==null?(a=E.tail,E.rendering=a,E.tail=a.sibling,E.renderingStartTime=At(),a.sibling=null,u=Vt.current,Bt(Vt,p?u&1|2:u&1),a):(Hn(a),null);case 22:case 23:return em(),p=a.memoizedState!==null,o!==null&&o.memoizedState!==null!==p&&(a.flags|=8192),p&&(a.mode&1)!==0?(Ir&1073741824)!==0&&(Hn(a),a.subtreeFlags&6&&(a.flags|=8192)):Hn(a),null;case 24:return null;case 25:return null}throw Error(n(156,a.tag))}function D6(o,a){switch(cp(a),a.tag){case 1:return Cr(a.type)&&ad(),o=a.flags,o&65536?(a.flags=o&-65537|128,a):null;case 3:return Ui(),Lt(wr),Lt(zn),Ep(),o=a.flags,(o&65536)!==0&&(o&128)===0?(a.flags=o&-65537|128,a):null;case 5:return wp(a),null;case 13:if(Lt(Vt),o=a.memoizedState,o!==null&&o.dehydrated!==null){if(a.alternate===null)throw Error(n(340));$i()}return o=a.flags,o&65536?(a.flags=o&-65537|128,a):null;case 19:return Lt(Vt),null;case 4:return Ui(),null;case 10:return mp(a.type._context),null;case 22:case 23:return em(),null;case 24:return null;default:return null}}var Dd=!1,Un=!1,S6=typeof WeakSet=="function"?WeakSet:Set,Pe=null;function qi(o,a){var u=o.ref;if(u!==null)if(typeof u=="function")try{u(null)}catch(p){Qt(o,a,p)}else u.current=null}function Vp(o,a,u){try{u()}catch(p){Qt(o,a,p)}}var Ov=!1;function F6(o,a){if(ep=vt,o=Zn(),er(o)){if("selectionStart"in o)var u={start:o.selectionStart,end:o.selectionEnd};else e:{u=(u=o.ownerDocument)&&u.defaultView||window;var p=u.getSelection&&u.getSelection();if(p&&p.rangeCount!==0){u=p.anchorNode;var y=p.anchorOffset,E=p.focusNode;p=p.focusOffset;try{u.nodeType,E.nodeType}catch{u=null;break e}var B=0,z=-1,W=-1,oe=0,ye=0,ve=o,pe=null;t:for(;;){for(var Se;ve!==u||y!==0&&ve.nodeType!==3||(z=B+y),ve!==E||p!==0&&ve.nodeType!==3||(W=B+p),ve.nodeType===3&&(B+=ve.nodeValue.length),(Se=ve.firstChild)!==null;)pe=ve,ve=Se;for(;;){if(ve===o)break t;if(pe===u&&++oe===y&&(z=B),pe===E&&++ye===p&&(W=B),(Se=ve.nextSibling)!==null)break;ve=pe,pe=ve.parentNode}ve=Se}u=z===-1||W===-1?null:{start:z,end:W}}else u=null}u=u||{start:0,end:0}}else u=null;for(tp={focusedElem:o,selectionRange:u},vt=!1,Pe=a;Pe!==null;)if(a=Pe,o=a.child,(a.subtreeFlags&1028)!==0&&o!==null)o.return=a,Pe=o;else for(;Pe!==null;){a=Pe;try{var Me=a.alternate;if((a.flags&1024)!==0)switch(a.tag){case 0:case 11:case 15:break;case 1:if(Me!==null){var _e=Me.memoizedProps,ln=Me.memoizedState,Q=a.stateNode,K=Q.getSnapshotBeforeUpdate(a.elementType===a.type?_e:bo(a.type,_e),ln);Q.__reactInternalSnapshotBeforeUpdate=K}break;case 3:var ee=a.stateNode.containerInfo;ee.nodeType===1?ee.textContent="":ee.nodeType===9&&ee.documentElement&&ee.removeChild(ee.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(n(163))}}catch(Ce){Qt(a,a.return,Ce)}if(o=a.sibling,o!==null){o.return=a.return,Pe=o;break}Pe=a.return}return Me=Ov,Ov=!1,Me}function mc(o,a,u){var p=a.updateQueue;if(p=p!==null?p.lastEffect:null,p!==null){var y=p=p.next;do{if((y.tag&o)===o){var E=y.destroy;y.destroy=void 0,E!==void 0&&Vp(a,u,E)}y=y.next}while(y!==p)}}function Sd(o,a){if(a=a.updateQueue,a=a!==null?a.lastEffect:null,a!==null){var u=a=a.next;do{if((u.tag&o)===o){var p=u.create;u.destroy=p()}u=u.next}while(u!==a)}}function Hp(o){var a=o.ref;if(a!==null){var u=o.stateNode;switch(o.tag){case 5:o=u;break;default:o=u}typeof a=="function"?a(o):a.current=o}}function $v(o){var a=o.alternate;a!==null&&(o.alternate=null,$v(a)),o.child=null,o.deletions=null,o.sibling=null,o.tag===5&&(a=o.stateNode,a!==null&&(delete a[jo],delete a[oc],delete a[sp],delete a[u6],delete a[d6])),o.stateNode=null,o.return=null,o.dependencies=null,o.memoizedProps=null,o.memoizedState=null,o.pendingProps=null,o.stateNode=null,o.updateQueue=null}function zv(o){return o.tag===5||o.tag===3||o.tag===4}function Vv(o){e:for(;;){for(;o.sibling===null;){if(o.return===null||zv(o.return))return null;o=o.return}for(o.sibling.return=o.return,o=o.sibling;o.tag!==5&&o.tag!==6&&o.tag!==18;){if(o.flags&2||o.child===null||o.tag===4)continue e;o.child.return=o,o=o.child}if(!(o.flags&2))return o.stateNode}}function Up(o,a,u){var p=o.tag;if(p===5||p===6)o=o.stateNode,a?u.nodeType===8?u.parentNode.insertBefore(o,a):u.insertBefore(o,a):(u.nodeType===8?(a=u.parentNode,a.insertBefore(o,u)):(a=u,a.appendChild(o)),u=u._reactRootContainer,u!=null||a.onclick!==null||(a.onclick=od));else if(p!==4&&(o=o.child,o!==null))for(Up(o,a,u),o=o.sibling;o!==null;)Up(o,a,u),o=o.sibling}function Wp(o,a,u){var p=o.tag;if(p===5||p===6)o=o.stateNode,a?u.insertBefore(o,a):u.appendChild(o);else if(p!==4&&(o=o.child,o!==null))for(Wp(o,a,u),o=o.sibling;o!==null;)Wp(o,a,u),o=o.sibling}var Rn=null,wo=!1;function Js(o,a,u){for(u=u.child;u!==null;)Hv(o,a,u),u=u.sibling}function Hv(o,a,u){if(gr&&typeof gr.onCommitFiberUnmount=="function")try{gr.onCommitFiberUnmount(Ps,u)}catch{}switch(u.tag){case 5:Un||qi(u,a);case 6:var p=Rn,y=wo;Rn=null,Js(o,a,u),Rn=p,wo=y,Rn!==null&&(wo?(o=Rn,u=u.stateNode,o.nodeType===8?o.parentNode.removeChild(u):o.removeChild(u)):Rn.removeChild(u.stateNode));break;case 18:Rn!==null&&(wo?(o=Rn,u=u.stateNode,o.nodeType===8?op(o.parentNode,u):o.nodeType===1&&op(o,u),Vs(o)):op(Rn,u.stateNode));break;case 4:p=Rn,y=wo,Rn=u.stateNode.containerInfo,wo=!0,Js(o,a,u),Rn=p,wo=y;break;case 0:case 11:case 14:case 15:if(!Un&&(p=u.updateQueue,p!==null&&(p=p.lastEffect,p!==null))){y=p=p.next;do{var E=y,B=E.destroy;E=E.tag,B!==void 0&&((E&2)!==0||(E&4)!==0)&&Vp(u,a,B),y=y.next}while(y!==p)}Js(o,a,u);break;case 1:if(!Un&&(qi(u,a),p=u.stateNode,typeof p.componentWillUnmount=="function"))try{p.props=u.memoizedProps,p.state=u.memoizedState,p.componentWillUnmount()}catch(z){Qt(u,a,z)}Js(o,a,u);break;case 21:Js(o,a,u);break;case 22:u.mode&1?(Un=(p=Un)||u.memoizedState!==null,Js(o,a,u),Un=p):Js(o,a,u);break;default:Js(o,a,u)}}function Uv(o){var a=o.updateQueue;if(a!==null){o.updateQueue=null;var u=o.stateNode;u===null&&(u=o.stateNode=new S6),a.forEach(function(p){var y=j6.bind(null,o,p);u.has(p)||(u.add(p),p.then(y,y))})}}function Co(o,a){var u=a.deletions;if(u!==null)for(var p=0;py&&(y=B),p&=~E}if(p=y,p=At()-p,p=(120>p?120:480>p?480:1080>p?1080:1920>p?1920:3e3>p?3e3:4320>p?4320:1960*T6(p/1960))-p,10o?16:o,ea===null)var p=!1;else{if(o=ea,ea=null,Md=0,(st&6)!==0)throw Error(n(331));var y=st;for(st|=4,Pe=o.current;Pe!==null;){var E=Pe,B=E.child;if((Pe.flags&16)!==0){var z=E.deletions;if(z!==null){for(var W=0;WAt()-Kp?Ha(o,0):Gp|=u),xr(o,a)}function rb(o,a){a===0&&((o.mode&1)===0?a=1:(a=Ms,Ms<<=1,(Ms&130023424)===0&&(Ms=4194304)));var u=nr();o=ds(o,a),o!==null&&(_s(o,a,u),xr(o,u))}function N6(o){var a=o.memoizedState,u=0;a!==null&&(u=a.retryLane),rb(o,u)}function j6(o,a){var u=0;switch(o.tag){case 13:var p=o.stateNode,y=o.memoizedState;y!==null&&(u=y.retryLane);break;case 19:p=o.stateNode;break;default:throw Error(n(314))}p!==null&&p.delete(a),rb(o,u)}var ob;ob=function(o,a,u){if(o!==null)if(o.memoizedProps!==a.pendingProps||wr.current)Er=!0;else{if((o.lanes&u)===0&&(a.flags&128)===0)return Er=!1,x6(o,a,u);Er=(o.flags&131072)!==0}else Er=!1,jt&&(a.flags&1048576)!==0&&j1(a,ud,a.index);switch(a.lanes=0,a.tag){case 2:var p=a.type;Ad(o,a),o=a.pendingProps;var y=ji(a,zn.current);Hi(a,u),y=Ap(null,a,p,o,y,u);var E=Dp();return a.flags|=1,typeof y=="object"&&y!==null&&typeof y.render=="function"&&y.$$typeof===void 0?(a.tag=1,a.memoizedState=null,a.updateQueue=null,Cr(p)?(E=!0,id(a)):E=!1,a.memoizedState=y.state!==null&&y.state!==void 0?y.state:null,vp(a),y.updater=kd,a.stateNode=y,y._reactInternals=a,Mp(a,p,o,u),a=Np(null,a,p,!0,E,u)):(a.tag=0,jt&&E&&lp(a),tr(null,a,y,u),a=a.child),a;case 16:p=a.elementType;e:{switch(Ad(o,a),o=a.pendingProps,y=p._init,p=y(p._payload),a.type=p,y=a.tag=O6(p),o=bo(p,o),y){case 0:a=Rp(null,a,p,o,u);break e;case 1:a=Tv(null,a,p,o,u);break e;case 11:a=Av(null,a,p,o,u);break e;case 14:a=Dv(null,a,p,bo(p.type,o),u);break e}throw Error(n(306,p,""))}return a;case 0:return p=a.type,y=a.pendingProps,y=a.elementType===p?y:bo(p,y),Rp(o,a,p,y,u);case 1:return p=a.type,y=a.pendingProps,y=a.elementType===p?y:bo(p,y),Tv(o,a,p,y,u);case 3:e:{if(Pv(a),o===null)throw Error(n(387));p=a.pendingProps,E=a.memoizedState,y=E.element,q1(o,a),gd(a,p,null,u);var B=a.memoizedState;if(p=B.element,E.isDehydrated)if(E={element:p,isDehydrated:!1,cache:B.cache,pendingSuspenseBoundaries:B.pendingSuspenseBoundaries,transitions:B.transitions},a.updateQueue.baseState=E,a.memoizedState=E,a.flags&256){y=Wi(Error(n(423)),a),a=Mv(o,a,p,u,y);break e}else if(p!==y){y=Wi(Error(n(424)),a),a=Mv(o,a,p,u,y);break e}else for(jr=qs(a.stateNode.containerInfo.firstChild),Nr=a,jt=!0,vo=null,u=U1(a,null,p,u),a.child=u;u;)u.flags=u.flags&-3|4096,u=u.sibling;else{if($i(),p===y){a=hs(o,a,u);break e}tr(o,a,p,u)}a=a.child}return a;case 5:return Y1(a),o===null&&dp(a),p=a.type,y=a.pendingProps,E=o!==null?o.memoizedProps:null,B=y.children,np(p,y)?B=null:E!==null&&np(p,E)&&(a.flags|=32),Bv(o,a),tr(o,a,B,u),a.child;case 6:return o===null&&dp(a),null;case 13:return Lv(o,a,u);case 4:return bp(a,a.stateNode.containerInfo),p=a.pendingProps,o===null?a.child=zi(a,null,p,u):tr(o,a,p,u),a.child;case 11:return p=a.type,y=a.pendingProps,y=a.elementType===p?y:bo(p,y),Av(o,a,p,y,u);case 7:return tr(o,a,a.pendingProps,u),a.child;case 8:return tr(o,a,a.pendingProps.children,u),a.child;case 12:return tr(o,a,a.pendingProps.children,u),a.child;case 10:e:{if(p=a.type._context,y=a.pendingProps,E=a.memoizedProps,B=y.value,Bt(hd,p._currentValue),p._currentValue=B,E!==null)if(Dt(E.value,B)){if(E.children===y.children&&!wr.current){a=hs(o,a,u);break e}}else for(E=a.child,E!==null&&(E.return=a);E!==null;){var z=E.dependencies;if(z!==null){B=E.child;for(var W=z.firstContext;W!==null;){if(W.context===p){if(E.tag===1){W=fs(-1,u&-u),W.tag=2;var oe=E.updateQueue;if(oe!==null){oe=oe.shared;var ye=oe.pending;ye===null?W.next=W:(W.next=ye.next,ye.next=W),oe.pending=W}}E.lanes|=u,W=E.alternate,W!==null&&(W.lanes|=u),gp(E.return,u,a),z.lanes|=u;break}W=W.next}}else if(E.tag===10)B=E.type===a.type?null:E.child;else if(E.tag===18){if(B=E.return,B===null)throw Error(n(341));B.lanes|=u,z=B.alternate,z!==null&&(z.lanes|=u),gp(B,u,a),B=E.sibling}else B=E.child;if(B!==null)B.return=E;else for(B=E;B!==null;){if(B===a){B=null;break}if(E=B.sibling,E!==null){E.return=B.return,B=E;break}B=B.return}E=B}tr(o,a,y.children,u),a=a.child}return a;case 9:return y=a.type,p=a.pendingProps.children,Hi(a,u),y=Xr(y),p=p(y),a.flags|=1,tr(o,a,p,u),a.child;case 14:return p=a.type,y=bo(p,a.pendingProps),y=bo(p.type,y),Dv(o,a,p,y,u);case 15:return Sv(o,a,a.type,a.pendingProps,u);case 17:return p=a.type,y=a.pendingProps,y=a.elementType===p?y:bo(p,y),Ad(o,a),a.tag=1,Cr(p)?(o=!0,id(a)):o=!1,Hi(a,u),vv(a,p,y),Mp(a,p,y,u),Np(null,a,p,!0,o,u);case 19:return Rv(o,a,u);case 22:return Fv(o,a,u)}throw Error(n(156,a.tag))};function sb(o,a){return on(o,a)}function I6(o,a,u,p){this.tag=o,this.key=u,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=a,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=p,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Zr(o,a,u,p){return new I6(o,a,u,p)}function nm(o){return o=o.prototype,!(!o||!o.isReactComponent)}function O6(o){if(typeof o=="function")return nm(o)?1:0;if(o!=null){if(o=o.$$typeof,o===X)return 11;if(o===se)return 14}return 2}function ra(o,a){var u=o.alternate;return u===null?(u=Zr(o.tag,a,o.key,o.mode),u.elementType=o.elementType,u.type=o.type,u.stateNode=o.stateNode,u.alternate=o,o.alternate=u):(u.pendingProps=a,u.type=o.type,u.flags=0,u.subtreeFlags=0,u.deletions=null),u.flags=o.flags&14680064,u.childLanes=o.childLanes,u.lanes=o.lanes,u.child=o.child,u.memoizedProps=o.memoizedProps,u.memoizedState=o.memoizedState,u.updateQueue=o.updateQueue,a=o.dependencies,u.dependencies=a===null?null:{lanes:a.lanes,firstContext:a.firstContext},u.sibling=o.sibling,u.index=o.index,u.ref=o.ref,u}function Nd(o,a,u,p,y,E){var B=2;if(p=o,typeof o=="function")nm(o)&&(B=1);else if(typeof o=="string")B=5;else e:switch(o){case O:return Wa(u.children,y,E,a);case _:B=8,y|=8;break;case j:return o=Zr(12,u,a,y|2),o.elementType=j,o.lanes=E,o;case V:return o=Zr(13,u,a,y),o.elementType=V,o.lanes=E,o;case G:return o=Zr(19,u,a,y),o.elementType=G,o.lanes=E,o;case ne:return jd(u,y,E,a);default:if(typeof o=="object"&&o!==null)switch(o.$$typeof){case H:B=10;break e;case U:B=9;break e;case X:B=11;break e;case se:B=14;break e;case fe:B=16,p=null;break e}throw Error(n(130,o==null?o:typeof o,""))}return a=Zr(B,u,a,y),a.elementType=o,a.type=p,a.lanes=E,a}function Wa(o,a,u,p){return o=Zr(7,o,p,a),o.lanes=u,o}function jd(o,a,u,p){return o=Zr(22,o,p,a),o.elementType=ne,o.lanes=u,o.stateNode={isHidden:!1},o}function rm(o,a,u){return o=Zr(6,o,null,a),o.lanes=u,o}function om(o,a,u){return a=Zr(4,o.children!==null?o.children:[],o.key,a),a.lanes=u,a.stateNode={containerInfo:o.containerInfo,pendingChildren:null,implementation:o.implementation},a}function $6(o,a,u,p,y){this.tag=a,this.containerInfo=o,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Wl(0),this.expirationTimes=Wl(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Wl(0),this.identifierPrefix=p,this.onRecoverableError=y,this.mutableSourceEagerHydrationData=null}function sm(o,a,u,p,y,E,B,z,W){return o=new $6(o,a,u,z,W),a===1?(a=1,E===!0&&(a|=8)):a=0,E=Zr(3,null,null,a),o.current=E,E.stateNode=o,E.memoizedState={element:p,isDehydrated:u,cache:null,transitions:null,pendingSuspenseBoundaries:null},vp(E),o}function z6(o,a,u){var p=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),dm.exports=n4(),dm.exports}var wb;function r4(){if(wb)return Ud;wb=1;var e=g5();return Ud.createRoot=e.createRoot,Ud.hydrateRoot=e.hydrateRoot,Ud}var o4=r4();/** - * react-router v7.10.1 - * - * Copyright (c) Remix Software Inc. - * - * This source code is licensed under the MIT license found in the - * LICENSE.md file in the root directory of this source tree. - * - * @license MIT - */var Cb="popstate";function s4(e={}){function t(r,s){let{pathname:i,search:l,hash:c}=r.location;return kg("",{pathname:i,search:l,hash:c},s.state&&s.state.usr||null,s.state&&s.state.key||"default")}function n(r,s){return typeof s=="string"?s:tu(s)}return i4(t,n,null,e)}function It(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function io(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function a4(){return Math.random().toString(36).substring(2,10)}function Eb(e,t){return{usr:e.state,key:e.key,idx:t}}function kg(e,t,n=null,r){return{pathname:typeof e=="string"?e:e.pathname,search:"",hash:"",...typeof t=="string"?xl(t):t,state:n,key:t&&t.key||r||a4()}}function tu({pathname:e="/",search:t="",hash:n=""}){return t&&t!=="?"&&(e+=t.charAt(0)==="?"?t:"?"+t),n&&n!=="#"&&(e+=n.charAt(0)==="#"?n:"#"+n),e}function xl(e){let t={};if(e){let n=e.indexOf("#");n>=0&&(t.hash=e.substring(n),e=e.substring(0,n));let r=e.indexOf("?");r>=0&&(t.search=e.substring(r),e=e.substring(0,r)),e&&(t.pathname=e)}return t}function i4(e,t,n,r={}){let{window:s=document.defaultView,v5Compat:i=!1}=r,l=s.history,c="POP",d=null,f=h();f==null&&(f=0,l.replaceState({...l.state,idx:f},""));function h(){return(l.state||{idx:null}).idx}function m(){c="POP";let x=h(),D=x==null?null:x-f;f=x,d&&d({action:c,location:w.location,delta:D})}function g(x,D){c="PUSH";let S=kg(w.location,x,D);f=h()+1;let F=Eb(S,f),P=w.createHref(S);try{l.pushState(F,"",P)}catch(M){if(M instanceof DOMException&&M.name==="DataCloneError")throw M;s.location.assign(P)}i&&d&&d({action:c,location:w.location,delta:1})}function b(x,D){c="REPLACE";let S=kg(w.location,x,D);f=h();let F=Eb(S,f),P=w.createHref(S);l.replaceState(F,"",P),i&&d&&d({action:c,location:w.location,delta:0})}function C(x){return l4(x)}let w={get action(){return c},get location(){return e(s,l)},listen(x){if(d)throw new Error("A history only accepts one active listener");return s.addEventListener(Cb,m),d=x,()=>{s.removeEventListener(Cb,m),d=null}},createHref(x){return t(s,x)},createURL:C,encodeLocation(x){let D=C(x);return{pathname:D.pathname,search:D.search,hash:D.hash}},push:g,replace:b,go(x){return l.go(x)}};return w}function l4(e,t=!1){let n="http://localhost";typeof window<"u"&&(n=window.location.origin!=="null"?window.location.origin:window.location.href),It(n,"No window.location.(origin|href) available to create URL");let r=typeof e=="string"?e:tu(e);return r=r.replace(/ $/,"%20"),!t&&r.startsWith("//")&&(r=n+r),new URL(r,n)}function y5(e,t,n="/"){return c4(e,t,n,!1)}function c4(e,t,n,r){let s=typeof t=="string"?xl(t):t,i=xs(s.pathname||"/",n);if(i==null)return null;let l=v5(e);u4(l);let c=null;for(let d=0;c==null&&d{let h={relativePath:f===void 0?l.path||"":f,caseSensitive:l.caseSensitive===!0,childrenIndex:c,route:l};if(h.relativePath.startsWith("/")){if(!h.relativePath.startsWith(r)&&d)return;It(h.relativePath.startsWith(r),`Absolute route path "${h.relativePath}" nested under path "${r}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),h.relativePath=h.relativePath.slice(r.length)}let m=vs([r,h.relativePath]),g=n.concat(h);l.children&&l.children.length>0&&(It(l.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${m}".`),v5(l.children,t,g,m,d)),!(l.path==null&&!l.index)&&t.push({path:m,score:y4(m,l.index),routesMeta:g})};return e.forEach((l,c)=>{var d;if(l.path===""||!((d=l.path)!=null&&d.includes("?")))i(l,c);else for(let f of b5(l.path))i(l,c,!0,f)}),t}function b5(e){let t=e.split("/");if(t.length===0)return[];let[n,...r]=t,s=n.endsWith("?"),i=n.replace(/\?$/,"");if(r.length===0)return s?[i,""]:[i];let l=b5(r.join("/")),c=[];return c.push(...l.map(d=>d===""?i:[i,d].join("/"))),s&&c.push(...l),c.map(d=>e.startsWith("/")&&d===""?"/":d)}function u4(e){e.sort((t,n)=>t.score!==n.score?n.score-t.score:v4(t.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}var d4=/^:[\w-]+$/,f4=3,h4=2,p4=1,m4=10,g4=-2,kb=e=>e==="*";function y4(e,t){let n=e.split("/"),r=n.length;return n.some(kb)&&(r+=g4),t&&(r+=h4),n.filter(s=>!kb(s)).reduce((s,i)=>s+(d4.test(i)?f4:i===""?p4:m4),r)}function v4(e,t){return e.length===t.length&&e.slice(0,-1).every((r,s)=>r===t[s])?e[e.length-1]-t[t.length-1]:0}function b4(e,t,n=!1){let{routesMeta:r}=e,s={},i="/",l=[];for(let c=0;c{if(h==="*"){let C=c[g]||"";l=i.slice(0,i.length-C.length).replace(/(.)\/+$/,"$1")}const b=c[g];return m&&!b?f[h]=void 0:f[h]=(b||"").replace(/%2F/g,"/"),f},{}),pathname:i,pathnameBase:l,pattern:e}}function w4(e,t=!1,n=!0){io(e==="*"||!e.endsWith("*")||e.endsWith("/*"),`Route path "${e}" will be treated as if it were "${e.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${e.replace(/\*$/,"/*")}".`);let r=[],s="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(l,c,d)=>(r.push({paramName:c,isOptional:d!=null}),d?"/?([^\\/]+)?":"/([^\\/]+)")).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return e.endsWith("*")?(r.push({paramName:"*"}),s+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?s+="\\/*$":e!==""&&e!=="/"&&(s+="(?:(?=\\/|$))"),[new RegExp(s,t?void 0:"i"),r]}function C4(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return io(!1,`The URL path "${e}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${t}).`),e}}function xs(e,t){if(t==="/")return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let n=t.endsWith("/")?t.length-1:t.length,r=e.charAt(n);return r&&r!=="/"?null:e.slice(n)||"/"}var E4=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,k4=e=>E4.test(e);function x4(e,t="/"){let{pathname:n,search:r="",hash:s=""}=typeof e=="string"?xl(e):e,i;if(n)if(k4(n))i=n;else{if(n.includes("//")){let l=n;n=n.replace(/\/\/+/g,"/"),io(!1,`Pathnames cannot have embedded double slashes - normalizing ${l} -> ${n}`)}n.startsWith("/")?i=xb(n.substring(1),"/"):i=xb(n,t)}else i=t;return{pathname:i,search:S4(r),hash:F4(s)}}function xb(e,t){let n=t.replace(/\/+$/,"").split("/");return e.split("/").forEach(s=>{s===".."?n.length>1&&n.pop():s!=="."&&n.push(s)}),n.length>1?n.join("/"):"/"}function pm(e,t,n,r){return`Cannot include a '${e}' character in a manually specified \`to.${t}\` field [${JSON.stringify(r)}]. Please separate it out to the \`to.${n}\` field. Alternatively you may provide the full path as a string in and the router will parse it for you.`}function A4(e){return e.filter((t,n)=>n===0||t.route.path&&t.route.path.length>0)}function M0(e){let t=A4(e);return t.map((n,r)=>r===t.length-1?n.pathname:n.pathnameBase)}function L0(e,t,n,r=!1){let s;typeof e=="string"?s=xl(e):(s={...e},It(!s.pathname||!s.pathname.includes("?"),pm("?","pathname","search",s)),It(!s.pathname||!s.pathname.includes("#"),pm("#","pathname","hash",s)),It(!s.search||!s.search.includes("#"),pm("#","search","hash",s)));let i=e===""||s.pathname==="",l=i?"/":s.pathname,c;if(l==null)c=n;else{let m=t.length-1;if(!r&&l.startsWith("..")){let g=l.split("/");for(;g[0]==="..";)g.shift(),m-=1;s.pathname=g.join("/")}c=m>=0?t[m]:"/"}let d=x4(s,c),f=l&&l!=="/"&&l.endsWith("/"),h=(i||l===".")&&n.endsWith("/");return!d.pathname.endsWith("/")&&(f||h)&&(d.pathname+="/"),d}var vs=e=>e.join("/").replace(/\/\/+/g,"/"),D4=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),S4=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,F4=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e;function B4(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}function T4(e){return e.map(t=>t.route.path).filter(Boolean).join("/").replace(/\/\/*/g,"/")||"/"}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var w5=["POST","PUT","PATCH","DELETE"];new Set(w5);var P4=["GET",...w5];new Set(P4);var Al=v.createContext(null);Al.displayName="DataRouter";var uh=v.createContext(null);uh.displayName="DataRouterState";v.createContext(!1);var C5=v.createContext({isTransitioning:!1});C5.displayName="ViewTransition";var M4=v.createContext(new Map);M4.displayName="Fetchers";var L4=v.createContext(null);L4.displayName="Await";var co=v.createContext(null);co.displayName="Navigation";var fu=v.createContext(null);fu.displayName="Location";var Jo=v.createContext({outlet:null,matches:[],isDataRoute:!1});Jo.displayName="Route";var _0=v.createContext(null);_0.displayName="RouteError";function _4(e,{relative:t}={}){It(Dl(),"useHref() may be used only in the context of a component.");let{basename:n,navigator:r}=v.useContext(co),{hash:s,pathname:i,search:l}=hu(e,{relative:t}),c=i;return n!=="/"&&(c=i==="/"?n:vs([n,i])),r.createHref({pathname:c,search:l,hash:s})}function Dl(){return v.useContext(fu)!=null}function Zo(){return It(Dl(),"useLocation() may be used only in the context of a component."),v.useContext(fu).location}var E5="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function k5(e){v.useContext(co).static||v.useLayoutEffect(e)}function dh(){let{isDataRoute:e}=v.useContext(Jo);return e?G4():R4()}function R4(){It(Dl(),"useNavigate() may be used only in the context of a component.");let e=v.useContext(Al),{basename:t,navigator:n}=v.useContext(co),{matches:r}=v.useContext(Jo),{pathname:s}=Zo(),i=JSON.stringify(M0(r)),l=v.useRef(!1);return k5(()=>{l.current=!0}),v.useCallback((d,f={})=>{if(io(l.current,E5),!l.current)return;if(typeof d=="number"){n.go(d);return}let h=L0(d,JSON.parse(i),s,f.relative==="path");e==null&&t!=="/"&&(h.pathname=h.pathname==="/"?t:vs([t,h.pathname])),(f.replace?n.replace:n.push)(h,f.state,f)},[t,n,i,s,e])}v.createContext(null);function hu(e,{relative:t}={}){let{matches:n}=v.useContext(Jo),{pathname:r}=Zo(),s=JSON.stringify(M0(n));return v.useMemo(()=>L0(e,JSON.parse(s),r,t==="path"),[e,s,r,t])}function N4(e,t){return x5(e,t)}function x5(e,t,n,r,s){var S;It(Dl(),"useRoutes() may be used only in the context of a component.");let{navigator:i}=v.useContext(co),{matches:l}=v.useContext(Jo),c=l[l.length-1],d=c?c.params:{},f=c?c.pathname:"/",h=c?c.pathnameBase:"/",m=c&&c.route;{let F=m&&m.path||"";A5(f,!m||F.endsWith("*")||F.endsWith("*?"),`You rendered descendant (or called \`useRoutes()\`) at "${f}" (under ) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render. - -Please change the parent to .`)}let g=Zo(),b;if(t){let F=typeof t=="string"?xl(t):t;It(h==="/"||((S=F.pathname)==null?void 0:S.startsWith(h)),`When overriding the location using \`\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${h}" but pathname "${F.pathname}" was given in the \`location\` prop.`),b=F}else b=g;let C=b.pathname||"/",w=C;if(h!=="/"){let F=h.replace(/^\//,"").split("/");w="/"+C.replace(/^\//,"").split("/").slice(F.length).join("/")}let x=y5(e,{pathname:w});io(m||x!=null,`No routes matched location "${b.pathname}${b.search}${b.hash}" `),io(x==null||x[x.length-1].route.element!==void 0||x[x.length-1].route.Component!==void 0||x[x.length-1].route.lazy!==void 0,`Matched leaf route at location "${b.pathname}${b.search}${b.hash}" does not have an element or Component. This means it will render an with a null value by default resulting in an "empty" page.`);let D=z4(x&&x.map(F=>Object.assign({},F,{params:Object.assign({},d,F.params),pathname:vs([h,i.encodeLocation?i.encodeLocation(F.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:F.pathname]),pathnameBase:F.pathnameBase==="/"?h:vs([h,i.encodeLocation?i.encodeLocation(F.pathnameBase.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:F.pathnameBase])})),l,n,r,s);return t&&D?v.createElement(fu.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",...b},navigationType:"POP"}},D):D}function j4(){let e=q4(),t=B4(e)?`${e.status} ${e.statusText}`:e instanceof Error?e.message:JSON.stringify(e),n=e instanceof Error?e.stack:null,r="rgba(200,200,200, 0.5)",s={padding:"0.5rem",backgroundColor:r},i={padding:"2px 4px",backgroundColor:r},l=null;return console.error("Error handled by React Router default ErrorBoundary:",e),l=v.createElement(v.Fragment,null,v.createElement("p",null,"💿 Hey developer 👋"),v.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",v.createElement("code",{style:i},"ErrorBoundary")," or"," ",v.createElement("code",{style:i},"errorElement")," prop on your route.")),v.createElement(v.Fragment,null,v.createElement("h2",null,"Unexpected Application Error!"),v.createElement("h3",{style:{fontStyle:"italic"}},t),n?v.createElement("pre",{style:s},n):null,l)}var I4=v.createElement(j4,null),O4=class extends v.Component{constructor(e){super(e),this.state={location:e.location,revalidation:e.revalidation,error:e.error}}static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,t){return t.location!==e.location||t.revalidation!=="idle"&&e.revalidation==="idle"?{error:e.error,location:e.location,revalidation:e.revalidation}:{error:e.error!==void 0?e.error:t.error,location:t.location,revalidation:e.revalidation||t.revalidation}}componentDidCatch(e,t){this.props.onError?this.props.onError(e,t):console.error("React Router caught the following error during render",e)}render(){return this.state.error!==void 0?v.createElement(Jo.Provider,{value:this.props.routeContext},v.createElement(_0.Provider,{value:this.state.error,children:this.props.component})):this.props.children}};function $4({routeContext:e,match:t,children:n}){let r=v.useContext(Al);return r&&r.static&&r.staticContext&&(t.route.errorElement||t.route.ErrorBoundary)&&(r.staticContext._deepestRenderedBoundaryId=t.route.id),v.createElement(Jo.Provider,{value:e},n)}function z4(e,t=[],n=null,r=null,s=null){if(e==null){if(!n)return null;if(n.errors)e=n.matches;else if(t.length===0&&!n.initialized&&n.matches.length>0)e=n.matches;else return null}let i=e,l=n==null?void 0:n.errors;if(l!=null){let h=i.findIndex(m=>m.route.id&&(l==null?void 0:l[m.route.id])!==void 0);It(h>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(l).join(",")}`),i=i.slice(0,Math.min(i.length,h+1))}let c=!1,d=-1;if(n)for(let h=0;h=0?i=i.slice(0,d+1):i=[i[0]];break}}}let f=n&&r?(h,m)=>{var g,b;r(h,{location:n.location,params:((b=(g=n.matches)==null?void 0:g[0])==null?void 0:b.params)??{},unstable_pattern:T4(n.matches),errorInfo:m})}:void 0;return i.reduceRight((h,m,g)=>{let b,C=!1,w=null,x=null;n&&(b=l&&m.route.id?l[m.route.id]:void 0,w=m.route.errorElement||I4,c&&(d<0&&g===0?(A5("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),C=!0,x=null):d===g&&(C=!0,x=m.route.hydrateFallbackElement||null)));let D=t.concat(i.slice(0,g+1)),S=()=>{let F;return b?F=w:C?F=x:m.route.Component?F=v.createElement(m.route.Component,null):m.route.element?F=m.route.element:F=h,v.createElement($4,{match:m,routeContext:{outlet:h,matches:D,isDataRoute:n!=null},children:F})};return n&&(m.route.ErrorBoundary||m.route.errorElement||g===0)?v.createElement(O4,{location:n.location,revalidation:n.revalidation,component:w,error:b,children:S(),routeContext:{outlet:null,matches:D,isDataRoute:!0},onError:f}):S()},null)}function R0(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function V4(e){let t=v.useContext(Al);return It(t,R0(e)),t}function H4(e){let t=v.useContext(uh);return It(t,R0(e)),t}function U4(e){let t=v.useContext(Jo);return It(t,R0(e)),t}function N0(e){let t=U4(e),n=t.matches[t.matches.length-1];return It(n.route.id,`${e} can only be used on routes that contain a unique "id"`),n.route.id}function W4(){return N0("useRouteId")}function q4(){var r;let e=v.useContext(_0),t=H4("useRouteError"),n=N0("useRouteError");return e!==void 0?e:(r=t.errors)==null?void 0:r[n]}function G4(){let{router:e}=V4("useNavigate"),t=N0("useNavigate"),n=v.useRef(!1);return k5(()=>{n.current=!0}),v.useCallback(async(s,i={})=>{io(n.current,E5),n.current&&(typeof s=="number"?await e.navigate(s):await e.navigate(s,{fromRouteId:t,...i}))},[e,t])}var Ab={};function A5(e,t,n){!t&&!Ab[e]&&(Ab[e]=!0,io(!1,n))}v.memo(K4);function K4({routes:e,future:t,state:n,unstable_onError:r}){return x5(e,void 0,n,r,t)}function Y4({to:e,replace:t,state:n,relative:r}){It(Dl()," may be used only in the context of a component.");let{static:s}=v.useContext(co);io(!s," must not be used on the initial render in a . This is a no-op, but you should modify your code so the is only ever rendered in response to some user interaction or state change.");let{matches:i}=v.useContext(Jo),{pathname:l}=Zo(),c=dh(),d=L0(e,M0(i),l,r==="path"),f=JSON.stringify(d);return v.useEffect(()=>{c(JSON.parse(f),{replace:t,state:n,relative:r})},[c,f,r,t,n]),null}function rr(e){It(!1,"A is only ever to be used as the child of element, never rendered directly. Please wrap your in a .")}function X4({basename:e="/",children:t=null,location:n,navigationType:r="POP",navigator:s,static:i=!1,unstable_useTransitions:l}){It(!Dl(),"You cannot render a inside another . You should never have more than one in your app.");let c=e.replace(/^\/*/,"/"),d=v.useMemo(()=>({basename:c,navigator:s,static:i,unstable_useTransitions:l,future:{}}),[c,s,i,l]);typeof n=="string"&&(n=xl(n));let{pathname:f="/",search:h="",hash:m="",state:g=null,key:b="default"}=n,C=v.useMemo(()=>{let w=xs(f,c);return w==null?null:{location:{pathname:w,search:h,hash:m,state:g,key:b},navigationType:r}},[c,f,h,m,g,b,r]);return io(C!=null,` is not able to match the URL "${f}${h}${m}" because it does not start with the basename, so the won't render anything.`),C==null?null:v.createElement(co.Provider,{value:d},v.createElement(fu.Provider,{children:t,value:C}))}function Db({children:e,location:t}){return N4(xg(e),t)}function xg(e,t=[]){let n=[];return v.Children.forEach(e,(r,s)=>{if(!v.isValidElement(r))return;let i=[...t,s];if(r.type===v.Fragment){n.push.apply(n,xg(r.props.children,i));return}It(r.type===rr,`[${typeof r.type=="string"?r.type:r.type.name}] is not a component. All component children of must be a or `),It(!r.props.index||!r.props.children,"An index route cannot have child routes.");let l={id:r.props.id||i.join("-"),caseSensitive:r.props.caseSensitive,element:r.props.element,Component:r.props.Component,index:r.props.index,path:r.props.path,middleware:r.props.middleware,loader:r.props.loader,action:r.props.action,hydrateFallbackElement:r.props.hydrateFallbackElement,HydrateFallback:r.props.HydrateFallback,errorElement:r.props.errorElement,ErrorBoundary:r.props.ErrorBoundary,hasErrorBoundary:r.props.hasErrorBoundary===!0||r.props.ErrorBoundary!=null||r.props.errorElement!=null,shouldRevalidate:r.props.shouldRevalidate,handle:r.props.handle,lazy:r.props.lazy};r.props.children&&(l.children=xg(r.props.children,i)),n.push(l)}),n}var Sf="get",Ff="application/x-www-form-urlencoded";function fh(e){return typeof HTMLElement<"u"&&e instanceof HTMLElement}function Q4(e){return fh(e)&&e.tagName.toLowerCase()==="button"}function J4(e){return fh(e)&&e.tagName.toLowerCase()==="form"}function Z4(e){return fh(e)&&e.tagName.toLowerCase()==="input"}function eD(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function tD(e,t){return e.button===0&&(!t||t==="_self")&&!eD(e)}var Wd=null;function nD(){if(Wd===null)try{new FormData(document.createElement("form"),0),Wd=!1}catch{Wd=!0}return Wd}var rD=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function mm(e){return e!=null&&!rD.has(e)?(io(!1,`"${e}" is not a valid \`encType\` for \`
\`/\`\` and will default to "${Ff}"`),null):e}function oD(e,t){let n,r,s,i,l;if(J4(e)){let c=e.getAttribute("action");r=c?xs(c,t):null,n=e.getAttribute("method")||Sf,s=mm(e.getAttribute("enctype"))||Ff,i=new FormData(e)}else if(Q4(e)||Z4(e)&&(e.type==="submit"||e.type==="image")){let c=e.form;if(c==null)throw new Error('Cannot submit a