@intent-hq/web 2.334.5 → 2.334.6

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 (141) hide show
  1. package/package.json +1 -1
  2. package/web/app/immutable/chunks/{CAQ9IZ-5.js → 0FyVrvMr.js} +1 -1
  3. package/web/app/immutable/chunks/{tXXMewoC.js → 0WwOrUwa.js} +1 -1
  4. package/web/app/immutable/chunks/{zjjhmoCi.js → 62Ck3yAT.js} +4 -4
  5. package/web/app/immutable/chunks/{BIG-RqmD.js → 81XDh255.js} +1 -1
  6. package/web/app/immutable/chunks/{-idyJf0Q.js → 8_ljbhiH.js} +1 -1
  7. package/web/app/immutable/chunks/{C0-S1-C9.js → B-tqV-du.js} +1 -1
  8. package/web/app/immutable/chunks/{JKTxaB_7.js → B0AQrNP8.js} +1 -1
  9. package/web/app/immutable/chunks/{Cze5ukTN.js → B2dH0oKn.js} +1 -1
  10. package/web/app/immutable/chunks/{CTAZgyxn.js → BBCAmMgd.js} +1 -1
  11. package/web/app/immutable/chunks/{bRY1vllE.js → BBSarno7.js} +1 -1
  12. package/web/app/immutable/chunks/{DRYJpcsn.js → BEtyTdg1.js} +1 -1
  13. package/web/app/immutable/chunks/{DAwl0H0O.js → BMxxonMM.js} +1 -1
  14. package/web/app/immutable/chunks/{C3jRnvWV.js → BN7oNeT4.js} +1 -1
  15. package/web/app/immutable/chunks/{DS0gXqKa.js → BNE5EdJc.js} +1 -1
  16. package/web/app/immutable/chunks/{C0Zprf9a.js → BRhn0zzz.js} +1 -1
  17. package/web/app/immutable/chunks/{BgwmpW_I.js → BRq9XkNc.js} +1 -1
  18. package/web/app/immutable/chunks/{B5OmV9OE.js → BSj_w_6H.js} +1 -1
  19. package/web/app/immutable/chunks/{B5fJ7v5T.js → BSt9DnIU.js} +1 -1
  20. package/web/app/immutable/chunks/{DN8LmwKG.js → BUfNF6yo.js} +1 -1
  21. package/web/app/immutable/chunks/{DIPFuM5R.js → BVbFqMmm.js} +1 -1
  22. package/web/app/immutable/chunks/{DBAYD4_r.js → BWwaybhk.js} +1 -1
  23. package/web/app/immutable/chunks/{BTgR8VBy.js → Ba_-F0B5.js} +2 -2
  24. package/web/app/immutable/chunks/{BtbEoZ6Z.js → BcXaAxkW.js} +1 -1
  25. package/web/app/immutable/chunks/{BHhf5z_U.js → Bd3NQ0dc.js} +1 -1
  26. package/web/app/immutable/chunks/{CuXeirUg.js → Be-iTE3o.js} +1 -1
  27. package/web/app/immutable/chunks/{D8G7OZUS.js → BerYJ_N3.js} +1 -1
  28. package/web/app/immutable/chunks/{CdYKja2-.js → BgVKKIhh.js} +4 -4
  29. package/web/app/immutable/chunks/{lYzRqPAn.js → BhHLn-bI.js} +1 -1
  30. package/web/app/immutable/chunks/{BTkpolI2.js → BkmDnHK5.js} +1 -1
  31. package/web/app/immutable/chunks/{BGLs-60-.js → BlAnjJrQ.js} +1 -1
  32. package/web/app/immutable/chunks/{_Z4ggDHe.js → Bm8uDgI4.js} +1 -1
  33. package/web/app/immutable/chunks/{BGPNdv6v.js → BmVaEhYz.js} +1 -1
  34. package/web/app/immutable/chunks/{CCmac_sS.js → BnEsz2KN.js} +1 -1
  35. package/web/app/immutable/chunks/{Crry_QMY.js → BnFz8cck.js} +2 -2
  36. package/web/app/immutable/chunks/{DLf4QVoe.js → BqZYZkSb.js} +1 -1
  37. package/web/app/immutable/chunks/{BC_5IcR6.js → Bs4slzIC.js} +2 -2
  38. package/web/app/immutable/chunks/{azFrCjQ_.js → Bte-s6hN.js} +3 -3
  39. package/web/app/immutable/chunks/{DNBLuGUg.js → Bugw0Y8f.js} +1 -1
  40. package/web/app/immutable/chunks/{D0iIRO7t.js → BwWjWCx7.js} +1 -1
  41. package/web/app/immutable/chunks/{xbuLLYO-.js → BxoQ-54W.js} +1 -1
  42. package/web/app/immutable/chunks/{CVXgztwC.js → C0n3GkXc.js} +1 -1
  43. package/web/app/immutable/chunks/{YDcLA9fq.js → C1v_uKxt.js} +1 -1
  44. package/web/app/immutable/chunks/{fR0qI3oF.js → C27VjfPV.js} +3 -3
  45. package/web/app/immutable/chunks/{BrhD-mFY.js → C43c9gOy.js} +1 -1
  46. package/web/app/immutable/chunks/{D8q3b1Qj.js → C4HlRcUf.js} +2 -2
  47. package/web/app/immutable/chunks/{B3icew6f.js → C4twHGiQ.js} +1 -1
  48. package/web/app/immutable/chunks/{Bow9NHT4.js → C6KILHrA.js} +1 -1
  49. package/web/app/immutable/chunks/{DZTSivxP.js → C9HiWs7H.js} +4 -4
  50. package/web/app/immutable/chunks/{CR6ShVtW.js → CAnlGY8T.js} +1 -1
  51. package/web/app/immutable/chunks/{DsUjXqko.js → CB_s16b4.js} +1 -1
  52. package/web/app/immutable/chunks/{BHJfNVxl.js → CF8VGN6V.js} +1 -1
  53. package/web/app/immutable/chunks/{4h3HEK5p.js → CFnSm94u.js} +1 -1
  54. package/web/app/immutable/chunks/{CwZLLHpg.js → CJGmFcnd.js} +1 -1
  55. package/web/app/immutable/chunks/{DfTMuGBe.js → CQdt2YW2.js} +1 -1
  56. package/web/app/immutable/chunks/{xsDm9mPC.js → CRUpele6.js} +1 -1
  57. package/web/app/immutable/chunks/{C87nTzqH.js → CR_TLVSm.js} +1 -1
  58. package/web/app/immutable/chunks/{B9WlbpxQ.js → CUIX5TSy.js} +4 -4
  59. package/web/app/immutable/chunks/{BbdQPklw.js → CeVaI72E.js} +1 -1
  60. package/web/app/immutable/chunks/{CyDiuifL.js → Cf5QUyxQ.js} +1 -1
  61. package/web/app/immutable/chunks/{_DGkiSFo.js → CldWVpJx.js} +1 -1
  62. package/web/app/immutable/chunks/{yJ_FteZh.js → ClsZKLeX.js} +1 -1
  63. package/web/app/immutable/chunks/{D-V8sk08.js → ClyIJA-J.js} +3 -3
  64. package/web/app/immutable/chunks/{BhatHgfe.js → Co9CQOEE.js} +1 -1
  65. package/web/app/immutable/chunks/{BoZS6xHC.js → CxKI5WLV.js} +1 -1
  66. package/web/app/immutable/chunks/{oYqOoA2z.js → CxN5ww35.js} +1 -1
  67. package/web/app/immutable/chunks/{DUujJVAq.js → D-JiThfG.js} +1 -1
  68. package/web/app/immutable/chunks/{Cyc8D2S-.js → D2R9j_dh.js} +1 -1
  69. package/web/app/immutable/chunks/{1pE0yFG-.js → D4KuwGYO.js} +1 -1
  70. package/web/app/immutable/chunks/{CWAEMi5v.js → D4RvzmFV.js} +1 -1
  71. package/web/app/immutable/chunks/{BlnDsiKL.js → DAS5c34n.js} +1 -1
  72. package/web/app/immutable/chunks/{CL0sOeN7.js → DBNZp5Wp.js} +1 -1
  73. package/web/app/immutable/chunks/{DC9BUHdJ.js → DCoF9aZO.js} +1 -1
  74. package/web/app/immutable/chunks/{CzHt8acf.js → DDzpiEuq.js} +1 -1
  75. package/web/app/immutable/chunks/{BDpPnl9d.js → DFIEz-U9.js} +1 -1
  76. package/web/app/immutable/chunks/{BrtiAZMp.js → DFZXcT7x.js} +1 -1
  77. package/web/app/immutable/chunks/{Mv7axlN8.js → DGCiv8do.js} +1 -1
  78. package/web/app/immutable/chunks/{C11ArHNe.js → DGIH8Giy.js} +1 -1
  79. package/web/app/immutable/chunks/{C_7drupe.js → DHZ6PxAq.js} +1 -1
  80. package/web/app/immutable/chunks/{DLlqqk1p.js → DHrUgmm5.js} +1 -1
  81. package/web/app/immutable/chunks/{B5o9xrsG.js → DIHTPxGm.js} +12 -12
  82. package/web/app/immutable/chunks/{BvNOW3-j.js → DIUwrF_K.js} +1 -1
  83. package/web/app/immutable/chunks/{MwMZNt41.js → DLHQbJV8.js} +1 -1
  84. package/web/app/immutable/chunks/{D6zVS1Lu.js → DLdcS_fn.js} +1 -1
  85. package/web/app/immutable/chunks/{BTIrsKYq.js → DMrPpGxC.js} +1 -1
  86. package/web/app/immutable/chunks/{D0k90uF2.js → DO-6xcR6.js} +1 -1
  87. package/web/app/immutable/chunks/{GZBOVtrm.js → DQ0dj2KX.js} +1 -1
  88. package/web/app/immutable/chunks/{JFKNrDCO.js → DV0bJEUk.js} +2 -2
  89. package/web/app/immutable/chunks/{BNmL07Ug.js → DYa_4kRY.js} +1 -1
  90. package/web/app/immutable/chunks/{tm6Kod_Q.js → D_pdm8Iu.js} +1 -1
  91. package/web/app/immutable/chunks/{Blj11OCd.js → DaM3w2zL.js} +1 -1
  92. package/web/app/immutable/chunks/{C2VIO6Sd.js → DblhKpGx.js} +1 -1
  93. package/web/app/immutable/chunks/{26pg4AP0.js → Dgr_dd3s.js} +1 -1
  94. package/web/app/immutable/chunks/{BVM24IKT.js → Di8eJd7y.js} +1 -1
  95. package/web/app/immutable/chunks/{BX-n5rHg.js → DjJMRMqK.js} +1 -1
  96. package/web/app/immutable/chunks/{DUwomAUZ.js → Do1EoraG.js} +1 -1
  97. package/web/app/immutable/chunks/{DwlBgt6v.js → Dq3t5TwZ.js} +3 -3
  98. package/web/app/immutable/chunks/{B2jKM7_0.js → Dqj_x1iH.js} +1 -1
  99. package/web/app/immutable/chunks/{DBUe0ybf.js → Dt0PtZRf.js} +1 -1
  100. package/web/app/immutable/chunks/{Co_upWle.js → DwGXL-qt.js} +1 -1
  101. package/web/app/immutable/chunks/{Dk8EoSv9.js → Dyka1Qt_.js} +2 -2
  102. package/web/app/immutable/chunks/{B_59TAlS.js → E9lFZacU.js} +1 -1
  103. package/web/app/immutable/chunks/{Djsfa1UR.js → FvsPOdWc.js} +1 -1
  104. package/web/app/immutable/chunks/{ocVU4jR3.js → G24AfB6y.js} +1 -1
  105. package/web/app/immutable/chunks/{CZlZwNY4.js → H7Zvcn3V.js} +1 -1
  106. package/web/app/immutable/chunks/{XoHqSozf.js → IlIt-f56.js} +1 -1
  107. package/web/app/immutable/chunks/{C1z1LSy4.js → LyXMg8Qe.js} +1 -1
  108. package/web/app/immutable/chunks/{DHtTqndc.js → QGl-Xn9g.js} +2 -2
  109. package/web/app/immutable/chunks/{CGmmcv0v.js → SuEehhCe.js} +1 -1
  110. package/web/app/immutable/chunks/{Uz3Vh8x0.js → UEEF_pji.js} +2 -2
  111. package/web/app/immutable/chunks/{Csmv6l_s.js → XTm8XS4k.js} +3 -3
  112. package/web/app/immutable/chunks/{B2OkJU1Q.js → YzN4RtUL.js} +1 -1
  113. package/web/app/immutable/chunks/{Cs183jPX.js → fkBazoe-.js} +1 -1
  114. package/web/app/immutable/chunks/{BKPbHBoH.js → gZgaz0G2.js} +2 -2
  115. package/web/app/immutable/chunks/{DEANs9P6.js → hODW-NKf.js} +1 -1
  116. package/web/app/immutable/chunks/{CIejl-Nh.js → i27DVf4h.js} +1 -1
  117. package/web/app/immutable/chunks/{BQZ8B0EP.js → kNlqjW-C.js} +1 -1
  118. package/web/app/immutable/chunks/{D0Q6d0a6.js → oLdtVgVq.js} +1 -1
  119. package/web/app/immutable/chunks/{cIO-28Lx.js → oUKZGyo6.js} +1 -1
  120. package/web/app/immutable/chunks/{BxvZVFA9.js → qS-FFtmP.js} +1 -1
  121. package/web/app/immutable/chunks/{DWDBvyQN.js → seqIFXVs.js} +1 -1
  122. package/web/app/immutable/chunks/{BKd3NqGe.js → sylOMk5x.js} +1 -1
  123. package/web/app/immutable/chunks/{DgeV_FnM.js → xctgDwNB.js} +1 -1
  124. package/web/app/immutable/entry/{app.DrIjug_X.js → app.DMK38pKj.js} +2 -2
  125. package/web/app/immutable/entry/start.DedWlol5.js +1 -0
  126. package/web/app/immutable/nodes/{0.CNJCBWEh.js → 0.ZjGfuQZ5.js} +1 -1
  127. package/web/app/immutable/nodes/{1.7VefspUf.js → 1.CzSlxWDI.js} +1 -1
  128. package/web/app/immutable/nodes/{10.BpKrKPhR.js → 10.CDcFOY3m.js} +1 -1
  129. package/web/app/immutable/nodes/{14.Ca2hU4Cy.js → 14.442_Kmt_.js} +1 -1
  130. package/web/app/immutable/nodes/{17.p0zmAz2d.js → 17.Gp4mmeUX.js} +2 -2
  131. package/web/app/immutable/nodes/{2.CXWUY6ZX.js → 2.BWlNOzaY.js} +4 -4
  132. package/web/app/immutable/nodes/{3.PhCW8_nQ.js → 3.DwEqcKct.js} +1 -1
  133. package/web/app/immutable/nodes/{4.CMO7JnM-.js → 4.CLbC-SYM.js} +1 -1
  134. package/web/app/immutable/nodes/{5.5nV6qflp.js → 5.Cb95bBtk.js} +1 -1
  135. package/web/app/immutable/nodes/{6.DfI35nbu.js → 6.K81lfiYe.js} +1 -1
  136. package/web/app/immutable/nodes/{7.D_LGZQdD.js → 7.B8yYgNgD.js} +1 -1
  137. package/web/app/immutable/nodes/{8.OhRibY6M.js → 8.CNNQksh_.js} +4 -4
  138. package/web/app/immutable/nodes/{9.Be1D9C6J.js → 9.Cg_qHOdY.js} +4 -4
  139. package/web/app/version.json +1 -1
  140. package/web/index.html +9 -9
  141. package/web/app/immutable/entry/start.B7AEsnQx.js +0 -1
