import{N as O,u as ie,d as l,S as Te,t as u,i as s,O as ce,P as ze,Q as Ge,b as Me,y as Ke,A as C,R as Ee,T as Y,U as i,G as D,B as I,V as J,I as W,W as ee,X as R,r as Re,D as Ne,g as _,Y as w,Z as P,_ as te,K as Oe,E as $,$ as Ae,a0 as je,F as T,a1 as N,a2 as He,a3 as Ve,a4 as ne,a5 as ae,a6 as Ue,a7 as Ze,a8 as Le,a9 as Qe,w as qe,aa as Be,n as Xe}from"./index-BfxF6Zjo.js";import{c as Ye,I as Je,a as We,f as z,b as et,d as tt,g as nt,e as at,h as lt,i as st,j as rt,r as ot}from"./index-CXfh_Ffl.js";import{D as it}from"./DocumentTitle-qgMGpI7d.js";import{f as ct}from"./time-M8P-MK1v.js";/**
 * @license @tabler/icons-solidjs v3.31.0 - MIT
 *
 * This source code is licensed under the MIT license.
 * See the LICENSE file in the root directory of this source tree.
 */var dt=O("outline","info-small","IconInfoSmall",[["path",{d:"M12 9h.01"}],["path",{d:"M11 12h1v4h1"}]]);/**
 * @license @tabler/icons-solidjs v3.31.0 - MIT
 *
 * This source code is licensed under the MIT license.
 * See the LICENSE file in the root directory of this source tree.
 */var le=O("filled","zoom-in-filled","IconZoomInFilled",[["path",{d:"M14 3.072a8 8 0 0 1 2.617 11.424l4.944 4.943a1.5 1.5 0 0 1 -2.008 2.225l-.114 -.103l-4.943 -4.944a8 8 0 0 1 -12.49 -6.332l-.006 -.285l.005 -.285a8 8 0 0 1 11.995 -6.643zm-4 2.928a1 1 0 0 0 -.993 .883l-.007 .117v2h-2l-.117 .007a1 1 0 0 0 0 1.986l.117 .007h2v2l.007 .117a1 1 0 0 0 1.986 0l.007 -.117v-2h2l.117 -.007a1 1 0 0 0 0 -1.986l-.117 -.007h-2v-2l-.007 -.117a1 1 0 0 0 -.993 -.883z"}]]);/**
 * @license @tabler/icons-solidjs v3.31.0 - MIT
 *
 * This source code is licensed under the MIT license.
 * See the LICENSE file in the root directory of this source tree.
 */var se=O("filled","zoom-out-filled","IconZoomOutFilled",[["path",{d:"M14 3.072a8 8 0 0 1 2.617 11.424l4.944 4.943a1.5 1.5 0 0 1 -2.008 2.225l-.114 -.103l-4.943 -4.944a8 8 0 0 1 -12.49 -6.332l-.006 -.285l.005 -.285a8 8 0 0 1 11.995 -6.643zm-1 5.928h-6l-.117 .007a1 1 0 0 0 0 1.986l.117 .007h6l.117 -.007a1 1 0 0 0 0 -1.986l-.117 -.007z"}]]),ut=u("<pre><code>");const gt=c=>{const[h]=ie();return l(Ge,{ref:g=>{var n;return(n=c.ref)==null?void 0:n.call(c,g)},get icon(){return l(ze,{size:24})},get title(){return h("connectionsDetails")},get children(){return l(Te,{get when(){return c.selectedConnectionID},get children(){var g=ut(),n=g.firstChild;return s(n,()=>JSON.stringify(ce().find(({id:S})=>S===c.selectedConnectionID),null,2)),g}})}})},mt=async c=>{typeof c=="string"?await navigator.clipboard.writeText(c):await navigator.clipboard.write(c)};var re=u('<div class="flex h-4 items-center">'),pt=u('<div class="flex h-full flex-col gap-2"><div class="flex w-full flex-wrap items-center gap-2"><div class="flex items-center gap-2"><div class="tabs tabs-sm gap-2 tabs-box"></div><div class="flex items-center"><span class="mr-2 hidden lg:inline-block">:</span><input type=checkbox class=toggle></div><select class="select flex-1 select-sm select-primary"><option value></option></select></div><div class="join flex flex-1 items-center"><input type=search class="input input-sm join-item flex-1 input-primary"></div></div><div class="overflow-x-auto rounded-md bg-base-300 whitespace-nowrap"><table><thead class="sticky top-0 z-10 h-8"></thead><tbody>'),bt=u('<button><span></span><div class="badge badge-sm">'),ft=u("<option>"),ht=u('<div class="loading loading-spinner">'),vt=u("<tr>"),Ct=u("<th class=bg-base-200><div><div>"),$t=u("<button class=cursor-pointer>"),St=u('<tr class="hover:!bg-primary hover:text-primary-content">'),yt=u("<td class=py-2>"),Ft=u("<button><div></div><div></div><div>(<!>)");const oe=(c,h,g,n)=>{const S=ot(c.getValue(h),g);return n({itemRank:S}),S.passed},Pt=()=>{const c=Me();if(!Ke())return c("/setup",{replace:!0}),null;let h,g;const[n]=ie(),[S,de]=C(0),{activeConnections:A,closedConnections:j,paused:ue,setPaused:ge}=Ee(),[me,H]=C(!1),[pe,V]=C(""),[U,be]=Y(C(!1),{name:"enableQuickFilter",storage:localStorage}),[fe,he]=C(),ve=[{header:()=>n("details"),enableGrouping:!1,enableSorting:!1,enableColumnFilter:!1,enableGlobalFilter:!1,accessorKey:i.Details,cell:({row:e})=>(()=>{var r=re();return s(r,l(I,{class:"btn-circle btn-xs",onClick:()=>{he(e.original.id),g==null||g.showModal()},get icon(){return l(dt,{size:"16"})}})),r})()},{header:()=>n("close"),enableGrouping:!1,enableSorting:!1,enableColumnFilter:!1,enableGlobalFilter:!1,accessorKey:i.Close,cell:({row:e})=>(()=>{var r=re();return s(r,l(I,{class:"btn-circle btn-xs",onClick:()=>J(e.original.id),get icon(){return l(W,{size:"16"})}})),r})()},{header:()=>n("ID"),enableGrouping:!1,accessorKey:i.ID,accessorFn:e=>e.id},{header:()=>n("type"),accessorKey:i.Type,accessorFn:e=>`${e.metadata.type}(${e.metadata.network})`},{header:()=>n("process"),accessorKey:i.Process,accessorFn:e=>e.metadata.process||e.metadata.processPath.replace(/^.*[/\\](.*)$/,"$1")||"-"},{header:()=>n("host"),accessorKey:i.Host,accessorFn:e=>`${e.metadata.host?e.metadata.host:e.metadata.destinationIP}:${e.metadata.destinationPort}`},{header:()=>n("sniffHost"),accessorKey:i.SniffHost,accessorFn:e=>e.metadata.sniffHost||"-"},{header:()=>n("rule"),accessorKey:i.Rule,accessorFn:e=>e.rulePayload?`${e.rule} :: ${e.rulePayload}`:e.rule},{header:()=>n("chains"),accessorKey:i.Chains,accessorFn:e=>e.chains.slice().reverse().join(" :: ")},{header:()=>n("connectTime"),enableGrouping:!1,accessorKey:i.ConnectTime,accessorFn:e=>ct(e.start),sortingFn:(e,r)=>ee(e.original.start).valueOf()-ee(r.original.start).valueOf()},{header:()=>n("dlSpeed"),enableGrouping:!1,accessorKey:i.DlSpeed,accessorFn:e=>`${D(e.downloadSpeed)}/s`,sortingFn:(e,r)=>e.original.downloadSpeed-r.original.downloadSpeed},{header:()=>n("ulSpeed"),enableGrouping:!1,accessorKey:i.UlSpeed,accessorFn:e=>`${D(e.uploadSpeed)}/s`,sortingFn:(e,r)=>e.original.uploadSpeed-r.original.uploadSpeed},{header:()=>n("dl"),enableGrouping:!1,accessorKey:i.Download,accessorFn:e=>D(e.download),sortingFn:(e,r)=>e.original.download-r.original.download},{header:()=>n("ul"),enableGrouping:!1,accessorKey:i.Upload,accessorFn:e=>D(e.upload),sortingFn:(e,r)=>e.original.upload-r.original.upload},{header:()=>n("sourceIP"),accessorKey:i.SourceIP,accessorFn:e=>{const r=e.metadata.sourceIP||n("inner"),m=R().find(F=>F.sourceIP===r);return(m==null?void 0:m.tagName)||r}},{header:()=>n("sourcePort"),accessorKey:i.SourcePort,accessorFn:e=>e.metadata.sourcePort},{header:()=>n("destination"),accessorKey:i.Destination,accessorFn:e=>e.metadata.remoteDestination||e.metadata.destinationIP||e.metadata.host},{header:()=>n("inboundUser"),accessorKey:i.InboundUser,accessorFn:e=>e.metadata.inboundUser||e.metadata.inboundName||e.metadata.inboundPort}],[Ce,$e]=C([]),[Se,ye]=Y(C([{id:i.ConnectTime,desc:!0}]),{name:"connectionsTableSorting",storage:localStorage}),x=Ye({filterFns:{fuzzy:oe},state:{get columnOrder(){return ae()},get grouping(){return Ce()},get sorting(){return Se()},get columnVisibility(){return ne()},get globalFilter(){return pe()}},get data(){const e=S()===0?A():j();if(e.sort((m,F)=>m.id.localeCompare(F.id)),!U())return e;const r=new RegExp(Be(),"i");return e.filter(m=>!r.test(m.chains.join("")))},sortDescFirst:!0,enableHiding:!0,columns:ve,onGlobalFilterChange:V,globalFilterFn:oe,onGroupingChange:$e,onSortingChange:ye,getFilteredRowModel:rt(),getSortedRowModel:st(),getExpandedRowModel:lt(),getGroupedRowModel:at(),getCoreRowModel:nt()}),G=x.getFlatHeaders().find(({id:e})=>e===i.SourceIP),[M,Fe]=C("");Re(qe(M,()=>{const e=R().find(r=>r.sourceIP===M());G==null||G.column.setFilterValue(e?e.tagName:M())}));const _e=Ne(()=>[{type:0,name:n("active"),count:A().length},{type:1,name:n("closed"),count:j().length}]);return[l(it,{get children(){return n("connections")}}),(()=>{var e=pt(),r=e.firstChild,m=r.firstChild,F=m.firstChild,Z=F.nextSibling,K=Z.firstChild,xe=K.firstChild,L=K.nextSibling,E=Z.nextSibling,Ie=E.firstChild,k=m.nextSibling,Q=k.firstChild,we=r.nextSibling,q=we.firstChild,B=q.firstChild,Pe=B.nextSibling;return s(F,l(te,{get each(){return _e()},children:t=>(()=>{var o=bt(),a=o.firstChild,p=a.nextSibling;return o.$$click=()=>de(t().type),s(a,()=>t().name),s(p,()=>t().count),_(()=>w(o,P(S()===t().type&&"bg-primary !text-neutral","tab gap-2 px-2"))),o})()})),s(K,()=>n("quickFilter"),xe),L.addEventListener("change",t=>be(t.target.checked)),E.addEventListener("change",t=>Fe(t.target.value)),s(Ie,()=>n("all")),s(E,l(te,{get each(){return Oe.uniq(ce().map(({metadata:{sourceIP:t}})=>{const o=t||n("inner"),a=R().find(p=>p.sourceIP===o);return(a==null?void 0:a.tagName)||o})).sort()},children:t=>(()=>{var o=ft();return s(o,t),_(()=>o.value=t()),o})()}),null),Q.$$input=t=>V(t.target.value),s(k,l(I,{class:"btn join-item btn-sm btn-primary",onClick:()=>ge(t=>!t),get icon(){return $(()=>!!ue())()?l(Je,{}):l(We,{})}}),null),s(k,l(I,{class:"btn join-item btn-sm btn-primary",onClick:async()=>{H(!0),x.getState().globalFilter?await Promise.allSettled(x.getFilteredRowModel().rows.map(({original:t})=>J(t.id))):await Ae(),H(!1)},get icon(){return $(()=>!!me())()?ht():l(W,{})}}),null),s(k,l(I,{class:"btn join-item btn-sm btn-primary",onClick:()=>h==null?void 0:h.showModal(),get icon(){return l(je,{})}}),null),s(B,l(T,{get each(){return x.getHeaderGroups()},children:t=>(()=>{var o=vt();return s(o,l(T,{get each(){return t.headers},children:a=>(()=>{var p=Ct(),v=p.firstChild,d=v.firstChild;return s(v,(()=>{var b=$(()=>!!a.column.getCanGroup());return()=>b()?(()=>{var f=$t();return N(f,"click",a.column.getToggleGroupingHandler(),!0),s(f,(()=>{var y=$(()=>!!a.column.getIsGrouped());return()=>y()?l(se,{size:18}):l(le,{size:18})})()),f})():null})(),d),N(d,"click",a.column.getToggleSortingHandler(),!0),s(d,()=>z(a.column.columnDef.header,a.getContext())),s(v,()=>({asc:l(tt,{}),desc:l(et,{})})[a.column.getIsSorted()]??null,null),_(b=>{var f=P("flex items-center gap-2"),y=P(a.column.getCanSort()&&"cursor-pointer select-none","flex-1");return f!==b.e&&w(v,b.e=f),y!==b.t&&w(d,b.t=y),b},{e:void 0,t:void 0}),p})()})),o})()})),s(Pe,l(T,{get each(){return x.getRowModel().rows},children:t=>(()=>{var o=St();return s(o,l(T,{get each(){return t.getVisibleCells()},children:a=>(()=>{var p=yt();return p.$$contextmenu=v=>{v.preventDefault();const d=a.renderValue();d&&mt(d).catch(()=>{})},s(p,(()=>{var v=$(()=>!!a.getIsGrouped());return()=>v()?(()=>{var d=Ft(),b=d.firstChild,f=b.nextSibling,y=f.nextSibling,ke=y.firstChild,X=ke.nextSibling;return X.nextSibling,N(d,"click",t.getToggleExpandedHandler(),!0),s(b,(()=>{var De=$(()=>!!t.getIsExpanded());return()=>De()?l(se,{size:18}):l(le,{size:18})})()),s(f,()=>z(a.column.columnDef.cell,a.getContext())),s(y,()=>t.subRows.length,X),_(()=>w(d,P(t.getCanExpand()?"cursor-pointer":"cursor-normal","flex items-center gap-2"))),d})():$(()=>!!a.getIsAggregated())()?z(a.column.columnDef.aggregatedCell??a.column.columnDef.cell,a.getContext()):$(()=>!!a.getIsPlaceholder())()?null:z(a.column.columnDef.cell,a.getContext())})()),p})()})),o})()})),s(e,l(Ue,{ref:t=>h=t,get order(){return ae()},get visible(){return ne()},onOrderChange:t=>Ve(t),onVisibleChange:t=>He({...t})}),null),s(e,l(gt,{ref:t=>g=t,get selectedConnectionID(){return fe()}}),null),_(t=>{var o=n("search"),a=P(Ze(Le()),"table relative rounded-none table-zebra");return o!==t.e&&Qe(Q,"placeholder",t.e=o),a!==t.t&&w(q,t.t=a),t},{e:void 0,t:void 0}),_(()=>L.checked=U()),e})()]};Xe(["input","click","contextmenu"]);export{Pt as default};
