import{i as e}from"./chunk-aKtaBQYM.js";import{Ft as t,L as n,Nt as r,vt as i}from"./mui-BgU4WrXF.js";import{l as a}from"./IconButton-oialqkv3.js";import{n as o}from"./MenuItem-BNgF7Xqv.js";import{n as s,t as c}from"./SearchHeader-CjrB_H_O.js";import{t as l}from"./TableHead-DZPVxfXH.js";import{A as u,St as d,dt as f,pt as p,st as m,vt as h,w as g,wt as _,xt as v}from"./index-bel1r0Sr.js";import{t as y}from"./CollectionActions-Be6ZPRyC.js";import{t as b}from"./TableShimmer-CBuxG-nx.js";import{n as x,t as S}from"./useSettingsStyles-Bugi6oTj.js";import{t as C}from"./Link-CzZvBT6w.js";var w=e(t(),1),T=i(),E=n((0,T.jsx)(`path`,{d:`M5 4v2h14V4zm0 10h4v6h6v-6h4l-7-7z`}),`Publish`),D=n((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=p(),i=u(`limitCommands`),O=r(e=>e.session.server.attributes.disableShare),k=r(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=f(()=>R(M.length));m(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)(_,{className:e.table,children:[(0,T.jsx)(l,{children:(0,T.jsxs)(h,{children:[(0,T.jsx)(v,{children:n(`sharedName`)}),(0,T.jsx)(v,{className:e.columnAction})]})}),(0,T.jsxs)(d,{children:[M.map(t=>(0,T.jsxs)(h,{children:[(0,T.jsx)(v,{children:t.name}),(0,T.jsx)(v,{className:e.columnAction,padding:`none`,children:(0,T.jsx)(y,{itemId:t.id,editPath:`/settings/group`,endpoint:`groups`,onReload:j,customActions:[H,...i?[]:[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};