import{i as e}from"./chunk-aKtaBQYM.js";import{Vt as t,wt as n}from"./mui-B6lh3XSP.js";import{n as r}from"./MenuItem-HQNtf0LG.js";import{n as i,t as a}from"./SearchHeader-CmohWzoP.js";import{t as o}from"./TableHead-_KJlbpnj.js";import{At as s,Dt as c,Ot as l,T as u,_t as d,pt as f,w as p,wt as m,yt as h}from"./index-KVuxnkWj.js";import{t as g}from"./CollectionActions-CDxOJIb6.js";import{t as _}from"./TableShimmer-f7Cf4NTV.js";import{n as v,t as y}from"./useSettingsStyles-X3caKosH.js";var b=e(t(),1),x=n(),S=()=>{let{classes:e}=y(),t=h(),[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=u(),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=d(()=>A(C.length));return f(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)(s,{className:e.table,children:[(0,x.jsx)(o,{children:(0,x.jsxs)(m,{children:[(0,x.jsx)(c,{children:t(`sharedDescription`)}),(0,x.jsx)(c,{children:t(`sharedAttribute`)}),(0,x.jsx)(c,{children:t(`sharedExpression`)}),(0,x.jsx)(c,{children:t(`sharedType`)}),k&&(0,x.jsx)(c,{className:e.columnAction})]})}),(0,x.jsxs)(l,{children:[C.map(t=>(0,x.jsxs)(m,{children:[(0,x.jsx)(c,{children:t.description}),(0,x.jsx)(c,{children:t.attribute}),(0,x.jsx)(c,{children:t.expression}),(0,x.jsx)(c,{children:t.type}),k&&(0,x.jsx)(c,{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};