import{P as N,u as re,f as a,S as Me,t as d,i as s,Q as ie,R as Te,T as Re,b as ze,A as Ge,C as h,U as Ee,V as X,W as i,H as D,B as I,X as Y,I as J,Y as W,Z as E,x as Ke,E as Ne,h as _,_ as w,$ as P,a0 as ee,L as He,G as v,a1 as Oe,a2 as Ae,F as M,a3 as K,a4 as je,a5 as Ve,a6 as te,a7 as ne,a8 as Ue,a9 as Le,aa as Ze,ab as qe,y as Qe,ac as Be,q as Xe}from"./index-CtVw7BLk.js";import{c as Ye,I as Je,a as We,f as T,b as et,d as tt,g as nt,e as at,h as lt,i as st,j as ot,r as rt}from"./index-CPvx_C2g.js";import{D as it}from"./DocumentTitle-D9yyEXNP.js";import{f as ct}from"./time-CVcUxeVU.js";/**
 * @license @tabler/icons-solidjs v3.34.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=N("outline","info-small","IconInfoSmall",[["path",{d:"M12 9h.01"}],["path",{d:"M11 12h1v4h1"}]]);/**
 * @license @tabler/icons-solidjs v3.34.0 - MIT
 *
 * This source code is licensed under the MIT license.
 * See the LICENSE file in the root directory of this source tree.
 */var ae=N("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.34.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=N("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=d("<pre><code>");const gt=u=>{const[y]=re();return a(Re,{ref:p=>u.ref?.(p),get icon(){return a(Te,{size:24})},get title(){return y("connectionsDetails")},get children(){return a(Me,{get when(){return u.selectedConnectionID},get children(){var p=ut(),n=p.firstChild;return s(n,()=>JSON.stringify(ie().find(({id:C})=>C===u.selectedConnectionID),null,2)),p}})}})},mt=async u=>{typeof u=="string"?await navigator.clipboard.writeText(u):await navigator.clipboard.write(u)};var se=d('<div class="flex h-4 items-center">'),pt=d('<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>'),ft=d('<button><span></span><div class="badge badge-sm">'),bt=d("<option>"),ht=d('<div class="loading loading-spinner">'),vt=d("<tr>"),Ct=d("<th class=bg-base-200><div><div>"),$t=d("<button class=cursor-pointer>"),St=d('<tr class="hover:!bg-primary hover:text-primary-content">'),yt=d("<td class=py-2>"),Ft=d("<button><div></div><div></div><div>(<!>)");const oe=(u,y,p,n)=>{const C=rt(u.getValue(y),p);return n({itemRank:C}),C.passed},Pt=()=>{const u=ze();if(!Ge())return u("/setup",{replace:!0}),null;let y,p;const[n]=re(),[C,ce]=h(0),{activeConnections:H,closedConnections:O,paused:de,setPaused:ue}=Ee(),[ge,A]=h(!1),[me,j]=h(""),[V,pe]=X(h(!1),{name:"enableQuickFilter",storage:localStorage}),[fe,be]=h(),he=[{header:()=>n("details"),enableGrouping:!1,enableSorting:!1,enableColumnFilter:!1,enableGlobalFilter:!1,accessorKey:i.Details,cell:({row:e})=>(()=>{var o=se();return s(o,a(I,{class:"btn-circle btn-xs",onClick:()=>{be(e.original.id),p?.showModal()},get icon(){return a(dt,{size:"16"})}})),o})()},{header:()=>n("close"),enableGrouping:!1,enableSorting:!1,enableColumnFilter:!1,enableGlobalFilter:!1,accessorKey:i.Close,cell:({row:e})=>(()=>{var o=se();return s(o,a(I,{class:"btn-circle btn-xs",onClick:()=>Y(e.original.id),get icon(){return a(J,{size:"16"})}})),o})()},{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,o)=>W(e.original.start).valueOf()-W(o.original.start).valueOf()},{header:()=>n("dlSpeed"),enableGrouping:!1,accessorKey:i.DlSpeed,accessorFn:e=>`${D(e.downloadSpeed)}/s`,sortingFn:(e,o)=>e.original.downloadSpeed-o.original.downloadSpeed},{header:()=>n("ulSpeed"),enableGrouping:!1,accessorKey:i.UlSpeed,accessorFn:e=>`${D(e.uploadSpeed)}/s`,sortingFn:(e,o)=>e.original.uploadSpeed-o.original.uploadSpeed},{header:()=>n("dl"),enableGrouping:!1,accessorKey:i.Download,accessorFn:e=>D(e.download),sortingFn:(e,o)=>e.original.download-o.original.download},{header:()=>n("ul"),enableGrouping:!1,accessorKey:i.Upload,accessorFn:e=>D(e.upload),sortingFn:(e,o)=>e.original.upload-o.original.upload},{header:()=>n("sourceIP"),accessorKey:i.SourceIP,accessorFn:e=>{const o=e.metadata.sourceIP||n("inner");return E().find(F=>F.sourceIP===o)?.tagName||o}},{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}],[ve,Ce]=h([]),[$e,Se]=X(h([{id:i.ConnectTime,desc:!0}]),{name:"connectionsTableSorting",storage:localStorage}),x=Ye({filterFns:{fuzzy:oe},state:{get columnOrder(){return ne()},get grouping(){return ve()},get sorting(){return $e()},get columnVisibility(){return te()},get globalFilter(){return me()}},get data(){const e=C()===0?H():O();if(e.sort(($,F)=>$.id.localeCompare(F.id)),!V())return e;const o=new RegExp(Be(),"i");return e.filter($=>!o.test($.chains.join("")))},sortDescFirst:!0,enableHiding:!0,columns:he,onGlobalFilterChange:j,globalFilterFn:oe,onGroupingChange:Ce,onSortingChange:Se,getFilteredRowModel:ot(),getSortedRowModel:st(),getExpandedRowModel:lt(),getGroupedRowModel:at(),getCoreRowModel:nt()}),ye=x.getFlatHeaders().find(({id:e})=>e===i.SourceIP),[R,Fe]=h("");Ke(Qe(R,()=>{const e=E().find(o=>o.sourceIP===R());ye?.column.setFilterValue(e?e.tagName:R())}));const _e=Ne(()=>[{type:0,name:n("active"),count:H().length},{type:1,name:n("closed"),count:O().length}]);return[a(it,{get children(){return n("connections")}}),(()=>{var e=pt(),o=e.firstChild,$=o.firstChild,F=$.firstChild,U=F.nextSibling,z=U.firstChild,xe=z.firstChild,L=z.nextSibling,G=U.nextSibling,Ie=G.firstChild,k=$.nextSibling,Z=k.firstChild,we=o.nextSibling,q=we.firstChild,Q=q.firstChild,Pe=Q.nextSibling;return s(F,a(ee,{get each(){return _e()},children:t=>(()=>{var r=ft(),l=r.firstChild,g=l.nextSibling;return r.$$click=()=>ce(t().type),s(l,()=>t().name),s(g,()=>t().count),_(()=>w(r,P(C()===t().type&&"bg-primary !text-neutral","tab gap-2 px-2"))),r})()})),s(z,()=>n("quickFilter"),xe),L.addEventListener("change",t=>pe(t.target.checked)),G.addEventListener("change",t=>Fe(t.target.value)),s(Ie,()=>n("all")),s(G,a(ee,{get each(){return He.uniq(ie().map(({metadata:{sourceIP:t}})=>{const r=t||n("inner");return E().find(g=>g.sourceIP===r)?.tagName||r})).sort()},children:t=>(()=>{var r=bt();return s(r,t),_(()=>r.value=t()),r})()}),null),Z.$$input=t=>j(t.target.value),s(k,a(I,{class:"btn join-item btn-sm btn-primary",onClick:()=>ue(t=>!t),get icon(){return v(()=>!!de())()?a(Je,{}):a(We,{})}}),null),s(k,a(I,{class:"btn join-item btn-sm btn-primary",onClick:async()=>{A(!0),x.getState().globalFilter?await Promise.allSettled(x.getFilteredRowModel().rows.map(({original:t})=>Y(t.id))):await Oe(),A(!1)},get icon(){return v(()=>!!ge())()?ht():a(J,{})}}),null),s(k,a(I,{class:"btn join-item btn-sm btn-primary",onClick:()=>y?.showModal(),get icon(){return a(Ae,{})}}),null),s(Q,a(M,{get each(){return x.getHeaderGroups()},children:t=>(()=>{var r=vt();return s(r,a(M,{get each(){return t.headers},children:l=>(()=>{var g=Ct(),b=g.firstChild,c=b.firstChild;return s(b,(()=>{var m=v(()=>!!l.column.getCanGroup());return()=>m()?(()=>{var f=$t();return K(f,"click",l.column.getToggleGroupingHandler(),!0),s(f,(()=>{var S=v(()=>!!l.column.getIsGrouped());return()=>S()?a(le,{size:18}):a(ae,{size:18})})()),f})():null})(),c),K(c,"click",l.column.getToggleSortingHandler(),!0),s(c,()=>T(l.column.columnDef.header,l.getContext())),s(b,()=>({asc:a(tt,{}),desc:a(et,{})})[l.column.getIsSorted()]??null,null),_(m=>{var f=P("flex items-center gap-2"),S=P(l.column.getCanSort()&&"cursor-pointer select-none","flex-1");return f!==m.e&&w(b,m.e=f),S!==m.t&&w(c,m.t=S),m},{e:void 0,t:void 0}),g})()})),r})()})),s(Pe,a(M,{get each(){return x.getRowModel().rows},children:t=>(()=>{var r=St();return s(r,a(M,{get each(){return t.getVisibleCells()},children:l=>(()=>{var g=yt();return g.$$contextmenu=b=>{b.preventDefault();const c=l.renderValue();c&&mt(c).catch(()=>{})},s(g,(()=>{var b=v(()=>!!l.getIsGrouped());return()=>b()?(()=>{var c=Ft(),m=c.firstChild,f=m.nextSibling,S=f.nextSibling,ke=S.firstChild,B=ke.nextSibling;return B.nextSibling,K(c,"click",t.getToggleExpandedHandler(),!0),s(m,(()=>{var De=v(()=>!!t.getIsExpanded());return()=>De()?a(le,{size:18}):a(ae,{size:18})})()),s(f,()=>T(l.column.columnDef.cell,l.getContext())),s(S,()=>t.subRows.length,B),_(()=>w(c,P(t.getCanExpand()?"cursor-pointer":"cursor-normal","flex items-center gap-2"))),c})():v(()=>!!l.getIsAggregated())()?T(l.column.columnDef.aggregatedCell??l.column.columnDef.cell,l.getContext()):v(()=>!!l.getIsPlaceholder())()?null:T(l.column.columnDef.cell,l.getContext())})()),g})()})),r})()})),s(e,a(Ue,{ref:t=>y=t,get order(){return ne()},get visible(){return te()},onOrderChange:t=>Ve(t),onVisibleChange:t=>je({...t})}),null),s(e,a(gt,{ref:t=>p=t,get selectedConnectionID(){return fe()}}),null),_(t=>{var r=n("search"),l=P(Le(Ze()),"table relative rounded-none table-zebra");return r!==t.e&&qe(Z,"placeholder",t.e=r),l!==t.t&&w(q,t.t=l),t},{e:void 0,t:void 0}),_(()=>L.checked=V()),e})()]};Xe(["input","click","contextmenu"]);export{Pt as default};
