@muyichengshayu/promptx 0.2.18 → 0.2.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/apps/web/dist/assets/{CodexSessionManagerDialog-D_72LIMv.js → CodexSessionManagerDialog-C5Cht229.js} +3 -3
  3. package/apps/web/dist/assets/{TaskDiffReviewDialog-CoQgN73y.js → TaskDiffReviewDialog-D2l8KtRI.js} +5 -5
  4. package/apps/web/dist/assets/{WorkbenchSettingsDialog-Bw-fcsXi.js → WorkbenchSettingsDialog-DGj-_tuL.js} +1 -1
  5. package/apps/web/dist/assets/WorkbenchView-ih1G4f79.js +58 -0
  6. package/apps/web/dist/assets/index-4LeM_JQe.js +2 -0
  7. package/apps/web/dist/assets/index-D9Ojj7Lp.css +1 -0
  8. package/apps/web/dist/assets/{vendor-markdown-9aQhqbjm.js → vendor-markdown-C2aIjAg9.js} +1 -1
  9. package/apps/web/dist/assets/{vendor-misc-u-M8sNMf.js → vendor-misc-DqxAnmp9.js} +30 -29
  10. package/apps/web/dist/assets/{vendor-router-Dn8q3tJM.js → vendor-router-4TN1NQvz.js} +1 -1
  11. package/apps/web/dist/assets/{vendor-shiki-core-1BqeTDsZ.js → vendor-shiki-core-UNANE_3B.js} +1 -1
  12. package/apps/web/dist/assets/vendor-shiki-lang-bash-OmlQ8O-f.js +1 -0
  13. package/apps/web/dist/assets/vendor-shiki-lang-c-Bf17QIO6.js +1 -0
  14. package/apps/web/dist/assets/vendor-shiki-lang-cpp-Dz7DCXQD.js +1 -0
  15. package/apps/web/dist/assets/vendor-shiki-lang-csharp-weekbih6.js +1 -0
  16. package/apps/web/dist/assets/vendor-shiki-lang-css-Cc89nYhT.js +1 -0
  17. package/apps/web/dist/assets/vendor-shiki-lang-diff-BKW5_WJa.js +1 -0
  18. package/apps/web/dist/assets/vendor-shiki-lang-dockerfile-DKFA3n9j.js +1 -0
  19. package/apps/web/dist/assets/vendor-shiki-lang-dotenv-BftIlyZY.js +1 -0
  20. package/apps/web/dist/assets/vendor-shiki-lang-fish-DTee4iUj.js +1 -0
  21. package/apps/web/dist/assets/vendor-shiki-lang-go-iEA7Y2np.js +1 -0
  22. package/apps/web/dist/assets/vendor-shiki-lang-html-fEXQcPZb.js +1 -0
  23. package/apps/web/dist/assets/vendor-shiki-lang-ini-BJNPDfrG.js +1 -0
  24. package/apps/web/dist/assets/vendor-shiki-lang-java-CZdBcwkx.js +1 -0
  25. package/apps/web/dist/assets/vendor-shiki-lang-javascript-5n6OdqL_.js +1 -0
  26. package/apps/web/dist/assets/vendor-shiki-lang-json-DkR7bRnH.js +1 -0
  27. package/apps/web/dist/assets/vendor-shiki-lang-less-DN-gfwMv.js +1 -0
  28. package/apps/web/dist/assets/vendor-shiki-lang-markdown-CgfEScgY.js +1 -0
  29. package/apps/web/dist/assets/vendor-shiki-lang-powershell-N9rELqmw.js +1 -0
  30. package/apps/web/dist/assets/vendor-shiki-lang-python-6ZggAICS.js +1 -0
  31. package/apps/web/dist/assets/vendor-shiki-lang-rust-BvkG5Wz9.js +1 -0
  32. package/apps/web/dist/assets/vendor-shiki-lang-sass-DFAXHETo.js +1 -0
  33. package/apps/web/dist/assets/vendor-shiki-lang-scss-ClLYCF3s.js +1 -0
  34. package/apps/web/dist/assets/vendor-shiki-lang-sql-CBrOCv6B.js +1 -0
  35. package/apps/web/dist/assets/vendor-shiki-lang-toml-C0vpllp6.js +1 -0
  36. package/apps/web/dist/assets/vendor-shiki-lang-tsx-DVg_XTuK.js +1 -0
  37. package/apps/web/dist/assets/vendor-shiki-lang-typescript-DV5oo9cD.js +1 -0
  38. package/apps/web/dist/assets/vendor-shiki-lang-vue-QYrDJbPe.js +1 -0
  39. package/apps/web/dist/assets/vendor-shiki-lang-xml-D4OZNqPk.js +1 -0
  40. package/apps/web/dist/assets/vendor-shiki-lang-yaml-BZu-v6Um.js +1 -0
  41. package/apps/web/dist/assets/vendor-shiki-theme-github-dark-default-DVxJvksW.js +1 -0
  42. package/apps/web/dist/assets/vendor-shiki-theme-github-light-BRz4x11q.js +1 -0
  43. package/apps/web/dist/assets/{vendor-tiptap-rwYdQb1L.js → vendor-tiptap-DLVi2vZE.js} +1 -1
  44. package/apps/web/dist/assets/{vendor-ui-BglsaDbv.js → vendor-ui-CnLXY_Zv.js} +31 -26
  45. package/apps/web/dist/index.html +4 -4
  46. package/package.json +1 -1
  47. package/apps/web/dist/assets/WorkbenchView-CsZnW4Q7.js +0 -58
  48. package/apps/web/dist/assets/index-Bt9T2IKp.js +0 -2
  49. package/apps/web/dist/assets/index-DaJU954y.css +0 -1
  50. package/apps/web/dist/assets/vendor-shiki-lang-bash-zsQu0xn-.js +0 -1
  51. package/apps/web/dist/assets/vendor-shiki-lang-c-BDF8vgks.js +0 -1
  52. package/apps/web/dist/assets/vendor-shiki-lang-cpp-DyDAaXl6.js +0 -1
  53. package/apps/web/dist/assets/vendor-shiki-lang-csharp-BWfTXJXw.js +0 -1
  54. package/apps/web/dist/assets/vendor-shiki-lang-css-DbAm1fUO.js +0 -1
  55. package/apps/web/dist/assets/vendor-shiki-lang-diff-DmGC1G26.js +0 -1
  56. package/apps/web/dist/assets/vendor-shiki-lang-dockerfile-3x-8396r.js +0 -1
  57. package/apps/web/dist/assets/vendor-shiki-lang-dotenv--IVOlX2Q.js +0 -1
  58. package/apps/web/dist/assets/vendor-shiki-lang-fish-Bpv3hhJP.js +0 -1
  59. package/apps/web/dist/assets/vendor-shiki-lang-go-CIGC59jP.js +0 -1
  60. package/apps/web/dist/assets/vendor-shiki-lang-html-Bt_TLLZN.js +0 -1
  61. package/apps/web/dist/assets/vendor-shiki-lang-ini-BIllfys4.js +0 -1
  62. package/apps/web/dist/assets/vendor-shiki-lang-java-CXxu9crF.js +0 -1
  63. package/apps/web/dist/assets/vendor-shiki-lang-javascript-Cha7GNZm.js +0 -1
  64. package/apps/web/dist/assets/vendor-shiki-lang-json-CCZCjDUh.js +0 -1
  65. package/apps/web/dist/assets/vendor-shiki-lang-less-DAToytC5.js +0 -1
  66. package/apps/web/dist/assets/vendor-shiki-lang-markdown-C6lwMXFp.js +0 -1
  67. package/apps/web/dist/assets/vendor-shiki-lang-powershell-lrpuM0ez.js +0 -1
  68. package/apps/web/dist/assets/vendor-shiki-lang-python-Bi9rmtY7.js +0 -1
  69. package/apps/web/dist/assets/vendor-shiki-lang-rust-GTGDbY6A.js +0 -1
  70. package/apps/web/dist/assets/vendor-shiki-lang-sass-DFtHupN8.js +0 -1
  71. package/apps/web/dist/assets/vendor-shiki-lang-scss-BrfBNyyi.js +0 -1
  72. package/apps/web/dist/assets/vendor-shiki-lang-sql-H6--iFN-.js +0 -1
  73. package/apps/web/dist/assets/vendor-shiki-lang-toml-aTteTWYL.js +0 -1
  74. package/apps/web/dist/assets/vendor-shiki-lang-tsx-DoKZm6AV.js +0 -1
  75. package/apps/web/dist/assets/vendor-shiki-lang-typescript-B5awnqri.js +0 -1
  76. package/apps/web/dist/assets/vendor-shiki-lang-vue-CnrgQ7Z5.js +0 -1
  77. package/apps/web/dist/assets/vendor-shiki-lang-xml-Bv-TNPJt.js +0 -1
  78. package/apps/web/dist/assets/vendor-shiki-lang-yaml-DpxUxQ6M.js +0 -1
  79. package/apps/web/dist/assets/vendor-shiki-theme-github-dark-default-DBX58552.js +0 -1
  80. package/apps/web/dist/assets/vendor-shiki-theme-github-light-RLAvZv0q.js +0 -1
