1import{l as h,r as d,j as t}from"./index-CCG9MGz0.js";import{as as g}from"./companyBrainApi-CrDzGhub.js";import{C as b}from"./circle-check-DdEYu8Ii.js";import{F as j}from"./file-text-Bb28mgmh.js";import{D as N}from"./download-CSYECM8Z.js";import"./serverApi-QuCfAnKQ.js";import"./types-BC6WDqr1.js";import"./createLucideIcon-BNie9-yg.js";function k(n,s=96){let r=String(n||"").replace(/[*_`#>]+/g,"").replace(/\s+/g," ").trim();return r=r.replace(/^(done|result|step\s*\d*|update|status|note)\s*[:\-â]\s*/i,""),r=r.replace(/^(i(?:'ve| have| am| was| will)?|i'll|okay|ok|alright|sure|great|now|so|then|next|let me)\s+(successfully\s+)?/i,""),r=(r.split(new RegExp("(?<=[.!?])\\s+"))[0]||r).replace(/[.]+$/,"").trim(),r?(r=r.charAt(0).toUpperCase()+r.slice(1),r.length<=s?r:`${r.slice(0,s-1).trim()}â¦`):""}function v(n){const s=typeof n=="number"?n:Date.parse(String(n||""));if(!s||Number.isNaN(s))return"";const r=Math.max(0,Math.floor((Date.now()-s)/1e3));if(r<60)return"just now";const l=Math.floor(r/60);if(l<60)return`${l} min${l===1?"":"s"} ago`;const i=Math.floor(l/60);if(i<24)return`${i} hour${i===1?"":"s"} ago`;const o=Math.floor(i/24);return`${o} day${o===1?"":"s"} ago`}function w(n,s){try{const r=String(n||"file.txt").split("/").pop()||"file.txt",l=new Blob([s??""],{type:"text/plain;charset=utf-8"}),i=URL.createObjectURL(l),o=document.createElement("a");o.href=i,o.download=r,document.body.appendChild(o),o.click(),o.remove(),setTimeout(()=>URL.revokeObjectURL(i),1e3)}catch(r){console.error("download failed:",r)}}function U(){const{token:n}=h(),[s,r]=d.useState(null),[l,i]=d.useState(null),[o,x]=d.useState(!0);d.useEffect(()=>{let e=!0;return x(!0),g(String(n||"")).then(a=>{e&&r(a)}).catch(a=>{e&&i((a==null?void 0:a.message)||"Replay unavailable")}).finally(()=>{e&&x(!1)}),()=>{e=!1}},[n]);const c=Array.isArray(s==null?void 0:s.plan)?s.plan:[],u=Array.isArray(s==null?void 0:s.logs)?s.logs:[],p=(Array.isArray(s==null?void 0:s.files)?s.files:[]).filter(e=>(e==null?void 0:e.path)&&(e==null?void 0:e.content)),m=u.map(e=>k(e!=null&&e.detail?`${e.message} ${e.detail}`:(e==null?void 0:e.message)||"")).filter(Boolean).slice(-30);return t.jsx("div",{className:"min-h-screen bg-[#f4efe4] text-[#171717]",children:t.jsxs("div",{className:"mx-auto max-w-[820px] px-4 py-8",children:[t.jsxs("div",{className:"mb-4 flex items-center gap-2",children:[t.jsx("span",{className:"font-serif text-[22px] font-black",children:"ChatGrid"}),t.jsx("span",{className:"rounded-full border border-[#242424]/16 bg-[#fffaf0] px-2 py-0.5 font-mono text-[10px] font-black uppercase tracking-[0.14em] text-[#8a8479]",children:"Replay"})]}),o?t.jsx("div",{className:"rounded-lg border border-[#242424]/12 bg-[#fffaf0] p-8 text-center font-mono text-[13px] text-[#8a8479]",children:"Loading replayâ¦"}):l?t.jsx("div",{className:"rounded-lg border border-rose-200 bg-rose-50 p-8 text-center font-mono text-[13px] text-rose-700",children:l}):s?t.jsxs("div",{className:"grid gap-4",children:[(()=>{const e=String(s.status||"done").toLowerCase(),a=e==="running"||e==="queued",f=v(s.updatedAt||s.createdAt);return t.jsxs("div",{className:"rounded-lg border-2 border-[#242424] bg-[#fffaf0] p-5 shadow-[3px_3px_0_rgba(0,0,0,0.12)]",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsxs("span",{className:`inline-flex items-center gap-1.5 rounded-full border px-2 py-0.5 font-mono text-[10px] font-black uppercase tracking-[0.14em] ${a?"border-emerald-700/25 bg-emerald-50 text-emerald-800":"border-[#242424]/16 bg-[#f4efe4] text-[#6d6961]"}`,children:[a?t.jsx("span",{className:"h-2 w-2 animate-pulse rounded-full bg-emerald-600"}):null,a?"Live":e]}),f?t.jsx("span",{className:"font-mono text-[10px] text-[#8a8479]",children:f}):null]}),t.jsx("h1",{className:"mt-2 text-[22px] font-black leading-tight",children:String(s.title||s.prompt||"Untitled task")})]})})(),c.length?t.jsxs("div",{className:"rounded-lg border border-[#242424]/14 bg-[#fffaf0] p-4",children:[t.jsxs("div",{className:"mb-2 font-mono text-[10px] font-black uppercase tracking-[0.16em] text-[#2f716b]",children:["Plan · ",c.filter(e=>e.done).length,"/",c.length]}),t.jsx("ul",{className:"grid gap-1.5",children:c.map((e,a)=>t.jsxs("li",{className:"flex items-start gap-2",children:[t.jsx("span",{className:`mt-0.5 grid h-4 w-4 shrink-0 place-items-center rounded-[4px] border ${e.done?"border-[#2f716b] bg-[#2f716b] text-white":"border-[#242424]/20 bg-white"}`,children:e.done?t.jsx(b,{size:12,strokeWidth:3}):null}),t.jsx("span",{className:`text-[13px] ${e.done?"text-[#8a8479] line-through":"text-[#25231f]"}`,children:e.text})]},a))})]}):null,m.length?t.jsxs("div",{className:"rounded-lg border border-[#242424]/14 bg-[#fffaf0] p-4",children:[t.jsx("div",{className:"mb-2 font-mono text-[10px] font-black uppercase tracking-[0.16em] text-[#8a8479]",children:"What it did"}),t.jsx("div",{className:"grid gap-1.5",children:m.map((e,a)=>t.jsxs("div",{className:"flex items-start gap-2 text-[13px] text-[#4b4740]",children:[t.jsx("span",{className:"mt-1 h-1.5 w-1.5 shrink-0 rounded-full bg-[#2f716b]"}),t.jsx("span",{children:e})]},a))})]}):null,p.length?t.jsxs("div",{className:"rounded-lg border border-[#242424]/14 bg-[#fffaf0] p-4",children:[t.jsxs("div",{className:"mb-2 flex items-center gap-1.5 font-mono text-[10px] font-black uppercase tracking-[0.16em] text-[#2f716b]",children:[t.jsx(j,{size:12,strokeWidth:2.6})," Deliverables · ",p.length]}),t.jsx("div",{className:"flex flex-wrap gap-2",children:p.map((e,a)=>t.jsxs("button",{type:"button",onClick:()=>w(e.path,e.content),className:"inline-flex items-center gap-1.5 rounded-md border border-[#242424]/14 bg-white px-2.5 py-1.5 font-mono text-[12px] font-black text-[#25231f] shadow-[1px_1px_0_rgba(0,0,0,0.05)] transition hover:-translate-y-0.5",children:[String(e.path).split("/").pop(),t.jsx(N,{size:13,strokeWidth:2.5,className:"text-[#8a8479]"})]},a))})]}
1):null,s.finalAnswer?t.jsxs("div",{className:"rounded-lg border border-emerald-200 bg-emerald-50/60 p-4",children:[t.jsx("div",{className:"mb-1 font-mono text-[10px] font-black uppercase tracking-[0.16em] text-emerald-800",children:"Result"}),t.jsx("p",{className:"whitespace-pre-wrap text-[14px] leading-6 text-[#1f554f]",children:String(s.finalAnswer)})]}):null,t.jsx("div",{className:"pt-2 text-center font-mono text-[11px] text-[#8a8479]",children:"Shared from ChatGrid â the AI that runs your business."})]}):null]})})}export{U 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.