copilot-operator 0.1.1 → 0.1.2

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 (57) hide show
  1. package/dist/src/api/operator.controller.js +44 -0
  2. package/dist/src/api/operator.service.js +48 -13
  3. package/dist/src/config/schema.js +8 -2
  4. package/dist/src/orchestrator/taskRunner.js +26 -13
  5. package/dist/src/plan/importPlan.js +3 -2
  6. package/dist/src/plan/systemGuide.js +56 -0
  7. package/dist/src/session/compose.js +21 -2
  8. package/dist/src/session/store.js +51 -1
  9. package/dist/src/transport/chatSession.js +16 -4
  10. package/dist/src/vcs/taskVcs.js +5 -0
  11. package/dist/web/404.html +2 -2
  12. package/dist/web/_next/static/chunks/549-2086c05135bc9753.js +1 -0
  13. package/dist/web/_next/static/chunks/867-5b104743e24a4e2f.js +1 -0
  14. package/dist/web/_next/static/chunks/955-cf291b8a60315c58.js +1 -0
  15. package/dist/web/_next/static/chunks/app/defaults/page-559af121c43127a1.js +1 -0
  16. package/dist/web/_next/static/chunks/app/history/{page-bad4f3e89b485719.js → page-0df90ab9998815db.js} +1 -1
  17. package/dist/web/_next/static/chunks/app/import/page-8a4bdee8e38341a9.js +1 -0
  18. package/dist/web/_next/static/chunks/app/layout-92fa876afe619cf3.js +1 -0
  19. package/dist/web/_next/static/chunks/app/level1/page-697d4d6ba5bba41a.js +1 -0
  20. package/dist/web/_next/static/chunks/app/page-050cf6f71187e8af.js +1 -0
  21. package/dist/web/_next/static/chunks/app/presets/page-e2dcb924d9e2d758.js +1 -0
  22. package/dist/web/_next/static/chunks/app/sessions/view/page-4d31690c22c8b331.js +1 -0
  23. package/dist/web/_next/static/chunks/app/system/page-3aa2a0fef5454e69.js +1 -0
  24. package/dist/web/_next/static/css/{d77735cdc9020a86.css → 5a10c60adf9c5336.css} +1 -1
  25. package/dist/web/appearance.html +2 -2
  26. package/dist/web/appearance.txt +26 -25
  27. package/dist/web/defaults.html +2 -2
  28. package/dist/web/defaults.txt +26 -25
  29. package/dist/web/history.html +2 -2
  30. package/dist/web/history.txt +26 -25
  31. package/dist/web/import.html +2 -2
  32. package/dist/web/import.txt +26 -25
  33. package/dist/web/index.html +2 -2
  34. package/dist/web/index.txt +26 -25
  35. package/dist/web/level1.html +2 -2
  36. package/dist/web/level1.txt +26 -25
  37. package/dist/web/presets.html +2 -2
  38. package/dist/web/presets.txt +26 -25
  39. package/dist/web/sessions/view.html +2 -2
  40. package/dist/web/sessions/view.txt +26 -25
  41. package/dist/web/system.html +2 -2
  42. package/dist/web/system.txt +26 -25
  43. package/package.json +5 -3
  44. package/prompts/level1.md +17 -7
  45. package/dist/web/_next/static/chunks/643-34b9f66a6c317c4a.js +0 -1
  46. package/dist/web/_next/static/chunks/867-03b7cac8f79896c3.js +0 -1
  47. package/dist/web/_next/static/chunks/955-63de06e182d98949.js +0 -1
  48. package/dist/web/_next/static/chunks/app/defaults/page-ed858127cbdfb4ab.js +0 -1
  49. package/dist/web/_next/static/chunks/app/import/page-db1f5f1ab2f5cad1.js +0 -1
  50. package/dist/web/_next/static/chunks/app/layout-72251c52cc54f95e.js +0 -1
  51. package/dist/web/_next/static/chunks/app/level1/page-cf3e50cf64fecf4f.js +0 -1
  52. package/dist/web/_next/static/chunks/app/page-6fd16e5c8cf3b20f.js +0 -1
  53. package/dist/web/_next/static/chunks/app/presets/page-951e78b80e0e22e6.js +0 -1
  54. package/dist/web/_next/static/chunks/app/sessions/view/page-f2e63618097d7221.js +0 -1
  55. package/dist/web/_next/static/chunks/app/system/page-44e7954c0e48f4ba.js +0 -1
  56. /package/dist/web/_next/static/{tMxWYVV0hUR9GoQZ96wFL → eWzbORCbQ1h_2IeLH_njb}/_buildManifest.js +0 -0
  57. /package/dist/web/_next/static/{tMxWYVV0hUR9GoQZ96wFL → eWzbORCbQ1h_2IeLH_njb}/_ssgManifest.js +0 -0
