@dendelion/paper-camp 0.23.0 → 0.23.1

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.
Files changed (22) hide show
  1. package/dist/app/assets/{index-Ds_iTHi0.js → index-B0T4zOOc.js} +2 -2
  2. package/dist/app/assets/{index-Ds_iTHi0.js.map → index-B0T4zOOc.js.map} +1 -1
  3. package/dist/app/assets/{index-Co_9IFtJ.js → index-CFMhKXQf.js} +2 -2
  4. package/dist/app/assets/{index-Co_9IFtJ.js.map → index-CFMhKXQf.js.map} +1 -1
  5. package/dist/app/assets/{index-siPA4naJ.js → index-CKO_a_mt.js} +2 -2
  6. package/dist/app/assets/{index-siPA4naJ.js.map → index-CKO_a_mt.js.map} +1 -1
  7. package/dist/app/assets/{index-DdiMHcBX.js → index-CTHTRX-O.js} +2 -2
  8. package/dist/app/assets/{index-DdiMHcBX.js.map → index-CTHTRX-O.js.map} +1 -1
  9. package/dist/app/assets/{index-DRVlFKav.js → index-CeEpQji6.js} +2 -2
  10. package/dist/app/assets/{index-DRVlFKav.js.map → index-CeEpQji6.js.map} +1 -1
  11. package/dist/app/assets/{index-e0PzaU7Z.js → index-DC_F8eQU.js} +2 -2
  12. package/dist/app/assets/{index-e0PzaU7Z.js.map → index-DC_F8eQU.js.map} +1 -1
  13. package/dist/app/assets/{index-Bq3vqVCv.js → index-DoH_Ktpt.js} +2 -2
  14. package/dist/app/assets/{index-Bq3vqVCv.js.map → index-DoH_Ktpt.js.map} +1 -1
  15. package/dist/app/assets/{index-8_65UWKz.js → index-Twqzhu_o.js} +2 -2
  16. package/dist/app/assets/{index-8_65UWKz.js.map → index-Twqzhu_o.js.map} +1 -1
  17. package/dist/app/assets/{main-C0TBUyF9.js → main-CDkrPxrg.js} +4 -4
  18. package/dist/app/assets/{main-C0TBUyF9.js.map → main-CDkrPxrg.js.map} +1 -1
  19. package/dist/app/assets/{sidebar-section-D0b_1DUA.js → sidebar-section-7T-4hlR4.js} +2 -2
  20. package/dist/app/assets/{sidebar-section-D0b_1DUA.js.map → sidebar-section-7T-4hlR4.js.map} +1 -1
  21. package/dist/app/index.html +1 -1
  22. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-Co_9IFtJ.js","assets/sidebar-section-D0b_1DUA.js","assets/index-siPA4naJ.js"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-CFMhKXQf.js","assets/sidebar-section-7T-4hlR4.js","assets/index-CKO_a_mt.js"])))=>i.map(i=>d[i]);
