import{S as f}from"./StatusGrid-DAyEP9oU.js";import{A as m}from"./ActionMenu-B3aKIJFu.js";import{d as u,u as b,P as h,g as _,o as g,f as v,r as y,L as S,_ as C}from"./index-D92x6h1h.js";import{f as V}from"./localDay-CoEbUe3O.js";import"./DataGrid-CbtTsx8d.js";import"./index-BG9mM10J.js";import"./index-7HNOjfAo.js";import"./useGridLayout-DCIiMD42.js";import"./CollapsibleSection.vue_vue_type_style_index_0_lang-Cq2AVc9p.js";import"./sliders-horizontal-Am8f4Xsv.js";import"./status-CE0GKX14.js";const k=u({__name:"ConnectionsView",setup(D){const{t:r}=b(),s=(n,e)=>{const o=e.peer??"",t=e.peer_port??"";return t?`${o}:${t}`:String(o)},a=(n,e)=>{const o=e.server??"",t=e.server_port??"";return t?`${o}:${t}`:String(o)},l=n=>{if(!n||typeof n!="object")return"";const e=n,o=[];return e.tcp&&o.push(`TCP: ${e.tcp.join(", ")}`),e.udp&&o.push(`UDP: ${e.udp.join(", ")}`),o.join("; ")},c=[{field:"type",label:r("Type"),sortable:!0,minVisible:"phone",phoneOrder:1},{field:"peer",label:r("Client Address"),sortable:!0,minVisible:"phone",phoneRole:"primary",width:200,format:s},{field:"peer_extra_ports",label:r("Client Data Ports"),sortable:!1,minVisible:"desktop",width:200,format:l},{field:"user",label:r("Username"),sortable:!0,minVisible:"phone",phoneOrder:2},{field:"started",label:r("Started"),sortable:!0,minVisible:"phone",phoneOrder:3,format:V},{field:"streaming",label:r("Streaming"),sortable:!0,minVisible:"phone",phoneOrder:4},{field:"server",label:r("Server"),sortable:!0,minVisible:"desktop",width:200,format:a}],i=y(!1);async function p(n,e){const o=n.map(t=>t.id).filter(t=>typeof t=="number");if(o.length!==0&&globalThis.confirm(r("Drop the selected connection(s)?"))){i.value=!0;try{await S("connections/cancel",{id:JSON.stringify(o)}),e()}catch(t){globalThis.alert(r("Failed to drop connection(s): {0}",t instanceof Error?t.message:String(t)))}finally{i.value=!1}}}function d(n,e){return[{id:"drop",label:i.value?r("Dropping…"):r("Drop"),tooltip:r("Drop the selected connection(s)"),disabled:n.length===0||i.value,onClick:()=>p(n,e)}]}return(n,e)=>(g(),h(f,{endpoint:"status/connections","help-page":"status_connections","notification-class":"connections",columns:c,"key-field":"id","default-sort":{key:"started",dir:"DESC"},"storage-key":"status-connections",class:"status-view__grid"},{toolbarActions:_(({selection:o,clearSelection:t})=>[v(m,{actions:d(o,t)},null,8,["actions"])]),_:1}))}}),N=C(k,[["__scopeId","data-v-017c9d62"]]);export{N as default};
