import{i as e}from"./chunk-aKtaBQYM.js";import{Ft as t,vt as n}from"./mui-BgU4WrXF.js";import{n as r}from"./MenuItem-BNgF7Xqv.js";import{n as i,t as a}from"./SearchHeader-CjrB_H_O.js";import{t as o}from"./TableHead-DZPVxfXH.js";import{D as s,St as c,dt as l,pt as u,st as d,vt as f,w as p,wt as m,xt as h}from"./index-bel1r0Sr.js";import{t as g}from"./CollectionActions-Be6ZPRyC.js";import{t as _}from"./TableShimmer-CBuxG-nx.js";import{n as v,t as y}from"./useSettingsStyles-Bugi6oTj.js";var b=e(t(),1),x=n(),S=()=>{let{classes:e}=y(),t=u(),[n,S]=(0,b.useReducer)(e=>e+1,0),[C,w]=(0,b.useState)([]),[T,E]=(0,b.useState)(``),[D,O]=(0,b.useState)(!0),k=s(),A=(0,b.useCallback)(async(e,t)=>{let n=new URLSearchParams({limit:50,offset:e});T&&n.append(`keyword`,T);let r=await(await p(`/api/attributes/computed?${n.toString()}`,{signal:t})).json();w(t=>e?[...t,...r]:r),O(r.length>=50)},[T]),j=l(()=>A(C.length));return d(async({signal:e})=>{w([]),await A(0,e)},[n,A]),(0,x.jsxs)(r,{menu:(0,x.jsx)(v,{}),breadcrumbs:[`settingsTitle`,`sharedComputedAttributes`],children:[(0,x.jsx)(a,{keyword:T,setKeyword:E}),(0,x.jsxs)(m,{className:e.table,children:[(0,x.jsx)(o,{children:(0,x.jsxs)(f,{children:[(0,x.jsx)(h,{children:t(`sharedDescription`)}),(0,x.jsx)(h,{children:t(`sharedAttribute`)}),(0,x.jsx)(h,{children:t(`sharedExpression`)}),(0,x.jsx)(h,{children:t(`sharedType`)}),k&&(0,x.jsx)(h,{className:e.columnAction})]})}),(0,x.jsxs)(c,{children:[C.map(t=>(0,x.jsxs)(f,{children:[(0,x.jsx)(h,{children:t.description}),(0,x.jsx)(h,{children:t.attribute}),(0,x.jsx)(h,{children:t.expression}),(0,x.jsx)(h,{children:t.type}),k&&(0,x.jsx)(h,{className:e.columnAction,padding:`none`,children:(0,x.jsx)(g,{itemId:t.id,editPath:`/settings/attribute`,endpoint:`attributes/computed`,onReload:S})})]},t.id)),D&&(0,x.jsx)(_,{ref:C.length>0?j:null,columns:k?5:4,endAction:k})]})]}),(0,x.jsx)(i,{editPath:`/settings/attribute`,disabled:!k})]})};export{S as default};