ultimatehuman 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +131 -0
- package/LICENSING.md +44 -0
- package/NOTICE +6 -0
- package/README.md +133 -2
- package/THIRD_PARTY_NOTICES.txt +436 -0
- package/dist/cli.mjs +33733 -0
- package/dist/dashboard/assets/ConversationWorkspace-6m6xkkC1.js +16 -0
- package/dist/dashboard/assets/ConversationWorkspace-De5tnYl0.css +1 -0
- package/dist/dashboard/assets/data-provider-CZ2WwK6_.js +1 -0
- package/dist/dashboard/assets/fmt-BRV4RZz4.js +12 -0
- package/dist/dashboard/assets/index-CIpIMh38.js +1 -0
- package/dist/dashboard/assets/index-pC0URNNS.js +2 -0
- package/dist/dashboard/assets/inter-cyrillic-ext-wght-normal-BOeWTOD4.woff2 +0 -0
- package/dist/dashboard/assets/inter-cyrillic-wght-normal-DqGufNeO.woff2 +0 -0
- package/dist/dashboard/assets/inter-greek-ext-wght-normal-DlzME5K_.woff2 +0 -0
- package/dist/dashboard/assets/inter-greek-wght-normal-CkhJZR-_.woff2 +0 -0
- package/dist/dashboard/assets/inter-latin-ext-wght-normal-DO1Apj_S.woff2 +0 -0
- package/dist/dashboard/assets/inter-latin-wght-normal-Dx4kXJAl.woff2 +0 -0
- package/dist/dashboard/assets/inter-vietnamese-wght-normal-CBcvBZtf.woff2 +0 -0
- package/dist/dashboard/assets/jetbrains-mono-cyrillic-wght-normal-D73BlboJ.woff2 +0 -0
- package/dist/dashboard/assets/jetbrains-mono-greek-wght-normal-Bw9x6K1M.woff2 +0 -0
- package/dist/dashboard/assets/jetbrains-mono-latin-ext-wght-normal-DBQx-q_a.woff2 +0 -0
- package/dist/dashboard/assets/jetbrains-mono-latin-wght-normal-B9CIFXIH.woff2 +0 -0
- package/dist/dashboard/assets/jetbrains-mono-vietnamese-wght-normal-Bt-aOZkq.woff2 +0 -0
- package/dist/dashboard/assets/page-CYCU6xk1.js +3 -0
- package/dist/dashboard/assets/render-card-BRSD9J_M.css +1 -0
- package/dist/dashboard/assets/render-card-C8_wQGAe.js +1 -0
- package/dist/dashboard/favicon.svg +5 -0
- package/dist/dashboard/index.html +14 -0
- package/package.json +45 -4
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/data-provider-CZ2WwK6_.js","assets/fmt-BRV4RZz4.js","assets/index-pC0URNNS.js","assets/page-CYCU6xk1.js","assets/index-CIpIMh38.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{_ as ze}from"./index-pC0URNNS.js";import{c as A,r as o,j as e,a as Oe,g as O,p as W,X as Ue,A as Fe,t as Nt,M as Ct,S as qe,C as St,f as $t,s as _t,h as Rt,i as Mt}from"./fmt-BRV4RZz4.js";const Be={name:"activity",size:24,node:[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]]};Be.node;const we=A(Be);const We={name:"arrow-right",size:24,node:[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]};We.node;const Y=A(We);const Ve={name:"arrow-up-right",size:24,node:[["path",{d:"M7 7h10v10",key:"1tivn9"}],["path",{d:"M7 17 17 7",key:"1vkiza"}]]};Ve.node;const H=A(Ve);const Ke={name:"arrow-up",size:24,node:[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]]};Ke.node;const zt=A(Ke);const Ye={name:"cable",size:24,node:[["path",{d:"M17 19a1 1 0 0 1-1-1v-2a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v2a1 1 0 0 1-1 1z",key:"trhst0"}],["path",{d:"M17 21v-2",key:"ds4u3f"}],["path",{d:"M19 14V6.5a1 1 0 0 0-7 0v11a1 1 0 0 1-7 0V10",key:"1mo9zo"}],["path",{d:"M21 21v-2",key:"eo0ou"}],["path",{d:"M3 5V3",key:"1k5hjh"}],["path",{d:"M4 10a2 2 0 0 1-2-2V6a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2a2 2 0 0 1-2 2z",key:"1dd30t"}],["path",{d:"M7 5V3",key:"1t1388"}]]};Ye.node;const Et=A(Ye);const Ge={name:"check",size:24,node:[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]};Ge.node;const ye=A(Ge);const Ze={name:"check-check",size:24,node:[["path",{d:"M18 6 7 17l-5-5",key:"116fxf"}],["path",{d:"m22 10-7.5 7.5L13 16",key:"ke71qq"}]]};Ze.node;const At=A(Ze);const Je={name:"chevron-right",size:24,node:[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]};Je.node;const Xe=A(Je);const Qe={name:"circle",size:24,node:[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]};Qe.node;const Dt=A(Qe);const et={name:"clock-3",size:24,node:[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 6v6h4",key:"135r8i"}]]};et.node;const Ee=A(et);const tt={name:"code-xml",size:24,node:[["path",{d:"m18 16 4-4-4-4",key:"1inbqp"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}],["path",{d:"m14.5 4-5 16",key:"e7oirm"}]],aliases:["code-2"]};tt.node;const Lt=A(tt);const st={name:"git-branch",size:24,node:[["path",{d:"M15 6a9 9 0 0 0-9 9V3",key:"1cii5b"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}]]};st.node;const nt=A(st);const at={name:"git-fork",size:24,node:[["circle",{cx:"12",cy:"18",r:"3",key:"1mpf1b"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["path",{d:"M18 9v2c0 .6-.4 1-1 1H7c-.6 0-1-.4-1-1V9",key:"1uq4wg"}],["path",{d:"M12 12v3",key:"158kv8"}]]};at.node;const ge=A(at);const it={name:"image-plus",size:24,node:[["path",{d:"M16 5h6",key:"1vod17"}],["path",{d:"M19 2v6",key:"4bpg5p"}],["path",{d:"M21 11.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7.5",key:"1ue2ih"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}]]};it.node;const Tt=A(it);const rt={name:"list-checks",size:24,node:[["path",{d:"M13 5h8",key:"a7qcls"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 19h8",key:"c3s6r1"}],["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["path",{d:"m3 7 2 2 4-4",key:"1obspn"}]]};rt.node;const It=A(rt);const lt={name:"loader-circle",size:24,node:[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],aliases:["loader-2"]};lt.node;const J=A(lt);const ct={name:"lock-keyhole",size:24,node:[["circle",{cx:"12",cy:"16",r:"1",key:"1au0dj"}],["rect",{x:"3",y:"10",width:"18",height:"12",rx:"2",key:"6s8ecr"}],["path",{d:"M7 10V7a5 5 0 0 1 10 0v3",key:"1pqi11"}]]};ct.node;const ot=A(ct);const dt={name:"message-square",size:24,node:[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}]]};dt.node;const Pt=A(dt);const ut={name:"plus",size:24,node:[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]};ut.node;const Ae=A(ut);const ht={name:"refresh-cw",size:24,node:[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]};ht.node;const pt=A(ht);const mt={name:"send",size:24,node:[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]]};mt.node;const Ht=A(mt);const gt={name:"settings-2",size:24,node:[["path",{d:"M14 17H5",key:"gfn3mx"}],["path",{d:"M19 7h-9",key:"6i9tg"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["circle",{cx:"7",cy:"7",r:"3",key:"dfmy0x"}]]};gt.node;const Ot=A(gt);const xt={name:"sliders-horizontal",size:24,node:[["path",{d:"M10 5H3",key:"1qgfaw"}],["path",{d:"M12 19H3",key:"yhmn1j"}],["path",{d:"M14 3v4",key:"1sua03"}],["path",{d:"M16 17v4",key:"1q0r14"}],["path",{d:"M21 12h-9",key:"1o4lsq"}],["path",{d:"M21 19h-5",key:"1rlt1p"}],["path",{d:"M21 5h-7",key:"1oszz2"}],["path",{d:"M8 10v4",key:"tgpxqk"}],["path",{d:"M8 12H3",key:"a7s4jb"}]]};xt.node;const Ut=A(xt);const ft={name:"terminal",size:24,node:[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]]};ft.node;const be=A(ft);const vt={name:"triangle-alert",size:24,node:[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],aliases:["alert-triangle"]};vt.node;const Ft=A(vt);function qt({current:t,accountKind:a,disabled:r,onChange:d}){const[l,h]=o.useState(null),[m,v]=o.useState(!0),[j,x]=o.useState(!1),[f,u]=o.useState(""),g=async(n=!1)=>{v(!0),u("");try{const p=await O(`/api/chat/models${n?"?refresh=1":""}`);h(p),u(p.error||"")}catch(p){u(p.message)}finally{v(!1)}};o.useEffect(()=>{g()},[]);const C=l?.models.find(n=>n.id===t||n.aliases.includes(t)),s=t==="claude-opus-5-5"?"Opus 5.5":t,i=async n=>{x(!0),u("");try{await W("/api/chat/model",{model:n}),await d()}catch(p){u(p.message)}finally{x(!1)}};return e.jsxs("div",{className:"chat-model-control",children:[e.jsxs("div",{className:"chat-model-select",title:`${a==="api"?"Your Claude API account":"Your Claude Code subscription"} · Applies to new messages`,children:[(m||j)&&e.jsx(J,{size:12,className:"uh-spin"}),e.jsxs("select",{"aria-label":"Chat model","aria-describedby":f?"chat-model-error":void 0,value:C?.id||t,onChange:n=>{i(n.target.value)},disabled:r||m||j||!l?.models.length,children:[!C&&e.jsxs("option",{value:t,children:[s,l?.models.length?" (current)":""]}),l?.models.map(n=>e.jsxs("option",{value:n.id,title:n.description,children:[n.label,n.id===l.default?" · Default":""]},n.id))]}),e.jsx(Oe,{size:12})]}),f&&e.jsxs("div",{className:"chat-model-error",id:"chat-model-error",role:"status",children:[e.jsx("span",{children:f}),e.jsxs("button",{type:"button",disabled:m,onClick:()=>{g(!0)},children:[e.jsx(pt,{size:11}),"Retry"]})]})]})}function ee({className:t=""}){return e.jsxs("svg",{className:t,viewBox:"0 0 40 40",fill:"none","aria-hidden":"true",children:[e.jsx("rect",{width:"40",height:"40",rx:"12",fill:"currentColor"}),e.jsx("circle",{cx:"20",cy:"14",r:"5",fill:"var(--mark-ink, #121a14)"}),e.jsx("path",{d:"M10.5 29a9.5 9.5 0 0 1 19 0v2h-19v-2Z",fill:"var(--mark-ink, #121a14)"})]})}function Ne({title:t,children:a,close:r,wide:d=!1}){const l=o.useRef(null),h=o.useRef(r);h.current=r;const m=o.useRef(document.activeElement);return o.useEffect(()=>{const v=document.body.style.overflow;document.body.style.overflow="hidden",l.current?.contains(document.activeElement)||l.current?.querySelector("input, textarea, select, button")?.focus();const j=x=>{if(x.key==="Escape"&&h.current(),x.key==="Tab"){const f=[...l.current?.querySelectorAll("button:not(:disabled), input:not(:disabled), select, textarea, a[href]")??[]].filter(C=>C.offsetParent!==null),u=f[0],g=f[f.length-1];x.shiftKey&&document.activeElement===u&&(x.preventDefault(),g?.focus()),!x.shiftKey&&document.activeElement===g&&(x.preventDefault(),u?.focus())}};return document.addEventListener("keydown",j),()=>{document.body.style.overflow=v,document.removeEventListener("keydown",j),m.current?.focus()}},[]),e.jsx("div",{className:"uh-scrim",onMouseDown:v=>{v.target===v.currentTarget&&r()},children:e.jsxs("div",{ref:l,className:`uh-modal ${d?"wide":""}`,role:"dialog","aria-modal":"true","aria-label":t,children:[e.jsxs("div",{className:"uh-modal-head",children:[e.jsx("h2",{children:t}),e.jsx("button",{className:"uh-icon-btn",onClick:r,"aria-label":"Close dialog",children:e.jsx(Ue,{size:20})})]}),a]})})}function Bt({request:t,initialKey:a="",close:r,connected:d}){const[l,h]=o.useState(null),[m,v]=o.useState({}),[j,x]=o.useState(""),[f,u]=o.useState([]),[g,C]=o.useState(!1),[s,i]=o.useState(!1),[n,p]=o.useState(""),[w,N]=o.useState(!1);o.useEffect(()=>{let k=!0;return O("/api/chat/connections").then(_=>{if(!k)return;const T=_.sources.find(S=>S.id===t.source);if(!T)throw new Error("This source is not available.");h(T),v(Object.fromEntries(T.fields.map(S=>[S.key,S.key==="apiKey"&&a?a:S.value||""]))),x(String(T.savedOptions.projectId||"")),C(t.source==="posthog"&&T.fields.some(S=>S.key==="host"&&!["https://us.posthog.com","https://eu.posthog.com"].includes(S.value)))}).catch(_=>{k&&p(_.message)}),()=>{k=!1}},[t.id]);const $=(k,_)=>v(T=>({...T,[k]:_}));let D="";try{const k=new URL(t.source==="posthog"?m.host||"https://us.posthog.com":`https://app.${m.site||"datadoghq.com"}`);["http:","https:"].includes(k.protocol)&&(D=k.origin)}catch{}const M=async()=>{if(!s){i(!0),p("");try{await W(`/api/chat/connections/${t.id}`,{credentials:m,options:j?{projectId:j}:{}}),v({}),N(!0),d()}catch(k){k instanceof Fe&&k.status===409&&k.detail?.projects?(u(k.detail.projects),x(""),p("")):p(k.message)}finally{i(!1)}}};return e.jsx(Ne,{title:w?`${l?.name||t.source} connected`:l?.guide.title||"Connect source",close:()=>{s||r()},children:w?e.jsxs("div",{className:"source-success",children:[e.jsx(ye,{size:25}),e.jsx("p",{children:"Access verified. Claude is continuing setup in chat."}),e.jsx("button",{className:"uh-btn primary",onClick:r,children:"Continue in chat"})]}):l?e.jsxs("form",{className:"source-form",autoComplete:"off",onSubmit:k=>{k.preventDefault(),M()},children:[e.jsx("p",{className:"source-purpose",children:t.source==="posthog"?"Use your existing events and errors to find bugs.":"Use your existing error logs to find bugs."}),e.jsxs("label",{className:"uh-field",children:[e.jsx("span",{children:t.source==="posthog"?"PostHog region":"Datadog site"}),t.source==="posthog"?e.jsxs("select",{disabled:s,value:g?"custom":m.host||"https://us.posthog.com",onChange:k=>{C(k.target.value==="custom"),$("host",k.target.value==="custom"?"":k.target.value),u([]),x("")},children:[e.jsx("option",{value:"https://us.posthog.com",children:"US Cloud"}),e.jsx("option",{value:"https://eu.posthog.com",children:"EU Cloud"}),e.jsx("option",{value:"custom",children:"Self-hosted"})]}):e.jsx("select",{disabled:s,value:m.site||"datadoghq.com",onChange:k=>$("site",k.target.value),children:["datadoghq.com","datadoghq.eu","us3.datadoghq.com","us5.datadoghq.com","ap1.datadoghq.com","ddog-gov.com"].map(k=>e.jsx("option",{children:k},k))})]}),g&&e.jsxs("label",{className:"uh-field",children:[e.jsx("span",{children:"PostHog URL"}),e.jsx("input",{disabled:s,type:"url",required:!0,value:m.host||"",placeholder:"https://posthog.example.com",onChange:k=>$("host",k.target.value)})]}),e.jsx("div",{className:"source-key-links",children:l.guide.links.map(k=>e.jsxs("a",{className:"uh-btn",href:D?D+k.path:l.guide.docsUrl,target:"_blank",rel:"noreferrer",children:[k.label,e.jsx(H,{size:14})]},k.path))}),e.jsxs("details",{className:"source-help",children:[e.jsx("summary",{children:"Key setup instructions"}),e.jsx("ol",{children:l.guide.steps.map(k=>e.jsx("li",{children:k},k))}),e.jsxs("div",{className:"source-scopes",children:[e.jsx("span",{children:"Read permissions"}),l.scopes.map(k=>e.jsx("code",{children:k},k))]}),e.jsxs("a",{className:"source-docs",href:l.guide.docsUrl,target:"_blank",rel:"noreferrer",children:["Official instructions ",e.jsx(H,{size:12})]})]}),l.fields.filter(k=>k.secret).map((k,_)=>e.jsxs("label",{className:"uh-field",children:[e.jsx("span",{children:k.label}),e.jsx("input",{disabled:s,autoFocus:_===0,type:"password",autoComplete:"off",spellCheck:!1,required:!l.configured,value:m[k.key]||"",placeholder:l.configured?"Use saved key, or paste a replacement":t.source==="posthog"?"phx_…":`Paste your ${k.label.toLowerCase()}`,onChange:T=>{$(k.key,T.target.value),u([]),x("")}})]},k.key)),f.length>0&&e.jsxs("label",{className:"uh-field",children:[e.jsxs("span",{children:["Which PostHog project belongs to ",t.project||"this project","?"]}),e.jsxs("select",{disabled:s,required:!0,value:j,onChange:k=>x(k.target.value),children:[e.jsx("option",{value:"",disabled:!0,children:"Choose a project"}),f.map(k=>e.jsxs("option",{value:k.id,children:[k.name," · ",k.id]},k.id))]})]}),e.jsxs("p",{className:"source-private",children:[e.jsx(ot,{size:13}),"Saved on this machine, outside the conversation."]}),n&&e.jsx("p",{role:"alert",className:"uh-error",children:n}),e.jsxs("div",{className:"uh-modal-actions",children:[e.jsx("button",{type:"button",className:"uh-btn",disabled:s,onClick:r,children:"Cancel"}),e.jsx("button",{className:"uh-btn primary",type:"submit",disabled:s||f.length>0&&!j,children:s?e.jsxs(e.Fragment,{children:[e.jsx(J,{size:15,className:"uh-spin"}),"Checking access…"]}):f.length?"Use this project":"Connect"})]})]}):e.jsx("p",{role:"status",children:n||"Loading connection…"})})}const Wt=/^\[user sent an? ([a-z ]+), saved at (\/.+)\]$/,De=/\[\[send:([^\]]+)\]\]/g,Vt=/\.(png|jpe?g|webp|gif|svg)$/i,jt=t=>`/api/chat/file?path=${encodeURIComponent(t)}`;function Kt(t){if(t.role==="assistant"){const d=[...t.text.matchAll(De)].map(l=>l[1].trim());return{text:t.text.replace(De,"").replace(/\n{3,}/g,`
|
|
3
|
+
|
|
4
|
+
`).trim(),files:d}}const a=[];return{text:t.text.split(`
|
|
5
|
+
`).filter(d=>{const l=Wt.exec(d.trim());return l&&a.push(l[2]),!l}).join(`
|
|
6
|
+
`).trim(),files:a}}function Yt({path:t,open:a}){const[r,d]=o.useState(!1),l=t.split("/").pop();return!Vt.test(t)||r?e.jsxs("span",{className:"chat-file",title:t,children:[r?"Unavailable: ":"File: ",l]}):e.jsx("button",{type:"button",className:"chat-thumb",onClick:()=>a(t),title:t,"data-chat-image":!0,children:e.jsx("img",{src:jt(t),alt:l,onError:()=>d(!0)})})}const Gt=t=>new Promise((a,r)=>{const d=new FileReader;d.onload=()=>a(String(d.result).split(",")[1]??""),d.onerror=()=>r(d.error),d.readAsDataURL(t)});function Zt({disabled:t=!1,initialPrompt:a="",configured:r=!1,projectNames:d=[]}={}){const[l,h]=o.useState([]),[m,v]=o.useState(0),j=c=>c.replace(/\bphx_[A-Za-z0-9]+\b/g,""),[x,f]=o.useState(()=>j(a||sessionStorage.getItem("uh.chat.draft")||""));o.useEffect(()=>{const c=new URL(location.href);c.searchParams.has("message")&&(c.searchParams.delete("message"),history.replaceState(null,"",c))},[]);const[u,g]=o.useState(""),C=o.useRef(!1);o.useEffect(()=>{sessionStorage.setItem("uh.chat.draft",j(x))},[x]);const[s,i]=o.useState([]),[n,p]=o.useState(null),[w,N]=o.useState(""),[$,D]=o.useState([]),[M,k]=o.useState(""),[_,T]=o.useState("subscription"),[S,E]=o.useState("claude-opus-5-5"),y=o.useRef(new Set),[L,b]=o.useState([]),[R,I]=o.useState(!1),[B,X]=o.useState(null),[ie,U]=o.useState(""),ue=o.useRef(null),Ce=o.useRef(null),Se=o.useRef(0),$e=o.useRef(null),V=l.length===0||l.length<=2&&/^Help me (set up ultimatehuman|manage this workspace)\./.test(l[0]?.text),kt=l.filter(c=>!(c.role==="user"&&/^Help me (set up ultimatehuman|manage this workspace)\.$/.test(c.text))),K=async()=>{const c=await O("/api/chat");h(c.messages),v(c.busy),g(c.activity||"Claude is working…"),i(c.connections||[]),D(c.permissions||[]),T(c.accountKind||"subscription"),E(c.model||"claude-opus-5-5")},he=(c,z="")=>{y.current.add(c.id),sessionStorage.setItem(`uh.connection.seen.${c.id}`,"1"),N(z),p(c)},_e=()=>{p(null),N(""),$e.current?.focus()};o.useEffect(()=>{if(n)return;const c=s.find(z=>z.status==="pending"&&!y.current.has(z.id)&&!sessionStorage.getItem(`uh.connection.seen.${z.id}`));c&&he(c)},[s,n]);const wt=c=>{const z=c.match(/\bphx_[A-Za-z0-9]{16,}\b/)?.[0];f(j(c)),z&&W("/api/chat/connections/request",{source:"posthog"}).then(P=>he(P.request,z)).catch(P=>U(P.message))},Re=async(c,z)=>{k(c),U("");try{await W(`/api/chat/permissions/${c}`,{allow:z}),await K()}catch(P){U(P.message)}finally{k("")}};o.useEffect(()=>{K().catch(z=>U(z.message));const c=setInterval(()=>{K().catch(()=>{})},1500);return()=>clearInterval(c)},[]),o.useEffect(()=>{const c=l[l.length-1]?.id??0;!V&&c!==Se.current&&ue.current?.scrollIntoView({block:"end"}),Se.current=c},[l]),o.useEffect(()=>{m&&!V&&ue.current?.scrollIntoView({block:"end"})},[m,$.length,s.length]);const pe=c=>{const z=[...c??[]].filter(P=>P.type.startsWith("image/"));z.length&&b(P=>[...P,...z.map(F=>({file:F,url:URL.createObjectURL(F)}))].slice(0,4))},Me=async()=>{const c=x.trim();if(t||C.current||!c&&!L.length)return;C.current=!0,U("");const z=L;f(""),b([]);try{const P=await Promise.all(z.map(async({file:F})=>({name:F.name||"pasted.png",data:await Gt(F)})));await W("/api/chat",{text:c,files:P}),z.forEach(F=>URL.revokeObjectURL(F.url)),await K()}catch(P){U(P.message),f(c),b(z)}finally{C.current=!1}};return e.jsxs("div",{className:`chat-full${V?" chat-intro-mode":""}${R?" dragging":""}`,onDragOver:c=>{[...c.dataTransfer.types].includes("Files")&&(c.preventDefault(),I(!0))},onDragLeave:c=>{c.currentTarget===c.target&&I(!1)},onDrop:c=>{c.preventDefault(),I(!1),pe(c.dataTransfer.files)},children:[e.jsx("div",{className:"chat-log","data-chat-log":!0,children:e.jsxs("div",{className:"chat-col",children:[V&&e.jsxs("div",{className:"chat-welcome",children:[e.jsx(ee,{}),e.jsx("h2",{children:r?"What’s next?":"Set up your first pipeline."}),e.jsx("p",{children:r?d.join(" · "):"Start with one project. Include all of its repositories."})]}),kt.map(c=>{const z=Kt(c),P=z.files.length>0&&e.jsx("div",{className:"chat-files",children:z.files.map((F,me)=>e.jsx(Yt,{path:F,open:X},me))});return e.jsxs("div",{className:`chat-msg ${c.role}`,"data-chat-msg":c.role,"data-source":c.source,children:[e.jsxs("div",{className:"chat-meta",children:[c.role==="assistant"&&e.jsx(ee,{className:"chat-avatar"}),e.jsx("strong",{children:c.role==="user"?"You":"ultimatehuman"}),e.jsx("span",{className:"chat-message-time",children:Nt(c.ts)}),c.source!=="dashboard"&&e.jsx("span",{className:"pill","data-source-tag":!0,children:c.source==="cli"?"CLI":c.source})]}),c.role==="user"&&P,z.text&&e.jsx("div",{className:"chat-bubble",children:c.role==="assistant"?e.jsx(Ct,{text:z.text}):z.text}),c.role==="assistant"&&P]},c.id)}),s.filter(c=>c.status==="pending").map(c=>e.jsxs("div",{className:"chat-action-card","data-connection-request":c.source,children:[e.jsx(Et,{size:20}),e.jsxs("div",{children:[e.jsxs("strong",{children:["Connect ",c.source==="posthog"?"PostHog":"Datadog"]}),e.jsxs("p",{children:["Use your existing ",c.source==="posthog"?"events and errors":"error logs",c.project?` for ${c.project}`:"","."]})]}),e.jsxs("button",{className:"uh-btn primary",onClick:()=>he(c),children:["Connect ",e.jsx(H,{size:14})]})]},c.id)),$.map(c=>e.jsxs("div",{className:"chat-permission","data-chat-permission":c.tool,children:[e.jsxs("div",{children:[e.jsx(be,{size:17}),e.jsx("strong",{children:c.tool==="Bash"?"Run this command?":`Allow Claude to ${c.tool==="Edit"?"edit this file":c.tool==="Write"?"write this file":"use "+c.tool}?`})]}),c.input.description&&e.jsx("p",{children:c.input.description}),e.jsx("pre",{children:c.tool==="Bash"?c.input.command:c.input.file_path||c.input.path||JSON.stringify(c.input,null,2)}),(c.input.new_string!==void 0||c.input.content!==void 0)&&e.jsxs("details",{children:[e.jsx("summary",{children:"View change"}),c.input.old_string&&e.jsx("pre",{className:"permission-before",children:c.input.old_string}),e.jsx("pre",{children:c.input.new_string??c.input.content})]}),e.jsxs("div",{className:"chat-permission-actions",children:[e.jsx("button",{className:"uh-btn",disabled:M===c.id,onClick:()=>{Re(c.id,!1)},children:"Decline"}),e.jsx("button",{className:"uh-btn primary",disabled:M===c.id,onClick:()=>{Re(c.id,!0)},children:M===c.id?"Continuing…":c.tool==="Bash"?"Run command":"Allow"})]})]},c.id)),m>0&&e.jsx("div",{className:"chat-msg assistant","data-chat-busy":!0,children:e.jsxs("div",{className:"chat-bubble chat-busy",children:[e.jsx(J,{size:14,className:"uh-spin"})," ",u,m>1?` · ${m-1} queued`:""]})}),e.jsx("div",{ref:ue})]})}),e.jsx("form",{className:"chat-input",onSubmit:c=>{c.preventDefault(),Me()},children:e.jsxs("div",{className:"chat-col",children:[L.length>0&&e.jsx("div",{className:"chat-pending","data-chat-pending":!0,children:L.map((c,z)=>e.jsxs("span",{className:"chat-pending-item",children:[e.jsx("img",{src:c.url,alt:c.file.name}),e.jsx("button",{type:"button","aria-label":"Remove",onClick:()=>b(P=>P.filter((F,me)=>me!==z)),children:e.jsx(Ue,{size:12})})]},c.url))}),e.jsxs("div",{className:"chat-row",children:[e.jsx("input",{ref:Ce,type:"file",accept:"image/*",multiple:!0,hidden:!0,"data-chat-file":!0,onChange:c=>(pe(c.target.files),c.target.value="")}),e.jsx("textarea",{ref:$e,"aria-label":"Message Claude","data-chat-input":!0,rows:V?2:1,value:x,placeholder:V?r?"What should we investigate?":"Repository paths or Git URLs…":"Message Claude…",onChange:c=>wt(c.target.value),onPaste:c=>{c.clipboardData.files.length&&(c.preventDefault(),pe(c.clipboardData.files))},onKeyDown:c=>{c.key==="Enter"&&!c.shiftKey&&!c.nativeEvent.isComposing&&(c.preventDefault(),Me())}}),e.jsxs("div",{className:"chat-composer-bar",children:[e.jsxs("button",{type:"button",className:"btn chat-attach","aria-label":"Attach an image",title:"Attach an image",onClick:()=>Ce.current?.click(),"data-chat-attach":!0,children:[e.jsx(Tt,{size:16}),e.jsx("span",{children:"Add context"})]}),e.jsx(qt,{current:S,accountKind:_,disabled:t,onChange:K}),e.jsx("button",{type:"submit",className:"btn primary chat-send","aria-label":"Send message",title:t?"Reconnect Claude to send":"Send message",disabled:t||!x.trim()&&!L.length,"data-chat-send":!0,children:e.jsx(zt,{size:19,strokeWidth:2})})]})]}),e.jsxs("div",{className:"chat-composer-hint",children:[e.jsx("span",{children:_==="api"?"Your Claude API account":"Your Claude Code subscription"}),e.jsx("span",{children:"Enter to send · Shift+Enter for a new line"})]}),ie&&e.jsx("p",{className:"chat-err",role:"alert",children:ie})]})}),n&&e.jsx(Bt,{request:n,initialKey:w,close:_e,connected:()=>{_e(),K()}}),R&&e.jsx("div",{className:"chat-drop",children:"Drop an image to attach it"}),B&&e.jsx("div",{className:"scrim chat-lightbox",onClick:()=>X(null),"data-chat-lightbox":!0,children:e.jsx("img",{src:jt(B),alt:B.split("/").pop()})})]})}const Jt=t=>`/chat?message=${encodeURIComponent(t)}`;function Xt(t,a){const r=t.workspace.projects,d=r.find(b=>b.id===a)??r[0],l=d?.repos??[],h=l.map(b=>b.name),m=d?t.pipelines.config.filter(b=>!b.repos||b.repos.some(R=>h.includes(R))):[],v=t.workspace.connections.filter(b=>b.supported),j=b=>b.configured&&b.probe?.ok===!0,x=b=>l.some(R=>R.trackers.some(I=>I.provider===b.id)),f=v.filter(x),u=v.filter(j),g=l.length>0&&l.every(b=>b.available),C=t.workspace.provider.authenticated===!0,s=b=>b.sources.some(R=>R==="repos"?g:R==="*"?u.length>0:u.some(I=>I.id===R)),i=b=>b.sources.some(R=>R!=="repos"&&R!=="*"&&!u.some(I=>I.id===R)),n=b=>g&&C&&s(b)&&!i(b),p=m.some(n),w=t.runs.filter(b=>m.some(R=>R.id===b.pipelineId)),N=w.find(b=>!["done","failed"].includes(b.phase)),$=(t.pipelines.queued??[]).some(b=>m.some(R=>R.id===b.pipelineId)),D=w.find(b=>b.phase==="done"&&!b.error&&b.sources?.some(R=>R.ok)),M=`/pipeline-live${d?`?project=${encodeURIComponent(d.id)}`:""}`,k=d?` for project ${JSON.stringify(d.id)}`:"",_=b=>Jt(b+k+"."),T=m.find(b=>b.template==="bug-radar"),S=v.find(b=>T?.sources.includes(b.id)&&!j(b))??f.find(j)??f[0]??u[0];let E={title:"Connect your first project",detail:"Tell Claude which repositories belong to it.",label:"Choose repositories",href:_("Help me connect my repositories")};if(d)if(!g)E={title:"Reconnect a repository",detail:"One of this project’s checkouts is unavailable.",label:"Resolve in chat",href:_("Help me restore access to the unavailable repository")};else if(!C)E={title:"Check the Claude connection",detail:"Use the account already installed on this machine.",label:"Check in chat",href:_("Check my existing Claude Code account connection")};else if(N||$)E={title:N?.phase==="parked"?"Investigation is waiting":$?"Investigation is queued":"Your pipeline is running",detail:"Follow the investigation and its evidence as it progresses.",label:"Open Pipeline live",href:M};else if(T&&!n(T)||!p&&S&&!j(S))E={title:S?`Connect ${S.name}`:"Connect an error source",detail:"Give Bug radar access to real errors for its next run.",label:"Continue in chat",href:_(S?`Connect ${S.name} and run the existing Bug radar, or set up the original Bug radar if none exists`:"Help me connect a tracking source and run Bug radar")};else if(D)E={title:"Your first investigation is complete",detail:D.findings?`The completed run produced ${D.findings} finding${D.findings===1?"":"s"}.`:"The run completed without a supported finding. You can inspect its coverage.",label:D.findings?"Open Review":"View run",href:D.findings?`/review?tab=decide&pipeline=${encodeURIComponent(D.pipelineId)}`:M};else if(p){const b=m.find(n);E={title:`Run ${b.name}`,detail:"Check the evidence, then send supported findings to Review.",label:"Start in chat",href:_(`Run the existing pipeline ${JSON.stringify(b.id)} now, keeping its saved settings`)}}else E={title:S?"Set up Bug radar":"Start with a Security check",detail:S?"Use your connected source to investigate real user problems.":"Review your code now. Add production tracking when you’re ready.",label:"Set up in chat",href:_(S?"Set up and run the original Bug radar using my connected source":"Set up and run the original Security check on my repositories")};const y=[{id:"repos",label:"Repositories",done:g,detail:l.length?g?`${l.length} connected`:"Access needed":"Not connected"},{id:"account",label:"Claude Code",done:C,detail:C?"Account connected":"Check connection"},{id:"pipeline",label:"Pipeline",done:p,detail:p?"Ready to run":m.length?"Connection needed":"Not set up"},{id:"run",label:"First run",done:!!D,detail:D?"Completed":N?.phase==="parked"?"Waiting for capacity":N?"Running":$?"Queued":w[0]?.phase==="failed"?"Needs attention":"Not started"}],L=t.pipelines.templates.map(b=>{const R=m.filter(U=>U.template===b.id),I=b.id==="security-check",B=g&&C&&(I||u.length>0),X=R.some(n),ie=f.length||u.length?!I:I;return{...b,existing:R,recommended:ie,ready:R.length?X:B,status:R.length?X?R.every(U=>!U.enabled)?"Paused":"Configured":"Connection needed":B?"Ready to add":g?C?"Needs tracking":"Needs Claude":"Needs repositories",description:I?"Find exposed secrets, risky dependencies, and gaps in authentication.":"Trace production errors and failed interactions back to the code.",href:_(R.length?`Check the setup of the existing ${b.name} pipeline${R.length===1?" "+JSON.stringify(R[0].id):"s"} and help me run it, preserving its saved settings`:`Help me set up ${b.name} using the original template defaults, then run it`)}}).sort((b,R)=>Number(R.recommended)-Number(b.recommended));return{project:d,repos:l,pipelines:m,sources:v,tracked:f,available:u,connected:j,detected:x,steps:y,next:E,suggestions:L,liveHref:M,ask:_,completed:D}}const Le={posthog:{description:"Product events, failed interactions, and user errors.",docs:"https://posthog.com/docs/libraries",letter:"P"},datadog:{description:"Backend error logs and service failures.",docs:"https://docs.datadoghq.com/logs/error_tracking/",letter:"D"}};function Qt({data:t,project:a}){const r=Xt(t,a),{project:d,repos:l,pipelines:h,sources:m,steps:v,next:j,suggestions:x,ask:f}=r,u=v.filter(s=>s.done).length,g=v.find(s=>!s.done)?.id,C=[...new Set(l.flatMap(s=>s.trackers.map(i=>i.provider)))].filter(s=>!m.some(i=>i.id===s));return e.jsxs("div",{className:"setup-page",children:[e.jsxs("div",{className:"setup-heading",children:[e.jsxs("div",{children:[e.jsx("span",{className:"setup-eyebrow",children:"PROJECT SETUP"}),e.jsx("h2",{children:d?.name||"Your first project"}),e.jsx("p",{children:"What’s connected. What’s next."})]}),e.jsxs("a",{className:"uh-btn",href:f("Help me connect another repository"),children:[e.jsx(Ae,{size:14}),"Add repository"]})]}),e.jsxs("section",{className:"setup-progress","aria-label":"Setup progress",children:[e.jsxs("div",{className:"setup-progress-top",children:[e.jsxs("span",{children:[e.jsx(At,{size:16}),"Setup progress"]}),e.jsxs("span",{children:[u," of ",v.length," complete"]})]}),e.jsx("ol",{children:v.map((s,i)=>e.jsxs("li",{className:s.done?"is-done":s.id===g?"is-next":"","aria-current":!s.done&&s.id===g?"step":void 0,children:[e.jsx("span",{className:"setup-step-marker",children:s.done?e.jsx(ye,{size:14}):String(i+1).padStart(2,"0")}),e.jsxs("div",{children:[e.jsx("strong",{children:s.label}),e.jsx("span",{children:s.detail})]})]},s.id))})]}),e.jsxs("div",{className:"setup-next",role:"status",children:[e.jsx("div",{className:"setup-next-icon",children:e.jsx(Y,{size:20})}),e.jsxs("div",{children:[e.jsx("span",{className:"setup-eyebrow",children:r.completed?"FIRST RUN COMPLETE":"NEXT STEP"}),e.jsx("h3",{children:j.title}),e.jsx("p",{children:j.detail})]}),e.jsxs("a",{className:"uh-btn primary",href:j.href,children:[j.label,e.jsx(Y,{size:14})]})]}),e.jsxs("div",{className:"setup-columns",children:[e.jsxs("div",{className:"setup-primary",children:[e.jsxs("section",{className:"setup-section","aria-labelledby":"setup-repositories",children:[e.jsxs("div",{className:"setup-section-heading",children:[e.jsxs("h3",{id:"setup-repositories",children:["Repositories ",e.jsx("span",{children:l.length})]}),e.jsx(ge,{size:17})]}),e.jsx("div",{className:"setup-repos",children:l.length?l.map(s=>{const i=h.filter(p=>!p.repos||p.repos.includes(s.name)),n=s.facts.filter(p=>p.kind==="application").map(p=>p.label).filter(p=>p!=="Node.js").join(" · ")||"Repository";return e.jsxs("div",{className:"setup-repo",children:[e.jsx("div",{className:"setup-repo-icon",children:e.jsx(Lt,{size:18})}),e.jsxs("div",{className:"setup-repo-info",children:[e.jsxs("div",{children:[e.jsx("strong",{children:s.name}),e.jsx("span",{className:`setup-label ${s.available?"positive":"attention"}`,children:s.available?"Connected":"Unavailable"})]}),e.jsxs("p",{children:[n,s.branch&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"·"}),e.jsx(nt,{size:11}),s.branch]})]}),e.jsxs("details",{children:[e.jsxs("summary",{children:[i.length?`${i.length} pipeline${i.length===1?"":"s"}`:"No pipeline yet",e.jsx(Xe,{size:11})]}),e.jsx("code",{children:s.path}),i.length>0&&e.jsx("p",{children:i.map(p=>p.name).join(" · ")}),s.error&&e.jsx("p",{children:s.error})]})]})]},s.name)}):e.jsxs("div",{className:"setup-empty",children:[e.jsx(ge,{size:24}),e.jsx("p",{children:"Connect the frontend, backend, or any repos that make up your project."}),e.jsxs("a",{href:j.href,children:["Choose repositories in chat ",e.jsx(Y,{size:13})]})]})})]}),e.jsxs("section",{className:"setup-section","aria-labelledby":"setup-pipelines",children:[e.jsxs("div",{className:"setup-section-heading",children:[e.jsx("h3",{id:"setup-pipelines",children:"Pipelines"}),e.jsx("span",{children:r.completed?"Add when useful":"Start with one"})]}),e.jsx("div",{className:"setup-pipeline-list",children:x.map(s=>e.jsxs("article",{className:"setup-pipeline","data-setup-pipeline":s.id,children:[e.jsxs("div",{className:"setup-pipeline-top",children:[e.jsx("span",{className:"setup-pipeline-icon",children:s.id==="security-check"?e.jsx(qe,{size:18}):e.jsx(we,{size:18})}),e.jsx("h4",{children:s.name}),s.recommended&&!s.existing.length&&e.jsx("span",{className:"setup-recommended",children:r.completed?"Suggested next":"Start here"})]}),e.jsx("p",{children:s.description}),e.jsxs("div",{className:"setup-pipeline-bottom",children:[e.jsxs("span",{className:`setup-label ${s.ready&&s.status!=="Paused"?"positive":""}`,children:[e.jsx(Dt,{size:6,fill:"currentColor"}),s.status]}),e.jsxs("a",{href:s.href,children:[s.existing.length?"Continue in chat":"Set up in chat",e.jsx(H,{size:14})]})]})]},s.id))}),h.filter(s=>!x.some(i=>i.id===s.template)).map(s=>e.jsxs("a",{className:"setup-custom-pipeline",href:f(`Show the setup and status of the existing pipeline ${JSON.stringify(s.id)}`),children:[e.jsx(Ut,{size:15}),s.name,e.jsx("span",{children:s.enabled?"Configured":"Paused"}),e.jsx(H,{size:13})]},s.id)),e.jsxs("a",{className:"setup-other",href:f("Help me design another pipeline using the existing engine capabilities"),children:[e.jsx(Ae,{size:13}),"Have another objective? Discuss it in chat."]})]})]}),e.jsxs("aside",{className:"setup-secondary",children:[e.jsxs("section",{className:"setup-section","aria-labelledby":"setup-tracking",children:[e.jsxs("div",{className:"setup-section-heading",children:[e.jsx("h3",{id:"setup-tracking",children:"Tracking"}),e.jsx("span",{children:r.tracked.length?"Found in your code":"For production signals"})]}),e.jsx("p",{className:"setup-section-copy",children:r.tracked.length?r.tracked.every(r.connected)?"Your detected tools have read access. Check their coverage for this project.":"Connect a tool you already use to investigate real user problems.":r.available.length?"Your workspace has connected sources. Check that they cover this project.":"No supported tracking SDK detected. Add one for production errors, or start with a code review."}),m.filter(s=>Le[s.id]).sort((s,i)=>Number(r.detected(i))-Number(r.detected(s))).map(s=>{const i=r.detected(s),n=r.connected(s),p=Le[s.id],w=l.filter(N=>N.trackers.some($=>$.provider===s.id));return e.jsxs("article",{className:"setup-source","data-setup-source":s.id,children:[e.jsxs("div",{className:"setup-source-top",children:[e.jsx("span",{className:`setup-source-logo ${s.id}`,children:p.letter}),e.jsx("h4",{children:s.name}),e.jsx("span",{className:`setup-label ${n?"positive":""}`,children:n?"Connected":i?"SDK detected":"Optional"})]}),e.jsx("p",{children:p.description}),i&&e.jsxs("div",{className:"setup-source-repos",children:[e.jsx(ge,{size:12}),e.jsx("span",{children:w.map(N=>N.name).join(" · ")})]}),n?e.jsxs("p",{className:"setup-source-access",children:[e.jsx(ye,{size:12}),"Workspace read access verified"]}):i&&e.jsx("p",{className:"setup-source-access",children:"Read access not connected"}),e.jsxs("div",{className:"setup-source-actions",children:[e.jsxs("a",{href:f(n?`Check ${s.name} project mapping and data coverage for my repositories`:i?`Connect the existing ${s.name} tracking using the in-chat connection form, then continue my first Bug radar`:`Help me add ${s.name} tracking to my repositories. Inspect the existing setup first and explain what needs to be installed`),children:[n?"Check coverage":i?`Connect ${s.name}`:"Set up with Claude",e.jsx(Y,{size:13})]}),e.jsx("a",{href:p.docs,target:"_blank",rel:"noreferrer","aria-label":`${s.name} documentation`,title:"Official documentation",children:e.jsx(H,{size:14})})]})]},s.id)}),C.length>0&&e.jsxs("p",{className:"setup-unsupported",children:[C.map(s=>s==="sentry"?"Sentry":s).join(", ")," detected. Collection is not available in this build."]})]}),e.jsxs("div",{className:"setup-flow",children:[e.jsx("span",{className:"setup-eyebrow",children:"HOW IT WORKS"}),e.jsxs("p",{children:["Signals ",e.jsx(Y,{size:12})," Investigation ",e.jsx(Y,{size:12})," Review"]}),e.jsx("span",{children:"Claude checks the code and evidence. You decide which findings to act on."}),e.jsxs("a",{href:r.liveHref,children:["See Pipeline live",e.jsx(H,{size:13})]})]})]})]})]})}function Z({href:t,prefetch:a,replace:r,scroll:d,shallow:l,passHref:h,legacyBehavior:m,...v}){return e.jsx("a",{href:typeof t=="string"?t:t?.pathname??"#",...v})}function es({title:t,titleId:a,...r},d){return o.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:d,"aria-labelledby":a},r),t?o.createElement("title",{id:a},t):null,o.createElement("path",{fillRule:"evenodd",d:"M10 3a.75.75 0 0 1 .75.75v10.638l3.96-4.158a.75.75 0 1 1 1.08 1.04l-5.25 5.5a.75.75 0 0 1-1.08 0l-5.25-5.5a.75.75 0 1 1 1.08-1.04l3.96 4.158V3.75A.75.75 0 0 1 10 3Z",clipRule:"evenodd"}))}const ts=o.forwardRef(es);function ss({title:t,titleId:a,...r},d){return o.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:d,"aria-labelledby":a},r),t?o.createElement("title",{id:a},t):null,o.createElement("path",{fillRule:"evenodd",d:"M3 10a.75.75 0 0 1 .75-.75h10.638L10.23 5.29a.75.75 0 1 1 1.04-1.08l5.5 5.25a.75.75 0 0 1 0 1.08l-5.5 5.25a.75.75 0 1 1-1.04-1.08l4.158-3.96H3.75A.75.75 0 0 1 3 10Z",clipRule:"evenodd"}))}const ns=o.forwardRef(ss);function as({title:t,titleId:a,...r},d){return o.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:d,"aria-labelledby":a},r),t?o.createElement("title",{id:a},t):null,o.createElement("path",{fillRule:"evenodd",d:"M8.22 5.22a.75.75 0 0 1 1.06 0l4.25 4.25a.75.75 0 0 1 0 1.06l-4.25 4.25a.75.75 0 0 1-1.06-1.06L11.94 10 8.22 6.28a.75.75 0 0 1 0-1.06Z",clipRule:"evenodd"}))}const oe=o.forwardRef(as);function is({title:t,titleId:a,...r},d){return o.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:d,"aria-labelledby":a},r),t?o.createElement("title",{id:a},t):null,o.createElement("path",{d:"M6.28 5.22a.75.75 0 0 0-1.06 1.06L8.94 10l-3.72 3.72a.75.75 0 1 0 1.06 1.06L10 11.06l3.72 3.72a.75.75 0 1 0 1.06-1.06L11.06 10l3.72-3.72a.75.75 0 0 0-1.06-1.06L10 8.94 6.28 5.22Z"}))}const rs=o.forwardRef(is),ls=30*1e3,ne=7,ke=14,te=24*3600*1e3,ce=[{key:"validate",label:"To validate",owner:"you",tab:"validate",hint:"MAX fixes wait for your go before anything runs."},{key:"queued",label:"Fix queue",owner:"pipeline",tab:"validate",hint:"Validated, or not using MAX: the pipeline picks them up."},{key:"building",label:"Building",owner:"pipeline",tab:"merge",hint:"A fix round is running."},{key:"decide",label:"Needs decision",owner:"you",tab:"decide",hint:"The pipeline asks you to choose."},{key:"manual",label:"Manual",owner:"you",tab:"manual",hint:"Stopped over budget, for you to run by hand."},{key:"merge",label:"Ready to merge",owner:"you",tab:"merge",hint:"Passed the hostile check: review and merge on GitHub."},{key:"shipped",label:"Shipped",owner:"done",tab:"shipped",hint:`Merged on GitHub, last ${ne} days.`}],q=t=>{const a=t?new Date(t).getTime():NaN;return Number.isFinite(a)?a:null},xe=(t,a)=>t.key.localeCompare(a.key,"en",{numeric:!0});function cs(t,a=Date.now()){if(!t?.key)return null;if(t.live_stage&&ce.some(r=>r.key===t.live_stage))return t.live_stage==="shipped"&&(q(t.merged_at)??0)<a-ne*te?null:t.live_stage;switch(t.queue){case"backlog":return t.merged_into?null:t.gate==="pending"||t.gate==="later"?"validate":t.gate==="validated"||t.gate==="auto"?"queued":null;case"building":return"building";case"decision":return"decide";case"manual":return"manual";case"merge":return"merge";case"shipped":{const r=q(t.merged_at);return r!=null&&r>=a-ne*te?"shipped":null}default:return null}}function os(t,a){if(t.live_state)return t.live_state;const r=(t.prs||[]).length,d=`${r} PR${r===1?"":"s"}`,l=t.fix_round?.stage;switch(a){case"validate":return t.gate==="later"?{turn:"parked",status:"Parked with Later: nothing runs until you validate it."}:{turn:"you",status:"Waiting for your validation."};case"queued":return{turn:"pipeline",status:t.gate==="validated"?"Validated by you, in the fix queue.":"No MAX cost, in the fix queue on its own."};case"building":return{turn:"pipeline",status:l?`Fix round ${l}.`:"Fix in progress."};case"decide":return t.answer?.answered_at?{turn:"pipeline",status:"You answered. The pipeline acts on it."}:{turn:"you",status:"Waiting for your decision."};case"manual":return{turn:"you",status:"Stopped over budget. Yours to run by hand."};case"merge":return l?{turn:"pipeline",status:`Your fix request is building (${l}).`}:t.hold?{turn:"you",status:`Held: ${t.hold}`}:{turn:"you",status:`Ready: review and merge ${d} on GitHub.`};case"shipped":return{turn:"done",status:`Merged on GitHub (${d}).`};default:return{turn:"pipeline",status:""}}}function fe(t){const a=new Date(t);return a.setHours(0,0,0,0),a.getTime()}function ds(t,a=Date.now(),r=ce){const d=fe(a),l=[];for(const s of t||[]){const i=cs(s,a);if(!i)continue;const{turn:n,status:p}=os(s,i),w=q(s.jira_created);l.push({key:s.key,title:(s.plain?.improves||s.title||"").trim(),stage:i,turn:n,status:p,held:i==="merge"&&!!s.hold&&!s.fix_round?.stage,round:s.fix_round?.stage||null,created:w,newToday:w!=null&&w>=d,at:i==="shipped"?q(s.merged_at):i==="manual"?q(s.manual?.stopped_at):w,flags:(s.flags||[]).map(N=>N.label).filter(Boolean),href:s.live_href||null,displayKey:s.displayKey||(s.live_stage?`${s.key.split("-")[0]}-${s.key.slice(-6)}`:null)})}const h=r.map(s=>{const i=l.filter(p=>p.stage===s.key);i.sort(s.key==="shipped"?(p,w)=>(w.at||0)-(p.at||0)||xe(p,w):(p,w)=>Te(p)-Te(w)||(p.created??1/0)-(w.created??1/0)||xe(p,w));const n=s.key==="validate"||s.key==="decide"?i.filter(p=>p.turn==="you").length:i.length;return{...s,nodes:i,count:n}}),m=s=>h.find(i=>i.key===s).count,v=l.filter(s=>s.turn==="you"),j=v.filter(s=>s.created!=null).sort((s,i)=>s.created-i.created)[0]||null,x={total:r===ce?m("validate")+m("merge")+m("decide")+m("manual"):v.length,validate:m("validate"),merge:m("merge"),held:l.filter(s=>s.held).length,decide:m("decide"),manual:m("manual"),parked:l.filter(s=>s.turn==="parked").length,oldest:j},f=d-(ke-1)*te,u=(t||[]).map(s=>q(s.createdAt)).filter(s=>s!=null),g=u.length?fe(Math.min(...u)-ne*te):null,C=Array.from({length:ke},(s,i)=>{const n=fe(f+i*te+432e5);return{start:n,count:0,keys:[],known:g==null||n>=g}});for(const s of t||[]){const i=q(s.merged_at);if(i==null||i<f||!s.key)continue;const n=C.find((p,w)=>i>=p.start&&(w===C.length-1||i<C[w+1].start));n&&(n.count+=1,n.keys.push(s.key),n.known=!0)}return{stages:h,nodes:l,waiting:x,shipped:C,today:{filed:l.filter(s=>s.newToday).sort(xe),shipped:l.filter(s=>s.stage==="shipped"&&s.at!=null&&s.at>=d)}}}function Te(t){return{you:0,pipeline:1,parked:2,done:3}[t.turn]??4}function us(t,a){const r=q(t?.last_push_at);if(r!=null)return{at:r,kind:"push"};const d=(a||[]).map(l=>q(l.synced_at)).filter(l=>l!=null);return d.length?{at:Math.max(...d),kind:"change"}:null}function G(t,a=Date.now()){if(t==null)return"";const r=Math.max(0,Math.round((a-t)/1e3));if(r<45)return"just now";const d=Math.round(r/60);if(d<60)return`${d} min ago`;const l=Math.round(d/60);if(l<36)return`${l} h ago`;const h=Math.round(l/24);return`${h} day${h===1?"":"s"} ago`}function ae(t,a){return`/administration/claims?tab=${ce.find(d=>d.key===t)?.tab||"merge"}${a?`&focus=${encodeURIComponent(a)}`:""}`}const hs=2700*1e3,ve=18,yt={you:"bg-amber-100 text-amber-950 ring-amber-300 hover:bg-amber-200",held:"bg-white text-amber-900 ring-transparent outline-dashed outline-[1.5px] -outline-offset-[1.5px] outline-amber-500 hover:bg-amber-50",pipeline:"bg-white text-gray-700 ring-gray-300 hover:bg-gray-50",building:"bg-sky-50 text-sky-900 ring-sky-300 hover:bg-sky-100",parked:"bg-gray-100 text-gray-500 ring-gray-200 hover:bg-gray-200",done:"bg-emerald-50 text-emerald-900 ring-emerald-200 hover:bg-emerald-100"},ps={you:{label:"You",cls:"bg-amber-100 text-amber-900"},pipeline:{label:"Pipeline",cls:"bg-gray-100 text-gray-600"},done:{label:"Done",cls:"bg-emerald-50 text-emerald-800"}},ms=[["validate"],["queued"],["building"],["decide","manual"],["merge"],["shipped"]],bt=t=>t.held?"held":t.stage==="building"||t.round?"building":t.turn,Ie={weekday:"short",day:"numeric",month:"short"};function gs(t,a){const[r,d]=o.useState(t),[l,h]=o.useState(!1),[m,v]=o.useState(()=>Date.parse(t.read_at));return o.useEffect(()=>{if(a)return;let j=!1;const x=async()=>{if(document.visibilityState==="visible")try{const u=await fetch("/api/admin/pipeline/live",{cache:"no-store"});if(!u.ok)throw new Error(String(u.status));const g=await u.json();if(j)return;d(g),h(!1),v(Date.parse(g.read_at)||Date.now())}catch{j||h(!0)}},f=setInterval(x,ls);return window.addEventListener("focus",x),document.addEventListener("visibilitychange",x),()=>{j=!0,clearInterval(f),window.removeEventListener("focus",x),document.removeEventListener("visibilitychange",x)}},[!!a]),a?{snap:a,failed:!!a.offline,checkedAt:Date.parse(a.read_at)}:{snap:r,failed:l,checkedAt:m}}function xs(t){const a=o.useRef(null),[r,d]=o.useState(()=>new Set),l=t.map(h=>`${h.key}:${h.stage}`).join(",");return o.useEffect(()=>{const h=new Set(l?l.split(","):[]);a.current&&d(new Set([...h].filter(m=>!a.current.has(m)).map(m=>m.split(":")[0]))),a.current=h},[l]),r}function fs({initial:t,snapshot:a=null,workspace:r=!1,children:d=null,activity:l=null}){const{snap:h,failed:m,checkedAt:v}=gs(t,a),[j,x]=o.useState(()=>Date.parse(t.read_at)),[f,u]=o.useState(!1);o.useEffect(()=>{u(!0),x(Date.now());const S=setInterval(()=>x(Date.now()),15e3);return()=>clearInterval(S)},[]),o.useEffect(()=>{x(Date.now())},[v]);const g=o.useMemo(()=>{const S=ds(h.tickets,j,h.stages);if(r){const E=h.historyStart?new Date(h.historyStart):null;E&&E.setHours(0,0,0,0),S.shipped.forEach(y=>{y.known=y.count>0||!!E&&y.start>=E.getTime()})}return S},[h.tickets,h.stages,h.historyStart,j,r]),C=o.useMemo(()=>$s(g.nodes.map(S=>S.key)),[g.nodes]),s=xs(g.nodes),i=us(h.sync,h.tickets),n=S=>g.stages.find(E=>E.key===S),[p,w]=o.useState(null),N=o.useCallback((S,E,y=!1)=>w({node:S,rect:E.getBoundingClientRect(),pinned:y}),[]),$=o.useCallback(()=>w(S=>S?.pinned?S:null),[]),D=o.useCallback(()=>w(null),[]);o.useEffect(()=>{if(!p)return;const S=()=>w(null),E=y=>{y.key==="Escape"&&w(null)};return window.addEventListener("scroll",S,!0),window.addEventListener("keydown",E),()=>{window.removeEventListener("scroll",S,!0),window.removeEventListener("keydown",E)}},[p]);const M=p&&g.nodes.find(S=>S.key===p.node.key),k={prefix:C,arrived:s,mounted:f,onShow:N,onHide:$,pinnedKey:p?.pinned?p.node.key:null},_=g.waiting,T=n("building").count+g.nodes.filter(S=>S.stage!=="building"&&S.round).length;return e.jsxs("div",{className:"min-h-full bg-gray-50","data-live-page":!0,children:[e.jsx("style",{children:_s}),e.jsxs("div",{className:"mx-auto max-w-[1600px] px-4 pb-12 pt-16 sm:px-8 md:pt-8",children:[e.jsxs("header",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-gray-900",children:"Pipeline live"}),!r&&e.jsx("p",{className:"mt-1 max-w-2xl text-sm text-gray-600",children:"Every ticket of the bug pipeline on its stage, from intake to shipped. Amber is your move."})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[r?e.jsxs("span",{className:`uh-live-connection ${m?"offline":""}`,children:[e.jsx("span",{className:"uh-dot"}),m?"Reconnecting · last known state":"Live · updates automatically"]}):e.jsx(vs,{sync:i,now:j,failed:m,mounted:f}),e.jsxs(Z,{href:r?h.reviewHref:"/administration/claims",className:"inline-flex min-h-[36px] items-center gap-1 rounded-full bg-white px-3.5 text-sm font-medium text-gray-700 ring-1 ring-gray-200 transition-colors hover:bg-gray-100 hover:text-gray-900",children:[r?"Review findings":"Open the cockpit",e.jsx(oe,{className:"h-4 w-4 text-gray-400","aria-hidden":!0})]})]})]}),d,e.jsxs("section",{"aria-label":"Summary",className:"mt-6 grid grid-cols-2 gap-3 lg:grid-cols-[minmax(0,2.4fr)_minmax(0,1fr)_minmax(0,1fr)]",children:[e.jsx("div",{"data-waiting-on-you":!0,className:"col-span-2 rounded-2xl lg:col-span-1 bg-amber-50 p-5 ring-1 ring-amber-300",children:e.jsxs("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-center",children:[e.jsxs("div",{className:"sm:w-48 sm:shrink-0",children:[e.jsx("p",{className:"text-sm font-semibold text-amber-900",children:"Waiting on you"}),e.jsx("p",{"data-waiting-total":!0,className:"mt-1 text-5xl font-semibold leading-none tracking-tight text-amber-950 tabular-nums",children:e.jsx(de,{value:_.total})}),e.jsx("p",{className:"mt-2 text-xs text-amber-800",children:_.oldest?e.jsxs(e.Fragment,{children:["Longest wait:"," ",e.jsx(Z,{href:_.oldest.href||ae(_.oldest.stage,_.oldest.key),"data-oldest":!0,className:"font-semibold underline decoration-amber-400 underline-offset-2 hover:decoration-amber-700",children:_.oldest.key}),", filed ",G(_.oldest.created,j)]}):r?_.total?"Review the decisions and blockers below":"No outstanding decisions or blockers":"tickets on your tabs"})]}),e.jsxs("div",{className:"grid flex-1 grid-cols-2 gap-2",children:[e.jsx(re,{tab:"validate",label:"To validate",value:_.validate,href:n("validate").href}),e.jsx(re,{tab:"decide",label:"Needs decision",value:_.decide,href:n("decide").href}),e.jsx(re,{tab:"manual",label:r?"Blocked":"Manual",value:_.manual,href:n("manual").href}),e.jsx(re,{tab:"merge",label:r?"Review later":"Ready to merge",value:r?_.parked:_.merge,href:r?h.reviewHref:n("merge").href,note:_.held?`${_.held} held`:null})]})]})}),e.jsx(Pe,{label:"Pipeline working",value:T+n("queued").count+(r?n("merge").count:0),lines:r?[`${T} investigating · ${n("merge").count} verifying`,`${n("queued").count} queued`]:[`${T} building now`,`${n("queued").count} in the fix queue`]}),e.jsx(Pe,{label:`${r?"Accepted":"Shipped"}, ${ne} days`,value:n("shipped").count,tone:"done",lines:f?[`${g.today.shipped.length} today`,`${g.today.filed.length} new item${g.today.filed.length===1?"":"s"} today`]:[" "," "]})]}),e.jsxs("section",{"aria-labelledby":"flow-title",className:"mt-8",children:[e.jsxs("div",{className:"flex flex-wrap items-baseline justify-between gap-2",children:[e.jsx("h2",{id:"flow-title",className:"text-sm font-semibold text-gray-900",children:"Flow"}),e.jsx(js,{looks:new Set(g.nodes.map(bt)),filedToday:f&&g.today.filed.length>0})]}),e.jsx("div",{"data-flow":!0,className:"mt-3 grid grid-cols-1 gap-3 md:grid-cols-3 xl:grid-cols-6 xl:gap-5",children:(r?[["validate"],["queued"],["building"],["merge"],["decide","manual"],["shipped"]]:ms).map((S,E)=>e.jsxs("div",{className:"relative flex min-w-0 flex-col gap-3",children:[E>0&&e.jsx(ys,{}),S.map(y=>e.jsx(bs,{stage:n(y),nodeProps:k,now:j},y))]},S.join("+")))})]}),l,e.jsxs("section",{className:"mt-8 grid grid-cols-1 gap-3 lg:grid-cols-[minmax(0,2fr)_minmax(0,1fr)]",children:[e.jsx(Cs,{days:g.shipped,mounted:f,workspace:r}),e.jsx(Ss,{today:g.today,mounted:f,nodeProps:k,workspace:r})]})]}),p&&M&&e.jsx(ws,{node:M,rect:p.rect,pinned:p.pinned,now:j,onClose:D,workspace:r})]})}function vs({sync:t,now:a,failed:r,mounted:d}){const l=!t||a-t.at>hs,h=t?`${t.kind==="push"?"Synced":"Last change"} ${G(t.at,a)}`:"No sync received yet";return e.jsxs("p",{"data-sync-pill":!0,title:t&&d?new Date(t.at).toLocaleString():void 0,className:`inline-flex min-h-[36px] items-center gap-2 rounded-full px-3.5 text-sm ring-1 ${l||r?"bg-amber-50 text-amber-900 ring-amber-200":"bg-white text-gray-700 ring-gray-200"}`,children:[e.jsxs("span",{className:"relative flex h-2 w-2","aria-hidden":!0,children:[!l&&!r&&e.jsx("span",{className:"live-ping absolute inline-flex h-full w-full rounded-full bg-emerald-400"}),e.jsx("span",{className:`relative inline-flex h-2 w-2 rounded-full ${l||r?"bg-amber-500":"bg-emerald-500"}`})]}),e.jsxs("span",{children:[r?"Could not refresh, retrying. ":"",h,l&&t?": the pipeline may be stopped":""]})]})}function re({tab:t,label:a,value:r,note:d,href:l}){return e.jsxs(Z,{href:l||ae(t),"data-wait-tile":t,className:"flex min-h-[48px] items-center gap-2.5 rounded-xl bg-white/80 px-3 py-2 ring-1 ring-amber-200 transition-colors hover:bg-white hover:ring-amber-400",children:[e.jsx("span",{"data-wait-count":!0,className:"w-9 shrink-0 text-2xl font-semibold leading-none text-amber-950 tabular-nums",children:e.jsx(de,{value:r})}),e.jsxs("span",{className:"min-w-0 leading-tight",children:[e.jsx("span",{className:"block text-[13px] font-medium text-amber-950",children:a}),d&&e.jsx("span",{className:"block text-xs text-amber-800",children:d})]}),e.jsx(oe,{className:"ml-auto h-4 w-4 shrink-0 text-amber-400","aria-hidden":!0})]})}function Pe({label:t,value:a,lines:r,tone:d}){return e.jsxs("div",{className:"rounded-2xl bg-white p-4 ring-1 ring-gray-200 sm:p-5",children:[e.jsx("p",{className:"text-sm font-semibold text-gray-900",children:t}),e.jsx("p",{className:`mt-1 text-4xl font-semibold leading-none tracking-tight tabular-nums ${a?d==="done"?"text-emerald-800":"text-gray-900":"text-gray-400"}`,children:e.jsx(de,{value:a})}),e.jsx("ul",{className:"mt-3 space-y-0.5 text-xs text-gray-600",children:r.map((l,h)=>e.jsx("li",{children:l},h))})]})}function de({value:t}){return e.jsx("span",{className:"live-num inline-block",children:t},t)}function js({looks:t,filedToday:a}){const d=[["you","Your move"],["held","Held, your call"],["pipeline","Pipeline's move"],["building","Building"],["parked","Parked"],["done","Shipped"]].filter(([l])=>l==="you"||t.has(l));return e.jsxs("ul",{"aria-label":"Legend",className:"flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-gray-600",children:[d.map(([l,h])=>e.jsxs("li",{className:"inline-flex items-center gap-1.5",children:[e.jsx("span",{className:`inline-block h-3 w-4 rounded ring-1 ring-inset ${yt[l]}`,"aria-hidden":!0}),h]},l)),a&&e.jsxs("li",{className:"inline-flex items-center gap-1.5",children:[e.jsx("span",{className:"inline-block h-1.5 w-1.5 rounded-full bg-indigo-500","aria-hidden":!0}),"Filed today"]})]})}function ys(){return e.jsxs(e.Fragment,{children:[e.jsx("span",{"aria-hidden":!0,className:"absolute -left-[18px] top-[22px] hidden h-5 w-5 items-center justify-center text-gray-300 xl:flex",children:e.jsx(ns,{className:"h-4 w-4"})}),e.jsx("span",{"aria-hidden":!0,className:"-mb-1 -mt-1 flex justify-center text-gray-300 md:hidden",children:e.jsx(ts,{className:"h-4 w-4"})})]})}function bs({stage:t,nodeProps:a,now:r}){const d=ps[t.owner],l=t.owner==="you";let h=t.nodes,m=0;t.key==="shipped"&&h.length>ve&&(m=h.length-ve,h=h.slice(0,ve));const v=t.key==="validate"?h.filter(u=>u.turn==="parked"):[],j=t.key==="decide"?h.filter(u=>u.turn==="pipeline"):[],x=h.filter(u=>!v.includes(u)&&!j.includes(u)),f=t.key==="shipped"&&t.nodes[0]?.at;return e.jsxs("div",{"data-stage":t.key,className:`flex min-w-0 flex-col rounded-2xl bg-white ring-1 ${l&&t.count?"ring-amber-300":"ring-gray-200"}`,children:[e.jsxs("div",{className:"flex items-start justify-between gap-2 px-3 pb-2 pt-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("span",{className:`inline-block rounded-full px-1.5 py-px text-[11px] font-medium ${d.cls}`,children:d.label}),e.jsx("h3",{className:"mt-1 truncate text-[13px] font-semibold text-gray-900",children:t.label})]}),e.jsx("span",{"data-stage-count":!0,className:`text-2xl font-semibold leading-none tabular-nums ${l&&t.count?"text-amber-950":"text-gray-900"}`,children:e.jsx(de,{value:t.count})})]}),e.jsx("p",{className:"px-3 text-xs leading-snug text-gray-500",children:f?`Latest ${G(f,r)}`:t.hint}),e.jsxs("div",{className:"flex flex-1 flex-col gap-2 px-3 pb-3 pt-2.5",children:[x.length>0&&e.jsx(se,{nodes:x,phoneCap:t.key==="shipped"?9:null,...a}),j.length>0&&e.jsx(He,{label:`${j.length} answered, pipeline's move`,children:e.jsx(se,{nodes:j,...a})}),v.length>0&&e.jsx(He,{label:`${v.length} parked with Later`,children:e.jsx(se,{nodes:v,...a})}),!h.length&&e.jsx("p",{className:"text-xs text-gray-500",children:"Nothing here right now."})]}),e.jsxs(Z,{href:t.href||ae(t.key),className:"mt-auto flex min-h-[36px] items-center justify-between border-t border-gray-100 px-3 text-xs font-medium text-gray-500 transition-colors hover:text-gray-900",children:[t.linkLabel||(m?`${m} more on the cockpit`:"Open on the cockpit"),e.jsx(oe,{className:"h-4 w-4 text-gray-300","aria-hidden":!0})]})]})}function He({label:t,children:a}){return e.jsxs("div",{className:"border-t border-dashed border-gray-200 pt-2",children:[e.jsx("p",{className:"mb-1.5 text-xs text-gray-500",children:t}),a]})}function se({nodes:t,phoneCap:a=null,...r}){return e.jsx("ul",{className:"flex flex-wrap gap-2 sm:gap-[5px]",children:t.map((d,l)=>e.jsx(ks,{node:d,hideOnPhone:a!=null&&l>=a,...r},d.key))})}function ks({node:t,prefix:a,arrived:r,mounted:d,onShow:l,onHide:h,pinnedKey:m,hideOnPhone:v}){const j=o.useRef(!1),x=t.displayKey||(a&&t.key.startsWith(a)?t.key.slice(a.length):t.key);return e.jsx("li",{className:v?"hidden sm:block":void 0,children:e.jsxs(Z,{href:t.href||ae(t.stage,t.key),"data-live-node":t.key,"data-turn":t.turn,"aria-label":`${t.key}${t.held?" (held)":""}: ${t.status}`,onPointerDown:f=>{j.current=f.pointerType==="touch"},onMouseEnter:f=>l(t,f.currentTarget),onMouseLeave:h,onFocus:f=>l(t,f.currentTarget),onBlur:h,onClick:f=>{j.current&&m!==t.key&&(f.preventDefault(),l(t,f.currentTarget,!0))},className:`relative inline-flex h-9 min-w-[48px] items-center justify-center rounded-md px-1 font-mono text-[13px] sm:h-7 sm:min-w-[42px] sm:text-[12px] tabular-nums ring-1 ring-inset transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-gray-900 ${yt[bt(t)]} ${t.turn==="you"?"font-semibold":""} ${r.has(t.key)?"live-arrive":""}`,children:[x,(t.stage==="building"||t.round)&&e.jsx("span",{className:"live-pulse absolute -right-0.5 -top-0.5 h-2 w-2 rounded-full bg-sky-500 ring-2 ring-white","aria-hidden":!0}),d&&t.newToday&&!(t.stage==="building"||t.round)&&e.jsx("span",{className:"absolute -right-0.5 -top-0.5 h-2 w-2 rounded-full bg-indigo-500 ring-2 ring-white","aria-hidden":!0})]})})}function ws({node:t,rect:a,pinned:r,now:d,onClose:l,workspace:h=!1}){const v=typeof window>"u"?1440:window.innerWidth,j=typeof window>"u"?900:window.innerHeight,x=Math.max(8,Math.min(a.left+a.width/2-288/2,v-288-8)),f=a.bottom+8,u=f+170>j?{left:x,bottom:j-a.top+8,width:288}:{left:x,top:f,width:288},g=t.stage==="shipped"?t.at?`${h?"Accepted":"Merged"} ${G(t.at,d)}`:null:t.stage==="manual"?t.at?`Stopped ${G(t.at,d)}`:null:t.created?`Filed ${G(t.created,d)}`:null;return e.jsxs(e.Fragment,{children:[r&&e.jsx("button",{type:"button","aria-label":"Close",onClick:l,className:"fixed inset-0 z-40 cursor-default bg-transparent"}),e.jsxs("div",{role:r?"dialog":"tooltip","data-node-detail":t.key,style:u,className:`fixed z-50 rounded-xl bg-white p-3.5 text-left shadow-lg ring-1 ring-gray-200 ${r?"":"pointer-events-none"}`,children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsx("p",{className:"font-mono text-xs font-semibold text-gray-900",children:t.key}),r&&e.jsx("button",{type:"button",onClick:l,"aria-label":"Close",className:"-m-1 rounded p-1 text-gray-400 hover:text-gray-700",children:e.jsx(rs,{className:"h-4 w-4"})})]}),t.title&&e.jsx("p",{className:"mt-1 line-clamp-2 text-sm font-medium leading-snug text-gray-900",children:t.title}),e.jsx("p",{className:`mt-1.5 line-clamp-3 text-xs leading-relaxed ${t.turn==="you"?"text-amber-900":"text-gray-600"}`,children:t.status}),(g||t.flags.length>0)&&e.jsx("p",{className:"mt-1.5 text-[11px] text-gray-500",children:[g,t.newToday?"new today":null,...t.flags].filter(Boolean).join(" · ")}),r?e.jsxs(Z,{href:t.href||ae(t.stage,t.key),className:"mt-3 flex min-h-[40px] items-center justify-center gap-1 rounded-lg bg-gray-900 text-sm font-medium text-white",children:["Open the card ",e.jsx(oe,{className:"h-4 w-4","aria-hidden":!0})]}):e.jsx("p",{className:"mt-2 text-[11px] text-gray-500",children:"Click to open the card"})]})]})}function Ns(t){if(t<=4)return 4;const a=t<=10?2:t<=25?5:t<=50?10:20;return Math.ceil(t/a)*a}function Cs({days:t,mounted:a,workspace:r=!1}){const d=r?"accepted":"shipped",[l,h]=o.useState(null),m=Ns(Math.max(0,...t.map(u=>u.count))),v=t.reduce((u,g)=>u+g.count,0),j=t.reduce((u,g,C)=>g.count>(t[u]?.count||0)?C:u,0),x=t.filter(u=>!u.known).length,f=160;return e.jsxs("figure",{"data-shipped-chart":!0,className:"rounded-2xl bg-white p-5 ring-1 ring-gray-200",children:[e.jsxs("figcaption",{className:"flex flex-wrap items-baseline justify-between gap-2",children:[e.jsx("span",{className:"text-sm font-semibold text-gray-900",children:r?"Accepted per day":"Shipped per day"}),e.jsx("span",{className:"text-xs text-gray-500",children:a?`${v} in the last ${ke} days`:" "})]}),e.jsxs("div",{className:"relative mt-4",style:{height:f+24},children:[[0,.5,1].map(u=>e.jsxs("div",{className:"absolute left-7 right-0 flex items-center",style:{bottom:24+u*f},children:[e.jsx("span",{className:"absolute -left-7 w-6 -translate-y-px text-right text-[11px] tabular-nums text-gray-500",children:a?Math.round(m*u):""}),e.jsx("span",{className:`h-px w-full ${u===0?"bg-gray-300":"bg-gray-100"}`})]},u)),a&&e.jsx("div",{className:"absolute bottom-0 left-7 right-0 top-0 flex items-stretch gap-[2px]",children:t.map((u,g)=>{const C=g===t.length-1,s=u.count?Math.max(3,u.count/m*f):0,i=new Date(u.start),n=C||g%2===(t.length-1)%2,p=n&&t.findIndex((N,$)=>$%2===(t.length-1)%2)===g,w=`${i.toLocaleDateString(void 0,Ie)}: ${u.known?`${u.count} ${d}`:"no record"}`;return e.jsxs("div",{"data-day":`${i.getFullYear()}-${String(i.getMonth()+1).padStart(2,"0")}-${String(i.getDate()).padStart(2,"0")}`,"data-count":u.count,"data-known":u.known?"yes":"no",tabIndex:0,"aria-label":w,className:"relative flex min-w-0 flex-1 flex-col justify-end rounded-sm focus:outline-none focus-visible:ring-2 focus-visible:ring-gray-900",onMouseEnter:()=>h(g),onMouseLeave:()=>h(null),onFocus:()=>h(g),onBlur:()=>h(null),onClick:()=>h(l===g?null:g),children:[e.jsxs("div",{className:`relative mx-auto flex w-full flex-col justify-end ${C?"rounded-t-md bg-gray-50":""}`,style:{height:f},children:[!u.known&&e.jsx("div",{"aria-hidden":!0,className:"absolute inset-x-0 bottom-0 top-0 [background-image:repeating-linear-gradient(135deg,rgb(243_244_246)_0_2px,transparent_2px_7px)]"}),(g===j||C)&&u.known&&(u.count>0||C)&&e.jsx("span",{className:"relative mb-1 text-center text-[11px] font-medium tabular-nums text-gray-700",children:u.count}),e.jsx("div",{className:`relative mx-auto w-full max-w-[28px] rounded-t-[4px] ${C?"bg-emerald-700":"bg-emerald-500"} ${l===g?"opacity-80":""}`,style:{height:s}})]}),e.jsx("span",{className:`block h-6 whitespace-nowrap pt-1.5 text-center text-[11px] leading-none tabular-nums ${C?"font-semibold text-gray-800":"text-gray-500"}`,children:n&&(C?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"sm:hidden",children:i.getDate()}),e.jsx("span",{className:"hidden sm:inline",children:"Today"})]}):p?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"sm:hidden",children:i.getDate()}),e.jsx("span",{className:"hidden sm:inline",children:i.toLocaleDateString(void 0,{day:"numeric",month:"short"})})]}):i.getDate())}),l===g&&e.jsxs("div",{role:"tooltip",className:`pointer-events-none absolute bottom-full z-10 mb-1 w-max max-w-[220px] rounded-lg bg-gray-900 px-2.5 py-1.5 text-xs text-white shadow-lg ${g>t.length/2?"right-0":"left-0"}`,children:[e.jsx("p",{className:"font-medium",children:i.toLocaleDateString(void 0,Ie)}),e.jsx("p",{className:"text-gray-300",children:u.known?`${u.count} ${d}${u.count?`: ${u.keys.slice(0,4).join(", ")}${u.keys.length>4?` and ${u.keys.length-4} more`:""}`:""}`:"Before this page's records"})]})]},u.start)})})]}),e.jsxs("p",{className:"mt-3 max-w-prose text-xs leading-relaxed text-gray-500",children:[r?"Accepted findings and applied guidelines, counted on the date of your decision.":"Counted from each ticket’s merge date on GitHub.",a&&x>0?" Hatched days come before this page's records: no data, not zero.":""]})]})}function Ss({today:t,mounted:a,nodeProps:r,workspace:d=!1}){return e.jsxs("div",{"data-today":!0,className:"self-start rounded-2xl bg-white p-5 ring-1 ring-gray-200",children:[e.jsx("p",{className:"text-sm font-semibold text-gray-900",children:"Today"}),e.jsxs("div",{className:"mt-3 space-y-4",children:[e.jsxs("div",{children:[e.jsxs("p",{className:"mb-1.5 text-xs text-gray-600",children:[e.jsx("span",{className:"font-semibold tabular-nums text-gray-900",children:a?t.filed.length:""})," ",d?"items started today":"filed on Jira today, still open"]}),a&&(t.filed.length?e.jsx(se,{nodes:t.filed,...r}):e.jsx("p",{className:"text-xs text-gray-500",children:"None yet"}))]}),e.jsxs("div",{children:[e.jsxs("p",{className:"mb-1.5 text-xs text-gray-600",children:[e.jsx("span",{className:"font-semibold tabular-nums text-gray-900",children:a?t.shipped.length:""})," ",d?"accepted today":"shipped today"]}),a&&(t.shipped.length?e.jsx(se,{nodes:t.shipped,...r}):e.jsx("p",{className:"text-xs text-gray-500",children:"None yet"}))]})]})]})}function $s(t){if(!t.length)return"";const a=/^[A-Z][A-Z0-9]+-/.exec(t[0])?.[0]||"";return a&&t.every(r=>r.startsWith(a))?a:""}const _s=`
|
|
7
|
+
@keyframes live-ping { 75%, 100% { transform: scale(2.2); opacity: 0; } }
|
|
8
|
+
@keyframes live-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
|
|
9
|
+
@keyframes live-arrive { from { box-shadow: 0 0 0 3px rgb(99 102 241 / .45); } to { box-shadow: 0 0 0 0 rgb(99 102 241 / 0); } }
|
|
10
|
+
@keyframes live-num { from { opacity: .25; } to { opacity: 1; } }
|
|
11
|
+
.live-ping { animation: live-ping 2s cubic-bezier(0, 0, .2, 1) infinite; }
|
|
12
|
+
.live-pulse { animation: live-pulse 1.6s ease-in-out infinite; }
|
|
13
|
+
.live-arrive { animation: live-arrive 2.4s ease-out 1; }
|
|
14
|
+
.live-num { animation: live-num .6s ease-out 1; }
|
|
15
|
+
@media (prefers-reduced-motion: reduce) { .live-ping, .live-pulse, .live-arrive, .live-num { animation: none; } }
|
|
16
|
+
`;function Rs(t,a,r,d=!1){const l=new Set(a.map(i=>i.id)),h=new Set(t.workspace.projects.filter(i=>r==="all"||i.id===r).flatMap(i=>i.repos.map(n=>n.name))),m=i=>r==="all"||l.has(i.pipelineId)||h.has(i.finding?.repo),v=(i,n={})=>{const p=new URLSearchParams({...r==="all"?{}:{project:r},...n});return`/${i}${p.size?`?${p}`:""}`},j=[{key:"validate",label:"To validate",owner:"you",hint:"Findings awaiting your go-ahead.",href:v("review",{tab:"validate"}),linkLabel:"Review validation"},{key:"queued",label:"Queued",owner:"pipeline",hint:"Investigations waiting for the engine.",href:"#live-activity",linkLabel:"See activity"},{key:"building",label:"Investigating",owner:"pipeline",hint:"Reading signals and tracing their cause.",href:"#live-activity",linkLabel:"See agent steps"},{key:"merge",label:"Verifying",owner:"pipeline",hint:"Checking evidence and challenging findings.",href:"#live-activity",linkLabel:"See verification"},{key:"decide",label:"Needs decision",owner:"you",hint:"Prepared findings and guideline proposals.",href:v("review",{tab:"decide"}),linkLabel:"Open review"},{key:"manual",label:"Blocked",owner:"you",hint:"Access, capacity, or a run needs attention.",href:"#live-activity",linkLabel:"Inspect blockers"},{key:"shipped",label:"Accepted",owner:"done",hint:"Findings accepted and guidelines applied in the last 7 days.",href:v("review",{tab:"shipped"}),linkLabel:"Review accepted"}],x=t.runs.filter(m),f=(t.pipelines.queued||[]).filter(i=>r==="all"||l.has(i.pipelineId)),u=[];for(const i of t.cockpit.cards.filter(m)){const n=i.finding;if(!n||i.ruling?.ruling==="dismiss")continue;const p=i.ruling?.ruling,w=["pending","later"].includes(n.validation?.state),N=p==="file"?"shipped":w?"validate":"decide",$=p==="park"||n.validation?.state==="later";u.push({key:`F-${n.id}`,title:i.title,live_stage:N,live_href:v("review",{finding:n.id}),live_state:{turn:p==="file"?"done":$?"parked":"you",status:p==="file"?"You accepted this finding.":$?"Set aside for later review.":w?"Waiting for your validation.":"Evidence prepared. Waiting for your decision."},jira_created:n.createdAt,createdAt:n.createdAt,merged_at:p==="file"?i.ruling.at:null})}for(const i of(t.cockpit.proposals||[]).filter(m)){if(!["pending","parked","applied"].includes(i.status))continue;const n=i.status==="applied";u.push({key:`G-${i.id}`,title:i.title,live_stage:n?"shipped":"decide",live_href:v("review",{tab:n?"shipped":"decide",proposal:i.id,pipeline:i.pipelineId}),live_state:{turn:n?"done":i.status==="parked"?"parked":"you",status:n?"Guideline improvement applied.":"Review the proposed guideline change."},createdAt:i.createdAt,jira_created:i.createdAt,merged_at:n?i.rulings?.at(-1)?.at:null})}const g=x.filter(i=>!["done","failed"].includes(i.phase)),C=[];for(const i of g){const n=i.steps?.find(N=>N.status==="running"),p=n&&["gate","adversarial","dedupe"].includes(n.step),w=i.phase==="parked";u.push({key:`RUN-${i.id}`,title:i.pipelineName||i.pipelineId,live_stage:w?"manual":p?"merge":"building",live_href:`#run-${i.id}`,live_state:{turn:w?"parked":"pipeline",status:w?`Waiting for capacity${i.parkedUntil?` until ${new Date(i.parkedUntil).toLocaleString()}`:""}.`:n?`${n.step.replaceAll("_"," ")}: ${n.clusterTitle}`:i.phase.replaceAll("_"," ")},createdAt:i.startedAt,jira_created:i.startedAt})}for(const i of f)u.push({key:`QUEUE-${i.pipelineId}`,title:a.find(n=>n.id===i.pipelineId)?.name||i.pipelineId,live_stage:"queued",live_href:"#live-activity",live_state:{turn:"pipeline",status:"Queued behind the current investigation."},createdAt:i.at,jira_created:i.at});for(const i of a){if(g.some(M=>M.pipelineId===i.id)||f.some(M=>M.pipelineId===i.id))continue;const n=x.find(M=>M.pipelineId===i.id),p=t.workspace.projects.flatMap(M=>M.repos).filter(M=>(!i.repos||i.repos.includes(M.name))&&!M.available),w=i.sources.filter(M=>M!=="repos"&&M!=="*"&&!t.workspace.connections.some(k=>k.id===M&&k.configured&&k.probe?.ok)),N=p.length?`Repository unavailable: ${p.map(M=>M.name).join(", ")}`:t.workspace.provider.authenticated?w.length?`Read access needed: ${w.join(", ")}`:n?.phase==="failed"?n.error||"Last investigation failed. Inspect its steps.":"":t.workspace.provider.detail;if(!N)continue;const $=p.length?"Repository access":t.workspace.provider.authenticated?w.length?"Source access":"Failed run":"Claude account",D=`#blocker-${i.id}`;C.push({id:i.id,name:i.name,detail:N,href:D,kind:$}),u.push({key:`BLOCKER-${i.id}`,displayKey:$,title:`${i.name} · ${$}`,live_stage:"manual",live_href:D,live_state:{turn:"you",status:N}})}const s=[...x.map(i=>i.startedAt),...u.map(i=>i.createdAt)].filter(Boolean).sort();return{tickets:u,stages:j,read_at:new Date().toISOString(),historyStart:s[0]||null,sync:null,reviewHref:v("review",{tab:"decide"}),offline:d,runs:x,queued:f,active:g,blocked:C,agents:g.flatMap(i=>(i.steps||[]).filter(n=>n.status==="running"&&n.model)),cost:x.reduce((i,n)=>i+(n.costUsd||0),0),settingsHref:v("pipelines"),projectsHref:v("projects")}}const Q=t=>t?.replaceAll("_"," ")||"",le=t=>t?new Date(t).toLocaleString(void 0,{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}):"";function Ms({data:t,pipelines:a,project:r,offline:d,act:l,chatFirst:h=!1}){const m=o.useMemo(()=>{const n=Rs(t,a,r,d);return h?{...n,settingsHref:"/chat?message=Show%20my%20pipelines",projectsHref:"/chat?message=Help%20me%20run%20a%20pipeline"}:n},[t,a,r,d,h]),[v,j]=o.useState(""),[x,f]=o.useState(!1),[u,g]=o.useState(""),C=m.blocked.find(n=>n.id===v),s=t.workspace.provider,i=e.jsxs("section",{id:"live-activity",className:"uh-live-activity",children:[e.jsxs("div",{className:"uh-section-heading",children:[e.jsx("div",{children:e.jsx("h2",{children:"Engine activity"})}),!h&&e.jsx("a",{className:"uh-btn",href:"/runs",children:"Full run history"}),e.jsxs("a",{className:"uh-btn",href:m.settingsHref,children:[e.jsx(Ot,{size:15}),h?"Manage in chat":"Manage pipelines"]})]}),m.blocked.map(n=>e.jsxs("a",{className:"uh-live-blocker",href:n.href,children:[e.jsx("span",{className:"uh-dot warn"}),e.jsxs("div",{children:[e.jsx("strong",{children:n.name}),e.jsx("p",{children:n.detail})]}),e.jsx(H,{size:17})]},n.id)),m.queued.map((n,p)=>e.jsxs("div",{className:"uh-live-queued",children:[e.jsx(Ee,{size:16}),e.jsxs("span",{children:["#",p+1," in queue"]}),e.jsx("strong",{children:a.find(w=>w.id===n.pipelineId)?.name||n.pipelineId}),e.jsx("span",{children:le(n.at)})]},n.pipelineId)),!m.runs.length&&e.jsxs("div",{className:"uh-live-empty",children:[e.jsx(we,{size:22}),e.jsx("h3",{children:"No runs yet"}),e.jsx("p",{children:m.blocked.length?"Resolve the blocker above to run the pipeline.":"Start a pipeline to see its progress here."}),e.jsxs("a",{className:"uh-link",href:m.projectsHref,children:[h?"Open chat":"Open projects"," ",e.jsx(H,{size:13})]})]}),m.runs.slice(0,12).map(n=>{const p=!["done","failed"].includes(n.phase),w=n.steps||[];return e.jsxs("details",{className:"uh-live-run",id:`run-${n.id}`,open:p||void 0,children:[e.jsxs("summary",{children:[n.phase==="failed"?e.jsx(Ft,{size:18}):n.phase==="parked"?e.jsx(Ee,{size:18}):p?e.jsx(J,{size:18,className:"uh-spin"}):e.jsx(St,{size:18}),e.jsxs("div",{children:[e.jsx("strong",{children:n.pipelineName||n.pipelineId}),e.jsxs("span",{children:[Q(n.phase)," · ",le(n.startedAt)]})]}),e.jsxs("span",{children:[n.signalsCollected??0," signals"]}),e.jsxs("span",{children:[n.findings??0," findings"]}),e.jsxs("span",{children:["$",(n.costUsd||0).toFixed(3)]}),e.jsx(Oe,{size:16})]}),e.jsxs("div",{className:"uh-live-run-body",children:[e.jsx("div",{className:"uh-live-phases",children:(n.phases||[]).map((N,$)=>e.jsxs("div",{"data-state":N.status,children:[e.jsx("span",{className:`uh-dot ${N.status==="failed"?"warn":""}`}),e.jsx("strong",{children:Q(N.phase)}),e.jsx("span",{children:N.status})]},$))}),w.length>0&&e.jsx("div",{className:"uh-live-steps",children:w.map((N,$)=>e.jsxs("div",{children:[e.jsx("span",{className:`uh-live-step-state ${N.status}`,children:Q(N.status)}),e.jsxs("div",{children:[e.jsxs("strong",{children:[Q(N.step)," · ",N.clusterTitle||"Investigation"]}),N.note&&e.jsx("p",{children:N.note}),e.jsxs("small",{children:[N.model||"Evidence check",N.startedAt?` · ${le(N.startedAt)}`:""]})]}),N.costUsd!=null&&e.jsxs("span",{children:["$",N.costUsd.toFixed(3)]})]},$))}),(n.sources||[]).map(N=>e.jsxs("p",{className:"uh-live-source",children:[e.jsx("strong",{children:N.pluginId})," · ",N.signals," signals · ",N.ok?"Read completed":"Needs attention",N.note?` · ${N.note}`:""]},N.pluginId)),(n.error||n.emptyReason)&&e.jsx("p",{className:"uh-live-run-note",children:n.error||n.emptyReason}),(n.notes||[]).map((N,$)=>e.jsx("p",{className:"uh-live-run-note",children:N},$)),e.jsxs("small",{className:"uh-muted",children:["Run ",n.id," · ",n.repos?.map(N=>`${N.name} @ ${N.commit?.slice(0,7)||"local checkout"}`).join(", ")]})]})]},n.id)})]});return e.jsxs("div",{className:"uh-live-surface",onClick:n=>{const p=n.target.closest("a")?.getAttribute("href");if(p?.startsWith("#blocker-")&&(n.preventDefault(),j(p.slice(9)),g("")),p?.startsWith("#run-")){const w=document.getElementById(p.slice(1));w instanceof HTMLDetailsElement&&(w.open=!0)}},children:[e.jsx(fs,{initial:m,snapshot:m,workspace:!0,activity:i,children:e.jsxs("div",{className:"uh-live-system",children:[e.jsxs("div",{children:[e.jsx("span",{children:"Engine"}),e.jsxs("strong",{children:[e.jsx("span",{className:`uh-dot ${d?"warn":""}`}),d?"Reconnecting":"Online"]})]}),e.jsxs("div",{children:[e.jsx("span",{children:"Configured pipelines"}),e.jsxs("strong",{children:[a.length,e.jsxs("small",{children:[a.filter(n=>n.enabled&&n.schedule!=="manual").length," scheduled"]})]})]}),e.jsxs("div",{children:[e.jsx("span",{children:"Active agents"}),e.jsxs("strong",{children:[m.agents.length,e.jsx("small",{children:m.agents.map(n=>Q(n.step)).join(", ")||"No model call running"})]})]}),e.jsxs("div",{children:[e.jsx("span",{children:"Recent run cost"}),e.jsxs("strong",{children:["$",m.cost.toFixed(3),e.jsxs("small",{children:[m.runs.length," recorded runs · ",t.workspace.reserve,"% reserve"]})]})]})]})}),v&&e.jsx(Ne,{title:C?`${C.kind} · ${C.name}`:"Access verified",close:()=>j(""),children:e.jsxs("div",{className:"uh-live-blocker-detail",children:[e.jsx("p",{children:C?.detail||"The account check succeeded. Your pipeline is ready to run with its saved settings."}),C?.kind==="Claude account"&&e.jsxs(e.Fragment,{children:[e.jsxs("dl",{children:[e.jsx("dt",{children:"Claude Code"}),e.jsxs("dd",{children:[s.available?"Installed":"Not found",s.cliVersion?` · ${s.cliVersion}`:""]}),e.jsx("dt",{children:"Account source"}),e.jsx("dd",{children:s.authMethod||"Local Claude login"}),s.configDirectory&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:"Claude configuration"}),e.jsx("dd",{children:e.jsx("code",{children:s.configDirectory})})]}),s.verifiedAt&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:"Last live check"}),e.jsx("dd",{children:le(s.verifiedAt)})]})]}),s.command&&e.jsxs("div",{className:"uh-activation-command",children:[e.jsx("code",{children:s.command}),e.jsx("button",{className:"uh-btn",onClick:()=>navigator.clipboard.writeText(s.command).catch(()=>g("Copy the command into your terminal.")),children:"Copy command"})]})]}),u&&e.jsx("p",{role:"alert",className:"uh-error",children:u}),e.jsxs("div",{className:"uh-modal-actions",children:[e.jsx("button",{className:"uh-btn",onClick:()=>j(""),children:"Close"}),C?.kind==="Claude account"?e.jsx("button",{className:"uh-btn primary",disabled:x,onClick:async()=>{f(!0),g("");try{await l("/api/workspace/provider/check",{})}catch(n){g(n.message)}finally{f(!1)}},children:x?"Checking Claude access…":"Check Claude access"}):C?.kind==="Source access"?e.jsx("a",{className:"uh-btn primary",href:h?"/chat":"/settings?tab=connections",children:"Manage source connection"}):C?.kind==="Failed run"?e.jsx("a",{className:"uh-btn primary",onClick:()=>j(""),href:`#run-${m.runs.find(n=>n.pipelineId===C.id)?.id}`,children:"Inspect run"}):null]})]})})]})}function zs(){return/\/setup$|\/projects$/.test(location.pathname)?"setup":/pipeline-live|\/runs$/.test(location.pathname)?"pipeline-live":/\/review$|\/results$|\/claims$|cockpit/.test(location.pathname)?"review":"chat"}const je=[{id:"chat",name:"Chat",href:"/chat",icon:Pt},{id:"setup",name:"Setup",href:"/setup",icon:It},{id:"pipeline-live",name:"Pipeline live",href:"/pipeline-live",icon:we},{id:"review",name:"Review",href:"/review?tab=decide",icon:qe}];function Es(){const[t,a]=o.useState(null),[r,d]=o.useState("");return o.useEffect(()=>{let l=!0;return(async()=>{const[{init:h},{default:m}]=await Promise.all([ze(()=>import("./data-provider-CZ2WwK6_.js"),__vite__mapDeps([0,1,2])),ze(()=>import("./page-CYCU6xk1.js"),__vite__mapDeps([3,1,0,2,4]))]),v=new URL(location.href);!v.searchParams.has("tab")&&/\/review$|\/results$/.test(v.pathname)&&(v.searchParams.set("tab",v.pathname==="/results"?"shipped":"decide"),history.replaceState(null,"",v)),await h();const j=await m();l&&a(j)})().catch(h=>{l&&d(h.message)}),()=>{l=!1}},[]),r?e.jsx("p",{role:"alert",className:"uh-error",children:r}):e.jsx("div",{className:"conversation-review",children:t||e.jsxs("p",{className:"conversation-loading",children:[e.jsx(J,{size:16,className:"uh-spin"})," Loading review…"]})})}function As({status:t,close:a,refresh:r}){const[d,l]=o.useState(""),[h,m]=o.useState(t),[v,j]=o.useState(!1),[x,f]=o.useState(""),[u,g]=o.useState(!1),C=async()=>{if(!v){j(!0),f("");try{const s=await W("/api/chat/telegram/connect",d?{token:d}:{});l(""),m(s),await r()}catch(s){f(s.message)}finally{j(!1)}}};return o.useEffect(()=>{const s=setInterval(()=>{O("/api/chat/telegram").then(i=>{m(i),i.paired&&r()}).catch(()=>{})},1500);return()=>clearInterval(s)},[]),e.jsxs(Ne,{title:h?.paired?"Telegram connected":"Connect Telegram",close:a,children:[h?.paired?e.jsx("p",{className:"conversation-modal-copy",children:"Messages here, in Telegram, and in the CLI use the same conversation."}):h?.link?e.jsx("p",{className:"conversation-modal-copy",children:"Open your bot and press Start to connect this conversation."}):e.jsxs("form",{onSubmit:s=>{s.preventDefault(),C()},children:[(!h?.hasToken||u)&&e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"conversation-modal-copy",children:["Create a bot with ",e.jsx("a",{href:"https://t.me/BotFather",target:"_blank",rel:"noreferrer",children:"@BotFather"}),", then enter its token here."]}),e.jsxs("label",{className:"uh-field",children:[e.jsx("span",{children:"Bot token"}),e.jsx("input",{autoFocus:!0,type:"password",autoComplete:"off",value:d,onChange:s=>l(s.target.value),required:!0,placeholder:"123456:…"})]}),e.jsx("p",{className:"conversation-secret-note",children:"Saved locally. Never sent to Claude or stored in chat."})]}),h?.hasToken&&!u&&e.jsxs("p",{className:"conversation-modal-copy",children:["Use the bot token already saved on this machine. ",e.jsx("button",{className:"uh-link",type:"button",onClick:()=>g(!0),children:"Use another token"})]}),e.jsxs("div",{className:"uh-modal-actions",children:[e.jsx("button",{className:"uh-btn",type:"button",onClick:a,children:"Cancel"}),e.jsx("button",{className:"uh-btn primary",type:"submit",disabled:v||(!h?.hasToken||u)&&!d.trim(),children:v?"Checking…":"Connect"})]})]}),h?.link&&e.jsxs("div",{className:"uh-modal-actions",children:[e.jsx("button",{className:"uh-btn",onClick:a,children:"Close"}),e.jsxs("a",{className:"uh-btn primary",href:h.link,target:"_blank",rel:"noreferrer",children:["Open Telegram ",e.jsx(H,{size:15})]})]}),h?.link&&!h.paired&&e.jsx("p",{className:"conversation-secret-note",role:"status",children:"Waiting for you to press Start in Telegram. The link expires after 10 minutes."}),x&&e.jsx("p",{role:"alert",className:"uh-error",children:x})]})}function Ds(){const t=zs(),[a,r]=o.useState(null),[d,l]=o.useState(null),[h,m]=o.useState(!1),[v,j]=o.useState(""),[x,f]=o.useState(!1),[u,g]=o.useState(!1),[C,s]=o.useState(!1),[i,n]=o.useState(""),p=o.useRef(!1),[w,N]=o.useState(new URLSearchParams(location.search).get("project")||"all"),$=o.useCallback(async()=>{if(!p.current){p.current=!0;try{const y=await O("/api/status");_t(y.csrf);const[L,b,R,I,B]=await Promise.all([O("/api/workspace"),O("/api/pipelines"),O("/api/cockpit"),O("/api/runs"),O("/api/chat/telegram")]);r({status:y,workspace:L,pipelines:b,cockpit:R,runs:I.runs}),l(B),f(!1),j("")}catch(y){y instanceof Fe&&y.status===401?j("Open a login link from ultimatehuman dashboard."):f(!0)}finally{p.current=!1}}},[]);o.useEffect(()=>{(async()=>{const b=await Rt();if(b!=="none"&&b!=="ok"){j(b);return}await $()})();const y=setInterval(()=>{$()},5e3),L=Mt(()=>{$()});return()=>{clearInterval(y),L()}},[$]),o.useEffect(()=>{t==="chat"&&a?.workspace.provider.authenticated&&W("/api/chat/start").catch(()=>{})},[t,a?.workspace.provider.authenticated]);const D=async(y,L)=>{const b=await W(y,L);return await $(),b};if(v||!a)return e.jsxs("div",{className:"conversation-access",children:[e.jsxs("a",{href:"/chat",className:"conversation-access-brand",children:[e.jsx(ee,{}),"ultimatehuman",e.jsx("span",{children:"."})]}),e.jsxs("div",{className:"conversation-access-card",children:[e.jsx("span",{className:"eyebrow",children:"YOUR LOCAL WORKSPACE"}),e.jsx("h1",{children:v?"Let’s get you in.":x?"Reconnect your workspace.":"Opening your workspace."}),e.jsx("p",{children:v||(x?"Start the local engine to continue.":"Connecting to the engine on this machine…")}),v||x?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"conversation-command",children:[e.jsx(be,{size:16}),e.jsx("code",{children:"ultimatehuman dashboard"})]}),e.jsxs("button",{className:"uh-btn primary",onClick:()=>{$()},children:["Try again ",e.jsx(H,{size:16})]})]}):e.jsx(J,{size:22,className:"uh-spin"})]}),e.jsx("span",{className:"conversation-access-foot",children:"AUTONOMOUS ENGINEERING. HUMAN JUDGMENT."})]});const M=a.workspace.provider,k=a.workspace.projects.filter(y=>w==="all"||y.id===w).flatMap(y=>y.repos.map(L=>L.name)),_=a.pipelines.config.filter(y=>w==="all"||!y.repos||y.repos.some(L=>k.includes(L))),T=a.workspace.projects.map(y=>y.name),S=a.cockpit.cards.filter(y=>y.finding&&(!y.ruling||["clear","resurfaced"].includes(y.ruling.ruling))).length+(a.cockpit.proposals||[]).filter(y=>y.status==="pending").length,E=a.runs.filter(y=>!["done","failed"].includes(y.phase)).length;return e.jsxs("div",{className:`uh-app conversation-app conversation-page-${t}`,children:[e.jsxs("aside",{className:"conversation-sidebar",children:[e.jsxs("a",{href:"/chat",className:"conversation-brand","aria-label":"ultimatehuman home",children:[e.jsx(ee,{}),e.jsxs("span",{children:["ultimatehuman",e.jsx("b",{children:"."})]})]}),e.jsx("nav",{"aria-label":"Main navigation",children:je.map(({id:y,name:L,href:b,icon:R})=>{const I=y==="review"?S:y==="pipeline-live"?E:0;return e.jsxs("a",{href:b,"aria-current":y===t?"page":void 0,children:[e.jsx(R,{size:18,strokeWidth:1.65}),e.jsx("span",{children:L}),I>0&&e.jsx("b",{className:"conversation-nav-count",children:I}),y===t&&e.jsx(Xe,{size:14,className:"conversation-nav-arrow"})]},y)})}),e.jsx("div",{className:"conversation-sidebar-bottom",children:e.jsxs("div",{className:"conversation-engine-status",children:[e.jsx("span",{className:`uh-dot ${x?"warn":""}`}),x?"Engine offline":"Local engine running"]})})]}),e.jsxs("div",{className:"conversation-main",children:[e.jsxs("header",{className:"conversation-header",children:[e.jsxs("div",{className:"conversation-breadcrumb",children:[e.jsx(ee,{className:"conversation-mobile-mark"}),e.jsx("span",{className:"conversation-breadcrumb-root",children:"Workspace"}),e.jsx("span",{className:"conversation-breadcrumb-slash",children:"/"}),e.jsx("h1",{children:je.find(y=>y.id===t)?.name})]}),e.jsxs("div",{className:"conversation-header-actions",children:[e.jsxs("span",{className:"conversation-local-status",children:[e.jsx("span",{className:`uh-dot ${x?"warn":""}`}),"Local workspace"]}),t==="chat"&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{className:"uh-btn conversation-cli",onClick:()=>{O("/api/chat").then(async y=>{const L=`${y.cliCommand||"ultimatehuman"} chat`;try{await navigator.clipboard.writeText(L),s(!0),setTimeout(()=>s(!1),2500)}catch{n(`Terminal command: ${L}`)}}).catch(y=>n(y.message))},title:"Copy terminal command",children:[e.jsx(be,{size:14}),C?"Copied":"Use CLI"]}),e.jsxs("button",{className:"uh-btn conversation-telegram",onClick:()=>m(!0),children:[e.jsx(Ht,{size:14}),d?.paired?"Telegram":"Connect Telegram",e.jsx(H,{size:13})]})]}),["pipeline-live","setup"].includes(t)&&a.workspace.projects.length>1&&e.jsxs("div",{className:"conversation-project-filter",children:[e.jsx(nt,{size:14}),e.jsxs("select",{"aria-label":"Project filter",value:t==="setup"&&!a.workspace.projects.some(y=>y.id===w)?a.workspace.projects[0].id:w,onChange:y=>N(y.target.value),children:[t!=="setup"&&e.jsx("option",{value:"all",children:"All projects"}),a.workspace.projects.map(y=>e.jsx("option",{value:y.id,children:y.name},y.id))]})]})]})]}),e.jsx("nav",{className:"conversation-mobile-nav","aria-label":"Mobile navigation",children:je.map(({id:y,name:L,href:b,icon:R})=>e.jsxs("a",{href:b,"aria-current":y===t?"page":void 0,children:[e.jsx(R,{size:15}),L]},y))}),x&&e.jsx("div",{className:"conversation-warning",role:"status",children:"Reconnecting to the engine…"}),t==="chat"&&M.authenticated&&i&&e.jsx("div",{className:"conversation-warning",role:"status",children:i}),t==="chat"&&!M.authenticated&&e.jsxs("div",{className:"conversation-warning conversation-account-warning",children:[e.jsx(ot,{size:15}),e.jsxs("div",{children:[e.jsx("strong",{children:i||(M.available?"Claude needs to reconnect.":"Claude Code is not installed.")}),e.jsxs("span",{children:["Run ",e.jsx("code",{children:M.command||"claude auth login"})," in your terminal."]})]}),e.jsxs("button",{className:"uh-btn",disabled:u,onClick:async()=>{g(!0),n("");try{await D("/api/workspace/provider/check",{})}catch(y){n(y.message)}finally{g(!1)}},children:[e.jsx(pt,{size:14,className:u?"uh-spin":""}),u?"Checking…":"Check connection"]})]}),e.jsxs("main",{className:`conversation-content ${t==="chat"?"conversation-chat":""}`,children:[t==="chat"&&e.jsx(Zt,{projectNames:T,configured:a.workspace.projects.length>0,disabled:!M.authenticated||x,initialPrompt:new URLSearchParams(location.search).get("message")||(/config|settings|pipelines|projects/.test(location.pathname)?"Help me configure this workspace.":"")}),t==="pipeline-live"&&e.jsx(Ms,{data:a,pipelines:_,project:w,offline:x,act:D,chatFirst:!0}),t==="setup"&&e.jsx(Qt,{data:a,project:w}),t==="review"&&e.jsx(Es,{})]})]}),h&&e.jsx(As,{status:d,close:()=>m(!1),refresh:$})]})}function Ls(t){$t.createRoot(t).render(e.jsx(Ds,{}))}const Ps=Object.freeze(Object.defineProperty({__proto__:null,mount:Ls},Symbol.toStringTag,{value:"Module"}));export{Ps as C,oe as F,Z as L,rs as a,ns as b,ae as c,cs as s};
|