2
2
  (function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))r(s);new MutationObserver(s=>{for(const i of s)if(i.type==="childList")for(const o of i.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&r(o)}).observe(document,{childList:!0,subtree:!0});function n(s){const i={};return s.integrity&&(i.integrity=s.integrity),s.referrerPolicy&&(i.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?i.credentials="include":s.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function r(s){if(s.ep)return;s.ep=!0;const i=n(s);fetch(s.href,i)}})();var td=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function lf(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var L1={exports:{}},cf={},M1={exports:{}},ue={};/**
3
3
  * @license React
4
4
  * react.production.min.js
@@ -295,7 +295,7 @@ ${i}`}]}),DY=(e,t,n)=>{const r=new Map($Y(t,n).map(i=>[i.text,i]));return[...e.m
295
295
 
296
296
  Output from the last run:
297
297
 
298
- ${e.output||"(no output captured)"}`,One=({check:e,onRun:t})=>{const n=e.status==="running",r=bI(e.lastRun);return f.jsxs(ry,{tooltip:r?`${e.cmd} — last run ${r}. Click to run.`:`${e.cmd} — click to run.`,onClick:()=>t(e.name),disabled:n,fillColor:Mne[e.status],textColor:$ne[e.status],variant:e.status==="stale"?"neutral":void 0,children:[e.name,f.jsx("span",{className:n?"visible":"invisible",children:"…"})]})},zne=({finding:e})=>f.jsxs("div",{className:"font-mono text-2xs opacity-70",children:[e.file,":",e.line," — ",e.message]}),Fne=({issue:e,linkedPlan:t,onNavigate:n})=>f.jsx("div",{className:"font-mono text-2xs opacity-70",children:t?f.jsx("button",{type:"button",onClick:n,className:"bg-none bg-transparent border-none p-0 underline cursor-pointer [font:inherit] text-left",children:e.message}):f.jsx("span",{className:"text-left",children:e.message})}),Bne=()=>{const{checks:e,run:t}=xc(),n=M(x=>x.doctor),r=M(x=>x.consistency),s=M(x=>x.plans),i=nt(),o=e.find(x=>x.status==="fail"),[a,l]=k.useState(!1),[c,u]=k.useState(!1),[d,h]=k.useState(!1),p=n.findings.length>0,m=r.length>0,g=k.useCallback(x=>x.planId?s==null?void 0:s.entries.find(y=>y.id===x.planId):void 0,[s==null?void 0:s.entries]);return f.jsxs("div",{children:[f.jsx("h4",{className:`${ch} m-0`,children:EI}),f.jsxs("div",{className:"flex flex-col gap-3",children:[f.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.map(x=>f.jsx(One,{check:x,onRun:t},x.name)),f.jsx(ry,{tooltip:p?`${n.errorCount} error(s), ${n.warningCount} warning(s) — click to show.`:"Corpus doctor — no findings.",onClick:()=>u(x=>!x),disabled:!p,disabledCursor:"default",ariaExpanded:p?c:void 0,fillColor:Nr[l1(n)],textColor:Ir[l1(n)],children:"doctor"}),f.jsx(ry,{tooltip:m?"Plan/idea doc findings — orphan subjects & title style. Click to show.":"Plan/idea docs — no findings.",onClick:()=>h(x=>!x),disabled:!m,disabledCursor:"default",ariaExpanded:m?d:void 0,fillColor:Nr[m?"fail":"pass"],textColor:Ir[m?"fail":"pass"],children:"docs"})]}),o&&f.jsxs("div",{className:"flex flex-col gap-1 text-center font-handwritten text-sm",children:[f.jsxs("span",{className:"text-desk-text-muted",children:["The ",o.name," check failed."]}),f.jsxs("span",{className:"text-desk-chalk",children:["Suggested fix: ",f.jsx(Kd,{text:Dne(o),surface:"chalkboard"}),o.output&&f.jsxs(f.Fragment,{children:[" · ",f.jsx("button",{type:"button",onClick:()=>l(x=>!x),className:"bg-none bg-transparent border-none p-0 underline cursor-pointer [font:inherit] text-desk-chalk","aria-expanded":a,children:a?"Hide output":"Show output"})]})]}),a&&o.output&&f.jsx("pre",{className:"mt-1 max-h-48 overflow-auto whitespace-pre-wrap text-left font-mono text-2xs opacity-70",children:o.output})]}),c&&p&&f.jsx("div",{className:"flex flex-col gap-1",children:n.findings.map(x=>f.jsx(zne,{finding:x},`${x.file}:${x.line}:${x.rule}`))}),d&&m&&f.jsx("div",{className:"flex flex-col gap-1",children:r.map((x,y)=>{const v=g(x);return f.jsx(Fne,{issue:x,linkedPlan:v,onNavigate:()=>v&&i(Ri(v))},`${x.kind}-${x.title}-${y}`)})})]})]})},Vne=async()=>{try{const e=await J(K("/api/ci"));return e.ok?e.json():null}catch{return null}};function Une(){const[e,t]=k.useState(null),[n,r]=k.useState(!0),s=k.useCallback(async()=>{try{t(await Vne())}finally{r(!1)}},[]);return k.useEffect(()=>{s()},[s]),{ci:e,loading:n,refresh:s}}const PI="CI & release",Wne={success:"bg-chalk-pass-text",failure:"bg-chalk-fail-text",in_progress:"bg-chalk-running-text",queued:"bg-chalk-running-text",cancelled:"bg-desk-text-muted",unknown:"bg-desk-text-muted"},Kp="text-desk-chalk underline decoration-desk-border hover:decoration-desk-chalk",Hne=({run:e})=>{const t=f.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[f.jsx("span",{"aria-hidden":"true",className:`h-2 w-2 shrink-0 rounded-full ${Wne[e.status]}`}),f.jsx("span",{className:"min-w-0 overflow-hidden text-ellipsis whitespace-nowrap text-desk-chalk",children:e.workflow}),f.jsx("span",{className:"shrink-0 font-mono text-2xs text-desk-text-muted",children:e.status})]});return e.url?f.jsx("a",{href:e.url,target:"_blank",rel:"noreferrer",className:"no-underline",children:t}):t},Kne=()=>{const{ci:e,loading:t,refresh:n}=Une(),r=M(o=>o.refreshing),s=k.useRef(!1);k.useEffect(()=>{s.current&&!r&&n(),s.current=r},[r,n]);const i=()=>{var a;if(!e)return f.jsx(pe,{surface:"chalkboard",size:"small",children:f.jsx("p",{className:"m-0 text-center text-xs opacity-50",children:t?"Checking CI…":"No CI source declared."})});const o=`https://github.com/${e.repo}/actions`;return e.available?f.jsx(pe,{surface:"chalkboard",size:"small",children:f.jsxs("div",{className:"flex flex-col gap-2 text-sm",children:[e.runs.length>0?e.runs.map(l=>f.jsx(Hne,{run:l},l.workflow)):f.jsxs("span",{className:"text-xs text-desk-text-muted opacity-70",children:["No recent runs on ",e.branch,"."]}),f.jsxs("div",{className:"font-mono text-2xs text-desk-text-muted",children:["Released ",e.releasedVersion??"—"," · Queued ",((a=e.releasePr)==null?void 0:a.version)??"none"]}),f.jsxs("div",{className:"flex flex-wrap gap-x-3 text-2xs",children:[e.releasePr&&f.jsxs("a",{href:e.releasePr.url,target:"_blank",rel:"noreferrer",className:Kp,children:["Release PR #",e.releasePr.number]}),f.jsx("a",{href:o,target:"_blank",rel:"noreferrer",className:Kp,children:"Open Actions"})]})]})}):f.jsx(pe,{surface:"chalkboard",size:"small",children:f.jsxs("p",{className:"m-0 text-center text-xs opacity-70",children:["CI status unavailable —"," ",f.jsx("a",{href:o,target:"_blank",rel:"noreferrer",className:Kp,children:"open Actions"})]})})};return f.jsxs("div",{children:[f.jsx("h4",{className:`${ch} m-0`,children:PI}),i()]})},TI=async(e,t)=>{if(!e.ok){const n=await e.json().catch(()=>({error:t}));throw new Error(n.error??t)}},Gne=async()=>{const e=await J(K("/api/services"));return e.ok?(await e.json()).services??[]:[]},Zne=async e=>{const t=await J(K(`/api/services/start?name=${encodeURIComponent(e)}`),{method:"POST"});await TI(t,"Failed to start service")},qne=async e=>{const t=await J(K(`/api/services/stop?name=${encodeURIComponent(e)}`),{method:"POST"});await TI(t,"Failed to stop service")},Yne=async e=>{const t=await J(K(`/api/services/logs?name=${encodeURIComponent(e)}`));return t.ok?(await t.json()).log??"":""};function Jne(){const[e,t]=k.useState([]),[n,r]=k.useState(!0),s=k.useCallback(async()=>{try{t(await Gne())}catch{}finally{r(!1)}},[]);k.useEffect(()=>{s()},[s]),k.useEffect(()=>{let a;const l=()=>{a&&clearTimeout(a),a=setTimeout(s,80)},c=yc(u=>{(u.type==="service"||u.message==="changed")&&l()});return()=>{a&&clearTimeout(a),c()}},[s]);const i=k.useCallback(async a=>{await Zne(a),await s()},[s]),o=k.useCallback(async a=>{await qne(a),await s()},[s]);return{services:e,loading:n,start:i,stop:o,refresh:s}}const Qne=1500,NI="Services",Xne=e=>e.status==="crashed"?"bg-chalk-fail-text":e.status==="running"?e.health==="up"?"bg-chalk-pass-text":"bg-chalk-running-text":e.status==="stopping"?"bg-chalk-running-text":"bg-desk-text-muted",ere=({service:e})=>{const t=e.status==="running"?`running · ${e.health}`:e.status;return f.jsx("span",{role:"img","aria-label":t,className:`h-2 w-2 shrink-0 rounded-full ${Xne(e)}`,title:t})},tre=({name:e,running:t})=>{const[n,r]=k.useState(""),s=k.useRef(null);return k.useEffect(()=>{let i=!1;const o=async()=>{const l=await Yne(e);i||r(l)};o();const a=t?setInterval(o,Qne):void 0;return()=>{i=!0,a&&clearInterval(a)}},[e,t]),k.useEffect(()=>{const i=s.current;i&&n&&(i.scrollTop=i.scrollHeight)},[n]),f.jsx("pre",{ref:s,className:"m-0 mt-2 max-h-40 overflow-auto whitespace-pre-wrap break-words rounded-[8px] bg-desk-bg/60 p-2 font-mono text-2xs leading-relaxed text-desk-text-muted",children:n||"No output yet."})},nre=({service:e,onStart:t,onStop:n})=>{const{toast:r}=rt(),[s,i]=k.useState(!1),[o,a]=k.useState(!1),l=e.status==="running"||e.status==="stopping",c=e.pid!==null,u=async()=>{if(!s){i(!0);try{await(l?n:t)(e.name)}catch(d){r({title:l?"Failed to stop service":"Failed to start service",description:d.message,variant:"error"})}finally{i(!1)}}};return f.jsxs(pe,{surface:"chalkboard",size:"small",children:[f.jsxs("div",{className:"flex items-center justify-between gap-2",children:[f.jsxs("button",{type:"button",onClick:()=>a(d=>!d),"aria-expanded":o,className:"flex min-w-0 cursor-pointer items-center gap-2 border-none bg-transparent p-0 text-left",children:[f.jsx("span",{className:`shrink-0 text-desk-text-muted transition-transform ${o?"rotate-90":""}`,children:f.jsx(I8,{})}),f.jsx(ere,{service:e}),f.jsx("span",{className:"min-w-0 overflow-hidden text-ellipsis whitespace-nowrap font-display-luminari text-sm font-semibold text-desk-chalk",children:e.name}),e.port&&f.jsxs("span",{className:"shrink-0 font-mono text-2xs text-desk-text-muted",children:[":",e.port]})]}),f.jsx("div",{className:"flex shrink-0 items-center gap-1",children:s?f.jsx(Wr,{size:"small",surface:"chalkboard",label:"Working"}):!l||c?f.jsx(xt,{icon:l?f.jsx(N8,{}):f.jsx(T8,{}),surface:"chalkboard",size:"small",variant:"ghost",label:l?`Stop ${e.name}`:`Start ${e.name}`,onClick:u}):null})]}),o&&f.jsx(tre,{name:e.name,running:l})]})},rre=()=>{const{services:e,start:t,stop:n}=Jne(),r=k.useCallback(i=>t(i),[t]),s=k.useCallback(i=>n(i),[n]);return f.jsxs("div",{children:[f.jsx("h4",{className:`${ch} m-0`,children:NI}),f.jsx("div",{className:"flex flex-col gap-2",children:e.length>0?e.map(i=>f.jsx(nre,{service:i,onStart:r,onStop:s},i.name)):f.jsx(pe,{surface:"chalkboard",size:"small",children:f.jsx("p",{className:"m-0 text-center text-xs opacity-50",children:"No services declared."})})})]})},sre=[NI,EI,PI],ire=()=>f.jsx("div",{className:"flex flex-col gap-4","aria-hidden":"true",children:sre.map(e=>f.jsxs("div",{children:[f.jsx("div",{className:ch,children:e}),f.jsx(rn,{variant:"rect",width:"100%",height:28,surface:"chalkboard"})]},e))}),ore=()=>f.jsx("div",{className:"flex flex-1 items-center justify-center",children:f.jsxs("p",{className:"m-0 text-center text-xs text-desk-text-muted",children:["Desk isn't configured — add ",f.jsx("code",{children:"desk"})," to ",f.jsx("code",{children:"papercamp/config.json"}),"."]})}),are=()=>{const{desk:e,loading:t}=jne();return f.jsxs(f.Fragment,{children:[f.jsx(jP,{surface:"chalkboard"}),f.jsxs("div",{className:"flex flex-1 flex-col p-[var(--pc-stack-pad)]",children:[f.jsxs("div",{className:"flex items-center justify-between gap-2 mb-3",children:[f.jsx("h3",{className:`${wI} m-0`,children:"Desk"}),f.jsx(kI,{label:"Fetch from GitHub",refreshingLabel:"Fetching…",surface:"chalkboard"})]}),t?f.jsx(ire,{}):e?f.jsxs("div",{className:"flex flex-col gap-4",children:[f.jsx(rre,{}),f.jsx(Bne,{}),f.jsx(Kne,{})]}):f.jsx(ore,{})]})]})},lre=({open:e,onToggle:t,pinned:n=!1})=>{const r=e||n,s=k.useRef(null);k.useEffect(()=>{s.current&&(s.current.inert=!r)},[r]),k.useEffect(()=>{if(!r||n)return;const h=p=>{p.key==="Escape"&&t()};return window.addEventListener("keydown",h),()=>window.removeEventListener("keydown",h)},[r,n,t]);const i=M(h=>h.consistency),o=M(h=>h.doctor),a=M(h=>h.agentStatus);k.useEffect(()=>{const{loadStatus:h,loadConsistency:p,loadDoctor:m,loadGitStatus:g,loadAgentStatus:x,loadArchivableIdeas:y}=M.getState();h(),p(),m(),g(),x(),y()},[]),k.useEffect(()=>{const h=()=>{M.getState().loadPlans(),M.getState().loadGitStatus()};return window.addEventListener("focus",h),()=>window.removeEventListener("focus",h)},[]),k.useEffect(()=>{const h={},p=(g,x,y)=>{h[g]&&clearTimeout(h[g]),h[g]=setTimeout(x,y)},m=yc(g=>{if(g.type==="status"){p("status",()=>M.getState().loadStatus(),80);return}if(g.type==="agent"){p("agent",()=>M.getState().loadAgentStatus(),120);return}g.message==="changed"&&p("activity",()=>{const{loadPlans:x,loadSuggestions:y,loadStatus:v,loadConsistency:w,loadDoctor:b,loadGitStatus:_,loadAgentStatus:S,loadArchivableIdeas:j}=M.getState();x(),y(),v(),w(),b(),_(),S(),j()},250)});return()=>{for(const g of Object.values(h))g&&clearTimeout(g);m()}},[]);const{checks:l}=xc(),c=i.length>0,u=l.some(h=>h.status==="fail")||c||o.errorCount>0,d=a.some(h=>h.status==="running"||h.status==="starting"||h.status==="stopping");return f.jsxs(f.Fragment,{children:[!r&&f.jsx("div",{className:"fixed right-0 top-[var(--pc-stack-toggle-top,50%)] z-[300] rounded-l-md shadow-[-2px_0_8px_rgba(0,0,0,0.15)] bg-desk-bg bg-chalkboard [background-repeat:repeat,no-repeat] [background-size:200px_200px,auto]",style:{transform:"translateY(-50%)"},children:f.jsx(xt,{icon:d?f.jsx(Wr,{size:"small",surface:"chalkboard",label:"Agent running"}):u?f.jsx("span",{"aria-hidden":"true",className:"h-2 w-2 rounded-full bg-chalk-fail-text shadow-[0_0_6px_rgba(214,160,160,0.9)]"}):f.jsx("span",{className:"text-2xs",children:"S"}),surface:"chalkboard",size:"small",label:d?"Open stack panel — agent running":u?"Open stack panel — checks failing":"Open stack panel",onClick:t,className:`w-7 h-[64px] rounded-l-md ${d?"shadow-[inset_0_0_0_1px_rgba(214,196,160,0.6)]":u?"shadow-[inset_0_0_0_1px_rgba(214,160,160,0.6)]":""}`})}),f.jsxs("aside",{ref:s,"aria-label":"Stack",className:"fixed inset-y-0 right-0 z-[300] flex w-[min(var(--pc-stack-width),100vw)] flex-col overflow-hidden border-l-4 border-paper-950/[12%] text-desk-text bg-desk-bg bg-chalkboard [background-repeat:repeat,no-repeat] [background-size:200px_200px,auto]",style:{transform:r?"translateX(0)":"translateX(100%)"},children:[f.jsxs("div",{className:"flex h-14 shrink-0 items-center justify-between px-[var(--pc-stack-pad)]",children:[f.jsx("h2",{className:"m-0 font-display-luminari text-base font-bold text-desk-chalk",children:"Stack"}),!n&&f.jsx(xt,{icon:f.jsx("span",{className:"text-sm leading-none",children:"×"}),surface:"chalkboard",size:"small",label:"Close stack panel",onClick:t,className:"h-7 w-7 border border-desk-border"})]}),f.jsx(jP,{surface:"chalkboard"}),f.jsxs("div",{className:"flex min-h-0 flex-1 flex-col overflow-y-auto",children:[f.jsx(Cne,{}),f.jsx(are,{})]})]})]})},c1=({size:e="md"})=>{const{projectName:t,iconDataUri:n,loading:r}=Ane();return f.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[n?f.jsx("img",{src:n,alt:"",className:`object-contain shrink-0 ${e==="sm"?"w-[18px] h-[18px]":"w-[20px] h-[20px]"}`}):f.jsx(O6,{icon:f.jsx($4,{}),size:"small"}),f.jsx("span",{className:`font-display-luminari font-semibold whitespace-nowrap overflow-hidden text-ellipsis min-w-0 ${e==="sm"?"text-sm":"text-md"}`,children:r?"Loading…":t??"Paper Camp"})]})},cre="data-paper-camp-mount";function ure(e){return(e==null?void 0:e.getAttribute(cre))??""}const da=typeof document>"u"?"":ure(document.getElementById("root")),dre=()=>{const e=nt();return da!==""?f.jsx(c1,{size:"sm"}):f.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[f.jsx(c1,{size:"sm"}),f.jsx(re,{variant:"ghost",size:"small",className:"font-handwritten !text-sm opacity-70",onClick:()=>e({to:"/projects"}),children:"Back to projects"})]})},fre=()=>{const e=M(l=>l.setGithubConfig),[t,n]=k.useState(""),[r,s]=k.useState(""),[i,o]=k.useState(""),a=t.trim()!==""&&r.trim()!==""&&i.trim()!=="";return f.jsxs(pe,{size:"small",texture:"kraft",className:"mt-4 w-full max-w-sm text-left",children:[f.jsxs("p",{className:"m-0 mb-3 text-sm opacity-[0.65]",children:["No runtime reachable — paste a"," ",f.jsx("a",{href:"https://github.com/settings/personal-access-tokens/new",target:"_blank",rel:"noopener noreferrer",children:"fine-grained token"})," ","scoped to this repo to read and write the corpus directly."]}),f.jsxs("div",{className:"flex flex-col gap-2",children:[f.jsx(In,{size:"small",label:"Owner",value:t,onChange:l=>n(l.target.value)}),f.jsx(In,{size:"small",label:"Repo",value:r,onChange:l=>s(l.target.value)}),f.jsx(In,{size:"small",type:"password",label:"Token",value:i,onChange:l=>o(l.target.value)})]}),f.jsx(re,{size:"small",className:"mt-3",disabled:!a,onClick:()=>e({owner:t.trim(),repo:r.trim(),token:i.trim()}),children:"Save"})]})},hre=({layer:e})=>f.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-2 py-24 text-center",children:[f.jsx("p",{className:"font-handwritten text-lg",children:e==="corpus"?"This needs the runtime or a GitHub token":"This needs the runtime"}),f.jsx("p",{className:"max-w-sm text-sm opacity-60",children:e==="corpus"?"Connect the project's runtime, or go plan-only below.":"Connect the project's runtime to use this — it owns the filesystem, git and the agent."}),e==="corpus"&&f.jsx(fre,{})]}),pre=()=>{const[e,t]=k.useState(null);return k.useEffect(()=>{},[]),e?f.jsxs("div",{role:"alert",className:"bg-watercolor-rose-dark text-desk-text py-2 px-4 text-2xs font-mono shrink-0",children:["Server failed to reload — restart `pnpm dev` to pick up the change. ",e]}):null},mre=({routeKey:e,children:t,mobileOpen:n,onMobileClose:r})=>{const s=k.useRef(null);return k.useEffect(()=>{if(!n)return;const i=o=>{o.key==="Escape"&&r()};return window.addEventListener("keydown",i),()=>window.removeEventListener("keydown",i)},[n,r]),k.useEffect(()=>{var o;if(!n)return;const i=document.activeElement;return(o=s.current)==null||o.focus(),()=>{var a;return(a=i==null?void 0:i.focus)==null?void 0:a.call(i)}},[n]),f.jsxs(f.Fragment,{children:[n&&f.jsx("button",{type:"button",className:"lg:hidden fixed inset-0 z-[290] cursor-default border-none p-0 bg-ink-900/[40%] backdrop-blur-sm",onClick:r,"aria-label":"Close sidebar",tabIndex:-1}),f.jsxs("aside",{ref:s,role:n?"dialog":void 0,"aria-modal":n||void 0,"aria-label":"Sidebar navigation",tabIndex:-1,className:`fixed inset-y-0 left-0 z-[300] w-[224px] shrink-0 flex flex-col overflow-hidden lg:sticky lg:inset-auto lg:top-0 lg:z-auto lg:translate-x-0 h-[var(--pc-sidebar-h,100%)] ${n?"translate-x-0":"-translate-x-full"} ${n?"bg-[var(--pui-bg-base)] shadow-[2px_0_12px_rgba(0,0,0,0.15)]":"bg-transparent"}`,children:[f.jsx("div",{className:"shrink-0 h-8"}),f.jsx("div",{className:"flex-1 overflow-y-auto relative",children:f.jsx("div",{children:t},e)})]})]})};function Gp(e){return e==="allowed"?"allowed":/reject|block|exceed|denied/i.test(e)?"rejected":"warning"}function gre(e){return e<1e12?e*1e3:e}function yre(e){const t=[`Claude usage: ${e.status}`];return e.rateLimitType&&t.push(e.rateLimitType),e.resetsAt!==void 0&&t.push(`resets ${new Date(gre(e.resetsAt)).toLocaleTimeString()}`),e.overage&&t.push("overage on"),t.join(" · ")}const xre="flex items-center gap-3 h-8 px-4 border-b border-black/[0.08] text-xs shrink-0 box-border overflow-x-auto overflow-y-hidden whitespace-nowrap",vre="flex items-center gap-3 shrink-0",wre="flex items-center gap-1",bre="opacity-50",kre="text-[var(--pui-text-primary)]",u1="opacity-60",_re="flex-1",d1="flex items-center gap-2 shrink-0",f1="bg-transparent border-none p-0 cursor-pointer",Sre="relative inline-flex",Cre="absolute -top-1 -right-1 pointer-events-none",jre=({gitBranch:e,gitAhead:t,changedFileCount:n,agentActive:r,activeTaskStatus:s,agentNotSignedIn:i,capabilityGapCount:o,rateLimit:a,unreadNotificationCount:l,onOpenSetup:c,onOpenGit:u,onOpenNotifications:d,trailing:h})=>f.jsxs("div",{className:xre,style:Uo("kraft"),children:[f.jsxs("div",{className:vre,children:[f.jsxs("span",{className:wre,children:[f.jsx("span",{className:bre,children:f.jsx(uk,{size:12})}),f.jsx("code",{className:kre,children:e??"no branch"})]}),t>0&&f.jsxs("span",{className:u1,children:["↑",t]}),f.jsx("span",{className:u1,children:n>0?`${n} changed`:"clean"}),r&&f.jsx(Wr,{size:"small",label:`Agent ${s}…`}),i&&f.jsx(ye,{content:"Sign in from Settings → Connections so agent tasks can run",children:f.jsx("button",{type:"button",onClick:c,className:f1,children:f.jsx(ce,{size:"small",variant:"warning",children:"Agent not signed in"})})}),o>0&&f.jsx(ye,{content:"Some features are disabled — open Setup to fix",children:f.jsx("button",{type:"button",onClick:c,className:f1,children:f.jsxs(ce,{size:"small",variant:"warning",children:["Setup (",o,")"]})})}),a&&Gp(a.status)!=="allowed"&&f.jsx(ye,{content:yre(a),children:f.jsx(ce,{size:"small",variant:Gp(a.status)==="rejected"?"error":"warning",children:Gp(a.status)==="rejected"?"Claude limit reached":"Claude usage warning"})})]}),f.jsx("div",{className:_re}),h&&f.jsx("div",{className:d1,children:h}),f.jsxs("div",{className:d1,children:[f.jsx(ye,{content:"Git",children:f.jsx(xt,{variant:"ghost",size:"small",icon:f.jsx(uk,{}),label:"Git",onClick:u})}),f.jsx(ye,{content:"Notifications",children:f.jsxs("span",{className:Sre,children:[f.jsx(xt,{variant:"ghost",size:"small",icon:f.jsx(A8,{}),label:"Notifications",onClick:d}),l>0&&f.jsx("span",{className:Cre,children:f.jsx(ce,{size:"small",variant:"warning",children:l})})]})})]})]}),Ere=()=>{const e=M(g=>g.agentStatus),t=M(g=>g.gitStatus),n=M(g=>g.gitBranch),r=M(g=>g.gitAhead),s=M(mJ),i=M(gJ),o=M(yJ),a=M(g=>{var x;return((x=g.notifications)==null?void 0:x.filter(y=>y.kind==="question"||!y.read).length)??0}),l=nt(),c=e.find(g=>g.status==="running"||g.status==="starting"||g.status==="stopping"),u=c!==void 0,d=(t==null?void 0:t.length)??0,h=()=>l({to:"/settings/$section",params:{section:"setup"}}),p=()=>l({to:"/git"}),m=()=>l({to:"/inbox"});return f.jsx(jre,{gitBranch:n,gitAhead:r,changedFileCount:d,agentActive:u,activeTaskStatus:c==null?void 0:c.status,agentNotSignedIn:i,capabilityGapCount:s,rateLimit:o,unreadNotificationCount:a,onOpenSetup:h,onOpenGit:p,onOpenNotifications:m})},Pre=()=>{const e=nt(),t=uh(),n=SI(),r=M(l=>l.plans),s=Ine(),i=M(l=>l.activeDocTitle),o=M(l=>l.activeReleaseVersion),a=(()=>{if(t){const c=t.entityKind==="ticket"&&t.idea?((r==null?void 0:r.entries)??[]).find(u=>u.id===t.idea):void 0;return[{id:"plans",label:"Plans",onClick:()=>e({to:"/"})},...c?[{id:"board",label:c.title,onClick:()=>e(Ri(c))}]:[],{id:"plan",label:t.title}]}if(n)return[{id:"plans",label:"Plans",onClick:()=>e({to:"/"})},{id:"idea",label:n.title}];const l=s==="repo-docs"?i:s==="release-notes"?o:null;return l?[{id:"docs",label:"Docs",onClick:()=>e({to:"/docs"})},{id:"doc",label:l}]:null})();return a?f.jsx("div",{className:"-mt-6 mb-3",children:f.jsx(u8,{className:"font-handwritten !text-xs min-w-0",items:a})}):null},II=({children:e,className:t=""})=>f.jsx("h1",{className:`text-4xl font-display-luminari font-semibold text-ink-900 mb-6 leading-[1.1] ${t}`,children:e}),Tre=[{path:"/projects",label:"Projects"},{path:"/projects/reviews",label:"In review"},{path:"/projects/activity",label:"Agent activity"},{path:"/projects/ideas",label:"Ideas"}],Nre=({children:e})=>{const t=nt(),n=Xm({select:r=>r.location.pathname});return f.jsx(xP,{background:{texture:"speckle",ruledType:"grid",ruledColor:"blue"},showHeader:!1,showSidebar:!1,showPage:!1,bleedBottom:!0,children:f.jsx("div",{className:"flex min-h-screen flex-col items-center justify-center px-6 py-16",children:f.jsxs(Wx,{texture:{texture:"parchment"},className:"w-full max-w-lg",children:[f.jsx(II,{children:"Paper Camp"}),f.jsx("nav",{"aria-label":"Hub navigation",className:"flex flex-wrap gap-1 mb-4",children:Tre.map(r=>f.jsx(re,{variant:"ghost",size:"small",isActive:n===r.path,onClick:()=>t({to:r.path}),"aria-current":n===r.path?"page":void 0,children:r.label},r.path))}),e]})})})};async function Vv(e,t){return(await Promise.all(e.map(async r=>{const s=await t(r.runtimeUrl);return s===null?null:{runtime:r,data:s}}))).filter(r=>r!==null)}function Uv(e,t){RN(e,window.localStorage),window.location.assign(t)}function Ire(e,t){return e!==""||t!==""}async function Are(e,t){if(e!=="")return!1;try{const n=await t("/api/capabilities");return n.ok?(await n.json(),!0):!1}catch{return!1}}function Rre(e,t){return`${e}?runtime=${encodeURIComponent(t)}`}function ed(e){try{return new URL(e).host}catch{return e}}function Wv(e){return e.label??ed(e.runtimeUrl)}const Lre=24*60*60*1e3;function Mre(){const[e,t]=k.useState([]),[n,r]=k.useState(!0);return k.useEffect(()=>{let s=!1;r(!0);const i=Hl(window.localStorage),o=Date.now()-Lre;return Vv(i,O9).then(a=>{if(s)return;const l=a.flatMap(c=>c.data.map(u=>({runtime:c.runtime,data:u}))).filter(c=>new Date(c.data.startedAt).getTime()>=o).sort((c,u)=>u.data.startedAt.localeCompare(c.data.startedAt));t(l),r(!1)}),()=>{s=!0}},[]),{rows:e,loading:n}}function $re(){const[e,t]=k.useState([]),[n,r]=k.useState(!0);return k.useEffect(()=>{let s=!1;r(!0);const i=Hl(window.localStorage);return Vv(i,K9).then(o=>{s||(t(o.flatMap(a=>a.data.entries.map(l=>({runtime:a.runtime,data:l})))),r(!1))}),()=>{s=!0}},[]),{rows:e,loading:n}}function Dre(){const[e,t]=k.useState([]),[n,r]=k.useState(!0);return k.useEffect(()=>{let s=!1;r(!0);const i=Hl(window.localStorage);return Vv(i,tW).then(o=>{s||(t(o.flatMap(a=>a.data.entries.filter(l=>l.status==="review"&&!!l.id).map(l=>({runtime:a.runtime,data:l})))),r(!1))}),()=>{s=!0}},[]),{rows:e,loading:n}}const Ore="0.23.0",AI=Ore,zre={name:null,reachable:!1,remoteVersion:null,versionSkew:!1};function Fre(e){const[t,n]=k.useState({}),r=e.map(s=>s.runtimeUrl).join(`
298
+ ${e.output||"(no output captured)"}`,One=({check:e,onRun:t})=>{const n=e.status==="running",r=bI(e.lastRun);return f.jsxs(ry,{tooltip:r?`${e.cmd} — last run ${r}. Click to run.`:`${e.cmd} — click to run.`,onClick:()=>t(e.name),disabled:n,fillColor:Mne[e.status],textColor:$ne[e.status],variant:e.status==="stale"?"neutral":void 0,children:[e.name,f.jsx("span",{className:n?"visible":"invisible",children:"…"})]})},zne=({finding:e})=>f.jsxs("div",{className:"font-mono text-2xs opacity-70",children:[e.file,":",e.line," — ",e.message]}),Fne=({issue:e,linkedPlan:t,onNavigate:n})=>f.jsx("div",{className:"font-mono text-2xs opacity-70",children:t?f.jsx("button",{type:"button",onClick:n,className:"bg-none bg-transparent border-none p-0 underline cursor-pointer [font:inherit] text-left",children:e.message}):f.jsx("span",{className:"text-left",children:e.message})}),Bne=()=>{const{checks:e,run:t}=xc(),n=M(x=>x.doctor),r=M(x=>x.consistency),s=M(x=>x.plans),i=nt(),o=e.find(x=>x.status==="fail"),[a,l]=k.useState(!1),[c,u]=k.useState(!1),[d,h]=k.useState(!1),p=n.findings.length>0,m=r.length>0,g=k.useCallback(x=>x.planId?s==null?void 0:s.entries.find(y=>y.id===x.planId):void 0,[s==null?void 0:s.entries]);return f.jsxs("div",{children:[f.jsx("h4",{className:`${ch} m-0`,children:EI}),f.jsxs("div",{className:"flex flex-col gap-3",children:[f.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.map(x=>f.jsx(One,{check:x,onRun:t},x.name)),f.jsx(ry,{tooltip:p?`${n.errorCount} error(s), ${n.warningCount} warning(s) — click to show.`:"Corpus doctor — no findings.",onClick:()=>u(x=>!x),disabled:!p,disabledCursor:"default",ariaExpanded:p?c:void 0,fillColor:Nr[l1(n)],textColor:Ir[l1(n)],children:"doctor"}),f.jsx(ry,{tooltip:m?"Plan/idea doc findings — orphan subjects & title style. Click to show.":"Plan/idea docs — no findings.",onClick:()=>h(x=>!x),disabled:!m,disabledCursor:"default",ariaExpanded:m?d:void 0,fillColor:Nr[m?"fail":"pass"],textColor:Ir[m?"fail":"pass"],children:"docs"})]}),o&&f.jsxs("div",{className:"flex flex-col gap-1 text-center font-handwritten text-sm",children:[f.jsxs("span",{className:"text-desk-text-muted",children:["The ",o.name," check failed."]}),f.jsxs("span",{className:"text-desk-chalk",children:["Suggested fix: ",f.jsx(Kd,{text:Dne(o),surface:"chalkboard"}),o.output&&f.jsxs(f.Fragment,{children:[" · ",f.jsx("button",{type:"button",onClick:()=>l(x=>!x),className:"bg-none bg-transparent border-none p-0 underline cursor-pointer [font:inherit] text-desk-chalk","aria-expanded":a,children:a?"Hide output":"Show output"})]})]}),a&&o.output&&f.jsx("pre",{className:"mt-1 max-h-48 overflow-auto whitespace-pre-wrap text-left font-mono text-2xs opacity-70",children:o.output})]}),c&&p&&f.jsx("div",{className:"flex flex-col gap-1",children:n.findings.map(x=>f.jsx(zne,{finding:x},`${x.file}:${x.line}:${x.rule}`))}),d&&m&&f.jsx("div",{className:"flex flex-col gap-1",children:r.map((x,y)=>{const v=g(x);return f.jsx(Fne,{issue:x,linkedPlan:v,onNavigate:()=>v&&i(Ri(v))},`${x.kind}-${x.title}-${y}`)})})]})]})},Vne=async()=>{try{const e=await J(K("/api/ci"));return e.ok?e.json():null}catch{return null}};function Une(){const[e,t]=k.useState(null),[n,r]=k.useState(!0),s=k.useCallback(async()=>{try{t(await Vne())}finally{r(!1)}},[]);return k.useEffect(()=>{s()},[s]),{ci:e,loading:n,refresh:s}}const PI="CI & release",Wne={success:"bg-chalk-pass-text",failure:"bg-chalk-fail-text",in_progress:"bg-chalk-running-text",queued:"bg-chalk-running-text",cancelled:"bg-desk-text-muted",unknown:"bg-desk-text-muted"},Kp="text-desk-chalk underline decoration-desk-border hover:decoration-desk-chalk",Hne=({run:e})=>{const t=f.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[f.jsx("span",{"aria-hidden":"true",className:`h-2 w-2 shrink-0 rounded-full ${Wne[e.status]}`}),f.jsx("span",{className:"min-w-0 overflow-hidden text-ellipsis whitespace-nowrap text-desk-chalk",children:e.workflow}),f.jsx("span",{className:"shrink-0 font-mono text-2xs text-desk-text-muted",children:e.status})]});return e.url?f.jsx("a",{href:e.url,target:"_blank",rel:"noreferrer",className:"no-underline",children:t}):t},Kne=()=>{const{ci:e,loading:t,refresh:n}=Une(),r=M(o=>o.refreshing),s=k.useRef(!1);k.useEffect(()=>{s.current&&!r&&n(),s.current=r},[r,n]);const i=()=>{var a;if(!e)return f.jsx(pe,{surface:"chalkboard",size:"small",children:f.jsx("p",{className:"m-0 text-center text-xs opacity-50",children:t?"Checking CI…":"No CI source declared."})});const o=`https://github.com/${e.repo}/actions`;return e.available?f.jsx(pe,{surface:"chalkboard",size:"small",children:f.jsxs("div",{className:"flex flex-col gap-2 text-sm",children:[e.runs.length>0?e.runs.map(l=>f.jsx(Hne,{run:l},l.workflow)):f.jsxs("span",{className:"text-xs text-desk-text-muted opacity-70",children:["No recent runs on ",e.branch,"."]}),f.jsxs("div",{className:"font-mono text-2xs text-desk-text-muted",children:["Released ",e.releasedVersion??"—"," · Queued ",((a=e.releasePr)==null?void 0:a.version)??"none"]}),f.jsxs("div",{className:"flex flex-wrap gap-x-3 text-2xs",children:[e.releasePr&&f.jsxs("a",{href:e.releasePr.url,target:"_blank",rel:"noreferrer",className:Kp,children:["Release PR #",e.releasePr.number]}),f.jsx("a",{href:o,target:"_blank",rel:"noreferrer",className:Kp,children:"Open Actions"})]})]})}):f.jsx(pe,{surface:"chalkboard",size:"small",children:f.jsxs("p",{className:"m-0 text-center text-xs opacity-70",children:["CI status unavailable —"," ",f.jsx("a",{href:o,target:"_blank",rel:"noreferrer",className:Kp,children:"open Actions"})]})})};return f.jsxs("div",{children:[f.jsx("h4",{className:`${ch} m-0`,children:PI}),i()]})},TI=async(e,t)=>{if(!e.ok){const n=await e.json().catch(()=>({error:t}));throw new Error(n.error??t)}},Gne=async()=>{const e=await J(K("/api/services"));return e.ok?(await e.json()).services??[]:[]},Zne=async e=>{const t=await J(K(`/api/services/start?name=${encodeURIComponent(e)}`),{method:"POST"});await TI(t,"Failed to start service")},qne=async e=>{const t=await J(K(`/api/services/stop?name=${encodeURIComponent(e)}`),{method:"POST"});await TI(t,"Failed to stop service")},Yne=async e=>{const t=await J(K(`/api/services/logs?name=${encodeURIComponent(e)}`));return t.ok?(await t.json()).log??"":""};function Jne(){const[e,t]=k.useState([]),[n,r]=k.useState(!0),s=k.useCallback(async()=>{try{t(await Gne())}catch{}finally{r(!1)}},[]);k.useEffect(()=>{s()},[s]),k.useEffect(()=>{let a;const l=()=>{a&&clearTimeout(a),a=setTimeout(s,80)},c=yc(u=>{(u.type==="service"||u.message==="changed")&&l()});return()=>{a&&clearTimeout(a),c()}},[s]);const i=k.useCallback(async a=>{await Zne(a),await s()},[s]),o=k.useCallback(async a=>{await qne(a),await s()},[s]);return{services:e,loading:n,start:i,stop:o,refresh:s}}const Qne=1500,NI="Services",Xne=e=>e.status==="crashed"?"bg-chalk-fail-text":e.status==="running"?e.health==="up"?"bg-chalk-pass-text":"bg-chalk-running-text":e.status==="stopping"?"bg-chalk-running-text":"bg-desk-text-muted",ere=({service:e})=>{const t=e.status==="running"?`running · ${e.health}`:e.status;return f.jsx("span",{role:"img","aria-label":t,className:`h-2 w-2 shrink-0 rounded-full ${Xne(e)}`,title:t})},tre=({name:e,running:t})=>{const[n,r]=k.useState(""),s=k.useRef(null);return k.useEffect(()=>{let i=!1;const o=async()=>{const l=await Yne(e);i||r(l)};o();const a=t?setInterval(o,Qne):void 0;return()=>{i=!0,a&&clearInterval(a)}},[e,t]),k.useEffect(()=>{const i=s.current;i&&n&&(i.scrollTop=i.scrollHeight)},[n]),f.jsx("pre",{ref:s,className:"m-0 mt-2 max-h-40 overflow-auto whitespace-pre-wrap break-words rounded-[8px] bg-desk-bg/60 p-2 font-mono text-2xs leading-relaxed text-desk-text-muted",children:n||"No output yet."})},nre=({service:e,onStart:t,onStop:n})=>{const{toast:r}=rt(),[s,i]=k.useState(!1),[o,a]=k.useState(!1),l=e.status==="running"||e.status==="stopping",c=e.pid!==null,u=async()=>{if(!s){i(!0);try{await(l?n:t)(e.name)}catch(d){r({title:l?"Failed to stop service":"Failed to start service",description:d.message,variant:"error"})}finally{i(!1)}}};return f.jsxs(pe,{surface:"chalkboard",size:"small",children:[f.jsxs("div",{className:"flex items-center justify-between gap-2",children:[f.jsxs("button",{type:"button",onClick:()=>a(d=>!d),"aria-expanded":o,className:"flex min-w-0 cursor-pointer items-center gap-2 border-none bg-transparent p-0 text-left",children:[f.jsx("span",{className:`shrink-0 text-desk-text-muted transition-transform ${o?"rotate-90":""}`,children:f.jsx(I8,{})}),f.jsx(ere,{service:e}),f.jsx("span",{className:"min-w-0 overflow-hidden text-ellipsis whitespace-nowrap font-display-luminari text-sm font-semibold text-desk-chalk",children:e.name}),e.port&&f.jsxs("span",{className:"shrink-0 font-mono text-2xs text-desk-text-muted",children:[":",e.port]})]}),f.jsx("div",{className:"flex shrink-0 items-center gap-1",children:s?f.jsx(Wr,{size:"small",surface:"chalkboard",label:"Working"}):!l||c?f.jsx(xt,{icon:l?f.jsx(N8,{}):f.jsx(T8,{}),surface:"chalkboard",size:"small",variant:"ghost",label:l?`Stop ${e.name}`:`Start ${e.name}`,onClick:u}):null})]}),o&&f.jsx(tre,{name:e.name,running:l})]})},rre=()=>{const{services:e,start:t,stop:n}=Jne(),r=k.useCallback(i=>t(i),[t]),s=k.useCallback(i=>n(i),[n]);return f.jsxs("div",{children:[f.jsx("h4",{className:`${ch} m-0`,children:NI}),f.jsx("div",{className:"flex flex-col gap-2",children:e.length>0?e.map(i=>f.jsx(nre,{service:i,onStart:r,onStop:s},i.name)):f.jsx(pe,{surface:"chalkboard",size:"small",children:f.jsx("p",{className:"m-0 text-center text-xs opacity-50",children:"No services declared."})})})]})},sre=[NI,EI,PI],ire=()=>f.jsx("div",{className:"flex flex-col gap-4","aria-hidden":"true",children:sre.map(e=>f.jsxs("div",{children:[f.jsx("div",{className:ch,children:e}),f.jsx(rn,{variant:"rect",width:"100%",height:28,surface:"chalkboard"})]},e))}),ore=()=>f.jsx("div",{className:"flex flex-1 items-center justify-center",children:f.jsxs("p",{className:"m-0 text-center text-xs text-desk-text-muted",children:["Desk isn't configured — add ",f.jsx("code",{children:"desk"})," to ",f.jsx("code",{children:"papercamp/config.json"}),"."]})}),are=()=>{const{desk:e,loading:t}=jne();return f.jsxs(f.Fragment,{children:[f.jsx(jP,{surface:"chalkboard"}),f.jsxs("div",{className:"flex flex-1 flex-col p-[var(--pc-stack-pad)]",children:[f.jsxs("div",{className:"flex items-center justify-between gap-2 mb-3",children:[f.jsx("h3",{className:`${wI} m-0`,children:"Desk"}),f.jsx(kI,{label:"Fetch from GitHub",refreshingLabel:"Fetching…",surface:"chalkboard"})]}),t?f.jsx(ire,{}):e?f.jsxs("div",{className:"flex flex-col gap-4",children:[f.jsx(rre,{}),f.jsx(Bne,{}),f.jsx(Kne,{})]}):f.jsx(ore,{})]})]})},lre=({open:e,onToggle:t,pinned:n=!1})=>{const r=e||n,s=k.useRef(null);k.useEffect(()=>{s.current&&(s.current.inert=!r)},[r]),k.useEffect(()=>{if(!r||n)return;const h=p=>{p.key==="Escape"&&t()};return window.addEventListener("keydown",h),()=>window.removeEventListener("keydown",h)},[r,n,t]);const i=M(h=>h.consistency),o=M(h=>h.doctor),a=M(h=>h.agentStatus);k.useEffect(()=>{const{loadStatus:h,loadConsistency:p,loadDoctor:m,loadGitStatus:g,loadAgentStatus:x,loadArchivableIdeas:y}=M.getState();h(),p(),m(),g(),x(),y()},[]),k.useEffect(()=>{const h=()=>{M.getState().loadPlans(),M.getState().loadGitStatus()};return window.addEventListener("focus",h),()=>window.removeEventListener("focus",h)},[]),k.useEffect(()=>{const h={},p=(g,x,y)=>{h[g]&&clearTimeout(h[g]),h[g]=setTimeout(x,y)},m=yc(g=>{if(g.type==="status"){p("status",()=>M.getState().loadStatus(),80);return}if(g.type==="agent"){p("agent",()=>M.getState().loadAgentStatus(),120);return}g.message==="changed"&&p("activity",()=>{const{loadPlans:x,loadSuggestions:y,loadStatus:v,loadConsistency:w,loadDoctor:b,loadGitStatus:_,loadAgentStatus:S,loadArchivableIdeas:j}=M.getState();x(),y(),v(),w(),b(),_(),S(),j()},250)});return()=>{for(const g of Object.values(h))g&&clearTimeout(g);m()}},[]);const{checks:l}=xc(),c=i.length>0,u=l.some(h=>h.status==="fail")||c||o.errorCount>0,d=a.some(h=>h.status==="running"||h.status==="starting"||h.status==="stopping");return f.jsxs(f.Fragment,{children:[!r&&f.jsx("div",{className:"fixed right-0 top-[var(--pc-stack-toggle-top,50%)] z-[300] rounded-l-md shadow-[-2px_0_8px_rgba(0,0,0,0.15)] bg-desk-bg bg-chalkboard [background-repeat:repeat,no-repeat] [background-size:200px_200px,auto]",style:{transform:"translateY(-50%)"},children:f.jsx(xt,{icon:d?f.jsx(Wr,{size:"small",surface:"chalkboard",label:"Agent running"}):u?f.jsx("span",{"aria-hidden":"true",className:"h-2 w-2 rounded-full bg-chalk-fail-text shadow-[0_0_6px_rgba(214,160,160,0.9)]"}):f.jsx("span",{className:"text-2xs",children:"S"}),surface:"chalkboard",size:"small",label:d?"Open stack panel — agent running":u?"Open stack panel — checks failing":"Open stack panel",onClick:t,className:`w-7 h-[64px] rounded-l-md ${d?"shadow-[inset_0_0_0_1px_rgba(214,196,160,0.6)]":u?"shadow-[inset_0_0_0_1px_rgba(214,160,160,0.6)]":""}`})}),f.jsxs("aside",{ref:s,"aria-label":"Stack",className:"fixed inset-y-0 right-0 z-[300] flex w-[min(var(--pc-stack-width),100vw)] flex-col overflow-hidden border-l-4 border-paper-950/[12%] text-desk-text bg-desk-bg bg-chalkboard [background-repeat:repeat,no-repeat] [background-size:200px_200px,auto]",style:{transform:r?"translateX(0)":"translateX(100%)"},children:[f.jsxs("div",{className:"flex h-14 shrink-0 items-center justify-between px-[var(--pc-stack-pad)]",children:[f.jsx("h2",{className:"m-0 font-display-luminari text-base font-bold text-desk-chalk",children:"Stack"}),!n&&f.jsx(xt,{icon:f.jsx("span",{className:"text-sm leading-none",children:"×"}),surface:"chalkboard",size:"small",label:"Close stack panel",onClick:t,className:"h-7 w-7 border border-desk-border"})]}),f.jsx(jP,{surface:"chalkboard"}),f.jsxs("div",{className:"flex min-h-0 flex-1 flex-col overflow-y-auto",children:[f.jsx(Cne,{}),f.jsx(are,{})]})]})]})},c1=({size:e="md"})=>{const{projectName:t,iconDataUri:n,loading:r}=Ane();return f.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[n?f.jsx("img",{src:n,alt:"",className:`object-contain shrink-0 ${e==="sm"?"w-[18px] h-[18px]":"w-[20px] h-[20px]"}`}):f.jsx(O6,{icon:f.jsx($4,{}),size:"small"}),f.jsx("span",{className:`font-display-luminari font-semibold whitespace-nowrap overflow-hidden text-ellipsis min-w-0 ${e==="sm"?"text-sm":"text-md"}`,children:r?"Loading…":t??"Paper Camp"})]})},cre="data-paper-camp-mount";function ure(e){return(e==null?void 0:e.getAttribute(cre))??""}const da=typeof document>"u"?"":ure(document.getElementById("root")),dre=()=>{const e=nt();return da!==""?f.jsx(c1,{size:"sm"}):f.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[f.jsx(c1,{size:"sm"}),f.jsx(re,{variant:"ghost",size:"small",className:"font-handwritten !text-sm opacity-70",onClick:()=>e({to:"/projects"}),children:"Back to projects"})]})},fre=()=>{const e=M(l=>l.setGithubConfig),[t,n]=k.useState(""),[r,s]=k.useState(""),[i,o]=k.useState(""),a=t.trim()!==""&&r.trim()!==""&&i.trim()!=="";return f.jsxs(pe,{size:"small",texture:"kraft",className:"mt-4 w-full max-w-sm text-left",children:[f.jsxs("p",{className:"m-0 mb-3 text-sm opacity-[0.65]",children:["No runtime reachable — paste a"," ",f.jsx("a",{href:"https://github.com/settings/personal-access-tokens/new",target:"_blank",rel:"noopener noreferrer",children:"fine-grained token"})," ","scoped to this repo to read and write the corpus directly."]}),f.jsxs("div",{className:"flex flex-col gap-2",children:[f.jsx(In,{size:"small",label:"Owner",value:t,onChange:l=>n(l.target.value)}),f.jsx(In,{size:"small",label:"Repo",value:r,onChange:l=>s(l.target.value)}),f.jsx(In,{size:"small",type:"password",label:"Token",value:i,onChange:l=>o(l.target.value)})]}),f.jsx(re,{size:"small",className:"mt-3",disabled:!a,onClick:()=>e({owner:t.trim(),repo:r.trim(),token:i.trim()}),children:"Save"})]})},hre=({layer:e})=>f.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-2 py-24 text-center",children:[f.jsx("p",{className:"font-handwritten text-lg",children:e==="corpus"?"This needs the runtime or a GitHub token":"This needs the runtime"}),f.jsx("p",{className:"max-w-sm text-sm opacity-60",children:e==="corpus"?"Connect the project's runtime, or go plan-only below.":"Connect the project's runtime to use this — it owns the filesystem, git and the agent."}),e==="corpus"&&f.jsx(fre,{})]}),pre=()=>{const[e,t]=k.useState(null);return k.useEffect(()=>{},[]),e?f.jsxs("div",{role:"alert",className:"bg-watercolor-rose-dark text-desk-text py-2 px-4 text-2xs font-mono shrink-0",children:["Server failed to reload — restart `pnpm dev` to pick up the change. ",e]}):null},mre=({routeKey:e,children:t,mobileOpen:n,onMobileClose:r})=>{const s=k.useRef(null);return k.useEffect(()=>{if(!n)return;const i=o=>{o.key==="Escape"&&r()};return window.addEventListener("keydown",i),()=>window.removeEventListener("keydown",i)},[n,r]),k.useEffect(()=>{var o;if(!n)return;const i=document.activeElement;return(o=s.current)==null||o.focus(),()=>{var a;return(a=i==null?void 0:i.focus)==null?void 0:a.call(i)}},[n]),f.jsxs(f.Fragment,{children:[n&&f.jsx("button",{type:"button",className:"lg:hidden fixed inset-0 z-[290] cursor-default border-none p-0 bg-ink-900/[40%] backdrop-blur-sm",onClick:r,"aria-label":"Close sidebar",tabIndex:-1}),f.jsxs("aside",{ref:s,role:n?"dialog":void 0,"aria-modal":n||void 0,"aria-label":"Sidebar navigation",tabIndex:-1,className:`fixed inset-y-0 left-0 z-[300] w-[224px] shrink-0 flex flex-col overflow-hidden lg:sticky lg:inset-auto lg:top-0 lg:z-auto lg:translate-x-0 h-[var(--pc-sidebar-h,100%)] ${n?"translate-x-0":"-translate-x-full"} ${n?"bg-[var(--pui-bg-base)] shadow-[2px_0_12px_rgba(0,0,0,0.15)]":"bg-transparent"}`,children:[f.jsx("div",{className:"shrink-0 h-8"}),f.jsx("div",{className:"flex-1 overflow-y-auto relative",children:f.jsx("div",{children:t},e)})]})]})};function Gp(e){return e==="allowed"?"allowed":/reject|block|exceed|denied/i.test(e)?"rejected":"warning"}function gre(e){return e<1e12?e*1e3:e}function yre(e){const t=[`Claude usage: ${e.status}`];return e.rateLimitType&&t.push(e.rateLimitType),e.resetsAt!==void 0&&t.push(`resets ${new Date(gre(e.resetsAt)).toLocaleTimeString()}`),e.overage&&t.push("overage on"),t.join(" · ")}const xre="flex items-center gap-3 h-8 px-4 border-b border-black/[0.08] text-xs shrink-0 box-border overflow-x-auto overflow-y-hidden whitespace-nowrap",vre="flex items-center gap-3 shrink-0",wre="flex items-center gap-1",bre="opacity-50",kre="text-[var(--pui-text-primary)]",u1="opacity-60",_re="flex-1",d1="flex items-center gap-2 shrink-0",f1="bg-transparent border-none p-0 cursor-pointer",Sre="relative inline-flex",Cre="absolute -top-1 -right-1 pointer-events-none",jre=({gitBranch:e,gitAhead:t,changedFileCount:n,agentActive:r,activeTaskStatus:s,agentNotSignedIn:i,capabilityGapCount:o,rateLimit:a,unreadNotificationCount:l,onOpenSetup:c,onOpenGit:u,onOpenNotifications:d,trailing:h})=>f.jsxs("div",{className:xre,style:Uo("kraft"),children:[f.jsxs("div",{className:vre,children:[f.jsxs("span",{className:wre,children:[f.jsx("span",{className:bre,children:f.jsx(uk,{size:12})}),f.jsx("code",{className:kre,children:e??"no branch"})]}),t>0&&f.jsxs("span",{className:u1,children:["↑",t]}),f.jsx("span",{className:u1,children:n>0?`${n} changed`:"clean"}),r&&f.jsx(Wr,{size:"small",label:`Agent ${s}…`}),i&&f.jsx(ye,{content:"Sign in from Settings → Connections so agent tasks can run",children:f.jsx("button",{type:"button",onClick:c,className:f1,children:f.jsx(ce,{size:"small",variant:"warning",children:"Agent not signed in"})})}),o>0&&f.jsx(ye,{content:"Some features are disabled — open Setup to fix",children:f.jsx("button",{type:"button",onClick:c,className:f1,children:f.jsxs(ce,{size:"small",variant:"warning",children:["Setup (",o,")"]})})}),a&&Gp(a.status)!=="allowed"&&f.jsx(ye,{content:yre(a),children:f.jsx(ce,{size:"small",variant:Gp(a.status)==="rejected"?"error":"warning",children:Gp(a.status)==="rejected"?"Claude limit reached":"Claude usage warning"})})]}),f.jsx("div",{className:_re}),h&&f.jsx("div",{className:d1,children:h}),f.jsxs("div",{className:d1,children:[f.jsx(ye,{content:"Git",children:f.jsx(xt,{variant:"ghost",size:"small",icon:f.jsx(uk,{}),label:"Git",onClick:u})}),f.jsx(ye,{content:"Notifications",children:f.jsxs("span",{className:Sre,children:[f.jsx(xt,{variant:"ghost",size:"small",icon:f.jsx(A8,{}),label:"Notifications",onClick:d}),l>0&&f.jsx("span",{className:Cre,children:f.jsx(ce,{size:"small",variant:"warning",children:l})})]})})]})]}),Ere=()=>{const e=M(g=>g.agentStatus),t=M(g=>g.gitStatus),n=M(g=>g.gitBranch),r=M(g=>g.gitAhead),s=M(mJ),i=M(gJ),o=M(yJ),a=M(g=>{var x;return((x=g.notifications)==null?void 0:x.filter(y=>y.kind==="question"||!y.read).length)??0}),l=nt(),c=e.find(g=>g.status==="running"||g.status==="starting"||g.status==="stopping"),u=c!==void 0,d=(t==null?void 0:t.length)??0,h=()=>l({to:"/settings/$section",params:{section:"setup"}}),p=()=>l({to:"/git"}),m=()=>l({to:"/inbox"});return f.jsx(jre,{gitBranch:n,gitAhead:r,changedFileCount:d,agentActive:u,activeTaskStatus:c==null?void 0:c.status,agentNotSignedIn:i,capabilityGapCount:s,rateLimit:o,unreadNotificationCount:a,onOpenSetup:h,onOpenGit:p,onOpenNotifications:m})},Pre=()=>{const e=nt(),t=uh(),n=SI(),r=M(l=>l.plans),s=Ine(),i=M(l=>l.activeDocTitle),o=M(l=>l.activeReleaseVersion),a=(()=>{if(t){const c=t.entityKind==="ticket"&&t.idea?((r==null?void 0:r.entries)??[]).find(u=>u.id===t.idea):void 0;return[{id:"plans",label:"Plans",onClick:()=>e({to:"/"})},...c?[{id:"board",label:c.title,onClick:()=>e(Ri(c))}]:[],{id:"plan",label:t.title}]}if(n)return[{id:"plans",label:"Plans",onClick:()=>e({to:"/"})},{id:"idea",label:n.title}];const l=s==="repo-docs"?i:s==="release-notes"?o:null;return l?[{id:"docs",label:"Docs",onClick:()=>e({to:"/docs"})},{id:"doc",label:l}]:null})();return a?f.jsx("div",{className:"-mt-6 mb-3",children:f.jsx(u8,{className:"font-handwritten !text-xs min-w-0",items:a})}):null},II=({children:e,className:t=""})=>f.jsx("h1",{className:`text-4xl font-display-luminari font-semibold text-ink-900 mb-6 leading-[1.1] ${t}`,children:e}),Tre=[{path:"/projects",label:"Projects"},{path:"/projects/reviews",label:"In review"},{path:"/projects/activity",label:"Agent activity"},{path:"/projects/ideas",label:"Ideas"}],Nre=({children:e})=>{const t=nt(),n=Xm({select:r=>r.location.pathname});return f.jsx(xP,{background:{texture:"speckle",ruledType:"grid",ruledColor:"blue"},showHeader:!1,showSidebar:!1,showPage:!1,bleedBottom:!0,children:f.jsx("div",{className:"flex min-h-screen flex-col items-center justify-center px-6 py-16",children:f.jsxs(Wx,{texture:{texture:"parchment"},className:"w-full max-w-lg",children:[f.jsx(II,{children:"Paper Camp"}),f.jsx("nav",{"aria-label":"Hub navigation",className:"flex flex-wrap gap-1 mb-4",children:Tre.map(r=>f.jsx(re,{variant:"ghost",size:"small",isActive:n===r.path,onClick:()=>t({to:r.path}),"aria-current":n===r.path?"page":void 0,children:r.label},r.path))}),e]})})})};async function Vv(e,t){return(await Promise.all(e.map(async r=>{const s=await t(r.runtimeUrl);return s===null?null:{runtime:r,data:s}}))).filter(r=>r!==null)}function Uv(e,t){RN(e,window.localStorage),window.location.assign(t)}function Ire(e,t){return e!==""||t!==""}async function Are(e,t){if(e!=="")return!1;try{const n=await t("/api/capabilities");return n.ok?(await n.json(),!0):!1}catch{return!1}}function Rre(e,t){return`${e}?runtime=${encodeURIComponent(t)}`}function ed(e){try{return new URL(e).host}catch{return e}}function Wv(e){return e.label??ed(e.runtimeUrl)}const Lre=24*60*60*1e3;function Mre(){const[e,t]=k.useState([]),[n,r]=k.useState(!0);return k.useEffect(()=>{let s=!1;r(!0);const i=Hl(window.localStorage),o=Date.now()-Lre;return Vv(i,O9).then(a=>{if(s)return;const l=a.flatMap(c=>c.data.map(u=>({runtime:c.runtime,data:u}))).filter(c=>new Date(c.data.startedAt).getTime()>=o).sort((c,u)=>u.data.startedAt.localeCompare(c.data.startedAt));t(l),r(!1)}),()=>{s=!0}},[]),{rows:e,loading:n}}function $re(){const[e,t]=k.useState([]),[n,r]=k.useState(!0);return k.useEffect(()=>{let s=!1;r(!0);const i=Hl(window.localStorage);return Vv(i,K9).then(o=>{s||(t(o.flatMap(a=>a.data.entries.map(l=>({runtime:a.runtime,data:l})))),r(!1))}),()=>{s=!0}},[]),{rows:e,loading:n}}function Dre(){const[e,t]=k.useState([]),[n,r]=k.useState(!0);return k.useEffect(()=>{let s=!1;r(!0);const i=Hl(window.localStorage);return Vv(i,tW).then(o=>{s||(t(o.flatMap(a=>a.data.entries.filter(l=>l.status==="review"&&!!l.id).map(l=>({runtime:a.runtime,data:l})))),r(!1))}),()=>{s=!0}},[]),{rows:e,loading:n}}const Ore="0.23.1",AI=Ore,zre={name:null,reachable:!1,remoteVersion:null,versionSkew:!1};function Fre(e){const[t,n]=k.useState({}),r=e.map(s=>s.runtimeUrl).join(`
299
299
  `);return k.useEffect(()=>{let s=!1;const i=r===""?[]:r.split(`
300
300
  `);return Promise.all(i.map(async o=>{const[a,l]=await Promise.all([c9(o),o9(o)]),c=l===null?zre:{name:a?DP(a):null,reachable:!0,remoteVersion:l,versionSkew:l!==AI};return[o,c]})).then(o=>{s||n(Object.fromEntries(o))}),()=>{s=!0}},[r]),t}const Bre={done:"success",error:"error",superseded:"neutral"},Vre=()=>{const{rows:e,loading:t}=Mre();return f.jsxs(pe,{size:"small",texture:"kraft",className:"flex flex-col gap-2 text-left",children:[f.jsx("p",{className:"m-0 font-semibold",children:"Agent activity, last 24 hours"}),t?f.jsx("p",{className:"m-0 text-sm opacity-70",children:"Checking every registered project…"}):e.length===0?f.jsx("p",{className:"m-0 text-sm opacity-70",children:"No agent runs in the last 24 hours."}):f.jsx("div",{className:"flex flex-col gap-1",children:e.map(({runtime:n,data:r})=>f.jsx(St,{size:"small",onClick:()=>{r.planId&&Uv(n.runtimeUrl,`/ideas/${r.planId}`)},action:f.jsx(ce,{size:"small",variant:Bre[r.outcome],children:r.outcome}),children:f.jsxs("span",{className:"flex flex-col gap-0.5 text-left",children:[f.jsx("span",{children:r.planTitle}),f.jsx("span",{className:"font-handwritten text-2xs opacity-60",children:Wv(n)})]})},`${n.runtimeUrl}:${r.id}`))})]})},Ure=({runtimeUrl:e,currentLabel:t,onRenamed:n})=>{const[r,s]=k.useState(!1),[i,o]=k.useState(t),a=()=>{s(!1),o(t)},l=()=>{tJ(e,i,window.localStorage),s(!1),n()};return f.jsxs(f.Fragment,{children:[f.jsx(re,{type:"button",variant:"ghost",size:"small",onClick:c=>{c.stopPropagation(),s(!0)},children:"Rename"}),f.jsx(Ni,{open:r,onClose:a,title:"Rename project",size:"small",children:f.jsxs("div",{className:"flex flex-col gap-4",children:[f.jsx(In,{label:"Name",value:i,onChange:c=>o(c.target.value),placeholder:"Project name",autoFocus:!0}),f.jsxs("div",{className:"flex justify-end gap-2",children:[f.jsx(re,{type:"button",variant:"ghost",onClick:a,children:"Cancel"}),f.jsx(re,{type:"button",variant:"primary",onClick:l,children:"Save"})]})]})})]})},RI=()=>{const[e,t]=k.useState(""),n=e.trim();return f.jsxs(pe,{size:"small",texture:"kraft",className:"flex flex-1 flex-col gap-2 text-left",children:[f.jsx("p",{className:"m-0 font-semibold",children:"Add a project by URL"}),f.jsxs("p",{className:"m-0 text-sm opacity-70",children:["Paste the address of a running ",f.jsx("code",{children:"paper-camp dev"})," this browser can reach — its LAN or tailnet address from another machine. ",f.jsx("code",{children:"localhost"})," only works on the machine running it."]}),f.jsx(In,{size:"small",label:"Runtime URL",placeholder:"http://localhost:3333",value:e,onChange:r=>t(r.target.value)}),f.jsx(re,{size:"small",disabled:n==="",onClick:()=>window.location.assign(Rre(window.location.pathname,n)),children:"Connect"})]})};async function Wre(){const e=await J(K("/api/github/device-code"),{method:"POST"});if(!e.ok)throw new Error("Could not reach GitHub.");return e.json()}async function Hre(e){return(await J(K("/api/github/device-token"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({device_code:e})})).json()}const Hv="papercamp:github-hub-token";function Kre(){try{return localStorage.getItem(Hv)}catch{return null}}function h1(e){try{localStorage.setItem(Hv,e)}catch{}}function p1(){try{localStorage.removeItem(Hv)}catch{}}const Gre="https://api.github.com";async function LI(e,t){const n=await fetch(`${Gre}${t}`,{headers:{Authorization:`Bearer ${e}`,Accept:"application/vnd.github+json"}});if(!n.ok){const r=await n.json().catch(()=>null);throw new kv((r==null?void 0:r.message)??`GitHub API error (${n.status})`,n.status)}return n.json()}async function Zre(e){const t=await LI(e,"/user");return{login:t.login,avatarUrl:t.avatar_url}}async function qre(e){const t=[];for(let n=1;;n++){const r=await LI(e,`/user/repos?per_page=100&affiliation=owner,collaborator&page=${n}`);if(!Array.isArray(r)||r.length===0||(t.push(...r.map(s=>s.full_name)),r.length<100))break}return t}const Yre="https://github.com/settings/personal-access-tokens/new";async function Zp(e){const[t,n]=await Promise.all([Zre(e),qre(e)]);return{identity:t,repoNames:n}}function m1(e){return e instanceof kv?e.message:"Could not reach GitHub."}const Jre=({state:e,error:t,onCancel:n})=>f.jsxs(pe,{size:"small",texture:"kraft",className:"flex flex-1 flex-col gap-2 text-left",children:[f.jsx("p",{className:"m-0 font-semibold",children:"Sign in with GitHub"}),f.jsx("p",{className:"m-0 text-sm opacity-70",children:"Enter this code on the GitHub tab that just opened:"}),f.jsxs("p",{className:"m-0 flex items-center gap-2 text-lg font-semibold tracking-widest",children:[e.userCode,f.jsx(Kd,{text:e.userCode})]}),t&&f.jsx("p",{className:"m-0 text-watercolor-rose-dark text-sm",children:t}),f.jsx(re,{size:"small",variant:"secondary",onClick:n,children:"Cancel"})]}),Qre=({connection:e,onDisconnect:t})=>f.jsxs(pe,{size:"small",texture:"kraft",className:"flex flex-1 flex-col gap-2 text-left",children:[f.jsxs("p",{className:"m-0 font-semibold",children:["Connected as ",e.identity.login]}),f.jsx("p",{className:"m-0 text-sm opacity-70",children:e.repoNames.length===0?"This token reaches no repositories yet.":`Reaches ${e.repoNames.length} ${e.repoNames.length===1?"repository":"repositories"}:`}),e.repoNames.length>0&&f.jsx("div",{className:"flex flex-col gap-1",children:e.repoNames.map(n=>f.jsx(St,{size:"small",children:n},n))}),f.jsx(re,{size:"small",variant:"secondary",onClick:t,children:"Disconnect"})]}),MI=()=>{const[e,t]=k.useState(""),[n,r]=k.useState(null),[s,i]=k.useState(!1),[o,a]=k.useState(null),[l,c]=k.useState(null),[u,d]=k.useState(!1),h=k.useRef(null);k.useEffect(()=>{const v=Kre();v&&(i(!0),Zp(v).then(w=>r(w)).catch(()=>{p1(),a("That token no longer works — reconnect below.")}).finally(()=>i(!1)))},[]);const p=()=>{const v=e.trim();v!==""&&(i(!0),a(null),Zp(v).then(w=>{h1(v),r(w),t("")}).catch(w=>a(m1(w))).finally(()=>i(!1)))},m=()=>{p1(),r(null),a(null)},g=async(v,w)=>{if(await new Promise(_=>setTimeout(_,w*1e3)),h.current!==v)return;const b=await Hre(v);if(h.current===v){if(b.access_token){h.current=null,h1(b.access_token);try{r(await Zp(b.access_token))}catch(_){a(m1(_))}c(null);return}if(b.error==="authorization_pending"){await g(v,w);return}if(b.error==="slow_down"){await g(v,b.interval??w+5);return}h.current=null,c(null),a(b.error_description??"GitHub sign-in did not complete.")}},x=()=>{d(!0),a(null),Wre().then(v=>{h.current=v.device_code,window.open(v.verification_uri,"_blank","noopener,noreferrer"),c({userCode:v.user_code,deviceCode:v.device_code,verificationUri:v.verification_uri}),g(v.device_code,v.interval)}).catch(()=>a("Could not reach GitHub.")).finally(()=>d(!1))},y=()=>{h.current=null,c(null),a(null)};return n?f.jsx(Qre,{connection:n,onDisconnect:m}):l?f.jsx(Jre,{state:l,error:o,onCancel:y}):f.jsxs(pe,{size:"small",texture:"kraft",className:"flex flex-1 flex-col gap-2 text-left",children:[f.jsx("p",{className:"m-0 font-semibold",children:"Connect GitHub"}),f.jsx("p",{className:"m-0 text-sm opacity-70",children:"Sign in to browse and plan against your repositories."}),f.jsx(re,{size:"small",disabled:u,onClick:x,children:u?"Starting…":"Sign in with GitHub"}),f.jsxs("p",{className:"m-0 text-sm opacity-70",children:["Or mint a"," ",f.jsx("a",{href:Yre,target:"_blank",rel:"noopener noreferrer",children:"fine-grained token"})," ","scoped to the repositories you want to browse and plan, then paste it in."]}),f.jsx(In,{size:"small",type:"password",label:"Token",value:e,onChange:v=>t(v.target.value)}),o&&f.jsx("p",{className:"m-0 text-watercolor-rose-dark text-sm",children:o}),f.jsx(re,{size:"small",variant:"secondary",disabled:e.trim()===""||s,onClick:p,children:s?"Connecting…":"Connect"})]})};function Xre(e){RN(e,window.localStorage),window.location.assign(da||"/")}function ese({status:e}){return e?e.reachable?e.versionSkew?f.jsx(ye,{content:`Runtime is on ${e.remoteVersion}, this client is on ${AI}`,children:f.jsx(ce,{size:"small",variant:"warning",children:"Version mismatch"})}):f.jsx(ce,{size:"small",variant:"success",children:"Can execute"}):f.jsx(ce,{size:"small",variant:"info",children:"Plan-only"}):f.jsx(ce,{size:"small",variant:"neutral",children:"Checking…"})}const tse=({runtimes:e,onChange:t})=>{const n=Fre(e);return f.jsxs("div",{className:"flex flex-col gap-4",children:[f.jsxs(pe,{size:"small",texture:"kraft",className:"flex flex-col gap-2 text-left",children:[f.jsx("p",{className:"m-0 font-semibold",children:"Projects"}),f.jsx("div",{className:"flex flex-col gap-1",children:e.map(r=>{const s=n[r.runtimeUrl],i=r.label??(s==null?void 0:s.name);return f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsx(St,{size:"small",className:"flex-1",onClick:()=>Xre(r.runtimeUrl),action:f.jsx(ese,{status:s}),children:i?f.jsxs("span",{className:"flex flex-col gap-0.5 text-left",children:[f.jsx("span",{children:i}),f.jsx("span",{className:"font-handwritten text-2xs opacity-60",children:ed(r.runtimeUrl)})]}):ed(r.runtimeUrl)}),f.jsx(Ure,{runtimeUrl:r.runtimeUrl,currentLabel:r.label??(s==null?void 0:s.name)??"",onRenamed:t}),f.jsx(xt,{variant:"danger",size:"small","aria-label":`Remove ${i??ed(r.runtimeUrl)}`,icon:f.jsx(rc,{size:14}),onClick:o=>{o.stopPropagation(),nJ(r.runtimeUrl,window.localStorage),t()}})]},r.runtimeUrl)})})]}),f.jsxs("div",{className:"flex flex-col gap-4 sm:flex-row",children:[f.jsx(MI,{}),f.jsx(RI,{})]})]})},nse=()=>f.jsxs("div",{className:"flex flex-col gap-6",children:[f.jsx("p",{className:"m-0 text-center text-sm opacity-70",children:"Nothing is open yet — connect GitHub, or add a project by its runtime URL."}),f.jsxs("div",{className:"flex flex-col gap-4 sm:flex-row",children:[f.jsx(MI,{}),f.jsx(RI,{})]})]}),g1=typeof window>"u"?null:window.localStorage,rse=()=>{const[e,t]=k.useState(()=>Hl(g1));return e.length===0?f.jsx(nse,{}):f.jsx(tse,{runtimes:e,onChange:()=>t(Hl(g1))})},sse=()=>{const{rows:e,loading:t}=$re(),[n,r]=k.useState(""),s=k.useMemo(()=>{const i=n.trim().toLowerCase();return i===""?e:e.filter(({data:o})=>o.title.toLowerCase().includes(i))},[e,n]);return f.jsxs(pe,{size:"small",texture:"kraft",className:"flex flex-col gap-2 text-left",children:[f.jsx("p",{className:"m-0 font-semibold",children:"Ideas"}),f.jsx(In,{size:"small",label:"Search",placeholder:"Search every registered project's ideas…",value:n,onChange:i=>r(i.target.value)}),t?f.jsx("p",{className:"m-0 text-sm opacity-70",children:"Checking every registered project…"}):s.length===0?f.jsx("p",{className:"m-0 text-sm opacity-70",children:e.length===0?"No ideas found across your registered projects.":"No matches."}):f.jsx("div",{className:"flex flex-col gap-1",children:s.map(({runtime:i,data:o})=>f.jsx(St,{size:"small",onClick:()=>{o.id&&Uv(i.runtimeUrl,`/ideas/${o.id}`)},action:f.jsx(ce,{size:"small",variant:"neutral",children:Wv(i)}),children:o.title},`${i.runtimeUrl}:${o.id??o.title}`))})]})},ise=()=>{const{rows:e,loading:t}=Dre();return f.jsxs(pe,{size:"small",texture:"kraft",className:"flex flex-col gap-2 text-left",children:[f.jsx("p",{className:"m-0 font-semibold",children:"In review"}),t?f.jsx("p",{className:"m-0 text-sm opacity-70",children:"Checking every registered project…"}):e.length===0?f.jsx("p",{className:"m-0 text-sm opacity-70",children:"Nothing in review across your registered projects."}):f.jsx("div",{className:"flex flex-col gap-1",children:e.map(({runtime:n,data:r})=>f.jsx(St,{size:"small",onClick:()=>Uv(n.runtimeUrl,`/ideas/${r.id}`),action:f.jsx(ce,{size:"small",variant:"info",children:Wv(n)}),children:r.title},`${n.runtimeUrl}:${r.id}`))})]})},y1=(e,t)=>{var n;return((n=e.find(r=>r.name===t))==null?void 0:n.status)??"stale"};function $I(e,t){var n;return{qualityStatus:y1(t,"lint"),testStatus:y1(t,"test"),consistencyStatus:((n=e==null?void 0:e.consistency)==null?void 0:n.status)??"stale"}}const ose=()=>{const e=M(g=>g.status),t=M(g=>g.runConsistencyCheck),{checks:n,run:r}=xc(),s=M(g=>g.consistency),i=M(g=>g.plans),o=nt(),[a,l]=k.useState(!1),{qualityStatus:c,testStatus:u,consistencyStatus:d}=k.useMemo(()=>$I(e,n),[e,n]),h=c==="running"||u==="running"||d==="running",p=s.length>0,m=k.useCallback(g=>g.planId?i==null?void 0:i.entries.find(x=>x.id===g.planId):void 0,[i==null?void 0:i.entries]);return{qualityStatus:c,testStatus:u,consistencyStatus:d,anyRunning:h,hasDocIssues:p,consistency:s,docsExpanded:a,setDocsExpanded:l,navigate:o,runDeskCheck:r,runConsistencyCheck:t,linkedPlanFor:m}},qp=new Map,x1=new Map,ase=e=>`commit-draft:${e}`;function lse(e,t){const{formKey:n,suggestedTitle:r,matchesSuggestionTask:s,beforeCommit:i}=t,o=M(N=>N.agentStatus),a=M(N=>N.loadGitStatus),l=M(N=>N.loadDiffFiles),c=M(N=>N.commitInFlight),u=M(N=>N.setCommitInFlight),{toast:d}=rt(),[h,p]=k.useState(""),[m,g]=k.useState(""),[x,y]=k.useState(!1),[v,w]=k.useState(!1),[b,_]=k.useState(null),S=k.useMemo(()=>e.map(N=>N.path),[e]),j=k.useMemo(()=>e.filter(N=>N.staged).length,[e]);k.useEffect(()=>{r&&!h&&p(r)},[r,h]);const E=ase(n);k.useEffect(()=>{const N=hc(E);p((N==null?void 0:N.title)??""),g((N==null?void 0:N.message)??"")},[E]),k.useEffect(()=>{!h&&!m||pc(E,{title:h,message:m})},[E,h,m]),k.useEffect(()=>{const N=qp.get(n)??Date.now();qp.set(n,N);const A=x1.get(n)??new Set,L=o.find(D=>s(D)&&D.suggestedCommit&&!A.has(D.id)&&(D.lastStreamAt??0)>N);L!=null&&L.suggestedCommit&&(A.add(L.id),x1.set(n,A),p(L.suggestedCommit.title),g(L.suggestedCommit.message))},[o,n,s]);const T=k.useCallback(async()=>{if(!h.trim()||c)return;y(!0),u(!0);let N;try{const A=i?await i(h.trim()):void 0;N=A==null?void 0:A.onFailure;const L=A==null?void 0:A.extraPath;if(j>0)L&&await U8(L),await Ng([],h.trim(),m.trim()||void 0);else{const D=L&&!S.includes(L)?[...S,L]:S;await Ng(D,h.trim(),m.trim()||void 0)}p(""),g(""),qp.set(n,Date.now()),Cv(E),await Promise.all([a(),l()])}catch(A){N&&await N(),d({title:"Commit failed",description:Ge(A.message),variant:"error"}),await Promise.all([a(),l()])}finally{y(!1),u(!1)}},[h,m,S,j,a,l,c,u,d,n,E,i]),P=k.useCallback(async()=>{if(S.length!==0){w(!0),_(null);try{const N=await LP(S);p(N.title),g(N.message)}catch(N){_(N.message)}finally{w(!1)}}},[S]);return{commitTitle:h,setCommitTitle:p,commitMessage:m,setCommitMessage:g,committing:x,commitInFlight:c,stagedCount:j,suggesting:v,suggestError:b,setSuggestError:_,handleCommit:T,handleSuggestFromChanges:P}}const vc=()=>{const e=M(a=>a.loadPlans),t=M(a=>a.runtimeReachable),n=M(a=>a.githubConfig),{toast:r}=rt(),[s,i]=k.useState(!1);return{patch:async(a,l,c)=>{i(!0);try{return!t&&n?await sY(n,a,l):await nW(a,l),await e(),!0}catch(u){return r({title:(c==null?void 0:c.errorTitle)??"Update failed",description:u.message,variant:"error"}),!1}finally{i(!1)}},updating:s}},cse=["core","cli","app","server","agent","plans","ideas","docs","settings","stack","ui","ci","config","deps","repo"];function use(e){var r;if(e.phases.length>0&&e.phases.every(s=>s.done))return{title:""};const t=((r=e.tags)==null?void 0:r.find(s=>cse.includes(s)))??"repo";return{title:`${e.kind??"feat"}(${t}): ${e.title}`}}const dse=(e,t)=>{const n=M(x=>x.status),{checks:r}=xc(),s=M(sh),i=M(x=>x.launchRunAll),{patch:o}=vc(),[a,l]=k.useState(!1),{title:c}=k.useMemo(()=>use(e),[e]),u=k.useMemo(()=>t.map(x=>x.path),[t]),d=k.useCallback(async x=>{if(!e.id||BY(u))return{};const y=e.id;return await o(e.title,{phases:FY(e.phases,x)})?{extraPath:VY(y),onFailure:async()=>{await o(e.title,{phases:e.phases})}}:{}},[e,u,o]),h=k.useCallback(x=>x.planId===e.id,[e.id]),p=lse(t,{formKey:e.id??"__plan-draft__",suggestedTitle:c,matchesSuggestionTask:h,beforeCommit:d}),m=!!e.id&&!s,g=k.useCallback(async()=>{if(!e.id||!n||a||s)return;const x=e.id;l(!0);try{const y=DY(e.fixes??[],n,r);await o(e.title,{fixes:y})&&await i(x)}finally{l(!1)}},[e,a,s,n,r,o,i]);return{...p,canFix:m,fixing:a,handleFix:g}},fse=3*6e4,hse=(e,t)=>{const n=M(o=>o.loadPlans),r=e.thread??[],s=r[r.length-1],i=e.id;k.useEffect(()=>{if(!i||!s||s.kind!=="chat")return;const o=setTimeout(()=>{E9(i).then(a=>{if(!a.skipped)return n()}).catch(()=>{})},fse);return()=>clearTimeout(o)},[t,i,s,n])},pse=e=>{const t=M(a=>a.loadPlans),{toast:n}=rt(),[r,s]=k.useState(null);return{promotingIndex:r,promoteToDurable:async(a,l)=>{if(!(!e.id||r!==null)){s(a);try{await hk(e.id,a,l),await t()}catch(c){n({title:"Promote failed",description:Ge(c.message),variant:"error"})}finally{s(null)}}},promoteToIdea:async(a,l)=>{if(!e.id||r!==null)return!1;s(a);try{const c=await VP(l);return await hk(e.id,a,"log",`Captured as ${c}: ${l.title}`).catch(()=>{}),await t(),!0}catch(c){return n({title:"Promote failed",description:Ge(c.message),variant:"error"}),!1}finally{s(null)}}}};function mse(e,t){const[n,r]=k.useState(""),[s,i]=k.useState(null),[o,a]=k.useState(null),l=e.thread??[],{promotingIndex:c,promoteToDurable:u,promoteToIdea:d}=pse(e);hse(e,!0);const h=WY(e);return k.useEffect(()=>{r(hc(h)??"")},[h]),k.useEffect(()=>{n&&pc(h,n)},[h,n]),{thread:l,input:n,setInput:r,pending:s,promotingIndex:c,ideaPromptIndex:o,handleSend:async()=>{const y=n.trim();y&&(i(y),r(""),await t(y)?Cv(h):r(v=>v||y),i(null))},handlePromote:(y,v)=>{v==="idea"?a(y):u(y,v)},handlePromoteToIdea:async y=>{o!==null&&await d(o,y)&&a(null)},closeIdeaPrompt:()=>a(null)}}const gse=()=>{const e=M(T=>T.plans),t=M(T=>T.plansError),n=M(T=>T.ideaEntries),r=M(T=>T.suggestions),s=M(T=>T.setDetailView),i=M(T=>T.planFilters),o=M(T=>T.setSubjectFilter),a=M(T=>T.dismissSuggestion),l=uh(),c=SI(),{planId:u,ideaId:d}=Ti({strict:!1}),h=nt(),p=CI(),{toast:m}=rt(),{subject:g}=cx({strict:!1});k.useEffect(()=>{o(g??null)},[g,o]);const x=u??d,y=k.useRef(x);k.useEffect(()=>{y.current!==x&&s("details"),y.current=x},[x,s]);const v=()=>{h({to:"/"})},w=T=>{var N;const P=(N=e==null?void 0:e.entries.find(A=>A.title===T))==null?void 0:N.id;p(P,T)},b=T=>{var N;const P=(N=n.find(A=>A.title===T))==null?void 0:N.id;h({to:"/ideas/$ideaId",params:{ideaId:_I(P,T)}})},_=T=>{p(T.id,T.title)},[S,j]=k.useState(null);return{plans:e,plansError:t,ideaEntries:n,suggestions:r,planFilters:i,activePlan:l,activeIdea:c,planId:u,ideaId:d,openSuggestion:S,setOpenSuggestion:j,handleBack:v,handleOpenPlan:w,handleOpenIdea:b,handleOpenArchivable:_,handleDismissSuggestion:async T=>{try{await a(T)}catch(P){m({title:"Failed to dismiss suggestion",description:P.message,variant:"error"})}}}},iy=.95,yse=3e4,oy={implement:{from:0,to:.6},verify:{from:.6,to:.9},checkbox:{from:.95,to:.95}};function xse(e){const t=[...e].sort((r,s)=>r-s),n=Math.floor(t.length/2);return t.length%2===0?(t[n-1]+t[n])/2:t[n]}function vse(e){const t=e.filter(s=>s.taskKind==="phase"&&s.outcome==="done").map(s=>Date.parse(s.endedAt)-Date.parse(s.startedAt)).filter(s=>Number.isFinite(s)&&s>0);if(t.length===0)return{};const n=xse(t),r={};for(const s of["implement","verify"]){const i=oy[s].to-oy[s].from;r[s]=n*i/iy}return r}function wse({anchor:e,anchorEnteredAt:t,lastStreamAt:n,now:r,medians:s}){if(!e)return 0;const i=oy[e],o=Math.min(i.from,iy),a=s==null?void 0:s[e];if(!a||a<=0||t===void 0||i.to===i.from)return o;const l=n===void 0?r:Math.min(r,n+yse),c=Math.min(1,Math.max(0,l-t)/a);return Math.min(i.from+c*(i.to-i.from),iy)}const bse=new Set(["starting","running","stopping"]),kse=1e3;function _se(e,t){const n=e!==void 0&&e.phaseIndex!==void 0&&bse.has(e.status),[r,s]=k.useState(()=>Date.now());return k.useEffect(()=>{if(!n)return;const i=setInterval(()=>s(Date.now()),kse);return()=>clearInterval(i)},[n]),!n||(e==null?void 0:e.phaseIndex)===void 0?null:{index:e.phaseIndex,fraction:wse({anchor:e.phaseAnchor,anchorEnteredAt:e.anchorEnteredAt,lastStreamAt:e.lastStreamAt,now:r,medians:vse(t)})}}const Sse=(e,{reload:t,notify:n})=>{const[r,s]=k.useState(!1),[i,o]=k.useState(!1),[a,l]=k.useState(null);return k.useEffect(()=>{l(null)},[e.id]),{sending:r,send:async d=>{if(!e.id)return!1;s(!0),l(null);try{const h={route:window.location.pathname,focusedIdeaId:e.id,viewport:{width:window.innerWidth,height:window.innerHeight}},{error:p,undo:m}=await j9(e.id,d,h);return await t(),m&&l(m),p&&n({title:"Agent did not reply",description:Ge(p),variant:"error"}),!0}catch(h){return n({title:"Message failed to send",description:Ge(h.message),variant:"error"}),!1}finally{s(!1)}},undo:a,undoing:i,undoEdit:async()=>{if(!(!e.id||!a)){o(!0);try{const{error:d}=await P9(e.id,a.commitSha);if(d){n({title:"Undo failed",description:Ge(d),variant:"error"});return}l(null),await t()}catch(d){n({title:"Undo failed",description:Ge(d.message),variant:"error"})}finally{o(!1)}}}}},Cse=async e=>{const t=await J(K(`/api/trail?id=${encodeURIComponent(e)}`));if(!t.ok)throw new Error("Failed to load the provenance trail");return t.json()},jse=e=>{const[t,n]=k.useState(null);return k.useEffect(()=>{if(n(null),!e)return;let r=!1;return Cse(e).then(s=>{r||n(s)}).catch(()=>{}),()=>{r=!0}},[e]),t},Ese=()=>{const[e,t]=k.useState(new Set);return k.useEffect(()=>{let n=!1;return zP().then(r=>{n||!r||t(new Set(r.horizons.flatMap(s=>s.items.map(i=>i.name))))}).catch(()=>{}),()=>{n=!0}},[]),e},Kv="Keep phases short: 3-7 phases, each a one-line imperative title. Add a description only when the phase isn't self-explanatory, and keep it to one sentence. Never restate the idea's body and never summarise the work you did.",DI="A title is a noun/verb phrase, at most 40 characters (roughly 3-6 words), no em-dash subtitles or trailing clauses — the symptom, mechanism, and detail belong in the body's first paragraph, not the title.";function Pse(e){const t=e.phases.map((s,i)=>`${i+1}. [${s.done?"x":" "}] ${s.text}`).join(`
301
301
  `),n=e.log&&e.log.length>0?e.log.map(s=>`- ${s.date}: ${s.text}`).join(`
@@ -421,5 +421,5 @@ Rules:
421
421
  `)}),f.jsx(Jp,{}),o.data?r&&!n?f.jsx(ye,{content:r,children:f.jsxs("span",{className:"inline-flex items-center gap-2",children:[f.jsx(b1,{pr:o.data,reviewing:n}),f.jsx(_1,{pr:o.data})]})}):f.jsxs(f.Fragment,{children:[f.jsx(b1,{pr:o.data,reviewing:n}),!n&&f.jsx(_1,{pr:o.data})]}):f.jsx(bu,{reached:!1,label:"PR"}),f.jsx(Jp,{}),f.jsx(bu,{reached:a.reached||!!t,label:c,tooltip:a.data,href:l==null?void 0:l.url})]})},WI=({open:e,onClose:t,onAdd:n,initialContent:r})=>{const[s,i]=k.useState(""),[o,a]=k.useState(""),[l,c]=k.useState(!1),[u,d]=k.useState(!1),[h,p]=k.useState(!1),[m,g]=k.useState(null),[x,y]=k.useState(null),[v,w]=k.useState(!1),[b,_]=k.useState(null),[S,j]=k.useState(null),E=M(z=>{var $;return(($=z.plans)==null?void 0:$.entries)??[]}),{patch:T}=vc();nt();const P=CI(),N=Lne(s,E.map(z=>({id:z.id,title:z.title,body:z.body,tags:z.tags,log:z.log})));k.useEffect(()=>{e&&(i(""),a(r??""),c(!1),d(!1),p(!1),g(null),w(!1),_(null),j(null))},[e,r]);const A=(z,$)=>{t(),P(z,$)},L=async()=>{const z=`${s.trim()}${o.trim()?`
422
422
 
423
423
  ${o.trim()}`:""}`;if(z){w(!0),j(null),_(null);try{const $=E.map(B=>({id:B.id,title:B.title,body:B.body,tags:B.tags}));_(await Y9(z,$))}catch($){j($.message)}finally{w(!1)}}},D=z=>{const $=E.find(B=>B.id===z);$&&A($.id,$.title)},R=async(z,$,B)=>{y(z);const V={date:new Date().toISOString().slice(0,10),text:s.trim()},Q=await T($,{log:[...B??[],V]},{errorTitle:"Extend failed"});y(null),Q&&t()},U=async z=>{if(z.preventDefault(),!(!s.trim()||h)){g(null),p(!0);try{await n({title:s.trim(),content:o.trim()||void 0,kind:l?"note":u?"board":void 0}),t()}catch($){g($.message)}finally{p(!1)}}};return f.jsx(Ni,{open:e,onClose:t,title:"New idea",size:"small",children:f.jsxs("form",{onSubmit:U,className:"flex flex-col gap-4",children:[f.jsx(In,{label:"Title",value:s,onChange:z=>i(z.target.value),placeholder:"Idea title…",helperText:"Noun/verb phrase, ≤40 chars — no subtitle; the detail goes in the description below.",disabled:h,autoFocus:!0,required:!0}),N.length>0&&f.jsxs("div",{className:"flex flex-col gap-2",children:[f.jsx("span",{className:"text-sm opacity-60 font-semibold",children:"Similar ideas"}),N.map(({candidate:z})=>{const $={id:z.id??null,title:z.title,body:z.body,log:z.log},B=E.filter(C=>C.id!==z.id);return f.jsx(pe,{size:"small",texture:"canvas",children:f.jsxs("div",{className:"flex flex-col gap-2",children:[f.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[f.jsx(Vs,{id:z.id}),f.jsx("span",{className:"overflow-hidden text-ellipsis whitespace-nowrap",children:z.title})]}),f.jsxs("div",{className:"flex justify-end gap-2",children:[f.jsx(re,{type:"button",variant:"ghost",size:"small",onClick:()=>A(z.id,z.title),children:"Open it"}),f.jsx(re,{type:"button",variant:"ghost",size:"small",disabled:!z.id||!s.trim()||x!==null,onClick:()=>z.id&&R(z.id,z.title,z.log),children:x===z.id?"Extending…":"Extend it instead"}),f.jsx(VI,{idea:$,otherPlans:B})]})]})},z.id??z.title)})]}),f.jsxs("div",{className:"flex flex-col gap-2",children:[f.jsx("div",{children:f.jsx(re,{type:"button",variant:"ghost",size:"small",disabled:!s.trim()||v,onClick:L,children:v?"Checking overlap…":"Check overlap"})}),S&&f.jsx("p",{className:"m-0 text-watercolor-rose-dark text-sm",children:S}),b&&f.jsx(pe,{size:"small",texture:"canvas",children:f.jsxs("div",{className:"flex flex-col gap-2",children:[f.jsx("span",{className:"font-semibold",children:b.verdict==="new"?"Looks genuinely new":b.verdict==="extend"?`Extends ${b.targetId??"an existing idea"}`:`Belongs inside ${b.targetId??"an existing idea"}`}),f.jsx("span",{className:"text-sm opacity-80",children:b.reasoning}),b.targetId&&f.jsx("div",{className:"flex justify-end",children:f.jsx(re,{type:"button",variant:"ghost",size:"small",onClick:()=>D(b.targetId),children:"Open it"})})]})})]}),f.jsx(Hx,{label:"Description",value:o,onChange:z=>a(z.target.value),placeholder:"Optional details…",disabled:h,rows:4}),f.jsx(Pg,{label:"Just a note (no plan needed)",checked:l,onChange:z=>{c(z.target.checked),z.target.checked&&d(!1)},disabled:h}),f.jsx(Pg,{label:"Board (decomposes into tickets instead of phases)",checked:u,onChange:z=>{d(z.target.checked),z.target.checked&&c(!1)},disabled:h}),m&&f.jsx("p",{className:"m-0 text-watercolor-rose-dark text-sm",children:m}),f.jsxs("div",{className:"flex justify-end gap-2",children:[f.jsx(re,{type:"button",variant:"ghost",onClick:t,disabled:h,children:"Cancel"}),f.jsx(re,{type:"submit",variant:"primary",disabled:!s.trim()||h,children:"Add"})]})]})})},Qse=({open:e,onClose:t,onConfirm:n})=>{const r=M(m=>{var g;return((g=m.plans)==null?void 0:g.entries)??[]}),[s,i]=k.useState([]),[o,a]=k.useState(new Set),[l,c]=k.useState(!1),[u,d]=k.useState(null);k.useEffect(()=>{if(e){const m=r.filter(g=>!!g.id&&g.phases.length===0&&g.status==="idea");i(m),a(new Set(m.map(g=>g.id))),c(!1),d(null)}},[e]);const h=m=>{a(g=>{const x=new Set(g);return x.has(m)?x.delete(m):x.add(m),x})},p=async()=>{c(!0),d(null);try{await n([...o]),t()}catch(m){d(m.message)}finally{c(!1)}};return f.jsx(Ni,{open:e,onClose:t,title:"Draft all",size:"small",children:f.jsxs("div",{className:"flex flex-col gap-4",children:[f.jsxs("p",{className:"m-0 opacity-80",children:[s.length," undrafted idea",s.length===1?"":"s"," will be turned into a plan."]}),s.length>0&&f.jsx("div",{className:"flex max-h-[16rem] flex-col gap-2 overflow-y-auto",children:s.map(m=>f.jsx(vP,{label:m.title,checked:o.has(m.id),onChange:()=>h(m.id)},m.id))}),u&&f.jsx("p",{className:"m-0 text-watercolor-rose-dark text-sm",children:u}),f.jsxs("div",{className:"flex justify-end gap-2",children:[f.jsx(re,{type:"button",variant:"ghost",onClick:t,disabled:l,children:"Cancel"}),f.jsx(re,{type:"button",variant:"primary",onClick:p,disabled:l||o.size===0,children:l?"Starting…":`Draft ${o.size}`})]})]})})},Xse=({suggestion:e,onClose:t})=>{const n=M(u=>u.promoteSuggestion),r=M(u=>u.launchIdeaExtend),[s,i]=k.useState(!1),[o,a]=k.useState(null),{toast:l}=rt();k.useEffect(()=>{e&&(i(!1),a(null))},[e]);const c=async()=>{if(e){i(!0),a(null);try{const u=await n(e),d=M.getState().ideaEntries.find(h=>h.id===u);if(d)try{await r(u,Ase(d))}catch(h){l({title:"Idea created, but the refine agent failed to launch",description:Ge(h.message),variant:"error"})}t()}catch(u){a(u.message)}finally{i(!1)}}};return f.jsx(Ni,{open:e!==null,onClose:t,title:(e==null?void 0:e.title)??"",size:"small",children:f.jsxs("div",{className:"flex flex-col gap-4",children:[f.jsx("p",{className:"m-0 opacity-80",children:e==null?void 0:e.description}),o&&f.jsx("p",{className:"m-0 text-watercolor-rose-dark text-sm",children:o}),f.jsxs("div",{className:"flex justify-end gap-2",children:[f.jsx(re,{type:"button",variant:"ghost",onClick:t,disabled:s,children:"Cancel"}),f.jsx(re,{type:"button",variant:"primary",onClick:c,disabled:s,children:s?"Moving…":"Move to ideas"})]})]})})},Qp=({tokens:e})=>f.jsx(f.Fragment,{children:e.map((t,n)=>{if(t.type==="same")return f.jsx("span",{children:t.text},`${t.type}-${n}`);const r=t.type==="added";return f.jsx("span",{className:r?"bg-watercolor-green/[30%] text-watercolor-green-dark no-underline":"bg-watercolor-rose/[30%] text-watercolor-rose-dark line-through",children:t.text},`${t.type}-${n}`)})}),E1=e=>f.jsx("h4",{className:"font-display-luminari text-xs font-semibold mb-2 opacity-[0.65]",children:e}),eie=({plan:e,before:t,onApprove:n,onDiscard:r,queuePosition:s})=>{const[i,o]=k.useState(!1),[a,l]=k.useState(!1),c=e.body!==t.body,u=e.phases.map((m,g)=>({phase:m,before:t.phases[g],index:g})).filter(({phase:m,before:g})=>g!==void 0&&(m.text!==g.text||(m.description??"")!==(g.description??""))),d=i||a,h=async()=>{if(!d){o(!0);try{await r()}finally{o(!1)}}},p=async()=>{l(!0);try{await n()}finally{l(!1)}};return f.jsx(Ni,{open:!0,title:s?`Review reconcile changes (${s.index} of ${s.total})`:"Review reconcile changes",size:"large",onClose:d?()=>{}:h,children:f.jsxs("div",{className:"flex flex-col gap-5",children:[f.jsxs("p",{className:"text-sm m-0 opacity-70",children:['The reconcile agent proposed the rewrite below for "',e.title,'". Approve to keep it, or discard to revert to the prior wording.']}),!c&&u.length===0&&f.jsx("p",{className:"text-sm m-0 opacity-60",children:"No wording changed."}),c&&f.jsxs("div",{children:[E1("Body"),f.jsx("p",{className:"text-base m-0 leading-normal",children:f.jsx(Qp,{tokens:Np(t.body,e.body)})})]}),u.length>0&&f.jsxs("div",{children:[E1("Phases"),f.jsx("div",{className:"flex flex-col gap-3",children:u.map(({phase:m,before:g,index:x})=>f.jsxs("div",{className:"text-sm leading-normal",children:[f.jsx(Qp,{tokens:Np(g.text,m.text)}),(m.description||g.description)&&f.jsx("div",{className:"opacity-[0.85] mt-1",children:f.jsx(Qp,{tokens:Np(g.description??"",m.description??"")})})]},x))})]}),f.jsxs("div",{className:"flex justify-end gap-2",children:[f.jsx(re,{variant:"danger",size:"small",onClick:h,disabled:d,children:"Discard"}),f.jsx(re,{variant:"primary",size:"small",onClick:p,disabled:d,children:"Approve"})]})]})})},dh=({order:e,done:t,running:n,status:r,fallback:s})=>f.jsx("span",{className:"flex-[0_0_36px] flex items-center justify-center",children:n?f.jsx(Wr,{size:"small",label:"Agent running"}):t?f.jsx("span",{"aria-label":"Done",className:"text-watercolor-green-dark text-sm",children:"✓"}):e!==void 0?s?f.jsx(ye,{content:"Queue position based on a status guess — GitHub's PR state couldn't be resolved",children:f.jsx(ce,{size:"small",variant:"warning",dot:!0,children:f.jsx("span",{className:"font-handwritten text-xs leading-none",children:e})})}):f.jsx(ce,{size:"small",fillColor:"rgba(0,0,0,0.06)",children:f.jsx("span",{className:"font-handwritten text-xs leading-none",children:e})}):r==="idea"?f.jsx("span",{"aria-label":"Backlog — not planned yet",className:"inline-flex text-ink-300",children:f.jsx(AP,{size:14})}):null}),Ko="grid grid-cols-[76px_minmax(0,1fr)_84px_96px_112px] gap-2.5 items-center max-lg:grid-cols-[76px_minmax(0,1fr)_96px_112px] max-[480px]:grid-cols-1 max-[480px]:gap-1",HI=({plans:e,activePlanTitle:t,onOpen:n})=>{const r=Ko,s=M(i=>i.agentStatus);return f.jsx("div",{className:"flex flex-col gap-1",children:e.map(i=>{var l;const o=_N(i),a=nh(i,s);return f.jsxs("div",{className:"flex items-center",children:[f.jsx(dh,{order:i.order,done:i.status==="done",status:i.status,running:!!th(i.id,s),fallback:i.statusFallback}),f.jsx("div",{role:n?"button":void 0,tabIndex:n?0:void 0,onClick:n?()=>n(i.title):void 0,onKeyDown:n?c=>{(c.key==="Enter"||c.key===" ")&&(c.preventDefault(),n(i.title))}:void 0,className:`${n?"cursor-pointer":""} rounded-[10px] flex-1 min-w-0 ${i.title===t?"plan-row-highlighted outline outline-2 outline-offset-[-2px] outline-[rgba(200,154,90,0.5)]":""}`,children:f.jsx(pe,{size:"small",texture:"canvas",className:"plan-row-card",children:f.jsxs("div",{className:r,children:[f.jsx(Vs,{id:i.id}),f.jsx("span",{className:"font-semibold overflow-hidden text-ellipsis whitespace-nowrap",children:i.title}),f.jsx("span",{className:"max-lg:hidden text-sm opacity-[0.45] whitespace-nowrap",children:i.updated?Wg(i.updated):Wg(i.created)}),o?f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsx("div",{className:"flex-1 min-w-0",children:f.jsx(UI,{pct:o.pct,color:zI[a]})}),f.jsxs("span",{className:"text-sm opacity-50 shrink-0",children:[o.done,"/",o.total]})]}):f.jsx("span",{className:"text-sm opacity-30",children:"—"}),f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsx(ce,{size:"small",fillColor:fn[a].fill,textColor:fn[a].text,children:wc[a]}),i.statusFallback&&f.jsx(ye,{content:"GitHub's PR state couldn't be resolved — this status is a guess from local data",children:f.jsx(ce,{size:"small",variant:"warning",dot:!0,children:"Guess"})}),((l=i.pr)==null?void 0:l.state)==="merged"&&f.jsx(ye,{content:`Merged in #${i.pr.number}`,children:f.jsx("span",{className:"inline-flex text-[#7B5E9E]",children:f.jsx(NP,{size:14})})})]})]})})})]},i.title)})})},tie=({onOpen:e})=>{const t=M(m=>m.archivableIdeas),n=M(m=>m.archiveIdeas),r=M(m=>m.planFilters.search),[s,i]=k.useState(null),[o,a]=k.useState(!1),{toast:l}=rt(),c=r.trim().toLowerCase(),u=c?t.filter(m=>m.title.toLowerCase().includes(c)):t,d=k.useCallback(async m=>{try{await n(m)}catch(g){l({title:"Archive failed",description:g.message,variant:"error"})}},[n,l]),h=k.useCallback(async m=>{i(m.id);try{await d([m.id])}finally{i(null)}},[d]),p=k.useCallback(async()=>{a(!0);try{await d(u.map(m=>m.id))}finally{a(!1)}},[d,u]);return u.length===0?null:f.jsxs("div",{className:"mt-5",children:[f.jsxs("div",{className:"flex items-center justify-between gap-2 mb-2",children:[f.jsxs("h2",{className:"text-sm m-0 opacity-60",children:["Ready to archive (",u.length,")"]}),f.jsx(re,{variant:"ghost",size:"small",disabled:o||s!==null,onClick:p,children:o?"Archiving…":"Archive all"})]}),f.jsx("div",{className:"flex flex-col gap-1",children:u.map(m=>f.jsxs("div",{className:"flex items-center",children:[f.jsx(dh,{done:!0}),f.jsx("div",{role:e?"button":void 0,tabIndex:e?0:void 0,onClick:e?()=>e(m):void 0,onKeyDown:e?g=>{(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),e(m))}:void 0,className:`${e?"cursor-pointer":""} rounded-[10px] flex-1 min-w-0`,children:f.jsx(pe,{size:"small",texture:"canvas",shade:!0,className:"plan-row-card",children:f.jsxs("div",{className:Ko,children:[f.jsx(Vs,{id:m.id}),f.jsx("span",{className:"font-semibold overflow-hidden text-ellipsis whitespace-nowrap",children:m.title}),f.jsx("span",{className:"max-lg:hidden text-sm opacity-30",children:"—"}),f.jsx("span",{className:"text-sm opacity-30",children:"—"}),f.jsx(re,{variant:"ghost",size:"small",className:"archive-row-action",disabled:s===m.id||o,onClick:g=>{g.stopPropagation(),h(m)},onKeyDown:g=>g.stopPropagation(),children:s===m.id?"Archiving…":"Archive"})]})})})]},m.id))})]})},nie="font-display-luminari text-sm font-semibold opacity-[0.65]",rie=({clarifications:e})=>e.length===0?null:f.jsxs("div",{className:"mb-5",children:[f.jsx("h3",{className:`${nie} mb-3`,children:"Clarifications"}),f.jsx("div",{className:"flex flex-col gap-2 mb-3",children:e.map((t,n)=>f.jsx("div",{className:"text-sm flex items-start justify-between gap-3 opacity-75",children:f.jsxs("span",{children:[f.jsx("span",{className:"font-semibold mr-2",children:t.date}),t.text]})},`clar-${t.date}-${n}`))})]}),sie=({plan:e})=>{const t=M(i=>i.gitStatus),n=k.useMemo(()=>(t==null?void 0:t.map(i=>({path:i.path,staged:i.staged})))??[],[t]),r=dse(e,n),s=n.length>0;return f.jsxs("div",{className:"flex min-h-[7rem] flex-col items-center justify-center gap-3",children:[f.jsx(Bse,{}),s?f.jsxs(f.Fragment,{children:[f.jsx("div",{className:"w-full max-w-md",children:f.jsx(L8,{state:r,filesEmpty:!1})}),f.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-4",children:[f.jsx(zse,{count:n.length}),f.jsx(Vse,{state:r,filesEmpty:!1})]})]}):f.jsx(Use,{})]})},iie="font-display-luminari font-semibold text-[1.75rem] leading-[1.2]",oie=({onAdd:e,disabled:t,entityId:n})=>{const[r,s]=k.useState(!1),[i,o]=k.useState(""),[a,l]=k.useState(null),[c,u]=k.useState(!1),d=`review-phases-draft:${n}`;k.useEffect(()=>{o(hc(d)??"")},[d]),k.useEffect(()=>{i&&pc(d,i)},[d,i]);const h=()=>{s(!1),o(""),l(null),Cv(d)},p=async()=>{let m;try{m=AY(i)}catch(g){l(g instanceof Error?g.message:"Could not parse findings");return}u(!0),l(null);try{await e(m),h()}finally{u(!1)}};return f.jsxs(f.Fragment,{children:[f.jsx(ye,{content:"Add code-review findings as phases",children:f.jsx(xt,{variant:"ghost",size:"small",onClick:()=>s(!0),disabled:t,"aria-label":"Add code-review findings as phases",icon:f.jsx(kP,{size:16})})}),f.jsx(Ni,{open:r,onClose:h,title:"Add code-review findings",size:"small",children:f.jsxs("div",{className:"flex flex-col gap-4",children:[f.jsxs("p",{className:"text-sm m-0 opacity-70",children:["Paste the JSON findings from a ",f.jsx("code",{children:"/code-review"})," run. Each finding becomes a new, unchecked phase on this plan."]}),f.jsx(Hx,{value:i,onChange:m=>o(m.target.value),placeholder:'[{ "description": "...", "file": "src/foo.ts", "line_start": 12, "failure_scenario": "..." }]',rows:10,disabled:c}),a&&f.jsxs(CP,{variant:"warning",children:["Could not add phases — ",a]}),f.jsxs("div",{className:"flex justify-end gap-2",children:[f.jsx(re,{type:"button",variant:"ghost",onClick:h,disabled:c,children:"Cancel"}),f.jsx(re,{type:"button",variant:"primary",onClick:p,disabled:c||!i.trim(),children:"Add phases"})]})]})})]})},aie=({onAdd:e,disabled:t})=>{const[n,r]=k.useState(!1),[s,i]=k.useState(""),[o,a]=k.useState(!1),[l,c]=k.useState(null),u=()=>{r(!1),i(""),c(null)},d=async()=>{if(s.trim()){a(!0),c(null);try{await e(s.trim()),u()}catch(h){c(h.message)}finally{a(!1)}}};return f.jsxs(f.Fragment,{children:[f.jsx(ye,{content:"Add a ticket to this board",children:f.jsx(xt,{variant:"ghost",size:"small",onClick:()=>r(!0),disabled:t,"aria-label":"Add a ticket to this board",icon:f.jsx(kP,{size:16})})}),f.jsx(Ni,{open:n,onClose:u,title:"Add ticket",size:"small",children:f.jsxs("div",{className:"flex flex-col gap-4",children:[f.jsx(In,{label:"Title",value:s,onChange:h=>i(h.target.value),placeholder:"Ticket title…",disabled:o,autoFocus:!0,required:!0}),l&&f.jsx("p",{className:"m-0 text-watercolor-rose-dark text-sm",children:l}),f.jsxs("div",{className:"flex justify-end gap-2",children:[f.jsx(re,{type:"button",variant:"ghost",onClick:u,disabled:o,children:"Cancel"}),f.jsx(re,{type:"button",variant:"primary",onClick:d,disabled:o||!s.trim(),children:"Add"})]})]})})]})},lie=({plan:e,disabled:t})=>{const n=M(l=>l.launchPlanAudit),r=M(Hr),[s,i]=k.useState(!1),o=async()=>{if(e.id){i(!0);try{await n(e.id,Pse(e))}catch(l){alert(l.message)}finally{i(!1)}}},a=e.id?r?void 0:"No agent CLI found — set up in Settings":"Plan needs an ID before an agent can run";return f.jsx(ye,{content:a,children:f.jsx(re,{variant:"ghost",size:"small",onClick:o,disabled:t||s||!e.id||!r,children:"Audit"})})};function KI(e){const[t,n]=k.useState(null),r=k.useCallback(async()=>{n(e?await C9(e):null)},[e]);return k.useEffect(()=>{r()},[r]),k.useEffect(()=>{let s;const i=yc(o=>{o.message==="changed"&&(s&&clearTimeout(s),s=setTimeout(r,250))});return()=>{s&&clearTimeout(s),i()}},[r]),t}const cie=({plan:e,disabled:t})=>{const n=M(u=>u.refreshAll),[r,s]=k.useState(!1),{toast:i}=rt(),o=KI(e.id),a=pY(e,o==null?void 0:o.ciGreen),l=async()=>{if(e.id){s(!0);try{const u=await q8(e.id);u.needsAttention?i({title:"Merged — main needs manual sync",description:Ge(u.needsAttention),variant:"error"}):i({title:"Idea complete",description:`${e.id} merged — main is up to date`,variant:"success"}),await n()}catch(u){i({title:"Complete failed",description:Ge(u.message),variant:"error"})}finally{s(!1)}}},c=t||r||!e.id||!a.ready;return f.jsxs("div",{className:"flex flex-col gap-0.5",children:[f.jsx(St,{size:"small",icon:f.jsx("span",{className:"text-watercolor-green-dark",children:"✓"}),onClick:l,disabled:c,className:`pc-row text-xs ${c?"opacity-50":""}`,children:r?"Completing…":"Complete idea"}),!a.ready&&a.missing.length>0&&f.jsxs("div",{className:"text-2xs text-ink-300 px-2",children:["Waiting on ",a.missing.join(", ")]})]})},uie=({plan:e,disabled:t})=>{const n=M(c=>c.gitBranch),r=M(c=>c.loadGitStatus),[s,i]=k.useState(!1),{toast:o}=rt(),a=async()=>{if(e.id){i(!0);try{const{branch:c,warning:u}=await J8(e.id);o({title:"Branch ready",description:`Now on ${c}`,variant:"success"}),u&&o({title:"Stale fork",description:u,variant:"warning"}),await r()}catch(c){o({title:"Branch failed",description:Ge(c.message),variant:"error"})}finally{i(!1)}}},l=t||s||!e.id;return f.jsxs("div",{className:"flex flex-col gap-0.5",children:[f.jsx(ye,{content:e.id?`Creates ${(e.kind??"feat").toLowerCase()}/${e.id.toLowerCase()}-… from main, or switches to it if it already exists`:void 0,children:f.jsx(St,{size:"small",icon:f.jsx("span",{className:"text-ink-500",children:"⎇"}),onClick:a,disabled:l,className:`pc-row text-xs ${l?"opacity-50":""}`,children:s?"Switching…":"Create branch"})}),f.jsxs("div",{className:"text-2xs text-ink-300 px-2",children:[f.jsx("code",{children:n??"unknown"})," — not this plan's branch"]})]})},GI=({idea:e,compact:t})=>{const n=M(h=>h.launchIdeaExtend),r=M(Hr),{state:s,errorMessage:i,run:o}=BI(),{toast:a}=rt(),l=e.id,c=()=>{l&&o(async()=>{const h=M.getState().ideaEntries.find(p=>p.id===l);if(!h)throw new Error(`Idea ${l} not found`);try{await n(l,Ise(h))}catch(p){throw a({title:"Extension failed",description:Ge(p.message),variant:"error"}),p}})},u=s==="loading"?"Extending…":s==="success"?t?"Sent!":"Extension sent!":s==="error"?"Extension failed":t?"Extend":"Extend with AI",d=s==="error"?i??"Extension failed":l?r?void 0:"No agent CLI found — set up in Settings":"Idea needs an ID before an agent can run";return f.jsx(ye,{content:d,children:f.jsx(re,{variant:"ghost",size:"small",onClick:c,disabled:s==="loading"||!l||!r,className:s==="error"?"text-watercolor-rose-dark":void 0,children:u})})},die=({plan:e,disabled:t})=>{const n=M(u=>u.launchFixReview),r=M(Hr),s=M(MN),[i,o]=k.useState(!1),a=async()=>{if(e.id){o(!0);try{await n(e.id)}catch(u){alert(u.message)}finally{o(!1)}}},l=t||i||!e.id||!r||!s,c=e.id?s?r?void 0:"No agent CLI found — set up in Settings":"GitHub CLI needs authentication — set up in Settings":"Plan needs an ID before an agent can run";return f.jsx(ye,{content:c,children:f.jsx(St,{size:"small",icon:f.jsx("span",{className:"text-watercolor-amber-dark",children:"⚑"}),onClick:a,disabled:l,className:`text-xs leading-4 py-2 ${l?"opacity-50":""}`,children:i?"Starting…":"Fix review comments"})})},fie=()=>{const e=M(o=>o.loadIdeas),t=M(o=>o.runtimeReachable),n=M(o=>o.githubConfig),[r,s]=k.useState(!1),i=async o=>{!t&&n?await tY(n,o):await VP(o),await e(),s(!1)};return f.jsxs(f.Fragment,{children:[f.jsx(re,{icon:f.jsx(wP,{size:16}),size:"small",onClick:()=>s(!0),children:"New idea"}),f.jsx(WI,{open:r,onClose:()=>s(!1),onAdd:i})]})},hie=({plan:e,disabled:t})=>{const n=M(m=>m.launchPrReview),r=M(Hr),s=M(MN),[i,o]=k.useState(!1),a=KI(e.id),l=async()=>{if(e.id){o(!0);try{await n(e.id)}catch(m){alert(m.message)}finally{o(!1)}}},c=t||i||!e.id||!r||!s,u=e.id?s?r?void 0:"No agent CLI found — set up in Settings":"GitHub CLI needs authentication — set up in Settings":"Plan needs an ID before an agent can run",d=!!(a!=null&&a.lastReviewedSha&&a.headSha&&a.lastReviewedSha===a.headSha),h=i?"Starting…":d?`Review again — last reviewed at ${((a==null?void 0:a.lastReviewedSha)??"").slice(0,7)}`:"Review PR",p=[a&&!a.ready&&"draft",(a==null?void 0:a.ciGreen)===!1&&"CI not green"].filter(Boolean);return f.jsxs("div",{className:"flex flex-col gap-0.5",children:[f.jsx(ye,{content:u,children:f.jsx(St,{size:"small",icon:f.jsx("span",{className:"text-watercolor-blue-dark",children:"◎"}),onClick:l,disabled:c,className:`text-xs leading-4 py-2 ${c?"opacity-50":""}`,children:h})}),p.length>0&&f.jsx("div",{className:"text-2xs text-ink-300 px-2",children:p.join(" · ")})]})},pie=({plan:e,disabled:t})=>{const n=M(l=>l.launchPlanReconcile),r=M(Hr),[s,i]=k.useState(!1),o=async()=>{if(e.id){i(!0);try{await n(e.id,Tse(e),{body:e.body,phases:e.phases})}catch(l){alert(l.message)}finally{i(!1)}}},a=e.id?r?void 0:"No agent CLI found — set up in Settings":"Plan needs an ID before an agent can run";return f.jsx(ye,{content:a,children:f.jsx(re,{variant:"ghost",size:"small",onClick:o,disabled:t||s||!e.id||!r,children:"Refresh"})})},mie=({plan:e,disabled:t})=>{const n=M(c=>c.launchRunAll),r=M(Hr),[s,i]=k.useState(!1),o=async()=>{if(e.id){i(!0);try{await n(e.id)}catch(c){alert(c.message)}finally{i(!1)}}},a=t||s||!e.id||!r,l=e.id?r?void 0:"No agent CLI found — set up in Settings":"Plan needs an ID before an agent can run";return f.jsx(ye,{content:l,children:f.jsx(St,{size:"small",icon:f.jsx("span",{className:"text-ink-500",children:"▶"}),onClick:o,disabled:a,className:`text-xs leading-4 py-2 ${a?"opacity-50":""}`,children:s?"Starting…":"Run all phases"})})},gie=({plan:e,onAdd:t,disabled:n})=>{const[r,s]=k.useState(!1),i=async()=>{s(!0);try{await t([Nse()])}finally{s(!1)}};return f.jsx(ye,{content:"Append a style pass against docs/CODE_STYLE.md as a phase",children:f.jsx(re,{variant:"ghost",size:"small",onClick:i,disabled:n||r||!hY(e),children:"Style pass"})})},yie=()=>{const e=M(b=>b.launchSuggestIdeas),t=M(b=>b.launchBatchReconcile),n=M(b=>b.launchBatchDraft),r=M(b=>b.launchPrioritise),s=M(b=>b.refreshAll),i=M(b=>b.ideaEntries),o=M(b=>b.suggestions),a=M(sh),l=M(Hr),{toast:c}=rt(),[u,d]=k.useState(null),[h,p]=k.useState(!1),m=async()=>{d("suggest");try{await e(Lse(i,o))}catch(b){c({title:"Failed to launch",description:Ge(b.message),variant:"error"})}finally{d(null)}},g=async()=>{d("reconcile");try{await t()}catch(b){c({title:"Failed to launch",description:Ge(b.message),variant:"error"})}finally{d(null)}},x=async b=>{d("draft-all");try{await n(b)}finally{d(null)}},y=async()=>{d("prioritise");try{const b=await r(),_=b.moved.length-b.annotated.length;c({title:b.moved.length>0?"Queue reordered":"Already in order",description:_>0?`${_} of ${b.moved.length} ideas could not be annotated`:b.why.join(`
424
- `)||void 0,variant:_>0?"warning":"success"})}catch(b){c({title:"Failed to prioritise",description:Ge(b.message),variant:"error"}),await s()}finally{d(null)}},v=u!==null||a,w=[{id:"suggest-ideas",label:u==="suggest"?"Starting…":"Suggest ideas",icon:f.jsx(TP,{size:16}),disabled:v||!l,onSelect:m},{id:"reconcile-all",label:u==="reconcile"?"Starting…":"Reconcile all",icon:f.jsx(bP,{size:16}),disabled:v||!l,onSelect:g},{id:"draft-all",label:"Draft all",icon:f.jsx(Kx,{size:16}),disabled:v||!l,onSelect:()=>p(!0)},{id:"prioritise",label:u==="prioritise"?"Prioritising…":"Prioritise queue",icon:f.jsx(P8,{size:16}),disabled:v||!l,onSelect:y}];return f.jsxs(f.Fragment,{children:[f.jsx(PP,{align:"end",trigger:f.jsx(xt,{icon:f.jsx(IP,{size:16}),label:"More actions",size:"small",variant:"ghost"}),items:w}),f.jsx(Qse,{open:h,onClose:()=>p(!1),onConfirm:x})]})},xie="font-display-luminari text-sm font-semibold opacity-[0.65]",vie=({plan:e,updating:t,onSend:n,undo:r,undoing:s,onUndo:i})=>{var x;const{thread:o,input:a,setInput:l,pending:c,promotingIndex:u,ideaPromptIndex:d,handleSend:h,handlePromote:p,handlePromoteToIdea:m,closeIdeaPrompt:g}=mse(e,n);return f.jsxs("div",{className:"mb-8",children:[f.jsx("h3",{className:`${xie} mb-3`,children:"Feedback"}),f.jsxs(pe,{size:"small",accent:!0,accentColor:"slate",texture:"kraft",children:[f.jsx("div",{className:"flex flex-col gap-3 mb-4",children:o.length>0||c?f.jsxs(f.Fragment,{children:[f.jsx(Hse,{messages:o,undo:r,undoing:s,onUndo:i,onPromote:p,promotingIndex:u}),c&&f.jsx("div",{className:"flex flex-col gap-1 items-end",children:f.jsx("div",{className:"max-w-[85%]",children:f.jsx(pe,{size:"small",surface:"paper",texture:"parchment",accent:!0,accentColor:"blue",children:c})})}),t&&f.jsx("div",{className:"flex flex-col gap-1 items-start",children:f.jsx(pe,{size:"small",surface:"paper",texture:"kraft",shade:!0,children:f.jsx(Wr,{size:"small",label:"Agent thinking…"})})})]}):f.jsx("p",{className:"text-sm m-0 text-ink-500",children:"Jot a comment, ask a question, or say what's wrong with this plan."})}),f.jsxs("div",{className:"flex flex-col gap-2",children:[f.jsx(Hx,{value:a,onChange:y=>l(y.target.value),"aria-label":"Feedback message",placeholder:"Write a message…",rows:3}),f.jsx("div",{className:"flex justify-end items-center gap-3",children:f.jsx(re,{size:"small",onClick:h,disabled:t||!a.trim(),children:"Send"})})]})]}),f.jsx(WI,{open:d!==null,onClose:g,onAdd:m,initialContent:d!==null?(x=o[d])==null?void 0:x.text:void 0})]})},wie="font-display-luminari text-sm font-semibold opacity-[0.65]",bie=({plan:e,otherPlans:t})=>{const n=nt(),r=t.filter(s=>s.entityKind==="fix"&&s.idea===e.id);return r.length===0?null:f.jsxs("div",{className:"mb-5",children:[f.jsx("h3",{className:`${wie} mb-3`,children:"Fixes"}),f.jsx("div",{className:"flex flex-col gap-2 mb-3",children:r.map(s=>f.jsxs("button",{type:"button",onClick:()=>n(Ri(s)),className:"flex items-center gap-2 bg-none bg-transparent border-none p-0 cursor-pointer [font:inherit] text-inherit text-left text-sm",children:[f.jsx(Vs,{id:s.id}),f.jsx("span",{className:"flex-1 min-w-0 overflow-hidden text-ellipsis whitespace-nowrap",children:s.title}),f.jsx(ce,{size:"small",fillColor:fn[s.status].fill,textColor:fn[s.status].text,children:wc[s.status]})]},s.title))})]})},kie=({plan:e,otherPlans:t})=>{const n=nt(),r=e.entityKind==="ticket";if(!r&&e.entityKind!=="fix"||!e.idea)return null;const s=e.idea,i=t.find(o=>o.id===s);return f.jsx("div",{className:"mb-3",children:f.jsxs("button",{type:"button",onClick:()=>n(Ri(i??{id:s,title:s})),className:"flex items-center gap-2 bg-none bg-transparent border-none p-0 cursor-pointer [font:inherit] text-inherit text-left",children:[f.jsx(ce,{size:"small",variant:r?"info":"warning",children:r?"ticket":"fix"}),f.jsxs("span",{className:"text-sm opacity-70",children:[r?"On board":"Fixes"," ",f.jsx("span",{className:"font-mono",children:s}),i&&` — ${i.title}`]})]})})},_ie="font-display-luminari text-sm font-semibold opacity-[0.65]",Sie=({plan:e,auditRunning:t,agentBusy:n,runningFill:r,updating:s,onTogglePhase:i,onToggleFix:o,onAddPhases:a,ideaView:l,otherPlans:c,deliverPanel:u})=>{const d=M(g=>g.launchRunAll),h=e.fixes??[],p=h.some(g=>!g.done),m=[...e.phases.map((g,x)=>({kind:"phase",item:g,index:x})),...h.map((g,x)=>({kind:"fix",item:g,index:x}))];return f.jsx("div",{className:"mb-8",style:r?{"--phase-fill":`${r.fraction*100}%`}:void 0,children:f.jsx(S5,{data:m,toolbar:{title:f.jsx("h3",{className:`${_ie} m-0`,children:"Phases"}),actions:f.jsxs(f.Fragment,{children:[t&&f.jsx(Wr,{size:"small",label:"Audit running…"}),m.length===0&&f.jsx(GI,{idea:l}),m.length>0&&(e.status==="review"||e.status==="done")&&f.jsx(lie,{plan:e}),m.length>0&&e.status!=="done"&&f.jsx(pie,{plan:e}),m.length>0&&f.jsx(oie,{onAdd:a,disabled:s,entityId:e.id??e.title}),m.length>0&&f.jsx(gie,{plan:e,onAdd:a,disabled:s}),e.id&&p&&f.jsx(ye,{content:"Run the open fixes with an agent",children:f.jsx(re,{size:"small",onClick:()=>e.id&&d(e.id),disabled:n,children:n?"Running…":"Run fixes"})})]})},panelFooter:m.length===0?f.jsx("div",{className:"flex justify-center py-6",children:f.jsx(VI,{idea:l,otherPlans:c,className:"font-handwritten !text-base underline"})}):u,columns:[{key:"checkbox",header:"",cell:g=>f.jsx(Gse,{row:g,runningFill:r,updating:s,onTogglePhase:i,onToggleFix:o}),width:1},{key:"title",header:"Title",cell:g=>f.jsx(Zse,{row:g,runningFill:r})},{key:"actions",header:"",align:"end",width:6,cell:g=>f.jsx(qse,{row:g,runningFill:r,agentBusy:n,planId:e.id})}],expandable:{render:g=>{const x=g.item.run?AH(g.item.run):null;return!g.item.description&&!x?null:f.jsxs("div",{className:"flex flex-col gap-1",children:[g.item.description&&f.jsx("span",{children:g.item.description}),x&&f.jsx("span",{className:"font-mono text-3xs opacity-[0.7]",children:x})]})}},hideHeader:!0,density:"compact",showExpandColumn:!1,rowTexture:g=>{if(g.kind==="fix")return"kraft";if(g.kind==="phase"&&g.item.done)return"canvas"},rowClassName:g=>{if(eh(g,r))return"phase-running-row";if(g.kind==="phase"&&g.item.source==="review")return"bg-[rgba(155,122,181,0.08)]"},className:"phase-table-phone"})})},Cie="font-display-luminari text-sm font-semibold opacity-[0.65]",jie=({plan:e})=>e.body?f.jsxs("div",{className:"mb-4",children:[f.jsx("h3",{className:`${Cie} mb-2`,children:"Description"}),f.jsx("div",{className:"opacity-[0.85]",children:f.jsx(xI,{children:e.body})})]}):null,Eie=({rollup:e})=>e.runs===0?null:f.jsx("span",{className:"shrink-0",children:f.jsx(ye,{content:`${Ar(e.inputTokens)} in · ${Ar(e.outputTokens)} out · cache ${Ar(e.cacheCreationTokens)} write · ${Ar(e.cacheReadTokens)} read`,children:f.jsx(ce,{size:"small",fillColor:"var(--pui-texture-shade)",textColor:"inherit",children:f.jsxs("span",{className:"whitespace-nowrap font-mono text-3xs font-normal opacity-[0.7]",children:[Ar(e.inputTokens+e.outputTokens)," tokens ·"," ",Gf(e.durationMs)," · ",e.runs," ",e.runs===1?"run":"runs"]})})})}),Pie=({progress:e,color:t,rollup:n})=>e===null&&n.runs===0?null:f.jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-min",children:[e!==null&&f.jsxs(f.Fragment,{children:[f.jsx("div",{className:"flex-1 min-w-16",children:f.jsx(UI,{pct:e.pct,color:t})}),f.jsxs("span",{className:"text-sm opacity-50 flex-shrink-0 font-handwritten",children:[Math.round(e.pct),"%"]})]}),f.jsx(Eie,{rollup:n})]}),Tie="font-display-luminari text-sm font-semibold opacity-[0.65]",Nie=({plan:e,otherPlans:t})=>{const n=nt(),r=M(a=>a.loadPlans),s=t.filter(a=>a.entityKind==="ticket"&&a.idea===e.id).sort((a,l)=>(a.order??Number.POSITIVE_INFINITY)-(l.order??Number.POSITIVE_INFINITY)),i=a=>{const l=s.find(c=>c.title===a);l&&n(Ri(l))},o=async a=>{e.id&&(await q9({boardId:e.id,title:a}),await r())};return f.jsxs("div",{className:"mb-8",children:[f.jsxs("div",{className:"flex items-center justify-between mb-3",children:[f.jsx("h3",{className:`${Tie} m-0`,children:"Tickets"}),f.jsx(aie,{onAdd:o,disabled:!e.id})]}),s.length>0?f.jsx(HI,{plans:s,onOpen:i}):f.jsx("p",{className:"text-sm m-0 opacity-50",children:"No tickets yet — add one to start the decomposition."})]})},Iie=({planId:e,released:t,reviewing:n,reviewNote:r})=>{const s=jse(e);return e?f.jsx("div",{className:"text-xs opacity-80 shrink-0",children:s?f.jsx(Jse,{trail:s,released:t,reviewing:n,reviewNote:r}):f.jsx("div",{className:"max-w-xs","aria-hidden":"true",children:f.jsx(rn,{variant:"text",height:32})})}):null},Aie=({plan:e})=>{const t=M(L=>L.plans),n=M(L=>L.loadPlans),{toast:r}=rt(),{patch:s,updating:i}=vc(),o=M(L=>L.agentStatus),a=M(sh),l=M(L=>L.detailView),c=M(L=>L.taskLog),u=M(L=>L.loadTaskLog),d=th(e.id,o),h=!!uY(e.id,o),p=dY(e.thread),m=_se(d,c),g=k.useMemo(()=>MH(c,e.id),[c,e.id]),x=(d==null?void 0:d.taskKind)==="audit",y=cY(e,(m==null?void 0:m.fraction)??0);e.phases.length>0;const v=l==="feedback",w={id:e.id??null,title:e.title,body:e.body,log:e.log},b=((t==null?void 0:t.entries)??[]).filter(L=>L.id!==e.id);k.useEffect(()=>{u()},[u]);const _=async L=>{const D=e.phases.map((U,z)=>z===L?{...U,done:!U.done}:U);D.every(U=>U.done)&&e.status==="in-progress"?await s(e.title,{phases:D,status:"review"}):await s(e.title,{phases:D})},S=async L=>{await s(e.title,{phases:[...e.phases,...L]})},j=async L=>{const D=(e.fixes??[]).map((U,z)=>z===L?{...U,done:!U.done}:U);D.every(U=>U.done)&&e.status==="in-progress"?await s(e.title,{fixes:D,status:"review"}):await s(e.title,{fixes:D})},{sending:E,send:T,undo:P,undoing:N,undoEdit:A}=Sse(e,{reload:n,notify:r});return f.jsxs("div",{children:[f.jsxs("div",{className:"flex items-baseline justify-between gap-3 mb-2",children:[f.jsxs("h2",{className:`${iie} m-0 flex items-center gap-3 min-w-0 flex-wrap`,children:[f.jsx(Vs,{id:e.id}),e.title]}),f.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0 font-handwritten",children:[f.jsxs("span",{className:"text-sm opacity-[0.45] whitespace-nowrap",children:[f.jsx("span",{className:"max-[480px]:hidden",children:e.updated?"updated ":"created "}),Wg(e.updated??e.created)]}),f.jsx(kI,{})]})]}),f.jsx(kie,{plan:e,otherPlans:b}),f.jsxs("div",{className:"flex items-center gap-x-4 gap-y-1 flex-wrap mb-3",children:[f.jsx(Iie,{planId:e.id,released:e.released,reviewing:h,reviewNote:p}),!v&&f.jsx(Pie,{progress:y,color:zI[nh(e,o)],rollup:g})]}),v?f.jsx(vie,{plan:e,updating:E,onSend:T,undo:P,undoing:N,onUndo:A}):f.jsxs(f.Fragment,{children:[e.entityKind==="board"?f.jsx(Nie,{plan:e,otherPlans:b}):f.jsx(Sie,{plan:e,auditRunning:x,agentBusy:a,runningFill:m,updating:i,onTogglePhase:_,onToggleFix:j,onAddPhases:S,ideaView:w,otherPlans:b,deliverPanel:f.jsx(sie,{plan:e})}),f.jsx(bie,{plan:e,otherPlans:b}),f.jsx(rie,{clarifications:e.clarifications??[]}),f.jsx(jie,{plan:e})]})]})},Rie="text-sm font-semibold opacity-60 whitespace-nowrap overflow-hidden",P1="font-handwritten text-xs font-semibold opacity-55 leading-none pt-2 pr-1 pb-0 pl-1",Lie="font-handwritten text-xs font-semibold opacity-55 leading-none",T1=`${Rie} bg-none bg-transparent border-none p-0 cursor-pointer [font:inherit] text-inherit text-left`,Mie=[{key:"id",label:"Id"},{key:"title",label:"Title"},{key:"updated",label:"Updated"},{key:"progress",label:"Progress"},{key:"status",label:"Status"}],ZI="flex items-center gap-2 min-w-0 bg-none bg-transparent border-none p-0 cursor-pointer text-left [font:inherit] text-inherit font-semibold",qI="overflow-hidden text-ellipsis whitespace-nowrap",$ie=()=>{const e=M(n=>n.planFilters.groupBySubject),t=M(n=>n.toggleGroupBySubject);return f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("span",{className:Lie,children:"Group by subject"}),f.jsx(Pg,{size:"small",checked:e,onChange:t,"aria-label":"Group by subject"})]})},Die=({rows:e,activePlanTitle:t,onOpenPlan:n,onOpenIdea:r})=>{const s=Ko,{roadmapItemNames:i,navigate:o,sortKey:a,sortDirection:l,handleSort:c,groups:u,showSubjectHeaders:d,sortReflectsRows:h}=Dse(e),p=m=>m.type==="plan"?f.jsx(HI,{plans:[m.plan],activePlanTitle:t,onOpen:n},m.plan.title):m.type==="note"?f.jsx(Oie,{row:m,onOpen:r},m.idea.title):f.jsx(Fie,{row:m,activePlanTitle:t,onOpen:n},m.fix.title);return f.jsxs("div",{className:"flex flex-col gap-1",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("span",{role:"columnheader",className:"flex-[0_0_36px] flex justify-center","aria-sort":h&&a==="order"?l==="asc"?"ascending":"descending":void 0,children:f.jsxs("button",{type:"button",className:T1,"aria-label":"Sort by run order",onClick:()=>c("order"),children:["#",a==="order"&&(l==="asc"?"▲":"▼")]})}),f.jsx("div",{className:"flex-1 min-w-0",children:f.jsx(pe,{size:"small",texture:"kraft",className:"plan-row-card",children:f.jsx("div",{className:s,children:Mie.map(({key:m,label:g})=>{const x=m===a;return f.jsx("span",{role:"columnheader",className:m==="updated"?"max-lg:hidden":void 0,"aria-sort":h&&x?l==="asc"?"ascending":"descending":void 0,children:f.jsxs("button",{type:"button",className:T1,onClick:()=>c(m),children:[g,x&&(l==="asc"?" ▲":" ▼")]})},m)})})})})]}),d?u.map(m=>{const g=m.subject;return f.jsxs("div",{className:"flex flex-col gap-1",children:[f.jsx("div",{className:"flex items-baseline gap-2",children:g&&i.has(g)?f.jsx("button",{type:"button",className:`${P1} bg-none bg-transparent border-none cursor-pointer text-left hover:underline`,title:"View in roadmap",onClick:()=>o({to:"/roadmap",search:{item:g}}),children:g}):f.jsx("div",{className:P1,children:g??"No subject"})}),m.rows.map(x=>p(x))]},g??"__no-subject__")}):e.map(m=>p(m))]})},Oie=({row:e,onOpen:t})=>{const n=e.idea,r=n.status??"open";return f.jsxs("div",{className:"flex items-center",children:[f.jsx(dh,{order:n.order,done:r==="done",status:r}),f.jsx("div",{role:t?"button":void 0,tabIndex:t?0:void 0,onClick:t?()=>t(n.title):void 0,onKeyDown:t?s=>{(s.key==="Enter"||s.key===" ")&&(s.preventDefault(),t(n.title))}:void 0,className:`${t?"cursor-pointer":""} rounded-[10px] flex-1 min-w-0`,children:f.jsx(pe,{size:"small",texture:"canvas",className:"plan-row-card",children:f.jsxs("div",{className:Ko,children:[n.id?f.jsx(Vs,{id:n.id}):f.jsx("span",{}),f.jsxs("span",{className:`${ZI} [cursor:inherit]`,children:[f.jsx(Kx,{}),f.jsx("span",{className:qI,children:n.title})]}),f.jsx("span",{className:"max-lg:hidden text-sm opacity-[0.45]",children:"—"}),f.jsx("span",{className:"text-sm opacity-30",children:"—"}),f.jsx(ce,{size:"small",fillColor:of[r].fill,textColor:of[r].text,children:FI[r]})]})})})]})},zie="grid grid-cols-[76px_minmax(0,1fr)_112px] gap-2.5 items-center max-[480px]:grid-cols-1 max-[480px]:gap-1",Fie=({row:e,activePlanTitle:t,onOpen:n})=>{const r=M(o=>o.agentStatus),s=e.fix,i=nh(s,r);return f.jsxs("div",{className:"flex items-center",children:[f.jsx(dh,{order:s.order,done:s.status==="done",status:s.status,running:!!th(s.id,r),fallback:s.statusFallback}),f.jsx("div",{role:n?"button":void 0,tabIndex:n?0:void 0,onClick:n?()=>n(s.title):void 0,onKeyDown:n?o=>{(o.key==="Enter"||o.key===" ")&&(o.preventDefault(),n(s.title))}:void 0,className:`${n?"cursor-pointer":""} rounded-[10px] flex-1 min-w-0 ${s.title===t?"plan-row-highlighted outline outline-2 outline-offset-[-2px] outline-[rgba(200,154,90,0.5)]":""}`,children:f.jsx(pe,{size:"small",texture:"kraft",className:"plan-row-card",children:f.jsxs("div",{className:zie,children:[f.jsx(Vs,{id:s.id}),f.jsxs("span",{className:`${ZI} [cursor:inherit]`,children:[f.jsx(ce,{size:"small",variant:"warning",children:"fix"}),f.jsx("span",{className:qI,children:s.title}),s.idea&&f.jsxs("span",{className:"text-xs opacity-45 whitespace-nowrap font-mono",children:["→ ",s.idea]})]}),f.jsx(ce,{size:"small",fillColor:fn[i].fill,textColor:fn[i].text,children:wc[i]})]})})})]})},Bie=({rows:e,activePlanTitle:t,onOpenPlan:n,onOpenIdea:r})=>{const s=k.useRef(null);return k.useEffect(()=>{var o;if(!t)return;const i=(o=s.current)==null?void 0:o.querySelector(".plan-row-highlighted");i==null||i.scrollIntoView({behavior:"smooth",block:"center"})},[t]),f.jsx("div",{ref:s,children:e.length>0?f.jsx(Die,{rows:e,activePlanTitle:t,onOpenPlan:n,onOpenIdea:r}):f.jsx("p",{className:"opacity-50 py-6 px-0 text-center",children:"Nothing matches these filters — clear one, or check back once something moves into this status."})})},Vie=({idea:e})=>f.jsxs("div",{className:"text-base leading-[1.7] text-ink-900",children:[f.jsxs("h2",{className:"font-display-luminari font-semibold text-[1.75rem] leading-tight mt-0 mr-0 mb-4 ml-0 flex items-center gap-3 flex-wrap",children:[f.jsx(Vs,{id:e.id??void 0}),e.title,e.status&&f.jsx(ce,{size:"small",fillColor:of[e.status].fill,textColor:of[e.status].text,children:FI[e.status]})]}),f.jsx(xI,{children:e.body.replace(/^#{1,3}\s+.+(\n|$)/,"").replace(/^\s*-{3,}\s*(\n|$)/,"").trim()}),f.jsx("div",{className:"mt-6",children:f.jsx(GI,{idea:e})})]}),Uie=e=>{const t=e==null?void 0:e.match(/^[a-z]+\/([a-z]+-\d+)-/);return t?t[1].toUpperCase():null},Xp="__no-subject__",N1="pc-row-label font-handwritten text-xs font-semibold opacity-[0.45]",Wie=()=>{var $,B;const e=uh(),t=M(sh),n=M(C=>C.agentStatus),r=M(C=>C.gitBranch),{patch:s,updating:i}=vc(),{subjects:o,available:a}=jI(),l=M(C=>C.detailView),c=M(C=>C.setDetailView),u=M(C=>C.archiveIdeas),{toast:d}=rt(),[h,p]=k.useState(""),[m,g]=k.useState(!1);if(k.useEffect(()=>{p((e==null?void 0:e.order)!==void 0?String(e==null?void 0:e.order):"")},[e==null?void 0:e.order]),!e)return null;const x=nh(e,n),y=e.status==="in-progress",v=e.status==="review",w=e.status==="dropped",b=e.status==="done",_=e.phases.some(C=>!C.done),S=(e.status==="planned"||y)&&_,j=fY(e),E=e.id!==void 0&&Uie(r)===e.id,T=e.entityKind!=="board"&&(e.status==="planned"||y||v)&&!E,P=!!(e.pr&&(e.pr.state==="open"||e.pr.state==="draft")&&e.pr.unresolvedThreadCount),N=(($=e.pr)==null?void 0:$.state)==="open"||((B=e.pr)==null?void 0:B.state)==="draft",A=a&&e.subject&&!o.includes(e.subject)?e.subject:void 0,L=C=>s(e.title,C),D=async()=>{if(e.id){g(!0);try{await u([e.id])}catch(C){d({title:"Archive failed",description:C.message,variant:"error"})}finally{g(!1)}}},R=async()=>{if(e.id){g(!0);try{if(e.entityKind!=="board"){const C=await Y8(e.id);if(!C.ready){d({title:"Not ready to complete idea",description:`Waiting on ${C.missing.join(", ")}`,variant:"error"});return}}await u([e.id])}catch(C){d({title:"Archive failed",description:C.message,variant:"error"})}finally{g(!1)}}},U=y||v||e.status==="planned",z=async()=>{const C=h.trim(),V=Number(C);if(C===""||!Number.isInteger(V)||V<1){p(e.order!==void 0?String(e.order):"");return}V!==e.order&&await L({order:V})};return f.jsxs("div",{className:"flex flex-col",children:[f.jsx("div",{children:f.jsxs("div",{className:"flex flex-col",children:[f.jsx(St,{size:"small",active:l==="details",onClick:()=>c("details"),className:"pc-row text-xs",children:"Details"}),f.jsx(St,{size:"small",active:l==="feedback",onClick:()=>c("feedback"),className:"pc-row text-xs",children:"Feedback"})]})}),f.jsx("div",{className:"h-[64px] flex items-center",children:f.jsx(ce,{size:"small",fillColor:fn[x].fill,textColor:fn[x].text,children:wc[x]})}),f.jsxs("div",{children:[f.jsx("div",{className:N1,children:"Subject"}),f.jsx("div",{className:"h-[32px] flex items-center",children:f.jsx(wV,{className:"w-full",size:"small",value:e.subject??Xp,onChange:C=>L({subject:C===Xp?null:C}),disabled:i||!a,options:[{value:Xp,label:"No subject"},...A?[{value:A,label:`${A} (orphan)`}]:[],...!a&&e.subject&&!A?[{value:e.subject,label:e.subject}]:[],...o.map(C=>({value:C,label:C}))]})})]}),U&&f.jsxs("div",{className:"flex items-center justify-between h-[64px]",children:[f.jsx("div",{className:N1,children:"Order"}),f.jsx(In,{type:"number",size:"small","aria-label":"Run order",min:1,value:h,onChange:C=>p(C.target.value),onBlur:z,disabled:i,className:"w-20"})]}),f.jsx(pe,{size:"small",children:f.jsxs("div",{className:"flex flex-col",children:[T&&f.jsx(uie,{plan:e,disabled:t||i}),S&&f.jsx(mie,{plan:e,disabled:t||i}),P&&f.jsx(die,{plan:e,disabled:t||i}),N&&f.jsx(hie,{plan:e,disabled:t||i}),v&&e.pr&&f.jsx(cie,{plan:e,disabled:t||i}),b&&f.jsx(St,{size:"small",icon:f.jsx("span",{className:"text-ink-300",children:"▣"}),onClick:D,disabled:m||!e.id,className:`pc-row text-xs ${m||!e.id?"opacity-50":""}`,children:m?"Archiving…":"Archive"}),j&&f.jsx(St,{size:"small",icon:f.jsx("span",{className:"text-watercolor-green-dark",children:"✓"}),onClick:R,disabled:m||!e.id,className:`pc-row text-xs ${m||!e.id?"opacity-50":""}`,children:m?"Completing…":"Complete idea"}),!b&&f.jsx(St,{size:"small",icon:f.jsx("span",{className:w?"text-watercolor-green-dark":"text-watercolor-rose-dark",children:w?"↺":"⊘"}),onClick:()=>L({status:w?null:"dropped"}),disabled:i,className:`pc-row text-xs ${i?"opacity-50":""}`,children:w?"Reopen plan":"Mark dropped"})]})})]})},Hie=["in-progress","review","planned","idea","done","dropped"],Kie=()=>{const e=M(h=>h.plans),t=uh(),n=M(h=>h.planFilters),r=M(h=>h.togglePlanStatus),s=M(h=>h.setPlanSearch),i=M(h=>h.setSubjectFilter),o=nt();if(!e||t)return null;const{statusCounts:a}=al(e.entries,n),{statusCounts:l}=al(e.entries),c=new Set(n.statuses),u=Hie.filter(h=>l[h]>0);return f.jsxs("div",{className:"flex flex-col",children:[f.jsx("div",{className:"h-[64px] flex items-center",children:f.jsx(In,{type:"search",size:"small",placeholder:"Search plans…","aria-label":"Search plans",value:n.search,onChange:h=>s(h.target.value)})}),n.subject!==null&&f.jsxs("div",{className:"flex items-center gap-2 h-[32px]","data-testid":"subject-filter-chip",children:[f.jsxs("span",{className:"text-2xs opacity-70",children:["Subject: ",n.subject]}),f.jsx("button",{type:"button",onClick:()=>{i(null),o({to:"/",search:{}})},className:"bg-none bg-transparent border-none p-0 cursor-pointer opacity-70 underline text-2xs",children:"Clear"})]}),f.jsx("div",{children:f.jsx("div",{className:"flex flex-col",children:u.map(h=>{const p=c.has(h);return f.jsx(St,{size:"small",active:p,onClick:()=>r(h),className:"pc-row text-xs",icon:f.jsx("span",{className:"w-[9px] h-[9px] rounded-full shrink-0",style:{background:fn[h].text}}),action:f.jsx("span",{className:"text-2xs text-ink-500",children:a[h]}),children:wc[h]},h)})})})]})},I1=({showGroupingToggle:e=!1})=>f.jsxs("div",{className:"flex items-center gap-3 mb-6 flex-wrap",children:[f.jsx("h1",{className:"text-4xl flex-1 font-display-luminari font-semibold text-ink-900 m-0 leading-[1.1]",children:"Plans"}),e&&f.jsx($ie,{}),f.jsx(fie,{}),f.jsx(yie,{})]}),Gie=[{key:"a",title:"72%"},{key:"b",title:"54%"},{key:"c",title:"83%"},{key:"d",title:"46%"},{key:"e",title:"66%"},{key:"f",title:"58%"}],Zie=()=>f.jsxs("div",{className:"flex flex-col gap-1","aria-hidden":"true",children:[f.jsxs("div",{className:"flex items-center",children:[f.jsx("span",{className:"flex-[0_0_36px]"}),f.jsx("div",{className:"flex-1 min-w-0",children:f.jsx(pe,{size:"small",texture:"kraft",className:"plan-row-card",children:f.jsxs("div",{className:Ko,children:[f.jsx(rn,{variant:"text",width:28}),f.jsx(rn,{variant:"text",width:44}),f.jsx("span",{className:"max-lg:hidden",children:f.jsx(rn,{variant:"text",width:56})}),f.jsx(rn,{variant:"text",width:64}),f.jsx(rn,{variant:"text",width:48})]})})})]}),Gie.map(e=>f.jsxs("div",{className:"flex items-center",children:[f.jsx("span",{className:"flex-[0_0_36px] flex items-center justify-center",children:f.jsx(rn,{variant:"text",width:16})}),f.jsx("div",{className:"flex-1 min-w-0",children:f.jsx(pe,{size:"small",className:"plan-row-card",children:f.jsxs("div",{className:Ko,children:[f.jsx(rn,{variant:"rect",width:44,height:18}),f.jsx(rn,{variant:"text",width:e.title}),f.jsx("span",{className:"max-lg:hidden",children:f.jsx(rn,{variant:"text",width:52})}),f.jsx(rn,{variant:"rect",width:80,height:8}),f.jsx(rn,{variant:"rect",width:64,height:20})]})})})]},e.key))]}),qie=()=>{const e=M(u=>u.reconcileQueue),t=M(u=>u.removeFromReconcileQueue),n=M(u=>u.plans),{patch:r}=vc(),{toast:s}=rt(),i=k.useRef(0),o=e[0]??null,a=o?(n==null?void 0:n.entries.find(u=>u.id===o.planId))??null:null;if(k.useEffect(()=>{o&&!a&&t(o.previewId)},[o,a,t]),k.useEffect(()=>{e.length===0&&(i.current=0)},[e.length]),!o||!a)return null;const l=async()=>{t(o.previewId),i.current+=1,s({title:"Kept the merged version",description:`"${a.title}" keeps the agent's rewrite.`})},c=async()=>{await r(a.title,{body:o.before.body,phases:o.before.phases},{errorTitle:"Discard failed"})&&(t(o.previewId),i.current+=1)};return f.jsx(eie,{plan:a,before:o.before,onApprove:l,onDiscard:c,queuePosition:{index:i.current+1,total:i.current+e.length}})},Yie=({suggestions:e,onOpen:t,onDismiss:n})=>e.length===0?null:f.jsxs("div",{className:"mt-5",children:[f.jsx("h2",{className:"text-sm mb-2 opacity-60",children:"Suggested from AI"}),f.jsx("div",{className:"flex flex-col gap-1",children:e.map(r=>f.jsx("div",{className:"rounded-[10px]",children:f.jsx(pe,{size:"small",texture:"canvas",className:"plan-row-card",children:f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsxs("button",{type:"button",onClick:()=>t(r),className:"flex-1 min-w-0 flex items-center gap-2 bg-none bg-transparent border-none p-0 cursor-pointer text-left [font:inherit] text-inherit",children:[f.jsx(AP,{}),f.jsx("span",{className:"font-semibold overflow-hidden text-ellipsis whitespace-nowrap",children:r.title})]}),f.jsx(xt,{icon:f.jsx("span",{children:"×"}),variant:"ghost",size:"small",label:"Dismiss",className:"w-[28px] h-[28px]",onClick:()=>n(r)})]})})},`${r.date}-${r.title}`))})]}),Zv=()=>{const{plans:e,plansError:t,ideaEntries:n,suggestions:r,planFilters:s,activePlan:i,activeIdea:o,planId:a,ideaId:l,openSuggestion:c,setOpenSuggestion:u,handleOpenPlan:d,handleOpenIdea:h,handleOpenArchivable:p,handleDismissSuggestion:m}=gse();if(t)return f.jsxs("div",{children:[f.jsx(II,{children:"Plans"}),f.jsxs(pe,{size:"small",accent:!0,accentColor:"rose",children:[f.jsx("p",{className:"m-0 font-semibold",children:"Couldn't load plans.md"}),f.jsx("p",{className:"m-0 opacity-75",children:t})]})]});if(!e)return a||l?f.jsxs("div",{children:[f.jsx("output",{"aria-live":"polite",className:"sr-only",children:"Loading…"}),f.jsx("p",{className:"opacity-50",children:"Loading…"})]}):f.jsxs("div",{children:[f.jsx(I1,{}),f.jsx("output",{"aria-live":"polite",className:"sr-only",children:"Loading plans…"}),f.jsx(Zie,{})]});const{rows:g}=SY(e.entries,n,s);return f.jsxs(f.Fragment,{children:[f.jsx(qie,{}),i?f.jsx("div",{children:f.jsx(Aie,{plan:i})}):o?f.jsx("div",{children:f.jsx(Vie,{idea:o})}):f.jsxs("div",{children:[f.jsx(I1,{showGroupingToggle:e.entries.length>0}),e.warnings.length>0&&f.jsxs(pe,{size:"small",accent:!0,accentColor:"amber",children:[f.jsx("p",{className:"m-0 font-semibold",children:"Some entries couldn't be parsed"}),f.jsx("ul",{className:"m-0 pl-5",children:e.warnings.map(x=>f.jsxs("li",{children:[x.title,": ",x.message]},x.title))})]}),e.entries.length===0?f.jsxs("p",{className:"opacity-50",children:["No ideas yet — capture one with ",f.jsx("strong",{children:"New idea"})," above, or click"," ",f.jsx("strong",{children:"Suggest ideas"})," to have an agent propose some."]}):f.jsx(Bie,{rows:g,activePlanTitle:null,onOpenPlan:d,onOpenIdea:h}),f.jsx(tie,{onOpen:p}),f.jsx(Yie,{suggestions:r,onOpen:u,onDismiss:m}),f.jsx(Xse,{suggestion:c,onClose:()=>u(null)})]})]})};function Jie(e){return e.filter(t=>t.kind!=="question")}function Qie(e,t){return t?e.filter(n=>!t.has(n.id)):[]}function Xie(){const e=M(r=>r.notifications),t=M(r=>r.loadNotifications),n=k.useRef(null);k.useEffect(()=>{typeof Notification<"u"&&Notification.permission==="default"&&Notification.requestPermission()},[]),k.useEffect(()=>{if(!e)return;const r=Jie(e),s=Qie(r,n.current);if(n.current=new Set(r.map(i=>i.id)),s.length!==0&&!(typeof Notification>"u"||Notification.permission!=="granted")&&!document.hasFocus())for(const i of s)new Notification(i.entityTitle,{body:i.text})},[e]),k.useEffect(()=>{let r;const s=yc(i=>{i.message==="changed"&&(r&&clearTimeout(r),r=setTimeout(t,250))});return()=>{r&&clearTimeout(r),s()}},[t])}function eoe(e,t,n={githubConfigured:!1}){return e===void 0||e==="client"||e==="corpus"&&n.githubConfigured?"ready":t.checking?"checking":t.reachable?"ready":"unreachable"}const YI=k.lazy(()=>$n(()=>import("./index-Co_9IFtJ.js"),__vite__mapDeps([0,1])).then(e=>({default:e.DocsPage}))),toe=k.lazy(()=>$n(()=>import("./index-Co_9IFtJ.js"),__vite__mapDeps([0,1])).then(e=>({default:e.DocsSidebar}))),JI=k.lazy(()=>$n(()=>import("./index-siPA4naJ.js"),__vite__mapDeps([2,1])).then(e=>({default:e.SettingsPage}))),noe=k.lazy(()=>$n(()=>import("./index-siPA4naJ.js"),__vite__mapDeps([2,1])).then(e=>({default:e.SettingsSidebar}))),roe=k.lazy(()=>$n(()=>import("./index-Bq3vqVCv.js"),[]).then(e=>({default:e.TasksPage}))),soe=k.lazy(()=>$n(()=>import("./index-Ds_iTHi0.js"),[]).then(e=>({default:e.RoadmapPage}))),ioe=k.lazy(()=>$n(()=>import("./index-Ds_iTHi0.js"),[]).then(e=>({default:e.RoadmapSidebar}))),ooe=k.lazy(()=>$n(()=>import("./index-DRVlFKav.js"),[]).then(e=>({default:e.StatsPage}))),aoe=k.lazy(()=>$n(()=>import("./index-DdiMHcBX.js"),[]).then(e=>({default:e.GitPage}))),loe=k.lazy(()=>$n(()=>import("./index-DdiMHcBX.js"),[]).then(e=>({default:e.GitFileList}))),coe=k.lazy(()=>$n(()=>import("./index-8_65UWKz.js"),[]).then(e=>({default:e.InboxPage}))),uoe=k.lazy(()=>$n(()=>import("./index-e0PzaU7Z.js"),[]).then(e=>({default:e.IssuesPage}))),ay="/projects",doe=[ay,"/projects/reviews","/projects/activity","/projects/ideas"],em=[{id:"plans",label:"Plans",path:"/"},{id:"roadmap",label:"Roadmap",path:"/roadmap"},{id:"docs",label:"Docs",path:"/docs"},{id:"issues",label:"Issues",path:"/issues"},{id:"stats",label:"Stats",path:"/stats"},{id:"settings",label:"Settings",path:"/settings"}],A1=({item:e})=>f.jsx("span",{className:"inline-flex items-center gap-1.5",children:e.label}),R1=()=>f.jsx("svg",{width:"18",height:"18",viewBox:"0 0 20 20",fill:"none",stroke:"currentColor",strokeWidth:"2","aria-hidden":"true",children:f.jsx("path",{d:"M3 5h14M3 10h14M3 15h14",strokeLinecap:"round"})}),QI="stack-open";function foe(){try{return localStorage.getItem(QI)==="true"}catch{return!1}}function hoe(e){try{localStorage.setItem(QI,String(e))}catch{}}const poe=224,moe=480,goe=495,yoe=poe+goe+moe,xoe=`(min-width: ${yoe}px)`;function voe(e){const[t,n]=k.useState(()=>typeof window<"u"?window.matchMedia(e).matches:!1);return k.useEffect(()=>{const r=window.matchMedia(e),s=i=>n(i.matches);return n(r.matches),r.addEventListener("change",s),()=>r.removeEventListener("change",s)},[e]),t}const woe=()=>{var D;const e=nt(),t=Xm({select:R=>R.location.pathname}),n=M(R=>R.loadPlans),r=M(R=>R.loadIdeas),s=M(R=>R.loadSuggestions),i=M(R=>R.loadCapabilities),o=M(R=>R.loadAgentAuthStatus),a=M(R=>R.loadParkedQuestions),l=M(R=>R.loadNotifications),c=M(R=>R.setActiveDocTitle),u=M(R=>R.checkRuntimeReachable),d=M(R=>R.runtimeReachable),h=M(R=>R.runtimeChecking),p=M(R=>R.githubConfig),m=Xm({select:R=>{var U;return(U=R.matches.at(-1))==null?void 0:U.staticData.layer}}),g=eoe(m,{reachable:d,checking:h},{githubConfigured:p!==null}),x=t==="/"||t.startsWith("/plans/")||t.startsWith("/ideas/"),y=t==="/docs"||t.startsWith("/docs/"),v=t==="/settings"||t.startsWith("/settings/"),w=t==="/roadmap",b=t==="/git",_=x?"plans":y?"docs":v?"settings":(D=em.find(R=>R.path===t))==null?void 0:D.id,S=x||y||v||w||b,j=x?"plans":y?"docs":v?"settings":w?"roadmap":"git",[E,T]=k.useState(foe),[P,N]=k.useState(!1),A=voe(xoe),L=k.useRef(!1);return Xie(),k.useEffect(()=>{s(),i(),o(),a(),l(),u()},[s,i,o,a,l,u]),k.useEffect(()=>{h||(n(),r())},[h,n,r]),k.useEffect(()=>{L.current||t!=="/"||(L.current=!0,Promise.all([Gx(),$P()]).then(([R,U])=>{if(!(R!=null&&R.setupDismissed)&&U!==null&&!U.every(z=>z.status==="ok")){e({to:"/settings/$section",params:{section:"setup"}});return}Promise.all([BP(),WP()]).then(([z,$])=>{z.entries.length>1||$.entries.length>0||(c("USAGE.md"),e({to:"/docs"}))})}))},[t,e,c]),k.useEffect(()=>{N(!1)},[t]),doe.includes(t)?f.jsx(ck,{position:"bottom-left",children:f.jsx(Nre,{children:f.jsx(Qm,{})})}):f.jsxs(ck,{position:"bottom-left",children:[f.jsxs("div",{className:"h-screen box-border flex flex-col",children:[f.jsxs("div",{className:"shrink-0 min-[1199px]:pr-[var(--pc-stack-width)]",children:[f.jsx(pre,{}),f.jsxs("header",{className:"pc-app-header flex items-center gap-3 h-[var(--pc-header-h)] max-[480px]:hidden",style:Vx({texture:"parchment",shade:!0}),children:[S&&f.jsx(xt,{variant:"ghost",size:"small",className:"lg:hidden",label:"Open sidebar",onClick:()=>N(!0),icon:f.jsx(R1,{})}),f.jsx(dre,{}),f.jsx("nav",{"aria-label":"Main navigation",className:"flex items-center gap-1 ml-auto",children:em.map(R=>f.jsx(re,{variant:"ghost",size:"small",isActive:R.id===_,onClick:()=>e({to:R.path}),"aria-current":R.id===_?"page":void 0,children:f.jsx(A1,{item:R})},R.id))})]}),f.jsx(Ere,{})]}),f.jsx(xP,{style:{flex:"1 1 0%",minHeight:0,height:"auto"},background:{texture:"speckle",ruledType:"grid",ruledColor:"blue"},showHeader:!1,showSidebar:!1,showPage:!1,bleedBottom:!0,children:f.jsx("div",{className:"flex flex-col h-full min-h-0",children:f.jsx("div",{className:"flex flex-1 min-h-0 justify-center items-start box-border overflow-y-auto [scrollbar-gutter:stable] -mt-8 -ml-8 -mr-8 pt-0 pl-8 pr-8 pb-[var(--pc-content-pad-bottom)]",children:f.jsxs("div",{className:"flex min-w-0 justify-center lg:[--pc-sidebar-h:calc(100vh-160px)] gap-6 w-full min-h-full",children:[S&&f.jsxs(mre,{routeKey:j,mobileOpen:P,onMobileClose:()=>N(!1),children:[x&&f.jsxs(f.Fragment,{children:[f.jsx(Kie,{}),f.jsx(Wie,{})]}),y&&f.jsx(k.Suspense,{fallback:null,children:f.jsx(toe,{})}),v&&f.jsx(k.Suspense,{fallback:null,children:f.jsx(noe,{})}),w&&f.jsx(k.Suspense,{fallback:null,children:f.jsx(ioe,{})}),b&&f.jsx(k.Suspense,{fallback:null,children:f.jsx(loe,{})})]}),f.jsx("div",{className:"relative flex flex-col min-w-0 flex-[1_1_0%]",children:f.jsx("div",{className:"flex flex-col flex-1 min-w-0",children:f.jsx(Wx,{texture:{texture:"parchment"},rounded:"none",className:"pc-page w-full max-w-none",children:g==="unreachable"?f.jsx(hre,{layer:m}):g==="checking"?null:f.jsxs(k.Suspense,{fallback:null,children:[f.jsx(Pre,{}),f.jsx(Qm,{})]})})})})]})})})})]}),f.jsx(lre,{open:E,pinned:A,onToggle:()=>{const R=!E;hoe(R),T(R)}}),f.jsxs("nav",{"aria-label":"Main navigation",className:"hidden max-[480px]:flex max-[480px]:fixed max-[480px]:left-0 max-[480px]:right-0 max-[480px]:bottom-0 max-[480px]:z-[250] max-[480px]:items-stretch max-[480px]:justify-around max-[480px]:gap-1 max-[480px]:py-2 max-[480px]:px-2 max-[480px]:[padding-bottom:calc(0.5rem+env(safe-area-inset-bottom))] max-[480px]:bg-[var(--pui-bg-base,#fff)] max-[480px]:border-t max-[480px]:border-black/10 max-[480px]:shadow-[0_-2px_8px_rgba(0,0,0,0.08)]",children:[S&&f.jsx(xt,{variant:"ghost",size:"small",label:"Open sidebar",onClick:()=>N(!0),icon:f.jsx(R1,{}),className:"min-h-11"}),em.map(R=>f.jsx(re,{variant:"ghost",size:"small",isActive:R.id===_,onClick:()=>e({to:R.path}),"aria-current":R.id===_?"page":void 0,className:"min-h-11",children:f.jsx(A1,{item:R})},R.id))]})]})},at=mM({component:woe}),boe=dt({getParentRoute:()=>at,path:"/projects",component:rse,staticData:{layer:"client"}}),koe=dt({getParentRoute:()=>at,path:"/projects/reviews",component:ise,staticData:{layer:"client"}}),_oe=dt({getParentRoute:()=>at,path:"/projects/activity",component:Vre,staticData:{layer:"client"}}),Soe=dt({getParentRoute:()=>at,path:"/projects/ideas",component:sse,staticData:{layer:"client"}}),Coe=dt({getParentRoute:()=>at,path:"/",component:Zv,validateSearch:e=>({subject:typeof e.subject=="string"?e.subject:void 0}),staticData:{layer:"corpus"}}),joe=dt({getParentRoute:()=>at,path:"/plans/$planId",beforeLoad:({params:e})=>{throw QC({to:"/ideas/$ideaId",params:{ideaId:sf(e.planId)??e.planId}})}}),Eoe=dt({getParentRoute:()=>at,path:"/ideas/$ideaId",component:Zv,staticData:{layer:"corpus"}}),Poe=dt({getParentRoute:()=>at,path:"/ideas/$ideaId/tickets/$ticketId",component:Zv,staticData:{layer:"corpus"}}),Toe=dt({getParentRoute:()=>at,path:"/docs",component:YI,staticData:{layer:"runtime"}}),Noe=dt({getParentRoute:()=>at,path:"/docs/$section",component:YI,staticData:{layer:"runtime"}}),Ioe=dt({getParentRoute:()=>at,path:"/settings",component:JI,staticData:{layer:"runtime"}}),Aoe=dt({getParentRoute:()=>at,path:"/settings/$section",component:JI,staticData:{layer:"runtime"}}),Roe=dt({getParentRoute:()=>at,path:"/roadmap",component:soe,validateSearch:e=>({item:typeof e.item=="string"?e.item:void 0}),staticData:{layer:"runtime"}}),Loe=dt({getParentRoute:()=>at,path:"/inbox",component:coe,staticData:{layer:"runtime"}}),Moe=dt({getParentRoute:()=>at,path:"/stats",component:ooe,staticData:{layer:"runtime"}}),$oe=dt({getParentRoute:()=>at,path:"/git",component:aoe,staticData:{layer:"runtime"}}),Doe=dt({getParentRoute:()=>at,path:"/tasks",component:roe,validateSearch:e=>({taskId:typeof e.taskId=="string"?e.taskId:void 0}),staticData:{layer:"runtime"}}),Ooe=dt({getParentRoute:()=>at,path:"/issues",component:uoe,staticData:{layer:"runtime"}}),zoe=at.addChildren([Coe,boe,koe,_oe,Soe,joe,Eoe,Poe,Toe,Noe,Ioe,Aoe,Doe,Ooe,Roe,Moe,Loe,$oe]),Foe=jM({routeTree:zoe,basepath:da||"/"}),{runtimeUrl:af,pairingToken:ly}=LN;O8(af||da);z8(ly);const Boe=15e3;async function Voe(){!af||!ly||await fetch(K("/api/pair"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:ly}),signal:AbortSignal.timeout(Boe)}).catch(()=>{})}const XI=document.getElementById("root");if(!XI)throw new Error("#root element not found");async function Uoe(){return Ire(da,af)?!0:Are(af,e=>J(K(e)))}Voe().then(Uoe).catch(()=>!1).then(e=>{!e&&!window.location.pathname.startsWith(ay)&&window.history.replaceState(null,"",`${da}${ay}`),KC(XI).render(f.jsx(k.StrictMode,{children:f.jsx(TM,{router:Foe})}))});export{ye as $,Yoe as A,fae as B,rt as C,Joe as D,cx as E,iae as F,CI as G,cae as H,aae as I,re as J,uae as K,dae as L,xI as M,Ni as N,oae as O,II as P,hae as Q,pe as R,Ge as S,b1 as T,wc as U,fn as V,Ese as W,$8 as X,Gp as Y,gre as Z,Gf as _,nt as a,l6 as a0,Ar as a1,xc as a2,$I as a3,lse as a4,U8 as a5,Xoe as a6,yc as a7,Zoe as a8,xt as a9,qoe as aa,vP as ab,Wr as ac,L8 as ad,SJ as ae,kJ as af,Vs as ag,Sse as ah,hc as ai,pc as aj,Hse as ak,Hx as al,Cv as am,cW as an,sae as ao,Ine as b,K as c,iie as d,CP as e,lae as f,ce as g,Ane as h,In as i,f as j,Gx as k,rae as l,Qoe as m,eae as n,tae as o,St as p,jI as q,k as r,nae as s,Goe as t,M as u,wV as v,jP as w,sc as x,D8 as y,To as z};
425
- //# sourceMappingURL=main-C0TBUyF9.js.map
424
+ `)||void 0,variant:_>0?"warning":"success"})}catch(b){c({title:"Failed to prioritise",description:Ge(b.message),variant:"error"}),await s()}finally{d(null)}},v=u!==null||a,w=[{id:"suggest-ideas",label:u==="suggest"?"Starting…":"Suggest ideas",icon:f.jsx(TP,{size:16}),disabled:v||!l,onSelect:m},{id:"reconcile-all",label:u==="reconcile"?"Starting…":"Reconcile all",icon:f.jsx(bP,{size:16}),disabled:v||!l,onSelect:g},{id:"draft-all",label:"Draft all",icon:f.jsx(Kx,{size:16}),disabled:v||!l,onSelect:()=>p(!0)},{id:"prioritise",label:u==="prioritise"?"Prioritising…":"Prioritise queue",icon:f.jsx(P8,{size:16}),disabled:v||!l,onSelect:y}];return f.jsxs(f.Fragment,{children:[f.jsx(PP,{align:"end",trigger:f.jsx(xt,{icon:f.jsx(IP,{size:16}),label:"More actions",size:"small",variant:"ghost"}),items:w}),f.jsx(Qse,{open:h,onClose:()=>p(!1),onConfirm:x})]})},xie="font-display-luminari text-sm font-semibold opacity-[0.65]",vie=({plan:e,updating:t,onSend:n,undo:r,undoing:s,onUndo:i})=>{var x;const{thread:o,input:a,setInput:l,pending:c,promotingIndex:u,ideaPromptIndex:d,handleSend:h,handlePromote:p,handlePromoteToIdea:m,closeIdeaPrompt:g}=mse(e,n);return f.jsxs("div",{className:"mb-8",children:[f.jsx("h3",{className:`${xie} mb-3`,children:"Feedback"}),f.jsxs(pe,{size:"small",accent:!0,accentColor:"slate",texture:"kraft",children:[f.jsx("div",{className:"flex flex-col gap-3 mb-4",children:o.length>0||c?f.jsxs(f.Fragment,{children:[f.jsx(Hse,{messages:o,undo:r,undoing:s,onUndo:i,onPromote:p,promotingIndex:u}),c&&f.jsx("div",{className:"flex flex-col gap-1 items-end",children:f.jsx("div",{className:"max-w-[85%]",children:f.jsx(pe,{size:"small",surface:"paper",texture:"parchment",accent:!0,accentColor:"blue",children:c})})}),t&&f.jsx("div",{className:"flex flex-col gap-1 items-start",children:f.jsx(pe,{size:"small",surface:"paper",texture:"kraft",shade:!0,children:f.jsx(Wr,{size:"small",label:"Agent thinking…"})})})]}):f.jsx("p",{className:"text-sm m-0 text-ink-500",children:"Jot a comment, ask a question, or say what's wrong with this plan."})}),f.jsxs("div",{className:"flex flex-col gap-2",children:[f.jsx(Hx,{value:a,onChange:y=>l(y.target.value),"aria-label":"Feedback message",placeholder:"Write a message…",rows:3}),f.jsx("div",{className:"flex justify-end items-center gap-3",children:f.jsx(re,{size:"small",onClick:h,disabled:t||!a.trim(),children:"Send"})})]})]}),f.jsx(WI,{open:d!==null,onClose:g,onAdd:m,initialContent:d!==null?(x=o[d])==null?void 0:x.text:void 0})]})},wie="font-display-luminari text-sm font-semibold opacity-[0.65]",bie=({plan:e,otherPlans:t})=>{const n=nt(),r=t.filter(s=>s.entityKind==="fix"&&s.idea===e.id);return r.length===0?null:f.jsxs("div",{className:"mb-5",children:[f.jsx("h3",{className:`${wie} mb-3`,children:"Fixes"}),f.jsx("div",{className:"flex flex-col gap-2 mb-3",children:r.map(s=>f.jsxs("button",{type:"button",onClick:()=>n(Ri(s)),className:"flex items-center gap-2 bg-none bg-transparent border-none p-0 cursor-pointer [font:inherit] text-inherit text-left text-sm",children:[f.jsx(Vs,{id:s.id}),f.jsx("span",{className:"flex-1 min-w-0 overflow-hidden text-ellipsis whitespace-nowrap",children:s.title}),f.jsx(ce,{size:"small",fillColor:fn[s.status].fill,textColor:fn[s.status].text,children:wc[s.status]})]},s.title))})]})},kie=({plan:e,otherPlans:t})=>{const n=nt(),r=e.entityKind==="ticket";if(!r&&e.entityKind!=="fix"||!e.idea)return null;const s=e.idea,i=t.find(o=>o.id===s);return f.jsx("div",{className:"mb-3",children:f.jsxs("button",{type:"button",onClick:()=>n(Ri(i??{id:s,title:s})),className:"flex items-center gap-2 bg-none bg-transparent border-none p-0 cursor-pointer [font:inherit] text-inherit text-left",children:[f.jsx(ce,{size:"small",variant:r?"info":"warning",children:r?"ticket":"fix"}),f.jsxs("span",{className:"text-sm opacity-70",children:[r?"On board":"Fixes"," ",f.jsx("span",{className:"font-mono",children:s}),i&&` — ${i.title}`]})]})})},_ie="font-display-luminari text-sm font-semibold opacity-[0.65]",Sie=({plan:e,auditRunning:t,agentBusy:n,runningFill:r,updating:s,onTogglePhase:i,onToggleFix:o,onAddPhases:a,ideaView:l,otherPlans:c,deliverPanel:u})=>{const d=M(g=>g.launchRunAll),h=e.fixes??[],p=h.some(g=>!g.done),m=[...e.phases.map((g,x)=>({kind:"phase",item:g,index:x})),...h.map((g,x)=>({kind:"fix",item:g,index:x}))];return f.jsx("div",{className:"mb-8",style:r?{"--phase-fill":`${r.fraction*100}%`}:void 0,children:f.jsx(S5,{data:m,toolbar:{title:f.jsx("h3",{className:`${_ie} m-0`,children:"Phases"}),actions:f.jsxs(f.Fragment,{children:[t&&f.jsx(Wr,{size:"small",label:"Audit running…"}),m.length===0&&f.jsx(GI,{idea:l}),m.length>0&&(e.status==="review"||e.status==="done")&&f.jsx(lie,{plan:e}),m.length>0&&e.status!=="done"&&f.jsx(pie,{plan:e}),m.length>0&&f.jsx(oie,{onAdd:a,disabled:s,entityId:e.id??e.title}),m.length>0&&f.jsx(gie,{plan:e,onAdd:a,disabled:s}),e.id&&p&&f.jsx(ye,{content:"Run the open fixes with an agent",children:f.jsx(re,{size:"small",onClick:()=>e.id&&d(e.id),disabled:n,children:n?"Running…":"Run fixes"})})]})},panelFooter:m.length===0?f.jsx("div",{className:"flex justify-center py-6",children:f.jsx(VI,{idea:l,otherPlans:c,className:"font-handwritten !text-base underline"})}):u,columns:[{key:"checkbox",header:"",cell:g=>f.jsx(Gse,{row:g,runningFill:r,updating:s,onTogglePhase:i,onToggleFix:o}),width:1},{key:"title",header:"Title",cell:g=>f.jsx(Zse,{row:g,runningFill:r})},{key:"actions",header:"",align:"end",width:6,cell:g=>f.jsx(qse,{row:g,runningFill:r,agentBusy:n,planId:e.id})}],expandable:{render:g=>{const x=g.item.run?AH(g.item.run):null;return!g.item.description&&!x?null:f.jsxs("div",{className:"flex flex-col gap-1",children:[g.item.description&&f.jsx("span",{children:g.item.description}),x&&f.jsx("span",{className:"font-mono text-3xs opacity-[0.7]",children:x})]})}},hideHeader:!0,density:"compact",showExpandColumn:!1,rowTexture:g=>{if(g.kind==="fix")return"kraft";if(g.kind==="phase"&&g.item.done)return"canvas"},rowClassName:g=>{if(eh(g,r))return"phase-running-row";if(g.kind==="phase"&&g.item.source==="review")return"bg-[rgba(155,122,181,0.08)]"},className:"phase-table-phone"})})},Cie="font-display-luminari text-sm font-semibold opacity-[0.65]",jie=({plan:e})=>e.body?f.jsxs("div",{className:"mb-4",children:[f.jsx("h3",{className:`${Cie} mb-2`,children:"Description"}),f.jsx("div",{className:"opacity-[0.85]",children:f.jsx(xI,{children:e.body})})]}):null,Eie=({rollup:e})=>e.runs===0?null:f.jsx("span",{className:"shrink-0",children:f.jsx(ye,{content:`${Ar(e.inputTokens)} in · ${Ar(e.outputTokens)} out · cache ${Ar(e.cacheCreationTokens)} write · ${Ar(e.cacheReadTokens)} read`,children:f.jsx(ce,{size:"small",fillColor:"var(--pui-texture-shade)",textColor:"inherit",children:f.jsxs("span",{className:"whitespace-nowrap font-mono text-3xs font-normal opacity-[0.7]",children:[Ar(e.inputTokens+e.outputTokens)," tokens ·"," ",Gf(e.durationMs)," · ",e.runs," ",e.runs===1?"run":"runs"]})})})}),Pie=({progress:e,color:t,rollup:n})=>e===null&&n.runs===0?null:f.jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-min",children:[e!==null&&f.jsxs(f.Fragment,{children:[f.jsx("div",{className:"flex-1 min-w-16",children:f.jsx(UI,{pct:e.pct,color:t})}),f.jsxs("span",{className:"text-sm opacity-50 flex-shrink-0 font-handwritten",children:[Math.round(e.pct),"%"]})]}),f.jsx(Eie,{rollup:n})]}),Tie="font-display-luminari text-sm font-semibold opacity-[0.65]",Nie=({plan:e,otherPlans:t})=>{const n=nt(),r=M(a=>a.loadPlans),s=t.filter(a=>a.entityKind==="ticket"&&a.idea===e.id).sort((a,l)=>(a.order??Number.POSITIVE_INFINITY)-(l.order??Number.POSITIVE_INFINITY)),i=a=>{const l=s.find(c=>c.title===a);l&&n(Ri(l))},o=async a=>{e.id&&(await q9({boardId:e.id,title:a}),await r())};return f.jsxs("div",{className:"mb-8",children:[f.jsxs("div",{className:"flex items-center justify-between mb-3",children:[f.jsx("h3",{className:`${Tie} m-0`,children:"Tickets"}),f.jsx(aie,{onAdd:o,disabled:!e.id})]}),s.length>0?f.jsx(HI,{plans:s,onOpen:i}):f.jsx("p",{className:"text-sm m-0 opacity-50",children:"No tickets yet — add one to start the decomposition."})]})},Iie=({planId:e,released:t,reviewing:n,reviewNote:r})=>{const s=jse(e);return e?f.jsx("div",{className:"text-xs opacity-80 shrink-0",children:s?f.jsx(Jse,{trail:s,released:t,reviewing:n,reviewNote:r}):f.jsx("div",{className:"max-w-xs","aria-hidden":"true",children:f.jsx(rn,{variant:"text",height:32})})}):null},Aie=({plan:e})=>{const t=M(L=>L.plans),n=M(L=>L.loadPlans),{toast:r}=rt(),{patch:s,updating:i}=vc(),o=M(L=>L.agentStatus),a=M(sh),l=M(L=>L.detailView),c=M(L=>L.taskLog),u=M(L=>L.loadTaskLog),d=th(e.id,o),h=!!uY(e.id,o),p=dY(e.thread),m=_se(d,c),g=k.useMemo(()=>MH(c,e.id),[c,e.id]),x=(d==null?void 0:d.taskKind)==="audit",y=cY(e,(m==null?void 0:m.fraction)??0);e.phases.length>0;const v=l==="feedback",w={id:e.id??null,title:e.title,body:e.body,log:e.log},b=((t==null?void 0:t.entries)??[]).filter(L=>L.id!==e.id);k.useEffect(()=>{u()},[u]);const _=async L=>{const D=e.phases.map((U,z)=>z===L?{...U,done:!U.done}:U);D.every(U=>U.done)&&e.status==="in-progress"?await s(e.title,{phases:D,status:"review"}):await s(e.title,{phases:D})},S=async L=>{await s(e.title,{phases:[...e.phases,...L]})},j=async L=>{const D=(e.fixes??[]).map((U,z)=>z===L?{...U,done:!U.done}:U);D.every(U=>U.done)&&e.status==="in-progress"?await s(e.title,{fixes:D,status:"review"}):await s(e.title,{fixes:D})},{sending:E,send:T,undo:P,undoing:N,undoEdit:A}=Sse(e,{reload:n,notify:r});return f.jsxs("div",{children:[f.jsxs("div",{className:"flex items-baseline justify-between gap-3 mb-2",children:[f.jsxs("h2",{className:`${iie} m-0 flex items-center gap-3 min-w-0 flex-wrap`,children:[f.jsx(Vs,{id:e.id}),e.title]}),f.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0 font-handwritten",children:[f.jsxs("span",{className:"text-sm opacity-[0.45] whitespace-nowrap",children:[f.jsx("span",{className:"max-[480px]:hidden",children:e.updated?"updated ":"created "}),Wg(e.updated??e.created)]}),f.jsx(kI,{})]})]}),f.jsx(kie,{plan:e,otherPlans:b}),f.jsxs("div",{className:"flex items-center gap-x-4 gap-y-1 flex-wrap mb-3",children:[f.jsx(Iie,{planId:e.id,released:e.released,reviewing:h,reviewNote:p}),!v&&f.jsx(Pie,{progress:y,color:zI[nh(e,o)],rollup:g})]}),v?f.jsx(vie,{plan:e,updating:E,onSend:T,undo:P,undoing:N,onUndo:A}):f.jsxs(f.Fragment,{children:[e.entityKind==="board"?f.jsx(Nie,{plan:e,otherPlans:b}):f.jsx(Sie,{plan:e,auditRunning:x,agentBusy:a,runningFill:m,updating:i,onTogglePhase:_,onToggleFix:j,onAddPhases:S,ideaView:w,otherPlans:b,deliverPanel:f.jsx(sie,{plan:e})}),f.jsx(bie,{plan:e,otherPlans:b}),f.jsx(rie,{clarifications:e.clarifications??[]}),f.jsx(jie,{plan:e})]})]})},Rie="text-sm font-semibold opacity-60 whitespace-nowrap overflow-hidden",P1="font-handwritten text-xs font-semibold opacity-55 leading-none pt-2 pr-1 pb-0 pl-1",Lie="font-handwritten text-xs font-semibold opacity-55 leading-none",T1=`${Rie} bg-none bg-transparent border-none p-0 cursor-pointer [font:inherit] text-inherit text-left`,Mie=[{key:"id",label:"Id"},{key:"title",label:"Title"},{key:"updated",label:"Updated"},{key:"progress",label:"Progress"},{key:"status",label:"Status"}],ZI="flex items-center gap-2 min-w-0 bg-none bg-transparent border-none p-0 cursor-pointer text-left [font:inherit] text-inherit font-semibold",qI="overflow-hidden text-ellipsis whitespace-nowrap",$ie=()=>{const e=M(n=>n.planFilters.groupBySubject),t=M(n=>n.toggleGroupBySubject);return f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("span",{className:Lie,children:"Group by subject"}),f.jsx(Pg,{size:"small",checked:e,onChange:t,"aria-label":"Group by subject"})]})},Die=({rows:e,activePlanTitle:t,onOpenPlan:n,onOpenIdea:r})=>{const s=Ko,{roadmapItemNames:i,navigate:o,sortKey:a,sortDirection:l,handleSort:c,groups:u,showSubjectHeaders:d,sortReflectsRows:h}=Dse(e),p=m=>m.type==="plan"?f.jsx(HI,{plans:[m.plan],activePlanTitle:t,onOpen:n},m.plan.title):m.type==="note"?f.jsx(Oie,{row:m,onOpen:r},m.idea.title):f.jsx(Fie,{row:m,activePlanTitle:t,onOpen:n},m.fix.title);return f.jsxs("div",{className:"flex flex-col gap-1",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("span",{role:"columnheader",className:"flex-[0_0_36px] flex justify-center","aria-sort":h&&a==="order"?l==="asc"?"ascending":"descending":void 0,children:f.jsxs("button",{type:"button",className:T1,"aria-label":"Sort by run order",onClick:()=>c("order"),children:["#",a==="order"&&(l==="asc"?"▲":"▼")]})}),f.jsx("div",{className:"flex-1 min-w-0",children:f.jsx(pe,{size:"small",texture:"kraft",className:"plan-row-card",children:f.jsx("div",{className:s,children:Mie.map(({key:m,label:g})=>{const x=m===a;return f.jsx("span",{role:"columnheader",className:m==="updated"?"max-lg:hidden":void 0,"aria-sort":h&&x?l==="asc"?"ascending":"descending":void 0,children:f.jsxs("button",{type:"button",className:T1,onClick:()=>c(m),children:[g,x&&(l==="asc"?" ▲":" ▼")]})},m)})})})})]}),d?u.map(m=>{const g=m.subject;return f.jsxs("div",{className:"flex flex-col gap-1",children:[f.jsx("div",{className:"flex items-baseline gap-2",children:g&&i.has(g)?f.jsx("button",{type:"button",className:`${P1} bg-none bg-transparent border-none cursor-pointer text-left hover:underline`,title:"View in roadmap",onClick:()=>o({to:"/roadmap",search:{item:g}}),children:g}):f.jsx("div",{className:P1,children:g??"No subject"})}),m.rows.map(x=>p(x))]},g??"__no-subject__")}):e.map(m=>p(m))]})},Oie=({row:e,onOpen:t})=>{const n=e.idea,r=n.status??"open";return f.jsxs("div",{className:"flex items-center",children:[f.jsx(dh,{order:n.order,done:r==="done",status:r}),f.jsx("div",{role:t?"button":void 0,tabIndex:t?0:void 0,onClick:t?()=>t(n.title):void 0,onKeyDown:t?s=>{(s.key==="Enter"||s.key===" ")&&(s.preventDefault(),t(n.title))}:void 0,className:`${t?"cursor-pointer":""} rounded-[10px] flex-1 min-w-0`,children:f.jsx(pe,{size:"small",texture:"canvas",className:"plan-row-card",children:f.jsxs("div",{className:Ko,children:[n.id?f.jsx(Vs,{id:n.id}):f.jsx("span",{}),f.jsxs("span",{className:`${ZI} [cursor:inherit]`,children:[f.jsx(Kx,{}),f.jsx("span",{className:qI,children:n.title})]}),f.jsx("span",{className:"max-lg:hidden text-sm opacity-[0.45]",children:"—"}),f.jsx("span",{className:"text-sm opacity-30",children:"—"}),f.jsx(ce,{size:"small",fillColor:of[r].fill,textColor:of[r].text,children:FI[r]})]})})})]})},zie="grid grid-cols-[76px_minmax(0,1fr)_112px] gap-2.5 items-center max-[480px]:grid-cols-1 max-[480px]:gap-1",Fie=({row:e,activePlanTitle:t,onOpen:n})=>{const r=M(o=>o.agentStatus),s=e.fix,i=nh(s,r);return f.jsxs("div",{className:"flex items-center",children:[f.jsx(dh,{order:s.order,done:s.status==="done",status:s.status,running:!!th(s.id,r),fallback:s.statusFallback}),f.jsx("div",{role:n?"button":void 0,tabIndex:n?0:void 0,onClick:n?()=>n(s.title):void 0,onKeyDown:n?o=>{(o.key==="Enter"||o.key===" ")&&(o.preventDefault(),n(s.title))}:void 0,className:`${n?"cursor-pointer":""} rounded-[10px] flex-1 min-w-0 ${s.title===t?"plan-row-highlighted outline outline-2 outline-offset-[-2px] outline-[rgba(200,154,90,0.5)]":""}`,children:f.jsx(pe,{size:"small",texture:"kraft",className:"plan-row-card",children:f.jsxs("div",{className:zie,children:[f.jsx(Vs,{id:s.id}),f.jsxs("span",{className:`${ZI} [cursor:inherit]`,children:[f.jsx(ce,{size:"small",variant:"warning",children:"fix"}),f.jsx("span",{className:qI,children:s.title}),s.idea&&f.jsxs("span",{className:"text-xs opacity-45 whitespace-nowrap font-mono",children:["→ ",s.idea]})]}),f.jsx(ce,{size:"small",fillColor:fn[i].fill,textColor:fn[i].text,children:wc[i]})]})})})]})},Bie=({rows:e,activePlanTitle:t,onOpenPlan:n,onOpenIdea:r})=>{const s=k.useRef(null);return k.useEffect(()=>{var o;if(!t)return;const i=(o=s.current)==null?void 0:o.querySelector(".plan-row-highlighted");i==null||i.scrollIntoView({behavior:"smooth",block:"center"})},[t]),f.jsx("div",{ref:s,children:e.length>0?f.jsx(Die,{rows:e,activePlanTitle:t,onOpenPlan:n,onOpenIdea:r}):f.jsx("p",{className:"opacity-50 py-6 px-0 text-center",children:"Nothing matches these filters — clear one, or check back once something moves into this status."})})},Vie=({idea:e})=>f.jsxs("div",{className:"text-base leading-[1.7] text-ink-900",children:[f.jsxs("h2",{className:"font-display-luminari font-semibold text-[1.75rem] leading-tight mt-0 mr-0 mb-4 ml-0 flex items-center gap-3 flex-wrap",children:[f.jsx(Vs,{id:e.id??void 0}),e.title,e.status&&f.jsx(ce,{size:"small",fillColor:of[e.status].fill,textColor:of[e.status].text,children:FI[e.status]})]}),f.jsx(xI,{children:e.body.replace(/^#{1,3}\s+.+(\n|$)/,"").replace(/^\s*-{3,}\s*(\n|$)/,"").trim()}),f.jsx("div",{className:"mt-6",children:f.jsx(GI,{idea:e})})]}),Uie=e=>{const t=e==null?void 0:e.match(/^[a-z]+\/([a-z]+-\d+)-/);return t?t[1].toUpperCase():null},Xp="__no-subject__",N1="pc-row-label font-handwritten text-xs font-semibold opacity-[0.45]",Wie=()=>{var $,B;const e=uh(),t=M(sh),n=M(C=>C.agentStatus),r=M(C=>C.gitBranch),{patch:s,updating:i}=vc(),{subjects:o,available:a}=jI(),l=M(C=>C.detailView),c=M(C=>C.setDetailView),u=M(C=>C.archiveIdeas),{toast:d}=rt(),[h,p]=k.useState(""),[m,g]=k.useState(!1);if(k.useEffect(()=>{p((e==null?void 0:e.order)!==void 0?String(e==null?void 0:e.order):"")},[e==null?void 0:e.order]),!e)return null;const x=nh(e,n),y=e.status==="in-progress",v=e.status==="review",w=e.status==="dropped",b=e.status==="done",_=e.phases.some(C=>!C.done),S=(e.status==="planned"||y)&&_,j=fY(e),E=e.id!==void 0&&Uie(r)===e.id,T=e.entityKind!=="board"&&(e.status==="planned"||y||v)&&!E,P=!!(e.pr&&(e.pr.state==="open"||e.pr.state==="draft")&&e.pr.unresolvedThreadCount),N=(($=e.pr)==null?void 0:$.state)==="open"||((B=e.pr)==null?void 0:B.state)==="draft",A=a&&e.subject&&!o.includes(e.subject)?e.subject:void 0,L=C=>s(e.title,C),D=async()=>{if(e.id){g(!0);try{await u([e.id])}catch(C){d({title:"Archive failed",description:C.message,variant:"error"})}finally{g(!1)}}},R=async()=>{if(e.id){g(!0);try{if(e.entityKind!=="board"){const C=await Y8(e.id);if(!C.ready){d({title:"Not ready to complete idea",description:`Waiting on ${C.missing.join(", ")}`,variant:"error"});return}}await u([e.id])}catch(C){d({title:"Archive failed",description:C.message,variant:"error"})}finally{g(!1)}}},U=y||v||e.status==="planned",z=async()=>{const C=h.trim(),V=Number(C);if(C===""||!Number.isInteger(V)||V<1){p(e.order!==void 0?String(e.order):"");return}V!==e.order&&await L({order:V})};return f.jsxs("div",{className:"flex flex-col",children:[f.jsx("div",{children:f.jsxs("div",{className:"flex flex-col",children:[f.jsx(St,{size:"small",active:l==="details",onClick:()=>c("details"),className:"pc-row text-xs",children:"Details"}),f.jsx(St,{size:"small",active:l==="feedback",onClick:()=>c("feedback"),className:"pc-row text-xs",children:"Feedback"})]})}),f.jsx("div",{className:"h-[64px] flex items-center",children:f.jsx(ce,{size:"small",fillColor:fn[x].fill,textColor:fn[x].text,children:wc[x]})}),f.jsxs("div",{children:[f.jsx("div",{className:N1,children:"Subject"}),f.jsx("div",{className:"h-[32px] flex items-center",children:f.jsx(wV,{className:"w-full",size:"small",value:e.subject??Xp,onChange:C=>L({subject:C===Xp?null:C}),disabled:i||!a,options:[{value:Xp,label:"No subject"},...A?[{value:A,label:`${A} (orphan)`}]:[],...!a&&e.subject&&!A?[{value:e.subject,label:e.subject}]:[],...o.map(C=>({value:C,label:C}))]})})]}),U&&f.jsxs("div",{className:"flex items-center justify-between h-[64px]",children:[f.jsx("div",{className:N1,children:"Order"}),f.jsx(In,{type:"number",size:"small","aria-label":"Run order",min:1,value:h,onChange:C=>p(C.target.value),onBlur:z,disabled:i,className:"w-20"})]}),f.jsx(pe,{size:"small",children:f.jsxs("div",{className:"flex flex-col",children:[T&&f.jsx(uie,{plan:e,disabled:t||i}),S&&f.jsx(mie,{plan:e,disabled:t||i}),P&&f.jsx(die,{plan:e,disabled:t||i}),N&&f.jsx(hie,{plan:e,disabled:t||i}),v&&e.pr&&f.jsx(cie,{plan:e,disabled:t||i}),b&&f.jsx(St,{size:"small",icon:f.jsx("span",{className:"text-ink-300",children:"▣"}),onClick:D,disabled:m||!e.id,className:`pc-row text-xs ${m||!e.id?"opacity-50":""}`,children:m?"Archiving…":"Archive"}),j&&f.jsx(St,{size:"small",icon:f.jsx("span",{className:"text-watercolor-green-dark",children:"✓"}),onClick:R,disabled:m||!e.id,className:`pc-row text-xs ${m||!e.id?"opacity-50":""}`,children:m?"Completing…":"Complete idea"}),!b&&f.jsx(St,{size:"small",icon:f.jsx("span",{className:w?"text-watercolor-green-dark":"text-watercolor-rose-dark",children:w?"↺":"⊘"}),onClick:()=>L({status:w?null:"dropped"}),disabled:i,className:`pc-row text-xs ${i?"opacity-50":""}`,children:w?"Reopen plan":"Mark dropped"})]})})]})},Hie=["in-progress","review","planned","idea","done","dropped"],Kie=()=>{const e=M(h=>h.plans),t=uh(),n=M(h=>h.planFilters),r=M(h=>h.togglePlanStatus),s=M(h=>h.setPlanSearch),i=M(h=>h.setSubjectFilter),o=nt();if(!e||t)return null;const{statusCounts:a}=al(e.entries,n),{statusCounts:l}=al(e.entries),c=new Set(n.statuses),u=Hie.filter(h=>l[h]>0);return f.jsxs("div",{className:"flex flex-col",children:[f.jsx("div",{className:"h-[64px] flex items-center",children:f.jsx(In,{type:"search",size:"small",placeholder:"Search plans…","aria-label":"Search plans",value:n.search,onChange:h=>s(h.target.value)})}),n.subject!==null&&f.jsxs("div",{className:"flex items-center gap-2 h-[32px]","data-testid":"subject-filter-chip",children:[f.jsxs("span",{className:"text-2xs opacity-70",children:["Subject: ",n.subject]}),f.jsx("button",{type:"button",onClick:()=>{i(null),o({to:"/",search:{}})},className:"bg-none bg-transparent border-none p-0 cursor-pointer opacity-70 underline text-2xs",children:"Clear"})]}),f.jsx("div",{children:f.jsx("div",{className:"flex flex-col",children:u.map(h=>{const p=c.has(h);return f.jsx(St,{size:"small",active:p,onClick:()=>r(h),className:"pc-row text-xs",icon:f.jsx("span",{className:"w-[9px] h-[9px] rounded-full shrink-0",style:{background:fn[h].text}}),action:f.jsx("span",{className:"text-2xs text-ink-500",children:a[h]}),children:wc[h]},h)})})})]})},I1=({showGroupingToggle:e=!1})=>f.jsxs("div",{className:"flex items-center gap-3 mb-6 flex-wrap",children:[f.jsx("h1",{className:"text-4xl flex-1 font-display-luminari font-semibold text-ink-900 m-0 leading-[1.1]",children:"Plans"}),e&&f.jsx($ie,{}),f.jsx(fie,{}),f.jsx(yie,{})]}),Gie=[{key:"a",title:"72%"},{key:"b",title:"54%"},{key:"c",title:"83%"},{key:"d",title:"46%"},{key:"e",title:"66%"},{key:"f",title:"58%"}],Zie=()=>f.jsxs("div",{className:"flex flex-col gap-1","aria-hidden":"true",children:[f.jsxs("div",{className:"flex items-center",children:[f.jsx("span",{className:"flex-[0_0_36px]"}),f.jsx("div",{className:"flex-1 min-w-0",children:f.jsx(pe,{size:"small",texture:"kraft",className:"plan-row-card",children:f.jsxs("div",{className:Ko,children:[f.jsx(rn,{variant:"text",width:28}),f.jsx(rn,{variant:"text",width:44}),f.jsx("span",{className:"max-lg:hidden",children:f.jsx(rn,{variant:"text",width:56})}),f.jsx(rn,{variant:"text",width:64}),f.jsx(rn,{variant:"text",width:48})]})})})]}),Gie.map(e=>f.jsxs("div",{className:"flex items-center",children:[f.jsx("span",{className:"flex-[0_0_36px] flex items-center justify-center",children:f.jsx(rn,{variant:"text",width:16})}),f.jsx("div",{className:"flex-1 min-w-0",children:f.jsx(pe,{size:"small",className:"plan-row-card",children:f.jsxs("div",{className:Ko,children:[f.jsx(rn,{variant:"rect",width:44,height:18}),f.jsx(rn,{variant:"text",width:e.title}),f.jsx("span",{className:"max-lg:hidden",children:f.jsx(rn,{variant:"text",width:52})}),f.jsx(rn,{variant:"rect",width:80,height:8}),f.jsx(rn,{variant:"rect",width:64,height:20})]})})})]},e.key))]}),qie=()=>{const e=M(u=>u.reconcileQueue),t=M(u=>u.removeFromReconcileQueue),n=M(u=>u.plans),{patch:r}=vc(),{toast:s}=rt(),i=k.useRef(0),o=e[0]??null,a=o?(n==null?void 0:n.entries.find(u=>u.id===o.planId))??null:null;if(k.useEffect(()=>{o&&!a&&t(o.previewId)},[o,a,t]),k.useEffect(()=>{e.length===0&&(i.current=0)},[e.length]),!o||!a)return null;const l=async()=>{t(o.previewId),i.current+=1,s({title:"Kept the merged version",description:`"${a.title}" keeps the agent's rewrite.`})},c=async()=>{await r(a.title,{body:o.before.body,phases:o.before.phases},{errorTitle:"Discard failed"})&&(t(o.previewId),i.current+=1)};return f.jsx(eie,{plan:a,before:o.before,onApprove:l,onDiscard:c,queuePosition:{index:i.current+1,total:i.current+e.length}})},Yie=({suggestions:e,onOpen:t,onDismiss:n})=>e.length===0?null:f.jsxs("div",{className:"mt-5",children:[f.jsx("h2",{className:"text-sm mb-2 opacity-60",children:"Suggested from AI"}),f.jsx("div",{className:"flex flex-col gap-1",children:e.map(r=>f.jsx("div",{className:"rounded-[10px]",children:f.jsx(pe,{size:"small",texture:"canvas",className:"plan-row-card",children:f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsxs("button",{type:"button",onClick:()=>t(r),className:"flex-1 min-w-0 flex items-center gap-2 bg-none bg-transparent border-none p-0 cursor-pointer text-left [font:inherit] text-inherit",children:[f.jsx(AP,{}),f.jsx("span",{className:"font-semibold overflow-hidden text-ellipsis whitespace-nowrap",children:r.title})]}),f.jsx(xt,{icon:f.jsx("span",{children:"×"}),variant:"ghost",size:"small",label:"Dismiss",className:"w-[28px] h-[28px]",onClick:()=>n(r)})]})})},`${r.date}-${r.title}`))})]}),Zv=()=>{const{plans:e,plansError:t,ideaEntries:n,suggestions:r,planFilters:s,activePlan:i,activeIdea:o,planId:a,ideaId:l,openSuggestion:c,setOpenSuggestion:u,handleOpenPlan:d,handleOpenIdea:h,handleOpenArchivable:p,handleDismissSuggestion:m}=gse();if(t)return f.jsxs("div",{children:[f.jsx(II,{children:"Plans"}),f.jsxs(pe,{size:"small",accent:!0,accentColor:"rose",children:[f.jsx("p",{className:"m-0 font-semibold",children:"Couldn't load plans.md"}),f.jsx("p",{className:"m-0 opacity-75",children:t})]})]});if(!e)return a||l?f.jsxs("div",{children:[f.jsx("output",{"aria-live":"polite",className:"sr-only",children:"Loading…"}),f.jsx("p",{className:"opacity-50",children:"Loading…"})]}):f.jsxs("div",{children:[f.jsx(I1,{}),f.jsx("output",{"aria-live":"polite",className:"sr-only",children:"Loading plans…"}),f.jsx(Zie,{})]});const{rows:g}=SY(e.entries,n,s);return f.jsxs(f.Fragment,{children:[f.jsx(qie,{}),i?f.jsx("div",{children:f.jsx(Aie,{plan:i})}):o?f.jsx("div",{children:f.jsx(Vie,{idea:o})}):f.jsxs("div",{children:[f.jsx(I1,{showGroupingToggle:e.entries.length>0}),e.warnings.length>0&&f.jsxs(pe,{size:"small",accent:!0,accentColor:"amber",children:[f.jsx("p",{className:"m-0 font-semibold",children:"Some entries couldn't be parsed"}),f.jsx("ul",{className:"m-0 pl-5",children:e.warnings.map(x=>f.jsxs("li",{children:[x.title,": ",x.message]},x.title))})]}),e.entries.length===0?f.jsxs("p",{className:"opacity-50",children:["No ideas yet — capture one with ",f.jsx("strong",{children:"New idea"})," above, or click"," ",f.jsx("strong",{children:"Suggest ideas"})," to have an agent propose some."]}):f.jsx(Bie,{rows:g,activePlanTitle:null,onOpenPlan:d,onOpenIdea:h}),f.jsx(tie,{onOpen:p}),f.jsx(Yie,{suggestions:r,onOpen:u,onDismiss:m}),f.jsx(Xse,{suggestion:c,onClose:()=>u(null)})]})]})};function Jie(e){return e.filter(t=>t.kind!=="question")}function Qie(e,t){return t?e.filter(n=>!t.has(n.id)):[]}function Xie(){const e=M(r=>r.notifications),t=M(r=>r.loadNotifications),n=k.useRef(null);k.useEffect(()=>{typeof Notification<"u"&&Notification.permission==="default"&&Notification.requestPermission()},[]),k.useEffect(()=>{if(!e)return;const r=Jie(e),s=Qie(r,n.current);if(n.current=new Set(r.map(i=>i.id)),s.length!==0&&!(typeof Notification>"u"||Notification.permission!=="granted")&&!document.hasFocus())for(const i of s)new Notification(i.entityTitle,{body:i.text})},[e]),k.useEffect(()=>{let r;const s=yc(i=>{i.message==="changed"&&(r&&clearTimeout(r),r=setTimeout(t,250))});return()=>{r&&clearTimeout(r),s()}},[t])}function eoe(e,t,n={githubConfigured:!1}){return e===void 0||e==="client"||e==="corpus"&&n.githubConfigured?"ready":t.checking?"checking":t.reachable?"ready":"unreachable"}const YI=k.lazy(()=>$n(()=>import("./index-CFMhKXQf.js"),__vite__mapDeps([0,1])).then(e=>({default:e.DocsPage}))),toe=k.lazy(()=>$n(()=>import("./index-CFMhKXQf.js"),__vite__mapDeps([0,1])).then(e=>({default:e.DocsSidebar}))),JI=k.lazy(()=>$n(()=>import("./index-CKO_a_mt.js"),__vite__mapDeps([2,1])).then(e=>({default:e.SettingsPage}))),noe=k.lazy(()=>$n(()=>import("./index-CKO_a_mt.js"),__vite__mapDeps([2,1])).then(e=>({default:e.SettingsSidebar}))),roe=k.lazy(()=>$n(()=>import("./index-DoH_Ktpt.js"),[]).then(e=>({default:e.TasksPage}))),soe=k.lazy(()=>$n(()=>import("./index-B0T4zOOc.js"),[]).then(e=>({default:e.RoadmapPage}))),ioe=k.lazy(()=>$n(()=>import("./index-B0T4zOOc.js"),[]).then(e=>({default:e.RoadmapSidebar}))),ooe=k.lazy(()=>$n(()=>import("./index-CeEpQji6.js"),[]).then(e=>({default:e.StatsPage}))),aoe=k.lazy(()=>$n(()=>import("./index-CTHTRX-O.js"),[]).then(e=>({default:e.GitPage}))),loe=k.lazy(()=>$n(()=>import("./index-CTHTRX-O.js"),[]).then(e=>({default:e.GitFileList}))),coe=k.lazy(()=>$n(()=>import("./index-Twqzhu_o.js"),[]).then(e=>({default:e.InboxPage}))),uoe=k.lazy(()=>$n(()=>import("./index-DC_F8eQU.js"),[]).then(e=>({default:e.IssuesPage}))),ay="/projects",doe=[ay,"/projects/reviews","/projects/activity","/projects/ideas"],em=[{id:"plans",label:"Plans",path:"/"},{id:"roadmap",label:"Roadmap",path:"/roadmap"},{id:"docs",label:"Docs",path:"/docs"},{id:"issues",label:"Issues",path:"/issues"},{id:"stats",label:"Stats",path:"/stats"},{id:"settings",label:"Settings",path:"/settings"}],A1=({item:e})=>f.jsx("span",{className:"inline-flex items-center gap-1.5",children:e.label}),R1=()=>f.jsx("svg",{width:"18",height:"18",viewBox:"0 0 20 20",fill:"none",stroke:"currentColor",strokeWidth:"2","aria-hidden":"true",children:f.jsx("path",{d:"M3 5h14M3 10h14M3 15h14",strokeLinecap:"round"})}),QI="stack-open";function foe(){try{return localStorage.getItem(QI)==="true"}catch{return!1}}function hoe(e){try{localStorage.setItem(QI,String(e))}catch{}}const poe=224,moe=480,goe=495,yoe=poe+goe+moe,xoe=`(min-width: ${yoe}px)`;function voe(e){const[t,n]=k.useState(()=>typeof window<"u"?window.matchMedia(e).matches:!1);return k.useEffect(()=>{const r=window.matchMedia(e),s=i=>n(i.matches);return n(r.matches),r.addEventListener("change",s),()=>r.removeEventListener("change",s)},[e]),t}const woe=()=>{var D;const e=nt(),t=Xm({select:R=>R.location.pathname}),n=M(R=>R.loadPlans),r=M(R=>R.loadIdeas),s=M(R=>R.loadSuggestions),i=M(R=>R.loadCapabilities),o=M(R=>R.loadAgentAuthStatus),a=M(R=>R.loadParkedQuestions),l=M(R=>R.loadNotifications),c=M(R=>R.setActiveDocTitle),u=M(R=>R.checkRuntimeReachable),d=M(R=>R.runtimeReachable),h=M(R=>R.runtimeChecking),p=M(R=>R.githubConfig),m=Xm({select:R=>{var U;return(U=R.matches.at(-1))==null?void 0:U.staticData.layer}}),g=eoe(m,{reachable:d,checking:h},{githubConfigured:p!==null}),x=t==="/"||t.startsWith("/plans/")||t.startsWith("/ideas/"),y=t==="/docs"||t.startsWith("/docs/"),v=t==="/settings"||t.startsWith("/settings/"),w=t==="/roadmap",b=t==="/git",_=x?"plans":y?"docs":v?"settings":(D=em.find(R=>R.path===t))==null?void 0:D.id,S=x||y||v||w||b,j=x?"plans":y?"docs":v?"settings":w?"roadmap":"git",[E,T]=k.useState(foe),[P,N]=k.useState(!1),A=voe(xoe),L=k.useRef(!1);return Xie(),k.useEffect(()=>{s(),i(),o(),a(),l(),u()},[s,i,o,a,l,u]),k.useEffect(()=>{h||(n(),r())},[h,n,r]),k.useEffect(()=>{L.current||t!=="/"||(L.current=!0,Promise.all([Gx(),$P()]).then(([R,U])=>{if(!(R!=null&&R.setupDismissed)&&U!==null&&!U.every(z=>z.status==="ok")){e({to:"/settings/$section",params:{section:"setup"}});return}Promise.all([BP(),WP()]).then(([z,$])=>{z.entries.length>1||$.entries.length>0||(c("USAGE.md"),e({to:"/docs"}))})}))},[t,e,c]),k.useEffect(()=>{N(!1)},[t]),doe.includes(t)?f.jsx(ck,{position:"bottom-left",children:f.jsx(Nre,{children:f.jsx(Qm,{})})}):f.jsxs(ck,{position:"bottom-left",children:[f.jsxs("div",{className:"h-screen box-border flex flex-col",children:[f.jsxs("div",{className:"shrink-0 min-[1199px]:pr-[var(--pc-stack-width)]",children:[f.jsx(pre,{}),f.jsxs("header",{className:"pc-app-header flex items-center gap-3 h-[var(--pc-header-h)] max-[480px]:hidden",style:Vx({texture:"parchment",shade:!0}),children:[S&&f.jsx(xt,{variant:"ghost",size:"small",className:"lg:hidden",label:"Open sidebar",onClick:()=>N(!0),icon:f.jsx(R1,{})}),f.jsx(dre,{}),f.jsx("nav",{"aria-label":"Main navigation",className:"flex items-center gap-1 ml-auto",children:em.map(R=>f.jsx(re,{variant:"ghost",size:"small",isActive:R.id===_,onClick:()=>e({to:R.path}),"aria-current":R.id===_?"page":void 0,children:f.jsx(A1,{item:R})},R.id))})]}),f.jsx(Ere,{})]}),f.jsx(xP,{style:{flex:"1 1 0%",minHeight:0,height:"auto"},background:{texture:"speckle",ruledType:"grid",ruledColor:"blue"},showHeader:!1,showSidebar:!1,showPage:!1,bleedBottom:!0,children:f.jsx("div",{className:"flex flex-col h-full min-h-0",children:f.jsx("div",{className:"flex flex-1 min-h-0 justify-center items-start box-border overflow-y-auto [scrollbar-gutter:stable] -mt-8 -ml-8 -mr-8 pt-0 pl-8 pr-8 pb-[var(--pc-content-pad-bottom)]",children:f.jsxs("div",{className:"flex min-w-0 justify-center lg:[--pc-sidebar-h:calc(100vh-160px)] gap-6 w-full min-h-full",children:[S&&f.jsxs(mre,{routeKey:j,mobileOpen:P,onMobileClose:()=>N(!1),children:[x&&f.jsxs(f.Fragment,{children:[f.jsx(Kie,{}),f.jsx(Wie,{})]}),y&&f.jsx(k.Suspense,{fallback:null,children:f.jsx(toe,{})}),v&&f.jsx(k.Suspense,{fallback:null,children:f.jsx(noe,{})}),w&&f.jsx(k.Suspense,{fallback:null,children:f.jsx(ioe,{})}),b&&f.jsx(k.Suspense,{fallback:null,children:f.jsx(loe,{})})]}),f.jsx("div",{className:"relative flex flex-col min-w-0 flex-[1_1_0%]",children:f.jsx("div",{className:"flex flex-col flex-1 min-w-0",children:f.jsx(Wx,{texture:{texture:"parchment"},rounded:"none",className:"pc-page w-full max-w-none",children:g==="unreachable"?f.jsx(hre,{layer:m}):g==="checking"?null:f.jsxs(k.Suspense,{fallback:null,children:[f.jsx(Pre,{}),f.jsx(Qm,{})]})})})})]})})})})]}),f.jsx(lre,{open:E,pinned:A,onToggle:()=>{const R=!E;hoe(R),T(R)}}),f.jsxs("nav",{"aria-label":"Main navigation",className:"hidden max-[480px]:flex max-[480px]:fixed max-[480px]:left-0 max-[480px]:right-0 max-[480px]:bottom-0 max-[480px]:z-[250] max-[480px]:items-stretch max-[480px]:justify-around max-[480px]:gap-1 max-[480px]:py-2 max-[480px]:px-2 max-[480px]:[padding-bottom:calc(0.5rem+env(safe-area-inset-bottom))] max-[480px]:bg-[var(--pui-bg-base,#fff)] max-[480px]:border-t max-[480px]:border-black/10 max-[480px]:shadow-[0_-2px_8px_rgba(0,0,0,0.08)]",children:[S&&f.jsx(xt,{variant:"ghost",size:"small",label:"Open sidebar",onClick:()=>N(!0),icon:f.jsx(R1,{}),className:"min-h-11"}),em.map(R=>f.jsx(re,{variant:"ghost",size:"small",isActive:R.id===_,onClick:()=>e({to:R.path}),"aria-current":R.id===_?"page":void 0,className:"min-h-11",children:f.jsx(A1,{item:R})},R.id))]})]})},at=mM({component:woe}),boe=dt({getParentRoute:()=>at,path:"/projects",component:rse,staticData:{layer:"client"}}),koe=dt({getParentRoute:()=>at,path:"/projects/reviews",component:ise,staticData:{layer:"client"}}),_oe=dt({getParentRoute:()=>at,path:"/projects/activity",component:Vre,staticData:{layer:"client"}}),Soe=dt({getParentRoute:()=>at,path:"/projects/ideas",component:sse,staticData:{layer:"client"}}),Coe=dt({getParentRoute:()=>at,path:"/",component:Zv,validateSearch:e=>({subject:typeof e.subject=="string"?e.subject:void 0}),staticData:{layer:"corpus"}}),joe=dt({getParentRoute:()=>at,path:"/plans/$planId",beforeLoad:({params:e})=>{throw QC({to:"/ideas/$ideaId",params:{ideaId:sf(e.planId)??e.planId}})}}),Eoe=dt({getParentRoute:()=>at,path:"/ideas/$ideaId",component:Zv,staticData:{layer:"corpus"}}),Poe=dt({getParentRoute:()=>at,path:"/ideas/$ideaId/tickets/$ticketId",component:Zv,staticData:{layer:"corpus"}}),Toe=dt({getParentRoute:()=>at,path:"/docs",component:YI,staticData:{layer:"runtime"}}),Noe=dt({getParentRoute:()=>at,path:"/docs/$section",component:YI,staticData:{layer:"runtime"}}),Ioe=dt({getParentRoute:()=>at,path:"/settings",component:JI,staticData:{layer:"runtime"}}),Aoe=dt({getParentRoute:()=>at,path:"/settings/$section",component:JI,staticData:{layer:"runtime"}}),Roe=dt({getParentRoute:()=>at,path:"/roadmap",component:soe,validateSearch:e=>({item:typeof e.item=="string"?e.item:void 0}),staticData:{layer:"runtime"}}),Loe=dt({getParentRoute:()=>at,path:"/inbox",component:coe,staticData:{layer:"runtime"}}),Moe=dt({getParentRoute:()=>at,path:"/stats",component:ooe,staticData:{layer:"runtime"}}),$oe=dt({getParentRoute:()=>at,path:"/git",component:aoe,staticData:{layer:"runtime"}}),Doe=dt({getParentRoute:()=>at,path:"/tasks",component:roe,validateSearch:e=>({taskId:typeof e.taskId=="string"?e.taskId:void 0}),staticData:{layer:"runtime"}}),Ooe=dt({getParentRoute:()=>at,path:"/issues",component:uoe,staticData:{layer:"runtime"}}),zoe=at.addChildren([Coe,boe,koe,_oe,Soe,joe,Eoe,Poe,Toe,Noe,Ioe,Aoe,Doe,Ooe,Roe,Moe,Loe,$oe]),Foe=jM({routeTree:zoe,basepath:da||"/"}),{runtimeUrl:af,pairingToken:ly}=LN;O8(af||da);z8(ly);const Boe=15e3;async function Voe(){!af||!ly||await fetch(K("/api/pair"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:ly}),signal:AbortSignal.timeout(Boe)}).catch(()=>{})}const XI=document.getElementById("root");if(!XI)throw new Error("#root element not found");async function Uoe(){return Ire(da,af)?!0:Are(af,e=>J(K(e)))}Voe().then(Uoe).catch(()=>!1).then(e=>{!e&&!window.location.pathname.startsWith(ay)&&window.history.replaceState(null,"",`${da}${ay}`),KC(XI).render(f.jsx(k.StrictMode,{children:f.jsx(TM,{router:Foe})}))});export{ye as $,Yoe as A,fae as B,rt as C,Joe as D,cx as E,iae as F,CI as G,cae as H,aae as I,re as J,uae as K,dae as L,xI as M,Ni as N,oae as O,II as P,hae as Q,pe as R,Ge as S,b1 as T,wc as U,fn as V,Ese as W,$8 as X,Gp as Y,gre as Z,Gf as _,nt as a,l6 as a0,Ar as a1,xc as a2,$I as a3,lse as a4,U8 as a5,Xoe as a6,yc as a7,Zoe as a8,xt as a9,qoe as aa,vP as ab,Wr as ac,L8 as ad,SJ as ae,kJ as af,Vs as ag,Sse as ah,hc as ai,pc as aj,Hse as ak,Hx as al,Cv as am,cW as an,sae as ao,Ine as b,K as c,iie as d,CP as e,lae as f,ce as g,Ane as h,In as i,f as j,Gx as k,rae as l,Qoe as m,eae as n,tae as o,St as p,jI as q,k as r,nae as s,Goe as t,M as u,wV as v,jP as w,sc as x,D8 as y,To as z};
425
+ //# sourceMappingURL=main-CDkrPxrg.js.map