import{j as e,L as m,r as l,s as y}from"./vendor-tanstack-BVzzyDEt.js";import{B as j,a as p,b as c,bz as h,a3 as u,D as v,q as b,I as w,w as N,P as k,dx as D,dy as L,dz as g,dA as S,dB as C,dC as T,dD as A,dw as _}from"./index-BJkJ93Lr.js";import{a as B}from"./use-get-artifacts-flow-task-runs-BxDyYvEa.js";import{L as f}from"./lazy-markdown-CwRqR_1U.js";import{u as R,E as I}from"./vendor-codemirror-BQuppSRL.js";import"./vendor-react-Bce9NwRC.js";import"./vendor-radix-CTAic6HB.js";import"./vendor-recharts-Mwm2qLZp.js";import"./vendor-forms-BN3tpxM2.js";import"./vendor-date-2jFo9aCm.js";const z=({artifact:s})=>{let a=e.jsx(e.Fragment,{});return s.key?a=e.jsx("div",{className:"flex items-center ",children:e.jsx(j,{children:e.jsxs(p,{children:[e.jsx(c,{className:"text-xl text-blue-700 hover:underline",children:e.jsx(m,{to:"/artifacts/key/$key",params:{key:s.key},children:s.key})}),e.jsx(h,{children:"/"}),e.jsx(c,{className:"text-xl font-bold text-foreground",children:s.id})]})})}):a=e.jsx("div",{className:"flex items-center ",children:e.jsx(j,{children:e.jsxs(p,{children:[s.flow_run&&e.jsxs(e.Fragment,{children:[e.jsx(c,{children:e.jsx(u,{variant:"bodyLarge",className:"text-blue-700 hover:underline",children:e.jsx(m,{to:"/runs/flow-run/$id",params:{id:s.flow_run_id??""},children:s.flow_run.name})})}),e.jsx(h,{children:"/"})]}),s.task_run&&e.jsxs(e.Fragment,{children:[e.jsx(c,{children:e.jsx(u,{variant:"bodyLarge",className:"text-blue-700 hover:underline",children:e.jsx(m,{to:"/runs/task-run/$id",params:{id:s.task_run_id??""},children:s.task_run.name})})}),e.jsx(h,{children:"/"})]}),e.jsx(c,{className:"text-xl font-bold text-foreground",children:s.id})]})})}),e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center justify-between",children:[a,e.jsx(v,{id:"artifacts-guide",label:"Documentation"})]}),s.description&&e.jsx("div",{className:"",children:e.jsx(u,{variant:"h2",className:"my-4 font-bold prose lg:prose-xl",children:e.jsx(f,{children:s.description})})}),e.jsx("hr",{})]})},M=({artifact:s})=>{const[a,t]=l.useState(!1),d=()=>{t(o=>!o)},n=l.useRef(null),x={highlightActiveLine:!1,foldGutter:!1,highlightActiveLineGutter:!1},{setContainer:r}=R({container:n.current,extensions:[I.lineWrapping],value:String(s.data),indentWithTab:!1,editable:!0,basicSetup:x});l.useEffect(()=>{n.current&&r(n.current)},[r]);const i=o=>{N.success("Copied to clipboard"),navigator.clipboard.writeText(o)};return e.jsxs("div",{className:"flex flex-col justify-center items-center",children:[e.jsxs(b,{"data-testid":"show-raw-data-button",variant:"outline",onClick:d,className:"my-4",children:[a?"Hide":"Show"," Raw Data"]}),e.jsx("div",{className:"rounded-md border shadow-xs focus-within:outline-hidden focus-within:ring-1 focus-within:ring-ring relative",style:{display:a?"block":"none"},ref:o=>{n.current=o},"data-testid":"raw-data-display",children:e.jsx(b,{onClick:()=>i(s.data),variant:"ghost",size:"icon",className:"absolute top-0 right-0 z-10","aria-label":"copy",children:e.jsx(w,{id:"Copy",className:"size-2"})})})]})},E=({url:s})=>e.jsxs("div",{"data-testid":s,className:"prose mt-2",children:[e.jsx("img",{"data-testid":`image-${s}`,src:s,alt:"artifact-image",className:"w-full"}),e.jsxs(u,{variant:"bodyLarge",children:["Image URL:"," ",e.jsx("a",{className:"text-blue-700 hover:underline",target:"_blank",href:s,rel:"noreferrer",children:s})]})]}),F=({markdown:s})=>e.jsx("div",{"data-testid":"markdown-display",className:"mt-4 prose",children:e.jsx(f,{children:s})}),H=({progress:s})=>e.jsxs(u,{"data-testid":"progress-display",variant:"bodyLarge",children:["Progress: ",s,"%"]}),P=({tableData:s})=>{const a=JSON.parse(s),t=Object.keys(a[0]),[d,n]=l.useState(""),x=l.useMemo(()=>a.filter(r=>Object.values(r).some(i=>String(i).toLowerCase().includes(d.toLowerCase()))),[d,a]);return e.jsxs("div",{"data-testid":"table-display",className:"mt-4",children:[e.jsx("div",{className:"flex flex-row justify-end items-center mb-2",children:e.jsx("div",{children:e.jsx(k,{placeholder:"Search",value:d,onChange:r=>n(r.target.value)})})}),e.jsx("div",{className:"rounded-md border",children:e.jsxs(D,{children:[e.jsx(L,{className:"bg-muted",children:e.jsx(g,{children:t.map(r=>e.jsx(S,{className:"py-2 text-foreground",children:r},r))})}),e.jsx(C,{children:x.map(r=>e.jsx(g,{children:t.map(i=>e.jsx(T,{children:r[i]},i))},r.id))})]})})]})},G=({artifact:s})=>{const a=l.useMemo(()=>{switch(s.type){case"markdown":case"link":return e.jsx(F,{markdown:s.data});case"image":return e.jsx(E,{url:s.data});case"progress":return e.jsx(H,{progress:s.data});case"table":return e.jsx(P,{tableData:s.data});default:return e.jsx("pre",{children:JSON.stringify(s.data,null,2)})}},[s]);return e.jsxs("div",{children:[e.jsx(z,{artifact:s}),a,e.jsx(M,{artifact:s})]})};function Y(){const{id:s}=A.useParams(),{data:a}=y(_(s)),t=B(s);return e.jsx(G,{artifact:t??a})}export{Y as component};
//# sourceMappingURL=artifact._id-Bca6_vP0.js.map
