@hienlh/ppm 0.19.5 → 0.19.7

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 (454) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/CLAUDE.md +15 -0
  3. package/assets/skills/ppm/SKILL.md +1 -1
  4. package/assets/skills/ppm/references/http-api.md +1 -1
  5. package/dist/web/assets/accounts-settings-section-D65EHybd.js +1 -0
  6. package/dist/web/assets/{ai-resource-editor-TVV8rOsT.js → ai-resource-editor-DmOGQ_1E.js} +1 -1
  7. package/dist/web/assets/{ai-settings-section-CutZAI-J.js → ai-settings-section-DP53HaV9.js} +1 -1
  8. package/dist/web/assets/{ai-settings-section-Whh5k2zL.js → ai-settings-section-Dlv_XYy3.js} +1 -1
  9. package/dist/web/assets/{angular-html-BuHNQIbQ.js → angular-html-C8nsn2VC.js} +1 -1
  10. package/dist/web/assets/{angular-ts-DHRWoLc-.js → angular-ts-Caw9nRCH.js} +1 -1
  11. package/dist/web/assets/{apl-C1VSWVei.js → apl-Dhu1LORF.js} +1 -1
  12. package/dist/web/assets/{appearance-settings-section-DbkXixUe.js → appearance-settings-section-WuJwZW7v.js} +1 -1
  13. package/dist/web/assets/architecture-PBZL5I3N-BZBxtErN.js +1 -0
  14. package/dist/web/assets/{astro-RX-rChsZ.js → astro-DwkX9sLZ.js} +1 -1
  15. package/dist/web/assets/{audio-preview-CCd1jdje.js → audio-preview-CkGZO8Uy.js} +1 -1
  16. package/dist/web/assets/{blade-CZ6bxMbK.js → blade-D1fC9Osx.js} +1 -1
  17. package/dist/web/assets/{bsl-BhgCXLWk.js → bsl-pur-PRip.js} +1 -1
  18. package/dist/web/assets/{cairo-BrwygPkn.js → cairo-DDJs9amR.js} +1 -1
  19. package/dist/web/assets/chat-tab-B3tKoaUT.js +15 -0
  20. package/dist/web/assets/{cobol-C5TGW1Ir.js → cobol-Bo0usdoM.js} +1 -1
  21. package/dist/web/assets/code-editor-8BjOSWul.js +7 -0
  22. package/dist/web/assets/{coffee-CFgKlmgI.js → coffee-DBBsbX1e.js} +1 -1
  23. package/dist/web/assets/{conflict-editor-B-HnPZX7.js → conflict-editor-D2JPf7dR.js} +1 -1
  24. package/dist/web/assets/{cpp-BhG5q3-d.js → cpp-6CTO78A-.js} +1 -1
  25. package/dist/web/assets/{crystal-DvuI7_tY.js → crystal-DAlvpAP7.js} +1 -1
  26. package/dist/web/assets/{csv-preview-CMIxkng3.js → csv-preview-DfHSVE7o.js} +1 -1
  27. package/dist/web/assets/{data-grid-overlay-editor-DP1xkog4.js → data-grid-overlay-editor-iRrpAV0e.js} +1 -1
  28. package/dist/web/assets/{database-viewer-CM6O4tar.js → database-viewer-BwSf-V1L.js} +1 -1
  29. package/dist/web/assets/{diff-viewer-nL4cAp1u.js → diff-viewer-CQU6j7uQ.js} +1 -1
  30. package/dist/web/assets/{edge-BSIEsmlI.js → edge-D0tZrpC7.js} +1 -1
  31. package/dist/web/assets/{edit-diff-preview-DeHb85DN.js → edit-diff-preview-DUgmjNre.js} +1 -1
  32. package/dist/web/assets/{elixir-BF-lrGXM.js → elixir-C1E6-o4G.js} +1 -1
  33. package/dist/web/assets/{elm-8mCsJOeN.js → elm-BKyTfeQX.js} +1 -1
  34. package/dist/web/assets/{erb-Dw5PUVKa.js → erb-Cdnr4BMI.js} +1 -1
  35. package/dist/web/assets/{erlang-BvjBIA6O.js → erlang-N1237mFq.js} +1 -1
  36. package/dist/web/assets/{esm-Bt9OwSnU.js → esm-ClNnmD9t.js} +1 -1
  37. package/dist/web/assets/{explorer-body-CuLBY282.js → explorer-body-B2FmdPAx.js} +2 -2
  38. package/dist/web/assets/{explorer-window-content-Cr8HYEIZ.js → explorer-window-content-CtSMepys.js} +1 -1
  39. package/dist/web/assets/{extension-manager-section-D_E1LteV.js → extension-manager-section-CBRXxG8W.js} +1 -1
  40. package/dist/web/assets/{extension-webview-BKVWrl6R.js → extension-webview-yfMof39w.js} +1 -1
  41. package/dist/web/assets/{files-settings-section-DzuWb19a.js → files-settings-section-Dxn0H4jj.js} +1 -1
  42. package/dist/web/assets/{fortran-fixed-form-CRjUJe9K.js → fortran-fixed-form-D_f9tVv0.js} +1 -1
  43. package/dist/web/assets/{fsharp-CjUIHIHp.js → fsharp-DEJmdhc2.js} +1 -1
  44. package/dist/web/assets/{gdresource-x_NUQFrZ.js → gdresource-Dmmrx2gP.js} +1 -1
  45. package/dist/web/assets/general-settings-section-C3ccyyOe.js +1 -0
  46. package/dist/web/assets/{git-commit-BOpxSbns.js → git-commit-qwJ867ig.js} +1 -1
  47. package/dist/web/assets/{git-log-panel-DRLGWrO2.js → git-log-panel-d2XBsNFP.js} +1 -1
  48. package/dist/web/assets/{git-rebase-BW4xlK7k.js → git-rebase-Dkv8Zw86.js} +1 -1
  49. package/dist/web/assets/gitGraph-HDMCJU4V-BHxJbXfV.js +1 -0
  50. package/dist/web/assets/{glide-data-grid-CUtOJQyB.js → glide-data-grid-5Un6IKEP.js} +7 -7
  51. package/dist/web/assets/{glimmer-js-CT9jrmFj.js → glimmer-js-CcrXn8lQ.js} +1 -1
  52. package/dist/web/assets/{glimmer-ts-CjQT1lxK.js → glimmer-ts-CLab3lU7.js} +1 -1
  53. package/dist/web/assets/{glsl-DsFJvtg5.js → glsl-DXhkG9dU.js} +1 -1
  54. package/dist/web/assets/{graphql-Dhlnmkn_.js → graphql-Cuqsx8r3.js} +1 -1
  55. package/dist/web/assets/group-chat-tab-COcbheaZ.js +1 -0
  56. package/dist/web/assets/{hack-BKHbsJ7u.js → hack-C_CBVdBc.js} +1 -1
  57. package/dist/web/assets/{haml-C1Ih25Y2.js → haml-CBWfzZpv.js} +1 -1
  58. package/dist/web/assets/{handlebars-CaFitvmC.js → handlebars-4e8OR-VI.js} +1 -1
  59. package/dist/web/assets/{html-BwpKIE6V.js → html-C5X4urn_.js} +1 -1
  60. package/dist/web/assets/{html-derivative-uuTEquZU.js → html-derivative-nH-jXfsL.js} +1 -1
  61. package/dist/web/assets/{http-Cv4Pg5cR.js → http-CQgaG7eu.js} +1 -1
  62. package/dist/web/assets/{hurl-DubkI6TG.js → hurl-B8gidJhu.js} +1 -1
  63. package/dist/web/assets/{hxml-B9OVZFAB.js → hxml-BAK94GX8.js} +1 -1
  64. package/dist/web/assets/{image-preview-DRbZ0FA2.js → image-preview-1kGj4W9R.js} +1 -1
  65. package/dist/web/assets/{index-C_s5DxFQ.js → index-DB-bD6Cx.js} +24 -24
  66. package/dist/web/assets/index-N-pnuwFP.css +2 -0
  67. package/dist/web/assets/info-3K5VOQVL-DI4p3vbH.js +1 -0
  68. package/dist/web/assets/{jinja-BHb1jyl6.js → jinja-BuAjvj8M.js} +1 -1
  69. package/dist/web/assets/{jira-watcher-section-B2-_4QW_.js → jira-watcher-section-BmDvZZ76.js} +1 -1
  70. package/dist/web/assets/{jison-CtpfXDzp.js → jison-Dhhs26-L.js} +1 -1
  71. package/dist/web/assets/{julia-TYjgpazU.js → julia-gZavIyll.js} +1 -1
  72. package/dist/web/assets/{just-D27bzZuW.js → just-DDHrFReO.js} +1 -1
  73. package/dist/web/assets/{keybindings-store-ehg0D6FR.js → keybindings-store-DAMW7K3e.js} +1 -1
  74. package/dist/web/assets/{keyboard-shortcuts-section-DMVcFwLJ.js → keyboard-shortcuts-section-BsZKKzf2.js} +1 -1
  75. package/dist/web/assets/{latex-D_MzopTn.js → latex-BdGZa8ov.js} +1 -1
  76. package/dist/web/assets/{liquid-BG_FG0Pe.js → liquid-urFfd9Fr.js} +1 -1
  77. package/dist/web/assets/{lua-Bl29oC2L.js → lua-CcS6tnB5.js} +1 -1
  78. package/dist/web/assets/{markdown-renderer-pDOFHEG7.js → markdown-renderer-BtrHvth9.js} +3 -3
  79. package/dist/web/assets/{markdown-renderer-CKIBtz-k.js → markdown-renderer-Dy4Vz3VW.js} +1 -1
  80. package/dist/web/assets/{marko-D-HI7dbm.js → marko-CSQqk4oG.js} +1 -1
  81. package/dist/web/assets/{mdc-y444JQTQ.js → mdc-CYIe80m_.js} +1 -1
  82. package/dist/web/assets/{mobile-bottom-sheet-BD5b7KJF.js → mobile-bottom-sheet-B3uDlD79.js} +1 -1
  83. package/dist/web/assets/{mobile-explorer-sheet-DFGPwNp0.js → mobile-explorer-sheet-BL1t1Ptr.js} +1 -1
  84. package/dist/web/assets/{nextflow-C5sKcldC.js → nextflow-C-W8vX8I.js} +1 -1
  85. package/dist/web/assets/{nginx-bXnEC3wm.js → nginx-COGi5you.js} +1 -1
  86. package/dist/web/assets/{nim-pevhf4WD.js → nim-CPitYGel.js} +1 -1
  87. package/dist/web/assets/{notification-store-CwLJtN2t.js → notification-store-DIwuBHMP.js} +1 -1
  88. package/dist/web/assets/{notifications-settings-section-C66s2JId.js → notifications-settings-section-CpnG8Ep4.js} +1 -1
  89. package/dist/web/assets/{number-overlay-editor-B7WINIW4.js → number-overlay-editor-C_eD-Bdr.js} +1 -1
  90. package/dist/web/assets/{overview-panel-mhN0qw6Q.js → overview-panel-Cm2HRtEz.js} +1 -1
  91. package/dist/web/assets/packet-RMMSAZCW-YNQWTi_-.js +1 -0
  92. package/dist/web/assets/{pdf-preview-0AwTBfeC.js → pdf-preview-9Olujr_E.js} +1 -1
  93. package/dist/web/assets/{perl-B1KUtMnW.js → perl-B0yW3hbb.js} +1 -1
  94. package/dist/web/assets/{php-BGmVZBAJ.js → php-BNMYN5Jp.js} +1 -1
  95. package/dist/web/assets/pie-UPGHQEXC-E3Wiw76n.js +1 -0
  96. package/dist/web/assets/{postgres-viewer-hDHYMHmG.js → postgres-viewer-qQtI_Qan.js} +3 -3
  97. package/dist/web/assets/{ppmbot-settings-section-DV6TMOfs.js → ppmbot-settings-section-C_yNqYo1.js} +1 -1
  98. package/dist/web/assets/{process-table-CmvwqGrQ.js → process-table-DH95ASxx.js} +1 -1
  99. package/dist/web/assets/proxy-settings-section-7OpR2hAD.js +1 -0
  100. package/dist/web/assets/{pug-BfN8CpEH.js → pug-CP5fxsxD.js} +1 -1
  101. package/dist/web/assets/{qml-D6fRdLZt.js → qml-CHGpQosY.js} +1 -1
  102. package/dist/web/assets/{query-audit-section-BgXdBaE1.js → query-audit-section-CHncxP-Z.js} +1 -1
  103. package/dist/web/assets/radar-KQ55EAFF-BPQJUKON.js +1 -0
  104. package/dist/web/assets/{razor-fg-9AScR.js → razor-Cfe0AYo4.js} +1 -1
  105. package/dist/web/assets/remote-desktop-mobile-sheet-Db21Gh-Y.js +2 -0
  106. package/dist/web/assets/{remote-desktop-mobile-view-DO5NJufM.js → remote-desktop-mobile-view-CiKtuPVS.js} +1 -1
  107. package/dist/web/assets/{remote-desktop-readiness-gate-CODu8fsP.js → remote-desktop-readiness-gate-BSBIPU4d.js} +1 -1
  108. package/dist/web/assets/{remote-desktop-window-content-DVhp7Y9T.js → remote-desktop-window-content-CJOxXllZ.js} +1 -1
  109. package/dist/web/assets/{rst-BZgx076b.js → rst-DxSSGshb.js} +1 -1
  110. package/dist/web/assets/{ruby-iUkWDcLo.js → ruby-rbK5SsJa.js} +1 -1
  111. package/dist/web/assets/{sas-CLXO0lZ6.js → sas-DDM28fbb.js} +1 -1
  112. package/dist/web/assets/schedules-settings-section-Q5X3kNJ8.js +1 -0
  113. package/dist/web/assets/{scss-DQqteGaG.js → scss-TDl-6ro4.js} +1 -1
  114. package/dist/web/assets/settings-body-5804QGDH.js +2 -0
  115. package/dist/web/assets/settings-store-DWUx3865.js +2 -0
  116. package/dist/web/assets/settings-tab-DgJP4K6b.js +1 -0
  117. package/dist/web/assets/settings-window-content-lyNwahx3.js +1 -0
  118. package/dist/web/assets/{shaderlab-CeMTqagR.js → shaderlab-CCvmDgGS.js} +1 -1
  119. package/dist/web/assets/{shellsession-BAkquZAV.js → shellsession-BzKS9yKh.js} +1 -1
  120. package/dist/web/assets/{soy-Bxm9Ez55.js → soy-QfO35nDh.js} +1 -1
  121. package/dist/web/assets/{sparql-C1phwdLc.js → sparql-D29RDfp2.js} +1 -1
  122. package/dist/web/assets/sql-query-editor-DH3H3gvx.js +1 -0
  123. package/dist/web/assets/{sqlite-viewer-Cy-H-h03.js → sqlite-viewer-DkmaTXae.js} +1 -1
  124. package/dist/web/assets/{stata-DGNMQdEb.js → stata-Be6j_SNv.js} +1 -1
  125. package/dist/web/assets/streaming-store-DDst3zA7.js +1 -0
  126. package/dist/web/assets/{surrealql-ByVrV320.js → surrealql-CykFjgNG.js} +1 -1
  127. package/dist/web/assets/{svelte-CNWjIMhl.js → svelte-CdBF8z4-.js} +1 -1
  128. package/dist/web/assets/system-monitor-body-KuahlPOb.js +2 -0
  129. package/dist/web/assets/system-monitor-tab-BK-nYh25.js +1 -0
  130. package/dist/web/assets/{system-monitor-window-content-5Kkti6yp.js → system-monitor-window-content-C5TkD158.js} +1 -1
  131. package/dist/web/assets/{tab-host-window-content-BnwmQM0I.js → tab-host-window-content-BwDnxvbx.js} +1 -1
  132. package/dist/web/assets/team-member-sheet-Cg82OxYB.js +2 -0
  133. package/dist/web/assets/{team-member-window-content-CHevmy9F.js → team-member-window-content-FxBRzgMW.js} +1 -1
  134. package/dist/web/assets/{templ-Cf0gQL4I.js → templ-BVHE2CNb.js} +1 -1
  135. package/dist/web/assets/{terminal-tab-DVb1AfrI.js → terminal-tab-Bro7kJBK.js} +2 -2
  136. package/dist/web/assets/{tex-BTIqPw_R.js → tex-C8XwrbBw.js} +1 -1
  137. package/dist/web/assets/{tool-cards-DIF_JcFj.js → tool-cards-BDmz33Y9.js} +5 -5
  138. package/dist/web/assets/treemap-KZPCXAKY-C2CvKBQR.js +1 -0
  139. package/dist/web/assets/{ts-tags-B8dN_Yf6.js → ts-tags-BIHk5AM0.js} +1 -1
  140. package/dist/web/assets/{twig-BgemonbJ.js → twig-YcE6Q2Ox.js} +1 -1
  141. package/dist/web/assets/{use-accounts-data--JHaCIoT.js → use-accounts-data-CvfdFWm3.js} +1 -1
  142. package/dist/web/assets/use-monaco-theme-D3Owwbo5.js +1 -0
  143. package/dist/web/assets/{use-remote-desktop-display-choice-DJFX_arw.js → use-remote-desktop-display-choice-DOg4xZ-8.js} +1 -1
  144. package/dist/web/assets/{use-websocket-DufdN3ZA.js → use-websocket-4y-ICdd7.js} +1 -1
  145. package/dist/web/assets/{vendor-mermaid-BKWscKt0.js → vendor-mermaid-CKKtYuTV.js} +1 -1
  146. package/dist/web/assets/{video-preview-DExfNDxI.js → video-preview-C70-MurL.js} +1 -1
  147. package/dist/web/assets/{vue-html-DYEQFAiK.js → vue-html-D1y9feOj.js} +1 -1
  148. package/dist/web/assets/{vue-D3D4lbXz.js → vue-q7m01V0h.js} +1 -1
  149. package/dist/web/assets/{vue-vine-D0OPNscN.js → vue-vine-DrIGs03v.js} +1 -1
  150. package/dist/web/assets/{xml-DHaWgpya.js → xml-oyvc1920.js} +1 -1
  151. package/dist/web/assets/{xsl-DVRN8JsA.js → xsl-BbIGdNPF.js} +1 -1
  152. package/dist/web/index.html +12 -11
  153. package/dist/web/sw.js +1 -1
  154. package/package.json +1 -1
  155. package/src/providers/registry.ts +6 -2
  156. package/src/server/routes/proxy.ts +6 -4
  157. package/src/server/routes/settings.ts +1 -0
  158. package/src/services/config.service.ts +28 -0
  159. package/src/services/db.service.ts +6 -0
  160. package/src/web/app.tsx +8 -0
  161. package/src/web/components/layout/status-bar.tsx +3 -0
  162. package/src/web/components/layout/wake-lock-indicator.tsx +50 -0
  163. package/src/web/components/settings/accounts/account-bucket-row.tsx +4 -4
  164. package/src/web/components/settings/accounts/codex-accounts-section.tsx +2 -8
  165. package/src/web/components/settings/accounts/codex-usage-rows.tsx +26 -0
  166. package/src/web/components/settings/accounts/use-codex-accounts.ts +12 -1
  167. package/src/web/components/settings/general-settings-section.tsx +37 -3
  168. package/src/web/components/settings/proxy-settings-section.tsx +27 -13
  169. package/src/web/components/settings/proxy-test-section.tsx +45 -17
  170. package/src/web/hooks/use-wake-lock.ts +148 -0
  171. package/src/web/lib/proxy-endpoints.ts +39 -0
  172. package/src/web/stores/settings-store.ts +12 -0
  173. package/src/web/stores/wake-lock-store.ts +21 -0
  174. package/dist/web/assets/accounts-settings-section-CmLGNwUl.js +0 -1
  175. package/dist/web/assets/architecture-PBZL5I3N-Ca5IpdzP.js +0 -1
  176. package/dist/web/assets/chat-tab-BYuPaeUJ.js +0 -15
  177. package/dist/web/assets/code-editor-4Lk47HbX.js +0 -7
  178. package/dist/web/assets/general-settings-section-c096J38r.js +0 -1
  179. package/dist/web/assets/gitGraph-HDMCJU4V-BloZfB0Q.js +0 -1
  180. package/dist/web/assets/group-chat-tab-Cano41wo.js +0 -1
  181. package/dist/web/assets/index-nP3uxXvR.css +0 -2
  182. package/dist/web/assets/info-3K5VOQVL-c0W8wp5o.js +0 -1
  183. package/dist/web/assets/packet-RMMSAZCW-D_BoHr_M.js +0 -1
  184. package/dist/web/assets/pie-UPGHQEXC-BaLfuEf8.js +0 -1
  185. package/dist/web/assets/proxy-settings-section-DjtXwOV_.js +0 -1
  186. package/dist/web/assets/radar-KQ55EAFF-DBIZEaIU.js +0 -1
  187. package/dist/web/assets/remote-desktop-mobile-sheet-Cakf7i6s.js +0 -2
  188. package/dist/web/assets/schedules-settings-section-IfwILuXE.js +0 -1
  189. package/dist/web/assets/settings-body-NYJVObzu.js +0 -2
  190. package/dist/web/assets/settings-store-Brjd0QnO.js +0 -2
  191. package/dist/web/assets/settings-tab-CPOI69SL.js +0 -1
  192. package/dist/web/assets/settings-window-content-BuuLt4qg.js +0 -1
  193. package/dist/web/assets/sql-query-editor-BSwL4jf9.js +0 -1
  194. package/dist/web/assets/system-monitor-body-B3jG3f5P.js +0 -2
  195. package/dist/web/assets/system-monitor-tab-Dt4wtPR0.js +0 -1
  196. package/dist/web/assets/team-member-sheet-B4TEEtVT.js +0 -2
  197. package/dist/web/assets/treemap-KZPCXAKY-DFiG9UYW.js +0 -1
  198. package/dist/web/assets/use-monaco-theme-xqDIVJcg.js +0 -1
  199. /package/dist/web/assets/{abap-h3QyH8MW.js → abap-Cq9nYQyd.js} +0 -0
  200. /package/dist/web/assets/{actionscript-3-mkxkq-FN.js → actionscript-3-DL8rUIy0.js} +0 -0
  201. /package/dist/web/assets/{ada-DhISK_EH.js → ada-BY8TLuhY.js} +0 -0
  202. /package/dist/web/assets/{andromeeda-DnlWWesX.js → andromeeda-CyVfHsS0.js} +0 -0
  203. /package/dist/web/assets/{apache-P5AK3sfA.js → apache-DTQUy73x.js} +0 -0
  204. /package/dist/web/assets/{apex-CJUPehg2.js → apex-CiSZngrZ.js} +0 -0
  205. /package/dist/web/assets/{api-settings-CTMdz_VF.js → api-settings-BVfemzZW.js} +0 -0
  206. /package/dist/web/assets/{api-themes-Cknp3Q-P.js → api-themes-BoOJPqwM.js} +0 -0
  207. /package/dist/web/assets/{applescript-Dx6GGbay.js → applescript-CzuRDd3h.js} +0 -0
  208. /package/dist/web/assets/{apply-theme-DxTXOAcV.js → apply-theme-r8tKDrCR.js} +0 -0
  209. /package/dist/web/assets/{ara-95Kx3qKb.js → ara-CSFV93kR.js} +0 -0
  210. /package/dist/web/assets/{asciidoc-Dp0RbIej.js → asciidoc-hOQNnXhz.js} +0 -0
  211. /package/dist/web/assets/{asm-C82coUjU.js → asm-DdG53NGR.js} +0 -0
  212. /package/dist/web/assets/{aurora-x-BFc3zeop.js → aurora-x-DJ7ORZG6.js} +0 -0
  213. /package/dist/web/assets/{awk-ChjC0icr.js → awk-B3FFpX_J.js} +0 -0
  214. /package/dist/web/assets/{ayu-dark-DYfUf_PB.js → ayu-dark-D_P1CfTe.js} +0 -0
  215. /package/dist/web/assets/{ayu-light-Bh6O0plO.js → ayu-light-Cz3YLUqH.js} +0 -0
  216. /package/dist/web/assets/{ayu-mirage-DlNhHTGq.js → ayu-mirage-JcMq5tgJ.js} +0 -0
  217. /package/dist/web/assets/{ballerina-Ceoll3Sk.js → ballerina-7Hs4Rfpk.js} +0 -0
  218. /package/dist/web/assets/{bat-C7QS6Lfq.js → bat-COgQdnFA.js} +0 -0
  219. /package/dist/web/assets/{beancount-5NMEAZgs.js → beancount-BJ3CutBG.js} +0 -0
  220. /package/dist/web/assets/{berry-BBL83Vbk.js → berry-D7so2Cui.js} +0 -0
  221. /package/dist/web/assets/{bibtex-L7rPkPSG.js → bibtex-Ct3acHa1.js} +0 -0
  222. /package/dist/web/assets/{bicep-BOwHIINh.js → bicep-jXDwCQcm.js} +0 -0
  223. /package/dist/web/assets/{bird2-CWLsMom2.js → bird2-CjLD2cna.js} +0 -0
  224. /package/dist/web/assets/{button-BZtEJcUv.js → button-2WCAS8dI.js} +0 -0
  225. /package/dist/web/assets/{c-CD4Ku5Cr.js → c-CdgZojnL.js} +0 -0
  226. /package/dist/web/assets/{c3-CpMl-w3G.js → c3-DtpZYego.js} +0 -0
  227. /package/dist/web/assets/{cadence-CvgF6ehN.js → cadence-CPLkixoh.js} +0 -0
  228. /package/dist/web/assets/{can-open-in-ppm-j3jh7fUo.js → can-open-in-ppm-BntPywsy.js} +0 -0
  229. /package/dist/web/assets/{catppuccin-frappe-eo_dTm3F.js → catppuccin-frappe-Xt0_qJa9.js} +0 -0
  230. /package/dist/web/assets/{catppuccin-latte-DoiMCU_7.js → catppuccin-latte-CJnbLec5.js} +0 -0
  231. /package/dist/web/assets/{catppuccin-macchiato-UQxsK2Vh.js → catppuccin-macchiato-BPHP1wYB.js} +0 -0
  232. /package/dist/web/assets/{catppuccin-mocha-J0i-8RNy.js → catppuccin-mocha-ssWJodGc.js} +0 -0
  233. /package/dist/web/assets/{clarity-DXYM8-SA.js → clarity-DB0408F6.js} +0 -0
  234. /package/dist/web/assets/{clojure-DzamsL69.js → clojure-dpRPlAO4.js} +0 -0
  235. /package/dist/web/assets/{cmake-CR6RP_T_.js → cmake-r2VkeX9y.js} +0 -0
  236. /package/dist/web/assets/{codeowners-D1s6-IyY.js → codeowners-v5nQqHiB.js} +0 -0
  237. /package/dist/web/assets/{codeql-DAqNWMkS.js → codeql-BSSEhKRR.js} +0 -0
  238. /package/dist/web/assets/{common-lisp-8e-KtitB.js → common-lisp-BXb2MMMA.js} +0 -0
  239. /package/dist/web/assets/{coq-UEq0WUcO.js → coq-BjBNi73X.js} +0 -0
  240. /package/dist/web/assets/{csharp-wxJ0TuCm.js → csharp-CdPjZRbV.js} +0 -0
  241. /package/dist/web/assets/{css-Cerub-yB.js → css-BuxbQOHL.js} +0 -0
  242. /package/dist/web/assets/{csv-Bh9_WD_h.js → csv-Dj-eoZwH.js} +0 -0
  243. /package/dist/web/assets/{csv-parser-BPIDt6ni.js → csv-parser-CBbALsFU.js} +0 -0
  244. /package/dist/web/assets/{cue-rzM1ztqU.js → cue-Dz73VksN.js} +0 -0
  245. /package/dist/web/assets/{cypher-DGaTQ8m0.js → cypher-CkVkDywZ.js} +0 -0
  246. /package/dist/web/assets/{d-DbkZGuhB.js → d-oU51Pbpf.js} +0 -0
  247. /package/dist/web/assets/{dark-plus-BO2bzZcA.js → dark-plus-DcwvjjfO.js} +0 -0
  248. /package/dist/web/assets/{dart-BDhCoqVg.js → dart-DGvu8mcX.js} +0 -0
  249. /package/dist/web/assets/{data-grid-types-CdAg-4W1.js → data-grid-types-B6kUrF-M.js} +0 -0
  250. /package/dist/web/assets/{dax-Bh03stWh.js → dax-BmbjKQ90.js} +0 -0
  251. /package/dist/web/assets/{desktop-BOdr_fwq.js → desktop-IRBSiFfh.js} +0 -0
  252. /package/dist/web/assets/{diff-Bb_gTsS2.js → diff-Bdik2JR8.js} +0 -0
  253. /package/dist/web/assets/{dist-DonmFWG8.js → dist-Bv4zQpS1.js} +0 -0
  254. /package/dist/web/assets/{dist-BUMDu0av.js → dist-C8YPBIOb.js} +0 -0
  255. /package/dist/web/assets/{docker-BDsTF5ce.js → docker-Bgdl0H8I.js} +0 -0
  256. /package/dist/web/assets/{docx-preview-CWIDVNZn.js → docx-preview-Bgw838ry.js} +0 -0
  257. /package/dist/web/assets/{dotenv-CbCWp9Ti.js → dotenv-COe5NdnA.js} +0 -0
  258. /package/dist/web/assets/{dracula-Cd1fxvoX.js → dracula-DjURaSAa.js} +0 -0
  259. /package/dist/web/assets/{dracula-soft-B7eXkfXG.js → dracula-soft-Do7d0bo-.js} +0 -0
  260. /package/dist/web/assets/{dream-maker-XlzuS21R.js → dream-maker-DYwQvJIj.js} +0 -0
  261. /package/dist/web/assets/{emacs-lisp-CXV1Ki_7.js → emacs-lisp-BXjlHyDW.js} +0 -0
  262. /package/dist/web/assets/{everforest-dark-DuqR60Dg.js → everforest-dark-h8Q2loiX.js} +0 -0
  263. /package/dist/web/assets/{everforest-light-q4BPnenD.js → everforest-light-CdsJiL-9.js} +0 -0
  264. /package/dist/web/assets/{fennel-B-e0TX2Q.js → fennel-D0CBtOvY.js} +0 -0
  265. /package/dist/web/assets/{fish-Bzb6-TtF.js → fish-DzayfrMj.js} +0 -0
  266. /package/dist/web/assets/{fluent-B-szH2-f.js → fluent-CatjkUfx.js} +0 -0
  267. /package/dist/web/assets/{format-bytes-CKXk9k2d.js → format-bytes-BulRSULX.js} +0 -0
  268. /package/dist/web/assets/{fortran-free-form-OS6SGYC0.js → fortran-free-form-DM04ud0b.js} +0 -0
  269. /package/dist/web/assets/{gdscript-FYq4OP2d.js → gdscript-BLN5iZwf.js} +0 -0
  270. /package/dist/web/assets/{gdshader-BpG6P8rw.js → gdshader-BK-1iZQs.js} +0 -0
  271. /package/dist/web/assets/{genie-BS9RLAna.js → genie-BGPOFWDN.js} +0 -0
  272. /package/dist/web/assets/{gherkin-B_9FdtGs.js → gherkin-CdVOJ_JY.js} +0 -0
  273. /package/dist/web/assets/{github-dark-cfaIlnBV.js → github-dark-B_xW8TaY.js} +0 -0
  274. /package/dist/web/assets/{github-dark-default-B2Wv65He.js → github-dark-default-h_iKq7CX.js} +0 -0
  275. /package/dist/web/assets/{github-dark-dimmed-CtM9X76s.js → github-dark-dimmed-nKDYE62T.js} +0 -0
  276. /package/dist/web/assets/{github-dark-high-contrast-DLHyk0tG.js → github-dark-high-contrast-l8I771QT.js} +0 -0
  277. /package/dist/web/assets/{github-light-DWEI10iG.js → github-light-DNhjkg8Z.js} +0 -0
  278. /package/dist/web/assets/{github-light-default-DcJkK1YN.js → github-light-default-DQ06uS3g.js} +0 -0
  279. /package/dist/web/assets/{github-light-high-contrast-Bcx9iKDt.js → github-light-high-contrast-qc2sZCVN.js} +0 -0
  280. /package/dist/web/assets/{gleam-DVpiM6b2.js → gleam-DPPatkNH.js} +0 -0
  281. /package/dist/web/assets/{gn-B80DNc0i.js → gn-BnzGQTy5.js} +0 -0
  282. /package/dist/web/assets/{gnuplot-D9i3MaT-.js → gnuplot-Ct1leoo3.js} +0 -0
  283. /package/dist/web/assets/{go-CwCBf_Pt.js → go-qysCdbrn.js} +0 -0
  284. /package/dist/web/assets/{groovy-D7mEfwmW.js → groovy-BkWIdrRQ.js} +0 -0
  285. /package/dist/web/assets/{gruvbox-dark-hard-C4R4MOoH.js → gruvbox-dark-hard-L6Iiybbl.js} +0 -0
  286. /package/dist/web/assets/{gruvbox-dark-medium-CZnFC0s8.js → gruvbox-dark-medium-DbD3yl0b.js} +0 -0
  287. /package/dist/web/assets/{gruvbox-dark-soft-DFcJlEBl.js → gruvbox-dark-soft-Ban2cHK3.js} +0 -0
  288. /package/dist/web/assets/{gruvbox-light-hard-B6IF_1L-.js → gruvbox-light-hard-CK_SjS3e.js} +0 -0
  289. /package/dist/web/assets/{gruvbox-light-medium-C19AZJv2.js → gruvbox-light-medium-Bjgvhc2w.js} +0 -0
  290. /package/dist/web/assets/{gruvbox-light-soft-BAnpDm9B.js → gruvbox-light-soft-EWnyYGUu.js} +0 -0
  291. /package/dist/web/assets/{haskell-CsXSYXRG.js → haskell-rT1N9nYr.js} +0 -0
  292. /package/dist/web/assets/{haxe-B1uyiI9t.js → haxe-Bbc91axo.js} +0 -0
  293. /package/dist/web/assets/{hcl-DlYKn5q9.js → hcl-D-3qJA4v.js} +0 -0
  294. /package/dist/web/assets/{hjson-C_0VMGJJ.js → hjson-DWtewcyQ.js} +0 -0
  295. /package/dist/web/assets/{hlsl-zt2PEzbg.js → hlsl-C7t6hCrO.js} +0 -0
  296. /package/dist/web/assets/{horizon-bright-CqI2qTim.js → horizon-bright-CRNyrJy8.js} +0 -0
  297. /package/dist/web/assets/{horizon-6wQfyOK0.js → horizon-zJAGUQ3j.js} +0 -0
  298. /package/dist/web/assets/{houston-BljpHDoG.js → houston-BFKa4W1-.js} +0 -0
  299. /package/dist/web/assets/{hy-XzuL55dw.js → hy-W1hNjMBM.js} +0 -0
  300. /package/dist/web/assets/{image-gallery-Cj8nd4xW.js → image-gallery-BycaVWOu.js} +0 -0
  301. /package/dist/web/assets/{imba-CqhhjBrP.js → imba-CPphaV-V.js} +0 -0
  302. /package/dist/web/assets/{ini-CiFDi6cY.js → ini-CayaZ4vW.js} +0 -0
  303. /package/dist/web/assets/{java-OsQgTL5-.js → java-BPAE_9Ej.js} +0 -0
  304. /package/dist/web/assets/{javascript-qWAOScxl.js → javascript-C5SKIVqe.js} +0 -0
  305. /package/dist/web/assets/{json-RiAKsaD1.js → json-C-0EUYmu.js} +0 -0
  306. /package/dist/web/assets/{json5-BeCnS3H2.js → json5-BqVetEZL.js} +0 -0
  307. /package/dist/web/assets/{jsonc-CbTW1Mka.js → jsonc-DnjIzkUB.js} +0 -0
  308. /package/dist/web/assets/{jsonl-BLSi_669.js → jsonl-rbV-3EqO.js} +0 -0
  309. /package/dist/web/assets/{jsonnet-C3xAggou.js → jsonnet-9hvXw4qr.js} +0 -0
  310. /package/dist/web/assets/{jssm-CLdiagC9.js → jssm-1ifXyIhu.js} +0 -0
  311. /package/dist/web/assets/{jsx-lYE1lb50.js → jsx-hPumywTY.js} +0 -0
  312. /package/dist/web/assets/{kanagawa-dragon-Cd1vcrpD.js → kanagawa-dragon-BCPjmoMO.js} +0 -0
  313. /package/dist/web/assets/{kanagawa-lotus-Dw3QKtk9.js → kanagawa-lotus-DN2VNjy7.js} +0 -0
  314. /package/dist/web/assets/{kanagawa-wave-DIq5Zv5G.js → kanagawa-wave-B8RZEsgc.js} +0 -0
  315. /package/dist/web/assets/{kdl-BfDV0825.js → kdl-CkvjWQIa.js} +0 -0
  316. /package/dist/web/assets/{kotlin-DONxR4wD.js → kotlin-D8cnRi5o.js} +0 -0
  317. /package/dist/web/assets/{kusto-BDP63Fh5.js → kusto-CmeeBEJG.js} +0 -0
  318. /package/dist/web/assets/{laserwave-BeBrWApL.js → laserwave--rtV8Mv9.js} +0 -0
  319. /package/dist/web/assets/{lean-DOZc0N1A.js → lean-CS-Pyi42.js} +0 -0
  320. /package/dist/web/assets/{less-C3H9NlDv.js → less-Ddi_7qGm.js} +0 -0
  321. /package/dist/web/assets/{lib-xrSJ4EZX.js → lib-DIrxSyLb.js} +0 -0
  322. /package/dist/web/assets/{libesm-DLBE59ul.js → libesm-CYLrAeW3.js} +0 -0
  323. /package/dist/web/assets/{light-plus-C_kTL608.js → light-plus-CrEjpkkX.js} +0 -0
  324. /package/dist/web/assets/{llvm-Dsp27U3P.js → llvm-Cm7ZXmAO.js} +0 -0
  325. /package/dist/web/assets/{log-BywQaTCy.js → log-lW2sYxtp.js} +0 -0
  326. /package/dist/web/assets/{logo-BirJgciO.js → logo-B-PiRb53.js} +0 -0
  327. /package/dist/web/assets/{luau-Btrz5kJB.js → luau-8St0pC-R.js} +0 -0
  328. /package/dist/web/assets/{make-Kl7nFQrS.js → make-DbNdhH54.js} +0 -0
  329. /package/dist/web/assets/{markdown-qsC4P8S-.js → markdown-CYocYSGd.js} +0 -0
  330. /package/dist/web/assets/{material-theme-CC__ui3p.js → material-theme-CVBF1Cbi.js} +0 -0
  331. /package/dist/web/assets/{material-theme-darker-D4FxG2FZ.js → material-theme-darker-HFrlNZD8.js} +0 -0
  332. /package/dist/web/assets/{material-theme-lighter-zGqiWcxn.js → material-theme-lighter-BM-uz2ft.js} +0 -0
  333. /package/dist/web/assets/{material-theme-ocean-CZIdTTB1.js → material-theme-ocean-PbvUez8m.js} +0 -0
  334. /package/dist/web/assets/{material-theme-palenight-CEIs0GcK.js → material-theme-palenight-B22Ck6qd.js} +0 -0
  335. /package/dist/web/assets/{matlab-Cf0aUjN9.js → matlab-GFFNzucw.js} +0 -0
  336. /package/dist/web/assets/{mdx-CIsXjH86.js → mdx-BVnJzMDx.js} +0 -0
  337. /package/dist/web/assets/{media-url-VzecHk9g.js → media-url-DBmHJRft.js} +0 -0
  338. /package/dist/web/assets/{mermaid-B06WO9Qc.js → mermaid-BlCmSTCM.js} +0 -0
  339. /package/dist/web/assets/{min-dark-z8fyp0FT.js → min-dark-B0PwlAfC.js} +0 -0
  340. /package/dist/web/assets/{min-light-Dr-qesbW.js → min-light-C_H2ABKu.js} +0 -0
  341. /package/dist/web/assets/{mipsasm-CWHzYLcE.js → mipsasm-C3rf2fo6.js} +0 -0
  342. /package/dist/web/assets/{mojo-D9zXrKmv.js → mojo-CDRuzM3o.js} +0 -0
  343. /package/dist/web/assets/{monokai-4b-AKOpX.js → monokai-KiebNy_Y.js} +0 -0
  344. /package/dist/web/assets/{moonbit-Dl4dhOZJ.js → moonbit-CdVUHoWl.js} +0 -0
  345. /package/dist/web/assets/{move-DTYKJmXy.js → move-Dq9iKZRY.js} +0 -0
  346. /package/dist/web/assets/{narrat-DnvXOS-o.js → narrat-7y5L5sGM.js} +0 -0
  347. /package/dist/web/assets/{nextflow-groovy-Di8QnEXg.js → nextflow-groovy-Cwcbkcrx.js} +0 -0
  348. /package/dist/web/assets/{night-owl-Czh0yq-H.js → night-owl-TBgLPzj4.js} +0 -0
  349. /package/dist/web/assets/{night-owl-light-D_OpZqOR.js → night-owl-light-Dehb9My2.js} +0 -0
  350. /package/dist/web/assets/{nix-2MvcjpK3.js → nix-BKj-gzoX.js} +0 -0
  351. /package/dist/web/assets/{nord-CG_r4cyk.js → nord-BF_r8PeX.js} +0 -0
  352. /package/dist/web/assets/{nushell-DINskMcU.js → nushell-CeAjk9_E.js} +0 -0
  353. /package/dist/web/assets/{objective-c-Dv7BIicR.js → objective-c-Xl1OMcDp.js} +0 -0
  354. /package/dist/web/assets/{objective-cpp-CpqsCxPb.js → objective-cpp-C4ZgzrRq.js} +0 -0
  355. /package/dist/web/assets/{ocaml-DwTsYSmW.js → ocaml-CGj8IYTq.js} +0 -0
  356. /package/dist/web/assets/{odin-G-4O4k4t.js → odin-C4veqvW2.js} +0 -0
  357. /package/dist/web/assets/{one-dark-pro-13Pv5SjI.js → one-dark-pro-gAcWejsV.js} +0 -0
  358. /package/dist/web/assets/{one-light-Bi2e86mS.js → one-light-B7E-UUXy.js} +0 -0
  359. /package/dist/web/assets/{openscad-D0WsOTij.js → openscad-C-wN9BEv.js} +0 -0
  360. /package/dist/web/assets/{pascal-DmDStuXr.js → pascal-C8WBtxMs.js} +0 -0
  361. /package/dist/web/assets/{pkl-Bl6Qjtuo.js → pkl-BBfF4G2A.js} +0 -0
  362. /package/dist/web/assets/{plastic-UeSVSjTI.js → plastic-DFOAb89P.js} +0 -0
  363. /package/dist/web/assets/{plsql-DreFC689.js → plsql-BS2CEMMV.js} +0 -0
  364. /package/dist/web/assets/{po-ZIjccxsX.js → po-BKJDtPmy.js} +0 -0
  365. /package/dist/web/assets/{poimandres-CvQHJPrI.js → poimandres-Cg3hL13e.js} +0 -0
  366. /package/dist/web/assets/{polar-BrMB0Kgh.js → polar-B9ebiXUU.js} +0 -0
  367. /package/dist/web/assets/{postcss-pgUsil1T.js → postcss-B5REwNY_.js} +0 -0
  368. /package/dist/web/assets/{powerquery-CTsZkCg_.js → powerquery-stc0Gzkf.js} +0 -0
  369. /package/dist/web/assets/{powershell-CcwVuBAp.js → powershell-jgd0ahJN.js} +0 -0
  370. /package/dist/web/assets/{prisma-spjnAI5W.js → prisma-CWuZjRhI.js} +0 -0
  371. /package/dist/web/assets/{prolog-ChCkZpDO.js → prolog-D5zNFE63.js} +0 -0
  372. /package/dist/web/assets/{proto-wVGqK4gB.js → proto-B-6RrU7n.js} +0 -0
  373. /package/dist/web/assets/{puppet-CED7iwPQ.js → puppet-DONP8TDR.js} +0 -0
  374. /package/dist/web/assets/{purescript-u9lGiQKV.js → purescript-DDJITf-A.js} +0 -0
  375. /package/dist/web/assets/{python-DeqTx6ef.js → python-bmWy9j1-.js} +0 -0
  376. /package/dist/web/assets/{qmldir-BH1uoPrX.js → qmldir-CKDwMt7X.js} +0 -0
  377. /package/dist/web/assets/{qss-CUVKA_13.js → qss-DptQQzBn.js} +0 -0
  378. /package/dist/web/assets/{r-BqdPzqYH.js → r-BorKpJ8r.js} +0 -0
  379. /package/dist/web/assets/{racket-C2eTgPN3.js → racket-BaHpYVsZ.js} +0 -0
  380. /package/dist/web/assets/{raku-uAay1sWx.js → raku-DFJIV4k_.js} +0 -0
  381. /package/dist/web/assets/{red-DTZP1ZfC.js → red-70oJGrkb.js} +0 -0
  382. /package/dist/web/assets/{reg-Cdk3YsxY.js → reg-C4g235Dv.js} +0 -0
  383. /package/dist/web/assets/{regexp-Bpa2aS7K.js → regexp-Cw1UVmti.js} +0 -0
  384. /package/dist/web/assets/{rel-bNsb1-3L.js → rel-DeLhIz5L.js} +0 -0
  385. /package/dist/web/assets/{resolve-theme-DQk_YcsT.js → resolve-theme-b_yGlUFQ.js} +0 -0
  386. /package/dist/web/assets/{riscv-DSaubByW.js → riscv-ChnTiBRK.js} +0 -0
  387. /package/dist/web/assets/{ron-DbQzYM6i.js → ron-C5IWeqDn.js} +0 -0
  388. /package/dist/web/assets/{rose-pine-C7RsprTu.js → rose-pine-DCR0ohYW.js} +0 -0
  389. /package/dist/web/assets/{rose-pine-dawn-VP976YzL.js → rose-pine-dawn-DvGZs1PR.js} +0 -0
  390. /package/dist/web/assets/{rose-pine-moon-XHZNhOqd.js → rose-pine-moon-BWACHjeS.js} +0 -0
  391. /package/dist/web/assets/{rosmsg-BVQlx0Lj.js → rosmsg-CQlIVazE.js} +0 -0
  392. /package/dist/web/assets/{run-in-terminal-bKRwuO2z.js → run-in-terminal-DHAvC1AG.js} +0 -0
  393. /package/dist/web/assets/{rust-VHaQ3rh3.js → rust-DGGVzWI8.js} +0 -0
  394. /package/dist/web/assets/{sass-CO-kMkwD.js → sass-bj1C0rFI.js} +0 -0
  395. /package/dist/web/assets/{scala-cY0GXkiz.js → scala-MU1tLKDi.js} +0 -0
  396. /package/dist/web/assets/{scheme-D4LNZE0X.js → scheme-CeGXtv7t.js} +0 -0
  397. /package/dist/web/assets/{sdbl-Bh2Fd2cn.js → sdbl-D0HLSGKp.js} +0 -0
  398. /package/dist/web/assets/{send-to-chat-S8LCNX7V.js → send-to-chat-BOyUWNKw.js} +0 -0
  399. /package/dist/web/assets/{separator-DqGg3f9c.js → separator-BzGoTlR7.js} +0 -0
  400. /package/dist/web/assets/{shellscript-KKclmCnt.js → shellscript-DkYiDvh1.js} +0 -0
  401. /package/dist/web/assets/{slack-dark-D6YQ-fqf.js → slack-dark-YqeHiGWH.js} +0 -0
  402. /package/dist/web/assets/{slack-ochin-CDf66CDj.js → slack-ochin-9Oe0DljJ.js} +0 -0
  403. /package/dist/web/assets/{smalltalk-D2OH_QIl.js → smalltalk-CaaxedR7.js} +0 -0
  404. /package/dist/web/assets/{snazzy-light-CQeF8G1K.js → snazzy-light-C8s2FHNC.js} +0 -0
  405. /package/dist/web/assets/{solarized-dark-LTPf1iLZ.js → solarized-dark-0ryY6oN3.js} +0 -0
  406. /package/dist/web/assets/{solarized-light-Ose1n88k.js → solarized-light-bltgZeNh.js} +0 -0
  407. /package/dist/web/assets/{solidity-lFuOMHki.js → solidity-DOf5HmLZ.js} +0 -0
  408. /package/dist/web/assets/{splunk-Bov-sB5S.js → splunk-D1u4WHDW.js} +0 -0
  409. /package/dist/web/assets/{sql-BKyZ6wmk.js → sql-G8uQZljX.js} +0 -0
  410. /package/dist/web/assets/{ssh-config-CqJoMGMb.js → ssh-config-rbXvly7Q.js} +0 -0
  411. /package/dist/web/assets/{stylus-Bf5pWRLI.js → stylus-Cii1iADy.js} +0 -0
  412. /package/dist/web/assets/{swift-D5d1hn_u.js → swift-DpIgonN4.js} +0 -0
  413. /package/dist/web/assets/{synthwave-84-B4c6YAgO.js → synthwave-84-DjGLzU2b.js} +0 -0
  414. /package/dist/web/assets/{system-verilog-D7fXyDsI.js → system-verilog-_Z0M0Hs1.js} +0 -0
  415. /package/dist/web/assets/{systemd-oNagzlBK.js → systemd-BhyDCh9P.js} +0 -0
  416. /package/dist/web/assets/{talonscript-C6Nqm9Dm.js → talonscript-CNchgCRD.js} +0 -0
  417. /package/dist/web/assets/{tasl-CaWy-cBX.js → tasl-m--W7Pyr.js} +0 -0
  418. /package/dist/web/assets/{tcl-C435P5Mq.js → tcl-gY-M_2BC.js} +0 -0
  419. /package/dist/web/assets/{terraform-CVDxqdPf.js → terraform-CB6CzMwo.js} +0 -0
  420. /package/dist/web/assets/{tokyo-night-Uhs17tQ3.js → tokyo-night-COh9oRYi.js} +0 -0
  421. /package/dist/web/assets/{toml-j6fPOJ6P.js → toml-Bg2bsY-v.js} +0 -0
  422. /package/dist/web/assets/{tsv-h78O6xrL.js → tsv-DceGDiJC.js} +0 -0
  423. /package/dist/web/assets/{tsx-Bol-vCrQ.js → tsx-EccDYa7i.js} +0 -0
  424. /package/dist/web/assets/{turtle-Dw8eFf04.js → turtle-C_l2JhvX.js} +0 -0
  425. /package/dist/web/assets/{typescript-Dtz7DPci.js → typescript-C1ytmMcr.js} +0 -0
  426. /package/dist/web/assets/{typespec-BIOQ7dMP.js → typespec-De2ztzG5.js} +0 -0
  427. /package/dist/web/assets/{typst-CoaGMjzu.js → typst-DNcS7gSr.js} +0 -0
  428. /package/dist/web/assets/{use-blob-url-Gfi69PtP.js → use-blob-url-De-ZtcpX.js} +0 -0
  429. /package/dist/web/assets/{use-open-team-member-CruUTqzD.js → use-open-team-member-DWhhWdmJ.js} +0 -0
  430. /package/dist/web/assets/{use-visual-viewport-rnvuooQZ.js → use-visual-viewport-D9O48HQt.js} +0 -0
  431. /package/dist/web/assets/{v-BoqFdpJ7.js → v-DSMUsdMO.js} +0 -0
  432. /package/dist/web/assets/{vala-COBpNnCC.js → vala-BEazLpkO.js} +0 -0
  433. /package/dist/web/assets/{vb-DxI86znh.js → vb-CV9pEJzW.js} +0 -0
  434. /package/dist/web/assets/{vendor-xterm-BaMOj65g.js → vendor-xterm-cuGQmUjN.js} +0 -0
  435. /package/dist/web/assets/{verilog-DcTAamuQ.js → verilog-DhXkLVMk.js} +0 -0
  436. /package/dist/web/assets/{vesper-DO298JSv.js → vesper-n4IltYq-.js} +0 -0
  437. /package/dist/web/assets/{vhdl-Dq-bDVSN.js → vhdl-CePjFbvs.js} +0 -0
  438. /package/dist/web/assets/{viml-zHTRWuQh.js → viml-ChndFsm5.js} +0 -0
  439. /package/dist/web/assets/{vitesse-black-jlYMJCBf.js → vitesse-black-BytVdvhC.js} +0 -0
  440. /package/dist/web/assets/{vitesse-dark-DS0sUlSZ.js → vitesse-dark-83Wech0N.js} +0 -0
  441. /package/dist/web/assets/{vitesse-light-HSeZ2YhG.js → vitesse-light-Xg4wbeMO.js} +0 -0
  442. /package/dist/web/assets/{vyper-BQfKVO3M.js → vyper-eW1NC3FG.js} +0 -0
  443. /package/dist/web/assets/{wasm-B6mCuI8h.js → wasm-Bhucqu1z.js} +0 -0
  444. /package/dist/web/assets/{wasm-B1xp9bLp.js → wasm-BucxKwBZ.js} +0 -0
  445. /package/dist/web/assets/{wenyan-CfpS05sP.js → wenyan-BJFBuXuH.js} +0 -0
  446. /package/dist/web/assets/{wgsl-14GDsWRD.js → wgsl-6z4FUyMK.js} +0 -0
  447. /package/dist/web/assets/{wikitext-Ccbq5EVX.js → wikitext-BoDU6teJ.js} +0 -0
  448. /package/dist/web/assets/{window-pip-registry-BEN0QNSW.js → window-pip-registry-CSLhJfpL.js} +0 -0
  449. /package/dist/web/assets/{wit-C19hb3R5.js → wit-DerMPpgt.js} +0 -0
  450. /package/dist/web/assets/{wolfram-B-ZSwGwP.js → wolfram-D78v0Ap-.js} +0 -0
  451. /package/dist/web/assets/{ws-auth-Dawx17PM.js → ws-auth-ZSZkAT6p.js} +0 -0
  452. /package/dist/web/assets/{yaml-mw_JUeio.js → yaml-C4TIgIw4.js} +0 -0
  453. /package/dist/web/assets/{zenscript-WbzDRjvF.js → zenscript-BydW-dLC.js} +0 -0
  454. /package/dist/web/assets/{zig-F0vvImTJ.js → zig-b9lTqL5E.js} +0 -0
@@ -0,0 +1,21 @@
1
+ import { create } from "zustand";
2
+
3
+ /**
4
+ * Whether a screen wake lock is being held right now.
5
+ *
6
+ * Deliberately separate from "should we be holding one". The browser grants the lock on its
7
+ * own terms and takes it back without asking — battery saver, a low battery, or the tab
8
+ * being hidden all revoke it — so the indicator has to report what actually happened rather
9
+ * than what was requested. `use-wake-lock.ts` is the only writer.
10
+ */
11
+ interface WakeLockStore {
12
+ active: boolean;
13
+ setActive: (active: boolean) => void;
14
+ }
15
+
16
+ export const useWakeLockStore = create<WakeLockStore>((set) => ({
17
+ active: false,
18
+ // Same-value writes are dropped so a re-acquire that changes nothing does not
19
+ // re-render the indicator.
20
+ setActive: (active) => set((s) => (s.active === active ? s : { active })),
21
+ }));
@@ -1 +0,0 @@
1
- import{o as e}from"./rolldown-runtime-FhOqtrmT.js";import{S as t,x as n}from"./vendor-markdown-Ls5AcU91.js";import"./vendor-ui-CaeeFO0B.js";import{t as r}from"./copy-BewHj66E.js";import{t as i}from"./download-DG3_9xXy.js";import{t as a}from"./flask-conical-tp8gyZGh.js";import{t as o}from"./key-round-CQpDrDxg.js";import{t as s}from"./loader-circle-DPMrnLQ2.js";import{t as c}from"./x-YDu4m2Iq.js";import{n as l,r as u}from"./api-client-oY1tC3tM.js";import{n as d}from"./utils-C9OjCrou.js";import"./portal-container-context-a399Hd9F.js";import{n as f}from"./use-is-mobile-CYW3FJFE.js";import{n as p,t as m}from"./button-BZtEJcUv.js";import{t as h}from"./mobile-bottom-sheet-BD5b7KJF.js";import"./use-visual-viewport-rnvuooQZ.js";import{$t as g,B as _,Cr as v,H as y,J as b,Jn as x,Jt as S,Pn as C,Qt as w,U as T,V as E,Vn as D,W as O,Xt as k,Y as A,Yt as j,Zt as M,ar as N,er as P,j as F,jn as I,tn as ee,z as te}from"./index-C_s5DxFQ.js";import{addAccount as L,deleteAccount as ne,exchangeOAuthCode as re,getAISettings as ie,getAccountSettings as ae,getOAuthUrl as oe,getUsageHistory as se,importAccounts as ce,patchAccount as le,testAccountToken as ue,testExport as de,testRawToken as fe,updateAccountSettings as R}from"./api-settings-CTMdz_VF.js";import{a as z,c as B,i as V,l as pe,n as me,o as H,r as U,t as he}from"./use-accounts-data--JHaCIoT.js";var W=e(t(),1),G=n(),K=[`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`,`Sun`],q=Array.from({length:24},(e,t)=>t);function ge(e,t){let n=Array.from({length:7},()=>Array.from({length:24},()=>({sum:0,count:0,avg:0})));for(let r of e){let e=t===`5h`?r.five_hour_util:r.weekly_util;if(e==null)continue;let i=new Date(r.recorded_at+(r.recorded_at.endsWith(`Z`)?``:`Z`)),a=(i.getDay()+6)%7,o=i.getHours();n[a][o].sum+=e,n[a][o].count+=1}for(let e of n)for(let t of e)t.avg=t.count>0?t.sum/t.count:0;return n}function _e(e){return e.map(e=>{let t=e.reduce((e,t)=>e+t.sum,0),n=e.reduce((e,t)=>e+t.count,0);return n>0?t/n:0})}function ve(e){return q.map(t=>{let n=0,r=0;for(let i of e)n+=i[t].sum,r+=i[t].count;return r>0?n/r:0})}function J(e){return e===0?`bg-surface-elevated`:e<.3?`bg-success/30`:e<.5?`bg-success/60`:e<.7?`bg-warning/50`:e<.9?`bg-warning/80`:`bg-error/80`}function ye(e){return e<.3?`bg-success`:e<.7?`bg-warning`:`bg-error`}function be({accountId:e}){let[t,n]=(0,W.useState)(null),[r,i]=(0,W.useState)(!0),[a,o]=(0,W.useState)(`5h`);(0,W.useEffect)(()=>{i(!0),se(e).then(n).catch(()=>n([])).finally(()=>i(!1))},[e]);let c=(0,W.useMemo)(()=>t?ge(t,a):null,[t,a]),l=(0,W.useMemo)(()=>c?_e(c):[],[c]),u=(0,W.useMemo)(()=>c?ve(c):[],[c]),d=Math.max(...l,.01);if(Math.max(...u,.01),r)return(0,G.jsx)(`div`,{className:`flex items-center justify-center py-3`,children:(0,G.jsx)(s,{className:`size-3 animate-spin text-text-subtle`})});if(!t||t.length===0)return(0,G.jsx)(`div`,{className:`text-[10px] text-text-subtle py-2 text-center`,children:`No usage history yet`});let f=t.length,p=new Set(t.map(e=>new Date(e.recorded_at+(e.recorded_at.endsWith(`Z`)?``:`Z`)).toDateString())).size;return(0,G.jsxs)(`div`,{className:`mt-2 space-y-2`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsx)(`span`,{className:`text-[10px] font-medium text-text-subtle`,children:`Usage Pattern (7d)`}),(0,G.jsxs)(`div`,{className:`flex gap-0.5 text-[9px]`,children:[(0,G.jsx)(`button`,{onClick:()=>o(`5h`),className:`px-1.5 py-0.5 rounded cursor-pointer transition-colors ${a===`5h`?`bg-primary/15 text-primary`:`text-text-subtle hover:text-text-secondary`}`,title:`5-hour rolling window limit — resets every 5 hours`,children:`5h`}),(0,G.jsx)(`button`,{onClick:()=>o(`weekly`),className:`px-1.5 py-0.5 rounded cursor-pointer transition-colors ${a===`weekly`?`bg-primary/15 text-primary`:`text-text-subtle hover:text-text-secondary`}`,title:`Weekly limit — resets every 7 days`,children:`Wk`})]})]}),(0,G.jsxs)(`p`,{className:`text-[9px] text-text-subtle leading-tight`,children:[`Avg `,a===`5h`?`5-hour`:`weekly`,` limit usage over `,p,`d (`,f,` samples). Higher % = closer to rate limit. Hover cells for details.`]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{className:`text-[9px] text-text-subtle`,children:`Avg usage by day of week`}),(0,G.jsx)(`div`,{className:`flex flex-col gap-[2px] mt-0.5`,children:K.map((e,t)=>{let n=l[t]??0;return(0,G.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,G.jsx)(`span`,{className:`text-[8px] text-text-subtle w-5 shrink-0 text-right tabular-nums`,children:e}),(0,G.jsx)(`div`,{className:`flex-1 h-2.5 bg-surface-elevated rounded-sm overflow-hidden`,children:(0,G.jsx)(`div`,{className:`h-full rounded-sm transition-all ${ye(n)}`,style:{width:`${Math.round(n/d*100)}%`}})}),(0,G.jsxs)(`span`,{className:`text-[8px] text-text-subtle w-6 shrink-0 text-right tabular-nums`,children:[Math.round(n*100),`%`]})]},e)})})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{className:`text-[9px] text-text-subtle`,children:`Avg usage by hour (0h-23h)`}),(0,G.jsx)(`div`,{className:`flex gap-[1px] mt-0.5`,children:q.map(e=>{let t=u[e]??0;return(0,G.jsxs)(`div`,{className:`flex-1 flex flex-col items-center gap-[1px]`,children:[(0,G.jsx)(`div`,{className:`w-full aspect-square rounded-[2px] ${J(t)}`,title:`${e}:00 — avg ${Math.round(t*100)}% usage`}),e%6==0&&(0,G.jsx)(`span`,{className:`text-[7px] text-text-subtle tabular-nums`,children:e})]},e)})})]}),c&&(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{className:`text-[9px] text-text-subtle`,children:`Day x Hour heatmap`}),(0,G.jsxs)(`div`,{className:`flex flex-col gap-[1px] mt-0.5`,children:[K.map((e,t)=>(0,G.jsxs)(`div`,{className:`flex items-center gap-[1px]`,children:[(0,G.jsx)(`span`,{className:`text-[7px] text-text-subtle w-4 shrink-0 text-right`,children:e.charAt(0)}),q.map(n=>{let r=c[t][n];return(0,G.jsx)(`div`,{className:`flex-1 aspect-square rounded-[1px] ${J(r.avg)}`,title:`${e} ${n}:00 — ${r.count>0?`avg ${Math.round(r.avg*100)}% (${r.count} samples)`:`no data`}`},n)})]},e)),(0,G.jsxs)(`div`,{className:`flex items-center gap-[1px]`,children:[(0,G.jsx)(`span`,{className:`w-4 shrink-0`}),q.map(e=>(0,G.jsx)(`div`,{className:`flex-1 text-center`,children:e%6==0&&(0,G.jsx)(`span`,{className:`text-[7px] text-text-subtle tabular-nums`,children:e})},e))]})]})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[8px] text-text-subtle`,children:[(0,G.jsx)(`span`,{children:`Low`}),(0,G.jsxs)(`div`,{className:`flex gap-[2px]`,children:[(0,G.jsx)(`div`,{className:`size-2 rounded-[1px] bg-success/30`}),(0,G.jsx)(`div`,{className:`size-2 rounded-[1px] bg-success/60`}),(0,G.jsx)(`div`,{className:`size-2 rounded-[1px] bg-warning/50`}),(0,G.jsx)(`div`,{className:`size-2 rounded-[1px] bg-warning/80`}),(0,G.jsx)(`div`,{className:`size-2 rounded-[1px] bg-error/80`})]}),(0,G.jsx)(`span`,{children:`High`}),(0,G.jsx)(`span`,{className:`ml-1`,children:`|`}),(0,G.jsx)(`div`,{className:`size-2 rounded-[1px] bg-surface-elevated border border-border/30`}),(0,G.jsx)(`span`,{children:`No data`})]})]})}function xe({profile:e,accountId:t,onClose:n}){let r=[[`Name`,e.account?.display_name],[`Email`,e.account?.email],[`Org`,e.organization?.name],[`Type`,e.organization?.organization_type],[`Tier`,e.organization?.rate_limit_tier],[`Status`,e.organization?.subscription_status]];return(0,G.jsxs)(`section`,{className:`space-y-2 border-t border-border pt-3`,"data-testid":`account-profile-panel`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsx)(`h3`,{className:`text-sm font-medium`,children:`Profile`}),(0,G.jsx)(`button`,{className:`p-2 text-muted-foreground hover:text-foreground cursor-pointer`,onClick:n,"aria-label":`Close profile`,children:(0,G.jsx)(c,{className:`size-4`})})]}),(0,G.jsx)(`div`,{className:`grid grid-cols-[80px_1fr] gap-x-3 gap-y-1 text-xs`,children:r.map(([e,t])=>t?(0,G.jsxs)(`span`,{className:`contents`,children:[(0,G.jsx)(`span`,{className:`text-muted-foreground`,children:e}),(0,G.jsx)(`span`,{className:`break-all`,children:t})]},e):null)}),(0,G.jsx)(be,{accountId:t})]})}function Se({display:e,onConfirm:t,onCancel:n}){let r=f(),i=(0,G.jsxs)(`div`,{className:`space-y-4`,"data-testid":`account-delete-confirm`,children:[(0,G.jsxs)(`p`,{className:`text-sm`,children:[`Remove `,(0,G.jsx)(`span`,{className:`font-medium`,children:e}),`?`]}),(0,G.jsx)(`p`,{className:`text-xs text-text-subtle`,children:`The stored token is deleted from this machine. Any export you already made keeps working.`}),(0,G.jsxs)(`div`,{className:`flex flex-col-reverse md:flex-row gap-2 md:justify-end pt-2`,children:[(0,G.jsx)(m,{variant:`outline`,onClick:n,className:`min-h-11`,children:`Cancel`}),(0,G.jsx)(m,{variant:`destructive`,autoFocus:!1,onClick:t,className:`min-h-11`,children:`Remove account`})]})]});return r?(0,G.jsx)(h,{open:!0,onClose:n,children:(0,G.jsxs)(`div`,{className:`px-4 pb-4`,children:[(0,G.jsx)(`h2`,{className:`text-base font-semibold mb-3`,children:`Remove account`}),i]})}):(0,G.jsx)(S,{open:!0,onOpenChange:e=>{e||n()},children:(0,G.jsxs)(j,{className:`sm:max-w-sm`,children:[(0,G.jsx)(w,{children:(0,G.jsx)(g,{className:`text-sm`,children:`Remove account`})}),i]})})}function Ce({open:e,onOpenChange:t,onSuccess:n}){let[r,i]=(0,W.useState)(``),[a,o]=(0,W.useState)(``),[c,l]=(0,W.useState)(!1),[u,d]=(0,W.useState)(null),[f,p]=(0,W.useState)(null),[h,_]=(0,W.useState)(``),[v,y]=(0,W.useState)(!1),[x,C]=(0,W.useState)(`idle`);function T(){p(null),_(``),C(`idle`),d(null)}function E(){t(!1),T(),i(``),o(``),d(null)}async function D(){y(!0),d(null);try{let{url:e,state:t}=await oe();p(t),C(`waiting`),window.open(e,`_blank`)}catch(e){d(e.message)}y(!1)}async function O(){if(!(!h.trim()||!f)){y(!0),d(null);try{let e=h.trim();e.includes(`#`)&&(e=e.split(`#`)[0]??e);let t=await re(e,f);E(),n(t?.status===`disabled`?`Signed in. This account is still disabled — enable it to use it.`:`Account connected via OAuth!`)}catch(e){d(e.message)}y(!1)}}async function N(){if(r.trim()){l(!0),d(null);try{let e=await L({apiKey:r.trim(),label:a.trim()||void 0});E(),n(e?.status===`disabled`?`Token updated. This account is still disabled — enable it to use it.`:`Account added!`)}catch(e){d(e.message)}l(!1)}}let P=r.trim()?r.trim().startsWith(`sk-ant-oat`)?`OAuth token (Claude Max/Pro)`:r.trim().startsWith(`sk-ant-api`)?`API key`:`Unknown format`:``;return(0,G.jsx)(S,{open:e,onOpenChange:e=>{e||E()},children:(0,G.jsxs)(j,{className:`sm:max-w-md`,children:[(0,G.jsxs)(w,{children:[(0,G.jsx)(g,{className:`text-sm`,children:`Add Claude Account`}),(0,G.jsx)(k,{className:`text-xs leading-relaxed`,children:`Connect via OAuth (recommended) or paste a token manually.`})]}),(0,G.jsxs)(`div`,{className:`space-y-3`,children:[(0,G.jsxs)(`div`,{className:`rounded-md border p-3 space-y-2`,children:[(0,G.jsx)(`p`,{className:`text-[11px] font-medium`,children:`Recommended: Login with Claude`}),x===`idle`?(0,G.jsx)(m,{size:`sm`,className:`w-full h-8 text-xs`,onClick:D,disabled:v,children:v?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(s,{className:`size-3 animate-spin mr-1`}),` Opening...`]}):`Login with Claude`}):(0,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:`Authorize in the opened tab, then paste the code:`}),(0,G.jsx)(A,{placeholder:`Paste code here...`,value:h,onChange:e=>_(e.target.value),className:`text-xs h-8 font-mono`,autoFocus:!0}),(0,G.jsxs)(`div`,{className:`flex gap-1.5`,children:[(0,G.jsx)(m,{size:`sm`,className:`flex-1 h-7 text-xs`,onClick:O,disabled:!h.trim()||v,children:v?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(s,{className:`size-3 animate-spin mr-1`}),` Connecting...`]}):`Connect`}),(0,G.jsx)(m,{size:`sm`,variant:`ghost`,className:`h-7 text-xs`,onClick:T,children:`Cancel`})]})]})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`div`,{className:`flex-1 border-t`}),(0,G.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:`or paste token`}),(0,G.jsx)(`div`,{className:`flex-1 border-t`})]}),(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(b,{htmlFor:`add-token`,className:`text-xs`,children:`Token`}),(0,G.jsx)(A,{id:`add-token`,type:`password`,placeholder:`sk-ant-...`,value:r,onChange:e=>i(e.target.value),className:`text-xs h-8 font-mono`}),P&&(0,G.jsxs)(`p`,{className:`text-[10px] text-muted-foreground`,children:[`Detected: `,P]})]}),(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(b,{htmlFor:`add-label`,className:`text-xs`,children:`Label (optional)`}),(0,G.jsx)(A,{id:`add-label`,placeholder:`e.g. Personal, Work`,value:a,onChange:e=>o(e.target.value),className:`text-xs h-8`})]})]}),u&&(0,G.jsx)(`div`,{className:`text-[11px] p-2 rounded bg-error/10 text-error`,children:u}),(0,G.jsxs)(M,{children:[(0,G.jsx)(m,{size:`sm`,variant:`outline`,className:`text-xs h-7`,onClick:E,children:`Cancel`}),(0,G.jsx)(m,{size:`sm`,className:`text-xs h-7`,onClick:N,disabled:!r.trim()||c,children:c?`Adding...`:`Add Token`})]})]})})}function we(e){let t=new Blob([e],{type:`application/json`}),n=document.createElement(`a`);n.href=URL.createObjectURL(t),n.download=`ppm-accounts-backup.json`,n.click(),URL.revokeObjectURL(n.href)}function Te({open:e,onOpenChange:t,accounts:n,preselectId:a,onMessage:o}){let c=n.filter(e=>e.hasRefreshToken),[l,d]=(0,W.useState)(new Set),[f,p]=(0,W.useState)(``),[h,_]=(0,W.useState)(!1),[v,y]=(0,W.useState)(!1),[x,C]=(0,W.useState)(!1),[T,E]=(0,W.useState)(!1);e&&!T&&(d(a?new Set([a]):new Set(c.map(e=>e.id))),E(!0)),!e&&T&&E(!1);function D(){t(!1),p(``),_(!1),y(!1)}async function O(e){if(l.size===0)return;C(!0);let t=f.trim()||`ppm-hienlh`;try{let n={"Content-Type":`application/json`},r=u();r&&(n.Authorization=`Bearer ${r}`);let i=await fetch(`/api/accounts/export`,{method:`POST`,headers:n,body:JSON.stringify({password:t,accountIds:[...l],includeRefreshToken:h,refreshBeforeExport:v})});if(!i.ok){let e=await i.json();throw Error(e.error??`Export failed: ${i.status}`)}let a=await i.text();e&&await ee(a)?o?.(`Backup copied to clipboard!`):(we(a),o?.(`Backup downloaded.`)),D()}catch{}C(!1)}let P=l.size>0&&!x;return(0,G.jsx)(S,{open:e,onOpenChange:e=>{e||D()},children:(0,G.jsxs)(j,{className:`sm:max-w-md`,children:[(0,G.jsxs)(w,{children:[(0,G.jsxs)(g,{className:`text-sm flex items-center gap-1.5`,children:[(0,G.jsx)(N,{className:`size-3.5`}),` Export Accounts`]}),(0,G.jsx)(k,{className:`text-xs`,children:`Select accounts and set a password to protect the backup.`})]}),(0,G.jsxs)(`div`,{className:`space-y-3`,children:[(0,G.jsxs)(`div`,{className:`space-y-1`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between mb-1`,children:[(0,G.jsx)(`p`,{className:`text-[11px] font-medium text-muted-foreground`,children:`Accounts to export`}),(0,G.jsx)(`button`,{className:`text-[10px] text-primary hover:underline cursor-pointer`,onClick:()=>d(l.size===c.length?new Set:new Set(c.map(e=>e.id))),children:l.size===c.length?`Deselect all`:`Select all`})]}),c.length===0?(0,G.jsx)(`p`,{className:`text-[10px] text-muted-foreground p-2 border rounded`,children:`No exportable accounts.`}):(0,G.jsx)(`div`,{className:`max-h-36 overflow-y-auto space-y-1 border rounded p-2`,children:c.map(e=>(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`input`,{type:`checkbox`,id:`exp-${e.id}`,checked:l.has(e.id),onChange:t=>{let n=new Set(l);t.target.checked?n.add(e.id):n.delete(e.id),d(n)},className:`size-3.5 accent-primary cursor-pointer`}),(0,G.jsx)(`label`,{htmlFor:`exp-${e.id}`,className:`text-xs cursor-pointer truncate`,children:e.label??e.email??e.id.slice(0,8)})]},e.id))})]}),(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsxs)(b,{className:`text-xs`,children:[`Password `,(0,G.jsx)(`span`,{className:`text-muted-foreground font-normal`,children:`(optional)`})]}),(0,G.jsx)(A,{type:`password`,placeholder:`Leave empty for default`,value:f,onChange:e=>p(e.target.value),className:`text-xs h-8`,autoComplete:`new-password`})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`input`,{type:`checkbox`,id:`exp-full`,checked:h,onChange:e=>_(e.target.checked),className:`size-3.5 accent-primary cursor-pointer`}),(0,G.jsx)(`label`,{htmlFor:`exp-full`,className:`text-[11px] cursor-pointer`,children:`Include refresh tokens (full transfer)`})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`input`,{type:`checkbox`,id:`exp-refresh`,checked:v,onChange:e=>y(e.target.checked),className:`size-3.5 accent-primary cursor-pointer`}),(0,G.jsx)(`label`,{htmlFor:`exp-refresh`,className:`text-[11px] cursor-pointer`,children:`Refresh tokens before export`})]}),h?(0,G.jsxs)(`div`,{className:`rounded-md border border-error/30 bg-error/5 p-2.5`,children:[(0,G.jsx)(`p`,{className:`text-[10px] font-medium text-error`,children:`Full transfer — source accounts will expire`}),(0,G.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:`Refresh tokens included. Source machine expires in ~1h after target refreshes.`})]}):v?(0,G.jsx)(`div`,{className:`rounded-md border border-warning/30 bg-warning/5 p-2.5`,children:(0,G.jsx)(`p`,{className:`text-[10px] font-medium text-warning`,children:`Refresh before export — invalidates previous shares`})}):(0,G.jsx)(`div`,{className:`rounded-md border border-success/30 bg-success/5 p-2.5`,children:(0,G.jsx)(`p`,{className:`text-[10px] font-medium text-success`,children:`Share current token (safe)`})}),(0,G.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:`Encrypted with AES-256-GCM + scrypt.`})]}),(0,G.jsxs)(M,{className:`gap-1.5 flex-col sm:flex-row`,children:[(0,G.jsx)(m,{size:`sm`,variant:`outline`,className:`text-xs h-7 cursor-pointer`,onClick:D,children:`Cancel`}),(0,G.jsxs)(m,{size:`sm`,variant:`outline`,className:`text-xs h-7 cursor-pointer`,disabled:!P,onClick:()=>O(!0),children:[(0,G.jsx)(r,{className:`size-3 mr-1`}),` Copy`]}),(0,G.jsx)(m,{size:`sm`,className:`text-xs h-7 cursor-pointer`,disabled:!P,onClick:()=>O(!1),children:x?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(s,{className:`size-3 animate-spin mr-1`}),` Exporting...`]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(i,{className:`size-3 mr-1`}),` Download`]})})]})]})})}function Ee({open:e,onOpenChange:t,onSuccess:n}){let[r,i]=(0,W.useState)(``),[a,o]=(0,W.useState)(``),[c,l]=(0,W.useState)(!1),[u,d]=(0,W.useState)(null);function f(){t(!1),i(``),o(``),d(null)}async function p(){if(r.trim()){l(!0),d(null);try{let e=await ce({data:r.trim(),password:a.trim()||`ppm-hienlh`});f(),n(`Imported ${e.imported} account(s)`)}catch(e){d(e.message||`Import failed`)}l(!1)}}return(0,G.jsx)(S,{open:e,onOpenChange:e=>{e||f()},children:(0,G.jsxs)(j,{className:`sm:max-w-md`,children:[(0,G.jsxs)(w,{children:[(0,G.jsxs)(g,{className:`text-sm flex items-center gap-1.5`,children:[(0,G.jsx)(N,{className:`size-3.5`}),` Import Accounts`]}),(0,G.jsx)(k,{className:`text-xs`,children:`Paste backup data and enter the export password. Imported accounts are temporary (~1h).`})]}),(0,G.jsxs)(`div`,{className:`space-y-3`,children:[(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(b,{className:`text-xs`,children:`Backup data`}),(0,G.jsx)(`textarea`,{value:r,onChange:e=>i(e.target.value),placeholder:`Paste backup JSON here...`,rows:4,className:`w-full text-xs p-2 rounded border border-border bg-background font-mono resize-none focus:outline-none focus:ring-1 focus:ring-primary`})]}),(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsxs)(b,{className:`text-xs`,children:[`Password `,(0,G.jsx)(`span`,{className:`text-muted-foreground font-normal`,children:`(optional)`})]}),(0,G.jsx)(A,{type:`password`,placeholder:`Leave empty for default`,value:a,onChange:e=>o(e.target.value),className:`text-xs h-8`,autoComplete:`current-password`})]})]}),u&&(0,G.jsx)(`div`,{className:`text-[11px] p-2 rounded bg-error/10 text-error`,children:u}),(0,G.jsxs)(M,{children:[(0,G.jsx)(m,{size:`sm`,variant:`outline`,className:`text-xs h-7 cursor-pointer`,onClick:f,children:`Cancel`}),(0,G.jsx)(m,{size:`sm`,className:`text-xs h-7 cursor-pointer`,disabled:!r.trim()||c,onClick:p,children:c?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(s,{className:`size-3 animate-spin mr-1`}),` Importing...`]}):`Import`})]})]})})}var Y=typeof window<`u`?window.matchMedia(`(min-width: 768px)`):null;function De(e){return Y?.addEventListener(`change`,e),()=>Y?.removeEventListener(`change`,e)}function Oe(){return Y?.matches??!0}function X(){let[e,t]=(0,W.useState)(null),[n,r]=(0,W.useState)(!0);return(0,W.useEffect)(()=>{r(!0),ae().then(t).finally(()=>r(!1))},[]),n?(0,G.jsx)(`p`,{className:`text-xs text-text-subtle py-4 text-center`,children:`Loading...`}):e?(0,G.jsxs)(`div`,{className:`space-y-4`,children:[(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(`label`,{className:`text-xs font-medium text-text-primary`,children:`Rotation Strategy`}),(0,G.jsxs)(te,{value:e.strategy,onValueChange:async e=>{t(await R({strategy:e}))},children:[(0,G.jsx)(y,{className:`w-full h-9 text-xs`,children:(0,G.jsx)(T,{})}),(0,G.jsxs)(_,{children:[(0,G.jsx)(E,{value:`round-robin`,children:`Round-robin`}),(0,G.jsx)(E,{value:`fill-first`,children:`Fill-first`}),(0,G.jsx)(E,{value:`lowest-usage`,children:`Lowest usage`})]})]}),(0,G.jsxs)(`p`,{className:`text-[10px] text-text-subtle`,children:[e.strategy===`round-robin`&&`Cycles through accounts evenly`,e.strategy===`fill-first`&&`Uses one account until its limit, then moves on`,e.strategy===`lowest-usage`&&`Picks the account with the lowest current usage`]})]}),(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(`label`,{className:`text-xs font-medium text-text-primary`,children:`Max Retry`}),(0,G.jsx)(`input`,{type:`number`,min:0,value:e.maxRetry,className:`w-full h-9 text-xs border rounded-md px-3 bg-background`,onChange:async e=>{let n=parseInt(e.target.value,10);!isNaN(n)&&n>=0&&t(await R({maxRetry:n}))}}),(0,G.jsx)(`p`,{className:`text-[10px] text-text-subtle`,children:`How many accounts to try on failure. 0 = try all available accounts.`})]}),(0,G.jsxs)(`div`,{className:`space-y-1.5 border-t border-border pt-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsx)(`label`,{className:`text-xs font-medium text-text-primary`,children:`Cooldown parking`}),(0,G.jsx)(O,{checked:e.cooldownEnabled,onCheckedChange:async e=>{t(await R({cooldownEnabled:e}))}})]}),(0,G.jsx)(`p`,{className:`text-[10px] text-text-subtle`,children:`Park a failing account (rate limit / usage limit / auth error) until it recovers. Off: accounts stay selectable — rotation still skips accounts already ≥95% on the 5-hour limit.`})]}),(0,G.jsxs)(`div`,{className:`flex items-center justify-between text-xs border-t border-border pt-3`,children:[(0,G.jsx)(`span`,{className:`text-text-subtle`,children:`Active accounts`}),(0,G.jsx)(`span`,{className:`font-medium text-text-primary`,children:e.activeCount})]})]}):(0,G.jsx)(`p`,{className:`text-xs text-text-subtle py-4 text-center`,children:`Failed to load settings`})}function ke({open:e,onOpenChange:t}){let n=(0,W.useSyncExternalStore)(De,Oe);return e?n?(0,G.jsx)(S,{open:e,onOpenChange:t,children:(0,G.jsxs)(j,{className:`sm:max-w-sm`,children:[(0,G.jsx)(w,{children:(0,G.jsxs)(g,{className:`text-sm flex items-center gap-2`,children:[(0,G.jsx)(D,{className:`size-4`}),` Rotation & Retry`]})}),(0,G.jsx)(X,{})]})}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{className:`fixed inset-0 z-50 transition-opacity duration-200 opacity-100`,onClick:()=>t(!1),style:{backgroundColor:`rgba(0,0,0,0.5)`}}),(0,G.jsxs)(`div`,{className:d(`fixed bottom-0 left-0 right-0 z-50 bg-background rounded-t-2xl border-t border-border shadow-2xl`,`transition-transform duration-300 ease-out max-h-[85vh] overflow-y-auto`,`translate-y-0`),children:[(0,G.jsx)(`div`,{className:`flex justify-center pt-3 pb-1`,children:(0,G.jsx)(`div`,{className:`w-10 h-1 rounded-full bg-border`})}),(0,G.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-2 border-b border-border`,children:[(0,G.jsxs)(`span`,{className:`text-sm font-semibold flex items-center gap-2`,children:[(0,G.jsx)(D,{className:`size-4`}),` Rotation & Retry`]}),(0,G.jsx)(`button`,{onClick:()=>t(!1),className:`flex items-center justify-center size-7 rounded-md hover:bg-surface-elevated transition-colors`,children:(0,G.jsx)(c,{className:`size-4`})})]}),(0,G.jsx)(`div`,{className:`px-4 py-4 pb-8`,children:(0,G.jsx)(X,{})})]})]}):null}var Ae=p(`inline-flex items-center rounded-md border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2`,{variants:{variant:{default:`border-transparent bg-primary text-primary-foreground shadow`,secondary:`border-transparent bg-secondary text-secondary-foreground`,destructive:`border-transparent bg-destructive text-destructive-foreground shadow`,outline:`text-foreground`}},defaultVariants:{variant:`default`}});function Z({className:e,variant:t,...n}){return(0,G.jsx)(`div`,{className:d(Ae({variant:t}),e),...n})}function je(e){let t=Math.floor(Date.now()/1e3);return e>t?`${Math.floor((e-t)/60)}m`:`exp`}function Me({accounts:e}){let[t,n]=(0,W.useState)([]),[r,i]=(0,W.useState)(!1),[a,o]=(0,W.useState)(!1),[c,l]=(0,W.useState)(new Map),u=e.filter(e=>e.hasRefreshToken);async function d(){if(u.length!==0){i(!0);try{let e=await de(u.map(e=>e.id),a);n(t=>[...t,{round:t.length+1,time:new Date().toLocaleTimeString(),includeRefresh:a,items:e}])}catch{}i(!1)}}async function f(e,t){l(t=>new Map(t).set(e,{loading:!0}));try{let n=await fe(t);l(t=>new Map(t).set(e,{loading:!1,...n}))}catch(t){l(n=>new Map(n).set(e,{loading:!1,status:`error`,error:t.message}))}}function p(e,t){return[{key:`r${e.round}-pre-${t.id}`,label:`Pre-export`,token:t.preExportTokenFull,preview:t.preExportToken,expires:t.preExportExpires},{key:`r${e.round}-exp-${t.id}`,label:`Exported`,token:t.exportedTokenFull,preview:t.exportedToken,expires:t.exportedExpires},{key:`r${e.round}-post-${t.id}`,label:`Post-export`,token:t.postExportTokenFull,preview:t.postExportToken,expires:t.postExportExpires}]}function h(){for(let e of t)for(let t of e.items)for(let n of p(e,t))n.token&&f(n.key,n.token)}return(0,G.jsxs)(`section`,{className:`border-t pt-4 space-y-2`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,G.jsx)(`p`,{className:`text-xs font-medium`,children:`Simulate export`}),t.length>0&&(0,G.jsxs)(`span`,{className:`text-[10px] text-muted-foreground`,children:[t.length,` round(s)`]})]}),(0,G.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:`Every run appends a round. Earlier rounds are kept so tokens can be compared across runs.`}),u.length===0?(0,G.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No OAuth account with a refresh token to export.`}):(0,G.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,G.jsx)(O,{id:`sim-include-refresh`,checked:a,onCheckedChange:o,className:`cursor-pointer`}),(0,G.jsx)(b,{htmlFor:`sim-include-refresh`,className:`text-[11px] cursor-pointer`,children:`Include refresh tokens`})]}),(0,G.jsx)(m,{size:`sm`,className:`h-7 text-xs cursor-pointer`,disabled:r,onClick:()=>void d(),children:r?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(s,{className:`size-3 animate-spin mr-1`}),` Exporting...`]}):`Run export #${t.length+1}`})]}),t.length>0&&(0,G.jsxs)(`div`,{className:`space-y-3`,children:[(0,G.jsxs)(m,{size:`sm`,variant:`outline`,className:`w-full h-7 text-[11px] cursor-pointer`,onClick:h,children:[`Test all tokens (`,t.reduce((e,t)=>e+t.items.length*3,0),`)`]}),t.map(e=>(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsxs)(`p`,{className:`text-xs font-medium text-primary`,children:[`Round #`,e.round]}),(0,G.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:e.time}),(0,G.jsx)(Z,{variant:e.includeRefresh?`destructive`:`secondary`,className:`text-[9px] px-1 py-0`,children:e.includeRefresh?`with refresh`:`access only`})]}),e.items.map(t=>(0,G.jsxs)(`div`,{className:`p-2 rounded-lg border bg-card space-y-1.5`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`text-[11px] font-medium`,children:t.label??t.email??t.id.slice(0,8)}),t.tokenChanged&&(0,G.jsx)(Z,{variant:`secondary`,className:`text-[9px] px-1 py-0`,children:`DB token changed`})]}),p(e,t).map(e=>{let t=c.get(e.key);return(0,G.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[11px]`,children:[(0,G.jsx)(`span`,{className:`w-20 shrink-0 text-muted-foreground text-[10px]`,children:e.label}),(0,G.jsx)(`code`,{className:`flex-1 truncate font-mono text-[10px] bg-muted px-1 rounded`,children:e.preview??`N/A`}),e.expires&&(0,G.jsx)(`span`,{className:`text-[10px] text-muted-foreground shrink-0`,children:je(e.expires)}),e.token?(0,G.jsx)(m,{size:`sm`,variant:`outline`,className:`h-6 text-[10px] px-1.5 cursor-pointer shrink-0`,disabled:t?.loading,onClick:()=>void f(e.key,e.token),children:t?.loading?(0,G.jsx)(s,{className:`size-3 animate-spin`}):`Test`}):(0,G.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:`-`}),t&&!t.loading&&(0,G.jsx)(`span`,{className:`text-[10px] font-medium shrink-0 ${t.status?.startsWith(`valid`)?`text-success`:`text-error`}`,children:t.status})]},e.key)})]},`r${e.round}-${t.id}`))]},e.round))]})]})}function Ne(e){let t=Math.floor(Date.now()/1e3),n=Math.floor(Math.abs(e-t)/60);return e>t?`${n}m left`:`expired ${n}m ago`}function Pe({open:e,onOpenChange:t,accounts:n}){let[r,i]=(0,W.useState)(new Map),[o,c]=(0,W.useState)(!1);async function l(e){i(t=>new Map(t).set(e,{loading:!0}));try{let t=await ue(e,o);i(n=>new Map(n).set(e,{loading:!1,result:t}))}catch(t){i(n=>new Map(n).set(e,{loading:!1,error:t.message}))}}function u(){for(let e of n.filter(e=>e.expiresAt!==null))l(e.id)}return(0,G.jsx)(S,{open:e,onOpenChange:t,children:(0,G.jsxs)(j,{className:`sm:max-w-xl max-h-[85vh] flex flex-col`,children:[(0,G.jsxs)(w,{children:[(0,G.jsxs)(g,{className:`text-sm flex items-center gap-1.5`,children:[(0,G.jsx)(a,{className:`size-4`}),` Token Test`]}),(0,G.jsx)(k,{className:`text-xs`,children:`Probe stored tokens for validity. Nothing is modified.`})]}),(0,G.jsxs)(`div`,{className:`space-y-4 overflow-y-auto flex-1 pr-1`,children:[(0,G.jsxs)(`section`,{className:`space-y-2`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,G.jsx)(`p`,{className:`text-xs font-medium`,children:`Current tokens`}),(0,G.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,G.jsx)(O,{id:`token-test-refresh`,checked:o,onCheckedChange:c,className:`cursor-pointer`}),(0,G.jsx)(b,{htmlFor:`token-test-refresh`,className:`text-[11px] cursor-pointer`,children:`Also test refresh`})]}),(0,G.jsx)(m,{size:`sm`,variant:`outline`,className:`h-7 text-xs cursor-pointer`,onClick:u,children:`Test all`})]})]}),n.length===0&&(0,G.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No accounts to test.`}),(0,G.jsx)(`div`,{className:`space-y-1.5`,children:n.map(e=>{let t=r.get(e.id),n=t?.result?.accessToken.status;return(0,G.jsxs)(`div`,{className:`p-2 rounded border bg-card space-y-1`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(`span`,{className:`text-xs font-medium truncate block`,children:e.label??e.email??e.id.slice(0,8)}),e.expiresAt&&(0,G.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:Ne(e.expiresAt)})]}),(0,G.jsx)(m,{size:`sm`,variant:`outline`,className:`h-7 text-xs cursor-pointer shrink-0`,disabled:t?.loading,onClick:()=>void l(e.id),children:t?.loading?(0,G.jsx)(s,{className:`size-3 animate-spin`}):`Test`})]}),t&&!t.loading&&(0,G.jsxs)(`div`,{className:`text-[11px] pl-2 border-l-2 border-muted`,children:[t.error&&(0,G.jsx)(`p`,{className:`text-error`,children:t.error}),n&&(0,G.jsxs)(`span`,{className:n.startsWith(`valid`)?`text-success`:`text-error`,children:[n,t.result?.accessToken.code?` (${t.result.accessToken.code})`:``]})]})]},e.id)})})]}),(0,G.jsx)(Me,{accounts:n})]}),(0,G.jsx)(M,{children:(0,G.jsx)(m,{size:`sm`,variant:`outline`,className:`text-xs cursor-pointer`,onClick:()=>t(!1),children:`Close`})})]})})}function Fe(){let{usages:e,accounts:t,activeAccountId:n,initialLoading:r,refreshing:c,flashIds:l,reload:u}=he(),[d,f]=(0,W.useState)(null),[p,h]=(0,W.useState)(null),[g,_]=(0,W.useState)(null),[v,y]=(0,W.useState)(null),[b,S]=(0,W.useState)(null),[C,w]=(0,W.useState)(null);function T(e){u(),e&&f(e)}async function E(e,t){h(e);try{await le(e,{status:t===`disabled`?`active`:`disabled`})}catch(e){f(e.message)}h(null),u()}async function O(){if(g){try{await ne(g.id),f(`Account "${g.display}" removed.`),u()}catch(e){f(`Failed to remove: ${e.message}`)}_(null)}}let k=new Map(t.map(e=>[e.id,e])),A=e[0]?.usage.lastFetchedAt;return(0,G.jsxs)(`div`,{className:`space-y-4`,children:[(0,G.jsx)(z,{description:`Connect multiple Claude accounts. PPM rotates between them automatically to avoid rate limits.`,onRefresh:()=>void u(),refreshing:c,disabled:r,actions:(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(m,{size:`sm`,className:`cursor-pointer gap-1.5`,onClick:()=>w(`add`),children:[(0,G.jsx)(x,{className:`size-4`}),` Add account`]}),(0,G.jsxs)(m,{size:`sm`,variant:`outline`,className:`cursor-pointer gap-1.5`,onClick:()=>{S(null),w(`export`)},children:[(0,G.jsx)(i,{className:`size-4`}),` Export`]}),(0,G.jsxs)(m,{size:`sm`,variant:`outline`,className:`cursor-pointer gap-1.5`,onClick:()=>w(`import`),children:[(0,G.jsx)(I,{className:`size-4`}),` Import`]}),(0,G.jsxs)(m,{size:`sm`,variant:`outline`,className:`cursor-pointer gap-1.5`,onClick:()=>w(`rotation`),children:[(0,G.jsx)(D,{className:`size-4`}),` Rotation`]}),(0,G.jsxs)(m,{size:`sm`,variant:`outline`,className:`cursor-pointer gap-1.5`,onClick:()=>w(`token-test`),children:[(0,G.jsx)(a,{className:`size-4`}),` Token test`]})]})}),(0,G.jsx)(H,{message:d,onDismiss:()=>f(null)}),(0,G.jsxs)(`section`,{className:`space-y-2`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsx)(`h3`,{className:`text-sm font-medium`,children:`Accounts`}),A&&(0,G.jsxs)(`span`,{className:`text-[10px] text-muted-foreground`,children:[`usage `,pe(new Date(A).getTime())]})]}),r?(0,G.jsxs)(`div`,{className:`flex items-center gap-2 py-6 text-xs text-muted-foreground`,children:[(0,G.jsx)(s,{className:`size-4 animate-spin`}),` Loading accounts...`]}):e.length===0?(0,G.jsxs)(`div`,{className:`flex flex-col items-center gap-2 py-8 text-center`,children:[(0,G.jsx)(o,{className:`size-5 text-muted-foreground`}),(0,G.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No accounts connected yet.`}),(0,G.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Add one to start using PPM.`})]}):(0,G.jsx)(U,{children:e.map(e=>(0,G.jsx)(me,{layout:`strip`,entry:e,isActive:e.accountId===n,accountInfo:k.get(e.accountId),onToggle:E,toggling:p===e.accountId,onDelete:(e,t)=>_({id:e,display:t}),onExport:e=>{S(e),w(`export`)},onViewProfile:(e,t)=>y({profile:e,accountId:t}),flash:l.has(e.accountId)},e.accountId))})]}),v&&(0,G.jsx)(xe,{profile:v.profile,accountId:v.accountId,onClose:()=>y(null)}),g&&(0,G.jsx)(Se,{display:g.display,onConfirm:()=>void O(),onCancel:()=>_(null)}),(0,G.jsx)(Ce,{open:C===`add`,onOpenChange:e=>w(e?`add`:null),onSuccess:T}),(0,G.jsx)(Te,{open:C===`export`,onOpenChange:e=>{w(e?`export`:null),e||S(null)},accounts:t,preselectId:b,onMessage:f}),(0,G.jsx)(Ee,{open:C===`import`,onOpenChange:e=>w(e?`import`:null),onSuccess:T}),(0,G.jsx)(ke,{open:C===`rotation`,onOpenChange:e=>w(e?`rotation`:null)}),(0,G.jsx)(Pe,{open:C===`token-test`,onOpenChange:e=>w(e?`token-test`:null),accounts:t})]})}function Q({open:e,onOpenChange:t,label:n,onLabelChange:r,apiKey:i,onApiKeyChange:a,adding:c,onAddApiKey:l,deviceWaiting:u,onStartDevice:d,device:f,error:p}){return(0,G.jsx)(S,{open:e,onOpenChange:t,children:(0,G.jsxs)(j,{className:`sm:max-w-md`,children:[(0,G.jsxs)(w,{children:[(0,G.jsx)(g,{className:`text-sm`,children:`Add Codex Account`}),(0,G.jsxs)(k,{className:`text-xs leading-relaxed`,children:[`Each account keeps its own login (its own `,(0,G.jsx)(`code`,{children:`CODEX_HOME`}),`).`]})]}),(0,G.jsxs)(`div`,{className:`space-y-3`,children:[(0,G.jsxs)(`div`,{className:`rounded-md border p-3 space-y-2`,children:[(0,G.jsx)(`p`,{className:`text-[11px] font-medium`,children:`Recommended: sign in with ChatGPT`}),(0,G.jsx)(m,{size:`sm`,className:`w-full cursor-pointer gap-1.5`,onClick:d,disabled:u,children:u?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(s,{className:`size-4 animate-spin`}),` Waiting for authorization...`]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(P,{className:`size-4`}),` Sign in with ChatGPT`]})}),f&&(0,G.jsxs)(`div`,{className:`rounded-md border border-primary/40 bg-primary/10 p-2.5 space-y-1.5`,children:[(0,G.jsx)(`p`,{className:`text-[11px]`,children:`Enter this code to authorize:`}),(0,G.jsx)(`div`,{className:`font-mono text-lg tracking-widest`,children:f.userCode}),(0,G.jsxs)(`a`,{href:f.verificationUrl,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-primary hover:underline text-[11px]`,children:[(0,G.jsx)(v,{className:`size-3`}),` `,f.verificationUrl]})]})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`div`,{className:`flex-1 border-t`}),(0,G.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:`or paste an API key`}),(0,G.jsx)(`div`,{className:`flex-1 border-t`})]}),(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(b,{htmlFor:`codex-api-key`,className:`text-xs`,children:`OpenAI API key`}),(0,G.jsx)(A,{id:`codex-api-key`,type:`password`,placeholder:`sk-...`,value:i,onChange:e=>a(e.target.value),className:`text-xs font-mono`})]}),(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(b,{htmlFor:`codex-label`,className:`text-xs`,children:`Label (optional)`}),(0,G.jsx)(A,{id:`codex-label`,placeholder:`e.g. Personal, Work`,value:n,onChange:e=>r(e.target.value),className:`text-xs`})]})]}),p&&(0,G.jsx)(`div`,{className:`text-[11px] p-2 rounded bg-error/10 text-error`,children:p}),(0,G.jsxs)(M,{children:[(0,G.jsx)(m,{size:`sm`,variant:`outline`,className:`text-xs cursor-pointer`,onClick:()=>t(!1),children:`Cancel`}),(0,G.jsxs)(m,{size:`sm`,className:`text-xs cursor-pointer gap-1.5`,onClick:l,disabled:!i.trim()||c,children:[c?(0,G.jsx)(s,{className:`size-3.5 animate-spin`}):(0,G.jsx)(o,{className:`size-3.5`}),`Add key`]})]})]})})}function Ie({mode:e,onOpenChange:t,password:n,onPasswordChange:r,busy:a,onExport:o,onImport:c,error:l}){let u=(0,W.useRef)(null),d=e===`export`;return(0,G.jsx)(S,{open:e!==null,onOpenChange:t,children:(0,G.jsxs)(j,{className:`sm:max-w-md`,children:[(0,G.jsxs)(w,{children:[(0,G.jsxs)(g,{className:`text-sm flex items-center gap-1.5`,children:[(0,G.jsx)(N,{className:`size-4`}),` `,d?`Export Codex Accounts`:`Import Codex Accounts`]}),(0,G.jsx)(k,{className:`text-xs leading-relaxed`,children:d?`Writes a password-encrypted file containing each account's login.`:`Reads a backup file. The password must be the one it was exported with.`})]}),(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(b,{htmlFor:`codex-backup-password`,className:`text-xs`,children:`Password`}),(0,G.jsx)(A,{id:`codex-backup-password`,type:`password`,placeholder:d?`Choose a password`:`Password used for the export`,value:n,onChange:e=>r(e.target.value),className:`text-xs`,autoComplete:d?`new-password`:`current-password`}),(0,G.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:`A backup holds full logins — keep the file and its password together.`})]}),l&&(0,G.jsx)(`div`,{className:`text-[11px] p-2 rounded bg-error/10 text-error`,children:l}),(0,G.jsx)(`input`,{ref:u,type:`file`,accept:`application/json,.json`,className:`hidden`,onChange:e=>{let t=e.target.files?.[0];e.target.value=``,t&&c(t)}}),(0,G.jsxs)(M,{children:[(0,G.jsx)(m,{size:`sm`,variant:`outline`,className:`text-xs cursor-pointer`,onClick:()=>t(!1),children:`Cancel`}),(0,G.jsxs)(m,{size:`sm`,className:`text-xs cursor-pointer gap-1.5`,disabled:!n.trim()||a,onClick:()=>d?o():u.current?.click(),children:[a?(0,G.jsx)(s,{className:`size-3.5 animate-spin`}):d?(0,G.jsx)(i,{className:`size-3.5`}):(0,G.jsx)(I,{className:`size-3.5`}),d?`Download backup`:`Choose file`]})]})]})})}var Le=[{value:`round-robin`,label:`Round-robin`,hint:`Take the next account each time.`},{value:`fill-first`,label:`Fill-first`,hint:`Stay on one account until it runs out.`},{value:`lowest-usage`,label:`Lowest usage`,hint:`Pick whichever has the most left.`}];function Re({open:e,onOpenChange:t,strategy:n,onChange:r}){return(0,G.jsx)(S,{open:e,onOpenChange:t,children:(0,G.jsxs)(j,{className:`sm:max-w-md`,children:[(0,G.jsxs)(w,{children:[(0,G.jsx)(g,{className:`text-sm`,children:`Codex Rotation`}),(0,G.jsx)(k,{className:`text-xs leading-relaxed`,children:`How a new chat chooses among your Codex accounts.`})]}),(0,G.jsx)(`div`,{className:`space-y-2`,children:Le.map(e=>(0,G.jsxs)(`button`,{type:`button`,onClick:()=>r(e.value),"aria-current":n===e.value?`true`:void 0,className:d(`w-full text-left rounded-md border px-3 py-2.5 min-h-11 cursor-pointer transition-colors`,n===e.value?`border-primary bg-primary/10`:`border-border hover:bg-accent/50 active:bg-accent`),children:[(0,G.jsx)(`p`,{className:`text-sm font-medium`,children:e.label}),(0,G.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.hint})]},e.value))}),(0,G.jsx)(M,{children:(0,G.jsx)(m,{size:`sm`,variant:`outline`,className:`text-xs cursor-pointer`,onClick:()=>t(!1),children:`Done`})})]})})}var ze=2e3,Be=21e4;function Ve(e){let[t,n]=(0,W.useState)([]),[r,i]=(0,W.useState)(`round-robin`),[a,o]=(0,W.useState)({}),[s,c]=(0,W.useState)(!1),[d,f]=(0,W.useState)(``),[p,m]=(0,W.useState)(``),[h,g]=(0,W.useState)(!1),[_,v]=(0,W.useState)(null),[y,b]=(0,W.useState)(null),[x,S]=(0,W.useState)(!1),[C,w]=(0,W.useState)(``),[T,E]=(0,W.useState)(!1),[D,O]=(0,W.useState)(!1),[k,A]=(0,W.useState)(null),j=(0,W.useRef)(null),M=(0,W.useRef)(null),N=(0,W.useCallback)(async()=>{c(!0);try{let e=await l.get(`/api/codex-accounts`);n(e.accounts),i(e.strategy),l.get(`/api/codex-accounts/usage`).then(o).catch(()=>{})}finally{c(!1)}},[]);(0,W.useEffect)(()=>{N()},[N]);let P=async()=>{if(d.trim()){g(!0),v(null);try{await l.post(`/api/codex-accounts/api-key`,{apiKey:d.trim(),label:p.trim()||void 0}),f(``),m(``),e(),await N()}catch(e){v(e.message)}finally{g(!1)}}},F=(0,W.useCallback)(t=>{let n=Date.now()+Be,r=!1;j.current=()=>{r=!0};let i=e=>{r=!0,j.current=null,M.current=null,e&&v(e),b(null),S(!1)},a=async()=>{if(r)return;let o=null;try{o=await l.get(`/api/codex-accounts/device-login/${t}/status`)}catch{}if(!r){if(o?.state===`done`){i(),m(``),e(),await N();return}if(o?.state===`error`){i(o.error);return}if(Date.now()>n){i(`Device login timed out.`);return}setTimeout(a,ze)}};a()},[N]);return(0,W.useEffect)(()=>()=>{j.current?.();let e=M.current;e&&l.del(`/api/codex-accounts/device-login/${e}`).catch(()=>{})},[]),{accounts:t,strategy:r,usages:a,loading:s,apiKey:d,setApiKey:f,label:p,setLabel:m,adding:h,err:_,setErr:v,device:y,deviceWaiting:x,backupPassword:C,setBackupPassword:w,exporting:T,importing:D,msg:k,setMsg:A,load:N,addApiKey:P,startDevice:async()=>{v(null);try{let e=await l.post(`/api/codex-accounts/device-login`,{label:p.trim()||void 0});b(e),S(!0),M.current=e.id,F(e.id)}catch(e){v(e.message)}},remove:async e=>{await l.del(`/api/codex-accounts/${e}`),await N()},changeStrategy:async e=>{i(e);try{await l.put(`/api/codex-accounts/strategy`,{strategy:e})}catch{}},doExport:async()=>{if(!C.trim()){v(`Set a backup password first.`);return}E(!0),v(null),A(null);try{let t={"Content-Type":`application/json`},n=u();n&&(t.Authorization=`Bearer ${n}`);let r=await fetch(`/api/codex-accounts/export`,{method:`POST`,headers:t,body:JSON.stringify({password:C})});if(!r.ok){let e=await r.json().catch(()=>({}));throw Error(e.error??`Export failed: ${r.status}`)}let i=await r.text(),a=new Blob([i],{type:`application/json`}),o=document.createElement(`a`);o.href=URL.createObjectURL(a),o.download=`ppm-codex-accounts-backup.json`,o.click(),URL.revokeObjectURL(o.href),A(`Backup downloaded.`),e()}catch(e){v(e.message)}finally{E(!1)}},doImport:async t=>{if(!C.trim()){v(`Enter the backup password first.`);return}O(!0),v(null),A(null);try{let n=await t.text(),r=await l.post(`/api/codex-accounts/import`,{data:n,password:C});A(`Imported ${r.imported}${r.skipped?`, skipped ${r.skipped}`:``}.`),e(),await N()}catch(e){v(e.message)}finally{O(!1)}}}}function $(e){return e==null?null:Math.round(e*100)}function He(){let[e,t]=(0,W.useState)(null),n=Ve(()=>t(null));return(0,G.jsxs)(`div`,{className:`space-y-4`,children:[(0,G.jsx)(z,{description:(0,G.jsxs)(G.Fragment,{children:[`Each Codex account keeps its own login (`,(0,G.jsx)(`code`,{children:`CODEX_HOME`}),`). One is picked per chat by the rotation setting.`]}),onRefresh:()=>void n.load(),refreshing:n.loading,actions:(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(m,{size:`sm`,className:`cursor-pointer gap-1.5`,onClick:()=>t(`add`),children:[(0,G.jsx)(x,{className:`size-4`}),` Add account`]}),(0,G.jsxs)(m,{size:`sm`,variant:`outline`,className:`cursor-pointer gap-1.5`,onClick:()=>t(`export`),children:[(0,G.jsx)(i,{className:`size-4`}),` Export`]}),(0,G.jsxs)(m,{size:`sm`,variant:`outline`,className:`cursor-pointer gap-1.5`,onClick:()=>t(`import`),children:[(0,G.jsx)(I,{className:`size-4`}),` Import`]}),(0,G.jsxs)(m,{size:`sm`,variant:`outline`,className:`cursor-pointer gap-1.5`,onClick:()=>t(`rotation`),children:[(0,G.jsx)(D,{className:`size-4`}),` Rotation`]})]})}),(0,G.jsx)(H,{message:n.msg??n.err,onDismiss:()=>{n.setMsg(null),n.setErr(null)}}),(0,G.jsxs)(`section`,{className:`space-y-2`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsx)(`h3`,{className:`text-sm font-medium`,children:`Codex Accounts`}),(0,G.jsx)(`span`,{className:`text-[10px] text-muted-foreground capitalize`,children:n.strategy.replace(`-`,` `)})]}),n.loading&&n.accounts.length===0?(0,G.jsxs)(`div`,{className:`flex items-center gap-2 py-6 text-xs text-muted-foreground`,children:[(0,G.jsx)(s,{className:`size-4 animate-spin`}),` Loading accounts...`]}):n.accounts.length===0?(0,G.jsxs)(`div`,{className:`flex flex-col items-center gap-2 py-8 text-center`,children:[(0,G.jsx)(o,{className:`size-5 text-muted-foreground`}),(0,G.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No Codex accounts yet.`}),(0,G.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Chats use your default `,(0,G.jsx)(`code`,{children:`~/.codex`}),` login until you add one.`]})]}):(0,G.jsx)(U,{children:n.accounts.map(e=>{let t=n.usages[e.id]??{};return(0,G.jsxs)(V,{dense:!0,className:`min-w-[300px] shrink-0 snap-start`,"data-testid":`account-card`,"data-account-id":e.id,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`text-sm font-medium truncate flex-1 min-w-0`,children:e.label}),(0,G.jsx)(`span`,{className:`text-[10px] uppercase tracking-wide text-text-subtle border border-border rounded px-1 shrink-0`,children:e.type}),e.planType&&(0,G.jsx)(`span`,{className:`text-[10px] text-text-subtle shrink-0`,children:e.planType}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>void n.remove(e.id),title:`Remove account`,"aria-label":`Remove account`,className:`p-2 rounded cursor-pointer text-text-subtle hover:text-error hover:bg-surface-elevated transition-colors shrink-0`,children:(0,G.jsx)(C,{className:`size-4`})})]}),(0,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsx)(B,{label:`5-Hour Session`,pct:$(t.fiveHour)}),(0,G.jsx)(B,{label:`Weekly`,pct:$(t.sevenDay)})]})]},e.id)})})]}),(0,G.jsx)(Q,{open:e===`add`,onOpenChange:e=>t(e?`add`:null),label:n.label,onLabelChange:n.setLabel,apiKey:n.apiKey,onApiKeyChange:n.setApiKey,adding:n.adding,onAddApiKey:()=>void n.addApiKey(),deviceWaiting:n.deviceWaiting,onStartDevice:()=>void n.startDevice(),device:n.device,error:n.err}),(0,G.jsx)(Ie,{mode:e===`export`?`export`:e===`import`?`import`:null,onOpenChange:e=>{e||t(null)},password:n.backupPassword,onPasswordChange:n.setBackupPassword,busy:n.exporting||n.importing,onExport:()=>void n.doExport(),onImport:e=>void n.doImport(e),error:n.err}),(0,G.jsx)(Re,{open:e===`rotation`,onOpenChange:e=>t(e?`rotation`:null),strategy:n.strategy,onChange:e=>void n.changeStrategy(e)})]})}var Ue=[{id:`claude`,label:`Claude`},{id:`codex`,label:`Codex`}];function We(){let[e,t]=(0,W.useState)(null),[n,r]=(0,W.useState)(`claude`);(0,W.useEffect)(()=>{let e=!1;return ie().then(n=>{e||t(new Set(Object.keys(n.providers??{})))}).catch(()=>{e||t(new Set([`claude`]))}),()=>{e=!0}},[]);let i=Ue.filter(t=>t.id===`claude`||e?.has(t.id)),a=i.length>1;return(0,G.jsxs)(`div`,{className:`space-y-4`,"data-testid":`accounts-pane`,"data-provider":n,children:[a&&(0,G.jsx)(`div`,{className:`flex gap-1 border-b border-border/50`,children:i.map(e=>(0,G.jsxs)(`button`,{onClick:()=>r(e.id),"data-testid":`accounts-tab-${e.id}`,"aria-current":n===e.id?`page`:void 0,className:`flex items-center gap-1.5 px-3 py-2 text-xs rounded-t transition-colors cursor-pointer ${n===e.id?`text-primary border-b-2 border-primary font-medium`:`text-text-subtle hover:text-text-secondary`}`,children:[(0,G.jsx)(F,{providerId:e.id}),e.label]},e.id))}),e===null&&!a&&(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,G.jsx)(s,{className:`size-3 animate-spin`}),` Checking configured providers...`]}),n===`claude`?(0,G.jsx)(Fe,{}):(0,G.jsx)(He,{})]})}export{We as AccountsSettingsSection};
@@ -1 +0,0 @@
1
- import{K as e}from"./vendor-mermaid-BKWscKt0.js";export{e as createArchitectureServices};
@@ -1,15 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/edit-diff-preview-DeHb85DN.js","assets/rolldown-runtime-FhOqtrmT.js","assets/vendor-markdown-Ls5AcU91.js","assets/libesm-DLBE59ul.js","assets/markdown-renderer-CKIBtz-k.js","assets/vendor-mermaid-BKWscKt0.js","assets/vendor-ui-CaeeFO0B.js","assets/markdown-renderer-pDOFHEG7.js","assets/index-C_s5DxFQ.js","assets/button-BZtEJcUv.js","assets/utils-C9OjCrou.js","assets/createLucideIcon-D8pyde1A.js","assets/arrow-left-CyFcsyzD.js","assets/bot-D6sx11y0.js","assets/check-DN75Ucvz.js","assets/chevron-down-Dp0rpHb8.js","assets/chevron-right-De-Wz5Lz.js","assets/chevron-up-8PbsNiJp.js","assets/circle-BCy0AUCo.js","assets/clock-C1CQUQPZ.js","assets/sparkles-Dh-_J2Rd.js","assets/copy-BewHj66E.js","assets/database-Y3ESDK4-.js","assets/download-DG3_9xXy.js","assets/use-coarse-long-press-BmI_GVW5.js","assets/eye-off-GjXVuAOn.js","assets/eye-gWwaF4Lg.js","assets/loader-circle-DPMrnLQ2.js","assets/monitor-C835ucWH.js","assets/x-YDu4m2Iq.js","assets/api-client-oY1tC3tM.js","assets/react-X4jUntEf.js","assets/window-store-DGKf9rPG.js","assets/window-pip-registry-BEN0QNSW.js","assets/panel-store-BRrnDO_i.js","assets/context-menu-C13b1uT3.js","assets/portal-container-context-a399Hd9F.js","assets/mobile-bottom-sheet-BD5b7KJF.js","assets/use-visual-viewport-rnvuooQZ.js","assets/use-is-mobile-CYW3FJFE.js","assets/project-store-BuY7rxn_.js","assets/ws-auth-Dawx17PM.js","assets/settings-store-Brjd0QnO.js","assets/tab-store-PZsP5ZwG.js","assets/apply-theme-DxTXOAcV.js","assets/resolve-theme-DQk_YcsT.js","assets/index-nP3uxXvR.css","assets/image-gallery-Cj8nd4xW.js","assets/run-in-terminal-bKRwuO2z.js","assets/api-client-BogqsFna.js"])))=>i.map(i=>d[i]);
2
- import{o as e}from"./rolldown-runtime-FhOqtrmT.js";import{S as t,x as n}from"./vendor-markdown-Ls5AcU91.js";import"./vendor-ui-CaeeFO0B.js";import{t as r}from"./createLucideIcon-D8pyde1A.js";import{t as i}from"./bot-D6sx11y0.js";import{t as a}from"./brain-KDa9jFRq.js";import{t as o}from"./check-DN75Ucvz.js";import{t as s}from"./chevron-down-Dp0rpHb8.js";import{t as c}from"./chevron-right-De-Wz5Lz.js";import{t as l}from"./chevron-up-8PbsNiJp.js";import{a as u,i as d,n as f,o as p,r as m}from"./tool-cards-DIF_JcFj.js";import{t as h}from"./circle-BCy0AUCo.js";import{t as g}from"./clock-C1CQUQPZ.js";import{t as _}from"./code-DJgYrFzm.js";import{t as v}from"./sparkles-Dh-_J2Rd.js";import{t as y}from"./copy-BewHj66E.js";import{n as b,r as x}from"./use-coarse-long-press-BmI_GVW5.js";import{t as S}from"./eye-gWwaF4Lg.js";import{t as C}from"./hand-x0ejq3fS.js";import{t as w}from"./loader-circle-DPMrnLQ2.js";import{t as ee}from"./shield-off-7jKWpJBD.js";import{t as te}from"./x-YDu4m2Iq.js";import{i as T,n as E,r as D,s as O}from"./api-client-oY1tC3tM.js";import{q as ne}from"./vendor-mermaid-BKWscKt0.js";import{t as k}from"./settings-store-Brjd0QnO.js";import{n as A,r as j,t as re}from"./utils-C9OjCrou.js";import"./portal-container-context-a399Hd9F.js";import{t as ie}from"./panel-store-BRrnDO_i.js";import"./window-store-DGKf9rPG.js";import{i as M}from"./project-store-BuY7rxn_.js";import{t as ae}from"./tab-store-PZsP5ZwG.js";import"./context-menu-C13b1uT3.js";import{n as oe}from"./use-is-mobile-CYW3FJFE.js";import{t as N}from"./button-BZtEJcUv.js";import{t as P}from"./mobile-bottom-sheet-BD5b7KJF.js";import"./use-visual-viewport-rnvuooQZ.js";import"./ws-auth-Dawx17PM.js";import{$t as F,An as se,Ar as ce,Bn as le,Cr as I,En as L,Er as R,Fn as ue,Fr as z,Gn as B,Hn as V,In as de,Ir as fe,It as H,Jt as pe,Kn as U,Kt as me,Ln as he,Lt as W,M as ge,Mr as G,N as _e,Nn as K,On as q,Or as ve,Pn as ye,Qn as J,Rn as be,Rt as xe,Tn as Se,Un as Ce,Xn as we,Yt as Te,Zn as Ee,_ as Y,_n as De,_r as Oe,bn as ke,cn as Ae,dr as je,gn as Me,hr as X,ir as Ne,j as Pe,jn as Fe,jr as Z,kr as Ie,lr as Le,nr as Re,on as ze,r as Be,t as Ve,tn as He,tr as Ue,vn as We,wn as Ge,yr as Ke,zn as qe}from"./index-C_s5DxFQ.js";import{t as Je}from"./use-websocket-DufdN3ZA.js";import{getAISettings as Ye}from"./api-settings-CTMdz_VF.js";import"./use-blob-url-Gfi69PtP.js";import{n as Xe,r as Ze,t as Qe}from"./image-gallery-Cj8nd4xW.js";import{t as $e}from"./libesm-DLBE59ul.js";import{t as et}from"./use-open-team-member-CruUTqzD.js";import{n as tt,t as nt}from"./send-to-chat-S8LCNX7V.js";import{t as rt}from"./ai-settings-section-Whh5k2zL.js";import{l as it,n as at,s as ot,t as st}from"./use-accounts-data--JHaCIoT.js";var ct=r(`activity`,[[`path`,{d:`M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2`,key:`169zse`}]]),lt=r(`chevrons-down`,[[`path`,{d:`m7 6 5 5 5-5`,key:`1lc07p`}],[`path`,{d:`m7 13 5 5 5-5`,key:`1d48rs`}]]),ut=r(`clipboard-check`,[[`rect`,{width:`8`,height:`4`,x:`8`,y:`2`,rx:`1`,ry:`1`,key:`tgr4d6`}],[`path`,{d:`M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2`,key:`116196`}],[`path`,{d:`m9 14 2 2 4-4`,key:`df797q`}]]),dt=r(`image-off`,[[`line`,{x1:`2`,x2:`22`,y1:`2`,y2:`22`,key:`a6p6uj`}],[`path`,{d:`M10.41 10.41a2 2 0 1 1-2.83-2.83`,key:`1bzlo9`}],[`line`,{x1:`13.5`,x2:`6`,y1:`13.5`,y2:`21`,key:`1q0aeu`}],[`line`,{x1:`18`,x2:`21`,y1:`12`,y2:`15`,key:`5mozeu`}],[`path`,{d:`M3.59 3.59A1.99 1.99 0 0 0 3 5v14a2 2 0 0 0 2 2h14c.55 0 1.052-.22 1.41-.59`,key:`mmje98`}],[`path`,{d:`M21 15V5a2 2 0 0 0-2-2H9`,key:`43el77`}]]),ft=r(`list-ordered`,[[`path`,{d:`M11 5h10`,key:`1cz7ny`}],[`path`,{d:`M11 12h10`,key:`1438ji`}],[`path`,{d:`M11 19h10`,key:`11t30w`}],[`path`,{d:`M4 4h1v5`,key:`10yrso`}],[`path`,{d:`M4 9h2`,key:`r1h2o0`}],[`path`,{d:`M6.5 20H3.4c0-1 2.6-1.925 2.6-3.5a1.5 1.5 0 0 0-2.6-1.02`,key:`xtkcd5`}]]),pt=r(`mic-off`,[[`path`,{d:`M12 19v3`,key:`npa21l`}],[`path`,{d:`M15 9.34V5a3 3 0 0 0-5.68-1.33`,key:`1gzdoj`}],[`path`,{d:`M16.95 16.95A7 7 0 0 1 5 12v-2`,key:`cqa7eg`}],[`path`,{d:`M18.89 13.23A7 7 0 0 0 19 12v-2`,key:`16hl24`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M9 9v3a3 3 0 0 0 5.12 2.12`,key:`r2i35w`}]]),mt=r(`paperclip`,[[`path`,{d:`m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551`,key:`1miecu`}]]),ht=r(`slash`,[[`path`,{d:`M22 2 2 22`,key:`y4kqgn`}]]),Q=e(t(),1),gt={maxImages:4,maxBase64PerImage:5e6,maxBase64Total:1e7};function _t(e){let t=[],n=0;for(let r of e)if(r.imageData){if(t.length>=gt.maxImages)break;r.imageData.data.length>gt.maxBase64PerImage||n+r.imageData.data.length>gt.maxBase64Total||(n+=r.imageData.data.length,t.push(r.imageData))}return t}function vt(e,t){let n=new Set(t),r=[],i=[];for(let t of e)t.serverPath&&(t.imageData&&n.has(t.imageData)?r.push(t.serverPath):i.push(t.serverPath));return{inlineImagePaths:r,pathOnlyPaths:i}}function yt(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n)|0;return Math.abs(t).toString(36)}function bt(e,t){let n=`pc-${yt(t)}-`;return e.map(e=>e.id?{...e,id:`${n}${e.id}`}:e)}function xt(e,t){if(t.size===0)return e;let n=[];for(let r of e){let e=r.id?t.get(r.id):void 0;e&&e.length>0&&n.push(...e),n.push(r)}return n}var St=null;function Ct(){return St||=new AudioContext,St}function wt(e,t,n,r,i=`sine`){let a=Ct(),o=a.createOscillator(),s=a.createGain();o.type=i,o.frequency.value=e,s.gain.setValueAtTime(r,n),s.gain.exponentialRampToValueAtTime(.001,n+t),o.connect(s),s.connect(a.destination),o.start(n),o.stop(n+t)}function Tt(){let e=Ct().currentTime;wt(523,.15,e,.15),wt(659,.2,e+.12,.15)}function Et(){let e=Ct().currentTime;wt(880,.12,e,.18,`square`),wt(698,.12,e+.15,.18,`square`),wt(880,.15,e+.3,.15,`square`)}function Dt(){let e=Ct().currentTime;wt(440,.12,e,.12),wt(523,.12,e+.1,.12),wt(659,.18,e+.2,.12)}var Ot={done:Tt,approval_request:Et,question:Dt};function kt(e){try{Ot[e]?.()}catch{}}var At={hasTeams:!1,teamNames:[],messageCount:0,unreadCount:0};function jt(e){if(document.hidden)return!1;let{panels:t}=ie.getState();for(let n of Object.values(t)){let t=n.tabs.find(e=>e.id===n.activeTabId);if(t?.type===`chat`&&t.metadata?.sessionId===e)return!0}return!1}function Mt(e,t=`claude`,n=``,r){let[i,a]=(0,Q.useState)([]),[o,s]=(0,Q.useState)(new Map),[c,l]=(0,Q.useState)(!1),[u,d]=(0,Q.useState)({}),[f,p]=(0,Q.useState)(`idle`),[m,h]=(0,Q.useState)(!1),[g,_]=(0,Q.useState)(0),[v,y]=(0,Q.useState)(null),[b,x]=(0,Q.useState)(null),[S,C]=(0,Q.useState)(null),[w,ee]=(0,Q.useState)([]),te=(0,Q.useRef)([]),[ne,k]=(0,Q.useState)(null),[A,j]=(0,Q.useState)(null),[re,M]=(0,Q.useState)(!1),[ae,oe]=(0,Q.useState)(null),[N,P]=(0,Q.useState)(null),F=(0,Q.useRef)(null),se=(0,Q.useRef)(null),[ce,le]=(0,Q.useState)(null),I=(0,Q.useRef)(null),[L,R]=(0,Q.useState)(!0),ue=(0,Q.useRef)(null),z=(0,Q.useRef)(null),B=(0,Q.useRef)(``),V=(0,Q.useRef)([]),de=(0,Q.useRef)(new Map),fe=(0,Q.useRef)(null),H=(0,Q.useRef)(`idle`),pe=(0,Q.useRef)(null),U=(0,Q.useRef)(()=>{}),me=(0,Q.useRef)(null),he=(0,Q.useRef)(!1),W=(0,Q.useRef)(new Set),ge=(0,Q.useRef)(0),G=(0,Q.useRef)(null),_e=(0,Q.useRef)(0),K=(0,Q.useRef)(e);K.current=e;let q=(0,Q.useRef)(r);q.current=r;let ve=(0,Q.useRef)([]);ve.current=i;let ye=(0,Q.useRef)(n);ye.current=n;let J=(0,Q.useRef)(null),be=(0,Q.useRef)(0),xe=(0,Q.useRef)({teamNames:new Set,messages:[]}),Se=(0,Q.useRef)(0),[Ce,we]=(0,Q.useState)(At),[Te,Ee]=(0,Q.useState)([]),Y=(0,Q.useCallback)(()=>{let e=xe.current;we({hasTeams:e.teamNames.size>0,teamNames:Array.from(e.teamNames),messageCount:e.messages.length,unreadCount:Se.current}),Ee([...e.messages])},[]),De=(0,Q.useCallback)(()=>{Se.current=0,Y()},[Y]),Oe=(0,Q.useCallback)(async e=>{try{let t=await E.get(`/api/teams/${encodeURIComponent(e)}`);if(!t?.messages)return;let n=xe.current.messages,r=t.messages.filter(e=>!n.some(t=>t.timestamp===e.timestamp&&t.from===e.from));n.push(...r),n.sort((e,t)=>new Date(e.timestamp).getTime()-new Date(t.timestamp).getTime()),n.length>500&&n.splice(0,n.length-500),Y()}catch{}},[Y]),ke=f!==`idle`;(0,Q.useEffect)(()=>{if(e)return ze.getState().setStreaming(e,f!==`idle`,n),()=>{ze.getState().setStreaming(e,!1)}},[e,f,n]);let Ae=(0,Q.useCallback)((e,t)=>{let n=V.current.findIndex(e=>e.type===`tool_use`&&(e.tool===`Agent`||e.tool===`Task`)&&e.toolUseId===t);if(n===-1)return!1;let r=V.current[n];if(r.type!==`tool_use`)return!1;let i=[...r.children??[],e];return V.current[n]={...r,children:i},!0},[]),je=(0,Q.useCallback)((e,t)=>{let n=e=>e.type===`tool_use`&&(e.tool===`Agent`||e.tool===`Task`)&&e.toolUseId===t,r=ve.current,i=-1;for(let e=r.length-1;e>=0;e--)if(r[e].events?.some(n)){i=e;break}return i===-1?!1:(a(t=>{let r=-1;for(let e=t.length-1;e>=0;e--)if(t[e].events?.some(n)){r=e;break}if(r===-1)return t;let i=t[r],a=i.events.map(t=>{if(!n(t)||t.type!==`tool_use`)return t;let r=[...t.children??[]],i=e.toolUseId,a=i?r.findIndex(t=>t.type===e.type&&t.toolUseId===i):-1;return a===-1?r.push(e):r[a]=e,{...t,children:r}});return[...t.slice(0,r),{...i,events:a},...t.slice(r+1)]}),!0)},[]),Me=(0,Q.useCallback)(()=>{be.current=0;let e=B.current,t=[...V.current],n=fe.current;(0,Q.startTransition)(()=>{a(r=>{let i=r[r.length-1];return i?.role===`assistant`&&!i.id.startsWith(`final-`)?[...r.slice(0,-1),{...i,content:e,events:t,...n}]:[...r,{id:`streaming-${Date.now()}`,role:`assistant`,content:e,events:t,timestamp:new Date().toISOString(),...n}]})})},[]),X=(0,Q.useCallback)(()=>{be.current||=window.setTimeout(Me,100)},[Me]),Ne=(0,Q.useCallback)((e,t)=>{let n=t=>t.type===`tool_use`&&(t.tool===`Agent`||t.tool===`Task`)&&t.toolUseId===e,r=V.current.findIndex(n);if(r!==-1){V.current[r]={...V.current[r],bgStatus:t},X();return}a(e=>{let r=-1;for(let t=e.length-1;t>=0;t--)if(e[t].events?.some(n)){r=t;break}if(r===-1)return e;let i=e[r],a=i.events.map(e=>n(e)?{...e,bgStatus:t}:e);return[...e.slice(0,r),{...i,events:a},...e.slice(r+1)]})},[X]),Pe=(0,Q.useCallback)(e=>{let t=e,n=t?.type;if(!n)return;let r=e=>{let n=V.current,r=n.findIndex(e);r===-1?n.push(t):n[r]=t};switch(n){case`account_info`:fe.current={accountId:t.accountId,accountLabel:t.accountLabel},k(null);break;case`account_retry`:t.accountId&&t.accountLabel&&(fe.current={accountId:t.accountId,accountLabel:t.accountLabel}),V.current=[t],X();break;case`status_update`:{let e=t.accountLabel?` (${t.accountLabel})`:``;k(`${t.message}${e}`);break}case`text`:{let e=t.parentToolUseId;if(e&&Ae(t,e)){X();break}if(e){je(t,e);break}B.current+=t.content,V.current.push(t),X();break}case`thinking`:{let e=t.parentToolUseId;if(e&&Ae(t,e)){X();break}if(e){je(t,e);break}V.current.push(t),X();break}case`tool_use`:{if(t.tool===`AskUserQuestion`){t.toolUseId&&W.current.add(t.toolUseId);break}let e=t.parentToolUseId;if(e&&Ae(t,e)){X();break}if(e){je(t,e);break}let n=t.toolUseId;r(e=>!!n&&e.type===`tool_use`&&e.toolUseId===n),X();break}case`tool_result`:{let e=t.toolUseId;if(e&&de.current.delete(e),e&&W.current.has(e))break;let n=t.parentToolUseId;if(n&&Ae(t,n)){X();break}if(n){je(t,n);break}r(t=>!!e&&t.type===`tool_result`&&t.toolUseId===e),X();break}case`approval_resolved`:{let e=t.requestId;if(t.approved&&t.answers){let n=V.current.find(t=>t.type===`approval_request`&&t.requestId===e&&t.tool===`AskUserQuestion`),r=n&&n.input;r&&typeof r==`object`&&(r.answers=t.answers,a(e=>[...e]))}y(t=>t&&t.requestId===e?null:t),J.current!=null&&(O.dismiss(J.current),J.current=null);break}case`approval_request`:if(r(e=>e.type===`approval_request`&&e.requestId===t.requestId),he.current)break;if(y({requestId:t.requestId,tool:t.tool,input:t.input}),K.current&&!jt(K.current)){kt(t.tool===`AskUserQuestion`?`question`:`approval_request`);let e=K.current,n=t.tool===`AskUserQuestion`;J.current=O[n?`info`:`warning`](n?`AI has a question`:`${t.tool} needs permission`,{description:ye.current||`Session ${e.slice(0,8)}`,duration:1/0,action:{label:`Go to session`,onClick:()=>{let{panels:t}=ie.getState();for(let[n,r]of Object.entries(t)){let t=r.tabs.find(t=>t.metadata?.sessionId===e);if(t){ie.getState().setActiveTab(t.id,n);break}}}}})}break;case`error`:a(e=>{let n=e[e.length-1];if(n?.role===`assistant`){let r=V.current,i=r[r.length-1],a=i?.type===`error`&&i.message===t.message?r:[...r,t];return V.current=a,[...e.slice(0,-1),{...n,events:a}]}return n?.role===`system`&&n.content===t.message?e:[...e,{id:`error-${Date.now()}`,role:`system`,content:t.message,events:[t],timestamp:new Date().toISOString()}]});break;case`team_detected`:{let e=t.teamName;e&&(xe.current.teamNames.add(e),Y(),Oe(e));break}case`team_inbox`:{let e=t.messages;if(Array.isArray(e)){let t=xe.current.messages;t.push(...e),t.length>500&&t.splice(0,t.length-500),Se.current+=e.length,Y()}break}case`team_updated`:Y();break;case`bash_output`:{let e=t.toolUseId;if(e){let n=de.current.get(e);n?(n.content+=t.content,n.content.length>5e5&&(n.content=n.content.slice(-5e5)),n.lineCount=t.lineCount):de.current.set(e,{content:t.content,lineCount:t.lineCount}),X()}break}case`subagent_status`:{let e=t.toolUseId,n=t.status;e&&n&&Ne(e,n);break}case`background_registry`:{let e=t.shells??[];te.current=e,ee(e);break}case`done`:{if(H.current===`idle`)break;t.contextWindowPct!=null&&x(t.contextWindowPct),K.current&&!jt(K.current)&&kt(`done`),be.current&&=(clearTimeout(be.current),0);let e=B.current,n=[...V.current],r=fe.current,i=t.lastMessageUuid,o=t.usage;a(t=>{let a=t[t.length-1];return a?.role===`assistant`?[...t.slice(0,-1),{...a,id:`final-${Date.now()}`,content:e||a.content,events:n.length>0?n:a.events,...i&&{sdkUuid:i},...o&&{usage:o}}]:e||n.length>0?[...t,{id:`final-${Date.now()}`,role:`assistant`,content:e,events:n,timestamp:new Date().toISOString(),...i&&{sdkUuid:i},...o&&{usage:o},...r}]:t}),B.current=``,V.current=[],fe.current=null,G.current=null,de.current.clear(),k(null);break}}},[Ae,je,X,Ne,Y,Oe]),Fe=(0,Q.useCallback)(e=>{let t;try{t=JSON.parse(e.data)}catch{return}if(t.type!==`ping`){if(t.type===`user_message`){let e=t.content;a(n=>{let r=n[n.length-1];return r?.role===`user`&&r.content===e?n:[...n,{id:`user-remote-${Date.now()}`,role:`user`,content:e,timestamp:t.timestamp??new Date().toISOString()}]});return}if(t.type===`title_updated`){j(t.title??null);return}if(t.type===`session_migrated`){let e=t.newSessionId;e&&e!==K.current&&q.current?.(e);return}if(t.type===`compact_status`){let e=t.status;e===`compacting`?C(`compacting`):e===`done`&&C(null);return}if(t.type===`phase_changed`){let e=t.phase;p(e),H.current=e,_(e===`connecting`?t.elapsed??0:0),e===`idle`&&C(null);return}if(t.type===`session_state`){M(!0),oe(t.sessionId??K.current);let e=t,n=e.phase,r=H.current===`idle`;if(p(n),H.current=n,e.sessionTitle&&j(e.sessionTitle),e.model&&(se.current&&e.model!==se.current||(e.model===se.current&&(se.current=null),P(e.model),F.current=e.model)),typeof e.effort==`string`&&(le(e.effort),I.current=e.effort),typeof e.thinking==`boolean`&&R(e.thinking),e.pendingApproval&&y({requestId:e.pendingApproval.requestId,tool:e.pendingApproval.tool,input:e.pendingApproval.input}),C(e.compactStatus===`compacting`?`compacting`:null),n===`idle`){let e=Date.now()-_e.current<5e3;r&&e||me.current?.(),h(!1)}return}if(t.type===`turn_events`){let e=t.events,n=t.userMessage;if(!e?.length&&!n){h(!1);return}ge.current&&=(cancelAnimationFrame(ge.current),0),G.current=n,a(e=>{let t=[...e],r=t.length;for(;r>0&&t[r-1].role===`assistant`;)r--;if(n!=null&&r>0&&t[r-1].role===`user`&&t[r-1].content===n)t=t.slice(0,r-1);else{let e=t[t.length-1];e?.role===`assistant`&&e.id.startsWith(`streaming-`)&&(t=t.slice(0,-1))}if(n){let e=t[t.length-1];(e?.role!==`user`||e.content!==n)&&(t=[...t,{id:`user-replay-${Date.now()}`,role:`user`,content:n,timestamp:new Date().toISOString()}])}return t}),B.current=``,V.current=[],fe.current=null,he.current=!0;let r=0,i=()=>{let t=Math.min(r+100,e.length);for(let n=r;n<t;n++)Pe(e[n]);r=t,r<e.length?ge.current=requestAnimationFrame(i):(ge.current=0,he.current=!1,h(!1))};ge.current=requestAnimationFrame(i);return}Pe(t)}},[Pe]),{send:Z,connect:Ie}=Je({url:e&&n?`/ws/project/${encodeURIComponent(n)}/chat/${e}`:``,onMessage:Fe,autoConnect:!!e&&!!n});U.current=Z,(0,Q.useEffect)(()=>{let r=!1;z.current&&z.current!==e&&(se.current=null,ue.current=null),z.current=e??null,p(`idle`),H.current=`idle`,y(null),J.current!=null&&(O.dismiss(J.current),J.current=null),C(null),s(new Map),d({}),B.current=``,V.current=[],G.current=null,_e.current=0,de.current.clear(),be.current&&=(clearTimeout(be.current),0),M(!1),oe(null),xe.current={teamNames:new Set,messages:[]},Se.current=0,we(At),Ee([]),e&&E.get(`/api/teams`).then(t=>{r||!Array.isArray(t)||t.filter(t=>(t?.name??t?.team_name)===e).length!==0&&(xe.current.teamNames.add(e),Y(),Oe(e))}).catch(()=>{});let i=new Set(ve.current.map(e=>e.id));return e&&n?(l(!0),E.get(`${T(n)}/chat/sessions/${e}/messages?providerId=${t}`).then(e=>{if(r)return;let t=Array.isArray(e)?{messages:e,versionMap:{}}:e,n=Array.isArray(t?.messages)?t.messages:[];t?.versionMap&&d(t.versionMap),t?.canonicalSessionId&&t.canonicalSessionId!==K.current&&q.current?.(t.canonicalSessionId);let o=G.current;if(o!=null){for(let e=n.length-1;e>=0;e--)if(n[e].role===`user`&&n[e].content===o){n=n.slice(0,e);break}}a(e=>{let t=e.filter(e=>!i.has(e.id));return[...n,...t]}),_e.current=Date.now()}).catch(()=>{r||a(e=>e.filter(e=>!i.has(e.id)))}).finally(()=>{r||l(!1)})):a([]),()=>{r=!0}},[e,t,n,Y,Oe]);let Le=(0,Q.useCallback)((e,t)=>{if(!e.trim()&&!t?.images?.length)return;let n=H.current!==`idle`;if(n){be.current&&=(clearTimeout(be.current),0);let e=B.current,t=[...V.current];a(n=>{let r=n[n.length-1];return r?.role===`assistant`?[...n.slice(0,-1),{...r,id:`final-${Date.now()}`,content:e||r.content,events:t.length>0?t:r.events}]:n})}a(t=>[...t,{id:`user-${Date.now()}`,role:`user`,content:e,timestamp:new Date().toISOString()}]),B.current=``,V.current=[],pe.current=null,n?(p(`thinking`),H.current=`thinking`):(p(`initializing`),H.current=`initializing`),y(null),J.current!=null&&(O.dismiss(J.current),J.current=null),Z(JSON.stringify({type:`message`,content:e,permissionMode:t?.permissionMode,priority:t?.priority,images:t?.images,imagePaths:t?.imagePaths,...F.current&&{model:F.current},...I.current&&{effort:I.current},...ue.current!==null&&{thinking:ue.current}}))},[Z]),Re=(0,Q.useCallback)(e=>{P(e),F.current=e,se.current=e,Z(JSON.stringify({type:`set_model`,model:e}))},[Z]),Be=(0,Q.useCallback)(e=>{le(e),I.current=e,Z(JSON.stringify({type:`set_effort`,effort:e}))},[Z]),He=(0,Q.useCallback)(e=>{R(e),ue.current=e,Z(JSON.stringify({type:`set_thinking`,enabled:e}))},[Z]),Ue=(0,Q.useCallback)((e,t,n)=>{if(Z(JSON.stringify({type:`approval_response`,requestId:e,approved:t,data:n})),t&&n){let t=V.current.find(t=>t.type===`approval_request`&&t.requestId===e&&t.tool===`AskUserQuestion`);if(t){let e=t.input;e&&typeof e==`object`&&(e.answers=n)}a(e=>[...e])}y(null),J.current!=null&&(O.dismiss(J.current),J.current=null)},[Z]),We=(0,Q.useCallback)(()=>{if(H.current===`idle`)return;Z(JSON.stringify({type:`cancel`}));let e=B.current,t=[...V.current];a(n=>{let r=n[n.length-1];return r?.role===`assistant`?[...n.slice(0,-1),{...r,id:`final-${Date.now()}`,content:e||r.content,events:t.length>0?t:r.events}]:n}),B.current=``,V.current=[],de.current.clear(),pe.current=null,p(`idle`),H.current=`idle`,y(null),J.current!=null&&(O.dismiss(J.current),J.current=null)},[Z]),Ge=(0,Q.useCallback)(e=>{e&&Z(JSON.stringify({type:`kill_background_shell`,shellId:e}))},[Z]),Ke=(0,Q.useCallback)(e=>{if(!e)return;let t=e.replace(/\.output$/,``);return te.current.find(n=>n.shellId===t||n.outputPath.endsWith(e)||n.outputPath.endsWith(`${t}.output`))},[]);(0,Q.useEffect)(()=>{e&&Ve.getState().setSessionShells(e,w)},[e,w]),(0,Q.useEffect)(()=>{if(e)return Ve.getState().retainSession(e),()=>{Ve.getState().releaseSession(e)}},[e]);let qe=(0,Q.useCallback)(()=>{M(!1),h(!0),Ie()},[Ie]),Ye=(0,Q.useCallback)(()=>{!e||!n||fetch(`${T(n)}/chat/sessions/${e}/messages?providerId=${t}`,{headers:{Authorization:`Bearer ${D()}`}}).then(e=>e.json()).then(e=>{if(H.current!==`idle`)return;let t=e.ok?Array.isArray(e.data)?{messages:e.data,versionMap:void 0}:e.data:null;t?.versionMap&&d(t.versionMap),Array.isArray(t?.messages)&&t.messages.length>0&&(a(t.messages),B.current=``,V.current=[]),_e.current=Date.now()}).catch(()=>{})},[e,t,n]);me.current=Ye;let Xe=(0,Q.useCallback)(async(e,t)=>{if(!n)throw Error(`No project context available`);let r=e.replace(/^pc-[^-]+-/,``),i=`${T(n)}/chat/pre-compact-messages?jsonlPath=${encodeURIComponent(t)}&before=${encodeURIComponent(r)}`,a=bt(await E.get(i),t);return s(t=>{let n=new Map(t);return n.set(e,a),n}),a.length},[n]),Ze=(0,Q.useCallback)(e=>o.has(e),[o]),Qe=(0,Q.useCallback)(e=>{a(t=>t.filter(t=>t.id!==e))},[]),$e=(0,Q.useCallback)(()=>{a(e=>e.filter(e=>e.role!==`system`))},[]);return{messages:i,renderedMessages:(0,Q.useMemo)(()=>xt(i,o),[i,o]),expandCompact:Xe,isCompactExpanded:Ze,dismissMessage:Qe,clearErrors:$e,messagesLoading:c,versionMap:u,isStreaming:ke,phase:f,isReconnecting:m,connectingElapsed:g,pendingApproval:v,contextWindowPct:b,compactStatus:S,statusMessage:ne,sessionTitle:A,model:N,setModel:Re,effort:ce,setEffort:Be,thinking:L,setThinking:He,teamActivity:Ce,teamMessages:Te,markTeamRead:De,bashPartialOutput:de,backgroundShells:w,killBackgroundShell:Ge,findBackgroundShellByOutput:Ke,sendMessage:Le,respondToApproval:Ue,cancelStreaming:We,reconnect:qe,refetchMessages:Ye,isConnected:re&&ae===e}}var Nt=12e4;function Pt(e,t=`claude`,n){let r=JSON.stringify([e,t,n]),[i,a]=(0,Q.useState)(null),[o,s]=(0,Q.useState)(!1),c=(0,Q.useRef)(null),l=(0,Q.useRef)(0),u=(0,Q.useCallback)((i=!1)=>{if(!e)return;let o=++l.current;s(!0);let c=i?`&refresh=1`:``,u=n?`&session=${encodeURIComponent(n)}`:``;E.get(`${T(e)}/chat/usage?providerId=${t}${u}${c}`).then(e=>{o===l.current&&a({scope:r,usage:e??{},fetchedAt:e?.lastFetchedAt??null})}).catch(()=>{}).finally(()=>{o===l.current&&s(!1)})},[e,t,n,r]);(0,Q.useEffect)(()=>(a(null),s(!1),u(),c.current=setInterval(()=>u(),Nt),()=>{++l.current,c.current&&clearInterval(c.current)}),[u]);let d=(0,Q.useCallback)(()=>u(!0),[u]),f=i?.scope===r?i:null;return{usageInfo:f?.usage??{},usageLoading:o,lastFetchedAt:f?.fetchedAt??null,refreshUsage:d}}var Ft={damping:.7,stiffness:.05,mass:1.25},It=70,Lt=1e3/60,Rt=350,zt=!1;globalThis.document?.addEventListener(`mousedown`,()=>{zt=!0}),globalThis.document?.addEventListener(`mouseup`,()=>{zt=!1}),globalThis.document?.addEventListener(`click`,()=>{zt=!1});var Bt=(e={})=>{let[t,n]=(0,Q.useState)(!1),[r,i]=(0,Q.useState)(e.initial!==!1),[a,o]=(0,Q.useState)(!1),s=(0,Q.useRef)(null);s.current=e;let c=(0,Q.useCallback)(()=>{if(!zt)return!1;let e=window.getSelection();if(!e||!e.rangeCount)return!1;let t=e.getRangeAt(0);return t.commonAncestorContainer.contains(g.current)||g.current?.contains(t.commonAncestorContainer)},[]),l=(0,Q.useCallback)(e=>{d.isAtBottom=e,i(e)},[]),u=(0,Q.useCallback)(e=>{d.escapedFromLock=e,n(e)},[]),d=(0,Q.useMemo)(()=>{let n;return{escapedFromLock:t,isAtBottom:r,resizeDifference:0,accumulated:0,velocity:0,listeners:new Set,get scrollTop(){return g.current?.scrollTop??0},set scrollTop(e){if(g.current){let{scrollBehavior:t}=getComputedStyle(g.current);t!==`auto`&&(g.current.style.scrollBehavior=`auto`),g.current.scrollTop=e,d.ignoreScrollToTop=g.current.scrollTop,t!==`auto`&&(g.current.style.scrollBehavior=t)}},get targetScrollTop(){return!g.current||!_.current?0:g.current.scrollHeight-1-g.current.clientHeight},get calculatedTargetScrollTop(){if(!g.current||!_.current)return 0;let{targetScrollTop:t}=this;if(!e.targetScrollTop)return t;if(n?.targetScrollTop===t)return n.calculatedScrollTop;let r=Math.max(Math.min(e.targetScrollTop(t,{scrollElement:g.current,contentElement:_.current}),t),0);return n={targetScrollTop:t,calculatedScrollTop:r},requestAnimationFrame(()=>{n=void 0}),r},get scrollDifference(){return this.calculatedTargetScrollTop-this.scrollTop},get isNearBottom(){return this.scrollDifference<=It}}},[]),f=(0,Q.useCallback)((e={})=>{typeof e==`string`&&(e={animation:e}),e.preserveScrollPosition||l(!0);let t=Date.now()+(Number(e.wait)||0),n=Ut(s.current,e.animation),{ignoreEscapes:r=!1}=e,i,a=d.calculatedTargetScrollTop;e.duration instanceof Promise?e.duration.finally(()=>{i=Date.now()}):i=t+(e.duration??0);let o=async()=>{let e=new Promise(requestAnimationFrame).then(()=>{if(!d.isAtBottom)return d.animation=void 0,!1;let{scrollTop:l}=d,u=performance.now(),p=(u-(d.lastTick??u))/Lt;if(d.animation||={behavior:n,promise:e,ignoreEscapes:r},d.animation.behavior===n&&(d.lastTick=u),c()||t>Date.now())return o();if(l<Math.min(a,d.calculatedTargetScrollTop)){if(d.animation?.behavior===n){if(n===`instant`)return d.scrollTop=d.calculatedTargetScrollTop,o();d.velocity=(n.damping*d.velocity+n.stiffness*d.scrollDifference)/n.mass,d.accumulated+=d.velocity*p,d.scrollTop+=d.accumulated,d.scrollTop!==l&&(d.accumulated=0)}return o()}return i>Date.now()?(a=d.calculatedTargetScrollTop,o()):(d.animation=void 0,d.scrollTop<d.calculatedTargetScrollTop?f({animation:Ut(s.current,s.current.resize),ignoreEscapes:r,duration:Math.max(0,i-Date.now())||void 0}):d.isAtBottom)});return e.then(e=>(requestAnimationFrame(()=>{d.animation||(d.lastTick=void 0,d.velocity=0)}),e))};return e.wait!==!0&&(d.animation=void 0),d.animation?.behavior===n?d.animation.promise:o()},[l,c,d]),p=(0,Q.useCallback)(()=>{u(!0),l(!1)},[u,l]),m=(0,Q.useCallback)(({target:e})=>{if(e!==g.current)return;let{scrollTop:t,ignoreScrollToTop:n}=d,{lastScrollTop:r=t}=d;d.lastScrollTop=t,d.ignoreScrollToTop=void 0,n&&n>t&&(r=n),o(d.isNearBottom),setTimeout(()=>{if(d.resizeDifference||t===n)return;if(c()){u(!0),l(!1);return}let e=t>r,i=t<r;if(d.animation?.ignoreEscapes){d.scrollTop=r;return}i&&(u(!0),l(!1)),e&&u(!1),!d.escapedFromLock&&d.isNearBottom&&l(!0)},1)},[u,l,c,d]),h=(0,Q.useCallback)(({target:e,deltaY:t})=>{let n=e;for(;![`scroll`,`auto`].includes(getComputedStyle(n).overflow);){if(!n.parentElement)return;n=n.parentElement}n===g.current&&t<0&&g.current.scrollHeight>g.current.clientHeight&&!d.animation?.ignoreEscapes&&(u(!0),l(!1))},[u,l,d]),g=Vt(e=>{g.current?.removeEventListener(`scroll`,m),g.current?.removeEventListener(`wheel`,h),e?.addEventListener(`scroll`,m,{passive:!0}),e?.addEventListener(`wheel`,h,{passive:!0})},[]),_=Vt(e=>{if(d.resizeObserver?.disconnect(),d.resizeObserver=void 0,!e)return;let t;d.resizeObserver=new ResizeObserver(([e])=>{let{height:n}=e.contentRect,r=n-(t??n);if(d.resizeDifference=r,d.scrollTop>d.targetScrollTop&&(d.scrollTop=d.targetScrollTop),o(d.isNearBottom),r>=0){let e=Ut(s.current,t?s.current.resize:s.current.initial);f({animation:e,wait:!0,preserveScrollPosition:!0,duration:e===`instant`?void 0:Rt})}else d.isNearBottom&&(u(!1),l(!0));t=n,requestAnimationFrame(()=>{setTimeout(()=>{d.resizeDifference===r&&(d.resizeDifference=0)},1)})}),d.resizeObserver?.observe(e)},[]);return{contentRef:_,scrollRef:g,scrollToBottom:f,stopScroll:p,isAtBottom:r||a,isNearBottom:a,escapedFromLock:t,state:d}};function Vt(e,t){let n=(0,Q.useCallback)(t=>(n.current=t,e(t)),t);return n}var Ht=new Map;function Ut(...e){let t={...Ft},n=!1;for(let r of e){if(r===`instant`){n=!0;continue}typeof r==`object`&&(n=!1,t.damping=r.damping??t.damping,t.stiffness=r.stiffness??t.stiffness,t.mass=r.mass??t.mass)}let r=JSON.stringify(t);return Ht.has(r)||Ht.set(r,Object.freeze(t)),n?`instant`:Ht.get(r)}var Wt=60,Gt=8,Kt=1400;function qt(e){if(e.scrollHeight<=e.clientHeight)return!1;let t=getComputedStyle(e).overflowY;return t===`auto`||t===`scroll`}function Jt(e,t){let n=[],r=e.parentElement;for(;r&&r!==t;)qt(r)&&n.push(r),r=r.parentElement;return n}function Yt(){return typeof matchMedia==`function`&&matchMedia(`(prefers-reduced-motion: reduce)`).matches}function Xt(e,t){let n=e.querySelector(`[data-edit-ref="${CSS.escape(t)}"]`);if(n)return{el:n,level:`edit`};let r=t.replace(/-\d+$/,``),i=e.querySelector(`[data-tool-ref="${CSS.escape(r)}"]`);return i?{el:i,level:`card`}:null}function Zt(e,t,n,r){let i=e.scrollTop+t.getBoundingClientRect().top-e.getBoundingClientRect().top-n;e.scrollTo({top:i,behavior:r?`smooth`:`auto`})}function Qt(e,t){let n=Xt(e,t);if(!n)return()=>{};let{el:r,level:i}=n;for(let t of Jt(r,e))Zt(t,r,Gt,!1);Zt(e,r,Wt,!Yt()),r.dataset.flash=i;let a=setTimeout(()=>{delete r.dataset.flash},Kt);return()=>{clearTimeout(a),delete r.dataset.flash}}var $t=new Set([`Write`,`Edit`,`MultiEdit`,`NotebookEdit`]),en={create:3,write:2,notebook:2,edit:1};function tn(e){return typeof e==`string`?e:``}function nn(e,t){let n=0,r=0;for(let i of $e(e,t))i.added?n+=i.count??0:i.removed&&(r+=i.count??0);return{added:n,removed:r}}function rn(e){return e&&/created successfully/i.test(e)?`create`:`write`}function an(e,t,n){switch(e){case`Write`:{let e=tn(t.file_path);return e?{filePath:e,op:rn(n),fragments:[{oldStr:``,newStr:tn(t.content)}]}:null}case`Edit`:{let e=tn(t.file_path);return e?{filePath:e,op:`edit`,fragments:[{oldStr:tn(t.old_string),newStr:tn(t.new_string)}]}:null}case`MultiEdit`:{let e=tn(t.file_path);if(!e||!Array.isArray(t.edits))return null;let n=t.edits.filter(e=>!!e&&typeof e==`object`).map(e=>({oldStr:tn(e.old_string),newStr:tn(e.new_string)}));return n.length===0?null:{filePath:e,op:`edit`,fragments:n}}case`NotebookEdit`:{let e=tn(t.notebook_path)||tn(t.file_path);return e?{filePath:e,op:`notebook`,fragments:[{oldStr:``,newStr:tn(t.new_source)}]}:null}default:return null}}function on(e,t){if(e){for(let n of e)if(n.type===`tool_result`&&n.toolUseId&&t.set(n.toolUseId,n.output??``),n.type===`tool_use`){let e=n.result;n.toolUseId&&e?.output!=null&&!t.has(n.toolUseId)&&t.set(n.toolUseId,e.output),on(n.children,t)}}}function sn(e,t,n,r){if(e)for(let i of e){if(i.type!==`tool_use`||(i.children?.length&&sn(i.children,!0,n,r),!$t.has(i.tool)))continue;let e=i.input&&typeof i.input==`object`?i.input:null;if(!e)continue;let a=an(i.tool,e,i.toolUseId?r.get(i.toolUseId):void 0);if(!a)continue;let o=n.get(a.filePath);o||(o={filePath:a.filePath,op:a.op,editCount:0,linesAdded:0,linesRemoved:0,edits:[],viaSubagent:!1},n.set(a.filePath,o)),en[a.op]>en[o.op]&&(o.op=a.op),t&&(o.viaSubagent=!0),a.fragments.forEach((e,n)=>{let{added:r,removed:a}=nn(e.oldStr,e.newStr);o.linesAdded+=r,o.linesRemoved+=a,o.editCount+=1,o.edits.push({...e,toolUseId:i.toolUseId,editIndex:n,editRef:i.toolUseId?`${i.toolUseId}-${n}`:void 0,viaSubagent:t})})}}function cn(e){let t=new Map;for(let n of e)on(n.events,t);let n=new Map;for(let r of e)sn(r.events,!1,n,t);return[...n.values()]}function ln(e,t){let n=[];for(let r=t;r>=0&&e[r]?.role===`assistant`;r--)n.unshift(e[r]);return n}var $=n();function un(e){try{return new Date(e).toLocaleString()}catch{return``}}function dn({icon:e,label:t,title:n,onClick:r}){return(0,$.jsxs)(`button`,{type:`button`,onClick:r,title:n,"aria-label":t,className:`inline-flex items-center justify-center gap-1 rounded-md px-1.5 py-1 text-text-subtle hover:text-text-primary hover:bg-surface transition-colors`,children:[e,(0,$.jsx)(`span`,{children:t})]})}function fn({content:e}){let[t,n]=(0,Q.useState)(!1);return(0,$.jsx)(dn,{icon:t?(0,$.jsx)(o,{className:`size-3.5`}):(0,$.jsx)(y,{className:`size-3.5`}),label:t?`Copied`:`Copy`,title:`Copy message to clipboard`,onClick:()=>{He(e),n(!0),setTimeout(()=>n(!1),1500)}})}function pn({timestamp:e,content:t,className:n,children:r}){return(0,$.jsxs)(`div`,{className:A(`flex items-center gap-0.5 flex-wrap text-xs text-text-subtle select-none`,n),children:[(0,$.jsx)(`time`,{title:un(e),className:`pr-1 tabular-nums`,children:L(e)}),(0,$.jsx)(fn,{content:t}),r]})}function mn(e){let t=0,n=0;for(let r of e)t+=r.linesAdded,n+=r.linesRemoved;return{added:t,removed:n}}function hn({count:e,totals:t,open:n,onToggle:r,ref:i}){let a=`${e} file${e===1?``:`s`}`;return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{"aria-hidden":!0,className:`mx-1.5 h-3.5 w-px bg-border-soft`}),(0,$.jsxs)(`button`,{ref:i,type:`button`,onClick:r,"aria-expanded":n,"aria-label":`${a} changed this turn, ${t.added} added, ${t.removed} removed`,className:A(`inline-flex items-center gap-[7px] rounded-full font-mono text-[11.5px]`,`px-3 min-h-11 md:min-h-0 md:px-[9px] md:py-[5px]`,`text-text-secondary transition-colors hover:bg-surface hover:text-text-primary`),children:[(0,$.jsx)(`span`,{"aria-hidden":!0,className:`size-[5px] shrink-0 rounded-full bg-primary`}),(0,$.jsx)(`span`,{children:a}),(0,$.jsxs)(`span`,{className:`flex items-center gap-[5px] tabular-nums`,children:[(0,$.jsxs)(`span`,{className:`text-success`,children:[`+`,t.added]}),(0,$.jsxs)(`span`,{className:`text-error`,children:[`−`,t.removed]})]})]})]})}function gn(e){if(!e)return!1;let t=e.closest(`[data-tab-pool-id]`)?.dataset.tabPoolId;if(!t)return e.offsetParent!==null;let{panels:n,focusedPanelId:r}=ie.getState();return n[r]?.activeTabId===t}var _n={create:{glyph:`A`,cls:`text-success`,label:`created`},write:{glyph:`W`,cls:`text-warning`,label:`overwritten`},notebook:{glyph:`N`,cls:`text-accent-2`,label:`notebook edited`},edit:{glyph:`·`,cls:`text-text-subtle`,label:`edited`}};function vn(e){let t=Math.max(e.lastIndexOf(`/`),e.lastIndexOf(`\\`));return t<0?{base:e,dir:``}:{base:e.slice(t+1),dir:e.slice(0,t)}}function yn({added:e,removed:t,editCount:n,className:r}){return(0,$.jsxs)(`span`,{className:A(`flex items-center gap-[5px] tabular-nums`,r),children:[(0,$.jsxs)(`span`,{className:`text-success`,children:[`+`,e]}),(0,$.jsxs)(`span`,{className:`text-error`,children:[`−`,t]}),n!=null&&n>1&&(0,$.jsxs)(`span`,{className:`text-text-subtle`,children:[`×`,n]})]})}function bn({change:e,dense:t,selected:n,onClick:r}){let i=_n[e.op],{base:a,dir:o}=vn(e.filePath),s=e.viaSubagent?`${i.label} · changed by a sub-agent`:i.label;return(0,$.jsxs)(`button`,{type:`button`,onClick:r,title:e.filePath,className:A(`grid w-full grid-cols-[16px_1fr_auto_10px] items-center gap-[10px] text-left font-mono`,`border-b border-border-soft hover:bg-surface transition-colors`,t?`min-h-[38px] px-2.5 py-[5px] text-xs`:`min-h-[52px] px-3 py-[7px] text-[12.5px]`,n&&`bg-surface shadow-[inset_2px_0_0_var(--accent)]`),children:[(0,$.jsx)(`span`,{"aria-label":s,title:s,className:A(`inline-flex size-4 items-center justify-center rounded bg-white/5 text-[9px] font-semibold`,i.cls,e.viaSubagent&&`bg-accent-2/20 ring-1 ring-inset ring-accent-2/35`),children:i.glyph}),(0,$.jsxs)(`span`,{className:`min-w-0`,children:[(0,$.jsx)(`span`,{className:`block truncate text-text-primary`,children:a}),o&&(0,$.jsx)(`span`,{className:`block overflow-hidden text-ellipsis whitespace-nowrap text-[10px] text-text-subtle [direction:rtl] text-left`,children:o})]}),(0,$.jsx)(yn,{added:e.linesAdded,removed:e.linesRemoved,editCount:e.editCount,className:`text-[11px]`}),(0,$.jsx)(c,{className:`size-[11px] text-text-subtle`})]})}var xn=(0,Q.lazy)(()=>ne(()=>import(`./edit-diff-preview-DeHb85DN.js`),__vite__mapDeps([0,1,2,3])));function Sn({change:e,onJump:t}){return(0,$.jsx)(`div`,{children:e.edits.map((n,r)=>(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`button`,{type:`button`,disabled:!n.editRef,onClick:()=>n.editRef&&t(n.editRef),className:`group flex min-h-11 w-full items-center gap-2 px-3 font-mono text-[10px] text-text-subtle transition-colors hover:bg-surface disabled:hover:bg-transparent`,children:[(0,$.jsxs)(`span`,{children:[`edit `,r+1,` of `,e.editCount]}),(0,$.jsx)(`span`,{className:`h-px flex-1 bg-border-soft`}),n.editRef&&(0,$.jsxs)(`span`,{className:`flex items-center gap-1 group-hover:text-primary`,children:[(0,$.jsx)(fe,{className:`size-3`}),`jump`]})]}),(0,$.jsx)(`div`,{className:`mx-3 mb-1`,children:(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(`div`,{className:`h-4`}),children:(0,$.jsx)(xn,{oldStr:n.oldStr,newStr:n.newStr,filePath:e.filePath})})})]},n.editRef??r))})}function Cn(e){let t=Math.max(e.lastIndexOf(`/`),e.lastIndexOf(`\\`));return t<0?{base:e,dir:``}:{base:e.slice(t+1),dir:e.slice(0,t)}}var wn=null;function Tn(e){return e instanceof HTMLElement?e.tagName===`INPUT`||e.tagName===`TEXTAREA`||e.isContentEditable:!1}function En({changes:e,onJump:t,onClose:n}){let[r,i]=(0,Q.useState)(0),a=(0,Q.useRef)(null),o=(0,Q.useRef)(null),s=(0,Q.useId)();(0,Q.useEffect)(()=>(wn=s,o.current?.querySelector(`button`)?.focus(),()=>{wn===s&&(wn=null)}),[s]),(0,Q.useEffect)(()=>{let o=o=>{if(wn===s&&gn(a.current)&&!Tn(document.activeElement)){if(o.key===`Escape`)o.preventDefault(),n();else if(o.key===`j`)o.preventDefault(),i(t=>Math.min(t+1,e.length-1));else if(o.key===`k`)o.preventDefault(),i(e=>Math.max(e-1,0));else if(o.key===`Enter`){let n=e[r]?.edits[0]?.editRef;n&&(o.preventDefault(),t(n))}}};return window.addEventListener(`keydown`,o),()=>window.removeEventListener(`keydown`,o)},[s,e,r,t,n]);let c=e[Math.min(r,e.length-1)];if(!c)return null;let{base:l,dir:u}=Cn(c.filePath);return(0,$.jsx)(`div`,{ref:a,className:`mt-0.5 overflow-hidden rounded-[10px] border border-border-soft bg-bg`,children:(0,$.jsxs)(`div`,{className:`grid h-[356px] grid-cols-[294px_1fr] grid-rows-[minmax(0,1fr)] bg-surface-elevated`,children:[(0,$.jsxs)(`div`,{ref:o,className:`min-h-0 overflow-y-auto border-r border-border-soft`,children:[e.map((e,t)=>(0,$.jsx)(bn,{change:e,dense:!0,selected:t===r,onClick:()=>i(t)},e.filePath)),(0,$.jsx)(`p`,{className:`px-2.5 pt-2 pb-2.5 font-mono text-[10px] text-text-subtle`,children:`j / k to move · enter to jump`})]}),(0,$.jsxs)(`div`,{className:`min-h-0 overflow-y-auto`,children:[(0,$.jsxs)(`div`,{className:`sticky top-0 z-10 flex items-center gap-2 border-b border-border-soft bg-surface-elevated py-[5px] pl-2.5 pr-2`,children:[(0,$.jsx)(`span`,{className:`shrink-0 font-mono text-xs font-medium text-text-primary`,children:l}),u&&(0,$.jsx)(`span`,{title:c.filePath,className:`min-w-0 flex-1 overflow-hidden text-ellipsis whitespace-nowrap font-mono text-[10.5px] text-text-subtle [direction:rtl] text-left`,children:u}),(0,$.jsx)(yn,{added:c.linesAdded,removed:c.linesRemoved,className:`shrink-0 font-mono text-[11px]`}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>void He(c.filePath),className:`shrink-0 rounded-md px-1.5 py-1 font-mono text-[10px] text-text-subtle transition-colors hover:bg-surface hover:text-text-primary`,children:`copy path`}),(0,$.jsx)(`button`,{type:`button`,onClick:n,"aria-label":`Close change tray`,className:`inline-flex size-8 shrink-0 items-center justify-center rounded-lg text-text-subtle transition-colors hover:bg-surface hover:text-text-primary`,children:(0,$.jsx)(te,{className:`size-3.5`})})]}),(0,$.jsx)(Sn,{change:c,onJump:t})]})]})})}function Dn(e){let t=Math.max(e.lastIndexOf(`/`),e.lastIndexOf(`\\`));return t<0?e:e.slice(t+1)}function On({label:e,onClick:t,children:n}){return(0,$.jsx)(`button`,{type:`button`,onClick:t,"aria-label":e,className:`inline-flex size-11 shrink-0 items-center justify-center rounded-lg text-text-subtle transition-colors hover:bg-surface hover:text-text-primary`,children:n})}function kn({changes:e,totals:t,open:n,onClose:r,onJump:i}){let[a,o]=(0,Q.useState)(null),s=a==null?null:e[a],c=(0,Q.useRef)(null),l=()=>{o(null),r()},u=e=>{l(),i(e)};return(0,Q.useEffect)(()=>{if(!n)return;let e=c.current,t=()=>Array.from(e?.querySelectorAll(`button:not([disabled])`)??[]);t()[0]?.focus();let r=e=>{if(e.key===`Escape`){e.preventDefault(),l();return}if(e.key!==`Tab`)return;let n=t();if(n.length===0)return;let r=n[0],i=n[n.length-1];e.shiftKey&&document.activeElement===r?(e.preventDefault(),i.focus()):!e.shiftKey&&document.activeElement===i&&(e.preventDefault(),r.focus())};return window.addEventListener(`keydown`,r),()=>window.removeEventListener(`keydown`,r)},[n,a]),(0,$.jsx)(P,{open:n,onClose:l,className:`flex max-h-[85%] flex-col rounded-t-[14px] motion-reduce:animate-none`,children:(0,$.jsx)(`div`,{ref:c,className:`flex min-h-0 flex-1 flex-col`,children:s?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1 border-b border-border-soft px-1 pb-1`,children:[(0,$.jsx)(On,{label:`Back to file list`,onClick:()=>o(null),children:(0,$.jsx)(ce,{className:`size-4`})}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-xs font-medium text-text-primary`,children:Dn(s.filePath)}),(0,$.jsx)(yn,{added:s.linesAdded,removed:s.linesRemoved,className:`shrink-0 font-mono text-[11px]`}),(0,$.jsx)(On,{label:`Close`,onClick:l,children:(0,$.jsx)(te,{className:`size-4`})})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1 border-b border-border-soft py-1.5 pl-3 pr-2`,children:[(0,$.jsx)(`span`,{title:s.filePath,className:`min-w-0 flex-1 overflow-hidden text-ellipsis whitespace-nowrap font-mono text-[10.5px] text-text-subtle [direction:rtl] text-left`,children:s.filePath}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>void He(s.filePath),className:`inline-flex min-h-11 shrink-0 items-center rounded-md px-2.5 font-mono text-[10px] text-text-subtle transition-colors hover:bg-surface hover:text-text-primary`,children:`copy`}),s.edits[0]?.editRef&&(0,$.jsxs)(`button`,{type:`button`,onClick:()=>u(s.edits[0].editRef),className:`inline-flex min-h-11 shrink-0 items-center gap-1 rounded-md px-2.5 font-mono text-[10px] text-text-subtle transition-colors hover:bg-surface hover:text-primary`,children:[(0,$.jsx)(fe,{className:`size-3`}),`card`]})]}),(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:(0,$.jsx)(Sn,{change:s,onJump:u})})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border-soft px-3 pb-2`,children:[(0,$.jsxs)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-xs font-medium text-text-primary`,children:[`Changed this turn · `,e.length,` file`,e.length===1?``:`s`]}),(0,$.jsx)(yn,{added:t.added,removed:t.removed,className:`shrink-0 font-mono text-[11px]`}),(0,$.jsx)(On,{label:`Close`,onClick:l,children:(0,$.jsx)(te,{className:`size-4`})})]}),(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:e.map((e,t)=>(0,$.jsx)(bn,{change:e,onClick:()=>o(t)},e.filePath))})]})})})}function An({timestamp:e,content:t,changes:n,onJumpToEdit:r}){let[i,a]=(0,Q.useState)(!1),o=oe(),s=(0,Q.useRef)(null),c=()=>{a(!1),s.current?.focus()},l=(0,$.jsx)(pn,{timestamp:e,content:t,className:`-mt-1.5`,children:n&&n.length>0&&(0,$.jsx)(hn,{ref:s,count:n.length,totals:mn(n),open:i,onToggle:()=>i?c():a(!0)})});return!n||n.length===0?l:(0,$.jsxs)($.Fragment,{children:[l,o?(0,$.jsx)(kn,{changes:n,totals:mn(n),open:i,onClose:c,onJump:r??(()=>{})}):i&&(0,$.jsx)(En,{changes:n,onJump:e=>{a(!1),r?.(e)},onClose:c})]})}function jn(e){return e.inputTokens+e.cacheReadTokens+e.cacheWriteTokens}function Mn(e){return e.inputTokens+e.cacheWriteTokens}var Nn=.5,Pn=.9,Fn={cache_expired:`the session's prompt cache had already lapsed, so PPM released its subprocess`,idle_timeout:`the session sat idle with no tab open long enough for PPM to release its subprocess`,warm_idle_cap:`too many idle sessions were holding a subprocess, so this one was released early`,tab_closed:`PPM shut the session's subprocess down when the last tab disconnected`,set_model:`the model was changed, which restarts the session`,stream_ended:`the session's subprocess had already exited`,resume:`the session was resumed on a new subprocess`};function In(e){let t=Mn(e),n=jn(e);if(!e.coldStart||n<2e4)return{level:`ok`,wastedTokens:t,reason:``};let r=e.cacheHitRate<Nn?`bad`:e.cacheHitRate<Pn?`warn`:`ok`;if(r===`ok`)return{level:r,wastedTokens:t,reason:``};let i=e.coldReason?Fn[e.coldReason]??`the session restarted (${e.coldReason})`:null;return{level:r,wastedTokens:t,reason:i?`${Bn(t)} of this session's transcript was re-sent uncached because ${i}.`:`${Bn(t)} of this session's transcript was re-sent uncached.`}}var Ln=.1,Rn=1.25;function zn(e){let t=jn(e);if(t===0)return 1;let n=e.inputTokens+e.cacheWriteTokens*Rn+e.cacheReadTokens*Ln,r=t*Ln;return r>0?Math.max(1,n/r):1}function Bn(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(e>=1e4?0:1)}k`:String(e)}function Vn({usage:e}){let[t,n]=(0,Q.useState)(!1),r=In(e);if(r.level===`ok`)return null;let i=zn(e),a=jn(e),o=Math.round(e.cacheHitRate*100),c=r.level===`bad`;return(0,$.jsxs)(`div`,{className:`rounded-md border px-2.5 py-2 text-[11px] ${c?`border-warning/40 bg-warning/10`:`border-border bg-surface`}`,children:[(0,$.jsxs)(`button`,{onClick:()=>n(e=>!e),"aria-expanded":t,className:`flex w-full items-start gap-2 py-1 text-left text-text-secondary transition-colors hover:text-text-primary`,children:[(0,$.jsx)(K,{className:`mt-px size-3.5 shrink-0 ${c?`text-warning`:`text-text-subtle`}`}),(0,$.jsxs)(`span`,{className:`flex-1`,children:[`Costly turn — `,o,`% of a `,Bn(a),`-token transcript came from cache, so it cost about`,` `,(0,$.jsxs)(`strong`,{className:`font-semibold`,children:[i.toFixed(1),`x`]}),` a fully cached turn.`]}),(0,$.jsx)(s,{className:`mt-px size-3.5 shrink-0 transition-transform ${t?`rotate-180`:``}`})]}),t&&(0,$.jsxs)(`div`,{className:`mt-2 flex flex-col gap-2 border-t border-border pt-2`,children:[r.reason&&(0,$.jsx)(`p`,{className:`text-text-secondary`,children:r.reason}),(0,$.jsxs)(`dl`,{className:`grid grid-cols-2 gap-x-3 gap-y-1 font-mono text-[10.5px] text-text-subtle`,children:[(0,$.jsx)(Hn,{label:`From cache`,value:`${Bn(e.cacheReadTokens)} (${o}%)`}),(0,$.jsx)(Hn,{label:`Written to cache`,value:Bn(e.cacheWriteTokens)}),(0,$.jsx)(Hn,{label:`Fresh input`,value:Bn(e.inputTokens)}),(0,$.jsx)(Hn,{label:`Output`,value:Bn(e.outputTokens)}),(0,$.jsx)(Hn,{label:`Model`,value:e.model||`unknown`}),(0,$.jsx)(Hn,{label:`Cost`,value:`$${e.costUsd.toFixed(4)}`})]}),(0,$.jsx)(`p`,{className:`text-text-subtle`,children:`A turn stays cached while the session keeps running. Closing the last tab of an idle session, switching model, or a retry all restart it, and the next turn re-sends the transcript at full price.`})]})]})}function Hn({label:e,value:t}){return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`dt`,{className:`truncate`,children:e}),(0,$.jsx)(`dd`,{className:`truncate text-right text-text-secondary`,children:t})]})}function Un(e,t,n,r){let[i,a]=(0,Q.useState)([]),o=(0,Q.useRef)(null);return(0,Q.useEffect)(()=>{if(!n||!e||!t){a([]);return}let r=!1;return o.current&&clearTimeout(o.current),o.current=setTimeout(()=>{E.get(`/api/project/${encodeURIComponent(e)}/chat/sessions/${encodeURIComponent(t)}/tasks`).then(e=>{r||a(e)}).catch(()=>{})},300),()=>{r=!0,o.current&&clearTimeout(o.current)}},[e,t,n,r]),i}var Wn=new Set([`TaskCreate`,`TaskUpdate`,`TaskStop`]);function Gn(e){let t=0;for(let n of e)if(n.events)for(let e of n.events)e.type===`tool_use`&&Wn.has(e.tool)&&t++;return t}var Kn={completed:{icon:`✓`,cls:`text-success`},in_progress:{icon:`▶`,cls:`text-warning`},stopped:{icon:`■`,cls:`text-text-subtle`},pending:{icon:`○`,cls:`text-text-subtle`}};function qn({projectName:e,sessionId:t,messages:n}){let r=(0,Q.useMemo)(()=>Gn(n),[n]),i=Un(e,t,r>0,r),[a,o]=(0,Q.useState)(!0);if(i.length===0||i.every(e=>e.status===`completed`||e.status===`stopped`))return null;let l=i.filter(e=>e.status===`completed`).length,u=i.length,f=u?Math.round(l/u*100):0;return(0,$.jsxs)(`div`,{className:`shrink-0 border-b border-border bg-surface/60 backdrop-blur-sm`,children:[(0,$.jsxs)(`button`,{type:`button`,onClick:()=>o(e=>!e),className:`flex items-center gap-2 w-full px-3 min-h-11 text-left text-xs hover:bg-surface transition-colors`,children:[a?(0,$.jsx)(c,{className:`size-3.5 shrink-0`}):(0,$.jsx)(s,{className:`size-3.5 shrink-0`}),(0,$.jsx)(d,{className:`size-3.5 shrink-0 text-text-secondary`}),(0,$.jsx)(`span`,{className:`text-text-primary font-medium`,children:`Tasks`}),(0,$.jsxs)(`span`,{className:`text-text-subtle`,children:[l,`/`,u,` done`]}),(0,$.jsx)(`span`,{className:`ml-auto h-1 w-16 rounded-full bg-border overflow-hidden shrink-0`,children:(0,$.jsx)(`span`,{className:`block h-full bg-success/70`,style:{width:`${f}%`}})})]}),!a&&(0,$.jsx)(`ul`,{className:`px-3 pb-2 space-y-0.5 max-h-48 overflow-y-auto`,children:i.map(e=>(0,$.jsx)(Jn,{task:e},e.id))})]})}function Jn({task:e}){let t=Kn[e.status]??Kn.pending,n=e.status===`in_progress`;return(0,$.jsxs)(`li`,{className:`flex items-start gap-1.5 text-xs rounded px-1 ${n?`bg-warning/10`:``}`,children:[(0,$.jsx)(`span`,{className:`shrink-0 mt-0.5 ${t.cls}`,children:t.icon}),(0,$.jsx)(`span`,{className:e.status===`completed`?`line-through text-text-subtle`:n?`text-text-primary font-medium`:`text-text-secondary`,children:e.subject||(0,$.jsxs)(`span`,{className:`text-text-subtle italic`,children:[`#`,e.id,` (no title)`]})})]})}var Yn=/read the full transcript at:\s*(\S+\.jsonl)/i;function Xn(e){return e.match(Yn)?.[1]?.trim()??null}var Zn=class extends Q.Component{state={hasError:!1};static getDerivedStateFromError(){return{hasError:!0}}render(){return this.state.hasError?this.props.fallback?this.props.fallback:this.props.fallbackContent?(0,$.jsx)(`div`,{className:`text-sm whitespace-pre-wrap break-words text-text-primary opacity-80`,children:this.props.fallbackContent}):null:this.props.children}};function Qn({projectName:e,onSelectSession:t}){return(0,$.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-6 text-text-secondary overflow-y-auto`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-3`,children:[(0,$.jsx)(i,{className:`size-10 text-text-subtle`}),(0,$.jsx)(`p`,{className:`text-sm`,children:`Send a message to start a new conversation`})]}),(0,$.jsx)(De,{projectName:e,onSelectSession:t,className:`w-full px-4`})]})}var $n=3200,er=1e3,tr={hasAbove:!1,atBottom:!0,idx:0,total:0};function nr({scrollElement:e,userIndices:t,scrollToBottom:n}){let r=oe(),[i,a]=(0,Q.useState)(tr),[o,c]=(0,Q.useState)(!1),[u,d]=(0,Q.useState)(0),f=(0,Q.useRef)($n),p=(0,Q.useRef)(null),m=(0,Q.useRef)(null),h=(0,Q.useRef)(!1),g=(0,Q.useRef)(!1),_=(e,t,n)=>t.getBoundingClientRect().top-n+e.scrollTop,v=(0,Q.useCallback)(e=>Array.from(e.querySelectorAll(`[data-msg-index]`)).filter(e=>t.includes(Number(e.dataset.msgIndex))),[t]);(0,Q.useEffect)(()=>{let t=e;if(!t)return;let n=0,r=()=>{let e=t.scrollTop,n=t.getBoundingClientRect().top,r=v(t).map(e=>_(t,e,n)),i=0;for(let t=0;t<r.length;t++)r[t]<=e+12&&(i=t+1);let o={hasAbove:r.some(t=>t<e-4),atBottom:t.scrollHeight-e-t.clientHeight<8,idx:i,total:r.length};a(e=>e.hasAbove===o.hasAbove&&e.atBottom===o.atBottom&&e.idx===o.idx&&e.total===o.total?e:o)},i=()=>{n&&cancelAnimationFrame(n),n=requestAnimationFrame(r)};r(),t.addEventListener(`scroll`,i,{passive:!0});let o=new ResizeObserver(i);return o.observe(t),()=>{n&&cancelAnimationFrame(n),t.removeEventListener(`scroll`,i),o.disconnect()}},[e,v]),(0,Q.useEffect)(()=>{if(!o)return;let e=setTimeout(()=>c(!1),f.current);return()=>clearTimeout(e)},[o,i.idx,u]),(0,Q.useEffect)(()=>{if(!o||!g.current)return;g.current=!1;let e=p.current;(e?.querySelector(`button:not(:disabled)`)??e)?.focus()},[o]),(0,Q.useEffect)(()=>{o||!h.current||(h.current=!1,m.current?.focus())},[o]);let y=(0,Q.useCallback)(()=>{f.current=$n,d(e=>e+1)},[]),b=(0,Q.useCallback)(()=>{let t=e;if(!t)return;let n=t.scrollTop,r=t.getBoundingClientRect().top,i;for(let e of v(t)){let a=_(t,e,r);if(a<n-4)i=a;else break}i!=null&&t.scrollTo({top:i,behavior:`auto`}),y()},[e,v,y]),x=(0,Q.useCallback)(()=>{let t=e;if(!t)return;let r=t.scrollTop,i=t.getBoundingClientRect().top,a=v(t).map(e=>_(t,e,i)).find(e=>e>r+4);a==null?n({animation:`instant`}):t.scrollTo({top:a,behavior:`auto`}),y()},[e,v,n,y]),S=(0,Q.useCallback)(()=>{n({animation:`instant`}),y()},[n,y]);(0,Q.useEffect)(()=>{let t=e;if(!t)return;let n=e=>()=>{gn(t)&&(e(),f.current=er,c(!0))},r=n(b),i=n(x);return window.addEventListener(`chat-nav-prev`,r),window.addEventListener(`chat-nav-next`,i),()=>{window.removeEventListener(`chat-nav-prev`,r),window.removeEventListener(`chat-nav-next`,i)}},[e,b,x]);let C=A(`w-[34px] flex items-center justify-center rounded-[9px] text-text-secondary`,`motion-safe:transition-colors hover:bg-surface-elevated hover:text-foreground`,`disabled:opacity-30 disabled:cursor-default disabled:hover:bg-transparent disabled:hover:text-text-secondary`,r?`h-9`:`h-[30px]`);return(0,$.jsx)(`div`,{className:`absolute bottom-3 right-2.5 z-10 flex flex-col items-end gap-1.5`,children:o?(0,$.jsxs)(`div`,{ref:p,tabIndex:-1,className:`flex flex-col p-[3px] rounded-xl border border-border bg-surface-elevated/95 backdrop-blur-[8px] shadow-lg outline-none`,onFocus:()=>{h.current=!0},onKeyDown:e=>{e.key===`Escape`&&c(!1)},children:[(0,$.jsx)(`button`,{type:`button`,onClick:b,disabled:!i.hasAbove,"aria-label":`Jump to previous message`,className:C,children:(0,$.jsx)(l,{className:`size-[15px]`})}),(0,$.jsx)(`span`,{className:`font-mono text-[10px] font-medium text-text-subtle text-center py-px`,"aria-label":`Message ${i.idx||1} of ${i.total}`,children:i.total?`${i.idx||1}/${i.total}`:`0/0`}),(0,$.jsx)(`button`,{type:`button`,onClick:x,disabled:i.atBottom,"aria-label":`Jump to next message`,className:C,children:(0,$.jsx)(s,{className:`size-[15px]`})}),(0,$.jsx)(`button`,{type:`button`,onClick:S,disabled:i.atBottom,"aria-label":`Jump to latest`,className:C,children:(0,$.jsx)(lt,{className:`size-[13px]`})})]}):(0,$.jsx)(`button`,{ref:m,type:`button`,onClick:()=>{f.current=$n,g.current=!0,c(!0)},"aria-label":`Navigate messages`,"aria-expanded":!1,title:`Navigate messages`,className:A(`group flex items-center justify-center`,r?`size-11`:`size-[30px]`),children:(0,$.jsx)(`span`,{className:A(`flex items-center justify-center rounded-full border border-border bg-surface-elevated/55 backdrop-blur-[6px] text-text-subtle`,`motion-safe:transition-colors group-hover:bg-surface-elevated group-hover:text-foreground`,r?`size-9`:`size-[30px]`),children:(0,$.jsx)(Ie,{className:`size-[15px]`})})})})}function rr({group:e,onNavigate:t,disabled:n}){if(!e||e.ids.length<2)return null;let{ids:r,currentIndex:i}=e,a=e=>{let i=r[e];i&&!n&&t(i)};return(0,$.jsxs)(`div`,{className:`mt-1 flex items-center gap-1 text-xs text-text-subtle select-none`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:()=>a(i-1),disabled:n||i<=0,"aria-label":`Previous version`,className:`flex items-center justify-center rounded p-0.5 hover:text-text-primary disabled:opacity-30 disabled:cursor-default`,children:(0,$.jsx)(ce,{className:`size-3.5`})}),(0,$.jsxs)(`span`,{className:`tabular-nums`,children:[i+1,`/`,r.length]}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>a(i+1),disabled:n||i>=r.length-1,"aria-label":`Next version`,className:`flex items-center justify-center rounded p-0.5 hover:text-text-primary disabled:opacity-30 disabled:cursor-default`,children:(0,$.jsx)(c,{className:`size-3.5`})})]})}function ir(e){let[t,n]=(0,Q.useState)({}),[r,i]=(0,Q.useState)({}),[a,o]=(0,Q.useState)(0),s=(0,Q.useCallback)((e,t)=>{n(n=>({...n,[e]:[t]})),i(t=>({...t,[e]:``}))},[]),c=(0,Q.useCallback)((e,t)=>{n(n=>{let r=n[e]||[];return{...n,[e]:r.includes(t)?r.filter(e=>e!==t):[...r,t]}})},[]),l=(0,Q.useCallback)((e,t)=>{i(n=>({...n,[e]:t})),t&&n(t=>({...t,[e]:[]}))},[]),u=(0,Q.useCallback)(e=>(t[e]?.length??0)>0||(r[e]?.trim().length??0)>0,[t,r]);return{answers:t,customInputs:r,activeTab:a,setActiveTab:o,handleSingleSelect:s,handleMultiSelect:c,handleCustomInput:l,hasAnswer:u,allAnswered:(0,Q.useMemo)(()=>e.every((e,t)=>u(t)),[e,u]),getFinalAnswer:(0,Q.useCallback)(e=>r[e]?.trim()||(t[e]??[]).join(`, `),[t,r]),goToNextTab:(0,Q.useCallback)(()=>o(t=>Math.min(t+1,e.length-1)),[e.length]),goToPrevTab:(0,Q.useCallback)(()=>o(e=>Math.max(e-1,0)),[])}}function ar(e){let[t,n]=(0,Q.useState)(0),r=(0,Q.useRef)(null);return(0,Q.useEffect)(()=>n(0),[e.activeTab]),(0,Q.useEffect)(()=>{if(!e.enabled)return;let i=r=>{let i=e.customInputRef.current,a=!!i&&i.ownerDocument.activeElement===i;if(!a&&r.key>=`1`&&r.key<=`9`){r.preventDefault();let t=parseInt(r.key)-1;t<e.totalOptions-1&&(n(t),e.onSelectOption(t));return}if(!a&&(r.key===`o`||r.key===`O`||r.key===`0`)){r.preventDefault(),e.customInputRef.current?.focus(),n(e.totalOptions-1);return}if(r.key===`Tab`&&e.questions.length>1){r.preventDefault(),r.shiftKey?e.goToPrevTab():e.goToNextTab();return}if(!a){if(r.key===`ArrowLeft`){r.preventDefault(),e.goToPrevTab();return}if(r.key===`ArrowRight`){r.preventDefault(),e.goToNextTab();return}if(r.key===`ArrowUp`){r.preventDefault(),n(e=>Math.max(0,e-1));return}if(r.key===`ArrowDown`){r.preventDefault(),n(t=>Math.min(e.totalOptions-1,t+1));return}if(r.key===` `){r.preventDefault(),e.onSelectOption(t);return}}if(r.key===`Enter`){r.preventDefault(),e.allAnswered?e.onSubmit():e.hasAnswer(e.activeTab)&&e.goToNextTab();return}r.key===`Escape`&&a&&e.customInputRef.current?.blur()},a=r.current;return a&&(a.addEventListener(`keydown`,i),a.setAttribute(`tabindex`,`0`),a.contains(a.ownerDocument.activeElement)||a.focus()),()=>{a?.removeEventListener(`keydown`,i)}},[e,t]),{focusedOption:t,setFocusedOption:n,containerRef:r}}function or({questions:e,onSubmit:t,onSkip:n}){let r=(0,Q.useRef)(null),i=ir(e),a=e[i.activeTab],o=a?a.options.length+1:0,s=e.length>1,c=(0,Q.useCallback)(()=>{if(!i.allAnswered)return;let n={};e.forEach((e,t)=>{n[e.question]=i.getFinalAnswer(t)}),t(n)},[i.allAnswered,i.getFinalAnswer,e,t]),l=(0,Q.useCallback)(e=>{if(!(!a||e<0))if(e<a.options.length){let t=a.options[e]?.label;if(!t)return;a.multiSelect?i.handleMultiSelect(i.activeTab,t):i.handleSingleSelect(i.activeTab,t)}else e===a.options.length&&r.current?.focus()},[a,i]),u=ar({questions:e,activeTab:i.activeTab,totalOptions:o,allAnswered:i.allAnswered,hasAnswer:i.hasAnswer,onSelectOption:l,goToNextTab:i.goToNextTab,goToPrevTab:i.goToPrevTab,onSubmit:c,customInputRef:r,enabled:!0}),d=(0,Q.useCallback)(e=>{l(e),u.setFocusedOption(e)},[l,u.setFocusedOption]);return(0,$.jsxs)(`div`,{ref:u.containerRef,className:`rounded-lg border-2 border-primary/30 bg-primary/5 p-3 space-y-3 outline-none animate-in slide-in-from-bottom-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between text-sm font-medium text-text-primary`,children:[(0,$.jsxs)(`span`,{children:[`AI has `,s?`${e.length} questions`:`a question`]}),(0,$.jsxs)(`span`,{className:`text-[10px] text-text-secondary font-normal`,children:[s?`←→ tabs · `:``,`↑↓ options · 1-`,Math.min(o-1,9),` select · Enter submit`]})]}),s&&(0,$.jsx)(`div`,{className:`flex gap-1 p-1 bg-background rounded-md overflow-x-auto border border-border`,children:e.map((e,t)=>(0,$.jsxs)(`button`,{className:`flex items-center gap-1.5 px-3 py-1.5 rounded text-xs whitespace-nowrap transition-all ${i.activeTab===t?`bg-primary text-primary-foreground`:i.hasAnswer(t)?`text-primary bg-transparent`:`text-text-secondary hover:bg-surface-elevated`}`,onClick:()=>{i.setActiveTab(t),u.setFocusedOption(0)},tabIndex:-1,children:[(0,$.jsx)(`span`,{className:`flex items-center justify-center w-4 h-4 rounded-full text-[10px] font-semibold ${i.activeTab===t?`bg-white/20`:i.hasAnswer(t)?`bg-primary/20 text-primary`:`bg-surface-elevated text-text-secondary`}`,children:i.hasAnswer(t)?`✓`:t+1}),(0,$.jsx)(`span`,{className:`max-w-[100px] overflow-hidden text-ellipsis`,children:e.header||`Q${t+1}`})]},t))}),a&&(0,$.jsxs)(`div`,{className:`space-y-2`,children:[!s&&a.header&&(0,$.jsx)(`div`,{className:`text-[11px] font-semibold uppercase tracking-wide text-text-secondary`,children:a.header}),(0,$.jsx)(`div`,{className:`text-sm text-text-primary select-text`,children:a.question}),a.multiSelect&&(0,$.jsx)(`div`,{className:`text-[11px] text-text-secondary`,children:`Select multiple`}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[a.options.map((e,t)=>{let n=(i.answers[i.activeTab]||[]).includes(e.label),r=u.focusedOption===t;return(0,$.jsxs)(`div`,{role:`button`,onClick:()=>d(t),className:`text-left flex items-start gap-2.5 rounded px-2.5 py-2 text-xs border transition-all cursor-pointer select-text ${n?`border-primary bg-primary/10 text-text-primary`:`border-border bg-background text-text-secondary hover:border-primary/40 hover:bg-primary/5`} ${r?`ring-2 ring-primary/40 ring-offset-1 ring-offset-background`:``}`,children:[(0,$.jsx)(`span`,{className:`flex items-center justify-center w-4.5 h-4.5 rounded text-[10px] font-semibold shrink-0 mt-px ${n?`bg-primary/20 text-primary`:`bg-surface-elevated text-text-secondary`}`,children:t+1}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-0.5 flex-1`,children:[(0,$.jsx)(`span`,{className:`font-medium text-text-primary`,children:e.label}),e.description&&(0,$.jsx)(`span`,{className:`text-[11px] text-text-secondary`,children:e.description})]})]},t)}),(0,$.jsxs)(`div`,{className:`flex items-start gap-2.5 rounded px-2.5 py-2 text-xs border border-dashed transition-all border-border bg-transparent ${u.focusedOption===o-1?`ring-2 ring-primary/40 ring-offset-1 ring-offset-background`:``}`,children:[(0,$.jsx)(`span`,{className:`flex items-center justify-center w-4.5 h-4.5 rounded bg-surface-elevated text-text-secondary text-[10px] font-semibold shrink-0 mt-px`,children:`O`}),(0,$.jsx)(`input`,{ref:r,type:`text`,className:`flex-1 px-2 py-1 text-xs bg-surface border border-border rounded text-text-primary outline-none placeholder:text-text-subtle focus:border-primary`,placeholder:`Other (press O to type)...`,value:i.customInputs[i.activeTab]||``,onChange:e=>i.handleCustomInput(i.activeTab,e.target.value),onFocus:()=>u.setFocusedOption(o-1)})]})]})]}),(0,$.jsxs)(`div`,{className:`flex gap-2 justify-end pt-1`,children:[s&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`button`,{className:`px-3 py-1.5 text-xs rounded border border-border bg-background text-text-primary hover:bg-surface-elevated disabled:opacity-40 disabled:cursor-not-allowed transition-colors`,onClick:i.goToPrevTab,disabled:i.activeTab===0,tabIndex:-1,children:`← Prev`}),(0,$.jsx)(`button`,{className:`px-3 py-1.5 text-xs rounded border border-border bg-background text-text-primary hover:bg-surface-elevated disabled:opacity-40 disabled:cursor-not-allowed transition-colors`,onClick:i.goToNextTab,disabled:i.activeTab===e.length-1,tabIndex:-1,children:`Next →`})]}),(0,$.jsx)(`button`,{onClick:n,className:`px-4 py-1.5 rounded border border-border bg-background text-text-secondary text-xs hover:bg-surface-elevated transition-colors`,tabIndex:-1,children:`Skip`}),(0,$.jsxs)(`button`,{onClick:c,disabled:!i.allAnswered,className:`px-4 py-1.5 rounded bg-primary text-primary-foreground text-xs font-medium hover:bg-primary/80 transition-colors disabled:opacity-40 disabled:cursor-not-allowed`,tabIndex:-1,children:[`Submit `,i.allAnswered?`✓`:`(${e.filter((e,t)=>i.hasAnswer(t)).length}/${e.length})`]})]})]})}var sr={"system-reminder":`Context`,claudeMd:`CLAUDE.md`,gitStatus:`Git Status`,currentDate:`Date`,fast_mode_info:`Fast Mode`,"available-deferred-tools":`Tools`,"task-notification":`Task Result`,environment_details:`Environment`,"local-command-caveat":`System`};function cr(e){let t=[],n=/<(system-reminder|available-deferred-tools|antml:[\w-]+|fast_mode_info|claudeMd|gitStatus|currentDate|task-notification|environment_details|local-command-caveat)[^>]*>([\s\S]*?)<\/\1>/g,r;for(;(r=n.exec(e))!==null;){let e=r[1];t.push({name:e,label:sr[e]??e.replace(/^antml:/,``).replace(/-/g,` `),content:r[2].trim()})}return{cleanText:e.replace(n,``).trim(),tags:t}}function lr(e){let t=e.match(/<command-name>([\s\S]*?)<\/command-name>/);if(!t)return{command:null,cleanText:e};let n=t[1].trim(),r=e.match(/<command-args>([\s\S]*?)<\/command-args>/)?.[1]?.trim()||void 0,i=e.replace(/<command-name>[\s\S]*?<\/command-name>/g,``).replace(/<command-message>[\s\S]*?<\/command-message>/g,``).replace(/<command-args>[\s\S]*?<\/command-args>/g,``).trim();return{command:{name:n,args:r},cleanText:i}}function ur(e){let t=e.match(/^Use the (\S+) agent to\s?/);return t?{agent:t[1],cleanText:e.slice(t[0].length)}:{agent:null,cleanText:e}}function dr(e){let t=/<ide_opened_file>([\s\S]*?)<\/ide_opened_file>/g.exec(e);return t?{idePath:t[1].match(/opened the file (.+?) in the IDE/)?.[1]?.trim()??null,cleanText:e.replace(/<ide_opened_file>[\s\S]*?<\/ide_opened_file>/g,``).trim()}:{idePath:null,cleanText:e}}function fr(e){let t=[],n=e;for(;;){let e=n.match(/^\[Attached image \(contents included in this message\): (.+?)\]\n*/);if(e){t.push(e[1]),n=n.slice(e[0].length);continue}break}if(t.length>0){let e=fr(n);return{files:[...t,...e.files],text:e.text}}let r=n.match(/^\[Attached file: (.+?)\]\n*/);if(r)return{files:[r[1]],text:n.slice(r[0].length)};let i=n.match(/^\[Attached files:\n([\s\S]+?)\]\n*/);return i?{files:i[1].split(`
3
- `).map(e=>e.trim()).filter(Boolean),text:n.slice(i[0].length)}:{files:[],text:n}}function pr(e){let t=[],n=e,r=/^```(?:bash|sh|shell|zsh)\n([\s\S]*?)\n```\s*(?:\n\n?)?/,i;for(;(i=n.match(r))!==null;)t.push(i[1]),n=n.slice(i[0].length);return{blocks:t,remainingText:n.trim()}}function mr(e){let{idePath:t,cleanText:n}=dr(e),{blocks:r,remainingText:i}=pr(n),a=fr(i),{cleanText:o,tags:s}=cr(a.text.replace(/<local-command-(?:stdout|stderr)>([\s\S]*?)<\/local-command-(?:stdout|stderr)>/g,`$1`)),{command:c,cleanText:l}=lr(o),{agent:u,cleanText:d}=ur(l),f=c?.args?d?`${c.args}\n\n${d}`:c.args:d;return{files:a.files,text:f,body:d,tags:s,command:c,terminalBlocks:r,idePath:t,agent:u}}function hr(e){let{agent:t,body:n,command:r}=mr(e);if(!r)return{agent:t,text:n};let i=`/${r.name.replace(/^\/+/,``)}${r.args?` ${r.args}`:``}`;return{agent:t,text:n?`${i}\n\n${n}`:i}}var gr=ne(()=>import(`./markdown-renderer-CKIBtz-k.js`),__vite__mapDeps([4,5,1,6,2,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48])),_r=(0,Q.lazy)(()=>gr.then(e=>({default:e.MarkdownRenderer})));function vr({messages:e,messagesLoading:t,keepStaleWhileLoading:n,pendingApproval:r,onApprovalResponse:a,isStreaming:o,phase:s,onSelectSession:c,connectingElapsed:l,statusMessage:u,compactStatus:d,projectName:f,onFork:m,onEdit:h,editingMsgId:g,sessionId:_,providerId:v,onNavigateVersion:y,versionMap:b,bashPartialOutput:x,onExpandCompact:S,isCompactExpanded:C,onDismissMessage:ee,onClearErrors:te}){let{scrollRef:T,contentRef:E,scrollToBottom:D,stopScroll:O,isAtBottom:ne}=Bt({initial:`instant`,resize:`instant`}),k=(0,Q.useMemo)(()=>e.filter(e=>{let t=e.content&&e.content.trim().length>0,n=e.events&&e.events.length>0;return e.role===`user`?t:t||n}),[e]),A=!!r||o,[j,re]=(0,Q.useState)(null),ie=(0,Q.useCallback)(e=>{T(e),re(e)},[T]),M=(0,Q.useRef)(new Map),ae=(0,Q.useMemo)(()=>{let e=M.current,t=new Map;for(let n=0;n<k.length;n++){let r=k[n];if(r.role!==`assistant`||k[n+1]?.role===`assistant`)continue;let i=`${r.id}:${r.events?.length??0}`,a=e.get(i);a||(a=cn(ln(k,n)),e.set(i,a)),a.length>0&&t.set(n,a)}return t},[k]),oe=(0,Q.useRef)(null),N=(0,Q.useCallback)(e=>{j&&(oe.current?.(),oe.current=Qt(j,e))},[j]);(0,Q.useEffect)(()=>()=>oe.current?.(),[]);let P=(0,Q.useRef)(null);(0,Q.useLayoutEffect)(()=>{let e=j;e&&P.current!=null&&(e.scrollTop=e.scrollHeight-P.current,P.current=null)},[k.length,j]),(0,Q.useLayoutEffect)(()=>{j&&D({animation:`instant`})},[_,j]);let F=(0,Q.useRef)(!0);(0,Q.useEffect)(()=>{j&&j.clientHeight>0&&(F.current=ne)},[ne,j]),(0,Q.useEffect)(()=>{let e=j;if(!e)return;let t=e.clientHeight,n=new ResizeObserver(()=>{let n=e.clientHeight,r=t===0&&n>0;t=n,r&&!F.current&&O()});return n.observe(e),()=>n.disconnect()},[j,O]);let se=(0,Q.useCallback)((e,t)=>{m?.(e,t)},[m]),ce=(0,Q.useCallback)((e,t,n)=>{h?.(e,t,n)},[h]),le=(0,Q.useCallback)(e=>{ee?.(e)},[ee]),I=(0,Q.useMemo)(()=>k.reduce((e,t)=>t.role===`system`?e+1:e,0),[k]),L=(0,Q.useMemo)(()=>k.reduce((e,t,n)=>(t.role===`user`&&e.push(n),e),[]),[k]),R=(0,Q.useCallback)(()=>{if(!S||!C)return null;for(let e of k){if(C(e.id))continue;let t=Xn(e.content||``);if(t)return{id:e.id,jsonlPath:t};if(e.events){for(let t of e.events)if(t.type===`text`){let n=Xn(t.content||``);if(n)return{id:e.id,jsonlPath:n}}}}return null},[k,S,C])(),ue=!!R,[z,B]=(0,Q.useState)(!1),V=(0,Q.useCallback)(async()=>{if(!R||!S||z)return;let e=j;P.current=e?e.scrollHeight-e.scrollTop:null,B(!0);try{await S(R.id,R.jsonlPath)}finally{B(!1)}},[R,S,z,j]);return(0,Q.useEffect)(()=>{let e=j;if(!e||!ue)return;let t=()=>{e.scrollTop<200&&!z&&V()};return e.addEventListener(`scroll`,t,{passive:!0}),()=>e.removeEventListener(`scroll`,t)},[j,ue,z,V]),t&&(!n||e.length===0)?(0,$.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-3 text-text-secondary`,children:[(0,$.jsx)(i,{className:`size-10 text-text-subtle animate-pulse`}),(0,$.jsx)(`p`,{className:`text-sm`,children:`Loading messages...`})]}):e.length===0&&!o?(0,$.jsx)(Qn,{projectName:f||``,onSelectSession:c||(()=>{})}):(0,$.jsxs)(`div`,{className:`relative flex-1 overflow-hidden flex flex-col min-h-0`,children:[(0,$.jsx)(qn,{projectName:f,sessionId:_,messages:e}),I>1&&te&&(0,$.jsx)(`div`,{className:`absolute top-2 left-0 right-0 z-20 flex justify-center pointer-events-none`,children:(0,$.jsxs)(`button`,{type:`button`,onClick:te,className:`pointer-events-auto flex items-center gap-1.5 rounded-full bg-error/15 border border-error/25 px-3 py-1 text-xs text-error hover:bg-error/25 shadow-md backdrop-blur-sm`,children:[(0,$.jsx)(p,{className:`size-3.5`}),`Clear all errors (`,I,`)`]})}),z&&(0,$.jsxs)(`div`,{className:`absolute top-2 left-0 right-0 z-10 flex items-center justify-center gap-1.5 text-xs text-text-secondary pointer-events-none`,children:[(0,$.jsx)(w,{className:`size-3 animate-spin`}),`Loading previous conversation...`]}),(0,$.jsx)(`div`,{ref:ie,[Xe]:``,className:`flex-1 overflow-y-auto overflow-x-hidden [overflow-anchor:none]`,style:{WebkitOverflowScrolling:`touch`,overscrollBehavior:`contain`},children:(0,$.jsxs)(`div`,{ref:E,className:`w-full`,children:[k.map((e,t)=>{let n=t>0?k[t-1]:void 0,r=e.role===`user`?k.slice(0,t+1).reduce((e,t)=>e+(t.role===`user`?1:0),0):0,i=r?b?.[r]:void 0,a=e.role===`user`&&g!=null&&e.id===g,s=k[t+1],c=e.role===`assistant`&&s?.role!==`assistant`,l;if(c){let e=[];for(let n=t;n>=0&&k[n].role===`assistant`;n--){let t=yr(k[n]);t&&e.unshift(t)}l=e.join(`
4
-
5
- `)}return(0,$.jsx)(`div`,{"data-msg-index":t,className:`px-4 pt-4 select-none`,children:(0,$.jsx)(Zn,{fallbackContent:e.content,children:(0,$.jsx)(br,{message:e,isStreaming:o&&e.id.startsWith(`streaming-`),isLastAssistantInTurn:c,turnCopyText:l,turnChanges:c?ae.get(t):void 0,onJumpToEdit:N,projectName:f,onFork:e.role===`user`&&m?se:void 0,onEdit:e.role===`user`&&h?ce:void 0,isEditing:a,onDismiss:e.role===`system`&&ee?le:void 0,prevMsgId:n?.sdkUuid??n?.id,sessionId:_,providerId:v,versionGroup:i,onNavigateVersion:y,versionNavDisabled:o,bashPartialOutput:x})})},e.id)}),A&&(0,$.jsxs)(`div`,{className:`px-4 pt-4 pb-4 space-y-4 select-none`,children:[r&&(r.tool===`AskUserQuestion`?(0,$.jsx)(Gr,{approval:r,onRespond:a}):(0,$.jsx)(Wr,{approval:r,onRespond:a})),o&&(0,$.jsx)(Br,{lastMessage:e[e.length-1],phase:s,elapsed:l,statusMessage:d===`compacting`?`Compacting messages...`:u})]})]})}),(0,$.jsx)(nr,{scrollElement:j,userIndices:L,scrollToBottom:D})]})}function yr(e){return e.events?.length?e.events.filter(e=>e.type===`text`).map(e=>e.content).join(``):e.content}var br=(0,Q.memo)(function({message:e,isStreaming:t,isLastAssistantInTurn:n,turnCopyText:r,turnChanges:i,onJumpToEdit:a,projectName:o,onFork:s,onEdit:c,isEditing:l,onDismiss:u,prevMsgId:d,sessionId:f,providerId:m,versionGroup:h,onNavigateVersion:g,versionNavDisabled:_,bashPartialOutput:v}){if(e.role===`user`){let t=s?()=>s(e.content,d):void 0,n=c?()=>c(e.content,d,e.id):void 0;return(0,$.jsx)(Tr,{content:e.content,messageId:e.id,timestamp:e.timestamp,projectName:o,onFork:t,onEdit:n,isEditing:l,sessionId:f,providerId:m,versionGroup:h,onNavigateVersion:g,versionNavDisabled:_})}return e.role===`system`?(0,$.jsxs)(`div`,{className:`group flex items-center gap-2 rounded-lg bg-error/10 border border-error/20 px-3 py-2 text-sm text-error`,children:[(0,$.jsx)(ve,{className:`size-4 shrink-0`}),(0,$.jsx)(`p`,{className:`flex-1`,children:e.content}),u&&(0,$.jsx)(`button`,{type:`button`,onClick:()=>u(e.id),"aria-label":`Dismiss`,title:`Dismiss`,className:`shrink-0 rounded p-1 text-error/70 hover:text-error hover:bg-error/15 md:opacity-0 md:group-hover:opacity-100`,children:(0,$.jsx)(p,{className:`size-4`})})]}):(0,$.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[e.events&&e.events.length>0?(0,$.jsx)(Lr,{events:e.events,isStreaming:t,projectName:o,bashPartialOutput:v}):e.content&&(0,$.jsx)(`div`,{className:`text-sm text-text-primary select-text`,children:(0,$.jsx)(Ur,{content:e.content,projectName:o})}),!t&&n&&e.usage&&(0,$.jsx)(Vn,{usage:e.usage}),!t&&n&&(0,$.jsx)(An,{timestamp:e.timestamp,content:r??yr(e),changes:i,onJumpToEdit:a})]})}),xr=new Set([`.png`,`.jpg`,`.jpeg`,`.gif`,`.webp`]);function Sr(e,t){let n=re(e);return`/api/project/${encodeURIComponent(t??`_`)}/chat/uploads/${encodeURIComponent(n)}`}function Cr(e){let t=e.lastIndexOf(`.`);return t===-1?!1:xr.has(e.slice(t).toLowerCase())}var wr=new Set([`task-notification`,`environment_details`,`local-command-caveat`]);function Tr({content:e,messageId:t,timestamp:n,projectName:r,onFork:a,onEdit:o,isEditing:c,sessionId:u,providerId:d,versionGroup:f,onNavigateVersion:p,versionNavDisabled:m}){let{files:h,text:g,tags:_,command:v,terminalBlocks:y,idePath:b,agent:x}=(0,Q.useMemo)(()=>mr(e),[e]),S=_.some(e=>wr.has(e.name)),[C,w]=(0,Q.useState)(!1),[ee,te]=(0,Q.useState)(!1),T=(0,Q.useRef)(null);return(0,Q.useEffect)(()=>{let e=T.current;if(!e)return;let t=()=>te(e.scrollHeight>e.clientHeight+2);t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[g]),(0,$.jsxs)(`div`,{className:A(`flex flex-col gap-1`,!S&&`items-end`),children:[(0,$.jsxs)(`div`,{"data-user-message":S?void 0:`true`,style:S?void 0:{borderRadius:`var(--rad) var(--rad) 4px var(--rad)`},className:A(`group/user relative px-3 py-2 text-sm border shadow-sm transition-all`,S?`rounded-lg bg-surface/40 border-border/40 text-text-secondary`:`max-w-[80%] bg-accent-wash border-accent-wash-border text-text`,c&&`ring-2 ring-primary/60 border-primary/40`),children:[_.length>0&&(0,$.jsx)(Dr,{tags:_}),x&&(0,$.jsx)(`div`,{className:`flex items-center gap-1.5 mb-0.5`,children:(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md bg-sky-500/15 border border-sky-500/25 px-2 py-0.5 text-xs font-medium text-sky-600 dark:text-sky-400`,children:[(0,$.jsx)(i,{className:`size-3 shrink-0`}),x]})}),v&&(0,$.jsx)(`div`,{className:`flex items-center gap-1.5 mb-0.5`,children:(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md bg-primary/15 border border-primary/20 px-2 py-0.5 text-xs font-medium text-primary`,children:[(0,$.jsx)(ht,{className:`size-3 shrink-0`}),v.name]})}),b&&(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 mb-1 text-[11px] text-text-subtle`,children:[(0,$.jsx)(`span`,{className:`shrink-0`,children:`Opened in IDE:`}),(0,$.jsx)(jr,{path:b,projectName:r})]}),h.length>0&&(0,$.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:h.map((e,t)=>Cr(e)?(0,$.jsx)(Ir,{filePath:e,projectName:r},t):(0,$.jsxs)(`div`,{className:`flex items-center gap-1 rounded-md border border-border/60 bg-background/40 px-1.5 py-0.5 text-[11px] text-text-secondary`,children:[(0,$.jsx)(Ke,{className:`size-3 shrink-0`}),(0,$.jsx)(`span`,{className:`truncate max-w-32`,children:re(e)})]},t))}),y.length>0&&(0,$.jsx)(`div`,{className:`space-y-1.5`,children:y.map((e,t)=>(0,$.jsx)(Er,{content:e},t))}),g&&(0,$.jsx)(`div`,{ref:T,className:A(`whitespace-pre-wrap break-words transition-all duration-200 select-text`,!C&&`line-clamp-2`,C&&`max-h-[50vh] overflow-y-auto`),children:S?(0,$.jsx)(Nr,{text:g,projectName:r}):(0,$.jsx)(Mr,{text:g})}),(ee||C)&&(0,$.jsx)(`button`,{onClick:()=>w(!C),className:A(`flex items-center gap-1 text-xs mt-1 transition-colors`,S?`text-text-subtle hover:text-text-secondary`:`text-primary/70 hover:text-primary`),children:C?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(l,{className:`size-3`}),`Show less`]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(s,{className:`size-3`}),`Show more`]})}),!S&&p&&(0,$.jsx)(rr,{group:f,onNavigate:p,disabled:m})]}),!S&&(0,$.jsxs)(pn,{timestamp:n,content:e,children:[o&&(0,$.jsx)(dn,{icon:(0,$.jsx)(J,{className:`size-3.5`}),label:`Edit`,title:`Edit this message (continue in the same tab)`,onClick:o}),a&&(0,$.jsx)(dn,{icon:(0,$.jsx)(B,{className:`size-3.5`}),label:`Fork`,title:`Retry from this message (fork into a new tab)`,onClick:a})]})]})}function Er({content:e}){let[t,n]=(0,Q.useState)(!1);return(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`button`,{type:`button`,onClick:()=>n(!t),className:A(`flex items-center gap-1.5 rounded-md border px-2 py-1 text-xs transition-colors`,t?`border-primary/50 bg-surface-elevated text-text-primary`:`border-border/60 bg-background/40 text-text-secondary hover:bg-surface`),children:[(0,$.jsx)(qe,{className:`size-3.5 shrink-0`}),(0,$.jsx)(`span`,{children:`Terminal output`}),(0,$.jsx)(s,{className:A(`size-3 shrink-0 transition-transform`,t&&`rotate-180`)})]}),t&&(0,$.jsx)(`pre`,{className:`mt-1 max-h-40 overflow-auto rounded-md border border-border bg-background p-2 text-xs text-text-primary font-mono whitespace-pre-wrap break-words`,children:e})]})}function Dr({tags:e}){return(0,$.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:e.map((e,t)=>(0,$.jsx)(Or,{tag:e},t))})}function Or({tag:e}){let[t,n]=(0,Q.useState)(!1);return e.name===`task-notification`?(0,$.jsx)(Ar,{content:e.content}):(0,$.jsxs)(`div`,{className:`text-xs`,children:[(0,$.jsxs)(`button`,{onClick:()=>n(!t),className:`flex items-center gap-1 rounded-full border border-border/60 bg-surface/50 px-2 py-0.5 text-text-subtle hover:text-text-secondary hover:bg-surface transition-colors`,children:[(0,$.jsx)(he,{className:`size-2.5`}),(0,$.jsx)(`span`,{children:e.label}),(0,$.jsx)(c,{className:A(`size-2.5 transition-transform`,t&&`rotate-90`)})]}),t&&(0,$.jsx)(`div`,{className:`mt-1 rounded border border-border/40 bg-surface/30 px-2 py-1.5 text-[11px] text-text-subtle/80 whitespace-pre-wrap max-h-40 overflow-y-auto leading-relaxed`,children:e.content})]})}function kr(e,t){return e.match(RegExp(`<${t}>([\\s\\S]*?)</${t}>`))?.[1]?.trim()||void 0}function Ar({content:e}){let[t,n]=(0,Q.useState)(!1),r=kr(e,`status`),i=kr(e,`summary`),a=kr(e,`output-file`),o=kr(e,`result`);return(0,$.jsxs)(`div`,{className:`text-xs`,children:[(0,$.jsxs)(`button`,{onClick:()=>n(!t),className:`flex items-center gap-1.5 rounded-full border border-border/60 bg-surface/50 px-2 py-0.5 text-text-subtle hover:text-text-secondary hover:bg-surface transition-colors`,children:[r===`completed`?(0,$.jsx)(R,{className:`size-2.5 text-success`}):(0,$.jsx)(p,{className:`size-2.5 text-warning`}),(0,$.jsx)(`span`,{className:`truncate max-w-80`,children:i??`Task notification`}),(0,$.jsx)(c,{className:A(`size-2.5 transition-transform shrink-0`,t&&`rotate-90`)})]}),t&&(0,$.jsxs)(`div`,{className:`mt-1 rounded border border-border/40 bg-surface/30 px-2 py-1.5 space-y-1.5`,children:[i&&(0,$.jsx)(`p`,{className:`text-[11px] text-text-secondary`,children:i}),a&&(0,$.jsx)(jr,{path:a}),o&&(0,$.jsx)(`div`,{className:`text-[11px] text-text-subtle/80 max-h-60 overflow-y-auto leading-relaxed`,children:(0,$.jsx)(Ur,{content:o})})]})]})}function jr({path:e,projectName:t}){return(0,$.jsxs)(`button`,{type:`button`,onClick:(0,Q.useCallback)(()=>{let n=ae.getState().openTab,r=t??M.getState().activeProject?.name,i=re(e),a={filePath:e};r&&(a.projectName=r),E.get(`/api/fs/read?path=${encodeURIComponent(e)}`).then(()=>{n({type:`editor`,title:i,metadata:a,projectId:null,closable:!0})}).catch(()=>{n({type:`editor`,title:i,metadata:a,projectId:null,closable:!0})})},[e,t]),className:`inline-flex items-center gap-1 rounded border border-border/50 bg-surface/50 px-1.5 py-0.5 font-mono text-[10px] text-text-secondary hover:text-text-primary hover:bg-surface transition-colors cursor-pointer`,children:[(0,$.jsx)(Ke,{className:`size-2.5 shrink-0`}),(0,$.jsx)(`span`,{className:`truncate max-w-60`,children:re(e)}),(0,$.jsx)(I,{className:`size-2 shrink-0 opacity-50`})]})}function Mr({text:e}){let t=(0,Q.useMemo)(()=>{let t=/(https?:\/\/[^\s<>()]+[^\s<>().,;:!?'"])/g,n=[],r=0,i;for(;(i=t.exec(e))!==null;)i.index>r&&n.push({kind:`text`,value:e.slice(r,i.index)}),n.push({kind:`url`,value:i[1]}),r=i.index+i[0].length;return r<e.length&&n.push({kind:`text`,value:e.slice(r)}),n},[e]);return t.every(e=>e.kind===`text`)?(0,$.jsx)($.Fragment,{children:e}):(0,$.jsx)($.Fragment,{children:t.map((e,t)=>e.kind===`url`?(0,$.jsx)(`a`,{href:e.value,target:`_blank`,rel:`noopener noreferrer`,className:`text-primary underline underline-offset-2 hover:text-primary/80 break-all`,onClick:e=>e.stopPropagation(),children:e.value},t):(0,$.jsx)(`span`,{children:e.value},t))})}function Nr({text:e,projectName:t}){return(0,$.jsx)($.Fragment,{children:(0,Q.useMemo)(()=>{let t=/(\/(?:[\w.\-]+\/)+[\w.\-]+)/g,n=[],r=0,i;for(;(i=t.exec(e))!==null;)i.index>r&&n.push({kind:`text`,value:e.slice(r,i.index)}),n.push({kind:`path`,value:i[1]}),r=i.index+i[0].length;return r<e.length&&n.push({kind:`text`,value:e.slice(r)}),n},[e]).map((e,n)=>e.kind===`path`?(0,$.jsx)(jr,{path:e.value,projectName:t},n):(0,$.jsx)(`span`,{children:e.value},n))})}var Pr=new Map;function Fr(e){let[t,n]=(0,Q.useState)(()=>Pr.get(e)?.url??null),[r,i]=(0,Q.useState)(!1);return(0,Q.useEffect)(()=>{let t=Pr.get(e);if(t){n(t.url);return}let r=!1,a=D();return fetch(e,{headers:a?{Authorization:`Bearer ${a}`}:{}}).then(e=>{if(!e.ok)throw Error(`Failed`);return e.blob()}).then(t=>{if(r)return;let i=URL.createObjectURL(t);Pr.set(e,{url:i}),n(i)}).catch(()=>{r||i(!0)}),()=>{r=!0}},[e]),{blobUrl:t,error:r}}function Ir({filePath:e,projectName:t}){let{blobUrl:n,error:r}=Fr(Sr(e,t)),i=Be(e=>e.open),a=re(e);return(0,$.jsxs)(`button`,{type:`button`,onClick:e=>n&&i(n,a,Ze(e.currentTarget)),className:`flex items-center gap-1 rounded-md border border-border/60 bg-background/40 px-1.5 py-0.5 text-[11px] text-text-secondary hover:bg-surface transition-colors cursor-pointer`,children:[n?(0,$.jsx)(`img`,{src:n,alt:a,[Qe]:``,className:`size-4 rounded-sm object-cover shrink-0`}):r?(0,$.jsx)(Le,{className:`size-3 shrink-0`}):(0,$.jsx)(`div`,{className:`size-4 rounded-sm bg-surface animate-pulse shrink-0`}),(0,$.jsx)(`span`,{className:`truncate max-w-32`,children:a})]})}function Lr({events:e,isStreaming:t,projectName:n,bashPartialOutput:r}){let i=[],a=``,o=``;for(let t=0;t<e.length;t++){let n=e[t];if(n.type===`thinking`){a&&=(i.push({kind:`text`,content:a}),``),o+=n.content;continue}if(o&&=(i.push({kind:`thinking`,content:o}),``),n.type===`account_retry`){a&&=(i.push({kind:`text`,content:a}),``);let e=n.accountLabel??`another account`,t=n.reason??`Auth failed`;i.push({kind:`text`,content:`\n\n> ↻ ${t} — retrying with **${e}**...\n\n`});continue}if(n.type===`text`)a+=n.content;else if(n.type===`tool_use`){let e=n.toolUseId,t=e?i.find(t=>t.kind===`tool`&&t.tool.type===`tool_use`&&t.tool.toolUseId===e):void 0;if(t){t.tool=n;continue}a&&=(i.push({kind:`text`,content:a}),``),i.push({kind:`tool`,tool:n})}else n.type===`tool_result`||(a&&=(i.push({kind:`text`,content:a}),``),i.push({kind:`tool`,tool:n}))}o&&i.push({kind:`thinking`,content:o}),a&&i.push({kind:`text`,content:a});let s=e.filter(e=>e.type===`tool_result`);for(let e of s){let t=e.toolUseId;if(t){let n=i.find(e=>e.kind===`tool`&&e.tool.type===`tool_use`&&e.tool.toolUseId===t);if(n){n.result=e;continue}}let n=i.find(e=>e.kind===`tool`&&!e.result);n&&(n.result=e)}for(let e of i)if(e.kind===`tool`&&!e.result&&e.tool.type===`tool_use`){let t=e.tool.result;t&&(e.result={type:`tool_result`,output:t.output,isError:t.isError})}for(let e=0;e<i.length;e++){let n=i[e];if(n.kind===`tool`&&!n.result){let r=!1;if(n.tool.type===`tool_use`&&n.tool.tool===`Read`){let t=n.tool.input?.file_path;t&&(r=i.slice(e+1).some(e=>e.kind===`tool`&&e.result&&e.tool.type===`tool_use`&&e.tool.tool===`Edit`&&e.tool.input?.file_path===t))}n.completed=r||!t}}return(0,$.jsx)($.Fragment,{children:i.map((e,a)=>{if(e.kind===`thinking`)return(0,$.jsx)(Rr,{content:e.content,isStreaming:t&&a===i.length-1},`think-${a}`);if(e.kind===`text`){let r=t&&a===i.length-1;return(0,$.jsx)(`div`,{className:`text-sm text-text-primary select-text`,children:(0,$.jsx)(zr,{content:e.content,animate:r,projectName:n})},`text-${a}`)}return(0,$.jsx)(f,{tool:e.tool,result:e.result,completed:e.completed,projectName:n,bashPartialOutput:r},`tool-${a}`)})})}function Rr({content:e,isStreaming:t}){let[n,r]=(0,Q.useState)(t),i=(0,Q.useRef)(null);return(0,Q.useEffect)(()=>{!t&&e.length>0&&r(!1)},[t,e.length]),(0,Q.useEffect)(()=>{t&&n&&i.current&&(i.current.scrollTop=i.current.scrollHeight)},[e,t,n]),(0,$.jsxs)(`div`,{className:`rounded border border-border/50 bg-surface/30 text-xs`,children:[(0,$.jsxs)(`button`,{onClick:()=>r(!n),className:`flex items-center gap-2 px-2 py-1.5 w-full text-left hover:bg-surface transition-colors text-text-subtle`,children:[t?(0,$.jsx)(w,{className:`size-3 animate-spin`}):(0,$.jsx)(c,{className:`size-3 transition-transform ${n?`rotate-90`:``}`}),(0,$.jsxs)(`span`,{children:[`Thinking`,t?`...`:``]}),!t&&(0,$.jsx)(`span`,{className:`text-text-subtle/50 ml-auto`,children:e.length>100?`${Math.round(e.length/4)} tokens`:``})]}),n&&(0,$.jsx)(`div`,{ref:i,className:`max-h-60 overflow-y-auto`,children:(0,$.jsx)(`div`,{className:`px-2 pb-2 text-text-subtle/80 whitespace-pre-wrap text-[11px] leading-relaxed`,children:e})})]})}function zr({content:e,animate:t,projectName:n}){return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Ur,{content:e,projectName:n,isStreaming:t}),t&&(0,$.jsx)(`span`,{className:`text-text-subtle text-sm animate-pulse`,children:`Thinking...`})]})}function Br({lastMessage:e,phase:t,elapsed:n,statusMessage:r}){let i=!e||e.role!==`assistant`,a=e?.events?.length?e.events[e.events.length-1].type===`tool_result`:!1;return!r&&!i&&!a?null:(0,$.jsxs)(`div`,{className:`flex flex-col gap-1 text-sm`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-text-subtle`,children:[(0,$.jsx)(w,{className:`size-3 animate-spin`}),(0,$.jsxs)(`span`,{children:[r||(t===`initializing`?`Initializing`:t===`connecting`?`Connecting`:t===`thinking`?`Thinking`:`Processing`),i&&(n??0)>0&&(0,$.jsxs)(`span`,{className:`text-text-subtle/60`,children:[`... (`,n,`s)`]})]})]}),t===`connecting`&&(n??0)>=30&&(0,$.jsx)(`p`,{className:`text-xs text-warning/80 ml-5`,children:`Taking longer than usual — may be rate-limited or API slow. Try sending a new message to retry.`})]})}var Vr=/<teammate-message[^>]*>[\s\S]*?<\/teammate-message>/g;function Hr(e){return e.replace(Vr,``).replace(/\n{3,}/g,`
6
-
7
- `).trim()}function Ur({content:e,projectName:t,isStreaming:n}){let r=Hr(e);return r?(0,$.jsx)(Zn,{fallbackContent:r,children:(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(`div`,{className:`animate-pulse h-4 bg-muted rounded`}),children:(0,$.jsx)(_r,{content:r,projectName:t,codeActions:!0,isStreaming:n})})}):null}function Wr({approval:e,onRespond:t}){return(0,$.jsxs)(`div`,{className:`rounded-lg border-2 border-warning/40 bg-warning/10 p-3 space-y-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-warning text-sm font-medium`,children:[(0,$.jsx)(le,{className:`size-4`}),(0,$.jsx)(`span`,{children:`Tool Approval Required`})]}),(0,$.jsx)(`div`,{className:`text-xs text-text-primary`,children:(0,$.jsx)(`span`,{className:`font-medium`,children:e.tool})}),(0,$.jsx)(`pre`,{className:`text-xs font-mono text-text-secondary overflow-x-auto bg-background rounded p-2 border border-border`,children:JSON.stringify(e.input,null,2)}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(`button`,{onClick:()=>t(e.requestId,!0),className:`px-4 py-1.5 rounded bg-success text-white text-xs font-medium hover:bg-success/80 transition-colors`,children:`Allow`}),(0,$.jsx)(`button`,{onClick:()=>t(e.requestId,!1),className:`px-4 py-1.5 rounded bg-error text-white text-xs font-medium hover:bg-error/80 transition-colors`,children:`Deny`})]})]})}function Gr({approval:e,onRespond:t}){return(0,$.jsx)(or,{questions:e.input.questions??[],onSubmit:n=>t(e.requestId,!0,n),onSkip:()=>t(e.requestId,!1)})}function Kr({shells:e,onKill:t}){let n=Ve(e=>e.openPanel),r=e.filter(e=>e.status!==`stopped`);return r.length===0?null:(0,$.jsx)(`div`,{className:`shrink-0 border-b border-border bg-surface-elevated/60 px-2 py-1.5 space-y-1`,children:r.map(e=>(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-xs`,children:[e.status===`stopping`?(0,$.jsx)(w,{className:`size-3.5 shrink-0 animate-spin text-warning`}):(0,$.jsxs)(`span`,{className:`relative flex size-2 shrink-0`,children:[(0,$.jsx)(`span`,{className:`absolute inline-flex size-full animate-ping rounded-full bg-emerald-400 opacity-60`}),(0,$.jsx)(`span`,{className:`relative inline-flex size-2 rounded-full bg-emerald-500`})]}),(0,$.jsx)(qe,{className:`size-3.5 shrink-0 text-text-secondary`}),(0,$.jsx)(`span`,{className:`flex-1 truncate font-mono text-text-primary`,title:e.command,children:e.command}),e.status===`stopping`&&(0,$.jsx)(`span`,{className:`text-[11px] text-warning shrink-0`,children:`stopping…`}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>n(e.shellId),className:`flex items-center justify-center size-8 rounded hover:bg-surface text-text-secondary hover:text-text-primary transition-colors`,"aria-label":`View output`,title:`View output`,children:(0,$.jsx)(S,{className:`size-4`})}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>t(e.shellId),disabled:e.status===`stopping`,className:`flex items-center justify-center size-8 rounded hover:bg-surface text-text-secondary hover:text-error transition-colors disabled:opacity-40`,"aria-label":`Stop command`,title:`Stop command`,children:(0,$.jsx)(be,{className:`size-3.5`})})]},e.shellId))})}function qr(e){if(!e)return;let t=e.split(`:`).pop();return t&&t!==`general-purpose`?t:e}function Jr(e,t){if(!e)return;let n=new Date(e).getTime(),r=t?new Date(t).getTime():Date.now();if(!Number.isFinite(n)||!Number.isFinite(r)||r<n)return;let i=Math.floor((r-n)/1e3),a=Math.floor(i/3600),o=Math.floor(i%3600/60);return a>0?`${a}h ${o}m`:o>0?`${o}m`:`${i}s`}function Yr(e){return e.lastTool?e.lastToolArg?`${e.lastTool}: ${e.lastToolArg}`:e.lastTool:e.lastNarrative??e.description}function Xr({teamName:e,members:t,projectName:n}){let r=et(),i=t.filter(e=>e.workState===`working`);return!e||i.length===0?null:(0,$.jsx)(`div`,{className:`shrink-0 border-t border-border bg-surface-elevated/60 px-2 py-1.5 space-y-1`,children:i.map(t=>{let i=Yr(t),a=Jr(t.startedAt),o=qr(t.agentType);return(0,$.jsxs)(`button`,{type:`button`,onClick:()=>r({teamName:e,memberName:t.name,projectName:n}),className:`flex w-full items-center gap-2 rounded px-1 py-1.5 min-h-[36px] text-left text-xs hover:bg-surface transition-colors`,title:`Open ${t.name}'s work session`,children:[(0,$.jsxs)(`span`,{className:`relative flex size-2 shrink-0`,children:[(0,$.jsx)(`span`,{className:`absolute inline-flex size-full animate-ping rounded-full bg-emerald-400 opacity-60`}),(0,$.jsx)(`span`,{className:`relative inline-flex size-2 rounded-full bg-emerald-500`})]}),(0,$.jsx)(se,{className:`size-3.5 shrink-0 text-accent-2`}),(0,$.jsx)(`span`,{className:`font-medium text-text-primary shrink-0`,children:t.name}),!!o&&(0,$.jsx)(`span`,{className:`text-text-3 shrink-0 hidden sm:inline`,children:o}),!!i&&(0,$.jsx)(`span`,{className:`flex-1 truncate text-text-subtle`,title:i,children:i}),!!a&&(0,$.jsx)(`span`,{className:`ml-auto shrink-0 text-text-3 font-mono`,children:a})]},t.name)})})}var Zr=5e3;function Qr(e,t){let[n,r]=(0,Q.useState)([]),[i,a]=(0,Q.useState)([]),[o,s]=(0,Q.useState)(!1),c=(0,Q.useRef)(!1),l=(0,Q.useCallback)(async e=>{if(e){s(!0);try{let t=await E.get(`/api/teams/${encodeURIComponent(e)}/activity`);if(c.current)return;r(t?.members??[]),a(t?.outbound??[])}catch{}finally{c.current||s(!1)}}},[]);return(0,Q.useEffect)(()=>{if(c.current=!1,!t||!e)return r([]),a([]),()=>{c.current=!0};l(e);let n=setInterval(()=>void l(e),Zr);return()=>{c.current=!0,clearInterval(n)}},[e,t,l]),{members:n,outbound:i,loading:o,refresh:(0,Q.useCallback)(()=>void l(e),[l,e])}}function $r(){let e=window;return e.SpeechRecognition??e.webkitSpeechRecognition??null}function ei(e){let[t,n]=(0,Q.useState)(!1),[r,i]=(0,Q.useState)(``),a=(0,Q.useRef)(null),o=(0,Q.useRef)(``),s=typeof window<`u`&&$r()!==null;return{isListening:t,interimText:r,start:(0,Q.useCallback)(t=>{let r=$r();if(!r)return;a.current?.abort();let s=new r;s.lang=e?.lang??`vi-VN`,s.continuous=!0,s.interimResults=!0,o.current=``,s.onresult=e=>{let n=``,r=``;for(let t=0;t<e.results.length;t++){let i=e.results[t];i.isFinal?r+=i[0].transcript:n+=i[0].transcript}r&&(o.current=r);let a=(o.current+` `+n).trim();i(n),t(a,n.length===0&&o.current.length>0)},s.onend=()=>{n(!1),i(``),o.current&&t(o.current.trim(),!0)},s.onerror=e=>{e.error!==`no-speech`&&e.error!==`aborted`&&console.warn(`[voice-input] error:`,e.error),n(!1),i(``)},a.current=s,s.start(),n(!0)},[e?.lang]),stop:(0,Q.useCallback)(()=>{a.current?.stop(),a.current=null,n(!1),i(``)},[]),supported:s}}var ti=2e3;function ni(e,t,n=ti){if(!(e>0)||!(t>0))return null;let r=Math.max(e,t);if(r<n)return null;let i=n-1,a=i/r;return{width:e>=t?i:Math.max(1,Math.round(e*a)),height:t>e?i:Math.max(1,Math.round(t*a))}}var ri=4096;function ii(e,t){let n=new TextEncoder().encode(t);outer:for(let t=0;t+n.length<=e.length;t++){for(let r=0;r<n.length;r++)if(e[t+r]!==n[r])continue outer;return!0}return!1}function ai(e,t){return e===`image/gif`?!0:e===`image/webp`?ii(t,`ANIM`):e===`image/png`||e===`image/apng`?ii(t,`acTL`):!1}async function oi(e){if(e.type===`image/gif`)return!0;if(e.type!==`image/webp`&&e.type!==`image/png`&&e.type!==`image/apng`)return!1;try{let t=new Uint8Array(await e.slice(0,ri).arrayBuffer());return ai(e.type,t)}catch{return!0}}var si=1600,ci=new Set([`image/png`,`image/jpeg`,`image/gif`,`image/webp`]);function li(e){return e===`image/jpeg`||e===`image/webp`?e:`image/png`}async function ui(e,t=si){let n={kind:`asis`,file:e};if(!e.type.startsWith(`image/`)||e.type===`image/svg+xml`||typeof createImageBitmap!=`function`||typeof document>`u`)return n;let r;try{r=await createImageBitmap(e)}catch{return n}let i={width:r.width,height:r.height},a=ni(i.width,i.height,t+1);if(a&&await oi(e))return r.close?.(),Math.max(i.width,i.height)<2e3&&ci.has(e.type)?{kind:`inlineable`,file:e,from:i}:{kind:`asis`,file:e,from:i};if(!a)return r.close?.(),ci.has(e.type)?{kind:`inlineable`,file:e,from:i}:{kind:`asis`,file:e,from:i};let o=r;try{try{o=await createImageBitmap(e,{resizeWidth:a.width,resizeHeight:a.height,resizeQuality:`high`}),r.close?.()}catch{o=r}let t=document.createElement(`canvas`);t.width=a.width,t.height=a.height;let n=t.getContext(`2d`);if(!n)return{kind:`asis`,file:e,from:i};n.imageSmoothingEnabled=!0,n.imageSmoothingQuality=`high`,n.drawImage(o,0,0,a.width,a.height);let s=li(e.type),c=await new Promise(e=>t.toBlob(e,s,.92));if(!c||c.size===0)return{kind:`asis`,file:e,from:i};let l=s===e.type?e.name:e.name.replace(/\.[^.]+$/,``)+`.png`;return{kind:`scaled`,file:new File([c],l,{type:s}),from:i,to:a}}catch{return{kind:`asis`,file:e,from:i}}finally{o.close?.()}}var di=new Set([`image/png`,`image/jpeg`,`image/gif`,`image/webp`]);function fi(e){return di.has(e.type)}function pi({attachments:e,onRemove:t}){let[n,r]=(0,Q.useState)(null);if(e.length===0)return null;let i=n?e.find(e=>e.id===n):null;return(0,$.jsxs)(`div`,{className:`px-2 md:px-4 pt-2`,children:[(0,$.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:e.map(e=>(0,$.jsxs)(`div`,{className:A(`flex items-center gap-1.5 rounded-md border border-border bg-surface px-2 py-1 text-xs text-text-secondary max-w-48`,e.textContent&&`cursor-pointer hover:border-primary/50`,n===e.id&&`border-primary/50 bg-surface-elevated`),onClick:()=>{e.textContent&&r(n===e.id?null:e.id)},children:[e.previewUrl?(0,$.jsx)(`img`,{src:e.previewUrl,alt:e.name,className:`size-5 rounded object-cover shrink-0`}):e.textContent?(0,$.jsx)(qe,{className:`size-3.5 shrink-0 text-text-subtle`}):e.isImage?(0,$.jsx)(Le,{className:`size-3.5 shrink-0 text-text-subtle`}):(0,$.jsx)(Ke,{className:`size-3.5 shrink-0 text-text-subtle`}),(0,$.jsx)(`span`,{className:`truncate`,children:e.name}),e.textContent&&(0,$.jsx)(s,{className:A(`size-3 shrink-0 text-text-subtle transition-transform`,n===e.id&&`rotate-180`)}),e.status===`uploading`?(0,$.jsx)(w,{className:`size-3 shrink-0 animate-spin text-text-subtle`}):e.status===`error`?(0,$.jsx)(`span`,{className:`text-error shrink-0`,title:`Upload failed`,children:`!`}):e.resized?(0,$.jsxs)(`span`,{className:`shrink-0 text-[10px] text-text-subtle`,title:`Shrunk from ${e.resized.from.width}x${e.resized.from.height} to ${e.resized.to.width}x${e.resized.to.height}`,children:[e.resized.to.width,`×`,e.resized.to.height]}):null,(0,$.jsx)(`button`,{type:`button`,onClick:i=>{i.stopPropagation(),t(e.id),n===e.id&&r(null)},className:`shrink-0 rounded-sm p-0.5 hover:bg-border/50 transition-colors`,"aria-label":`Remove ${e.name}`,children:(0,$.jsx)(te,{className:`size-3`})})]},e.id))}),i?.textContent&&(0,$.jsx)(`pre`,{className:`mt-1.5 max-h-40 overflow-auto rounded-md border border-border bg-background p-2 text-xs text-text-primary font-mono whitespace-pre-wrap break-words`,children:mi(i.textContent)})]})}function mi(e){let t=e.trim(),n=t.match(/^```\w*\n([\s\S]*?)\n```$/);return n?n[1]:t}function hi(e,t,n){if(e.length===0)return null;let r=t+n;return r<-1||r>=e.length?null:{index:r,text:r===-1?``:e[e.length-1-r]}}var gi=[{id:`default`,label:`Ask before edits`,icon:C,description:`Claude will ask for approval before making each edit`},{id:`acceptEdits`,label:`Edit automatically`,icon:_,description:`Claude will edit files without asking first`},{id:`plan`,label:`Plan mode`,icon:u,description:`Claude will present a plan before editing`},{id:`bypassPermissions`,label:`Bypass permissions`,icon:ee,description:`Claude will not ask before running commands`}];function _i(e){return gi.find(t=>t.id===e)?.label??`Unknown`}function vi(e){return gi.find(t=>t.id===e)?.icon??C}function yi({value:e,onChange:t,open:n,onOpenChange:r}){let i=(0,Q.useRef)(null),a=(0,Q.useRef)(0);(0,Q.useEffect)(()=>{if(!n)return;let e=e=>{i.current&&!i.current.contains(e.target)&&r(!1)},t=i.current?.ownerDocument??document;return t.addEventListener(`mousedown`,e),()=>t.removeEventListener(`mousedown`,e)},[n,r]),(0,Q.useEffect)(()=>{n&&(a.current=gi.findIndex(t=>t.id===e),a.current<0&&(a.current=0))},[n,e]);let s=(0,Q.useCallback)(e=>{if(e.key===`Escape`){r(!1);return}if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault();let t=e.key===`ArrowDown`?1:-1;a.current=(a.current+t+gi.length)%gi.length,(i.current?.querySelector(`[data-idx="${a.current}"]`))?.focus()}if(e.key===`Enter`){e.preventDefault();let n=gi[a.current];n&&(t(n.id),r(!1))}},[t,r]);return n?(0,$.jsxs)(`div`,{ref:i,role:`listbox`,"aria-label":`Permission modes`,onKeyDown:s,onMouseDown:e=>e.stopPropagation(),onClick:e=>e.stopPropagation(),className:`absolute bottom-full left-0 mb-1 z-50 w-72 md:w-80 rounded-lg border border-border popover-solid shadow-[var(--shadow-panel)]`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-2 border-b border-border`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-text-secondary`,children:`Modes`}),(0,$.jsx)(`kbd`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-surface-elevated text-text-subtle border border-border`,children:`Shift + Tab`})]}),(0,$.jsx)(`div`,{className:`py-1`,children:gi.map((n,i)=>{let a=n.icon,s=n.id===e;return(0,$.jsxs)(`button`,{"data-idx":i,role:`option`,"aria-selected":s,tabIndex:0,onClick:()=>{t(n.id),r(!1)},className:`w-full flex items-start gap-3 px-3 py-2.5 text-left transition-colors hover:bg-surface-elevated focus:bg-surface-elevated focus:outline-none ${s?`bg-surface-elevated`:``}`,children:[(0,$.jsx)(a,{className:`size-4 mt-0.5 shrink-0 text-text-secondary`}),(0,$.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,$.jsx)(`div`,{className:`text-sm font-medium text-text-primary`,children:n.label}),(0,$.jsx)(`div`,{className:`text-xs text-text-subtle leading-snug`,children:n.description})]}),s&&(0,$.jsx)(o,{className:`size-4 mt-0.5 shrink-0 text-primary`})]},n.id)})})]}):null}var bi=[{label:`Low`,value:`low`},{label:`Medium`,value:`medium`},{label:`High`,value:`high`,default:!0},{label:`Extra`,value:`xhigh`},{label:`Max`,value:`max`}];function xi(e){return e?bi.find(t=>t.value===e)?.label??e:``}function Si(e,t){let n=xi(t);return n?`${e} · ${n}`:e}function Ci(e){return e.replace(/^Claude\s+/i,``)}var wi=bi.find(e=>e.default).value;function Ti({model:e,effort:t,thinking:n,onModelChange:r,onEffortChange:i,onThinkingChange:s,projectName:c,providerId:l,disabled:u}){let[d,f]=(0,Q.useState)([]),[p,m]=(0,Q.useState)(!1),h=(0,Q.useRef)(null),g=oe();(0,Q.useEffect)(()=>{!c||!l||E.get(`${T(c)}/chat/providers/${l}/models`).then(f).catch(()=>{})},[c,l]),(0,Q.useEffect)(()=>{u&&m(!1)},[u]),(0,Q.useEffect)(()=>{if(!p||g)return;let e=e=>{h.current&&!h.current.contains(e.target)&&m(!1)},t=h.current?.ownerDocument??document;return t.addEventListener(`mousedown`,e),()=>t.removeEventListener(`mousedown`,e)},[p,g]);let _=d.find(t=>t.value===e),y=_?Ci(_.label):e?Ci(e):`Model`,b=t??wi,x=d.length>1,S=Si(y,b),C=e=>{e(),g||m(!1)},w=(0,$.jsxs)(`div`,{className:`flex divide-x divide-border`,children:[x&&(0,$.jsxs)(`div`,{className:`flex-1 min-w-0 py-1`,children:[(0,$.jsx)(Ei,{children:`Model`}),d.map(t=>(0,$.jsxs)(Oi,{active:t.value===e,onClick:()=>C(()=>r(t.value)),children:[(0,$.jsx)(`span`,{className:`flex-1 truncate`,children:Ci(t.label)}),t.value===e&&(0,$.jsx)(o,{className:`size-4 shrink-0 text-primary`})]},t.value))]}),(0,$.jsxs)(`div`,{className:`flex-1 min-w-0 py-1`,children:[(0,$.jsx)(Ei,{children:`Effort`}),bi.map(e=>(0,$.jsxs)(Oi,{active:e.value===b,onClick:()=>C(()=>i(e.value)),children:[(0,$.jsxs)(`span`,{className:`flex-1 truncate`,children:[e.label,e.default&&(0,$.jsx)(`span`,{className:`ml-2 text-xs text-text-subtle`,children:`Default`})]}),e.value===b&&(0,$.jsx)(o,{className:`size-4 shrink-0 text-primary`})]},e.value)),(0,$.jsx)(Di,{}),(0,$.jsxs)(`button`,{type:`button`,onClick:()=>s(!n),className:`w-full flex items-center gap-3 px-3 min-h-[44px] text-left text-sm hover:bg-surface-elevated`,role:`switch`,"aria-checked":n,children:[(0,$.jsx)(a,{className:`size-4 shrink-0`}),(0,$.jsx)(`span`,{className:`flex-1`,children:`Thinking`}),(0,$.jsx)(`span`,{className:`inline-flex h-5 w-9 items-center rounded-full transition-colors ${n?`bg-primary`:`bg-border`}`,children:(0,$.jsx)(`span`,{className:`h-4 w-4 rounded-full bg-white transition-transform ${n?`translate-x-4`:`translate-x-0.5`}`})})]})]})]});return(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsxs)(`button`,{type:`button`,disabled:u,onClick:e=>{e.stopPropagation(),u||m(e=>!e)},className:`inline-flex items-center gap-1.5 px-[9px] py-1 rounded-full text-[11.5px] text-primary bg-accent-wash border border-accent-wash-border hover:brightness-110 transition-[filter] disabled:opacity-50 disabled:cursor-default`,"aria-label":`Model ${y}, effort ${b}${n?`, thinking on`:``}`,title:u?`Can't change while running`:S,children:[(0,$.jsx)(v,{className:`h-3.5 w-3.5 shrink-0`}),(0,$.jsx)(`span`,{className:`max-w-[140px] truncate`,children:S}),n&&(0,$.jsx)(a,{className:`h-3 w-3 shrink-0`})]}),p&&!u&&(g?(0,$.jsx)(P,{open:p,onClose:()=>m(!1),children:(0,$.jsx)(`div`,{className:`px-1 pb-2`,children:w})}):(0,$.jsx)(`div`,{ref:h,role:`listbox`,"aria-label":`Model and thinking`,onMouseDown:e=>e.stopPropagation(),onClick:e=>e.stopPropagation(),className:`absolute bottom-full left-0 mb-1 z-50 w-80 rounded-lg border border-border popover-solid shadow-[var(--shadow-panel)] max-h-[70vh] overflow-y-auto`,children:w}))]})}function Ei({children:e}){return(0,$.jsx)(`div`,{className:`px-3 py-1.5 text-xs font-medium text-text-secondary`,children:e})}function Di(){return(0,$.jsx)(`div`,{className:`my-1 border-t border-border`})}function Oi({active:e,onClick:t,children:n}){return(0,$.jsx)(`button`,{type:`button`,onClick:t,className:`w-full flex items-center gap-3 px-3 min-h-[44px] text-left text-sm text-text-primary transition-colors hover:bg-surface-elevated ${e?`bg-surface-elevated`:``}`,children:n})}var ki=new Map;function Ai(e,t,n){let r=`${e}\0${t??``}\0${n??``}`,i=ki.get(r);if(i)return i;let a=new URLSearchParams;t&&a.set(`providerId`,t),n&&a.set(`sessionId`,n);let o=a.size>0?`?${a}`:``,s=E.get(`${T(e)}/chat/slash-items${o}`).then(e=>({items:e.items??[],recentNames:e.recentNames??[]})).catch(e=>{throw ki.delete(r),e});return ki.set(r,s),s}function ji(e){if(!e){ki.clear();return}let t=`${e}\0`;for(let e of ki.keys())e.startsWith(t)&&ki.delete(e)}async function Mi(e){try{let t=await new Promise((t,n)=>{let r=new FileReader;r.onload=()=>t(String(r.result??``)),r.onerror=()=>n(r.error),r.readAsDataURL(e)}),n=t.indexOf(`,`),r=n>=0?t.slice(n+1):``;return r?{data:r,mediaType:e.type||`image/png`}:void 0}catch{return}}var Ni=(0,Q.memo)(function({tabId:e,onSend:t,isStreaming:n,onCancel:r,disabled:a,projectName:o,onSlashStateChange:s,onSlashItemsLoaded:c,slashSelected:l,onFileStateChange:u,onFileItemsLoaded:d,fileSelected:f,externalFiles:p,externalPaths:m,onExternalPathsConsumed:h,initialValue:g,clearSignal:_,onContentChange:v,getUserHistory:y,autoFocus:b,permissionMode:x,onModeChange:S,providerId:C,sessionId:ee,onProviderChange:E,model:O,onModelChange:ne,effort:k,onEffortChange:A,thinking:re,onThinkingChange:ie}){let M=(0,Q.useRef)(g??``),[ae,oe]=(0,Q.useState)(()=>(g??``).trim().length>0),[N,P]=(0,Q.useState)([]),[F,se]=(0,Q.useState)(null),[ce,le]=(0,Q.useState)(!1),[I,L]=(0,Q.useState)(!1),[R,ue]=(0,Q.useState)(`next`),z=(0,Q.useRef)(null),B=(0,Q.useRef)(null),V=(0,Q.useRef)(null),de=(0,Q.useRef)([]),H=(0,Q.useRef)([]),pe=(0,Q.useRef)(0),U=(0,Q.useRef)(!1),me=(0,Q.useRef)(!1),he=(0,Q.useRef)(typeof CSS>`u`||!CSS.supports(`field-sizing`,`content`)),W=(0,Q.useCallback)(e=>{M.current=e,z.current&&(z.current.value=e),B.current&&(B.current.value=e),oe(e.trim().length>0)},[]),G=(0,Q.useCallback)(()=>window.matchMedia(`(min-width: 768px)`).matches?z.current:B.current,[]),_e=(0,Q.useRef)(-1),K=(0,Q.useCallback)(e=>{let t=hi(y?.()??[],_e.current,e);if(!t)return!1;_e.current=t.index;let{agent:n,text:r}=hr(t.text);se(n),W(r);let i=G();return i?(i.focus(),requestAnimationFrame(()=>{i.selectionStart=i.selectionEnd=r.length}),he.current&&(i.style.height=`auto`,i.style.height=Math.min(i.scrollHeight,i===B.current?80:160)+`px`),!0):!0},[y,W,G]),q=ei(),ve=(0,Q.useRef)(``),ye=(0,Q.useCallback)(e=>{let t=ve.current;W(t?t+` `+e:e),he.current&&requestAnimationFrame(()=>{let e=G();e&&(e.style.height=`auto`,e.style.height=Math.min(e.scrollHeight,160)+`px`)})},[W,G]),J=(0,Q.useCallback)(()=>{q.isListening?q.stop():(ve.current=M.current.trim(),q.start(ye))},[q.isListening,q.start,q.stop,ye]);(0,Q.useEffect)(()=>{let e=()=>{q.supported&&gn(G())&&J()};return window.addEventListener(`toggle-voice-input`,e),()=>window.removeEventListener(`toggle-voice-input`,e)},[q.supported,J,G]),(0,Q.useEffect)(()=>{let t=t=>{let{text:n,label:r,targetTabId:i}=t.detail??{};if(!n||(i?i!==e:!gn(G())))return;window.dispatchEvent(new Event(nt));let a={id:j(),name:r??`Terminal output`,file:new File([],`terminal-output.txt`),isImage:!1,textContent:n,status:`ready`};P(e=>[...e,a]),G()?.focus()};return window.addEventListener(tt,t),()=>window.removeEventListener(tt,t)},[G,e]),(0,Q.useEffect)(()=>{g&&!M.current&&(W(g),setTimeout(()=>{let e=z.current;e&&(e.focus(),e.selectionStart=e.selectionEnd=e.value.length)},50))},[g]),(0,Q.useEffect)(()=>{_&&W(``)},[_]),(0,Q.useEffect)(()=>{b&&setTimeout(()=>{G()?.focus()},100)},[]);let xe=(0,Q.useCallback)(()=>{if(!o){de.current=[],c?.([],[]);return}Ai(o,C,ee).then(e=>{de.current=e.items,c?.(e.items,e.recentNames)}).catch(()=>{de.current=[],c?.([],[])})},[o,C,ee,c]);(0,Q.useEffect)(()=>{xe()},[xe]),(0,Q.useEffect)(()=>{let e=()=>{ji(o),xe()};return window.addEventListener(`ppm:slash-items-refresh`,e),()=>window.removeEventListener(`ppm:slash-items-refresh`,e)},[xe,o]),(0,Q.useEffect)(()=>{let e=()=>{if(!o){H.current=[],d?.([]);return}let{fileIndex:e}=Me.getState(),t=e.map(e=>({name:e.name,path:e.path,type:e.type}));H.current=t,d?.(t)};e();let t=Me.getState().fileIndex,n=Me.getState().indexStatus;return Me.subscribe(r=>{(r.fileIndex!==t||r.indexStatus!==n)&&(t=r.fileIndex,n=r.indexStatus,e())})},[o]),(0,Q.useEffect)(()=>{if(!l)return;let e=G();if(!e)return;let t=e.value,n=e.selectionStart,r=t.slice(0,n),i=t.slice(n),a=e=>e.startsWith(`/`)?``:e[0];if(l.type===`agent`){let t=r.replace(/(?:^|\s)\/\S*$/,a);se(l.name),W(t+i),s?.(!1,``),U.current=!1,e.focus(),setTimeout(()=>{e.selectionStart=e.selectionEnd=t.length},0);return}let o=r.replace(/(?:^|\s)\/\S*$/,e=>`${a(e)}${l.invokeSigil??`/`}${l.name} `);W(o+i),s?.(!1,``),U.current=!1,u?.(!1,``),me.current=!1,e.focus(),setTimeout(()=>{e.selectionStart=e.selectionEnd=o.length},0)},[l]),(0,Q.useEffect)(()=>{if(!f)return;let e=G();if(!e)return;let t=e.value,n=e.selectionStart,r=t.slice(0,n),i=t.slice(n),a=r.match(/@(\S*)$/);if(a){let t=r.length-a[0].length;W(r.slice(0,t)+`@${f.path} `+i);let n=t+f.path.length+2;setTimeout(()=>{e.selectionStart=e.selectionEnd=n,e.focus()},0)}else{let n=t+`@${f.path} `;W(n),setTimeout(()=>{e.selectionStart=e.selectionEnd=n.length,e.focus()},0)}u?.(!1,``),me.current=!1},[f]),(0,Q.useEffect)(()=>{!p||p.length===0||we(p)},[p]),(0,Q.useEffect)(()=>{if(!m||m.length===0)return;let e=m.map(e=>`@${e}`).join(` `),t=M.current;W(t+(t.length>0&&!t.endsWith(` `)?` `:``)+e+` `),G()?.focus(),h?.()},[m]);let Se=(0,Q.useCallback)(async e=>{if(!o)return;let t=e.split(/[\\/]/).pop();if(t)try{let e={},n=D();n&&(e.Authorization=`Bearer ${n}`),await fetch(`${T(o)}/chat/uploads/${encodeURIComponent(t)}`,{method:`DELETE`,headers:e})}catch{}},[o]),Ce=(0,Q.useCallback)(async e=>{if(!o)return null;try{let t=new FormData;t.append(`files`,e);let n={},r=D();r&&(n.Authorization=`Bearer ${r}`);let i=await(await fetch(`${T(o)}/chat/upload`,{method:`POST`,headers:n,body:t})).json();return i.ok&&Array.isArray(i.data)&&i.data.length>0?i.data[0].path:null}catch{return null}},[o]),we=(0,Q.useCallback)(async e=>{for(let t of e){let e=j(),n=fi(t),r={id:e,name:t.name,file:t,isImage:n,previewUrl:n?URL.createObjectURL(t):void 0,status:`uploading`};P(e=>[...e,r]);try{let i=n?await ui(t):null,a=i?.file??t,o=n&&a!==t?URL.createObjectURL(a):void 0,s=await Ce(a),c=i&&i.kind!==`asis`?await Mi(a):void 0,l=!!c&&c.data.length<=gt.maxBase64PerImage;o&&r.previewUrl&&URL.revokeObjectURL(r.previewUrl),P(t=>t.map(t=>t.id===e?{...t,file:a,...o&&{previewUrl:o},serverPath:s??void 0,imageData:l?c:void 0,resized:i?.to?{from:i.from,to:i.to}:void 0,status:s||l?`ready`:`error`}:t))}catch{P(t=>t.map(t=>t.id===e?{...t,status:`error`}:t))}}(B.current??z.current)?.focus()},[Ce]),Te=(0,Q.useCallback)(e=>{P(t=>{let n=t.find(t=>t.id===e);return n?.previewUrl&&URL.revokeObjectURL(n.previewUrl),n?.serverPath&&Se(n.serverPath),t.filter(t=>t.id!==e)})},[Se]),Ee=(0,Q.useCallback)(()=>{let e=M.current.trim(),r=N.filter(e=>e.status===`ready`);if(!e&&r.length===0&&!F){L(!1);return}let i=F?`Use the ${F} agent to ${e}`.trimEnd():e;s?.(!1,``),U.current=!1,u?.(!1,``),me.current=!1,q.isListening&&q.stop(),t(i,r,n?R:void 0),W(``);for(let e of N)e.previewUrl&&URL.revokeObjectURL(e.previewUrl);P([]),se(null),L(!1),ue(`next`),_e.current=-1,he.current&&(z.current&&(z.current.style.height=`auto`),B.current&&(B.current.style.height=`auto`))},[N,F,t,s,u,n,R,W]),Y=(0,Q.useCallback)(()=>{if(!a){if(N.some(e=>e.status===`uploading`)){(M.current.trim()||N.some(e=>e.status!==`error`))&&L(!0);return}Ee()}},[N,a,Ee]);(0,Q.useEffect)(()=>{I&&(N.some(e=>e.status===`uploading`)||Ee())},[I,N,Ee]);let De=(0,Q.useCallback)(e=>{if(e.key===`Enter`&&!e.shiftKey){e.preventDefault(),Y();return}if((e.key===`ArrowUp`||e.key===`ArrowDown`)&&!e.altKey&&!e.ctrlKey&&!e.metaKey&&!e.shiftKey){if(!(_e.current>=0)&&(e.key===`ArrowDown`||M.current!==``||F))return;K(e.key===`ArrowUp`?1:-1)&&e.preventDefault();return}if(e.shiftKey&&e.key===`Tab`){e.preventDefault();let t=[`default`,`acceptEdits`,`plan`,`bypassPermissions`],n=t[(t.indexOf(x??`bypassPermissions`)+1)%t.length];S?.(n)}},[Y,x,S,K,F]),Oe=(0,Q.useCallback)((e,t)=>{let n=e.slice(0,t),r=n.includes(`/`),i=n.includes(`@`);if(!r&&!i){U.current&&=(s?.(!1,``),!1),me.current&&=(u?.(!1,``),!1);return}if(r){let e=n.match(/(?:^|\s)\/(\S*)$/);if(e&&de.current.length>0){let t=e[1]??``;s?.(!0,t),U.current=!0,me.current&&=(u?.(!1,``),!1);return}}if(i){let e=n.match(/@(\S*)$/);if(e&&H.current.length>0){u?.(!0,e[1]??``),me.current=!0,U.current&&=(s?.(!1,``),!1);return}}U.current&&=(s?.(!1,``),!1),me.current&&=(u?.(!1,``),!1)},[s,u]),ke=(0,Q.useCallback)(e=>{let t=e.target,n=t.value;M.current=n,_e.current=-1;let r=t===z.current?B.current:z.current;r&&(r.value=n),oe(n.trim().length>0),Oe(n,t.selectionStart),v?.(n,N.filter(e=>e.status===`ready`&&e.serverPath).map(e=>({name:e.name,path:e.serverPath}))),he.current&&(pe.current&&cancelAnimationFrame(pe.current),pe.current=requestAnimationFrame(()=>{pe.current=0,t.style.height=`auto`,t.style.height=Math.min(t.scrollHeight,t===B.current?80:160)+`px`}))},[Oe,v,N]),Ae=(0,Q.useCallback)(e=>{let t=e.clipboardData?.items;if(!t)return;let n=[];for(let e of t)if(e.kind===`file`){let t=e.getAsFile();t&&n.push(t)}n.length>0&&(e.preventDefault(),we(n))},[we]),je=(0,Q.useCallback)(e=>{e.preventDefault();let t=e.dataTransfer.getData(`application/x-ppm-path`);if(t){let e=M.current;W(e+(e.length>0&&!e.endsWith(` `)?` `:``)+`@${t} `),G()?.focus();return}let n=Array.from(e.dataTransfer.files);n.length>0&&we(n)},[we,W,G]),X=(0,Q.useCallback)(e=>{e.preventDefault()},[]),Ne=(0,Q.useCallback)(()=>{V.current?.click()},[]),Pe=(0,Q.useCallback)(e=>{let t=Array.from(e.target.files??[]);t.length>0&&we(t),e.target.value=``},[we]),Fe=ae||N.some(e=>e.status!==`error`)||!!F,Z=n&&!Fe;return(0,$.jsxs)(`div`,{className:`p-2 md:p-3`,children:[(0,$.jsxs)(`div`,{className:`border border-border rounded-[var(--rad)] bg-panel shadow-[var(--shadow-float)] cursor-text`,onClick:e=>{a||e.target instanceof HTMLTextAreaElement||G()?.focus()},children:[F&&(0,$.jsx)(`div`,{className:`px-2 md:px-4 pt-2`,children:(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 rounded-md border border-sky-500/30 bg-sky-500/10 px-2 py-1 text-xs font-medium text-sky-600 dark:text-sky-400`,children:[(0,$.jsx)(i,{className:`size-3.5 shrink-0`}),F,(0,$.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),se(null),G()?.focus()},className:`shrink-0 rounded-sm p-0.5 hover:bg-sky-500/20 transition-colors`,"aria-label":`Remove ${F} agent`,children:(0,$.jsx)(te,{className:`size-3`})})]})}),(0,$.jsx)(pi,{attachments:N,onRemove:Te}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1 px-2 pt-2 md:hidden relative`,children:[(0,$.jsx)(Pi,{mode:x??`bypassPermissions`,onClick:()=>le(e=>!e)}),(0,$.jsx)(yi,{value:x??`bypassPermissions`,onChange:e=>S?.(e),open:ce,onOpenChange:le}),E&&o&&(0,$.jsx)(ge,{value:C??`claude`,onChange:E,projectName:o}),ne&&o&&(0,$.jsx)(Ti,{model:O??null,effort:k??null,thinking:re??!1,onModelChange:ne,onEffortChange:A??(()=>{}),onThinkingChange:ie??(()=>{}),projectName:o,providerId:C??`claude`,disabled:n}),n&&(0,$.jsx)(Ii,{value:R,onChange:ue})]}),(0,$.jsxs)(`div`,{className:`flex items-end gap-1 md:hidden px-2 py-2`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),Ne()},disabled:a,className:`flex items-center justify-center size-8 shrink-0 rounded-[10px] text-text-3 hover:text-text-primary transition-colors disabled:opacity-50`,"aria-label":`Attach file`,children:(0,$.jsx)(mt,{className:`size-4`})}),(0,$.jsx)(`textarea`,{ref:B,defaultValue:g??``,onChange:ke,onKeyDown:De,onPaste:Ae,onDrop:je,onDragOver:X,placeholder:n?`Follow-up...`:`Ask anything...`,disabled:a,rows:1,className:`flex-1 resize-none bg-transparent py-1.5 text-sm text-foreground placeholder:text-text-subtle focus:outline-none disabled:opacity-50 max-h-20 [field-sizing:content]`}),q.supported&&(0,$.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),J()},disabled:a,className:`flex items-center justify-center size-8 shrink-0 rounded-[10px] transition-colors disabled:opacity-50 ${q.isListening?`bg-error text-white animate-pulse`:`text-text-3 hover:text-text-primary`}`,"aria-label":q.isListening?`Stop voice input`:`Start voice input`,children:q.isListening?(0,$.jsx)(pt,{className:`size-4`}):(0,$.jsx)(Re,{className:`size-4`})}),Z?(0,$.jsx)(`button`,{onClick:e=>{e.stopPropagation(),r?.()},className:`flex items-center justify-center size-9 shrink-0 rounded-[11px] bg-error text-white hover:bg-error/80 shadow-[var(--shadow-float)] transition-colors`,"aria-label":`Stop`,children:(0,$.jsx)(be,{className:`size-3.5`})}):(0,$.jsx)(`button`,{onClick:e=>{e.stopPropagation(),I?L(!1):Y()},disabled:a||!Fe,className:`flex items-center justify-center size-9 shrink-0 rounded-[11px] bg-primary text-primary-foreground hover:bg-primary/90 shadow-[var(--shadow-float)] disabled:opacity-30 disabled:shadow-none transition-colors`,"aria-label":I?`Cancel queued send`:`Send`,children:I?(0,$.jsx)(w,{className:`size-4 animate-spin`}):(0,$.jsx)(fe,{className:`size-4`})})]}),(0,$.jsxs)(`div`,{className:`hidden md:block`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 px-2.5 pt-2.5`,children:[(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(Pi,{mode:x??`bypassPermissions`,onClick:()=>le(e=>!e)}),(0,$.jsx)(yi,{value:x??`bypassPermissions`,onChange:e=>S?.(e),open:ce,onOpenChange:le})]}),E&&o&&(0,$.jsx)(ge,{value:C??`claude`,onChange:E,projectName:o}),ne&&o&&(0,$.jsx)(Ti,{model:O??null,effort:k??null,thinking:re??!1,onModelChange:ne,onEffortChange:A??(()=>{}),onThinkingChange:ie??(()=>{}),projectName:o,providerId:C??`claude`,disabled:n}),n&&(0,$.jsx)(Ii,{value:R,onChange:ue})]}),(0,$.jsxs)(`div`,{className:`flex items-end gap-2 px-2.5 py-2`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),Ne()},disabled:a,className:`flex items-center justify-center size-[34px] shrink-0 rounded-[10px] text-text-3 hover:text-text-primary hover:bg-surface-elevated transition-colors disabled:opacity-50`,"aria-label":`Attach file`,children:(0,$.jsx)(mt,{className:`size-[17px]`})}),(0,$.jsx)(`textarea`,{ref:z,defaultValue:g??``,onChange:ke,onKeyDown:De,onPaste:Ae,onDrop:je,onDragOver:X,placeholder:n?`Follow-up or Stop...`:`Ask anything...`,disabled:a,rows:1,className:`flex-1 resize-none bg-transparent py-2 text-sm text-foreground placeholder:text-text-subtle focus:outline-none disabled:opacity-50 max-h-[90px] leading-relaxed [field-sizing:content]`}),q.supported&&(0,$.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),J()},disabled:a,className:`flex items-center justify-center size-[34px] shrink-0 rounded-[10px] transition-colors disabled:opacity-50 ${q.isListening?`bg-error text-white animate-pulse`:`text-text-3 hover:text-text-primary hover:bg-surface-elevated`}`,"aria-label":q.isListening?`Stop voice input`:`Start voice input`,children:q.isListening?(0,$.jsx)(pt,{className:`size-[17px]`}):(0,$.jsx)(Re,{className:`size-[17px]`})}),Z?(0,$.jsx)(`button`,{onClick:e=>{e.stopPropagation(),r?.()},className:`flex items-center justify-center size-9 shrink-0 rounded-[11px] bg-error text-white hover:bg-error/80 shadow-[var(--shadow-float)] transition-colors`,"aria-label":`Stop response`,children:(0,$.jsx)(be,{className:`size-4`})}):(0,$.jsx)(`button`,{onClick:e=>{e.stopPropagation(),I?L(!1):Y()},disabled:a||!Fe,className:`flex items-center justify-center size-9 shrink-0 rounded-[11px] bg-primary text-primary-foreground hover:bg-primary/90 shadow-[var(--shadow-float)] disabled:opacity-30 disabled:cursor-not-allowed disabled:shadow-none transition-colors`,"aria-label":I?`Cancel queued send`:`Send message`,children:I?(0,$.jsx)(w,{className:`size-4 animate-spin`}):(0,$.jsx)(fe,{className:`size-[17px]`})})]})]})]}),(0,$.jsx)(`input`,{ref:V,type:`file`,multiple:!0,className:`hidden`,onChange:Pe})]})});function Pi({mode:e,onClick:t}){let n=vi(e),r=_i(e);return(0,$.jsxs)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),t()},className:`inline-flex items-center gap-1.5 px-[9px] py-1 rounded-full text-[11.5px] text-text-2 bg-panel-2 border border-border-soft hover:text-text-primary hover:border-border transition-colors`,"aria-label":`Permission mode: ${r}`,children:[(0,$.jsx)(n,{className:`size-3`}),(0,$.jsx)(`span`,{className:`max-w-[100px] truncate`,children:r})]})}var Fi=[{value:`now`,label:`Interrupt`,Icon:q},{value:`next`,label:`Queue`,Icon:ft},{value:`later`,label:`Later`,Icon:g}];function Ii({value:e,onChange:t}){let n=(0,Q.useCallback)(()=>{let n=[`next`,`later`,`now`];t(n[(n.indexOf(e)+1)%n.length])},[e,t]),r=Fi.find(t=>t.value===e)??Fi[1],i=r.Icon;return(0,$.jsxs)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),n()},className:`inline-flex items-center gap-1.5 px-[9px] py-1 rounded-full text-[11.5px] text-text-2 bg-panel-2 border border-border-soft hover:text-text-primary hover:border-border transition-colors`,"aria-label":`Message priority: ${r.label}`,title:`Priority: ${r.label} (click to cycle)`,children:[(0,$.jsx)(i,{className:`size-3`}),(0,$.jsx)(`span`,{children:r.label})]})}function Li(e,t){if(e===t)return 0;if(e.length===0)return t.length;if(t.length===0)return e.length;let n=Array.from({length:t.length+1},(e,t)=>t),r=Array(t.length+1);for(let i=1;i<=e.length;i++){r[0]=i;for(let a=1;a<=t.length;a++){let o=e[i-1]===t[a-1]?0:1;r[a]=Math.min(r[a-1]+1,n[a]+1,n[a-1]+o)}[n,r]=[r,n]}return n[t.length]}function Ri(e,t){let n=e.toLowerCase(),r=t.toLowerCase();if(r.startsWith(n))return{rank:0,distance:0};if(r.includes(n))return{rank:1,distance:r.indexOf(n)};let i=Math.max(Math.floor(n.length*.4),2),a=Li(n,r.slice(0,n.length+i));return a<=i?{rank:2,distance:a}:null}var zi=1;function Bi(e,t,n=20,r=[]){if(!t)return e;t=t.slice(0,50);let i=new Map(r.map((e,t)=>[e,t])),a=[];for(let n of e){let e=Ri(t,n.name),o=[e,Ri(t,n.description)].filter(e=>e!==null).sort((e,t)=>e.rank-t.rank||e.distance-t.distance)[0];if(o){let t=i.get(n.name),s=t!==void 0&&e?.rank===o.rank;a.push({item:n,rank:o.rank-(s?zi:0),distance:o.distance,recency:t??r.length})}}return a.sort((e,t)=>e.rank-t.rank||e.recency-t.recency||e.distance-t.distance||e.item.name.localeCompare(t.item.name)),a.slice(0,n).map(e=>e.item)}function Vi({items:e,filter:t,onSelect:n,onClose:r,visible:a,recentNames:o=[],projectName:s}){let[c,l]=(0,Q.useState)(0),[u,d]=(0,Q.useState)(!1),f=(0,Q.useRef)(null),p=(0,Q.useMemo)(()=>new Set(o),[o]),m=(0,Q.useMemo)(()=>{if(t)return{items:Bi(e,t,20,o),recentCount:0};if(o.length>0){let t=[],n=[];for(let r of e)p.has(r.name)?t.push(r):n.push(r);return t.sort((e,t)=>o.indexOf(e.name)-o.indexOf(t.name)),{items:[...t,...n],recentCount:t.length}}return{items:e,recentCount:0}},[e,t,o,p]),h=m.items,_=m.recentCount;(0,Q.useEffect)(()=>{l(0)},[t]),(0,Q.useEffect)(()=>{let e=f.current;e&&e.children[c]?.scrollIntoView({block:`nearest`})},[c]);let y=(0,Q.useCallback)(e=>{if(!a||h.length===0)return!1;switch(e.key){case`ArrowUp`:return e.preventDefault(),l(e=>e>0?e-1:h.length-1),!0;case`ArrowDown`:return e.preventDefault(),l(e=>e<h.length-1?e+1:0),!0;case`Enter`:case`Tab`:return e.preventDefault(),h[c]&&n(h[c]),!0;case`Escape`:return e.preventDefault(),r(),!0}return!1},[a,h,c,n,r]);(0,Q.useEffect)(()=>{if(!a)return;let e=e=>{y(e)&&e.stopPropagation()},t=f.current?.ownerDocument??document;return t.addEventListener(`keydown`,e,!0),()=>t.removeEventListener(`keydown`,e,!0)},[a,y]);let b=(0,Q.useCallback)(()=>{!s||u||(d(!0),E.del(`${T(s)}/chat/slash-items/cache`).then(()=>{window.dispatchEvent(new CustomEvent(`ppm:slash-items-refresh`))}).finally(()=>d(!1)))},[s,u]);return!a||h.length===0?null:(0,$.jsx)(`div`,{className:`max-h-52 overflow-y-auto overflow-x-hidden border-b border-border bg-surface`,children:(0,$.jsx)(`div`,{ref:f,className:`py-1`,children:h.map((e,t)=>{let r=_>0&&t===0,a=_>0&&t===_;return(0,$.jsxs)(`div`,{children:[r&&(0,$.jsxs)(`div`,{className:`flex items-center justify-between px-3 pt-1 pb-0.5`,children:[(0,$.jsxs)(`span`,{className:`text-[10px] font-medium text-text-subtle uppercase tracking-wider flex items-center gap-1`,children:[(0,$.jsx)(g,{className:`size-3`}),`Recent`]}),s&&(0,$.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),b()},className:`text-text-subtle hover:text-text-primary transition-colors p-0.5 rounded`,title:`Refresh skill list`,"aria-label":`Refresh skill list`,children:(0,$.jsx)(U,{className:`size-3 ${u?`animate-spin`:``}`})})]}),a&&(0,$.jsx)(`div`,{className:`px-3 pt-1.5 pb-0.5`,children:(0,$.jsx)(`span`,{className:`text-[10px] font-medium text-text-subtle uppercase tracking-wider`,children:`All`})}),(0,$.jsxs)(`button`,{className:`flex items-start gap-3 w-full px-3 py-2 text-left transition-colors ${t===c?`bg-primary/10 text-primary`:`hover:bg-surface-hover text-text-primary`}`,onMouseEnter:()=>l(t),onClick:()=>n(e),children:[(0,$.jsx)(`span`,{className:`shrink-0 mt-0.5`,children:e.iconDataUri?(0,$.jsx)(`img`,{src:e.iconDataUri,alt:``,className:`size-4 object-contain`}):e.type===`builtin`?(0,$.jsx)(q,{className:`size-4 text-emerald-500`}):e.type===`skill`?(0,$.jsx)(v,{className:`size-4 text-warning`}):e.type===`agent`?(0,$.jsx)(i,{className:`size-4 text-sky-500`}):(0,$.jsx)(ue,{className:`size-4 text-primary`})}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsxs)(`div`,{className:`flex items-baseline gap-2 min-w-0`,children:[(0,$.jsxs)(`span`,{className:`font-medium text-sm truncate`,children:[e.invokeSigil??`/`,e.name]}),e.displayName&&e.displayName!==e.name&&(0,$.jsx)(`span`,{className:`text-xs text-text-2 truncate`,children:e.displayName}),e.argumentHint&&(0,$.jsx)(`span`,{className:`text-xs text-text-subtle truncate`,children:e.argumentHint}),(0,$.jsx)(`span`,{className:`text-xs text-text-subtle capitalize ml-auto shrink-0 whitespace-nowrap`,children:e.invokeSigil===`$`?`Codex`:e.scope===`bundled`?`PPM`:e.scope===`user`?`global`:e.type})]}),e.description&&(0,$.jsx)(`p`,{className:`text-xs text-text-subtle mt-0.5 line-clamp-2 break-words`,children:e.description})]})]})]},`${e.type}-${e.name}`)})})})}function Hi({items:e,filter:t,onSelect:n,onClose:r,visible:i}){let[a,o]=(0,Q.useState)(0),s=(0,Q.useRef)(null),c=(()=>{if(!t)return e.slice(0,50);let n=t.toLowerCase();return e.filter(e=>e.path.toLowerCase().includes(n)||e.name.toLowerCase().includes(n)).slice(0,50)})();(0,Q.useEffect)(()=>{o(0)},[t]),(0,Q.useEffect)(()=>{let e=s.current;e&&e.children[a]?.scrollIntoView({block:`nearest`})},[a]);let l=(0,Q.useCallback)(e=>{if(!i||c.length===0)return!1;switch(e.key){case`ArrowUp`:return e.preventDefault(),o(e=>e>0?e-1:c.length-1),!0;case`ArrowDown`:return e.preventDefault(),o(e=>e<c.length-1?e+1:0),!0;case`Enter`:case`Tab`:return e.preventDefault(),c[a]&&n(c[a]),!0;case`Escape`:return e.preventDefault(),r(),!0}return!1},[i,c,a,n,r]);return(0,Q.useEffect)(()=>{if(!i)return;let e=e=>{l(e)&&e.stopPropagation()},t=s.current?.ownerDocument??document;return t.addEventListener(`keydown`,e,!0),()=>t.removeEventListener(`keydown`,e,!0)},[i,l]),!i||c.length===0?null:(0,$.jsx)(`div`,{className:`max-h-52 overflow-y-auto border-b border-border bg-surface`,children:(0,$.jsx)(`div`,{ref:s,className:`py-1`,children:c.map((e,t)=>(0,$.jsxs)(`button`,{className:`flex items-center gap-2 w-full px-3 py-1.5 text-left transition-colors ${t===a?`bg-primary/10 text-primary`:`hover:bg-surface-hover text-text-primary`}`,onMouseEnter:()=>o(t),onClick:()=>n(e),children:[(0,$.jsx)(`span`,{className:`shrink-0`,children:e.type===`directory`?(0,$.jsx)(X,{className:`size-4 text-warning`}):(0,$.jsx)(Oe,{className:`size-4 text-primary`})}),(0,$.jsx)(`span`,{className:`text-sm truncate`,children:e.path})]},e.path))})})}var Ui=e=>`${(e/1048576).toFixed(2)} MB`;function Wi(e){return e>=1048576?`${(e/1048576).toFixed(1)} MB`:`${Math.max(1,Math.round(e/1024))} KB`}function Gi(){let e=null;for(let t of document.querySelectorAll(`.overflow-y-auto`))t.clientHeight<100||!t.querySelector(`[data-msg-index]`)||(!e||t.scrollHeight>e.scrollHeight)&&(e=t);let t=[];e&&(t.push(`Rendered messages: ${e.querySelectorAll(`[data-msg-index]`).length}`),t.push(`Transcript DOM nodes: ${e.querySelectorAll(`*`).length}`),t.push(`Transcript height: ${Math.round(e.scrollHeight)}px`));let n=performance.memory;return n&&t.push(`JS heap (page): ${(n.usedJSHeapSize/1048576).toFixed(1)} MB`),t}function Ki({sessionId:e,projectName:t}){let[n,r]=(0,Q.useState)(null),[i,a]=(0,Q.useState)(null),[o,s]=(0,Q.useState)(null),[c,l]=(0,Q.useState)(null);(0,Q.useEffect)(()=>{let n=!0;return E.get(`${T(t)}/chat/sessions/${e}/images?project=${encodeURIComponent(t)}`).then(e=>{n&&r(e)}).catch(e=>{n&&a(e.message)}),()=>{n=!1}},[e,t]);let u=(n,i=!1)=>{s(n),a(null),E.post(`${T(t)}/chat/sessions/${e}/images/strip?project=${encodeURIComponent(t)}`,{mode:n,includeAttachments:i}).then(e=>{r(e.remaining),l({removed:e.removed,bytes:e.bytesFreed})}).catch(e=>a(e.message)).finally(()=>s(null))};return i&&!n?(0,$.jsx)(`p`,{className:`text-[11px] text-error`,children:i}):n?(0,$.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,$.jsx)(`h3`,{className:`text-xs font-semibold text-foreground`,children:`Transcript images`}),n.total===0?(0,$.jsxs)(`p`,{className:`text-[11px] text-text-subtle`,children:[`No images in this transcript`,c?` — it is clean.`:`.`]}):(0,$.jsxs)(`p`,{className:`text-[11px] text-text-secondary`,children:[n.total,` image`,n.total===1?``:`s`,` · `,Wi(n.bytes),` of base64, replayed on every turn`,n.attachments>0&&` · ${n.attachments} attached by you`,`.`]}),n.oversized>0&&(0,$.jsxs)(`div`,{className:`flex gap-2 rounded-md border border-warning/40 bg-warning/10 p-2 text-[11px] text-text-secondary`,children:[(0,$.jsx)(K,{className:`mt-px size-3.5 shrink-0 text-warning`}),(0,$.jsxs)(`span`,{children:[n.oversized,` image`,n.oversized===1?` reaches`:`s reach`,` the `,n.limit,`px limit (largest `,n.largestSide,`px). Once a request carries several images the API rejects those outright, which fails the whole turn — removing them loses no context.`]})]}),n.oversizedAttachments>0&&(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-md border border-error/40 bg-error/10 p-2 text-[11px] text-text-secondary`,children:[(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(K,{className:`mt-px size-3.5 shrink-0 text-error`}),(0,$.jsxs)(`span`,{children:[n.oversizedAttachments,` of those `,n.oversizedAttachments===1?`is an image you`:`are images you`,` `,`attached yourself, so the buttons below leave `,n.oversizedAttachments===1?`it`:`them`,` in place. While `,n.oversizedAttachments===1?`it stays`:`they stay`,`, every turn in this session keeps failing. Removing `,n.oversizedAttachments===1?`it`:`them`,` cannot be undone: an attachment PPM sent keeps a copy on disk with its path still in the message, but one from another client does not.`]})]}),(0,$.jsxs)(N,{size:`sm`,variant:`destructive`,disabled:o!==null,onClick:()=>u(`oversized`,!0),children:[o===`oversized`?(0,$.jsx)(w,{className:`size-3.5 animate-spin`}):(0,$.jsx)(dt,{className:`size-3.5`}),`Remove oversized, attachments included`]})]}),c&&(0,$.jsxs)(`p`,{className:`text-[11px] text-success`,children:[`Removed `,c.removed,` image`,c.removed===1?``:`s`,`, freed `,Wi(c.bytes),`.`]}),i&&(0,$.jsx)(`p`,{className:`text-[11px] text-error`,children:i}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5 sm:flex-row`,children:[(0,$.jsxs)(N,{size:`sm`,variant:`outline`,className:`flex-1`,disabled:o!==null||n.oversized===0,onClick:()=>u(`oversized`),children:[o===`oversized`?(0,$.jsx)(w,{className:`size-3.5 animate-spin`}):(0,$.jsx)(dt,{className:`size-3.5`}),`Remove oversized`,n.oversized>0?` (${n.oversized} · ${Wi(n.oversizedBytes)})`:``]}),(0,$.jsxs)(N,{size:`sm`,variant:`destructive`,className:`flex-1`,disabled:o!==null||n.total===0,onClick:()=>u(`all`),children:[o===`all`?(0,$.jsx)(w,{className:`size-3.5 animate-spin`}):(0,$.jsx)(dt,{className:`size-3.5`}),`Remove all`,n.total>0?` (${n.total} · ${Wi(n.bytes)})`:``]})]}),(0,$.jsx)(`p`,{className:`text-[11px] text-text-subtle`,children:`These two buttons cover tool images only, and leave anything you attached alone. A removed tool image is replaced by its placeholder text; the chat still shows the file, re-read from disk.`})]}):(0,$.jsx)(`p`,{className:`text-[11px] text-text-subtle`,children:`Scanning transcript for images...`})}function qi({sessionId:e,projectName:t}){let[n,r]=(0,Q.useState)(null),[i,a]=(0,Q.useState)(null);if((0,Q.useEffect)(()=>{let n=!0;return E.get(`${T(t)}/chat/sessions/${e}/usage?project=${encodeURIComponent(t)}`).then(e=>{n&&r(e.turns)}).catch(e=>{n&&a(e.message)}),()=>{n=!1}},[e,t]),i)return(0,$.jsx)(`p`,{className:`text-[11px] text-error`,children:i});if(!n)return(0,$.jsx)(`p`,{className:`text-[11px] text-text-subtle`,children:`Loading token history...`});if(n.length===0)return(0,$.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,$.jsx)(`h3`,{className:`text-xs font-semibold text-foreground`,children:`Token & cache`}),(0,$.jsx)(`p`,{className:`text-[11px] text-text-subtle`,children:`No turns recorded yet. Send a message and the token split for each turn shows up here.`})]});let o=n.filter(e=>e.usage.coldStart).length,s=n.reduce((e,t)=>e+t.usage.costUsd,0),c=n.reduce((e,t)=>e+Mn(t.usage),0),l=new Set(n.map(e=>e.usage.accountId).filter(Boolean)).size;return(0,$.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,$.jsx)(`h3`,{className:`text-xs font-semibold text-foreground`,children:`Token & cache`}),(0,$.jsxs)(`p`,{className:`text-[11px] text-text-secondary`,children:[`Last `,n.length,` turn`,n.length===1?``:`s`,` · `,o,` restarted the session ·`,` `,Bn(c),` of transcript re-sent uncached · $`,s.toFixed(2),l>1&&` · spread over ${l} accounts`]}),(0,$.jsx)(`div`,{className:`max-h-[30vh] overflow-y-auto rounded-md border border-border`,children:(0,$.jsxs)(`table`,{className:`w-full font-mono text-[10.5px]`,children:[(0,$.jsx)(`thead`,{className:`sticky top-0 bg-surface text-text-subtle`,children:(0,$.jsxs)(`tr`,{children:[(0,$.jsx)(`th`,{className:`px-2 py-1 text-left font-normal`,children:`When`}),(0,$.jsx)(`th`,{className:`px-2 py-1 text-left font-normal`,children:`Account`}),(0,$.jsx)(`th`,{className:`px-2 py-1 text-right font-normal`,children:`Prefix`}),(0,$.jsx)(`th`,{className:`px-2 py-1 text-right font-normal`,children:`Cached`}),(0,$.jsx)(`th`,{className:`px-2 py-1 text-right font-normal`,children:`Cost`}),(0,$.jsx)(`th`,{className:`px-2 py-1 text-left font-normal`,children:`Start`})]})}),(0,$.jsx)(`tbody`,{children:n.map(e=>{let t=Math.round(e.usage.cacheHitRate*100),n=In(e.usage).level;return(0,$.jsxs)(`tr`,{className:`border-t border-border`,children:[(0,$.jsx)(`td`,{className:`px-2 py-1 text-text-subtle`,children:e.recordedAt.slice(11,16)||e.recordedAt.slice(0,10)}),(0,$.jsx)(`td`,{className:`max-w-24 truncate px-2 py-1 text-text-subtle`,title:e.usage.accountLabel??e.usage.accountId??``,children:e.usage.accountLabel??e.usage.accountId?.slice(0,8)??`—`}),(0,$.jsx)(`td`,{className:`px-2 py-1 text-right text-text-secondary`,children:Bn(jn(e.usage))}),(0,$.jsxs)(`td`,{className:`px-2 py-1 text-right ${n===`bad`?`text-warning`:n===`warn`?`text-text-primary`:`text-success`}`,children:[t,`%`]}),(0,$.jsxs)(`td`,{className:`px-2 py-1 text-right text-text-secondary`,children:[`$`,e.usage.costUsd.toFixed(3)]}),(0,$.jsx)(`td`,{className:`px-2 py-1 text-text-subtle`,children:e.usage.coldStart?e.usage.coldReason??`cold`:`warm`})]},e.id)})})]})}),(0,$.jsxs)(`p`,{className:`text-[11px] text-text-subtle`,children:[`A high "Cached" share is the cheap case. A turn marked `,(0,$.jsx)(`code`,{children:`idle_timeout`}),` paid for the whole transcript again because the session sat idle with no tab open long enough for PPM to release its subprocess. The cache is scoped per account, so a turn on a different account starts cold no matter how the session was resumed.`]})]})}function Ji({sessionId:e,projectName:t,open:n,onOpenChange:r}){let[i,a]=(0,Q.useState)(null),[o,s]=(0,Q.useState)(!1),c=oe();(0,Q.useEffect)(()=>{n&&(s(!1),a(null),E.get(`${T(t)}/chat/sessions/${e}/debug?project=${encodeURIComponent(t)}`).then(e=>{let t=e.jsonlSizeBytes==null?``:` (${Ui(e.jsonlSizeBytes)}${e.jsonlLines==null?``:`, ${e.jsonlLines} records`})`;a([`PPM Session: ${e.ppmSessionId}`,`SDK Session: ${e.sdkSessionId}`,e.jsonlPath?`JSONL: ${e.jsonlPath}${t}`:`JSONL: not found`,e.projectPath?`Project: ${e.projectPath}`:null,...Gi()].filter(Boolean).join(`
8
- `))}).catch(()=>a(`Failed to load debug info`)))},[n,e,t]);let l=(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,$.jsxs)(`h2`,{className:`flex items-center gap-2 text-sm font-semibold text-foreground`,children:[(0,$.jsx)(G,{className:`size-4 text-primary`}),`Session debug info`]}),(0,$.jsx)(`pre`,{className:`max-h-[35vh] overflow-y-auto whitespace-pre-wrap break-all rounded-md border border-border bg-surface p-2.5 font-mono text-[11px] leading-relaxed text-text-secondary select-text`,children:i??`Loading...`}),(0,$.jsx)(N,{size:`sm`,onClick:()=>{i&&He(i).then(e=>{e&&(s(!0),setTimeout(()=>s(!1),1500))})},disabled:!i,className:`w-full`,children:o?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(ut,{className:`size-3.5`}),` Copied!`]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(y,{className:`size-3.5`}),` Copy`]})}),(0,$.jsx)(`div`,{className:`border-t border-border pt-3`,children:n&&(0,$.jsx)(qi,{sessionId:e,projectName:t})}),(0,$.jsx)(`div`,{className:`border-t border-border pt-3`,children:n&&(0,$.jsx)(Ki,{sessionId:e,projectName:t})})]});return c?(0,$.jsx)(P,{open:n,onClose:()=>r(!1),className:`popover-solid`,children:(0,$.jsx)(`div`,{className:`max-h-[85vh] overflow-y-auto px-4 pb-4 pt-1`,children:l})}):(0,$.jsx)(pe,{open:n,onOpenChange:r,children:(0,$.jsxs)(Te,{className:`sm:max-w-lg`,children:[(0,$.jsx)(F,{className:`sr-only`,children:`Session debug info`}),l]})})}function Yi({hasUnread:e,onToggleUnread:t,onOpenDebug:n}){return(0,$.jsxs)(H,{children:[(0,$.jsx)(me,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:`flex items-center justify-center size-5 rounded text-text-subtle hover:text-text-secondary hover:bg-surface-elevated transition-colors`,title:`More actions`,"aria-label":`More actions`,children:(0,$.jsx)(x,{className:`size-3.5`})})}),(0,$.jsxs)(W,{align:`end`,side:`top`,className:`min-w-[190px]`,children:[(0,$.jsx)(xe,{onClick:t,className:`max-md:py-3`,children:e?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(z,{className:`size-3.5 text-warning`}),` Mark as read`]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(h,{className:`size-3.5 fill-current text-primary`}),` Mark as unread`]})}),(0,$.jsxs)(xe,{onClick:n,className:`max-md:py-3`,children:[(0,$.jsx)(G,{className:`size-3.5`}),` Session debug info`]})]})]})}function Xi({usage:e,visible:t,onClose:n,onReload:r,loading:i,lastFetchedAt:a}){let{usages:o,accounts:s,activeAccountId:c,initialLoading:l,refreshing:u,flashIds:d,reload:f}=st(t),[p,m]=(0,Q.useState)(!1);if(!t)return null;let h=new Map(s.map(e=>[e.id,e])),g=e.queryCostUsd!=null||e.totalCostUsd!=null,_=o.length>0,v=o.length||1,y=Math.ceil(Math.sqrt(v)),b=Math.ceil(v/y);return(0,$.jsxs)(`div`,{className:`relative border-b border-border bg-surface px-3 py-2.5 ${p?`fixed inset-0 z-50 flex flex-col gap-2.5 overflow-hidden`:`space-y-2.5 max-h-[350px] overflow-y-auto`}`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between shrink-0`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`text-xs font-semibold text-text-primary`,children:`Usage`}),a&&(0,$.jsx)(`span`,{className:`text-[10px] text-text-subtle`,children:it(new Date(a).getTime())})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,$.jsxs)(`button`,{onClick:()=>Ae(`accounts`),className:`flex items-center gap-1 text-[10px] text-text-subtle hover:text-text-primary px-1 cursor-pointer`,title:`Add, remove or rotate accounts`,children:[`Manage accounts `,(0,$.jsx)(I,{className:`size-3`})]}),_&&(0,$.jsx)(`button`,{onClick:()=>m(e=>!e),className:`text-xs text-text-subtle hover:text-text-primary px-1 cursor-pointer`,title:p?`Exit fullscreen`:`Fullscreen view`,"aria-label":p?`Exit fullscreen`:`Fullscreen view`,children:p?(0,$.jsx)(Ue,{className:`size-3`}):(0,$.jsx)(Ne,{className:`size-3`})}),r&&(0,$.jsx)(`button`,{onClick:()=>{r(),f()},disabled:i||u,className:`text-xs text-text-subtle hover:text-text-primary px-1 disabled:opacity-50 cursor-pointer`,title:`Refresh`,"aria-label":`Refresh usage`,children:(0,$.jsx)(U,{className:`size-3 ${i||u?`animate-spin`:``}`})}),(0,$.jsx)(`button`,{onClick:()=>{m(!1),n()},className:`text-xs text-text-subtle hover:text-text-primary px-1 cursor-pointer`,"aria-label":`Close usage panel`,children:(0,$.jsx)(te,{className:`size-3`})})]})]}),_||l?(0,$.jsx)(`div`,{className:p?`flex-1 min-h-0 grid gap-2 overflow-hidden`:`flex gap-2 overflow-x-auto pb-1 -mx-3 px-3 snap-x snap-mandatory scrollbar-thin`,style:p?{gridTemplateColumns:`repeat(${y}, minmax(0, 1fr))`,gridTemplateRows:`repeat(${b}, minmax(0, 1fr))`}:void 0,children:l?(0,$.jsx)(`p`,{className:`text-[10px] text-text-subtle`,children:`Loading...`}):o.map(t=>(0,$.jsx)(at,{entry:t,isActive:t.accountId===(c??e.activeAccountId),accountInfo:h.get(t.accountId),flash:d.has(t.accountId),layout:p?`grid`:`strip`},t.accountId))}):e.session||e.weekly||e.weeklyOpus||e.weeklySonnet?(0,$.jsxs)(`div`,{className:`space-y-2.5`,children:[(0,$.jsx)(ot,{label:`5-Hour Session`,bucket:e.session}),(0,$.jsx)(ot,{label:`Weekly`,bucket:e.weekly}),(0,$.jsx)(ot,{label:`Weekly (Opus)`,bucket:e.weeklyOpus}),(0,$.jsx)(ot,{label:`Weekly (Sonnet)`,bucket:e.weeklySonnet})]}):(0,$.jsx)(`p`,{className:`text-xs text-text-subtle`,children:`No usage data available`}),g&&(0,$.jsxs)(`div`,{className:`border-t border-border pt-2 space-y-1`,children:[e.queryCostUsd!=null&&(0,$.jsxs)(`div`,{className:`flex items-center justify-between text-xs`,children:[(0,$.jsx)(`span`,{className:`text-text-subtle`,children:`Last query`}),(0,$.jsxs)(`span`,{className:`text-text-primary font-medium tabular-nums`,children:[`$`,e.queryCostUsd.toFixed(4)]})]}),e.totalCostUsd!=null&&(0,$.jsxs)(`div`,{className:`flex items-center justify-between text-xs`,children:[(0,$.jsx)(`span`,{className:`text-text-subtle`,children:`Session total`}),(0,$.jsxs)(`span`,{className:`text-text-primary font-medium tabular-nums`,children:[`$`,e.totalCostUsd.toFixed(4)]})]})]})]})}function Zi(e){return e>=90?`text-error`:e>=70?`text-warning`:`text-success`}function Qi(e){return e>=90?`bg-error`:e>=70?`bg-warning`:`bg-success`}function $i({label:e,frac:t}){let n=t==null?null:Math.round(t*100);return(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-text-primary`,children:e}),(0,$.jsx)(`span`,{className:`text-xs font-medium tabular-nums ${n==null?`text-text-subtle`:Zi(n)}`,children:n==null?`—`:`${n}%`})]}),(0,$.jsx)(`div`,{className:`h-2 rounded-full bg-border overflow-hidden`,children:(0,$.jsx)(`div`,{className:`h-full rounded-full transition-all ${n==null?``:Qi(n)}`,style:{width:`${Math.min(n??0,100)}%`}})})]})}function ea({onClose:e,usage:t}){let[n,r]=(0,Q.useState)([]),[i,a]=(0,Q.useState)({}),[o,s]=(0,Q.useState)(!1),c=(0,Q.useCallback)(async()=>{s(!0);try{r((await E.get(`/api/codex-accounts`)).accounts),a(await E.get(`/api/codex-accounts/usage`))}catch{}finally{s(!1)}},[]);return(0,Q.useEffect)(()=>{c()},[c]),(0,$.jsxs)(`div`,{className:`border-t border-border bg-surface px-3 py-2.5 space-y-2.5 max-h-[350px] overflow-y-auto`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(`span`,{className:`text-xs font-semibold text-text-primary`,children:`Codex Usage`}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(`button`,{onClick:c,disabled:o,className:`text-text-subtle hover:text-text-primary px-1 cursor-pointer disabled:opacity-50`,title:`Refresh`,children:(0,$.jsx)(U,{className:`size-3 ${o?`animate-spin`:``}`})}),(0,$.jsx)(`button`,{onClick:e,className:`text-text-subtle hover:text-text-primary px-1 cursor-pointer`,title:`Close`,children:(0,$.jsx)(te,{className:`size-3`})})]})]}),o&&n.length===0&&(0,$.jsxs)(`div`,{className:`text-xs text-text-subtle flex items-center gap-2`,children:[(0,$.jsx)(w,{className:`size-3 animate-spin`}),` Loading…`]}),!o&&n.length===0&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`rounded-md border border-border/50 bg-surface/40 p-2.5 space-y-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`text-sm text-text-primary truncate flex-1 min-w-0`,children:t.activeAccountLabel||`Default login`}),(0,$.jsx)(`span`,{className:`text-[10px] uppercase tracking-wide text-text-subtle border border-border rounded px-1`,children:`~/.codex`})]}),(0,$.jsx)($i,{label:`5-Hour`,frac:t.fiveHour}),(0,$.jsx)($i,{label:`Weekly`,frac:t.sevenDay})]}),(0,$.jsxs)(`p`,{className:`text-[11px] text-text-subtle`,children:[`Using your default `,(0,$.jsx)(`code`,{children:`~/.codex`}),` login. Add managed accounts in Settings → AI Provider → Codex.`]})]}),n.map(e=>{let t=i[e.id]??{};return(0,$.jsxs)(`div`,{className:`rounded-md border border-border/50 bg-surface/40 p-2.5 space-y-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`text-sm text-text-primary truncate flex-1 min-w-0`,children:e.label}),(0,$.jsx)(`span`,{className:`text-[10px] uppercase tracking-wide text-text-subtle border border-border rounded px-1`,children:e.type}),e.planType&&(0,$.jsx)(`span`,{className:`text-[10px] text-text-subtle`,children:e.planType})]}),(0,$.jsx)($i,{label:`5-Hour`,frac:t.fiveHour}),(0,$.jsx)($i,{label:`Weekly`,frac:t.sevenDay})]},e.id)})]})}var ta={working:`working`,paused:`paused`,"no-transcript":`no session`};function na({member:e,onOpen:t}){let n=e.workState===`working`,r=Yr(e),i=Jr(e.startedAt,n?void 0:e.lastEventAt),a=qr(e.agentType);return(0,$.jsxs)(`button`,{type:`button`,onClick:()=>t(e.name),className:`w-full text-left min-h-[44px] px-1.5 py-1 rounded-md hover:bg-surface-elevated transition-colors group`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-xs`,children:[n?(0,$.jsx)(w,{className:`size-3 shrink-0 animate-spin text-success`}):(0,$.jsx)(`span`,{className:A(`size-1.5 rounded-full shrink-0`,e.workState===`paused`?`bg-warning`:`bg-text-3`)}),(0,$.jsx)(`span`,{className:`font-medium truncate`,children:e.name}),a&&(0,$.jsx)(`span`,{className:`text-text-subtle text-[10px] truncate`,children:a}),e.model&&(0,$.jsxs)(`span`,{className:`text-text-subtle text-[10px]`,children:[`(`,e.model,`)`]}),(0,$.jsxs)(`span`,{className:`ml-auto flex items-center gap-1 shrink-0 text-[10px] text-text-subtle`,children:[i&&(0,$.jsx)(`span`,{children:i}),(0,$.jsx)(`span`,{className:A(n&&`text-success`),children:ta[e.workState]}),(0,$.jsx)(c,{className:`size-3 opacity-0 group-hover:opacity-100 transition-opacity`})]})]}),r&&(0,$.jsx)(`div`,{className:`mt-0.5 pl-5 text-[11px] text-text-subtle truncate font-mono`,children:r})]})}function ra({members:e,loading:t,onOpenMember:n,className:r}){return e.length===0?(0,$.jsx)(`div`,{className:A(`flex items-center justify-center gap-2 text-xs text-text-subtle py-4`,r),children:t?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(w,{className:`size-3 animate-spin`}),`Reading member sessions…`]}):`No member sessions recorded`}):(0,$.jsx)(`div`,{className:A(`overflow-y-auto space-y-0.5`,r),children:e.map(e=>(0,$.jsx)(na,{member:e,onOpen:n},e.name))})}var ia=[`subject`,`summary`,`text`,`message`,`content`,`description`,`reason`,`feedback`],aa=[`description`,`message`,`content`,`reason`,`feedback`],oa=new Set([`type`,`taskId`,`task_id`,`assignedBy`,`assigned_by`,`timestamp`,`request_id`,`requestId`]),sa=e=>typeof e==`string`?e.trim():e==null?``:String(e);function ca(e,t,n){for(let r of t){if(r===n)continue;let t=sa(e[r]);if(t)return{key:r,value:t}}return null}function la(e){return Object.entries(e).filter(([e,t])=>!oa.has(e)&&sa(t)).map(([e,t])=>`${e}: ${sa(t)}`).join(` · `)}function ua(e,t){let n=sa(t),r=sa(e);if(!r)return{title:n};let i;try{i=JSON.parse(r)}catch{let[e,...t]=r.split(`
9
- `),i=t.join(`
10
- `).trim();return{title:n||sa(e),...i?{detail:i}:{}}}if(!i||typeof i!=`object`||Array.isArray(i))return{title:n||r};let a=i,o=sa(a.taskId)||sa(a.task_id),s=ca(a,ia),c=ca(a,aa,s?.key);return{title:n||s?.value||la(a)||sa(a.type)||r,...c?{detail:c.value}:{},...o?{taskId:o}:{}}}function da({messages:e,className:t}){let n=(0,Q.useRef)(null);return(0,Q.useEffect)(()=>{n.current?.scrollIntoView({behavior:`smooth`})},[e.length]),e.length===0?(0,$.jsx)(`p`,{className:A(`text-xs text-text-subtle text-center py-4`,t),children:`No messages yet`}):(0,$.jsx)(`div`,{className:A(`overflow-y-auto`,t),children:(0,$.jsxs)(`div`,{className:`space-y-2`,children:[e.map((e,t)=>{let n=e.parsedType?m[e.parsedType]:null,{title:r,detail:i,taskId:a}=ua(e.text,e.summary);return(0,$.jsxs)(`div`,{className:`text-xs`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1 text-text-subtle`,children:[(0,$.jsx)(`span`,{className:`font-medium`,style:pa(e.color),children:e.from}),(0,$.jsx)(`span`,{children:`→`}),(0,$.jsx)(`span`,{children:e.to}),(0,$.jsx)(`span`,{className:`ml-auto text-[10px]`,children:fa(e.timestamp)})]}),(0,$.jsxs)(`div`,{className:`mt-0.5 text-foreground/90 break-words`,children:[n&&(0,$.jsx)(`span`,{className:A(`inline-block px-1 py-0 rounded text-[9px] mr-1`,n.className),children:n.label}),a&&(0,$.jsxs)(`span`,{className:`inline-block px-1 py-0 rounded text-[9px] mr-1 bg-surface-elevated text-text-subtle`,children:[`#`,a]}),r]}),i&&(0,$.jsx)(`div`,{className:`mt-0.5 text-[11px] text-text-subtle break-words line-clamp-2`,children:i})]},`${e.timestamp}-${t}`)}),(0,$.jsx)(`div`,{ref:n})]})})}function fa(e){try{return new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,second:`2-digit`})}catch{return``}}function pa(e){if(e&&(/^#[0-9a-fA-F]{3,8}$/.test(e)||/^[a-zA-Z]{3,20}$/.test(e)))return{color:e}}function ma(e,t){return e===t?`Team (current session)`:e}function ha({teamNames:e,messages:t,sessionId:n,projectName:r}){let[i,a]=(0,Q.useState)(e[0]??``),[o,s]=(0,Q.useState)(`members`),c=et(),l=b();(0,Q.useEffect)(()=>{e.length>0&&!e.includes(i)&&a(e[0])},[e,i]);let{members:u,outbound:d,loading:f,refresh:p}=Qr(i,!!i),m=(0,Q.useCallback)(e=>{c({teamName:i,memberName:e,projectName:r})},[c,i,r]),h=(0,Q.useMemo)(()=>{let e=d.map(e=>({from:e.from,to:e.to,text:e.text,timestamp:e.timestamp,...e.summary?{summary:e.summary}:{}}));return[...t,...e].sort((e,t)=>new Date(e.timestamp).getTime()-new Date(t.timestamp).getTime()).slice(-200)},[t,d]),g=u.filter(e=>e.workState===`working`).length,_=e=>A(`flex items-center gap-1.5 px-2.5 rounded-md text-[11px] whitespace-nowrap transition-colors`,l?`min-h-[44px]`:`py-1`,e?`bg-primary/10 text-primary font-medium`:`text-text-subtle hover:text-text-primary`);return(0,$.jsxs)(`div`,{className:`flex flex-col min-h-0`,children:[e.length>1&&(0,$.jsx)(`div`,{className:`flex items-center gap-1 overflow-x-auto min-w-0 mb-1.5`,children:e.map(e=>(0,$.jsx)(`button`,{onClick:()=>a(e),className:A(`px-2 py-0.5 text-[11px] rounded-md whitespace-nowrap transition-colors`,i===e?`bg-primary/10 text-primary font-medium`:`text-text-subtle hover:text-text-primary`),children:ma(e,n)},e))}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1 mb-1.5 shrink-0`,role:`tablist`,children:[(0,$.jsxs)(`button`,{role:`tab`,"aria-selected":o===`members`,onClick:()=>s(`members`),className:_(o===`members`),children:[(0,$.jsx)(`span`,{children:`Members`}),(0,$.jsx)(`span`,{className:`text-text-subtle`,children:u.length}),g>0&&(0,$.jsxs)(`span`,{className:`flex items-center gap-1 text-success`,children:[(0,$.jsx)(`span`,{className:`size-1.5 rounded-full bg-success animate-pulse`}),g]})]}),(0,$.jsxs)(`button`,{role:`tab`,"aria-selected":o===`messages`,onClick:()=>s(`messages`),className:_(o===`messages`),children:[(0,$.jsx)(`span`,{children:`Messages`}),(0,$.jsx)(`span`,{className:`text-text-subtle`,children:h.length})]}),(0,$.jsx)(`button`,{onClick:p,className:A(`ml-auto text-text-subtle hover:text-foreground shrink-0`,l?`p-3`:`p-1`),"aria-label":`Refresh`,children:(0,$.jsx)(U,{className:A(`size-3`,f&&`animate-spin`)})})]}),o===`members`?(0,$.jsx)(ra,{members:u,loading:f,onOpenMember:m,className:`max-h-56`}):(0,$.jsx)(da,{messages:h,className:`max-h-56`})]})}function ga(e){return e>=90?`text-error`:e>=70?`text-warning`:`text-success`}function _a({projectName:e,usageInfo:t,usageLoading:n,refreshUsage:r,lastFetchedAt:a,sessionId:s,providerId:c,onSelectSession:l,onBugReport:u,isConnected:d,onReload:f,teamActivity:p,teamMessages:m,onTeamOpen:h}){let[g,_]=(0,Q.useState)(null),[v,y]=(0,Q.useState)([]),[b,x]=(0,Q.useState)(!1),S=Ge(e=>e.notifications),C=Ge(e=>s?e.notifications.has(s):!1),ee=Ge(e=>e.clearForSession),D=Ge(e=>e.markUnread),[O,ne]=(0,Q.useState)(``),k=Se(O,300),[j,re]=(0,Q.useState)(null),[ie,M]=(0,Q.useState)(``),[oe,N]=(0,Q.useState)(!1),[P,F]=(0,Q.useState)(!1),[ce,le]=(0,Q.useState)([]),[I,R]=(0,Q.useState)(null),[ue,z]=(0,Q.useState)({}),[B,fe]=(0,Q.useState)(!1),[H,pe]=(0,Q.useState)(!1),me=(0,Q.useRef)(null),he=ae(e=>e.openTab),W=e=>{_(t=>t===e?null:e)},ge=(0,Q.useCallback)(async t=>{if(e){x(!0);try{let n=new URLSearchParams({limit:`50`,offset:`0`});t&&n.set(`q`,t);let r=await E.get(`${T(e)}/chat/sessions?${n}`);y(r.sessions),N(r.hasMore)}catch{}finally{x(!1)}}},[e]),G=(0,Q.useCallback)(async()=>{if(!(!e||P||!oe)){F(!0);try{let t=v.filter(e=>!e.pinned).length,n=new URLSearchParams({limit:`50`,offset:String(t)});k&&n.set(`q`,k);let r=await E.get(`${T(e)}/chat/sessions?${n}`);y(e=>{let t=new Set(e.map(e=>e.id)),n=r.sessions.filter(e=>!t.has(e.id));return[...e,...n]}),N(r.hasMore)}catch{}finally{F(!1)}}},[e,P,oe,v,k]);(0,Q.useEffect)(()=>{g===`history`&&v.length===0&&ge()},[g]),(0,Q.useEffect)(()=>{g===`history`&&ge(k||void 0)},[k]);let K=(0,Q.useCallback)(async()=>{if(e)try{let t=await E.get(`${T(e)}/tags`);le(t.tags),z(t.counts)}catch{}},[e]);(0,Q.useEffect)(()=>{g===`history`&&e&&K()},[g,e,K]);function q(t){l?(l(t),_(null)):he({type:`chat`,title:t.title||`Chat`,projectId:e??null,metadata:{projectName:e,sessionId:t.id,providerId:t.providerId},closable:!0})}let ve=(0,Q.useCallback)((e,t)=>{t.stopPropagation(),re(e.id),M(e.title||``),setTimeout(()=>me.current?.select(),0)},[]),be=(0,Q.useCallback)(async()=>{if(!j||!ie.trim()||!e){re(null);return}try{await E.patch(`${T(e)}/chat/sessions/${j}`,{title:ie.trim()}),y(e=>e.map(e=>e.id===j?{...e,title:ie.trim()}:e))}catch{}re(null)},[j,ie,e]),xe=(0,Q.useCallback)(()=>re(null),[]),Te=(0,Q.useCallback)(async(t,n)=>{if(t.stopPropagation(),!e)return;let r=`${T(e)}/chat/sessions/${n.id}/pin`;try{n.pinned?await E.del(r):await E.put(r),y(e=>e.map(e=>e.id===n.id?{...e,pinned:!e.pinned}:e).sort((e,t)=>e.pinned&&!t.pinned?-1:!e.pinned&&t.pinned?1:new Date(t.createdAt).getTime()-new Date(e.createdAt).getTime()))}catch{}},[e]),Y=(0,Q.useCallback)(async(t,n)=>{if(t.stopPropagation(),e&&window.confirm(`Delete this session? This cannot be undone.`))try{await E.del(`${T(e)}/chat/sessions/${n.id}?providerId=${n.providerId}`),y(e=>e.filter(e=>e.id!==n.id))}catch{}},[e]),De=(0,Q.useCallback)((e,t)=>{y(n=>n.map(n=>n.id===e?{...n,tag:t}:n)),K()},[K]),Oe=(0,Q.useCallback)(async()=>{if(!e)return;let t=window.prompt(`Delete sessions older than how many days? (pinned sessions are kept)`,`30`);if(!t)return;let n=parseInt(t,10);if(!(!n||n<1)&&window.confirm(`Delete all unpinned sessions older than ${n} days? This cannot be undone.`)){x(!0);try{await E.del(`${T(e)}/chat/sessions?olderThanDays=${n}`),ge(k||void 0)}catch{}}},[e,ge,k]);(0,Q.useEffect)(()=>{if(g!==`history`)return;let t=t=>{if(t.target instanceof HTMLInputElement||t.target instanceof HTMLTextAreaElement)return;let n=parseInt(t.key);if(n>=1&&n<=ce.length&&s){let t=ce[n-1];t&&(E.patch(`${T(e)}/chat/sessions/${s}/tag`,{tagId:t.id}).catch(()=>{}),De(s,{id:t.id,name:t.name,color:t.color}))}};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[g,ce,s,e,De]);let Ae=I===null?v:v.filter(e=>e.tag?.id===I),Me=!c||c===`claude`,X=c===`codex`,Ne=t.fiveHour==null?null:Math.round(t.fiveHour*100),Fe=t.sevenDay==null?null:Math.round(t.sevenDay*100),Ie=Ne!=null||Fe!=null?ga(Math.max(Ne??0,Fe??0)):`text-text-subtle`;return(0,$.jsxs)(`div`,{className:`border-b border-border/50`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1 px-2 py-1`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-1 overflow-x-auto scrollbar-none`,children:[(0,$.jsxs)(`button`,{onClick:()=>W(`history`),className:`shrink-0 flex items-center gap-1 px-1.5 py-0.5 rounded text-[11px] transition-colors ${g===`history`?`text-primary bg-primary/10`:`text-text-secondary hover:text-foreground hover:bg-surface-elevated`}`,children:[(0,$.jsx)(je,{className:`size-3`}),(0,$.jsx)(`span`,{children:`History`})]}),s&&c&&c!==`mock`?(0,$.jsxs)(`button`,{onClick:()=>W(`config`),className:`shrink-0 flex items-center gap-1 px-1.5 py-0.5 rounded text-[11px] transition-colors ${g===`config`?`text-primary bg-primary/10`:`text-text-secondary hover:text-foreground hover:bg-surface-elevated`}`,title:`AI Settings`,children:[(0,$.jsx)(Pe,{providerId:c}),(0,$.jsx)(`span`,{className:`capitalize`,children:c})]}):(0,$.jsx)(`button`,{onClick:()=>W(`config`),className:`shrink-0 p-1 rounded transition-colors ${g===`config`?`text-primary bg-primary/10`:`text-text-subtle hover:text-text-secondary hover:bg-surface-elevated`}`,title:`AI Settings`,children:(0,$.jsx)(V,{className:`size-3`})}),Me||X?(0,$.jsxs)(`button`,{onClick:()=>W(`usage`),className:`shrink-0 flex items-center gap-1 px-1.5 py-0.5 rounded text-[11px] font-medium tabular-nums transition-colors hover:bg-surface-elevated ${g===`usage`?`bg-primary/10`:``} ${Ie}`,title:`Usage limits`,children:[(0,$.jsx)(ct,{className:`size-3`}),t.activeAccountLabel&&(0,$.jsxs)(`span`,{className:`text-text-secondary font-normal truncate max-w-[110px]`,title:t.activeAccountLabel,children:[`[`,t.activeAccountLabel,`]`]}),(0,$.jsxs)(`span`,{children:[`5h:`,Ne==null?`--%`:`${Ne}%`]}),(0,$.jsx)(`span`,{className:`text-text-subtle`,children:`·`}),(0,$.jsxs)(`span`,{children:[`Wk:`,Fe==null?`--%`:`${Fe}%`]})]}):null,p?.hasTeams&&(0,$.jsxs)(`button`,{onClick:()=>{W(`team`),h?.()},className:`shrink-0 relative flex items-center gap-1 px-1.5 py-0.5 rounded text-[11px] transition-colors ${g===`team`?`text-primary bg-primary/10`:`text-text-secondary hover:text-foreground hover:bg-surface-elevated`}`,title:`Team activity`,children:[(0,$.jsx)(se,{className:`size-3`}),(0,$.jsx)(`span`,{children:`Team`}),(p.unreadCount??0)>0&&(0,$.jsx)(`span`,{className:`absolute -top-0.5 -right-0.5 size-2 bg-primary rounded-full animate-pulse`})]})]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1 pl-1`,children:[f&&(0,$.jsxs)(`button`,{onClick:e=>{let t=e.currentTarget.querySelector(`svg`);t&&(t.classList.add(`animate-spin`),setTimeout(()=>t.classList.remove(`animate-spin`),600)),f()},className:`relative size-4 flex items-center justify-center`,title:d?`Reload messages`:`Disconnected — click to reload`,children:[(0,$.jsx)(U,{className:`size-3 ${d?`text-muted-foreground/60`:`text-error`}`,strokeWidth:2.5}),(0,$.jsx)(`span`,{className:`absolute -top-0.5 -right-0.5 size-1.5 rounded-full ${d?`bg-success`:`bg-error animate-pulse`}`})]}),s&&(0,$.jsx)(Yi,{hasUnread:C,onToggleUnread:()=>C?ee(s):D(s,e),onOpenDebug:()=>pe(!0)})]})]}),s&&(0,$.jsx)(Ji,{sessionId:s,projectName:e,open:H,onOpenChange:pe}),g===`history`&&(0,$.jsxs)(`div`,{className:`border-t border-border/30 bg-surface`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 px-2 py-1 border-b border-border/30`,children:[(0,$.jsx)(Ce,{className:`size-3 text-text-subtle shrink-0`}),(0,$.jsx)(`input`,{type:`text`,value:O,onChange:e=>ne(e.target.value),placeholder:`Search sessions...`,className:`flex-1 bg-transparent text-[11px] text-text-primary outline-none placeholder:text-text-subtle`}),(0,$.jsx)(`button`,{onClick:Oe,className:`p-0.5 rounded text-text-subtle hover:text-error transition-colors`,title:`Delete old sessions...`,children:(0,$.jsx)(Z,{className:`size-3`})}),(0,$.jsx)(`button`,{onClick:()=>ge(k||void 0),disabled:b,className:`p-0.5 rounded text-text-subtle hover:text-text-secondary transition-colors disabled:opacity-50`,title:`Refresh`,children:(0,$.jsx)(U,{className:`size-3 ${b?`animate-spin`:``}`})})]}),ce.length>0&&(0,$.jsxs)(`div`,{className:`flex items-center gap-1 px-2 py-1 overflow-x-auto border-b border-border/30 scrollbar-none`,children:[(0,$.jsxs)(`button`,{onClick:()=>R(null),className:`shrink-0 rounded-md border px-2 py-1 text-[10px] transition-colors ${I===null?`bg-primary/20 border-primary text-primary`:`border-border bg-surface text-text-secondary`}`,children:[`All (`,v.length,`)`]}),ce.map(e=>(0,$.jsxs)(`button`,{onClick:()=>R(I===e.id?null:e.id),className:`shrink-0 flex items-center gap-1 rounded-md border px-2 py-1 text-[10px] transition-colors ${I===e.id?`border-current`:`border-border bg-surface`}`,style:I===e.id?{backgroundColor:e.color+`20`,color:e.color,borderColor:e.color}:void 0,children:[(0,$.jsx)(`span`,{className:`size-2 rounded-full shrink-0`,style:{backgroundColor:e.color}}),e.name,` (`,ue[e.id]??0,`)`]},e.id)),(0,$.jsx)(`button`,{onClick:()=>fe(!B),className:`shrink-0 p-1 rounded transition-colors ${B?`text-primary bg-primary/10`:`text-text-subtle hover:text-text-secondary`}`,title:`Manage tags`,children:(0,$.jsx)(de,{className:`size-3`})})]}),B&&(0,$.jsx)(`div`,{className:`border-b border-border/30 px-2 py-2 max-h-[180px] overflow-y-auto bg-surface-elevated/50`,children:(0,$.jsx)(_e,{projectName:e,onTagsChanged:K})}),(0,$.jsx)(`div`,{className:`max-h-[200px] overflow-y-auto`,children:b&&v.length===0?(0,$.jsx)(`div`,{className:`flex items-center justify-center py-3`,children:(0,$.jsx)(w,{className:`size-3.5 animate-spin text-text-subtle`})}):Ae.length===0?(0,$.jsx)(`div`,{className:`flex items-center justify-center py-3 text-[11px] text-text-subtle`,children:O?`No matching sessions`:`No sessions yet`}):(0,$.jsxs)($.Fragment,{children:[Ae.map(t=>{let n=S.get(t.id),r=!!n;return(0,$.jsx)(We,{session:t,projectName:e,projectTags:ce,onTogglePin:Te,onStartEditing:ve,onDeleteSession:Y,onTagChanged:De,children:(0,$.jsxs)(`div`,{className:A(`flex items-center gap-2 w-full px-3 py-1.5 text-left hover:bg-surface-elevated transition-colors group`,r&&`font-medium text-foreground`,r&&ke(n.type),!r&&`text-text-secondary`),children:[(0,$.jsx)(Pe,{providerId:t.providerId}),t.tag&&(0,$.jsx)(`span`,{className:`size-2 rounded-full shrink-0`,style:{backgroundColor:t.tag.color},title:t.tag.name}),j===t.id?(0,$.jsxs)(`form`,{className:`flex items-center gap-1 flex-1 min-w-0`,onSubmit:e=>{e.preventDefault(),be()},children:[(0,$.jsx)(`input`,{ref:me,value:ie,onChange:e=>M(e.target.value),onBlur:be,onKeyDown:e=>{e.key===`Escape`&&xe()},className:`flex-1 min-w-0 bg-surface-elevated text-[11px] text-text-primary px-1 py-0.5 rounded border border-border outline-none focus:border-primary`,autoFocus:!0}),(0,$.jsx)(`button`,{type:`submit`,className:`p-0.5 text-success hover:text-success/80`,onClick:e=>e.stopPropagation(),children:(0,$.jsx)(o,{className:`size-3`})}),(0,$.jsx)(`button`,{type:`button`,className:`p-0.5 text-text-subtle hover:text-text-secondary`,onClick:e=>{e.stopPropagation(),xe()},children:(0,$.jsx)(te,{className:`size-3`})})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`button`,{onClick:()=>q(t),className:`text-[11px] truncate flex-1 text-left flex items-center gap-1`,children:[t.title?.startsWith(`[PPM]`)&&(0,$.jsx)(i,{className:`size-3 text-muted-foreground shrink-0`}),t.title?.startsWith(`[PPM]`)?t.title.slice(7):t.title||`Untitled`]}),(0,$.jsx)(`button`,{onClick:e=>Te(e,t),className:`p-0.5 rounded transition-all ${t.pinned?`text-primary hover:text-primary/70`:`text-text-subtle hover:text-text-secondary can-hover:opacity-0 can-hover:group-hover:opacity-100`}`,title:t.pinned?`Unpin session`:`Pin session`,children:t.pinned?(0,$.jsx)(Ee,{className:`size-3`}):(0,$.jsx)(we,{className:`size-3`})}),(0,$.jsx)(`button`,{onClick:e=>ve(t,e),className:`p-0.5 rounded text-text-subtle hover:text-text-secondary can-hover:opacity-0 can-hover:group-hover:opacity-100 transition-opacity`,title:`Rename session`,children:(0,$.jsx)(J,{className:`size-3`})}),(0,$.jsx)(`button`,{onClick:e=>Y(e,t),className:`p-0.5 rounded text-text-subtle hover:text-error hover:bg-error/20 can-hover:opacity-0 can-hover:group-hover:opacity-100 transition-opacity`,title:`Delete session`,children:(0,$.jsx)(ye,{className:`size-3`})})]}),j!==t.id&&t.updatedAt&&(0,$.jsx)(`span`,{className:`text-[10px] text-text-subtle shrink-0 w-16 text-right`,children:L(t.updatedAt)})]})},t.id)}),oe&&(0,$.jsxs)(`button`,{onClick:G,disabled:P,className:`flex items-center justify-center gap-1 w-full py-1.5 text-[11px] text-text-subtle hover:text-text-secondary hover:bg-surface-elevated transition-colors`,children:[P?(0,$.jsx)(w,{className:`size-3 animate-spin`}):null,P?`Loading...`:`Load more`]})]})})]}),g===`config`&&(0,$.jsx)(`div`,{className:`border-t border-border/30 bg-surface px-3 py-2 max-h-[280px] overflow-y-auto`,children:(0,$.jsx)(rt,{compact:!0})}),g===`team`&&p?.hasTeams&&(0,$.jsx)(`div`,{className:`border-t border-border/30 bg-surface px-3 py-2`,children:(0,$.jsx)(ha,{teamNames:p.teamNames,messages:m??[],sessionId:s,projectName:e})}),g===`usage`&&Me&&(0,$.jsx)(Xi,{usage:t,visible:!0,onClose:()=>_(null),onReload:r,loading:n,lastFetchedAt:a}),g===`usage`&&X&&(0,$.jsx)(ea,{usage:t,onClose:()=>_(null)})]})}var va=3e3;function ya(e,t){let[n,r]=(0,Q.useState)(null),[i,a]=(0,Q.useState)(!0),o=(0,Q.useRef)(void 0),s=(0,Q.useRef)(t);s.current=t;let c=t??`__new__`;(0,Q.useEffect)(()=>{if(!e){a(!1);return}let t=!1;a(!0);let n=setTimeout(()=>{t||a(!1)},va);return E.get(`${T(e)}/chat/drafts/${encodeURIComponent(c)}`).then(e=>{if(!t)if(e){let t=[];try{t=JSON.parse(e.attachments)}catch{}r({content:e.content,attachments:t})}else r(null)}).catch(()=>{t||r(null)}).finally(()=>{clearTimeout(n),t||a(!1)}),()=>{t=!0,clearTimeout(n)}},[e,c]);let l=(0,Q.useCallback)((t,n)=>{e&&(o.current&&clearTimeout(o.current),o.current=setTimeout(()=>{let r=s.current??`__new__`;E.put(`${T(e)}/chat/drafts/${encodeURIComponent(r)}`,{content:t,attachments:JSON.stringify(n??[])}).catch(()=>{})},1e3))},[e]),u=(0,Q.useCallback)(()=>{if(!e)return;o.current&&clearTimeout(o.current);let t=s.current??`__new__`;E.del(`${T(e)}/chat/drafts/${encodeURIComponent(t)}`).catch(()=>{}),r(null)},[e]);return(0,Q.useEffect)(()=>()=>{o.current&&clearTimeout(o.current)},[]),{draft:n,draftLoading:i,saveDraft:l,clearDraft:u}}function ba({metadata:e,tabId:t}){let[n,r]=(0,Q.useState)(e?.sessionId??null),i=(0,Q.useCallback)(e=>{r(e)},[]),[a,o]=(0,Q.useState)(e?.providerId??`claude`),[s,c]=(0,Q.useState)([]),[l,u]=(0,Q.useState)(!1),[d,f]=(0,Q.useState)(``),[p,m]=(0,Q.useState)(null),[h,g]=(0,Q.useState)([]),[_,v]=(0,Q.useState)([]),[y,b]=(0,Q.useState)(!1),[x,S]=(0,Q.useState)(``),[C,ee]=(0,Q.useState)(null),[D,A]=(0,Q.useState)(e?.permissionMode??void 0),j=(0,Q.useRef)(null),[re,M]=(0,Q.useState)(!1),[oe,N]=(0,Q.useState)(null),[P,F]=(0,Q.useState)(null),[se,ce]=(0,Q.useState)(null),le=(0,Q.useRef)(0),I=e?.projectName??``,L=ae(e=>e.updateTab),R=k(e=>e.version),{usageInfo:ue,usageLoading:z,lastFetchedAt:B,refreshUsage:V}=Pt(I,a,n??void 0),{draft:de,draftLoading:fe,saveDraft:H,clearDraft:pe}=ya(I,n);(0,Q.useEffect)(()=>{D||Ye().then(e=>{let t=e.providers[e.default_provider??`claude`];A(t?.permission_mode??`bypassPermissions`)}).catch(()=>{})},[]),(0,Q.useEffect)(()=>{!t||!n||L(t,{metadata:{...e,sessionId:n,providerId:a,permissionMode:D}})},[n,a,D]);let{messages:U,renderedMessages:me,expandCompact:he,isCompactExpanded:W,dismissMessage:ge,clearErrors:G,messagesLoading:_e,versionMap:K,isStreaming:q,phase:ve,isReconnecting:ye,connectingElapsed:J,pendingApproval:be,contextWindowPct:xe,compactStatus:Se,statusMessage:Ce,sessionTitle:we,model:Te,setModel:Ee,effort:De,setEffort:Oe,thinking:ke,setThinking:Ae,sendMessage:je,respondToApproval:Me,cancelStreaming:X,reconnect:Ne,refetchMessages:Pe,isConnected:Z,teamActivity:Ie,teamMessages:Le,markTeamRead:Re,bashPartialOutput:ze,backgroundShells:Be,killBackgroundShell:Ve}=Mt(n,a,I,i),He=Ie?.teamNames?.[0]??``,{members:Ue}=Qr(He,!!He);(0,Q.useEffect)(()=>{if(Z&&j.current){let{content:e,permissionMode:t,images:n,imagePaths:r}=j.current;j.current=null,je(e,{permissionMode:t,...n?.length&&{images:n},...r?.length&&{imagePaths:r}})}},[Z,je]),(0,Q.useEffect)(()=>{if(!n||!t)return;let e=()=>{if(document.hidden)return;let{panels:e}=ie.getState();Object.values(e).some(e=>e.activeTabId===t)&&(Ge.getState().notifications.get(n)?.manual||Ge.getState().clearForSession(n))};e(),document.addEventListener(`visibilitychange`,e);let r=ie.subscribe(e),i=Ge.subscribe(e);return()=>{document.removeEventListener(`visibilitychange`,e),r(),i()}},[n,t]),(0,Q.useEffect)(()=>{t&&we&&L(t,{title:we})},[we]);let[We,Ke]=(0,Q.useState)(e?.pendingMessage),[qe,Je]=(0,Q.useState)(null),[Xe,Ze]=(0,Q.useState)(!1),[Qe,$e]=(0,Q.useState)(0),[et,tt]=(0,Q.useState)(!1),nt=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{nt.current&&!_e&&tt(!1),nt.current=!!_e},[_e]);let[rt,it]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{fe||it(!0)},[fe]),(0,Q.useEffect)(()=>{We&&Z&&n&&t&&L(t,{metadata:{...e,pendingMessage:void 0}})},[Z,n]),(0,Q.useEffect)(()=>{Xe&&q&&Ze(!1)},[Xe,q]),(0,Q.useEffect)(()=>{if(!Xe)return;let e=setTimeout(()=>Ze(!1),6e4);return()=>clearTimeout(e)},[Xe]);let at=(0,Q.useCallback)((e,t)=>{ae.getState().openTab({type:`chat`,title:e||`AI Chat`,metadata:{projectName:I,providerId:a,...t&&{clearedFrom:t}},projectId:I||null,closable:!0})},[I,a]),ot=(0,Q.useCallback)(e=>{Ze(!1),r(e.id),o(e.providerId),t&&L(t,{title:e.title||`Chat`}),Ge.getState().clearForSession(e.id)},[t,L]),st=(0,Q.useCallback)(async(e,t)=>{if(!(!n||!I))try{let{api:r,projectUrl:i}=await ne(async()=>{let{api:e,projectUrl:t}=await import(`./api-client-BogqsFna.js`);return{api:e,projectUrl:t}},__vite__mapDeps([49,6,1,2,30])),o=await r.post(`${i(I)}/chat/sessions/${n}/fork?providerId=${a}`,{messageId:t});ae.getState().openTab({type:`chat`,title:`Fork: ${e.slice(0,30)}`,metadata:{projectName:I,sessionId:o.id,providerId:a,pendingMessage:e},projectId:I||null,closable:!0})}catch(e){console.error(`Fork failed:`,e);let t=e?.message||`Unknown error`;O.error(`Cannot fork from this message`,{description:t.includes(`not found`)||t.includes(`Invalid upToMessageId`)?`The original message is no longer available in the session transcript. Try forking from a different message.`:t})}},[n,I,a]),ct=(0,Q.useCallback)((e,t,n)=>{Ke(e),Je({anchorMsgId:t,ownMsgId:n})},[]),lt=(0,Q.useCallback)(()=>{Je(null),Ke(void 0),Ze(!1),pe(),$e(e=>e+1)},[pe]),ut=(0,Q.useCallback)(async(i,o)=>{if(!(!i.trim()||!n||!I)){Ze(!0);try{let s=await E.post(`${T(I)}/chat/sessions/${n}/fork?providerId=${a}&mode=edit`,{messageId:o});j.current={content:i,permissionMode:D},tt(!0),t&&L(t,{metadata:{...e,sessionId:s.id}}),r(s.id)}catch(e){Ze(!1);let t=e?.message||`Unknown error`;O.error(`Cannot edit from this message`,{description:t.includes(`not found`)||t.includes(`Invalid upToMessageId`)?`The original message is no longer available in the session transcript.`:t})}}},[n,I,a,D,t,L,e]),dt=(0,Q.useCallback)(i=>{!i||i===n||(Ze(!1),tt(!0),t&&L(t,{metadata:{...e,sessionId:i}}),r(i))},[n,t,L,e]),ft=(0,Q.useCallback)((e,t,n=[])=>{if(t.length===0)return e;let r=[];for(let e of t)e.textContent&&r.push(e.textContent);let{inlineImagePaths:i,pathOnlyPaths:a}=vt(t,n);for(let e of i)r.push(`[Attached image (contents included in this message): ${e}]`);if(a.length>0){let e=a.join(`
11
- `);r.push(a.length===1?`[Attached file: ${e}]`:`[Attached files:\n${e}\n]`)}return r.length===0?e:r.join(`
12
-
13
- `)+`
14
-
15
- `+e},[]),pt=(0,Q.useCallback)(async(t,i=[],s)=>{let c=_t(i),l=ft(t,i,c),u=i.filter(e=>e.isImage&&e.serverPath).map(e=>e.serverPath);if(!(!l.trim()&&c.length===0)){if(!n)try{let n=I,i=await E.post(`${T(n)}/chat/sessions`,{providerId:a,title:t.slice(0,50),clearedFrom:e?.clearedFrom});r(i.id),o(i.providerId),j.current={content:l,permissionMode:D,images:c,imagePaths:u};return}catch(e){console.error(`Failed to create session:`,e);return}je(l,{permissionMode:D,priority:s,...c.length>0&&{images:c},...u.length>0&&{imagePaths:u}})}},[n,a,I,je,ft,D,e]),mt=(0,Q.useRef)(s);mt.current=s;let ht=(0,Q.useCallback)((e,t,r)=>{let i=e.trim().match(/^\/(\S+)(?:\s+([\s\S]+))?$/);if(i&&mt.current.find(e=>e.handler===`client`&&(e.name===i[1]||e.aliases?.includes(i[1])))?.name===`clear`){pe(),at(i[2]?.trim(),n??void 0);return}if(Ke(void 0),pe(),qe&&n&&I){let n=qe.anchorMsgId;Je(null),ut(ft(e,t),n);return}pt(e,t,r)},[pt,pe,qe,n,I,ut,ft,at]),gt=(0,Q.useRef)(U);gt.current=U;let yt=(0,Q.useCallback)(()=>gt.current.filter(e=>e.role===`user`&&e.content.trim()).map(e=>e.content),[]),bt=(0,Q.useCallback)((e,t)=>{H(e,t)},[H]),xt=(0,Q.useCallback)((e,t)=>{c(e),t&&g(t)},[]),St=(0,Q.useCallback)((e,t)=>{u(e),f(t)},[]),Ct=(0,Q.useCallback)(e=>{m(e),u(!1),f(``),setTimeout(()=>m(null),50),I&&(E.post(`${T(I)}/chat/slash-recents`,{name:e.name,type:e.type}).catch(()=>{}),g(t=>[e.name,...t.filter(t=>t!==e.name)].slice(0,5)))},[I]),wt=(0,Q.useCallback)(()=>{u(!1),f(``)},[]),Tt=(0,Q.useCallback)(()=>F(null),[]),Et=(0,Q.useCallback)(e=>{ce(e)},[]),Dt=(0,Q.useCallback)(e=>{F([e.path]),ce(null)},[]),Ot=(0,Q.useCallback)((e,t)=>{b(e),S(t)},[]),kt=(0,Q.useCallback)(e=>{ee(e),b(!1),S(``),setTimeout(()=>ee(null),50)},[]),At=(0,Q.useCallback)(()=>{b(!1),S(``)},[]);return(0,$.jsxs)(`div`,{className:`flex flex-col h-full relative`,onDragEnter:(0,Q.useCallback)(e=>{e.preventDefault(),le.current++,(e.dataTransfer.types.includes(`application/x-ppm-path`)||e.dataTransfer.types.includes(`Files`))&&M(!0)},[]),onDragLeave:(0,Q.useCallback)(e=>{e.preventDefault(),le.current--,le.current===0&&M(!1)},[]),onDragOver:(0,Q.useCallback)(e=>{e.preventDefault()},[]),onDrop:(0,Q.useCallback)(e=>{e.preventDefault(),le.current=0,M(!1);let t=e.dataTransfer.getData(`application/x-ppm-path`);if(t){F([t]);return}let n=Array.from(e.dataTransfer.files);n.length>0&&(N(n),setTimeout(()=>N(null),100))},[]),children:[re&&(0,$.jsx)(`div`,{className:`absolute inset-0 z-50 flex items-center justify-center bg-background/80 backdrop-blur-sm border-2 border-dashed border-primary rounded-lg pointer-events-none`,children:(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-2 text-primary`,children:[(0,$.jsx)(Fe,{className:`size-8`}),(0,$.jsx)(`span`,{className:`text-sm font-medium`,children:`Drop files to attach`})]})}),ye&&(0,$.jsx)(`div`,{className:`absolute inset-0 z-50 flex items-center justify-center bg-background/60 backdrop-blur-sm`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,$.jsx)(w,{className:`size-4 animate-spin`}),(0,$.jsx)(`span`,{children:`Reconnecting...`})]})}),Xe&&(0,$.jsx)(`div`,{className:`absolute inset-0 z-50 flex items-center justify-center bg-background/70 backdrop-blur-sm`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,$.jsx)(w,{className:`size-4 animate-spin`}),(0,$.jsx)(`span`,{children:`Creating edited version…`})]})}),(0,$.jsx)(Kr,{shells:Be,onKill:Ve}),(0,$.jsx)(vr,{messages:me,onExpandCompact:he,isCompactExpanded:W,messagesLoading:_e,keepStaleWhileLoading:et,pendingApproval:be,onApprovalResponse:Me,isStreaming:q,phase:ve,connectingElapsed:J,statusMessage:Ce,compactStatus:Se,projectName:I,onFork:q?void 0:st,onEdit:q?void 0:ct,editingMsgId:qe?.ownMsgId,sessionId:n??void 0,providerId:a,onNavigateVersion:dt,versionMap:K,onSelectSession:ot,onDismissMessage:ge,onClearErrors:G,bashPartialOutput:ze}),(0,$.jsx)(Xr,{teamName:He,members:Ue,projectName:I}),(0,$.jsxs)(`div`,{className:`border-t border-border bg-panel shrink-0`,children:[(0,$.jsx)(_a,{projectName:I,usageInfo:ue,usageLoading:z,refreshUsage:V,lastFetchedAt:B,sessionId:n,providerId:a,onSelectSession:ot,onBugReport:n?()=>Y(R,{sessionId:n,projectName:I}):void 0,isConnected:Z,onReload:()=>{Z||Ne(),Pe()},teamActivity:Ie,teamMessages:Le,onTeamOpen:Re}),(0,$.jsx)(Vi,{items:s,filter:d,onSelect:Ct,onClose:wt,visible:l,recentNames:h,projectName:I}),(0,$.jsx)(Hi,{items:_,filter:x,onSelect:kt,onClose:At,visible:y}),se&&(0,$.jsx)(Hi,{items:se,filter:``,onSelect:Dt,onClose:()=>ce(null),visible:!0}),qe&&(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-3 py-1.5 text-xs text-muted-foreground border-t border-border bg-muted/40`,children:[(0,$.jsx)(`span`,{children:`Editing message — your next send replaces it`}),(0,$.jsxs)(`button`,{type:`button`,onClick:lt,className:`flex items-center gap-1 rounded px-2 py-1 min-h-[28px] hover:bg-accent hover:text-accent-foreground transition-colors`,title:`Cancel edit (send as a new message instead)`,children:[(0,$.jsx)(te,{className:`h-3.5 w-3.5`}),`Cancel`]})]}),(rt||!fe)&&(0,$.jsx)(Ni,{tabId:t,onSend:ht,isStreaming:q,onCancel:X,autoFocus:!e?.sessionId||!!We,initialValue:We??de?.content,clearSignal:Qe,projectName:I,onSlashStateChange:St,onSlashItemsLoaded:xt,slashSelected:p,onFileStateChange:Ot,onFileItemsLoaded:v,fileSelected:C,externalFiles:oe,externalPaths:P,onExternalPathsConsumed:Tt,onDisambiguate:Et,onContentChange:bt,getUserHistory:yt,permissionMode:D,onModeChange:A,providerId:a,sessionId:n??void 0,onProviderChange:n?void 0:o,model:Te,onModelChange:Ee,effort:De,onEffortChange:Oe,thinking:ke,onThinkingChange:Ae})]})]})}export{ba as ChatTab};