import{a2 as v,r as s,a3 as D,j as e,a4 as E,a0 as k}from"./index-CULuikBf.js";import{B}from"./Breadcrumbs--TWNuJCy.js";import{B as I}from"./Button-CIw4apuU.js";function $(){const i=v.useParams(),t=v.useLoaderData(),{namespaceId:m}=t,[x,b]=s.useState(t.cursor),[u,c]=s.useState(null),[w,h]=s.useState(t.hasMore),[L,d]=s.useState(!1),[n,l]=s.useState(!1),[p,o]=s.useState(t.objects);s.useEffect(()=>{o(t.objects),b(t.cursor),h(t.hasMore),c(null),d(!1),l(!1)},[t]);const O=s.useCallback(async r=>{var f,j,g;try{r?l(!0):(d(!0),o([])),c(null);const a=await D({path:{id:m},query:{cursor:r,limit:50}}),y=((f=a.data)==null?void 0:f.result)??[];o(r?S=>[...S,...y]:y);const N=(g=(j=a.data)==null?void 0:j.result_info)==null?void 0:g.cursor;b(N??null),h(!!N)}catch(a){c(a instanceof Error?a.message:"Failed to fetch objects")}finally{d(!1),l(!1)}},[m]);function M(){x&&!n&&O(x)}return e.jsxs(e.Fragment,{children:[e.jsx(B,{icon:E,items:[e.jsx("span",{className:"flex items-center gap-1.5",children:i.className},"class-name")],title:"Durable Objects"}),e.jsxs("div",{className:"px-6 py-6",children:[u&&e.jsx("div",{className:"text-danger p-4 bg-danger/8 border border-danger/20 rounded-md mb-4",children:u}),L?e.jsx("div",{className:"text-center p-12 text-text-secondary",children:"Loading..."}):p.length===0?e.jsxs("div",{className:"text-center p-12 text-text-secondary space-y-2 flex flex-col items-center justify-center",children:[e.jsx("h2",{className:"text-2xl font-medium",children:"No Durable Objects with stored data"}),e.jsx("p",{className:"text-sm font-light",children:"Create a Durable Object with SQLite storage to see it here."})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"rounded-lg border border-border overflow-hidden",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{className:"bg-bg-secondary",children:e.jsxs("tr",{children:[e.jsx("th",{className:"text-left px-4 py-3 font-medium text-text-secondary border-b border-border",children:"Object ID"}),e.jsx("th",{className:"text-right px-4 py-3 font-medium text-text-secondary border-b border-border"})]})}),e.jsx("tbody",{children:p.map(r=>e.jsxs("tr",{className:"border-b border-border last:border-b-0 hover:bg-bg-secondary/50 transition-colors",children:[e.jsx("td",{className:"px-4 py-3 font-mono text-xs",children:r.id}),e.jsx("td",{className:"px-4 py-3 text-right",children:e.jsx(k,{className:"inline-flex items-center justify-center py-1.5 px-3 text-xs font-medium rounded-md cursor-pointer transition-colors bg-primary text-white hover:bg-primary-hover",params:{className:i.className,objectId:r.id},search:{table:void 0},to:"/do/$className/$objectId",children:"Open Studio"})})]},r.id))})]})}),w&&e.jsx("div",{className:"text-center p-4",children:e.jsx(I,{className:"inline-flex items-center justify-center py-2 px-4 text-sm font-medium rounded-md cursor-pointer transition-[background-color,transform] active:translate-y-px bg-bg-tertiary text-text border border-border hover:bg-border data-disabled:opacity-60 data-disabled:cursor-not-allowed data-disabled:active:translate-y-0",disabled:n,focusableWhenDisabled:!0,onClick:M,children:n?"Loading...":"Load More"})})]})]})]})}export{$ as component};