@@ -1,5 +1,5 @@
1
- import{g as ut,t as U,f as tt,u as ke,a as st,b as ct}from"./index-Bt9T2IKp.js";import{u as ft,g as He,b as ht,l as mt,_ as vt,a as gt,c as pt,r as xt,e as yt,D as Be,d as bt,i as wt,f as kt,h as St,j as Rt}from"./WorkbenchView-CsZnW4Q7.js";import{w as te,c as z,b as Q,n as at,aD as c,aE as h,aF as a,aR as he,aS as Ie,aL as Z,aQ as o,aG as V,u as t,aW as Ue,aX as $t,aN as O,aI as ve,aT as Ft,ak as _t,aJ as we,f as Pt,a$ as We}from"./vendor-misc-u-M8sNMf.js";import{c as Ct,D as Te,f as Ke,M as Lt,V as Tt,p as It,k as Ge,C as Je,R as Qe,b as Dt,i as Mt,h as nt,F as Xe,z as Ye}from"./vendor-ui-BglsaDbv.js";import"./vendor-router-Dn8q3tJM.js";import"./vendor-markdown-9aQhqbjm.js";import"./vendor-tiptap-rwYdQb1L.js";function oe(e,r,i=""){const w=r==="run"?"run":r==="task"?"task":"workspace";return[String(e||"").trim(),w,String(i||"").trim()].join("::")}function Ne(e="",r=""){return`${String(e||"").trim()}::${String(r||"").trim()}`}function jt(e=""){return`${String(e||"").trim()}::`}function it(e){if(!e||typeof e!="object")return e;try{return JSON.parse(JSON.stringify(e))}catch{return e}}function ye(e,r){const i=e.get(r);return i?(e.delete(r),e.set(r,i),it(i)):null}function be(e,r,i,w=0){for(e.delete(r),e.set(r,it(i));w>0&&e.size>w;){const b=e.keys().next().value;if(typeof b>"u")break;e.delete(b)}}function fe(e=""){const r=String(e||"").trim().toUpperCase();return r==="A"||r==="D"?r:"M"}function At(e=""){const r=String(e||"");if(!r)return[];const i=r.split(`
2
- `),w=[];let b=0,T=0;return i.forEach((v,u)=>{const I=v.match(/^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/);if(I){b=Number(I[1]),T=Number(I[2]),w.push({id:`hunk-${u}`,kind:"hunk",oldNumber:"",newNumber:"",content:v});return}if(v.startsWith("+")&&!v.startsWith("+++")){w.push({id:`line-${u}`,kind:"add",oldNumber:"",newNumber:T,content:v}),T+=1;return}if(v.startsWith("-")&&!v.startsWith("---")){w.push({id:`line-${u}`,kind:"delete",oldNumber:b,newNumber:"",content:v}),b+=1;return}if(v.startsWith(" ")){w.push({id:`line-${u}`,kind:"context",oldNumber:b,newNumber:T,content:v}),b+=1,T+=1;return}w.push({id:`line-${u}`,kind:"meta",oldNumber:"",newNumber:"",content:v})}),w}function Ht(e=""){const r=String(e||"").trim();if(!r)return"";const i=r.match(/^当前分支已从 (.+) 切换到 (.+)$/);return i?U("diffReview.warningBranchChanged",{from:i[1],to:i[2]}):r==="当前 HEAD 已不在基线 commit 的后续历史中,仓库可能经历了 reset、rebase 或切分支"?U("diffReview.warningHeadDetachedFromBaseline"):r}function De(e=""){const r=String(e||"").trim();if(!r)return"";const w=new Map([["二进制文件暂不支持在线 diff 预览。","diffReview.binaryPreviewUnavailable"],["文件内容较大,暂不展示具体 diff。","diffReview.fileTooLarge"],["diff 内容较长,暂不在页面内完整展示。","diffReview.diffTooLong"],["diff 内容较长,当前仅展示摘要预览。","diffReview.diffPreviewOnly"],["当前工作目录不是 Git 仓库,暂不支持代码变更审查。","diffReview.notGitRepo"],["任务不存在。","diffReview.taskNotFound"],["请选择一轮执行后再查看本轮代码变更。","diffReview.runRequired"],["没有找到对应的执行记录。","diffReview.runNotFound"],["这轮执行还没有建立代码变更基线,暂时无法查看本轮 diff。","diffReview.runBaselineMissing"],["当前任务还没有建立代码变更基线,请先让 Codex 执行一轮。","diffReview.taskBaselineMissing"],["这轮执行缺少结束快照,暂时无法准确还原本轮代码变更。","diffReview.runSnapshotMissing"],["原工作目录已不是有效的 Git 仓库,暂时无法读取代码变更。","diffReview.originalRepoInvalid"],["基线对应的 commit 已不存在,仓库可能被 reset、rebase 或切换到无关历史,暂时无法准确读取该范围的代码变更。","diffReview.baselineCommitMissing"]]).get(r);return w?U(w):/^git diff 计算超时(>\d+ms)[。.]?$/.test(r)||r==="该文件 diff 计算超时,暂不在线展示详细内容。"?U("diffReview.fileDiffTimedOut"):r}function Ve(e=null){return!e||typeof e!="object"?e:{...e,reason:De(e.reason),warnings:Array.isArray(e.warnings)?e.warnings.map(r=>Ht(r)).filter(Boolean):[],files:Array.isArray(e.files)?e.files.map(r=>({...r,message:De(r==null?void 0:r.message)})):[]}}function Bt(e=[],r="",i=0){const w=Math.max(0,Number(i)||0);if(!w)return[];const b=String(r||"").trim(),T=Array.isArray(e)?e:[],v=[],u=new Set;return b&&T.find(R=>String((R==null?void 0:R.path)||"").trim()===b)&&(v.push(b),u.add(b)),T.forEach(I=>{const R=String((I==null?void 0:I.path)||"").trim();!R||u.has(R)||v.length>=w||(v.push(R),u.add(R))}),v}function Nt(e){const r=Q("workspace"),i=Q(""),w=Q(""),b=Q("all"),T=Q(""),v=Q([]),u=Q(null),I=Q(!1),R=Q(!1),M=Q(""),N=Q(!1),G=Q(null),j=Q(0),E=new Map,se=ft();let _=0,$=0,f="",C="",p="",g=-1;const X=new Map,J=new Map,q=new Map,Y=new Map,W=12e3,re=3,de=z(()=>v.value.filter(s=>s.completed)),n=z(()=>{var l;const s={all:0,A:0,M:0,D:0};return(((l=u.value)==null?void 0:l.files)||[]).forEach(m=>{const y=fe(m==null?void 0:m.status);s.all+=1,s[y]+=1}),s}),d=z(()=>{var m;const s=((m=u.value)==null?void 0:m.files)||[],l=String(T.value||"").trim().toLowerCase();return s.filter(y=>b.value!=="all"&&fe(y==null?void 0:y.status)!==b.value?!1:l?String((y==null?void 0:y.path)||"").toLowerCase().includes(l):!0)}),k=z(()=>{const s=d.value;return s.find(l=>l.path===w.value)||s[0]||null}),A=z(()=>{var s;return At(((s=k.value)==null?void 0:s.patch)||"")}),P=z(()=>A.value.map((s,l)=>({...s,index:l})).filter(s=>s.kind==="hunk")),ae=z(()=>Bt(d.value,w.value,re)),x=z(()=>{var s,l;return R.value&&!((l=(s=u.value)==null?void 0:s.summary)!=null&&l.statsComplete)}),H=z(()=>{var m;const s=((m=u.value)==null?void 0:m.baseline)||null;if(!(s!=null&&s.createdAt)&&!(s!=null&&s.headShort))return"";const l=[];return s.createdAt&&l.push(U("diffReview.baselineTime",{value:tt(s.createdAt)})),s.branch&&l.push(U("diffReview.baselineBranch",{value:s.branch})),s.headShort&&l.push(U("diffReview.baselineCommit",{value:s.headShort})),s.currentHeadShort&&l.push(U("diffReview.currentHead",{value:s.currentHeadShort})),l.join(" · ")});function L(s){return(s==null?void 0:s.status)==="completed"?U("diffReview.completed"):(s==null?void 0:s.status)==="error"?U("diffReview.failed"):(s==null?void 0:s.status)==="interrupted"?U("diffReview.interrupted"):U("diffReview.stopped")}function me(s,l){if(s){if(l){E.set(s,l);return}E.delete(s)}}function ue(s,l={}){const m=P.value;if(!m.length)return;const y=Math.min(Math.max(0,Number(s)||0),m.length-1),K=m[y],B=E.get(K.id);B&&(j.value=y,B.scrollIntoView({block:l.block||"center",behavior:l.behavior||"smooth"}))}function le(s=1){P.value.length&&ue(j.value+s)}function S(s){return`${new Date((s==null?void 0:s.startedAt)||(s==null?void 0:s.createdAt)).toLocaleString(ut())} · ${L(s)}`}function Se(){const s=de.value;if(!s.length){i.value="";return}s.some(l=>l.id===i.value)||(i.value=s[0].id)}function ce(){const s=d.value;if(!s.length){w.value="";return}s.some(l=>l.path===w.value)||(w.value=s[0].path)}function Re(s=""){return fe(s)==="A"?U("diffReview.added"):fe(s)==="D"?U("diffReview.deleted"):U("diffReview.modified")}function $e(s=""){return fe(s)==="A"?"theme-status-success":fe(s)==="D"?"theme-status-danger":"theme-status-warning"}function Fe(s="all"){return s==="A"?U("diffReview.added"):s==="D"?U("diffReview.deleted"):s==="M"?U("diffReview.modified"):U("diffReview.all")}function F(s="all"){return b.value===s?"theme-filter-active":"theme-filter-idle"}function _e(s="context"){return s==="add"?"theme-patch-add":s==="delete"?"theme-patch-delete":s==="hunk"?"theme-patch-hunk":s==="meta"?"theme-patch-meta":"theme-patch-context"}function ge(s,l=""){const m=String(l||"").trim();m&&Array.from(s.keys()).forEach(y=>{String(y||"").startsWith(m)&&s.delete(y)})}function lt(){const s=jt(e.taskSlug);ge(X,s),ge(J,s),ge(q,s)}function Me(){const s=r.value==="run"?"run":r.value==="task"?"task":"workspace",l=s==="run"?i.value:"",m=oe(e.taskSlug,s,l);return{scope:s,runId:l,signature:m}}function rt(s,l="after"){const m=String((s==null?void 0:s.path)||"").trim();if(!e.taskSlug||!m)return"";const y=Me();return ht(e.taskSlug,{scope:y.scope,runId:y.runId,filePath:m,side:l})}function ze(s=""){var m;const l=String(s||"").trim();return l&&(((m=u.value)==null?void 0:m.files)||[]).find(y=>y.path===l)||null}function Oe(s=null){return!!s&&!s.patchLoaded&&!s.binary&&!s.tooLarge&&!s.message}function pe(s="",l="",m=null,y=null){var B;const K=oe(e.taskSlug,r.value,r.value==="run"?i.value:"");return s!==K||!m||!((B=u.value)!=null&&B.files)?!1:(u.value={...u.value,baseline:(y==null?void 0:y.baseline)||u.value.baseline||null,warnings:(y==null?void 0:y.warnings)||u.value.warnings||[],files:u.value.files.map(D=>D.path===l?m:D)},!0)}async function Ee(s="",l={}){const m=String(s||"").trim(),y=String(l.signature||"").trim();if(!m||!y)return null;const K=Ne(y,m),B=ye(q,K);if(B)return{detailedFile:B,normalizedPayload:null};const D=Y.get(K);if(D)return D;const ne=(async()=>{try{const ee=await He(e.taskSlug,{scope:l.scope,runId:l.runId,filePath:m,timeoutMs:W}),ie=Ve(ee),xe=(ie.files||[]).find(Le=>Le.path===m);if(!xe)throw new Error(U("diffReview.noFileDiffContent"));return be(q,K,xe,120),{detailedFile:xe,normalizedPayload:ie}}catch(ee){return{error:ee}}finally{Y.delete(K)}})();return Y.set(K,ne),ne}async function je(){var l,m;if(!e.taskSlug||!e.active||!((l=u.value)!=null&&l.supported))return;const s=Me();for(const y of ae.value){const K=ze(y);if(!Oe(K))continue;const B=oe(e.taskSlug,r.value,r.value==="run"?i.value:"");if(s.signature!==B)return;const D=await Ee(y,s);if(D){if(D.error){const ne=De(((m=D.error)==null?void 0:m.message)||"")||U("diffReview.fileDiffTimedOut"),ee={...K,patch:"",patchLoaded:!0,tooLarge:!0,message:ne};be(q,Ne(s.signature,y),ee,120),pe(s.signature,y,ee,null);continue}pe(s.signature,y,D.detailedFile,D.normalizedPayload)}}}async function ot(){if(!e.taskSlug){v.value=[],i.value="",p="",g=-1;return}const s=se.getTaskRunSyncVersion(e.taskSlug);if(p===e.taskSlug&&g===s)return;const l=await mt(e.taskSlug,{limit:20,events:"none"});v.value=l.items||[],p=e.taskSlug,g=s,Se()}async function Ae(){if(!e.taskSlug||!e.active)return;const s=++_;I.value=!0,R.value=!1,M.value="";try{const l=r.value==="run"?"run":r.value==="task"?"task":"workspace";l==="run"&&await ot();const m=oe(e.taskSlug,l,l==="run"?i.value:"");if(l==="run"&&!i.value){u.value={supported:!1,reason:U("diffReview.noReviewRuns"),repoRoot:"",summary:{fileCount:0,additions:0,deletions:0,statsComplete:!0},files:[]},ce();return}const y=ye(X,m);if(y){u.value=y,f=m;const D=ye(J,m);D?(u.value={...y,baseline:D.baseline||y.baseline||null,warnings:D.warnings||y.warnings||[],summary:D.summary||y.summary},C=m):C="",ce(),Pe().catch(()=>{}),je().catch(()=>{}),D||qe().catch(()=>{});return}const K=await He(e.taskSlug,{scope:l,runId:l==="run"?i.value:"",includeStats:!1});if(s!==_)return;const B=Ve(K);u.value=B,be(X,m,B,36),f=m,C="",ce(),Pe().catch(()=>{}),je().catch(()=>{}),qe().catch(()=>{})}catch(l){if(s!==_)return;M.value=l.message,u.value=null}finally{s===_&&(I.value=!1)}}async function qe(){var K,B,D;if(!e.taskSlug||!e.active||!((K=u.value)!=null&&K.supported))return;const s=r.value==="run"?"run":r.value==="task"?"task":"workspace",l=s==="run"?i.value:"",m=oe(e.taskSlug,s,l);if(C===m&&((D=(B=u.value)==null?void 0:B.summary)!=null&&D.statsComplete))return;const y=ye(J,m);if(y){u.value={...u.value,baseline:y.baseline||u.value.baseline||null,warnings:y.warnings||u.value.warnings||[],summary:y.summary||u.value.summary},C=m,R.value=!1;return}R.value=!0;try{const ne=await He(e.taskSlug,{scope:s,runId:l,includeFiles:!1,includeStats:!0}),ee=oe(e.taskSlug,r.value,r.value==="run"?i.value:"");if(m!==ee||!u.value)return;const ie=Ve(ne);u.value={...u.value,baseline:ie.baseline||u.value.baseline||null,warnings:ie.warnings||u.value.warnings||[],summary:ie.summary||u.value.summary},be(J,m,{baseline:ie.baseline||null,warnings:ie.warnings||[],summary:ie.summary||null},36),C=m}catch{}finally{const ne=oe(e.taskSlug,r.value,r.value==="run"?i.value:"");m===ne&&(R.value=!1)}}async function Pe(){var D,ne;const s=String(w.value||"").trim();if(!e.taskSlug||!e.active||!s)return;const l=Me(),m=ze(s);if(!Oe(m))return;const y=Ne(l.signature,s),K=ye(q,y);if(K&&((D=u.value)!=null&&D.files)){pe(l.signature,s,K,null);return}const B=++$;N.value=!0;try{const ee=await Ee(s,l);if(B!==$||!ee)return;const ie=oe(e.taskSlug,r.value,r.value==="run"?i.value:"");if(l.signature!==ie)return;if(ee.error){const xe=De(((ne=ee.error)==null?void 0:ne.message)||"")||U("diffReview.fileDiffTimedOut"),Le={...m,patch:"",patchLoaded:!0,tooLarge:!0,message:xe};be(q,y,Le,120),pe(l.signature,s,Le,null);return}pe(l.signature,s,ee.detailedFile,ee.normalizedPayload)}finally{B===$&&(N.value=!1,String(w.value||"").trim()!==s&&Pe().catch(()=>{}))}}function Ce({force:s=!1}={}){if(!e.taskSlug||!e.active)return;const l=oe(e.taskSlug,r.value,r.value==="run"?i.value:"");!s&&l===f||Ae().catch(()=>{})}async function dt(){!e.taskSlug||!e.active||I.value||(lt(),f="",C="",p="",g=-1,await Ae())}return te(()=>[e.taskSlug,e.active,r.value,i.value],([s,l],m=[])=>{const y=m[0]||"";s!==y&&(w.value="",f="",v.value=[],i.value="",p="",g=-1,C=""),!(!s||!l)&&Ce()},{immediate:!0}),te(()=>{var s,l;return[b.value,((l=(s=u.value)==null?void 0:s.files)==null?void 0:l.length)||0]},()=>{ce()}),te(()=>[w.value,P.value.length],()=>{j.value=0,E.clear(),at(()=>{var s,l;P.value.length?ue(0,{behavior:"auto",block:"start"}):(l=(s=G.value)==null?void 0:s.scrollTo)==null||l.call(s,{top:0,behavior:"auto"})})}),te(()=>w.value,()=>{Pe().catch(()=>{})},{immediate:!0}),te(()=>{var s;return[e.active,(s=u.value)==null?void 0:s.supported,ae.value.join(`
3
- `)]},([s,l])=>{!s||!l||je().catch(()=>{})}),te(()=>[e.preferredScope,e.preferredRunId,e.focusToken],([s,l,m],y=[])=>{const K=Number(y[2]||0),B=s==="run"?"run":s==="task"?"task":"workspace",D=B==="run"&&l?String(l||""):"",ne=r.value!==B,ee=B==="run"&&D&&i.value!==D;r.value=B,D&&(i.value=D),B!=="run"&&(i.value=""),!ne&&!ee&&e.active&&e.taskSlug&&m!==K&&(f="",Ce())},{immediate:!0}),te(()=>se.readyVersion.value,()=>{!e.active||!e.taskSlug||(p="",g=-1,f="",C="",Ce({force:!0}))}),te(()=>se.getTaskDiffSyncVersion(e.taskSlug),()=>{!e.active||!e.taskSlug||(p="",g=-1,C="",f="",Ce({force:!0}))}),{activeHunkIndex:j,baselineMetaText:H,diffPayload:u,diffScope:r,error:M,fileSearch:T,filteredFiles:d,getFilterButtonClass:F,getFilterLabel:Fe,getFileBlobUrl:rt,getPatchLineClass:_e,getRunStatusLabel:L,getStatusClass:$e,getStatusLabel:Re,jumpToAdjacentHunk:le,loadDiff:Ae,loading:I,normalizeFileStatus:fe,patchLoading:N,patchViewportRef:G,runs:v,selectedFile:k,selectedFilePath:w,selectedPatchHunks:P,selectedPatchLines:A,selectedRunId:i,setPatchLineRef:me,showSummarySkeleton:x,statsLoading:R,statusCounts:n,statusFilter:b,terminalRuns:de,formatRunOptionLabel:S,refreshDiff:dt}}const Vt={class:"mb-3 grid grid-cols-2 gap-2"},Ut=["onClick"],zt={class:"theme-input-shell mb-3 flex items-center gap-2 rounded-sm border px-3 py-2 text-xs text-[var(--theme-textMuted)]"},Ot=["placeholder"],Et={key:0,class:"theme-empty-state theme-empty-state-strong mb-3 px-3 py-2 text-[11px]"},qt={key:1,class:"theme-empty-state px-3 py-4 text-xs"},Wt={key:2,class:"theme-empty-state px-3 py-4 text-xs"},Kt={key:3,class:"space-y-1"},Gt=["onClick","onKeydown"],Jt={class:"min-w-0 flex-1"},Qt={class:"flex items-start gap-2"},Xt={class:"theme-list-item-title min-w-0 flex-1 break-all"},Yt={key:0,class:"theme-status-info inline-flex shrink-0 items-center rounded-sm border border-dashed px-1.5 py-0.5 text-[10px]"},Zt={class:"theme-list-item-meta mt-1"},Ze={__name:"TaskDiffFileList",props:{diffPayload:{type:Object,default:null},fileSearch:{type:String,default:""},autoFocusSelected:{type:Boolean,default:!1},filteredFiles:{type:Array,default:()=>[]},focusToken:{type:Number,default:0},getFilterButtonClass:{type:Function,default:()=>""},getFilterLabel:{type:Function,default:e=>e},getStatusClass:{type:Function,default:()=>""},getStatusLabel:{type:Function,default:e=>e},selectedFilePath:{type:String,default:""},showSummarySkeleton:{type:Boolean,default:!1},statusCounts:{type:Object,default:()=>({})},statusFilter:{type:String,default:"all"}},emits:["select-file","update:fileSearch","update:statusFilter"],setup(e,{emit:r}){const i=e,w=r,{t:b}=ke(),T=new Map,v=Q(0),u=Q(0),I=z({get:()=>i.fileSearch,set:_=>w("update:fileSearch",_)}),R=z({get:()=>i.statusFilter,set:_=>w("update:statusFilter",_)}),M=z(()=>{var _;return Array.isArray((_=i.diffPayload)==null?void 0:_.files)&&i.diffPayload.files.length>0});function N(_,$){if($){T.set(_,$);return}T.delete(_)}function G(_){at(()=>{var f,C;const $=T.get(_);(f=$==null?void 0:$.focus)==null||f.call($),(C=$==null?void 0:$.scrollIntoView)==null||C.call($,{block:"nearest",inline:"nearest"})})}function j(){!i.autoFocusSelected||!i.selectedFilePath||v.value===u.value||(u.value=v.value,G(i.selectedFilePath))}function E(_=1,$=""){const f=Array.isArray(i.filteredFiles)?i.filteredFiles:[];if(!f.length)return;const C=f.findIndex(q=>q.path===$),p=f.findIndex(q=>q.path===i.selectedFilePath),X=(Math.max(0,C>=0?C:p)+_+f.length)%f.length,J=f[X];J!=null&&J.path&&(w("select-file",J.path),G(J.path))}function se(_,$){const f=String((_==null?void 0:_.key)||"");if(f==="ArrowDown"){_.preventDefault(),E(1,$);return}if(f==="ArrowUp"){_.preventDefault(),E(-1,$);return}(f==="Enter"||f===" ")&&$&&(_.preventDefault(),w("select-file",$))}return te(()=>i.focusToken,_=>{v.value=_,j()},{immediate:!0}),te(()=>i.selectedFilePath,()=>{j()}),(_,$)=>(c(),h(he,null,[a("div",Vt,[(c(),h(he,null,Ie(["all","A","M","D"],f=>a("button",{key:f,type:"button",class:Z(["inline-flex w-full items-center justify-center gap-1 whitespace-nowrap rounded-sm border px-2 py-1 text-[11px] transition",e.getFilterButtonClass(f)]),onClick:C=>R.value=f},o(e.getFilterLabel(f))+" "+o(e.statusCounts[f]||0),11,Ut)),64))]),a("label",zt,[V(t(Ct),{class:"h-3.5 w-3.5 shrink-0"}),Ue(a("input",{"onUpdate:modelValue":$[0]||($[0]=f=>I.value=f),type:"text",placeholder:t(b)("diffReview.searchFilePath"),class:"min-w-0 flex-1 bg-transparent text-xs text-[var(--theme-textPrimary)] outline-none placeholder:text-[var(--theme-textMuted)]"},null,8,Ot),[[$t,I.value]])]),e.showSummarySkeleton?(c(),h("div",Et,o(t(b)("diffReview.statsPending")),1)):O("",!0),M.value?e.filteredFiles.length?(c(),h("div",Kt,[(c(!0),h(he,null,Ie(e.filteredFiles,f=>{var C;return c(),h("button",{key:f.path,ref_for:!0,ref:p=>N(f.path,p),type:"button",class:Z(["theme-list-row focus:outline-none",f.path===e.selectedFilePath?"theme-list-item-active":"theme-list-item-hover"]),onClick:p=>w("select-file",f.path),onKeydown:p=>se(p,f.path)},[a("span",{class:Z(["theme-list-item-badge",e.getStatusClass(f.status)])},o(e.getStatusLabel(f.status)),3),a("div",Jt,[a("div",Qt,[a("div",Xt,o(f.path),1),f.binary?(c(),h("span",Yt,o(t(b)("diffReview.binaryTag")),1)):O("",!0)]),a("div",Zt,o(f.binary?((C=f.binaryPreview)==null?void 0:C.mimeType)||t(b)("diffReview.binaryPreviewTitle"):f.statsLoaded?`+${f.additions} / -${f.deletions}`:t(b)("diffReview.statsOnDemand")),1)])],42,Gt)}),128))])):(c(),h("div",Wt,o(t(b)("diffReview.noMatches")),1)):(c(),h("div",qt,o(t(b)("diffReview.noChanges")),1))],64))}},es={class:"flex h-full min-h-0 flex-col overflow-hidden"},ts={class:"theme-divider theme-secondary-text border-b px-4 py-3 text-[12px]"},ss={class:"flex flex-wrap items-center gap-2"},as={class:"font-medium text-[var(--theme-textPrimary)]"},ns={class:"theme-muted-text"},is={class:"min-h-0 flex-1 overflow-auto p-4"},ls={key:0,class:"grid min-h-full gap-4 md:grid-cols-2"},rs={class:"theme-inline-panel flex min-h-[20rem] flex-col rounded-sm border p-3"},os={class:"mb-3 flex items-center justify-between gap-2"},ds={class:"min-w-0"},us={class:"text-sm font-medium text-[var(--theme-textPrimary)]"},cs={class:"theme-muted-text mt-1 text-[11px]"},fs=["href","download","title"],hs={key:0,class:"theme-empty-state flex min-h-[16rem] flex-1 items-center justify-center text-[12px]"},ms={key:1,class:"theme-empty-state flex min-h-[16rem] flex-1 items-center justify-center text-[12px]"},vs={key:2,class:"theme-empty-state flex min-h-[16rem] flex-1 items-center justify-center text-[12px]"},gs=["title"],ps=["src","alt"],xs=["src"],ys=["src"],bs=["src","title"],ws={class:"theme-inline-panel flex min-h-[20rem] flex-col rounded-sm border p-3"},ks={class:"mb-3 flex items-center justify-between gap-2"},Ss={class:"min-w-0"},Rs={class:"text-sm font-medium text-[var(--theme-textPrimary)]"},$s={class:"theme-muted-text mt-1 text-[11px]"},Fs=["href","download","title"],_s={key:0,class:"theme-empty-state flex min-h-[16rem] flex-1 items-center justify-center text-[12px]"},Ps={key:1,class:"theme-empty-state flex min-h-[16rem] flex-1 items-center justify-center text-[12px]"},Cs={key:2,class:"theme-empty-state flex min-h-[16rem] flex-1 items-center justify-center text-[12px]"},Ls=["title"],Ts=["src","alt"],Is=["src"],Ds=["src"],Ms=["src","title"],js={key:1,class:"theme-inline-panel flex min-h-full flex-col rounded-sm border p-4"},As={class:"flex items-center gap-2"},Hs={class:"text-sm font-medium text-[var(--theme-textPrimary)]"},Bs={class:"mt-4 grid gap-3 md:grid-cols-2"},Ns={class:"rounded-sm border border-dashed px-3 py-3"},Vs={class:"text-xs font-medium text-[var(--theme-textPrimary)]"},Us={class:"theme-muted-text mt-2 space-y-1 text-[12px]"},zs={key:0},Os=["href","download"],Es={class:"rounded-sm border border-dashed px-3 py-3"},qs={class:"text-xs font-medium text-[var(--theme-textPrimary)]"},Ws={class:"theme-muted-text mt-2 space-y-1 text-[12px]"},Ks={key:0},Gs=["href","download"],Js={__name:"TaskDiffBinaryPreview",props:{getFileBlobUrl:{type:Function,default:()=>""},selectedFile:{type:Object,default:null}},setup(e){const r=e,{t:i}=ke(),w=Q(""),b=Q({before:!1,after:!1});function T(p=0){const g=Math.max(0,Number(p)||0);return g<1024?`${g} B`:g<1024*1024?`${(g/1024).toFixed(g<10*1024?1:0)} KB`:`${(g/(1024*1024)).toFixed(g<10*1024*1024?1:0)} MB`}function v(p="after"){var g,X;return((X=(g=r.selectedFile)==null?void 0:g.binaryPreview)==null?void 0:X[p])||{exists:!1,size:0,hashShort:"",mimeType:"",previewKind:"binary",tooLarge:!1}}function u(p="after"){return r.selectedFile?r.getFileBlobUrl(r.selectedFile,p):""}function I(p="binary"){return p==="image"?Ke:p==="audio"?Lt:p==="video"?Tt:p==="pdf"?It:Ke}const R=z(()=>{var p,g;return String(((g=(p=r.selectedFile)==null?void 0:p.binaryPreview)==null?void 0:g.kind)||"binary")}),M=z(()=>v("before")),N=z(()=>v("after")),G=z(()=>u("before")),j=z(()=>u("after")),E=z(()=>{var p;return String(((p=r.selectedFile)==null?void 0:p.path)||"").trim()}),se=z(()=>["image","audio","video","pdf"].includes(R.value)),_=z(()=>R.value!=="image"?[]:[M.value.exists&&!M.value.tooLarge&&!b.value.before?G.value:"",N.value.exists&&!N.value.tooLarge&&!b.value.after?j.value:""].filter(Boolean));function $(p){return(p==null?void 0:p.exists)&&!(p!=null&&p.tooLarge)}function f(p="before"){b.value={...b.value,[p]:!0}}function C(p=""){const g=String(p||"").trim();g&&(w.value=g)}return te(()=>{var p,g,X,J,q,Y,W;return[String(((p=r.selectedFile)==null?void 0:p.path)||"").trim(),String(G.value||"").trim(),String(j.value||"").trim(),String(((J=(X=(g=r.selectedFile)==null?void 0:g.binaryPreview)==null?void 0:X.before)==null?void 0:J.hash)||"").trim(),String(((W=(Y=(q=r.selectedFile)==null?void 0:q.binaryPreview)==null?void 0:Y.after)==null?void 0:W.hash)||"").trim()].join(`
4
- `)},()=>{w.value="",b.value={before:!1,after:!1}},{immediate:!0}),(p,g)=>{var X,J,q,Y;return c(),h("div",es,[a("div",ts,[a("div",ss,[a("span",as,o(E.value),1),a("span",ns,o(t(i)("diffReview.binaryPreviewTitle")),1)])]),a("div",is,[se.value?(c(),h("div",ls,[a("section",rs,[a("div",os,[a("div",ds,[a("p",us,o(t(i)("diffReview.binaryBefore")),1),a("p",cs,o(M.value.exists?`${T(M.value.size)} · ${M.value.hashShort||"-"}`:t(i)("diffReview.binarySideMissing")),1)]),$(M.value)?(c(),h("a",{key:0,class:"theme-icon-button h-8 w-8",href:G.value,download:((X=e.selectedFile)==null?void 0:X.path)||"before.bin",title:t(i)("diffReview.downloadBinarySide")},[V(t(Te),{class:"h-4 w-4"})],8,fs)):O("",!0)]),M.value.exists?M.value.tooLarge?(c(),h("div",ms,o(t(i)("diffReview.binaryPreviewTooLarge")),1)):b.value.before?(c(),h("div",vs,o(t(i)("diffReview.binaryPreviewUnavailable")),1)):R.value==="image"?(c(),h("button",{key:3,type:"button",class:"task-diff-binary-image-wrap flex min-h-[16rem] flex-1 cursor-zoom-in items-center justify-center rounded-sm border p-3",title:t(i)("diffReview.openImagePreview"),onClick:g[1]||(g[1]=W=>C(G.value))},[a("img",{src:G.value,alt:`${E.value} before`,class:"max-h-full max-w-full object-contain",onError:g[0]||(g[0]=W=>f("before"))},null,40,ps)],8,gs)):R.value==="audio"?(c(),h("audio",{key:4,class:"w-full",src:G.value,controls:"",preload:"metadata",onError:g[2]||(g[2]=W=>f("before"))},null,40,xs)):R.value==="video"?(c(),h("video",{key:5,class:"max-h-[26rem] w-full rounded-sm border bg-black",src:G.value,controls:"",preload:"metadata",onError:g[3]||(g[3]=W=>f("before"))},null,40,ys)):R.value==="pdf"?(c(),h("iframe",{key:6,class:"min-h-[26rem] w-full rounded-sm border bg-white",src:G.value,title:`${E.value} before`,onError:g[4]||(g[4]=W=>f("before"))},null,40,bs)):O("",!0):(c(),h("div",hs,o(t(i)("diffReview.binarySideMissing")),1))]),a("section",ws,[a("div",ks,[a("div",Ss,[a("p",Rs,o(t(i)("diffReview.binaryAfter")),1),a("p",$s,o(N.value.exists?`${T(N.value.size)} · ${N.value.hashShort||"-"}`:t(i)("diffReview.binarySideMissing")),1)]),$(N.value)?(c(),h("a",{key:0,class:"theme-icon-button h-8 w-8",href:j.value,download:((J=e.selectedFile)==null?void 0:J.path)||"after.bin",title:t(i)("diffReview.downloadBinarySide")},[V(t(Te),{class:"h-4 w-4"})],8,Fs)):O("",!0)]),N.value.exists?N.value.tooLarge?(c(),h("div",Ps,o(t(i)("diffReview.binaryPreviewTooLarge")),1)):b.value.after?(c(),h("div",Cs,o(t(i)("diffReview.binaryPreviewUnavailable")),1)):R.value==="image"?(c(),h("button",{key:3,type:"button",class:"task-diff-binary-image-wrap flex min-h-[16rem] flex-1 cursor-zoom-in items-center justify-center rounded-sm border p-3",title:t(i)("diffReview.openImagePreview"),onClick:g[6]||(g[6]=W=>C(j.value))},[a("img",{src:j.value,alt:`${E.value} after`,class:"max-h-full max-w-full object-contain",onError:g[5]||(g[5]=W=>f("after"))},null,40,Ts)],8,Ls)):R.value==="audio"?(c(),h("audio",{key:4,class:"w-full",src:j.value,controls:"",preload:"metadata",onError:g[7]||(g[7]=W=>f("after"))},null,40,Is)):R.value==="video"?(c(),h("video",{key:5,class:"max-h-[26rem] w-full rounded-sm border bg-black",src:j.value,controls:"",preload:"metadata",onError:g[8]||(g[8]=W=>f("after"))},null,40,Ds)):R.value==="pdf"?(c(),h("iframe",{key:6,class:"min-h-[26rem] w-full rounded-sm border bg-white",src:j.value,title:`${E.value} after`,onError:g[9]||(g[9]=W=>f("after"))},null,40,Ms)):O("",!0):(c(),h("div",_s,o(t(i)("diffReview.binarySideMissing")),1))])])):(c(),h("div",js,[a("div",As,[(c(),ve(Ft(I(R.value)),{class:"h-5 w-5 text-[var(--theme-textSecondary)]"})),a("span",Hs,o(t(i)("diffReview.binaryMetaTitle")),1)]),a("div",Bs,[a("div",Ns,[a("div",Vs,o(t(i)("diffReview.binaryBefore")),1),a("div",Us,[a("p",null,o(M.value.exists?`${T(M.value.size)} · ${M.value.hashShort||"-"}`:t(i)("diffReview.binarySideMissing")),1),M.value.mimeType?(c(),h("p",zs,o(M.value.mimeType),1)):O("",!0)]),$(M.value)?(c(),h("a",{key:0,class:"tool-button mt-3 inline-flex items-center gap-2 px-3 py-2 text-xs",href:G.value,download:((q=e.selectedFile)==null?void 0:q.path)||"before.bin"},[V(t(Te),{class:"h-3.5 w-3.5"}),a("span",null,o(t(i)("diffReview.downloadBinarySide")),1)],8,Os)):O("",!0)]),a("div",Es,[a("div",qs,o(t(i)("diffReview.binaryAfter")),1),a("div",Ws,[a("p",null,o(N.value.exists?`${T(N.value.size)} · ${N.value.hashShort||"-"}`:t(i)("diffReview.binarySideMissing")),1),N.value.mimeType?(c(),h("p",Ks,o(N.value.mimeType),1)):O("",!0)]),$(N.value)?(c(),h("a",{key:0,class:"tool-button mt-3 inline-flex items-center gap-2 px-3 py-2 text-xs",href:j.value,download:((Y=e.selectedFile)==null?void 0:Y.path)||"after.bin"},[V(t(Te),{class:"h-3.5 w-3.5"}),a("span",null,o(t(i)("diffReview.downloadBinarySide")),1)],8,Gs)):O("",!0)])])]))]),V(vt,{modelValue:w.value,"onUpdate:modelValue":g[10]||(g[10]=W=>w.value=W),images:_.value},null,8,["modelValue","images"])])}}},Qs=st(Js,[["__scopeId","data-v-4703ec91"]]),Xs={key:0,class:"flex h-full min-h-0 flex-col overflow-hidden"},Ys={class:"theme-divider theme-secondary-text border-b px-4 py-3 text-[12px]"},Zs={class:"space-y-3 sm:hidden"},ea={class:"flex items-start gap-2"},ta={class:"min-w-0 break-all font-medium text-[var(--theme-textPrimary)]"},sa={class:"flex items-center justify-between gap-3"},aa={class:"min-w-0"},na={class:"opacity-75"},ia={key:0,class:"theme-muted-text mt-1 text-[11px]"},la=["disabled"],ra={class:"min-w-[64px] text-center text-[12px] text-[var(--theme-textSecondary)]"},oa=["disabled"],da={class:"hidden items-center gap-3 sm:flex"},ua={class:"flex min-w-0 flex-1 flex-wrap items-center gap-2"},ca={class:"break-all font-medium text-[var(--theme-textPrimary)]"},fa={class:"opacity-75"},ha={key:0,class:"theme-muted-text text-[11px]"},ma=["disabled"],va={class:"min-w-[64px] text-center text-[12px] text-[var(--theme-textSecondary)]"},ga=["disabled"],pa={key:1,class:"theme-secondary-text flex-1 overflow-y-auto px-4 py-4 text-[12px]"},xa={class:"theme-empty-state px-4 py-4"},ya={key:2,class:"theme-muted-text flex-1 overflow-y-auto px-4 py-4 text-[12px]"},ba={class:"task-diff-view min-w-max px-4 py-4 font-mono"},wa={key:0,class:"theme-inline-panel theme-secondary-text mb-3 rounded-sm border border-dashed px-3 py-2 text-[12px]"},ka=["data-line-id","data-line-kind"],Sa={class:"task-diff-row__number select-none"},Ra={class:"task-diff-row__number select-none"},$a=["innerHTML"],Fa={key:4,class:"theme-secondary-text flex-1 overflow-y-auto px-4 py-4 text-[12px]"},_a={class:"theme-empty-state px-4 py-4"},Pa={key:1,class:"theme-muted-text flex h-full items-center justify-center px-5 text-[12px]"},Ca={__name:"TaskDiffPatchView",props:{activeHunkIndex:{type:Number,default:0},getPatchLineClass:{type:Function,default:()=>""},getFileBlobUrl:{type:Function,default:()=>""},getStatusClass:{type:Function,default:()=>""},getStatusLabel:{type:Function,default:e=>e},jumpToAdjacentHunk:{type:Function,default:()=>{}},patchLoading:{type:Boolean,default:!1},selectedFile:{type:Object,default:null},selectedPatchHunks:{type:Array,default:()=>[]},selectedPatchLines:{type:Array,default:()=>[]},setPatchLineRef:{type:Function,default:()=>{}},setPatchViewportRef:{type:Function,default:()=>{}}},emits:["insert-code-context"],setup(e,{emit:r}){const i=e,w=r,{t:b}=ke(),{isDark:T}=ct(),v=Q([]),u=z(()=>{var n;return wt(((n=i.selectedFile)==null?void 0:n.path)||"")}),I=Q(null),R=new Map,M=z(()=>{var n,d;return!!((n=i.selectedFile)!=null&&n.binary&&((d=i.selectedFile)!=null&&d.binaryPreview))});function N(n={}){return["add","delete","context"].includes(String((n==null?void 0:n.kind)||"").trim())}function G(n=""){const d=String(n||"").trim();return d&&v.value.find(k=>k.id===d)||null}const{selectedRows:j,selectionAction:E,clearSelectionState:se,handleSelectionMouseUp:_,updateSelectionActionFromDom:$}=gt({getContainer:()=>I.value,isActive:()=>!!(i.selectedFile&&i.selectedPatchLines.length),rowSelector:".task-diff-row[data-line-id]",getOrderedRowElements:n=>[...n.querySelectorAll(".task-diff-row[data-line-id]")].filter(d=>N(G(d.getAttribute("data-line-id")))),mapRowElement:n=>{var d;return G(((d=n==null?void 0:n.getAttribute)==null?void 0:d.call(n,"data-line-id"))||"")},getCodeLeft:n=>{var ae,x,H;const d=(ae=n==null?void 0:n.querySelector)==null?void 0:ae.call(n,".task-diff-line");if(!d)return 0;const k=(x=d.getBoundingClientRect)==null?void 0:x.call(d),A=(H=window.getComputedStyle)==null?void 0:H.call(window,d),P=Number.parseFloat((A==null?void 0:A.paddingLeft)||"0")||0;return((k==null?void 0:k.left)||0)+P},debounceMs:72});function f(n=[]){const d=n.flatMap(P=>[Number((P==null?void 0:P.oldNumber)||0),Number((P==null?void 0:P.newNumber)||0)]).filter(P=>P>0);if(!d.length)return{start:0,end:0,label:""};const k=Math.min(...d),A=Math.max(...d);return{start:k,end:A,label:k===A?`L${k}`:`L${k}-L${A}`}}function C(n=[]){return n.map(d=>String((d==null?void 0:d.content)||"")).join(`
5
- `).replace(/\u200b/g,"").trim()}function p(){var d,k,A;if(!i.selectedFile||!E.value.visible||!j.value.length)return;const n=f(j.value);w("insert-code-context",{source:"diff",filePath:String(i.selectedFile.path||""),language:"diff",rangeLabel:n.label,lineStart:n.start,lineEnd:n.end,content:C(j.value)||String(E.value.content||"").trim()}),(A=(k=(d=window.getSelection)==null?void 0:d.call(window))==null?void 0:k.removeAllRanges)==null||A.call(k),se()}function g(n,d){if(i.setPatchLineRef(n,d),!!n){if(d){R.set(n,d);return}R.delete(n)}}function X(n){I.value=n||null,i.setPatchViewportRef(n)}function J(n){var H,L,me,ue;const d=(H=window.getSelection)==null?void 0:H.call(window),k=I.value;if(!d||d.rangeCount<1||d.isCollapsed||!k)return;$();const P=d.getRangeAt(0).commonAncestorContainer;if(!k.contains((P==null?void 0:P.nodeType)===1?P:P==null?void 0:P.parentNode))return;const ae=j.value;if(!ae.length)return;const x=C(ae);x&&((me=(L=n==null?void 0:n.clipboardData)==null?void 0:L.setData)==null||me.call(L,"text/plain",x),(ue=n==null?void 0:n.preventDefault)==null||ue.call(n))}function q(n){return(n==null?void 0:n.kind)==="add"?"+":(n==null?void 0:n.kind)==="delete"?"-":(n==null?void 0:n.kind)==="context"?" ":""}function Y(n){const d=String((n==null?void 0:n.content)||"");return(n==null?void 0:n.kind)==="add"||(n==null?void 0:n.kind)==="delete"||(n==null?void 0:n.kind)==="context"?d.slice(1):d}function W(n=""){return String(n||"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function re(n,d=""){if((n==null?void 0:n.kind)==="add"||(n==null?void 0:n.kind)==="delete"||(n==null?void 0:n.kind)==="context"){const k=q(n),A=`task-diff-line__prefix--${n.kind}`;return{...n,renderedHtml:`<span class="task-diff-line__prefix ${A}">${W(k||" ")}</span><span class="task-diff-line__body">${d||"&#8203;"}</span>`}}return{...n,renderedHtml:W(String((n==null?void 0:n.content)||""))}}async function de(){const n=Array.isArray(i.selectedPatchLines)?i.selectedPatchLines:[],d=[];n.forEach((x,H)=>{((x==null?void 0:x.kind)==="add"||(x==null?void 0:x.kind)==="delete"||(x==null?void 0:x.kind)==="context")&&d.push({lineIndex:H,body:Y(x)})});const k=xt(d.map(x=>x.body));let A=0;if(v.value=n.map(x=>{if((x==null?void 0:x.kind)==="add"||(x==null?void 0:x.kind)==="delete"||(x==null?void 0:x.kind)==="context"){const H=k[A]||"&#8203;";return A+=1,re(x,H)}return re(x)}),!d.length||yt(d.map(x=>x.body),Be))return;const P=await bt(d.map(x=>x.body),{isDark:T.value,language:u.value,maxHighlightLines:Be.maxLines,maxHighlightChars:Be.maxChars});let ae=0;v.value=n.map(x=>{if((x==null?void 0:x.kind)==="add"||(x==null?void 0:x.kind)==="delete"||(x==null?void 0:x.kind)==="context"){const H=P[ae]||"&#8203;";return ae+=1,re(x,H)}return re(x)})}return te(()=>{var n;return[i.selectedPatchLines,(n=i.selectedFile)==null?void 0:n.path,T.value]},()=>{se(),de()},{immediate:!0,deep:!0}),_t(()=>{var n,d,k;(k=(d=(n=window.getSelection)==null?void 0:n.call(window))==null?void 0:d.removeAllRanges)==null||k.call(d),se({clearBrowserSelection:!0}),R.clear()}),(n,d)=>e.selectedFile?(c(),h("div",Xs,[a("div",Ys,[a("div",Zs,[a("div",ea,[a("span",{class:Z(["inline-flex shrink-0 rounded-sm border px-1.5 py-0.5 text-[12px]",e.getStatusClass(e.selectedFile.status)])},o(e.getStatusLabel(e.selectedFile.status)),3),a("span",ta,o(e.selectedFile.path),1)]),a("div",sa,[a("div",aa,[a("div",na,o(e.selectedFile.statsLoaded?`+${e.selectedFile.additions} / -${e.selectedFile.deletions}`:t(b)("diffReview.statsOnDemand")),1),M.value?O("",!0):(c(),h("div",ia,o(t(b)("diffReview.selectCodeLineHint")),1))]),a("div",{class:Z(["inline-flex h-8 shrink-0 items-center gap-1 rounded-sm border px-1.5 py-1",e.selectedPatchHunks.length?"theme-inline-panel":"pointer-events-none invisible border-transparent"])},[a("button",{type:"button",class:"theme-icon-button h-6 w-6 disabled:opacity-50",disabled:e.activeHunkIndex<=0,onClick:d[0]||(d[0]=k=>e.jumpToAdjacentHunk(-1))},[V(t(Ge),{class:"h-4 w-4"})],8,la),a("span",ra,o(t(b)("diffReview.changeIndex",{current:Math.min(e.activeHunkIndex+1,e.selectedPatchHunks.length),total:e.selectedPatchHunks.length})),1),a("button",{type:"button",class:"theme-icon-button h-6 w-6 disabled:opacity-50",disabled:e.activeHunkIndex>=e.selectedPatchHunks.length-1,onClick:d[1]||(d[1]=k=>e.jumpToAdjacentHunk(1))},[V(t(Je),{class:"h-4 w-4"})],8,oa)],2)])]),a("div",da,[a("div",ua,[a("span",{class:Z(["inline-flex rounded-sm border px-1.5 py-0.5 text-[12px]",e.getStatusClass(e.selectedFile.status)])},o(e.getStatusLabel(e.selectedFile.status)),3),a("span",ca,o(e.selectedFile.path),1),a("span",fa,o(e.selectedFile.statsLoaded?`+${e.selectedFile.additions} / -${e.selectedFile.deletions}`:t(b)("diffReview.statsOnDemand")),1),M.value?O("",!0):(c(),h("span",ha,o(t(b)("diffReview.selectCodeLineHint")),1))]),a("div",{class:Z(["inline-flex h-8 w-[132px] shrink-0 items-center gap-1 rounded-sm border px-1.5 py-1",e.selectedPatchHunks.length?"theme-inline-panel":"pointer-events-none invisible border-transparent"])},[a("button",{type:"button",class:"theme-icon-button h-6 w-6 disabled:opacity-50",disabled:e.activeHunkIndex<=0,onClick:d[2]||(d[2]=k=>e.jumpToAdjacentHunk(-1))},[V(t(Ge),{class:"h-4 w-4"})],8,ma),a("span",va,o(t(b)("diffReview.changeIndex",{current:Math.min(e.activeHunkIndex+1,e.selectedPatchHunks.length),total:e.selectedPatchHunks.length})),1),a("button",{type:"button",class:"theme-icon-button h-6 w-6 disabled:opacity-50",disabled:e.activeHunkIndex>=e.selectedPatchHunks.length-1,onClick:d[3]||(d[3]=k=>e.jumpToAdjacentHunk(1))},[V(t(Je),{class:"h-4 w-4"})],8,ga)],2)])]),e.selectedFile.binary&&e.selectedFile.binaryPreview?(c(),ve(Qs,{key:0,"get-file-blob-url":e.getFileBlobUrl,"selected-file":e.selectedFile},null,8,["get-file-blob-url","selected-file"])):e.selectedFile.message&&!e.selectedPatchLines.length?(c(),h("div",pa,[a("div",xa,o(e.selectedFile.message),1)])):e.patchLoading&&!e.selectedFile.patchLoaded?(c(),h("div",ya,o(t(b)("diffReview.loadingFileDiff")),1)):e.selectedPatchLines.length?(c(),h("div",{key:3,ref:X,class:"relative flex-1 overflow-auto",onCopy:J,onMouseup:d[4]||(d[4]=(...k)=>t(_)&&t(_)(...k))},[a("div",ba,[e.selectedFile.message?(c(),h("div",wa,o(e.selectedFile.message),1)):O("",!0),(c(!0),h(he,null,Ie(v.value,k=>{var A;return c(),h("div",{key:k.id,ref_for:!0,ref:P=>g(k.id,P),class:Z(["task-diff-row grid",[e.getPatchLineClass(k.kind),k.kind==="hunk"&&((A=e.selectedPatchHunks[e.activeHunkIndex])==null?void 0:A.id)===k.id?"ring-1 ring-inset ring-[var(--theme-warning)]":""]]),"data-line-id":k.id,"data-line-kind":k.kind},[a("span",Sa,o(k.oldNumber),1),a("span",Ra,o(k.newNumber),1),a("pre",{class:Z(["task-diff-line overflow-visible whitespace-pre px-3 py-0.5",k.kind==="meta"||k.kind==="hunk"?"task-diff-line--plain":""]),innerHTML:k.renderedHtml},null,10,$a)],10,ka)}),128))]),t(E).visible?(c(),ve(pt,{key:0,top:t(E).top,left:t(E).left,label:t(b)("diffReview.insertSelection"),onClick:p},null,8,["top","left","label"])):O("",!0)],32)):(c(),h("div",Fa,[a("div",_a,o(t(b)("diffReview.noFileDiffContent")),1)]))])):(c(),h("div",Pa,o(t(b)("diffReview.selectFile")),1))}},et=st(Ca,[["__scopeId","data-v-ee7937d4"]]),La={class:"panel flex h-full min-h-0 flex-col overflow-hidden"},Ta={class:"theme-divider border-b px-4 py-3"},Ia={class:"flex flex-col gap-2"},Da={class:"grid grid-cols-4 gap-2 sm:flex sm:flex-wrap sm:items-center"},Ma={class:"sm:hidden"},ja={class:"hidden sm:inline"},Aa={class:"sm:hidden"},Ha={class:"hidden sm:inline"},Ba=["disabled"],Na={class:"sm:hidden"},Va={class:"hidden sm:inline"},Ua={class:"truncate text-xs text-[var(--theme-textPrimary)]"},za={class:"theme-divider theme-muted-text border-b border-dashed px-3 py-2 text-[11px]"},Oa=["onClick"],Ea={class:"flex items-start gap-3"},qa={class:"min-w-0 flex-1"},Wa={class:"truncate text-xs font-medium text-[var(--theme-textPrimary)]"},Ka={class:"theme-muted-text mt-1 text-[11px]"},Ga={key:0,class:"theme-divider theme-danger-text border-b px-4 py-3 text-sm"},Ja={class:"inline-flex items-start gap-2"},Qa={class:"break-all"},Xa={key:1,class:"theme-muted-text flex flex-1 items-center justify-center px-5 text-sm"},Ya={key:2,class:"flex flex-1 items-center justify-center px-5"},Za={class:"theme-empty-state w-full max-w-xl px-4 py-5 text-sm text-[var(--theme-textSecondary)]"},en={class:"theme-heading inline-flex items-center gap-2 font-medium"},tn={class:"mt-2 break-all leading-7"},sn={key:0,class:"mt-3 flex flex-wrap gap-2 text-xs"},an={class:"theme-status-neutral inline-flex items-center gap-2 rounded-sm border border-dashed px-2.5 py-1.5"},nn={class:"break-all"},ln={key:0,class:"theme-status-success inline-flex items-center gap-2 rounded-sm border border-dashed px-2.5 py-1.5"},rn={key:3,class:"flex min-h-0 flex-1 flex-col overflow-hidden"},on={class:"theme-divider theme-secondary-text border-b px-4 py-3 text-xs"},dn={class:"flex flex-wrap items-center gap-2"},un={key:0,class:"theme-status-info inline-flex min-w-0 items-center gap-2 rounded-sm border border-dashed px-2.5 py-1.5"},cn={class:"min-w-0 break-all"},fn={class:"theme-status-success inline-flex items-center gap-2 rounded-sm border border-dashed px-2.5 py-1.5"},hn={class:"text-[var(--theme-textPrimary)]"},mn={class:"font-medium text-[var(--theme-success)]"},vn={class:"font-medium text-[var(--theme-danger)]"},gn={key:2,class:"opacity-75"},pn={key:0,class:"mt-2 break-all text-[11px] opacity-75"},xn={key:1,class:"mt-2 flex flex-col gap-1"},yn={key:0,class:"flex min-h-0 flex-1 flex-col overflow-hidden"},bn={class:"theme-divider border-b px-3 py-3"},wn={class:"grid grid-cols-2 gap-2"},kn=["disabled"],Sn={class:"theme-divider theme-muted-panel min-h-0 flex-1 overflow-y-auto p-3"},Rn={class:"min-h-0 flex-1 overflow-hidden bg-[var(--theme-appPanelStrong)]"},$n={key:1,class:"grid min-h-0 flex-1 grid-cols-[320px_minmax(0,1fr)] overflow-hidden"},Fn={class:"theme-divider theme-muted-panel min-h-0 overflow-y-auto border-r p-3"},_n={class:"min-h-0 overflow-hidden bg-[var(--theme-appPanelStrong)]"},Pn={__name:"TaskDiffReviewPanel",props:{taskSlug:{type:String,default:""},preferredScope:{type:String,default:"workspace"},preferredRunId:{type:String,default:""},focusToken:{type:Number,default:0},active:{type:Boolean,default:!1}},emits:["insert-code-context"],setup(e,{emit:r}){const i=e,w=r,{activeHunkIndex:b,baselineMetaText:T,diffPayload:v,diffScope:u,error:I,fileSearch:R,filteredFiles:M,formatRunOptionLabel:N,getFilterButtonClass:G,getFilterLabel:j,getFileBlobUrl:E,getPatchLineClass:se,getRunStatusLabel:_,getStatusClass:$,getStatusLabel:f,jumpToAdjacentHunk:C,loading:p,patchLoading:g,patchViewportRef:X,refreshDiff:J,selectedFile:q,selectedFilePath:Y,selectedPatchHunks:W,selectedPatchLines:re,selectedRunId:de,setPatchLineRef:n,showSummarySkeleton:d,statsLoading:k,statusCounts:A,statusFilter:P,terminalRuns:ae}=Nt(i),{matches:x}=kt("(max-width: 767px)"),H=Q("files"),{t:L}=ke();function me(le){Y.value=le,x.value&&(H.value="patch")}function ue(le){X.value=le||null}return te(x,le=>{le||(H.value="files")},{immediate:!0}),te(Y,le=>{!le&&x.value&&(H.value="files")}),te(u,()=>{x.value&&(H.value="files")}),(le,S)=>{var Se,ce,Re,$e,Fe;return c(),h("section",La,[a("div",Ta,[a("div",Ia,[a("div",Da,[a("button",{type:"button",class:Z(["tool-button inline-flex items-center justify-center gap-2 px-3 py-2 text-xs",t(u)==="workspace"?"theme-filter-active":""]),onClick:S[0]||(S[0]=F=>u.value="workspace")},[a("span",Ma,o(t(L)("diffReview.scopeCurrentShort")),1),a("span",ja,o(t(L)("diffReview.scopeCurrent")),1)],2),a("button",{type:"button",class:Z(["tool-button inline-flex items-center justify-center gap-2 px-3 py-2 text-xs",t(u)==="task"?"theme-filter-active":""]),onClick:S[1]||(S[1]=F=>u.value="task")},[a("span",Aa,o(t(L)("diffReview.scopeTaskShort")),1),a("span",Ha,o(t(L)("diffReview.scopeTask")),1)],2),a("button",{type:"button",class:Z(["tool-button inline-flex items-center justify-center gap-2 px-3 py-2 text-xs",t(u)==="run"?"theme-filter-active":""]),onClick:S[2]||(S[2]=F=>u.value="run")},[a("span",null,o(t(L)("diffReview.scopeRun")),1)],2),a("button",{type:"button",class:"tool-button tool-button-info-subtle inline-flex shrink-0 items-center justify-center gap-2 px-3 py-2 text-xs",disabled:t(p),onClick:S[3]||(S[3]=(...F)=>t(J)&&t(J)(...F))},[V(t(Qe),{class:Z(["h-3.5 w-3.5 sm:hidden",t(p)?"animate-spin":""])},null,8,["class"]),a("span",Na,o(t(L)("diffReview.refresh")),1),V(t(Qe),{class:Z(["hidden h-3.5 w-3.5 sm:inline-block",t(p)?"animate-spin":""])},null,8,["class"]),a("span",Va,o(t(p)?t(L)("diffReview.refreshing"):t(k)?t(L)("diffReview.computing"):t(L)("diffReview.refresh")),1)],8,Ba)]),t(u)==="run"?(c(),ve(St,{key:0,modelValue:t(de),"onUpdate:modelValue":S[4]||(S[4]=F=>Pt(de)?de.value=F:null),class:"min-w-0 sm:max-w-[360px]",options:t(ae),loading:t(p),"get-option-value":F=>(F==null?void 0:F.id)||"",placeholder:t(L)("diffReview.selectRun"),"empty-text":t(L)("diffReview.noRuns")},{trigger:we(({selectedOption:F})=>[a("div",Ua,o(F?t(N)(F):t(L)("diffReview.selectRun")),1)]),header:we(()=>[a("div",za,o(t(L)("diffReview.runCount",{count:t(ae).length})),1)]),option:we(({option:F,selected:_e,select:ge})=>[a("button",{type:"button",class:Z(["w-full rounded-sm border border-dashed px-3 py-2 text-left transition",_e?"theme-filter-active":"theme-filter-idle"]),onClick:ge},[a("div",Ea,[a("div",qa,[a("div",Wa,o(t(tt)(F.startedAt||F.createdAt,{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"})),1),a("div",Ka,o(t(_)(F)),1)]),_e?(c(),ve(t(Dt),{key:0,class:"mt-0.5 h-4 w-4 shrink-0 text-[var(--theme-textSecondary)]"})):O("",!0)])],10,Oa)]),_:1},8,["modelValue","options","loading","get-option-value","placeholder","empty-text"])):O("",!0)])]),t(I)?(c(),h("div",Ga,[a("div",Ja,[V(t(Mt),{class:"mt-0.5 h-4 w-4 shrink-0"}),a("span",Qa,o(t(I)),1)])])):O("",!0),t(p)&&!t(v)?(c(),h("div",Xa,o(t(L)("diffReview.loading")),1)):t(v)&&!t(v).supported?(c(),h("div",Ya,[a("div",Za,[a("div",en,[V(t(nt),{class:"h-4 w-4"}),a("span",null,o(t(L)("diffReview.unavailableTitle")),1)]),a("p",tn,o(t(v).reason||t(L)("diffReview.unavailableReason")),1),t(v).repoRoot?(c(),h("div",sn,[a("div",an,[V(t(Xe),{class:"h-3.5 w-3.5 shrink-0"}),a("span",nn,o(t(v).repoRoot),1)]),t(v).branch?(c(),h("div",ln,[V(t(Ye),{class:"h-3.5 w-3.5 shrink-0"}),a("span",null,o(t(v).branch),1)])):O("",!0)])):O("",!0)])])):t(v)?(c(),h("div",rn,[a("div",on,[a("div",dn,[t(v).repoRoot?(c(),h("div",un,[V(t(Xe),{class:"h-3.5 w-3.5 shrink-0"}),a("span",cn,o(t(v).repoRoot),1)])):O("",!0),a("div",fn,[V(t(Ye),{class:"h-3.5 w-3.5 shrink-0"}),a("span",null,o(t(v).branch||t(L)("diffReview.unknownBranch")),1),S[18]||(S[18]=a("span",{class:"opacity-50"},"•",-1)),a("span",hn,o(t(L)("diffReview.fileCount",{count:((Se=t(v).summary)==null?void 0:Se.fileCount)||0})),1),(ce=t(v).summary)!=null&&ce.statsComplete?(c(),h(he,{key:0},[S[14]||(S[14]=a("span",{class:"opacity-50"},"•",-1)),a("span",mn,"+"+o(((Re=t(v).summary)==null?void 0:Re.additions)||0),1),a("span",vn,"-"+o((($e=t(v).summary)==null?void 0:$e.deletions)||0),1)],64)):t(d)?(c(),h(he,{key:1},[S[15]||(S[15]=a("span",{class:"opacity-50"},"•",-1)),S[16]||(S[16]=a("span",{class:"h-3 w-10 animate-pulse rounded bg-[var(--theme-successSoft)]"},null,-1)),S[17]||(S[17]=a("span",{class:"h-3 w-10 animate-pulse rounded bg-[var(--theme-dangerSoft)]"},null,-1))],64)):(c(),h("span",gn,o(t(L)("diffReview.waitingStats")),1))])]),t(T)?(c(),h("p",pn,o(t(T)),1)):O("",!0),(Fe=t(v).warnings)!=null&&Fe.length?(c(),h("div",xn,[(c(!0),h(he,null,Ie(t(v).warnings,F=>(c(),h("p",{key:F,class:"text-[11px] text-[var(--theme-warningText)]"},o(F),1))),128))])):O("",!0)]),t(x)?(c(),h("div",yn,[a("div",bn,[a("div",wn,[a("button",{type:"button",class:Z(["tool-button px-3 py-2 text-sm",H.value==="files"?"tool-button-accent-subtle":""]),onClick:S[5]||(S[5]=F=>H.value="files")},o(t(L)("diffReview.filesTab")),3),a("button",{type:"button",class:Z(["tool-button px-3 py-2 text-sm",H.value==="patch"?"tool-button-accent-subtle":""]),disabled:!t(q),onClick:S[6]||(S[6]=F=>H.value="patch")},o(t(L)("diffReview.diffTab")),11,kn)])]),Ue(a("div",Sn,[V(Ze,{"auto-focus-selected":e.active&&H.value==="files","diff-payload":t(v),"file-search":t(R),"focus-token":e.focusToken,"filtered-files":t(M),"get-filter-button-class":t(G),"get-filter-label":t(j),"get-status-class":t($),"get-status-label":t(f),"selected-file-path":t(Y),"show-summary-skeleton":t(d),"status-counts":t(A),"status-filter":t(P),"onUpdate:fileSearch":S[7]||(S[7]=F=>R.value=F),"onUpdate:statusFilter":S[8]||(S[8]=F=>P.value=F),onSelectFile:me},null,8,["auto-focus-selected","diff-payload","file-search","focus-token","filtered-files","get-filter-button-class","get-filter-label","get-status-class","get-status-label","selected-file-path","show-summary-skeleton","status-counts","status-filter"])],512),[[We,H.value==="files"]]),Ue(a("div",Rn,[V(et,{"active-hunk-index":t(b),"get-file-blob-url":t(E),"get-patch-line-class":t(se),"get-status-class":t($),"get-status-label":t(f),"jump-to-adjacent-hunk":t(C),"patch-loading":t(g),"selected-file":t(q),"selected-patch-hunks":t(W),"selected-patch-lines":t(re),"set-patch-line-ref":t(n),"set-patch-viewport-ref":ue,onInsertCodeContext:S[9]||(S[9]=F=>w("insert-code-context",F))},null,8,["active-hunk-index","get-file-blob-url","get-patch-line-class","get-status-class","get-status-label","jump-to-adjacent-hunk","patch-loading","selected-file","selected-patch-hunks","selected-patch-lines","set-patch-line-ref"])],512),[[We,H.value==="patch"]])])):(c(),h("div",$n,[a("div",Fn,[V(Ze,{"auto-focus-selected":e.active,"diff-payload":t(v),"file-search":t(R),"focus-token":e.focusToken,"filtered-files":t(M),"get-filter-button-class":t(G),"get-filter-label":t(j),"get-status-class":t($),"get-status-label":t(f),"selected-file-path":t(Y),"show-summary-skeleton":t(d),"status-counts":t(A),"status-filter":t(P),"onUpdate:fileSearch":S[10]||(S[10]=F=>R.value=F),"onUpdate:statusFilter":S[11]||(S[11]=F=>P.value=F),onSelectFile:S[12]||(S[12]=F=>Y.value=F)},null,8,["auto-focus-selected","diff-payload","file-search","focus-token","filtered-files","get-filter-button-class","get-filter-label","get-status-class","get-status-label","selected-file-path","show-summary-skeleton","status-counts","status-filter"])]),a("div",_n,[V(et,{"active-hunk-index":t(b),"get-file-blob-url":t(E),"get-patch-line-class":t(se),"get-status-class":t($),"get-status-label":t(f),"jump-to-adjacent-hunk":t(C),"patch-loading":t(g),"selected-file":t(q),"selected-patch-hunks":t(W),"selected-patch-lines":t(re),"set-patch-line-ref":t(n),"set-patch-viewport-ref":ue,onInsertCodeContext:S[13]||(S[13]=F=>w("insert-code-context",F))},null,8,["active-hunk-index","get-file-blob-url","get-patch-line-class","get-status-class","get-status-label","jump-to-adjacent-hunk","patch-loading","selected-file","selected-patch-hunks","selected-patch-lines","set-patch-line-ref"])])]))])):O("",!0)])}}},Cn={class:"theme-heading inline-flex items-center gap-2 text-sm font-medium"},Hn={__name:"TaskDiffReviewDialog",props:{open:{type:Boolean,default:!1},taskSlug:{type:String,default:""},taskTitle:{type:String,default:""},preferredScope:{type:String,default:"task"},preferredRunId:{type:String,default:""},focusToken:{type:Number,default:0}},emits:["close","insert-code-context"],setup(e,{emit:r}){const i=e,w=r,{t:b}=ke(),T=z(()=>{const u=String(i.taskTitle||"").trim();return u?b("diffReview.dialogTitleWithTask",{title:u}):b("diffReview.dialogTitle")});function v(u){w("insert-code-context",u),w("close")}return(u,I)=>(c(),ve(Rt,{open:e.open,"stack-level":2,"panel-class":"settings-dialog-panel h-[calc(100dvh-1rem)] sm:h-[96vh] sm:max-h-[96vh] sm:w-[90vw] sm:max-w-[90vw]","header-class":"settings-dialog-header px-5 py-4","body-class":"settings-dialog-body min-h-0 flex-1 overflow-hidden p-3 sm:p-4",onClose:I[0]||(I[0]=R=>w("close"))},{title:we(()=>[a("div",Cn,[V(t(nt),{class:"h-4 w-4"}),a("span",null,o(T.value),1)])]),default:we(()=>[V(Pn,{"task-slug":e.taskSlug,active:e.open,"preferred-scope":e.preferredScope,"preferred-run-id":e.preferredRunId,"focus-token":e.focusToken,onInsertCodeContext:v},null,8,["task-slug","active","preferred-scope","preferred-run-id","focus-token"])]),_:1},8,["open"]))}};export{Hn as default};
1
+ import{g as ut,t as U,f as tt,u as ke,a as st,b as ct}from"./index-4LeM_JQe.js";import{u as ft,g as Ae,b as ht,l as mt,_ as vt,a as gt,c as pt,r as xt,e as yt,D as Be,d as bt,i as wt,f as kt,h as St,j as Rt}from"./WorkbenchView-ih1G4f79.js";import{w as te,c as z,b as Q,n as at,aD as c,aE as h,aF as a,aR as he,aS as Ie,aL as Z,aQ as o,aG as V,u as t,aW as Ue,aX as $t,aN as O,aI as ve,aT as Ft,ak as _t,aJ as we,f as Pt,b0 as We}from"./vendor-misc-DqxAnmp9.js";import{c as Ct,D as Te,f as Ke,M as Lt,V as Tt,p as It,k as Ge,C as Je,R as Qe,b as Dt,i as Mt,h as nt,F as Xe,H as Ye}from"./vendor-ui-CnLXY_Zv.js";import"./vendor-router-4TN1NQvz.js";import"./vendor-markdown-C2aIjAg9.js";import"./vendor-tiptap-DLVi2vZE.js";function oe(e,r,i=""){const w=r==="run"?"run":r==="task"?"task":"workspace";return[String(e||"").trim(),w,String(i||"").trim()].join("::")}function Ne(e="",r=""){return`${String(e||"").trim()}::${String(r||"").trim()}`}function Ht(e=""){return`${String(e||"").trim()}::`}function it(e){if(!e||typeof e!="object")return e;try{return JSON.parse(JSON.stringify(e))}catch{return e}}function ye(e,r){const i=e.get(r);return i?(e.delete(r),e.set(r,i),it(i)):null}function be(e,r,i,w=0){for(e.delete(r),e.set(r,it(i));w>0&&e.size>w;){const b=e.keys().next().value;if(typeof b>"u")break;e.delete(b)}}function fe(e=""){const r=String(e||"").trim().toUpperCase();return r==="A"||r==="D"?r:"M"}function jt(e=""){const r=String(e||"");if(!r)return[];const i=r.split(`
2
+ `),w=[];let b=0,T=0;return i.forEach((v,u)=>{const I=v.match(/^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/);if(I){b=Number(I[1]),T=Number(I[2]),w.push({id:`hunk-${u}`,kind:"hunk",oldNumber:"",newNumber:"",content:v});return}if(v.startsWith("+")&&!v.startsWith("+++")){w.push({id:`line-${u}`,kind:"add",oldNumber:"",newNumber:T,content:v}),T+=1;return}if(v.startsWith("-")&&!v.startsWith("---")){w.push({id:`line-${u}`,kind:"delete",oldNumber:b,newNumber:"",content:v}),b+=1;return}if(v.startsWith(" ")){w.push({id:`line-${u}`,kind:"context",oldNumber:b,newNumber:T,content:v}),b+=1,T+=1;return}w.push({id:`line-${u}`,kind:"meta",oldNumber:"",newNumber:"",content:v})}),w}function At(e=""){const r=String(e||"").trim();if(!r)return"";const i=r.match(/^当前分支已从 (.+) 切换到 (.+)$/);return i?U("diffReview.warningBranchChanged",{from:i[1],to:i[2]}):r==="当前 HEAD 已不在基线 commit 的后续历史中,仓库可能经历了 reset、rebase 或切分支"?U("diffReview.warningHeadDetachedFromBaseline"):r}function De(e=""){const r=String(e||"").trim();if(!r)return"";const w=new Map([["二进制文件暂不支持在线 diff 预览。","diffReview.binaryPreviewUnavailable"],["文件内容较大,暂不展示具体 diff。","diffReview.fileTooLarge"],["diff 内容较长,暂不在页面内完整展示。","diffReview.diffTooLong"],["diff 内容较长,当前仅展示摘要预览。","diffReview.diffPreviewOnly"],["当前工作目录不是 Git 仓库,暂不支持代码变更审查。","diffReview.notGitRepo"],["任务不存在。","diffReview.taskNotFound"],["请选择一轮执行后再查看本轮代码变更。","diffReview.runRequired"],["没有找到对应的执行记录。","diffReview.runNotFound"],["这轮执行还没有建立代码变更基线,暂时无法查看本轮 diff。","diffReview.runBaselineMissing"],["当前任务还没有建立代码变更基线,请先让 Codex 执行一轮。","diffReview.taskBaselineMissing"],["这轮执行缺少结束快照,暂时无法准确还原本轮代码变更。","diffReview.runSnapshotMissing"],["原工作目录已不是有效的 Git 仓库,暂时无法读取代码变更。","diffReview.originalRepoInvalid"],["基线对应的 commit 已不存在,仓库可能被 reset、rebase 或切换到无关历史,暂时无法准确读取该范围的代码变更。","diffReview.baselineCommitMissing"]]).get(r);return w?U(w):/^git diff 计算超时(>\d+ms)[。.]?$/.test(r)||r==="该文件 diff 计算超时,暂不在线展示详细内容。"?U("diffReview.fileDiffTimedOut"):r}function Ve(e=null){return!e||typeof e!="object"?e:{...e,reason:De(e.reason),warnings:Array.isArray(e.warnings)?e.warnings.map(r=>At(r)).filter(Boolean):[],files:Array.isArray(e.files)?e.files.map(r=>({...r,message:De(r==null?void 0:r.message)})):[]}}function Bt(e=[],r="",i=0){const w=Math.max(0,Number(i)||0);if(!w)return[];const b=String(r||"").trim(),T=Array.isArray(e)?e:[],v=[],u=new Set;return b&&T.find(R=>String((R==null?void 0:R.path)||"").trim()===b)&&(v.push(b),u.add(b)),T.forEach(I=>{const R=String((I==null?void 0:I.path)||"").trim();!R||u.has(R)||v.length>=w||(v.push(R),u.add(R))}),v}function Nt(e){const r=Q("workspace"),i=Q(""),w=Q(""),b=Q("all"),T=Q(""),v=Q([]),u=Q(null),I=Q(!1),R=Q(!1),M=Q(""),N=Q(!1),G=Q(null),H=Q(0),E=new Map,se=ft();let _=0,$=0,f="",C="",p="",g=-1;const X=new Map,J=new Map,q=new Map,Y=new Map,W=12e3,re=3,de=z(()=>v.value.filter(s=>s.completed)),n=z(()=>{var l;const s={all:0,A:0,M:0,D:0};return(((l=u.value)==null?void 0:l.files)||[]).forEach(m=>{const y=fe(m==null?void 0:m.status);s.all+=1,s[y]+=1}),s}),d=z(()=>{var m;const s=((m=u.value)==null?void 0:m.files)||[],l=String(T.value||"").trim().toLowerCase();return s.filter(y=>b.value!=="all"&&fe(y==null?void 0:y.status)!==b.value?!1:l?String((y==null?void 0:y.path)||"").toLowerCase().includes(l):!0)}),k=z(()=>{const s=d.value;return s.find(l=>l.path===w.value)||s[0]||null}),j=z(()=>{var s;return jt(((s=k.value)==null?void 0:s.patch)||"")}),P=z(()=>j.value.map((s,l)=>({...s,index:l})).filter(s=>s.kind==="hunk")),ae=z(()=>Bt(d.value,w.value,re)),x=z(()=>{var s,l;return R.value&&!((l=(s=u.value)==null?void 0:s.summary)!=null&&l.statsComplete)}),A=z(()=>{var m;const s=((m=u.value)==null?void 0:m.baseline)||null;if(!(s!=null&&s.createdAt)&&!(s!=null&&s.headShort))return"";const l=[];return s.createdAt&&l.push(U("diffReview.baselineTime",{value:tt(s.createdAt)})),s.branch&&l.push(U("diffReview.baselineBranch",{value:s.branch})),s.headShort&&l.push(U("diffReview.baselineCommit",{value:s.headShort})),s.currentHeadShort&&l.push(U("diffReview.currentHead",{value:s.currentHeadShort})),l.join(" · ")});function L(s){return(s==null?void 0:s.status)==="completed"?U("diffReview.completed"):(s==null?void 0:s.status)==="error"?U("diffReview.failed"):(s==null?void 0:s.status)==="interrupted"?U("diffReview.interrupted"):U("diffReview.stopped")}function me(s,l){if(s){if(l){E.set(s,l);return}E.delete(s)}}function ue(s,l={}){const m=P.value;if(!m.length)return;const y=Math.min(Math.max(0,Number(s)||0),m.length-1),K=m[y],B=E.get(K.id);B&&(H.value=y,B.scrollIntoView({block:l.block||"center",behavior:l.behavior||"smooth"}))}function le(s=1){P.value.length&&ue(H.value+s)}function S(s){return`${new Date((s==null?void 0:s.startedAt)||(s==null?void 0:s.createdAt)).toLocaleString(ut())} · ${L(s)}`}function Se(){const s=de.value;if(!s.length){i.value="";return}s.some(l=>l.id===i.value)||(i.value=s[0].id)}function ce(){const s=d.value;if(!s.length){w.value="";return}s.some(l=>l.path===w.value)||(w.value=s[0].path)}function Re(s=""){return fe(s)==="A"?U("diffReview.added"):fe(s)==="D"?U("diffReview.deleted"):U("diffReview.modified")}function $e(s=""){return fe(s)==="A"?"theme-status-success":fe(s)==="D"?"theme-status-danger":"theme-status-warning"}function Fe(s="all"){return s==="A"?U("diffReview.added"):s==="D"?U("diffReview.deleted"):s==="M"?U("diffReview.modified"):U("diffReview.all")}function F(s="all"){return b.value===s?"theme-filter-active":"theme-filter-idle"}function _e(s="context"){return s==="add"?"theme-patch-add":s==="delete"?"theme-patch-delete":s==="hunk"?"theme-patch-hunk":s==="meta"?"theme-patch-meta":"theme-patch-context"}function ge(s,l=""){const m=String(l||"").trim();m&&Array.from(s.keys()).forEach(y=>{String(y||"").startsWith(m)&&s.delete(y)})}function lt(){const s=Ht(e.taskSlug);ge(X,s),ge(J,s),ge(q,s)}function Me(){const s=r.value==="run"?"run":r.value==="task"?"task":"workspace",l=s==="run"?i.value:"",m=oe(e.taskSlug,s,l);return{scope:s,runId:l,signature:m}}function rt(s,l="after"){const m=String((s==null?void 0:s.path)||"").trim();if(!e.taskSlug||!m)return"";const y=Me();return ht(e.taskSlug,{scope:y.scope,runId:y.runId,filePath:m,side:l})}function ze(s=""){var m;const l=String(s||"").trim();return l&&(((m=u.value)==null?void 0:m.files)||[]).find(y=>y.path===l)||null}function Oe(s=null){return!!s&&!s.patchLoaded&&!s.binary&&!s.tooLarge&&!s.message}function pe(s="",l="",m=null,y=null){var B;const K=oe(e.taskSlug,r.value,r.value==="run"?i.value:"");return s!==K||!m||!((B=u.value)!=null&&B.files)?!1:(u.value={...u.value,baseline:(y==null?void 0:y.baseline)||u.value.baseline||null,warnings:(y==null?void 0:y.warnings)||u.value.warnings||[],files:u.value.files.map(D=>D.path===l?m:D)},!0)}async function Ee(s="",l={}){const m=String(s||"").trim(),y=String(l.signature||"").trim();if(!m||!y)return null;const K=Ne(y,m),B=ye(q,K);if(B)return{detailedFile:B,normalizedPayload:null};const D=Y.get(K);if(D)return D;const ne=(async()=>{try{const ee=await Ae(e.taskSlug,{scope:l.scope,runId:l.runId,filePath:m,timeoutMs:W}),ie=Ve(ee),xe=(ie.files||[]).find(Le=>Le.path===m);if(!xe)throw new Error(U("diffReview.noFileDiffContent"));return be(q,K,xe,120),{detailedFile:xe,normalizedPayload:ie}}catch(ee){return{error:ee}}finally{Y.delete(K)}})();return Y.set(K,ne),ne}async function He(){var l,m;if(!e.taskSlug||!e.active||!((l=u.value)!=null&&l.supported))return;const s=Me();for(const y of ae.value){const K=ze(y);if(!Oe(K))continue;const B=oe(e.taskSlug,r.value,r.value==="run"?i.value:"");if(s.signature!==B)return;const D=await Ee(y,s);if(D){if(D.error){const ne=De(((m=D.error)==null?void 0:m.message)||"")||U("diffReview.fileDiffTimedOut"),ee={...K,patch:"",patchLoaded:!0,tooLarge:!0,message:ne};be(q,Ne(s.signature,y),ee,120),pe(s.signature,y,ee,null);continue}pe(s.signature,y,D.detailedFile,D.normalizedPayload)}}}async function ot(){if(!e.taskSlug){v.value=[],i.value="",p="",g=-1;return}const s=se.getTaskRunSyncVersion(e.taskSlug);if(p===e.taskSlug&&g===s)return;const l=await mt(e.taskSlug,{limit:20,events:"none"});v.value=l.items||[],p=e.taskSlug,g=s,Se()}async function je(){if(!e.taskSlug||!e.active)return;const s=++_;I.value=!0,R.value=!1,M.value="";try{const l=r.value==="run"?"run":r.value==="task"?"task":"workspace";l==="run"&&await ot();const m=oe(e.taskSlug,l,l==="run"?i.value:"");if(l==="run"&&!i.value){u.value={supported:!1,reason:U("diffReview.noReviewRuns"),repoRoot:"",summary:{fileCount:0,additions:0,deletions:0,statsComplete:!0},files:[]},ce();return}const y=ye(X,m);if(y){u.value=y,f=m;const D=ye(J,m);D?(u.value={...y,baseline:D.baseline||y.baseline||null,warnings:D.warnings||y.warnings||[],summary:D.summary||y.summary},C=m):C="",ce(),Pe().catch(()=>{}),He().catch(()=>{}),D||qe().catch(()=>{});return}const K=await Ae(e.taskSlug,{scope:l,runId:l==="run"?i.value:"",includeStats:!1});if(s!==_)return;const B=Ve(K);u.value=B,be(X,m,B,36),f=m,C="",ce(),Pe().catch(()=>{}),He().catch(()=>{}),qe().catch(()=>{})}catch(l){if(s!==_)return;M.value=l.message,u.value=null}finally{s===_&&(I.value=!1)}}async function qe(){var K,B,D;if(!e.taskSlug||!e.active||!((K=u.value)!=null&&K.supported))return;const s=r.value==="run"?"run":r.value==="task"?"task":"workspace",l=s==="run"?i.value:"",m=oe(e.taskSlug,s,l);if(C===m&&((D=(B=u.value)==null?void 0:B.summary)!=null&&D.statsComplete))return;const y=ye(J,m);if(y){u.value={...u.value,baseline:y.baseline||u.value.baseline||null,warnings:y.warnings||u.value.warnings||[],summary:y.summary||u.value.summary},C=m,R.value=!1;return}R.value=!0;try{const ne=await Ae(e.taskSlug,{scope:s,runId:l,includeFiles:!1,includeStats:!0}),ee=oe(e.taskSlug,r.value,r.value==="run"?i.value:"");if(m!==ee||!u.value)return;const ie=Ve(ne);u.value={...u.value,baseline:ie.baseline||u.value.baseline||null,warnings:ie.warnings||u.value.warnings||[],summary:ie.summary||u.value.summary},be(J,m,{baseline:ie.baseline||null,warnings:ie.warnings||[],summary:ie.summary||null},36),C=m}catch{}finally{const ne=oe(e.taskSlug,r.value,r.value==="run"?i.value:"");m===ne&&(R.value=!1)}}async function Pe(){var D,ne;const s=String(w.value||"").trim();if(!e.taskSlug||!e.active||!s)return;const l=Me(),m=ze(s);if(!Oe(m))return;const y=Ne(l.signature,s),K=ye(q,y);if(K&&((D=u.value)!=null&&D.files)){pe(l.signature,s,K,null);return}const B=++$;N.value=!0;try{const ee=await Ee(s,l);if(B!==$||!ee)return;const ie=oe(e.taskSlug,r.value,r.value==="run"?i.value:"");if(l.signature!==ie)return;if(ee.error){const xe=De(((ne=ee.error)==null?void 0:ne.message)||"")||U("diffReview.fileDiffTimedOut"),Le={...m,patch:"",patchLoaded:!0,tooLarge:!0,message:xe};be(q,y,Le,120),pe(l.signature,s,Le,null);return}pe(l.signature,s,ee.detailedFile,ee.normalizedPayload)}finally{B===$&&(N.value=!1,String(w.value||"").trim()!==s&&Pe().catch(()=>{}))}}function Ce({force:s=!1}={}){if(!e.taskSlug||!e.active)return;const l=oe(e.taskSlug,r.value,r.value==="run"?i.value:"");!s&&l===f||je().catch(()=>{})}async function dt(){!e.taskSlug||!e.active||I.value||(lt(),f="",C="",p="",g=-1,await je())}return te(()=>[e.taskSlug,e.active,r.value,i.value],([s,l],m=[])=>{const y=m[0]||"";s!==y&&(w.value="",f="",v.value=[],i.value="",p="",g=-1,C=""),!(!s||!l)&&Ce()},{immediate:!0}),te(()=>{var s,l;return[b.value,((l=(s=u.value)==null?void 0:s.files)==null?void 0:l.length)||0]},()=>{ce()}),te(()=>[w.value,P.value.length],()=>{H.value=0,E.clear(),at(()=>{var s,l;P.value.length?ue(0,{behavior:"auto",block:"start"}):(l=(s=G.value)==null?void 0:s.scrollTo)==null||l.call(s,{top:0,behavior:"auto"})})}),te(()=>w.value,()=>{Pe().catch(()=>{})},{immediate:!0}),te(()=>{var s;return[e.active,(s=u.value)==null?void 0:s.supported,ae.value.join(`
3
+ `)]},([s,l])=>{!s||!l||He().catch(()=>{})}),te(()=>[e.preferredScope,e.preferredRunId,e.focusToken],([s,l,m],y=[])=>{const K=Number(y[2]||0),B=s==="run"?"run":s==="task"?"task":"workspace",D=B==="run"&&l?String(l||""):"",ne=r.value!==B,ee=B==="run"&&D&&i.value!==D;r.value=B,D&&(i.value=D),B!=="run"&&(i.value=""),!ne&&!ee&&e.active&&e.taskSlug&&m!==K&&(f="",Ce())},{immediate:!0}),te(()=>se.readyVersion.value,()=>{!e.active||!e.taskSlug||(p="",g=-1,f="",C="",Ce({force:!0}))}),te(()=>se.getTaskDiffSyncVersion(e.taskSlug),()=>{!e.active||!e.taskSlug||(p="",g=-1,C="",f="",Ce({force:!0}))}),{activeHunkIndex:H,baselineMetaText:A,diffPayload:u,diffScope:r,error:M,fileSearch:T,filteredFiles:d,getFilterButtonClass:F,getFilterLabel:Fe,getFileBlobUrl:rt,getPatchLineClass:_e,getRunStatusLabel:L,getStatusClass:$e,getStatusLabel:Re,jumpToAdjacentHunk:le,loadDiff:je,loading:I,normalizeFileStatus:fe,patchLoading:N,patchViewportRef:G,runs:v,selectedFile:k,selectedFilePath:w,selectedPatchHunks:P,selectedPatchLines:j,selectedRunId:i,setPatchLineRef:me,showSummarySkeleton:x,statsLoading:R,statusCounts:n,statusFilter:b,terminalRuns:de,formatRunOptionLabel:S,refreshDiff:dt}}const Vt={class:"mb-3 grid grid-cols-2 gap-2"},Ut=["onClick"],zt={class:"theme-input-shell mb-3 flex items-center gap-2 rounded-sm border px-3 py-2 text-xs text-[var(--theme-textMuted)]"},Ot=["placeholder"],Et={key:0,class:"theme-empty-state theme-empty-state-strong mb-3 px-3 py-2 text-[11px]"},qt={key:1,class:"theme-empty-state px-3 py-4 text-xs"},Wt={key:2,class:"theme-empty-state px-3 py-4 text-xs"},Kt={key:3,class:"space-y-1"},Gt=["onClick","onKeydown"],Jt={class:"min-w-0 flex-1"},Qt={class:"flex items-start gap-2"},Xt={class:"theme-list-item-title min-w-0 flex-1 break-all"},Yt={key:0,class:"theme-status-info inline-flex shrink-0 items-center rounded-sm border border-dashed px-1.5 py-0.5 text-[10px]"},Zt={class:"theme-list-item-meta mt-1"},Ze={__name:"TaskDiffFileList",props:{diffPayload:{type:Object,default:null},fileSearch:{type:String,default:""},autoFocusSelected:{type:Boolean,default:!1},filteredFiles:{type:Array,default:()=>[]},focusToken:{type:Number,default:0},getFilterButtonClass:{type:Function,default:()=>""},getFilterLabel:{type:Function,default:e=>e},getStatusClass:{type:Function,default:()=>""},getStatusLabel:{type:Function,default:e=>e},selectedFilePath:{type:String,default:""},showSummarySkeleton:{type:Boolean,default:!1},statusCounts:{type:Object,default:()=>({})},statusFilter:{type:String,default:"all"}},emits:["select-file","update:fileSearch","update:statusFilter"],setup(e,{emit:r}){const i=e,w=r,{t:b}=ke(),T=new Map,v=Q(0),u=Q(0),I=z({get:()=>i.fileSearch,set:_=>w("update:fileSearch",_)}),R=z({get:()=>i.statusFilter,set:_=>w("update:statusFilter",_)}),M=z(()=>{var _;return Array.isArray((_=i.diffPayload)==null?void 0:_.files)&&i.diffPayload.files.length>0});function N(_,$){if($){T.set(_,$);return}T.delete(_)}function G(_){at(()=>{var f,C;const $=T.get(_);(f=$==null?void 0:$.focus)==null||f.call($),(C=$==null?void 0:$.scrollIntoView)==null||C.call($,{block:"nearest",inline:"nearest"})})}function H(){!i.autoFocusSelected||!i.selectedFilePath||v.value===u.value||(u.value=v.value,G(i.selectedFilePath))}function E(_=1,$=""){const f=Array.isArray(i.filteredFiles)?i.filteredFiles:[];if(!f.length)return;const C=f.findIndex(q=>q.path===$),p=f.findIndex(q=>q.path===i.selectedFilePath),X=(Math.max(0,C>=0?C:p)+_+f.length)%f.length,J=f[X];J!=null&&J.path&&(w("select-file",J.path),G(J.path))}function se(_,$){const f=String((_==null?void 0:_.key)||"");if(f==="ArrowDown"){_.preventDefault(),E(1,$);return}if(f==="ArrowUp"){_.preventDefault(),E(-1,$);return}(f==="Enter"||f===" ")&&$&&(_.preventDefault(),w("select-file",$))}return te(()=>i.focusToken,_=>{v.value=_,H()},{immediate:!0}),te(()=>i.selectedFilePath,()=>{H()}),(_,$)=>(c(),h(he,null,[a("div",Vt,[(c(),h(he,null,Ie(["all","A","M","D"],f=>a("button",{key:f,type:"button",class:Z(["inline-flex w-full items-center justify-center gap-1 whitespace-nowrap rounded-sm border px-2 py-1 text-[11px] transition",e.getFilterButtonClass(f)]),onClick:C=>R.value=f},o(e.getFilterLabel(f))+" "+o(e.statusCounts[f]||0),11,Ut)),64))]),a("label",zt,[V(t(Ct),{class:"h-3.5 w-3.5 shrink-0"}),Ue(a("input",{"onUpdate:modelValue":$[0]||($[0]=f=>I.value=f),type:"text",placeholder:t(b)("diffReview.searchFilePath"),class:"min-w-0 flex-1 bg-transparent text-xs text-[var(--theme-textPrimary)] outline-none placeholder:text-[var(--theme-textMuted)]"},null,8,Ot),[[$t,I.value]])]),e.showSummarySkeleton?(c(),h("div",Et,o(t(b)("diffReview.statsPending")),1)):O("",!0),M.value?e.filteredFiles.length?(c(),h("div",Kt,[(c(!0),h(he,null,Ie(e.filteredFiles,f=>{var C;return c(),h("button",{key:f.path,ref_for:!0,ref:p=>N(f.path,p),type:"button",class:Z(["theme-list-row focus:outline-none",f.path===e.selectedFilePath?"theme-list-item-active":"theme-list-item-hover"]),onClick:p=>w("select-file",f.path),onKeydown:p=>se(p,f.path)},[a("span",{class:Z(["theme-list-item-badge",e.getStatusClass(f.status)])},o(e.getStatusLabel(f.status)),3),a("div",Jt,[a("div",Qt,[a("div",Xt,o(f.path),1),f.binary?(c(),h("span",Yt,o(t(b)("diffReview.binaryTag")),1)):O("",!0)]),a("div",Zt,o(f.binary?((C=f.binaryPreview)==null?void 0:C.mimeType)||t(b)("diffReview.binaryPreviewTitle"):f.statsLoaded?`+${f.additions} / -${f.deletions}`:t(b)("diffReview.statsOnDemand")),1)])],42,Gt)}),128))])):(c(),h("div",Wt,o(t(b)("diffReview.noMatches")),1)):(c(),h("div",qt,o(t(b)("diffReview.noChanges")),1))],64))}},es={class:"flex h-full min-h-0 flex-col overflow-hidden"},ts={class:"theme-divider theme-secondary-text border-b px-4 py-3 text-[12px]"},ss={class:"flex flex-wrap items-center gap-2"},as={class:"font-medium text-[var(--theme-textPrimary)]"},ns={class:"theme-muted-text"},is={class:"min-h-0 flex-1 overflow-auto p-4"},ls={key:0,class:"grid min-h-full gap-4 md:grid-cols-2"},rs={class:"theme-inline-panel flex min-h-[20rem] flex-col rounded-sm border p-3"},os={class:"mb-3 flex items-center justify-between gap-2"},ds={class:"min-w-0"},us={class:"text-sm font-medium text-[var(--theme-textPrimary)]"},cs={class:"theme-muted-text mt-1 text-[11px]"},fs=["href","download","title"],hs={key:0,class:"theme-empty-state flex min-h-[16rem] flex-1 items-center justify-center text-[12px]"},ms={key:1,class:"theme-empty-state flex min-h-[16rem] flex-1 items-center justify-center text-[12px]"},vs={key:2,class:"theme-empty-state flex min-h-[16rem] flex-1 items-center justify-center text-[12px]"},gs=["title"],ps=["src","alt"],xs=["src"],ys=["src"],bs=["src","title"],ws={class:"theme-inline-panel flex min-h-[20rem] flex-col rounded-sm border p-3"},ks={class:"mb-3 flex items-center justify-between gap-2"},Ss={class:"min-w-0"},Rs={class:"text-sm font-medium text-[var(--theme-textPrimary)]"},$s={class:"theme-muted-text mt-1 text-[11px]"},Fs=["href","download","title"],_s={key:0,class:"theme-empty-state flex min-h-[16rem] flex-1 items-center justify-center text-[12px]"},Ps={key:1,class:"theme-empty-state flex min-h-[16rem] flex-1 items-center justify-center text-[12px]"},Cs={key:2,class:"theme-empty-state flex min-h-[16rem] flex-1 items-center justify-center text-[12px]"},Ls=["title"],Ts=["src","alt"],Is=["src"],Ds=["src"],Ms=["src","title"],Hs={key:1,class:"theme-inline-panel flex min-h-full flex-col rounded-sm border p-4"},js={class:"flex items-center gap-2"},As={class:"text-sm font-medium text-[var(--theme-textPrimary)]"},Bs={class:"mt-4 grid gap-3 md:grid-cols-2"},Ns={class:"rounded-sm border border-dashed px-3 py-3"},Vs={class:"text-xs font-medium text-[var(--theme-textPrimary)]"},Us={class:"theme-muted-text mt-2 space-y-1 text-[12px]"},zs={key:0},Os=["href","download"],Es={class:"rounded-sm border border-dashed px-3 py-3"},qs={class:"text-xs font-medium text-[var(--theme-textPrimary)]"},Ws={class:"theme-muted-text mt-2 space-y-1 text-[12px]"},Ks={key:0},Gs=["href","download"],Js={__name:"TaskDiffBinaryPreview",props:{getFileBlobUrl:{type:Function,default:()=>""},selectedFile:{type:Object,default:null}},setup(e){const r=e,{t:i}=ke(),w=Q(""),b=Q({before:!1,after:!1});function T(p=0){const g=Math.max(0,Number(p)||0);return g<1024?`${g} B`:g<1024*1024?`${(g/1024).toFixed(g<10*1024?1:0)} KB`:`${(g/(1024*1024)).toFixed(g<10*1024*1024?1:0)} MB`}function v(p="after"){var g,X;return((X=(g=r.selectedFile)==null?void 0:g.binaryPreview)==null?void 0:X[p])||{exists:!1,size:0,hashShort:"",mimeType:"",previewKind:"binary",tooLarge:!1}}function u(p="after"){return r.selectedFile?r.getFileBlobUrl(r.selectedFile,p):""}function I(p="binary"){return p==="image"?Ke:p==="audio"?Lt:p==="video"?Tt:p==="pdf"?It:Ke}const R=z(()=>{var p,g;return String(((g=(p=r.selectedFile)==null?void 0:p.binaryPreview)==null?void 0:g.kind)||"binary")}),M=z(()=>v("before")),N=z(()=>v("after")),G=z(()=>u("before")),H=z(()=>u("after")),E=z(()=>{var p;return String(((p=r.selectedFile)==null?void 0:p.path)||"").trim()}),se=z(()=>["image","audio","video","pdf"].includes(R.value)),_=z(()=>R.value!=="image"?[]:[M.value.exists&&!M.value.tooLarge&&!b.value.before?G.value:"",N.value.exists&&!N.value.tooLarge&&!b.value.after?H.value:""].filter(Boolean));function $(p){return(p==null?void 0:p.exists)&&!(p!=null&&p.tooLarge)}function f(p="before"){b.value={...b.value,[p]:!0}}function C(p=""){const g=String(p||"").trim();g&&(w.value=g)}return te(()=>{var p,g,X,J,q,Y,W;return[String(((p=r.selectedFile)==null?void 0:p.path)||"").trim(),String(G.value||"").trim(),String(H.value||"").trim(),String(((J=(X=(g=r.selectedFile)==null?void 0:g.binaryPreview)==null?void 0:X.before)==null?void 0:J.hash)||"").trim(),String(((W=(Y=(q=r.selectedFile)==null?void 0:q.binaryPreview)==null?void 0:Y.after)==null?void 0:W.hash)||"").trim()].join(`
4
+ `)},()=>{w.value="",b.value={before:!1,after:!1}},{immediate:!0}),(p,g)=>{var X,J,q,Y;return c(),h("div",es,[a("div",ts,[a("div",ss,[a("span",as,o(E.value),1),a("span",ns,o(t(i)("diffReview.binaryPreviewTitle")),1)])]),a("div",is,[se.value?(c(),h("div",ls,[a("section",rs,[a("div",os,[a("div",ds,[a("p",us,o(t(i)("diffReview.binaryBefore")),1),a("p",cs,o(M.value.exists?`${T(M.value.size)} · ${M.value.hashShort||"-"}`:t(i)("diffReview.binarySideMissing")),1)]),$(M.value)?(c(),h("a",{key:0,class:"theme-icon-button h-8 w-8",href:G.value,download:((X=e.selectedFile)==null?void 0:X.path)||"before.bin",title:t(i)("diffReview.downloadBinarySide")},[V(t(Te),{class:"h-4 w-4"})],8,fs)):O("",!0)]),M.value.exists?M.value.tooLarge?(c(),h("div",ms,o(t(i)("diffReview.binaryPreviewTooLarge")),1)):b.value.before?(c(),h("div",vs,o(t(i)("diffReview.binaryPreviewUnavailable")),1)):R.value==="image"?(c(),h("button",{key:3,type:"button",class:"task-diff-binary-image-wrap flex min-h-[16rem] flex-1 cursor-zoom-in items-center justify-center rounded-sm border p-3",title:t(i)("diffReview.openImagePreview"),onClick:g[1]||(g[1]=W=>C(G.value))},[a("img",{src:G.value,alt:`${E.value} before`,class:"max-h-full max-w-full object-contain",onError:g[0]||(g[0]=W=>f("before"))},null,40,ps)],8,gs)):R.value==="audio"?(c(),h("audio",{key:4,class:"w-full",src:G.value,controls:"",preload:"metadata",onError:g[2]||(g[2]=W=>f("before"))},null,40,xs)):R.value==="video"?(c(),h("video",{key:5,class:"max-h-[26rem] w-full rounded-sm border bg-black",src:G.value,controls:"",preload:"metadata",onError:g[3]||(g[3]=W=>f("before"))},null,40,ys)):R.value==="pdf"?(c(),h("iframe",{key:6,class:"min-h-[26rem] w-full rounded-sm border bg-white",src:G.value,title:`${E.value} before`,onError:g[4]||(g[4]=W=>f("before"))},null,40,bs)):O("",!0):(c(),h("div",hs,o(t(i)("diffReview.binarySideMissing")),1))]),a("section",ws,[a("div",ks,[a("div",Ss,[a("p",Rs,o(t(i)("diffReview.binaryAfter")),1),a("p",$s,o(N.value.exists?`${T(N.value.size)} · ${N.value.hashShort||"-"}`:t(i)("diffReview.binarySideMissing")),1)]),$(N.value)?(c(),h("a",{key:0,class:"theme-icon-button h-8 w-8",href:H.value,download:((J=e.selectedFile)==null?void 0:J.path)||"after.bin",title:t(i)("diffReview.downloadBinarySide")},[V(t(Te),{class:"h-4 w-4"})],8,Fs)):O("",!0)]),N.value.exists?N.value.tooLarge?(c(),h("div",Ps,o(t(i)("diffReview.binaryPreviewTooLarge")),1)):b.value.after?(c(),h("div",Cs,o(t(i)("diffReview.binaryPreviewUnavailable")),1)):R.value==="image"?(c(),h("button",{key:3,type:"button",class:"task-diff-binary-image-wrap flex min-h-[16rem] flex-1 cursor-zoom-in items-center justify-center rounded-sm border p-3",title:t(i)("diffReview.openImagePreview"),onClick:g[6]||(g[6]=W=>C(H.value))},[a("img",{src:H.value,alt:`${E.value} after`,class:"max-h-full max-w-full object-contain",onError:g[5]||(g[5]=W=>f("after"))},null,40,Ts)],8,Ls)):R.value==="audio"?(c(),h("audio",{key:4,class:"w-full",src:H.value,controls:"",preload:"metadata",onError:g[7]||(g[7]=W=>f("after"))},null,40,Is)):R.value==="video"?(c(),h("video",{key:5,class:"max-h-[26rem] w-full rounded-sm border bg-black",src:H.value,controls:"",preload:"metadata",onError:g[8]||(g[8]=W=>f("after"))},null,40,Ds)):R.value==="pdf"?(c(),h("iframe",{key:6,class:"min-h-[26rem] w-full rounded-sm border bg-white",src:H.value,title:`${E.value} after`,onError:g[9]||(g[9]=W=>f("after"))},null,40,Ms)):O("",!0):(c(),h("div",_s,o(t(i)("diffReview.binarySideMissing")),1))])])):(c(),h("div",Hs,[a("div",js,[(c(),ve(Ft(I(R.value)),{class:"h-5 w-5 text-[var(--theme-textSecondary)]"})),a("span",As,o(t(i)("diffReview.binaryMetaTitle")),1)]),a("div",Bs,[a("div",Ns,[a("div",Vs,o(t(i)("diffReview.binaryBefore")),1),a("div",Us,[a("p",null,o(M.value.exists?`${T(M.value.size)} · ${M.value.hashShort||"-"}`:t(i)("diffReview.binarySideMissing")),1),M.value.mimeType?(c(),h("p",zs,o(M.value.mimeType),1)):O("",!0)]),$(M.value)?(c(),h("a",{key:0,class:"tool-button mt-3 inline-flex items-center gap-2 px-3 py-2 text-xs",href:G.value,download:((q=e.selectedFile)==null?void 0:q.path)||"before.bin"},[V(t(Te),{class:"h-3.5 w-3.5"}),a("span",null,o(t(i)("diffReview.downloadBinarySide")),1)],8,Os)):O("",!0)]),a("div",Es,[a("div",qs,o(t(i)("diffReview.binaryAfter")),1),a("div",Ws,[a("p",null,o(N.value.exists?`${T(N.value.size)} · ${N.value.hashShort||"-"}`:t(i)("diffReview.binarySideMissing")),1),N.value.mimeType?(c(),h("p",Ks,o(N.value.mimeType),1)):O("",!0)]),$(N.value)?(c(),h("a",{key:0,class:"tool-button mt-3 inline-flex items-center gap-2 px-3 py-2 text-xs",href:H.value,download:((Y=e.selectedFile)==null?void 0:Y.path)||"after.bin"},[V(t(Te),{class:"h-3.5 w-3.5"}),a("span",null,o(t(i)("diffReview.downloadBinarySide")),1)],8,Gs)):O("",!0)])])]))]),V(vt,{modelValue:w.value,"onUpdate:modelValue":g[10]||(g[10]=W=>w.value=W),images:_.value},null,8,["modelValue","images"])])}}},Qs=st(Js,[["__scopeId","data-v-4703ec91"]]),Xs={key:0,class:"flex h-full min-h-0 flex-col overflow-hidden"},Ys={class:"theme-divider theme-secondary-text border-b px-4 py-3 text-[12px]"},Zs={class:"space-y-3 sm:hidden"},ea={class:"flex items-start gap-2"},ta={class:"min-w-0 break-all font-medium text-[var(--theme-textPrimary)]"},sa={class:"flex items-center justify-between gap-3"},aa={class:"min-w-0"},na={class:"opacity-75"},ia={key:0,class:"theme-muted-text mt-1 text-[11px]"},la=["disabled"],ra={class:"min-w-[64px] text-center text-[12px] text-[var(--theme-textSecondary)]"},oa=["disabled"],da={class:"hidden items-center gap-3 sm:flex"},ua={class:"flex min-w-0 flex-1 flex-wrap items-center gap-2"},ca={class:"break-all font-medium text-[var(--theme-textPrimary)]"},fa={class:"opacity-75"},ha={key:0,class:"theme-muted-text text-[11px]"},ma=["disabled"],va={class:"min-w-[64px] text-center text-[12px] text-[var(--theme-textSecondary)]"},ga=["disabled"],pa={key:1,class:"theme-secondary-text flex-1 overflow-y-auto px-4 py-4 text-[12px]"},xa={class:"theme-empty-state px-4 py-4"},ya={key:2,class:"theme-muted-text flex-1 overflow-y-auto px-4 py-4 text-[12px]"},ba={class:"task-diff-view min-w-max px-4 py-4 font-mono"},wa={key:0,class:"theme-inline-panel theme-secondary-text mb-3 rounded-sm border border-dashed px-3 py-2 text-[12px]"},ka=["data-line-id","data-line-kind"],Sa={class:"task-diff-row__number select-none"},Ra={class:"task-diff-row__number select-none"},$a=["innerHTML"],Fa={key:4,class:"theme-secondary-text flex-1 overflow-y-auto px-4 py-4 text-[12px]"},_a={class:"theme-empty-state px-4 py-4"},Pa={key:1,class:"theme-muted-text flex h-full items-center justify-center px-5 text-[12px]"},Ca={__name:"TaskDiffPatchView",props:{activeHunkIndex:{type:Number,default:0},getPatchLineClass:{type:Function,default:()=>""},getFileBlobUrl:{type:Function,default:()=>""},getStatusClass:{type:Function,default:()=>""},getStatusLabel:{type:Function,default:e=>e},jumpToAdjacentHunk:{type:Function,default:()=>{}},patchLoading:{type:Boolean,default:!1},selectedFile:{type:Object,default:null},selectedPatchHunks:{type:Array,default:()=>[]},selectedPatchLines:{type:Array,default:()=>[]},setPatchLineRef:{type:Function,default:()=>{}},setPatchViewportRef:{type:Function,default:()=>{}}},emits:["insert-code-context"],setup(e,{emit:r}){const i=e,w=r,{t:b}=ke(),{isDark:T}=ct(),v=Q([]),u=z(()=>{var n;return wt(((n=i.selectedFile)==null?void 0:n.path)||"")}),I=Q(null),R=new Map,M=z(()=>{var n,d;return!!((n=i.selectedFile)!=null&&n.binary&&((d=i.selectedFile)!=null&&d.binaryPreview))});function N(n={}){return["add","delete","context"].includes(String((n==null?void 0:n.kind)||"").trim())}function G(n=""){const d=String(n||"").trim();return d&&v.value.find(k=>k.id===d)||null}const{selectedRows:H,selectionAction:E,clearSelectionState:se,handleSelectionMouseUp:_,updateSelectionActionFromDom:$}=gt({getContainer:()=>I.value,isActive:()=>!!(i.selectedFile&&i.selectedPatchLines.length),rowSelector:".task-diff-row[data-line-id]",getOrderedRowElements:n=>[...n.querySelectorAll(".task-diff-row[data-line-id]")].filter(d=>N(G(d.getAttribute("data-line-id")))),mapRowElement:n=>{var d;return G(((d=n==null?void 0:n.getAttribute)==null?void 0:d.call(n,"data-line-id"))||"")},getCodeLeft:n=>{var ae,x,A;const d=(ae=n==null?void 0:n.querySelector)==null?void 0:ae.call(n,".task-diff-line");if(!d)return 0;const k=(x=d.getBoundingClientRect)==null?void 0:x.call(d),j=(A=window.getComputedStyle)==null?void 0:A.call(window,d),P=Number.parseFloat((j==null?void 0:j.paddingLeft)||"0")||0;return((k==null?void 0:k.left)||0)+P},debounceMs:72});function f(n=[]){const d=n.flatMap(P=>[Number((P==null?void 0:P.oldNumber)||0),Number((P==null?void 0:P.newNumber)||0)]).filter(P=>P>0);if(!d.length)return{start:0,end:0,label:""};const k=Math.min(...d),j=Math.max(...d);return{start:k,end:j,label:k===j?`L${k}`:`L${k}-L${j}`}}function C(n=[]){return n.map(d=>String((d==null?void 0:d.content)||"")).join(`
5
+ `).replace(/\u200b/g,"").trim()}function p(){var d,k,j;if(!i.selectedFile||!E.value.visible||!H.value.length)return;const n=f(H.value);w("insert-code-context",{source:"diff",filePath:String(i.selectedFile.path||""),language:"diff",rangeLabel:n.label,lineStart:n.start,lineEnd:n.end,content:C(H.value)||String(E.value.content||"").trim()}),(j=(k=(d=window.getSelection)==null?void 0:d.call(window))==null?void 0:k.removeAllRanges)==null||j.call(k),se()}function g(n,d){if(i.setPatchLineRef(n,d),!!n){if(d){R.set(n,d);return}R.delete(n)}}function X(n){I.value=n||null,i.setPatchViewportRef(n)}function J(n){var A,L,me,ue;const d=(A=window.getSelection)==null?void 0:A.call(window),k=I.value;if(!d||d.rangeCount<1||d.isCollapsed||!k)return;$();const P=d.getRangeAt(0).commonAncestorContainer;if(!k.contains((P==null?void 0:P.nodeType)===1?P:P==null?void 0:P.parentNode))return;const ae=H.value;if(!ae.length)return;const x=C(ae);x&&((me=(L=n==null?void 0:n.clipboardData)==null?void 0:L.setData)==null||me.call(L,"text/plain",x),(ue=n==null?void 0:n.preventDefault)==null||ue.call(n))}function q(n){return(n==null?void 0:n.kind)==="add"?"+":(n==null?void 0:n.kind)==="delete"?"-":(n==null?void 0:n.kind)==="context"?" ":""}function Y(n){const d=String((n==null?void 0:n.content)||"");return(n==null?void 0:n.kind)==="add"||(n==null?void 0:n.kind)==="delete"||(n==null?void 0:n.kind)==="context"?d.slice(1):d}function W(n=""){return String(n||"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function re(n,d=""){if((n==null?void 0:n.kind)==="add"||(n==null?void 0:n.kind)==="delete"||(n==null?void 0:n.kind)==="context"){const k=q(n),j=`task-diff-line__prefix--${n.kind}`;return{...n,renderedHtml:`<span class="task-diff-line__prefix ${j}">${W(k||" ")}</span><span class="task-diff-line__body">${d||"&#8203;"}</span>`}}return{...n,renderedHtml:W(String((n==null?void 0:n.content)||""))}}async function de(){const n=Array.isArray(i.selectedPatchLines)?i.selectedPatchLines:[],d=[];n.forEach((x,A)=>{((x==null?void 0:x.kind)==="add"||(x==null?void 0:x.kind)==="delete"||(x==null?void 0:x.kind)==="context")&&d.push({lineIndex:A,body:Y(x)})});const k=xt(d.map(x=>x.body));let j=0;if(v.value=n.map(x=>{if((x==null?void 0:x.kind)==="add"||(x==null?void 0:x.kind)==="delete"||(x==null?void 0:x.kind)==="context"){const A=k[j]||"&#8203;";return j+=1,re(x,A)}return re(x)}),!d.length||yt(d.map(x=>x.body),Be))return;const P=await bt(d.map(x=>x.body),{isDark:T.value,language:u.value,maxHighlightLines:Be.maxLines,maxHighlightChars:Be.maxChars});let ae=0;v.value=n.map(x=>{if((x==null?void 0:x.kind)==="add"||(x==null?void 0:x.kind)==="delete"||(x==null?void 0:x.kind)==="context"){const A=P[ae]||"&#8203;";return ae+=1,re(x,A)}return re(x)})}return te(()=>{var n;return[i.selectedPatchLines,(n=i.selectedFile)==null?void 0:n.path,T.value]},()=>{se(),de()},{immediate:!0,deep:!0}),_t(()=>{var n,d,k;(k=(d=(n=window.getSelection)==null?void 0:n.call(window))==null?void 0:d.removeAllRanges)==null||k.call(d),se({clearBrowserSelection:!0}),R.clear()}),(n,d)=>e.selectedFile?(c(),h("div",Xs,[a("div",Ys,[a("div",Zs,[a("div",ea,[a("span",{class:Z(["inline-flex shrink-0 rounded-sm border px-1.5 py-0.5 text-[12px]",e.getStatusClass(e.selectedFile.status)])},o(e.getStatusLabel(e.selectedFile.status)),3),a("span",ta,o(e.selectedFile.path),1)]),a("div",sa,[a("div",aa,[a("div",na,o(e.selectedFile.statsLoaded?`+${e.selectedFile.additions} / -${e.selectedFile.deletions}`:t(b)("diffReview.statsOnDemand")),1),M.value?O("",!0):(c(),h("div",ia,o(t(b)("diffReview.selectCodeLineHint")),1))]),a("div",{class:Z(["inline-flex h-8 shrink-0 items-center gap-1 rounded-sm border px-1.5 py-1",e.selectedPatchHunks.length?"theme-inline-panel":"pointer-events-none invisible border-transparent"])},[a("button",{type:"button",class:"theme-icon-button h-6 w-6 disabled:opacity-50",disabled:e.activeHunkIndex<=0,onClick:d[0]||(d[0]=k=>e.jumpToAdjacentHunk(-1))},[V(t(Ge),{class:"h-4 w-4"})],8,la),a("span",ra,o(t(b)("diffReview.changeIndex",{current:Math.min(e.activeHunkIndex+1,e.selectedPatchHunks.length),total:e.selectedPatchHunks.length})),1),a("button",{type:"button",class:"theme-icon-button h-6 w-6 disabled:opacity-50",disabled:e.activeHunkIndex>=e.selectedPatchHunks.length-1,onClick:d[1]||(d[1]=k=>e.jumpToAdjacentHunk(1))},[V(t(Je),{class:"h-4 w-4"})],8,oa)],2)])]),a("div",da,[a("div",ua,[a("span",{class:Z(["inline-flex rounded-sm border px-1.5 py-0.5 text-[12px]",e.getStatusClass(e.selectedFile.status)])},o(e.getStatusLabel(e.selectedFile.status)),3),a("span",ca,o(e.selectedFile.path),1),a("span",fa,o(e.selectedFile.statsLoaded?`+${e.selectedFile.additions} / -${e.selectedFile.deletions}`:t(b)("diffReview.statsOnDemand")),1),M.value?O("",!0):(c(),h("span",ha,o(t(b)("diffReview.selectCodeLineHint")),1))]),a("div",{class:Z(["inline-flex h-8 w-[132px] shrink-0 items-center gap-1 rounded-sm border px-1.5 py-1",e.selectedPatchHunks.length?"theme-inline-panel":"pointer-events-none invisible border-transparent"])},[a("button",{type:"button",class:"theme-icon-button h-6 w-6 disabled:opacity-50",disabled:e.activeHunkIndex<=0,onClick:d[2]||(d[2]=k=>e.jumpToAdjacentHunk(-1))},[V(t(Ge),{class:"h-4 w-4"})],8,ma),a("span",va,o(t(b)("diffReview.changeIndex",{current:Math.min(e.activeHunkIndex+1,e.selectedPatchHunks.length),total:e.selectedPatchHunks.length})),1),a("button",{type:"button",class:"theme-icon-button h-6 w-6 disabled:opacity-50",disabled:e.activeHunkIndex>=e.selectedPatchHunks.length-1,onClick:d[3]||(d[3]=k=>e.jumpToAdjacentHunk(1))},[V(t(Je),{class:"h-4 w-4"})],8,ga)],2)])]),e.selectedFile.binary&&e.selectedFile.binaryPreview?(c(),ve(Qs,{key:0,"get-file-blob-url":e.getFileBlobUrl,"selected-file":e.selectedFile},null,8,["get-file-blob-url","selected-file"])):e.selectedFile.message&&!e.selectedPatchLines.length?(c(),h("div",pa,[a("div",xa,o(e.selectedFile.message),1)])):e.patchLoading&&!e.selectedFile.patchLoaded?(c(),h("div",ya,o(t(b)("diffReview.loadingFileDiff")),1)):e.selectedPatchLines.length?(c(),h("div",{key:3,ref:X,class:"relative flex-1 overflow-auto",onCopy:J,onMouseup:d[4]||(d[4]=(...k)=>t(_)&&t(_)(...k))},[a("div",ba,[e.selectedFile.message?(c(),h("div",wa,o(e.selectedFile.message),1)):O("",!0),(c(!0),h(he,null,Ie(v.value,k=>{var j;return c(),h("div",{key:k.id,ref_for:!0,ref:P=>g(k.id,P),class:Z(["task-diff-row grid",[e.getPatchLineClass(k.kind),k.kind==="hunk"&&((j=e.selectedPatchHunks[e.activeHunkIndex])==null?void 0:j.id)===k.id?"ring-1 ring-inset ring-[var(--theme-warning)]":""]]),"data-line-id":k.id,"data-line-kind":k.kind},[a("span",Sa,o(k.oldNumber),1),a("span",Ra,o(k.newNumber),1),a("pre",{class:Z(["task-diff-line overflow-visible whitespace-pre px-3 py-0.5",k.kind==="meta"||k.kind==="hunk"?"task-diff-line--plain":""]),innerHTML:k.renderedHtml},null,10,$a)],10,ka)}),128))]),t(E).visible?(c(),ve(pt,{key:0,top:t(E).top,left:t(E).left,label:t(b)("diffReview.insertSelection"),onClick:p},null,8,["top","left","label"])):O("",!0)],32)):(c(),h("div",Fa,[a("div",_a,o(t(b)("diffReview.noFileDiffContent")),1)]))])):(c(),h("div",Pa,o(t(b)("diffReview.selectFile")),1))}},et=st(Ca,[["__scopeId","data-v-ee7937d4"]]),La={class:"panel flex h-full min-h-0 flex-col overflow-hidden"},Ta={class:"theme-divider border-b px-4 py-3"},Ia={class:"flex flex-col gap-2"},Da={class:"grid grid-cols-4 gap-2 sm:flex sm:flex-wrap sm:items-center"},Ma={class:"sm:hidden"},Ha={class:"hidden sm:inline"},ja={class:"sm:hidden"},Aa={class:"hidden sm:inline"},Ba=["disabled"],Na={class:"sm:hidden"},Va={class:"hidden sm:inline"},Ua={class:"truncate text-xs text-[var(--theme-textPrimary)]"},za={class:"theme-divider theme-muted-text border-b border-dashed px-3 py-2 text-[11px]"},Oa=["onClick"],Ea={class:"flex items-start gap-3"},qa={class:"min-w-0 flex-1"},Wa={class:"truncate text-xs font-medium text-[var(--theme-textPrimary)]"},Ka={class:"theme-muted-text mt-1 text-[11px]"},Ga={key:0,class:"theme-divider theme-danger-text border-b px-4 py-3 text-sm"},Ja={class:"inline-flex items-start gap-2"},Qa={class:"break-all"},Xa={key:1,class:"theme-muted-text flex flex-1 items-center justify-center px-5 text-sm"},Ya={key:2,class:"flex flex-1 items-center justify-center px-5"},Za={class:"theme-empty-state w-full max-w-xl px-4 py-5 text-sm text-[var(--theme-textSecondary)]"},en={class:"theme-heading inline-flex items-center gap-2 font-medium"},tn={class:"mt-2 break-all leading-7"},sn={key:0,class:"mt-3 flex flex-wrap gap-2 text-xs"},an={class:"theme-status-neutral inline-flex items-center gap-2 rounded-sm border border-dashed px-2.5 py-1.5"},nn={class:"break-all"},ln={key:0,class:"theme-status-success inline-flex items-center gap-2 rounded-sm border border-dashed px-2.5 py-1.5"},rn={key:3,class:"flex min-h-0 flex-1 flex-col overflow-hidden"},on={class:"theme-divider theme-secondary-text border-b px-4 py-3 text-xs"},dn={class:"flex flex-wrap items-center gap-2"},un={key:0,class:"theme-status-info inline-flex min-w-0 items-center gap-2 rounded-sm border border-dashed px-2.5 py-1.5"},cn={class:"min-w-0 break-all"},fn={class:"theme-status-success inline-flex items-center gap-2 rounded-sm border border-dashed px-2.5 py-1.5"},hn={class:"text-[var(--theme-textPrimary)]"},mn={class:"font-medium text-[var(--theme-success)]"},vn={class:"font-medium text-[var(--theme-danger)]"},gn={key:2,class:"opacity-75"},pn={key:0,class:"mt-2 break-all text-[11px] opacity-75"},xn={key:1,class:"mt-2 flex flex-col gap-1"},yn={key:0,class:"flex min-h-0 flex-1 flex-col overflow-hidden"},bn={class:"theme-divider border-b px-3 py-3"},wn={class:"grid grid-cols-2 gap-2"},kn=["disabled"],Sn={class:"theme-divider theme-muted-panel min-h-0 flex-1 overflow-y-auto p-3"},Rn={class:"min-h-0 flex-1 overflow-hidden bg-[var(--theme-appPanelStrong)]"},$n={key:1,class:"grid min-h-0 flex-1 grid-cols-[320px_minmax(0,1fr)] overflow-hidden"},Fn={class:"theme-divider theme-muted-panel min-h-0 overflow-y-auto border-r p-3"},_n={class:"min-h-0 overflow-hidden bg-[var(--theme-appPanelStrong)]"},Pn={__name:"TaskDiffReviewPanel",props:{taskSlug:{type:String,default:""},preferredScope:{type:String,default:"workspace"},preferredRunId:{type:String,default:""},focusToken:{type:Number,default:0},active:{type:Boolean,default:!1}},emits:["insert-code-context"],setup(e,{emit:r}){const i=e,w=r,{activeHunkIndex:b,baselineMetaText:T,diffPayload:v,diffScope:u,error:I,fileSearch:R,filteredFiles:M,formatRunOptionLabel:N,getFilterButtonClass:G,getFilterLabel:H,getFileBlobUrl:E,getPatchLineClass:se,getRunStatusLabel:_,getStatusClass:$,getStatusLabel:f,jumpToAdjacentHunk:C,loading:p,patchLoading:g,patchViewportRef:X,refreshDiff:J,selectedFile:q,selectedFilePath:Y,selectedPatchHunks:W,selectedPatchLines:re,selectedRunId:de,setPatchLineRef:n,showSummarySkeleton:d,statsLoading:k,statusCounts:j,statusFilter:P,terminalRuns:ae}=Nt(i),{matches:x}=kt("(max-width: 767px)"),A=Q("files"),{t:L}=ke();function me(le){Y.value=le,x.value&&(A.value="patch")}function ue(le){X.value=le||null}return te(x,le=>{le||(A.value="files")},{immediate:!0}),te(Y,le=>{!le&&x.value&&(A.value="files")}),te(u,()=>{x.value&&(A.value="files")}),(le,S)=>{var Se,ce,Re,$e,Fe;return c(),h("section",La,[a("div",Ta,[a("div",Ia,[a("div",Da,[a("button",{type:"button",class:Z(["tool-button inline-flex items-center justify-center gap-2 px-3 py-2 text-xs",t(u)==="workspace"?"theme-filter-active":""]),onClick:S[0]||(S[0]=F=>u.value="workspace")},[a("span",Ma,o(t(L)("diffReview.scopeCurrentShort")),1),a("span",Ha,o(t(L)("diffReview.scopeCurrent")),1)],2),a("button",{type:"button",class:Z(["tool-button inline-flex items-center justify-center gap-2 px-3 py-2 text-xs",t(u)==="task"?"theme-filter-active":""]),onClick:S[1]||(S[1]=F=>u.value="task")},[a("span",ja,o(t(L)("diffReview.scopeTaskShort")),1),a("span",Aa,o(t(L)("diffReview.scopeTask")),1)],2),a("button",{type:"button",class:Z(["tool-button inline-flex items-center justify-center gap-2 px-3 py-2 text-xs",t(u)==="run"?"theme-filter-active":""]),onClick:S[2]||(S[2]=F=>u.value="run")},[a("span",null,o(t(L)("diffReview.scopeRun")),1)],2),a("button",{type:"button",class:"tool-button tool-button-info-subtle inline-flex shrink-0 items-center justify-center gap-2 px-3 py-2 text-xs",disabled:t(p),onClick:S[3]||(S[3]=(...F)=>t(J)&&t(J)(...F))},[V(t(Qe),{class:Z(["h-3.5 w-3.5 sm:hidden",t(p)?"animate-spin":""])},null,8,["class"]),a("span",Na,o(t(L)("diffReview.refresh")),1),V(t(Qe),{class:Z(["hidden h-3.5 w-3.5 sm:inline-block",t(p)?"animate-spin":""])},null,8,["class"]),a("span",Va,o(t(p)?t(L)("diffReview.refreshing"):t(k)?t(L)("diffReview.computing"):t(L)("diffReview.refresh")),1)],8,Ba)]),t(u)==="run"?(c(),ve(St,{key:0,modelValue:t(de),"onUpdate:modelValue":S[4]||(S[4]=F=>Pt(de)?de.value=F:null),class:"min-w-0 sm:max-w-[360px]",options:t(ae),loading:t(p),"get-option-value":F=>(F==null?void 0:F.id)||"",placeholder:t(L)("diffReview.selectRun"),"empty-text":t(L)("diffReview.noRuns")},{trigger:we(({selectedOption:F})=>[a("div",Ua,o(F?t(N)(F):t(L)("diffReview.selectRun")),1)]),header:we(()=>[a("div",za,o(t(L)("diffReview.runCount",{count:t(ae).length})),1)]),option:we(({option:F,selected:_e,select:ge})=>[a("button",{type:"button",class:Z(["w-full rounded-sm border border-dashed px-3 py-2 text-left transition",_e?"theme-filter-active":"theme-filter-idle"]),onClick:ge},[a("div",Ea,[a("div",qa,[a("div",Wa,o(t(tt)(F.startedAt||F.createdAt,{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"})),1),a("div",Ka,o(t(_)(F)),1)]),_e?(c(),ve(t(Dt),{key:0,class:"mt-0.5 h-4 w-4 shrink-0 text-[var(--theme-textSecondary)]"})):O("",!0)])],10,Oa)]),_:1},8,["modelValue","options","loading","get-option-value","placeholder","empty-text"])):O("",!0)])]),t(I)?(c(),h("div",Ga,[a("div",Ja,[V(t(Mt),{class:"mt-0.5 h-4 w-4 shrink-0"}),a("span",Qa,o(t(I)),1)])])):O("",!0),t(p)&&!t(v)?(c(),h("div",Xa,o(t(L)("diffReview.loading")),1)):t(v)&&!t(v).supported?(c(),h("div",Ya,[a("div",Za,[a("div",en,[V(t(nt),{class:"h-4 w-4"}),a("span",null,o(t(L)("diffReview.unavailableTitle")),1)]),a("p",tn,o(t(v).reason||t(L)("diffReview.unavailableReason")),1),t(v).repoRoot?(c(),h("div",sn,[a("div",an,[V(t(Xe),{class:"h-3.5 w-3.5 shrink-0"}),a("span",nn,o(t(v).repoRoot),1)]),t(v).branch?(c(),h("div",ln,[V(t(Ye),{class:"h-3.5 w-3.5 shrink-0"}),a("span",null,o(t(v).branch),1)])):O("",!0)])):O("",!0)])])):t(v)?(c(),h("div",rn,[a("div",on,[a("div",dn,[t(v).repoRoot?(c(),h("div",un,[V(t(Xe),{class:"h-3.5 w-3.5 shrink-0"}),a("span",cn,o(t(v).repoRoot),1)])):O("",!0),a("div",fn,[V(t(Ye),{class:"h-3.5 w-3.5 shrink-0"}),a("span",null,o(t(v).branch||t(L)("diffReview.unknownBranch")),1),S[18]||(S[18]=a("span",{class:"opacity-50"},"•",-1)),a("span",hn,o(t(L)("diffReview.fileCount",{count:((Se=t(v).summary)==null?void 0:Se.fileCount)||0})),1),(ce=t(v).summary)!=null&&ce.statsComplete?(c(),h(he,{key:0},[S[14]||(S[14]=a("span",{class:"opacity-50"},"•",-1)),a("span",mn,"+"+o(((Re=t(v).summary)==null?void 0:Re.additions)||0),1),a("span",vn,"-"+o((($e=t(v).summary)==null?void 0:$e.deletions)||0),1)],64)):t(d)?(c(),h(he,{key:1},[S[15]||(S[15]=a("span",{class:"opacity-50"},"•",-1)),S[16]||(S[16]=a("span",{class:"h-3 w-10 animate-pulse rounded bg-[var(--theme-successSoft)]"},null,-1)),S[17]||(S[17]=a("span",{class:"h-3 w-10 animate-pulse rounded bg-[var(--theme-dangerSoft)]"},null,-1))],64)):(c(),h("span",gn,o(t(L)("diffReview.waitingStats")),1))])]),t(T)?(c(),h("p",pn,o(t(T)),1)):O("",!0),(Fe=t(v).warnings)!=null&&Fe.length?(c(),h("div",xn,[(c(!0),h(he,null,Ie(t(v).warnings,F=>(c(),h("p",{key:F,class:"text-[11px] text-[var(--theme-warningText)]"},o(F),1))),128))])):O("",!0)]),t(x)?(c(),h("div",yn,[a("div",bn,[a("div",wn,[a("button",{type:"button",class:Z(["tool-button px-3 py-2 text-sm",A.value==="files"?"tool-button-accent-subtle":""]),onClick:S[5]||(S[5]=F=>A.value="files")},o(t(L)("diffReview.filesTab")),3),a("button",{type:"button",class:Z(["tool-button px-3 py-2 text-sm",A.value==="patch"?"tool-button-accent-subtle":""]),disabled:!t(q),onClick:S[6]||(S[6]=F=>A.value="patch")},o(t(L)("diffReview.diffTab")),11,kn)])]),Ue(a("div",Sn,[V(Ze,{"auto-focus-selected":e.active&&A.value==="files","diff-payload":t(v),"file-search":t(R),"focus-token":e.focusToken,"filtered-files":t(M),"get-filter-button-class":t(G),"get-filter-label":t(H),"get-status-class":t($),"get-status-label":t(f),"selected-file-path":t(Y),"show-summary-skeleton":t(d),"status-counts":t(j),"status-filter":t(P),"onUpdate:fileSearch":S[7]||(S[7]=F=>R.value=F),"onUpdate:statusFilter":S[8]||(S[8]=F=>P.value=F),onSelectFile:me},null,8,["auto-focus-selected","diff-payload","file-search","focus-token","filtered-files","get-filter-button-class","get-filter-label","get-status-class","get-status-label","selected-file-path","show-summary-skeleton","status-counts","status-filter"])],512),[[We,A.value==="files"]]),Ue(a("div",Rn,[V(et,{"active-hunk-index":t(b),"get-file-blob-url":t(E),"get-patch-line-class":t(se),"get-status-class":t($),"get-status-label":t(f),"jump-to-adjacent-hunk":t(C),"patch-loading":t(g),"selected-file":t(q),"selected-patch-hunks":t(W),"selected-patch-lines":t(re),"set-patch-line-ref":t(n),"set-patch-viewport-ref":ue,onInsertCodeContext:S[9]||(S[9]=F=>w("insert-code-context",F))},null,8,["active-hunk-index","get-file-blob-url","get-patch-line-class","get-status-class","get-status-label","jump-to-adjacent-hunk","patch-loading","selected-file","selected-patch-hunks","selected-patch-lines","set-patch-line-ref"])],512),[[We,A.value==="patch"]])])):(c(),h("div",$n,[a("div",Fn,[V(Ze,{"auto-focus-selected":e.active,"diff-payload":t(v),"file-search":t(R),"focus-token":e.focusToken,"filtered-files":t(M),"get-filter-button-class":t(G),"get-filter-label":t(H),"get-status-class":t($),"get-status-label":t(f),"selected-file-path":t(Y),"show-summary-skeleton":t(d),"status-counts":t(j),"status-filter":t(P),"onUpdate:fileSearch":S[10]||(S[10]=F=>R.value=F),"onUpdate:statusFilter":S[11]||(S[11]=F=>P.value=F),onSelectFile:S[12]||(S[12]=F=>Y.value=F)},null,8,["auto-focus-selected","diff-payload","file-search","focus-token","filtered-files","get-filter-button-class","get-filter-label","get-status-class","get-status-label","selected-file-path","show-summary-skeleton","status-counts","status-filter"])]),a("div",_n,[V(et,{"active-hunk-index":t(b),"get-file-blob-url":t(E),"get-patch-line-class":t(se),"get-status-class":t($),"get-status-label":t(f),"jump-to-adjacent-hunk":t(C),"patch-loading":t(g),"selected-file":t(q),"selected-patch-hunks":t(W),"selected-patch-lines":t(re),"set-patch-line-ref":t(n),"set-patch-viewport-ref":ue,onInsertCodeContext:S[13]||(S[13]=F=>w("insert-code-context",F))},null,8,["active-hunk-index","get-file-blob-url","get-patch-line-class","get-status-class","get-status-label","jump-to-adjacent-hunk","patch-loading","selected-file","selected-patch-hunks","selected-patch-lines","set-patch-line-ref"])])]))])):O("",!0)])}}},Cn={class:"theme-heading inline-flex items-center gap-2 text-sm font-medium"},An={__name:"TaskDiffReviewDialog",props:{open:{type:Boolean,default:!1},taskSlug:{type:String,default:""},taskTitle:{type:String,default:""},preferredScope:{type:String,default:"task"},preferredRunId:{type:String,default:""},focusToken:{type:Number,default:0}},emits:["close","insert-code-context"],setup(e,{emit:r}){const i=e,w=r,{t:b}=ke(),T=z(()=>{const u=String(i.taskTitle||"").trim();return u?b("diffReview.dialogTitleWithTask",{title:u}):b("diffReview.dialogTitle")});function v(u){w("insert-code-context",u),w("close")}return(u,I)=>(c(),ve(Rt,{open:e.open,"stack-level":2,"panel-class":"settings-dialog-panel h-[calc(100dvh-1rem)] sm:h-[96vh] sm:max-h-[96vh] sm:w-[90vw] sm:max-w-[90vw]","header-class":"settings-dialog-header px-5 py-4","body-class":"settings-dialog-body min-h-0 flex-1 overflow-hidden p-3 sm:p-4",onClose:I[0]||(I[0]=R=>w("close"))},{title:we(()=>[a("div",Cn,[V(t(nt),{class:"h-4 w-4"}),a("span",null,o(T.value),1)])]),default:we(()=>[V(Pn,{"task-slug":e.taskSlug,active:e.open,"preferred-scope":e.preferredScope,"preferred-run-id":e.preferredRunId,"focus-token":e.focusToken,onInsertCodeContext:v},null,8,["task-slug","active","preferred-scope","preferred-run-id","focus-token"])]),_:1},8,["open"]))}};export{An as default};
@@ -1 +1 @@
1
- import{aD as l,aE as c,aF as e,aQ as a,u as i,aR as j,aS as F,aL as I,aV as Ht,aI as T,aN as v,c as x,w as at,ak as qt,aJ as it,aG as K,aW as U,b2 as Kt,aY as ot,aX as fe,b3 as Wt,b as m,r as be}from"./vendor-misc-u-M8sNMf.js";import{k as Q,m as zt,j as Jt,n as Gt}from"./WorkbenchView-CsZnW4Q7.js";import{u as mt,b as Yt,W as De,c as Qt,f as Xt,d as lt}from"./index-Bt9T2IKp.js";import{b as gt,K as Ce,L as ue,H as rt,E as Zt,g as es,J as ct,t as ts,N as ss,x as ns}from"./vendor-ui-BglsaDbv.js";import"./vendor-markdown-9aQhqbjm.js";import"./vendor-tiptap-rwYdQb1L.js";import"./vendor-router-Dn8q3tJM.js";function as(){return Q("/api/relay/config",{cache:"no-store"})}function dt(L){return Q("/api/relay/config",{method:"PUT",body:JSON.stringify(L)})}function is(){return Q("/api/relay/reconnect",{method:"POST"})}function os(){return Q("/api/system/config",{cache:"no-store"})}function ut(L){return Q("/api/system/config",{method:"PUT",body:JSON.stringify(L)})}function ls(){return Q("/api/diagnostics/runtime",{cache:"no-store"})}const rs={class:"space-y-4"},cs={class:"flex items-center justify-between gap-3"},ds={class:"theme-heading text-sm font-medium"},us={class:"theme-toggle-current theme-badge-muted theme-muted-text rounded-sm border border-dashed px-2 py-1 text-[11px]"},ms={class:"theme-muted-text theme-note-text mt-1"},gs={class:"space-y-4"},hs={class:"theme-muted-text px-1 text-[10px] font-medium uppercase tracking-[0.16em]"},vs=["onClick"],xs={class:"flex items-start gap-3"},ys={class:"mt-0.5 flex items-center gap-1.5"},ps={class:"min-w-0 flex-1"},_s={class:"flex items-center justify-between gap-2"},fs={class:"truncate text-sm font-medium"},bs={class:"theme-muted-text theme-note-text mt-1"},Ds={__name:"ThemeToggle",setup(L){const{currentTheme:X,setTheme:Z,themes:me}=Yt(),{t:R}=mt(),ke=x(()=>{const C=me.value.filter(y=>y.mode==="light"),ee=me.value.filter(y=>y.mode==="dark");return[{id:"light",label:R("theme.groupLight"),items:C},{id:"dark",label:R("theme.groupDark"),items:ee}].filter(y=>y.items.length)});function we(C){Z(C)}function s(C){return R(`theme.description.${C.id}`,{},C.description)}return(C,ee)=>(l(),c("div",rs,[e("div",null,[e("div",cs,[e("div",ds,a(i(R)("theme.heading")),1),e("div",us,a(i(R)("theme.currentTheme",{name:i(X).shortName})),1)]),e("div",ms,a(i(R)("theme.helper")),1)]),e("div",gs,[(l(!0),c(j,null,F(ke.value,y=>(l(),c("section",{key:y.id,class:"space-y-1.5"},[e("div",hs,a(y.label),1),(l(!0),c(j,null,F(y.items,b=>(l(),c("button",{key:b.id,type:"button",class:I(["theme-option theme-toggle-card w-full rounded-sm border px-3 py-2 text-left transition",b.id===i(X).id?"theme-option-active":"theme-option-idle"]),onClick:O=>we(b.id)},[e("div",xs,[e("div",ys,[(l(!0),c(j,null,F(b.swatches,(O,P)=>(l(),c("span",{key:`${b.id}-${P}`,class:"h-3 w-3 rounded-full border border-black/10",style:Ht({backgroundColor:O})},null,4))),128))]),e("div",ps,[e("div",_s,[e("span",fs,a(b.shortName),1),b.id===i(X).id?(l(),T(i(gt),{key:0,class:"h-4 w-4 shrink-0"})):v("",!0)]),e("div",bs,a(s(b)),1)])])],10,vs))),128))]))),128))])]))}},Cs={class:"theme-heading inline-flex items-center gap-2 text-sm font-medium"},ks={class:"settings-dialog-content min-h-0 flex-1 overflow-y-auto px-5 py-5"},ws={key:0,class:"space-y-4"},Ss={class:"theme-heading inline-flex items-center gap-2 text-base font-medium"},Ts={class:"settings-section-card space-y-4 px-4 py-4"},Rs={class:"theme-heading text-sm font-medium"},Ps={class:"theme-muted-text mt-1 text-xs leading-5"},Es={class:"grid gap-3"},Ms={class:"min-w-0"},Bs={class:"text-sm font-medium text-[var(--theme-textPrimary)]"},Ns={class:"theme-muted-text mt-1 text-xs leading-5"},$s=["value","onChange"],Us={class:"settings-section-card space-y-4 px-4 py-4"},Is={class:"theme-heading text-sm font-medium"},js={class:"theme-muted-text mt-1 text-xs leading-5"},Fs={class:"settings-form-card flex items-center justify-between gap-3 px-3 py-3"},Ls={class:"min-w-0"},Os={class:"text-sm font-medium text-[var(--theme-textPrimary)]"},As={class:"theme-muted-text mt-1 text-xs leading-5"},Vs={class:"settings-section-card space-y-4 px-4 py-4"},Hs={class:"theme-heading text-sm font-medium"},qs={class:"theme-muted-text mt-1 text-xs leading-5"},Ks={class:"space-y-1.5"},Ws={class:"theme-muted-text text-xs"},zs={class:"space-y-2"},Js={class:"min-w-0"},Gs={class:"truncate text-sm font-medium text-[var(--theme-textPrimary)]"},Ys={class:"theme-muted-text mt-1 truncate text-xs"},Qs=["checked","value","onChange"],Xs={class:"theme-muted-text theme-note-text"},Zs={class:"settings-section-card space-y-4 px-4 py-4"},en={class:"theme-heading text-sm font-medium"},tn={class:"theme-muted-text mt-1 text-xs leading-5"},sn={class:"space-y-1.5"},nn={class:"theme-muted-text text-xs"},an={class:"space-y-2"},on={class:"min-w-0"},ln={class:"text-sm font-medium text-[var(--theme-textPrimary)]"},rn={class:"theme-muted-text mt-1 text-xs leading-5"},cn=["checked"],dn={class:"min-w-0"},un={class:"text-sm font-medium text-[var(--theme-textPrimary)]"},mn={class:"theme-muted-text mt-1 text-xs leading-5"},gn=["checked"],hn={class:"min-w-0"},vn={class:"text-sm font-medium text-[var(--theme-textPrimary)]"},xn={class:"theme-muted-text mt-1 text-xs leading-5"},yn=["checked"],pn={key:0,class:"space-y-1.5"},_n={class:"theme-muted-text text-xs"},fn=["placeholder"],bn={key:0,class:"theme-muted-text text-xs leading-5"},Dn={class:"theme-muted-text text-xs leading-5"},Cn={class:"settings-form-card px-3 py-3"},kn={class:"text-xs leading-5 text-[var(--theme-warningText)]"},wn={class:"settings-form-footer flex flex-wrap items-center justify-end gap-3"},Sn={class:"flex flex-wrap items-center gap-2"},Tn=["disabled"],Rn={key:1,class:"space-y-4"},Pn={class:"theme-heading text-base font-medium"},En={class:"theme-muted-text mt-1 text-xs leading-5"},Mn={class:"settings-section-card px-4 py-4"},Bn={key:2,class:"space-y-4"},Nn={class:"flex items-start justify-between gap-3"},$n={class:"theme-heading inline-flex items-center gap-2 text-base font-medium"},Un={class:"settings-section-card space-y-4 px-4 py-4"},In={class:"settings-form-card flex items-center justify-between gap-3 px-3 py-2"},jn={class:"text-sm font-medium text-[var(--theme-textPrimary)]"},Fn={class:"theme-muted-text mt-1 text-xs"},Ln=["disabled"],On={class:"grid gap-4 sm:grid-cols-2"},An={class:"space-y-1.5 sm:col-span-2"},Vn={class:"theme-muted-text text-xs"},Hn=["disabled"],qn={class:"space-y-1.5"},Kn={class:"theme-muted-text text-xs"},Wn=["disabled"],zn={class:"space-y-1.5"},Jn={class:"theme-muted-text text-xs"},Gn={class:"relative"},Yn=["type","placeholder","disabled"],Qn=["disabled"],Xn={class:"settings-form-footer flex flex-wrap items-center justify-between gap-3"},Zn={class:"min-w-0 space-y-1"},ea={key:0,class:"theme-danger-text theme-note-text"},ta={key:1,class:"theme-status-warning theme-note-text"},sa={key:2,class:"theme-danger-text theme-note-text"},na={key:3,class:"theme-status-success theme-note-text"},aa={key:4,class:"theme-danger-text theme-note-text"},ia={key:5,class:"theme-muted-text theme-note-text"},oa={key:6,class:"theme-muted-text theme-note-text"},la={key:7,class:"theme-muted-text theme-note-text"},ra={key:8,class:"theme-status-success theme-note-text"},ca={key:9,class:"theme-muted-text theme-note-text"},da={class:"flex flex-wrap items-center gap-2"},ua=["disabled"],ma=["disabled"],ga=["disabled"],ha={key:3,class:"space-y-4"},va={class:"theme-heading inline-flex items-center gap-2 text-base font-medium"},xa={class:"theme-muted-text mt-1 text-xs leading-5"},ya={class:"settings-section-card space-y-4 px-4 py-4"},pa={class:"space-y-1.5"},_a={class:"theme-muted-text text-xs"},fa=["disabled"],ba={class:"theme-muted-text text-xs leading-5"},Da={class:"settings-form-footer flex flex-wrap items-center justify-between gap-3"},Ca={class:"min-w-0 space-y-1"},ka={key:0,class:"theme-status-warning theme-note-text"},wa={key:1,class:"theme-danger-text theme-note-text"},Sa={key:2,class:"theme-status-success theme-note-text"},Ta={key:3,class:"theme-muted-text theme-note-text"},Ra={class:"flex flex-wrap items-center gap-2"},Pa=["disabled"],Ea={class:"settings-section-card space-y-4 px-4 py-4"},Ma={class:"flex flex-wrap items-start justify-between gap-3"},Ba={class:"theme-heading text-sm font-medium"},Na={class:"theme-muted-text mt-1 text-xs leading-5"},$a={class:"flex flex-wrap items-center gap-2"},Ua=["disabled"],Ia={class:"min-w-0 space-y-1"},ja={key:0,class:"theme-danger-text theme-note-text"},Fa={key:1,class:"theme-status-success theme-note-text"},La={key:2,class:"theme-muted-text theme-note-text"},Oa={key:0,class:"grid gap-3 sm:grid-cols-2 xl:grid-cols-4"},Aa={class:"settings-form-card space-y-1 px-3 py-3"},Va={class:"theme-heading text-lg font-medium"},Ha={class:"theme-muted-text text-xs"},qa={class:"settings-form-card space-y-1 px-3 py-3"},Ka={class:"theme-heading text-lg font-medium"},Wa={class:"theme-muted-text text-xs"},za={class:"settings-form-card space-y-1 px-3 py-3"},Ja={class:"theme-heading text-lg font-medium"},Ga={class:"theme-muted-text text-xs"},Ya={class:"settings-form-card space-y-1 px-3 py-3"},Qa={class:"theme-heading text-lg font-medium"},Xa={class:"theme-muted-text text-xs"},Za={key:1,class:"grid gap-3 sm:grid-cols-2 xl:grid-cols-4"},ei={class:"settings-form-card space-y-1 px-3 py-3"},ti={class:"theme-heading text-lg font-medium"},si={class:"theme-muted-text text-xs"},ni={class:"settings-form-card space-y-1 px-3 py-3"},ai={class:"theme-heading text-lg font-medium"},ii={class:"theme-muted-text text-xs"},oi={class:"settings-form-card space-y-1 px-3 py-3"},li={class:"theme-heading text-lg font-medium"},ri={class:"theme-muted-text text-xs"},ci={class:"settings-form-card space-y-1 px-3 py-3"},di={class:"theme-heading text-lg font-medium"},ui={class:"theme-muted-text text-xs"},mi={key:2,class:"grid gap-3 sm:grid-cols-2 xl:grid-cols-3"},gi={class:"settings-form-card space-y-1 px-3 py-3"},hi={class:"theme-heading text-lg font-medium"},vi={class:"theme-muted-text text-xs"},xi={class:"settings-form-card space-y-1 px-3 py-3"},yi={class:"theme-heading text-lg font-medium"},pi={class:"theme-muted-text text-xs"},_i={class:"settings-form-card space-y-1 px-3 py-3"},fi={class:"theme-heading text-sm font-medium"},bi={class:"theme-muted-text text-xs"},Di={class:"grid gap-4 lg:grid-cols-2"},Ci={class:"settings-form-card space-y-3 px-3 py-3"},ki={class:"theme-heading text-sm font-medium"},wi={class:"space-y-2 text-xs"},Si={class:"flex items-center justify-between gap-3"},Ti={class:"truncate text-right text-[var(--theme-textPrimary)]"},Ri={class:"flex items-center justify-between gap-3"},Pi={class:"text-right text-[var(--theme-textPrimary)]"},Ei={class:"flex items-center justify-between gap-3"},Mi={class:"text-right text-[var(--theme-textPrimary)]"},Bi={class:"flex items-center justify-between gap-3"},Ni={class:"text-right text-[var(--theme-textPrimary)]"},$i={class:"flex items-center justify-between gap-3"},Ui={class:"text-right text-[var(--theme-textPrimary)]"},Ii={class:"settings-form-card space-y-3 px-3 py-3"},ji={class:"theme-heading text-sm font-medium"},Fi={class:"space-y-2 text-xs"},Li={class:"theme-muted-text"},Oi={class:"text-[var(--theme-textPrimary)]"},Ai={key:3,class:"settings-form-card space-y-3 px-3 py-3"},Vi={class:"theme-heading text-sm font-medium"},Hi={class:"grid gap-2 sm:grid-cols-2 xl:grid-cols-3 text-xs"},qi={class:"theme-muted-text"},Ki={class:"text-[var(--theme-textPrimary)]"},Wi={key:4,class:"settings-form-card space-y-2 px-3 py-3"},zi={class:"theme-heading text-sm font-medium"},Ji={class:"theme-muted-text text-xs leading-5"},Gi={class:"theme-muted-text text-xs leading-5"},Yi={key:4,class:"space-y-4"},Qi={class:"theme-heading inline-flex items-center gap-2 text-base font-medium"},Xi={class:"theme-muted-text mt-1 text-xs leading-5"},Zi={class:"settings-section-card space-y-3 px-4 py-4"},eo={class:"min-w-0"},to={class:"text-sm font-medium text-[var(--theme-textPrimary)]"},so={class:"theme-muted-text mt-1 text-xs leading-5"},no={class:"flex flex-wrap items-center gap-2"},ao={class:"rounded-sm border border-dashed border-[var(--theme-borderDefault)] px-2.5 py-1 text-xs font-medium text-[var(--theme-textPrimary)]"},io={class:"rounded-sm border border-dashed border-[var(--theme-borderDefault)] px-2.5 py-1 text-xs font-medium text-[var(--theme-textPrimary)]"},oo={class:"theme-muted-text theme-note-text"},lo={key:5,class:"space-y-4"},ro={class:"theme-heading text-base font-medium"},co={class:"theme-muted-text mt-1 text-xs leading-5"},uo={class:"settings-section-card px-4 py-4"},mo={class:"flex items-center justify-between gap-3"},go={class:"theme-heading text-sm font-medium"},ho={class:"theme-muted-text mt-1 text-xs leading-5"},vo={class:"theme-badge-strong rounded-sm border border-dashed px-2.5 py-1 text-xs font-medium"},Co={__name:"WorkbenchSettingsDialog",props:{open:{type:Boolean,default:!1}},emits:["close"],setup(L,{emit:X}){const Z=L,me=X,{locale:R,localeOptions:ke,setLocale:we,t:s}=mt(),{getPreference:C,setPreference:ee}=Qt(),y=m(""),b=m(!1),O=m(""),P=m(!1),A=m(!1),E=m(!1),_=m(""),k=m(""),ge=m(!1),W=m(!1),M=m(""),te=m(""),se=m(!1),z=m(!1),he=m(!1),J=m(!1),ne=m(""),w=m(null),u=m(null),f=m(!1),G=be({runnerMaxConcurrentRuns:!1}),ae=m(!1),ve=m(!1),xe=m(!1),ye=m(!1),d=be({enabled:!1,relayUrl:"",deviceId:"",deviceToken:""}),Y=be({runnerMaxConcurrentRuns:3}),h=be({sendBehavior:"",notificationSoundEnabled:!1,remoteCommandSecurityMode:"disabled",trustedProxyToken:""}),S=m("general");let V=null,H=null,pe=null,ie=null;const ht=x(()=>[{id:"general",label:s("settingsDialog.general.sectionLabel"),description:s("settingsDialog.general.sectionDescription"),icon:Ce},{id:"theme",label:s("theme.title"),description:s("theme.sectionDescription"),icon:ss},{id:"relay",label:s("settingsDialog.relay.sectionLabel"),description:s("settingsDialog.relay.sectionDescription"),icon:rt},{id:"system",label:s("settingsDialog.system.sectionLabel"),description:s("settingsDialog.system.sectionDescription"),icon:ct},{id:"shortcuts",label:s("settingsDialog.shortcuts.sectionLabel"),description:s("settingsDialog.shortcuts.sectionDescription"),icon:Ce},{id:"about",label:s("settingsDialog.about.sectionLabel"),description:s("settingsDialog.about.sectionDescription"),icon:ns}]),vt=x(()=>lt.map(t=>({value:t.value,label:s(t.labelKey),description:s(t.descriptionKey)})));function xt(t=null,n=""){const o=String((t==null?void 0:t.messageKey)||"").trim();if(o){const g=s(o);if(g&&g!==o)return g}return String((t==null?void 0:t.message)||"").trim()||(n?s(n):"")}function _e(t="",n=""){const o=String(t||"").trim();if(o){const g=`settingsDialog.relay.reason.${o}`,D=s(g);if(D!==g)return D}return String(n||"").trim()||s("common.notAvailable")}function yt(t=null){const n=String((t==null?void 0:t.type)||"").trim()||"unknown",o=`settingsDialog.relay.event.${n}`,g=s(o);return g!==o?g:n}function pt(t=null){const n=String((t==null?void 0:t.lastErrorKey)||"").trim(),o=t!=null&&t.lastErrorParams&&typeof t.lastErrorParams=="object"?t.lastErrorParams:{};return n==="connect_failed"?s("settingsDialog.relay.error.connect_failed"):n==="disconnected"?s("settingsDialog.relay.error.disconnected",{reason:_e(o.reasonCode,t==null?void 0:t.lastCloseReason)}):n==="rejected"?s("settingsDialog.relay.error.rejected",{reason:_e(o.reasonCode,t==null?void 0:t.lastCloseReason)}):n==="closed_with_code"?s("settingsDialog.relay.error.closedWithCode",{code:o.code||(t==null?void 0:t.lastCloseCode)||0}):String((t==null?void 0:t.lastError)||"").trim()}const _t=x(()=>{var t,n,o,g;return E.value?s("settingsDialog.relay.status.reconnecting"):A.value||ae.value?s("settingsDialog.relay.status.saving"):P.value?s("settingsDialog.relay.status.loading"):(t=u.value)!=null&&t.reconnectPaused?s("settingsDialog.relay.status.paused"):(n=u.value)!=null&&n.connected?s("settingsDialog.relay.status.connected"):(((o=u.value)==null?void 0:o.enabled)??d.enabled)&&Number(((g=u.value)==null?void 0:g.nextReconnectDelayMs)||0)>0?s("settingsDialog.relay.status.waitingReconnect"):d.enabled?s("settingsDialog.relay.status.disconnected"):s("settingsDialog.relay.status.disabled")}),ft=x(()=>{var t,n;return(t=u.value)!=null&&t.reconnectPaused?"theme-status-danger":(n=u.value)!=null&&n.connected?"theme-status-success":d.enabled?"theme-status-warning":"theme-status-neutral"}),bt=x(()=>[{id:"open-settings",label:s("settingsDialog.shortcuts.openSettingsTitle"),description:s("settingsDialog.shortcuts.openSettingsDescription"),mac:"⌘ ⇧ ,",windows:"Ctrl + Shift + ,"},{id:"open-project-manager",label:s("settingsDialog.shortcuts.openProjectManagerTitle"),description:s("settingsDialog.shortcuts.openProjectManagerDescription"),mac:"⌘ ⇧ K",windows:"Ctrl + Shift + K"},{id:"open-source-browser",label:s("settingsDialog.shortcuts.openSourceBrowserTitle"),description:s("settingsDialog.shortcuts.openSourceBrowserDescription"),mac:"⌘ ⇧ O",windows:"Ctrl + Shift + O"},{id:"open-diff-review",label:s("settingsDialog.shortcuts.openDiffReviewTitle"),description:s("settingsDialog.shortcuts.openDiffReviewDescription"),mac:"⌘ ⇧ D",windows:"Ctrl + Shift + D"},{id:"close-top-dialog",label:s("settingsDialog.shortcuts.closeTopDialogTitle"),description:s("settingsDialog.shortcuts.closeTopDialogDescription"),mac:"Esc",windows:"Esc"}]),Dt=x(()=>{var t,n,o;return!f.value&&!_.value&&!k.value&&!((t=u.value)!=null&&t.lastError)&&!((n=u.value)!=null&&n.lastCloseReason)&&!((o=u.value)!=null&&o.lastConnectedAt)}),Ct=x(()=>{const t=d.deviceToken?`${"*".repeat(Math.max(0,d.deviceToken.length-4))}${d.deviceToken.slice(-4)}`:"";return JSON.stringify({generatedAt:new Date().toISOString(),source:"local-settings",config:{enabled:d.enabled,relayUrl:d.relayUrl,deviceId:d.deviceId,deviceTokenMasked:t,managedByEnv:f.value},status:u.value||null},null,2)}),q=x(()=>{var t,n;return((n=(t=w.value)==null?void 0:t.runner)==null?void 0:n.runner)||null}),oe=x(()=>{var t,n;return!!((n=(t=w.value)==null?void 0:t.runner)!=null&&n.ok&&q.value)}),p=x(()=>{var t;return((t=q.value)==null?void 0:t.metrics)||null}),Me=x(()=>{var t;return((t=w.value)==null?void 0:t.recovery)||null}),Be=x(()=>{var t;return((t=w.value)==null?void 0:t.maintenance)||null}),kt=x(()=>{var t;return((t=w.value)==null?void 0:t.gitDiffWorker)||null}),wt=x(()=>JSON.stringify({generatedAt:new Date().toISOString(),source:"local-settings",config:{runner:{maxConcurrentRuns:Y.runnerMaxConcurrentRuns,managedByEnv:G.runnerMaxConcurrentRuns}},diagnostics:w.value||null},null,2));function le(t){const n=String(t||"").trim();if(!n)return s("common.notAvailable");const o=new Date(n);return Number.isNaN(o.getTime())?n:Xt(o.toISOString(),{year:"numeric",month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"})}const St=x(()=>{var t,n,o,g,D,B,N,$;return[{key:"queued_cancelled",label:s("settingsDialog.system.stopReasons.queued_cancelled"),value:Math.max(0,Number((n=(t=p.value)==null?void 0:t.stopReasons)==null?void 0:n.queued_cancelled)||0)},{key:"user_requested",label:s("settingsDialog.system.stopReasons.user_requested"),value:Math.max(0,Number((g=(o=p.value)==null?void 0:o.stopReasons)==null?void 0:g.user_requested)||0)},{key:"user_requested_after_error",label:s("settingsDialog.system.stopReasons.user_requested_after_error"),value:Math.max(0,Number((B=(D=p.value)==null?void 0:D.stopReasons)==null?void 0:B.user_requested_after_error)||0)},{key:"stop_timeout",label:s("settingsDialog.system.stopReasons.stop_timeout"),value:Math.max(0,Number(($=(N=p.value)==null?void 0:N.stopReasons)==null?void 0:$.stop_timeout)||0)}]}),Tt=x(()=>{var t,n,o,g,D,B,N,$,ce,de;return[{key:"runner_timeout_without_stop_request",label:s("settingsDialog.system.stopTimeoutPhases.runner_timeout_without_stop_request"),value:Math.max(0,Number((n=(t=p.value)==null?void 0:t.stopTimeoutPhases)==null?void 0:n.runner_timeout_without_stop_request)||0)},{key:"runner_timeout_before_cancel",label:s("settingsDialog.system.stopTimeoutPhases.runner_timeout_before_cancel"),value:Math.max(0,Number((g=(o=p.value)==null?void 0:o.stopTimeoutPhases)==null?void 0:g.runner_timeout_before_cancel)||0)},{key:"cli_not_exiting",label:s("settingsDialog.system.stopTimeoutPhases.cli_not_exiting"),value:Math.max(0,Number((B=(D=p.value)==null?void 0:D.stopTimeoutPhases)==null?void 0:B.cli_not_exiting)||0)},{key:"os_kill_slow",label:s("settingsDialog.system.stopTimeoutPhases.os_kill_slow"),value:Math.max(0,Number(($=(N=p.value)==null?void 0:N.stopTimeoutPhases)==null?void 0:$.os_kill_slow)||0)},{key:"runner_finalize_after_exit",label:s("settingsDialog.system.stopTimeoutPhases.runner_finalize_after_exit"),value:Math.max(0,Number((de=(ce=p.value)==null?void 0:ce.stopTimeoutPhases)==null?void 0:de.runner_finalize_after_exit)||0)}]}),Rt=x(()=>ke.value.map(t=>({value:t.value,label:t.value==="zh-CN"?s("locale.zhHans"):s("locale.enUs"),englishLabel:t.englishLabel})));async function Pt(){b.value=!0,O.value="";try{const t=await Gt(),n=String((t==null?void 0:t.version)||"").trim();y.value=n,n||(O.value=s("settingsDialog.about.versionPending"))}catch(t){y.value="",O.value=(t==null?void 0:t.message)||s("settingsDialog.about.versionLoadFailed")}finally{b.value=!1}}function Se(t={}){d.enabled=!!(t!=null&&t.enabled),d.relayUrl=String((t==null?void 0:t.relayUrl)||""),d.deviceId=String((t==null?void 0:t.deviceId)||""),d.deviceToken=String((t==null?void 0:t.deviceToken)||"")}function Te(t={}){var n,o,g;Y.runnerMaxConcurrentRuns=Math.max(1,Number((n=t==null?void 0:t.runner)==null?void 0:n.maxConcurrentRuns)||3),h.remoteCommandSecurityMode=String(((o=t==null?void 0:t.remoteCommandSecurity)==null?void 0:o.mode)||"disabled").trim()||"disabled",h.trustedProxyToken="",he.value=!!((g=t==null?void 0:t.remoteCommandSecurity)!=null&&g.trustedProxyTokenConfigured)}function Et(){var t;h.sendBehavior=String(C(De.SEND_BEHAVIOR)||((t=lt[1])==null?void 0:t.value)||""),h.notificationSoundEnabled=!!C(De.NOTIFICATION_SOUND_ENABLED)}async function Ne(){P.value=!0,_.value="",k.value="";try{const t=await as();Se((t==null?void 0:t.config)||{}),f.value=!!(t!=null&&t.managedByEnv),u.value=(t==null?void 0:t.relay)||null}catch(t){_.value=(t==null?void 0:t.message)||s("settingsDialog.relay.relayConfigLoadFailed"),u.value=null}finally{P.value=!1}}async function Mt(){var t,n;ge.value=!0,M.value="",te.value="";try{const o=await os();Te((o==null?void 0:o.config)||{}),G.runnerMaxConcurrentRuns=!!((n=(t=o==null?void 0:o.managedByEnv)==null?void 0:t.runner)!=null&&n.maxConcurrentRuns),re()}catch(o){M.value=(o==null?void 0:o.message)||s("settingsDialog.system.systemConfigLoadFailed")}finally{ge.value=!1}}async function re(){J.value=!0,ne.value="";try{w.value=await ls()}catch(t){ne.value=(t==null?void 0:t.message)||s("settingsDialog.system.systemDiagnosticsLoadFailed")}finally{J.value=!1}}async function Bt(){A.value=!0,_.value="",k.value="";try{const t=await dt({enabled:d.enabled,relayUrl:d.relayUrl,deviceId:d.deviceId,deviceToken:d.deviceToken});Se((t==null?void 0:t.config)||{}),f.value=!!(t!=null&&t.managedByEnv),u.value=(t==null?void 0:t.relay)||null,k.value=d.enabled?s("settingsDialog.relay.relayConfigSavedEnabled"):s("settingsDialog.relay.relayConfigSavedDisabled")}catch(t){_.value=(t==null?void 0:t.message)||s("settingsDialog.relay.relayConfigSaveFailed")}finally{A.value=!1}}async function Nt(){E.value=!0,_.value="",k.value="";try{const t=await is();u.value=(t==null?void 0:t.relay)||null,k.value=s("settingsDialog.relay.relayReconnectTriggered"),setTimeout(()=>{Ne()},1200)}catch(t){_.value=(t==null?void 0:t.message)||s("settingsDialog.relay.relayReconnectFailed")}finally{E.value=!1}}async function $t(){var t,n;W.value=!0,M.value="",te.value="";try{const o=await ut({runner:{maxConcurrentRuns:Y.runnerMaxConcurrentRuns}});Te((o==null?void 0:o.config)||{}),G.runnerMaxConcurrentRuns=!!((n=(t=o==null?void 0:o.managedByEnv)==null?void 0:t.runner)!=null&&n.maxConcurrentRuns),te.value=s("settingsDialog.system.systemConfigSaved"),re()}catch(o){M.value=(o==null?void 0:o.message)||s("settingsDialog.system.systemConfigSaveFailed")}finally{W.value=!1}}function $e(){ie&&(clearTimeout(ie),ie=null),z.value=!1}async function Ut(){se.value=!0,M.value="";try{const t=await ut({remoteCommandSecurity:It()});Te((t==null?void 0:t.config)||{}),$e(),z.value=!0,ie=setTimeout(()=>{z.value=!1,ie=null},1200)}catch(t){M.value=(t==null?void 0:t.message)||s("settingsDialog.system.systemConfigSaveFailed")}finally{se.value=!1}}function It(){const t={mode:h.remoteCommandSecurityMode},n=String(h.trustedProxyToken||"").trim();return h.remoteCommandSecurityMode==="trusted-proxy"&&n&&(t.trustedProxyToken=n),t}function Re(t){h.remoteCommandSecurityMode=t}function jt(){return!!(String(d.relayUrl||"").trim()&&String(d.deviceId||"").trim()&&String(d.deviceToken||"").trim())}async function Ft(){var t;if(!f.value){if(_.value="",k.value="",d.enabled&&!jt()){d.enabled=!1,_.value=s("settingsDialog.relay.relayFieldsRequired");return}ae.value=!0;try{const n=await dt({enabled:d.enabled,relayUrl:d.relayUrl,deviceId:d.deviceId,deviceToken:d.deviceToken});Se((n==null?void 0:n.config)||{}),f.value=!!(n!=null&&n.managedByEnv),u.value=(n==null?void 0:n.relay)||null,k.value=d.enabled?s("settingsDialog.relay.relayEnabledSaved"):s("settingsDialog.relay.relayConfigSavedDisabled")}catch(n){d.enabled=!!((t=u.value)!=null&&t.enabled),_.value=(n==null?void 0:n.message)||s("settingsDialog.relay.relayToggleFailed")}finally{ae.value=!1}}}async function Ue(t){var o;if((o=navigator.clipboard)!=null&&o.writeText&&window.isSecureContext){await navigator.clipboard.writeText(t);return}const n=document.createElement("textarea");n.value=t,n.setAttribute("readonly","true"),n.style.position="fixed",n.style.opacity="0",n.style.pointerEvents="none",document.body.appendChild(n),n.select(),document.execCommand("copy"),document.body.removeChild(n)}async function Lt(){try{await Ue(Ct.value),xe.value=!0,V&&clearTimeout(V),V=setTimeout(()=>{xe.value=!1,V=null},2e3)}catch(t){_.value=(t==null?void 0:t.message)||s("settingsDialog.relay.relayDiagnosticsCopyFailed")}}async function Ot(){try{await Ue(wt.value),ye.value=!0,H&&clearTimeout(H),H=setTimeout(()=>{ye.value=!1,H=null},2e3)}catch(t){ne.value=(t==null?void 0:t.message)||s("settingsDialog.system.systemDiagnosticsCopyFailed")}}function At(t){we(t)}function Pe(){pe&&(clearInterval(pe),pe=null)}function Vt(){Pe(),!(!Z.open||S.value!=="system")&&(re(),pe=setInterval(()=>{re()},5e3))}return at(()=>Z.open,t=>{if(t){S.value="general",Et(),Pt(),Ne(),Mt();return}},{immediate:!0}),at([()=>Z.open,S],([t,n])=>{if(t&&n==="system"){Vt();return}Pe()},{immediate:!0}),qt(()=>{V&&(clearTimeout(V),V=null),H&&(clearTimeout(H),H=null),$e(),Pe()}),(t,n)=>(l(),T(Jt,{open:L.open,"stack-level":2,"panel-class":"settings-dialog-panel h-[calc(100dvh-1rem)] max-w-5xl sm:h-[96vh] sm:max-h-[96vh]","header-class":"settings-dialog-header px-5 py-4","body-class":"settings-dialog-body min-h-0 flex flex-1 flex-col sm:flex-row",onClose:n[14]||(n[14]=o=>me("close"))},{title:it(()=>[e("div",Cs,[K(i(ts),{class:"h-4 w-4"}),e("span",null,a(i(s)("common.settings")),1)])]),default:it(()=>{var o,g,D,B,N,$,ce,de,Ie,je,Fe,Le,Oe,Ae,Ve,He,qe,Ke,We,ze,Je,Ge,Ye,Qe,Xe,Ze,et,tt,st,nt;return[K(zt,{modelValue:S.value,"onUpdate:modelValue":n[0]||(n[0]=r=>S.value=r),sections:ht.value},null,8,["modelValue","sections"]),e("div",ks,[S.value==="general"?(l(),c("section",ws,[e("div",null,[e("div",Ss,[K(i(Ce),{class:"h-4 w-4"}),e("span",null,a(i(s)("settingsDialog.general.title")),1)])]),e("section",Ts,[e("div",null,[e("div",Rs,a(i(s)("settingsDialog.general.sendBehavior.title")),1),e("p",Ps,a(i(s)("settingsDialog.general.sendBehavior.description")),1)]),e("div",Es,[(l(!0),c(j,null,F(vt.value,r=>(l(),c("label",{key:r.value,class:I(["settings-form-card flex cursor-pointer items-start justify-between gap-3 px-3 py-3",h.sendBehavior===r.value?"ring-1 ring-[var(--theme-accent)]":""])},[e("div",Ms,[e("div",Bs,a(r.label),1),e("p",Ns,a(r.description),1)]),U(e("input",{"onUpdate:modelValue":n[1]||(n[1]=Ee=>h.sendBehavior=Ee),value:r.value,type:"radio",name:"workbench-send-behavior",class:"mt-0.5 h-4 w-4 shrink-0",onChange:Ee=>i(ee)(i(De).SEND_BEHAVIOR,r.value)},null,40,$s),[[Kt,h.sendBehavior]])],2))),128))])]),e("section",Us,[e("div",null,[e("div",Is,a(i(s)("settingsDialog.general.notificationSound.title")),1),e("p",js,a(i(s)("settingsDialog.general.notificationSound.description")),1)]),e("label",Fs,[e("div",Ls,[e("div",Os,a(i(s)("settingsDialog.general.notificationSound.switchLabel")),1),e("p",As,a(i(s)("settingsDialog.general.notificationSound.switchHint")),1)]),U(e("input",{"onUpdate:modelValue":n[2]||(n[2]=r=>h.notificationSoundEnabled=r),type:"checkbox",class:"h-4 w-4 shrink-0",onChange:n[3]||(n[3]=r=>i(ee)(i(De).NOTIFICATION_SOUND_ENABLED,h.notificationSoundEnabled))},null,544),[[ot,h.notificationSoundEnabled]])])]),e("section",Vs,[e("div",null,[e("div",Hs,a(i(s)("locale.title")),1),e("p",qs,a(i(s)("locale.description")),1)]),e("div",Ks,[e("span",Ws,a(i(s)("locale.field")),1),e("div",zs,[(l(!0),c(j,null,F(Rt.value,r=>(l(),c("label",{key:r.value,class:I(["settings-form-card flex cursor-pointer items-center justify-between gap-3 px-3 py-3",i(R)===r.value?"ring-1 ring-[var(--theme-accent)]":""])},[e("div",Js,[e("div",Gs,a(r.label),1),e("div",Ys,a(r.englishLabel),1)]),e("input",{checked:i(R)===r.value,value:r.value,name:"promptx-locale",type:"radio",class:"h-4 w-4 shrink-0",onChange:Ee=>At(r.value)},null,40,Qs)],2))),128))])]),e("p",Xs,a(i(s)("locale.immediateHint")),1)]),e("section",Zs,[e("div",null,[e("div",en,a(i(s)("settingsDialog.general.remoteCommandSecurityTitle")),1),e("p",tn,a(i(s)("settingsDialog.general.remoteCommandSecurityDescription")),1)]),e("div",sn,[e("span",nn,a(i(s)("settingsDialog.general.remoteCommandSecurityModeField")),1),e("div",an,[e("label",{class:I(["settings-form-card flex cursor-pointer items-start justify-between gap-3 px-3 py-3",h.remoteCommandSecurityMode==="disabled"?"ring-1 ring-[var(--theme-primary)]":""])},[e("div",on,[e("div",ln,a(i(s)("settingsDialog.general.remoteCommandSecurityModeDisabled")),1),e("p",rn,a(i(s)("settingsDialog.general.remoteCommandSecurityModeDisabledDescription")),1)]),e("input",{checked:h.remoteCommandSecurityMode==="disabled",type:"checkbox",class:"mt-0.5 h-4 w-4 shrink-0",onChange:n[4]||(n[4]=r=>Re("disabled"))},null,40,cn)],2),e("label",{class:I(["settings-form-card flex cursor-pointer items-start justify-between gap-3 px-3 py-3",h.remoteCommandSecurityMode==="relay"?"ring-1 ring-[var(--theme-primary)]":""])},[e("div",dn,[e("div",un,a(i(s)("settingsDialog.general.remoteCommandSecurityModeRelay")),1),e("p",mn,a(i(s)("settingsDialog.general.remoteCommandSecurityModeRelayDescription")),1)]),e("input",{checked:h.remoteCommandSecurityMode==="relay",type:"checkbox",class:"mt-0.5 h-4 w-4 shrink-0",onChange:n[5]||(n[5]=r=>Re("relay"))},null,40,gn)],2),e("label",{class:I(["settings-form-card flex cursor-pointer items-start justify-between gap-3 px-3 py-3",h.remoteCommandSecurityMode==="trusted-proxy"?"ring-1 ring-[var(--theme-primary)]":""])},[e("div",hn,[e("div",vn,a(i(s)("settingsDialog.general.remoteCommandSecurityModeTrustedProxy")),1),e("p",xn,a(i(s)("settingsDialog.general.remoteCommandSecurityModeTrustedProxyDescription")),1)]),e("input",{checked:h.remoteCommandSecurityMode==="trusted-proxy",type:"checkbox",class:"mt-0.5 h-4 w-4 shrink-0",onChange:n[6]||(n[6]=r=>Re("trusted-proxy"))},null,40,yn)],2)])]),h.remoteCommandSecurityMode==="trusted-proxy"?(l(),c("label",pn,[e("span",_n,a(i(s)("settingsDialog.general.trustedProxyTokenField")),1),U(e("input",{"onUpdate:modelValue":n[7]||(n[7]=r=>h.trustedProxyToken=r),type:"password",class:"tool-input",placeholder:he.value?i(s)("settingsDialog.general.trustedProxyTokenReplacePlaceholder"):i(s)("settingsDialog.general.trustedProxyTokenPlaceholder")},null,8,fn),[[fe,h.trustedProxyToken]]),he.value?(l(),c("p",bn,a(i(s)("settingsDialog.general.trustedProxyTokenConfiguredHint")),1)):v("",!0),e("p",Dn,a(he.value?i(s)("settingsDialog.general.trustedProxyTokenReplaceHint"):i(s)("settingsDialog.general.trustedProxyTokenHint")),1)])):v("",!0),e("div",Cn,[e("p",kn,a(i(s)("settingsDialog.general.remoteCommandSecurityWarning")),1)]),e("div",wn,[e("div",Sn,[e("button",{type:"button",class:I(["tool-button inline-flex items-center gap-2 px-3 py-2 text-xs",z.value?"tool-button-accent-subtle":"tool-button-primary"]),disabled:se.value,onClick:Ut},[se.value?(l(),T(i(ue),{key:0,class:"h-4 w-4 animate-spin"})):z.value?(l(),T(i(gt),{key:1,class:"h-4 w-4"})):v("",!0),e("span",null,a(se.value?i(s)("common.saving"):z.value?i(s)("settingsDialog.general.remoteCommandSecuritySaved"):i(s)("settingsDialog.general.remoteCommandSecuritySave")),1)],10,Tn)])])])])):S.value==="theme"?(l(),c("section",Rn,[e("div",null,[e("div",Pn,a(i(s)("theme.title")),1),e("p",En,a(i(s)("theme.sectionDescription")),1)]),e("section",Mn,[K(Ds)])])):S.value==="relay"?(l(),c("section",Bn,[e("div",Nn,[e("div",null,[e("div",$n,[K(i(rt),{class:"h-4 w-4"}),e("span",null,a(i(s)("settingsDialog.relay.title")),1)])]),e("span",{class:I(["rounded-sm border border-dashed px-2.5 py-1 text-xs font-medium",ft.value])},a(_t.value),3)]),e("section",Un,[e("label",In,[e("div",null,[e("div",jn,a(i(s)("settingsDialog.relay.enableTitle")),1),e("p",Fn,a(i(s)("settingsDialog.relay.enableDescription")),1)]),U(e("input",{"onUpdate:modelValue":n[8]||(n[8]=r=>d.enabled=r),type:"checkbox",class:"h-4 w-4",disabled:f.value,onChange:Ft},null,40,Ln),[[ot,d.enabled]])]),e("div",On,[e("label",An,[e("span",Vn,a(i(s)("settingsDialog.relay.relayUrl")),1),U(e("input",{"onUpdate:modelValue":n[9]||(n[9]=r=>d.relayUrl=r),type:"text",placeholder:"https://user1.promptx.example.com",class:"tool-input",disabled:f.value},null,8,Hn),[[fe,d.relayUrl]])]),e("label",qn,[e("span",Kn,a(i(s)("settingsDialog.relay.deviceId")),1),U(e("input",{"onUpdate:modelValue":n[10]||(n[10]=r=>d.deviceId=r),type:"text",placeholder:"my-macbook",class:"tool-input",disabled:f.value},null,8,Wn),[[fe,d.deviceId]])]),e("label",zn,[e("span",Jn,a(i(s)("settingsDialog.relay.deviceToken")),1),e("div",Gn,[U(e("input",{"onUpdate:modelValue":n[11]||(n[11]=r=>d.deviceToken=r),type:ve.value?"text":"password",placeholder:i(s)("settingsDialog.relay.deviceTokenPlaceholder"),class:"tool-input pr-10",disabled:f.value},null,8,Yn),[[Wt,d.deviceToken]]),e("button",{type:"button",class:"theme-icon-button absolute inset-y-1 right-1 flex h-auto w-8 items-center justify-center",disabled:f.value,onClick:n[12]||(n[12]=r=>ve.value=!ve.value)},[ve.value?(l(),T(i(es),{key:1,class:"h-4 w-4"})):(l(),T(i(Zt),{key:0,class:"h-4 w-4"}))],8,Qn)])])]),e("div",Xn,[e("div",Zn,[(o=u.value)!=null&&o.reconnectPausedReason?(l(),c("p",ea,a(i(s)("settingsDialog.relay.pausedReconnect",{reason:_e(u.value.reconnectPausedReasonCode,u.value.reconnectPausedReason)})),1)):v("",!0),f.value?(l(),c("p",ta,a(i(s)("settingsDialog.relay.managedByEnv")),1)):v("",!0),_.value?(l(),c("p",sa,a(_.value),1)):k.value?(l(),c("p",na,a(k.value),1)):(g=u.value)!=null&&g.lastError?(l(),c("p",aa,a(i(s)("settingsDialog.relay.lastError",{value:pt(u.value)})),1)):(D=u.value)!=null&&D.lastCloseReason?(l(),c("p",ia,a(i(s)("settingsDialog.relay.lastClosed",{reason:_e(u.value.lastCloseReasonCode,u.value.lastCloseReason),code:u.value.lastCloseCode})),1)):(B=u.value)!=null&&B.lastConnectedAt?(l(),c("p",oa,a(i(s)("settingsDialog.relay.lastConnected",{value:le(u.value.lastConnectedAt)})),1)):v("",!0),($=(N=u.value)==null?void 0:N.recentEvents)!=null&&$.length?(l(),c("p",la,a(i(s)("settingsDialog.relay.recentEvent",{value:yt(u.value.recentEvents[0])})),1)):v("",!0),xe.value?(l(),c("p",ra,a(i(s)("settingsDialog.relay.copied")),1)):v("",!0),Dt.value?(l(),c("p",ca,a(i(s)("settingsDialog.relay.defaultHint")),1)):v("",!0)]),e("div",da,[e("button",{type:"button",class:"tool-button inline-flex items-center gap-2 px-3 py-2 text-xs",disabled:P.value||A.value||ae.value||E.value||!(((ce=u.value)==null?void 0:ce.enabled)??d.enabled),onClick:Nt},[E.value?(l(),T(i(ue),{key:0,class:"h-4 w-4 animate-spin"})):v("",!0),e("span",null,a(E.value?i(s)("settingsDialog.relay.reconnecting"):i(s)("settingsDialog.relay.reconnectNow")),1)],8,ua),e("button",{type:"button",class:"tool-button inline-flex items-center gap-2 px-3 py-2 text-xs",disabled:P.value||E.value,onClick:Lt},[e("span",null,a(xe.value?i(s)("settingsDialog.relay.diagnosticsCopied"):i(s)("settingsDialog.relay.copyDiagnostics")),1)],8,ma),e("button",{type:"button",class:"tool-button tool-button-primary inline-flex items-center gap-2 px-3 py-2 text-xs",disabled:P.value||A.value||ae.value||E.value||f.value,onClick:Bt},[A.value?(l(),T(i(ue),{key:0,class:"h-4 w-4 animate-spin"})):v("",!0),e("span",null,a(A.value?i(s)("common.saving"):i(s)("settingsDialog.relay.saveConfig")),1)],8,ga)])])])])):S.value==="system"?(l(),c("section",ha,[e("div",null,[e("div",va,[K(i(ct),{class:"h-4 w-4"}),e("span",null,a(i(s)("settingsDialog.system.title")),1)]),e("p",xa,a(i(s)("settingsDialog.system.intro")),1)]),e("section",ya,[e("label",pa,[e("span",_a,a(i(s)("settingsDialog.system.maxConcurrentRuns")),1),U(e("input",{"onUpdate:modelValue":n[13]||(n[13]=r=>Y.runnerMaxConcurrentRuns=r),type:"number",min:"1",max:"16",step:"1",class:"tool-input",disabled:G.runnerMaxConcurrentRuns||ge.value||W.value},null,8,fa),[[fe,Y.runnerMaxConcurrentRuns,void 0,{number:!0}]]),e("p",ba,a(i(s)("settingsDialog.system.maxConcurrentRunsHint")),1)]),e("div",Da,[e("div",Ca,[G.runnerMaxConcurrentRuns?(l(),c("p",ka,a(i(s)("settingsDialog.system.managedByEnv")),1)):M.value?(l(),c("p",wa,a(M.value),1)):te.value?(l(),c("p",Sa,a(te.value),1)):(l(),c("p",Ta,a(i(s)("settingsDialog.system.diagnosticsHint")),1))]),e("div",Ra,[e("button",{type:"button",class:"tool-button tool-button-primary inline-flex items-center gap-2 px-3 py-2 text-xs",disabled:G.runnerMaxConcurrentRuns||ge.value||W.value,onClick:$t},[W.value?(l(),T(i(ue),{key:0,class:"h-4 w-4 animate-spin"})):v("",!0),e("span",null,a(W.value?i(s)("common.saving"):i(s)("settingsDialog.system.saveConfig")),1)],8,Pa)])])]),e("section",Ea,[e("div",Ma,[e("div",null,[e("div",Ba,a(i(s)("settingsDialog.system.runtimeDiagnostics")),1),e("p",Na,a(i(s)("settingsDialog.system.runtimeDiagnosticsHint")),1)]),e("div",$a,[e("button",{type:"button",class:"tool-button inline-flex items-center gap-2 px-3 py-2 text-xs",disabled:J.value,onClick:re},[J.value?(l(),T(i(ue),{key:0,class:"h-4 w-4 animate-spin"})):v("",!0),e("span",null,a(J.value?i(s)("settingsDialog.system.refreshingDiagnostics"):i(s)("settingsDialog.system.refreshDiagnostics")),1)],8,Ua),e("button",{type:"button",class:"tool-button inline-flex items-center gap-2 px-3 py-2 text-xs",onClick:Ot},[e("span",null,a(ye.value?i(s)("settingsDialog.system.diagnosticsCopied"):i(s)("settingsDialog.system.copyDiagnostics")),1)])])]),e("div",Ia,[ne.value?(l(),c("p",ja,a(ne.value),1)):ye.value?(l(),c("p",Fa,a(i(s)("settingsDialog.system.diagnosticsCopiedHint")),1)):(l(),c("p",La,a(i(s)("settingsDialog.system.diagnosticsHint")),1))]),oe.value?(l(),c("div",Oa,[e("div",Aa,[n[15]||(n[15]=e("div",{class:"theme-muted-text text-xs"},"active",-1)),e("div",Va,a(((de=q.value)==null?void 0:de.activeRunCount)||0),1),e("p",Ha,a(i(s)("settingsDialog.system.active")),1)]),e("div",qa,[n[16]||(n[16]=e("div",{class:"theme-muted-text text-xs"},"tracked",-1)),e("div",Ka,a(((Ie=q.value)==null?void 0:Ie.trackedRunCount)||0),1),e("p",Wa,a(i(s)("settingsDialog.system.tracked")),1)]),e("div",za,[n[17]||(n[17]=e("div",{class:"theme-muted-text text-xs"},"queued",-1)),e("div",Ja,a(((je=q.value)==null?void 0:je.queuedRunCount)||0),1),e("p",Ga,a(i(s)("settingsDialog.system.queued")),1)]),e("div",Ya,[n[18]||(n[18]=e("div",{class:"theme-muted-text text-xs"},"maxConcurrent",-1)),e("div",Qa,a(((Le=(Fe=q.value)==null?void 0:Fe.config)==null?void 0:Le.maxConcurrentRuns)||Y.runnerMaxConcurrentRuns),1),e("p",Xa,a(i(s)("settingsDialog.system.maxConcurrent")),1)])])):v("",!0),oe.value?(l(),c("div",Za,[e("div",ei,[n[19]||(n[19]=e("div",{class:"theme-muted-text text-xs"},"completed",-1)),e("div",ti,a(((Oe=p.value)==null?void 0:Oe.totalCompleted)||0),1),e("p",si,a(i(s)("settingsDialog.system.completed")),1)]),e("div",ni,[n[20]||(n[20]=e("div",{class:"theme-muted-text text-xs"},"stopped",-1)),e("div",ai,a(((Ae=p.value)==null?void 0:Ae.totalStopped)||0),1),e("p",ii,a(i(s)("settingsDialog.system.stopped")),1)]),e("div",oi,[n[21]||(n[21]=e("div",{class:"theme-muted-text text-xs"},"error",-1)),e("div",li,a(((Ve=p.value)==null?void 0:Ve.totalErrored)||0),1),e("p",ri,a(i(s)("settingsDialog.system.error")),1)]),e("div",ci,[n[22]||(n[22]=e("div",{class:"theme-muted-text text-xs"},"stop_timeout",-1)),e("div",di,a(((He=p.value)==null?void 0:He.totalStopTimeout)||0),1),e("p",ui,a(i(s)("settingsDialog.system.stopTimeout")),1)])])):v("",!0),oe.value?(l(),c("div",mi,[e("div",gi,[n[23]||(n[23]=e("div",{class:"theme-muted-text text-xs"},"event flush failures",-1)),e("div",hi,a(((qe=p.value)==null?void 0:qe.eventFlushFailureCount)||0),1),e("p",vi,a(i(s)("settingsDialog.system.eventWriteFailures")),1)]),e("div",xi,[n[24]||(n[24]=e("div",{class:"theme-muted-text text-xs"},"recovered runs",-1)),e("div",yi,a(((We=(Ke=Me.value)==null?void 0:Ke.metrics)==null?void 0:We.totalRecovered)||0),1),e("p",pi,a(i(s)("settingsDialog.system.recoveredRuns")),1)]),e("div",_i,[n[25]||(n[25]=e("div",{class:"theme-muted-text text-xs"},"last cleanup",-1)),e("div",fi,a(le((Je=(ze=Be.value)==null?void 0:ze.lastCleanup)==null?void 0:Je.finishedAt)),1),e("p",bi,a(i(s)("settingsDialog.system.lastMaintenanceAt")),1)])])):v("",!0),e("div",Di,[e("div",Ci,[e("div",ki,a(i(s)("settingsDialog.system.baseStatus")),1),e("div",wi,[e("div",Si,[n[26]||(n[26]=e("span",{class:"theme-muted-text"},"runner baseUrl",-1)),e("span",Ti,a(((Ye=(Ge=w.value)==null?void 0:Ge.runner)==null?void 0:Ye.baseUrl)||"-"),1)]),e("div",Ri,[n[27]||(n[27]=e("span",{class:"theme-muted-text"},"runner startedAt",-1)),e("span",Pi,a(le((Qe=q.value)==null?void 0:Qe.startedAt)),1)]),e("div",Ei,[n[28]||(n[28]=e("span",{class:"theme-muted-text"},"last sweep",-1)),e("span",Mi,a(le((Ze=(Xe=Me.value)==null?void 0:Xe.metrics)==null?void 0:Ze.lastSweepFinishedAt)),1)]),e("div",Bi,[n[29]||(n[29]=e("span",{class:"theme-muted-text"},"git diff worker",-1)),e("span",Ni,a(kt.value?i(s)("settingsDialog.system.available"):i(s)("settingsDialog.system.unknown")),1)]),e("div",$i,[n[30]||(n[30]=e("span",{class:"theme-muted-text"},"db vacuum",-1)),e("span",Ui,a(le((et=Be.value)==null?void 0:et.lastVacuumAt)),1)])])]),e("div",Ii,[e("div",ji,a(i(s)("settingsDialog.system.stopReasonTitle")),1),e("div",Fi,[(l(!0),c(j,null,F(St.value,r=>(l(),c("div",{key:r.key,class:"flex items-center justify-between gap-3"},[e("span",Li,a(r.label),1),e("span",Oi,a(r.value),1)]))),128))])])]),oe.value?(l(),c("div",Ai,[e("div",Vi,a(i(s)("settingsDialog.system.stopTimeoutPhaseTitle")),1),e("div",Hi,[(l(!0),c(j,null,F(Tt.value,r=>(l(),c("div",{key:r.key,class:"flex items-center justify-between gap-3 rounded-sm border border-dashed border-[var(--theme-borderMuted)] px-2.5 py-2"},[e("span",qi,a(r.label),1),e("span",Ki,a(r.value),1)]))),128))])])):v("",!0),!oe.value&&!J.value?(l(),c("div",Wi,[e("div",zi,a(i(s)("settingsDialog.system.runnerUnavailable")),1),e("p",Ji,a(xt((tt=w.value)==null?void 0:tt.runner,"settingsDialog.system.runnerUnavailableDescription")),1),e("p",Gi," baseUrl: "+a(((nt=(st=w.value)==null?void 0:st.runner)==null?void 0:nt.baseUrl)||"-"),1)])):v("",!0)])])):S.value==="shortcuts"?(l(),c("section",Yi,[e("div",null,[e("div",Qi,[K(i(Ce),{class:"h-4 w-4"}),e("span",null,a(i(s)("settingsDialog.shortcuts.title")),1)]),e("p",Xi,a(i(s)("settingsDialog.shortcuts.intro")),1)]),e("section",Zi,[(l(!0),c(j,null,F(bt.value,r=>(l(),c("div",{key:r.id,class:"settings-form-card flex flex-col justify-between gap-3 px-3 py-3 sm:flex-row sm:items-center"},[e("div",eo,[e("div",to,a(r.label),1),e("p",so,a(r.description),1)]),e("div",no,[e("span",ao,a(r.mac),1),e("span",io,a(r.windows),1)])]))),128)),e("p",oo,a(i(s)("settingsDialog.shortcuts.note")),1)])])):(l(),c("section",lo,[e("div",null,[e("div",ro,a(i(s)("settingsDialog.about.title")),1),e("p",co,a(i(s)("settingsDialog.about.intro")),1)]),e("section",uo,[e("div",mo,[e("div",null,[e("div",go,a(i(s)("settingsDialog.about.versionTitle")),1),e("p",ho,a(O.value||i(s)("settingsDialog.about.versionDescription")),1)]),e("span",vo,a(b.value?i(s)("common.loading"):y.value?`v${y.value}`:i(s)("common.unavailable")),1)])])]))])]}),_:1},8,["open"]))}};export{Co as default};
1
+ import{aD as l,aE as c,aF as e,aQ as a,u as i,aR as j,aS as F,aL as I,aV as Ht,aI as T,aN as v,c as x,w as at,ak as qt,aJ as it,aG as K,aW as U,b3 as Kt,aY as ot,aX as fe,b4 as Wt,b as m,r as be}from"./vendor-misc-DqxAnmp9.js";import{k as Q,m as zt,j as Jt,n as Gt}from"./WorkbenchView-ih1G4f79.js";import{u as mt,b as Yt,W as De,c as Qt,f as Xt,d as lt}from"./index-4LeM_JQe.js";import{b as gt,K as Ce,L as ue,J as rt,E as Zt,g as es,N as ct,u as ts,O as ss,y as ns}from"./vendor-ui-CnLXY_Zv.js";import"./vendor-markdown-C2aIjAg9.js";import"./vendor-tiptap-DLVi2vZE.js";import"./vendor-router-4TN1NQvz.js";function as(){return Q("/api/relay/config",{cache:"no-store"})}function dt(O){return Q("/api/relay/config",{method:"PUT",body:JSON.stringify(O)})}function is(){return Q("/api/relay/reconnect",{method:"POST"})}function os(){return Q("/api/system/config",{cache:"no-store"})}function ut(O){return Q("/api/system/config",{method:"PUT",body:JSON.stringify(O)})}function ls(){return Q("/api/diagnostics/runtime",{cache:"no-store"})}const rs={class:"space-y-4"},cs={class:"flex items-center justify-between gap-3"},ds={class:"theme-heading text-sm font-medium"},us={class:"theme-toggle-current theme-badge-muted theme-muted-text rounded-sm border border-dashed px-2 py-1 text-[11px]"},ms={class:"theme-muted-text theme-note-text mt-1"},gs={class:"space-y-4"},hs={class:"theme-muted-text px-1 text-[10px] font-medium uppercase tracking-[0.16em]"},vs=["onClick"],xs={class:"flex items-start gap-3"},ys={class:"mt-0.5 flex items-center gap-1.5"},ps={class:"min-w-0 flex-1"},_s={class:"flex items-center justify-between gap-2"},fs={class:"truncate text-sm font-medium"},bs={class:"theme-muted-text theme-note-text mt-1"},Ds={__name:"ThemeToggle",setup(O){const{currentTheme:X,setTheme:Z,themes:me}=Yt(),{t:R}=mt(),ke=x(()=>{const C=me.value.filter(y=>y.mode==="light"),ee=me.value.filter(y=>y.mode==="dark");return[{id:"light",label:R("theme.groupLight"),items:C},{id:"dark",label:R("theme.groupDark"),items:ee}].filter(y=>y.items.length)});function we(C){Z(C)}function s(C){return R(`theme.description.${C.id}`,{},C.description)}return(C,ee)=>(l(),c("div",rs,[e("div",null,[e("div",cs,[e("div",ds,a(i(R)("theme.heading")),1),e("div",us,a(i(R)("theme.currentTheme",{name:i(X).shortName})),1)]),e("div",ms,a(i(R)("theme.helper")),1)]),e("div",gs,[(l(!0),c(j,null,F(ke.value,y=>(l(),c("section",{key:y.id,class:"space-y-1.5"},[e("div",hs,a(y.label),1),(l(!0),c(j,null,F(y.items,b=>(l(),c("button",{key:b.id,type:"button",class:I(["theme-option theme-toggle-card w-full rounded-sm border px-3 py-2 text-left transition",b.id===i(X).id?"theme-option-active":"theme-option-idle"]),onClick:L=>we(b.id)},[e("div",xs,[e("div",ys,[(l(!0),c(j,null,F(b.swatches,(L,P)=>(l(),c("span",{key:`${b.id}-${P}`,class:"h-3 w-3 rounded-full border border-black/10",style:Ht({backgroundColor:L})},null,4))),128))]),e("div",ps,[e("div",_s,[e("span",fs,a(b.shortName),1),b.id===i(X).id?(l(),T(i(gt),{key:0,class:"h-4 w-4 shrink-0"})):v("",!0)]),e("div",bs,a(s(b)),1)])])],10,vs))),128))]))),128))])]))}},Cs={class:"theme-heading inline-flex items-center gap-2 text-sm font-medium"},ks={class:"settings-dialog-content min-h-0 flex-1 overflow-y-auto px-5 py-5"},ws={key:0,class:"space-y-4"},Ss={class:"theme-heading inline-flex items-center gap-2 text-base font-medium"},Ts={class:"settings-section-card space-y-4 px-4 py-4"},Rs={class:"theme-heading text-sm font-medium"},Ps={class:"theme-muted-text mt-1 text-xs leading-5"},Es={class:"grid gap-3"},Ms={class:"min-w-0"},Bs={class:"text-sm font-medium text-[var(--theme-textPrimary)]"},Ns={class:"theme-muted-text mt-1 text-xs leading-5"},$s=["value","onChange"],Us={class:"settings-section-card space-y-4 px-4 py-4"},Is={class:"theme-heading text-sm font-medium"},js={class:"theme-muted-text mt-1 text-xs leading-5"},Fs={class:"settings-form-card flex items-center justify-between gap-3 px-3 py-3"},Os={class:"min-w-0"},Ls={class:"text-sm font-medium text-[var(--theme-textPrimary)]"},As={class:"theme-muted-text mt-1 text-xs leading-5"},Vs={class:"settings-section-card space-y-4 px-4 py-4"},Hs={class:"theme-heading text-sm font-medium"},qs={class:"theme-muted-text mt-1 text-xs leading-5"},Ks={class:"space-y-1.5"},Ws={class:"theme-muted-text text-xs"},zs={class:"space-y-2"},Js={class:"min-w-0"},Gs={class:"truncate text-sm font-medium text-[var(--theme-textPrimary)]"},Ys={class:"theme-muted-text mt-1 truncate text-xs"},Qs=["checked","value","onChange"],Xs={class:"theme-muted-text theme-note-text"},Zs={class:"settings-section-card space-y-4 px-4 py-4"},en={class:"theme-heading text-sm font-medium"},tn={class:"theme-muted-text mt-1 text-xs leading-5"},sn={class:"space-y-1.5"},nn={class:"theme-muted-text text-xs"},an={class:"space-y-2"},on={class:"min-w-0"},ln={class:"text-sm font-medium text-[var(--theme-textPrimary)]"},rn={class:"theme-muted-text mt-1 text-xs leading-5"},cn=["checked"],dn={class:"min-w-0"},un={class:"text-sm font-medium text-[var(--theme-textPrimary)]"},mn={class:"theme-muted-text mt-1 text-xs leading-5"},gn=["checked"],hn={class:"min-w-0"},vn={class:"text-sm font-medium text-[var(--theme-textPrimary)]"},xn={class:"theme-muted-text mt-1 text-xs leading-5"},yn=["checked"],pn={key:0,class:"space-y-1.5"},_n={class:"theme-muted-text text-xs"},fn=["placeholder"],bn={key:0,class:"theme-muted-text text-xs leading-5"},Dn={class:"theme-muted-text text-xs leading-5"},Cn={class:"settings-form-card px-3 py-3"},kn={class:"text-xs leading-5 text-[var(--theme-warningText)]"},wn={class:"settings-form-footer flex flex-wrap items-center justify-end gap-3"},Sn={class:"flex flex-wrap items-center gap-2"},Tn=["disabled"],Rn={key:1,class:"space-y-4"},Pn={class:"theme-heading text-base font-medium"},En={class:"theme-muted-text mt-1 text-xs leading-5"},Mn={class:"settings-section-card px-4 py-4"},Bn={key:2,class:"space-y-4"},Nn={class:"flex items-start justify-between gap-3"},$n={class:"theme-heading inline-flex items-center gap-2 text-base font-medium"},Un={class:"settings-section-card space-y-4 px-4 py-4"},In={class:"settings-form-card flex items-center justify-between gap-3 px-3 py-2"},jn={class:"text-sm font-medium text-[var(--theme-textPrimary)]"},Fn={class:"theme-muted-text mt-1 text-xs"},On=["disabled"],Ln={class:"grid gap-4 sm:grid-cols-2"},An={class:"space-y-1.5 sm:col-span-2"},Vn={class:"theme-muted-text text-xs"},Hn=["disabled"],qn={class:"space-y-1.5"},Kn={class:"theme-muted-text text-xs"},Wn=["disabled"],zn={class:"space-y-1.5"},Jn={class:"theme-muted-text text-xs"},Gn={class:"relative"},Yn=["type","placeholder","disabled"],Qn=["disabled"],Xn={class:"settings-form-footer flex flex-wrap items-center justify-between gap-3"},Zn={class:"min-w-0 space-y-1"},ea={key:0,class:"theme-danger-text theme-note-text"},ta={key:1,class:"theme-status-warning theme-note-text"},sa={key:2,class:"theme-danger-text theme-note-text"},na={key:3,class:"theme-status-success theme-note-text"},aa={key:4,class:"theme-danger-text theme-note-text"},ia={key:5,class:"theme-muted-text theme-note-text"},oa={key:6,class:"theme-muted-text theme-note-text"},la={key:7,class:"theme-muted-text theme-note-text"},ra={key:8,class:"theme-status-success theme-note-text"},ca={key:9,class:"theme-muted-text theme-note-text"},da={class:"flex flex-wrap items-center gap-2"},ua=["disabled"],ma=["disabled"],ga=["disabled"],ha={key:3,class:"space-y-4"},va={class:"theme-heading inline-flex items-center gap-2 text-base font-medium"},xa={class:"theme-muted-text mt-1 text-xs leading-5"},ya={class:"settings-section-card space-y-4 px-4 py-4"},pa={class:"space-y-1.5"},_a={class:"theme-muted-text text-xs"},fa=["disabled"],ba={class:"theme-muted-text text-xs leading-5"},Da={class:"settings-form-footer flex flex-wrap items-center justify-between gap-3"},Ca={class:"min-w-0 space-y-1"},ka={key:0,class:"theme-status-warning theme-note-text"},wa={key:1,class:"theme-danger-text theme-note-text"},Sa={key:2,class:"theme-status-success theme-note-text"},Ta={key:3,class:"theme-muted-text theme-note-text"},Ra={class:"flex flex-wrap items-center gap-2"},Pa=["disabled"],Ea={class:"settings-section-card space-y-4 px-4 py-4"},Ma={class:"flex flex-wrap items-start justify-between gap-3"},Ba={class:"theme-heading text-sm font-medium"},Na={class:"theme-muted-text mt-1 text-xs leading-5"},$a={class:"flex flex-wrap items-center gap-2"},Ua=["disabled"],Ia={class:"min-w-0 space-y-1"},ja={key:0,class:"theme-danger-text theme-note-text"},Fa={key:1,class:"theme-status-success theme-note-text"},Oa={key:2,class:"theme-muted-text theme-note-text"},La={key:0,class:"grid gap-3 sm:grid-cols-2 xl:grid-cols-4"},Aa={class:"settings-form-card space-y-1 px-3 py-3"},Va={class:"theme-heading text-lg font-medium"},Ha={class:"theme-muted-text text-xs"},qa={class:"settings-form-card space-y-1 px-3 py-3"},Ka={class:"theme-heading text-lg font-medium"},Wa={class:"theme-muted-text text-xs"},za={class:"settings-form-card space-y-1 px-3 py-3"},Ja={class:"theme-heading text-lg font-medium"},Ga={class:"theme-muted-text text-xs"},Ya={class:"settings-form-card space-y-1 px-3 py-3"},Qa={class:"theme-heading text-lg font-medium"},Xa={class:"theme-muted-text text-xs"},Za={key:1,class:"grid gap-3 sm:grid-cols-2 xl:grid-cols-4"},ei={class:"settings-form-card space-y-1 px-3 py-3"},ti={class:"theme-heading text-lg font-medium"},si={class:"theme-muted-text text-xs"},ni={class:"settings-form-card space-y-1 px-3 py-3"},ai={class:"theme-heading text-lg font-medium"},ii={class:"theme-muted-text text-xs"},oi={class:"settings-form-card space-y-1 px-3 py-3"},li={class:"theme-heading text-lg font-medium"},ri={class:"theme-muted-text text-xs"},ci={class:"settings-form-card space-y-1 px-3 py-3"},di={class:"theme-heading text-lg font-medium"},ui={class:"theme-muted-text text-xs"},mi={key:2,class:"grid gap-3 sm:grid-cols-2 xl:grid-cols-3"},gi={class:"settings-form-card space-y-1 px-3 py-3"},hi={class:"theme-heading text-lg font-medium"},vi={class:"theme-muted-text text-xs"},xi={class:"settings-form-card space-y-1 px-3 py-3"},yi={class:"theme-heading text-lg font-medium"},pi={class:"theme-muted-text text-xs"},_i={class:"settings-form-card space-y-1 px-3 py-3"},fi={class:"theme-heading text-sm font-medium"},bi={class:"theme-muted-text text-xs"},Di={class:"grid gap-4 lg:grid-cols-2"},Ci={class:"settings-form-card space-y-3 px-3 py-3"},ki={class:"theme-heading text-sm font-medium"},wi={class:"space-y-2 text-xs"},Si={class:"flex items-center justify-between gap-3"},Ti={class:"truncate text-right text-[var(--theme-textPrimary)]"},Ri={class:"flex items-center justify-between gap-3"},Pi={class:"text-right text-[var(--theme-textPrimary)]"},Ei={class:"flex items-center justify-between gap-3"},Mi={class:"text-right text-[var(--theme-textPrimary)]"},Bi={class:"flex items-center justify-between gap-3"},Ni={class:"text-right text-[var(--theme-textPrimary)]"},$i={class:"flex items-center justify-between gap-3"},Ui={class:"text-right text-[var(--theme-textPrimary)]"},Ii={class:"settings-form-card space-y-3 px-3 py-3"},ji={class:"theme-heading text-sm font-medium"},Fi={class:"space-y-2 text-xs"},Oi={class:"theme-muted-text"},Li={class:"text-[var(--theme-textPrimary)]"},Ai={key:3,class:"settings-form-card space-y-3 px-3 py-3"},Vi={class:"theme-heading text-sm font-medium"},Hi={class:"grid gap-2 sm:grid-cols-2 xl:grid-cols-3 text-xs"},qi={class:"theme-muted-text"},Ki={class:"text-[var(--theme-textPrimary)]"},Wi={key:4,class:"settings-form-card space-y-2 px-3 py-3"},zi={class:"theme-heading text-sm font-medium"},Ji={class:"theme-muted-text text-xs leading-5"},Gi={class:"theme-muted-text text-xs leading-5"},Yi={key:4,class:"space-y-4"},Qi={class:"theme-heading inline-flex items-center gap-2 text-base font-medium"},Xi={class:"theme-muted-text mt-1 text-xs leading-5"},Zi={class:"settings-section-card space-y-3 px-4 py-4"},eo={class:"min-w-0"},to={class:"text-sm font-medium text-[var(--theme-textPrimary)]"},so={class:"theme-muted-text mt-1 text-xs leading-5"},no={class:"flex flex-wrap items-center gap-2"},ao={class:"rounded-sm border border-dashed border-[var(--theme-borderDefault)] px-2.5 py-1 text-xs font-medium text-[var(--theme-textPrimary)]"},io={class:"rounded-sm border border-dashed border-[var(--theme-borderDefault)] px-2.5 py-1 text-xs font-medium text-[var(--theme-textPrimary)]"},oo={class:"theme-muted-text theme-note-text"},lo={key:5,class:"space-y-4"},ro={class:"theme-heading text-base font-medium"},co={class:"theme-muted-text mt-1 text-xs leading-5"},uo={class:"settings-section-card px-4 py-4"},mo={class:"flex items-center justify-between gap-3"},go={class:"theme-heading text-sm font-medium"},ho={class:"theme-muted-text mt-1 text-xs leading-5"},vo={class:"theme-badge-strong rounded-sm border border-dashed px-2.5 py-1 text-xs font-medium"},Co={__name:"WorkbenchSettingsDialog",props:{open:{type:Boolean,default:!1}},emits:["close"],setup(O,{emit:X}){const Z=O,me=X,{locale:R,localeOptions:ke,setLocale:we,t:s}=mt(),{getPreference:C,setPreference:ee}=Qt(),y=m(""),b=m(!1),L=m(""),P=m(!1),A=m(!1),E=m(!1),_=m(""),k=m(""),ge=m(!1),W=m(!1),M=m(""),te=m(""),se=m(!1),z=m(!1),he=m(!1),J=m(!1),ne=m(""),w=m(null),u=m(null),f=m(!1),G=be({runnerMaxConcurrentRuns:!1}),ae=m(!1),ve=m(!1),xe=m(!1),ye=m(!1),d=be({enabled:!1,relayUrl:"",deviceId:"",deviceToken:""}),Y=be({runnerMaxConcurrentRuns:3}),h=be({sendBehavior:"",notificationSoundEnabled:!1,remoteCommandSecurityMode:"disabled",trustedProxyToken:""}),S=m("general");let V=null,H=null,pe=null,ie=null;const ht=x(()=>[{id:"general",label:s("settingsDialog.general.sectionLabel"),description:s("settingsDialog.general.sectionDescription"),icon:Ce},{id:"theme",label:s("theme.title"),description:s("theme.sectionDescription"),icon:ss},{id:"relay",label:s("settingsDialog.relay.sectionLabel"),description:s("settingsDialog.relay.sectionDescription"),icon:rt},{id:"system",label:s("settingsDialog.system.sectionLabel"),description:s("settingsDialog.system.sectionDescription"),icon:ct},{id:"shortcuts",label:s("settingsDialog.shortcuts.sectionLabel"),description:s("settingsDialog.shortcuts.sectionDescription"),icon:Ce},{id:"about",label:s("settingsDialog.about.sectionLabel"),description:s("settingsDialog.about.sectionDescription"),icon:ns}]),vt=x(()=>lt.map(t=>({value:t.value,label:s(t.labelKey),description:s(t.descriptionKey)})));function xt(t=null,n=""){const o=String((t==null?void 0:t.messageKey)||"").trim();if(o){const g=s(o);if(g&&g!==o)return g}return String((t==null?void 0:t.message)||"").trim()||(n?s(n):"")}function _e(t="",n=""){const o=String(t||"").trim();if(o){const g=`settingsDialog.relay.reason.${o}`,D=s(g);if(D!==g)return D}return String(n||"").trim()||s("common.notAvailable")}function yt(t=null){const n=String((t==null?void 0:t.type)||"").trim()||"unknown",o=`settingsDialog.relay.event.${n}`,g=s(o);return g!==o?g:n}function pt(t=null){const n=String((t==null?void 0:t.lastErrorKey)||"").trim(),o=t!=null&&t.lastErrorParams&&typeof t.lastErrorParams=="object"?t.lastErrorParams:{};return n==="connect_failed"?s("settingsDialog.relay.error.connect_failed"):n==="disconnected"?s("settingsDialog.relay.error.disconnected",{reason:_e(o.reasonCode,t==null?void 0:t.lastCloseReason)}):n==="rejected"?s("settingsDialog.relay.error.rejected",{reason:_e(o.reasonCode,t==null?void 0:t.lastCloseReason)}):n==="closed_with_code"?s("settingsDialog.relay.error.closedWithCode",{code:o.code||(t==null?void 0:t.lastCloseCode)||0}):String((t==null?void 0:t.lastError)||"").trim()}const _t=x(()=>{var t,n,o,g;return E.value?s("settingsDialog.relay.status.reconnecting"):A.value||ae.value?s("settingsDialog.relay.status.saving"):P.value?s("settingsDialog.relay.status.loading"):(t=u.value)!=null&&t.reconnectPaused?s("settingsDialog.relay.status.paused"):(n=u.value)!=null&&n.connected?s("settingsDialog.relay.status.connected"):(((o=u.value)==null?void 0:o.enabled)??d.enabled)&&Number(((g=u.value)==null?void 0:g.nextReconnectDelayMs)||0)>0?s("settingsDialog.relay.status.waitingReconnect"):d.enabled?s("settingsDialog.relay.status.disconnected"):s("settingsDialog.relay.status.disabled")}),ft=x(()=>{var t,n;return(t=u.value)!=null&&t.reconnectPaused?"theme-status-danger":(n=u.value)!=null&&n.connected?"theme-status-success":d.enabled?"theme-status-warning":"theme-status-neutral"}),bt=x(()=>[{id:"open-settings",label:s("settingsDialog.shortcuts.openSettingsTitle"),description:s("settingsDialog.shortcuts.openSettingsDescription"),mac:"⌘ ⇧ ,",windows:"Ctrl + Shift + ,"},{id:"open-project-manager",label:s("settingsDialog.shortcuts.openProjectManagerTitle"),description:s("settingsDialog.shortcuts.openProjectManagerDescription"),mac:"⌘ ⇧ K",windows:"Ctrl + Shift + K"},{id:"open-source-browser",label:s("settingsDialog.shortcuts.openSourceBrowserTitle"),description:s("settingsDialog.shortcuts.openSourceBrowserDescription"),mac:"⌘ ⇧ O",windows:"Ctrl + Shift + O"},{id:"open-diff-review",label:s("settingsDialog.shortcuts.openDiffReviewTitle"),description:s("settingsDialog.shortcuts.openDiffReviewDescription"),mac:"⌘ ⇧ D",windows:"Ctrl + Shift + D"},{id:"close-top-dialog",label:s("settingsDialog.shortcuts.closeTopDialogTitle"),description:s("settingsDialog.shortcuts.closeTopDialogDescription"),mac:"Esc",windows:"Esc"}]),Dt=x(()=>{var t,n,o;return!f.value&&!_.value&&!k.value&&!((t=u.value)!=null&&t.lastError)&&!((n=u.value)!=null&&n.lastCloseReason)&&!((o=u.value)!=null&&o.lastConnectedAt)}),Ct=x(()=>{const t=d.deviceToken?`${"*".repeat(Math.max(0,d.deviceToken.length-4))}${d.deviceToken.slice(-4)}`:"";return JSON.stringify({generatedAt:new Date().toISOString(),source:"local-settings",config:{enabled:d.enabled,relayUrl:d.relayUrl,deviceId:d.deviceId,deviceTokenMasked:t,managedByEnv:f.value},status:u.value||null},null,2)}),q=x(()=>{var t,n;return((n=(t=w.value)==null?void 0:t.runner)==null?void 0:n.runner)||null}),oe=x(()=>{var t,n;return!!((n=(t=w.value)==null?void 0:t.runner)!=null&&n.ok&&q.value)}),p=x(()=>{var t;return((t=q.value)==null?void 0:t.metrics)||null}),Me=x(()=>{var t;return((t=w.value)==null?void 0:t.recovery)||null}),Be=x(()=>{var t;return((t=w.value)==null?void 0:t.maintenance)||null}),kt=x(()=>{var t;return((t=w.value)==null?void 0:t.gitDiffWorker)||null}),wt=x(()=>JSON.stringify({generatedAt:new Date().toISOString(),source:"local-settings",config:{runner:{maxConcurrentRuns:Y.runnerMaxConcurrentRuns,managedByEnv:G.runnerMaxConcurrentRuns}},diagnostics:w.value||null},null,2));function le(t){const n=String(t||"").trim();if(!n)return s("common.notAvailable");const o=new Date(n);return Number.isNaN(o.getTime())?n:Xt(o.toISOString(),{year:"numeric",month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"})}const St=x(()=>{var t,n,o,g,D,B,N,$;return[{key:"queued_cancelled",label:s("settingsDialog.system.stopReasons.queued_cancelled"),value:Math.max(0,Number((n=(t=p.value)==null?void 0:t.stopReasons)==null?void 0:n.queued_cancelled)||0)},{key:"user_requested",label:s("settingsDialog.system.stopReasons.user_requested"),value:Math.max(0,Number((g=(o=p.value)==null?void 0:o.stopReasons)==null?void 0:g.user_requested)||0)},{key:"user_requested_after_error",label:s("settingsDialog.system.stopReasons.user_requested_after_error"),value:Math.max(0,Number((B=(D=p.value)==null?void 0:D.stopReasons)==null?void 0:B.user_requested_after_error)||0)},{key:"stop_timeout",label:s("settingsDialog.system.stopReasons.stop_timeout"),value:Math.max(0,Number(($=(N=p.value)==null?void 0:N.stopReasons)==null?void 0:$.stop_timeout)||0)}]}),Tt=x(()=>{var t,n,o,g,D,B,N,$,ce,de;return[{key:"runner_timeout_without_stop_request",label:s("settingsDialog.system.stopTimeoutPhases.runner_timeout_without_stop_request"),value:Math.max(0,Number((n=(t=p.value)==null?void 0:t.stopTimeoutPhases)==null?void 0:n.runner_timeout_without_stop_request)||0)},{key:"runner_timeout_before_cancel",label:s("settingsDialog.system.stopTimeoutPhases.runner_timeout_before_cancel"),value:Math.max(0,Number((g=(o=p.value)==null?void 0:o.stopTimeoutPhases)==null?void 0:g.runner_timeout_before_cancel)||0)},{key:"cli_not_exiting",label:s("settingsDialog.system.stopTimeoutPhases.cli_not_exiting"),value:Math.max(0,Number((B=(D=p.value)==null?void 0:D.stopTimeoutPhases)==null?void 0:B.cli_not_exiting)||0)},{key:"os_kill_slow",label:s("settingsDialog.system.stopTimeoutPhases.os_kill_slow"),value:Math.max(0,Number(($=(N=p.value)==null?void 0:N.stopTimeoutPhases)==null?void 0:$.os_kill_slow)||0)},{key:"runner_finalize_after_exit",label:s("settingsDialog.system.stopTimeoutPhases.runner_finalize_after_exit"),value:Math.max(0,Number((de=(ce=p.value)==null?void 0:ce.stopTimeoutPhases)==null?void 0:de.runner_finalize_after_exit)||0)}]}),Rt=x(()=>ke.value.map(t=>({value:t.value,label:t.value==="zh-CN"?s("locale.zhHans"):s("locale.enUs"),englishLabel:t.englishLabel})));async function Pt(){b.value=!0,L.value="";try{const t=await Gt(),n=String((t==null?void 0:t.version)||"").trim();y.value=n,n||(L.value=s("settingsDialog.about.versionPending"))}catch(t){y.value="",L.value=(t==null?void 0:t.message)||s("settingsDialog.about.versionLoadFailed")}finally{b.value=!1}}function Se(t={}){d.enabled=!!(t!=null&&t.enabled),d.relayUrl=String((t==null?void 0:t.relayUrl)||""),d.deviceId=String((t==null?void 0:t.deviceId)||""),d.deviceToken=String((t==null?void 0:t.deviceToken)||"")}function Te(t={}){var n,o,g;Y.runnerMaxConcurrentRuns=Math.max(1,Number((n=t==null?void 0:t.runner)==null?void 0:n.maxConcurrentRuns)||3),h.remoteCommandSecurityMode=String(((o=t==null?void 0:t.remoteCommandSecurity)==null?void 0:o.mode)||"disabled").trim()||"disabled",h.trustedProxyToken="",he.value=!!((g=t==null?void 0:t.remoteCommandSecurity)!=null&&g.trustedProxyTokenConfigured)}function Et(){var t;h.sendBehavior=String(C(De.SEND_BEHAVIOR)||((t=lt[1])==null?void 0:t.value)||""),h.notificationSoundEnabled=!!C(De.NOTIFICATION_SOUND_ENABLED)}async function Ne(){P.value=!0,_.value="",k.value="";try{const t=await as();Se((t==null?void 0:t.config)||{}),f.value=!!(t!=null&&t.managedByEnv),u.value=(t==null?void 0:t.relay)||null}catch(t){_.value=(t==null?void 0:t.message)||s("settingsDialog.relay.relayConfigLoadFailed"),u.value=null}finally{P.value=!1}}async function Mt(){var t,n;ge.value=!0,M.value="",te.value="";try{const o=await os();Te((o==null?void 0:o.config)||{}),G.runnerMaxConcurrentRuns=!!((n=(t=o==null?void 0:o.managedByEnv)==null?void 0:t.runner)!=null&&n.maxConcurrentRuns),re()}catch(o){M.value=(o==null?void 0:o.message)||s("settingsDialog.system.systemConfigLoadFailed")}finally{ge.value=!1}}async function re(){J.value=!0,ne.value="";try{w.value=await ls()}catch(t){ne.value=(t==null?void 0:t.message)||s("settingsDialog.system.systemDiagnosticsLoadFailed")}finally{J.value=!1}}async function Bt(){A.value=!0,_.value="",k.value="";try{const t=await dt({enabled:d.enabled,relayUrl:d.relayUrl,deviceId:d.deviceId,deviceToken:d.deviceToken});Se((t==null?void 0:t.config)||{}),f.value=!!(t!=null&&t.managedByEnv),u.value=(t==null?void 0:t.relay)||null,k.value=d.enabled?s("settingsDialog.relay.relayConfigSavedEnabled"):s("settingsDialog.relay.relayConfigSavedDisabled")}catch(t){_.value=(t==null?void 0:t.message)||s("settingsDialog.relay.relayConfigSaveFailed")}finally{A.value=!1}}async function Nt(){E.value=!0,_.value="",k.value="";try{const t=await is();u.value=(t==null?void 0:t.relay)||null,k.value=s("settingsDialog.relay.relayReconnectTriggered"),setTimeout(()=>{Ne()},1200)}catch(t){_.value=(t==null?void 0:t.message)||s("settingsDialog.relay.relayReconnectFailed")}finally{E.value=!1}}async function $t(){var t,n;W.value=!0,M.value="",te.value="";try{const o=await ut({runner:{maxConcurrentRuns:Y.runnerMaxConcurrentRuns}});Te((o==null?void 0:o.config)||{}),G.runnerMaxConcurrentRuns=!!((n=(t=o==null?void 0:o.managedByEnv)==null?void 0:t.runner)!=null&&n.maxConcurrentRuns),te.value=s("settingsDialog.system.systemConfigSaved"),re()}catch(o){M.value=(o==null?void 0:o.message)||s("settingsDialog.system.systemConfigSaveFailed")}finally{W.value=!1}}function $e(){ie&&(clearTimeout(ie),ie=null),z.value=!1}async function Ut(){se.value=!0,M.value="";try{const t=await ut({remoteCommandSecurity:It()});Te((t==null?void 0:t.config)||{}),$e(),z.value=!0,ie=setTimeout(()=>{z.value=!1,ie=null},1200)}catch(t){M.value=(t==null?void 0:t.message)||s("settingsDialog.system.systemConfigSaveFailed")}finally{se.value=!1}}function It(){const t={mode:h.remoteCommandSecurityMode},n=String(h.trustedProxyToken||"").trim();return h.remoteCommandSecurityMode==="trusted-proxy"&&n&&(t.trustedProxyToken=n),t}function Re(t){h.remoteCommandSecurityMode=t}function jt(){return!!(String(d.relayUrl||"").trim()&&String(d.deviceId||"").trim()&&String(d.deviceToken||"").trim())}async function Ft(){var t;if(!f.value){if(_.value="",k.value="",d.enabled&&!jt()){d.enabled=!1,_.value=s("settingsDialog.relay.relayFieldsRequired");return}ae.value=!0;try{const n=await dt({enabled:d.enabled,relayUrl:d.relayUrl,deviceId:d.deviceId,deviceToken:d.deviceToken});Se((n==null?void 0:n.config)||{}),f.value=!!(n!=null&&n.managedByEnv),u.value=(n==null?void 0:n.relay)||null,k.value=d.enabled?s("settingsDialog.relay.relayEnabledSaved"):s("settingsDialog.relay.relayConfigSavedDisabled")}catch(n){d.enabled=!!((t=u.value)!=null&&t.enabled),_.value=(n==null?void 0:n.message)||s("settingsDialog.relay.relayToggleFailed")}finally{ae.value=!1}}}async function Ue(t){var o;if((o=navigator.clipboard)!=null&&o.writeText&&window.isSecureContext){await navigator.clipboard.writeText(t);return}const n=document.createElement("textarea");n.value=t,n.setAttribute("readonly","true"),n.style.position="fixed",n.style.opacity="0",n.style.pointerEvents="none",document.body.appendChild(n),n.select(),document.execCommand("copy"),document.body.removeChild(n)}async function Ot(){try{await Ue(Ct.value),xe.value=!0,V&&clearTimeout(V),V=setTimeout(()=>{xe.value=!1,V=null},2e3)}catch(t){_.value=(t==null?void 0:t.message)||s("settingsDialog.relay.relayDiagnosticsCopyFailed")}}async function Lt(){try{await Ue(wt.value),ye.value=!0,H&&clearTimeout(H),H=setTimeout(()=>{ye.value=!1,H=null},2e3)}catch(t){ne.value=(t==null?void 0:t.message)||s("settingsDialog.system.systemDiagnosticsCopyFailed")}}function At(t){we(t)}function Pe(){pe&&(clearInterval(pe),pe=null)}function Vt(){Pe(),!(!Z.open||S.value!=="system")&&(re(),pe=setInterval(()=>{re()},5e3))}return at(()=>Z.open,t=>{if(t){S.value="general",Et(),Pt(),Ne(),Mt();return}},{immediate:!0}),at([()=>Z.open,S],([t,n])=>{if(t&&n==="system"){Vt();return}Pe()},{immediate:!0}),qt(()=>{V&&(clearTimeout(V),V=null),H&&(clearTimeout(H),H=null),$e(),Pe()}),(t,n)=>(l(),T(Jt,{open:O.open,"stack-level":2,"panel-class":"settings-dialog-panel h-[calc(100dvh-1rem)] max-w-5xl sm:h-[96vh] sm:max-h-[96vh]","header-class":"settings-dialog-header px-5 py-4","body-class":"settings-dialog-body min-h-0 flex flex-1 flex-col sm:flex-row",onClose:n[14]||(n[14]=o=>me("close"))},{title:it(()=>[e("div",Cs,[K(i(ts),{class:"h-4 w-4"}),e("span",null,a(i(s)("common.settings")),1)])]),default:it(()=>{var o,g,D,B,N,$,ce,de,Ie,je,Fe,Oe,Le,Ae,Ve,He,qe,Ke,We,ze,Je,Ge,Ye,Qe,Xe,Ze,et,tt,st,nt;return[K(zt,{modelValue:S.value,"onUpdate:modelValue":n[0]||(n[0]=r=>S.value=r),sections:ht.value},null,8,["modelValue","sections"]),e("div",ks,[S.value==="general"?(l(),c("section",ws,[e("div",null,[e("div",Ss,[K(i(Ce),{class:"h-4 w-4"}),e("span",null,a(i(s)("settingsDialog.general.title")),1)])]),e("section",Ts,[e("div",null,[e("div",Rs,a(i(s)("settingsDialog.general.sendBehavior.title")),1),e("p",Ps,a(i(s)("settingsDialog.general.sendBehavior.description")),1)]),e("div",Es,[(l(!0),c(j,null,F(vt.value,r=>(l(),c("label",{key:r.value,class:I(["settings-form-card flex cursor-pointer items-start justify-between gap-3 px-3 py-3",h.sendBehavior===r.value?"ring-1 ring-[var(--theme-accent)]":""])},[e("div",Ms,[e("div",Bs,a(r.label),1),e("p",Ns,a(r.description),1)]),U(e("input",{"onUpdate:modelValue":n[1]||(n[1]=Ee=>h.sendBehavior=Ee),value:r.value,type:"radio",name:"workbench-send-behavior",class:"mt-0.5 h-4 w-4 shrink-0",onChange:Ee=>i(ee)(i(De).SEND_BEHAVIOR,r.value)},null,40,$s),[[Kt,h.sendBehavior]])],2))),128))])]),e("section",Us,[e("div",null,[e("div",Is,a(i(s)("settingsDialog.general.notificationSound.title")),1),e("p",js,a(i(s)("settingsDialog.general.notificationSound.description")),1)]),e("label",Fs,[e("div",Os,[e("div",Ls,a(i(s)("settingsDialog.general.notificationSound.switchLabel")),1),e("p",As,a(i(s)("settingsDialog.general.notificationSound.switchHint")),1)]),U(e("input",{"onUpdate:modelValue":n[2]||(n[2]=r=>h.notificationSoundEnabled=r),type:"checkbox",class:"h-4 w-4 shrink-0",onChange:n[3]||(n[3]=r=>i(ee)(i(De).NOTIFICATION_SOUND_ENABLED,h.notificationSoundEnabled))},null,544),[[ot,h.notificationSoundEnabled]])])]),e("section",Vs,[e("div",null,[e("div",Hs,a(i(s)("locale.title")),1),e("p",qs,a(i(s)("locale.description")),1)]),e("div",Ks,[e("span",Ws,a(i(s)("locale.field")),1),e("div",zs,[(l(!0),c(j,null,F(Rt.value,r=>(l(),c("label",{key:r.value,class:I(["settings-form-card flex cursor-pointer items-center justify-between gap-3 px-3 py-3",i(R)===r.value?"ring-1 ring-[var(--theme-accent)]":""])},[e("div",Js,[e("div",Gs,a(r.label),1),e("div",Ys,a(r.englishLabel),1)]),e("input",{checked:i(R)===r.value,value:r.value,name:"promptx-locale",type:"radio",class:"h-4 w-4 shrink-0",onChange:Ee=>At(r.value)},null,40,Qs)],2))),128))])]),e("p",Xs,a(i(s)("locale.immediateHint")),1)]),e("section",Zs,[e("div",null,[e("div",en,a(i(s)("settingsDialog.general.remoteCommandSecurityTitle")),1),e("p",tn,a(i(s)("settingsDialog.general.remoteCommandSecurityDescription")),1)]),e("div",sn,[e("span",nn,a(i(s)("settingsDialog.general.remoteCommandSecurityModeField")),1),e("div",an,[e("label",{class:I(["settings-form-card flex cursor-pointer items-start justify-between gap-3 px-3 py-3",h.remoteCommandSecurityMode==="disabled"?"ring-1 ring-[var(--theme-primary)]":""])},[e("div",on,[e("div",ln,a(i(s)("settingsDialog.general.remoteCommandSecurityModeDisabled")),1),e("p",rn,a(i(s)("settingsDialog.general.remoteCommandSecurityModeDisabledDescription")),1)]),e("input",{checked:h.remoteCommandSecurityMode==="disabled",type:"checkbox",class:"mt-0.5 h-4 w-4 shrink-0",onChange:n[4]||(n[4]=r=>Re("disabled"))},null,40,cn)],2),e("label",{class:I(["settings-form-card flex cursor-pointer items-start justify-between gap-3 px-3 py-3",h.remoteCommandSecurityMode==="relay"?"ring-1 ring-[var(--theme-primary)]":""])},[e("div",dn,[e("div",un,a(i(s)("settingsDialog.general.remoteCommandSecurityModeRelay")),1),e("p",mn,a(i(s)("settingsDialog.general.remoteCommandSecurityModeRelayDescription")),1)]),e("input",{checked:h.remoteCommandSecurityMode==="relay",type:"checkbox",class:"mt-0.5 h-4 w-4 shrink-0",onChange:n[5]||(n[5]=r=>Re("relay"))},null,40,gn)],2),e("label",{class:I(["settings-form-card flex cursor-pointer items-start justify-between gap-3 px-3 py-3",h.remoteCommandSecurityMode==="trusted-proxy"?"ring-1 ring-[var(--theme-primary)]":""])},[e("div",hn,[e("div",vn,a(i(s)("settingsDialog.general.remoteCommandSecurityModeTrustedProxy")),1),e("p",xn,a(i(s)("settingsDialog.general.remoteCommandSecurityModeTrustedProxyDescription")),1)]),e("input",{checked:h.remoteCommandSecurityMode==="trusted-proxy",type:"checkbox",class:"mt-0.5 h-4 w-4 shrink-0",onChange:n[6]||(n[6]=r=>Re("trusted-proxy"))},null,40,yn)],2)])]),h.remoteCommandSecurityMode==="trusted-proxy"?(l(),c("label",pn,[e("span",_n,a(i(s)("settingsDialog.general.trustedProxyTokenField")),1),U(e("input",{"onUpdate:modelValue":n[7]||(n[7]=r=>h.trustedProxyToken=r),type:"password",class:"tool-input",placeholder:he.value?i(s)("settingsDialog.general.trustedProxyTokenReplacePlaceholder"):i(s)("settingsDialog.general.trustedProxyTokenPlaceholder")},null,8,fn),[[fe,h.trustedProxyToken]]),he.value?(l(),c("p",bn,a(i(s)("settingsDialog.general.trustedProxyTokenConfiguredHint")),1)):v("",!0),e("p",Dn,a(he.value?i(s)("settingsDialog.general.trustedProxyTokenReplaceHint"):i(s)("settingsDialog.general.trustedProxyTokenHint")),1)])):v("",!0),e("div",Cn,[e("p",kn,a(i(s)("settingsDialog.general.remoteCommandSecurityWarning")),1)]),e("div",wn,[e("div",Sn,[e("button",{type:"button",class:I(["tool-button inline-flex items-center gap-2 px-3 py-2 text-xs",z.value?"tool-button-accent-subtle":"tool-button-primary"]),disabled:se.value,onClick:Ut},[se.value?(l(),T(i(ue),{key:0,class:"h-4 w-4 animate-spin"})):z.value?(l(),T(i(gt),{key:1,class:"h-4 w-4"})):v("",!0),e("span",null,a(se.value?i(s)("common.saving"):z.value?i(s)("settingsDialog.general.remoteCommandSecuritySaved"):i(s)("settingsDialog.general.remoteCommandSecuritySave")),1)],10,Tn)])])])])):S.value==="theme"?(l(),c("section",Rn,[e("div",null,[e("div",Pn,a(i(s)("theme.title")),1),e("p",En,a(i(s)("theme.sectionDescription")),1)]),e("section",Mn,[K(Ds)])])):S.value==="relay"?(l(),c("section",Bn,[e("div",Nn,[e("div",null,[e("div",$n,[K(i(rt),{class:"h-4 w-4"}),e("span",null,a(i(s)("settingsDialog.relay.title")),1)])]),e("span",{class:I(["rounded-sm border border-dashed px-2.5 py-1 text-xs font-medium",ft.value])},a(_t.value),3)]),e("section",Un,[e("label",In,[e("div",null,[e("div",jn,a(i(s)("settingsDialog.relay.enableTitle")),1),e("p",Fn,a(i(s)("settingsDialog.relay.enableDescription")),1)]),U(e("input",{"onUpdate:modelValue":n[8]||(n[8]=r=>d.enabled=r),type:"checkbox",class:"h-4 w-4",disabled:f.value,onChange:Ft},null,40,On),[[ot,d.enabled]])]),e("div",Ln,[e("label",An,[e("span",Vn,a(i(s)("settingsDialog.relay.relayUrl")),1),U(e("input",{"onUpdate:modelValue":n[9]||(n[9]=r=>d.relayUrl=r),type:"text",placeholder:"https://user1.promptx.example.com",class:"tool-input",disabled:f.value},null,8,Hn),[[fe,d.relayUrl]])]),e("label",qn,[e("span",Kn,a(i(s)("settingsDialog.relay.deviceId")),1),U(e("input",{"onUpdate:modelValue":n[10]||(n[10]=r=>d.deviceId=r),type:"text",placeholder:"my-macbook",class:"tool-input",disabled:f.value},null,8,Wn),[[fe,d.deviceId]])]),e("label",zn,[e("span",Jn,a(i(s)("settingsDialog.relay.deviceToken")),1),e("div",Gn,[U(e("input",{"onUpdate:modelValue":n[11]||(n[11]=r=>d.deviceToken=r),type:ve.value?"text":"password",placeholder:i(s)("settingsDialog.relay.deviceTokenPlaceholder"),class:"tool-input pr-10",disabled:f.value},null,8,Yn),[[Wt,d.deviceToken]]),e("button",{type:"button",class:"theme-icon-button absolute inset-y-1 right-1 flex h-auto w-8 items-center justify-center",disabled:f.value,onClick:n[12]||(n[12]=r=>ve.value=!ve.value)},[ve.value?(l(),T(i(es),{key:1,class:"h-4 w-4"})):(l(),T(i(Zt),{key:0,class:"h-4 w-4"}))],8,Qn)])])]),e("div",Xn,[e("div",Zn,[(o=u.value)!=null&&o.reconnectPausedReason?(l(),c("p",ea,a(i(s)("settingsDialog.relay.pausedReconnect",{reason:_e(u.value.reconnectPausedReasonCode,u.value.reconnectPausedReason)})),1)):v("",!0),f.value?(l(),c("p",ta,a(i(s)("settingsDialog.relay.managedByEnv")),1)):v("",!0),_.value?(l(),c("p",sa,a(_.value),1)):k.value?(l(),c("p",na,a(k.value),1)):(g=u.value)!=null&&g.lastError?(l(),c("p",aa,a(i(s)("settingsDialog.relay.lastError",{value:pt(u.value)})),1)):(D=u.value)!=null&&D.lastCloseReason?(l(),c("p",ia,a(i(s)("settingsDialog.relay.lastClosed",{reason:_e(u.value.lastCloseReasonCode,u.value.lastCloseReason),code:u.value.lastCloseCode})),1)):(B=u.value)!=null&&B.lastConnectedAt?(l(),c("p",oa,a(i(s)("settingsDialog.relay.lastConnected",{value:le(u.value.lastConnectedAt)})),1)):v("",!0),($=(N=u.value)==null?void 0:N.recentEvents)!=null&&$.length?(l(),c("p",la,a(i(s)("settingsDialog.relay.recentEvent",{value:yt(u.value.recentEvents[0])})),1)):v("",!0),xe.value?(l(),c("p",ra,a(i(s)("settingsDialog.relay.copied")),1)):v("",!0),Dt.value?(l(),c("p",ca,a(i(s)("settingsDialog.relay.defaultHint")),1)):v("",!0)]),e("div",da,[e("button",{type:"button",class:"tool-button inline-flex items-center gap-2 px-3 py-2 text-xs",disabled:P.value||A.value||ae.value||E.value||!(((ce=u.value)==null?void 0:ce.enabled)??d.enabled),onClick:Nt},[E.value?(l(),T(i(ue),{key:0,class:"h-4 w-4 animate-spin"})):v("",!0),e("span",null,a(E.value?i(s)("settingsDialog.relay.reconnecting"):i(s)("settingsDialog.relay.reconnectNow")),1)],8,ua),e("button",{type:"button",class:"tool-button inline-flex items-center gap-2 px-3 py-2 text-xs",disabled:P.value||E.value,onClick:Ot},[e("span",null,a(xe.value?i(s)("settingsDialog.relay.diagnosticsCopied"):i(s)("settingsDialog.relay.copyDiagnostics")),1)],8,ma),e("button",{type:"button",class:"tool-button tool-button-primary inline-flex items-center gap-2 px-3 py-2 text-xs",disabled:P.value||A.value||ae.value||E.value||f.value,onClick:Bt},[A.value?(l(),T(i(ue),{key:0,class:"h-4 w-4 animate-spin"})):v("",!0),e("span",null,a(A.value?i(s)("common.saving"):i(s)("settingsDialog.relay.saveConfig")),1)],8,ga)])])])])):S.value==="system"?(l(),c("section",ha,[e("div",null,[e("div",va,[K(i(ct),{class:"h-4 w-4"}),e("span",null,a(i(s)("settingsDialog.system.title")),1)]),e("p",xa,a(i(s)("settingsDialog.system.intro")),1)]),e("section",ya,[e("label",pa,[e("span",_a,a(i(s)("settingsDialog.system.maxConcurrentRuns")),1),U(e("input",{"onUpdate:modelValue":n[13]||(n[13]=r=>Y.runnerMaxConcurrentRuns=r),type:"number",min:"1",max:"16",step:"1",class:"tool-input",disabled:G.runnerMaxConcurrentRuns||ge.value||W.value},null,8,fa),[[fe,Y.runnerMaxConcurrentRuns,void 0,{number:!0}]]),e("p",ba,a(i(s)("settingsDialog.system.maxConcurrentRunsHint")),1)]),e("div",Da,[e("div",Ca,[G.runnerMaxConcurrentRuns?(l(),c("p",ka,a(i(s)("settingsDialog.system.managedByEnv")),1)):M.value?(l(),c("p",wa,a(M.value),1)):te.value?(l(),c("p",Sa,a(te.value),1)):(l(),c("p",Ta,a(i(s)("settingsDialog.system.diagnosticsHint")),1))]),e("div",Ra,[e("button",{type:"button",class:"tool-button tool-button-primary inline-flex items-center gap-2 px-3 py-2 text-xs",disabled:G.runnerMaxConcurrentRuns||ge.value||W.value,onClick:$t},[W.value?(l(),T(i(ue),{key:0,class:"h-4 w-4 animate-spin"})):v("",!0),e("span",null,a(W.value?i(s)("common.saving"):i(s)("settingsDialog.system.saveConfig")),1)],8,Pa)])])]),e("section",Ea,[e("div",Ma,[e("div",null,[e("div",Ba,a(i(s)("settingsDialog.system.runtimeDiagnostics")),1),e("p",Na,a(i(s)("settingsDialog.system.runtimeDiagnosticsHint")),1)]),e("div",$a,[e("button",{type:"button",class:"tool-button inline-flex items-center gap-2 px-3 py-2 text-xs",disabled:J.value,onClick:re},[J.value?(l(),T(i(ue),{key:0,class:"h-4 w-4 animate-spin"})):v("",!0),e("span",null,a(J.value?i(s)("settingsDialog.system.refreshingDiagnostics"):i(s)("settingsDialog.system.refreshDiagnostics")),1)],8,Ua),e("button",{type:"button",class:"tool-button inline-flex items-center gap-2 px-3 py-2 text-xs",onClick:Lt},[e("span",null,a(ye.value?i(s)("settingsDialog.system.diagnosticsCopied"):i(s)("settingsDialog.system.copyDiagnostics")),1)])])]),e("div",Ia,[ne.value?(l(),c("p",ja,a(ne.value),1)):ye.value?(l(),c("p",Fa,a(i(s)("settingsDialog.system.diagnosticsCopiedHint")),1)):(l(),c("p",Oa,a(i(s)("settingsDialog.system.diagnosticsHint")),1))]),oe.value?(l(),c("div",La,[e("div",Aa,[n[15]||(n[15]=e("div",{class:"theme-muted-text text-xs"},"active",-1)),e("div",Va,a(((de=q.value)==null?void 0:de.activeRunCount)||0),1),e("p",Ha,a(i(s)("settingsDialog.system.active")),1)]),e("div",qa,[n[16]||(n[16]=e("div",{class:"theme-muted-text text-xs"},"tracked",-1)),e("div",Ka,a(((Ie=q.value)==null?void 0:Ie.trackedRunCount)||0),1),e("p",Wa,a(i(s)("settingsDialog.system.tracked")),1)]),e("div",za,[n[17]||(n[17]=e("div",{class:"theme-muted-text text-xs"},"queued",-1)),e("div",Ja,a(((je=q.value)==null?void 0:je.queuedRunCount)||0),1),e("p",Ga,a(i(s)("settingsDialog.system.queued")),1)]),e("div",Ya,[n[18]||(n[18]=e("div",{class:"theme-muted-text text-xs"},"maxConcurrent",-1)),e("div",Qa,a(((Oe=(Fe=q.value)==null?void 0:Fe.config)==null?void 0:Oe.maxConcurrentRuns)||Y.runnerMaxConcurrentRuns),1),e("p",Xa,a(i(s)("settingsDialog.system.maxConcurrent")),1)])])):v("",!0),oe.value?(l(),c("div",Za,[e("div",ei,[n[19]||(n[19]=e("div",{class:"theme-muted-text text-xs"},"completed",-1)),e("div",ti,a(((Le=p.value)==null?void 0:Le.totalCompleted)||0),1),e("p",si,a(i(s)("settingsDialog.system.completed")),1)]),e("div",ni,[n[20]||(n[20]=e("div",{class:"theme-muted-text text-xs"},"stopped",-1)),e("div",ai,a(((Ae=p.value)==null?void 0:Ae.totalStopped)||0),1),e("p",ii,a(i(s)("settingsDialog.system.stopped")),1)]),e("div",oi,[n[21]||(n[21]=e("div",{class:"theme-muted-text text-xs"},"error",-1)),e("div",li,a(((Ve=p.value)==null?void 0:Ve.totalErrored)||0),1),e("p",ri,a(i(s)("settingsDialog.system.error")),1)]),e("div",ci,[n[22]||(n[22]=e("div",{class:"theme-muted-text text-xs"},"stop_timeout",-1)),e("div",di,a(((He=p.value)==null?void 0:He.totalStopTimeout)||0),1),e("p",ui,a(i(s)("settingsDialog.system.stopTimeout")),1)])])):v("",!0),oe.value?(l(),c("div",mi,[e("div",gi,[n[23]||(n[23]=e("div",{class:"theme-muted-text text-xs"},"event flush failures",-1)),e("div",hi,a(((qe=p.value)==null?void 0:qe.eventFlushFailureCount)||0),1),e("p",vi,a(i(s)("settingsDialog.system.eventWriteFailures")),1)]),e("div",xi,[n[24]||(n[24]=e("div",{class:"theme-muted-text text-xs"},"recovered runs",-1)),e("div",yi,a(((We=(Ke=Me.value)==null?void 0:Ke.metrics)==null?void 0:We.totalRecovered)||0),1),e("p",pi,a(i(s)("settingsDialog.system.recoveredRuns")),1)]),e("div",_i,[n[25]||(n[25]=e("div",{class:"theme-muted-text text-xs"},"last cleanup",-1)),e("div",fi,a(le((Je=(ze=Be.value)==null?void 0:ze.lastCleanup)==null?void 0:Je.finishedAt)),1),e("p",bi,a(i(s)("settingsDialog.system.lastMaintenanceAt")),1)])])):v("",!0),e("div",Di,[e("div",Ci,[e("div",ki,a(i(s)("settingsDialog.system.baseStatus")),1),e("div",wi,[e("div",Si,[n[26]||(n[26]=e("span",{class:"theme-muted-text"},"runner baseUrl",-1)),e("span",Ti,a(((Ye=(Ge=w.value)==null?void 0:Ge.runner)==null?void 0:Ye.baseUrl)||"-"),1)]),e("div",Ri,[n[27]||(n[27]=e("span",{class:"theme-muted-text"},"runner startedAt",-1)),e("span",Pi,a(le((Qe=q.value)==null?void 0:Qe.startedAt)),1)]),e("div",Ei,[n[28]||(n[28]=e("span",{class:"theme-muted-text"},"last sweep",-1)),e("span",Mi,a(le((Ze=(Xe=Me.value)==null?void 0:Xe.metrics)==null?void 0:Ze.lastSweepFinishedAt)),1)]),e("div",Bi,[n[29]||(n[29]=e("span",{class:"theme-muted-text"},"git diff worker",-1)),e("span",Ni,a(kt.value?i(s)("settingsDialog.system.available"):i(s)("settingsDialog.system.unknown")),1)]),e("div",$i,[n[30]||(n[30]=e("span",{class:"theme-muted-text"},"db vacuum",-1)),e("span",Ui,a(le((et=Be.value)==null?void 0:et.lastVacuumAt)),1)])])]),e("div",Ii,[e("div",ji,a(i(s)("settingsDialog.system.stopReasonTitle")),1),e("div",Fi,[(l(!0),c(j,null,F(St.value,r=>(l(),c("div",{key:r.key,class:"flex items-center justify-between gap-3"},[e("span",Oi,a(r.label),1),e("span",Li,a(r.value),1)]))),128))])])]),oe.value?(l(),c("div",Ai,[e("div",Vi,a(i(s)("settingsDialog.system.stopTimeoutPhaseTitle")),1),e("div",Hi,[(l(!0),c(j,null,F(Tt.value,r=>(l(),c("div",{key:r.key,class:"flex items-center justify-between gap-3 rounded-sm border border-dashed border-[var(--theme-borderMuted)] px-2.5 py-2"},[e("span",qi,a(r.label),1),e("span",Ki,a(r.value),1)]))),128))])])):v("",!0),!oe.value&&!J.value?(l(),c("div",Wi,[e("div",zi,a(i(s)("settingsDialog.system.runnerUnavailable")),1),e("p",Ji,a(xt((tt=w.value)==null?void 0:tt.runner,"settingsDialog.system.runnerUnavailableDescription")),1),e("p",Gi," baseUrl: "+a(((nt=(st=w.value)==null?void 0:st.runner)==null?void 0:nt.baseUrl)||"-"),1)])):v("",!0)])])):S.value==="shortcuts"?(l(),c("section",Yi,[e("div",null,[e("div",Qi,[K(i(Ce),{class:"h-4 w-4"}),e("span",null,a(i(s)("settingsDialog.shortcuts.title")),1)]),e("p",Xi,a(i(s)("settingsDialog.shortcuts.intro")),1)]),e("section",Zi,[(l(!0),c(j,null,F(bt.value,r=>(l(),c("div",{key:r.id,class:"settings-form-card flex flex-col justify-between gap-3 px-3 py-3 sm:flex-row sm:items-center"},[e("div",eo,[e("div",to,a(r.label),1),e("p",so,a(r.description),1)]),e("div",no,[e("span",ao,a(r.mac),1),e("span",io,a(r.windows),1)])]))),128)),e("p",oo,a(i(s)("settingsDialog.shortcuts.note")),1)])])):(l(),c("section",lo,[e("div",null,[e("div",ro,a(i(s)("settingsDialog.about.title")),1),e("p",co,a(i(s)("settingsDialog.about.intro")),1)]),e("section",uo,[e("div",mo,[e("div",null,[e("div",go,a(i(s)("settingsDialog.about.versionTitle")),1),e("p",ho,a(L.value||i(s)("settingsDialog.about.versionDescription")),1)]),e("span",vo,a(b.value?i(s)("common.loading"):y.value?`v${y.value}`:i(s)("common.unavailable")),1)])])]))])]}),_:1},8,["open"]))}};export{Co as default};