1import{r,j as e,a as f,X as ae,as as re,y as ie,U as V,F as ne,ap as le,ao as T,B as m,ar as C,ah as w,d as U}from"./index-B9xblx1X.js";import{A as de}from"./AdminBadge-BOwKRD__.js";import{C as oe}from"./ConfirmDestructiveDialog-B1PIECrX.js";import{S as k}from"./StatusBadge-CJs5Fb83.js";import{I as L}from"./input-BgkJCVH0.js";import{S as D,a as z,b as I,d as P,e as a}from"./select-CUcPkDqG.js";import{S as R}from"./skeleton-DfJRheVQ.js";import{R as ce,O as Q,C as K,a as me,b as H,D as X,P as xe}from"./index-CaFA2jif.js";import{S as ue}from"./search-HVOvfHW_.js";import{E as pe}from"./external-link-BKp7hCh4.js";import"./badge-4Ub-F2rG.js";import"./alert-dialog-CqOkVI1E.js";import"./label-pqjvqnDT.js";import"./circle-check-Bam9U-dU.js";import"./triangle-alert-D0ZXp46o.js";import"./index-ByduhlRr.js";import"./Combination-R_zhYWsV.js";import"./index-D45U-z8e.js";import"./index-fou4DczH.js";import"./chevron-down-CkmF6cMV.js";import"./check-BUi6PNNz.js";const he=ce,je=xe,$=r.forwardRef(({className:n,...i},d)=>e.jsx(Q,{className:f("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",n),...i,ref:d}));$.displayName=Q.displayName;const fe=re("fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:duration-500",{variants:{side:{top:"inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",bottom:"inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",left:"inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm",right:"inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm"}},defaultVariants:{side:"right"}}),G=r.forwardRef(({side:n="right",className:i,children:d,...p},N)=>e.jsxs(je,{children:[e.jsx($,{}),e.jsxs(K,{ref:N,className:f(fe({side:n}),i),...p,children:[d,e.jsxs(me,{className:"absolute right-4 top-4 roun
1ded-sm opacity-70 ring-offset-background transition-opacity data-[state=open]:bg-secondary hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none",children:[e.jsx(ae,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));G.displayName=K.displayName;const J=({className:n,...i})=>e.jsx("div",{className:f("flex flex-col space-y-2 text-center sm:text-left",n),...i});J.displayName="SheetHeader";const W=r.forwardRef(({className:n,...i},d)=>e.jsx(H,{ref:d,className:f("text-lg font-semibold text-foreground",n),...i}));W.displayName=H.displayName;const Y=r.forwardRef(({className:n,...i},d)=>e.jsx(X,{ref:d,className:f("text-sm text-muted-foreground",n),...i}));Y.displayName=X.displayName;function Me(){var E,F,M;const n=ie(),[i,d]=r.useState(""),[p,N]=r.useState("all"),[v,Z]=r.useState(""),[y,ee]=r.useState("all"),[S,te]=r.useState("created_desc"),[h,x]=r.useState(1),[u,g]=r.useState(null),[c,_]=r.useState(null),[O,se]=r.useState(null),q=r.useMemo(()=>({search:i.trim()||void 0,status:p,domain:v.trim()||void 0,plan:y,sort:S,page:h,pageSize:25}),[i,p,v,y,S,h]),l=V({queryKey:["admin","items",q],queryFn:()=>w("items.list",q),placeholderData:t=>t}),A=V({queryKey:["admin","item",u],enabled:!!u,queryFn:()=>w("items.get",{itemId:u})}),j=ne({mutationFn:t=>w(t.action,t.body||{}),onSuccess:async(t,o)=>{U.success("Done"),await n.invalidateQueries({queryKey:["admin","items"]}),u&&await n.invalidateQueries({queryKey:["admin","item",u]}),o.action==="items.delete"&&(_(null),g(null))},onError:t=>U.error(t.message)}),B=Math.max(1,Math.ceil((((E=l.data)==null?void 0:E.total)||0)/25)),s=(F=A.data)==null?void 0:F.item;return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-bold tracking-tight sm:text-2xl",children:"Stored items"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Metadata-first investigation. Archived content access is audited."})]}),e.jsxs("div",{className:"grid gap-2 rounded-xl border border-border/60 bg-background p-3 md:grid-cols-2 xl:grid-cols-5",children:[e.jsxs("div",{className:"relative xl:col-span-2",children:[e.jsx(ue,{className:"absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground"}),e.jsx(L,{value:i,onChange:t=>{x(1),d(t.target.value)},placeholder:"Title, URL, domain, owner email",className:"h-8 pl-8 text-sm"})]}),e.jsxs(D,{value:p,onValueChange:t=>{x(1),N(t)},children:[e.jsx(z,{className:"h-8 text-xs",children:e.jsx(I,{placeholder:"Status"})}),e.jsxs(P,{children:[e.jsx(a,{value:"all",children:"All statuses"}),e.jsx(a,{value:"queued",children:"Queued"}),e.jsx(a,{value:"parsing",children:"Processing"}),e.jsx(a,{value:"processing",children:"Item processing"}),e.jsx(a,{value:"archived",children:"Completed"}),e.jsx(a,{value:"failed",children:"Failed"}),e.jsx(a,{value:"metadata_only",children:"Unsupported / metadata"}),e.jsx(a,{value:"original_unavailable",children:"Original unavailable"})]})]}),e.jsx(L,{value:v,onChange:t=>{x(1),Z(t.target.value)},placeholder:"Domain filter",className:"h-8 text-sm"}),e.jsxs(D,{value:y,onValueChange:t=>{x(1),ee(t)},children:[e.jsx(z,{className:"h-8 text-xs",children:e.jsx(I,{placeholder:"Plan"})}),e.jsxs(P,{children:[e.jsx(a,{value:"all",children:"All plans"}),e.jsx(a,{value:"free",children:"Free"}),e.jsx(a,{value:"pro",children:"Pro"})]})]}),e.jsxs(D,{value:S,onValueChange:te,children:[e.jsx(z,{className:"h-8 text-xs",children:e.jsx(I,{placeholder:"Sort"})}),e.jsxs(P,{children:[e.jsx(a,{value:"created_desc",children:"Created â"}),e.jsx(a,{value:"created_asc",children:"Created â"}),e.jsx(a,{value:"size_desc",children:"Size â"}),e.jsx(a,{value:"size_asc",children:"Size â"})]})]})]}),l.isLoading&&!l.data?e.jsx("div",{className:"space-y-2",children:Array.from({length:6}).map((t,o)=>e.jsx(R,{className:"h-14"},o))}):l.error?e.jsx("div",{className:"rounded-lg border border-destructive/30 bg-destructive/5 p-4 text-sm text-destructive",children:l.error instanceof Error?l.error.message:"Failed to load items"}):(M=l.data)!=null&&M.items.length?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"hidden overflow-x-auto rounded-xl border border-border/60 bg-background md:block",children:e.jsxs("table",{className:"w-full min-w-[1000px] text-left text-sm",children:[e.jsx("thead",{className:"border-b border-border/60 bg-muted/40 text-[11px] uppercase tracking-wide text-muted-foreground",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-3 py-2.5 font-medium",children:"Title"}),e.jsx("th",{className:"px-3 py-2.5 font-medium",children:"Domain"}),e.jsx("th",{className:"px-3 py-2.5 font-medium",children:"Owner"}),e.jsx("th",{className:"px-3 py-2.5 font-medium",children:"Status"}),e.jsx("th",{className:"px-3 py-2.5 font-medium",children:"Created"}),e.jsx("th",{className:"px-3 py-2.5 font-medium",children:"Type"}),e.jsx("th",{className:"px-3 py-2.5 font-medium",children:"Size"}),e.jsx("th",{className:"px-3 py-2.5 font-medium",children:"Shelf"})]})}),e.jsx("tbody",{children:l.data.items.map(t=>e.jsxs("tr",{className:"cursor-pointer border-b border-border/40 hover:bg-accent/40",onClick:()=>g(t.id),children:[e.jsxs("td",{className:"px-3 py-2.5",children:[e.jsx("p",{className:"max-w-[240px] truncate font-medium",children:t.title||"Untitled"}),t.error_message&&e.jsx("p",{className:"max-w-[240px] truncate text-[11px] text-destructive",children:t.error_message})]}),e.jsx("td",{className:"px-3 py-2.5 text-xs",children:t.source_domain||"â"}),e.jsx("td",{className:"px-3 py-2.5 text-xs",children:t.owner_email}),e.jsx("td",{className:"px-3 py-2.5",children:e.jsx(k,{status:t.job_status||t.capture_status})}),e.jsx("td",{className:"px-3 py-2.5 text-xs",children:le(t.created_at)}),e.jsx("td",{className:"px-3 py-2.5 text-xs capitalize",children:t.content_type}),e.jsx("td",{className:"px-3 py-2.5 text-xs",children:T(t.storage_bytes)}),e.jsx("td",{className:"px-3 py-2.5 text-xs",children:t.collection_name||"â"})]},t.id))})]})}),e.jsx("div",{className:"space-y-2 md:hidden",children:l.data.items.map(t=>e.jsxs("button",{type:"button",onClick:()=>g(t.id),className:"block w-full rounded-xl border border-border/60 bg-background p-3 text-left",children:[e.jsx("p",{className:"font-medium",children:t.title||"Untitled"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[t.source_domain," · ",t.owner_email]}),e.jsx("div",{className:"mt-2",children:e.jsx(k,{status:t.job_status||t.capture_status})})]},t.id))}),e.jsxs("div",{className:"flex items-center justify-between gap-2 text-sm",children:[e.jsxs("p",{className:"text-muted-foreground",children:["Page ",h," of ",B]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(m,{variant:"outline",size:"sm",disabled:h<=1,onClick:()=>x(t=>t-1),children:"Previous"}),e.jsx(m,{variant:"outline",size:"sm",disabled:h>=B,onClick:()=>x(t=>t+1),children:"Next"})]})]})]}):e.jsx("div",{className:"rounded-xl border border-dashed border-border p-10 text-center text-sm text-muted-foreground",children:"No items match these filters."}),e.jsx(he,{open:!!u,onOpenChange:t=>!t&&g(null),children:e.jsxs(G,{className:"w-full overflow-y-auto sm:max-w-lg",children:[e.jsxs(J,{children:[e.jsx(W,{children:(s==null?void 0:s.title)||"Item detail"}),e.jsx(Y,{children:"Metadata only by default. Content views are audited."})]}),A.isLoading||!s?e.jsxs("div",{className:"mt-4 space-y-2",children:[e.jsx(R,{className:"h-20"}),e.jsx(R,{className:"h-20"})]}):e.jsxs("div",{className:"mt-4 space-y-4 text-sm",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("p",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Owner:"})," ",s.owner.email," (",s.owner.plan,")"]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Domain:"})," ",s.source_domain||"â"]}
1),e.jsxs("p",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Type:"})," ",s.type]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Status:"})," ",s.status]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Created:"})," ",C(s.created_at)]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Updated:"})," ",C(s.updated_at)]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Snapshot:"})," ",s.snapshot?T(s.snapshot.size_bytes):"â"]}),s.error_message&&e.jsx("p",{className:"rounded-md bg-destructive/5 p-2 text-destructive",children:s.error_message})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[s.url&&e.jsx(m,{variant:"outline",size:"sm",asChild:!0,children:e.jsxs("a",{href:s.url,target:"_blank",rel:"noreferrer",children:["Open original ",e.jsx(pe,{className:"ml-1 h-3.5 w-3.5"})]})}),e.jsx(m,{variant:"outline",size:"sm",onClick:()=>j.mutate({action:"items.retry",body:{itemId:s.id}}),children:"Retry capture"}),e.jsx(m,{variant:"outline",size:"sm",onClick:()=>j.mutate({action:"items.markInvestigation",body:{itemId:s.id}}),children:"Mark investigation"}),e.jsx(m,{variant:"outline",size:"sm",onClick:()=>j.mutate({action:"items.viewContent",body:{itemId:s.id,confirm:!0}},{onSuccess:t=>{var b;const o=(b=t.content)==null?void 0:b.textExcerpt;se(o||"(empty)")}}),children:"View text excerpt"}),e.jsx(m,{variant:"destructive",size:"sm",onClick:()=>{var o;const t=((o=l.data)==null?void 0:o.items.find(b=>b.id===s.id))||null;_(t)},children:"Delete item"})]}),O&&e.jsxs("div",{className:"rounded-md border border-warning/30 bg-warning/5 p-3",children:[e.jsx("div",{className:"mb-1 flex items-center gap-2",children:e.jsx(de,{label:"Audited content access",tone:"warning"})}),e.jsx("pre",{className:"max-h-64 overflow-auto whitespace-pre-wrap text-xs",children:O})]}),e.jsxs("div",{children:[e.jsx("p",{className:"mb-2 text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Retry history"}),e.jsx("div",{className:"space-y-2",children:(s.jobs||[]).map(t=>e.jsxs("div",{className:"rounded-md border border-border/50 px-2.5 py-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx(k,{status:t.status}),e.jsxs("span",{className:"text-[11px] text-muted-foreground",children:["attempts ",t.attempt_count]})]}),e.jsxs("p",{className:"mt-1 text-[11px] text-muted-foreground",children:[C(t.created_at),t.duration_ms!=null?` · ${t.duration_ms}ms`:""]}),t.error_message&&e.jsx("p",{className:"mt-1 text-xs text-destructive",children:t.error_message})]},t.id))})]})]})]})}),e.jsx(oe,{open:!!c,onOpenChange:t=>!t&&_(null),title:"Delete stored item",description:"Deletes this archive item for the owner. Type the owner email to confirm.",confirmEmail:c==null?void 0:c.owner_email,loading:j.isPending,confirmLabel:"Delete item",onConfirm:t=>j.mutate({action:"items.delete",body:{itemId:c==null?void 0:c.id,confirmEmail:t}})})]})}export{Me as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.