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