import{r as c,j as e,E as h}from"./vendor-tanstack-DE4ALVGD.js";import{U as j,V as b,S as v,a as S,b as A,c as C,e as N,I as x,B as E,g as T,h as k,D as y,E as I,t as D,v as M,w as V,x as w,ax as L,bw as p,bx as B,by as R}from"./index-CNL5pSma.js";import{T as _,a as f,A as G}from"./toggle-group-Cj8bStbF.js";import{u as Q}from"./use-debounce-callback-_1tAtOwa.js";import"./vendor-react-HBv6Kpyp.js";import"./vendor-radix-K8EF6rBE.js";import"./vendor-recharts-B3wzJa9e.js";import"./vendor-forms-BvpM0AtX.js";import"./vendor-date-Bck8LDfw.js";import"./lazy-markdown-Ds39cUgX.js";const F=[{value:"all",label:"All Types"},{value:"markdown",label:"Markdown"},{value:"progress",label:"Progress"},{value:"image",label:"Image"},{value:"table",label:"Table"}],P=({filters:t,onFilterChange:s,totalCount:l,displayMode:d,setDisplayMode:i})=>{const r=c.useCallback(a=>{s([...t.filter(u=>u.id!=="name"),{id:"name",label:"Name",value:a}])},[t,s]),o=c.useCallback(a=>{s([...t.filter(u=>u.id!=="type"),{id:"type",label:"Type",value:a}])},[t,s]),m=c.useMemo(()=>t.find(a=>a.id==="type")?.value,[t]),n=c.useMemo(()=>t.find(a=>a.id==="name")?.value,[t]);return e.jsxs("div",{"data-testid":"artifact-filter",className:"flex justify-between items-center",children:[e.jsx("div",{children:e.jsxs("p",{className:"text-base text-sm text-muted-foreground",children:[l," ",j(l,"artifact")]})}),e.jsxs("div",{className:"flex gap-4",children:[e.jsx(b,{"data-testid":"search-input",defaultValue:n,placeholder:"Search artifacts",onChange:a=>r(a.target.value)}),e.jsxs("div",{className:"flex gap-4",children:[e.jsxs(v,{"data-testid":"type-select",value:m,onValueChange:o,children:[e.jsx(S,{"aria-label":"Artifact type",children:e.jsx(A,{placeholder:"Type"})}),e.jsx(C,{children:F.map(({value:a,label:u})=>e.jsx(N,{value:a,children:u},a))})]}),e.jsx("div",{children:e.jsxs(_,{type:"single",defaultValue:d,onValueChange:a=>i(a),children:[e.jsx(f,{"data-testid":"grid-layout",value:"grid",children:e.jsx(x,{id:"LayoutGrid"})}),e.jsx(f,{"data-testid":"list-layout",value:"list",children:e.jsx(x,{id:"AlignJustify"})})]})})]})]})]})},q=()=>e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(E,{children:e.jsx(T,{children:e.jsx(k,{className:"text-xl font-semibold",children:"Artifacts"})})})}),e.jsx(y,{id:"artifacts-guide",label:"Documentation"})]}),z=()=>e.jsxs(I,{children:[e.jsx("div",{className:"flex items-center gap-3",children:e.jsx(D,{id:"Image"})}),e.jsx(M,{children:"Create an artifact to get started"}),e.jsx(V,{children:"Artifacts are byproducts of your runs; they can be anything from a markdown string to a table."}),e.jsx(w,{children:e.jsx(y,{id:"artifacts-guide"})})]}),H=({filters:t,onFilterChange:s,artifactsList:l,artifactsCount:d})=>{const[i,r]=L("artifacts-grid-style","grid"),o=c.useMemo(()=>i==="grid"?"grid grid-cols-1 lg:grid-cols-2 xl:grid-cols-3 gap-4":"grid-cols-1",[i]),m=c.useMemo(()=>l.reduce((n,a)=>(n.find(u=>u.key===a.key)||n.push(a),n),[]),[l]);return e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx(q,{}),e.jsx(P,{filters:t,onFilterChange:s,totalCount:d,setDisplayMode:r,displayMode:i}),m.length===0?e.jsx(z,{}):e.jsx("div",{className:o,children:m.map(n=>e.jsx(G,{artifact:n},n.id))})]})},g=t=>({artifacts:{operator:"and_",type:{any_:t?.type&&t?.type!=="all"?[t.type]:void 0},key:{like_:t?.name??""}},sort:"CREATED_DESC",offset:0}),J=()=>{const t=p.useSearch(),s=p.useNavigate(),l=c.useMemo(()=>[{id:"type",label:"Type",value:t.type??"all"},{id:"name",label:"Name",value:t.name}],[t.type,t.name]),d=Q(c.useCallback(i=>{i&&s({to:".",search:()=>i.filter(r=>r.value).reduce((r,o)=>(o.value&&(r[o.id]=o.value),r),{}),replace:!0})},[s]),400);return{filters:l,onFilterChange:d}};function ae(){const t=p.useSearch(),{filters:s,onFilterChange:l}=J(),[{data:d},{data:i}]=h({queries:[B(g(t)),R(g(t))]});return e.jsx(H,{filters:s,onFilterChange:l,artifactsCount:d,artifactsList:i})}export{ae as component};
//# sourceMappingURL=index-BZnnVKhE.js.map
