@intent-hq/web 2.372.2 → 2.372.3

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 (146) hide show
  1. package/package.json +1 -1
  2. package/web/app/immutable/chunks/{BZQZwdGm.js → -il6if-X.js} +1 -1
  3. package/web/app/immutable/chunks/{DSIsc1Ss.js → 0PFbquWg.js} +1 -1
  4. package/web/app/immutable/chunks/{D9-KwDth.js → 2gbKHQXV.js} +1 -1
  5. package/web/app/immutable/chunks/{B6l-Kttu.js → 3vi-OgRR.js} +1 -1
  6. package/web/app/immutable/chunks/{B0kpU9fA.js → 4WFBPbig.js} +2 -2
  7. package/web/app/immutable/chunks/{vE2E6sS8.js → 64KJqioX.js} +1 -1
  8. package/web/app/immutable/chunks/{CrL6DZCQ.js → 8vt0w0gB.js} +1 -1
  9. package/web/app/immutable/chunks/{CL1PbmdJ.js → AzvtNQGc.js} +1 -1
  10. package/web/app/immutable/chunks/{lFTk8wpi.js → B3agx6Zv.js} +1 -1
  11. package/web/app/immutable/chunks/{BpWCMu3u.js → B430oCRo.js} +1 -1
  12. package/web/app/immutable/chunks/{BIn5egRU.js → B4N2SW_I.js} +1 -1
  13. package/web/app/immutable/chunks/{Dkvzw9dt.js → B6OWzTDz.js} +1 -1
  14. package/web/app/immutable/chunks/{CjYF1At4.js → B77zwvv7.js} +1 -1
  15. package/web/app/immutable/chunks/{DC0oh9YH.js → B8GoKZxM.js} +1 -1
  16. package/web/app/immutable/chunks/{Di4F3rxF.js → B93aSOB6.js} +1 -1
  17. package/web/app/immutable/chunks/{BrFkQr4z.js → BAcZGd3g.js} +1 -1
  18. package/web/app/immutable/chunks/{O-dTT9_6.js → BDMD6FdT.js} +1 -1
  19. package/web/app/immutable/chunks/{CrBBYf3_.js → BFAXN_U2.js} +1 -1
  20. package/web/app/immutable/chunks/{ulO2uazy.js → BIZcpPtH.js} +1 -1
  21. package/web/app/immutable/chunks/{ftVcR4tQ.js → BMjTWq66.js} +1 -1
  22. package/web/app/immutable/chunks/{BQNpzQlP.js → BQ0lhaiw.js} +1 -1
  23. package/web/app/immutable/chunks/{EwMtkE4R.js → BR-e1Dqz.js} +4 -4
  24. package/web/app/immutable/chunks/{Ixhw1ROs.js → BSXFgzj_.js} +1 -1
  25. package/web/app/immutable/chunks/{CnzZSXm6.js → BbbO1mVP.js} +1 -1
  26. package/web/app/immutable/chunks/{CajUAX8N.js → BiWBSez2.js} +2 -2
  27. package/web/app/immutable/chunks/{DY06SZsl.js → BjLzmoKu.js} +1 -1
  28. package/web/app/immutable/chunks/{ZJOyleCJ.js → BjmThgx9.js} +3 -3
  29. package/web/app/immutable/chunks/{BIkmNkpw.js → BlPpu_gv.js} +1 -1
  30. package/web/app/immutable/chunks/{BTcBtO7l.js → Bmgc_Vmk.js} +1 -1
  31. package/web/app/immutable/chunks/{D-usBtmP.js → BpXYSrHL.js} +4 -4
  32. package/web/app/immutable/chunks/{vlM04DTZ.js → BuHIOAsb.js} +1 -1
  33. package/web/app/immutable/chunks/{OusZ11tk.js → Buf2XX2m.js} +1 -1
  34. package/web/app/immutable/chunks/{BuQN2T0g.js → Byc-Gwn1.js} +2 -2
  35. package/web/app/immutable/chunks/{uA3ZM6fH.js → C2f0QCtk.js} +1 -1
  36. package/web/app/immutable/chunks/{C79sRXBG.js → C4tXJNlU.js} +1 -1
  37. package/web/app/immutable/chunks/{CQy8trug.js → C5Ddrquv.js} +1 -1
  38. package/web/app/immutable/chunks/{DsnmJyUD.js → C8F76z1j.js} +1 -1
  39. package/web/app/immutable/chunks/{B2NZzPt-.js → C8GDR5mq.js} +1 -1
  40. package/web/app/immutable/chunks/{DHpb0iQY.js → CBP_r2rZ.js} +1 -1
  41. package/web/app/immutable/chunks/{BOD8_Ffh.js → CCr3GhwT.js} +1 -1
  42. package/web/app/immutable/chunks/{A-qdlPO9.js → CEIGYgmC.js} +1 -1
  43. package/web/app/immutable/chunks/{Z4Jzxw8B.js → CLkKOQIb.js} +1 -1
  44. package/web/app/immutable/chunks/{CBHdapAk.js → CMR4RacT.js} +1 -1
  45. package/web/app/immutable/chunks/{B9STQthu.js → CMd9xe_v.js} +1 -1
  46. package/web/app/immutable/chunks/{DdJj628K.js → CNW9Rwes.js} +1 -1
  47. package/web/app/immutable/chunks/{Ds6NYQhM.js → CNc8h__d.js} +1 -1
  48. package/web/app/immutable/chunks/{CYyfRGPT.js → CP03b_lt.js} +1 -1
  49. package/web/app/immutable/chunks/{BTi_uPkP.js → CSUG4tUd.js} +2 -2
  50. package/web/app/immutable/chunks/{D82C3bhe.js → CVA75Jzf.js} +1 -1
  51. package/web/app/immutable/chunks/{CtZeiR9i.js → CXXobfG5.js} +1 -1
  52. package/web/app/immutable/chunks/{BApUcPKR.js → C_MA8w30.js} +1 -1
  53. package/web/app/immutable/chunks/{wDPUZWBZ.js → CbGkMYMi.js} +1 -1
  54. package/web/app/immutable/chunks/{xs1C7KnJ.js → CgyKOUjB.js} +1 -1
  55. package/web/app/immutable/chunks/{f50N8hQo.js → Ciyw1cDk.js} +1 -1
  56. package/web/app/immutable/chunks/{LbiCax8N.js → CjmicwNO.js} +1 -1
  57. package/web/app/immutable/chunks/Ck2JBj0W.js +3 -0
  58. package/web/app/immutable/chunks/{Dge5ZGj2.js → CmfLCgYN.js} +1 -1
  59. package/web/app/immutable/chunks/{2XoFwLeT.js → CuNdhmq6.js} +1 -1
  60. package/web/app/immutable/chunks/{CMAV3UUk.js → Cu_kcmjo.js} +1 -1
  61. package/web/app/immutable/chunks/{B0lZCUS6.js → CvO597Pq.js} +1 -1
  62. package/web/app/immutable/chunks/{CPj4SFCC.js → CwLBVHwC.js} +1 -1
  63. package/web/app/immutable/chunks/{CZDluI6H.js → CygNkso5.js} +1 -1
  64. package/web/app/immutable/chunks/{CtKyfVB_.js → D-5xnKgT.js} +1 -1
  65. package/web/app/immutable/chunks/{RwJyhbRN.js → D0WHOKE3.js} +1 -1
  66. package/web/app/immutable/chunks/{CIJY2gxU.js → D4HebHoD.js} +1 -1
  67. package/web/app/immutable/chunks/{BbobBw8S.js → D4_8WlAX.js} +1 -1
  68. package/web/app/immutable/chunks/{CR5ZxoLH.js → D4p9bnGO.js} +1 -1
  69. package/web/app/immutable/chunks/{BDThAQjj.js → D73rJM26.js} +1 -1
  70. package/web/app/immutable/chunks/{Df3mQZLv.js → D7X_WaSL.js} +3 -3
  71. package/web/app/immutable/chunks/{DE_K0DMt.js → D9E1Sed-.js} +3 -3
  72. package/web/app/immutable/chunks/{DCzChru-.js → D9ZsyNyz.js} +1 -1
  73. package/web/app/immutable/chunks/{2YKrLT6f.js → DAAshoKb.js} +1 -1
  74. package/web/app/immutable/chunks/{BesmUwoU.js → DL1rChoc.js} +1 -1
  75. package/web/app/immutable/chunks/{Oweeyv1v.js → DL9oF9R-.js} +1 -1
  76. package/web/app/immutable/chunks/{BehvUfjM.js → DO0YQnSr.js} +1 -1
  77. package/web/app/immutable/chunks/{BpSBXUuJ.js → DQITwHBm.js} +2 -2
  78. package/web/app/immutable/chunks/{DOOplL0N.js → DSam4kPq.js} +2 -2
  79. package/web/app/immutable/chunks/{BPW7kjsh.js → DSviIBB2.js} +1 -1
  80. package/web/app/immutable/chunks/{m11ohSMf.js → DTl-epgW.js} +1 -1
  81. package/web/app/immutable/chunks/{B418rdhJ.js → DUnf3IJM.js} +1 -1
  82. package/web/app/immutable/chunks/{5Z6V3HtS.js → DVkhmNxg.js} +3 -3
  83. package/web/app/immutable/chunks/{BWDjljS8.js → DXT_tHZV.js} +3 -3
  84. package/web/app/immutable/chunks/{BPwzpRKZ.js → DXq51U5Z.js} +1 -1
  85. package/web/app/immutable/chunks/{1mJrE3jk.js → DZnf3Vcd.js} +1 -1
  86. package/web/app/immutable/chunks/{B9Y57c7j.js → D_yMjDjB.js} +6 -6
  87. package/web/app/immutable/chunks/{CKK0Gz-a.js → DdfA1Cl6.js} +2 -2
  88. package/web/app/immutable/chunks/{DFQ6yCR1.js → DfvdR1t7.js} +13 -13
  89. package/web/app/immutable/chunks/{D1wNvwqn.js → Di8laZBj.js} +1 -1
  90. package/web/app/immutable/chunks/{CwB9Am9z.js → DjHgMTjl.js} +3 -3
  91. package/web/app/immutable/chunks/{BoefNJ5Q.js → DlekFIEJ.js} +1 -1
  92. package/web/app/immutable/chunks/{NPKMdhKA.js → DmNlyOFF.js} +2 -2
  93. package/web/app/immutable/chunks/{9DRLCqFH.js → DoGlKPs8.js} +1 -1
  94. package/web/app/immutable/chunks/{CNsgRr0G.js → DoKriIRg.js} +1 -1
  95. package/web/app/immutable/chunks/{CsleiD5D.js → DoUa1hTg.js} +1 -1
  96. package/web/app/immutable/chunks/{oaGKgX0i.js → DpqgMZNx.js} +1 -1
  97. package/web/app/immutable/chunks/{Bpb7JDWq.js → Dqso2iIq.js} +1 -1
  98. package/web/app/immutable/chunks/{DLmLA9DN.js → Dr_KWcsf.js} +1 -1
  99. package/web/app/immutable/chunks/{B89v0U4a.js → DsATs4Yw.js} +3 -3
  100. package/web/app/immutable/chunks/{OfToEAub.js → DtPlbqlO.js} +1 -1
  101. package/web/app/immutable/chunks/{C-y2Lv4J.js → DumB3eQv.js} +1 -1
  102. package/web/app/immutable/chunks/{R-aBLidW.js → DyOuvQsx.js} +3 -3
  103. package/web/app/immutable/chunks/{DCO02E6M.js → Dyda26aD.js} +1 -1
  104. package/web/app/immutable/chunks/{yLWVsiXj.js → Dz9187FZ.js} +1 -1
  105. package/web/app/immutable/chunks/{lCSqh71Z.js → DzXo18RQ.js} +1 -1
  106. package/web/app/immutable/chunks/{fth1noPu.js → FHdlPR2E.js} +1 -1
  107. package/web/app/immutable/chunks/{BEWjMMmw.js → QJaPD5ja.js} +3 -3
  108. package/web/app/immutable/chunks/{Cv2q5gkL.js → Smn45KEu.js} +1 -1
  109. package/web/app/immutable/chunks/{ahq3r4Wz.js → TWY-IEJw.js} +1 -1
  110. package/web/app/immutable/chunks/{DqfSttpc.js → a_hFrVUs.js} +1 -1
  111. package/web/app/immutable/chunks/{Bxb8LI6C.js → eHy-2vQk.js} +1 -1
  112. package/web/app/immutable/chunks/{Qh1eK2X9.js → eWtOjdwZ.js} +1 -1
  113. package/web/app/immutable/chunks/{zROLTv2m.js → ezsQjlt6.js} +1 -1
  114. package/web/app/immutable/chunks/{vQ3XSTvm.js → kRDyYnu-.js} +1 -1
  115. package/web/app/immutable/chunks/{BHtMcien.js → lMYobXp7.js} +1 -1
  116. package/web/app/immutable/chunks/{55NQjm3t.js → m5FEmsd9.js} +1 -1
  117. package/web/app/immutable/chunks/{DQewNXDh.js → n1Mub_w4.js} +1 -1
  118. package/web/app/immutable/chunks/{DsFpAZo7.js → pO_uIUtS.js} +2 -2
  119. package/web/app/immutable/chunks/{CQR1o7um.js → paBp5EDQ.js} +2 -2
  120. package/web/app/immutable/chunks/{eGqXrC9g.js → rUAQGuY9.js} +1 -1
  121. package/web/app/immutable/chunks/{DadrYnVI.js → s5eSUTR7.js} +1 -1
  122. package/web/app/immutable/chunks/{DyaBo2y6.js → sppurVVE.js} +1 -1
  123. package/web/app/immutable/chunks/{B5PU_SZw.js → tDXv5z_U.js} +1 -1
  124. package/web/app/immutable/chunks/{CAG8YIXN.js → uMNoDmQ2.js} +1 -1
  125. package/web/app/immutable/chunks/{D0xQDzbV.js → xCNFDAsL.js} +1 -1
  126. package/web/app/immutable/chunks/{CRBVaIXN.js → yc-ZA4uZ.js} +1 -1
  127. package/web/app/immutable/entry/{app.-hRXZvoO.js → app.DDy_f4Vr.js} +2 -2
  128. package/web/app/immutable/entry/start.CtWgyCM1.js +1 -0
  129. package/web/app/immutable/nodes/{0.Bf92A2SS.js → 0.BIgrj7tk.js} +1 -1
  130. package/web/app/immutable/nodes/{1.BWS1uOkH.js → 1.BS4qG73n.js} +1 -1
  131. package/web/app/immutable/nodes/{10.xvB45P-Z.js → 10.CoUmfWJP.js} +4 -4
  132. package/web/app/immutable/nodes/{11.CWt_UL31.js → 11.Cp19-DaX.js} +1 -1
  133. package/web/app/immutable/nodes/{15.BFkam5BT.js → 15._NKX_puo.js} +1 -1
  134. package/web/app/immutable/nodes/{19.DASGyMmu.js → 19.CrIpgdrd.js} +2 -2
  135. package/web/app/immutable/nodes/{2.BLp65UB0.js → 2.B-ARMoF4.js} +4 -4
  136. package/web/app/immutable/nodes/{3.sLYNU_z5.js → 3.CeiKZ0d6.js} +1 -1
  137. package/web/app/immutable/nodes/{4.CYsqPvqR.js → 4.-s0Jfvde.js} +1 -1
  138. package/web/app/immutable/nodes/{5.BDPUNvGt.js → 5.BIDxYMYJ.js} +1 -1
  139. package/web/app/immutable/nodes/{6.Cmp_rej6.js → 6.3fDeScAq.js} +1 -1
  140. package/web/app/immutable/nodes/{7.BeJ_Zasr.js → 7.DydkXABx.js} +1 -1
  141. package/web/app/immutable/nodes/{8.CTerGGp8.js → 8.DyQruTiJ.js} +1 -1
  142. package/web/app/immutable/nodes/{9.D8TUAlXi.js → 9.D0w1njvH.js} +4 -4
  143. package/web/app/version.json +1 -1
  144. package/web/index.html +9 -9
  145. package/web/app/immutable/chunks/Qqd9dQHZ.js +0 -3
  146. package/web/app/immutable/entry/start.C3r7ji-v.js +0 -1
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["/app/immutable/chunks/D82C3bhe.js","/app/immutable/chunks/C1zxTHwk.js","/app/immutable/chunks/Bqd7fdCF.js","/app/immutable/chunks/CIyUrgF0.js","/app/immutable/chunks/ClpAEjbe.js","/app/immutable/chunks/CJxGDkBm.js","/app/immutable/chunks/wmcYjLAa.js","/app/immutable/chunks/CnGVh7I3.js","/app/immutable/chunks/WSVFXKpL.js","/app/immutable/assets/spinner.D_TRo5Hy.css","/app/immutable/chunks/BVi5KkOP.js","/app/immutable/chunks/NtFyWdpR.js","/app/immutable/chunks/BwASeArv.js","/app/immutable/chunks/CPDV_dyu.js","/app/immutable/chunks/BejTxFyR.js","/app/immutable/chunks/uXuxG9cN.js","/app/immutable/assets/button.-yaUNjRS.css","/app/immutable/chunks/DSqSJXGX.js","/app/immutable/chunks/Xh71Wbuh.js","/app/immutable/chunks/By588DV1.js","/app/immutable/chunks/BeYVt6Wg.js","/app/immutable/chunks/CpP1PKzF.js","/app/immutable/chunks/PVXvIyE8.js","/app/immutable/chunks/ChTqQfQN.js","/app/immutable/chunks/CgBcONKs.js","/app/immutable/chunks/DxwfiAWm.js","/app/immutable/chunks/DJfJ5NWH.js","/app/immutable/chunks/CtJxHvGv.js","/app/immutable/chunks/oXpJ1LFx.js","/app/immutable/chunks/BoIfXiRv.js","/app/immutable/chunks/XJv96NUg.js","/app/immutable/assets/notify.B1j5oT2y.css","/app/immutable/chunks/D9Ykl3eH.js","/app/immutable/chunks/DypB-Dwi.js","/app/immutable/chunks/CTV49dzf.js","/app/immutable/chunks/CL3a4Hm1.js","/app/immutable/chunks/BBWuirRW.js","/app/immutable/chunks/BdWqymET.js","/app/immutable/chunks/DsFpAZo7.js","/app/immutable/chunks/DKwAaLwd.js","/app/immutable/chunks/b89lNINv.js","/app/immutable/chunks/DujUyPvo.js","/app/immutable/chunks/ByoP16rr.js","/app/immutable/chunks/C5TH9nNS.js","/app/immutable/chunks/B6-GEB4b.js","/app/immutable/chunks/B5aYN90J.js","/app/immutable/chunks/DedMJivv.js","/app/immutable/chunks/CMiilI_P.js","/app/immutable/chunks/B_QPRXJ5.js","/app/immutable/chunks/BxKppgO5.js","/app/immutable/chunks/DONrLvvt.js"])))=>i.map(i=>d[i]);
2
- var Et=Object.defineProperty;var Dt=(e,t,n)=>t in e?Et(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Pe=(e,t,n)=>Dt(e,typeof t!="symbol"?t+"":t,n);import{Jq as A,m as be,nV as R,wp as Rt,Cm as Ge,wr as xt,DA as Je,cJ as Pt,cK as Bt,nW as Ye,nI as Ot,i as ke,fU as Lt,m7 as Ut,cR as $t}from"./CpP1PKzF.js";import{J as Nt,Z as Ht,dT as Be,cR as pe,dE as Ft,aw as Kt,bc as Qe,I as Wt,e4 as jt}from"./D9Ykl3eH.js";import{e as qt,b as ae,F as Vt,y as re,_ as ve,G as zt,C as Gt,W as Xe,v as Jt,u as Yt,M as Qt}from"./CgBcONKs.js";import{D as Oe,a as Xt,d as Zt}from"./CQcEqK4G.js";import{m as en,g as Ze,r as tn,k as nn,D as an}from"./BqoCUMk3.js";import{e as rn}from"./CL3a4Hm1.js";import{z as et,O as sn}from"./Bqd7fdCF.js";import{a as on}from"./B-pzX-N9.js";import{f as cn}from"./D35mkEt2.js";import{bm as b,_ as fe}from"./ClpAEjbe.js";import{aa as tt,aB as se,J as he,a as nt,n as at,cS as rt,e as st,aI as it,M as ln,ac as dn,aV as Le,d as le,C as un,cT as mn,U as pn,a6 as fn,aJ as hn,b_ as gn}from"./Bxb8LI6C.js";import{W as yn,L as wn,w as bn,R as kn,M as vn,h as _n}from"./CPDV_dyu.js";import{l as V,i as Sn,n as Mn}from"./By588DV1.js";import{x as An,J as In,ai as Tn,ar as Cn}from"./B89v0U4a.js";import{a as Ue,b as En,g as Dn}from"./DypB-Dwi.js";import{m as Rn}from"./b89lNINv.js";import{C as xn}from"./B5aYN90J.js";import{i as Pn}from"./D95Y9O1z.js";import{o as L,e as Bn,l as z,s as C,n as ce,b as On,d as Ln,c as Un}from"./CIyUrgF0.js";const Rr=A.createSelector((e,t)=>e.unreadTracking.dividerSessionByAgentId[t]??null),xr=A.createSelector(e=>e.unreadTracking.currentlyViewedAgentId),Pr=A.createSelector(e=>{const t=[];for(const s of Object.values(e.panelLayout.byWorkspaceId))for(const i of Object.values(s.panels))for(const o of i.tabs)o.type==="agent"&&o.agentId&&t.push(o.agentId);const n=Object.keys(e.unreadTracking.dividerSessionByAgentId),a=new Set(e.agentSessions.agentIdsByWorkspace[be]??[]);return{chiefCardVisible:e.sidebarNav.panelItem==="chief",chiefSessionAgentIds:n.filter(s=>a.has(s)),dividerSessionAgentIds:n,openAgentTabIds:t}});function Br(e,t){if(e)return e.model}function $n({messages:e,pendingInitialPrompt:t,pendingContextReferenceCount:n=0}){return e.length>0||!!t||n>0}function Or({session:e,messages:t,pendingInitialPrompt:n,pendingContextReferenceCount:a=0}){return!(e?Nt(e):!1)&&!$n({messages:t,pendingInitialPrompt:n,pendingContextReferenceCount:a})}function Lr(e){return Ht(e.messageMetadata)}function Nn(e){return{id:e.id,appMessageId:e.appMessageId,role:"user",timestamp:new Date(e.createdAt??0).toISOString(),contentBlocks:[...e.content?[{type:"text",text:e.content}]:[],...e.imageBlocks??[],...e.fileBlocks??[]],metadata:e.messageMetadata,...e.author!==void 0?{author:e.author}:{}}}function Ur(e){return Nn({...e,createdAt:Date.parse(e.queuedAt)})}const Hn=8*1024*1024,Fn=3*1024*1024;function Kn(e){return Math.ceil(Math.max(0,e)/3)*4}function Wn(e){const t=e.promptBase64Bytes;return e.mimeType==="image/jpeg"&&Number.isSafeInteger(e.size)&&e.size>0&&e.size<=Fn&&typeof t=="number"&&t===Kn(e.size)?t:null}async function ot(e,t,n,a,r=()=>{}){const s=()=>{if(!a())throw new Error("media-send-retired")};if(s(),r("overlay-render"),!n.exportMedia)throw new Error("media-export-unavailable");const i=on(e.source,e.saved);if(i.length>1e4)throw new Error("media-animation-layer-limit");const o=[];for(const c of i)s(),o.push({...c,png:await en(e.source,e.saved,c.atMs)});s(),r("export");const l=await n.exportMedia({outputVersion:qt,jobId:t,media:e,layers:o});if(s(),!l.ok)throw new Error(["media-export-failed",l.error].filter(Boolean).join(":"));return{jobId:t,value:l.value}}const _e={CLIPBOARD_WRITE:"dock-media:clipboard-write",CLIPBOARD_READ:"dock-media:clipboard-read",MENU:"dock-media:menu"};function $e(e,t){return Math.max(0,(e.pausedAt??t)-e.startedAt-(e.pausedMs??0))}function ge(e,t){if(!t?.startsWith(".intent/attachments/"))return;const n=t.split("/").map(encodeURIComponent).join("/"),a=tt(`intent://local/file/${n}`,e);return a?.kind==="video"?a.url:void 0}function jn(e){const t=e.video==="full"?b.dock_captureEditor_videoFull_label():b.dock_captureEditor_videoHighlights_label(),n=e.voice==="audio"?b.dock_captureEditor_voiceAudio_label():e.voice==="transcript"?b.dock_captureEditor_voiceTranscript_label():b.dock_captureEditor_voiceOff_summary();return`${t} · ${n}`}function qn(e,t,n,a){if(a?.error==="permission")return a.kind==="pick"?"accessibility":"screen";if(e==="permission"||t==="permission")return"screen";if(n?.startsWith("microphone-permission"))return"microphone";if(n?.startsWith("speech-permission"))return"speech"}const q=cn;function $r(e){const{view:t,items:n,local:a,labels:r,copy:s}=e,i=t.speech.error??t.speech.capability?.reason??null,o=qn(t.captureError,t.clips.find(g=>g.status==="failed"&&g.error==="permission")?.error??null,i,t.annotationIssue),l=t.annotationIssue?.error==="unavailable"?s?.annotationUnavailable:void 0,c=t.annotationIssue,d=t.captureError==="permission",u=c?.error==="permission"&&c.kind!=="pick",h=c?.error==="permission"&&c.kind==="pick",p=i?.startsWith("speech-permission")?"speech":i?.startsWith("microphone-permission")||i==="permission"?"microphone":void 0,m={},y={},f=(g,D,$)=>{m[g]=D,$&&(y[g]=$)};s&&(d&&(f("capture",s.permission,"screen"),t.recording||f("record",s.permission,"screen")),u&&!t.annotating&&f("annotate",s.permission,"screen"),h&&(f("pick",s.accessibilityPermission,"accessibility"),t.tool==="pick"&&!t.annotating&&f("annotate",s.accessibilityPermission,"accessibility")),p&&!t.dictation&&f("mic",(i&&r.speechError?.(i))??s.speechPermission,p));const k=g=>{const D=y[g];D&&e.actions.onOpenSettings(D)},v=new Set(t.evidenceOwnedItemIds),I=t.clips.find(g=>g.status==="recording"),S=t.clips.length>=ae.clips,_=t.capabilities,B=t.speech.available,E=new Set(t.clips.filter(g=>g.status==="recording"||g.status==="placing"||!!g.media).flatMap(g=>g.captureHistory?.map(D=>D.image.id)??[])),P=[...t.tiles.filter(({image:g,marks:D})=>!!g.media||g.source!=="annotate"||!E.has(g.id)||D.some(({mark:$})=>!$.clipId)).map(({image:g,marks:D})=>({kind:"image",id:g.contextItemId,url:a.previews[g.id]??"",markCount:D.length,owner:"evidence",...a.previews[g.id]?{}:{status:"placing"}})),...t.clips.filter(g=>!g.discarding).map(g=>({kind:"clip",id:g.contextItemId??g.id,duration:q(g.status==="recording"?$e(g,a.now):g.durationMs),recording:g.status==="recording",...g.media?.saved?{summary:jn(g.media.saved)}:{},...g.status==="ready"&&ge(e.workspaceId,g.path)?{url:ge(e.workspaceId,g.path)}:{},owner:"evidence",...g.status==="placing"?{status:"placing"}:{},...g.status==="failed"?{status:"failed",...g.error==="limit"?{error:b.dock_composer_clipTooLarge_error()}:{}}:{}})),...n.filter(g=>!v.has(g.id)).map(g=>({...g.imageData&&g.imageMimeType?{kind:"image",id:g.id,url:`data:${g.imageMimeType};base64,${g.imageData}`,markCount:0,file:{name:g.label,imageData:g.imageData,imageMimeType:g.imageMimeType}}:{kind:"file",id:g.id,name:g.label},owner:"attachment",...g.placementStatus==="placing"?{status:"placing"}:{},...g.placementStatus==="failed"?{status:"failed",error:g.placementError}:{}}))];return{mediaStatus:t.recording?{kind:"recording",label:r.recording}:t.annotating?{kind:"annotating",label:r.annotating}:void 0,...o?{settingsPane:o}:{},...l?{annotationNotice:l}:{},labels:r,attachments:P,...s?{placeholder:t.dictation?"":s.idle}:{},state:{captureRevision:t.captureAccepted,capturePending:t.capturePending,captureDisabled:!_.capture||t.captureDisabled,...t.captureDisabled?{captureTooltip:r.captureLimit}:{},captureMode:t.evidence?.annotation?"fullscreen":t.captureMode,captureModesAvailable:!!_.captureModes&&!t.evidence?.annotation,annotationActive:t.annotating,tool:t.tool,toolUsed:t.toolUsed,annotationDisabled:!_.annotate,recording:t.recording&&!I?.discarding,recordingDisabled:!!I?.discarding||!t.recording&&(!_.record||S),...S&&!t.recording?{recordingTooltip:r.clipLimit}:{},recordingTime:q(I?$e(I,a.now):0),dictating:!!t.dictation,dictationPending:t.speech.pending||t.dictation?.status==="transcribing",dictationDisabled:!B&&!t.dictation&&!m.mic,...t.speech.error&&r.speechError?{dictationTooltip:r.speechError(t.speech.error)}:{},dictationTime:t.dictation?q(a.now-t.dictation.startedAt):q(0),inputLevels:t.speech.levels,...Object.keys(m).length?{alerts:m}:{}},...e.actions,...t.fileAttachmentsEnabled===!1?{onEdit:void 0}:{},onAlert:k,beforeSubmit:e.beforeSubmit}}const Se=()=>globalThis.electronAPI,Vn=["image/png","image/jpeg","image/webp"],Ne=e=>Vn.includes(e??"")?e:null;function He(e){const t=atob(e),n=new Uint8Array(t.length);for(let a=0;a<t.length;a+=1)n[a]=t.charCodeAt(a);return n}async function Nr(e,t){const{view:n,items:a,previews:r}=t,s=n.tiles.find(({image:c})=>c.id===e||c.contextItemId===e);if(s){const c=a.find(p=>p.id===s.image.contextItemId),d=s.image.media;if(s.image.mediaError)return null;if(d?.saved){if(!t.createSavedPreviewUrl||!t.revokeUrl)return null;const p={...d,saved:d.saved},m=await t.createSavedPreviewUrl(t.workspaceId,p);try{const y=await t.fetchBytes(m),f=p.saved.crop;return{kind:"image",name:c?.label||"screenshot.png",mimeType:"image/png",bytes:y,intent:{pixels:{mimeType:"image/png",width:Math.max(1,Math.round(f?.w??p.source.width)),height:Math.max(1,Math.round(f?.h??p.source.height)),displayScale:s.image.displayScale,capturedAt:s.image.capturedAt},raw:y,marks:[]}}}finally{t.revokeUrl(m)}}const u=Ne(c?.imageMimeType),h=r[s.image.id];return!c?.imageData||!u||!h?null:{kind:"image",name:c.label||"screenshot.png",mimeType:"image/png",bytes:await t.fetchBytes(h),intent:{pixels:{mimeType:u,width:s.image.width,height:s.image.height,displayScale:s.image.displayScale,capturedAt:s.image.capturedAt,...s.image.hash?{hash:s.image.hash}:{}},raw:He(c.imageData),marks:s.marks.map(({mark:p})=>({tool:p.tool,geometry:p.geometry,bounds:p.bounds,element:p.element}))}}}const i=n.clips.find(c=>c.id===e||c.contextItemId===e);if(i){const c=i.status==="ready"?ge(t.workspaceId,i.path):null;if(!c)return null;const d=a.find(h=>h.id===i.contextItemId),u=await t.fetchBytes(c);if(!Gn(u))throw new Error("Not a recording file");return{kind:"clip",name:d?.label||`recording-${i.id.slice(0,8)}.mp4`,mimeType:d?.attachmentMimeType||"video/mp4",bytes:u,durationMs:i.durationMs,hasMicAudio:i.hasMicAudio}}const o=a.find(c=>c.id===e),l=Ne(o?.imageMimeType);return o?.imageData&&l?{kind:"image",name:o.label||"image",mimeType:l,bytes:He(o.imageData)}:null}async function zn(e){const t=await fetch(e);if(!t.ok)throw new Error(`Media request failed (${t.status})`);const n=new Uint8Array(await t.arrayBuffer()),a=Number(t.headers.get("content-length")??Number.NaN);if(n.byteLength===0||Number.isFinite(a)&&a!==n.byteLength)throw new Error("Media response was incomplete");return n}function Gn(e){return e.byteLength>8&&String.fromCharCode(...e.subarray(4,8))==="ftyp"}async function Hr(e){try{return(await Se()?.invoke(_e.CLIPBOARD_WRITE,e))?.ok===!0}catch{return!1}}async function Jn(){try{return await Se()?.invoke(_e.CLIPBOARD_READ,{})??null}catch{return null}}async function Fr(e){try{const t=await Se()?.invoke(_e.MENU,{canCut:e});return t?.action==="copy"||t?.action==="cut"?t.action:null}catch{return null}}const Fe=new WeakSet;async function Yn(e,t){const[n]=e;if(e.length!==1||!n||n.size!==t.size)return!1;try{const a=await crypto.subtle.digest("SHA-256",await n.arrayBuffer());return Array.from(new Uint8Array(a),s=>s.toString(16).padStart(2,"0")).join("")===t.sha256}catch{return!1}}function Kr(e,{onIntentMedia:t,isCurrent:n,read:a=Jn}){const r=e.clipboardData;if(Fe.has(e)||!r||r.files.length===0)return!1;const s=e.target,i=Array.from(r.files),o=r.types.filter(l=>l!=="Files").map(l=>[l,r.getData(l)]);return e.preventDefault(),e.stopImmediatePropagation(),a().catch(()=>null).then(async l=>{if(!n())return;if(l&&await Yn(i,l)){n()&&t(l);return}if(!n()||!(s instanceof Node)||!s.isConnected)return;const c=new DataTransfer;for(const u of i)c.items.add(u);for(const[u,h]of o)c.setData(u,h);const d=new ClipboardEvent("paste",{clipboardData:c,bubbles:!0,cancelable:!0});Fe.add(d),s.dispatchEvent(d)}),!0}function Qn(e){const t=atob(e),n=new Uint8Array(t.length);for(let a=0;a<t.length;a++)n[a]=t.charCodeAt(a);return n}function Xn(e){let t="";for(let a=0;a<e.length;a+=32768)t+=String.fromCharCode(...e.subarray(a,a+32768));return btoa(t)}function ct(e){let t=0;return e.endsWith("==")?t=2:e.endsWith("=")&&(t=1),Math.floor(e.length*3/4)-t}async function Zn(e){const t=await crypto.subtle.digest("SHA-256",e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength));return Array.from(new Uint8Array(t)).map(n=>n.toString(16).padStart(2,"0")).join("")}const lt={placeAttachment:it,beginAttachmentUpload:st,sendAttachmentUploadChunk:rt,commitAttachmentUpload:at,abortAttachmentUpload:nt,getAttachmentInfo:he,mintIdempotencyKey:se};async function Me(e,t,n,a=lt){const{idempotencyKey:r}=n,s={...r!==void 0?{idempotencyKey:r}:{},...n.rawScreenshot!==void 0?{rawScreenshot:n.rawScreenshot}:{}},i=async m=>mn(m,r)?Le(e,r,a.getAttachmentInfo):void 0;if(ct(n.data)<=ln)try{return await a.placeAttachment(e,t,{data:n.data,mimeType:n.mimeType,...s})}catch(m){const y=await i(m);if(y)return y;throw m}const o=Qn(n.data),l=await Zn(o);let c,d;try{({uploadId:c,maxChunkBytes:d}=await a.beginAttachmentUpload(e,t,o.byteLength,l,{mimeType:n.mimeType,...s}))}catch(m){if(r!==void 0&&dn(m)){const y=await Le(e,r,a.getAttachmentInfo);if(y)return y}throw m}const u=Math.min(pn,d),h=Math.ceil(o.byteLength/u);let p=!1;try{for(let m=0;m<h;m++){const y=o.subarray(m*u,(m+1)*u);await a.sendAttachmentUploadChunk(c,m,Xn(y),e)}return p=!0,await a.commitAttachmentUpload(c,e)}catch(m){const y=p?await i(m):void 0;if(y)return y;throw await a.abortAttachmentUpload(c,e).catch(()=>{}),m}}function ea(e,t){return fn(e,`image-${Date.now()}-${t+1}`)}class Ae extends Error{constructor(n,a){super(n);Pe(this,"retryBlocks");this.name="ImagePlacementError",this.retryBlocks=a}}function ta(e,t){return e instanceof Ae?e.retryBlocks:t}async function na(e,t,n=lt,a=()=>!0){const r=l=>(...c)=>(le(a),l(...c));n={placeAttachment:r(n.placeAttachment),beginAttachmentUpload:r(n.beginAttachmentUpload),sendAttachmentUploadChunk:r(n.sendAttachmentUploadChunk),commitAttachmentUpload:r(n.commitAttachmentUpload),abortAttachmentUpload:r(n.abortAttachmentUpload),getAttachmentInfo:r(n.getAttachmentInfo),mintIdempotencyKey:r(n.mintIdempotencyKey)};const s=[],i=[],o=[];for(let l=0;l<t.length;l++){le(a);const c=t[l];if("attachmentId"in c&&c.attachmentId){const p={type:"image",attachmentId:c.attachmentId,...c.mimeType?{mimeType:c.mimeType}:{}};s.push(p),i.push(p);continue}const d=c,u=d.placementFileName??ea(d.mimeType,l),h=n.mintIdempotencyKey(d.placementIdempotencyKey);try{const p=await Me(e,u,{data:d.data,mimeType:d.mimeType,...h!==void 0?{idempotencyKey:h}:{}},n),m={type:"image",attachmentId:p.attachmentId,...p.mimeType??d.mimeType?{mimeType:p.mimeType??d.mimeType}:{}};s.push(m),i.push(m)}catch(p){const m=un(p);o.push(m?`${u} (${m})`:u),i.push(h!==void 0?{...d,placementIdempotencyKey:h,placementFileName:u}:d)}}if(o.length>0)throw new Ae(b.chat_imagePlacement_failed_error({names:o.join(", ")}),i);return le(a),s}const Wr=Object.freeze(Object.defineProperty({__proto__:null,ImagePlacementError:Ae,base64DecodedBytes:ct,imageRetryBlocks:ta,placeImageAttachment:Me,toImageReferenceBlocks:na},Symbol.toStringTag,{value:"Module"}));function dt(){try{return yn()}catch{return null}}function aa(){return{backendId:A.state.connections.windowBackendId??null,generation:A.state.daemonHealth.connectionGeneration,transport:dt()}}class Ie extends Error{constructor(){super("dock-evidence-backend-changed")}}function N(e,t){return async(...n)=>{e();const a=await t(...n);return e(),a}}const F={current:e=>dt()===e.transport&&A.state.daemonHealth.connectionGeneration===e.generation&&(A.state.connections.windowBackendId??null)===e.backendId,capabilities:()=>wn(),placeImage:(e,t,n,a)=>Me(e,t,n,{placeAttachment:N(a,it),beginAttachmentUpload:N(a,st),sendAttachmentUploadChunk:N(a,rt),commitAttachmentUpload:N(a,at),abortAttachmentUpload:N(a,nt),getAttachmentInfo:N(a,he),mintIdempotencyKey:se}),lookup:(e,t)=>he({workspaceId:e,idempotencyKey:t}),mintKey:se};function J(e){return F.current(e)}function ra(e,t){const n=A.state.dockConversation;return{generation:n.generation,authority:n.authority,clearRevision:R(n.drafts,Vt(e,t))?.clearRevision??0,binding:aa()}}function jr(e,t,n){const a=ra(e,t);return a.generation===n.generation&&a.authority===n.authority&&a.clearRevision===n.clearRevision&&J(n.binding)}function ut(e,t){return()=>{if(!e.current(t))throw new Ie}}const mt=Object.freeze({rawRetention:!1,chiefAttachments:!1});function qr(e){return e!==mt}const de=new Map;function pt(e,t=F){const n=`${e.backendId}:${e.generation}`;let a=de.get(n);if(!a){const r=ut(t,e);a=(async()=>{r();const i=await t.capabilities();r();const o=i?.server?.capabilities;if(!o||typeof o!="object")throw new Error("unobserved");return{rawRetention:o.rawScreenshotRetention===1,chiefAttachments:o.chiefAttachments===1}})().catch(()=>(de.delete(n),mt)),de.set(n,a)}return a}class ee extends Error{constructor(t){super(`dock-raw-retention-contract:${t}`),this.reason=t}}function ft(e){const{rpcCode:t,code:n}=e??{};return t===-32602||n==="INVALID_PARAMS"}function sa(e){const t=String(e?.message??"");return ft(e)&&(t.includes("rawScreenshotExpired:")||/expired at .*not renewable/i.test(t))}function ia(e,t,n){const a=e.rawScreenshot;if(!a||a.compositeAttachmentId!==t)return null;const r=Date.parse(a.expiresAt);return Number.isFinite(r)?a.expired||r<=n?"expired":{attachmentId:e.attachmentId,expiresAt:a.expiresAt}:null}function Ke(e){return{ok:!0,path:e.path,fileName:e.fileName,size:e.size,attachmentId:e.attachmentId,...e.mimeType?{mimeType:e.mimeType}:{},uploadedAt:e.uploadedAt,replayed:!0,...e.rawScreenshot?{rawScreenshot:e.rawScreenshot}:{}}}class oa extends Error{constructor(t,n){super("dock-evidence-placement-failed"),this.imageId=t,this.failure=n}}const We=e=>e.split("/")[1]?.replace("jpeg","jpg")||"png";async function ca(e){const t=e.api??F,n=e.now??Date.now,a=ut(t,e.binding);a();const r=await pt(e.binding,t);a();const s=r.rawRetention&&(e.workspaceId!==be||r.chiefAttachments),i=[];for(const o of e.images){const l=e.records[o.image.id];let c=l&&l.signature===o.signature&&l.workspaceId===e.workspaceId&&l.backendId===e.binding.backendId?l:{imageId:o.image.id,signature:o.signature,workspaceId:e.workspaceId,backendId:e.binding.backendId,compositeKey:null,rawKey:null,composite:null,raw:null,rawSettled:!1};const d=u=>{c=u,e.onRecord(u)};try{if(!c.composite){const h=c.compositeKey,p=t.mintKey(h??void 0)??null;p!==c.compositeKey&&d({...c,compositeKey:p});let m;h&&p===h&&(a(),m=await t.lookup(e.workspaceId,p).then(Ke).catch(()=>{}),a()),m||(a(),m=await t.placeImage(e.workspaceId,`screenshot-${o.image.id.slice(0,8)}.${We(o.composite.mimeType)}`,{data:o.composite.base64,mimeType:o.composite.mimeType,...p?{idempotencyKey:p}:{}},a),a()),d({...c,composite:{attachmentId:m.attachmentId,mimeType:m.mimeType??o.composite.mimeType}})}const u=c.composite.attachmentId;if(s&&o.raw&&!c.raw&&!c.rawSettled){const h=c.rawKey,p=t.mintKey(h??void 0);if(p){p!==c.rawKey&&d({...c,rawKey:p});let m;h&&p===h&&(a(),m=await t.lookup(e.workspaceId,p).then(Ke).catch(()=>{}),a());try{m||(a(),m=await t.placeImage(e.workspaceId,`screenshot-${o.image.id.slice(0,8)}-original.${We(o.raw.mimeType)}`,{data:o.raw.base64,mimeType:o.raw.mimeType,idempotencyKey:p,rawScreenshot:{compositeAttachmentId:u}},a),a());const y=ia(m,u,n());if(y==="expired")d({...c,rawSettled:!0});else if(y)d({...c,raw:y});else throw new ee("echo")}catch(y){if(sa(y))d({...c,rawSettled:!0});else throw y instanceof ee?y:ft(y)?new ee("refused"):y}}else throw new ee("unkeyed")}}catch(u){throw u instanceof Ie?u:new oa(o.image.id,u)}i.push(c)}return i}async function Vr(e,t,n,a){const r=()=>{if(!F.current(a))throw new Ie};r();const s=await F.placeImage(e,t,{...n,idempotencyKey:F.mintKey()},r);return r(),s}const la=new Set(["invalid-saved-edit","media-send-retired","transcript-unavailable","transcript-pending","invalid-edit","stale-source","legacy-baked-marks","timing-unavailable","audio-unavailable","media-source-unavailable","media-export-unavailable","media-animation-layer-limit","media-export-failed","legacy-original-unavailable","capture-render-unavailable","capture-blur-unavailable","stale-source-pixels","not-a-screenshot","not-admitted","unavailable","dock-evidence-missing-pixels","draft-restore-failed","image-budget-exceeded"]),da=new Set(["unavailable","permission","failed","busy","cancelled","limit"]);class O extends Error{constructor(t,n){super(n),this.stage=t,this.code=n,this.name="DockSendError"}}function ie(e){const t=e instanceof Error?e.message:typeof e=="string"?e:"";if(t.length>64)return"unclassified";const[n,...a]=t.split(":");return!la.has(n)||a.length>2?"unclassified":n!=="media-export-failed"?a.length?"unclassified":n:[n,...a.map(r=>da.has(r)?r:"other")].join(":")}function zr(e,t){return e instanceof O?{stage:e.stage,code:ie(e.code)}:{stage:t,code:ie(e)}}function K(e){if(!e||e.source.kind!=="recording")return!1;const t=e.source,n=e.saved??re(t,t.capturedMarks??[],e.transcript);if(n.video!=="full"||n.voice!=="audio"||n.crop||n.blurRegions.length||n.blurStrokes?.length)return!1;const a=ve(n,t,e.transcript);return t.visuals==="clean"?!a.errors.length&&!a.muted&&n.cuts.length===0&&!n.marks.some(r=>r.included)&&a.marks.length===0&&a.transcript===null&&a.kept.length===1&&a.kept[0].startMs===0&&a.kept[0].endMs===t.durationMs&&a.clips.length===1&&a.clips[0].startMs===0&&a.clips[0].endMs===t.durationMs:!a.errors.length&&!a.muted&&a.clips.length===1&&a.clips[0].startMs===0&&a.clips[0].endMs>=t.durationMs}async function ua(e,t,n,a,r,s){const i={images:{},files:[],frames:[],framePromptBytes:[],metadata:[]};let o="validate";try{const l=()=>{if(!r()||!J(n))throw new Error("media-send-retired")};for(const c of[...t.images,...t.clips]){if(o="validate",s?.stage(o),c.mediaError)throw new Error("invalid-saved-edit");if(!c.media||K(c.media))continue;l();const d=structuredClone(c.media),u=d.source;let h=d.saved??re(u,u.capturedMarks??[],d.transcript),p=crypto.randomUUID();try{if(u.kind==="recording"&&h.voice==="transcript"&&d.transcript?.status!=="ready"){if(o="transcribe",s?.stage(o),!a?.transcribeMedia)throw new Error("transcript-unavailable");const f=await a.transcribeMedia({jobId:p,media:d});if(l(),!f.ok)throw new Error("transcript-unavailable");d.transcript=f.value,d.saved||(h=re(u,u.capturedMarks??[],d.transcript))}o="plan",s?.stage(o);const m=ve(h,u,d.transcript);if(m.errors.length)throw new Error(m.errors[0]);const y={id:c.id,kind:u.kind,video:h.video,voice:h.voice,transcript:m.transcript,batches:u.batches,marks:m.marks.map(({n:f,mark:k,frameAtMs:v})=>({n:f,id:k.id,at_ms:v,kind:k.kind,label:k.label,note:k.note,context:k.context,geometry:k.geometry}))};if(u.kind==="screenshot"){o="screenshot-source",s?.stage(o);const f=u.path.split("/").map(encodeURIComponent).join("/"),k=tt(`intent://local/file/${f}`,e);if(!k||k.kind!=="image")throw new Error("media-source-unavailable");const v=await zn(k.url);l();const I={base64:Ze(v.buffer.slice(v.byteOffset,v.byteOffset+v.byteLength)),mimeType:/\.jpe?g$/i.test(u.path)?"image/jpeg":/\.webp$/i.test(u.path)?"image/webp":"image/png"};o="screenshot-render",s?.stage(o),i.images[c.id]=await tn(u,h,I),l()}else{if(!m.clips.length){y.video_attachment_id=null,y.frames=[],y.kept_ms=[],i.metadata.push(y);continue}const f={...d,saved:h};let k=await a?.takePreparedRecording?.(f);if(k&&(p=k.jobId),l(),!k){if(!a)throw new Error("media-export-unavailable");k=await ot(f,p,a,()=>r()&&J(n),S=>{o=S,s?.stage(S),S==="export"&&s?.exportAttempt(p)})}p=k.jobId,o="placement",s?.stage(o);const v=[k.value.video,...k.value.frames],I=[];for(let S=0;S<v.length;S++){l();const _=v[S],B=`capture-${c.id.slice(0,12)}-${S}.${S===0?"mp4":_.mimeType==="image/jpeg"?"jpg":"png"}`,E=await hn(e,B,{sourcePath:_.sourcePath,mimeType:_.mimeType,idempotencyKey:se()},void 0,void 0,()=>r()&&J(n));l(),S===0?i.files.push({type:"file",attachmentId:E.attachmentId,fileName:B,mimeType:E.mimeType??_.mimeType,size:E.size}):(i.frames.push({type:"image",attachmentId:E.attachmentId,mimeType:_.mimeType==="image/jpeg"?"image/jpeg":"image/png"}),i.framePromptBytes.push(Wn(_))),I.push(E.attachmentId)}y.video_attachment_id=I[0],y.frames=k.value.frames.map((S,_)=>({mark_id:S.markId,attachment_id:I[_+1]})),y.kept_ms=m.clips}i.metadata.push(y)}finally{s?.stage("release"),await a?.releaseMediaJob?.(p).catch(()=>{})}}return i}catch(l){throw l instanceof O?l:new O(o,ie(l))}}const ue=1568,ma=.85;async function pa(e,t){const n=Math.round(e.length*3/4/1024),a=await fa(e,t),{width:r,height:s}=a,i=r>ue||s>ue;let o=r,l=s;if(i){const f=ue/Math.max(r,s);o=Math.round(r*f),l=Math.round(s*f)}const c=new OffscreenCanvas(o,l),d=c.getContext("2d");if(!d)throw new Error("Failed to get 2D canvas context for image resize");d.drawImage(a,0,0,o,l);let u=t;ha(d,o,l)||(u="image/jpeg");const h=await c.convertToBlob({type:u,quality:u==="image/jpeg"?ma:void 0}),p=h.type||u,m=await ga(h),y=Math.round(m.length*3/4/1024);return console.debug(`[image-resize] ${r}×${s} → ${o}×${l} | ${t} → ${p} | ${n} KB → ${y} KB`),{base64:m,mimeType:p}}async function fa(e,t){const n=atob(e),a=new Uint8Array(n.length);for(let s=0;s<n.length;s++)a[s]=n.charCodeAt(s);const r=new Blob([a],{type:t});return createImageBitmap(r)}function ha(e,t,n){const r=e.getImageData(0,0,t,n).data;for(let s=3;s<r.length;s+=4)if(r[s]<255)return!0;return!1}async function ga(e){const t=await e.arrayBuffer(),n=new Uint8Array(t);let a="";for(let r=0;r<n.length;r++)a+=String.fromCharCode(n[r]);return btoa(a)}const T={...Oe,badge:Oe.badgeRadius*2};function ya(e,t,n=1,a=0){const r=Math.max(1,e.displayScale)*n,s=[],i=o=>o*n;for(const{n:o,mark:l}of t){const c=l.geometry;if(c.kind==="rect")s.push({kind:"rect",x:i(c.x),y:i(c.y),w:i(c.w),h:i(c.h),width:T.stroke*r});else if(c.kind==="path")s.push({kind:"path",points:c.points.map(m=>({x:i(m.x),y:i(m.y)})),width:T.pen*r});else{const m={x:i(c.from.x),y:i(c.from.y)},y={x:i(c.to.x),y:i(c.to.y)};s.push({kind:"arrow",from:m,to:y,head:_a(m,y,T.arrowHead*r),width:T.stroke*r})}if(!T.showNumbers)continue;const d=Math.max(a,T.badge/2*r),u=i(l.bounds.x+l.bounds.w),h=i(l.bounds.y),p=Zt({x:i(l.bounds.x),y:h,w:u-i(l.bounds.x),h:i(l.bounds.h)},{x:0,y:0,w:i(e.width),h:i(e.height)},r,d);s.push({kind:"badge",...p,radius:d,label:String(o),font:d*T.badgeTextScale})}return s}function wa(e,t){"letterSpacing"in e&&(e.letterSpacing="0px"),"wordSpacing"in e&&(e.wordSpacing="0px");const n=(a,r,s)=>{e.strokeStyle=T.halo,e.lineWidth=a+T.haloWidth*r,s(),e.strokeStyle=T.accent,e.lineWidth=a,s()};e.strokeStyle=T.accent,e.lineCap="round",e.lineJoin="round";for(const a of t)if(a.kind==="rect")n(a.width,a.width/T.stroke,()=>e.strokeRect(a.x,a.y,a.w,a.h));else if(a.kind==="path"||a.kind==="arrow"){e.lineWidth=a.width,e.beginPath();const r=a.kind==="path"?a.points:[a.from,a.to];a.kind==="arrow"&&r.forEach((i,o)=>o?e.lineTo(i.x,i.y):e.moveTo(i.x,i.y)),a.kind==="arrow"&&(e.moveTo(a.head.left.x,a.head.left.y),e.lineTo(a.to.x,a.to.y),e.lineTo(a.head.right.x,a.head.right.y));const s=a.kind==="path"?new Path2D(Xt(a.points)):null;n(a.width,a.width/(a.kind==="path"?T.pen:T.stroke),()=>s?e.stroke(s):e.stroke())}else e.fillStyle=T.paper,e.beginPath(),e.arc(a.x,a.y,a.radius,0,Math.PI*2),e.closePath(),e.fill(),e.strokeStyle=T.accent,e.lineWidth=T.badgeOutline*a.radius/T.badgeRadius,e.stroke(),e.fillStyle=T.ink,e.font=`600 ${a.font}px ${T.badgeFontFamily}`,e.textAlign="center",e.textBaseline="middle",e.fillText(a.label,a.x,a.y)}async function ba(e,t){const n=Uint8Array.from(atob(e),a=>a.charCodeAt(0));return createImageBitmap(new Blob([n],{type:t}))}async function ka(e){const t=await e.convertToBlob({type:"image/png"});return Ze(await t.arrayBuffer())}async function ht(e,t,n,a,r=0){await nn();const s=await ba(e.base64,e.mimeType);try{const i=Math.min(1,a/Math.max(t.width,t.height)),o=new OffscreenCanvas(Math.max(1,Math.round(t.width*i)),Math.max(1,Math.round(t.height*i))),l=o.getContext("2d");if(!l)throw new Error("dock-evidence-canvas-unavailable");return l.drawImage(s,0,0,o.width,o.height),wa(l,ya(t,n,i,r)),o}finally{s.close()}}async function va(e,t,n){const a=await ht(e,t,n,Math.max(t.width,t.height));return pa(await ka(a),"image/png")}async function Gr(e,t,n,a=384){const r=await ht(e,t,n,a,a/32);return URL.createObjectURL(await r.convertToBlob({type:"image/png"}))}function _a(e,t,n=T.arrowHead){const a=Math.atan2(t.y-e.y,t.x-e.x),r=T.arrowSpread;return{left:{x:t.x-n*Math.cos(a-r),y:t.y-n*Math.sin(a-r)},right:{x:t.x-n*Math.cos(a+r),y:t.y-n*Math.sin(a+r)}}}function Jr(e,t){const n=zt(t??void 0),a=new Set(t?.clips.filter(r=>!!r.media&&!K(r.media)).map(r=>r.contextItemId));return e.filter(r=>!n.has(r.id)&&!a.has(r.id))}async function Yr({workspaceId:e,agentId:t,evidence:n,clickedItems:a,sendItems:r,clickedPayload:s,binding:i,service:o,current:l,onRecord:c,timing:d}){const u=()=>{if(!l()||!J(i))throw new O("validate","media-send-retired")};if(u(),n?.images.some(w=>w.mediaError)||n?.clips.some(w=>w.mediaError))throw new O("validate","invalid-saved-edit");const h=w=>!!w.media&&!K(w.media),p=n?{workspaceId:e,agentId:t,appUrl:`intent://local/workspace/${encodeURIComponent(e)}`,clipAttachmentIds:Object.fromEntries(n.clips.map(w=>[w.id,a.find(M=>M.id===w.contextItemId)?.attachmentId??null]))}:null;for(const w of n?.clips??[]){if(!w.media||!K(w.media))continue;const M=a.find(X=>X.id===w.contextItemId);if(!M||M.attachmentId!==w.media.source.attachmentId||M.path!==w.media.source.path||M.placementStatus!==void 0&&M.placementStatus!=="placed")throw new O("validate","legacy-original-unavailable")}const m=n?await ua(e,n,i,o,l,d):{images:{},files:[],frames:[],framePromptBytes:[],metadata:[]},y=new Set(n?.clips.filter(w=>h(w)||!!w.media&&K(w.media)).map(w=>w.id)),f=new Set(n?.clips.filter(w=>y.has(w.id)).flatMap(w=>(w.captureHistory??[]).map(M=>M.image.id))),k=(n?.images??[]).filter(w=>w.source!=="annotate"||!!w.media||!f.has(w.id)||n.marks.some(M=>M.imageId===w.id&&!(M.clipId&&y.has(M.clipId))));d?.stage("burn");let v=[];try{v=n?await Sa({...n,images:k},a,m.images):[]}catch(w){throw new O("burn",ie(w))}if(m.framePromptBytes.reduce((w,M)=>w+(M??0),0)>Hn)throw new O("validate","image-budget-exceeded");const S=new Set(n?.images.filter(w=>w.media).map(w=>w.id)),_=n?{...n,images:k.map(w=>m.images[w.id]?{...w,width:m.images[w.id].width,height:m.images[w.id].height}:w),clips:n.clips.filter(w=>!h(w)),marks:n.marks.filter(w=>!S.has(w.imageId)&&!n.clips.some(M=>h(M)&&M.id===w.clipId))}:null;u();const B=m.metadata.some(w=>typeof w.transcript=="string"&&w.transcript.trim());if(!s.text.trim()&&!r.length&&!s.workspaceContextStr?.trim()&&!v.length&&!m.files.length&&!m.frames.length&&!s.imageBlocks?.length&&!s.fileBlocks?.length&&!B)return null;let E=v,P=null;d?.stage("placement");const xe=n?await pt(i):null;if(u(),n&&(e!==be||xe?.chiefAttachments)){const w=await ca({workspaceId:e,binding:i,images:k.map((M,X)=>{const Z=a.find(Ct=>Ct.id===M.contextItemId);return{image:M,signature:Gt(n,M.id),composite:{base64:v[X].data,mimeType:v[X].mimeType},raw:!M.media&&Z?.imageData&&Z.imageMimeType?{base64:Z.imageData,mimeType:Z.imageMimeType}:null}}),records:n?.placements??{},onRecord:c});u(),E=w.map(M=>({type:"image",attachmentId:M.composite.attachmentId,mimeType:M.composite.mimeType})),P=Object.fromEntries(w.map(M=>[M.imageId,{attachmentId:M.composite.attachmentId,raw:M.raw}]))}const g=new Map(n?Xe(n).map(({n:w,mark:M})=>[M.id,w]):[]),D=p&&P?{...p,imageAttachments:P,markNumbers:g}:p&&{...p,markNumbers:g},$=n&&D?{...s,imageBlocks:[...E,...m.frames,...s.imageBlocks??[]],fileBlocks:[...s.fileBlocks??[],...m.files],workspaceContextStr:[Yt(_,D),m.metadata.length?`[Edited capture outputs]
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["/app/immutable/chunks/CVA75Jzf.js","/app/immutable/chunks/C1zxTHwk.js","/app/immutable/chunks/Bqd7fdCF.js","/app/immutable/chunks/CIyUrgF0.js","/app/immutable/chunks/ClpAEjbe.js","/app/immutable/chunks/CJxGDkBm.js","/app/immutable/chunks/wmcYjLAa.js","/app/immutable/chunks/CnGVh7I3.js","/app/immutable/chunks/WSVFXKpL.js","/app/immutable/assets/spinner.D_TRo5Hy.css","/app/immutable/chunks/BVi5KkOP.js","/app/immutable/chunks/NtFyWdpR.js","/app/immutable/chunks/BwASeArv.js","/app/immutable/chunks/CPDV_dyu.js","/app/immutable/chunks/BejTxFyR.js","/app/immutable/chunks/uXuxG9cN.js","/app/immutable/assets/button.-yaUNjRS.css","/app/immutable/chunks/DSqSJXGX.js","/app/immutable/chunks/Xh71Wbuh.js","/app/immutable/chunks/By588DV1.js","/app/immutable/chunks/BeYVt6Wg.js","/app/immutable/chunks/CpP1PKzF.js","/app/immutable/chunks/PVXvIyE8.js","/app/immutable/chunks/ChTqQfQN.js","/app/immutable/chunks/CgBcONKs.js","/app/immutable/chunks/DxwfiAWm.js","/app/immutable/chunks/DJfJ5NWH.js","/app/immutable/chunks/CtJxHvGv.js","/app/immutable/chunks/oXpJ1LFx.js","/app/immutable/chunks/BoIfXiRv.js","/app/immutable/chunks/XJv96NUg.js","/app/immutable/assets/notify.B1j5oT2y.css","/app/immutable/chunks/D9Ykl3eH.js","/app/immutable/chunks/DypB-Dwi.js","/app/immutable/chunks/CTV49dzf.js","/app/immutable/chunks/CL3a4Hm1.js","/app/immutable/chunks/BBWuirRW.js","/app/immutable/chunks/BdWqymET.js","/app/immutable/chunks/pO_uIUtS.js","/app/immutable/chunks/DKwAaLwd.js","/app/immutable/chunks/b89lNINv.js","/app/immutable/chunks/DujUyPvo.js","/app/immutable/chunks/ByoP16rr.js","/app/immutable/chunks/C5TH9nNS.js","/app/immutable/chunks/B6-GEB4b.js","/app/immutable/chunks/B5aYN90J.js","/app/immutable/chunks/DedMJivv.js","/app/immutable/chunks/CMiilI_P.js","/app/immutable/chunks/B_QPRXJ5.js","/app/immutable/chunks/BxKppgO5.js","/app/immutable/chunks/DONrLvvt.js"])))=>i.map(i=>d[i]);
2
+ var Et=Object.defineProperty;var Dt=(e,t,n)=>t in e?Et(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Pe=(e,t,n)=>Dt(e,typeof t!="symbol"?t+"":t,n);import{Jq as A,m as be,nV as R,wp as Rt,Cm as Ge,wr as xt,DA as Je,cJ as Pt,cK as Bt,nW as Ye,nI as Ot,i as ke,fU as Lt,m7 as Ut,cR as $t}from"./CpP1PKzF.js";import{J as Nt,Z as Ht,dT as Be,cR as pe,dE as Ft,aw as Kt,bc as Qe,I as Wt,e4 as jt}from"./D9Ykl3eH.js";import{e as qt,b as ae,F as Vt,y as re,_ as ve,G as zt,C as Gt,W as Xe,v as Jt,u as Yt,M as Qt}from"./CgBcONKs.js";import{D as Oe,a as Xt,d as Zt}from"./CQcEqK4G.js";import{m as en,g as Ze,r as tn,k as nn,D as an}from"./BqoCUMk3.js";import{e as rn}from"./CL3a4Hm1.js";import{z as et,O as sn}from"./Bqd7fdCF.js";import{a as on}from"./B-pzX-N9.js";import{f as cn}from"./D35mkEt2.js";import{bm as b,_ as fe}from"./ClpAEjbe.js";import{aa as tt,aB as se,J as he,a as nt,n as at,cS as rt,e as st,aI as it,M as ln,ac as dn,aV as Le,d as le,C as un,cT as mn,U as pn,a6 as fn,aJ as hn,b_ as gn}from"./eHy-2vQk.js";import{W as yn,L as wn,w as bn,R as kn,M as vn,h as _n}from"./CPDV_dyu.js";import{l as V,i as Sn,n as Mn}from"./By588DV1.js";import{x as An,J as In,ai as Tn,ar as Cn}from"./DsATs4Yw.js";import{a as Ue,b as En,g as Dn}from"./DypB-Dwi.js";import{m as Rn}from"./b89lNINv.js";import{C as xn}from"./B5aYN90J.js";import{i as Pn}from"./D95Y9O1z.js";import{o as L,e as Bn,l as z,s as C,n as ce,b as On,d as Ln,c as Un}from"./CIyUrgF0.js";const Rr=A.createSelector((e,t)=>e.unreadTracking.dividerSessionByAgentId[t]??null),xr=A.createSelector(e=>e.unreadTracking.currentlyViewedAgentId),Pr=A.createSelector(e=>{const t=[];for(const s of Object.values(e.panelLayout.byWorkspaceId))for(const i of Object.values(s.panels))for(const o of i.tabs)o.type==="agent"&&o.agentId&&t.push(o.agentId);const n=Object.keys(e.unreadTracking.dividerSessionByAgentId),a=new Set(e.agentSessions.agentIdsByWorkspace[be]??[]);return{chiefCardVisible:e.sidebarNav.panelItem==="chief",chiefSessionAgentIds:n.filter(s=>a.has(s)),dividerSessionAgentIds:n,openAgentTabIds:t}});function Br(e,t){if(e)return e.model}function $n({messages:e,pendingInitialPrompt:t,pendingContextReferenceCount:n=0}){return e.length>0||!!t||n>0}function Or({session:e,messages:t,pendingInitialPrompt:n,pendingContextReferenceCount:a=0}){return!(e?Nt(e):!1)&&!$n({messages:t,pendingInitialPrompt:n,pendingContextReferenceCount:a})}function Lr(e){return Ht(e.messageMetadata)}function Nn(e){return{id:e.id,appMessageId:e.appMessageId,role:"user",timestamp:new Date(e.createdAt??0).toISOString(),contentBlocks:[...e.content?[{type:"text",text:e.content}]:[],...e.imageBlocks??[],...e.fileBlocks??[]],metadata:e.messageMetadata,...e.author!==void 0?{author:e.author}:{}}}function Ur(e){return Nn({...e,createdAt:Date.parse(e.queuedAt)})}const Hn=8*1024*1024,Fn=3*1024*1024;function Kn(e){return Math.ceil(Math.max(0,e)/3)*4}function Wn(e){const t=e.promptBase64Bytes;return e.mimeType==="image/jpeg"&&Number.isSafeInteger(e.size)&&e.size>0&&e.size<=Fn&&typeof t=="number"&&t===Kn(e.size)?t:null}async function ot(e,t,n,a,r=()=>{}){const s=()=>{if(!a())throw new Error("media-send-retired")};if(s(),r("overlay-render"),!n.exportMedia)throw new Error("media-export-unavailable");const i=on(e.source,e.saved);if(i.length>1e4)throw new Error("media-animation-layer-limit");const o=[];for(const c of i)s(),o.push({...c,png:await en(e.source,e.saved,c.atMs)});s(),r("export");const l=await n.exportMedia({outputVersion:qt,jobId:t,media:e,layers:o});if(s(),!l.ok)throw new Error(["media-export-failed",l.error].filter(Boolean).join(":"));return{jobId:t,value:l.value}}const _e={CLIPBOARD_WRITE:"dock-media:clipboard-write",CLIPBOARD_READ:"dock-media:clipboard-read",MENU:"dock-media:menu"};function $e(e,t){return Math.max(0,(e.pausedAt??t)-e.startedAt-(e.pausedMs??0))}function ge(e,t){if(!t?.startsWith(".intent/attachments/"))return;const n=t.split("/").map(encodeURIComponent).join("/"),a=tt(`intent://local/file/${n}`,e);return a?.kind==="video"?a.url:void 0}function jn(e){const t=e.video==="full"?b.dock_captureEditor_videoFull_label():b.dock_captureEditor_videoHighlights_label(),n=e.voice==="audio"?b.dock_captureEditor_voiceAudio_label():e.voice==="transcript"?b.dock_captureEditor_voiceTranscript_label():b.dock_captureEditor_voiceOff_summary();return`${t} · ${n}`}function qn(e,t,n,a){if(a?.error==="permission")return a.kind==="pick"?"accessibility":"screen";if(e==="permission"||t==="permission")return"screen";if(n?.startsWith("microphone-permission"))return"microphone";if(n?.startsWith("speech-permission"))return"speech"}const q=cn;function $r(e){const{view:t,items:n,local:a,labels:r,copy:s}=e,i=t.speech.error??t.speech.capability?.reason??null,o=qn(t.captureError,t.clips.find(g=>g.status==="failed"&&g.error==="permission")?.error??null,i,t.annotationIssue),l=t.annotationIssue?.error==="unavailable"?s?.annotationUnavailable:void 0,c=t.annotationIssue,d=t.captureError==="permission",u=c?.error==="permission"&&c.kind!=="pick",h=c?.error==="permission"&&c.kind==="pick",p=i?.startsWith("speech-permission")?"speech":i?.startsWith("microphone-permission")||i==="permission"?"microphone":void 0,m={},y={},f=(g,D,$)=>{m[g]=D,$&&(y[g]=$)};s&&(d&&(f("capture",s.permission,"screen"),t.recording||f("record",s.permission,"screen")),u&&!t.annotating&&f("annotate",s.permission,"screen"),h&&(f("pick",s.accessibilityPermission,"accessibility"),t.tool==="pick"&&!t.annotating&&f("annotate",s.accessibilityPermission,"accessibility")),p&&!t.dictation&&f("mic",(i&&r.speechError?.(i))??s.speechPermission,p));const k=g=>{const D=y[g];D&&e.actions.onOpenSettings(D)},v=new Set(t.evidenceOwnedItemIds),I=t.clips.find(g=>g.status==="recording"),S=t.clips.length>=ae.clips,_=t.capabilities,B=t.speech.available,E=new Set(t.clips.filter(g=>g.status==="recording"||g.status==="placing"||!!g.media).flatMap(g=>g.captureHistory?.map(D=>D.image.id)??[])),P=[...t.tiles.filter(({image:g,marks:D})=>!!g.media||g.source!=="annotate"||!E.has(g.id)||D.some(({mark:$})=>!$.clipId)).map(({image:g,marks:D})=>({kind:"image",id:g.contextItemId,url:a.previews[g.id]??"",markCount:D.length,owner:"evidence",...a.previews[g.id]?{}:{status:"placing"}})),...t.clips.filter(g=>!g.discarding).map(g=>({kind:"clip",id:g.contextItemId??g.id,duration:q(g.status==="recording"?$e(g,a.now):g.durationMs),recording:g.status==="recording",...g.media?.saved?{summary:jn(g.media.saved)}:{},...g.status==="ready"&&ge(e.workspaceId,g.path)?{url:ge(e.workspaceId,g.path)}:{},owner:"evidence",...g.status==="placing"?{status:"placing"}:{},...g.status==="failed"?{status:"failed",...g.error==="limit"?{error:b.dock_composer_clipTooLarge_error()}:{}}:{}})),...n.filter(g=>!v.has(g.id)).map(g=>({...g.imageData&&g.imageMimeType?{kind:"image",id:g.id,url:`data:${g.imageMimeType};base64,${g.imageData}`,markCount:0,file:{name:g.label,imageData:g.imageData,imageMimeType:g.imageMimeType}}:{kind:"file",id:g.id,name:g.label},owner:"attachment",...g.placementStatus==="placing"?{status:"placing"}:{},...g.placementStatus==="failed"?{status:"failed",error:g.placementError}:{}}))];return{mediaStatus:t.recording?{kind:"recording",label:r.recording}:t.annotating?{kind:"annotating",label:r.annotating}:void 0,...o?{settingsPane:o}:{},...l?{annotationNotice:l}:{},labels:r,attachments:P,...s?{placeholder:t.dictation?"":s.idle}:{},state:{captureRevision:t.captureAccepted,capturePending:t.capturePending,captureDisabled:!_.capture||t.captureDisabled,...t.captureDisabled?{captureTooltip:r.captureLimit}:{},captureMode:t.evidence?.annotation?"fullscreen":t.captureMode,captureModesAvailable:!!_.captureModes&&!t.evidence?.annotation,annotationActive:t.annotating,tool:t.tool,toolUsed:t.toolUsed,annotationDisabled:!_.annotate,recording:t.recording&&!I?.discarding,recordingDisabled:!!I?.discarding||!t.recording&&(!_.record||S),...S&&!t.recording?{recordingTooltip:r.clipLimit}:{},recordingTime:q(I?$e(I,a.now):0),dictating:!!t.dictation,dictationPending:t.speech.pending||t.dictation?.status==="transcribing",dictationDisabled:!B&&!t.dictation&&!m.mic,...t.speech.error&&r.speechError?{dictationTooltip:r.speechError(t.speech.error)}:{},dictationTime:t.dictation?q(a.now-t.dictation.startedAt):q(0),inputLevels:t.speech.levels,...Object.keys(m).length?{alerts:m}:{}},...e.actions,...t.fileAttachmentsEnabled===!1?{onEdit:void 0}:{},onAlert:k,beforeSubmit:e.beforeSubmit}}const Se=()=>globalThis.electronAPI,Vn=["image/png","image/jpeg","image/webp"],Ne=e=>Vn.includes(e??"")?e:null;function He(e){const t=atob(e),n=new Uint8Array(t.length);for(let a=0;a<t.length;a+=1)n[a]=t.charCodeAt(a);return n}async function Nr(e,t){const{view:n,items:a,previews:r}=t,s=n.tiles.find(({image:c})=>c.id===e||c.contextItemId===e);if(s){const c=a.find(p=>p.id===s.image.contextItemId),d=s.image.media;if(s.image.mediaError)return null;if(d?.saved){if(!t.createSavedPreviewUrl||!t.revokeUrl)return null;const p={...d,saved:d.saved},m=await t.createSavedPreviewUrl(t.workspaceId,p);try{const y=await t.fetchBytes(m),f=p.saved.crop;return{kind:"image",name:c?.label||"screenshot.png",mimeType:"image/png",bytes:y,intent:{pixels:{mimeType:"image/png",width:Math.max(1,Math.round(f?.w??p.source.width)),height:Math.max(1,Math.round(f?.h??p.source.height)),displayScale:s.image.displayScale,capturedAt:s.image.capturedAt},raw:y,marks:[]}}}finally{t.revokeUrl(m)}}const u=Ne(c?.imageMimeType),h=r[s.image.id];return!c?.imageData||!u||!h?null:{kind:"image",name:c.label||"screenshot.png",mimeType:"image/png",bytes:await t.fetchBytes(h),intent:{pixels:{mimeType:u,width:s.image.width,height:s.image.height,displayScale:s.image.displayScale,capturedAt:s.image.capturedAt,...s.image.hash?{hash:s.image.hash}:{}},raw:He(c.imageData),marks:s.marks.map(({mark:p})=>({tool:p.tool,geometry:p.geometry,bounds:p.bounds,element:p.element}))}}}const i=n.clips.find(c=>c.id===e||c.contextItemId===e);if(i){const c=i.status==="ready"?ge(t.workspaceId,i.path):null;if(!c)return null;const d=a.find(h=>h.id===i.contextItemId),u=await t.fetchBytes(c);if(!Gn(u))throw new Error("Not a recording file");return{kind:"clip",name:d?.label||`recording-${i.id.slice(0,8)}.mp4`,mimeType:d?.attachmentMimeType||"video/mp4",bytes:u,durationMs:i.durationMs,hasMicAudio:i.hasMicAudio}}const o=a.find(c=>c.id===e),l=Ne(o?.imageMimeType);return o?.imageData&&l?{kind:"image",name:o.label||"image",mimeType:l,bytes:He(o.imageData)}:null}async function zn(e){const t=await fetch(e);if(!t.ok)throw new Error(`Media request failed (${t.status})`);const n=new Uint8Array(await t.arrayBuffer()),a=Number(t.headers.get("content-length")??Number.NaN);if(n.byteLength===0||Number.isFinite(a)&&a!==n.byteLength)throw new Error("Media response was incomplete");return n}function Gn(e){return e.byteLength>8&&String.fromCharCode(...e.subarray(4,8))==="ftyp"}async function Hr(e){try{return(await Se()?.invoke(_e.CLIPBOARD_WRITE,e))?.ok===!0}catch{return!1}}async function Jn(){try{return await Se()?.invoke(_e.CLIPBOARD_READ,{})??null}catch{return null}}async function Fr(e){try{const t=await Se()?.invoke(_e.MENU,{canCut:e});return t?.action==="copy"||t?.action==="cut"?t.action:null}catch{return null}}const Fe=new WeakSet;async function Yn(e,t){const[n]=e;if(e.length!==1||!n||n.size!==t.size)return!1;try{const a=await crypto.subtle.digest("SHA-256",await n.arrayBuffer());return Array.from(new Uint8Array(a),s=>s.toString(16).padStart(2,"0")).join("")===t.sha256}catch{return!1}}function Kr(e,{onIntentMedia:t,isCurrent:n,read:a=Jn}){const r=e.clipboardData;if(Fe.has(e)||!r||r.files.length===0)return!1;const s=e.target,i=Array.from(r.files),o=r.types.filter(l=>l!=="Files").map(l=>[l,r.getData(l)]);return e.preventDefault(),e.stopImmediatePropagation(),a().catch(()=>null).then(async l=>{if(!n())return;if(l&&await Yn(i,l)){n()&&t(l);return}if(!n()||!(s instanceof Node)||!s.isConnected)return;const c=new DataTransfer;for(const u of i)c.items.add(u);for(const[u,h]of o)c.setData(u,h);const d=new ClipboardEvent("paste",{clipboardData:c,bubbles:!0,cancelable:!0});Fe.add(d),s.dispatchEvent(d)}),!0}function Qn(e){const t=atob(e),n=new Uint8Array(t.length);for(let a=0;a<t.length;a++)n[a]=t.charCodeAt(a);return n}function Xn(e){let t="";for(let a=0;a<e.length;a+=32768)t+=String.fromCharCode(...e.subarray(a,a+32768));return btoa(t)}function ct(e){let t=0;return e.endsWith("==")?t=2:e.endsWith("=")&&(t=1),Math.floor(e.length*3/4)-t}async function Zn(e){const t=await crypto.subtle.digest("SHA-256",e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength));return Array.from(new Uint8Array(t)).map(n=>n.toString(16).padStart(2,"0")).join("")}const lt={placeAttachment:it,beginAttachmentUpload:st,sendAttachmentUploadChunk:rt,commitAttachmentUpload:at,abortAttachmentUpload:nt,getAttachmentInfo:he,mintIdempotencyKey:se};async function Me(e,t,n,a=lt){const{idempotencyKey:r}=n,s={...r!==void 0?{idempotencyKey:r}:{},...n.rawScreenshot!==void 0?{rawScreenshot:n.rawScreenshot}:{}},i=async m=>mn(m,r)?Le(e,r,a.getAttachmentInfo):void 0;if(ct(n.data)<=ln)try{return await a.placeAttachment(e,t,{data:n.data,mimeType:n.mimeType,...s})}catch(m){const y=await i(m);if(y)return y;throw m}const o=Qn(n.data),l=await Zn(o);let c,d;try{({uploadId:c,maxChunkBytes:d}=await a.beginAttachmentUpload(e,t,o.byteLength,l,{mimeType:n.mimeType,...s}))}catch(m){if(r!==void 0&&dn(m)){const y=await Le(e,r,a.getAttachmentInfo);if(y)return y}throw m}const u=Math.min(pn,d),h=Math.ceil(o.byteLength/u);let p=!1;try{for(let m=0;m<h;m++){const y=o.subarray(m*u,(m+1)*u);await a.sendAttachmentUploadChunk(c,m,Xn(y),e)}return p=!0,await a.commitAttachmentUpload(c,e)}catch(m){const y=p?await i(m):void 0;if(y)return y;throw await a.abortAttachmentUpload(c,e).catch(()=>{}),m}}function ea(e,t){return fn(e,`image-${Date.now()}-${t+1}`)}class Ae extends Error{constructor(n,a){super(n);Pe(this,"retryBlocks");this.name="ImagePlacementError",this.retryBlocks=a}}function ta(e,t){return e instanceof Ae?e.retryBlocks:t}async function na(e,t,n=lt,a=()=>!0){const r=l=>(...c)=>(le(a),l(...c));n={placeAttachment:r(n.placeAttachment),beginAttachmentUpload:r(n.beginAttachmentUpload),sendAttachmentUploadChunk:r(n.sendAttachmentUploadChunk),commitAttachmentUpload:r(n.commitAttachmentUpload),abortAttachmentUpload:r(n.abortAttachmentUpload),getAttachmentInfo:r(n.getAttachmentInfo),mintIdempotencyKey:r(n.mintIdempotencyKey)};const s=[],i=[],o=[];for(let l=0;l<t.length;l++){le(a);const c=t[l];if("attachmentId"in c&&c.attachmentId){const p={type:"image",attachmentId:c.attachmentId,...c.mimeType?{mimeType:c.mimeType}:{}};s.push(p),i.push(p);continue}const d=c,u=d.placementFileName??ea(d.mimeType,l),h=n.mintIdempotencyKey(d.placementIdempotencyKey);try{const p=await Me(e,u,{data:d.data,mimeType:d.mimeType,...h!==void 0?{idempotencyKey:h}:{}},n),m={type:"image",attachmentId:p.attachmentId,...p.mimeType??d.mimeType?{mimeType:p.mimeType??d.mimeType}:{}};s.push(m),i.push(m)}catch(p){const m=un(p);o.push(m?`${u} (${m})`:u),i.push(h!==void 0?{...d,placementIdempotencyKey:h,placementFileName:u}:d)}}if(o.length>0)throw new Ae(b.chat_imagePlacement_failed_error({names:o.join(", ")}),i);return le(a),s}const Wr=Object.freeze(Object.defineProperty({__proto__:null,ImagePlacementError:Ae,base64DecodedBytes:ct,imageRetryBlocks:ta,placeImageAttachment:Me,toImageReferenceBlocks:na},Symbol.toStringTag,{value:"Module"}));function dt(){try{return yn()}catch{return null}}function aa(){return{backendId:A.state.connections.windowBackendId??null,generation:A.state.daemonHealth.connectionGeneration,transport:dt()}}class Ie extends Error{constructor(){super("dock-evidence-backend-changed")}}function N(e,t){return async(...n)=>{e();const a=await t(...n);return e(),a}}const F={current:e=>dt()===e.transport&&A.state.daemonHealth.connectionGeneration===e.generation&&(A.state.connections.windowBackendId??null)===e.backendId,capabilities:()=>wn(),placeImage:(e,t,n,a)=>Me(e,t,n,{placeAttachment:N(a,it),beginAttachmentUpload:N(a,st),sendAttachmentUploadChunk:N(a,rt),commitAttachmentUpload:N(a,at),abortAttachmentUpload:N(a,nt),getAttachmentInfo:N(a,he),mintIdempotencyKey:se}),lookup:(e,t)=>he({workspaceId:e,idempotencyKey:t}),mintKey:se};function J(e){return F.current(e)}function ra(e,t){const n=A.state.dockConversation;return{generation:n.generation,authority:n.authority,clearRevision:R(n.drafts,Vt(e,t))?.clearRevision??0,binding:aa()}}function jr(e,t,n){const a=ra(e,t);return a.generation===n.generation&&a.authority===n.authority&&a.clearRevision===n.clearRevision&&J(n.binding)}function ut(e,t){return()=>{if(!e.current(t))throw new Ie}}const mt=Object.freeze({rawRetention:!1,chiefAttachments:!1});function qr(e){return e!==mt}const de=new Map;function pt(e,t=F){const n=`${e.backendId}:${e.generation}`;let a=de.get(n);if(!a){const r=ut(t,e);a=(async()=>{r();const i=await t.capabilities();r();const o=i?.server?.capabilities;if(!o||typeof o!="object")throw new Error("unobserved");return{rawRetention:o.rawScreenshotRetention===1,chiefAttachments:o.chiefAttachments===1}})().catch(()=>(de.delete(n),mt)),de.set(n,a)}return a}class ee extends Error{constructor(t){super(`dock-raw-retention-contract:${t}`),this.reason=t}}function ft(e){const{rpcCode:t,code:n}=e??{};return t===-32602||n==="INVALID_PARAMS"}function sa(e){const t=String(e?.message??"");return ft(e)&&(t.includes("rawScreenshotExpired:")||/expired at .*not renewable/i.test(t))}function ia(e,t,n){const a=e.rawScreenshot;if(!a||a.compositeAttachmentId!==t)return null;const r=Date.parse(a.expiresAt);return Number.isFinite(r)?a.expired||r<=n?"expired":{attachmentId:e.attachmentId,expiresAt:a.expiresAt}:null}function Ke(e){return{ok:!0,path:e.path,fileName:e.fileName,size:e.size,attachmentId:e.attachmentId,...e.mimeType?{mimeType:e.mimeType}:{},uploadedAt:e.uploadedAt,replayed:!0,...e.rawScreenshot?{rawScreenshot:e.rawScreenshot}:{}}}class oa extends Error{constructor(t,n){super("dock-evidence-placement-failed"),this.imageId=t,this.failure=n}}const We=e=>e.split("/")[1]?.replace("jpeg","jpg")||"png";async function ca(e){const t=e.api??F,n=e.now??Date.now,a=ut(t,e.binding);a();const r=await pt(e.binding,t);a();const s=r.rawRetention&&(e.workspaceId!==be||r.chiefAttachments),i=[];for(const o of e.images){const l=e.records[o.image.id];let c=l&&l.signature===o.signature&&l.workspaceId===e.workspaceId&&l.backendId===e.binding.backendId?l:{imageId:o.image.id,signature:o.signature,workspaceId:e.workspaceId,backendId:e.binding.backendId,compositeKey:null,rawKey:null,composite:null,raw:null,rawSettled:!1};const d=u=>{c=u,e.onRecord(u)};try{if(!c.composite){const h=c.compositeKey,p=t.mintKey(h??void 0)??null;p!==c.compositeKey&&d({...c,compositeKey:p});let m;h&&p===h&&(a(),m=await t.lookup(e.workspaceId,p).then(Ke).catch(()=>{}),a()),m||(a(),m=await t.placeImage(e.workspaceId,`screenshot-${o.image.id.slice(0,8)}.${We(o.composite.mimeType)}`,{data:o.composite.base64,mimeType:o.composite.mimeType,...p?{idempotencyKey:p}:{}},a),a()),d({...c,composite:{attachmentId:m.attachmentId,mimeType:m.mimeType??o.composite.mimeType}})}const u=c.composite.attachmentId;if(s&&o.raw&&!c.raw&&!c.rawSettled){const h=c.rawKey,p=t.mintKey(h??void 0);if(p){p!==c.rawKey&&d({...c,rawKey:p});let m;h&&p===h&&(a(),m=await t.lookup(e.workspaceId,p).then(Ke).catch(()=>{}),a());try{m||(a(),m=await t.placeImage(e.workspaceId,`screenshot-${o.image.id.slice(0,8)}-original.${We(o.raw.mimeType)}`,{data:o.raw.base64,mimeType:o.raw.mimeType,idempotencyKey:p,rawScreenshot:{compositeAttachmentId:u}},a),a());const y=ia(m,u,n());if(y==="expired")d({...c,rawSettled:!0});else if(y)d({...c,raw:y});else throw new ee("echo")}catch(y){if(sa(y))d({...c,rawSettled:!0});else throw y instanceof ee?y:ft(y)?new ee("refused"):y}}else throw new ee("unkeyed")}}catch(u){throw u instanceof Ie?u:new oa(o.image.id,u)}i.push(c)}return i}async function Vr(e,t,n,a){const r=()=>{if(!F.current(a))throw new Ie};r();const s=await F.placeImage(e,t,{...n,idempotencyKey:F.mintKey()},r);return r(),s}const la=new Set(["invalid-saved-edit","media-send-retired","transcript-unavailable","transcript-pending","invalid-edit","stale-source","legacy-baked-marks","timing-unavailable","audio-unavailable","media-source-unavailable","media-export-unavailable","media-animation-layer-limit","media-export-failed","legacy-original-unavailable","capture-render-unavailable","capture-blur-unavailable","stale-source-pixels","not-a-screenshot","not-admitted","unavailable","dock-evidence-missing-pixels","draft-restore-failed","image-budget-exceeded"]),da=new Set(["unavailable","permission","failed","busy","cancelled","limit"]);class O extends Error{constructor(t,n){super(n),this.stage=t,this.code=n,this.name="DockSendError"}}function ie(e){const t=e instanceof Error?e.message:typeof e=="string"?e:"";if(t.length>64)return"unclassified";const[n,...a]=t.split(":");return!la.has(n)||a.length>2?"unclassified":n!=="media-export-failed"?a.length?"unclassified":n:[n,...a.map(r=>da.has(r)?r:"other")].join(":")}function zr(e,t){return e instanceof O?{stage:e.stage,code:ie(e.code)}:{stage:t,code:ie(e)}}function K(e){if(!e||e.source.kind!=="recording")return!1;const t=e.source,n=e.saved??re(t,t.capturedMarks??[],e.transcript);if(n.video!=="full"||n.voice!=="audio"||n.crop||n.blurRegions.length||n.blurStrokes?.length)return!1;const a=ve(n,t,e.transcript);return t.visuals==="clean"?!a.errors.length&&!a.muted&&n.cuts.length===0&&!n.marks.some(r=>r.included)&&a.marks.length===0&&a.transcript===null&&a.kept.length===1&&a.kept[0].startMs===0&&a.kept[0].endMs===t.durationMs&&a.clips.length===1&&a.clips[0].startMs===0&&a.clips[0].endMs===t.durationMs:!a.errors.length&&!a.muted&&a.clips.length===1&&a.clips[0].startMs===0&&a.clips[0].endMs>=t.durationMs}async function ua(e,t,n,a,r,s){const i={images:{},files:[],frames:[],framePromptBytes:[],metadata:[]};let o="validate";try{const l=()=>{if(!r()||!J(n))throw new Error("media-send-retired")};for(const c of[...t.images,...t.clips]){if(o="validate",s?.stage(o),c.mediaError)throw new Error("invalid-saved-edit");if(!c.media||K(c.media))continue;l();const d=structuredClone(c.media),u=d.source;let h=d.saved??re(u,u.capturedMarks??[],d.transcript),p=crypto.randomUUID();try{if(u.kind==="recording"&&h.voice==="transcript"&&d.transcript?.status!=="ready"){if(o="transcribe",s?.stage(o),!a?.transcribeMedia)throw new Error("transcript-unavailable");const f=await a.transcribeMedia({jobId:p,media:d});if(l(),!f.ok)throw new Error("transcript-unavailable");d.transcript=f.value,d.saved||(h=re(u,u.capturedMarks??[],d.transcript))}o="plan",s?.stage(o);const m=ve(h,u,d.transcript);if(m.errors.length)throw new Error(m.errors[0]);const y={id:c.id,kind:u.kind,video:h.video,voice:h.voice,transcript:m.transcript,batches:u.batches,marks:m.marks.map(({n:f,mark:k,frameAtMs:v})=>({n:f,id:k.id,at_ms:v,kind:k.kind,label:k.label,note:k.note,context:k.context,geometry:k.geometry}))};if(u.kind==="screenshot"){o="screenshot-source",s?.stage(o);const f=u.path.split("/").map(encodeURIComponent).join("/"),k=tt(`intent://local/file/${f}`,e);if(!k||k.kind!=="image")throw new Error("media-source-unavailable");const v=await zn(k.url);l();const I={base64:Ze(v.buffer.slice(v.byteOffset,v.byteOffset+v.byteLength)),mimeType:/\.jpe?g$/i.test(u.path)?"image/jpeg":/\.webp$/i.test(u.path)?"image/webp":"image/png"};o="screenshot-render",s?.stage(o),i.images[c.id]=await tn(u,h,I),l()}else{if(!m.clips.length){y.video_attachment_id=null,y.frames=[],y.kept_ms=[],i.metadata.push(y);continue}const f={...d,saved:h};let k=await a?.takePreparedRecording?.(f);if(k&&(p=k.jobId),l(),!k){if(!a)throw new Error("media-export-unavailable");k=await ot(f,p,a,()=>r()&&J(n),S=>{o=S,s?.stage(S),S==="export"&&s?.exportAttempt(p)})}p=k.jobId,o="placement",s?.stage(o);const v=[k.value.video,...k.value.frames],I=[];for(let S=0;S<v.length;S++){l();const _=v[S],B=`capture-${c.id.slice(0,12)}-${S}.${S===0?"mp4":_.mimeType==="image/jpeg"?"jpg":"png"}`,E=await hn(e,B,{sourcePath:_.sourcePath,mimeType:_.mimeType,idempotencyKey:se()},void 0,void 0,()=>r()&&J(n));l(),S===0?i.files.push({type:"file",attachmentId:E.attachmentId,fileName:B,mimeType:E.mimeType??_.mimeType,size:E.size}):(i.frames.push({type:"image",attachmentId:E.attachmentId,mimeType:_.mimeType==="image/jpeg"?"image/jpeg":"image/png"}),i.framePromptBytes.push(Wn(_))),I.push(E.attachmentId)}y.video_attachment_id=I[0],y.frames=k.value.frames.map((S,_)=>({mark_id:S.markId,attachment_id:I[_+1]})),y.kept_ms=m.clips}i.metadata.push(y)}finally{s?.stage("release"),await a?.releaseMediaJob?.(p).catch(()=>{})}}return i}catch(l){throw l instanceof O?l:new O(o,ie(l))}}const ue=1568,ma=.85;async function pa(e,t){const n=Math.round(e.length*3/4/1024),a=await fa(e,t),{width:r,height:s}=a,i=r>ue||s>ue;let o=r,l=s;if(i){const f=ue/Math.max(r,s);o=Math.round(r*f),l=Math.round(s*f)}const c=new OffscreenCanvas(o,l),d=c.getContext("2d");if(!d)throw new Error("Failed to get 2D canvas context for image resize");d.drawImage(a,0,0,o,l);let u=t;ha(d,o,l)||(u="image/jpeg");const h=await c.convertToBlob({type:u,quality:u==="image/jpeg"?ma:void 0}),p=h.type||u,m=await ga(h),y=Math.round(m.length*3/4/1024);return console.debug(`[image-resize] ${r}×${s} → ${o}×${l} | ${t} → ${p} | ${n} KB → ${y} KB`),{base64:m,mimeType:p}}async function fa(e,t){const n=atob(e),a=new Uint8Array(n.length);for(let s=0;s<n.length;s++)a[s]=n.charCodeAt(s);const r=new Blob([a],{type:t});return createImageBitmap(r)}function ha(e,t,n){const r=e.getImageData(0,0,t,n).data;for(let s=3;s<r.length;s+=4)if(r[s]<255)return!0;return!1}async function ga(e){const t=await e.arrayBuffer(),n=new Uint8Array(t);let a="";for(let r=0;r<n.length;r++)a+=String.fromCharCode(n[r]);return btoa(a)}const T={...Oe,badge:Oe.badgeRadius*2};function ya(e,t,n=1,a=0){const r=Math.max(1,e.displayScale)*n,s=[],i=o=>o*n;for(const{n:o,mark:l}of t){const c=l.geometry;if(c.kind==="rect")s.push({kind:"rect",x:i(c.x),y:i(c.y),w:i(c.w),h:i(c.h),width:T.stroke*r});else if(c.kind==="path")s.push({kind:"path",points:c.points.map(m=>({x:i(m.x),y:i(m.y)})),width:T.pen*r});else{const m={x:i(c.from.x),y:i(c.from.y)},y={x:i(c.to.x),y:i(c.to.y)};s.push({kind:"arrow",from:m,to:y,head:_a(m,y,T.arrowHead*r),width:T.stroke*r})}if(!T.showNumbers)continue;const d=Math.max(a,T.badge/2*r),u=i(l.bounds.x+l.bounds.w),h=i(l.bounds.y),p=Zt({x:i(l.bounds.x),y:h,w:u-i(l.bounds.x),h:i(l.bounds.h)},{x:0,y:0,w:i(e.width),h:i(e.height)},r,d);s.push({kind:"badge",...p,radius:d,label:String(o),font:d*T.badgeTextScale})}return s}function wa(e,t){"letterSpacing"in e&&(e.letterSpacing="0px"),"wordSpacing"in e&&(e.wordSpacing="0px");const n=(a,r,s)=>{e.strokeStyle=T.halo,e.lineWidth=a+T.haloWidth*r,s(),e.strokeStyle=T.accent,e.lineWidth=a,s()};e.strokeStyle=T.accent,e.lineCap="round",e.lineJoin="round";for(const a of t)if(a.kind==="rect")n(a.width,a.width/T.stroke,()=>e.strokeRect(a.x,a.y,a.w,a.h));else if(a.kind==="path"||a.kind==="arrow"){e.lineWidth=a.width,e.beginPath();const r=a.kind==="path"?a.points:[a.from,a.to];a.kind==="arrow"&&r.forEach((i,o)=>o?e.lineTo(i.x,i.y):e.moveTo(i.x,i.y)),a.kind==="arrow"&&(e.moveTo(a.head.left.x,a.head.left.y),e.lineTo(a.to.x,a.to.y),e.lineTo(a.head.right.x,a.head.right.y));const s=a.kind==="path"?new Path2D(Xt(a.points)):null;n(a.width,a.width/(a.kind==="path"?T.pen:T.stroke),()=>s?e.stroke(s):e.stroke())}else e.fillStyle=T.paper,e.beginPath(),e.arc(a.x,a.y,a.radius,0,Math.PI*2),e.closePath(),e.fill(),e.strokeStyle=T.accent,e.lineWidth=T.badgeOutline*a.radius/T.badgeRadius,e.stroke(),e.fillStyle=T.ink,e.font=`600 ${a.font}px ${T.badgeFontFamily}`,e.textAlign="center",e.textBaseline="middle",e.fillText(a.label,a.x,a.y)}async function ba(e,t){const n=Uint8Array.from(atob(e),a=>a.charCodeAt(0));return createImageBitmap(new Blob([n],{type:t}))}async function ka(e){const t=await e.convertToBlob({type:"image/png"});return Ze(await t.arrayBuffer())}async function ht(e,t,n,a,r=0){await nn();const s=await ba(e.base64,e.mimeType);try{const i=Math.min(1,a/Math.max(t.width,t.height)),o=new OffscreenCanvas(Math.max(1,Math.round(t.width*i)),Math.max(1,Math.round(t.height*i))),l=o.getContext("2d");if(!l)throw new Error("dock-evidence-canvas-unavailable");return l.drawImage(s,0,0,o.width,o.height),wa(l,ya(t,n,i,r)),o}finally{s.close()}}async function va(e,t,n){const a=await ht(e,t,n,Math.max(t.width,t.height));return pa(await ka(a),"image/png")}async function Gr(e,t,n,a=384){const r=await ht(e,t,n,a,a/32);return URL.createObjectURL(await r.convertToBlob({type:"image/png"}))}function _a(e,t,n=T.arrowHead){const a=Math.atan2(t.y-e.y,t.x-e.x),r=T.arrowSpread;return{left:{x:t.x-n*Math.cos(a-r),y:t.y-n*Math.sin(a-r)},right:{x:t.x-n*Math.cos(a+r),y:t.y-n*Math.sin(a+r)}}}function Jr(e,t){const n=zt(t??void 0),a=new Set(t?.clips.filter(r=>!!r.media&&!K(r.media)).map(r=>r.contextItemId));return e.filter(r=>!n.has(r.id)&&!a.has(r.id))}async function Yr({workspaceId:e,agentId:t,evidence:n,clickedItems:a,sendItems:r,clickedPayload:s,binding:i,service:o,current:l,onRecord:c,timing:d}){const u=()=>{if(!l()||!J(i))throw new O("validate","media-send-retired")};if(u(),n?.images.some(w=>w.mediaError)||n?.clips.some(w=>w.mediaError))throw new O("validate","invalid-saved-edit");const h=w=>!!w.media&&!K(w.media),p=n?{workspaceId:e,agentId:t,appUrl:`intent://local/workspace/${encodeURIComponent(e)}`,clipAttachmentIds:Object.fromEntries(n.clips.map(w=>[w.id,a.find(M=>M.id===w.contextItemId)?.attachmentId??null]))}:null;for(const w of n?.clips??[]){if(!w.media||!K(w.media))continue;const M=a.find(X=>X.id===w.contextItemId);if(!M||M.attachmentId!==w.media.source.attachmentId||M.path!==w.media.source.path||M.placementStatus!==void 0&&M.placementStatus!=="placed")throw new O("validate","legacy-original-unavailable")}const m=n?await ua(e,n,i,o,l,d):{images:{},files:[],frames:[],framePromptBytes:[],metadata:[]},y=new Set(n?.clips.filter(w=>h(w)||!!w.media&&K(w.media)).map(w=>w.id)),f=new Set(n?.clips.filter(w=>y.has(w.id)).flatMap(w=>(w.captureHistory??[]).map(M=>M.image.id))),k=(n?.images??[]).filter(w=>w.source!=="annotate"||!!w.media||!f.has(w.id)||n.marks.some(M=>M.imageId===w.id&&!(M.clipId&&y.has(M.clipId))));d?.stage("burn");let v=[];try{v=n?await Sa({...n,images:k},a,m.images):[]}catch(w){throw new O("burn",ie(w))}if(m.framePromptBytes.reduce((w,M)=>w+(M??0),0)>Hn)throw new O("validate","image-budget-exceeded");const S=new Set(n?.images.filter(w=>w.media).map(w=>w.id)),_=n?{...n,images:k.map(w=>m.images[w.id]?{...w,width:m.images[w.id].width,height:m.images[w.id].height}:w),clips:n.clips.filter(w=>!h(w)),marks:n.marks.filter(w=>!S.has(w.imageId)&&!n.clips.some(M=>h(M)&&M.id===w.clipId))}:null;u();const B=m.metadata.some(w=>typeof w.transcript=="string"&&w.transcript.trim());if(!s.text.trim()&&!r.length&&!s.workspaceContextStr?.trim()&&!v.length&&!m.files.length&&!m.frames.length&&!s.imageBlocks?.length&&!s.fileBlocks?.length&&!B)return null;let E=v,P=null;d?.stage("placement");const xe=n?await pt(i):null;if(u(),n&&(e!==be||xe?.chiefAttachments)){const w=await ca({workspaceId:e,binding:i,images:k.map((M,X)=>{const Z=a.find(Ct=>Ct.id===M.contextItemId);return{image:M,signature:Gt(n,M.id),composite:{base64:v[X].data,mimeType:v[X].mimeType},raw:!M.media&&Z?.imageData&&Z.imageMimeType?{base64:Z.imageData,mimeType:Z.imageMimeType}:null}}),records:n?.placements??{},onRecord:c});u(),E=w.map(M=>({type:"image",attachmentId:M.composite.attachmentId,mimeType:M.composite.mimeType})),P=Object.fromEntries(w.map(M=>[M.imageId,{attachmentId:M.composite.attachmentId,raw:M.raw}]))}const g=new Map(n?Xe(n).map(({n:w,mark:M})=>[M.id,w]):[]),D=p&&P?{...p,imageAttachments:P,markNumbers:g}:p&&{...p,markNumbers:g},$=n&&D?{...s,imageBlocks:[...E,...m.frames,...s.imageBlocks??[]],fileBlocks:[...s.fileBlocks??[],...m.files],workspaceContextStr:[Yt(_,D),m.metadata.length?`[Edited capture outputs]
3
3
  ${JSON.stringify(m.metadata)}`:"",s.workspaceContextStr].filter(Boolean).join(`
4
4
 
5
5
  `),messageMetadata:{...s.messageMetadata,...Jt(_,D),edited_captures:m.metadata}}:s;return u(),$}async function Sa(e,t,n={}){const a=Xe(e);return Promise.all(e.images.map(async r=>{if(n[r.id])return{type:"image",...n[r.id]};const s=t.find(o=>o.id===r.contextItemId);if(!s?.imageData||!s.imageMimeType)throw new Error("dock-evidence-missing-pixels");const i=await va({base64:s.imageData,mimeType:s.imageMimeType},r,a.filter(({mark:o})=>o.imageId===r.id));return{type:"image",data:i.base64,mimeType:i.mimeType}}))}function Ma(){return et()}function Qr(e){const{clip:t}=e;if(t.status!=="ready"||!t.path)return null;const n=e.marks.filter(s=>s.clipId===t.id&&typeof s.clipMs=="number").sort((s,i)=>s.clipMs-i.clipMs).map(s=>({id:s.id,tool:s.tool,atMs:s.clipMs,...s.element?.name?{label:s.element.name.slice(0,200)}:{}})),a=Qt(e.evidence??void 0,t.id),r=a?t.media:void 0;return{kind:"recording",workspaceId:e.workspaceId,agentId:e.agentId,attachmentId:a?.attachmentId??t.id,sourceRevision:a?`${a.id}:${a.revision}`:t.path,attachmentPath:t.path,title:"",durationMs:t.durationMs,marks:n,provenance:a?{...a.audio==="unknown"?{}:{hasMicAudio:a.audio==="available"},visuals:a.visuals}:{hasMicAudio:t.hasMicAudio,visuals:n.length>0?"baked-marks":"clean"},...a&&r?{source:a,saved:r.saved??null,transcript:r.transcript??null}:{}}}async function Xr(e){if(!Ma())return{ok:!1,error:"unavailable"};try{return await rn().invoke(an.OPEN,e)??{ok:!1,error:"unavailable"}}catch{return{ok:!1,error:"transport"}}}function Zr(e){let t=null,n=null;const a=o=>e.releaseMediaJob?.(o).catch(()=>{});function r(){const o=t;t=null,!(!o||o.taken||o.stopped)&&(o.stopped=!0,clearTimeout(o.timer),a(o.id))}function s(o,l,c){if(t?.key===o||n===o||(r(),n=null,!e.adoptMediaJob||!e.exportMedia||!c()||K(l)))return;const d=structuredClone(l),u=d.saved??re(d.source,d.source.capturedMarks??[],d.transcript),h=ve(u,d.source,d.transcript);if(d.source.kind!=="recording"||d.source.visuals!=="clean"||h.errors.length||!h.clips.length||u.voice==="transcript"&&d.transcript?.status!=="ready")return;const p={...d,saved:u},m=crypto.randomUUID(),y={key:o,mediaKey:JSON.stringify(p),id:m,current:c,taken:!1,stopped:!1,settled:!1,failed:!1,timer:setTimeout(()=>{t===y&&(n=o,r())},3e4),result:Promise.resolve({error:new Error("not-started")})};t=y,y.result=ot(p,m,e,()=>!y.stopped&&y.current()).then(async f=>y.stopped||!y.current()?(await a(m),{error:new Error("media-send-retired")}):{value:f},async f=>(y.failed=!0,t===y&&(n=o),await a(m),{error:f})).finally(()=>{y.settled=!0})}async function i(o,l,c){const d=t;if(!d||d.key!==o||d.mediaKey!==JSON.stringify(l)||d.stopped||d.taken||!c())return null;if(d.failed&&d.settled)return r(),null;d.taken=!0,d.current=c,clearTimeout(d.timer),t=null;const u=await d.result;if("error"in u)throw u.error;try{if(!c())throw new Error("media-send-retired");const h=await e.adoptMediaJob?.(d.id);if(!c())throw new Error("media-send-retired");return!h?.ok||!h.value?(await a(d.id),null):u.value}catch(h){throw await a(d.id),h}}return{warm:s,take:i,cancel:r}}function es(e={}){const t=a=>sn(a,typeof e=="function"?e():e),n=a=>bn(t(a));return{actionHints:{get capture(){return{label:b.dock_composer_screenshotAction_label(),shortcut:t("dock.capture")}},get record(){return{label:b.ui_shortcuts_dockRecord_label(),shortcut:t("dock.record")}},get dictate(){return{label:b.dock_shortcut_dictate_label()}}},get capture(){return b.dock_composer_capture_tooltip({shortcut:n("dock.capture")})},captureMode:{get window(){return b.dock_composer_captureWindow_tooltip({shortcut:n("dock.capture")})},get region(){return b.dock_composer_captureRegion_tooltip({shortcut:n("dock.capture")})}},captureModes:{fullscreen:b.dock_composer_captureFullscreen_label(),window:b.dock_composer_captureWindow_label(),region:b.dock_composer_captureRegion_label()},captureOptions:b.dock_composer_captureModes_ariaLabel(),captureLimit:b.dock_composer_captureLimit_tooltip(),clipLimit:b.dock_composer_clipLimit_tooltip({limit:V(ae.clips)}),get record(){return b.dock_composer_record_tooltip({shortcut:n("dock.record")})},stopRecording:b.dock_composer_stopRecording_tooltip(),annotationTools:b.annotation_toolbar_ariaLabel(),annotateCurrent:a=>b.dock_composer_annotate_ariaLabel({tool:a}),tools:{pick:b.dock_composer_pick_label(),box:b.dock_composer_box_label(),pen:b.dock_composer_pen_label(),arrow:b.annotation_arrow_label()},get dictate(){return b.dock_shortcut_dictate_label()},stopDictating:b.dock_composer_stopDictating_tooltip(),annotating:b.dock_composer_annotating_status(),recording:b.dock_composer_recording_status(),markUp:b.dock_composer_markUp_label(),remove:b.chat_contextChip_remove_label(),play:b.dock_composer_play_label(),edit:b.dock_composer_edit_label(),done:b.dock_composer_done_label(),attachments:b.context_attachments_title_label(),retry:b.chat_shared_retry_label(),attachmentPending:b.dock_composer_attachmentPending_status(),attachmentFailed:b.dock_composer_attachmentFailed_error(),image:a=>b.dock_composer_image_ariaLabel({n:V(a)}),clip:a=>b.dock_composer_clip_ariaLabel({duration:a}),recordingReference:(a,r)=>r?b.dock_composer_recordingEnd_chip({n:V(a)}):b.dock_composer_recordingStart_chip({n:V(a)}),speechError:a=>a.includes("permission")?b.dock_composer_speechPermission_error():["unsupported-platform","helper-missing","recognizer-unavailable","locale-unsupported","assets-unavailable","unavailable"].includes(a)?b.dock_composer_speechUnavailable_error():b.dock_composer_speechFailed_error()}}function ts(e,t){return{enabled:e,limit:ae.files,excludedIds:t,unavailableMessage:b.dock_composer_filesUnavailable_error(),limitMessage:b.dock_composer_fileLimit_error({limit:V(ae.files)})}}function Aa(e){try{return new URL(e.pageUrl).hostname||e.pageUrl}catch{return e.pageUrl}}function ns(e,t){return e.targetAgentId===t}function as(e){const t=e.element,n=e.viewport,a=Aa(e),r=t?`<${t.tagName.toLowerCase()}> · ${a}`:e.title||a,s=["<browser-element-capture>",`Page URL: ${e.pageUrl}`,`Page title: ${e.title}`,...t?[`DOM path: ${t.domPath}`,`CSS selector: ${t.selector}`,`Text snippet: ${t.textSnippet}`,...t.sourceRef?[`Source ref: ${t.sourceRef}`]:[],...n?[`Viewport: ${n.width}×${n.height}`]:[],`Element bounds: ${t.rect.width}×${t.rect.height} at (${t.rect.x}, ${t.rect.y})`]:[],"</browser-element-capture>"].join(`
@@ -8,5 +8,5 @@ ${JSON.stringify(m.metadata)}`:"",s.workspaceContextStr].filter(Boolean).join(`
8
8
  \`\`\`
9
9
  ${i}
10
10
  \`\`\`]`)}return Ia(a.join(`
11
- `),e)}function rs(e,t,n){if(e==="suggested-prompt")return{fields:{},hasAttachments:!1,cleanup:{clearInput:!1,followBottom:!0,historyText:null}};const a=n(),{imageBlocks:r,fileBlocks:s}=Ta(a.contextItems);return{fields:{contextItems:a.contextItems,workspaceContextStr:Ca(a.contextItems,a.checkedPanels,a.checkedSelections),noteIds:a.noteIds,...r.length>0?{imageBlocks:r}:{},...s.length>0?{fileBlocks:s}:{},...a.pickedMentions?{messageMetadata:a.pickedMentions}:{}},hasAttachments:r.length>0||s.length>0,cleanup:{clearInput:!0,followBottom:!0,historyText:t}}}const Ea="chat-read:",W=new Map,ye=new Set;function ss(e,t){let n=W.get(e);n||(n=new Set,W.set(e,n)),n.add(t)}function is(e,t){const n=W.get(e);if(!(!n||!n.delete(t))&&n.size===0){W.delete(e);for(const a of[...ye])a(e)}}function os(e){return ye.add(e),()=>ye.delete(e)}function cs(e){return W.has(e)}function ls(e){const t=W.get(e);if(!t)return!1;for(const n of t)if(!n.startsWith(Ea))return!0;return!1}function Da(e,t,n){const a=e.state.pendingSubmissions.byAgentId[t.agentId];if(!a||!Ge(a.scope,t))return null;const r={...structuredClone(n),id:crypto.randomUUID(),createdAt:Date.now()};e.dispatch(xt(t,r));const s=e.state.pendingSubmissions.byAgentId[t.agentId];return s&&R(s.submissions,r.id)?r:null}function Ra(e,t,n,a,r){const s=Be.select(e.state,n),i=pe.select(e.state)?.principal.id,o=Ue(e.state);if(!s||!i||!o)return null;const l=An(t,n),c={agentId:t,workspaceId:n,principalId:i,participation:s,authority:o,owner:l.key,lifetime:e.state.pendingSubmissions.byAgentId[t]?.scope.lifetime??crypto.randomUUID()},d=()=>l.isCurrent(e.state.agentSessions?.byAgentId[t]?.workspaceId)&&Be.select(e.state,n)===s&&pe.select(e.state)?.principal.id===i&&Ue(e.state)===o;if(!d())return null;e.dispatch(Rt(c,a,Ft.select(e.state,n)));const u=Da(e,c,r);return u?{scope:c,submission:u,isCurrent:()=>{const h=e.state.pendingSubmissions.byAgentId[t];return d()&&!!h&&Ge(h.scope,c)&&(!!R(h.operations,u.id)||!!R(h.submissions,u.id))}}:null}function we(e,t,n){if(!n.text.trim()&&!n.imageBlocks?.length&&!n.fileBlocks?.length)return null;const a=n.userAppMessageId??In();return Ra(e,t,n.wsId,pe.select(e.state)?.capabilities.submissionCorrelation,{content:n.text.trim(),appMessageId:a,destination:!n.forceSubmit&&Kt.select(e.state,t)?"queue":"conversation",contextItems:n.contextItems,imageBlocks:n.imageBlocks,fileBlocks:n.fileBlocks,messageMetadata:n.messageMetadata})}function xa(e,t,n){const a=we(e,t,n);return a?(e.dispatch(Je(t,{...n,userAppMessageId:a.submission.appMessageId,submission:{scope:a.scope,id:a.submission.id}})),!0):!1}async function Pa(e,t,n,a){const r=n.submission;if(!r)return"legacy";const s=r.reference,i=()=>s.scope.agentId===e&&s.scope.workspaceId===t&&Qe.select(A.state,e)===n?gn.select(A.state,s.scope):void 0,o=i();if(!o)return null;if(!o.supported)return"legacy";const l={wsId:t,text:n.text,imageBlocks:n.options?.imageBlocks,fileBlocks:n.options?.fileBlocks,noteIds:n.options?.noteIds,messageMetadata:n.options?.messageMetadata,model:a??n.options?.model};if(r.outcome==="rejected"){const p=R(o.tombstones,s.id);return R(o.submissions,s.id)||p&&p.reason!=="rejected"?null:we(A,e,l)}if(r.outcome==="accepted")return we(A,e,l);await Promise.all([Tn(e,t).catch(()=>{}),Cn(e,t).catch(()=>{})]);const c=i();if(!c||R(c.submissions,s.id)?.status!=="uncertain")return null;const{notify:d}=await fe(async()=>{const{notify:p}=await import("./D82C3bhe.js").then(m=>m.u);return{notify:p}},__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]),import.meta.url);if(i()!==c)return null;let u=!1;const h=()=>{u=!0};return d.warning(b.agent_chatSend_uncertainRetry_description(),{key:`submission-retry:${t}:${e}:${s.id}`,duration:Number.POSITIVE_INFINITY,action:{label:b.agent_chatSend_resend_label(),onClick:()=>{if(u)return;u=!0;const p=i();!p||p.generation!==c.generation||p.submissions!==c.submissions||p.observationVersion!==c.observationVersion||R(p.submissions,s.id)?.status!=="uncertain"||xa(A,e,l)}},cancel:{label:b.chat_richInput_cancel_label(),onClick:h},onDismiss:h}),null}async function ds(e,t,n){const a=Qe.select(A.state,e),r=a?.submission?await Pa(e,t,a,n):"legacy";if(r){if(r==="legacy"){await A.dispatch(n===void 0?Pt(e,t):Bt(e,t,n));return}!r.isCurrent()||!a||A.dispatch(Je(e,{wsId:t,text:a.text,imageBlocks:a.options?.imageBlocks,fileBlocks:a.options?.fileBlocks,noteIds:a.options?.noteIds,messageMetadata:a.options?.messageMetadata,model:n??a.options?.model,userAppMessageId:r.submission.appMessageId,submission:{scope:r.scope,id:r.submission.id}}))}}const us=A.createSelector((e,t)=>{const n=R(e.chatDrafts.owners,t);return n?{restore:n.restore,saves:Ye(n.saves),shared:n.restore?e.chatDrafts.shared[JSON.stringify([n.restore.workspaceId,n.restore.agentId])]:void 0}:void 0});function Ba(e,t){return t.workspaceId===e&&!t.retiredAt&&!t.pendingDeleteAt&&t.status!==ke.Deleted&&!t.notificationsMuted&&Lt(t)==="topLevel"}function Oa(e){const t=e.metadata?.pendingQuestionsMessageId;return typeof t=="string"&&t.length>0&&!Rn(e.metadata,t)?t:null}function La(e){return e.status===ke.Error&&!Wt(jt(e))}function ms(e,t){return t.filter(n=>Ba(e,n)).flatMap(n=>{const a=Ot(n),r=Oa(n),s=n.status===ke.Error;if(!a&&!r&&!s)return[];const i=a?.timestamp??(s?n.stopReasonTimestamp:void 0);return[{agentId:n.id,agentName:n.name,kind:a?.kind??(s?"failed":"question"),reason:a?.reason,timestamp:i&&Number.isFinite(Date.parse(i))?i:void 0,questionMessageId:r,canRetry:La(n)}]})}function ps(e){return e.displayStatus==="failed"?"failed":e.displayStatus==="blocked"?"blocked":e.attention==="review_required"?"review":e.displayStatus==="needs_attention"?"question":e.activity==="agent_running"||e.displayStatus==="in_progress"?"running":e.scriptsRunning===!0?"scripts_running":e.backgroundTasksRunning===!0?"background_tasks_running":e.displayStatus==="pr_ready"?"pr_ready":e.displayStatus==="pr_merged"?"merged":e.displayStatus==="complete"?"complete":e.attention==="unread"?"unread":e.displayStatus==="pr_open"||e.displayStatus==="pr_queued"?e.displayStatus:"idle"}function fs(e){const t=e.kind==="prs"?e.organization?.trim().toLowerCase():void 0;return{key:JSON.stringify([e.kind,e.workspaceId,t||null,[...new Set((t?[]:e.repositories).map(n=>JSON.stringify([n.key,n.owner,n.name])))].sort()]),hasGitHubRepositories:!!t||e.repositories.some(n=>!!n.owner),hasLocalRepositories:!t&&e.repositories.some(n=>!n.owner)}}function Te(e){const t=kn(e);if(t?.kind!=="pr"||!Number.isSafeInteger(t.number)||t.number<=0)return null;const n=t.owner.toLowerCase(),a=t.repo.toLowerCase();return{owner:n,repo:a,number:t.number,id:`${n}/${a}#${t.number}`,url:`https://github.com/${n}/${a}/pull/${t.number}`}}function hs(e,t,n,a){const r=e.filter(s=>a?a.includes(s.id):n?s.repositoryOwner?.toLowerCase()===n.toLowerCase():t.some(i=>i.owner?.toLowerCase()===s.repositoryOwner?.toLowerCase()&&i.name.toLowerCase()===s.repositoryName?.toLowerCase()));return[...new Map(r.flatMap(s=>[...(s.pullRequests??[]).map(i=>i.url),s.activePullRequest?.url,s.prUrl]).flatMap(s=>{const i=s?Te(s):null;return i?[[i.id,{owner:i.owner,repo:i.repo,number:i.number}]]:[]})).values()].sort((s,i)=>`${s.owner}/${s.repo}#${s.number}`.localeCompare(`${i.owner}/${i.repo}#${i.number}`))}function gs(e,t){const[n]=t;return t.length!==1||e.owner?.toLowerCase()!==n?.owner?.toLowerCase()||e.repo?.toLowerCase()!==n?.name.toLowerCase()}const ys=A.createSelector(e=>e.homeIntegrations),ws=A.createSelector(e=>{const t=e.homeIntegrations;return!t.linkedItems||!Object.keys(t.linkedItems).length?t:{...t,items:[...new Map([...Object.values(t.linkedItems),...t.items].map(n=>[n.id,n])).values()].sort((n,a)=>(a.updatedAt??"").localeCompare(n.updatedAt??""))}}),gt=A.createSelector(e=>Ye(e.workspace.workspaces).flatMap(t=>[...(t.pullRequests??[]).map(n=>n.url),t.activePullRequest?.url,t.prUrl].filter(n=>!!n).map(n=>({url:Te(n)?.url??n.replace(/\/$/,"").toLowerCase(),workspaceId:t.id,name:t.title||t.id})))),bs=A.createSelector(e=>{const t=e.homeIntegrations.detail?.url,n=t?Te(t)?.url??t.replace(/\/$/,"").toLowerCase():void 0;return gt.select(e).find(a=>a.url===n)??null}),ks=A.createSelector(e=>gt.select(e).map(t=>t.url));let te=null;function vs(e){return te=e,()=>{te===e&&(te=null)}}function _s(){return te}function Ss(e){return[...e.groups.length>0?e.groups.filter(n=>n.expanded).flatMap(n=>n.items):e.workspaces,...e.asideExpanded?e.aside:[]].map(n=>n.id)}function Ms(e,t,n){if(e.length===0)return null;const a=t===null?-1:e.indexOf(t);return a===-1?e[0]:e[a+(n==="clockwise"?1:-1)]??null}let H=[];function As(e,t={}){const n={source:e,fallback:t.fallback===!0};return H=[...H,n],()=>{H=H.filter(a=>a!==n)}}function Is(){const e=H.findLast(n=>!n.fallback);return e?e.source:H.findLast(n=>n.fallback&&(n.source.available?.()??!0))?.source??null}function Ts(e){if(!e?.isConnected||e.closest("[inert]"))return!1;const t=e.ownerDocument.querySelectorAll('[aria-modal="true"]');return Array.from(t).every(n=>n.contains(e))}function Cs(e){return Mn(e)}function Ua(e){return Sn(e)}function $a(e,t){return!e||!t?!1:e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}function me(e){if(e.length===0)return[];const t=[];let n=null;for(const a of e){const r=a.timestamp?typeof a.timestamp=="string"?new Date(a.timestamp):a.timestamp:new Date;(!n||!$a(n.date,r))&&(n={date:r,label:Ua(r),messages:[]},t.push(n)),n.messages.push(a)}return t}function Es(e){const t=new Map;return e.map(({date:n})=>{const a=`${n.getFullYear()}-${n.getMonth()+1}-${n.getDate()}`,r=t.get(a)??0;return t.set(a,r+1),r===0?a:`${a}#${r}`})}function Ds(e,t){const n=new Map;let a=t?null:void 0;for(const r of e.groups)for(const s of r.messages)a!==void 0&&n.set(s.id,a),s.role==="user"&&!Pn(s)&&(a=s);return n}function Na(e){return`${e.getFullYear()}-${e.getMonth()+1}-${e.getDate()}`}function je(e,t){const n=new Map;return e.map(a=>{const r=`${t}-${Na(a.date)}`,s=(n.get(r)??0)+1;return n.set(r,s),{...a,groupKey:s===1?r:`${r}-${s}`}})}function Ha(e,t){if(e.length===0||t.length===0)return e;const n=new Set(t.map(s=>s.id)),a=new Set(t.map(s=>s.appMessageId).filter(s=>typeof s=="string"&&s.length>0)),r=e.filter(s=>!n.has(s.id)&&!(typeof s.appMessageId=="string"&&s.appMessageId.length>0&&a.has(s.appMessageId)));return r.length===e.length?e:r}function Rs(e,t,n){return e=Ha(e,t),e.length===0?{groups:me(t),detached:!1,hiddenTail:[]}:n?{groups:je(me(e),"h"),detached:!0,hiddenTail:t}:{groups:je(me([...e,...t]),"d"),detached:!1,hiddenTail:[]}}function xs(e){const{scrollTop:t,threshold:n,fetching:a,exhausted:r,historyCount:s,tailCount:i,tailTruncated:o,totalMessages:l,spacerAbove:c=0}=e;return t>n+c||a||r?!1:s>0||o||l>i+s}const Ps=300;function Bs(e){const{fetching:t,chainEvaluationPending:n,visible:a,hideArmed:r}=e;return t||n?a&&!r?"none":"show":a&&!r?"arm-hide":"none"}const qe=24,Fa=320;function Ce(e){return Number.isFinite(e)?Math.min(Fa,Math.max(qe,e)):qe}const Ka=.2,Wa=.12;function ja(e,t,n=Ka){const a=Ce(t);return e===null||!Number.isFinite(e)?a:e+n*(a-e)}function Os(e,t){const n=Ce(t??Number.NaN);return{above:Math.round(Math.max(0,e.above)*n),below:Math.round(Math.max(0,e.below)*n)}}function Ls(e){const{totalMessages:t,residentCount:n,exhausted:a,residentContentHeight:r,currentSpacerHeight:s,viewportHeight:i}=e;let o=e.rowHeightEma;n>0&&r>0&&(o=ja(o,r/n));const l=e.unloadedRows??t-n,d=a||t<=0||n<=0||l<=0||o===null?0:Math.round(l*o),u=Math.abs(d-s);return u===0?{spacerHeight:s,rowHeightEma:o,applied:!1,scrollTopDelta:0}:d===0||s===0||u>s*Wa||i>0&&u>i?{spacerHeight:d,rowHeightEma:o,applied:!0,scrollTopDelta:d-s}:{spacerHeight:s,rowHeightEma:o,applied:!1,scrollTopDelta:0}}const qa=xn,Va=2;function Us(e){const{scrollTop:t,spacerAboveHeight:n,rowHeightEstimate:a,pageSize:r=qa,nearPages:s=Va}=e;if(n<=0||t>=n)return"serial";const i=Ce(a??Number.NaN);return(n-Math.max(0,t))/i>s*r?"seek":"serial"}const yt=200,za=1;function $s(e,t,n=yt){const a=t.timestamp-n;return[...e.filter(r=>r.timestamp>=a),t]}function Ns(e){const{samples:t,viewportHeight:n,windowMs:a=yt,viewportFactor:r=za}=e;if(n<=0||t.length<2)return"gentle";const s=t[t.length-1].timestamp-a,i=t.filter(l=>l.timestamp>=s);if(i.length<2)return"gentle";let o=0;for(let l=1;l<i.length;l+=1)o+=Math.abs(i[l].scrollTop-i[l-1].scrollTop);return o>n*r?"rapid":"gentle"}function Hs(e){const{scrollTop:t,spacerAboveHeight:n,unloadedRowsAbove:a}=e;if(a<=0||n<=0)return 0;const r=Math.min(1,Math.max(0,t/n));return Math.min(a-1,Math.max(0,Math.floor(r*a)))}function Fs(e){const{totalMessages:t,residentCount:n,exhausted:a,startOrdinalEstimate:r,detachedFromTail:s}=e,i=Math.max(0,t-n);if(!s)return{above:a?0:i,below:0};const o=Math.max(0,e.hiddenTailCount??0);if(a)return{above:0,below:i+o};if(r!==null){const c=Math.min(i,Math.max(0,Math.round(r)));return{above:c,below:i-c+o}}const l=Math.min(i,Math.max(0,Math.round(e.holeRowsEstimate??0)));return{above:i-l,below:l+o}}function Ks(e){const{exhausted:t,historyCount:n,tailCount:a,tailTruncated:r,totalMessages:s}=e;return t?!0:n>0?!1:!r&&s<=a}const Ga="intent.drafts.sync",Ja="intent.drafts.changed",Ya=L({id:C(),type:C(),label:C(),description:C().optional(),content:C().optional(),path:C().optional(),imageData:C().optional(),imageMimeType:C().optional(),attachmentId:C().optional(),attachmentMimeType:C().optional(),attachmentSize:ce().optional(),sourcePath:C().optional(),placementStatus:z("failed").optional(),screen:Bn().optional()}),wt=L({text:C(),attachments:On(Ya)}),G={provenance:C().min(1),workspaceId:C().min(1),agentId:C().min(1)},ne={lifetime:C(),revision:ce().int().nonnegative()};Ln("kind",[L({...G,kind:z("read")}),L({...G,...ne,kind:z("edit"),origin:C().min(1),sequence:ce().int().positive(),snapshot:wt}),L({...G,...ne,kind:z("flush")}),L({...G,...ne,kind:z("clear"),origin:C().min(1)})]);const bt=L({...G,...ne,origin:C(),sequence:ce().int().nonnegative(),snapshot:wt}),Qa=L({accepted:Un(),draft:bt});function Xa(e,t,n=t){const a=new Map,r=new Set,s=crypto.randomUUID();let i=0,o=!1;const l=()=>{const f=t();if(o||!f)throw new Error("draft-authority-unavailable");return f},c=()=>{const f=n();if(!f||o)throw new Error("draft-authority-unavailable");return()=>{if(o||n()!==f)throw new Error("draft-authority-changed")}},d=(f,k,v)=>{const I=JSON.stringify([f,k,v]);let S=a.get(I);return S||(S={dirty:0},a.set(I,S)),S},u=(f,k)=>{if(o||f.provenance!==t())return;const v=d(f.provenance,f.workspaceId,f.agentId);if(!(v.value?.lifetime===f.lifetime&&v.value.revision>f.revision)&&(v.value=f,k&&v.dirty===0))for(const I of r)I(f)},h=e.subscribe(f=>{const k=bt.safeParse(f);k.success&&u(k.data,!0)}),p=async(f,k)=>{k();const v=Qa.parse(await e.request(f));if(k(),f.provenance!==l()||v.draft.provenance!==f.provenance)throw new Error("draft-authority-changed");if(!v.accepted)throw u(v.draft,!1),new Error("draft-changed-in-another-editor");return v.draft},m=async(f,k)=>{const v=l(),I=c(),S=d(v,f,k);S.tail&&await S.tail;const _=await p({kind:"read",provenance:v,workspaceId:f,agentId:k},I);return u(_,!1),_},y=(f,k,v)=>{const I=l(),S=c(),_=d(I,f,k),B=_.tail??(_.value?Promise.resolve(_.value):p({kind:"read",provenance:I,workspaceId:f,agentId:k},S));_.dirty+=1;const E=B.then(P=>p(v(P),S));return _.tail=E,E.then(P=>{_.dirty-=1,_.tail===E&&(_.tail=void 0),u(P,!0)},()=>{_.dirty-=1,_.tail===E&&(_.tail=void 0)}),E};return{authority:()=>o?null:n(),read:m,async edit(f,k,v,I){const S=++i;return y(k,v,_=>({kind:"edit",provenance:_.provenance,workspaceId:k,agentId:v,lifetime:_.lifetime,revision:_.revision,origin:f,sequence:S,snapshot:I}))},async flush(f,k){const v=l(),I=c(),S=d(v,f,k),_=await(S.tail??(S.value?Promise.resolve(S.value):m(f,k)));await p({kind:"flush",provenance:v,workspaceId:f,agentId:k,lifetime:_.lifetime,revision:_.revision},I)},async clear(f,k){await y(f,k,v=>({kind:"clear",provenance:v.provenance,workspaceId:f,agentId:k,lifetime:v.lifetime,revision:v.revision,origin:s}))},subscribe(f){return r.add(f),()=>{r.delete(f)}},dispose(){o=!0,h(),r.clear(),a.clear()}}}let U=null;async function Ws(e,t,n,a,r){const s=U;if(!s)throw new Error("draft-shared-transport-unavailable");const i=()=>{if(U!==s||s.authority()!==r)throw new Error("draft-authority-changed")};i(),await s.edit(e,t,n,a),i(),await s.flush(t,n),i()}async function js(e,t){await Promise.resolve(),U&&await U.flush(e,t)}function qs(){if(!et())return null;const e=Xa({request:n=>_n(Ga,n),subscribe:n=>vn(a=>{a.method===Ja&&n(a.params)})},()=>En(A.state),()=>Dn(A.state));U=e;const t=e.dispose;return e.dispose=()=>{U===e&&(U=null),t()},e}const kt=new Map;function vt(e,t){return`${e}\0${t}`}function Vs(e,t){return kt.get(vt(e,t))}function zs(e,t,n){kt.set(vt(e,t),n)}const Gs=A.createSelector((e,t,n)=>{const a=e.chatPanelUi.byWorkspaceId[t];return a?R(a.userMessageIndexes,n):void 0}),Js=A.createSelector((e,t,n)=>{const a=e.chatPanelUi.byWorkspaceId[t];return a?R(a.retryAgents,n):void 0});function Za(e){e=Math.max(0,e);const t=Math.floor(e/1e3);if(t<10){const s=e/1e3,i=s.toFixed(1);return i.endsWith(".0")?`${Math.round(s)}s`:`${i}s`}if(t<60)return`${t}s`;const n=Math.floor(t/3600),a=Math.floor(t%3600/60),r=t%60;return n>0?`${n}h ${a}m ${r}s`:`${a}m ${r}s`}function Ys(e){return Za(Math.max(1e3,Math.round(e/1e3)*1e3))}const er=new Set(["launch","init","session-create","session-load","prompt"]),tr=new Set(["tool-call","tool-waiting"]);function nr(e){let t=null;for(const n of e)(!t||n.timestamp>=t.timestamp)&&(t=n);return t}function Qs(e){return e&&er.has(e)?"pulse":e&&tr.has(e)?"twist":"bloom"}const _t="stalled";function Xs(e,t){const n=nr(e);return!n||n.phase!==_t||typeof t=="number"&&t>n.timestamp?null:n}function Zs(e){let t=null;for(const n of e)n.phase!==_t&&(!t||n.timestamp>=t.timestamp)&&(t=n);return t}const Ve={get title(){return b.chat_streamingStatus_sessionCorrupted_title()},get message(){return b.chat_streamingStatus_sessionCorrupted_message()}},ar=/^session\/[a-z_]+(?: failed)?:\s*/i;function rr(e){const n=(e.split(`
11
+ `),e)}function rs(e,t,n){if(e==="suggested-prompt")return{fields:{},hasAttachments:!1,cleanup:{clearInput:!1,followBottom:!0,historyText:null}};const a=n(),{imageBlocks:r,fileBlocks:s}=Ta(a.contextItems);return{fields:{contextItems:a.contextItems,workspaceContextStr:Ca(a.contextItems,a.checkedPanels,a.checkedSelections),noteIds:a.noteIds,...r.length>0?{imageBlocks:r}:{},...s.length>0?{fileBlocks:s}:{},...a.pickedMentions?{messageMetadata:a.pickedMentions}:{}},hasAttachments:r.length>0||s.length>0,cleanup:{clearInput:!0,followBottom:!0,historyText:t}}}const Ea="chat-read:",W=new Map,ye=new Set;function ss(e,t){let n=W.get(e);n||(n=new Set,W.set(e,n)),n.add(t)}function is(e,t){const n=W.get(e);if(!(!n||!n.delete(t))&&n.size===0){W.delete(e);for(const a of[...ye])a(e)}}function os(e){return ye.add(e),()=>ye.delete(e)}function cs(e){return W.has(e)}function ls(e){const t=W.get(e);if(!t)return!1;for(const n of t)if(!n.startsWith(Ea))return!0;return!1}function Da(e,t,n){const a=e.state.pendingSubmissions.byAgentId[t.agentId];if(!a||!Ge(a.scope,t))return null;const r={...structuredClone(n),id:crypto.randomUUID(),createdAt:Date.now()};e.dispatch(xt(t,r));const s=e.state.pendingSubmissions.byAgentId[t.agentId];return s&&R(s.submissions,r.id)?r:null}function Ra(e,t,n,a,r){const s=Be.select(e.state,n),i=pe.select(e.state)?.principal.id,o=Ue(e.state);if(!s||!i||!o)return null;const l=An(t,n),c={agentId:t,workspaceId:n,principalId:i,participation:s,authority:o,owner:l.key,lifetime:e.state.pendingSubmissions.byAgentId[t]?.scope.lifetime??crypto.randomUUID()},d=()=>l.isCurrent(e.state.agentSessions?.byAgentId[t]?.workspaceId)&&Be.select(e.state,n)===s&&pe.select(e.state)?.principal.id===i&&Ue(e.state)===o;if(!d())return null;e.dispatch(Rt(c,a,Ft.select(e.state,n)));const u=Da(e,c,r);return u?{scope:c,submission:u,isCurrent:()=>{const h=e.state.pendingSubmissions.byAgentId[t];return d()&&!!h&&Ge(h.scope,c)&&(!!R(h.operations,u.id)||!!R(h.submissions,u.id))}}:null}function we(e,t,n){if(!n.text.trim()&&!n.imageBlocks?.length&&!n.fileBlocks?.length)return null;const a=n.userAppMessageId??In();return Ra(e,t,n.wsId,pe.select(e.state)?.capabilities.submissionCorrelation,{content:n.text.trim(),appMessageId:a,destination:!n.forceSubmit&&Kt.select(e.state,t)?"queue":"conversation",contextItems:n.contextItems,imageBlocks:n.imageBlocks,fileBlocks:n.fileBlocks,messageMetadata:n.messageMetadata})}function xa(e,t,n){const a=we(e,t,n);return a?(e.dispatch(Je(t,{...n,userAppMessageId:a.submission.appMessageId,submission:{scope:a.scope,id:a.submission.id}})),!0):!1}async function Pa(e,t,n,a){const r=n.submission;if(!r)return"legacy";const s=r.reference,i=()=>s.scope.agentId===e&&s.scope.workspaceId===t&&Qe.select(A.state,e)===n?gn.select(A.state,s.scope):void 0,o=i();if(!o)return null;if(!o.supported)return"legacy";const l={wsId:t,text:n.text,imageBlocks:n.options?.imageBlocks,fileBlocks:n.options?.fileBlocks,noteIds:n.options?.noteIds,messageMetadata:n.options?.messageMetadata,model:a??n.options?.model};if(r.outcome==="rejected"){const p=R(o.tombstones,s.id);return R(o.submissions,s.id)||p&&p.reason!=="rejected"?null:we(A,e,l)}if(r.outcome==="accepted")return we(A,e,l);await Promise.all([Tn(e,t).catch(()=>{}),Cn(e,t).catch(()=>{})]);const c=i();if(!c||R(c.submissions,s.id)?.status!=="uncertain")return null;const{notify:d}=await fe(async()=>{const{notify:p}=await import("./CVA75Jzf.js").then(m=>m.u);return{notify:p}},__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]),import.meta.url);if(i()!==c)return null;let u=!1;const h=()=>{u=!0};return d.warning(b.agent_chatSend_uncertainRetry_description(),{key:`submission-retry:${t}:${e}:${s.id}`,duration:Number.POSITIVE_INFINITY,action:{label:b.agent_chatSend_resend_label(),onClick:()=>{if(u)return;u=!0;const p=i();!p||p.generation!==c.generation||p.submissions!==c.submissions||p.observationVersion!==c.observationVersion||R(p.submissions,s.id)?.status!=="uncertain"||xa(A,e,l)}},cancel:{label:b.chat_richInput_cancel_label(),onClick:h},onDismiss:h}),null}async function ds(e,t,n){const a=Qe.select(A.state,e),r=a?.submission?await Pa(e,t,a,n):"legacy";if(r){if(r==="legacy"){await A.dispatch(n===void 0?Pt(e,t):Bt(e,t,n));return}!r.isCurrent()||!a||A.dispatch(Je(e,{wsId:t,text:a.text,imageBlocks:a.options?.imageBlocks,fileBlocks:a.options?.fileBlocks,noteIds:a.options?.noteIds,messageMetadata:a.options?.messageMetadata,model:n??a.options?.model,userAppMessageId:r.submission.appMessageId,submission:{scope:r.scope,id:r.submission.id}}))}}const us=A.createSelector((e,t)=>{const n=R(e.chatDrafts.owners,t);return n?{restore:n.restore,saves:Ye(n.saves),shared:n.restore?e.chatDrafts.shared[JSON.stringify([n.restore.workspaceId,n.restore.agentId])]:void 0}:void 0});function Ba(e,t){return t.workspaceId===e&&!t.retiredAt&&!t.pendingDeleteAt&&t.status!==ke.Deleted&&!t.notificationsMuted&&Lt(t)==="topLevel"}function Oa(e){const t=e.metadata?.pendingQuestionsMessageId;return typeof t=="string"&&t.length>0&&!Rn(e.metadata,t)?t:null}function La(e){return e.status===ke.Error&&!Wt(jt(e))}function ms(e,t){return t.filter(n=>Ba(e,n)).flatMap(n=>{const a=Ot(n),r=Oa(n),s=n.status===ke.Error;if(!a&&!r&&!s)return[];const i=a?.timestamp??(s?n.stopReasonTimestamp:void 0);return[{agentId:n.id,agentName:n.name,kind:a?.kind??(s?"failed":"question"),reason:a?.reason,timestamp:i&&Number.isFinite(Date.parse(i))?i:void 0,questionMessageId:r,canRetry:La(n)}]})}function ps(e){return e.displayStatus==="failed"?"failed":e.displayStatus==="blocked"?"blocked":e.attention==="review_required"?"review":e.displayStatus==="needs_attention"?"question":e.activity==="agent_running"||e.displayStatus==="in_progress"?"running":e.scriptsRunning===!0?"scripts_running":e.backgroundTasksRunning===!0?"background_tasks_running":e.displayStatus==="pr_ready"?"pr_ready":e.displayStatus==="pr_merged"?"merged":e.displayStatus==="complete"?"complete":e.attention==="unread"?"unread":e.displayStatus==="pr_open"||e.displayStatus==="pr_queued"?e.displayStatus:"idle"}function fs(e){const t=e.kind==="prs"?e.organization?.trim().toLowerCase():void 0;return{key:JSON.stringify([e.kind,e.workspaceId,t||null,[...new Set((t?[]:e.repositories).map(n=>JSON.stringify([n.key,n.owner,n.name])))].sort()]),hasGitHubRepositories:!!t||e.repositories.some(n=>!!n.owner),hasLocalRepositories:!t&&e.repositories.some(n=>!n.owner)}}function Te(e){const t=kn(e);if(t?.kind!=="pr"||!Number.isSafeInteger(t.number)||t.number<=0)return null;const n=t.owner.toLowerCase(),a=t.repo.toLowerCase();return{owner:n,repo:a,number:t.number,id:`${n}/${a}#${t.number}`,url:`https://github.com/${n}/${a}/pull/${t.number}`}}function hs(e,t,n,a){const r=e.filter(s=>a?a.includes(s.id):n?s.repositoryOwner?.toLowerCase()===n.toLowerCase():t.some(i=>i.owner?.toLowerCase()===s.repositoryOwner?.toLowerCase()&&i.name.toLowerCase()===s.repositoryName?.toLowerCase()));return[...new Map(r.flatMap(s=>[...(s.pullRequests??[]).map(i=>i.url),s.activePullRequest?.url,s.prUrl]).flatMap(s=>{const i=s?Te(s):null;return i?[[i.id,{owner:i.owner,repo:i.repo,number:i.number}]]:[]})).values()].sort((s,i)=>`${s.owner}/${s.repo}#${s.number}`.localeCompare(`${i.owner}/${i.repo}#${i.number}`))}function gs(e,t){const[n]=t;return t.length!==1||e.owner?.toLowerCase()!==n?.owner?.toLowerCase()||e.repo?.toLowerCase()!==n?.name.toLowerCase()}const ys=A.createSelector(e=>e.homeIntegrations),ws=A.createSelector(e=>{const t=e.homeIntegrations;return!t.linkedItems||!Object.keys(t.linkedItems).length?t:{...t,items:[...new Map([...Object.values(t.linkedItems),...t.items].map(n=>[n.id,n])).values()].sort((n,a)=>(a.updatedAt??"").localeCompare(n.updatedAt??""))}}),gt=A.createSelector(e=>Ye(e.workspace.workspaces).flatMap(t=>[...(t.pullRequests??[]).map(n=>n.url),t.activePullRequest?.url,t.prUrl].filter(n=>!!n).map(n=>({url:Te(n)?.url??n.replace(/\/$/,"").toLowerCase(),workspaceId:t.id,name:t.title||t.id})))),bs=A.createSelector(e=>{const t=e.homeIntegrations.detail?.url,n=t?Te(t)?.url??t.replace(/\/$/,"").toLowerCase():void 0;return gt.select(e).find(a=>a.url===n)??null}),ks=A.createSelector(e=>gt.select(e).map(t=>t.url));let te=null;function vs(e){return te=e,()=>{te===e&&(te=null)}}function _s(){return te}function Ss(e){return[...e.groups.length>0?e.groups.filter(n=>n.expanded).flatMap(n=>n.items):e.workspaces,...e.asideExpanded?e.aside:[]].map(n=>n.id)}function Ms(e,t,n){if(e.length===0)return null;const a=t===null?-1:e.indexOf(t);return a===-1?e[0]:e[a+(n==="clockwise"?1:-1)]??null}let H=[];function As(e,t={}){const n={source:e,fallback:t.fallback===!0};return H=[...H,n],()=>{H=H.filter(a=>a!==n)}}function Is(){const e=H.findLast(n=>!n.fallback);return e?e.source:H.findLast(n=>n.fallback&&(n.source.available?.()??!0))?.source??null}function Ts(e){if(!e?.isConnected||e.closest("[inert]"))return!1;const t=e.ownerDocument.querySelectorAll('[aria-modal="true"]');return Array.from(t).every(n=>n.contains(e))}function Cs(e){return Mn(e)}function Ua(e){return Sn(e)}function $a(e,t){return!e||!t?!1:e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}function me(e){if(e.length===0)return[];const t=[];let n=null;for(const a of e){const r=a.timestamp?typeof a.timestamp=="string"?new Date(a.timestamp):a.timestamp:new Date;(!n||!$a(n.date,r))&&(n={date:r,label:Ua(r),messages:[]},t.push(n)),n.messages.push(a)}return t}function Es(e){const t=new Map;return e.map(({date:n})=>{const a=`${n.getFullYear()}-${n.getMonth()+1}-${n.getDate()}`,r=t.get(a)??0;return t.set(a,r+1),r===0?a:`${a}#${r}`})}function Ds(e,t){const n=new Map;let a=t?null:void 0;for(const r of e.groups)for(const s of r.messages)a!==void 0&&n.set(s.id,a),s.role==="user"&&!Pn(s)&&(a=s);return n}function Na(e){return`${e.getFullYear()}-${e.getMonth()+1}-${e.getDate()}`}function je(e,t){const n=new Map;return e.map(a=>{const r=`${t}-${Na(a.date)}`,s=(n.get(r)??0)+1;return n.set(r,s),{...a,groupKey:s===1?r:`${r}-${s}`}})}function Ha(e,t){if(e.length===0||t.length===0)return e;const n=new Set(t.map(s=>s.id)),a=new Set(t.map(s=>s.appMessageId).filter(s=>typeof s=="string"&&s.length>0)),r=e.filter(s=>!n.has(s.id)&&!(typeof s.appMessageId=="string"&&s.appMessageId.length>0&&a.has(s.appMessageId)));return r.length===e.length?e:r}function Rs(e,t,n){return e=Ha(e,t),e.length===0?{groups:me(t),detached:!1,hiddenTail:[]}:n?{groups:je(me(e),"h"),detached:!0,hiddenTail:t}:{groups:je(me([...e,...t]),"d"),detached:!1,hiddenTail:[]}}function xs(e){const{scrollTop:t,threshold:n,fetching:a,exhausted:r,historyCount:s,tailCount:i,tailTruncated:o,totalMessages:l,spacerAbove:c=0}=e;return t>n+c||a||r?!1:s>0||o||l>i+s}const Ps=300;function Bs(e){const{fetching:t,chainEvaluationPending:n,visible:a,hideArmed:r}=e;return t||n?a&&!r?"none":"show":a&&!r?"arm-hide":"none"}const qe=24,Fa=320;function Ce(e){return Number.isFinite(e)?Math.min(Fa,Math.max(qe,e)):qe}const Ka=.2,Wa=.12;function ja(e,t,n=Ka){const a=Ce(t);return e===null||!Number.isFinite(e)?a:e+n*(a-e)}function Os(e,t){const n=Ce(t??Number.NaN);return{above:Math.round(Math.max(0,e.above)*n),below:Math.round(Math.max(0,e.below)*n)}}function Ls(e){const{totalMessages:t,residentCount:n,exhausted:a,residentContentHeight:r,currentSpacerHeight:s,viewportHeight:i}=e;let o=e.rowHeightEma;n>0&&r>0&&(o=ja(o,r/n));const l=e.unloadedRows??t-n,d=a||t<=0||n<=0||l<=0||o===null?0:Math.round(l*o),u=Math.abs(d-s);return u===0?{spacerHeight:s,rowHeightEma:o,applied:!1,scrollTopDelta:0}:d===0||s===0||u>s*Wa||i>0&&u>i?{spacerHeight:d,rowHeightEma:o,applied:!0,scrollTopDelta:d-s}:{spacerHeight:s,rowHeightEma:o,applied:!1,scrollTopDelta:0}}const qa=xn,Va=2;function Us(e){const{scrollTop:t,spacerAboveHeight:n,rowHeightEstimate:a,pageSize:r=qa,nearPages:s=Va}=e;if(n<=0||t>=n)return"serial";const i=Ce(a??Number.NaN);return(n-Math.max(0,t))/i>s*r?"seek":"serial"}const yt=200,za=1;function $s(e,t,n=yt){const a=t.timestamp-n;return[...e.filter(r=>r.timestamp>=a),t]}function Ns(e){const{samples:t,viewportHeight:n,windowMs:a=yt,viewportFactor:r=za}=e;if(n<=0||t.length<2)return"gentle";const s=t[t.length-1].timestamp-a,i=t.filter(l=>l.timestamp>=s);if(i.length<2)return"gentle";let o=0;for(let l=1;l<i.length;l+=1)o+=Math.abs(i[l].scrollTop-i[l-1].scrollTop);return o>n*r?"rapid":"gentle"}function Hs(e){const{scrollTop:t,spacerAboveHeight:n,unloadedRowsAbove:a}=e;if(a<=0||n<=0)return 0;const r=Math.min(1,Math.max(0,t/n));return Math.min(a-1,Math.max(0,Math.floor(r*a)))}function Fs(e){const{totalMessages:t,residentCount:n,exhausted:a,startOrdinalEstimate:r,detachedFromTail:s}=e,i=Math.max(0,t-n);if(!s)return{above:a?0:i,below:0};const o=Math.max(0,e.hiddenTailCount??0);if(a)return{above:0,below:i+o};if(r!==null){const c=Math.min(i,Math.max(0,Math.round(r)));return{above:c,below:i-c+o}}const l=Math.min(i,Math.max(0,Math.round(e.holeRowsEstimate??0)));return{above:i-l,below:l+o}}function Ks(e){const{exhausted:t,historyCount:n,tailCount:a,tailTruncated:r,totalMessages:s}=e;return t?!0:n>0?!1:!r&&s<=a}const Ga="intent.drafts.sync",Ja="intent.drafts.changed",Ya=L({id:C(),type:C(),label:C(),description:C().optional(),content:C().optional(),path:C().optional(),imageData:C().optional(),imageMimeType:C().optional(),attachmentId:C().optional(),attachmentMimeType:C().optional(),attachmentSize:ce().optional(),sourcePath:C().optional(),placementStatus:z("failed").optional(),screen:Bn().optional()}),wt=L({text:C(),attachments:On(Ya)}),G={provenance:C().min(1),workspaceId:C().min(1),agentId:C().min(1)},ne={lifetime:C(),revision:ce().int().nonnegative()};Ln("kind",[L({...G,kind:z("read")}),L({...G,...ne,kind:z("edit"),origin:C().min(1),sequence:ce().int().positive(),snapshot:wt}),L({...G,...ne,kind:z("flush")}),L({...G,...ne,kind:z("clear"),origin:C().min(1)})]);const bt=L({...G,...ne,origin:C(),sequence:ce().int().nonnegative(),snapshot:wt}),Qa=L({accepted:Un(),draft:bt});function Xa(e,t,n=t){const a=new Map,r=new Set,s=crypto.randomUUID();let i=0,o=!1;const l=()=>{const f=t();if(o||!f)throw new Error("draft-authority-unavailable");return f},c=()=>{const f=n();if(!f||o)throw new Error("draft-authority-unavailable");return()=>{if(o||n()!==f)throw new Error("draft-authority-changed")}},d=(f,k,v)=>{const I=JSON.stringify([f,k,v]);let S=a.get(I);return S||(S={dirty:0},a.set(I,S)),S},u=(f,k)=>{if(o||f.provenance!==t())return;const v=d(f.provenance,f.workspaceId,f.agentId);if(!(v.value?.lifetime===f.lifetime&&v.value.revision>f.revision)&&(v.value=f,k&&v.dirty===0))for(const I of r)I(f)},h=e.subscribe(f=>{const k=bt.safeParse(f);k.success&&u(k.data,!0)}),p=async(f,k)=>{k();const v=Qa.parse(await e.request(f));if(k(),f.provenance!==l()||v.draft.provenance!==f.provenance)throw new Error("draft-authority-changed");if(!v.accepted)throw u(v.draft,!1),new Error("draft-changed-in-another-editor");return v.draft},m=async(f,k)=>{const v=l(),I=c(),S=d(v,f,k);S.tail&&await S.tail;const _=await p({kind:"read",provenance:v,workspaceId:f,agentId:k},I);return u(_,!1),_},y=(f,k,v)=>{const I=l(),S=c(),_=d(I,f,k),B=_.tail??(_.value?Promise.resolve(_.value):p({kind:"read",provenance:I,workspaceId:f,agentId:k},S));_.dirty+=1;const E=B.then(P=>p(v(P),S));return _.tail=E,E.then(P=>{_.dirty-=1,_.tail===E&&(_.tail=void 0),u(P,!0)},()=>{_.dirty-=1,_.tail===E&&(_.tail=void 0)}),E};return{authority:()=>o?null:n(),read:m,async edit(f,k,v,I){const S=++i;return y(k,v,_=>({kind:"edit",provenance:_.provenance,workspaceId:k,agentId:v,lifetime:_.lifetime,revision:_.revision,origin:f,sequence:S,snapshot:I}))},async flush(f,k){const v=l(),I=c(),S=d(v,f,k),_=await(S.tail??(S.value?Promise.resolve(S.value):m(f,k)));await p({kind:"flush",provenance:v,workspaceId:f,agentId:k,lifetime:_.lifetime,revision:_.revision},I)},async clear(f,k){await y(f,k,v=>({kind:"clear",provenance:v.provenance,workspaceId:f,agentId:k,lifetime:v.lifetime,revision:v.revision,origin:s}))},subscribe(f){return r.add(f),()=>{r.delete(f)}},dispose(){o=!0,h(),r.clear(),a.clear()}}}let U=null;async function Ws(e,t,n,a,r){const s=U;if(!s)throw new Error("draft-shared-transport-unavailable");const i=()=>{if(U!==s||s.authority()!==r)throw new Error("draft-authority-changed")};i(),await s.edit(e,t,n,a),i(),await s.flush(t,n),i()}async function js(e,t){await Promise.resolve(),U&&await U.flush(e,t)}function qs(){if(!et())return null;const e=Xa({request:n=>_n(Ga,n),subscribe:n=>vn(a=>{a.method===Ja&&n(a.params)})},()=>En(A.state),()=>Dn(A.state));U=e;const t=e.dispose;return e.dispose=()=>{U===e&&(U=null),t()},e}const kt=new Map;function vt(e,t){return`${e}\0${t}`}function Vs(e,t){return kt.get(vt(e,t))}function zs(e,t,n){kt.set(vt(e,t),n)}const Gs=A.createSelector((e,t,n)=>{const a=e.chatPanelUi.byWorkspaceId[t];return a?R(a.userMessageIndexes,n):void 0}),Js=A.createSelector((e,t,n)=>{const a=e.chatPanelUi.byWorkspaceId[t];return a?R(a.retryAgents,n):void 0});function Za(e){e=Math.max(0,e);const t=Math.floor(e/1e3);if(t<10){const s=e/1e3,i=s.toFixed(1);return i.endsWith(".0")?`${Math.round(s)}s`:`${i}s`}if(t<60)return`${t}s`;const n=Math.floor(t/3600),a=Math.floor(t%3600/60),r=t%60;return n>0?`${n}h ${a}m ${r}s`:`${a}m ${r}s`}function Ys(e){return Za(Math.max(1e3,Math.round(e/1e3)*1e3))}const er=new Set(["launch","init","session-create","session-load","prompt"]),tr=new Set(["tool-call","tool-waiting"]);function nr(e){let t=null;for(const n of e)(!t||n.timestamp>=t.timestamp)&&(t=n);return t}function Qs(e){return e&&er.has(e)?"pulse":e&&tr.has(e)?"twist":"bloom"}const _t="stalled";function Xs(e,t){const n=nr(e);return!n||n.phase!==_t||typeof t=="number"&&t>n.timestamp?null:n}function Zs(e){let t=null;for(const n of e)n.phase!==_t&&(!t||n.timestamp>=t.timestamp)&&(t=n);return t}const Ve={get title(){return b.chat_streamingStatus_sessionCorrupted_title()},get message(){return b.chat_streamingStatus_sessionCorrupted_message()}},ar=/^session\/[a-z_]+(?: failed)?:\s*/i;function rr(e){const n=(e.split(`
12
12
  `).map(a=>a.trim()).find(Boolean)??"").replace(ar,"");return n.charAt(0).toUpperCase()+n.slice(1)}function ei(e,t){return e?t===!0?{corrupted:!0,title:Ve.title,message:Ve.message,detail:e}:{corrupted:!1,title:b.chat_streamingStatus_responseFailed_label(),message:rr(e),detail:null}:null}const ti=A.createSelector((e,t)=>R(e.questionUi.consumers,t)),sr=3e4,Y=new Map;function ni(e,t){const n=Y.get(e);n&&clearTimeout(n.timer);const a=setTimeout(()=>Y.delete(e),sr);Y.set(e,{value:t,timer:a})}function ai(e){const t=Y.get(e);if(t)return clearTimeout(t.timer),Y.delete(e),t.value}const St=A.createSelector((e,t,n)=>e.agentWorkers?.byKey[$t(t,n)]??Ut),ir=A.createSelector((e,t,n)=>{const a=St.select(e,t,n);return a.status==="unsupported"?[]:(a.snapshot?.workers??[]).filter(r=>r.status==="running"||r.status==="unknown")}),ri=A.createSelector((e,t,n)=>{const a=St.select(e,t,n);return a.status==="failed"?!0:a.status!=="ready"||!a.snapshot?!1:a.snapshot.truncated?!0:a.snapshot.support.status!=="supported"&&ir.select(e,t,n).length>0}),or=1e3,Mt={requireViewedAndFocused:!0,requireAssistantTail:!0},Q=new Map,x=new Map;let j=null;function Ee(e){(e===void 0||j===e)&&(j=null)}const cr=200;function lr(e,t){if(x.delete(e),x.set(e,t),x.size>cr){const n=x.keys().next().value;n!==void 0&&x.delete(n)}}function At(e){for(let t=e.length-1;t>=0;t--){const n=e[t];if(!n.isStreaming&&typeof n.id=="string"&&n.id.length>0)return n}return null}function si(e){return At(e)?.id??null}function ii(e){De(e,{requireViewedAndFocused:!0})}function oi(e){De(e,{requireViewedAndFocused:!1})}function ci(e){Ee(),De(e,Mt)}function li(e){j===e&&(Q.has(e)||(j=null,Re(e,Mt)))}function di(e){for(const t of e)typeof t!="string"||t.length===0||(It(t),Ee(t),Re(t,{requireViewedAndFocused:!1}))}function It(e){const t=Q.get(e);t&&(clearTimeout(t.timer),Q.delete(e))}function De(e,t){It(e),Ee(e);const n=setTimeout(()=>{Q.delete(e),Re(e,t)},or);Q.set(e,{timer:n,gates:t})}let ze=null;function dr(){return ze??=Promise.all([fe(()=>import("./DedMJivv.js"),__vite__mapDeps([46,21,22,5,23,24,3,8,4,25,15,2,47,48]),import.meta.url),fe(()=>import("./BxKppgO5.js").then(e=>e.o),__vite__mapDeps([49,45,4,5,21,22,23,24,3,8,25,15,2,13,14,7,9,16,37,36,50,33,42]),import.meta.url)]).then(([e,t])=>({appStore:e.store,appClient:t.appClient})),ze}async function Re(e,t){let n=null;try{const{appStore:a,appClient:r}=await dr(),s=a.state;if(t.requireViewedAndFocused&&(s.unreadTracking?.currentlyViewedAgentId!==e||typeof document<"u"&&!document.hasFocus()))return;const i=s.agentSessions?.byAgentId[e];if(!i)return;const o=typeof i.workspaceId=="string"?i.workspaceId:"";if(o.length===0)return;if(t.requireAssistantTail&&s.chatState?.byAgentId[e]?.initialHistoryPending){j=e;return}const l=At(i.messages??[]);if(!l){t.requireAssistantTail&&(j=e);return}if(t.requireAssistantTail&&l.role!=="assistant")return;const c=l.id;if(x.get(e)===c)return;lr(e,c),n=c,!(await r.agents.markSeen({workspaceId:o,agentId:e,messageId:c})).success&&x.get(e)===n&&x.delete(e)}catch{n!==null&&x.get(e)===n&&x.delete(e)}}const oe=new Map;function Tt(e,t){return`${e}\0${t}`}function ui(e,t){return oe.get(Tt(e,t))}function mi(e,t,n){oe.set(Tt(e,t),n)}function pi(e){if(e.length===0)return;const t=new Set(e);for(const n of[...oe.keys()]){const a=n.slice(n.indexOf("\0")+1);t.has(a)&&oe.delete(n)}}export{Ss as $,Nr as A,Qr as B,zr as C,O as D,Ha as E,Jr as F,Ta as G,Ea as H,zn as I,js as J,Ys as K,Cs as L,or as M,Xs as N,Ps as O,ui as P,Vs as Q,yt as R,Is as S,ms as T,_s as U,qe as V,ps as W,Zs as X,Qs as Y,cs as Z,ls as _,ss as a,Wr as a0,ta as a1,Ds as a2,Kr as a3,Ks as a4,J as a5,qr as a6,jr as a7,Ts as a8,Lr as a9,ir as aA,St as aB,ri as aC,us as aD,xr as aE,Pr as aF,Rr as aG,ys as aH,bs as aI,ws as aJ,ks as aK,gt as aL,ti as aM,Js as aN,Gs as aO,mi as aP,zs as aQ,xs as aR,Fr as aS,gs as aT,Fs as aU,ni as aV,Ms as aW,xa as aX,ai as aY,na as aZ,Hr as a_,Hs as aa,di as ab,li as ac,ii as ad,oi as ae,ci as af,si as ag,Bs as ah,os as ai,Xr as aj,Nn as ak,Ws as al,Vr as am,rs as an,Yr as ao,Pa as ap,pt as aq,Ur as ar,As as as,Ls as at,vs as au,is as av,Ee as aw,ds as ax,Br as ay,Os as az,we as b,$s as c,ns as d,as as e,Es as f,$r as g,Ca as h,Or as i,ra as j,aa as k,Ns as l,Us as m,pi as n,hs as o,Rs as p,ts as q,es as r,Gr as s,qs as t,Zr as u,ei as v,fs as w,Ma as x,ge as y,jn as z};
