import{o as e}from"./rolldown-runtime-C_s2cVnS.js";import{Ir as t}from"./i18n-CsN8OUP9.js";import{h as n,m as r,n as i}from"./vendor-react-nmZsNlRz.js";import{t as a}from"./utils-BRwGVQJx.js";import"./chat-runtime-Ba5_U-jf.js";import{n as o}from"./code-card-BZMbZVjT.js";import{t as s}from"./copy-button-B5vL0GU1.js";var c=i(),l=e(n(),1),u=[];function d(e,t){let n=(0,c.c)(5),r;n[0]===e?r=n[1]:(r=t=>e.listen(t),n[0]=e,n[1]=r);let i;return n[2]!==t||n[3]!==e?(i=()=>t?e.get()[t]??u:u,n[2]=t,n[3]=e,n[4]=i):i=n[4],(0,l.useSyncExternalStore)(r,i)}function f(e,t){let n=(0,l.useRef)(t);n.current=t;let r=(0,l.useCallback)(t=>e.listen(t),[e]);return(0,l.useSyncExternalStore)(r,()=>n.current(e.get()))}var p=8,m=3e5,h=t({});function g(e){h.set(_({...h.get(),[e.name]:{status:e,updatedAt:Date.now()}}))}function _(e){let t=Date.now();return Object.fromEntries(Object.entries(e).filter(([,e])=>e.status.running||t-e.updatedAt<=m).sort(([,e],[,t])=>t.updatedAt-e.updatedAt).slice(0,p))}var v=t(null);function y(e){return b(!1),new Promise(t=>{v.set({...e,resolve:t})})}function b(e){let t=v.get();t&&(v.set(null),t.resolve(e))}var x=e(r(),1);function S(e){let t=(0,c.c)(15),{className:n,emptyLabel:r,lines:i}=e,u=(0,l.useRef)(null),d=(0,l.useRef)(!0),f;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(f=()=>{let e=u.current;e&&d.current&&(e.scrollTop=e.scrollHeight)},t[0]=f):f=t[0];let p;t[1]===i?p=t[2]:(p=[i],t[1]=i,t[2]=p),(0,l.useEffect)(f,p);let m;t[3]===n?m=t[4]:(m=a(`group/logs relative h-full min-h-0`,n),t[3]=n,t[4]=m);let h;t[5]===i?h=t[6]:(h=(0,x.jsx)(s,{appearance:`inline`,className:`absolute right-2.5 top-1.5 z-10 h-5 gap-0 rounded-md px-1 opacity-5 transition-opacity group-hover/logs:opacity-100 hover:opacity-100 focus-visible:opacity-100`,iconClassName:`size-3`,showLabel:!1,text:()=>(i??[]).join(`
`)}),t[5]=i,t[6]=h);let g;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(g=e=>{let t=e.currentTarget;d.current=t.scrollHeight-t.scrollTop-t.clientHeight<24},t[7]=g):g=t[7];let _;t[8]!==r||t[9]!==i?(_=(0,x.jsx)(`div`,{className:`h-full min-h-0 overflow-y-auto [scrollbar-gutter:stable]`,"data-selectable-text":`true`,onScroll:g,ref:u,children:i===null||i.length===0?(0,x.jsx)(`p`,{className:`px-2 py-1.5 font-mono text-[0.7rem] leading-relaxed text-muted-foreground/50`,children:i===null?`…`:r}):(0,x.jsx)(o,{children:(0,x.jsx)(`pre`,{className:`whitespace-pre-wrap break-words`,children:i.map(C)})})}),t[8]=r,t[9]=i,t[10]=_):_=t[10];let v;return t[11]!==m||t[12]!==h||t[13]!==_?(v=(0,x.jsxs)(`div`,{className:m,children:[h,_]}),t[11]=m,t[12]=h,t[13]=_,t[14]=v):v=t[14],v}function C(e,t){return(0,x.jsx)(`span`,{className:a(`block`,e.startsWith(`=====`)&&`mt-1 text-(--ui-text-tertiary)`),children:e},t)}export{g as a,b as i,v as n,d as o,y as r,f as s,S as t};