@dendelion/paper-camp 0.13.0 → 0.13.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.
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-BHrFKlRC.js","assets/sidebar-section-C1uCSbsw.js","assets/index-CVlBKMF5.js","assets/tokens-C9JyAXxm.js","assets/index-DuSUXl7P.js","assets/index-BYaEopge.js"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-CQB12bDI.js","assets/sidebar-section-DLMrMf9C.js","assets/index-D6bamXbC.js","assets/tokens-C9JyAXxm.js","assets/index-BMsByqaB.js","assets/index-D-k_o5eq.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 Xl=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Gc(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Nv={exports:{}},Kc={},Iv={exports:{}},re={};/**
3
3
  * @license React
4
4
  * react.production.min.js
@@ -203,5 +203,5 @@ Rules:
203
203
 
204
204
  ${i.trim()}`:""}`;if(A){w(!0),k(null),x(null);try{const R=S.map(z=>({id:z.id,title:z.title,body:z.body,tags:z.tags}));x(await ik(A,R))}catch(R){k(R.message)}finally{w(!1)}}},I=A=>{const R=S.find(z=>z.id===A);R&&T(R.title)},M=async(A,R,z)=>{m(A);const L={date:new Date().toISOString().slice(0,10),text:r.trim()},$=await b(R,{log:[...z??[],L]},{errorTitle:"Extend failed"});m(null),$&&t()},O=async A=>{if(A.preventDefault(),!(!r.trim()||u)){h(null),c(!0);try{await n({title:r.trim(),content:i.trim()||void 0,kind:a?"note":void 0}),t()}catch(R){h(R.message)}finally{c(!1)}}};return f.jsx(ja,{open:e,onClose:t,title:"New idea",size:"small",children:f.jsxs("form",{onSubmit:O,className:"flex flex-col gap-4",children:[f.jsx(Pa,{label:"Title",value:r,onChange:A=>s(A.target.value),placeholder:"Idea title…",disabled:u,autoFocus:!0,required:!0}),P.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"}),P.map(({candidate:A})=>{const R={id:A.id??null,title:A.title,body:A.body,log:A.log},z=S.filter(B=>B.id!==A.id);return f.jsx(Ee,{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(Jr,{id:A.id}),f.jsx("span",{className:"overflow-hidden text-ellipsis whitespace-nowrap",children:A.title})]}),f.jsxs("div",{className:"flex justify-end gap-2",children:[f.jsx(ne,{type:"button",variant:"ghost",size:"small",onClick:()=>T(A.title),children:"Open it"}),f.jsx(ne,{type:"button",variant:"ghost",size:"small",disabled:!A.id||!r.trim()||p!==null,onClick:()=>A.id&&M(A.id,A.title,A.log),children:p===A.id?"Extending…":"Extend it instead"}),f.jsx(Nu,{idea:R,otherPlans:z})]})]})},A.id??A.title)})]}),f.jsxs("div",{className:"flex flex-col gap-2",children:[f.jsx("div",{children:f.jsx(ne,{type:"button",variant:"ghost",size:"small",disabled:!r.trim()||y,onClick:E,children:y?"Checking overlap…":"Check overlap"})}),v&&f.jsx("p",{className:"m-0 text-watercolor-rose-dark text-sm",children:v}),g&&f.jsx(Ee,{size:"small",texture:"canvas",children:f.jsxs("div",{className:"flex flex-col gap-2",children:[f.jsx("span",{className:"font-semibold",children:g.verdict==="new"?"Looks genuinely new":g.verdict==="extend"?`Extends ${g.targetId??"an existing idea"}`:`Belongs inside ${g.targetId??"an existing idea"}`}),f.jsx("span",{className:"text-sm opacity-80",children:g.reasoning}),g.targetId&&f.jsx("div",{className:"flex justify-end",children:f.jsx(ne,{type:"button",variant:"ghost",size:"small",onClick:()=>I(g.targetId),children:"Open it"})})]})})]}),f.jsx(Eu,{label:"Description",value:i,onChange:A=>o(A.target.value),placeholder:"Optional details…",disabled:u,rows:4}),f.jsx(a6,{label:"Just a note (no plan needed)",checked:a,onChange:A=>l(A.target.checked),disabled:u}),d&&f.jsx("p",{className:"m-0 text-watercolor-rose-dark text-sm",children:d}),f.jsxs("div",{className:"flex justify-end gap-2",children:[f.jsx(ne,{type:"button",variant:"ghost",onClick:t,disabled:u,children:"Cancel"}),f.jsx(ne,{type:"submit",variant:"primary",disabled:!r.trim()||u,children:"Add"})]})]})})},CU=({suggestion:e,onClose:t})=>{const n=F(c=>c.promoteSuggestion),r=F(c=>c.launchIdeaExtend),[s,i]=_.useState(!1),[o,a]=_.useState(null),{toast:l}=Ge();_.useEffect(()=>{e&&(i(!1),a(null))},[e]);const u=async()=>{if(e){i(!0),a(null);try{const c=await n(e),d=F.getState().ideaEntries.find(h=>h.id===c);if(d)try{await r(c,gU(d))}catch(h){l({title:"Idea created, but the refine agent failed to launch",description:Qe(h.message),variant:"error"})}t()}catch(c){a(c.message)}finally{i(!1)}}};return f.jsx(ja,{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(ne,{type:"button",variant:"ghost",onClick:t,disabled:s,children:"Cancel"}),f.jsx(ne,{type:"button",variant:"primary",onClick:u,disabled:s,children:s?"Moving…":"Move to ideas"})]})]})})},af=({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}`)})}),Sv=e=>f.jsx("h4",{className:"font-display-luminari text-xs font-semibold mb-2 opacity-[0.65]",children:e}),PU=({plan:e,before:t,onApprove:n,onDiscard:r,queuePosition:s})=>{const[i,o]=_.useState(!1),[a,l]=_.useState(!1),u=e.body!==t.body,c=e.phases.map((m,y)=>({phase:m,before:t.phases[y],index:y})).filter(({phase:m,before:y})=>y!==void 0&&(m.text!==y.text||(m.description??"")!==(y.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(ja,{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.']}),!u&&c.length===0&&f.jsx("p",{className:"text-sm m-0 opacity-60",children:"No wording changed."}),u&&f.jsxs("div",{children:[Sv("Body"),f.jsx("p",{className:"text-base m-0 leading-normal",children:f.jsx(af,{tokens:Ed(t.body,e.body)})})]}),c.length>0&&f.jsxs("div",{children:[Sv("Phases"),f.jsx("div",{className:"flex flex-col gap-3",children:c.map(({phase:m,before:y,index:w})=>f.jsxs("div",{className:"text-sm leading-normal",children:[f.jsx(af,{tokens:Ed(y.text,m.text)}),(m.description||y.description)&&f.jsx("div",{className:"opacity-[0.85] mt-1",children:f.jsx(af,{tokens:Ed(y.description??"",m.description??"")})})]},w))})]}),f.jsxs("div",{className:"flex justify-end gap-2",children:[f.jsx(ne,{variant:"danger",size:"small",onClick:h,disabled:d,children:"Discard"}),f.jsx(ne,{variant:"primary",size:"small",onClick:p,disabled:d,children:"Approve"})]})]})})},jU=()=>{const e=F(c=>c.archivableIdeas),t=F(c=>c.archiveIdeas),[n,r]=_.useState(null),[s,i]=_.useState(!1),{toast:o}=Ge(),a=_.useCallback(async c=>{try{await t(c)}catch(d){o({title:"Archive failed",description:d.message,variant:"error"})}},[t,o]),l=_.useCallback(async c=>{r(c.id);try{await a([c.id])}finally{r(null)}},[a]),u=_.useCallback(async()=>{i(!0);try{await a(e.map(c=>c.id))}finally{i(!1)}},[a,e]);return e.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 (",e.length,")"]}),f.jsx(ne,{variant:"ghost",size:"small",disabled:s||n!==null,onClick:u,children:s?"Archiving…":"Archive all"})]}),f.jsx("div",{className:"flex flex-col gap-1",children:e.map(c=>f.jsx("div",{className:"rounded-[10px]",children:f.jsx(Ee,{size:"small",texture:"canvas",className:"plan-row-card",children:f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(Jr,{id:c.id}),f.jsx("span",{className:"flex-1 min-w-0 font-semibold overflow-hidden text-ellipsis whitespace-nowrap",children:c.title}),f.jsx(ut,{icon:f.jsx("span",{children:"→"}),variant:"ghost",size:"small",label:`Archive ${c.title}`,disabled:n===c.id||s,onClick:()=>l(c),className:"w-[28px] h-[28px]"})]})})},c.id))})]})},EU="font-display-luminari font-semibold text-[1.75rem] leading-[1.2]",TU=({onAdd:e,disabled:t})=>{const[n,r]=_.useState(!1),[s,i]=_.useState(""),[o,a]=_.useState(null),[l,u]=_.useState(!1),c=()=>{r(!1),i(""),a(null)},d=async()=>{let h;try{h=CM(s)}catch(p){a(p instanceof Error?p.message:"Could not parse findings");return}u(!0),a(null);try{await e(h),c()}finally{u(!1)}};return f.jsxs(f.Fragment,{children:[f.jsx(Ie,{content:"Add code-review findings as phases",children:f.jsx(ut,{variant:"ghost",size:"small",onClick:()=>r(!0),disabled:t,"aria-label":"Add code-review findings as phases",icon:f.jsx(Q4,{size:16})})}),f.jsx(ja,{open:n,onClose:c,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(Eu,{value:s,onChange:h=>i(h.target.value),placeholder:'[{ "description": "...", "file": "src/foo.ts", "line_start": 12, "failure_scenario": "..." }]',rows:10,disabled:l}),o&&f.jsxs(xS,{variant:"warning",children:["Could not add phases — ",o]}),f.jsxs("div",{className:"flex justify-end gap-2",children:[f.jsx(ne,{type:"button",variant:"ghost",onClick:c,disabled:l,children:"Cancel"}),f.jsx(ne,{type:"button",variant:"primary",onClick:d,disabled:l||!s.trim(),children:"Add phases"})]})]})})]})},RU=cM.map(e=>({value:e,label:e})),NU=({open:e,onClose:t,onAdd:n})=>{const[r,s]=_.useState(""),[i,o]=_.useState(""),[a,l]=_.useState("feat"),[u,c]=_.useState(!1),[d,h]=_.useState(null),[p,m]=_.useState(null),[y,w]=_.useState(!1),[g,x]=_.useState(null),[v,k]=_.useState(null),S=F(R=>{var z;return((z=R.plans)==null?void 0:z.entries)??[]}),{patch:b}=Ea(),j=Zt(),{toast:P}=Ge(),T=SS(r,S.map(R=>({id:R.id,title:R.title,body:R.body,tags:R.tags,log:R.log})));_.useEffect(()=>{e&&(s(""),o(""),l("feat"),c(!1),h(null),w(!1),x(null),k(null))},[e]),_.useEffect(()=>{x(null),k(null)},[r,i]);const E=R=>{t(),j({to:"/plans/$planId",params:{planId:encodeURIComponent(R)}})},I=async()=>{const R=`${r.trim()}${i.trim()?`
205
205
 
206
- ${i.trim()}`:""}`;if(R){w(!0),k(null),x(null);try{const z=S.map(B=>({id:B.id,title:B.title,body:B.body,tags:B.tags}));x(await ik(R,z))}catch(z){k(z.message)}finally{w(!1)}}},M=R=>{const z=S.find(B=>B.id===R);z?E(z.title):P({title:"Plan not found",description:`No plan with id ${R}`,variant:"error"})},O=async(R,z,B)=>{m(R);const $={date:new Date().toISOString().slice(0,10),text:r.trim()},C=await b(z,{log:[...B??[],$]},{errorTitle:"Extend failed"});m(null),C&&t()},A=async R=>{if(R.preventDefault(),!(!r.trim()||u)){h(null),c(!0);try{await n({title:r.trim(),content:i.trim()||void 0,kind:a}),t()}catch(z){h(z.message)}finally{c(!1)}}};return f.jsx(ja,{open:e,onClose:t,title:"Quick plan",size:"small",children:f.jsxs("form",{onSubmit:A,className:"flex flex-col gap-4",children:[f.jsx(Pa,{label:"Title",value:r,onChange:R=>s(R.target.value),placeholder:"Backlog item title…",disabled:u,autoFocus:!0,required:!0}),T.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"}),T.map(({candidate:R})=>{const z={id:R.id??null,title:R.title,body:R.body,log:R.log},B=S.filter(L=>L.id!==R.id);return f.jsx(Ee,{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(Jr,{id:R.id}),f.jsx("span",{className:"overflow-hidden text-ellipsis whitespace-nowrap",children:R.title})]}),f.jsxs("div",{className:"flex justify-end gap-2",children:[f.jsx(ne,{type:"button",variant:"ghost",size:"small",onClick:()=>E(R.title),children:"Open it"}),f.jsx(ne,{type:"button",variant:"ghost",size:"small",disabled:!R.id||!r.trim()||p!==null,onClick:()=>R.id&&O(R.id,R.title,R.log),children:p===R.id?"Extending…":"Extend it instead"}),f.jsx(Nu,{idea:z,otherPlans:B})]})]})},R.id??R.title)})]}),f.jsxs("div",{className:"flex flex-col gap-2",children:[f.jsx("div",{children:f.jsx(ne,{type:"button",variant:"ghost",size:"small",disabled:!r.trim()||y,onClick:I,children:y?"Checking overlap…":"Check overlap"})}),v&&f.jsx("p",{className:"m-0 text-watercolor-rose-dark text-sm",children:v}),g&&f.jsx(Ee,{size:"small",texture:"canvas",children:f.jsxs("div",{className:"flex flex-col gap-2",children:[f.jsx("span",{className:"font-semibold",children:g.verdict==="new"?"Looks genuinely new":g.verdict==="extend"?`Extends ${g.targetId??"an existing idea"}`:`Belongs inside ${g.targetId??"an existing idea"}`}),f.jsx("span",{className:"text-sm opacity-80",children:g.reasoning}),g.targetId&&f.jsx("div",{className:"flex justify-end",children:f.jsx(ne,{type:"button",variant:"ghost",size:"small",onClick:()=>M(g.targetId),children:"Open it"})})]})})]}),f.jsx(qh,{label:"Kind",value:a,onChange:R=>l(R),options:RU,disabled:u}),f.jsx(Eu,{label:"Description",value:i,onChange:R=>o(R.target.value),placeholder:"Optional details…",disabled:u,rows:4}),d&&f.jsx("p",{className:"m-0 text-watercolor-rose-dark text-sm",children:d}),f.jsxs("div",{className:"flex justify-end gap-2",children:[f.jsx(ne,{type:"button",variant:"ghost",onClick:t,disabled:u,children:"Cancel"}),f.jsx(ne,{type:"submit",variant:"primary",disabled:!r.trim()||u,children:"Add"})]})]})})},IU=()=>f.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[f.jsx("path",{d:"M10 6h10M10 12h10M10 18h10"}),f.jsx("path",{d:"M3 6l1.5 1.5L7 5M3 12l1.5 1.5L7 11M3 18l1.5 1.5L7 17"})]}),AU=()=>{const e=F(o=>o.loadPlans),t=F(o=>o.gitBranchHygiene),[n,r]=_.useState(!1),s=t==="stale-merged",i=async o=>{await tM(o),await e(),r(!1)};return f.jsxs(f.Fragment,{children:[f.jsx(Ie,{content:s?"Switch to main first":void 0,children:f.jsx(ut,{icon:f.jsx(IU,{}),variant:"ghost",size:"small",label:s?"Switch to main first":"Quick plan",disabled:s,onClick:()=>r(!0)})}),f.jsx(NU,{open:n,onClose:()=>r(!1),onAdd:i})]})},MU=({planId:e,phaseIndex:t,disabled:n})=>{const r=F(c=>c.launchAgent),s=F(Qr),{toast:i}=Ge(),[o,a]=_.useState(!1),l=async c=>{if(c.stopPropagation(),!!e){a(!0);try{await r(e,t)}catch(d){i({title:"Failed to start agent",description:Qe(d.message),variant:"error"})}finally{a(!1)}}},u=e?s?"Start agent on this phase":"No agent CLI found — set up in Settings":"Plan needs an ID before an agent can run";return f.jsx(ut,{icon:f.jsx("span",{className:"text-xs leading-none",children:"▶"}),variant:"ghost",size:"small",label:u,onClick:l,disabled:n||o||!e||!s,className:"transition-opacity text-ink-500"})},LU=({plan:e,disabled:t})=>{const n=F(l=>l.launchPlanAudit),r=F(Qr),[s,i]=_.useState(!1),o=async()=>{if(e.id){i(!0);try{await n(e.id,hU(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(Ie,{content:a,children:f.jsx(ne,{variant:"ghost",size:"small",onClick:o,disabled:t||s||!e.id||!r,children:"Audit"})})},tg=({idea:e,compact:t})=>{const n=F(h=>h.launchIdeaExtend),r=F(Qr),{state:s,errorMessage:i,run:o}=ES(),{toast:a}=Ge(),l=e.id,u=()=>{l&&o(async()=>{const h=F.getState().ideaEntries.find(p=>p.id===l);if(!h)throw new Error(`Idea ${l} not found`);try{await n(l,mU(h))}catch(p){throw a({title:"Extension failed",description:Qe(p.message),variant:"error"}),p}})},c=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(Ie,{content:d,children:f.jsx(ne,{variant:"ghost",size:"small",onClick:u,disabled:s==="loading"||!l||!r,className:s==="error"?"text-watercolor-rose-dark":void 0,children:c})})},DU=({plan:e,disabled:t})=>{const n=F(c=>c.launchFixReview),r=F(Qr),s=F($M),[i,o]=_.useState(!1),a=async()=>{if(e.id){o(!0);try{await n(e.id)}catch(c){alert(c.message)}finally{o(!1)}}},l=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";return f.jsx(Ie,{content:u,children:f.jsx(li,{size:"small",icon:f.jsx("span",{className:"text-watercolor-amber-dark",children:"⚑"}),onClick:a,disabled:l,className:l?"opacity-50":void 0,children:i?"Starting…":"Fix review comments"})})},FU=()=>{const e=F(s=>s.loadIdeas),[t,n]=_.useState(!1),r=async s=>{await ZA(s),await e(),n(!1)};return f.jsxs(f.Fragment,{children:[f.jsx(ut,{icon:f.jsx(K4,{size:16}),variant:"ghost",size:"small",label:"New idea",onClick:()=>n(!0)}),f.jsx(SU,{open:t,onClose:()=>n(!1),onAdd:r})]})};async function OU(e){var r;if((r=navigator.clipboard)!=null&&r.writeText)try{return await navigator.clipboard.writeText(e),!0}catch{}const t=document.createElement("textarea");t.value=e,t.style.position="fixed",t.style.opacity="0",document.body.appendChild(t),t.focus(),t.select();let n=!1;try{n=document.execCommand("copy")}catch{n=!1}return document.body.removeChild(t),n}const zU=({planTitle:e,planId:t,phaseIndex:n})=>{const[r,s]=_.useState("idle"),i=async o=>{o.stopPropagation();const a=`Start phase ${n+1} of plan "${e}" in papercamp/ideas/${t??"<ID>"}.md`,l=await OU(a);s(l?"copied":"failed"),setTimeout(()=>s("idle"),1500)};return f.jsx(ut,{icon:r==="copied"?f.jsx(gS,{size:16}):r==="failed"?f.jsx(Ca,{size:16}):f.jsx(q4,{size:16}),variant:"ghost",size:"small",label:r==="copied"?"Copied":r==="failed"?"Copy failed — select and copy manually":"Copy phase prompt",onClick:i,className:`transition-opacity ${r==="copied"?"text-state-success":r==="failed"?"text-state-danger":"text-ink-500"}`})},BU=({plan:e,disabled:t})=>{const n=F(l=>l.launchPlanReconcile),r=F(Qr),[s,i]=_.useState(!1),o=async()=>{if(e.id){i(!0);try{await n(e.id,pU(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(Ie,{content:a,children:f.jsx(ne,{variant:"ghost",size:"small",onClick:o,disabled:t||s||!e.id||!r,children:"Refresh"})})},LS=()=>{const e=F(s=>s.refreshAll),t=F(s=>s.refreshing),{toast:n}=Ge(),r=async()=>{if(t)return;const s=await e();s.ok?n({title:"Up to date",description:"Plans, ideas, checks and PR review state re-read.",variant:"success"}):n({title:"Couldn't refresh",description:s.error??"The read failed — is the dev server running?",variant:"error"})};return f.jsx(ut,{icon:f.jsx("span",{className:`inline-flex${t?" animate-pc-spin motion-reduce:animate-none":""}`,children:f.jsx(F8,{size:16})}),label:t?"Refreshing…":"Refresh data",size:"small",variant:"ghost",disabled:t,onClick:r})},$U=({plan:e,disabled:t})=>{const n=F(u=>u.launchRunAll),r=F(Qr),[s,i]=_.useState(!1),o=async()=>{if(e.id){i(!0);try{await n(e.id)}catch(u){alert(u.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(Ie,{content:l,children:f.jsx(li,{size:"small",icon:f.jsx("span",{className:"text-ink-500",children:"▶"}),onClick:o,disabled:a,className:a?"opacity-50":void 0,children:s?"Starting…":"Run all phases"})})},VU=()=>{const e=F(y=>y.launchSuggestIdeas),t=F(y=>y.launchBatchReconcile),n=F(y=>y.launchPrioritise),r=F(y=>y.ideaEntries),s=F(y=>y.suggestions),i=F(gm),o=F(Qr),{toast:a}=Ge(),[l,u]=_.useState(null),c=async()=>{u("suggest");try{await e(xU(r,s))}catch(y){a({title:"Failed to launch",description:Qe(y.message),variant:"error"})}finally{u(null)}},d=async()=>{u("actualise");try{await t()}catch(y){a({title:"Failed to launch",description:Qe(y.message),variant:"error"})}finally{u(null)}},h=async()=>{u("prioritise");try{const y=await n();a({title:y.moved.length>0?"Queue reordered":"Already in order",description:y.why||void 0,variant:"success"})}catch(y){a({title:"Failed to prioritise",description:Qe(y.message),variant:"error"})}finally{u(null)}},p=l!==null||i,m=[{id:"suggest-ideas",label:l==="suggest"?"Starting…":"Suggest ideas",icon:f.jsx(bS,{size:16}),disabled:p||!o,onSelect:c},{id:"actualise-all",label:l==="actualise"?"Starting…":"Actualise all",icon:f.jsx(gS,{size:16}),disabled:p||!o,onSelect:d},{id:"prioritise",label:l==="prioritise"?"Prioritising…":"Prioritise queue",icon:f.jsx(z8,{size:16}),disabled:p||!o,onSelect:h}];return f.jsx(E8,{align:"end",trigger:f.jsx(ut,{icon:f.jsx(O8,{size:16}),label:"More actions",size:"small",variant:"ghost"}),items:m})};function UU(e){const t=e==null?void 0:e.match(/^[a-z]+\/([a-z]+-\d+)-/);return t?t[1].toUpperCase():null}const Iu="font-display-luminari text-sm font-semibold opacity-[0.65]",WU=({plan:e,auditRunning:t,agentBusy:n,agentPhaseIndex:r,planTask:s,updating:i,onTogglePhase:o,onToggleFix:a,onAddReviewPhases:l})=>{const u=F(p=>p.launchRunAll),c=e.fixes??[],d=c.some(p=>!p.done),h=[...e.phases.map((p,m)=>({kind:"phase",item:p,index:m})),...c.map((p,m)=>({kind:"fix",item:p,index:m}))];return f.jsxs("div",{className:"mb-8",children:[f.jsxs("div",{className:"flex items-center justify-between gap-3 mb-3 flex-wrap",children:[f.jsx("h3",{className:`${Iu} m-0`,children:"Phases"}),f.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t&&f.jsx(Ii,{size:"small",label:"Audit running…"}),(e.status==="review"||e.status==="done")&&f.jsx(LU,{plan:e}),e.status!=="done"&&f.jsx(BU,{plan:e}),f.jsx(TU,{onAdd:l,disabled:i}),e.id&&d&&f.jsx(Ie,{content:"Run the open fixes with an agent",children:f.jsx(ne,{size:"small",onClick:()=>e.id&&u(e.id),disabled:n,children:n?"Running…":"Run fixes"})})]})]}),f.jsx(M$,{data:h,columns:[{key:"checkbox",header:"Status",cell:p=>f.jsx(f4,{checked:p.item.done,onChange:()=>p.kind==="phase"?o(p.index):a(p.index),disabled:i}),width:2},{key:"title",header:"Title",cell:p=>f.jsxs("span",{className:`inline-flex items-center gap-2 ${p.item.done?"line-through opacity-[0.45]":"no-underline"}`,children:[p.item.text,p.kind==="phase"&&p.item.source==="review"&&f.jsx(Ae,{size:"small",fillColor:er.review.fill,textColor:er.review.text,children:"review"}),p.kind==="fix"&&f.jsx(Ae,{size:"small",variant:"warning",children:"fix"})]})},{key:"actions",header:"Actions",align:"end",cell:p=>p.kind==="phase"?f.jsxs("div",{className:"inline-flex gap-2 items-center",children:[f.jsx(zU,{planTitle:e.title,planId:e.id,phaseIndex:p.index}),!p.item.done&&r===p.index?f.jsx(Ii,{size:"small",label:`Agent ${s==null?void 0:s.status}…`}):!p.item.done&&f.jsx(MU,{planId:e.id,phaseIndex:p.index,disabled:n})]}):null,width:7}],expandable:{render:p=>p.item.description||null},showExpandColumn:!1,rowTexture:p=>p.kind==="fix"?"kraft":void 0,rowClassName:p=>p.kind==="phase"&&p.item.source==="review"?"bg-[rgba(155,122,181,0.08)]":void 0,className:"phase-table-phone"})]})},HU=({plan:e,gitBranch:t,onOwnBranch:n,branching:r,onCreateBranch:s})=>{const i=e.status==="planned"||e.status==="in-progress"||e.status==="review";return!i&&!e.pr?null:f.jsxs("div",{className:"flex items-center gap-3 flex-wrap mb-4",children:[i&&!n&&f.jsx(Ee,{size:"small",accent:!0,accentColor:"amber",texture:"kraft",children:f.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[f.jsxs("span",{className:"text-sm",children:["Working branch: ",f.jsx("code",{children:t??"unknown"})," — not this plan's branch."]}),e.id&&f.jsx(Ie,{content:`Creates ${(e.kind??"feat").toLowerCase()}/${e.id.toLowerCase()}-… from main, or switches to it if it already exists`,children:f.jsx(ne,{size:"small",onClick:s,disabled:r,children:r?"Switching…":"Create branch"})})]})}),i&&n&&f.jsxs("span",{className:"text-sm opacity-[0.45]",children:["Working branch: ",f.jsx("code",{children:t})]}),e.pr&&f.jsx(AS,{pr:e.pr}),e.pr&&f.jsx(_U,{pr:e.pr})]})},GU=({progress:e,color:t})=>f.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[f.jsx("div",{className:"flex-1",children:f.jsx(MS,{pct:e.pct,color:t})}),f.jsxs("span",{className:"text-sm opacity-50 flex-shrink-0",children:[e.done,"/",e.total]})]}),KU=({plan:e})=>f.jsx("div",{className:"mb-4",children:f.jsx("div",{className:"opacity-[0.85]",children:e.body&&f.jsx(RS,{resetKey:e.id??e.title,children:f.jsx(ek,{children:e.body})})})}),qU=({clarifications:e})=>e.length===0?null:f.jsxs("div",{className:"mb-5",children:[f.jsx("h3",{className:`${Iu} 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}`))})]}),YU=({planId:e})=>{const t=fU(e);return t?f.jsxs("div",{className:"mb-8",children:[f.jsx("h3",{className:`${Iu} mb-3`,children:"History"}),f.jsx(kU,{trail:t})]}):null},QU={review:"review",note:"note",decision:"decision",question:"question",clarification:"clarification"},XU=({messages:e,undo:t,undoing:n,onUndo:r})=>f.jsx(f.Fragment,{children:e.map((s,i)=>{const o=QU[s.kind],a=s.from==="agent",l=i===e.length-1;return f.jsxs("div",{className:`flex flex-col gap-1 ${a?"items-start":"items-end"}`,children:[f.jsx("div",{className:"max-w-[85%]",children:f.jsx(Ee,{size:"small",surface:"paper",texture:a?"kraft":o?"canvas":"parchment",shade:a,accent:!a,accentColor:o?"rose":"blue",children:f.jsx(RS,{collapsedLines:3,resetKey:`${s.kind}-${s.date??""}-${i}`,children:s.text})})}),f.jsxs("div",{className:"flex items-center gap-2",children:[a&&f.jsx(Ae,{size:"small",fillColor:"rgba(0,0,0,0.06)",children:"agent"}),a&&l&&t&&f.jsx(Ie,{content:"Revert this run's plan edit",children:f.jsx(ne,{size:"small",variant:"ghost",onClick:r,disabled:n,children:n?"Undoing…":"Undo"})}),s.date&&f.jsx("span",{className:"text-sm font-semibold opacity-[0.45]",children:s.date}),o&&f.jsx(Ae,{size:"small",fillColor:"rgba(0,0,0,0.06)",children:o})]})]},`${s.kind}-${s.date??""}-${i}`)})}),JU=({plan:e,updating:t,onSend:n,undo:r,undoing:s,onUndo:i})=>{const[o,a]=_.useState(""),l=e.thread??[],u=async()=>{o.trim()&&await n(o.trim())&&a("")};return f.jsxs("div",{className:"mb-8",children:[f.jsx("h3",{className:`${Iu} mb-3`,children:"Feedback"}),f.jsxs(Ee,{size:"small",accent:!0,accentColor:"slate",texture:"kraft",children:[f.jsx("div",{className:"flex flex-col gap-3 mb-4",children:l.length>0?f.jsx(XU,{messages:l,undo:r,undoing:s,onUndo:i}):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(Eu,{value:o,onChange:c=>a(c.target.value),"aria-label":"Feedback message",placeholder:"Write a message…",rows:3,disabled:t}),f.jsxs("div",{className:"flex justify-end items-center gap-3",children:[f.jsx("span",{className:t?"visible":"invisible",children:f.jsx(Ii,{size:"small",label:"Agent replying…"})}),f.jsx(ne,{size:"small",onClick:u,disabled:t||!o.trim(),children:"Send"})]})]})]})]})},ZU=({plan:e})=>{const t=F(A=>A.plans),n=F(A=>A.gitBranch),r=F(A=>A.loadGitStatus),{toast:s}=Ge(),{patch:i,updating:o}=Ea(),[a,l]=_.useState(!1),u=F(A=>A.agentStatus),c=F(gm),d=F(A=>A.detailView),h=fm(e.id,u),p=h?h.phaseIndex:null,m=(h==null?void 0:h.taskKind)==="audit",y=iM(e),w=e.phases.length>0,g=d==="feedback",x={id:e.id??null,title:e.title,body:e.body,log:e.log},v=((t==null?void 0:t.entries)??[]).filter(A=>A.id!==e.id),k=e.id!==void 0&&UU(n)===e.id,S=async()=>{if(e.id){l(!0);try{const A=await AM(e.id);s({title:"Branch ready",description:`Now on ${A}`,variant:"success"}),await r()}catch(A){s({title:"Branch failed",description:Qe(A.message),variant:"error"})}finally{l(!1)}}},b=async A=>{const R=e.phases.map((B,L)=>L===A?{...B,done:!B.done}:B);R.every(B=>B.done)&&e.status==="in-progress"?await i(e.title,{phases:R,status:"review"}):await i(e.title,{phases:R})},j=async A=>{await i(e.title,{phases:[...e.phases,...A]})},P=async A=>{const R=(e.fixes??[]).map((B,L)=>L===A?{...B,done:!B.done}:B);R.every(B=>B.done)&&e.status==="in-progress"?await i(e.title,{fixes:R,status:"review"}):await i(e.title,{fixes:R})},{sending:T,send:E,undo:I,undoing:M,undoEdit:O}=uU(e);return f.jsxs("div",{children:[f.jsxs("div",{className:"flex items-baseline justify-between gap-3 mb-3 flex-wrap",children:[f.jsxs("h2",{className:`${EU} m-0 flex items-center gap-3 min-w-0 flex-wrap`,children:[f.jsx(Jr,{id:e.id}),e.title]}),f.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[f.jsx("span",{className:"text-sm opacity-[0.45] whitespace-nowrap",children:e.updated?`updated ${Tc(e.updated)}`:`created ${Tc(e.created)}`}),f.jsx(LS,{})]})]}),g?f.jsx(JU,{plan:e,updating:T,onSend:E,undo:I,undoing:M,onUndo:O}):f.jsxs(f.Fragment,{children:[f.jsx(HU,{plan:e,gitBranch:n,onOwnBranch:k,branching:a,onCreateBranch:S}),y!==null&&f.jsx(GU,{progress:y,color:NS[hm(e,u)]}),f.jsx(KU,{plan:e}),f.jsx(qU,{clarifications:e.clarifications??[]}),!w&&f.jsxs("div",{className:"flex items-center gap-3 mb-8",children:[f.jsx(Nu,{idea:x,otherPlans:v}),f.jsx(tg,{idea:x})]}),w&&f.jsx(WU,{plan:e,auditRunning:m,agentBusy:c,agentPhaseIndex:p,planTask:h,updating:o,onTogglePhase:b,onToggleFix:P,onAddReviewPhases:j}),f.jsx(YU,{planId:e.id})]})]})},eW=()=>{const[e,t]=_.useState(new Set);return _.useEffect(()=>{let n=!1;return qA().then(r=>{n||!r||t(new Set(r.horizons.flatMap(s=>s.items.map(i=>i.name))))}).catch(()=>{}),()=>{n=!0}},[]),e},go="text-sm font-semibold opacity-60 whitespace-nowrap overflow-hidden",ng=({order:e,done:t,running:n,status:r})=>f.jsx("span",{className:"flex-[0_0_36px] flex items-center justify-center",children:n?f.jsx(Ii,{size:"small",label:"Agent running"}):t?f.jsx("span",{"aria-label":"Done",className:"text-watercolor-green-dark text-sm",children:"✓"}):e!==void 0?f.jsx(Ae,{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(Qm,{size:14})}):null}),Yh="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",DS=({plans:e,activePlanTitle:t,onOpen:n,showHeader:r=!0})=>{const s=Yh,i=F(o=>o.agentStatus);return f.jsxs("div",{className:"flex flex-col gap-1",children:[r&&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(Ee,{size:"small",texture:"kraft",className:"plan-row-card",children:f.jsxs("div",{className:s,children:[f.jsx("span",{className:go,children:"Id"}),f.jsx("span",{className:go,children:"Title"}),f.jsx("span",{className:`max-lg:hidden ${go}`,children:"Updated"}),f.jsx("span",{className:go,children:"Progress"}),f.jsx("span",{className:go,children:"Status"})]})})})]}),e.map(o=>{var u;const a=lk(o),l=hm(o,i);return f.jsxs("div",{className:"flex items-center",children:[f.jsx(ng,{order:o.order,done:o.status==="done",status:o.status,running:!!fm(o.id,i)}),f.jsx("div",{role:n?"button":void 0,tabIndex:n?0:void 0,onClick:n?()=>n(o.title):void 0,onKeyDown:n?c=>{(c.key==="Enter"||c.key===" ")&&(c.preventDefault(),n(o.title))}:void 0,className:`${n?"cursor-pointer":""} rounded-[10px] flex-1 min-w-0 ${o.title===t?"plan-row-highlighted outline outline-2 outline-offset-[-2px] outline-[rgba(200,154,90,0.5)]":""}`,children:f.jsx(Ee,{size:"small",texture:"canvas",className:"plan-row-card",children:f.jsxs("div",{className:s,children:[f.jsx(Jr,{id:o.id}),f.jsx("span",{className:"font-semibold overflow-hidden text-ellipsis whitespace-nowrap",children:o.title}),f.jsx("span",{className:"max-lg:hidden text-sm opacity-[0.45] whitespace-nowrap",children:o.updated?Tc(o.updated):Tc(o.created)}),a?f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsx("div",{className:"flex-1 min-w-0",children:f.jsx(MS,{pct:a.pct,color:NS[l]})}),f.jsxs("span",{className:"text-sm opacity-50 shrink-0",children:[a.done,"/",a.total]})]}):f.jsx("span",{className:"text-sm opacity-30",children:"—"}),f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsx(Ae,{size:"small",fillColor:er[l].fill,textColor:er[l].text,children:eg[l]}),((u=o.pr)==null?void 0:u.state)==="merged"&&f.jsx(Ie,{content:`Merged in #${o.pr.number}`,children:f.jsx("span",{className:"inline-flex text-[#7B5E9E]",children:f.jsx(Ru,{size:14})})})]})]})})})]},o.title)})]})},tW=5,nW="text-sm font-semibold opacity-60 whitespace-nowrap overflow-hidden",FS="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",Cv="font-handwritten text-xs font-semibold opacity-55 leading-none pt-2 pr-1 pb-0 pl-1",Pv=`${nW} bg-none bg-transparent border-none p-0 cursor-pointer [font:inherit] text-inherit text-left`,rW=[{key:"id",label:"Id"},{key:"title",label:"Title"},{key:"updated",label:"Updated"},{key:"progress",label:"Progress"},{key:"status",label:"Status"}],OS="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",zS="overflow-hidden text-ellipsis whitespace-nowrap",sW=({rows:e,plans:t,activePlanTitle:n,onOpenPlan:r,onOpenIdea:s})=>{const[i,o]=_.useState(new Set),{subjects:a,loading:l,available:u}=CS(),c=eW(),d=Zt(),h=FS,p=F(b=>b.planFilters.sortKey),m=F(b=>b.planFilters.sortDirection),y=F(b=>b.setPlanSortKey),w=F(b=>b.togglePlanSortDirection),g=b=>{b===p?w():y(b)},x=b=>{o(j=>{const P=new Set(j);return P.has(b)?P.delete(b):P.add(b),P})},v=b=>b.type==="plan"?f.jsx(DS,{plans:[b.plan],activePlanTitle:n,onOpen:r,showHeader:!1},b.plan.title):b.type==="note"?f.jsx(iW,{row:b,onOpen:s},b.idea.title):f.jsx(oW,{row:b,plans:t,activePlanTitle:n,onOpenPlan:r,onOpenIdea:s,expanded:i.has(b.idea.title),onToggleExpanded:()=>x(b.idea.title)},b.idea.title),k=gM(e,l||!u?void 0:a),S=k.length>1;return f.jsxs("div",{className:"flex flex-col gap-1",children:[f.jsxs("div",{className:"flex items-center",children:[f.jsx("span",{role:"columnheader",className:"flex-[0_0_36px] flex justify-center","aria-sort":p==="order"?m==="asc"?"ascending":"descending":void 0,children:f.jsxs("button",{type:"button",className:Pv,"aria-label":"Sort by run order",onClick:()=>g("order"),children:["#",p==="order"&&(m==="asc"?"▲":"▼")]})}),f.jsx("div",{className:"flex-1 min-w-0",children:f.jsx(Ee,{size:"small",texture:"kraft",className:"plan-row-card",children:f.jsx("div",{className:h,children:rW.map(({key:b,label:j})=>{const P=b===p;return f.jsx("span",{role:"columnheader",className:b==="updated"?"max-lg:hidden":void 0,"aria-sort":P?m==="asc"?"ascending":"descending":void 0,children:f.jsxs("button",{type:"button",className:Pv,onClick:()=>g(b),children:[j,P&&(m==="asc"?" ▲":" ▼")]})},b)})})})})]}),S?k.map(b=>{const j=b.subject;return f.jsxs("div",{className:"flex flex-col gap-1",children:[f.jsx("div",{className:"flex items-baseline gap-2",children:j&&c.has(j)?f.jsx("button",{type:"button",className:`${Cv} bg-none bg-transparent border-none cursor-pointer text-left hover:underline`,title:"View in roadmap",onClick:()=>d({to:"/roadmap",search:{item:j}}),children:j}):f.jsx("div",{className:Cv,children:j??"No subject"})}),b.rows.map(P=>v(P))]},j??"__no-subject__")}):e.map(b=>v(b))]})},iW=({row:e,onOpen:t})=>{const n=e.idea,r=n.status??"open";return f.jsxs("div",{className:"flex items-center",children:[f.jsx(ng,{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(Ee,{size:"small",texture:"canvas",className:"plan-row-card",children:f.jsxs("div",{className:FS,children:[n.id?f.jsx(Jr,{id:n.id}):f.jsx("span",{}),f.jsxs("span",{className:`${OS} [cursor:inherit]`,children:[f.jsx(V8,{}),f.jsx("span",{className:zS,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(Ae,{size:"small",fillColor:Hc[r].fill,textColor:Hc[r].text,children:IS[r]})]})})})]})},oW=({row:e,plans:t,activePlanTitle:n,onOpenPlan:r,onOpenIdea:s,expanded:i,onToggleExpanded:o})=>{const a=e.idea,l=e.children,u=l.filter(p=>p.status==="done"),c=l.filter(p=>p.status!=="done"),d=l.length>tW,h=d&&!i?c:l;return f.jsxs("div",{className:"flex flex-col gap-1",children:[f.jsxs("div",{className:"flex items-center",children:[f.jsx(ng,{order:a.order,done:a.status==="done",status:a.status}),f.jsx("div",{className:"flex-1 min-w-0",children:f.jsx(Ee,{size:"small",texture:"canvas",className:"plan-row-card",children:f.jsxs("div",{className:"grid grid-cols-[76px_minmax(0,1fr)_84px_1fr] gap-2 items-center max-[480px]:grid-cols-1 max-[480px]:gap-1",children:[a.id?f.jsx(Jr,{id:a.id}):f.jsx("span",{}),f.jsxs("button",{type:"button",onClick:()=>s==null?void 0:s(a.title),className:OS,children:[f.jsx(Qm,{}),f.jsx("span",{className:zS,children:a.title})]}),f.jsx("span",{className:"max-lg:hidden text-sm opacity-[0.45]",children:"—"}),f.jsxs("div",{className:"flex items-center justify-end gap-2",children:[f.jsx("span",{className:`text-sm ${l.length>0?"opacity-60":"opacity-30"}`,children:l.length>0?`${u.length}/${l.length} plans done`:"—"}),f.jsx(tg,{idea:a,compact:!0}),f.jsx(Nu,{idea:a,otherPlans:t})]})]})})})]}),l.length>0&&f.jsxs("div",{className:"ml-5 pl-3 border-l-2 border-black/[8%] flex flex-col gap-1",children:[f.jsx(DS,{plans:h,activePlanTitle:n,onOpen:r,showHeader:!1}),d&&f.jsx("button",{type:"button",onClick:o,className:"self-start bg-none bg-transparent border-none py-1 px-0 opacity-60 cursor-pointer underline text-xs [font:inherit]",children:i?"Show less":`+${u.length} done`})]})]})},aW=({plans:e,rows:t,activePlanTitle:n,onOpenPlan:r,onOpenIdea:s})=>{const i=_.useRef(null);return _.useEffect(()=>{var a;if(!n)return;const o=(a=i.current)==null?void 0:a.querySelector(".plan-row-highlighted");o==null||o.scrollIntoView({behavior:"smooth",block:"center"})},[n]),f.jsx("div",{ref:i,children:t.length>0?f.jsx(sW,{rows:t,plans:e,activePlanTitle:n,onOpenPlan:r,onOpenIdea:s}):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."})})},lW=({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(Jr,{id:e.id??void 0}),e.title,e.status&&f.jsx(Ae,{size:"small",fillColor:Hc[e.status].fill,textColor:Hc[e.status].text,children:IS[e.status]})]}),f.jsx(ek,{children:e.body.replace(/^#{1,3}\s+.+(\n|$)/,"").replace(/^\s*-{3,}\s*(\n|$)/,"").trim()}),f.jsx("div",{className:"mt-6",children:f.jsx(tg,{idea:e})})]}),lf="__no-subject__",ss="font-handwritten text-xs font-semibold leading-none text-ink-300 mb-2",cW=()=>{const e=F(P=>P.plans),t=Xm(),n=F(gm),r=F(P=>P.agentStatus),{patch:s,updating:i}=Ea(),{subjects:o,available:a}=CS(),l=F(P=>P.detailView),u=F(P=>P.setDetailView),c=t?e==null?void 0:e.entries.find(P=>P.title===t):null,[d,h]=_.useState("");if(_.useEffect(()=>{h((c==null?void 0:c.order)!==void 0?String(c==null?void 0:c.order):"")},[c==null?void 0:c.order]),!c)return null;const p=hm(c,r),m=c.status==="in-progress",y=c.status==="review",w=c.status==="dropped",g=c.phases.some(P=>!P.done),x=(c.status==="planned"||m)&&g,v=!!(c.pr&&(c.pr.state==="open"||c.pr.state==="draft")&&c.pr.unresolvedThreadCount),k=a&&c.subject&&!o.includes(c.subject)?c.subject:void 0,S=P=>s(c.title,P),b=m||y||c.status==="planned",j=async()=>{const P=d.trim(),T=Number(P);if(P===""||!Number.isInteger(T)||T<1){h(c.order!==void 0?String(c.order):"");return}T!==c.order&&await S({order:T})};return f.jsx("div",{className:"-mt-5",children:f.jsx(Ee,{surface:"paper",texture:"speckle",size:"small",children:f.jsxs("div",{className:"flex flex-col gap-5",children:[f.jsx("h2",{className:"m-0 font-display-luminari text-base text-ink-900",children:"Plan"}),f.jsxs("div",{children:[f.jsx("div",{className:ss,children:"Show"}),f.jsxs("div",{className:"flex flex-col gap-1",children:[f.jsx(li,{size:"small",active:l==="details",onClick:()=>u("details"),children:"Details"}),f.jsx(li,{size:"small",active:l==="feedback",onClick:()=>u("feedback"),children:"Feedback"})]})]}),f.jsxs("div",{children:[f.jsx("div",{className:ss,children:"Status"}),f.jsx(Ae,{size:"small",fillColor:er[p].fill,textColor:er[p].text,children:eg[p]})]}),f.jsxs("div",{children:[f.jsx("div",{className:ss,children:"Subject"}),f.jsx(qh,{size:"small",value:c.subject??lf,onChange:P=>S({subject:P===lf?null:P}),disabled:i||!a,options:[{value:lf,label:"No subject"},...k?[{value:k,label:`${k} (orphan)`}]:[],...!a&&c.subject&&!k?[{value:c.subject,label:c.subject}]:[],...o.map(P=>({value:P,label:P}))]})]}),b&&f.jsxs("div",{children:[f.jsx("div",{className:ss,children:"Order"}),f.jsx(Pa,{type:"number",size:"small","aria-label":"Run order",min:1,value:d,onChange:P=>h(P.target.value),onBlur:j,disabled:i})]}),f.jsxs("div",{children:[f.jsx("div",{className:ss,children:"Agent"}),f.jsx(qh,{size:"small",value:c.agent??"",onChange:P=>S({agent:P||null}),disabled:i,options:[{value:"",label:"Project default agent"},...uM.map(P=>({value:P,label:ck[P]}))]})]}),c.tags.length>0&&f.jsxs("div",{children:[f.jsx("div",{className:ss,children:"Tags"}),f.jsx("div",{className:"flex items-center gap-1 flex-wrap",children:c.tags.map(P=>f.jsx(Ae,{size:"small",fillColor:"rgba(0,0,0,0.06)",children:P},P))})]}),f.jsxs("div",{children:[f.jsx("div",{className:ss,children:"Actions"}),f.jsxs("div",{className:"flex flex-col gap-1",children:[x&&f.jsx($U,{plan:c,disabled:n||i}),v&&f.jsx(DU,{plan:c,disabled:n||i}),y&&f.jsx(li,{size:"small",icon:f.jsx("span",{className:"text-watercolor-green-dark",children:"✓"}),onClick:()=>S({status:"done"}),disabled:i,className:i?"opacity-50":void 0,children:"Approve & close"}),f.jsx(li,{size:"small",icon:f.jsx("span",{className:w?"text-watercolor-green-dark":"text-watercolor-rose-dark",children:w?"↺":"⊘"}),onClick:()=>S({status:w?null:"dropped"}),disabled:i,className:i?"opacity-50":void 0,children:w?"Reopen plan":"Mark dropped"})]})]})]})})})},jv=8,uW=["in-progress","review","planned","idea","done","dropped"],dW={...eg,idea:"Backlog"},Ev="text-2xs font-semibold tracking-[0.08em] uppercase text-ink-300 mb-2",fW=()=>{const e=F(v=>v.plans),t=Xm(),n=F(v=>v.planFilters),r=F(v=>v.togglePlanStatus),s=F(v=>v.togglePlanTag),i=F(v=>v.setPlanSearch),o=F(v=>v.setSubjectFilter),a=Zt(),[l,u]=_.useState(!1);if(!e||t)return null;const{statusCounts:c,tagCounts:d}=Bl(e.entries,n),h=new Set(n.statuses),p=new Set(n.tags),y=[...new Set([...Object.keys(d),...n.tags])].sort((v,k)=>{const S=(d[k]??0)-(d[v]??0);return S!==0?S:v.localeCompare(k)}),w=l?y:y.slice(0,jv),g=y.length-w.length,x="bg-none bg-transparent border-none p-0 cursor-pointer opacity-70 underline text-2xs";return f.jsx("div",{className:"-mt-5",children:f.jsx(Ee,{surface:"paper",texture:"speckle",size:"small",children:f.jsxs("div",{className:"flex flex-col gap-5",children:[f.jsx("h2",{className:"m-0 font-display-luminari text-base text-ink-900",children:"Filters"}),f.jsx(Pa,{type:"search",size:"small",placeholder:"Search plans…","aria-label":"Search plans",value:n.search,onChange:v=>i(v.target.value)}),n.subject!==null&&f.jsxs("div",{className:"flex items-center gap-2","data-testid":"subject-filter-chip",children:[f.jsxs("span",{className:"text-2xs opacity-70",children:["Subject: ",n.subject]}),f.jsx("button",{type:"button",onClick:()=>{o(null),a({to:"/",search:{}})},className:x,children:"Clear"})]}),f.jsxs("div",{children:[f.jsx("div",{className:Ev,children:"Status"}),f.jsx("div",{className:"flex flex-col gap-1",children:uW.map(v=>{const k=h.has(v);return f.jsxs("button",{type:"button",onClick:()=>r(v),"aria-pressed":k,className:`flex items-center gap-2 w-full px-2 py-1 rounded-md border-none cursor-pointer text-left ${k?"bg-black/[5%] opacity-100":"bg-transparent opacity-50"}`,children:[f.jsx("span",{className:"w-[9px] h-[9px] rounded-full shrink-0",style:{background:er[v].text}}),f.jsx("span",{className:"flex-1 text-xs text-ink-900",children:dW[v]}),f.jsx("span",{className:"text-2xs text-ink-500",children:c[v]})]},v)})})]}),f.jsxs("div",{children:[f.jsx("div",{className:Ev,children:"Tags"}),f.jsxs("div",{className:"flex flex-wrap gap-1 items-center",children:[y.length===0&&f.jsx("span",{className:"opacity-50 text-2xs",children:"No tags"}),w.map(v=>{const k=p.has(v);return f.jsxs("button",{type:"button",onClick:()=>s(v),"aria-pressed":k,className:`text-2xs px-2 py-[2px] rounded-md border-[0.5px] border-black/[12%] cursor-pointer ${k?"bg-black/[8%] opacity-100":"bg-transparent opacity-55"}`,children:[v," ",d[v]??0]},v)}),g>0&&f.jsxs("button",{type:"button",onClick:()=>u(!0),className:x,children:["+",g," more"]}),l&&y.length>jv&&f.jsx("button",{type:"button",onClick:()=>u(!1),className:x,children:"Show less"})]})]})]})})})},Tv=()=>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"}),f.jsx(LS,{}),f.jsx(FU,{}),f.jsx(AU,{}),f.jsx(VU,{})]}),hW=[{key:"a",title:"72%"},{key:"b",title:"54%"},{key:"c",title:"83%"},{key:"d",title:"46%"},{key:"e",title:"66%"},{key:"f",title:"58%"}],pW=()=>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(Ee,{size:"small",texture:"kraft",className:"plan-row-card",children:f.jsxs("div",{className:Yh,children:[f.jsx(on,{variant:"text",width:28}),f.jsx(on,{variant:"text",width:44}),f.jsx("span",{className:"max-lg:hidden",children:f.jsx(on,{variant:"text",width:56})}),f.jsx(on,{variant:"text",width:64}),f.jsx(on,{variant:"text",width:48})]})})})]}),hW.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(on,{variant:"text",width:16})}),f.jsx("div",{className:"flex-1 min-w-0",children:f.jsx(Ee,{size:"small",className:"plan-row-card",children:f.jsxs("div",{className:Yh,children:[f.jsx(on,{variant:"rect",width:44,height:18}),f.jsx(on,{variant:"text",width:e.title}),f.jsx("span",{className:"max-lg:hidden",children:f.jsx(on,{variant:"text",width:52})}),f.jsx(on,{variant:"rect",width:80,height:8}),f.jsx(on,{variant:"rect",width:64,height:20})]})})})]},e.key))]}),mW=()=>{const e=F(c=>c.reconcileQueue),t=F(c=>c.removeFromReconcileQueue),n=F(c=>c.plans),{patch:r}=Ea(),{toast:s}=Ge(),i=_.useRef(0),o=e[0]??null,a=o?(n==null?void 0:n.entries.find(c=>c.id===o.planId))??null:null;if(_.useEffect(()=>{o&&!a&&t(o.previewId)},[o,a,t]),_.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.`})},u=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(PU,{plan:a,before:o.before,onApprove:l,onDiscard:u,queuePosition:{index:i.current+1,total:i.current+e.length}})},gW=({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(Ee,{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(Qm,{}),f.jsx("span",{className:"font-semibold overflow-hidden text-ellipsis whitespace-nowrap",children:r.title})]}),f.jsx(ut,{icon:f.jsx("span",{children:"×"}),variant:"ghost",size:"small",label:"Dismiss",className:"w-[28px] h-[28px]",onClick:()=>n(r)})]})})},`${r.date}-${r.title}`))})]}),rg=()=>{const e=F(b=>b.plans),t=F(b=>b.plansError),n=F(b=>b.ideaEntries),r=F(b=>b.suggestions);F(b=>b.loadPlans);const s=F(b=>b.setDetailView),i=F(b=>b.planFilters),o=F(b=>b.setSubjectFilter),a=Xm(),l=nU(),u=F(b=>b.dismissSuggestion),c=Zt(),{toast:d}=Ge(),{subject:h}=Qp({strict:!1});_.useEffect(()=>{o(h??null)},[h,o]),_.useEffect(()=>{s("details")},[a,l,s]);const p=()=>{c({to:"/"})},m=b=>{c({to:"/plans/$planId",params:{planId:encodeURIComponent(b)}})},y=b=>{c({to:"/ideas/$ideaId",params:{ideaId:encodeURIComponent(b)}})},[w,g]=_.useState(null),x=async b=>{try{await u(b)}catch(j){d({title:"Failed to dismiss suggestion",description:j.message,variant:"error"})}},v=a?e==null?void 0:e.entries.find(b=>b.title===a):null,k=l?n.find(b=>b.title===l):null;if(t)return f.jsxs("div",{children:[f.jsx(cU,{children:"Plans"}),f.jsxs(Ee,{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 f.jsxs("div",{children:[f.jsx(Tv,{}),f.jsx("output",{"aria-live":"polite",className:"sr-only",children:"Loading plans…"}),f.jsx(pW,{})]});const{rows:S}=yM(e.entries,n,i);return f.jsxs(f.Fragment,{children:[f.jsx(mW,{}),v?f.jsxs("div",{children:[f.jsx("div",{className:"mb-4",children:f.jsx(yv,{items:[{id:"plans",label:"Plans",onClick:p},{id:"plan",label:v.title}]})}),f.jsx(ZU,{plan:v})]}):k?f.jsxs("div",{children:[f.jsx("div",{className:"mb-4",children:f.jsx(yv,{items:[{id:"plans",label:"Plans",onClick:p},{id:"idea",label:k.title}]})}),f.jsx(lW,{idea:k})]}):f.jsxs("div",{children:[f.jsx(Tv,{}),e.warnings.length>0&&f.jsxs(Ee,{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(b=>f.jsxs("li",{children:[b.title,": ",b.message]},b.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(aW,{plans:e.entries,rows:S,activePlanTitle:a,onOpenPlan:m,onOpenIdea:y}),f.jsx(jU,{}),f.jsx(gW,{suggestions:r,onOpen:g,onDismiss:x}),f.jsx(CU,{suggestion:w,onClose:()=>g(null)})]})]})},BS=_.lazy(()=>Kr(()=>import("./index-BHrFKlRC.js"),__vite__mapDeps([0,1])).then(e=>({default:e.DocsPage}))),yW=_.lazy(()=>Kr(()=>import("./index-BHrFKlRC.js"),__vite__mapDeps([0,1])).then(e=>({default:e.DocsSidebar}))),$S=_.lazy(()=>Kr(()=>import("./index-CVlBKMF5.js"),__vite__mapDeps([2,3,1])).then(e=>({default:e.SettingsPage}))),xW=_.lazy(()=>Kr(()=>import("./index-CVlBKMF5.js"),__vite__mapDeps([2,3,1])).then(e=>({default:e.SettingsSidebar}))),vW=_.lazy(()=>Kr(()=>import("./index-DuSUXl7P.js"),__vite__mapDeps([4,3])).then(e=>({default:e.TasksPage}))),wW=_.lazy(()=>Kr(()=>import("./index-Q6C6X2L9.js"),[]).then(e=>({default:e.RoadmapPage}))),bW=_.lazy(()=>Kr(()=>import("./index-DmvGoONp.js"),[]).then(e=>({default:e.DiffPage}))),kW=_.lazy(()=>Kr(()=>import("./index-BYaEopge.js"),__vite__mapDeps([5,3])).then(e=>({default:e.StatsPage}))),cf=[{id:"plans",label:"Plans",path:"/"},{id:"roadmap",label:"Roadmap",path:"/roadmap"},{id:"docs",label:"Docs",path:"/docs"},{id:"tasks",label:"Tasks",path:"/tasks"},{id:"stats",label:"Stats",path:"/stats"},{id:"settings",label:"Settings",path:"/settings"}],Rv=()=>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"})}),VS="stack-open";function _W(){try{return localStorage.getItem(VS)==="true"}catch{return!1}}function SW(e){try{localStorage.setItem(VS,String(e))}catch{}}const CW="(min-width: 1440px)";function PW(e){const[t,n]=_.useState(()=>typeof window<"u"?window.matchMedia(e).matches:!1);return _.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 jW=()=>{var S;const e=Zt(),t=bT({select:b=>b.location.pathname}),n=F(b=>b.loadPlans),r=F(b=>b.loadIdeas),s=F(b=>b.loadSuggestions),i=F(b=>b.loadCapabilities),o=F(b=>b.loadAgentAuthStatus),a=F(b=>b.setActiveDocTitle),l=t==="/"||t.startsWith("/plans/")||t.startsWith("/ideas/"),u=t==="/docs"||t.startsWith("/docs/"),c=t==="/settings"||t.startsWith("/settings/"),d=l?"plans":u?"docs":c?"settings":(S=cf.find(b=>b.path===t))==null?void 0:S.id,h=l||u||c,p=l?"plans":u?"docs":"settings",[m,y]=_.useState(_W),[w,g]=_.useState(!1),x=_u(),v=PW(CW),k=_.useRef(!1);return _.useEffect(()=>{n(),r(),s(),i(),o()},[n,r,s,i,o]),_.useEffect(()=>{k.current||t!=="/"||(k.current=!0,Promise.all([rk(),nk()]).then(([b,j])=>{if(!(b!=null&&b.setupDismissed)&&j!==null&&!j.every(P=>P.status==="ok")){e({to:"/settings/$section",params:{section:"setup"}});return}Promise.all([sk(),ok()]).then(([P,T])=>{P.entries.length>1||T.entries.length>0||(a("USAGE.md"),e({to:"/docs"}))})}))},[t,e,a]),_.useEffect(()=>{g(!1)},[t]),f.jsxs(i8,{position:"bottom-left",children:[f.jsxs("div",{className:"h-screen box-border min-[1440px]:pr-[480px] flex flex-col",children:[f.jsx(oU,{}),f.jsx(lU,{}),f.jsx(ZB,{style:{flex:"1 1 0%",minHeight:0,height:"auto"},background:{texture:"speckle",ruledType:"grid",ruledColor:"blue"},showHeader:!0,showSidebar:!1,showPage:!1,bleedBottom:!0,headerActions:f.jsxs(f.Fragment,{children:[h&&f.jsx(ut,{variant:"ghost",size:"small",className:"lg:hidden max-[480px]:hidden",label:"Open sidebar",onClick:()=>g(!0),icon:f.jsx(Rv,{})}),f.jsx(iU,{size:"sm"}),f.jsx("div",{className:"flex-1"}),f.jsx("nav",{"aria-label":"Main navigation",className:"flex items-center gap-1 max-[480px]:hidden",children:cf.map(b=>f.jsx(ne,{variant:"ghost",size:"small",isActive:b.id===d,onClick:()=>e({to:b.path}),"aria-current":b.id===d?"page":void 0,children:b.label},b.id))})]}),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 -mt-8 -ml-8 -mr-8 pt-0 pl-8 pr-8 pb-[var(--pc-content-pad-bottom,32px)]",children:f.jsxs("div",{className:"flex min-w-0 justify-center lg:[--pc-sidebar-h:calc(100vh-160px)] gap-6 w-full",children:[h&&f.jsxs(aU,{routeKey:p,mobileOpen:w,onMobileClose:()=>g(!1),children:[l&&f.jsxs(f.Fragment,{children:[f.jsx(fW,{}),f.jsx(cW,{})]}),u&&f.jsx(_.Suspense,{fallback:null,children:f.jsx(yW,{})}),c&&f.jsx(_.Suspense,{fallback:null,children:f.jsx(xW,{})})]}),f.jsx("div",{className:`flex flex-col min-w-0 ${v?"flex-[1_1_0%]":"flex-[0_1_800px]"}`,children:f.jsx(Ni.div,{...jS(x),transition:PS(x),className:"flex flex-col flex-1 min-w-0",children:f.jsx(mS,{texture:{texture:"parchment"},outline:!0,className:`min-h-[calc(100vh-160px)] w-full ${v?"max-w-none":""}`,children:f.jsx(_.Suspense,{fallback:null,children:f.jsx(yb,{})})})},t)})]})})})})]}),f.jsx(X8,{open:m,pinned:v,onToggle:()=>{const b=!m;SW(b),y(b)}}),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:[h&&f.jsx(ut,{variant:"ghost",size:"small",label:"Open sidebar",onClick:()=>g(!0),icon:f.jsx(Rv,{}),className:"min-h-11"}),cf.map(b=>f.jsx(ne,{variant:"ghost",size:"small",isActive:b.id===d,onClick:()=>e({to:b.path}),"aria-current":b.id===d?"page":void 0,className:"min-h-11",children:b.label},b.id))]})]})},en=oT({component:jW}),EW=gn({getParentRoute:()=>en,path:"/",component:rg,validateSearch:e=>({subject:typeof e.subject=="string"?e.subject:void 0})}),TW=gn({getParentRoute:()=>en,path:"/plans/$planId",component:rg}),RW=gn({getParentRoute:()=>en,path:"/ideas/$ideaId",component:rg}),NW=gn({getParentRoute:()=>en,path:"/docs",component:BS}),IW=gn({getParentRoute:()=>en,path:"/docs/$section",component:BS}),AW=gn({getParentRoute:()=>en,path:"/settings",component:$S}),MW=gn({getParentRoute:()=>en,path:"/settings/$section",component:$S}),LW=gn({getParentRoute:()=>en,path:"/roadmap",component:wW,validateSearch:e=>({item:typeof e.item=="string"?e.item:void 0})}),DW=gn({getParentRoute:()=>en,path:"/diff",component:bW}),FW=gn({getParentRoute:()=>en,path:"/stats",component:kW}),OW=gn({getParentRoute:()=>en,path:"/tasks",component:vW,validateSearch:e=>({taskId:typeof e.taskId=="string"?e.taskId:void 0})}),zW=en.addChildren([EW,TW,RW,NW,IW,AW,MW,OW,LW,DW,FW]),BW=yT({routeTree:zW}),US=document.getElementById("root");if(!US)throw new Error("#root element not found");Uw(US).render(f.jsx(_.StrictMode,{children:f.jsx(wT,{router:BW})}));export{qW as A,HW as B,ja as C,YW as D,r9 as E,Qe as F,qA as G,KW as H,GW as I,ne as J,AS as K,eg as L,ek as M,eW as N,QW as O,cU as P,yV as Q,lM as R,er as S,Ae as U,e9 as V,Zt as a,n9 as b,rk as c,EU as d,VW as e,$W as f,Ie as g,CS as h,li as i,f as j,Ge as k,xS as l,t9 as m,Z8 as n,Pa as o,gv as p,WW as q,_ as r,UW as s,qh as t,F as u,uM as v,Ee as w,ck as x,yv as y,Qp as z};
207
- //# sourceMappingURL=main-CTwMgTvE.js.map
206
+ ${i.trim()}`:""}`;if(R){w(!0),k(null),x(null);try{const z=S.map(B=>({id:B.id,title:B.title,body:B.body,tags:B.tags}));x(await ik(R,z))}catch(z){k(z.message)}finally{w(!1)}}},M=R=>{const z=S.find(B=>B.id===R);z?E(z.title):P({title:"Plan not found",description:`No plan with id ${R}`,variant:"error"})},O=async(R,z,B)=>{m(R);const $={date:new Date().toISOString().slice(0,10),text:r.trim()},C=await b(z,{log:[...B??[],$]},{errorTitle:"Extend failed"});m(null),C&&t()},A=async R=>{if(R.preventDefault(),!(!r.trim()||u)){h(null),c(!0);try{await n({title:r.trim(),content:i.trim()||void 0,kind:a}),t()}catch(z){h(z.message)}finally{c(!1)}}};return f.jsx(ja,{open:e,onClose:t,title:"Quick plan",size:"small",children:f.jsxs("form",{onSubmit:A,className:"flex flex-col gap-4",children:[f.jsx(Pa,{label:"Title",value:r,onChange:R=>s(R.target.value),placeholder:"Backlog item title…",disabled:u,autoFocus:!0,required:!0}),T.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"}),T.map(({candidate:R})=>{const z={id:R.id??null,title:R.title,body:R.body,log:R.log},B=S.filter(L=>L.id!==R.id);return f.jsx(Ee,{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(Jr,{id:R.id}),f.jsx("span",{className:"overflow-hidden text-ellipsis whitespace-nowrap",children:R.title})]}),f.jsxs("div",{className:"flex justify-end gap-2",children:[f.jsx(ne,{type:"button",variant:"ghost",size:"small",onClick:()=>E(R.title),children:"Open it"}),f.jsx(ne,{type:"button",variant:"ghost",size:"small",disabled:!R.id||!r.trim()||p!==null,onClick:()=>R.id&&O(R.id,R.title,R.log),children:p===R.id?"Extending…":"Extend it instead"}),f.jsx(Nu,{idea:z,otherPlans:B})]})]})},R.id??R.title)})]}),f.jsxs("div",{className:"flex flex-col gap-2",children:[f.jsx("div",{children:f.jsx(ne,{type:"button",variant:"ghost",size:"small",disabled:!r.trim()||y,onClick:I,children:y?"Checking overlap…":"Check overlap"})}),v&&f.jsx("p",{className:"m-0 text-watercolor-rose-dark text-sm",children:v}),g&&f.jsx(Ee,{size:"small",texture:"canvas",children:f.jsxs("div",{className:"flex flex-col gap-2",children:[f.jsx("span",{className:"font-semibold",children:g.verdict==="new"?"Looks genuinely new":g.verdict==="extend"?`Extends ${g.targetId??"an existing idea"}`:`Belongs inside ${g.targetId??"an existing idea"}`}),f.jsx("span",{className:"text-sm opacity-80",children:g.reasoning}),g.targetId&&f.jsx("div",{className:"flex justify-end",children:f.jsx(ne,{type:"button",variant:"ghost",size:"small",onClick:()=>M(g.targetId),children:"Open it"})})]})})]}),f.jsx(qh,{label:"Kind",value:a,onChange:R=>l(R),options:RU,disabled:u}),f.jsx(Eu,{label:"Description",value:i,onChange:R=>o(R.target.value),placeholder:"Optional details…",disabled:u,rows:4}),d&&f.jsx("p",{className:"m-0 text-watercolor-rose-dark text-sm",children:d}),f.jsxs("div",{className:"flex justify-end gap-2",children:[f.jsx(ne,{type:"button",variant:"ghost",onClick:t,disabled:u,children:"Cancel"}),f.jsx(ne,{type:"submit",variant:"primary",disabled:!r.trim()||u,children:"Add"})]})]})})},IU=()=>f.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[f.jsx("path",{d:"M10 6h10M10 12h10M10 18h10"}),f.jsx("path",{d:"M3 6l1.5 1.5L7 5M3 12l1.5 1.5L7 11M3 18l1.5 1.5L7 17"})]}),AU=()=>{const e=F(o=>o.loadPlans),t=F(o=>o.gitBranchHygiene),[n,r]=_.useState(!1),s=t==="stale-merged",i=async o=>{await tM(o),await e(),r(!1)};return f.jsxs(f.Fragment,{children:[f.jsx(Ie,{content:s?"Switch to main first":void 0,children:f.jsx(ut,{icon:f.jsx(IU,{}),variant:"ghost",size:"small",label:s?"Switch to main first":"Quick plan",disabled:s,onClick:()=>r(!0)})}),f.jsx(NU,{open:n,onClose:()=>r(!1),onAdd:i})]})},MU=({planId:e,phaseIndex:t,disabled:n})=>{const r=F(c=>c.launchAgent),s=F(Qr),{toast:i}=Ge(),[o,a]=_.useState(!1),l=async c=>{if(c.stopPropagation(),!!e){a(!0);try{await r(e,t)}catch(d){i({title:"Failed to start agent",description:Qe(d.message),variant:"error"})}finally{a(!1)}}},u=e?s?"Start agent on this phase":"No agent CLI found — set up in Settings":"Plan needs an ID before an agent can run";return f.jsx(ut,{icon:f.jsx("span",{className:"text-xs leading-none",children:"▶"}),variant:"ghost",size:"small",label:u,onClick:l,disabled:n||o||!e||!s,className:"transition-opacity text-ink-500"})},LU=({plan:e,disabled:t})=>{const n=F(l=>l.launchPlanAudit),r=F(Qr),[s,i]=_.useState(!1),o=async()=>{if(e.id){i(!0);try{await n(e.id,hU(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(Ie,{content:a,children:f.jsx(ne,{variant:"ghost",size:"small",onClick:o,disabled:t||s||!e.id||!r,children:"Audit"})})},tg=({idea:e,compact:t})=>{const n=F(h=>h.launchIdeaExtend),r=F(Qr),{state:s,errorMessage:i,run:o}=ES(),{toast:a}=Ge(),l=e.id,u=()=>{l&&o(async()=>{const h=F.getState().ideaEntries.find(p=>p.id===l);if(!h)throw new Error(`Idea ${l} not found`);try{await n(l,mU(h))}catch(p){throw a({title:"Extension failed",description:Qe(p.message),variant:"error"}),p}})},c=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(Ie,{content:d,children:f.jsx(ne,{variant:"ghost",size:"small",onClick:u,disabled:s==="loading"||!l||!r,className:s==="error"?"text-watercolor-rose-dark":void 0,children:c})})},DU=({plan:e,disabled:t})=>{const n=F(c=>c.launchFixReview),r=F(Qr),s=F($M),[i,o]=_.useState(!1),a=async()=>{if(e.id){o(!0);try{await n(e.id)}catch(c){alert(c.message)}finally{o(!1)}}},l=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";return f.jsx(Ie,{content:u,children:f.jsx(li,{size:"small",icon:f.jsx("span",{className:"text-watercolor-amber-dark",children:"⚑"}),onClick:a,disabled:l,className:l?"opacity-50":void 0,children:i?"Starting…":"Fix review comments"})})},FU=()=>{const e=F(s=>s.loadIdeas),[t,n]=_.useState(!1),r=async s=>{await ZA(s),await e(),n(!1)};return f.jsxs(f.Fragment,{children:[f.jsx(ut,{icon:f.jsx(K4,{size:16}),variant:"ghost",size:"small",label:"New idea",onClick:()=>n(!0)}),f.jsx(SU,{open:t,onClose:()=>n(!1),onAdd:r})]})};async function OU(e){var r;if((r=navigator.clipboard)!=null&&r.writeText)try{return await navigator.clipboard.writeText(e),!0}catch{}const t=document.createElement("textarea");t.value=e,t.style.position="fixed",t.style.opacity="0",document.body.appendChild(t),t.focus(),t.select();let n=!1;try{n=document.execCommand("copy")}catch{n=!1}return document.body.removeChild(t),n}const zU=({planTitle:e,planId:t,phaseIndex:n})=>{const[r,s]=_.useState("idle"),i=async o=>{o.stopPropagation();const a=`Start phase ${n+1} of plan "${e}" in papercamp/ideas/${t??"<ID>"}.md`,l=await OU(a);s(l?"copied":"failed"),setTimeout(()=>s("idle"),1500)};return f.jsx(ut,{icon:r==="copied"?f.jsx(gS,{size:16}):r==="failed"?f.jsx(Ca,{size:16}):f.jsx(q4,{size:16}),variant:"ghost",size:"small",label:r==="copied"?"Copied":r==="failed"?"Copy failed — select and copy manually":"Copy phase prompt",onClick:i,className:`transition-opacity ${r==="copied"?"text-state-success":r==="failed"?"text-state-danger":"text-ink-500"}`})},BU=({plan:e,disabled:t})=>{const n=F(l=>l.launchPlanReconcile),r=F(Qr),[s,i]=_.useState(!1),o=async()=>{if(e.id){i(!0);try{await n(e.id,pU(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(Ie,{content:a,children:f.jsx(ne,{variant:"ghost",size:"small",onClick:o,disabled:t||s||!e.id||!r,children:"Refresh"})})},LS=()=>{const e=F(s=>s.refreshAll),t=F(s=>s.refreshing),{toast:n}=Ge(),r=async()=>{if(t)return;const s=await e();s.ok?n({title:"Up to date",description:"Plans, ideas, checks and PR review state re-read.",variant:"success"}):n({title:"Couldn't refresh",description:s.error??"The read failed — is the dev server running?",variant:"error"})};return f.jsx(ut,{icon:f.jsx("span",{className:`inline-flex${t?" animate-pc-spin motion-reduce:animate-none":""}`,children:f.jsx(F8,{size:16})}),label:t?"Refreshing…":"Refresh data",size:"small",variant:"ghost",disabled:t,onClick:r})},$U=({plan:e,disabled:t})=>{const n=F(u=>u.launchRunAll),r=F(Qr),[s,i]=_.useState(!1),o=async()=>{if(e.id){i(!0);try{await n(e.id)}catch(u){alert(u.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(Ie,{content:l,children:f.jsx(li,{size:"small",icon:f.jsx("span",{className:"text-ink-500",children:"▶"}),onClick:o,disabled:a,className:a?"opacity-50":void 0,children:s?"Starting…":"Run all phases"})})},VU=()=>{const e=F(y=>y.launchSuggestIdeas),t=F(y=>y.launchBatchReconcile),n=F(y=>y.launchPrioritise),r=F(y=>y.ideaEntries),s=F(y=>y.suggestions),i=F(gm),o=F(Qr),{toast:a}=Ge(),[l,u]=_.useState(null),c=async()=>{u("suggest");try{await e(xU(r,s))}catch(y){a({title:"Failed to launch",description:Qe(y.message),variant:"error"})}finally{u(null)}},d=async()=>{u("actualise");try{await t()}catch(y){a({title:"Failed to launch",description:Qe(y.message),variant:"error"})}finally{u(null)}},h=async()=>{u("prioritise");try{const y=await n();a({title:y.moved.length>0?"Queue reordered":"Already in order",description:y.why||void 0,variant:"success"})}catch(y){a({title:"Failed to prioritise",description:Qe(y.message),variant:"error"})}finally{u(null)}},p=l!==null||i,m=[{id:"suggest-ideas",label:l==="suggest"?"Starting…":"Suggest ideas",icon:f.jsx(bS,{size:16}),disabled:p||!o,onSelect:c},{id:"actualise-all",label:l==="actualise"?"Starting…":"Actualise all",icon:f.jsx(gS,{size:16}),disabled:p||!o,onSelect:d},{id:"prioritise",label:l==="prioritise"?"Prioritising…":"Prioritise queue",icon:f.jsx(z8,{size:16}),disabled:p||!o,onSelect:h}];return f.jsx(E8,{align:"end",trigger:f.jsx(ut,{icon:f.jsx(O8,{size:16}),label:"More actions",size:"small",variant:"ghost"}),items:m})};function UU(e){const t=e==null?void 0:e.match(/^[a-z]+\/([a-z]+-\d+)-/);return t?t[1].toUpperCase():null}const Iu="font-display-luminari text-sm font-semibold opacity-[0.65]",WU=({plan:e,auditRunning:t,agentBusy:n,agentPhaseIndex:r,planTask:s,updating:i,onTogglePhase:o,onToggleFix:a,onAddReviewPhases:l})=>{const u=F(p=>p.launchRunAll),c=e.fixes??[],d=c.some(p=>!p.done),h=[...e.phases.map((p,m)=>({kind:"phase",item:p,index:m})),...c.map((p,m)=>({kind:"fix",item:p,index:m}))];return f.jsxs("div",{className:"mb-8",children:[f.jsxs("div",{className:"flex items-center justify-between gap-3 mb-3 flex-wrap",children:[f.jsx("h3",{className:`${Iu} m-0`,children:"Phases"}),f.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t&&f.jsx(Ii,{size:"small",label:"Audit running…"}),(e.status==="review"||e.status==="done")&&f.jsx(LU,{plan:e}),e.status!=="done"&&f.jsx(BU,{plan:e}),f.jsx(TU,{onAdd:l,disabled:i}),e.id&&d&&f.jsx(Ie,{content:"Run the open fixes with an agent",children:f.jsx(ne,{size:"small",onClick:()=>e.id&&u(e.id),disabled:n,children:n?"Running…":"Run fixes"})})]})]}),f.jsx(M$,{data:h,columns:[{key:"checkbox",header:"Status",cell:p=>f.jsx(f4,{checked:p.item.done,onChange:()=>p.kind==="phase"?o(p.index):a(p.index),disabled:i}),width:2},{key:"title",header:"Title",cell:p=>f.jsxs("span",{className:`inline-flex items-center gap-2 ${p.item.done?"line-through opacity-[0.45]":"no-underline"}`,children:[p.item.text,p.kind==="phase"&&p.item.source==="review"&&f.jsx(Ae,{size:"small",fillColor:er.review.fill,textColor:er.review.text,children:"review"}),p.kind==="fix"&&f.jsx(Ae,{size:"small",variant:"warning",children:"fix"})]})},{key:"actions",header:"Actions",align:"end",cell:p=>p.kind==="phase"?f.jsxs("div",{className:"inline-flex gap-2 items-center",children:[f.jsx(zU,{planTitle:e.title,planId:e.id,phaseIndex:p.index}),!p.item.done&&r===p.index?f.jsx(Ii,{size:"small",label:`Agent ${s==null?void 0:s.status}…`}):!p.item.done&&f.jsx(MU,{planId:e.id,phaseIndex:p.index,disabled:n})]}):null,width:7}],expandable:{render:p=>p.item.description||null},showExpandColumn:!1,rowTexture:p=>p.kind==="fix"?"kraft":void 0,rowClassName:p=>p.kind==="phase"&&p.item.source==="review"?"bg-[rgba(155,122,181,0.08)]":void 0,className:"phase-table-phone"})]})},HU=({plan:e,gitBranch:t,onOwnBranch:n,branching:r,onCreateBranch:s})=>{const i=e.status==="planned"||e.status==="in-progress"||e.status==="review";return!i&&!e.pr?null:f.jsxs("div",{className:"flex items-center gap-3 flex-wrap mb-4",children:[i&&!n&&f.jsx(Ee,{size:"small",accent:!0,accentColor:"amber",texture:"kraft",children:f.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[f.jsxs("span",{className:"text-sm",children:["Working branch: ",f.jsx("code",{children:t??"unknown"})," — not this plan's branch."]}),e.id&&f.jsx(Ie,{content:`Creates ${(e.kind??"feat").toLowerCase()}/${e.id.toLowerCase()}-… from main, or switches to it if it already exists`,children:f.jsx(ne,{size:"small",onClick:s,disabled:r,children:r?"Switching…":"Create branch"})})]})}),i&&n&&f.jsxs("span",{className:"text-sm opacity-[0.45]",children:["Working branch: ",f.jsx("code",{children:t})]}),e.pr&&f.jsx(AS,{pr:e.pr}),e.pr&&f.jsx(_U,{pr:e.pr})]})},GU=({progress:e,color:t})=>f.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[f.jsx("div",{className:"flex-1",children:f.jsx(MS,{pct:e.pct,color:t})}),f.jsxs("span",{className:"text-sm opacity-50 flex-shrink-0",children:[e.done,"/",e.total]})]}),KU=({plan:e})=>f.jsx("div",{className:"mb-4",children:f.jsx("div",{className:"opacity-[0.85]",children:e.body&&f.jsx(RS,{resetKey:e.id??e.title,children:f.jsx(ek,{children:e.body})})})}),qU=({clarifications:e})=>e.length===0?null:f.jsxs("div",{className:"mb-5",children:[f.jsx("h3",{className:`${Iu} 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}`))})]}),YU=({planId:e})=>{const t=fU(e);return t?f.jsxs("div",{className:"mb-8",children:[f.jsx("h3",{className:`${Iu} mb-3`,children:"History"}),f.jsx(kU,{trail:t})]}):null},QU={review:"review",note:"note",decision:"decision",question:"question",clarification:"clarification"},XU=({messages:e,undo:t,undoing:n,onUndo:r})=>f.jsx(f.Fragment,{children:e.map((s,i)=>{const o=QU[s.kind],a=s.from==="agent",l=i===e.length-1;return f.jsxs("div",{className:`flex flex-col gap-1 ${a?"items-start":"items-end"}`,children:[f.jsx("div",{className:"max-w-[85%]",children:f.jsx(Ee,{size:"small",surface:"paper",texture:a?"kraft":o?"canvas":"parchment",shade:a,accent:!a,accentColor:o?"rose":"blue",children:f.jsx(RS,{collapsedLines:3,resetKey:`${s.kind}-${s.date??""}-${i}`,children:s.text})})}),f.jsxs("div",{className:"flex items-center gap-2",children:[a&&f.jsx(Ae,{size:"small",fillColor:"rgba(0,0,0,0.06)",children:"agent"}),a&&l&&t&&f.jsx(Ie,{content:"Revert this run's plan edit",children:f.jsx(ne,{size:"small",variant:"ghost",onClick:r,disabled:n,children:n?"Undoing…":"Undo"})}),s.date&&f.jsx("span",{className:"text-sm font-semibold opacity-[0.45]",children:s.date}),o&&f.jsx(Ae,{size:"small",fillColor:"rgba(0,0,0,0.06)",children:o})]})]},`${s.kind}-${s.date??""}-${i}`)})}),JU=({plan:e,updating:t,onSend:n,undo:r,undoing:s,onUndo:i})=>{const[o,a]=_.useState(""),l=e.thread??[],u=async()=>{o.trim()&&await n(o.trim())&&a("")};return f.jsxs("div",{className:"mb-8",children:[f.jsx("h3",{className:`${Iu} mb-3`,children:"Feedback"}),f.jsxs(Ee,{size:"small",accent:!0,accentColor:"slate",texture:"kraft",children:[f.jsx("div",{className:"flex flex-col gap-3 mb-4",children:l.length>0?f.jsx(XU,{messages:l,undo:r,undoing:s,onUndo:i}):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(Eu,{value:o,onChange:c=>a(c.target.value),"aria-label":"Feedback message",placeholder:"Write a message…",rows:3,disabled:t}),f.jsxs("div",{className:"flex justify-end items-center gap-3",children:[f.jsx("span",{className:t?"visible":"invisible",children:f.jsx(Ii,{size:"small",label:"Agent replying…"})}),f.jsx(ne,{size:"small",onClick:u,disabled:t||!o.trim(),children:"Send"})]})]})]})]})},ZU=({plan:e})=>{const t=F(A=>A.plans),n=F(A=>A.gitBranch),r=F(A=>A.loadGitStatus),{toast:s}=Ge(),{patch:i,updating:o}=Ea(),[a,l]=_.useState(!1),u=F(A=>A.agentStatus),c=F(gm),d=F(A=>A.detailView),h=fm(e.id,u),p=h?h.phaseIndex:null,m=(h==null?void 0:h.taskKind)==="audit",y=iM(e),w=e.phases.length>0,g=d==="feedback",x={id:e.id??null,title:e.title,body:e.body,log:e.log},v=((t==null?void 0:t.entries)??[]).filter(A=>A.id!==e.id),k=e.id!==void 0&&UU(n)===e.id,S=async()=>{if(e.id){l(!0);try{const A=await AM(e.id);s({title:"Branch ready",description:`Now on ${A}`,variant:"success"}),await r()}catch(A){s({title:"Branch failed",description:Qe(A.message),variant:"error"})}finally{l(!1)}}},b=async A=>{const R=e.phases.map((B,L)=>L===A?{...B,done:!B.done}:B);R.every(B=>B.done)&&e.status==="in-progress"?await i(e.title,{phases:R,status:"review"}):await i(e.title,{phases:R})},j=async A=>{await i(e.title,{phases:[...e.phases,...A]})},P=async A=>{const R=(e.fixes??[]).map((B,L)=>L===A?{...B,done:!B.done}:B);R.every(B=>B.done)&&e.status==="in-progress"?await i(e.title,{fixes:R,status:"review"}):await i(e.title,{fixes:R})},{sending:T,send:E,undo:I,undoing:M,undoEdit:O}=uU(e);return f.jsxs("div",{children:[f.jsxs("div",{className:"flex items-baseline justify-between gap-3 mb-3 flex-wrap",children:[f.jsxs("h2",{className:`${EU} m-0 flex items-center gap-3 min-w-0 flex-wrap`,children:[f.jsx(Jr,{id:e.id}),e.title]}),f.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[f.jsx("span",{className:"text-sm opacity-[0.45] whitespace-nowrap",children:e.updated?`updated ${Tc(e.updated)}`:`created ${Tc(e.created)}`}),f.jsx(LS,{})]})]}),g?f.jsx(JU,{plan:e,updating:T,onSend:E,undo:I,undoing:M,onUndo:O}):f.jsxs(f.Fragment,{children:[f.jsx(HU,{plan:e,gitBranch:n,onOwnBranch:k,branching:a,onCreateBranch:S}),y!==null&&f.jsx(GU,{progress:y,color:NS[hm(e,u)]}),f.jsx(KU,{plan:e}),f.jsx(qU,{clarifications:e.clarifications??[]}),!w&&f.jsxs("div",{className:"flex items-center gap-3 mb-8",children:[f.jsx(Nu,{idea:x,otherPlans:v}),f.jsx(tg,{idea:x})]}),w&&f.jsx(WU,{plan:e,auditRunning:m,agentBusy:c,agentPhaseIndex:p,planTask:h,updating:o,onTogglePhase:b,onToggleFix:P,onAddReviewPhases:j}),f.jsx(YU,{planId:e.id})]})]})},eW=()=>{const[e,t]=_.useState(new Set);return _.useEffect(()=>{let n=!1;return qA().then(r=>{n||!r||t(new Set(r.horizons.flatMap(s=>s.items.map(i=>i.name))))}).catch(()=>{}),()=>{n=!0}},[]),e},go="text-sm font-semibold opacity-60 whitespace-nowrap overflow-hidden",ng=({order:e,done:t,running:n,status:r})=>f.jsx("span",{className:"flex-[0_0_36px] flex items-center justify-center",children:n?f.jsx(Ii,{size:"small",label:"Agent running"}):t?f.jsx("span",{"aria-label":"Done",className:"text-watercolor-green-dark text-sm",children:"✓"}):e!==void 0?f.jsx(Ae,{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(Qm,{size:14})}):null}),Yh="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",DS=({plans:e,activePlanTitle:t,onOpen:n,showHeader:r=!0})=>{const s=Yh,i=F(o=>o.agentStatus);return f.jsxs("div",{className:"flex flex-col gap-1",children:[r&&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(Ee,{size:"small",texture:"kraft",className:"plan-row-card",children:f.jsxs("div",{className:s,children:[f.jsx("span",{className:go,children:"Id"}),f.jsx("span",{className:go,children:"Title"}),f.jsx("span",{className:`max-lg:hidden ${go}`,children:"Updated"}),f.jsx("span",{className:go,children:"Progress"}),f.jsx("span",{className:go,children:"Status"})]})})})]}),e.map(o=>{var u;const a=lk(o),l=hm(o,i);return f.jsxs("div",{className:"flex items-center",children:[f.jsx(ng,{order:o.order,done:o.status==="done",status:o.status,running:!!fm(o.id,i)}),f.jsx("div",{role:n?"button":void 0,tabIndex:n?0:void 0,onClick:n?()=>n(o.title):void 0,onKeyDown:n?c=>{(c.key==="Enter"||c.key===" ")&&(c.preventDefault(),n(o.title))}:void 0,className:`${n?"cursor-pointer":""} rounded-[10px] flex-1 min-w-0 ${o.title===t?"plan-row-highlighted outline outline-2 outline-offset-[-2px] outline-[rgba(200,154,90,0.5)]":""}`,children:f.jsx(Ee,{size:"small",texture:"canvas",className:"plan-row-card",children:f.jsxs("div",{className:s,children:[f.jsx(Jr,{id:o.id}),f.jsx("span",{className:"font-semibold overflow-hidden text-ellipsis whitespace-nowrap",children:o.title}),f.jsx("span",{className:"max-lg:hidden text-sm opacity-[0.45] whitespace-nowrap",children:o.updated?Tc(o.updated):Tc(o.created)}),a?f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsx("div",{className:"flex-1 min-w-0",children:f.jsx(MS,{pct:a.pct,color:NS[l]})}),f.jsxs("span",{className:"text-sm opacity-50 shrink-0",children:[a.done,"/",a.total]})]}):f.jsx("span",{className:"text-sm opacity-30",children:"—"}),f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsx(Ae,{size:"small",fillColor:er[l].fill,textColor:er[l].text,children:eg[l]}),((u=o.pr)==null?void 0:u.state)==="merged"&&f.jsx(Ie,{content:`Merged in #${o.pr.number}`,children:f.jsx("span",{className:"inline-flex text-[#7B5E9E]",children:f.jsx(Ru,{size:14})})})]})]})})})]},o.title)})]})},tW=5,nW="text-sm font-semibold opacity-60 whitespace-nowrap overflow-hidden",FS="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",Cv="font-handwritten text-xs font-semibold opacity-55 leading-none pt-2 pr-1 pb-0 pl-1",Pv=`${nW} bg-none bg-transparent border-none p-0 cursor-pointer [font:inherit] text-inherit text-left`,rW=[{key:"id",label:"Id"},{key:"title",label:"Title"},{key:"updated",label:"Updated"},{key:"progress",label:"Progress"},{key:"status",label:"Status"}],OS="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",zS="overflow-hidden text-ellipsis whitespace-nowrap",sW=({rows:e,plans:t,activePlanTitle:n,onOpenPlan:r,onOpenIdea:s})=>{const[i,o]=_.useState(new Set),{subjects:a,loading:l,available:u}=CS(),c=eW(),d=Zt(),h=FS,p=F(b=>b.planFilters.sortKey),m=F(b=>b.planFilters.sortDirection),y=F(b=>b.setPlanSortKey),w=F(b=>b.togglePlanSortDirection),g=b=>{b===p?w():y(b)},x=b=>{o(j=>{const P=new Set(j);return P.has(b)?P.delete(b):P.add(b),P})},v=b=>b.type==="plan"?f.jsx(DS,{plans:[b.plan],activePlanTitle:n,onOpen:r,showHeader:!1},b.plan.title):b.type==="note"?f.jsx(iW,{row:b,onOpen:s},b.idea.title):f.jsx(oW,{row:b,plans:t,activePlanTitle:n,onOpenPlan:r,onOpenIdea:s,expanded:i.has(b.idea.title),onToggleExpanded:()=>x(b.idea.title)},b.idea.title),k=gM(e,l||!u?void 0:a),S=k.length>1;return f.jsxs("div",{className:"flex flex-col gap-1",children:[f.jsxs("div",{className:"flex items-center",children:[f.jsx("span",{role:"columnheader",className:"flex-[0_0_36px] flex justify-center","aria-sort":p==="order"?m==="asc"?"ascending":"descending":void 0,children:f.jsxs("button",{type:"button",className:Pv,"aria-label":"Sort by run order",onClick:()=>g("order"),children:["#",p==="order"&&(m==="asc"?"▲":"▼")]})}),f.jsx("div",{className:"flex-1 min-w-0",children:f.jsx(Ee,{size:"small",texture:"kraft",className:"plan-row-card",children:f.jsx("div",{className:h,children:rW.map(({key:b,label:j})=>{const P=b===p;return f.jsx("span",{role:"columnheader",className:b==="updated"?"max-lg:hidden":void 0,"aria-sort":P?m==="asc"?"ascending":"descending":void 0,children:f.jsxs("button",{type:"button",className:Pv,onClick:()=>g(b),children:[j,P&&(m==="asc"?" ▲":" ▼")]})},b)})})})})]}),S?k.map(b=>{const j=b.subject;return f.jsxs("div",{className:"flex flex-col gap-1",children:[f.jsx("div",{className:"flex items-baseline gap-2",children:j&&c.has(j)?f.jsx("button",{type:"button",className:`${Cv} bg-none bg-transparent border-none cursor-pointer text-left hover:underline`,title:"View in roadmap",onClick:()=>d({to:"/roadmap",search:{item:j}}),children:j}):f.jsx("div",{className:Cv,children:j??"No subject"})}),b.rows.map(P=>v(P))]},j??"__no-subject__")}):e.map(b=>v(b))]})},iW=({row:e,onOpen:t})=>{const n=e.idea,r=n.status??"open";return f.jsxs("div",{className:"flex items-center",children:[f.jsx(ng,{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(Ee,{size:"small",texture:"canvas",className:"plan-row-card",children:f.jsxs("div",{className:FS,children:[n.id?f.jsx(Jr,{id:n.id}):f.jsx("span",{}),f.jsxs("span",{className:`${OS} [cursor:inherit]`,children:[f.jsx(V8,{}),f.jsx("span",{className:zS,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(Ae,{size:"small",fillColor:Hc[r].fill,textColor:Hc[r].text,children:IS[r]})]})})})]})},oW=({row:e,plans:t,activePlanTitle:n,onOpenPlan:r,onOpenIdea:s,expanded:i,onToggleExpanded:o})=>{const a=e.idea,l=e.children,u=l.filter(p=>p.status==="done"),c=l.filter(p=>p.status!=="done"),d=l.length>tW,h=d&&!i?c:l;return f.jsxs("div",{className:"flex flex-col gap-1",children:[f.jsxs("div",{className:"flex items-center",children:[f.jsx(ng,{order:a.order,done:a.status==="done",status:a.status}),f.jsx("div",{className:"flex-1 min-w-0",children:f.jsx(Ee,{size:"small",texture:"canvas",className:"plan-row-card",children:f.jsxs("div",{className:"grid grid-cols-[76px_minmax(0,1fr)_84px_1fr] gap-2 items-center max-[480px]:grid-cols-1 max-[480px]:gap-1",children:[a.id?f.jsx(Jr,{id:a.id}):f.jsx("span",{}),f.jsxs("button",{type:"button",onClick:()=>s==null?void 0:s(a.title),className:OS,children:[f.jsx(Qm,{}),f.jsx("span",{className:zS,children:a.title})]}),f.jsx("span",{className:"max-lg:hidden text-sm opacity-[0.45]",children:"—"}),f.jsxs("div",{className:"flex items-center justify-end gap-2",children:[f.jsx("span",{className:`text-sm ${l.length>0?"opacity-60":"opacity-30"}`,children:l.length>0?`${u.length}/${l.length} plans done`:"—"}),f.jsx(tg,{idea:a,compact:!0}),f.jsx(Nu,{idea:a,otherPlans:t})]})]})})})]}),l.length>0&&f.jsxs("div",{className:"ml-5 pl-3 border-l-2 border-black/[8%] flex flex-col gap-1",children:[f.jsx(DS,{plans:h,activePlanTitle:n,onOpen:r,showHeader:!1}),d&&f.jsx("button",{type:"button",onClick:o,className:"self-start bg-none bg-transparent border-none py-1 px-0 opacity-60 cursor-pointer underline text-xs [font:inherit]",children:i?"Show less":`+${u.length} done`})]})]})},aW=({plans:e,rows:t,activePlanTitle:n,onOpenPlan:r,onOpenIdea:s})=>{const i=_.useRef(null);return _.useEffect(()=>{var a;if(!n)return;const o=(a=i.current)==null?void 0:a.querySelector(".plan-row-highlighted");o==null||o.scrollIntoView({behavior:"smooth",block:"center"})},[n]),f.jsx("div",{ref:i,children:t.length>0?f.jsx(sW,{rows:t,plans:e,activePlanTitle:n,onOpenPlan:r,onOpenIdea:s}):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."})})},lW=({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(Jr,{id:e.id??void 0}),e.title,e.status&&f.jsx(Ae,{size:"small",fillColor:Hc[e.status].fill,textColor:Hc[e.status].text,children:IS[e.status]})]}),f.jsx(ek,{children:e.body.replace(/^#{1,3}\s+.+(\n|$)/,"").replace(/^\s*-{3,}\s*(\n|$)/,"").trim()}),f.jsx("div",{className:"mt-6",children:f.jsx(tg,{idea:e})})]}),lf="__no-subject__",ss="font-handwritten text-xs font-semibold leading-none text-ink-300 mb-2",cW=()=>{const e=F(P=>P.plans),t=Xm(),n=F(gm),r=F(P=>P.agentStatus),{patch:s,updating:i}=Ea(),{subjects:o,available:a}=CS(),l=F(P=>P.detailView),u=F(P=>P.setDetailView),c=t?e==null?void 0:e.entries.find(P=>P.title===t):null,[d,h]=_.useState("");if(_.useEffect(()=>{h((c==null?void 0:c.order)!==void 0?String(c==null?void 0:c.order):"")},[c==null?void 0:c.order]),!c)return null;const p=hm(c,r),m=c.status==="in-progress",y=c.status==="review",w=c.status==="dropped",g=c.phases.some(P=>!P.done),x=(c.status==="planned"||m)&&g,v=!!(c.pr&&(c.pr.state==="open"||c.pr.state==="draft")&&c.pr.unresolvedThreadCount),k=a&&c.subject&&!o.includes(c.subject)?c.subject:void 0,S=P=>s(c.title,P),b=m||y||c.status==="planned",j=async()=>{const P=d.trim(),T=Number(P);if(P===""||!Number.isInteger(T)||T<1){h(c.order!==void 0?String(c.order):"");return}T!==c.order&&await S({order:T})};return f.jsx("div",{className:"-mt-5",children:f.jsx(Ee,{surface:"paper",texture:"speckle",size:"small",children:f.jsxs("div",{className:"flex flex-col gap-5",children:[f.jsx("h2",{className:"m-0 font-display-luminari text-base text-ink-900",children:"Plan"}),f.jsxs("div",{children:[f.jsx("div",{className:ss,children:"Show"}),f.jsxs("div",{className:"flex flex-col gap-1",children:[f.jsx(li,{size:"small",active:l==="details",onClick:()=>u("details"),children:"Details"}),f.jsx(li,{size:"small",active:l==="feedback",onClick:()=>u("feedback"),children:"Feedback"})]})]}),f.jsxs("div",{children:[f.jsx("div",{className:ss,children:"Status"}),f.jsx(Ae,{size:"small",fillColor:er[p].fill,textColor:er[p].text,children:eg[p]})]}),f.jsxs("div",{children:[f.jsx("div",{className:ss,children:"Subject"}),f.jsx(qh,{size:"small",value:c.subject??lf,onChange:P=>S({subject:P===lf?null:P}),disabled:i||!a,options:[{value:lf,label:"No subject"},...k?[{value:k,label:`${k} (orphan)`}]:[],...!a&&c.subject&&!k?[{value:c.subject,label:c.subject}]:[],...o.map(P=>({value:P,label:P}))]})]}),b&&f.jsxs("div",{children:[f.jsx("div",{className:ss,children:"Order"}),f.jsx(Pa,{type:"number",size:"small","aria-label":"Run order",min:1,value:d,onChange:P=>h(P.target.value),onBlur:j,disabled:i})]}),f.jsxs("div",{children:[f.jsx("div",{className:ss,children:"Agent"}),f.jsx(qh,{size:"small",value:c.agent??"",onChange:P=>S({agent:P||null}),disabled:i,options:[{value:"",label:"Project default agent"},...uM.map(P=>({value:P,label:ck[P]}))]})]}),c.tags.length>0&&f.jsxs("div",{children:[f.jsx("div",{className:ss,children:"Tags"}),f.jsx("div",{className:"flex items-center gap-1 flex-wrap",children:c.tags.map(P=>f.jsx(Ae,{size:"small",fillColor:"rgba(0,0,0,0.06)",children:P},P))})]}),f.jsxs("div",{children:[f.jsx("div",{className:ss,children:"Actions"}),f.jsxs("div",{className:"flex flex-col gap-1",children:[x&&f.jsx($U,{plan:c,disabled:n||i}),v&&f.jsx(DU,{plan:c,disabled:n||i}),y&&f.jsx(li,{size:"small",icon:f.jsx("span",{className:"text-watercolor-green-dark",children:"✓"}),onClick:()=>S({status:"done"}),disabled:i,className:i?"opacity-50":void 0,children:"Approve & close"}),f.jsx(li,{size:"small",icon:f.jsx("span",{className:w?"text-watercolor-green-dark":"text-watercolor-rose-dark",children:w?"↺":"⊘"}),onClick:()=>S({status:w?null:"dropped"}),disabled:i,className:i?"opacity-50":void 0,children:w?"Reopen plan":"Mark dropped"})]})]})]})})})},jv=8,uW=["in-progress","review","planned","idea","done","dropped"],dW={...eg,idea:"Backlog"},Ev="text-2xs font-semibold tracking-[0.08em] uppercase text-ink-300 mb-2",fW=()=>{const e=F(v=>v.plans),t=Xm(),n=F(v=>v.planFilters),r=F(v=>v.togglePlanStatus),s=F(v=>v.togglePlanTag),i=F(v=>v.setPlanSearch),o=F(v=>v.setSubjectFilter),a=Zt(),[l,u]=_.useState(!1);if(!e||t)return null;const{statusCounts:c,tagCounts:d}=Bl(e.entries,n),h=new Set(n.statuses),p=new Set(n.tags),y=[...new Set([...Object.keys(d),...n.tags])].sort((v,k)=>{const S=(d[k]??0)-(d[v]??0);return S!==0?S:v.localeCompare(k)}),w=l?y:y.slice(0,jv),g=y.length-w.length,x="bg-none bg-transparent border-none p-0 cursor-pointer opacity-70 underline text-2xs";return f.jsx("div",{className:"-mt-5",children:f.jsx(Ee,{surface:"paper",texture:"speckle",size:"small",children:f.jsxs("div",{className:"flex flex-col gap-5",children:[f.jsx("h2",{className:"m-0 font-display-luminari text-base text-ink-900",children:"Filters"}),f.jsx(Pa,{type:"search",size:"small",placeholder:"Search plans…","aria-label":"Search plans",value:n.search,onChange:v=>i(v.target.value)}),n.subject!==null&&f.jsxs("div",{className:"flex items-center gap-2","data-testid":"subject-filter-chip",children:[f.jsxs("span",{className:"text-2xs opacity-70",children:["Subject: ",n.subject]}),f.jsx("button",{type:"button",onClick:()=>{o(null),a({to:"/",search:{}})},className:x,children:"Clear"})]}),f.jsxs("div",{children:[f.jsx("div",{className:Ev,children:"Status"}),f.jsx("div",{className:"flex flex-col gap-1",children:uW.map(v=>{const k=h.has(v);return f.jsxs("button",{type:"button",onClick:()=>r(v),"aria-pressed":k,className:`flex items-center gap-2 w-full px-2 py-1 rounded-md border-none cursor-pointer text-left ${k?"bg-black/[5%] opacity-100":"bg-transparent opacity-50"}`,children:[f.jsx("span",{className:"w-[9px] h-[9px] rounded-full shrink-0",style:{background:er[v].text}}),f.jsx("span",{className:"flex-1 text-xs text-ink-900",children:dW[v]}),f.jsx("span",{className:"text-2xs text-ink-500",children:c[v]})]},v)})})]}),f.jsxs("div",{children:[f.jsx("div",{className:Ev,children:"Tags"}),f.jsxs("div",{className:"flex flex-wrap gap-1 items-center",children:[y.length===0&&f.jsx("span",{className:"opacity-50 text-2xs",children:"No tags"}),w.map(v=>{const k=p.has(v);return f.jsxs("button",{type:"button",onClick:()=>s(v),"aria-pressed":k,className:`text-2xs px-2 py-[2px] rounded-md border-[0.5px] border-black/[12%] cursor-pointer ${k?"bg-black/[8%] opacity-100":"bg-transparent opacity-55"}`,children:[v," ",d[v]??0]},v)}),g>0&&f.jsxs("button",{type:"button",onClick:()=>u(!0),className:x,children:["+",g," more"]}),l&&y.length>jv&&f.jsx("button",{type:"button",onClick:()=>u(!1),className:x,children:"Show less"})]})]})]})})})},Tv=()=>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"}),f.jsx(LS,{}),f.jsx(FU,{}),f.jsx(AU,{}),f.jsx(VU,{})]}),hW=[{key:"a",title:"72%"},{key:"b",title:"54%"},{key:"c",title:"83%"},{key:"d",title:"46%"},{key:"e",title:"66%"},{key:"f",title:"58%"}],pW=()=>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(Ee,{size:"small",texture:"kraft",className:"plan-row-card",children:f.jsxs("div",{className:Yh,children:[f.jsx(on,{variant:"text",width:28}),f.jsx(on,{variant:"text",width:44}),f.jsx("span",{className:"max-lg:hidden",children:f.jsx(on,{variant:"text",width:56})}),f.jsx(on,{variant:"text",width:64}),f.jsx(on,{variant:"text",width:48})]})})})]}),hW.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(on,{variant:"text",width:16})}),f.jsx("div",{className:"flex-1 min-w-0",children:f.jsx(Ee,{size:"small",className:"plan-row-card",children:f.jsxs("div",{className:Yh,children:[f.jsx(on,{variant:"rect",width:44,height:18}),f.jsx(on,{variant:"text",width:e.title}),f.jsx("span",{className:"max-lg:hidden",children:f.jsx(on,{variant:"text",width:52})}),f.jsx(on,{variant:"rect",width:80,height:8}),f.jsx(on,{variant:"rect",width:64,height:20})]})})})]},e.key))]}),mW=()=>{const e=F(c=>c.reconcileQueue),t=F(c=>c.removeFromReconcileQueue),n=F(c=>c.plans),{patch:r}=Ea(),{toast:s}=Ge(),i=_.useRef(0),o=e[0]??null,a=o?(n==null?void 0:n.entries.find(c=>c.id===o.planId))??null:null;if(_.useEffect(()=>{o&&!a&&t(o.previewId)},[o,a,t]),_.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.`})},u=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(PU,{plan:a,before:o.before,onApprove:l,onDiscard:u,queuePosition:{index:i.current+1,total:i.current+e.length}})},gW=({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(Ee,{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(Qm,{}),f.jsx("span",{className:"font-semibold overflow-hidden text-ellipsis whitespace-nowrap",children:r.title})]}),f.jsx(ut,{icon:f.jsx("span",{children:"×"}),variant:"ghost",size:"small",label:"Dismiss",className:"w-[28px] h-[28px]",onClick:()=>n(r)})]})})},`${r.date}-${r.title}`))})]}),rg=()=>{const e=F(b=>b.plans),t=F(b=>b.plansError),n=F(b=>b.ideaEntries),r=F(b=>b.suggestions);F(b=>b.loadPlans);const s=F(b=>b.setDetailView),i=F(b=>b.planFilters),o=F(b=>b.setSubjectFilter),a=Xm(),l=nU(),u=F(b=>b.dismissSuggestion),c=Zt(),{toast:d}=Ge(),{subject:h}=Qp({strict:!1});_.useEffect(()=>{o(h??null)},[h,o]),_.useEffect(()=>{s("details")},[a,l,s]);const p=()=>{c({to:"/"})},m=b=>{c({to:"/plans/$planId",params:{planId:encodeURIComponent(b)}})},y=b=>{c({to:"/ideas/$ideaId",params:{ideaId:encodeURIComponent(b)}})},[w,g]=_.useState(null),x=async b=>{try{await u(b)}catch(j){d({title:"Failed to dismiss suggestion",description:j.message,variant:"error"})}},v=a?e==null?void 0:e.entries.find(b=>b.title===a):null,k=l?n.find(b=>b.title===l):null;if(t)return f.jsxs("div",{children:[f.jsx(cU,{children:"Plans"}),f.jsxs(Ee,{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 f.jsxs("div",{children:[f.jsx(Tv,{}),f.jsx("output",{"aria-live":"polite",className:"sr-only",children:"Loading plans…"}),f.jsx(pW,{})]});const{rows:S}=yM(e.entries,n,i);return f.jsxs(f.Fragment,{children:[f.jsx(mW,{}),v?f.jsxs("div",{children:[f.jsx("div",{className:"mb-4",children:f.jsx(yv,{items:[{id:"plans",label:"Plans",onClick:p},{id:"plan",label:v.title}]})}),f.jsx(ZU,{plan:v})]}):k?f.jsxs("div",{children:[f.jsx("div",{className:"mb-4",children:f.jsx(yv,{items:[{id:"plans",label:"Plans",onClick:p},{id:"idea",label:k.title}]})}),f.jsx(lW,{idea:k})]}):f.jsxs("div",{children:[f.jsx(Tv,{}),e.warnings.length>0&&f.jsxs(Ee,{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(b=>f.jsxs("li",{children:[b.title,": ",b.message]},b.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(aW,{plans:e.entries,rows:S,activePlanTitle:a,onOpenPlan:m,onOpenIdea:y}),f.jsx(jU,{}),f.jsx(gW,{suggestions:r,onOpen:g,onDismiss:x}),f.jsx(CU,{suggestion:w,onClose:()=>g(null)})]})]})},BS=_.lazy(()=>Kr(()=>import("./index-CQB12bDI.js"),__vite__mapDeps([0,1])).then(e=>({default:e.DocsPage}))),yW=_.lazy(()=>Kr(()=>import("./index-CQB12bDI.js"),__vite__mapDeps([0,1])).then(e=>({default:e.DocsSidebar}))),$S=_.lazy(()=>Kr(()=>import("./index-D6bamXbC.js"),__vite__mapDeps([2,3,1])).then(e=>({default:e.SettingsPage}))),xW=_.lazy(()=>Kr(()=>import("./index-D6bamXbC.js"),__vite__mapDeps([2,3,1])).then(e=>({default:e.SettingsSidebar}))),vW=_.lazy(()=>Kr(()=>import("./index-BMsByqaB.js"),__vite__mapDeps([4,3])).then(e=>({default:e.TasksPage}))),wW=_.lazy(()=>Kr(()=>import("./index-V3ou3lzT.js"),[]).then(e=>({default:e.RoadmapPage}))),bW=_.lazy(()=>Kr(()=>import("./index-Bwc1cGPX.js"),[]).then(e=>({default:e.DiffPage}))),kW=_.lazy(()=>Kr(()=>import("./index-D-k_o5eq.js"),__vite__mapDeps([5,3])).then(e=>({default:e.StatsPage}))),cf=[{id:"plans",label:"Plans",path:"/"},{id:"roadmap",label:"Roadmap",path:"/roadmap"},{id:"docs",label:"Docs",path:"/docs"},{id:"tasks",label:"Tasks",path:"/tasks"},{id:"stats",label:"Stats",path:"/stats"},{id:"settings",label:"Settings",path:"/settings"}],Rv=()=>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"})}),VS="stack-open";function _W(){try{return localStorage.getItem(VS)==="true"}catch{return!1}}function SW(e){try{localStorage.setItem(VS,String(e))}catch{}}const CW="(min-width: 1440px)";function PW(e){const[t,n]=_.useState(()=>typeof window<"u"?window.matchMedia(e).matches:!1);return _.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 jW=()=>{var S;const e=Zt(),t=bT({select:b=>b.location.pathname}),n=F(b=>b.loadPlans),r=F(b=>b.loadIdeas),s=F(b=>b.loadSuggestions),i=F(b=>b.loadCapabilities),o=F(b=>b.loadAgentAuthStatus),a=F(b=>b.setActiveDocTitle),l=t==="/"||t.startsWith("/plans/")||t.startsWith("/ideas/"),u=t==="/docs"||t.startsWith("/docs/"),c=t==="/settings"||t.startsWith("/settings/"),d=l?"plans":u?"docs":c?"settings":(S=cf.find(b=>b.path===t))==null?void 0:S.id,h=l||u||c,p=l?"plans":u?"docs":"settings",[m,y]=_.useState(_W),[w,g]=_.useState(!1),x=_u(),v=PW(CW),k=_.useRef(!1);return _.useEffect(()=>{n(),r(),s(),i(),o()},[n,r,s,i,o]),_.useEffect(()=>{k.current||t!=="/"||(k.current=!0,Promise.all([rk(),nk()]).then(([b,j])=>{if(!(b!=null&&b.setupDismissed)&&j!==null&&!j.every(P=>P.status==="ok")){e({to:"/settings/$section",params:{section:"setup"}});return}Promise.all([sk(),ok()]).then(([P,T])=>{P.entries.length>1||T.entries.length>0||(a("USAGE.md"),e({to:"/docs"}))})}))},[t,e,a]),_.useEffect(()=>{g(!1)},[t]),f.jsxs(i8,{position:"bottom-left",children:[f.jsxs("div",{className:"h-screen box-border min-[1440px]:pr-[480px] flex flex-col",children:[f.jsx(oU,{}),f.jsx(lU,{}),f.jsx(ZB,{style:{flex:"1 1 0%",minHeight:0,height:"auto"},background:{texture:"speckle",ruledType:"grid",ruledColor:"blue"},showHeader:!0,showSidebar:!1,showPage:!1,bleedBottom:!0,headerActions:f.jsxs(f.Fragment,{children:[h&&f.jsx(ut,{variant:"ghost",size:"small",className:"lg:hidden max-[480px]:hidden",label:"Open sidebar",onClick:()=>g(!0),icon:f.jsx(Rv,{})}),f.jsx(iU,{size:"sm"}),f.jsx("div",{className:"flex-1"}),f.jsx("nav",{"aria-label":"Main navigation",className:"flex items-center gap-1 max-[480px]:hidden",children:cf.map(b=>f.jsx(ne,{variant:"ghost",size:"small",isActive:b.id===d,onClick:()=>e({to:b.path}),"aria-current":b.id===d?"page":void 0,children:b.label},b.id))})]}),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 -mt-8 -ml-8 -mr-8 pt-0 pl-8 pr-8 pb-[var(--pc-content-pad-bottom,32px)]",children:f.jsxs("div",{className:"flex min-w-0 justify-center lg:[--pc-sidebar-h:calc(100vh-160px)] gap-6 w-full",children:[h&&f.jsxs(aU,{routeKey:p,mobileOpen:w,onMobileClose:()=>g(!1),children:[l&&f.jsxs(f.Fragment,{children:[f.jsx(fW,{}),f.jsx(cW,{})]}),u&&f.jsx(_.Suspense,{fallback:null,children:f.jsx(yW,{})}),c&&f.jsx(_.Suspense,{fallback:null,children:f.jsx(xW,{})})]}),f.jsx("div",{className:`flex flex-col min-w-0 ${v?"flex-[1_1_0%]":"flex-[0_1_800px]"}`,children:f.jsx(Ni.div,{...jS(x),transition:PS(x),className:"flex flex-col flex-1 min-w-0",children:f.jsx(mS,{texture:{texture:"parchment"},outline:!0,className:`min-h-[calc(100vh-160px)] w-full ${v?"max-w-none":""}`,children:f.jsx(_.Suspense,{fallback:null,children:f.jsx(yb,{})})})},t)})]})})})})]}),f.jsx(X8,{open:m,pinned:v,onToggle:()=>{const b=!m;SW(b),y(b)}}),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:[h&&f.jsx(ut,{variant:"ghost",size:"small",label:"Open sidebar",onClick:()=>g(!0),icon:f.jsx(Rv,{}),className:"min-h-11"}),cf.map(b=>f.jsx(ne,{variant:"ghost",size:"small",isActive:b.id===d,onClick:()=>e({to:b.path}),"aria-current":b.id===d?"page":void 0,className:"min-h-11",children:b.label},b.id))]})]})},en=oT({component:jW}),EW=gn({getParentRoute:()=>en,path:"/",component:rg,validateSearch:e=>({subject:typeof e.subject=="string"?e.subject:void 0})}),TW=gn({getParentRoute:()=>en,path:"/plans/$planId",component:rg}),RW=gn({getParentRoute:()=>en,path:"/ideas/$ideaId",component:rg}),NW=gn({getParentRoute:()=>en,path:"/docs",component:BS}),IW=gn({getParentRoute:()=>en,path:"/docs/$section",component:BS}),AW=gn({getParentRoute:()=>en,path:"/settings",component:$S}),MW=gn({getParentRoute:()=>en,path:"/settings/$section",component:$S}),LW=gn({getParentRoute:()=>en,path:"/roadmap",component:wW,validateSearch:e=>({item:typeof e.item=="string"?e.item:void 0})}),DW=gn({getParentRoute:()=>en,path:"/diff",component:bW}),FW=gn({getParentRoute:()=>en,path:"/stats",component:kW}),OW=gn({getParentRoute:()=>en,path:"/tasks",component:vW,validateSearch:e=>({taskId:typeof e.taskId=="string"?e.taskId:void 0})}),zW=en.addChildren([EW,TW,RW,NW,IW,AW,MW,OW,LW,DW,FW]),BW=yT({routeTree:zW}),US=document.getElementById("root");if(!US)throw new Error("#root element not found");Uw(US).render(f.jsx(_.StrictMode,{children:f.jsx(wT,{router:BW})}));export{qW as A,HW as B,ja as C,YW as D,r9 as E,Qe as F,qA as G,KW as H,GW as I,ne as J,AS as K,eg as L,ek as M,eW as N,QW as O,cU as P,yV as Q,lM as R,er as S,Ae as U,e9 as V,Zt as a,n9 as b,rk as c,EU as d,VW as e,$W as f,Ie as g,CS as h,li as i,f as j,Ge as k,xS as l,t9 as m,Z8 as n,Pa as o,gv as p,WW as q,_ as r,UW as s,qh as t,F as u,uM as v,Ee as w,ck as x,yv as y,Qp as z};
207
+ //# sourceMappingURL=main-0sfOZaxl.js.map