@@ -1,4 +1,4 @@
1
- import{p as xt}from"./zROLTv2m.js";import{aZ as gt,U as $t,Y as bt,b0 as wt,V as Ct,a_ as vt,b as s,ay as O,aX as Dt,B as kt,r as Tt,q as U,W as Z,O as At,a6 as ot}from"./D-usBtmP.js";import{p as Bt}from"./2ypcXvW0.js";var rt=s(()=>({domains:new Map,transitions:[]}),"createDefaultData"),H=rt(),St=s(()=>H.domains,"getDomains"),Mt=s(()=>H.transitions,"getTransitions"),zt=s(t=>{if(t)for(const e of t){const n=e.domain,a=(e.items??[]).map(c=>({label:c.label}));H.domains.set(n,{name:n,items:a})}},"setDomains"),Lt=s(t=>{t&&(H.transitions=t.filter(e=>e.from===e.to?(O.warn(`Cynefin: self-loop transition on domain "${e.from}" is not meaningful and will be skipped.`),!1):!0).map(e=>({from:e.from,to:e.to,label:e.label||void 0})))},"setTransitions"),Nt=s(()=>U({...At.cynefin,...Z().cynefin}),"getConfig"),Pt=s(()=>{Tt(),H=rt()},"clear"),G={getDomains:St,getTransitions:Mt,setDomains:zt,setTransitions:Lt,getConfig:Nt,clear:Pt,setAccTitle:vt,getAccTitle:Ct,setDiagramTitle:wt,getDiagramTitle:bt,getAccDescription:$t,setAccDescription:gt},Wt=s(t=>{xt(t,G),G.setDomains(t.domains),G.setTransitions(t.transitions)},"populate"),It={parse:s(async t=>{const e=await Bt("cynefin",t);O.debug(e),Wt(e)},"parse")};function E(t){let e=t+1831565813|0;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}s(E,"seededRandom");function st(t){let e=0;for(let n=0;n<t.length;n++){const a=t.charCodeAt(n);e=(e<<5)-e+a,e|=0}return e}s(st,"hashString");function it(t,e){return typeof t=="number"&&Number.isFinite(t)&&t!==0?t:st(e)}s(it,"resolveSeed");function ct(t,e,n,a){const c=t/2,m=a??t*.015,v=7,I=e/v,d=[];for(let o=0;o<=v;o++){const p=E(n+o*17)*m*2-m;d.push({x:c+p,y:o*I})}let D=`M${d[0].x},${d[0].y}`;for(let o=0;o<d.length-1;o++){const p=d[o],i=d[o+1],f=(p.y+i.y)/2,b=o%2===0?1:-1,h=m*1.5*b*E(n+o*31+7),R=p.x+h,V=f,_=i.x-h;D+=` C${R},${V} ${_},${f} ${i.x},${i.y}`}return D}s(ct,"generateFoldPath");function lt(t,e,n,a){const c=e/2,m=a??e*.015,v=7,I=t/v,d=[];for(let o=0;o<=v;o++){const p=E(n+o*23)*m*2-m;d.push({x:o*I,y:c+p})}let D=`M${d[0].x},${d[0].y}`;for(let o=0;o<d.length-1;o++){const p=d[o],i=d[o+1],f=(p.x+i.x)/2,b=o%2===0?1:-1,h=m*1.5*b*E(n+o*37+11),R=f,V=p.y+h,_=f,z=i.y-h;D+=` C${R},${V} ${_},${z} ${i.x},${i.y}`}return D}s(lt,"generateHorizontalBoundary");function dt(t,e){const n=t/2,a=e*.5,c=e,m=t*.03;return[`M${n},${a}`,`C${n+m},${a+(c-a)*.2}`,`${n-m*1.5},${a+(c-a)*.55}`,`${n+m*.5},${a+(c-a)*.75}`,`C${n-m},${a+(c-a)*.85}`,`${n+m*.3},${a+(c-a)*.95}`,`${n},${c}`].join(" ")}s(dt,"generateCliffPath");function ft(t,e,n,a){return[`M${t-n},${e}`,`A${n},${a} 0 1,1 ${t+n},${e}`,`A${n},${a} 0 1,1 ${t-n},${e}`,"Z"].join(" ")}s(ft,"generateConfusionPath");var at={complex:{model:"Probe → Sense → Respond",practice:"Emergent Practices"},complicated:{model:"Sense → Analyse → Respond",practice:"Good Practices"},clear:{model:"Sense → Categorise → Respond",practice:"Best Practices"},chaotic:{model:"Act → Sense → Respond",practice:"Novel Practices"},confusion:{model:"",practice:"Disorder"}},Rt=s((t,e)=>{const n=t/2,a=e/2;return{complex:{cx:n/2,cy:a/2,x:0,y:0,w:n,h:a},complicated:{cx:n+n/2,cy:a/2,x:n,y:0,w:n,h:a},chaotic:{cx:n/2,cy:a+a/2,x:0,y:a,w:n,h:a},clear:{cx:n+n/2,cy:a+a/2,x:n,y:a,w:n,h:a},confusion:{cx:n,cy:a,x:n*.7,y:a*.7,w:n*.6,h:a*.6}}},"getDomainLayouts"),Vt=s(()=>{const t=ot(),e=Z();return U(t,e.themeVariables).cynefin},"getCynefinDomainColors"),q=3,_t=s((t,e,n,a)=>{const c=a.db,m=c.getDomains(),v=c.getTransitions(),I=c.getDiagramTitle(),d=c.getAccTitle(),D=c.getAccDescription(),o=c.getConfig(),p=Vt();O.debug("Rendering Cynefin diagram");const i=o.width,f=o.height,b=o.padding,h=o.showDomainDescriptions,R=o.boundaryAmplitude,V=i+b*2,_=f+b*2,z={complex:p.complexBg,complicated:p.complicatedBg,clear:p.clearBg,chaotic:p.chaoticBg,confusion:p.confusionBg},k=Dt(e);kt(k,_,V,o.useMaxWidth??!0),k.attr("viewBox",`0 0 ${V} ${_}`),d&&k.append("title").text(d),D&&k.append("desc").text(D);const T=k.append("g").attr("transform",`translate(${b}, ${b})`),F=Rt(i,f),Q=it(o.seed,e),mt=T.append("g").attr("class","cynefin-backgrounds"),X=["complex","complicated","chaotic","clear"];for(const l of X){const r=F[l];mt.append("rect").attr("class","cynefinDomain").attr("x",r.x).attr("y",r.y).attr("width",r.w).attr("height",r.h).attr("fill",z[l]).attr("fill-opacity",.4).attr("stroke","none")}const j=T.append("g").attr("class","cynefin-boundaries");j.append("path").attr("class","cynefinBoundary").attr("d",ct(i,f,Q,R)).attr("fill","none"),j.append("path").attr("class","cynefinBoundary").attr("d",lt(i,f,Q+100,R)).attr("fill","none"),j.append("path").attr("class","cynefinCliff").attr("d",dt(i,f)).attr("fill","none");const pt=i*.15,yt=f*.15;T.append("path").attr("class","cynefinConfusion").attr("d",ft(i/2,f/2,pt,yt)).attr("fill",z.confusion).attr("fill-opacity",.5);const J=T.append("g").attr("class","cynefin-labels");for(const l of X){const r=F[l];J.append("text").attr("class","cynefinDomainLabel").attr("x",r.cx).attr("y",h?r.cy-30:r.cy).attr("text-anchor","middle").attr("dominant-baseline","middle").text(l.charAt(0).toUpperCase()+l.slice(1))}if(J.append("text").attr("class","cynefinDomainLabel").attr("x",i/2).attr("y",h?f/2-10:f/2).attr("text-anchor","middle").attr("dominant-baseline","middle").text("Confusion"),h){const l=T.append("g").attr("class","cynefin-subtitles");for(const r of X){const u=F[r],y=at[r];l.append("text").attr("class","cynefinSubtitle").attr("x",u.cx).attr("y",u.cy-10).attr("text-anchor","middle").attr("dominant-baseline","middle").text(y.model),l.append("text").attr("class","cynefinSubtitle").attr("x",u.cx).attr("y",u.cy+5).attr("text-anchor","middle").attr("dominant-baseline","middle").text(y.practice)}l.append("text").attr("class","cynefinSubtitle").attr("x",i/2).attr("y",f/2+8).attr("text-anchor","middle").attr("dominant-baseline","middle").text(at.confusion.practice)}const K=T.append("g").attr("class","cynefin-items"),A=26,tt=10,ut=["complex","complicated","chaotic","clear","confusion"];for(const l of ut){const r=m.get(l);if(!r||r.items.length===0)continue;const u=F[l],y=l==="confusion";let L=r.items,N=0;y&&r.items.length>q&&(N=r.items.length-q,L=r.items.slice(0,q));let B;if(y){const g=h?22:14;B=u.cy+g}else B=u.cy+(h?25:15);if([...L].forEach((g,S)=>{const w=B+S*(A+4),M=K.append("g"),P=M.append("text").attr("class","cynefinItemText").attr("x",0).attr("y",A/2).attr("text-anchor","middle").attr("dominant-baseline","central").text(g.label);let $=g.label.length*7;const x=P.node();if(x&&typeof x.getBBox=="function"){const Y=x.getBBox();Y.width>0&&($=Y.width)}const C=$+tt*2,W=u.cx-C/2;M.attr("transform",`translate(${W}, ${w})`),M.insert("rect","text").attr("class","cynefinItem").attr("x",0).attr("y",0).attr("width",C).attr("height",A).attr("rx",4).attr("ry",4).attr("fill",z[l]).attr("fill-opacity",.95),P.attr("x",C/2).attr("y",A/2)}),N>0){const g=B+L.length*(A+4),S=`+${N} more`,w=K.append("g"),M=w.append("text").attr("class","cynefinItemText").attr("x",0).attr("y",A/2).attr("text-anchor","middle").attr("dominant-baseline","central").text(S);let P=S.length*7;const $=M.node();if($&&typeof $.getBBox=="function"){const W=$.getBBox();W.width>0&&(P=W.width)}const x=P+tt*2,C=u.cx-x/2;w.attr("transform",`translate(${C}, ${g})`),w.insert("rect","text").attr("class","cynefinItemOverflow").attr("x",0).attr("y",0).attr("width",x).attr("height",A).attr("rx",4).attr("ry",4).attr("fill",z[l]).attr("fill-opacity",.6),M.attr("x",x/2).attr("y",A/2)}}if(v.length>0){const l=k.select("defs").empty()?k.append("defs"):k.select("defs"),r=`cynefin-arrow-${e}`;l.append("marker").attr("id",r).attr("viewBox","0 0 10 10").attr("refX",9).attr("refY",5).attr("markerWidth",6).attr("markerHeight",6).attr("orient","auto-start-reverse").append("path").attr("d","M 0 0 L 10 5 L 0 10 z").attr("class","cynefinArrowHead");const u=T.append("g").attr("class","cynefin-arrows");v.forEach(y=>{const L=F[y.from],N=F[y.to];if(!L||!N)return;if(y.from===y.to){O.warn(`Cynefin renderer: skipping self-loop on domain "${y.from}"`);return}const B=L.cx,g=L.cy,S=N.cx,w=N.cy,M=(B+S)/2,P=(g+w)/2,$=S-B,x=w-g,C=Math.sqrt($*$+x*x),W=C*.15,Y=-x/C,ht=$/C,et=M+Y*W,nt=P+ht*W;u.append("path").attr("class","cynefinArrowLine").attr("d",`M${B},${g} Q${et},${nt} ${S},${w}`).attr("fill","none").attr("marker-end",`url(#${r})`),y.label&&u.append("text").attr("class","cynefinArrowLabel").attr("x",et).attr("y",nt-6).attr("text-anchor","middle").attr("dominant-baseline","auto").text(y.label)})}I&&T.append("text").attr("class","cynefinTitle").attr("x",i/2).attr("y",-b/2).attr("text-anchor","middle").attr("dominant-baseline","middle").text(I)},"draw"),Ft={draw:_t},Et=s(()=>{const t=ot(),e=Z();return U(t,e.themeVariables).cynefin},"getCynefinTheme"),Ht=s(()=>{const t=Et();return`
1
+ import{p as xt}from"./ezsQjlt6.js";import{aZ as gt,U as $t,Y as bt,b0 as wt,V as Ct,a_ as vt,b as s,ay as O,aX as Dt,B as kt,r as Tt,q as U,W as Z,O as At,a6 as ot}from"./BpXYSrHL.js";import{p as Bt}from"./2ypcXvW0.js";var rt=s(()=>({domains:new Map,transitions:[]}),"createDefaultData"),H=rt(),St=s(()=>H.domains,"getDomains"),Mt=s(()=>H.transitions,"getTransitions"),zt=s(t=>{if(t)for(const e of t){const n=e.domain,a=(e.items??[]).map(c=>({label:c.label}));H.domains.set(n,{name:n,items:a})}},"setDomains"),Lt=s(t=>{t&&(H.transitions=t.filter(e=>e.from===e.to?(O.warn(`Cynefin: self-loop transition on domain "${e.from}" is not meaningful and will be skipped.`),!1):!0).map(e=>({from:e.from,to:e.to,label:e.label||void 0})))},"setTransitions"),Nt=s(()=>U({...At.cynefin,...Z().cynefin}),"getConfig"),Pt=s(()=>{Tt(),H=rt()},"clear"),G={getDomains:St,getTransitions:Mt,setDomains:zt,setTransitions:Lt,getConfig:Nt,clear:Pt,setAccTitle:vt,getAccTitle:Ct,setDiagramTitle:wt,getDiagramTitle:bt,getAccDescription:$t,setAccDescription:gt},Wt=s(t=>{xt(t,G),G.setDomains(t.domains),G.setTransitions(t.transitions)},"populate"),It={parse:s(async t=>{const e=await Bt("cynefin",t);O.debug(e),Wt(e)},"parse")};function E(t){let e=t+1831565813|0;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}s(E,"seededRandom");function st(t){let e=0;for(let n=0;n<t.length;n++){const a=t.charCodeAt(n);e=(e<<5)-e+a,e|=0}return e}s(st,"hashString");function it(t,e){return typeof t=="number"&&Number.isFinite(t)&&t!==0?t:st(e)}s(it,"resolveSeed");function ct(t,e,n,a){const c=t/2,m=a??t*.015,v=7,I=e/v,d=[];for(let o=0;o<=v;o++){const p=E(n+o*17)*m*2-m;d.push({x:c+p,y:o*I})}let D=`M${d[0].x},${d[0].y}`;for(let o=0;o<d.length-1;o++){const p=d[o],i=d[o+1],f=(p.y+i.y)/2,b=o%2===0?1:-1,h=m*1.5*b*E(n+o*31+7),R=p.x+h,V=f,_=i.x-h;D+=` C${R},${V} ${_},${f} ${i.x},${i.y}`}return D}s(ct,"generateFoldPath");function lt(t,e,n,a){const c=e/2,m=a??e*.015,v=7,I=t/v,d=[];for(let o=0;o<=v;o++){const p=E(n+o*23)*m*2-m;d.push({x:o*I,y:c+p})}let D=`M${d[0].x},${d[0].y}`;for(let o=0;o<d.length-1;o++){const p=d[o],i=d[o+1],f=(p.x+i.x)/2,b=o%2===0?1:-1,h=m*1.5*b*E(n+o*37+11),R=f,V=p.y+h,_=f,z=i.y-h;D+=` C${R},${V} ${_},${z} ${i.x},${i.y}`}return D}s(lt,"generateHorizontalBoundary");function dt(t,e){const n=t/2,a=e*.5,c=e,m=t*.03;return[`M${n},${a}`,`C${n+m},${a+(c-a)*.2}`,`${n-m*1.5},${a+(c-a)*.55}`,`${n+m*.5},${a+(c-a)*.75}`,`C${n-m},${a+(c-a)*.85}`,`${n+m*.3},${a+(c-a)*.95}`,`${n},${c}`].join(" ")}s(dt,"generateCliffPath");function ft(t,e,n,a){return[`M${t-n},${e}`,`A${n},${a} 0 1,1 ${t+n},${e}`,`A${n},${a} 0 1,1 ${t-n},${e}`,"Z"].join(" ")}s(ft,"generateConfusionPath");var at={complex:{model:"Probe → Sense → Respond",practice:"Emergent Practices"},complicated:{model:"Sense → Analyse → Respond",practice:"Good Practices"},clear:{model:"Sense → Categorise → Respond",practice:"Best Practices"},chaotic:{model:"Act → Sense → Respond",practice:"Novel Practices"},confusion:{model:"",practice:"Disorder"}},Rt=s((t,e)=>{const n=t/2,a=e/2;return{complex:{cx:n/2,cy:a/2,x:0,y:0,w:n,h:a},complicated:{cx:n+n/2,cy:a/2,x:n,y:0,w:n,h:a},chaotic:{cx:n/2,cy:a+a/2,x:0,y:a,w:n,h:a},clear:{cx:n+n/2,cy:a+a/2,x:n,y:a,w:n,h:a},confusion:{cx:n,cy:a,x:n*.7,y:a*.7,w:n*.6,h:a*.6}}},"getDomainLayouts"),Vt=s(()=>{const t=ot(),e=Z();return U(t,e.themeVariables).cynefin},"getCynefinDomainColors"),q=3,_t=s((t,e,n,a)=>{const c=a.db,m=c.getDomains(),v=c.getTransitions(),I=c.getDiagramTitle(),d=c.getAccTitle(),D=c.getAccDescription(),o=c.getConfig(),p=Vt();O.debug("Rendering Cynefin diagram");const i=o.width,f=o.height,b=o.padding,h=o.showDomainDescriptions,R=o.boundaryAmplitude,V=i+b*2,_=f+b*2,z={complex:p.complexBg,complicated:p.complicatedBg,clear:p.clearBg,chaotic:p.chaoticBg,confusion:p.confusionBg},k=Dt(e);kt(k,_,V,o.useMaxWidth??!0),k.attr("viewBox",`0 0 ${V} ${_}`),d&&k.append("title").text(d),D&&k.append("desc").text(D);const T=k.append("g").attr("transform",`translate(${b}, ${b})`),F=Rt(i,f),Q=it(o.seed,e),mt=T.append("g").attr("class","cynefin-backgrounds"),X=["complex","complicated","chaotic","clear"];for(const l of X){const r=F[l];mt.append("rect").attr("class","cynefinDomain").attr("x",r.x).attr("y",r.y).attr("width",r.w).attr("height",r.h).attr("fill",z[l]).attr("fill-opacity",.4).attr("stroke","none")}const j=T.append("g").attr("class","cynefin-boundaries");j.append("path").attr("class","cynefinBoundary").attr("d",ct(i,f,Q,R)).attr("fill","none"),j.append("path").attr("class","cynefinBoundary").attr("d",lt(i,f,Q+100,R)).attr("fill","none"),j.append("path").attr("class","cynefinCliff").attr("d",dt(i,f)).attr("fill","none");const pt=i*.15,yt=f*.15;T.append("path").attr("class","cynefinConfusion").attr("d",ft(i/2,f/2,pt,yt)).attr("fill",z.confusion).attr("fill-opacity",.5);const J=T.append("g").attr("class","cynefin-labels");for(const l of X){const r=F[l];J.append("text").attr("class","cynefinDomainLabel").attr("x",r.cx).attr("y",h?r.cy-30:r.cy).attr("text-anchor","middle").attr("dominant-baseline","middle").text(l.charAt(0).toUpperCase()+l.slice(1))}if(J.append("text").attr("class","cynefinDomainLabel").attr("x",i/2).attr("y",h?f/2-10:f/2).attr("text-anchor","middle").attr("dominant-baseline","middle").text("Confusion"),h){const l=T.append("g").attr("class","cynefin-subtitles");for(const r of X){const u=F[r],y=at[r];l.append("text").attr("class","cynefinSubtitle").attr("x",u.cx).attr("y",u.cy-10).attr("text-anchor","middle").attr("dominant-baseline","middle").text(y.model),l.append("text").attr("class","cynefinSubtitle").attr("x",u.cx).attr("y",u.cy+5).attr("text-anchor","middle").attr("dominant-baseline","middle").text(y.practice)}l.append("text").attr("class","cynefinSubtitle").attr("x",i/2).attr("y",f/2+8).attr("text-anchor","middle").attr("dominant-baseline","middle").text(at.confusion.practice)}const K=T.append("g").attr("class","cynefin-items"),A=26,tt=10,ut=["complex","complicated","chaotic","clear","confusion"];for(const l of ut){const r=m.get(l);if(!r||r.items.length===0)continue;const u=F[l],y=l==="confusion";let L=r.items,N=0;y&&r.items.length>q&&(N=r.items.length-q,L=r.items.slice(0,q));let B;if(y){const g=h?22:14;B=u.cy+g}else B=u.cy+(h?25:15);if([...L].forEach((g,S)=>{const w=B+S*(A+4),M=K.append("g"),P=M.append("text").attr("class","cynefinItemText").attr("x",0).attr("y",A/2).attr("text-anchor","middle").attr("dominant-baseline","central").text(g.label);let $=g.label.length*7;const x=P.node();if(x&&typeof x.getBBox=="function"){const Y=x.getBBox();Y.width>0&&($=Y.width)}const C=$+tt*2,W=u.cx-C/2;M.attr("transform",`translate(${W}, ${w})`),M.insert("rect","text").attr("class","cynefinItem").attr("x",0).attr("y",0).attr("width",C).attr("height",A).attr("rx",4).attr("ry",4).attr("fill",z[l]).attr("fill-opacity",.95),P.attr("x",C/2).attr("y",A/2)}),N>0){const g=B+L.length*(A+4),S=`+${N} more`,w=K.append("g"),M=w.append("text").attr("class","cynefinItemText").attr("x",0).attr("y",A/2).attr("text-anchor","middle").attr("dominant-baseline","central").text(S);let P=S.length*7;const $=M.node();if($&&typeof $.getBBox=="function"){const W=$.getBBox();W.width>0&&(P=W.width)}const x=P+tt*2,C=u.cx-x/2;w.attr("transform",`translate(${C}, ${g})`),w.insert("rect","text").attr("class","cynefinItemOverflow").attr("x",0).attr("y",0).attr("width",x).attr("height",A).attr("rx",4).attr("ry",4).attr("fill",z[l]).attr("fill-opacity",.6),M.attr("x",x/2).attr("y",A/2)}}if(v.length>0){const l=k.select("defs").empty()?k.append("defs"):k.select("defs"),r=`cynefin-arrow-${e}`;l.append("marker").attr("id",r).attr("viewBox","0 0 10 10").attr("refX",9).attr("refY",5).attr("markerWidth",6).attr("markerHeight",6).attr("orient","auto-start-reverse").append("path").attr("d","M 0 0 L 10 5 L 0 10 z").attr("class","cynefinArrowHead");const u=T.append("g").attr("class","cynefin-arrows");v.forEach(y=>{const L=F[y.from],N=F[y.to];if(!L||!N)return;if(y.from===y.to){O.warn(`Cynefin renderer: skipping self-loop on domain "${y.from}"`);return}const B=L.cx,g=L.cy,S=N.cx,w=N.cy,M=(B+S)/2,P=(g+w)/2,$=S-B,x=w-g,C=Math.sqrt($*$+x*x),W=C*.15,Y=-x/C,ht=$/C,et=M+Y*W,nt=P+ht*W;u.append("path").attr("class","cynefinArrowLine").attr("d",`M${B},${g} Q${et},${nt} ${S},${w}`).attr("fill","none").attr("marker-end",`url(#${r})`),y.label&&u.append("text").attr("class","cynefinArrowLabel").attr("x",et).attr("y",nt-6).attr("text-anchor","middle").attr("dominant-baseline","auto").text(y.label)})}I&&T.append("text").attr("class","cynefinTitle").attr("x",i/2).attr("y",-b/2).attr("text-anchor","middle").attr("dominant-baseline","middle").text(I)},"draw"),Ft={draw:_t},Et=s(()=>{const t=ot(),e=Z();return U(t,e.themeVariables).cynefin},"getCynefinTheme"),Ht=s(()=>{const t=Et();return`
2
2
  .cynefinDomain {
3
3
  stroke: none;
4
4
  }
@@ -1,4 +1,4 @@
1
- import{b as p,ay as C,aX as H,W as _,r as q,a6 as G,B as U,aV as j,X as K}from"./D-usBtmP.js";var A="",M="",O="",D=[],b=new Map,v=p(e=>j(e,K()),"sanitizeText"),y=p(e=>{switch(e.type){case"terminal":return{...e,value:v(e.value)};case"nonterminal":return{...e,name:v(e.name)};case"sequence":return{...e,elements:e.elements.map(y)};case"choice":return{...e,alternatives:e.alternatives.map(y)};case"optional":return{...e,element:y(e.element)};case"repetition":return{...e,element:y(e.element),separator:e.separator?y(e.separator):void 0};case"special":return{...e,text:v(e.text)}}},"sanitizeAstNode"),J=p(()=>{A="",M="",O="",D.length=0,b.clear(),q(),C.debug("[Railroad] Database cleared")},"clear"),Y=p(e=>{A=v(e),C.debug("[Railroad] Title set:",e)},"setTitle"),P=p(()=>A,"getTitle"),Q=p(e=>{const i={...e,name:v(e.name),definition:y(e.definition),comment:e.comment?v(e.comment):void 0};C.debug("[Railroad] Adding rule:",i.name),b.has(i.name)&&C.warn(`[Railroad] Rule '${i.name}' is already defined. Overwriting.`),D.push(i),b.set(i.name,i)},"addRule"),Z=p(()=>D,"getRules"),V=p(e=>b.get(e),"getRule"),ee=p(e=>{M=v(e).replace(/^\s+/g,""),C.debug("[Railroad] Accessibility title set:",e)},"setAccTitle"),te=p(()=>M,"getAccTitle"),re=p(e=>{O=v(e).replace(/\n\s+/g,`
1
+ import{b as p,ay as C,aX as H,W as _,r as q,a6 as G,B as U,aV as j,X as K}from"./BpXYSrHL.js";var A="",M="",O="",D=[],b=new Map,v=p(e=>j(e,K()),"sanitizeText"),y=p(e=>{switch(e.type){case"terminal":return{...e,value:v(e.value)};case"nonterminal":return{...e,name:v(e.name)};case"sequence":return{...e,elements:e.elements.map(y)};case"choice":return{...e,alternatives:e.alternatives.map(y)};case"optional":return{...e,element:y(e.element)};case"repetition":return{...e,element:y(e.element),separator:e.separator?y(e.separator):void 0};case"special":return{...e,text:v(e.text)}}},"sanitizeAstNode"),J=p(()=>{A="",M="",O="",D.length=0,b.clear(),q(),C.debug("[Railroad] Database cleared")},"clear"),Y=p(e=>{A=v(e),C.debug("[Railroad] Title set:",e)},"setTitle"),P=p(()=>A,"getTitle"),Q=p(e=>{const i={...e,name:v(e.name),definition:y(e.definition),comment:e.comment?v(e.comment):void 0};C.debug("[Railroad] Adding rule:",i.name),b.has(i.name)&&C.warn(`[Railroad] Rule '${i.name}' is already defined. Overwriting.`),D.push(i),b.set(i.name,i)},"addRule"),Z=p(()=>D,"getRules"),V=p(e=>b.get(e),"getRule"),ee=p(e=>{M=v(e).replace(/^\s+/g,""),C.debug("[Railroad] Accessibility title set:",e)},"setAccTitle"),te=p(()=>M,"getAccTitle"),re=p(e=>{O=v(e).replace(/\n\s+/g,`
2
2
  `),C.debug("[Railroad] Accessibility description set:",e)},"setAccDescription"),ie=p(()=>O,"getAccDescription"),ae=Y,ne=P,oe={clear:J,setTitle:Y,getTitle:P,addRule:Q,getRules:Z,getRule:V,setAccTitle:ee,getAccTitle:te,setAccDescription:re,getAccDescription:ie,setDiagramTitle:ae,getDiagramTitle:ne},f={compactMode:!1,padding:10,verticalSeparation:8,horizontalSeparation:10,arcRadius:10,fontSize:14,fontFamily:"monospace",terminalFill:"#FFFFC0",terminalStroke:"#000000",terminalTextColor:"#000000",nonTerminalFill:"#FFFFFF",nonTerminalStroke:"#000000",nonTerminalTextColor:"#000000",lineColor:"#000000",strokeWidth:2,markerFill:"#000000",commentFill:"#E8E8E8",commentStroke:"#888888",commentTextColor:"#666666",specialFill:"#F0E0FF",specialStroke:"#8800CC",ruleNameColor:"#000066",showMarkers:!0,markerRadius:5},le=/^#(?:[\da-f]{3,4}|[\da-f]{6}|[\da-f]{8})$|^(?:rgb|rgba|hsl|hsla|hwb|lab|lch|oklab|oklch)\([\d\s%+,./-]+\)$|^[a-z]+$/i,se=/^[\w "',.-]+$/,de=new Set(["compactMode","padding","verticalSeparation","horizontalSeparation","arcRadius","fontSize","fontFamily","terminalFill","terminalStroke","terminalTextColor","nonTerminalFill","nonTerminalStroke","nonTerminalTextColor","lineColor","strokeWidth","markerFill","commentFill","commentStroke","commentTextColor","specialFill","specialStroke","ruleNameColor","showMarkers","markerRadius"]),L=p(e=>e?Object.keys(e).every(i=>i==="railroad"||de.has(i)):!1,"isRailroadStyleOptions"),ce=p(e=>e?"railroad"in e&&e.railroad?e.railroad:L(e)?e:{}:{},"extractRailroadOverrides"),me=p(e=>{if(!e||L(e))return{};const{railroad:i,svgId:n,theme:a,look:t,...r}=e;return r},"extractThemeOverrides"),m=p((e,i)=>{if(typeof e!="string")return i;const n=e.trim();return le.test(n)?n:i},"sanitizeColorValue"),X=p((e,i)=>{if(typeof e!="string")return i;const n=e.trim();return se.test(n)?n:i},"sanitizeFontFamilyValue"),F=p((e,i)=>{const n=typeof e=="number"?e:typeof e=="string"?Number.parseFloat(e):Number.NaN;return Number.isFinite(n)&&n>=0?n:i},"sanitizeNumberValue"),he=p(e=>{const i=typeof e=="number"?e:typeof e=="string"?Number.parseFloat(e):Number.NaN;return Number.isFinite(i)&&i>0?i:void 0},"parseThemeFontSize"),pe=p(e=>{const i=X(e.fontFamily,f.fontFamily),n=he(e.fontSize)??f.fontSize;return{...f,fontFamily:i,fontSize:n,terminalFill:m(e.secondBkg??e.secondaryColor,f.terminalFill),terminalStroke:m(e.secondaryBorderColor??e.lineColor,f.terminalStroke),terminalTextColor:m(e.secondaryTextColor??e.textColor,f.terminalTextColor),nonTerminalFill:m(e.mainBkg??e.background,f.nonTerminalFill),nonTerminalStroke:m(e.primaryBorderColor??e.lineColor,f.nonTerminalStroke),nonTerminalTextColor:m(e.primaryTextColor??e.textColor,f.nonTerminalTextColor),lineColor:m(e.lineColor,f.lineColor),markerFill:m(e.lineColor,f.markerFill),commentFill:m(e.labelBackground??e.tertiaryColor,f.commentFill),commentStroke:m(e.tertiaryBorderColor??e.lineColor,f.commentStroke),commentTextColor:m(e.tertiaryTextColor??e.textColor,f.commentTextColor),specialFill:m(e.tertiaryColor??e.secondaryColor,f.specialFill),specialStroke:m(e.tertiaryBorderColor??e.secondaryBorderColor,f.specialStroke),ruleNameColor:m(e.titleColor??e.textColor,f.ruleNameColor)}},"buildThemeDefaults"),E=p(e=>{const i=_(),n={...G(),...i.themeVariables??{},...me(e)},a=pe(n),t={...i.railroad??{},...ce(e)};return{compactMode:t.compactMode??a.compactMode,padding:F(t.padding,a.padding),verticalSeparation:F(t.verticalSeparation,a.verticalSeparation),horizontalSeparation:F(t.horizontalSeparation,a.horizontalSeparation),arcRadius:F(t.arcRadius,a.arcRadius),fontSize:F(t.fontSize,a.fontSize),fontFamily:X(t.fontFamily,a.fontFamily),terminalFill:m(t.terminalFill,a.terminalFill),terminalStroke:m(t.terminalStroke,a.terminalStroke),terminalTextColor:m(t.terminalTextColor,a.terminalTextColor),nonTerminalFill:m(t.nonTerminalFill,a.nonTerminalFill),nonTerminalStroke:m(t.nonTerminalStroke,a.nonTerminalStroke),nonTerminalTextColor:m(t.nonTerminalTextColor,a.nonTerminalTextColor),lineColor:m(t.lineColor,a.lineColor),strokeWidth:F(t.strokeWidth,a.strokeWidth),markerFill:m(t.markerFill,a.markerFill),commentFill:m(t.commentFill,a.commentFill),commentStroke:m(t.commentStroke,a.commentStroke),commentTextColor:m(t.commentTextColor,a.commentTextColor),specialFill:m(t.specialFill,a.specialFill),specialStroke:m(t.specialStroke,a.specialStroke),ruleNameColor:m(t.ruleNameColor,a.ruleNameColor),showMarkers:t.showMarkers??a.showMarkers,markerRadius:F(t.markerRadius,a.markerRadius)}},"buildRailroadStyleOptions"),Te=p(e=>{const{fontFamily:i,fontSize:n,terminalFill:a,terminalStroke:t,terminalTextColor:r,nonTerminalFill:o,nonTerminalStroke:g,nonTerminalTextColor:l,lineColor:s,strokeWidth:h,markerFill:u,commentFill:c,commentStroke:w,commentTextColor:d,specialFill:T,specialStroke:z,ruleNameColor:S}=E(e);return`
3
3
  .railroad-diagram {
4
4
  font-family: ${i};