copilot-operator 0.1.13 → 0.1.16

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 (78) hide show
  1. package/README.md +9 -14
  2. package/dist/src/api/operator.controller.js +42 -42
  3. package/dist/src/api/operator.service.js +743 -367
  4. package/dist/src/api/saveToDesktop.js +1 -1
  5. package/dist/src/api/security.js +40 -10
  6. package/dist/src/api/server.js +75 -12
  7. package/dist/src/api/settings.js +156 -15
  8. package/dist/src/cli.js +108 -97
  9. package/dist/src/config/handWritten.js +36 -0
  10. package/dist/src/config/layout.js +13 -4
  11. package/dist/src/config/lockedPolicy.js +56 -22
  12. package/dist/src/config/schema.js +13 -84
  13. package/dist/src/context/desktopDir.js +44 -0
  14. package/dist/src/exec/authorizer.js +9 -1
  15. package/dist/src/exec/checks.js +240 -23
  16. package/dist/src/exec/dangerous.js +29 -5
  17. package/dist/src/exec/network.js +105 -28
  18. package/dist/src/exec/redaction.js +52 -9
  19. package/dist/src/exec/reportFile.js +4 -5
  20. package/dist/src/exec/runner.js +146 -13
  21. package/dist/src/exec/shells.js +41 -6
  22. package/dist/src/exec/workDir.js +4 -4
  23. package/dist/src/orchestrator/derivedChecks.js +1 -0
  24. package/dist/src/orchestrator/review.js +25 -3
  25. package/dist/src/orchestrator/taskRunner.js +476 -163
  26. package/dist/src/plan/brief.js +37 -44
  27. package/dist/src/plan/importPlan.js +15 -7
  28. package/dist/src/plan/schema.js +64 -29
  29. package/dist/src/plan/script.js +0 -15
  30. package/dist/src/plan/systemGuide.js +33 -177
  31. package/dist/src/protocol/parser.js +5 -1
  32. package/dist/src/session/debugExport.js +1 -1
  33. package/dist/src/session/exportRecord.js +1 -1
  34. package/dist/src/session/exports.js +49 -9
  35. package/dist/src/session/store.js +215 -80
  36. package/dist/src/transport/copilotTransport.js +39 -1
  37. package/dist/src/vcs/scope.js +29 -6
  38. package/dist/src/vcs/taskVcs.js +78 -10
  39. package/dist/web/404.html +2 -2
  40. package/dist/web/_next/static/chunks/36-94660f1cde2da529.js +1 -0
  41. package/dist/web/_next/static/chunks/549-7fd4fe96682299f5.js +1 -0
  42. package/dist/web/_next/static/chunks/867-631dc4314840fed6.js +1 -0
  43. package/dist/web/_next/static/chunks/app/defaults/page-fd819bbfa7f33982.js +1 -0
  44. package/dist/web/_next/static/chunks/app/sessions/view/page-886f5fc99e146408.js +1 -0
  45. package/dist/web/_next/static/css/{a0642fdb8adf9edb.css → e2a2c9eb3c226313.css} +1 -1
  46. package/dist/web/appearance.html +2 -2
  47. package/dist/web/appearance.txt +12 -12
  48. package/dist/web/defaults.html +2 -2
  49. package/dist/web/defaults.txt +12 -12
  50. package/dist/web/history.html +2 -2
  51. package/dist/web/history.txt +12 -12
  52. package/dist/web/import.html +2 -2
  53. package/dist/web/import.txt +12 -12
  54. package/dist/web/index.html +2 -2
  55. package/dist/web/index.txt +12 -12
  56. package/dist/web/level1.html +2 -2
  57. package/dist/web/level1.txt +12 -12
  58. package/dist/web/presets.html +2 -2
  59. package/dist/web/presets.txt +12 -12
  60. package/dist/web/sessions/view.html +2 -2
  61. package/dist/web/sessions/view.txt +12 -12
  62. package/dist/web/system.html +2 -2
  63. package/dist/web/system.txt +12 -12
  64. package/package.json +19 -10
  65. package/prompts/level1.md +2 -1
  66. package/prompts/organisation.bg.md +0 -1
  67. package/prompts/organisation.en.md +0 -1
  68. package/dist/src/context/contextFiles.js +0 -295
  69. package/dist/src/context/desktopMirror.js +0 -173
  70. package/dist/src/context/projectMirror.js +0 -432
  71. package/dist/web/_next/static/chunks/295-04151ded0741d18d.js +0 -1
  72. package/dist/web/_next/static/chunks/36-c3dd06c6a459c114.js +0 -1
  73. package/dist/web/_next/static/chunks/549-a5a59a94f92bb3eb.js +0 -1
  74. package/dist/web/_next/static/chunks/867-84c19f047972ffc3.js +0 -1
  75. package/dist/web/_next/static/chunks/app/defaults/page-5f180a88398be4c9.js +0 -1
  76. package/dist/web/_next/static/chunks/app/sessions/view/page-34d7988849f9aa76.js +0 -1
  77. /package/dist/web/_next/static/{NosxirjkOgV-Boyq8dGPl → GhdY7nVcYi-WV3j7saVPK}/_buildManifest.js +0 -0
  78. /package/dist/web/_next/static/{NosxirjkOgV-Boyq8dGPl → GhdY7nVcYi-WV3j7saVPK}/_ssgManifest.js +0 -0
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[189],{1035:(e,l,t)=>{"use strict";t.d(l,{DialogHost:()=>c,Z:()=>d});var r=t(3365),s=t(1521),n=t(867),a=t(4969);let i=null,o=[];function d(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(i?i(r):o.push(r))})}function c(e){var l,t;let{children:d}=e,{t:c}=(0,n.kj)(),[u,m]=(0,s.useState)([]),h=(0,s.useRef)(null),p=(0,s.useRef)(null);(0,s.useEffect)(()=>{if(i=e=>m(l=>[...l,e]),o.length>0){let e=o.splice(0,o.length);m(l=>[...l,...e])}return()=>{i=null}},[]);let x=u[0],j=(0,s.useCallback)(e=>{x&&(x.resolve(e),m(e=>e.slice(1)))},[x]);return(0,a.V)(p,!!x,h),(0,s.useEffect)(()=>{if(!x)return;let e=e=>{"Escape"===e.key&&(e.preventDefault(),j(!1))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[x,j]),(0,r.jsxs)(r.Fragment,{children:[d,x&&(0,r.jsx)("div",{className:"modal-backdrop",onClick:()=>j(!1),role:"presentation",children:(0,r.jsxs)("div",{ref:p,className:"modal".concat(x.danger?" danger":""),role:"confirm"===x.kind?"alertdialog":"dialog","aria-modal":"true","aria-labelledby":"modal-title","aria-describedby":"modal-body",onClick:e=>e.stopPropagation(),children:[(0,r.jsx)("h2",{id:"modal-title",children:null!=(l=x.title)?l:c("confirm"===x.kind?"dialog.confirmTitle":"dialog.noticeTitle")}),(0,r.jsx)("div",{id:"modal-body",className:"modal-body",children:x.message}),(0,r.jsxs)("div",{className:"row modal-actions",children:["confirm"===x.kind&&(0,r.jsx)("button",{type:"button",className:"quiet",onClick:()=>j(!1),children:c("dialog.cancel")}),(0,r.jsx)("button",{ref:h,type:"button",className:x.danger?"danger":"primary",onClick:()=>j(!0),children:null!=(t=x.okLabel)?t:c("dialog.ok")})]})]})})]})}},1896:(e,l,t)=>{Promise.resolve().then(t.bind(t,3197))},3197:(e,l,t)=>{"use strict";t.r(l),t.d(l,{default:()=>h});var r=t(3365),s=t(1521),n=t(2285),a=t(8197),i=t.n(a),o=t(5549),d=t(867),c=t(1035),u=t(4784),m=t(2244);function h(){let{t:e}=(0,d.kj)(),[l,t]=(0,s.useState)(null),[n,a]=(0,s.useState)(!1),[i,u]=(0,s.useState)("");(0,s.useEffect)(()=>{o.FH.models().then(t).catch(()=>void 0)},[]);let m=async()=>{if(await (0,c.Z)(e("model.refreshConfirm"))){a(!0),u(e("model.refreshing"));try{var l;let r=await o.FH.models().then(()=>o.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{a(!1)}}},h={catalogue:l,setCatalogue:t,refreshModels:m,refreshing:n,refreshMsg:i};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)(f,{}),(0,r.jsx)(b,{...h}),(0,r.jsx)(w,{...h}),(0,r.jsx)(k,{})]})}function p(e){let l=arguments.length>1&&void 0!==arguments[1]?arguments[1]:900,t=(0,s.useRef)(null),r=(0,s.useRef)(null),n=(0,s.useRef)(e);return n.current=e,(0,s.useEffect)(()=>()=>{t.current&&clearTimeout(t.current),r.current&&n.current(r.current.value)},[]),e=>{t.current&&clearTimeout(t.current),r.current={value:e},t.current=setTimeout(()=>{r.current=null,n.current(e)},l)}}function x(e){let{id:l,value:t,min:n,max:a,onChange:i,disabled:o}=e,[d,c]=(0,s.useState)(String(t));return(0,s.useEffect)(()=>c(e=>j(e)===t?e:String(t)),[t]),(0,r.jsx)("input",{id:l,type:"number",min:n,max:a,step:1,value:d,onChange:e=>{c(e.target.value);let l=j(e.target.value);null!==l&&l>=n&&l<=a&&i(l)},onBlur:()=>{let e=j(d),l=null===e?t:Math.max(n,Math.min(a,e));c(String(l)),l!==t&&i(l)},style:{width:"9ch"},disabled:o})}function j(e){if(""===e.trim())return null;let l=Number(e);return Number.isInteger(l)?l:null}function v(e){let{msg:l,onSave:t}=e,{t:s}=(0,d.kj)();return(0,r.jsxs)("div",{className:"row",style:{marginTop:6},children:[t&&(0,r.jsx)("button",{className:"quiet",onClick:t,title:s("def.saveAnywayWhy"),children:s("def.saveAnyway")}),(0,r.jsx)("span",{className:"muted small",role:"status",children:l||s("def.savedAutomatically")})]})}function f(){var e,l,t;let{t:n}=(0,d.kj)(),[a,i]=(0,s.useState)(null),[c,u]=(0,s.useState)(""),[m,h]=(0,s.useState)(""),[x,j]=(0,s.useState)(""),[f,g]=(0,s.useState)(""),[k,b]=(0,s.useState)(!1),[w,N]=(0,s.useState)(""),[S,D]=(0,s.useState)(""),C=(0,s.useCallback)(async()=>{try{let e=await o.FH.project();i(e),u(e.rootDir),h(e.name),g("")}catch(e){g(e.message)}},[]);(0,s.useEffect)(()=>{C()},[C]);let F=async(e,l)=>{b(!0),j("");try{let t=await o.FH.setProject(e);return i(t),u(t.rootDir),j(l(t)),g(""),!0}catch(e){return g(e.message),!1}finally{b(!1)}},T=e=>F({rootDir:e},e=>e.rootDir?n("proj.saved",{dir:e.rootDir}):n("proj.cleared")),M=e=>F({name:e},()=>n("proj.nameSaved")),R=p(T),E=p(M),A=async(e,l)=>{b(!0);try{var t;let r=await o.FH.browseFolder(l.trim()||void 0);r.ok?e(r.path):r.cancelled||g(null!=(t=r.reason)?t:"")}catch(e){g(e.message)}finally{b(!1)}},B=null!=(e=null==a?void 0:a.others)?e:[],I=e=>e.map(e=>({name:e.name,rootDir:e.rootDir,...e.mirror?{mirror:e.mirror}:{},...!1===e.desktop?{desktop:!1}:{}})),H=e=>e?n("proj.desktopOn"):n("proj.desktopOff"),P=async()=>{await F({others:[...I(B),{name:w.trim(),rootDir:S.trim()}]},e=>n("proj.othersSaved",{n:e.others.length}))&&(N(""),D(""))};return(0,r.jsxs)("div",{className:"panel",id:"project",children:[(0,r.jsx)("h2",{children:n("proj.title")}),(0,r.jsx)("p",{className:"muted small",children:n("proj.intro")}),f&&(0,r.jsx)("div",{className:"err",children:f}),a&&(0,r.jsxs)("div",{className:"option".concat(a.mirrorToDesktop?" warned":""),style:{marginBottom:12},children:[(0,r.jsxs)("label",{children:[(0,r.jsx)("input",{type:"checkbox",checked:a.mirrorToDesktop,onChange:e=>{F({mirrorToDesktop:e.target.checked},e=>e.mirrorToDesktop?n("proj.mirrorOn",{root:e.contextRoot}):n("proj.mirrorOff"))},disabled:k}),(0,r.jsx)("span",{children:n("proj.mirrorToDesktop")})]}),(0,r.jsx)("p",{className:"why",children:n("proj.mirrorToDesktopWhy",{root:a.contextRoot})})]}),(0,r.jsx)("p",{className:"muted small",children:n("proj.listIntro")}),(0,r.jsx)(y,{name:m,dir:c,repoOk:!!(null==a?void 0:a.repoOk),repoProblem:null==a?void 0:a.repoProblem,mirror:null==a?void 0:a.mirror,isDefault:!0,busy:k,onNameInput:e=>{h(e),E(e)},onName:e=>void M(e),onDirInput:e=>{u(e),R(e)},onDir:e=>void T(e),onBrowse:()=>void A(e=>void T(e),c),onRemove:(null==a?void 0:a.rootDir)?()=>void T(""):void 0,removeLabel:n("proj.clear"),onFolders:e=>F({mirror:e},()=>n("proj.foldersSaved")),desktop:null==(l=null==a?void 0:a.desktop)||l,desktopMaster:null!=(t=null==a?void 0:a.mirrorToDesktop)&&t,onDesktop:e=>void F({desktop:e},()=>H(e))}),(0,r.jsx)(v,{msg:x}),a&&!a.rootDir&&(0,r.jsx)("p",{className:"muted small",style:{marginTop:8},children:n("proj.none")}),B.map((e,l)=>{var t;return(0,r.jsx)(y,{name:e.name,dir:e.rootDir,repoOk:e.repoOk,repoProblem:e.repoProblem,mirror:e.mirror,busy:k,onName:l=>void F({others:I(B.map(t=>t.name===e.name?{...t,name:l}:t))},()=>n("proj.nameSaved")),onDir:l=>void F({others:I(B.map(t=>t.name===e.name?{...t,rootDir:l}:t))},()=>n("proj.othersSaved",{n:B.length})),onBrowse:()=>void A(l=>void F({others:I(B.map(t=>t.name===e.name?{...t,rootDir:l}:t))},()=>n("proj.othersSaved",{n:B.length})),e.rootDir),onRemove:()=>{let l;l=e.name,F({others:I(B.filter(e=>e.name!==l))},e=>n("proj.othersSaved",{n:e.others.length}))},removeLabel:n("proj.otherRemove"),onFolders:l=>{let t;return t=e.name,F({others:I(B.map(e=>e.name===t?{...e,mirror:l}:e))},()=>n("proj.foldersSaved"))},desktop:e.desktop,desktopMaster:null!=(t=null==a?void 0:a.mirrorToDesktop)&&t,onDesktop:l=>void F({others:I(B.map(t=>t.name===e.name?{...t,desktop:l}:t))},()=>H(l))},"other-".concat(l))}),(0,r.jsx)("h3",{id:"others",children:n("proj.addTitle")}),(0,r.jsx)("p",{className:"muted small",children:n("proj.othersIntro")}),(0,r.jsxs)("div",{className:"row",style:{marginTop:8},children:[(0,r.jsx)("input",{type:"text","aria-label":n("proj.entryName"),value:w,onChange:e=>N(e.target.value),placeholder:n("proj.entryName"),disabled:k,style:{width:160}}),(0,r.jsx)("input",{type:"text",className:"grow","aria-label":n("proj.entryDir"),value:S,onChange:e=>D(e.target.value),placeholder:"C:\\Projects\\my-app-tests",disabled:k}),(0,r.jsx)("button",{onClick:()=>void A(e=>D(e),S),disabled:k,children:n("mirror.browse")}),(0,r.jsx)("button",{className:"primary",onClick:()=>void P(),disabled:k||!w.trim()||!S.trim(),children:n("proj.otherAdd")})]}),(0,r.jsx)("h3",{children:n("proj.affects")}),(0,r.jsxs)("ul",{className:"muted small",style:{margin:0,paddingLeft:20},children:[(0,r.jsx)("li",{children:n("proj.affectsNew")}),(0,r.jsx)("li",{children:n("proj.affectsExisting")}),(0,r.jsx)("li",{children:n("proj.affectsPlan")}),(0,r.jsx)("li",{children:n("proj.affectsNever")})]})]})}function y(e){var l;let{name:t,dir:a,repoOk:i,repoProblem:o,mirror:c,isDefault:u=!1,busy:m,onNameInput:h,onName:p,onDirInput:x,onDir:j,onBrowse:v,onRemove:f,removeLabel:y,onFolders:k,desktop:b,desktopMaster:w,onDesktop:N}=e,{t:S}=(0,d.kj)(),D=(0,s.useId)(),[C,F]=(0,s.useState)(t),[T,M]=(0,s.useState)(a);return(0,s.useEffect)(()=>F(t),[t]),(0,s.useEffect)(()=>M(a),[a]),(0,r.jsxs)("div",{className:"panel inner",style:{marginTop:10},children:[(0,r.jsxs)("div",{className:"row",children:[(0,r.jsxs)("div",{style:{width:"min(200px, 100%)"},children:[(0,r.jsx)("label",{htmlFor:"".concat(D,"-name"),children:S("proj.entryName")}),(0,r.jsx)("input",{id:"".concat(D,"-name"),type:"text",value:C,onChange:e=>{F(e.target.value),null==h||h(e.target.value)},onBlur:()=>{(C!==t||h)&&p(C)},placeholder:a?null!=(l=a.replace(/[\/]+$/,"").split(/[\/]/).pop())?l:"":S("proj.namePlaceholder")})]}),(0,r.jsxs)("div",{className:"grow",children:[(0,r.jsx)("label",{htmlFor:"".concat(D,"-dir"),children:S("proj.entryDir")}),(0,r.jsx)("input",{id:"".concat(D,"-dir"),type:"text",value:T,onChange:e=>{M(e.target.value),null==x||x(e.target.value)},onBlur:()=>{(T!==a||x)&&j(T)},placeholder:"C:\\Projects\\my-app"})]}),(0,r.jsx)("button",{onClick:v,disabled:m,children:S("mirror.browse")}),f&&(0,r.jsx)("button",{className:"quiet",onClick:f,disabled:m,children:y})]}),(0,r.jsxs)("div",{className:"row small",style:{marginTop:6},children:[u&&(0,r.jsx)("span",{className:"chip",title:S("proj.isDefaultWhy"),children:S("proj.isDefault")}),a&&(0,r.jsx)("span",{className:"badge ".concat(i?"done":""),title:i?S("proj.isRepo"):o,children:S(i?"proj.otherRepo":"proj.otherNotRepo")}),a&&!i&&(0,r.jsx)("span",{className:"muted",children:o||S("proj.notRepoWhy")})]}),a&&(0,r.jsxs)("details",{className:"small",style:{marginTop:8},children:[(0,r.jsx)("summary",{children:S("proj.folders")}),(0,r.jsx)(g,{rootDir:a,value:c,onSave:k,busy:m})]}),a&&(0,r.jsxs)("label",{className:"option-inline small",style:{marginTop:8},title:w?void 0:S("proj.desktopMasterOff"),children:[(0,r.jsx)("input",{type:"checkbox",checked:b,disabled:m||!w,onChange:e=>N(e.target.checked)})," ",S("proj.desktopThis"),!w&&(0,r.jsxs)("span",{className:"muted",children:[" — ",S("proj.desktopMasterOff")]})]}),a&&i&&(0,r.jsx)(n.b,{dir:a})]})}function g(e){var l,t,n,a;let{rootDir:i,value:o,onSave:u,busy:h}=e,{t:x}=(0,d.kj)(),j=(0,s.useId)(),[f,y]=(0,s.useState)((null!=(l=null==o?void 0:o.includeDirs)?l:[]).join("\n")),[g,k]=(0,s.useState)((null!=(t=null==o?void 0:o.excludeDirs)?t:[]).join("\n")),[b,w]=(0,s.useState)(null==(n=null==o?void 0:o.respectGitignore)||n),[N,S]=(0,s.useState)(null!=(a=null==o?void 0:o.includeEnvFiles)&&a),D=e=>e.split("\n").map(e=>e.trim()).filter(Boolean),[C,F]=(0,s.useState)(""),T=async e=>{let l={includeDirs:D(f),excludeDirs:D(g),respectGitignore:b,includeEnvFiles:N,...e};await u(l)&&F(x("proj.foldersSaved"))},M=p(T),R=async e=>{(!e||await (0,c.Z)(x("mirror.envWarn")))&&(S(e),T({includeEnvFiles:e}))};return(0,r.jsxs)("div",{style:{marginTop:8},children:[(0,r.jsx)("p",{className:"muted small",children:x("proj.foldersHint")}),(0,r.jsxs)("div",{className:"row",style:{alignItems:"flex-start"},children:[(0,r.jsxs)("div",{className:"grow",children:[(0,r.jsx)("label",{htmlFor:"".concat(j,"-include"),children:x("mirror.include")}),(0,r.jsx)("textarea",{id:"".concat(j,"-include"),value:f,onChange:e=>{y(e.target.value),M({includeDirs:D(e.target.value),excludeDirs:D(g)})},placeholder:"src\ntests",style:{minHeight:70}})]}),(0,r.jsxs)("div",{className:"grow",children:[(0,r.jsx)("label",{htmlFor:"".concat(j,"-exclude"),children:x("mirror.exclude")}),(0,r.jsx)("textarea",{id:"".concat(j,"-exclude"),value:g,onChange:e=>{k(e.target.value),M({includeDirs:D(f),excludeDirs:D(e.target.value)})},placeholder:"src/generated",style:{minHeight:70}})]})]}),(0,r.jsx)(m.k,{rootDir:i,respectGitignore:b,includeEnvFiles:N,include:D(f),exclude:D(g),onChange:(e,l)=>{y(e.join("\n")),k(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=>{w(e.target.checked),T({respectGitignore:e.target.checked})}}),(0,r.jsx)("span",{children:x("mirror.gitignore")})]})}),(0,r.jsx)("div",{className:"option".concat(N?" warned":""),children:(0,r.jsxs)("label",{children:[(0,r.jsx)("input",{type:"checkbox",checked:N,onChange:e=>void R(e.target.checked)}),(0,r.jsx)("span",{children:x("mirror.env")})]})}),(0,r.jsx)(v,{msg:h?"":C})]})}function k(){let{t:e}=(0,d.kj)(),[l,t]=(0,s.useState)(null),n=(0,s.useRef)(null),a=(0,s.useRef)(Promise.resolve()),[i,c]=(0,s.useState)(2),[u,m]=(0,s.useState)(2),[h,j]=(0,s.useState)(60),[f,y]=(0,s.useState)(240),[g,k]=(0,s.useState)(900),[b,w]=(0,s.useState)("none"),[N,S]=(0,s.useState)("confirm"),[D,C]=(0,s.useState)("ask"),[F,T]=(0,s.useState)(""),[M,R]=(0,s.useState)("");(0,s.useEffect)(()=>{o.FH.settings().then(e=>{var l,r,s,a,i,o;n.current=e.raw,t(e.raw);let d=null!=(l=e.raw.limits)?l:{};c("number"==typeof d.retryBlockedInFreshChat?d.retryBlockedInFreshChat:2),m("number"==typeof d.minApproachesBeforeBlocked?d.minApproachesBeforeBlocked:2),j("number"==typeof d.maxIterations?d.maxIterations:60),y("number"==typeof d.maxRunMinutes?d.maxRunMinutes:240);let u=null!=(r=e.raw.copilot)?r:{};k("number"==typeof u.replyTimeoutSec?u.replyTimeoutSec:900);let h=null!=(s=e.raw.execution)?s:{};w(null!=(a=h.isolation)?a:"none"),S(null!=(i=h.mode)?i:"confirm"),C(null!=(o=h.networkFetch)?o:"ask")}).catch(e=>R(e.message))},[]);let E=(l,r,s)=>{let i=async()=>{var a;if(!n.current)return;let i=await o.FH.settings().then(e=>e.raw).catch(()=>n.current),d={...i,[l]:{...null!=(a=i[l])?a:{},[r]:s}};T("");try{await o.FH.saveSettings(d),n.current=d,t(d),T(e("exec.saved")),R("")}catch(e){R(e.message)}},d=a.current.then(i);return a.current=d.catch(()=>void 0),d},A=p(e=>E("limits","retryBlockedInFreshChat",e)),B=p(e=>E("limits","minApproachesBeforeBlocked",e)),I=p(e=>E("limits","maxIterations",e)),H=p(e=>E("limits","maxRunMinutes",e)),P=p(e=>E("copilot","replyTimeoutSec",e)),W=(e,l)=>E("execution",e,l);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")}),M&&(0,r.jsx)("div",{className:"err",children:M}),(0,r.jsx)("label",{htmlFor:"min-approaches",children:e("exec.minApproaches")}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)(x,{id:"min-approaches",value:u,min:2,max:20,onChange:e=>{m(e),B(e)},disabled:!l}),(0,r.jsx)("span",{className:"muted small",children:e("exec.minApproachesUnit")})]}),(0,r.jsx)("p",{className:"why",children:e("exec.minApproachesWhy")}),(0,r.jsx)("label",{htmlFor:"retry-blocked",children:e("exec.retryBlocked")}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)(x,{id:"retry-blocked",value:i,min:0,max:5,onChange:e=>{c(e),A(e)},disabled:!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)(x,{id:"max-iterations",value:h,min:5,max:200,onChange:e=>{j(e),I(e)},disabled:!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)(x,{id:"max-minutes",value:f,min:10,max:1440,onChange:e=>{y(e),H(e)},disabled:!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:"reply-timeout",children:e("exec.replyTimeout")}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)(x,{id:"reply-timeout",value:g,min:60,max:10800,onChange:e=>{k(e),P(e)},disabled:!l}),(0,r.jsx)("span",{className:"muted small",children:e("exec.replyTimeoutUnit")})]}),(0,r.jsx)("p",{className:"why",children:e("exec.replyTimeoutWhy")}),(0,r.jsx)("label",{htmlFor:"isolation",children:e("exec.isolation")}),(0,r.jsxs)("select",{id:"isolation",value:b,onChange:e=>{let l=e.target.value;w(l),W("isolation",l)},disabled:!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)("p",{className:"why",children:e("exec.isolationWhy")}),(0,r.jsx)("label",{htmlFor:"start-mode",children:e("exec.startMode")}),(0,r.jsxs)("select",{id:"start-mode",value:N,onChange:e=>{let l=e.target.value;S(l),W("mode",l)},disabled:!l,children:[(0,r.jsx)("option",{value:"confirm",children:e("exec.startModeAsk")}),(0,r.jsx)("option",{value:"unattended",children:e("exec.startModeAuto")})]}),(0,r.jsx)("p",{className:"why",children:e("exec.startModeWhy")}),(0,r.jsx)("label",{htmlFor:"network-fetch",children:e("exec.networkFetch")}),(0,r.jsxs)("select",{id:"network-fetch",value:D,onChange:e=>{let l=e.target.value;C(l),W("networkFetch",l)},disabled:!l,children:[(0,r.jsx)("option",{value:"ask",children:e("exec.networkFetchAsk")}),(0,r.jsx)("option",{value:"refuse",children:e("exec.networkFetchRefuse")}),(0,r.jsx)("option",{value:"run",children:e("exec.networkFetchRun")})]}),(0,r.jsx)(v,{msg:F}),(0,r.jsx)("p",{className:"why",children:e("exec.networkFetchWhy")})]})}function b(e){var l;let{catalogue:t,setCatalogue:n,refreshModels:a,refreshing:i,refreshMsg:c}=e,{t:m}=(0,d.kj)(),h=(0,d.W3)(),[p,x]=(0,s.useState)(""),[j,f]=(0,s.useState)(""),[y,g]=(0,s.useState)(!1),k=null!=(l=null==t?void 0:t.defaultModel)?l:"",b=async e=>{g(!0),x("");try{let l=await o.FH.setDefaultModel(e);t&&n({...t,defaultModel:l.defaultModel}),x(l.defaultModel?m("def.modelSaved",{name:l.defaultModel}):m("def.modelCleared")),f("")}catch(e){f(e.message)}finally{g(!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")}),j&&(0,r.jsx)("div",{className:"err",children:j}),(0,r.jsx)("label",{htmlFor:"default-model",children:m("def.modelField")}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)(u.Y,{id:"default-model",chosen:k,onChange:e=>void b(e),none:m("def.modelNone"),catalogue:t,disabled:y||i}),(0,r.jsx)("button",{className:"quiet",onClick:()=>void b(""),disabled:y||!k,children:m("proj.clear")}),(0,r.jsx)("button",{onClick:()=>void a(),disabled:y||i,children:m("model.refresh")})]}),(0,r.jsx)(v,{msg:p||c}),(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 w(e){var l,t;let{catalogue:n,setCatalogue:a,refreshModels:c,refreshing:m,refreshMsg:h}=e,{t:p}=(0,d.kj)(),[x,j]=(0,s.useState)(""),[f,y]=(0,s.useState)(""),[g,k]=(0,s.useState)(!1),b=null!=(l=null==n?void 0:n.defaultReviewModel)?l:"",w=async e=>{k(!0),j("");try{let l=await o.FH.setDefaultReviewModel(e);n&&a({...n,defaultReviewModel:l.defaultReviewModel}),j(l.defaultReviewModel?p("def.reviewSaved",{name:l.defaultReviewModel}):p("def.reviewCleared")),y("")}catch(e){y(e.message)}finally{k(!1)}},N=""!==b&&b===(null!=(t=null==n?void 0:n.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)(u.Y,{id:"default-review-model",chosen:b,onChange:e=>void w(e),none:p("def.reviewNone"),catalogue:n,disabled:g||m}),(0,r.jsx)("button",{className:"quiet",onClick:()=>void w(""),disabled:g||!b,children:p("proj.clear")}),(0,r.jsx)("button",{onClick:()=>void c(),disabled:g||m,children:p("model.refresh")})]}),N&&(0,r.jsx)("p",{className:"why",style:{color:"var(--warn)"},children:p("def.reviewSame")}),(0,r.jsx)(v,{msg:x||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)(i(),{href:"/",className:"button-link plain",children:p("proj.toSessions")}),(0,r.jsx)(i(),{href:"/import",className:"button-link quiet",children:p("proj.toImport")})]})]})}},4969:(e,l,t)=>{"use strict";t.d(l,{V:()=>n});var r=t(1521);let s='a[href], button:not([disabled]), textarea:not([disabled]), input:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex="-1"])';function n(e,l,t){(0,r.useEffect)(()=>{var r,n;if(!l)return;let a=document.activeElement instanceof HTMLElement?document.activeElement:null,i=e.current,o=null!=(n=null!=(r=null==t?void 0:t.current)?r:null==i?void 0:i.querySelector(s))?n:null;null==o||o.focus();let d=e=>{if("Tab"!==e.key||!i)return;let l=Array.from(i.querySelectorAll(s)).filter(e=>null!==e.offsetParent);if(0===l.length)return;let t=l[0],r=l[l.length-1],n=i.contains(document.activeElement);e.shiftKey&&(document.activeElement===t||!n)?(e.preventDefault(),r.focus()):e.shiftKey||document.activeElement!==r&&n||(e.preventDefault(),t.focus())};return document.addEventListener("keydown",d),()=>{document.removeEventListener("keydown",d),a&&document.contains(a)&&a.focus()}},[e,l,t])}}},e=>{e.O(0,[197,867,549,295,347,131,358],()=>e(e.s=1896)),_N_E=e.O()}]);
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[66],{1205:(e,s,n)=>{"use strict";n.d(s,{AppearanceProvider:()=>m,KP:()=>h,themeScript:()=>c});var a=n(3365),l=n(1521);let t=["small","normal","large","huge","giant"],r={theme:"light",textSize:"normal",highContrast:!1,reduceMotion:!1,underlineLinks:!1,strongFocus:!1},i="cop.appearance",c="\n(function () {\n try {\n var d = document.documentElement;\n var raw = localStorage.getItem('".concat(i,"');\n var a = raw ? JSON.parse(raw) : {};\n if (!a || typeof a !== 'object') a = {};\n d.dataset.theme = a.theme === 'dark' ? 'dark' : 'light';\n d.dataset.textsize = ").concat(JSON.stringify(t),".indexOf(a.textSize) >= 0 ? a.textSize : 'normal';\n d.dataset.contrast = a.highContrast ? 'high' : 'normal';\n d.dataset.motion = a.reduceMotion ? 'reduced' : 'normal';\n d.dataset.links = a.underlineLinks ? 'underline' : 'plain';\n d.dataset.focus = a.strongFocus ? 'strong' : 'normal';\n } catch (e) {}\n})();\n");function d(e){let s=document.documentElement;s.dataset.theme=e.theme,s.dataset.textsize=e.textSize,s.dataset.contrast=e.highContrast?"high":"normal",s.dataset.motion=e.reduceMotion?"reduced":"normal",s.dataset.links=e.underlineLinks?"underline":"plain",s.dataset.focus=e.strongFocus?"strong":"normal"}let o=(0,l.createContext)({appearance:r,set:()=>void 0,reset:()=>void 0,loaded:!1});function m(e){let{children:s}=e,[n,c]=(0,l.useState)(r),[m,h]=(0,l.useState)(!1);(0,l.useEffect)(()=>{let e=r;try{let s=window.localStorage.getItem(i);s?e=function(e){let s=e&&"object"==typeof e?e:{},n=(e,s)=>"boolean"==typeof e?e:s;return{theme:"dark"===s.theme?"dark":"light"===s.theme?"light":r.theme,textSize:t.includes(s.textSize)?s.textSize:r.textSize,highContrast:n(s.highContrast,r.highContrast),reduceMotion:n(s.reduceMotion,r.reduceMotion),underlineLinks:n(s.underlineLinks,r.underlineLinks),strongFocus:n(s.strongFocus,r.strongFocus)}}(JSON.parse(s)):window.matchMedia("(prefers-color-scheme: dark)").matches&&(e={...e,theme:"dark"}),window.matchMedia("(prefers-reduced-motion: reduce)").matches&&!s&&(e={...e,reduceMotion:!0})}catch(e){}c(e),d(e),h(!0)},[]);let u=(0,l.useCallback)(e=>{c(s=>{let n={...s,...e};d(n);try{window.localStorage.setItem(i,JSON.stringify(n))}catch(e){}return n})},[]),p=(0,l.useCallback)(()=>{c(r),d(r);try{window.localStorage.removeItem(i)}catch(e){}},[]);return(0,a.jsx)(o.Provider,{value:{appearance:n,set:u,reset:p,loaded:m},children:s})}function h(){return(0,l.useContext)(o)}},1702:(e,s,n)=>{"use strict";var a=n(9962);n.o(a,"usePathname")&&n.d(s,{usePathname:function(){return a.usePathname}}),n.o(a,"useSearchParams")&&n.d(s,{useSearchParams:function(){return a.useSearchParams}})},1772:(e,s,n)=>{Promise.resolve().then(n.bind(n,4269))},4269:(e,s,n)=>{"use strict";n.r(s),n.d(s,{default:()=>D});var a=n(3365),l=n(1521),t=n(1702),r=n(8197),i=n.n(r),c=n(5549),d=n(867),o=n(1910),m=n(3523),h=n(3374);function u(e){let s=e.trim().replace(/\\/g,"/").replace(/^\.\//,"").replace(/\/+$/,"");return""===s?".":s}function p(e){return e.split("\n").map(e=>e.trim()).filter(Boolean)}var v=n(1205),x=n(8848),j=n(4784),g=n(2244),f=n(2876),k=n(5132),b=n(1035),y=n(8934),N=n(4811),w=n(3041),S=n(7527),C=n(1366),F=n(2285);function D(){return(0,a.jsx)(l.Suspense,{fallback:null,children:(0,a.jsx)(H,{})})}function H(){var e;let{t:s}=(0,d.kj)(),n=null!=(e=(0,t.useSearchParams)().get("id"))?e:"",[r,o]=(0,l.useState)(null),[m,h]=(0,l.useState)([]),[u,p]=(0,l.useState)([]),[v,x]=(0,l.useState)(null),[j,g]=(0,l.useState)(""),[f,k]=(0,l.useState)(!1),b=(0,l.useRef)(null),y=(0,l.useRef)(0),N=(0,l.useCallback)(async()=>{if(!n)return;let e=++y.current;try{let s=await c.FH.session(n);if(e!==y.current)return;o(s),g("")}catch(s){if(e!==y.current)return;g(s.message)}},[n]),w=(0,l.useCallback)(()=>{b.current||(b.current=window.setTimeout(()=>{b.current=null,N()},400))},[N]);if((0,l.useEffect)(()=>{if(!n)return;c.FH.presets().then(p).catch(()=>void 0),c.FH.level1().then(x).catch(()=>void 0);let e=new EventSource(c.FH.streamUrl(n));return e.onopen=()=>k(!1),e.onmessage=e=>{let s;try{s=JSON.parse(e.data)}catch(e){return}"ping"!==s.type&&(h(e=>[...e.slice(-400),s]),w())},e.onerror=()=>{e.readyState===EventSource.CLOSED&&k(!0)},()=>{e.close()}},[n,w]),(0,S.z)(N,8e3,!!n),!n)return(0,a.jsx)("div",{className:"panel err",children:s("session.noId")});if(j&&!r)return(0,a.jsx)("div",{className:"panel err",children:j});if(!r)return(0,a.jsx)("div",{className:"panel muted",children:s("home.loading")});let C=r.tasks.filter(e=>"queued"===e.status).length;return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"crumbs",children:[(0,a.jsx)(i(),{href:"/",children:s("session.crumb")})," / ",r.name]}),j&&(0,a.jsx)("div",{className:"panel err",role:"alert",children:s("session.stale",{err:j})}),f&&!j&&(0,a.jsx)("div",{className:"panel muted small",role:"status",children:s("session.streamClosed")}),(0,a.jsx)(I,{session:r,queued:C,onChange:N}),(0,a.jsx)(J,{tasks:r.tasks}),(0,a.jsx)(M,{session:r,onChange:N}),(0,a.jsx)(T,{level1:v,sent:r.contractSent}),(0,a.jsx)(R,{session:r,onChange:N}),(0,a.jsx)(P,{session:r,onChange:N}),(0,a.jsx)(L,{session:r,onChange:N}),(0,a.jsxs)("div",{className:"panel",children:[(0,a.jsx)("h2",{children:s("tasks.title")}),(0,a.jsx)("p",{className:"muted small",children:s("tasks.hint")}),(0,a.jsx)(B,{session:r,onChange:N}),0===r.tasks.length&&(0,a.jsx)("div",{className:"muted",children:s("tasks.none")}),r.tasks.map((e,s)=>(0,a.jsx)(G,{session:r,task:e,index:s+1,presets:u,onChange:N},e.id))]}),(0,a.jsx)(E,{session:r}),(0,a.jsx)(U,{session:r,presets:u,onAdded:N,onPresetsChanged:()=>c.FH.presets().then(p)}),(0,a.jsx)(z,{events:m})]})}function I(e){var s;let{session:n,queued:t,onChange:r}=e,{t:i}=(0,d.kj)(),[o,m]=(0,l.useState)(""),[h,u]=(0,l.useState)("");(0,l.useEffect)(()=>{c.FH.models().then(e=>{var s;return u(null!=(s=e.defaultModel)?s:"")}).catch(()=>void 0)},[]);let[p,v]=(0,l.useState)(n.name),[x,j]=(0,l.useState)(null!=(s=n.conversationGroup)?s:"");(0,l.useEffect)(()=>v(n.name),[n.name]),(0,l.useEffect)(()=>{var e;return j(null!=(e=n.conversationGroup)?e:"")},[n.conversationGroup]);let g=(0,N.p)(),[f,k]=(0,l.useState)(!1),y=(0,l.useRef)(!1),w=async e=>{if(!y.current){y.current=!0,k(!0);try{await e()}catch(e){m(e.message)}finally{y.current=!1,k(!1),r()}}},S=async e=>{("unattended"!==e||g||await (0,b.Z)(i("session.unattendedConfirm")))&&await w(async()=>{var s;let a=await c.FH.start(n.id,e,n.planName);m(a.started?i("unattended"===e?"session.startedAuto":"session.startedStep"):i("session.notStarted",{reason:null!=(s=a.reason)?s:""}))})},C=async()=>{if(n.running)return void m(i("home.deleteRunning"));if(await (0,b.Z)(i("home.deleteConfirm",{name:n.name,n:n.tasks.length})))try{await c.FH.deleteSession(n.id),window.location.href="/"}catch(e){m(e.message)}},F=async()=>{var e;if(x.trim()!==(null!=(e=n.conversationGroup)?e:""))try{await c.FH.updateSession(n.id,{conversationGroup:x.trim()}),m(i("session.groupSaved")),r()}catch(e){m(e.message)}},D=n.running?i("state.running"):i("state.".concat(n.status));return(0,a.jsxs)("div",{className:"panel",children:[(0,a.jsxs)("div",{className:"row",children:[(0,a.jsx)("input",{type:"text",className:"grow","aria-label":i("home.col.name"),value:p,onChange:e=>v(e.target.value),onBlur:()=>void w(async()=>{p.trim()&&p!==n.name&&await c.FH.updateSession(n.id,{name:p})})}),(0,a.jsx)("span",{className:"badge ".concat(n.running?"running":""),children:D})]}),!n.running&&(0,a.jsxs)("div",{className:"run-choice",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("button",{className:"primary",onClick:()=>void S("unattended"),disabled:f||0===t,children:i("session.run",{n:t})}),(0,a.jsx)("p",{className:"why",children:i("session.runWhy")})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("button",{onClick:()=>void S("confirm"),disabled:f||0===t,children:i("session.runStep")}),(0,a.jsx)("p",{className:"why",children:i("session.runStepWhy")})]})]}),(0,a.jsxs)("div",{className:"row",style:{marginTop:10},children:[n.running&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("button",{className:"danger",onClick:()=>void w(async()=>{await c.FH.stop(n.id),m(i("session.stopping"))}),disabled:f,children:i("session.stop")}),"unattended"===n.runMode&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("span",{className:"badge waiting-approval",children:i("session.modeUnattended")}),(0,a.jsx)("button",{onClick:()=>void w(async()=>{await c.FH.setRunMode(n.id,"confirm"),m(i("session.askingAgain"))}),disabled:f,children:i("session.askAgain")})]})]}),(0,a.jsx)("span",{className:"muted small",children:o}),(0,a.jsx)("span",{className:"grow"}),(0,a.jsx)("button",{className:"quiet",onClick:()=>void C(),disabled:n.running,children:i("home.delete")}),n.chat?(0,a.jsx)("a",{href:n.chat.url,target:"_blank",rel:"noreferrer",className:"small",children:i("session.openChat",{name:n.chat.name})}):(0,a.jsx)("span",{className:"muted small",children:i("session.noChat")})]}),(0,a.jsx)("label",{htmlFor:"session-group",children:i("session.group")}),(0,a.jsx)("div",{className:"row",children:(0,a.jsx)("input",{id:"session-group",type:"text",className:"grow",value:x,placeholder:i("session.groupPlaceholder"),onChange:e=>j(e.target.value),onBlur:()=>void F(),disabled:n.running})}),(0,a.jsxs)("p",{className:"why",children:[i("session.groupWhy"),n.chat&&" ".concat(i("session.groupHasChat"))]}),(0,a.jsxs)("div",{className:"muted small",style:{marginTop:10},children:[i("session.willUseModel",{name:n.model||(h?i("model.followsDefault",{name:h}):i("model.default"))})," \xb7 ",n.mirror.enabled&&n.mirror.rootDir?i("session.willUseFiles",{root:n.mirror.rootDir,dirs:n.mirror.includeDirs.length?n.mirror.includeDirs.join(", "):"."}):(0,a.jsx)("span",{className:"err",children:i("session.noFiles")})]})]})}function T(e){var s;let{level1:n,sent:l}=e,{t}=(0,d.kj)();return(0,a.jsxs)("div",{className:"panel",children:[(0,a.jsxs)("div",{className:"row",children:[(0,a.jsx)("h2",{className:"grow",style:{margin:0},children:t("l1.title")}),(0,a.jsx)("span",{className:"badge",children:t(l?"l1.sent":"l1.notSent")}),(0,a.jsx)(i(),{href:"/level1",className:"small",children:t("l1.edit")})]}),(0,a.jsxs)("p",{className:"muted small",style:{marginBottom:6},children:[t("l1.hint"),(null==n?void 0:n.customised)?" ".concat(t("l1.customised")):""]}),(0,a.jsxs)("details",{children:[(0,a.jsx)("summary",{children:t("l1.show")}),(0,a.jsx)("pre",{className:"tall",children:null!=(s=null==n?void 0:n.content)?s:"…"})]})]})}function M(e){var s,n,t,r;let{session:i,onChange:o}=e,{t:m}=(0,d.kj)(),h=(0,d.W3)(),[u,p]=(0,l.useState)(null),[v,j]=(0,l.useState)(!1),[g,f]=(0,l.useState)("");(0,l.useEffect)(()=>{c.FH.models().then(p).catch(()=>void 0)},[]);let k=async e=>{try{await c.FH.updateSession(i.id,{model:e}),f(e?m("model.saved",{name:e}):m("model.savedDefault")),o()}catch(e){f(e.message)}},y=async()=>{try{let e=await c.FH.setDefaultModel(w);p(s=>s?{...s,defaultModel:e.defaultModel}:s),f(e.defaultModel?m("model.defaultSaved",{name:e.defaultModel}):m("model.defaultCleared"))}catch(e){f(e.message)}},N=async()=>{if(await (0,b.Z)(m("model.refreshConfirm"))){j(!0),f(m("model.refreshing"));try{var e;let s=await c.FH.refreshModels();p(s),f(0===s.options.length?null!=(e=s.note)?e:m("model.none"):m("model.refreshed",{n:s.options.length}))}catch(e){f(e.message)}finally{j(!1)}}},w=null!=(s=i.model)?s:"",S=null!=(n=null==u?void 0:u.options)?n:[],C=S.some(e=>e.name===w),F=S.filter(e=>!e.group),D=new Map;for(let e of S)e.group&&D.set(e.group,[...null!=(t=D.get(e.group))?t:[],e]);return(0,a.jsxs)("div",{className:"panel",children:[(0,a.jsxs)("div",{className:"row",children:[(0,a.jsx)("h2",{className:"grow",style:{margin:0},children:m("model.title")}),i.modelInUse&&(0,a.jsx)("span",{className:"chip",children:m("model.lastUsed",{name:i.modelInUse})})]}),(0,a.jsx)("p",{className:"muted small",children:m("model.hint")}),(0,a.jsxs)("div",{className:"row",children:[(0,a.jsxs)("select",{"aria-label":m("model.title"),value:w,disabled:i.running,onChange:e=>void k(e.target.value),style:{width:"auto",minWidth:260},children:[(0,a.jsx)("option",{value:"",children:(null==u?void 0:u.defaultModel)?m("model.followsDefault",{name:u.defaultModel}):m("model.default")}),w&&!C&&(0,a.jsx)("option",{value:w,children:m("model.notInList",{name:w})}),F.map(e=>(0,a.jsxs)("option",{value:e.name,disabled:e.disabled,children:[e.name,e.disabled?" — ".concat(m("model.unavailable")):""]},e.name)),[...D.entries()].map(e=>{let[s,n]=e;return(0,a.jsx)("optgroup",{label:s,children:n.map(e=>(0,a.jsxs)("option",{value:e.name,disabled:e.disabled,children:[e.name,e.disabled?" — ".concat(m("model.unavailable")):""]},e.name))},s)})]}),(0,a.jsx)("button",{onClick:()=>void N(),disabled:v||i.running,children:m("model.refresh")}),(0,a.jsx)("span",{className:"muted small",role:"status",children:g})]}),(0,a.jsx)(x.L,{current:w,onUse:e=>void k(e)}),(0,a.jsxs)("div",{className:"row",style:{marginTop:8},children:[(0,a.jsx)("span",{className:"muted small",children:(null==u?void 0:u.defaultModel)?m("model.defaultIs",{name:u.defaultModel}):m("model.defaultIsNone")}),(0,a.jsx)("button",{onClick:()=>void y(),disabled:w===(null!=(r=null==u?void 0:u.defaultModel)?r:""),children:w?m("model.makeDefault",{name:w}):m("model.clearDefault")})]}),(null==u?void 0:u.readAt)?(0,a.jsxs)("p",{className:"muted small",style:{marginTop:8},children:[m("model.readAt",{t:h(u.readAt),n:u.options.length}),u.current?" ".concat(m("model.chatWasOn",{name:u.current})):"",u.note?" ".concat(u.note):""]}):(0,a.jsx)("p",{className:"muted small",style:{marginTop:8},children:m("model.neverRead")}),S.length>0&&(0,a.jsxs)("details",{children:[(0,a.jsx)("summary",{children:m("model.showDetails")}),(0,a.jsx)("pre",{className:"tall",children:S.map(e=>"".concat(e.selected?"*":" "," ").concat(e.group?"".concat(e.group," > "):"").concat(e.name)+"".concat(e.disabled?" [unavailable]":"","\n ").concat(e.raw.replace(/\n/g," | "))).join("\n")})]})]})}function P(e){var s,n;let{session:t,onChange:r}=e,{t:i}=(0,d.kj)(),o=null!=(s=t.review)?s:{enabled:!0,model:""},[m,h]=(0,l.useState)(o.enabled),[u,p]=(0,l.useState)(null!=(n=o.model)?n:""),[v,g]=(0,l.useState)(""),[f,k]=(0,l.useState)(!1),[b,y]=(0,l.useState)("");(0,l.useEffect)(()=>{c.FH.models().then(e=>{var s;return y(null!=(s=e.defaultReviewModel)?s:"")}).catch(()=>void 0)},[]);let N=async()=>{k(!0),g("");try{await c.FH.updateSession(t.id,{review:{enabled:m,model:u}}),g(i("review.saved")),r()}catch(e){g(e.message)}finally{k(!1)}};return(0,a.jsxs)("div",{className:"panel",children:[(0,a.jsxs)("div",{className:"row",children:[(0,a.jsx)("h2",{className:"grow",style:{margin:0},children:i("review.title")}),(0,a.jsx)("span",{className:"badge ".concat(m?"done":""),children:m?i("review.on"):i("review.off")})]}),(0,a.jsx)("p",{className:"muted small",children:i("review.hint")}),(0,a.jsxs)("div",{className:"option",children:[(0,a.jsxs)("label",{children:[(0,a.jsx)("input",{type:"checkbox",checked:m,onChange:e=>h(e.target.checked),disabled:t.running}),(0,a.jsx)("span",{children:i("review.enable")})]}),(0,a.jsx)("p",{className:"why",children:i("review.enableWhy")})]}),(0,a.jsx)("label",{htmlFor:"review-model",children:i("review.modelField")}),(0,a.jsx)("div",{className:"row",children:(0,a.jsx)(j.Y,{id:"review-model",chosen:u,onChange:p,none:b?i("model.followsDefault",{name:b}):i("review.modelSame"),disabled:t.running||!m})}),(0,a.jsx)("p",{className:"why",children:i("review.modelWhy")}),(0,a.jsx)(x.z4,{current:u,onUse:e=>p(e)}),(0,a.jsxs)("div",{className:"row",style:{marginTop:10},children:[(0,a.jsx)("button",{className:"primary",onClick:()=>void N(),disabled:f||t.running,children:i("review.save")}),v&&(0,a.jsx)("span",{className:"muted small",children:v})]})]})}function R(e){var s,n,t,r,i,o,m,h,u,p,v,j,g,f,k,b,y;let{session:N,onChange:w}=e,{t:S}=(0,d.kj)(),C=null!=(n=N.vcs)?n:{enabled:!0,repoDir:"",branchMode:"per-task",commitOnFinish:!0,branchPrefix:"cop/"},[D,H]=(0,l.useState)(C.repoDir),[I,T]=(0,l.useState)(null),[M,P]=(0,l.useState)(""),[R,L]=(0,l.useState)(!1),W=JSON.stringify(C),[B,O]=(0,l.useState)(null),[E,A]=(0,l.useState)(null!=(t=C.branchName)?t:"");(0,l.useEffect)(()=>{var e;return A(null!=(e=JSON.parse(W).branchName)?e:"")},[W]);let[U,G]=(0,l.useState)(null!=(r=C.baseBranch)?r:"");(0,l.useEffect)(()=>{var e;return G(null!=(e=JSON.parse(W).baseBranch)?e:"")},[W]);let[z,q]=(0,l.useState)(null!=(i=C.existingBranch)?i:"");(0,l.useEffect)(()=>{var e;return q(null!=(e=JSON.parse(W).existingBranch)?e:"")},[W]);let J=null!=(o=C.startFrom)?o:"head";(0,l.useEffect)(()=>{H(JSON.parse(W).repoDir)},[W]);let Z=JSON.parse(W).repoDir||N.mirror.rootDir||"";(0,l.useEffect)(()=>{let e=!1;return Z.trim()?(c.FH.repoCheck(Z).then(s=>{var n;e||O(s.ok?null:null!=(n=s.problem)?n:null)}).catch(()=>{e||O(null)}),()=>{e=!0}):void O(null)},[Z]);let _=(0,l.useCallback)(()=>{c.FH.vcsStatus(N.id).then(T).catch(()=>T(null))},[N.id]);(0,l.useEffect)(_,[_,W]);let K=async e=>{try{await c.FH.updateSession(N.id,{vcs:e}),P(S("vcs.saved")),w(),_()}catch(e){P(e.message)}},Y=async()=>{L(!0),P(S("mirror.browsing"));try{let s=await c.FH.browseFolder(D.trim()||N.mirror.rootDir||void 0);if(s.ok)H(s.path),await K({repoDir:s.path});else{var e;P(s.cancelled?S("mirror.browseCancelled"):null!=(e=s.reason)?e:"")}}catch(e){P(e.message)}finally{L(!1)}},$=C.repoDir||N.mirror.rootDir||"",Q=""!==$.trim()&&null===B;return(0,a.jsxs)("div",{className:"panel",children:[(0,a.jsxs)("div",{className:"row",children:[(0,a.jsx)("h2",{className:"grow",style:{margin:0},children:S("vcs.title")}),(0,a.jsx)("span",{className:"badge ".concat(C.enabled?"done":""),children:C.enabled?S("vcs.on"):S("vcs.off")})]}),(0,a.jsx)("p",{className:"muted small",children:S("vcs.hint")}),(0,a.jsx)("label",{htmlFor:"vcs-root",children:S("vcs.repoField")}),(0,a.jsxs)("div",{className:"row",children:[(0,a.jsx)("input",{id:"vcs-root",type:"text",className:"grow",value:D,onChange:e=>H(e.target.value),onBlur:()=>D.trim()!==C.repoDir&&void K({repoDir:D.trim()}),placeholder:N.mirror.rootDir||"C:\\Projects\\my-app",disabled:N.running}),(0,a.jsx)("button",{onClick:()=>void Y(),disabled:R||N.running,children:S("mirror.browse")})]}),(0,a.jsx)(x.H4,{current:D,onUse:e=>{H(e),K({repoDir:e})}}),B&&(0,a.jsxs)("div",{className:"notice caution",style:{marginTop:8},children:[(0,a.jsx)("strong",{children:S("vcs.noRepo")}),(0,a.jsx)("div",{className:"small",style:{marginTop:4},children:B}),(0,a.jsx)("div",{className:"muted small",style:{marginTop:6},children:S("vcs.noRepoHow")})]}),!B&&""!==$.trim()&&(0,a.jsx)("p",{className:"muted small",style:{marginTop:4},children:S("vcs.repoOk")}),""===$.trim()&&(0,a.jsx)("p",{className:"muted small",style:{marginTop:4},children:S("vcs.pickFirst")}),(0,a.jsxs)("div",{className:"option".concat(Q||C.enabled?"":" warned"),children:[(0,a.jsxs)("label",{children:[(0,a.jsx)("input",{type:"checkbox",checked:C.enabled,onChange:e=>void K({enabled:e.target.checked}),disabled:N.running||!Q&&!C.enabled}),(0,a.jsx)("span",{children:S("vcs.enable")})]}),(0,a.jsx)("p",{className:"why",children:S("vcs.enableWhy")})]}),C.enabled&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("div",{className:"muted small",style:{marginTop:4},children:$?S("vcs.repoIs",{dir:$}):S("vcs.repoNone")}),$&&!B&&(0,a.jsx)(F.b,{dir:$}),(0,a.jsx)("h3",{children:S("vcs.branches")}),"existing-branch"===J&&(0,a.jsx)("p",{className:"muted small",children:S("vcs.branchesExisting",{branch:C.existingBranch||"…"})}),(0,a.jsxs)("div",{className:"option",children:[(0,a.jsxs)("label",{children:[(0,a.jsx)("input",{type:"radio",name:"branchMode",checked:"per-task"===C.branchMode,onChange:()=>void K({branchMode:"per-task"}),disabled:N.running}),(0,a.jsx)("span",{children:S("vcs.perTask")})]}),(0,a.jsx)("p",{className:"why",children:S("vcs.perTaskWhy")})]}),(0,a.jsxs)("div",{className:"option",children:[(0,a.jsxs)("label",{children:[(0,a.jsx)("input",{type:"radio",name:"branchMode",checked:"per-session"===C.branchMode,onChange:()=>void K({branchMode:"per-session"}),disabled:N.running}),(0,a.jsx)("span",{children:S("vcs.perSession")})]}),(0,a.jsx)("p",{className:"why",children:S("vcs.perSessionWhy")})]}),"per-session"===C.branchMode&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("label",{htmlFor:"vcs-branch-name",children:S("vcs.branchName")}),(0,a.jsx)("input",{id:"vcs-branch-name",type:"text",value:E,onChange:e=>A(e.target.value),onBlur:()=>{var e;return E.trim()!==(null!=(e=C.branchName)?e:"")&&void K({branchName:E.trim()})},placeholder:N.name,disabled:N.running}),(0,a.jsx)("p",{className:"why",children:S("vcs.branchNameWhy")})]}),(0,a.jsx)("h3",{children:S("vcs.startFrom")}),(0,a.jsxs)("div",{className:"option",children:[(0,a.jsxs)("label",{children:[(0,a.jsx)("input",{type:"radio",name:"startFrom",checked:"branch"===J,onChange:()=>void K({startFrom:"branch"}),disabled:N.running}),(0,a.jsx)("span",{children:S("vcs.startBranch")})]}),(0,a.jsx)("p",{className:"why",children:S("vcs.startBranchWhy")})]}),(0,a.jsxs)("div",{className:"option",children:[(0,a.jsxs)("label",{children:[(0,a.jsx)("input",{type:"radio",name:"startFrom",checked:"previous-session"===J,onChange:()=>void K({startFrom:"previous-session"}),disabled:N.running}),(0,a.jsx)("span",{children:S("vcs.startPrevious")})]}),(0,a.jsx)("p",{className:"why",children:S("vcs.startPreviousWhy")})]}),(0,a.jsxs)("div",{className:"option",children:[(0,a.jsxs)("label",{children:[(0,a.jsx)("input",{type:"radio",name:"startFrom",checked:"head"===J,onChange:()=>void K({startFrom:"head"}),disabled:N.running}),(0,a.jsx)("span",{children:S("vcs.startHead")})]}),(0,a.jsx)("p",{className:"why",children:S("vcs.startHeadWhy")})]}),(0,a.jsxs)("div",{className:"option",children:[(0,a.jsxs)("label",{children:[(0,a.jsx)("input",{type:"radio",name:"startFrom",checked:"existing-branch"===J,onChange:()=>void K({startFrom:"existing-branch"}),disabled:N.running}),(0,a.jsx)("span",{children:S("vcs.startExisting")})]}),(0,a.jsx)("p",{className:"why",children:S("vcs.startExistingWhy")})]}),"existing-branch"===J&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("label",{htmlFor:"vcs-existing-branch",children:S("vcs.existingBranch")}),(0,a.jsx)("input",{id:"vcs-existing-branch",type:"text",list:"vcs-local-branches",value:z,onChange:e=>q(e.target.value),onBlur:()=>{var e;return z.trim()!==(null!=(e=C.existingBranch)?e:"")&&void K({existingBranch:z.trim()})},disabled:N.running}),(0,a.jsx)("datalist",{id:"vcs-local-branches",children:(null!=(m=null==I?void 0:I.branches)?m:[]).map(e=>(0,a.jsx)("option",{value:e},e))}),(0,a.jsx)("p",{className:"why",children:S("vcs.existingBranchWhy")}),C.existingBranch&&(null==I?void 0:I.branches)&&!I.branches.includes(C.existingBranch)&&(0,a.jsx)("p",{className:"err small",children:S("vcs.existingBranchMissing",{branch:C.existingBranch})})]}),("branch"===J||"previous-session"===J)&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("label",{htmlFor:"vcs-base-branch",children:S("vcs.baseBranch")}),(0,a.jsx)("input",{id:"vcs-base-branch",type:"text",value:U,onChange:e=>G(e.target.value),onBlur:()=>{var e;return U.trim()!==(null!=(e=C.baseBranch)?e:"")&&void K({baseBranch:U.trim()})},placeholder:"main",disabled:N.running}),(0,a.jsx)("p",{className:"why",children:S("vcs.baseBranchWhy")})]}),N.vcsStart&&(0,a.jsxs)("p",{className:"muted small",children:["existing-branch"===N.vcsStart.kind?S("vcs.startedExisting",{branch:null!=(h=N.vcsStart.branch)?h:"",commit:N.vcsStart.commit.slice(0,8)}):"previous-session"===N.vcsStart.kind?S("vcs.startedPrevious",{name:null!=(u=null==(s=N.vcsStart.fromSession)?void 0:s.name)?u:"",branch:null!=(p=N.vcsStart.branch)?p:"",commit:N.vcsStart.commit.slice(0,8)}):"branch"===N.vcsStart.kind?S("vcs.startedBranch",{branch:null!=(v=N.vcsStart.branch)?v:"",commit:N.vcsStart.commit.slice(0,8)}):S("vcs.startedHead",{commit:N.vcsStart.commit.slice(0,8)}),N.vcsStart.note?" — ".concat(N.vcsStart.note):"",N.vcsStart.update&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("br",{}),"updated"===N.vcsStart.update.outcome?S("vcs.updated",{branch:N.vcsStart.update.branch,remote:null!=(j=N.vcsStart.update.remote)?j:"",from:(null!=(g=N.vcsStart.update.from)?g:"").slice(0,8),to:(null!=(f=N.vcsStart.update.to)?f:"").slice(0,8)}):"up-to-date"===N.vcsStart.update.outcome?S("vcs.upToDate",{branch:N.vcsStart.update.branch,remote:null!=(k=N.vcsStart.update.remote)?k:""}):S("vcs.notUpdated",{branch:N.vcsStart.update.branch,why:null!=(b=N.vcsStart.update.detail)?b:N.vcsStart.update.outcome})]})]}),"head"!==J&&(0,a.jsxs)("div",{className:"option",children:[(0,a.jsxs)("label",{children:[(0,a.jsx)("input",{type:"checkbox",checked:!1!==C.updateFromRemote,onChange:e=>void K({updateFromRemote:e.target.checked}),disabled:N.running}),(0,a.jsx)("span",{children:S("vcs.updateFromRemote")})]}),(0,a.jsx)("p",{className:"why",children:S("vcs.updateFromRemoteWhy")})]}),(0,a.jsxs)("div",{className:"option",children:[(0,a.jsxs)("label",{children:[(0,a.jsx)("input",{type:"checkbox",checked:C.commitOnFinish,onChange:e=>void K({commitOnFinish:e.target.checked}),disabled:N.running}),(0,a.jsx)("span",{children:S("vcs.commit")})]}),(0,a.jsx)("p",{className:"why",children:S("vcs.commitWhy")})]}),I&&!I.ok&&(0,a.jsxs)("div",{className:"notice caution",role:"status",children:[(0,a.jsx)("strong",{children:S("vcs.notReady")})," ",I.problem]}),(null==I?void 0:I.ok)&&(0,a.jsx)("div",{className:"muted small",children:S("vcs.ready",{branch:null!=(y=I.branch)?y:"—",dir:I.repoDir})}),(null==I?void 0:I.ok)&&I.work&&I.work.branches.length>0&&(0,a.jsxs)("div",{className:"muted small",children:["per-session"===I.work.mode&&I.work.complete?S("vcs.completeOn",{branch:I.work.complete}):S("vcs.noSingleBranch",{n:I.work.branches.length}),"per-task"===I.work.mode&&(0,a.jsx)("ul",{style:{margin:"4px 0",paddingLeft:20},children:I.work.branches.map(e=>(0,a.jsxs)("li",{children:[(0,a.jsx)("code",{children:e.branch})," — ",e.title,e.commit?"":" (".concat(S("vcs.taskNoFiles"),")")]},e.branch))})]}),(0,a.jsx)("p",{className:"muted small",children:S("vcs.pushIsYours")})]}),(0,a.jsx)("div",{className:"muted small",role:"status",children:M})]})}function L(e){var s,n,t,r;let{session:i,onChange:o}=e,{t:m}=(0,d.kj)(),[h,v]=(0,l.useState)(i.mirror.enabled),[j,f]=(0,l.useState)(i.mirror.rootDir),[k,y]=(0,l.useState)(i.mirror.includeDirs.join("\n")),[N,w]=(0,l.useState)(i.mirror.excludeDirs.join("\n")),[S,C]=(0,l.useState)(null==(s=i.mirror.respectGitignore)||s),[F,D]=(0,l.useState)(null!=(n=i.mirror.includeEnvFiles)&&n),[H,I]=(0,l.useState)(null),[T,M]=(0,l.useState)(null),[P,R]=(0,l.useState)(""),[L,B]=(0,l.useState)(""),[O,E]=(0,l.useState)([]),A=JSON.stringify(i.mirror);(0,l.useEffect)(()=>{var e,s;let n=JSON.parse(A);v(n.enabled),f(n.rootDir),y(n.includeDirs.join("\n")),w(n.excludeDirs.join("\n")),C(null==(e=n.respectGitignore)||e),D(null!=(s=n.includeEnvFiles)&&s)},[A]),(0,l.useEffect)(()=>{c.FH.doctor().then(e=>{var s;return E(null!=(s=e.alwaysIgnoredDirs)?s:[])}).catch(()=>void 0)},[]);let U=p(k),G=p(N),z=function(e,s){let n=e.map(u).filter(Boolean),a=s.map(u).filter(Boolean),l=[];for(let e of n)for(let s of a)if(e.toLowerCase()===s.toLowerCase())l.push({include:e,exclude:s,kind:"same"});else("."===s?"."!==e:e.toLowerCase().startsWith("".concat(s.toLowerCase(),"/")))&&l.push({include:e,exclude:s,kind:"excluded-parent"});return l}(U,G),q={rootDir:j.trim(),includeDirs:U,excludeDirs:G,respectGitignore:S,includeEnvFiles:F},J=h&&!q.rootDir,Z=z.length>0||J,_=JSON.stringify({enabled:i.mirror.enabled,rootDir:i.mirror.rootDir,includeDirs:i.mirror.includeDirs,excludeDirs:i.mirror.excludeDirs,respectGitignore:null==(t=i.mirror.respectGitignore)||t,includeEnvFiles:null!=(r=i.mirror.includeEnvFiles)&&r}),K=JSON.stringify({enabled:h,...q}),Y=async()=>{if(!Z)try{await c.FH.updateSession(i.id,{mirror:{enabled:h,...q}}),B(m("mirror.saved")),o()}catch(e){B(e.message)}},$=async()=>{try{I(await c.FH.dirs(j,S)),B("")}catch(e){B(e.message)}},Q=async()=>{R("browse"),B(m("mirror.browsing"));try{let s=await c.FH.browseFolder(j.trim()||void 0);if(s.ok)f(s.path),I(null),M(null),B("");else{var e;B(s.cancelled?m("mirror.browseCancelled"):null!=(e=s.reason)?e:"")}}catch(e){B(e.message)}finally{R("")}},V=async()=>{if(!q.rootDir)return void B(m("mirror.needRoot"));R("check"),B(m("mirror.checking"));try{M(await c.FH.previewMirror(q)),B("")}catch(e){M(null),B(e.message)}finally{R("")}},X=async e=>{(!e||await (0,b.Z)(m("mirror.envWarn")))&&(D(e),M(null))};return(0,a.jsxs)("div",{className:"panel",children:[(0,a.jsxs)("div",{className:"row",children:[(0,a.jsx)("h2",{className:"grow",style:{margin:0},children:m("mirror.title")}),(0,a.jsx)("span",{className:"badge ".concat(i.mirror.enabled?"done":""),children:i.mirror.enabled?m("mirror.stateOn"):m("mirror.stateOff")})]}),(0,a.jsx)("p",{className:"muted small",children:m("mirror.hint",{example:"src--test--a.spec.ts.txt"})}),(0,a.jsx)("div",{className:"option",children:(0,a.jsxs)("label",{children:[(0,a.jsx)("input",{type:"checkbox",checked:h,onChange:e=>v(e.target.checked)}),(0,a.jsx)("span",{children:m("mirror.enable")})]})}),(0,a.jsx)("label",{htmlFor:"mirror-root",children:m("mirror.root")}),(0,a.jsxs)("div",{className:"row",children:[(0,a.jsx)("input",{id:"mirror-root",type:"text",className:"grow",value:j,onChange:e=>{f(e.target.value),M(null)},placeholder:"C:\\Projects\\my-app"}),(0,a.jsx)("button",{onClick:()=>void Q(),disabled:"browse"===P,children:m("mirror.browse")}),(0,a.jsx)("button",{onClick:()=>void $(),disabled:!j.trim(),children:m("mirror.listDirs")})]}),(0,a.jsx)("div",{className:"muted small",style:{marginTop:4},children:m("mirror.rootHint")}),(0,a.jsx)(x.H4,{current:j,onUse:e=>{f(e),M(null)}}),H&&(0,a.jsx)("div",{className:"small muted",style:{margin:"6px 0"},children:0===H.length?m("mirror.noDirs"):H.join(" \xb7 ")}),(0,a.jsx)("h3",{children:m("mirror.rules")}),(0,a.jsxs)("div",{className:"option",children:[(0,a.jsxs)("label",{children:[(0,a.jsx)("input",{type:"checkbox",checked:S,onChange:e=>{C(e.target.checked),M(null)}}),(0,a.jsx)("span",{children:m("mirror.gitignore")})]}),(0,a.jsx)("p",{className:"why",children:m("mirror.gitignoreWhy")})]}),(0,a.jsxs)("div",{className:"option".concat(F?" warned":""),children:[(0,a.jsxs)("label",{children:[(0,a.jsx)("input",{type:"checkbox",checked:F,onChange:e=>X(e.target.checked)}),(0,a.jsx)("span",{children:m("mirror.env")})]}),(0,a.jsx)("p",{className:"why",children:m("mirror.envWhy")}),F&&(0,a.jsx)("p",{className:"why",children:(0,a.jsx)("strong",{children:m("mirror.envOn")})})]}),O.length>0&&(0,a.jsx)("p",{className:"muted small",children:m("mirror.alwaysOut",{dirs:O.join(", ")})}),(0,a.jsxs)("div",{className:"row",style:{alignItems:"flex-start"},children:[(0,a.jsxs)("div",{className:"grow",children:[(0,a.jsx)("label",{htmlFor:"mirror-include",children:m("mirror.include")}),(0,a.jsx)("textarea",{id:"mirror-include",value:k,onChange:e=>{y(e.target.value),M(null)},placeholder:"src\ntests",style:{minHeight:80},"aria-invalid":z.length>0})]}),(0,a.jsxs)("div",{className:"grow",children:[(0,a.jsx)("label",{htmlFor:"mirror-exclude",children:m("mirror.exclude")}),(0,a.jsx)("textarea",{id:"mirror-exclude",value:N,onChange:e=>{w(e.target.value),M(null)},placeholder:"src/generated",style:{minHeight:80},"aria-invalid":z.length>0})]})]}),(0,a.jsx)(g.k,{rootDir:j,respectGitignore:S,includeEnvFiles:F,include:k.split("\n"),exclude:N.split("\n"),onChange:(e,s)=>{y(e.join("\n")),w(s.join("\n")),M(null)}}),z.length>0&&(0,a.jsxs)("div",{className:"notice",role:"alert",children:[(0,a.jsx)("strong",{children:m("mirror.conflict")}),(0,a.jsx)("ul",{children:z.map((e,s)=>(0,a.jsx)("li",{children:"same"===e.kind?m("mirror.conflictSame",{dir:e.include}):m("mirror.conflictParent",{include:e.include,exclude:e.exclude})},s))}),(0,a.jsx)("div",{style:{marginTop:6},children:m("mirror.conflictFix")})]}),J&&(0,a.jsx)("div",{className:"notice caution",role:"alert",children:(0,a.jsx)("strong",{children:m("mirror.needRoot")})}),K!==_&&(0,a.jsxs)("div",{className:"notice caution",role:"status",children:[(0,a.jsx)("strong",{children:m("mirror.unsaved")})," ",m("mirror.unsavedWhy")]}),(0,a.jsxs)("div",{className:"row",style:{marginTop:10},children:[(0,a.jsx)("button",{className:"primary",onClick:()=>void Y(),disabled:Z,children:m("mirror.save")}),(0,a.jsx)("button",{onClick:()=>void V(),disabled:z.length>0||"check"===P,children:m("mirror.check")}),(0,a.jsx)("span",{className:"muted small",role:"status",children:L})]}),T&&(0,a.jsx)(W,{preview:T})]})}function W(e){let{preview:s}=e,{t:n}=(0,d.kj)();return 0===s.files.length?(0,a.jsx)("div",{className:"notice caution",style:{marginTop:10},children:(0,a.jsx)("strong",{children:n("mirror.checkedNone")})}):(0,a.jsxs)("div",{className:"notice calm",style:{marginTop:10},children:[(0,a.jsx)("strong",{children:n("mirror.checked",{files:s.files.length,size:(0,c.zi)(s.totalBytes)})})," ",s.envFiles.length>0&&(0,a.jsx)("span",{className:"err",children:n("mirror.checkedEnv",{n:s.envFiles.length})})," ",s.skipped.length>0&&(0,a.jsx)("span",{className:"muted",children:n("mirror.checkedSkipped",{n:s.skipped.length})}),(0,a.jsxs)("details",{style:{marginTop:6},children:[(0,a.jsx)("summary",{children:n("mirror.showFiles")}),(0,a.jsx)("pre",{className:"tall",children:s.files.join("\n")})]}),s.skipped.length>0&&(0,a.jsxs)("details",{children:[(0,a.jsx)("summary",{children:n("mirror.showSkipped")}),(0,a.jsx)("pre",{className:"tall",children:s.skipped.map(e=>"".concat(e.relPath," — ").concat(e.reason)).join("\n")})]})]})}function B(e){var s;let{session:n,onChange:t}=e,{t:r}=(0,d.kj)(),[i,o]=(0,l.useState)(""),m=null!=(s=n.onFailure)?s:"stop",h=async e=>{if(e!==m)try{await c.FH.updateSession(n.id,{onFailure:e}),o(r("stop"===e?"chain.savedStop":"chain.savedContinue")),t()}catch(e){o(e.message)}};return(0,a.jsxs)("fieldset",{style:{border:0,padding:0,margin:"10px 0 14px"},children:[(0,a.jsx)("legend",{className:"muted small",style:{padding:0},children:r("chain.title")}),(0,a.jsxs)("div",{className:"option",children:[(0,a.jsxs)("label",{children:[(0,a.jsx)("input",{type:"radio",name:"chain",checked:"stop"===m,onChange:()=>void h("stop"),disabled:n.running}),(0,a.jsx)("span",{children:r("chain.stop")})]}),(0,a.jsx)("p",{className:"why",children:r("chain.stopWhy")})]}),(0,a.jsxs)("div",{className:"option",children:[(0,a.jsxs)("label",{children:[(0,a.jsx)("input",{type:"radio",name:"chain",checked:"continue"===m,onChange:()=>void h("continue"),disabled:n.running}),(0,a.jsx)("span",{children:r("chain.continue")})]}),(0,a.jsx)("p",{className:"why",children:r("chain.continueWhy")})]}),i&&(0,a.jsx)("div",{className:"muted small",role:"status",children:i}),n.running&&(0,a.jsx)("div",{className:"muted small",children:r("chain.locked")})]})}function O(e){let{value:s,onChange:n,presets:t,onPresetsChanged:r}=e,{t:i}=(0,d.kj)(),o=(0,l.useId)(),[m,h]=(0,l.useState)(""),u=async()=>{let e=prompt(i("l2.saveAsPrompt"));if(e)try{await c.FH.savePreset(e,s),h(i("l2.savedAs",{name:e})),null==r||r()}catch(e){h(e.message)}};return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"row",children:[(0,a.jsx)("label",{className:"grow",style:{margin:0},htmlFor:"".concat(o,"-text"),children:i("l2.label")}),(0,a.jsxs)("select",{value:"","aria-label":i("l2.loadPreset"),onChange:e=>{let s=t.find(s=>s.name===e.target.value);s&&n(s.content)},children:[(0,a.jsx)("option",{value:"",children:i("l2.loadPreset")}),t.map(e=>(0,a.jsx)("option",{value:e.name,children:e.name},e.name))]}),(0,a.jsx)("button",{onClick:()=>void u(),disabled:!s.trim(),children:i("l2.saveAs")})]}),(0,a.jsx)("textarea",{id:"".concat(o,"-text"),className:"prose",value:s,onChange:e=>n(e.target.value),placeholder:i("l2.placeholder"),style:{minHeight:140,marginTop:10}}),m&&(0,a.jsx)("div",{className:"muted small",children:m})]})}function E(e){let{session:s}=e,{t:n}=(0,d.kj)(),t=(0,d.W3)(),r=s.tasks.filter(e=>"queued"!==e.status),[i,o]=(0,l.useState)([]),m=i.length>0?i:r.map(e=>e.id),h=e=>(0,c.ub)("".concat(c.nC,"/sessions/").concat(s.id,"/export?variant=").concat(e)+(i.length>0?"&tasks=".concat(encodeURIComponent(i.join(","))):""));return(0,a.jsxs)("div",{className:"panel",children:[(0,a.jsx)("h2",{children:n("export.title")}),(0,a.jsx)("p",{className:"muted small",children:n("export.hint")}),0===r.length?(0,a.jsx)("div",{className:"empty",children:n("export.nothing")}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"row",style:{marginBottom:6},children:[(0,a.jsx)("button",{className:"quiet",onClick:()=>o(r.map(e=>e.id)),children:n("export.all")}),(0,a.jsx)("button",{className:"quiet",onClick:()=>o([]),children:n("export.none")}),(0,a.jsx)("span",{className:"muted small",children:i.length>0?n("export.selected",{n:i.length}):n("export.allOf",{n:r.length})})]}),r.map(e=>{var s,l,r,c,d;return(0,a.jsx)("div",{className:"option",style:{margin:"6px 0"},children:(0,a.jsxs)("label",{children:[(0,a.jsx)("input",{type:"checkbox",checked:i.includes(e.id),onChange:()=>{let s;return s=e.id,o(e=>e.includes(s)?e.filter(e=>e!==s):[...e,s])}}),(0,a.jsxs)("span",{children:[e.title," ",(0,a.jsx)("span",{className:"badge ".concat(e.status),children:n("status.".concat(e.status))})," ",e.readOnly&&(0,a.jsx)("span",{className:"chip",children:n("task.readOnly")})," ",(null!=(l=null==(s=e.scope)?void 0:s.length)?l:0)>0&&(0,a.jsx)("span",{className:"chip",children:n("task.scope",{paths:(null!=(r=e.scope)?r:[]).join(", ")})})," ",(0,a.jsx)("span",{className:"muted small",children:t(null!=(d=null!=(c=e.finishedAt)?c:e.startedAt)?d:e.createdAt)})]})]})},e.id)}),(0,a.jsxs)("div",{className:"row",style:{marginTop:10},children:[(0,a.jsx)("a",{className:"button-link",href:h("outcome"),download:!0,children:n("export.outcome",{n:m.length})}),(0,a.jsx)("a",{className:"button-link",href:h("full"),download:!0,children:n("export.full",{n:m.length})})]}),(0,a.jsx)("p",{className:"muted small",style:{marginTop:8},children:n("export.outcomeWhy")})]})]})}function A(e){let{handoff:s}=e,{t:n}=(0,d.kj)(),l=(e,s)=>(0,a.jsxs)("div",{className:"handoff-row",children:[(0,a.jsx)("strong",{children:n(e)})," ",s]}),t=e=>(0,a.jsx)("ul",{children:e.map((e,s)=>(0,a.jsx)("li",{children:e},s))}),r=s.validation.filter(e=>e.passed).length;return(0,a.jsxs)("div",{className:"summary handoff",children:[(0,a.jsx)("strong",{children:n("handoff.title")}),l("handoff.outcome",(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("span",{className:"badge ".concat(s.outcome.status),children:n("status.".concat(s.outcome.status))}),s.outcome.reason?" ".concat(s.outcome.reason):""]})),l("handoff.files",0===s.changedFiles.length?(0,a.jsx)("span",{className:"muted",children:n("handoff.noFiles")}):(0,a.jsx)("code",{children:s.changedFiles.map(e=>"".concat(e.path).concat(e.added>=0?" +".concat(e.added,"/-").concat(e.removed):"")).join(", ")})),s.validation.length>0&&l("handoff.validation",(0,a.jsxs)(a.Fragment,{children:[n("handoff.passed",{n:r,of:s.validation.length}),s.review?" \xb7 ".concat(n("handoff.review",{verdict:s.review.verdict,open:s.review.open})):""]})),l("handoff.issues",0===s.knownIssues.length?(0,a.jsx)("span",{className:"muted",children:n("handoff.noIssues")}):t(s.knownIssues)),s.evidence.runId&&l("handoff.evidence",(0,a.jsx)("code",{children:s.evidence.runId})),(s.vcs.branch||s.vcs.problem)&&l("handoff.vcs",(0,a.jsxs)(a.Fragment,{children:[s.vcs.branch&&(0,a.jsx)("code",{children:s.vcs.branch}),s.vcs.commit?" @ ".concat(s.vcs.commit.slice(0,8)," \xb7 ").concat(n("handoff.notPushed")):s.vcs.branch?" \xb7 ".concat(n("handoff.noCommit")):"",s.vcs.problem?" — ".concat(s.vcs.problem):""]})),s.manual.length>0&&l("handoff.manual",t(s.manual)),s.notExecuted.length>0&&l("handoff.notRun",t(s.notExecuted))]})}function U(e){var s;let{session:n,presets:t,onAdded:r,onPresetsChanged:i}=e,{t:o}=(0,d.kj)(),m=[...n.tasks].reverse()[0],[h,u]=(0,l.useState)(""),[p,v]=(0,l.useState)(null!=(s=null==m?void 0:m.level2)?s:""),[x,j]=(0,l.useState)(""),[g,f]=(0,l.useState)(""),[k,b]=(0,l.useState)(!1),y=(0,l.useRef)(!1),N=async()=>{if(!y.current){y.current=!0,b(!0);try{await c.FH.addTask(n.id,{title:h,level2:p,prompt:x}),u(""),j(""),f(o("form.queued")),r()}catch(e){f(e.message)}finally{y.current=!1,b(!1)}}};return(0,a.jsxs)("div",{className:"panel",id:"new-task",children:[(0,a.jsx)("h2",{children:o("form.title")}),(0,a.jsx)("p",{className:"muted small",children:o("form.hint")}),(0,a.jsx)("label",{htmlFor:"new-task-title",children:o("form.titleLabel")}),(0,a.jsx)("input",{id:"new-task-title",type:"text",value:h,onChange:e=>u(e.target.value),placeholder:o("form.titlePlaceholder")}),(0,a.jsx)("div",{style:{marginTop:10},children:(0,a.jsx)(O,{value:p,onChange:v,presets:t,onPresetsChanged:i})}),(0,a.jsx)("label",{htmlFor:"new-task-prompt",children:o("form.taskLabel")}),(0,a.jsx)("textarea",{id:"new-task-prompt",className:"prose",value:x,onChange:e=>j(e.target.value),placeholder:o("form.taskPlaceholder"),style:{minHeight:140}}),(0,a.jsxs)("div",{className:"row",style:{marginTop:10},children:[(0,a.jsx)("button",{className:"primary",onClick:()=>void N(),disabled:k||!x.trim(),children:o("form.add")}),(0,a.jsx)("span",{className:"muted small",children:g})]})]})}function G(e){var s,n,t,r,i,u,p,v,x,j,g,N,S,F,D,H,I,T,M,P,R,L,W,B,E,U,G,z,J,Y,$,Q,V,X,ee,es,en,ea,el,et,er,ei,ec,ed,eo,em,eh,eu,ep,ev,ex,ej,eg,ef,ek,eb,ey,eN,ew,eS,eC,eF,eD,eH,eI,eT,eM,eP,eR,eL,eW,eB,eO,eE;let{session:eA,task:eU,index:eG,presets:ez,onChange:eq}=e,{t:eJ}=(0,d.kj)(),eZ=(0,d.W3)(),[e_,eK]=(0,l.useState)(!1),[eY,e$]=(0,l.useState)(!1),[eQ,eV]=(0,l.useState)(eU.title),[eX,e0]=(0,l.useState)(eU.level2),[e1,e2]=(0,l.useState)(eU.prompt),[e4,e8]=(0,l.useState)(null!=(Q=null==(s=eU.vcsPlan)?void 0:s.branch)?Q:""),[e6,e3]=(0,l.useState)(null!=(V=null==(n=eU.vcsPlan)?void 0:n.commitMessage)?V:""),[e5,e7]=(0,l.useState)(null!=(X=eU.checks)?X:[]),[e9,se]=(0,l.useState)(!!eU.readOnly),[ss,sn]=(0,l.useState)((null!=(ee=eU.scope)?ee:[]).join("\n")),sa={readOnly:e9,scope:e9?[]:(0,C.w)(ss)},sl=(0,h.c)((0,m.DG)(eU)),[st,sr]=(0,l.useState)(null),[si,sc]=(0,l.useState)(""),sd=async()=>{try{await c.FH.updateTask(eA.id,eU.id,{title:eQ,level2:eX,prompt:e1,vcsPlan:{branch:e4,commitMessage:e6},checks:e5,...sa}),eK(!1),eq()}catch(e){sc(e.message)}},so="running"===eU.status||"waiting-approval"===eU.status,sm=!so&&"queued"!==eU.status,sh=!so&&"queued"!==eU.status,su=!so&&null!=(es=null==(t=eA.vcs)?void 0:t.enabled)&&es&&(!!(null==(r=eU.vcs)?void 0:r.baseCommit)||(null!=(en=eU.attempts)?en:[]).some(e=>{var s;return null==(s=e.vcs)?void 0:s.baseCommit})),sp=!so&&(0,c.Zm)(eU),sv=async()=>{if(await (0,b.Z)(eJ("task.continueConfirm",{title:eU.title})))try{await c.FH.continueTask(eA.id,eU.id),eq()}catch(e){sc(e.message)}},sx=async()=>{if(await (0,b.Z)(eJ("task.rerunConfirm",{title:eU.title})))try{await c.FH.rerunTask(eA.id,eU.id),eq()}catch(e){sc(e.message)}},sj=async()=>{if(await (0,b.Z)(eJ("task.editRanConfirm",{title:eU.title})))try{await c.FH.rerunTask(eA.id,eU.id,{title:eQ,level2:eX,prompt:e1,vcsPlan:{branch:e4,commitMessage:e6},checks:e5,...sa},{buildOnFinished:"done"===eU.status}),eK(!1),eq()}catch(e){sc(e.message)}},sg=(0,w.e)(eq),sf=async()=>{let e="queued"===eU.status?"task.deleteConfirm":"task.deleteConfirmRan";if(await (0,b.Z)(eJ(e,{title:eU.title})))try{await c.FH.deleteTask(eA.id,eU.id),eq()}catch(e){sc(e.message)}},sk=async()=>{try{sr(await c.FH.taskFiles(eA.id,eU.id))}catch(e){sc(e.message)}},sb=(e,s,n)=>n.length>0&&(0,a.jsxs)("div",{children:[(0,a.jsxs)("span",{className:"muted",children:[eJ(e)," "]}),n.map(e=>(0,a.jsx)("span",{style:{marginRight:10},children:(0,a.jsx)(o.u,{label:e,save:()=>c.FH.saveTaskFile(eA.id,eU.id,s,e)})},e))]});return(0,a.jsxs)("div",{className:"task ".concat(eU.status),id:eU.id,children:[(0,a.jsxs)("div",{className:"row",children:[(0,a.jsxs)("h4",{className:"grow",children:[eG,". ",eU.title]}),(0,a.jsx)("span",{className:"badge ".concat(eU.status),children:eJ("status.".concat(eU.status))}),eU.limit&&(0,a.jsx)("span",{className:"chip",title:eJ("reg.limitChipWhy"),children:eJ("reg.limitChip",{limit:eJ("limit.".concat(eU.limit.setting),{n:eU.limit.value})})}),(null!=(ea=eU.attempt)?ea:1)>1&&(0,a.jsx)("span",{className:"chip",children:eJ("task.attemptN",{n:null!=(el=eU.attempt)?el:1})}),eU.iterations>0&&(0,a.jsx)("span",{className:"muted small",children:eJ("task.iterations",{n:eU.iterations})}),eU.runId&&(0,a.jsxs)("button",{className:eY?"":"quiet","aria-expanded":eY,onClick:()=>e$(e=>!e),title:(0,m.DG)(eU)?eJ("story.showLiveWhy"):eJ("story.why"),children:[(0,m.DG)(eU)&&!eY&&(0,a.jsx)("span",{className:"dot","aria-hidden":"true"}),eY?eJ("story.hide"):(0,m.DG)(eU)?eJ("story.showLive"):eJ("story.show")]}),!so&&(0,a.jsx)("button",{onClick:()=>{if(!e_){var e,s,n,a,l,t;eV(eU.title),e0(eU.level2),e2(eU.prompt),e8(null!=(n=null==(e=eU.vcsPlan)?void 0:e.branch)?n:""),e3(null!=(a=null==(s=eU.vcsPlan)?void 0:s.commitMessage)?a:""),e7(null!=(l=eU.checks)?l:[]),se(!!eU.readOnly),sn((null!=(t=eU.scope)?t:[]).join("\n"))}eK(!e_)},title:eJ("task.editAll"),children:e_?eJ("task.cancel"):eJ("task.edit")}),sp&&(0,a.jsx)("button",{className:"primary",onClick:()=>void sv(),title:eJ("task.continueWhy"),children:eJ("task.continue")}),sh&&(0,a.jsx)("button",{className:sp?"":"primary",onClick:()=>void sx(),title:eJ("task.rerunWhy"),children:eJ("task.rerun")}),su&&(0,a.jsx)("button",{onClick:()=>void sg.restore({sessionId:eA.id,taskId:eU.id,title:eU.title}),disabled:""!==sg.busy||eA.running,title:eJ("restore.why"),children:"restore"===sg.busy?eJ("restore.checking"):eJ("restore.button")}),sm&&(0,a.jsx)("button",{onClick:()=>void sg.restartFrom({sessionId:eA.id,taskId:eU.id,title:eU.title}),disabled:""!==sg.busy||eA.running,title:eJ("restart.why"),children:"restart"===sg.busy?eJ("restart.checking"):eJ("restart.button")}),!so&&(0,a.jsx)("button",{className:"danger",onClick:()=>void sf(),children:eJ("task.delete")}),!e_&&(si||sg.message)&&(0,a.jsx)("span",{className:"err",role:"alert",children:si||sg.message})]}),(0,a.jsxs)("div",{className:"muted small",children:[eU.startedAt?eJ("task.started",{t:eZ(eU.startedAt)}):eJ("task.added",{t:eZ(eU.createdAt)}),eU.finishedAt?" \xb7 ".concat(eJ("task.finished",{t:eZ(eU.finishedAt)})):"",eU.startedAt&&eU.finishedAt?" \xb7 ".concat(eJ("task.took",{d:(0,c.c5)((0,m.d5)(eU.startedAt,eU.finishedAt))})):"",(0,m.DG)(eU)?" \xb7 ".concat(eJ("task.runningFor",{d:(0,c.c5)((0,m.d5)(eU.startedAt,void 0,sl))})):""]}),"queued"!==eU.status&&(null==(i=eA.vcs)?void 0:i.enabled)&&eU.vcs&&(0,a.jsx)("div",{className:"muted small",children:eU.vcs.problem&&!eU.vcs.branch?(0,a.jsx)("span",{className:"reason",children:eJ("vcs.taskProblem",{problem:eU.vcs.problem})}):(0,a.jsxs)(a.Fragment,{children:[eU.vcs.branch&&eJ("vcs.taskBranch",{branch:eU.vcs.branch}),eU.vcs.baseCommit&&" \xb7 ".concat(eJ("vcs.taskBase",{commit:eU.vcs.baseCommit.slice(0,8)})),eU.vcs.commit?" \xb7 ".concat(eJ("vcs.taskCommit",{commit:eU.vcs.commit.slice(0,8)})):" \xb7 ".concat(eJ("vcs.taskNoFiles")),(null!=(et=null==(u=eU.vcs.files)?void 0:u.length)?et:0)>0&&(0,a.jsxs)("details",{style:{display:"inline"},children:[(0,a.jsxs)("summary",{style:{display:"inline",cursor:"pointer"},children:[" \xb7 ",eJ("vcs.taskFiles",{n:null!=(er=null==(p=eU.vcs.files)?void 0:p.length)?er:0})]}),(0,a.jsx)("ul",{style:{margin:"4px 0 4px 0",paddingLeft:20},children:(null!=(ei=eU.vcs.files)?ei:[]).map(e=>(0,a.jsxs)("li",{children:[(0,a.jsx)("code",{children:e.path})," ",e.added<0||e.removed<0?eJ("vcs.taskBinary"):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("span",{style:{color:"var(--ok)"},children:["+",e.added]})," ",(0,a.jsxs)("span",{style:{color:"var(--bad)"},children:["-",e.removed]})]})]},e.path))})]}),eU.vcs.commit&&eU.vcs.baseCommit&&(0,a.jsxs)(a.Fragment,{children:[" \xb7 ",(0,a.jsx)(y.C,{sessionId:eA.id,taskId:eU.id,title:eU.title,files:null!=(ec=null==(v=eU.vcs.files)?void 0:v.length)?ec:0})]}),(null!=(ed=null==(x=eU.vcs.suspicious)?void 0:x.length)?ed:0)>0&&(0,a.jsxs)("div",{className:"err small",style:{marginTop:4},children:[eJ("vcs.suspicious",{n:null!=(eo=null==(j=eU.vcs.suspicious)?void 0:j.length)?eo:0}),(0,a.jsx)("ul",{style:{margin:"4px 0",paddingLeft:20},children:(null!=(em=eU.vcs.suspicious)?em:[]).map(e=>(0,a.jsxs)("li",{children:[(0,a.jsx)("code",{children:e.path})," — ",e.reason]},e.path))})]}),(null!=(eh=null==(g=eU.scopeReverted)?void 0:g.length)?eh:0)>0&&(0,a.jsx)("div",{className:"small",style:{marginTop:4},children:eJ("task.scopeReverted",{n:null!=(eu=null==(N=eU.scopeReverted)?void 0:N.length)?eu:0,paths:(null!=(ep=eU.scopeReverted)?ep:[]).join(", ")})}),(null!=(ev=null==(S=eU.vcs.foreignCommits)?void 0:S.length)?ev:0)>0&&(0,a.jsxs)("div",{className:"err small",style:{marginTop:4},children:[eJ("vcs.foreignCommits",{n:null!=(ex=null==(F=eU.vcs.foreignCommits)?void 0:F.length)?ex:0}),(0,a.jsx)("ul",{style:{margin:"4px 0",paddingLeft:20},children:(null!=(ej=eU.vcs.foreignCommits)?ej:[]).map(e=>(0,a.jsx)("li",{children:(0,a.jsx)("code",{children:e})},e))})]})]})}),"queued"===eU.status&&(null==(D=eA.vcs)?void 0:D.enabled)&&((null==(H=eU.vcsPlan)?void 0:H.branch)||(null==(I=eU.vcsPlan)?void 0:I.commitMessage))&&(0,a.jsx)("div",{className:"muted small",children:eU.vcsPlan.branch&&eU.vcsPlan.commitMessage?eJ("task.gitNames",{branch:eU.vcsPlan.branch,subject:eU.vcsPlan.commitMessage.split("\n")[0]}):eU.vcsPlan.branch?eJ("task.gitBranchOnly",{branch:eU.vcsPlan.branch}):eJ("task.gitCommitOnly",{subject:(null!=(eg=eU.vcsPlan.commitMessage)?eg:"").split("\n")[0]})}),eY&&eU.runId&&(0,a.jsx)(f.P,{sessionId:eA.id,taskId:eU.id,live:"running"===eU.status||"waiting-approval"===eU.status}),e_?(0,a.jsxs)("div",{style:{marginTop:8},children:[(0,a.jsx)("label",{children:eJ("form.titleLabel")}),(0,a.jsx)("input",{type:"text",value:eQ,onChange:e=>eV(e.target.value)}),(0,a.jsx)("div",{style:{marginTop:8},children:(0,a.jsx)(O,{value:eX,onChange:e0,presets:ez})}),(0,a.jsx)("label",{children:eJ("form.taskLabel")}),(0,a.jsx)("textarea",{className:"prose",value:e1,onChange:e=>e2(e.target.value)}),(null==(T=eA.vcs)?void 0:T.enabled)&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("label",{htmlFor:"branch-".concat(eU.id),children:eJ("task.branch")}),(0,a.jsx)("input",{id:"branch-".concat(eU.id),type:"text",value:e4,onChange:e=>e8(e.target.value),placeholder:eA.vcs.branchPrefix,disabled:"per-session"===eA.vcs.branchMode}),(0,a.jsx)("p",{className:"why",children:"per-session"===eA.vcs.branchMode?eJ("task.branchIgnored"):eJ("task.branchWhy")}),(0,a.jsx)("label",{htmlFor:"commit-".concat(eU.id),children:eJ("task.commitMessage")}),(0,a.jsx)("textarea",{id:"commit-".concat(eU.id),value:e6,onChange:e=>e3(e.target.value),style:{minHeight:70}}),(0,a.jsx)("p",{className:"why",children:eJ("task.commitWhy")})]}),(0,a.jsx)(q,{checks:e5,onChange:e7}),e1.trim()!==eU.prompt.trim()&&(0,a.jsx)("p",{className:"notice caution small",children:eJ("task.newIntentNote")}),(0,a.jsx)(C.y,{readOnly:e9,scope:ss,onReadOnly:se,onScope:sn}),(0,a.jsxs)("div",{className:"row",style:{marginTop:8},children:[(0,a.jsx)("button",{className:"primary",onClick:()=>void(sm?sj():sd()),children:sm?eJ("task.saveAndRerun"):eJ("task.save")}),(0,a.jsx)("span",{className:"err",children:si})]}),sm&&(0,a.jsx)("p",{className:"muted small",children:eJ("task.editRanWhy")})]}):(0,a.jsxs)(a.Fragment,{children:[(null!=(ef=null==(M=eU.checks)?void 0:M.length)?ef:0)>0&&(0,a.jsxs)("details",{className:"small",style:{margin:"6px 0"},children:[(0,a.jsxs)("summary",{children:[eJ("checks.title")," — ",eJ("checks.n",{n:null!=(ek=null==(P=eU.checks)?void 0:P.length)?ek:0}),(null!=(eb=null==(R=eU.checkResults)?void 0:R.length)?eb:0)>0&&" \xb7 ".concat((null!=(ey=eU.checkResults)?ey:[]).filter(e=>e.passed).length,"/").concat(null==(L=eU.checkResults)?void 0:L.length," ").concat(eJ("checks.passed"))]}),(0,a.jsx)("ul",{style:{margin:"6px 0",paddingLeft:20},children:(null!=(eN=eU.checks)?eN:[]).map((e,s)=>{var n;let l=(null!=(n=eU.checkResults)?n:[]).find(s=>s.name===e.name);return(0,a.jsxs)("li",{children:[(0,a.jsx)("strong",{children:e.name}),(0,a.jsxs)("span",{className:"muted",children:[" — ",eJ("checks.kind.".concat(e.expect)),e.value?' "'.concat(e.value,'"'):"",e.run?": ".concat(e.run):e.file?": ".concat(e.file):""]}),l&&(0,a.jsxs)("div",{className:l.passed?"muted":"reason",children:[l.passed?eJ("checks.passed"):eJ("checks.failed")," — ",l.detail]})]},"".concat(e.name,"-").concat(s))})})]}),(null!=(ew=null==(W=eU.reviewChecks)?void 0:W.length)?ew:0)>0&&(0,a.jsxs)("details",{className:"small",style:{margin:"6px 0"},children:[(0,a.jsx)("summary",{children:eJ("checks.fromReview",{n:null!=(eS=null==(B=eU.reviewChecks)?void 0:B.length)?eS:0})}),(0,a.jsx)("p",{className:"why",children:eJ("checks.fromReviewWhy")}),(0,a.jsx)("ul",{style:{margin:"6px 0",paddingLeft:20},children:(null!=(eC=eU.reviewChecks)?eC:[]).map(e=>{var s;let n=(null!=(s=eU.checkResults)?s:[]).find(s=>s.name===e.check.name);return(0,a.jsxs)("li",{children:[(0,a.jsx)("code",{children:e.findingId})," ",(0,a.jsx)("strong",{children:e.check.name}),"active"!==e.state&&(0,a.jsx)("span",{className:"chip",style:{marginLeft:6},children:eJ("checks.state.".concat(e.state))}),(0,a.jsx)("div",{className:"muted",children:e.what}),n&&(0,a.jsxs)("div",{className:n.passed?"muted":"reason",children:[n.passed?eJ("checks.passed"):eJ("checks.failed")," — ",n.detail]})]},e.check.name)})})]}),(0,a.jsx)(K,{review:eU.review}),eU.stopCode&&!(0,m.DG)(eU)&&(0,a.jsx)("p",{className:"small",children:(0,a.jsx)("span",{className:"chip",title:eJ("stop.why"),children:eJ("stop.".concat(eU.stopCode))})}),eU.handoff&&!(0,m.DG)(eU)&&(0,a.jsx)(A,{handoff:eU.handoff}),eU.summary&&(0,a.jsxs)("div",{className:"summary",children:[(0,a.jsx)("strong",{children:eJ("task.whatWasDone")}),(0,a.jsx)(k.s,{text:eU.summary})]}),(null!=(eF=null==(E=eU.deviations)?void 0:E.length)?eF:0)>0&&(0,a.jsx)(Z,{items:null!=(eD=eU.deviations)?eD:[]}),(null!=(eH=null==(U=eU.disputes)?void 0:U.length)?eH:0)>0&&(0,a.jsx)(_,{items:null!=(eI=eU.disputes)?eI:[]}),eU.environment&&(0,a.jsx)("div",{className:"muted small",style:{margin:"4px 0"},children:eJ("task.ranWith",{node:eU.environment.node,npm:null!=(eT=eU.environment.npm)?eT:"—",git:null!=(eM=eU.environment.git)?eM:"—",pwsh:null!=(eR=null!=(eP=eU.environment.pwsh)?eP:eU.environment.powershell)?eR:"—"})}),(null!=(eL=null==(G=eU.leftovers)?void 0:G.length)?eL:0)>0&&(0,a.jsxs)("div",{className:"err small",style:{margin:"6px 0"},children:[eJ("task.leftovers",{n:null!=(eW=null==(z=eU.leftovers)?void 0:z.length)?eW:0}),(0,a.jsx)("ul",{style:{margin:"4px 0",paddingLeft:20},children:(null!=(eB=eU.leftovers)?eB:[]).map(e=>(0,a.jsxs)("li",{children:[(0,a.jsx)("code",{children:e.name})," pid ",e.pid,e.ports.length>0?" \xb7 ".concat(eJ("task.leftoverPorts",{ports:e.ports.join(", ")})):""," \xb7 ",e.by]},"".concat(e.by,"-").concat(e.pid)))})]}),eU.reason&&(0,a.jsx)("div",{className:"reason small",style:{margin:"6px 0"},children:eU.reason}),(null!=(eO=null==(J=eU.attempts)?void 0:J.length)?eO:0)>0&&(0,a.jsxs)("details",{children:[(0,a.jsx)("summary",{children:eJ("task.attempts",{n:null!=(eE=null==(Y=eU.attempts)?void 0:Y.length)?eE:0})}),null==($=eU.attempts)?void 0:$.map((e,s)=>{var n,l,t,r;return(0,a.jsxs)("div",{className:"small",style:{margin:"8px 0 12px"},children:[(0,a.jsxs)("div",{className:"row",children:[(0,a.jsx)("strong",{children:eJ("task.attemptN",{n:s+1})}),(0,a.jsx)("span",{className:"badge ".concat(e.status),children:eJ("status.".concat(e.status))}),e.iterations>0&&(0,a.jsx)("span",{className:"muted",children:eJ("task.iterations",{n:e.iterations})}),e.runId&&(0,a.jsx)(o.u,{label:eJ("save.attemptLog"),save:()=>c.FH.saveTaskLog(eA.id,eU.id,e.runId)}),e.runId&&(0,a.jsx)(o.H,{sessionId:eA.id,taskId:eU.id,attempt:s+1}),e.runId&&(null==(n=e.vcs)?void 0:n.commit)&&e.vcs.baseCommit&&(0,a.jsx)(y.C,{sessionId:eA.id,taskId:eU.id,runId:e.runId,title:"".concat(eU.title," — ").concat(eJ("task.attemptN",{n:s+1})),files:null!=(t=null==(l=e.vcs.files)?void 0:l.length)?t:0})]}),(0,a.jsxs)("div",{className:"muted",children:[e.startedAt?eJ("task.started",{t:eZ(e.startedAt)}):"",e.finishedAt?" \xb7 ".concat(eJ("task.finished",{t:eZ(e.finishedAt)})):""]}),e.summary&&(0,a.jsx)("div",{children:e.summary}),e.reason&&(0,a.jsx)("div",{className:"err",children:e.reason}),e.prompt&&e.prompt!==eU.prompt&&(0,a.jsxs)("details",{children:[(0,a.jsx)("summary",{children:eJ("task.attemptText")}),(0,a.jsx)("pre",{children:e.prompt})]})]},"".concat(null!=(r=e.runId)?r:s))})]}),"queued"===eU.status?(0,a.jsxs)("div",{style:{marginTop:8},children:[(0,a.jsx)("div",{className:"muted small",children:eJ("task.prompt")}),(0,a.jsx)("pre",{children:eU.prompt}),eU.level2.trim()?(0,a.jsxs)("details",{children:[(0,a.jsx)("summary",{children:eJ("task.l2Show",{n:eU.level2.trim().split("\n").length})}),(0,a.jsx)("pre",{children:eU.level2})]}):(0,a.jsx)("div",{className:"muted small",children:eJ("task.noL2")})]}):(0,a.jsxs)("details",{children:[(0,a.jsx)("summary",{children:eJ("task.promptAndL2")}),eU.level2.trim()&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("div",{className:"muted small",children:eJ("task.l2")}),(0,a.jsx)("pre",{children:eU.level2})]}),(0,a.jsx)("div",{className:"muted small",children:eJ("task.prompt")}),(0,a.jsx)("pre",{children:eU.prompt})]}),eU.firstMessage&&(0,a.jsxs)("details",{children:[(0,a.jsx)("summary",{children:eJ("task.firstMessage")}),(0,a.jsx)("pre",{className:"tall",children:eU.firstMessage})]}),eU.runId&&(0,a.jsxs)("details",{onToggle:e=>e.currentTarget.open&&void sk(),children:[(0,a.jsx)("summary",{children:eJ("task.files")}),(0,a.jsx)("div",{className:"row small",style:{margin:"6px 0"},children:(0,a.jsx)(o.u,{label:eJ("save.log"),save:()=>c.FH.saveTaskLog(eA.id,eU.id)})}),st&&(0,a.jsxs)("div",{className:"small",children:[sb("task.reports","reports",st.reports),sb("task.artifacts","artifacts",st.artifacts),sb("task.replies","replies",st.replies)]})]}),eU.finalReply&&(0,a.jsxs)("details",{children:[(0,a.jsx)("summary",{children:eJ("task.finalReply")}),(0,a.jsx)("pre",{className:"tall",children:eU.finalReply})]})]})]})}function z(e){let{events:s}=e,{t:n}=(0,d.kj)(),{appearance:t}=(0,v.KP)(),r=(0,l.useRef)(null);return(0,l.useEffect)(()=>{!t.reduceMotion&&r.current&&(r.current.scrollTop=r.current.scrollHeight)},[s.length,t.reduceMotion]),(0,a.jsxs)("div",{className:"panel",children:[(0,a.jsx)("h2",{children:n("live.title")}),(0,a.jsxs)("div",{className:"log",ref:r,children:[0===s.length&&(0,a.jsx)("div",{className:"muted",children:n("live.none")}),s.map((e,s)=>{var n;return(0,a.jsxs)("div",{className:e.level,children:[(0,a.jsx)("span",{className:"time",children:new Date(e.at).toLocaleTimeString(void 0,{hour12:!1})}),null!=(n=e.message)?n:e.type]},s)})]})]})}function q(e){let{checks:s,onChange:n}=e,{t:l}=(0,d.kj)(),t=(e,a)=>n(s.map((s,n)=>e===n?{...s,...a}:s));return(0,a.jsxs)("div",{style:{marginTop:12},children:[(0,a.jsx)("label",{children:l("checks.title")}),(0,a.jsx)("p",{className:"why",style:{marginTop:0},children:l("checks.why")}),0===s.length&&(0,a.jsx)("p",{className:"muted small",children:l("checks.noneWhy")}),s.map((e,r)=>{var i,d,o,m;return(0,a.jsxs)("div",{className:"option",children:[(0,a.jsxs)("div",{className:"row",children:[(0,a.jsx)("input",{type:"text",className:"grow",value:e.name,placeholder:l("checks.namePlaceholder"),onChange:e=>t(r,{name:e.target.value}),"aria-label":l("checks.name")}),(0,a.jsx)("select",{value:e.expect,onChange:e=>t(r,{expect:e.target.value}),"aria-label":l("checks.kind"),style:{width:"auto"},children:c.FZ.map(e=>(0,a.jsx)("option",{value:e,children:l("checks.kind.".concat(e))},e))}),(0,a.jsx)("button",{className:"quiet",onClick:()=>n(s.filter((e,s)=>s!==r)),children:l("checks.remove")})]}),(0,a.jsxs)("div",{className:"row",style:{marginTop:6},children:[(0,c.rt)(e.expect)?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("input",{type:"text",className:"grow",value:null!=(i=e.run)?i:"",placeholder:l("checks.run"),onChange:e=>t(r,{run:e.target.value}),"aria-label":l("checks.run")}),(0,a.jsx)("input",{type:"text",value:null!=(d=e.cwd)?d:"",placeholder:l("checks.cwd"),onChange:e=>t(r,{cwd:e.target.value}),"aria-label":l("checks.cwd"),style:{width:220}})]}):(0,a.jsx)("input",{type:"text",className:"grow",value:null!=(o=e.file)?o:"",placeholder:l("checks.file"),onChange:e=>t(r,{file:e.target.value}),"aria-label":l("checks.file")}),(0,c.dK)(e.expect)&&(0,a.jsx)("input",{type:"text",value:null!=(m=e.value)?m:"",placeholder:"output-matches"===e.expect?l("checks.valueRegex"):l("checks.value"),onChange:e=>t(r,{value:e.target.value}),"aria-label":l("checks.value"),style:{width:240}})]})]},r)}),(0,a.jsx)("button",{onClick:()=>n([...s,{name:"",expect:"exit-zero",run:""}]),children:l("checks.add")})]})}function J(e){let{tasks:s}=e,{t:n}=(0,d.kj)(),l=(0,m.hH)(s),t=(0,h.c)(!!l&&l.tasks.some(m.DG));if(!l)return null;let r=(0,m.eZ)(l.run,l.tasks,t);return(0,a.jsx)("p",{className:"muted small",style:{margin:"4px 0 10px"},children:n(r.live?"session.runClockLive":"session.runClock",{n:r.tasks,d:(0,c.c5)(r.ms)})})}function Z(e){let{items:s}=e,{t:n}=(0,d.kj)();return(0,a.jsxs)("div",{className:"summary",children:[(0,a.jsx)("strong",{children:n("task.deviations",{n:s.length})}),(0,a.jsx)("ol",{style:{margin:"6px 0",paddingLeft:20},children:s.map((e,s)=>(0,a.jsxs)("li",{style:{marginBottom:6},children:[(0,a.jsx)("div",{children:e.instruction}),(0,a.jsxs)("div",{className:"muted",children:[n("task.deviationDid"),": ",e.did]}),(0,a.jsxs)("div",{className:"muted",children:[n("task.deviationWhy"),": ",e.why]})]},s))})]})}function _(e){let{items:s}=e,{t:n}=(0,d.kj)();return(0,a.jsxs)("div",{className:"summary",children:[(0,a.jsx)("strong",{children:n("task.disputes",{n:s.length})}),(0,a.jsx)("ol",{style:{margin:"6px 0",paddingLeft:20},children:s.map((e,s)=>(0,a.jsxs)("li",{style:{marginBottom:6},children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("code",{children:e.finding})," — ",e.why]}),(0,a.jsxs)("div",{className:"muted",children:[n("review.evidence"),": ",e.evidence]})]},s))})]})}function K(e){var s,n,l,t,r;let{review:i}=e,{t:c}=(0,d.kj)();if(!i)return null;if("skipped"===i.verdict)return i.skippedBecause?(0,a.jsx)("p",{className:"muted small",children:c("review.skippedWhy",{why:i.skippedBecause})}):null;let o="pass"===i.verdict?"done":"fail"===i.verdict?"blocked":"waiting-approval";return(0,a.jsxs)("div",{className:"small",style:{margin:"8px 0"},children:[(0,a.jsxs)("div",{className:"row",children:[(0,a.jsx)("span",{className:"badge ".concat(o),children:c("review.verdict.".concat(i.verdict))}),i.stepsRun>0&&(0,a.jsx)("span",{className:"muted",children:c("review.ran",{n:i.stepsRun})}),i.rounds>1&&(0,a.jsx)("span",{className:"muted",children:c("review.rounds",{n:i.rounds})}),i.model&&(0,a.jsx)("span",{className:"chip",children:c("review.onModel",{model:i.model})})]}),i.problem&&(0,a.jsx)("p",{className:"reason",children:c("review.problem",{problem:i.problem})}),i.summary&&(0,a.jsx)(k.s,{text:i.summary}),(null!=(l=null==(s=i.findings)?void 0:s.length)?l:0)>0&&(0,a.jsxs)("details",{style:{marginTop:4},children:[(0,a.jsx)("summary",{children:c("review.findings",{n:null!=(t=null==(n=i.findings)?void 0:n.length)?t:0})}),(0,a.jsx)("ol",{style:{margin:"6px 0",paddingLeft:20},children:(null!=(r=i.findings)?r:[]).map((e,s)=>(0,a.jsxs)("li",{style:{marginBottom:8},children:[(0,a.jsxs)("div",{children:[e.id&&(0,a.jsx)("code",{style:{marginRight:6},children:e.id}),e.what,"task"===e.about&&(0,a.jsx)("span",{className:"chip",style:{marginLeft:6},children:c("review.aboutTask")}),e.repeated&&(0,a.jsx)("span",{className:"chip",style:{marginLeft:6},children:c("review.repeated")})]}),e.where&&(0,a.jsx)("div",{className:"muted",children:e.where}),(0,a.jsxs)("div",{className:"muted",children:[c("review.evidence"),": ",e.evidence]})]},s))})]})]})}},8848:(e,s,n)=>{"use strict";n.d(s,{H4:()=>d,L:()=>o,z4:()=>m});var a=n(3365),l=n(8197),t=n.n(l),r=n(1521),i=n(5549),c=n(867);function d(e){let{current:s,onUse:n}=e,{t:l}=(0,c.kj)(),[t,d]=(0,r.useState)(null);if((0,r.useEffect)(()=>{let e=!1;return i.FH.project().then(s=>{e||d(s)}).catch(()=>void 0),()=>{e=!0}},[]),!t)return null;let o=t.rootDir.trim(),m=s.trim().toLowerCase(),h=n?t.others.filter(e=>e.rootDir.trim().toLowerCase()!==m):[];return(0,a.jsx)(u,{label:o?l("proj.defaultIs",{dir:o}):l("proj.noneShort"),offer:o&&n&&m!==o.toLowerCase()?{text:l("proj.useIt"),onUse:()=>n(o)}:void 0,more:h.map(e=>({text:l("proj.otherUse",{name:e.name}),title:e.rootDir,onUse:()=>null==n?void 0:n(e.rootDir)})),link:o?l("proj.change"):l("proj.setIt"),anchor:"project"})}function o(e){let{current:s,onUse:n}=e,l=h(),{t}=(0,c.kj)();if(!l)return null;let r=l.defaultModel.trim();return(0,a.jsx)(u,{label:r?t("def.modelDefaultIs",{name:r}):t("def.modelNoneShort"),offer:r&&n&&s.trim()!==r?{text:t("def.modelUseIt"),onUse:()=>n(r)}:void 0,link:t(r?"proj.change":"proj.setIt"),anchor:"model"})}function m(e){let{current:s,onUse:n}=e,l=h(),{t}=(0,c.kj)();if(!l)return null;let r=l.defaultReviewModel.trim();return(0,a.jsx)(u,{label:r?t("def.reviewDefaultIs",{name:r}):t("def.reviewNoneShort"),offer:r&&n&&s.trim()!==r?{text:t("def.modelUseIt"),onUse:()=>n(r)}:void 0,link:t(r?"proj.change":"proj.setIt"),anchor:"review"})}function h(){let[e,s]=(0,r.useState)(null);return(0,r.useEffect)(()=>{let e=!1;return i.FH.models().then(n=>{e||s(n)}).catch(()=>void 0),()=>{e=!0}},[]),e}function u(e){let{label:s,offer:n,more:l=[],link:r,anchor:i}=e;return(0,a.jsxs)("p",{className:"muted small",style:{marginTop:4},children:[s," ",n&&(0,a.jsxs)(a.Fragment,{children:["\xb7"," ",(0,a.jsx)("button",{type:"button",className:"linkish",onClick:n.onUse,children:n.text})," "]}),l.map(e=>(0,a.jsxs)("span",{children:["\xb7"," ",(0,a.jsx)("button",{type:"button",className:"linkish",onClick:e.onUse,title:e.title,children:e.text})," "]},e.text)),"\xb7 ",(0,a.jsx)(t(),{href:"/defaults#".concat(i),children:r})]})}}},e=>{e.O(0,[197,867,549,36,295,347,131,358],()=>e(e.s=1772)),_N_E=e.O()}]);