copilot-operator 0.1.96 → 0.1.97

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 (56) hide show
  1. package/dist/src/api/apiLock.js +82 -0
  2. package/dist/src/api/main.js +5 -0
  3. package/dist/src/api/operator.controller.js +18 -4
  4. package/dist/src/api/operator.service.js +264 -51
  5. package/dist/src/api/server.js +10 -0
  6. package/dist/src/config/exportHome.js +1 -1
  7. package/dist/src/config/schema.js +13 -0
  8. package/dist/src/exec/policy.js +9 -18
  9. package/dist/src/plan/kerrigan.js +2 -2
  10. package/dist/src/plan/systemGuide.js +26 -26
  11. package/dist/src/queue/queue.js +7 -0
  12. package/dist/src/session/locatorFailures.js +10 -11
  13. package/dist/src/session/model.js +4 -0
  14. package/dist/src/session/store.js +47 -0
  15. package/dist/src/vcs/newBranch.js +6 -1
  16. package/dist/src/vcs/operatorGit.js +9 -10
  17. package/dist/web/404.html +2 -2
  18. package/dist/web/_next/static/chunks/1024-c0eee3ec374816d1.js +1 -0
  19. package/dist/web/_next/static/chunks/1077.4da389906036b1bb.js +1 -0
  20. package/dist/web/_next/static/chunks/1548.4aa3e42afe4542ab.js +1 -0
  21. package/dist/web/_next/static/chunks/2163.4c6ce20cf967756c.js +1 -0
  22. package/dist/web/_next/static/chunks/714.ffb1325246519f64.js +1 -0
  23. package/dist/web/_next/static/chunks/7220.f483b83c11525063.js +1 -0
  24. package/dist/web/_next/static/chunks/7921-946e538fe3f9630f.js +1 -0
  25. package/dist/web/_next/static/chunks/8124-967df691ec1bfeeb.js +1 -0
  26. package/dist/web/_next/static/chunks/8584.3301b056c97be517.js +1 -0
  27. package/dist/web/_next/static/chunks/9067.03cdfb01ebf6a35d.js +1 -0
  28. package/dist/web/_next/static/chunks/9747.fe06238bc42bd23d.js +1 -0
  29. package/dist/web/_next/static/chunks/app/{layout-2364903896c2c175.js → layout-7943a4391ad2f88f.js} +1 -1
  30. package/dist/web/_next/static/chunks/app/page-6ec948e0cf4b24f0.js +1 -0
  31. package/dist/web/_next/static/chunks/{webpack-3f144d13be3516c2.js → webpack-710628d673fa4afb.js} +1 -1
  32. package/dist/web/defaults.html +2 -2
  33. package/dist/web/defaults.txt +7 -7
  34. package/dist/web/index.html +3 -3
  35. package/dist/web/index.txt +8 -8
  36. package/dist/web/queue.html +2 -2
  37. package/dist/web/queue.txt +8 -8
  38. package/dist/web/settings.html +2 -2
  39. package/dist/web/settings.txt +8 -8
  40. package/dist/web/system.html +2 -2
  41. package/dist/web/system.txt +8 -8
  42. package/package.json +1 -1
  43. package/dist/web/_next/static/chunks/1024-214ded25b9048526.js +0 -1
  44. package/dist/web/_next/static/chunks/1077.161de82f740d47f0.js +0 -1
  45. package/dist/web/_next/static/chunks/1548.f2688468bf946e13.js +0 -1
  46. package/dist/web/_next/static/chunks/2163.b8ada3b7bde69f03.js +0 -1
  47. package/dist/web/_next/static/chunks/714.d1489788e598833b.js +0 -1
  48. package/dist/web/_next/static/chunks/7220.b85c8d105f394389.js +0 -1
  49. package/dist/web/_next/static/chunks/7921-00ebbcc6f65fbe35.js +0 -1
  50. package/dist/web/_next/static/chunks/8124-1dba8babfcfbc6e2.js +0 -1
  51. package/dist/web/_next/static/chunks/8584.a678bfced1cea938.js +0 -1
  52. package/dist/web/_next/static/chunks/9067.6da03ae052877b19.js +0 -1
  53. package/dist/web/_next/static/chunks/9747.ba29e64e97e8a15b.js +0 -1
  54. package/dist/web/_next/static/chunks/app/page-d031bf326e401246.js +0 -1
  55. /package/dist/web/_next/static/{kNfJ9jSwlboc-1sFBBfuI → D3ew46wEw5JXPsTVwZwFC}/_buildManifest.js +0 -0
  56. /package/dist/web/_next/static/{kNfJ9jSwlboc-1sFBBfuI → D3ew46wEw5JXPsTVwZwFC}/_ssgManifest.js +0 -0
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8974],{11272:(e,t,a)=>{"use strict";a.d(t,{O:()=>l});var s=a(73365);function l(){return(0,s.jsxs)("svg",{className:"branch-ico",viewBox:"0 0 16 16","aria-hidden":"true",focusable:"false",children:[(0,s.jsx)("path",{d:"M4.5 3.5v9M4.5 10c0-3 7-2.5 7-5.5",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round"}),(0,s.jsx)("circle",{cx:"4.5",cy:"3",r:"1.7",fill:"currentColor"}),(0,s.jsx)("circle",{cx:"4.5",cy:"13",r:"1.7",fill:"currentColor"}),(0,s.jsx)("circle",{cx:"11.5",cy:"4.2",r:"1.7",fill:"currentColor"})]})}},60405:(e,t,a)=>{"use strict";a.r(t),a.d(t,{default:()=>an});var s=a(73365),l=a(1521),n=a(18197),i=a.n(n),r=a(15549);let c=new Map,o=new Set,d=e=>"cop.git.base:".concat(e);function u(e){return o.add(e),()=>{o.delete(e)}}function h(e){return[(0,l.useSyncExternalStore)(u,()=>(function(e){let t=c.get(e);if(void 0!==t)return t;let a="";try{var s;a=null!=(s=window.localStorage.getItem(d(e)))?s:""}catch(e){}return c.set(e,a),a})(e),()=>""),t=>(function(e,t){c.set(e,t);try{window.localStorage.setItem(d(e),t)}catch(e){}for(let e of o)e()})(e,t)]}var m=a(87527);let p="cop.drafts.v1",f="cop.tabs.v1",x=new Set,b=new Set,g=(e,t)=>"".concat(e,"\n").concat(t);function v(e){try{let t=window.localStorage.getItem(e),a=t?JSON.parse(t):null;return a&&"object"==typeof a&&!Array.isArray(a)?a:{}}catch(e){return{}}}function j(e,t){try{return window.localStorage.setItem(e,JSON.stringify(t)),!0}catch(e){return!1}}function w(e,t){var a;x.delete(g(e,t));let s=v(p);(null==(a=s[e])?void 0:a[t])&&(delete s[e][t],0===Object.keys(s[e]).length&&delete s[e],j(p,s))}var k=a(8205),y=a(16752);let N=[{id:"plain",name:"Plain text"},{id:"typescript",name:"TypeScript"},{id:"javascript",name:"JavaScript"},{id:"json",name:"JSON"},{id:"html",name:"HTML"},{id:"xml",name:"XML"},{id:"css",name:"CSS"},{id:"scss",name:"SCSS"},{id:"markdown",name:"Markdown"},{id:"powershell",name:"PowerShell"},{id:"batch",name:"Batch (cmd)"},{id:"shell",name:"Shell"},{id:"python",name:"Python"},{id:"csharp",name:"C#"},{id:"java",name:"Java"},{id:"kotlin",name:"Kotlin"},{id:"go",name:"Go"},{id:"rust",name:"Rust"},{id:"c",name:"C"},{id:"cpp",name:"C++"},{id:"swift",name:"Swift"},{id:"dart",name:"Dart"},{id:"php",name:"PHP"},{id:"ruby",name:"Ruby"},{id:"lua",name:"Lua"},{id:"sql",name:"SQL"},{id:"yaml",name:"YAML"},{id:"toml",name:"TOML"},{id:"ini",name:"INI / config"},{id:"dockerfile",name:"Dockerfile"},{id:"makefile",name:"Makefile"},{id:"vue",name:"Vue"}],S={ts:"typescript",tsx:"typescript",mts:"typescript",cts:"typescript",js:"javascript",jsx:"javascript",mjs:"javascript",cjs:"javascript",json:"json",jsonc:"json",json5:"json",webmanifest:"json",har:"json",css:"css",scss:"scss",sass:"scss",less:"scss",html:"html",htm:"html",xhtml:"html",svelte:"html",vue:"vue",xml:"xml",svg:"xml",xsd:"xml",xsl:"xml",csproj:"xml",props:"xml",targets:"xml",config:"xml",resx:"xml",plist:"xml",vbproj:"xml",fsproj:"xml",nuspec:"xml",md:"markdown",markdown:"markdown",mdx:"markdown",ps1:"powershell",psm1:"powershell",psd1:"powershell",bat:"batch",cmd:"batch",sh:"shell",bash:"shell",zsh:"shell",py:"python",pyw:"python",pyi:"python",cs:"csharp",csx:"csharp",java:"java",kt:"kotlin",kts:"kotlin",gradle:"kotlin",go:"go",rs:"rust",c:"c",h:"c",cpp:"cpp",cc:"cpp",cxx:"cpp",hpp:"cpp",hh:"cpp",hxx:"cpp",swift:"swift",dart:"dart",php:"php",rb:"ruby",lua:"lua",sql:"sql",yml:"yaml",yaml:"yaml",toml:"toml",ini:"ini",cfg:"ini",conf:"ini",properties:"ini",env:"ini",editorconfig:"ini",gitconfig:"ini",npmrc:"ini",dockerfile:"dockerfile",mk:"makefile"},C={dockerfile:"dockerfile",containerfile:"dockerfile",makefile:"makefile",gnumakefile:"makefile",".gitignore":"shell",".gitattributes":"shell",".dockerignore":"shell",".npmignore":"shell",".prettierignore":"shell",".eslintignore":"shell",".env":"ini",".editorconfig":"ini",".npmrc":"ini",".gitconfig":"ini",".babelrc":"json",".prettierrc":"json",".eslintrc":"json","tsconfig.json":"json","package.json":"json",gemfile:"ruby",rakefile:"ruby",jenkinsfile:"java"};function F(e){var t;let a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",s=e.split("/").pop().toLowerCase();if(C[s])return C[s];if(s.startsWith(".env."))return"ini";if(s.startsWith("dockerfile."))return"dockerfile";let l=s.lastIndexOf(".");if(l>0&&S[s.slice(l+1)])return S[s.slice(l+1)];let n=null!=(t=a.slice(0,200).split(/\r?\n/)[0])?t:"",i=/^#!.*\b(python\d?|node|deno|bun|bash|sh|zsh|pwsh|powershell|ruby|php|lua)\b/.exec(n);if(i){let e=i[1];return e.startsWith("python")?"python":"node"===e||"deno"===e||"bun"===e?"javascript":"pwsh"===e||"powershell"===e?"powershell":"ruby"===e?"ruby":"php"===e?"php":"lua"===e?"lua":"shell"}let r=a.trimStart().slice(0,100);if(/^<\?xml\b/.test(r))return"xml";if(/^<!doctype html|^<html\b/i.test(r))return"html";if(/^[{[]/.test(r))try{return JSON.parse(a),"json"}catch(e){}return"plain"}let M=e=>e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),O=(e,t)=>'<span class="hl-'.concat(e,'">').concat(M(t),"</span>"),q=e=>new Set(e.split(/\s+/).filter(Boolean)),E=q("break case catch class const continue debugger default delete do else export extends finally for from function if import in instanceof let new of return super switch this throw try typeof var void while with yield async await static get set as satisfies"),L=new Set([...E,...q("interface type enum implements namespace module declare abstract private protected public readonly keyof infer is asserts override accessor unique")]),I=q("string number boolean bigint symbol object unknown any never void undefined Record Partial Required Readonly Pick Omit Promise Array Map Set Date Error RegExp"),z=q("true false null undefined NaN Infinity"),D={typescript:{line:["//"],block:[["/*","*/"]],quotes:['"',"'","`"],multiline:["`"],keywords:L,types:I,literals:z,calls:!0,sigil:/^@[A-Za-z_]\w*/},javascript:{line:["//"],block:[["/*","*/"]],quotes:['"',"'","`"],multiline:["`"],keywords:E,literals:z,calls:!0},csharp:{line:["//"],block:[["/*","*/"]],quotes:['"',"'"],calls:!0,literals:q("true false null"),keywords:q("abstract as base break case catch checked class const continue default delegate do else enum event explicit extern finally fixed for foreach goto if implicit in interface internal is lock namespace new operator out override params private protected public readonly ref return sealed sizeof stackalloc static struct switch this throw try typeof unchecked unsafe using virtual volatile while async await var record init required get set value where yield partial"),types:q("bool byte char decimal double float int long object sbyte short string uint ulong ushort void dynamic Task List Dictionary")},java:{line:["//"],block:[["/*","*/"]],quotes:['"',"'"],calls:!0,literals:q("true false null"),keywords:q("abstract assert break case catch class const continue default do else enum extends final finally for goto if implements import instanceof interface native new package private protected public return static strictfp super switch synchronized this throw throws transient try volatile while var record sealed permits yield"),types:q("boolean byte char double float int long short void String Object List Map Integer"),sigil:/^@[A-Za-z_]\w*/},kotlin:{line:["//"],block:[["/*","*/"]],quotes:['"',"'"],calls:!0,literals:q("true false null"),keywords:q("as break class continue do else for fun if in interface is object package return super this throw try typealias typeof val var when while by catch constructor delegate dynamic field file finally get import init param property receiver set setparam where actual abstract annotation companion const crossinline data enum expect external final infix inline inner internal lateinit noinline open operator out override private protected public reified sealed suspend tailrec vararg"),types:q("Int Long Short Byte Double Float Boolean Char String Unit Any Nothing List Map Set"),sigil:/^@[A-Za-z_]\w*/},go:{line:["//"],block:[["/*","*/"]],quotes:['"',"'","`"],multiline:["`"],calls:!0,literals:q("true false nil iota"),keywords:q("break case chan const continue default defer else fallthrough for func go goto if import interface map package range return select struct switch type var"),types:q("bool byte complex64 complex128 error float32 float64 int int8 int16 int32 int64 rune string uint uint8 uint16 uint32 uint64 uintptr any")},rust:{line:["//"],block:[["/*","*/"]],quotes:['"'],calls:!0,literals:q("true false None Some Ok Err"),keywords:q("as async await break const continue crate dyn else enum extern fn for if impl in let loop match mod move mut pub ref return self Self static struct super trait type unsafe use where while"),types:q("bool char f32 f64 i8 i16 i32 i64 i128 isize str u8 u16 u32 u64 u128 usize String Vec Option Result Box"),sigil:/^#!?\[[^\]]*\]/},c:{line:["//"],block:[["/*","*/"]],quotes:['"',"'"],calls:!0,literals:q("true false NULL"),keywords:q("auto break case const continue default do else enum extern for goto if inline register restrict return sizeof static struct switch typedef union volatile while"),types:q("char double float int long short signed unsigned void size_t bool"),sigil:/^#\s*\w+/},cpp:{line:["//"],block:[["/*","*/"]],quotes:['"',"'"],calls:!0,literals:q("true false nullptr NULL"),keywords:q("alignas alignof and asm auto break case catch class const constexpr const_cast continue decltype default delete do dynamic_cast else enum explicit export extern for friend goto if inline mutable namespace new noexcept not operator or private protected public register reinterpret_cast return sizeof static static_assert static_cast struct switch template this thread_local throw try typedef typeid typename union using virtual volatile while override final concept requires co_await co_return co_yield"),types:q("bool char double float int long short signed unsigned void wchar_t size_t string vector map std"),sigil:/^#\s*\w+/},swift:{line:["//"],block:[["/*","*/"]],quotes:['"'],calls:!0,literals:q("true false nil"),keywords:q("associatedtype class deinit enum extension fileprivate func import init inout internal let open operator private protocol public rethrows static struct subscript typealias var break case continue default defer do else fallthrough for guard if in repeat return switch where while as catch is self Self super throw throws try async await some any"),types:q("Int Double Float Bool String Character Array Dictionary Set Optional Void"),sigil:/^@[A-Za-z_]\w*/},dart:{line:["//"],block:[["/*","*/"]],quotes:['"',"'"],calls:!0,literals:q("true false null"),keywords:q("abstract as assert async await break case catch class const continue covariant default deferred do dynamic else enum export extends extension external factory final finally for get hide if implements import in interface is late library mixin new on operator part required rethrow return set show static super switch sync this throw try typedef var void while with yield"),types:q("int double num bool String List Map Set Future Stream Object"),sigil:/^@[A-Za-z_]\w*/},php:{line:["//","#"],block:[["/*","*/"]],quotes:['"',"'"],calls:!0,caseless:!0,literals:q("true false null"),keywords:q("abstract and array as break callable case catch class clone const continue declare default do echo else elseif empty enddeclare endfor endforeach endif endswitch endwhile enum extends final finally fn for foreach function global goto if implements include include_once instanceof insteadof interface isset list match namespace new or print private protected public readonly require require_once return static switch throw trait try unset use var while xor yield"),sigil:/^\$[A-Za-z_]\w*/},lua:{line:["--"],block:[["--[[","]]"]],quotes:['"',"'"],calls:!0,literals:q("true false nil"),keywords:q("and break do else elseif end for function goto if in local not or repeat return then until while")},powershell:{line:["#"],block:[["<#","#>"]],quotes:['"',"'"],multiline:['"',"'"],caseless:!0,calls:!1,literals:q("$true $false $null"),keywords:q("begin break catch class continue data define do dynamicparam else elseif end enum exit filter finally for foreach from function hidden if in inlinescript param process return sequence static switch throw trap try until using var while workflow -and -or -not -xor -eq -ne -gt -ge -lt -le -like -notlike -match -notmatch -contains -notcontains -in -notin -replace -split -join -is -isnot -as -band -bor -f"),sigil:/^\$(?:\{[^}]*\}|[A-Za-z_][\w:]*|[?^$_])/},python:{line:["#"],quotes:['"""',"'''",'"',"'"],multiline:['"""',"'''"],calls:!0,literals:q("True False None"),keywords:q("and as assert async await break class continue def del elif else except finally for from global if import in is lambda nonlocal not or pass raise return try while with yield match case"),types:q("int float str bool list dict set tuple bytes object type self cls"),sigil:/^@[A-Za-z_][\w.]*/},ruby:{line:["#"],block:[["=begin","=end"]],quotes:['"',"'"],calls:!0,literals:q("true false nil"),keywords:q("alias and begin break case class def defined? do else elsif end ensure for if in module next not or redo rescue retry return self super then undef unless until when while yield require require_relative attr_accessor attr_reader attr_writer"),sigil:/^(?:@@?|\$)[A-Za-z_]\w*|^:[A-Za-z_]\w*/},shell:{line:["#"],quotes:['"',"'"],multiline:['"',"'"],literals:q("true false"),keywords:q("if then else elif fi case esac for select while until do done in function time coproc return exit export local readonly declare unset shift source alias echo cd"),sigil:/^\$(?:\{[^}]*\}|[A-Za-z_]\w*|[0-9@#?$!*-])/},batch:{line:["REM ","rem ","::"],quotes:['"'],caseless:!0,keywords:q("call cd chdir cls copy del dir echo else endlocal errorlevel exist exit for goto if in md mkdir move not off on pause popd pushd rd rem ren rmdir set setlocal shift start title type"),sigil:/^%[^%\s]+%|^%%?[A-Za-z0-9~]/},dockerfile:{line:["#"],quotes:['"',"'"],caseless:!0,keywords:q("from as run cmd label maintainer expose env add copy entrypoint volume user workdir arg onbuild stopsignal healthcheck shell"),sigil:/^\$(?:\{[^}]*\}|[A-Za-z_]\w*)/},makefile:{line:["#"],quotes:['"',"'"],keywords:q("ifeq ifneq ifdef ifndef else endif include define endef export override .PHONY"),sigil:/^\$(?:\([^)]*\)|\{[^}]*\}|[@<^*?%])/},sql:{line:["--"],block:[["/*","*/"]],quotes:["'",'"'],caseless:!0,calls:!0,literals:q("true false null"),keywords:q("select from where and or not insert into values update set delete create table view index drop alter add column primary key foreign references join left right inner outer full on as group by order having limit offset union all distinct case when then else end exists in is like between with returning begin commit rollback transaction grant revoke default constraint unique check if replace truncate procedure function trigger declare"),types:q("int integer bigint smallint decimal numeric float real double varchar char text date time timestamp boolean bool uuid json jsonb blob")}};function W(e,t){let a="",s=0,l=e.length,n=a=>t.caseless?e.substr(s,a.length).toLowerCase()===a.toLowerCase():e.startsWith(a,s),i=[...t.quotes].sort((e,t)=>t.length-e.length);for(;s<l;){var r,c,o,d,u,h,m;let p=e[s],f=null==(r=t.block)?void 0:r.find(e=>{let[t]=e;return n(t)});if(f){let t=e.indexOf(f[1],s+f[0].length),n=t<0?l:t+f[1].length;a+=O("com",e.slice(s,n)),s=n;continue}if(null==(c=t.line)?void 0:c.find(e=>n(e))){let t=e.indexOf("\n",s),n=t<0?l:t;a+=O("com",e.slice(s,n)),s=n;continue}let x=i.find(t=>e.startsWith(t,s));if(x){let n=s+x.length,i=null==(o=t.multiline)?void 0:o.includes(x),r=t!==D.powershell&&t!==D.batch&&(t!==D.shell&&t!==D.sql||"'"!==x);for(;n<l;){if("\\"===e[n]&&r){n+=2;continue}if(e.startsWith(x,n)){n+=x.length;break}if("\n"===e[n]&&!i)break;n+=1}a+=O("str",e.slice(s,Math.min(n,l))),s=Math.min(n,l);continue}if(t.sigil&&/[$@#%:[]/.test(p)){let l=t.sigil.exec(e.slice(s,s+200));if(l){let e=l[0];a+=O("@"===p||"#"===p||"["===p?"meta":"var",e),s+=e.length;continue}}if(/[0-9]/.test(p)||"."===p&&/[0-9]/.test(null!=(d=e[s+1])?d:"")){let t=null!=(u=e[s-1])?u:"";if(!/[\w$]/.test(t)){let t=/^(?:0[xX][\da-fA-F_]+|0[bB][01_]+|0[oO][0-7_]+|(?:\d[\d_]*\.?\d*|\.\d+)(?:[eE][+-]?\d+)?)[a-zA-Z]*/.exec(e.slice(s,s+64));if(t){a+=O("num",t[0]),s+=t[0].length;continue}}}if(/[A-Za-z_$-]/.test(p)){let l=/^-?[A-Za-z_$][\w$-]*\??/.exec(e.slice(s,s+120));if(l&&!(l[0].startsWith("-")&&!t.caseless)){let n=l[0];t!==D.powershell&&n.includes("-")&&(n=n.split("-")[0]||n.slice(0,1)),n||(n=p);let i=t.caseless?n.toLowerCase():n,r=(null==(h=t.literals)?void 0:h.has(i))?"lit":t.keywords.has(i)?"kw":(null==(m=t.types)?void 0:m.has(i))?"type":null;r?a+=O(r,n):t.calls&&"("===e[s+n.length]?a+=O("fn",n):/^[A-Z][a-z]\w*$/.test(n)&&t.types?a+=O("type",n):t===D.powershell&&/^[A-Z][a-z]+-[A-Z]\w*$/.test(n)?a+=O("fn",n):a+=M(n),s+=n.length;continue}}a+=M(p),s+=1}return a}function A(e,t){let a="",s=0,l=e.length;for(;s<l;){if(e.startsWith("\x3c!--",s)){let t=e.indexOf("--\x3e",s+4),n=t<0?l:t+3;a+=O("com",e.slice(s,n)),s=n;continue}if(e.startsWith("<![CDATA[",s)){let t=e.indexOf("]]>",s),n=t<0?l:t+3;a+=O("str",e.slice(s,n)),s=n;continue}let n=/^<\/?[A-Za-z!?][\w:.-]*/.exec(e.slice(s,s+100));if(n){let i=n[0];for(a+=O(i.startsWith("<!")||i.startsWith("<?")?"meta":"tag",i),s+=i.length;s<l&&">"!==e[s];){let t=/^[\s/?]+/.exec(e.slice(s,s+50));if(t){a+=M(t[0]),s+=t[0].length;continue}if('"'===e[s]||"'"===e[s]){let t=e.indexOf(e[s],s+1),n=t<0?l:t+1;a+=O("str",e.slice(s,n)),s=n;continue}let n=/^[^\s=>/"']+/.exec(e.slice(s,s+100));if(n){a+=O("attr",n[0]),s+=n[0].length;continue}a+=M(e[s]),s+=1}s<l&&(a+=O("tag",">"),s+=1);let r=i.toLowerCase();if(t&&("<script"===r||"<style"===r)){let t="<script"===r?"</script":"</style",n=e.toLowerCase().indexOf(t,s),i=n<0?l:n,c=e.slice(s,i);a+="<script"===r?W(c,D.javascript):H(c,!1),s=i}continue}if("&"===e[s]){let t=/^&[#\w]+;/.exec(e.slice(s,s+12));if(t){a+=O("lit",t[0]),s+=t[0].length;continue}}let i=e.indexOf("<",s+1),r=e.indexOf("&",s+1),c=Math.min(i<0?l:i,r<0?l:r);a+=M(e.slice(s,c)),s=c}return a}function H(e,t){let a="",s=0,l=e.length,n=0,i=!1;for(;s<l;){var r;let c=e[s];if(e.startsWith("/*",s)){let t=e.indexOf("*/",s+2),n=t<0?l:t+2;a+=O("com",e.slice(s,n)),s=n;continue}if(t&&e.startsWith("//",s)){let t=e.indexOf("\n",s),n=t<0?l:t;a+=O("com",e.slice(s,n)),s=n;continue}if('"'===c||"'"===c){let t=s+1;for(;t<l&&e[t]!==c&&"\n"!==e[t];)t+="\\"===e[t]?2:1;a+=O("str",e.slice(s,t+1)),s=t+1;continue}if("@"===c){let t=/^@[\w-]+/.exec(e.slice(s,s+40));if(t){a+=O("kw",t[0]),s+=t[0].length;continue}}if("$"===c&&t){let t=/^\$[\w-]+/.exec(e.slice(s,s+60));if(t){a+=O("var",t[0]),s+=t[0].length;continue}}if("{"===c&&(n+=1),"}"===c&&(n=Math.max(0,n-1),i=!1),";"===c&&(i=!1),":"===c&&n>0){a+=M(c),s+=1,i=!0;continue}if("#"===c&&i){let t=/^#[\da-fA-F]{3,8}\b/.exec(e.slice(s,s+12));if(t){a+=O("num",t[0]),s+=t[0].length;continue}}if(/[\d.]/.test(c)&&i&&!/[\w-]/.test(null!=(r=e[s-1])?r:"")){let t=/^-?(?:\d+\.?\d*|\.\d+)(?:%|[a-zA-Z]+)?/.exec(e.slice(s,s+20));if(t){a+=O("num",t[0]),s+=t[0].length;continue}}if(/[A-Za-z_-]/.test(c)){let t=/^-?-?[A-Za-z_][\w-]*/.exec(e.slice(s,s+80));if(t){let l=t[0];a+=n>0&&!i&&/^\s*:/.test(e.slice(s+l.length,s+l.length+10))?O("prop",l):i?/^(important|inherit|initial|unset|none|auto)$/.test(l)?O("lit",l):"("===e[s+l.length]?O("fn",l):M(l):O("tag",l),s+=l.length;continue}}a+=M(c),s+=1}return a}let R={typescript:{text:"TS",color:"#3178c6"},javascript:{text:"JS",color:"#b89a00"},json:{text:"{}",color:"#c48c12"},html:{text:"<>",color:"#e34c26"},xml:{text:"<>",color:"#e37933"},css:{text:"#",color:"#2f6fe0"},scss:{text:"S",color:"#cd6799"},markdown:{text:"M↓",color:"#3f7fbf"},powershell:{text:"PS",color:"#2a7bd0"},batch:{text:"BAT",color:"#7c8a96"},shell:{text:"$_",color:"#4a9e22"},python:{text:"PY",color:"#3d7fbf"},csharp:{text:"C#",color:"#9b4dca"},java:{text:"J",color:"#b07219"},kotlin:{text:"K",color:"#7f52ff"},go:{text:"GO",color:"#00a3cc"},rust:{text:"RS",color:"#c4561f"},c:{text:"C",color:"#6f8aa6"},cpp:{text:"C++",color:"#d6336c"},swift:{text:"SW",color:"#f05138"},dart:{text:"DT",color:"#0a85d6"},php:{text:"PHP",color:"#777bb4"},ruby:{text:"RB",color:"#cc342d"},lua:{text:"LUA",color:"#5466d6"},sql:{text:"SQL",color:"#d48a00"},yaml:{text:"Y",color:"#cb3a3a"},toml:{text:"T",color:"#b5562a"},ini:{glyph:"gear",color:"#7c8a96"},dockerfile:{text:"D",color:"#2496ed"},makefile:{text:"MK",color:"#7c8a96"},vue:{text:"V",color:"#3fae7c"}},T={glyph:"image",color:"#a074c4"},P={glyph:"archive",color:"#a07d3e"},B={png:T,jpg:T,jpeg:T,gif:T,webp:T,ico:T,bmp:T,svg:{text:"SVG",color:"#d6922d"},pdf:{text:"PDF",color:"#d03b35"},csv:{text:"CSV",color:"#2e8a55"},xlsx:{text:"XLS",color:"#2e8a55"},docx:{text:"DOC",color:"#3a6cc0"},pptx:{text:"PPT",color:"#d04a26"},zip:P,gz:P,"7z":P,tgz:P,txt:{text:"TXT",color:"#7c8a96"},log:{text:"LOG",color:"#7c8a96"},lock:{glyph:"lock",color:"#7c8a96"},exe:{text:"EXE",color:"#7c8a96"},dll:{text:"DLL",color:"#7c8a96"},sln:{text:"SLN",color:"#9b4dca"},csproj:{text:"C#",color:"#9b4dca"},tsx:{text:"TSX",color:"#3178c6"},jsx:{text:"JSX",color:"#b89a00"}},_={glyph:"git",color:"#f14e32"},$={".gitignore":_,".gitattributes":_,".gitmodules":_,"package.json":{text:"npm",color:"#cb3837"},"package-lock.json":{text:"npm",color:"#cb3837"},license:{text:"\xa9",color:"#7c8a96"},"license.md":{text:"\xa9",color:"#7c8a96"},"license.txt":{text:"\xa9",color:"#7c8a96"},".env":{glyph:"gear",color:"#c49a10"}};[...Object.values(R),...Object.values(B),...Object.values($)].filter(e=>!!e);let U=e=>{let t=e.replace("#",""),a=3===t.length?t.split("").map(e=>e+e).join(""):t;return[0,2,4].map(e=>parseInt(a.slice(e,e+2),16))},K=e=>{let[t,a,s]=e;return"#".concat([t,a,s].map(e=>Math.round(e).toString(16).padStart(2,"0")).join(""))};function V(e){let[t,a,s]=U(e).map(e=>{let t=e/255;return t<=.03928?t/12.92:((t+.055)/1.055)**2.4});return .2126*t+.7152*a+.0722*s}let Z=new Map;function J(e){let{glyph:t}=e;switch(t){case"image":return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("circle",{cx:"11",cy:"4.5",r:"1.8",fill:"currentColor"}),(0,s.jsx)("path",{d:"M1 14 6 7l3.5 4.5L11.5 9 15 14z",fill:"currentColor"})]});case"git":return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("path",{d:"M4.5 3v10M4.5 9.5c0-2.5 7-2 7-5",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round"}),(0,s.jsx)("circle",{cx:"4.5",cy:"3",r:"1.9",fill:"currentColor"}),(0,s.jsx)("circle",{cx:"4.5",cy:"13",r:"1.9",fill:"currentColor"}),(0,s.jsx)("circle",{cx:"11.5",cy:"4.5",r:"1.9",fill:"currentColor"})]});case"lock":return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("path",{d:"M5 7V5a3 3 0 0 1 6 0v2",fill:"none",stroke:"currentColor",strokeWidth:"1.8"}),(0,s.jsx)("rect",{x:"3",y:"7",width:"10",height:"8",rx:"1.5",fill:"currentColor"})]});case"gear":return(0,s.jsx)("path",{d:"M8 5.2a2.8 2.8 0 1 0 0 5.6 2.8 2.8 0 0 0 0-5.6zM7 1h2l.4 1.9 1.3.6 1.7-1 1.4 1.4-1 1.7.6 1.3L15 7v2l-1.9.4-.6 1.3 1 1.7-1.4 1.4-1.7-1-1.3.6L9 15H7l-.4-1.9-1.3-.6-1.7 1-1.4-1.4 1-1.7-.6-1.3L1 9V7l1.9-.4.6-1.3-1-1.7 1.4-1.4 1.7 1 1.3-.6z",fill:"currentColor",fillRule:"evenodd"});case"archive":return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("path",{d:"M2 4h12v10H2z",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinejoin:"round"}),(0,s.jsx)("path",{d:"M8 4v1.5M8 7v1.5M8 10v1.5",stroke:"currentColor",strokeWidth:"1.6"}),(0,s.jsx)("path",{d:"M1.5 1.5h13V4h-13z",fill:"currentColor"})]})}}let G=e=>({"--ico":e.color,"--ico-dark":function(e){let t=Z.get(e);if(t)return t;let a=U(e),s=K(a);for(let e=.12;e<=1&&!(function(e,t){let[a,s]=[V(e),V(t)].sort((e,t)=>t-e);return(a+.05)/(s+.05)}(s=K(a.map(t=>t+(255-t)*e)),"#152436")>=4.8);e+=.04);return Z.set(e,s),s}(e.color)});function Y(e){var t;let{path:a}=e,l=function(e){var t;let a=e.split("/").pop().toLowerCase();if($[a])return $[a];let s=a.lastIndexOf("."),l=s>0?a.slice(s+1):"";return B[l]?B[l]:null!=(t=R[F(e)])?t:null}(a);if(!l)return(0,s.jsxs)("svg",{className:"file-ico",viewBox:"0 0 16 16","aria-hidden":"true",children:[(0,s.jsx)("path",{d:"M3.5 1.5h6l3 3v10h-9z",fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinejoin:"round"}),(0,s.jsx)("path",{d:"M9.5 1.5v3h3",fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinejoin:"round"})]});if(l.glyph)return(0,s.jsx)("svg",{className:"file-ico marked",viewBox:"0 0 16 16","aria-hidden":"true",style:G(l),children:(0,s.jsx)(J,{glyph:l.glyph})});let n=null!=(t=l.text)?t:"",i=n.length>=3?9.2:2===n.length?11.5:15;return(0,s.jsx)("svg",{className:"file-ico marked",viewBox:"0 0 16 16","aria-hidden":"true",style:G(l),children:(0,s.jsx)("text",{x:"8",y:"8.6",textAnchor:"middle",dominantBaseline:"middle",fontFamily:"'Segoe UI', system-ui, sans-serif",fontWeight:"800",fontSize:i,fill:"currentColor",...n.length>=2?{textLength:n.length>=3?16:15,lengthAdjust:"spacingAndGlyphs"}:{},children:n})})}let Q={staged:"git.uncommitted.staged",changes:"git.uncommitted.changes",untracked:"git.uncommitted.untracked",mixed:"git.uncommitted.mixed"};function X(e){var t,a,n;let{data:i,onBase:r,onOpenFile:c,statusName:o}=e,{t:d}=(0,k.kj)(),[u,h]=(0,l.useState)("all");if(i.problem){let e="no-common"===i.problem?d("git.problem.noCommon",{base:null!=(t=i.base)?t:""}):d("no-base"===i.problem?"git.problem.noBase":"git.problem.noCommit");return(0,s.jsx)("p",{className:"muted small wb-pad",children:e})}let m=i.files,p=m.filter(e=>e.uncommitted),f=m.filter(e=>e.committed),x="committed"===u?f:"uncommitted"===u?p:m,b=m.reduce((e,t)=>e+Math.max(0,t.added),0),g=m.reduce((e,t)=>e+Math.max(0,t.removed),0),v=(e,t)=>(0,s.jsx)("button",{type:"button",role:"tab","aria-selected":u===e,className:u===e?"on":"",onClick:()=>h(e),children:t});return(0,s.jsxs)("div",{className:"wb-branch",children:[(0,s.jsxs)("div",{className:"wb-branch-base",children:[(0,s.jsx)("label",{htmlFor:"wb-branch-base",className:"muted small",children:d("git.against")}),(0,s.jsx)("select",{id:"wb-branch-base",value:null!=(a=i.base)?a:"",onChange:e=>r(e.target.value),title:d("git.againstWhy"),children:i.bases.map(e=>(0,s.jsx)("option",{value:e,children:e},e))})]}),(0,s.jsxs)("p",{className:"muted small wb-pad wb-branch-counts",children:[(0,s.jsx)("span",{className:"wb-branch-ahead",children:d("git.branchCounts",{ahead:i.ahead,behind:i.behind})}),(0,s.jsxs)("span",{className:"wb-branch-files",children:[d("git.branchFiles",{files:m.length}),m.length>0&&(0,s.jsxs)("span",{className:"wb-git-counts",children:[" \xb7 ",(0,s.jsxs)("span",{className:"plus",children:["+",b]})," ",(0,s.jsxs)("span",{className:"minus",children:["−",g]})]})]})]}),0===m.length?(0,s.jsx)("p",{className:"muted small wb-pad",children:d("git.noBranchChanges",{base:null!=(n=i.base)?n:""})}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"wb-branch-filter",role:"tablist","aria-label":d("git.filter"),children:[v("all",d("git.filterAll",{n:m.length})),v("committed",d("git.filterCommitted",{n:f.length})),v("uncommitted",d("git.filterUncommitted",{n:p.length}))]}),p.length>0&&(0,s.jsxs)("p",{className:"muted small wb-pad wb-branch-legend",children:[(0,s.jsx)("span",{className:"wb-uncommitted","aria-hidden":"true",children:"●"})," ",d("git.legend")]}),0===x.length?(0,s.jsx)("p",{className:"muted small wb-pad",children:d("uncommitted"===u?"git.allCommitted":"git.noneCommitted")}):(0,s.jsx)("ul",{className:"wb-git-files","aria-label":d("git.branch"),children:x.map(e=>(0,s.jsx)(ee,{f:e,onOpen:t=>c(e.path,t),statusName:o},e.path))}),i.moreFiles&&(0,s.jsx)("p",{className:"muted small wb-pad",children:d("git.moreFiles",{n:m.length})})]})]})}function ee(e){let{f:t,onOpen:a,statusName:l}=e,{t:n}=(0,k.kj)(),i=t.path.lastIndexOf("/"),r=t.uncommitted?n(Q[t.uncommitted]):"";return(0,s.jsx)("li",{children:(0,s.jsxs)("button",{type:"button",className:"wb-row wb-git-file".concat(t.uncommitted?" has-uncommitted":""),onClick:()=>a(),onDoubleClick:()=>a(!0),title:["".concat(t.oldPath?"".concat(t.oldPath," → "):"").concat(t.path," \xb7 ").concat(l(t.status)),t.committed?n("git.inCommits"):"",r].filter(Boolean).join(" \xb7 "),children:[(0,s.jsx)(Y,{path:t.path}),(0,s.jsx)("span",{className:"wb-row-name",children:t.path.slice(i+1)}),i>=0&&(0,s.jsx)("span",{className:"muted wb-git-dir",children:t.path.slice(0,i)}),(0,s.jsx)("span",{className:"grow"}),(0,s.jsx)("span",{className:"wb-git-counts",children:t.added<0?n("diff.binaryShort"):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("span",{className:"plus",children:["+",t.added]})," ",(0,s.jsxs)("span",{className:"minus",children:["−",t.removed]})]})}),t.uncommitted?(0,s.jsx)("span",{className:"wb-uncommitted u-".concat(t.uncommitted),role:"img","aria-label":r,children:"●"}):(0,s.jsx)("span",{className:"wb-uncommitted none","aria-hidden":"true"}),(0,s.jsx)("span",{className:"wb-git-status s-".concat(t.status),"aria-hidden":"true",children:t.status})]})})}var et=a(24872);let ea=e=>"cop.git.message:".concat(e.toLowerCase()),es="cop.git.opSeen",el=e=>{try{var t;return null!=(t=localStorage.getItem(e))?t:""}catch(e){return""}},en=(e,t)=>{try{t?localStorage.setItem(e,t):localStorage.removeItem(e)}catch(e){}};function ei(e){var t;let{state:a,onChanged:n,onOpen:i}=e,{t:c}=(0,k.kj)(),[o,d]=(0,l.useState)(""),[u,h]=(0,l.useState)(null),[p,f]=(0,l.useState)(""),[x,b]=(0,l.useState)(!1),g=(0,l.useRef)(""),v=(0,l.useRef)(n);v.current=n;let j=a.dir;(0,l.useEffect)(()=>{d(el(ea(j)))},[j]);let w=(0,l.useCallback)(e=>{d(e),en(ea(j),e)},[j]),y=(0,l.useCallback)(()=>r.FH.gitOp().then(e=>{let{op:t}=e;if(!t||t.id===el(es))return h(null);h(t),"running"!==t.state&&g.current!==t.id&&(g.current=t.id,v.current(),"commit"===t.kind&&"done"===t.state&&void 0!==t.message&&el(ea(j)).trim()===t.message.trim()&&w(""))}).catch(()=>void 0),[j,w]);(0,l.useEffect)(()=>{y()},[y]),(0,m.z)(y,1e3,(null==u?void 0:u.state)==="running");let N=(null==u?void 0:u.state)==="running"||x,S=a.staged.length,C=a.changes.length,F=0===S,M=F?C:S,O=a.upstream,q=!!a.branch&&"HEAD"!==a.branch,E=e=>{f(""),b(!0),e().then(e=>{en(es,""),h(e)}).catch(e=>f(e.message)).finally(()=>b(!1))},L=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:o,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:F;return E(()=>r.FH.gitCommit(t,a,e))},I=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return E(()=>r.FH.gitPush(e))},z=(e,t)=>{var a,s;return"commit"===e.kind?L(t,null!=(a=e.message)?a:o,null!=(s=e.all)?s:F):I(t)},D=o.trim()?0===M?c("git.nothingToCommit"):F?c("git.commitAllWhy",{n:C}):c("git.commitWhy",{n:S}):c("git.commitNeedsMessage"),W=null!=(t=null==O?void 0:O.name)?t:"",A=O?O.behind>0&&O.ahead>0?c("git.pushBehind",{target:W,n:O.behind}):0===O.ahead?c("git.pushNothing",{target:W}):c("git.pushWhy",{target:W,n:O.ahead}):c("git.publishWhy");return(0,s.jsxs)("div",{className:"wb-git-actions",children:[(0,s.jsx)("label",{htmlFor:"wb-git-message",className:"sr-only",children:c("git.message")}),(0,s.jsx)("textarea",{id:"wb-git-message",className:"wb-git-message",rows:2,value:o,placeholder:c("git.messagePlaceholder"),onChange:e=>w(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.ctrlKey||e.metaKey)&&o.trim()&&M>0&&!N&&(e.preventDefault(),L())},disabled:N}),(0,s.jsxs)("div",{className:"wb-git-buttons",children:[(0,s.jsxs)("button",{type:"button",className:"primary",onClick:()=>L(),disabled:N||!o.trim()||0===M,title:D,children:["✓ ",c(F?"git.commitAll":"git.commit"),M>0&&(0,s.jsx)("span",{className:"wb-badge",children:M})]}),q&&!(O&&0===O.ahead)&&(0,s.jsx)("button",{type:"button",onClick:()=>I(),disabled:N,title:A,children:O?c("git.push",{n:O.ahead}):c("git.publish")})]}),p&&(0,s.jsx)("p",{className:"err small",role:"alert",children:p}),u&&(0,s.jsx)(er,{op:u,onAgain:z,onDismiss:()=>{u&&en(es,u.id),h(null)},onOpen:i,onIdentity:e=>z(e,{})})]})}function er(e){var t,a,l;let{op:n,onAgain:i,onDismiss:r,onOpen:c,onIdentity:o}=e,{t:d}=(0,k.kj)(),u=null!=(t=n.target)?t:"",h=(null!=(a=n.commit)?a:"").slice(0,8),m="running"===n.state?"commit"===n.kind?d("git.op.committing"):d("git.op.pushing",{target:u}):"hooks"===n.state?d("git.op.hooksAsk"):"done"===n.state?"commit"===n.kind?d("git.op.committed",{sha:h,branch:null!=(l=n.branch)?l:"HEAD"}):n.upToDate?d("git.op.upToDate",{target:u}):n.published?d("git.op.published",{target:u}):d("git.op.pushed",{target:u}):"commit"===n.kind?d("git.op.commitFailed"):d("git.op.pushFailed");return(0,s.jsxs)("div",{className:"wb-git-op s-".concat(n.state),role:"failed"===n.state?"alert":"status","aria-live":"polite","data-awaits":"hooks"===n.state?"git-hooks":void 0,children:[(0,s.jsxs)("div",{className:"wb-git-op-head",children:["running"===n.state&&(0,s.jsx)("span",{className:"wb-live","aria-hidden":"true"}),(0,s.jsx)("strong",{className:"grow",children:m}),"running"!==n.state&&(0,s.jsx)("button",{type:"button",className:"wb-icon-btn",onClick:r,title:d("git.op.dismiss"),"aria-label":d("git.op.dismiss"),children:"✕"})]}),"failed"===n.state&&n.cause&&(0,s.jsx)("p",{className:"wb-git-why",children:d("git.why.".concat(n.cause))}),n.passwordWindow&&"running"===n.state&&(0,s.jsx)("p",{className:"wb-git-why",children:d("git.op.passwordWindow")}),"running"!==n.state&&"hooks"!==n.state&&"none"!==n.hooks&&(0,s.jsx)("p",{className:"muted small",children:"run"===n.hooks?d("git.op.hooksRan"):d("git.op.hooksSkipped")}),"hooks"===n.state&&n.flagged&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("ul",{className:"wb-git-hooks",children:n.flagged.map(e=>(0,s.jsxs)("li",{children:[(0,s.jsx)("code",{children:e.path})," — ",d("git.hookWhy.".concat(e.why))," ",!/^[A-Za-z]:|^\//.test(e.path)&&(0,s.jsx)("button",{type:"button",className:"quiet small",onClick:()=>c({kind:"file",path:e.path}),children:d("git.hooks.open")})]},e.path))}),(0,s.jsxs)("div",{className:"wb-git-buttons",children:[(0,s.jsx)("button",{type:"button",onClick:()=>i(n,{hooks:"skip"}),title:d("git.hooks.skipWhy"),children:d("git.hooks.skip")}),(0,s.jsx)("button",{type:"button",onClick:()=>i(n,{trust:n.flagged.map(e=>({path:e.path,sha:e.sha}))}),title:d("git.hooks.trustWhy"),children:d("git.hooks.trust")}),(0,s.jsx)("button",{type:"button",className:"quiet",onClick:r,children:d("git.hooks.cancel")})]})]}),"failed"===n.state&&"identity"===n.cause&&"commit"===n.kind&&(0,s.jsx)(ec,{onSaved:()=>o(n)}),"failed"===n.state&&"hook"===n.cause&&(0,s.jsx)("div",{className:"wb-git-buttons",children:(0,s.jsx)("button",{type:"button",onClick:()=>i(n,{hooks:"skip"}),title:d("git.hooks.skipWhy"),children:d("git.hooks.skip")})}),(n.output||"failed"===n.state)&&(0,s.jsxs)("details",{className:"wb-git-output",open:"failed"===n.state||"running"===n.state,children:[(0,s.jsxs)("summary",{children:[d("git.op.output")," ",(0,s.jsx)("code",{children:n.command})]}),(0,s.jsxs)("pre",{children:[n.cut?"…\n":"",n.output||"—"]}),n.output&&(0,s.jsx)(et.i8,{text:n.output,what:"git.op.copy"})]})]})}function ec(e){let{onSaved:t}=e,{t:a}=(0,k.kj)(),[n,i]=(0,l.useState)(""),[c,o]=(0,l.useState)(""),[d,u]=(0,l.useState)(!0),[h,m]=(0,l.useState)(""),[p,f]=(0,l.useState)(!1);return(0,l.useEffect)(()=>{r.FH.gitIdentity().then(e=>{i(t=>t||e.name),o(t=>t||e.email)}).catch(()=>void 0)},[]),(0,s.jsxs)("form",{className:"wb-git-identity",onSubmit:e=>{e.preventDefault(),m(""),f(!0),r.FH.setGitIdentity(n,c,d).then(t).catch(e=>m(e.message)).finally(()=>f(!1))},children:[(0,s.jsx)("p",{className:"small",children:(0,s.jsx)("strong",{children:a("git.identity.title")})}),(0,s.jsxs)("label",{children:[a("git.identity.name"),(0,s.jsx)("input",{type:"text",value:n,onChange:e=>i(e.target.value),autoComplete:"name"})]}),(0,s.jsxs)("label",{children:[a("git.identity.email"),(0,s.jsx)("input",{type:"email",value:c,onChange:e=>o(e.target.value),autoComplete:"email"})]}),(0,s.jsxs)("label",{className:"check",children:[(0,s.jsx)("input",{type:"checkbox",checked:d,onChange:e=>u(e.target.checked)})," ",a("git.identity.global")]}),h&&(0,s.jsx)("p",{className:"err small",children:h}),(0,s.jsx)("button",{type:"submit",disabled:p||!n.trim()||!c.trim(),children:a("git.identity.save")})]})}var eo=a(11272);function ed(e){let{view:t,onOpen:a,reveal:l,workspace:n,onOpenFolder:i,grip:r}=e;return"commits"===t?(0,s.jsx)(ep,{workspace:n,onOpen:a,onOpenFolder:i,grip:r}):(0,s.jsx)(em,{workspace:n,onOpen:a,reveal:l,onOpenFolder:i,grip:r})}function eu(e){let{title:t,children:a,grip:l}=e;return(0,s.jsxs)("div",{className:"wb-side-head",children:[l,(0,s.jsx)("h2",{children:t}),(0,s.jsx)("span",{className:"grow"}),a]})}let eh=(e,t)=>e.localeCompare(t,void 0,{sensitivity:"base"});function em(e){let{workspace:t,onOpen:a,reveal:n,onOpenFolder:i,grip:c}=e,{t:o}=(0,k.kj)(),[d,u]=(0,l.useState)(null),[h,p]=(0,l.useState)(""),[f,x]=(0,l.useState)(new Set),[b,g]=(0,l.useState)(""),[v,j]=(0,l.useState)(""),w=()=>(null==t?void 0:t.ok)?r.FH.workspaceFiles().then(e=>{u(e.files),p("")}).catch(e=>p(e.message)):Promise.resolve();(0,l.useEffect)(()=>{u(null),w()},[null==t?void 0:t.dir,null==t?void 0:t.ok]),(0,m.z)(w,6e3,!!(null==t?void 0:t.ok));let y=(0,l.useRef)(0),N=(0,l.useRef)("");(0,l.useEffect)(()=>{if(!n||!d||y.current===n.n)return;if(y.current=n.n,!d.includes(n.path)){g(""),j(n.path);return}j(""),g(n.path);let e=n.path.split("/");x(t=>new Set([...t,...e.slice(0,-1).map((t,a)=>e.slice(0,a+1).join("/"))])),N.current=n.path},[n,d]),(0,l.useEffect)(()=>{if(!N.current)return;let e=[...document.querySelectorAll(".wb-tree-list [data-path]")].find(e=>e.dataset.path===N.current);e&&(N.current="",e.scrollIntoView({block:"nearest"}))});let S=(e,t)=>(0,s.jsxs)(s.Fragment,{children:[[...e.dirs.keys()].sort(eh).map(a=>{let l=t?"".concat(t,"/").concat(a):a;return(0,s.jsxs)("li",{role:"treeitem","aria-expanded":f.has(l),children:[(0,s.jsxs)("button",{type:"button",className:"wb-row",onClick:()=>x(e=>{let t=new Set(e);return t.has(l)?t.delete(l):t.add(l),t}),children:[(0,s.jsx)("span",{className:"wb-chev","aria-hidden":"true",children:f.has(l)?"▾":"▸"}),(0,s.jsx)("span",{className:"wb-row-name",children:a})]}),f.has(l)&&(0,s.jsx)("ul",{role:"group",children:S(e.dirs.get(a),l)})]},"d:".concat(l))}),[...e.files].sort((e,t)=>eh(e.split("/").pop(),t.split("/").pop())).map(e=>(0,s.jsx)("li",{role:"treeitem","aria-selected":b===e,children:(0,s.jsxs)("button",{type:"button",className:"wb-row file".concat(b===e?" sel":""),"data-path":e,onClick:()=>{g(e),j(""),a({kind:"file",path:e,preview:!0})},onDoubleClick:()=>a({kind:"file",path:e}),title:e,children:[(0,s.jsx)(Y,{path:e}),(0,s.jsx)("span",{className:"wb-row-name",children:e.split("/").pop()})]})},"f:".concat(e)))]});return(0,s.jsxs)("div",{className:"wb-tree",children:[(0,s.jsxs)(eu,{title:(null==t?void 0:t.ok)?t.name:o("wb.files"),grip:c,children:[(0,s.jsx)("button",{type:"button",className:"wb-icon-btn",onClick:i,title:o("chat.openFolder"),"aria-label":o("chat.openFolder"),children:"⋯"}),(0,s.jsx)("button",{type:"button",className:"wb-icon-btn",onClick:()=>void w(),title:o("wb.refresh"),"aria-label":o("wb.refresh"),children:"↻"})]}),t?t.ok?h?(0,s.jsx)("p",{className:"err small wb-pad",children:h}):d?(0,s.jsxs)(s.Fragment,{children:[v&&(0,s.jsx)("p",{className:"muted small wb-pad",role:"status",children:o("wb.revealGone",{name:v})}),(0,s.jsx)("p",{className:"muted small wb-pad",title:t.dir,children:t.branch?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(eo.O,{})," ",t.branch]}):t.dir}),(0,s.jsx)("ul",{className:"wb-tree-list",role:"tree","aria-label":o("wb.files"),children:S(function(e){let t={dirs:new Map,files:[]};for(let a of e){let e=a.split("/"),s=t;for(let t of e.slice(0,-1)){let e=s.dirs.get(t);e||(e={dirs:new Map,files:[]},s.dirs.set(t,e)),s=e}s.files.push(a)}return t}(d),"")})]}):(0,s.jsx)("p",{className:"muted small wb-pad",children:o("wb.loading")}):(0,s.jsxs)("div",{className:"wb-pad",children:[(0,s.jsx)("p",{className:"small",children:t.problem}),(0,s.jsx)("button",{type:"button",className:"primary",onClick:i,children:o("chat.openFolder")})]}):(0,s.jsx)("p",{className:"muted small wb-pad",children:o("wb.loading")})]})}function ep(e){var t,a;let{workspace:n,onOpen:i,onOpenFolder:c,grip:o}=e,{t:d}=(0,k.kj)(),u=(0,k.W3)(),[p,f]=(0,l.useState)(null),[x,b]=(0,l.useState)(""),[g,v]=(0,l.useState)(new Set),[j,w]=(0,l.useState)(""),[y,N]=(0,l.useState)(new Map),[S,C]=(0,l.useState)(null),[F,M]=h(null!=(t=null==n?void 0:n.dir)?t:""),O=(0,l.useCallback)(()=>Promise.all([r.FH.workspaceGit(),r.FH.workspaceBranch(F||void 0)]).then(e=>{let[t,a]=e;f(t),C(a),b("")}).catch(e=>b(e.message)),[F]);(0,l.useEffect)(()=>{f(null),C(null),(null==n?void 0:n.ok)&&O()},[O,null==n?void 0:n.ok,null==n?void 0:n.dir]),(0,m.z)(O,5e3,!!(null==n?void 0:n.ok));let q=e=>d("git.status.".concat("!"===e?"conflict":e)),[E,L]=(0,l.useState)(!1),[I,z]=(0,l.useState)(""),D=(e,t)=>{L(!0),z(""),r.FH.gitStage(e,t).then(f).catch(e=>z(e.message)).finally(()=>L(!1))},W=(e,t,a)=>{let l=e.path.lastIndexOf("/");return(0,s.jsxs)("li",{className:"changes"===t||"staged"===t?"wb-git-stageable":void 0,children:[(0,s.jsxs)("button",{type:"button",className:"wb-row wb-git-file",onClick:()=>i({kind:"diff",area:t,path:e.path,...a?{commit:a}:{},preview:!0}),onDoubleClick:()=>i({kind:"diff",area:t,path:e.path,...a?{commit:a}:{}}),title:"".concat(e.oldPath?"".concat(e.oldPath," → "):"").concat(e.path," \xb7 ").concat(q(e.status)),children:[(0,s.jsx)(Y,{path:e.path}),(0,s.jsx)("span",{className:"wb-row-name",children:e.path.slice(l+1)}),l>=0&&(0,s.jsx)("span",{className:"muted wb-git-dir",children:e.path.slice(0,l)}),(0,s.jsx)("span",{className:"grow"}),(0,s.jsx)("span",{className:"wb-git-counts",children:e.added<0?d("diff.binaryShort"):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("span",{className:"plus",children:["+",e.added]})," ",(0,s.jsxs)("span",{className:"minus",children:["−",e.removed]})]})}),(0,s.jsx)("span",{className:"wb-git-status s-".concat("!"===e.status?"conflict":e.status),"aria-hidden":"true",children:e.status})]}),"changes"===t||"staged"===t?(0,s.jsx)("button",{type:"button",className:"wb-icon-btn wb-git-stage",onClick:()=>D("changes"===t?"stage":"unstage",[e.path]),disabled:E,title:d("changes"===t?"git.stageFile":"git.unstageFile",{path:e.path}),"aria-label":d("changes"===t?"git.stageFile":"git.unstageFile",{path:e.path}),children:"changes"===t?"+":"−"}):null]},"".concat(t,":").concat(null!=a?a:"",":").concat(e.path))},A=(e,t,a,l,n)=>(0,s.jsxs)("div",{className:"wb-git-section",children:[(0,s.jsxs)("div",{className:"wb-git-head-row",children:[(0,s.jsxs)("button",{type:"button",className:"wb-git-head","aria-expanded":!g.has(e),onClick:()=>v(t=>new Set(t.has(e)?[...t].filter(t=>t!==e):[...t,e])),children:[(0,s.jsx)("span",{"aria-hidden":"true",children:g.has(e)?"▸":"▾"})," ",t,null!==a&&(0,s.jsx)("span",{className:"wb-badge",children:a})]}),n]}),!g.has(e)&&l]}),H=e=>(0,s.jsx)("button",{type:"button",className:"wb-icon-btn wb-git-stage",onClick:()=>D(e,"all"),disabled:E,title:d("stage"===e?"git.stageAll":"git.unstageAll"),"aria-label":d("stage"===e?"git.stageAll":"git.unstageAll"),children:"stage"===e?"+":"−"});return(0,s.jsxs)("div",{className:"wb-tree",children:[(0,s.jsx)(eu,{title:d("git.title"),grip:o,children:(0,s.jsx)("button",{type:"button",className:"wb-icon-btn",onClick:()=>void O(),title:d("git.refresh"),"aria-label":d("git.refresh"),disabled:!(null==n?void 0:n.ok),children:"↻"})}),(null==n?void 0:n.ok)?x?(0,s.jsx)("p",{className:"err small wb-pad",children:x}):p?p.isRepo?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("p",{className:"small wb-pad wb-git-branch",children:[(0,s.jsx)(eo.O,{})," ",(0,s.jsx)("strong",{children:null!=(a=p.branch)?a:"HEAD"}),p.upstream&&(0,s.jsxs)("span",{className:"muted",children:[" \xb7 ",d("git.upstream",{name:p.upstream.name,ahead:p.upstream.ahead,behind:p.upstream.behind})]})]}),(0,s.jsx)(ei,{state:p,onChanged:()=>void O(),onOpen:i}),I&&(0,s.jsx)("p",{className:"err small wb-pad",role:"alert",children:I}),S&&A("branch",d("git.branch"),S.problem?null:S.files.length,(0,s.jsx)(X,{data:S,onBase:M,statusName:q,onOpenFile:(e,t)=>i({kind:"diff",area:"branch",path:e,...S.base?{commit:S.base}:{},...t?{}:{preview:!0}})})),p.staged.length>0&&A("staged",d("git.staged"),p.staged.length,(0,s.jsx)("ul",{className:"wb-git-files",children:p.staged.map(e=>W(e,"staged"))}),H("unstage")),A("changes",d("git.changes"),p.changes.length,0===p.changes.length?(0,s.jsx)("p",{className:"muted small wb-pad",children:d("git.noChanges")}):(0,s.jsx)("ul",{className:"wb-git-files",children:p.changes.map(e=>W(e,"changes"))}),p.changes.length>0?H("stage"):void 0),A("commits",d("git.commits"),null,0===p.commits.length?(0,s.jsx)("p",{className:"muted small wb-pad",children:d("git.noCommits")}):(0,s.jsx)("ul",{className:"wb-commits",children:p.commits.map((e,t)=>{var a;let l=y.get(e.sha),n=!!(null==S?void 0:S.mergeBase)&&S.commits.includes(e.sha),i=!!(null==S?void 0:S.mergeBase)&&e.sha===S.mergeBase&&t>0&&S.commits.length>0;return(0,s.jsxs)("li",{className:n?"on-branch":void 0,children:[i&&(0,s.jsx)("p",{className:"wb-branch-start small",role:"separator",children:d("git.branchStart",{base:null!=(a=S.base)?a:"",sha:e.short})}),(0,s.jsxs)("button",{type:"button",className:"wb-row","aria-expanded":j===e.sha,onClick:()=>(e=>{if(j===e)return void w("");w(e),y.has(e)||r.FH.workspaceCommit(e).then(t=>N(a=>new Map(a).set(e,t.files))).catch(t=>N(a=>new Map(a).set(e,t.message)))})(e.sha),title:n?"".concat(e.subject," \xb7 ").concat(d("git.onBranch")):e.subject,children:[(0,s.jsx)("span",{"aria-hidden":"true",children:j===e.sha?"▾":"▸"}),(0,s.jsx)("code",{children:e.short}),(0,s.jsx)("span",{className:"wb-row-name",children:e.subject})]}),(0,s.jsxs)("div",{className:"muted wb-commit-meta",children:[e.author," \xb7 ",u(e.at)]}),j===e.sha&&(void 0===l?(0,s.jsx)("p",{className:"muted small wb-pad",children:d("wb.loading")}):"string"==typeof l?(0,s.jsx)("p",{className:"err small wb-pad",children:l}):(0,s.jsx)("ul",{className:"wb-git-files nested","aria-label":d("git.commitFiles",{sha:e.short}),children:l.map(t=>W(t,"commit",e.sha))}))]},e.sha)})})),p.moreCommits&&(0,s.jsx)("p",{className:"muted small wb-pad",children:d("git.more",{n:p.commits.length})})]}):(0,s.jsx)("p",{className:"muted small wb-pad",children:d("git.notRepo")}):(0,s.jsx)("p",{className:"muted small wb-pad",children:d("wb.loading")}):(0,s.jsxs)("div",{className:"wb-pad",children:[(0,s.jsx)("p",{className:"muted small",children:d("git.noFolder")}),(0,s.jsx)("button",{type:"button",onClick:c,children:d("chat.openFolder")})]})]})}let ef=/^(\s{0,3})(`{3,}|~{3,})\s*([^\s`]*)?.*$/,ex=/^(\s*)([-*+]|\d{1,9}[.)])\s+(.*)$/;function eb(e,t){if(/^[a-z][a-z0-9+.-]*:/i.test(t)||t.startsWith("//"))return null;let a=decodeURI(t.split("#")[0].split("?")[0]),s=(a.startsWith("/")?a.slice(1):"".concat(e).concat(e?"/":"").concat(a)).split("/"),l=[];for(let e of s)if(""!==e&&"."!==e)if(".."===e){if(0===l.length)return null;l.pop()}else l.push(e);return l.join("/")}function eg(e,t){let a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"i",l=[],n=e,i=0,c=()=>"".concat(a,"-").concat(i++),o=[[/^\\([\\`*_{}[\]()#+\-.!|~<>])/,e=>e[1]],[/^(`+)([\s\S]*?[^`])\1(?!`)/,e=>(0,s.jsx)("code",{children:e[2].replace(/^ (.*) $/,"$1")},c())],[/^!\[([^\]]*)\]\(\s*<?([^\s)>]+)>?(?:\s+"([^"]*)")?\s*\)/,e=>{let a=eb(t.dir,e[2]);return null===a?(0,s.jsxs)("a",{href:e[2],target:"_blank",rel:"noopener noreferrer",title:t.t("md.externalImage",{url:e[2]}),children:["\uD83D\uDDBC ",e[1]||e[2]]},c()):(0,s.jsx)("img",{src:"".concat(r.nC,"/workspace/raw?path=").concat(encodeURIComponent(a)),alt:e[1],title:e[3],loading:"lazy"},c())}],[/^\[((?:[^\][]|\[[^\]]*\])*)\]\(\s*<?([^\s)>]*)>?(?:\s+"([^"]*)")?\s*\)/,e=>d(e[2],eg(e[1],t,c()),e[3])],[/^<(https?:\/\/[^>\s]+)>/,e=>d(e[1],[e[1]])],[/^(https?:\/\/[^\s<>()]+[^\s<>().,;:!?'"])/,e=>d(e[1],[e[1]])],[/^(\*\*|__)(?=\S)([\s\S]*?\S)\1/,e=>(0,s.jsx)("strong",{children:eg(e[2],t,c())},c())],[RegExp("^(\\*|_)(?=\\S)([\\s\\S]*?\\S)\\1(?![\\p{L}\\p{N}])","u"),e=>(0,s.jsx)("em",{children:eg(e[2],t,c())},c())],[/^~~(?=\S)([\s\S]*?\S)~~/,e=>(0,s.jsx)("del",{children:eg(e[1],t,c())},c())],[/^( {2,}|\\)\n/,()=>(0,s.jsx)("br",{},c())]];function d(e,a,l){if(e.startsWith("#"))return(0,s.jsx)("a",{href:e,title:l,children:a},c());let n=eb(t.dir,e);return null!==n?(0,s.jsx)("a",{href:"#".concat(n),title:null!=l?l:n,onClick:e=>{e.preventDefault(),t.onOpenFile(n)},children:a},c()):(0,s.jsx)("a",{href:e,target:"_blank",rel:"noopener noreferrer",title:l,children:a},c())}let u="",h=()=>{u&&l.push(u),u=""};for(;n.length>0;){let e=!1;for(let[t,a]of o){let s=t.exec(n);if(s){h(),l.push(a(s)),n=n.slice(s[0].length),e=!0;break}}e||(u+=n[0],n=n.slice(1))}return h(),l}function ev(e){let{code:t}=e,{t:n}=(0,k.kj)(),i=(0,l.useId)().replace(/[^a-zA-Z0-9]/g,""),[r,c]=(0,l.useState)(""),[o,d]=(0,l.useState)(""),[u,h]=(0,l.useState)("");return((0,l.useEffect)(()=>{let e=()=>{var e;return h(null!=(e=document.documentElement.dataset.theme)?e:"light")};e();let t=new MutationObserver(e);return t.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]}),()=>t.disconnect()},[]),(0,l.useEffect)(()=>{if(!u)return;let e=!1;return(async()=>{try{let s=(await Promise.all([a.e(7100),a.e(8653),a.e(9891)]).then(a.bind(a,50879))).default;s.initialize({startOnLoad:!1,securityLevel:"strict",theme:"dark"===u?"dark":"default",fontFamily:"inherit"});let l=await s.render("mmd-".concat(i,"-").concat(u),t);e||(c(l.svg),d(""))}catch(t){var s;e||d(null!=(s=t.message.split("\n")[0])?s:String(t))}})(),()=>{e=!0}},[t,u,i]),o)?(0,s.jsxs)("div",{className:"md-mermaid bad",children:[(0,s.jsx)("p",{className:"small",children:n("md.mermaidError",{why:o})}),(0,s.jsx)("pre",{children:(0,s.jsx)("code",{children:t})})]}):r?(0,s.jsx)("div",{className:"md-mermaid",role:"img","aria-label":t.split("\n")[0],dangerouslySetInnerHTML:{__html:r}}):(0,s.jsx)("p",{className:"md-mermaid muted small",children:n("md.mermaidLoading")})}function ej(e){let{text:t,path:a,onOpenFile:l}=e,{t:n}=(0,k.kj)(),i=a.includes("/")?a.slice(0,a.lastIndexOf("/")):"";return(0,s.jsx)("article",{className:"md",children:function e(t,a){let l=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"b";return t.map((t,n)=>{let i="".concat(l,"-").concat(n);switch(t.kind){case"heading":{let e="h".concat(t.level);return(0,s.jsx)(e,{id:t.text.toLowerCase().replace(/[`*_~[\]()]/g,"").replace(RegExp("[^\\p{L}\\p{N}\\s-]","gu"),"").trim().replace(/\s+/g,"-"),children:eg(t.text,a,i)},i)}case"para":return(0,s.jsx)("p",{children:eg(t.text,a,i)},i);case"rule":return(0,s.jsx)("hr",{},i);case"html":return(0,s.jsx)("pre",{className:"md-html",children:(0,s.jsx)("code",{children:t.text})},i);case"quote":return(0,s.jsx)("blockquote",{children:e(t.blocks,a,i)},i);case"code":{var r,c;if("mermaid"===t.lang)return(0,s.jsx)(ev,{code:t.text},i);let e=null!=(c=null==(r=N.find(e=>e.id===t.lang||e.name.toLowerCase()===t.lang))?void 0:r.id)?c:({ts:"typescript",tsx:"typescript",js:"javascript",jsx:"javascript",sh:"shell",bash:"shell",zsh:"shell",ps1:"powershell",pwsh:"powershell",py:"python",cs:"csharp","c#":"csharp",yml:"yaml",md:"markdown",html:"html",xml:"xml",json:"json",css:"css",sql:"sql",rs:"rust",go:"go",java:"java",kt:"kotlin",rb:"ruby",php:"php",cpp:"cpp","c++":"cpp",c:"c",bat:"batch",cmd:"batch",toml:"toml",ini:"ini",dockerfile:"dockerfile"})[t.lang];return(0,s.jsx)("pre",{className:"md-code",children:e?(0,s.jsx)("code",{dangerouslySetInnerHTML:{__html:function e(t,a){switch(a){case"plain":return M(t);case"json":return t.replace(/("(?:[^"\\\n]|\\.)*")(\s*:)?|\/\/[^\n]*|\/\*[\s\S]*?\*\/|\b(true|false|null)\b|-?\b\d+(?:\.\d+)?(?:[eE][+-]?\d+)?\b|[&<>]/g,(e,t,a,s)=>void 0!==t?a?O("prop",t)+M(a):O("str",t):e.startsWith("//")||e.startsWith("/*")?O("com",e):s?O("lit",e):/^[&<>]$/.test(e)?M(e):O("num",e));case"html":case"vue":return A(t,!0);case"xml":return A(t,!1);case"css":return H(t,!1);case"scss":return H(t,!0);case"yaml":return t.split("\n").map(e=>{let t=/^(\s*(?:- )?)([^#:'"\n][^:#\n]*?)(:)(\s|$)(.*)$/.exec(e),a=e=>e.replace(/(#.*$)|("(?:[^"\\]|\\.)*"|'[^']*')|(\b(?:true|false|null|yes|no|on|off|~)\b)|(-?\b\d+(?:\.\d+)?\b)|([&*][\w-]+)|([&<>])/gi,(e,t,a,s,l,n,i)=>t?O("com",t):a?O("str",a):s?O("lit",s):l?O("num",l):n?O("var",n):i?M(i):M(e));return/^\s*#/.test(e)?O("com",e):/^\s*---|^\s*\.\.\./.test(e)?O("meta",e):t?M(t[1])+O("prop",t[2])+M(t[3])+M(t[4])+a(t[5]):a(e)}).join("\n");case"ini":case"toml":return t.split("\n").map(e=>{if(/^\s*[#;]/.test(e))return O("com",e);let t=/^(\s*)(\[\[?[^\]]*\]\]?)(.*)$/.exec(e);if(t)return M(t[1])+O("head",t[2])+M(t[3]);let a=/^(\s*)([^=:\s][^=:]*?)(\s*[=:]\s*)(.*)$/.exec(e);if(a){let e=a[4],t=/^(".*"|'.*')$/.test(e.trim())?O("str",e):/^-?\d+(\.\d+)?$/.test(e.trim())?O("num",e):/^(true|false|yes|no|on|off)$/i.test(e.trim())?O("lit",e):M(e);return M(a[1])+O("prop",a[2])+M(a[3])+t}return M(e)}).join("\n");case"markdown":return function(t){let a=t.split("\n"),s=[],l=null;for(let t of a){if(l){t.trimStart().startsWith(l.mark)?(s.push(l.body.length?e(l.body.join("\n"),l.lang):""),s.push(O("code",t)),l=null):l.body.push(t);continue}let a=/^(\s*)(```+|~~~+)\s*([\w+#-]*)/.exec(t);if(a){var n,i,r;let e=a[3]?null!=(r=S[a[3].toLowerCase()])?r:null!=(i=null==(n=N.find(e=>e.name.toLowerCase()===a[3].toLowerCase()))?void 0:n.id)?i:"plain":"plain";l={mark:a[2],lang:e,body:[]},s.push(O("code",t));continue}if(/^\s{0,3}#{1,6}\s/.test(t)){s.push(O("head",t));continue}if(/^\s*>/.test(t)){s.push(O("com",t));continue}let c=M(t);c=c.replace(/^(\s*)([-*+]|\d+[.)])(\s)/,(e,t,a,s)=>"".concat(t,'<span class="hl-kw">').concat(a,"</span>").concat(s)).replace(/(`+)([^`]+?)\1/g,e=>'<span class="hl-code">'.concat(e,"</span>")).replace(RegExp("(\\*\\*|__)(?=\\S)(.+?)(?<=\\S)\\1","g"),e=>'<span class="hl-head">'.concat(e,"</span>")).replace(RegExp("(^|[^*\\w])(\\*|_)(?=\\S)(.+?)(?<=\\S)\\2(?!\\w)","g"),(e,t,a,s)=>"".concat(t,'<span class="hl-em">').concat(a).concat(s).concat(a,"</span>")).replace(/(!?\[[^\]]*\])(\([^)]*\))/g,(e,t,a)=>'<span class="hl-str">'.concat(t,'</span><span class="hl-link">').concat(a,"</span>")),s.push(c)}return l&&s.push(e(l.body.join("\n"),l.lang)),s.join("\n")}(t);default:{let e=D[a];return e?W(t,e):M(t)}}}(t.text,e)}}):(0,s.jsx)("code",{children:t.text})},i)}case"list":{let l=t.items.map((t,l)=>(0,s.jsxs)("li",{className:t.task?"md-task":void 0,children:[t.task&&(0,s.jsx)("input",{type:"checkbox",checked:!!t.done,disabled:!0,"aria-label":t.done?"✓":"○"}),1===t.blocks.length&&"para"===t.blocks[0].kind?eg(t.blocks[0].text,a,"".concat(i,"-").concat(l)):e(t.blocks,a,"".concat(i,"-").concat(l))]},"".concat(i,"-").concat(l)));return t.ordered?(0,s.jsx)("ol",{start:t.start,children:l},i):(0,s.jsx)("ul",{children:l},i)}case"table":return(0,s.jsx)("div",{className:"md-table",children:(0,s.jsxs)("table",{children:[(0,s.jsx)("thead",{children:(0,s.jsx)("tr",{children:t.head.map((e,l)=>(0,s.jsx)("th",{style:t.align[l]?{textAlign:t.align[l]}:void 0,children:eg(e,a,"".concat(i,"-h").concat(l))},l))})}),(0,s.jsx)("tbody",{children:t.rows.map((e,l)=>(0,s.jsx)("tr",{children:t.head.map((n,r)=>{var c;return(0,s.jsx)("td",{style:t.align[r]?{textAlign:t.align[r]}:void 0,children:eg(null!=(c=e[r])?c:"",a,"".concat(i,"-").concat(l,"-").concat(r))},r)})},l))})]})},i)}})}(function e(t){let a=t.replace(/\r\n?/g,"\n").split("\n"),s=[],l=0,n=e=>void 0===e||""===e.trim();for(;l<a.length;){var i,r,c,o,d,u,h,m;let t=a[l];if(n(t)){l+=1;continue}let p=ef.exec(t);if(p){let e=p[2],t=[];for(l+=1;l<a.length&&!a[l].trim().startsWith(e[0].repeat(e.length));)t.push(a[l++]);l+=1,s.push({kind:"code",lang:(null!=(i=p[3])?i:"").toLowerCase(),text:t.join("\n")});continue}let f=/^\s{0,3}(#{1,6})\s+(.*?)\s*#*\s*$/.exec(t);if(f){s.push({kind:"heading",level:f[1].length,text:f[2]}),l+=1;continue}if(/^\s{0,3}([-*_])(\s*\1){2,}\s*$/.test(t)){s.push({kind:"rule"}),l+=1;continue}if(/^\s{0,3}>/.test(t)){let t=[];for(;l<a.length&&!n(a[l])&&(/^\s{0,3}>/.test(a[l])||t.length>0)&&!(!/^\s{0,3}>/.test(a[l])&&(ef.test(a[l])||ex.test(a[l])));)t.push(a[l].replace(/^\s{0,3}>\s?/,"")),l+=1;s.push({kind:"quote",blocks:e(t.join("\n"))});continue}if(t.includes("|")&&l+1<a.length&&/^\s*\|?\s*:?-{1,}:?\s*(\|\s*:?-{1,}:?\s*)*\|?\s*$/.test(a[l+1])){let e=e=>e.trim().replace(/^\|/,"").replace(/\|$/,"").split(RegExp("(?<!\\\\)\\|")).map(e=>e.trim().replace(/\\\|/g,"|")),i=e(t),r=e(a[l+1]).map(e=>e.startsWith(":")&&e.endsWith(":")?"center":e.endsWith(":")?"right":e.startsWith(":")?"left":"");l+=2;let c=[];for(;l<a.length&&!n(a[l])&&a[l].includes("|");)c.push(e(a[l++]));s.push({kind:"table",head:i,align:r,rows:c});continue}let x=ex.exec(t);if(x){let t=x[1].length,i=/\d/.test(x[2]),p=[];for(;l<a.length;){let s=ex.exec(a[l]);if(!s||s[1].length!==t||/\d/.test(s[2])!==i)break;let f=[s[3]];for(l+=1;l<a.length;){let e=a[l],s=ex.exec(e);if(n(e)){if(l+1<a.length&&(null!=(u=null==(d=a[l+1].match(/^\s*/))?void 0:d[0].length)?u:0)>t&&!n(a[l+1])){f.push(""),l+=1;continue}break}if(s&&s[1].length<=t)break;let r=null!=(h=null==(o=e.match(/^\s*/))?void 0:o[0].length)?h:0;if(r<=t&&!s&&/^\s{0,3}(#|>|```|~~~)/.test(e))break;f.push(r>t?e.slice(Math.min(r,t+2+ +!!i)):e.trim()),l+=1}let x=/^\[([ xX])\]\s+/.exec(f[0]);for(x&&(f[0]=f[0].slice(x[0].length)),p.push({blocks:e(f.join("\n")),...x?{task:!0,done:" "!==x[1]}:{}});l<a.length&&n(a[l])&&(null==(c=ex.exec(null!=(m=a[l+1])?m:""))||null==(r=c[1])?void 0:r.length)===t;)l+=1}s.push({kind:"list",ordered:i,start:i?parseInt(x[2],10):1,items:p});continue}if(/^\s{0,3}<[a-zA-Z!/]/.test(t)){let e=[];for(;l<a.length&&!n(a[l]);)e.push(a[l++]);s.push({kind:"html",text:e.join("\n")});continue}let b=[];for(;l<a.length&&!n(a[l])&&!ef.test(a[l])&&!/^\s{0,3}(#{1,6}\s|>)/.test(a[l])&&!(b.length>0&&ex.test(a[l]));){if(b.length>0&&/^\s{0,3}(=+|-+)\s*$/.test(a[l])){s.push({kind:"heading",level:a[l].trim().startsWith("=")?1:2,text:b.join(" ")}),b.length=0,l+=1;break}b.push(a[l++])}b.length>0&&s.push({kind:"para",text:b.join("\n")})}return s}(t),{dir:i,onOpenFile:l,t:n})})}let ew=null,ek={plain:"plaintext",batch:"bat",vue:"html",toml:"ini",makefile:"plaintext"},ey=e=>{var t;return null!=(t=ek[e])?t:e};function eN(e,t){let a=function(){let e=document.documentElement,t=getComputedStyle(e),a=parseFloat(t.getPropertyValue("--scale"))||1;return{dark:"dark"===e.dataset.theme,size:Math.round(13*a*10)/10,background:t.getPropertyValue("--bg").trim()||"#ffffff",ink:t.getPropertyValue("--ink").trim()||"#000000"}}();e.editor.defineTheme("cop-light",{base:"vs",inherit:!0,rules:[],colors:{"editor.background":a.dark?"#ffffff":a.background}}),e.editor.defineTheme("cop-dark",{base:"vs-dark",inherit:!0,rules:[],colors:{"editor.background":a.dark?a.background:"#1e1e1e"}}),e.editor.setTheme(a.dark?"cop-dark":"cop-light"),null==t||t.updateOptions({fontSize:a.size})}function eS(e){let{path:t,value:n,language:i,onChange:r,onSave:c,onToggleMarkdown:o,goTo:d,label:u,reset:h}=e,{t:m}=(0,k.kj)(),p=(0,l.useRef)(null),f=(0,l.useRef)(null),x=(0,l.useRef)(null),[b,g]=(0,l.useState)(!1),[v,j]=(0,l.useState)(""),w=(0,l.useRef)({onChange:r,onSave:c,onToggleMarkdown:o});return w.current={onChange:r,onSave:c,onToggleMarkdown:o},(0,l.useEffect)(()=>{let e=!1,s=null;return(null!=ew||(ew=(async()=>{self.MonacoEnvironment={getWorker:(e,t)=>"json"===t?new Worker(a.tu(new URL(a.p+a.u(2355),a.b)),{type:void 0}):"css"===t||"scss"===t||"less"===t?new Worker(a.tu(new URL(a.p+a.u(7443),a.b)),{type:void 0}):"html"===t||"handlebars"===t||"razor"===t?new Worker(a.tu(new URL(a.p+a.u(7484),a.b)),{type:void 0}):"typescript"===t||"javascript"===t?new Worker(a.tu(new URL(a.p+a.u(7695),a.b)),{type:void 0}):new Worker(a.tu(new URL(a.p+a.u(2395),a.b)),{type:void 0})};let e=await Promise.all([a.e(3499),a.e(5591),a.e(2737),a.e(1384),a.e(5706),a.e(4008),a.e(9658)]).then(a.bind(a,39658)),t={noSemanticValidation:!0,noSyntaxValidation:!0,noSuggestionDiagnostics:!0};for(let a of(e.typescript.typescriptDefaults.setDiagnosticsOptions(t),e.typescript.javascriptDefaults.setDiagnosticsOptions(t),e.json.jsonDefaults.setDiagnosticsOptions({...e.json.jsonDefaults.diagnosticsOptions,validate:!1}),[e.css.cssDefaults,e.css.scssDefaults,e.css.lessDefaults]))a.setOptions({...a.options,validate:!1});return e})()),ew).then(a=>{if(e||!p.current)return;x.current=a;let l=a.editor.createModel(n,ey(i),a.Uri.file("/workspace/".concat(t))),r=a.editor.create(p.current,{model:l,automaticLayout:!0,ariaLabel:u,minimap:{enabled:!0},scrollBeyondLastLine:!1,renderWhitespace:"selection",tabSize:2,detectIndentation:!0,fixedOverflowWidgets:!0,renderValidationDecorations:"off"});f.current=r,eN(a,r),p.current.copEditor=r,l.onDidChangeContent(()=>w.current.onChange(l.getValue())),r.addAction({id:"cop.save",label:m("ed.save"),keybindings:[a.KeyMod.CtrlCmd|a.KeyCode.KeyS],run:()=>w.current.onSave()}),r.addAction({id:"cop.markdownView",label:m("ed.viewPreview"),keybindings:[a.KeyMod.CtrlCmd|a.KeyMod.Shift|a.KeyCode.KeyV],precondition:void 0,run:()=>{var e,t;return null==(e=(t=w.current).onToggleMarkdown)?void 0:e.call(t)}}),(s=new MutationObserver(()=>eN(a,r))).observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme","data-textsize"]}),g(!0)}).catch(e=>j(e.message)),()=>{var t;e=!0,null==s||s.disconnect();let a=f.current;null==a||null==(t=a.getModel())||t.dispose(),null==a||a.dispose(),f.current=null}},[t]),(0,l.useEffect)(()=>{var e;let t=null==(e=f.current)?void 0:e.getModel();t&&t.getValue()!==n&&t.pushEditOperations([],[{range:t.getFullModelRange(),text:n}],()=>null)},[h,b]),(0,l.useEffect)(()=>{var e;let t=null==(e=f.current)?void 0:e.getModel();t&&x.current&&x.current.editor.setModelLanguage(t,ey(i))},[i,b]),(0,l.useEffect)(()=>{var e;null==(e=f.current)||e.updateOptions({ariaLabel:u})},[u]),(0,l.useEffect)(()=>{var e,t,a;let s=f.current,l=x.current,n=null==s?void 0:s.getModel();if(!d||!s||!l||!n)return;let i=Math.max(1,Math.min(d.line,n.getLineCount())),r=n.getLineLength(i),c=Math.min(null!=(e=d.from)?e:0,r)+1,o=Math.min(null!=(a=null!=(t=d.to)?t:d.from)?a:0,r)+1,u=new l.Range(i,c,i,o);s.setSelection(u),s.revealRangeNearTopIfOutsideViewport(u),s.focus()},[null==d?void 0:d.n,b]),(0,s.jsxs)("div",{className:"ed-code",children:[!b&&!v&&(0,s.jsx)("p",{className:"muted small ed-code-loading",children:m("ed.loading")}),v&&(0,s.jsx)("p",{className:"err small",children:m("ed.failed",{reason:v})}),(0,s.jsx)("div",{ref:p,className:"ed-monaco","data-ready":b?"yes":void 0})]})}let eC="cop.md.view";function eF(e){var t,a,n,i,c;let{dir:o,path:d,onDirty:u,goTo:h,onOpenFile:f}=e,{t:y}=(0,k.kj)(),[S,C]=(0,l.useState)(null),[M,O]=(0,l.useState)(""),[q,E]=(0,l.useState)(""),[L,I]=(0,l.useState)(""),[z,D]=(0,l.useState)(!1),[W,A]=(0,l.useState)(!1),[H,R]=(0,l.useState)("auto"),[T,P]=(0,l.useState)(0),B=!!S&&null!==S.text&&M!==S.text;(0,l.useEffect)(()=>null==u?void 0:u(d,B),[d,B,u]);let _=(0,l.useCallback)(async e=>{try{var t,a;let s=await r.FH.workspaceFile(d,o),l=e?function(e,t){var a;b.delete(g(e,t));let s=null==(a=v(p)[e])?void 0:a[t];return s&&"string"==typeof s.text?s:null}(o,d):null;e||w(o,d),l&&null!==s.text&&l.text!==s.text?(C({...s,version:null!=(t=l.version)?t:s.version}),O(l.text)):(l&&w(o,d),C(s),O(null!=(a=s.text)?a:"")),P(e=>e+1),A(!1),E("")}catch(e){E(e.message)}},[d,o]),$=(0,l.useCallback)(()=>_(!1),[_]);(0,l.useEffect)(()=>{C(null),I(""),A(!1),_(!0)},[_]);let U=(0,l.useRef)(null),K=(0,l.useCallback)(()=>{U.current&&(!function(e,t,a,s){var l;if(b.has(g(e,t)))return;let n=v(p);n[e]={...null!=(l=n[e])?l:{},[t]:{text:a,...s?{version:s}:{},at:new Date().toISOString()}},j(p,n)?x.delete(g(e,t)):x.add(g(e,t))}(o,d,U.current.text,U.current.version),U.current=null)},[o,d]);(0,l.useEffect)(()=>{if(!S||null===S.text)return;if(!B){U.current=null,w(o,d);return}U.current={text:M,...S.version?{version:S.version}:{}};let e=setTimeout(K,300);return()=>clearTimeout(e)},[B,M,S,o,d,K]),(0,l.useEffect)(()=>(window.addEventListener("pagehide",K),()=>{window.removeEventListener("pagehide",K),K()}),[K]),(0,m.z)(async()=>{if(!(null==S?void 0:S.version)||z)return;let e=await r.FH.workspaceFile(d,o).catch(()=>null);if((null==e?void 0:e.version)&&e.version!==S.version)if(B)A(!0);else{var t;C(e),O(null!=(t=e.text)?t:""),P(e=>e+1)}},4e3,!!S);let V="auto"===H?F(d,null!=(t=null==S?void 0:S.text)?t:""):H,Z="markdown"===F(d,""),[J,G]=(0,l.useState)("preview");(0,l.useEffect)(()=>{try{let e=window.localStorage.getItem(eC);("code"===e||"split"===e||"preview"===e)&&G(e)}catch(e){}},[]);let Q=e=>{G(e);try{window.localStorage.setItem(eC,e)}catch(e){}},X=Z?J:"code",ee=async function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(S&&!z){D(!0),I("");try{let t=await r.FH.saveWorkspaceFile(d,M,e?void 0:S.version,o);C({...S,text:M,version:t.version,size:t.size}),A(!1),I(y("ed.saved"))}catch(e){409===e.status?A(!0):I(e.message)}finally{D(!1)}}};return((0,l.useEffect)(()=>{h&&Z&&"preview"===J&&G("split")},[null==h?void 0:h.n]),q&&!S)?(0,s.jsx)("p",{className:"err small",children:q}):S?S.binary||S.tooLarge?(0,s.jsxs)("div",{className:"wb-file",children:[(0,s.jsx)("p",{className:"muted small",children:y("wb.fileOnDisk",{path:S.path})}),(0,s.jsx)("p",{className:"muted",children:S.binary?y("wb.binary"):y("wb.tooLarge")})]}):(0,s.jsxs)("div",{className:"ed",children:[(0,s.jsxs)("div",{className:"ed-bar",children:[(0,s.jsx)(Y,{path:d}),(0,s.jsx)("span",{className:"ed-path",title:S.path,children:S.path}),(0,s.jsx)("span",{className:"small ".concat(B?"ed-dirty":"muted"),role:"status",children:B?y("ed.unsaved"):L||y("ed.clean")}),(0,s.jsx)("span",{className:"grow"}),Z&&(0,s.jsx)("span",{className:"segmented ed-md-view",role:"group","aria-label":y("ed.view"),title:y("ed.viewWhy"),children:["code","split","preview"].map(e=>(0,s.jsx)("button",{type:"button","aria-pressed":J===e,onClick:()=>Q(e),children:y("code"===e?"ed.viewCode":"split"===e?"ed.viewSplit":"ed.viewPreview")},e))}),(0,s.jsx)("label",{htmlFor:"ed-lang-".concat(d),className:"sr-only",children:y("ed.language")}),(0,s.jsxs)("select",{id:"ed-lang-".concat(d),className:"ed-lang",value:H,onChange:e=>R(e.target.value),title:y("ed.language"),children:[(0,s.jsx)("option",{value:"auto",children:y("ed.langAuto",{name:(n=F(d,null!=(a=S.text)?a:""),null!=(c=null==(i=N.find(e=>e.id===n))?void 0:i.name)?c:n)})}),N.map(e=>(0,s.jsx)("option",{value:e.id,children:e.name},e.id))]}),(0,s.jsx)("button",{type:"button",className:"quiet small",disabled:!B||z,onClick:()=>{var e;O(null!=(e=S.text)?e:""),P(e=>e+1),I("")},children:y("ed.revert")}),(0,s.jsx)("button",{type:"button",className:"primary small",disabled:!B||z,onClick:()=>void ee(),title:"Ctrl+S",children:y("ed.save")})]}),W&&(0,s.jsxs)("div",{className:"notice caution small ed-conflict",role:"alert",children:[(0,s.jsx)("span",{children:y("ed.changedOnDisk")}),(0,s.jsx)("button",{type:"button",className:"small",onClick:()=>void $(),children:y("ed.reload")}),(0,s.jsx)("button",{type:"button",className:"small danger",onClick:()=>void ee(!0),children:y("ed.saveOver")})]}),(0,s.jsxs)("div",{className:"ed-body ed-show-".concat(X),children:["code"!==X&&(0,s.jsx)("div",{className:"ed-preview",children:(0,s.jsx)(ej,{text:M,path:d,onOpenFile:e=>null==f?void 0:f(e)})}),"preview"!==X&&(0,s.jsx)(eS,{path:d,value:M,language:V,onChange:O,onSave:()=>void ee(),onToggleMarkdown:Z?()=>Q("code"===J?"preview":"code"):void 0,goTo:h,label:y("ed.label",{path:S.path}),reset:T})]})]}):(0,s.jsx)("p",{className:"muted small",children:y("wb.loading")})}function eM(e){if(null===e||""===e)return[];let t=e.split(/\r?\n/);return""===t[t.length-1]&&t.pop(),t}function eO(e,t){let a=function(e,t){let a=0;for(;a<e.length&&a<t.length&&e[a]===t[a];)a+=1;let s=e.length,l=t.length;for(;s>a&&l>a&&e[s-1]===t[l-1];)s-=1,l-=1;let n=[];for(let e=0;e<a;e+=1)n.push({kind:"same",a:e,b:e});for(let i of function(e,t){let a=e.length,s=t.length;if(0===a)return t.map((e,t)=>({kind:"add",b:t}));if(0===s)return e.map((e,t)=>({kind:"del",a:t}));let l=a+s,n=l+1,i=new Int32Array(2*l+3),r=[];for(let c=0;c<=Math.min(l,2e3);c+=1){r.push(i.slice(n-c-1,n+c+2));for(let l=-c;l<=c;l+=2){let o=l===-c||l!==c&&i[n+l-1]<i[n+l+1]?i[n+l+1]:i[n+l-1]+1,d=o-l;for(;o<a&&d<s&&e[o]===t[d];)o+=1,d+=1;if(i[n+l]=o,o>=a&&d>=s)return function(e,t,a,s){let l=[],n=t.length,i=a.length;for(let t=s;t>0;t-=1){let a=e[t],s=e=>a[e+t+1],r=n-i,c=r===-t||r!==t&&s(r-1)<s(r+1)?r+1:r-1,o=s(c),d=o-c;for(;n>o&&i>d;)n-=1,i-=1,l.push({kind:"same",a:n,b:i});n===o?l.push({kind:"add",b:d}):l.push({kind:"del",a:o}),n=o,i=d}for(;n>0&&i>0;)n-=1,i-=1,l.push({kind:"same",a:n,b:i});return l.reverse()}(r,e,t,c)}}return[...e.map((e,t)=>({kind:"del",a:t})),...t.map((e,t)=>({kind:"add",b:t}))]}(e.slice(a,s),t.slice(a,l)))n.push({kind:i.kind,...void 0!==i.a?{a:i.a+a}:{},...void 0!==i.b?{b:i.b+a}:{}});for(let t=0;s+t<e.length;t+=1)n.push({kind:"same",a:s+t,b:l+t});return n}(e,t),s=[];for(let l=0;l<a.length;){let n=a[l];if("same"===n.kind){s.push({kind:"same",left:{no:n.a+1,text:e[n.a]},right:{no:n.b+1,text:t[n.b]}}),l+=1;continue}let i=[],r=[];for(;l<a.length&&"same"!==a[l].kind;){let e=a[l];"del"===e.kind?i.push(e.a):r.push(e.b),l+=1}let c=Math.max(i.length,r.length);for(let a=0;a<c;a+=1){let l=i[a],n=r[a];s.push({kind:void 0!==l&&void 0!==n?"change":void 0!==l?"del":"add",...void 0!==l?{left:{no:l+1,text:e[l]}}:{},...void 0!==n?{right:{no:n+1,text:t[n]}}:{}})}}return s}function eq(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:new Set,s=arguments.length>3&&void 0!==arguments[3]&&arguments[3];if(s)return e.map((e,t)=>({type:"row",row:e,index:t}));let l=[];for(let s=0;s<e.length;){if("same"!==e[s].kind){l.push({type:"row",row:e[s],index:s}),s+=1;continue}let n=s;for(;n<e.length&&"same"===e[n].kind;)n+=1;let i=0===s?0:t,r=n===e.length?0:t,c=n-s-i-r;if(c>1&&!a.has(s+i)){for(let t=s;t<s+i;t+=1)l.push({type:"row",row:e[t],index:t});l.push({type:"gap",from:s+i,count:c});for(let t=n-r;t<n;t+=1)l.push({type:"row",row:e[t],index:t})}else for(let t=s;t<n;t+=1)l.push({type:"row",row:e[t],index:t});s=n}return l}var eE=a(94969);function eL(e){let{sessionId:t,taskId:a,runId:n,title:i,files:r}=e,{t:c}=(0,k.kj)(),[o,d]=(0,l.useState)(!1);return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("button",{type:"button",className:"linkish",onClick:()=>d(!0),title:c("diff.openWhy"),children:c("diff.open",{n:r})}),o&&(0,s.jsx)(eI,{sessionId:t,taskId:a,runId:n,title:i,onClose:()=>d(!1)})]})}function eI(e){var t,a,n,i,c,o,d;let{sessionId:u,taskId:h,runId:m,title:p,onClose:f}=e,{t:x}=(0,k.kj)(),[b,g]=(0,l.useState)(null),[v,j]=(0,l.useState)(""),[w,y]=(0,l.useState)(0),[N,S]=(0,l.useState)(new Map),[C,F]=(0,l.useState)(!1),[M,O]=(0,l.useState)(!0),[q,E]=(0,l.useState)(new Map),[L,I]=(0,l.useState)(-1),z=(0,l.useRef)(null),D=(0,l.useRef)(null),W=(0,l.useRef)(null);(0,eE.V)(D,!0,W),(0,l.useEffect)(()=>{r.FH.taskChanges(u,h,m).then(g).catch(e=>j(e.message))},[u,h,m]);let A=null!=(n=null==b?void 0:b.files)?n:[],H=A[w];(0,l.useEffect)(()=>{!H||N.has(H.path)||r.FH.taskChangeFile(u,h,H.path,m).then(e=>S(t=>new Map(t).set(H.path,e))).catch(e=>S(t=>new Map(t).set(H.path,e.message)))},[H,N,u,h,m]);let R=H?N.get(H.path):void 0,T=(0,l.useMemo)(()=>!R||"string"==typeof R||R.binary||R.tooLarge?[]:eO(eM(R.before),eM(R.after)),[R]),P=H&&q.get(H.path)||new Set,B=(0,l.useMemo)(()=>eq(T,3,P,C),[T,P,C]),_=(0,l.useMemo)(()=>T.flatMap((e,t)=>"same"!==e.kind&&(0===t||"same"===T[t-1].kind)?[t]:[]),[T]);(0,l.useEffect)(()=>{I(-1),z.current&&(z.current.scrollTop=0)},[w]);let $=(0,l.useCallback)(e=>{var t;if(0===_.length)return;let a=L<0?1===e?0:_.length-1:Math.min(_.length-1,Math.max(0,L+e));I(a);let s=null==(t=z.current)?void 0:t.querySelector('[data-row="'.concat(_[a],'"]'));null==s||s.scrollIntoView({block:"center"})},[L,_]),U=(0,l.useCallback)(e=>y(t=>Math.min(Math.max(0,t+e),Math.max(0,A.length-1))),[A.length]);(0,l.useEffect)(()=>{let e=e=>{if(!e.ctrlKey&&!e.metaKey&&!e.altKey){if("Escape"===e.key)f();else if("n"===e.key)$(1);else if("p"===e.key)$(-1);else if("]"===e.key)U(1);else{if("["!==e.key)return;U(-1)}e.preventDefault()}};window.addEventListener("keydown",e);let t=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{window.removeEventListener("keydown",e),document.body.style.overflow=t}},[$,U,f]);let K=A.reduce((e,t)=>({added:e.added+Math.max(0,t.added),removed:e.removed+Math.max(0,t.removed)}),{added:0,removed:0});return(0,s.jsxs)("div",{ref:D,className:"diff-overlay",role:"dialog","aria-modal":"true","aria-labelledby":"diff-title",children:[(0,s.jsxs)("div",{className:"diff-head",children:[(0,s.jsx)("h2",{id:"diff-title",children:x("diff.title",{title:p})}),(null==b?void 0:b.ok)&&(0,s.jsxs)("span",{className:"muted small",children:[b.branch?"".concat(b.branch," \xb7 "):"",null==(t=b.base)?void 0:t.slice(0,8)," → ",null==(a=b.commit)?void 0:a.slice(0,8)," \xb7 ",x("diff.summary",{n:A.length,a:K.added,r:K.removed})]}),(0,s.jsx)("span",{className:"grow"}),(0,s.jsx)("span",{className:"muted small",children:x("diff.keys")}),(0,s.jsx)("button",{ref:W,type:"button",onClick:f,children:x("diff.close")})]}),v&&(0,s.jsx)("div",{className:"err",style:{padding:12},children:v}),!b&&!v&&(0,s.jsx)("div",{className:"muted",style:{padding:12},children:x("diff.loading")}),b&&!b.ok&&(0,s.jsx)("div",{className:"notice caution",style:{margin:12},children:b.problem}),(null==b?void 0:b.ok)&&0===A.length&&(0,s.jsx)("div",{className:"notice",style:{margin:12},children:x("diff.nothing")}),(null==b?void 0:b.ok)&&A.length>0&&(0,s.jsxs)("div",{className:"diff-body",children:[(0,s.jsx)("nav",{className:"diff-files","aria-label":x("diff.files"),children:A.map((e,t)=>{let a=e.path.lastIndexOf("/");return(0,s.jsxs)("button",{type:"button",className:"diff-file".concat(t===w?" on":""),onClick:()=>y(t),title:e.oldPath?"".concat(e.oldPath," → ").concat(e.path):e.path,children:[(0,s.jsx)("span",{className:"diff-status s-".concat(e.status),children:e.status}),(0,s.jsxs)("span",{className:"diff-path",children:[a>=0&&(0,s.jsx)("span",{className:"muted",children:e.path.slice(0,a+1)}),(0,s.jsx)("strong",{children:e.path.slice(a+1)})]}),(0,s.jsx)("span",{className:"diff-counts",children:e.added<0?x("diff.binaryShort"):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("span",{className:"plus",children:["+",e.added]})," ",(0,s.jsxs)("span",{className:"minus",children:["−",e.removed]})]})})]},e.path)})}),(0,s.jsxs)("div",{className:"diff-main",children:[H&&(0,s.jsxs)("div",{className:"diff-toolbar",children:[(0,s.jsxs)("div",{className:"diff-title-row",children:[(0,s.jsx)("strong",{className:"diff-name",children:H.oldPath?"".concat(H.oldPath," → ").concat(H.path):H.path}),(0,s.jsx)("span",{className:"muted small",children:"A"===H.status?x("diff.added"):"D"===H.status?x("diff.deleted"):"R"===H.status?x("diff.renamed"):""})]}),(0,s.jsx)(ez,{changes:_.length,onChange:$,files:{at:w,count:A.length,onFile:U},whole:C,onWhole:F,wrap:M,onWrap:O})]}),(0,s.jsxs)("div",{className:"diff-scroll",ref:z,children:[void 0===R&&(0,s.jsx)("div",{className:"muted",style:{padding:12},children:x("diff.loading")}),"string"==typeof R&&(0,s.jsx)("div",{className:"err",style:{padding:12},children:R}),R&&"string"!=typeof R&&R.binary&&(0,s.jsx)("div",{className:"notice",style:{margin:12},children:x("diff.binary")}),R&&"string"!=typeof R&&R.tooLarge&&(0,s.jsx)("div",{className:"notice",style:{margin:12},children:x("diff.tooLarge")}),R&&"string"!=typeof R&&!R.binary&&!R.tooLarge&&(0,s.jsxs)(s.Fragment,{children:[(null!=(i=R.before)?i:"").includes("\r\n")!==(null!=(c=R.after)?c:"").includes("\r\n")&&null!==R.before&&null!==R.after&&(0,s.jsx)("div",{className:"notice small",style:{margin:8},children:x("diff.eol",{from:(null!=(o=R.before)?o:"").includes("\r\n")?"CRLF":"LF",to:(null!=(d=R.after)?d:"").includes("\r\n")?"CRLF":"LF"})}),T.length>0&&0===_.length&&(0,s.jsx)("div",{className:"notice small",style:{margin:8},children:x("diff.sameText")}),(0,s.jsxs)("table",{className:"diff-table".concat(M?"":" nowrap"),children:[(0,s.jsxs)("colgroup",{children:[(0,s.jsx)("col",{className:"num"}),(0,s.jsx)("col",{}),(0,s.jsx)("col",{className:"num"}),(0,s.jsx)("col",{})]}),(0,s.jsx)(eD,{changes:_.length,at:L}),(0,s.jsx)("tbody",{children:B.map(e=>"gap"===e.type?(0,s.jsx)("tr",{className:"diff-gap",children:(0,s.jsx)("td",{colSpan:4,children:(0,s.jsx)("button",{type:"button",className:"linkish small",onClick:()=>{var t;return t=e.from,void(H&&E(e=>{var a;return new Map(e).set(H.path,new Set([...null!=(a=e.get(H.path))?a:[],t]))}))},children:x("diff.gap",{n:e.count})})})},"g".concat(e.from)):(0,s.jsx)(eW,{row:e.row,index:e.index,current:L>=0&&_[L]===e.index},e.index))})]})]})]})]})]})]})}function ez(e){let{changes:t,onChange:a,files:l,whole:n,onWhole:i,wrap:r,onWrap:c}=e,{t:o}=(0,k.kj)();return(0,s.jsxs)("div",{className:"diff-tools",children:[(0,s.jsxs)("span",{className:"diff-pair",children:[(0,s.jsx)("button",{type:"button",className:"quiet",onClick:()=>a(-1),disabled:0===t,children:o("diff.prevChange")}),(0,s.jsx)("button",{type:"button",className:"quiet",onClick:()=>a(1),disabled:0===t,children:o("diff.nextChange")})]}),l&&l.count>1&&(0,s.jsxs)("span",{className:"diff-pair",children:[(0,s.jsx)("button",{type:"button",className:"quiet",onClick:()=>l.onFile(-1),disabled:0===l.at,children:o("diff.prevFile")}),(0,s.jsx)("button",{type:"button",className:"quiet",onClick:()=>l.onFile(1),disabled:l.at>=l.count-1,children:o("diff.nextFile")})]}),(0,s.jsxs)("span",{className:"diff-pair",children:[(0,s.jsxs)("label",{className:"option-inline",children:[(0,s.jsx)("input",{type:"checkbox",checked:n,onChange:e=>i(e.target.checked)})," ",o("diff.whole")]}),(0,s.jsxs)("label",{className:"option-inline",children:[(0,s.jsx)("input",{type:"checkbox",checked:r,onChange:e=>c(e.target.checked)})," ",o("diff.wrap")]})]})]})}function eD(e){let{changes:t,at:a}=e,{t:l}=(0,k.kj)();return(0,s.jsxs)("thead",{children:[t>0&&(0,s.jsx)("tr",{className:"diff-where",children:(0,s.jsx)("th",{colSpan:4,children:l("diff.changeN",{i:a<0?"–":a+1,n:t})})}),(0,s.jsxs)("tr",{children:[(0,s.jsx)("th",{colSpan:2,children:l("diff.before")}),(0,s.jsx)("th",{colSpan:2,children:l("diff.after")})]})]})}function eW(e){var t,a,n,i;let{row:r,index:c,current:o}=e,d="change"===r.kind?function(e,t){let a=0;for(;a<e.length&&a<t.length&&e[a]===t[a];)a+=1;let s=e.length,l=t.length;for(;s>a&&l>a&&e[s-1]===t[l-1];)s-=1,l-=1;return{start:a,leftEnd:s,rightEnd:l}}(r.left.text,r.right.text):null,u=e=>{let t=r[e];if(!t)return null;if(!d)return t.text;let a="left"===e?d.leftEnd:d.rightEnd;return(0,s.jsxs)(l.Fragment,{children:[t.text.slice(0,d.start),(0,s.jsx)("mark",{children:t.text.slice(d.start,a)}),t.text.slice(a)]})};return(0,s.jsxs)("tr",{className:"diff-row ".concat(r.kind).concat(o?" current":""),"data-row":c,children:[(0,s.jsx)("td",{className:"num",children:null!=(n=null==(t=r.left)?void 0:t.no)?n:""}),(0,s.jsx)("td",{className:"code l".concat(r.left?"":" empty"),children:u("left")}),(0,s.jsx)("td",{className:"num",children:null!=(i=null==(a=r.right)?void 0:a.no)?i:""}),(0,s.jsx)("td",{className:"code r".concat(r.right?"":" empty"),children:u("right")})]})}function eA(e){var t;let{area:a,path:n,commit:i}=e,{t:c}=(0,k.kj)(),[o,d]=(0,l.useState)(null),[u,h]=(0,l.useState)(""),[p,f]=(0,l.useState)(!1),[x,b]=(0,l.useState)(!0),[g,v]=(0,l.useState)(new Set),[j,w]=(0,l.useState)(-1),y=(0,l.useRef)(null),N=(0,l.useCallback)(()=>r.FH.workspaceGitFile(a,n,i).then(e=>{d(e),h("")}).catch(e=>h(e.message)),[a,n,i]);(0,l.useEffect)(()=>{d(null),h(""),v(new Set),w(-1),N()},[N]),(0,m.z)(N,5e3,"commit"!==a);let S=(0,l.useMemo)(()=>!o||o.binary||o.tooLarge?[]:eO(eM(o.before),eM(o.after)),[o]),C=(0,l.useMemo)(()=>eq(S,3,g,p),[S,g,p]),F=(0,l.useMemo)(()=>S.flatMap((e,t)=>"same"!==e.kind&&(0===t||"same"===S[t-1].kind)?[t]:[]),[S]),M="commit"===a?(null!=i?i:"").slice(0,7):"branch"===a?c("git.againstBase",{base:null!=i?i:""}):c("staged"===a?"git.index":"git.workingTree"),O=null!=(t=null==o?void 0:o.status)?t:"";return(0,s.jsxs)("div",{className:"wb-gitdiff",children:[(0,s.jsxs)("div",{className:"diff-toolbar",children:[(0,s.jsxs)("div",{className:"diff-title-row",children:[(0,s.jsx)("strong",{className:"diff-name",children:(null==o?void 0:o.oldPath)?"".concat(o.oldPath," → ").concat(n):n}),(0,s.jsxs)("span",{className:"muted small",children:[M,O?" \xb7 ".concat(c("git.status.".concat("!"===O?"conflict":O))):""]})]}),(0,s.jsx)(ez,{changes:F.length,onChange:e=>{var t,a;if(0===F.length)return;let s=j<0?1===e?0:F.length-1:Math.min(F.length-1,Math.max(0,j+e));w(s),null==(a=y.current)||null==(t=a.querySelector('[data-row="'.concat(F[s],'"]')))||t.scrollIntoView({block:"center"})},whole:p,onWhole:f,wrap:x,onWrap:b})]}),(0,s.jsxs)("div",{className:"diff-scroll",ref:y,children:[u&&(0,s.jsx)("div",{className:"err",style:{padding:12},children:u}),!o&&!u&&(0,s.jsx)("div",{className:"muted",style:{padding:12},children:c("diff.loading")}),(null==o?void 0:o.binary)&&(0,s.jsx)("div",{className:"notice",style:{margin:12},children:c("diff.binary")}),(null==o?void 0:o.tooLarge)&&(0,s.jsx)("div",{className:"notice",style:{margin:12},children:c("diff.tooLarge")}),o&&!o.binary&&!o.tooLarge&&(0,s.jsxs)(s.Fragment,{children:[S.length>0&&0===F.length&&(0,s.jsx)("div",{className:"notice small",style:{margin:8},children:c("diff.sameText")}),(0,s.jsxs)("table",{className:"diff-table".concat(x?"":" nowrap"),children:[(0,s.jsxs)("colgroup",{children:[(0,s.jsx)("col",{className:"num"}),(0,s.jsx)("col",{}),(0,s.jsx)("col",{className:"num"}),(0,s.jsx)("col",{})]}),(0,s.jsx)(eD,{changes:F.length,at:j}),(0,s.jsx)("tbody",{children:C.map(e=>"gap"===e.type?(0,s.jsx)("tr",{className:"diff-gap",children:(0,s.jsx)("td",{colSpan:4,children:(0,s.jsx)("button",{type:"button",className:"linkish small",onClick:()=>v(t=>new Set([...t,e.from])),children:c("diff.gap",{n:e.count})})})},"g".concat(e.from)):(0,s.jsx)(eW,{row:e.row,index:e.index,current:j>=0&&F[j]===e.index},e.index))})]})]})]})]})}var eH=a(61238),eR=a(52157);let eT="",eP=new Set;function eB(e){if(e!==eT)for(let t of(eT=e,eP))t()}function e_(e){return eP.add(e),()=>{eP.delete(e)}}function e$(){return[(0,l.useSyncExternalStore)(e_,()=>eT,()=>""),eB]}var eU=a(41370),eK=a(33389),eV=a(68176);function eZ(e,t){let[a,s]=(0,l.useState)(null),n=(0,l.useRef)(!0),[i,r]=(0,l.useState)(!0),c=(0,l.useRef)(e);c.current=e;let o=(0,l.useRef)(null),d=(0,l.useRef)(0),u=(0,l.useRef)(new Set),h=(0,l.useCallback)(e=>s(e),[]),m=(0,l.useCallback)(e=>{n.current!==e&&(n.current=e,r(e))},[]),p=e=>[...e.querySelectorAll("[data-awaits]")].filter(e=>!e.closest("[data-kerrigan-thinking]")),f=e=>{var t;return null!=(t=e.closest("[data-awaits-frame]"))?t:e},x=(e,t,a)=>{let s=t.getBoundingClientRect().top-e.getBoundingClientRect().top+e.scrollTop,l=e.clientHeight-t.offsetHeight;return a&&l>24?s-l/2:s-12},b=(e,t)=>{let a=e.scrollHeight-e.clientHeight;e.scrollTop=Math.max(0,Math.min(a,t)),o.current=e.scrollTop,d.current=e.scrollTop},g=e=>{let t=p(e)[0],a=e.scrollHeight-e.clientHeight;b(e,t?Math.min(a,x(e,f(t),!1)):a)},v=e=>{var t;if(0===e.clientHeight)return!1;let a=p(e),s=a.filter(e=>{var t;return!u.current.has(null!=(t=e.dataset.awaits)?t:"")});for(let e of a)u.current.add(null!=(t=e.dataset.awaits)?t:"");let l=s[0];return!!l&&(n.current?g(e):b(e,x(e,f(l),!0)),!0)};return(0,l.useLayoutEffect)(()=>{if(!a)return;a.dataset.follow="",d.current=a.scrollTop;let e=()=>{let e=a.scrollTop,t=a.scrollHeight-e-a.clientHeight<=24,s=null!==o.current&&1>=Math.abs(e-o.current);o.current=null,t?m(!0):!s&&e<d.current-1&&m(!1),d.current=e},t=()=>{c.current&&!v(a)&&n.current&&g(a)},s=new ResizeObserver(t);for(let e of(s.observe(a),a.children))s.observe(e);let l=new MutationObserver(e=>{for(let t of e){for(let e of t.addedNodes)e instanceof Element&&e.parentElement===a&&s.observe(e);for(let e of t.removedNodes)e instanceof Element&&s.unobserve(e)}t()});return l.observe(a,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["data-awaits","data-kerrigan-thinking"]}),a.addEventListener("scroll",e,{passive:!0}),()=>{a.removeEventListener("scroll",e),s.disconnect(),l.disconnect(),delete a.dataset.follow}},[a,m]),(0,l.useLayoutEffect)(()=>{a&&e&&!v(a)&&n.current&&g(a)},[a,e,t]),{ref:h,following:i,follow:(0,l.useCallback)(()=>{n.current=!0,r(!0),a&&g(a)},[a])}}var eJ=a(51035),eG=a(24784),eY=a(65132),eQ=a(36657),eX=a(92842),e0=a(79717);let e1={done:"✓",running:"●",planned:"○",blocked:"⊘",failed:"✗",stopped:"■"},e2={done:"lead.todo.done",running:"lead.todo.running",planned:"lead.todo.planned",blocked:"lead.todo.blocked",failed:"lead.todo.failed",stopped:"lead.todo.stopped"};function e3(e){var t,a;let s=[];for(let t of e.items)t.phase&&!s.includes(t.phase)&&s.push(t.phase);let l=null!=(a=null!=(t=e.items.find(e=>"running"===e.status))?t:e.items.find(e=>"planned"===e.status))?a:e.items.at(-1);return{phases:s,current:(null==l?void 0:l.phase)?s.indexOf(l.phase):-1}}function e4(e){let{lead:t,live:a}=e,{t:l}=(0,k.kj)(),n=t.ledger;if(!n||0===n.items.length)return(0,s.jsx)("p",{className:"muted small cs-lead-progress",children:l("lead.subtasks",{n:t.subtasks,max:t.maxSubtasks})});let i=n.items,r=e=>i.filter(t=>t.status===e).length,c=i.findIndex(e=>"running"===e.status),o=r("blocked")+r("failed"),{phases:d,current:u}=e3(n);return(0,s.jsxs)("div",{className:"cs-lead-progress",role:"status",children:[d.length>0&&u>=0&&(0,s.jsx)("p",{className:"cs-lead-phase",children:l("lead.phase",{n:u+1,total:d.length,title:d[u]})}),(0,s.jsxs)("p",{className:"small",children:[(0,s.jsx)("strong",{children:a&&c>=0?l("lead.subtaskOf",{n:c+1,total:i.length}):l("lead.doneOf",{done:r("done"),total:i.length})}),o>0&&(0,s.jsxs)("span",{className:"cs-lead-stuck",children:[" \xb7 ",l("lead.stuck",{n:o})]})]}),(0,s.jsx)("p",{className:"muted small",children:l("lead.left",{left:r("planned"),max:t.maxSubtasks})}),(0,s.jsx)(e5,{ledger:n,live:a})]})}function e5(e){let{ledger:t,live:a}=e,{t:l}=(0,k.kj)(),{phases:n}=e3(t),i=0===n.length?[{phase:"",items:t.items}]:[];if(n.length>0){for(let e of n)i.push({phase:e,items:t.items.filter(t=>t.phase===e)});let e=t.items.filter(e=>!e.phase);e.length>0&&i.push({phase:l("lead.otherPhase"),items:e})}let r=i.map(e=>[...e.phase?["## ".concat(e.phase)]:[],...e.items.map(e=>"".concat(e1["running"===e.status&&!a?"stopped":e.status]," ").concat(e.title).concat(e.n?" (#".concat(e.n,")"):""))].join("\n")).join("\n\n");return(0,s.jsxs)("details",{className:"cs-ledger",children:[(0,s.jsx)("summary",{children:l("lead.ledgerList",{v:t.revision})}),(0,s.jsx)("div",{className:"cs-copy-row",children:(0,s.jsx)(et.i8,{text:r,what:"lead.copyList"})}),i.map(e=>(0,s.jsxs)("div",{className:"cs-ledger-group",children:[e.phase&&(0,s.jsx)("p",{className:"cs-ledger-phase",children:e.phase}),(0,s.jsx)("ul",{children:e.items.map(e=>{let t="running"!==e.status||a?e.status:"stopped";return(0,s.jsxs)("li",{className:"cs-todo cs-todo-".concat(t),children:[(0,s.jsx)("span",{className:"cs-todo-mark",title:l(e2[t]),"aria-label":l(e2[t]),children:e1[t]}),(0,s.jsx)("span",{className:"cs-todo-title",children:e.title}),e.n?(0,s.jsxs)("span",{className:"muted small",title:l("lead.givenAs",{n:e.n}),children:[" ","#",e.n]}):null]},e.title)})})]},e.phase||"-"))]})}function e6(e){let{change:t}=e,{t:a}=(0,k.kj)();if(1===t.revision)return(0,s.jsx)("p",{className:"cs-system cs-ledger-change",children:a("lead.ledgerFirst",{n:t.total})});let l=[t.added>0?a("lead.ledgerAdded",{n:t.added}):"",t.removed>0?a("lead.ledgerRemoved",{n:t.removed}):""].filter(Boolean).join(", ")||a("lead.ledgerReordered");return(0,s.jsx)("p",{className:"cs-system cs-ledger-change",children:a("lead.ledgerChanged",{v:t.revision,what:l})})}function e8(e){var t,a;let{workspace:n,running:i,queue:r=!1,onMade:c}=e,{t:o}=(0,k.kj)(),[d,u]=(0,l.useState)(!1),h=(t={running:i,queue:r,workspace:n}).running?o("nb.offRunning"):t.queue?o("nb.offQueue"):(null==(a=t.workspace)?void 0:a.ok)?t.workspace.isRepo?"":o("nb.offNoRepo"):o("nb.offNoFolder");return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("button",{type:"button",className:"button-link plain small cs-new-branch","aria-disabled":!!h||void 0,onClick:()=>!h&&u(!0),title:h||o("nb.buttonWhy"),children:o("nb.button")}),d&&(0,s.jsx)(e7,{onClose:()=>u(!1),onMade:e=>{u(!1),c(e)}})]})}function e7(e){var t,a,n,i,c,o,d,u,h,m,p;let{onClose:f,onMade:x}=e,{t:b}=(0,k.kj)(),g=(0,k.W3)(),v=(0,l.useRef)(null),j=(0,l.useRef)(null),[w,y]=(0,l.useState)(null),[N,S]=(0,l.useState)(!0),[C,F]=(0,l.useState)(""),[M,O]=(0,l.useState)("take"),[q,E]=(0,l.useState)(""),[L,I]=(0,l.useState)(!1),[z,D]=(0,l.useState)(""),[W,A]=(0,l.useState)(!1),H=(0,eU.q)(N||L);(0,eE.V)(v,!0,j);let R=async e=>{S(!0),D(""),A(!1);try{let t=await r.FH.newBranchPreview(e);y(t),t.suggested&&F(e=>e||t.suggested)}catch(e){y(null),D(e.message)}finally{S(!1)}};(0,l.useEffect)(()=>{R(!0)},[]),(0,l.useEffect)(()=>{let e=e=>{"Escape"!==e.key||L||(e.preventDefault(),f())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[L,f]);let T=async()=>{if(null==w?void 0:w.fingerprint){I(!0),D(""),A(!1);try{let e=await r.FH.newBranchCreate(C.trim(),M,w.fingerprint,"commit"===M?q:void 0);if(e.ok)return void x(e.result);D(e.problem),e.conflict&&(A(!0),O("aside"))}catch(e){D(e.message)}finally{I(!1)}}},P=(null!=(t=null==w?void 0:w.changed.length)?t:0)+(null!=(a=null==w?void 0:w.untracked.length)?a:0),B=(null==w?void 0:w.fetched)&&!w.fetched.ok,_=[...null!=(n=null==w?void 0:w.changed)?n:[],...null!=(i=null==w?void 0:w.untracked)?i:[]];return(0,s.jsx)("div",{className:"modal-backdrop",role:"presentation",onClick:()=>!L&&f(),children:(0,s.jsxs)("div",{ref:v,className:"modal wide nb",role:"dialog","aria-modal":"true","aria-labelledby":"nb-title",onClick:e=>e.stopPropagation(),children:[(0,s.jsx)("h2",{id:"nb-title",children:b("nb.title")}),N?(0,s.jsxs)("div",{className:"nb-reading",role:"status",children:[(0,s.jsxs)("p",{children:[b("nb.fetching"),(0,s.jsx)("span",{className:"saving-dots",children:H})]}),(0,s.jsx)("p",{className:"muted small",children:b("nb.passwordNote")})]}):(0,s.jsxs)(s.Fragment,{children:[(null==w?void 0:w.ok)&&(0,s.jsxs)(s.Fragment,{children:[B&&(0,s.jsxs)("div",{className:"nb-warn",role:"alert",children:[(0,s.jsx)("p",{children:b(w.fetched.auth?"nb.fetchAuth":"nb.fetchFailed",{remote:null!=(c=w.remote)?c:"origin",detail:null!=(o=w.fetched.detail)?o:""})}),(0,s.jsx)("p",{className:"small",children:w.lastFetched?b("nb.lastFetched",{target:null!=(d=w.target)?d:"",at:g(w.lastFetched)}):b("nb.lastKnown",{target:null!=(u=w.target)?u:""})}),(0,s.jsx)("div",{className:"row",children:(0,s.jsx)("button",{type:"button",onClick:()=>void R(!0),disabled:L,children:b("nb.tryAgain")})})]}),(0,s.jsxs)("p",{className:"nb-from",children:[b("nb.from",{target:null!=(h=w.target)?h:"",commit:(null!=(m=w.targetCommit)?m:"").slice(0,8)})," ",w.targetSubject&&(0,s.jsxs)("span",{className:"muted",children:["— ",w.targetSubject]})]}),(0,s.jsx)("p",{className:"small muted",children:w.branch?b("nb.now",{branch:w.branch}):b("nb.nowDetached")}),(0,s.jsxs)("div",{className:"settings-field",children:[(0,s.jsx)("label",{htmlFor:"nb-name",className:"field-label",children:b("nb.name")}),(0,s.jsx)("input",{id:"nb-name",type:"text",dir:"ltr",value:C,onChange:e=>F(e.target.value),spellCheck:!1,disabled:L})]}),P>0&&(0,s.jsxs)("fieldset",{className:"nb-dirty",children:[(0,s.jsx)("legend",{children:b("nb.dirty",{n:P})}),(0,s.jsxs)("ul",{className:"small nb-files",children:[_.slice(0,8).map(e=>(0,s.jsx)("li",{children:(0,s.jsx)("code",{children:e})},e)),_.length>8&&(0,s.jsx)("li",{className:"muted",children:b("nb.more",{n:_.length-8})})]}),(0,s.jsxs)("label",{className:"nb-choice",children:[(0,s.jsx)("input",{type:"radio",name:"nb-carry",checked:"take"===M,onChange:()=>O("take"),disabled:W||L}),(0,s.jsxs)("span",{children:[(0,s.jsx)("strong",{children:b("nb.take")})," ",(0,s.jsx)("span",{className:"muted small",children:b("nb.takeWhy")})]})]}),(0,s.jsxs)("label",{className:"nb-choice",children:[(0,s.jsx)("input",{type:"radio",name:"nb-carry",checked:"aside"===M,onChange:()=>O("aside"),disabled:L}),(0,s.jsxs)("span",{children:[(0,s.jsx)("strong",{children:b("nb.aside")})," ",(0,s.jsx)("span",{className:"muted small",children:b("nb.asideWhy")})]})]}),(0,s.jsxs)("label",{className:"nb-choice",title:w.branch?void 0:b("nb.commitDetached"),children:[(0,s.jsx)("input",{type:"radio",name:"nb-carry",checked:"commit"===M,onChange:()=>O("commit"),disabled:L||!w.branch}),(0,s.jsxs)("span",{children:[(0,s.jsx)("strong",{children:b("nb.commit",{branch:null!=(p=w.branch)?p:"—"})})," ",(0,s.jsx)("span",{className:"muted small",children:b("nb.commitWhy")})]})]}),"commit"===M&&w.branch&&(0,s.jsxs)("div",{className:"settings-field nb-message",children:[(0,s.jsx)("label",{htmlFor:"nb-message",className:"field-label",children:b("nb.commitMessage")}),(0,s.jsx)("input",{id:"nb-message",type:"text",value:q,onChange:e=>E(e.target.value),placeholder:"Work in progress, before a new branch from main",disabled:L,maxLength:2e3})]})]}),(0,s.jsx)("p",{className:"muted small",children:b("nb.after")})]}),z&&(0,s.jsx)("p",{className:"err",role:"alert",children:z})]}),(0,s.jsxs)("div",{className:"row modal-actions",children:[(0,s.jsx)("button",{ref:j,type:"button",className:"quiet",onClick:f,disabled:L,children:b("nb.cancel")}),!N&&!(null==w?void 0:w.ok)&&(0,s.jsx)("button",{type:"button",onClick:()=>void R(!0),children:b("nb.tryAgain")}),!N&&(null==w?void 0:w.ok)&&z&&!L&&(0,s.jsx)("button",{type:"button",onClick:()=>void R(!0),children:b("nb.tryAgain")}),!N&&(null==w?void 0:w.ok)&&(0,s.jsx)("button",{type:"button",className:"primary",onClick:()=>void T(),disabled:L||!C.trim(),"aria-busy":L||void 0,children:L?(0,s.jsxs)(s.Fragment,{children:[b("nb.making"),(0,s.jsx)("span",{className:"saving-dots",children:H})]}):b(B?"nb.makeFromLast":"nb.make")})]})]})})}var e9=a(34982),te=a(44504),tt=a(14236);let ta="cop.chat.thread",ts="cop.chat.plan",tl="cop.chat.review",tn="cop.chat.lead",ti="cop.chat.kerrigan",tr=(e,t)=>{try{t?window.localStorage.setItem(e,t):window.localStorage.removeItem(e)}catch(e){}},tc=e=>{try{var t;return null!=(t=window.localStorage.getItem(e))?t:""}catch(e){return""}};function to(e){var t,a,n,c,o,d,u,h,p,f,x,b,g,v,j,w,y,N,S,C,F,M;let{workspace:O,composeAsk:q,showThread:E,onOpenFile:L,onChange:I,onOpenFolder:z,onTurn:D}=e,{t:W,locale:A}=(0,k.kj)(),[H,R]=(0,l.useState)([]),[T,P]=(0,l.useState)(""),[B,_]=(0,l.useState)(null),[$,U]=(0,l.useState)(!1),[K,V]=(0,l.useState)(!0),[Z,J]=(0,l.useState)(""),[G,Y]=(0,l.useState)(!1),[Q,X]=(0,l.useState)(""),[ee,ea]=(0,l.useState)(!1),[es,el]=(0,l.useState)(null),[en,ei]=(0,l.useState)(""),[er,ec]=(0,l.useState)(!1),[eo,ed]=(0,l.useState)(""),[eu,eh]=(0,l.useState)([]),[em,ep]=(0,l.useState)(null),[ef,ex]=(0,l.useState)(""),[eb,eg]=(0,l.useState)(!1),[ev,ej]=(0,l.useState)([]),[ew,ek]=e$(),ey=(0,l.useRef)(null),eN=!!B&&("idle"!==B.status||!!B.directedBy&&B.tasks.some(e=>"running"===e.status||"waiting-approval"===e.status)),eS=B?!!B.lead||!!B.kerrigan:G||ee,eC=null!=(p=(B?!!B.kerrigan:ee)?(null==em?void 0:em.defaultKerriganModel)||(null==em?void 0:em.defaultLeadModel)||(null==em?void 0:em.defaultModel):eS&&(null==em?void 0:em.defaultLeadModel)||(null==em?void 0:em.defaultModel))?p:"",eF=null!=(f=null==em?void 0:em.defaultModel)?f:"",eM=B?!B.manualModel&&(B.model||eC)?null!=(x=B.model)?x:"":eG.u:"",eO=ef!==eG.u&&(ef||eC)?ef:eG.u;(0,l.useEffect)(()=>{P(tc(ta)),U("on"===tc(ts)),V("off"!==tc(tl)),Y("on"===tc(tn)&&"on"!==tc(ti)),ea("on"===tc(ti))},[]),(0,l.useEffect)(()=>{var e;q>0&&(null==(e=ey.current)||e.focus())},[q]),(0,l.useEffect)(()=>{(null==E?void 0:E.id)&&eP(E.id)},[null==E?void 0:E.n]),(0,l.useEffect)(()=>{r.FH.models().then(ep).catch(()=>void 0),r.FH.skills().then(e=>ej(e.skills)).catch(()=>void 0)},[]);let eq=e=>e.trim().replace(/[\\/]+$/,"").replace(/\//g,"\\").toLowerCase(),eE=ev.filter(e=>!e.projectDir||(null==O?void 0:O.dir)&&eq(e.projectDir)===eq(O.dir)),eL=(0,l.useCallback)(()=>r.FH.chatThreads().then(R).catch(()=>void 0),[]);(0,m.z)(eL,5e3);let eI=(0,l.useRef)(T);eI.current=T;let ez=(0,l.useCallback)(()=>{let e=eI.current;return e?r.FH.session(e).then(t=>{eI.current===e&&_("chat"===t.kind?t:null)}).catch(t=>{404===t.status&&eI.current===e&&(_(null),P(""),tr(ta,""))}):Promise.resolve(_(null))},[]);(0,l.useEffect)(()=>{ez()},[T,ez]),(0,m.z)(ez,eN?1500:5e3,!!T);let eD=(0,l.useRef)(new Set),eW=()=>T&&eN?r.FH.approvals(T).then(e=>eh(e.filter(e=>!eD.current.has(e.id)))).catch(()=>void 0):Promise.resolve(eh([]));(0,m.z)(eW,1500,!!T);let eA=(e,t)=>{t&&(eD.current.add(e),eh(t=>t.filter(t=>t.id!==e))),eW()},eR=null!=(b=null==B||null==(t=B.lead)?void 0:t.workerSessionId)?b:"",eT=(0,l.useCallback)(()=>eR?r.FH.session(eR).then(el).catch(()=>void 0):Promise.resolve(el(null)),[eR]);(0,l.useEffect)(()=>{eT()},[eT]),(0,m.z)(eT,eN?1500:1e4,!!eR);let eP=e=>{eI.current=e,P(e),tr(ta,e),ed(""),eQ(null)},eB=e=>(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("label",{htmlFor:"cs-model",className:"sr-only",children:W("chat.model")}),(0,s.jsx)(eG.Yb,{id:"cs-model",chosen:B?eM:eO,onChange:e=>void e6(e),byHand:W("chat.modelByHand"),none:eC?W("chat.modelDefault",{model:eC}):void 0,catalogue:em,disabled:eN,style:{minWidth:0,maxWidth:e}}),(0,s.jsx)("button",{type:"button",className:"wb-icon-btn",onClick:()=>void to(),disabled:eb||eN,title:W("chat.readModels"),"aria-label":W("chat.readModels"),children:"↻"})]}),e_=eN||H.some(e=>e.running),eK=e_?W("chat.newChatRunning"):B?"":W("chat.newChatFresh"),eV=()=>{var e;eP(""),_(null),null==(e=ey.current)||e.focus()},[eY,eQ]=(0,l.useState)(null),eX=e=>e.replace(/^chat: /,""),e0=async()=>{var e;let t=null!=(e=null==eY?void 0:eY.trim())?e:"";if(B&&t)try{let e=await r.FH.updateSession(B.id,{name:t});_(t=>t&&t.id===e.id?{...t,name:e.name}:t),R(t=>t.map(t=>t.id===e.id?{...t,name:e.name}:t)),eQ(null),ed("")}catch(e){ed(e.message)}},e1=async()=>{let e=en.trim();if(!e||er)return;let t=ew,a=eE.length>0?/^\/([a-z0-9][a-z0-9-]*[a-z0-9])(?=\s|$)\s*([\s\S]*)$/.exec(e):null;if(a){let s=eE.find(e=>e.name===a[1]);if(!s)return void ed(W("chat.skillUnknown",{name:a[1],names:eE.map(e=>"/".concat(e.name)).join(", ")}));if(!a[2].trim())return void ed(W("chat.skillNoText",{name:s.name}));t=s.name,e=a[2].trim()}ec(!0),ed("");try{var s;let a=!T,l=a&&ef===eG.u,n=a&&G&&!ee?{workerModel:Q===eG.u?void 0:Q||void 0,workerManualModel:Q===eG.u}:void 0,i=a&&ee?{chatModel:Q===eG.u?void 0:Q||void 0,chatManualModel:Q===eG.u}:void 0,c=await r.FH.chatSend(e,T||void 0,a&&!l&&ef||void 0,l,A,a&&$&&!i,a?!n&&!i&&K:void 0,n,t||void 0,a&&!n&&!i&&Z||void 0,i);if(ei(""),ek(""),eP(c.threadId),c.noted)return void ed(W("chat.noted"));let o=await r.FH.settings().then(e=>{var t;return(null==(t=e.raw.execution)?void 0:t.mode)==="unattended"?"unattended":"confirm"}).catch(()=>"confirm"),d=await r.FH.start(c.threadId,o);d.started||ed(W("chat.notStarted",{reason:null!=(s=d.reason)?s:""}))}catch(e){ed(e.message)}finally{ec(!1),ez(),eL(),I()}},e2=async(e,t,a)=>{if(!B||er)return!1;ec(!0),ed("");let s=!1;try{var l;let n=await r.FH.chatRetrySubtask(B.id,e.id,t,a);s=n.started,n.started||ed(null!=(l=n.reason)?l:W("retry.notStarted"))}catch(e){ed(e.message)}finally{ec(!1),ez()}return s},e3=async e=>{if(B&&!er){ec(!0),ed("");try{var t;let a=await r.FH.chatContinue(B.id,e.id);a.started||ed(null!=(t=a.reason)?t:W("chat.carryOnNotStarted"))}catch(e){ed(e.message)}finally{ec(!1),ez(),eL(),I()}}},e4=async e=>{if(B&&!er&&await (0,eJ.Z)(W("chat.rewindConfirm",{n:B.tasks.length-B.tasks.indexOf(e)}))){ec(!0),ed("");try{var t;let a=await r.FH.chatRewind(B.id,e.id);ei(a.text),ed(W("chat.rewound")),null==(t=ey.current)||t.focus()}catch(e){ed(e.message)}finally{ec(!1),ez(),I()}}},e5=async e=>{if(B){_(t=>{var a;if(!t)return t;let{review:s,workerModel:l,workerManualModel:n,...i}=e;return{...t,...i,...s?{review:{...null!=(a=t.review)?a:{enabled:!0,model:""},...s}}:{},...(null==s?void 0:s.model)!==void 0?{reviewModelSource:s.model?"operator":void 0}:{},...t.lead&&(void 0!==l||void 0!==n)?{lead:{...t.lead,workerManualModel:n||void 0,workerModel:n?void 0:l||void 0}}:{},...t.kerrigan&&(void 0!==l||void 0!==n)?{kerrigan:{chatManualModel:n||void 0,chatModel:n?void 0:l||void 0}}:{}}});try{await r.FH.updateSession(B.id,e)}catch(e){ed(e.message)}finally{ez()}}},e6=async e=>{if(!B)return void ex(e);await e5(e===eG.u?{model:"",manualModel:!0}:{model:e,manualModel:!1})},e7=B?!!B.lead:G&&!ee,e9=B?!!B.kerrigan:ee,te=B?B.kerrigan?B.kerrigan.chatManualModel?eG.u:null!=(g=B.kerrigan.chatModel)?g:"":(null==(a=B.lead)?void 0:a.workerManualModel)?eG.u:null!=(v=null==(n=B.lead)?void 0:n.workerModel)?v:"":Q,tt=async e=>{if(!B)return void X(e);await e5(e===eG.u?{workerModel:"",workerManualModel:!0}:{workerModel:e,workerManualModel:!1})},to=async()=>{eg(!0),ed(W("chat.modelsReading"));try{ep(await r.FH.refreshModels()),ed(W("chat.modelsRead"))}catch(e){ed(e.message)}finally{eg(!1)}},tu=B?"approve"===B.planMode:$,th=async e=>{if(!B){U(e),tr(ts,e?"on":"");return}await e5({planMode:e?"approve":"off"})},tm=B?(null==(c=B.review)?void 0:c.enabled)!==!1:K,tf=async e=>{if(!B){V(e),tr(tl,e?"":"off");return}await e5({review:{enabled:e}})},tx=B?"operator"===B.reviewModelSource&&null!=(j=null==(o=B.review)?void 0:o.model)?j:"":Z,tb=null!=(w=null==em?void 0:em.defaultReviewModel)?w:"",tg=async e=>{if(!B)return void J(e);await e5({review:{model:e}})},tv=eN&&!!(null==B?void 0:B.paused),tj=(0,eH.v)(),tw=async()=>{if(!B)return;let e=!B.paused;_(t=>t?{...t,paused:e}:t);try{await (e?r.FH.pause(B.id):r.FH.resume(B.id))}catch(e){ed(e.message)}finally{ez()}},[tN,tS]=(0,l.useState)(!1);(0,l.useEffect)(()=>{eN||tS(!1)},[eN]),(0,l.useEffect)(()=>{tS(!1)},[null==B?void 0:B.id]);let tC=(0,eU.q)(tN),tF=null==B?void 0:B.tasks.at(-1),tM=null==tF||null==(u=tF.lead)||null==(d=u.rounds.filter(e=>e.subtask).at(-1))?void 0:d.subtask;(0,l.useEffect)(()=>{D(T?B&&tF?tM&&eR?{sessionId:eR,taskId:tM.taskId}:{sessionId:B.id,taskId:tF.id}:null:"new")},[T,null==B?void 0:B.id,null==tF?void 0:tF.id,null==tM?void 0:tM.taskId,eR]);let{ref:tO}=eZ(!0,"".concat(null!=(y=null==B?void 0:B.tasks.length)?y:0,":").concat(null!=(N=null==tF?void 0:tF.status)?N:"",":").concat(null!=(S=null==tF?void 0:tF.iterations)?S:0));return(0,s.jsxs)("div",{className:"cs",children:[(0,s.jsxs)("div",{className:"cs-head",children:[null!==eY&&B?(0,s.jsxs)("form",{className:"cs-rename",onSubmit:e=>{e.preventDefault(),e0()},children:[(0,s.jsx)("label",{htmlFor:"cs-rename",className:"sr-only",children:W("chat.renameLabel")}),(0,s.jsx)("input",{id:"cs-rename",type:"text",dir:"auto",maxLength:120,value:eY,autoFocus:!0,onFocus:e=>e.target.select(),onChange:e=>eQ(e.target.value),onKeyDown:e=>{"Escape"===e.key&&(e.preventDefault(),eQ(null))}}),(0,s.jsx)("button",{type:"submit",className:"wb-icon-btn",disabled:!eY.trim(),title:W("chat.renameSave"),"aria-label":W("chat.renameSave"),children:"✓"}),(0,s.jsx)("button",{type:"button",className:"wb-icon-btn",onClick:()=>eQ(null),title:W("chat.renameCancel"),"aria-label":W("chat.renameCancel"),children:"✕"})]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("label",{htmlFor:"cs-thread",className:"sr-only",children:W("chat.thread")}),(0,s.jsxs)("select",{id:"cs-thread",dir:"auto",value:T,onChange:e=>eP(e.target.value),children:[(0,s.jsx)("option",{value:"",children:W("chat.newThread")}),(function(e){var t,a;let s=new Map,l=new Set(e.map(e=>e.id));for(let a of e)a.directedBy&&l.has(a.directedBy)&&s.set(a.directedBy,[...null!=(t=s.get(a.directedBy))?t:[],a]);let n=[];for(let t of e)t.directedBy&&l.has(t.directedBy)||(n.push(t),n.push(...(null!=(a=s.get(t.id))?a:[]).sort((e,t)=>e.createdAt.localeCompare(t.createdAt))));return n})(H).map(e=>(0,s.jsx)("option",{value:e.id,children:e.kerrigan?"✦ ".concat(eX(e.name)):e.directedBy?" ↳ ".concat(eX(e.name)):eX(e.name)},e.id))]}),B&&(0,s.jsx)("button",{type:"button",className:"wb-icon-btn cs-rename-btn",onClick:()=>eQ(eX(B.name)),title:W("chat.rename"),"aria-label":W("chat.rename"),children:"✎"})]}),(0,s.jsxs)("span",{className:"cs-new-wrap",children:[(0,s.jsx)("button",{type:"button",className:"cs-new","aria-disabled":!!eK||void 0,"aria-describedby":eK?"cs-new-tip":void 0,onClick:()=>{eK||eV()},title:eK?void 0:W("chat.newChatWhy"),children:W("chat.newChat")}),eK&&(0,s.jsx)("span",{id:"cs-new-tip",role:"tooltip",className:"cs-new-tip",children:eK})]})]}),(0,s.jsxs)("div",{className:"cs-body",ref:tO,"aria-live":"polite",children:[(null==B?void 0:B.directedBy)&&(0,s.jsxs)("p",{className:"cs-system cs-directed",children:[W("kz.directedBy")," ",(0,s.jsx)("button",{type:"button",className:"quiet small",onClick:()=>eP(B.directedBy),children:W("kz.openHers")})]}),B?B.tasks.map((e,t)=>B.kerrigan?(0,s.jsx)(ty,{n:t+1,session:B,task:e,threads:H,approvals:eu,onDecided:eA,onOpenFile:L,onOpenChat:eP,onRewind:eN||er?void 0:()=>void e4(e)},e.id):B.lead?(0,s.jsx)(tk,{n:t+1,session:B,task:e,worker:es,approvals:eu,onDecided:eA,onOpenFile:L,onRewind:eN||er?void 0:()=>void e4(e),onRetrySubtask:eN||"aborted"!==e.status?void 0:(t,a)=>e2(e,t,a)},e.id):(0,s.jsx)(tp,{n:t+1,session:B,task:e,approvals:eu.filter(t=>t.taskId===e.id),onDecided:eA,onOpenFile:L,onRewind:eN||er?void 0:()=>void e4(e)},e.id)):(0,s.jsx)(td,{workspace:O,onPick:e=>{var t;ei(e),null==(t=ey.current)||t.focus()},onOpenFolder:z}),B&&!eN&&!(B.directedBy&&(null==(h=B.tasks.at(-1))?void 0:h.fromKerrigan))&&!!(M=B.tasks.at(-1))&&!!(0,r.ex)(M.parked)&&("queued"===M.status||"aborted"===M.status||"limit-reached"===M.status||!!M.limit&&("failed"===M.status||"blocked"===M.status))&&(0,s.jsxs)("div",{className:"cs-system cs-carry",role:"group","aria-label":W("chat.carryOnLabel"),children:[(0,s.jsx)("span",{className:"grow",children:W("chat.carryOnNote")}),(0,s.jsx)("button",{type:"button",className:"primary small",disabled:er,onClick:()=>void e3(B.tasks.at(-1)),children:W("chat.carryOn")})]}),tv&&(0,s.jsx)("p",{className:"cs-system cs-paused",role:"status",children:W("chat.pausedNote")}),eN&&(null==tj?void 0:tj.password)&&(0,s.jsxs)("div",{className:"cs-system cs-password",role:"alert","data-awaits":"password:".concat(null!=(C=null==B?void 0:B.id)?C:""),tabIndex:-1,children:[W("chat.passwordWaiting"),(0,s.jsx)(et.T4,{text:W("chat.passwordWaiting")})]}),eN&&(null==tj?void 0:tj.signIn)&&(0,s.jsxs)("div",{className:"cs-system cs-password",role:"alert","data-awaits":"sign-in:".concat(null!=(F=null==B?void 0:B.id)?F:""),tabIndex:-1,children:[W("chat.signInWaiting"),(0,s.jsx)(et.T4,{text:W("chat.signInWaiting")})]}),eo&&(0,s.jsx)("p",{className:"cs-system",role:"status",children:eo})]}),(0,s.jsxs)("div",{className:"cs-compose",children:[(0,s.jsx)("label",{htmlFor:"cs-input",className:"sr-only",children:W("chat.input")}),(0,s.jsx)("textarea",{id:"cs-input",ref:ey,value:en,onChange:e=>ei(e.target.value),placeholder:eN?W("chat.placeholderRunning"):(null==O?void 0:O.ok)?W("chat.placeholder",{folder:O.name}):W("chat.placeholderNoFolder"),disabled:er||!(null==O?void 0:O.ok),onKeyDown:e=>{"Enter"!==e.key||e.shiftKey||e.nativeEvent.isComposing||(e.preventDefault(),e1())}}),e9?(0,s.jsxs)("div",{className:"cs-models",children:[(0,s.jsx)("span",{className:"cs-pick-label","aria-hidden":"true",children:W("chat.kerriganModel")}),(0,s.jsx)("div",{className:"cs-bar",children:eB("90%")}),(0,s.jsx)("label",{htmlFor:"cs-chats-model",className:"cs-pick-label",children:W("chat.kerriganChatsModel")}),(0,s.jsx)("div",{className:"cs-bar",children:(0,s.jsx)(eG.Yb,{id:"cs-chats-model",chosen:te,onChange:e=>void tt(e),byHand:W("chat.modelByHand"),none:eF?W("chat.modelDefault",{model:eF}):W("chat.modelByHand"),catalogue:em,disabled:eN,style:{minWidth:0,maxWidth:"90%"}})})]}):e7?(0,s.jsxs)("div",{className:"cs-models",children:[(0,s.jsx)("span",{className:"cs-pick-label","aria-hidden":"true",children:W("chat.leadModel")}),(0,s.jsx)("div",{className:"cs-bar",children:eB("90%")}),(0,s.jsx)("label",{htmlFor:"cs-worker-model",className:"cs-pick-label",children:W("chat.workerModel")}),(0,s.jsx)("div",{className:"cs-bar",children:(0,s.jsx)(eG.Yb,{id:"cs-worker-model",chosen:te,onChange:e=>void tt(e),byHand:W("chat.modelByHand"),none:eF?W("chat.modelDefault",{model:eF}):W("chat.workerSameModel"),catalogue:em,disabled:eN,style:{minWidth:0,maxWidth:"90%"}})})]}):tm&&!e9?(0,s.jsxs)("div",{className:"cs-models",children:[(0,s.jsx)("span",{className:"cs-pick-label","aria-hidden":"true",children:W("chat.workModel")}),(0,s.jsx)("div",{className:"cs-bar",children:eB("90%")}),(0,s.jsx)("label",{htmlFor:"cs-review-model",className:"cs-pick-label",children:W("chat.reviewModel")}),(0,s.jsx)("div",{className:"cs-bar",title:W("chat.reviewModelWhy"),children:(0,s.jsx)(eG.Yb,{id:"cs-review-model",chosen:tx,onChange:e=>void tg(e),none:tb?W("chat.reviewModelDefault",{model:tb}):W("chat.reviewModelByHand"),catalogue:em,disabled:eN,style:{minWidth:0,maxWidth:"90%"}})})]}):(0,s.jsx)("div",{className:"cs-bar",children:eB("48%")}),(0,s.jsxs)("div",{className:"cs-bar cs-skills",children:[eE.length>0&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("label",{htmlFor:"cs-skill",className:"cs-pick-label",children:W("chat.skill")}),(0,s.jsxs)("select",{id:"cs-skill",value:ew,onChange:e=>ek(e.target.value),disabled:eN,title:W("chat.skillWhy"),style:{minWidth:0,maxWidth:"60%"},children:[(0,s.jsx)("option",{value:"",children:W("chat.skillNone")}),eE.map(e=>(0,s.jsxs)("option",{value:e.name,title:e.description||void 0,children:["/",e.name]},e.name))]})]}),(0,s.jsx)(i(),{href:"/settings#skills",className:"button-link plain small cs-skills-link",title:W("chat.skillsLinkWhy"),children:W("chat.skillsLink")}),(0,s.jsx)(e8,{workspace:O,running:e_,queue:!!(null==tj?void 0:tj.queue),onMade:e=>{eV(),ed("".concat(e," ").concat(W("nb.madeChat"))),I()}})]}),(0,s.jsxs)("div",{className:"cs-bar",children:[(0,s.jsxs)("label",{className:"cs-plan-toggle cs-kerrigan-toggle",title:W("chat.kerriganWhy"),children:[(0,s.jsx)("input",{type:"checkbox",checked:e9,disabled:eN||!!B,onChange:e=>{var t;return t=e.target.checked,void(!B&&(ea(t),tr(ti,t?"on":""),t&&(Y(!1),tr(tn,""))))}}),(0,s.jsx)("span",{children:W("chat.kerrigan")})]}),!e9&&(0,s.jsxs)("label",{className:"cs-plan-toggle",title:W("chat.planModeWhy"),children:[(0,s.jsx)("input",{type:"checkbox",checked:tu,disabled:eN,onChange:e=>void th(e.target.checked)}),(0,s.jsx)("span",{children:W("chat.planMode")})]}),!e9&&(0,s.jsxs)("label",{className:"cs-plan-toggle cs-lead-toggle",title:W("chat.leadWhy"),children:[(0,s.jsx)("input",{type:"checkbox",checked:e7,disabled:eN||!!B,onChange:e=>{var t;return t=e.target.checked,void(!B&&(Y(t),tr(tn,t?"on":""),t&&(ea(!1),tr(ti,""))))}}),(0,s.jsx)("span",{children:W("chat.lead")})]}),!e7&&!e9&&(0,s.jsxs)("label",{className:"cs-plan-toggle cs-review-toggle",title:W("chat.reviewWhy"),children:[(0,s.jsx)("input",{type:"checkbox",checked:tm,disabled:eN,onChange:e=>void tf(e.target.checked)}),(0,s.jsx)("span",{children:W("chat.review")})]}),(0,s.jsxs)("span",{className:"cs-actions",children:[eN&&(0,s.jsx)("button",{type:"button",className:"cs-pause",onClick:()=>void tw(),title:tv?W("chat.resumeWhy"):W("chat.pauseWhy"),children:tv?W("chat.resume"):W("chat.pause")}),eN&&(0,s.jsx)("button",{type:"button",className:"danger cs-stop",onClick:()=>{B&&!tN&&(tS(!0),r.FH.stop(B.id).then(()=>ed(W("chat.stopping"))).catch(e=>{tS(!1),ed(e.message)}))},disabled:tN,"aria-busy":tN||void 0,children:tN?(0,s.jsxs)(s.Fragment,{children:[W("chat.stoppingNow"),(0,s.jsx)("span",{className:"saving-dots",children:tC})]}):W("chat.stop")}),(0,s.jsx)("button",{type:"button",className:"primary",disabled:er||!en.trim()||!(null==O?void 0:O.ok),onClick:()=>void e1(),title:W("chat.sendWhy"),children:eN?W("chat.sendNote"):W("chat.send")})]})]})]})]})}function td(e){var t;let{workspace:a,onPick:l,onOpenFolder:n}=e,{t:i}=(0,k.kj)();if(!a)return(0,s.jsx)("p",{className:"muted small",children:i("wb.loading")});if(!a.ok)return(0,s.jsxs)("div",{className:"cs-welcome",children:[(0,s.jsx)("p",{children:a.problem}),(0,s.jsx)("button",{type:"button",className:"primary",onClick:n,children:i("chat.openFolder")})]});let r=[i("chat.example1"),i("chat.example2"),i("chat.example3")];return(0,s.jsxs)("div",{className:"cs-welcome",children:[(0,s.jsx)("h3",{children:i("chat.welcome",{folder:a.name})}),(0,s.jsx)("p",{className:"muted small",children:i("chat.welcomeWhy",{dir:a.dir,branch:null!=(t=a.branch)?t:"—"})}),(0,s.jsx)("ul",{className:"cs-examples",children:r.map(e=>(0,s.jsx)("li",{children:(0,s.jsx)("button",{type:"button",className:"linkish",onClick:()=>l(e),children:e})},e))})]})}function tu(e,t){var a;let[s,n]=(0,l.useState)(null),i=(null==t?void 0:t.status)==="running"||(null==t?void 0:t.status)==="waiting-approval",c=()=>t&&(t.startedAt||i)?r.FH.taskStory(e,t.id,t.runId).then(n).catch(()=>void 0):Promise.resolve();(0,l.useEffect)(()=>{c()},[e,null==t?void 0:t.id,null==t?void 0:t.runId,null==t?void 0:t.status]),(0,m.z)(c,i?1500:6e4,!!i);let o=[],d=e=>e.forEach(e=>"review"===e.kind?d(e.entries):o.push(e));return d(null!=(a=null==s?void 0:s.entries)?a:[]),o}function th(e){let{entries:t}=e;return(0,s.jsx)(s.Fragment,{children:t.map((e,t)=>{var a;return"reply"===e.kind?(null==(a=e.notes)?void 0:a.trim())?(0,s.jsxs)("div",{className:"cs-bot",children:[(0,s.jsx)(eY.s,{text:e.notes}),(0,s.jsx)("div",{className:"cs-copy-row",children:(0,s.jsx)(et.i8,{text:e.notes,what:"chat.copyReply"})})]},t):null:"step"===e.kind?(0,s.jsx)(tg,{step:e},t):"handoff"===e.kind?(0,s.jsx)(eV.Q$,{card:e.card,outcome:e.outcome,answer:e.answer},t):null})})}function tm(e){let{task:t,n:a,onRewind:l}=e,{t:n}=(0,k.kj)(),i=(0,k.Vl)();return(0,s.jsxs)("div",{className:"cs-user-row",children:[l&&(t.checkpoint||"queued"===t.status)&&(0,s.jsx)("button",{type:"button",className:"wb-icon-btn cs-rewind",onClick:l,title:n("chat.rewind"),"aria-label":n("chat.rewind"),children:"↶"}),(0,s.jsxs)("div",{className:"cs-user",children:[(0,s.jsxs)("p",{className:"cs-user-head",children:[(0,s.jsx)("span",{className:"cs-user-who",children:n("chat.you")}),(0,s.jsx)("span",{className:"cs-user-n",children:n("chat.youN",{n:a})}),(0,s.jsx)("time",{dateTime:t.createdAt,children:i(t.createdAt)})]}),t.skill&&(0,s.jsx)(tS,{skill:t.skill}),(0,s.jsx)(tb,{children:(0,s.jsx)(eY.s,{text:t.prompt})}),(0,s.jsx)("div",{className:"cs-copy-row",children:(0,s.jsx)(et.i8,{text:t.prompt,what:"chat.copyMessage"})})]})]})}function tp(e){var t,a,l,n;let{n:i,session:c,task:o,approvals:d,onDecided:u,onOpenFile:h,onRewind:m}=e,{t:p}=(0,k.kj)(),f="running"===o.status||"waiting-approval"===o.status,x=tu(c.id,o);return(0,s.jsxs)("section",{className:"cs-turn",id:"cs-turn-".concat(o.id),"aria-label":p("chat.turn",{text:o.title}),children:[(0,s.jsx)(tm,{task:o,n:i,onRewind:m}),"queued"===o.status&&(0,s.jsx)("p",{className:"muted small cs-system",children:p("idle"===c.status?"chat.queued":"chat.waitingTurn")}),(0,s.jsx)(th,{entries:x}),(null==(t=o.plan)?void 0:t.approved)&&!d.some(e=>e.plan)&&(0,s.jsxs)("details",{className:"cs-plan",children:[(0,s.jsx)("summary",{children:p("chat.planShown",{v:o.plan.version})}),(0,s.jsx)(e0.D,{plan:o.plan})]}),d.map(e=>(0,s.jsx)(tj,{approval:e,onDecided:u},e.id)),f&&(0,s.jsxs)("p",{className:"cs-working",role:"status",children:[o.acting?(0,s.jsx)(eX.y,{actor:o.acting.actor,acting:o.acting}):(0,s.jsx)("span",{className:"wb-live","aria-hidden":"true"})," ",p("chat.working",{n:o.iterations})]}),!f&&"queued"!==o.status&&(0,s.jsx)(tf,{task:o}),!f&&(0,s.jsx)(tN,{session:c,task:o}),o.runId&&(0,s.jsx)("div",{className:"cs-exchange",children:(0,s.jsx)("a",{className:"button-link quiet small",href:r.FH.taskExchangeUrl(c.id,o.id),download:!0,title:p("chat.exchangeWhy"),children:p("chat.exchange")})}),(null!=(n=null==(l=o.vcs)||null==(a=l.files)?void 0:a.length)?n:0)>0&&!f&&(0,s.jsxs)("div",{className:"cs-files",children:[(0,s.jsx)("span",{className:"small",children:p("chat.changed",{n:o.vcs.files.length})}),o.vcs.files.slice(0,12).map(e=>(0,s.jsxs)("button",{type:"button",className:"cs-file",onClick:()=>h(e.path),title:e.path,children:[(0,s.jsx)(Y,{path:e.path})," ",e.path.split("/").pop()," ",(0,s.jsx)("span",{className:"muted",children:e.added>=0?"+".concat(e.added," −").concat(e.removed):""})]},e.path)),(0,s.jsx)(eL,{sessionId:c.id,taskId:o.id,runId:o.runId,title:o.title,files:o.vcs.files.length})]})]})}function tf(e){let{task:t}=e,a=(0,l.useRef)(null),[n,i]=(0,l.useState)(!1),r=[t.summary,"done"!==t.status?t.reason:""].filter(Boolean).join("\n\n");return(0,l.useEffect)(()=>{let e=a.current;if(!e)return;let t=()=>{let t=window.getComputedStyle(e),a=parseFloat(t.lineHeight)||1.45*parseFloat(t.fontSize);i(e.scrollHeight>a*tx)};t();let s=new ResizeObserver(t);return s.observe(e),()=>s.disconnect()},[]),(0,s.jsxs)("div",{className:"cs-end s-".concat(t.status),children:[(0,s.jsx)(as,{status:t.status}),(0,s.jsxs)("div",{className:"grow",ref:a,children:[t.summary?(0,s.jsx)(eY.s,{text:t.summary}):null,"done"!==t.status&&t.reason?(0,s.jsx)("p",{className:"small",children:t.reason}):null,r&&n&&(0,s.jsx)("div",{className:"cs-copy-row cs-copy-bottom",children:(0,s.jsx)(et.i8,{text:r,what:"chat.copySummary"})})]}),r&&(0,s.jsx)(et.i8,{text:r,what:"chat.copySummary"})]})}let tx=6;function tb(e){let{children:t}=e,{t:a}=(0,k.kj)(),n=(0,l.useRef)(null),[i,r]=(0,l.useState)(0),[c,o]=(0,l.useState)(!1),[d,u]=(0,l.useState)(!1);(0,l.useEffect)(()=>{let e=n.current;if(!e)return;let t=()=>{let t=window.getComputedStyle(e),a=parseFloat(t.lineHeight)||1.45*parseFloat(t.fontSize),s=Math.round(3*a);r(s),o(e.scrollHeight>s+.6*a)};t();let a=new ResizeObserver(t);return a.observe(e),()=>a.disconnect()},[]);let h=c&&!d;return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{ref:n,className:"cs-fold".concat(h?" folded":""),style:h?{maxHeight:i}:void 0,children:[t,h&&(0,s.jsxs)("div",{className:"cs-fold-blur","aria-hidden":"true",children:[(0,s.jsx)("span",{}),(0,s.jsx)("span",{}),(0,s.jsx)("span",{})]})]}),c&&(0,s.jsx)("button",{type:"button",className:"cs-fold-toggle","aria-expanded":d,"aria-label":a(d?"chat.foldClose":"chat.foldOpen"),title:a(d?"chat.foldClose":"chat.foldOpen"),onClick:()=>u(!d),children:d?"▴":"▾"})]})}function tg(e){let{step:t}=e,{t:a}=(0,k.kj)(),n=!t.outcome,[i,r]=(0,l.useState)(null),c=null!=i?i:n||t.failed;return(0,s.jsxs)("div",{className:"cs-cmd".concat(t.failed?" bad":""),children:[(0,s.jsxs)("div",{className:"cs-cmd-row",children:[(0,s.jsxs)("button",{type:"button",className:"cs-cmd-head","aria-expanded":c,onClick:()=>r(!c),children:[(0,s.jsx)("span",{className:"cs-cmd-ico","aria-hidden":"true",children:n?"⟳":t.failed?"✗":"✓"}),(0,s.jsx)("code",{className:"wb-row-name",children:t.command}),(0,s.jsx)("span",{className:"muted small",children:n?a("chat.running"):void 0!==t.exitCode?a("chat.exit",{code:t.exitCode}):t.outcome})]}),(0,s.jsx)(et.i8,{text:t.output?"$ ".concat(t.command,"\n").concat(t.output):t.command,what:"chat.copyCommand"})]}),c&&t.output&&(0,s.jsx)("pre",{className:"cs-out",children:t.output})]})}let tv=e=>({"data-awaits":e.id,tabIndex:-1});function tj(e){var t;let{approval:a,onDecided:l}=e,{t:n}=(0,k.kj)(),i=a.kerrigan;return i?(0,s.jsxs)("div",{className:"cs-kz-card s-".concat(i.state),"data-awaits-frame":"",..."thinking"===i.state?{"data-kerrigan-thinking":""}:{},children:[(0,s.jsxs)("p",{className:"small cs-kz-on-card",role:"status",children:[(0,s.jsx)(eX.y,{actor:"kerrigan"})," ","thinking"===i.state?n("kz.thinking"):n("kz.yoursOnCard",{why:null!=(t=i.why)?t:""}),"yours"===i.state&&i.suggestion&&(0,s.jsxs)("span",{className:"cs-kz-suggests",children:[" ",n("kz.suggests",{answer:i.suggestion})]})]}),(0,s.jsx)(tw,{approval:a,onDecided:l})]}):(0,s.jsx)(tw,{approval:a,onDecided:l})}function tw(e){var t,a,l;let{approval:n,onDecided:i}=e,{t:c}=(0,k.kj)(),{err:o,choose:d,mark:u}=(0,eK.p)(),h=async e=>{i(n.id,await d(e,async()=>{await r.FH.decide(n.id,e)}))};return n.plan?(0,s.jsx)("div",{className:"cs-plan-ask",...tv(n),children:(0,s.jsx)(eQ.Mt,{approval:n,onDecided:e=>i(n.id,e)})}):(null==(t=n.question)?void 0:t.handoff)?(0,s.jsx)(tL,{approval:n,onDecided:i}):n.question?(0,s.jsx)(tI,{approval:n,onDecided:i}):n.retry?(0,s.jsx)(tE,{approval:n,onDecided:i}):n.model?(0,s.jsx)("p",{className:"cs-system small",children:c("chat.lookAbove")}):(0,s.jsxs)("div",{className:"cs-ask",role:"group","aria-label":c("chat.askTitle"),...tv(n),children:[(0,s.jsxs)("p",{className:"small cs-ask-head",children:[(0,s.jsx)("strong",{children:c("chat.askTitle")})," ",n.actor&&(0,s.jsx)(eX.y,{actor:n.actor,how:"asks"})]}),(0,s.jsx)("pre",{className:"cs-out",children:n.description}),(0,s.jsx)("div",{className:"cs-copy-row",children:(0,s.jsx)(et.i8,{text:n.description,what:"chat.copyAsked"})}),n.platform&&(0,s.jsx)("p",{className:"reason small",children:c("approval.platform",{platform:n.platform})}),n.readOnly&&(0,s.jsx)("p",{className:"reason small cs-read-only",children:c("approval.readOnly")}),(null!=(l=null==(a=n.scripts)?void 0:a.length)?l:0)>0&&(0,s.jsx)(eV.G,{scripts:n.scripts}),(0,s.jsxs)("div",{className:"row",children:[(0,s.jsx)("button",{type:"button",className:"primary",...u("run"),onClick:()=>void h("run"),children:c("chat.askRun")}),!n.network&&!n.platform&&!n.runAllOff&&(0,s.jsx)("button",{type:"button",...u("run-all"),onClick:()=>void h("run-all"),children:c("chat.askRunAll")}),(0,s.jsx)("button",{type:"button",...u("skip"),onClick:()=>void h("skip"),children:c("chat.askSkip")})]}),(0,s.jsx)(eQ.Sz,{approval:n}),o&&(0,s.jsx)("p",{className:"err",role:"alert",children:o}),(0,s.jsx)(et.T4,{text:(0,te.Mo)(c,n)})]})}function tk(e){var t,a,n,i,c,o,d,u,h,m,p,f,x,b,g,v,j,w;let{n:y,session:N,task:S,worker:C,approvals:F,onDecided:M,onOpenFile:O,onRewind:q,onRetrySubtask:E}=e,{t:L}=(0,k.kj)(),I="running"===S.status||"waiting-approval"===S.status,z=null!=(b=null==(t=S.lead)?void 0:t.rounds)?b:[],D=new Map(z.filter(e=>e.subtask).map(e=>[e.subtask.n,e.n])),W=null==(a=z.filter(e=>"plan"===e.status).at(-1))?void 0:a.n,A=F.filter(e=>e.taskId===S.id),H=(null==(n=z.at(-1))?void 0:n.subtask)&&(null==C?void 0:C.tasks.find(e=>{var t,a;return e.id===(null==(a=z.at(-1))||null==(t=a.subtask)?void 0:t.taskId)&&("running"===e.status||"waiting-approval"===e.status)}));return(0,s.jsxs)("section",{className:"cs-turn cs-lead-turn",id:"cs-turn-".concat(S.id),"aria-label":L("chat.turn",{text:S.title}),children:[(0,s.jsx)(tm,{task:S,n:y,onRewind:q}),"queued"===S.status&&(0,s.jsx)("p",{className:"muted small cs-system",children:"idle"===N.status?L("chat.queued"):L("chat.waitingTurn")}),z.map(e=>{var t,a;return(0,s.jsxs)(l.Fragment,{children:[e.understanding&&(0,s.jsx)(tC,{who:L("lead.understood"),text:e.understanding}),e.notes&&(0,s.jsx)(tC,{who:L("lead.who"),text:e.notes}),e.ledger&&(0,s.jsx)(e6,{change:e.ledger}),"plan"===e.status&&e.n===W&&S.plan&&!A.some(e=>e.plan)&&(0,s.jsxs)("details",{className:"cs-plan",children:[(0,s.jsx)("summary",{children:L("lead.plan",{v:S.plan.version})}),(0,s.jsx)(e0.D,{plan:S.plan})]}),e.subtask&&D.get(e.subtask.n)===e.n&&(0,s.jsx)(tF,{round:e,worker:C,approvals:F.filter(t=>{var a;return t.taskId===(null==(a=e.subtask)?void 0:a.taskId)}),onDecided:M,onOpenFile:O,onRetry:E?t=>E(e.subtask.n,t):void 0}),(null==(t=e.question)?void 0:t.answer)!==void 0&&(0,s.jsxs)("div",{className:"cs-bot cs-lead-qa",children:[(0,s.jsx)("p",{className:"cs-who",children:L("lead.question")}),(0,s.jsx)(eY.s,{text:e.question.text}),(0,s.jsx)("div",{className:"cs-copy-row",children:(0,s.jsx)(et.i8,{text:(0,te.yw)(L,{...e.question,options:null!=(a=e.question.options)?a:[]},!1),what:"chat.copyQuestion"})}),(0,s.jsx)("p",{className:"cs-who",children:L("lead.answered")}),(0,s.jsx)(eY.s,{text:e.question.answer}),(0,s.jsx)("div",{className:"cs-copy-row",children:(0,s.jsx)(et.i8,{text:e.question.answer,what:"chat.copyAnswer"})})]})]},e.n)}),A.map(e=>(0,s.jsx)(tj,{approval:e,onDecided:M},e.id)),I&&(0,s.jsxs)("p",{className:"cs-working",role:"status",children:[S.acting?(0,s.jsx)(eX.y,{actor:S.acting.actor,acting:S.acting}):(0,s.jsx)("span",{className:"wb-live","aria-hidden":"true"})," ",H?(null==(i=S.lead)?void 0:i.ledger)?L("lead.workingOn",{title:null!=(g=null==(o=z.at(-1))||null==(c=o.subtask)?void 0:c.title)?g:""}):L("lead.working",{n:null!=(v=null==(u=z.at(-1))||null==(d=u.subtask)?void 0:d.n)?v:0}):L("lead.thinking")]}),S.lead&&(I||S.lead.ledger)&&(0,s.jsx)(e4,{lead:S.lead,live:I}),(null==(h=S.lead)?void 0:h.messages)&&(0,s.jsx)("p",{className:"muted small cs-lead-count",children:L("lead.messages",{lead:S.lead.messages.lead,worker:S.lead.messages.worker,total:S.lead.messages.lead+S.lead.messages.worker})}),!I&&"queued"!==S.status&&(0,s.jsx)(tf,{task:S}),!I&&(0,s.jsx)(tN,{session:N,task:S}),!I&&(null!=(j=null==(p=S.lead)||null==(m=p.evidence)?void 0:m.length)?j:0)>0&&(0,s.jsxs)("div",{className:"cs-evidence",children:[(0,s.jsx)("p",{className:"cs-who",children:L("lead.evidence")}),(0,s.jsx)("ul",{children:S.lead.evidence.map(e=>(0,s.jsx)("li",{children:(0,s.jsx)(eY.s,{text:e})},e))}),(0,s.jsx)("div",{className:"cs-copy-row",children:(0,s.jsx)(et.i8,{text:S.lead.evidence.map(e=>"- ".concat(e)).join("\n"),what:"chat.copyEvidence"})})]}),S.runId&&(0,s.jsx)("div",{className:"cs-exchange",children:(0,s.jsx)("a",{className:"button-link quiet small",href:r.FH.taskExchangeUrl(N.id,S.id),download:!0,title:L("chat.exchangeWhy"),children:L("chat.exchange")})}),(null!=(w=null==(x=S.vcs)||null==(f=x.files)?void 0:f.length)?w:0)>0&&!I&&(0,s.jsxs)("div",{className:"cs-files",children:[(0,s.jsx)("span",{className:"small",children:L("chat.changed",{n:S.vcs.files.length})}),S.vcs.files.slice(0,12).map(e=>(0,s.jsxs)("button",{type:"button",className:"cs-file",onClick:()=>O(e.path),title:e.path,children:[(0,s.jsx)(Y,{path:e.path})," ",e.path.split("/").pop()," ",(0,s.jsx)("span",{className:"muted",children:e.added>=0?"+".concat(e.added," −").concat(e.removed):""})]},e.path)),(0,s.jsx)(eL,{sessionId:N.id,taskId:S.id,runId:S.runId,title:S.title,files:S.vcs.files.length})]})]})}function ty(e){var t,a,n,i,c,o,d,u;let{n:h,session:m,task:p,threads:f,approvals:x,onDecided:b,onOpenFile:g,onOpenChat:v,onRewind:j}=e,{t:w}=(0,k.kj)(),y="running"===p.status||"waiting-approval"===p.status,N=p.kerrigan,S=null!=(o=null==N?void 0:N.rounds)?o:[],C=e=>{var t,a;return(null!=(a=null==(t=f.find(t=>t.id===e))?void 0:t.name)?a:"").replace(/^chat: /,"")||w("kz.aChat")},F=y?x.filter(e=>e.taskId===p.id||e.sessionId!==m.id):[],M=null==(t=[...S].reverse().find(e=>e.send))?void 0:t.send,O=y&&M&&("running"===M.status||"waiting-approval"===M.status);return(0,s.jsxs)("section",{className:"cs-turn cs-kz-turn",id:"cs-turn-".concat(p.id),"aria-label":w("chat.turn",{text:p.title}),children:[(0,s.jsx)(tm,{task:p,n:h,onRewind:j}),"queued"===p.status&&(0,s.jsx)("p",{className:"muted small cs-system",children:"idle"===m.status?w("chat.queued"):w("chat.waitingTurn")}),S.map((e,t)=>{var a,n,i;return(0,s.jsxs)(l.Fragment,{children:[e.understanding&&(0,s.jsx)(tC,{who:w("kz.understood"),text:e.understanding}),e.notes&&(0,s.jsx)(tC,{who:w("actor.kerrigan"),text:e.notes}),(null!=(n=null==(a=e.sources)?void 0:a.length)?n:0)>0&&(0,s.jsxs)("div",{className:"cs-kz-sources small",children:[(0,s.jsx)("span",{className:"cs-who",children:w("kz.sources")}),(0,s.jsx)("ul",{children:e.sources.map(e=>(0,s.jsx)("li",{children:e},e))})]}),e.send&&(0,s.jsxs)("div",{className:"cs-bot cs-kz-send",children:[(0,s.jsx)("p",{className:"cs-who",children:w("kz.send",{n:e.send.n,name:C(e.send.sessionId)})}),(0,s.jsxs)("p",{className:"cs-kz-chips",children:[(0,s.jsx)("span",{className:"badge",children:"same"===e.send.chat?w("kz.sameChat"):w("kz.newChat")}),e.send.planMode&&(0,s.jsx)("span",{className:"badge",children:w("kz.planMode")}),e.send.twoChats&&(0,s.jsx)("span",{className:"badge",children:w("kz.twoChats")}),e.send.review&&(0,s.jsx)("span",{className:"badge",children:w("kz.review")}),e.send.skill&&(0,s.jsx)("span",{className:"badge skill",children:w("chat.skillUsed",{name:e.send.skill})})]}),(0,s.jsx)(tb,{children:(0,s.jsx)(eY.s,{text:e.send.prompt})}),(0,s.jsxs)("div",{className:"cs-copy-row",children:[(0,s.jsx)(et.i8,{text:e.send.prompt,what:"kz.copyPrompt"}),e.send.sessionId&&(0,s.jsx)("button",{type:"button",className:"quiet small cs-kz-open",onClick:()=>v(e.send.sessionId),title:w("kz.openChatWhy"),children:w("kz.openChat")})]}),e.send.status&&"running"!==e.send.status&&"waiting-approval"!==e.send.status&&(0,s.jsxs)("p",{className:"small cs-kz-ended",children:[(0,s.jsx)(as,{status:e.send.status})," ",w("kz.chatEnded")]})]}),e.card&&(0,s.jsxs)("div",{className:"cs-bot cs-kz-answer",children:[(0,s.jsxs)("p",{className:"cs-who",children:[w("kz.cardHead")," ",e.card.actor&&(0,s.jsx)(eX.y,{actor:e.card.actor,how:"asks"})]}),(0,s.jsx)(eY.s,{text:e.card.text}),void 0!==e.card.answer&&(0,s.jsx)("p",{className:"small",children:(0,s.jsx)("strong",{children:"operator"===e.card.by?w("kz.youAnswered",{answer:e.card.answer}):w("kz.answered",{answer:e.card.answer})})}),e.card.yours&&(0,s.jsxs)("p",{className:"small cs-kz-yours",children:[w("kz.leftToYou",{why:e.card.yours.why}),e.card.yours.suggestion?" ".concat(w("kz.suggests",{answer:e.card.yours.suggestion})):""]})]}),e.question&&void 0!==e.question.answer&&(0,s.jsxs)("div",{className:"cs-bot cs-lead-qa",children:[(0,s.jsx)("p",{className:"cs-who",children:w("kz.asked")}),(0,s.jsx)(eY.s,{text:e.question.text}),(0,s.jsx)("div",{className:"cs-copy-row",children:(0,s.jsx)(et.i8,{text:(0,te.yw)(w,{...e.question,options:null!=(i=e.question.options)?i:[]},!1),what:"chat.copyQuestion"})}),(0,s.jsx)("p",{className:"cs-who",children:w("lead.answered")}),(0,s.jsx)(eY.s,{text:e.question.answer})]}),"blocked"===e.status&&e.needed&&(0,s.jsx)("p",{className:"small cs-kz-needed",children:w("kz.needed",{needed:e.needed})})]},"".concat(e.at,"-").concat(t))}),F.map(e=>(0,s.jsx)(tj,{approval:e,onDecided:b},e.id)),y&&(0,s.jsxs)("p",{className:"cs-working",role:"status",children:[p.acting?(0,s.jsx)(eX.y,{actor:p.acting.actor,acting:p.acting}):(0,s.jsx)("span",{className:"wb-live","aria-hidden":"true"})," ",O?w("kz.chatWorking",{n:M.n,name:C(M.sessionId)}):w("kz.working")]}),N&&(N.sent>0||N.messages>0)&&(0,s.jsx)("p",{className:"muted small cs-kz-count",children:w("kz.counts",{sent:N.sent,max:N.maxSends,messages:N.messages})}),!y&&"queued"!==p.status&&(0,s.jsx)(tf,{task:p}),!y&&(null!=(d=null==(n=S.at(-1))||null==(a=n.evidence)?void 0:a.length)?d:0)>0&&(0,s.jsxs)("div",{className:"cs-evidence",children:[(0,s.jsx)("p",{className:"cs-who",children:w("lead.evidence")}),(0,s.jsx)("ul",{children:S.at(-1).evidence.map(e=>(0,s.jsx)("li",{children:(0,s.jsx)(eY.s,{text:e})},e))}),(0,s.jsx)("div",{className:"cs-copy-row",children:(0,s.jsx)(et.i8,{text:S.at(-1).evidence.map(e=>"- ".concat(e)).join("\n"),what:"chat.copyEvidence"})})]}),p.runId&&(0,s.jsx)("div",{className:"cs-exchange",children:(0,s.jsx)("a",{className:"button-link quiet small",href:r.FH.taskExchangeUrl(m.id,p.id),download:!0,title:w("chat.exchangeWhy"),children:w("chat.exchange")})}),(null!=(u=null==(c=p.vcs)||null==(i=c.files)?void 0:i.length)?u:0)>0&&!y&&(0,s.jsxs)("div",{className:"cs-files",children:[(0,s.jsx)("span",{className:"small",children:w("chat.changed",{n:p.vcs.files.length})}),p.vcs.files.slice(0,12).map(e=>(0,s.jsxs)("button",{type:"button",className:"cs-file",onClick:()=>g(e.path),title:e.path,children:[(0,s.jsx)(Y,{path:e.path})," ",e.path.split("/").pop()," ",(0,s.jsx)("span",{className:"muted",children:e.added>=0?"+".concat(e.added," −").concat(e.removed):""})]},e.path)),(0,s.jsx)(eL,{sessionId:m.id,taskId:p.id,runId:p.runId,title:p.title,files:p.vcs.files.length})]})]})}function tN(e){let{session:t,task:a}=e;if(!a.parked||!t.queueItem)return null;let l=t.queueItem;return(0,s.jsx)("div",{className:"cs-parked",children:(0,s.jsx)(e9.a,{parked:a.parked,onAnswer:async e=>void await r.FH.answerParked(l,{...e,sessionId:t.id})})})}function tS(e){let{skill:t}=e,{t:a}=(0,k.kj)();return(0,s.jsx)("p",{className:"cs-skill-chip",children:(0,s.jsx)("span",{className:"badge skill",title:t.description||void 0,children:a("chat.skillUsed",{name:t.name})})})}function tC(e){let{who:t,text:a}=e;return(0,s.jsxs)("div",{className:"cs-bot cs-lead-say",children:[(0,s.jsx)("p",{className:"cs-who",children:t}),(0,s.jsx)(eY.s,{text:a}),(0,s.jsx)("div",{className:"cs-copy-row",children:(0,s.jsx)(et.i8,{text:a,what:"chat.copyReply"})})]})}function tF(e){var t,a,l,n,i,r,c,o;let{round:d,worker:u,approvals:h,onDecided:m,onOpenFile:p,onRetry:f}=e,{t:x}=(0,k.kj)(),b=(0,eK.p)(),g=d.subtask,v=null==u?void 0:u.tasks.find(e=>e.id===g.taskId),j=(null==v?void 0:v.status)==="running"||(null==v?void 0:v.status)==="waiting-approval",w=tu(null!=(l=null==u?void 0:u.id)?l:"",v),y=null!=(n=g.attempts)?n:[],N=y.at(-1),S=null!=(i=g.maxAttempts)?i:y.length,C=y.slice(0,-1),F=y.length>1,M=!j&&!!N&&"done"!==N.status&&!!N.category,O=!!f&&!!v&&"done"!==v.status&&!j;return(0,s.jsxs)("details",{className:"cs-subtask s-".concat(null!=(r=null==v?void 0:v.status)?r:"queued"),open:j||h.length>0||O||void 0,children:[(0,s.jsxs)("summary",{children:[(0,s.jsx)(as,{status:null!=(c=null==v?void 0:v.status)?c:"queued"})," ",(0,s.jsx)("span",{children:x("lead.subtask",{n:g.n,title:g.title})}),g.readOnly&&(0,s.jsx)("span",{className:"badge",children:x("lead.readOnly")}),g.fresh&&(0,s.jsx)("span",{className:"badge",children:x("lead.fresh")}),j&&F&&N&&(0,s.jsx)("span",{className:"badge running cs-attempt",children:x("retry.retrying",{k:N.attempt,m:S})}),!j&&F&&(null==v?void 0:v.status)==="done"&&N&&(0,s.jsx)("span",{className:"badge done cs-attempt",children:x("retry.doneAt",{k:N.attempt})}),M&&(0,s.jsx)("span",{className:"badge failed cs-attempt",children:x("retry.attempt",{k:N.attempt,m:S})})]}),(0,s.jsxs)("div",{className:"cs-subtask-body",children:[M&&(0,s.jsxs)("p",{className:"small cs-attempt-why",children:[(0,s.jsx)("span",{className:"badge",children:x(te.P3[N.category])})," ",N.reason&&(0,s.jsx)("span",{children:N.reason})]}),C.length>0&&(0,s.jsx)(tM,{attempts:C,max:S,worker:u}),F&&(0,s.jsx)("p",{className:"cs-who cs-attempt-now",children:x("retry.attempt",{k:N.attempt,m:S})}),(0,s.jsx)(th,{entries:w}),h.map(e=>(0,s.jsx)(tj,{approval:e,onDecided:m},e.id)),v&&!j&&"queued"!==v.status&&(0,s.jsx)(tf,{task:v}),v&&(null!=(o=null==(a=v.vcs)||null==(t=a.files)?void 0:t.length)?o:0)>0&&!j&&(0,s.jsx)("div",{className:"cs-files",children:v.vcs.files.slice(0,8).map(e=>(0,s.jsxs)("button",{type:"button",className:"cs-file",onClick:()=>p(e.path),title:e.path,children:[(0,s.jsx)(Y,{path:e.path})," ",e.path.split("/").pop()]},e.path))}),O&&f&&(0,s.jsxs)("div",{className:"cs-retry-after",role:"group","aria-label":x("retry.afterStop"),children:[(0,s.jsx)("p",{className:"muted small",children:x("retry.afterStopWhy")}),(0,s.jsxs)("div",{className:"row",children:[(0,s.jsx)("button",{type:"button",className:"primary",...b.mark("same"),onClick:()=>void b.choose("same",()=>f(!1)),children:x("retry.same")}),(0,s.jsx)("button",{type:"button",...b.mark("fresh"),onClick:()=>void b.choose("fresh",()=>f(!0)),children:x("retry.fresh")})]}),(0,s.jsx)(et.T4,{text:(0,te.qq)(x,g.n,g.title)})]})]})]})}function tM(e){let{attempts:t,max:a,worker:l}=e,{t:n}=(0,k.kj)();return(0,s.jsxs)("details",{className:"cs-attempts",children:[(0,s.jsx)("summary",{className:"small",children:n("retry.earlier",{n:t.length})}),t.map(e=>(0,s.jsx)(tO,{attempt:e,max:a,worker:l},e.attempt))]})}function tO(e){var t;let{attempt:a,max:n,worker:i}=e,{t:r}=(0,k.kj)(),c=(0,k.Vl)(),[o,d]=(0,l.useState)(!1),u=null==i?void 0:i.tasks.find(e=>e.id===a.taskId);return(0,s.jsxs)("details",{className:"cs-attempt-line s-".concat(a.status),onToggle:e=>d(e.target.open),children:[(0,s.jsxs)("summary",{className:"small",children:[(0,s.jsx)(as,{status:a.status})," ",(0,s.jsx)("strong",{children:r("retry.attempt",{k:a.attempt,m:n})}),a.category&&(0,s.jsx)("span",{className:"badge",children:r(te.P3[a.category])}),a.fresh&&(0,s.jsx)("span",{className:"badge",children:r("lead.fresh")}),a.continued&&(0,s.jsx)("span",{className:"badge",children:r("retry.continued")}),a.restored&&(0,s.jsx)("span",{className:"badge",children:r("retry.restored")}),"after-stop"===a.by&&(0,s.jsx)("span",{className:"badge",children:r("retry.byAfterStop")})]}),(0,s.jsxs)("div",{className:"cs-attempt-facts small",children:[a.reason&&(0,s.jsx)("p",{children:r("retry.reason",{reason:a.reason})}),(0,s.jsxs)("p",{className:"muted",children:[r("retry.commands",{started:a.commands.started,completed:a.commands.completed})," \xb7"," ",r(!0===a.repoChanged?"retry.repoChanged":!1===a.repoChanged?"retry.repoSame":"retry.repoUnknown"),a.startedAt&&(0,s.jsxs)(s.Fragment,{children:[" \xb7 ",c(a.startedAt),a.endedAt?"–".concat(c(a.endedAt)):""]})]}),o&&(0,s.jsx)(tq,{sessionId:null!=(t=null==i?void 0:i.id)?t:"",task:u})]})]})}function tq(e){let{sessionId:t,task:a}=e,l=tu(t,a);return(0,s.jsx)(th,{entries:l})}function tE(e){var t;let{approval:a,onDecided:l}=e,{t:n}=(0,k.kj)(),{err:i,choose:c,mark:o}=(0,eK.p)(),d=a.retry,u=async e=>{("restore"!==e||await (0,eJ.Z)(n("retry.restoreConfirm")))&&l(a.id,await c(e,async()=>{await r.FH.answerRetry(a.id,e)}))};return(0,s.jsxs)("div",{className:"cs-ask cs-retry",role:"group","aria-label":n("retry.title",{n:d.n}),...tv(a),children:[(0,s.jsxs)("p",{className:"small cs-ask-head",children:[(0,s.jsx)("strong",{children:n("retry.title",{n:d.n})})," ",(0,s.jsx)(eX.y,{actor:null!=(t=a.actor)?t:"lead",how:"asks"})]}),(0,s.jsxs)("p",{className:"small",children:[(0,s.jsx)("span",{className:"badge failed",children:n("retry.attempt",{k:d.attempt,m:d.maxAttempts})})," ",(0,s.jsx)("span",{className:"badge",children:n(te.P3[d.category])})]}),d.reason&&(0,s.jsx)("p",{className:"small",children:n("retry.reason",{reason:d.reason})}),"unknown"===d.sideEffects&&(0,s.jsx)("p",{className:"reason small",children:n("retry.unknown")}),d.changed.length>0&&(0,s.jsx)("p",{className:"muted small",children:n("retry.changed",{files:d.changed.slice(0,8).join(", ")+(d.changed.length>8?", …":"")})}),(0,s.jsx)("div",{className:"row",children:d.choices.map((e,t)=>(0,s.jsx)("button",{type:"button",className:0===t?"primary":void 0,...o(e),onClick:()=>void u(e),children:n(te.Sx[e])},e))}),i&&(0,s.jsx)("p",{className:"err",role:"alert",children:i}),(0,s.jsx)(et.T4,{text:(0,te.Mo)(n,a)})]})}function tL(e){var t;let{approval:a,onDecided:n}=e,{t:i}=(0,k.kj)(),c=(0,l.useId)(),[o,d]=(0,l.useState)(""),[u,h]=(0,l.useState)(!1),[m,p]=(0,l.useState)(""),{locked:f,err:x,choose:b,mark:g}=(0,eK.p)(),v=a.question,j=async e=>{let t="revise"===e?m:o;("ran"!==e&&"revise"!==e||t.trim())&&n(a.id,await b(e,async()=>{await r.FH.answerQuestion(a.id,t,e)}))},w=async()=>{await (0,eJ.Z)(i("lead.stopConfirm"))&&n(a.id,await b("stop",async()=>{await r.FH.decide(a.id,"abort")}))};return(0,s.jsxs)("div",{className:"cs-ask cs-handoff",role:"group","aria-label":i("ho.title"),...tv(a),children:[(0,s.jsxs)("p",{className:"small cs-ask-head",children:[(0,s.jsx)("strong",{children:i("ho.title")})," ",(0,s.jsx)(eX.y,{actor:null!=(t=a.actor)?t:"worker",how:"asks"})]}),(0,s.jsx)(eV.Lp,{card:v.handoff,why:v.text}),(0,s.jsx)("label",{htmlFor:"".concat(c,"-out"),className:"small",children:i("ho.output")}),(0,s.jsx)("textarea",{id:"".concat(c,"-out"),className:"prose",rows:5,dir:"ltr",value:o,onChange:e=>d(e.target.value),placeholder:i("ho.outputPlaceholder"),disabled:f}),(0,s.jsxs)("div",{className:"row",children:[(0,s.jsx)("button",{type:"button",className:"primary",...g("ran"),disabled:f||!o.trim(),onClick:()=>void j("ran"),children:i("ho.send")}),(0,s.jsx)("button",{type:"button",...g("revise"),"aria-expanded":u,onClick:()=>h(e=>!e),title:i("ho.reviseWhy"),disabled:f,children:i("ho.revise")}),(0,s.jsx)("button",{type:"button",...g("declined"),onClick:()=>void j("declined"),title:i("ho.notRunWhy"),children:i("ho.notRun")}),(0,s.jsx)("button",{type:"button",className:"danger",...g("stop"),onClick:()=>void w(),children:i("lead.stop")})]}),u&&(0,s.jsxs)("div",{className:"ho-revise",children:[(0,s.jsx)("label",{htmlFor:"".concat(c,"-note"),className:"small",children:i("ho.reviseNote")}),(0,s.jsx)("textarea",{id:"".concat(c,"-note"),className:"prose",rows:3,value:m,onChange:e=>p(e.target.value),required:!0,"aria-required":"true",disabled:f}),(0,s.jsx)("div",{className:"row",children:(0,s.jsx)("button",{type:"button",className:"primary",disabled:f||!m.trim(),onClick:()=>void j("revise"),children:i("ho.reviseSend")})})]}),x&&(0,s.jsx)("p",{className:"err",role:"alert",children:x}),(0,s.jsx)(et.T4,{text:(0,te.Mo)(i,a)})]})}function tI(e){var t;let{approval:a,onDecided:n}=e,{t:i}=(0,k.kj)(),c=(0,l.useId)(),{locked:o,err:d,choose:u,mark:h}=(0,eK.p)(),m=a.question,p=null!=(t=a.actor)?t:"lead",f=async(e,t)=>{(t.chosen||t.text.trim())&&n(a.id,await u(e,async()=>{await (t.chosen?r.FH.answerChosen(a.id,t.chosen,t.text):r.FH.answerQuestion(a.id,t.text))}))},x=async()=>{await (0,eJ.Z)(i("lead.stopConfirm"))&&n(a.id,await u("stop",async()=>{await r.FH.decide(a.id,"abort")}))};return(0,s.jsxs)("div",{className:"cs-ask cs-question",role:"group","aria-label":i("lead"===p?"lead.question":"chat.question"),...tv(a),children:[(0,s.jsxs)("p",{className:"small cs-ask-head",children:[(0,s.jsx)("strong",{children:i("lead"===p?"lead.question":"chat.question")})," ",(0,s.jsx)(eX.y,{actor:p,how:"asks"})]}),(0,s.jsx)(eY.s,{text:m.text}),m.why&&(0,s.jsx)("p",{className:"muted small",children:m.why}),(0,s.jsx)("div",{className:"cs-copy-row",children:(0,s.jsx)(et.i8,{text:(0,te.yw)(i,m,!0),what:"chat.copyQuestion"})}),(0,s.jsx)(tt.Y,{id:c,q:m,locked:o,mark:h,onAnswer:(e,t)=>void f(e,t),children:(0,s.jsx)("button",{type:"button",className:"danger",...h("stop"),onClick:()=>void x(),children:i("lead.stop")})}),d&&(0,s.jsx)("p",{className:"err",role:"alert",children:d}),(0,s.jsx)(et.T4,{text:(0,te.Mo)(i,a)})]})}function tz(e){let{workspace:t,composeAsk:a,showThread:l,onOpenFile:n,onOpenFolder:i,onTurn:r,onChange:c,onClose:o,grip:d}=e,{t:u}=(0,k.kj)(),h=(0,eH.v)(),m=(0,eR.ms)(h),p=(0,eR.IH)(u,h);return(0,s.jsxs)("div",{className:"wb-chat-inner",children:[(0,s.jsxs)("div",{className:"wb-chat-tabs",role:"tablist","aria-label":u("wb.chatPanel"),children:[d,(0,s.jsxs)("button",{type:"button",role:"tab","aria-selected":!0,className:"on",children:[u("wb.chatTab"),m&&(0,s.jsxs)("span",{className:"wb-live-badge".concat((null==h?void 0:h.paused)?" paused":""),role:"status",title:p,"aria-label":p,children:[(0,s.jsx)("span",{className:"wb-live-badge-dot","aria-hidden":"true"}),u("wb.live")]})]}),(0,s.jsx)("span",{className:"grow"}),(0,s.jsx)("button",{type:"button",className:"wb-icon-btn","aria-label":u("wb.toggleChat"),title:u("wb.toggleChat"),onClick:o,children:"\xd7"})]}),(0,s.jsx)(to,{workspace:t,composeAsk:a,showThread:l,onOpenFile:n,onChange:c,onOpenFolder:i,onTurn:r})]})}var tD=a(5462);let tW=[{tab:"terminal",label:"wb.terminal",infoLabel:"wb.terminalInfoLabel",info:"wb.terminalInfo"},{tab:"problems",label:"wb.problems",infoLabel:"wb.problemsInfoLabel",info:"wb.problemsInfo"},{tab:"output",label:"wb.output",infoLabel:"wb.outputInfoLabel",info:"wb.outputInfo"}];function tA(e){let{open:t,onToggle:a,tab:n,onTab:i,session:r,task:c,newChat:o=!1,onShowMessage:d}=e,{t:u}=(0,k.kj)(),h=r?function(e){let t=[];return e.tasks.forEach((a,s)=>{var l,n,i,r;let c="".concat(s+1,". ").concat(a.title),o=function(l,n,i){var r,o;let d=arguments.length>3&&void 0!==arguments[3]?arguments[3]:c,u=null!=(r=i.at)?r:a.finishedAt;t.push({key:"".concat(e.id,"|").concat(a.id,"|a").concat(null!=(o=a.attempt)?o:1,"|").concat(l,"|").concat(n),taskId:a.id,kind:l,text:n,where:d,...i,...u?{at:u}:{},...!i.at&&u&&"stop"!==i.from?{atEnd:!0}:{},n:s+1,title:a.title,status:a.status})};for(let e of null!=(i=a.checkResults)?i:[])e.passed||o("error","".concat(e.name,": ").concat(e.detail.slice(0,160)),{from:"check",full:"".concat(e.name,"\n\n").concat(e.detail),at:e.at});if((null==(l=a.review)?void 0:l.verdict)==="fail")for(let e of null!=(r=a.review.findings)?r:[])o("error",e.what.slice(0,200),{from:"review",full:e.what,evidence:e.evidence||void 0,place:e.where,at:a.review.at},e.where?"".concat(c," \xb7 ").concat(e.where):c);["failed","blocked","limit-reached","aborted"].includes(a.status)&&a.reason&&o("warn",a.reason.slice(0,200),{from:"stop",full:a.reason}),(null==(n=a.vcs)?void 0:n.problem)&&o("warn",a.vcs.problem.slice(0,200),{from:"vcs",full:a.vcs.problem,at:a.vcs.problemAt})}),t}(r):[],[m,p]=(0,l.useState)(()=>new Set),[f,x]=(0,l.useState)(!1),[b,g]=(0,l.useState)(()=>new Set);(0,l.useEffect)(()=>p(tP()),[]);let v=e=>p(function(e){let t=[...new Set([...tP(),...e.filter(e=>e)])].slice(-500);try{window.localStorage.setItem(tT,JSON.stringify(t))}catch(e){}return new Set(t)}(e)),j=h.filter(e=>!m.has(e.key)),w=f?h:j,y=h.length-j.length;return(0,s.jsxs)("section",{className:"wb-bottom","aria-label":u("wb.panel"),children:[(0,s.jsxs)("div",{className:"wb-bottom-tabs",role:"tablist","aria-label":u("wb.panel"),children:[tW.map(e=>{let{tab:a,label:r,infoLabel:c,info:o}=e;return(0,s.jsxs)(l.Fragment,{children:[(0,s.jsxs)("button",{type:"button",role:"tab","aria-selected":t&&n===a,className:t&&n===a?"on":"",onClick:()=>i(a),children:[u(r),"problems"===a&&j.length>0&&(0,s.jsx)("span",{className:"wb-badge",children:j.length})]}),(0,s.jsx)(tD.q,{label:u(c),text:u(o)})]},a)}),(0,s.jsx)("span",{className:"grow"}),(0,s.jsx)("button",{type:"button",className:"wb-icon-btn","aria-label":u("wb.cmdPanel"),title:"".concat(u("wb.cmdPanel")," (Ctrl+J)"),onClick:a,children:t?"▾":"▴"})]}),t&&(0,s.jsx)("div",{className:"wb-bottom-body",role:"tabpanel",children:"terminal"===n?o?(0,s.jsx)("p",{className:"muted small wb-pad",children:u("wb.newChatTerminal")}):(0,s.jsx)(tB,{session:r,task:c}):"problems"===n?0===h.length?(0,s.jsx)("p",{className:"muted small wb-pad",children:o?u("wb.newChatProblems"):r?u("wb.noProblems"):u("wb.pickChat")}):(0,s.jsxs)(s.Fragment,{children:[0===w.length?(0,s.jsx)("p",{className:"muted small wb-pad",children:u("wb.problemsNoneNew")}):(0,s.jsx)("ul",{className:"wb-problems",children:w.map((e,t)=>{let a=b.has(e.key);return(0,s.jsxs)("li",{className:m.has(e.key)?"seen":void 0,children:[(0,s.jsxs)("div",{className:"wb-problem-line",children:[(0,s.jsxs)("button",{type:"button",className:"wb-row","aria-expanded":a,"aria-controls":a?"wb-problem-".concat(t):void 0,onClick:()=>{let t;return t=e.key,g(e=>{let a=new Set(e);return a.delete(t)||a.add(t),a})},title:u(a?"wb.problemLessWhy":"wb.problemMoreWhy"),children:[(0,s.jsx)("span",{className:"wb-fold","aria-hidden":"true",children:a?"▾":"▸"}),(0,s.jsx)("span",{className:"wb-sev ".concat(e.kind),"aria-hidden":"true",children:"error"===e.kind?"✗":"⚠"}),(0,s.jsx)("span",{className:"wb-row-name",children:e.text}),(0,s.jsx)("span",{className:"muted wb-problem-where",children:e.where})]}),!m.has(e.key)&&(0,s.jsx)("button",{type:"button",className:"quiet small wb-seen",onClick:()=>v([e.key]),title:u("wb.problemSeenWhy"),children:u("wb.problemSeen")})]}),a&&r&&(0,s.jsx)(tR,{id:"wb-problem-".concat(t),problem:e,session:r,onShowMessage:d})]},e.key)})}),(j.length>1||y>0)&&(0,s.jsxs)("div",{className:"row wb-pad",children:[j.length>1&&(0,s.jsx)("button",{type:"button",className:"quiet small",onClick:()=>v(j.map(e=>e.key)),title:u("wb.problemSeenWhy"),children:u("wb.problemsAllSeen")}),y>0&&(0,s.jsx)("button",{type:"button",className:"quiet small",onClick:()=>x(!f),children:f?u("wb.problemsHideSeen"):u("wb.problemsShowSeen",{n:y})})]})]}):o?(0,s.jsx)("p",{className:"muted small wb-pad",children:u("wb.newChatOutput")}):(0,s.jsx)(t_,{session:r})})]})}let tH={check:"wb.problemFromCheck",review:"wb.problemFromReview",stop:"wb.problemFromStop",vcs:"wb.problemFromVcs"};function tR(e){var t;let{id:a,problem:n,session:i,onShowMessage:r}=e,{t:c}=(0,k.kj)(),o=(0,k.W3)(),d=c("status.".concat(n.status)),u=c(tH[n.from],{status:d}),h=n.at?n.atEnd?c("wb.problemWhenEnd",{time:o(n.at)}):o(n.at):c("wb.problemWhenNone"),m=i.name.replace(/^chat: /,""),p=(null==(t=i.chat)?void 0:t.name)&&i.chat.name!==m?i.chat.name:void 0,f=[["wb.problemWhat",u],["wb.problemWhen",h],["wb.problemChat",p?"".concat(m," (").concat(c("wb.problemInCopilot",{name:p}),")"):m],["wb.problemMessage","".concat(n.n,". ").concat(n.title)],...n.place?[["wb.problemPlace",n.place]]:[]],x=[n.full,...n.evidence?["".concat(c("wb.problemEvidence"),":\n").concat(n.evidence)]:[],f.map(e=>{let[t,a]=e;return"".concat(c(t),": ").concat(a)}).join("\n")].join("\n\n");return(0,s.jsxs)("div",{id:a,className:"wb-problem-more",children:[(0,s.jsx)("dl",{className:"wb-problem-facts",children:f.map(e=>{let[t,a]=e;return(0,s.jsxs)(l.Fragment,{children:[(0,s.jsx)("dt",{children:c(t)}),(0,s.jsx)("dd",{dir:"auto",children:a})]},t)})}),(0,s.jsxs)("div",{className:"row wb-problem-actions",children:[(0,s.jsx)("button",{type:"button",className:"quiet small",onClick:()=>r(n.taskId),children:c("wb.problemShow")}),(0,s.jsx)(et.i8,{text:x,what:"wb.problemCopy"})]}),(0,s.jsx)("p",{className:"wb-problem-full",dir:"auto",children:n.full}),n.evidence&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("p",{className:"muted small wb-problem-label",children:c("wb.problemEvidence")}),(0,s.jsx)("p",{className:"wb-problem-full",dir:"auto",children:n.evidence})]})]})}let tT="cop.problems.seen";function tP(){try{var e;let t=JSON.parse(null!=(e=window.localStorage.getItem(tT))?e:"[]");return new Set(Array.isArray(t)?t.filter(e=>"string"==typeof e):[])}catch(e){return new Set}}function tB(e){var t,a;let{session:n,task:i}=e,{t:c}=(0,k.kj)(),[o,d]=(0,l.useState)(null),u=(null==i?void 0:i.status)==="running"||(null==i?void 0:i.status)==="waiting-approval",{ref:h}=eZ(!!u,null!=(t=null==o?void 0:o.entries.length)?t:0),p=()=>n&&i&&(i.startedAt||u)?r.FH.taskStory(n.id,i.id,i.runId).then(d).catch(()=>void 0):Promise.resolve();if((0,l.useEffect)(()=>{d(null),p()},[null==i?void 0:i.id,null==i?void 0:i.runId]),(0,m.z)(p,u?2e3:15e3,!!n&&!!i),!i)return(0,s.jsx)("p",{className:"muted small wb-pad",children:c("wb.pickChat")});let f=[],x=e=>e.forEach(e=>"step"===e.kind?f.push(e):"review"===e.kind?x(e.entries):void 0);return(x(null!=(a=null==o?void 0:o.entries)?a:[]),0===f.length)?(0,s.jsx)("p",{className:"muted small wb-pad",children:o?c("wb.noSteps"):c("wb.loading")}):(0,s.jsx)("div",{ref:h,className:"wb-terminal","aria-live":"off",children:f.map((e,t)=>(0,s.jsxs)("div",{className:e.failed?"bad":"",children:[(0,s.jsxs)("div",{className:"wb-cmd",children:[(0,s.jsx)("span",{"aria-hidden":"true",children:"$ "}),e.command,(0,s.jsxs)("span",{className:"muted",children:[" ",e.outcome?"".concat(e.outcome).concat(void 0!==e.exitCode?" (".concat(e.exitCode,")"):""):c("wb.runningNow")]})]}),e.output&&(0,s.jsx)("pre",{children:e.output})]},t))})}function t_(e){let{session:t}=e,{t:a}=(0,k.kj)(),n=(0,k.W3)(),[i,c]=(0,l.useState)([]),{ref:o}=eZ(!0,i.length),d=()=>t?r.FH.sessionEvents(t.id).then(c).catch(()=>void 0):Promise.resolve();return((0,l.useEffect)(()=>{c([]),d()},[null==t?void 0:t.id]),(0,m.z)(d,3e3,!!t),t)?(0,s.jsx)("div",{ref:o,className:"wb-terminal",children:0===i.length?(0,s.jsx)("p",{className:"muted small",children:a("wb.noEvents")}):i.map((e,t)=>{var a;return(0,s.jsxs)("div",{className:"error"===e.level?"bad":"warn"===e.level?"warnline":"",children:[(0,s.jsxs)("span",{className:"muted",children:[n(e.at)," "]}),null!=(a=e.message)?a:e.type]},t)})}):(0,s.jsx)("p",{className:"muted small wb-pad",children:a("wb.pickChat")})}function t$(e){var t,a,n,i,c,o,d,u,h,p,f;let{sessions:x,session:b,workspace:g,onShowThread:v,onApprovals:j,onShowWaiting:w}=e,{t:y}=(0,k.kj)(),N=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1e3,[a,s]=(0,l.useState)(()=>Date.now());return(0,l.useEffect)(()=>{if(!e)return;s(Date.now());let a=window.setInterval(()=>s(Date.now()),t);return()=>window.clearInterval(a)},[e,t]),a}(!0,5e3),[S,C]=(0,l.useState)([]),[F,M]=(0,l.useState)({iterations:60,minutes:240});(0,l.useEffect)(()=>{r.FH.settings().then(e=>{var t,a,s;let l=null!=(t=e.raw.limits)?t:{};M({iterations:null!=(a=l.maxIterations)?a:60,minutes:null!=(s=l.maxRunMinutes)?s:240})}).catch(()=>void 0)},[]);let O=(0,l.useRef)(j);O.current=j,(0,m.z)(()=>r.FH.approvals().then(e=>{var t;C(e),null==(t=O.current)||t.call(O,e)}).catch(()=>void 0),3e3);let q=null!=(c=x.find(e=>"idle"!==e.status&&!e.workerOf))?c:x.find(e=>"idle"!==e.status),E=null==q?void 0:q.tasks.find(e=>"running"===e.status||"waiting-approval"===e.status),L=Math.floor(function(e,t,a){let s=e?Date.parse(e):NaN;if(!Number.isFinite(s))return 0;let l=0;for(let e of null!=t?t:[]){let t=Date.parse(e.from),n=e.to?Date.parse(e.to):a;Number.isFinite(t)&&Number.isFinite(n)&&(l+=Math.max(0,Math.min(n,a)-Math.max(t,s)))}return Math.max(0,a-s-l)}(null==E?void 0:E.startedAt,null==q?void 0:q.pauses,N)/6e4);return(0,s.jsxs)("footer",{className:"wb-statusbar","aria-label":y("wb.status"),children:[(null==g?void 0:g.ok)&&(0,s.jsxs)("span",{title:g.dir,children:[(0,s.jsx)(eo.O,{})," ",g.branch?"".concat(g.name," \xb7 ").concat(g.branch):g.name]}),q&&E?(0,s.jsxs)("button",{type:"button",className:"wb-status-btn",onClick:()=>v(q.id),title:y("wb.openRunning"),children:[(0,s.jsx)("span",{className:q.paused?"wb-live paused":"wb-live","aria-hidden":"true"})," ",E.acting&&(0,s.jsx)(eX.y,{actor:E.acting.actor,acting:E.acting})," ",E.lead?y("wb.runningLineTwo",{session:q.name.replace(/^chat: /,""),task:E.title,lead:null!=(o=null==(t=E.lead.messages)?void 0:t.lead)?o:0,worker:null!=(d=null==(a=E.lead.messages)?void 0:a.worker)?d:0,total:(null!=(u=null==(n=E.lead.messages)?void 0:n.lead)?u:0)+(null!=(h=null==(i=E.lead.messages)?void 0:i.worker)?h:0),m:L,maxm:F.minutes}):y("wb.runningLine",{session:q.name.replace(/^chat: /,""),task:E.title,n:E.iterations,max:F.iterations,m:L,maxm:F.minutes}),q.paused&&(0,s.jsxs)("strong",{className:"wb-paused",children:[" \xb7 ",y("wb.pausedTag")]})]}):(0,s.jsx)("span",{children:y("wb.idle")}),(0,s.jsx)("span",{className:"grow"}),S.length>0&&(0,s.jsx)("button",{type:"button",className:"wb-status-btn warn",onClick:()=>{var e;let t=S[0];!t.model&&(null==w?void 0:w(t))||null==(e=document.querySelector(".approval-banner"))||e.scrollIntoView({block:"start"})},children:y("wb.waiting",{n:S.length})}),b&&(0,s.jsx)("span",{title:y("wb.modelNow"),children:null!=(f=null!=(p=b.modelInUse)?p:b.model)?f:y("wb.modelDefault")})]})}var tU=a(1702);function tK(e){let{commands:t,onClose:a}=e,{t:n}=(0,k.kj)(),i=(0,tU.useRouter)(),[r,c]=(0,l.useState)(""),[o,d]=(0,l.useState)(0),u=(0,l.useRef)(null);(0,l.useEffect)(()=>{var e;return null==(e=u.current)?void 0:e.focus()},[]);let h=(0,l.useMemo)(()=>{let e=r.toLowerCase().split(/\s+/).filter(Boolean);return t.filter(t=>e.every(e=>{var a;return"".concat(t.label," ").concat(null!=(a=t.hint)?a:"").toLowerCase().includes(e)})).slice(0,60)},[r,t]),m=0===h.length?-1:Math.min(o,h.length-1),p=e=>{var t;e&&(a(),e.href?i.push(e.href):null==(t=e.run)||t.call(e))};return(0,s.jsx)("div",{className:"modal-backdrop",role:"presentation",onClick:a,children:(0,s.jsxs)("div",{className:"wb-palette",role:"dialog","aria-modal":"true","aria-label":n("wb.palette"),onClick:e=>e.stopPropagation(),children:[(0,s.jsx)("input",{ref:u,type:"text",role:"combobox","aria-expanded":"true","aria-controls":"wb-palette-list","aria-activedescendant":m>=0?"wb-cmd-".concat(m):void 0,"aria-label":n("wb.palette"),placeholder:n("wb.palettePlaceholder"),value:r,onChange:e=>{c(e.target.value),d(0)},onKeyDown:e=>{"Escape"===e.key?a():"ArrowDown"===e.key?(e.preventDefault(),d(Math.min(h.length-1,m+1))):"ArrowUp"===e.key?(e.preventDefault(),d(Math.max(0,m-1))):"Enter"===e.key&&(e.preventDefault(),p(h[m]))}}),(0,s.jsxs)("ul",{id:"wb-palette-list",role:"listbox","aria-label":n("wb.palette"),children:[0===h.length&&(0,s.jsx)("li",{className:"muted small",children:n("wb.paletteNone")}),h.map((e,t)=>(0,s.jsxs)("li",{id:"wb-cmd-".concat(t),role:"option","aria-selected":t===m,className:t===m?"on":"",onMouseEnter:()=>d(t),onClick:()=>p(e),children:[(0,s.jsx)("span",{className:"wb-row-name",children:e.label}),e.hint&&(0,s.jsx)("span",{className:"muted small",children:e.hint})]},e.id))]})]})})}function tV(){let{t:e}=(0,k.kj)();return(0,s.jsxs)("section",{className:"kerrigan-about","aria-labelledby":"kerrigan-about-title",children:[(0,s.jsx)("h3",{id:"kerrigan-about-title",children:e("kerrigan.aboutTitle")}),(0,s.jsx)("p",{children:e("kerrigan.aboutWhat")}),(0,s.jsx)("p",{className:"kerrigan-about-uses",children:e("kerrigan.aboutUses")}),(0,s.jsxs)("ul",{children:[(0,s.jsx)("li",{children:e("kerrigan.aboutUse1")}),(0,s.jsx)("li",{children:e("kerrigan.aboutUse2")}),(0,s.jsx)("li",{children:e("kerrigan.aboutUse3")}),(0,s.jsx)("li",{children:e("kerrigan.aboutUse4",{file:e("chatloc.file")})})]}),(0,s.jsx)("p",{className:"kerrigan-about-uses",children:e("kerrigan.aboutStepsTitle")}),(0,s.jsxs)("ol",{children:[(0,s.jsx)("li",{children:e("kerrigan.aboutStep1",{button:e("kerrigan.button"),copy:e("kerrigan.copy"),save:e("kerrigan.save")})}),(0,s.jsx)("li",{children:e("kerrigan.aboutStep2")}),(0,s.jsx)("li",{children:e("kerrigan.aboutStep3")}),(0,s.jsx)("li",{children:e("kerrigan.aboutStep4")})]}),(0,s.jsx)("p",{className:"muted small",children:e("kerrigan.aboutFresh")}),(0,s.jsx)("p",{className:"muted small",children:e("kerrigan.aboutNote")})]})}function tZ(e){let{workspace:t}=e,{t:a,locale:n}=(0,k.kj)(),i=(0,tD.f)("below"),[c,o]=(0,l.useState)(""),[d,u]=e$(),[h,m]=(0,l.useState)([]);(0,l.useEffect)(()=>{r.FH.skills().then(e=>m(e.skills)).catch(()=>void 0)},[]);let p=e=>e.trim().replace(/[\\/]+$/,"").replace(/\//g,"\\").toLowerCase(),f=h.filter(e=>!e.projectDir||(null==t?void 0:t.ok)&&p(e.projectDir)===p(t.dir)),x=async()=>{try{let e=await r.FH.kerrigan(n,d||void 0);return e.filled?e:{...e,text:e.text.replace(/⟦([\w.-]+)⟧/g,(e,t)=>a(t))}}catch(e){return o(a("kerrigan.failed",{reason:e.message})),null}},b=async()=>{i.close();let e=await x();if(!e)return;let t=URL.createObjectURL(new Blob([e.text],{type:"text/markdown;charset=utf-8"})),s=document.createElement("a");s.href=t,s.download=e.fileName,s.click(),URL.revokeObjectURL(t),o(a("kerrigan.saved",{name:e.fileName}))},g=async()=>{i.close();let e=await x();e&&o(await (0,et.Dk)(e.text)?a("kerrigan.copied",{n:e.text.length}):a("kerrigan.copyFailed"))};return(0,s.jsxs)("div",{className:"kerrigan",children:[(0,s.jsxs)("div",{className:"row",children:[(0,s.jsxs)("button",{ref:i.anchor,type:"button",className:"primary","aria-haspopup":"menu","aria-expanded":i.open,"aria-controls":i.open?i.id:void 0,onClick:()=>{i.open||x(),i.toggle()},children:[a("kerrigan.button")," ",(0,s.jsx)("span",{"aria-hidden":"true",children:"▾"})]}),(0,s.jsx)(tD.q,{label:a("kerrigan.infoLabel"),text:a("kerrigan.info")}),f.length>0&&(0,s.jsxs)("span",{className:"kerrigan-skill",children:[(0,s.jsx)("label",{htmlFor:"kerrigan-skill",className:"cs-pick-label",children:a("chat.skill")}),(0,s.jsxs)("select",{id:"kerrigan-skill",value:d,onChange:e=>u(e.target.value),children:[(0,s.jsx)("option",{value:"",children:a("chat.skillNone")}),f.map(e=>(0,s.jsxs)("option",{value:e.name,title:e.description||void 0,children:["/",e.name]},e.name))]}),(0,s.jsx)(tD.q,{label:a("info.about",{name:a("chat.skill")}),text:a("kerrigan.skillWhy")})]})]}),i.open&&(0,s.jsxs)("div",{ref:i.panel,id:i.id,role:"menu","aria-label":a("kerrigan.menu"),className:"pop menu",style:i.style,children:[(0,s.jsx)("button",{type:"button",role:"menuitem",onClick:()=>void b(),children:a("kerrigan.save")}),(0,s.jsx)("button",{type:"button",role:"menuitem",onClick:()=>void g(),children:a("kerrigan.copy")})]}),c&&(0,s.jsx)("p",{className:"small",role:"status",children:c})]})}var tJ=a(83285);let tG=(e,t)=>0===t||/[/\\._\-\s]/.test(e[t-1])||/[a-z]/.test(e[t-1])&&/[A-Z]/.test(e[t]);function tY(e,t){let a=e.toLowerCase(),s=[],l=0,n=0,i=-2;for(let r of t.toLowerCase()){let t=a.indexOf(r,n);if(t<0)return null;for(let s=t;s>=0&&s<a.length&&s<t+12;s=a.indexOf(r,s+1))if(tG(e,s)){t=s;break}l+=1,t===i+1&&(l+=5),tG(e,t)&&(l+=3),e[t]===r&&(l+=1),s.push(t),i=t,n=t+1}return{score:l-.05*Math.max(0,s[0]),hits:s}}function tQ(e,t){let a=new Set(t),l=[],n="",i=!1,r=e=>{n&&(l.push(i?(0,s.jsx)("mark",{className:"qo-hit",children:n},e):n),n="")};return[...e].forEach((e,t)=>{let s=a.has(t);s!==i&&(r(t),i=s),n+=e}),r(e.length),l}function tX(e){let{recent:t,onOpen:a,onClose:n}=e,{t:i}=(0,k.kj)(),[c,o]=(0,l.useState)(null),[d,u]=(0,l.useState)(""),[h,m]=(0,l.useState)(0),[p,f]=(0,l.useState)(!1),x=(0,l.useRef)(null),b=(0,l.useRef)(null);(0,l.useEffect)(()=>{var e;return null==(e=x.current)?void 0:e.focus()},[]),(0,l.useEffect)(()=>{r.FH.workspaceFiles().then(e=>o(e.files)).catch(()=>o([]))},[]);let{query:g,line:v}=function(e){let t=/^(.*?):(\d+)(?::\d+)?\s*$/.exec(e);return t?{query:t[1],line:Number(t[2])}:{query:e}}(d),j=(0,l.useMemo)(()=>{if(!c)return[];if(!g.trim()){let e=new Set(c),a=t.filter(t=>e.has(t)),s=c.filter(e=>!a.includes(e)).slice(0,50);return[...a.map(e=>({path:e,score:0,nameHits:[],dirHits:[],recent:!0})),...s.map(e=>({path:e,score:0,nameHits:[],dirHits:[]}))]}return function(e,t){let a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:50,s=[];for(let a of e){let e=function(e,t){let a=t.trim();if(!a)return{path:e,score:0,nameHits:[],dirHits:[]};let s=e.lastIndexOf("/"),l=e.slice(s+1),n=s>=0?e.slice(0,s):"",i=0,r=[],c=[];for(let t of a.split(/\s+/).filter(Boolean)){if(t.includes("/")){let a=tY(e,t);if(!a)return null;for(let e of(i+=a.score,a.hits))e>s?r.push(e-s-1):c.push(e);continue}let a=tY(l,t);if(a){i+=a.score+10+8*!!l.toLowerCase().startsWith(t.toLowerCase()),r.push(...a.hits);continue}let n=tY(e,t);if(!n)return null;for(let e of(i+=n.score,n.hits))e>s?r.push(e-s-1):c.push(e)}return{path:e,score:i-.01*e.length-(n?.2*n.split("/").length:0),nameHits:r,dirHits:c}}(a,t);e&&s.push(e)}return s.sort((e,t)=>t.score-e.score||e.path.localeCompare(t.path)).slice(0,a)}(c,g,60)},[c,g,t]),w=0===j.length?-1:Math.min(h,j.length-1);(0,l.useEffect)(()=>{var e,t;null==(t=b.current)||null==(e=t.querySelector('[aria-selected="true"]'))||e.scrollIntoView({block:"nearest"})},[w]);let y=e=>{e&&(n(),a(e.path,v))};return(0,l.useEffect)(()=>{p&&c&&(f(!1),y(j[0]))},[p,c]),(0,s.jsx)("div",{className:"modal-backdrop qo-backdrop",role:"presentation",onClick:n,children:(0,s.jsxs)("div",{className:"wb-palette qo",role:"dialog","aria-modal":"true","aria-label":i("quick.label"),onClick:e=>e.stopPropagation(),children:[(0,s.jsx)("input",{ref:x,type:"text",role:"combobox","aria-expanded":"true","aria-controls":"qo-list","aria-activedescendant":w>=0?"qo-".concat(w):void 0,"aria-label":i("quick.label"),placeholder:i("quick.placeholder"),value:d,spellCheck:!1,onChange:e=>{u(e.target.value),m(0)},onKeyDown:e=>{"Escape"===e.key?n():"ArrowDown"===e.key?(e.preventDefault(),m(Math.min(j.length-1,w+1))):"ArrowUp"===e.key?(e.preventDefault(),m(Math.max(0,w-1))):"Enter"===e.key&&(e.preventDefault(),c?y(j[w]):f(!0))}}),(0,s.jsxs)("ul",{id:"qo-list",ref:b,role:"listbox","aria-label":i("quick.label"),children:[c&&0===j.length&&(0,s.jsx)("li",{className:"muted small qo-none",children:i("quick.none")}),j.map((e,t)=>{let a=e.path.lastIndexOf("/"),l=e.path.slice(a+1),n=a>=0?e.path.slice(0,a):"";return(0,s.jsxs)("li",{id:"qo-".concat(t),role:"option","aria-selected":t===w,className:"qo-row".concat(t===w?" on":""),onMouseEnter:()=>m(t),onClick:()=>y(e),title:e.path,children:[(0,s.jsx)(Y,{path:e.path}),(0,s.jsx)("span",{className:"qo-name",children:tQ(l,e.nameHits)}),n&&(0,s.jsx)("span",{className:"qo-dir",children:tQ(n,e.dirHits)}),"recent"in e&&e.recent&&(0,s.jsx)("span",{className:"qo-tag",children:i("quick.recent")})]},e.path)})]})]})})}function t0(e){var t;let{onOpen:a,grip:n,focusAsk:i}=e,{t:c}=(0,k.kj)(),[o,d]=(0,l.useState)(""),[u,h]=(0,l.useState)(!1),[m,p]=(0,l.useState)(!1),[f,x]=(0,l.useState)(!1),[b,g]=(0,l.useState)(!1),[v,j]=(0,l.useState)(""),[w,y]=(0,l.useState)(""),[N,S]=(0,l.useState)(null),[C,F]=(0,l.useState)(!1),[M,O]=(0,l.useState)(""),[q,E]=(0,l.useState)(new Set),L=(0,l.useRef)(null),I=(0,l.useRef)(0);(0,l.useEffect)(()=>{if(i>0){var e,t;null==(e=L.current)||e.focus(),null==(t=L.current)||t.select()}},[i]);let z=async()=>{let e=++I.current;if(!o){S(null),F(!1),O("");return}F(!0);try{let t=await r.FH.workspaceSearch(o,{matchCase:u,wholeWord:m,regex:f,include:v,exclude:w});if(e!==I.current)return;S(t),O(""),E(new Set)}catch(t){e===I.current&&O(t.message)}finally{e===I.current&&F(!1)}};(0,l.useEffect)(()=>{let e=setTimeout(()=>void z(),300);return()=>clearTimeout(e)},[o,u,m,f,v,w]);let D=null!=(t=null==N?void 0:N.files)?t:[],W=D.length>0&&D.every(e=>q.has(e.path)),A=(e,t,a,l,n)=>(0,s.jsx)("button",{type:"button",className:"sv-toggle ".concat(n).concat(t?" on":""),"aria-pressed":t,"aria-label":e,title:e,onClick:()=>a(!t),children:l}),H=C?c("search.searching"):M||(null==N?void 0:N.problem)?c("search.problem",{why:M||(null==N?void 0:N.problem)||""}):N&&o?0===N.total?c("search.none"):c("search.results",{n:N.total,files:D.length}):"";return(0,s.jsxs)("div",{className:"sv",children:[(0,s.jsxs)("div",{className:"wb-side-head",children:[n,(0,s.jsx)("h2",{children:c("search.title")}),(0,s.jsx)("span",{className:"grow"}),(0,s.jsx)("button",{type:"button",className:"wb-icon-btn",onClick:()=>void z(),disabled:!o,"aria-label":c("search.refresh"),title:c("search.refresh"),children:"↻"}),(0,s.jsx)("button",{type:"button",className:"wb-icon-btn",onClick:()=>{var e;d(""),S(null),null==(e=L.current)||e.focus()},disabled:!o&&!N,"aria-label":c("search.clear"),title:c("search.clear"),children:(0,s.jsx)("svg",{viewBox:"0 0 16 16",width:"14",height:"14",fill:"none",stroke:"currentColor",strokeWidth:"1.4","aria-hidden":"true",children:(0,s.jsx)("path",{d:"M3 4h10M6 4V2.5h4V4M4.5 4l.7 9.5h5.6L11.5 4"})})}),(0,s.jsx)("button",{type:"button",className:"wb-icon-btn",onClick:()=>E(W?new Set:new Set(D.map(e=>e.path))),disabled:0===D.length,"aria-label":c(W?"search.expand":"search.collapse"),title:c(W?"search.expand":"search.collapse"),children:(0,s.jsx)("svg",{viewBox:"0 0 16 16",width:"14",height:"14",fill:"none",stroke:"currentColor",strokeWidth:"1.4","aria-hidden":"true",children:W?(0,s.jsx)("path",{d:"M4 6l4 4 4-4"}):(0,s.jsx)("path",{d:"M3 3h10v10H3zM5.5 8h5"})})})]}),(0,s.jsxs)("div",{className:"sv-form",children:[(0,s.jsxs)("div",{className:"sv-row",children:[(0,s.jsx)("button",{type:"button",className:"sv-details".concat(b?" on":""),"aria-expanded":b,"aria-label":c("search.details"),title:c("search.details"),onClick:()=>g(!b),children:"…"}),(0,s.jsxs)("div",{className:"sv-box",children:[(0,s.jsx)("input",{ref:L,type:"text",value:o,onChange:e=>d(e.target.value),onKeyDown:e=>{"Enter"===e.key&&z()},placeholder:c("search.input"),"aria-label":c("search.input"),spellCheck:!1}),A(c("search.matchCase"),u,h,"Aa","case"),A(c("search.wholeWord"),m,p,(0,s.jsx)("span",{className:"sv-word",children:"ab"}),"word"),A(c("search.regex"),f,x,".*","regex")]})]}),b&&(0,s.jsxs)("div",{className:"sv-globs",children:[(0,s.jsx)("label",{htmlFor:"sv-include",children:c("search.include")}),(0,s.jsx)("input",{id:"sv-include",type:"text",value:v,onChange:e=>j(e.target.value),placeholder:c("search.includePlaceholder"),spellCheck:!1}),(0,s.jsx)("label",{htmlFor:"sv-exclude",children:c("search.exclude")}),(0,s.jsx)("input",{id:"sv-exclude",type:"text",value:w,onChange:e=>y(e.target.value),placeholder:c("search.excludePlaceholder"),spellCheck:!1})]}),H&&(0,s.jsx)("p",{className:"sv-message".concat(M||(null==N?void 0:N.problem)?" bad":""),role:"status",children:H}),(null==N?void 0:N.truncated)&&!C&&(0,s.jsx)("p",{className:"sv-message",children:c("search.truncated")})]}),(0,s.jsx)("div",{className:"sv-results",role:"tree","aria-label":c("search.title"),children:D.map(e=>{let t=!q.has(e.path),l=e.path.lastIndexOf("/");return(0,s.jsxs)("div",{role:"treeitem","aria-expanded":t,"aria-selected":!1,className:"sv-file",children:[(0,s.jsxs)("button",{type:"button",className:"sv-file-head",onClick:()=>E(t=>{let a=new Set(t);return a.has(e.path)?a.delete(e.path):a.add(e.path),a}),title:e.path,children:[(0,s.jsx)("span",{className:"sv-chevron".concat(t?" open":""),"aria-hidden":"true",children:"›"}),(0,s.jsx)(Y,{path:e.path}),(0,s.jsx)("span",{className:"sv-name",children:e.path.slice(l+1)}),l>0&&(0,s.jsx)("span",{className:"sv-dir",children:e.path.slice(0,l)}),(0,s.jsx)("span",{className:"sv-count",children:e.matches.reduce((e,t)=>e+Math.max(1,t.ranges.length),0)})]}),t&&(0,s.jsx)("div",{role:"group",children:e.matches.map((t,l)=>(0,s.jsx)("button",{type:"button",role:"treeitem","aria-selected":!1,className:"sv-match",title:"".concat(e.path,":").concat(t.line),onClick:()=>{var s;return a({path:e.path,line:t.line,...void 0!==t.column?{from:t.column,to:t.column+(null!=(s=t.length)?s:0)}:{}})},onDoubleClick:()=>{var s;return a({path:e.path,line:t.line,...void 0!==t.column?{from:t.column,to:t.column+(null!=(s=t.length)?s:0)}:{}},!0)},children:function(e,t){let a=[],l=0;return t.forEach((t,n)=>{let[i,r]=t;i>l&&a.push(e.slice(l,i)),a.push((0,s.jsx)("mark",{className:"sv-hit",children:e.slice(i,r)},n)),l=r}),l<e.length&&a.push(e.slice(l)),a}(t.text,t.ranges)},"".concat(t.line,"-").concat(l)))})]},e.path)})})]})}let t1=["side","center","chat"],t2="application/x-cop-area",t3=["wb.moveLeft","wb.moveCenter","wb.moveRight"];function t4(e){let{name:t,place:a,onMove:l,onDragging:n}=e,{t:i}=(0,k.kj)(),r=(0,tD.f)("below");return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("button",{ref:r.anchor,type:"button",className:"wb-grip",draggable:!0,"aria-haspopup":"menu","aria-expanded":r.open,"aria-controls":r.open?r.id:void 0,"aria-label":i("wb.move",{name:t}),title:i("wb.moveWhy"),onClick:r.toggle,onDragStart:e=>{var t,a;e.dataTransfer.setData(t2,null!=(a=null==(t=e.currentTarget.closest("[data-area]"))?void 0:t.dataset.area)?a:""),e.dataTransfer.effectAllowed="move",r.close(),n(!0)},onDragEnd:()=>n(!1),children:(0,s.jsx)("svg",{viewBox:"0 0 10 16",width:"8",height:"13","aria-hidden":"true",children:[3,8,13].map(e=>(0,s.jsxs)("g",{children:[(0,s.jsx)("circle",{cx:"2.5",cy:e,r:"1.4",fill:"currentColor"}),(0,s.jsx)("circle",{cx:"7.5",cy:e,r:"1.4",fill:"currentColor"})]},e))})}),r.open&&(0,s.jsx)("div",{ref:r.panel,id:r.id,role:"menu","aria-label":i("wb.move",{name:t}),className:"pop wb-move-menu",style:r.style,children:t3.map((e,t)=>(0,s.jsx)("button",{type:"button",role:"menuitem",disabled:t===a,onClick:()=>{r.close(),l(t)},children:i(e)},e))})]})}let t5=e=>{var t;return"diff"===e.kind?"d:".concat(e.area,":").concat(null!=(t=e.commit)?t:"",":").concat(e.path):"f:".concat(e.path)},t6={side:290,chat:420,bottom:240,sideOpen:!0,chatOpen:!0,bottomOpen:!0,order:t1},t8="cop.workbench.layout";function t7(){return(0,s.jsx)(l.Suspense,{fallback:null,children:(0,s.jsx)(t9,{})})}function t9(){let{t:e}=(0,k.kj)(),[t,a]=(0,l.useState)(null),[n,c]=(0,l.useState)([]),[o,d]=(0,l.useState)(""),[u,h]=(0,l.useState)("files"),[p,N]=(0,l.useState)(""),[S,C]=(0,l.useState)(null),[F,M]=(0,l.useState)(null),[O,q]=(0,l.useState)("terminal"),[E,L]=(0,l.useState)(t6),[I,z]=(0,l.useState)(!1),[D,W]=(0,l.useState)(0),[A,H]=(0,l.useState)(null),[R,T]=(0,l.useState)(new Set),P=(0,l.useCallback)((e,t)=>{t&&c(t=>t.some(t=>"file"===t.kind&&t.path===e&&t.preview)?t.map(t=>"file"===t.kind&&t.path===e?{...t,preview:!1}:t):t),T(a=>{if(a.has(e)===t)return a;let s=new Set(a);return t?s.add(e):s.delete(e),s})},[]),B=(0,l.useCallback)(()=>r.FH.sessions().then(e=>a(e.filter(e=>"chat"===e.kind))).catch(()=>void 0),[]);(0,m.z)(B,3e3);let _=(0,l.useCallback)(()=>r.FH.workspace().then(C).catch(()=>void 0),[]);(0,m.z)(_,1e4);let[$,U]=(0,l.useState)(null),K=(null==S?void 0:S.ok)?S.dir:null;(0,l.useEffect)(()=>{if(!K||K===$)return;let e=function(e){let t=v(f)[e];return{tabs:Array.isArray(null==t?void 0:t.tabs)?t.tabs.filter(e=>e&&"file"===e.kind&&"string"==typeof e.path):[],active:"string"==typeof(null==t?void 0:t.active)?t.active:""}}(K);c(e.tabs),d(e.tabs.some(t=>t5(t)===e.active)?e.active:e.tabs[0]?t5(e.tabs[0]):""),T(new Set),U(K)},[K,$]),(0,l.useEffect)(()=>{if($){var e=n.filter(e=>"file"===e.kind).map(e=>({kind:"file",path:e.path,...e.preview?{preview:!0}:{}}));let t=v(f);0===e.length?delete t[$]:t[$]={tabs:e,active:o},j(f,t)}},[$,n,o]),(0,l.useEffect)(()=>{let e=e=>{x.size>0&&(e.preventDefault(),e.returnValue="")};return window.addEventListener("beforeunload",e),()=>window.removeEventListener("beforeunload",e)},[]);let V=(0,l.useCallback)(async()=>{try{let e=await r.FH.browseFolder((null==S?void 0:S.dir)||void 0);if(!e.ok){e.reason&&N(e.reason);return}await r.FH.openProjectFolder(e.path),await _()}catch(e){N(e.message)}},[null==S?void 0:S.dir,_]);(0,l.useEffect)(()=>L(function(){try{var e;let t=window.localStorage.getItem(t8);if(!t)return t6;let a={...t6,...JSON.parse(t)};return{...a,order:(e=a.order,Array.isArray(e)&&3===e.length&&t1.every(t=>e.includes(t))?e:t1)}}catch(e){return t6}}()),[]),(0,l.useEffect)(()=>{try{window.localStorage.setItem(t8,JSON.stringify(E))}catch(e){}},[E]);let Z=(0,l.useCallback)(e=>{let t=t5(e);c(a=>{let s=a.findIndex(e=>t5(e)===t);if(s>=0)return e.preview||!a[s].preview?a:a.map((e,t)=>t===s?{...e,preview:!1}:e);if(!e.preview)return[...a,e];let l=a.findIndex(e=>e.preview);return l<0?[...a,e]:a.map((t,a)=>a===l?e:t)}),d(t)},[]),[J,G]=(0,l.useState)(null),[Q,X]=(0,l.useState)(!1),[ee,et]=(0,l.useState)(null),[ea,es]=(0,l.useState)(0),el=(0,l.useCallback)((e,t)=>{Z({kind:"file",path:e.path,...t?{}:{preview:!0}}),et(t=>{var a;return{path:e.path,line:e.line,from:e.from,to:e.to,n:(null!=(a=null==t?void 0:t.n)?a:0)+1}})},[Z]),en=()=>{h("search"),eu({sideOpen:!0}),es(e=>e+1)},ei=async t=>{let a=n.find(e=>t5(e)===t);if((null==a?void 0:a.kind)==="file"&&R.has(a.path)){var s,l;if(!await (0,eJ.Z)(e("ed.closeUnsaved",{name:null!=(s=a.path.split("/").pop())?s:a.path})))return;P(a.path,!1),$&&(l=a.path,b.add(g($,l)),w($,l))}c(e=>{let a=e.findIndex(e=>t5(e)===t),s=e.filter(e=>t5(e)!==t);return t===o&&d(s[Math.max(0,a-1)]?t5(s[Math.max(0,a-1)]):""),s})},er=n.find(e=>t5(e)===o),ec=F&&"new"!==F?null==t?void 0:t.find(e=>e.id===F.sessionId):void 0,eo=F&&"new"!==F?null==ec?void 0:ec.tasks.find(e=>e.id===F.taskId):void 0,eu=e=>L(t=>({...t,...e})),eh=e=>{let t=n.find(t=>t5(t)===e);t&&(c(t=>t.map(t=>t5(t)===e&&t.preview?{...t,preview:!1}:t)),h("files"),eu({sideOpen:!0}),G(e=>{var a;return{path:t.path,n:(null!=(a=null==e?void 0:e.n)?a:0)+1}}))},em=()=>{eu({chatOpen:!0}),W(e=>e+1)},ep=(0,l.useRef)(new Set),ef=e=>{var a;let s=null==t?void 0:t.find(t=>t.id===e.sessionId);if(!s)return!1;eu({chatOpen:!0});let l=[];for(let e=s;e&&l.length<4;e=null==t?void 0:t.find(t=>{var a;return t.id===(null!=(a=e.workerOf)?a:e.directedBy)}))e.workerOf||l.push(e.id);if(l.includes(tc(ta)))return!0;let n=null!=(a=l.at(-1))?a:s.id;return H(e=>{var t;return{id:n,n:(null!=(t=null==e?void 0:e.n)?t:0)+1}}),!0};(0,l.useEffect)(()=>{let e=e=>{if(!(e.ctrlKey||e.metaKey))return;let t=e.key.toLowerCase();"k"===t||"p"===t&&e.shiftKey?(e.preventDefault(),z(!0)):"p"===t?(e.preventDefault(),X(!0)):"f"===t&&e.shiftKey?(e.preventDefault(),en()):"e"===t&&e.shiftKey?(e.preventDefault(),h("files"),eu({sideOpen:!0})):"b"!==t||e.shiftKey?"j"===t?(e.preventDefault(),eu({bottomOpen:!E.bottomOpen})):"l"===t&&(e.preventDefault(),em()):(e.preventDefault(),eu({sideOpen:!E.sideOpen}))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[E]);let ex=(0,l.useMemo)(()=>[{id:"chat",label:e("wb.cmdChat"),hint:"Ctrl+L",run:em},{id:"side",label:e("wb.cmdSide"),hint:"Ctrl+B",run:()=>eu({sideOpen:!E.sideOpen})},{id:"panel",label:e("wb.cmdPanel"),hint:"Ctrl+J",run:()=>eu({bottomOpen:!E.bottomOpen})},{id:"quick-open",label:e("wb.cmdQuickOpen"),hint:"Ctrl+P",run:()=>X(!0)},{id:"search",label:e("wb.cmdSearch"),hint:"Ctrl+Shift+F",run:en},{id:"layout",label:e("wb.cmdResetLayout"),run:()=>eu({order:t1,side:t6.side,chat:t6.chat})},{id:"files",label:e("wb.cmdFiles"),run:()=>{eu({sideOpen:!0}),h("files")}},{id:"commits",label:e("wb.cmdCommits"),run:()=>{eu({sideOpen:!0}),h("commits")}},{id:"problems",label:e("wb.cmdProblems"),run:()=>{eu({bottomOpen:!0}),q("problems")}},...er?[{id:"keep-tab",label:e("wb.cmdKeepTab"),run:()=>eh(o)}]:[],...[["/queue","nav.queue"],["/settings","nav.defaults"],["/system","nav.system"]].map(t=>{let[a,s]=t;return{id:"go:".concat(a),label:e("wb.cmdGo",{page:e(s)}),href:a}}),...(null!=t?t:[]).map(t=>({id:"c:".concat(t.id),label:e("wb.cmdThread",{name:t.name.replace(/^chat: /,"")}),run:()=>{eu({chatOpen:!0}),H(e=>{var a;return{id:t.id,n:(null!=(a=null==e?void 0:e.n)?a:0)+1}})}}))],[t,e,E,o,n]),[eb,eg]=(0,l.useState)(!1),[ev,ej]=(0,l.useState)(null),ew=e=>E.order.indexOf(e),ek=E.order.filter(e=>"side"===e?E.sideOpen:"chat"!==e||E.chatOpen),ey=ek.map(e=>1===ew(e)?"minmax(0, 1fr)":"".concat(0===ew(e)?E.side:E.chat,"px"));ey.length>0&&!ey.includes("minmax(0, 1fr)")&&(ey[ey.length-1]="minmax(0, 1fr)");let eN=["46px",...ey.flatMap((e,t)=>0===t?[e]:["5px",e])].join(" "),eS=(e,t)=>eu({order:function(e,t,a){let s=e.indexOf(t);if(s<0||a<0||a>2||s===a)return e;let l=[...e];return l[s]=e[a],l[a]=t,l}(E.order,e,t)}),eC=(e,t)=>(0,s.jsx)(t4,{area:e,name:t,place:ew(e),onMove:t=>eS(e,t),onDragging:eg}),eM=t=>({"data-area":t,"data-drop":e("wb.dropHere"),onDragOver:e=>{e.dataTransfer.types.includes(t2)&&(e.preventDefault(),e.dataTransfer.dropEffect="move",ev!==t&&ej(t))},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||ej(e=>e===t?null:e)},onDrop:e=>{let a=e.dataTransfer.getData(t2);e.preventDefault(),ej(null),eg(!1),a&&a!==t&&E.order.includes(a)&&eS(a,ew(t))}}),eO=e=>"".concat(eb?" wb-drop":"").concat(ev===e?" wb-drop-over":""),eq={"--wb-columns":eN,"--wb-side":E.sideOpen?"".concat(E.side,"px"):"0px","--wb-chat":E.chatOpen?"".concat(E.chat,"px"):"0px","--wb-bottom":E.bottomOpen?"".concat(E.bottom,"px"):"34px"},eE={side:(0,s.jsxs)("aside",{className:"wb-side".concat(eO("side")),"aria-label":e("wb.explorer"),hidden:!E.sideOpen,...eM("side"),children:[(0,s.jsx)("div",{className:"wb-side-view",hidden:"search"!==u,children:(0,s.jsx)(t0,{onOpen:el,grip:"search"===u?eC("side",e("wb.explorer")):void 0,focusAsk:ea})}),"search"!==u&&(0,s.jsx)(ed,{view:u,onOpen:Z,reveal:J,workspace:S,onOpenFolder:()=>void V(),grip:eC("side",e("wb.explorer"))})]},"side"),center:(0,s.jsxs)("section",{className:"wb-center".concat(eO("center")),"aria-label":e("wb.editor"),...eM("center"),children:[(0,s.jsxs)("div",{className:"wb-tabs",role:"tablist","aria-label":e("wb.openTabs"),children:[eC("center",e("wb.editor")),0===n.length&&(0,s.jsx)("span",{className:"muted small wb-tabs-empty",children:e("wb.noTabs")}),n.map(t=>{var a,l,n;let i=t5(t),r="diff"===t.kind?"".concat(t.path.split("/").pop()," (").concat("commit"===t.area?(null!=(a=t.commit)?a:"").slice(0,7):"branch"===t.area?"⎇ ".concat(null!=(l=t.commit)?l:""):e("staged"===t.area?"git.index":"git.workingTree"),")"):null!=(n=t.path.split("/").pop())?n:t.path;return(0,s.jsxs)("div",{className:"wb-tab".concat(i===o?" active":"").concat(t.preview?" preview":""),children:[(0,s.jsxs)("button",{type:"button",role:"tab","aria-selected":i===o,onClick:()=>d(i),onDoubleClick:()=>eh(i),title:t.preview?"".concat(t.path," \xb7 ").concat(e("wb.previewHint")):t.path,children:["diff"===t.kind?(0,s.jsx)("span",{className:"wb-ico","aria-hidden":"true",children:"\xb1"}):(0,s.jsx)(Y,{path:t.path}),(0,s.jsx)("span",{className:"wb-tab-label",children:r}),"file"===t.kind&&R.has(t.path)&&(0,s.jsx)("span",{className:"wb-unsaved",title:e("ed.unsaved"),"aria-label":e("ed.unsaved"),children:"●"})]}),(0,s.jsx)("button",{type:"button",className:"wb-tab-close","aria-label":e("wb.closeTab",{name:r}),onClick:()=>void ei(i),children:"\xd7"})]},i)})]}),(0,s.jsxs)("div",{className:"wb-editor",role:"tabpanel",children:[er?"diff"===er.kind?(0,s.jsx)(eA,{area:er.area,path:er.path,commit:er.commit},t5(er)):null:(0,s.jsx)(al,{workspace:S,problem:p}),$&&n.map(e=>"file"===e.kind?(0,s.jsx)("div",{className:"wb-file-pane",hidden:t5(e)!==o,children:(0,s.jsx)(eF,{dir:$,path:e.path,onDirty:P,goTo:(null==ee?void 0:ee.path)===e.path?ee:void 0,onOpenFile:e=>Z({kind:"file",path:e})})},"".concat($,"|").concat(t5(e))):null)]}),E.bottomOpen&&(0,s.jsx)(aa,{axis:"y",label:e("wb.resize"),onDrag:e=>eu({bottom:ae(E.bottom-e,90,700)})}),(0,s.jsx)(tA,{open:E.bottomOpen,onToggle:()=>eu({bottomOpen:!E.bottomOpen}),tab:O,onTab:e=>{q(e),eu({bottomOpen:!0})},session:ec,task:eo,newChat:"new"===F,onShowMessage:e=>{eu({chatOpen:!0}),window.setTimeout(()=>{var t;return null==(t=document.getElementById("cs-turn-".concat(e)))?void 0:t.scrollIntoView({block:"start",behavior:"smooth"})},50)}})]},"center"),chat:(0,s.jsx)("aside",{className:"wb-chat".concat(eO("chat")),"aria-label":e("wb.chatPanel"),hidden:!E.chatOpen,...eM("chat"),children:(0,s.jsx)(tz,{workspace:S,composeAsk:D,showThread:A,onOpenFile:e=>Z({kind:"file",path:e}),onOpenFolder:()=>void V(),onTurn:M,onChange:()=>void B(),onClose:()=>eu({chatOpen:!1}),grip:eC("chat",e("wb.chatPanel"))})},"chat")};return(0,s.jsxs)("div",{className:"wb",style:eq,children:[(0,s.jsxs)("header",{className:"wb-top",children:[(0,s.jsxs)("span",{className:"wb-brand",children:[(0,s.jsx)(tJ.g,{}),"copilot-operator"]}),(0,s.jsxs)("button",{type:"button",className:"wb-search",onClick:()=>z(!0),title:e("wb.paletteWhy"),children:[(0,s.jsx)("span",{children:e("wb.palette")}),(0,s.jsx)("kbd",{children:"Ctrl+K"})]}),(0,s.jsxs)("nav",{className:"wb-menu","aria-label":e("nav.label"),children:[(0,s.jsx)(i(),{href:"/queue",children:e("nav.queue")}),(0,s.jsx)(i(),{href:"/settings",children:e("nav.defaults")}),(0,s.jsx)(i(),{href:"/system",children:e("nav.system")}),(0,s.jsx)(y.i,{})]})]}),(0,s.jsxs)("div",{className:"wb-body".concat(E.sideOpen?"":" no-side").concat(E.chatOpen?"":" no-chat"),children:[(0,s.jsx)(at,{side:u,sideOpen:E.sideOpen,onSide:e=>{e===u&&E.sideOpen?eu({sideOpen:!1}):(h(e),eu({sideOpen:!0}))},chatOpen:E.chatOpen,onChat:()=>eu({chatOpen:!E.chatOpen}),workspace:S}),E.order.map(t=>{let a=ek.indexOf(t),n=a>0?ek[a-1]:null;return(0,s.jsxs)(l.Fragment,{children:[n&&(0,s.jsx)(aa,{axis:"x",label:e("wb.resize"),onDrag:e=>{0===ew(n)?eu({side:ae(E.side+e,180,820)}):2===ew(t)&&eu({chat:ae(E.chat-e,260,820)})}}),eE[t]]},t)})]}),(0,s.jsx)(t$,{sessions:null!=t?t:[],session:ec,workspace:S,onShowThread:e=>{eu({chatOpen:!0}),H(t=>{var a;return{id:e,n:(null!=(a=null==t?void 0:t.n)?a:0)+1}})},onApprovals:e=>{let a=e.filter(e=>{var a;return!ep.current.has(e.id)&&(null==(a=e.kerrigan)?void 0:a.state)!=="thinking"&&!!(null==t?void 0:t.some(t=>t.id===e.sessionId))});for(let e of a)ep.current.add(e.id);a[0]&&ef(a[0])},onShowWaiting:ef}),I&&(0,s.jsx)(tK,{commands:ex,onClose:()=>z(!1)}),Q&&(0,s.jsx)(tX,{recent:n.filter(e=>"file"===e.kind).map(e=>e.path).reverse(),onOpen:(e,t)=>t?el({path:e,line:t}):Z({kind:"file",path:e,preview:!0}),onClose:()=>X(!1)})]})}let ae=(e,t,a)=>Math.max(t,Math.min(a,e));function at(e){var t,a;let{side:n,sideOpen:i,onSide:c,chatOpen:o,onChat:d,workspace:u}=e,{t:p}=(0,k.kj)(),f=(e,t,a,l)=>(0,s.jsxs)("button",{type:"button",className:"wb-act".concat(i&&n===e?" on":""),"aria-pressed":i&&n===e,"aria-label":t,"aria-describedby":(null==l?void 0:l.said)?"wb-act-".concat(e,"-said"):void 0,title:(null==l?void 0:l.said)?"".concat(t," \xb7 ").concat(l.said):t,onClick:()=>c(e),children:[(0,s.jsx)("svg",{viewBox:"0 0 24 24",width:"22",height:"22",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:a}),null==l?void 0:l.badges,(null==l?void 0:l.said)&&(0,s.jsx)("span",{id:"wb-act-".concat(e,"-said"),className:"sr-only",children:l.said})]}),x=!!(null==u?void 0:u.ok),[b]=h(x?u.dir:""),[g,v]=(0,l.useState)(null),j=(0,l.useCallback)(()=>r.FH.workspaceGitCounts(b||void 0).then(v).catch(()=>v(null)),[b]);(0,l.useEffect)(()=>{v(null),x&&j()},[j,x,null==u?void 0:u.dir]),(0,m.z)(j,5e3,x);let w=(null==g?void 0:g.isRepo)?g.uncommitted:0,y=(null==g?void 0:g.isRepo)&&null!=(t=g.branch)?t:0,N=p("git.badgeUncommitted",{n:w}),S=p("git.badgeBranch",{n:y,base:null!=(a=null==g?void 0:g.base)?a:""}),C=[...w>0?[N]:[],...y>0?[S]:[]].join(" \xb7 "),F=e=>e>99?"99+":String(e),M=(0,s.jsxs)(s.Fragment,{children:[w>0&&(0,s.jsx)("span",{className:"wb-act-badge uncommitted","aria-hidden":"true",children:F(w)}),y>0&&(0,s.jsx)("span",{className:"wb-act-badge branch","aria-hidden":"true",children:F(y)})]});return(0,s.jsxs)("nav",{className:"wb-activity","aria-label":p("wb.views"),children:[f("files",p("wb.viewFiles"),(0,s.jsx)("path",{d:"M4 4h6l2 2h8v14H4z"})),f("search",p("wb.search"),(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("circle",{cx:"10.5",cy:"10.5",r:"6"}),(0,s.jsx)("path",{d:"M15 15l5 5"})]})),f("commits",p("wb.viewCommits"),(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("circle",{cx:"12",cy:"12",r:"3"}),(0,s.jsx)("path",{d:"M12 3v6M12 15v6"})]}),{said:C,badges:M}),(0,s.jsx)("span",{className:"grow"}),(0,s.jsx)("button",{type:"button",className:"wb-act".concat(o?" on":""),"aria-pressed":o,"aria-label":p("wb.toggleChat"),title:"".concat(p("wb.toggleChat")," (Ctrl+L)"),onClick:d,children:(0,s.jsx)("svg",{viewBox:"0 0 24 24",width:"22",height:"22",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinejoin:"round","aria-hidden":"true",children:(0,s.jsx)("path",{d:"M4 5h16v11H9l-5 4z"})})})]})}function aa(e){let{axis:t,label:a,onDrag:n}=e,i=(0,l.useRef)(null);return(0,s.jsx)("div",{className:"wb-split ".concat(t),role:"separator","aria-orientation":"x"===t?"vertical":"horizontal","aria-label":a,tabIndex:0,onPointerDown:e=>{i.current="x"===t?e.clientX:e.clientY,e.target.setPointerCapture(e.pointerId)},onPointerMove:e=>{if(null===i.current)return;let a="x"===t?e.clientX:e.clientY;n(a-i.current),i.current=a},onPointerUp:()=>i.current=null,onKeyDown:e=>{let a=e.shiftKey?40:12;("x"===t&&"ArrowLeft"===e.key||"y"===t&&"ArrowUp"===e.key)&&n(-a),("x"===t&&"ArrowRight"===e.key||"y"===t&&"ArrowDown"===e.key)&&n(a)}})}function as(e){var t;let{status:a}=e,{t:l}=(0,k.kj)();return(0,s.jsx)("span",{className:"wb-status s-".concat(a),title:l("status.".concat(a)),"aria-label":l("status.".concat(a)),role:"img",children:null!=(t=({done:"✓",failed:"✗",blocked:"⊘","limit-reached":"⏸",aborted:"■",queued:"○",running:"●","waiting-approval":"◐"})[a])?t:"\xb7"})}function al(e){let{workspace:t,problem:a}=e,{t:l}=(0,k.kj)();return(0,s.jsxs)("div",{className:"wb-welcome",children:[(0,s.jsx)("h2",{children:(null==t?void 0:t.ok)?t.name:l("wb.welcome")}),(0,s.jsx)("p",{className:"muted",children:(null==t?void 0:t.ok)?l("wb.welcomeChat",{dir:t.dir}):l("wb.welcomeWhy")}),a&&(0,s.jsx)("p",{className:"err small",children:a}),(0,s.jsx)(tZ,{workspace:t}),(0,s.jsx)(tV,{}),(0,s.jsx)("p",{className:"muted small",children:l("wb.keys")})]})}function an(){return(0,s.jsx)(t7,{})}},92364:(e,t,a)=>{Promise.resolve().then(a.bind(a,60405))}},e=>{e.O(0,[8197,7921,895,8124,1024,2347,3131,7358],()=>e(e.s=92364)),_N_E=e.O()}]);