copilot-operator 0.1.92 → 0.1.94
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.
- package/README.md +640 -625
- package/dist/src/api/operator.controller.js +26 -0
- package/dist/src/api/operator.service.js +117 -25
- package/dist/src/exec/readOnly.js +27 -2
- package/dist/src/orchestrator/kerriganRunner.js +9 -2
- package/dist/src/orchestrator/taskRunner.js +14 -3
- package/dist/src/plan/kerrigan.js +263 -243
- package/dist/src/plan/systemGuide.js +125 -85
- package/dist/src/session/chatbotFile.js +117 -0
- package/dist/src/session/compose.js +13 -0
- package/dist/src/session/locatorFailures.js +8 -5
- package/dist/src/transport/copilotTransport.js +94 -12
- package/dist/src/transport/locators.js +53 -0
- package/dist/src/transport/pageHtml.js +36 -2
- package/dist/src/vcs/newBranch.js +46 -0
- package/dist/web/404.html +2 -2
- package/dist/web/_next/static/chunks/1077.b7df9cb8ca810075.js +1 -0
- package/dist/web/_next/static/chunks/1548.417c17b63c371f00.js +1 -0
- package/dist/web/_next/static/chunks/2163.469367b8fbcc862d.js +1 -0
- package/dist/web/_next/static/chunks/714.72112704f3cb8127.js +1 -0
- package/dist/web/_next/static/chunks/{7220.260579c8dbfa2c30.js → 7220.8bd897c7ddfee701.js} +1 -1
- package/dist/web/_next/static/chunks/7921-25d1755799107ea7.js +1 -0
- package/dist/web/_next/static/chunks/8584.f87df7324303ab75.js +1 -0
- package/dist/web/_next/static/chunks/9067.67a7c7cf3b019b5c.js +1 -0
- package/dist/web/_next/static/chunks/9747.a87dbd4acd45e39d.js +1 -0
- package/dist/web/_next/static/chunks/app/layout-1b7d13f7b2efd008.js +1 -0
- package/dist/web/_next/static/chunks/app/{page-b71841852e6b9ff5.js → page-7eae1e8848525e1d.js} +1 -1
- package/dist/web/_next/static/chunks/app/settings/page-c92548f9c6318962.js +1 -0
- package/dist/web/_next/static/chunks/{webpack-abd1f09115b96456.js → webpack-91b2de9c3da6f8b9.js} +1 -1
- package/dist/web/_next/static/css/{6b92f118889ca88b.css → 523d11041085f836.css} +1 -1
- package/dist/web/defaults.html +2 -2
- package/dist/web/defaults.txt +8 -8
- package/dist/web/index.html +3 -3
- package/dist/web/index.txt +9 -9
- package/dist/web/queue.html +2 -2
- package/dist/web/queue.txt +9 -9
- package/dist/web/settings.html +2 -2
- package/dist/web/settings.txt +9 -9
- package/dist/web/system.html +2 -2
- package/dist/web/system.txt +9 -9
- package/package.json +2 -1
- package/dist/web/_next/static/chunks/1077.922b5f1492f6e0dd.js +0 -1
- package/dist/web/_next/static/chunks/1548.4a09f12e23d369ec.js +0 -1
- package/dist/web/_next/static/chunks/2163.14e7879a45ae9748.js +0 -1
- package/dist/web/_next/static/chunks/714.2daeede6dd07ee60.js +0 -1
- package/dist/web/_next/static/chunks/7921-1de1f08d23145c0d.js +0 -1
- package/dist/web/_next/static/chunks/8584.01e3a7f9f14f0b4f.js +0 -1
- package/dist/web/_next/static/chunks/9067.75d4fdcf47f62fd1.js +0 -1
- package/dist/web/_next/static/chunks/9747.f1bdfbefaba61f8b.js +0 -1
- package/dist/web/_next/static/chunks/app/layout-f5681fae8247797b.js +0 -1
- package/dist/web/_next/static/chunks/app/settings/page-7d343eecdd9c7500.js +0 -1
- /package/dist/web/_next/static/{n7rfXOWgaCFmATod4Q6hp → UNygvDtRnBVZrGJt53IE4}/_buildManifest.js +0 -0
- /package/dist/web/_next/static/{n7rfXOWgaCFmATod4Q6hp → UNygvDtRnBVZrGJt53IE4}/_ssgManifest.js +0 -0
package/dist/web/_next/static/chunks/app/{page-b71841852e6b9ff5.js → page-7eae1e8848525e1d.js}
RENAMED
|
@@ -1 +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"})]})}},55522:(e,t,a)=>{"use strict";a.r(t),a.d(t,{default:()=>t8});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),p=a(8205),x=a(16752);let f=[{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"}],b={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"},g={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 v(e){var t;let a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",s=e.split("/").pop().toLowerCase();if(g[s])return g[s];if(s.startsWith(".env."))return"ini";if(s.startsWith("dockerfile."))return"dockerfile";let l=s.lastIndexOf(".");if(l>0&&b[s.slice(l+1)])return b[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 j=e=>e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">"),w=(e,t)=>'<span class="hl-'.concat(e,'">').concat(j(t),"</span>"),k=e=>new Set(e.split(/\s+/).filter(Boolean)),y=k("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"),N=new Set([...y,...k("interface type enum implements namespace module declare abstract private protected public readonly keyof infer is asserts override accessor unique")]),C=k("string number boolean bigint symbol object unknown any never void undefined Record Partial Required Readonly Pick Omit Promise Array Map Set Date Error RegExp"),S=k("true false null undefined NaN Infinity"),F={typescript:{line:["//"],block:[["/*","*/"]],quotes:['"',"'","`"],multiline:["`"],keywords:N,types:C,literals:S,calls:!0,sigil:/^@[A-Za-z_]\w*/},javascript:{line:["//"],block:[["/*","*/"]],quotes:['"',"'","`"],multiline:["`"],keywords:y,literals:S,calls:!0},csharp:{line:["//"],block:[["/*","*/"]],quotes:['"',"'"],calls:!0,literals:k("true false null"),keywords:k("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:k("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:k("true false null"),keywords:k("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:k("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:k("true false null"),keywords:k("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:k("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:k("true false nil iota"),keywords:k("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:k("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:k("true false None Some Ok Err"),keywords:k("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:k("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:k("true false NULL"),keywords:k("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:k("char double float int long short signed unsigned void size_t bool"),sigil:/^#\s*\w+/},cpp:{line:["//"],block:[["/*","*/"]],quotes:['"',"'"],calls:!0,literals:k("true false nullptr NULL"),keywords:k("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:k("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:k("true false nil"),keywords:k("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:k("Int Double Float Bool String Character Array Dictionary Set Optional Void"),sigil:/^@[A-Za-z_]\w*/},dart:{line:["//"],block:[["/*","*/"]],quotes:['"',"'"],calls:!0,literals:k("true false null"),keywords:k("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:k("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:k("true false null"),keywords:k("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:k("true false nil"),keywords:k("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:k("$true $false $null"),keywords:k("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:k("True False None"),keywords:k("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:k("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:k("true false nil"),keywords:k("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:k("true false"),keywords:k("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:k("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:k("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:k("ifeq ifneq ifdef ifndef else endif include define endef export override .PHONY"),sigil:/^\$(?:\([^)]*\)|\{[^}]*\}|[@<^*?%])/},sql:{line:["--"],block:[["/*","*/"]],quotes:["'",'"'],caseless:!0,calls:!0,literals:k("true false null"),keywords:k("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:k("int integer bigint smallint decimal numeric float real double varchar char text date time timestamp boolean bool uuid json jsonb blob")}};function M(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],x=null==(r=t.block)?void 0:r.find(e=>{let[t]=e;return n(t)});if(x){let t=e.indexOf(x[1],s+x[0].length),n=t<0?l:t+x[1].length;a+=w("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+=w("com",e.slice(s,n)),s=n;continue}let f=i.find(t=>e.startsWith(t,s));if(f){let n=s+f.length,i=null==(o=t.multiline)?void 0:o.includes(f),r=t!==F.powershell&&t!==F.batch&&(t!==F.shell&&t!==F.sql||"'"!==f);for(;n<l;){if("\\"===e[n]&&r){n+=2;continue}if(e.startsWith(f,n)){n+=f.length;break}if("\n"===e[n]&&!i)break;n+=1}a+=w("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+=w("@"===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+=w("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!==F.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+=w(r,n):t.calls&&"("===e[s+n.length]?a+=w("fn",n):/^[A-Z][a-z]\w*$/.test(n)&&t.types?a+=w("type",n):t===F.powershell&&/^[A-Z][a-z]+-[A-Z]\w*$/.test(n)?a+=w("fn",n):a+=j(n),s+=n.length;continue}}a+=j(p),s+=1}return a}function O(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+=w("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+=w("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+=w(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+=j(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+=w("str",e.slice(s,n)),s=n;continue}let n=/^[^\s=>/"']+/.exec(e.slice(s,s+100));if(n){a+=w("attr",n[0]),s+=n[0].length;continue}a+=j(e[s]),s+=1}s<l&&(a+=w("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?M(c,F.javascript):q(c,!1),s=i}continue}if("&"===e[s]){let t=/^&[#\w]+;/.exec(e.slice(s,s+12));if(t){a+=w("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+=j(e.slice(s,c)),s=c}return a}function q(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+=w("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+=w("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+=w("str",e.slice(s,t+1)),s=t+1;continue}if("@"===c){let t=/^@[\w-]+/.exec(e.slice(s,s+40));if(t){a+=w("kw",t[0]),s+=t[0].length;continue}}if("$"===c&&t){let t=/^\$[\w-]+/.exec(e.slice(s,s+60));if(t){a+=w("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+=j(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+=w("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+=w("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))?w("prop",l):i?/^(important|inherit|initial|unset|none|auto)$/.test(l)?w("lit",l):"("===e[s+l.length]?w("fn",l):j(l):w("tag",l),s+=l.length;continue}}a+=j(c),s+=1}return a}let L={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"}},E={glyph:"image",color:"#a074c4"},z={glyph:"archive",color:"#a07d3e"},I={png:E,jpg:E,jpeg:E,gif:E,webp:E,ico:E,bmp:E,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:z,gz:z,"7z":z,tgz:z,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"}},D={glyph:"git",color:"#f14e32"},W={".gitignore":D,".gitattributes":D,".gitmodules":D,"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(L),...Object.values(I),...Object.values(W)].filter(e=>!!e);let H=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))},R=e=>{let[t,a,s]=e;return"#".concat([t,a,s].map(e=>Math.round(e).toString(16).padStart(2,"0")).join(""))};function A(e){let[t,a,s]=H(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 T=new Map;function P(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 B=e=>({"--ico":e.color,"--ico-dark":function(e){let t=T.get(e);if(t)return t;let a=H(e),s=R(a);for(let e=.12;e<=1&&!(function(e,t){let[a,s]=[A(e),A(t)].sort((e,t)=>t-e);return(a+.05)/(s+.05)}(s=R(a.map(t=>t+(255-t)*e)),"#152436")>=4.8);e+=.04);return T.set(e,s),s}(e.color)});function _(e){var t;let{path:a}=e,l=function(e){var t;let a=e.split("/").pop().toLowerCase();if(W[a])return W[a];let s=a.lastIndexOf("."),l=s>0?a.slice(s+1):"";return I[l]?I[l]:null!=(t=L[v(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:B(l),children:(0,s.jsx)(P,{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:B(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 $={staged:"git.uncommitted.staged",changes:"git.uncommitted.changes",untracked:"git.uncommitted.untracked",mixed:"git.uncommitted.mixed"};function U(e){var t,a,n;let{data:i,onBase:r,onOpenFile:c,statusName:o}=e,{t:d}=(0,p.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,x=m.filter(e=>e.uncommitted),f=m.filter(e=>e.committed),b="committed"===u?f:"uncommitted"===u?x:m,g=m.reduce((e,t)=>e+Math.max(0,t.added),0),v=m.reduce((e,t)=>e+Math.max(0,t.removed),0),j=(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:["+",g]})," ",(0,s.jsxs)("span",{className:"minus",children:["−",v]})]})]})]}),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:[j("all",d("git.filterAll",{n:m.length})),j("committed",d("git.filterCommitted",{n:f.length})),j("uncommitted",d("git.filterUncommitted",{n:x.length}))]}),x.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===b.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:b.map(e=>(0,s.jsx)(K,{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 K(e){let{f:t,onOpen:a,statusName:l}=e,{t:n}=(0,p.kj)(),i=t.path.lastIndexOf("/"),r=t.uncommitted?n($[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)(_,{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 V=a(24872);let Z=e=>"cop.git.message:".concat(e.toLowerCase()),J="cop.git.opSeen",G=e=>{try{var t;return null!=(t=localStorage.getItem(e))?t:""}catch(e){return""}},Y=(e,t)=>{try{t?localStorage.setItem(e,t):localStorage.removeItem(e)}catch(e){}};function X(e){var t;let{state:a,onChanged:n,onOpen:i}=e,{t:c}=(0,p.kj)(),[o,d]=(0,l.useState)(""),[u,h]=(0,l.useState)(null),[x,f]=(0,l.useState)(""),[b,g]=(0,l.useState)(!1),v=(0,l.useRef)(""),j=(0,l.useRef)(n);j.current=n;let w=a.dir;(0,l.useEffect)(()=>{d(G(Z(w)))},[w]);let k=(0,l.useCallback)(e=>{d(e),Y(Z(w),e)},[w]),y=(0,l.useCallback)(()=>r.FH.gitOp().then(e=>{let{op:t}=e;if(!t||t.id===G(J))return h(null);h(t),"running"!==t.state&&v.current!==t.id&&(v.current=t.id,j.current(),"commit"===t.kind&&"done"===t.state&&void 0!==t.message&&G(Z(w)).trim()===t.message.trim()&&k(""))}).catch(()=>void 0),[w,k]);(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"||b,C=a.staged.length,S=a.changes.length,F=0===C,M=F?S:C,O=a.upstream,q=!!a.branch&&"HEAD"!==a.branch,L=e=>{f(""),g(!0),e().then(e=>{Y(J,""),h(e)}).catch(e=>f(e.message)).finally(()=>g(!1))},E=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 L(()=>r.FH.gitCommit(t,a,e))},z=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return L(()=>r.FH.gitPush(e))},I=(e,t)=>{var a,s;return"commit"===e.kind?E(t,null!=(a=e.message)?a:o,null!=(s=e.all)?s:F):z(t)},D=o.trim()?0===M?c("git.nothingToCommit"):F?c("git.commitAllWhy",{n:S}):c("git.commitWhy",{n:C}):c("git.commitNeedsMessage"),W=null!=(t=null==O?void 0:O.name)?t:"",H=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=>k(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.ctrlKey||e.metaKey)&&o.trim()&&M>0&&!N&&(e.preventDefault(),E())},disabled:N}),(0,s.jsxs)("div",{className:"wb-git-buttons",children:[(0,s.jsxs)("button",{type:"button",className:"primary",onClick:()=>E(),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:()=>z(),disabled:N,title:H,children:O?c("git.push",{n:O.ahead}):c("git.publish")})]}),x&&(0,s.jsx)("p",{className:"err small",role:"alert",children:x}),u&&(0,s.jsx)(Q,{op:u,onAgain:I,onDismiss:()=>{u&&Y(J,u.id),h(null)},onOpen:i,onIdentity:e=>I(e,{})})]})}function Q(e){var t,a,l;let{op:n,onAgain:i,onDismiss:r,onOpen:c,onIdentity:o}=e,{t:d}=(0,p.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)(ee,{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)(V.i8,{text:n.output,what:"git.op.copy"})]})]})}function ee(e){let{onSaved:t}=e,{t:a}=(0,p.kj)(),[n,i]=(0,l.useState)(""),[c,o]=(0,l.useState)(""),[d,u]=(0,l.useState)(!0),[h,m]=(0,l.useState)(""),[x,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:x||!n.trim()||!c.trim(),children:a("git.identity.save")})]})}var et=a(11272);function ea(e){let{view:t,onOpen:a,reveal:l,workspace:n,onOpenFolder:i,grip:r}=e;return"commits"===t?(0,s.jsx)(ei,{workspace:n,onOpen:a,onOpenFolder:i,grip:r}):(0,s.jsx)(en,{workspace:n,onOpen:a,reveal:l,onOpenFolder:i,grip:r})}function es(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 el=(e,t)=>e.localeCompare(t,void 0,{sensitivity:"base"});function en(e){let{workspace:t,onOpen:a,reveal:n,onOpenFolder:i,grip:c}=e,{t:o}=(0,p.kj)(),[d,u]=(0,l.useState)(null),[h,x]=(0,l.useState)(""),[f,b]=(0,l.useState)(new Set),[g,v]=(0,l.useState)(""),[j,w]=(0,l.useState)(""),k=()=>(null==t?void 0:t.ok)?r.FH.workspaceFiles().then(e=>{u(e.files),x("")}).catch(e=>x(e.message)):Promise.resolve();(0,l.useEffect)(()=>{u(null),k()},[null==t?void 0:t.dir,null==t?void 0:t.ok]),(0,m.z)(k,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)){v(""),w(n.path);return}w(""),v(n.path);let e=n.path.split("/");b(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 C=(e,t)=>(0,s.jsxs)(s.Fragment,{children:[[...e.dirs.keys()].sort(el).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:()=>b(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:C(e.dirs.get(a),l)})]},"d:".concat(l))}),[...e.files].sort((e,t)=>el(e.split("/").pop(),t.split("/").pop())).map(e=>(0,s.jsx)("li",{role:"treeitem","aria-selected":g===e,children:(0,s.jsxs)("button",{type:"button",className:"wb-row file".concat(g===e?" sel":""),"data-path":e,onClick:()=>{v(e),w(""),a({kind:"file",path:e,preview:!0})},onDoubleClick:()=>a({kind:"file",path:e}),title:e,children:[(0,s.jsx)(_,{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)(es,{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 k(),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:[j&&(0,s.jsx)("p",{className:"muted small wb-pad",role:"status",children:o("wb.revealGone",{name:j})}),(0,s.jsx)("p",{className:"muted small wb-pad",title:t.dir,children:t.branch?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(et.O,{})," ",t.branch]}):t.dir}),(0,s.jsx)("ul",{className:"wb-tree-list",role:"tree","aria-label":o("wb.files"),children:C(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 ei(e){var t,a;let{workspace:n,onOpen:i,onOpenFolder:c,grip:o}=e,{t:d}=(0,p.kj)(),u=(0,p.W3)(),[x,f]=(0,l.useState)(null),[b,g]=(0,l.useState)(""),[v,j]=(0,l.useState)(new Set),[w,k]=(0,l.useState)(""),[y,N]=(0,l.useState)(new Map),[C,S]=(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),S(a),g("")}).catch(e=>g(e.message)),[F]);(0,l.useEffect)(()=>{f(null),S(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)),[L,E]=(0,l.useState)(!1),[z,I]=(0,l.useState)(""),D=(e,t)=>{E(!0),I(""),r.FH.gitStage(e,t).then(f).catch(e=>I(e.message)).finally(()=>E(!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)(_,{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:L,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))},H=(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":!v.has(e),onClick:()=>j(t=>new Set(t.has(e)?[...t].filter(t=>t!==e):[...t,e])),children:[(0,s.jsx)("span",{"aria-hidden":"true",children:v.has(e)?"▸":"▾"})," ",t,null!==a&&(0,s.jsx)("span",{className:"wb-badge",children:a})]}),n]}),!v.has(e)&&l]}),R=e=>(0,s.jsx)("button",{type:"button",className:"wb-icon-btn wb-git-stage",onClick:()=>D(e,"all"),disabled:L,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)(es,{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)?b?(0,s.jsx)("p",{className:"err small wb-pad",children:b}):x?x.isRepo?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("p",{className:"small wb-pad wb-git-branch",children:[(0,s.jsx)(et.O,{})," ",(0,s.jsx)("strong",{children:null!=(a=x.branch)?a:"HEAD"}),x.upstream&&(0,s.jsxs)("span",{className:"muted",children:[" \xb7 ",d("git.upstream",{name:x.upstream.name,ahead:x.upstream.ahead,behind:x.upstream.behind})]})]}),(0,s.jsx)(X,{state:x,onChanged:()=>void O(),onOpen:i}),z&&(0,s.jsx)("p",{className:"err small wb-pad",role:"alert",children:z}),C&&H("branch",d("git.branch"),C.problem?null:C.files.length,(0,s.jsx)(U,{data:C,onBase:M,statusName:q,onOpenFile:(e,t)=>i({kind:"diff",area:"branch",path:e,...C.base?{commit:C.base}:{},...t?{}:{preview:!0}})})),x.staged.length>0&&H("staged",d("git.staged"),x.staged.length,(0,s.jsx)("ul",{className:"wb-git-files",children:x.staged.map(e=>W(e,"staged"))}),R("unstage")),H("changes",d("git.changes"),x.changes.length,0===x.changes.length?(0,s.jsx)("p",{className:"muted small wb-pad",children:d("git.noChanges")}):(0,s.jsx)("ul",{className:"wb-git-files",children:x.changes.map(e=>W(e,"changes"))}),x.changes.length>0?R("stage"):void 0),H("commits",d("git.commits"),null,0===x.commits.length?(0,s.jsx)("p",{className:"muted small wb-pad",children:d("git.noCommits")}):(0,s.jsx)("ul",{className:"wb-commits",children:x.commits.map((e,t)=>{var a;let l=y.get(e.sha),n=!!(null==C?void 0:C.mergeBase)&&C.commits.includes(e.sha),i=!!(null==C?void 0:C.mergeBase)&&e.sha===C.mergeBase&&t>0&&C.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=C.base)?a:"",sha:e.short})}),(0,s.jsxs)("button",{type:"button",className:"wb-row","aria-expanded":w===e.sha,onClick:()=>(e=>{if(w===e)return void k("");k(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:w===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)]}),w===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)})})),x.moreCommits&&(0,s.jsx)("p",{className:"muted small wb-pad",children:d("git.more",{n:x.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 er=/^(\s{0,3})(`{3,}|~{3,})\s*([^\s`]*)?.*$/,ec=/^(\s*)([-*+]|\d{1,9}[.)])\s+(.*)$/;function eo(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 ed(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=eo(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],ed(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:ed(e[2],t,c())},c())],[RegExp("^(\\*|_)(?=\\S)([\\s\\S]*?\\S)\\1(?![\\p{L}\\p{N}])","u"),e=>(0,s.jsx)("em",{children:ed(e[2],t,c())},c())],[/^~~(?=\S)([\s\S]*?\S)~~/,e=>(0,s.jsx)("del",{children:ed(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=eo(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 eu(e){let{code:t}=e,{t:n}=(0,p.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 eh(e){let{text:t,path:a,onOpenFile:l}=e,{t:n}=(0,p.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:ed(t.text,a,i)},i)}case"para":return(0,s.jsx)("p",{children:ed(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)(eu,{code:t.text},i);let e=null!=(c=null==(r=f.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 j(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?w("prop",t)+j(a):w("str",t):e.startsWith("//")||e.startsWith("/*")?w("com",e):s?w("lit",e):/^[&<>]$/.test(e)?j(e):w("num",e));case"html":case"vue":return O(t,!0);case"xml":return O(t,!1);case"css":return q(t,!1);case"scss":return q(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?w("com",t):a?w("str",a):s?w("lit",s):l?w("num",l):n?w("var",n):i?j(i):j(e));return/^\s*#/.test(e)?w("com",e):/^\s*---|^\s*\.\.\./.test(e)?w("meta",e):t?j(t[1])+w("prop",t[2])+j(t[3])+j(t[4])+a(t[5]):a(e)}).join("\n");case"ini":case"toml":return t.split("\n").map(e=>{if(/^\s*[#;]/.test(e))return w("com",e);let t=/^(\s*)(\[\[?[^\]]*\]\]?)(.*)$/.exec(e);if(t)return j(t[1])+w("head",t[2])+j(t[3]);let a=/^(\s*)([^=:\s][^=:]*?)(\s*[=:]\s*)(.*)$/.exec(e);if(a){let e=a[4],t=/^(".*"|'.*')$/.test(e.trim())?w("str",e):/^-?\d+(\.\d+)?$/.test(e.trim())?w("num",e):/^(true|false|yes|no|on|off)$/i.test(e.trim())?w("lit",e):j(e);return j(a[1])+w("prop",a[2])+j(a[3])+t}return j(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(w("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=b[a[3].toLowerCase()])?r:null!=(i=null==(n=f.find(e=>e.name.toLowerCase()===a[3].toLowerCase()))?void 0:n.id)?i:"plain":"plain";l={mark:a[2],lang:e,body:[]},s.push(w("code",t));continue}if(/^\s{0,3}#{1,6}\s/.test(t)){s.push(w("head",t));continue}if(/^\s*>/.test(t)){s.push(w("com",t));continue}let c=j(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=F[a];return e?M(t,e):j(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?ed(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:ed(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:ed(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=er.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 x=/^\s{0,3}(#{1,6})\s+(.*?)\s*#*\s*$/.exec(t);if(x){s.push({kind:"heading",level:x[1].length,text:x[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])&&(er.test(a[l])||ec.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 f=ec.exec(t);if(f){let t=f[1].length,i=/\d/.test(f[2]),p=[];for(;l<a.length;){let s=ec.exec(a[l]);if(!s||s[1].length!==t||/\d/.test(s[2])!==i)break;let x=[s[3]];for(l+=1;l<a.length;){let e=a[l],s=ec.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])){x.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;x.push(r>t?e.slice(Math.min(r,t+2+ +!!i)):e.trim()),l+=1}let f=/^\[([ xX])\]\s+/.exec(x[0]);for(f&&(x[0]=x[0].slice(f[0].length)),p.push({blocks:e(x.join("\n")),...f?{task:!0,done:" "!==f[1]}:{}});l<a.length&&n(a[l])&&(null==(c=ec.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(f[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])&&!er.test(a[l])&&!/^\s{0,3}(#{1,6}\s|>)/.test(a[l])&&!(b.length>0&&ec.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 em=null,ep={plain:"plaintext",batch:"bat",vue:"html",toml:"ini",makefile:"plaintext"},ex=e=>{var t;return null!=(t=ep[e])?t:e};function ef(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 eb(e){let{path:t,value:n,language:i,onChange:r,onSave:c,onToggleMarkdown:o,goTo:d,label:u,reset:h}=e,{t:m}=(0,p.kj)(),x=(0,l.useRef)(null),f=(0,l.useRef)(null),b=(0,l.useRef)(null),[g,v]=(0,l.useState)(!1),[j,w]=(0,l.useState)(""),k=(0,l.useRef)({onChange:r,onSave:c,onToggleMarkdown:o});return k.current={onChange:r,onSave:c,onToggleMarkdown:o},(0,l.useEffect)(()=>{let e=!1,s=null;return(null!=em||(em=(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})()),em).then(a=>{if(e||!x.current)return;b.current=a;let l=a.editor.createModel(n,ex(i),a.Uri.file("/workspace/".concat(t))),r=a.editor.create(x.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,ef(a,r),x.current.copEditor=r,l.onDidChangeContent(()=>k.current.onChange(l.getValue())),r.addAction({id:"cop.save",label:m("ed.save"),keybindings:[a.KeyMod.CtrlCmd|a.KeyCode.KeyS],run:()=>k.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=k.current).onToggleMarkdown)?void 0:e.call(t)}}),(s=new MutationObserver(()=>ef(a,r))).observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme","data-textsize"]}),v(!0)}).catch(e=>w(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,g]),(0,l.useEffect)(()=>{var e;let t=null==(e=f.current)?void 0:e.getModel();t&&b.current&&b.current.editor.setModelLanguage(t,ex(i))},[i,g]),(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=b.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,g]),(0,s.jsxs)("div",{className:"ed-code",children:[!g&&!j&&(0,s.jsx)("p",{className:"muted small ed-code-loading",children:m("ed.loading")}),j&&(0,s.jsx)("p",{className:"err small",children:m("ed.failed",{reason:j})}),(0,s.jsx)("div",{ref:x,className:"ed-monaco","data-ready":g?"yes":void 0})]})}let eg="cop.md.view";function ev(e){var t,a,n,i,c;let{path:o,onDirty:d,goTo:u,onOpenFile:h}=e,{t:x}=(0,p.kj)(),[b,g]=(0,l.useState)(null),[j,w]=(0,l.useState)(""),[k,y]=(0,l.useState)(""),[N,C]=(0,l.useState)(""),[S,F]=(0,l.useState)(!1),[M,O]=(0,l.useState)(!1),[q,L]=(0,l.useState)("auto"),[E,z]=(0,l.useState)(0),I=!!b&&null!==b.text&&j!==b.text;(0,l.useEffect)(()=>null==d?void 0:d(o,I),[o,I,d]);let D=(0,l.useCallback)(async()=>{try{var e;let t=await r.FH.workspaceFile(o);g(t),w(null!=(e=t.text)?e:""),z(e=>e+1),O(!1),y("")}catch(e){y(e.message)}},[o]);(0,l.useEffect)(()=>{g(null),C(""),O(!1),D()},[D]),(0,m.z)(async()=>{if(!(null==b?void 0:b.version)||S)return;let e=await r.FH.workspaceFile(o).catch(()=>null);if((null==e?void 0:e.version)&&e.version!==b.version)if(I)O(!0);else{var t;g(e),w(null!=(t=e.text)?t:""),z(e=>e+1)}},4e3,!!b);let W="auto"===q?v(o,null!=(t=null==b?void 0:b.text)?t:""):q,H="markdown"===v(o,""),[R,A]=(0,l.useState)("preview");(0,l.useEffect)(()=>{try{let e=window.localStorage.getItem(eg);("code"===e||"split"===e||"preview"===e)&&A(e)}catch(e){}},[]);let T=e=>{A(e);try{window.localStorage.setItem(eg,e)}catch(e){}},P=H?R:"code",B=async function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(b&&!S){F(!0),C("");try{let t=await r.FH.saveWorkspaceFile(o,j,e?void 0:b.version);g({...b,text:j,version:t.version,size:t.size}),O(!1),C(x("ed.saved"))}catch(e){409===e.status?O(!0):C(e.message)}finally{F(!1)}}};return((0,l.useEffect)(()=>{u&&H&&"preview"===R&&A("split")},[null==u?void 0:u.n]),k&&!b)?(0,s.jsx)("p",{className:"err small",children:k}):b?b.binary||b.tooLarge?(0,s.jsxs)("div",{className:"wb-file",children:[(0,s.jsx)("p",{className:"muted small",children:x("wb.fileOnDisk",{path:b.path})}),(0,s.jsx)("p",{className:"muted",children:b.binary?x("wb.binary"):x("wb.tooLarge")})]}):(0,s.jsxs)("div",{className:"ed",children:[(0,s.jsxs)("div",{className:"ed-bar",children:[(0,s.jsx)(_,{path:o}),(0,s.jsx)("span",{className:"ed-path",title:b.path,children:b.path}),(0,s.jsx)("span",{className:"small ".concat(I?"ed-dirty":"muted"),role:"status",children:I?x("ed.unsaved"):N||x("ed.clean")}),(0,s.jsx)("span",{className:"grow"}),H&&(0,s.jsx)("span",{className:"segmented ed-md-view",role:"group","aria-label":x("ed.view"),title:x("ed.viewWhy"),children:["code","split","preview"].map(e=>(0,s.jsx)("button",{type:"button","aria-pressed":R===e,onClick:()=>T(e),children:x("code"===e?"ed.viewCode":"split"===e?"ed.viewSplit":"ed.viewPreview")},e))}),(0,s.jsx)("label",{htmlFor:"ed-lang-".concat(o),className:"sr-only",children:x("ed.language")}),(0,s.jsxs)("select",{id:"ed-lang-".concat(o),className:"ed-lang",value:q,onChange:e=>L(e.target.value),title:x("ed.language"),children:[(0,s.jsx)("option",{value:"auto",children:x("ed.langAuto",{name:(n=v(o,null!=(a=b.text)?a:""),null!=(c=null==(i=f.find(e=>e.id===n))?void 0:i.name)?c:n)})}),f.map(e=>(0,s.jsx)("option",{value:e.id,children:e.name},e.id))]}),(0,s.jsx)("button",{type:"button",className:"quiet small",disabled:!I||S,onClick:()=>{var e;w(null!=(e=b.text)?e:""),z(e=>e+1),C("")},children:x("ed.revert")}),(0,s.jsx)("button",{type:"button",className:"primary small",disabled:!I||S,onClick:()=>void B(),title:"Ctrl+S",children:x("ed.save")})]}),M&&(0,s.jsxs)("div",{className:"notice caution small ed-conflict",role:"alert",children:[(0,s.jsx)("span",{children:x("ed.changedOnDisk")}),(0,s.jsx)("button",{type:"button",className:"small",onClick:()=>void D(),children:x("ed.reload")}),(0,s.jsx)("button",{type:"button",className:"small danger",onClick:()=>void B(!0),children:x("ed.saveOver")})]}),(0,s.jsxs)("div",{className:"ed-body ed-show-".concat(P),children:["code"!==P&&(0,s.jsx)("div",{className:"ed-preview",children:(0,s.jsx)(eh,{text:j,path:o,onOpenFile:e=>null==h?void 0:h(e)})}),"preview"!==P&&(0,s.jsx)(eb,{path:o,value:j,language:W,onChange:w,onSave:()=>void B(),onToggleMarkdown:H?()=>T("code"===R?"preview":"code"):void 0,goTo:u,label:x("ed.label",{path:b.path}),reset:E})]})]}):(0,s.jsx)("p",{className:"muted small",children:x("wb.loading")})}function ej(e){if(null===e||""===e)return[];let t=e.split(/\r?\n/);return""===t[t.length-1]&&t.pop(),t}function ew(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 ek(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 ey=a(94969);function eN(e){let{sessionId:t,taskId:a,runId:n,title:i,files:r}=e,{t:c}=(0,p.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)(eC,{sessionId:t,taskId:a,runId:n,title:i,onClose:()=>d(!1)})]})}function eC(e){var t,a,n,i,c,o,d;let{sessionId:u,taskId:h,runId:m,title:x,onClose:f}=e,{t:b}=(0,p.kj)(),[g,v]=(0,l.useState)(null),[j,w]=(0,l.useState)(""),[k,y]=(0,l.useState)(0),[N,C]=(0,l.useState)(new Map),[S,F]=(0,l.useState)(!1),[M,O]=(0,l.useState)(!0),[q,L]=(0,l.useState)(new Map),[E,z]=(0,l.useState)(-1),I=(0,l.useRef)(null),D=(0,l.useRef)(null),W=(0,l.useRef)(null);(0,ey.V)(D,!0,W),(0,l.useEffect)(()=>{r.FH.taskChanges(u,h,m).then(v).catch(e=>w(e.message))},[u,h,m]);let H=null!=(n=null==g?void 0:g.files)?n:[],R=H[k];(0,l.useEffect)(()=>{!R||N.has(R.path)||r.FH.taskChangeFile(u,h,R.path,m).then(e=>C(t=>new Map(t).set(R.path,e))).catch(e=>C(t=>new Map(t).set(R.path,e.message)))},[R,N,u,h,m]);let A=R?N.get(R.path):void 0,T=(0,l.useMemo)(()=>!A||"string"==typeof A||A.binary||A.tooLarge?[]:ew(ej(A.before),ej(A.after)),[A]),P=R&&q.get(R.path)||new Set,B=(0,l.useMemo)(()=>ek(T,3,P,S),[T,P,S]),_=(0,l.useMemo)(()=>T.flatMap((e,t)=>"same"!==e.kind&&(0===t||"same"===T[t-1].kind)?[t]:[]),[T]);(0,l.useEffect)(()=>{z(-1),I.current&&(I.current.scrollTop=0)},[k]);let $=(0,l.useCallback)(e=>{var t;if(0===_.length)return;let a=E<0?1===e?0:_.length-1:Math.min(_.length-1,Math.max(0,E+e));z(a);let s=null==(t=I.current)?void 0:t.querySelector('[data-row="'.concat(_[a],'"]'));null==s||s.scrollIntoView({block:"center"})},[E,_]),U=(0,l.useCallback)(e=>y(t=>Math.min(Math.max(0,t+e),Math.max(0,H.length-1))),[H.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=H.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:b("diff.title",{title:x})}),(null==g?void 0:g.ok)&&(0,s.jsxs)("span",{className:"muted small",children:[g.branch?"".concat(g.branch," \xb7 "):"",null==(t=g.base)?void 0:t.slice(0,8)," → ",null==(a=g.commit)?void 0:a.slice(0,8)," \xb7 ",b("diff.summary",{n:H.length,a:K.added,r:K.removed})]}),(0,s.jsx)("span",{className:"grow"}),(0,s.jsx)("span",{className:"muted small",children:b("diff.keys")}),(0,s.jsx)("button",{ref:W,type:"button",onClick:f,children:b("diff.close")})]}),j&&(0,s.jsx)("div",{className:"err",style:{padding:12},children:j}),!g&&!j&&(0,s.jsx)("div",{className:"muted",style:{padding:12},children:b("diff.loading")}),g&&!g.ok&&(0,s.jsx)("div",{className:"notice caution",style:{margin:12},children:g.problem}),(null==g?void 0:g.ok)&&0===H.length&&(0,s.jsx)("div",{className:"notice",style:{margin:12},children:b("diff.nothing")}),(null==g?void 0:g.ok)&&H.length>0&&(0,s.jsxs)("div",{className:"diff-body",children:[(0,s.jsx)("nav",{className:"diff-files","aria-label":b("diff.files"),children:H.map((e,t)=>{let a=e.path.lastIndexOf("/");return(0,s.jsxs)("button",{type:"button",className:"diff-file".concat(t===k?" 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?b("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:[R&&(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:R.oldPath?"".concat(R.oldPath," → ").concat(R.path):R.path}),(0,s.jsx)("span",{className:"muted small",children:"A"===R.status?b("diff.added"):"D"===R.status?b("diff.deleted"):"R"===R.status?b("diff.renamed"):""})]}),(0,s.jsx)(eS,{changes:_.length,onChange:$,files:{at:k,count:H.length,onFile:U},whole:S,onWhole:F,wrap:M,onWrap:O})]}),(0,s.jsxs)("div",{className:"diff-scroll",ref:I,children:[void 0===A&&(0,s.jsx)("div",{className:"muted",style:{padding:12},children:b("diff.loading")}),"string"==typeof A&&(0,s.jsx)("div",{className:"err",style:{padding:12},children:A}),A&&"string"!=typeof A&&A.binary&&(0,s.jsx)("div",{className:"notice",style:{margin:12},children:b("diff.binary")}),A&&"string"!=typeof A&&A.tooLarge&&(0,s.jsx)("div",{className:"notice",style:{margin:12},children:b("diff.tooLarge")}),A&&"string"!=typeof A&&!A.binary&&!A.tooLarge&&(0,s.jsxs)(s.Fragment,{children:[(null!=(i=A.before)?i:"").includes("\r\n")!==(null!=(c=A.after)?c:"").includes("\r\n")&&null!==A.before&&null!==A.after&&(0,s.jsx)("div",{className:"notice small",style:{margin:8},children:b("diff.eol",{from:(null!=(o=A.before)?o:"").includes("\r\n")?"CRLF":"LF",to:(null!=(d=A.after)?d:"").includes("\r\n")?"CRLF":"LF"})}),T.length>0&&0===_.length&&(0,s.jsx)("div",{className:"notice small",style:{margin:8},children:b("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)(eF,{changes:_.length,at:E}),(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(R&&L(e=>{var a;return new Map(e).set(R.path,new Set([...null!=(a=e.get(R.path))?a:[],t]))}))},children:b("diff.gap",{n:e.count})})})},"g".concat(e.from)):(0,s.jsx)(eM,{row:e.row,index:e.index,current:E>=0&&_[E]===e.index},e.index))})]})]})]})]})]})]})}function eS(e){let{changes:t,onChange:a,files:l,whole:n,onWhole:i,wrap:r,onWrap:c}=e,{t:o}=(0,p.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 eF(e){let{changes:t,at:a}=e,{t:l}=(0,p.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 eM(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 eO(e){var t;let{area:a,path:n,commit:i}=e,{t:c}=(0,p.kj)(),[o,d]=(0,l.useState)(null),[u,h]=(0,l.useState)(""),[x,f]=(0,l.useState)(!1),[b,g]=(0,l.useState)(!0),[v,j]=(0,l.useState)(new Set),[w,k]=(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(""),j(new Set),k(-1),N()},[N]),(0,m.z)(N,5e3,"commit"!==a);let C=(0,l.useMemo)(()=>!o||o.binary||o.tooLarge?[]:ew(ej(o.before),ej(o.after)),[o]),S=(0,l.useMemo)(()=>ek(C,3,v,x),[C,v,x]),F=(0,l.useMemo)(()=>C.flatMap((e,t)=>"same"!==e.kind&&(0===t||"same"===C[t-1].kind)?[t]:[]),[C]),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)(eS,{changes:F.length,onChange:e=>{var t,a;if(0===F.length)return;let s=w<0?1===e?0:F.length-1:Math.min(F.length-1,Math.max(0,w+e));k(s),null==(a=y.current)||null==(t=a.querySelector('[data-row="'.concat(F[s],'"]')))||t.scrollIntoView({block:"center"})},whole:x,onWhole:f,wrap:b,onWrap:g})]}),(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:[C.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(b?"":" 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)(eF,{changes:F.length,at:w}),(0,s.jsx)("tbody",{children:S.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:()=>j(t=>new Set([...t,e.from])),children:c("diff.gap",{n:e.count})})})},"g".concat(e.from)):(0,s.jsx)(eM,{row:e.row,index:e.index,current:w>=0&&F[w]===e.index},e.index))})]})]})]})]})}var eq=a(61238),eL=a(52157);let eE="",ez=new Set;function eI(e){if(e!==eE)for(let t of(eE=e,ez))t()}function eD(e){return ez.add(e),()=>{ez.delete(e)}}function eW(){return[(0,l.useSyncExternalStore)(eD,()=>eE,()=>""),eI]}var eH=a(41370),eR=a(33389),eA=a(68176);function eT(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]")),x=e=>{var t;return null!=(t=e.closest("[data-awaits-frame]"))?t:e},f=(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,f(e,x(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,f(e,x(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 eP=a(51035),eB=a(24784),e_=a(65132),e$=a(36657),eU=a(92842),eK=a(79717);let eV={done:"✓",running:"●",planned:"○",blocked:"⊘",failed:"✗",stopped:"■"},eZ={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 eJ(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 eG(e){let{lead:t,live:a}=e,{t:l}=(0,p.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}=eJ(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)(eY,{ledger:n,live:a})]})}function eY(e){let{ledger:t,live:a}=e,{t:l}=(0,p.kj)(),{phases:n}=eJ(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(eV["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)(V.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(eZ[t]),"aria-label":l(eZ[t]),children:eV[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 eX(e){let{change:t}=e,{t:a}=(0,p.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 eQ(e){let{workspace:t,running:a,onMade:n}=e,{t:i}=(0,p.kj)(),[r,c]=(0,l.useState)(!1),o=a?i("nb.offRunning"):(null==t?void 0:t.ok)?t.isRepo?"":i("nb.offNoRepo"):i("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":!!o||void 0,onClick:()=>!o&&c(!0),title:o||i("nb.buttonWhy"),children:i("nb.button")}),r&&(0,s.jsx)(e0,{onClose:()=>c(!1),onMade:e=>{c(!1),n(e)}})]})}function e0(e){var t,a,n,i,c,o,d,u,h,m,x;let{onClose:f,onMade:b}=e,{t:g}=(0,p.kj)(),v=(0,p.W3)(),j=(0,l.useRef)(null),w=(0,l.useRef)(null),[k,y]=(0,l.useState)(null),[N,C]=(0,l.useState)(!0),[S,F]=(0,l.useState)(""),[M,O]=(0,l.useState)("take"),[q,L]=(0,l.useState)(""),[E,z]=(0,l.useState)(!1),[I,D]=(0,l.useState)(""),[W,H]=(0,l.useState)(!1),R=(0,eH.q)(N||E);(0,ey.V)(j,!0,w);let A=async e=>{C(!0),D("");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{C(!1)}};(0,l.useEffect)(()=>{A(!0)},[]),(0,l.useEffect)(()=>{let e=e=>{"Escape"!==e.key||E||(e.preventDefault(),f())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[E,f]);let T=async()=>{if(null==k?void 0:k.fingerprint){z(!0),D(""),H(!1);try{let e=await r.FH.newBranchCreate(S.trim(),M,k.fingerprint,"commit"===M?q:void 0);if(e.ok)return void b(e.result);D(e.problem),e.conflict&&(H(!0),O("aside"))}catch(e){D(e.message)}finally{z(!1)}}},P=(null!=(t=null==k?void 0:k.changed.length)?t:0)+(null!=(a=null==k?void 0:k.untracked.length)?a:0),B=(null==k?void 0:k.fetched)&&!k.fetched.ok,_=[...null!=(n=null==k?void 0:k.changed)?n:[],...null!=(i=null==k?void 0:k.untracked)?i:[]];return(0,s.jsx)("div",{className:"modal-backdrop",role:"presentation",onClick:()=>!E&&f(),children:(0,s.jsxs)("div",{ref:j,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:g("nb.title")}),N?(0,s.jsxs)("div",{className:"nb-reading",role:"status",children:[(0,s.jsxs)("p",{children:[g("nb.fetching"),(0,s.jsx)("span",{className:"saving-dots",children:R})]}),(0,s.jsx)("p",{className:"muted small",children:g("nb.passwordNote")})]}):(0,s.jsxs)(s.Fragment,{children:[(null==k?void 0:k.ok)&&(0,s.jsxs)(s.Fragment,{children:[B&&(0,s.jsxs)("div",{className:"nb-warn",role:"alert",children:[(0,s.jsx)("p",{children:g(k.fetched.auth?"nb.fetchAuth":"nb.fetchFailed",{remote:null!=(c=k.remote)?c:"origin",detail:null!=(o=k.fetched.detail)?o:""})}),(0,s.jsx)("p",{className:"small",children:k.lastFetched?g("nb.lastFetched",{target:null!=(d=k.target)?d:"",at:v(k.lastFetched)}):g("nb.lastKnown",{target:null!=(u=k.target)?u:""})}),(0,s.jsx)("div",{className:"row",children:(0,s.jsx)("button",{type:"button",onClick:()=>void A(!0),disabled:E,children:g("nb.tryAgain")})})]}),(0,s.jsxs)("p",{className:"nb-from",children:[g("nb.from",{target:null!=(h=k.target)?h:"",commit:(null!=(m=k.targetCommit)?m:"").slice(0,8)})," ",k.targetSubject&&(0,s.jsxs)("span",{className:"muted",children:["— ",k.targetSubject]})]}),(0,s.jsx)("p",{className:"small muted",children:k.branch?g("nb.now",{branch:k.branch}):g("nb.nowDetached")}),(0,s.jsxs)("div",{className:"settings-field",children:[(0,s.jsx)("label",{htmlFor:"nb-name",className:"field-label",children:g("nb.name")}),(0,s.jsx)("input",{id:"nb-name",type:"text",dir:"ltr",value:S,onChange:e=>F(e.target.value),spellCheck:!1,disabled:E})]}),P>0&&(0,s.jsxs)("fieldset",{className:"nb-dirty",children:[(0,s.jsx)("legend",{children:g("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:g("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||E}),(0,s.jsxs)("span",{children:[(0,s.jsx)("strong",{children:g("nb.take")})," ",(0,s.jsx)("span",{className:"muted small",children:g("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:E}),(0,s.jsxs)("span",{children:[(0,s.jsx)("strong",{children:g("nb.aside")})," ",(0,s.jsx)("span",{className:"muted small",children:g("nb.asideWhy")})]})]}),(0,s.jsxs)("label",{className:"nb-choice",title:k.branch?void 0:g("nb.commitDetached"),children:[(0,s.jsx)("input",{type:"radio",name:"nb-carry",checked:"commit"===M,onChange:()=>O("commit"),disabled:E||!k.branch}),(0,s.jsxs)("span",{children:[(0,s.jsx)("strong",{children:g("nb.commit",{branch:null!=(x=k.branch)?x:"—"})})," ",(0,s.jsx)("span",{className:"muted small",children:g("nb.commitWhy")})]})]}),"commit"===M&&k.branch&&(0,s.jsxs)("div",{className:"settings-field nb-message",children:[(0,s.jsx)("label",{htmlFor:"nb-message",className:"field-label",children:g("nb.commitMessage")}),(0,s.jsx)("input",{id:"nb-message",type:"text",value:q,onChange:e=>L(e.target.value),placeholder:"Work in progress, before a new branch from main",disabled:E,maxLength:2e3})]})]}),(0,s.jsx)("p",{className:"muted small",children:g("nb.after")})]}),I&&(0,s.jsx)("p",{className:"err",role:"alert",children:I})]}),(0,s.jsxs)("div",{className:"row modal-actions",children:[(0,s.jsx)("button",{ref:w,type:"button",className:"quiet",onClick:f,disabled:E,children:g("nb.cancel")}),!N&&!(null==k?void 0:k.ok)&&(0,s.jsx)("button",{type:"button",onClick:()=>void A(!0),children:g("nb.tryAgain")}),!N&&(null==k?void 0:k.ok)&&(0,s.jsx)("button",{type:"button",className:"primary",onClick:()=>void T(),disabled:E||!S.trim(),"aria-busy":E||void 0,children:E?(0,s.jsxs)(s.Fragment,{children:[g("nb.making"),(0,s.jsx)("span",{className:"saving-dots",children:R})]}):g(B?"nb.makeFromLast":"nb.make")})]})]})})}var e1=a(34982),e2=a(44504),e3=a(14236);let e4="cop.chat.thread",e5="cop.chat.plan",e6="cop.chat.review",e8="cop.chat.lead",e7="cop.chat.kerrigan",e9=(e,t)=>{try{t?window.localStorage.setItem(e,t):window.localStorage.removeItem(e)}catch(e){}},te=e=>{try{var t;return null!=(t=window.localStorage.getItem(e))?t:""}catch(e){return""}};function tt(e){var t,a,n,c,o,d,u,h,x,f,b,g,v,j,w,k,y,N,C,S;let{workspace:F,composeAsk:M,showThread:O,onOpenFile:q,onChange:L,onOpenFolder:E,onTurn:z}=e,{t:I,locale:D}=(0,p.kj)(),[W,H]=(0,l.useState)([]),[R,A]=(0,l.useState)(""),[T,P]=(0,l.useState)(null),[B,_]=(0,l.useState)(!1),[$,U]=(0,l.useState)(!0),[K,Z]=(0,l.useState)(""),[J,G]=(0,l.useState)(!1),[Y,X]=(0,l.useState)(""),[Q,ee]=(0,l.useState)(!1),[et,ea]=(0,l.useState)(null),[es,el]=(0,l.useState)(""),[en,ei]=(0,l.useState)(!1),[er,ec]=(0,l.useState)(""),[eo,ed]=(0,l.useState)([]),[eu,eh]=(0,l.useState)(null),[em,ep]=(0,l.useState)(""),[ex,ef]=(0,l.useState)(!1),[eb,eg]=(0,l.useState)([]),[ev,ej]=eW(),ew=(0,l.useRef)(null),ek=!!T&&("idle"!==T.status||!!T.directedBy&&T.tasks.some(e=>"running"===e.status||"waiting-approval"===e.status)),ey=T?!!T.lead||!!T.kerrigan:J||Q,eN=null!=(h=(T?!!T.kerrigan:Q)?(null==eu?void 0:eu.defaultKerriganModel)||(null==eu?void 0:eu.defaultLeadModel)||(null==eu?void 0:eu.defaultModel):ey&&(null==eu?void 0:eu.defaultLeadModel)||(null==eu?void 0:eu.defaultModel))?h:"",eC=null!=(x=null==eu?void 0:eu.defaultModel)?x:"",eS=T?!T.manualModel&&(T.model||eN)?null!=(f=T.model)?f:"":eB.u:"",eF=em!==eB.u&&(em||eN)?em:eB.u;(0,l.useEffect)(()=>{A(te(e4)),_("on"===te(e5)),U("off"!==te(e6)),G("on"===te(e8)&&"on"!==te(e7)),ee("on"===te(e7))},[]),(0,l.useEffect)(()=>{var e;M>0&&(null==(e=ew.current)||e.focus())},[M]),(0,l.useEffect)(()=>{(null==O?void 0:O.id)&&e$(O.id)},[null==O?void 0:O.n]),(0,l.useEffect)(()=>{r.FH.models().then(eh).catch(()=>void 0),r.FH.skills().then(e=>eg(e.skills)).catch(()=>void 0)},[]);let eM=e=>e.trim().replace(/[\\/]+$/,"").replace(/\//g,"\\").toLowerCase(),eO=eb.filter(e=>!e.projectDir||(null==F?void 0:F.dir)&&eM(e.projectDir)===eM(F.dir)),eL=(0,l.useCallback)(()=>r.FH.chatThreads().then(H).catch(()=>void 0),[]);(0,m.z)(eL,5e3);let eE=(0,l.useRef)(R);eE.current=R;let ez=(0,l.useCallback)(()=>{let e=eE.current;return e?r.FH.session(e).then(t=>{eE.current===e&&P("chat"===t.kind?t:null)}).catch(t=>{404===t.status&&eE.current===e&&(P(null),A(""),e9(e4,""))}):Promise.resolve(P(null))},[]);(0,l.useEffect)(()=>{ez()},[R,ez]),(0,m.z)(ez,ek?1500:5e3,!!R);let eI=(0,l.useRef)(new Set),eD=()=>R&&ek?r.FH.approvals(R).then(e=>ed(e.filter(e=>!eI.current.has(e.id)))).catch(()=>void 0):Promise.resolve(ed([]));(0,m.z)(eD,1500,!!R);let eR=(e,t)=>{t&&(eI.current.add(e),ed(t=>t.filter(t=>t.id!==e))),eD()},eA=null!=(b=null==T||null==(t=T.lead)?void 0:t.workerSessionId)?b:"",e_=(0,l.useCallback)(()=>eA?r.FH.session(eA).then(ea).catch(()=>void 0):Promise.resolve(ea(null)),[eA]);(0,l.useEffect)(()=>{e_()},[e_]),(0,m.z)(e_,ek?1500:1e4,!!eA);let e$=e=>{eE.current=e,A(e),e9(e4,e),ec(""),eG(null)},eU=e=>(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("label",{htmlFor:"cs-model",className:"sr-only",children:I("chat.model")}),(0,s.jsx)(eB.Yb,{id:"cs-model",chosen:T?eS:eF,onChange:e=>void ts(e),byHand:I("chat.modelByHand"),none:eN?I("chat.modelDefault",{model:eN}):void 0,catalogue:eu,disabled:ek,style:{minWidth:0,maxWidth:e}}),(0,s.jsx)("button",{type:"button",className:"wb-icon-btn",onClick:()=>void to(),disabled:ex||ek,title:I("chat.readModels"),"aria-label":I("chat.readModels"),children:"↻"})]}),eK=ek||W.some(e=>e.running),eV=eK?I("chat.newChatRunning"):T?"":I("chat.newChatFresh"),eZ=()=>{var e;e$(""),P(null),null==(e=ew.current)||e.focus()},[eJ,eG]=(0,l.useState)(null),eY=e=>e.replace(/^chat: /,""),eX=async()=>{var e;let t=null!=(e=null==eJ?void 0:eJ.trim())?e:"";if(T&&t)try{let e=await r.FH.updateSession(T.id,{name:t});P(t=>t&&t.id===e.id?{...t,name:e.name}:t),H(t=>t.map(t=>t.id===e.id?{...t,name:e.name}:t)),eG(null),ec("")}catch(e){ec(e.message)}},e0=async()=>{let e=es.trim();if(!e||en)return;let t=ev,a=eO.length>0?/^\/([a-z0-9][a-z0-9-]*[a-z0-9])(?=\s|$)\s*([\s\S]*)$/.exec(e):null;if(a){let s=eO.find(e=>e.name===a[1]);if(!s)return void ec(I("chat.skillUnknown",{name:a[1],names:eO.map(e=>"/".concat(e.name)).join(", ")}));if(!a[2].trim())return void ec(I("chat.skillNoText",{name:s.name}));t=s.name,e=a[2].trim()}ei(!0),ec("");try{var s;let a=!R,l=a&&em===eB.u,n=a&&J&&!Q?{workerModel:Y===eB.u?void 0:Y||void 0,workerManualModel:Y===eB.u}:void 0,i=a&&Q?{chatModel:Y===eB.u?void 0:Y||void 0,chatManualModel:Y===eB.u}:void 0,c=await r.FH.chatSend(e,R||void 0,a&&!l&&em||void 0,l,D,a&&B&&!i,a?!n&&!i&&$:void 0,n,t||void 0,a&&!n&&!i&&K||void 0,i);if(el(""),ej(""),e$(c.threadId),c.noted)return void ec(I("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||ec(I("chat.notStarted",{reason:null!=(s=d.reason)?s:""}))}catch(e){ec(e.message)}finally{ei(!1),ez(),eL(),L()}},e1=async(e,t,a)=>{if(!T||en)return!1;ei(!0),ec("");let s=!1;try{var l;let n=await r.FH.chatRetrySubtask(T.id,e.id,t,a);s=n.started,n.started||ec(null!=(l=n.reason)?l:I("retry.notStarted"))}catch(e){ec(e.message)}finally{ei(!1),ez()}return s},e2=async e=>{if(T&&!en){ei(!0),ec("");try{var t;let a=await r.FH.chatContinue(T.id,e.id);a.started||ec(null!=(t=a.reason)?t:I("chat.carryOnNotStarted"))}catch(e){ec(e.message)}finally{ei(!1),ez(),eL(),L()}}},e3=async e=>{if(T&&!en&&await (0,eP.Z)(I("chat.rewindConfirm",{n:T.tasks.length-T.tasks.indexOf(e)}))){ei(!0),ec("");try{var t;let a=await r.FH.chatRewind(T.id,e.id);el(a.text),ec(I("chat.rewound")),null==(t=ew.current)||t.focus()}catch(e){ec(e.message)}finally{ei(!1),ez(),L()}}},tt=async e=>{if(T){P(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(T.id,e)}catch(e){ec(e.message)}finally{ez()}}},ts=async e=>{if(!T)return void ep(e);await tt(e===eB.u?{model:"",manualModel:!0}:{model:e,manualModel:!1})},tl=T?!!T.lead:J&&!Q,tn=T?!!T.kerrigan:Q,tr=T?T.kerrigan?T.kerrigan.chatManualModel?eB.u:null!=(g=T.kerrigan.chatModel)?g:"":(null==(a=T.lead)?void 0:a.workerManualModel)?eB.u:null!=(v=null==(n=T.lead)?void 0:n.workerModel)?v:"":Y,tc=async e=>{if(!T)return void X(e);await tt(e===eB.u?{workerModel:"",workerManualModel:!0}:{workerModel:e,workerManualModel:!1})},to=async()=>{ef(!0),ec(I("chat.modelsReading"));try{eh(await r.FH.refreshModels()),ec(I("chat.modelsRead"))}catch(e){ec(e.message)}finally{ef(!1)}},td=T?"approve"===T.planMode:B,tu=async e=>{if(!T){_(e),e9(e5,e?"on":"");return}await tt({planMode:e?"approve":"off"})},th=T?(null==(c=T.review)?void 0:c.enabled)!==!1:$,tm=async e=>{if(!T){U(e),e9(e6,e?"":"off");return}await tt({review:{enabled:e}})},tf=T?"operator"===T.reviewModelSource&&null!=(j=null==(o=T.review)?void 0:o.model)?j:"":K,tb=null!=(w=null==eu?void 0:eu.defaultReviewModel)?w:"",tg=async e=>{if(!T)return void Z(e);await tt({review:{model:e}})},tv=ek&&!!(null==T?void 0:T.paused),tj=(0,eq.v)(),tw=async()=>{if(!T)return;let e=!T.paused;P(t=>t?{...t,paused:e}:t);try{await (e?r.FH.pause(T.id):r.FH.resume(T.id))}catch(e){ec(e.message)}finally{ez()}},[tk,ty]=(0,l.useState)(!1);(0,l.useEffect)(()=>{ek||ty(!1)},[ek]),(0,l.useEffect)(()=>{ty(!1)},[null==T?void 0:T.id]);let tN=(0,eH.q)(tk),tC=null==T?void 0:T.tasks.at(-1),tS=null==tC||null==(u=tC.lead)||null==(d=u.rounds.filter(e=>e.subtask).at(-1))?void 0:d.subtask;(0,l.useEffect)(()=>{z(R?T&&tC?tS&&eA?{sessionId:eA,taskId:tS.taskId}:{sessionId:T.id,taskId:tC.id}:null:"new")},[R,null==T?void 0:T.id,null==tC?void 0:tC.id,null==tS?void 0:tS.taskId,eA]);let{ref:tF}=eT(!0,"".concat(null!=(k=null==T?void 0:T.tasks.length)?k:0,":").concat(null!=(y=null==tC?void 0:tC.status)?y:"",":").concat(null!=(N=null==tC?void 0:tC.iterations)?N:0));return(0,s.jsxs)("div",{className:"cs",children:[(0,s.jsxs)("div",{className:"cs-head",children:[null!==eJ&&T?(0,s.jsxs)("form",{className:"cs-rename",onSubmit:e=>{e.preventDefault(),eX()},children:[(0,s.jsx)("label",{htmlFor:"cs-rename",className:"sr-only",children:I("chat.renameLabel")}),(0,s.jsx)("input",{id:"cs-rename",type:"text",dir:"auto",maxLength:120,value:eJ,autoFocus:!0,onFocus:e=>e.target.select(),onChange:e=>eG(e.target.value),onKeyDown:e=>{"Escape"===e.key&&(e.preventDefault(),eG(null))}}),(0,s.jsx)("button",{type:"submit",className:"wb-icon-btn",disabled:!eJ.trim(),title:I("chat.renameSave"),"aria-label":I("chat.renameSave"),children:"✓"}),(0,s.jsx)("button",{type:"button",className:"wb-icon-btn",onClick:()=>eG(null),title:I("chat.renameCancel"),"aria-label":I("chat.renameCancel"),children:"✕"})]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("label",{htmlFor:"cs-thread",className:"sr-only",children:I("chat.thread")}),(0,s.jsxs)("select",{id:"cs-thread",dir:"auto",value:R,onChange:e=>e$(e.target.value),children:[(0,s.jsx)("option",{value:"",children:I("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})(W).map(e=>(0,s.jsx)("option",{value:e.id,children:e.kerrigan?"✦ ".concat(eY(e.name)):e.directedBy?" ↳ ".concat(eY(e.name)):eY(e.name)},e.id))]}),T&&(0,s.jsx)("button",{type:"button",className:"wb-icon-btn cs-rename-btn",onClick:()=>eG(eY(T.name)),title:I("chat.rename"),"aria-label":I("chat.rename"),children:"✎"})]}),(0,s.jsxs)("span",{className:"cs-new-wrap",children:[(0,s.jsx)("button",{type:"button",className:"cs-new","aria-disabled":!!eV||void 0,"aria-describedby":eV?"cs-new-tip":void 0,onClick:()=>{eV||eZ()},title:eV?void 0:I("chat.newChatWhy"),children:I("chat.newChat")}),eV&&(0,s.jsx)("span",{id:"cs-new-tip",role:"tooltip",className:"cs-new-tip",children:eV})]})]}),(0,s.jsxs)("div",{className:"cs-body",ref:tF,"aria-live":"polite",children:[(null==T?void 0:T.directedBy)&&(0,s.jsxs)("p",{className:"cs-system cs-directed",children:[I("kz.directedBy")," ",(0,s.jsx)("button",{type:"button",className:"quiet small",onClick:()=>e$(T.directedBy),children:I("kz.openHers")})]}),T?T.tasks.map((e,t)=>T.kerrigan?(0,s.jsx)(tx,{n:t+1,session:T,task:e,threads:W,approvals:eo,onDecided:eR,onOpenFile:q,onOpenChat:e$,onRewind:ek||en?void 0:()=>void e3(e)},e.id):T.lead?(0,s.jsx)(tp,{n:t+1,session:T,task:e,worker:et,approvals:eo,onDecided:eR,onOpenFile:q,onRewind:ek||en?void 0:()=>void e3(e),onRetrySubtask:ek||"aborted"!==e.status?void 0:(t,a)=>e1(e,t,a)},e.id):(0,s.jsx)(ti,{n:t+1,session:T,task:e,approvals:eo.filter(t=>t.taskId===e.id),onDecided:eR,onOpenFile:q,onRewind:ek||en?void 0:()=>void e3(e)},e.id)):(0,s.jsx)(ta,{workspace:F,onPick:e=>{var t;el(e),null==(t=ew.current)||t.focus()},onOpenFolder:E}),T&&!ek&&!T.directedBy&&!!(S=T.tasks.at(-1))&&("aborted"===S.status||"limit-reached"===S.status||!!S.limit&&("failed"===S.status||"blocked"===S.status))&&(0,s.jsxs)("div",{className:"cs-system cs-carry",role:"group","aria-label":I("chat.carryOnLabel"),children:[(0,s.jsx)("span",{className:"grow",children:I("chat.carryOnNote")}),(0,s.jsx)("button",{type:"button",className:"primary small",disabled:en,onClick:()=>void e2(T.tasks.at(-1)),children:I("chat.carryOn")})]}),tv&&(0,s.jsx)("p",{className:"cs-system cs-paused",role:"status",children:I("chat.pausedNote")}),ek&&(null==tj?void 0:tj.password)&&(0,s.jsxs)("div",{className:"cs-system cs-password",role:"alert","data-awaits":"password:".concat(null!=(C=null==T?void 0:T.id)?C:""),tabIndex:-1,children:[I("chat.passwordWaiting"),(0,s.jsx)(V.T4,{text:I("chat.passwordWaiting")})]}),er&&(0,s.jsx)("p",{className:"cs-system",role:"status",children:er})]}),(0,s.jsxs)("div",{className:"cs-compose",children:[(0,s.jsx)("label",{htmlFor:"cs-input",className:"sr-only",children:I("chat.input")}),(0,s.jsx)("textarea",{id:"cs-input",ref:ew,value:es,onChange:e=>el(e.target.value),placeholder:ek?I("chat.placeholderRunning"):(null==F?void 0:F.ok)?I("chat.placeholder",{folder:F.name}):I("chat.placeholderNoFolder"),disabled:en||!(null==F?void 0:F.ok),onKeyDown:e=>{"Enter"!==e.key||e.shiftKey||e.nativeEvent.isComposing||(e.preventDefault(),e0())}}),tn?(0,s.jsxs)("div",{className:"cs-models",children:[(0,s.jsx)("span",{className:"cs-pick-label","aria-hidden":"true",children:I("chat.kerriganModel")}),(0,s.jsx)("div",{className:"cs-bar",children:eU("90%")}),(0,s.jsx)("label",{htmlFor:"cs-chats-model",className:"cs-pick-label",children:I("chat.kerriganChatsModel")}),(0,s.jsx)("div",{className:"cs-bar",children:(0,s.jsx)(eB.Yb,{id:"cs-chats-model",chosen:tr,onChange:e=>void tc(e),byHand:I("chat.modelByHand"),none:eC?I("chat.modelDefault",{model:eC}):I("chat.modelByHand"),catalogue:eu,disabled:ek,style:{minWidth:0,maxWidth:"90%"}})})]}):tl?(0,s.jsxs)("div",{className:"cs-models",children:[(0,s.jsx)("span",{className:"cs-pick-label","aria-hidden":"true",children:I("chat.leadModel")}),(0,s.jsx)("div",{className:"cs-bar",children:eU("90%")}),(0,s.jsx)("label",{htmlFor:"cs-worker-model",className:"cs-pick-label",children:I("chat.workerModel")}),(0,s.jsx)("div",{className:"cs-bar",children:(0,s.jsx)(eB.Yb,{id:"cs-worker-model",chosen:tr,onChange:e=>void tc(e),byHand:I("chat.modelByHand"),none:eC?I("chat.modelDefault",{model:eC}):I("chat.workerSameModel"),catalogue:eu,disabled:ek,style:{minWidth:0,maxWidth:"90%"}})})]}):th&&!tn?(0,s.jsxs)("div",{className:"cs-models",children:[(0,s.jsx)("span",{className:"cs-pick-label","aria-hidden":"true",children:I("chat.workModel")}),(0,s.jsx)("div",{className:"cs-bar",children:eU("90%")}),(0,s.jsx)("label",{htmlFor:"cs-review-model",className:"cs-pick-label",children:I("chat.reviewModel")}),(0,s.jsx)("div",{className:"cs-bar",title:I("chat.reviewModelWhy"),children:(0,s.jsx)(eB.Yb,{id:"cs-review-model",chosen:tf,onChange:e=>void tg(e),none:tb?I("chat.reviewModelDefault",{model:tb}):I("chat.reviewModelByHand"),catalogue:eu,disabled:ek,style:{minWidth:0,maxWidth:"90%"}})})]}):(0,s.jsx)("div",{className:"cs-bar",children:eU("48%")}),(0,s.jsxs)("div",{className:"cs-bar cs-skills",children:[eO.length>0&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("label",{htmlFor:"cs-skill",className:"cs-pick-label",children:I("chat.skill")}),(0,s.jsxs)("select",{id:"cs-skill",value:ev,onChange:e=>ej(e.target.value),disabled:ek,title:I("chat.skillWhy"),style:{minWidth:0,maxWidth:"60%"},children:[(0,s.jsx)("option",{value:"",children:I("chat.skillNone")}),eO.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:I("chat.skillsLinkWhy"),children:I("chat.skillsLink")}),(0,s.jsx)(eQ,{workspace:F,running:eK,onMade:e=>{eZ(),ec("".concat(e," ").concat(I("nb.madeChat"))),L()}})]}),(0,s.jsxs)("div",{className:"cs-bar",children:[(0,s.jsxs)("label",{className:"cs-plan-toggle cs-kerrigan-toggle",title:I("chat.kerriganWhy"),children:[(0,s.jsx)("input",{type:"checkbox",checked:tn,disabled:ek||!!T,onChange:e=>{var t;return t=e.target.checked,void(!T&&(ee(t),e9(e7,t?"on":""),t&&(G(!1),e9(e8,""))))}}),(0,s.jsx)("span",{children:I("chat.kerrigan")})]}),!tn&&(0,s.jsxs)("label",{className:"cs-plan-toggle",title:I("chat.planModeWhy"),children:[(0,s.jsx)("input",{type:"checkbox",checked:td,disabled:ek,onChange:e=>void tu(e.target.checked)}),(0,s.jsx)("span",{children:I("chat.planMode")})]}),!tn&&(0,s.jsxs)("label",{className:"cs-plan-toggle cs-lead-toggle",title:I("chat.leadWhy"),children:[(0,s.jsx)("input",{type:"checkbox",checked:tl,disabled:ek||!!T,onChange:e=>{var t;return t=e.target.checked,void(!T&&(G(t),e9(e8,t?"on":""),t&&(ee(!1),e9(e7,""))))}}),(0,s.jsx)("span",{children:I("chat.lead")})]}),!tl&&!tn&&(0,s.jsxs)("label",{className:"cs-plan-toggle cs-review-toggle",title:I("chat.reviewWhy"),children:[(0,s.jsx)("input",{type:"checkbox",checked:th,disabled:ek,onChange:e=>void tm(e.target.checked)}),(0,s.jsx)("span",{children:I("chat.review")})]}),(0,s.jsxs)("span",{className:"cs-actions",children:[ek&&(0,s.jsx)("button",{type:"button",className:"cs-pause",onClick:()=>void tw(),title:tv?I("chat.resumeWhy"):I("chat.pauseWhy"),children:tv?I("chat.resume"):I("chat.pause")}),ek&&(0,s.jsx)("button",{type:"button",className:"danger cs-stop",onClick:()=>{T&&!tk&&(ty(!0),r.FH.stop(T.id).then(()=>ec(I("chat.stopping"))).catch(e=>{ty(!1),ec(e.message)}))},disabled:tk,"aria-busy":tk||void 0,children:tk?(0,s.jsxs)(s.Fragment,{children:[I("chat.stoppingNow"),(0,s.jsx)("span",{className:"saving-dots",children:tN})]}):I("chat.stop")}),(0,s.jsx)("button",{type:"button",className:"primary",disabled:en||!es.trim()||!(null==F?void 0:F.ok),onClick:()=>void e0(),title:I("chat.sendWhy"),children:ek?I("chat.sendNote"):I("chat.send")})]})]})]})]})}function ta(e){var t;let{workspace:a,onPick:l,onOpenFolder:n}=e,{t:i}=(0,p.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 ts(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 tl(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)(e_.s,{text:e.notes}),(0,s.jsx)("div",{className:"cs-copy-row",children:(0,s.jsx)(V.i8,{text:e.notes,what:"chat.copyReply"})})]},t):null:"step"===e.kind?(0,s.jsx)(td,{step:e},t):"handoff"===e.kind?(0,s.jsx)(eA.Q$,{card:e.card,outcome:e.outcome,answer:e.answer},t):null})})}function tn(e){let{task:t,n:a,onRewind:l}=e,{t:n}=(0,p.kj)(),i=(0,p.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)(tb,{skill:t.skill}),(0,s.jsx)(to,{children:(0,s.jsx)(e_.s,{text:t.prompt})}),(0,s.jsx)("div",{className:"cs-copy-row",children:(0,s.jsx)(V.i8,{text:t.prompt,what:"chat.copyMessage"})})]})]})}function ti(e){var t,a,l,n;let{n:i,session:c,task:o,approvals:d,onDecided:u,onOpenFile:h,onRewind:m}=e,{t:x}=(0,p.kj)(),f="running"===o.status||"waiting-approval"===o.status,b=ts(c.id,o);return(0,s.jsxs)("section",{className:"cs-turn",id:"cs-turn-".concat(o.id),"aria-label":x("chat.turn",{text:o.title}),children:[(0,s.jsx)(tn,{task:o,n:i,onRewind:m}),"queued"===o.status&&(0,s.jsx)("p",{className:"muted small cs-system",children:x("idle"===c.status?"chat.queued":"chat.waitingTurn")}),(0,s.jsx)(tl,{entries:b}),(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:x("chat.planShown",{v:o.plan.version})}),(0,s.jsx)(eK.D,{plan:o.plan})]}),d.map(e=>(0,s.jsx)(th,{approval:e,onDecided:u},e.id)),f&&(0,s.jsxs)("p",{className:"cs-working",role:"status",children:[o.acting?(0,s.jsx)(eU.y,{actor:o.acting.actor,acting:o.acting}):(0,s.jsx)("span",{className:"wb-live","aria-hidden":"true"})," ",x("chat.working",{n:o.iterations})]}),!f&&"queued"!==o.status&&(0,s.jsx)(tr,{task:o}),!f&&(0,s.jsx)(tf,{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:x("chat.exchangeWhy"),children:x("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:x("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)(_,{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)(eN,{sessionId:c.id,taskId:o.id,runId:o.runId,title:o.title,files:o.vcs.files.length})]})]})}function tr(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*tc)};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)(t5,{status:t.status}),(0,s.jsxs)("div",{className:"grow",ref:a,children:[t.summary?(0,s.jsx)(e_.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)(V.i8,{text:r,what:"chat.copySummary"})})]}),r&&(0,s.jsx)(V.i8,{text:r,what:"chat.copySummary"})]})}let tc=6;function to(e){let{children:t}=e,{t:a}=(0,p.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 td(e){let{step:t}=e,{t:a}=(0,p.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)(V.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 tu=e=>({"data-awaits":e.id,tabIndex:-1});function th(e){var t;let{approval:a,onDecided:l}=e,{t:n}=(0,p.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)(eU.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)(tm,{approval:a,onDecided:l})]}):(0,s.jsx)(tm,{approval:a,onDecided:l})}function tm(e){var t,a,l;let{approval:n,onDecided:i}=e,{t:c}=(0,p.kj)(),{err:o,choose:d,mark:u}=(0,eR.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",...tu(n),children:(0,s.jsx)(e$.M,{approval:n,onDecided:e=>i(n.id,e)})}):(null==(t=n.question)?void 0:t.handoff)?(0,s.jsx)(tN,{approval:n,onDecided:i}):n.question?(0,s.jsx)(tC,{approval:n,onDecided:i}):n.retry?(0,s.jsx)(ty,{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"),...tu(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)(eU.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)(V.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)(eA.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&&(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")})]}),o&&(0,s.jsx)("p",{className:"err",role:"alert",children:o}),(0,s.jsx)(V.T4,{text:(0,e2.Mo)(c,n)})]})}function tp(e){var t,a,n,i,c,o,d,u,h,m,x,f,b,g,v,j,w,k;let{n:y,session:N,task:C,worker:S,approvals:F,onDecided:M,onOpenFile:O,onRewind:q,onRetrySubtask:L}=e,{t:E}=(0,p.kj)(),z="running"===C.status||"waiting-approval"===C.status,I=null!=(g=null==(t=C.lead)?void 0:t.rounds)?g:[],D=new Map(I.filter(e=>e.subtask).map(e=>[e.subtask.n,e.n])),W=null==(a=I.filter(e=>"plan"===e.status).at(-1))?void 0:a.n,H=F.filter(e=>e.taskId===C.id),R=(null==(n=I.at(-1))?void 0:n.subtask)&&(null==S?void 0:S.tasks.find(e=>{var t,a;return e.id===(null==(a=I.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(C.id),"aria-label":E("chat.turn",{text:C.title}),children:[(0,s.jsx)(tn,{task:C,n:y,onRewind:q}),"queued"===C.status&&(0,s.jsx)("p",{className:"muted small cs-system",children:"idle"===N.status?E("chat.queued"):E("chat.waitingTurn")}),I.map(e=>{var t,a;return(0,s.jsxs)(l.Fragment,{children:[e.understanding&&(0,s.jsx)(tg,{who:E("lead.understood"),text:e.understanding}),e.notes&&(0,s.jsx)(tg,{who:E("lead.who"),text:e.notes}),e.ledger&&(0,s.jsx)(eX,{change:e.ledger}),"plan"===e.status&&e.n===W&&C.plan&&!H.some(e=>e.plan)&&(0,s.jsxs)("details",{className:"cs-plan",children:[(0,s.jsx)("summary",{children:E("lead.plan",{v:C.plan.version})}),(0,s.jsx)(eK.D,{plan:C.plan})]}),e.subtask&&D.get(e.subtask.n)===e.n&&(0,s.jsx)(tv,{round:e,worker:S,approvals:F.filter(t=>{var a;return t.taskId===(null==(a=e.subtask)?void 0:a.taskId)}),onDecided:M,onOpenFile:O,onRetry:L?t=>L(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:E("lead.question")}),(0,s.jsx)(e_.s,{text:e.question.text}),(0,s.jsx)("div",{className:"cs-copy-row",children:(0,s.jsx)(V.i8,{text:(0,e2.yw)(E,{...e.question,options:null!=(a=e.question.options)?a:[]},!1),what:"chat.copyQuestion"})}),(0,s.jsx)("p",{className:"cs-who",children:E("lead.answered")}),(0,s.jsx)(e_.s,{text:e.question.answer}),(0,s.jsx)("div",{className:"cs-copy-row",children:(0,s.jsx)(V.i8,{text:e.question.answer,what:"chat.copyAnswer"})})]})]},e.n)}),H.map(e=>(0,s.jsx)(th,{approval:e,onDecided:M},e.id)),z&&(0,s.jsxs)("p",{className:"cs-working",role:"status",children:[C.acting?(0,s.jsx)(eU.y,{actor:C.acting.actor,acting:C.acting}):(0,s.jsx)("span",{className:"wb-live","aria-hidden":"true"})," ",R?(null==(i=C.lead)?void 0:i.ledger)?E("lead.workingOn",{title:null!=(v=null==(o=I.at(-1))||null==(c=o.subtask)?void 0:c.title)?v:""}):E("lead.working",{n:null!=(j=null==(u=I.at(-1))||null==(d=u.subtask)?void 0:d.n)?j:0}):E("lead.thinking")]}),C.lead&&(z||C.lead.ledger)&&(0,s.jsx)(eG,{lead:C.lead,live:z}),(null==(h=C.lead)?void 0:h.messages)&&(0,s.jsx)("p",{className:"muted small cs-lead-count",children:E("lead.messages",{lead:C.lead.messages.lead,worker:C.lead.messages.worker,total:C.lead.messages.lead+C.lead.messages.worker})}),!z&&"queued"!==C.status&&(0,s.jsx)(tr,{task:C}),!z&&(0,s.jsx)(tf,{session:N,task:C}),!z&&(null!=(w=null==(x=C.lead)||null==(m=x.evidence)?void 0:m.length)?w:0)>0&&(0,s.jsxs)("div",{className:"cs-evidence",children:[(0,s.jsx)("p",{className:"cs-who",children:E("lead.evidence")}),(0,s.jsx)("ul",{children:C.lead.evidence.map(e=>(0,s.jsx)("li",{children:(0,s.jsx)(e_.s,{text:e})},e))}),(0,s.jsx)("div",{className:"cs-copy-row",children:(0,s.jsx)(V.i8,{text:C.lead.evidence.map(e=>"- ".concat(e)).join("\n"),what:"chat.copyEvidence"})})]}),C.runId&&(0,s.jsx)("div",{className:"cs-exchange",children:(0,s.jsx)("a",{className:"button-link quiet small",href:r.FH.taskExchangeUrl(N.id,C.id),download:!0,title:E("chat.exchangeWhy"),children:E("chat.exchange")})}),(null!=(k=null==(b=C.vcs)||null==(f=b.files)?void 0:f.length)?k:0)>0&&!z&&(0,s.jsxs)("div",{className:"cs-files",children:[(0,s.jsx)("span",{className:"small",children:E("chat.changed",{n:C.vcs.files.length})}),C.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)(_,{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)(eN,{sessionId:N.id,taskId:C.id,runId:C.runId,title:C.title,files:C.vcs.files.length})]})]})}function tx(e){var t,a,n,i,c,o,d,u;let{n:h,session:m,task:x,threads:f,approvals:b,onDecided:g,onOpenFile:v,onOpenChat:j,onRewind:w}=e,{t:k}=(0,p.kj)(),y="running"===x.status||"waiting-approval"===x.status,N=x.kerrigan,C=null!=(o=null==N?void 0:N.rounds)?o:[],S=e=>{var t,a;return(null!=(a=null==(t=f.find(t=>t.id===e))?void 0:t.name)?a:"").replace(/^chat: /,"")||k("kz.aChat")},F=y?b.filter(e=>e.taskId===x.id||e.sessionId!==m.id):[],M=null==(t=[...C].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(x.id),"aria-label":k("chat.turn",{text:x.title}),children:[(0,s.jsx)(tn,{task:x,n:h,onRewind:w}),"queued"===x.status&&(0,s.jsx)("p",{className:"muted small cs-system",children:"idle"===m.status?k("chat.queued"):k("chat.waitingTurn")}),C.map((e,t)=>{var a,n,i;return(0,s.jsxs)(l.Fragment,{children:[e.understanding&&(0,s.jsx)(tg,{who:k("kz.understood"),text:e.understanding}),e.notes&&(0,s.jsx)(tg,{who:k("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:k("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:k("kz.send",{n:e.send.n,name:S(e.send.sessionId)})}),(0,s.jsxs)("p",{className:"cs-kz-chips",children:[(0,s.jsx)("span",{className:"badge",children:"same"===e.send.chat?k("kz.sameChat"):k("kz.newChat")}),e.send.planMode&&(0,s.jsx)("span",{className:"badge",children:k("kz.planMode")}),e.send.twoChats&&(0,s.jsx)("span",{className:"badge",children:k("kz.twoChats")}),e.send.review&&(0,s.jsx)("span",{className:"badge",children:k("kz.review")}),e.send.skill&&(0,s.jsx)("span",{className:"badge skill",children:k("chat.skillUsed",{name:e.send.skill})})]}),(0,s.jsx)(to,{children:(0,s.jsx)(e_.s,{text:e.send.prompt})}),(0,s.jsxs)("div",{className:"cs-copy-row",children:[(0,s.jsx)(V.i8,{text:e.send.prompt,what:"kz.copyPrompt"}),e.send.sessionId&&(0,s.jsx)("button",{type:"button",className:"quiet small cs-kz-open",onClick:()=>j(e.send.sessionId),title:k("kz.openChatWhy"),children:k("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)(t5,{status:e.send.status})," ",k("kz.chatEnded")]})]}),e.card&&(0,s.jsxs)("div",{className:"cs-bot cs-kz-answer",children:[(0,s.jsxs)("p",{className:"cs-who",children:[k("kz.cardHead")," ",e.card.actor&&(0,s.jsx)(eU.y,{actor:e.card.actor,how:"asks"})]}),(0,s.jsx)(e_.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?k("kz.youAnswered",{answer:e.card.answer}):k("kz.answered",{answer:e.card.answer})})}),e.card.yours&&(0,s.jsxs)("p",{className:"small cs-kz-yours",children:[k("kz.leftToYou",{why:e.card.yours.why}),e.card.yours.suggestion?" ".concat(k("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:k("kz.asked")}),(0,s.jsx)(e_.s,{text:e.question.text}),(0,s.jsx)("div",{className:"cs-copy-row",children:(0,s.jsx)(V.i8,{text:(0,e2.yw)(k,{...e.question,options:null!=(i=e.question.options)?i:[]},!1),what:"chat.copyQuestion"})}),(0,s.jsx)("p",{className:"cs-who",children:k("lead.answered")}),(0,s.jsx)(e_.s,{text:e.question.answer})]}),"blocked"===e.status&&e.needed&&(0,s.jsx)("p",{className:"small cs-kz-needed",children:k("kz.needed",{needed:e.needed})})]},"".concat(e.at,"-").concat(t))}),F.map(e=>(0,s.jsx)(th,{approval:e,onDecided:g},e.id)),y&&(0,s.jsxs)("p",{className:"cs-working",role:"status",children:[x.acting?(0,s.jsx)(eU.y,{actor:x.acting.actor,acting:x.acting}):(0,s.jsx)("span",{className:"wb-live","aria-hidden":"true"})," ",O?k("kz.chatWorking",{n:M.n,name:S(M.sessionId)}):k("kz.working")]}),N&&(N.sent>0||N.messages>0)&&(0,s.jsx)("p",{className:"muted small cs-kz-count",children:k("kz.counts",{sent:N.sent,max:N.maxSends,messages:N.messages})}),!y&&"queued"!==x.status&&(0,s.jsx)(tr,{task:x}),!y&&(null!=(d=null==(n=C.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:k("lead.evidence")}),(0,s.jsx)("ul",{children:C.at(-1).evidence.map(e=>(0,s.jsx)("li",{children:(0,s.jsx)(e_.s,{text:e})},e))}),(0,s.jsx)("div",{className:"cs-copy-row",children:(0,s.jsx)(V.i8,{text:C.at(-1).evidence.map(e=>"- ".concat(e)).join("\n"),what:"chat.copyEvidence"})})]}),x.runId&&(0,s.jsx)("div",{className:"cs-exchange",children:(0,s.jsx)("a",{className:"button-link quiet small",href:r.FH.taskExchangeUrl(m.id,x.id),download:!0,title:k("chat.exchangeWhy"),children:k("chat.exchange")})}),(null!=(u=null==(c=x.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:k("chat.changed",{n:x.vcs.files.length})}),x.vcs.files.slice(0,12).map(e=>(0,s.jsxs)("button",{type:"button",className:"cs-file",onClick:()=>v(e.path),title:e.path,children:[(0,s.jsx)(_,{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)(eN,{sessionId:m.id,taskId:x.id,runId:x.runId,title:x.title,files:x.vcs.files.length})]})]})}function tf(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)(e1.a,{parked:a.parked,onAnswer:async e=>void await r.FH.answerParked(l,e)})})}function tb(e){let{skill:t}=e,{t:a}=(0,p.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 tg(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)(e_.s,{text:a}),(0,s.jsx)("div",{className:"cs-copy-row",children:(0,s.jsx)(V.i8,{text:a,what:"chat.copyReply"})})]})}function tv(e){var t,a,l,n,i,r,c,o;let{round:d,worker:u,approvals:h,onDecided:m,onOpenFile:x,onRetry:f}=e,{t:b}=(0,p.kj)(),g=(0,eR.p)(),v=d.subtask,j=null==u?void 0:u.tasks.find(e=>e.id===v.taskId),w=(null==j?void 0:j.status)==="running"||(null==j?void 0:j.status)==="waiting-approval",k=ts(null!=(l=null==u?void 0:u.id)?l:"",j),y=null!=(n=v.attempts)?n:[],N=y.at(-1),C=null!=(i=v.maxAttempts)?i:y.length,S=y.slice(0,-1),F=y.length>1,M=!w&&!!N&&"done"!==N.status&&!!N.category,O=!!f&&!!j&&"done"!==j.status&&!w;return(0,s.jsxs)("details",{className:"cs-subtask s-".concat(null!=(r=null==j?void 0:j.status)?r:"queued"),open:w||h.length>0||O||void 0,children:[(0,s.jsxs)("summary",{children:[(0,s.jsx)(t5,{status:null!=(c=null==j?void 0:j.status)?c:"queued"})," ",(0,s.jsx)("span",{children:b("lead.subtask",{n:v.n,title:v.title})}),v.readOnly&&(0,s.jsx)("span",{className:"badge",children:b("lead.readOnly")}),v.fresh&&(0,s.jsx)("span",{className:"badge",children:b("lead.fresh")}),w&&F&&N&&(0,s.jsx)("span",{className:"badge running cs-attempt",children:b("retry.retrying",{k:N.attempt,m:C})}),!w&&F&&(null==j?void 0:j.status)==="done"&&N&&(0,s.jsx)("span",{className:"badge done cs-attempt",children:b("retry.doneAt",{k:N.attempt})}),M&&(0,s.jsx)("span",{className:"badge failed cs-attempt",children:b("retry.attempt",{k:N.attempt,m:C})})]}),(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:b(e2.P3[N.category])})," ",N.reason&&(0,s.jsx)("span",{children:N.reason})]}),S.length>0&&(0,s.jsx)(tj,{attempts:S,max:C,worker:u}),F&&(0,s.jsx)("p",{className:"cs-who cs-attempt-now",children:b("retry.attempt",{k:N.attempt,m:C})}),(0,s.jsx)(tl,{entries:k}),h.map(e=>(0,s.jsx)(th,{approval:e,onDecided:m},e.id)),j&&!w&&"queued"!==j.status&&(0,s.jsx)(tr,{task:j}),j&&(null!=(o=null==(a=j.vcs)||null==(t=a.files)?void 0:t.length)?o:0)>0&&!w&&(0,s.jsx)("div",{className:"cs-files",children:j.vcs.files.slice(0,8).map(e=>(0,s.jsxs)("button",{type:"button",className:"cs-file",onClick:()=>x(e.path),title:e.path,children:[(0,s.jsx)(_,{path:e.path})," ",e.path.split("/").pop()]},e.path))}),O&&f&&(0,s.jsxs)("div",{className:"cs-retry-after",role:"group","aria-label":b("retry.afterStop"),children:[(0,s.jsx)("p",{className:"muted small",children:b("retry.afterStopWhy")}),(0,s.jsxs)("div",{className:"row",children:[(0,s.jsx)("button",{type:"button",className:"primary",...g.mark("same"),onClick:()=>void g.choose("same",()=>f(!1)),children:b("retry.same")}),(0,s.jsx)("button",{type:"button",...g.mark("fresh"),onClick:()=>void g.choose("fresh",()=>f(!0)),children:b("retry.fresh")})]}),(0,s.jsx)(V.T4,{text:(0,e2.qq)(b,v.n,v.title)})]})]})]})}function tj(e){let{attempts:t,max:a,worker:l}=e,{t:n}=(0,p.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)(tw,{attempt:e,max:a,worker:l},e.attempt))]})}function tw(e){var t;let{attempt:a,max:n,worker:i}=e,{t:r}=(0,p.kj)(),c=(0,p.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)(t5,{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(e2.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)(tk,{sessionId:null!=(t=null==i?void 0:i.id)?t:"",task:u})]})]})}function tk(e){let{sessionId:t,task:a}=e,l=ts(t,a);return(0,s.jsx)(tl,{entries:l})}function ty(e){var t;let{approval:a,onDecided:l}=e,{t:n}=(0,p.kj)(),{err:i,choose:c,mark:o}=(0,eR.p)(),d=a.retry,u=async e=>{("restore"!==e||await (0,eP.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}),...tu(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)(eU.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(e2.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(e2.Sx[e])},e))}),i&&(0,s.jsx)("p",{className:"err",role:"alert",children:i}),(0,s.jsx)(V.T4,{text:(0,e2.Mo)(n,a)})]})}function tN(e){var t;let{approval:a,onDecided:n}=e,{t:i}=(0,p.kj)(),c=(0,l.useId)(),[o,d]=(0,l.useState)(""),[u,h]=(0,l.useState)(!1),[m,x]=(0,l.useState)(""),{locked:f,err:b,choose:g,mark:v}=(0,eR.p)(),j=a.question,w=async e=>{let t="revise"===e?m:o;("ran"!==e&&"revise"!==e||t.trim())&&n(a.id,await g(e,async()=>{await r.FH.answerQuestion(a.id,t,e)}))},k=async()=>{await (0,eP.Z)(i("lead.stopConfirm"))&&n(a.id,await g("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"),...tu(a),children:[(0,s.jsxs)("p",{className:"small cs-ask-head",children:[(0,s.jsx)("strong",{children:i("ho.title")})," ",(0,s.jsx)(eU.y,{actor:null!=(t=a.actor)?t:"worker",how:"asks"})]}),(0,s.jsx)(eA.Lp,{card:j.handoff,why:j.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",...v("ran"),disabled:f||!o.trim(),onClick:()=>void w("ran"),children:i("ho.send")}),(0,s.jsx)("button",{type:"button",...v("revise"),"aria-expanded":u,onClick:()=>h(e=>!e),title:i("ho.reviseWhy"),disabled:f,children:i("ho.revise")}),(0,s.jsx)("button",{type:"button",...v("declined"),onClick:()=>void w("declined"),title:i("ho.notRunWhy"),children:i("ho.notRun")}),(0,s.jsx)("button",{type:"button",className:"danger",...v("stop"),onClick:()=>void k(),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=>x(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 w("revise"),children:i("ho.reviseSend")})})]}),b&&(0,s.jsx)("p",{className:"err",role:"alert",children:b}),(0,s.jsx)(V.T4,{text:(0,e2.Mo)(i,a)})]})}function tC(e){var t;let{approval:a,onDecided:n}=e,{t:i}=(0,p.kj)(),c=(0,l.useId)(),{locked:o,err:d,choose:u,mark:h}=(0,eR.p)(),m=a.question,x=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))}))},b=async()=>{await (0,eP.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"===x?"lead.question":"chat.question"),...tu(a),children:[(0,s.jsxs)("p",{className:"small cs-ask-head",children:[(0,s.jsx)("strong",{children:i("lead"===x?"lead.question":"chat.question")})," ",(0,s.jsx)(eU.y,{actor:x,how:"asks"})]}),(0,s.jsx)(e_.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)(V.i8,{text:(0,e2.yw)(i,m,!0),what:"chat.copyQuestion"})}),(0,s.jsx)(e3.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 b(),children:i("lead.stop")})}),d&&(0,s.jsx)("p",{className:"err",role:"alert",children:d}),(0,s.jsx)(V.T4,{text:(0,e2.Mo)(i,a)})]})}function tS(e){let{workspace:t,composeAsk:a,showThread:l,onOpenFile:n,onOpenFolder:i,onTurn:r,onChange:c,onClose:o,grip:d}=e,{t:u}=(0,p.kj)(),h=(0,eq.v)(),m=(0,eL.ms)(h),x=(0,eL.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:x,"aria-label":x,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)(tt,{workspace:t,composeAsk:a,showThread:l,onOpenFile:n,onChange:c,onOpenFolder:i,onTurn:r})]})}var tF=a(5462);let tM=[{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 tO(e){let{open:t,onToggle:a,tab:n,onTab:i,session:r,task:c,newChat:o=!1,onShowMessage:d}=e,{t:u}=(0,p.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,x]=(0,l.useState)(()=>new Set),[f,b]=(0,l.useState)(!1),[g,v]=(0,l.useState)(()=>new Set);(0,l.useEffect)(()=>x(tz()),[]);let j=e=>x(function(e){let t=[...new Set([...tz(),...e.filter(e=>e)])].slice(-500);try{window.localStorage.setItem(tE,JSON.stringify(t))}catch(e){}return new Set(t)}(e)),w=h.filter(e=>!m.has(e.key)),k=f?h:w,y=h.length-w.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:[tM.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&&w.length>0&&(0,s.jsx)("span",{className:"wb-badge",children:w.length})]}),(0,s.jsx)(tF.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)(tI,{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===k.length?(0,s.jsx)("p",{className:"muted small wb-pad",children:u("wb.problemsNoneNew")}):(0,s.jsx)("ul",{className:"wb-problems",children:k.map((e,t)=>{let a=g.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,v(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:()=>j([e.key]),title:u("wb.problemSeenWhy"),children:u("wb.problemSeen")})]}),a&&r&&(0,s.jsx)(tL,{id:"wb-problem-".concat(t),problem:e,session:r,onShowMessage:d})]},e.key)})}),(w.length>1||y>0)&&(0,s.jsxs)("div",{className:"row wb-pad",children:[w.length>1&&(0,s.jsx)("button",{type:"button",className:"quiet small",onClick:()=>j(w.map(e=>e.key)),title:u("wb.problemSeenWhy"),children:u("wb.problemsAllSeen")}),y>0&&(0,s.jsx)("button",{type:"button",className:"quiet small",onClick:()=>b(!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)(tD,{session:r})})]})}let tq={check:"wb.problemFromCheck",review:"wb.problemFromReview",stop:"wb.problemFromStop",vcs:"wb.problemFromVcs"};function tL(e){var t;let{id:a,problem:n,session:i,onShowMessage:r}=e,{t:c}=(0,p.kj)(),o=(0,p.W3)(),d=c("status.".concat(n.status)),u=c(tq[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: /,""),x=(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",x?"".concat(m," (").concat(c("wb.problemInCopilot",{name:x}),")"):m],["wb.problemMessage","".concat(n.n,". ").concat(n.title)],...n.place?[["wb.problemPlace",n.place]]:[]],b=[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)(V.i8,{text:b,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 tE="cop.problems.seen";function tz(){try{var e;let t=JSON.parse(null!=(e=window.localStorage.getItem(tE))?e:"[]");return new Set(Array.isArray(t)?t.filter(e=>"string"==typeof e):[])}catch(e){return new Set}}function tI(e){var t,a;let{session:n,task:i}=e,{t:c}=(0,p.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}=eT(!!u,null!=(t=null==o?void 0:o.entries.length)?t:0),x=()=>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),x()},[null==i?void 0:i.id,null==i?void 0:i.runId]),(0,m.z)(x,u?2e3:15e3,!!n&&!!i),!i)return(0,s.jsx)("p",{className:"muted small wb-pad",children:c("wb.pickChat")});let f=[],b=e=>e.forEach(e=>"step"===e.kind?f.push(e):"review"===e.kind?b(e.entries):void 0);return(b(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 tD(e){let{session:t}=e,{t:a}=(0,p.kj)(),n=(0,p.W3)(),[i,c]=(0,l.useState)([]),{ref:o}=eT(!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 tW(e){var t,a,n,i,c,o,d,u,h,x,f;let{sessions:b,session:g,workspace:v,onShowThread:j,onApprovals:w,onShowWaiting:k}=e,{t:y}=(0,p.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),[C,S]=(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)(w);O.current=w,(0,m.z)(()=>r.FH.approvals().then(e=>{var t;S(e),null==(t=O.current)||t.call(O,e)}).catch(()=>void 0),3e3);let q=null!=(c=b.find(e=>"idle"!==e.status&&!e.workerOf))?c:b.find(e=>"idle"!==e.status),L=null==q?void 0:q.tasks.find(e=>"running"===e.status||"waiting-approval"===e.status),E=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==L?void 0:L.startedAt,null==q?void 0:q.pauses,N)/6e4);return(0,s.jsxs)("footer",{className:"wb-statusbar","aria-label":y("wb.status"),children:[(null==v?void 0:v.ok)&&(0,s.jsxs)("span",{title:v.dir,children:[(0,s.jsx)(et.O,{})," ",v.branch?"".concat(v.name," \xb7 ").concat(v.branch):v.name]}),q&&L?(0,s.jsxs)("button",{type:"button",className:"wb-status-btn",onClick:()=>j(q.id),title:y("wb.openRunning"),children:[(0,s.jsx)("span",{className:q.paused?"wb-live paused":"wb-live","aria-hidden":"true"})," ",L.acting&&(0,s.jsx)(eU.y,{actor:L.acting.actor,acting:L.acting})," ",L.lead?y("wb.runningLineTwo",{session:q.name.replace(/^chat: /,""),task:L.title,lead:null!=(o=null==(t=L.lead.messages)?void 0:t.lead)?o:0,worker:null!=(d=null==(a=L.lead.messages)?void 0:a.worker)?d:0,total:(null!=(u=null==(n=L.lead.messages)?void 0:n.lead)?u:0)+(null!=(h=null==(i=L.lead.messages)?void 0:i.worker)?h:0),m:E,maxm:F.minutes}):y("wb.runningLine",{session:q.name.replace(/^chat: /,""),task:L.title,n:L.iterations,max:F.iterations,m:E,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"}),C.length>0&&(0,s.jsx)("button",{type:"button",className:"wb-status-btn warn",onClick:()=>{var e;let t=C[0];!t.model&&(null==k?void 0:k(t))||null==(e=document.querySelector(".approval-banner"))||e.scrollIntoView({block:"start"})},children:y("wb.waiting",{n:C.length})}),g&&(0,s.jsx)("span",{title:y("wb.modelNow"),children:null!=(f=null!=(x=g.modelInUse)?x:g.model)?f:y("wb.modelDefault")})]})}var tH=a(1702);function tR(e){let{commands:t,onClose:a}=e,{t:n}=(0,p.kj)(),i=(0,tH.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),x=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(),x(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:()=>x(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 tA(){let{t:e}=(0,p.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)("p",{children:e("kerrigan.aboutHow",{button:e("kerrigan.button"),copy:e("kerrigan.copy"),save:e("kerrigan.save")})}),(0,s.jsx)("p",{className:"muted small",children:e("kerrigan.aboutNote")})]})}function tT(e){let{workspace:t}=e,{t:a,locale:n}=(0,p.kj)(),i=(0,tF.f)("below"),[c,o]=(0,l.useState)(""),[d,u]=eW(),[h,m]=(0,l.useState)([]);(0,l.useEffect)(()=>{r.FH.skills().then(e=>m(e.skills)).catch(()=>void 0)},[]);let x=e=>e.trim().replace(/[\\/]+$/,"").replace(/\//g,"\\").toLowerCase(),f=h.filter(e=>!e.projectDir||(null==t?void 0:t.ok)&&x(e.projectDir)===x(t.dir)),b=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}},g=async()=>{i.close();let e=await b();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}))},v=async()=>{i.close();let e=await b();e&&o(await (0,V.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||b(),i.toggle()},children:[a("kerrigan.button")," ",(0,s.jsx)("span",{"aria-hidden":"true",children:"▾"})]}),(0,s.jsx)(tF.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)(tF.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 g(),children:a("kerrigan.save")}),(0,s.jsx)("button",{type:"button",role:"menuitem",onClick:()=>void v(),children:a("kerrigan.copy")})]}),c&&(0,s.jsx)("p",{className:"small",role:"status",children:c})]})}var tP=a(83285);let tB=(e,t)=>0===t||/[/\\._\-\s]/.test(e[t-1])||/[a-z]/.test(e[t-1])&&/[A-Z]/.test(e[t]);function t_(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(tB(e,s)){t=s;break}l+=1,t===i+1&&(l+=5),tB(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 t$(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 tU(e){let{recent:t,onOpen:a,onClose:n}=e,{t:i}=(0,p.kj)(),[c,o]=(0,l.useState)(null),[d,u]=(0,l.useState)(""),[h,m]=(0,l.useState)(0),[x,f]=(0,l.useState)(!1),b=(0,l.useRef)(null),g=(0,l.useRef)(null);(0,l.useEffect)(()=>{var e;return null==(e=b.current)?void 0:e.focus()},[]),(0,l.useEffect)(()=>{r.FH.workspaceFiles().then(e=>o(e.files)).catch(()=>o([]))},[]);let{query:v,line:j}=function(e){let t=/^(.*?):(\d+)(?::\d+)?\s*$/.exec(e);return t?{query:t[1],line:Number(t[2])}:{query:e}}(d),w=(0,l.useMemo)(()=>{if(!c)return[];if(!v.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=t_(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=t_(l,t);if(a){i+=a.score+10+8*!!l.toLowerCase().startsWith(t.toLowerCase()),r.push(...a.hits);continue}let n=t_(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,v,60)},[c,v,t]),k=0===w.length?-1:Math.min(h,w.length-1);(0,l.useEffect)(()=>{var e,t;null==(t=g.current)||null==(e=t.querySelector('[aria-selected="true"]'))||e.scrollIntoView({block:"nearest"})},[k]);let y=e=>{e&&(n(),a(e.path,j))};return(0,l.useEffect)(()=>{x&&c&&(f(!1),y(w[0]))},[x,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:b,type:"text",role:"combobox","aria-expanded":"true","aria-controls":"qo-list","aria-activedescendant":k>=0?"qo-".concat(k):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(w.length-1,k+1))):"ArrowUp"===e.key?(e.preventDefault(),m(Math.max(0,k-1))):"Enter"===e.key&&(e.preventDefault(),c?y(w[k]):f(!0))}}),(0,s.jsxs)("ul",{id:"qo-list",ref:g,role:"listbox","aria-label":i("quick.label"),children:[c&&0===w.length&&(0,s.jsx)("li",{className:"muted small qo-none",children:i("quick.none")}),w.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===k,className:"qo-row".concat(t===k?" on":""),onMouseEnter:()=>m(t),onClick:()=>y(e),title:e.path,children:[(0,s.jsx)(_,{path:e.path}),(0,s.jsx)("span",{className:"qo-name",children:t$(l,e.nameHits)}),n&&(0,s.jsx)("span",{className:"qo-dir",children:t$(n,e.dirHits)}),"recent"in e&&e.recent&&(0,s.jsx)("span",{className:"qo-tag",children:i("quick.recent")})]},e.path)})]})]})})}function tK(e){var t;let{onOpen:a,grip:n,focusAsk:i}=e,{t:c}=(0,p.kj)(),[o,d]=(0,l.useState)(""),[u,h]=(0,l.useState)(!1),[m,x]=(0,l.useState)(!1),[f,b]=(0,l.useState)(!1),[g,v]=(0,l.useState)(!1),[j,w]=(0,l.useState)(""),[k,y]=(0,l.useState)(""),[N,C]=(0,l.useState)(null),[S,F]=(0,l.useState)(!1),[M,O]=(0,l.useState)(""),[q,L]=(0,l.useState)(new Set),E=(0,l.useRef)(null),z=(0,l.useRef)(0);(0,l.useEffect)(()=>{if(i>0){var e,t;null==(e=E.current)||e.focus(),null==(t=E.current)||t.select()}},[i]);let I=async()=>{let e=++z.current;if(!o){C(null),F(!1),O("");return}F(!0);try{let t=await r.FH.workspaceSearch(o,{matchCase:u,wholeWord:m,regex:f,include:j,exclude:k});if(e!==z.current)return;C(t),O(""),L(new Set)}catch(t){e===z.current&&O(t.message)}finally{e===z.current&&F(!1)}};(0,l.useEffect)(()=>{let e=setTimeout(()=>void I(),300);return()=>clearTimeout(e)},[o,u,m,f,j,k]);let D=null!=(t=null==N?void 0:N.files)?t:[],W=D.length>0&&D.every(e=>q.has(e.path)),H=(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}),R=S?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 I(),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(""),C(null),null==(e=E.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:()=>L(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(g?" on":""),"aria-expanded":g,"aria-label":c("search.details"),title:c("search.details"),onClick:()=>v(!g),children:"…"}),(0,s.jsxs)("div",{className:"sv-box",children:[(0,s.jsx)("input",{ref:E,type:"text",value:o,onChange:e=>d(e.target.value),onKeyDown:e=>{"Enter"===e.key&&I()},placeholder:c("search.input"),"aria-label":c("search.input"),spellCheck:!1}),H(c("search.matchCase"),u,h,"Aa","case"),H(c("search.wholeWord"),m,x,(0,s.jsx)("span",{className:"sv-word",children:"ab"}),"word"),H(c("search.regex"),f,b,".*","regex")]})]}),g&&(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:j,onChange:e=>w(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:k,onChange:e=>y(e.target.value),placeholder:c("search.excludePlaceholder"),spellCheck:!1})]}),R&&(0,s.jsx)("p",{className:"sv-message".concat(M||(null==N?void 0:N.problem)?" bad":""),role:"status",children:R}),(null==N?void 0:N.truncated)&&!S&&(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:()=>L(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)(_,{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 tV=["side","center","chat"],tZ="application/x-cop-area",tJ=["wb.moveLeft","wb.moveCenter","wb.moveRight"];function tG(e){let{name:t,place:a,onMove:l,onDragging:n}=e,{t:i}=(0,p.kj)(),r=(0,tF.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(tZ,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:tJ.map((e,t)=>(0,s.jsx)("button",{type:"button",role:"menuitem",disabled:t===a,onClick:()=>{r.close(),l(t)},children:i(e)},e))})]})}let tY=e=>{var t;return"diff"===e.kind?"d:".concat(e.area,":").concat(null!=(t=e.commit)?t:"",":").concat(e.path):"f:".concat(e.path)},tX={side:290,chat:420,bottom:240,sideOpen:!0,chatOpen:!0,bottomOpen:!0,order:tV},tQ="cop.workbench.layout";function t0(){return(0,s.jsx)(l.Suspense,{fallback:null,children:(0,s.jsx)(t1,{})})}function t1(){let{t:e}=(0,p.kj)(),[t,a]=(0,l.useState)(null),[n,c]=(0,l.useState)([]),[o,d]=(0,l.useState)(""),[u,h]=(0,l.useState)("files"),[f,b]=(0,l.useState)(""),[g,v]=(0,l.useState)(null),[j,w]=(0,l.useState)(null),[k,y]=(0,l.useState)("terminal"),[N,C]=(0,l.useState)(tX),[S,F]=(0,l.useState)(!1),[M,O]=(0,l.useState)(0),[q,L]=(0,l.useState)(null),[E,z]=(0,l.useState)(new Set),I=(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),z(a=>{if(a.has(e)===t)return a;let s=new Set(a);return t?s.add(e):s.delete(e),s})},[]),D=(0,l.useCallback)(()=>r.FH.sessions().then(e=>a(e.filter(e=>"chat"===e.kind))).catch(()=>void 0),[]);(0,m.z)(D,3e3);let W=(0,l.useCallback)(()=>r.FH.workspace().then(v).catch(()=>void 0),[]);(0,m.z)(W,1e4);let H=(0,l.useCallback)(async()=>{try{var e;let t=await r.FH.browseFolder((null==g?void 0:g.dir)||void 0);if(!t.ok)return;let a=await r.FH.settings();await r.FH.saveSettings({...a.raw,project:{...null!=(e=a.raw.project)?e:{},rootDir:t.path}}),await W()}catch(e){b(e.message)}},[null==g?void 0:g.dir,W]);(0,l.useEffect)(()=>C(function(){try{var e;let t=window.localStorage.getItem(tQ);if(!t)return tX;let a={...tX,...JSON.parse(t)};return{...a,order:(e=a.order,Array.isArray(e)&&3===e.length&&tV.every(t=>e.includes(t))?e:tV)}}catch(e){return tX}}()),[]),(0,l.useEffect)(()=>{try{window.localStorage.setItem(tQ,JSON.stringify(N))}catch(e){}},[N]);let R=(0,l.useCallback)(e=>{let t=tY(e);c(a=>{let s=a.findIndex(e=>tY(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)},[]),[A,T]=(0,l.useState)(null),[P,B]=(0,l.useState)(!1),[$,U]=(0,l.useState)(null),[K,V]=(0,l.useState)(0),Z=(0,l.useCallback)((e,t)=>{R({kind:"file",path:e.path,...t?{}:{preview:!0}}),U(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}})},[R]),J=()=>{h("search"),ee({sideOpen:!0}),V(e=>e+1)},G=async t=>{let a=n.find(e=>tY(e)===t);if((null==a?void 0:a.kind)==="file"&&E.has(a.path)){var s;if(!await (0,eP.Z)(e("ed.closeUnsaved",{name:null!=(s=a.path.split("/").pop())?s:a.path})))return;I(a.path,!1)}c(e=>{let a=e.findIndex(e=>tY(e)===t),s=e.filter(e=>tY(e)!==t);return t===o&&d(s[Math.max(0,a-1)]?tY(s[Math.max(0,a-1)]):""),s})},Y=n.find(e=>tY(e)===o),X=j&&"new"!==j?null==t?void 0:t.find(e=>e.id===j.sessionId):void 0,Q=j&&"new"!==j?null==X?void 0:X.tasks.find(e=>e.id===j.taskId):void 0,ee=e=>C(t=>({...t,...e})),et=e=>{let t=n.find(t=>tY(t)===e);t&&(c(t=>t.map(t=>tY(t)===e&&t.preview?{...t,preview:!1}:t)),h("files"),ee({sideOpen:!0}),T(e=>{var a;return{path:t.path,n:(null!=(a=null==e?void 0:e.n)?a:0)+1}}))},es=()=>{ee({chatOpen:!0}),O(e=>e+1)},el=(0,l.useRef)(new Set),en=e=>{var a;let s=null==t?void 0:t.find(t=>t.id===e.sessionId);if(!s)return!1;ee({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(te(e4)))return!0;let n=null!=(a=l.at(-1))?a:s.id;return L(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(),F(!0)):"p"===t?(e.preventDefault(),B(!0)):"f"===t&&e.shiftKey?(e.preventDefault(),J()):"e"===t&&e.shiftKey?(e.preventDefault(),h("files"),ee({sideOpen:!0})):"b"!==t||e.shiftKey?"j"===t?(e.preventDefault(),ee({bottomOpen:!N.bottomOpen})):"l"===t&&(e.preventDefault(),es()):(e.preventDefault(),ee({sideOpen:!N.sideOpen}))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[N]);let ei=(0,l.useMemo)(()=>[{id:"chat",label:e("wb.cmdChat"),hint:"Ctrl+L",run:es},{id:"side",label:e("wb.cmdSide"),hint:"Ctrl+B",run:()=>ee({sideOpen:!N.sideOpen})},{id:"panel",label:e("wb.cmdPanel"),hint:"Ctrl+J",run:()=>ee({bottomOpen:!N.bottomOpen})},{id:"quick-open",label:e("wb.cmdQuickOpen"),hint:"Ctrl+P",run:()=>B(!0)},{id:"search",label:e("wb.cmdSearch"),hint:"Ctrl+Shift+F",run:J},{id:"layout",label:e("wb.cmdResetLayout"),run:()=>ee({order:tV,side:tX.side,chat:tX.chat})},{id:"files",label:e("wb.cmdFiles"),run:()=>{ee({sideOpen:!0}),h("files")}},{id:"commits",label:e("wb.cmdCommits"),run:()=>{ee({sideOpen:!0}),h("commits")}},{id:"problems",label:e("wb.cmdProblems"),run:()=>{ee({bottomOpen:!0}),y("problems")}},...Y?[{id:"keep-tab",label:e("wb.cmdKeepTab"),run:()=>et(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:()=>{ee({chatOpen:!0}),L(e=>{var a;return{id:t.id,n:(null!=(a=null==e?void 0:e.n)?a:0)+1}})}}))],[t,e,N,o,n]),[er,ec]=(0,l.useState)(!1),[eo,ed]=(0,l.useState)(null),eu=e=>N.order.indexOf(e),eh=N.order.filter(e=>"side"===e?N.sideOpen:"chat"!==e||N.chatOpen),em=eh.map(e=>1===eu(e)?"minmax(0, 1fr)":"".concat(0===eu(e)?N.side:N.chat,"px"));em.length>0&&!em.includes("minmax(0, 1fr)")&&(em[em.length-1]="minmax(0, 1fr)");let ep=["46px",...em.flatMap((e,t)=>0===t?[e]:["5px",e])].join(" "),ex=(e,t)=>ee({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}(N.order,e,t)}),ef=(e,t)=>(0,s.jsx)(tG,{area:e,name:t,place:eu(e),onMove:t=>ex(e,t),onDragging:ec}),eb=t=>({"data-area":t,"data-drop":e("wb.dropHere"),onDragOver:e=>{e.dataTransfer.types.includes(tZ)&&(e.preventDefault(),e.dataTransfer.dropEffect="move",eo!==t&&ed(t))},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||ed(e=>e===t?null:e)},onDrop:e=>{let a=e.dataTransfer.getData(tZ);e.preventDefault(),ed(null),ec(!1),a&&a!==t&&N.order.includes(a)&&ex(a,eu(t))}}),eg=e=>"".concat(er?" wb-drop":"").concat(eo===e?" wb-drop-over":""),ej={"--wb-columns":ep,"--wb-side":N.sideOpen?"".concat(N.side,"px"):"0px","--wb-chat":N.chatOpen?"".concat(N.chat,"px"):"0px","--wb-bottom":N.bottomOpen?"".concat(N.bottom,"px"):"34px"},ew={side:(0,s.jsxs)("aside",{className:"wb-side".concat(eg("side")),"aria-label":e("wb.explorer"),hidden:!N.sideOpen,...eb("side"),children:[(0,s.jsx)("div",{className:"wb-side-view",hidden:"search"!==u,children:(0,s.jsx)(tK,{onOpen:Z,grip:"search"===u?ef("side",e("wb.explorer")):void 0,focusAsk:K})}),"search"!==u&&(0,s.jsx)(ea,{view:u,onOpen:R,reveal:A,workspace:g,onOpenFolder:()=>void H(),grip:ef("side",e("wb.explorer"))})]},"side"),center:(0,s.jsxs)("section",{className:"wb-center".concat(eg("center")),"aria-label":e("wb.editor"),...eb("center"),children:[(0,s.jsxs)("div",{className:"wb-tabs",role:"tablist","aria-label":e("wb.openTabs"),children:[ef("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=tY(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:()=>et(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)(_,{path:t.path}),(0,s.jsx)("span",{className:"wb-tab-label",children:r}),"file"===t.kind&&E.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 G(i),children:"\xd7"})]},i)})]}),(0,s.jsxs)("div",{className:"wb-editor",role:"tabpanel",children:[Y?"diff"===Y.kind?(0,s.jsx)(eO,{area:Y.area,path:Y.path,commit:Y.commit},tY(Y)):null:(0,s.jsx)(t6,{workspace:g,problem:f}),n.map(e=>"file"===e.kind?(0,s.jsx)("div",{className:"wb-file-pane",hidden:tY(e)!==o,children:(0,s.jsx)(ev,{path:e.path,onDirty:I,goTo:(null==$?void 0:$.path)===e.path?$:void 0,onOpenFile:e=>R({kind:"file",path:e})})},tY(e)):null)]}),N.bottomOpen&&(0,s.jsx)(t4,{axis:"y",label:e("wb.resize"),onDrag:e=>ee({bottom:t2(N.bottom-e,90,700)})}),(0,s.jsx)(tO,{open:N.bottomOpen,onToggle:()=>ee({bottomOpen:!N.bottomOpen}),tab:k,onTab:e=>{y(e),ee({bottomOpen:!0})},session:X,task:Q,newChat:"new"===j,onShowMessage:e=>{ee({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(eg("chat")),"aria-label":e("wb.chatPanel"),hidden:!N.chatOpen,...eb("chat"),children:(0,s.jsx)(tS,{workspace:g,composeAsk:M,showThread:q,onOpenFile:e=>R({kind:"file",path:e}),onOpenFolder:()=>void H(),onTurn:w,onChange:()=>void D(),onClose:()=>ee({chatOpen:!1}),grip:ef("chat",e("wb.chatPanel"))})},"chat")};return(0,s.jsxs)("div",{className:"wb",style:ej,children:[(0,s.jsxs)("header",{className:"wb-top",children:[(0,s.jsxs)("span",{className:"wb-brand",children:[(0,s.jsx)(tP.g,{}),"copilot-operator"]}),(0,s.jsxs)("button",{type:"button",className:"wb-search",onClick:()=>F(!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)(x.i,{})]})]}),(0,s.jsxs)("div",{className:"wb-body".concat(N.sideOpen?"":" no-side").concat(N.chatOpen?"":" no-chat"),children:[(0,s.jsx)(t3,{side:u,sideOpen:N.sideOpen,onSide:e=>{e===u&&N.sideOpen?ee({sideOpen:!1}):(h(e),ee({sideOpen:!0}))},chatOpen:N.chatOpen,onChat:()=>ee({chatOpen:!N.chatOpen}),workspace:g}),N.order.map(t=>{let a=eh.indexOf(t),n=a>0?eh[a-1]:null;return(0,s.jsxs)(l.Fragment,{children:[n&&(0,s.jsx)(t4,{axis:"x",label:e("wb.resize"),onDrag:e=>{0===eu(n)?ee({side:t2(N.side+e,180,820)}):2===eu(t)&&ee({chat:t2(N.chat-e,260,820)})}}),ew[t]]},t)})]}),(0,s.jsx)(tW,{sessions:null!=t?t:[],session:X,workspace:g,onShowThread:e=>{ee({chatOpen:!0}),L(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!el.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)el.current.add(e.id);a[0]&&en(a[0])},onShowWaiting:en}),S&&(0,s.jsx)(tR,{commands:ei,onClose:()=>F(!1)}),P&&(0,s.jsx)(tU,{recent:n.filter(e=>"file"===e.kind).map(e=>e.path).reverse(),onOpen:(e,t)=>t?Z({path:e,line:t}):R({kind:"file",path:e,preview:!0}),onClose:()=>B(!1)})]})}let t2=(e,t,a)=>Math.max(t,Math.min(a,e));function t3(e){var t,a;let{side:n,sideOpen:i,onSide:c,chatOpen:o,onChat:d,workspace:u}=e,{t:x}=(0,p.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})]}),b=!!(null==u?void 0:u.ok),[g]=h(b?u.dir:""),[v,j]=(0,l.useState)(null),w=(0,l.useCallback)(()=>r.FH.workspaceGitCounts(g||void 0).then(j).catch(()=>j(null)),[g]);(0,l.useEffect)(()=>{j(null),b&&w()},[w,b,null==u?void 0:u.dir]),(0,m.z)(w,5e3,b);let k=(null==v?void 0:v.isRepo)?v.uncommitted:0,y=(null==v?void 0:v.isRepo)&&null!=(t=v.branch)?t:0,N=x("git.badgeUncommitted",{n:k}),C=x("git.badgeBranch",{n:y,base:null!=(a=null==v?void 0:v.base)?a:""}),S=[...k>0?[N]:[],...y>0?[C]:[]].join(" \xb7 "),F=e=>e>99?"99+":String(e),M=(0,s.jsxs)(s.Fragment,{children:[k>0&&(0,s.jsx)("span",{className:"wb-act-badge uncommitted","aria-hidden":"true",children:F(k)}),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":x("wb.views"),children:[f("files",x("wb.viewFiles"),(0,s.jsx)("path",{d:"M4 4h6l2 2h8v14H4z"})),f("search",x("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",x("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:S,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":x("wb.toggleChat"),title:"".concat(x("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 t4(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 t5(e){var t;let{status:a}=e,{t:l}=(0,p.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 t6(e){let{workspace:t,problem:a}=e,{t:l}=(0,p.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)(tT,{workspace:t}),(0,s.jsx)(tA,{}),(0,s.jsx)("p",{className:"muted small",children:l("wb.keys")})]})}function t8(){return(0,s.jsx)(t0,{})}},92364:(e,t,a)=>{Promise.resolve().then(a.bind(a,55522))}},e=>{e.O(0,[8197,7921,895,8124,1024,2347,3131,7358],()=>e(e.s=92364)),_N_E=e.O()}]);
|
|
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"})]})}},55522:(e,t,a)=>{"use strict";a.r(t),a.d(t,{default:()=>t8});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),p=a(8205),x=a(16752);let f=[{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"}],b={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"},g={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 v(e){var t;let a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",s=e.split("/").pop().toLowerCase();if(g[s])return g[s];if(s.startsWith(".env."))return"ini";if(s.startsWith("dockerfile."))return"dockerfile";let l=s.lastIndexOf(".");if(l>0&&b[s.slice(l+1)])return b[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 j=e=>e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">"),w=(e,t)=>'<span class="hl-'.concat(e,'">').concat(j(t),"</span>"),k=e=>new Set(e.split(/\s+/).filter(Boolean)),y=k("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"),N=new Set([...y,...k("interface type enum implements namespace module declare abstract private protected public readonly keyof infer is asserts override accessor unique")]),C=k("string number boolean bigint symbol object unknown any never void undefined Record Partial Required Readonly Pick Omit Promise Array Map Set Date Error RegExp"),S=k("true false null undefined NaN Infinity"),F={typescript:{line:["//"],block:[["/*","*/"]],quotes:['"',"'","`"],multiline:["`"],keywords:N,types:C,literals:S,calls:!0,sigil:/^@[A-Za-z_]\w*/},javascript:{line:["//"],block:[["/*","*/"]],quotes:['"',"'","`"],multiline:["`"],keywords:y,literals:S,calls:!0},csharp:{line:["//"],block:[["/*","*/"]],quotes:['"',"'"],calls:!0,literals:k("true false null"),keywords:k("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:k("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:k("true false null"),keywords:k("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:k("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:k("true false null"),keywords:k("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:k("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:k("true false nil iota"),keywords:k("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:k("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:k("true false None Some Ok Err"),keywords:k("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:k("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:k("true false NULL"),keywords:k("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:k("char double float int long short signed unsigned void size_t bool"),sigil:/^#\s*\w+/},cpp:{line:["//"],block:[["/*","*/"]],quotes:['"',"'"],calls:!0,literals:k("true false nullptr NULL"),keywords:k("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:k("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:k("true false nil"),keywords:k("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:k("Int Double Float Bool String Character Array Dictionary Set Optional Void"),sigil:/^@[A-Za-z_]\w*/},dart:{line:["//"],block:[["/*","*/"]],quotes:['"',"'"],calls:!0,literals:k("true false null"),keywords:k("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:k("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:k("true false null"),keywords:k("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:k("true false nil"),keywords:k("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:k("$true $false $null"),keywords:k("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:k("True False None"),keywords:k("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:k("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:k("true false nil"),keywords:k("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:k("true false"),keywords:k("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:k("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:k("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:k("ifeq ifneq ifdef ifndef else endif include define endef export override .PHONY"),sigil:/^\$(?:\([^)]*\)|\{[^}]*\}|[@<^*?%])/},sql:{line:["--"],block:[["/*","*/"]],quotes:["'",'"'],caseless:!0,calls:!0,literals:k("true false null"),keywords:k("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:k("int integer bigint smallint decimal numeric float real double varchar char text date time timestamp boolean bool uuid json jsonb blob")}};function M(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],x=null==(r=t.block)?void 0:r.find(e=>{let[t]=e;return n(t)});if(x){let t=e.indexOf(x[1],s+x[0].length),n=t<0?l:t+x[1].length;a+=w("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+=w("com",e.slice(s,n)),s=n;continue}let f=i.find(t=>e.startsWith(t,s));if(f){let n=s+f.length,i=null==(o=t.multiline)?void 0:o.includes(f),r=t!==F.powershell&&t!==F.batch&&(t!==F.shell&&t!==F.sql||"'"!==f);for(;n<l;){if("\\"===e[n]&&r){n+=2;continue}if(e.startsWith(f,n)){n+=f.length;break}if("\n"===e[n]&&!i)break;n+=1}a+=w("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+=w("@"===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+=w("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!==F.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+=w(r,n):t.calls&&"("===e[s+n.length]?a+=w("fn",n):/^[A-Z][a-z]\w*$/.test(n)&&t.types?a+=w("type",n):t===F.powershell&&/^[A-Z][a-z]+-[A-Z]\w*$/.test(n)?a+=w("fn",n):a+=j(n),s+=n.length;continue}}a+=j(p),s+=1}return a}function O(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+=w("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+=w("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+=w(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+=j(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+=w("str",e.slice(s,n)),s=n;continue}let n=/^[^\s=>/"']+/.exec(e.slice(s,s+100));if(n){a+=w("attr",n[0]),s+=n[0].length;continue}a+=j(e[s]),s+=1}s<l&&(a+=w("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?M(c,F.javascript):q(c,!1),s=i}continue}if("&"===e[s]){let t=/^&[#\w]+;/.exec(e.slice(s,s+12));if(t){a+=w("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+=j(e.slice(s,c)),s=c}return a}function q(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+=w("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+=w("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+=w("str",e.slice(s,t+1)),s=t+1;continue}if("@"===c){let t=/^@[\w-]+/.exec(e.slice(s,s+40));if(t){a+=w("kw",t[0]),s+=t[0].length;continue}}if("$"===c&&t){let t=/^\$[\w-]+/.exec(e.slice(s,s+60));if(t){a+=w("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+=j(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+=w("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+=w("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))?w("prop",l):i?/^(important|inherit|initial|unset|none|auto)$/.test(l)?w("lit",l):"("===e[s+l.length]?w("fn",l):j(l):w("tag",l),s+=l.length;continue}}a+=j(c),s+=1}return a}let L={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"}},E={glyph:"image",color:"#a074c4"},z={glyph:"archive",color:"#a07d3e"},I={png:E,jpg:E,jpeg:E,gif:E,webp:E,ico:E,bmp:E,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:z,gz:z,"7z":z,tgz:z,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"}},D={glyph:"git",color:"#f14e32"},W={".gitignore":D,".gitattributes":D,".gitmodules":D,"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(L),...Object.values(I),...Object.values(W)].filter(e=>!!e);let H=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))},R=e=>{let[t,a,s]=e;return"#".concat([t,a,s].map(e=>Math.round(e).toString(16).padStart(2,"0")).join(""))};function A(e){let[t,a,s]=H(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 T=new Map;function P(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 B=e=>({"--ico":e.color,"--ico-dark":function(e){let t=T.get(e);if(t)return t;let a=H(e),s=R(a);for(let e=.12;e<=1&&!(function(e,t){let[a,s]=[A(e),A(t)].sort((e,t)=>t-e);return(a+.05)/(s+.05)}(s=R(a.map(t=>t+(255-t)*e)),"#152436")>=4.8);e+=.04);return T.set(e,s),s}(e.color)});function _(e){var t;let{path:a}=e,l=function(e){var t;let a=e.split("/").pop().toLowerCase();if(W[a])return W[a];let s=a.lastIndexOf("."),l=s>0?a.slice(s+1):"";return I[l]?I[l]:null!=(t=L[v(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:B(l),children:(0,s.jsx)(P,{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:B(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 $={staged:"git.uncommitted.staged",changes:"git.uncommitted.changes",untracked:"git.uncommitted.untracked",mixed:"git.uncommitted.mixed"};function U(e){var t,a,n;let{data:i,onBase:r,onOpenFile:c,statusName:o}=e,{t:d}=(0,p.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,x=m.filter(e=>e.uncommitted),f=m.filter(e=>e.committed),b="committed"===u?f:"uncommitted"===u?x:m,g=m.reduce((e,t)=>e+Math.max(0,t.added),0),v=m.reduce((e,t)=>e+Math.max(0,t.removed),0),j=(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:["+",g]})," ",(0,s.jsxs)("span",{className:"minus",children:["−",v]})]})]})]}),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:[j("all",d("git.filterAll",{n:m.length})),j("committed",d("git.filterCommitted",{n:f.length})),j("uncommitted",d("git.filterUncommitted",{n:x.length}))]}),x.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===b.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:b.map(e=>(0,s.jsx)(K,{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 K(e){let{f:t,onOpen:a,statusName:l}=e,{t:n}=(0,p.kj)(),i=t.path.lastIndexOf("/"),r=t.uncommitted?n($[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)(_,{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 V=a(24872);let Z=e=>"cop.git.message:".concat(e.toLowerCase()),J="cop.git.opSeen",G=e=>{try{var t;return null!=(t=localStorage.getItem(e))?t:""}catch(e){return""}},Y=(e,t)=>{try{t?localStorage.setItem(e,t):localStorage.removeItem(e)}catch(e){}};function X(e){var t;let{state:a,onChanged:n,onOpen:i}=e,{t:c}=(0,p.kj)(),[o,d]=(0,l.useState)(""),[u,h]=(0,l.useState)(null),[x,f]=(0,l.useState)(""),[b,g]=(0,l.useState)(!1),v=(0,l.useRef)(""),j=(0,l.useRef)(n);j.current=n;let w=a.dir;(0,l.useEffect)(()=>{d(G(Z(w)))},[w]);let k=(0,l.useCallback)(e=>{d(e),Y(Z(w),e)},[w]),y=(0,l.useCallback)(()=>r.FH.gitOp().then(e=>{let{op:t}=e;if(!t||t.id===G(J))return h(null);h(t),"running"!==t.state&&v.current!==t.id&&(v.current=t.id,j.current(),"commit"===t.kind&&"done"===t.state&&void 0!==t.message&&G(Z(w)).trim()===t.message.trim()&&k(""))}).catch(()=>void 0),[w,k]);(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"||b,C=a.staged.length,S=a.changes.length,F=0===C,M=F?S:C,O=a.upstream,q=!!a.branch&&"HEAD"!==a.branch,L=e=>{f(""),g(!0),e().then(e=>{Y(J,""),h(e)}).catch(e=>f(e.message)).finally(()=>g(!1))},E=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 L(()=>r.FH.gitCommit(t,a,e))},z=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return L(()=>r.FH.gitPush(e))},I=(e,t)=>{var a,s;return"commit"===e.kind?E(t,null!=(a=e.message)?a:o,null!=(s=e.all)?s:F):z(t)},D=o.trim()?0===M?c("git.nothingToCommit"):F?c("git.commitAllWhy",{n:S}):c("git.commitWhy",{n:C}):c("git.commitNeedsMessage"),W=null!=(t=null==O?void 0:O.name)?t:"",H=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=>k(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.ctrlKey||e.metaKey)&&o.trim()&&M>0&&!N&&(e.preventDefault(),E())},disabled:N}),(0,s.jsxs)("div",{className:"wb-git-buttons",children:[(0,s.jsxs)("button",{type:"button",className:"primary",onClick:()=>E(),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:()=>z(),disabled:N,title:H,children:O?c("git.push",{n:O.ahead}):c("git.publish")})]}),x&&(0,s.jsx)("p",{className:"err small",role:"alert",children:x}),u&&(0,s.jsx)(Q,{op:u,onAgain:I,onDismiss:()=>{u&&Y(J,u.id),h(null)},onOpen:i,onIdentity:e=>I(e,{})})]})}function Q(e){var t,a,l;let{op:n,onAgain:i,onDismiss:r,onOpen:c,onIdentity:o}=e,{t:d}=(0,p.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)(ee,{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)(V.i8,{text:n.output,what:"git.op.copy"})]})]})}function ee(e){let{onSaved:t}=e,{t:a}=(0,p.kj)(),[n,i]=(0,l.useState)(""),[c,o]=(0,l.useState)(""),[d,u]=(0,l.useState)(!0),[h,m]=(0,l.useState)(""),[x,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:x||!n.trim()||!c.trim(),children:a("git.identity.save")})]})}var et=a(11272);function ea(e){let{view:t,onOpen:a,reveal:l,workspace:n,onOpenFolder:i,grip:r}=e;return"commits"===t?(0,s.jsx)(ei,{workspace:n,onOpen:a,onOpenFolder:i,grip:r}):(0,s.jsx)(en,{workspace:n,onOpen:a,reveal:l,onOpenFolder:i,grip:r})}function es(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 el=(e,t)=>e.localeCompare(t,void 0,{sensitivity:"base"});function en(e){let{workspace:t,onOpen:a,reveal:n,onOpenFolder:i,grip:c}=e,{t:o}=(0,p.kj)(),[d,u]=(0,l.useState)(null),[h,x]=(0,l.useState)(""),[f,b]=(0,l.useState)(new Set),[g,v]=(0,l.useState)(""),[j,w]=(0,l.useState)(""),k=()=>(null==t?void 0:t.ok)?r.FH.workspaceFiles().then(e=>{u(e.files),x("")}).catch(e=>x(e.message)):Promise.resolve();(0,l.useEffect)(()=>{u(null),k()},[null==t?void 0:t.dir,null==t?void 0:t.ok]),(0,m.z)(k,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)){v(""),w(n.path);return}w(""),v(n.path);let e=n.path.split("/");b(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 C=(e,t)=>(0,s.jsxs)(s.Fragment,{children:[[...e.dirs.keys()].sort(el).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:()=>b(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:C(e.dirs.get(a),l)})]},"d:".concat(l))}),[...e.files].sort((e,t)=>el(e.split("/").pop(),t.split("/").pop())).map(e=>(0,s.jsx)("li",{role:"treeitem","aria-selected":g===e,children:(0,s.jsxs)("button",{type:"button",className:"wb-row file".concat(g===e?" sel":""),"data-path":e,onClick:()=>{v(e),w(""),a({kind:"file",path:e,preview:!0})},onDoubleClick:()=>a({kind:"file",path:e}),title:e,children:[(0,s.jsx)(_,{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)(es,{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 k(),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:[j&&(0,s.jsx)("p",{className:"muted small wb-pad",role:"status",children:o("wb.revealGone",{name:j})}),(0,s.jsx)("p",{className:"muted small wb-pad",title:t.dir,children:t.branch?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(et.O,{})," ",t.branch]}):t.dir}),(0,s.jsx)("ul",{className:"wb-tree-list",role:"tree","aria-label":o("wb.files"),children:C(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 ei(e){var t,a;let{workspace:n,onOpen:i,onOpenFolder:c,grip:o}=e,{t:d}=(0,p.kj)(),u=(0,p.W3)(),[x,f]=(0,l.useState)(null),[b,g]=(0,l.useState)(""),[v,j]=(0,l.useState)(new Set),[w,k]=(0,l.useState)(""),[y,N]=(0,l.useState)(new Map),[C,S]=(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),S(a),g("")}).catch(e=>g(e.message)),[F]);(0,l.useEffect)(()=>{f(null),S(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)),[L,E]=(0,l.useState)(!1),[z,I]=(0,l.useState)(""),D=(e,t)=>{E(!0),I(""),r.FH.gitStage(e,t).then(f).catch(e=>I(e.message)).finally(()=>E(!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)(_,{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:L,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))},H=(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":!v.has(e),onClick:()=>j(t=>new Set(t.has(e)?[...t].filter(t=>t!==e):[...t,e])),children:[(0,s.jsx)("span",{"aria-hidden":"true",children:v.has(e)?"▸":"▾"})," ",t,null!==a&&(0,s.jsx)("span",{className:"wb-badge",children:a})]}),n]}),!v.has(e)&&l]}),R=e=>(0,s.jsx)("button",{type:"button",className:"wb-icon-btn wb-git-stage",onClick:()=>D(e,"all"),disabled:L,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)(es,{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)?b?(0,s.jsx)("p",{className:"err small wb-pad",children:b}):x?x.isRepo?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("p",{className:"small wb-pad wb-git-branch",children:[(0,s.jsx)(et.O,{})," ",(0,s.jsx)("strong",{children:null!=(a=x.branch)?a:"HEAD"}),x.upstream&&(0,s.jsxs)("span",{className:"muted",children:[" \xb7 ",d("git.upstream",{name:x.upstream.name,ahead:x.upstream.ahead,behind:x.upstream.behind})]})]}),(0,s.jsx)(X,{state:x,onChanged:()=>void O(),onOpen:i}),z&&(0,s.jsx)("p",{className:"err small wb-pad",role:"alert",children:z}),C&&H("branch",d("git.branch"),C.problem?null:C.files.length,(0,s.jsx)(U,{data:C,onBase:M,statusName:q,onOpenFile:(e,t)=>i({kind:"diff",area:"branch",path:e,...C.base?{commit:C.base}:{},...t?{}:{preview:!0}})})),x.staged.length>0&&H("staged",d("git.staged"),x.staged.length,(0,s.jsx)("ul",{className:"wb-git-files",children:x.staged.map(e=>W(e,"staged"))}),R("unstage")),H("changes",d("git.changes"),x.changes.length,0===x.changes.length?(0,s.jsx)("p",{className:"muted small wb-pad",children:d("git.noChanges")}):(0,s.jsx)("ul",{className:"wb-git-files",children:x.changes.map(e=>W(e,"changes"))}),x.changes.length>0?R("stage"):void 0),H("commits",d("git.commits"),null,0===x.commits.length?(0,s.jsx)("p",{className:"muted small wb-pad",children:d("git.noCommits")}):(0,s.jsx)("ul",{className:"wb-commits",children:x.commits.map((e,t)=>{var a;let l=y.get(e.sha),n=!!(null==C?void 0:C.mergeBase)&&C.commits.includes(e.sha),i=!!(null==C?void 0:C.mergeBase)&&e.sha===C.mergeBase&&t>0&&C.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=C.base)?a:"",sha:e.short})}),(0,s.jsxs)("button",{type:"button",className:"wb-row","aria-expanded":w===e.sha,onClick:()=>(e=>{if(w===e)return void k("");k(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:w===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)]}),w===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)})})),x.moreCommits&&(0,s.jsx)("p",{className:"muted small wb-pad",children:d("git.more",{n:x.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 er=/^(\s{0,3})(`{3,}|~{3,})\s*([^\s`]*)?.*$/,ec=/^(\s*)([-*+]|\d{1,9}[.)])\s+(.*)$/;function eo(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 ed(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=eo(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],ed(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:ed(e[2],t,c())},c())],[RegExp("^(\\*|_)(?=\\S)([\\s\\S]*?\\S)\\1(?![\\p{L}\\p{N}])","u"),e=>(0,s.jsx)("em",{children:ed(e[2],t,c())},c())],[/^~~(?=\S)([\s\S]*?\S)~~/,e=>(0,s.jsx)("del",{children:ed(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=eo(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 eu(e){let{code:t}=e,{t:n}=(0,p.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 eh(e){let{text:t,path:a,onOpenFile:l}=e,{t:n}=(0,p.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:ed(t.text,a,i)},i)}case"para":return(0,s.jsx)("p",{children:ed(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)(eu,{code:t.text},i);let e=null!=(c=null==(r=f.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 j(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?w("prop",t)+j(a):w("str",t):e.startsWith("//")||e.startsWith("/*")?w("com",e):s?w("lit",e):/^[&<>]$/.test(e)?j(e):w("num",e));case"html":case"vue":return O(t,!0);case"xml":return O(t,!1);case"css":return q(t,!1);case"scss":return q(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?w("com",t):a?w("str",a):s?w("lit",s):l?w("num",l):n?w("var",n):i?j(i):j(e));return/^\s*#/.test(e)?w("com",e):/^\s*---|^\s*\.\.\./.test(e)?w("meta",e):t?j(t[1])+w("prop",t[2])+j(t[3])+j(t[4])+a(t[5]):a(e)}).join("\n");case"ini":case"toml":return t.split("\n").map(e=>{if(/^\s*[#;]/.test(e))return w("com",e);let t=/^(\s*)(\[\[?[^\]]*\]\]?)(.*)$/.exec(e);if(t)return j(t[1])+w("head",t[2])+j(t[3]);let a=/^(\s*)([^=:\s][^=:]*?)(\s*[=:]\s*)(.*)$/.exec(e);if(a){let e=a[4],t=/^(".*"|'.*')$/.test(e.trim())?w("str",e):/^-?\d+(\.\d+)?$/.test(e.trim())?w("num",e):/^(true|false|yes|no|on|off)$/i.test(e.trim())?w("lit",e):j(e);return j(a[1])+w("prop",a[2])+j(a[3])+t}return j(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(w("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=b[a[3].toLowerCase()])?r:null!=(i=null==(n=f.find(e=>e.name.toLowerCase()===a[3].toLowerCase()))?void 0:n.id)?i:"plain":"plain";l={mark:a[2],lang:e,body:[]},s.push(w("code",t));continue}if(/^\s{0,3}#{1,6}\s/.test(t)){s.push(w("head",t));continue}if(/^\s*>/.test(t)){s.push(w("com",t));continue}let c=j(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=F[a];return e?M(t,e):j(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?ed(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:ed(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:ed(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=er.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 x=/^\s{0,3}(#{1,6})\s+(.*?)\s*#*\s*$/.exec(t);if(x){s.push({kind:"heading",level:x[1].length,text:x[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])&&(er.test(a[l])||ec.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 f=ec.exec(t);if(f){let t=f[1].length,i=/\d/.test(f[2]),p=[];for(;l<a.length;){let s=ec.exec(a[l]);if(!s||s[1].length!==t||/\d/.test(s[2])!==i)break;let x=[s[3]];for(l+=1;l<a.length;){let e=a[l],s=ec.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])){x.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;x.push(r>t?e.slice(Math.min(r,t+2+ +!!i)):e.trim()),l+=1}let f=/^\[([ xX])\]\s+/.exec(x[0]);for(f&&(x[0]=x[0].slice(f[0].length)),p.push({blocks:e(x.join("\n")),...f?{task:!0,done:" "!==f[1]}:{}});l<a.length&&n(a[l])&&(null==(c=ec.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(f[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])&&!er.test(a[l])&&!/^\s{0,3}(#{1,6}\s|>)/.test(a[l])&&!(b.length>0&&ec.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 em=null,ep={plain:"plaintext",batch:"bat",vue:"html",toml:"ini",makefile:"plaintext"},ex=e=>{var t;return null!=(t=ep[e])?t:e};function ef(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 eb(e){let{path:t,value:n,language:i,onChange:r,onSave:c,onToggleMarkdown:o,goTo:d,label:u,reset:h}=e,{t:m}=(0,p.kj)(),x=(0,l.useRef)(null),f=(0,l.useRef)(null),b=(0,l.useRef)(null),[g,v]=(0,l.useState)(!1),[j,w]=(0,l.useState)(""),k=(0,l.useRef)({onChange:r,onSave:c,onToggleMarkdown:o});return k.current={onChange:r,onSave:c,onToggleMarkdown:o},(0,l.useEffect)(()=>{let e=!1,s=null;return(null!=em||(em=(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})()),em).then(a=>{if(e||!x.current)return;b.current=a;let l=a.editor.createModel(n,ex(i),a.Uri.file("/workspace/".concat(t))),r=a.editor.create(x.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,ef(a,r),x.current.copEditor=r,l.onDidChangeContent(()=>k.current.onChange(l.getValue())),r.addAction({id:"cop.save",label:m("ed.save"),keybindings:[a.KeyMod.CtrlCmd|a.KeyCode.KeyS],run:()=>k.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=k.current).onToggleMarkdown)?void 0:e.call(t)}}),(s=new MutationObserver(()=>ef(a,r))).observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme","data-textsize"]}),v(!0)}).catch(e=>w(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,g]),(0,l.useEffect)(()=>{var e;let t=null==(e=f.current)?void 0:e.getModel();t&&b.current&&b.current.editor.setModelLanguage(t,ex(i))},[i,g]),(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=b.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,g]),(0,s.jsxs)("div",{className:"ed-code",children:[!g&&!j&&(0,s.jsx)("p",{className:"muted small ed-code-loading",children:m("ed.loading")}),j&&(0,s.jsx)("p",{className:"err small",children:m("ed.failed",{reason:j})}),(0,s.jsx)("div",{ref:x,className:"ed-monaco","data-ready":g?"yes":void 0})]})}let eg="cop.md.view";function ev(e){var t,a,n,i,c;let{path:o,onDirty:d,goTo:u,onOpenFile:h}=e,{t:x}=(0,p.kj)(),[b,g]=(0,l.useState)(null),[j,w]=(0,l.useState)(""),[k,y]=(0,l.useState)(""),[N,C]=(0,l.useState)(""),[S,F]=(0,l.useState)(!1),[M,O]=(0,l.useState)(!1),[q,L]=(0,l.useState)("auto"),[E,z]=(0,l.useState)(0),I=!!b&&null!==b.text&&j!==b.text;(0,l.useEffect)(()=>null==d?void 0:d(o,I),[o,I,d]);let D=(0,l.useCallback)(async()=>{try{var e;let t=await r.FH.workspaceFile(o);g(t),w(null!=(e=t.text)?e:""),z(e=>e+1),O(!1),y("")}catch(e){y(e.message)}},[o]);(0,l.useEffect)(()=>{g(null),C(""),O(!1),D()},[D]),(0,m.z)(async()=>{if(!(null==b?void 0:b.version)||S)return;let e=await r.FH.workspaceFile(o).catch(()=>null);if((null==e?void 0:e.version)&&e.version!==b.version)if(I)O(!0);else{var t;g(e),w(null!=(t=e.text)?t:""),z(e=>e+1)}},4e3,!!b);let W="auto"===q?v(o,null!=(t=null==b?void 0:b.text)?t:""):q,H="markdown"===v(o,""),[R,A]=(0,l.useState)("preview");(0,l.useEffect)(()=>{try{let e=window.localStorage.getItem(eg);("code"===e||"split"===e||"preview"===e)&&A(e)}catch(e){}},[]);let T=e=>{A(e);try{window.localStorage.setItem(eg,e)}catch(e){}},P=H?R:"code",B=async function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(b&&!S){F(!0),C("");try{let t=await r.FH.saveWorkspaceFile(o,j,e?void 0:b.version);g({...b,text:j,version:t.version,size:t.size}),O(!1),C(x("ed.saved"))}catch(e){409===e.status?O(!0):C(e.message)}finally{F(!1)}}};return((0,l.useEffect)(()=>{u&&H&&"preview"===R&&A("split")},[null==u?void 0:u.n]),k&&!b)?(0,s.jsx)("p",{className:"err small",children:k}):b?b.binary||b.tooLarge?(0,s.jsxs)("div",{className:"wb-file",children:[(0,s.jsx)("p",{className:"muted small",children:x("wb.fileOnDisk",{path:b.path})}),(0,s.jsx)("p",{className:"muted",children:b.binary?x("wb.binary"):x("wb.tooLarge")})]}):(0,s.jsxs)("div",{className:"ed",children:[(0,s.jsxs)("div",{className:"ed-bar",children:[(0,s.jsx)(_,{path:o}),(0,s.jsx)("span",{className:"ed-path",title:b.path,children:b.path}),(0,s.jsx)("span",{className:"small ".concat(I?"ed-dirty":"muted"),role:"status",children:I?x("ed.unsaved"):N||x("ed.clean")}),(0,s.jsx)("span",{className:"grow"}),H&&(0,s.jsx)("span",{className:"segmented ed-md-view",role:"group","aria-label":x("ed.view"),title:x("ed.viewWhy"),children:["code","split","preview"].map(e=>(0,s.jsx)("button",{type:"button","aria-pressed":R===e,onClick:()=>T(e),children:x("code"===e?"ed.viewCode":"split"===e?"ed.viewSplit":"ed.viewPreview")},e))}),(0,s.jsx)("label",{htmlFor:"ed-lang-".concat(o),className:"sr-only",children:x("ed.language")}),(0,s.jsxs)("select",{id:"ed-lang-".concat(o),className:"ed-lang",value:q,onChange:e=>L(e.target.value),title:x("ed.language"),children:[(0,s.jsx)("option",{value:"auto",children:x("ed.langAuto",{name:(n=v(o,null!=(a=b.text)?a:""),null!=(c=null==(i=f.find(e=>e.id===n))?void 0:i.name)?c:n)})}),f.map(e=>(0,s.jsx)("option",{value:e.id,children:e.name},e.id))]}),(0,s.jsx)("button",{type:"button",className:"quiet small",disabled:!I||S,onClick:()=>{var e;w(null!=(e=b.text)?e:""),z(e=>e+1),C("")},children:x("ed.revert")}),(0,s.jsx)("button",{type:"button",className:"primary small",disabled:!I||S,onClick:()=>void B(),title:"Ctrl+S",children:x("ed.save")})]}),M&&(0,s.jsxs)("div",{className:"notice caution small ed-conflict",role:"alert",children:[(0,s.jsx)("span",{children:x("ed.changedOnDisk")}),(0,s.jsx)("button",{type:"button",className:"small",onClick:()=>void D(),children:x("ed.reload")}),(0,s.jsx)("button",{type:"button",className:"small danger",onClick:()=>void B(!0),children:x("ed.saveOver")})]}),(0,s.jsxs)("div",{className:"ed-body ed-show-".concat(P),children:["code"!==P&&(0,s.jsx)("div",{className:"ed-preview",children:(0,s.jsx)(eh,{text:j,path:o,onOpenFile:e=>null==h?void 0:h(e)})}),"preview"!==P&&(0,s.jsx)(eb,{path:o,value:j,language:W,onChange:w,onSave:()=>void B(),onToggleMarkdown:H?()=>T("code"===R?"preview":"code"):void 0,goTo:u,label:x("ed.label",{path:b.path}),reset:E})]})]}):(0,s.jsx)("p",{className:"muted small",children:x("wb.loading")})}function ej(e){if(null===e||""===e)return[];let t=e.split(/\r?\n/);return""===t[t.length-1]&&t.pop(),t}function ew(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 ek(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 ey=a(94969);function eN(e){let{sessionId:t,taskId:a,runId:n,title:i,files:r}=e,{t:c}=(0,p.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)(eC,{sessionId:t,taskId:a,runId:n,title:i,onClose:()=>d(!1)})]})}function eC(e){var t,a,n,i,c,o,d;let{sessionId:u,taskId:h,runId:m,title:x,onClose:f}=e,{t:b}=(0,p.kj)(),[g,v]=(0,l.useState)(null),[j,w]=(0,l.useState)(""),[k,y]=(0,l.useState)(0),[N,C]=(0,l.useState)(new Map),[S,F]=(0,l.useState)(!1),[M,O]=(0,l.useState)(!0),[q,L]=(0,l.useState)(new Map),[E,z]=(0,l.useState)(-1),I=(0,l.useRef)(null),D=(0,l.useRef)(null),W=(0,l.useRef)(null);(0,ey.V)(D,!0,W),(0,l.useEffect)(()=>{r.FH.taskChanges(u,h,m).then(v).catch(e=>w(e.message))},[u,h,m]);let H=null!=(n=null==g?void 0:g.files)?n:[],R=H[k];(0,l.useEffect)(()=>{!R||N.has(R.path)||r.FH.taskChangeFile(u,h,R.path,m).then(e=>C(t=>new Map(t).set(R.path,e))).catch(e=>C(t=>new Map(t).set(R.path,e.message)))},[R,N,u,h,m]);let A=R?N.get(R.path):void 0,T=(0,l.useMemo)(()=>!A||"string"==typeof A||A.binary||A.tooLarge?[]:ew(ej(A.before),ej(A.after)),[A]),P=R&&q.get(R.path)||new Set,B=(0,l.useMemo)(()=>ek(T,3,P,S),[T,P,S]),_=(0,l.useMemo)(()=>T.flatMap((e,t)=>"same"!==e.kind&&(0===t||"same"===T[t-1].kind)?[t]:[]),[T]);(0,l.useEffect)(()=>{z(-1),I.current&&(I.current.scrollTop=0)},[k]);let $=(0,l.useCallback)(e=>{var t;if(0===_.length)return;let a=E<0?1===e?0:_.length-1:Math.min(_.length-1,Math.max(0,E+e));z(a);let s=null==(t=I.current)?void 0:t.querySelector('[data-row="'.concat(_[a],'"]'));null==s||s.scrollIntoView({block:"center"})},[E,_]),U=(0,l.useCallback)(e=>y(t=>Math.min(Math.max(0,t+e),Math.max(0,H.length-1))),[H.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=H.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:b("diff.title",{title:x})}),(null==g?void 0:g.ok)&&(0,s.jsxs)("span",{className:"muted small",children:[g.branch?"".concat(g.branch," \xb7 "):"",null==(t=g.base)?void 0:t.slice(0,8)," → ",null==(a=g.commit)?void 0:a.slice(0,8)," \xb7 ",b("diff.summary",{n:H.length,a:K.added,r:K.removed})]}),(0,s.jsx)("span",{className:"grow"}),(0,s.jsx)("span",{className:"muted small",children:b("diff.keys")}),(0,s.jsx)("button",{ref:W,type:"button",onClick:f,children:b("diff.close")})]}),j&&(0,s.jsx)("div",{className:"err",style:{padding:12},children:j}),!g&&!j&&(0,s.jsx)("div",{className:"muted",style:{padding:12},children:b("diff.loading")}),g&&!g.ok&&(0,s.jsx)("div",{className:"notice caution",style:{margin:12},children:g.problem}),(null==g?void 0:g.ok)&&0===H.length&&(0,s.jsx)("div",{className:"notice",style:{margin:12},children:b("diff.nothing")}),(null==g?void 0:g.ok)&&H.length>0&&(0,s.jsxs)("div",{className:"diff-body",children:[(0,s.jsx)("nav",{className:"diff-files","aria-label":b("diff.files"),children:H.map((e,t)=>{let a=e.path.lastIndexOf("/");return(0,s.jsxs)("button",{type:"button",className:"diff-file".concat(t===k?" 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?b("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:[R&&(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:R.oldPath?"".concat(R.oldPath," → ").concat(R.path):R.path}),(0,s.jsx)("span",{className:"muted small",children:"A"===R.status?b("diff.added"):"D"===R.status?b("diff.deleted"):"R"===R.status?b("diff.renamed"):""})]}),(0,s.jsx)(eS,{changes:_.length,onChange:$,files:{at:k,count:H.length,onFile:U},whole:S,onWhole:F,wrap:M,onWrap:O})]}),(0,s.jsxs)("div",{className:"diff-scroll",ref:I,children:[void 0===A&&(0,s.jsx)("div",{className:"muted",style:{padding:12},children:b("diff.loading")}),"string"==typeof A&&(0,s.jsx)("div",{className:"err",style:{padding:12},children:A}),A&&"string"!=typeof A&&A.binary&&(0,s.jsx)("div",{className:"notice",style:{margin:12},children:b("diff.binary")}),A&&"string"!=typeof A&&A.tooLarge&&(0,s.jsx)("div",{className:"notice",style:{margin:12},children:b("diff.tooLarge")}),A&&"string"!=typeof A&&!A.binary&&!A.tooLarge&&(0,s.jsxs)(s.Fragment,{children:[(null!=(i=A.before)?i:"").includes("\r\n")!==(null!=(c=A.after)?c:"").includes("\r\n")&&null!==A.before&&null!==A.after&&(0,s.jsx)("div",{className:"notice small",style:{margin:8},children:b("diff.eol",{from:(null!=(o=A.before)?o:"").includes("\r\n")?"CRLF":"LF",to:(null!=(d=A.after)?d:"").includes("\r\n")?"CRLF":"LF"})}),T.length>0&&0===_.length&&(0,s.jsx)("div",{className:"notice small",style:{margin:8},children:b("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)(eF,{changes:_.length,at:E}),(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(R&&L(e=>{var a;return new Map(e).set(R.path,new Set([...null!=(a=e.get(R.path))?a:[],t]))}))},children:b("diff.gap",{n:e.count})})})},"g".concat(e.from)):(0,s.jsx)(eM,{row:e.row,index:e.index,current:E>=0&&_[E]===e.index},e.index))})]})]})]})]})]})]})}function eS(e){let{changes:t,onChange:a,files:l,whole:n,onWhole:i,wrap:r,onWrap:c}=e,{t:o}=(0,p.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 eF(e){let{changes:t,at:a}=e,{t:l}=(0,p.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 eM(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 eO(e){var t;let{area:a,path:n,commit:i}=e,{t:c}=(0,p.kj)(),[o,d]=(0,l.useState)(null),[u,h]=(0,l.useState)(""),[x,f]=(0,l.useState)(!1),[b,g]=(0,l.useState)(!0),[v,j]=(0,l.useState)(new Set),[w,k]=(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(""),j(new Set),k(-1),N()},[N]),(0,m.z)(N,5e3,"commit"!==a);let C=(0,l.useMemo)(()=>!o||o.binary||o.tooLarge?[]:ew(ej(o.before),ej(o.after)),[o]),S=(0,l.useMemo)(()=>ek(C,3,v,x),[C,v,x]),F=(0,l.useMemo)(()=>C.flatMap((e,t)=>"same"!==e.kind&&(0===t||"same"===C[t-1].kind)?[t]:[]),[C]),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)(eS,{changes:F.length,onChange:e=>{var t,a;if(0===F.length)return;let s=w<0?1===e?0:F.length-1:Math.min(F.length-1,Math.max(0,w+e));k(s),null==(a=y.current)||null==(t=a.querySelector('[data-row="'.concat(F[s],'"]')))||t.scrollIntoView({block:"center"})},whole:x,onWhole:f,wrap:b,onWrap:g})]}),(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:[C.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(b?"":" 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)(eF,{changes:F.length,at:w}),(0,s.jsx)("tbody",{children:S.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:()=>j(t=>new Set([...t,e.from])),children:c("diff.gap",{n:e.count})})})},"g".concat(e.from)):(0,s.jsx)(eM,{row:e.row,index:e.index,current:w>=0&&F[w]===e.index},e.index))})]})]})]})]})}var eq=a(61238),eL=a(52157);let eE="",ez=new Set;function eI(e){if(e!==eE)for(let t of(eE=e,ez))t()}function eD(e){return ez.add(e),()=>{ez.delete(e)}}function eW(){return[(0,l.useSyncExternalStore)(eD,()=>eE,()=>""),eI]}var eH=a(41370),eR=a(33389),eA=a(68176);function eT(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]")),x=e=>{var t;return null!=(t=e.closest("[data-awaits-frame]"))?t:e},f=(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,f(e,x(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,f(e,x(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 eP=a(51035),eB=a(24784),e_=a(65132),e$=a(36657),eU=a(92842),eK=a(79717);let eV={done:"✓",running:"●",planned:"○",blocked:"⊘",failed:"✗",stopped:"■"},eZ={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 eJ(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 eG(e){let{lead:t,live:a}=e,{t:l}=(0,p.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}=eJ(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)(eY,{ledger:n,live:a})]})}function eY(e){let{ledger:t,live:a}=e,{t:l}=(0,p.kj)(),{phases:n}=eJ(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(eV["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)(V.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(eZ[t]),"aria-label":l(eZ[t]),children:eV[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 eX(e){let{change:t}=e,{t:a}=(0,p.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 eQ(e){let{workspace:t,running:a,onMade:n}=e,{t:i}=(0,p.kj)(),[r,c]=(0,l.useState)(!1),o=a?i("nb.offRunning"):(null==t?void 0:t.ok)?t.isRepo?"":i("nb.offNoRepo"):i("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":!!o||void 0,onClick:()=>!o&&c(!0),title:o||i("nb.buttonWhy"),children:i("nb.button")}),r&&(0,s.jsx)(e0,{onClose:()=>c(!1),onMade:e=>{c(!1),n(e)}})]})}function e0(e){var t,a,n,i,c,o,d,u,h,m,x;let{onClose:f,onMade:b}=e,{t:g}=(0,p.kj)(),v=(0,p.W3)(),j=(0,l.useRef)(null),w=(0,l.useRef)(null),[k,y]=(0,l.useState)(null),[N,C]=(0,l.useState)(!0),[S,F]=(0,l.useState)(""),[M,O]=(0,l.useState)("take"),[q,L]=(0,l.useState)(""),[E,z]=(0,l.useState)(!1),[I,D]=(0,l.useState)(""),[W,H]=(0,l.useState)(!1),R=(0,eH.q)(N||E);(0,ey.V)(j,!0,w);let A=async e=>{C(!0),D("");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{C(!1)}};(0,l.useEffect)(()=>{A(!0)},[]),(0,l.useEffect)(()=>{let e=e=>{"Escape"!==e.key||E||(e.preventDefault(),f())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[E,f]);let T=async()=>{if(null==k?void 0:k.fingerprint){z(!0),D(""),H(!1);try{let e=await r.FH.newBranchCreate(S.trim(),M,k.fingerprint,"commit"===M?q:void 0);if(e.ok)return void b(e.result);D(e.problem),e.conflict&&(H(!0),O("aside"))}catch(e){D(e.message)}finally{z(!1)}}},P=(null!=(t=null==k?void 0:k.changed.length)?t:0)+(null!=(a=null==k?void 0:k.untracked.length)?a:0),B=(null==k?void 0:k.fetched)&&!k.fetched.ok,_=[...null!=(n=null==k?void 0:k.changed)?n:[],...null!=(i=null==k?void 0:k.untracked)?i:[]];return(0,s.jsx)("div",{className:"modal-backdrop",role:"presentation",onClick:()=>!E&&f(),children:(0,s.jsxs)("div",{ref:j,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:g("nb.title")}),N?(0,s.jsxs)("div",{className:"nb-reading",role:"status",children:[(0,s.jsxs)("p",{children:[g("nb.fetching"),(0,s.jsx)("span",{className:"saving-dots",children:R})]}),(0,s.jsx)("p",{className:"muted small",children:g("nb.passwordNote")})]}):(0,s.jsxs)(s.Fragment,{children:[(null==k?void 0:k.ok)&&(0,s.jsxs)(s.Fragment,{children:[B&&(0,s.jsxs)("div",{className:"nb-warn",role:"alert",children:[(0,s.jsx)("p",{children:g(k.fetched.auth?"nb.fetchAuth":"nb.fetchFailed",{remote:null!=(c=k.remote)?c:"origin",detail:null!=(o=k.fetched.detail)?o:""})}),(0,s.jsx)("p",{className:"small",children:k.lastFetched?g("nb.lastFetched",{target:null!=(d=k.target)?d:"",at:v(k.lastFetched)}):g("nb.lastKnown",{target:null!=(u=k.target)?u:""})}),(0,s.jsx)("div",{className:"row",children:(0,s.jsx)("button",{type:"button",onClick:()=>void A(!0),disabled:E,children:g("nb.tryAgain")})})]}),(0,s.jsxs)("p",{className:"nb-from",children:[g("nb.from",{target:null!=(h=k.target)?h:"",commit:(null!=(m=k.targetCommit)?m:"").slice(0,8)})," ",k.targetSubject&&(0,s.jsxs)("span",{className:"muted",children:["— ",k.targetSubject]})]}),(0,s.jsx)("p",{className:"small muted",children:k.branch?g("nb.now",{branch:k.branch}):g("nb.nowDetached")}),(0,s.jsxs)("div",{className:"settings-field",children:[(0,s.jsx)("label",{htmlFor:"nb-name",className:"field-label",children:g("nb.name")}),(0,s.jsx)("input",{id:"nb-name",type:"text",dir:"ltr",value:S,onChange:e=>F(e.target.value),spellCheck:!1,disabled:E})]}),P>0&&(0,s.jsxs)("fieldset",{className:"nb-dirty",children:[(0,s.jsx)("legend",{children:g("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:g("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||E}),(0,s.jsxs)("span",{children:[(0,s.jsx)("strong",{children:g("nb.take")})," ",(0,s.jsx)("span",{className:"muted small",children:g("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:E}),(0,s.jsxs)("span",{children:[(0,s.jsx)("strong",{children:g("nb.aside")})," ",(0,s.jsx)("span",{className:"muted small",children:g("nb.asideWhy")})]})]}),(0,s.jsxs)("label",{className:"nb-choice",title:k.branch?void 0:g("nb.commitDetached"),children:[(0,s.jsx)("input",{type:"radio",name:"nb-carry",checked:"commit"===M,onChange:()=>O("commit"),disabled:E||!k.branch}),(0,s.jsxs)("span",{children:[(0,s.jsx)("strong",{children:g("nb.commit",{branch:null!=(x=k.branch)?x:"—"})})," ",(0,s.jsx)("span",{className:"muted small",children:g("nb.commitWhy")})]})]}),"commit"===M&&k.branch&&(0,s.jsxs)("div",{className:"settings-field nb-message",children:[(0,s.jsx)("label",{htmlFor:"nb-message",className:"field-label",children:g("nb.commitMessage")}),(0,s.jsx)("input",{id:"nb-message",type:"text",value:q,onChange:e=>L(e.target.value),placeholder:"Work in progress, before a new branch from main",disabled:E,maxLength:2e3})]})]}),(0,s.jsx)("p",{className:"muted small",children:g("nb.after")})]}),I&&(0,s.jsx)("p",{className:"err",role:"alert",children:I})]}),(0,s.jsxs)("div",{className:"row modal-actions",children:[(0,s.jsx)("button",{ref:w,type:"button",className:"quiet",onClick:f,disabled:E,children:g("nb.cancel")}),!N&&!(null==k?void 0:k.ok)&&(0,s.jsx)("button",{type:"button",onClick:()=>void A(!0),children:g("nb.tryAgain")}),!N&&(null==k?void 0:k.ok)&&(0,s.jsx)("button",{type:"button",className:"primary",onClick:()=>void T(),disabled:E||!S.trim(),"aria-busy":E||void 0,children:E?(0,s.jsxs)(s.Fragment,{children:[g("nb.making"),(0,s.jsx)("span",{className:"saving-dots",children:R})]}):g(B?"nb.makeFromLast":"nb.make")})]})]})})}var e1=a(34982),e2=a(44504),e3=a(14236);let e4="cop.chat.thread",e5="cop.chat.plan",e6="cop.chat.review",e8="cop.chat.lead",e7="cop.chat.kerrigan",e9=(e,t)=>{try{t?window.localStorage.setItem(e,t):window.localStorage.removeItem(e)}catch(e){}},te=e=>{try{var t;return null!=(t=window.localStorage.getItem(e))?t:""}catch(e){return""}};function tt(e){var t,a,n,c,o,d,u,h,x,f,b,g,v,j,w,k,y,N,C,S;let{workspace:F,composeAsk:M,showThread:O,onOpenFile:q,onChange:L,onOpenFolder:E,onTurn:z}=e,{t:I,locale:D}=(0,p.kj)(),[W,H]=(0,l.useState)([]),[R,A]=(0,l.useState)(""),[T,P]=(0,l.useState)(null),[B,_]=(0,l.useState)(!1),[$,U]=(0,l.useState)(!0),[K,Z]=(0,l.useState)(""),[J,G]=(0,l.useState)(!1),[Y,X]=(0,l.useState)(""),[Q,ee]=(0,l.useState)(!1),[et,ea]=(0,l.useState)(null),[es,el]=(0,l.useState)(""),[en,ei]=(0,l.useState)(!1),[er,ec]=(0,l.useState)(""),[eo,ed]=(0,l.useState)([]),[eu,eh]=(0,l.useState)(null),[em,ep]=(0,l.useState)(""),[ex,ef]=(0,l.useState)(!1),[eb,eg]=(0,l.useState)([]),[ev,ej]=eW(),ew=(0,l.useRef)(null),ek=!!T&&("idle"!==T.status||!!T.directedBy&&T.tasks.some(e=>"running"===e.status||"waiting-approval"===e.status)),ey=T?!!T.lead||!!T.kerrigan:J||Q,eN=null!=(h=(T?!!T.kerrigan:Q)?(null==eu?void 0:eu.defaultKerriganModel)||(null==eu?void 0:eu.defaultLeadModel)||(null==eu?void 0:eu.defaultModel):ey&&(null==eu?void 0:eu.defaultLeadModel)||(null==eu?void 0:eu.defaultModel))?h:"",eC=null!=(x=null==eu?void 0:eu.defaultModel)?x:"",eS=T?!T.manualModel&&(T.model||eN)?null!=(f=T.model)?f:"":eB.u:"",eF=em!==eB.u&&(em||eN)?em:eB.u;(0,l.useEffect)(()=>{A(te(e4)),_("on"===te(e5)),U("off"!==te(e6)),G("on"===te(e8)&&"on"!==te(e7)),ee("on"===te(e7))},[]),(0,l.useEffect)(()=>{var e;M>0&&(null==(e=ew.current)||e.focus())},[M]),(0,l.useEffect)(()=>{(null==O?void 0:O.id)&&e$(O.id)},[null==O?void 0:O.n]),(0,l.useEffect)(()=>{r.FH.models().then(eh).catch(()=>void 0),r.FH.skills().then(e=>eg(e.skills)).catch(()=>void 0)},[]);let eM=e=>e.trim().replace(/[\\/]+$/,"").replace(/\//g,"\\").toLowerCase(),eO=eb.filter(e=>!e.projectDir||(null==F?void 0:F.dir)&&eM(e.projectDir)===eM(F.dir)),eL=(0,l.useCallback)(()=>r.FH.chatThreads().then(H).catch(()=>void 0),[]);(0,m.z)(eL,5e3);let eE=(0,l.useRef)(R);eE.current=R;let ez=(0,l.useCallback)(()=>{let e=eE.current;return e?r.FH.session(e).then(t=>{eE.current===e&&P("chat"===t.kind?t:null)}).catch(t=>{404===t.status&&eE.current===e&&(P(null),A(""),e9(e4,""))}):Promise.resolve(P(null))},[]);(0,l.useEffect)(()=>{ez()},[R,ez]),(0,m.z)(ez,ek?1500:5e3,!!R);let eI=(0,l.useRef)(new Set),eD=()=>R&&ek?r.FH.approvals(R).then(e=>ed(e.filter(e=>!eI.current.has(e.id)))).catch(()=>void 0):Promise.resolve(ed([]));(0,m.z)(eD,1500,!!R);let eR=(e,t)=>{t&&(eI.current.add(e),ed(t=>t.filter(t=>t.id!==e))),eD()},eA=null!=(b=null==T||null==(t=T.lead)?void 0:t.workerSessionId)?b:"",e_=(0,l.useCallback)(()=>eA?r.FH.session(eA).then(ea).catch(()=>void 0):Promise.resolve(ea(null)),[eA]);(0,l.useEffect)(()=>{e_()},[e_]),(0,m.z)(e_,ek?1500:1e4,!!eA);let e$=e=>{eE.current=e,A(e),e9(e4,e),ec(""),eG(null)},eU=e=>(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("label",{htmlFor:"cs-model",className:"sr-only",children:I("chat.model")}),(0,s.jsx)(eB.Yb,{id:"cs-model",chosen:T?eS:eF,onChange:e=>void ts(e),byHand:I("chat.modelByHand"),none:eN?I("chat.modelDefault",{model:eN}):void 0,catalogue:eu,disabled:ek,style:{minWidth:0,maxWidth:e}}),(0,s.jsx)("button",{type:"button",className:"wb-icon-btn",onClick:()=>void to(),disabled:ex||ek,title:I("chat.readModels"),"aria-label":I("chat.readModels"),children:"↻"})]}),eK=ek||W.some(e=>e.running),eV=eK?I("chat.newChatRunning"):T?"":I("chat.newChatFresh"),eZ=()=>{var e;e$(""),P(null),null==(e=ew.current)||e.focus()},[eJ,eG]=(0,l.useState)(null),eY=e=>e.replace(/^chat: /,""),eX=async()=>{var e;let t=null!=(e=null==eJ?void 0:eJ.trim())?e:"";if(T&&t)try{let e=await r.FH.updateSession(T.id,{name:t});P(t=>t&&t.id===e.id?{...t,name:e.name}:t),H(t=>t.map(t=>t.id===e.id?{...t,name:e.name}:t)),eG(null),ec("")}catch(e){ec(e.message)}},e0=async()=>{let e=es.trim();if(!e||en)return;let t=ev,a=eO.length>0?/^\/([a-z0-9][a-z0-9-]*[a-z0-9])(?=\s|$)\s*([\s\S]*)$/.exec(e):null;if(a){let s=eO.find(e=>e.name===a[1]);if(!s)return void ec(I("chat.skillUnknown",{name:a[1],names:eO.map(e=>"/".concat(e.name)).join(", ")}));if(!a[2].trim())return void ec(I("chat.skillNoText",{name:s.name}));t=s.name,e=a[2].trim()}ei(!0),ec("");try{var s;let a=!R,l=a&&em===eB.u,n=a&&J&&!Q?{workerModel:Y===eB.u?void 0:Y||void 0,workerManualModel:Y===eB.u}:void 0,i=a&&Q?{chatModel:Y===eB.u?void 0:Y||void 0,chatManualModel:Y===eB.u}:void 0,c=await r.FH.chatSend(e,R||void 0,a&&!l&&em||void 0,l,D,a&&B&&!i,a?!n&&!i&&$:void 0,n,t||void 0,a&&!n&&!i&&K||void 0,i);if(el(""),ej(""),e$(c.threadId),c.noted)return void ec(I("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||ec(I("chat.notStarted",{reason:null!=(s=d.reason)?s:""}))}catch(e){ec(e.message)}finally{ei(!1),ez(),eL(),L()}},e1=async(e,t,a)=>{if(!T||en)return!1;ei(!0),ec("");let s=!1;try{var l;let n=await r.FH.chatRetrySubtask(T.id,e.id,t,a);s=n.started,n.started||ec(null!=(l=n.reason)?l:I("retry.notStarted"))}catch(e){ec(e.message)}finally{ei(!1),ez()}return s},e2=async e=>{if(T&&!en){ei(!0),ec("");try{var t;let a=await r.FH.chatContinue(T.id,e.id);a.started||ec(null!=(t=a.reason)?t:I("chat.carryOnNotStarted"))}catch(e){ec(e.message)}finally{ei(!1),ez(),eL(),L()}}},e3=async e=>{if(T&&!en&&await (0,eP.Z)(I("chat.rewindConfirm",{n:T.tasks.length-T.tasks.indexOf(e)}))){ei(!0),ec("");try{var t;let a=await r.FH.chatRewind(T.id,e.id);el(a.text),ec(I("chat.rewound")),null==(t=ew.current)||t.focus()}catch(e){ec(e.message)}finally{ei(!1),ez(),L()}}},tt=async e=>{if(T){P(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(T.id,e)}catch(e){ec(e.message)}finally{ez()}}},ts=async e=>{if(!T)return void ep(e);await tt(e===eB.u?{model:"",manualModel:!0}:{model:e,manualModel:!1})},tl=T?!!T.lead:J&&!Q,tn=T?!!T.kerrigan:Q,tr=T?T.kerrigan?T.kerrigan.chatManualModel?eB.u:null!=(g=T.kerrigan.chatModel)?g:"":(null==(a=T.lead)?void 0:a.workerManualModel)?eB.u:null!=(v=null==(n=T.lead)?void 0:n.workerModel)?v:"":Y,tc=async e=>{if(!T)return void X(e);await tt(e===eB.u?{workerModel:"",workerManualModel:!0}:{workerModel:e,workerManualModel:!1})},to=async()=>{ef(!0),ec(I("chat.modelsReading"));try{eh(await r.FH.refreshModels()),ec(I("chat.modelsRead"))}catch(e){ec(e.message)}finally{ef(!1)}},td=T?"approve"===T.planMode:B,tu=async e=>{if(!T){_(e),e9(e5,e?"on":"");return}await tt({planMode:e?"approve":"off"})},th=T?(null==(c=T.review)?void 0:c.enabled)!==!1:$,tm=async e=>{if(!T){U(e),e9(e6,e?"":"off");return}await tt({review:{enabled:e}})},tf=T?"operator"===T.reviewModelSource&&null!=(j=null==(o=T.review)?void 0:o.model)?j:"":K,tb=null!=(w=null==eu?void 0:eu.defaultReviewModel)?w:"",tg=async e=>{if(!T)return void Z(e);await tt({review:{model:e}})},tv=ek&&!!(null==T?void 0:T.paused),tj=(0,eq.v)(),tw=async()=>{if(!T)return;let e=!T.paused;P(t=>t?{...t,paused:e}:t);try{await (e?r.FH.pause(T.id):r.FH.resume(T.id))}catch(e){ec(e.message)}finally{ez()}},[tk,ty]=(0,l.useState)(!1);(0,l.useEffect)(()=>{ek||ty(!1)},[ek]),(0,l.useEffect)(()=>{ty(!1)},[null==T?void 0:T.id]);let tN=(0,eH.q)(tk),tC=null==T?void 0:T.tasks.at(-1),tS=null==tC||null==(u=tC.lead)||null==(d=u.rounds.filter(e=>e.subtask).at(-1))?void 0:d.subtask;(0,l.useEffect)(()=>{z(R?T&&tC?tS&&eA?{sessionId:eA,taskId:tS.taskId}:{sessionId:T.id,taskId:tC.id}:null:"new")},[R,null==T?void 0:T.id,null==tC?void 0:tC.id,null==tS?void 0:tS.taskId,eA]);let{ref:tF}=eT(!0,"".concat(null!=(k=null==T?void 0:T.tasks.length)?k:0,":").concat(null!=(y=null==tC?void 0:tC.status)?y:"",":").concat(null!=(N=null==tC?void 0:tC.iterations)?N:0));return(0,s.jsxs)("div",{className:"cs",children:[(0,s.jsxs)("div",{className:"cs-head",children:[null!==eJ&&T?(0,s.jsxs)("form",{className:"cs-rename",onSubmit:e=>{e.preventDefault(),eX()},children:[(0,s.jsx)("label",{htmlFor:"cs-rename",className:"sr-only",children:I("chat.renameLabel")}),(0,s.jsx)("input",{id:"cs-rename",type:"text",dir:"auto",maxLength:120,value:eJ,autoFocus:!0,onFocus:e=>e.target.select(),onChange:e=>eG(e.target.value),onKeyDown:e=>{"Escape"===e.key&&(e.preventDefault(),eG(null))}}),(0,s.jsx)("button",{type:"submit",className:"wb-icon-btn",disabled:!eJ.trim(),title:I("chat.renameSave"),"aria-label":I("chat.renameSave"),children:"✓"}),(0,s.jsx)("button",{type:"button",className:"wb-icon-btn",onClick:()=>eG(null),title:I("chat.renameCancel"),"aria-label":I("chat.renameCancel"),children:"✕"})]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("label",{htmlFor:"cs-thread",className:"sr-only",children:I("chat.thread")}),(0,s.jsxs)("select",{id:"cs-thread",dir:"auto",value:R,onChange:e=>e$(e.target.value),children:[(0,s.jsx)("option",{value:"",children:I("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})(W).map(e=>(0,s.jsx)("option",{value:e.id,children:e.kerrigan?"✦ ".concat(eY(e.name)):e.directedBy?" ↳ ".concat(eY(e.name)):eY(e.name)},e.id))]}),T&&(0,s.jsx)("button",{type:"button",className:"wb-icon-btn cs-rename-btn",onClick:()=>eG(eY(T.name)),title:I("chat.rename"),"aria-label":I("chat.rename"),children:"✎"})]}),(0,s.jsxs)("span",{className:"cs-new-wrap",children:[(0,s.jsx)("button",{type:"button",className:"cs-new","aria-disabled":!!eV||void 0,"aria-describedby":eV?"cs-new-tip":void 0,onClick:()=>{eV||eZ()},title:eV?void 0:I("chat.newChatWhy"),children:I("chat.newChat")}),eV&&(0,s.jsx)("span",{id:"cs-new-tip",role:"tooltip",className:"cs-new-tip",children:eV})]})]}),(0,s.jsxs)("div",{className:"cs-body",ref:tF,"aria-live":"polite",children:[(null==T?void 0:T.directedBy)&&(0,s.jsxs)("p",{className:"cs-system cs-directed",children:[I("kz.directedBy")," ",(0,s.jsx)("button",{type:"button",className:"quiet small",onClick:()=>e$(T.directedBy),children:I("kz.openHers")})]}),T?T.tasks.map((e,t)=>T.kerrigan?(0,s.jsx)(tx,{n:t+1,session:T,task:e,threads:W,approvals:eo,onDecided:eR,onOpenFile:q,onOpenChat:e$,onRewind:ek||en?void 0:()=>void e3(e)},e.id):T.lead?(0,s.jsx)(tp,{n:t+1,session:T,task:e,worker:et,approvals:eo,onDecided:eR,onOpenFile:q,onRewind:ek||en?void 0:()=>void e3(e),onRetrySubtask:ek||"aborted"!==e.status?void 0:(t,a)=>e1(e,t,a)},e.id):(0,s.jsx)(ti,{n:t+1,session:T,task:e,approvals:eo.filter(t=>t.taskId===e.id),onDecided:eR,onOpenFile:q,onRewind:ek||en?void 0:()=>void e3(e)},e.id)):(0,s.jsx)(ta,{workspace:F,onPick:e=>{var t;el(e),null==(t=ew.current)||t.focus()},onOpenFolder:E}),T&&!ek&&!T.directedBy&&!!(S=T.tasks.at(-1))&&(!S.parked||!!S.parked.answer)&&("queued"===S.status||"aborted"===S.status||"limit-reached"===S.status||!!S.limit&&("failed"===S.status||"blocked"===S.status))&&(0,s.jsxs)("div",{className:"cs-system cs-carry",role:"group","aria-label":I("chat.carryOnLabel"),children:[(0,s.jsx)("span",{className:"grow",children:I("chat.carryOnNote")}),(0,s.jsx)("button",{type:"button",className:"primary small",disabled:en,onClick:()=>void e2(T.tasks.at(-1)),children:I("chat.carryOn")})]}),tv&&(0,s.jsx)("p",{className:"cs-system cs-paused",role:"status",children:I("chat.pausedNote")}),ek&&(null==tj?void 0:tj.password)&&(0,s.jsxs)("div",{className:"cs-system cs-password",role:"alert","data-awaits":"password:".concat(null!=(C=null==T?void 0:T.id)?C:""),tabIndex:-1,children:[I("chat.passwordWaiting"),(0,s.jsx)(V.T4,{text:I("chat.passwordWaiting")})]}),er&&(0,s.jsx)("p",{className:"cs-system",role:"status",children:er})]}),(0,s.jsxs)("div",{className:"cs-compose",children:[(0,s.jsx)("label",{htmlFor:"cs-input",className:"sr-only",children:I("chat.input")}),(0,s.jsx)("textarea",{id:"cs-input",ref:ew,value:es,onChange:e=>el(e.target.value),placeholder:ek?I("chat.placeholderRunning"):(null==F?void 0:F.ok)?I("chat.placeholder",{folder:F.name}):I("chat.placeholderNoFolder"),disabled:en||!(null==F?void 0:F.ok),onKeyDown:e=>{"Enter"!==e.key||e.shiftKey||e.nativeEvent.isComposing||(e.preventDefault(),e0())}}),tn?(0,s.jsxs)("div",{className:"cs-models",children:[(0,s.jsx)("span",{className:"cs-pick-label","aria-hidden":"true",children:I("chat.kerriganModel")}),(0,s.jsx)("div",{className:"cs-bar",children:eU("90%")}),(0,s.jsx)("label",{htmlFor:"cs-chats-model",className:"cs-pick-label",children:I("chat.kerriganChatsModel")}),(0,s.jsx)("div",{className:"cs-bar",children:(0,s.jsx)(eB.Yb,{id:"cs-chats-model",chosen:tr,onChange:e=>void tc(e),byHand:I("chat.modelByHand"),none:eC?I("chat.modelDefault",{model:eC}):I("chat.modelByHand"),catalogue:eu,disabled:ek,style:{minWidth:0,maxWidth:"90%"}})})]}):tl?(0,s.jsxs)("div",{className:"cs-models",children:[(0,s.jsx)("span",{className:"cs-pick-label","aria-hidden":"true",children:I("chat.leadModel")}),(0,s.jsx)("div",{className:"cs-bar",children:eU("90%")}),(0,s.jsx)("label",{htmlFor:"cs-worker-model",className:"cs-pick-label",children:I("chat.workerModel")}),(0,s.jsx)("div",{className:"cs-bar",children:(0,s.jsx)(eB.Yb,{id:"cs-worker-model",chosen:tr,onChange:e=>void tc(e),byHand:I("chat.modelByHand"),none:eC?I("chat.modelDefault",{model:eC}):I("chat.workerSameModel"),catalogue:eu,disabled:ek,style:{minWidth:0,maxWidth:"90%"}})})]}):th&&!tn?(0,s.jsxs)("div",{className:"cs-models",children:[(0,s.jsx)("span",{className:"cs-pick-label","aria-hidden":"true",children:I("chat.workModel")}),(0,s.jsx)("div",{className:"cs-bar",children:eU("90%")}),(0,s.jsx)("label",{htmlFor:"cs-review-model",className:"cs-pick-label",children:I("chat.reviewModel")}),(0,s.jsx)("div",{className:"cs-bar",title:I("chat.reviewModelWhy"),children:(0,s.jsx)(eB.Yb,{id:"cs-review-model",chosen:tf,onChange:e=>void tg(e),none:tb?I("chat.reviewModelDefault",{model:tb}):I("chat.reviewModelByHand"),catalogue:eu,disabled:ek,style:{minWidth:0,maxWidth:"90%"}})})]}):(0,s.jsx)("div",{className:"cs-bar",children:eU("48%")}),(0,s.jsxs)("div",{className:"cs-bar cs-skills",children:[eO.length>0&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("label",{htmlFor:"cs-skill",className:"cs-pick-label",children:I("chat.skill")}),(0,s.jsxs)("select",{id:"cs-skill",value:ev,onChange:e=>ej(e.target.value),disabled:ek,title:I("chat.skillWhy"),style:{minWidth:0,maxWidth:"60%"},children:[(0,s.jsx)("option",{value:"",children:I("chat.skillNone")}),eO.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:I("chat.skillsLinkWhy"),children:I("chat.skillsLink")}),(0,s.jsx)(eQ,{workspace:F,running:eK,onMade:e=>{eZ(),ec("".concat(e," ").concat(I("nb.madeChat"))),L()}})]}),(0,s.jsxs)("div",{className:"cs-bar",children:[(0,s.jsxs)("label",{className:"cs-plan-toggle cs-kerrigan-toggle",title:I("chat.kerriganWhy"),children:[(0,s.jsx)("input",{type:"checkbox",checked:tn,disabled:ek||!!T,onChange:e=>{var t;return t=e.target.checked,void(!T&&(ee(t),e9(e7,t?"on":""),t&&(G(!1),e9(e8,""))))}}),(0,s.jsx)("span",{children:I("chat.kerrigan")})]}),!tn&&(0,s.jsxs)("label",{className:"cs-plan-toggle",title:I("chat.planModeWhy"),children:[(0,s.jsx)("input",{type:"checkbox",checked:td,disabled:ek,onChange:e=>void tu(e.target.checked)}),(0,s.jsx)("span",{children:I("chat.planMode")})]}),!tn&&(0,s.jsxs)("label",{className:"cs-plan-toggle cs-lead-toggle",title:I("chat.leadWhy"),children:[(0,s.jsx)("input",{type:"checkbox",checked:tl,disabled:ek||!!T,onChange:e=>{var t;return t=e.target.checked,void(!T&&(G(t),e9(e8,t?"on":""),t&&(ee(!1),e9(e7,""))))}}),(0,s.jsx)("span",{children:I("chat.lead")})]}),!tl&&!tn&&(0,s.jsxs)("label",{className:"cs-plan-toggle cs-review-toggle",title:I("chat.reviewWhy"),children:[(0,s.jsx)("input",{type:"checkbox",checked:th,disabled:ek,onChange:e=>void tm(e.target.checked)}),(0,s.jsx)("span",{children:I("chat.review")})]}),(0,s.jsxs)("span",{className:"cs-actions",children:[ek&&(0,s.jsx)("button",{type:"button",className:"cs-pause",onClick:()=>void tw(),title:tv?I("chat.resumeWhy"):I("chat.pauseWhy"),children:tv?I("chat.resume"):I("chat.pause")}),ek&&(0,s.jsx)("button",{type:"button",className:"danger cs-stop",onClick:()=>{T&&!tk&&(ty(!0),r.FH.stop(T.id).then(()=>ec(I("chat.stopping"))).catch(e=>{ty(!1),ec(e.message)}))},disabled:tk,"aria-busy":tk||void 0,children:tk?(0,s.jsxs)(s.Fragment,{children:[I("chat.stoppingNow"),(0,s.jsx)("span",{className:"saving-dots",children:tN})]}):I("chat.stop")}),(0,s.jsx)("button",{type:"button",className:"primary",disabled:en||!es.trim()||!(null==F?void 0:F.ok),onClick:()=>void e0(),title:I("chat.sendWhy"),children:ek?I("chat.sendNote"):I("chat.send")})]})]})]})]})}function ta(e){var t;let{workspace:a,onPick:l,onOpenFolder:n}=e,{t:i}=(0,p.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 ts(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 tl(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)(e_.s,{text:e.notes}),(0,s.jsx)("div",{className:"cs-copy-row",children:(0,s.jsx)(V.i8,{text:e.notes,what:"chat.copyReply"})})]},t):null:"step"===e.kind?(0,s.jsx)(td,{step:e},t):"handoff"===e.kind?(0,s.jsx)(eA.Q$,{card:e.card,outcome:e.outcome,answer:e.answer},t):null})})}function tn(e){let{task:t,n:a,onRewind:l}=e,{t:n}=(0,p.kj)(),i=(0,p.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)(tb,{skill:t.skill}),(0,s.jsx)(to,{children:(0,s.jsx)(e_.s,{text:t.prompt})}),(0,s.jsx)("div",{className:"cs-copy-row",children:(0,s.jsx)(V.i8,{text:t.prompt,what:"chat.copyMessage"})})]})]})}function ti(e){var t,a,l,n;let{n:i,session:c,task:o,approvals:d,onDecided:u,onOpenFile:h,onRewind:m}=e,{t:x}=(0,p.kj)(),f="running"===o.status||"waiting-approval"===o.status,b=ts(c.id,o);return(0,s.jsxs)("section",{className:"cs-turn",id:"cs-turn-".concat(o.id),"aria-label":x("chat.turn",{text:o.title}),children:[(0,s.jsx)(tn,{task:o,n:i,onRewind:m}),"queued"===o.status&&(0,s.jsx)("p",{className:"muted small cs-system",children:x("idle"===c.status?"chat.queued":"chat.waitingTurn")}),(0,s.jsx)(tl,{entries:b}),(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:x("chat.planShown",{v:o.plan.version})}),(0,s.jsx)(eK.D,{plan:o.plan})]}),d.map(e=>(0,s.jsx)(th,{approval:e,onDecided:u},e.id)),f&&(0,s.jsxs)("p",{className:"cs-working",role:"status",children:[o.acting?(0,s.jsx)(eU.y,{actor:o.acting.actor,acting:o.acting}):(0,s.jsx)("span",{className:"wb-live","aria-hidden":"true"})," ",x("chat.working",{n:o.iterations})]}),!f&&"queued"!==o.status&&(0,s.jsx)(tr,{task:o}),!f&&(0,s.jsx)(tf,{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:x("chat.exchangeWhy"),children:x("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:x("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)(_,{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)(eN,{sessionId:c.id,taskId:o.id,runId:o.runId,title:o.title,files:o.vcs.files.length})]})]})}function tr(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*tc)};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)(t5,{status:t.status}),(0,s.jsxs)("div",{className:"grow",ref:a,children:[t.summary?(0,s.jsx)(e_.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)(V.i8,{text:r,what:"chat.copySummary"})})]}),r&&(0,s.jsx)(V.i8,{text:r,what:"chat.copySummary"})]})}let tc=6;function to(e){let{children:t}=e,{t:a}=(0,p.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 td(e){let{step:t}=e,{t:a}=(0,p.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)(V.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 tu=e=>({"data-awaits":e.id,tabIndex:-1});function th(e){var t;let{approval:a,onDecided:l}=e,{t:n}=(0,p.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)(eU.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)(tm,{approval:a,onDecided:l})]}):(0,s.jsx)(tm,{approval:a,onDecided:l})}function tm(e){var t,a,l;let{approval:n,onDecided:i}=e,{t:c}=(0,p.kj)(),{err:o,choose:d,mark:u}=(0,eR.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",...tu(n),children:(0,s.jsx)(e$.M,{approval:n,onDecided:e=>i(n.id,e)})}):(null==(t=n.question)?void 0:t.handoff)?(0,s.jsx)(tN,{approval:n,onDecided:i}):n.question?(0,s.jsx)(tC,{approval:n,onDecided:i}):n.retry?(0,s.jsx)(ty,{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"),...tu(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)(eU.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)(V.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)(eA.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&&(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")})]}),o&&(0,s.jsx)("p",{className:"err",role:"alert",children:o}),(0,s.jsx)(V.T4,{text:(0,e2.Mo)(c,n)})]})}function tp(e){var t,a,n,i,c,o,d,u,h,m,x,f,b,g,v,j,w,k;let{n:y,session:N,task:C,worker:S,approvals:F,onDecided:M,onOpenFile:O,onRewind:q,onRetrySubtask:L}=e,{t:E}=(0,p.kj)(),z="running"===C.status||"waiting-approval"===C.status,I=null!=(g=null==(t=C.lead)?void 0:t.rounds)?g:[],D=new Map(I.filter(e=>e.subtask).map(e=>[e.subtask.n,e.n])),W=null==(a=I.filter(e=>"plan"===e.status).at(-1))?void 0:a.n,H=F.filter(e=>e.taskId===C.id),R=(null==(n=I.at(-1))?void 0:n.subtask)&&(null==S?void 0:S.tasks.find(e=>{var t,a;return e.id===(null==(a=I.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(C.id),"aria-label":E("chat.turn",{text:C.title}),children:[(0,s.jsx)(tn,{task:C,n:y,onRewind:q}),"queued"===C.status&&(0,s.jsx)("p",{className:"muted small cs-system",children:"idle"===N.status?E("chat.queued"):E("chat.waitingTurn")}),I.map(e=>{var t,a;return(0,s.jsxs)(l.Fragment,{children:[e.understanding&&(0,s.jsx)(tg,{who:E("lead.understood"),text:e.understanding}),e.notes&&(0,s.jsx)(tg,{who:E("lead.who"),text:e.notes}),e.ledger&&(0,s.jsx)(eX,{change:e.ledger}),"plan"===e.status&&e.n===W&&C.plan&&!H.some(e=>e.plan)&&(0,s.jsxs)("details",{className:"cs-plan",children:[(0,s.jsx)("summary",{children:E("lead.plan",{v:C.plan.version})}),(0,s.jsx)(eK.D,{plan:C.plan})]}),e.subtask&&D.get(e.subtask.n)===e.n&&(0,s.jsx)(tv,{round:e,worker:S,approvals:F.filter(t=>{var a;return t.taskId===(null==(a=e.subtask)?void 0:a.taskId)}),onDecided:M,onOpenFile:O,onRetry:L?t=>L(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:E("lead.question")}),(0,s.jsx)(e_.s,{text:e.question.text}),(0,s.jsx)("div",{className:"cs-copy-row",children:(0,s.jsx)(V.i8,{text:(0,e2.yw)(E,{...e.question,options:null!=(a=e.question.options)?a:[]},!1),what:"chat.copyQuestion"})}),(0,s.jsx)("p",{className:"cs-who",children:E("lead.answered")}),(0,s.jsx)(e_.s,{text:e.question.answer}),(0,s.jsx)("div",{className:"cs-copy-row",children:(0,s.jsx)(V.i8,{text:e.question.answer,what:"chat.copyAnswer"})})]})]},e.n)}),H.map(e=>(0,s.jsx)(th,{approval:e,onDecided:M},e.id)),z&&(0,s.jsxs)("p",{className:"cs-working",role:"status",children:[C.acting?(0,s.jsx)(eU.y,{actor:C.acting.actor,acting:C.acting}):(0,s.jsx)("span",{className:"wb-live","aria-hidden":"true"})," ",R?(null==(i=C.lead)?void 0:i.ledger)?E("lead.workingOn",{title:null!=(v=null==(o=I.at(-1))||null==(c=o.subtask)?void 0:c.title)?v:""}):E("lead.working",{n:null!=(j=null==(u=I.at(-1))||null==(d=u.subtask)?void 0:d.n)?j:0}):E("lead.thinking")]}),C.lead&&(z||C.lead.ledger)&&(0,s.jsx)(eG,{lead:C.lead,live:z}),(null==(h=C.lead)?void 0:h.messages)&&(0,s.jsx)("p",{className:"muted small cs-lead-count",children:E("lead.messages",{lead:C.lead.messages.lead,worker:C.lead.messages.worker,total:C.lead.messages.lead+C.lead.messages.worker})}),!z&&"queued"!==C.status&&(0,s.jsx)(tr,{task:C}),!z&&(0,s.jsx)(tf,{session:N,task:C}),!z&&(null!=(w=null==(x=C.lead)||null==(m=x.evidence)?void 0:m.length)?w:0)>0&&(0,s.jsxs)("div",{className:"cs-evidence",children:[(0,s.jsx)("p",{className:"cs-who",children:E("lead.evidence")}),(0,s.jsx)("ul",{children:C.lead.evidence.map(e=>(0,s.jsx)("li",{children:(0,s.jsx)(e_.s,{text:e})},e))}),(0,s.jsx)("div",{className:"cs-copy-row",children:(0,s.jsx)(V.i8,{text:C.lead.evidence.map(e=>"- ".concat(e)).join("\n"),what:"chat.copyEvidence"})})]}),C.runId&&(0,s.jsx)("div",{className:"cs-exchange",children:(0,s.jsx)("a",{className:"button-link quiet small",href:r.FH.taskExchangeUrl(N.id,C.id),download:!0,title:E("chat.exchangeWhy"),children:E("chat.exchange")})}),(null!=(k=null==(b=C.vcs)||null==(f=b.files)?void 0:f.length)?k:0)>0&&!z&&(0,s.jsxs)("div",{className:"cs-files",children:[(0,s.jsx)("span",{className:"small",children:E("chat.changed",{n:C.vcs.files.length})}),C.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)(_,{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)(eN,{sessionId:N.id,taskId:C.id,runId:C.runId,title:C.title,files:C.vcs.files.length})]})]})}function tx(e){var t,a,n,i,c,o,d,u;let{n:h,session:m,task:x,threads:f,approvals:b,onDecided:g,onOpenFile:v,onOpenChat:j,onRewind:w}=e,{t:k}=(0,p.kj)(),y="running"===x.status||"waiting-approval"===x.status,N=x.kerrigan,C=null!=(o=null==N?void 0:N.rounds)?o:[],S=e=>{var t,a;return(null!=(a=null==(t=f.find(t=>t.id===e))?void 0:t.name)?a:"").replace(/^chat: /,"")||k("kz.aChat")},F=y?b.filter(e=>e.taskId===x.id||e.sessionId!==m.id):[],M=null==(t=[...C].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(x.id),"aria-label":k("chat.turn",{text:x.title}),children:[(0,s.jsx)(tn,{task:x,n:h,onRewind:w}),"queued"===x.status&&(0,s.jsx)("p",{className:"muted small cs-system",children:"idle"===m.status?k("chat.queued"):k("chat.waitingTurn")}),C.map((e,t)=>{var a,n,i;return(0,s.jsxs)(l.Fragment,{children:[e.understanding&&(0,s.jsx)(tg,{who:k("kz.understood"),text:e.understanding}),e.notes&&(0,s.jsx)(tg,{who:k("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:k("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:k("kz.send",{n:e.send.n,name:S(e.send.sessionId)})}),(0,s.jsxs)("p",{className:"cs-kz-chips",children:[(0,s.jsx)("span",{className:"badge",children:"same"===e.send.chat?k("kz.sameChat"):k("kz.newChat")}),e.send.planMode&&(0,s.jsx)("span",{className:"badge",children:k("kz.planMode")}),e.send.twoChats&&(0,s.jsx)("span",{className:"badge",children:k("kz.twoChats")}),e.send.review&&(0,s.jsx)("span",{className:"badge",children:k("kz.review")}),e.send.skill&&(0,s.jsx)("span",{className:"badge skill",children:k("chat.skillUsed",{name:e.send.skill})})]}),(0,s.jsx)(to,{children:(0,s.jsx)(e_.s,{text:e.send.prompt})}),(0,s.jsxs)("div",{className:"cs-copy-row",children:[(0,s.jsx)(V.i8,{text:e.send.prompt,what:"kz.copyPrompt"}),e.send.sessionId&&(0,s.jsx)("button",{type:"button",className:"quiet small cs-kz-open",onClick:()=>j(e.send.sessionId),title:k("kz.openChatWhy"),children:k("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)(t5,{status:e.send.status})," ",k("kz.chatEnded")]})]}),e.card&&(0,s.jsxs)("div",{className:"cs-bot cs-kz-answer",children:[(0,s.jsxs)("p",{className:"cs-who",children:[k("kz.cardHead")," ",e.card.actor&&(0,s.jsx)(eU.y,{actor:e.card.actor,how:"asks"})]}),(0,s.jsx)(e_.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?k("kz.youAnswered",{answer:e.card.answer}):k("kz.answered",{answer:e.card.answer})})}),e.card.yours&&(0,s.jsxs)("p",{className:"small cs-kz-yours",children:[k("kz.leftToYou",{why:e.card.yours.why}),e.card.yours.suggestion?" ".concat(k("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:k("kz.asked")}),(0,s.jsx)(e_.s,{text:e.question.text}),(0,s.jsx)("div",{className:"cs-copy-row",children:(0,s.jsx)(V.i8,{text:(0,e2.yw)(k,{...e.question,options:null!=(i=e.question.options)?i:[]},!1),what:"chat.copyQuestion"})}),(0,s.jsx)("p",{className:"cs-who",children:k("lead.answered")}),(0,s.jsx)(e_.s,{text:e.question.answer})]}),"blocked"===e.status&&e.needed&&(0,s.jsx)("p",{className:"small cs-kz-needed",children:k("kz.needed",{needed:e.needed})})]},"".concat(e.at,"-").concat(t))}),F.map(e=>(0,s.jsx)(th,{approval:e,onDecided:g},e.id)),y&&(0,s.jsxs)("p",{className:"cs-working",role:"status",children:[x.acting?(0,s.jsx)(eU.y,{actor:x.acting.actor,acting:x.acting}):(0,s.jsx)("span",{className:"wb-live","aria-hidden":"true"})," ",O?k("kz.chatWorking",{n:M.n,name:S(M.sessionId)}):k("kz.working")]}),N&&(N.sent>0||N.messages>0)&&(0,s.jsx)("p",{className:"muted small cs-kz-count",children:k("kz.counts",{sent:N.sent,max:N.maxSends,messages:N.messages})}),!y&&"queued"!==x.status&&(0,s.jsx)(tr,{task:x}),!y&&(null!=(d=null==(n=C.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:k("lead.evidence")}),(0,s.jsx)("ul",{children:C.at(-1).evidence.map(e=>(0,s.jsx)("li",{children:(0,s.jsx)(e_.s,{text:e})},e))}),(0,s.jsx)("div",{className:"cs-copy-row",children:(0,s.jsx)(V.i8,{text:C.at(-1).evidence.map(e=>"- ".concat(e)).join("\n"),what:"chat.copyEvidence"})})]}),x.runId&&(0,s.jsx)("div",{className:"cs-exchange",children:(0,s.jsx)("a",{className:"button-link quiet small",href:r.FH.taskExchangeUrl(m.id,x.id),download:!0,title:k("chat.exchangeWhy"),children:k("chat.exchange")})}),(null!=(u=null==(c=x.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:k("chat.changed",{n:x.vcs.files.length})}),x.vcs.files.slice(0,12).map(e=>(0,s.jsxs)("button",{type:"button",className:"cs-file",onClick:()=>v(e.path),title:e.path,children:[(0,s.jsx)(_,{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)(eN,{sessionId:m.id,taskId:x.id,runId:x.runId,title:x.title,files:x.vcs.files.length})]})]})}function tf(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)(e1.a,{parked:a.parked,onAnswer:async e=>void await r.FH.answerParked(l,e)})})}function tb(e){let{skill:t}=e,{t:a}=(0,p.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 tg(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)(e_.s,{text:a}),(0,s.jsx)("div",{className:"cs-copy-row",children:(0,s.jsx)(V.i8,{text:a,what:"chat.copyReply"})})]})}function tv(e){var t,a,l,n,i,r,c,o;let{round:d,worker:u,approvals:h,onDecided:m,onOpenFile:x,onRetry:f}=e,{t:b}=(0,p.kj)(),g=(0,eR.p)(),v=d.subtask,j=null==u?void 0:u.tasks.find(e=>e.id===v.taskId),w=(null==j?void 0:j.status)==="running"||(null==j?void 0:j.status)==="waiting-approval",k=ts(null!=(l=null==u?void 0:u.id)?l:"",j),y=null!=(n=v.attempts)?n:[],N=y.at(-1),C=null!=(i=v.maxAttempts)?i:y.length,S=y.slice(0,-1),F=y.length>1,M=!w&&!!N&&"done"!==N.status&&!!N.category,O=!!f&&!!j&&"done"!==j.status&&!w;return(0,s.jsxs)("details",{className:"cs-subtask s-".concat(null!=(r=null==j?void 0:j.status)?r:"queued"),open:w||h.length>0||O||void 0,children:[(0,s.jsxs)("summary",{children:[(0,s.jsx)(t5,{status:null!=(c=null==j?void 0:j.status)?c:"queued"})," ",(0,s.jsx)("span",{children:b("lead.subtask",{n:v.n,title:v.title})}),v.readOnly&&(0,s.jsx)("span",{className:"badge",children:b("lead.readOnly")}),v.fresh&&(0,s.jsx)("span",{className:"badge",children:b("lead.fresh")}),w&&F&&N&&(0,s.jsx)("span",{className:"badge running cs-attempt",children:b("retry.retrying",{k:N.attempt,m:C})}),!w&&F&&(null==j?void 0:j.status)==="done"&&N&&(0,s.jsx)("span",{className:"badge done cs-attempt",children:b("retry.doneAt",{k:N.attempt})}),M&&(0,s.jsx)("span",{className:"badge failed cs-attempt",children:b("retry.attempt",{k:N.attempt,m:C})})]}),(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:b(e2.P3[N.category])})," ",N.reason&&(0,s.jsx)("span",{children:N.reason})]}),S.length>0&&(0,s.jsx)(tj,{attempts:S,max:C,worker:u}),F&&(0,s.jsx)("p",{className:"cs-who cs-attempt-now",children:b("retry.attempt",{k:N.attempt,m:C})}),(0,s.jsx)(tl,{entries:k}),h.map(e=>(0,s.jsx)(th,{approval:e,onDecided:m},e.id)),j&&!w&&"queued"!==j.status&&(0,s.jsx)(tr,{task:j}),j&&(null!=(o=null==(a=j.vcs)||null==(t=a.files)?void 0:t.length)?o:0)>0&&!w&&(0,s.jsx)("div",{className:"cs-files",children:j.vcs.files.slice(0,8).map(e=>(0,s.jsxs)("button",{type:"button",className:"cs-file",onClick:()=>x(e.path),title:e.path,children:[(0,s.jsx)(_,{path:e.path})," ",e.path.split("/").pop()]},e.path))}),O&&f&&(0,s.jsxs)("div",{className:"cs-retry-after",role:"group","aria-label":b("retry.afterStop"),children:[(0,s.jsx)("p",{className:"muted small",children:b("retry.afterStopWhy")}),(0,s.jsxs)("div",{className:"row",children:[(0,s.jsx)("button",{type:"button",className:"primary",...g.mark("same"),onClick:()=>void g.choose("same",()=>f(!1)),children:b("retry.same")}),(0,s.jsx)("button",{type:"button",...g.mark("fresh"),onClick:()=>void g.choose("fresh",()=>f(!0)),children:b("retry.fresh")})]}),(0,s.jsx)(V.T4,{text:(0,e2.qq)(b,v.n,v.title)})]})]})]})}function tj(e){let{attempts:t,max:a,worker:l}=e,{t:n}=(0,p.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)(tw,{attempt:e,max:a,worker:l},e.attempt))]})}function tw(e){var t;let{attempt:a,max:n,worker:i}=e,{t:r}=(0,p.kj)(),c=(0,p.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)(t5,{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(e2.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)(tk,{sessionId:null!=(t=null==i?void 0:i.id)?t:"",task:u})]})]})}function tk(e){let{sessionId:t,task:a}=e,l=ts(t,a);return(0,s.jsx)(tl,{entries:l})}function ty(e){var t;let{approval:a,onDecided:l}=e,{t:n}=(0,p.kj)(),{err:i,choose:c,mark:o}=(0,eR.p)(),d=a.retry,u=async e=>{("restore"!==e||await (0,eP.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}),...tu(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)(eU.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(e2.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(e2.Sx[e])},e))}),i&&(0,s.jsx)("p",{className:"err",role:"alert",children:i}),(0,s.jsx)(V.T4,{text:(0,e2.Mo)(n,a)})]})}function tN(e){var t;let{approval:a,onDecided:n}=e,{t:i}=(0,p.kj)(),c=(0,l.useId)(),[o,d]=(0,l.useState)(""),[u,h]=(0,l.useState)(!1),[m,x]=(0,l.useState)(""),{locked:f,err:b,choose:g,mark:v}=(0,eR.p)(),j=a.question,w=async e=>{let t="revise"===e?m:o;("ran"!==e&&"revise"!==e||t.trim())&&n(a.id,await g(e,async()=>{await r.FH.answerQuestion(a.id,t,e)}))},k=async()=>{await (0,eP.Z)(i("lead.stopConfirm"))&&n(a.id,await g("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"),...tu(a),children:[(0,s.jsxs)("p",{className:"small cs-ask-head",children:[(0,s.jsx)("strong",{children:i("ho.title")})," ",(0,s.jsx)(eU.y,{actor:null!=(t=a.actor)?t:"worker",how:"asks"})]}),(0,s.jsx)(eA.Lp,{card:j.handoff,why:j.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",...v("ran"),disabled:f||!o.trim(),onClick:()=>void w("ran"),children:i("ho.send")}),(0,s.jsx)("button",{type:"button",...v("revise"),"aria-expanded":u,onClick:()=>h(e=>!e),title:i("ho.reviseWhy"),disabled:f,children:i("ho.revise")}),(0,s.jsx)("button",{type:"button",...v("declined"),onClick:()=>void w("declined"),title:i("ho.notRunWhy"),children:i("ho.notRun")}),(0,s.jsx)("button",{type:"button",className:"danger",...v("stop"),onClick:()=>void k(),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=>x(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 w("revise"),children:i("ho.reviseSend")})})]}),b&&(0,s.jsx)("p",{className:"err",role:"alert",children:b}),(0,s.jsx)(V.T4,{text:(0,e2.Mo)(i,a)})]})}function tC(e){var t;let{approval:a,onDecided:n}=e,{t:i}=(0,p.kj)(),c=(0,l.useId)(),{locked:o,err:d,choose:u,mark:h}=(0,eR.p)(),m=a.question,x=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))}))},b=async()=>{await (0,eP.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"===x?"lead.question":"chat.question"),...tu(a),children:[(0,s.jsxs)("p",{className:"small cs-ask-head",children:[(0,s.jsx)("strong",{children:i("lead"===x?"lead.question":"chat.question")})," ",(0,s.jsx)(eU.y,{actor:x,how:"asks"})]}),(0,s.jsx)(e_.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)(V.i8,{text:(0,e2.yw)(i,m,!0),what:"chat.copyQuestion"})}),(0,s.jsx)(e3.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 b(),children:i("lead.stop")})}),d&&(0,s.jsx)("p",{className:"err",role:"alert",children:d}),(0,s.jsx)(V.T4,{text:(0,e2.Mo)(i,a)})]})}function tS(e){let{workspace:t,composeAsk:a,showThread:l,onOpenFile:n,onOpenFolder:i,onTurn:r,onChange:c,onClose:o,grip:d}=e,{t:u}=(0,p.kj)(),h=(0,eq.v)(),m=(0,eL.ms)(h),x=(0,eL.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:x,"aria-label":x,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)(tt,{workspace:t,composeAsk:a,showThread:l,onOpenFile:n,onChange:c,onOpenFolder:i,onTurn:r})]})}var tF=a(5462);let tM=[{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 tO(e){let{open:t,onToggle:a,tab:n,onTab:i,session:r,task:c,newChat:o=!1,onShowMessage:d}=e,{t:u}=(0,p.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,x]=(0,l.useState)(()=>new Set),[f,b]=(0,l.useState)(!1),[g,v]=(0,l.useState)(()=>new Set);(0,l.useEffect)(()=>x(tz()),[]);let j=e=>x(function(e){let t=[...new Set([...tz(),...e.filter(e=>e)])].slice(-500);try{window.localStorage.setItem(tE,JSON.stringify(t))}catch(e){}return new Set(t)}(e)),w=h.filter(e=>!m.has(e.key)),k=f?h:w,y=h.length-w.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:[tM.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&&w.length>0&&(0,s.jsx)("span",{className:"wb-badge",children:w.length})]}),(0,s.jsx)(tF.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)(tI,{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===k.length?(0,s.jsx)("p",{className:"muted small wb-pad",children:u("wb.problemsNoneNew")}):(0,s.jsx)("ul",{className:"wb-problems",children:k.map((e,t)=>{let a=g.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,v(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:()=>j([e.key]),title:u("wb.problemSeenWhy"),children:u("wb.problemSeen")})]}),a&&r&&(0,s.jsx)(tL,{id:"wb-problem-".concat(t),problem:e,session:r,onShowMessage:d})]},e.key)})}),(w.length>1||y>0)&&(0,s.jsxs)("div",{className:"row wb-pad",children:[w.length>1&&(0,s.jsx)("button",{type:"button",className:"quiet small",onClick:()=>j(w.map(e=>e.key)),title:u("wb.problemSeenWhy"),children:u("wb.problemsAllSeen")}),y>0&&(0,s.jsx)("button",{type:"button",className:"quiet small",onClick:()=>b(!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)(tD,{session:r})})]})}let tq={check:"wb.problemFromCheck",review:"wb.problemFromReview",stop:"wb.problemFromStop",vcs:"wb.problemFromVcs"};function tL(e){var t;let{id:a,problem:n,session:i,onShowMessage:r}=e,{t:c}=(0,p.kj)(),o=(0,p.W3)(),d=c("status.".concat(n.status)),u=c(tq[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: /,""),x=(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",x?"".concat(m," (").concat(c("wb.problemInCopilot",{name:x}),")"):m],["wb.problemMessage","".concat(n.n,". ").concat(n.title)],...n.place?[["wb.problemPlace",n.place]]:[]],b=[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)(V.i8,{text:b,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 tE="cop.problems.seen";function tz(){try{var e;let t=JSON.parse(null!=(e=window.localStorage.getItem(tE))?e:"[]");return new Set(Array.isArray(t)?t.filter(e=>"string"==typeof e):[])}catch(e){return new Set}}function tI(e){var t,a;let{session:n,task:i}=e,{t:c}=(0,p.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}=eT(!!u,null!=(t=null==o?void 0:o.entries.length)?t:0),x=()=>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),x()},[null==i?void 0:i.id,null==i?void 0:i.runId]),(0,m.z)(x,u?2e3:15e3,!!n&&!!i),!i)return(0,s.jsx)("p",{className:"muted small wb-pad",children:c("wb.pickChat")});let f=[],b=e=>e.forEach(e=>"step"===e.kind?f.push(e):"review"===e.kind?b(e.entries):void 0);return(b(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 tD(e){let{session:t}=e,{t:a}=(0,p.kj)(),n=(0,p.W3)(),[i,c]=(0,l.useState)([]),{ref:o}=eT(!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 tW(e){var t,a,n,i,c,o,d,u,h,x,f;let{sessions:b,session:g,workspace:v,onShowThread:j,onApprovals:w,onShowWaiting:k}=e,{t:y}=(0,p.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),[C,S]=(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)(w);O.current=w,(0,m.z)(()=>r.FH.approvals().then(e=>{var t;S(e),null==(t=O.current)||t.call(O,e)}).catch(()=>void 0),3e3);let q=null!=(c=b.find(e=>"idle"!==e.status&&!e.workerOf))?c:b.find(e=>"idle"!==e.status),L=null==q?void 0:q.tasks.find(e=>"running"===e.status||"waiting-approval"===e.status),E=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==L?void 0:L.startedAt,null==q?void 0:q.pauses,N)/6e4);return(0,s.jsxs)("footer",{className:"wb-statusbar","aria-label":y("wb.status"),children:[(null==v?void 0:v.ok)&&(0,s.jsxs)("span",{title:v.dir,children:[(0,s.jsx)(et.O,{})," ",v.branch?"".concat(v.name," \xb7 ").concat(v.branch):v.name]}),q&&L?(0,s.jsxs)("button",{type:"button",className:"wb-status-btn",onClick:()=>j(q.id),title:y("wb.openRunning"),children:[(0,s.jsx)("span",{className:q.paused?"wb-live paused":"wb-live","aria-hidden":"true"})," ",L.acting&&(0,s.jsx)(eU.y,{actor:L.acting.actor,acting:L.acting})," ",L.lead?y("wb.runningLineTwo",{session:q.name.replace(/^chat: /,""),task:L.title,lead:null!=(o=null==(t=L.lead.messages)?void 0:t.lead)?o:0,worker:null!=(d=null==(a=L.lead.messages)?void 0:a.worker)?d:0,total:(null!=(u=null==(n=L.lead.messages)?void 0:n.lead)?u:0)+(null!=(h=null==(i=L.lead.messages)?void 0:i.worker)?h:0),m:E,maxm:F.minutes}):y("wb.runningLine",{session:q.name.replace(/^chat: /,""),task:L.title,n:L.iterations,max:F.iterations,m:E,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"}),C.length>0&&(0,s.jsx)("button",{type:"button",className:"wb-status-btn warn",onClick:()=>{var e;let t=C[0];!t.model&&(null==k?void 0:k(t))||null==(e=document.querySelector(".approval-banner"))||e.scrollIntoView({block:"start"})},children:y("wb.waiting",{n:C.length})}),g&&(0,s.jsx)("span",{title:y("wb.modelNow"),children:null!=(f=null!=(x=g.modelInUse)?x:g.model)?f:y("wb.modelDefault")})]})}var tH=a(1702);function tR(e){let{commands:t,onClose:a}=e,{t:n}=(0,p.kj)(),i=(0,tH.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),x=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(),x(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:()=>x(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 tA(){let{t:e}=(0,p.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 tT(e){let{workspace:t}=e,{t:a,locale:n}=(0,p.kj)(),i=(0,tF.f)("below"),[c,o]=(0,l.useState)(""),[d,u]=eW(),[h,m]=(0,l.useState)([]);(0,l.useEffect)(()=>{r.FH.skills().then(e=>m(e.skills)).catch(()=>void 0)},[]);let x=e=>e.trim().replace(/[\\/]+$/,"").replace(/\//g,"\\").toLowerCase(),f=h.filter(e=>!e.projectDir||(null==t?void 0:t.ok)&&x(e.projectDir)===x(t.dir)),b=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}},g=async()=>{i.close();let e=await b();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}))},v=async()=>{i.close();let e=await b();e&&o(await (0,V.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||b(),i.toggle()},children:[a("kerrigan.button")," ",(0,s.jsx)("span",{"aria-hidden":"true",children:"▾"})]}),(0,s.jsx)(tF.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)(tF.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 g(),children:a("kerrigan.save")}),(0,s.jsx)("button",{type:"button",role:"menuitem",onClick:()=>void v(),children:a("kerrigan.copy")})]}),c&&(0,s.jsx)("p",{className:"small",role:"status",children:c})]})}var tP=a(83285);let tB=(e,t)=>0===t||/[/\\._\-\s]/.test(e[t-1])||/[a-z]/.test(e[t-1])&&/[A-Z]/.test(e[t]);function t_(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(tB(e,s)){t=s;break}l+=1,t===i+1&&(l+=5),tB(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 t$(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 tU(e){let{recent:t,onOpen:a,onClose:n}=e,{t:i}=(0,p.kj)(),[c,o]=(0,l.useState)(null),[d,u]=(0,l.useState)(""),[h,m]=(0,l.useState)(0),[x,f]=(0,l.useState)(!1),b=(0,l.useRef)(null),g=(0,l.useRef)(null);(0,l.useEffect)(()=>{var e;return null==(e=b.current)?void 0:e.focus()},[]),(0,l.useEffect)(()=>{r.FH.workspaceFiles().then(e=>o(e.files)).catch(()=>o([]))},[]);let{query:v,line:j}=function(e){let t=/^(.*?):(\d+)(?::\d+)?\s*$/.exec(e);return t?{query:t[1],line:Number(t[2])}:{query:e}}(d),w=(0,l.useMemo)(()=>{if(!c)return[];if(!v.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=t_(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=t_(l,t);if(a){i+=a.score+10+8*!!l.toLowerCase().startsWith(t.toLowerCase()),r.push(...a.hits);continue}let n=t_(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,v,60)},[c,v,t]),k=0===w.length?-1:Math.min(h,w.length-1);(0,l.useEffect)(()=>{var e,t;null==(t=g.current)||null==(e=t.querySelector('[aria-selected="true"]'))||e.scrollIntoView({block:"nearest"})},[k]);let y=e=>{e&&(n(),a(e.path,j))};return(0,l.useEffect)(()=>{x&&c&&(f(!1),y(w[0]))},[x,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:b,type:"text",role:"combobox","aria-expanded":"true","aria-controls":"qo-list","aria-activedescendant":k>=0?"qo-".concat(k):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(w.length-1,k+1))):"ArrowUp"===e.key?(e.preventDefault(),m(Math.max(0,k-1))):"Enter"===e.key&&(e.preventDefault(),c?y(w[k]):f(!0))}}),(0,s.jsxs)("ul",{id:"qo-list",ref:g,role:"listbox","aria-label":i("quick.label"),children:[c&&0===w.length&&(0,s.jsx)("li",{className:"muted small qo-none",children:i("quick.none")}),w.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===k,className:"qo-row".concat(t===k?" on":""),onMouseEnter:()=>m(t),onClick:()=>y(e),title:e.path,children:[(0,s.jsx)(_,{path:e.path}),(0,s.jsx)("span",{className:"qo-name",children:t$(l,e.nameHits)}),n&&(0,s.jsx)("span",{className:"qo-dir",children:t$(n,e.dirHits)}),"recent"in e&&e.recent&&(0,s.jsx)("span",{className:"qo-tag",children:i("quick.recent")})]},e.path)})]})]})})}function tK(e){var t;let{onOpen:a,grip:n,focusAsk:i}=e,{t:c}=(0,p.kj)(),[o,d]=(0,l.useState)(""),[u,h]=(0,l.useState)(!1),[m,x]=(0,l.useState)(!1),[f,b]=(0,l.useState)(!1),[g,v]=(0,l.useState)(!1),[j,w]=(0,l.useState)(""),[k,y]=(0,l.useState)(""),[N,C]=(0,l.useState)(null),[S,F]=(0,l.useState)(!1),[M,O]=(0,l.useState)(""),[q,L]=(0,l.useState)(new Set),E=(0,l.useRef)(null),z=(0,l.useRef)(0);(0,l.useEffect)(()=>{if(i>0){var e,t;null==(e=E.current)||e.focus(),null==(t=E.current)||t.select()}},[i]);let I=async()=>{let e=++z.current;if(!o){C(null),F(!1),O("");return}F(!0);try{let t=await r.FH.workspaceSearch(o,{matchCase:u,wholeWord:m,regex:f,include:j,exclude:k});if(e!==z.current)return;C(t),O(""),L(new Set)}catch(t){e===z.current&&O(t.message)}finally{e===z.current&&F(!1)}};(0,l.useEffect)(()=>{let e=setTimeout(()=>void I(),300);return()=>clearTimeout(e)},[o,u,m,f,j,k]);let D=null!=(t=null==N?void 0:N.files)?t:[],W=D.length>0&&D.every(e=>q.has(e.path)),H=(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}),R=S?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 I(),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(""),C(null),null==(e=E.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:()=>L(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(g?" on":""),"aria-expanded":g,"aria-label":c("search.details"),title:c("search.details"),onClick:()=>v(!g),children:"…"}),(0,s.jsxs)("div",{className:"sv-box",children:[(0,s.jsx)("input",{ref:E,type:"text",value:o,onChange:e=>d(e.target.value),onKeyDown:e=>{"Enter"===e.key&&I()},placeholder:c("search.input"),"aria-label":c("search.input"),spellCheck:!1}),H(c("search.matchCase"),u,h,"Aa","case"),H(c("search.wholeWord"),m,x,(0,s.jsx)("span",{className:"sv-word",children:"ab"}),"word"),H(c("search.regex"),f,b,".*","regex")]})]}),g&&(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:j,onChange:e=>w(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:k,onChange:e=>y(e.target.value),placeholder:c("search.excludePlaceholder"),spellCheck:!1})]}),R&&(0,s.jsx)("p",{className:"sv-message".concat(M||(null==N?void 0:N.problem)?" bad":""),role:"status",children:R}),(null==N?void 0:N.truncated)&&!S&&(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:()=>L(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)(_,{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 tV=["side","center","chat"],tZ="application/x-cop-area",tJ=["wb.moveLeft","wb.moveCenter","wb.moveRight"];function tG(e){let{name:t,place:a,onMove:l,onDragging:n}=e,{t:i}=(0,p.kj)(),r=(0,tF.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(tZ,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:tJ.map((e,t)=>(0,s.jsx)("button",{type:"button",role:"menuitem",disabled:t===a,onClick:()=>{r.close(),l(t)},children:i(e)},e))})]})}let tY=e=>{var t;return"diff"===e.kind?"d:".concat(e.area,":").concat(null!=(t=e.commit)?t:"",":").concat(e.path):"f:".concat(e.path)},tX={side:290,chat:420,bottom:240,sideOpen:!0,chatOpen:!0,bottomOpen:!0,order:tV},tQ="cop.workbench.layout";function t0(){return(0,s.jsx)(l.Suspense,{fallback:null,children:(0,s.jsx)(t1,{})})}function t1(){let{t:e}=(0,p.kj)(),[t,a]=(0,l.useState)(null),[n,c]=(0,l.useState)([]),[o,d]=(0,l.useState)(""),[u,h]=(0,l.useState)("files"),[f,b]=(0,l.useState)(""),[g,v]=(0,l.useState)(null),[j,w]=(0,l.useState)(null),[k,y]=(0,l.useState)("terminal"),[N,C]=(0,l.useState)(tX),[S,F]=(0,l.useState)(!1),[M,O]=(0,l.useState)(0),[q,L]=(0,l.useState)(null),[E,z]=(0,l.useState)(new Set),I=(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),z(a=>{if(a.has(e)===t)return a;let s=new Set(a);return t?s.add(e):s.delete(e),s})},[]),D=(0,l.useCallback)(()=>r.FH.sessions().then(e=>a(e.filter(e=>"chat"===e.kind))).catch(()=>void 0),[]);(0,m.z)(D,3e3);let W=(0,l.useCallback)(()=>r.FH.workspace().then(v).catch(()=>void 0),[]);(0,m.z)(W,1e4);let H=(0,l.useCallback)(async()=>{try{var e;let t=await r.FH.browseFolder((null==g?void 0:g.dir)||void 0);if(!t.ok)return;let a=await r.FH.settings();await r.FH.saveSettings({...a.raw,project:{...null!=(e=a.raw.project)?e:{},rootDir:t.path}}),await W()}catch(e){b(e.message)}},[null==g?void 0:g.dir,W]);(0,l.useEffect)(()=>C(function(){try{var e;let t=window.localStorage.getItem(tQ);if(!t)return tX;let a={...tX,...JSON.parse(t)};return{...a,order:(e=a.order,Array.isArray(e)&&3===e.length&&tV.every(t=>e.includes(t))?e:tV)}}catch(e){return tX}}()),[]),(0,l.useEffect)(()=>{try{window.localStorage.setItem(tQ,JSON.stringify(N))}catch(e){}},[N]);let R=(0,l.useCallback)(e=>{let t=tY(e);c(a=>{let s=a.findIndex(e=>tY(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)},[]),[A,T]=(0,l.useState)(null),[P,B]=(0,l.useState)(!1),[$,U]=(0,l.useState)(null),[K,V]=(0,l.useState)(0),Z=(0,l.useCallback)((e,t)=>{R({kind:"file",path:e.path,...t?{}:{preview:!0}}),U(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}})},[R]),J=()=>{h("search"),ee({sideOpen:!0}),V(e=>e+1)},G=async t=>{let a=n.find(e=>tY(e)===t);if((null==a?void 0:a.kind)==="file"&&E.has(a.path)){var s;if(!await (0,eP.Z)(e("ed.closeUnsaved",{name:null!=(s=a.path.split("/").pop())?s:a.path})))return;I(a.path,!1)}c(e=>{let a=e.findIndex(e=>tY(e)===t),s=e.filter(e=>tY(e)!==t);return t===o&&d(s[Math.max(0,a-1)]?tY(s[Math.max(0,a-1)]):""),s})},Y=n.find(e=>tY(e)===o),X=j&&"new"!==j?null==t?void 0:t.find(e=>e.id===j.sessionId):void 0,Q=j&&"new"!==j?null==X?void 0:X.tasks.find(e=>e.id===j.taskId):void 0,ee=e=>C(t=>({...t,...e})),et=e=>{let t=n.find(t=>tY(t)===e);t&&(c(t=>t.map(t=>tY(t)===e&&t.preview?{...t,preview:!1}:t)),h("files"),ee({sideOpen:!0}),T(e=>{var a;return{path:t.path,n:(null!=(a=null==e?void 0:e.n)?a:0)+1}}))},es=()=>{ee({chatOpen:!0}),O(e=>e+1)},el=(0,l.useRef)(new Set),en=e=>{var a;let s=null==t?void 0:t.find(t=>t.id===e.sessionId);if(!s)return!1;ee({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(te(e4)))return!0;let n=null!=(a=l.at(-1))?a:s.id;return L(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(),F(!0)):"p"===t?(e.preventDefault(),B(!0)):"f"===t&&e.shiftKey?(e.preventDefault(),J()):"e"===t&&e.shiftKey?(e.preventDefault(),h("files"),ee({sideOpen:!0})):"b"!==t||e.shiftKey?"j"===t?(e.preventDefault(),ee({bottomOpen:!N.bottomOpen})):"l"===t&&(e.preventDefault(),es()):(e.preventDefault(),ee({sideOpen:!N.sideOpen}))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[N]);let ei=(0,l.useMemo)(()=>[{id:"chat",label:e("wb.cmdChat"),hint:"Ctrl+L",run:es},{id:"side",label:e("wb.cmdSide"),hint:"Ctrl+B",run:()=>ee({sideOpen:!N.sideOpen})},{id:"panel",label:e("wb.cmdPanel"),hint:"Ctrl+J",run:()=>ee({bottomOpen:!N.bottomOpen})},{id:"quick-open",label:e("wb.cmdQuickOpen"),hint:"Ctrl+P",run:()=>B(!0)},{id:"search",label:e("wb.cmdSearch"),hint:"Ctrl+Shift+F",run:J},{id:"layout",label:e("wb.cmdResetLayout"),run:()=>ee({order:tV,side:tX.side,chat:tX.chat})},{id:"files",label:e("wb.cmdFiles"),run:()=>{ee({sideOpen:!0}),h("files")}},{id:"commits",label:e("wb.cmdCommits"),run:()=>{ee({sideOpen:!0}),h("commits")}},{id:"problems",label:e("wb.cmdProblems"),run:()=>{ee({bottomOpen:!0}),y("problems")}},...Y?[{id:"keep-tab",label:e("wb.cmdKeepTab"),run:()=>et(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:()=>{ee({chatOpen:!0}),L(e=>{var a;return{id:t.id,n:(null!=(a=null==e?void 0:e.n)?a:0)+1}})}}))],[t,e,N,o,n]),[er,ec]=(0,l.useState)(!1),[eo,ed]=(0,l.useState)(null),eu=e=>N.order.indexOf(e),eh=N.order.filter(e=>"side"===e?N.sideOpen:"chat"!==e||N.chatOpen),em=eh.map(e=>1===eu(e)?"minmax(0, 1fr)":"".concat(0===eu(e)?N.side:N.chat,"px"));em.length>0&&!em.includes("minmax(0, 1fr)")&&(em[em.length-1]="minmax(0, 1fr)");let ep=["46px",...em.flatMap((e,t)=>0===t?[e]:["5px",e])].join(" "),ex=(e,t)=>ee({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}(N.order,e,t)}),ef=(e,t)=>(0,s.jsx)(tG,{area:e,name:t,place:eu(e),onMove:t=>ex(e,t),onDragging:ec}),eb=t=>({"data-area":t,"data-drop":e("wb.dropHere"),onDragOver:e=>{e.dataTransfer.types.includes(tZ)&&(e.preventDefault(),e.dataTransfer.dropEffect="move",eo!==t&&ed(t))},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||ed(e=>e===t?null:e)},onDrop:e=>{let a=e.dataTransfer.getData(tZ);e.preventDefault(),ed(null),ec(!1),a&&a!==t&&N.order.includes(a)&&ex(a,eu(t))}}),eg=e=>"".concat(er?" wb-drop":"").concat(eo===e?" wb-drop-over":""),ej={"--wb-columns":ep,"--wb-side":N.sideOpen?"".concat(N.side,"px"):"0px","--wb-chat":N.chatOpen?"".concat(N.chat,"px"):"0px","--wb-bottom":N.bottomOpen?"".concat(N.bottom,"px"):"34px"},ew={side:(0,s.jsxs)("aside",{className:"wb-side".concat(eg("side")),"aria-label":e("wb.explorer"),hidden:!N.sideOpen,...eb("side"),children:[(0,s.jsx)("div",{className:"wb-side-view",hidden:"search"!==u,children:(0,s.jsx)(tK,{onOpen:Z,grip:"search"===u?ef("side",e("wb.explorer")):void 0,focusAsk:K})}),"search"!==u&&(0,s.jsx)(ea,{view:u,onOpen:R,reveal:A,workspace:g,onOpenFolder:()=>void H(),grip:ef("side",e("wb.explorer"))})]},"side"),center:(0,s.jsxs)("section",{className:"wb-center".concat(eg("center")),"aria-label":e("wb.editor"),...eb("center"),children:[(0,s.jsxs)("div",{className:"wb-tabs",role:"tablist","aria-label":e("wb.openTabs"),children:[ef("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=tY(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:()=>et(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)(_,{path:t.path}),(0,s.jsx)("span",{className:"wb-tab-label",children:r}),"file"===t.kind&&E.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 G(i),children:"\xd7"})]},i)})]}),(0,s.jsxs)("div",{className:"wb-editor",role:"tabpanel",children:[Y?"diff"===Y.kind?(0,s.jsx)(eO,{area:Y.area,path:Y.path,commit:Y.commit},tY(Y)):null:(0,s.jsx)(t6,{workspace:g,problem:f}),n.map(e=>"file"===e.kind?(0,s.jsx)("div",{className:"wb-file-pane",hidden:tY(e)!==o,children:(0,s.jsx)(ev,{path:e.path,onDirty:I,goTo:(null==$?void 0:$.path)===e.path?$:void 0,onOpenFile:e=>R({kind:"file",path:e})})},tY(e)):null)]}),N.bottomOpen&&(0,s.jsx)(t4,{axis:"y",label:e("wb.resize"),onDrag:e=>ee({bottom:t2(N.bottom-e,90,700)})}),(0,s.jsx)(tO,{open:N.bottomOpen,onToggle:()=>ee({bottomOpen:!N.bottomOpen}),tab:k,onTab:e=>{y(e),ee({bottomOpen:!0})},session:X,task:Q,newChat:"new"===j,onShowMessage:e=>{ee({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(eg("chat")),"aria-label":e("wb.chatPanel"),hidden:!N.chatOpen,...eb("chat"),children:(0,s.jsx)(tS,{workspace:g,composeAsk:M,showThread:q,onOpenFile:e=>R({kind:"file",path:e}),onOpenFolder:()=>void H(),onTurn:w,onChange:()=>void D(),onClose:()=>ee({chatOpen:!1}),grip:ef("chat",e("wb.chatPanel"))})},"chat")};return(0,s.jsxs)("div",{className:"wb",style:ej,children:[(0,s.jsxs)("header",{className:"wb-top",children:[(0,s.jsxs)("span",{className:"wb-brand",children:[(0,s.jsx)(tP.g,{}),"copilot-operator"]}),(0,s.jsxs)("button",{type:"button",className:"wb-search",onClick:()=>F(!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)(x.i,{})]})]}),(0,s.jsxs)("div",{className:"wb-body".concat(N.sideOpen?"":" no-side").concat(N.chatOpen?"":" no-chat"),children:[(0,s.jsx)(t3,{side:u,sideOpen:N.sideOpen,onSide:e=>{e===u&&N.sideOpen?ee({sideOpen:!1}):(h(e),ee({sideOpen:!0}))},chatOpen:N.chatOpen,onChat:()=>ee({chatOpen:!N.chatOpen}),workspace:g}),N.order.map(t=>{let a=eh.indexOf(t),n=a>0?eh[a-1]:null;return(0,s.jsxs)(l.Fragment,{children:[n&&(0,s.jsx)(t4,{axis:"x",label:e("wb.resize"),onDrag:e=>{0===eu(n)?ee({side:t2(N.side+e,180,820)}):2===eu(t)&&ee({chat:t2(N.chat-e,260,820)})}}),ew[t]]},t)})]}),(0,s.jsx)(tW,{sessions:null!=t?t:[],session:X,workspace:g,onShowThread:e=>{ee({chatOpen:!0}),L(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!el.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)el.current.add(e.id);a[0]&&en(a[0])},onShowWaiting:en}),S&&(0,s.jsx)(tR,{commands:ei,onClose:()=>F(!1)}),P&&(0,s.jsx)(tU,{recent:n.filter(e=>"file"===e.kind).map(e=>e.path).reverse(),onOpen:(e,t)=>t?Z({path:e,line:t}):R({kind:"file",path:e,preview:!0}),onClose:()=>B(!1)})]})}let t2=(e,t,a)=>Math.max(t,Math.min(a,e));function t3(e){var t,a;let{side:n,sideOpen:i,onSide:c,chatOpen:o,onChat:d,workspace:u}=e,{t:x}=(0,p.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})]}),b=!!(null==u?void 0:u.ok),[g]=h(b?u.dir:""),[v,j]=(0,l.useState)(null),w=(0,l.useCallback)(()=>r.FH.workspaceGitCounts(g||void 0).then(j).catch(()=>j(null)),[g]);(0,l.useEffect)(()=>{j(null),b&&w()},[w,b,null==u?void 0:u.dir]),(0,m.z)(w,5e3,b);let k=(null==v?void 0:v.isRepo)?v.uncommitted:0,y=(null==v?void 0:v.isRepo)&&null!=(t=v.branch)?t:0,N=x("git.badgeUncommitted",{n:k}),C=x("git.badgeBranch",{n:y,base:null!=(a=null==v?void 0:v.base)?a:""}),S=[...k>0?[N]:[],...y>0?[C]:[]].join(" \xb7 "),F=e=>e>99?"99+":String(e),M=(0,s.jsxs)(s.Fragment,{children:[k>0&&(0,s.jsx)("span",{className:"wb-act-badge uncommitted","aria-hidden":"true",children:F(k)}),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":x("wb.views"),children:[f("files",x("wb.viewFiles"),(0,s.jsx)("path",{d:"M4 4h6l2 2h8v14H4z"})),f("search",x("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",x("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:S,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":x("wb.toggleChat"),title:"".concat(x("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 t4(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 t5(e){var t;let{status:a}=e,{t:l}=(0,p.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 t6(e){let{workspace:t,problem:a}=e,{t:l}=(0,p.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)(tT,{workspace:t}),(0,s.jsx)(tA,{}),(0,s.jsx)("p",{className:"muted small",children:l("wb.keys")})]})}function t8(){return(0,s.jsx)(t0,{})}},92364:(e,t,a)=>{Promise.resolve().then(a.bind(a,55522))}},e=>{e.O(0,[8197,7921,895,8124,1024,2347,3131,7358],()=>e(e.s=92364)),_N_E=e.O()}]);
|