copilot-operator 0.1.42 → 0.1.44

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/dist/src/api/operator.controller.js +185 -0
  2. package/dist/src/api/operator.service.js +421 -3
  3. package/dist/src/api/server.js +16 -0
  4. package/dist/src/cli.js +12 -0
  5. package/dist/src/config/schema.js +10 -0
  6. package/dist/src/orchestrator/taskRunner.js +109 -38
  7. package/dist/src/plan/brief.js +57 -20
  8. package/dist/src/plan/changes.js +217 -0
  9. package/dist/src/plan/schema.js +1 -1
  10. package/dist/src/plan/systemGuide.js +733 -12
  11. package/dist/src/session/compose.js +15 -1
  12. package/dist/src/session/model.js +1 -1
  13. package/dist/src/session/store.js +60 -0
  14. package/dist/src/session/workspace.js +71 -0
  15. package/dist/src/vcs/taskVcs.js +110 -1
  16. package/dist/web/404.html +2 -2
  17. package/dist/web/_next/static/BX8Nw248DTY9xAfUu2pOH/_buildManifest.js +1 -0
  18. package/dist/web/_next/static/chunks/499-751e0be9d4f86e2d.js +1 -0
  19. package/dist/web/_next/static/chunks/549-1fe42544e4b72942.js +1 -0
  20. package/dist/web/_next/static/chunks/699-9d031f8c145a0465.js +1 -0
  21. package/dist/web/_next/static/chunks/867-0f0f8c3bd37be31e.js +1 -0
  22. package/dist/web/_next/static/chunks/897-5a34109533c3da50.js +1 -0
  23. package/dist/web/_next/static/chunks/app/defaults/page-56134fbb8cc7554f.js +1 -0
  24. package/dist/web/_next/static/chunks/app/history/{page-47973539ceff81d6.js → page-0bb537407fed5944.js} +1 -1
  25. package/dist/web/_next/static/chunks/app/import/{page-999d6cd958989723.js → page-8ef75fc08638e75f.js} +1 -1
  26. package/dist/web/_next/static/chunks/app/layout-12f138ee04d33c1e.js +1 -0
  27. package/dist/web/_next/static/chunks/app/page-09c6e2d42098f8d4.js +1 -0
  28. package/dist/web/_next/static/chunks/app/{page-e557d58476ae6383.js → sessions/page-28376d2e4a9b4738.js} +1 -1
  29. package/dist/web/_next/static/chunks/app/sessions/view/page-afc235a9171535d8.js +1 -0
  30. package/dist/web/_next/static/css/{0e55721108c300f2.css → eaec9cc6fe8aceb7.css} +1 -1
  31. package/dist/web/appearance.html +2 -2
  32. package/dist/web/appearance.txt +25 -28
  33. package/dist/web/defaults.html +2 -2
  34. package/dist/web/defaults.txt +25 -28
  35. package/dist/web/history.html +2 -2
  36. package/dist/web/history.txt +25 -28
  37. package/dist/web/import.html +2 -2
  38. package/dist/web/import.txt +25 -28
  39. package/dist/web/index.html +2 -2
  40. package/dist/web/index.txt +25 -28
  41. package/dist/web/level1.html +2 -2
  42. package/dist/web/level1.txt +25 -28
  43. package/dist/web/presets.html +3 -3
  44. package/dist/web/presets.txt +25 -28
  45. package/dist/web/sessions/view.html +2 -2
  46. package/dist/web/sessions/view.txt +25 -28
  47. package/dist/web/sessions.html +16 -0
  48. package/dist/web/sessions.txt +26 -0
  49. package/dist/web/system.html +2 -2
  50. package/dist/web/system.txt +25 -28
  51. package/package.json +5 -2
  52. package/dist/web/_next/static/chunks/204-db82ca47ff211e21.js +0 -1
  53. package/dist/web/_next/static/chunks/499-39b2c00bda3656f0.js +0 -1
  54. package/dist/web/_next/static/chunks/549-348b0a1404407e5a.js +0 -1
  55. package/dist/web/_next/static/chunks/867-7d86a692260006f1.js +0 -1
  56. package/dist/web/_next/static/chunks/app/defaults/page-a25c40436fc312db.js +0 -1
  57. package/dist/web/_next/static/chunks/app/layout-6ee612d25e78b246.js +0 -1
  58. package/dist/web/_next/static/chunks/app/sessions/view/page-872d8b9fe8eedbbf.js +0 -1
  59. package/dist/web/_next/static/lDmqS7pWU_B_Ac5idPvdS/_buildManifest.js +0 -1
  60. /package/dist/web/_next/static/{lDmqS7pWU_B_Ac5idPvdS → BX8Nw248DTY9xAfUu2pOH}/_ssgManifest.js +0 -0
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[974],{1702:(e,s,t)=>{"use strict";var a=t(9962);t.o(a,"usePathname")&&t.d(s,{usePathname:function(){return a.usePathname}}),t.o(a,"useRouter")&&t.d(s,{useRouter:function(){return a.useRouter}}),t.o(a,"useSearchParams")&&t.d(s,{useSearchParams:function(){return a.useSearchParams}})},4846:(e,s,t)=>{"use strict";t.r(s),t.d(s,{default:()=>en});var a=t(3365),n=t(1521),l=t(8197),i=t.n(l),r=t(5549),c=t(7527),o=t(867);function d(e){let{view:s,sessions:t,selected:n,onOpen:l,onChange:i,workspace:r,onOpenFolder:c}=e;return"files"===s?(0,a.jsx)(b,{workspace:r,onOpen:l,onOpenFolder:c}):"commits"===s?(0,a.jsx)(p,{sessions:t,selected:n,onOpen:l}):(0,a.jsx)(h,{sessions:t?t.filter(e=>"chat"!==e.kind):null,selected:n,onOpen:l,onChange:i})}function u(e){let{title:s,children:t}=e;return(0,a.jsxs)("div",{className:"wb-side-head",children:[(0,a.jsx)("h2",{children:s}),(0,a.jsx)("span",{className:"grow"}),t]})}function h(e){let{sessions:s,selected:t,onOpen:l,onChange:r}=e,{t:c}=(0,o.kj)(),[d,h]=(0,n.useState)(new Set),[m,b]=(0,n.useState)(""),p=m.trim().toLowerCase();return(0,a.jsxs)("div",{className:"wb-tree",children:[(0,a.jsxs)(u,{title:c("wb.sessions"),children:[(0,a.jsx)(i(),{className:"wb-icon-btn",href:"/sessions#new-session",title:c("wb.newSession"),"aria-label":c("wb.newSession"),children:"+"}),(0,a.jsx)(i(),{className:"wb-icon-btn",href:"/import",title:c("wb.startPlan"),"aria-label":c("wb.startPlan"),children:"⇩"}),(0,a.jsx)("button",{type:"button",className:"wb-icon-btn",onClick:r,title:c("wb.refresh"),"aria-label":c("wb.refresh"),children:"↻"})]}),(0,a.jsx)("div",{className:"wb-filter",children:(0,a.jsx)("input",{type:"search","aria-label":c("wb.filter"),placeholder:c("wb.filter"),value:m,onChange:e=>b(e.target.value)})}),s?0===s.length?(0,a.jsxs)("p",{className:"muted small wb-pad",children:[c("wb.noSessions")," ",(0,a.jsx)(i(),{href:"/import",children:c("wb.startPlan")})]}):(0,a.jsx)("ul",{className:"wb-tree-list",role:"tree","aria-label":c("wb.sessions"),children:s.map(e=>{let s=e.tasks.filter(s=>!p||s.title.toLowerCase().includes(p)||e.name.toLowerCase().includes(p));if(p&&0===s.length)return null;let n=!d.has(e.id)||!!p,i=e.tasks.filter(e=>"done"===e.status).length;return(0,a.jsxs)("li",{role:"treeitem","aria-expanded":n,"aria-selected":t.sessionId===e.id&&!t.taskId,children:[(0,a.jsxs)("div",{className:"wb-row session".concat(t.sessionId!==e.id||t.taskId?"":" sel"),children:[(0,a.jsx)("button",{type:"button",className:"wb-chev","aria-label":n?c("wb.collapse",{name:e.name}):c("wb.expand",{name:e.name}),onClick:()=>h(s=>{let t=new Set(s);return t.has(e.id)?t.delete(e.id):t.add(e.id),t}),children:n?"▾":"▸"}),(0,a.jsxs)("button",{type:"button",className:"wb-row-main",onClick:()=>l({kind:"session",sessionId:e.id}),children:[(0,a.jsx)("span",{className:"wb-row-name",children:e.name}),e.running&&(0,a.jsx)("span",{className:"wb-live",title:c("wb.running"),"aria-label":c("wb.running")}),(0,a.jsxs)("span",{className:"wb-count",children:[i,"/",e.tasks.length]})]})]}),n&&(0,a.jsx)("ul",{role:"group",children:s.map(s=>{var n;let i=e.tasks.indexOf(s)+1,r=t.taskId===s.id;return(0,a.jsx)("li",{role:"treeitem","aria-selected":r,children:(0,a.jsxs)("button",{type:"button",className:"wb-row task".concat(r?" sel":""),onClick:()=>l({kind:"task",sessionId:e.id,taskId:s.id}),title:s.title,children:[(0,a.jsx)(et,{status:s.status}),(0,a.jsxs)("span",{className:"wb-num",children:[i,"."]}),(0,a.jsx)("span",{className:"wb-row-name",children:s.title}),(null!=(n=s.attempt)?n:1)>1&&(0,a.jsxs)("span",{className:"wb-count",children:["a",s.attempt]})]})},s.id)})})]},e.id)})}):(0,a.jsx)("p",{className:"muted small wb-pad",children:c("wb.loading")})]})}let m=(e,s)=>e.localeCompare(s,void 0,{sensitivity:"base"});function b(e){let{workspace:s,onOpen:t,onOpenFolder:l}=e,{t:i}=(0,o.kj)(),[d,h]=(0,n.useState)(null),[b,p]=(0,n.useState)(""),[w,x]=(0,n.useState)(new Set),j=()=>(null==s?void 0:s.ok)?r.FH.workspaceFiles().then(e=>{h(e.files),p("")}).catch(e=>p(e.message)):Promise.resolve();(0,n.useEffect)(()=>{h(null),j()},[null==s?void 0:s.dir,null==s?void 0:s.ok]),(0,c.z)(j,6e3,!!(null==s?void 0:s.ok));let k=(e,s)=>(0,a.jsxs)(a.Fragment,{children:[[...e.dirs.keys()].sort(m).map(t=>{let n=s?"".concat(s,"/").concat(t):t;return(0,a.jsxs)("li",{role:"treeitem","aria-expanded":w.has(n),children:[(0,a.jsxs)("button",{type:"button",className:"wb-row",onClick:()=>x(e=>{let s=new Set(e);return s.has(n)?s.delete(n):s.add(n),s}),children:[(0,a.jsx)("span",{className:"wb-chev","aria-hidden":"true",children:w.has(n)?"▾":"▸"}),(0,a.jsx)("span",{className:"wb-row-name",children:t})]}),w.has(n)&&(0,a.jsx)("ul",{role:"group",children:k(e.dirs.get(t),n)})]},"d:".concat(n))}),[...e.files].sort((e,s)=>m(e.split("/").pop(),s.split("/").pop())).map(e=>(0,a.jsx)("li",{role:"treeitem",children:(0,a.jsxs)("button",{type:"button",className:"wb-row file",onClick:()=>t({kind:"file",sessionId:"",path:e}),title:e,children:[(0,a.jsx)("span",{className:"wb-ico","aria-hidden":"true",children:"≡"}),(0,a.jsx)("span",{className:"wb-row-name",children:e.split("/").pop()})]})},"f:".concat(e)))]});return(0,a.jsxs)("div",{className:"wb-tree",children:[(0,a.jsxs)(u,{title:(null==s?void 0:s.ok)?s.name:i("wb.files"),children:[(0,a.jsx)("button",{type:"button",className:"wb-icon-btn",onClick:l,title:i("chat.openFolder"),"aria-label":i("chat.openFolder"),children:"⋯"}),(0,a.jsx)("button",{type:"button",className:"wb-icon-btn",onClick:()=>void j(),title:i("wb.refresh"),"aria-label":i("wb.refresh"),children:"↻"})]}),s?s.ok?b?(0,a.jsx)("p",{className:"err small wb-pad",children:b}):d?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("p",{className:"muted small wb-pad",title:s.dir,children:s.branch?"⎇ ".concat(s.branch):s.dir}),(0,a.jsx)("ul",{className:"wb-tree-list",role:"tree","aria-label":i("wb.files"),children:k(function(e){let s={dirs:new Map,files:[]};for(let t of e){let e=t.split("/"),a=s;for(let s of e.slice(0,-1)){let e=a.dirs.get(s);e||(e={dirs:new Map,files:[]},a.dirs.set(s,e)),a=e}a.files.push(t)}return s}(d),"")})]}):(0,a.jsx)("p",{className:"muted small wb-pad",children:i("wb.loading")}):(0,a.jsxs)("div",{className:"wb-pad",children:[(0,a.jsx)("p",{className:"small",children:s.problem}),(0,a.jsx)("button",{type:"button",className:"primary",onClick:l,children:i("chat.openFolder")})]}):(0,a.jsx)("p",{className:"muted small wb-pad",children:i("wb.loading")})]})}function p(e){var s;let{sessions:t,selected:l,onOpen:i}=e,{t:c}=(0,o.kj)(),d=(0,o.W3)(),h=null!=(s=null==t?void 0:t.find(e=>e.id===l.sessionId))?s:null==t?void 0:t.find(e=>{var s;return(null==(s=e.vcs)?void 0:s.enabled)&&e.vcs.repoDir}),[m,b]=(0,n.useState)(null),[p,w]=(0,n.useState)("");return(0,n.useEffect)(()=>{b(null),w(""),h&&r.FH.repoLog(h.id).then(b).catch(e=>w(e.message))},[null==h?void 0:h.id,null==h?void 0:h.tasks.map(e=>{var s,t;return null!=(t=null==(s=e.vcs)?void 0:s.commit)?t:""}).join()]),(0,a.jsxs)("div",{className:"wb-tree",children:[(0,a.jsx)(u,{title:c("wb.commits")}),h?p?(0,a.jsx)("p",{className:"err small wb-pad",children:p}):m?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("p",{className:"muted small wb-pad",children:c("wb.commitsOf",{name:h.name,ref:m.label})}),(0,a.jsx)("ul",{className:"wb-commits",children:m.commits.map(e=>(0,a.jsxs)("li",{children:[e.taskId?(0,a.jsxs)("button",{type:"button",className:"wb-row",onClick:()=>i({kind:"task",sessionId:h.id,taskId:e.taskId}),title:e.subject,children:[(0,a.jsx)("code",{children:e.sha.slice(0,7)}),(0,a.jsx)("span",{className:"wb-row-name",children:e.subject})]}):(0,a.jsxs)("div",{className:"wb-row plain",title:e.subject,children:[(0,a.jsx)("code",{children:e.sha.slice(0,7)}),(0,a.jsx)("span",{className:"wb-row-name",children:e.subject})]}),(0,a.jsxs)("div",{className:"muted wb-commit-meta",children:[e.author," \xb7 ",d(e.at),e.taskTitle?" \xb7 ".concat(c("wb.byTask",{title:e.taskTitle})):""]})]},e.sha))})]}):(0,a.jsx)("p",{className:"muted small wb-pad",children:c("wb.loading")}):(0,a.jsx)("p",{className:"muted small wb-pad",children:c("wb.noRepo")})]})}var w=t(1035),x=t(8934),j=t(287),k=t(5132),v=t(9717);function f(e){let{session:s,task:t,focusAsk:l,onChange:i}=e,{t:c}=(0,o.kj)(),[d,u]=(0,n.useState)(""),[h,m]=(0,n.useState)(""),[b,p]=(0,n.useState)(!1),[w,x]=(0,n.useState)(!1),k=(0,n.useRef)(null),v="idle"===s.status,f="queued"===t.status||"running"===t.status||"waiting-approval"===t.status?"note":v&&"contract-conflict"!==t.stopCode?(0,r.Zm)(t)||(0,r.Dh)(t)?"continue":"done"===t.status?"newPrompt":"none":"none",N="running"===t.status||"waiting-approval"===t.status;(0,n.useEffect)(()=>{m(""),x(!1),u("")},[t.id]),(0,n.useEffect)(()=>{if(l>0){var e,s;null==(e=k.current)||e.focus(),null==(s=k.current)||s.scrollIntoView({block:"nearest"})}},[l]);let g=async()=>{if(d.trim()&&!b&&"none"!==f){p(!0),m("");try{"note"===f?(await r.FH.addTaskNote(s.id,t.id,d),m(N?c("wb.noteSentSoon"):c("wb.noteKept"))):("continue"===f?(await r.FH.continueTask(s.id,t.id,d),m(c("wb.queuedToContinue"))):(await r.FH.rerunTask(s.id,t.id,{prompt:d},{buildOnFinished:!0}),m(c("wb.queuedNewPrompt"))),x(!0)),u("")}catch(e){m(e.message)}finally{p(!1),i()}}},y="note"===f?c("wb.sendNote"):"continue"===f?c("wb.sendContinue"):"newPrompt"===f?c("wb.sendNewPrompt"):c("wb.sendNone"),C="note"===f?N?c("wb.hintNoteLive"):c("wb.hintNoteQueued"):"continue"===f?c("wb.hintContinue"):"newPrompt"===f?c("wb.hintNewPrompt"):v?c("wb.hintNone"):c("wb.hintBusy");return(0,a.jsxs)("div",{className:"wb-compose wb-task-compose",children:[w&&"queued"===t.status&&(0,a.jsx)("div",{className:"wb-inline-panel",children:(0,a.jsx)(j.f,{target:{sessionId:s.id,taskId:t.id,title:t.title},onClose:e=>{x(!1),e&&m(c("wb.started")),i()}})}),h&&(0,a.jsx)("p",{className:"small",role:"status",children:h}),(0,a.jsx)("label",{htmlFor:"wb-compose",className:"sr-only",children:y}),(0,a.jsx)("textarea",{id:"wb-compose",ref:k,value:d,onChange:e=>u(e.target.value),placeholder:"Ctrl+Enter",disabled:"none"===f||b,onKeyDown:e=>{"Enter"===e.key&&(e.ctrlKey||e.metaKey)&&(e.preventDefault(),g())}}),(0,a.jsxs)("div",{className:"row",children:[(0,a.jsx)("span",{className:"muted small grow",children:C}),(0,a.jsx)("button",{type:"button",className:"primary",disabled:"none"===f||b||!d.trim(),onClick:()=>void g(),title:"Ctrl+Enter",children:y})]})]})}var N=t(7619);function g(e){var s,t,l,c,d,u,h,m,b,p,g,C,I,S,F,O,T,P,H,E,A,M,D,L,R,q,K,W,z;let{session:B,task:U,onChange:Z,onKerrigan:_,onOpenFile:Y}=e,{t:G}=(0,o.kj)(),J=(0,o.W3)(),[V,Q]=(0,n.useState)(""),[X,$]=(0,n.useState)(!1),[ee,es]=(0,n.useState)(!1),[ea,en]=(0,n.useState)(!1),[el,ei]=(0,n.useState)(0),er=()=>ei(e=>e+1),ec=B.tasks.findIndex(e=>e.id===U.id)+1,eo="running"===U.status||"waiting-approval"===U.status,ed="idle"!==B.status,eu=(0,r.Zm)(U),eh=(0,r.Dh)(U)&&!eu,em="contract-conflict"===U.stopCode,eb=!!U.startedAt,ep=null==(t=U.attempts)||null==(s=t.at(-1))?void 0:s.undone,ew=null!=(P=U.plan)?P:U.continuing?null==(l=[...null!=(T=U.attempts)?T:[]].reverse().find(e=>{var s;return null==(s=e.plan)?void 0:s.approved}))?void 0:l.plan:void 0;(0,n.useEffect)(()=>{Q(""),es(!1),en(!1),ef(!1),eg("")},[U.id]);let ex=async function(e,s){let t=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(!X){$(!0),Q("");try{await e(),s&&Q(s),t&&es(!0)}catch(e){Q(e.message)}finally{$(!1),Z()}}},ej=async()=>{await (0,w.Z)(G("wb.removeConfirm",{title:U.title}))&&await ex(()=>r.FH.deleteTask(B.id,U.id),G("wb.removed"))},ek=async()=>{await (0,w.Z)(G("wb.runAgainConfirm",{title:U.title}))&&await ex(()=>r.FH.rerunTask(B.id,U.id),G("wb.queuedAgain"),!0)},[ev,ef]=(0,n.useState)(!1),[eN,eg]=(0,n.useState)("");return(0,a.jsxs)("article",{className:"wb-task","aria-labelledby":"wb-task-".concat(U.id),children:[(0,a.jsxs)("header",{className:"wb-task-head",children:[(0,a.jsx)(et,{status:U.status}),(0,a.jsxs)("div",{className:"grow",children:[(0,a.jsx)("h2",{id:"wb-task-".concat(U.id),children:U.title}),(0,a.jsxs)("p",{className:"muted small",children:[G("wb.taskOf",{n:ec,session:B.name,status:G("status.".concat(U.status))}),(null!=(H=U.attempt)?H:1)>1?" \xb7 ".concat(G("wb.attempt",{n:null!=(E=U.attempt)?E:1})):"",(null==(c=U.vcs)?void 0:c.branch)?" \xb7 ".concat(U.vcs.branch).concat(U.vcs.commit?" @ ".concat(U.vcs.commit.slice(0,8)):""):""]})]}),(0,a.jsx)(i(),{className:"button-link plain small",href:(0,r.aT)(B.id,U.id),children:G("wb.onSessionPage")})]}),(0,a.jsxs)("div",{className:"wb-actions",role:"toolbar","aria-label":G("wb.waysOn"),children:["queued"===U.status&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("button",{type:"button",className:"primary",disabled:X||ed,onClick:()=>es(!0),children:G("wb.runThis")}),(0,a.jsx)("button",{type:"button",onClick:er,children:G("wb.addNote")}),(0,a.jsx)(i(),{className:"button-link",href:(0,r.aT)(B.id,U.id),children:G("wb.editTask")}),(0,a.jsx)("button",{type:"button",className:"danger",disabled:X,onClick:()=>void ej(),children:G("wb.remove")})]}),eo&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("button",{type:"button",className:"primary",onClick:er,children:G("wb.writeToChat")}),(0,a.jsx)("button",{type:"button",className:"danger",disabled:X,onClick:()=>void ex(()=>r.FH.stop(B.id),G("wb.stopping")),children:G("wb.stopSession")})]}),em&&(0,a.jsx)(i(),{className:"button-link primary",href:(0,r.aT)(B.id,U.id),children:G("wb.fixContradiction")}),eu&&!eo&&(0,a.jsx)("button",{type:"button",className:"primary",disabled:X||ed,onClick:()=>void ex(()=>r.FH.continueTask(B.id,U.id),G("wb.queuedToContinue"),!0),children:G("wb.continue")}),(eh||eu)&&!em&&!eo&&(0,a.jsx)("button",{type:"button",className:eh?"primary":"",disabled:ed,onClick:er,children:G("wb.continueWithPrompt")}),"done"===U.status&&(0,a.jsx)("button",{type:"button",className:"primary",disabled:ed,onClick:er,children:G("wb.newPrompt")}),eb&&!eo&&"queued"!==U.status&&(0,a.jsx)("button",{type:"button",disabled:X||ed,onClick:()=>void ek(),children:G("wb.runAgain")}),["failed","blocked","limit-reached","aborted"].includes(U.status)&&(0,a.jsx)("button",{type:"button","aria-expanded":ev,disabled:X||ed,onClick:()=>ef(e=>!e),children:G("wb.accept")}),eb&&!eo&&"queued"!==U.status&&(0,a.jsx)("button",{type:"button","aria-expanded":ea,disabled:ed,onClick:()=>en(e=>!e),children:G("wb.undo")}),(null!=(A=null==(u=U.vcs)||null==(d=u.files)?void 0:d.length)?A:0)>0&&(0,a.jsx)(x.C,{sessionId:B.id,taskId:U.id,runId:U.runId,title:U.title,files:null!=(M=null==(m=U.vcs)||null==(h=m.files)?void 0:h.length)?M:0}),(0,a.jsx)("button",{type:"button",onClick:_,children:G("wb.askKerrigan")})]}),V&&(0,a.jsx)("p",{className:"notice small",role:"status",children:V}),ed&&!eo&&(0,a.jsx)("p",{className:"muted small",children:G("wb.sessionBusy")}),(0,a.jsx)(f,{session:B,task:U,focusAsk:el,onChange:Z}),ev&&(0,a.jsxs)("div",{className:"wb-inline-panel",role:"group","aria-label":G("wb.accept"),children:[(0,a.jsx)("label",{htmlFor:"wb-accept-".concat(U.id),children:G("wb.acceptNote")}),(0,a.jsx)("textarea",{id:"wb-accept-".concat(U.id),value:eN,onChange:e=>eg(e.target.value),style:{minHeight:60}}),(0,a.jsxs)("div",{className:"row",children:[(0,a.jsx)("button",{type:"button",className:"primary",disabled:X,onClick:()=>void ex(()=>r.FH.acceptTask(B.id,U.id,eN),G("wb.accepted")).then(()=>ef(!1)),children:G("wb.acceptGo")}),(0,a.jsx)("button",{type:"button",className:"quiet",onClick:()=>ef(!1),children:G("dialog.cancel")})]})]}),ea&&(0,a.jsx)(y,{session:B,task:U,onDone:e=>{en(!1),Q(e),es(!0),Z()}}),ee&&"queued"===U.status&&(0,a.jsx)("div",{className:"wb-inline-panel",children:(0,a.jsx)(j.f,{target:{sessionId:B.id,taskId:U.id,title:U.title},intro:V||void 0,onClose:e=>{es(!1),e&&Q(G("wb.started")),Z()}})}),(0,a.jsxs)("section",{className:"wb-sec",children:[(0,a.jsx)("h3",{children:G("wb.result")}),U.accepted&&(0,a.jsxs)("p",{className:"notice calm small",children:[G("wb.acceptedWas",{was:G("status.".concat(U.accepted.was)),at:J(U.accepted.at)}),U.accepted.note?" ".concat(U.accepted.note):""]}),"queued"===U.status&&ep&&(0,a.jsx)("p",{className:"notice calm small",children:"this"===ep.how?G("wb.undoneThis",{commit:null!=(D=null==(b=ep.commit)?void 0:b.slice(0,8))?D:"—"}):G("wb.undoneBack")}),(null==(p=U.continuing)?void 0:p.instruction)&&"done"!==U.status&&(0,a.jsxs)("p",{className:"small",children:[(0,a.jsx)("strong",{children:G("task.continuedWith",{n:U.continuing.fromAttempt})})," ",U.continuing.instruction]}),U.summary?(0,a.jsx)(k.s,{text:U.summary}):"queued"===U.status?(0,a.jsx)("p",{className:"muted small",children:G("wb.notRunYet")}):null,U.reason&&U.reason!==U.summary&&"done"!==U.status&&(0,a.jsx)("p",{className:"reason small",children:U.reason})]}),(0,a.jsxs)("details",{className:"wb-sec",open:"queued"===U.status,children:[(0,a.jsx)("summary",{children:G("wb.prompt")}),(0,a.jsx)(k.s,{text:U.prompt})]}),ew&&(0,a.jsxs)("details",{className:"wb-sec",children:[(0,a.jsx)("summary",{children:G("wb.plan",{n:ew.version})}),(0,a.jsx)(v.D,{plan:ew})]}),(null!=(L=null==(g=U.checkResults)?void 0:g.length)?L:0)>0&&(0,a.jsxs)("section",{className:"wb-sec",children:[(0,a.jsx)("h3",{children:G("wb.checks")}),(0,a.jsx)("ul",{className:"wb-list",children:U.checkResults.map(e=>(0,a.jsxs)("li",{className:e.passed?"ok":"bad",children:[(0,a.jsx)("span",{"aria-hidden":"true",children:e.passed?"✓":"✗"})," ",(0,a.jsx)("strong",{children:e.name})," ",(0,a.jsx)("span",{className:"muted small",children:e.detail})]},e.name))})]}),U.review&&(0,a.jsxs)("section",{className:"wb-sec",children:[(0,a.jsx)("h3",{children:G("wb.review",{verdict:U.review.verdict})}),U.review.summary&&(0,a.jsx)("p",{className:"small",children:U.review.summary}),(null!=(R=null==(C=U.review.findings)?void 0:C.length)?R:0)>0&&(0,a.jsx)("ul",{className:"wb-list",children:U.review.findings.map((e,s)=>{var t;return(0,a.jsxs)("li",{className:"bad small",children:[e.id&&(0,a.jsx)("code",{children:e.id})," ",e.what,e.where?(0,a.jsxs)("span",{className:"muted",children:[" — ",e.where]}):null]},null!=(t=e.id)?t:s)})})]}),(null!=(q=null==(S=U.vcs)||null==(I=S.files)?void 0:I.length)?q:0)>0&&(0,a.jsxs)("section",{className:"wb-sec",children:[(0,a.jsx)("h3",{children:G("wb.changedFiles",{n:U.vcs.files.length})}),(0,a.jsx)("ul",{className:"wb-list",children:U.vcs.files.map(e=>(0,a.jsxs)("li",{children:[(0,a.jsx)("button",{type:"button",className:"linkish",onClick:()=>Y(e.path),children:e.path})," ",(0,a.jsx)("span",{className:"muted small",children:e.added>=0?"+".concat(e.added," −").concat(e.removed):G("wb.binary")})]},e.path))})]}),(null!=(K=null==(F=U.notes)?void 0:F.length)?K:0)>0&&(0,a.jsxs)("section",{className:"wb-sec",children:[(0,a.jsx)("h3",{children:G("wb.notes")}),(0,a.jsx)("ul",{className:"wb-list",children:U.notes.map(e=>(0,a.jsxs)("li",{className:"small",children:[e.text," ",(0,a.jsxs)("span",{className:"muted",children:["— ",e.sentAt?G("wb.noteSent",{at:J(e.sentAt)}):G("wb.noteWaiting")]})]},e.id))})]}),(U.startedAt||eo)&&(0,a.jsxs)("details",{className:"wb-sec",open:eo,children:[(0,a.jsx)("summary",{children:G("wb.conversation")}),(0,a.jsx)(N.P,{sessionId:B.id,taskId:U.id,runId:U.runId,live:eo},"".concat(U.id,":").concat(null!=(W=U.runId)?W:""))]}),(null!=(z=null==(O=U.attempts)?void 0:O.length)?z:0)>0&&(0,a.jsxs)("details",{className:"wb-sec",children:[(0,a.jsx)("summary",{children:G("wb.attempts",{n:U.attempts.length})}),(0,a.jsx)("ol",{className:"wb-list",children:U.attempts.map((e,s)=>(0,a.jsxs)("li",{className:"small",children:[(0,a.jsx)(et,{status:e.status})," ",G("wb.attemptLine",{n:s+1,status:G("status.".concat(e.status))}),e.undone?" \xb7 ".concat("this"===e.undone.how?G("wb.undoneShortThis"):G("wb.undoneShortBack")):"",e.reason?(0,a.jsxs)("span",{className:"muted",children:[" — ",e.reason.slice(0,200)]}):null]},s))})]})]})}function y(e){var s,t,l;let{session:i,task:c,onDone:d}=e,{t:u}=(0,o.kj)(),[h,m]=(0,n.useState)(null),[b,p]=(0,n.useState)(""),[x,j]=(0,n.useState)(!1);(0,n.useEffect)(()=>{r.FH.undoPreview(i.id,c.id).then(m).catch(e=>p(e.message))},[i.id,c.id]);let k=async e=>{if(await (0,w.Z)("this"===e?u("wb.undoThisConfirm",{title:c.title}):u("wb.undoBackConfirm",{title:c.title}))){j(!0);try{let s=await r.FH.undoTask(i.id,c.id,e);d(s.message)}catch(e){p(e.message)}finally{j(!1)}}};if(b&&!h)return(0,a.jsx)("p",{className:"err small",children:b});if(!h)return(0,a.jsx)("p",{className:"muted small",children:u("wb.loading")});let v=h.this,f=h.back;return(0,a.jsxs)("div",{className:"wb-inline-panel",role:"group","aria-label":u("wb.undo"),children:[(0,a.jsxs)("div",{className:"option",children:[(0,a.jsx)("strong",{children:u("wb.undoThis")}),(0,a.jsx)("p",{className:"small",children:v.ok?v.nothing?v.nothing:v.perTask?u("wb.undoThisPerTask",{base:(null!=(s=v.baseCommit)?s:"").slice(0,8),branch:null!=(t=v.branch)?t:"—"}):u("wb.undoThisWhat",{n:v.commits.length,branch:null!=(l=v.branch)?l:"",later:v.later.length}):v.problem}),(0,a.jsx)("button",{type:"button",className:"primary",disabled:x||!v.ok,onClick:()=>void k("this"),children:u("wb.undoThisGo")})]}),(0,a.jsxs)("div",{className:"option",children:[(0,a.jsx)("strong",{children:u("wb.undoBack")}),(0,a.jsx)("p",{className:"small",children:f.ok?u("wb.undoBackWhat",{tasks:f.tasks.map(e=>"“".concat(e.title,"”")).join(", ")}):f.problem}),(0,a.jsx)("button",{type:"button",disabled:x||!f.ok,onClick:()=>void k("back"),children:u("wb.undoBackGo")})]}),b&&(0,a.jsx)("p",{className:"err small",children:b}),(0,a.jsx)("p",{className:"muted small",children:u("wb.undoKept")})]})}var C=t(1701),I=t(4811);function S(e){var s,t;let{session:l,onOpen:c,onChange:d}=e,{t:u}=(0,o.kj)(),h=(0,I.p)(),[m,b]=(0,n.useState)(""),[p,x]=(0,n.useState)(!1),j=l.tasks.filter(e=>"queued"===e.status).length,k=l.tasks.filter(e=>"done"===e.status).length,v="idle"===l.status,f=async e=>{if("unattended"!==e||h||await (0,w.Z)(u("session.unattendedConfirm"))){x(!0),b("");try{var s;let t=await (0,C.L)({sessionIds:[l.id],mode:e,start:s=>r.FH.start(l.id,e,l.planName,s)});t.started?b(u("unattended"===e?"session.startedAuto":"session.startedStep")):t.reply&&b(u("session.notStarted",{reason:null!=(s=t.reply.reason)?s:""}))}catch(e){b(e.message)}finally{x(!1),d()}}};return(0,a.jsxs)("article",{className:"wb-task","aria-labelledby":"wb-s-".concat(l.id),children:[(0,a.jsxs)("header",{className:"wb-task-head",children:[(0,a.jsx)("span",{className:"wb-ico","aria-hidden":"true",children:"▤"}),(0,a.jsxs)("div",{className:"grow",children:[(0,a.jsx)("h2",{id:"wb-s-".concat(l.id),children:l.name}),(0,a.jsxs)("p",{className:"muted small",children:[u("wb.sessionLine",{done:k,all:l.tasks.length,queued:j}),(null==(s=l.vcs)?void 0:s.enabled)?" \xb7 ".concat("per-task"===l.vcs.branchMode?u("wb.perTask"):u("wb.perSession")):" \xb7 ".concat(u("wb.noVcs")),l.modelInUse||l.model?" \xb7 ".concat(null!=(t=l.modelInUse)?t:l.model):""]})]}),(0,a.jsx)(i(),{className:"button-link plain small",href:(0,r.aT)(l.id),children:u("wb.sessionSettings")})]}),(0,a.jsxs)("div",{className:"wb-actions",role:"toolbar","aria-label":u("wb.waysOn"),children:[v?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("button",{type:"button",className:"primary",disabled:p||0===j,onClick:()=>void f("unattended"),children:u("session.run",{n:j})}),(0,a.jsx)("button",{type:"button",disabled:p||0===j,onClick:()=>void f("confirm"),children:u("session.runStep")})]}):(0,a.jsx)("button",{type:"button",className:"danger",disabled:p,onClick:()=>void r.FH.stop(l.id).then(()=>b(u("wb.stopping"))).catch(e=>b(e.message)).finally(d),children:u("wb.stopSession")}),(0,a.jsx)(i(),{className:"button-link",href:(0,r.aT)(l.id,"new-task"),children:u("wb.addTask")})]}),0===j&&v&&(0,a.jsx)("p",{className:"muted small",children:u("wb.nothingQueued")}),m&&(0,a.jsx)("p",{className:"notice small",role:"status",children:m}),(0,a.jsx)("ol",{className:"wb-list wb-session-tasks",children:l.tasks.map(e=>(0,a.jsxs)("li",{children:[(0,a.jsxs)("button",{type:"button",className:"linkish",onClick:()=>c({kind:"task",sessionId:l.id,taskId:e.id}),children:[(0,a.jsx)(et,{status:e.status})," ",e.title]}),e.reason&&"done"!==e.status&&"queued"!==e.status?(0,a.jsxs)("span",{className:"muted small",children:[" — ",e.reason.slice(0,160)]}):null]},e.id))})]})}function F(e){var s;let{sessionId:t,path:l,taskId:i}=e,{t:c}=(0,o.kj)(),[d,u]=(0,n.useState)(null),[h,m]=(0,n.useState)("");if((0,n.useEffect)(()=>{let e=!0;return m(""),(t?r.FH.repoFile(t,l,i):r.FH.workspaceFile(l).then(e=>({...e,label:""}))).then(s=>e&&u(s)).catch(s=>e&&m(s.message)),()=>{e=!1}},[t,l,i,c]),h)return(0,a.jsx)("p",{className:"err small",children:h});if(!d)return(0,a.jsx)("p",{className:"muted small",children:c("wb.loading")});let b=(null!=(s=d.text)?s:"").split("\n");return(0,a.jsxs)("div",{className:"wb-file",children:[(0,a.jsx)("p",{className:"muted small",children:t?c("wb.fileAt",{path:d.path,ref:d.label}):c("wb.fileOnDisk",{path:d.path})}),d.binary?(0,a.jsx)("p",{className:"muted",children:c("wb.binary")}):d.tooLarge?(0,a.jsx)("p",{className:"muted",children:c("wb.tooLarge")}):(0,a.jsx)("pre",{className:"wb-code","aria-label":d.path,children:b.map((e,s)=>(0,a.jsxs)("span",{className:"wb-line",children:[(0,a.jsx)("span",{className:"wb-ln","aria-hidden":"true",children:s+1}),e,"\n"]},s))})]})}var O=t(7908);let T="cop.chat.thread",P="cop.chat.mode",H=(e,s)=>{try{s?window.localStorage.setItem(e,s):window.localStorage.removeItem(e)}catch(e){}},E=e=>{try{var s;return null!=(s=window.localStorage.getItem(e))?s:""}catch(e){return""}};function A(e){var s,t,l;let{workspace:i,composeAsk:d,onOpenFile:u,onChange:h,onOpenFolder:m,onTurn:b}=e,{t:p}=(0,o.kj)(),x=(0,I.p)(),[j,k]=(0,n.useState)([]),[v,f]=(0,n.useState)(""),[N,g]=(0,n.useState)(null),[y,S]=(0,n.useState)("confirm"),[F,A]=(0,n.useState)(""),[L,R]=(0,n.useState)(!1),[q,K]=(0,n.useState)(""),[W,z]=(0,n.useState)([]),B=(0,n.useRef)(null),U=!!N&&"idle"!==N.status;(0,n.useEffect)(()=>{f(E(T));let e=E(P);"confirm"===e||"unattended"===e?S(e):r.FH.settings().then(e=>{var s;return S((null==(s=e.raw.execution)?void 0:s.mode)==="unattended"?"unattended":"confirm")}).catch(()=>void 0)},[]),(0,n.useEffect)(()=>{var e;d>0&&(null==(e=B.current)||e.focus())},[d]);let Z=(0,n.useCallback)(()=>r.FH.chatThreads().then(k).catch(()=>void 0),[]);(0,c.z)(Z,5e3);let _=(0,n.useCallback)(()=>v?r.FH.session(v).then(e=>g("chat"===e.kind?e:null)).catch(()=>{g(null),f(""),H(T,"")}):Promise.resolve(g(null)),[v]);(0,n.useEffect)(()=>{_()},[_]),(0,c.z)(_,U?1500:5e3,!!v),(0,c.z)(()=>v&&U?r.FH.approvals(v).then(z).catch(()=>void 0):Promise.resolve(z([])),1500,!!v);let Y=e=>{f(e),H(T,e),K("")},G=async()=>{let e=F.trim();if(e&&!L){R(!0),K("");try{var s;let t=await r.FH.chatSend(e,v||void 0);if(A(""),Y(t.threadId),t.noted)return void K(p("chat.noted"));if("unattended"===y&&t.needsStart&&!x&&!await (0,w.Z)(p("session.unattendedConfirm")))return void K(p("chat.notStartedYet"));let a=t.needsStart?(await (0,C.L)({sessionIds:[t.threadId],mode:y,start:e=>r.FH.start(t.threadId,y,void 0,e)})).reply:await r.FH.start(t.threadId,y);a&&!a.started&&K(p("chat.notStarted",{reason:null!=(s=a.reason)?s:""}))}catch(e){K(e.message)}finally{R(!1),_(),Z(),h()}}},J=null==N?void 0:N.tasks.at(-1);(0,n.useEffect)(()=>{b(N&&J?{sessionId:N.id,taskId:J.id}:null)},[null==N?void 0:N.id,null==J?void 0:J.id]);let{ref:V}=(0,O.U)(!0,"".concat(null!=(s=null==N?void 0:N.tasks.length)?s:0,":").concat(null!=(t=null==J?void 0:J.status)?t:"",":").concat(null!=(l=null==J?void 0:J.iterations)?l:0));return(0,a.jsxs)("div",{className:"cs",children:[(0,a.jsxs)("div",{className:"cs-head",children:[(0,a.jsx)("label",{htmlFor:"cs-thread",className:"sr-only",children:p("chat.thread")}),(0,a.jsxs)("select",{id:"cs-thread",value:v,onChange:e=>Y(e.target.value),children:[(0,a.jsx)("option",{value:"",children:p("chat.newThread")}),j.map(e=>(0,a.jsx)("option",{value:e.id,children:e.name.replace(/^chat: /,"")},e.id))]}),(0,a.jsx)("button",{type:"button",className:"wb-icon-btn",onClick:()=>{var e;Y(""),g(null),null==(e=B.current)||e.focus()},title:p("chat.newChat"),"aria-label":p("chat.newChat"),children:"+"})]}),(0,a.jsxs)("div",{className:"cs-body",ref:V,"aria-live":"polite",children:[N?N.tasks.map(e=>(0,a.jsx)(D,{session:N,task:e,approvals:W.filter(s=>s.taskId===e.id),onOpenFile:u},e.id)):(0,a.jsx)(M,{workspace:i,onPick:e=>{var s;A(e),null==(s=B.current)||s.focus()},onOpenFolder:m}),q&&(0,a.jsx)("p",{className:"cs-system",role:"status",children:q})]}),(0,a.jsxs)("div",{className:"cs-compose",children:[(0,a.jsx)("label",{htmlFor:"cs-input",className:"sr-only",children:p("chat.input")}),(0,a.jsx)("textarea",{id:"cs-input",ref:B,value:F,onChange:e=>A(e.target.value),placeholder:U?p("chat.placeholderRunning"):(null==i?void 0:i.ok)?p("chat.placeholder",{folder:i.name}):p("chat.placeholderNoFolder"),disabled:L||!(null==i?void 0:i.ok),onKeyDown:e=>{"Enter"!==e.key||e.shiftKey||e.nativeEvent.isComposing||(e.preventDefault(),G())}}),(0,a.jsxs)("div",{className:"cs-bar",children:[(0,a.jsx)("label",{htmlFor:"cs-mode",className:"sr-only",children:p("chat.mode")}),(0,a.jsxs)("select",{id:"cs-mode",value:y,onChange:e=>{let s=e.target.value;S(s),H(P,s)},disabled:U,title:p("chat.modeWhy"),children:[(0,a.jsx)("option",{value:"confirm",children:p("chat.modeAsk")}),(0,a.jsx)("option",{value:"unattended",children:p("chat.modeAuto")})]}),(0,a.jsx)("span",{className:"grow"}),U&&(0,a.jsx)("button",{type:"button",className:"danger",onClick:()=>{N&&r.FH.stop(N.id).then(()=>K(p("chat.stopping"))).catch(e=>K(e.message))},children:p("chat.stop")}),(0,a.jsx)("button",{type:"button",className:"primary",disabled:L||!F.trim()||!(null==i?void 0:i.ok),onClick:()=>void G(),title:p("chat.sendWhy"),children:U?p("chat.sendNote"):p("chat.send")})]})]})]})}function M(e){var s;let{workspace:t,onPick:n,onOpenFolder:l}=e,{t:i}=(0,o.kj)();if(!t)return(0,a.jsx)("p",{className:"muted small",children:i("wb.loading")});if(!t.ok)return(0,a.jsxs)("div",{className:"cs-welcome",children:[(0,a.jsx)("p",{children:t.problem}),(0,a.jsx)("button",{type:"button",className:"primary",onClick:l,children:i("chat.openFolder")})]});let r=[i("chat.example1"),i("chat.example2"),i("chat.example3")];return(0,a.jsxs)("div",{className:"cs-welcome",children:[(0,a.jsx)("h3",{children:i("chat.welcome",{folder:t.name})}),(0,a.jsx)("p",{className:"muted small",children:i("chat.welcomeWhy",{dir:t.dir,branch:null!=(s=t.branch)?s:"—"})}),(0,a.jsx)("ul",{className:"cs-examples",children:r.map(e=>(0,a.jsx)("li",{children:(0,a.jsx)("button",{type:"button",className:"linkish",onClick:()=>n(e),children:e})},e))})]})}function D(e){var s,t,l,i;let{session:d,task:u,approvals:h,onOpenFile:m}=e,{t:b}=(0,o.kj)(),[p,w]=(0,n.useState)(null),j="running"===u.status||"waiting-approval"===u.status,v=()=>u.startedAt||j?r.FH.taskStory(d.id,u.id,u.runId).then(w).catch(()=>void 0):Promise.resolve();(0,n.useEffect)(()=>{v()},[u.id,u.runId,u.status]),(0,c.z)(v,j?1500:6e4,j);let f=[],N=e=>e.forEach(e=>"review"===e.kind?N(e.entries):f.push(e));return N(null!=(l=null==p?void 0:p.entries)?l:[]),(0,a.jsxs)("section",{className:"cs-turn","aria-label":b("chat.turn",{text:u.title}),children:[(0,a.jsx)("div",{className:"cs-user",children:(0,a.jsx)(k.s,{text:u.prompt})}),"queued"===u.status&&(0,a.jsx)("p",{className:"muted small cs-system",children:b("idle"===d.status?"chat.queued":"chat.waitingTurn")}),f.map((e,s)=>{var t;return"reply"===e.kind?(null==(t=e.notes)?void 0:t.trim())?(0,a.jsx)("div",{className:"cs-bot",children:(0,a.jsx)(k.s,{text:e.notes})},s):null:"step"===e.kind?(0,a.jsx)(L,{step:e},s):null}),h.map(e=>(0,a.jsx)(R,{approval:e},e.id)),j&&(0,a.jsxs)("p",{className:"cs-working",role:"status",children:[(0,a.jsx)("span",{className:"wb-live","aria-hidden":"true"})," ",b("chat.working",{n:u.iterations})]}),!j&&"queued"!==u.status&&(0,a.jsxs)("div",{className:"cs-end s-".concat(u.status),children:[(0,a.jsx)(et,{status:u.status}),(0,a.jsxs)("div",{className:"grow",children:[u.summary?(0,a.jsx)(k.s,{text:u.summary}):null,"done"!==u.status&&u.reason?(0,a.jsx)("p",{className:"small",children:u.reason}):null]})]}),(null!=(i=null==(t=u.vcs)||null==(s=t.files)?void 0:s.length)?i:0)>0&&!j&&(0,a.jsxs)("div",{className:"cs-files",children:[(0,a.jsx)("span",{className:"small",children:b("chat.changed",{n:u.vcs.files.length})}),u.vcs.files.slice(0,12).map(e=>(0,a.jsxs)("button",{type:"button",className:"cs-file",onClick:()=>m(e.path),title:e.path,children:[e.path.split("/").pop()," ",(0,a.jsx)("span",{className:"muted",children:e.added>=0?"+".concat(e.added," −").concat(e.removed):""})]},e.path)),(0,a.jsx)(x.C,{sessionId:d.id,taskId:u.id,runId:u.runId,title:u.title,files:u.vcs.files.length})]})]})}function L(e){let{step:s}=e,{t}=(0,o.kj)(),l=!s.outcome,[i,r]=(0,n.useState)(null),c=null!=i?i:l||s.failed;return(0,a.jsxs)("div",{className:"cs-cmd".concat(s.failed?" bad":""),children:[(0,a.jsxs)("button",{type:"button",className:"cs-cmd-head","aria-expanded":c,onClick:()=>r(!c),children:[(0,a.jsx)("span",{className:"cs-cmd-ico","aria-hidden":"true",children:l?"⟳":s.failed?"✗":"✓"}),(0,a.jsx)("code",{className:"wb-row-name",children:s.command}),(0,a.jsx)("span",{className:"muted small",children:l?t("chat.running"):void 0!==s.exitCode?t("chat.exit",{code:s.exitCode}):s.outcome})]}),c&&s.output&&(0,a.jsx)("pre",{className:"cs-out",children:s.output})]})}function R(e){let{approval:s}=e,{t}=(0,o.kj)(),[l,i]=(0,n.useState)(!1),c=async e=>{i(!0);try{await r.FH.decide(s.id,e)}finally{i(!1)}};return s.plan||s.model?(0,a.jsx)("p",{className:"cs-system small",children:t("chat.lookAbove")}):(0,a.jsxs)("div",{className:"cs-ask",role:"group","aria-label":t("chat.askTitle"),children:[(0,a.jsx)("p",{className:"small",children:(0,a.jsx)("strong",{children:t("chat.askTitle")})}),(0,a.jsx)("pre",{className:"cs-out",children:s.description}),(0,a.jsxs)("div",{className:"row",children:[(0,a.jsx)("button",{type:"button",className:"primary",disabled:l,onClick:()=>void c("run"),children:t("chat.askRun")}),!s.network&&(0,a.jsx)("button",{type:"button",disabled:l,onClick:()=>void c("run-all"),children:t("chat.askRunAll")}),(0,a.jsx)("button",{type:"button",disabled:l,onClick:()=>void c("skip"),children:t("chat.askSkip")})]})]})}function q(e){let{session:s,task:t,sessions:l,onChange:c}=e,{t:d}=(0,o.kj)(),[u,h]=(0,n.useState)(""),[m,b]=(0,n.useState)(t?"task":s?"session":"all"),[p,w]=(0,n.useState)(""),[x,j]=(0,n.useState)(""),[k,v]=(0,n.useState)(null),[f,N]=(0,n.useState)(""),[g,y]=(0,n.useState)(!1),C="task"!==m||t?"session"!==m||s?m:"all":s?"session":"all",I=async()=>{try{let e="task"===C&&s&&t?{sessionIds:[s.id],taskIds:[t.id],note:u}:"session"===C&&s?{sessionIds:[s.id],note:u}:{sessionIds:l.map(e=>e.id),note:u};return(await r.FH.kerriganReport(e)).text}catch(e){return w(e.message),null}},S=async()=>{let e=await I();if(e)try{await navigator.clipboard.writeText(e),w(d("wb.kCopied",{n:e.length}))}catch(e){w(d("wb.kCopyFailed"))}},F=async()=>{let e=await I();if(!e)return;let s=URL.createObjectURL(new Blob([e],{type:"text/plain;charset=utf-8"})),t=document.createElement("a");t.href=s,t.download="what-happened-".concat(new Date().toISOString().slice(0,16).replace(/[:T]/g,"-"),".txt"),t.click(),URL.revokeObjectURL(s),w(d("wb.kSaved"))},O=async()=>{y(!0),N("");try{v(await r.FH.checkChanges(x))}catch(e){N(e.message)}finally{y(!1)}},T=async()=>{y(!0);try{var e;let s=await r.FH.applyChanges(x);s.ok?(N(d("wb.kApplied",{n:s.applied.length})),v(null),j("")):N(null!=(e=s.problem)?e:s.check&&!s.check.ok?s.check.issues.map(e=>e.message).join(" "):"")}catch(e){N(e.message)}finally{y(!1),c()}},P=!!k&&!k.ok&&/"sessions"\s*:/.test(x)&&!/"changes"\s*:/.test(x);return(0,a.jsxs)("div",{className:"wb-kerrigan",children:[(0,a.jsxs)("section",{children:[(0,a.jsx)("h3",{children:d("wb.kTell")}),(0,a.jsx)("p",{className:"muted small",children:d("wb.kTellWhy")}),(0,a.jsxs)("fieldset",{className:"wb-scope",children:[(0,a.jsx)("legend",{className:"sr-only",children:d("wb.kScope")}),t&&(0,a.jsxs)("label",{children:[(0,a.jsx)("input",{type:"radio",name:"wb-k-scope",checked:"task"===C,onChange:()=>b("task")})," ",d("wb.kScopeTask")]}),s&&(0,a.jsxs)("label",{children:[(0,a.jsx)("input",{type:"radio",name:"wb-k-scope",checked:"session"===C,onChange:()=>b("session")})," ",d("wb.kScopeSession")]}),(0,a.jsxs)("label",{children:[(0,a.jsx)("input",{type:"radio",name:"wb-k-scope",checked:"all"===C,onChange:()=>b("all")})," ",d("wb.kScopeAll")]})]}),(0,a.jsx)("label",{htmlFor:"wb-k-note",children:d("wb.kNote")}),(0,a.jsx)("textarea",{id:"wb-k-note",value:u,onChange:e=>h(e.target.value),placeholder:d("wb.kNotePlaceholder"),style:{minHeight:90}}),(0,a.jsxs)("div",{className:"row",children:[(0,a.jsx)("button",{type:"button",className:"primary",onClick:()=>void S(),children:d("wb.kCopy")}),(0,a.jsx)("button",{type:"button",onClick:()=>void F(),children:d("wb.kSave")}),(0,a.jsx)(i(),{className:"button-link plain small",href:"/import",children:d("wb.kBrief")})]}),p&&(0,a.jsx)("p",{className:"small",role:"status",children:p})]}),(0,a.jsxs)("section",{children:[(0,a.jsx)("h3",{children:d("wb.kAnswer")}),(0,a.jsx)("label",{htmlFor:"wb-k-answer",children:d("wb.kPaste")}),(0,a.jsx)("textarea",{id:"wb-k-answer",value:x,onChange:e=>{j(e.target.value),v(null)},style:{minHeight:110}}),(0,a.jsxs)("div",{className:"row",children:[(0,a.jsx)("button",{type:"button",disabled:g||!x.trim(),onClick:()=>void O(),children:d("wb.kCheck")}),(null==k?void 0:k.ok)&&(0,a.jsx)("button",{type:"button",className:"primary",disabled:g,onClick:()=>void T(),children:d("wb.kApply",{n:k.changes.length})})]}),(null==k?void 0:k.ok)&&(0,a.jsxs)(a.Fragment,{children:[k.notes&&(0,a.jsx)("p",{className:"small",children:k.notes}),(0,a.jsx)("ol",{className:"wb-list small",children:k.changes.map(e=>(0,a.jsx)("li",{children:e.says},e.index))}),k.warnings.map(e=>(0,a.jsx)("p",{className:"muted small",children:e},e))]}),k&&!k.ok&&(0,a.jsx)(a.Fragment,{children:P?(0,a.jsxs)("p",{className:"small",children:[d("wb.kIsPlan")," ",(0,a.jsx)(i(),{href:"/import",children:d("wb.kImportPage")})]}):(0,a.jsx)("ul",{className:"wb-list small",children:k.issues.map(e=>(0,a.jsxs)("li",{className:"bad",children:[e.path&&(0,a.jsx)("code",{children:e.path})," ",e.message]},"".concat(e.path).concat(e.message)))})}),f&&(0,a.jsx)("p",{className:"notice small",role:"status",children:f})]})]})}function K(e){let{tab:s,onTab:t,session:n,task:l,sessions:i,workspace:r,composeAsk:c,onOpenFile:d,onOpenFolder:u,onTurn:h,onChange:m,onClose:b}=e,{t:p}=(0,o.kj)();return(0,a.jsxs)("div",{className:"wb-chat-inner",children:[(0,a.jsxs)("div",{className:"wb-chat-tabs",role:"tablist","aria-label":p("wb.chatPanel"),children:[(0,a.jsx)("button",{type:"button",role:"tab","aria-selected":"chat"===s,className:"chat"===s?"on":"",onClick:()=>t("chat"),children:p("wb.chatTab")}),(0,a.jsx)("button",{type:"button",role:"tab","aria-selected":"kerrigan"===s,className:"kerrigan"===s?"on":"",onClick:()=>t("kerrigan"),children:p("wb.kerriganTab")}),(0,a.jsx)("span",{className:"grow"}),(0,a.jsx)("button",{type:"button",className:"wb-icon-btn","aria-label":p("wb.toggleChat"),title:p("wb.toggleChat"),onClick:b,children:"\xd7"})]}),"kerrigan"===s?(0,a.jsx)(q,{session:n,task:l,sessions:i,onChange:m}):(0,a.jsx)(A,{workspace:r,composeAsk:c,onOpenFile:d,onChange:m,onOpenFolder:u,onTurn:h})]})}function W(e){let{open:s,onToggle:t,tab:n,onTab:l,session:i,task:r,onOpenTask:c}=e,{t:d}=(0,o.kj)(),u=i?function(e){let s=[];return e.tasks.forEach((t,a)=>{var n,l,i,r;let c="".concat(a+1,". ").concat(t.title);for(let a of null!=(i=t.checkResults)?i:[])a.passed||s.push({sessionId:e.id,taskId:t.id,kind:"error",text:"".concat(a.name,": ").concat(a.detail.slice(0,160)),where:c});if((null==(n=t.review)?void 0:n.verdict)==="fail")for(let a of null!=(r=t.review.findings)?r:[])s.push({sessionId:e.id,taskId:t.id,kind:"error",text:a.what.slice(0,200),where:a.where?"".concat(c," \xb7 ").concat(a.where):c});["failed","blocked","limit-reached","aborted"].includes(t.status)&&t.reason&&s.push({sessionId:e.id,taskId:t.id,kind:"warn",text:t.reason.slice(0,200),where:c}),(null==(l=t.vcs)?void 0:l.problem)&&s.push({sessionId:e.id,taskId:t.id,kind:"warn",text:t.vcs.problem.slice(0,200),where:c})}),s}(i):[];return(0,a.jsxs)("section",{className:"wb-bottom","aria-label":d("wb.panel"),children:[(0,a.jsxs)("div",{className:"wb-bottom-tabs",role:"tablist","aria-label":d("wb.panel"),children:[["terminal","problems","output"].map(e=>(0,a.jsxs)("button",{type:"button",role:"tab","aria-selected":s&&n===e,className:s&&n===e?"on":"",onClick:()=>l(e),children:[d("terminal"===e?"wb.terminal":"problems"===e?"wb.problems":"wb.output"),"problems"===e&&u.length>0&&(0,a.jsx)("span",{className:"wb-badge",children:u.length})]},e)),(0,a.jsx)("span",{className:"grow"}),(0,a.jsx)("button",{type:"button",className:"wb-icon-btn","aria-label":d("wb.cmdPanel"),title:"".concat(d("wb.cmdPanel")," (Ctrl+J)"),onClick:t,children:s?"▾":"▴"})]}),s&&(0,a.jsx)("div",{className:"wb-bottom-body",role:"tabpanel",children:"terminal"===n?(0,a.jsx)(z,{session:i,task:r}):"problems"===n?0===u.length?(0,a.jsx)("p",{className:"muted small wb-pad",children:i?d("wb.noProblems"):d("wb.pickSession")}):(0,a.jsx)("ul",{className:"wb-problems",children:u.map((e,s)=>(0,a.jsx)("li",{children:(0,a.jsxs)("button",{type:"button",className:"wb-row",onClick:()=>c(e.sessionId,e.taskId),children:[(0,a.jsx)("span",{className:"wb-sev ".concat(e.kind),"aria-hidden":"true",children:"error"===e.kind?"✗":"⚠"}),(0,a.jsx)("span",{className:"wb-row-name",children:e.text}),(0,a.jsx)("span",{className:"muted",children:e.where})]})},s))}):(0,a.jsx)(B,{session:i})})]})}function z(e){var s,t;let{session:l,task:i}=e,{t:d}=(0,o.kj)(),[u,h]=(0,n.useState)(null),m=(null==i?void 0:i.status)==="running"||(null==i?void 0:i.status)==="waiting-approval",{ref:b}=(0,O.U)(!!m,null!=(s=null==u?void 0:u.entries.length)?s:0),p=()=>l&&i&&(i.startedAt||m)?r.FH.taskStory(l.id,i.id,i.runId).then(h).catch(()=>void 0):Promise.resolve();if((0,n.useEffect)(()=>{h(null),p()},[null==i?void 0:i.id,null==i?void 0:i.runId]),(0,c.z)(p,m?2e3:15e3,!!l&&!!i),!i)return(0,a.jsx)("p",{className:"muted small wb-pad",children:d("wb.pickTask")});let w=[],x=e=>e.forEach(e=>"step"===e.kind?w.push(e):"review"===e.kind?x(e.entries):void 0);return(x(null!=(t=null==u?void 0:u.entries)?t:[]),0===w.length)?(0,a.jsx)("p",{className:"muted small wb-pad",children:u?d("wb.noSteps"):d("wb.loading")}):(0,a.jsx)("div",{ref:b,className:"wb-terminal","aria-live":"off",children:w.map((e,s)=>(0,a.jsxs)("div",{className:e.failed?"bad":"",children:[(0,a.jsxs)("div",{className:"wb-cmd",children:[(0,a.jsx)("span",{"aria-hidden":"true",children:"$ "}),e.command,(0,a.jsxs)("span",{className:"muted",children:[" ",e.outcome?"".concat(e.outcome).concat(void 0!==e.exitCode?" (".concat(e.exitCode,")"):""):d("wb.runningNow")]})]}),e.output&&(0,a.jsx)("pre",{children:e.output})]},s))})}function B(e){let{session:s}=e,{t}=(0,o.kj)(),l=(0,o.W3)(),[i,d]=(0,n.useState)([]),{ref:u}=(0,O.U)(!0,i.length),h=()=>s?r.FH.sessionEvents(s.id).then(d).catch(()=>void 0):Promise.resolve();return((0,n.useEffect)(()=>{d([]),h()},[null==s?void 0:s.id]),(0,c.z)(h,3e3,!!s),s)?(0,a.jsx)("div",{ref:u,className:"wb-terminal",children:0===i.length?(0,a.jsx)("p",{className:"muted small",children:t("wb.noEvents")}):i.map((e,s)=>{var t;return(0,a.jsxs)("div",{className:"error"===e.level?"bad":"warn"===e.level?"warnline":"",children:[(0,a.jsxs)("span",{className:"muted",children:[l(e.at)," "]}),null!=(t=e.message)?t:e.type]},s)})}):(0,a.jsx)("p",{className:"muted small wb-pad",children:t("wb.pickSession")})}var U=t(3374);function Z(e){var s,t,l,i;let{sessions:d,session:u,task:h,workspace:m,onOpenTask:b}=e,{t:p}=(0,o.kj)(),w=(0,U.c)(!0,5e3),[x,j]=(0,n.useState)(""),[k,v]=(0,n.useState)(0),[f,N]=(0,n.useState)({iterations:60,minutes:240});(0,n.useEffect)(()=>{r.FH.settings().then(e=>{var s,t,a;let n=null!=(s=e.raw.limits)?s:{};N({iterations:null!=(t=n.maxIterations)?t:60,minutes:null!=(a=n.maxRunMinutes)?a:240})}).catch(()=>void 0)},[]),(0,n.useEffect)(()=>{var e;j(""),(null==u||null==(e=u.vcs)?void 0:e.enabled)&&r.FH.vcsStatus(u.id).then(e=>{var s;return j(null!=(s=e.branch)?s:"")}).catch(()=>void 0)},[null==u?void 0:u.id,null==u?void 0:u.status,null==h?void 0:h.status]),(0,c.z)(()=>r.FH.approvals().then(e=>v(e.length)).catch(()=>void 0),3e3);let g=d.find(e=>"idle"!==e.status),y=null==g?void 0:g.tasks.find(e=>"running"===e.status||"waiting-approval"===e.status),C=(null==y?void 0:y.startedAt)?Math.floor((w-Date.parse(y.startedAt))/6e4):0;return(0,a.jsxs)("footer",{className:"wb-statusbar","aria-label":p("wb.status"),children:[!(null==u||null==(s=u.vcs)?void 0:s.enabled)&&(null==m?void 0:m.ok)&&(0,a.jsxs)("span",{title:m.dir,children:[(0,a.jsx)("span",{"aria-hidden":"true",children:"⎇ "}),m.branch?"".concat(m.name," \xb7 ").concat(m.branch):m.name]}),(null==u||null==(t=u.vcs)?void 0:t.enabled)&&(0,a.jsxs)("span",{title:p("wb.branchNow"),children:[(0,a.jsx)("span",{"aria-hidden":"true",children:"⎇ "}),x||"…"]}),g&&y?(0,a.jsxs)("button",{type:"button",className:"wb-status-btn",onClick:()=>b(g.id,y.id),title:p("wb.openRunning"),children:[(0,a.jsx)("span",{className:"wb-live","aria-hidden":"true"})," ",p("wb.runningLine",{session:g.name,task:y.title,n:y.iterations,max:f.iterations,m:C,maxm:f.minutes})]}):(0,a.jsx)("span",{children:p("wb.idle")}),(0,a.jsx)("span",{className:"grow"}),k>0&&(0,a.jsx)("button",{type:"button",className:"wb-status-btn warn",onClick:()=>{var e;return null==(e=document.querySelector(".approval-banner"))?void 0:e.scrollIntoView({block:"start"})},children:p("wb.waiting",{n:k})}),u&&(0,a.jsx)("span",{title:p("wb.modelNow"),children:null!=(i=null!=(l=u.modelInUse)?l:u.model)?i:p("wb.modelDefault")})]})}var _=t(1702);function Y(e){let{commands:s,onClose:t}=e,{t:l}=(0,o.kj)(),i=(0,_.useRouter)(),[r,c]=(0,n.useState)(""),[d,u]=(0,n.useState)(0),h=(0,n.useRef)(null);(0,n.useEffect)(()=>{var e;return null==(e=h.current)?void 0:e.focus()},[]);let m=(0,n.useMemo)(()=>{let e=r.toLowerCase().split(/\s+/).filter(Boolean);return s.filter(s=>e.every(e=>{var t;return"".concat(s.label," ").concat(null!=(t=s.hint)?t:"").toLowerCase().includes(e)})).slice(0,60)},[r,s]),b=0===m.length?-1:Math.min(d,m.length-1),p=e=>{var s;e&&(t(),e.href?i.push(e.href):null==(s=e.run)||s.call(e))};return(0,a.jsx)("div",{className:"modal-backdrop",role:"presentation",onClick:t,children:(0,a.jsxs)("div",{className:"wb-palette",role:"dialog","aria-modal":"true","aria-label":l("wb.palette"),onClick:e=>e.stopPropagation(),children:[(0,a.jsx)("input",{ref:h,type:"text",role:"combobox","aria-expanded":"true","aria-controls":"wb-palette-list","aria-activedescendant":b>=0?"wb-cmd-".concat(b):void 0,"aria-label":l("wb.palette"),placeholder:l("wb.palettePlaceholder"),value:r,onChange:e=>{c(e.target.value),u(0)},onKeyDown:e=>{"Escape"===e.key?t():"ArrowDown"===e.key?(e.preventDefault(),u(Math.min(m.length-1,b+1))):"ArrowUp"===e.key?(e.preventDefault(),u(Math.max(0,b-1))):"Enter"===e.key&&(e.preventDefault(),p(m[b]))}}),(0,a.jsxs)("ul",{id:"wb-palette-list",role:"listbox","aria-label":l("wb.palette"),children:[0===m.length&&(0,a.jsx)("li",{className:"muted small",children:l("wb.paletteNone")}),m.map((e,s)=>(0,a.jsxs)("li",{id:"wb-cmd-".concat(s),role:"option","aria-selected":s===b,className:s===b?"on":"",onMouseEnter:()=>u(s),onClick:()=>p(e),children:[(0,a.jsx)("span",{className:"wb-row-name",children:e.label}),e.hint&&(0,a.jsx)("span",{className:"muted small",children:e.hint})]},e.id))]})]})})}let G=e=>"task"===e.kind?"t:".concat(e.taskId):"session"===e.kind?"s:".concat(e.sessionId):"f:".concat(e.sessionId,":").concat(e.path),J={side:290,chat:420,bottom:240,sideOpen:!0,chatOpen:!0,bottomOpen:!0},V="cop.workbench.layout";function Q(){return(0,a.jsx)(n.Suspense,{fallback:null,children:(0,a.jsx)(X,{})})}function X(){let{t:e}=(0,o.kj)(),[s,t]=(0,n.useState)(null),[l,u]=(0,n.useState)(""),[h,m]=(0,n.useState)({}),[b,p]=(0,n.useState)([]),[w,x]=(0,n.useState)(""),[j,k]=(0,n.useState)("files"),[v,f]=(0,n.useState)(null),[N,y]=(0,n.useState)(null),[C,I]=(0,n.useState)("terminal"),[O,T]=(0,n.useState)("chat"),[P,H]=(0,n.useState)(J),[E,A]=(0,n.useState)(!1),[M,D]=(0,n.useState)(0),L=(0,n.useRef)(!1),R=(0,n.useCallback)(()=>r.FH.sessions().then(e=>{t(e),u("")}).catch(e=>u(e.message)),[]);(0,c.z)(R,3e3);let q=(0,n.useCallback)(()=>r.FH.workspace().then(f).catch(()=>void 0),[]);(0,c.z)(q,1e4);let z=(0,n.useCallback)(async()=>{try{var e;let s=await r.FH.browseFolder((null==v?void 0:v.dir)||void 0);if(!s.ok)return;let t=await r.FH.settings();await r.FH.saveSettings({...t.raw,project:{...null!=(e=t.raw.project)?e:{},rootDir:s.path}}),await q()}catch(e){u(e.message)}},[null==v?void 0:v.dir,q]);(0,n.useEffect)(()=>{var e,s;H(function(){try{let e=window.localStorage.getItem(V);return e?{...J,...JSON.parse(e)}:J}catch(e){return J}}());let t=new URLSearchParams(window.location.search),a=null!=(e=t.get("s"))?e:void 0,n=null!=(s=t.get("t"))?s:void 0;a&&m({sessionId:a,taskId:n}),L.current=!0},[]),(0,n.useEffect)(()=>{try{window.localStorage.setItem(V,JSON.stringify(P))}catch(e){}},[P]),(0,n.useEffect)(()=>{if(!L.current)return;let e=new URLSearchParams;h.sessionId&&e.set("s",h.sessionId),h.taskId&&e.set("t",h.taskId);let s=e.toString()?"/?".concat(e.toString()):"/";"".concat(window.location.pathname).concat(window.location.search)!==s&&window.history.replaceState(null,"",s)},[h]);let B=(0,n.useCallback)(e=>{p(s=>s.some(s=>G(s)===G(e))?s:[...s,e]),x(G(e)),"task"===e.kind?m({sessionId:e.sessionId,taskId:e.taskId}):m(s=>({sessionId:e.sessionId,taskId:s.sessionId===e.sessionId?s.taskId:void 0}))},[]),U=(0,n.useRef)(!1);(0,n.useEffect)(()=>{if(U.current||!s||!h.sessionId)return;let e=s.find(e=>e.id===h.sessionId);e&&(U.current=!0,h.taskId&&e.tasks.some(e=>e.id===h.taskId)?B({kind:"task",sessionId:e.id,taskId:h.taskId}):B({kind:"session",sessionId:e.id}))},[s,h,B]);let _=null==s?void 0:s.find(e=>e.id===h.sessionId),Q=null==_?void 0:_.tasks.find(e=>e.id===h.taskId),X=b.find(e=>G(e)===w),en=N?null==s?void 0:s.find(e=>e.id===N.sessionId):void 0,el=(null==X?void 0:X.kind)!=="task"&&en?en:_,ei=(null==X?void 0:X.kind)!=="task"&&en?en.tasks.find(e=>e.id===(null==N?void 0:N.taskId)):Q,er=e=>H(s=>({...s,...e}));(0,n.useEffect)(()=>{let e=e=>{if(!(e.ctrlKey||e.metaKey))return;let s=e.key.toLowerCase();"k"===s||"p"===s&&e.shiftKey?(e.preventDefault(),A(!0)):"b"!==s||e.shiftKey?"j"===s?(e.preventDefault(),er({bottomOpen:!P.bottomOpen})):"l"===s&&(e.preventDefault(),er({chatOpen:!0}),T("chat"),D(e=>e+1)):(e.preventDefault(),er({sideOpen:!P.sideOpen}))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[P]);let ec=(0,n.useMemo)(()=>{let t=[{id:"kerrigan",label:e("wb.cmdKerrigan"),run:()=>{er({chatOpen:!0}),T("kerrigan")}},{id:"chat",label:e("wb.cmdChat"),hint:"Ctrl+L",run:()=>{er({chatOpen:!0}),T("chat"),D(e=>e+1)}},{id:"side",label:e("wb.cmdSide"),hint:"Ctrl+B",run:()=>er({sideOpen:!P.sideOpen})},{id:"panel",label:e("wb.cmdPanel"),hint:"Ctrl+J",run:()=>er({bottomOpen:!P.bottomOpen})},{id:"files",label:e("wb.cmdFiles"),run:()=>{er({sideOpen:!0}),k("files")}},{id:"commits",label:e("wb.cmdCommits"),run:()=>{er({sideOpen:!0}),k("commits")}},{id:"problems",label:e("wb.cmdProblems"),run:()=>{er({bottomOpen:!0}),I("problems")}},...[["/sessions","nav.sessions"],["/history","nav.history"],["/import","nav.import"],["/defaults","nav.defaults"],["/level1","nav.level1"],["/presets","nav.presets"],["/appearance","nav.appearance"],["/system","nav.system"]].map(s=>{let[t,a]=s;return{id:"go:".concat(t),label:e("wb.cmdGo",{page:e(a)}),href:t}})];for(let a of null!=s?s:[])t.push({id:"s:".concat(a.id),label:e("wb.cmdSession",{name:a.name}),run:()=>B({kind:"session",sessionId:a.id})}),a.tasks.forEach((s,n)=>t.push({id:"t:".concat(s.id),label:"".concat(a.name," › ").concat(n+1,". ").concat(s.title),hint:e("status.".concat(s.status)),run:()=>B({kind:"task",sessionId:a.id,taskId:s.id})}));return t},[s,e,P,B]),eo={"--wb-side":P.sideOpen?"".concat(P.side,"px"):"0px","--wb-chat":P.chatOpen?"".concat(P.chat,"px"):"0px","--wb-bottom":P.bottomOpen?"".concat(P.bottom,"px"):"34px"};return(0,a.jsxs)("div",{className:"wb",style:eo,children:[(0,a.jsxs)("header",{className:"wb-top",children:[(0,a.jsx)("span",{className:"wb-brand",children:"copilot-operator"}),(0,a.jsxs)("button",{type:"button",className:"wb-search",onClick:()=>A(!0),title:e("wb.paletteWhy"),children:[(0,a.jsx)("span",{children:e("wb.palette")}),(0,a.jsx)("kbd",{children:"Ctrl+K"})]}),(0,a.jsxs)("nav",{className:"wb-menu","aria-label":e("nav.label"),children:[(0,a.jsx)(i(),{href:"/sessions",children:e("nav.sessions")}),(0,a.jsx)(i(),{href:"/history",children:e("nav.history")}),(0,a.jsx)(i(),{href:"/import",children:e("nav.import")}),(0,a.jsx)(i(),{href:"/defaults",children:e("nav.defaults")}),(0,a.jsx)(o.c5,{})]})]}),(0,a.jsxs)("div",{className:"wb-body".concat(P.sideOpen?"":" no-side").concat(P.chatOpen?"":" no-chat"),children:[(0,a.jsx)(ee,{side:j,sideOpen:P.sideOpen,onSide:e=>{e===j&&P.sideOpen?er({sideOpen:!1}):(k(e),er({sideOpen:!0}))},chatOpen:P.chatOpen,onChat:()=>er({chatOpen:!P.chatOpen})}),(0,a.jsxs)("aside",{className:"wb-side","aria-label":e("wb.explorer"),hidden:!P.sideOpen,children:[l&&!s?(0,a.jsx)("p",{className:"err small",style:{padding:10},children:l}):null,(0,a.jsx)(d,{view:j,sessions:s,selected:h,onOpen:B,onChange:()=>void R(),workspace:v,onOpenFolder:()=>void z()})]}),P.sideOpen&&(0,a.jsx)(es,{axis:"x",label:e("wb.resize"),onDrag:e=>er({side:$(P.side+e,180,560)})}),(0,a.jsxs)("section",{className:"wb-center","aria-label":e("wb.editor"),children:[(0,a.jsxs)("div",{className:"wb-tabs",role:"tablist","aria-label":e("wb.openTabs"),children:[0===b.length&&(0,a.jsx)("span",{className:"muted small wb-tabs-empty",children:e("wb.noTabs")}),b.map(t=>{var n,l;let i=G(t),r=null==s?void 0:s.find(e=>e.id===t.sessionId),c="task"===t.kind?null==r?void 0:r.tasks.find(e=>e.id===t.taskId):void 0,o="task"===t.kind?null!=(n=null==c?void 0:c.title)?n:e("wb.goneTask"):"session"===t.kind?null!=(l=null==r?void 0:r.name)?l:e("wb.goneSession"):t.path.split("/").pop();return(0,a.jsxs)("div",{className:"wb-tab".concat(i===w?" active":""),children:[(0,a.jsxs)("button",{type:"button",role:"tab","aria-selected":i===w,onClick:()=>"task"===t.kind?B(t):(x(i),m({sessionId:t.sessionId,taskId:"file"===t.kind?t.taskId:void 0})),title:"file"===t.kind?t.path:void 0,children:[c&&(0,a.jsx)(et,{status:c.status}),"file"===t.kind&&(0,a.jsx)("span",{className:"wb-ico","aria-hidden":"true",children:"≡"}),"session"===t.kind&&(0,a.jsx)("span",{className:"wb-ico","aria-hidden":"true",children:"▤"}),(0,a.jsx)("span",{className:"wb-tab-label",children:o})]}),(0,a.jsx)("button",{type:"button",className:"wb-tab-close","aria-label":e("wb.closeTab",{name:null!=o?o:""}),onClick:()=>{p(e=>{let s=e.findIndex(e=>G(e)===i),t=e.filter(e=>G(e)!==i);return i===w&&x(t[Math.max(0,s-1)]?G(t[Math.max(0,s-1)]):""),t})},children:"\xd7"})]},i)})]}),(0,a.jsx)("div",{className:"wb-editor",role:"tabpanel",children:X?"task"===X.kind?_&&Q?(0,a.jsx)(g,{session:_,task:Q,onChange:()=>void R(),onKerrigan:()=>{er({chatOpen:!0}),T("kerrigan")},onOpenFile:e=>B({kind:"file",sessionId:_.id,path:e,taskId:Q.id})}):(0,a.jsx)("p",{className:"muted",children:e("wb.goneTask")}):"session"===X.kind?(()=>{let t=null==s?void 0:s.find(e=>e.id===X.sessionId);return t?(0,a.jsx)(S,{session:t,onOpen:B,onChange:()=>void R()}):(0,a.jsx)("p",{className:"muted",children:e("wb.goneSession")})})():(0,a.jsx)(F,{sessionId:X.sessionId,path:X.path,taskId:X.taskId}):(0,a.jsx)(ea,{sessions:s,workspace:v,onOpen:B,onChat:()=>{er({chatOpen:!0}),T("chat"),D(e=>e+1)},onKerrigan:()=>{er({chatOpen:!0}),T("kerrigan")}})}),P.bottomOpen&&(0,a.jsx)(es,{axis:"y",label:e("wb.resize"),onDrag:e=>er({bottom:$(P.bottom-e,90,700)})}),(0,a.jsx)(W,{open:P.bottomOpen,onToggle:()=>er({bottomOpen:!P.bottomOpen}),tab:C,onTab:e=>{I(e),er({bottomOpen:!0})},session:el,task:ei,onOpenTask:(e,s)=>B({kind:"task",sessionId:e,taskId:s})})]}),P.chatOpen&&(0,a.jsx)(es,{axis:"x",label:e("wb.resize"),onDrag:e=>er({chat:$(P.chat-e,300,820)})}),(0,a.jsx)("aside",{className:"wb-chat","aria-label":e("wb.chatPanel"),hidden:!P.chatOpen,children:(0,a.jsx)(K,{tab:O,onTab:T,session:_,task:Q,sessions:(null!=s?s:[]).filter(e=>"chat"!==e.kind),workspace:v,composeAsk:M,onOpenFile:e=>B({kind:"file",sessionId:"",path:e}),onOpenFolder:()=>void z(),onTurn:y,onChange:()=>void R(),onClose:()=>er({chatOpen:!1})})})]}),(0,a.jsx)(Z,{sessions:null!=s?s:[],session:_,task:Q,workspace:v,onOpenTask:(e,s)=>B({kind:"task",sessionId:e,taskId:s})}),E&&(0,a.jsx)(Y,{commands:ec,onClose:()=>A(!1)})]})}let $=(e,s,t)=>Math.max(s,Math.min(t,e));function ee(e){let{side:s,sideOpen:t,onSide:n,chatOpen:l,onChat:r}=e,{t:c}=(0,o.kj)(),d=(e,l,i)=>(0,a.jsx)("button",{type:"button",className:"wb-act".concat(t&&s===e?" on":""),"aria-pressed":t&&s===e,"aria-label":l,title:l,onClick:()=>n(e),children:(0,a.jsx)("svg",{viewBox:"0 0 24 24",width:"22",height:"22",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:i})});return(0,a.jsxs)("nav",{className:"wb-activity","aria-label":c("wb.views"),children:[d("tasks",c("wb.viewTasks"),(0,a.jsx)("path",{d:"M4 6h16M4 12h16M4 18h10"})),d("files",c("wb.viewFiles"),(0,a.jsx)("path",{d:"M4 4h6l2 2h8v14H4z"})),d("commits",c("wb.viewCommits"),(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("circle",{cx:"12",cy:"12",r:"3"}),(0,a.jsx)("path",{d:"M12 3v6M12 15v6"})]})),(0,a.jsx)("span",{className:"grow"}),(0,a.jsx)("button",{type:"button",className:"wb-act".concat(l?" on":""),"aria-pressed":l,"aria-label":c("wb.toggleChat"),title:"".concat(c("wb.toggleChat")," (Ctrl+L)"),onClick:r,children:(0,a.jsx)("svg",{viewBox:"0 0 24 24",width:"22",height:"22",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinejoin:"round","aria-hidden":"true",children:(0,a.jsx)("path",{d:"M4 5h16v11H9l-5 4z"})})}),(0,a.jsx)(i(),{className:"wb-act",href:"/defaults","aria-label":c("nav.defaults"),title:c("nav.defaults"),children:(0,a.jsxs)("svg",{viewBox:"0 0 24 24",width:"22",height:"22",fill:"none",stroke:"currentColor",strokeWidth:"1.8","aria-hidden":"true",children:[(0,a.jsx)("circle",{cx:"12",cy:"12",r:"3"}),(0,a.jsx)("path",{d:"M12 2v3M12 19v3M2 12h3M19 12h3M5 5l2 2M17 17l2 2M5 19l2-2M17 7l2-2"})]})})]})}function es(e){let{axis:s,label:t,onDrag:l}=e,i=(0,n.useRef)(null);return(0,a.jsx)("div",{className:"wb-split ".concat(s),role:"separator","aria-orientation":"x"===s?"vertical":"horizontal","aria-label":t,tabIndex:0,onPointerDown:e=>{i.current="x"===s?e.clientX:e.clientY,e.target.setPointerCapture(e.pointerId)},onPointerMove:e=>{if(null===i.current)return;let t="x"===s?e.clientX:e.clientY;l(t-i.current),i.current=t},onPointerUp:()=>i.current=null,onKeyDown:e=>{let t=e.shiftKey?40:12;("x"===s&&"ArrowLeft"===e.key||"y"===s&&"ArrowUp"===e.key)&&l(-t),("x"===s&&"ArrowRight"===e.key||"y"===s&&"ArrowDown"===e.key)&&l(t)}})}function et(e){var s;let{status:t}=e,{t:n}=(0,o.kj)();return(0,a.jsx)("span",{className:"wb-status s-".concat(t),title:n("status.".concat(t)),"aria-label":n("status.".concat(t)),role:"img",children:null!=(s=({done:"✓",failed:"✗",blocked:"⊘","limit-reached":"⏸",aborted:"■",queued:"○",running:"●","waiting-approval":"◐"})[t])?s:"\xb7"})}function ea(e){let{sessions:s,workspace:t,onOpen:n,onChat:l,onKerrigan:r}=e,{t:c}=(0,o.kj)(),d=(null!=s?s:[]).filter(e=>"chat"!==e.kind),u=d.flatMap(e=>e.tasks.filter(e=>["failed","blocked","limit-reached","aborted","waiting-approval"].includes(e.status)).map(s=>({s:e,x:s}))),h=d.reduce((e,s)=>e+s.tasks.filter(e=>"queued"===e.status).length,0);return(0,a.jsxs)("div",{className:"wb-welcome",children:[(0,a.jsx)("h2",{children:(null==t?void 0:t.ok)?t.name:c("wb.welcome")}),(0,a.jsx)("p",{className:"muted",children:(null==t?void 0:t.ok)?c("wb.welcomeChat",{dir:t.dir}):c("wb.welcomeWhy")}),(0,a.jsxs)("div",{className:"row",children:[(0,a.jsx)("button",{type:"button",className:"primary",onClick:l,children:c("wb.startChat")}),(0,a.jsx)(i(),{className:"button-link",href:"/import",children:c("wb.startPlan")}),(0,a.jsx)("button",{type:"button",onClick:r,children:c("wb.askKerrigan")})]}),u.length>0&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("h3",{children:c("wb.needsYou",{n:u.length})}),(0,a.jsx)("ul",{className:"wb-list",children:u.slice(0,12).map(e=>{let{s,x:t}=e;return(0,a.jsx)("li",{children:(0,a.jsxs)("button",{type:"button",className:"linkish",onClick:()=>n({kind:"task",sessionId:s.id,taskId:t.id}),children:[(0,a.jsx)(et,{status:t.status})," ",s.name," › ",t.title]})},t.id)})})]}),h>0&&(0,a.jsx)("p",{className:"small",children:c("wb.queuedCount",{n:h})}),(0,a.jsx)("p",{className:"muted small",children:c("wb.keys")})]})}function en(){return(0,a.jsx)(Q,{})}},5704:(e,s,t)=>{Promise.resolve().then(t.bind(t,4846))},9717:(e,s,t)=>{"use strict";t.d(s,{D:()=>l});var a=t(3365),n=t(867);function l(e){var s,t;let{plan:l,showApproval:i=!0}=e,{t:r}=(0,n.kj)(),c=(0,n.W3)(),o=l.approved;return(0,a.jsxs)("div",{className:"plan-view",children:[(0,a.jsx)("p",{className:"small muted",children:r("pm.version",{n:l.version,at:c(l.at)})}),i&&o&&(0,a.jsxs)("p",{className:"small",children:["operator"===o.by?r("pm.approvedByOperator",{at:c(o.at)}):r("pm.approvedAuto",{at:c(o.at)}),o.why&&" ".concat(o.why),o.note&&" ".concat(r("pm.approvedNote",{note:o.note}))]}),(0,a.jsx)("h4",{children:r("pm.existing")}),(0,a.jsx)("p",{className:"pre-wrap",children:l.existing}),(0,a.jsx)("h4",{children:r("pm.approach")}),(0,a.jsx)("p",{className:"pre-wrap",children:l.approach}),(0,a.jsx)("h4",{children:r("pm.steps")}),(0,a.jsx)("ol",{children:l.steps.map((e,s)=>(0,a.jsx)("li",{className:"pre-wrap",children:e},s))}),l.files.length>0&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("h4",{children:r("pm.files")}),(0,a.jsx)("ul",{children:l.files.map(e=>(0,a.jsx)("li",{children:(0,a.jsx)("code",{children:e})},e))})]}),(0,a.jsx)("h4",{children:r("pm.verification")}),(0,a.jsx)("p",{className:"pre-wrap",children:l.verification}),l.risks&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("h4",{children:r("pm.risks")}),(0,a.jsx)("p",{className:"pre-wrap",children:l.risks})]}),(null!=(t=null==(s=l.revisions)?void 0:s.length)?t:0)>0&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("h4",{children:r("pm.revisions")}),(0,a.jsx)("ul",{children:l.revisions.map(e=>(0,a.jsxs)("li",{className:"small",children:[r("pm.revision",{n:e.version,at:c(e.at)})," ",(0,a.jsx)("span",{className:"pre-wrap",children:e.comment})]},e.version))})]})]})}}},e=>{e.O(0,[197,867,549,499,897,347,131,358],()=>e(e.s=5704)),_N_E=e.O()}]);
@@ -1 +1 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[974],{2114:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>x});var a=n(3365),l=n(1521),s=n(8197),i=n.n(s),d=n(5549),r=n(7527),c=n(867),h=n(1035),o=n(4811),m=n(8848),u=n(3486),p=n(1701),g=n(3069);function x(){let{t:e}=(0,c.kj)(),t=(0,c.W3)(),[n,s]=(0,l.useState)(null),[o,m]=(0,l.useState)(null),[u,p]=(0,l.useState)([]),[g,x]=(0,l.useState)([]),[b,v]=(0,l.useState)([]),[f,N]=(0,l.useState)("stop"),[w,y]=(0,l.useState)(!1),[k,S]=(0,l.useState)(""),[C,F]=(0,l.useState)(""),[I,H]=(0,l.useState)(""),[W,D]=(0,l.useState)(null),[T,R]=(0,l.useState)(!1),U=(0,l.useCallback)(async()=>{try{let[e,t,n]=await Promise.all([d.FH.sessions(),d.FH.batch().catch(()=>null),d.FH.approvals().catch(()=>[])]);s(e),m(t),p(n),x(t=>t.filter(t=>e.some(e=>e.id===t))),D(!0),R(!1),H("")}catch(e){R(!(0,d.AV)()),D(!1),H(e.message)}},[]);(0,r.z)(U,3e3),(0,l.useEffect)(()=>{var e;let t=new URLSearchParams(window.location.search),n=(null!=(e=t.get("run"))?e:"").split(",").map(e=>e.trim()).filter(Boolean);0!==n.length&&(x(n),N("continue"===t.get("fail")?"continue":"stop"),y(!0),window.history.replaceState(null,"",window.location.pathname))},[]);let[O,E]=(0,l.useState)(!1),B=(0,l.useRef)(!1),M=async()=>{if(!B.current){B.current=!0,E(!0);try{let e=await d.FH.createSession(k||"session");S(""),window.location.href=(0,d.aT)(e.id)}catch(e){H(e.message),B.current=!1,E(!1)}}},q=async t=>{if(t.running)return void F(e("home.deleteRunning"));if(await (0,h.Z)(e("home.deleteConfirm",{name:t.name,n:t.tasks.length})))try{await d.FH.deleteSession(t.id),F(e("home.deleted",{name:t.name})),x(e=>e.filter(e=>e!==t.id)),await U()}catch(e){F(e.message)}},A=async()=>{let t=(null!=n?n:[]).filter(e=>b.includes(e.id)&&!e.running);if(0===t.length)return;let a=t.map(e=>"• ".concat(e.name," (").concat(e.tasks.length,")")).join("\n");if(!await (0,h.Z)(e("home.deleteSelectedConfirm",{n:t.length,names:a})))return;let l=0,s=[];for(let e of t)try{await d.FH.deleteSession(e.id),l+=1}catch(t){s.push("".concat(e.name,": ").concat(t.message))}F(0===s.length?e("home.deletedMany",{n:l}):e("home.deleteSomeFailed",{n:l,m:s.length,why:s.join("; ")})),x(e=>e.filter(e=>!t.some(t=>t.id===e))),v([]),await U()},L=async t=>{let a=(null!=n?n:[]).filter(e=>b.includes(e.id)&&!e.running);if(0===a.length)return;let l=[];for(let e of a)try{await d.FH.updateSession(e.id,{active:t})}catch(t){l.push("".concat(e.name,": ").concat(t.message))}F(0===l.length?e(t?"home.madeActive":"home.madeInactive",{n:a.length}):e("home.statusSomeFailed",{n:a.length-l.length,m:l.length,why:l.join("; ")})),t||x(e=>e.filter(e=>!a.some(t=>t.id===e))),v([]),await U()},P=t=>{if(t.running)return{label:e("state.running"),badge:"running"};let n=t.tasks.some(e=>"queued"===e.status||"running"===e.status);if("idle"!==t.status||n||0===t.tasks.length)return{label:e("state.".concat(t.status)),badge:""};let a=t.tasks.filter(e=>"done"!==e.status).length;return 0===a?{label:e("state.completed"),badge:"done",title:e("state.completedTitle")}:{label:e("state.ended"),badge:"failed",title:e("state.endedTitle",{n:a})}},_=async e=>{if(!n)return;let t=new Map(n.map(e=>[e.id,e]));s(e.map(e=>t.get(e)).filter(e=>!!e));try{s(await d.FH.reorderSessions(e)),H("")}catch(e){H(e.message),U()}},K=(e,t)=>{let a=(null!=n?n:[]).map(e=>e.id),l=a.indexOf(e),s=l+t;l<0||s<0||s>=a.length||([a[l],a[s]]=[a[s],a[l]],_(a))},[Z,z]=(0,l.useState)(null),[V,Q]=(0,l.useState)(null),X=(null!=n?n:[]).filter(e=>!e.running),G=X.filter(e=>b.includes(e.id));return(0,a.jsxs)(a.Fragment,{children:[T&&(0,a.jsxs)("div",{className:"panel",children:[(0,a.jsx)("strong",{children:e("home.noToken")}),(0,a.jsx)("div",{className:"muted small",children:e("home.noTokenHint",{cmd:"npm start"})})]}),!1===W&&!T&&(0,a.jsxs)("div",{className:"panel",children:[(0,a.jsx)("strong",{children:e("home.apiDown")}),(0,a.jsx)("div",{className:"muted small",children:e("home.apiHint",{cmd:"npm start",url:"/api"})}),I&&(0,a.jsx)("div",{className:"err",children:I})]}),(0,a.jsxs)("div",{className:"panel",id:"new-session",children:[(0,a.jsx)("h2",{children:e("home.new")}),(0,a.jsx)("p",{className:"muted small",children:e("home.newHint")}),(0,a.jsxs)("div",{className:"row",children:[(0,a.jsx)("input",{type:"text",className:"grow","aria-label":e("home.col.name"),placeholder:e("home.namePlaceholder"),value:k,onChange:e=>S(e.target.value),onKeyDown:e=>{"Enter"===e.key&&M()}}),(0,a.jsx)("button",{className:"primary",onClick:()=>void M(),disabled:O||!1===W,children:e("home.create")})]})]}),n&&n.length>0&&(0,a.jsx)(j,{sessions:n,selected:g,setSelected:x,onFailure:f,setOnFailure:N,fromPlan:w,batch:o,approvals:u,onChange:U,move:(e,t)=>{x(n=>{let a=n.indexOf(e),l=a+t;if(a<0||l<0||l>=n.length)return n;let s=[...n];return[s[a],s[l]]=[s[l],s[a]],s})}}),(0,a.jsxs)("div",{className:"panel",children:[(0,a.jsx)("h2",{children:e("home.sessions")}),null===n&&(0,a.jsx)("div",{className:"muted",children:e("home.loading")}),n&&0===n.length&&(0,a.jsx)("div",{className:"muted",children:e("home.none")}),n&&n.length>0&&(0,a.jsxs)("div",{className:"row",style:{marginBottom:10},children:[(0,a.jsx)("strong",{className:"small",children:e("home.managed",{n:G.length})}),(0,a.jsx)("button",{onClick:()=>void L(!0),disabled:0===G.length,children:e("home.makeActive")}),(0,a.jsx)("button",{onClick:()=>void L(!1),disabled:0===G.length,children:e("home.makeInactive")}),(0,a.jsx)("button",{className:"danger",onClick:()=>void A(),disabled:0===G.length,children:e("home.deleteSelected",{n:G.length})}),(0,a.jsx)("span",{className:"muted small",children:e("home.tickForBoth")})]}),n&&n.length>0&&(0,a.jsx)("p",{className:"muted small",children:e("home.deleteWhy")}),n&&n.length>1&&(0,a.jsx)("p",{className:"muted small",children:e("home.orderWhy")}),C&&(0,a.jsx)("div",{className:"muted small",role:"status",children:C}),n&&n.length>0&&(0,a.jsxs)("table",{children:[(0,a.jsx)("thead",{children:(0,a.jsxs)("tr",{children:[(0,a.jsx)("th",{children:(0,a.jsx)("input",{type:"checkbox","aria-label":e("home.manageAll"),title:e("home.manageAll"),checked:X.length>0&&X.every(e=>b.includes(e.id)),onChange:e=>v(e.target.checked?X.map(e=>e.id):[]),disabled:0===X.length})}),(0,a.jsx)("th",{children:(0,a.jsx)("input",{type:"checkbox","aria-label":e("home.selectAll"),checked:n.length>0&&g.length===n.filter(e=>!1!==e.active).length,onChange:e=>x(e.target.checked?n.filter(e=>!1!==e.active).map(e=>e.id):[]),disabled:(null==o?void 0:o.running)===!0})}),(0,a.jsx)("th",{children:e("home.col.order")}),(0,a.jsx)("th",{children:e("home.col.name")}),(0,a.jsx)("th",{children:e("home.col.tasks")}),(0,a.jsx)("th",{children:e("home.col.state")}),(0,a.jsx)("th",{children:e("home.col.chat")}),(0,a.jsx)("th",{children:e("home.col.created")}),(0,a.jsx)("th",{children:(0,a.jsx)("span",{className:"visually-hidden",children:e("home.col.remove")})})]})}),(0,a.jsx)("tbody",{children:n.map((l,s)=>{let r=l.tasks.filter(e=>"done"===e.status).length,c=l.tasks.filter(e=>"queued"===e.status).length,h=[!1===l.active?"inactive":"",Z===l.id?"dragging":"",V===l.id&&Z!==l.id?"drop-target":""].filter(Boolean).join(" ");return(0,a.jsxs)("tr",{className:h||void 0,draggable:!0,onDragStart:e=>{e.dataTransfer.setData("text/plain",l.id),e.dataTransfer.effectAllowed="move",z(l.id)},onDragOver:e=>{Z&&(e.preventDefault(),e.dataTransfer.dropEffect="move",V!==l.id&&Q(l.id))},onDrop:e=>{e.preventDefault();let t=e.dataTransfer.getData("text/plain")||Z;z(null),Q(null),t&&((e,t)=>{let a=(null!=n?n:[]).map(e=>e.id),l=a.indexOf(e),s=a.indexOf(t);l<0||s<0||l===s||(a.splice(l,1),a.splice(s,0,e),_(a))})(t,l.id)},onDragEnd:()=>{z(null),Q(null)},children:[(0,a.jsx)("td",{children:(0,a.jsx)("input",{type:"checkbox",checked:b.includes(l.id),onChange:()=>v(e=>e.includes(l.id)?e.filter(e=>e!==l.id):[...e,l.id]),disabled:!!l.running,"aria-label":e("home.manageRow",{name:l.name}),title:l.running?e("home.manageRunning"):e("home.manageRow",{name:l.name})})}),(0,a.jsx)("td",{children:(0,a.jsx)("input",{type:"checkbox",checked:g.includes(l.id),onChange:()=>{var e;return e=l.id,void x(t=>{if(t.includes(e))return t.filter(t=>t!==e);let a=(null!=n?n:[]).map(e=>e.id);return[...t,e].sort((e,t)=>a.indexOf(e)-a.indexOf(t))})},disabled:(null==o?void 0:o.running)===!0||!1===l.active,"aria-label":l.name,title:!1===l.active?e("home.inactiveWhy"):void 0})}),(0,a.jsxs)("td",{className:"order-cell",children:[(0,a.jsx)("span",{className:"drag-handle","aria-hidden":"true",title:e("home.dragHint"),children:"⠿"}),(0,a.jsx)("button",{className:"quiet small",onClick:()=>K(l.id,-1),disabled:0===s,"aria-label":e("home.moveUp",{name:l.name}),title:e("home.moveUp",{name:l.name}),children:"↑"}),(0,a.jsx)("button",{className:"quiet small",onClick:()=>K(l.id,1),disabled:s===n.length-1,"aria-label":e("home.moveDown",{name:l.name}),title:e("home.moveDown",{name:l.name}),children:"↓"})]}),(0,a.jsx)("td",{children:(0,a.jsx)(i(),{href:(0,d.aT)(l.id),children:l.name})}),(0,a.jsxs)("td",{children:[l.tasks.length," ",(0,a.jsx)("span",{className:"muted small",children:e("home.tasksDetail",{done:r,queued:c})})]}),(0,a.jsxs)("td",{children:[(0,a.jsx)("span",{className:"badge ".concat(P(l).badge),title:P(l).title,children:P(l).label})," ",(0,a.jsx)("span",{className:"chip".concat(!1===l.active?" inactive":""),title:e(!1===l.active?"home.inactiveWhy":"home.activeWhy"),children:e(!1===l.active?"home.statusInactive":"home.statusActive")})]}),(0,a.jsx)("td",{children:l.chat?(0,a.jsx)("a",{href:l.chat.url,target:"_blank",rel:"noreferrer",children:l.chat.name}):(0,a.jsx)("span",{className:"muted",children:e("home.notOpened")})}),(0,a.jsx)("td",{className:"muted small",children:t(l.createdAt)}),(0,a.jsx)("td",{children:(0,a.jsx)("button",{className:"quiet",onClick:()=>void q(l),disabled:!!l.running,title:e("home.delete"),children:e("home.delete")})})]},l.id)})})]})]})]})}function j(e){var t,n,s,r,x,j,b;let{sessions:v,selected:f,setSelected:N,onFailure:w,setOnFailure:y,fromPlan:k,batch:S,approvals:C,onChange:F,move:I}=e,{t:H}=(0,c.kj)(),[W,D]=(0,l.useState)(""),[T,R]=(0,l.useState)(""),[U,O]=(0,l.useState)(void 0),[E,B]=(0,l.useState)(""),[M,q]=(0,l.useState)(""),[A,L]=(0,l.useState)(""),[P,_]=(0,l.useState)(null),[K,Z]=(0,l.useState)([]),[z,V]=(0,l.useState)(0);(0,l.useEffect)(()=>{d.FH.models().then(e=>{_(e),B(t=>t||e.defaultModel),q(t=>t||e.defaultReviewModel)}).catch(()=>void 0)},[]);let Q=f.join(",");(0,l.useEffect)(()=>{let e=!1,t=Q.split(",").filter(Boolean);if(0===t.length)return void Z([]);let n=async()=>{let n=await d.FH.runVcs(t).catch(()=>[]);e||Z(n)};n();let a=setInterval(()=>void n(),1e4);return()=>{e=!0,clearInterval(a)}},[Q,z]);let X=new Map(v.map(e=>[e.id,e])),G=e=>e.tasks.filter(e=>"queued"===e.status).length,J=f.map(e=>X.get(e)).filter(e=>!!e),Y=J.filter(e=>G(e)>0&&!1!==e.active),$=Y.reduce((e,t)=>e+G(t),0),ee=(null==S?void 0:S.running)===!0,et=v.some(e=>e.running),en=K.some(e=>!e.ready&&!e.startChoiceCanFix),ea=ee||0===Y.length||et||en,el=et?{title:"batch.oneRunning",why:"batch.oneRunningWhy"}:0===J.length?{title:"batch.pickFirst",why:"batch.pickFirstWhy"}:0===Y.length?{title:"batch.nothingRunnable",why:"batch.nothingRunnableWhy"}:null,es=(0,o.p)(),[ei,ed]=(0,l.useState)(!1),er=(0,l.useRef)(!1),ec=async e=>{if(!er.current){er.current=!0,ed(!0);try{await e()}catch(e){R(e.message)}finally{er.current=!1,ed(!1),F()}}},eh=async e=>{("unattended"!==e||es||await (0,h.Z)(H("batch.unattendedConfirm",{n:Y.length})))&&await ec(async()=>{var t,n,a;let l=Y.map(e=>e.id),s=await (0,p.L)({sessionIds:l,mode:e,start:t=>d.FH.startBatch(l,e,w,E||void 0,M||void 0,A.trim()||Y.map(e=>e.planName).find(Boolean)||void 0,void 0,t)});D(""),R(s.started?"":null!=(a=null==(t=s.reply)?void 0:t.reason)?a:""),O(s.started||null==(n=s.reply)?void 0:n.failure),V(e=>e+1)})},eo=J.filter(e=>{var t;return(null!=(t=e.model)?t:"")!==E}).length,em=J.filter(e=>{var t;return(null==(t=e.review)?void 0:t.enabled)===!1}).length,eu=null!=(s=null==P?void 0:P.options)?s:[],ep=eu.filter(e=>!e.group),eg=new Map;for(let e of eu)e.group&&eg.set(e.group,[...null!=(r=eg.get(e.group))?r:[],e]);let ex=S?{done:S.sessions.filter(e=>"done"===e.state).length,failed:S.sessions.filter(e=>"failed"===e.state).length,skipped:S.sessions.filter(e=>"skipped"===e.state||"stopped"===e.state).length}:null,ej=null==S?void 0:S.sessions.find(e=>"running"===e.state);return(0,a.jsxs)("div",{className:"panel",children:[(0,a.jsx)("h2",{children:H("batch.title")}),(0,a.jsx)("p",{className:"muted small",children:H("batch.hint")}),!ee&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"row",children:[(0,a.jsx)("strong",{className:"small",children:H("batch.selected",{n:Y.length,tasks:$})}),(0,a.jsx)("button",{className:"quiet",onClick:()=>N(v.filter(e=>G(e)>0).map(e=>e.id)),children:H("batch.selectQueued")}),(0,a.jsx)("button",{className:"quiet",onClick:()=>N([]),disabled:0===J.length,children:H("batch.selectNone")})]}),k&&(0,a.jsx)("p",{className:"muted small",children:H("batch.fromPlan")}),J.length>Y.length&&(0,a.jsx)("p",{className:"muted small",children:H("batch.notRunnable",{n:J.length-Y.length})}),Y.length>0&&(0,a.jsx)("ol",{className:"run-order",children:Y.map((e,t)=>(0,a.jsxs)("li",{children:[(0,a.jsxs)("span",{children:[e.name," ",(0,a.jsxs)("span",{className:"muted small",children:["(",G(e),")"]})]}),(0,a.jsxs)("span",{children:[(0,a.jsx)("button",{className:"quiet",onClick:()=>I(e.id,-1),disabled:0===t,"aria-label":H("batch.moveUp",{name:e.name}),children:"↑"}),(0,a.jsx)("button",{className:"quiet",onClick:()=>I(e.id,1),disabled:t===Y.length-1,"aria-label":H("batch.moveDown",{name:e.name}),children:"↓"})]})]},e.id))}),(0,a.jsx)("label",{htmlFor:"batch-run-name",children:H("batch.runName")}),(0,a.jsx)("input",{id:"batch-run-name",type:"text",value:A,onChange:e=>L(e.target.value),placeholder:null!=(x=Y.map(e=>e.planName).find(Boolean))?x:H("batch.runNamePlaceholder")}),(0,a.jsx)("p",{className:"why",children:H("batch.runNameWhy")}),(0,a.jsx)("label",{htmlFor:"batch-model",children:H("batch.model")}),(0,a.jsxs)("div",{className:"row",children:[(0,a.jsxs)("select",{id:"batch-model",value:E,onChange:e=>B(e.target.value),style:{width:"auto",minWidth:260},children:[(0,a.jsx)("option",{value:"",children:H("batch.modelKeep")}),ep.map(e=>(0,a.jsx)("option",{value:e.name,disabled:e.disabled,children:e.name},e.name)),[...eg.entries()].map(e=>{let[t,n]=e;return(0,a.jsx)("optgroup",{label:t,children:n.map(e=>(0,a.jsx)("option",{value:e.name,disabled:e.disabled,children:e.name},e.name))},t)})]}),(null!=(j=null==P?void 0:P.options.length)?j:0)===0&&(0,a.jsx)("span",{className:"muted small",children:H("batch.modelNone")})]}),(0,a.jsx)("p",{className:"why",children:H("batch.modelWhy")}),(0,a.jsx)(m.L,{current:E,onUse:e=>B(e)}),E&&eo>0&&(0,a.jsx)("p",{className:"why",style:{color:"var(--warn)"},children:H("batch.modelOverrides",{n:eo})}),(0,a.jsx)("label",{htmlFor:"batch-review-model",children:H("batch.reviewModel")}),(0,a.jsx)("div",{className:"row",children:(0,a.jsxs)("select",{id:"batch-review-model",value:M,onChange:e=>q(e.target.value),style:{width:"auto",minWidth:260},children:[(0,a.jsx)("option",{value:"",children:H("batch.reviewModelKeep")}),ep.map(e=>(0,a.jsx)("option",{value:e.name,disabled:e.disabled,children:e.name},e.name)),[...eg.entries()].map(e=>{let[t,n]=e;return(0,a.jsx)("optgroup",{label:t,children:n.map(e=>(0,a.jsx)("option",{value:e.name,disabled:e.disabled,children:e.name},e.name))},t)})]})}),(0,a.jsx)("p",{className:"why",children:H("batch.reviewModelWhy")}),""!==M&&M===E&&(0,a.jsx)("p",{className:"why",style:{color:"var(--warn)"},children:H("batch.reviewSame")}),em>0&&(0,a.jsx)("p",{className:"why",children:H("batch.reviewOffIn",{n:em})}),(0,a.jsxs)("fieldset",{style:{border:0,padding:0,margin:"10px 0 14px"},children:[(0,a.jsx)("legend",{className:"muted small",style:{padding:0},children:H("batch.onFailure")}),(0,a.jsxs)("div",{className:"option",children:[(0,a.jsxs)("label",{children:[(0,a.jsx)("input",{type:"radio",name:"batch-fail",checked:"stop"===w,onChange:()=>y("stop")}),(0,a.jsx)("span",{children:H("batch.chain")})]}),(0,a.jsx)("p",{className:"why",children:H("batch.chainWhy")})]}),(0,a.jsxs)("div",{className:"option",children:[(0,a.jsxs)("label",{children:[(0,a.jsx)("input",{type:"radio",name:"batch-fail",checked:"continue"===w,onChange:()=>y("continue")}),(0,a.jsx)("span",{children:H("batch.independent")})]}),(0,a.jsx)("p",{className:"why",children:H("batch.independentWhy")})]})]}),el&&(0,a.jsxs)("div",{className:"notice caution",children:[(0,a.jsx)("strong",{children:H(el.title)}),(0,a.jsx)("div",{className:"small",style:{marginTop:4},children:H(el.why)})]}),(0,a.jsx)(u.w,{groups:K,sessionIds:Y.map(e=>e.id),onChange:()=>V(e=>e+1)}),T&&(0,a.jsx)(g.X,{failure:U,reason:T,children:/execution\.isolation/.test(T)&&(0,a.jsx)("div",{className:"small",style:{marginTop:4},children:(0,a.jsx)(i(),{href:"/defaults",children:H("batch.notStartedIsolation")})})}),!en&&(0,a.jsxs)("div",{className:"run-choice",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("button",{className:"primary",onClick:()=>void eh("unattended"),disabled:ei||ea,children:H("batch.run",{n:Y.length})}),(0,a.jsx)("p",{className:"why",children:H("batch.runWhy")})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("button",{onClick:()=>void eh("confirm"),disabled:ei||ea,children:H("batch.runStep")}),(0,a.jsx)("p",{className:"why",children:H("batch.runStepWhy")})]})]})]}),ee&&(0,a.jsxs)("div",{className:"row",children:[(null==S?void 0:S.pausing)?(0,a.jsx)("button",{className:"primary",onClick:()=>void ec(async()=>{await d.FH.resumeBatch(),D("")}),disabled:ei||(null==S?void 0:S.stopping),title:H("batch.resumeWhy"),children:H("batch.resume")}):(0,a.jsx)("button",{onClick:()=>void ec(async()=>{await d.FH.pauseBatch(),D(H("batch.pausing"))}),disabled:ei||(null==S?void 0:S.stopping),title:H("batch.pauseWhy"),children:H("batch.pause")}),(0,a.jsx)("button",{onClick:()=>void ec(async()=>{await d.FH.stopBatch(),D(H("batch.stopping"))}),disabled:ei||(null==S?void 0:S.stopping),title:H("batch.stopWhy"),children:H("batch.stop")}),(null==S?void 0:S.pausing)&&!(null==S?void 0:S.stopping)&&(0,a.jsx)("span",{className:"muted small",children:H("batch.pausing")}),(0,a.jsx)("span",{className:"badge",children:H("batch.modelRunning",{name:(ej?(null==(t=X.get(ej.sessionId))?void 0:t.modelInUse)||(null==(n=X.get(ej.sessionId))?void 0:n.model):"")||H("model.default")})}),C.length>0&&(0,a.jsx)("span",{className:"badge waiting-approval",children:H("batch.waiting",{n:C.length})}),ej&&(0,a.jsx)("span",{className:"small",children:H("batch.progress",{name:ej.name,done:S.sessions.filter(e=>"waiting"!==e.state&&"running"!==e.state).length,total:S.sessions.length})})]}),ee&&(0,a.jsx)("p",{className:"muted small",children:H("batch.hiddenWhileRunning")}),W&&(0,a.jsx)("div",{className:"muted small",role:"status",children:W}),(J.length>0||S)&&(0,a.jsxs)("div",{className:"row",style:{marginTop:12},children:[(0,a.jsx)("a",{className:"button-link",href:d.FH.debugExportUrl(J.length>0?J.map(e=>e.id):(null!=(b=null==S?void 0:S.sessions)?b:[]).map(e=>e.sessionId)),children:H("batch.debug")}),(0,a.jsx)("span",{className:"muted small",children:J.length>0?H("batch.debugSelected",{n:J.length}):H("batch.debugLast")})]}),(J.length>0||S)&&(0,a.jsx)("p",{className:"why",children:H("batch.debugWhy")}),S&&(0,a.jsxs)(a.Fragment,{children:[!ee&&ex&&(0,a.jsx)("div",{className:"notice calm",style:{marginTop:12},children:(0,a.jsx)("strong",{children:H("batch.finished",ex)})}),(0,a.jsxs)("table",{style:{marginTop:10},children:[(0,a.jsx)("thead",{children:(0,a.jsxs)("tr",{children:[(0,a.jsx)("th",{children:H("batch.col.session")}),(0,a.jsx)("th",{children:H("batch.col.state")}),(0,a.jsx)("th",{children:H("batch.col.ran")}),(0,a.jsx)("th",{children:H("batch.col.why")})]})}),(0,a.jsx)("tbody",{children:S.sessions.map(e=>{var t,n;return(0,a.jsxs)("tr",{className:"batch-row ".concat(e.state),children:[(0,a.jsx)("td",{children:(0,a.jsx)(i(),{href:(0,d.aT)(e.sessionId),children:e.name})}),(0,a.jsx)("td",{children:(0,a.jsx)("span",{className:"badge ".concat("running"===(n=e.state)?"running":"done"===n?"done":"failed"===n?"failed":"stopped"===n?"aborted":""),children:H("batch.state.".concat(e.state))})}),(0,a.jsx)("td",{className:"small",children:H("batch.ranOf",{ran:e.ran,failed:e.failed})}),(0,a.jsx)("td",{className:"muted small",children:null!=(t=e.reason)?t:""})]},e.sessionId)})})]})]})]})}},4811:(e,t,n)=>{"use strict";n.d(t,{p:()=>s});var a=n(1521),l=n(5549);function s(){let[e,t]=(0,a.useState)(!1);return(0,a.useEffect)(()=>{let e=!0;return l.FH.settings().then(n=>{var a;let l=null!=(a=n.raw.execution)?a:{};e&&t("unattended"===l.mode)}).catch(()=>void 0),()=>{e=!1}},[]),e}},5704:(e,t,n)=>{Promise.resolve().then(n.bind(n,2114))},8848:(e,t,n)=>{"use strict";n.d(t,{H4:()=>c,L:()=>h,z4:()=>o});var a=n(3365),l=n(8197),s=n.n(l),i=n(1521),d=n(5549),r=n(867);function c(e){let{current:t,onUse:n}=e,{t:l}=(0,r.kj)(),[s,c]=(0,i.useState)(null);if((0,i.useEffect)(()=>{let e=!1;return d.FH.project().then(t=>{e||c(t)}).catch(()=>void 0),()=>{e=!0}},[]),!s)return null;let h=s.rootDir.trim(),o=t.trim().toLowerCase(),m=n?s.others.filter(e=>e.rootDir.trim().toLowerCase()!==o):[];return(0,a.jsx)(u,{label:h?l("proj.defaultIs",{dir:h}):l("proj.noneShort"),offer:h&&n&&o!==h.toLowerCase()?{text:l("proj.useIt"),onUse:()=>n(h)}:void 0,more:m.map(e=>({text:l("proj.otherUse",{name:e.name}),title:e.rootDir,onUse:()=>null==n?void 0:n(e.rootDir)})),link:h?l("proj.change"):l("proj.setIt"),anchor:"project"})}function h(e){let{current:t,onUse:n}=e,l=m(),{t:s}=(0,r.kj)();if(!l)return null;let i=l.defaultModel.trim();return(0,a.jsx)(u,{label:i?s("def.modelDefaultIs",{name:i}):s("def.modelNoneShort"),offer:i&&n&&t.trim()!==i?{text:s("def.modelUseIt"),onUse:()=>n(i)}:void 0,link:s(i?"proj.change":"proj.setIt"),anchor:"model"})}function o(e){let{current:t,onUse:n}=e,l=m(),{t:s}=(0,r.kj)();if(!l)return null;let i=l.defaultReviewModel.trim();return(0,a.jsx)(u,{label:i?s("def.reviewDefaultIs",{name:i}):s("def.reviewNoneShort"),offer:i&&n&&t.trim()!==i?{text:s("def.modelUseIt"),onUse:()=>n(i)}:void 0,link:s(i?"proj.change":"proj.setIt"),anchor:"review"})}function m(){let[e,t]=(0,i.useState)(null);return(0,i.useEffect)(()=>{let e=!1;return d.FH.models().then(n=>{e||t(n)}).catch(()=>void 0),()=>{e=!0}},[]),e}function u(e){let{label:t,offer:n,more:l=[],link:i,anchor:d}=e;return(0,a.jsxs)("p",{className:"muted small",style:{marginTop:4},children:[t," ",n&&(0,a.jsxs)(a.Fragment,{children:["\xb7"," ",(0,a.jsx)("button",{type:"button",className:"linkish",onClick:n.onUse,children:n.text})," "]}),l.map(e=>(0,a.jsxs)("span",{children:["\xb7"," ",(0,a.jsx)("button",{type:"button",className:"linkish",onClick:e.onUse,title:e.title,children:e.text})," "]},e.text)),"\xb7 ",(0,a.jsx)(s(),{href:"/defaults#".concat(d),children:i})]})}}},e=>{e.O(0,[197,867,549,499,347,131,358],()=>e(e.s=5704)),_N_E=e.O()}]);
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[898],{4350:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>x});var a=n(3365),l=n(1521),s=n(8197),i=n.n(s),d=n(5549),r=n(7527),c=n(867),h=n(1035),o=n(4811),m=n(8848),u=n(3486),p=n(1701),g=n(3069);function x(){let{t:e}=(0,c.kj)(),t=(0,c.W3)(),[n,s]=(0,l.useState)(null),[o,m]=(0,l.useState)(null),[u,p]=(0,l.useState)([]),[g,x]=(0,l.useState)([]),[b,v]=(0,l.useState)([]),[f,N]=(0,l.useState)("stop"),[w,y]=(0,l.useState)(!1),[k,S]=(0,l.useState)(""),[C,F]=(0,l.useState)(""),[I,H]=(0,l.useState)(""),[W,D]=(0,l.useState)(null),[T,R]=(0,l.useState)(!1),U=(0,l.useCallback)(async()=>{try{let[e,t,n]=await Promise.all([d.FH.sessions(),d.FH.batch().catch(()=>null),d.FH.approvals().catch(()=>[])]);s(e),m(t),p(n),x(t=>t.filter(t=>e.some(e=>e.id===t))),D(!0),R(!1),H("")}catch(e){R(!(0,d.AV)()),D(!1),H(e.message)}},[]);(0,r.z)(U,3e3),(0,l.useEffect)(()=>{var e;let t=new URLSearchParams(window.location.search),n=(null!=(e=t.get("run"))?e:"").split(",").map(e=>e.trim()).filter(Boolean);0!==n.length&&(x(n),N("continue"===t.get("fail")?"continue":"stop"),y(!0),window.history.replaceState(null,"",window.location.pathname))},[]);let[O,E]=(0,l.useState)(!1),B=(0,l.useRef)(!1),M=async()=>{if(!B.current){B.current=!0,E(!0);try{let e=await d.FH.createSession(k||"session");S(""),window.location.href=(0,d.aT)(e.id)}catch(e){H(e.message),B.current=!1,E(!1)}}},q=async t=>{if(t.running)return void F(e("home.deleteRunning"));if(await (0,h.Z)(e("home.deleteConfirm",{name:t.name,n:t.tasks.length})))try{await d.FH.deleteSession(t.id),F(e("home.deleted",{name:t.name})),x(e=>e.filter(e=>e!==t.id)),await U()}catch(e){F(e.message)}},A=async()=>{let t=(null!=n?n:[]).filter(e=>b.includes(e.id)&&!e.running);if(0===t.length)return;let a=t.map(e=>"• ".concat(e.name," (").concat(e.tasks.length,")")).join("\n");if(!await (0,h.Z)(e("home.deleteSelectedConfirm",{n:t.length,names:a})))return;let l=0,s=[];for(let e of t)try{await d.FH.deleteSession(e.id),l+=1}catch(t){s.push("".concat(e.name,": ").concat(t.message))}F(0===s.length?e("home.deletedMany",{n:l}):e("home.deleteSomeFailed",{n:l,m:s.length,why:s.join("; ")})),x(e=>e.filter(e=>!t.some(t=>t.id===e))),v([]),await U()},L=async t=>{let a=(null!=n?n:[]).filter(e=>b.includes(e.id)&&!e.running);if(0===a.length)return;let l=[];for(let e of a)try{await d.FH.updateSession(e.id,{active:t})}catch(t){l.push("".concat(e.name,": ").concat(t.message))}F(0===l.length?e(t?"home.madeActive":"home.madeInactive",{n:a.length}):e("home.statusSomeFailed",{n:a.length-l.length,m:l.length,why:l.join("; ")})),t||x(e=>e.filter(e=>!a.some(t=>t.id===e))),v([]),await U()},P=t=>{if(t.running)return{label:e("state.running"),badge:"running"};let n=t.tasks.some(e=>"queued"===e.status||"running"===e.status);if("idle"!==t.status||n||0===t.tasks.length)return{label:e("state.".concat(t.status)),badge:""};let a=t.tasks.filter(e=>"done"!==e.status).length;return 0===a?{label:e("state.completed"),badge:"done",title:e("state.completedTitle")}:{label:e("state.ended"),badge:"failed",title:e("state.endedTitle",{n:a})}},_=async e=>{if(!n)return;let t=new Map(n.map(e=>[e.id,e]));s(e.map(e=>t.get(e)).filter(e=>!!e));try{s(await d.FH.reorderSessions(e)),H("")}catch(e){H(e.message),U()}},K=(e,t)=>{let a=(null!=n?n:[]).map(e=>e.id),l=a.indexOf(e),s=l+t;l<0||s<0||s>=a.length||([a[l],a[s]]=[a[s],a[l]],_(a))},[Z,z]=(0,l.useState)(null),[V,Q]=(0,l.useState)(null),X=(null!=n?n:[]).filter(e=>!e.running),G=X.filter(e=>b.includes(e.id));return(0,a.jsxs)(a.Fragment,{children:[T&&(0,a.jsxs)("div",{className:"panel",children:[(0,a.jsx)("strong",{children:e("home.noToken")}),(0,a.jsx)("div",{className:"muted small",children:e("home.noTokenHint",{cmd:"npm start"})})]}),!1===W&&!T&&(0,a.jsxs)("div",{className:"panel",children:[(0,a.jsx)("strong",{children:e("home.apiDown")}),(0,a.jsx)("div",{className:"muted small",children:e("home.apiHint",{cmd:"npm start",url:"/api"})}),I&&(0,a.jsx)("div",{className:"err",children:I})]}),(0,a.jsxs)("div",{className:"panel",id:"new-session",children:[(0,a.jsx)("h2",{children:e("home.new")}),(0,a.jsx)("p",{className:"muted small",children:e("home.newHint")}),(0,a.jsxs)("div",{className:"row",children:[(0,a.jsx)("input",{type:"text",className:"grow","aria-label":e("home.col.name"),placeholder:e("home.namePlaceholder"),value:k,onChange:e=>S(e.target.value),onKeyDown:e=>{"Enter"===e.key&&M()}}),(0,a.jsx)("button",{className:"primary",onClick:()=>void M(),disabled:O||!1===W,children:e("home.create")})]})]}),n&&n.length>0&&(0,a.jsx)(j,{sessions:n,selected:g,setSelected:x,onFailure:f,setOnFailure:N,fromPlan:w,batch:o,approvals:u,onChange:U,move:(e,t)=>{x(n=>{let a=n.indexOf(e),l=a+t;if(a<0||l<0||l>=n.length)return n;let s=[...n];return[s[a],s[l]]=[s[l],s[a]],s})}}),(0,a.jsxs)("div",{className:"panel",children:[(0,a.jsx)("h2",{children:e("home.sessions")}),null===n&&(0,a.jsx)("div",{className:"muted",children:e("home.loading")}),n&&0===n.length&&(0,a.jsx)("div",{className:"muted",children:e("home.none")}),n&&n.length>0&&(0,a.jsxs)("div",{className:"row",style:{marginBottom:10},children:[(0,a.jsx)("strong",{className:"small",children:e("home.managed",{n:G.length})}),(0,a.jsx)("button",{onClick:()=>void L(!0),disabled:0===G.length,children:e("home.makeActive")}),(0,a.jsx)("button",{onClick:()=>void L(!1),disabled:0===G.length,children:e("home.makeInactive")}),(0,a.jsx)("button",{className:"danger",onClick:()=>void A(),disabled:0===G.length,children:e("home.deleteSelected",{n:G.length})}),(0,a.jsx)("span",{className:"muted small",children:e("home.tickForBoth")})]}),n&&n.length>0&&(0,a.jsx)("p",{className:"muted small",children:e("home.deleteWhy")}),n&&n.length>1&&(0,a.jsx)("p",{className:"muted small",children:e("home.orderWhy")}),C&&(0,a.jsx)("div",{className:"muted small",role:"status",children:C}),n&&n.length>0&&(0,a.jsxs)("table",{children:[(0,a.jsx)("thead",{children:(0,a.jsxs)("tr",{children:[(0,a.jsx)("th",{children:(0,a.jsx)("input",{type:"checkbox","aria-label":e("home.manageAll"),title:e("home.manageAll"),checked:X.length>0&&X.every(e=>b.includes(e.id)),onChange:e=>v(e.target.checked?X.map(e=>e.id):[]),disabled:0===X.length})}),(0,a.jsx)("th",{children:(0,a.jsx)("input",{type:"checkbox","aria-label":e("home.selectAll"),checked:n.length>0&&g.length===n.filter(e=>!1!==e.active).length,onChange:e=>x(e.target.checked?n.filter(e=>!1!==e.active).map(e=>e.id):[]),disabled:(null==o?void 0:o.running)===!0})}),(0,a.jsx)("th",{children:e("home.col.order")}),(0,a.jsx)("th",{children:e("home.col.name")}),(0,a.jsx)("th",{children:e("home.col.tasks")}),(0,a.jsx)("th",{children:e("home.col.state")}),(0,a.jsx)("th",{children:e("home.col.chat")}),(0,a.jsx)("th",{children:e("home.col.created")}),(0,a.jsx)("th",{children:(0,a.jsx)("span",{className:"visually-hidden",children:e("home.col.remove")})})]})}),(0,a.jsx)("tbody",{children:n.map((l,s)=>{let r=l.tasks.filter(e=>"done"===e.status).length,c=l.tasks.filter(e=>"queued"===e.status).length,h=[!1===l.active?"inactive":"",Z===l.id?"dragging":"",V===l.id&&Z!==l.id?"drop-target":""].filter(Boolean).join(" ");return(0,a.jsxs)("tr",{className:h||void 0,draggable:!0,onDragStart:e=>{e.dataTransfer.setData("text/plain",l.id),e.dataTransfer.effectAllowed="move",z(l.id)},onDragOver:e=>{Z&&(e.preventDefault(),e.dataTransfer.dropEffect="move",V!==l.id&&Q(l.id))},onDrop:e=>{e.preventDefault();let t=e.dataTransfer.getData("text/plain")||Z;z(null),Q(null),t&&((e,t)=>{let a=(null!=n?n:[]).map(e=>e.id),l=a.indexOf(e),s=a.indexOf(t);l<0||s<0||l===s||(a.splice(l,1),a.splice(s,0,e),_(a))})(t,l.id)},onDragEnd:()=>{z(null),Q(null)},children:[(0,a.jsx)("td",{children:(0,a.jsx)("input",{type:"checkbox",checked:b.includes(l.id),onChange:()=>v(e=>e.includes(l.id)?e.filter(e=>e!==l.id):[...e,l.id]),disabled:!!l.running,"aria-label":e("home.manageRow",{name:l.name}),title:l.running?e("home.manageRunning"):e("home.manageRow",{name:l.name})})}),(0,a.jsx)("td",{children:(0,a.jsx)("input",{type:"checkbox",checked:g.includes(l.id),onChange:()=>{var e;return e=l.id,void x(t=>{if(t.includes(e))return t.filter(t=>t!==e);let a=(null!=n?n:[]).map(e=>e.id);return[...t,e].sort((e,t)=>a.indexOf(e)-a.indexOf(t))})},disabled:(null==o?void 0:o.running)===!0||!1===l.active,"aria-label":l.name,title:!1===l.active?e("home.inactiveWhy"):void 0})}),(0,a.jsxs)("td",{className:"order-cell",children:[(0,a.jsx)("span",{className:"drag-handle","aria-hidden":"true",title:e("home.dragHint"),children:"⠿"}),(0,a.jsx)("button",{className:"quiet small",onClick:()=>K(l.id,-1),disabled:0===s,"aria-label":e("home.moveUp",{name:l.name}),title:e("home.moveUp",{name:l.name}),children:"↑"}),(0,a.jsx)("button",{className:"quiet small",onClick:()=>K(l.id,1),disabled:s===n.length-1,"aria-label":e("home.moveDown",{name:l.name}),title:e("home.moveDown",{name:l.name}),children:"↓"})]}),(0,a.jsx)("td",{children:(0,a.jsx)(i(),{href:(0,d.aT)(l.id),children:l.name})}),(0,a.jsxs)("td",{children:[l.tasks.length," ",(0,a.jsx)("span",{className:"muted small",children:e("home.tasksDetail",{done:r,queued:c})})]}),(0,a.jsxs)("td",{children:[(0,a.jsx)("span",{className:"badge ".concat(P(l).badge),title:P(l).title,children:P(l).label})," ",(0,a.jsx)("span",{className:"chip".concat(!1===l.active?" inactive":""),title:e(!1===l.active?"home.inactiveWhy":"home.activeWhy"),children:e(!1===l.active?"home.statusInactive":"home.statusActive")})]}),(0,a.jsx)("td",{children:l.chat?(0,a.jsx)("a",{href:l.chat.url,target:"_blank",rel:"noreferrer",children:l.chat.name}):(0,a.jsx)("span",{className:"muted",children:e("home.notOpened")})}),(0,a.jsx)("td",{className:"muted small",children:t(l.createdAt)}),(0,a.jsx)("td",{children:(0,a.jsx)("button",{className:"quiet",onClick:()=>void q(l),disabled:!!l.running,title:e("home.delete"),children:e("home.delete")})})]},l.id)})})]})]})]})}function j(e){var t,n,s,r,x,j,b;let{sessions:v,selected:f,setSelected:N,onFailure:w,setOnFailure:y,fromPlan:k,batch:S,approvals:C,onChange:F,move:I}=e,{t:H}=(0,c.kj)(),[W,D]=(0,l.useState)(""),[T,R]=(0,l.useState)(""),[U,O]=(0,l.useState)(void 0),[E,B]=(0,l.useState)(""),[M,q]=(0,l.useState)(""),[A,L]=(0,l.useState)(""),[P,_]=(0,l.useState)(null),[K,Z]=(0,l.useState)([]),[z,V]=(0,l.useState)(0);(0,l.useEffect)(()=>{d.FH.models().then(e=>{_(e),B(t=>t||e.defaultModel),q(t=>t||e.defaultReviewModel)}).catch(()=>void 0)},[]);let Q=f.join(",");(0,l.useEffect)(()=>{let e=!1,t=Q.split(",").filter(Boolean);if(0===t.length)return void Z([]);let n=async()=>{let n=await d.FH.runVcs(t).catch(()=>[]);e||Z(n)};n();let a=setInterval(()=>void n(),1e4);return()=>{e=!0,clearInterval(a)}},[Q,z]);let X=new Map(v.map(e=>[e.id,e])),G=e=>e.tasks.filter(e=>"queued"===e.status).length,J=f.map(e=>X.get(e)).filter(e=>!!e),Y=J.filter(e=>G(e)>0&&!1!==e.active),$=Y.reduce((e,t)=>e+G(t),0),ee=(null==S?void 0:S.running)===!0,et=v.some(e=>e.running),en=K.some(e=>!e.ready&&!e.startChoiceCanFix),ea=ee||0===Y.length||et||en,el=et?{title:"batch.oneRunning",why:"batch.oneRunningWhy"}:0===J.length?{title:"batch.pickFirst",why:"batch.pickFirstWhy"}:0===Y.length?{title:"batch.nothingRunnable",why:"batch.nothingRunnableWhy"}:null,es=(0,o.p)(),[ei,ed]=(0,l.useState)(!1),er=(0,l.useRef)(!1),ec=async e=>{if(!er.current){er.current=!0,ed(!0);try{await e()}catch(e){R(e.message)}finally{er.current=!1,ed(!1),F()}}},eh=async e=>{("unattended"!==e||es||await (0,h.Z)(H("batch.unattendedConfirm",{n:Y.length})))&&await ec(async()=>{var t,n,a;let l=Y.map(e=>e.id),s=await (0,p.L)({sessionIds:l,mode:e,start:t=>d.FH.startBatch(l,e,w,E||void 0,M||void 0,A.trim()||Y.map(e=>e.planName).find(Boolean)||void 0,void 0,t)});D(""),R(s.started?"":null!=(a=null==(t=s.reply)?void 0:t.reason)?a:""),O(s.started||null==(n=s.reply)?void 0:n.failure),V(e=>e+1)})},eo=J.filter(e=>{var t;return(null!=(t=e.model)?t:"")!==E}).length,em=J.filter(e=>{var t;return(null==(t=e.review)?void 0:t.enabled)===!1}).length,eu=null!=(s=null==P?void 0:P.options)?s:[],ep=eu.filter(e=>!e.group),eg=new Map;for(let e of eu)e.group&&eg.set(e.group,[...null!=(r=eg.get(e.group))?r:[],e]);let ex=S?{done:S.sessions.filter(e=>"done"===e.state).length,failed:S.sessions.filter(e=>"failed"===e.state).length,skipped:S.sessions.filter(e=>"skipped"===e.state||"stopped"===e.state).length}:null,ej=null==S?void 0:S.sessions.find(e=>"running"===e.state);return(0,a.jsxs)("div",{className:"panel",children:[(0,a.jsx)("h2",{children:H("batch.title")}),(0,a.jsx)("p",{className:"muted small",children:H("batch.hint")}),!ee&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"row",children:[(0,a.jsx)("strong",{className:"small",children:H("batch.selected",{n:Y.length,tasks:$})}),(0,a.jsx)("button",{className:"quiet",onClick:()=>N(v.filter(e=>G(e)>0).map(e=>e.id)),children:H("batch.selectQueued")}),(0,a.jsx)("button",{className:"quiet",onClick:()=>N([]),disabled:0===J.length,children:H("batch.selectNone")})]}),k&&(0,a.jsx)("p",{className:"muted small",children:H("batch.fromPlan")}),J.length>Y.length&&(0,a.jsx)("p",{className:"muted small",children:H("batch.notRunnable",{n:J.length-Y.length})}),Y.length>0&&(0,a.jsx)("ol",{className:"run-order",children:Y.map((e,t)=>(0,a.jsxs)("li",{children:[(0,a.jsxs)("span",{children:[e.name," ",(0,a.jsxs)("span",{className:"muted small",children:["(",G(e),")"]})]}),(0,a.jsxs)("span",{children:[(0,a.jsx)("button",{className:"quiet",onClick:()=>I(e.id,-1),disabled:0===t,"aria-label":H("batch.moveUp",{name:e.name}),children:"↑"}),(0,a.jsx)("button",{className:"quiet",onClick:()=>I(e.id,1),disabled:t===Y.length-1,"aria-label":H("batch.moveDown",{name:e.name}),children:"↓"})]})]},e.id))}),(0,a.jsx)("label",{htmlFor:"batch-run-name",children:H("batch.runName")}),(0,a.jsx)("input",{id:"batch-run-name",type:"text",value:A,onChange:e=>L(e.target.value),placeholder:null!=(x=Y.map(e=>e.planName).find(Boolean))?x:H("batch.runNamePlaceholder")}),(0,a.jsx)("p",{className:"why",children:H("batch.runNameWhy")}),(0,a.jsx)("label",{htmlFor:"batch-model",children:H("batch.model")}),(0,a.jsxs)("div",{className:"row",children:[(0,a.jsxs)("select",{id:"batch-model",value:E,onChange:e=>B(e.target.value),style:{width:"auto",minWidth:260},children:[(0,a.jsx)("option",{value:"",children:H("batch.modelKeep")}),ep.map(e=>(0,a.jsx)("option",{value:e.name,disabled:e.disabled,children:e.name},e.name)),[...eg.entries()].map(e=>{let[t,n]=e;return(0,a.jsx)("optgroup",{label:t,children:n.map(e=>(0,a.jsx)("option",{value:e.name,disabled:e.disabled,children:e.name},e.name))},t)})]}),(null!=(j=null==P?void 0:P.options.length)?j:0)===0&&(0,a.jsx)("span",{className:"muted small",children:H("batch.modelNone")})]}),(0,a.jsx)("p",{className:"why",children:H("batch.modelWhy")}),(0,a.jsx)(m.L,{current:E,onUse:e=>B(e)}),E&&eo>0&&(0,a.jsx)("p",{className:"why",style:{color:"var(--warn)"},children:H("batch.modelOverrides",{n:eo})}),(0,a.jsx)("label",{htmlFor:"batch-review-model",children:H("batch.reviewModel")}),(0,a.jsx)("div",{className:"row",children:(0,a.jsxs)("select",{id:"batch-review-model",value:M,onChange:e=>q(e.target.value),style:{width:"auto",minWidth:260},children:[(0,a.jsx)("option",{value:"",children:H("batch.reviewModelKeep")}),ep.map(e=>(0,a.jsx)("option",{value:e.name,disabled:e.disabled,children:e.name},e.name)),[...eg.entries()].map(e=>{let[t,n]=e;return(0,a.jsx)("optgroup",{label:t,children:n.map(e=>(0,a.jsx)("option",{value:e.name,disabled:e.disabled,children:e.name},e.name))},t)})]})}),(0,a.jsx)("p",{className:"why",children:H("batch.reviewModelWhy")}),""!==M&&M===E&&(0,a.jsx)("p",{className:"why",style:{color:"var(--warn)"},children:H("batch.reviewSame")}),em>0&&(0,a.jsx)("p",{className:"why",children:H("batch.reviewOffIn",{n:em})}),(0,a.jsxs)("fieldset",{style:{border:0,padding:0,margin:"10px 0 14px"},children:[(0,a.jsx)("legend",{className:"muted small",style:{padding:0},children:H("batch.onFailure")}),(0,a.jsxs)("div",{className:"option",children:[(0,a.jsxs)("label",{children:[(0,a.jsx)("input",{type:"radio",name:"batch-fail",checked:"stop"===w,onChange:()=>y("stop")}),(0,a.jsx)("span",{children:H("batch.chain")})]}),(0,a.jsx)("p",{className:"why",children:H("batch.chainWhy")})]}),(0,a.jsxs)("div",{className:"option",children:[(0,a.jsxs)("label",{children:[(0,a.jsx)("input",{type:"radio",name:"batch-fail",checked:"continue"===w,onChange:()=>y("continue")}),(0,a.jsx)("span",{children:H("batch.independent")})]}),(0,a.jsx)("p",{className:"why",children:H("batch.independentWhy")})]})]}),el&&(0,a.jsxs)("div",{className:"notice caution",children:[(0,a.jsx)("strong",{children:H(el.title)}),(0,a.jsx)("div",{className:"small",style:{marginTop:4},children:H(el.why)})]}),(0,a.jsx)(u.w,{groups:K,sessionIds:Y.map(e=>e.id),onChange:()=>V(e=>e+1)}),T&&(0,a.jsx)(g.X,{failure:U,reason:T,children:/execution\.isolation/.test(T)&&(0,a.jsx)("div",{className:"small",style:{marginTop:4},children:(0,a.jsx)(i(),{href:"/defaults",children:H("batch.notStartedIsolation")})})}),!en&&(0,a.jsxs)("div",{className:"run-choice",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("button",{className:"primary",onClick:()=>void eh("unattended"),disabled:ei||ea,children:H("batch.run",{n:Y.length})}),(0,a.jsx)("p",{className:"why",children:H("batch.runWhy")})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("button",{onClick:()=>void eh("confirm"),disabled:ei||ea,children:H("batch.runStep")}),(0,a.jsx)("p",{className:"why",children:H("batch.runStepWhy")})]})]})]}),ee&&(0,a.jsxs)("div",{className:"row",children:[(null==S?void 0:S.pausing)?(0,a.jsx)("button",{className:"primary",onClick:()=>void ec(async()=>{await d.FH.resumeBatch(),D("")}),disabled:ei||(null==S?void 0:S.stopping),title:H("batch.resumeWhy"),children:H("batch.resume")}):(0,a.jsx)("button",{onClick:()=>void ec(async()=>{await d.FH.pauseBatch(),D(H("batch.pausing"))}),disabled:ei||(null==S?void 0:S.stopping),title:H("batch.pauseWhy"),children:H("batch.pause")}),(0,a.jsx)("button",{onClick:()=>void ec(async()=>{await d.FH.stopBatch(),D(H("batch.stopping"))}),disabled:ei||(null==S?void 0:S.stopping),title:H("batch.stopWhy"),children:H("batch.stop")}),(null==S?void 0:S.pausing)&&!(null==S?void 0:S.stopping)&&(0,a.jsx)("span",{className:"muted small",children:H("batch.pausing")}),(0,a.jsx)("span",{className:"badge",children:H("batch.modelRunning",{name:(ej?(null==(t=X.get(ej.sessionId))?void 0:t.modelInUse)||(null==(n=X.get(ej.sessionId))?void 0:n.model):"")||H("model.default")})}),C.length>0&&(0,a.jsx)("span",{className:"badge waiting-approval",children:H("batch.waiting",{n:C.length})}),ej&&(0,a.jsx)("span",{className:"small",children:H("batch.progress",{name:ej.name,done:S.sessions.filter(e=>"waiting"!==e.state&&"running"!==e.state).length,total:S.sessions.length})})]}),ee&&(0,a.jsx)("p",{className:"muted small",children:H("batch.hiddenWhileRunning")}),W&&(0,a.jsx)("div",{className:"muted small",role:"status",children:W}),(J.length>0||S)&&(0,a.jsxs)("div",{className:"row",style:{marginTop:12},children:[(0,a.jsx)("a",{className:"button-link",href:d.FH.debugExportUrl(J.length>0?J.map(e=>e.id):(null!=(b=null==S?void 0:S.sessions)?b:[]).map(e=>e.sessionId)),children:H("batch.debug")}),(0,a.jsx)("span",{className:"muted small",children:J.length>0?H("batch.debugSelected",{n:J.length}):H("batch.debugLast")})]}),(J.length>0||S)&&(0,a.jsx)("p",{className:"why",children:H("batch.debugWhy")}),S&&(0,a.jsxs)(a.Fragment,{children:[!ee&&ex&&(0,a.jsx)("div",{className:"notice calm",style:{marginTop:12},children:(0,a.jsx)("strong",{children:H("batch.finished",ex)})}),(0,a.jsxs)("table",{style:{marginTop:10},children:[(0,a.jsx)("thead",{children:(0,a.jsxs)("tr",{children:[(0,a.jsx)("th",{children:H("batch.col.session")}),(0,a.jsx)("th",{children:H("batch.col.state")}),(0,a.jsx)("th",{children:H("batch.col.ran")}),(0,a.jsx)("th",{children:H("batch.col.why")})]})}),(0,a.jsx)("tbody",{children:S.sessions.map(e=>{var t,n;return(0,a.jsxs)("tr",{className:"batch-row ".concat(e.state),children:[(0,a.jsx)("td",{children:(0,a.jsx)(i(),{href:(0,d.aT)(e.sessionId),children:e.name})}),(0,a.jsx)("td",{children:(0,a.jsx)("span",{className:"badge ".concat("running"===(n=e.state)?"running":"done"===n?"done":"failed"===n?"failed":"stopped"===n?"aborted":""),children:H("batch.state.".concat(e.state))})}),(0,a.jsx)("td",{className:"small",children:H("batch.ranOf",{ran:e.ran,failed:e.failed})}),(0,a.jsx)("td",{className:"muted small",children:null!=(t=e.reason)?t:""})]},e.sessionId)})})]})]})]})}},4779:(e,t,n)=>{Promise.resolve().then(n.bind(n,4350))},4811:(e,t,n)=>{"use strict";n.d(t,{p:()=>s});var a=n(1521),l=n(5549);function s(){let[e,t]=(0,a.useState)(!1);return(0,a.useEffect)(()=>{let e=!0;return l.FH.settings().then(n=>{var a;let l=null!=(a=n.raw.execution)?a:{};e&&t("unattended"===l.mode)}).catch(()=>void 0),()=>{e=!1}},[]),e}},8848:(e,t,n)=>{"use strict";n.d(t,{H4:()=>c,L:()=>h,z4:()=>o});var a=n(3365),l=n(8197),s=n.n(l),i=n(1521),d=n(5549),r=n(867);function c(e){let{current:t,onUse:n}=e,{t:l}=(0,r.kj)(),[s,c]=(0,i.useState)(null);if((0,i.useEffect)(()=>{let e=!1;return d.FH.project().then(t=>{e||c(t)}).catch(()=>void 0),()=>{e=!0}},[]),!s)return null;let h=s.rootDir.trim(),o=t.trim().toLowerCase(),m=n?s.others.filter(e=>e.rootDir.trim().toLowerCase()!==o):[];return(0,a.jsx)(u,{label:h?l("proj.defaultIs",{dir:h}):l("proj.noneShort"),offer:h&&n&&o!==h.toLowerCase()?{text:l("proj.useIt"),onUse:()=>n(h)}:void 0,more:m.map(e=>({text:l("proj.otherUse",{name:e.name}),title:e.rootDir,onUse:()=>null==n?void 0:n(e.rootDir)})),link:h?l("proj.change"):l("proj.setIt"),anchor:"project"})}function h(e){let{current:t,onUse:n}=e,l=m(),{t:s}=(0,r.kj)();if(!l)return null;let i=l.defaultModel.trim();return(0,a.jsx)(u,{label:i?s("def.modelDefaultIs",{name:i}):s("def.modelNoneShort"),offer:i&&n&&t.trim()!==i?{text:s("def.modelUseIt"),onUse:()=>n(i)}:void 0,link:s(i?"proj.change":"proj.setIt"),anchor:"model"})}function o(e){let{current:t,onUse:n}=e,l=m(),{t:s}=(0,r.kj)();if(!l)return null;let i=l.defaultReviewModel.trim();return(0,a.jsx)(u,{label:i?s("def.reviewDefaultIs",{name:i}):s("def.reviewNoneShort"),offer:i&&n&&t.trim()!==i?{text:s("def.modelUseIt"),onUse:()=>n(i)}:void 0,link:s(i?"proj.change":"proj.setIt"),anchor:"review"})}function m(){let[e,t]=(0,i.useState)(null);return(0,i.useEffect)(()=>{let e=!1;return d.FH.models().then(n=>{e||t(n)}).catch(()=>void 0),()=>{e=!0}},[]),e}function u(e){let{label:t,offer:n,more:l=[],link:i,anchor:d}=e;return(0,a.jsxs)("p",{className:"muted small",style:{marginTop:4},children:[t," ",n&&(0,a.jsxs)(a.Fragment,{children:["\xb7"," ",(0,a.jsx)("button",{type:"button",className:"linkish",onClick:n.onUse,children:n.text})," "]}),l.map(e=>(0,a.jsxs)("span",{children:["\xb7"," ",(0,a.jsx)("button",{type:"button",className:"linkish",onClick:e.onUse,title:e.title,children:e.text})," "]},e.text)),"\xb7 ",(0,a.jsx)(s(),{href:"/defaults#".concat(d),children:i})]})}}},e=>{e.O(0,[197,867,549,499,347,131,358],()=>e(e.s=4779)),_N_E=e.O()}]);
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[66],{1702:(e,s,n)=>{"use strict";var a=n(9962);n.o(a,"usePathname")&&n.d(s,{usePathname:function(){return a.usePathname}}),n.o(a,"useRouter")&&n.d(s,{useRouter:function(){return a.useRouter}}),n.o(a,"useSearchParams")&&n.d(s,{useSearchParams:function(){return a.useSearchParams}})},1772:(e,s,n)=>{Promise.resolve().then(n.bind(n,2438))},2438:(e,s,n)=>{"use strict";n.r(s),n.d(s,{default:()=>W});var a=n(3365),t=n(1521),l=n(1702),i=n(8197),r=n.n(i),c=n(5549),d=n(867),o=n(1910),h=n(3523),u=n(3374),m=n(8078),p=n(8848),v=n(4784),x=n(7619),j=n(5132),g=n(1035),f=n(8934),y=n(4811),b=n(3041),k=n(7527),N=n(1366),w=n(8596),S=n(287),C=n(6983),F=n(1701),I=n(9717);function W(){return(0,a.jsx)(t.Suspense,{fallback:null,children:(0,a.jsx)(M,{})})}function M(){var e;let{t:s}=(0,d.kj)(),n=null!=(e=(0,l.useSearchParams)().get("id"))?e:"",[i,o]=(0,t.useState)(null),[h,u]=(0,t.useState)([]),[m,p]=(0,t.useState)([]),[v,x]=(0,t.useState)(null),[j,g]=(0,t.useState)(""),[f,y]=(0,t.useState)(!1),b=(0,t.useRef)(null),N=(0,t.useRef)(0),w=(0,t.useCallback)(async()=>{if(!n)return;let e=++N.current;try{let s=await c.FH.session(n);if(e!==N.current)return;o(s),g("")}catch(s){if(e!==N.current)return;g(s.message)}},[n]),S=(0,t.useCallback)(()=>{b.current||(b.current=window.setTimeout(()=>{b.current=null,w()},400))},[w]);if((0,t.useEffect)(()=>{if(!n)return;c.FH.presets().then(p).catch(()=>void 0),c.FH.level1().then(x).catch(()=>void 0);let e=new EventSource(c.FH.streamUrl(n));return e.onopen=()=>y(!1),e.onmessage=e=>{let s;try{s=JSON.parse(e.data)}catch(e){return}"ping"!==s.type&&(u(e=>[...e.slice(-400),s]),S())},e.onerror=()=>{e.readyState===EventSource.CLOSED&&y(!0)},()=>{e.close()}},[n,S]),(0,k.z)(w,8e3,!!n),!n)return(0,a.jsx)("div",{className:"panel err",children:s("session.noId")});if(j&&!i)return(0,a.jsx)("div",{className:"panel err",children:j});if(!i)return(0,a.jsx)("div",{className:"panel muted",children:s("home.loading")});let C=i.tasks.filter(e=>"queued"===e.status).length;return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"crumbs",children:[(0,a.jsx)(r(),{href:"/sessions",children:s("session.crumb")})," / ",i.name]}),j&&(0,a.jsx)("div",{className:"panel err",role:"alert",children:s("session.stale",{err:j})}),f&&!j&&(0,a.jsx)("div",{className:"panel muted small",role:"status",children:s("session.streamClosed")}),(0,a.jsx)(T,{session:i,queued:C,onChange:w}),(0,a.jsx)(G,{tasks:i.tasks}),(0,a.jsx)(B,{session:i,onChange:w}),(0,a.jsx)(R,{level1:v,sent:i.contractSent}),(0,a.jsx)(P,{session:i,onChange:w}),(0,a.jsx)(O,{session:i,onChange:w}),(0,a.jsxs)("div",{className:"panel",children:[(0,a.jsx)("h2",{children:s("tasks.title")}),(0,a.jsx)("p",{className:"muted small",children:s("tasks.hint")}),(0,a.jsx)(D,{session:i,onChange:w}),0===i.tasks.length&&(0,a.jsx)("div",{className:"muted",children:s("tasks.none")}),i.tasks.map((e,s)=>(0,a.jsx)(U,{session:i,task:e,index:s+1,presets:m,onChange:w},e.id))]}),(0,a.jsx)(L,{session:i}),(0,a.jsx)(q,{session:i,presets:m,onAdded:w,onPresetsChanged:()=>c.FH.presets().then(p)}),(0,a.jsx)(J,{events:h})]})}function T(e){var s,n;let{session:l,queued:i,onChange:r}=e,{t:o}=(0,d.kj)(),[h,u]=(0,t.useState)(""),[m,p]=(0,t.useState)("");(0,t.useEffect)(()=>{c.FH.models().then(e=>{var s;return p(null!=(s=e.defaultModel)?s:"")}).catch(()=>void 0)},[]);let[v,x]=(0,t.useState)(l.name),[j,f]=(0,t.useState)(null!=(s=l.conversationGroup)?s:"");(0,t.useEffect)(()=>x(l.name),[l.name]),(0,t.useEffect)(()=>{var e;return f(null!=(e=l.conversationGroup)?e:"")},[l.conversationGroup]);let b=(0,y.p)(),[k,N]=(0,t.useState)(!1),w=(0,t.useRef)(!1),S=async e=>{if(!w.current){w.current=!0,N(!0);try{await e()}catch(e){u(e.message)}finally{w.current=!1,N(!1),r()}}},C=async e=>{("unattended"!==e||b||await (0,g.Z)(o("session.unattendedConfirm")))&&await S(async()=>{var s;let n=await (0,F.L)({sessionIds:[l.id],mode:e,start:s=>c.FH.start(l.id,e,l.planName,s)});n.started?u(o("unattended"===e?"session.startedAuto":"session.startedStep")):n.reply&&u(o("session.notStarted",{reason:null!=(s=n.reply.reason)?s:""}))})},I=async()=>{if(l.running)return void u(o("home.deleteRunning"));if(await (0,g.Z)(o("home.deleteConfirm",{name:l.name,n:l.tasks.length})))try{await c.FH.deleteSession(l.id),window.location.href="/"}catch(e){u(e.message)}},W=async()=>{var e;if(j.trim()!==(null!=(e=l.conversationGroup)?e:""))try{await c.FH.updateSession(l.id,{conversationGroup:j.trim()}),u(o("session.groupSaved")),r()}catch(e){u(e.message)}},M=l.running?o("state.running"):o("state.".concat(l.status));return(0,a.jsxs)("div",{className:"panel",children:[(0,a.jsxs)("div",{className:"row",children:[(0,a.jsx)("input",{type:"text",className:"grow","aria-label":o("home.col.name"),value:v,onChange:e=>x(e.target.value),onBlur:()=>void S(async()=>{v.trim()&&v!==l.name&&await c.FH.updateSession(l.id,{name:v})})}),(0,a.jsx)("span",{className:"badge ".concat(l.running?"running":""),children:M})]}),!l.running&&(0,a.jsxs)("div",{className:"run-choice",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("button",{className:"primary",onClick:()=>void C("unattended"),disabled:k||0===i,children:o("session.run",{n:i})}),(0,a.jsx)("p",{className:"why",children:o("session.runWhy")})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("button",{onClick:()=>void C("confirm"),disabled:k||0===i,children:o("session.runStep")}),(0,a.jsx)("p",{className:"why",children:o("session.runStepWhy")})]})]}),(0,a.jsxs)("div",{className:"row",style:{marginTop:10},children:[l.running&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("button",{className:"danger",onClick:()=>void S(async()=>{await c.FH.stop(l.id),u(o("session.stopping"))}),disabled:k,children:o("session.stop")}),"unattended"===l.runMode&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("span",{className:"badge waiting-approval",children:o("session.modeUnattended")}),(0,a.jsx)("button",{onClick:()=>void S(async()=>{await c.FH.setRunMode(l.id,"confirm"),u(o("session.askingAgain"))}),disabled:k,children:o("session.askAgain")})]})]}),(0,a.jsx)("span",{className:"muted small",children:h}),(0,a.jsx)("span",{className:"grow"}),(0,a.jsx)("button",{className:"quiet",onClick:()=>void I(),disabled:l.running,children:o("home.delete")}),l.chat?(0,a.jsx)("a",{href:l.chat.url,target:"_blank",rel:"noreferrer",className:"small",children:o("session.openChat",{name:l.chat.name})}):(0,a.jsx)("span",{className:"muted small",children:o("session.noChat")})]}),(0,a.jsx)("label",{htmlFor:"session-group",children:o("session.group")}),(0,a.jsx)("div",{className:"row",children:(0,a.jsx)("input",{id:"session-group",type:"text",className:"grow",value:j,placeholder:o("session.groupPlaceholder"),onChange:e=>f(e.target.value),onBlur:()=>void W(),disabled:l.running})}),(0,a.jsxs)("p",{className:"why",children:[o("session.groupWhy"),l.chat&&" ".concat(o("session.groupHasChat"))]}),(0,a.jsx)("label",{htmlFor:"session-plan-mode",children:o("pm.sessionSetting")}),(0,a.jsxs)("select",{id:"session-plan-mode",value:null!=(n=l.planMode)?n:"",onChange:e=>{let s=e.target.value;c.FH.updateSession(l.id,{planMode:s}).then(()=>{u(o("pm.saved")),r()}).catch(e=>u(e.message))},disabled:l.running,style:{width:"auto",maxWidth:"100%"},children:[(0,a.jsx)("option",{value:"",children:o("pm.followSettings")}),(0,a.jsx)("option",{value:"off",children:o("pm.off")}),(0,a.jsx)("option",{value:"auto",children:o("pm.auto")}),(0,a.jsx)("option",{value:"approve",children:o("pm.approveMode")})]}),(0,a.jsx)("p",{className:"why",children:o("pm.sessionWhy")}),(0,a.jsx)("div",{className:"muted small",style:{marginTop:10},children:o("session.willUseModel",{name:(l.model&&("operator"===l.modelSource||!m)?l.model:"")||(m?o("model.followsDefault",{name:m}):o("model.default"))})})]})}function R(e){var s;let{level1:n,sent:t}=e,{t:l}=(0,d.kj)();return(0,a.jsxs)("div",{className:"panel",children:[(0,a.jsxs)("div",{className:"row",children:[(0,a.jsx)("h2",{className:"grow",style:{margin:0},children:l("l1.title")}),(0,a.jsx)("span",{className:"badge",children:l(t?"l1.sent":"l1.notSent")}),(0,a.jsx)(r(),{href:"/level1",className:"small",children:l("l1.edit")})]}),(0,a.jsxs)("p",{className:"muted small",style:{marginBottom:6},children:[l("l1.hint"),(null==n?void 0:n.customised)?" ".concat(l("l1.customised")):""]}),(0,a.jsxs)("details",{children:[(0,a.jsx)("summary",{children:l("l1.show")}),(0,a.jsx)("pre",{className:"tall",children:null!=(s=null==n?void 0:n.content)?s:"…"})]})]})}function B(e){var s,n,l,i,r;let{session:o,onChange:h}=e,{t:u}=(0,d.kj)(),m=(0,d.W3)(),[v,x]=(0,t.useState)(null),[j,f]=(0,t.useState)(!1),[y,b]=(0,t.useState)("");(0,t.useEffect)(()=>{c.FH.models().then(x).catch(()=>void 0)},[]);let k=async e=>{try{await c.FH.updateSession(o.id,{model:e}),b(e?u("model.saved",{name:e}):u("model.savedDefault")),h()}catch(e){b(e.message)}},N=async()=>{try{let e=await c.FH.setDefaultModel(C);x(s=>s?{...s,defaultModel:e.defaultModel}:s),b(e.defaultModel?u("model.defaultSaved",{name:e.defaultModel}):u("model.defaultCleared"))}catch(e){b(e.message)}},w=async()=>{if(await (0,g.Z)(u("model.refreshConfirm"))){f(!0),b(u("model.refreshing"));try{var e;let s=await c.FH.refreshModels();x(s),b(0===s.options.length?null!=(e=s.note)?e:u("model.none"):u("model.refreshed",{n:s.options.length}))}catch(e){b(e.message)}finally{f(!1)}}},S=!!o.model&&"operator"!==o.modelSource&&!!(null==v?void 0:v.defaultModel),C=S?"":null!=(s=o.model)?s:"",F=null!=(n=null==v?void 0:v.options)?n:[],I=F.some(e=>e.name===C),W=F.filter(e=>!e.group),M=new Map;for(let e of F)e.group&&M.set(e.group,[...null!=(l=M.get(e.group))?l:[],e]);return(0,a.jsxs)("div",{className:"panel",children:[(0,a.jsxs)("div",{className:"row",children:[(0,a.jsx)("h2",{className:"grow",style:{margin:0},children:u("model.title")}),o.modelInUse&&(0,a.jsx)("span",{className:"chip",children:u("model.lastUsed",{name:o.modelInUse})}),S&&(0,a.jsx)("p",{className:"muted small",children:u("model.planOutranked",{name:null!=(i=o.model)?i:""})})]}),(0,a.jsx)("p",{className:"muted small",children:u("model.hint")}),(0,a.jsxs)("div",{className:"row",children:[(0,a.jsxs)("select",{"aria-label":u("model.title"),value:C,disabled:o.running,onChange:e=>void k(e.target.value),style:{width:"auto",minWidth:260},children:[(0,a.jsx)("option",{value:"",children:(null==v?void 0:v.defaultModel)?u("model.followsDefault",{name:v.defaultModel}):u("model.default")}),C&&!I&&(0,a.jsx)("option",{value:C,children:u("model.notInList",{name:C})}),W.map(e=>(0,a.jsxs)("option",{value:e.name,disabled:e.disabled,children:[e.name,e.disabled?" — ".concat(u("model.unavailable")):""]},e.name)),[...M.entries()].map(e=>{let[s,n]=e;return(0,a.jsx)("optgroup",{label:s,children:n.map(e=>(0,a.jsxs)("option",{value:e.name,disabled:e.disabled,children:[e.name,e.disabled?" — ".concat(u("model.unavailable")):""]},e.name))},s)})]}),(0,a.jsx)("button",{onClick:()=>void w(),disabled:j||o.running,children:u("model.refresh")}),(0,a.jsx)("span",{className:"muted small",role:"status",children:y})]}),(0,a.jsx)(p.L,{current:C,onUse:e=>void k(e)}),(0,a.jsxs)("div",{className:"row",style:{marginTop:8},children:[(0,a.jsx)("span",{className:"muted small",children:(null==v?void 0:v.defaultModel)?u("model.defaultIs",{name:v.defaultModel}):u("model.defaultIsNone")}),(0,a.jsx)("button",{onClick:()=>void N(),disabled:C===(null!=(r=null==v?void 0:v.defaultModel)?r:""),children:C?u("model.makeDefault",{name:C}):u("model.clearDefault")})]}),(null==v?void 0:v.readAt)?(0,a.jsxs)("p",{className:"muted small",style:{marginTop:8},children:[u("model.readAt",{t:m(v.readAt),n:v.options.length}),v.current?" ".concat(u("model.chatWasOn",{name:v.current})):"",v.note?" ".concat(v.note):""]}):(0,a.jsx)("p",{className:"muted small",style:{marginTop:8},children:u("model.neverRead")}),F.length>0&&(0,a.jsxs)("details",{children:[(0,a.jsx)("summary",{children:u("model.showDetails")}),(0,a.jsx)("pre",{className:"tall",children:F.map(e=>"".concat(e.selected?"*":" "," ").concat(e.group?"".concat(e.group," > "):"").concat(e.name)+"".concat(e.disabled?" [unavailable]":"","\n ").concat(e.raw.replace(/\n/g," | "))).join("\n")})]})]})}function O(e){var s,n;let{session:l,onChange:i}=e,{t:r}=(0,d.kj)(),o=null!=(s=l.review)?s:{enabled:!0,model:""},[h,u]=(0,t.useState)(o.enabled),[m,x]=(0,t.useState)(null!=(n=o.model)?n:""),[j,g]=(0,t.useState)(""),[f,y]=(0,t.useState)(!1),[b,k]=(0,t.useState)("");(0,t.useEffect)(()=>{c.FH.models().then(e=>{var s;k(null!=(s=e.defaultReviewModel)?s:""),e.defaultReviewModel&&"operator"!==l.reviewModelSource&&x("")}).catch(()=>void 0)},[l.reviewModelSource]);let N=async()=>{y(!0),g("");try{await c.FH.updateSession(l.id,{review:{enabled:h,model:m}}),g(r("review.saved")),i()}catch(e){g(e.message)}finally{y(!1)}};return(0,a.jsxs)("div",{className:"panel",children:[(0,a.jsxs)("div",{className:"row",children:[(0,a.jsx)("h2",{className:"grow",style:{margin:0},children:r("review.title")}),(0,a.jsx)("span",{className:"badge ".concat(h?"done":""),children:h?r("review.on"):r("review.off")})]}),(0,a.jsx)("p",{className:"muted small",children:r("review.hint")}),(0,a.jsxs)("div",{className:"option",children:[(0,a.jsxs)("label",{children:[(0,a.jsx)("input",{type:"checkbox",checked:h,onChange:e=>u(e.target.checked),disabled:l.running}),(0,a.jsx)("span",{children:r("review.enable")})]}),(0,a.jsx)("p",{className:"why",children:r("review.enableWhy")})]}),(0,a.jsx)("label",{htmlFor:"review-model",children:r("review.modelField")}),(0,a.jsx)("div",{className:"row",children:(0,a.jsx)(v.Y,{id:"review-model",chosen:m,onChange:x,none:b?r("model.followsDefault",{name:b}):r("review.modelSame"),disabled:l.running||!h})}),(0,a.jsx)("p",{className:"why",children:r("review.modelWhy")}),(0,a.jsx)(p.z4,{current:m,onUse:e=>x(e)}),(0,a.jsxs)("div",{className:"row",style:{marginTop:10},children:[(0,a.jsx)("button",{className:"primary",onClick:()=>void N(),disabled:f||l.running,children:r("review.save")}),j&&(0,a.jsx)("span",{className:"muted small",children:j})]})]})}function H(e){var s;let{session:n,plan:l,onDone:i}=e,{t:r}=(0,d.kj)(),o=()=>Object.fromEntries(l.entries.filter(e=>e.choice).map(e=>[e.path,e.choice])),h=JSON.stringify(l.entries.map(e=>[e.path,e.choice])),[u,m]=(0,t.useState)(o);(0,t.useEffect)(()=>m(o()),[h]);let[p,v]=(0,t.useState)(!1),[x,j]=(0,t.useState)(""),g=l.entries.filter(e=>"include"===u[e.path]).length,f=async()=>{v(!0),j("");try{var e,s,a;let t=await c.FH.vcsSnapshot(n.id,u);j(t.ok?r("vcs.snapshotTaken",{branch:null!=(e=t.branch)?e:"",commit:(null!=(s=t.commit)?s:"").slice(0,8)}):null!=(a=t.problem)?a:""),i()}catch(e){j(e.message)}finally{v(!1)}};return(0,a.jsxs)("div",{className:"option",children:[(0,a.jsx)("p",{className:"small",children:r("vcs.snapshotList",{n:l.entries.length,branch:null!=(s=l.baselineBranch)?s:"—"})}),(0,a.jsx)("ul",{style:{margin:"4px 0",paddingLeft:0,listStyle:"none"},children:l.entries.map(e=>{var s;return(0,a.jsxs)("li",{style:{marginBottom:4,overflowWrap:"anywhere"},children:[(0,a.jsx)("code",{children:e.path})," ",(0,a.jsxs)("span",{className:"muted small",children:["(",e.input?"".concat(r("vcs.snapshotInput"),", "):"",r("vcs.snapshotKind.".concat(e.kind)),void 0!==e.size?", ".concat((0,c.zi)(e.size)):"",")"]})," ",0===e.allowed.length?(0,a.jsx)("span",{className:"err small",children:r("vcs.snapshotBlocked")}):(0,a.jsx)("select",{"aria-label":e.path,value:null!=(s=u[e.path])?s:"",onChange:s=>m({...u,[e.path]:s.target.value}),disabled:p||n.running||e.allowed.length<2,children:e.allowed.map(e=>(0,a.jsx)("option",{value:e,children:r("include"===e?"vcs.snapshotInclude":"vcs.snapshotLeaveOut")},e))}),e.reason&&(0,a.jsx)("div",{className:"muted small",children:e.reason})]},e.path)})}),(0,a.jsx)("button",{className:"primary",onClick:()=>void f(),disabled:p||n.running||!l.ok||0===g,children:r("vcs.snapshotTake")}),(0,a.jsx)("p",{className:"why",children:r("vcs.snapshotCancelWhy")}),x&&(0,a.jsx)("p",{className:"small",role:"status",children:x})]})}function P(e){var s,n,l,i,r,o,h,u,m,v,x,j,g,f,y,b,k,N,S,C,F,I,W,M,T,R,B,O,P,D,A,L,E,q,U,J;let{session:z,onChange:G}=e,{t:Z}=(0,d.kj)(),K=null!=(g=z.vcs)?g:{enabled:!0,repoDir:"",branchMode:"per-task",commitOnFinish:!0,branchPrefix:"cop/"},[_,Y]=(0,t.useState)(K.repoDir),[Q,V]=(0,t.useState)(null),[X,$]=(0,t.useState)(""),[ee,es]=(0,t.useState)(!1),en=JSON.stringify(K),[ea,et]=(0,t.useState)(null),[el,ei]=(0,t.useState)(null!=(f=K.branchName)?f:"");(0,t.useEffect)(()=>{var e;return ei(null!=(e=JSON.parse(en).branchName)?e:"")},[en]);let[er,ec]=(0,t.useState)(null!=(y=K.baseBranch)?y:"");(0,t.useEffect)(()=>{var e;return ec(null!=(e=JSON.parse(en).baseBranch)?e:"")},[en]);let[ed,eo]=(0,t.useState)((null!=(b=null==(s=K.userInputs)?void 0:s.paths)?b:[]).join("\n"));(0,t.useEffect)(()=>{var e,s;return eo((null!=(s=null==(e=JSON.parse(en).userInputs)?void 0:e.paths)?s:[]).join("\n"))},[en]);let[eh,eu]=(0,t.useState)((null!=(k=null==(n=K.artifacts)?void 0:n.paths)?k:[]).join("\n"));(0,t.useEffect)(()=>{var e,s;return eu((null!=(s=null==(e=JSON.parse(en).artifacts)?void 0:e.paths)?s:[]).join("\n"))},[en]);let em=e=>e.split(/\r?\n/).map(e=>e.trim()).filter(Boolean),[ep,ev]=(0,t.useState)(null!=(N=K.existingBranch)?N:"");(0,t.useEffect)(()=>{var e;return ev(null!=(e=JSON.parse(en).existingBranch)?e:"")},[en]);let ex=null!=(S=K.startFrom)?S:"head";(0,t.useEffect)(()=>{Y(JSON.parse(en).repoDir)},[en]);let ej=JSON.parse(en).repoDir||z.projectDir||"";(0,t.useEffect)(()=>{let e=!1;return ej.trim()?(c.FH.repoCheck(ej).then(s=>{var n;e||et(s.ok?null:null!=(n=s.problem)?n:null)}).catch(()=>{e||et(null)}),()=>{e=!0}):void et(null)},[ej]);let eg=(0,t.useCallback)(()=>{c.FH.vcsStatus(z.id).then(V).catch(()=>V(null))},[z.id]);(0,t.useEffect)(eg,[eg,en]);let ef=async e=>{try{await c.FH.updateSession(z.id,{vcs:e}),$(Z("vcs.saved")),G(),eg()}catch(e){$(e.message)}},ey=async()=>{es(!0),$(Z("mirror.browsing"));try{let s=await c.FH.browseFolder(_.trim()||z.projectDir||void 0);if(s.ok)Y(s.path),await ef({repoDir:s.path});else{var e;$(s.cancelled?Z("mirror.browseCancelled"):null!=(e=s.reason)?e:"")}}catch(e){$(e.message)}finally{es(!1)}},eb=K.repoDir||z.projectDir||"",ek=""!==eb.trim()&&null===ea;return(0,a.jsxs)("div",{className:"panel",children:[(0,a.jsxs)("div",{className:"row",children:[(0,a.jsx)("h2",{className:"grow",style:{margin:0},children:Z("vcs.title")}),(0,a.jsx)("span",{className:"badge ".concat(K.enabled?"done":""),children:K.enabled?Z("vcs.on"):Z("vcs.off")})]}),(0,a.jsx)("p",{className:"muted small",children:Z("vcs.hint")}),(0,a.jsx)("label",{htmlFor:"vcs-root",children:Z("vcs.repoField")}),(0,a.jsxs)("div",{className:"row",children:[(0,a.jsx)("input",{id:"vcs-root",type:"text",className:"grow",value:_,onChange:e=>Y(e.target.value),onBlur:()=>_.trim()!==K.repoDir&&void ef({repoDir:_.trim()}),placeholder:z.projectDir||"C:\\Projects\\my-app",disabled:z.running}),(0,a.jsx)("button",{onClick:()=>void ey(),disabled:ee||z.running,children:Z("mirror.browse")})]}),(0,a.jsx)(p.H4,{current:_,onUse:e=>{Y(e),ef({repoDir:e})}}),ea&&(0,a.jsxs)("div",{className:"notice caution",style:{marginTop:8},children:[(0,a.jsx)("strong",{children:Z("vcs.noRepo")}),(0,a.jsx)("div",{className:"small",style:{marginTop:4},children:ea}),(0,a.jsx)("div",{className:"muted small",style:{marginTop:6},children:Z("vcs.noRepoHow")})]}),!ea&&""!==eb.trim()&&(0,a.jsx)("p",{className:"muted small",style:{marginTop:4},children:Z("vcs.repoOk")}),""===eb.trim()&&(0,a.jsx)("p",{className:"muted small",style:{marginTop:4},children:Z("vcs.pickFirst")}),(0,a.jsxs)("div",{className:"option".concat(ek||K.enabled?"":" warned"),children:[(0,a.jsxs)("label",{children:[(0,a.jsx)("input",{type:"checkbox",checked:K.enabled,onChange:e=>void ef({enabled:e.target.checked}),disabled:z.running||!ek&&!K.enabled}),(0,a.jsx)("span",{children:Z("vcs.enable")})]}),(0,a.jsx)("p",{className:"why",children:Z("vcs.enableWhy")})]}),K.enabled&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("div",{className:"muted small",style:{marginTop:4},children:eb?Z("vcs.repoIs",{dir:eb}):Z("vcs.repoNone")}),eb&&!ea&&(0,a.jsx)(w.E,{dir:eb}),(0,a.jsx)("h3",{children:Z("vcs.branches")}),"existing-branch"===ex&&(0,a.jsx)("p",{className:"muted small",children:Z("vcs.branchesExisting",{branch:K.existingBranch||"…"})}),(0,a.jsxs)("div",{className:"option",children:[(0,a.jsxs)("label",{children:[(0,a.jsx)("input",{type:"radio",name:"branchMode",checked:"per-task"===K.branchMode,onChange:()=>void ef({branchMode:"per-task"}),disabled:z.running}),(0,a.jsx)("span",{children:Z("vcs.perTask")})]}),(0,a.jsx)("p",{className:"why",children:Z("vcs.perTaskWhy")})]}),(0,a.jsxs)("div",{className:"option",children:[(0,a.jsxs)("label",{children:[(0,a.jsx)("input",{type:"radio",name:"branchMode",checked:"per-session"===K.branchMode,onChange:()=>void ef({branchMode:"per-session"}),disabled:z.running}),(0,a.jsx)("span",{children:Z("vcs.perSession")})]}),(0,a.jsx)("p",{className:"why",children:Z("vcs.perSessionWhy")})]}),"per-session"===K.branchMode&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("label",{htmlFor:"vcs-branch-name",children:Z("vcs.branchName")}),(0,a.jsx)("input",{id:"vcs-branch-name",type:"text",value:el,onChange:e=>ei(e.target.value),onBlur:()=>{var e;return el.trim()!==(null!=(e=K.branchName)?e:"")&&void ef({branchName:el.trim()})},placeholder:z.name,disabled:z.running}),(0,a.jsx)("p",{className:"why",children:Z("vcs.branchNameWhy")})]}),(0,a.jsx)("h3",{children:Z("vcs.startFrom")}),(0,a.jsx)("p",{className:"muted small",children:Z("vcs.startAsked")}),K.baseRemote&&("branch"===ex||"existing-branch"===ex)&&(0,a.jsx)("p",{className:"small",children:Z("vcs.fromRemote",{remote:K.baseRemote,branch:("existing-branch"===ex?K.existingBranch:K.baseBranch)||"main"})}),(0,a.jsxs)("div",{className:"option",children:[(0,a.jsxs)("label",{children:[(0,a.jsx)("input",{type:"radio",name:"startFrom",checked:"branch"===ex,onChange:()=>void ef({startFrom:"branch"}),disabled:z.running}),(0,a.jsx)("span",{children:Z("vcs.startBranch")})]}),(0,a.jsx)("p",{className:"why",children:Z("vcs.startBranchWhy")})]}),(0,a.jsxs)("div",{className:"option",children:[(0,a.jsxs)("label",{children:[(0,a.jsx)("input",{type:"radio",name:"startFrom",checked:"previous-session"===ex,onChange:()=>void ef({startFrom:"previous-session"}),disabled:z.running}),(0,a.jsx)("span",{children:Z("vcs.startPrevious")})]}),(0,a.jsx)("p",{className:"why",children:Z("vcs.startPreviousWhy")})]}),(0,a.jsxs)("div",{className:"option",children:[(0,a.jsxs)("label",{children:[(0,a.jsx)("input",{type:"radio",name:"startFrom",checked:"head"===ex,onChange:()=>void ef({startFrom:"head"}),disabled:z.running}),(0,a.jsx)("span",{children:Z("vcs.startHead")})]}),(0,a.jsx)("p",{className:"why",children:Z("vcs.startHeadWhy")})]}),(0,a.jsxs)("div",{className:"option",children:[(0,a.jsxs)("label",{children:[(0,a.jsx)("input",{type:"radio",name:"startFrom",checked:"existing-branch"===ex,onChange:()=>void ef({startFrom:"existing-branch"}),disabled:z.running}),(0,a.jsx)("span",{children:Z("vcs.startExisting")})]}),(0,a.jsx)("p",{className:"why",children:Z("vcs.startExistingWhy")})]}),"existing-branch"===ex&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("label",{htmlFor:"vcs-existing-branch",children:Z("vcs.existingBranch")}),(0,a.jsx)("input",{id:"vcs-existing-branch",type:"text",list:"vcs-local-branches",value:ep,onChange:e=>ev(e.target.value),onBlur:()=>{var e;return ep.trim()!==(null!=(e=K.existingBranch)?e:"")&&void ef({existingBranch:ep.trim()})},disabled:z.running}),(0,a.jsx)("datalist",{id:"vcs-local-branches",children:(null!=(C=null==Q?void 0:Q.branches)?C:[]).map(e=>(0,a.jsx)("option",{value:e},e))}),(0,a.jsx)("p",{className:"why",children:Z("vcs.existingBranchWhy")}),K.existingBranch&&(null==Q?void 0:Q.branches)&&!Q.branches.includes(K.existingBranch)&&(0,a.jsx)("p",{className:"err small",children:Z("vcs.existingBranchMissing",{branch:K.existingBranch})})]}),("branch"===ex||"previous-session"===ex)&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("label",{htmlFor:"vcs-base-branch",children:Z("vcs.baseBranch")}),(0,a.jsx)("input",{id:"vcs-base-branch",type:"text",value:er,onChange:e=>ec(e.target.value),onBlur:()=>{var e;return er.trim()!==(null!=(e=K.baseBranch)?e:"")&&void ef({baseBranch:er.trim()})},placeholder:"main",disabled:z.running}),(0,a.jsx)("p",{className:"why",children:Z("vcs.baseBranchWhy")})]}),z.vcsStart&&(0,a.jsxs)("p",{className:"muted small",children:["existing-branch"===z.vcsStart.kind?Z("vcs.startedExisting",{branch:null!=(F=z.vcsStart.branch)?F:"",commit:z.vcsStart.commit.slice(0,8)}):"previous-session"===z.vcsStart.kind?Z("vcs.startedPrevious",{name:null!=(I=null==(l=z.vcsStart.fromSession)?void 0:l.name)?I:"",branch:null!=(W=z.vcsStart.branch)?W:"",commit:z.vcsStart.commit.slice(0,8)}):"branch"===z.vcsStart.kind?Z(z.vcsStart.remote?"vcs.startedRemote":"vcs.startedBranch",{branch:null!=(M=z.vcsStart.branch)?M:"",commit:z.vcsStart.commit.slice(0,8)}):"snapshot"===z.vcsStart.kind?Z("vcs.startedSnapshot",{branch:null!=(T=z.vcsStart.branch)?T:"",commit:z.vcsStart.commit.slice(0,8),from:null!=(R=null==(i=z.vcsStart.snapshot)?void 0:i.fromBranch)?R:"HEAD",n:null!=(B=null==(r=z.vcsStart.snapshot)?void 0:r.included.length)?B:0,out:null!=(O=null==(o=z.vcsStart.snapshot)?void 0:o.leftOut.length)?O:0}):Z("vcs.startedHead",{commit:z.vcsStart.commit.slice(0,8)}),z.vcsStart.note?" — ".concat(z.vcsStart.note):"",z.vcsStart.update&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("br",{}),"updated"===z.vcsStart.update.outcome?Z("vcs.updated",{branch:z.vcsStart.update.branch,remote:null!=(P=z.vcsStart.update.remote)?P:"",from:(null!=(D=z.vcsStart.update.from)?D:"").slice(0,8),to:(null!=(A=z.vcsStart.update.to)?A:"").slice(0,8)}):"up-to-date"===z.vcsStart.update.outcome?Z("vcs.upToDate",{branch:z.vcsStart.update.branch,remote:null!=(L=z.vcsStart.update.remote)?L:""}):Z("vcs.notUpdated",{branch:z.vcsStart.update.branch,why:null!=(E=z.vcsStart.update.detail)?E:z.vcsStart.update.outcome})]})]}),"head"!==ex&&(0,a.jsxs)("div",{className:"option",children:[(0,a.jsxs)("label",{children:[(0,a.jsx)("input",{type:"checkbox",checked:!1!==K.updateFromRemote,onChange:e=>void ef({updateFromRemote:e.target.checked}),disabled:z.running}),(0,a.jsx)("span",{children:Z("vcs.updateFromRemote")})]}),(0,a.jsx)("p",{className:"why",children:Z("vcs.updateFromRemoteWhy")})]}),(0,a.jsxs)("div",{className:"option",children:[(0,a.jsxs)("label",{children:[(0,a.jsx)("input",{type:"checkbox",checked:K.commitOnFinish,onChange:e=>void ef({commitOnFinish:e.target.checked}),disabled:z.running}),(0,a.jsx)("span",{children:Z("vcs.commit")})]}),(0,a.jsx)("p",{className:"why",children:Z("vcs.commitWhy")})]}),"existing-branch"!==ex&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("h3",{children:Z("vcs.dirty")}),["reject","snapshot","tracked-only-snapshot"].map(e=>{var s,n;return(0,a.jsxs)("div",{className:"option",children:[(0,a.jsxs)("label",{children:[(0,a.jsx)("input",{type:"radio",name:"vcs-dirty-".concat(z.id),checked:(null!=(n=null==(s=K.dirtyWorktree)?void 0:s.policy)?n:"reject")===e,onChange:()=>{var s;ef({dirtyWorktree:{policy:e,requireApproval:null==(s=K.dirtyWorktree)?void 0:s.requireApproval}})},disabled:z.running}),(0,a.jsx)("span",{children:Z("reject"===e?"vcs.dirtyReject":"snapshot"===e?"vcs.dirtySnapshot":"vcs.dirtyTracked")})]}),(0,a.jsx)("p",{className:"why",children:Z("reject"===e?"vcs.dirtyRejectWhy":"snapshot"===e?"vcs.dirtySnapshotWhy":"vcs.dirtyTrackedWhy")})]},e)}),(null!=(q=null==(h=K.dirtyWorktree)?void 0:h.policy)?q:"reject")!=="reject"&&(0,a.jsxs)("div",{className:"option",children:[(0,a.jsxs)("label",{children:[(0,a.jsx)("input",{type:"checkbox",checked:(null==(u=K.dirtyWorktree)?void 0:u.requireApproval)!==!1,onChange:e=>{var s,n;ef({dirtyWorktree:{policy:null!=(n=null==(s=K.dirtyWorktree)?void 0:s.policy)?n:"snapshot",requireApproval:e.target.checked}})},disabled:z.running}),(0,a.jsx)("span",{children:Z("vcs.dirtyApproval")})]}),(0,a.jsx)("p",{className:"why",children:Z("vcs.dirtyApprovalWhy")})]})]}),(0,a.jsx)("h3",{children:Z("vcs.inputs")}),(0,a.jsx)("label",{htmlFor:"vcs-inputs-".concat(z.id),children:Z("vcs.inputsField")}),(0,a.jsx)("textarea",{id:"vcs-inputs-".concat(z.id),rows:3,value:ed,onChange:e=>eo(e.target.value),onBlur:()=>{var e,s;return JSON.stringify(em(ed))!==JSON.stringify(null!=(s=null==(e=K.userInputs)?void 0:e.paths)?s:[])&&void ef({userInputs:{...K.userInputs,paths:em(ed)}})},disabled:z.running,placeholder:"rules-engine/test-data/schemas/*.yaml",spellCheck:!1}),(0,a.jsx)("p",{className:"why",children:Z("vcs.inputsWhy")}),(null!=(U=null==(m=K.userInputs)?void 0:m.paths.length)?U:0)>0&&(0,a.jsxs)("div",{className:"option",children:[(0,a.jsxs)("label",{children:[(0,a.jsx)("input",{type:"checkbox",checked:(null==(v=K.userInputs)?void 0:v.readOnly)!==!1,onChange:e=>{var s,n,a;ef({userInputs:{paths:null!=(a=null==(s=K.userInputs)?void 0:s.paths)?a:[],requireApproval:null==(n=K.userInputs)?void 0:n.requireApproval,readOnly:e.target.checked}})},disabled:z.running}),(0,a.jsx)("span",{children:Z("vcs.inputsReadOnly")})]}),(0,a.jsx)("p",{className:"why",children:Z("vcs.inputsReadOnlyWhy")})]}),(null==(x=z.vcsStart)?void 0:x.inputs)&&(0,a.jsx)("p",{className:"muted small",children:z.vcsStart.inputs.carried?Z("vcs.inputsCarried",{n:z.vcsStart.inputs.files.length,branch:z.vcsStart.inputs.carried.branch,onto:z.vcsStart.inputs.carried.onto.slice(0,8)}):Z("vcs.inputsRecorded",{n:z.vcsStart.inputs.files.length,commit:z.vcsStart.commit.slice(0,8)})}),(0,a.jsx)("h3",{children:Z("vcs.artifacts")}),(0,a.jsx)("label",{htmlFor:"vcs-artifacts-".concat(z.id),children:Z("vcs.artifactsField")}),(0,a.jsx)("textarea",{id:"vcs-artifacts-".concat(z.id),rows:2,value:eh,onChange:e=>eu(e.target.value),onBlur:()=>{var e,s;return JSON.stringify(em(eh))!==JSON.stringify(null!=(s=null==(e=K.artifacts)?void 0:e.paths)?s:[])&&void ef({artifacts:{paths:em(eh)}})},disabled:z.running,placeholder:"rules-engine/test-results/**",spellCheck:!1}),(0,a.jsx)("p",{className:"why",children:Z("vcs.artifactsWhy")}),Q&&!Q.ok&&(0,a.jsxs)("div",{className:"notice caution",role:"status",children:[(0,a.jsx)("strong",{children:Z("vcs.notReady")})," ",Q.problem]}),(null==Q||null==(j=Q.snapshot)?void 0:j.needed)&&Q.snapshot.entries.length>0&&(0,a.jsx)(H,{session:z,plan:Q.snapshot,onDone:()=>{G(),eg()}}),(null==Q?void 0:Q.ok)&&(0,a.jsx)("div",{className:"muted small",children:Z("vcs.ready",{branch:null!=(J=Q.branch)?J:"—",dir:Q.repoDir})}),(null==Q?void 0:Q.ok)&&Q.work&&Q.work.branches.length>0&&(0,a.jsxs)("div",{className:"muted small",children:["per-session"===Q.work.mode&&Q.work.complete?Z("vcs.completeOn",{branch:Q.work.complete}):Z("vcs.noSingleBranch",{n:Q.work.branches.length}),"per-task"===Q.work.mode&&(0,a.jsx)("ul",{style:{margin:"4px 0",paddingLeft:20},children:Q.work.branches.map(e=>(0,a.jsxs)("li",{children:[(0,a.jsx)("code",{children:e.branch})," — ",e.title,e.commit?"":" (".concat(Z("vcs.taskNoFiles"),")")]},e.branch))})]}),(0,a.jsx)("p",{className:"muted small",children:Z("vcs.pushIsYours")})]}),(0,a.jsx)("div",{className:"muted small",role:"status",children:X})]})}function D(e){var s;let{session:n,onChange:l}=e,{t:i}=(0,d.kj)(),[r,o]=(0,t.useState)(""),h=null!=(s=n.onFailure)?s:"stop",u=async e=>{if(e!==h)try{await c.FH.updateSession(n.id,{onFailure:e}),o(i("stop"===e?"chain.savedStop":"chain.savedContinue")),l()}catch(e){o(e.message)}};return(0,a.jsxs)("fieldset",{style:{border:0,padding:0,margin:"10px 0 14px"},children:[(0,a.jsx)("legend",{className:"muted small",style:{padding:0},children:i("chain.title")}),(0,a.jsxs)("div",{className:"option",children:[(0,a.jsxs)("label",{children:[(0,a.jsx)("input",{type:"radio",name:"chain",checked:"stop"===h,onChange:()=>void u("stop"),disabled:n.running}),(0,a.jsx)("span",{children:i("chain.stop")})]}),(0,a.jsx)("p",{className:"why",children:i("chain.stopWhy")})]}),(0,a.jsxs)("div",{className:"option",children:[(0,a.jsxs)("label",{children:[(0,a.jsx)("input",{type:"radio",name:"chain",checked:"continue"===h,onChange:()=>void u("continue"),disabled:n.running}),(0,a.jsx)("span",{children:i("chain.continue")})]}),(0,a.jsx)("p",{className:"why",children:i("chain.continueWhy")})]}),r&&(0,a.jsx)("div",{className:"muted small",role:"status",children:r}),n.running&&(0,a.jsx)("div",{className:"muted small",children:i("chain.locked")})]})}function A(e){let{value:s,onChange:n,presets:l,onPresetsChanged:i}=e,{t:r}=(0,d.kj)(),o=(0,t.useId)(),[h,u]=(0,t.useState)(""),m=async()=>{let e=prompt(r("l2.saveAsPrompt"));if(e)try{await c.FH.savePreset(e,s),u(r("l2.savedAs",{name:e})),null==i||i()}catch(e){u(e.message)}};return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"row",children:[(0,a.jsx)("label",{className:"grow",style:{margin:0},htmlFor:"".concat(o,"-text"),children:r("l2.label")}),(0,a.jsxs)("select",{value:"","aria-label":r("l2.loadPreset"),onChange:e=>{let s=l.find(s=>s.name===e.target.value);s&&n(s.content)},children:[(0,a.jsx)("option",{value:"",children:r("l2.loadPreset")}),l.map(e=>(0,a.jsx)("option",{value:e.name,children:e.name},e.name))]}),(0,a.jsx)("button",{onClick:()=>void m(),disabled:!s.trim(),children:r("l2.saveAs")})]}),(0,a.jsx)("textarea",{id:"".concat(o,"-text"),className:"prose",value:s,onChange:e=>n(e.target.value),placeholder:r("l2.placeholder"),style:{minHeight:140,marginTop:10}}),h&&(0,a.jsx)("div",{className:"muted small",children:h})]})}function L(e){let{session:s}=e,{t:n}=(0,d.kj)(),l=(0,d.W3)(),i=s.tasks.filter(e=>"queued"!==e.status),[r,o]=(0,t.useState)([]),h=r.length>0?r:i.map(e=>e.id),u=e=>(0,c.ub)("".concat(c.nC,"/sessions/").concat(s.id,"/export?variant=").concat(e)+(r.length>0?"&tasks=".concat(encodeURIComponent(r.join(","))):""));return(0,a.jsxs)("div",{className:"panel",children:[(0,a.jsx)("h2",{children:n("export.title")}),(0,a.jsx)("p",{className:"muted small",children:n("export.hint")}),0===i.length?(0,a.jsx)("div",{className:"empty",children:n("export.nothing")}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"row",style:{marginBottom:6},children:[(0,a.jsx)("button",{className:"quiet",onClick:()=>o(i.map(e=>e.id)),children:n("export.all")}),(0,a.jsx)("button",{className:"quiet",onClick:()=>o([]),children:n("export.none")}),(0,a.jsx)("span",{className:"muted small",children:r.length>0?n("export.selected",{n:r.length}):n("export.allOf",{n:i.length})})]}),i.map(e=>{var s,t,i,c,d;return(0,a.jsx)("div",{className:"option",style:{margin:"6px 0"},children:(0,a.jsxs)("label",{children:[(0,a.jsx)("input",{type:"checkbox",checked:r.includes(e.id),onChange:()=>{let s;return s=e.id,o(e=>e.includes(s)?e.filter(e=>e!==s):[...e,s])}}),(0,a.jsxs)("span",{children:[e.title," ",(0,a.jsx)("span",{className:"badge ".concat(e.status),children:n("status.".concat(e.status))})," ",e.readOnly&&(0,a.jsx)("span",{className:"chip",children:n("task.readOnly")})," ",(null!=(t=null==(s=e.scope)?void 0:s.length)?t:0)>0&&(0,a.jsx)("span",{className:"chip",children:n("task.scope",{paths:(null!=(i=e.scope)?i:[]).join(", ")})})," ",(0,a.jsx)("span",{className:"muted small",children:l(null!=(d=null!=(c=e.finishedAt)?c:e.startedAt)?d:e.createdAt)})]})]})},e.id)}),(0,a.jsxs)("div",{className:"row",style:{marginTop:10},children:[(0,a.jsx)("a",{className:"button-link",href:u("outcome"),download:!0,children:n("export.outcome",{n:h.length})}),(0,a.jsx)("a",{className:"button-link",href:u("full"),download:!0,children:n("export.full",{n:h.length})})]}),(0,a.jsx)("p",{className:"muted small",style:{marginTop:8},children:n("export.outcomeWhy")})]})]})}function E(e){let{handoff:s}=e,{t:n}=(0,d.kj)(),t=(e,s)=>(0,a.jsxs)("div",{className:"handoff-row",children:[(0,a.jsx)("strong",{children:n(e)})," ",s]}),l=e=>(0,a.jsx)("ul",{children:e.map((e,s)=>(0,a.jsx)("li",{children:e},s))}),i=s.validation.filter(e=>e.passed).length;return(0,a.jsxs)("div",{className:"summary handoff",children:[(0,a.jsx)("strong",{children:n("handoff.title")}),t("handoff.outcome",(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("span",{className:"badge ".concat(s.outcome.status),children:n("status.".concat(s.outcome.status))}),s.outcome.reason?" ".concat(s.outcome.reason):""]})),t("handoff.files",0===s.changedFiles.length?(0,a.jsx)("span",{className:"muted",children:n("handoff.noFiles")}):(0,a.jsx)("code",{children:s.changedFiles.map(e=>"".concat(e.path).concat(e.added>=0?" +".concat(e.added,"/-").concat(e.removed):"")).join(", ")})),s.validation.length>0&&t("handoff.validation",(0,a.jsxs)(a.Fragment,{children:[n("handoff.passed",{n:i,of:s.validation.length}),s.review?" \xb7 ".concat(n("handoff.review",{verdict:s.review.verdict,open:s.review.open})):""]})),t("handoff.issues",0===s.knownIssues.length?(0,a.jsx)("span",{className:"muted",children:n("handoff.noIssues")}):l(s.knownIssues)),s.evidence.runId&&t("handoff.evidence",(0,a.jsx)("code",{children:s.evidence.runId})),(s.vcs.branch||s.vcs.problem)&&t("handoff.vcs",(0,a.jsxs)(a.Fragment,{children:[s.vcs.branch&&(0,a.jsx)("code",{children:s.vcs.branch}),s.vcs.commit?" @ ".concat(s.vcs.commit.slice(0,8)," \xb7 ").concat(n("handoff.notPushed")):s.vcs.branch?" \xb7 ".concat(n("handoff.noCommit")):"",s.vcs.problem?" — ".concat(s.vcs.problem):""]})),s.manual.length>0&&t("handoff.manual",l(s.manual)),s.notExecuted.length>0&&t("handoff.notRun",l(s.notExecuted))]})}function q(e){var s;let{session:n,presets:l,onAdded:i,onPresetsChanged:r}=e,{t:o}=(0,d.kj)(),h=[...n.tasks].reverse()[0],[u,m]=(0,t.useState)(""),[p,v]=(0,t.useState)(null!=(s=null==h?void 0:h.level2)?s:""),[x,j]=(0,t.useState)(""),[g,f]=(0,t.useState)(""),[y,b]=(0,t.useState)(!1),k=(0,t.useRef)(!1),N=async()=>{if(!k.current){k.current=!0,b(!0);try{await c.FH.addTask(n.id,{title:u,level2:p,prompt:x}),m(""),j(""),f(o("form.queued")),i()}catch(e){f(e.message)}finally{k.current=!1,b(!1)}}};return(0,a.jsxs)("div",{className:"panel",id:"new-task",children:[(0,a.jsx)("h2",{children:o("form.title")}),(0,a.jsx)("p",{className:"muted small",children:o("form.hint")}),(0,a.jsx)("label",{htmlFor:"new-task-title",children:o("form.titleLabel")}),(0,a.jsx)("input",{id:"new-task-title",type:"text",value:u,onChange:e=>m(e.target.value),placeholder:o("form.titlePlaceholder")}),(0,a.jsx)("div",{style:{marginTop:10},children:(0,a.jsx)(A,{value:p,onChange:v,presets:l,onPresetsChanged:r})}),(0,a.jsx)("label",{htmlFor:"new-task-prompt",children:o("form.taskLabel")}),(0,a.jsx)("textarea",{id:"new-task-prompt",className:"prose",value:x,onChange:e=>j(e.target.value),placeholder:o("form.taskPlaceholder"),style:{minHeight:140}}),(0,a.jsxs)("div",{className:"row",style:{marginTop:10},children:[(0,a.jsx)("button",{className:"primary",onClick:()=>void N(),disabled:y||!x.trim(),children:o("form.add")}),(0,a.jsx)("span",{className:"muted small",children:g})]})]})}function U(e){var s,n,l,i,r,m,p,v,y,k,w,F,W,M,T,R,B,O,H,P,D,L,q,U,J,G,Y,Q,V,X,$,ee,es,en,ea,et,el,ei,er,ec,ed,eo,eh,eu,em,ep,ev,ex,ej,eg,ef,ey,eb,ek,eN,ew,eS,eC,eF,eI,eW,eM,eT,eR,eB,eO,eH,eP,eD,eA,eL,eE,eq,eU,eJ,ez,eG,eZ,eK,e_,eY,eQ,eV,eX,e$,e0,e1,e2;let{session:e8,task:e4,index:e6,presets:e3,onChange:e5}=e,{t:e7}=(0,d.kj)(),e9=(0,d.W3)(),[se,ss]=(0,t.useState)(!1),[sn,sa]=(0,t.useState)(!1),[st,sl]=(0,t.useState)(e4.title),[si,sr]=(0,t.useState)(e4.level2),[sc,sd]=(0,t.useState)(e4.prompt),[so,sh]=(0,t.useState)(null!=(ei=null==(s=e4.vcsPlan)?void 0:s.branch)?ei:""),[su,sm]=(0,t.useState)(null!=(er=null==(n=e4.vcsPlan)?void 0:n.commitMessage)?er:""),[sp,sv]=(0,t.useState)(null!=(ec=e4.checks)?ec:[]),[sx,sj]=(0,t.useState)(!!e4.readOnly),[sg,sf]=(0,t.useState)((null!=(ed=e4.scope)?ed:[]).join("\n")),sy={readOnly:sx,scope:sx?[]:(0,N.w)(sg)},sb=(0,u.c)((0,h.DG)(e4)),[sk,sN]=(0,t.useState)(null),[sw,sS]=(0,t.useState)(""),[sC,sF]=(0,t.useState)(null),[sI,sW]=(0,t.useState)(!1),[sM,sT]=(0,t.useState)(!1),sR=async()=>{try{await c.FH.updateTask(e8.id,e4.id,{title:st,level2:si,prompt:sc,vcsPlan:{branch:so,commitMessage:su},checks:sp,...sy}),ss(!1),e5()}catch(e){sS(e.message)}},sB="running"===e4.status||"waiting-approval"===e4.status,sO=!sB&&"queued"!==e4.status,sH=!sB&&"queued"!==e4.status,sP=!sB&&null!=(eo=null==(l=e8.vcs)?void 0:l.enabled)&&eo&&(!!(null==(i=e4.vcs)?void 0:i.baseCommit)||(null!=(eh=e4.attempts)?eh:[]).some(e=>{var s;return null==(s=e.vcs)?void 0:s.baseCommit})),sD=!sB&&(0,c.Zm)(e4),sA=!sB&&!sD&&(0,c.Dh)(e4)&&!e8.running,sL=async()=>{if(await (0,g.Z)(e7("task.continueConfirm",{title:e4.title})))try{await c.FH.continueTask(e8.id,e4.id),e5(),sF({intro:e7("runq.savedOffer")})}catch(e){sS(e.message)}},sE=async()=>{if(await (0,g.Z)(e7("task.rerunConfirm",{title:e4.title})))try{await c.FH.rerunTask(e8.id,e4.id),e5(),sF({intro:e7("runq.savedOffer")})}catch(e){sS(e.message)}},sq=async()=>{if(await (0,g.Z)(e7("task.editRanConfirm",{title:e4.title})))try{await c.FH.rerunTask(e8.id,e4.id,{title:st,level2:si,prompt:sc,vcsPlan:{branch:so,commitMessage:su},checks:sp,...sy},{buildOnFinished:"done"===e4.status}),ss(!1),e5(),sF({intro:e7("runq.savedOffer")})}catch(e){sS(e.message)}},sU=(0,b.e)(e5),sJ=async()=>{let e="queued"===e4.status?"task.deleteConfirm":"task.deleteConfirmRan";if(await (0,g.Z)(e7(e,{title:e4.title})))try{await c.FH.deleteTask(e8.id,e4.id),e5()}catch(e){sS(e.message)}},sz=null!=(em=e4.plan)?em:e4.continuing?null==(r=[...null!=(eu=e4.attempts)?eu:[]].reverse().find(e=>{var s;return null==(s=e.plan)?void 0:s.approved}))?void 0:r.plan:void 0,sG=async()=>{try{sN(await c.FH.taskFiles(e8.id,e4.id))}catch(e){sS(e.message)}},sZ=(e,s,n)=>n.length>0&&(0,a.jsxs)("div",{children:[(0,a.jsxs)("span",{className:"muted",children:[e7(e)," "]}),n.map(e=>(0,a.jsx)("span",{style:{marginRight:10},children:(0,a.jsx)(o.u,{label:e,save:()=>c.FH.saveTaskFile(e8.id,e4.id,s,e)})},e))]});return(0,a.jsxs)("div",{className:"task ".concat(e4.status),id:e4.id,children:[(0,a.jsxs)("div",{className:"row",children:[(0,a.jsxs)("h4",{className:"grow",children:[e6,". ",e4.title]}),(0,a.jsx)("span",{className:"badge ".concat(e4.status),children:e7("status.".concat(e4.status))}),e4.limit&&(0,a.jsx)("span",{className:"chip",title:e7("reg.limitChipWhy"),children:e7("reg.limitChip",{limit:e7("limit.".concat(e4.limit.setting),{n:e4.limit.value})})}),(null!=(ep=e4.attempt)?ep:1)>1&&(0,a.jsx)("span",{className:"chip",children:e7("task.attemptN",{n:null!=(ev=e4.attempt)?ev:1})}),e4.iterations>0&&(0,a.jsx)("span",{className:"muted small",children:e7("task.iterations",{n:e4.iterations})}),e4.runId&&(0,a.jsxs)("button",{className:sn?"":"quiet","aria-expanded":sn,onClick:()=>sa(e=>!e),title:(0,h.DG)(e4)?e7("story.showLiveWhy"):e7("story.why"),children:[(0,h.DG)(e4)&&!sn&&(0,a.jsx)("span",{className:"dot","aria-hidden":"true"}),sn?e7("story.hide"):(0,h.DG)(e4)?e7("story.showLive"):e7("story.show")]}),"queued"===e4.status&&!e8.running&&!1!==e8.active&&(0,a.jsx)("button",{className:sC?"":"primary","aria-expanded":!!sC,onClick:()=>{sW(!1),sF(sC?null:{})},title:e7("runq.buttonWhy"),children:e7("runq.button")}),(sI||"contract-conflict"===e4.stopCode&&!sB&&"queued"!==e4.status&&!e8.running)&&(0,a.jsx)("button",{className:sI?"":"primary","aria-expanded":sI,onClick:()=>sW(!sI),title:e7("cfix.buttonWhy"),children:e7("cfix.button")}),!sB&&(0,a.jsx)("button",{onClick:()=>{if(!se){var e,s,n,a,t,l;sl(e4.title),sr(e4.level2),sd(e4.prompt),sh(null!=(n=null==(e=e4.vcsPlan)?void 0:e.branch)?n:""),sm(null!=(a=null==(s=e4.vcsPlan)?void 0:s.commitMessage)?a:""),sv(null!=(t=e4.checks)?t:[]),sj(!!e4.readOnly),sf((null!=(l=e4.scope)?l:[]).join("\n"))}ss(!se)},title:e7("task.editAll"),children:se?e7("task.cancel"):e7("task.edit")}),sD&&(0,a.jsx)("button",{className:"primary",onClick:()=>void sL(),title:e7("task.continueWhy"),children:e7("task.continue")}),sA&&(0,a.jsx)("button",{className:"primary","aria-haspopup":"dialog",onClick:()=>sT(!0),title:e7("fup.buttonWhy"),children:e7("fup.button")}),sH&&(0,a.jsx)("button",{className:sD||sA?"":"primary",onClick:()=>void sE(),title:e7("task.rerunWhy"),children:e7("task.rerun")}),sP&&(0,a.jsx)("button",{onClick:()=>void sU.restore({sessionId:e8.id,taskId:e4.id,title:e4.title}),disabled:""!==sU.busy||e8.running,title:e7("restore.why"),children:"restore"===sU.busy?e7("restore.checking"):e7("restore.button")}),sO&&(0,a.jsx)("button",{onClick:()=>void sU.restartFrom({sessionId:e8.id,taskId:e4.id,title:e4.title}),disabled:""!==sU.busy||e8.running,title:e7("restart.why"),children:"restart"===sU.busy?e7("restart.checking"):e7("restart.button")}),!sB&&(0,a.jsx)("button",{className:"danger",onClick:()=>void sJ(),children:e7("task.delete")}),!se&&(sw||sU.message)&&(0,a.jsx)("span",{className:"err",role:"alert",children:sw||sU.message})]}),(0,a.jsxs)("div",{className:"muted small",children:[e4.startedAt?e7("task.started",{t:e9(e4.startedAt)}):e7("task.added",{t:e9(e4.createdAt)}),e4.finishedAt?" \xb7 ".concat(e7("task.finished",{t:e9(e4.finishedAt)})):"",e4.startedAt&&e4.finishedAt?" \xb7 ".concat(e7("task.took",{d:(0,c.c5)((0,h.d5)(e4.startedAt,e4.finishedAt))})):"",(0,h.DG)(e4)?" \xb7 ".concat(e7("task.runningFor",{d:(0,c.c5)((0,h.d5)(e4.startedAt,void 0,sb))})):""]}),"queued"!==e4.status&&(null==(m=e8.vcs)?void 0:m.enabled)&&e4.vcs&&(0,a.jsx)("div",{className:"muted small",children:e4.vcs.problem&&!e4.vcs.branch?(0,a.jsx)("span",{className:"reason",children:e7("vcs.taskProblem",{problem:e4.vcs.problem})}):(0,a.jsxs)(a.Fragment,{children:[e4.vcs.branch&&e7("vcs.taskBranch",{branch:e4.vcs.branch}),e4.vcs.baseCommit&&" \xb7 ".concat(e7("vcs.taskBase",{commit:e4.vcs.baseCommit.slice(0,8)})),e4.vcs.commit?" \xb7 ".concat(e7("vcs.taskCommit",{commit:e4.vcs.commit.slice(0,8)})):" \xb7 ".concat(e7("vcs.taskNoFiles")),(null!=(ex=null==(p=e4.vcs.files)?void 0:p.length)?ex:0)>0&&(0,a.jsxs)("details",{style:{display:"inline"},children:[(0,a.jsxs)("summary",{style:{display:"inline",cursor:"pointer"},children:[" \xb7 ",e7("vcs.taskFiles",{n:null!=(ej=null==(v=e4.vcs.files)?void 0:v.length)?ej:0})]}),(0,a.jsx)("ul",{style:{margin:"4px 0 4px 0",paddingLeft:20},children:(null!=(eg=e4.vcs.files)?eg:[]).map(e=>(0,a.jsxs)("li",{children:[(0,a.jsx)("code",{children:e.path})," ",e.added<0||e.removed<0?e7("vcs.taskBinary"):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("span",{style:{color:"var(--ok)"},children:["+",e.added]})," ",(0,a.jsxs)("span",{style:{color:"var(--bad)"},children:["-",e.removed]})]})]},e.path))})]}),e4.vcs.commit&&e4.vcs.baseCommit&&(0,a.jsxs)(a.Fragment,{children:[" \xb7 ",(0,a.jsx)(f.C,{sessionId:e8.id,taskId:e4.id,title:e4.title,files:null!=(ef=null==(y=e4.vcs.files)?void 0:y.length)?ef:0})]}),(null!=(ey=null==(k=e4.vcs.suspicious)?void 0:k.length)?ey:0)>0&&(0,a.jsxs)("div",{className:"err small",style:{marginTop:4},children:[e7("vcs.suspicious",{n:null!=(eb=null==(w=e4.vcs.suspicious)?void 0:w.length)?eb:0}),(0,a.jsx)("ul",{style:{margin:"4px 0",paddingLeft:20},children:(null!=(ek=e4.vcs.suspicious)?ek:[]).map(e=>(0,a.jsxs)("li",{children:[(0,a.jsx)("code",{children:e.path})," — ",e.reason]},e.path))})]}),(null!=(eN=null==(F=e4.scopeReverted)?void 0:F.length)?eN:0)>0&&(0,a.jsx)("div",{className:"small",style:{marginTop:4},children:e7(e4.readOnly?"task.readOnlyReverted":"task.scopeReverted",{n:null!=(ew=null==(W=e4.scopeReverted)?void 0:W.length)?ew:0,paths:(null!=(eS=e4.scopeReverted)?eS:[]).join(", ")})}),(null!=(eC=null==(M=e4.inputsRestored)?void 0:M.length)?eC:0)>0&&(0,a.jsx)("div",{className:"small",style:{marginTop:4},children:e7("task.inputsRestored",{n:null!=(eF=null==(T=e4.inputsRestored)?void 0:T.length)?eF:0,paths:(null!=(eI=e4.inputsRestored)?eI:[]).join(", ")})}),(null!=(eW=null==(R=e4.artifactsKept)?void 0:R.length)?eW:0)>0&&(0,a.jsx)("div",{className:"muted small",style:{marginTop:4,overflowWrap:"anywhere"},children:e7("task.artifactsKept",{n:null!=(eM=null==(B=e4.artifactsKept)?void 0:B.length)?eM:0,paths:(null!=(eT=e4.artifactsKept)?eT:[]).slice(0,10).map(e=>e.path).join(", ")})}),(null!=(eR=null==(O=e4.vcs.foreignCommits)?void 0:O.length)?eR:0)>0&&(0,a.jsxs)("div",{className:"err small",style:{marginTop:4},children:[e7("vcs.foreignCommits",{n:null!=(eB=null==(H=e4.vcs.foreignCommits)?void 0:H.length)?eB:0}),(0,a.jsx)("ul",{style:{margin:"4px 0",paddingLeft:20},children:(null!=(eO=e4.vcs.foreignCommits)?eO:[]).map(e=>(0,a.jsx)("li",{children:(0,a.jsx)("code",{children:e})},e))})]})]})}),"queued"===e4.status&&(null==(P=e8.vcs)?void 0:P.enabled)&&((null==(D=e4.vcsPlan)?void 0:D.branch)||(null==(L=e4.vcsPlan)?void 0:L.commitMessage))&&(0,a.jsx)("div",{className:"muted small",children:e4.vcsPlan.branch&&e4.vcsPlan.commitMessage?e7("task.gitNames",{branch:e4.vcsPlan.branch,subject:e4.vcsPlan.commitMessage.split("\n")[0]}):e4.vcsPlan.branch?e7("task.gitBranchOnly",{branch:e4.vcsPlan.branch}):e7("task.gitCommitOnly",{subject:(null!=(eH=e4.vcsPlan.commitMessage)?eH:"").split("\n")[0]})}),sM&&(0,a.jsx)(C.J,{sessionId:e8.id,taskId:e4.id,title:e4.title,onClose:e=>{sT(!1),e&&e5()}}),sI&&(0,a.jsx)(S.y,{target:{sessionId:e8.id,taskId:e4.id,title:e4.title},onApplied:(e,s)=>{e5(),0===e&&(sW(!1),sF({intro:"".concat(s," ").concat(e7("runq.savedOffer"))}))}}),sC&&"queued"===e4.status&&(0,a.jsx)(S.f,{target:{sessionId:e8.id,taskId:e4.id,title:e4.title},intro:sC.intro,checkContract:!sI,onClose:e=>{sF(null),e&&e5()}}),sn&&e4.runId&&(0,a.jsx)(x.P,{sessionId:e8.id,taskId:e4.id,live:"running"===e4.status||"waiting-approval"===e4.status}),se?(0,a.jsxs)("div",{style:{marginTop:8},children:[(0,a.jsx)("label",{children:e7("form.titleLabel")}),(0,a.jsx)("input",{type:"text",value:st,onChange:e=>sl(e.target.value)}),(0,a.jsx)("div",{style:{marginTop:8},children:(0,a.jsx)(A,{value:si,onChange:sr,presets:e3})}),(0,a.jsx)("label",{children:e7("form.taskLabel")}),(0,a.jsx)("textarea",{className:"prose",value:sc,onChange:e=>sd(e.target.value)}),(null==(q=e8.vcs)?void 0:q.enabled)&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("label",{htmlFor:"branch-".concat(e4.id),children:e7("task.branch")}),(0,a.jsx)("input",{id:"branch-".concat(e4.id),type:"text",value:so,onChange:e=>sh(e.target.value),placeholder:e8.vcs.branchPrefix,disabled:"per-session"===e8.vcs.branchMode}),(0,a.jsx)("p",{className:"why",children:"per-session"===e8.vcs.branchMode?e7("task.branchIgnored"):e7("task.branchWhy")}),(0,a.jsx)("label",{htmlFor:"commit-".concat(e4.id),children:e7("task.commitMessage")}),(0,a.jsx)("textarea",{id:"commit-".concat(e4.id),value:su,onChange:e=>sm(e.target.value),style:{minHeight:70}}),(0,a.jsx)("p",{className:"why",children:e7("task.commitWhy")})]}),(0,a.jsx)(z,{checks:sp,onChange:sv}),sc.trim()!==e4.prompt.trim()&&(0,a.jsx)("p",{className:"notice caution small",children:e7("task.newIntentNote")}),(0,a.jsx)(N.y,{readOnly:sx,scope:sg,onReadOnly:sj,onScope:sf}),(0,a.jsxs)("div",{className:"row",style:{marginTop:8},children:[(0,a.jsx)("button",{className:"primary",onClick:()=>void(sO?sq():sR()),children:sO?e7("task.saveAndRerun"):e7("task.save")}),(0,a.jsx)("span",{className:"err",children:sw})]}),sO&&(0,a.jsx)("p",{className:"muted small",children:e7("task.editRanWhy")})]}):(0,a.jsxs)(a.Fragment,{children:[(null!=(eP=null==(U=e4.checks)?void 0:U.length)?eP:0)>0&&(0,a.jsxs)("details",{className:"small",style:{margin:"6px 0"},children:[(0,a.jsxs)("summary",{children:[e7("checks.title")," — ",e7("checks.n",{n:null!=(eD=null==(J=e4.checks)?void 0:J.length)?eD:0}),(null!=(eA=null==(G=e4.checkResults)?void 0:G.length)?eA:0)>0&&" \xb7 ".concat((null!=(eL=e4.checkResults)?eL:[]).filter(e=>e.passed).length,"/").concat(null==(Y=e4.checkResults)?void 0:Y.length," ").concat(e7("checks.passed"))]}),(0,a.jsx)("ul",{style:{margin:"6px 0",paddingLeft:20},children:(null!=(eE=e4.checks)?eE:[]).map((e,s)=>{var n;let t=(null!=(n=e4.checkResults)?n:[]).find(s=>s.name===e.name);return(0,a.jsxs)("li",{children:[(0,a.jsx)("strong",{children:e.name}),(0,a.jsxs)("span",{className:"muted",children:[" — ",e7("checks.kind.".concat(e.expect)),e.value?' "'.concat(e.value,'"'):"",e.run?": ".concat(e.run):e.file?": ".concat(e.file):""]}),t&&(0,a.jsxs)("div",{className:t.passed?"muted":"reason",children:[t.passed?e7("checks.passed"):e7("checks.failed")," — ",t.detail]})]},"".concat(e.name,"-").concat(s))})})]}),(null!=(eq=null==(Q=e4.reviewChecks)?void 0:Q.length)?eq:0)>0&&(0,a.jsxs)("details",{className:"small",style:{margin:"6px 0"},children:[(0,a.jsx)("summary",{children:e7("checks.fromReview",{n:null!=(eU=null==(V=e4.reviewChecks)?void 0:V.length)?eU:0})}),(0,a.jsx)("p",{className:"why",children:e7("checks.fromReviewWhy")}),(0,a.jsx)("ul",{style:{margin:"6px 0",paddingLeft:20},children:(null!=(eJ=e4.reviewChecks)?eJ:[]).map(e=>{var s;let n=(null!=(s=e4.checkResults)?s:[]).find(s=>s.name===e.check.name);return(0,a.jsxs)("li",{children:[(0,a.jsx)("code",{children:e.findingId})," ",(0,a.jsx)("strong",{children:e.check.name}),"active"!==e.state&&(0,a.jsx)("span",{className:"chip",style:{marginLeft:6},children:e7("checks.state.".concat(e.state))}),(0,a.jsx)("div",{className:"muted",children:e.what}),n&&(0,a.jsxs)("div",{className:n.passed?"muted":"reason",children:[n.passed?e7("checks.passed"):e7("checks.failed")," — ",n.detail]})]},"".concat(e.attempt,":").concat(e.findingId,":").concat(e.check.name))})})]}),(0,a.jsx)(_,{review:e4.review}),e4.stopCode&&!(0,h.DG)(e4)&&(0,a.jsx)("p",{className:"small",children:(0,a.jsx)("span",{className:"chip",title:e7("stop.why"),children:e7("stop.".concat(e4.stopCode))})}),e4.handoff&&!(0,h.DG)(e4)&&(0,a.jsx)(E,{handoff:e4.handoff}),e4.summary&&(0,a.jsxs)("div",{className:"summary",children:[(0,a.jsx)("strong",{children:e7("task.whatWasDone")}),(0,a.jsx)(j.s,{text:e4.summary})]}),(null!=(ez=null==(X=e4.deviations)?void 0:X.length)?ez:0)>0&&(0,a.jsx)(Z,{items:null!=(eG=e4.deviations)?eG:[]}),(null!=(eZ=null==($=e4.disputes)?void 0:$.length)?eZ:0)>0&&(0,a.jsx)(K,{items:null!=(eK=e4.disputes)?eK:[]}),e4.environment&&(0,a.jsx)("div",{className:"muted small",style:{margin:"4px 0"},children:e7("task.ranWith",{node:e4.environment.node,npm:null!=(e_=e4.environment.npm)?e_:"—",git:null!=(eY=e4.environment.git)?eY:"—",pwsh:null!=(eV=null!=(eQ=e4.environment.pwsh)?eQ:e4.environment.powershell)?eV:"—"})}),(null!=(eX=null==(ee=e4.leftovers)?void 0:ee.length)?eX:0)>0&&(0,a.jsxs)("div",{className:"err small",style:{margin:"6px 0"},children:[e7("task.leftovers",{n:null!=(e$=null==(es=e4.leftovers)?void 0:es.length)?e$:0}),(0,a.jsx)("ul",{style:{margin:"4px 0",paddingLeft:20},children:(null!=(e0=e4.leftovers)?e0:[]).map(e=>(0,a.jsxs)("li",{children:[(0,a.jsx)("code",{children:e.name})," pid ",e.pid,e.ports.length>0?" \xb7 ".concat(e7("task.leftoverPorts",{ports:e.ports.join(", ")})):""," \xb7 ",e.by]},"".concat(e.by,"-").concat(e.pid)))})]}),e4.reason&&(0,a.jsx)("div",{className:"reason small",style:{margin:"6px 0"},children:e4.reason}),(null!=(e1=null==(en=e4.attempts)?void 0:en.length)?e1:0)>0&&(0,a.jsxs)("details",{children:[(0,a.jsx)("summary",{children:e7("task.attempts",{n:null!=(e2=null==(ea=e4.attempts)?void 0:ea.length)?e2:0})}),null==(et=e4.attempts)?void 0:et.map((e,s)=>{var n,t,l,i;return(0,a.jsxs)("div",{className:"small",style:{margin:"8px 0 12px"},children:[(0,a.jsxs)("div",{className:"row",children:[(0,a.jsx)("strong",{children:e7("task.attemptN",{n:s+1})}),(0,a.jsx)("span",{className:"badge ".concat(e.status),children:e7("status.".concat(e.status))}),e.iterations>0&&(0,a.jsx)("span",{className:"muted",children:e7("task.iterations",{n:e.iterations})}),e.runId&&(0,a.jsx)(o.u,{label:e7("save.attemptLog"),save:()=>c.FH.saveTaskLog(e8.id,e4.id,e.runId)}),e.runId&&(0,a.jsx)(o.H,{sessionId:e8.id,taskId:e4.id,attempt:s+1}),e.runId&&(null==(n=e.vcs)?void 0:n.commit)&&e.vcs.baseCommit&&(0,a.jsx)(f.C,{sessionId:e8.id,taskId:e4.id,runId:e.runId,title:"".concat(e4.title," — ").concat(e7("task.attemptN",{n:s+1})),files:null!=(l=null==(t=e.vcs.files)?void 0:t.length)?l:0})]}),(0,a.jsxs)("div",{className:"muted",children:[e.startedAt?e7("task.started",{t:e9(e.startedAt)}):"",e.finishedAt?" \xb7 ".concat(e7("task.finished",{t:e9(e.finishedAt)})):""]}),e.summary&&(0,a.jsx)("div",{children:e.summary}),e.reason&&(0,a.jsx)("div",{className:"err",children:e.reason}),e.prompt&&e.prompt!==e4.prompt&&(0,a.jsxs)("details",{children:[(0,a.jsx)("summary",{children:e7("task.attemptText")}),(0,a.jsx)("pre",{children:e.prompt})]})]},"".concat(null!=(i=e.runId)?i:s))})]}),"queued"===e4.status?(0,a.jsxs)("div",{style:{marginTop:8},children:[(0,a.jsx)("div",{className:"muted small",children:e7("task.prompt")}),(0,a.jsx)("pre",{children:e4.prompt}),e4.level2.trim()?(0,a.jsxs)("details",{children:[(0,a.jsx)("summary",{children:e7("task.l2Show",{n:e4.level2.trim().split("\n").length})}),(0,a.jsx)("pre",{children:e4.level2})]}):(0,a.jsx)("div",{className:"muted small",children:e7("task.noL2")})]}):(0,a.jsxs)("details",{children:[(0,a.jsx)("summary",{children:e7("task.promptAndL2")}),e4.level2.trim()&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("div",{className:"muted small",children:e7("task.l2")}),(0,a.jsx)("pre",{children:e4.level2})]}),(0,a.jsx)("div",{className:"muted small",children:e7("task.prompt")}),(0,a.jsx)("pre",{children:e4.prompt})]}),(null==(el=e4.continuing)?void 0:el.instruction)&&(0,a.jsxs)("div",{className:"notice calm small",style:{marginTop:6},children:[(0,a.jsx)("strong",{children:e7("task.continuedWith",{n:e4.continuing.fromAttempt})}),(0,a.jsx)("pre",{style:{margin:"4px 0 0",whiteSpace:"pre-wrap"},children:e4.continuing.instruction})]}),sz&&(0,a.jsxs)("details",{open:!sz.approved,children:[(0,a.jsx)("summary",{children:sz.approved?e7("pm.taskApproved",{n:sz.version}):e7("pm.taskWaiting",{n:sz.version})}),(0,a.jsx)(I.D,{plan:sz})]}),e4.firstMessage&&(0,a.jsxs)("details",{children:[(0,a.jsx)("summary",{children:e7("task.firstMessage")}),(0,a.jsx)("pre",{className:"tall",children:e4.firstMessage})]}),e4.runId&&(0,a.jsxs)("details",{onToggle:e=>e.currentTarget.open&&void sG(),children:[(0,a.jsx)("summary",{children:e7("task.files")}),(0,a.jsx)("div",{className:"row small",style:{margin:"6px 0"},children:(0,a.jsx)(o.u,{label:e7("save.log"),save:()=>c.FH.saveTaskLog(e8.id,e4.id)})}),sk&&(0,a.jsxs)("div",{className:"small",children:[sZ("task.reports","reports",sk.reports),sZ("task.artifacts","artifacts",sk.artifacts),sZ("task.replies","replies",sk.replies)]})]}),e4.finalReply&&(0,a.jsxs)("details",{children:[(0,a.jsx)("summary",{children:e7("task.finalReply")}),(0,a.jsx)("pre",{className:"tall",children:e4.finalReply})]})]})]})}function J(e){let{events:s}=e,{t:n}=(0,d.kj)(),{appearance:l}=(0,m.KP)(),i=(0,t.useRef)(null);return(0,t.useEffect)(()=>{!l.reduceMotion&&i.current&&(i.current.scrollTop=i.current.scrollHeight)},[s.length,l.reduceMotion]),(0,a.jsxs)("div",{className:"panel",children:[(0,a.jsx)("h2",{children:n("live.title")}),(0,a.jsxs)("div",{className:"log",ref:i,children:[0===s.length&&(0,a.jsx)("div",{className:"muted",children:n("live.none")}),s.map((e,s)=>{var n;return(0,a.jsxs)("div",{className:e.level,children:[(0,a.jsx)("span",{className:"time",children:new Date(e.at).toLocaleTimeString(void 0,{hour12:!1})}),null!=(n=e.message)?n:e.type]},s)})]})]})}function z(e){let{checks:s,onChange:n}=e,{t}=(0,d.kj)(),l=(e,a)=>n(s.map((s,n)=>e===n?{...s,...a}:s));return(0,a.jsxs)("div",{style:{marginTop:12},children:[(0,a.jsx)("label",{children:t("checks.title")}),(0,a.jsx)("p",{className:"why",style:{marginTop:0},children:t("checks.why")}),0===s.length&&(0,a.jsx)("p",{className:"muted small",children:t("checks.noneWhy")}),s.map((e,i)=>{var r,d,o,h;return(0,a.jsxs)("div",{className:"option",children:[(0,a.jsxs)("div",{className:"row",children:[(0,a.jsx)("input",{type:"text",className:"grow",value:e.name,placeholder:t("checks.namePlaceholder"),onChange:e=>l(i,{name:e.target.value}),"aria-label":t("checks.name")}),(0,a.jsx)("select",{value:e.expect,onChange:e=>l(i,{expect:e.target.value}),"aria-label":t("checks.kind"),style:{width:"auto"},children:c.FZ.map(e=>(0,a.jsx)("option",{value:e,children:t("checks.kind.".concat(e))},e))}),(0,a.jsx)("button",{className:"quiet",onClick:()=>n(s.filter((e,s)=>s!==i)),children:t("checks.remove")})]}),(0,a.jsxs)("div",{className:"row",style:{marginTop:6},children:[(0,c.rt)(e.expect)?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("input",{type:"text",className:"grow",value:null!=(r=e.run)?r:"",placeholder:t("checks.run"),onChange:e=>l(i,{run:e.target.value}),"aria-label":t("checks.run")}),(0,a.jsx)("input",{type:"text",value:null!=(d=e.cwd)?d:"",placeholder:t("checks.cwd"),onChange:e=>l(i,{cwd:e.target.value}),"aria-label":t("checks.cwd"),style:{width:220}})]}):(0,a.jsx)("input",{type:"text",className:"grow",value:null!=(o=e.file)?o:"",placeholder:t("checks.file"),onChange:e=>l(i,{file:e.target.value}),"aria-label":t("checks.file")}),(0,c.dK)(e.expect)&&(0,a.jsx)("input",{type:"text",value:null!=(h=e.value)?h:"",placeholder:"output-matches"===e.expect?t("checks.valueRegex"):t("checks.value"),onChange:e=>l(i,{value:e.target.value}),"aria-label":t("checks.value"),style:{width:240}})]})]},i)}),(0,a.jsx)("button",{onClick:()=>n([...s,{name:"",expect:"exit-zero",run:""}]),children:t("checks.add")})]})}function G(e){let{tasks:s}=e,{t:n}=(0,d.kj)(),t=(0,h.hH)(s),l=(0,u.c)(!!t&&t.tasks.some(h.DG));if(!t)return null;let i=(0,h.eZ)(t.run,t.tasks,l);return(0,a.jsx)("p",{className:"muted small",style:{margin:"4px 0 10px"},children:n(i.live?"session.runClockLive":"session.runClock",{n:i.tasks,d:(0,c.c5)(i.ms)})})}function Z(e){let{items:s}=e,{t:n}=(0,d.kj)();return(0,a.jsxs)("div",{className:"summary",children:[(0,a.jsx)("strong",{children:n("task.deviations",{n:s.length})}),(0,a.jsx)("ol",{style:{margin:"6px 0",paddingLeft:20},children:s.map((e,s)=>(0,a.jsxs)("li",{style:{marginBottom:6},children:[(0,a.jsx)("div",{children:e.instruction}),(0,a.jsxs)("div",{className:"muted",children:[n("task.deviationDid"),": ",e.did]}),(0,a.jsxs)("div",{className:"muted",children:[n("task.deviationWhy"),": ",e.why]})]},s))})]})}function K(e){let{items:s}=e,{t:n}=(0,d.kj)();return(0,a.jsxs)("div",{className:"summary",children:[(0,a.jsx)("strong",{children:n("task.disputes",{n:s.length})}),(0,a.jsx)("ol",{style:{margin:"6px 0",paddingLeft:20},children:s.map((e,s)=>(0,a.jsxs)("li",{style:{marginBottom:6},children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("code",{children:e.finding})," — ",e.why]}),(0,a.jsxs)("div",{className:"muted",children:[n("review.evidence"),": ",e.evidence]})]},s))})]})}function _(e){var s,n,t,l,i;let{review:r}=e,{t:c}=(0,d.kj)();if(!r)return null;if("skipped"===r.verdict)return r.skippedBecause?(0,a.jsx)("p",{className:"muted small",children:c("review.skippedWhy",{why:r.skippedBecause})}):null;let o="pass"===r.verdict?"done":"fail"===r.verdict?"blocked":"waiting-approval";return(0,a.jsxs)("div",{className:"small",style:{margin:"8px 0"},children:[(0,a.jsxs)("div",{className:"row",children:[(0,a.jsx)("span",{className:"badge ".concat(o),children:c("review.verdict.".concat(r.verdict))}),r.stepsRun>0&&(0,a.jsx)("span",{className:"muted",children:c("review.ran",{n:r.stepsRun})}),r.rounds>1&&(0,a.jsx)("span",{className:"muted",children:c("review.rounds",{n:r.rounds})}),r.model&&(0,a.jsx)("span",{className:"chip",children:c("review.onModel",{model:r.model})})]}),r.problem&&(0,a.jsx)("p",{className:"reason",children:c("review.problem",{problem:r.problem})}),r.summary&&(0,a.jsx)(j.s,{text:r.summary}),(null!=(t=null==(s=r.findings)?void 0:s.length)?t:0)>0&&(0,a.jsxs)("details",{style:{marginTop:4},children:[(0,a.jsx)("summary",{children:c("review.findings",{n:null!=(l=null==(n=r.findings)?void 0:n.length)?l:0})}),(0,a.jsx)("ol",{style:{margin:"6px 0",paddingLeft:20},children:(null!=(i=r.findings)?i:[]).map((e,s)=>(0,a.jsxs)("li",{style:{marginBottom:8},children:[(0,a.jsxs)("div",{children:[e.id&&(0,a.jsx)("code",{style:{marginRight:6},children:e.id}),e.what,"task"===e.about&&(0,a.jsx)("span",{className:"chip",style:{marginLeft:6},children:c("review.aboutTask")}),e.repeated&&(0,a.jsx)("span",{className:"chip",style:{marginLeft:6},children:c("review.repeated")})]}),e.where&&(0,a.jsx)("div",{className:"muted",children:e.where}),(0,a.jsxs)("div",{className:"muted",children:[c("review.evidence"),": ",e.evidence]})]},s))})]})]})}},4784:(e,s,n)=>{"use strict";n.d(s,{Y:()=>r});var a=n(3365),t=n(1521),l=n(5549),i=n(867);function r(e){var s,n,r;let{id:c,chosen:d,onChange:o,none:h,catalogue:u,disabled:m=!1,style:p}=e,{t:v}=(0,i.kj)(),x=function(e){let[s,n]=(0,t.useState)(null);return(0,t.useEffect)(()=>{if(void 0!==e)return;let s=!0;return l.FH.models().then(e=>{s&&n(e)}).catch(()=>void 0),()=>{s=!1}},[e]),void 0!==e?e:s}(u),j=null!=(s=null==x?void 0:x.options)?s:[],g=e=>e.toLowerCase().replace(/[-‐‑‒–—_]+/g," ").replace(/\s+/g," ").trim(),f=d?j.find(e=>g(e.name)===g(d)):void 0,y=null!=(n=null==f?void 0:f.name)?n:d,b=!!f,k=j.filter(e=>!e.group),N=new Map;for(let e of j)e.group&&N.set(e.group,[...null!=(r=N.get(e.group))?r:[],e]);return(0,a.jsxs)("select",{id:c,value:y,onChange:e=>o(e.target.value),disabled:m,style:{width:"auto",minWidth:280,...p},children:[(0,a.jsx)("option",{value:"",children:h}),d&&!b&&(0,a.jsx)("option",{value:d,children:v("model.notInList",{name:d})}),k.map(e=>(0,a.jsxs)("option",{value:e.name,disabled:e.disabled,children:[e.name,e.disabled?" — ".concat(v("model.unavailable")):""]},e.name)),[...N.entries()].map(e=>{let[s,n]=e;return(0,a.jsx)("optgroup",{label:s,children:n.map(e=>(0,a.jsxs)("option",{value:e.name,disabled:e.disabled,children:[e.name,e.disabled?" — ".concat(v("model.unavailable")):""]},e.name))},s)})]})}},8078:(e,s,n)=>{"use strict";n.d(s,{AppearanceProvider:()=>o,KP:()=>h});var a=n(3365),t=n(1521);let l="cop.appearance",i=["small","normal","large","huge","giant"];"\n(function () {\n try {\n var d = document.documentElement;\n var raw = localStorage.getItem('".concat(l,"');\n var a = raw ? JSON.parse(raw) : {};\n if (!a || typeof a !== 'object') a = {};\n d.dataset.theme = a.theme === 'dark' ? 'dark' : 'light';\n d.dataset.textsize = ").concat(JSON.stringify(i),".indexOf(a.textSize) >= 0 ? a.textSize : 'normal';\n d.dataset.contrast = a.highContrast ? 'high' : 'normal';\n d.dataset.motion = a.reduceMotion ? 'reduced' : 'normal';\n d.dataset.links = a.underlineLinks ? 'underline' : 'plain';\n d.dataset.focus = a.strongFocus ? 'strong' : 'normal';\n } catch (e) {}\n})();\n");let r={theme:"light",textSize:"normal",highContrast:!1,reduceMotion:!1,underlineLinks:!1,strongFocus:!1};function c(e){let s=document.documentElement;s.dataset.theme=e.theme,s.dataset.textsize=e.textSize,s.dataset.contrast=e.highContrast?"high":"normal",s.dataset.motion=e.reduceMotion?"reduced":"normal",s.dataset.links=e.underlineLinks?"underline":"plain",s.dataset.focus=e.strongFocus?"strong":"normal"}let d=(0,t.createContext)({appearance:r,set:()=>void 0,reset:()=>void 0,loaded:!1});function o(e){let{children:s}=e,[n,o]=(0,t.useState)(r),[h,u]=(0,t.useState)(!1);(0,t.useEffect)(()=>{let e=r;try{let s=window.localStorage.getItem(l);s?e=function(e){let s=e&&"object"==typeof e?e:{},n=(e,s)=>"boolean"==typeof e?e:s;return{theme:"dark"===s.theme?"dark":"light"===s.theme?"light":r.theme,textSize:i.includes(s.textSize)?s.textSize:r.textSize,highContrast:n(s.highContrast,r.highContrast),reduceMotion:n(s.reduceMotion,r.reduceMotion),underlineLinks:n(s.underlineLinks,r.underlineLinks),strongFocus:n(s.strongFocus,r.strongFocus)}}(JSON.parse(s)):window.matchMedia("(prefers-color-scheme: dark)").matches&&(e={...e,theme:"dark"}),window.matchMedia("(prefers-reduced-motion: reduce)").matches&&!s&&(e={...e,reduceMotion:!0})}catch(e){}o(e),c(e),u(!0)},[]);let m=(0,t.useCallback)(e=>{o(s=>{let n={...s,...e};c(n);try{window.localStorage.setItem(l,JSON.stringify(n))}catch(e){}return n})},[]),p=(0,t.useCallback)(()=>{o(r),c(r);try{window.localStorage.removeItem(l)}catch(e){}},[]);return(0,a.jsx)(d.Provider,{value:{appearance:n,set:m,reset:p,loaded:h},children:s})}function h(){return(0,t.useContext)(d)}},8596:(e,s,n)=>{"use strict";n.d(s,{E:()=>r});var a=n(3365),t=n(1521),l=n(5549),i=n(867);function r(e){var s,n,r,c,d,o,h;let{dir:u,onDone:m}=e,{t:p}=(0,i.kj)(),v=(0,i.W3)(),[x,j]=(0,t.useState)(null),[g,f]=(0,t.useState)(""),[y,b]=(0,t.useState)(""),[k,N]=(0,t.useState)(""),[w,S]=(0,t.useState)(!1),C=e=>(null!=e?e:"—").slice(0,8),F=async e=>{b(""),N(""),f(e?"fetch":"prepare");try{j(await l.FH.preparePreview(u,e))}catch(e){b(e.message)}finally{f("")}},I=async()=>{if(null==x?void 0:x.fingerprint){b(""),f("prepare");try{var e,s;let n=await l.FH.prepareProject(u,x.fingerprint,{savedBranch:x.savedBranch,savedMainBranch:x.savedMainBranch});n.ok?(N(null!=(s=n.result)?s:""),j(null),null==m||m()):b(null!=(e=n.problem)?e:"")}catch(e){b(e.message)}finally{f("")}}},W=async e=>{try{await navigator.clipboard.writeText(e),S(!0),window.setTimeout(()=>S(!1),2500)}catch(e){b(p("plan.copyFailed"))}},M=e=>(0,a.jsxs)("ul",{style:{margin:"2px 0 6px",paddingLeft:20},children:[e.slice(0,30).map(e=>(0,a.jsx)("li",{children:(0,a.jsx)("code",{children:e})},e)),e.length>30&&(0,a.jsx)("li",{className:"muted",children:p("prep.more",{n:e.length-30})})]}),T=x&&!x.ok&&x.fetched&&!x.fetched.ok;return(0,a.jsxs)("div",{className:"prepare-folder small",style:{marginTop:8,overflowWrap:"anywhere"},children:[(0,a.jsx)("button",{type:"button",onClick:()=>void F(!0),disabled:!!g,children:p("prep.show")}),(0,a.jsx)("p",{className:"why",children:p("prep.why")}),(0,a.jsx)("p",{className:"why",children:p("prep.password")}),"fetch"===g&&(0,a.jsx)("p",{role:"status",children:p("prep.fetching")}),y&&(0,a.jsx)("p",{className:"err",role:"alert",children:y}),k&&(0,a.jsx)("p",{className:"notice",role:"status",children:k}),x&&!x.ok&&!T&&(0,a.jsx)("p",{className:"err",children:x.problem}),T&&(0,a.jsxs)("div",{className:"notice caution",style:{marginTop:8},children:[(0,a.jsxs)("p",{children:[(0,a.jsx)("strong",{children:p("prep.fetchFailed")})," ",(0,a.jsx)("code",{children:null==(s=x.fetched)?void 0:s.detail})]}),(null==(n=x.fetched)?void 0:n.auth)&&(0,a.jsx)("p",{children:p("prep.fetchAuth")}),(0,a.jsx)("div",{className:"row",children:(0,a.jsx)("button",{type:"button",onClick:()=>void F(!0),disabled:!!g,children:p("prep.retry")})}),x.fetchCommand&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("p",{style:{marginTop:8},children:p("prep.ownTerminal")}),(0,a.jsx)("pre",{className:"sync-cmd",children:x.fetchCommand}),(0,a.jsxs)("div",{className:"row",children:[(0,a.jsx)("button",{type:"button",onClick:()=>{var e;W(null!=(e=x.fetchCommand)?e:"")},children:p("prep.copyFetch")}),w&&(0,a.jsx)("span",{className:"badge done",children:p("prep.copied")}),(0,a.jsx)("button",{type:"button",onClick:()=>void F(!1),disabled:!!g,children:p("prep.useFetched")})]}),x.lastFetched&&(0,a.jsx)("p",{className:"muted",children:p("prep.lastFetched",{when:v(x.lastFetched)})})]})]}),(null==x?void 0:x.ok)&&(0,a.jsxs)("div",{className:"notice caution",style:{marginTop:8},children:[(0,a.jsx)("p",{children:p("prep.where",{target:null!=(r=x.target)?r:"",commit:C(x.targetCommit),branch:null!=(c=x.branch)?c:"HEAD",head:C(x.head)})}),!x.fetched&&(0,a.jsxs)("p",{className:"muted",children:[p("prep.notFetched")," ",x.lastFetched?p("prep.lastFetched",{when:v(x.lastFetched)}):p("prep.lastFetchedUnknown")]}),x.alreadyThere?(0,a.jsx)("p",{children:p("prep.already")}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("strong",{children:p("prep.willDo")}),(0,a.jsxs)("ol",{style:{margin:"4px 0",paddingLeft:20},children:[x.savedBranch&&(0,a.jsxs)("li",{children:[p("prep.keepChanges",{changed:x.changed.length,untracked:x.untracked.length,saved:x.savedBranch}),M([...x.changed,...x.untracked])]}),x.savedMainBranch&&(0,a.jsxs)("li",{children:[p("prep.keepMain",{n:x.mainOnlyCommits.length,branch:null!=(d=x.localBranch)?d:"",saved:x.savedMainBranch}),M(x.mainOnlyCommits)]}),(0,a.jsx)("li",{children:p("prep.moveTo",{branch:null!=(o=x.localBranch)?o:"",commit:C(x.targetCommit),target:null!=(h=x.target)?h:""})})]}),x.branchOnlyCommits.length>0&&x.branch&&(0,a.jsx)("p",{children:p("prep.branchStays",{branch:x.branch,n:x.branchOnlyCommits.length})}),(0,a.jsx)("p",{className:"muted",children:p("prep.ignored")}),(0,a.jsxs)("div",{className:"row",children:[(0,a.jsx)("button",{type:"button",className:"primary",onClick:()=>void I(),disabled:!!g,children:p("prep.confirm")}),(0,a.jsx)("button",{type:"button",className:"quiet",onClick:()=>j(null),disabled:!!g,children:p("prep.cancel")})]})]})]})]})}},8848:(e,s,n)=>{"use strict";n.d(s,{H4:()=>d,L:()=>o,z4:()=>h});var a=n(3365),t=n(8197),l=n.n(t),i=n(1521),r=n(5549),c=n(867);function d(e){let{current:s,onUse:n}=e,{t}=(0,c.kj)(),[l,d]=(0,i.useState)(null);if((0,i.useEffect)(()=>{let e=!1;return r.FH.project().then(s=>{e||d(s)}).catch(()=>void 0),()=>{e=!0}},[]),!l)return null;let o=l.rootDir.trim(),h=s.trim().toLowerCase(),u=n?l.others.filter(e=>e.rootDir.trim().toLowerCase()!==h):[];return(0,a.jsx)(m,{label:o?t("proj.defaultIs",{dir:o}):t("proj.noneShort"),offer:o&&n&&h!==o.toLowerCase()?{text:t("proj.useIt"),onUse:()=>n(o)}:void 0,more:u.map(e=>({text:t("proj.otherUse",{name:e.name}),title:e.rootDir,onUse:()=>null==n?void 0:n(e.rootDir)})),link:o?t("proj.change"):t("proj.setIt"),anchor:"project"})}function o(e){let{current:s,onUse:n}=e,t=u(),{t:l}=(0,c.kj)();if(!t)return null;let i=t.defaultModel.trim();return(0,a.jsx)(m,{label:i?l("def.modelDefaultIs",{name:i}):l("def.modelNoneShort"),offer:i&&n&&s.trim()!==i?{text:l("def.modelUseIt"),onUse:()=>n(i)}:void 0,link:l(i?"proj.change":"proj.setIt"),anchor:"model"})}function h(e){let{current:s,onUse:n}=e,t=u(),{t:l}=(0,c.kj)();if(!t)return null;let i=t.defaultReviewModel.trim();return(0,a.jsx)(m,{label:i?l("def.reviewDefaultIs",{name:i}):l("def.reviewNoneShort"),offer:i&&n&&s.trim()!==i?{text:l("def.modelUseIt"),onUse:()=>n(i)}:void 0,link:l(i?"proj.change":"proj.setIt"),anchor:"review"})}function u(){let[e,s]=(0,i.useState)(null);return(0,i.useEffect)(()=>{let e=!1;return r.FH.models().then(n=>{e||s(n)}).catch(()=>void 0),()=>{e=!0}},[]),e}function m(e){let{label:s,offer:n,more:t=[],link:i,anchor:r}=e;return(0,a.jsxs)("p",{className:"muted small",style:{marginTop:4},children:[s," ",n&&(0,a.jsxs)(a.Fragment,{children:["\xb7"," ",(0,a.jsx)("button",{type:"button",className:"linkish",onClick:n.onUse,children:n.text})," "]}),t.map(e=>(0,a.jsxs)("span",{children:["\xb7"," ",(0,a.jsx)("button",{type:"button",className:"linkish",onClick:e.onUse,title:e.title,children:e.text})," "]},e.text)),"\xb7 ",(0,a.jsx)(l(),{href:"/defaults#".concat(r),children:i})]})}},9717:(e,s,n)=>{"use strict";n.d(s,{D:()=>l});var a=n(3365),t=n(867);function l(e){var s,n;let{plan:l,showApproval:i=!0}=e,{t:r}=(0,t.kj)(),c=(0,t.W3)(),d=l.approved;return(0,a.jsxs)("div",{className:"plan-view",children:[(0,a.jsx)("p",{className:"small muted",children:r("pm.version",{n:l.version,at:c(l.at)})}),i&&d&&(0,a.jsxs)("p",{className:"small",children:["operator"===d.by?r("pm.approvedByOperator",{at:c(d.at)}):r("pm.approvedAuto",{at:c(d.at)}),d.why&&" ".concat(d.why),d.note&&" ".concat(r("pm.approvedNote",{note:d.note}))]}),(0,a.jsx)("h4",{children:r("pm.existing")}),(0,a.jsx)("p",{className:"pre-wrap",children:l.existing}),(0,a.jsx)("h4",{children:r("pm.approach")}),(0,a.jsx)("p",{className:"pre-wrap",children:l.approach}),(0,a.jsx)("h4",{children:r("pm.steps")}),(0,a.jsx)("ol",{children:l.steps.map((e,s)=>(0,a.jsx)("li",{className:"pre-wrap",children:e},s))}),l.files.length>0&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("h4",{children:r("pm.files")}),(0,a.jsx)("ul",{children:l.files.map(e=>(0,a.jsx)("li",{children:(0,a.jsx)("code",{children:e})},e))})]}),(0,a.jsx)("h4",{children:r("pm.verification")}),(0,a.jsx)("p",{className:"pre-wrap",children:l.verification}),l.risks&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("h4",{children:r("pm.risks")}),(0,a.jsx)("p",{className:"pre-wrap",children:l.risks})]}),(null!=(n=null==(s=l.revisions)?void 0:s.length)?n:0)>0&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("h4",{children:r("pm.revisions")}),(0,a.jsx)("ul",{children:l.revisions.map(e=>(0,a.jsxs)("li",{className:"small",children:[r("pm.revision",{n:e.version,at:c(e.at)})," ",(0,a.jsx)("span",{className:"pre-wrap",children:e.comment})]},e.version))})]})]})}}},e=>{e.O(0,[197,867,549,499,897,699,347,131,358],()=>e(e.s=1772)),_N_E=e.O()}]);