1import{a0 as _,a2 as q,bf as Q,r as x,j as e,m as A,aa as G,b as y,B as X,dd as J,N as m,au as O}from"./main-HVf8ATPQ.js";import{a as W,b as H,c as Y,D as c}from"./data-table-pagination-BHsGIGM4.js";import{A as Z,a as ee,b as ae}from"./avatar-CNW2Ya6W.js";import{I as se}from"./input-ePyCg58M.js";import{M as le}from"./markdown-JToFVMiD.js";import{T as te,a as re,b as h,c as ne,d as ie,e as v}from"./table-YB8_VMJQ.js";import{a as oe}from"./admin-middleware-TlT-O_-X.js";import{u as de}from"./useQuery-CsEp9Bxp.js";import{b as F}from"./formatter-CT658pPs.js";import{u as ce,d as me,h as ue,f as T}from"./index-DST4Ks8I.js";import{u as xe,p as j,a as E,b as pe}from"./index-BYg7ERHY.js";import{t as ge}from"./index-CTmY_VWW.js";import{D as fe}from"./dashboard-header-D7xxC7I2.js";import"./IconSettings2-BRPuQ4OJ.js";import"./IconChevronUp-TOoROmoE.js";import"./IconSelector-6KUoE1Io.js";import"./IconEyeOff-BloCvZc6.js";import"./popover-CtyeNmb7.js";import"./index-CaxpBmri.js";import"./IconSearch-DNOQsjxP.js";import"./separator-Citf5KwQ.js";import"./IconCircleX-BlD-J07a.js";import"./select-DnajAyZX.js";import"./useValueChanged-EvXERLVL.js";import"./IconChevronLeft-DfdSrRtC.js";import"./sidebar-BL2up1jA.js";import"./sheet-DsEHVsCp.js";import"./DialogTitle-nT-rcQsU.js";const he=_({method:"GET"}).middleware([oe]).handler(q("310587378b4eb21ff09e7ff6112df9f4d2d044a07c9a58e0eeefe5aa8b681b47")),K={all:["admin-domain-lobster-history"],list:a=>[...K.all,"list",a]};function be(a,r,l,o,u,g){return de({queryKey:K.list({fallback:g,pageIndex:a,pageSize:r,search:l,sorting:o,status:u}),queryFn:()=>{const p=o[0];return he({data:{pageIndex:a,pageSize:r,search:l,sortId:p?.id,sortDesc:p?.desc??!0,status:u,fallback:g}})},placeholderData:Q})}const s=A.admin.domainLobsterHistory;function je({value:a}){return a?e.jsx("span",{children:F(new Date(a))}):e.jsx("span",{className:"text-muted-foreground",children:"-"})}function ve({item:a}){if(!a.userEmail)return e.jsx(m,{variant:"outline",children:s.anonymous});const r=(a.userName||a.userEmail).slice(0,1).toUpperCase();return e.jsxs("div",{className:"flex min-w-48 items-center gap-2",children:[e.jsxs(Z,{className:"size-8",children:[e.jsx(ee,{src:a.userImage||void 0,alt:a.userName??""}),e.jsx(ae,{children:r})]}),e.jsxs("div",{className:"flex min-w-0 flex-col",children:[e.jsx("span",{className:"truncate text-sm font-medium",children:a.userName||a.userEmail}),e.jsx("button",{type:"button",className:"truncate text-left text-muted-foreground text-xs hover:text-foreground",onClick:()=>{navigator.clipboard.writeText(a.userEmail??""),ge.success(s.emailCopied)},children:a.userEmail})]})]})}function P({fallback:a,status:r}){return r==="failed"?e.jsx(m,{variant:"destructive",children:s.status.failed}):a?e.jsx(m,{variant:"secondary",children:s.fallback.fallback}):e.jsx(m,{className:"bg-primary/10 text-primary",children:s.status.completed})}function ye({item:a}){return e.jsxs("div",{className:"flex max-w-56 flex-col gap-1",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:a.sessionId}),a.clientUserId?e.jsx("span",{className:"truncate text-muted-foreground text-xs",children:a.clientUserId}):null]})}function R({value:a}){return a?e.jsx("p",{className:"max-h-20 max-w-[28rem] overflow-hidden whitespace-pre-wrap text-sm leading-5",children:a}):e.jsx("span",{className:"text-muted-foreground",children:"-"})}function Ne({item:a}){const r=a.errorMessage||a.reply;return e.jsxs("section",{id:`conversation-details-${a.id}`,"aria-labelledby":`conversation-details-title-${a.id}`,className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3 border-b border-primary/15 bg-primary/[0.035] px-5 py-3.5",children:[e.jsx("h2",{id:`conversation-details-title-${a.id}`,className:"font-semibold text-sm",children:s.details.title}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(P,{fallback:!1,status:a.status}),a.fallback?e.jsx(m,{variant:"secondary",children:s.fallback.fallback}):null,e.jsx("span",{className:"text-muted-foreground text-xs tabular-nums",children:a.durationMs!=null?`${(a.durationMs/1e3).toFixed(1)}s`:"-"}),e.jsx("span",{className:"text-muted-foreground text-xs",children:F(new Date(a.createdAt))})]})]}),e.jsxs("dl",{className:"grid gap-x-8 gap-y-2 border-b bg-muted/20 px-5 py-3 text-xs sm:grid-cols-2 xl:grid-cols-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("dt",{className:"text-muted-foreground",children:s.details.sessionId}),e.jsx("dd",{className:"mt-0.5 break-all font-mono text-foreground",children:a.sessionId})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("dt",{className:"text-muted-foreground",children:s.details.visitorId}),e.jsx("dd",{className:"mt-0.5 break-all font-mono text-foreground",children:a.clientUserId||"-"})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("dt",{className:"text-muted-foreground",children:s.details.locale}),e.jsx("dd",{className:"mt-0.5 text-foreground",children:a.locale||"-"})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("dt",{className:"text-muted-foreground",children:s.columns.domains}),e.jsx("dd",{className:"mt-1",children:a.domains.length?e.jsx("div",{className:"flex flex-wrap gap-1",children:a.domains.map(l=>e.jsx(m,{variant:"outline",className:"font-normal",children:l},l))}):e.jsx("span",{className:"text-muted-foreground",children:"-"})})]})]}),e.jsxs("div",{className:"divide-y",children:[e.jsxs("div",{className:"grid gap-2 px-5 py-4 sm:grid-cols-[7rem_minmax(0,1fr)] sm:gap-5",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:s.details.prompt}),e.jsx("p",{className:"mt-0.5 text-muted-foreground text-xs",children:a.userName||a.userEmail||s.anonymous}),a.userName&&a.userEmail?e.jsx("p",{className:"mt-0.5 break-all text-muted-foreground text-xs",children:a.userEmail}):null]}
1),e.jsx("p",{className:"min-w-0 whitespace-pre-wrap text-sm leading-6",children:a.message})]}),e.jsxs("div",{className:"grid gap-2 px-5 py-4 sm:grid-cols-[7rem_minmax(0,1fr)] sm:gap-5",children:[e.jsxs("div",{children:[e.jsx("p",{className:y("font-medium text-sm",a.errorMessage&&"text-destructive"),children:a.errorMessage?s.details.error:s.details.reply}),e.jsx("p",{className:"mt-0.5 text-muted-foreground text-xs",children:a.agentId||s.details.agent})]}),r?a.errorMessage?e.jsx("p",{className:"min-w-0 whitespace-pre-wrap text-destructive text-sm leading-6",children:r}):e.jsx(le,{content:r,className:"prose prose-sm min-w-0 max-w-none dark:prose-invert prose-headings:mt-4 prose-headings:mb-2 prose-p:my-2 prose-p:leading-6 prose-table:my-3 prose-th:border prose-th:px-2 prose-th:py-1 prose-td:border prose-td:px-2 prose-td:py-1 prose-pre:overflow-x-auto prose-ul:my-2 prose-ol:my-2 prose-li:my-0.5"}):e.jsx("p",{className:"text-muted-foreground text-sm",children:s.details.noReply})]})]})]})}function we({domains:a}){return a.length?e.jsxs("div",{className:"flex max-w-56 flex-wrap gap-1",children:[a.slice(0,3).map(r=>e.jsx(m,{variant:"outline",className:"font-normal",children:r},r)),a.length>3?e.jsxs(m,{variant:"secondary",className:"font-normal",children:["+",a.length-3]}):null]}):e.jsx("span",{className:"text-muted-foreground",children:"-"})}function ke({value:a}){return a==null?e.jsx("span",{className:"text-muted-foreground",children:"-"}):e.jsxs("span",{className:"tabular-nums",children:[(a/1e3).toFixed(1),"s"]})}function Se({columns:a}){return e.jsx(h,{className:"h-14",children:Array.from({length:a}).map((r,l)=>e.jsx(v,{className:"py-3",children:e.jsx(O,{className:"h-4 w-24"})},l))})}function Ce(a,r){return x.useMemo(()=>[{id:"details",enableHiding:!1,enableSorting:!1,header:()=>e.jsx("span",{className:"sr-only",children:s.details.column}),cell:({row:l})=>{const o=a===l.original.id;return e.jsx(X,{type:"button",variant:"ghost",size:"icon","aria-controls":`conversation-details-${l.original.id}`,"aria-expanded":o,"aria-label":o?s.details.collapse:s.details.expand,className:y("size-11 text-muted-foreground",o&&"bg-primary/10 text-primary hover:bg-primary/15 hover:text-primary"),onClick:()=>r(l.original.id),children:e.jsx(J,{className:y("size-4 transition-transform duration-200",o&&"rotate-90")})})},minSize:52,size:52},{id:"user",accessorKey:"userEmail",enableSorting:!0,enableHiding:!0,header:({column:l})=>e.jsx(c,{column:l,label:s.columns.user}),cell:({row:l})=>e.jsx(ve,{item:l.original}),meta:{label:s.columns.user},minSize:220,size:240},{id:"session",accessorKey:"sessionId",enableSorting:!1,enableHiding:!0,header:({column:l})=>e.jsx(c,{column:l,label:s.columns.session}),cell:({row:l})=>e.jsx(ye,{item:l.original}),meta:{label:s.columns.session},minSize:190,size:220},{id:"message",accessorKey:"message",enableSorting:!1,enableHiding:!0,header:({column:l})=>e.jsx(c,{column:l,label:s.columns.message}),cell:({row:l})=>e.jsx(R,{value:l.original.message}),meta:{label:s.columns.message},minSize:280,size:340},{id:"reply",accessorKey:"reply",enableSorting:!1,enableHiding:!0,header:({column:l})=>e.jsx(c,{column:l,label:s.columns.reply}),cell:({row:l})=>e.jsx(R,{value:l.original.errorMessage||l.original.reply}),meta:{label:s.columns.reply},minSize:320,size:380},{id:"status",accessorKey:"status",enableSorting:!0,enableHiding:!0,header:({column:l})=>e.jsx(c,{column:l,label:s.columns.status}),cell:({row:l})=>e.jsx(P,{fallback:l.original.fallback,status:l.original.status}),meta:{label:s.columns.status},minSize:130,size:150},{id:"fallback",accessorKey:"fallback",enableSorting:!0,enableHiding:!0,header:({column:l})=>e.jsx(c,{column:l,label:s.columns.fallback}),cell:({row:l})=>e.jsx(m,{variant:l.original.fallback?"secondary":"outline",children:l.original.fallback?s.yes:s.no}),meta:{label:s.columns.fallback},minSize:110,size:120},{id:"domains",accessorKey:"domains",enableSorting:!1,enableHiding:!0,header:({column:l})=>e.jsx(c,{column:l,label:s.columns.domains}),cell:({row:l})=>e.jsx(we,{domains:l.original.domains}),meta:{label:s.columns.domains},minSize:180,size:220},{id:"durationMs",accessorKey:"durationMs",enableSorting:!0,enableHiding:!0,header:({column:l})=>e.jsx(c,{column:l,label:s.columns.duration}),cell:({row:l})=>e.jsx(ke,{value:l.original.durationMs}),meta:{label:s.columns.duration},minSize:110,size:120},{id:"createdAt",accessorKey:"createdAt",enableSorting:!0,enableHiding:!0,header:({column:l})=>e.jsx(c,{column:l,label:s.columns.createdAt}),cell:({row:l})=>e.jsx(je,{value:l.original.createdAt}),meta:{label:s.columns.createdAt},minSize:170,size:180}],[a,r])}function De(){const[,a]=x.useTransition(),[r,l]=x.useState(null),[o,u]=xe({fallback:j.withDefault("all"),page:pe.withDefault(0),search:j.withDefault(""),size:E.withDefault(10),sortDesc:E.withDefault(1),sortId:j.withDefault("
1createdAt"),status:j.withDefault("all")},{startTransition:a,history:"replace"}),g=["createdAt","user","status","fallback","durationMs"],{fallback:p,page:N,search:w,size:f,sortDesc:I,sortId:k,status:b}=o,S=x.useMemo(()=>[{id:g.includes(k)?k:"createdAt",desc:!!I}],[I,k]),C=be(N,f,w,S,b,p),L=x.useCallback(t=>{l(n=>n===t?null:t)},[]),V=Ce(r,L),[B,$]=x.useState({domains:!1,fallback:!1}),M=x.useMemo(()=>[b!=="all"&&{id:"status",value:[b]},p!=="all"&&{id:"fallback",value:[p]}].filter(Boolean),[p,b]),d=ce({data:C.data?.items??[],columns:V,pageCount:Math.ceil((C.data?.total??0)/f)||1,state:{columnFilters:M,columnVisibility:B,pagination:{pageIndex:N,pageSize:f},sorting:S},onColumnFiltersChange:t=>{const n=typeof t=="function"?t(M):t,i=D=>{const z=n.find(U=>U.id===D);return Array.isArray(z?.value)?z.value[0]??"":z?.value??""};u({fallback:i("fallback")||"all",page:0,status:i("status")||"all"})},onColumnVisibilityChange:$,onPaginationChange:t=>{const n=typeof t=="function"?t({pageIndex:N,pageSize:f}):t;u({page:n.pageIndex,size:n.pageSize})},onSortingChange:t=>{const i=(typeof t=="function"?t(S):t)[0],D=g.includes(i?.id??"")?i?.id??"createdAt":"createdAt";u({page:0,sortDesc:i?i.desc?1:0:1,sortId:D})},getCoreRowModel:ue(),getPaginationRowModel:me(),manualFiltering:!0,manualPagination:!0,manualSorting:!0,enableMultiSort:!1});return e.jsxs("div",{className:"w-full space-y-4",children:[e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("h1",{className:"text-xl font-semibold tracking-normal",children:s.title}),e.jsx("p",{className:"max-w-3xl text-muted-foreground text-sm leading-6",children:s.description})]}),e.jsx(W,{table:d,children:e.jsxs("div",{className:"flex flex-1 flex-wrap items-center gap-2",children:[e.jsxs("div",{className:"relative",children:[e.jsx(se,{placeholder:s.search,value:w,onChange:t=>{u({page:0,search:t.target.value})},className:"h-8 w-[min(360px,calc(100vw-3rem))] pr-8"}),w.length>0?e.jsx("button",{type:"button","aria-label":s.clearSearch,className:"absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground transition-colors hover:text-foreground",onClick:()=>{u({page:0,search:""})},children:e.jsx(G,{className:"size-3.5"})}):null]}),e.jsx(H,{column:d.getColumn("status"),title:s.columns.status,options:[{label:s.filters.all,value:"all"},{label:s.status.completed,value:"completed"},{label:s.status.failed,value:"failed"}]}),e.jsx(H,{column:d.getColumn("fallback"),title:s.columns.fallback,options:[{label:s.filters.all,value:"all"},{label:s.fallback.primary,value:"primary"},{label:s.fallback.fallback,value:"fallback"}]})]})}),e.jsxs("div",{className:"relative flex flex-col gap-4 overflow-auto",children:[e.jsx("div",{className:"overflow-hidden rounded-lg border",children:e.jsxs(te,{children:[e.jsx(re,{className:"bg-muted sticky top-0 z-10",children:d.getHeaderGroups().map(t=>e.jsx(h,{children:t.headers.map(n=>e.jsx(ne,{children:n.isPlaceholder?null:T(n.column.columnDef.header,n.getContext())},n.id))},t.id))}),e.jsx(ie,{children:C.isLoading?Array.from({length:f}).map((t,n)=>e.jsx(Se,{columns:d.getVisibleLeafColumns().length},n)):d.getRowModel().rows?.length?d.getRowModel().rows.map(t=>{const n=r===t.original.id;return e.jsxs(x.Fragment,{children:[e.jsx(h,{"data-state":n?"selected":void 0,className:"h-14 align-top data-[state=selected]:bg-primary/[0.025]",children:t.getVisibleCells().map(i=>e.jsx(v,{className:y("py-3",i.column.id==="details"&&"px-1 py-1.5"),children:T(i.column.columnDef.cell,i.getContext())},i.id))}),n?e.jsx(h,{className:"border-primary/15 bg-background hover:bg-background",children:e.jsx(v,{colSpan:t.getVisibleCells().length,className:"p-0 whitespace-normal",children:e.jsx(Ne,{item:t.original})})},`${t.id}-details`):null]},t.id)}):e.jsx(h,{children:e.jsx(v,{colSpan:d.getVisibleLeafColumns().length,className:"h-24 text-center",children:s.noResults})})})]})}),e.jsx(Y,{table:d,className:"px-0"})]})]})}const ze=A.admin.domainLobsterHistory;function la(){const a=[{label:A.admin.title,isCurrentPage:!1},{label:ze.title,isCurrentPage:!0}];return e.jsxs(e.Fragment,{children:[e.jsx(fe,{breadcrumbs:a}),e.jsx("div",{className:"flex flex-1 flex-col",children:e.jsx("div",{className:"@container/main flex flex-1 flex-col gap-2",children:e.jsx("div",{className:"flex flex-col gap-4 py-4 lg:gap-6 lg:py-6",children:e.jsx("div",{className:"px-4 lg:px-6",children:e.jsx(De,{})})})})})]})}export{la as component};
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.