@@ -0,0 +1 @@
1
+ "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[955],{1035:(e,t,s)=>{s.d(t,{DialogHost:()=>c,Z:()=>o});var n=s(3365),a=s(1521),r=s(867);let l=null,i=[];function o(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new Promise(s=>{var n;return n={kind:"confirm",message:e,...t,resolve:s},void(l?l(n):i.push(n))})}function c(e){var t,s;let{children:o}=e,{t:c}=(0,r.kj)(),[d,u]=(0,a.useState)([]),h=(0,a.useRef)(null);(0,a.useEffect)(()=>{if(l=e=>u(t=>[...t,e]),i.length>0){let e=i.splice(0,i.length);u(t=>[...t,...e])}return()=>{l=null}},[]);let m=d[0],p=(0,a.useCallback)(e=>{m&&(m.resolve(e),u(e=>e.slice(1)))},[m]);return(0,a.useEffect)(()=>{var e;if(!m)return;null==(e=h.current)||e.focus();let t=e=>{"Escape"===e.key&&(e.preventDefault(),p(!1))};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[m,p]),(0,n.jsxs)(n.Fragment,{children:[o,m&&(0,n.jsx)("div",{className:"modal-backdrop",onClick:()=>p(!1),role:"presentation",children:(0,n.jsxs)("div",{className:"modal".concat(m.danger?" danger":""),role:"confirm"===m.kind?"alertdialog":"dialog","aria-modal":"true","aria-labelledby":"modal-title",onClick:e=>e.stopPropagation(),children:[(0,n.jsx)("h2",{id:"modal-title",children:null!=(t=m.title)?t:c("confirm"===m.kind?"dialog.confirmTitle":"dialog.noticeTitle")}),(0,n.jsx)("div",{className:"modal-body",children:m.message}),(0,n.jsxs)("div",{className:"row modal-actions",children:["confirm"===m.kind&&(0,n.jsx)("button",{type:"button",className:"quiet",onClick:()=>p(!1),children:c("dialog.cancel")}),(0,n.jsx)("button",{ref:h,type:"button",className:m.danger?"danger":"primary",onClick:()=>p(!0),children:null!=(s=m.okLabel)?s:c("dialog.ok")})]})]})})]})}},1910:(e,t,s)=>{s.d(t,{u:()=>l});var n=s(3365),a=s(1521),r=s(867);function l(e){let{label:t,save:s}=e,{t:l}=(0,r.kj)(),[i,o]=(0,a.useState)(!1),[c,d]=(0,a.useState)(""),[u,h]=(0,a.useState)(!1),m=async()=>{o(!0),d("");try{var e;let t=await s();h(!1),d(t.revealed?l("save.done",{path:t.path}):l("save.savedOnly",{path:t.path,note:null!=(e=t.note)?e:""}))}catch(e){h(!0),d(l("save.failed",{problem:e.message}))}finally{o(!1)}};return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("button",{type:"button",className:"linkish",disabled:i,title:l("save.why"),onClick:()=>void m(),children:i?l("save.saving"):t}),c&&(0,n.jsx)("span",{className:u?"err small":"muted small",children:c})]})}},3041:(e,t,s)=>{s.d(t,{e:()=>i});var n=s(1521),a=s(5549),r=s(1035),l=s(867);function i(e){let{t}=(0,l.kj)(),[s,i]=(0,n.useState)(""),[o,c]=(0,n.useState)("");return{busy:s,message:o,clearMessage:()=>c(""),restore:(0,n.useCallback)(async s=>{i("restore"),c("");try{var n,l,o,d,u,h,m,p,f,x,g,j,y,k;let i=await a.FH.restorePreview(s.sessionId,s.taskId);if(!i.ok)return void c(t("restore.cannot",{problem:null!=(o=i.problem)?o:""}));let v={repo:i.repoDir,title:s.title,branch:null!=(d=i.branchName)?d:"",commit:(null!=(u=i.baseCommit)?u:"").slice(0,8)},N=i.leftBehind.length>0?t("restore.confirmLosing",{...v,n:i.leftBehind.length,kept:null!=(h=i.keptOn)?h:"",list:i.leftBehind.slice(0,10).join("\n")}):t("restore.confirm",v);if(!await (0,r.Z)(N))return;let b=await a.FH.restore(s.sessionId,s.taskId);if(!b.ok)return void c(t("restore.failed",{problem:null!=(m=b.problem)?m:""}));c((null!=(p=null==(n=b.leftBehind)?void 0:n.length)?p:0)>0?t("restore.done",{branch:null!=(f=b.branch)?f:"",commit:(null!=(x=b.commit)?x:"").slice(0,8),n:null!=(g=null==(l=b.leftBehind)?void 0:l.length)?g:0,kept:null!=(j=b.keptOn)?j:""}):t("restore.doneNothing",{branch:null!=(y=b.branch)?y:"",commit:(null!=(k=b.commit)?k:"").slice(0,8)})),e()}catch(e){c(e.message)}finally{i("")}},[t,e]),restartFrom:(0,n.useCallback)(async s=>{i("restart"),c("");try{var n,l;let i=await a.FH.restartPlan(s.sessionId,s.taskId);if(!i.ok)return void c(t("restart.cannot",{problem:null!=(n=i.problem)?n:""}));let o=i.restores.filter(e=>!e.ok);if(o.length>0)return void c(t("restart.cannot",{problem:o.map(e=>{var t;return"".concat(e.repoDir,": ").concat(null!=(t=e.problem)?t:"")}).join(" | ")}));let d=i.restores.map(e=>{var s,n,a;return t("restart.repoLine",{repo:e.repoDir,commit:(null!=(s=e.baseCommit)?s:"").slice(0,8),branch:null!=(n=e.branchName)?n:"",n:e.leftBehind.length,kept:null!=(a=e.keptOn)?a:""})}).join("\n"),u=i.tasks.map(e=>" ".concat(e.sessionName," / ").concat(e.title).concat(e.alreadyQueued?t("restart.alreadyQueued"):"")).join("\n"),h=t("restart.confirm",{title:i.from.title,tasks:i.tasks.length,sessions:i.sessions.length,list:u,repos:d||t("restart.noRepo"),mode:t("unattended"===i.mode?"run.unattended":"run.confirm")});if(!await (0,r.Z)(h))return;let m=await a.FH.restartFrom(s.sessionId,s.taskId);if(!m.started){c(t("restart.failed",{problem:null!=(l=m.reason)?l:""})),e();return}c(t("restart.started",{requeued:m.requeued,repos:m.restored.length})),e()}catch(e){c(e.message)}finally{i("")}},[t,e])}}},3374:(e,t,s)=>{s.d(t,{c:()=>a});var n=s(1521);function a(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1e3,[s,a]=(0,n.useState)(()=>Date.now());return(0,n.useEffect)(()=>{if(!e)return;a(Date.now());let s=window.setInterval(()=>a(Date.now()),t);return()=>window.clearInterval(s)},[e,t]),s}},3523:(e,t,s)=>{function n(e,t){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Date.now();if(!e)return;let n=Date.parse(e);if(Number.isNaN(n))return;let a=t?Date.parse(t):s;return Number.isNaN(a)?void 0:Math.max(0,a-n)}function a(e){return!!e.startedAt&&!e.finishedAt&&"queued"!==e.status}function r(e,t){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Date.now(),n=t.some(e=>a(e)),r=t.map(e=>e.finishedAt?Date.parse(e.finishedAt):NaN).filter(e=>!Number.isNaN(e)),l=Date.parse(e.startedAt),i=n||0===r.length?s:Math.max(...r);return{ms:Number.isNaN(l)?0:Math.max(0,i-l),live:n,tasks:t.length}}function l(e){var t,s;let n=new Map;for(let s of e){if(!s.runGroup)continue;let e=null!=(t=n.get(s.runGroup.id))?t:{run:s.runGroup,tasks:[]};e.tasks.push(s),n.set(s.runGroup.id,e)}return null!=(s=[...n.values()].sort((e,t)=>Date.parse(t.run.startedAt)-Date.parse(e.run.startedAt))[0])?s:null}s.d(t,{DG:()=>a,d5:()=>n,eZ:()=>r,hH:()=>l})},5132:(e,t,s)=>{s.d(t,{s:()=>i});var n=s(3365),a=s(1521);function r(e,t){let s,a=[],r=/(`[^`\n]+`)|(\*\*[^*\n]+\*\*)|(\*[^*\n]+\*)/g,l=0,i=0;for(;null!==(s=r.exec(e));){s.index>l&&a.push(e.slice(l,s.index));let r=s[0],o="".concat(t,"-i").concat(i+=1);r.startsWith("`")?a.push((0,n.jsx)("code",{children:r.slice(1,-1)},o)):r.startsWith("**")?a.push((0,n.jsx)("strong",{children:r.slice(2,-2)},o)):a.push((0,n.jsx)("em",{children:r.slice(1,-1)},o)),l=s.index+r.length}return l<e.length&&a.push(e.slice(l)),a}function l(e){let t=/^\s*[-*•]\s+(.*)$/.exec(e);if(t)return t[1];let s=/^\s*\d+[.)]\s+(.*)$/.exec(e);return s?s[1]:null}function i(e){let{text:t,className:s}=e,i=[],o=t.replace(/\r\n/g,"\n").split("\n"),c=0,d=0;for(;c<o.length;){let e=o[c];if(e.trim().startsWith("```")){let e=[];for(c+=1;c<o.length&&!o[c].trim().startsWith("```");)e.push(o[c++]);c+=1,e.length>0&&i.push((0,n.jsx)("pre",{children:e.join("\n")},"b".concat(d+=1)));continue}if(null!==l(e)){let e=[];for(;c<o.length&&null!==l(o[c]);)e.push(l(o[c++]));i.push((0,n.jsx)("ul",{children:e.map((e,t)=>(0,n.jsx)("li",{children:r(e,"b".concat(d,"-").concat(t))},t))},"b".concat(d+=1)));continue}if(""===e.trim()){c+=1;continue}let t=[];for(;c<o.length&&""!==o[c].trim()&&null===l(o[c])&&!o[c].trim().startsWith("```");)t.push(o[c++]);let s=d+=1;i.push((0,n.jsx)("p",{children:t.map((e,t)=>(0,n.jsxs)(a.Fragment,{children:[t>0&&(0,n.jsx)("br",{}),r(e,"b".concat(s,"-").concat(t))]},t))},"b".concat(s)))}return(0,n.jsx)("div",{className:"rich ".concat(null!=s?s:""),children:i})}},7619:(e,t,s)=>{s.d(t,{P:()=>o});var n=s(3365),a=s(1521),r=s(5549),l=s(867),i=s(5132);function o(e){let{sessionId:t,taskId:s,runId:o,live:c}=e,{t:d}=(0,l.kj)(),[u,h]=(0,a.useState)(null),[m,p]=(0,a.useState)(""),[f,x]=(0,a.useState)(!0),[g,j]=(0,a.useState)(!0),[y,k]=(0,a.useState)(new Set);if((0,a.useEffect)(()=>{let e,n=!0,a=async()=>{try{let l=await r.FH.taskStory(t,s,o);if(!n)return;h(l),p(""),l.live&&(e=setTimeout(a,4e3))}catch(t){if(!n)return;p(t.message),c&&(e=setTimeout(a,4e3))}};return a(),()=>{n=!1,e&&clearTimeout(e)}},[t,s,o,c]),m&&!u)return(0,n.jsx)("div",{className:"err small",children:m});if(!u)return(0,n.jsx)("div",{className:"muted small",children:d("story.loading")});let v=e=>k(t=>{let s=new Set(t);return s.has(e)?s.delete(e):s.add(e),s}),N=(e,t)=>{if(!("review"===e.kind?f||g:"step"===e.kind?g:f))return null;if("review"===e.kind)return(0,n.jsxs)("li",{className:"story-review",children:[(0,n.jsx)("div",{className:"story-head",children:(0,n.jsx)("span",{className:"chip",children:d("story.review",{n:e.round})})}),(0,n.jsx)("ol",{className:"story",children:e.entries.map((e,s)=>N(e,"".concat(t,"-").concat(s)))})]},t);if("step"===e.kind){let s=y.has(t);return(0,n.jsxs)("li",{className:"story-step".concat(e.failed?" failed":""),children:[(0,n.jsxs)("div",{className:"story-head",children:[(0,n.jsx)("span",{className:"chip",children:d("story.step",{it:e.iteration,id:e.id})}),e.outcome&&(0,n.jsxs)("span",{className:"badge ".concat(e.failed?"failed":"done"),children:[e.outcome,void 0!==e.exitCode?" \xb7 exit ".concat(e.exitCode):"",void 0!==e.durationMs?" \xb7 ".concat((0,r.c5)(e.durationMs)):""]}),!e.outcome&&(0,n.jsx)("span",{className:"badge running",children:d("story.running")}),e.failed&&(0,n.jsx)("span",{className:"badge failed",children:d("story.failedHere")})]}),(0,n.jsx)("pre",{className:"story-cmd",children:e.command}),e.output&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("button",{type:"button",className:"linkish small",onClick:()=>v(t),children:s?d("story.hideOutput"):d("story.showOutput",{n:e.output.length})}),s&&(0,n.jsx)("pre",{className:"story-out",children:e.output})]})]},t)}let s=y.has(t),a="sent"===e.kind?d("story.bot"):d("story.chat"),l="reply"===e.kind&&("blocked"===e.status||"failed"===e.status);return(0,n.jsxs)("li",{className:"story-msg ".concat(e.kind).concat(l?" failed":""),children:[(0,n.jsxs)("div",{className:"story-head",children:[(0,n.jsx)("strong",{children:a}),(0,n.jsx)("span",{className:"muted small",children:e.label}),"reply"===e.kind&&e.status&&(0,n.jsx)("span",{className:"badge ".concat(l?"failed":"done"===e.status?"done":""),children:e.status})]}),"reply"===e.kind&&e.notes&&(0,n.jsx)("p",{className:"story-notes",children:e.notes}),(0,n.jsx)("button",{type:"button",className:"linkish small",onClick:()=>v(t),children:s?d("story.hideText"):d("story.showText",{n:e.text.length})}),s&&(0,n.jsx)("pre",{className:"story-out",children:e.text})]},t)},b=u.close,w=b&&"done"!==b.status;return(0,n.jsxs)("div",{className:"story-box",children:[(0,n.jsxs)("div",{className:"row small",style:{marginBottom:6},children:[(0,n.jsxs)("label",{className:"option-inline",children:[(0,n.jsx)("input",{type:"checkbox",checked:f,onChange:e=>x(e.target.checked)})," ",d("story.showChat")]}),(0,n.jsxs)("label",{className:"option-inline",children:[(0,n.jsx)("input",{type:"checkbox",checked:g,onChange:e=>j(e.target.checked)})," ",d("story.showCommands")]}),u.live&&(0,n.jsxs)("span",{className:"live",children:[(0,n.jsx)("span",{className:"dot","aria-hidden":"true"})," ",d("story.live")]}),m&&(0,n.jsx)("span",{className:"err",children:m})]}),(0,n.jsxs)("div",{className:"story-fixed",children:[(0,n.jsx)("strong",{children:d("story.prompt")}),(0,n.jsx)("pre",{className:"story-out always",children:u.prompt})]}),(0,n.jsx)("ol",{className:"story",children:u.entries.map((e,t)=>N(e,"e".concat(t)))}),b?(0,n.jsxs)("div",{className:"story-fixed close".concat(w?" failed":""),children:[(0,n.jsx)("strong",{children:w?d("story.endedBadly",{status:b.status}):d("story.ended")}),b.reason&&(0,n.jsx)("p",{className:"err small",children:b.reason}),b.summary&&(0,n.jsx)(i.s,{text:b.summary,className:"what"}),b.checks&&b.checks.length>0&&(0,n.jsx)("ul",{className:"small",style:{margin:"6px 0 0",paddingLeft:18},children:b.checks.map((e,t)=>(0,n.jsxs)("li",{className:e.passed?"":"err",children:[e.passed?"✓":"✗"," ",e.name,!e.passed&&e.detail?" — ".concat(e.detail):""]},t))})]}):(0,n.jsx)("div",{className:"story-fixed muted small",children:d("story.notEnded")})]})}}}]);
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[189],{1035:(e,l,t)=>{"use strict";t.d(l,{DialogHost:()=>d,Z:()=>o});var r=t(3365),a=t(1521),s=t(867);let n=null,i=[];function o(e){let l=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new Promise(t=>{var r;return r={kind:"confirm",message:e,...l,resolve:t},void(n?n(r):i.push(r))})}function d(e){var l,t;let{children:o}=e,{t:d}=(0,s.kj)(),[c,u]=(0,a.useState)([]),m=(0,a.useRef)(null);(0,a.useEffect)(()=>{if(n=e=>u(l=>[...l,e]),i.length>0){let e=i.splice(0,i.length);u(l=>[...l,...e])}return()=>{n=null}},[]);let h=c[0],x=(0,a.useCallback)(e=>{h&&(h.resolve(e),u(e=>e.slice(1)))},[h]);return(0,a.useEffect)(()=>{var e;if(!h)return;null==(e=m.current)||e.focus();let l=e=>{"Escape"===e.key&&(e.preventDefault(),x(!1))};return window.addEventListener("keydown",l),()=>window.removeEventListener("keydown",l)},[h,x]),(0,r.jsxs)(r.Fragment,{children:[o,h&&(0,r.jsx)("div",{className:"modal-backdrop",onClick:()=>x(!1),role:"presentation",children:(0,r.jsxs)("div",{className:"modal".concat(h.danger?" danger":""),role:"confirm"===h.kind?"alertdialog":"dialog","aria-modal":"true","aria-labelledby":"modal-title",onClick:e=>e.stopPropagation(),children:[(0,r.jsx)("h2",{id:"modal-title",children:null!=(l=h.title)?l:d("confirm"===h.kind?"dialog.confirmTitle":"dialog.noticeTitle")}),(0,r.jsx)("div",{className:"modal-body",children:h.message}),(0,r.jsxs)("div",{className:"row modal-actions",children:["confirm"===h.kind&&(0,r.jsx)("button",{type:"button",className:"quiet",onClick:()=>x(!1),children:d("dialog.cancel")}),(0,r.jsx)("button",{ref:m,type:"button",className:h.danger?"danger":"primary",onClick:()=>x(!0),children:null!=(t=h.okLabel)?t:d("dialog.ok")})]})]})})]})}},1896:(e,l,t)=>{Promise.resolve().then(t.bind(t,3197))},2244:(e,l,t)=>{"use strict";t.d(l,{k:()=>c});var r=t(3365),a=t(1521),s=t(5549),n=t(867);function i(e){return e.trim().replace(/\\/g,"/").replace(/^\.\//,"").replace(/\/+$/,"")}function o(e,l){return"."===l||""===l||e===l||e.startsWith("".concat(l,"/"))}function d(e,l,t){return t.includes(e)?"out":t.some(l=>l!==e&&o(e,l))?"out-inherited":l.includes(e)?"in":l.some(l=>l!==e&&o(e,l))?"inherited":"none"}function c(e){let{rootDir:l,respectGitignore:t,includeEnvFiles:c,include:u,exclude:m,onChange:h}=e,{t:x}=(0,n.kj)(),[p,j]=(0,a.useState)(null),[v,f]=(0,a.useState)(""),[g,y]=(0,a.useState)(new Set),[b,N]=(0,a.useState)(""),w=async()=>{if(l.trim()){f("");try{let e=await s.FH.dirs(l,t);j(e),N("".concat(l,"|").concat(t)),y(new Set(e.filter(e=>!e.includes("/"))))}catch(e){f(e.message)}}};(0,a.useEffect)(()=>{j(null),N("")},[l,t]);let k=(0,a.useMemo)(()=>(function(e){let l=[],t=new Map;for(let a of[...e].sort()){var r;let e={path:a,name:null!=(r=a.split("/").pop())?r:a,children:[]};t.set(a,e);let s=a.includes("/")?t.get(a.slice(0,a.lastIndexOf("/"))):void 0;(s?s.children:l).push(e)}return l})(null!=p?p:[]),[p]),S=u.map(i).filter(Boolean),C=m.map(i).filter(Boolean),D=e=>(0,r.jsx)("ul",{className:"dir-tree",children:e.map(e=>{let l=d(e.path,S,C),t=g.has(e.path),a=function(e,l,t){let r=l=>l.filter(l=>l!==e&&o(l,e)).length;return{included:r(l),excluded:r(t)}}(e.path,S,C),s=!t&&e.children.length>0&&(a.included>0||a.excluded>0);return(0,r.jsxs)("li",{className:"dir ".concat(l),children:[(0,r.jsxs)("div",{className:"dir-row",children:[e.children.length>0?(0,r.jsx)("button",{type:"button",className:"dir-flip",onClick:()=>{let l;return l=e.path,y(e=>{let t=new Set(e);return t.has(l)?t.delete(l):t.add(l),t})},"aria-label":t?x("tree.fold"):x("tree.unfold"),"aria-expanded":t,children:t?"▾":"▸"}):(0,r.jsx)("span",{className:"dir-flip","aria-hidden":"true"}),(0,r.jsxs)("button",{type:"button",className:"dir-name",onClick:()=>(e=>{if("in"===d(e,S,C))return void h(S.filter(l=>l!==e),C);h([...S.filter(l=>!o(l,e)),e],C.filter(l=>!o(l,e)))})(e.path),title:"in"===l?x("tree.stateIn"):"inherited"===l?x("tree.stateInherited"):"out"===l?x("tree.stateOut"):"out-inherited"===l?x("tree.stateOutInherited"):x("tree.stateNone"),"aria-pressed":"in"===l||"inherited"===l,children:[(0,r.jsx)("span",{className:"dir-mark","aria-hidden":"true",children:"in"===l?"✓":"inherited"===l?"\xb7":"out"===l||"out-inherited"===l?"\xd7":""}),e.name]}),(0,r.jsx)("button",{type:"button",className:"dir-out".concat("out"===l?" on":""),onClick:()=>(e=>{if(C.includes(e))return void h(S,C.filter(l=>l!==e));h(S.filter(l=>l!==e&&!o(l,e)),[...C.filter(l=>!o(l,e)),e])})(e.path),title:"out"===l?x("tree.unexclude"):x("tree.exclude"),children:"−"}),s&&(0,r.jsx)("span",{className:"chip inside".concat(a.excluded>0?" out":""),title:x("tree.insideWhy"),children:a.excluded>0&&a.included>0?x("tree.insideBoth",{i:a.included,e:a.excluded}):a.excluded>0?x("tree.insideOut",{n:a.excluded}):x("tree.insideIn",{n:a.included})})]}),t&&e.children.length>0&&D(e.children)]},e.path)})}),F=b!=="".concat(l,"|").concat(t);return(0,r.jsxs)("div",{className:"dir-tree-box",children:[(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("button",{type:"button",onClick:()=>void w(),disabled:!l.trim(),children:null===p||F?x("tree.load"):x("tree.reload")}),(0,r.jsx)("span",{className:"muted small",children:x("tree.hint")})]}),v&&(0,r.jsx)("div",{className:"err small",children:v}),(0,r.jsxs)("p",{className:"muted small",style:{marginTop:6},children:[x("tree.alsoOut")," ",[t?x("tree.alsoGitignore"):null,!1===c?x("tree.alsoEnv"):null,x("tree.alsoAlways")].filter(Boolean).join(" \xb7 ")]}),null!==p&&!F&&(0===p.length?(0,r.jsx)("p",{className:"muted small",children:x("mirror.noDirs")}):D(k))]})}},3197:(e,l,t)=>{"use strict";t.r(l),t.d(l,{default:()=>m});var r=t(3365),a=t(1521),s=t(8197),n=t.n(s),i=t(5549),o=t(867),d=t(1035),c=t(4784),u=t(2244);function m(){let{t:e}=(0,o.kj)(),[l,t]=(0,a.useState)(null),[s,n]=(0,a.useState)(!1),[c,u]=(0,a.useState)("");(0,a.useEffect)(()=>{i.FH.models().then(t).catch(()=>void 0)},[]);let m=async()=>{if(await (0,d.Z)(e("model.refreshConfirm"))){n(!0),u(e("model.refreshing"));try{var l;let r=await i.FH.models().then(()=>i.FH.refreshModels());t(r),u(0===r.options.length?null!=(l=r.note)?l:e("model.none"):e("model.refreshed",{n:r.options.length}))}catch(e){u(e.message)}finally{n(!1)}}},h={catalogue:l,setCatalogue:t,refreshModels:m,refreshing:s,refreshMsg:c};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"panel",children:[(0,r.jsx)("h2",{children:e("def.title")}),(0,r.jsx)("p",{className:"muted small",children:e("def.intro")}),(0,r.jsx)("p",{className:"why",children:e("def.autoSave")})]}),(0,r.jsx)(p,{}),(0,r.jsx)(g,{...h}),(0,r.jsx)(y,{...h}),(0,r.jsx)(f,{})]})}function h(e){let l=arguments.length>1&&void 0!==arguments[1]?arguments[1]:900,t=(0,a.useRef)(null),r=(0,a.useRef)(e);return r.current=e,(0,a.useEffect)(()=>()=>{t.current&&clearTimeout(t.current)},[]),e=>{t.current&&clearTimeout(t.current),t.current=setTimeout(()=>void r.current(e),l)}}function x(e){let{msg:l,onSave:t}=e,{t:a}=(0,o.kj)();return(0,r.jsxs)("div",{className:"row",style:{marginTop:6},children:[t&&(0,r.jsx)("button",{className:"quiet",onClick:t,title:a("def.saveAnywayWhy"),children:a("def.saveAnyway")}),(0,r.jsx)("span",{className:"muted small",role:"status",children:l||a("def.savedAutomatically")})]})}function p(){var e;let{t:l}=(0,o.kj)(),[t,s]=(0,a.useState)(null),[n,d]=(0,a.useState)(""),[c,u]=(0,a.useState)(""),[m,p]=(0,a.useState)(""),[v,f]=(0,a.useState)(""),[g,y]=(0,a.useState)(!1),[b,N]=(0,a.useState)(""),[w,k]=(0,a.useState)(""),S=(0,a.useCallback)(async()=>{try{let e=await i.FH.project();s(e),d(e.rootDir),u(e.name),f("")}catch(e){f(e.message)}},[]);(0,a.useEffect)(()=>{S()},[S]);let C=async(e,l)=>{y(!0),p("");try{let t=await i.FH.setProject(e);return s(t),d(t.rootDir),p(l(t)),f(""),!0}catch(e){return f(e.message),!1}finally{y(!1)}},D=e=>C({rootDir:e},e=>e.rootDir?l("proj.saved",{dir:e.rootDir}):l("proj.cleared")),F=e=>C({name:e},()=>l("proj.nameSaved")),M=h(D),R=h(F),T=async(e,l)=>{y(!0);try{var t;let r=await i.FH.browseFolder(l.trim()||void 0);r.ok?e(r.path):r.cancelled||f(null!=(t=r.reason)?t:"")}finally{y(!1)}},B=null!=(e=null==t?void 0:t.others)?e:[],E=e=>e.map(e=>({name:e.name,rootDir:e.rootDir,...e.mirror?{mirror:e.mirror}:{}})),I=async()=>{await C({others:[...E(B),{name:b.trim(),rootDir:w.trim()}]},e=>l("proj.othersSaved",{n:e.others.length}))&&(N(""),k(""))};return(0,r.jsxs)("div",{className:"panel",id:"project",children:[(0,r.jsx)("h2",{children:l("proj.title")}),(0,r.jsx)("p",{className:"muted small",children:l("proj.intro")}),v&&(0,r.jsx)("div",{className:"err",children:v}),t&&(0,r.jsxs)("div",{className:"option".concat(t.mirrorToDesktop?" warned":""),style:{marginBottom:12},children:[(0,r.jsxs)("label",{children:[(0,r.jsx)("input",{type:"checkbox",checked:t.mirrorToDesktop,onChange:e=>{C({mirrorToDesktop:e.target.checked},e=>e.mirrorToDesktop?l("proj.mirrorOn",{root:e.contextRoot}):l("proj.mirrorOff"))},disabled:g}),(0,r.jsx)("span",{children:l("proj.mirrorToDesktop")})]}),(0,r.jsx)("p",{className:"why",children:l("proj.mirrorToDesktopWhy",{root:t.contextRoot})})]}),(0,r.jsx)("p",{className:"muted small",children:l("proj.listIntro")}),(0,r.jsx)(j,{name:c,dir:n,repoOk:!!(null==t?void 0:t.repoOk),repoProblem:null==t?void 0:t.repoProblem,mirror:null==t?void 0:t.mirror,isDefault:!0,busy:g,onName:e=>{u(e),R(e)},onNameBlur:()=>void F(c),onDir:e=>{d(e),M(e)},onDirBlur:()=>void D(n),onBrowse:()=>void T(e=>void D(e),n),onRemove:(null==t?void 0:t.rootDir)?()=>void D(""):void 0,removeLabel:l("proj.clear"),onFolders:e=>C({mirror:e},()=>l("proj.foldersSaved"))}),(0,r.jsx)(x,{msg:m}),t&&!t.rootDir&&(0,r.jsx)("p",{className:"muted small",style:{marginTop:8},children:l("proj.none")}),B.map(e=>(0,r.jsx)(j,{name:e.name,dir:e.rootDir,repoOk:e.repoOk,repoProblem:e.repoProblem,mirror:e.mirror,busy:g,onName:t=>void C({others:E(B.map(l=>l.name===e.name?{...l,name:t}:l))},()=>l("proj.nameSaved")),onDir:t=>void C({others:E(B.map(l=>l.name===e.name?{...l,rootDir:t}:l))},()=>l("proj.othersSaved",{n:B.length})),onBrowse:()=>void T(t=>void C({others:E(B.map(l=>l.name===e.name?{...l,rootDir:t}:l))},()=>l("proj.othersSaved",{n:B.length})),e.rootDir),onRemove:()=>{let t;t=e.name,C({others:E(B.filter(e=>e.name!==t))},e=>l("proj.othersSaved",{n:e.others.length}))},removeLabel:l("proj.otherRemove"),onFolders:t=>{let r;return r=e.name,C({others:E(B.map(e=>e.name===r?{...e,mirror:t}:e))},()=>l("proj.foldersSaved"))}},e.name)),(0,r.jsx)("h3",{id:"others",children:l("proj.addTitle")}),(0,r.jsx)("p",{className:"muted small",children:l("proj.othersIntro")}),(0,r.jsxs)("div",{className:"row",style:{marginTop:8},children:[(0,r.jsx)("input",{type:"text","aria-label":l("proj.entryName"),value:b,onChange:e=>N(e.target.value),placeholder:l("proj.entryName"),disabled:g,style:{width:160}}),(0,r.jsx)("input",{type:"text",className:"grow","aria-label":l("proj.entryDir"),value:w,onChange:e=>k(e.target.value),placeholder:"C:\\Projects\\my-app-tests",disabled:g}),(0,r.jsx)("button",{onClick:()=>void T(e=>k(e),w),disabled:g,children:l("mirror.browse")}),(0,r.jsx)("button",{className:"primary",onClick:()=>void I(),disabled:g||!b.trim()||!w.trim(),children:l("proj.otherAdd")})]}),(0,r.jsx)("h3",{children:l("proj.affects")}),(0,r.jsxs)("ul",{className:"muted small",style:{margin:0,paddingLeft:20},children:[(0,r.jsx)("li",{children:l("proj.affectsNew")}),(0,r.jsx)("li",{children:l("proj.affectsExisting")}),(0,r.jsx)("li",{children:l("proj.affectsPlan")}),(0,r.jsx)("li",{children:l("proj.affectsNever")})]})]})}function j(e){var l;let{name:t,dir:a,repoOk:s,repoProblem:n,mirror:i,isDefault:d=!1,busy:c,onName:u,onNameBlur:m,onDir:h,onDirBlur:x,onBrowse:p,onRemove:j,removeLabel:f,onFolders:g}=e,{t:y}=(0,o.kj)();return(0,r.jsxs)("div",{className:"panel inner",style:{marginTop:10},children:[(0,r.jsxs)("div",{className:"row",children:[(0,r.jsxs)("div",{style:{width:200},children:[(0,r.jsx)("label",{children:y("proj.entryName")}),(0,r.jsx)("input",{type:"text",value:t,onChange:e=>u(e.target.value),onBlur:m,placeholder:a?null!=(l=a.replace(/[\/]+$/,"").split(/[\/]/).pop())?l:"":y("proj.namePlaceholder"),disabled:c})]}),(0,r.jsxs)("div",{className:"grow",children:[(0,r.jsx)("label",{children:y("proj.entryDir")}),(0,r.jsx)("input",{type:"text",value:a,onChange:e=>h(e.target.value),onBlur:x,placeholder:"C:\\Projects\\my-app",disabled:c})]}),(0,r.jsx)("button",{onClick:p,disabled:c,children:y("mirror.browse")}),j&&(0,r.jsx)("button",{className:"quiet",onClick:j,disabled:c,children:f})]}),(0,r.jsxs)("div",{className:"row small",style:{marginTop:6},children:[d&&(0,r.jsx)("span",{className:"chip",title:y("proj.isDefaultWhy"),children:y("proj.isDefault")}),a&&(0,r.jsx)("span",{className:"badge ".concat(s?"done":""),title:s?y("proj.isRepo"):n,children:y(s?"proj.otherRepo":"proj.otherNotRepo")}),a&&!s&&(0,r.jsx)("span",{className:"muted",children:n||y("proj.notRepoWhy")})]}),a&&(0,r.jsxs)("details",{className:"small",style:{marginTop:8},children:[(0,r.jsx)("summary",{children:y("proj.folders")}),(0,r.jsx)(v,{rootDir:a,value:i,onSave:g,busy:c})]})]})}function v(e){var l,t,s,n;let{rootDir:i,value:c,onSave:m,busy:p}=e,{t:j}=(0,o.kj)(),[v,f]=(0,a.useState)((null!=(l=null==c?void 0:c.includeDirs)?l:[]).join("\n")),[g,y]=(0,a.useState)((null!=(t=null==c?void 0:c.excludeDirs)?t:[]).join("\n")),[b,N]=(0,a.useState)(null==(s=null==c?void 0:c.respectGitignore)||s),[w,k]=(0,a.useState)(null!=(n=null==c?void 0:c.includeEnvFiles)&&n),S=e=>e.split("\n").map(e=>e.trim()).filter(Boolean),[C,D]=(0,a.useState)(""),F=async e=>{let l={includeDirs:S(v),excludeDirs:S(g),respectGitignore:b,includeEnvFiles:w,...e};await m(l),D(j("proj.foldersSaved"))},M=h(F),R=async e=>{(!e||await (0,d.Z)(j("mirror.envWarn")))&&(k(e),F({includeEnvFiles:e}))};return(0,r.jsxs)("div",{style:{marginTop:8},children:[(0,r.jsx)("p",{className:"muted small",children:j("proj.foldersHint")}),(0,r.jsxs)("div",{className:"row",style:{alignItems:"flex-start"},children:[(0,r.jsxs)("div",{className:"grow",children:[(0,r.jsx)("label",{children:j("mirror.include")}),(0,r.jsx)("textarea",{value:v,onChange:e=>{f(e.target.value),M({includeDirs:S(e.target.value),excludeDirs:S(g)})},placeholder:"src\ntests",style:{minHeight:70}})]}),(0,r.jsxs)("div",{className:"grow",children:[(0,r.jsx)("label",{children:j("mirror.exclude")}),(0,r.jsx)("textarea",{value:g,onChange:e=>{y(e.target.value),M({includeDirs:S(v),excludeDirs:S(e.target.value)})},placeholder:"src/generated",style:{minHeight:70}})]})]}),(0,r.jsx)(u.k,{rootDir:i,respectGitignore:b,includeEnvFiles:w,include:S(v),exclude:S(g),onChange:(e,l)=>{f(e.join("\n")),y(l.join("\n")),M({includeDirs:e,excludeDirs:l})}}),(0,r.jsx)("div",{className:"option",children:(0,r.jsxs)("label",{children:[(0,r.jsx)("input",{type:"checkbox",checked:b,onChange:e=>{N(e.target.checked),F({respectGitignore:e.target.checked})}}),(0,r.jsx)("span",{children:j("mirror.gitignore")})]})}),(0,r.jsx)("div",{className:"option".concat(w?" warned":""),children:(0,r.jsxs)("label",{children:[(0,r.jsx)("input",{type:"checkbox",checked:w,onChange:e=>void R(e.target.checked)}),(0,r.jsx)("span",{children:j("mirror.env")})]})}),(0,r.jsx)(x,{msg:p?"":C})]})}function f(){let{t:e}=(0,o.kj)(),[l,t]=(0,a.useState)(null),[s,n]=(0,a.useState)(2),[d,c]=(0,a.useState)(60),[u,m]=(0,a.useState)(240),[p,j]=(0,a.useState)("none"),[v,f]=(0,a.useState)(2),[g,y]=(0,a.useState)(""),[b,N]=(0,a.useState)(""),[w,k]=(0,a.useState)(!1);(0,a.useEffect)(()=>{i.FH.settings().then(e=>{var l,r,a;t(e.raw);let s=null!=(l=e.raw.limits)?l:{},i="number"==typeof s.retryBlockedInFreshChat?s.retryBlockedInFreshChat:2;n(i),f(i),c("number"==typeof s.maxIterations?s.maxIterations:60),m("number"==typeof s.maxRunMinutes?s.maxRunMinutes:240),j(null!=(a=(null!=(r=e.raw.execution)?r:{}).isolation)?a:"none")}).catch(e=>N(e.message))},[]);let S=async r=>{if(l){k(!0),y("");try{var a;let s={...null!=(a=l.limits)?a:{},retryBlockedInFreshChat:r},n={...l,limits:s};await i.FH.saveSettings(n),t(n),f(r),y(e("exec.saved")),N("")}catch(e){N(e.message)}finally{k(!1)}}},C=h(S),D=async(r,a)=>{if(l){k(!0),y("");try{var s;let n={...null!=(s=l.limits)?s:{},[r]:a},o={...l,limits:n};await i.FH.saveSettings(o),t(o),y(e("exec.saved")),N("")}catch(e){N(e.message)}finally{k(!1)}}},F=h(e=>D("maxIterations",e)),M=h(e=>D("maxRunMinutes",e)),R=async r=>{if(l){k(!0),y("");try{var a;let s={...null!=(a=l.execution)?a:{},isolation:r},n={...l,execution:s};await i.FH.saveSettings(n),t(n),y(e("exec.saved")),N("")}catch(e){N(e.message)}finally{k(!1)}}};return(0,r.jsxs)("div",{className:"panel",id:"execution",children:[(0,r.jsx)("h2",{children:e("exec.title")}),(0,r.jsx)("p",{className:"muted small",children:e("exec.intro")}),b&&(0,r.jsx)("div",{className:"err",children:b}),(0,r.jsx)("label",{htmlFor:"retry-blocked",children:e("exec.retryBlocked")}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("input",{id:"retry-blocked",type:"number",min:0,max:5,value:s,onChange:e=>{let l=Math.max(0,Math.min(5,Number(e.target.value)||0));n(l),C(l)},onBlur:()=>s!==v&&void S(s),style:{width:90},disabled:w||!l}),(0,r.jsx)("span",{className:"muted small",children:e("exec.retryBlockedTimes")})]}),(0,r.jsx)("p",{className:"why",children:e("exec.retryBlockedWhy")}),(0,r.jsx)("label",{htmlFor:"max-iterations",children:e("exec.maxIterations")}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("input",{id:"max-iterations",type:"number",min:5,max:200,value:d,onChange:e=>{let l=Math.max(5,Math.min(200,Number(e.target.value)||5));c(l),F(l)},style:{width:90},disabled:w||!l}),(0,r.jsx)("span",{className:"muted small",children:e("exec.maxIterationsUnit")})]}),(0,r.jsx)("p",{className:"why",children:e("exec.maxIterationsWhy")}),(0,r.jsx)("label",{htmlFor:"max-minutes",children:e("exec.maxRunMinutes")}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("input",{id:"max-minutes",type:"number",min:10,max:1440,value:u,onChange:e=>{let l=Math.max(10,Math.min(1440,Number(e.target.value)||10));m(l),M(l)},style:{width:90},disabled:w||!l}),(0,r.jsx)("span",{className:"muted small",children:e("exec.maxRunMinutesUnit")})]}),(0,r.jsx)("p",{className:"why",children:e("exec.maxRunMinutesWhy")}),(0,r.jsx)("label",{htmlFor:"isolation",children:e("exec.isolation")}),(0,r.jsxs)("select",{id:"isolation",value:p,onChange:e=>{let l=e.target.value;j(l),R(l)},disabled:w||!l,children:[(0,r.jsx)("option",{value:"none",children:e("exec.isolationNone")}),(0,r.jsx)("option",{value:"none-accepted",children:e("exec.isolationNoneAccepted")}),(0,r.jsx)("option",{value:"separate-account",children:e("exec.isolationAccount")}),(0,r.jsx)("option",{value:"sandbox",children:e("exec.isolationSandbox")}),(0,r.jsx)("option",{value:"vm",children:e("exec.isolationVm")})]}),(0,r.jsx)(x,{msg:g}),(0,r.jsx)("p",{className:"why",children:e("exec.isolationWhy")})]})}function g(e){var l;let{catalogue:t,setCatalogue:s,refreshModels:n,refreshing:d,refreshMsg:u}=e,{t:m}=(0,o.kj)(),h=(0,o.W3)(),[p,j]=(0,a.useState)(""),[v,f]=(0,a.useState)(""),[g,y]=(0,a.useState)(!1),b=null!=(l=null==t?void 0:t.defaultModel)?l:"",N=async e=>{y(!0),j("");try{let l=await i.FH.setDefaultModel(e);t&&s({...t,defaultModel:l.defaultModel}),j(l.defaultModel?m("def.modelSaved",{name:l.defaultModel}):m("def.modelCleared")),f("")}catch(e){f(e.message)}finally{y(!1)}};return(0,r.jsxs)("div",{className:"panel",id:"model",children:[(0,r.jsx)("h2",{children:m("def.modelTitle")}),(0,r.jsx)("p",{className:"muted small",children:m("def.modelIntro")}),v&&(0,r.jsx)("div",{className:"err",children:v}),(0,r.jsx)("label",{htmlFor:"default-model",children:m("def.modelField")}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)(c.Y,{id:"default-model",chosen:b,onChange:e=>void N(e),none:m("def.modelNone"),catalogue:t,disabled:g||d}),(0,r.jsx)("button",{className:"quiet",onClick:()=>void N(""),disabled:g||!b,children:m("proj.clear")}),(0,r.jsx)("button",{onClick:()=>void n(),disabled:g||d,children:m("model.refresh")})]}),(0,r.jsx)(x,{msg:p||u}),(0,r.jsx)("p",{className:"muted small",style:{marginTop:8},children:(null==t?void 0:t.readAt)?m("model.readAt",{t:h(t.readAt),n:t.options.length}):m("model.neverRead")}),(0,r.jsx)("h3",{children:m("proj.affects")}),(0,r.jsxs)("ul",{className:"muted small",style:{margin:0,paddingLeft:20},children:[(0,r.jsx)("li",{children:m("def.modelAffectsNew")}),(0,r.jsx)("li",{children:m("def.modelAffectsExisting")}),(0,r.jsx)("li",{children:m("def.modelAffectsBatch")})]})]})}function y(e){var l,t;let{catalogue:s,setCatalogue:d,refreshModels:u,refreshing:m,refreshMsg:h}=e,{t:p}=(0,o.kj)(),[j,v]=(0,a.useState)(""),[f,g]=(0,a.useState)(""),[y,b]=(0,a.useState)(!1),N=null!=(l=null==s?void 0:s.defaultReviewModel)?l:"",w=async e=>{b(!0),v("");try{let l=await i.FH.setDefaultReviewModel(e);s&&d({...s,defaultReviewModel:l.defaultReviewModel}),v(l.defaultReviewModel?p("def.reviewSaved",{name:l.defaultReviewModel}):p("def.reviewCleared")),g("")}catch(e){g(e.message)}finally{b(!1)}},k=""!==N&&N===(null!=(t=null==s?void 0:s.defaultModel)?t:"");return(0,r.jsxs)("div",{className:"panel",id:"review",children:[(0,r.jsx)("h2",{children:p("def.reviewTitle")}),(0,r.jsx)("p",{className:"muted small",children:p("def.reviewIntro")}),f&&(0,r.jsx)("div",{className:"err",children:f}),(0,r.jsx)("label",{htmlFor:"default-review-model",children:p("def.reviewField")}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)(c.Y,{id:"default-review-model",chosen:N,onChange:e=>void w(e),none:p("def.reviewNone"),catalogue:s,disabled:y||m}),(0,r.jsx)("button",{className:"quiet",onClick:()=>void w(""),disabled:y||!N,children:p("proj.clear")}),(0,r.jsx)("button",{onClick:()=>void u(),disabled:y||m,children:p("model.refresh")})]}),k&&(0,r.jsx)("p",{className:"why",style:{color:"var(--warn)"},children:p("def.reviewSame")}),(0,r.jsx)(x,{msg:j||h}),(0,r.jsx)("h3",{children:p("proj.affects")}),(0,r.jsxs)("ul",{className:"muted small",style:{margin:0,paddingLeft:20},children:[(0,r.jsx)("li",{children:p("def.reviewAffectsNew")}),(0,r.jsx)("li",{children:p("def.reviewAffectsExisting")}),(0,r.jsx)("li",{children:p("def.reviewAffectsBatch")})]}),(0,r.jsxs)("div",{className:"row",style:{marginTop:12},children:[(0,r.jsx)(n(),{href:"/",children:(0,r.jsx)("button",{children:p("proj.toSessions")})}),(0,r.jsx)(n(),{href:"/import",children:(0,r.jsx)("button",{className:"quiet",children:p("proj.toImport")})})]})]})}},4784:(e,l,t)=>{"use strict";t.d(l,{Y:()=>i});var r=t(3365),a=t(1521),s=t(5549),n=t(867);function i(e){var l,t;let{id:i,chosen:o,onChange:d,none:c,catalogue:u,disabled:m=!1,style:h}=e,{t:x}=(0,n.kj)(),p=function(e){let[l,t]=(0,a.useState)(null);return(0,a.useEffect)(()=>{if(void 0!==e)return;let l=!0;return s.FH.models().then(e=>{l&&t(e)}).catch(()=>void 0),()=>{l=!1}},[e]),void 0!==e?e:l}(u),j=null!=(l=null==p?void 0:p.options)?l:[],v=j.some(e=>e.name===o),f=j.filter(e=>!e.group),g=new Map;for(let e of j)e.group&&g.set(e.group,[...null!=(t=g.get(e.group))?t:[],e]);return(0,r.jsxs)("select",{id:i,value:o,onChange:e=>d(e.target.value),disabled:m,style:{width:"auto",minWidth:280,...h},children:[(0,r.jsx)("option",{value:"",children:c}),o&&!v&&(0,r.jsx)("option",{value:o,children:x("model.notInList",{name:o})}),f.map(e=>(0,r.jsxs)("option",{value:e.name,disabled:e.disabled,children:[e.name,e.disabled?" — ".concat(x("model.unavailable")):""]},e.name)),[...g.entries()].map(e=>{let[l,t]=e;return(0,r.jsx)("optgroup",{label:l,children:t.map(e=>(0,r.jsxs)("option",{value:e.name,disabled:e.disabled,children:[e.name,e.disabled?" — ".concat(x("model.unavailable")):""]},e.name))},l)})]})}}},e=>{e.O(0,[197,867,549,347,131,358],()=>e(e.s=1896)),_N_E=e.O()}]);
@@ -1 +1 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[810],{3256:(e,s,t)=>{Promise.resolve().then(t.bind(t,4627))},4627:(e,s,t)=>{"use strict";t.r(s),t.d(s,{default:()=>b});var n=t(3365),a=t(1521),l=t(8197),r=t.n(l),i=t(5549),d=t(3523),c=t(3374),o=t(867),u=t(1910),h=t(5132);function m(){let{t:e}=(0,o.kj)(),[s,t]=(0,a.useState)(!1);return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("button",{type:"button",className:"info-dot","aria-expanded":s,"aria-label":e("row.info"),title:e("row.info"),onClick:()=>t(e=>!e),children:"i"}),s&&(0,n.jsxs)("div",{className:"notice info-panel",children:[(0,n.jsx)("strong",{children:e("row.infoTitle")}),(0,n.jsxs)("dl",{className:"small",children:[(0,n.jsx)("dt",{children:e("reg.openTask")}),(0,n.jsx)("dd",{children:e("row.infoOpenTask")}),(0,n.jsx)("dt",{children:e("save.log")}),(0,n.jsx)("dd",{children:e("save.why")}),(0,n.jsx)("dt",{children:e("home.col.chat")}),(0,n.jsx)("dd",{children:e("row.infoChat")})]}),(0,n.jsx)("div",{className:"small",style:{marginTop:6},children:e("row.infoExports")}),(0,n.jsxs)("dl",{className:"small",children:[(0,n.jsx)("dt",{children:e("reg.exportPlan")}),(0,n.jsx)("dd",{children:e("reg.exportPlanWhy")}),(0,n.jsx)("dt",{children:e("reg.exportDomain")}),(0,n.jsx)("dd",{children:e("reg.exportDomainWhy")}),(0,n.jsx)("dt",{children:e("reg.exportBot")}),(0,n.jsx)("dd",{children:e("reg.exportBotWhy")})]}),(0,n.jsx)(h.s,{text:e("row.infoWhich"),className:"small"})]})]})}function g(e){let{onChange:s}=e,{t}=(0,o.kj)(),[l,r]=(0,a.useState)(null),[d,c]=(0,a.useState)(!1),[u,h]=(0,a.useState)(""),m=(0,a.useCallback)(async()=>{try{r(await i.FH.batch())}catch(e){}},[]);(0,a.useEffect)(()=>{m();let e=setInterval(()=>void m(),3e3);return()=>clearInterval(e)},[m]);let g=async e=>{c(!0),h("");try{"pause"===e?await i.FH.pauseBatch():"resume"===e?await i.FH.resumeBatch():await i.FH.stopBatch(),await m(),null==s||s()}catch(e){h(e.message)}finally{c(!1)}};return(null==l?void 0:l.running)?(0,n.jsxs)("div",{className:"row",style:{marginBottom:8},children:[l.pausing?(0,n.jsx)("button",{className:"primary",disabled:d,onClick:()=>void g("resume"),title:t("batch.resumeWhy"),children:t("batch.resume")}):(0,n.jsx)("button",{disabled:d||l.stopping,onClick:()=>void g("pause"),title:t("batch.pauseWhy"),children:t("batch.pause")}),(0,n.jsx)("button",{className:"danger",disabled:d||l.stopping,onClick:()=>void g("stop"),title:t("batch.stopWhy"),children:t("batch.stop")}),l.pausing&&!l.stopping&&(0,n.jsx)("span",{className:"muted small",children:t("batch.pausing")}),l.stopping&&(0,n.jsx)("span",{className:"muted small",children:t("batch.stopping")}),u&&(0,n.jsx)("span",{className:"err small",children:u})]}):null}var x=t(3041),p=t(1035),j=t(7619);let v=["queued","running","waiting-approval"],N=["blocked","failed","aborted","limit-reached"];function k(e){let{run:s}=e,{t}=(0,o.kj)(),a=s.entries.some(d.DG),l=(0,c.c)(a),r=(0,d.eZ)(s,s.entries,l);return(0,n.jsx)(n.Fragment,{children:t(r.live?"reg.runRunning":"reg.runTook",{d:(0,i.c5)(r.ms)})})}function f(e){let s=new Map,t=[];for(let n of e){if(!n.runGroup){t.push(n);continue}let e=s.get(n.runGroup.id);e?e.entries.push(n):s.set(n.runGroup.id,{...n.runGroup,entries:[n]})}let n=[...s.values()].sort((e,s)=>Date.parse(s.startedAt)-Date.parse(e.startedAt));for(let e of n)e.entries.sort((e,s)=>{var t,n;return Date.parse(null!=(t=e.startedAt)?t:e.createdAt)-Date.parse(null!=(n=s.startedAt)?n:s.createdAt)});return{runs:n,loose:t}}function b(){let{t:e}=(0,o.kj)(),s=(0,o.W3)(),[t,l]=(0,a.useState)(null),[r,d]=(0,a.useState)(""),[c,u]=(0,a.useState)(""),[h,m]=(0,a.useState)("flow"),[x,p]=(0,a.useState)(""),[j,k]=(0,a.useState)(""),[b,y]=(0,a.useState)(""),S=(0,a.useCallback)(async()=>{try{l(await i.FH.tasks()),u(new Date().toISOString()),d("")}catch(e){d(e.message)}},[]);(0,a.useEffect)(()=>{S();let e=setInterval(()=>void S(),6e3);return()=>clearInterval(e)},[S]);let q=(0,a.useMemo)(()=>{let e=new Map;for(let s of null!=t?t:[])e.has(s.sessionId)||e.set(s.sessionId,s.sessionName);return[...e.entries()]},[t]),R=(0,a.useMemo)(()=>{let e=b.trim().toLowerCase();return(null!=t?t:[]).filter(s=>{var t,n;return(!x||s.sessionId===x)&&(!j||s.status===j)&&(!e||"".concat(s.title," ").concat(null!=(t=s.summary)?t:""," ").concat(null!=(n=s.reason)?n:""," ").concat(s.sessionName).toLowerCase().includes(e))})},[t,x,j,b]),W=(0,a.useMemo)(()=>{let e=null!=t?t:[];return{total:e.length,done:e.filter(e=>"done"===e.status).length,running:e.filter(e=>"running"===e.status||"waiting-approval"===e.status).length,open:e.filter(e=>"queued"===e.status).length,failed:e.filter(e=>N.includes(e.status)).length}},[t]),G=(0,a.useMemo)(()=>{let e=new Map;for(let n of null!=t?t:[]){var s;n.runGroup&&e.set(n.runGroup.id,(null!=(s=e.get(n.runGroup.id))?s:0)+1)}return e},[t]),P=(0,a.useMemo)(()=>f(R),[R]),H=R.filter(e=>"running"===e.status||"waiting-approval"===e.status),D=R.filter(e=>"queued"===e.status),E=[...R.filter(e=>N.includes(e.status)&&"stop"===e.sessionOnFailure&&!e.sessionRunning&&D.some(s=>s.sessionId===e.sessionId)),...D].sort((e,s)=>{var t,n;return(null!=(t=e.sessionRunOrder)?t:Number.MAX_SAFE_INTEGER)-(null!=(n=s.sessionRunOrder)?n:Number.MAX_SAFE_INTEGER)||e.position-s.position}),M=R.filter(e=>!v.includes(e.status)).sort((e,s)=>{var t,n,a,l;return Date.parse(null!=(n=null!=(t=s.finishedAt)?t:s.startedAt)?n:s.createdAt)-Date.parse(null!=(l=null!=(a=e.finishedAt)?a:e.startedAt)?l:e.createdAt)}),O=""!==x||""!==j||""!==b.trim();return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{className:"panel",children:[(0,n.jsxs)("div",{className:"row",children:[(0,n.jsx)("h2",{className:"grow",style:{margin:0},children:e("reg.title")}),(0,n.jsx)("span",{className:"muted small",children:c&&e("reg.updated",{t:s(c)})}),(0,n.jsx)("button",{className:"quiet",onClick:()=>void S(),children:e("reg.refresh")})]}),(0,n.jsx)("p",{className:"muted small",children:e("reg.hint")}),(0,n.jsx)(F,{sessions:q}),(0,n.jsxs)("div",{className:"counts",children:[(0,n.jsxs)("div",{className:"count",children:[(0,n.jsx)("div",{className:"n",children:W.total}),(0,n.jsx)("div",{className:"k",children:e("reg.total")})]}),(0,n.jsxs)("div",{className:"count done",children:[(0,n.jsx)("div",{className:"n",children:W.done}),(0,n.jsx)("div",{className:"k",children:e("reg.done")})]}),(0,n.jsxs)("div",{className:"count running",children:[(0,n.jsx)("div",{className:"n",children:W.running}),(0,n.jsx)("div",{className:"k",children:e("reg.runningCount")})]}),(0,n.jsxs)("div",{className:"count queued",children:[(0,n.jsx)("div",{className:"n",children:W.open}),(0,n.jsx)("div",{className:"k",children:e("reg.open")})]}),(0,n.jsxs)("div",{className:"count failed",children:[(0,n.jsx)("div",{className:"n",children:W.failed}),(0,n.jsx)("div",{className:"k",children:e("reg.failedCount")})]})]})]}),r&&(0,n.jsx)("div",{className:"panel err",children:r}),(0,n.jsxs)("div",{className:"panel",children:[(0,n.jsxs)("div",{className:"toolbar",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("label",{htmlFor:"f-session",style:{margin:0},children:e("reg.filterSession")}),(0,n.jsxs)("select",{id:"f-session",value:x,onChange:e=>p(e.target.value),children:[(0,n.jsx)("option",{value:"",children:e("reg.allSessions")}),q.map(e=>{let[s,t]=e;return(0,n.jsx)("option",{value:s,children:t},s)})]})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("label",{htmlFor:"f-status",style:{margin:0},children:e("reg.filterStatus")}),(0,n.jsxs)("select",{id:"f-status",value:j,onChange:e=>k(e.target.value),children:[(0,n.jsx)("option",{value:"",children:e("reg.allStatuses")}),["queued","running","waiting-approval","done","blocked","failed","aborted","limit-reached"].map(s=>(0,n.jsx)("option",{value:s,children:e("status.".concat(s))},s))]})]}),(0,n.jsxs)("div",{className:"grow",children:[(0,n.jsx)("label",{htmlFor:"f-q",style:{margin:0},children:e("reg.search")}),(0,n.jsx)("input",{id:"f-q",type:"text",value:b,onChange:e=>y(e.target.value),placeholder:e("reg.searchPlaceholder")})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("label",{style:{margin:0},id:"view-label",children:e("reg.viewLabel")}),(0,n.jsxs)("div",{className:"segmented",role:"group","aria-labelledby":"view-label",children:[(0,n.jsx)("button",{type:"button","aria-pressed":"flow"===h,onClick:()=>m("flow"),children:e("reg.viewFlow")}),(0,n.jsx)("button",{type:"button","aria-pressed":"runs"===h,onClick:()=>m("runs"),children:e("reg.groupBy")}),(0,n.jsx)("button",{type:"button","aria-pressed":"list"===h,onClick:()=>m("list"),children:e("reg.viewList")})]})]}),O&&(0,n.jsx)("button",{className:"quiet",onClick:()=>{p(""),k(""),y("")},children:e("reg.clear")})]}),null===t&&(0,n.jsx)("div",{className:"muted",children:e("home.loading")}),null!==t&&0===t.length&&(0,n.jsx)("div",{className:"empty",children:e("reg.none")}),null!==t&&t.length>0&&0===R.length&&(0,n.jsx)("div",{className:"empty",children:e("reg.noMatch")})]}),"list"===h&&R.length>0&&(0,n.jsx)(T,{entries:[...H,...D,...M]}),"runs"===h&&R.length>0&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{className:"panel",children:[(0,n.jsx)("h2",{children:e("reg.runGroup")}),(0,n.jsx)("p",{className:"muted small",children:e("reg.runGroupHint")})]}),P.runs.map(e=>(0,n.jsxs)("section",{className:"panel",children:[(0,n.jsx)(I,{run:e}),(0,n.jsx)(w,{entries:e.entries,sizes:G,onChange:()=>void S()})]},e.id)),P.loose.length>0&&(0,n.jsxs)("section",{className:"panel",children:[(0,n.jsx)("h2",{children:e("reg.notInARun")}),(0,n.jsx)("p",{className:"muted small",children:e("reg.notInARunHint")}),(0,n.jsx)(w,{entries:P.loose,sizes:G,onChange:()=>void S()})]})]}),"flow"===h&&(0,n.jsxs)(n.Fragment,{children:[H.length>0&&(0,n.jsxs)("section",{className:"panel",children:[(0,n.jsx)("h2",{children:e("reg.activeNow")}),(0,n.jsx)(w,{entries:H,sizes:G,onChange:()=>void S()})]}),R.length>0&&(0,n.jsxs)("section",{className:"panel",children:[(0,n.jsx)("h2",{children:e("reg.upcoming")}),(0,n.jsx)("p",{className:"muted small",children:e("reg.upcomingHint")}),(0,n.jsx)(g,{onChange:()=>void S()}),(0,n.jsx)(A,{entries:R,onChange:()=>void S()}),0===E.length?(0,n.jsx)("div",{className:"empty",children:e("reg.noUpcoming")}):(0,n.jsx)(w,{entries:E,upcoming:!0,sizes:G,onChange:()=>void S()})]}),R.length>0&&(0,n.jsxs)("section",{className:"panel",children:[(0,n.jsx)("h2",{children:e("reg.past")}),(0,n.jsx)("p",{className:"muted small",children:e("reg.pastHint")}),0===M.length?(0,n.jsx)("div",{className:"empty",children:e("reg.noPast")}):(0,n.jsx)(C,{entries:M,sizes:G,onChange:()=>void S()})]})]})]})}function w(e){let{entries:s,upcoming:t=!1,sizes:l,onChange:g,picking:p}=e,{t:v}=(0,o.kj)(),k=(0,o.W3)(),f=(0,x.e)(null!=g?g:()=>void 0),b=(0,c.c)(s.some(d.DG)),[w,I]=(0,a.useState)(null),[C,F]=(0,a.useState)(new Set);return(0,n.jsxs)(n.Fragment,{children:[w&&(0,n.jsx)(S,{entry:w,onClose:e=>{I(null),e&&(null==g||g())}}),(0,n.jsx)("ol",{className:"flow",children:s.map(e=>{var s,a,c,o,g,x,w,S,A,T,q,R,W,G,P,H,D,E,M,O,_,B;let L=t&&1===e.queuePosition,z=e.runGroup?null!=(w=null==l?void 0:l.get(e.runGroup.id))?w:1:0;return(0,n.jsxs)("li",{className:"".concat(e.status).concat(L?" next":""),children:[(0,n.jsxs)("div",{className:"head",children:[p&&(0,n.jsx)("input",{type:"checkbox",className:"pick","aria-label":e.title,checked:p.picked.has("".concat(e.sessionId,":").concat(e.taskId)),onChange:()=>p.toggle("".concat(e.sessionId,":").concat(e.taskId))}),(0,n.jsx)("strong",{children:e.title}),(0,n.jsx)("span",{className:"badge ".concat(e.status),children:v("status.".concat(e.status))}),L&&(0,n.jsx)("span",{className:"chip",children:v("reg.next")}),t&&N.includes(e.status)&&(0,n.jsx)("span",{className:"chip",title:v("reg.willRequeueFirstWhy"),children:v("reg.willRequeueFirst")}),e.sessionRunning&&(0,n.jsx)("span",{className:"chip",children:v("reg.sessionRunning")}),e.review&&"skipped"!==e.review.verdict&&(0,n.jsxs)("span",{className:"badge ".concat("pass"===e.review.verdict?"done":"fail"===e.review.verdict?"blocked":"waiting-approval"),title:e.review.stepsRun>0?v("review.ran",{n:e.review.stepsRun}):void 0,children:[v("review.verdict.".concat(e.review.verdict)),e.review.findings>0?" (".concat(e.review.findings,")"):""]}),(null!=(S=e.deviations)?S:0)>0&&(0,n.jsx)("span",{className:"badge waiting-approval",title:v("reg.deviationsWhy"),children:v("reg.deviations",{n:null!=(A=e.deviations)?A:0})}),(null!=(T=e.disputes)?T:0)>0&&(0,n.jsx)("span",{className:"badge waiting-approval",title:v("reg.disputesWhy"),children:v("reg.disputes",{n:null!=(q=e.disputes)?q:0})}),e.readOnly&&(0,n.jsx)("span",{className:"chip",title:v("reg.readOnlyWhy"),children:v("task.readOnly")}),(null!=(R=e.autoRetries)?R:0)>0&&(0,n.jsx)("span",{className:"badge ".concat("done"===e.status?"done":"blocked"),title:v("reg.retriedFreshWhy"),children:"done"===e.status?v("reg.retriedFreshDone",{n:null!=(W=e.autoRetries)?W:0}):v("reg.retriedFreshStill",{n:null!=(G=e.autoRetries)?G:0})}),e.runGroup&&(0,n.jsx)("span",{className:"chip",title:v("reg.runTitle",{t:z,s:e.runGroup.sessions,when:k(e.runGroup.startedAt)}),children:z>1?v("reg.runWith",{n:z-1}):v("reg.runAlone")})]}),(0,n.jsxs)("div",{className:"when",children:[(0,n.jsx)(r(),{href:(0,i.aT)(e.sessionId),children:e.sessionName})," \xb7 ",e.startedAt?v("task.started",{t:k(e.startedAt)}):v("task.added",{t:k(e.createdAt)}),e.finishedAt?" \xb7 ".concat(v("task.finished",{t:k(e.finishedAt)})):"",void 0!==e.durationMs?" \xb7 ".concat(v("reg.took",{d:(0,i.c5)(e.durationMs)})):"",(0,d.DG)(e)?" \xb7 ".concat(v("task.runningFor",{d:(0,i.c5)((0,d.d5)(e.startedAt,void 0,b))})):"",e.iterations>0?" \xb7 ".concat(v("reg.iterations",{n:e.iterations})):""]}),"queued"===e.status&&(0,n.jsx)("div",{className:"when",children:e.queuePosition&&e.queuePosition>1?v("reg.willFollow",{n:e.queuePosition-1}):e.sessionRunning?v("reg.queuePos",{n:null!=(P=e.queuePosition)?P:1}):v("reg.waitingRun")}),"blocked"===e.status&&(0,n.jsx)("p",{className:"what muted small",children:v("reg.blockedWhat")}),(null!=(H=null==(s=e.attempts)?void 0:s.length)?H:0)>0&&(0,n.jsxs)("details",{className:"small",style:{marginTop:6},children:[(0,n.jsx)("summary",{children:(null!=(D=null==(a=e.attempts)?void 0:a.length)?D:0)===1?v("reg.attemptsOne",{n:null!=(M=e.attempt)?M:(null!=(E=null==(c=e.attempts)?void 0:c.length)?E:0)+1}):v("reg.attempts",{n:null!=(_=e.attempt)?_:(null!=(O=null==(o=e.attempts)?void 0:o.length)?O:0)+1,m:null!=(B=null==(g=e.attempts)?void 0:g.length)?B:0})}),(0,n.jsx)("ol",{className:"attempts",children:null==(x=e.attempts)?void 0:x.map(s=>{var t;return(0,n.jsxs)("li",{children:[(0,n.jsxs)("div",{className:"head",children:[(0,n.jsx)("strong",{children:v("reg.attemptN",{n:s.attempt})}),(0,n.jsx)("span",{className:"badge ".concat(s.status),children:v("status.".concat(s.status))}),s.iterations>0&&(0,n.jsx)("span",{className:"muted",children:v("reg.iterations",{n:s.iterations})}),void 0!==s.durationMs&&(0,n.jsx)("span",{className:"muted",children:v("reg.took",{d:(0,i.c5)(s.durationMs)})}),s.runId&&(0,n.jsx)(u.u,{label:v("save.attemptLog"),save:()=>i.FH.saveTaskLog(e.sessionId,e.taskId,s.runId)})]}),(0,n.jsxs)("div",{className:"when",children:[s.startedAt?v("task.started",{t:k(s.startedAt)}):"",s.finishedAt?" \xb7 ".concat(v("task.finished",{t:k(s.finishedAt)})):"",s.branch?" \xb7 ".concat(s.branch):""]}),s.reason&&(0,n.jsx)("p",{className:"what err",children:v("reg.stopped",{reason:s.reason})}),s.summary&&(0,n.jsx)(h.s,{text:s.summary,className:"what"})]},"".concat(null!=(t=s.runId)?t:s.attempt))})})]}),e.summary&&(0,n.jsx)(h.s,{text:e.summary,className:"what"}),e.reason&&(0,n.jsx)("p",{className:"what err",children:v("reg.stopped",{reason:e.reason})}),f.message&&(0,n.jsx)("p",{className:"what small",children:f.message}),(0,n.jsxs)("div",{className:"row small",style:{marginTop:6},children:[(0,n.jsx)(r(),{href:(0,i.aT)(e.sessionId,e.taskId),children:v("reg.openTask")}),e.runId&&(0,n.jsx)(u.u,{label:v("save.log"),save:()=>i.FH.saveTaskLog(e.sessionId,e.taskId)}),e.chatUrl&&(0,n.jsx)("a",{href:e.chatUrl,target:"_blank",rel:"noreferrer",children:v("home.col.chat")}),e.startedAt&&(0,n.jsx)(y,{where:{session:e.sessionId,task:e.taskId}}),(0,n.jsx)(m,{}),e.runId&&(0,n.jsxs)("button",{className:C.has(e.taskId)?"":"quiet",onClick:()=>{let s;return s=e.taskId,F(e=>{let t=new Set(e);return t.has(s)?t.delete(s):t.add(s),t})},title:(0,d.DG)(e)?v("story.showLiveWhy"):v("story.why"),children:[(0,d.DG)(e)&&!C.has(e.taskId)&&(0,n.jsx)("span",{className:"dot","aria-hidden":"true"}),C.has(e.taskId)?v("story.hide"):(0,d.DG)(e)?v("story.showLive"):v("story.show")]}),N.includes(e.status)&&!e.sessionRunning&&(0,n.jsx)("button",{className:"quiet",onClick:()=>I(e),title:v("reg.fixPromptHint"),children:v("reg.fixPrompt")}),e.startedAt&&!e.sessionRunning&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("button",{className:"quiet",disabled:""!==f.busy,title:v("restore.why"),onClick:()=>void f.restore({sessionId:e.sessionId,taskId:e.taskId,title:e.title}),children:"restore"===f.busy?v("restore.checking"):v("restore.button")}),(0,n.jsx)("button",{className:"quiet",disabled:""!==f.busy,title:v("restart.why"),onClick:()=>void f.restartFrom({sessionId:e.sessionId,taskId:e.taskId,title:e.title}),children:"restart"===f.busy?v("restart.checking"):v("restart.button")})]})]}),C.has(e.taskId)&&e.runId&&(0,n.jsx)(j.P,{sessionId:e.sessionId,taskId:e.taskId,live:"running"===e.status||"waiting-approval"===e.status})]},"".concat(e.sessionId,"-").concat(e.taskId))})})]})}function y(e){let{where:s}=e,{t}=(0,o.kj)();return(0,n.jsxs)("span",{className:"exports",title:t("reg.exportTitle"),children:[(0,n.jsxs)("span",{className:"muted",children:[t("reg.exportTitle"),":"]})," ",(0,n.jsx)("a",{href:i.FH.exportUrl("plan",s),title:t("reg.exportPlanWhy"),children:t("reg.exportPlan")})," \xb7 ",(0,n.jsx)("a",{href:i.FH.exportUrl("domain",s),title:t("reg.exportDomainWhy"),children:t("reg.exportDomain")})," \xb7 ",(0,n.jsx)("a",{href:i.FH.exportUrl("bot",s),title:t("reg.exportBotWhy"),children:t("reg.exportBot")})]})}function I(e){var s;let{run:t}=e,{t:a}=(0,o.kj)(),l=(0,o.W3)(),r=null!=(s=t.entries.map(e=>{var s;return null==(s=e.runGroup)?void 0:s.name}).find(Boolean))?s:a("reg.runUnnamed"),i=t.entries.filter(e=>"done"===e.status).length,d=t.entries.filter(e=>N.includes(e.status)).length;return(0,n.jsxs)("div",{className:"run-heading",children:[(0,n.jsxs)("div",{className:"row",children:[(0,n.jsx)("h2",{className:"grow",style:{margin:0},children:r}),(0,n.jsxs)("span",{className:"muted small",children:[a("reg.runOf",{t:t.entries.length,s:t.sessions})," \xb7 ",a("reg.runAt",{when:l(t.startedAt)})," \xb7 ",(0,n.jsx)(k,{run:t})]})]}),(0,n.jsxs)("div",{className:"row small",style:{marginTop:4},children:[(0,n.jsx)("span",{className:"badge ".concat(d>0?"failed":i===t.entries.length?"done":""),children:a("reg.runCounts",{done:i,failed:d})}),(0,n.jsx)(y,{where:{run:t.id}})]})]})}function C(e){let{entries:s,sizes:t,onChange:l}=e,{t:r}=(0,o.kj)(),d=(0,a.useMemo)(()=>f(s),[s]),[c,u]=(0,a.useState)(!1),[h,m]=(0,a.useState)(new Set),[g,x]=(0,a.useState)(!1),[p,j]=(0,a.useState)(""),[v,N]=(0,a.useState)(""),k=e=>"".concat(e.sessionId,":").concat(e.taskId),b=s.filter(e=>e.startedAt),y=[...h],C=async()=>{x(!0),N(""),j("");try{let e=await i.FH.downloadBundle(y.map(e=>{let[s,t]=e.split(":");return{sessionId:s,taskId:t}}));j(r("reg.bundleSaved",{name:e}))}catch(e){N(e.message)}finally{x(!1)}},S=c?{picked:h,toggle:e=>m(s=>{let t=new Set(s);return t.has(e)?t.delete(e):t.add(e),t})}:void 0;return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{className:"row small",style:{marginBottom:8},children:[c?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("button",{className:"quiet",onClick:()=>{u(!1),m(new Set),j(""),N("")},children:r("reg.pickDone")}),(0,n.jsx)("button",{className:"quiet",onClick:()=>m(new Set(b.map(k))),children:r("reg.pickAll")}),(0,n.jsx)("button",{className:"quiet",onClick:()=>m(new Set),children:r("reg.pickNone")}),(0,n.jsx)("span",{className:"muted",children:h.size>0?r("reg.pickedN",{n:h.size}):r("reg.pickedNone")}),h.size>0&&(0,n.jsx)("button",{className:"primary",disabled:g,onClick:()=>void C(),title:r("reg.bundleWhy"),children:r("reg.bundle",{n:h.size})})]}):(0,n.jsx)("button",{className:"quiet",onClick:()=>u(!0),title:r("reg.pickWhy"),children:r("reg.pick")}),p&&(0,n.jsx)("span",{className:"muted",children:p}),v&&(0,n.jsx)("span",{className:"err",children:v})]}),d.runs.map((e,s)=>(0,n.jsxs)("details",{className:"run-fold",open:0===s||c,children:[(0,n.jsx)("summary",{children:(0,n.jsx)(I,{run:e})}),(0,n.jsx)(w,{entries:e.entries,sizes:t,onChange:l,picking:S})]},e.id)),d.loose.length>0&&(0,n.jsxs)("details",{className:"run-fold",open:0===d.runs.length||c,children:[(0,n.jsx)("summary",{children:(0,n.jsxs)("div",{className:"run-heading",children:[(0,n.jsx)("h2",{style:{margin:0},children:r("reg.notInARun")}),(0,n.jsx)("p",{className:"muted small",style:{margin:"4px 0 0"},children:r("reg.notInARunHint")})]})}),(0,n.jsx)(w,{entries:d.loose,sizes:t,onChange:l,picking:S})]})]})}function S(e){let{entry:s,onClose:t}=e,{t:l}=(0,o.kj)(),[r,d]=(0,a.useState)(null),[c,u]=(0,a.useState)(""),[h,m]=(0,a.useState)(!1);(0,a.useEffect)(()=>{let e=!0;return i.FH.session(s.sessionId).then(t=>{var n;let a=t.tasks.find(e=>e.id===s.taskId);e&&d(null!=(n=null==a?void 0:a.prompt)?n:"")}).catch(s=>{e&&u(s.message)}),()=>{e=!1}},[s.sessionId,s.taskId]);let g=async()=>{if(null!==r){m(!0),u("");try{await i.FH.rerunTask(s.sessionId,s.taskId,{prompt:r}),u(l("reg.fixPromptSaved",{title:s.title})),setTimeout(()=>t(!0),900)}catch(e){u(e.message),m(!1)}}};return(0,n.jsx)("div",{className:"modal-backdrop",role:"presentation",onClick:()=>t(!1),children:(0,n.jsxs)("div",{className:"modal wide",role:"dialog","aria-modal":"true","aria-labelledby":"fix-title",onClick:e=>e.stopPropagation(),children:[(0,n.jsx)("h2",{id:"fix-title",children:l("reg.fixPromptTitle",{title:s.title})}),(0,n.jsx)("p",{className:"muted small",children:l("reg.fixPromptHint")}),s.reason&&(0,n.jsx)("p",{className:"what err small",children:l("reg.stopped",{reason:s.reason})}),null===r?(0,n.jsx)("p",{className:"muted small",children:c||l("reg.fixPromptLoading")}):(0,n.jsx)("textarea",{className:"prose",value:r,onChange:e=>d(e.target.value),style:{minHeight:260},disabled:h}),(0,n.jsxs)("div",{className:"row modal-actions",children:[c&&null!==r&&(0,n.jsx)("span",{className:"small grow",children:c}),(0,n.jsx)("button",{type:"button",className:"quiet",onClick:()=>t(!1),disabled:h,children:l("dialog.cancel")}),(0,n.jsx)("button",{type:"button",className:"primary",onClick:()=>void g(),disabled:h||null===r||!r.trim(),children:l("reg.fixPromptSave")})]})]})})}function F(e){let{sessions:s}=e,{t}=(0,o.kj)();return(0,n.jsxs)("div",{className:"row",style:{margin:"14px 0 18px"},children:[(0,n.jsx)(r(),{href:"/#new-session",children:(0,n.jsx)("button",{className:"primary",children:t("reg.newSession")})}),s.length>0&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("label",{htmlFor:"new-task-session",style:{margin:0},children:[t("reg.newTask")," ",t("reg.newTaskIn")]}),(0,n.jsxs)("select",{id:"new-task-session",value:"",onChange:e=>{e.target.value&&(window.location.href=(0,i.aT)(e.target.value,"new-task"))},style:{width:"auto",minWidth:200},children:[(0,n.jsx)("option",{value:"",children:t("reg.newTaskPick")}),s.map(e=>{let[s,t]=e;return(0,n.jsx)("option",{value:s,children:t},s)})]})]})]})}function A(e){let{entries:s,onChange:t}=e,{t:l}=(0,o.kj)(),[r,d]=(0,a.useState)(!1),[c,u]=(0,a.useState)(""),[h,m]=(0,a.useState)(!1),[g,x]=(0,a.useState)(new Set),[j,v]=(0,a.useState)(null),k=s.filter(e=>"queued"===e.status),f=s.filter(e=>N.includes(e.status)&&!e.sessionRunning),b=s.some(e=>e.sessionRunning),w=f.filter(e=>"stop"===e.sessionOnFailure),y=f.filter(e=>"stop"!==e.sessionOnFailure),I=[...w,...y.filter(e=>g.has(e.taskId))],C=[...new Set([...k,...I].sort((e,s)=>{var t,n;return(null!=(t=e.sessionRunOrder)?t:Number.MAX_SAFE_INTEGER)-(null!=(n=s.sessionRunOrder)?n:Number.MAX_SAFE_INTEGER)||e.position-s.position}).map(e=>e.sessionId))],[F,A]=(0,a.useState)(""),T=w.length>0?l("reg.continueWithFailed",{f:w.length,n:k.length,s:C.length}):l("reg.continue",{n:k.length,s:C.length}),q=async e=>{if("unattended"!==e||await (0,p.Z)(l("batch.unattendedConfirm",{n:C.length}))){d(!0),u("");try{var s;for(let e of I)await i.FH.rerunTask(e.sessionId,e.taskId);let n=await i.FH.startBatch(C,e,"stop",void 0,void 0,F.trim()||void 0);u(n.started?l("reg.continueStarted",{n:C.length}):l("batch.notStarted",{reason:null!=(s=n.reason)?s:""})),m(!1),t()}catch(e){u(e.message)}finally{d(!1)}}};return 0===k.length&&0===f.length?null:(0,n.jsxs)("div",{style:{marginBottom:8},children:[(0,n.jsxs)("div",{className:"row",children:[(0,n.jsx)("button",{className:"primary",disabled:r||b,onClick:()=>{x(new Set(y.map(e=>e.taskId))),m(!0),u(""),i.FH.suggestedRunName(C).then(e=>A(e.name)).catch(()=>void 0)},title:l("reg.continueWhy"),children:T}),b&&(0,n.jsx)("span",{className:"muted small",children:l("reg.continueRunning")}),c&&(0,n.jsx)("span",{className:"small",children:c})]}),h&&!b&&(0,n.jsxs)("div",{className:"notice",style:{marginTop:8},children:[(0,n.jsx)("strong",{children:l("reg.continuePanelTitle")}),w.length>0&&(0,n.jsxs)("div",{style:{marginTop:6},children:[(0,n.jsx)("div",{className:"small",children:l("reg.continueChain")}),(0,n.jsx)("ul",{className:"small",style:{margin:"4px 0",paddingLeft:18},children:w.map(e=>(0,n.jsxs)("li",{children:[(0,n.jsx)("strong",{children:e.title})," \xb7 ",e.sessionName," \xb7 ",(0,n.jsx)("span",{className:"badge ".concat(e.status),children:l("status.".concat(e.status))})," ",(0,n.jsx)("button",{className:"quiet small",onClick:()=>v(e),children:l("reg.fixPrompt")})]},e.taskId))})]}),y.length>0&&(0,n.jsxs)("div",{style:{marginTop:6},children:[(0,n.jsx)("div",{className:"small",children:l("reg.continueIndependent")}),(0,n.jsx)("ul",{className:"small",style:{margin:"4px 0",paddingLeft:18,listStyle:"none"},children:y.map(e=>(0,n.jsx)("li",{children:(0,n.jsxs)("label",{className:"option-inline",children:[(0,n.jsx)("input",{type:"checkbox",checked:g.has(e.taskId),onChange:s=>x(t=>{let n=new Set(t);return s.target.checked?n.add(e.taskId):n.delete(e.taskId),n})}),(0,n.jsx)("strong",{children:e.title})," \xb7 ",e.sessionName," \xb7 ",(0,n.jsx)("span",{className:"badge ".concat(e.status),children:l("status.".concat(e.status))})]})},e.taskId))})]}),(0,n.jsxs)("div",{style:{marginTop:8},children:[(0,n.jsx)("label",{htmlFor:"continue-run-name",children:l("batch.runName")}),(0,n.jsx)("input",{id:"continue-run-name",type:"text",value:F,onChange:e=>A(e.target.value),placeholder:l("batch.runNamePlaceholder"),disabled:r}),(0,n.jsx)("p",{className:"why",children:l("reg.continueNameWhy")})]}),(0,n.jsx)("div",{className:"small",style:{marginTop:6},children:l("reg.continueSummary",{q:k.length,r:I.length,s:C.length})}),(0,n.jsxs)("div",{className:"row",style:{marginTop:8},children:[(0,n.jsx)("button",{className:"primary",disabled:r||0===C.length,onClick:()=>void q("unattended"),title:l("reg.continueUnattendedWhy"),children:l("reg.continueUnattended")}),(0,n.jsx)("button",{disabled:r||0===C.length,onClick:()=>void q("confirm"),title:l("reg.continueWhy"),children:l("reg.continueGo")}),(0,n.jsx)("button",{className:"quiet",disabled:r,onClick:()=>m(!1),children:l("dialog.cancel")})]})]}),j&&(0,n.jsx)(S,{entry:j,onClose:e=>{v(null),e&&t()}})]})}function T(e){let{entries:s}=e,{t}=(0,o.kj)(),a=(0,o.W3)();return(0,n.jsx)("div",{className:"panel",children:(0,n.jsxs)("table",{children:[(0,n.jsx)("thead",{children:(0,n.jsxs)("tr",{children:[(0,n.jsx)("th",{children:t("reg.col.task")}),(0,n.jsx)("th",{children:t("reg.col.session")}),(0,n.jsx)("th",{children:t("reg.col.status")}),(0,n.jsx)("th",{children:t("reg.col.started")}),(0,n.jsx)("th",{children:t("reg.col.took")}),(0,n.jsx)("th",{children:t("reg.col.result")})]})}),(0,n.jsx)("tbody",{children:s.map(e=>{var s;return(0,n.jsxs)("tr",{children:[(0,n.jsx)("td",{children:(0,n.jsx)(r(),{href:(0,i.aT)(e.sessionId,e.taskId),children:e.title})}),(0,n.jsx)("td",{children:(0,n.jsx)(r(),{href:(0,i.aT)(e.sessionId),children:e.sessionName})}),(0,n.jsx)("td",{children:(0,n.jsx)("span",{className:"badge ".concat(e.status),children:t("status.".concat(e.status))})}),(0,n.jsx)("td",{className:"muted small",children:e.startedAt?a(e.startedAt):"—"}),(0,n.jsx)("td",{className:"muted small",children:(0,i.c5)(e.durationMs)||"—"}),(0,n.jsx)("td",{className:"small",children:null!=(s=e.summary)?s:e.reason?(0,n.jsx)("span",{className:"err",children:e.reason}):"—"})]},"".concat(e.sessionId,"-").concat(e.taskId))})})]})})}}},e=>{e.O(0,[197,867,643,955,347,131,358],()=>e(e.s=3256)),_N_E=e.O()}]);
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[810],{3256:(e,s,t)=>{Promise.resolve().then(t.bind(t,4627))},4627:(e,s,t)=>{"use strict";t.r(s),t.d(s,{default:()=>b});var n=t(3365),a=t(1521),l=t(8197),r=t.n(l),i=t(5549),d=t(3523),c=t(3374),o=t(867),u=t(1910),h=t(5132);function m(){let{t:e}=(0,o.kj)(),[s,t]=(0,a.useState)(!1);return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("button",{type:"button",className:"info-dot","aria-expanded":s,"aria-label":e("row.info"),title:e("row.info"),onClick:()=>t(e=>!e),children:"i"}),s&&(0,n.jsxs)("div",{className:"notice info-panel",children:[(0,n.jsx)("strong",{children:e("row.infoTitle")}),(0,n.jsxs)("dl",{className:"small",children:[(0,n.jsx)("dt",{children:e("reg.openTask")}),(0,n.jsx)("dd",{children:e("row.infoOpenTask")}),(0,n.jsx)("dt",{children:e("save.log")}),(0,n.jsx)("dd",{children:e("save.why")}),(0,n.jsx)("dt",{children:e("home.col.chat")}),(0,n.jsx)("dd",{children:e("row.infoChat")})]}),(0,n.jsx)("div",{className:"small",style:{marginTop:6},children:e("row.infoExports")}),(0,n.jsxs)("dl",{className:"small",children:[(0,n.jsx)("dt",{children:e("reg.exportPlan")}),(0,n.jsx)("dd",{children:e("reg.exportPlanWhy")}),(0,n.jsx)("dt",{children:e("reg.exportDomain")}),(0,n.jsx)("dd",{children:e("reg.exportDomainWhy")}),(0,n.jsx)("dt",{children:e("reg.exportBot")}),(0,n.jsx)("dd",{children:e("reg.exportBotWhy")})]}),(0,n.jsx)(h.s,{text:e("row.infoWhich"),className:"small"})]})]})}function g(e){let{onChange:s}=e,{t}=(0,o.kj)(),[l,r]=(0,a.useState)(null),[d,c]=(0,a.useState)(!1),[u,h]=(0,a.useState)(""),m=(0,a.useCallback)(async()=>{try{r(await i.FH.batch())}catch(e){}},[]);(0,a.useEffect)(()=>{m();let e=setInterval(()=>void m(),3e3);return()=>clearInterval(e)},[m]);let g=async e=>{c(!0),h("");try{"pause"===e?await i.FH.pauseBatch():"resume"===e?await i.FH.resumeBatch():await i.FH.stopBatch(),await m(),null==s||s()}catch(e){h(e.message)}finally{c(!1)}};return(null==l?void 0:l.running)?(0,n.jsxs)("div",{className:"row",style:{marginBottom:8},children:[l.pausing?(0,n.jsx)("button",{className:"primary",disabled:d,onClick:()=>void g("resume"),title:t("batch.resumeWhy"),children:t("batch.resume")}):(0,n.jsx)("button",{disabled:d||l.stopping,onClick:()=>void g("pause"),title:t("batch.pauseWhy"),children:t("batch.pause")}),(0,n.jsx)("button",{className:"danger",disabled:d||l.stopping,onClick:()=>void g("stop"),title:t("batch.stopWhy"),children:t("batch.stop")}),l.pausing&&!l.stopping&&(0,n.jsx)("span",{className:"muted small",children:t("batch.pausing")}),l.stopping&&(0,n.jsx)("span",{className:"muted small",children:t("batch.stopping")}),u&&(0,n.jsx)("span",{className:"err small",children:u})]}):null}var x=t(3041),p=t(1035),j=t(7619);let v=["queued","running","waiting-approval"],N=["blocked","failed","aborted","limit-reached"];function k(e){let{run:s}=e,{t}=(0,o.kj)(),a=s.entries.some(d.DG),l=(0,c.c)(a),r=(0,d.eZ)(s,s.entries,l);return(0,n.jsx)(n.Fragment,{children:t(r.live?"reg.runRunning":"reg.runTook",{d:(0,i.c5)(r.ms)})})}function f(e){let s=new Map,t=[];for(let n of e){if(!n.runGroup){t.push(n);continue}let e=s.get(n.runGroup.id);e?e.entries.push(n):s.set(n.runGroup.id,{...n.runGroup,entries:[n]})}let n=[...s.values()].sort((e,s)=>Date.parse(s.startedAt)-Date.parse(e.startedAt));for(let e of n)e.entries.sort((e,s)=>{var t,n;return Date.parse(null!=(t=e.startedAt)?t:e.createdAt)-Date.parse(null!=(n=s.startedAt)?n:s.createdAt)});return{runs:n,loose:t}}function b(){let{t:e}=(0,o.kj)(),s=(0,o.W3)(),[t,l]=(0,a.useState)(null),[r,d]=(0,a.useState)(""),[c,u]=(0,a.useState)(""),[h,m]=(0,a.useState)("flow"),[x,p]=(0,a.useState)(""),[j,k]=(0,a.useState)(""),[b,y]=(0,a.useState)(""),S=(0,a.useCallback)(async()=>{try{l(await i.FH.tasks()),u(new Date().toISOString()),d("")}catch(e){d(e.message)}},[]);(0,a.useEffect)(()=>{S();let e=setInterval(()=>void S(),6e3);return()=>clearInterval(e)},[S]);let q=(0,a.useMemo)(()=>{let e=new Map;for(let s of null!=t?t:[])e.has(s.sessionId)||e.set(s.sessionId,s.sessionName);return[...e.entries()]},[t]),R=(0,a.useMemo)(()=>{let e=b.trim().toLowerCase();return(null!=t?t:[]).filter(s=>{var t,n;return(!x||s.sessionId===x)&&(!j||s.status===j)&&(!e||"".concat(s.title," ").concat(null!=(t=s.summary)?t:""," ").concat(null!=(n=s.reason)?n:""," ").concat(s.sessionName).toLowerCase().includes(e))})},[t,x,j,b]),W=(0,a.useMemo)(()=>{let e=null!=t?t:[];return{total:e.length,done:e.filter(e=>"done"===e.status).length,running:e.filter(e=>"running"===e.status||"waiting-approval"===e.status).length,open:e.filter(e=>"queued"===e.status).length,failed:e.filter(e=>N.includes(e.status)).length}},[t]),G=(0,a.useMemo)(()=>{let e=new Map;for(let n of null!=t?t:[]){var s;n.runGroup&&e.set(n.runGroup.id,(null!=(s=e.get(n.runGroup.id))?s:0)+1)}return e},[t]),P=(0,a.useMemo)(()=>f(R),[R]),H=R.filter(e=>"running"===e.status||"waiting-approval"===e.status),D=R.filter(e=>"queued"===e.status),E=[...R.filter(e=>N.includes(e.status)&&"stop"===e.sessionOnFailure&&!e.sessionRunning&&D.some(s=>s.sessionId===e.sessionId)),...D].sort((e,s)=>{var t,n;return(null!=(t=e.sessionRunOrder)?t:Number.MAX_SAFE_INTEGER)-(null!=(n=s.sessionRunOrder)?n:Number.MAX_SAFE_INTEGER)||e.position-s.position}),M=R.filter(e=>!v.includes(e.status)).sort((e,s)=>{var t,n,a,l;return Date.parse(null!=(n=null!=(t=s.finishedAt)?t:s.startedAt)?n:s.createdAt)-Date.parse(null!=(l=null!=(a=e.finishedAt)?a:e.startedAt)?l:e.createdAt)}),O=""!==x||""!==j||""!==b.trim();return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{className:"panel",children:[(0,n.jsxs)("div",{className:"row",children:[(0,n.jsx)("h2",{className:"grow",style:{margin:0},children:e("reg.title")}),(0,n.jsx)("span",{className:"muted small",children:c&&e("reg.updated",{t:s(c)})}),(0,n.jsx)("button",{className:"quiet",onClick:()=>void S(),children:e("reg.refresh")})]}),(0,n.jsx)("p",{className:"muted small",children:e("reg.hint")}),(0,n.jsx)(F,{sessions:q}),(0,n.jsxs)("div",{className:"counts",children:[(0,n.jsxs)("div",{className:"count",children:[(0,n.jsx)("div",{className:"n",children:W.total}),(0,n.jsx)("div",{className:"k",children:e("reg.total")})]}),(0,n.jsxs)("div",{className:"count done",children:[(0,n.jsx)("div",{className:"n",children:W.done}),(0,n.jsx)("div",{className:"k",children:e("reg.done")})]}),(0,n.jsxs)("div",{className:"count running",children:[(0,n.jsx)("div",{className:"n",children:W.running}),(0,n.jsx)("div",{className:"k",children:e("reg.runningCount")})]}),(0,n.jsxs)("div",{className:"count queued",children:[(0,n.jsx)("div",{className:"n",children:W.open}),(0,n.jsx)("div",{className:"k",children:e("reg.open")})]}),(0,n.jsxs)("div",{className:"count failed",children:[(0,n.jsx)("div",{className:"n",children:W.failed}),(0,n.jsx)("div",{className:"k",children:e("reg.failedCount")})]})]})]}),r&&(0,n.jsx)("div",{className:"panel err",children:r}),(0,n.jsxs)("div",{className:"panel",children:[(0,n.jsxs)("div",{className:"toolbar",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("label",{htmlFor:"f-session",style:{margin:0},children:e("reg.filterSession")}),(0,n.jsxs)("select",{id:"f-session",value:x,onChange:e=>p(e.target.value),children:[(0,n.jsx)("option",{value:"",children:e("reg.allSessions")}),q.map(e=>{let[s,t]=e;return(0,n.jsx)("option",{value:s,children:t},s)})]})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("label",{htmlFor:"f-status",style:{margin:0},children:e("reg.filterStatus")}),(0,n.jsxs)("select",{id:"f-status",value:j,onChange:e=>k(e.target.value),children:[(0,n.jsx)("option",{value:"",children:e("reg.allStatuses")}),["queued","running","waiting-approval","done","blocked","failed","aborted","limit-reached"].map(s=>(0,n.jsx)("option",{value:s,children:e("status.".concat(s))},s))]})]}),(0,n.jsxs)("div",{className:"grow",children:[(0,n.jsx)("label",{htmlFor:"f-q",style:{margin:0},children:e("reg.search")}),(0,n.jsx)("input",{id:"f-q",type:"text",value:b,onChange:e=>y(e.target.value),placeholder:e("reg.searchPlaceholder")})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("label",{style:{margin:0},id:"view-label",children:e("reg.viewLabel")}),(0,n.jsxs)("div",{className:"segmented",role:"group","aria-labelledby":"view-label",children:[(0,n.jsx)("button",{type:"button","aria-pressed":"flow"===h,onClick:()=>m("flow"),children:e("reg.viewFlow")}),(0,n.jsx)("button",{type:"button","aria-pressed":"runs"===h,onClick:()=>m("runs"),children:e("reg.groupBy")}),(0,n.jsx)("button",{type:"button","aria-pressed":"list"===h,onClick:()=>m("list"),children:e("reg.viewList")})]})]}),O&&(0,n.jsx)("button",{className:"quiet",onClick:()=>{p(""),k(""),y("")},children:e("reg.clear")})]}),null===t&&(0,n.jsx)("div",{className:"muted",children:e("home.loading")}),null!==t&&0===t.length&&(0,n.jsx)("div",{className:"empty",children:e("reg.none")}),null!==t&&t.length>0&&0===R.length&&(0,n.jsx)("div",{className:"empty",children:e("reg.noMatch")})]}),"list"===h&&R.length>0&&(0,n.jsx)(T,{entries:[...H,...D,...M]}),"runs"===h&&R.length>0&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{className:"panel",children:[(0,n.jsx)("h2",{children:e("reg.runGroup")}),(0,n.jsx)("p",{className:"muted small",children:e("reg.runGroupHint")})]}),P.runs.map(e=>(0,n.jsxs)("section",{className:"panel",children:[(0,n.jsx)(I,{run:e}),(0,n.jsx)(w,{entries:e.entries,sizes:G,onChange:()=>void S()})]},e.id)),P.loose.length>0&&(0,n.jsxs)("section",{className:"panel",children:[(0,n.jsx)("h2",{children:e("reg.notInARun")}),(0,n.jsx)("p",{className:"muted small",children:e("reg.notInARunHint")}),(0,n.jsx)(w,{entries:P.loose,sizes:G,onChange:()=>void S()})]})]}),"flow"===h&&(0,n.jsxs)(n.Fragment,{children:[H.length>0&&(0,n.jsxs)("section",{className:"panel",children:[(0,n.jsx)("h2",{children:e("reg.activeNow")}),(0,n.jsx)(w,{entries:H,sizes:G,onChange:()=>void S()})]}),R.length>0&&(0,n.jsxs)("section",{className:"panel",children:[(0,n.jsx)("h2",{children:e("reg.upcoming")}),(0,n.jsx)("p",{className:"muted small",children:e("reg.upcomingHint")}),(0,n.jsx)(g,{onChange:()=>void S()}),(0,n.jsx)(A,{entries:R,onChange:()=>void S()}),0===E.length?(0,n.jsx)("div",{className:"empty",children:e("reg.noUpcoming")}):(0,n.jsx)(w,{entries:E,upcoming:!0,sizes:G,onChange:()=>void S()})]}),R.length>0&&(0,n.jsxs)("section",{className:"panel",children:[(0,n.jsx)("h2",{children:e("reg.past")}),(0,n.jsx)("p",{className:"muted small",children:e("reg.pastHint")}),0===M.length?(0,n.jsx)("div",{className:"empty",children:e("reg.noPast")}):(0,n.jsx)(C,{entries:M,sizes:G,onChange:()=>void S()})]})]})]})}function w(e){let{entries:s,upcoming:t=!1,sizes:l,onChange:g,picking:p}=e,{t:v}=(0,o.kj)(),k=(0,o.W3)(),f=(0,x.e)(null!=g?g:()=>void 0),b=(0,c.c)(s.some(d.DG)),[w,I]=(0,a.useState)(null),[C,F]=(0,a.useState)(new Set);return(0,n.jsxs)(n.Fragment,{children:[w&&(0,n.jsx)(S,{entry:w,onClose:e=>{I(null),e&&(null==g||g())}}),(0,n.jsx)("ol",{className:"flow",children:s.map(e=>{var s,a,c,o,g,x,w,S,A,T,q,R,W,G,P,H,D,E,M,O,_,B;let L=t&&1===e.queuePosition,z=e.runGroup?null!=(w=null==l?void 0:l.get(e.runGroup.id))?w:1:0;return(0,n.jsxs)("li",{className:"".concat(e.status).concat(L?" next":""),children:[(0,n.jsxs)("div",{className:"head",children:[p&&(0,n.jsx)("input",{type:"checkbox",className:"pick","aria-label":e.title,checked:p.picked.has("".concat(e.sessionId,":").concat(e.taskId)),onChange:()=>p.toggle("".concat(e.sessionId,":").concat(e.taskId))}),(0,n.jsx)("strong",{children:e.title}),(0,n.jsx)("span",{className:"badge ".concat(e.status),children:v("status.".concat(e.status))}),L&&(0,n.jsx)("span",{className:"chip",children:v("reg.next")}),t&&N.includes(e.status)&&(0,n.jsx)("span",{className:"chip",title:v("reg.willRequeueFirstWhy"),children:v("reg.willRequeueFirst")}),e.sessionRunning&&(0,n.jsx)("span",{className:"chip",children:v("reg.sessionRunning")}),e.review&&"skipped"!==e.review.verdict&&(0,n.jsxs)("span",{className:"badge ".concat("pass"===e.review.verdict?"done":"fail"===e.review.verdict?"blocked":"waiting-approval"),title:e.review.stepsRun>0?v("review.ran",{n:e.review.stepsRun}):void 0,children:[v("review.verdict.".concat(e.review.verdict)),e.review.findings>0?" (".concat(e.review.findings,")"):""]}),(null!=(S=e.deviations)?S:0)>0&&(0,n.jsx)("span",{className:"badge waiting-approval",title:v("reg.deviationsWhy"),children:v("reg.deviations",{n:null!=(A=e.deviations)?A:0})}),(null!=(T=e.disputes)?T:0)>0&&(0,n.jsx)("span",{className:"badge waiting-approval",title:v("reg.disputesWhy"),children:v("reg.disputes",{n:null!=(q=e.disputes)?q:0})}),e.readOnly&&(0,n.jsx)("span",{className:"chip",title:v("reg.readOnlyWhy"),children:v("task.readOnly")}),(null!=(R=e.autoRetries)?R:0)>0&&(0,n.jsx)("span",{className:"badge ".concat("done"===e.status?"done":"blocked"),title:v("reg.retriedFreshWhy"),children:"done"===e.status?v("reg.retriedFreshDone",{n:null!=(W=e.autoRetries)?W:0}):v("reg.retriedFreshStill",{n:null!=(G=e.autoRetries)?G:0})}),e.runGroup&&(0,n.jsx)("span",{className:"chip",title:v("reg.runTitle",{t:z,s:e.runGroup.sessions,when:k(e.runGroup.startedAt)}),children:z>1?v("reg.runWith",{n:z-1}):v("reg.runAlone")})]}),(0,n.jsxs)("div",{className:"when",children:[(0,n.jsx)(r(),{href:(0,i.aT)(e.sessionId),children:e.sessionName})," \xb7 ",e.startedAt?v("task.started",{t:k(e.startedAt)}):v("task.added",{t:k(e.createdAt)}),e.finishedAt?" \xb7 ".concat(v("task.finished",{t:k(e.finishedAt)})):"",void 0!==e.durationMs?" \xb7 ".concat(v("reg.took",{d:(0,i.c5)(e.durationMs)})):"",(0,d.DG)(e)?" \xb7 ".concat(v("task.runningFor",{d:(0,i.c5)((0,d.d5)(e.startedAt,void 0,b))})):"",e.iterations>0?" \xb7 ".concat(v("reg.iterations",{n:e.iterations})):""]}),"queued"===e.status&&(0,n.jsx)("div",{className:"when",children:e.queuePosition&&e.queuePosition>1?v("reg.willFollow",{n:e.queuePosition-1}):e.sessionRunning?v("reg.queuePos",{n:null!=(P=e.queuePosition)?P:1}):v("reg.waitingRun")}),"blocked"===e.status&&(0,n.jsx)("p",{className:"what muted small",children:v("reg.blockedWhat")}),(null!=(H=null==(s=e.attempts)?void 0:s.length)?H:0)>0&&(0,n.jsxs)("details",{className:"small",style:{marginTop:6},children:[(0,n.jsx)("summary",{children:(null!=(D=null==(a=e.attempts)?void 0:a.length)?D:0)===1?v("reg.attemptsOne",{n:null!=(M=e.attempt)?M:(null!=(E=null==(c=e.attempts)?void 0:c.length)?E:0)+1}):v("reg.attempts",{n:null!=(_=e.attempt)?_:(null!=(O=null==(o=e.attempts)?void 0:o.length)?O:0)+1,m:null!=(B=null==(g=e.attempts)?void 0:g.length)?B:0})}),(0,n.jsx)("ol",{className:"attempts",children:null==(x=e.attempts)?void 0:x.map(s=>{var t;return(0,n.jsxs)("li",{children:[(0,n.jsxs)("div",{className:"head",children:[(0,n.jsx)("strong",{children:v("reg.attemptN",{n:s.attempt})}),(0,n.jsx)("span",{className:"badge ".concat(s.status),children:v("status.".concat(s.status))}),s.iterations>0&&(0,n.jsx)("span",{className:"muted",children:v("reg.iterations",{n:s.iterations})}),void 0!==s.durationMs&&(0,n.jsx)("span",{className:"muted",children:v("reg.took",{d:(0,i.c5)(s.durationMs)})}),s.runId&&(0,n.jsx)(u.u,{label:v("save.attemptLog"),save:()=>i.FH.saveTaskLog(e.sessionId,e.taskId,s.runId)})]}),(0,n.jsxs)("div",{className:"when",children:[s.startedAt?v("task.started",{t:k(s.startedAt)}):"",s.finishedAt?" \xb7 ".concat(v("task.finished",{t:k(s.finishedAt)})):"",s.branch?" \xb7 ".concat(s.branch):""]}),s.reason&&(0,n.jsx)("p",{className:"what err",children:v("reg.stopped",{reason:s.reason})}),s.summary&&(0,n.jsx)(h.s,{text:s.summary,className:"what"})]},"".concat(null!=(t=s.runId)?t:s.attempt))})})]}),e.summary&&(0,n.jsx)(h.s,{text:e.summary,className:"what"}),e.reason&&(0,n.jsx)("p",{className:"what err",children:v("reg.stopped",{reason:e.reason})}),f.message&&(0,n.jsx)("p",{className:"what small",children:f.message}),(0,n.jsxs)("div",{className:"row small",style:{marginTop:6},children:[(0,n.jsx)(r(),{href:(0,i.aT)(e.sessionId,e.taskId),children:v("reg.openTask")}),e.runId&&(0,n.jsx)(u.u,{label:v("save.log"),save:()=>i.FH.saveTaskLog(e.sessionId,e.taskId)}),e.chatUrl&&(0,n.jsx)("a",{href:e.chatUrl,target:"_blank",rel:"noreferrer",children:v("home.col.chat")}),e.startedAt&&(0,n.jsx)(y,{where:{session:e.sessionId,task:e.taskId}}),(0,n.jsx)(m,{}),e.runId&&(0,n.jsxs)("button",{className:C.has(e.taskId)?"":"quiet",onClick:()=>{let s;return s=e.taskId,F(e=>{let t=new Set(e);return t.has(s)?t.delete(s):t.add(s),t})},title:(0,d.DG)(e)?v("story.showLiveWhy"):v("story.why"),children:[(0,d.DG)(e)&&!C.has(e.taskId)&&(0,n.jsx)("span",{className:"dot","aria-hidden":"true"}),C.has(e.taskId)?v("story.hide"):(0,d.DG)(e)?v("story.showLive"):v("story.show")]}),N.includes(e.status)&&!e.sessionRunning&&(0,n.jsx)("button",{className:"quiet",onClick:()=>I(e),title:v("reg.fixPromptHint"),children:v("reg.fixPrompt")}),e.startedAt&&!e.sessionRunning&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("button",{className:"quiet",disabled:""!==f.busy,title:v("restore.why"),onClick:()=>void f.restore({sessionId:e.sessionId,taskId:e.taskId,title:e.title}),children:"restore"===f.busy?v("restore.checking"):v("restore.button")}),(0,n.jsx)("button",{className:"quiet",disabled:""!==f.busy,title:v("restart.why"),onClick:()=>void f.restartFrom({sessionId:e.sessionId,taskId:e.taskId,title:e.title}),children:"restart"===f.busy?v("restart.checking"):v("restart.button")})]})]}),C.has(e.taskId)&&e.runId&&(0,n.jsx)(j.P,{sessionId:e.sessionId,taskId:e.taskId,live:"running"===e.status||"waiting-approval"===e.status})]},"".concat(e.sessionId,"-").concat(e.taskId))})})]})}function y(e){let{where:s}=e,{t}=(0,o.kj)();return(0,n.jsxs)("span",{className:"exports",title:t("reg.exportTitle"),children:[(0,n.jsxs)("span",{className:"muted",children:[t("reg.exportTitle"),":"]})," ",(0,n.jsx)("a",{href:i.FH.exportUrl("plan",s),title:t("reg.exportPlanWhy"),children:t("reg.exportPlan")})," \xb7 ",(0,n.jsx)("a",{href:i.FH.exportUrl("domain",s),title:t("reg.exportDomainWhy"),children:t("reg.exportDomain")})," \xb7 ",(0,n.jsx)("a",{href:i.FH.exportUrl("bot",s),title:t("reg.exportBotWhy"),children:t("reg.exportBot")})]})}function I(e){var s;let{run:t}=e,{t:a}=(0,o.kj)(),l=(0,o.W3)(),r=null!=(s=t.entries.map(e=>{var s;return null==(s=e.runGroup)?void 0:s.name}).find(Boolean))?s:a("reg.runUnnamed"),i=t.entries.filter(e=>"done"===e.status).length,d=t.entries.filter(e=>N.includes(e.status)).length;return(0,n.jsxs)("div",{className:"run-heading",children:[(0,n.jsxs)("div",{className:"row",children:[(0,n.jsx)("h2",{className:"grow",style:{margin:0},children:r}),(0,n.jsxs)("span",{className:"muted small",children:[a("reg.runOf",{t:t.entries.length,s:t.sessions})," \xb7 ",a("reg.runAt",{when:l(t.startedAt)})," \xb7 ",(0,n.jsx)(k,{run:t})]})]}),(0,n.jsxs)("div",{className:"row small",style:{marginTop:4},children:[(0,n.jsx)("span",{className:"badge ".concat(d>0?"failed":i===t.entries.length?"done":""),children:a("reg.runCounts",{done:i,failed:d})}),(0,n.jsx)(y,{where:{run:t.id}})]})]})}function C(e){let{entries:s,sizes:t,onChange:l}=e,{t:r}=(0,o.kj)(),d=(0,a.useMemo)(()=>f(s),[s]),[c,u]=(0,a.useState)(!1),[h,m]=(0,a.useState)(new Set),[g,x]=(0,a.useState)(!1),[p,j]=(0,a.useState)(""),[v,N]=(0,a.useState)(""),k=e=>"".concat(e.sessionId,":").concat(e.taskId),b=s.filter(e=>e.startedAt),y=[...h],C=async()=>{x(!0),N(""),j("");try{let e=await i.FH.downloadBundle(y.map(e=>{let[s,t]=e.split(":");return{sessionId:s,taskId:t}}));j(r("reg.bundleSaved",{name:e}))}catch(e){N(e.message)}finally{x(!1)}},S=c?{picked:h,toggle:e=>m(s=>{let t=new Set(s);return t.has(e)?t.delete(e):t.add(e),t})}:void 0;return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{className:"row small",style:{marginBottom:8},children:[c?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("button",{className:"quiet",onClick:()=>{u(!1),m(new Set),j(""),N("")},children:r("reg.pickDone")}),(0,n.jsx)("button",{className:"quiet",onClick:()=>m(new Set(b.map(k))),children:r("reg.pickAll")}),(0,n.jsx)("button",{className:"quiet",onClick:()=>m(new Set),children:r("reg.pickNone")}),(0,n.jsx)("span",{className:"muted",children:h.size>0?r("reg.pickedN",{n:h.size}):r("reg.pickedNone")}),h.size>0&&(0,n.jsx)("button",{className:"primary",disabled:g,onClick:()=>void C(),title:r("reg.bundleWhy"),children:r("reg.bundle",{n:h.size})})]}):(0,n.jsx)("button",{className:"quiet",onClick:()=>u(!0),title:r("reg.pickWhy"),children:r("reg.pick")}),p&&(0,n.jsx)("span",{className:"muted",children:p}),v&&(0,n.jsx)("span",{className:"err",children:v})]}),d.runs.map((e,s)=>(0,n.jsxs)("details",{className:"run-fold",open:0===s||c,children:[(0,n.jsx)("summary",{children:(0,n.jsx)(I,{run:e})}),(0,n.jsx)(w,{entries:e.entries,sizes:t,onChange:l,picking:S})]},e.id)),d.loose.length>0&&(0,n.jsxs)("details",{className:"run-fold",open:0===d.runs.length||c,children:[(0,n.jsx)("summary",{children:(0,n.jsxs)("div",{className:"run-heading",children:[(0,n.jsx)("h2",{style:{margin:0},children:r("reg.notInARun")}),(0,n.jsx)("p",{className:"muted small",style:{margin:"4px 0 0"},children:r("reg.notInARunHint")})]})}),(0,n.jsx)(w,{entries:d.loose,sizes:t,onChange:l,picking:S})]})]})}function S(e){let{entry:s,onClose:t}=e,{t:l}=(0,o.kj)(),[r,d]=(0,a.useState)(null),[c,u]=(0,a.useState)(""),[h,m]=(0,a.useState)(!1);(0,a.useEffect)(()=>{let e=!0;return i.FH.session(s.sessionId).then(t=>{var n;let a=t.tasks.find(e=>e.id===s.taskId);e&&d(null!=(n=null==a?void 0:a.prompt)?n:"")}).catch(s=>{e&&u(s.message)}),()=>{e=!1}},[s.sessionId,s.taskId]);let g=async()=>{if(null!==r){m(!0),u("");try{await i.FH.rerunTask(s.sessionId,s.taskId,{prompt:r}),u(l("reg.fixPromptSaved",{title:s.title})),setTimeout(()=>t(!0),900)}catch(e){u(e.message),m(!1)}}};return(0,n.jsx)("div",{className:"modal-backdrop",role:"presentation",onClick:()=>t(!1),children:(0,n.jsxs)("div",{className:"modal wide",role:"dialog","aria-modal":"true","aria-labelledby":"fix-title",onClick:e=>e.stopPropagation(),children:[(0,n.jsx)("h2",{id:"fix-title",children:l("reg.fixPromptTitle",{title:s.title})}),(0,n.jsx)("p",{className:"muted small",children:l("reg.fixPromptHint")}),s.reason&&(0,n.jsx)("p",{className:"what err small",children:l("reg.stopped",{reason:s.reason})}),null===r?(0,n.jsx)("p",{className:"muted small",children:c||l("reg.fixPromptLoading")}):(0,n.jsx)("textarea",{className:"prose",value:r,onChange:e=>d(e.target.value),style:{minHeight:260},disabled:h}),(0,n.jsxs)("div",{className:"row modal-actions",children:[c&&null!==r&&(0,n.jsx)("span",{className:"small grow",children:c}),(0,n.jsx)("button",{type:"button",className:"quiet",onClick:()=>t(!1),disabled:h,children:l("dialog.cancel")}),(0,n.jsx)("button",{type:"button",className:"primary",onClick:()=>void g(),disabled:h||null===r||!r.trim(),children:l("reg.fixPromptSave")})]})]})})}function F(e){let{sessions:s}=e,{t}=(0,o.kj)();return(0,n.jsxs)("div",{className:"row",style:{margin:"14px 0 18px"},children:[(0,n.jsx)(r(),{href:"/#new-session",children:(0,n.jsx)("button",{className:"primary",children:t("reg.newSession")})}),s.length>0&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("label",{htmlFor:"new-task-session",style:{margin:0},children:[t("reg.newTask")," ",t("reg.newTaskIn")]}),(0,n.jsxs)("select",{id:"new-task-session",value:"",onChange:e=>{e.target.value&&(window.location.href=(0,i.aT)(e.target.value,"new-task"))},style:{width:"auto",minWidth:200},children:[(0,n.jsx)("option",{value:"",children:t("reg.newTaskPick")}),s.map(e=>{let[s,t]=e;return(0,n.jsx)("option",{value:s,children:t},s)})]})]})]})}function A(e){let{entries:s,onChange:t}=e,{t:l}=(0,o.kj)(),[r,d]=(0,a.useState)(!1),[c,u]=(0,a.useState)(""),[h,m]=(0,a.useState)(!1),[g,x]=(0,a.useState)(new Set),[j,v]=(0,a.useState)(null),k=s.filter(e=>"queued"===e.status),f=s.filter(e=>N.includes(e.status)&&!e.sessionRunning),b=s.some(e=>e.sessionRunning),w=f.filter(e=>"stop"===e.sessionOnFailure),y=f.filter(e=>"stop"!==e.sessionOnFailure),I=[...w,...y.filter(e=>g.has(e.taskId))],C=[...new Set([...k,...I].sort((e,s)=>{var t,n;return(null!=(t=e.sessionRunOrder)?t:Number.MAX_SAFE_INTEGER)-(null!=(n=s.sessionRunOrder)?n:Number.MAX_SAFE_INTEGER)||e.position-s.position}).map(e=>e.sessionId))],[F,A]=(0,a.useState)(""),T=w.length>0?l("reg.continueWithFailed",{f:w.length,n:k.length,s:C.length}):l("reg.continue",{n:k.length,s:C.length}),q=async e=>{if("unattended"!==e||await (0,p.Z)(l("batch.unattendedConfirm",{n:C.length}))){d(!0),u("");try{var s;for(let e of I)await i.FH.rerunTask(e.sessionId,e.taskId);let n=await i.FH.startBatch(C,e,"stop",void 0,void 0,F.trim()||void 0);u(n.started?l("reg.continueStarted",{n:C.length}):l("batch.notStarted",{reason:null!=(s=n.reason)?s:""})),m(!1),t()}catch(e){u(e.message)}finally{d(!1)}}};return 0===k.length&&0===f.length?null:(0,n.jsxs)("div",{style:{marginBottom:8},children:[(0,n.jsxs)("div",{className:"row",children:[(0,n.jsx)("button",{className:"primary",disabled:r||b,onClick:()=>{x(new Set(y.map(e=>e.taskId))),m(!0),u(""),i.FH.suggestedRunName(C).then(e=>A(e.name)).catch(()=>void 0)},title:l("reg.continueWhy"),children:T}),b&&(0,n.jsx)("span",{className:"muted small",children:l("reg.continueRunning")}),c&&(0,n.jsx)("span",{className:"small",children:c})]}),h&&!b&&(0,n.jsxs)("div",{className:"notice",style:{marginTop:8},children:[(0,n.jsx)("strong",{children:l("reg.continuePanelTitle")}),w.length>0&&(0,n.jsxs)("div",{style:{marginTop:6},children:[(0,n.jsx)("div",{className:"small",children:l("reg.continueChain")}),(0,n.jsx)("ul",{className:"small",style:{margin:"4px 0",paddingLeft:18},children:w.map(e=>(0,n.jsxs)("li",{children:[(0,n.jsx)("strong",{children:e.title})," \xb7 ",e.sessionName," \xb7 ",(0,n.jsx)("span",{className:"badge ".concat(e.status),children:l("status.".concat(e.status))})," ",(0,n.jsx)("button",{className:"quiet small",onClick:()=>v(e),children:l("reg.fixPrompt")})]},e.taskId))})]}),y.length>0&&(0,n.jsxs)("div",{style:{marginTop:6},children:[(0,n.jsx)("div",{className:"small",children:l("reg.continueIndependent")}),(0,n.jsx)("ul",{className:"small",style:{margin:"4px 0",paddingLeft:18,listStyle:"none"},children:y.map(e=>(0,n.jsx)("li",{children:(0,n.jsxs)("label",{className:"option-inline",children:[(0,n.jsx)("input",{type:"checkbox",checked:g.has(e.taskId),onChange:s=>x(t=>{let n=new Set(t);return s.target.checked?n.add(e.taskId):n.delete(e.taskId),n})}),(0,n.jsx)("strong",{children:e.title})," \xb7 ",e.sessionName," \xb7 ",(0,n.jsx)("span",{className:"badge ".concat(e.status),children:l("status.".concat(e.status))})]})},e.taskId))})]}),(0,n.jsxs)("div",{style:{marginTop:8},children:[(0,n.jsx)("label",{htmlFor:"continue-run-name",children:l("batch.runName")}),(0,n.jsx)("input",{id:"continue-run-name",type:"text",value:F,onChange:e=>A(e.target.value),placeholder:l("batch.runNamePlaceholder"),disabled:r}),(0,n.jsx)("p",{className:"why",children:l("reg.continueNameWhy")})]}),(0,n.jsx)("div",{className:"small",style:{marginTop:6},children:l("reg.continueSummary",{q:k.length,r:I.length,s:C.length})}),(0,n.jsxs)("div",{className:"row",style:{marginTop:8},children:[(0,n.jsx)("button",{className:"primary",disabled:r||0===C.length,onClick:()=>void q("unattended"),title:l("reg.continueUnattendedWhy"),children:l("reg.continueUnattended")}),(0,n.jsx)("button",{disabled:r||0===C.length,onClick:()=>void q("confirm"),title:l("reg.continueWhy"),children:l("reg.continueGo")}),(0,n.jsx)("button",{className:"quiet",disabled:r,onClick:()=>m(!1),children:l("dialog.cancel")})]})]}),j&&(0,n.jsx)(S,{entry:j,onClose:e=>{v(null),e&&t()}})]})}function T(e){let{entries:s}=e,{t}=(0,o.kj)(),a=(0,o.W3)();return(0,n.jsx)("div",{className:"panel",children:(0,n.jsxs)("table",{children:[(0,n.jsx)("thead",{children:(0,n.jsxs)("tr",{children:[(0,n.jsx)("th",{children:t("reg.col.task")}),(0,n.jsx)("th",{children:t("reg.col.session")}),(0,n.jsx)("th",{children:t("reg.col.status")}),(0,n.jsx)("th",{children:t("reg.col.started")}),(0,n.jsx)("th",{children:t("reg.col.took")}),(0,n.jsx)("th",{children:t("reg.col.result")})]})}),(0,n.jsx)("tbody",{children:s.map(e=>{var s;return(0,n.jsxs)("tr",{children:[(0,n.jsx)("td",{children:(0,n.jsx)(r(),{href:(0,i.aT)(e.sessionId,e.taskId),children:e.title})}),(0,n.jsx)("td",{children:(0,n.jsx)(r(),{href:(0,i.aT)(e.sessionId),children:e.sessionName})}),(0,n.jsx)("td",{children:(0,n.jsx)("span",{className:"badge ".concat(e.status),children:t("status.".concat(e.status))})}),(0,n.jsx)("td",{className:"muted small",children:e.startedAt?a(e.startedAt):"—"}),(0,n.jsx)("td",{className:"muted small",children:(0,i.c5)(e.durationMs)||"—"}),(0,n.jsx)("td",{className:"small",children:null!=(s=e.summary)?s:e.reason?(0,n.jsx)("span",{className:"err",children:e.reason}):"—"})]},"".concat(e.sessionId,"-").concat(e.taskId))})})]})})}}},e=>{e.O(0,[197,867,549,955,347,131,358],()=>e(e.s=3256)),_N_E=e.O()}]);
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[322],{1035:(e,a,s)=>{"use strict";s.d(a,{DialogHost:()=>o,Z:()=>c});var n=s(3365),l=s(1521),t=s(867);let i=null,r=[];function c(e){let a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new Promise(s=>{var n;return n={kind:"confirm",message:e,...a,resolve:s},void(i?i(n):r.push(n))})}function o(e){var a,s;let{children:c}=e,{t:o}=(0,t.kj)(),[d,p]=(0,l.useState)([]),m=(0,l.useRef)(null);(0,l.useEffect)(()=>{if(i=e=>p(a=>[...a,e]),r.length>0){let e=r.splice(0,r.length);p(a=>[...a,...e])}return()=>{i=null}},[]);let u=d[0],h=(0,l.useCallback)(e=>{u&&(u.resolve(e),p(e=>e.slice(1)))},[u]);return(0,l.useEffect)(()=>{var e;if(!u)return;null==(e=m.current)||e.focus();let a=e=>{"Escape"===e.key&&(e.preventDefault(),h(!1))};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[u,h]),(0,n.jsxs)(n.Fragment,{children:[c,u&&(0,n.jsx)("div",{className:"modal-backdrop",onClick:()=>h(!1),role:"presentation",children:(0,n.jsxs)("div",{className:"modal".concat(u.danger?" danger":""),role:"confirm"===u.kind?"alertdialog":"dialog","aria-modal":"true","aria-labelledby":"modal-title",onClick:e=>e.stopPropagation(),children:[(0,n.jsx)("h2",{id:"modal-title",children:null!=(a=u.title)?a:o("confirm"===u.kind?"dialog.confirmTitle":"dialog.noticeTitle")}),(0,n.jsx)("div",{className:"modal-body",children:u.message}),(0,n.jsxs)("div",{className:"row modal-actions",children:["confirm"===u.kind&&(0,n.jsx)("button",{type:"button",className:"quiet",onClick:()=>h(!1),children:o("dialog.cancel")}),(0,n.jsx)("button",{ref:m,type:"button",className:u.danger?"danger":"primary",onClick:()=>h(!0),children:null!=(s=u.okLabel)?s:o("dialog.ok")})]})]})})]})}},5515:(e,a,s)=>{Promise.resolve().then(s.bind(s,9262))},9262:(e,a,s)=>{"use strict";s.r(a),s.d(a,{default:()=>d});var n=s(3365),l=s(1521),t=s(8197),i=s.n(t),r=s(5549),c=s(1035),o=s(867);function d(){var e,a;let{t:s,locale:t}=(0,o.kj)(),d=(0,o.W3)(),[p,u]=(0,l.useState)(""),[h,x]=(0,l.useState)(""),[j,v]=(0,l.useState)(!1),[g,y]=(0,l.useState)(""),[f,k]=(0,l.useState)(""),[N,w]=(0,l.useState)(0),[b,C]=(0,l.useState)(""),[S,H]=(0,l.useState)(!1),[T,F]=(0,l.useState)(null),[P,E]=(0,l.useState)(""),[D,A]=(0,l.useState)(""),L=(0,l.useRef)(null),[R,W]=(0,l.useState)(null);(0,l.useEffect)(()=>{let e=!1;return r.FH.planBrief(t).then(a=>{e||(u(a.text),x(a.software),k(""))}).catch(a=>{e||k(a.message)}),()=>{e=!0}},[t,N]);let B=(0,l.useCallback)(async(e,a)=>{try{await navigator.clipboard.writeText(a),y(e),window.setTimeout(()=>y(""),2500)}catch(e){A(s("plan.copyFailed"))}},[s]),Z=(0,l.useCallback)(async e=>{if(e.size>2097152)return void A(s("plan.fileTooBig",{size:"".concat(Math.round(e.size/1024)," KB")}));try{C(await e.text()),F(null),W(null),A("")}catch(e){A(s("plan.fileError",{reason:e.message}))}},[s]),_=async()=>{E("check"),A("");try{F(await r.FH.checkPlan(b))}catch(e){A(e.message)}finally{E("")}},O=async()=>{var e;let a=T&&!T.ok?[]:null!=(e=null==T?void 0:T.duplicates)?e:[];if(a.length>0){let e=a.map(e=>"• ".concat(e.name," (").concat(e.tasks,")")).join("\n");if(!await (0,c.Z)(s("plan.duplicateConfirm",{names:e})))return}E("import"),A("");try{let e=await r.FH.importPlan(b);e.ok?(W(e),F({ok:!0,warnings:e.result.warnings,summary:e.summary,duplicates:e.duplicates}),C("")):(W(null),F(e.check))}catch(e){A(e.message)}finally{E("")}},q=(T&&!T.ok?T.issues:[]).map(e=>e.path?"- ".concat(e.path,": ").concat(e.message):"- ".concat(e.message)).join("\n");return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{className:"panel",children:[(0,n.jsx)("h2",{children:s("plan.title")}),(0,n.jsx)("p",{className:"muted small",children:s("plan.intro")})]}),(0,n.jsxs)("div",{className:"panel",children:[(0,n.jsx)("h2",{children:s("plan.step1")}),(0,n.jsx)("p",{className:"muted small",children:s("plan.step1Hint")}),(0,n.jsx)("h3",{children:s("plan.briefAsks")}),(0,n.jsx)("p",{className:"why",children:s("plan.briefAsksWhy")}),(0,n.jsxs)("div",{className:"row",style:{marginTop:12},children:[(0,n.jsx)("button",{className:"primary",onClick:()=>void B("brief",p),disabled:!p,children:s("plan.copyBrief")}),"brief"===g&&(0,n.jsx)("span",{className:"badge done",children:s("plan.copied")}),(0,n.jsx)("span",{className:"muted small",children:s("plan.briefLang")})]}),f&&(0,n.jsx)("div",{className:"err",children:f}),(0,n.jsx)("h3",{style:{marginTop:16},children:s("plan.persona")}),(0,n.jsx)("p",{className:"why",children:s("plan.personaWhy")}),(0,n.jsxs)("details",{style:{marginTop:8},open:j,onToggle:e=>v(e.target.open),children:[(0,n.jsx)("summary",{children:s("plan.softwarePart")}),(0,n.jsx)("textarea",{readOnly:!0,value:h,style:{minHeight:380,marginTop:10}})]}),(0,n.jsx)(m,{kind:"organisation",onSaved:()=>w(e=>e+1)}),(0,n.jsx)(m,{kind:"persona",onSaved:()=>w(e=>e+1)}),(0,n.jsx)(m,{kind:"work",onSaved:()=>w(e=>e+1)})]}),(0,n.jsxs)("div",{className:"panel",children:[(0,n.jsx)("h2",{children:s("plan.step2")}),(0,n.jsx)("p",{className:"muted small",children:s("plan.step2Hint")}),(0,n.jsxs)("div",{className:"dropzone".concat(S?" active":""),onDragOver:e=>{e.preventDefault(),H(!0)},onDragLeave:()=>H(!1),onDrop:e=>{var a;e.preventDefault(),H(!1);let s=null==(a=e.dataTransfer.files)?void 0:a[0];s&&Z(s)},children:[(0,n.jsx)("textarea",{className:"grow",placeholder:s("plan.placeholder"),value:b,onChange:e=>{C(e.target.value),F(null),W(null)},style:{minHeight:220,width:"100%"}}),(0,n.jsx)("p",{className:"muted small",children:S?s("plan.dropActive"):s("plan.drop")})]}),(0,n.jsxs)("div",{className:"row",style:{marginTop:10},children:[(0,n.jsx)("button",{onClick:()=>{var e;return null==(e=L.current)?void 0:e.click()},children:s("plan.browse")}),(0,n.jsx)("input",{ref:L,type:"file",accept:".json,application/json,text/plain",style:{display:"none"},onChange:e=>{var a;let s=null==(a=e.target.files)?void 0:a[0];s&&Z(s),e.target.value=""}}),(0,n.jsx)("button",{onClick:()=>void _(),disabled:!b.trim()||""!==P,children:"check"===P?s("plan.checking"):s("plan.check")}),(0,n.jsx)("button",{className:"primary",onClick:()=>void O(),disabled:!b.trim()||""!==P,children:"import"===P?s("plan.importing"):s("plan.import")}),(0,n.jsx)("button",{className:"quiet",onClick:()=>{C(""),F(null),W(null),A("")},disabled:!b&&!T,children:s("plan.clear")})]}),D&&(0,n.jsx)("div",{className:"err",children:D}),R&&""===b.trim()&&(0,n.jsx)("p",{className:"why",children:s("plan.cleared")})]}),T&&!T.ok&&(0,n.jsxs)("div",{className:"panel",children:[(0,n.jsx)("div",{className:"notice",children:(0,n.jsx)("strong",{children:s("plan.invalid")})}),(0,n.jsx)("h3",{children:s("plan.issues")}),(0,n.jsx)("p",{className:"muted small",children:s("plan.issuesHint")}),(0,n.jsx)("pre",{children:q}),(0,n.jsxs)("div",{className:"row",children:[(0,n.jsx)("button",{onClick:()=>void B("issues",q),children:s("plan.copyIssues")}),"issues"===g&&(0,n.jsx)("span",{className:"badge done",children:s("plan.copied")})]})]}),(null!=(e=null==T?void 0:T.duplicates.length)?e:0)>0&&(0,n.jsxs)("div",{className:"panel",children:[(0,n.jsxs)("div",{className:"notice caution",children:[(0,n.jsx)("strong",{children:s("plan.duplicates")}),(0,n.jsx)("ul",{children:(null!=(a=null==T?void 0:T.duplicates)?a:[]).map(e=>(0,n.jsx)("li",{children:(0,n.jsx)(i(),{href:(0,r.aT)(e.sessionId),children:s("plan.duplicateRow",{name:e.name,tasks:e.tasks,when:d(e.createdAt)})})},e.sessionId))})]}),(0,n.jsx)("p",{className:"muted small",children:s("plan.duplicatesHint")})]}),(null==T?void 0:T.ok)&&(0,n.jsxs)("div",{className:"panel",children:[(0,n.jsx)("div",{className:"notice calm",children:(0,n.jsx)("strong",{children:R?s("plan.imported",{sessions:R.result.sessions.length,tasks:R.result.taskCount}):s("plan.valid",{sessions:T.summary.sessions.length,tasks:T.summary.taskCount})})}),T.summary.plan&&(0,n.jsx)("p",{children:T.summary.plan}),(0,n.jsxs)("p",{className:"muted small",children:[s("plan.col.planFail"),":"," ","continue"===T.summary.onFailure?s("batch.independent"):s("batch.chain")]}),(0,n.jsx)("h3",{children:s("plan.preview")}),(0,n.jsxs)("table",{children:[(0,n.jsx)("thead",{children:(0,n.jsxs)("tr",{children:[(0,n.jsx)("th",{children:s("plan.col.session")}),(0,n.jsx)("th",{children:s("plan.col.tasks")}),(0,n.jsx)("th",{children:s("plan.col.chain")}),(0,n.jsx)("th",{children:s("plan.col.repo")})]})}),(0,n.jsx)("tbody",{children:T.summary.sessions.map((e,a)=>{let l=null==R?void 0:R.result.sessions[a];return(0,n.jsxs)("tr",{children:[(0,n.jsx)("td",{children:l?(0,n.jsx)(i(),{href:(0,r.aT)(l.id),children:e.name}):e.name}),(0,n.jsxs)("td",{className:"small",children:[e.tasks.length,(0,n.jsx)("div",{className:"muted small",children:e.tasks.join(", ")})]}),(0,n.jsx)("td",{className:"small",children:"continue"===e.onFailure?s("chain.continue"):s("chain.stop")}),(0,n.jsx)("td",{className:"small muted",children:e.repoDir||s("plan.noRepo")})]},"".concat(e.name,"-").concat(a))})})]}),T.summary.notes&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("h3",{children:s("plan.notes")}),(0,n.jsx)("p",{className:"muted small",style:{whiteSpace:"pre-wrap"},children:T.summary.notes})]}),T.warnings.length>0&&(0,n.jsxs)("div",{className:"notice caution",children:[(0,n.jsx)("strong",{children:s("plan.warnings")}),(0,n.jsx)("ul",{children:T.warnings.map(e=>(0,n.jsx)("li",{children:e},e))})]})]}),R&&(0,n.jsxs)("div",{className:"panel",children:[(0,n.jsx)("h2",{children:s("plan.step3")}),(0,n.jsx)("p",{className:"muted small",children:s("plan.step3Hint")}),(0,n.jsxs)("div",{className:"row",children:[(0,n.jsx)(i(),{href:"/?run=".concat(encodeURIComponent(R.result.sessions.map(e=>e.id).join(",")),"&fail=").concat(R.summary.onFailure),children:(0,n.jsx)("button",{className:"primary",children:s("plan.runThese")})}),(0,n.jsx)(i(),{href:"/",children:(0,n.jsx)("button",{children:s("plan.toSessions")})})]})]})]})}function p(e){var a,s;let{current:t,onLoad:i}=e,{t:d}=(0,o.kj)(),[p,m]=(0,l.useState)([]),[u,h]=(0,l.useState)(""),[x,j]=(0,l.useState)(""),v=(0,l.useCallback)(async()=>{try{m(await r.FH.personas())}catch(e){j(e.message)}},[]);(0,l.useEffect)(()=>{v()},[v]);let g=null!=(s=null==(a=p.find(e=>e.content===t))?void 0:a.name)?s:"",y=async e=>{let a=p.find(a=>a.name===e);a&&(!t.trim()||g||await (0,c.Z)(d("plan.personaReplaceConfirm",{name:e})))&&(i(a.content),h(a.name),j(d("plan.personaLoaded",{name:a.name})))},f=async()=>{let e=u.trim();if(e&&t.trim()&&(!p.some(a=>a.name===e)||await (0,c.Z)(d("plan.personaOverwriteConfirm",{name:e}))))try{let a=await r.FH.savePersona(e,t);h(a.name),j(d("plan.personaSavedAs",{name:a.name})),await v()}catch(e){j(e.message)}},k=async()=>{if(g&&await (0,c.Z)(d("plan.personaDeleteConfirm",{name:g})))try{await r.FH.deletePersona(g),j(d("plan.personaDeleted",{name:g})),await v()}catch(e){j(e.message)}};return(0,n.jsxs)("div",{className:"option",style:{marginBottom:8},children:[(0,n.jsx)("label",{htmlFor:"persona-shelf",children:d("plan.personaSaved")}),(0,n.jsxs)("div",{className:"row",children:[(0,n.jsxs)("select",{id:"persona-shelf",value:g,onChange:e=>void y(e.target.value),style:{width:"auto",minWidth:260},children:[(0,n.jsx)("option",{value:"",children:0===p.length?d("plan.personaNone"):d("plan.personaPick")}),p.map(e=>(0,n.jsx)("option",{value:e.name,children:e.name},e.name))]}),(0,n.jsx)("button",{className:"quiet",onClick:()=>void k(),disabled:!g,children:d("plan.personaDelete")})]}),(0,n.jsxs)("div",{className:"row",style:{marginTop:6},children:[(0,n.jsx)("input",{type:"text",value:u,onChange:e=>h(e.target.value),placeholder:d("plan.personaNamePlaceholder"),"aria-label":d("plan.personaNamePlaceholder"),style:{maxWidth:360}}),(0,n.jsx)("button",{onClick:()=>void f(),disabled:!u.trim()||!t.trim(),children:d("plan.personaSaveAs")}),(0,n.jsx)("span",{className:"muted small",role:"status",children:x})]}),(0,n.jsx)("p",{className:"why",children:d("plan.personaSavedWhy")})]})}function m(e){let{kind:a,onSaved:s}=e,{t,locale:i}=(0,o.kj)(),[d,m]=(0,l.useState)(""),[u,h]=(0,l.useState)(""),[x,j]=(0,l.useState)(""),[v,g]=(0,l.useState)(!1),[y,f]=(0,l.useState)(""),k=(0,l.useRef)(null);(0,l.useEffect)(()=>{let e=!1;return r.FH.context(a,i).then(a=>{e||(m(a.content),h(a.content),j(a.example),g(a.customised))}).catch(e=>f(e.message)),()=>{e=!0}},[a,i]);let N=async e=>{try{await r.FH.setContext(a,e),h(e),g(""!==e.trim()),f(t("plan.ctxSaved")),s()}catch(e){f(e.message)}},w=async()=>{if(await (0,c.Z)(t("plan.ctxClearConfirm")))try{let e=await r.FH.resetContext(a,i);m(e.content),h(e.content),g(e.customised),f(t("plan.ctxCleared")),s()}catch(e){f(e.message)}},b="organisation"===a?t("plan.orgPart"):"persona"===a?t("plan.personaPart"):t("plan.workPart"),C="organisation"===a?t("plan.orgHint"):"persona"===a?t("plan.personaHint"):t("plan.workHint");return(0,n.jsxs)("details",{style:{marginTop:8},open:!0,children:[(0,n.jsxs)("summary",{children:[b," ",(0,n.jsxs)("span",{className:"muted small",children:["— ",v?t("plan.ctxWritten"):t("plan.ctxEmpty")]})]}),(0,n.jsx)("p",{className:"muted small",style:{marginTop:8},children:C}),"persona"===a&&(0,n.jsx)(p,{current:d,onLoad:e=>{m(e),N(e)}}),(0,n.jsx)("textarea",{value:d,onChange:e=>{var a;m(e.target.value),a=e.target.value,k.current&&clearTimeout(k.current),k.current=setTimeout(()=>void N(a),900)},onBlur:()=>d!==u&&void N(d),placeholder:x,style:{minHeight:220}}),(0,n.jsxs)("div",{className:"row",style:{marginTop:6},children:[(0,n.jsx)("button",{className:"quiet",onClick:()=>void w(),disabled:!v,children:t("plan.ctxClear")}),(0,n.jsx)("span",{className:"muted small",role:"status",children:y||t("def.savedAutomatically")})]})]})}}},e=>{e.O(0,[197,867,549,347,131,358],()=>e(e.s=5515)),_N_E=e.O()}]);
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[177],{216:(e,a,t)=>{Promise.resolve().then(t.t.bind(t,8197,23)),Promise.resolve().then(t.bind(t,6657)),Promise.resolve().then(t.bind(t,1035)),Promise.resolve().then(t.t.bind(t,952,23)),Promise.resolve().then(t.bind(t,8214)),Promise.resolve().then(t.bind(t,1205)),Promise.resolve().then(t.bind(t,867))},952:()=>{},1035:(e,a,t)=>{"use strict";t.d(a,{DialogHost:()=>c,Z:()=>o});var n=t(3365),r=t(1521),s=t(867);let l=null,i=[];function o(e){let a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new Promise(t=>{var n;return n={kind:"confirm",message:e,...a,resolve:t},void(l?l(n):i.push(n))})}function c(e){var a,t;let{children:o}=e,{t:c}=(0,s.kj)(),[d,h]=(0,r.useState)([]),u=(0,r.useRef)(null);(0,r.useEffect)(()=>{if(l=e=>h(a=>[...a,e]),i.length>0){let e=i.splice(0,i.length);h(a=>[...a,...e])}return()=>{l=null}},[]);let m=d[0],v=(0,r.useCallback)(e=>{m&&(m.resolve(e),h(e=>e.slice(1)))},[m]);return(0,r.useEffect)(()=>{var e;if(!m)return;null==(e=u.current)||e.focus();let a=e=>{"Escape"===e.key&&(e.preventDefault(),v(!1))};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[m,v]),(0,n.jsxs)(n.Fragment,{children:[o,m&&(0,n.jsx)("div",{className:"modal-backdrop",onClick:()=>v(!1),role:"presentation",children:(0,n.jsxs)("div",{className:"modal".concat(m.danger?" danger":""),role:"confirm"===m.kind?"alertdialog":"dialog","aria-modal":"true","aria-labelledby":"modal-title",onClick:e=>e.stopPropagation(),children:[(0,n.jsx)("h2",{id:"modal-title",children:null!=(a=m.title)?a:c("confirm"===m.kind?"dialog.confirmTitle":"dialog.noticeTitle")}),(0,n.jsx)("div",{className:"modal-body",children:m.message}),(0,n.jsxs)("div",{className:"row modal-actions",children:["confirm"===m.kind&&(0,n.jsx)("button",{type:"button",className:"quiet",onClick:()=>v(!1),children:c("dialog.cancel")}),(0,n.jsx)("button",{ref:u,type:"button",className:m.danger?"danger":"primary",onClick:()=>v(!0),children:null!=(t=m.okLabel)?t:c("dialog.ok")})]})]})})]})}},1205:(e,a,t)=>{"use strict";t.d(a,{AppearanceProvider:()=>d,K:()=>h,themeScript:()=>i});var n=t(3365),r=t(1521);let s={theme:"light",textSize:"normal",highContrast:!1,reduceMotion:!1,underlineLinks:!1,strongFocus:!1},l="cop.appearance",i="\n(function () {\n try {\n var d = document.documentElement;\n var raw = localStorage.getItem('".concat(l,"');\n var a = raw ? JSON.parse(raw) : {};\n d.dataset.theme = a.theme === 'dark' ? 'dark' : 'light';\n d.dataset.textsize = 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");function o(e){let a=document.documentElement;a.dataset.theme=e.theme,a.dataset.textsize=e.textSize,a.dataset.contrast=e.highContrast?"high":"normal",a.dataset.motion=e.reduceMotion?"reduced":"normal",a.dataset.links=e.underlineLinks?"underline":"plain",a.dataset.focus=e.strongFocus?"strong":"normal"}let c=(0,r.createContext)({appearance:s,set:()=>void 0,reset:()=>void 0,loaded:!1});function d(e){let{children:a}=e,[t,i]=(0,r.useState)(s),[d,h]=(0,r.useState)(!1);(0,r.useEffect)(()=>{let e=s;try{let a=window.localStorage.getItem(l);a?e={...s,...JSON.parse(a)}:window.matchMedia("(prefers-color-scheme: dark)").matches&&(e={...e,theme:"dark"}),window.matchMedia("(prefers-reduced-motion: reduce)").matches&&!a&&(e={...e,reduceMotion:!0})}catch(e){}i(e),o(e),h(!0)},[]);let u=(0,r.useCallback)(e=>{i(a=>{let t={...a,...e};o(t);try{window.localStorage.setItem(l,JSON.stringify(t))}catch(e){}return t})},[]),m=(0,r.useCallback)(()=>{i(s),o(s);try{window.localStorage.removeItem(l)}catch(e){}},[]);return(0,n.jsx)(c.Provider,{value:{appearance:t,set:u,reset:m,loaded:d},children:a})}function h(){return(0,r.useContext)(c)}},1702:(e,a,t)=>{"use strict";var n=t(9962);t.o(n,"usePathname")&&t.d(a,{usePathname:function(){return n.usePathname}}),t.o(n,"useSearchParams")&&t.d(a,{useSearchParams:function(){return n.useSearchParams}})},6657:(e,a,t)=>{"use strict";t.d(a,{GlobalApprovals:()=>d});var n=t(3365),r=t(1521),s=t(8197),l=t.n(s),i=t(5549),o=t(867),c=t(1035);function d(){let{t:e}=(0,o.kj)(),[a,t]=(0,r.useState)([]),[s,l]=(0,r.useState)({}),c=(0,r.useCallback)(async()=>{try{let e=await i.FH.approvals();if(t(e),e.some(e=>!s[e.sessionId])){let e=await i.FH.sessions().catch(()=>[]);l(Object.fromEntries(e.map(e=>[e.id,e.name])))}}catch(e){}},[s]);return((0,r.useEffect)(()=>{c();let e=setInterval(()=>void c(),2e3);return()=>clearInterval(e)},[c]),(0,r.useEffect)(()=>{let t="copilot-operator";document.title=a.length>0?"(".concat(a.length,") ").concat(e("approval.tabTitle")," — ").concat(t):t},[a.length,e]),0===a.length)?null:(0,n.jsxs)("section",{className:"approval-banner",role:"alert","aria-live":"assertive",children:[(0,n.jsx)("h2",{children:e("approval.waitingHere")}),(0,n.jsx)("p",{className:"small",children:e("approval.waitingHereWhy")}),a.map(e=>{var a;return(0,n.jsx)(h,{approval:e,sessionName:null!=(a=s[e.sessionId])?a:e.sessionId,onDecided:()=>void c()},e.id)})]})}function h(e){let{approval:a,sessionName:t,onDecided:s}=e,{t:d}=(0,o.kj)(),h=(0,o.W3)(),[u,m]=(0,r.useState)(!1),v=async e=>{if("run-all"!==e||await (0,c.Z)(d("approval.runAllConfirm"))){m(!0);try{await i.FH.decide(a.id,e)}finally{m(!1),s()}}};return(0,n.jsxs)("div",{className:"approval",children:[(0,n.jsxs)("div",{className:"row",children:[(0,n.jsx)("strong",{children:d("approval.title",{n:a.stepId})}),(0,n.jsx)(l(),{href:(0,i.aT)(a.sessionId),children:t}),(0,n.jsx)("span",{className:"muted small",children:h(a.createdAt)})]}),(0,n.jsx)("pre",{style:{margin:"8px 0"},children:a.description}),a.network&&(0,n.jsx)("p",{className:"reason small",children:d("approval.network")}),(0,n.jsxs)("div",{className:"row",children:[(0,n.jsx)("button",{className:"primary",disabled:u,onClick:()=>void v("run"),children:d("approval.run")}),!a.network&&(0,n.jsx)("button",{disabled:u,onClick:()=>void v("run-all"),title:d("approval.runAllWhy"),children:d("approval.runAll")}),(0,n.jsx)("button",{disabled:u,onClick:()=>void v("skip"),children:d("approval.skip")}),(0,n.jsx)("button",{className:"danger",disabled:u,onClick:()=>void v("abort"),children:d("approval.abort")})]})]})}},8214:(e,a,t)=>{"use strict";t.d(a,{Nav:()=>m,SkipLink:()=>u});var n=t(3365),r=t(1521),s=t(8197),l=t.n(s),i=t(1702),o=t(5549),c=t(867);let d={sessions:(0,n.jsx)("path",{d:"M4 5h16v4H4zM4 11h16v4H4zM4 17h10v2H4z"}),defaults:(0,n.jsx)("path",{d:"M12 8a4 4 0 1 0 0 8 4 4 0 0 0 0-8zm8.5 4 1.5 1-1.6 2.8-1.8-.4a7 7 0 0 1-1.5 1.5l.4 1.8L14.7 21l-1-1.5a7 7 0 0 1-3.4 0l-1 1.5-2.8-1.6.4-1.8A7 7 0 0 1 5.4 16l-1.8.4L2 13.6 3.5 12.6V11.4L2 10.4l1.6-2.8 1.8.4A7 7 0 0 1 6.9 6.5l-.4-1.8L9.3 3l1 1.5a7 7 0 0 1 3.4 0l1-1.5 2.8 1.6-.4 1.8a7 7 0 0 1 1.5 1.5l1.8-.4L22 10.4l-1.5 1z"}),import:(0,n.jsx)("path",{d:"M12 3v10m0 0 4-4m-4 4-4-4M4 15v4a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-4",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),history:(0,n.jsx)("path",{d:"M12 3a9 9 0 1 0 8.5 6M12 7v5l3 2M3 4v5h5",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),level1:(0,n.jsx)("path",{d:"M6 3h9l5 5v13H6zM14 3v6h6M9 13h7M9 17h7",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinejoin:"round"}),presets:(0,n.jsx)("path",{d:"M5 4h14v4H5zM5 10h14v4H5zM5 16h9v4H5z",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinejoin:"round"}),appearance:(0,n.jsx)("path",{d:"M12 3a9 9 0 0 0 0 18c1.5 0 2-1 2-2s-1-1.5-1-2.5S14 15 15.5 15H17a4 4 0 0 0 4-4 8 8 0 0 0-9-8zM8 9a1 1 0 1 0 0 2 1 1 0 0 0 0-2zm4-3a1 1 0 1 0 0 2 1 1 0 0 0 0-2zm4 3a1 1 0 1 0 0 2 1 1 0 0 0 0-2z"}),system:(0,n.jsx)("path",{d:"M4 5h16v10H4zM2 19h20M9 15v4M15 15v4",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinejoin:"round"})},h=[{href:"/",label:"nav.sessions",icon:"sessions"},{href:"/defaults",label:"nav.defaults",icon:"defaults"},{href:"/import",label:"nav.import",icon:"import"},{href:"/history",label:"nav.history",icon:"history"},{href:"/level1",label:"nav.level1",icon:"level1"},{href:"/presets",label:"nav.presets",icon:"presets"},{href:"/appearance",label:"nav.appearance",icon:"appearance"},{href:"/system",label:"nav.system",icon:"system"}];function u(){let{t:e}=(0,c.kj)();return(0,n.jsx)("a",{className:"skip-link",href:"#main",children:e("a11y.skip")})}function m(){let{t:e}=(0,c.kj)(),a=(0,i.usePathname)(),t=function(){let[e,a]=(0,r.useState)(0);return(0,r.useEffect)(()=>{let e=!0,t=()=>o.FH.activity().then(t=>{e&&a(t.sessions)}).catch(()=>void 0);t();let n=setInterval(t,4e3);return()=>{e=!1,clearInterval(n)}},[]),e}();return(0,n.jsxs)("nav",{"aria-label":e("nav.label"),children:[h.map(r=>(0,n.jsxs)(l(),{href:r.href,"aria-current":a===r.href?"page":void 0,children:[(0,n.jsx)("svg",{className:"nav-icon",viewBox:"0 0 24 24",width:"16",height:"16",fill:"currentColor","aria-hidden":"true",children:d[r.icon]}),(0,n.jsx)("span",{children:e(r.label)}),"/history"===r.href&&t>0&&(0,n.jsxs)("span",{className:"live",title:e("nav.liveTitle",{n:t}),children:[(0,n.jsx)("span",{className:"dot","aria-hidden":"true"}),e("nav.live")]})]},r.href)),(0,n.jsx)(c.c5,{})]})}}},e=>{e.O(0,[353,197,867,549,347,131,358],()=>e(e.s=216)),_N_E=e.O()}]);
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[562],{1035:(e,l,a)=>{"use strict";a.d(l,{DialogHost:()=>o,Z:()=>c});var s=a(3365),t=a(1521),n=a(867);let i=null,r=[];function c(e){let l=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new Promise(a=>{var s;return s={kind:"confirm",message:e,...l,resolve:a},void(i?i(s):r.push(s))})}function o(e){var l,a;let{children:c}=e,{t:o}=(0,n.kj)(),[d,u]=(0,t.useState)([]),m=(0,t.useRef)(null);(0,t.useEffect)(()=>{if(i=e=>u(l=>[...l,e]),r.length>0){let e=r.splice(0,r.length);u(l=>[...l,...e])}return()=>{i=null}},[]);let p=d[0],g=(0,t.useCallback)(e=>{p&&(p.resolve(e),u(e=>e.slice(1)))},[p]);return(0,t.useEffect)(()=>{var e;if(!p)return;null==(e=m.current)||e.focus();let l=e=>{"Escape"===e.key&&(e.preventDefault(),g(!1))};return window.addEventListener("keydown",l),()=>window.removeEventListener("keydown",l)},[p,g]),(0,s.jsxs)(s.Fragment,{children:[c,p&&(0,s.jsx)("div",{className:"modal-backdrop",onClick:()=>g(!1),role:"presentation",children:(0,s.jsxs)("div",{className:"modal".concat(p.danger?" danger":""),role:"confirm"===p.kind?"alertdialog":"dialog","aria-modal":"true","aria-labelledby":"modal-title",onClick:e=>e.stopPropagation(),children:[(0,s.jsx)("h2",{id:"modal-title",children:null!=(l=p.title)?l:o("confirm"===p.kind?"dialog.confirmTitle":"dialog.noticeTitle")}),(0,s.jsx)("div",{className:"modal-body",children:p.message}),(0,s.jsxs)("div",{className:"row modal-actions",children:["confirm"===p.kind&&(0,s.jsx)("button",{type:"button",className:"quiet",onClick:()=>g(!1),children:o("dialog.cancel")}),(0,s.jsx)("button",{ref:m,type:"button",className:p.danger?"danger":"primary",onClick:()=>g(!0),children:null!=(a=p.okLabel)?a:o("dialog.ok")})]})]})})]})}},2162:(e,l,a)=>{"use strict";a.r(l),a.d(l,{default:()=>c});var s=a(3365),t=a(1521),n=a(5549),i=a(1035),r=a(867);function c(){let{t:e}=(0,r.kj)(),[l,a]=(0,t.useState)(""),[c,o]=(0,t.useState)(""),[d,u]=(0,t.useState)(!1),[m,p]=(0,t.useState)(""),g=async()=>{let e=await n.FH.level1();a(e.content),o(e.content),u(e.customised)};(0,t.useEffect)(()=>{g().catch(e=>p(e.message))},[]);let h=async()=>{try{await n.FH.setLevel1(l),o(l),u(!0),p(e("l1page.saved"))}catch(e){p(e.message)}},v=async()=>{if(!await (0,i.Z)(e("l1page.resetConfirm")))return;let l=await n.FH.resetLevel1();a(l.content),o(l.content),u(!1),p(e("l1page.resetDone"))};return(0,s.jsxs)("div",{className:"panel",children:[(0,s.jsx)("h2",{children:e("l1page.title")}),(0,s.jsx)("p",{className:"muted small",children:e("l1page.hint")}),(0,s.jsxs)("div",{className:"row small muted",children:[(0,s.jsx)("span",{children:d?e("l1page.custom"):e("l1page.shipped")}),(0,s.jsx)("span",{className:"grow"}),l!==c&&(0,s.jsx)("span",{children:e("l1page.unsaved")})]}),(0,s.jsx)("textarea",{className:"prose",style:{minHeight:520},value:l,onChange:e=>a(e.target.value)}),(0,s.jsxs)("div",{className:"row",style:{marginTop:10},children:[(0,s.jsx)("button",{className:"primary",onClick:()=>void h(),disabled:l===c,children:e("l1page.save")}),(0,s.jsx)("button",{onClick:()=>void v(),disabled:!d,children:e("l1page.reset")}),(0,s.jsx)("span",{className:"muted small",children:m})]})]})}},6103:(e,l,a)=>{Promise.resolve().then(a.bind(a,2162))}},e=>{e.O(0,[867,549,347,131,358],()=>e(e.s=6103)),_N_E=e.O()}]);
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[974],{1035:(e,l,t)=>{"use strict";t.d(l,{DialogHost:()=>c,Z:()=>d});var n=t(3365),s=t(1521),a=t(867);let i=null,r=[];function d(e){let l=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new Promise(t=>{var n;return n={kind:"confirm",message:e,...l,resolve:t},void(i?i(n):r.push(n))})}function c(e){var l,t;let{children:d}=e,{t:c}=(0,a.kj)(),[o,h]=(0,s.useState)([]),m=(0,s.useRef)(null);(0,s.useEffect)(()=>{if(i=e=>h(l=>[...l,e]),r.length>0){let e=r.splice(0,r.length);h(l=>[...l,...e])}return()=>{i=null}},[]);let u=o[0],p=(0,s.useCallback)(e=>{u&&(u.resolve(e),h(e=>e.slice(1)))},[u]);return(0,s.useEffect)(()=>{var e;if(!u)return;null==(e=m.current)||e.focus();let l=e=>{"Escape"===e.key&&(e.preventDefault(),p(!1))};return window.addEventListener("keydown",l),()=>window.removeEventListener("keydown",l)},[u,p]),(0,n.jsxs)(n.Fragment,{children:[d,u&&(0,n.jsx)("div",{className:"modal-backdrop",onClick:()=>p(!1),role:"presentation",children:(0,n.jsxs)("div",{className:"modal".concat(u.danger?" danger":""),role:"confirm"===u.kind?"alertdialog":"dialog","aria-modal":"true","aria-labelledby":"modal-title",onClick:e=>e.stopPropagation(),children:[(0,n.jsx)("h2",{id:"modal-title",children:null!=(l=u.title)?l:c("confirm"===u.kind?"dialog.confirmTitle":"dialog.noticeTitle")}),(0,n.jsx)("div",{className:"modal-body",children:u.message}),(0,n.jsxs)("div",{className:"row modal-actions",children:["confirm"===u.kind&&(0,n.jsx)("button",{type:"button",className:"quiet",onClick:()=>p(!1),children:c("dialog.cancel")}),(0,n.jsx)("button",{ref:m,type:"button",className:u.danger?"danger":"primary",onClick:()=>p(!0),children:null!=(t=u.okLabel)?t:c("dialog.ok")})]})]})})]})}},2114:(e,l,t)=>{"use strict";t.r(l),t.d(l,{default:()=>h});var n=t(3365),s=t(1521),a=t(8197),i=t.n(a),r=t(5549),d=t(867),c=t(1035),o=t(8848);function h(){let{t:e}=(0,d.kj)(),l=(0,d.W3)(),[t,a]=(0,s.useState)(null),[o,h]=(0,s.useState)(null),[u,p]=(0,s.useState)([]),[j,x]=(0,s.useState)([]),[g,b]=(0,s.useState)("stop"),[v,f]=(0,s.useState)(!1),[N,w]=(0,s.useState)(""),[y,k]=(0,s.useState)(""),[S,C]=(0,s.useState)(""),[F,I]=(0,s.useState)(null),[H,W]=(0,s.useState)(!1),T=(0,s.useCallback)(async()=>{try{let[e,l,t]=await Promise.all([r.FH.sessions(),r.FH.batch().catch(()=>null),r.FH.approvals().catch(()=>[])]);a(e),h(l),p(t),x(l=>l.filter(l=>e.some(e=>e.id===l))),I(!0),W(!1),C("")}catch(e){W(!(0,r.AV)()),I(!1),C(e.message)}},[]);(0,s.useEffect)(()=>{T();let e=setInterval(()=>void T(),3e3);return()=>clearInterval(e)},[T]),(0,s.useEffect)(()=>{var e;let l=new URLSearchParams(window.location.search),t=(null!=(e=l.get("run"))?e:"").split(",").map(e=>e.trim()).filter(Boolean);0!==t.length&&(x(t),b("continue"===l.get("fail")?"continue":"stop"),f(!0),window.history.replaceState(null,"",window.location.pathname))},[]);let E=async()=>{try{let e=await r.FH.createSession(N||"session");w(""),window.location.href=(0,r.aT)(e.id)}catch(e){C(e.message)}},P=async l=>{if(l.running)return void k(e("home.deleteRunning"));if(await (0,c.Z)(e("home.deleteConfirm",{name:l.name,n:l.tasks.length})))try{await r.FH.deleteSession(l.id),k(e("home.deleted",{name:l.name})),x(e=>e.filter(e=>e!==l.id)),await T()}catch(e){k(e.message)}},R=async()=>{let l=(null!=t?t:[]).filter(e=>j.includes(e.id));if(0===l.length)return;let n=l.map(e=>"• ".concat(e.name," (").concat(e.tasks.length,")")).join("\n");if(!await (0,c.Z)(e("home.deleteSelectedConfirm",{n:l.length,names:n})))return;let s=0,a=[];for(let e of l)try{await r.FH.deleteSession(e.id),s+=1}catch(l){a.push("".concat(e.name,": ").concat(l.message))}k(0===a.length?e("home.deletedMany",{n:s}):e("home.deleteSomeFailed",{n:s,m:a.length,why:a.join("; ")})),x([]),await T()},U=l=>{if(l.running)return{label:e("state.running"),badge:"running"};let t=l.tasks.some(e=>"queued"===e.status||"running"===e.status);if("idle"!==l.status||t||0===l.tasks.length)return{label:e("state.".concat(l.status)),badge:""};let n=l.tasks.filter(e=>"done"!==e.status).length;return 0===n?{label:e("state.completed"),badge:"done",title:e("state.completedTitle")}:{label:e("state.ended"),badge:"failed",title:e("state.endedTitle",{n:n})}};return(0,n.jsxs)(n.Fragment,{children:[H&&(0,n.jsxs)("div",{className:"panel",children:[(0,n.jsx)("strong",{children:e("home.noToken")}),(0,n.jsx)("div",{className:"muted small",children:e("home.noTokenHint",{cmd:"npm start"})})]}),!1===F&&!H&&(0,n.jsxs)("div",{className:"panel",children:[(0,n.jsx)("strong",{children:e("home.apiDown")}),(0,n.jsx)("div",{className:"muted small",children:e("home.apiHint",{cmd:"npm start",url:"/api"})}),S&&(0,n.jsx)("div",{className:"err",children:S})]}),(0,n.jsxs)("div",{className:"panel",id:"new-session",children:[(0,n.jsx)("h2",{children:e("home.new")}),(0,n.jsx)("p",{className:"muted small",children:e("home.newHint")}),(0,n.jsxs)("div",{className:"row",children:[(0,n.jsx)("input",{type:"text",className:"grow",placeholder:e("home.namePlaceholder"),value:N,onChange:e=>w(e.target.value),onKeyDown:e=>{"Enter"===e.key&&E()}}),(0,n.jsx)("button",{className:"primary",onClick:()=>void E(),disabled:!1===F,children:e("home.create")})]})]}),t&&t.length>0&&(0,n.jsx)(m,{sessions:t,selected:j,setSelected:x,onFailure:g,setOnFailure:b,fromPlan:v,batch:o,approvals:u,onChange:T,move:(e,l)=>{x(t=>{let n=t.indexOf(e),s=n+l;if(n<0||s<0||s>=t.length)return t;let a=[...t];return[a[n],a[s]]=[a[s],a[n]],a})}}),(0,n.jsxs)("div",{className:"panel",children:[(0,n.jsx)("h2",{children:e("home.sessions")}),null===t&&(0,n.jsx)("div",{className:"muted",children:e("home.loading")}),t&&0===t.length&&(0,n.jsx)("div",{className:"muted",children:e("home.none")}),t&&t.length>0&&(0,n.jsxs)("div",{className:"row",style:{marginBottom:10},children:[(0,n.jsx)("strong",{className:"small",children:e("home.selected",{n:j.length})}),(0,n.jsx)("button",{className:"danger",onClick:()=>void R(),disabled:0===j.length||(null==o?void 0:o.running)===!0||t.some(e=>j.includes(e.id)&&e.running),children:e("home.deleteSelected",{n:j.length})}),(0,n.jsx)("span",{className:"muted small",children:e("home.tickForBoth")})]}),t&&t.length>0&&(0,n.jsx)("p",{className:"muted small",children:e("home.deleteWhy")}),y&&(0,n.jsx)("div",{className:"muted small",role:"status",children:y}),t&&t.length>0&&(0,n.jsxs)("table",{children:[(0,n.jsx)("thead",{children:(0,n.jsxs)("tr",{children:[(0,n.jsx)("th",{children:(0,n.jsx)("input",{type:"checkbox","aria-label":e("home.selectAll"),checked:t.length>0&&j.length===t.length,onChange:e=>x(e.target.checked?t.map(e=>e.id).reverse():[]),disabled:(null==o?void 0:o.running)===!0})}),(0,n.jsx)("th",{children:e("home.col.name")}),(0,n.jsx)("th",{children:e("home.col.tasks")}),(0,n.jsx)("th",{children:e("home.col.state")}),(0,n.jsx)("th",{children:e("home.col.chat")}),(0,n.jsx)("th",{children:e("home.col.created")}),(0,n.jsx)("th",{children:(0,n.jsx)("span",{className:"visually-hidden",children:e("home.col.remove")})})]})}),(0,n.jsx)("tbody",{children:t.map(s=>{let a=s.tasks.filter(e=>"done"===e.status).length,d=s.tasks.filter(e=>"queued"===e.status).length;return(0,n.jsxs)("tr",{children:[(0,n.jsx)("td",{children:(0,n.jsx)("input",{type:"checkbox",checked:j.includes(s.id),onChange:()=>{var e;return e=s.id,void x(l=>{if(l.includes(e))return l.filter(l=>l!==e);let n=(null!=t?t:[]).map(e=>e.id).reverse();return[...l,e].sort((e,l)=>n.indexOf(e)-n.indexOf(l))})},disabled:(null==o?void 0:o.running)===!0,"aria-label":s.name})}),(0,n.jsx)("td",{children:(0,n.jsx)(i(),{href:(0,r.aT)(s.id),children:s.name})}),(0,n.jsxs)("td",{children:[s.tasks.length," ",(0,n.jsx)("span",{className:"muted small",children:e("home.tasksDetail",{done:a,queued:d})})]}),(0,n.jsx)("td",{children:(0,n.jsx)("span",{className:"badge ".concat(U(s).badge),title:U(s).title,children:U(s).label})}),(0,n.jsx)("td",{children:s.chat?(0,n.jsx)("a",{href:s.chat.url,target:"_blank",rel:"noreferrer",children:s.chat.name}):(0,n.jsx)("span",{className:"muted",children:e("home.notOpened")})}),(0,n.jsx)("td",{className:"muted small",children:l(s.createdAt)}),(0,n.jsx)("td",{children:(0,n.jsx)("button",{className:"quiet",onClick:()=>void P(s),disabled:s.running||(null==o?void 0:o.running)===!0,title:e("home.delete"),children:e("home.delete")})})]},s.id)})})]})]})]})}function m(e){var l,t,a,h,m,u,p;let{sessions:j,selected:x,setSelected:g,onFailure:b,setOnFailure:v,fromPlan:f,batch:N,approvals:w,onChange:y,move:k}=e,{t:S}=(0,d.kj)(),[C,F]=(0,s.useState)(""),[I,H]=(0,s.useState)(""),[W,T]=(0,s.useState)(""),[E,P]=(0,s.useState)(""),[R,U]=(0,s.useState)(""),[D,B]=(0,s.useState)(null),[L,M]=(0,s.useState)([]);(0,s.useEffect)(()=>{r.FH.models().then(e=>{B(e),T(l=>l||e.defaultModel),P(l=>l||e.defaultReviewModel)}).catch(()=>void 0)},[]);let O=x.join(",");(0,s.useEffect)(()=>{let e=!1,l=O.split(",").filter(Boolean);if(0===l.length)return void M([]);let t=async()=>{let t=await Promise.all(l.map(async e=>{let l=await r.FH.vcsStatus(e).catch(()=>null);return{id:e,status:l}}));e||M(t.filter(e=>e.status&&!e.status.ok&&"off"!==e.status.problem).map(e=>{var l,t,n,s;return{name:null!=(n=null==(l=j.find(l=>l.id===e.id))?void 0:l.name)?n:e.id,problem:null!=(s=null==(t=e.status)?void 0:t.problem)?s:""}}))};t();let n=setInterval(()=>void t(),1e4);return()=>{e=!0,clearInterval(n)}},[O]);let q=new Map(j.map(e=>[e.id,e])),_=e=>e.tasks.filter(e=>"queued"===e.status).length,Z=x.map(e=>q.get(e)).filter(e=>!!e),A=Z.filter(e=>_(e)>0),K=A.reduce((e,l)=>e+_(l),0),z=(null==N?void 0:N.running)===!0,Q=j.some(e=>e.running),V=z||0===A.length||Q,G=Q?{title:"batch.oneRunning",why:"batch.oneRunningWhy"}:0===Z.length?{title:"batch.pickFirst",why:"batch.pickFirstWhy"}:0===A.length?{title:"batch.nothingRunnable",why:"batch.nothingRunnableWhy"}:null,J=async e=>{if("unattended"!==e||await (0,c.Z)(S("batch.unattendedConfirm",{n:A.length})))try{var l;let t=await r.FH.startBatch(A.map(e=>e.id),e,b,W||void 0,E||void 0,R.trim()||A.map(e=>e.planName).find(Boolean)||void 0);F(""),H(t.started?"":null!=(l=t.reason)?l:""),y()}catch(e){H(e.message)}},X=async()=>{await r.FH.stopBatch(),F(S("batch.stopping")),y()},Y=async()=>{await r.FH.pauseBatch(),F(S("batch.pausing")),y()},$=async()=>{await r.FH.resumeBatch(),F(""),y()},ee=Z.filter(e=>{var l;return(null!=(l=e.model)?l:"")!==W}).length,el=Z.filter(e=>{var l;return(null==(l=e.review)?void 0:l.enabled)===!1}).length,et=null!=(a=null==D?void 0:D.options)?a:[],en=et.filter(e=>!e.group),es=new Map;for(let e of et)e.group&&es.set(e.group,[...null!=(h=es.get(e.group))?h:[],e]);let ea=N?{done:N.sessions.filter(e=>"done"===e.state).length,failed:N.sessions.filter(e=>"failed"===e.state).length,skipped:N.sessions.filter(e=>"skipped"===e.state||"stopped"===e.state).length}:null,ei=null==N?void 0:N.sessions.find(e=>"running"===e.state);return(0,n.jsxs)("div",{className:"panel",children:[(0,n.jsx)("h2",{children:S("batch.title")}),(0,n.jsx)("p",{className:"muted small",children:S("batch.hint")}),!z&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{className:"row",children:[(0,n.jsx)("strong",{className:"small",children:S("batch.selected",{n:A.length,tasks:K})}),(0,n.jsx)("button",{className:"quiet",onClick:()=>g(j.filter(e=>_(e)>0).map(e=>e.id).reverse()),children:S("batch.selectQueued")}),(0,n.jsx)("button",{className:"quiet",onClick:()=>g([]),disabled:0===Z.length,children:S("batch.selectNone")})]}),f&&(0,n.jsx)("p",{className:"muted small",children:S("batch.fromPlan")}),Z.length>A.length&&(0,n.jsx)("p",{className:"muted small",children:S("batch.notRunnable",{n:Z.length-A.length})}),A.length>0&&(0,n.jsx)("ol",{className:"run-order",children:A.map((e,l)=>(0,n.jsxs)("li",{children:[(0,n.jsxs)("span",{children:[e.name," ",(0,n.jsxs)("span",{className:"muted small",children:["(",_(e),")"]})]}),(0,n.jsxs)("span",{children:[(0,n.jsx)("button",{className:"quiet",onClick:()=>k(e.id,-1),disabled:0===l,"aria-label":"up",children:"↑"}),(0,n.jsx)("button",{className:"quiet",onClick:()=>k(e.id,1),disabled:l===A.length-1,"aria-label":"down",children:"↓"})]})]},e.id))}),(0,n.jsx)("label",{htmlFor:"batch-run-name",children:S("batch.runName")}),(0,n.jsx)("input",{id:"batch-run-name",type:"text",value:R,onChange:e=>U(e.target.value),placeholder:null!=(m=A.map(e=>e.planName).find(Boolean))?m:S("batch.runNamePlaceholder")}),(0,n.jsx)("p",{className:"why",children:S("batch.runNameWhy")}),(0,n.jsx)("label",{htmlFor:"batch-model",children:S("batch.model")}),(0,n.jsxs)("div",{className:"row",children:[(0,n.jsxs)("select",{id:"batch-model",value:W,onChange:e=>T(e.target.value),style:{width:"auto",minWidth:260},children:[(0,n.jsx)("option",{value:"",children:S("batch.modelKeep")}),en.map(e=>(0,n.jsx)("option",{value:e.name,disabled:e.disabled,children:e.name},e.name)),[...es.entries()].map(e=>{let[l,t]=e;return(0,n.jsx)("optgroup",{label:l,children:t.map(e=>(0,n.jsx)("option",{value:e.name,disabled:e.disabled,children:e.name},e.name))},l)})]}),(null!=(u=null==D?void 0:D.options.length)?u:0)===0&&(0,n.jsx)("span",{className:"muted small",children:S("batch.modelNone")})]}),(0,n.jsx)("p",{className:"why",children:S("batch.modelWhy")}),(0,n.jsx)(o.L,{current:W,onUse:e=>T(e)}),W&&ee>0&&(0,n.jsx)("p",{className:"why",style:{color:"var(--warn)"},children:S("batch.modelOverrides",{n:ee})}),(0,n.jsx)("label",{htmlFor:"batch-review-model",children:S("batch.reviewModel")}),(0,n.jsx)("div",{className:"row",children:(0,n.jsxs)("select",{id:"batch-review-model",value:E,onChange:e=>P(e.target.value),style:{width:"auto",minWidth:260},children:[(0,n.jsx)("option",{value:"",children:S("batch.reviewModelKeep")}),en.map(e=>(0,n.jsx)("option",{value:e.name,disabled:e.disabled,children:e.name},e.name)),[...es.entries()].map(e=>{let[l,t]=e;return(0,n.jsx)("optgroup",{label:l,children:t.map(e=>(0,n.jsx)("option",{value:e.name,disabled:e.disabled,children:e.name},e.name))},l)})]})}),(0,n.jsx)("p",{className:"why",children:S("batch.reviewModelWhy")}),""!==E&&E===W&&(0,n.jsx)("p",{className:"why",style:{color:"var(--warn)"},children:S("batch.reviewSame")}),el>0&&(0,n.jsx)("p",{className:"why",children:S("batch.reviewOffIn",{n:el})}),(0,n.jsxs)("fieldset",{style:{border:0,padding:0,margin:"10px 0 14px"},children:[(0,n.jsx)("legend",{className:"muted small",style:{padding:0},children:S("batch.onFailure")}),(0,n.jsxs)("div",{className:"option",children:[(0,n.jsxs)("label",{children:[(0,n.jsx)("input",{type:"radio",name:"batch-fail",checked:"stop"===b,onChange:()=>v("stop")}),(0,n.jsx)("span",{children:S("batch.chain")})]}),(0,n.jsx)("p",{className:"why",children:S("batch.chainWhy")})]}),(0,n.jsxs)("div",{className:"option",children:[(0,n.jsxs)("label",{children:[(0,n.jsx)("input",{type:"radio",name:"batch-fail",checked:"continue"===b,onChange:()=>v("continue")}),(0,n.jsx)("span",{children:S("batch.independent")})]}),(0,n.jsx)("p",{className:"why",children:S("batch.independentWhy")})]})]}),G&&(0,n.jsxs)("div",{className:"notice caution",children:[(0,n.jsx)("strong",{children:S(G.title)}),(0,n.jsx)("div",{className:"small",style:{marginTop:4},children:S(G.why)})]}),L.length>0&&(0,n.jsxs)("div",{className:"notice caution",children:[(0,n.jsx)("strong",{children:S("batch.vcsProblem")}),(0,n.jsx)("ul",{children:L.map(e=>(0,n.jsx)("li",{children:S("batch.vcsProblemRow",{name:e.name,problem:e.problem})},e.name))}),(0,n.jsx)("div",{className:"muted small",children:S("batch.vcsProblemWhy")})]}),I&&(0,n.jsxs)("div",{className:"notice caution",role:"alert",children:[(0,n.jsx)("strong",{children:S("batch.notStartedTitle")}),(0,n.jsx)("div",{className:"small",style:{marginTop:4},children:I}),/execution\.isolation/.test(I)&&(0,n.jsx)("div",{className:"small",style:{marginTop:4},children:(0,n.jsx)(i(),{href:"/defaults",children:S("batch.notStartedIsolation")})})]}),(0,n.jsxs)("div",{className:"run-choice",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("button",{className:"primary",onClick:()=>void J("unattended"),disabled:V,children:S("batch.run",{n:A.length})}),(0,n.jsx)("p",{className:"why",children:S("batch.runWhy")})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("button",{onClick:()=>void J("confirm"),disabled:V,children:S("batch.runStep")}),(0,n.jsx)("p",{className:"why",children:S("batch.runStepWhy")})]})]})]}),z&&(0,n.jsxs)("div",{className:"row",children:[(null==N?void 0:N.pausing)?(0,n.jsx)("button",{className:"primary",onClick:()=>void $(),disabled:null==N?void 0:N.stopping,title:S("batch.resumeWhy"),children:S("batch.resume")}):(0,n.jsx)("button",{onClick:()=>void Y(),disabled:null==N?void 0:N.stopping,title:S("batch.pauseWhy"),children:S("batch.pause")}),(0,n.jsx)("button",{onClick:()=>void X(),disabled:null==N?void 0:N.stopping,title:S("batch.stopWhy"),children:S("batch.stop")}),(null==N?void 0:N.pausing)&&!(null==N?void 0:N.stopping)&&(0,n.jsx)("span",{className:"muted small",children:S("batch.pausing")}),(0,n.jsx)("span",{className:"badge",children:S("batch.modelRunning",{name:(ei?(null==(l=q.get(ei.sessionId))?void 0:l.modelInUse)||(null==(t=q.get(ei.sessionId))?void 0:t.model):"")||S("model.default")})}),w.length>0&&(0,n.jsx)("span",{className:"badge waiting-approval",children:S("batch.waiting",{n:w.length})}),ei&&(0,n.jsx)("span",{className:"small",children:S("batch.progress",{name:ei.name,done:N.sessions.filter(e=>"waiting"!==e.state&&"running"!==e.state).length,total:N.sessions.length})})]}),z&&(0,n.jsx)("p",{className:"muted small",children:S("batch.hiddenWhileRunning")}),C&&(0,n.jsx)("div",{className:"muted small",role:"status",children:C}),(Z.length>0||N)&&(0,n.jsxs)("div",{className:"row",style:{marginTop:12},children:[(0,n.jsx)("a",{className:"button-link",href:r.FH.debugExportUrl(Z.length>0?Z.map(e=>e.id):(null!=(p=null==N?void 0:N.sessions)?p:[]).map(e=>e.sessionId)),children:S("batch.debug")}),(0,n.jsx)("span",{className:"muted small",children:Z.length>0?S("batch.debugSelected",{n:Z.length}):S("batch.debugLast")})]}),(Z.length>0||N)&&(0,n.jsx)("p",{className:"why",children:S("batch.debugWhy")}),N&&(0,n.jsxs)(n.Fragment,{children:[!z&&ea&&(0,n.jsx)("div",{className:"notice calm",style:{marginTop:12},children:(0,n.jsx)("strong",{children:S("batch.finished",ea)})}),(0,n.jsxs)("table",{style:{marginTop:10},children:[(0,n.jsx)("thead",{children:(0,n.jsxs)("tr",{children:[(0,n.jsx)("th",{children:S("batch.col.session")}),(0,n.jsx)("th",{children:S("batch.col.state")}),(0,n.jsx)("th",{children:S("batch.col.ran")}),(0,n.jsx)("th",{children:S("batch.col.why")})]})}),(0,n.jsx)("tbody",{children:N.sessions.map(e=>{var l,t;return(0,n.jsxs)("tr",{className:"batch-row ".concat(e.state),children:[(0,n.jsx)("td",{children:(0,n.jsx)(i(),{href:(0,r.aT)(e.sessionId),children:e.name})}),(0,n.jsx)("td",{children:(0,n.jsx)("span",{className:"badge ".concat("running"===(t=e.state)?"running":"done"===t?"done":"failed"===t?"failed":"stopped"===t?"aborted":""),children:S("batch.state.".concat(e.state))})}),(0,n.jsx)("td",{className:"small",children:S("batch.ranOf",{ran:e.ran,failed:e.failed})}),(0,n.jsx)("td",{className:"muted small",children:null!=(l=e.reason)?l:""})]},e.sessionId)})})]})]})]})}},5704:(e,l,t)=>{Promise.resolve().then(t.bind(t,2114))},8848:(e,l,t)=>{"use strict";t.d(l,{H4:()=>c,L:()=>o,z4:()=>h});var n=t(3365),s=t(8197),a=t.n(s),i=t(1521),r=t(5549),d=t(867);function c(e){let{current:l,onUse:t}=e,{t:s}=(0,d.kj)(),[a,c]=(0,i.useState)(null);if((0,i.useEffect)(()=>{let e=!1;return r.FH.project().then(l=>{e||c(l)}).catch(()=>void 0),()=>{e=!0}},[]),!a)return null;let o=a.rootDir.trim(),h=l.trim().toLowerCase(),m=t?a.others.filter(e=>e.rootDir.trim().toLowerCase()!==h):[];return(0,n.jsx)(u,{label:o?s("proj.defaultIs",{dir:o}):s("proj.noneShort"),offer:o&&t&&h!==o.toLowerCase()?{text:s("proj.useIt"),onUse:()=>t(o)}:void 0,more:m.map(e=>({text:s("proj.otherUse",{name:e.name}),title:e.rootDir,onUse:()=>null==t?void 0:t(e.rootDir)})),link:o?s("proj.change"):s("proj.setIt"),anchor:"project"})}function o(e){let{current:l,onUse:t}=e,s=m(),{t:a}=(0,d.kj)();if(!s)return null;let i=s.defaultModel.trim();return(0,n.jsx)(u,{label:i?a("def.modelDefaultIs",{name:i}):a("def.modelNoneShort"),offer:i&&t&&l.trim()!==i?{text:a("def.modelUseIt"),onUse:()=>t(i)}:void 0,link:a(i?"proj.change":"proj.setIt"),anchor:"model"})}function h(e){let{current:l,onUse:t}=e,s=m(),{t:a}=(0,d.kj)();if(!s)return null;let i=s.defaultReviewModel.trim();return(0,n.jsx)(u,{label:i?a("def.reviewDefaultIs",{name:i}):a("def.reviewNoneShort"),offer:i&&t&&l.trim()!==i?{text:a("def.modelUseIt"),onUse:()=>t(i)}:void 0,link:a(i?"proj.change":"proj.setIt"),anchor:"review"})}function m(){let[e,l]=(0,i.useState)(null);return(0,i.useEffect)(()=>{let e=!1;return r.FH.models().then(t=>{e||l(t)}).catch(()=>void 0),()=>{e=!0}},[]),e}function u(e){let{label:l,offer:t,more:s=[],link:i,anchor:r}=e;return(0,n.jsxs)("p",{className:"muted small",style:{marginTop:4},children:[l," ",t&&(0,n.jsxs)(n.Fragment,{children:["\xb7"," ",(0,n.jsx)("button",{type:"button",className:"linkish",onClick:t.onUse,children:t.text})," "]}),s.map(e=>(0,n.jsxs)("span",{children:["\xb7"," ",(0,n.jsx)("button",{type:"button",className:"linkish",onClick:e.onUse,title:e.title,children:e.text})," "]},e.text)),"\xb7 ",(0,n.jsx)(a(),{href:"/defaults#".concat(r),children:i})]})}}},e=>{e.O(0,[197,867,549,347,131,358],()=>e(e.s=5704)),_N_E=e.O()}]);
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[933],{1035:(e,s,a)=>{"use strict";a.d(s,{DialogHost:()=>d,Z:()=>c});var l=a(3365),t=a(1521),n=a(867);let r=null,i=[];function c(e){let s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new Promise(a=>{var l;return l={kind:"confirm",message:e,...s,resolve:a},void(r?r(l):i.push(l))})}function d(e){var s,a;let{children:c}=e,{t:d}=(0,n.kj)(),[o,m]=(0,t.useState)([]),u=(0,t.useRef)(null);(0,t.useEffect)(()=>{if(r=e=>m(s=>[...s,e]),i.length>0){let e=i.splice(0,i.length);m(s=>[...s,...e])}return()=>{r=null}},[]);let h=o[0],p=(0,t.useCallback)(e=>{h&&(h.resolve(e),m(e=>e.slice(1)))},[h]);return(0,t.useEffect)(()=>{var e;if(!h)return;null==(e=u.current)||e.focus();let s=e=>{"Escape"===e.key&&(e.preventDefault(),p(!1))};return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[h,p]),(0,l.jsxs)(l.Fragment,{children:[c,h&&(0,l.jsx)("div",{className:"modal-backdrop",onClick:()=>p(!1),role:"presentation",children:(0,l.jsxs)("div",{className:"modal".concat(h.danger?" danger":""),role:"confirm"===h.kind?"alertdialog":"dialog","aria-modal":"true","aria-labelledby":"modal-title",onClick:e=>e.stopPropagation(),children:[(0,l.jsx)("h2",{id:"modal-title",children:null!=(s=h.title)?s:d("confirm"===h.kind?"dialog.confirmTitle":"dialog.noticeTitle")}),(0,l.jsx)("div",{className:"modal-body",children:h.message}),(0,l.jsxs)("div",{className:"row modal-actions",children:["confirm"===h.kind&&(0,l.jsx)("button",{type:"button",className:"quiet",onClick:()=>p(!1),children:d("dialog.cancel")}),(0,l.jsx)("button",{ref:u,type:"button",className:h.danger?"danger":"primary",onClick:()=>p(!0),children:null!=(a=h.okLabel)?a:d("dialog.ok")})]})]})})]})}},2333:(e,s,a)=>{"use strict";a.r(s),a.d(s,{default:()=>c});var l=a(3365),t=a(1521),n=a(5549),r=a(1035),i=a(867);function c(){let{t:e}=(0,i.kj)(),s=(0,i.W3)(),[a,c]=(0,t.useState)([]),[d,o]=(0,t.useState)(""),[m,u]=(0,t.useState)(""),[h,p]=(0,t.useState)(""),j=async()=>c(await n.FH.presets());(0,t.useEffect)(()=>{j().catch(e=>p(e.message))},[]);let x=async()=>{try{await n.FH.savePreset(d,m),p(e("presets.saved",{name:d})),await j()}catch(e){p(e.message)}},v=async s=>{await (0,r.Z)(e("presets.deleteConfirm",{name:s.name}))&&(await n.FH.deletePreset(s.name),await j())};return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)("div",{className:"panel",children:[(0,l.jsx)("h2",{children:e("presets.title")}),(0,l.jsx)("p",{className:"muted small",children:e("presets.hint")}),(0,l.jsx)("label",{children:e("presets.name")}),(0,l.jsx)("input",{type:"text",value:d,onChange:e=>o(e.target.value),placeholder:e("presets.namePlaceholder")}),(0,l.jsx)("label",{children:e("presets.content")}),(0,l.jsx)("textarea",{className:"prose",style:{minHeight:220},value:m,onChange:e=>u(e.target.value),placeholder:e("presets.contentPlaceholder")}),(0,l.jsxs)("div",{className:"row",style:{marginTop:10},children:[(0,l.jsx)("button",{className:"primary",onClick:()=>void x(),disabled:!d.trim(),children:e("presets.save")}),(0,l.jsx)("span",{className:"muted small",children:h})]})]}),(0,l.jsxs)("div",{className:"panel",children:[(0,l.jsx)("h2",{children:e("presets.list")}),0===a.length&&(0,l.jsx)("div",{className:"muted",children:e("presets.none")}),a.map(a=>(0,l.jsxs)("div",{className:"task",children:[(0,l.jsxs)("div",{className:"row",children:[(0,l.jsx)("h4",{className:"grow",children:a.name}),(0,l.jsx)("span",{className:"muted small",children:s(a.updatedAt)}),(0,l.jsx)("button",{onClick:()=>{o(a.name),u(a.content)},children:e("presets.edit")}),(0,l.jsx)("button",{className:"danger",onClick:()=>void v(a),children:e("presets.delete")})]}),(0,l.jsxs)("details",{children:[(0,l.jsx)("summary",{children:e("presets.show")}),(0,l.jsx)("pre",{children:a.content})]})]},a.name))]})]})}},6568:(e,s,a)=>{Promise.resolve().then(a.bind(a,2333))}},e=>{e.O(0,[867,549,347,131,358],()=>e(e.s=6568)),_N_E=e.O()}]);