@@ -1 +1 @@
1
- import{t as pt,br as S,a_ as E,bz as bt,bt as Pt,b as Ct,bp as vt,bv as h}from"./CEL6QztG.js";import{bs as kt,ca as K,aD as n,c9 as i,a7 as L,ay as _,W as w,bn as $t,bS as yt,aA as I,aB as St}from"./DYhIMPy1.js";import{G as _t}from"./CuEQVba7.js";import{c as wt}from"./B4USm-wY.js";import{b2 as It}from"./CdYKja2-.js";import{Ik as u,eu as Bt,ev as Wt,IR as Rt,J6 as Ut,IW as Tt,uH as Dt,o2 as V}from"./DYfeeu3f.js";import{g as At}from"./DfN8_dcw.js";import{bA as Ht,bC as Ft,dr as Mt}from"./Dml826jn.js";import{C as f}from"./DypB-Dwi.js";import"./yJ_FteZh.js";import"./yn6WWSq8.js";import"./CiSnSGvU.js";import{bc as xt}from"./DnKg2UsP.js";import"./Cd_8r4jJ.js";import"./DHtTqndc.js";import{T as Nt}from"./DN8LmwKG.js";import"./CGjjowC8.js";import{M as qt}from"./DSLbxDPz.js";import{V as Et}from"./FjbzmN5N.js";import{O as Kt}from"./DRYJpcsn.js";import{bQ as Lt,bK as Vt,b5 as Gt}from"./BxvZVFA9.js";import{i as Ot}from"./H2jLkRRS.js";var zt=St("<!> <!>",1);function Jt(B,p){if(new.target)return pt({component:Jt,...B});kt(p,!0);const W=()=>h(et,"$workspace",m),P=()=>h(Y,"$ftChanges$",m),G=()=>h(Z,"$ftCommits$",m),R=()=>h(j,"$foldUnchanged",m),U=()=>h(Q,"$lineWrapping",m),T=()=>h(X,"$diffSideBySide",m),[m,O]=Pt(),z=t=>{Et(t,{embedded:!0,get foldEnabled(){return R()},onToggleFold:()=>u.dispatch(Tt()),get wrapEnabled(){return U()},onToggleWrap:()=>u.dispatch(Ut()),get splitEnabled(){return T()},onToggleSplit:()=>u.dispatch(Rt())})},J=t=>{var e=zt(),r=_(e);{let l=i(()=>vt.layout_diffHeader_goToFile_tooltip());wt(r,()=>qt,(y,ht)=>{ht(y,{get icon(){return xt},get label(){return n(l)},onclick:Qt=>ft()})})}var s=yt(r,2);{var d=l=>{Kt(l,{get filePath(){return n(k)},get workspaceId(){return o()},isDirectory:!1,embedded:!0,get workspaceFolderPath(){return n(v)}})};E(s,l=>{n(k)&&l(d)})}w(t,e)},Q=Lt(),j=Vt(),X=Gt();let a=S(p,"tab",7),o=S(p,"workspaceId",7),b=S(p,"isActive",7);const C=It(()=>o()),Y=Ht(C),Z=Ft(C),tt=new Set([f.Committed,f.Pushed,f.PullRequest,f.Merged,f.Trunk]),D=At(),et=Mt(C),nt=i(()=>W()?.worktreePath||W()?.repositoryPath||void 0);K(()=>{const t=o();if(!(!b()||!t||n(c)))return u.dispatch(Bt(t,"all")),()=>u.dispatch(Wt(t,"all"))});const c=i(()=>a().data?.gitRootId),A=i(()=>a().data?.gitRootPath),v=i(()=>n(A)||n(nt)),k=i(()=>a().diffPath&&n(v)?Ot(a().diffPath)?a().diffPath:`${n(v)}/${a().diffPath}`:null);function H(t,e){return!!(t.file===e||t.relativePath===e||t.relativePath&&e.endsWith("/"+t.relativePath)||t.file&&e.endsWith("/"+t.file)||t.relativePath&&t.relativePath.endsWith("/"+e)||t.file&&t.file.endsWith("/"+e))}function F(t){return!t||n(c)?null:P().find(e=>H(e,t)&&(e.stage==="staged"||e.stage==="unstaged"))??null}function at(t){if(!t||n(c))return null;let e=null,r=-1/0;for(const s of P()){if(!H(s,t)||!tt.has(s.stage)||!s.commitHash)continue;const d=s.attribution?.timestamp??0;d>=r&&(e=s,r=d)}return e}function it(t,e){return!!(t===e||e.endsWith("/"+t)||t.endsWith("/"+e))}function rt(t){if(!t||n(c))return null;for(const e of G())if(e?.hash&&e.files?.some(r=>r?.path&&it(r.path,t)))return{id:`diff-${t}-${e.hash}`,file:t,relativePath:t,status:"modified",stage:f.Committed,commitHash:e.hash,stats:{additions:0,deletions:0},attribution:{timestamp:e.timestamp??Date.now()}};return null}const M=i(()=>a().diffPath?F(a().diffPath):null),st=i(()=>{if(!a().diffPath)return 0;const t=F(a().diffPath),e=P().length;if(t){const r=t.stage==="staged"?1:t.stage==="unstaged"?2:3,s=(t.stats?.additions||0)+(t.stats?.deletions||0),d=t.attribution?.timestamp?t.attribution.timestamp%1e5:0;return r*1e6+s*1e3+d+e}return e}),g=i(()=>a().data?.change),x=i(()=>a().data?.branchBaseRef),N=i(()=>a().data?.branchBaseCommitSha),ot=i(()=>!!(n(x)||n(N))),$=i(()=>{if(n(g)?.commitHash)return n(g);if(n(M))return n(M);if(n(ot)&&n(g))return n(g);const t=at(a().diffPath??null);if(t)return t;const e=rt(a().diffPath??null);return e||(n(g)?n(g):{id:`diff-${a().diffPath}`,file:a().diffPath||"",relativePath:a().diffPath||"",status:"modified",stage:f.Unstaged,stats:{additions:0,deletions:0},attribution:{timestamp:Date.now()}})});function ft(t){if(!a().diffPath)return;const r={type:"file",title:a().diffPath.split("/").pop()||a().diffPath,closable:!0,filePath:n(k)||a().diffPath,workspaceId:o()};u.dispatch(Dt(o(),r))}K(()=>{!D||!b()||D.registerActions({display:z,actions:J})});function dt(t,e){u.dispatch(V(o(),crypto.randomUUID(),{kind:"stageHunk",filePath:t,hunkPatch:e,source:"diff"}))}function ut(t,e){u.dispatch(V(o(),crypto.randomUUID(),{kind:"unstageHunk",filePath:t,hunkPatch:e,source:"diff"}))}var ct={get tab(){return a()},set tab(t){a(t),I()},get workspaceId(){return o()},set workspaceId(t){o(t),I()},get isActive(){return b()},set isActive(t){b(t),I()},$set:bt,$on:(t,e)=>Ct(p,t,e)},q=L(),lt=_(q);{var mt=t=>{var e=L(),r=_(e);_t(r,()=>a().diffPath,s=>{{let d=i(()=>T()?"split":"unified"),l=i(()=>!n(c)&&n($).stage===f.Unstaged?dt:void 0),y=i(()=>!n(c)&&n($).stage===f.Staged?ut:void 0);Nt(s,{get active(){return b()},get change(){return n($)},get workspaceId(){return o()},get viewMode(){return n(d)},get foldUnchanged(){return R()},get lineWrapping(){return U()},get refreshKey(){return n(st)},get branchBaseRef(){return n(x)},get branchBaseCommitSha(){return n(N)},get gitRootId(){return n(c)},get gitRootPath(){return n(A)},get onStageHunk(){return n(l)},get onUnstageHunk(){return n(y)}})}}),w(t,e)};E(lt,t=>{a().diffPath&&t(mt)})}w(B,q);var gt=$t(ct);return O(),gt}export{Jt as default};
1
+ import{t as pt,br as S,a_ as E,bz as bt,bt as Pt,b as Ct,bp as vt,bv as h}from"./CEL6QztG.js";import{bs as kt,ca as K,aD as n,c9 as i,a7 as L,ay as _,W as w,bn as $t,bS as yt,aA as I,aB as St}from"./DYhIMPy1.js";import{G as _t}from"./CuEQVba7.js";import{c as wt}from"./B4USm-wY.js";import{b2 as It}from"./BgVKKIhh.js";import{Ik as u,eu as Bt,ev as Wt,IR as Rt,J6 as Ut,IW as Tt,uH as Dt,o2 as V}from"./DYfeeu3f.js";import{g as At}from"./DfN8_dcw.js";import{bA as Ht,bC as Ft,dr as Mt}from"./Dml826jn.js";import{C as f}from"./DypB-Dwi.js";import"./ClsZKLeX.js";import"./yn6WWSq8.js";import"./CiSnSGvU.js";import{bc as xt}from"./DnKg2UsP.js";import"./Cd_8r4jJ.js";import"./QGl-Xn9g.js";import{T as Nt}from"./BUfNF6yo.js";import"./CGjjowC8.js";import{M as qt}from"./DSLbxDPz.js";import{V as Et}from"./FjbzmN5N.js";import{O as Kt}from"./BEtyTdg1.js";import{bQ as Lt,bK as Vt,b5 as Gt}from"./qS-FFtmP.js";import{i as Ot}from"./H2jLkRRS.js";var zt=St("<!> <!>",1);function Jt(B,p){if(new.target)return pt({component:Jt,...B});kt(p,!0);const W=()=>h(et,"$workspace",m),P=()=>h(Y,"$ftChanges$",m),G=()=>h(Z,"$ftCommits$",m),R=()=>h(j,"$foldUnchanged",m),U=()=>h(Q,"$lineWrapping",m),T=()=>h(X,"$diffSideBySide",m),[m,O]=Pt(),z=t=>{Et(t,{embedded:!0,get foldEnabled(){return R()},onToggleFold:()=>u.dispatch(Tt()),get wrapEnabled(){return U()},onToggleWrap:()=>u.dispatch(Ut()),get splitEnabled(){return T()},onToggleSplit:()=>u.dispatch(Rt())})},J=t=>{var e=zt(),r=_(e);{let l=i(()=>vt.layout_diffHeader_goToFile_tooltip());wt(r,()=>qt,(y,ht)=>{ht(y,{get icon(){return xt},get label(){return n(l)},onclick:Qt=>ft()})})}var s=yt(r,2);{var d=l=>{Kt(l,{get filePath(){return n(k)},get workspaceId(){return o()},isDirectory:!1,embedded:!0,get workspaceFolderPath(){return n(v)}})};E(s,l=>{n(k)&&l(d)})}w(t,e)},Q=Lt(),j=Vt(),X=Gt();let a=S(p,"tab",7),o=S(p,"workspaceId",7),b=S(p,"isActive",7);const C=It(()=>o()),Y=Ht(C),Z=Ft(C),tt=new Set([f.Committed,f.Pushed,f.PullRequest,f.Merged,f.Trunk]),D=At(),et=Mt(C),nt=i(()=>W()?.worktreePath||W()?.repositoryPath||void 0);K(()=>{const t=o();if(!(!b()||!t||n(c)))return u.dispatch(Bt(t,"all")),()=>u.dispatch(Wt(t,"all"))});const c=i(()=>a().data?.gitRootId),A=i(()=>a().data?.gitRootPath),v=i(()=>n(A)||n(nt)),k=i(()=>a().diffPath&&n(v)?Ot(a().diffPath)?a().diffPath:`${n(v)}/${a().diffPath}`:null);function H(t,e){return!!(t.file===e||t.relativePath===e||t.relativePath&&e.endsWith("/"+t.relativePath)||t.file&&e.endsWith("/"+t.file)||t.relativePath&&t.relativePath.endsWith("/"+e)||t.file&&t.file.endsWith("/"+e))}function F(t){return!t||n(c)?null:P().find(e=>H(e,t)&&(e.stage==="staged"||e.stage==="unstaged"))??null}function at(t){if(!t||n(c))return null;let e=null,r=-1/0;for(const s of P()){if(!H(s,t)||!tt.has(s.stage)||!s.commitHash)continue;const d=s.attribution?.timestamp??0;d>=r&&(e=s,r=d)}return e}function it(t,e){return!!(t===e||e.endsWith("/"+t)||t.endsWith("/"+e))}function rt(t){if(!t||n(c))return null;for(const e of G())if(e?.hash&&e.files?.some(r=>r?.path&&it(r.path,t)))return{id:`diff-${t}-${e.hash}`,file:t,relativePath:t,status:"modified",stage:f.Committed,commitHash:e.hash,stats:{additions:0,deletions:0},attribution:{timestamp:e.timestamp??Date.now()}};return null}const M=i(()=>a().diffPath?F(a().diffPath):null),st=i(()=>{if(!a().diffPath)return 0;const t=F(a().diffPath),e=P().length;if(t){const r=t.stage==="staged"?1:t.stage==="unstaged"?2:3,s=(t.stats?.additions||0)+(t.stats?.deletions||0),d=t.attribution?.timestamp?t.attribution.timestamp%1e5:0;return r*1e6+s*1e3+d+e}return e}),g=i(()=>a().data?.change),x=i(()=>a().data?.branchBaseRef),N=i(()=>a().data?.branchBaseCommitSha),ot=i(()=>!!(n(x)||n(N))),$=i(()=>{if(n(g)?.commitHash)return n(g);if(n(M))return n(M);if(n(ot)&&n(g))return n(g);const t=at(a().diffPath??null);if(t)return t;const e=rt(a().diffPath??null);return e||(n(g)?n(g):{id:`diff-${a().diffPath}`,file:a().diffPath||"",relativePath:a().diffPath||"",status:"modified",stage:f.Unstaged,stats:{additions:0,deletions:0},attribution:{timestamp:Date.now()}})});function ft(t){if(!a().diffPath)return;const r={type:"file",title:a().diffPath.split("/").pop()||a().diffPath,closable:!0,filePath:n(k)||a().diffPath,workspaceId:o()};u.dispatch(Dt(o(),r))}K(()=>{!D||!b()||D.registerActions({display:z,actions:J})});function dt(t,e){u.dispatch(V(o(),crypto.randomUUID(),{kind:"stageHunk",filePath:t,hunkPatch:e,source:"diff"}))}function ut(t,e){u.dispatch(V(o(),crypto.randomUUID(),{kind:"unstageHunk",filePath:t,hunkPatch:e,source:"diff"}))}var ct={get tab(){return a()},set tab(t){a(t),I()},get workspaceId(){return o()},set workspaceId(t){o(t),I()},get isActive(){return b()},set isActive(t){b(t),I()},$set:bt,$on:(t,e)=>Ct(p,t,e)},q=L(),lt=_(q);{var mt=t=>{var e=L(),r=_(e);_t(r,()=>a().diffPath,s=>{{let d=i(()=>T()?"split":"unified"),l=i(()=>!n(c)&&n($).stage===f.Unstaged?dt:void 0),y=i(()=>!n(c)&&n($).stage===f.Staged?ut:void 0);Nt(s,{get active(){return b()},get change(){return n($)},get workspaceId(){return o()},get viewMode(){return n(d)},get foldUnchanged(){return R()},get lineWrapping(){return U()},get refreshKey(){return n(st)},get branchBaseRef(){return n(x)},get branchBaseCommitSha(){return n(N)},get gitRootId(){return n(c)},get gitRootPath(){return n(A)},get onStageHunk(){return n(l)},get onUnstageHunk(){return n(y)}})}}),w(t,e)};E(lt,t=>{a().diffPath&&t(mt)})}w(B,q);var gt=$t(ct);return O(),gt}export{Jt as default};
@@ -1,4 +1,4 @@
1
- import{b as o,W as pt,x as nt,am as Wt,an as Rt,au as Pt,H as Bt,X as ft,ay as E,aX as Vt,aH as Ft,b3 as yt,aW as U,d as ct,_ as zt,y as Ot,r as Gt}from"./DZTSivxP.js";var tt=(function(){var e=o(function(k,a,d,l){for(d=d||{},l=k.length;l--;d[k[l]]=a);return d},"o"),t=[6,11,13,14,15,17,19,20,23,24],s=[1,12],r=[1,13],n=[1,14],h=[1,15],c=[1,16],i=[1,19],y=[1,20],p={trace:o(function(){},"trace"),yy:{},symbols_:{error:2,start:3,timeline_header:4,document:5,EOF:6,timeline:7,timeline_lr:8,timeline_td:9,line:10,SPACE:11,statement:12,NEWLINE:13,title:14,acc_title:15,acc_title_value:16,acc_descr:17,acc_descr_value:18,acc_descr_multiline_value:19,section:20,period_statement:21,event_statement:22,period:23,event:24,$accept:0,$end:1},terminals_:{2:"error",6:"EOF",7:"timeline",8:"timeline_lr",9:"timeline_td",11:"SPACE",13:"NEWLINE",14:"title",15:"acc_title",16:"acc_title_value",17:"acc_descr",18:"acc_descr_value",19:"acc_descr_multiline_value",20:"section",23:"period",24:"event"},productions_:[0,[3,3],[4,1],[4,1],[4,1],[5,0],[5,2],[10,2],[10,1],[10,1],[10,1],[12,1],[12,2],[12,2],[12,1],[12,1],[12,1],[12,1],[21,1],[22,1]],performAction:o(function(a,d,l,g,x,u,S){var v=u.length-1;switch(x){case 1:return u[v-1];case 3:g.setDirection("LR");break;case 4:g.setDirection("TD");break;case 5:this.$=[];break;case 6:u[v-1].push(u[v]),this.$=u[v-1];break;case 7:case 8:this.$=u[v];break;case 9:case 10:this.$=[];break;case 11:g.getCommonDb().setDiagramTitle(u[v].substr(6)),this.$=u[v].substr(6);break;case 12:this.$=u[v].trim(),g.getCommonDb().setAccTitle(this.$);break;case 13:case 14:this.$=u[v].trim(),g.getCommonDb().setAccDescription(this.$);break;case 15:g.addSection(u[v].substr(8)),this.$=u[v].substr(8);break;case 18:g.addTask(u[v],0,""),this.$=u[v];break;case 19:g.addEvent(u[v].substr(2)),this.$=u[v];break}},"anonymous"),table:[{3:1,4:2,7:[1,3],8:[1,4],9:[1,5]},{1:[3]},e(t,[2,5],{5:6}),e(t,[2,2]),e(t,[2,3]),e(t,[2,4]),{6:[1,7],10:8,11:[1,9],12:10,13:[1,11],14:s,15:r,17:n,19:h,20:c,21:17,22:18,23:i,24:y},e(t,[2,10],{1:[2,1]}),e(t,[2,6]),{12:21,14:s,15:r,17:n,19:h,20:c,21:17,22:18,23:i,24:y},e(t,[2,8]),e(t,[2,9]),e(t,[2,11]),{16:[1,22]},{18:[1,23]},e(t,[2,14]),e(t,[2,15]),e(t,[2,16]),e(t,[2,17]),e(t,[2,18]),e(t,[2,19]),e(t,[2,7]),e(t,[2,12]),e(t,[2,13])],defaultActions:{},parseError:o(function(a,d){if(d.recoverable)this.trace(a);else{var l=new Error(a);throw l.hash=d,l}},"parseError"),parse:o(function(a){var d=this,l=[0],g=[],x=[null],u=[],S=this.table,v="",I=0,C=0,R=2,O=1,L=u.slice.call(arguments,1),w=Object.create(this.lexer),H={yy:{}};for(var V in this.yy)Object.prototype.hasOwnProperty.call(this.yy,V)&&(H.yy[V]=this.yy[V]);w.setInput(a,H.yy),H.yy.lexer=w,H.yy.parser=this,typeof w.yylloc>"u"&&(w.yylloc={});var F=w.yylloc;u.push(F);var K=w.options&&w.options.ranges;typeof H.yy.parseError=="function"?this.parseError=H.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;function N(A){l.length=l.length-2*A,x.length=x.length-A,u.length=u.length-A}o(N,"popStack");function b(){var A;return A=g.pop()||w.lex()||O,typeof A!="number"&&(A instanceof Array&&(g=A,A=g.pop()),A=d.symbols_[A]||A),A}o(b,"lex");for(var _,$,T,P,W={},G,B,Z,j;;){if($=l[l.length-1],this.defaultActions[$]?T=this.defaultActions[$]:((_===null||typeof _>"u")&&(_=b()),T=S[$]&&S[$][_]),typeof T>"u"||!T.length||!T[0]){var Y="";j=[];for(G in S[$])this.terminals_[G]&&G>R&&j.push("'"+this.terminals_[G]+"'");w.showPosition?Y="Parse error on line "+(I+1)+`:
1
+ import{b as o,W as pt,x as nt,am as Wt,an as Rt,au as Pt,H as Bt,X as ft,ay as E,aX as Vt,aH as Ft,b3 as yt,aW as U,d as ct,_ as zt,y as Ot,r as Gt}from"./C9HiWs7H.js";var tt=(function(){var e=o(function(k,a,d,l){for(d=d||{},l=k.length;l--;d[k[l]]=a);return d},"o"),t=[6,11,13,14,15,17,19,20,23,24],s=[1,12],r=[1,13],n=[1,14],h=[1,15],c=[1,16],i=[1,19],y=[1,20],p={trace:o(function(){},"trace"),yy:{},symbols_:{error:2,start:3,timeline_header:4,document:5,EOF:6,timeline:7,timeline_lr:8,timeline_td:9,line:10,SPACE:11,statement:12,NEWLINE:13,title:14,acc_title:15,acc_title_value:16,acc_descr:17,acc_descr_value:18,acc_descr_multiline_value:19,section:20,period_statement:21,event_statement:22,period:23,event:24,$accept:0,$end:1},terminals_:{2:"error",6:"EOF",7:"timeline",8:"timeline_lr",9:"timeline_td",11:"SPACE",13:"NEWLINE",14:"title",15:"acc_title",16:"acc_title_value",17:"acc_descr",18:"acc_descr_value",19:"acc_descr_multiline_value",20:"section",23:"period",24:"event"},productions_:[0,[3,3],[4,1],[4,1],[4,1],[5,0],[5,2],[10,2],[10,1],[10,1],[10,1],[12,1],[12,2],[12,2],[12,1],[12,1],[12,1],[12,1],[21,1],[22,1]],performAction:o(function(a,d,l,g,x,u,S){var v=u.length-1;switch(x){case 1:return u[v-1];case 3:g.setDirection("LR");break;case 4:g.setDirection("TD");break;case 5:this.$=[];break;case 6:u[v-1].push(u[v]),this.$=u[v-1];break;case 7:case 8:this.$=u[v];break;case 9:case 10:this.$=[];break;case 11:g.getCommonDb().setDiagramTitle(u[v].substr(6)),this.$=u[v].substr(6);break;case 12:this.$=u[v].trim(),g.getCommonDb().setAccTitle(this.$);break;case 13:case 14:this.$=u[v].trim(),g.getCommonDb().setAccDescription(this.$);break;case 15:g.addSection(u[v].substr(8)),this.$=u[v].substr(8);break;case 18:g.addTask(u[v],0,""),this.$=u[v];break;case 19:g.addEvent(u[v].substr(2)),this.$=u[v];break}},"anonymous"),table:[{3:1,4:2,7:[1,3],8:[1,4],9:[1,5]},{1:[3]},e(t,[2,5],{5:6}),e(t,[2,2]),e(t,[2,3]),e(t,[2,4]),{6:[1,7],10:8,11:[1,9],12:10,13:[1,11],14:s,15:r,17:n,19:h,20:c,21:17,22:18,23:i,24:y},e(t,[2,10],{1:[2,1]}),e(t,[2,6]),{12:21,14:s,15:r,17:n,19:h,20:c,21:17,22:18,23:i,24:y},e(t,[2,8]),e(t,[2,9]),e(t,[2,11]),{16:[1,22]},{18:[1,23]},e(t,[2,14]),e(t,[2,15]),e(t,[2,16]),e(t,[2,17]),e(t,[2,18]),e(t,[2,19]),e(t,[2,7]),e(t,[2,12]),e(t,[2,13])],defaultActions:{},parseError:o(function(a,d){if(d.recoverable)this.trace(a);else{var l=new Error(a);throw l.hash=d,l}},"parseError"),parse:o(function(a){var d=this,l=[0],g=[],x=[null],u=[],S=this.table,v="",I=0,C=0,R=2,O=1,L=u.slice.call(arguments,1),w=Object.create(this.lexer),H={yy:{}};for(var V in this.yy)Object.prototype.hasOwnProperty.call(this.yy,V)&&(H.yy[V]=this.yy[V]);w.setInput(a,H.yy),H.yy.lexer=w,H.yy.parser=this,typeof w.yylloc>"u"&&(w.yylloc={});var F=w.yylloc;u.push(F);var K=w.options&&w.options.ranges;typeof H.yy.parseError=="function"?this.parseError=H.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;function N(A){l.length=l.length-2*A,x.length=x.length-A,u.length=u.length-A}o(N,"popStack");function b(){var A;return A=g.pop()||w.lex()||O,typeof A!="number"&&(A instanceof Array&&(g=A,A=g.pop()),A=d.symbols_[A]||A),A}o(b,"lex");for(var _,$,T,P,W={},G,B,Z,j;;){if($=l[l.length-1],this.defaultActions[$]?T=this.defaultActions[$]:((_===null||typeof _>"u")&&(_=b()),T=S[$]&&S[$][_]),typeof T>"u"||!T.length||!T[0]){var Y="";j=[];for(G in S[$])this.terminals_[G]&&G>R&&j.push("'"+this.terminals_[G]+"'");w.showPosition?Y="Parse error on line "+(I+1)+`:
2
2
  `+w.showPosition()+`
3
3
  Expecting `+j.join(", ")+", got '"+(this.terminals_[_]||_)+"'":Y="Parse error on line "+(I+1)+": Unexpected "+(_==O?"end of input":"'"+(this.terminals_[_]||_)+"'"),this.parseError(Y,{text:w.match,token:this.terminals_[_]||_,line:w.yylineno,loc:F,expected:j})}if(T[0]instanceof Array&&T.length>1)throw new Error("Parse Error: multiple actions possible at state: "+$+", token: "+_);switch(T[0]){case 1:l.push(_),x.push(w.yytext),u.push(w.yylloc),l.push(T[1]),_=null,C=w.yyleng,v=w.yytext,I=w.yylineno,F=w.yylloc;break;case 2:if(B=this.productions_[T[1]][1],W.$=x[x.length-B],W._$={first_line:u[u.length-(B||1)].first_line,last_line:u[u.length-1].last_line,first_column:u[u.length-(B||1)].first_column,last_column:u[u.length-1].last_column},K&&(W._$.range=[u[u.length-(B||1)].range[0],u[u.length-1].range[1]]),P=this.performAction.apply(W,[v,C,I,H.yy,T[1],x,u].concat(L)),typeof P<"u")return P;B&&(l=l.slice(0,-1*B*2),x=x.slice(0,-1*B),u=u.slice(0,-1*B)),l.push(this.productions_[T[1]][0]),x.push(W.$),u.push(W._$),Z=S[l[l.length-2]][l[l.length-1]],l.push(Z);break;case 3:return!0}}return!0},"parse")},m=(function(){var k={EOF:1,parseError:o(function(d,l){if(this.yy.parser)this.yy.parser.parseError(d,l);else throw new Error(d)},"parseError"),setInput:o(function(a,d){return this.yy=d||this.yy||{},this._input=a,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},"setInput"),input:o(function(){var a=this._input[0];this.yytext+=a,this.yyleng++,this.offset++,this.match+=a,this.matched+=a;var d=a.match(/(?:\r\n?|\n).*/g);return d?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),a},"input"),unput:o(function(a){var d=a.length,l=a.split(/(?:\r\n?|\n)/g);this._input=a+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-d),this.offset-=d;var g=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),l.length-1&&(this.yylineno-=l.length-1);var x=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:l?(l.length===g.length?this.yylloc.first_column:0)+g[g.length-l.length].length-l[0].length:this.yylloc.first_column-d},this.options.ranges&&(this.yylloc.range=[x[0],x[0]+this.yyleng-d]),this.yyleng=this.yytext.length,this},"unput"),more:o(function(){return this._more=!0,this},"more"),reject:o(function(){if(this.options.backtrack_lexer)this._backtrack=!0;else return this.parseError("Lexical error on line "+(this.yylineno+1)+`. You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).
4
4
  `+this.showPosition(),{text:"",token:null,line:this.yylineno});return this},"reject"),less:o(function(a){this.unput(this.match.slice(a))},"less"),pastInput:o(function(){var a=this.matched.substr(0,this.matched.length-this.match.length);return(a.length>20?"...":"")+a.substr(-20).replace(/\n/g,"")},"pastInput"),upcomingInput:o(function(){var a=this.match;return a.length<20&&(a+=this._input.substr(0,20-a.length)),(a.substr(0,20)+(a.length>20?"...":"")).replace(/\n/g,"")},"upcomingInput"),showPosition:o(function(){var a=this.pastInput(),d=new Array(a.length+1).join("-");return a+this.upcomingInput()+`
@@ -1 +1 @@
1
- import{d as l,v as h,t as T}from"./WFvSJ9zU.js";import{Ik as c,uW as w}from"./DYfeeu3f.js";import{i as W,c as s,n as u,b as m}from"./JFKNrDCO.js";const E=new Set(["new","creating"]);function g(n){let t;try{t=decodeURIComponent(n)}catch{return null}return t.length===0||E.has(t)?null:t}function f(n){const t=/^\/workspace\/([^/?#]+)\/?(?:[?#].*)?$/.exec(n);return t?g(t[1]):null}function A(n){const t=/^\/workspace\/([^/?#]+)(?:[/?#].*)?$/.exec(n);return t?g(t[1]):null}function N(n,t){return t.length>0&&A(n)===t}function p(){return typeof window>"u"?null:window.location?.pathname??null}function d(n,t){const e=`/workspace/${encodeURIComponent(n)}`,a=t?new URLSearchParams(t).toString():"";return a?`${e}?${a}`:e}function R(n,t){const e=t?.presenceFollowRequestId;return e?w(n,e):w(n)}function I(n,t){return t?u(n,{state:t}):u(n)}function o(n){return n?.tabState?.currentTabId??null}async function S(n,t,e,a){m();const i=I(t,e),r={workspaceId:n,epoch:s(),startTabId:a};return await i,r}function y(n){return!n||W()}function b(n,t){if(s()!==n.epoch||t!==n.startTabId&&t!==n.workspaceId)return!1;const e=p();return e===null||f(e)===n.workspaceId}async function v(n,t,e){if(y(n))return!1;const a=await S(n,t,e,o(c.state));return b(a,o(c.state))?(c.dispatch(R(n,e)),!0):!1}function*k(n,t,e){if(y(n))return!1;const a=o(yield*h(r=>r)),i=yield*l(S,n,t,e,a);return b(i,o(yield*h(r=>r)))?(yield*T(R(n,e)),!0):!1}function P(){m();const n=s(),t=o(c.state),e=p();return()=>s()===n&&o(c.state)===t&&p()===e}function _(n,t={}){return v(n,d(n,t.query),t.state)}function O(n,t={}){return k(n,d(n,t.query),t.state)}async function $(n){const t=f(n);t?await v(t,n,void 0):await u(n)}function*j(n){const t=f(n);t?yield*l(k,t,n,void 0):yield*l(u,n)}const U=Object.freeze(Object.defineProperty({__proto__:null,claimNavigation:P,navigateToAppRoute:$,navigateToAppRouteSaga:j,openAndShowWorkspace:_,showWorkspaceSaga:O,workspaceRoute:d},Symbol.toStringTag,{value:"Module"}));export{p as a,j as b,P as c,O as d,d as e,N as i,$ as n,_ as o,f as p,U as s,A as w};
1
+ import{d as l,v as h,t as T}from"./WFvSJ9zU.js";import{Ik as c,uW as w}from"./DYfeeu3f.js";import{i as W,c as s,n as u,b as m}from"./DV0bJEUk.js";const E=new Set(["new","creating"]);function g(n){let t;try{t=decodeURIComponent(n)}catch{return null}return t.length===0||E.has(t)?null:t}function f(n){const t=/^\/workspace\/([^/?#]+)\/?(?:[?#].*)?$/.exec(n);return t?g(t[1]):null}function A(n){const t=/^\/workspace\/([^/?#]+)(?:[/?#].*)?$/.exec(n);return t?g(t[1]):null}function N(n,t){return t.length>0&&A(n)===t}function p(){return typeof window>"u"?null:window.location?.pathname??null}function d(n,t){const e=`/workspace/${encodeURIComponent(n)}`,a=t?new URLSearchParams(t).toString():"";return a?`${e}?${a}`:e}function R(n,t){const e=t?.presenceFollowRequestId;return e?w(n,e):w(n)}function I(n,t){return t?u(n,{state:t}):u(n)}function o(n){return n?.tabState?.currentTabId??null}async function S(n,t,e,a){m();const i=I(t,e),r={workspaceId:n,epoch:s(),startTabId:a};return await i,r}function y(n){return!n||W()}function b(n,t){if(s()!==n.epoch||t!==n.startTabId&&t!==n.workspaceId)return!1;const e=p();return e===null||f(e)===n.workspaceId}async function v(n,t,e){if(y(n))return!1;const a=await S(n,t,e,o(c.state));return b(a,o(c.state))?(c.dispatch(R(n,e)),!0):!1}function*k(n,t,e){if(y(n))return!1;const a=o(yield*h(r=>r)),i=yield*l(S,n,t,e,a);return b(i,o(yield*h(r=>r)))?(yield*T(R(n,e)),!0):!1}function P(){m();const n=s(),t=o(c.state),e=p();return()=>s()===n&&o(c.state)===t&&p()===e}function _(n,t={}){return v(n,d(n,t.query),t.state)}function O(n,t={}){return k(n,d(n,t.query),t.state)}async function $(n){const t=f(n);t?await v(t,n,void 0):await u(n)}function*j(n){const t=f(n);t?yield*l(k,t,n,void 0):yield*l(u,n)}const U=Object.freeze(Object.defineProperty({__proto__:null,claimNavigation:P,navigateToAppRoute:$,navigateToAppRouteSaga:j,openAndShowWorkspace:_,showWorkspaceSaga:O,workspaceRoute:d},Symbol.toStringTag,{value:"Module"}));export{p as a,j as b,P as c,O as d,d as e,N as i,$ as n,_ as o,f as p,U as s,A as w};
@@ -1,4 +1,4 @@
1
- var vo=Object.defineProperty;var bo=(e,t,i)=>t in e?vo(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i;var v=(e,t,i)=>bo(e,typeof t!="symbol"?t+"":t,i);import{t as ir,br as M,a_ as we,bz as nr,b as rr,bv as dn,bt as So,bp as $e}from"./CEL6QztG.js";import{bs as or,a5 as De,ay as hn,bS as Xe,aD as C,bA as ke,b_ as Me,bO as rt,W as le,bl as Xt,be as Hi,bn as sr,c9 as ne,aA as I,b$ as ar,aB as ge,ai as yo,bV as Te,br as Co,ca as je,bH as Y,c5 as dt,bk as xo,bj as Lo,aj as wo,c0 as fn}from"./DYhIMPy1.js";import{n as ko,p as Eo,v as un,w as pi,u as cn}from"./yn6WWSq8.js";import{b as Ro}from"./p7znhYIU.js";import{b as pn}from"./BaIAhI85.js";import{h as Ao,c as Ye,w as lr,N as O,O as Jt,b2 as Qe,a as dr,j as hr,P as Je,H as fr,i as ur,ab as cr,U as Ho,f as To,e as pr,T as Do,g as Mo,S as Io,a4 as Ze,a3 as Ve,C as Fo,G as gr,F as No,I as Po,A as At,ah as zo,$ as Ht,ad as Tt,v as St,a1 as Ti,s as J,r as Ue,an as wt,D as Uo,d as _o,aa as mr,b as gn,u as mn,aI as Oo,ap as ct,ac as Bo,K as Le,M as Ut,L as Vo,a0 as Dt,E as Wo,al as vr,a6 as Go,a2 as vn,t as br,af as ft,a5 as kt,ae as ot,ag as Sr,B as gi,a9 as mi,k as $o,aH as bn}from"./Csmv6l_s.js";import{F as vi,c3 as jo,be as qo,at as Ko,as as Xo}from"./DnKg2UsP.js";import{f as Di}from"./Cd_8r4jJ.js";import{g as Yo}from"./CcXckLs7.js";import{c as Qo}from"./D-Brs8OV.js";import{P as Jo}from"./CdYKja2-.js";import{t as Sn}from"./wwtnRh6M.js";class Zo extends Ao{constructor(){super(...arguments),this.tokenize=ts}equals(t,i,n){return n.ignoreWhitespace?((!n.newlineIsToken||!t.includes(`
1
+ var vo=Object.defineProperty;var bo=(e,t,i)=>t in e?vo(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i;var v=(e,t,i)=>bo(e,typeof t!="symbol"?t+"":t,i);import{t as ir,br as M,a_ as we,bz as nr,b as rr,bv as dn,bt as So,bp as $e}from"./CEL6QztG.js";import{bs as or,a5 as De,ay as hn,bS as Xe,aD as C,bA as ke,b_ as Me,bO as rt,W as le,bl as Xt,be as Hi,bn as sr,c9 as ne,aA as I,b$ as ar,aB as ge,ai as yo,bV as Te,br as Co,ca as je,bH as Y,c5 as dt,bk as xo,bj as Lo,aj as wo,c0 as fn}from"./DYhIMPy1.js";import{n as ko,p as Eo,v as un,w as pi,u as cn}from"./yn6WWSq8.js";import{b as Ro}from"./p7znhYIU.js";import{b as pn}from"./BaIAhI85.js";import{h as Ao,c as Ye,w as lr,N as O,O as Jt,b2 as Qe,a as dr,j as hr,P as Je,H as fr,i as ur,ab as cr,U as Ho,f as To,e as pr,T as Do,g as Mo,S as Io,a4 as Ze,a3 as Ve,C as Fo,G as gr,F as No,I as Po,A as At,ah as zo,$ as Ht,ad as Tt,v as St,a1 as Ti,s as J,r as Ue,an as wt,D as Uo,d as _o,aa as mr,b as gn,u as mn,aI as Oo,ap as ct,ac as Bo,K as Le,M as Ut,L as Vo,a0 as Dt,E as Wo,al as vr,a6 as Go,a2 as vn,t as br,af as ft,a5 as kt,ae as ot,ag as Sr,B as gi,a9 as mi,k as $o,aH as bn}from"./XTm8XS4k.js";import{F as vi,c3 as jo,be as qo,at as Ko,as as Xo}from"./DnKg2UsP.js";import{f as Di}from"./Cd_8r4jJ.js";import{g as Yo}from"./CcXckLs7.js";import{c as Qo}from"./D-Brs8OV.js";import{P as Jo}from"./BgVKKIhh.js";import{t as Sn}from"./wwtnRh6M.js";class Zo extends Ao{constructor(){super(...arguments),this.tokenize=ts}equals(t,i,n){return n.ignoreWhitespace?((!n.newlineIsToken||!t.includes(`
2
2
  `))&&(t=t.trim()),(!n.newlineIsToken||!i.includes(`
3
3
  `))&&(i=i.trim())):n.ignoreNewlineAtEof&&!n.newlineIsToken&&(t.endsWith(`
4
4
  `)&&(t=t.slice(0,-1)),i.endsWith(`
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["/app/immutable/chunks/DHtTqndc.js","/app/immutable/chunks/DYhIMPy1.js","/app/immutable/chunks/CEL6QztG.js","/app/immutable/chunks/CiSnSGvU.js","/app/immutable/chunks/DR_tn5Kl.js","/app/immutable/chunks/wwtnRh6M.js","/app/immutable/chunks/yn6WWSq8.js","/app/immutable/chunks/CIyUrgF0.js","/app/immutable/assets/spinner.D_TRo5Hy.css","/app/immutable/chunks/DYfeeu3f.js","/app/immutable/chunks/WFvSJ9zU.js","/app/immutable/chunks/ChTqQfQN.js","/app/immutable/chunks/66MF_whg.js","/app/immutable/chunks/DxwfiAWm.js","/app/immutable/chunks/uXuxG9cN.js","/app/immutable/chunks/CuEQVba7.js","/app/immutable/chunks/BaIAhI85.js","/app/immutable/chunks/Cd_8r4jJ.js","/app/immutable/chunks/B4USm-wY.js","/app/immutable/chunks/B5PFzC2T.js","/app/immutable/assets/button.-yaUNjRS.css","/app/immutable/chunks/DXDNvQ8c.js","/app/immutable/chunks/BAnLxjCI.js","/app/immutable/chunks/BCF9Fm7Q.js","/app/immutable/chunks/WAMpa_Dp.js","/app/immutable/chunks/DnKg2UsP.js","/app/immutable/chunks/CGjjowC8.js","/app/immutable/assets/menu-footer.Ck5GCpgU.css","/app/immutable/chunks/DfxQWSVU.js","/app/immutable/chunks/BYddvidz.js","/app/immutable/assets/dialog.BtQTVchw.css","/app/immutable/chunks/BsieX9dN.js","/app/immutable/assets/observe-overflow.CbDLK6fN.css","/app/immutable/chunks/BRmUBbbw.js","/app/immutable/chunks/q1Qi1tRJ.js","/app/immutable/chunks/Bsy-6OEk.js","/app/immutable/chunks/XJv96NUg.js","/app/immutable/assets/confirm.UE5obH5A.css","/app/immutable/chunks/BWYr8u9e.js","/app/immutable/chunks/BeP4UORy.js","/app/immutable/chunks/zKAv0Iid.js","/app/immutable/chunks/D-Brs8OV.js","/app/immutable/assets/SettingsPage.D8u26cHZ.css","/app/immutable/chunks/Dbpx98ZW.js","/app/immutable/chunks/CbM8k2mZ.js","/app/immutable/chunks/CC7to1B5.js","/app/immutable/chunks/Cn76YSbd.js","/app/immutable/assets/notify.BeL_JB6L.css","/app/immutable/chunks/BdWqymET.js","/app/immutable/chunks/BrhD-mFY.js","/app/immutable/chunks/Dml826jn.js","/app/immutable/chunks/DypB-Dwi.js","/app/immutable/chunks/CcXckLs7.js","/app/immutable/chunks/CsUbymBr.js","/app/immutable/chunks/hf8xs0et.js","/app/immutable/chunks/50HPeG9s.js","/app/immutable/chunks/C3cmIhWo.js","/app/immutable/chunks/pU8ZyAzb.js","/app/immutable/chunks/BvFAWM27.js","/app/immutable/chunks/JFKNrDCO.js","/app/immutable/chunks/DWDBvyQN.js","/app/immutable/chunks/BTgR8VBy.js","/app/immutable/chunks/Cs183jPX.js","/app/immutable/chunks/B0Z-1lwJ.js","/app/immutable/chunks/_DGkiSFo.js","/app/immutable/assets/directory-picker-service.CzNEA6Ot.css"])))=>i.map(i=>d[i]);
2
- import{bp as v,t as Wt,br as y,a_ as D,bz as Ut,b as qt,bs as Vf,bv as It,bt as oa,bu as _i,b7 as fl,bm as Kf,ba as Gf,bl as Jf,bb as Yf,bn as Xf,a$ as Zf,b9 as Qf,b8 as $f,b2 as ep,bf as tp,bg as rp,bk as np,be as ap,bo as sp,b0 as op,b4 as ip,bi as lp,bh as cp,b6 as dp,b5 as up,b3 as fp,bd as pp,bc as gp,bj as vp,b1 as mp,_ as hp}from"./CEL6QztG.js";import{bI as bp,bj as Es,aG as yp,bs as Vt,aD as e,a5 as I,bS as m,bA as w,W as d,bn as Kt,c9 as u,aA as _,a7 as kt,ay as We,be as rr,b$ as Rt,aC as xa,bl as M,b_ as k,bO as x,aB as S,bo as As,ca as St,bH as R,bV as he,br as Jr,bk as Ps,c0 as Xn,ai as Oa,cd as $a,aw as En,a as _p,aj as Lr,c7 as xp,c6 as pl,c5 as An,bf as Gs,bz as rd}from"./DYhIMPy1.js";import{G as ms,I as wp,z as kp}from"./CuEQVba7.js";import{o as Sp,i as Ip,u as se,g as Fn,w as Pn,l as xn,j as ir,v as vt,I as Ts,n as Tt,p as Mr,q as Cp,s as Ep,m as Ap,x as Pp}from"./yn6WWSq8.js";import{s as ln}from"./CiSnSGvU.js";import{c as en}from"./B4USm-wY.js";import{I as Ko,t as nr,n as Tp,i as gl,u as vl}from"./wwtnRh6M.js";import{b as mr}from"./BaIAhI85.js";import{i as nd,bv as Rp,cM as Mp,dG as Lp,ds as Np,ax as Op,cv as Dp,a2 as Bp,cS as Fp,dr as hs,aC as so,c3 as zp,I as Hp,a as jp,a0 as ml,cY as Wp,bT as Up,M as qp,dm as Vp,W as Kp,dx as Gp,af as Jp,at as Yp,g as Xp,u as Zp}from"./Dml826jn.js";import{c as Qp}from"./D-62MVd3.js";import{k as ra,w as $p,C as ad,c as eg,R as tg}from"./Cn76YSbd.js";import{f as yt,ap as Za,ai as rg,am as Go,bc as ng}from"./Cd_8r4jJ.js";import{ao as ag,ab as hl,$ as sg,aD as og,ac as ig,h as lg,ad as cg,aW as dg,I as ug,R as fg,au as pg,ah as gg,a0 as vg,a as bl,av as mg,s as hg,n as bg,b0 as yg,m as _g,b2 as Jo,A as yl,ag as xg,b1 as wg,aq as sd,T as od,a7 as kg,a6 as _l,V as Sg,L as xl}from"./CdYKja2-.js";import{F as At,bf as Yo,bJ as Ig,am as Cg,aO as Eg,cK as Ag,bj as xi,bz as Pg,aE as id,aJ as wi,cZ as Js,a9 as Xo,cm as Tg,cb as Rg,ch as ki,cE as ld,bq as Mg,e as Lg,bZ as wl,c7 as Ng,ck as Og,cV as cd,bT as kl,b6 as Io,bc as fs,aD as Dg,ax as Zo,as as dd,ba as ud,bA as Bg,B as Fg,bt as zg,a4 as fd,cf as Hg,aj as pd,cM as gd,cI as Sl,aq as vd,aI as Il,_ as jg,cu as Wg,cT as Ug,aH as qg,aZ as Vg,bM as md,bl as Kg,c3 as Cl,al as hd,aw as Gg,a7 as Jg,a5 as Yg}from"./DnKg2UsP.js";import{c as bd}from"./ChTqQfQN.js";import{g as Xg}from"./D-Brs8OV.js";import{Ik as Lt,bM as Zg,rQ as El,sq as Qg,J8 as $g,Je as ev,g as yd,HZ as tv,nw as _d,nM as xd,nL as wd,np as oo,p$ as Si,xP as rv,uT as js,ua as Qo,uV as nv,ne as kd,Ip as av,t5 as sv,oz as Sd,rc as Ii,lX as Al,a2 as Pl,qI as ov,qE as iv,qJ as lv,qA as cv,qG as dv,uJ as uv,Ak as Id,Ao as Cd,nN as Tl,be as $o,GI as fv,HV as pv,h9 as gv,h8 as vv,nH as mv,vU as hv,vV as bv,vT as Rl,Bk as Jn,cr as yv,cf as _v,d0 as xv,d7 as wv,Au as kv}from"./DYfeeu3f.js";import{bH as Sv,bQ as Iv,i as Cv,B as Ev,bT as Av,ah as Pv,aj as Tv,al as Rv,a5 as Mv,a4 as Lv}from"./50HPeG9s.js";import{n as Nv,m as Ov,v as ei,ck as Dv,M as Bv,ci as Fv,cb as zv,aD as Ml,cd as Hv,bM as ti,aN as jv,s as Wv,c as bs,d as ri,cf as Ed,cg as ni,bB as Uv,b6 as qv,bQ as Vv,bO as Kv,E as Gv,ce as Ll,bv as Jv,y as Yv}from"./BrhD-mFY.js";import{ch as Xv,cj as Zv,ci as Qv,b0 as $v,a_ as em,a$ as tm,a3 as rm,ak as Ds,aj as nm,az as Nl,aH as am,ai as sm,C as om,i as im,E as Ws,cS as lm,aV as Ol,cX as cm,af as dm,a7 as um,r as fm,p as pm,aE as gm,c_ as vm,cJ as mm,cC as hm,ct as bm,bR as ym}from"./BxvZVFA9.js";import{i as _m,I as es,c as Dl}from"./DXDNvQ8c.js";import"./BAnLxjCI.js";import{f as Bl,y as Fl,M as xm,n as wm,m as km,z as Ad,x as ai,e as ys,W as ts,h as Sm}from"./DHtTqndc.js";import"./Bsy-6OEk.js";import{b as Pd}from"./CbM8k2mZ.js";import"./BYddvidz.js";import{z as Ci,P as Im,p as Cm,h as Em,G as Am,l as Pm,i as Tm,M as Rm,H as Mm,t as Ya,a as Lm,K as Nm,k as Om,R as Dm}from"./BCF9Fm7Q.js";import{t as _s,O as Bm,M as Fm,S as ya}from"./WAMpa_Dp.js";import{a as zm}from"./CGjjowC8.js";import{C as si}from"./C3vze1oW.js";import{aQ as Hm,aY as jm,aB as Wm,b0 as Um,aO as qm,aU as Vm,a7 as ns,b3 as zl,aK as Km,aR as Gm,aX as Ei,aS as Ai,W as Co,aq as Jm,X as Ym,a_ as Xm,aJ as Zm,aT as Qm,aW as $m,b6 as eh,b4 as th,ay as Td,p as rh,n as nh,aV as ah,_ as sh,ao as oh,aD as ih,z as lh,aC as ch,a8 as dh}from"./Csmv6l_s.js";import{s as oi}from"./BIG-RqmD.js";import{M as uh}from"./DSLbxDPz.js";import{s as fh,a as ph}from"./BsieX9dN.js";import{u as Pi,w as gh,v as io,I as vh,A as Hl,e as xs,d as _a,J as jl,c as mh,f as hh,g as Wl,i as bh,b as yh,o as Rd,j as _h,O as xh,x as wh,k as Md,S as kh,N as Sh,q as Ul,p as Ih,n as ql,z as Ch,s as Eh}from"./C1z1LSy4.js";import{o as Vl,a as Kl,T as Eo,b as Ah}from"./D8q3b1Qj.js";import{O as Ph,y as Th,j as Rh,h as Mh,R as Lh}from"./T4aQylmi.js";import{D as ws}from"./yJ_FteZh.js";import"./DJuQfCSS.js";import{C as na}from"./B3icew6f.js";import{M as Nh}from"./DZTSivxP.js";import{g as Ti}from"./DR_tn5Kl.js";import{f as Gl}from"./DWDBvyQN.js";import{c as Us}from"./CV0Fs-12.js";import{handleIntentLink as Oh}from"./Dk8EoSv9.js";import{s as Dh,a as Bh,f as Fh,d as zh,r as Hh,h as jh,w as ps,g as Wh,W as Uh,H as qh,c as Vh,M as Ld}from"./zjjhmoCi.js";import{e as Kh,q as Gh}from"./C3cmIhWo.js";import{showAssistantContent as Jh}from"./BKPbHBoH.js";import{o as Ys,c as Yh,n as Xh}from"./_DGkiSFo.js";import{p as Zh}from"./DLf4QVoe.js";import{m as Qh}from"./-DqWFMjY.js";import{h as Bs}from"./DTClNSVs.js";import{i as Nd}from"./CsUbymBr.js";import{g as $h,e as eb,f as tb,h as rb}from"./BvFAWM27.js";import{T as Ao}from"./DZo9MSm2.js";import"./q1Qi1tRJ.js";import{i as nb,r as Jl}from"./B2jKM7_0.js";import{a as ab}from"./Dbpx98ZW.js";import{a as sb}from"./BdWqymET.js";import{p as ob}from"./Co_upWle.js";const ib="intent:inline-visual-draft";function dC(r,t){const n=t.title.replace(/\s+/g," ").trim(),a=JSON.stringify({inputs:t.inputs,results:t.results},null,2),s=(a.match(/`+/g)??[]).reduce((c,l)=>Math.max(c,l.length),0),o="`".repeat(Math.max(3,s+1));return`${r}${r?`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["/app/immutable/chunks/QGl-Xn9g.js","/app/immutable/chunks/DYhIMPy1.js","/app/immutable/chunks/CEL6QztG.js","/app/immutable/chunks/CiSnSGvU.js","/app/immutable/chunks/DR_tn5Kl.js","/app/immutable/chunks/wwtnRh6M.js","/app/immutable/chunks/yn6WWSq8.js","/app/immutable/chunks/CIyUrgF0.js","/app/immutable/assets/spinner.D_TRo5Hy.css","/app/immutable/chunks/DYfeeu3f.js","/app/immutable/chunks/WFvSJ9zU.js","/app/immutable/chunks/ChTqQfQN.js","/app/immutable/chunks/66MF_whg.js","/app/immutable/chunks/DxwfiAWm.js","/app/immutable/chunks/uXuxG9cN.js","/app/immutable/chunks/CuEQVba7.js","/app/immutable/chunks/BaIAhI85.js","/app/immutable/chunks/Cd_8r4jJ.js","/app/immutable/chunks/B4USm-wY.js","/app/immutable/chunks/B5PFzC2T.js","/app/immutable/assets/button.-yaUNjRS.css","/app/immutable/chunks/DXDNvQ8c.js","/app/immutable/chunks/BAnLxjCI.js","/app/immutable/chunks/BCF9Fm7Q.js","/app/immutable/chunks/WAMpa_Dp.js","/app/immutable/chunks/DnKg2UsP.js","/app/immutable/chunks/CGjjowC8.js","/app/immutable/assets/menu-footer.Ck5GCpgU.css","/app/immutable/chunks/DfxQWSVU.js","/app/immutable/chunks/BYddvidz.js","/app/immutable/assets/dialog.BtQTVchw.css","/app/immutable/chunks/BsieX9dN.js","/app/immutable/assets/observe-overflow.CbDLK6fN.css","/app/immutable/chunks/BRmUBbbw.js","/app/immutable/chunks/q1Qi1tRJ.js","/app/immutable/chunks/Bsy-6OEk.js","/app/immutable/chunks/XJv96NUg.js","/app/immutable/assets/confirm.UE5obH5A.css","/app/immutable/chunks/BWYr8u9e.js","/app/immutable/chunks/BeP4UORy.js","/app/immutable/chunks/zKAv0Iid.js","/app/immutable/chunks/D-Brs8OV.js","/app/immutable/assets/SettingsPage.D8u26cHZ.css","/app/immutable/chunks/Dbpx98ZW.js","/app/immutable/chunks/CbM8k2mZ.js","/app/immutable/chunks/CC7to1B5.js","/app/immutable/chunks/Cn76YSbd.js","/app/immutable/assets/notify.BeL_JB6L.css","/app/immutable/chunks/BdWqymET.js","/app/immutable/chunks/C43c9gOy.js","/app/immutable/chunks/Dml826jn.js","/app/immutable/chunks/DypB-Dwi.js","/app/immutable/chunks/CcXckLs7.js","/app/immutable/chunks/CsUbymBr.js","/app/immutable/chunks/hf8xs0et.js","/app/immutable/chunks/50HPeG9s.js","/app/immutable/chunks/C3cmIhWo.js","/app/immutable/chunks/pU8ZyAzb.js","/app/immutable/chunks/BvFAWM27.js","/app/immutable/chunks/DV0bJEUk.js","/app/immutable/chunks/seqIFXVs.js","/app/immutable/chunks/Ba_-F0B5.js","/app/immutable/chunks/fkBazoe-.js","/app/immutable/chunks/B0Z-1lwJ.js","/app/immutable/chunks/CldWVpJx.js","/app/immutable/assets/directory-picker-service.CzNEA6Ot.css"])))=>i.map(i=>d[i]);
2
+ import{bp as v,t as Wt,br as y,a_ as D,bz as Ut,b as qt,bs as Vf,bv as It,bt as oa,bu as _i,b7 as fl,bm as Kf,ba as Gf,bl as Jf,bb as Yf,bn as Xf,a$ as Zf,b9 as Qf,b8 as $f,b2 as ep,bf as tp,bg as rp,bk as np,be as ap,bo as sp,b0 as op,b4 as ip,bi as lp,bh as cp,b6 as dp,b5 as up,b3 as fp,bd as pp,bc as gp,bj as vp,b1 as mp,_ as hp}from"./CEL6QztG.js";import{bI as bp,bj as Es,aG as yp,bs as Vt,aD as e,a5 as I,bS as m,bA as w,W as d,bn as Kt,c9 as u,aA as _,a7 as kt,ay as We,be as rr,b$ as Rt,aC as xa,bl as M,b_ as k,bO as x,aB as S,bo as As,ca as St,bH as R,bV as he,br as Jr,bk as Ps,c0 as Xn,ai as Oa,cd as $a,aw as En,a as _p,aj as Lr,c7 as xp,c6 as pl,c5 as An,bf as Gs,bz as rd}from"./DYhIMPy1.js";import{G as ms,I as wp,z as kp}from"./CuEQVba7.js";import{o as Sp,i as Ip,u as se,g as Fn,w as Pn,l as xn,j as ir,v as vt,I as Ts,n as Tt,p as Mr,q as Cp,s as Ep,m as Ap,x as Pp}from"./yn6WWSq8.js";import{s as ln}from"./CiSnSGvU.js";import{c as en}from"./B4USm-wY.js";import{I as Ko,t as nr,n as Tp,i as gl,u as vl}from"./wwtnRh6M.js";import{b as mr}from"./BaIAhI85.js";import{i as nd,bv as Rp,cM as Mp,dG as Lp,ds as Np,ax as Op,cv as Dp,a2 as Bp,cS as Fp,dr as hs,aC as so,c3 as zp,I as Hp,a as jp,a0 as ml,cY as Wp,bT as Up,M as qp,dm as Vp,W as Kp,dx as Gp,af as Jp,at as Yp,g as Xp,u as Zp}from"./Dml826jn.js";import{c as Qp}from"./D-62MVd3.js";import{k as ra,w as $p,C as ad,c as eg,R as tg}from"./Cn76YSbd.js";import{f as yt,ap as Za,ai as rg,am as Go,bc as ng}from"./Cd_8r4jJ.js";import{ao as ag,ab as hl,$ as sg,aD as og,ac as ig,h as lg,ad as cg,aW as dg,I as ug,R as fg,au as pg,ah as gg,a0 as vg,a as bl,av as mg,s as hg,n as bg,b0 as yg,m as _g,b2 as Jo,A as yl,ag as xg,b1 as wg,aq as sd,T as od,a7 as kg,a6 as _l,V as Sg,L as xl}from"./BgVKKIhh.js";import{F as At,bf as Yo,bJ as Ig,am as Cg,aO as Eg,cK as Ag,bj as xi,bz as Pg,aE as id,aJ as wi,cZ as Js,a9 as Xo,cm as Tg,cb as Rg,ch as ki,cE as ld,bq as Mg,e as Lg,bZ as wl,c7 as Ng,ck as Og,cV as cd,bT as kl,b6 as Io,bc as fs,aD as Dg,ax as Zo,as as dd,ba as ud,bA as Bg,B as Fg,bt as zg,a4 as fd,cf as Hg,aj as pd,cM as gd,cI as Sl,aq as vd,aI as Il,_ as jg,cu as Wg,cT as Ug,aH as qg,aZ as Vg,bM as md,bl as Kg,c3 as Cl,al as hd,aw as Gg,a7 as Jg,a5 as Yg}from"./DnKg2UsP.js";import{c as bd}from"./ChTqQfQN.js";import{g as Xg}from"./D-Brs8OV.js";import{Ik as Lt,bM as Zg,rQ as El,sq as Qg,J8 as $g,Je as ev,g as yd,HZ as tv,nw as _d,nM as xd,nL as wd,np as oo,p$ as Si,xP as rv,uT as js,ua as Qo,uV as nv,ne as kd,Ip as av,t5 as sv,oz as Sd,rc as Ii,lX as Al,a2 as Pl,qI as ov,qE as iv,qJ as lv,qA as cv,qG as dv,uJ as uv,Ak as Id,Ao as Cd,nN as Tl,be as $o,GI as fv,HV as pv,h9 as gv,h8 as vv,nH as mv,vU as hv,vV as bv,vT as Rl,Bk as Jn,cr as yv,cf as _v,d0 as xv,d7 as wv,Au as kv}from"./DYfeeu3f.js";import{bH as Sv,bQ as Iv,i as Cv,B as Ev,bT as Av,ah as Pv,aj as Tv,al as Rv,a5 as Mv,a4 as Lv}from"./50HPeG9s.js";import{n as Nv,m as Ov,v as ei,ck as Dv,M as Bv,ci as Fv,cb as zv,aD as Ml,cd as Hv,bM as ti,aN as jv,s as Wv,c as bs,d as ri,cf as Ed,cg as ni,bB as Uv,b6 as qv,bQ as Vv,bO as Kv,E as Gv,ce as Ll,bv as Jv,y as Yv}from"./C43c9gOy.js";import{ch as Xv,cj as Zv,ci as Qv,b0 as $v,a_ as em,a$ as tm,a3 as rm,ak as Ds,aj as nm,az as Nl,aH as am,ai as sm,C as om,i as im,E as Ws,cS as lm,aV as Ol,cX as cm,af as dm,a7 as um,r as fm,p as pm,aE as gm,c_ as vm,cJ as mm,cC as hm,ct as bm,bR as ym}from"./qS-FFtmP.js";import{i as _m,I as es,c as Dl}from"./DXDNvQ8c.js";import"./BAnLxjCI.js";import{f as Bl,y as Fl,M as xm,n as wm,m as km,z as Ad,x as ai,e as ys,W as ts,h as Sm}from"./QGl-Xn9g.js";import"./Bsy-6OEk.js";import{b as Pd}from"./CbM8k2mZ.js";import"./BYddvidz.js";import{z as Ci,P as Im,p as Cm,h as Em,G as Am,l as Pm,i as Tm,M as Rm,H as Mm,t as Ya,a as Lm,K as Nm,k as Om,R as Dm}from"./BCF9Fm7Q.js";import{t as _s,O as Bm,M as Fm,S as ya}from"./WAMpa_Dp.js";import{a as zm}from"./CGjjowC8.js";import{C as si}from"./C3vze1oW.js";import{aQ as Hm,aY as jm,aB as Wm,b0 as Um,aO as qm,aU as Vm,a7 as ns,b3 as zl,aK as Km,aR as Gm,aX as Ei,aS as Ai,W as Co,aq as Jm,X as Ym,a_ as Xm,aJ as Zm,aT as Qm,aW as $m,b6 as eh,b4 as th,ay as Td,p as rh,n as nh,aV as ah,_ as sh,ao as oh,aD as ih,z as lh,aC as ch,a8 as dh}from"./XTm8XS4k.js";import{s as oi}from"./81XDh255.js";import{M as uh}from"./DSLbxDPz.js";import{s as fh,a as ph}from"./BsieX9dN.js";import{u as Pi,w as gh,v as io,I as vh,A as Hl,e as xs,d as _a,J as jl,c as mh,f as hh,g as Wl,i as bh,b as yh,o as Rd,j as _h,O as xh,x as wh,k as Md,S as kh,N as Sh,q as Ul,p as Ih,n as ql,z as Ch,s as Eh}from"./LyXMg8Qe.js";import{o as Vl,a as Kl,T as Eo,b as Ah}from"./C4HlRcUf.js";import{O as Ph,y as Th,j as Rh,h as Mh,R as Lh}from"./T4aQylmi.js";import{D as ws}from"./ClsZKLeX.js";import"./DJuQfCSS.js";import{C as na}from"./C4twHGiQ.js";import{M as Nh}from"./C9HiWs7H.js";import{g as Ti}from"./DR_tn5Kl.js";import{f as Gl}from"./seqIFXVs.js";import{c as Us}from"./CV0Fs-12.js";import{handleIntentLink as Oh}from"./Dyka1Qt_.js";import{s as Dh,a as Bh,f as Fh,d as zh,r as Hh,h as jh,w as ps,g as Wh,W as Uh,H as qh,c as Vh,M as Ld}from"./62Ck3yAT.js";import{e as Kh,q as Gh}from"./C3cmIhWo.js";import{showAssistantContent as Jh}from"./gZgaz0G2.js";import{o as Ys,c as Yh,n as Xh}from"./CldWVpJx.js";import{p as Zh}from"./BqZYZkSb.js";import{m as Qh}from"./-DqWFMjY.js";import{h as Bs}from"./DTClNSVs.js";import{i as Nd}from"./CsUbymBr.js";import{g as $h,e as eb,f as tb,h as rb}from"./BvFAWM27.js";import{T as Ao}from"./DZo9MSm2.js";import"./q1Qi1tRJ.js";import{i as nb,r as Jl}from"./Dqj_x1iH.js";import{a as ab}from"./Dbpx98ZW.js";import{a as sb}from"./BdWqymET.js";import{p as ob}from"./DwGXL-qt.js";const ib="intent:inline-visual-draft";function dC(r,t){const n=t.title.replace(/\s+/g," ").trim(),a=JSON.stringify({inputs:t.inputs,results:t.results},null,2),s=(a.match(/`+/g)??[]).reduce((c,l)=>Math.max(c,l.length),0),o="`".repeat(Math.max(3,s+1));return`${r}${r?`
3
3
 
4
4
  `:""}${n}
5
5
 
@@ -260,7 +260,7 @@ ${r.content}`:a.content=r.content,a):r.old_text!==void 0&&r.new_text!==void 0?(a
260
260
  `,b0=["background","foreground","card","card-foreground","primary","primary-ink","primary-foreground","secondary","secondary-foreground","muted","muted-foreground","border","input","ring","danger","danger-background","info","info-foreground","success","success-foreground","warning","warning-foreground","font-ui","font-code","text-body-size","text-body-line-height","text-body-weight","text-body-tracking","radius-small","radius-medium","radius-large","app-background","sidebar","sidebar-accent","agent-avatar-surface-active","agent-avatar-foreground","diagram-host-surface","diagram-canvas","diagram-label-surface","diagram-node-surface","diagram-node-hover-surface","diagram-node-outline","diagram-node-title","diagram-metadata","diagram-group-outline","diagram-connector","diagram-connector-hover","diagram-connector-muted","diagram-connector-inactive","diagram-connector-danger","diagram-connector-success","diagram-connector-warning","diagram-connector-active","diagram-accent","diagram-accent-foreground","diagram-node-radius","diagram-group-radius","diagram-connector-width","text-caption-size","text-caption-line-height","text-caption-weight","text-caption-tracking","text-body-strong-size","text-body-strong-line-height","text-body-strong-weight","text-body-strong-tracking","space-1","space-2","space-3","space-4","space-5","space-6","space-7","control-height-compact","control-height-small","control-height-medium","control-height-large","radius-full","spring-fast","spring-fast-exit","spring-fast-ease","spring-moderate","spring-moderate-exit","spring-moderate-ease","spring-slow","spring-slow-exit","spring-slow-ease","spring-exit-ease","motion-fast","motion-standard","motion-slow","ease-standard","ease-emphasized-out","motion-reduced"],jo=96,Bc=2e4,y0=480,ju=512,_0=["default-src 'none'","script-src 'unsafe-inline'","style-src 'unsafe-inline'","img-src data:","connect-src 'none'","font-src data:","media-src 'none'","object-src 'none'","frame-src 'none'","child-src 'none'","worker-src 'none'","manifest-src 'none'","base-uri 'none'","form-action 'none'"].join("; ");function x0(r,t,n,a,s,o){const c=new MessageChannel,l=MessagePort.prototype.postMessage.bind(c.port1);window.parent.postMessage({channel:r,type:"scroll-port"},"*",[c.port2]);const f=(E,z={})=>{window.parent.postMessage({channel:r,type:E,...z},"*")};let i=s?.state??null,p=null,g=!1;Object.defineProperty(window,"intentVisual",{configurable:!1,writable:!1,value:Object.freeze({get state(){return i},publish(E){try{if(!o(E))return!1;const z=JSON.parse(JSON.stringify(E));return i=z.state,p=z,g||(g=!0,requestAnimationFrame(()=>{g=!1,p&&f("snapshot",{snapshot:p}),p=null})),!0}catch{return!1}}})});let T=!1,b=-1,h=innerHeight,A=Number.NaN,P=0,F=0;const B=()=>{if(T=!1,!document.body)return;let E=Math.ceil(Math.max(document.body.scrollHeight,document.body.getBoundingClientRect().height));const z=innerHeight,G=E-z;if(z>h+1&&G>1&&Math.abs(G-A)<=1?P+=1:(z!==h||G<=1)&&(P=0),h=z,A=G,!F&&P>=3){F=Math.max(a,z);const Y="Page height follows the frame (vh units or height: 100%); frame height held.";console.warn(Y),f("layout",{message:Y})}F&&(E=Math.min(E,F)),E!==b&&(b=E,f("resize",{height:E}))},O=()=>{T||(T=!0,requestAnimationFrame(B))},N=E=>{if(!E||typeof E.dark!="boolean"||!E.variables)return;const z=document.documentElement;z.classList.toggle("dark",E.dark),z.style.colorScheme=E.dark?"dark":"light";const G=E.variables["--inline-html-root-font-size"];"--inline-html-root-font-size"in t.variables&&typeof G=="string"&&G.length<512&&z.style.setProperty("--inline-html-root-font-size",G);for(const Y of Object.keys(t.variables)){if(Y==="--inline-html-root-font-size")continue;const Z=E.variables[Y];typeof Z=="string"&&Z.length<512&&z.style.setProperty(Y,Z)}O()};window.addEventListener("message",E=>{E.source!==window.parent||!E.data||E.data.channel!==r||E.data.type==="theme"&&N(E.data.theme)});const W=E=>{if(E.defaultPrevented||!E.isTrusted||E.ctrlKey||E.metaKey||E.shiftKey||!E.deltaY||Math.abs(E.deltaX)>Math.abs(E.deltaY))return;const z=Z=>{const Ce=getComputedStyle(Z);if(Z!==document.scrollingElement&&!/^(auto|scroll|overlay)$/.test(Ce.overflowY)||/^(hidden|clip)$/.test(Ce.overflowY))return!1;const le=Z.scrollHeight-Z.clientHeight;return le>1&&(E.deltaY<0?Z.scrollTop>1:Z.scrollTop<le-1)};if(E.composedPath().some(Z=>Z instanceof Element&&z(Z))||document.scrollingElement&&z(document.scrollingElement))return;const G=E.deltaMode===WheelEvent.DOM_DELTA_LINE?parseFloat(getComputedStyle(document.body).lineHeight)||16:E.deltaMode===WheelEvent.DOM_DELTA_PAGE?innerHeight:1,Y=Math.max(-n,Math.min(n,E.deltaY*G));Number.isFinite(Y)&&(E.preventDefault(),l({deltaY:Y}))};window.addEventListener("wheel",()=>{window.removeEventListener("wheel",W),window.addEventListener("wheel",W,{passive:!1})},{capture:!0,passive:!1}),window.addEventListener("error",E=>{E.message&&f("error",{message:E.message.slice(0,300)})}),window.addEventListener("unhandledrejection",E=>{const z=E.reason;f("error",{message:String(z instanceof Error?z.message:z).slice(0,300)})}),window.addEventListener("click",E=>{const z=E.target instanceof Element?E.target.closest("a, area"):null;if(!z)return;(z.getAttribute("href")??z.getAttribute("xlink:href"))?.startsWith("#")||E.preventDefault()},!0),window.addEventListener("submit",E=>E.preventDefault(),!0),N(t),window.addEventListener("DOMContentLoaded",()=>{new ResizeObserver(O).observe(document.body),new MutationObserver(O).observe(document.body,{childList:!0,subtree:!0,attributes:!0,characterData:!0}),window.addEventListener("resize",O),document.addEventListener("load",O,!0),document.fonts.ready.then(O),f("ready"),O()},{once:!0})}function w0(r,t,n,a,s){const o=document.createElement("iframe");o.setAttribute("sandbox","allow-scripts"),o.setAttribute("referrerpolicy","no-referrer"),o.title=n,o.style.cssText="display:block;width:100%;height:100%;border:0;";let c;const l=f=>{const i=f.data?.deltaY;typeof i=="number"&&Number.isFinite(i)&&i!==0&&Math.abs(i)<=a&&window.parent.postMessage({channel:r,type:"wheel",deltaY:i},"*")};window.addEventListener("message",f=>{const i=f.data;if(!(!i||typeof i!="object"||i.channel!==r)){if(f.source===window.parent&&i.type==="theme"){o.contentWindow?.postMessage({channel:r,type:"theme",theme:i.theme},"*");return}if(!(f.source!==o.contentWindow||f.origin!=="null")){if(i.type==="scroll-port"&&!c&&f.ports.length===1){c=f.ports[0],c.onmessage=l;return}i.type==="resize"&&typeof i.height=="number"&&Number.isFinite(i.height)&&i.height>=0?window.parent.postMessage({channel:r,type:"resize",height:i.height},"*"):i.type==="ready"?window.parent.postMessage({channel:r,type:"ready"},"*"):(i.type==="error"||i.type==="layout")&&typeof i.message=="string"?window.parent.postMessage({channel:r,type:i.type,message:i.message.slice(0,300)},"*"):i.type==="snapshot"&&s(i.snapshot)&&window.parent.postMessage({channel:r,type:"snapshot",snapshot:i.snapshot},"*")}}}),window.addEventListener("DOMContentLoaded",()=>{o.srcdoc=t,document.body.append(o)},{once:!0})}function k0(r,t,n,a,s,o,c,l){const f=document.implementation.createHTMLDocument(""),i=f.createElement("template");i.innerHTML=n,f.body.append(i.content);const p=Y=>{Y.querySelectorAll("meta, base, link, iframe, frame, frameset, object, embed").forEach(Z=>Z.remove()),Y.querySelectorAll("template").forEach(Z=>p(Z.content)),Y.querySelectorAll("a, area").forEach(Z=>{for(const Ce of["href","xlink:href"])Z.getAttribute(Ce)?.startsWith("#")||Z.removeAttribute(Ce);Z.removeAttribute("target"),Z.removeAttribute("ping"),Z.removeAttribute("download")})};p(f);const g=Y=>JSON.stringify(Y).replace(/</g,"\\u003c"),T=f.createElement("meta");T.httpEquiv="Content-Security-Policy",T.content=r.csp;const b=f.createElement("meta");b.setAttribute("charset","utf-8");const h=f.createElement("style"),A=/^data:[\w.+/-]+;base64,[A-Za-z0-9+/=]+$/.test(l)?`@font-face { font-family: 'Inter'; font-style: normal; font-weight: 100 900;
261
261
  font-display: swap; src: url('${l}') format('woff2'); }`:"";h.textContent=`${A}${r.styles}`;const P=f.createElement("script"),F=g([a,s,r.maxScrollDelta,r.lockHeight,t(c)?c:null]);P.textContent=`(${r.bridge})(...${F}, (${r.validate}));`,f.head.prepend(T,b,h,P);const B=`<!doctype html>${f.documentElement.outerHTML}`,O=document.implementation.createHTMLDocument(""),N=O.createElement("meta");N.httpEquiv="Content-Security-Policy",N.content=r.csp.replace("frame-src 'none'","frame-src about:");const W=O.createElement("meta");W.setAttribute("charset","utf-8");const E=O.createElement("style");E.textContent="html, body { margin: 0; width: 100%; height: 100%; overflow: hidden; }";const z=O.createElement("script"),G=g([a,B,o,r.maxScrollDelta]);return z.textContent=`(${r.shell})(...${G}, (${r.validate}));`,O.head.prepend(N,W,E,z),`<!doctype html>${O.documentElement.outerHTML}`}const S0=()=>({csp:_0,styles:h0,maxScrollDelta:ju,lockHeight:y0,bridge:x0.toString(),shell:w0.toString(),validate:Ii.toString()});function I0(r,t,n,a,s=null,o=""){return k0(S0(),Ii,r,t,n,a,s,o)}function Fc(r){const t=getComputedStyle(r);return{dark:document.documentElement.classList.contains("dark"),variables:{...Object.fromEntries(b0.map(n=>[`--${n}`,t.getPropertyValue(`--${n}`).trim()])),"--inline-html-root-font-size":getComputedStyle(document.documentElement).fontSize}}}function C0(r,t,n,a,s=null){return I0(r,t,n,a,s,m0)}var E0=S('<p class="type-caption m-0 break-words px-4 pb-2 text-muted-foreground"> </p>'),A0=S('<div class="type-body flex items-center justify-between gap-3 px-4 py-2" role="status"><span class="text-danger"> </span> <!></div> <!>',1),P0=S('<p class="sr-only" role="status"> </p>'),T0=S('<p class="type-body m-0 px-4 py-3 text-muted-foreground" role="status"> </p>'),R0=S('<div class="type-body px-4 py-2 text-danger" role="status"><p class="m-0"> </p> <p class="type-code m-0 break-words"> </p></div>'),M0=S('<iframe sandbox="allow-scripts" referrerpolicy="no-referrer"></iframe>'),L0=S('<div class="space-y-4 p-4" aria-hidden="true"><div class="space-y-2"><!> <!></div> <!> <div class="flex items-center gap-4"><!> <!> <!></div></div>'),N0=S('<span class="type-caption ml-auto text-muted-foreground" role="status"> </span>'),O0=S('<p class="type-caption m-0 break-words px-4 pb-2 text-muted-foreground" role="status"> <!></p>'),D0=S('<th class="min-w-40 px-2 pb-3 align-top font-normal"><!> <div class="mt-1 flex gap-1"><!> <!></div></th>'),B0=S('<td class="max-w-56 px-2 py-2 align-top break-words tabular-nums"> </td>'),F0=S('<tr><th class="max-w-48 py-2 pr-4 align-top font-normal break-words text-muted-foreground"> </th><!></tr>'),z0=S('<div class="overflow-x-auto px-4 pb-4" data-inline-visual-comparison=""><table class="type-body w-full border-separate border-spacing-0 text-left"><thead><tr><th class="min-w-28 pr-4 pb-3 font-normal text-muted-foreground"> </th><th class="min-w-32 px-2 pb-3 align-top font-medium"> </th><!></tr></thead><tbody></tbody></table></div>'),H0=S('<div class="flex flex-wrap items-center gap-1 px-4 py-2" data-inline-visual-actions=""><!> <!> <!> <!> <!></div> <!> <!>',1),j0=S('<div data-inline-html="" class="my-3 min-w-0 overflow-hidden rounded-lg bg-background text-foreground"><div class="flex min-w-0 items-center justify-end gap-1 p-1"><!> <!></div> <!> <!> <div class="relative min-w-0"><!> <!></div> <!></div>');function Wu(r,t){if(new.target)return Wt({component:Wu,...r});Vt(t,!0);const n=720,a=1e4;let s=y(t,"source",7),o=y(t,"isStreaming",7,!1),c=y(t,"isComplete",7,!0),l=y(t,"record",7),f=y(t,"storageStatus",7,"ready"),i=y(t,"onRecordChange",7),p=y(t,"onUseConfiguration",7),g=y(t,"onExport",7),T=y(t,"onRetry",7),b=y(t,"storageError",7),h=y(t,"exportStatus",7),A=y(t,"exportPath",7),P=y(t,"exportError",7),F,B=he(void 0),O=he(!1),N=he(!1),W=he(0),E=he(""),z=he(""),G=he(!1),Y=he(""),Z=he(Jr(jo)),Ce=he(n),le=he(""),ue=he(Al()),ie=he(void 0),Se,J=he(void 0),be=he(!1);const Q=u(()=>l()??e(ue)),je=u(()=>f()!=="loading"&&(f()!=="error"||!!e(Q).current)),Ie=u(()=>!o()&&c()&&!!s().trim()&&e(je)),xe=u(()=>Math.min(Bc,Math.max(jo,e(Z)))),we=u(()=>o()||f()==="loading"?"loading":c()?s().trim()?e(Y)?"error":e(G)?"ready":"loading":"empty":"incomplete"),Ue=u(()=>o()||f()==="loading"||e(Ie)&&!e(G)&&!e(Y));function Be(ne){const Te={...ne,current:e(ie)??ne.current};R(ue,Te),i()?.(Te)}function oe(){const ne=e(ie);!ne||e(Q).scenarios.length>=Pl||(Be({...e(Q),scenarios:[...e(Q).scenarios,{id:crypto.randomUUID(),name:np({number:vl(e(Q).scenarios.length+1)}),snapshot:structuredClone(ne)}]}),R(be,!0))}function $(ne,Te){const nt=Te.trim().slice(0,120);nt&&Be({...e(Q),scenarios:e(Q).scenarios.map(ut=>ut.id===ne?{...ut,name:nt}:ut)})}function Je(ne){const Te=structuredClone(ne);R(ie,Te),R(J,Te),Be({...e(Q),current:Te}),R(W,e(W)+1)}function V(ne){return typeof ne=="number"?vl(ne):typeof ne=="string"?ne:JSON.stringify(ne)}function K(){!e(B)?.contentWindow||!e(z)||e(B).contentWindow.postMessage({channel:e(z),type:"theme",theme:Fc(F)},"*")}function U(ne){let Te=F.parentElement;for(;Te;){const nt=getComputedStyle(Te),ut=Te.scrollHeight-Te.clientHeight;if(/^(auto|scroll|overlay)$/.test(nt.overflowY)&&ut>1){if(ne<0?Te.scrollTop>0:Te.scrollTop<ut){Te.dispatchEvent(new WheelEvent("wheel",{deltaY:ne,bubbles:!0})),Te.scrollTop+=ne;return}if(/^(contain|none)$/.test(nt.overscrollBehaviorY))return}Te=Te.parentElement}window.scrollBy({top:ne,behavior:"instant"})}St(()=>{if(!e(O))return;const ne=s(),Te=e(Ie);e(W),An(()=>{Se!==ne&&(R(ue,Al()),R(ie,void 0),R(be,!1),R(J,void 0),Se=ne),R(G,!1),R(Y,""),R(le,""),R(Z,jo,!0),R(z,crypto.randomUUID(),!0),R(E,Te?C0(ne,e(z),Fc(F),fl(),e(J)??e(ie)??e(Q).current):"",!0),R(J,void 0)})}),St(()=>{if(!e(E)||e(G)||e(Y))return;const ne=setTimeout(()=>{R(Y,Kf(),!0)},a);return()=>clearTimeout(ne)}),Ps(()=>{R(O,!0);const ne=Ze=>{if(Ze.source!==e(B)?.contentWindow||Ze.origin!=="null")return;const rt=Ze.data;if(!(!rt||typeof rt!="object"||rt.channel!==e(z))){if(rt.type==="bootstrap"){e(B)?.contentWindow?.postMessage({channel:e(z),type:"initialize",documentHtml:e(E)},"*");return}if(rt.type==="resize"&&typeof rt.height=="number"&&Number.isFinite(rt.height)&&rt.height>=0)R(Z,Math.min(Bc,Math.ceil(rt.height)),!0);else if(rt.type==="ready")R(G,!0),K();else if(rt.type==="error"&&typeof rt.message=="string")R(Y,rt.message.slice(0,300),!0);else if(rt.type==="layout"&&typeof rt.message=="string")R(le,rt.message.slice(0,300),!0);else if(rt.type==="snapshot"&&e(Ie)&&Ii(rt.snapshot)){const at=rt.snapshot;R(ie,at),Be({...e(Q),current:at})}else rt.type==="wheel"&&e(G)&&e(Ie)&&!e(N)&&!e(Ue)&&typeof rt.deltaY=="number"&&Number.isFinite(rt.deltaY)&&rt.deltaY!==0&&Math.abs(rt.deltaY)<=ju&&U(rt.deltaY)}},Te=()=>{R(Ce,Math.min(n,Math.max(160,Math.floor(window.innerHeight*.8))),!0)},nt=new MutationObserver(K);nt.observe(document.documentElement,{attributes:!0,attributeFilter:["class","style","data-theme"]});const ut=window.matchMedia("(prefers-color-scheme: dark)");return ut.addEventListener("change",K),window.addEventListener("message",ne),window.addEventListener("resize",Te),Te(),()=>{nt.disconnect(),ut.removeEventListener("change",K),window.removeEventListener("message",ne),window.removeEventListener("resize",Te)}});var ce={get source(){return s()},set source(ne){s(ne),_()},get isStreaming(){return o()},set isStreaming(ne=!1){o(ne),_()},get isComplete(){return c()},set isComplete(ne=!0){c(ne),_()},get record(){return l()},set record(ne){l(ne),_()},get storageStatus(){return f()},set storageStatus(ne="ready"){f(ne),_()},get onRecordChange(){return i()},set onRecordChange(ne){i(ne),_()},get onUseConfiguration(){return p()},set onUseConfiguration(ne){p(ne),_()},get onExport(){return g()},set onExport(ne){g(ne),_()},get onRetry(){return T()},set onRetry(ne){T(ne),_()},get storageError(){return b()},set storageError(ne){b(ne),_()},get exportStatus(){return h()},set exportStatus(ne){h(ne),_()},get exportPath(){return A()},set exportPath(ne){A(ne),_()},get exportError(){return P()},set exportError(ne){P(ne),_()},$set:Ut,$on:(ne,Te)=>qt(t,ne,Te)},_e=j0(),X=I(_e),de=I(X);yt(de,{variant:"ghost",size:"sm",get active(){return e(N)},get"aria-pressed"(){return e(N)},onclick:()=>{R(N,!e(N))},children:(ne,Te)=>{rr();var nt=Rt();k(ut=>x(nt,ut),[()=>e(N)?Gf():Jf()]),d(ne,nt)},$$slots:{default:!0}});var Pe=m(de,2);{let ne=u(()=>!e(Ie));yt(Pe,{variant:"ghost",size:"sm",get disabled(){return e(ne)},onclick:()=>{R(W,e(W)+1)},children:(Te,nt)=>{rr();var ut=Rt();k(Ze=>x(ut,Ze),[()=>Yf()]),d(Te,ut)},$$slots:{default:!0}})}w(X);var Fe=m(X,2);{var tt=ne=>{var Te=A0(),nt=We(Te),ut=I(nt),Ze=M(ut,!0),rt=m(ut,2);{var at=Nt=>{yt(Nt,{variant:"ghost",size:"sm",get onclick(){return T()},children:(Dt,Yt)=>{rr();var _t=Rt();k(Ht=>x(_t,Ht),[()=>ap()]),d(Dt,_t)},$$slots:{default:!0}})};D(rt,Nt=>{T()&&Nt(at)})}w(nt);var it=m(nt,2);{var gt=Nt=>{var Dt=E0(),Yt=M(Dt,!0);k(()=>x(Yt,b())),d(Nt,Dt)};D(it,Nt=>{b()&&Nt(gt)})}k(Nt=>x(Ze,Nt),[()=>Xf()]),d(ne,Te)};D(Fe,ne=>{f()==="error"&&ne(tt)})}var pe=m(Fe,2);{var Le=ne=>{var Te=P0(),nt=M(Te,!0);k(ut=>x(nt,ut),[()=>o()?Zf():Qf()]),d(ne,Te)},q=ne=>{var Te=T0(),nt=M(Te,!0);k(ut=>x(nt,ut),[()=>c()?ep():$f()]),d(ne,Te)},Ne=ne=>{var Te=R0(),nt=I(Te),ut=M(nt,!0),Ze=m(nt,2),rt=M(Ze,!0);w(Te),k(at=>{x(ut,at),x(rt,e(Y))},[()=>tp()]),d(ne,Te)};D(pe,ne=>{e(Ue)?ne(Le):e(Ie)?e(Y)&&ne(Ne,2):ne(q,1)})}var ge=m(pe,2),L=I(ge);{var H=ne=>{var Te=kt(),nt=We(Te);ms(nt,()=>e(z),ut=>{var Ze=M0();let rt,at;mr(Ze,it=>R(B,it),()=>e(B)),k(it=>{se(Ze,"title",it),se(Ze,"src",`/inline-html-sandbox.html#${e(z)}`),rt=vt(Ze,1,"block w-full border-0 svelte-1kkow1d",null,rt,{"preview-hidden":e(N)||!e(G)}),se(Ze,"aria-hidden",e(N)||!e(G)),at=Pn(Ze,"",at,{height:`${e(xe)}px`})},[()=>fl()]),d(ut,Ze)}),d(ne,Te)};D(L,ne=>{e(Ie)&&e(E)&&ne(H)})}var ve=m(L,2);{var Xe=ne=>{na(ne,{get code(){return s()},language:"html",noBorder:!0,noMargin:!0,get maxHeight(){return e(Ce)}})},Ee=ne=>{var Te=L0(),nt=I(Te),ut=I(nt);Ya(ut,{class:"h-4 w-32 max-w-1/2"});var Ze=m(ut,2);Ya(Ze,{class:"h-3 w-2/3"}),w(nt);var rt=m(nt,2);Ya(rt,{class:"aspect-video max-h-60 w-full rounded-lg"});var at=m(rt,2),it=I(at);Ya(it,{class:"h-3 w-16"});var gt=m(it,2);Ya(gt,{class:"h-2 min-w-0 flex-1"});var Nt=m(gt,2);Ya(Nt,{class:"h-3 w-10"}),w(at),w(Te),d(ne,Te)};D(ve,ne=>{e(N)?ne(Xe):e(Ue)&&ne(Ee,1)})}w(ge);var ze=m(ge,2);{var et=ne=>{var Te=H0(),nt=We(Te),ut=I(nt);{var Ze=Ot=>{{let Ct=u(()=>!e(G)||!!e(Y));yt(Ot,{size:"sm",get disabled(){return e(Ct)},onclick:()=>e(ie)&&p()(e(ie)),children:(ye,te)=>{rr();var qe=Rt();k(st=>x(qe,st),[()=>sp()]),d(ye,qe)},$$slots:{default:!0}})}};D(ut,Ot=>{p()&&Ot(Ze)})}var rt=m(ut,2);{let Ot=u(()=>!e(G)||!!e(Y)||e(Q).scenarios.length>=Pl);yt(rt,{variant:"ghost",size:"sm",get disabled(){return e(Ot)},onclick:oe,children:(Ct,ye)=>{rr();var te=Rt();k(qe=>x(te,qe),[()=>rp()]),d(Ct,te)},$$slots:{default:!0}})}var at=m(rt,2);{var it=Ot=>{yt(Ot,{variant:"ghost",size:"sm",get active(){return e(be)},get"aria-expanded"(){return e(be)},onclick:()=>R(be,!e(be)),children:(Ct,ye)=>{rr();var te=Rt();k(qe=>x(te,qe),[()=>op()]),d(Ct,te)},$$slots:{default:!0}})};D(at,Ot=>{e(Q).scenarios.length&&Ot(it)})}var gt=m(at,2);{var Nt=Ot=>{{let Ct=u(()=>!e(G)||h()==="saving");yt(Ot,{variant:"ghost",size:"sm",get disabled(){return e(Ct)},onclick:()=>g()({...e(Q),current:e(ie)??null}),children:(ye,te)=>{rr();var qe=Rt();k(st=>x(qe,st),[()=>ip()]),d(ye,qe)},$$slots:{default:!0}})}};D(gt,Ot=>{g()&&Ot(Nt)})}var Dt=m(gt,2);{var Yt=Ot=>{var Ct=N0(),ye=M(Ct,!0);k(te=>x(ye,te),[()=>f()==="saving"?lp():f()==="ready"?cp():""]),d(Ot,Ct)};D(Dt,Ot=>{i()&&Ot(Yt)})}w(nt);var _t=m(nt,2);{var Ht=Ot=>{var Ct=O0(),ye=I(Ct),te=m(ye);{var qe=st=>{var ct=Rt();k(()=>x(ct,P())),d(st,ct)};D(te,st=>{h()==="error"&&P()&&st(qe)})}w(Ct),k(st=>x(ye,`${st??""} `),[()=>h()==="saving"?dp():h()==="saved"?up({path:A()??""}):fp()]),d(Ot,Ct)};D(_t,Ot=>{h()&&Ot(Ht)})}var Gt=m(_t,2);{var cr=Ot=>{var Ct=z0(),ye=I(Ct),te=I(ye),qe=I(te),st=I(qe),ct=M(st,!0),Oe=m(st),re=M(Oe,!0),fe=m(Oe);Tt(fe,17,()=>e(Q).scenarios,Ae=>Ae.id,(Ae,ke)=>{var Ke=D0(),He=I(Ke);{let Ye=u(()=>vp());es(He,{get value(){return e(ke).name},get"aria-label"(){return e(Ye)},maxlength:120,onblur:Re=>{Re.currentTarget.value.trim()||(Re.currentTarget.value=e(ke).name),$(e(ke).id,Re.currentTarget.value)},onkeydown:Re=>{Re.key==="Enter"&&Re.currentTarget.blur(),Re.key==="Escape"&&(Re.currentTarget.value=e(ke).name,Re.currentTarget.blur())}})}var Ve=m(He,2),Qe=I(Ve);yt(Qe,{variant:"ghost",size:"sm",onclick:()=>Je(e(ke).snapshot),children:(Ye,Re)=>{rr();var $e=Rt();k(ft=>x($e,ft),[()=>pp()]),d(Ye,$e)},$$slots:{default:!0}});var De=m(Qe,2);yt(De,{variant:"ghost",size:"sm",onclick:()=>Be({...e(Q),scenarios:e(Q).scenarios.filter(Ye=>Ye.id!==e(ke).id)}),children:(Ye,Re)=>{rr();var $e=Rt();k(ft=>x($e,ft),[()=>gp()]),d(Ye,$e)},$$slots:{default:!0}}),w(Ve),w(Ke),d(Ae,Ke)}),w(qe),w(te);var ae=m(te);Tt(ae,20,()=>["inputs","results"],Mr,(Ae,ke)=>{const Ke=u(()=>ke),He=u(()=>Array.from(new Set([...Object.keys(e(ie)[e(Ke)]),...e(Q).scenarios.flatMap(De=>Object.keys(De.snapshot[e(Ke)]))])));var Ve=kt(),Qe=We(Ve);Tt(Qe,16,()=>e(He),De=>De,(De,Ye)=>{var Re=F0(),$e=I(Re),ft=M($e,!0),dt=m($e);Tt(dt,17,()=>[e(ie),...e(Q).scenarios.map(ot=>ot.snapshot)],Mr,(ot,xt)=>{var ht=B0(),Bt=M(ht,!0);k(Jt=>x(Bt,Jt),[()=>Object.hasOwn(e(xt)[e(Ke)],Ye)?V(e(xt)[e(Ke)][Ye]):"—"]),d(ot,ht)}),w(Re),k(()=>x(ft,Ye)),d(De,Re)}),d(Ae,Ve)}),w(ae),w(ye),w(Ct),k(Ae=>{x(ct,e(ie).title),x(re,Ae)},[()=>mp()]),d(Ot,Ct)};D(Gt,Ot=>{e(be)&&e(Q).scenarios.length&&Ot(cr)})}d(ne,Te)};D(ze,ne=>{e(ie)&&e(Ie)&&ne(et)})}return w(_e),mr(_e,ne=>F=ne,()=>F),k(()=>{se(_e,"data-inline-html-status",e(we)),se(_e,"data-inline-html-layout",e(le)?"viewport-locked":void 0),se(_e,"aria-busy",e(Ue))}),d(r,_e),Kt(ce)}var W0=S('<div class="w-full min-w-0"><!></div>');function U0(r,t){if(new.target)return Wt({component:U0,...r});Vt(t,!0);const n=()=>It(e(b),"$agent$",s),a=()=>It(e(F),"$entry$",s),[s,o]=oa();let c=y(t,"block",7),l=y(t,"role",7),f=y(t,"workspaceId",7),i=y(t,"agentId",7),p=y(t,"messageId",7),g=y(t,"contentBlockKey",7,""),T=he(void 0);const b=u(()=>so(i()??"")),h=u(()=>l()==="assistant"&&f()&&i()&&p()&&c().metadata?.fenceClosed&&!c().metadata?.isStreaming&&n()&&!Sd(n())?{workspaceId:f(),agentId:i(),messageId:p(),blockKey:JSON.stringify([g(),c().metadata?.fenceStart??0]),source:c().content}:void 0),A=u(()=>!!(f()&&i()&&p()&&c().metadata?.fenceClosed&&!n())),P=u(()=>e(h)?dv(e(h)):""),F=u(()=>qm(e(P)));St(()=>{e(h)&&Lt.dispatch(ov(e(h)))});function B(Y){!f()||!i()||n()?.retiredAt||e(T)?.dispatchEvent(new CustomEvent(ib,{bubbles:!0,detail:{workspaceId:f(),agentId:i(),snapshot:Y}}))}var O={get block(){return c()},set block(Y){c(Y),_()},get role(){return l()},set role(Y){l(Y),_()},get workspaceId(){return f()},set workspaceId(Y){f(Y),_()},get agentId(){return i()},set agentId(Y){i(Y),_()},get messageId(){return p()},set messageId(Y){p(Y),_()},get contentBlockKey(){return g()},set contentBlockKey(Y=""){g(Y),_()},$set:Ut,$on:(Y,Z)=>qt(t,Y,Z)},N=kt(),W=We(N);{var E=Y=>{var Z=W0(),Ce=I(Z);{let le=u(()=>c().metadata?.isStreaming??!1),ue=u(()=>c().metadata?.fenceClosed??!1),ie=u(()=>a()?.record),Se=u(()=>e(h)?a()?.status??"loading":e(A)?"loading":"ready"),J=u(()=>a()?.error),be=u(()=>e(h)?Be=>Lt.dispatch(cv(e(P),Be)):void 0),Q=u(()=>f()&&i()&&n()&&!n().retiredAt?B:void 0),je=u(()=>e(h)?()=>Lt.dispatch(lv(e(P))):void 0),Ie=u(()=>e(h)?Be=>Lt.dispatch(iv(e(P),crypto.randomUUID(),Be)):void 0),xe=u(()=>a()?.export?.status),we=u(()=>a()?.export?.path),Ue=u(()=>a()?.export?.error);Wu(Ce,{get source(){return c().content},get isStreaming(){return e(le)},get isComplete(){return e(ue)},get record(){return e(ie)},get storageStatus(){return e(Se)},get storageError(){return e(J)},get onRecordChange(){return e(be)},get onUseConfiguration(){return e(Q)},get onRetry(){return e(je)},get onExport(){return e(Ie)},get exportStatus(){return e(xe)},get exportPath(){return e(we)},get exportError(){return e(Ue)}})}w(Z),mr(Z,le=>R(T,le),()=>e(T)),d(Y,Z)},z=Y=>{na(Y,{get code(){return c().content},language:"html"})};D(W,Y=>{l()==="assistant"?Y(E):Y(z,-1)})}d(r,N);var G=Kt(O);return o(),G}var q0=S('<div class="digest-card flex items-start gap-2.5 py-5 px-6 my-4 shadow-xs text-base leading-normal border border-border"> </div>');function V0(r,t){if(new.target)return Wt({component:V0,...r});Vt(t,!0);let n=y(t,"digest",7);var a={get digest(){return n()},set digest(c){n(c),_()},$set:Ut,$on:(c,l)=>qt(t,c,l)},s=q0(),o=M(s,!0);return k(()=>x(o,n())),d(r,s),Kt(a)}var K0=S('<span class="inline-flex items-center px-1.5 py-0.5 rounded text-xs font-medium bg-blue-500/15 text-blue-600 dark:text-blue-400"> </span>'),G0=S('<span class="inline-flex items-center px-1.5 py-0.5 rounded text-xs font-medium bg-muted text-muted-foreground"> </span>'),J0=S('<span class="inline-flex items-center px-1.5 py-0.5 rounded text-xs font-medium bg-primary/10 text-primary/80"> </span>'),Y0=S('<div class="flex items-start gap-3 px-4 py-2.5"><div class="flex-1 min-w-0"><div class="flex items-center gap-2 flex-wrap"><span class="text-sm font-semibold text-foreground"> </span> <!> <!></div> <div class="mt-0.5 text-xs font-mono text-muted-foreground truncate"> </div></div></div>'),X0=S('<div class="detected-scripts-card my-3 rounded-lg border border-border bg-muted/30 overflow-hidden"><div class="flex items-center gap-2 px-4 py-2.5 border-b border-border bg-muted/40"><!> <span class="text-sm font-semibold text-foreground"> </span></div> <div class="divide-y divide-border"></div> <div class="px-4 py-2 border-t border-border bg-muted/20"><span class="text-xs text-muted-foreground"> </span></div></div>');function Z0(r,t){if(new.target)return Wt({component:Z0,...r});Vt(t,!0);let n=y(t,"scripts",7);var a={get scripts(){return n()},set scripts(b){n(b),_()},$set:Ut,$on:(b,h)=>qt(t,b,h)},s=X0(),o=I(s),c=I(o);At(c,{get icon(){return cd},size:"sm",class:"text-primary-ink/70"});var l=m(c,2),f=M(l,!0);w(o);var i=m(o,2);Tt(i,21,n,b=>b.name+b.command,(b,h)=>{var A=Y0(),P=I(A),F=I(P),B=I(F),O=M(B,!0),N=m(B,2);{var W=Ce=>{var le=K0(),ue=M(le,!0);k(ie=>x(ue,ie),[()=>v.chat_detectedScripts_service_badge()]),d(Ce,le)},E=Ce=>{var le=G0(),ue=M(le,!0);k(ie=>x(ue,ie),[()=>v.chat_detectedScripts_command_badge()]),d(Ce,le)};D(N,Ce=>{e(h).mode==="service"?Ce(W):Ce(E,-1)})}var z=m(N,2);{var G=Ce=>{var le=J0(),ue=M(le,!0);k(()=>x(ue,e(h).category)),d(Ce,le)};D(z,Ce=>{e(h).category&&e(h).category!=="other"&&Ce(G)})}w(F);var Y=m(F,2),Z=M(Y,!0);w(P),w(A),k(()=>{x(O,e(h).name),x(Z,e(h).command)}),d(b,A)}),w(i);var p=m(i,2),g=I(p),T=M(g,!0);return w(p),w(s),k((b,h)=>{x(f,b),x(T,h)},[()=>v.chat_detectedScripts_title(),()=>n().length===1?v.chat_detectedScripts_count_one({count:nr(n().length)}):v.chat_detectedScripts_count_many({count:nr(n().length)})]),d(r,s),Kt(a)}function Q0(r,t){if(new.target)return Wt({component:Q0,...r});Vt(t,!0);let n=y(t,"diff",7),a=y(t,"filePath",7),s=y(t,"language",7),o=y(t,"onApply",7),c=y(t,"onReject",7);function l(){o()?.(),ra.success(v.chat_diffViewer_applied_toast())}function f(){c()?.(),ra.info(v.chat_diffViewer_rejected_toast())}const i=u(()=>{const g=[];return o()&&g.push({label:v.chat_diffViewer_apply_label(),variant:"success",onClick:l}),c()&&g.push({label:v.chat_diffViewer_reject_label(),variant:"danger",onClick:f}),g});var p={get diff(){return n()},set diff(g){n(g),_()},get filePath(){return a()},set filePath(g){a(g),_()},get language(){return s()},set language(g){s(g),_()},get onApply(){return o()},set onApply(g){o(g),_()},get onReject(){return c()},set onReject(g){c(g),_()},$set:Ut,$on:(g,T)=>qt(t,g,T)};{let g=u(()=>a()||v.chat_diffViewer_suggestedChanges_fallback());ws(r,{get patch(){return n()},get fileName(){return e(g)},get language(){return s()},get actions(){return e(i)},collapsible:!0,initialCollapsed:!1,maxHeight:"500px"})}return Kt(p)}var $0=xa('<circle fill="none" style="transition: stroke-dasharray 0.3s ease-out"></circle>'),zc=xa("<circle></circle>"),ek=xa('<svg class="absolute top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2 fill-background" viewBox="0 0 8 6"><path fill-rule="evenodd" clip-rule="evenodd" d="M7.69471 1.69471C7.87687 1.50611 7.97766 1.25351 7.97539 0.991311C7.97311 0.729114 7.86794 0.478302 7.68253 0.292894C7.49712 0.107485 7.24631 0.00231622 6.98411 3.78025e-05C6.72192 -0.00224062 6.46931 0.0985542 6.28071 0.280712L2.98771 3.57371L1.69471 2.28071C1.50611 2.09855 1.25351 1.99776 0.991311 2.00004C0.729114 2.00232 0.478302 2.10749 0.292894 2.29289C0.107485 2.4783 0.00231622 2.72911 3.78025e-05 2.99131C-0.00224062 3.25351 0.0985542 3.50611 0.280712 3.69471L2.28071 5.69471C2.46824 5.88218 2.72255 5.9875 2.98771 5.9875C3.25288 5.9875 3.50718 5.88218 3.69471 5.69471L7.69471 1.69471Z"></path></svg>'),tk=S('<div class="relative"><svg fill="none" xmlns="http://www.w3.org/2000/svg"><circle fill="none"></circle><!></svg> <!></div>');function Ks(r,t){if(new.target)return Wt({component:Ks,...r});Vt(t,!0);let n=y(t,"phase",7),a=y(t,"progress",7,0),s=y(t,"size",7,16),o=y(t,"class",7,""),c=u(()=>s()/2),l=u(()=>e(c)),f=u(()=>e(c)),i=u(()=>s()*.12),p=u(()=>e(c)-e(i)/2),g=u(()=>e(c)*.35),T=u(()=>2*Math.PI*e(g)),b=u(()=>Math.max(0,Math.min(1,a()))*e(T));const h={planning:"#99999999",building:"#54B1F3",reviewing:"#6D7FF5",shipped:"var(--color-foreground)"};let A=u(()=>h[n()]||"currentColor");var P={get phase(){return n()},set phase(le){n(le),_()},get progress(){return a()},set progress(le=0){a(le),_()},get size(){return s()},set size(le=16){s(le),_()},get class(){return o()},set class(le=""){o(le),_()},$set:Ut,$on:(le,ue)=>qt(t,le,ue)},F=tk(),B=I(F),O=I(B),N=m(O);{var W=le=>{},E=le=>{var ue=$0();k(()=>{se(ue,"cx",e(l)),se(ue,"cy",e(f)),se(ue,"r",e(g)*.8),se(ue,"stroke",e(A)),se(ue,"stroke-width",e(g)*1.5),se(ue,"stroke-dasharray",`${e(b)??""} ${e(T)??""}`),se(ue,"stroke-dashoffset",e(T)*.25),se(ue,"transform",`rotate(-90 ${e(l)??""} ${e(f)??""})`)}),d(le,ue)},z=le=>{var ue=zc();k(()=>{se(ue,"cx",e(l)),se(ue,"cy",e(f)),se(ue,"r",e(p)*.6),se(ue,"fill",e(A))}),d(le,ue)},G=le=>{var ue=zc();k(()=>{se(ue,"cx",e(l)),se(ue,"cy",e(f)),se(ue,"r",e(p)),se(ue,"fill",e(A))}),d(le,ue)};D(N,le=>{n()==="planning"?le(W):n()==="building"?le(E,1):n()==="reviewing"?le(z,2):n()==="shipped"&&le(G,3)})}w(B);var Y=m(B,2);{var Z=le=>{},Ce=le=>{var ue=ek();k(()=>se(ue,"width",s()*.5)),d(le,ue)};D(Y,le=>{n()==="reviewing"?le(Z):n()==="shipped"&&le(Ce,1)})}return w(F),k(()=>{se(B,"width",s()),se(B,"height",s()),se(B,"viewBox",`0 0 ${s()??""} ${s()??""}`),vt(B,0,ir(o())),se(O,"cx",e(l)),se(O,"cy",e(f)),se(O,"r",e(p)),se(O,"stroke",e(A)),se(O,"stroke-width",e(i))}),d(r,F),Kt(P)}var Hc=S('<span class="flex items-center gap-1"><span class="size-1.5 rounded-full"></span> </span>'),rk=S('<span class="flex items-center gap-1"><span class="size-1.5 rounded-full bg-border"></span> </span>'),jc=S('<span class="text-ui text-subtle truncate"> </span>'),Wc=S('<div class="flex items-center gap-1 mt-0.5"><!> <!></div>'),Uc=S('<div class="flex items-start gap-2"><div class="shrink-0 mt-0.5"><!></div> <div class="flex-1 min-w-0"><div class="text-xs leading-snug truncate"> </div> <!></div></div>'),nk=S('<div class="flex items-center gap-2"><div class="shrink-0"><!></div> <span class="text-ui text-subtle truncate line-through"> </span></div>'),ak=S('<span class="text-ui text-subtle pl-4"> </span>'),sk=S('<div class="flex flex-col gap-0.5 pt-1 border-t border-border"><!> <!></div>'),ok=S('<div class="text-ui text-subtle"> </div>'),ik=S("<!> <!> <!> <!>",1),lk=S('<div class="flex flex-col py-2 px-3 gap-2 max-h-80 overflow-y-auto"><div class="flex items-center justify-between gap-3"><span class="text-xs font-semibold text-foreground"> </span> <div class="flex items-center gap-3 text-ui text-subtle"><!> <!> <!></div></div> <!></div>'),ck=S('<div class="rounded-[0.5px]"></div>');function Uu(r,t){if(new.target)return Wt({component:Uu,...r});Vt(t,!0);let n=y(t,"stats",7),a=y(t,"tasks",23,()=>[]),s=y(t,"maxBars",7,20),o=y(t,"barWidth",7,"1px"),c=y(t,"barHeight",7,"16px"),l=y(t,"gap",7,"1px"),f=y(t,"class",7);const i={completed:"#22c55e",inProgress:"#4F7BF7",notStarted:"var(--border)"};let p=u(()=>{const{completed:N,inProgress:W,notStarted:E,total:z}=n();if(z===0)return[];const G=[...Array(N).fill("completed"),...Array(W).fill("inProgress"),...Array(Math.max(0,E)).fill("notStarted")];return G.length<=s()?G:G.slice(G.length-s())}),g=u(()=>a().filter(N=>N.status==="complete")),T=u(()=>a().filter(N=>N.status==="in_progress"||N.status==="review_required")),b=u(()=>a().filter(N=>N.status!=="complete"&&N.status!=="in_progress"&&N.status!=="review_required"&&N.status!=="cancelled")),h=u(()=>a().filter(N=>N.status==="cancelled")),A=u(()=>a().length>0);var P={get stats(){return n()},set stats(N){n(N),_()},get tasks(){return a()},set tasks(N=[]){a(N),_()},get maxBars(){return s()},set maxBars(N=20){s(N),_()},get barWidth(){return o()},set barWidth(N="1px"){o(N),_()},get barHeight(){return c()},set barHeight(N="16px"){c(N),_()},get gap(){return l()},set gap(N="1px"){l(N),_()},get class(){return f()},set class(N){f(N),_()},$set:Ut,$on:(N,W)=>qt(t,N,W)},F=kt(),B=We(F);{var O=N=>{Go(N,{side:"top",align:"start",sideOffset:6,contentClass:"max-w-xs p-0",delayDuration:200,disableHoverableContent:!1,content:E=>{var z=lk(),G=I(z),Y=I(G),Z=M(Y,!0),Ce=m(Y,2),le=I(Ce);{var ue=Ie=>{var xe=Hc(),we=I(xe);Pn(we,"",{},{"background-color":"#22c55e"});var Ue=m(we);w(xe),k(()=>x(Ue,` ${n().completed??""}`)),d(Ie,xe)};D(le,Ie=>{n().completed>0&&Ie(ue)})}var ie=m(le,2);{var Se=Ie=>{var xe=Hc(),we=I(xe);Pn(we,"",{},{"background-color":"#4F7BF7"});var Ue=m(we);w(xe),k(()=>x(Ue,` ${n().inProgress??""}`)),d(Ie,xe)};D(ie,Ie=>{n().inProgress>0&&Ie(Se)})}var J=m(ie,2);{var be=Ie=>{var xe=rk(),we=m(I(xe));w(xe),k(()=>x(we,` ${n().notStarted??""}`)),d(Ie,xe)};D(J,Ie=>{n().notStarted>0&&Ie(be)})}w(Ce),w(G);var Q=m(G,2);{var je=Ie=>{var xe=ik(),we=We(xe);Tt(we,17,()=>e(T),Mr,(V,K)=>{var U=Uc(),ce=I(U),_e=I(ce);Eo(_e,{get status(){return e(K).status},size:14}),w(ce);var X=m(ce,2),de=I(X),Pe=M(de,!0),Fe=m(de,2);{var tt=pe=>{var Le=Wc(),q=I(Le);{let L=u(()=>e(K).agentState||"idle");yl(q,{get agentId(){return e(K).agentId},get state(){return e(L)},size:12,get specialist(){return e(K).agentSpecialist}})}var Ne=m(q,2);{var ge=L=>{var H=jc(),ve=M(H,!0);k(()=>x(ve,e(K).agentName)),d(L,H)};D(Ne,L=>{e(K).agentName&&L(ge)})}w(Le),d(pe,Le)};D(Fe,pe=>{e(K).agentId&&pe(tt)})}w(X),w(U),k(()=>x(Pe,e(K).title)),d(V,U)});var Ue=m(we,2);Tt(Ue,17,()=>e(b),Mr,(V,K)=>{var U=Uc(),ce=I(U),_e=I(ce);Eo(_e,{get status(){return e(K).status},size:14}),w(ce);var X=m(ce,2),de=I(X),Pe=M(de,!0),Fe=m(de,2);{var tt=pe=>{var Le=Wc(),q=I(Le);{let L=u(()=>e(K).agentState||"idle");yl(q,{get agentId(){return e(K).agentId},get state(){return e(L)},size:12,get specialist(){return e(K).agentSpecialist}})}var Ne=m(q,2);{var ge=L=>{var H=jc(),ve=M(H,!0);k(()=>x(ve,e(K).agentName)),d(L,H)};D(Ne,L=>{e(K).agentName&&L(ge)})}w(Le),d(pe,Le)};D(Fe,pe=>{e(K).agentId&&pe(tt)})}w(X),w(U),k(()=>x(Pe,e(K).title)),d(V,U)});var Be=m(Ue,2);{var oe=V=>{var K=sk(),U=I(K);Tt(U,17,()=>e(g).slice(0,3),Mr,(X,de)=>{var Pe=nk(),Fe=I(Pe),tt=I(Fe);Eo(tt,{status:"complete",size:12}),w(Fe);var pe=m(Fe,2),Le=M(pe,!0);w(Pe),k(()=>x(Le,e(de).title)),d(X,Pe)});var ce=m(U,2);{var _e=X=>{var de=ak(),Pe=M(de,!0);k(Fe=>x(Pe,Fe),[()=>v.workspace_taskProgressBar_moreCompleted_label({count:nr(e(g).length-3)})]),d(X,de)};D(ce,X=>{e(g).length>3&&X(_e)})}w(K),d(V,K)};D(Be,V=>{e(g).length>0&&V(oe)})}var $=m(Be,2);{var Je=V=>{var K=ok(),U=M(K,!0);k(ce=>x(U,ce),[()=>v.workspace_taskProgressBar_cancelled_label({count:nr(e(h).length)})]),d(V,K)};D($,V=>{e(h).length>0&&V(Je)})}d(Ie,xe)};D(Q,Ie=>{e(A)&&Ie(je)})}w(z),k(Ie=>x(Z,Ie),[()=>v.workspace_taskProgressBar_tasksRatio_label({completed:nr(n().completed),total:nr(n().total)})]),d(E,z)},children:(E,z)=>{{let G=u(()=>xn("flex h-auto min-w-0 shrink items-end justify-start cursor-default rounded-none border-0",f())),Y=u(()=>`gap: ${l()}`),Z=u(()=>v.workspace_taskProgressBar_tasksRatio_label({completed:nr(n().completed),total:nr(n().total)}));yt(E,{variant:"plain",type:"button",wrapContent:!1,get class(){return e(G)},get style(){return e(Y)},get"aria-label"(){return e(Z)},"data-task-progress-trigger":!0,children:(Ce,le)=>{var ue=kt(),ie=We(ue);Tt(ie,17,()=>e(p),Mr,(Se,J)=>{var be=ck();let Q;k(()=>Q=Pn(be,"",Q,{width:o(),height:c(),"background-color":i[e(J)]})),d(Se,be)}),d(Ce,ue)},$$slots:{default:!0}})}},$$slots:{content:!0,default:!0}})};D(B,N=>{n().total>0&&N(O)})}return d(r,F),Kt(P)}function Ui(r,t){if(new.target)return Wt({component:Ui,...r});Vt(t,!0);let n=y(t,"items",7),a=y(t,"ariaLabel",7),s=y(t,"open",15,!1),o=y(t,"orientation",7,"vertical"),c=y(t,"selection",7),l=y(t,"class",7,"");const f=u(()=>wg(n(),c(),a()));var i={get items(){return n()},set items(p){n(p),_()},get ariaLabel(){return a()},set ariaLabel(p){a(p),_()},get open(){return s()},set open(p=!1){s(p),_()},get orientation(){return o()},set orientation(p="vertical"){o(p),_()},get selection(){return c()},set selection(p){c(p),_()},get class(){return l()},set class(p=""){l(p),_()},$set:Ut,$on:(p,g)=>qt(t,p,g)};return Lm(r,{get actions(){return e(f)},align:"end",get ariaLabel(){return a()},onAction:g=>xg(n(),g)?.onClick(),get open(){return s()},set open(g){s(g)},trigger:(g,T)=>{let b=()=>(T?.()).props;yt(g,_i(b,{variant:"plain",size:"icon-compact",iconOnly:!0,type:"button",get class(){return l()},get"aria-label"(){return a()},onclick:h=>{h.stopPropagation(),b().onclick?.(h)},oncontextmenu:h=>{h.preventDefault(),h.stopPropagation()},children:(h,A)=>{Nm(h,{get orientation(){return o()},class:"size-3.5"})},$$slots:{default:!0}}))},$$slots:{trigger:!0}}),Kt(i)}var dk=S('<span class="contents"><!></span>'),uk=S("<!> <!>",1);function qu(r,t){if(new.target)return Wt({component:qu,...r});Vt(t,!0);let n=y(t,"workspaceId",7),a=y(t,"slot",7);const s=u(()=>Xg(a()));let o=he(null);St(()=>{e(o)&&e(o).workspaceId!==n()&&R(o,null)});function c(h){const A=sd(h);A&&R(o,{...A,workspaceId:n()},!0)}function l(h){h.preventDefault(),h.stopPropagation();const A=h.currentTarget.getBoundingClientRect();R(o,{x:A.left,y:A.bottom+2,returnFocus:h.currentTarget,workspaceId:n()},!0)}function f(){R(o,null)}var i={get workspaceId(){return n()},set workspaceId(h){n(h),_()},get slot(){return a()},set slot(h){a(h),_()},$set:Ut,$on:(h,A)=>qt(t,h,A)},p=uk(),g=We(p);{let h=u(()=>v.workspace_microKeyBadge_ariaLabel({number:nr(a()+1)})),A=u(()=>v.workspace_microKeyBadge_tooltip({number:nr(a()+1)})),P=u(()=>e(o)!==null);yt(g,{variant:"ghost",size:"icon",type:"button",class:"micro-key-slot-badge size-4 min-w-0 shrink-0 cursor-pointer rounded-[3px] p-0 a11y-ignore",get"aria-label"(){return e(h)},get title(){return e(A)},onclick:l,oncontextmenu:c,onkeydown:c,"aria-haspopup":"menu",get"aria-expanded"(){return e(P)},children:(F,B)=>{var O=dk(),N=I(O);eg(N,{get slot(){return a()},get class(){return`transition-colors ${e(s)??""}`}}),w(O),d(F,O)},$$slots:{default:!0}})}var T=m(g,2);{var b=h=>{{let A=u(()=>e(o)?.x??0),P=u(()=>e(o)?.y??0),F=u(()=>e(o)?.returnFocus),B=u(()=>v.workspace_card_assignMicroKey_label()),O=u(()=>Fh(n(),f));od(h,{get x(){return e(A)},get y(){return e(P)},get returnFocus(){return e(F)},selection:"single",get ariaLabel(){return e(B)},get items(){return e(O)},onClickOutside:f})}};D(T,h=>{e(o)&&h(b)})}return d(r,p),Kt(i)}var fk=S('<span class="flex size-4 shrink-0 items-center justify-center"><!></span>'),pk=S('<span data-workspace-card-pin-indicator="" aria-hidden="true"><!></span> <span class="sr-only"> </span>',1),gk=S('<span class="type-caption shrink-0 rounded-sm bg-muted-foreground/10 px-1.5 font-normal text-muted-foreground" data-workspace-card-trailing-label=""> </span>'),vk=S('<span data-workspace-card-pr-item=""><!></span>'),mk=S('<span class="flex shrink-0 items-center" data-workspace-card-pr-list=""><!></span>'),hk=S('<span data-workspace-card-time=""><!></span>'),bk=S('<span aria-hidden="true"><!></span>'),yk=S("<div><!> <!> <!> <!></div>"),_k=S('<div data-workspace-card-hover-surface=""><!></div>'),xk=S('<div role="group" data-workspace-card-row=""><!> <div class="relative z-10 flex shrink-0 items-center gap-1.5"><!> <!> <span class="sr-only"> </span></div> <div class="relative z-10 flex min-w-0 flex-1 items-center gap-2"><span class="flex min-w-0 flex-1 items-center gap-1" data-workspace-card-title-group=""><span dir="ltr" data-workspace-card-title=""><span class="wc-title-text svelte-1ct56pd"> </span></span> <!></span> <!> <!> <!></div> <!></div> <!> <!>',1),wk=S('<div class="relative z-10 flex shrink-0 items-center"><!></div>'),kk=S('<div><!> <!> <span class="font-medium truncate"> </span> <span class="shrink-0 text-muted-foreground">·</span> <span class="truncate text-xs text-muted-foreground"> </span> <!></div>'),Sk=S('<div class="text-sm font-semibold truncate"> </div>'),qc=S('<span class="truncate"> </span>'),Ik=S('<span class="text-muted-foreground">·</span>'),Ck=S('<div class="flex items-center gap-1 truncate text-xs text-muted-foreground"><!> <!> <!></div>'),Ek=S('<div><!> <!> <div class="flex items-center gap-2 text-xs"><!> <span class="truncate text-muted-foreground"> </span> <span> </span></div> <!></div>'),Ak=S('<div class="flex items-center gap-2"><!> <span class="text-ui shrink-0 tabular-nums text-muted-foreground"> </span></div>'),Pk=S('<div class="flex items-center justify-between text-ui"><span class="text-muted-foreground"> </span> <span class="tabular-nums"><span class="text-success"> </span> <span class="ml-1 text-danger"> </span></span></div>'),Tk=S('<div class="flex items-center justify-between text-ui"><span class="text-muted-foreground"> </span></div>'),Rk=S('<div class="flex items-center text-ui"><span> </span></div>'),Mk=S('<div class="flex flex-col gap-1 px-3 pb-2.5"><!> <!> <!> <!></div>'),Lk=S('<div class="relative z-10 flex items-center gap-1.5 px-2 pb-2"><!></div>'),Nk=S('<div class="relative z-10 flex items-center gap-1.5 px-2 pb-2"><!> <!></div>'),Ok=S('<div role="group"><!> <div class="flex items-start gap-2.5 px-3 pt-3 pb-2"><!> <div class="flex-1 min-w-0"><div class="text-sm font-medium"> </div> <div class="mt-0.5 line-clamp-2 text-xs leading-snug text-muted-foreground"> </div></div></div> <!> <!></div>');function Vu(r,t){if(new.target)return Wt({component:Vu,...r});Vt(t,!0);const n=()=>It(Ue,"$prMonitors$",c),a=()=>It(Be,"$microConnected$",c),s=()=>It($,"$hidesOwnerActions$",c),o=()=>It(oe,"$workspaceKeySlot$",c),[c,l]=oa();let f=y(t,"workspace",7),i=y(t,"phase",7),p=y(t,"stats",7),g=y(t,"variant",7,"compact"),T=y(t,"showTime",7,!0),b=y(t,"isRunning",7,!1),h=y(t,"isUnread",7,!1),A=y(t,"isWaiting",7),P=y(t,"isPinned",7,!1),F=y(t,"streamingAgentIds",23,()=>[]),B=y(t,"hasSpec",7,!1),O=y(t,"isAgentRunning",7,!1),N=y(t,"agentDigest",7),W=y(t,"trailingLabel",7),E=y(t,"title",7),z=y(t,"repoName",7),G=y(t,"branch",7),Y=y(t,"onClick",7),Z=y(t,"onAction",7),Ce=y(t,"onTogglePin",7),le=y(t,"onMarkAsRead",7),ue=y(t,"onOpenInNewWindow",7),ie=y(t,"onHover",7),Se=y(t,"highlighted",7,!1),J=y(t,"selected",7,!1),be=y(t,"highlightId",7),Q=y(t,"suppressHover",7,!1),je=y(t,"isolateHoverReveal",7,!1),Ie=y(t,"class",7),xe=y(t,"actions",7);const we=$a("");St(()=>{we.set(f()?.id??"")});const Ue=Wp(we),Be=Qh(),oe=Av(we),$=Up(we),Je=u(()=>Hh(f()??{})),V=u(()=>jh(e(Je)));let K=u(()=>f()?Zh.url.pathname===`/workspace/${f().id}`:!1),U=u(()=>f()?`workspace-hover-card-${f().id}`:void 0),ce=he(!1),_e=he(null),X=he(null);St(()=>{if(!e(X))return;const ee=Bs(e(X),{id:be()});return()=>ee.destroy()});let de=he(null),Pe=he(null),Fe=he(null),tt=he(0),pe=he(0),Le=u(()=>e(tt)+(e(pe)>0?e(pe)+4:0));function q(){const ee=e(de),mt=e(Fe);R(tt,ee?Math.max(0,ee.scrollWidth-ee.clientWidth):0,!0),R(pe,ee&&mt&&mt.getClientRects().length>0?Math.max(0,ee.getBoundingClientRect().right-mt.getBoundingClientRect().left):0,!0)}St(()=>{const ee=e(de),mt=e(Pe),Ft=e(Fe);if(!ee||!mt||(q(),typeof ResizeObserver>"u"))return;const ur=new ResizeObserver(q);return ur.observe(ee),ur.observe(mt),Ft&&ur.observe(Ft),()=>ur.disconnect()});let Ne=null,ge=null,L=!1,H=!1,ve=!1,Xe=!1,Ee=!1,ze=!1,et=he(!1),ne=!1,Te=null,nt=he(null),ut=null,Ze;function rt(){Ne!==null&&(clearTimeout(Ne),Ne=null)}function at(){ge!==null&&(clearTimeout(ge),ge=null),ut?.(),ut=null}function it(){at(),R(et,!0),R(ce,!0),!Ee&&(Ee=!0,ps.notifyOpened())}function gt(){at(),clearTimeout(Ze),R(et,!1),R(ce,!1),H=!1,Xe=!1,Ee&&(Ee=!1,ps.notifyClosed())}function Nt(){return L||H||ve||Xe}function Dt(){if(!e(ce)){gt();return}at(),ge=setTimeout(()=>{ge=null,Nt()||gt()},Uh),ut=ps.deferClose(gt)}function Yt(){H=!0,at()}function _t(){H=!1,!ve&&!Xe&&Dt()}function Ht(){Xe=!0,clearTimeout(Ze),at()}function Gt(ee){const mt=ee.relatedTarget instanceof Node?ee.relatedTarget:null;if(mt&&fe()?.contains(mt)||(Xe=!1,mt&&e(_e)?.contains(mt)))return;if(mt){!L&&!H&&gt();return}const Ft=ee.target;clearTimeout(Ze),Ze=setTimeout(()=>{const ur=document.activeElement,_r=fe()?.contains(ur)||e(_e)?.contains(ur);ur&&ur!==Ft&&_r||!L&&!H&&gt()},0)}function cr(){Te!==null&&clearTimeout(Te),ne=!0,Te=setTimeout(()=>{ne=!1,Te=null},0)}function Ot(ee){const mt=ee.target,Ft=fe();mt instanceof Node&&Ft?.contains(mt)||ee.type==="scroll"&&e(_e)&&mt instanceof Node&&!mt.contains(e(_e))||(ee.type==="pointerdown"&&cr(),rt(),gt())}St(()=>{if(e(et))return window.addEventListener("pointerdown",Ot,!0),window.addEventListener("scroll",Ot,!0),()=>{window.removeEventListener("pointerdown",Ot,!0),window.removeEventListener("scroll",Ot,!0)}});function Ct(ee){if(ee.key!=="Escape")return;const mt=ee.target;mt instanceof Node&&fe()?.contains(mt)||(ee.preventDefault(),ee.stopPropagation(),ze=ve,rt(),gt())}St(()=>{if(e(ce))return window.addEventListener("keydown",Ct,!0),()=>window.removeEventListener("keydown",Ct,!0)});const ye=u(()=>f()?Vp.select(Lt.state,f().id):null),te=u(()=>e(ye)?e(ye):f()?.activePullRequest?f().activePullRequest:!f()?.prStatus||f().prNumber==null?null:{id:`legacy-pr-${f().prNumber}`,number:f().prNumber,url:f().prUrl??"",title:v.workspace_hoverCard_pullRequest_label(),status:f().prStatus,createdAt:f().updatedAt,updatedAt:f().updatedAt}),qe=u(()=>qp(f())),st=u(()=>{if(!f()||e(qe))return[];const ee=f(),mt=ee.repositoryOwner&&ee.repositoryName?`${ee.repositoryOwner}/${ee.repositoryName}`:void 0;return kg({workspacePRs:ee.pullRequests,activePR:e(te),monitors:n(),workspaceRepo:mt,buildPrUrl:(Ft,ur)=>pm(Ft,ee.repositoryOwner,ee.repositoryName,ur),getDisplayTitle:Ft=>Ft.title})}),ct=u(()=>e(st)[0]);function Oe(ee){const mt=ee.resource?.repository.provider==="gitlab"?`${ee.repo} !${ee.number}`:ee.repo?v.workspace_card_prBadge_repoLine_tooltip({repo:ee.repo,number:ee.number}):v.workspace_card_prBadge_label({number:` #${ee.number}`});return[Kp(mt,ee),ee.title,ee.details].filter(Boolean).join(`
262
262
  `)}function re(ee){ee.key==="Enter"&&Y()?.(ee)}function fe(){return e(U)?document.getElementById(e(U)):null}function ae(){return Array.from(fe()?.querySelectorAll("button:not(:disabled), a[href]")??[])}function Ae(){const ee=e(_e)?.querySelector("[data-workspace-card-trigger]"),mt=fe();if(!ee||!mt)return null;const Ft=Array.from(document.querySelectorAll('button:not(:disabled), a[href], input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [tabindex]:not([tabindex="-1"])')).filter(_r=>_r.tabIndex>=0&&!mt.contains(_r)),ur=Ft.indexOf(ee);return ur>=0?Ft[ur+1]:null}function ke(ee){ze=!!e(_e)?.contains(ee),gt(),ee.focus({preventScroll:!0})}function Ke(){const ee=e(_e)?.querySelector("[data-workspace-card-trigger]");ee&&ke(ee)}async function He(ee){if(ee.key==="Escape"&&e(ce)){ee.preventDefault(),ee.stopPropagation(),gt();return}ee.key!=="ArrowDown"||Q()||!f()||(ee.preventDefault(),ee.stopPropagation(),R(et,!0),R(ce,!0),await Xn(),ae()[0]?.focus({preventScroll:!0}))}function Ve(ee){const mt=ae(),Ft=ee.key==="Tab"&&ee.shiftKey&&ee.currentTarget===mt[0],_r=ee.key==="Tab"&&!ee.shiftKey&&ee.currentTarget===mt.at(-1)?Ae():null;ee.key!=="Escape"&&!Ft&&!_r||(ee.preventDefault(),ee.stopPropagation(),_r?ke(_r):Ke())}function Qe(){L=!0,at(),ps.settleDeferredCloses(),q(),ie()?.(),f()&&!Q()&&!ve&&(rt(),R(et,!0),Ne=setTimeout(()=>{Ne=null,it()},ps.currentOpenDelay))}function De(){L=!1,rt(),!ve&&!Xe&&Dt()}function Ye(){ve=!0,rt(),at(),!ze&&(ne||f()&&!Q()&&(R(et,!0),R(ce,!0)))}function Re(ee){const mt=ee.relatedTarget instanceof Node?ee.relatedTarget:null;mt&&e(_e)?.contains(mt)||(ze=!1,ve=!1,!(mt&&fe()?.contains(mt))&&!L&&!H&&gt())}St(()=>{Q()&&(rt(),at(),gt())});let $e=he(null),ft=he(!1),dt;St(()=>{const ee=f()?.id;dt!==ee&&(dt=ee,R(ft,!1)),e($e)&&e($e).workspaceId!==f()?.id&&xt()});function ot(ee){if(!f())return;const mt=sd(ee);if(mt){if(R(ft,!1),ht().length===0){R($e,null);return}R($e,{...mt,returnFocus:ee.target instanceof HTMLElement?ee.target.closest("button")??e(_e)?.querySelector("button")??null:null,workspaceId:f().id},!0)}}function xt(){R($e,null),R(ft,!1)}St(()=>{e(ft)&&R($e,null)}),Es(()=>{rt(),at(),Te!==null&&(clearTimeout(Te),Te=null),gt()});function ht(){if(!f())return[];const ee=[];return ue()&&ee.push({id:"open-new-window",label:v.workspace_card_openNewWindow_label(),icon:fd,onClick:()=>{ue()?.(),xt()}}),ee.push(...Wh(f().id,{connected:a(),onClose:xt})),s()||(e(qe)||ee.push({id:"transfer",label:v.workspace_card_transfer_label(),icon:Hg,onClick:()=>{Lt.dispatch(uv({workspaceId:f().id,workspaceTitle:f().title})),xt()}}),ee.push({id:"archive",label:v.workspace_card_archive_label(),icon:pd,onClick:()=>{Lt.dispatch(Id(f().id)),xt()}}),ee.push({id:"delete",label:v.workspace_card_deleteSpace_label(),icon:gd,destructive:!0,onClick:()=>{Lt.dispatch(Cd(f().id)),xt()}})),ee}let Bt=u(()=>O()&&N()?N():i()?.subtitle??""),Jt=u(()=>p()&&p().tasks.total>0?p().tasks.completed/p().tasks.total:0),$t=u(()=>!!p()&&(p().tasks.total>0||p().files.changed>0||p().commits.total>0||p().pr.hasOpen||p().pr.hasMerged)),dr=u(()=>e(qe)?void 0:G()),jr=u(()=>!p()||e(qe)?"":p().pr.hasMerged?v.workspace_card_prMerged_label({number:p().pr.number??""}):p().pr.hasOpen?v.workspace_card_prOpen_label({number:p().pr.number?`#${p().pr.number}`:""}):""),nn=u(()=>i()?.phase==="planning"?O()?{primary:{label:v.workspace_card_showCoordinator_label(),action:"show-coordinator"},secondary:{label:v.workspace_card_pause_label(),action:"pause"}}:B()||(p()?.tasks.total??0)>0?{primary:{label:v.workspace_card_approveStart_label(),action:"approve"},secondary:{label:v.workspace_card_viewSpec_label(),action:"view-spec"}}:{primary:{label:v.workspace_card_showCoordinator_label(),action:"show-coordinator"},secondary:{label:v.workspace_card_viewSpec_label(),action:"view-spec"}}:i()?.phase==="building"?{primary:{label:v.workspace_card_showCoordinator_label(),action:"show-coordinator"},secondary:{label:v.workspace_card_pause_label(),action:"pause"}}:i()?.phase==="reviewing"?{primary:{label:v.workspace_card_createPr_label(),action:"create-pr"},secondary:{label:v.workspace_card_showChanges_label(),action:"show-changes"}}:{primary:{label:v.workspace_card_archive_label(),action:"archive"},secondary:{label:v.workspace_card_showChanges_label(),action:"show-changes"}});const mn={planning:"bg-muted/20 text-muted-foreground",building:"bg-info/15 text-info",reviewing:"bg-primary/15 text-primary",shipped:"bg-foreground/10 text-foreground"};var zn={get workspace(){return f()},set workspace(ee){f(ee),_()},get phase(){return i()},set phase(ee){i(ee),_()},get stats(){return p()},set stats(ee){p(ee),_()},get variant(){return g()},set variant(ee="compact"){g(ee),_()},get showTime(){return T()},set showTime(ee=!0){T(ee),_()},get isRunning(){return b()},set isRunning(ee=!1){b(ee),_()},get isUnread(){return h()},set isUnread(ee=!1){h(ee),_()},get isWaiting(){return A()},set isWaiting(ee){A(ee),_()},get isPinned(){return P()},set isPinned(ee=!1){P(ee),_()},get streamingAgentIds(){return F()},set streamingAgentIds(ee=[]){F(ee),_()},get hasSpec(){return B()},set hasSpec(ee=!1){B(ee),_()},get isAgentRunning(){return O()},set isAgentRunning(ee=!1){O(ee),_()},get agentDigest(){return N()},set agentDigest(ee){N(ee),_()},get trailingLabel(){return W()},set trailingLabel(ee){W(ee),_()},get title(){return E()},set title(ee){E(ee),_()},get repoName(){return z()},set repoName(ee){z(ee),_()},get branch(){return G()},set branch(ee){G(ee),_()},get onClick(){return Y()},set onClick(ee){Y(ee),_()},get onAction(){return Z()},set onAction(ee){Z(ee),_()},get onTogglePin(){return Ce()},set onTogglePin(ee){Ce(ee),_()},get onMarkAsRead(){return le()},set onMarkAsRead(ee){le(ee),_()},get onOpenInNewWindow(){return ue()},set onOpenInNewWindow(ee){ue(ee),_()},get onHover(){return ie()},set onHover(ee){ie(ee),_()},get highlighted(){return Se()},set highlighted(ee=!1){Se(ee),_()},get selected(){return J()},set selected(ee=!1){J(ee),_()},get highlightId(){return be()},set highlightId(ee){be(ee),_()},get suppressHover(){return Q()},set suppressHover(ee=!1){Q(ee),_()},get isolateHoverReveal(){return je()},set isolateHoverReveal(ee=!1){je(ee),_()},get class(){return Ie()},set class(ee){Ie(ee),_()},get actions(){return xe()},set actions(ee){xe(ee),_()},$set:Ut,$on:(ee,mt)=>qt(t,ee,mt)},Un=kt(),da=We(Un);{var wr=ee=>{var mt=xk(),Ft=We(mt);let ur;var _r=I(Ft);{let bt=u(()=>f().title||v.workspace_links_untitled_label()),Pt=u(()=>`workspace-status-state-${f().id}${P()?` workspace-pinned-state-${f().id}`:""}${e(ce)?` ${e(U)}`:""}`),pr=u(()=>e(K)?"page":void 0);yt(_r,{variant:"plain",class:"absolute inset-0 z-0 h-auto w-auto rounded-md focus-visible:border-transparent focus-visible:bg-background/50 focus-visible:ring-0",get"aria-label"(){return e(bt)},get"aria-describedby"(){return e(Pt)},get"aria-current"(){return e(pr)},"data-workspace-card-trigger":!0,onkeydown:He,onclick:xr=>{xr.stopPropagation(),Y()?.(xr)}})}var kn=m(_r,2),cn=I(kn);{var Hn=bt=>{var Pt=fk(),pr=I(Pt);{var xr=Pr=>{qu(Pr,{get workspaceId(){return f().id},get slot(){return o()}})};D(pr,Pr=>{o()!==null&&Pr(xr)})}w(Pt),d(bt,Pt)};D(cn,bt=>{a()&&bt(Hn)})}var hn=m(cn,2);Go(hn,{get content(){return e(V).tooltip},side:"bottom",sideOffset:4,children:(bt,Pt)=>{zh(bt,{get status(){return e(Je)},size:14,decorative:!0,class:"justify-start"})},$$slots:{default:!0}});var Tn=m(hn,2),Zn=M(Tn,!0);w(kn);var Yr=m(kn,2),dn=I(Yr),Xt=I(dn),an=I(Xt),qn=M(an,!0);mr(an,bt=>R(Pe,bt),()=>e(Pe)),w(Xt),mr(Xt,bt=>R(de,bt),()=>e(de));var kr=m(Xt,2);{var Or=bt=>{var Pt=pk(),pr=We(Pt),xr=I(pr);At(xr,{get icon(){return Sl},size:"xs"}),w(pr);var Pr=m(pr,2),j=M(Pr,!0);k(Me=>{vt(pr,1,`wc-pin-indicator inline-flex shrink-0 items-center text-muted-foreground transition-opacity
263
- ${Ce()?Se()?"opacity-0":Q()?"":je()?"group-hover/wc:opacity-0 group-focus-within/wc:opacity-0":"group-hover:opacity-0 group-focus-within:opacity-0":""}`,"svelte-1ct56pd"),se(Pr,"id",`workspace-pinned-state-${f().id??""}`),x(j,Me)},[()=>v.layout_activeCard_pinned_header()]),d(bt,Pt)};D(kr,bt=>{P()&&bt(Or)})}w(dn);var un=m(dn,2);{var la=bt=>{var Pt=gk(),pr=M(Pt,!0);k(()=>x(pr,W())),d(bt,Pt)};D(un,bt=>{W()&&bt(la)})}var Xr=m(un,2);{var Zr=bt=>{const Pt=u(()=>e(ct));var pr=mk(),xr=I(pr);{let Pr=u(()=>Oe(e(Pt)));Go(xr,{get content(){return e(Pr)},side:"bottom",sideOffset:4,children:(j,Me)=>{var pt=kt(),Qt=We(pt);{var fr=gr=>{{let hr=u(()=>Oe(e(Pt)));yt(gr,{variant:"plain",size:"icon-compact",iconOnly:!0,get class(){return`size-5 shrink-0 rounded-sm ${e(Pt).foregroundClass??""}`},get"aria-label"(){return e(hr)},"data-workspace-card-pr-item":!0,get"data-pr-identity"(){return e(Pt).identity},get"data-pr-status"(){return e(Pt).status},onclick:sn=>{sn.stopPropagation();const Vn=f().id;hp(async()=>{const{handleLink:Wr}=await import("./DHtTqndc.js").then(Tr=>Tr.H);return{handleLink:Wr}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65]),import.meta.url).then(({handleLink:Wr})=>Wr(e(Pt).url,{workspaceId:Vn,event:sn}))},children:(sn,Vn)=>{At(sn,{get icon(){return e(Pt).statusIcon},size:14})},$$slots:{default:!0}})}},ar=gr=>{var hr=vk(),sn=I(hr);At(sn,{get icon(){return e(Pt).statusIcon},size:14}),w(hr),k(Vn=>{vt(hr,1,`inline-flex size-5 shrink-0 items-center justify-center rounded-sm ${e(Pt).foregroundClass??""}`,"svelte-1ct56pd"),se(hr,"aria-label",Vn),se(hr,"data-pr-identity",e(Pt).identity),se(hr,"data-pr-status",e(Pt).status)},[()=>Oe(e(Pt))]),d(gr,hr)};D(Qt,gr=>{e(Pt).url?gr(fr):gr(ar,-1)})}d(j,pt)},$$slots:{default:!0}})}w(pr),k(Pr=>se(pr,"aria-label",Pr),[()=>e(Pt).resource?.repository.provider==="gitlab"?v.workspace_hoverCard_mergeRequest_label():v.workspace_hoverCard_pullRequest_label()]),d(bt,pr)};D(Xr,bt=>{e(ct)&&bt(Zr)})}var Br=m(Xr,2);{var Qn=bt=>{var Pt=hk(),pr=I(Pt);{var xr=j=>{{let Me=u(()=>Tl(f()));tg(j,{get date(){return e(Me)},class:"type-caption whitespace-nowrap tabular-nums text-muted-foreground",compact:!0})}},Pr=u(()=>Tl(f())>0);D(pr,j=>{e(Pr)&&j(xr)})}w(Pt),k(()=>vt(Pt,1,`wc-secondary shrink-0 ${xe()||Ce()||h()&&le()?Se()?"opacity-0":Q()?"":je()?"group-hover/wc:opacity-0 group-hover/message:opacity-0":"group-hover:opacity-0 group-hover/message:opacity-0":""}`,"svelte-1ct56pd")),d(bt,Pt)};D(Br,bt=>{T()&&bt(Qn)})}w(Yr);var Pa=m(Yr,2);{var Ba=bt=>{var Pt=yk(),pr=I(Pt);{var xr=fr=>{{let ar=u(()=>P()?"text-primary-ink":"text-muted-foreground"),gr=u(()=>P()?v.workspace_card_unpin_ariaLabel():v.workspace_card_pin_ariaLabel()),hr=u(()=>P()?v.workspace_card_unpin_tooltip():v.workspace_card_pin_tooltip());yt(fr,{variant:"plain",size:"icon-xs",iconOnly:!0,get class(){return`transition-all hover:bg-muted/50 hover:text-foreground focus-visible:border-transparent focus-visible:bg-muted/50 focus-visible:text-foreground focus-visible:ring-0
263
+ ${Ce()?Se()?"opacity-0":Q()?"":je()?"group-hover/wc:opacity-0 group-focus-within/wc:opacity-0":"group-hover:opacity-0 group-focus-within:opacity-0":""}`,"svelte-1ct56pd"),se(Pr,"id",`workspace-pinned-state-${f().id??""}`),x(j,Me)},[()=>v.layout_activeCard_pinned_header()]),d(bt,Pt)};D(kr,bt=>{P()&&bt(Or)})}w(dn);var un=m(dn,2);{var la=bt=>{var Pt=gk(),pr=M(Pt,!0);k(()=>x(pr,W())),d(bt,Pt)};D(un,bt=>{W()&&bt(la)})}var Xr=m(un,2);{var Zr=bt=>{const Pt=u(()=>e(ct));var pr=mk(),xr=I(pr);{let Pr=u(()=>Oe(e(Pt)));Go(xr,{get content(){return e(Pr)},side:"bottom",sideOffset:4,children:(j,Me)=>{var pt=kt(),Qt=We(pt);{var fr=gr=>{{let hr=u(()=>Oe(e(Pt)));yt(gr,{variant:"plain",size:"icon-compact",iconOnly:!0,get class(){return`size-5 shrink-0 rounded-sm ${e(Pt).foregroundClass??""}`},get"aria-label"(){return e(hr)},"data-workspace-card-pr-item":!0,get"data-pr-identity"(){return e(Pt).identity},get"data-pr-status"(){return e(Pt).status},onclick:sn=>{sn.stopPropagation();const Vn=f().id;hp(async()=>{const{handleLink:Wr}=await import("./QGl-Xn9g.js").then(Tr=>Tr.H);return{handleLink:Wr}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65]),import.meta.url).then(({handleLink:Wr})=>Wr(e(Pt).url,{workspaceId:Vn,event:sn}))},children:(sn,Vn)=>{At(sn,{get icon(){return e(Pt).statusIcon},size:14})},$$slots:{default:!0}})}},ar=gr=>{var hr=vk(),sn=I(hr);At(sn,{get icon(){return e(Pt).statusIcon},size:14}),w(hr),k(Vn=>{vt(hr,1,`inline-flex size-5 shrink-0 items-center justify-center rounded-sm ${e(Pt).foregroundClass??""}`,"svelte-1ct56pd"),se(hr,"aria-label",Vn),se(hr,"data-pr-identity",e(Pt).identity),se(hr,"data-pr-status",e(Pt).status)},[()=>Oe(e(Pt))]),d(gr,hr)};D(Qt,gr=>{e(Pt).url?gr(fr):gr(ar,-1)})}d(j,pt)},$$slots:{default:!0}})}w(pr),k(Pr=>se(pr,"aria-label",Pr),[()=>e(Pt).resource?.repository.provider==="gitlab"?v.workspace_hoverCard_mergeRequest_label():v.workspace_hoverCard_pullRequest_label()]),d(bt,pr)};D(Xr,bt=>{e(ct)&&bt(Zr)})}var Br=m(Xr,2);{var Qn=bt=>{var Pt=hk(),pr=I(Pt);{var xr=j=>{{let Me=u(()=>Tl(f()));tg(j,{get date(){return e(Me)},class:"type-caption whitespace-nowrap tabular-nums text-muted-foreground",compact:!0})}},Pr=u(()=>Tl(f())>0);D(pr,j=>{e(Pr)&&j(xr)})}w(Pt),k(()=>vt(Pt,1,`wc-secondary shrink-0 ${xe()||Ce()||h()&&le()?Se()?"opacity-0":Q()?"":je()?"group-hover/wc:opacity-0 group-hover/message:opacity-0":"group-hover:opacity-0 group-hover/message:opacity-0":""}`,"svelte-1ct56pd")),d(bt,Pt)};D(Br,bt=>{T()&&bt(Qn)})}w(Yr);var Pa=m(Yr,2);{var Ba=bt=>{var Pt=yk(),pr=I(Pt);{var xr=fr=>{{let ar=u(()=>P()?"text-primary-ink":"text-muted-foreground"),gr=u(()=>P()?v.workspace_card_unpin_ariaLabel():v.workspace_card_pin_ariaLabel()),hr=u(()=>P()?v.workspace_card_unpin_tooltip():v.workspace_card_pin_tooltip());yt(fr,{variant:"plain",size:"icon-xs",iconOnly:!0,get class(){return`transition-all hover:bg-muted/50 hover:text-foreground focus-visible:border-transparent focus-visible:bg-muted/50 focus-visible:text-foreground focus-visible:ring-0
264
264
  ${e(ar)??""}`},onclick:sn=>{sn.stopPropagation(),Ce()?.(sn)},get"aria-label"(){return e(gr)},get title(){return e(hr)},children:(sn,Vn)=>{var Wr=bk(),Tr=I(Wr);At(Tr,{get icon(){return Sl},size:"xs"}),w(Wr),d(sn,Wr)},$$slots:{default:!0}})}};D(pr,fr=>{Ce()&&fr(xr)})}var Pr=m(pr,2);{var j=fr=>{{let ar=u(()=>v.workspace_card_markAsRead_label()),gr=u(()=>v.workspace_card_markAsRead_label());yt(fr,{variant:"plain",size:"icon-xs",iconOnly:!0,class:"text-muted-foreground hover:bg-muted/50 hover:text-foreground focus-visible:border-transparent focus-visible:bg-muted/50 focus-visible:text-foreground focus-visible:ring-0",onclick:hr=>{hr.stopPropagation(),le()?.(hr)},get"aria-label"(){return e(ar)},get title(){return e(gr)},children:(hr,sn)=>{At(hr,{get icon(){return vd},size:"xs"})},$$slots:{default:!0}})}};D(Pr,fr=>{h()&&le()&&fr(j)})}var Me=m(Pr,2);ln(Me,()=>xe()??Gs);var pt=m(Me,2);{var Qt=fr=>{{let ar=u(ht),gr=u(()=>v.workspace_progressCard_actions_ariaLabel());Ui(fr,{get items(){return e(ar)},get ariaLabel(){return e(gr)},class:"flex size-5 cursor-pointer items-center justify-center rounded text-muted-foreground transition-colors hover:bg-muted/50 hover:text-foreground focus-visible:bg-muted/50 focus-visible:text-foreground focus-visible:outline-none",get open(){return e(ft)},set open(hr){R(ft,hr,!0)}})}};D(pt,fr=>{ue()&&fr(Qt)})}w(Pt),mr(Pt,fr=>R(Fe,fr),()=>e(Fe)),k(()=>vt(Pt,1,`wc-actions absolute right-1 top-1/2 z-20 flex -translate-y-1/2 items-center gap-0.5 rounded-md bg-accent/95 px-0.5 focus-within:opacity-100
265
265
  ${je()?"group-focus-within/wc:opacity-100":"group-focus-within:opacity-100"}
266
266
  ${Se()?"opacity-100":Q()?"opacity-0":je()?"opacity-0 group-hover/wc:opacity-100":"opacity-0 group-hover:opacity-100"}`,"svelte-1ct56pd")),d(bt,Pt)};D(Pa,bt=>{(xe()||ue()||Ce()||h()&&le())&&bt(Ba)})}w(Ft),mr(Ft,bt=>R(_e,bt),()=>e(_e)),Fn(Ft,(bt,Pt)=>Bs?.(bt,Pt),()=>({id:be()}));var Qr=m(Ft,2);{var $r=bt=>{qh(bt,{get id(){return e(U)},get anchor(){return`--workspace-list-${f().id??""}`},position:"right",get anchorElement(){return e(_e)},class:"w-auto overflow-visible! rounded-lg border-0! bg-background! shadow-none!",onmouseenter:Yt,onmouseleave:_t,onfocusin:Ht,onfocusout:Gt,children:(Pt,pr)=>{var xr=_k(),Pr=I(xr);Vh(Pr,{get workspace(){return f()},get activeAgentIds(){return F()},onkeydown:Ve}),w(xr),mr(xr,j=>R(nt,j),()=>e(nt)),En("pointerenter",xr,Yt),En("pointerleave",xr,_t),Lr("focusin",xr,Ht),Lr("focusout",xr,Gt),d(Pt,xr)},$$slots:{default:!0}})};D(Qr,bt=>{e(ce)&&!Q()&&bt($r)})}var Rn=m(Qr,2);{var $n=bt=>{const Pt=u(ht);var pr=kt(),xr=We(pr);{var Pr=j=>{{let Me=u(()=>e($e)?.x??0),pt=u(()=>e($e)?.y??0),Qt=u(()=>e($e)?.returnFocus),fr=u(()=>v.workspace_progressCard_actions_ariaLabel());od(j,{get x(){return e(Me)},get y(){return e(pt)},get returnFocus(){return e(Qt)},get ariaLabel(){return e(fr)},get items(){return e(Pt)},onClickOutside:xt})}};D(xr,j=>{e(Pt).length>0&&j(Pr)})}d(bt,pr)};D(Rn,bt=>{e($e)&&bt($n)})}k((bt,Pt,pr)=>{vt(Ft,1,bt,"svelte-1ct56pd"),se(Ft,"data-pinned",P()),se(Ft,"data-highlight-id",be()),ur=Pn(Ft,"",ur,{"anchor-name":`--workspace-list-${f().id??""}`}),se(Tn,"id",`workspace-status-state-${f().id??""}`),x(Zn,e(V).accessibleName),vt(Xt,1,`wc-title type-body min-w-0 truncate font-normal!
@@ -1 +1 @@
1
- var Me=Object.defineProperty;var De=(i,s,e)=>s in i?Me(i,s,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[s]=e;var m=(i,s,e)=>De(i,typeof s!="symbol"?s+"":s,e);import{x as Ne,J as oe,Z as ce,ai as q,ar as Ce}from"./Csmv6l_s.js";import{bX as Le,cW as le,cn as ue,cm as ve}from"./BxvZVFA9.js";import{Ik as p,B0 as we,bw as be,c as Fe,Kn as de,i8 as me,bI as ke,CX as z,Bp as Ge,f5 as Pe,zv as xe,dS as Ee,f1 as fe,dR as _e,zZ as Ve,K1 as Ue,vG as Be}from"./DYfeeu3f.js";import{aC as Ae,dG as he,A as H,P as Re,ay as K}from"./Dml826jn.js";import{ax as $e}from"./Cd_8r4jJ.js";import{c as Y}from"./ChTqQfQN.js";import{a as Xe}from"./BdWqymET.js";import{k as Q}from"./Cn76YSbd.js";import"./DYhIMPy1.js";import{bp as n}from"./CEL6QztG.js";import"./yn6WWSq8.js";import"./CiSnSGvU.js";import"./D-Brs8OV.js";import{R as ge}from"./BvFAWM27.js";import{L as We}from"./CSiaiLHL.js";function Ye(i,s){return i.some(e=>e.id===s.id)?i.map(e=>e.id===s.id?{...s,...s.author==null&&e.author!==void 0?{author:e.author}:{}}:e):[...i,s]}const Z=typeof performance<"u"?performance:{now:()=>Date.now()},V=new Xe("PerformanceOptimizer"),w=class w{constructor(){m(this,"metricsBuffer");m(this,"metricsIndex",0);m(this,"metricsCount",0);m(this,"MAX_METRICS",500);m(this,"TARGET_RESPONSE_TIME",100);m(this,"memoCache",new Map);m(this,"MEMO_TTL",6e4);m(this,"MAX_CACHE_SIZE",100);m(this,"cacheHits",0);m(this,"cacheMisses",0);m(this,"pendingRequests",new Map);m(this,"requestQueue",[]);m(this,"cleanupInterval",null);this.metricsBuffer=new Array(this.MAX_METRICS).fill(null),this.startCacheCleanup(),V.info("PerformanceOptimizer initialized")}static getInstance(){return w.instance||(w.instance=new w),w.instance}reset(){this.metricsBuffer=new Array(this.MAX_METRICS).fill(null),this.metricsIndex=0,this.metricsCount=0,this.memoCache.clear(),this.pendingRequests.clear(),this.requestQueue=[],this.cacheHits=0,this.cacheMisses=0}clearCache(){this.memoCache.clear(),this.cacheHits=0,this.cacheMisses=0}async processBatch(s,e,t={}){const{batchSize:r=10,concurrency:a=4}=t,l=[];for(let c=0;c<s.length;c+=r){const f=s.slice(c,c+r).map((o,g)=>{const R=Math.floor(g/a)*10;return new Promise(d=>{setTimeout(async()=>{const k=await e(o);d(k)},R)})}),u=await Promise.all(f);l.push(...u)}return l}startCacheCleanup(){this.cleanupInterval=setInterval(()=>{this.cleanupCache()},3e4)}stopCacheCleanup(){this.cleanupInterval&&(clearInterval(this.cleanupInterval),this.cleanupInterval=null)}cleanupCache(){const s=Date.now(),e=[];this.memoCache.forEach((t,r)=>{s-t.timestamp>this.MEMO_TTL&&e.push(r)}),e.forEach(t=>this.memoCache.delete(t)),this.memoCache.size>this.MAX_CACHE_SIZE&&Array.from(this.memoCache.entries()).sort((a,l)=>a[1].hits-l[1].hits||a[1].timestamp-l[1].timestamp).slice(0,this.memoCache.size-this.MAX_CACHE_SIZE).forEach(([a])=>this.memoCache.delete(a))}async track(s,e,t={}){const r=Z.now();try{const a=t.cacheKey||s;if(t.memoize){const f=this.getMemoized(a);if(f!==void 0)return this.cacheHits++,V.debug("Memoized result used",{operation:s,cacheKey:a,hits:this.cacheHits}),f;this.cacheMisses++}if(t.coalesce){const f=this.pendingRequests.get(s);if(f)return V.debug("Request coalesced",{operation:s}),f}let l;t.coalesce?(l=t.timeout?this.withTimeout(e(),t.timeout):e(),this.pendingRequests.set(s,l)):l=t.timeout?this.withTimeout(e(),t.timeout):e();const c=await l;t.memoize&&this.memoize(a,c);const E=Z.now()-r;return this.recordMetric(s,E,!0,{strategy:t.priority||"normal",memoized:t.memoize||!1,coalesced:t.coalesce||!1}),E>this.TARGET_RESPONSE_TIME&&V.warn("Operation exceeded target time",{operation:s,duration:Math.round(E),target:this.TARGET_RESPONSE_TIME}),c}catch(a){const l=Z.now()-r;throw this.recordMetric(s,l,!1,{error:a instanceof Error?a.message:"Unknown error"}),a}finally{t.coalesce&&this.pendingRequests.delete(s)}}getStats(){if(this.metricsCount===0)return{avgResponseTime:0,p95ResponseTime:0,p99ResponseTime:0,successRate:100,slowOperations:[]};const s=[],e=this.metricsCount<this.MAX_METRICS?0:this.metricsIndex;for(let u=0;u<this.metricsCount;u++){const o=this.metricsBuffer[(e+u)%this.MAX_METRICS];o&&s.push(o)}if(s.length===0)return{avgResponseTime:0,p95ResponseTime:0,p99ResponseTime:0,successRate:100,slowOperations:[]};const t=s.sort((u,o)=>u.duration-o.duration);let r=0,a=0;const l=new Set;for(const u of s)a+=u.duration,u.success&&r++,u.duration>this.TARGET_RESPONSE_TIME&&l.add(u.operation);const c=a/s.length,E=Math.floor(t.length*.95),f=Math.floor(t.length*.99);return{avgResponseTime:Math.round(c),p95ResponseTime:Math.round(t[E]?.duration||0),p99ResponseTime:Math.round(t[f]?.duration||0),successRate:r/s.length*100,slowOperations:Array.from(l)}}getCacheStats(){const s=this.cacheHits+this.cacheMisses;return{size:this.memoCache.size,hitRate:s>0?this.cacheHits/s*100:0,hits:this.cacheHits,misses:this.cacheMisses}}getMemoized(s){const e=this.memoCache.get(s);if(e){if(Date.now()-e.timestamp>this.MEMO_TTL){this.memoCache.delete(s);return}return e.hits++,e.value}}memoize(s,e){const t=JSON.stringify(e).length;this.memoCache.set(s,{value:e,timestamp:Date.now(),hits:0,size:t}),this.memoCache.size>this.MAX_CACHE_SIZE&&this.cleanupCache()}async withTimeout(s,e){return Promise.race([s,new Promise((t,r)=>setTimeout(()=>r(new Error(`Operation timed out after ${e}ms`)),e))])}recordMetric(s,e,t,r){this.metricsBuffer[this.metricsIndex]={operation:s,duration:e,timestamp:Date.now(),success:t,metadata:r},this.metricsIndex=(this.metricsIndex+1)%this.MAX_METRICS,this.metricsCount<this.MAX_METRICS&&this.metricsCount++,e>this.TARGET_RESPONSE_TIME&&V.warn("Slow operation detected",{operation:s,duration:`${e.toFixed(2)}ms`,target:`${this.TARGET_RESPONSE_TIME}ms`,metadata:r})}};m(w,"instance");let ee=w;const qe=ee.getInstance(),pe={AGENT_CREATION:"https://docs.example.com/agent-creation",STREAMING:"https://docs.example.com/streaming-issues",STORAGE:"https://docs.example.com/storage-troubleshooting",MEMORY:"https://docs.example.com/memory-management",PROVIDER:"https://docs.example.com/provider-setup",GENERAL:"https://docs.example.com/help"},j={get AGENT_CREATION_FAILED(){return n.errors_catalog_agentCreationFailed_template({agentName:"{agentName}",details:"{details}"})},get AGENT_ALREADY_EXISTS(){return n.errors_catalog_agentAlreadyExists_template({agentName:"{agentName}"})},get INVALID_AGENT_CONFIG(){return n.errors_catalog_invalidAgentConfig_template({details:"{details}"})},get INVALID_CONFIG(){return n.errors_catalog_invalidConfig_template({details:"{details}"})},get SESSION_NOT_FOUND(){return n.errors_catalog_sessionNotFound_template({sessionId:"{sessionId}"})},get SESSION_ALREADY_ACTIVE(){return n.errors_catalog_sessionAlreadyActive_template()},get SESSION_INITIALIZATION_FAILED(){return n.errors_catalog_sessionInitializationFailed_template({details:"{details}"})},get STREAM_CONNECTION_FAILED(){return n.errors_catalog_streamConnectionFailed_template({details:"{details}"})},get STREAM_TIMEOUT(){return n.errors_catalog_streamTimeout_template({timeout:"{timeout}"})},get STREAM_INTERRUPTED(){return n.errors_catalog_streamInterrupted_template({attempt:"{attempt}",maxAttempts:"{maxAttempts}"})},get STREAM_RECOVERY_FAILED(){return n.errors_catalog_streamRecoveryFailed_template({attempts:"{attempts}"})},get MESSAGE_SEND_FAILED(){return n.errors_catalog_messageSendFailed_template({details:"{details}"})},get MESSAGE_VALIDATION_FAILED(){return n.errors_catalog_messageValidationFailed_template({details:"{details}"})},get MESSAGE_TOO_LONG(){return n.errors_catalog_messageTooLong_template({maxLength:"{maxLength}",currentLength:"{currentLength}"})},get PROVIDER_NOT_FOUND(){return n.errors_catalog_providerNotFound_template({provider:"{provider}"})},get PROVIDER_CONNECTION_FAILED(){return n.errors_catalog_providerConnectionFailed_template({provider:"{provider}",details:"{details}"})},get PROVIDER_PROCESS_DIED(){return n.errors_catalog_providerProcessDied_template({provider:"{provider}"})},get STORAGE_READ_FAILED(){return n.errors_catalog_storageReadFailed_template({details:"{details}"})},get STORAGE_WRITE_FAILED(){return n.errors_catalog_storageWriteFailed_template({details:"{details}"})},get STORAGE_CORRUPTED(){return n.errors_catalog_storageCorrupted_template({lastBackup:"{lastBackup}"})},get MEMORY_LIMIT_EXCEEDED(){return n.errors_catalog_memoryLimitExceeded_template({currentUsage:"{currentUsage}",limit:"{limit}"})},get RATE_LIMIT_EXCEEDED(){return n.errors_catalog_rateLimitExceeded_template({count:"{count}",window:"{window}"})},get CONCURRENT_LIMIT_EXCEEDED(){return n.errors_catalog_concurrentLimitExceeded_template({current:"{current}",max:"{max}"})}},ze={get AGENT_CREATION_FAILED(){return n.errors_catalog_agentCreationFailed_friendly()},get AGENT_ALREADY_EXISTS(){return n.errors_catalog_agentAlreadyExists_friendly()},get INVALID_AGENT_CONFIG(){return n.errors_catalog_invalidAgentConfig_friendly()},get INVALID_CONFIG(){return n.errors_catalog_invalidConfig_friendly()},get SESSION_NOT_FOUND(){return n.errors_catalog_sessionNotFound_friendly()},get SESSION_ALREADY_ACTIVE(){return n.errors_catalog_sessionAlreadyActive_friendly()},get SESSION_INITIALIZATION_FAILED(){return n.errors_catalog_sessionInitializationFailed_friendly()},get STREAM_CONNECTION_FAILED(){return n.errors_catalog_streamConnectionFailed_friendly()},get STREAM_TIMEOUT(){return n.errors_catalog_streamTimeout_friendly()},get STREAM_INTERRUPTED(){return n.errors_catalog_streamInterrupted_friendly()},get STREAM_RECOVERY_FAILED(){return n.errors_catalog_streamRecoveryFailed_friendly()},get MESSAGE_SEND_FAILED(){return n.errors_catalog_messageSendFailed_friendly()},get MESSAGE_VALIDATION_FAILED(){return n.errors_catalog_messageValidationFailed_friendly()},get MESSAGE_TOO_LONG(){return n.errors_catalog_messageTooLong_friendly()},get PROVIDER_NOT_FOUND(){return n.errors_catalog_providerNotFound_friendly()},get PROVIDER_CONNECTION_FAILED(){return n.errors_catalog_providerConnectionFailed_friendly()},get PROVIDER_PROCESS_DIED(){return n.errors_catalog_providerProcessDied_friendly()},get STORAGE_READ_FAILED(){return n.errors_catalog_storageReadFailed_friendly()},get STORAGE_WRITE_FAILED(){return n.errors_catalog_storageWriteFailed_friendly()},get STORAGE_CORRUPTED(){return n.errors_catalog_storageCorrupted_friendly()},get MEMORY_LIMIT_EXCEEDED(){return n.errors_catalog_memoryLimitExceeded_friendly()},get RATE_LIMIT_EXCEEDED(){return n.errors_catalog_rateLimitExceeded_friendly()},get CONCURRENT_LIMIT_EXCEEDED(){return n.errors_catalog_concurrentLimitExceeded_friendly()}};function He(i){return(i.match(/{(\w+)}/g)||[]).map(e=>e.slice(1,-1))}function Ke(i,s){return He(i).every(t=>t in s)}function Ie(i,s={}){return i.replace(/{(\w+)}/g,(e,t)=>String(s[t]??e))}function J(i){const s=n.errors_cleanMessage_fallback_error();if(!i)return s;let e=i;return e=e.replace(/^.*?failed(?:\s+to\s+.*?)?\s+after\s+\d+\s+attempts:\s*/i,""),e=e.replace(/^Error invoking remote method '[^']+':(\s*Error:)?\s*/i,""),e=e.replace(/^(Error:\s*)+/i,""),e=e.replace(/\n\s*at .+/g,""),e=e.replace(/\s+/g," ").trim(),e||s}function Qe(i,s){return s&&j[i]&&Ke(j[i],s)?Ie(j[i],s):ze[i]||n.errors_userFriendly_fallback_error()}function Ze(i){const e={AGENT_CREATION_FAILED:"AGENT_CREATION",AGENT_ALREADY_EXISTS:"AGENT_CREATION",INVALID_AGENT_CONFIG:"AGENT_CREATION",STREAM_CONNECTION_FAILED:"STREAMING",STREAM_TIMEOUT:"STREAMING",STREAM_INTERRUPTED:"STREAMING",STREAM_RECOVERY_FAILED:"STREAMING",STORAGE_READ_FAILED:"STORAGE",STORAGE_WRITE_FAILED:"STORAGE",STORAGE_CORRUPTED:"STORAGE",MEMORY_LIMIT_EXCEEDED:"MEMORY",RATE_LIMIT_EXCEEDED:"MEMORY",CONCURRENT_LIMIT_EXCEEDED:"MEMORY",PROVIDER_NOT_FOUND:"PROVIDER",PROVIDER_CONNECTION_FAILED:"PROVIDER",PROVIDER_PROCESS_DIED:"PROVIDER"}[i];return e?pe[e]:pe.GENERAL}const je={AGENT_CREATION_FAILED:[{action:"retry",description:"Try creating the agent again",automatic:!1,priority:"high"},{action:"check-config",description:"Verify agent configuration in settings",automatic:!1,priority:"high"},{action:"check-resources",description:"Ensure sufficient memory and disk space",automatic:!1,priority:"medium"}],AGENT_ALREADY_EXISTS:[{action:"rename",description:"Choose a different name for the agent",automatic:!1,priority:"high"},{action:"delete-existing",description:"Delete the existing agent first",automatic:!1,priority:"medium"}],INVALID_AGENT_CONFIG:[{action:"review-config",description:"Review and correct the configuration",automatic:!1,priority:"high"},{action:"use-defaults",description:"Reset to default configuration",automatic:!1,priority:"medium"}],INVALID_CONFIG:[{action:"review-config",description:"Review and correct the configuration",automatic:!1,priority:"high"},{action:"use-defaults",description:"Reset to default configuration",automatic:!1,priority:"medium"}],SESSION_NOT_FOUND:[{action:"start-new",description:"Start a new agent session",automatic:!1,priority:"high"},{action:"check-history",description:"Check session history for recent sessions",automatic:!1,priority:"medium"}],SESSION_ALREADY_ACTIVE:[{action:"wait",description:"Wait for the current session to complete",automatic:!1,priority:"high"},{action:"cancel",description:"Cancel the active session first",automatic:!1,priority:"high"}],SESSION_INITIALIZATION_FAILED:[{action:"retry",description:"Try initializing the session again",automatic:!1,priority:"high"},{action:"check-resources",description:"Ensure sufficient resources are available",automatic:!1,priority:"medium"}],MESSAGE_SEND_FAILED:[{action:"retry",description:"Try sending the message again",automatic:!1,priority:"high"},{action:"check-connection",description:"Check your network connection",automatic:!1,priority:"high"}],MESSAGE_VALIDATION_FAILED:[{action:"review-config",description:"Review and correct the message format",automatic:!1,priority:"high"},{action:"check-config",description:"Check configuration for valid message format",automatic:!1,priority:"medium"}],MESSAGE_TOO_LONG:[{action:"retry",description:"Shorten the message and try again",automatic:!1,priority:"high"},{action:"batch",description:"Split the message into multiple parts",automatic:!1,priority:"medium"}],PROVIDER_NOT_FOUND:[{action:"check-config",description:"Verify provider is properly configured",automatic:!1,priority:"high"},{action:"recreate",description:"Install or reinstall the provider",automatic:!1,priority:"high"}],PROVIDER_CONNECTION_FAILED:[{action:"retry",description:"Try connecting to the provider again",automatic:!1,priority:"high"},{action:"check-config",description:"Verify provider configuration",automatic:!1,priority:"high"}],STORAGE_READ_FAILED:[{action:"retry",description:"Try reading the data again",automatic:!1,priority:"high"},{action:"restore",description:"Restore from a recent backup",automatic:!1,priority:"medium"}],STORAGE_WRITE_FAILED:[{action:"retry",description:"Try saving again",automatic:!1,priority:"high"},{action:"check-resources",description:"Check available disk space",automatic:!1,priority:"high"}],STREAM_CONNECTION_FAILED:[{action:"retry",description:"Try connecting again",automatic:!1,priority:"high"},{action:"check-connection",description:"Check your network connection",automatic:!1,priority:"high"}],STREAM_RECOVERY_FAILED:[{action:"restart",description:"Restart the agent",automatic:!1,priority:"high"},{action:"check-config",description:"Check error logs for more details",automatic:!1,priority:"medium"}],STREAM_INTERRUPTED:[{action:"reconnect",description:"Attempting automatic reconnection",automatic:!0,priority:"high"},{action:"retry",description:"Retry sending the message",automatic:!1,priority:"high"},{action:"check-connection",description:"Check your internet connection",automatic:!1,priority:"medium"}],STREAM_TIMEOUT:[{action:"wait",description:"Wait for agent to complete processing",automatic:!1,priority:"high"},{action:"cancel",description:"Cancel current operation",automatic:!1,priority:"medium"},{action:"increase-timeout",description:"Increase timeout in settings",automatic:!1,priority:"low"}],PROVIDER_PROCESS_DIED:[{action:"restart",description:"Restart agent process",automatic:!0,priority:"high"},{action:"recreate",description:"Create new agent session",automatic:!1,priority:"high"}],STORAGE_CORRUPTED:[{action:"restore",description:"Restore from backup",automatic:!1,priority:"high"},{action:"reset",description:"Reset agent data",automatic:!1,priority:"medium"}],MEMORY_LIMIT_EXCEEDED:[{action:"cleanup",description:"Close unused agents",automatic:!1,priority:"high"},{action:"increase-limit",description:"Increase memory limit in settings",automatic:!1,priority:"medium"}],RATE_LIMIT_EXCEEDED:[{action:"wait",description:"Wait before making more requests",automatic:!1,priority:"high"},{action:"batch",description:"Batch requests together",automatic:!1,priority:"medium"}],CONCURRENT_LIMIT_EXCEEDED:[{action:"close-agents",description:"Close some running agents",automatic:!1,priority:"high"},{action:"queue",description:"Queue operation for later",automatic:!1,priority:"medium"}]};function Je(i){return je[i]||[{action:"retry",description:"Try the operation again",automatic:!1,priority:"high"}]}var D=(i=>(i.AGENT_CREATION_FAILED="AGENT_CREATION_FAILED",i.AGENT_ALREADY_EXISTS="AGENT_ALREADY_EXISTS",i.INVALID_AGENT_CONFIG="INVALID_AGENT_CONFIG",i.INVALID_CONFIG="INVALID_CONFIG",i.SESSION_NOT_FOUND="SESSION_NOT_FOUND",i.SESSION_ALREADY_ACTIVE="SESSION_ALREADY_ACTIVE",i.SESSION_INITIALIZATION_FAILED="SESSION_INITIALIZATION_FAILED",i.STREAM_CONNECTION_FAILED="STREAM_CONNECTION_FAILED",i.STREAM_TIMEOUT="STREAM_TIMEOUT",i.STREAM_INTERRUPTED="STREAM_INTERRUPTED",i.STREAM_RECOVERY_FAILED="STREAM_RECOVERY_FAILED",i.MESSAGE_SEND_FAILED="MESSAGE_SEND_FAILED",i.MESSAGE_VALIDATION_FAILED="MESSAGE_VALIDATION_FAILED",i.MESSAGE_TOO_LONG="MESSAGE_TOO_LONG",i.PROVIDER_NOT_FOUND="PROVIDER_NOT_FOUND",i.PROVIDER_CONNECTION_FAILED="PROVIDER_CONNECTION_FAILED",i.PROVIDER_PROCESS_DIED="PROVIDER_PROCESS_DIED",i.PROVIDER_UNAVAILABLE="PROVIDER_UNAVAILABLE",i.PROVIDER_ERROR="PROVIDER_ERROR",i.STORAGE_READ_FAILED="STORAGE_READ_FAILED",i.STORAGE_WRITE_FAILED="STORAGE_WRITE_FAILED",i.STORAGE_CORRUPTED="STORAGE_CORRUPTED",i.STORAGE_ERROR="STORAGE_ERROR",i.STORAGE_QUOTA_EXCEEDED="STORAGE_QUOTA_EXCEEDED",i.MEMORY_LIMIT_EXCEEDED="MEMORY_LIMIT_EXCEEDED",i.RATE_LIMIT_EXCEEDED="RATE_LIMIT_EXCEEDED",i.CONCURRENT_LIMIT_EXCEEDED="CONCURRENT_LIMIT_EXCEEDED",i.RESOURCE_NOT_FOUND="RESOURCE_NOT_FOUND",i.RESOURCE_EXHAUSTED="RESOURCE_EXHAUSTED",i.NETWORK_ERROR="NETWORK_ERROR",i.PERMISSION_DENIED="PERMISSION_DENIED",i.OPERATION_FAILED="OPERATION_FAILED",i.VALIDATION_ERROR="VALIDATION_ERROR",i.INVALID_RESPONSE="INVALID_RESPONSE",i.STATE_CORRUPTION="STATE_CORRUPTION",i.CONTEXT_OVERFLOW="CONTEXT_OVERFLOW",i))(D||{});class W extends Error{constructor(e,t,r={},a){super(e);m(this,"code");m(this,"context");m(this,"recoverySuggestions");m(this,"userMessage");m(this,"isRecoverable");m(this,"cause");this.name="AgentError",this.code=t,this.context={...r,timestamp:new Date,stackTrace:this.stack},this.userMessage=a?.userMessage||this.getDefaultUserMessage(t),this.recoverySuggestions=a?.recoverySuggestions||this.getDefaultRecoverySuggestions(t),this.isRecoverable=a?.isRecoverable??this.isErrorRecoverable(t),a?.cause&&(this.cause=a.cause)}getDefaultUserMessage(e){return Qe(e,this.context)}getDefaultRecoverySuggestions(e){return Je(e)}isErrorRecoverable(e){return["STREAM_INTERRUPTED","STREAM_TIMEOUT","MESSAGE_SEND_FAILED","PROVIDER_PROCESS_DIED","STORAGE_READ_FAILED","STORAGE_WRITE_FAILED"].includes(e)}getHelpLink(){return Ze(this.code)}formatMessage(e){return Ie(e,this.context)}toJSON(){return{name:this.name,code:this.code,message:this.message,userMessage:this.userMessage,context:this.context,recoverySuggestions:this.recoverySuggestions,isRecoverable:this.isRecoverable,helpLink:this.getHelpLink(),stack:this.stack}}}const et={NON_RETRYABLE_ERRORS:["EACCES","EPERM","ENOSPC","EMFILE","permission","memory","fatal","process died","not available on your current plan","agent binary","rate limit","too many requests","hit your limit","you've hit your limit","quota exceeded"]};function ie(i){const s=i.toLowerCase();for(const e of et.NON_RETRYABLE_ERRORS)if(s.includes(e.toLowerCase()))return!0;return!1}const tt="Agent already has an in-flight prompt. Message was not delivered.",v=Y("ErrorBoundary"),b=class b{constructor(){}static getInstance(){return b.instance||(b.instance=new b),b.instance}async wrap(s,e,t={}){const{retries:r=ge.DEFAULT_ATTEMPTS,retryDelay:a=ge.BASE_DELAY,exponentialBackoff:l=!0,notify:c=!1,notifyOnRetry:E=!1,context:f={},onError:u,onRetry:o,shouldRetry:g=this.defaultShouldRetry}=t;let R=null,d=0;for(d=1;d<=r+1;d++)try{v.debug(`[${e}] Attempt ${d}/${r+1}`);const h=await s();return d>1&&v.info(`[${e}] Succeeded after ${d} attempts`),h}catch(h){if(R=h,v.error(`[${e}] Attempt ${d} failed`,{error:R.message,attempt:d,maxAttempts:r+1,context:f}),u?.(R,d),d<=r&&g(R)){const C=l?a*Math.pow(2,d-1):a;E&&Q.warning(n.agent_errorBoundary_retrying_message({seconds:C/1e3})),o?.(d),v.info(`[${e}] Retrying in ${C}ms`),await this.sleep(C)}else break}const k=`${e} failed after ${d} attempt${d===1?"":"s"}: ${R?.message}`,P=J(R?.message||n.agent_errorBoundary_generic_error()),N=R?.message?.toLowerCase()||"",$=N.includes("no available models")||N.includes("all models exhausted")||N.includes("all models unavailable");throw c&&!$&&Q.error(P),new W(P,D.OPERATION_FAILED,{originalError:R?.message,detailedMessage:k,attempts:d,context:f})}async wrapVoid(s,e,t={}){await this.wrap(s,e,t)}wrapSync(s,e,t={}){try{return s()}catch(r){const a=r;throw v.error(`[${e}] Failed`,{error:a.message,context:t.context}),t.notify&&Q.error(J(a.message)),new W(J(a.message),D.OPERATION_FAILED,t.context)}}defaultShouldRetry(s){const e=s.message.toLowerCase();return ie(s.message)?!1:e.includes("network")||e.includes("timeout")?!0:s instanceof W?[D.NETWORK_ERROR,D.STREAM_TIMEOUT,D.STREAM_CONNECTION_FAILED,D.PROVIDER_CONNECTION_FAILED,D.PROVIDER_UNAVAILABLE].includes(s.code):!(e.includes("invalid")||e.includes("interrupted")||e.includes("cancel")||e.includes("not found")||e.includes("not available")||e.includes("404")||e.includes("no available models")||e.includes("all models exhausted")||e.includes("all models unavailable")||e.includes("413")||e.includes("too long for the agent")||e.includes("request entity too large")||e.includes("payload too large")||e.includes("content too large")||e.includes("body too large")||e.includes("unauthorized")||e.includes("forbidden")||e.includes("401")||e.includes("403"))}sleep(s){return new Promise(e=>setTimeout(e,s))}async withTimeout(s,e,t){return Promise.race([s(),new Promise((r,a)=>setTimeout(()=>a(new W(`${t} timed out after ${e}ms`,D.STREAM_TIMEOUT)),e))])}async batchOperations(s,e,t={}){const{concurrency:r=5,continueOnError:a=!0,operationName:l="batch operation"}=t,c=[],E=[];for(let f=0;f<s.length;f+=r){const u=s.slice(f,f+r);(await Promise.allSettled(u.map(g=>e(g)))).forEach((g,R)=>{if(g.status==="fulfilled")c.push(g.value);else{const d=g.reason;if(E.push({item:u[R],error:d}),v.error(`[${l}] Batch item failed`,{item:u[R],error:d.message}),!a)throw d}})}return E.length>0&&v.warn(`[${l}] Completed with ${E.length} errors`),{results:c,errors:E}}};m(b,"instance");let te=b;const st=te.getInstance(),se=Y("browser/index"),F=new Map,B=new Map;let U;function it(i,s,e){for(const t of s)try{t(e)}catch(r){se.error("Error in agent subscriber callback",{agentId:i,error:r})}}function rt(){if(U)return;let i=!1;U=p.createSelector(e=>e.agentSessions)().subscribe(()=>{if(!i){i=!0;return}if(F.size===0)return;const e=p.state;for(const[t,r]of F){const a=Ae.select(e,t);B.get(t)!==a&&(B.set(t,a),it(t,r,a))}})}function at(){F.size>0||!U||(U(),U=void 0,B.clear())}function Ct(i,s,e){let t=F.get(i);const r=!t;t||(t=new Set,F.set(i,t)),t.add(s),rt();const a=p.state,l=Ae.select(a,i);return r&&B.set(i,l),l?se.debug("[subscribeToAgent] Initial callback data",{agentId:i,workspaceId:e??"current",hasSession:!0}):se.debug("[subscribeToAgent] No session found",{agentId:i,workspaceId:e??"current"}),s(l),()=>{const c=F.get(i);c&&(c.delete(s),c.size===0&&(F.delete(i),B.delete(i))),at()}}const y=Y("ErrorRecovery"),Se={network:{maxRetries:3,initialBackoffMs:1e3,maxBackoffMs:1e4,backoffMultiplier:2,shouldRetry:i=>{const s=i.message.toLowerCase();return s.includes("network")||s.includes("fetch")||s.includes("connection")||s.includes("timeout")}},streaming:{maxRetries:5,initialBackoffMs:500,maxBackoffMs:5e3,backoffMultiplier:1.5,shouldRetry:(i,s)=>{if(s>=5)return!1;const e=i.message.toLowerCase();return e.includes("no available models")||e.includes("all models exhausted")||e.includes("all models unavailable")||ie(i.message)?!1:e.includes("stream")||e.includes("chunk")||e.includes("incomplete")}},persistence:{maxRetries:2,initialBackoffMs:100,maxBackoffMs:1e3,backoffMultiplier:2,shouldRetry:i=>{const s=i.message.toLowerCase();return s.includes("save")||s.includes("write")||s.includes("persist")}},rateLimit:{maxRetries:3,initialBackoffMs:5e3,maxBackoffMs:3e4,backoffMultiplier:2,shouldRetry:i=>{const s=i.message.toLowerCase();return s.includes("rate")||s.includes("limit")||s.includes("429")}}};class nt{constructor(){m(this,"listeners",new Map)}on(s,e){let t=this.listeners.get(s);t||(t=new Set,this.listeners.set(s,t)),t.add(e)}off(s,e){this.listeners.get(s)?.delete(e)}emit(s,...e){this.listeners.get(s)?.forEach(t=>{try{t(...e)}catch(r){y.error(`Error in event listener for ${s}:`,r)}})}removeAllListeners(){this.listeners.clear()}}class ot extends nt{constructor(){super(...arguments);m(this,"activeRecoveries",new Map);m(this,"recoveryStats",new Map)}async executeWithRecovery(e,t=Se.network,r){const a=Date.now(),l=new AbortController;r&&(this.cancelRecovery(r),this.activeRecoveries.set(r,l));let c,E=t.initialBackoffMs,f=0;for(let u=1;u<=t.maxRetries;u++){if(f=u,l.signal.aborted){y.info(`Recovery cancelled for operation ${r}`);break}try{y.debug(`Attempting operation (attempt ${u}/${t.maxRetries})`,{operationId:r});const o=await e();return this.updateStats(r,!0),this.emit("recovery:success",{operationId:r,attempt:u,duration:Date.now()-a}),r&&this.activeRecoveries.delete(r),{success:!0,data:o,attempts:u,totalTime:Date.now()-a}}catch(o){c=o,y.warn(`Operation failed (attempt ${u}/${t.maxRetries})`,{operationId:r,error:c.message});const g=c.message.toLowerCase();if(g.includes("interrupted")||g.includes("cancelled")||g.includes("canceled")){y.debug("User-initiated interruption/cancellation, not retrying",{operationId:r,error:c.message});break}if(g.includes("no available models")||g.includes("all models exhausted")||g.includes("all models unavailable")){y.debug("All models exhausted, not retrying",{operationId:r,error:c.message});break}if(ie(c.message)){y.debug("Fatal error detected, not retrying",{operationId:r,error:c.message});break}if(!t.shouldRetry(c,u)){y.debug("Error not retryable, stopping recovery",{operationId:r,error:c.message});break}if(u<t.maxRetries){const R=Math.random()*.2*E,d=Math.min(E+R,t.maxBackoffMs);t.onRetry?.(u,d),this.emit("recovery:retry",{operationId:r,attempt:u,delay:d,error:c.message}),await this.delay(d,l.signal),E=Math.min(E*t.backoffMultiplier,t.maxBackoffMs)}}}return this.updateStats(r,!1),t.onFailure?.(c,f),this.emit("recovery:failure",{operationId:r,attempts:f,duration:Date.now()-a,error:c?.message}),r&&this.activeRecoveries.delete(r),{success:!1,error:c,attempts:f,totalTime:Date.now()-a}}cancelRecovery(e){const t=this.activeRecoveries.get(e);t&&(t.abort(),this.activeRecoveries.delete(e),y.info(`Cancelled recovery for operation ${e}`))}cancelAllRecoveries(){for(const[e,t]of this.activeRecoveries)t.abort(),y.info(`Cancelled recovery for operation ${e}`);this.activeRecoveries.clear()}getStats(e){if(e)return this.recoveryStats.get(e)||{successes:0,failures:0};const t={};for(const[r,a]of this.recoveryStats)t[r]=a;return t}clearStats(e){e?this.recoveryStats.delete(e):this.recoveryStats.clear()}isRetryable(e,t){const r=e.message.toLowerCase();if(t)switch(t){case"NETWORK":return r.includes("network")||r.includes("fetch");case"TIMEOUT":return r.includes("timeout")||r.includes("timed out");case"RATE_LIMIT":return r.includes("rate")||r.includes("limit")||r.includes("429");case"TEMPORARY":return r.includes("temporary")||r.includes("transient");case"CONFLICT":return r.includes("conflict")||r.includes("concurrent");default:return!1}return this.isRetryable(e,"NETWORK")||this.isRetryable(e,"TIMEOUT")||this.isRetryable(e,"RATE_LIMIT")||this.isRetryable(e,"TEMPORARY")||this.isRetryable(e,"CONFLICT")}delay(e,t){return new Promise((r,a)=>{const l=setTimeout(r,e);if(t){const c=()=>{clearTimeout(l),a(new Error("Delay aborted"))};t.addEventListener("abort",c);const E=r;r=()=>{t.removeEventListener("abort",c),E()}}})}updateStats(e,t){if(!e)return;const r=this.recoveryStats.get(e)||{successes:0,failures:0};t?r.successes++:r.failures++,this.recoveryStats.set(e,r)}dispose(){this.cancelAllRecoveries(),this.recoveryStats.clear(),this.removeAllListeners()}}const ct=new ot,O=new We({category:"WorkspaceMetrics"}),lt=100;class ut{constructor(){m(this,"metrics",new Map);m(this,"operations",new Map)}startWorkspaceCreation(s){const e=Date.now();for(this.metrics.delete(s),this.metrics.set(s,{workspaceId:s,creationStarted:e});this.metrics.size>lt;){const t=this.metrics.keys().next().value;if(t===void 0)break;this.metrics.delete(t)}O.info("Started tracking workspace creation",{workspaceId:s})}recordMilestone(s,e){const t=this.metrics.get(s);if(!t){O.warn("No metrics found for workspace",{workspaceId:s,milestone:e});return}const r=Date.now();switch(e){case"optimisticNavigation":t.optimisticNavigation=r;break;case"realWorkspaceCreated":t.realWorkspaceCreated=r;break;case"agentCreated":t.agentCreated=r;break;case"agentReady":t.agentReady=r;break;case"firstMessageSent":t.firstMessageSent=r;break;case"firstResponseReceived":t.firstResponseReceived=r;break;case"firstChunkReceived":t.firstChunkReceived=r;break;case"totalDuration":t.totalDuration=r;break;case"workspaceId":case"creationStarted":O.warn("Cannot update milestone",{milestone:e});return}const a=r-t.creationStarted;O.info(`Milestone: ${e}`,{workspaceId:s,elapsed:`${a}ms`,timestamp:r}),e==="firstResponseReceived"&&(t.totalDuration=r-t.creationStarted,this.logSummary(s))}startOperation(s,e){this.operations.set(s,{startTime:Date.now(),metadata:e})}endOperation(s,e){const t=this.operations.get(s);if(!t)return O.warn("Operation not found",{operationId:s}),null;const r=Date.now();return t.endTime=r,t.duration=r-t.startTime,e&&(t.metadata={...t.metadata,...e}),O.info("Operation completed",{operationId:s,duration:`${t.duration}ms`,metadata:t.metadata}),this.operations.delete(s),t.duration}getMetrics(s){return this.metrics.get(s)}logSummary(s){const e=this.metrics.get(s);if(!e)return;const t={workspaceId:s,totalDuration:`${e.totalDuration}ms`,stages:{optimisticNavigation:e.optimisticNavigation?`${e.optimisticNavigation-e.creationStarted}ms`:"N/A",realWorkspaceCreation:e.realWorkspaceCreated?`${e.realWorkspaceCreated-e.creationStarted}ms`:"N/A",agentCreation:e.agentCreated?`${e.agentCreated-e.creationStarted}ms`:"N/A",agentReady:e.agentReady?`${e.agentReady-e.creationStarted}ms`:"N/A",firstMessage:e.firstMessageSent?`${e.firstMessageSent-e.creationStarted}ms`:"N/A",firstResponse:e.firstResponseReceived?`${e.firstResponseReceived-e.creationStarted}ms`:"N/A"}};O.info("=== Workspace Creation Metrics Summary ===",t),O.info("Workspace Creation Metrics:",t)}clearMetrics(s){this.metrics.delete(s)}incrementAgentCreated(s){const e=this.metrics.get(s);e&&(e.agentCreated=Date.now(),O.info("Agent created",{workspaceId:s}))}incrementMessageSent(s){const e=this.metrics.get(s);e&&!e.firstMessageSent&&(e.firstMessageSent=Date.now(),O.info("First message sent",{workspaceId:s}))}}const dt=new ut,M=Y("AgentSend");function A(i){p.dispatch(i)}function Te(i){return typeof i=="object"&&i!==null&&!Array.isArray(i)}function mt(i){const s=Te(i)&&i.success===!0&&"data"in i?i.data:i;return!Te(s)||s.success!==!1?!1:typeof s.error=="string"&&s.error.includes(tt)}async function Lt(i,s,e,t={}){const r=he.select(p.state,e.id);if(!r)return;const a=Ne(i,e.id),l=t.submission,c=!!l&&Le.select(p.state,l.scope)?.supported===!0,E=(o,g,R=!1)=>{l&&A(Be(l.scope,l.id,o,Date.now(),g,R))};let f=!1;const u=()=>(!l||f||ve.select(p.state,l))&&r===he.select(p.state,e.id)&&a.isCurrent(p.state.agentSessions?.byAgentId[i]?.workspaceId);return qe.track(`sendMessage:${a.key}:${i}:${l?.id??"legacy"}`,async()=>{if(!u())return;M.debug(`Sending message to agent ${i}`,{contentLength:s.length,hasContextReferences:!!t.contextReferences?.length,model:t.model});let o=await p.dispatch(we(e.id,i));if(u()){if(!o)throw new Error(n.agent_streamLifecycle_sessionNotFound_error({agentId:i}));o={...o,isStreaming:o.isStreaming??!1};{if(o&&(o.status==="pending"||!o.id)&&!o.backendSessionId&&o.activationState!==H.ACTIVE&&o.activationState!==H.ACTIVATING){const h=e.id.startsWith("optimistic-"),C=e.worktreePath||e.repositoryPath||e.path;if(!h&&C){M.info("Activating pending session in sendMessage",{agentId:i,status:o.status,activationState:o.activationState,hasBackendSessionId:!!o.backendSessionId});const x=await p.dispatch(be(e.id,i));if(!u())return;x&&(o=x)}else throw M.warn("Cannot activate agent - workspace not ready",{agentId:i,workspaceId:e.id,isOptimistic:h,hasWorktreePath:!!e.worktreePath,hasRepositoryPath:!!e.repositoryPath,hasPath:!!e.path}),new Error(n.agent_streamLifecycle_spaceNotReady_error())}else o&&o.status==="pending"&&o.backendSessionId&&(M.info("Fixing status for already-activated session",{agentId:i,backendSessionId:o.backendSessionId,activationState:o.activationState}),o={...o,status:Fe.Active,activationState:H.ACTIVE},A(de({...o,workspaceId:e.id})));if(!o)throw new Error(`Failed to get or create session for agent ${i}`);A(de({...o,workspaceId:e.id}));const R=[{type:"text",text:s}];if(t.imageBlocks)for(const h of t.imageBlocks)R.push({type:"image",...h.data!==void 0?{data:h.data}:{},...h.mimeType!==void 0?{mimeType:h.mimeType}:{},...h.attachmentId!==void 0?{attachmentId:h.attachmentId}:{}});if(t.fileBlocks)for(const h of t.fileBlocks)R.push({type:"file",attachmentId:h.attachmentId,fileName:h.fileName,...h.mimeType!==void 0?{mimeType:h.mimeType}:{},...h.size!==void 0?{size:h.size}:{}});const d=t.userAppMessageId??oe(),k=t.messageMetadata?.[Re],P={...t.contextReferences?.length?{contextReferences:t.contextReferences}:{},...k!==void 0?{[Re]:k}:{}},N={id:me(le()),appMessageId:d,role:"user",contentBlocks:R,timestamp:new Date().toISOString(),metadata:{...P,...t.messageMetadata??{}}};c||(l&&(E("rejected"),f=!0),A(ke(o.id,N))),A(z(o.id,!0));let $=!1;try{c||await p.dispatch(Ge(e.id,i,!0,{allowTruncation:t.resetHistory}));const h=me(`msg_${le()}`),C=oe(),x=async()=>st.wrap(async()=>{if(!u())return;M.info("Agent Service: Sending message to backend with image and file blocks",{agentId:i,sessionId:o.id,hasImageBlocks:!!t.imageBlocks,imageBlocksCount:t.imageBlocks?.length||0,imageBlockDetails:t.imageBlocks?.map(_=>({type:_.type,mimeType:_.mimeType,dataLength:_.data?.length||0}))||[],hasFileBlocks:!!t.fileBlocks,fileBlocksCount:t.fileBlocks?.length||0,fileBlockDetails:t.fileBlocks?.map(_=>({type:_.type,fileName:_.fileName,mimeType:_.mimeType,attachmentId:_.attachmentId,size:_.size}))||[]});const Oe=t.model??t.modelId??o.model??void 0;A(Pe(i));const ye=ce(i,e.id),ae=p.state.chatState?.byAgentId[i]?.attemptGeneration??0,T=await $e("agent.sendMessage",{agentId:i,...c&&l?{messageId:l.id}:{},workspaceId:e.id,content:s,model:Oe,contextReferences:t.contextReferences,imageBlocks:t.imageBlocks,fileBlocks:t.fileBlocks,noteIds:t.noteIds,stdinContext:t.stdinContext,assistantMessageId:h,userAppMessageId:d,assistantAppMessageId:C,priority:t.priority,...t.messageMetadata?{messageMetadata:t.messageMetadata}:{}}).catch(_=>{if(u())throw _});if(u()){if(mt(T)){M.info("Backend dropped duplicate in-flight prompt",{agentId:i,sessionId:o.id}),E("rejected");return}if(T&&typeof T=="object"&&"success"in T){if(!T.success){const _=T.error,I=typeof _=="string"?_:_?.message;throw $=!0,new Error(I||n.agent_streamLifecycle_sendToBackendFailed_error())}if("queued"in T&&T.queued===!0){if(M.info("sendMessage auto-queued by daemon (mid-turn or turn-startup race)",{agentId:i,sessionId:o.id,queuedMessageId:T.queuedMessage?.id}),(!c||!l||!ue.select(p.state,l))&&A(z(o.id,!1)),c||A(xe(o.id,N.id)),c){const I=T.queuedMessage,G=T.turnId,L=typeof G=="string"?G:I?.turnId;if(I&&typeof L=="string"){const S=Ee(s,t),X=K.select(p.state,i,e.id).find(ne=>ne.id===I.id||ne.turnId===L);A(fe(i,I.id,S,L,_e(X??I,S),!X&&!!l&&ue.select(p.state,l),ae))}E("accepted",I,!0),q(i,e.id);return}const _=T.queuedMessage;if(_){const I=T.turnId,G=typeof I=="string"?I:_.turnId;let L=_;if(u()&&ce(i,e.id)===ye){const S=K.select(p.state,i,e.id),X=Ye(S,_);A(Ve(i,X,e.id))}else u()&&(M.debug("queued-response queue seed superseded by an authoritative snapshot; reconciling via hydrate",{agentId:i,queuedMessageId:_.id}),await q(i,e.id).catch(()=>{}),L=K.select(p.state,i,e.id).find(S=>S.id===_.id||S.turnId===G));if(u()&&typeof G=="string"){const S=Ee(s,t);A(fe(i,_.id,S,G,_e(L??_,S),!L,ae))}else u()&&M.warn("auto-queued sendMessage response carried no turnId; retry record not parked",{agentId:i,queuedMessageId:_.id})}return}}c&&(E("accepted"),q(i,e.id),Ce(i,e.id)),dt.incrementMessageSent(e.id)}},"send message",{retries:c?0:2,notify:!1,context:{agentId:i,workspace:e.id}}),re=c?await x().then(()=>({success:!0,error:void 0})):await ct.executeWithRecovery(x,Se.streaming,`send-message-${i}`);if(!re.success)throw re.error||new Error(n.agent_streamLifecycle_sendFailed_error())}catch(h){if(!u())return;throw A(z(o.id,!1)),!c&&t.messageMetadata&&A(Ue(o.id,N.id,{metadata:P})),c&&E($?"rejected":"uncertain"),h}}}},{memoize:!1,coalesce:!0,priority:"high"})}export{Ct as a,J as c,Ye as r,Lt as s};
1
+ var Me=Object.defineProperty;var De=(i,s,e)=>s in i?Me(i,s,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[s]=e;var m=(i,s,e)=>De(i,typeof s!="symbol"?s+"":s,e);import{x as Ne,J as oe,Z as ce,ai as q,ar as Ce}from"./XTm8XS4k.js";import{bX as Le,cW as le,cn as ue,cm as ve}from"./qS-FFtmP.js";import{Ik as p,B0 as we,bw as be,c as Fe,Kn as de,i8 as me,bI as ke,CX as z,Bp as Ge,f5 as Pe,zv as xe,dS as Ee,f1 as fe,dR as _e,zZ as Ve,K1 as Ue,vG as Be}from"./DYfeeu3f.js";import{aC as Ae,dG as he,A as H,P as Re,ay as K}from"./Dml826jn.js";import{ax as $e}from"./Cd_8r4jJ.js";import{c as Y}from"./ChTqQfQN.js";import{a as Xe}from"./BdWqymET.js";import{k as Q}from"./Cn76YSbd.js";import"./DYhIMPy1.js";import{bp as n}from"./CEL6QztG.js";import"./yn6WWSq8.js";import"./CiSnSGvU.js";import"./D-Brs8OV.js";import{R as ge}from"./BvFAWM27.js";import{L as We}from"./CSiaiLHL.js";function Ye(i,s){return i.some(e=>e.id===s.id)?i.map(e=>e.id===s.id?{...s,...s.author==null&&e.author!==void 0?{author:e.author}:{}}:e):[...i,s]}const Z=typeof performance<"u"?performance:{now:()=>Date.now()},V=new Xe("PerformanceOptimizer"),w=class w{constructor(){m(this,"metricsBuffer");m(this,"metricsIndex",0);m(this,"metricsCount",0);m(this,"MAX_METRICS",500);m(this,"TARGET_RESPONSE_TIME",100);m(this,"memoCache",new Map);m(this,"MEMO_TTL",6e4);m(this,"MAX_CACHE_SIZE",100);m(this,"cacheHits",0);m(this,"cacheMisses",0);m(this,"pendingRequests",new Map);m(this,"requestQueue",[]);m(this,"cleanupInterval",null);this.metricsBuffer=new Array(this.MAX_METRICS).fill(null),this.startCacheCleanup(),V.info("PerformanceOptimizer initialized")}static getInstance(){return w.instance||(w.instance=new w),w.instance}reset(){this.metricsBuffer=new Array(this.MAX_METRICS).fill(null),this.metricsIndex=0,this.metricsCount=0,this.memoCache.clear(),this.pendingRequests.clear(),this.requestQueue=[],this.cacheHits=0,this.cacheMisses=0}clearCache(){this.memoCache.clear(),this.cacheHits=0,this.cacheMisses=0}async processBatch(s,e,t={}){const{batchSize:r=10,concurrency:a=4}=t,l=[];for(let c=0;c<s.length;c+=r){const f=s.slice(c,c+r).map((o,g)=>{const R=Math.floor(g/a)*10;return new Promise(d=>{setTimeout(async()=>{const k=await e(o);d(k)},R)})}),u=await Promise.all(f);l.push(...u)}return l}startCacheCleanup(){this.cleanupInterval=setInterval(()=>{this.cleanupCache()},3e4)}stopCacheCleanup(){this.cleanupInterval&&(clearInterval(this.cleanupInterval),this.cleanupInterval=null)}cleanupCache(){const s=Date.now(),e=[];this.memoCache.forEach((t,r)=>{s-t.timestamp>this.MEMO_TTL&&e.push(r)}),e.forEach(t=>this.memoCache.delete(t)),this.memoCache.size>this.MAX_CACHE_SIZE&&Array.from(this.memoCache.entries()).sort((a,l)=>a[1].hits-l[1].hits||a[1].timestamp-l[1].timestamp).slice(0,this.memoCache.size-this.MAX_CACHE_SIZE).forEach(([a])=>this.memoCache.delete(a))}async track(s,e,t={}){const r=Z.now();try{const a=t.cacheKey||s;if(t.memoize){const f=this.getMemoized(a);if(f!==void 0)return this.cacheHits++,V.debug("Memoized result used",{operation:s,cacheKey:a,hits:this.cacheHits}),f;this.cacheMisses++}if(t.coalesce){const f=this.pendingRequests.get(s);if(f)return V.debug("Request coalesced",{operation:s}),f}let l;t.coalesce?(l=t.timeout?this.withTimeout(e(),t.timeout):e(),this.pendingRequests.set(s,l)):l=t.timeout?this.withTimeout(e(),t.timeout):e();const c=await l;t.memoize&&this.memoize(a,c);const E=Z.now()-r;return this.recordMetric(s,E,!0,{strategy:t.priority||"normal",memoized:t.memoize||!1,coalesced:t.coalesce||!1}),E>this.TARGET_RESPONSE_TIME&&V.warn("Operation exceeded target time",{operation:s,duration:Math.round(E),target:this.TARGET_RESPONSE_TIME}),c}catch(a){const l=Z.now()-r;throw this.recordMetric(s,l,!1,{error:a instanceof Error?a.message:"Unknown error"}),a}finally{t.coalesce&&this.pendingRequests.delete(s)}}getStats(){if(this.metricsCount===0)return{avgResponseTime:0,p95ResponseTime:0,p99ResponseTime:0,successRate:100,slowOperations:[]};const s=[],e=this.metricsCount<this.MAX_METRICS?0:this.metricsIndex;for(let u=0;u<this.metricsCount;u++){const o=this.metricsBuffer[(e+u)%this.MAX_METRICS];o&&s.push(o)}if(s.length===0)return{avgResponseTime:0,p95ResponseTime:0,p99ResponseTime:0,successRate:100,slowOperations:[]};const t=s.sort((u,o)=>u.duration-o.duration);let r=0,a=0;const l=new Set;for(const u of s)a+=u.duration,u.success&&r++,u.duration>this.TARGET_RESPONSE_TIME&&l.add(u.operation);const c=a/s.length,E=Math.floor(t.length*.95),f=Math.floor(t.length*.99);return{avgResponseTime:Math.round(c),p95ResponseTime:Math.round(t[E]?.duration||0),p99ResponseTime:Math.round(t[f]?.duration||0),successRate:r/s.length*100,slowOperations:Array.from(l)}}getCacheStats(){const s=this.cacheHits+this.cacheMisses;return{size:this.memoCache.size,hitRate:s>0?this.cacheHits/s*100:0,hits:this.cacheHits,misses:this.cacheMisses}}getMemoized(s){const e=this.memoCache.get(s);if(e){if(Date.now()-e.timestamp>this.MEMO_TTL){this.memoCache.delete(s);return}return e.hits++,e.value}}memoize(s,e){const t=JSON.stringify(e).length;this.memoCache.set(s,{value:e,timestamp:Date.now(),hits:0,size:t}),this.memoCache.size>this.MAX_CACHE_SIZE&&this.cleanupCache()}async withTimeout(s,e){return Promise.race([s,new Promise((t,r)=>setTimeout(()=>r(new Error(`Operation timed out after ${e}ms`)),e))])}recordMetric(s,e,t,r){this.metricsBuffer[this.metricsIndex]={operation:s,duration:e,timestamp:Date.now(),success:t,metadata:r},this.metricsIndex=(this.metricsIndex+1)%this.MAX_METRICS,this.metricsCount<this.MAX_METRICS&&this.metricsCount++,e>this.TARGET_RESPONSE_TIME&&V.warn("Slow operation detected",{operation:s,duration:`${e.toFixed(2)}ms`,target:`${this.TARGET_RESPONSE_TIME}ms`,metadata:r})}};m(w,"instance");let ee=w;const qe=ee.getInstance(),pe={AGENT_CREATION:"https://docs.example.com/agent-creation",STREAMING:"https://docs.example.com/streaming-issues",STORAGE:"https://docs.example.com/storage-troubleshooting",MEMORY:"https://docs.example.com/memory-management",PROVIDER:"https://docs.example.com/provider-setup",GENERAL:"https://docs.example.com/help"},j={get AGENT_CREATION_FAILED(){return n.errors_catalog_agentCreationFailed_template({agentName:"{agentName}",details:"{details}"})},get AGENT_ALREADY_EXISTS(){return n.errors_catalog_agentAlreadyExists_template({agentName:"{agentName}"})},get INVALID_AGENT_CONFIG(){return n.errors_catalog_invalidAgentConfig_template({details:"{details}"})},get INVALID_CONFIG(){return n.errors_catalog_invalidConfig_template({details:"{details}"})},get SESSION_NOT_FOUND(){return n.errors_catalog_sessionNotFound_template({sessionId:"{sessionId}"})},get SESSION_ALREADY_ACTIVE(){return n.errors_catalog_sessionAlreadyActive_template()},get SESSION_INITIALIZATION_FAILED(){return n.errors_catalog_sessionInitializationFailed_template({details:"{details}"})},get STREAM_CONNECTION_FAILED(){return n.errors_catalog_streamConnectionFailed_template({details:"{details}"})},get STREAM_TIMEOUT(){return n.errors_catalog_streamTimeout_template({timeout:"{timeout}"})},get STREAM_INTERRUPTED(){return n.errors_catalog_streamInterrupted_template({attempt:"{attempt}",maxAttempts:"{maxAttempts}"})},get STREAM_RECOVERY_FAILED(){return n.errors_catalog_streamRecoveryFailed_template({attempts:"{attempts}"})},get MESSAGE_SEND_FAILED(){return n.errors_catalog_messageSendFailed_template({details:"{details}"})},get MESSAGE_VALIDATION_FAILED(){return n.errors_catalog_messageValidationFailed_template({details:"{details}"})},get MESSAGE_TOO_LONG(){return n.errors_catalog_messageTooLong_template({maxLength:"{maxLength}",currentLength:"{currentLength}"})},get PROVIDER_NOT_FOUND(){return n.errors_catalog_providerNotFound_template({provider:"{provider}"})},get PROVIDER_CONNECTION_FAILED(){return n.errors_catalog_providerConnectionFailed_template({provider:"{provider}",details:"{details}"})},get PROVIDER_PROCESS_DIED(){return n.errors_catalog_providerProcessDied_template({provider:"{provider}"})},get STORAGE_READ_FAILED(){return n.errors_catalog_storageReadFailed_template({details:"{details}"})},get STORAGE_WRITE_FAILED(){return n.errors_catalog_storageWriteFailed_template({details:"{details}"})},get STORAGE_CORRUPTED(){return n.errors_catalog_storageCorrupted_template({lastBackup:"{lastBackup}"})},get MEMORY_LIMIT_EXCEEDED(){return n.errors_catalog_memoryLimitExceeded_template({currentUsage:"{currentUsage}",limit:"{limit}"})},get RATE_LIMIT_EXCEEDED(){return n.errors_catalog_rateLimitExceeded_template({count:"{count}",window:"{window}"})},get CONCURRENT_LIMIT_EXCEEDED(){return n.errors_catalog_concurrentLimitExceeded_template({current:"{current}",max:"{max}"})}},ze={get AGENT_CREATION_FAILED(){return n.errors_catalog_agentCreationFailed_friendly()},get AGENT_ALREADY_EXISTS(){return n.errors_catalog_agentAlreadyExists_friendly()},get INVALID_AGENT_CONFIG(){return n.errors_catalog_invalidAgentConfig_friendly()},get INVALID_CONFIG(){return n.errors_catalog_invalidConfig_friendly()},get SESSION_NOT_FOUND(){return n.errors_catalog_sessionNotFound_friendly()},get SESSION_ALREADY_ACTIVE(){return n.errors_catalog_sessionAlreadyActive_friendly()},get SESSION_INITIALIZATION_FAILED(){return n.errors_catalog_sessionInitializationFailed_friendly()},get STREAM_CONNECTION_FAILED(){return n.errors_catalog_streamConnectionFailed_friendly()},get STREAM_TIMEOUT(){return n.errors_catalog_streamTimeout_friendly()},get STREAM_INTERRUPTED(){return n.errors_catalog_streamInterrupted_friendly()},get STREAM_RECOVERY_FAILED(){return n.errors_catalog_streamRecoveryFailed_friendly()},get MESSAGE_SEND_FAILED(){return n.errors_catalog_messageSendFailed_friendly()},get MESSAGE_VALIDATION_FAILED(){return n.errors_catalog_messageValidationFailed_friendly()},get MESSAGE_TOO_LONG(){return n.errors_catalog_messageTooLong_friendly()},get PROVIDER_NOT_FOUND(){return n.errors_catalog_providerNotFound_friendly()},get PROVIDER_CONNECTION_FAILED(){return n.errors_catalog_providerConnectionFailed_friendly()},get PROVIDER_PROCESS_DIED(){return n.errors_catalog_providerProcessDied_friendly()},get STORAGE_READ_FAILED(){return n.errors_catalog_storageReadFailed_friendly()},get STORAGE_WRITE_FAILED(){return n.errors_catalog_storageWriteFailed_friendly()},get STORAGE_CORRUPTED(){return n.errors_catalog_storageCorrupted_friendly()},get MEMORY_LIMIT_EXCEEDED(){return n.errors_catalog_memoryLimitExceeded_friendly()},get RATE_LIMIT_EXCEEDED(){return n.errors_catalog_rateLimitExceeded_friendly()},get CONCURRENT_LIMIT_EXCEEDED(){return n.errors_catalog_concurrentLimitExceeded_friendly()}};function He(i){return(i.match(/{(\w+)}/g)||[]).map(e=>e.slice(1,-1))}function Ke(i,s){return He(i).every(t=>t in s)}function Ie(i,s={}){return i.replace(/{(\w+)}/g,(e,t)=>String(s[t]??e))}function J(i){const s=n.errors_cleanMessage_fallback_error();if(!i)return s;let e=i;return e=e.replace(/^.*?failed(?:\s+to\s+.*?)?\s+after\s+\d+\s+attempts:\s*/i,""),e=e.replace(/^Error invoking remote method '[^']+':(\s*Error:)?\s*/i,""),e=e.replace(/^(Error:\s*)+/i,""),e=e.replace(/\n\s*at .+/g,""),e=e.replace(/\s+/g," ").trim(),e||s}function Qe(i,s){return s&&j[i]&&Ke(j[i],s)?Ie(j[i],s):ze[i]||n.errors_userFriendly_fallback_error()}function Ze(i){const e={AGENT_CREATION_FAILED:"AGENT_CREATION",AGENT_ALREADY_EXISTS:"AGENT_CREATION",INVALID_AGENT_CONFIG:"AGENT_CREATION",STREAM_CONNECTION_FAILED:"STREAMING",STREAM_TIMEOUT:"STREAMING",STREAM_INTERRUPTED:"STREAMING",STREAM_RECOVERY_FAILED:"STREAMING",STORAGE_READ_FAILED:"STORAGE",STORAGE_WRITE_FAILED:"STORAGE",STORAGE_CORRUPTED:"STORAGE",MEMORY_LIMIT_EXCEEDED:"MEMORY",RATE_LIMIT_EXCEEDED:"MEMORY",CONCURRENT_LIMIT_EXCEEDED:"MEMORY",PROVIDER_NOT_FOUND:"PROVIDER",PROVIDER_CONNECTION_FAILED:"PROVIDER",PROVIDER_PROCESS_DIED:"PROVIDER"}[i];return e?pe[e]:pe.GENERAL}const je={AGENT_CREATION_FAILED:[{action:"retry",description:"Try creating the agent again",automatic:!1,priority:"high"},{action:"check-config",description:"Verify agent configuration in settings",automatic:!1,priority:"high"},{action:"check-resources",description:"Ensure sufficient memory and disk space",automatic:!1,priority:"medium"}],AGENT_ALREADY_EXISTS:[{action:"rename",description:"Choose a different name for the agent",automatic:!1,priority:"high"},{action:"delete-existing",description:"Delete the existing agent first",automatic:!1,priority:"medium"}],INVALID_AGENT_CONFIG:[{action:"review-config",description:"Review and correct the configuration",automatic:!1,priority:"high"},{action:"use-defaults",description:"Reset to default configuration",automatic:!1,priority:"medium"}],INVALID_CONFIG:[{action:"review-config",description:"Review and correct the configuration",automatic:!1,priority:"high"},{action:"use-defaults",description:"Reset to default configuration",automatic:!1,priority:"medium"}],SESSION_NOT_FOUND:[{action:"start-new",description:"Start a new agent session",automatic:!1,priority:"high"},{action:"check-history",description:"Check session history for recent sessions",automatic:!1,priority:"medium"}],SESSION_ALREADY_ACTIVE:[{action:"wait",description:"Wait for the current session to complete",automatic:!1,priority:"high"},{action:"cancel",description:"Cancel the active session first",automatic:!1,priority:"high"}],SESSION_INITIALIZATION_FAILED:[{action:"retry",description:"Try initializing the session again",automatic:!1,priority:"high"},{action:"check-resources",description:"Ensure sufficient resources are available",automatic:!1,priority:"medium"}],MESSAGE_SEND_FAILED:[{action:"retry",description:"Try sending the message again",automatic:!1,priority:"high"},{action:"check-connection",description:"Check your network connection",automatic:!1,priority:"high"}],MESSAGE_VALIDATION_FAILED:[{action:"review-config",description:"Review and correct the message format",automatic:!1,priority:"high"},{action:"check-config",description:"Check configuration for valid message format",automatic:!1,priority:"medium"}],MESSAGE_TOO_LONG:[{action:"retry",description:"Shorten the message and try again",automatic:!1,priority:"high"},{action:"batch",description:"Split the message into multiple parts",automatic:!1,priority:"medium"}],PROVIDER_NOT_FOUND:[{action:"check-config",description:"Verify provider is properly configured",automatic:!1,priority:"high"},{action:"recreate",description:"Install or reinstall the provider",automatic:!1,priority:"high"}],PROVIDER_CONNECTION_FAILED:[{action:"retry",description:"Try connecting to the provider again",automatic:!1,priority:"high"},{action:"check-config",description:"Verify provider configuration",automatic:!1,priority:"high"}],STORAGE_READ_FAILED:[{action:"retry",description:"Try reading the data again",automatic:!1,priority:"high"},{action:"restore",description:"Restore from a recent backup",automatic:!1,priority:"medium"}],STORAGE_WRITE_FAILED:[{action:"retry",description:"Try saving again",automatic:!1,priority:"high"},{action:"check-resources",description:"Check available disk space",automatic:!1,priority:"high"}],STREAM_CONNECTION_FAILED:[{action:"retry",description:"Try connecting again",automatic:!1,priority:"high"},{action:"check-connection",description:"Check your network connection",automatic:!1,priority:"high"}],STREAM_RECOVERY_FAILED:[{action:"restart",description:"Restart the agent",automatic:!1,priority:"high"},{action:"check-config",description:"Check error logs for more details",automatic:!1,priority:"medium"}],STREAM_INTERRUPTED:[{action:"reconnect",description:"Attempting automatic reconnection",automatic:!0,priority:"high"},{action:"retry",description:"Retry sending the message",automatic:!1,priority:"high"},{action:"check-connection",description:"Check your internet connection",automatic:!1,priority:"medium"}],STREAM_TIMEOUT:[{action:"wait",description:"Wait for agent to complete processing",automatic:!1,priority:"high"},{action:"cancel",description:"Cancel current operation",automatic:!1,priority:"medium"},{action:"increase-timeout",description:"Increase timeout in settings",automatic:!1,priority:"low"}],PROVIDER_PROCESS_DIED:[{action:"restart",description:"Restart agent process",automatic:!0,priority:"high"},{action:"recreate",description:"Create new agent session",automatic:!1,priority:"high"}],STORAGE_CORRUPTED:[{action:"restore",description:"Restore from backup",automatic:!1,priority:"high"},{action:"reset",description:"Reset agent data",automatic:!1,priority:"medium"}],MEMORY_LIMIT_EXCEEDED:[{action:"cleanup",description:"Close unused agents",automatic:!1,priority:"high"},{action:"increase-limit",description:"Increase memory limit in settings",automatic:!1,priority:"medium"}],RATE_LIMIT_EXCEEDED:[{action:"wait",description:"Wait before making more requests",automatic:!1,priority:"high"},{action:"batch",description:"Batch requests together",automatic:!1,priority:"medium"}],CONCURRENT_LIMIT_EXCEEDED:[{action:"close-agents",description:"Close some running agents",automatic:!1,priority:"high"},{action:"queue",description:"Queue operation for later",automatic:!1,priority:"medium"}]};function Je(i){return je[i]||[{action:"retry",description:"Try the operation again",automatic:!1,priority:"high"}]}var D=(i=>(i.AGENT_CREATION_FAILED="AGENT_CREATION_FAILED",i.AGENT_ALREADY_EXISTS="AGENT_ALREADY_EXISTS",i.INVALID_AGENT_CONFIG="INVALID_AGENT_CONFIG",i.INVALID_CONFIG="INVALID_CONFIG",i.SESSION_NOT_FOUND="SESSION_NOT_FOUND",i.SESSION_ALREADY_ACTIVE="SESSION_ALREADY_ACTIVE",i.SESSION_INITIALIZATION_FAILED="SESSION_INITIALIZATION_FAILED",i.STREAM_CONNECTION_FAILED="STREAM_CONNECTION_FAILED",i.STREAM_TIMEOUT="STREAM_TIMEOUT",i.STREAM_INTERRUPTED="STREAM_INTERRUPTED",i.STREAM_RECOVERY_FAILED="STREAM_RECOVERY_FAILED",i.MESSAGE_SEND_FAILED="MESSAGE_SEND_FAILED",i.MESSAGE_VALIDATION_FAILED="MESSAGE_VALIDATION_FAILED",i.MESSAGE_TOO_LONG="MESSAGE_TOO_LONG",i.PROVIDER_NOT_FOUND="PROVIDER_NOT_FOUND",i.PROVIDER_CONNECTION_FAILED="PROVIDER_CONNECTION_FAILED",i.PROVIDER_PROCESS_DIED="PROVIDER_PROCESS_DIED",i.PROVIDER_UNAVAILABLE="PROVIDER_UNAVAILABLE",i.PROVIDER_ERROR="PROVIDER_ERROR",i.STORAGE_READ_FAILED="STORAGE_READ_FAILED",i.STORAGE_WRITE_FAILED="STORAGE_WRITE_FAILED",i.STORAGE_CORRUPTED="STORAGE_CORRUPTED",i.STORAGE_ERROR="STORAGE_ERROR",i.STORAGE_QUOTA_EXCEEDED="STORAGE_QUOTA_EXCEEDED",i.MEMORY_LIMIT_EXCEEDED="MEMORY_LIMIT_EXCEEDED",i.RATE_LIMIT_EXCEEDED="RATE_LIMIT_EXCEEDED",i.CONCURRENT_LIMIT_EXCEEDED="CONCURRENT_LIMIT_EXCEEDED",i.RESOURCE_NOT_FOUND="RESOURCE_NOT_FOUND",i.RESOURCE_EXHAUSTED="RESOURCE_EXHAUSTED",i.NETWORK_ERROR="NETWORK_ERROR",i.PERMISSION_DENIED="PERMISSION_DENIED",i.OPERATION_FAILED="OPERATION_FAILED",i.VALIDATION_ERROR="VALIDATION_ERROR",i.INVALID_RESPONSE="INVALID_RESPONSE",i.STATE_CORRUPTION="STATE_CORRUPTION",i.CONTEXT_OVERFLOW="CONTEXT_OVERFLOW",i))(D||{});class W extends Error{constructor(e,t,r={},a){super(e);m(this,"code");m(this,"context");m(this,"recoverySuggestions");m(this,"userMessage");m(this,"isRecoverable");m(this,"cause");this.name="AgentError",this.code=t,this.context={...r,timestamp:new Date,stackTrace:this.stack},this.userMessage=a?.userMessage||this.getDefaultUserMessage(t),this.recoverySuggestions=a?.recoverySuggestions||this.getDefaultRecoverySuggestions(t),this.isRecoverable=a?.isRecoverable??this.isErrorRecoverable(t),a?.cause&&(this.cause=a.cause)}getDefaultUserMessage(e){return Qe(e,this.context)}getDefaultRecoverySuggestions(e){return Je(e)}isErrorRecoverable(e){return["STREAM_INTERRUPTED","STREAM_TIMEOUT","MESSAGE_SEND_FAILED","PROVIDER_PROCESS_DIED","STORAGE_READ_FAILED","STORAGE_WRITE_FAILED"].includes(e)}getHelpLink(){return Ze(this.code)}formatMessage(e){return Ie(e,this.context)}toJSON(){return{name:this.name,code:this.code,message:this.message,userMessage:this.userMessage,context:this.context,recoverySuggestions:this.recoverySuggestions,isRecoverable:this.isRecoverable,helpLink:this.getHelpLink(),stack:this.stack}}}const et={NON_RETRYABLE_ERRORS:["EACCES","EPERM","ENOSPC","EMFILE","permission","memory","fatal","process died","not available on your current plan","agent binary","rate limit","too many requests","hit your limit","you've hit your limit","quota exceeded"]};function ie(i){const s=i.toLowerCase();for(const e of et.NON_RETRYABLE_ERRORS)if(s.includes(e.toLowerCase()))return!0;return!1}const tt="Agent already has an in-flight prompt. Message was not delivered.",v=Y("ErrorBoundary"),b=class b{constructor(){}static getInstance(){return b.instance||(b.instance=new b),b.instance}async wrap(s,e,t={}){const{retries:r=ge.DEFAULT_ATTEMPTS,retryDelay:a=ge.BASE_DELAY,exponentialBackoff:l=!0,notify:c=!1,notifyOnRetry:E=!1,context:f={},onError:u,onRetry:o,shouldRetry:g=this.defaultShouldRetry}=t;let R=null,d=0;for(d=1;d<=r+1;d++)try{v.debug(`[${e}] Attempt ${d}/${r+1}`);const h=await s();return d>1&&v.info(`[${e}] Succeeded after ${d} attempts`),h}catch(h){if(R=h,v.error(`[${e}] Attempt ${d} failed`,{error:R.message,attempt:d,maxAttempts:r+1,context:f}),u?.(R,d),d<=r&&g(R)){const C=l?a*Math.pow(2,d-1):a;E&&Q.warning(n.agent_errorBoundary_retrying_message({seconds:C/1e3})),o?.(d),v.info(`[${e}] Retrying in ${C}ms`),await this.sleep(C)}else break}const k=`${e} failed after ${d} attempt${d===1?"":"s"}: ${R?.message}`,P=J(R?.message||n.agent_errorBoundary_generic_error()),N=R?.message?.toLowerCase()||"",$=N.includes("no available models")||N.includes("all models exhausted")||N.includes("all models unavailable");throw c&&!$&&Q.error(P),new W(P,D.OPERATION_FAILED,{originalError:R?.message,detailedMessage:k,attempts:d,context:f})}async wrapVoid(s,e,t={}){await this.wrap(s,e,t)}wrapSync(s,e,t={}){try{return s()}catch(r){const a=r;throw v.error(`[${e}] Failed`,{error:a.message,context:t.context}),t.notify&&Q.error(J(a.message)),new W(J(a.message),D.OPERATION_FAILED,t.context)}}defaultShouldRetry(s){const e=s.message.toLowerCase();return ie(s.message)?!1:e.includes("network")||e.includes("timeout")?!0:s instanceof W?[D.NETWORK_ERROR,D.STREAM_TIMEOUT,D.STREAM_CONNECTION_FAILED,D.PROVIDER_CONNECTION_FAILED,D.PROVIDER_UNAVAILABLE].includes(s.code):!(e.includes("invalid")||e.includes("interrupted")||e.includes("cancel")||e.includes("not found")||e.includes("not available")||e.includes("404")||e.includes("no available models")||e.includes("all models exhausted")||e.includes("all models unavailable")||e.includes("413")||e.includes("too long for the agent")||e.includes("request entity too large")||e.includes("payload too large")||e.includes("content too large")||e.includes("body too large")||e.includes("unauthorized")||e.includes("forbidden")||e.includes("401")||e.includes("403"))}sleep(s){return new Promise(e=>setTimeout(e,s))}async withTimeout(s,e,t){return Promise.race([s(),new Promise((r,a)=>setTimeout(()=>a(new W(`${t} timed out after ${e}ms`,D.STREAM_TIMEOUT)),e))])}async batchOperations(s,e,t={}){const{concurrency:r=5,continueOnError:a=!0,operationName:l="batch operation"}=t,c=[],E=[];for(let f=0;f<s.length;f+=r){const u=s.slice(f,f+r);(await Promise.allSettled(u.map(g=>e(g)))).forEach((g,R)=>{if(g.status==="fulfilled")c.push(g.value);else{const d=g.reason;if(E.push({item:u[R],error:d}),v.error(`[${l}] Batch item failed`,{item:u[R],error:d.message}),!a)throw d}})}return E.length>0&&v.warn(`[${l}] Completed with ${E.length} errors`),{results:c,errors:E}}};m(b,"instance");let te=b;const st=te.getInstance(),se=Y("browser/index"),F=new Map,B=new Map;let U;function it(i,s,e){for(const t of s)try{t(e)}catch(r){se.error("Error in agent subscriber callback",{agentId:i,error:r})}}function rt(){if(U)return;let i=!1;U=p.createSelector(e=>e.agentSessions)().subscribe(()=>{if(!i){i=!0;return}if(F.size===0)return;const e=p.state;for(const[t,r]of F){const a=Ae.select(e,t);B.get(t)!==a&&(B.set(t,a),it(t,r,a))}})}function at(){F.size>0||!U||(U(),U=void 0,B.clear())}function Ct(i,s,e){let t=F.get(i);const r=!t;t||(t=new Set,F.set(i,t)),t.add(s),rt();const a=p.state,l=Ae.select(a,i);return r&&B.set(i,l),l?se.debug("[subscribeToAgent] Initial callback data",{agentId:i,workspaceId:e??"current",hasSession:!0}):se.debug("[subscribeToAgent] No session found",{agentId:i,workspaceId:e??"current"}),s(l),()=>{const c=F.get(i);c&&(c.delete(s),c.size===0&&(F.delete(i),B.delete(i))),at()}}const y=Y("ErrorRecovery"),Se={network:{maxRetries:3,initialBackoffMs:1e3,maxBackoffMs:1e4,backoffMultiplier:2,shouldRetry:i=>{const s=i.message.toLowerCase();return s.includes("network")||s.includes("fetch")||s.includes("connection")||s.includes("timeout")}},streaming:{maxRetries:5,initialBackoffMs:500,maxBackoffMs:5e3,backoffMultiplier:1.5,shouldRetry:(i,s)=>{if(s>=5)return!1;const e=i.message.toLowerCase();return e.includes("no available models")||e.includes("all models exhausted")||e.includes("all models unavailable")||ie(i.message)?!1:e.includes("stream")||e.includes("chunk")||e.includes("incomplete")}},persistence:{maxRetries:2,initialBackoffMs:100,maxBackoffMs:1e3,backoffMultiplier:2,shouldRetry:i=>{const s=i.message.toLowerCase();return s.includes("save")||s.includes("write")||s.includes("persist")}},rateLimit:{maxRetries:3,initialBackoffMs:5e3,maxBackoffMs:3e4,backoffMultiplier:2,shouldRetry:i=>{const s=i.message.toLowerCase();return s.includes("rate")||s.includes("limit")||s.includes("429")}}};class nt{constructor(){m(this,"listeners",new Map)}on(s,e){let t=this.listeners.get(s);t||(t=new Set,this.listeners.set(s,t)),t.add(e)}off(s,e){this.listeners.get(s)?.delete(e)}emit(s,...e){this.listeners.get(s)?.forEach(t=>{try{t(...e)}catch(r){y.error(`Error in event listener for ${s}:`,r)}})}removeAllListeners(){this.listeners.clear()}}class ot extends nt{constructor(){super(...arguments);m(this,"activeRecoveries",new Map);m(this,"recoveryStats",new Map)}async executeWithRecovery(e,t=Se.network,r){const a=Date.now(),l=new AbortController;r&&(this.cancelRecovery(r),this.activeRecoveries.set(r,l));let c,E=t.initialBackoffMs,f=0;for(let u=1;u<=t.maxRetries;u++){if(f=u,l.signal.aborted){y.info(`Recovery cancelled for operation ${r}`);break}try{y.debug(`Attempting operation (attempt ${u}/${t.maxRetries})`,{operationId:r});const o=await e();return this.updateStats(r,!0),this.emit("recovery:success",{operationId:r,attempt:u,duration:Date.now()-a}),r&&this.activeRecoveries.delete(r),{success:!0,data:o,attempts:u,totalTime:Date.now()-a}}catch(o){c=o,y.warn(`Operation failed (attempt ${u}/${t.maxRetries})`,{operationId:r,error:c.message});const g=c.message.toLowerCase();if(g.includes("interrupted")||g.includes("cancelled")||g.includes("canceled")){y.debug("User-initiated interruption/cancellation, not retrying",{operationId:r,error:c.message});break}if(g.includes("no available models")||g.includes("all models exhausted")||g.includes("all models unavailable")){y.debug("All models exhausted, not retrying",{operationId:r,error:c.message});break}if(ie(c.message)){y.debug("Fatal error detected, not retrying",{operationId:r,error:c.message});break}if(!t.shouldRetry(c,u)){y.debug("Error not retryable, stopping recovery",{operationId:r,error:c.message});break}if(u<t.maxRetries){const R=Math.random()*.2*E,d=Math.min(E+R,t.maxBackoffMs);t.onRetry?.(u,d),this.emit("recovery:retry",{operationId:r,attempt:u,delay:d,error:c.message}),await this.delay(d,l.signal),E=Math.min(E*t.backoffMultiplier,t.maxBackoffMs)}}}return this.updateStats(r,!1),t.onFailure?.(c,f),this.emit("recovery:failure",{operationId:r,attempts:f,duration:Date.now()-a,error:c?.message}),r&&this.activeRecoveries.delete(r),{success:!1,error:c,attempts:f,totalTime:Date.now()-a}}cancelRecovery(e){const t=this.activeRecoveries.get(e);t&&(t.abort(),this.activeRecoveries.delete(e),y.info(`Cancelled recovery for operation ${e}`))}cancelAllRecoveries(){for(const[e,t]of this.activeRecoveries)t.abort(),y.info(`Cancelled recovery for operation ${e}`);this.activeRecoveries.clear()}getStats(e){if(e)return this.recoveryStats.get(e)||{successes:0,failures:0};const t={};for(const[r,a]of this.recoveryStats)t[r]=a;return t}clearStats(e){e?this.recoveryStats.delete(e):this.recoveryStats.clear()}isRetryable(e,t){const r=e.message.toLowerCase();if(t)switch(t){case"NETWORK":return r.includes("network")||r.includes("fetch");case"TIMEOUT":return r.includes("timeout")||r.includes("timed out");case"RATE_LIMIT":return r.includes("rate")||r.includes("limit")||r.includes("429");case"TEMPORARY":return r.includes("temporary")||r.includes("transient");case"CONFLICT":return r.includes("conflict")||r.includes("concurrent");default:return!1}return this.isRetryable(e,"NETWORK")||this.isRetryable(e,"TIMEOUT")||this.isRetryable(e,"RATE_LIMIT")||this.isRetryable(e,"TEMPORARY")||this.isRetryable(e,"CONFLICT")}delay(e,t){return new Promise((r,a)=>{const l=setTimeout(r,e);if(t){const c=()=>{clearTimeout(l),a(new Error("Delay aborted"))};t.addEventListener("abort",c);const E=r;r=()=>{t.removeEventListener("abort",c),E()}}})}updateStats(e,t){if(!e)return;const r=this.recoveryStats.get(e)||{successes:0,failures:0};t?r.successes++:r.failures++,this.recoveryStats.set(e,r)}dispose(){this.cancelAllRecoveries(),this.recoveryStats.clear(),this.removeAllListeners()}}const ct=new ot,O=new We({category:"WorkspaceMetrics"}),lt=100;class ut{constructor(){m(this,"metrics",new Map);m(this,"operations",new Map)}startWorkspaceCreation(s){const e=Date.now();for(this.metrics.delete(s),this.metrics.set(s,{workspaceId:s,creationStarted:e});this.metrics.size>lt;){const t=this.metrics.keys().next().value;if(t===void 0)break;this.metrics.delete(t)}O.info("Started tracking workspace creation",{workspaceId:s})}recordMilestone(s,e){const t=this.metrics.get(s);if(!t){O.warn("No metrics found for workspace",{workspaceId:s,milestone:e});return}const r=Date.now();switch(e){case"optimisticNavigation":t.optimisticNavigation=r;break;case"realWorkspaceCreated":t.realWorkspaceCreated=r;break;case"agentCreated":t.agentCreated=r;break;case"agentReady":t.agentReady=r;break;case"firstMessageSent":t.firstMessageSent=r;break;case"firstResponseReceived":t.firstResponseReceived=r;break;case"firstChunkReceived":t.firstChunkReceived=r;break;case"totalDuration":t.totalDuration=r;break;case"workspaceId":case"creationStarted":O.warn("Cannot update milestone",{milestone:e});return}const a=r-t.creationStarted;O.info(`Milestone: ${e}`,{workspaceId:s,elapsed:`${a}ms`,timestamp:r}),e==="firstResponseReceived"&&(t.totalDuration=r-t.creationStarted,this.logSummary(s))}startOperation(s,e){this.operations.set(s,{startTime:Date.now(),metadata:e})}endOperation(s,e){const t=this.operations.get(s);if(!t)return O.warn("Operation not found",{operationId:s}),null;const r=Date.now();return t.endTime=r,t.duration=r-t.startTime,e&&(t.metadata={...t.metadata,...e}),O.info("Operation completed",{operationId:s,duration:`${t.duration}ms`,metadata:t.metadata}),this.operations.delete(s),t.duration}getMetrics(s){return this.metrics.get(s)}logSummary(s){const e=this.metrics.get(s);if(!e)return;const t={workspaceId:s,totalDuration:`${e.totalDuration}ms`,stages:{optimisticNavigation:e.optimisticNavigation?`${e.optimisticNavigation-e.creationStarted}ms`:"N/A",realWorkspaceCreation:e.realWorkspaceCreated?`${e.realWorkspaceCreated-e.creationStarted}ms`:"N/A",agentCreation:e.agentCreated?`${e.agentCreated-e.creationStarted}ms`:"N/A",agentReady:e.agentReady?`${e.agentReady-e.creationStarted}ms`:"N/A",firstMessage:e.firstMessageSent?`${e.firstMessageSent-e.creationStarted}ms`:"N/A",firstResponse:e.firstResponseReceived?`${e.firstResponseReceived-e.creationStarted}ms`:"N/A"}};O.info("=== Workspace Creation Metrics Summary ===",t),O.info("Workspace Creation Metrics:",t)}clearMetrics(s){this.metrics.delete(s)}incrementAgentCreated(s){const e=this.metrics.get(s);e&&(e.agentCreated=Date.now(),O.info("Agent created",{workspaceId:s}))}incrementMessageSent(s){const e=this.metrics.get(s);e&&!e.firstMessageSent&&(e.firstMessageSent=Date.now(),O.info("First message sent",{workspaceId:s}))}}const dt=new ut,M=Y("AgentSend");function A(i){p.dispatch(i)}function Te(i){return typeof i=="object"&&i!==null&&!Array.isArray(i)}function mt(i){const s=Te(i)&&i.success===!0&&"data"in i?i.data:i;return!Te(s)||s.success!==!1?!1:typeof s.error=="string"&&s.error.includes(tt)}async function Lt(i,s,e,t={}){const r=he.select(p.state,e.id);if(!r)return;const a=Ne(i,e.id),l=t.submission,c=!!l&&Le.select(p.state,l.scope)?.supported===!0,E=(o,g,R=!1)=>{l&&A(Be(l.scope,l.id,o,Date.now(),g,R))};let f=!1;const u=()=>(!l||f||ve.select(p.state,l))&&r===he.select(p.state,e.id)&&a.isCurrent(p.state.agentSessions?.byAgentId[i]?.workspaceId);return qe.track(`sendMessage:${a.key}:${i}:${l?.id??"legacy"}`,async()=>{if(!u())return;M.debug(`Sending message to agent ${i}`,{contentLength:s.length,hasContextReferences:!!t.contextReferences?.length,model:t.model});let o=await p.dispatch(we(e.id,i));if(u()){if(!o)throw new Error(n.agent_streamLifecycle_sessionNotFound_error({agentId:i}));o={...o,isStreaming:o.isStreaming??!1};{if(o&&(o.status==="pending"||!o.id)&&!o.backendSessionId&&o.activationState!==H.ACTIVE&&o.activationState!==H.ACTIVATING){const h=e.id.startsWith("optimistic-"),C=e.worktreePath||e.repositoryPath||e.path;if(!h&&C){M.info("Activating pending session in sendMessage",{agentId:i,status:o.status,activationState:o.activationState,hasBackendSessionId:!!o.backendSessionId});const x=await p.dispatch(be(e.id,i));if(!u())return;x&&(o=x)}else throw M.warn("Cannot activate agent - workspace not ready",{agentId:i,workspaceId:e.id,isOptimistic:h,hasWorktreePath:!!e.worktreePath,hasRepositoryPath:!!e.repositoryPath,hasPath:!!e.path}),new Error(n.agent_streamLifecycle_spaceNotReady_error())}else o&&o.status==="pending"&&o.backendSessionId&&(M.info("Fixing status for already-activated session",{agentId:i,backendSessionId:o.backendSessionId,activationState:o.activationState}),o={...o,status:Fe.Active,activationState:H.ACTIVE},A(de({...o,workspaceId:e.id})));if(!o)throw new Error(`Failed to get or create session for agent ${i}`);A(de({...o,workspaceId:e.id}));const R=[{type:"text",text:s}];if(t.imageBlocks)for(const h of t.imageBlocks)R.push({type:"image",...h.data!==void 0?{data:h.data}:{},...h.mimeType!==void 0?{mimeType:h.mimeType}:{},...h.attachmentId!==void 0?{attachmentId:h.attachmentId}:{}});if(t.fileBlocks)for(const h of t.fileBlocks)R.push({type:"file",attachmentId:h.attachmentId,fileName:h.fileName,...h.mimeType!==void 0?{mimeType:h.mimeType}:{},...h.size!==void 0?{size:h.size}:{}});const d=t.userAppMessageId??oe(),k=t.messageMetadata?.[Re],P={...t.contextReferences?.length?{contextReferences:t.contextReferences}:{},...k!==void 0?{[Re]:k}:{}},N={id:me(le()),appMessageId:d,role:"user",contentBlocks:R,timestamp:new Date().toISOString(),metadata:{...P,...t.messageMetadata??{}}};c||(l&&(E("rejected"),f=!0),A(ke(o.id,N))),A(z(o.id,!0));let $=!1;try{c||await p.dispatch(Ge(e.id,i,!0,{allowTruncation:t.resetHistory}));const h=me(`msg_${le()}`),C=oe(),x=async()=>st.wrap(async()=>{if(!u())return;M.info("Agent Service: Sending message to backend with image and file blocks",{agentId:i,sessionId:o.id,hasImageBlocks:!!t.imageBlocks,imageBlocksCount:t.imageBlocks?.length||0,imageBlockDetails:t.imageBlocks?.map(_=>({type:_.type,mimeType:_.mimeType,dataLength:_.data?.length||0}))||[],hasFileBlocks:!!t.fileBlocks,fileBlocksCount:t.fileBlocks?.length||0,fileBlockDetails:t.fileBlocks?.map(_=>({type:_.type,fileName:_.fileName,mimeType:_.mimeType,attachmentId:_.attachmentId,size:_.size}))||[]});const Oe=t.model??t.modelId??o.model??void 0;A(Pe(i));const ye=ce(i,e.id),ae=p.state.chatState?.byAgentId[i]?.attemptGeneration??0,T=await $e("agent.sendMessage",{agentId:i,...c&&l?{messageId:l.id}:{},workspaceId:e.id,content:s,model:Oe,contextReferences:t.contextReferences,imageBlocks:t.imageBlocks,fileBlocks:t.fileBlocks,noteIds:t.noteIds,stdinContext:t.stdinContext,assistantMessageId:h,userAppMessageId:d,assistantAppMessageId:C,priority:t.priority,...t.messageMetadata?{messageMetadata:t.messageMetadata}:{}}).catch(_=>{if(u())throw _});if(u()){if(mt(T)){M.info("Backend dropped duplicate in-flight prompt",{agentId:i,sessionId:o.id}),E("rejected");return}if(T&&typeof T=="object"&&"success"in T){if(!T.success){const _=T.error,I=typeof _=="string"?_:_?.message;throw $=!0,new Error(I||n.agent_streamLifecycle_sendToBackendFailed_error())}if("queued"in T&&T.queued===!0){if(M.info("sendMessage auto-queued by daemon (mid-turn or turn-startup race)",{agentId:i,sessionId:o.id,queuedMessageId:T.queuedMessage?.id}),(!c||!l||!ue.select(p.state,l))&&A(z(o.id,!1)),c||A(xe(o.id,N.id)),c){const I=T.queuedMessage,G=T.turnId,L=typeof G=="string"?G:I?.turnId;if(I&&typeof L=="string"){const S=Ee(s,t),X=K.select(p.state,i,e.id).find(ne=>ne.id===I.id||ne.turnId===L);A(fe(i,I.id,S,L,_e(X??I,S),!X&&!!l&&ue.select(p.state,l),ae))}E("accepted",I,!0),q(i,e.id);return}const _=T.queuedMessage;if(_){const I=T.turnId,G=typeof I=="string"?I:_.turnId;let L=_;if(u()&&ce(i,e.id)===ye){const S=K.select(p.state,i,e.id),X=Ye(S,_);A(Ve(i,X,e.id))}else u()&&(M.debug("queued-response queue seed superseded by an authoritative snapshot; reconciling via hydrate",{agentId:i,queuedMessageId:_.id}),await q(i,e.id).catch(()=>{}),L=K.select(p.state,i,e.id).find(S=>S.id===_.id||S.turnId===G));if(u()&&typeof G=="string"){const S=Ee(s,t);A(fe(i,_.id,S,G,_e(L??_,S),!L,ae))}else u()&&M.warn("auto-queued sendMessage response carried no turnId; retry record not parked",{agentId:i,queuedMessageId:_.id})}return}}c&&(E("accepted"),q(i,e.id),Ce(i,e.id)),dt.incrementMessageSent(e.id)}},"send message",{retries:c?0:2,notify:!1,context:{agentId:i,workspace:e.id}}),re=c?await x().then(()=>({success:!0,error:void 0})):await ct.executeWithRecovery(x,Se.streaming,`send-message-${i}`);if(!re.success)throw re.error||new Error(n.agent_streamLifecycle_sendFailed_error())}catch(h){if(!u())return;throw A(z(o.id,!1)),!c&&t.messageMetadata&&A(Ue(o.id,N.id,{metadata:P})),c&&E($?"rejected":"uncertain"),h}}}},{memoize:!1,coalesce:!0,priority:"high"})}export{Ct as a,J as c,Ye as r,Lt as s};
@@ -1 +1 @@
1
- import{aB as v,b as y}from"./DZTSivxP.js";var w=5,O=1e-5,X=2,Y=.6,R=1e-6;function N(t){const e=[];for(let s=0;s<t.length-1;s++)e.push({a:t[s],b:t[s+1]});return e}y(N,"buildSegmentList");function T(t,e,s,a){const r=e.x-t.x,o=e.y-t.y,i=a.x-s.x,d=a.y-s.y,u=r*d-o*i;if(u===0)return null;const n=s.x-t.x,c=s.y-t.y,p=(n*d-c*i)/u,f=(n*o-c*r)/u;return p<=R||p>=1-R||f<=R||f>=1-R?null:{point:{x:t.x+p*r,y:t.y+p*o},tA:p,tB:f}}y(T,"segmentIntersection");function P(t){return Math.abs(t.b.x-t.a.x)>=Math.abs(t.b.y-t.a.y)}y(P,"isHorizontalSeg");function B(t,e,s){if(t.curve!=="rounded")return!1;const a=t.points,r=a[e],o=a[e+1];if(!r||!o)return!1;const i=Math.hypot(o.x-r.x,o.y-r.y),d=s*i,u=e>0?L(a[e-1],r,o,w):null;if(u&&d<u.cutLen)return!0;const n=e+2<a.length?L(r,o,a[e+2],w):null;return n!==null&&i-d<n.cutLen}y(B,"crossingSitsInRoundedCorner");function C(t){const e=[];for(let s=0;s<t.length;s++){const a=t[s],r=N(a.points);for(let o=s+1;o<t.length;o++){const i=t[o],d=N(i.points);for(const[u,n]of r.entries())for(const[c,p]of d.entries()){const f=T(n.a,n.b,p.a,p.b);if(!f||B(a,u,f.tA)||B(i,c,f.tB))continue;const g=P(n),S=P(p);(g!==S?g:!1)?e.push({jumpEdgeId:a.id,otherEdgeId:i.id,segIndex:u,t:f.tA,point:f.point}):e.push({jumpEdgeId:i.id,otherEdgeId:a.id,segIndex:c,t:f.tB,point:f.point})}}}return e}y(C,"findEdgeIntersections");function M(t){const e=Math.round(t*1e3)/1e3;return Number.isInteger(e)?`${e}`:`${e}`}y(M,"fmt");function A(t){return`${M(t.x)},${M(t.y)}`}y(A,"pointToString");function D(t){const e=t.b.x-t.a.x,s=t.b.y-t.a.y;return Math.abs(e)>=Math.abs(s)?e>=0?1:0:s>=0?1:0}y(D,"getArcSweepFlag");function _(t,e){if(t.length<2)return t.map(o=>({...o}));const s=t.map(o=>({...o})),a=e.arrowTypeStart&&v[e.arrowTypeStart];if(a){const o=t[0],i=t[1],d=Math.atan2(i.y-o.y,i.x-o.x);s[0].x=o.x+a*Math.cos(d),s[0].y=o.y+a*Math.sin(d)}const r=e.arrowTypeEnd&&v[e.arrowTypeEnd];if(r){const o=t.length,i=t[o-2],d=t[o-1],u=Math.atan2(d.y-i.y,d.x-i.x);s[o-1].x=d.x-r*Math.cos(u),s[o-1].y=d.y-r*Math.sin(u)}return s}y(_,"applyMarkerOffsets");function k(t,e,s,a,r){const o=t.point.x,i=t.point.y,d={x:o-e*t.r,y:i-s*t.r},u={x:o+e*t.r,y:i+s*t.r},n=[`L${A(d)}`];return r==="arc"?n.push(`A${M(t.r)},${M(t.r)} 0 0 ${a} ${A(u)}`):n.push(`M${A(u)}`),n}y(k,"emitJump");function L(t,e,s,a){const r=e.x-t.x,o=e.y-t.y,i=s.x-e.x,d=s.y-e.y,u=Math.hypot(r,o),n=Math.hypot(i,d);if(u<O||n<O)return null;const c=r/u,p=o/u,f=i/n,g=d/n,S=c*f+p*g,b=Math.max(-1,Math.min(1,S)),m=Math.acos(b);if(m<O||Math.abs(Math.PI-m)<O)return null;const h=Math.min(a/Math.sin(m/2),u/2,n/2);return{startX:e.x-c*h,startY:e.y-p*h,endX:e.x+f*h,endY:e.y+g*h,ctrlX:e.x,ctrlY:e.y,cutLen:h}}y(L,"computeRoundedCorner");function H(t,e,s){const a=t.points;if(a.length<2)return"";const r=_(a,t),o=t.curve==="rounded",i=N(r),d=new Map;for(const n of e){const c=i[n.segIndex];if(!c)continue;const p=Math.hypot(c.b.x-c.a.x,c.b.y-c.a.y),f=d.get(n.segIndex)??[];f.push({t:n.t,point:n.point,d:n.t*p,r:s.jumpRadius}),d.set(n.segIndex,f)}const u=[`M${A(r[0])}`];for(let n=0;n<i.length;n++){const c=i[n],p=Math.hypot(c.b.x-c.a.x,c.b.y-c.a.y),f=p===0?0:(c.b.x-c.a.x)/p,g=p===0?0:(c.b.y-c.a.y)/p,S=D(c);let b=0;if(o&&n>0){const l=L(r[n-1],r[n],r[n+1]??r[n],w);l&&(b=l.cutLen)}let m=p,h=null;o&&n<i.length-1&&(h=L(r[n],r[n+1],r[n+2]??r[n+1],w),h&&(m=p-h.cutLen));const $=s.jumpRadius*Y,x=[...d.get(n)??[]].sort((l,E)=>l.t-E.t).filter(l=>{const E=Math.min(l.d-b,m-l.d)-X;return l.r=Math.min(l.r,E),l.r>=$});for(let l=0;l<x.length-1;l++){const E=x[l+1].d-x[l].d;if(x[l].r+x[l+1].r>E){const I=E/2;x[l].r=Math.min(x[l].r,I),x[l+1].r=Math.min(x[l+1].r,I)}}for(const l of x)l.r<$||u.push(...k(l,f,g,S,s.jumpStyle));o&&h?(u.push(`L${M(h.startX)},${M(h.startY)}`),u.push(`Q${M(h.ctrlX)},${M(h.ctrlY)} ${M(h.endX)},${M(h.endY)}`)):u.push(`L${A(c.b)}`)}return u.join(" ")}y(H,"rewriteEdgePath");function J(t){return/^[\d\s+,.LMelm-]*$/.test(t)}y(J,"isStraightPath");function U(t){return t?t==="linear"||t==="rounded"||t==="step"||t==="stepBefore"||t==="stepAfter":!0}y(U,"curveSupportsLineHops");function j(t){if(!t)return null;try{const e=typeof atob=="function"?atob(t):Buffer.from(t,"base64").toString(),s=JSON.parse(e);if(!Array.isArray(s))return null;const a=[];for(const r of s)r&&typeof r.x=="number"&&typeof r.y=="number"&&a.push({x:r.x,y:r.y});return a.length>=2?a:null}catch{return null}}y(j,"decodeDataPoints");function F(t,e,s){if(!s.enabled)return;const a=t.node();if(!a)return;const r=new Map;for(const n of e)r.set(n.id,n);const o=new Map;for(const n of a.querySelectorAll("path[data-id]")){const c=n.getAttribute("data-id");c!==null&&!o.has(c)&&o.set(c,n)}const i=[];for(const n of e){const c=o.get(n.id);if(!c)continue;const f=j(c.getAttribute("data-points"))??n.points;i.push({...n,points:f})}const d=C(i);if(d.length===0)return;const u=new Map;for(const n of d){const c=u.get(n.jumpEdgeId)??[];c.push(n),u.set(n.jumpEdgeId,c)}for(const n of i){const c=u.get(n.id);if(!c||c.length===0)continue;const f=r.get(n.id)?.curve;if(f!==void 0&&!U(f))continue;const g=o.get(n.id);if(!g)continue;if(f===void 0){const x=g.getAttribute("d")??"";if(!J(x))continue}const S=g.getAttribute("style")??"",b=/stroke-dasharray\s*:\s*0\s+([\d.]+)\s+[\d.]+\s+([\d.]+)/.exec(S),m=b?Number.parseFloat(b[1]):null,h=b?Number.parseFloat(b[2]):null,$=H(n,c,s);if(g.setAttribute("d",$),m!==null&&h!==null&&typeof g.getTotalLength=="function"){const x=g.getTotalLength(),l=Math.max(0,x-m-h),E=`0 ${m} ${l} ${h}`,I=S.replace(/stroke-dasharray\s*:[^;]*;?/g,`stroke-dasharray: ${E};`).replace(/;\s*;+/g,";");g.setAttribute("style",I)}}}y(F,"applyLineJumpsToSvg");export{F as a};
1
+ import{aB as v,b as y}from"./C9HiWs7H.js";var w=5,O=1e-5,X=2,Y=.6,R=1e-6;function N(t){const e=[];for(let s=0;s<t.length-1;s++)e.push({a:t[s],b:t[s+1]});return e}y(N,"buildSegmentList");function T(t,e,s,a){const r=e.x-t.x,o=e.y-t.y,i=a.x-s.x,d=a.y-s.y,u=r*d-o*i;if(u===0)return null;const n=s.x-t.x,c=s.y-t.y,p=(n*d-c*i)/u,f=(n*o-c*r)/u;return p<=R||p>=1-R||f<=R||f>=1-R?null:{point:{x:t.x+p*r,y:t.y+p*o},tA:p,tB:f}}y(T,"segmentIntersection");function P(t){return Math.abs(t.b.x-t.a.x)>=Math.abs(t.b.y-t.a.y)}y(P,"isHorizontalSeg");function B(t,e,s){if(t.curve!=="rounded")return!1;const a=t.points,r=a[e],o=a[e+1];if(!r||!o)return!1;const i=Math.hypot(o.x-r.x,o.y-r.y),d=s*i,u=e>0?L(a[e-1],r,o,w):null;if(u&&d<u.cutLen)return!0;const n=e+2<a.length?L(r,o,a[e+2],w):null;return n!==null&&i-d<n.cutLen}y(B,"crossingSitsInRoundedCorner");function C(t){const e=[];for(let s=0;s<t.length;s++){const a=t[s],r=N(a.points);for(let o=s+1;o<t.length;o++){const i=t[o],d=N(i.points);for(const[u,n]of r.entries())for(const[c,p]of d.entries()){const f=T(n.a,n.b,p.a,p.b);if(!f||B(a,u,f.tA)||B(i,c,f.tB))continue;const g=P(n),S=P(p);(g!==S?g:!1)?e.push({jumpEdgeId:a.id,otherEdgeId:i.id,segIndex:u,t:f.tA,point:f.point}):e.push({jumpEdgeId:i.id,otherEdgeId:a.id,segIndex:c,t:f.tB,point:f.point})}}}return e}y(C,"findEdgeIntersections");function M(t){const e=Math.round(t*1e3)/1e3;return Number.isInteger(e)?`${e}`:`${e}`}y(M,"fmt");function A(t){return`${M(t.x)},${M(t.y)}`}y(A,"pointToString");function D(t){const e=t.b.x-t.a.x,s=t.b.y-t.a.y;return Math.abs(e)>=Math.abs(s)?e>=0?1:0:s>=0?1:0}y(D,"getArcSweepFlag");function _(t,e){if(t.length<2)return t.map(o=>({...o}));const s=t.map(o=>({...o})),a=e.arrowTypeStart&&v[e.arrowTypeStart];if(a){const o=t[0],i=t[1],d=Math.atan2(i.y-o.y,i.x-o.x);s[0].x=o.x+a*Math.cos(d),s[0].y=o.y+a*Math.sin(d)}const r=e.arrowTypeEnd&&v[e.arrowTypeEnd];if(r){const o=t.length,i=t[o-2],d=t[o-1],u=Math.atan2(d.y-i.y,d.x-i.x);s[o-1].x=d.x-r*Math.cos(u),s[o-1].y=d.y-r*Math.sin(u)}return s}y(_,"applyMarkerOffsets");function k(t,e,s,a,r){const o=t.point.x,i=t.point.y,d={x:o-e*t.r,y:i-s*t.r},u={x:o+e*t.r,y:i+s*t.r},n=[`L${A(d)}`];return r==="arc"?n.push(`A${M(t.r)},${M(t.r)} 0 0 ${a} ${A(u)}`):n.push(`M${A(u)}`),n}y(k,"emitJump");function L(t,e,s,a){const r=e.x-t.x,o=e.y-t.y,i=s.x-e.x,d=s.y-e.y,u=Math.hypot(r,o),n=Math.hypot(i,d);if(u<O||n<O)return null;const c=r/u,p=o/u,f=i/n,g=d/n,S=c*f+p*g,b=Math.max(-1,Math.min(1,S)),m=Math.acos(b);if(m<O||Math.abs(Math.PI-m)<O)return null;const h=Math.min(a/Math.sin(m/2),u/2,n/2);return{startX:e.x-c*h,startY:e.y-p*h,endX:e.x+f*h,endY:e.y+g*h,ctrlX:e.x,ctrlY:e.y,cutLen:h}}y(L,"computeRoundedCorner");function H(t,e,s){const a=t.points;if(a.length<2)return"";const r=_(a,t),o=t.curve==="rounded",i=N(r),d=new Map;for(const n of e){const c=i[n.segIndex];if(!c)continue;const p=Math.hypot(c.b.x-c.a.x,c.b.y-c.a.y),f=d.get(n.segIndex)??[];f.push({t:n.t,point:n.point,d:n.t*p,r:s.jumpRadius}),d.set(n.segIndex,f)}const u=[`M${A(r[0])}`];for(let n=0;n<i.length;n++){const c=i[n],p=Math.hypot(c.b.x-c.a.x,c.b.y-c.a.y),f=p===0?0:(c.b.x-c.a.x)/p,g=p===0?0:(c.b.y-c.a.y)/p,S=D(c);let b=0;if(o&&n>0){const l=L(r[n-1],r[n],r[n+1]??r[n],w);l&&(b=l.cutLen)}let m=p,h=null;o&&n<i.length-1&&(h=L(r[n],r[n+1],r[n+2]??r[n+1],w),h&&(m=p-h.cutLen));const $=s.jumpRadius*Y,x=[...d.get(n)??[]].sort((l,E)=>l.t-E.t).filter(l=>{const E=Math.min(l.d-b,m-l.d)-X;return l.r=Math.min(l.r,E),l.r>=$});for(let l=0;l<x.length-1;l++){const E=x[l+1].d-x[l].d;if(x[l].r+x[l+1].r>E){const I=E/2;x[l].r=Math.min(x[l].r,I),x[l+1].r=Math.min(x[l+1].r,I)}}for(const l of x)l.r<$||u.push(...k(l,f,g,S,s.jumpStyle));o&&h?(u.push(`L${M(h.startX)},${M(h.startY)}`),u.push(`Q${M(h.ctrlX)},${M(h.ctrlY)} ${M(h.endX)},${M(h.endY)}`)):u.push(`L${A(c.b)}`)}return u.join(" ")}y(H,"rewriteEdgePath");function J(t){return/^[\d\s+,.LMelm-]*$/.test(t)}y(J,"isStraightPath");function U(t){return t?t==="linear"||t==="rounded"||t==="step"||t==="stepBefore"||t==="stepAfter":!0}y(U,"curveSupportsLineHops");function j(t){if(!t)return null;try{const e=typeof atob=="function"?atob(t):Buffer.from(t,"base64").toString(),s=JSON.parse(e);if(!Array.isArray(s))return null;const a=[];for(const r of s)r&&typeof r.x=="number"&&typeof r.y=="number"&&a.push({x:r.x,y:r.y});return a.length>=2?a:null}catch{return null}}y(j,"decodeDataPoints");function F(t,e,s){if(!s.enabled)return;const a=t.node();if(!a)return;const r=new Map;for(const n of e)r.set(n.id,n);const o=new Map;for(const n of a.querySelectorAll("path[data-id]")){const c=n.getAttribute("data-id");c!==null&&!o.has(c)&&o.set(c,n)}const i=[];for(const n of e){const c=o.get(n.id);if(!c)continue;const f=j(c.getAttribute("data-points"))??n.points;i.push({...n,points:f})}const d=C(i);if(d.length===0)return;const u=new Map;for(const n of d){const c=u.get(n.jumpEdgeId)??[];c.push(n),u.set(n.jumpEdgeId,c)}for(const n of i){const c=u.get(n.id);if(!c||c.length===0)continue;const f=r.get(n.id)?.curve;if(f!==void 0&&!U(f))continue;const g=o.get(n.id);if(!g)continue;if(f===void 0){const x=g.getAttribute("d")??"";if(!J(x))continue}const S=g.getAttribute("style")??"",b=/stroke-dasharray\s*:\s*0\s+([\d.]+)\s+[\d.]+\s+([\d.]+)/.exec(S),m=b?Number.parseFloat(b[1]):null,h=b?Number.parseFloat(b[2]):null,$=H(n,c,s);if(g.setAttribute("d",$),m!==null&&h!==null&&typeof g.getTotalLength=="function"){const x=g.getTotalLength(),l=Math.max(0,x-m-h),E=`0 ${m} ${l} ${h}`,I=S.replace(/stroke-dasharray\s*:[^;]*;?/g,`stroke-dasharray: ${E};`).replace(/;\s*;+/g,";");g.setAttribute("style",I)}}}y(F,"applyLineJumpsToSvg");export{F as a};