import{i as e}from"./chunk-aKtaBQYM.js";import{N as t,Vt as n,wt as r,zt as i}from"./mui-B6lh3XSP.js";import{l as a}from"./IconButton-BEBOUWhl.js";import{n as o}from"./MenuItem-HQNtf0LG.js";import{n as s,t as c}from"./SearchHeader-CmohWzoP.js";import{t as l}from"./TableHead-_KJlbpnj.js";import{At as u,Dt as d,O as f,Ot as p,_t as m,pt as h,w as g,wt as _,yt as v}from"./index-KVuxnkWj.js";import{t as y}from"./CollectionActions-CDxOJIb6.js";import{t as b}from"./TableShimmer-f7Cf4NTV.js";import{n as x,t as S}from"./useSettingsStyles-X3caKosH.js";import{t as C}from"./Link-C46sYcuF.js";var w=e(n(),1),T=r(),E=t((0,T.jsx)(`path`,{d:`M5 4v2h14V4zm0 10h4v6h6v-6h4l-7-7z`}),`Publish`),D=t((0,T.jsx)(`path`,{d:`M18 16.08c-.76 0-1.44.3-1.96.77L8.91 12.7c.05-.23.09-.46.09-.7s-.04-.47-.09-.7l7.05-4.11c.54.5 1.25.81 2.04.81 1.66 0 3-1.34 3-3s-1.34-3-3-3-3 1.34-3 3c0 .24.04.47.09.7L8.04 9.81C7.5 9.31 6.79 9 6 9c-1.66 0-3 1.34-3 3s1.34 3 3 3c.79 0 1.5-.31 2.04-.81l7.12 4.16c-.05.21-.08.43-.08.65 0 1.61 1.31 2.92 2.92 2.92s2.92-1.31 2.92-2.92-1.31-2.92-2.92-2.92`}),`Share`),O=()=>{let{classes:e}=S(),t=a(),n=v(),r=f(`limitCommands`),O=i(e=>e.session.server.attributes.disableShare),k=i(e=>e.session.user),[A,j]=(0,w.useReducer)(e=>e+1,0),[M,N]=(0,w.useState)([]),[P,F]=(0,w.useState)(``),[I,L]=(0,w.useState)(!0),R=(0,w.useCallback)(async(e,t)=>{let n=new URLSearchParams({limit:50,offset:e});P&&n.append(`keyword`,P);let r=await(await g(`/api/groups?${n.toString()}`,{signal:t})).json();N(t=>e?[...t,...r]:r),L(r.length>=50)},[P]),z=m(()=>R(M.length));h(async({signal:e})=>{N([]),await R(0,e)},[A,R]);let B={key:`command`,title:n(`deviceCommand`),icon:(0,T.jsx)(E,{fontSize:`small`}),handler:e=>t(`/settings/group/${e}/command`)},V={key:`share`,title:n(`sharedShare`),icon:(0,T.jsx)(D,{fontSize:`small`}),handler:e=>t(`/settings/group/${e}/share`)},H={key:`connections`,title:n(`sharedConnections`),icon:(0,T.jsx)(C,{fontSize:`small`}),handler:e=>t(`/settings/group/${e}/connections`)};return(0,T.jsxs)(o,{menu:(0,T.jsx)(x,{}),breadcrumbs:[`settingsTitle`,`settingsGroups`],children:[(0,T.jsx)(c,{keyword:P,setKeyword:F}),(0,T.jsxs)(u,{className:e.table,children:[(0,T.jsx)(l,{children:(0,T.jsxs)(_,{children:[(0,T.jsx)(d,{children:n(`sharedName`)}),(0,T.jsx)(d,{className:e.columnAction})]})}),(0,T.jsxs)(p,{children:[M.map(t=>(0,T.jsxs)(_,{children:[(0,T.jsx)(d,{children:t.name}),(0,T.jsx)(d,{className:e.columnAction,padding:`none`,children:(0,T.jsx)(y,{itemId:t.id,editPath:`/settings/group`,endpoint:`groups`,onReload:j,customActions:[H,...r?[]:[B],...!O&&!k.temporary?[V]:[]]})})]},t.id)),I&&(0,T.jsx)(b,{ref:M.length>0?z:null,columns:2,endAction:!0})]})]}),(0,T.jsx)(s,{editPath:`/settings/group`})]})};export{O as default};