@hienlh/ppm 0.25.7 → 0.25.8

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 (649) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/CLAUDE.md +2 -0
  3. package/assets/skills/ppm/SKILL.md +1 -1
  4. package/assets/skills/ppm/references/cli-reference.md +1 -0
  5. package/assets/skills/ppm/references/http-api.md +1 -1
  6. package/dist/web/assets/{accounts-settings-section-Dj-tqgLP.js → accounts-settings-section-CJpMzwRN.js} +1 -1
  7. package/dist/web/assets/accounts-settings-section-CJpMzwRN.js.br +0 -0
  8. package/dist/web/assets/accounts-settings-section-CJpMzwRN.js.gz +0 -0
  9. package/dist/web/assets/{agent-session-sheet-ES6BGGHr.js → agent-session-sheet-FInwTnf_.js} +2 -2
  10. package/dist/web/assets/agent-session-sheet-FInwTnf_.js.br +0 -0
  11. package/dist/web/assets/agent-session-sheet-FInwTnf_.js.gz +0 -0
  12. package/dist/web/assets/{agent-session-window-content-D1Qz_Jtj.js → agent-session-window-content-Ct6ZHTtp.js} +1 -1
  13. package/dist/web/assets/agent-session-window-content-Ct6ZHTtp.js.br +0 -0
  14. package/dist/web/assets/agent-session-window-content-Ct6ZHTtp.js.gz +0 -0
  15. package/dist/web/assets/{ai-resource-editor-C1xHoS9l.js → ai-resource-editor-CNhRBVzA.js} +1 -1
  16. package/dist/web/assets/ai-resource-editor-CNhRBVzA.js.br +0 -0
  17. package/dist/web/assets/ai-resource-editor-CNhRBVzA.js.gz +0 -0
  18. package/dist/web/assets/{ai-settings-section-B2s5uYmr.js → ai-settings-section-BGocvC5p.js} +1 -1
  19. package/dist/web/assets/ai-settings-section-BGocvC5p.js.br +0 -0
  20. package/dist/web/assets/ai-settings-section-BGocvC5p.js.gz +0 -0
  21. package/dist/web/assets/{ai-settings-section-D0LobmFN.js → ai-settings-section-BuEmNuZv.js} +1 -1
  22. package/dist/web/assets/ai-settings-section-BuEmNuZv.js.br +0 -0
  23. package/dist/web/assets/ai-settings-section-BuEmNuZv.js.gz +0 -0
  24. package/dist/web/assets/{android-tab-JEd1TSF7.js → android-tab-BbqO4tTg.js} +1 -1
  25. package/dist/web/assets/android-tab-BbqO4tTg.js.br +0 -0
  26. package/dist/web/assets/android-tab-BbqO4tTg.js.gz +0 -0
  27. package/dist/web/assets/{antigravity-usage-view-CCOvhebf.js → antigravity-usage-view-BBxDn7OP.js} +1 -1
  28. package/dist/web/assets/antigravity-usage-view-BBxDn7OP.js.br +0 -0
  29. package/dist/web/assets/antigravity-usage-view-BBxDn7OP.js.gz +0 -0
  30. package/dist/web/assets/{appearance-settings-section-DO6hc-od.js → appearance-settings-section-CAh8nPhs.js} +1 -1
  31. package/dist/web/assets/appearance-settings-section-CAh8nPhs.js.br +0 -0
  32. package/dist/web/assets/appearance-settings-section-CAh8nPhs.js.gz +0 -0
  33. package/dist/web/assets/{apps-panel-DcTJU6vR.js → apps-panel-Dof7DwAj.js} +1 -1
  34. package/dist/web/assets/apps-panel-Dof7DwAj.js.br +0 -0
  35. package/dist/web/assets/apps-panel-Dof7DwAj.js.gz +0 -0
  36. package/dist/web/assets/{assistant-name-store-DunABllt.js → assistant-name-store-D5teXZ9K.js} +1 -1
  37. package/dist/web/assets/assistant-name-store-D5teXZ9K.js.br +0 -0
  38. package/dist/web/assets/assistant-name-store-D5teXZ9K.js.gz +0 -0
  39. package/dist/web/assets/assistant-settings-BvOjO9ir.js +1 -0
  40. package/dist/web/assets/assistant-settings-BvOjO9ir.js.br +0 -0
  41. package/dist/web/assets/assistant-settings-BvOjO9ir.js.gz +0 -0
  42. package/dist/web/assets/{assistant-settings-section-B2Ku9p0H.js → assistant-settings-section-DDFHPVIR.js} +2 -2
  43. package/dist/web/assets/assistant-settings-section-DDFHPVIR.js.br +0 -0
  44. package/dist/web/assets/assistant-settings-section-DDFHPVIR.js.gz +0 -0
  45. package/dist/web/assets/{assistant-tab-C7PHbtlQ.js → assistant-tab-CFDxGZDa.js} +1 -1
  46. package/dist/web/assets/assistant-tab-CFDxGZDa.js.br +0 -0
  47. package/dist/web/assets/assistant-tab-CFDxGZDa.js.gz +0 -0
  48. package/dist/web/assets/{background-output-store-D2KAitP3.js → background-output-store-CYu95pMo.js} +1 -1
  49. package/dist/web/assets/background-output-store-CYu95pMo.js.br +0 -0
  50. package/dist/web/assets/background-output-store-CYu95pMo.js.gz +0 -0
  51. package/dist/web/assets/{branch-review-tab-BTkWVfIx.js → branch-review-tab-DmD06w26.js} +1 -1
  52. package/dist/web/assets/branch-review-tab-DmD06w26.js.br +0 -0
  53. package/dist/web/assets/branch-review-tab-DmD06w26.js.gz +0 -0
  54. package/dist/web/assets/{build-message-with-attachments-CRWLGa4Y.js → build-message-with-attachments-CaOUFGji.js} +1 -1
  55. package/dist/web/assets/build-message-with-attachments-CaOUFGji.js.br +0 -0
  56. package/dist/web/assets/build-message-with-attachments-CaOUFGji.js.gz +0 -0
  57. package/dist/web/assets/{chat-tab-edXhE4lm.js → chat-tab-BfB-YkvJ.js} +3 -3
  58. package/dist/web/assets/chat-tab-BfB-YkvJ.js.br +0 -0
  59. package/dist/web/assets/chat-tab-BfB-YkvJ.js.gz +0 -0
  60. package/dist/web/assets/chat-tab-Cy8oEjQj.js +1 -0
  61. package/dist/web/assets/chat-tab-Cy8oEjQj.js.br +0 -0
  62. package/dist/web/assets/chat-tab-Cy8oEjQj.js.gz +0 -0
  63. package/dist/web/assets/{close-window-C-DU_r5Y.js → close-window-xumIsJ3C.js} +1 -1
  64. package/dist/web/assets/{code-editor-B1hoVvoe.js → code-editor-wq1uUv3e.js} +4 -4
  65. package/dist/web/assets/code-editor-wq1uUv3e.js.br +0 -0
  66. package/dist/web/assets/code-editor-wq1uUv3e.js.gz +0 -0
  67. package/dist/web/assets/{conflict-editor-CiGF-H8E.js → conflict-editor-3dvOYhsg.js} +1 -1
  68. package/dist/web/assets/conflict-editor-3dvOYhsg.js.br +0 -0
  69. package/dist/web/assets/conflict-editor-3dvOYhsg.js.gz +0 -0
  70. package/dist/web/assets/{connection-form-tab-DfrYYyqN.js → connection-form-tab--411MxSo.js} +1 -1
  71. package/dist/web/assets/connection-form-tab--411MxSo.js.br +0 -0
  72. package/dist/web/assets/connection-form-tab--411MxSo.js.gz +0 -0
  73. package/dist/web/assets/{csv-preview-PhPn1H22.js → csv-preview-B8kSkU3R.js} +1 -1
  74. package/dist/web/assets/csv-preview-B8kSkU3R.js.br +0 -0
  75. package/dist/web/assets/{csv-preview-PhPn1H22.js.gz → csv-preview-B8kSkU3R.js.gz} +0 -0
  76. package/dist/web/assets/{database-drivers-section-C2iSgtsK.js → database-drivers-section-BRIzMorf.js} +1 -1
  77. package/dist/web/assets/database-drivers-section-BRIzMorf.js.br +0 -0
  78. package/dist/web/assets/database-drivers-section-BRIzMorf.js.gz +0 -0
  79. package/dist/web/assets/{db-connection-config-FJf8q_kG.js → db-connection-config-sCgRWO6g.js} +1 -1
  80. package/dist/web/assets/db-connection-config-sCgRWO6g.js.br +0 -0
  81. package/dist/web/assets/db-connection-config-sCgRWO6g.js.gz +0 -0
  82. package/dist/web/assets/{db-explorer-store-DiyDlsSd.js → db-explorer-store-DIVU5YE1.js} +1 -1
  83. package/dist/web/assets/db-explorer-store-DIVU5YE1.js.br +0 -0
  84. package/dist/web/assets/db-explorer-store-DIVU5YE1.js.gz +0 -0
  85. package/dist/web/assets/{db-tab-parts-CFvFJKsW.js → db-tab-parts-Db6dNGCV.js} +1 -1
  86. package/dist/web/assets/db-tab-parts-Db6dNGCV.js.br +0 -0
  87. package/dist/web/assets/db-tab-parts-Db6dNGCV.js.gz +0 -0
  88. package/dist/web/assets/{design-settings-section-C3rGRKd9.js → design-settings-section-DTWDBysp.js} +1 -1
  89. package/dist/web/assets/design-settings-section-DTWDBysp.js.br +0 -0
  90. package/dist/web/assets/design-settings-section-DTWDBysp.js.gz +0 -0
  91. package/dist/web/assets/{design-tab-CujDONDO.js → design-tab-DzFFWqgU.js} +1 -1
  92. package/dist/web/assets/design-tab-DzFFWqgU.js.br +0 -0
  93. package/dist/web/assets/design-tab-DzFFWqgU.js.gz +0 -0
  94. package/dist/web/assets/{designs-sidebar-panel-BmzMD8PY.js → designs-sidebar-panel-MPtHF-kA.js} +1 -1
  95. package/dist/web/assets/designs-sidebar-panel-MPtHF-kA.js.br +0 -0
  96. package/dist/web/assets/designs-sidebar-panel-MPtHF-kA.js.gz +0 -0
  97. package/dist/web/assets/{diff-viewer-BradW_q7.js → diff-viewer-6H5Jl2t8.js} +1 -1
  98. package/dist/web/assets/diff-viewer-6H5Jl2t8.js.br +0 -0
  99. package/dist/web/assets/diff-viewer-6H5Jl2t8.js.gz +0 -0
  100. package/dist/web/assets/{docx-preview-CrfPGFGk.js → docx-preview-Bhk0VwBH.js} +1 -1
  101. package/dist/web/assets/docx-preview-Bhk0VwBH.js.br +0 -0
  102. package/dist/web/assets/docx-preview-Bhk0VwBH.js.gz +0 -0
  103. package/dist/web/assets/{editor-dialog-CIIhsxqp.js → editor-dialog-C3yeHsGp.js} +1 -1
  104. package/dist/web/assets/editor-dialog-C3yeHsGp.js.br +0 -0
  105. package/dist/web/assets/editor-dialog-C3yeHsGp.js.gz +0 -0
  106. package/dist/web/assets/{editor-language-service-stDe-8Hh.js → editor-language-service-BKV35pp_.js} +1 -1
  107. package/dist/web/assets/editor-language-service-BKV35pp_.js.br +0 -0
  108. package/dist/web/assets/editor-language-service-BKV35pp_.js.gz +0 -0
  109. package/dist/web/assets/{explorer-body-DslJEPu8.js → explorer-body-CX65jdUB.js} +1 -1
  110. package/dist/web/assets/explorer-body-CX65jdUB.js.br +0 -0
  111. package/dist/web/assets/explorer-body-CX65jdUB.js.gz +0 -0
  112. package/dist/web/assets/{explorer-model-Daztib0H.js → explorer-model-CHQNPtY-.js} +1 -1
  113. package/dist/web/assets/explorer-model-CHQNPtY-.js.br +0 -0
  114. package/dist/web/assets/explorer-model-CHQNPtY-.js.gz +0 -0
  115. package/dist/web/assets/{explorer-window-content-Cujhxewh.js → explorer-window-content-DSY92TDq.js} +1 -1
  116. package/dist/web/assets/explorer-window-content-DSY92TDq.js.br +0 -0
  117. package/dist/web/assets/explorer-window-content-DSY92TDq.js.gz +0 -0
  118. package/dist/web/assets/{extension-manager-section-DVYKtRbp.js → extension-manager-section-BipKy2Rw.js} +1 -1
  119. package/dist/web/assets/extension-manager-section-BipKy2Rw.js.br +0 -0
  120. package/dist/web/assets/extension-manager-section-BipKy2Rw.js.gz +0 -0
  121. package/dist/web/assets/{extension-webview-CYKu8RhB.js → extension-webview-DFWHAUUH.js} +1 -1
  122. package/dist/web/assets/extension-webview-DFWHAUUH.js.br +0 -0
  123. package/dist/web/assets/extension-webview-DFWHAUUH.js.gz +0 -0
  124. package/dist/web/assets/{files-settings-section-DQn2QDq8.js → files-settings-section-BDrlGgwW.js} +1 -1
  125. package/dist/web/assets/files-settings-section-BDrlGgwW.js.br +0 -0
  126. package/dist/web/assets/files-settings-section-BDrlGgwW.js.gz +0 -0
  127. package/dist/web/assets/{general-settings-section-CnZIAqkr.js → general-settings-section-CHVQSPfM.js} +1 -1
  128. package/dist/web/assets/general-settings-section-CHVQSPfM.js.br +0 -0
  129. package/dist/web/assets/general-settings-section-CHVQSPfM.js.gz +0 -0
  130. package/dist/web/assets/{git-log-panel-C91xwW-U.js → git-log-panel-1v7JOQMr.js} +1 -1
  131. package/dist/web/assets/git-log-panel-1v7JOQMr.js.br +0 -0
  132. package/dist/web/assets/git-log-panel-1v7JOQMr.js.gz +0 -0
  133. package/dist/web/assets/{git-review-tab-WpaSXeje.js → git-review-tab-DwB7zqOw.js} +1 -1
  134. package/dist/web/assets/git-review-tab-DwB7zqOw.js.br +0 -0
  135. package/dist/web/assets/git-review-tab-DwB7zqOw.js.gz +0 -0
  136. package/dist/web/assets/{glide-data-grid-sts6YE2c.js → glide-data-grid-CL9ERRkH.js} +1 -1
  137. package/dist/web/assets/glide-data-grid-CL9ERRkH.js.br +0 -0
  138. package/dist/web/assets/glide-data-grid-CL9ERRkH.js.gz +0 -0
  139. package/dist/web/assets/{grid-save-dialog-jjma4-nR.js → grid-save-dialog-CK2kug73.js} +1 -1
  140. package/dist/web/assets/grid-save-dialog-CK2kug73.js.br +0 -0
  141. package/dist/web/assets/grid-save-dialog-CK2kug73.js.gz +0 -0
  142. package/dist/web/assets/{group-chat-tab-ze6sWOA9.js → group-chat-tab-CRtOsmm6.js} +1 -1
  143. package/dist/web/assets/group-chat-tab-CRtOsmm6.js.br +0 -0
  144. package/dist/web/assets/group-chat-tab-CRtOsmm6.js.gz +0 -0
  145. package/dist/web/assets/{impexp-tab-ClR7MjKN.js → impexp-tab-D7iyg3Xr.js} +1 -1
  146. package/dist/web/assets/impexp-tab-D7iyg3Xr.js.br +0 -0
  147. package/dist/web/assets/impexp-tab-D7iyg3Xr.js.gz +0 -0
  148. package/dist/web/assets/{index-DdWNTpRC.js → index-rFeA9cN0.js} +6 -6
  149. package/dist/web/assets/index-rFeA9cN0.js.br +0 -0
  150. package/dist/web/assets/index-rFeA9cN0.js.gz +0 -0
  151. package/dist/web/assets/{jira-watcher-section-CfNmK06d.js → jira-watcher-section-BoYMt11_.js} +1 -1
  152. package/dist/web/assets/{keyboard-shortcuts-section-DQq6Hr5R.js → keyboard-shortcuts-section-BDTcp2Mp.js} +1 -1
  153. package/dist/web/assets/keyboard-shortcuts-section-BDTcp2Mp.js.br +0 -0
  154. package/dist/web/assets/keyboard-shortcuts-section-BDTcp2Mp.js.gz +0 -0
  155. package/dist/web/assets/{language-servers-section-B8DlpKwG.js → language-servers-section-D4ohb6fF.js} +2 -2
  156. package/dist/web/assets/language-servers-section-D4ohb6fF.js.br +0 -0
  157. package/dist/web/assets/language-servers-section-D4ohb6fF.js.gz +0 -0
  158. package/dist/web/assets/{logs-app-BSb7y8Ub.js → logs-app-DTLXuUwz.js} +1 -1
  159. package/dist/web/assets/logs-app-DTLXuUwz.js.br +0 -0
  160. package/dist/web/assets/logs-app-DTLXuUwz.js.gz +0 -0
  161. package/dist/web/assets/logs-tab-CBPgD74S.js +1 -0
  162. package/dist/web/assets/{logs-window-content-9Ntbw6Pa.js → logs-window-content-BQg5LdB4.js} +1 -1
  163. package/dist/web/assets/{lsp-client-BcS52GK3.js → lsp-client-DbxW8RE8.js} +1 -1
  164. package/dist/web/assets/lsp-client-DbxW8RE8.js.br +0 -0
  165. package/dist/web/assets/lsp-client-DbxW8RE8.js.gz +0 -0
  166. package/dist/web/assets/markdown-renderer-BLotknvo.js +1 -0
  167. package/dist/web/assets/markdown-renderer-BLotknvo.js.br +0 -0
  168. package/dist/web/assets/markdown-renderer-BLotknvo.js.gz +0 -0
  169. package/dist/web/assets/{markdown-renderer-DyR-2m0n.js → markdown-renderer-EpZgAvPW.js} +1 -1
  170. package/dist/web/assets/markdown-renderer-EpZgAvPW.js.br +0 -0
  171. package/dist/web/assets/markdown-renderer-EpZgAvPW.js.gz +0 -0
  172. package/dist/web/assets/{mobile-explorer-sheet-CDkiK9ss.js → mobile-explorer-sheet-2gso3b7e.js} +1 -1
  173. package/dist/web/assets/mobile-explorer-sheet-2gso3b7e.js.br +0 -0
  174. package/dist/web/assets/mobile-explorer-sheet-2gso3b7e.js.gz +0 -0
  175. package/dist/web/assets/{model-thinking-selector-helpers-B9R_GCmG.js → model-thinking-selector-helpers-BR5Y_oCs.js} +1 -1
  176. package/dist/web/assets/model-thinking-selector-helpers-BR5Y_oCs.js.br +0 -0
  177. package/dist/web/assets/model-thinking-selector-helpers-BR5Y_oCs.js.gz +0 -0
  178. package/dist/web/assets/{new-design-dialog-CEheObfH.js → new-design-dialog-Djulr0aD.js} +1 -1
  179. package/dist/web/assets/new-design-dialog-Djulr0aD.js.br +0 -0
  180. package/dist/web/assets/new-design-dialog-Djulr0aD.js.gz +0 -0
  181. package/dist/web/assets/{notifications-settings-section--wueiusr.js → notifications-settings-section-C5VPaRfs.js} +1 -1
  182. package/dist/web/assets/notifications-settings-section-C5VPaRfs.js.br +0 -0
  183. package/dist/web/assets/notifications-settings-section-C5VPaRfs.js.gz +0 -0
  184. package/dist/web/assets/{onboarding-entry-BnyHu8g-.js → onboarding-entry-B6iyOCP1.js} +1 -1
  185. package/dist/web/assets/onboarding-entry-B6iyOCP1.js.br +0 -0
  186. package/dist/web/assets/onboarding-entry-B6iyOCP1.js.gz +0 -0
  187. package/dist/web/assets/{open-assistant-CIClEfBP.js → open-assistant-B3VjLarr.js} +1 -1
  188. package/dist/web/assets/open-assistant-B3VjLarr.js.br +0 -0
  189. package/dist/web/assets/open-assistant-B3VjLarr.js.gz +0 -0
  190. package/dist/web/assets/open-assistant-DVw1LOlL.js +1 -0
  191. package/dist/web/assets/{open-db-tabs-hq8ISs9i.js → open-db-tabs-CZCVwLtY.js} +1 -1
  192. package/dist/web/assets/open-db-tabs-CZCVwLtY.js.br +0 -0
  193. package/dist/web/assets/open-db-tabs-CZCVwLtY.js.gz +0 -0
  194. package/dist/web/assets/{open-logs-CrdQYlxl.js → open-logs-B8h-9fK0.js} +1 -1
  195. package/dist/web/assets/{open-manager-chat-Bq9rYZkX.js → open-manager-chat-AREyrwCV.js} +1 -1
  196. package/dist/web/assets/open-manager-chat-AREyrwCV.js.br +0 -0
  197. package/dist/web/assets/open-manager-chat-AREyrwCV.js.gz +0 -0
  198. package/dist/web/assets/open-manager-chat-BDcdRhCP.js +1 -0
  199. package/dist/web/assets/{open-ppm-tab-8o5Mp2VL.js → open-ppm-tab-Ycg95vdE.js} +1 -1
  200. package/dist/web/assets/open-ppm-tab-Ycg95vdE.js.br +0 -0
  201. package/dist/web/assets/open-ppm-tab-Ycg95vdE.js.gz +0 -0
  202. package/dist/web/assets/{open-settings-CO64bJ_7.js → open-settings-BJGUPvOw.js} +1 -1
  203. package/dist/web/assets/{open-settings-DnGfgkEL.js → open-settings-kdMfXpHq.js} +1 -1
  204. package/dist/web/assets/{panel-store-BVDYuCvt.js → panel-store-CBSQTnq9.js} +1 -1
  205. package/dist/web/assets/panel-store-CBSQTnq9.js.br +0 -0
  206. package/dist/web/assets/panel-store-CBSQTnq9.js.gz +0 -0
  207. package/dist/web/assets/{patch-tab-metadata-DrKrCjLH.js → patch-tab-metadata-jquPSDfD.js} +1 -1
  208. package/dist/web/assets/{performance-panel-CKT9071S.js → performance-panel-vtfFrYmB.js} +1 -1
  209. package/dist/web/assets/performance-panel-vtfFrYmB.js.br +0 -0
  210. package/dist/web/assets/performance-panel-vtfFrYmB.js.gz +0 -0
  211. package/dist/web/assets/{problems-panel-3DmEaBKD.js → problems-panel-ty4WAeub.js} +1 -1
  212. package/dist/web/assets/problems-panel-ty4WAeub.js.br +0 -0
  213. package/dist/web/assets/problems-panel-ty4WAeub.js.gz +0 -0
  214. package/dist/web/assets/{process-table-CJAoXA5W.js → process-table-Dk-9ohXl.js} +1 -1
  215. package/dist/web/assets/process-table-Dk-9ohXl.js.br +0 -0
  216. package/dist/web/assets/process-table-Dk-9ohXl.js.gz +0 -0
  217. package/dist/web/assets/{proxy-settings-section-2l86_w2k.js → proxy-settings-section-CpmKuU96.js} +1 -1
  218. package/dist/web/assets/proxy-settings-section-CpmKuU96.js.br +0 -0
  219. package/dist/web/assets/proxy-settings-section-CpmKuU96.js.gz +0 -0
  220. package/dist/web/assets/{query-tab-B94Pr_zx.js → query-tab-BRkozohy.js} +1 -1
  221. package/dist/web/assets/query-tab-BRkozohy.js.br +0 -0
  222. package/dist/web/assets/query-tab-BRkozohy.js.gz +0 -0
  223. package/dist/web/assets/release-notes-window-content-D4jEU3wD.js +1 -0
  224. package/dist/web/assets/{remote-access-settings-section-a8AImvR6.js → remote-access-settings-section-C40hJCpz.js} +1 -1
  225. package/dist/web/assets/remote-access-settings-section-C40hJCpz.js.br +0 -0
  226. package/dist/web/assets/remote-access-settings-section-C40hJCpz.js.gz +0 -0
  227. package/dist/web/assets/{remote-access-tab-store-BZ6vf17_.js → remote-access-tab-store-DxDHebNj.js} +1 -1
  228. package/dist/web/assets/{remote-desktop-clipboard-notice-DFn1nxw8.js → remote-desktop-clipboard-notice-DBKfzIao.js} +1 -1
  229. package/dist/web/assets/remote-desktop-clipboard-notice-DBKfzIao.js.br +0 -0
  230. package/dist/web/assets/remote-desktop-clipboard-notice-DBKfzIao.js.gz +0 -0
  231. package/dist/web/assets/{remote-desktop-mobile-sheet-BWS190GJ.js → remote-desktop-mobile-sheet-DH12hzq0.js} +2 -2
  232. package/dist/web/assets/remote-desktop-mobile-sheet-DH12hzq0.js.br +0 -0
  233. package/dist/web/assets/remote-desktop-mobile-sheet-DH12hzq0.js.gz +0 -0
  234. package/dist/web/assets/{remote-desktop-mobile-view-Byw7sIXV.js → remote-desktop-mobile-view-G7lonBBK.js} +1 -1
  235. package/dist/web/assets/remote-desktop-mobile-view-G7lonBBK.js.br +0 -0
  236. package/dist/web/assets/remote-desktop-mobile-view-G7lonBBK.js.gz +0 -0
  237. package/dist/web/assets/{remote-desktop-readiness-gate-CNw85fJW.js → remote-desktop-readiness-gate-CEnwbi9-.js} +1 -1
  238. package/dist/web/assets/remote-desktop-readiness-gate-CEnwbi9-.js.br +0 -0
  239. package/dist/web/assets/remote-desktop-readiness-gate-CEnwbi9-.js.gz +0 -0
  240. package/dist/web/assets/{remote-desktop-window-content-D-hkqiGt.js → remote-desktop-window-content-DRoq0Doz.js} +1 -1
  241. package/dist/web/assets/remote-desktop-window-content-DRoq0Doz.js.br +0 -0
  242. package/dist/web/assets/remote-desktop-window-content-DRoq0Doz.js.gz +0 -0
  243. package/dist/web/assets/{rename-object-dialog-DMjr26AG.js → rename-object-dialog-B4_M7kq7.js} +1 -1
  244. package/dist/web/assets/rename-object-dialog-B4_M7kq7.js.br +0 -0
  245. package/dist/web/assets/rename-object-dialog-B4_M7kq7.js.gz +0 -0
  246. package/dist/web/assets/{review-address-setup-CjN4yI9s.js → review-address-setup-Dr0-k8Ii.js} +1 -1
  247. package/dist/web/assets/review-address-setup-Dr0-k8Ii.js.br +0 -0
  248. package/dist/web/assets/review-address-setup-Dr0-k8Ii.js.gz +0 -0
  249. package/dist/web/assets/{review-code-BPChqugN.js → review-code-BiqpKBwR.js} +1 -1
  250. package/dist/web/assets/review-code-BiqpKBwR.js.br +0 -0
  251. package/dist/web/assets/review-code-BiqpKBwR.js.gz +0 -0
  252. package/dist/web/assets/{run-in-terminal-button-CtLSkimO.js → run-in-terminal-button-BFs3ncra.js} +1 -1
  253. package/dist/web/assets/{run-in-terminal-D2tpbSVS.js → run-in-terminal-sraD6sWh.js} +1 -1
  254. package/dist/web/assets/{save-as-dialog-DZabqzFG.js → save-as-dialog-DNBlWN4R.js} +1 -1
  255. package/dist/web/assets/save-as-dialog-DNBlWN4R.js.br +0 -0
  256. package/dist/web/assets/save-as-dialog-DNBlWN4R.js.gz +0 -0
  257. package/dist/web/assets/{schedule-script-editor-CmbffDN5.js → schedule-script-editor-JYIGILyl.js} +1 -1
  258. package/dist/web/assets/schedule-script-editor-JYIGILyl.js.br +0 -0
  259. package/dist/web/assets/schedule-script-editor-JYIGILyl.js.gz +0 -0
  260. package/dist/web/assets/{schedules-settings-section-C9buhsq2.js → schedules-settings-section-BqKUZ8se.js} +3 -3
  261. package/dist/web/assets/schedules-settings-section-BqKUZ8se.js.br +0 -0
  262. package/dist/web/assets/schedules-settings-section-BqKUZ8se.js.gz +0 -0
  263. package/dist/web/assets/{send-to-chat-oE-JUerN.js → send-to-chat-bbnVuPiz.js} +1 -1
  264. package/dist/web/assets/send-to-chat-bbnVuPiz.js.br +0 -0
  265. package/dist/web/assets/send-to-chat-bbnVuPiz.js.gz +0 -0
  266. package/dist/web/assets/{session-changes-chip-BieRAjqg.js → session-changes-chip-DfOeZz3v.js} +1 -1
  267. package/dist/web/assets/session-changes-chip-DfOeZz3v.js.br +0 -0
  268. package/dist/web/assets/session-changes-chip-DfOeZz3v.js.gz +0 -0
  269. package/dist/web/assets/{session-collab-client-DU-Iuwkh.js → session-collab-client-DOUeHjr_.js} +2 -2
  270. package/dist/web/assets/session-collab-client-DOUeHjr_.js.br +0 -0
  271. package/dist/web/assets/session-collab-client-DOUeHjr_.js.gz +0 -0
  272. package/dist/web/assets/{session-review-tab-Du1h3fb7.js → session-review-tab-BZ3jPhrf.js} +1 -1
  273. package/dist/web/assets/session-review-tab-BZ3jPhrf.js.br +0 -0
  274. package/dist/web/assets/session-review-tab-BZ3jPhrf.js.gz +0 -0
  275. package/dist/web/assets/{session-turns-Brf8WhTP.js → session-turns-Bl6ccivQ.js} +1 -1
  276. package/dist/web/assets/session-turns-Bl6ccivQ.js.br +0 -0
  277. package/dist/web/assets/session-turns-Bl6ccivQ.js.gz +0 -0
  278. package/dist/web/assets/{settings-body-CSXclIUd.js → settings-body-OVphMQRm.js} +1 -1
  279. package/dist/web/assets/settings-body-OVphMQRm.js.br +0 -0
  280. package/dist/web/assets/settings-body-OVphMQRm.js.gz +0 -0
  281. package/dist/web/assets/{settings-rows-Db0TK6_7.js → settings-rows-BqVoWUah.js} +1 -1
  282. package/dist/web/assets/settings-rows-BqVoWUah.js.br +0 -0
  283. package/dist/web/assets/settings-rows-BqVoWUah.js.gz +0 -0
  284. package/dist/web/assets/{settings-section-content-DIPL9pgs.js → settings-section-content-BOGhX0Gc.js} +2 -2
  285. package/dist/web/assets/settings-section-content-BOGhX0Gc.js.br +0 -0
  286. package/dist/web/assets/settings-section-content-BOGhX0Gc.js.gz +0 -0
  287. package/dist/web/assets/{settings-section-content-B2x1KNB9.js → settings-section-content-Dv75IMdD.js} +1 -1
  288. package/dist/web/assets/settings-store-DbEIO8Ou.js +45 -0
  289. package/dist/web/assets/settings-store-DbEIO8Ou.js.br +0 -0
  290. package/dist/web/assets/settings-store-DbEIO8Ou.js.gz +0 -0
  291. package/dist/web/assets/{settings-tab-Br5JjR6T.js → settings-tab-omkNFzAB.js} +1 -1
  292. package/dist/web/assets/{settings-window-content-Na7uO5UI.js → settings-window-content-CmNMpFk1.js} +1 -1
  293. package/dist/web/assets/{sql-object-tab-CVOIYxsK.js → sql-object-tab-DnZb8XeX.js} +1 -1
  294. package/dist/web/assets/sql-object-tab-DnZb8XeX.js.br +0 -0
  295. package/dist/web/assets/sql-object-tab-DnZb8XeX.js.gz +0 -0
  296. package/dist/web/assets/{sqlite-viewer-gYzT8mK_.js → sqlite-viewer-C_LN_liu.js} +1 -1
  297. package/dist/web/assets/sqlite-viewer-C_LN_liu.js.br +0 -0
  298. package/dist/web/assets/sqlite-viewer-C_LN_liu.js.gz +0 -0
  299. package/dist/web/assets/{storage-settings-section-kLoWvAiE.js → storage-settings-section-DjVmPPsq.js} +1 -1
  300. package/dist/web/assets/storage-settings-section-DjVmPPsq.js.br +0 -0
  301. package/dist/web/assets/storage-settings-section-DjVmPPsq.js.gz +0 -0
  302. package/dist/web/assets/{structure-save-dialog-DKX27TZj.js → structure-save-dialog-CPihivr8.js} +1 -1
  303. package/dist/web/assets/structure-save-dialog-CPihivr8.js.br +0 -0
  304. package/dist/web/assets/structure-save-dialog-CPihivr8.js.gz +0 -0
  305. package/dist/web/assets/{structure-tab-B7nUzq1k.js → structure-tab-TiVBWIsX.js} +1 -1
  306. package/dist/web/assets/structure-tab-TiVBWIsX.js.br +0 -0
  307. package/dist/web/assets/structure-tab-TiVBWIsX.js.gz +0 -0
  308. package/dist/web/assets/{system-monitor-body-ISqdObYR.js → system-monitor-body-CXOMCVD1.js} +2 -2
  309. package/dist/web/assets/system-monitor-body-CXOMCVD1.js.br +0 -0
  310. package/dist/web/assets/system-monitor-body-CXOMCVD1.js.gz +0 -0
  311. package/dist/web/assets/system-monitor-tab-C8pbRhyF.js +1 -0
  312. package/dist/web/assets/{system-monitor-window-content-C-o618OT.js → system-monitor-window-content-BfcvuXt-.js} +1 -1
  313. package/dist/web/assets/{tab-host-window-content-DruWYAe4.js → tab-host-window-content-C3z9ouJg.js} +1 -1
  314. package/dist/web/assets/tab-host-window-content-C3z9ouJg.js.br +0 -0
  315. package/dist/web/assets/tab-host-window-content-C3z9ouJg.js.gz +0 -0
  316. package/dist/web/assets/{tab-store-DrKCCcn0.js → tab-store-CiT16Eol.js} +1 -1
  317. package/dist/web/assets/{table-tab-Dfdj2oUR.js → table-tab-IgNEY_LZ.js} +1 -1
  318. package/dist/web/assets/table-tab-IgNEY_LZ.js.br +0 -0
  319. package/dist/web/assets/table-tab-IgNEY_LZ.js.gz +0 -0
  320. package/dist/web/assets/{telegram-bot-token-field-DAlWvisV.js → telegram-bot-token-field-BibezKpI.js} +1 -1
  321. package/dist/web/assets/telegram-bot-token-field-BibezKpI.js.br +0 -0
  322. package/dist/web/assets/telegram-bot-token-field-BibezKpI.js.gz +0 -0
  323. package/dist/web/assets/{terminal-tab-DftSyAN_.js → terminal-tab-C9bsg88-.js} +1 -1
  324. package/dist/web/assets/terminal-tab-C9bsg88-.js.br +0 -0
  325. package/dist/web/assets/terminal-tab-C9bsg88-.js.gz +0 -0
  326. package/dist/web/assets/{tool-cards-DtIbRB5W.js → tool-cards-DUKn_XTY.js} +3 -3
  327. package/dist/web/assets/tool-cards-DUKn_XTY.js.br +0 -0
  328. package/dist/web/assets/tool-cards-DUKn_XTY.js.gz +0 -0
  329. package/dist/web/assets/{tools-settings-section-7VXtk6zh.js → tools-settings-section-BWP7lR_H.js} +1 -1
  330. package/dist/web/assets/tools-settings-section-BWP7lR_H.js.br +0 -0
  331. package/dist/web/assets/tools-settings-section-BWP7lR_H.js.gz +0 -0
  332. package/dist/web/assets/use-assistant-sessions-DwnkM0MT.js +1 -0
  333. package/dist/web/assets/use-assistant-sessions-DwnkM0MT.js.br +0 -0
  334. package/dist/web/assets/use-assistant-sessions-DwnkM0MT.js.gz +0 -0
  335. package/dist/web/assets/{use-assistant-telegram-binding-BDrv3xPb.js → use-assistant-telegram-binding-BElVy80Y.js} +1 -1
  336. package/dist/web/assets/use-assistant-telegram-binding-BElVy80Y.js.br +0 -0
  337. package/dist/web/assets/use-assistant-telegram-binding-BElVy80Y.js.gz +0 -0
  338. package/dist/web/assets/{use-db-read-CRBKwyT0.js → use-db-read-CVKBGcwR.js} +1 -1
  339. package/dist/web/assets/use-db-read-CVKBGcwR.js.br +0 -0
  340. package/dist/web/assets/use-db-read-CVKBGcwR.js.gz +0 -0
  341. package/dist/web/assets/{use-db-tab-Ba601MmM.js → use-db-tab-Dqt-fdlx.js} +1 -1
  342. package/dist/web/assets/use-db-tab-Dqt-fdlx.js.br +0 -0
  343. package/dist/web/assets/use-db-tab-Dqt-fdlx.js.gz +0 -0
  344. package/dist/web/assets/{use-inline-blame-Dtf0igmc.js → use-inline-blame-B5Y2JpMW.js} +1 -1
  345. package/dist/web/assets/use-inline-blame-B5Y2JpMW.js.br +0 -0
  346. package/dist/web/assets/use-inline-blame-B5Y2JpMW.js.gz +0 -0
  347. package/dist/web/assets/{use-lsp-DpckRfpY.js → use-lsp-CX8DCsdI.js} +1 -1
  348. package/dist/web/assets/use-lsp-CX8DCsdI.js.br +0 -0
  349. package/dist/web/assets/use-lsp-CX8DCsdI.js.gz +0 -0
  350. package/dist/web/assets/{use-monaco-theme-LNAN16lw.js → use-monaco-theme-D7J2RPBT.js} +1 -1
  351. package/dist/web/assets/{use-process-kill-qtE7lYOh.js → use-process-kill-DroUSw5r.js} +1 -1
  352. package/dist/web/assets/use-process-kill-DroUSw5r.js.br +0 -0
  353. package/dist/web/assets/use-process-kill-DroUSw5r.js.gz +0 -0
  354. package/dist/web/assets/{use-sql-schema-info-Bmg281GG.js → use-sql-schema-info-wl-EurBd.js} +1 -1
  355. package/dist/web/assets/use-sql-schema-info-wl-EurBd.js.br +0 -0
  356. package/dist/web/assets/use-sql-schema-info-wl-EurBd.js.gz +0 -0
  357. package/dist/web/assets/{use-websocket-BMYxcPK5.js → use-websocket-Bd1Zw6mK.js} +1 -1
  358. package/dist/web/assets/{user-message-parse-CQHAZlXx.js → user-message-parse-yeAjynUW.js} +1 -1
  359. package/dist/web/assets/user-message-parse-yeAjynUW.js.br +0 -0
  360. package/dist/web/assets/user-message-parse-yeAjynUW.js.gz +0 -0
  361. package/dist/web/assets/{voice-settings-section-DU4upkvs.js → voice-settings-section-B4fxNTf6.js} +1 -1
  362. package/dist/web/assets/voice-settings-section-B4fxNTf6.js.br +0 -0
  363. package/dist/web/assets/voice-settings-section-B4fxNTf6.js.gz +0 -0
  364. package/dist/web/assets/{web-preview-tab-PKyBaE63.js → web-preview-tab-C5yXS9An.js} +1 -1
  365. package/dist/web/assets/web-preview-tab-C5yXS9An.js.br +0 -0
  366. package/dist/web/assets/web-preview-tab-C5yXS9An.js.gz +0 -0
  367. package/dist/web/assets/{xlsx-preview-D8-XSrk6.js → xlsx-preview-CstDrlVE.js} +1 -1
  368. package/dist/web/assets/xlsx-preview-CstDrlVE.js.br +0 -0
  369. package/dist/web/assets/xlsx-preview-CstDrlVE.js.gz +0 -0
  370. package/dist/web/index.html +23 -23
  371. package/dist/web/index.html.br +0 -0
  372. package/dist/web/index.html.gz +0 -0
  373. package/dist/web/sw.js +1 -1
  374. package/dist/web/sw.js.br +0 -0
  375. package/dist/web/sw.js.gz +0 -0
  376. package/docs/architecture/ppm-assistant.md +79 -3
  377. package/package.json +1 -1
  378. package/src/cli/commands/restart.ts +30 -3
  379. package/src/cli/commands/stop.ts +19 -0
  380. package/src/index.ts +1 -0
  381. package/src/server/index.ts +9 -0
  382. package/src/services/assistant/assistant-settings.service.ts +2 -1
  383. package/src/services/assistant/assistant-turn-provenance.ts +36 -5
  384. package/src/services/assistant-hub/assistant-hub-startup.ts +9 -0
  385. package/src/services/assistant-managers/manager-context-entry.ts +1 -0
  386. package/src/services/assistant-wake/assistant-wake-queue.ts +15 -1
  387. package/src/services/assistant-wake/wake-news-text.ts +18 -7
  388. package/src/services/log-rotate.ts +21 -0
  389. package/src/services/restart-news/interrupted-chats.ts +234 -0
  390. package/src/services/restart-news/ordered-stop-note.ts +69 -0
  391. package/src/services/restart-news/restart-news-lifecycle.ts +161 -0
  392. package/src/services/restart-news/restart-news-run.ts +55 -0
  393. package/src/services/restart-news/restart-news-source.ts +240 -0
  394. package/src/services/restart-news/restart-news-text.ts +154 -0
  395. package/src/services/restart-news/server-run-log.ts +115 -0
  396. package/src/services/restart-news/start-reason.ts +128 -0
  397. package/src/services/restart-news/supervisor-start-reason.ts +138 -0
  398. package/src/services/session-collab/assistant-send-guards-live.ts +31 -5
  399. package/src/services/session-collab/assistant-send-guards.ts +5 -5
  400. package/src/services/session-collab/collab-assistant-hooks.ts +5 -2
  401. package/src/services/session-collab/collab-env.ts +1 -1
  402. package/src/services/session-collab/collab-send-manager.ts +3 -3
  403. package/src/services/supervisor-self-replace-wait.ts +45 -0
  404. package/src/services/supervisor.ts +175 -63
  405. package/src/services/windows-process-tree.ts +155 -32
  406. package/src/shared/assistant-limits.ts +10 -0
  407. package/src/shared/assistant-provenance.ts +26 -2
  408. package/src/shared/assistant-settings.ts +10 -0
  409. package/src/shared/assistant-wake-news.ts +14 -2
  410. package/src/shared/restart-news.ts +140 -0
  411. package/src/web/components/settings/assistant/assistant-digest-quiet-section.tsx +28 -10
  412. package/src/web/lib/assistant-settings-api.ts +4 -4
  413. package/dist/web/assets/accounts-settings-section-Dj-tqgLP.js.br +0 -0
  414. package/dist/web/assets/accounts-settings-section-Dj-tqgLP.js.gz +0 -0
  415. package/dist/web/assets/agent-session-sheet-ES6BGGHr.js.br +0 -0
  416. package/dist/web/assets/agent-session-sheet-ES6BGGHr.js.gz +0 -0
  417. package/dist/web/assets/agent-session-window-content-D1Qz_Jtj.js.br +0 -0
  418. package/dist/web/assets/agent-session-window-content-D1Qz_Jtj.js.gz +0 -0
  419. package/dist/web/assets/ai-resource-editor-C1xHoS9l.js.br +0 -0
  420. package/dist/web/assets/ai-resource-editor-C1xHoS9l.js.gz +0 -0
  421. package/dist/web/assets/ai-settings-section-B2s5uYmr.js.br +0 -0
  422. package/dist/web/assets/ai-settings-section-B2s5uYmr.js.gz +0 -0
  423. package/dist/web/assets/ai-settings-section-D0LobmFN.js.br +0 -0
  424. package/dist/web/assets/ai-settings-section-D0LobmFN.js.gz +0 -0
  425. package/dist/web/assets/android-tab-JEd1TSF7.js.br +0 -0
  426. package/dist/web/assets/android-tab-JEd1TSF7.js.gz +0 -0
  427. package/dist/web/assets/antigravity-usage-view-CCOvhebf.js.br +0 -0
  428. package/dist/web/assets/antigravity-usage-view-CCOvhebf.js.gz +0 -0
  429. package/dist/web/assets/appearance-settings-section-DO6hc-od.js.br +0 -0
  430. package/dist/web/assets/appearance-settings-section-DO6hc-od.js.gz +0 -0
  431. package/dist/web/assets/apps-panel-DcTJU6vR.js.br +0 -0
  432. package/dist/web/assets/apps-panel-DcTJU6vR.js.gz +0 -0
  433. package/dist/web/assets/assistant-name-store-DunABllt.js.br +0 -0
  434. package/dist/web/assets/assistant-name-store-DunABllt.js.gz +0 -0
  435. package/dist/web/assets/assistant-settings-D0Ro1s7r.js +0 -1
  436. package/dist/web/assets/assistant-settings-D0Ro1s7r.js.br +0 -0
  437. package/dist/web/assets/assistant-settings-D0Ro1s7r.js.gz +0 -0
  438. package/dist/web/assets/assistant-settings-section-B2Ku9p0H.js.br +0 -0
  439. package/dist/web/assets/assistant-settings-section-B2Ku9p0H.js.gz +0 -0
  440. package/dist/web/assets/assistant-tab-C7PHbtlQ.js.br +0 -0
  441. package/dist/web/assets/assistant-tab-C7PHbtlQ.js.gz +0 -0
  442. package/dist/web/assets/background-output-store-D2KAitP3.js.br +0 -0
  443. package/dist/web/assets/background-output-store-D2KAitP3.js.gz +0 -0
  444. package/dist/web/assets/branch-review-tab-BTkWVfIx.js.br +0 -0
  445. package/dist/web/assets/branch-review-tab-BTkWVfIx.js.gz +0 -0
  446. package/dist/web/assets/build-message-with-attachments-CRWLGa4Y.js.br +0 -0
  447. package/dist/web/assets/build-message-with-attachments-CRWLGa4Y.js.gz +0 -0
  448. package/dist/web/assets/chat-tab-BeGzYhAz.js +0 -1
  449. package/dist/web/assets/chat-tab-BeGzYhAz.js.br +0 -0
  450. package/dist/web/assets/chat-tab-BeGzYhAz.js.gz +0 -0
  451. package/dist/web/assets/chat-tab-edXhE4lm.js.br +0 -0
  452. package/dist/web/assets/chat-tab-edXhE4lm.js.gz +0 -0
  453. package/dist/web/assets/code-editor-B1hoVvoe.js.br +0 -0
  454. package/dist/web/assets/code-editor-B1hoVvoe.js.gz +0 -0
  455. package/dist/web/assets/conflict-editor-CiGF-H8E.js.br +0 -0
  456. package/dist/web/assets/conflict-editor-CiGF-H8E.js.gz +0 -0
  457. package/dist/web/assets/connection-form-tab-DfrYYyqN.js.br +0 -0
  458. package/dist/web/assets/connection-form-tab-DfrYYyqN.js.gz +0 -0
  459. package/dist/web/assets/csv-preview-PhPn1H22.js.br +0 -0
  460. package/dist/web/assets/database-drivers-section-C2iSgtsK.js.br +0 -0
  461. package/dist/web/assets/database-drivers-section-C2iSgtsK.js.gz +0 -0
  462. package/dist/web/assets/db-connection-config-FJf8q_kG.js.br +0 -0
  463. package/dist/web/assets/db-connection-config-FJf8q_kG.js.gz +0 -0
  464. package/dist/web/assets/db-explorer-store-DiyDlsSd.js.br +0 -0
  465. package/dist/web/assets/db-explorer-store-DiyDlsSd.js.gz +0 -0
  466. package/dist/web/assets/db-tab-parts-CFvFJKsW.js.br +0 -0
  467. package/dist/web/assets/db-tab-parts-CFvFJKsW.js.gz +0 -0
  468. package/dist/web/assets/design-settings-section-C3rGRKd9.js.br +0 -0
  469. package/dist/web/assets/design-settings-section-C3rGRKd9.js.gz +0 -0
  470. package/dist/web/assets/design-tab-CujDONDO.js.br +0 -0
  471. package/dist/web/assets/design-tab-CujDONDO.js.gz +0 -0
  472. package/dist/web/assets/designs-sidebar-panel-BmzMD8PY.js.br +0 -0
  473. package/dist/web/assets/designs-sidebar-panel-BmzMD8PY.js.gz +0 -0
  474. package/dist/web/assets/diff-viewer-BradW_q7.js.br +0 -0
  475. package/dist/web/assets/diff-viewer-BradW_q7.js.gz +0 -0
  476. package/dist/web/assets/docx-preview-CrfPGFGk.js.br +0 -0
  477. package/dist/web/assets/docx-preview-CrfPGFGk.js.gz +0 -0
  478. package/dist/web/assets/editor-dialog-CIIhsxqp.js.br +0 -0
  479. package/dist/web/assets/editor-dialog-CIIhsxqp.js.gz +0 -0
  480. package/dist/web/assets/editor-language-service-stDe-8Hh.js.br +0 -0
  481. package/dist/web/assets/editor-language-service-stDe-8Hh.js.gz +0 -0
  482. package/dist/web/assets/explorer-body-DslJEPu8.js.br +0 -0
  483. package/dist/web/assets/explorer-body-DslJEPu8.js.gz +0 -0
  484. package/dist/web/assets/explorer-model-Daztib0H.js.br +0 -0
  485. package/dist/web/assets/explorer-model-Daztib0H.js.gz +0 -0
  486. package/dist/web/assets/explorer-window-content-Cujhxewh.js.br +0 -0
  487. package/dist/web/assets/explorer-window-content-Cujhxewh.js.gz +0 -0
  488. package/dist/web/assets/extension-manager-section-DVYKtRbp.js.br +0 -0
  489. package/dist/web/assets/extension-manager-section-DVYKtRbp.js.gz +0 -0
  490. package/dist/web/assets/extension-webview-CYKu8RhB.js.br +0 -0
  491. package/dist/web/assets/extension-webview-CYKu8RhB.js.gz +0 -0
  492. package/dist/web/assets/files-settings-section-DQn2QDq8.js.br +0 -0
  493. package/dist/web/assets/files-settings-section-DQn2QDq8.js.gz +0 -0
  494. package/dist/web/assets/general-settings-section-CnZIAqkr.js.br +0 -0
  495. package/dist/web/assets/general-settings-section-CnZIAqkr.js.gz +0 -0
  496. package/dist/web/assets/git-log-panel-C91xwW-U.js.br +0 -0
  497. package/dist/web/assets/git-log-panel-C91xwW-U.js.gz +0 -0
  498. package/dist/web/assets/git-review-tab-WpaSXeje.js.br +0 -0
  499. package/dist/web/assets/git-review-tab-WpaSXeje.js.gz +0 -0
  500. package/dist/web/assets/glide-data-grid-sts6YE2c.js.br +0 -0
  501. package/dist/web/assets/glide-data-grid-sts6YE2c.js.gz +0 -0
  502. package/dist/web/assets/grid-save-dialog-jjma4-nR.js.br +0 -0
  503. package/dist/web/assets/grid-save-dialog-jjma4-nR.js.gz +0 -0
  504. package/dist/web/assets/group-chat-tab-ze6sWOA9.js.br +0 -0
  505. package/dist/web/assets/group-chat-tab-ze6sWOA9.js.gz +0 -0
  506. package/dist/web/assets/impexp-tab-ClR7MjKN.js.br +0 -0
  507. package/dist/web/assets/impexp-tab-ClR7MjKN.js.gz +0 -0
  508. package/dist/web/assets/index-DdWNTpRC.js.br +0 -0
  509. package/dist/web/assets/index-DdWNTpRC.js.gz +0 -0
  510. package/dist/web/assets/keyboard-shortcuts-section-DQq6Hr5R.js.br +0 -0
  511. package/dist/web/assets/keyboard-shortcuts-section-DQq6Hr5R.js.gz +0 -0
  512. package/dist/web/assets/language-servers-section-B8DlpKwG.js.br +0 -0
  513. package/dist/web/assets/language-servers-section-B8DlpKwG.js.gz +0 -0
  514. package/dist/web/assets/logs-app-BSb7y8Ub.js.br +0 -0
  515. package/dist/web/assets/logs-app-BSb7y8Ub.js.gz +0 -0
  516. package/dist/web/assets/logs-tab-DNtMgRwA.js +0 -1
  517. package/dist/web/assets/lsp-client-BcS52GK3.js.br +0 -0
  518. package/dist/web/assets/lsp-client-BcS52GK3.js.gz +0 -0
  519. package/dist/web/assets/markdown-renderer-DyR-2m0n.js.br +0 -0
  520. package/dist/web/assets/markdown-renderer-DyR-2m0n.js.gz +0 -0
  521. package/dist/web/assets/markdown-renderer-pHQ_XZui.js +0 -1
  522. package/dist/web/assets/markdown-renderer-pHQ_XZui.js.br +0 -0
  523. package/dist/web/assets/markdown-renderer-pHQ_XZui.js.gz +0 -0
  524. package/dist/web/assets/mobile-explorer-sheet-CDkiK9ss.js.br +0 -0
  525. package/dist/web/assets/mobile-explorer-sheet-CDkiK9ss.js.gz +0 -0
  526. package/dist/web/assets/model-thinking-selector-helpers-B9R_GCmG.js.br +0 -0
  527. package/dist/web/assets/model-thinking-selector-helpers-B9R_GCmG.js.gz +0 -0
  528. package/dist/web/assets/new-design-dialog-CEheObfH.js.br +0 -0
  529. package/dist/web/assets/new-design-dialog-CEheObfH.js.gz +0 -0
  530. package/dist/web/assets/notifications-settings-section--wueiusr.js.br +0 -0
  531. package/dist/web/assets/notifications-settings-section--wueiusr.js.gz +0 -0
  532. package/dist/web/assets/onboarding-entry-BnyHu8g-.js.br +0 -0
  533. package/dist/web/assets/onboarding-entry-BnyHu8g-.js.gz +0 -0
  534. package/dist/web/assets/open-assistant-CIClEfBP.js.br +0 -0
  535. package/dist/web/assets/open-assistant-CIClEfBP.js.gz +0 -0
  536. package/dist/web/assets/open-assistant-DL7Uhfi1.js +0 -1
  537. package/dist/web/assets/open-db-tabs-hq8ISs9i.js.br +0 -0
  538. package/dist/web/assets/open-db-tabs-hq8ISs9i.js.gz +0 -0
  539. package/dist/web/assets/open-manager-chat-Bq9rYZkX.js.br +0 -0
  540. package/dist/web/assets/open-manager-chat-Bq9rYZkX.js.gz +0 -0
  541. package/dist/web/assets/open-manager-chat-DqvuUigC.js +0 -1
  542. package/dist/web/assets/open-ppm-tab-8o5Mp2VL.js.br +0 -0
  543. package/dist/web/assets/open-ppm-tab-8o5Mp2VL.js.gz +0 -0
  544. package/dist/web/assets/panel-store-BVDYuCvt.js.br +0 -0
  545. package/dist/web/assets/panel-store-BVDYuCvt.js.gz +0 -0
  546. package/dist/web/assets/performance-panel-CKT9071S.js.br +0 -0
  547. package/dist/web/assets/performance-panel-CKT9071S.js.gz +0 -0
  548. package/dist/web/assets/problems-panel-3DmEaBKD.js.br +0 -0
  549. package/dist/web/assets/problems-panel-3DmEaBKD.js.gz +0 -0
  550. package/dist/web/assets/process-table-CJAoXA5W.js.br +0 -0
  551. package/dist/web/assets/process-table-CJAoXA5W.js.gz +0 -0
  552. package/dist/web/assets/proxy-settings-section-2l86_w2k.js.br +0 -0
  553. package/dist/web/assets/proxy-settings-section-2l86_w2k.js.gz +0 -0
  554. package/dist/web/assets/query-tab-B94Pr_zx.js.br +0 -0
  555. package/dist/web/assets/query-tab-B94Pr_zx.js.gz +0 -0
  556. package/dist/web/assets/release-notes-window-content-Cb02dQ0z.js +0 -1
  557. package/dist/web/assets/remote-access-settings-section-a8AImvR6.js.br +0 -0
  558. package/dist/web/assets/remote-access-settings-section-a8AImvR6.js.gz +0 -0
  559. package/dist/web/assets/remote-desktop-clipboard-notice-DFn1nxw8.js.br +0 -0
  560. package/dist/web/assets/remote-desktop-clipboard-notice-DFn1nxw8.js.gz +0 -0
  561. package/dist/web/assets/remote-desktop-mobile-sheet-BWS190GJ.js.br +0 -0
  562. package/dist/web/assets/remote-desktop-mobile-sheet-BWS190GJ.js.gz +0 -0
  563. package/dist/web/assets/remote-desktop-mobile-view-Byw7sIXV.js.br +0 -0
  564. package/dist/web/assets/remote-desktop-mobile-view-Byw7sIXV.js.gz +0 -0
  565. package/dist/web/assets/remote-desktop-readiness-gate-CNw85fJW.js.br +0 -0
  566. package/dist/web/assets/remote-desktop-readiness-gate-CNw85fJW.js.gz +0 -0
  567. package/dist/web/assets/remote-desktop-window-content-D-hkqiGt.js.br +0 -0
  568. package/dist/web/assets/remote-desktop-window-content-D-hkqiGt.js.gz +0 -0
  569. package/dist/web/assets/rename-object-dialog-DMjr26AG.js.br +0 -0
  570. package/dist/web/assets/rename-object-dialog-DMjr26AG.js.gz +0 -0
  571. package/dist/web/assets/review-address-setup-CjN4yI9s.js.br +0 -0
  572. package/dist/web/assets/review-address-setup-CjN4yI9s.js.gz +0 -0
  573. package/dist/web/assets/review-code-BPChqugN.js.br +0 -0
  574. package/dist/web/assets/review-code-BPChqugN.js.gz +0 -0
  575. package/dist/web/assets/save-as-dialog-DZabqzFG.js.br +0 -0
  576. package/dist/web/assets/save-as-dialog-DZabqzFG.js.gz +0 -0
  577. package/dist/web/assets/schedule-script-editor-CmbffDN5.js.br +0 -0
  578. package/dist/web/assets/schedule-script-editor-CmbffDN5.js.gz +0 -0
  579. package/dist/web/assets/schedules-settings-section-C9buhsq2.js.br +0 -0
  580. package/dist/web/assets/schedules-settings-section-C9buhsq2.js.gz +0 -0
  581. package/dist/web/assets/send-to-chat-oE-JUerN.js.br +0 -0
  582. package/dist/web/assets/send-to-chat-oE-JUerN.js.gz +0 -0
  583. package/dist/web/assets/session-changes-chip-BieRAjqg.js.br +0 -0
  584. package/dist/web/assets/session-changes-chip-BieRAjqg.js.gz +0 -0
  585. package/dist/web/assets/session-collab-client-DU-Iuwkh.js.br +0 -0
  586. package/dist/web/assets/session-collab-client-DU-Iuwkh.js.gz +0 -0
  587. package/dist/web/assets/session-review-tab-Du1h3fb7.js.br +0 -0
  588. package/dist/web/assets/session-review-tab-Du1h3fb7.js.gz +0 -0
  589. package/dist/web/assets/session-turns-Brf8WhTP.js.br +0 -0
  590. package/dist/web/assets/session-turns-Brf8WhTP.js.gz +0 -0
  591. package/dist/web/assets/settings-body-CSXclIUd.js.br +0 -0
  592. package/dist/web/assets/settings-body-CSXclIUd.js.gz +0 -0
  593. package/dist/web/assets/settings-rows-Db0TK6_7.js.br +0 -0
  594. package/dist/web/assets/settings-rows-Db0TK6_7.js.gz +0 -0
  595. package/dist/web/assets/settings-section-content-DIPL9pgs.js.br +0 -0
  596. package/dist/web/assets/settings-section-content-DIPL9pgs.js.gz +0 -0
  597. package/dist/web/assets/settings-store-DBwLfOkD.js +0 -45
  598. package/dist/web/assets/settings-store-DBwLfOkD.js.br +0 -0
  599. package/dist/web/assets/settings-store-DBwLfOkD.js.gz +0 -0
  600. package/dist/web/assets/sql-object-tab-CVOIYxsK.js.br +0 -0
  601. package/dist/web/assets/sql-object-tab-CVOIYxsK.js.gz +0 -0
  602. package/dist/web/assets/sqlite-viewer-gYzT8mK_.js.br +0 -0
  603. package/dist/web/assets/sqlite-viewer-gYzT8mK_.js.gz +0 -0
  604. package/dist/web/assets/storage-settings-section-kLoWvAiE.js.br +0 -0
  605. package/dist/web/assets/storage-settings-section-kLoWvAiE.js.gz +0 -0
  606. package/dist/web/assets/structure-save-dialog-DKX27TZj.js.br +0 -0
  607. package/dist/web/assets/structure-save-dialog-DKX27TZj.js.gz +0 -0
  608. package/dist/web/assets/structure-tab-B7nUzq1k.js.br +0 -0
  609. package/dist/web/assets/structure-tab-B7nUzq1k.js.gz +0 -0
  610. package/dist/web/assets/system-monitor-body-ISqdObYR.js.br +0 -0
  611. package/dist/web/assets/system-monitor-body-ISqdObYR.js.gz +0 -0
  612. package/dist/web/assets/system-monitor-tab-BJcFebE0.js +0 -1
  613. package/dist/web/assets/tab-host-window-content-DruWYAe4.js.br +0 -0
  614. package/dist/web/assets/tab-host-window-content-DruWYAe4.js.gz +0 -0
  615. package/dist/web/assets/table-tab-Dfdj2oUR.js.br +0 -0
  616. package/dist/web/assets/table-tab-Dfdj2oUR.js.gz +0 -0
  617. package/dist/web/assets/telegram-bot-token-field-DAlWvisV.js.br +0 -0
  618. package/dist/web/assets/telegram-bot-token-field-DAlWvisV.js.gz +0 -0
  619. package/dist/web/assets/terminal-tab-DftSyAN_.js.br +0 -0
  620. package/dist/web/assets/terminal-tab-DftSyAN_.js.gz +0 -0
  621. package/dist/web/assets/tool-cards-DtIbRB5W.js.br +0 -0
  622. package/dist/web/assets/tool-cards-DtIbRB5W.js.gz +0 -0
  623. package/dist/web/assets/tools-settings-section-7VXtk6zh.js.br +0 -0
  624. package/dist/web/assets/tools-settings-section-7VXtk6zh.js.gz +0 -0
  625. package/dist/web/assets/use-assistant-sessions-ad7CX4sq.js +0 -1
  626. package/dist/web/assets/use-assistant-sessions-ad7CX4sq.js.br +0 -0
  627. package/dist/web/assets/use-assistant-sessions-ad7CX4sq.js.gz +0 -0
  628. package/dist/web/assets/use-assistant-telegram-binding-BDrv3xPb.js.br +0 -0
  629. package/dist/web/assets/use-assistant-telegram-binding-BDrv3xPb.js.gz +0 -0
  630. package/dist/web/assets/use-db-read-CRBKwyT0.js.br +0 -0
  631. package/dist/web/assets/use-db-read-CRBKwyT0.js.gz +0 -0
  632. package/dist/web/assets/use-db-tab-Ba601MmM.js.br +0 -0
  633. package/dist/web/assets/use-db-tab-Ba601MmM.js.gz +0 -0
  634. package/dist/web/assets/use-inline-blame-Dtf0igmc.js.br +0 -0
  635. package/dist/web/assets/use-inline-blame-Dtf0igmc.js.gz +0 -0
  636. package/dist/web/assets/use-lsp-DpckRfpY.js.br +0 -0
  637. package/dist/web/assets/use-lsp-DpckRfpY.js.gz +0 -0
  638. package/dist/web/assets/use-process-kill-qtE7lYOh.js.br +0 -0
  639. package/dist/web/assets/use-process-kill-qtE7lYOh.js.gz +0 -0
  640. package/dist/web/assets/use-sql-schema-info-Bmg281GG.js.br +0 -0
  641. package/dist/web/assets/use-sql-schema-info-Bmg281GG.js.gz +0 -0
  642. package/dist/web/assets/user-message-parse-CQHAZlXx.js.br +0 -0
  643. package/dist/web/assets/user-message-parse-CQHAZlXx.js.gz +0 -0
  644. package/dist/web/assets/voice-settings-section-DU4upkvs.js.br +0 -0
  645. package/dist/web/assets/voice-settings-section-DU4upkvs.js.gz +0 -0
  646. package/dist/web/assets/web-preview-tab-PKyBaE63.js.br +0 -0
  647. package/dist/web/assets/web-preview-tab-PKyBaE63.js.gz +0 -0
  648. package/dist/web/assets/xlsx-preview-D8-XSrk6.js.br +0 -0
  649. package/dist/web/assets/xlsx-preview-D8-XSrk6.js.gz +0 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.25.8] - 2026-11-15
4
+
5
+ ### Added
6
+
7
+ - **The PPM Assistant is told after every PPM restart** (upgrade, crash, watchdog, manual or boot) why it restarted, the versions before and after, and which chats it cut off mid-turn in every project, so it can ask each project's manager to resume them; switch it in Settings → PPM Assistant.
8
+ - `ppm restart --reason "<text>"` records why you restarted.
9
+
10
+ ### Fixed
11
+
12
+ - **An upgrade no longer takes PPM down**: a reused Windows process id could make the supervisor kill its own edge, tunnel and new supervisor; a server-tree kill now never reaches them, and a new supervisor that dies brings the old one back to restart the server.
13
+ - The previous `ppm.err.log` is kept as `ppm.err.log.1` when PPM starts.
14
+
3
15
  ## [0.25.7] - 2026-11-15
4
16
 
5
17
  ### Added
package/CLAUDE.md CHANGED
@@ -275,6 +275,7 @@ Related: `configService.save()`/`set()` throw when `load()` has not run, because
275
275
 
276
276
  - **The chat sidebar's session list read every Codex transcript on disk, synchronously, on every request**: `GET /chat/sessions` asks every provider, and Codex finds a project's sessions by reading the head of each rollout in each account's sessions tree, which holds every project's rollouts (5,262 files / 5.4 GB on the dev host). Done with `readSync` per request, that was 10.9 s of stopped event loop for one project with the files out of the OS cache, and the sidebar lists two or three projects at once — so the server froze 35–90 s at a time, many times a day (`Event loop stalled … cause=blocked`, main thread `waiting/Executive`), taking the usage panel, chat history and health probe down with it. The tell was in the log: nearly every stall had a `/chat/sessions` request whose duration matched the stall to within a second. `codex-rollout-index.ts` now keeps each rollout's header keyed by path and re-reads a file only when its size or mtime moves, reads asynchronously, shares one pass between concurrent callers and reads titles only for the page returned (two projects at once: 135 ms, longest event-loop block ~30 ms). Any new reader of that tree should go through it rather than `readSessionMeta`, which is for single lookups.
277
277
  - **The SDK's `getSessionMessages` reads the whole transcript, however little you need from it**: past 5 MB it scans every byte for the last `compact_boundary` (1 MB reads on Bun's pool threads) and then `JSON.parse`s all that follows. The streaming loop's tool_result fallback used to fire on the frames that follow a tool_use inside its own response (`content_block_stop`, `message_delta`, `message_stop`), i.e. on every tool call before the tool had even run, and it yielded each result twice. One 7-day session's 1.47 GB transcript was read back every ~8 s: the server's RSS swung 4.9→12.8 GB, its main thread sat at 96% and requests hit Bun's 10 s timeout. The fallback now waits for a new response (`message_start`, or an assistant frame of another message id). Measured over 3 tool calls on a 401 MB transcript, peak RSS went 1466 MB → 203 MB. Keep it off every per-event path: `readCompactions` with no window still reads the whole file. `claude-agent-sdk.test.ts` "tool results" pins both halves of the fallback. Its "skip what precedes the boundary" is also void in practice: a boundary carrying `preservedSegment`/`preservedMessages` (every current auto-compaction) never resets the scan, so a 1.77 GB transcript was read whole on each chat open (8.5 s, +5.7 GB RSS) for 31 messages. Every call now goes through `readSessionMessages` (`src/providers/claude-transcript-tail.ts`), which reads backward to the newest boundary plus the records it preserves and hands that range to the SDK as a `sessionStore` — same answer, byte for byte on the 60 largest local transcripts. When comparing against the SDK from a script outside the repo, import `node_modules/@anthropic-ai/claude-agent-sdk/sdk.mjs` by path: a bare import from `/tmp` makes Bun auto-install another SDK version, whose output differs.
278
+ - **On Windows a parent PID is a claim about a process that may no longer exist, so never walk a tree by parent PID alone**: Windows does not reparent, and the edge, the tunnel and a self-replaced supervisor all keep naming the supervisor that started them long after it exits. The server tree churns PIDs fast (git, shells, MCP servers), so one of its processes eventually gets that dead supervisor's PID, and a walk by parent PID then lists the edge, the tunnel and the *running* supervisor as server descendants. That is exactly what happened on the 0.25.6 → 0.25.7 upgrade (14/11/2026): `snapshotServerDescendants` had recorded all three, stopping the server for the upgrade reaped them, the supervisor killed itself mid-self-replace, and PPM stayed down 11 minutes with no log line saying why. `descendantsByLineage` (`windows-process-tree.ts`) only accepts a child that started no earlier than its parent. The supervisor's kills of the server tree — the stop before an upgrade, the health-check kill and `shutdown()` — go through `killTreeByLineage` (blocking `killTreeByLineageSync` in `shutdown()`), and the reap (`reapTrackedDescendants`) walks the same lineage. They kill the server itself even when the process list cannot be read, spare the supervisor, its ancestors, the edge, the tunnel and the share host, and do not use `taskkill /T`, which walks parent PIDs as they stand. `killProcessTree` (`taskkill /T`) is still used elsewhere: port-holder kills, the `ppm start` stale-status cleanup, the codex and cloudflared helpers. Two related guards: a self-replace gives up the moment its new supervisor exits, even one that already wrote its PID to status.json (it used to wait 30 s and trust that PID), and a server stopped while `shuttingDown` is not counted as a crash. `ppm start` keeps the previous `ppm.err.log` as `ppm.err.log.1`, because `Start-Process -RedirectStandardError` truncates it. For a supervisor started by `ppm start`, that file is the only record left when it dies without a log line; a self-replaced supervisor writes its stderr into `ppm.log` instead. The first upgrade onto this code still runs the old supervisor's reap against whatever its tracked file holds.
278
279
  - **Bun before 1.3.11 on Windows leaks every idle helper thread, so PPM must not run on it**: JavaScriptCore's helper threads exit after 10 s idle and come back with the next bit of work, and those releases (measured: 1.2.23, 1.3.9, 1.3.10) never close their handles. Any process on a timer longer than that churns them, and the supervisor reached 7,352 dead `Thread` handles and 15.4 GB of private bytes (484 fully committed 32 MB segments) against a 1.4 GB working set in 37 hours. A script that only sleeps in 15 s gaps leaks ~8 handles a cycle on 1.3.10 and none on 1.3.11–1.4.4. `bun-runtime-advisory.ts` WARNs at start on a runtime measured to leak, and `scripts/release.sh` refuses to build with one, because `bun build --compile` embeds the builder's own runtime in every binary. Releases use 1.3.12: 1.3.13 rejects TLS over an existing socket (the SSH-tunnel database path, `tls-identity-check.test.ts`), and from 1.4.1–1.4.4 `node:child_process` no longer goes through `Bun.spawn`, which blinds the memory monitor's spawn tracker (`memory-watchdog.test.ts`). 1.3.12 fixed the handles, **not the memory**: each idle exit still keeps a fully committed 32 MB block. A probe that allocates and forces a GC every 11 s gained 7–10 blocks in 54–59 cycles on 1.3.12, the same work every 2 s gained none in 328, and 1.4.4 gained none at 11 s (flat at 90 MB). Private bytes climb while RSS stays put, so measure commit, never RSS. Every long-lived Bun process leaks this way: the server ~180 MB/h idle, the supervisor ~250–330 MB/h, and worst of all the edge, which every upgrade adopts instead of replacing (5.7 GB after 34 h, 144 blocks). So on Windows the edge hands its port to a fresh copy once its private bytes have been over 1.5 GB for two readings in a row and the moment is quiet (at most `EDGE_RECYCLE_QUIET_CONNECTIONS` clients open; `PPM_EDGE_RECYCLE_MB`, `0` = off). It closes the listener and its few clients and exits 75. The supervisor starts the successor from that exit event (a ~70 ms gap, measured), or, for an adopted edge with no exit handle, from a 250 ms watch it starts once its own 10 s reading sees the edge over the limit. The second reading, a minute after the first, makes it all but certain the supervisor's own reading saw the edge over the limit before it exits; with the edge exiting at its first over-limit reading and the supervisor reading once a minute, an adopted edge's recycle was often taken for a crash. `adoptEdge` replaces an edge already over the limit instead of adopting it, but kills it only when netstat names it as the port's listener (`isPpmProcess` matches any command line containing "ppm"); see `edge-recycle-policy.ts`. Off Windows nothing reports commit per process, so nothing is recycled there. When timing Bun versions here, run every binary from the same folder: one outside `~/.bun/bin` is Defender-scanned and reads new files 25–50x slower. How to inspect a leaking Windows process without tools: `docs/lessons-learned.md`.
279
280
  - **A process with little CPU during a stall was not necessarily starved**: the Windows autostart task once ran at the Task Scheduler's default priority 7, which also means memory priority 2 and I/O priority Low for the supervisor and every child it spawns. The server's main thread then sat in `PageIn` waits for 20-60s on an idle machine (13% CPU) until the health check killed it, while the lag monitor logged `cause=starved`. The task is now priority 5, both processes raise themselves at start (`process-priority.ts`, logged as a `WARN` when it fires), the lag monitor says `cause=blocked` when cores were free, and a failed health probe logs the server's main-thread wait from the supervisor (`process-thread-snapshot.ts`). See `docs/lessons-learned.md`.
280
281
  - **On Windows every child PPM spawned kept a copy of every socket PPM had open, so a connection the server closed never closed**: Bun 1.3.10 creates its sockets inheritable — the `Bun.serve` listener, every accepted connection, `fetch`'s outgoing ones — and `Bun.spawn` creates children with handle inheritance on; `node:child_process` (the Agent SDK's Claude CLI on Windows, codex, git) goes through `Bun.spawn`. Measured with a handle dump of the server's PowerShell child: it held the server's listener and both open client connections, by address. `closesocket` then drops one handle of several, no FIN goes out, and the browser reuses what it still thinks is a live keep-alive connection: a reload after the server spawned a long-lived child hung **44 s** waiting on the old page's `DELETE /api/system/resources/stream/…` (2/2 runs; 72-78 ms with the fix) — the "blank page after a chat cold-starts Claude" report. Inherited handles stay inheritable, so they pass to grandchildren too. Clearing the flag on the listener is not enough (an accepted socket is created inheritable again), and identifying sockets first is not safe: `getsockopt` on an inheritable synchronous pipe that another thread is blocked reading never returned. `src/services/windows-socket-inheritance.ts` therefore wraps `Bun.spawn`/`Bun.spawnSync` once at startup (`src/index.ts`, `__serve__`, the supervisor) and clears `HANDLE_FLAG_INHERIT` on every handle except stdin/stdout/stderr before each spawn — a handle-table call that touches no object (0.25 ms clearing 101 handles, 0.02 ms after); libuv still duplicates the child's own stdio as inheritable inside the spawn. Not covered, and not needed today: `Bun.$` does not go through `Bun.spawn` (only `ppm report` uses it), and bun-pty's ConPTY spawn does not inherit (measured). A spawn from a Worker would not be wrapped, and one running concurrently with a sweep could lose its stdio — PPM spawns only from the main thread; keep it that way. To check a process: duplicate its handles into a probe and ask each `getsockname`/`getpeername` (with a timeout per handle — see the pipe hang above); `handle.exe` needs admin. `tests/unit/services/windows-socket-inheritance.test.ts` fails without the guard (no EOF in 8 s while the child lives).
@@ -374,6 +375,7 @@ Before planning or implementing a new feature, read `docs/project-roadmap.md` to
374
375
  - `src/services/assistant/` + `src/services/assistant-mcp/` — the PPM Assistant, a chat that operates PPM itself on Claude and Codex. Sessions live in the reserved project `__assistant__` (`src/shared/assistant-project.ts`), which only the chat path resolves (`src/server/helpers/resolve-chat-project.ts`) to a work dir per database (`assistant-work-dir.ts`); `isAssistantSession` (`assistant-session.ts`) reads `session_metadata.assistant`, the migrated id's mark or that work dir. Policy: `assistant-tool-policy.ts` (Claude PreToolUse + `canUseTool`, reads unasked only inside registered projects and outside `assistant-private-paths.ts`), `ASSISTANT_PERMISSION` (`codex-permission-map.ts`). Isolation: `assistant-settings.service.ts` behind `/api/assistant/settings` (shape in `src/shared/assistant-settings.ts`), Claude `settingSources: []` + `strictMcpConfig` (`assistantMcpServers`), Codex `assistantSessionConfig` (`codex-thread-params.ts`) + `codex-assistant-mcp-guard.ts`; `assistant-instructions.ts`, and `assistant-ui-summary.ts` for the screen summary inside `<ppm-shared-context>`. Tools: `/api/assistant-mcp` (`assistant-mcp-endpoint.ts`, before auth, per-session tokens, names in `src/shared/assistant-tool-names.ts`); screen tools go through a strict device broker (`assistant-ui-tools.ts` on `createDeviceBroker`, `deliverToChattingDevice` in `src/server/ws/chat.ts`, protocol `src/shared/assistant-ui-protocol.ts`), approvals through `assistant-approval-broker.ts` + `assistant-approval-summary.ts` onto the session's one card (`src/server/ws/chat-pending-approval.ts`), unasked SQL through `assistant-sql-safety.ts` + `assistant-sql-reach-check.ts`. Git, schedule and tunnel tools are families (`assistant-tool-family.ts`; `assistant-{git,schedule,tunnel}-*.ts`, names in `src/shared/assistant-{git,schedule,tunnel}-tool-names.ts`) that call the UI's own routes in-process through `assistant-route-call.ts`, so a change keeps `git:changed`, the discard Undo journal, the `?repo=` check and `schedules:changed`; it skips auth, so each family's `*_ROUTES` allowlist (templates from the leaf `assistant-route-rules.ts`, never regexes) is the boundary — a new route is a deliberate edit there. Browser: `src/web/components/assistant/` (`open-assistant.ts`: `tab-host` window on desktop, tab below `md`), `src/web/lib/assistant-ui/` (answers `assistant_ui`), the command registry `src/web/lib/commands/` (palette, keybindings and `ui_run_command`), `markdown-external-resources.ts` + `markdown-assistant-allowlist.ts` (no auto-loaded resources), Settings pane `settings/assistant-settings-section.tsx`. Docs `docs/architecture/ppm-assistant.md`; e2e `PPM_PLAYWRIGHT_MODULE=<playwright>/index.mjs node tests/e2e/assistant-e2e.mjs` (scripted provider `tests/e2e/fixtures/assistant-server.ts`)
375
376
  - `src/services/chat-control/` + `src/services/assistant-hub/` + `src/services/assistant-watch/` + `src/services/assistant-telegram/` — the PPM Assistant's hub, which replaced the PPMBot coordinator (and the `ppm bot` CLI). `chat-control/chat-control.ts` is `chatControl()`, registered by `src/server/ws/chat.ts`: send a user message, answer a card, stop a turn, read live state with no browser attached, through the same core the socket handler runs; `chat-lifecycle.ts` is the bus emitted even when no client is connected (listeners only record or enqueue); `approval-deciding-input.ts` is the one builder of what a person must see to decide a card. `assistant-hub/assistant-hub-startup.ts` is `startAssistantHub()`, called by both `src/server/index.ts` and the e2e fixture; `chat-attention.service.ts` backs `chats_attention`; `assistant-hub-db.ts` owns the binding and watch tables (migration 62). Tools `assistant-mcp/assistant-hub-tools.ts` (`chats_attention`, `chat_answer_approval`, `ppm_cli_reference`) and `assistant-watch-tools.ts`; opening and messaging chats is PPM's session tools under an Assistant caller policy (`src/services/session-collab/collab-caller-policy.ts`, `collab-send-assistant.ts`). Watches: `assistant-watch/assistant-watch.service.ts` (wake turns that may not ask for anything; cards relayed, never a model turn). Telegram: `assistant-telegram/assistant-telegram.service.ts` (bridge: a connected private chat is a second window onto one Assistant session), `-relay.ts` (watched chats' cards and reports), `-card-format.ts` (Allow only when the whole deciding input fits). Routes `src/server/routes/assistant-telegram.ts` (`/api/assistant/telegram`) and `/api/settings/clawbot*` in `settings.ts`; UI `settings/assistant-telegram-settings.tsx`, deep link `src/web/lib/assistant-deep-link.ts` (`/assistant?session=<provider>/<id>`). Docs `docs/architecture/ppm-assistant.md` → Telegram, Watches; integration `tests/integration/assistant-telegram-{bridge,relay}.test.ts`, `assistant-watch-flow.test.ts`
376
377
  - `src/services/assistant-managers/` + `assistant-cards/` + `assistant-wake/` + `assistant-digest/` + `assistant-notes/` — the PPM Assistant over per-project **manager chats** (docs `docs/architecture/ppm-assistant.md` → Manager chats, Reports and cards, Morning digest, Notebook, Threat model). `assistant-managers/`: the `manager_chats` table and its in-memory answers (`manager-chats.service.ts`: one Claude chat per project, keyed by `projectKey`), the rules file `.ppm/manager.md` (`manager-rules-file.ts` writes it and `.ppm/.gitignore`; `manager-rules-guard.ts` checks it at every manager turn start — ordered line diff, held changes kept off disk, `manager-rules-check.ts` the one Haiku `completeOnce` per plain addition, failing closed) and `manager-context-entry.ts` (the rules as a shared-context entry, never the system prompt). The card-free send to a manager is `session-collab/collab-send-manager.ts` (provenance block `src/shared/assistant-provenance.ts`, budgets and quiet hours `assistant-send-guards.ts`, all limits in `src/shared/assistant-limits.ts`). `assistant-cards/`: `report_to_assistant` (`manager-report-tool.ts`), what PPM sees in a manager chat (`manager-signals.ts`), rules and budget cards (`assistant-event-cards.ts`), the `assistant_cards` table and its compare-and-set transitions, Telegram outbound with the quiet-hours hold (`card-outbound.ts`), OK and replies (`card-reply-actions.ts`; the user's words block is written only by `forward-verbatim.ts`). `assistant-wake/`: the injectable clock (`assistant-clock.ts`) every schedule here reads, and the wake queue, the one door through which PPM starts an Assistant turn (capped per hour, held in quiet hours unless urgent). `assistant-digest/`: one timer per day on that clock, asks sent `later`, the run written before the first ask. `assistant-notes/`: the notebook (user lines locked, unattended writes Unverified). Routes `src/server/routes/assistant-{managers,manager-rules,cards,notes,settings}.ts` under `/api/assistant`; UI `src/web/components/assistant/` (the window, chips, cards) and `src/web/components/settings/assistant/` (the Settings pane). e2e `tests/e2e/assistant-manager-loop-e2e.mjs` (fixture `assistant-server.ts` with `PPM_ASSISTANT_MANAGER_LOOP=1` → `assistant-manager-fixture.ts`: a clock the script moves, a scripted rules check; Node 20 in `ppm-e2e-chromium`)
378
+ - `src/services/restart-news/` — after every server start, one wake turn tells the main PPM Assistant session why PPM restarted and which chats were cut off mid-turn (docs `docs/architecture/ppm-assistant.md` → Restart news). The supervisor names each spawn in `PPM_START_REASON`/`PPM_START_DETAIL` (decided by the pure, table-tested `supervisor-start-reason.ts`; `start-reason.ts`; `ppm restart --reason` leaves `.restart-reason` for its next manual spawn); the server keeps a per-database run log (`restart-news-run.ts` + `server-run-log.ts`, config row `server_run_log`), so a run with no clean stop reads as a crash — unless the supervisor left `.server-stop.<pid>.json` before stopping it (`ordered-stop-note.ts`: on Windows it always hard-kills, so the server never writes its own stop); `interrupted-chats.ts` reads the cut-off turns from the session trace, which `ppm.db`, `ppm.dev.db` and the CLI share, so only sessions this database places in a registered project count; `restart-news-source.ts` is the wake source (config row `assistant_restart_news`, merged until told, urgent only with cut-off chats: `RESTART_NEWS_URGENT_WHEN`); `restart-news-text.ts` the entry. While that turn runs, a message to a manager whose project has cut-off chats in the news carries the provenance reason `restart` with those chats' ids (`restartChats`), and the manager may resume only those (`manager-context-entry.ts`); only those messages pass quiet hours (`assistantQuietNow`). Setting `assistant.restart_news`
377
379
  - `src/services/design/share/` — design share links (docs `docs/architecture/workspace-and-ui.md` → Design mode → Share links): `design-share-code.ts` (derived codes), `design-share-links.service.ts` + `design-share-links-store.ts` + `design-share-resolve.ts` (links, pinned snapshots, status), `design-share-comments.service.ts` (a reviewer's view of the threads, 304 ETags), `design-share-rate-limit.ts` + `design-share-client-key.ts`, `design-share-address.ts` (the review address when on, else PPM's tunnel; the review address itself is `src/services/share-host/`), `design-share-notifier.ts` (`design_review`); allow-list `preview/design-guest-alias.ts`, guest bridge `bridge/guest-bridge.ts`, replies in `design-comment-replies.service.ts`. Owner routes `src/server/routes/design-shares.ts` (`/api/project/:name/designs/:slug/shares`) and `design-share-address.ts` (`/api/design-shares/address`); reviewer routes `src/server/routes/design-share-guest*.ts` on `/s/<code>`; owner UI `src/web/components/design/share/`; reviewer page `src/web/design-share-page/`, built by `vite.share.config.ts` inside `build:web`. e2e `PPM_PLAYWRIGHT_MODULE=<playwright>/index.mjs node tests/e2e/design-share-e2e.mjs` and `tests/e2e/design-comment-threads-e2e.mjs`; Markdown/Mermaid/docx sanitising `tests/e2e/markdown-sanitize-e2e.mjs`
378
380
  - `src/services/tab-tools-mcp/` — the AI's tab tools, `open_file` (optional `line`), `open_preview`, `open_url`, `read_terminal` and `run_in_terminal`, given to every chat that is not a design session while any is on in Settings → Tools (`ai.ppm_tools`, decided by `src/shared/ppm-tools.ts`; `open_file`/`open_preview` never switched there follow the older single switch `ai.tab_tools`, the other three default on, so the server reaches every chat by default); Claude's claude.ai Artifact tools are turned off while `open_preview` is on (`CLAUDE_CODE_DISABLE_ARTIFACT=1`), and a call to a tool turned off since is refused at the endpoint (`unavailable` in `mcp-http-endpoint.ts`), because a chat keeps the tools it started with. `/api/tab-tools-mcp` (`tab-tools-mcp-endpoint.ts`, mounted before auth) is built from the same parts as `/api/design-mcp`: `src/services/mcp-http-endpoint.ts` (JSON-only Streamable HTTP, a request with an `Origin` refused, 64 KB cap) and `src/services/mcp-session-tokens.ts` (per-session capability tokens, memory only, looked up by SHA-256); `tab-tools-mcp-tokens.ts` binds a token to the session id alone, so a warm spare's token is the one its session's turns mint. `tab-target.ts` resolves the agent's `path` under the editor's own read rules, and `tab-open-broker.ts` sends `tab_open` over the chat WebSocket and waits for the first `tab_open_result` (8 s for a file, 40 s for a page; 4 calls in flight and 20 a minute per session) — `deliverTabOpen` in `src/server/ws/chat.ts` picks the device that sent the turn's message, else every device showing the chat, and never buffers it for replay. Protocol and the per-provider tool names in `src/shared/tab-open-protocol.ts`; provider wiring `tabToolsMcpServers` (`claude-agent-sdk-query-options.ts`) and `tabToolsMcpConfig`/`tabToolsMcpEnv` (`codex-thread-params.ts`), from the access `chatService.prepareSendOptions` mints. Browser: `src/web/lib/open-ai-tab.ts` (answers `tab_open` from `use-chat.ts`: opens the tab, waits for the page, runs its check), `ai-tab-placement.ts` (pure: beside the chat on a desktop, the whole screen on a phone), `html-preview-loads.ts` (which preview shows which page, by load), `tab-tool-call.ts` + `src/web/components/chat/tab-tool-card.tsx` (the card and its Open button). The three tools that take no file: `open-url-tool.ts` (host servers only; an existing forward, else a private Tailscale forward it starts, else the address itself, which `openAiUrlTab` accepts only on a page loaded from loopback), `terminal-tools.ts` (`read_terminal` over the chat's project terminals plus the ones it opened; `run_in_terminal` starts the shell, has the device dock it via `openAiTerminal`, types one checked line with no newline) and `terminal-text.ts` (the raw buffer replayed through `@xterm/headless` into the lines the screen shows); their card is `src/web/components/chat/device-tool-card.tsx`. The HTML preview route serves the design canvas's CSP (`buildDesignCsp`, so the design CDNs load) and injects `design/bridge/html-preview-bridge.ts`, the design bridge's core plus its self-check. Docs `docs/architecture/ai-chat-and-providers.md` → AI tab tools; e2e `PPM_PLAYWRIGHT_MODULE=<playwright>/index.mjs node tests/e2e/ai-tab-tools-e2e.mjs` (scripted provider in `tests/e2e/fixtures/tab-tools-server.ts`, which also mounts the terminal socket; `PPM_TAB_TOOLS_WEB_DIR` reuses a scratch build; a stand-in `tailscale` on its `PATH` keeps `open_url` off the real tailnet) and `tests/e2e/html-preview-cdn-check-e2e.mjs`. Full design: `docs/architecture/ai-tab-tools.md`
379
381
  - `src/services/db-ai-tools/` — the AI chat's database tools, `db_query` (read-only), `open_query` (a Query tab holding a script the user runs) and `db_execute` (a change, once, after the user approves it with PPM's password), on the saved connections with *Available to the AI chat* on, each tool on or off in Settings → Tools (`ai.ppm_tools`, all three on by default; `src/shared/ppm-tools.ts`). `db_query` names only the change tools that are on (`dbChangeHint`). `/api/db-tools-mcp` (`db-ai-tools-endpoint.ts`, mounted before auth) is built like `/api/tab-tools-mcp`: `mcp-http-endpoint.ts` + per-session tokens (`db-ai-tools-tokens.ts`). `db-ai-tools-tool.ts` holds the tool definitions and limits, `db-ai-connections.ts` which connections (light on purpose: `chat.service.ts` imports it, and the CLI loads `chat.service.ts`), `db-ai-target.ts` the adapter config with the *tool's* `readonly`, `db-ai-run.ts` the runs (`QueryScriptRun` for reads, `runApprovedScript` for one approved transaction), `db-ai-format.ts` rows as fenced untrusted data, `db-approval-broker.ts` the wait for the user's answer. Shared names and the approval's shape in `src/shared/db-ai-tools.ts`; the password check in `src/services/ppm-password.ts`. Chat side: `announcePpmApproval` / `ppmApprovalResolved` in `src/server/ws/chat.ts`, onto the session's approval slot (`chat-pending-approval.ts`, origin `ppm`; shared with the session tools' cards through `chat-ppm-approvals.ts`); the answer route `POST /api/db/ai-approvals/:requestId` in `src/server/routes/database.ts`. Browser: `src/web/components/chat/db-execute-approval-card.tsx`, `db-tool-card.tsx` + `src/web/lib/db-tool-call.ts`, `openAiQueryTab` in `src/web/lib/open-ai-tab.ts`, and the Query tab's *Run with write access (once)* (`write-once-dialog.tsx`, `writeOnce` on `/query/script`). Docs `docs/architecture/ai-chat-and-providers.md` → AI database tools; e2e `PPM_PLAYWRIGHT_MODULE=<playwright>/index.mjs node tests/e2e/ai-db-tools-e2e.mjs` (scripted provider in `tests/e2e/fixtures/db-tools-server.ts`; `PPM_DB_TOOLS_WEB_DIR` reuses a scratch build).
@@ -83,4 +83,4 @@ This skill covers the `ppm` CLI, its HTTP API, and its config DB. It does **not*
83
83
  - Third-party extensions (inspect via `ppm ext list`).
84
84
  - The Claude Agent SDK internals (separate skill).
85
85
 
86
- <!-- Generated for PPM v0.25.7 at build time. Re-run `ppm export skill --install` to refresh. -->
86
+ <!-- Generated for PPM v0.25.8 at build time. Re-run `ppm export skill --install` to refresh. -->
@@ -1876,6 +1876,7 @@ Restart the server (keeps tunnel alive)
1876
1876
 
1877
1877
  **Options:**
1878
1878
  - `--force` — Force resume from paused state
1879
+ - `--reason <text>` — Why PPM is restarted (watchdog, recycle, or free text); the PPM Assistant is told
1879
1880
 
1880
1881
  ## `ppm restore`
1881
1882
 
@@ -843,4 +843,4 @@ Authenticate with `?token=<token>` (see Authentication).
843
843
  - `/ws/android`
844
844
  - `/ws/project/<project>/<type>/<id>` — `<type>`: `terminal`, `chat`, `group`, `lsp` (for `chat`, `<id>` is the session id)
845
845
 
846
- <!-- Generated from src/server/routes/ for PPM v0.25.7 -->
846
+ <!-- Generated from src/server/routes/ for PPM v0.25.8 -->
@@ -1 +1 @@
1
- import{s as e}from"./rolldown-runtime-C5c2KzVm.js";import{D as t,E as n}from"./vendor-markdown-WX6NXGTJ.js";import"./vendor-ui-XWGn718B.js";import{At as r,J as i,Qr as a,Sn as o,_r as s,gr as c,gt as l,ht as u,lr as d,qr as f,ui as p,un as m,ut as h,wn as g,wr as _}from"./icons-CXY5ue_g.js";import{a as v,r as y}from"./api-client-vI7TyFOL.js";import{n as b}from"./utils-DMiycH3O.js";import"./portal-container-context-tAk8C8AE.js";import{i as x,n as S,t as C}from"./tooltip-CCx1ynhU.js";import{t as w}from"./mobile-bottom-sheet-CR0IYSBI.js";import"./use-visual-viewport-CFeFggvP.js";import{n as T}from"./use-is-mobile-_O8suyE-.js";import{r as E,t as D}from"./button-BCTqB-tu.js";import{a as O,i as k,n as A,o as j,r as M,t as N}from"./dialog-CoO-z2qj.js";import"./chat-preparation-cache-BjKMLTNJ.js";import"./provider-logos-m5ZC_yzc.js";import{t as P}from"./provider-selector-DcPsEA72.js";import{r as F}from"./clipboard-SyUe4kh-.js";import{t as I}from"./input-CcBfRi6-.js";import{S as L,a as R,b as z,g as B,h as ee,m as te,o as ne,r as V,v as re,y as H}from"./api-settings-D4cXrjrY.js";import{Fn as ie,In as ae,Ln as U,Mn as W,Nn as G,Pn as K,vr as q}from"./index-DdWNTpRC.js";import{C as oe,_ as J,a as se,b as ce,c as le,d as ue,f as Y,g as de,i as X,l as fe,m as Z,n as pe,o as me,p as he,r as ge,s as _e,t as ve,v as ye}from"./antigravity-usage-view-CCOvhebf.js";var Q=e(t(),1),$=n(),be=[`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`,`Sun`],xe=Array.from({length:24},(e,t)=>t);function Se(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 Ce(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 we(e){return xe.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 Te(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 Ee(e){return e<.3?`bg-success`:e<.7?`bg-warning`:`bg-error`}function De({accountId:e}){let[t,n]=(0,Q.useState)(null),[r,i]=(0,Q.useState)(!0),[a,s]=(0,Q.useState)(`5h`);(0,Q.useEffect)(()=>{i(!0),te(e).then(n).catch(()=>n([])).finally(()=>i(!1))},[e]);let c=(0,Q.useMemo)(()=>t?Se(t,a):null,[t,a]),l=(0,Q.useMemo)(()=>c?Ce(c):[],[c]),u=(0,Q.useMemo)(()=>c?we(c):[],[c]),d=Math.max(...l,.01);if(Math.max(...u,.01),r)return(0,$.jsx)(`div`,{className:`flex items-center justify-center py-3`,children:(0,$.jsx)(o,{className:`size-3 animate-spin text-text-subtle`})});if(!t||t.length===0)return(0,$.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,$.jsxs)(`div`,{className:`mt-2 space-y-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(`span`,{className:`text-[10px] font-medium text-text-subtle`,children:`Usage Pattern (7d)`}),(0,$.jsxs)(`div`,{className:`flex gap-0.5 text-[9px]`,children:[(0,$.jsx)(`button`,{onClick:()=>s(`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,$.jsx)(`button`,{onClick:()=>s(`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,$.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,$.jsxs)(`div`,{children:[(0,$.jsx)(`span`,{className:`text-[9px] text-text-subtle`,children:`Avg usage by day of week`}),(0,$.jsx)(`div`,{className:`flex flex-col gap-[2px] mt-0.5`,children:be.map((e,t)=>{let n=l[t]??0;return(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(`span`,{className:`text-[8px] text-text-subtle w-5 shrink-0 text-right tabular-nums`,children:e}),(0,$.jsx)(`div`,{className:`flex-1 h-2.5 bg-surface-elevated rounded-sm overflow-hidden`,children:(0,$.jsx)(`div`,{className:`h-full rounded-sm transition-all ${Ee(n)}`,style:{width:`${Math.round(n/d*100)}%`}})}),(0,$.jsxs)(`span`,{className:`text-[8px] text-text-subtle w-6 shrink-0 text-right tabular-nums`,children:[Math.round(n*100),`%`]})]},e)})})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`span`,{className:`text-[9px] text-text-subtle`,children:`Avg usage by hour (0h-23h)`}),(0,$.jsx)(`div`,{className:`flex gap-[1px] mt-0.5`,children:xe.map(e=>{let t=u[e]??0;return(0,$.jsxs)(`div`,{className:`flex-1 flex flex-col items-center gap-[1px]`,children:[(0,$.jsx)(`div`,{className:`w-full aspect-square rounded-[2px] ${Te(t)}`,title:`${e}:00 — avg ${Math.round(t*100)}% usage`}),e%6==0&&(0,$.jsx)(`span`,{className:`text-[7px] text-text-subtle tabular-nums`,children:e})]},e)})})]}),c&&(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`span`,{className:`text-[9px] text-text-subtle`,children:`Day x Hour heatmap`}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-[1px] mt-0.5`,children:[be.map((e,t)=>(0,$.jsxs)(`div`,{className:`flex items-center gap-[1px]`,children:[(0,$.jsx)(`span`,{className:`text-[7px] text-text-subtle w-4 shrink-0 text-right`,children:e.charAt(0)}),xe.map(n=>{let r=c[t][n];return(0,$.jsx)(`div`,{className:`flex-1 aspect-square rounded-[1px] ${Te(r.avg)}`,title:`${e} ${n}:00 — ${r.count>0?`avg ${Math.round(r.avg*100)}% (${r.count} samples)`:`no data`}`},n)})]},e)),(0,$.jsxs)(`div`,{className:`flex items-center gap-[1px]`,children:[(0,$.jsx)(`span`,{className:`w-4 shrink-0`}),xe.map(e=>(0,$.jsx)(`div`,{className:`flex-1 text-center`,children:e%6==0&&(0,$.jsx)(`span`,{className:`text-[7px] text-text-subtle tabular-nums`,children:e})},e))]})]})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[8px] text-text-subtle`,children:[(0,$.jsx)(`span`,{children:`Low`}),(0,$.jsxs)(`div`,{className:`flex gap-[2px]`,children:[(0,$.jsx)(`div`,{className:`size-2 rounded-[1px] bg-success/30`}),(0,$.jsx)(`div`,{className:`size-2 rounded-[1px] bg-success/60`}),(0,$.jsx)(`div`,{className:`size-2 rounded-[1px] bg-warning/50`}),(0,$.jsx)(`div`,{className:`size-2 rounded-[1px] bg-warning/80`}),(0,$.jsx)(`div`,{className:`size-2 rounded-[1px] bg-error/80`})]}),(0,$.jsx)(`span`,{children:`High`}),(0,$.jsx)(`span`,{className:`ml-1`,children:`|`}),(0,$.jsx)(`div`,{className:`size-2 rounded-[1px] bg-surface-elevated border border-border/30`}),(0,$.jsx)(`span`,{children:`No data`})]})]})}function Oe({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,$.jsxs)(`section`,{className:`space-y-2 border-t border-border pt-3`,"data-testid":`account-profile-panel`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-medium`,children:`Profile`}),(0,$.jsx)(`button`,{className:`p-2 text-muted-foreground hover:text-foreground cursor-pointer`,onClick:n,"aria-label":`Close profile`,children:(0,$.jsx)(p,{className:`size-4`})})]}),(0,$.jsx)(`div`,{className:`grid grid-cols-[80px_1fr] gap-x-3 gap-y-1 text-xs`,children:r.map(([e,t])=>t?(0,$.jsxs)(`span`,{className:`contents`,children:[(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:e}),(0,$.jsx)(`span`,{className:`break-all`,children:t})]},e):null)}),(0,$.jsx)(De,{accountId:t})]})}function ke({display:e,onConfirm:t,onCancel:n}){let r=T(),i=(0,$.jsxs)(`div`,{className:`space-y-4`,"data-testid":`account-delete-confirm`,children:[(0,$.jsxs)(`p`,{className:`text-sm`,children:[`Remove `,(0,$.jsx)(`span`,{className:`font-medium`,children:e}),`?`]}),(0,$.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,$.jsxs)(`div`,{className:`flex flex-col-reverse md:flex-row gap-2 md:justify-end pt-2`,children:[(0,$.jsx)(D,{variant:`outline`,onClick:n,className:`min-h-11`,children:`Cancel`}),(0,$.jsx)(D,{variant:`destructive`,autoFocus:!1,onClick:t,className:`min-h-11`,children:`Remove account`})]})]});return r?(0,$.jsx)(w,{open:!0,onClose:n,children:(0,$.jsxs)(`div`,{className:`px-4 pb-4`,children:[(0,$.jsx)(`h2`,{className:`text-base font-semibold mb-3`,children:`Remove account`}),i]})}):(0,$.jsx)(N,{open:!0,onOpenChange:e=>{e||n()},children:(0,$.jsxs)(A,{className:`sm:max-w-sm`,children:[(0,$.jsx)(O,{children:(0,$.jsx)(j,{className:`text-sm`,children:`Remove account`})}),i]})})}var Ae=80;function je({current:e,onSave:t,onCancel:n}){let r=T(),[i,a]=(0,Q.useState)(e),[s,c]=(0,Q.useState)(!1),[l,u]=(0,Q.useState)(null),d=i.trim(),f=!!d&&d!==e&&!s,p=async()=>{if(f){c(!0),u(null);try{await t(d)}catch(e){u(e.message||`Could not rename the account`),c(!1)}}},m=()=>{s||n()},h=(0,$.jsxs)(`form`,{className:`space-y-4`,"data-testid":`account-rename-dialog`,onSubmit:e=>{e.preventDefault(),p()},children:[(0,$.jsx)(I,{autoFocus:!0,value:i,maxLength:Ae,onChange:e=>a(e.target.value),placeholder:`e.g. Personal, Work`,"aria-label":`Account name`,className:`min-h-11 text-sm md:min-h-9`}),l&&(0,$.jsx)(`p`,{className:`text-xs text-error`,role:`alert`,children:l}),(0,$.jsxs)(`div`,{className:`flex flex-col-reverse md:flex-row gap-2 md:justify-end`,children:[(0,$.jsx)(D,{type:`button`,variant:`outline`,onClick:m,disabled:s,className:`min-h-11 md:min-h-9`,children:`Cancel`}),(0,$.jsxs)(D,{type:`submit`,disabled:!f,className:`min-h-11 md:min-h-9`,children:[s&&(0,$.jsx)(o,{className:`size-4 animate-spin`}),` Save`]})]})]});return r?(0,$.jsx)(w,{open:!0,onClose:m,children:(0,$.jsxs)(`div`,{className:`px-4 pb-4`,children:[(0,$.jsx)(`h2`,{className:`text-base font-semibold mb-3`,children:`Rename account`}),h]})}):(0,$.jsx)(N,{open:!0,onOpenChange:e=>{e||m()},children:(0,$.jsxs)(A,{className:`sm:max-w-sm`,children:[(0,$.jsx)(O,{children:(0,$.jsx)(j,{className:`text-sm`,children:`Rename account`})}),h]})})}function Me(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 Ne({open:e,onOpenChange:t,accounts:n,preselectId:r,onMessage:i}){let a=n.filter(e=>e.hasRefreshToken),[s,c]=(0,Q.useState)(new Set),[l,d]=(0,Q.useState)(``),[f,p]=(0,Q.useState)(!1),[m,_]=(0,Q.useState)(!1),[y,b]=(0,Q.useState)(!1),[x,S]=(0,Q.useState)(!1);e&&!x&&(c(r?new Set([r]):new Set(a.map(e=>e.id))),S(!0)),!e&&x&&S(!1);function C(){t(!1),d(``),p(!1),_(!1)}async function w(e){if(s.size===0)return;b(!0);let t=l.trim()||`ppm-hienlh`;try{let n={"Content-Type":`application/json`},r=v();r&&(n.Authorization=`Bearer ${r}`);let a=await fetch(`/api/accounts/export`,{method:`POST`,headers:n,body:JSON.stringify({password:t,accountIds:[...s],includeRefreshToken:f,refreshBeforeExport:m})});if(!a.ok){let e=await a.json();throw Error(e.error??`Export failed: ${a.status}`)}let o=await a.text();e&&await F(o)?i?.(`Backup copied to clipboard!`):(Me(o),i?.(`Backup downloaded.`)),C()}catch{}b(!1)}let T=s.size>0&&!y;return(0,$.jsx)(N,{open:e,onOpenChange:e=>{e||C()},children:(0,$.jsxs)(A,{className:`sm:max-w-md`,children:[(0,$.jsxs)(O,{children:[(0,$.jsxs)(j,{className:`text-sm flex items-center gap-1.5`,children:[(0,$.jsx)(g,{className:`size-3.5`}),` Export Accounts`]}),(0,$.jsx)(M,{className:`text-xs`,children:`Select accounts and set a password to protect the backup.`})]}),(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between mb-1`,children:[(0,$.jsx)(`p`,{className:`text-[11px] font-medium text-muted-foreground`,children:`Accounts to export`}),(0,$.jsx)(`button`,{className:`text-[10px] text-primary hover:underline cursor-pointer`,onClick:()=>c(s.size===a.length?new Set:new Set(a.map(e=>e.id))),children:s.size===a.length?`Deselect all`:`Select all`})]}),a.length===0?(0,$.jsx)(`p`,{className:`text-[10px] text-muted-foreground p-2 border rounded`,children:`No exportable accounts.`}):(0,$.jsx)(`div`,{className:`max-h-36 overflow-y-auto space-y-1 border rounded p-2`,children:a.map(e=>(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{type:`checkbox`,id:`exp-${e.id}`,checked:s.has(e.id),onChange:t=>{let n=new Set(s);t.target.checked?n.add(e.id):n.delete(e.id),c(n)},className:`size-3.5 accent-primary cursor-pointer`}),(0,$.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,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsxs)(q,{className:`text-xs`,children:[`Password `,(0,$.jsx)(`span`,{className:`text-muted-foreground font-normal`,children:`(optional)`})]}),(0,$.jsx)(I,{type:`password`,placeholder:`Leave empty for default`,value:l,onChange:e=>d(e.target.value),className:`text-xs h-8`,autoComplete:`new-password`})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{type:`checkbox`,id:`exp-full`,checked:f,onChange:e=>p(e.target.checked),className:`size-3.5 accent-primary cursor-pointer`}),(0,$.jsx)(`label`,{htmlFor:`exp-full`,className:`text-[11px] cursor-pointer`,children:`Include refresh tokens (full transfer)`})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{type:`checkbox`,id:`exp-refresh`,checked:m,onChange:e=>_(e.target.checked),className:`size-3.5 accent-primary cursor-pointer`}),(0,$.jsx)(`label`,{htmlFor:`exp-refresh`,className:`text-[11px] cursor-pointer`,children:`Refresh tokens before export`})]}),f?(0,$.jsxs)(`div`,{className:`rounded-md border border-error/30 bg-error/5 p-2.5`,children:[(0,$.jsx)(`p`,{className:`text-[10px] font-medium text-error`,children:`Full transfer — source accounts will expire`}),(0,$.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:`Refresh tokens included. Source machine expires in ~1h after target refreshes.`})]}):m?(0,$.jsx)(`div`,{className:`rounded-md border border-warning/30 bg-warning/5 p-2.5`,children:(0,$.jsx)(`p`,{className:`text-[10px] font-medium text-warning`,children:`Refresh before export — invalidates previous shares`})}):(0,$.jsx)(`div`,{className:`rounded-md border border-success/30 bg-success/5 p-2.5`,children:(0,$.jsx)(`p`,{className:`text-[10px] font-medium text-success`,children:`Share current token (safe)`})}),(0,$.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:`Encrypted with AES-256-GCM + scrypt.`})]}),(0,$.jsxs)(k,{className:`gap-1.5 flex-col sm:flex-row`,children:[(0,$.jsx)(D,{size:`sm`,variant:`outline`,className:`text-xs h-7 cursor-pointer`,onClick:C,children:`Cancel`}),(0,$.jsxs)(D,{size:`sm`,variant:`outline`,className:`text-xs h-7 cursor-pointer`,disabled:!T,onClick:()=>w(!0),children:[(0,$.jsx)(h,{className:`size-3 mr-1`}),` Copy`]}),(0,$.jsx)(D,{size:`sm`,className:`text-xs h-7 cursor-pointer`,disabled:!T,onClick:()=>w(!1),children:y?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(o,{className:`size-3 animate-spin mr-1`}),` Exporting...`]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(u,{className:`size-3 mr-1`}),` Download`]})})]})]})})}function Pe({open:e,onOpenChange:t,onSuccess:n}){let[r,i]=(0,Q.useState)(``),[a,s]=(0,Q.useState)(``),[c,l]=(0,Q.useState)(!1),[u,d]=(0,Q.useState)(null);function f(){t(!1),i(``),s(``),d(null)}async function p(){if(r.trim()){l(!0),d(null);try{let e=await ee({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,$.jsx)(N,{open:e,onOpenChange:e=>{e||f()},children:(0,$.jsxs)(A,{className:`sm:max-w-md`,children:[(0,$.jsxs)(O,{children:[(0,$.jsxs)(j,{className:`text-sm flex items-center gap-1.5`,children:[(0,$.jsx)(g,{className:`size-3.5`}),` Import Accounts`]}),(0,$.jsx)(M,{className:`text-xs`,children:`Paste backup data and enter the export password. Imported accounts are temporary (~1h).`})]}),(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(q,{className:`text-xs`,children:`Backup data`}),(0,$.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,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsxs)(q,{className:`text-xs`,children:[`Password `,(0,$.jsx)(`span`,{className:`text-muted-foreground font-normal`,children:`(optional)`})]}),(0,$.jsx)(I,{type:`password`,placeholder:`Leave empty for default`,value:a,onChange:e=>s(e.target.value),className:`text-xs h-8`,autoComplete:`current-password`})]})]}),u&&(0,$.jsx)(`div`,{className:`text-[11px] p-2 rounded bg-error/10 text-error`,children:u}),(0,$.jsxs)(k,{children:[(0,$.jsx)(D,{size:`sm`,variant:`outline`,className:`text-xs h-7 cursor-pointer`,onClick:f,children:`Cancel`}),(0,$.jsx)(D,{size:`sm`,className:`text-xs h-7 cursor-pointer`,disabled:!r.trim()||c,onClick:p,children:c?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(o,{className:`size-3 animate-spin mr-1`}),` Importing...`]}):`Import`})]})]})})}var Fe=typeof window<`u`?window.matchMedia(`(min-width: 768px)`):null;function Ie(e){return Fe?.addEventListener(`change`,e),()=>Fe?.removeEventListener(`change`,e)}function Le(){return Fe?.matches??!0}function Re(){let[e,t]=(0,Q.useState)(null),[n,r]=(0,Q.useState)(!0);return(0,Q.useEffect)(()=>{r(!0),ne().then(t).finally(()=>r(!1))},[]),n?(0,$.jsx)(`p`,{className:`text-xs text-text-subtle py-4 text-center`,children:`Loading...`}):e?(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(`label`,{className:`text-xs font-medium text-text-primary`,children:`Rotation Strategy`}),(0,$.jsxs)(W,{value:e.strategy,onValueChange:async e=>{t(await L({strategy:e}))},children:[(0,$.jsx)(ie,{className:`w-full h-9 text-xs`,children:(0,$.jsx)(ae,{})}),(0,$.jsxs)(G,{children:[(0,$.jsx)(K,{value:`round-robin`,children:`Round-robin`}),(0,$.jsx)(K,{value:`fill-first`,children:`Fill-first`}),(0,$.jsx)(K,{value:`lowest-usage`,children:`Lowest usage`})]})]}),(0,$.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,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(`label`,{className:`text-xs font-medium text-text-primary`,children:`Max Retry`}),(0,$.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 L({maxRetry:n}))}}),(0,$.jsx)(`p`,{className:`text-[10px] text-text-subtle`,children:`How many accounts to try on failure. 0 = try all available accounts.`})]}),(0,$.jsxs)(`div`,{className:`space-y-1.5 border-t border-border pt-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(`label`,{className:`text-xs font-medium text-text-primary`,children:`Cooldown parking`}),(0,$.jsx)(U,{checked:e.cooldownEnabled,onCheckedChange:async e=>{t(await L({cooldownEnabled:e}))}})]}),(0,$.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,$.jsxs)(`div`,{className:`flex items-center justify-between text-xs border-t border-border pt-3`,children:[(0,$.jsx)(`span`,{className:`text-text-subtle`,children:`Active accounts`}),(0,$.jsx)(`span`,{className:`font-medium text-text-primary`,children:e.activeCount})]})]}):(0,$.jsx)(`p`,{className:`text-xs text-text-subtle py-4 text-center`,children:`Failed to load settings`})}function ze({open:e,onOpenChange:t}){let n=(0,Q.useSyncExternalStore)(Ie,Le);return e?n?(0,$.jsx)(N,{open:e,onOpenChange:t,children:(0,$.jsxs)(A,{className:`sm:max-w-sm`,children:[(0,$.jsx)(O,{children:(0,$.jsxs)(j,{className:`text-sm flex items-center gap-2`,children:[(0,$.jsx)(_,{className:`size-4`}),` Rotation & Retry`]})}),(0,$.jsx)(Re,{})]})}):(0,$.jsxs)($.Fragment,{children:[(0,$.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,$.jsxs)(`div`,{className:b(`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,$.jsx)(`div`,{className:`flex justify-center pt-3 pb-1`,children:(0,$.jsx)(`div`,{className:`w-10 h-1 rounded-full bg-border`})}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-2 border-b border-border`,children:[(0,$.jsxs)(`span`,{className:`text-sm font-semibold flex items-center gap-2`,children:[(0,$.jsx)(_,{className:`size-4`}),` Rotation & Retry`]}),(0,$.jsx)(`button`,{onClick:()=>t(!1),className:`flex items-center justify-center size-7 rounded-md hover:bg-surface-elevated transition-colors`,children:(0,$.jsx)(p,{className:`size-4`})})]}),(0,$.jsx)(`div`,{className:`px-4 py-4 pb-8`,children:(0,$.jsx)(Re,{})})]})]}):null}var Be=E(`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 Ve({className:e,variant:t,...n}){return(0,$.jsx)(`div`,{className:b(Be({variant:t}),e),...n})}function He(e){let t=Math.floor(Date.now()/1e3);return e>t?`${Math.floor((e-t)/60)}m`:`exp`}function Ue({accounts:e}){let[t,n]=(0,Q.useState)([]),[r,i]=(0,Q.useState)(!1),[a,s]=(0,Q.useState)(!1),[c,l]=(0,Q.useState)(new Map),u=e.filter(e=>e.hasRefreshToken);async function d(){if(u.length!==0){i(!0);try{let e=await H(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 z(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 m(){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,$.jsxs)(`section`,{className:`border-t pt-4 space-y-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsx)(`p`,{className:`text-xs font-medium`,children:`Simulate export`}),t.length>0&&(0,$.jsxs)(`span`,{className:`text-[10px] text-muted-foreground`,children:[t.length,` round(s)`]})]}),(0,$.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,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No OAuth account with a refresh token to export.`}):(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(U,{id:`sim-include-refresh`,checked:a,onCheckedChange:s,className:`cursor-pointer`}),(0,$.jsx)(q,{htmlFor:`sim-include-refresh`,className:`text-[11px] cursor-pointer`,children:`Include refresh tokens`})]}),(0,$.jsx)(D,{size:`sm`,className:`h-7 text-xs cursor-pointer`,disabled:r,onClick:()=>void d(),children:r?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(o,{className:`size-3 animate-spin mr-1`}),` Exporting...`]}):`Run export #${t.length+1}`})]}),t.length>0&&(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsxs)(D,{size:`sm`,variant:`outline`,className:`w-full h-7 text-[11px] cursor-pointer`,onClick:m,children:[`Test all tokens (`,t.reduce((e,t)=>e+t.items.length*3,0),`)`]}),t.map(e=>(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsxs)(`p`,{className:`text-xs font-medium text-primary`,children:[`Round #`,e.round]}),(0,$.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:e.time}),(0,$.jsx)(Ve,{variant:e.includeRefresh?`destructive`:`secondary`,className:`text-[9px] px-1 py-0`,children:e.includeRefresh?`with refresh`:`access only`})]}),e.items.map(t=>(0,$.jsxs)(`div`,{className:`p-2 rounded-lg border bg-card space-y-1.5`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`text-[11px] font-medium`,children:t.label??t.email??t.id.slice(0,8)}),t.tokenChanged&&(0,$.jsx)(Ve,{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,$.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[11px]`,children:[(0,$.jsx)(`span`,{className:`w-20 shrink-0 text-muted-foreground text-[10px]`,children:e.label}),(0,$.jsx)(`code`,{className:`flex-1 truncate font-mono text-[10px] bg-muted px-1 rounded`,children:e.preview??`N/A`}),e.expires&&(0,$.jsx)(`span`,{className:`text-[10px] text-muted-foreground shrink-0`,children:He(e.expires)}),e.token?(0,$.jsx)(D,{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,$.jsx)(o,{className:`size-3 animate-spin`}):`Test`}):(0,$.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:`-`}),t&&!t.loading&&(0,$.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 We(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 Ge({open:e,onOpenChange:t,accounts:n}){let[i,a]=(0,Q.useState)(new Map),[s,c]=(0,Q.useState)(!1);async function l(e){a(t=>new Map(t).set(e,{loading:!0}));try{let t=await re(e,s);a(n=>new Map(n).set(e,{loading:!1,result:t}))}catch(t){a(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,$.jsx)(N,{open:e,onOpenChange:t,children:(0,$.jsxs)(A,{className:`sm:max-w-xl max-h-[85vh] flex flex-col`,children:[(0,$.jsxs)(O,{children:[(0,$.jsxs)(j,{className:`text-sm flex items-center gap-1.5`,children:[(0,$.jsx)(r,{className:`size-4`}),` Token Test`]}),(0,$.jsx)(M,{className:`text-xs`,children:`Probe stored tokens for validity. Nothing is modified.`})]}),(0,$.jsxs)(`div`,{className:`space-y-4 overflow-y-auto flex-1 pr-1`,children:[(0,$.jsxs)(`section`,{className:`space-y-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsx)(`p`,{className:`text-xs font-medium`,children:`Current tokens`}),(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(U,{id:`token-test-refresh`,checked:s,onCheckedChange:c,className:`cursor-pointer`}),(0,$.jsx)(q,{htmlFor:`token-test-refresh`,className:`text-[11px] cursor-pointer`,children:`Also test refresh`})]}),(0,$.jsx)(D,{size:`sm`,variant:`outline`,className:`h-7 text-xs cursor-pointer`,onClick:u,children:`Test all`})]})]}),n.length===0&&(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No accounts to test.`}),(0,$.jsx)(`div`,{className:`space-y-1.5`,children:n.map(e=>{let t=i.get(e.id),n=t?.result?.accessToken.status;return(0,$.jsxs)(`div`,{className:`p-2 rounded border bg-card space-y-1`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium truncate block`,children:e.label??e.email??e.id.slice(0,8)}),e.expiresAt&&(0,$.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:We(e.expiresAt)})]}),(0,$.jsx)(D,{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,$.jsx)(o,{className:`size-3 animate-spin`}):`Test`})]}),t&&!t.loading&&(0,$.jsxs)(`div`,{className:`text-[11px] pl-2 border-l-2 border-muted`,children:[t.error&&(0,$.jsx)(`p`,{className:`text-error`,children:t.error}),n&&(0,$.jsxs)(`span`,{className:n.startsWith(`valid`)?`text-success`:`text-error`,children:[n,t.result?.accessToken.code?` (${t.result.accessToken.code})`:``]})]})]},e.id)})})]}),(0,$.jsx)(Ue,{accounts:n})]}),(0,$.jsx)(k,{children:(0,$.jsx)(D,{size:`sm`,variant:`outline`,className:`text-xs cursor-pointer`,onClick:()=>t(!1),children:`Close`})})]})})}function Ke(){let{usages:e,accounts:t,activeAccountId:n,initialLoading:i,refreshing:s,flashIds:c,reload:l}=he(),[f,p]=(0,Q.useState)(null),[h,g]=(0,Q.useState)(null),[v,y]=(0,Q.useState)(null),[b,x]=(0,Q.useState)(null),[S,C]=(0,Q.useState)(null),[w,T]=(0,Q.useState)(null),[E,O]=(0,Q.useState)(null),[k,A]=(0,Q.useState)(void 0);function j(e){l(),e&&p(e)}async function M(e,t){g(e);try{await B(e,{status:t===`disabled`?`active`:`disabled`})}catch(e){p(e.message)}g(null),l()}async function N(){if(v){try{await V(v.id),p(`Account "${v.display}" removed.`),l()}catch(e){p(`Failed to remove: ${e.message}`)}y(null)}}async function P(e){b&&(await B(b.id,{label:e}),x(null),p(`Account renamed to "${e}".`),l())}let F=new Map(t.map(e=>[e.id,e])),I=e[0]?.usage.lastFetchedAt;return(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsx)(_e,{description:`Connect multiple Claude accounts. PPM rotates between them automatically to avoid rate limits.`,onRefresh:()=>void l(),refreshing:s,disabled:i,actions:(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(D,{size:`sm`,className:`cursor-pointer gap-1.5`,onClick:()=>{A(void 0),O(`add`)},children:[(0,$.jsx)(d,{className:`size-4`}),` Add account`]}),(0,$.jsxs)(D,{size:`sm`,variant:`outline`,className:`cursor-pointer gap-1.5`,onClick:()=>{T(null),O(`export`)},children:[(0,$.jsx)(u,{className:`size-4`}),` Export`]}),(0,$.jsxs)(D,{size:`sm`,variant:`outline`,className:`cursor-pointer gap-1.5`,onClick:()=>O(`import`),children:[(0,$.jsx)(a,{className:`size-4`}),` Import`]}),(0,$.jsxs)(D,{size:`sm`,variant:`outline`,className:`cursor-pointer gap-1.5`,onClick:()=>O(`rotation`),children:[(0,$.jsx)(_,{className:`size-4`}),` Rotation`]}),(0,$.jsxs)(D,{size:`sm`,variant:`outline`,className:`cursor-pointer gap-1.5`,onClick:()=>O(`token-test`),children:[(0,$.jsx)(r,{className:`size-4`}),` Token test`]})]})}),(0,$.jsx)(le,{message:f,onDismiss:()=>p(null)}),(0,$.jsxs)(`section`,{className:`space-y-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-medium`,children:`Accounts`}),I&&(0,$.jsxs)(`span`,{className:`text-[10px] text-muted-foreground`,children:[`usage `,ce(new Date(I).getTime())]})]}),i?(0,$.jsxs)(`div`,{className:`flex items-center gap-2 py-6 text-xs text-muted-foreground`,children:[(0,$.jsx)(o,{className:`size-4 animate-spin`}),` Loading accounts...`]}):e.length===0?(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-2 py-8 text-center`,children:[(0,$.jsx)(m,{className:`size-5 text-muted-foreground`}),(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No accounts connected yet.`}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Add one to start using PPM.`})]}):(0,$.jsx)(se,{children:e.map(e=>(0,$.jsx)(ge,{layout:`strip`,entry:e,isActive:e.accountId===n,accountInfo:F.get(e.accountId),onToggle:M,toggling:h===e.accountId,onDelete:(e,t)=>y({id:e,display:t}),onRename:(e,t)=>x({id:e,current:t}),onExport:e=>{T(e),O(`export`)},onViewProfile:(e,t)=>C({profile:e,accountId:t}),onReauth:()=>{A({id:e.accountId,label:e.accountLabel??e.accountId.slice(0,8)}),O(`add`)},flash:c.has(e.accountId)},e.accountId))})]}),S&&(0,$.jsx)(Oe,{profile:S.profile,accountId:S.accountId,onClose:()=>C(null)}),v&&(0,$.jsx)(ke,{display:v.display,onConfirm:()=>void N(),onCancel:()=>y(null)}),b&&(0,$.jsx)(je,{current:b.current,onSave:P,onCancel:()=>x(null)}),(0,$.jsx)(ye,{open:E===`add`,onOpenChange:e=>{O(e?`add`:null),e||A(void 0)},onSuccess:j,signInAgainFor:k}),(0,$.jsx)(Ne,{open:E===`export`,onOpenChange:e=>{O(e?`export`:null),e||T(null)},accounts:t,preselectId:w,onMessage:p}),(0,$.jsx)(Pe,{open:E===`import`,onOpenChange:e=>O(e?`import`:null),onSuccess:j}),(0,$.jsx)(ze,{open:E===`rotation`,onOpenChange:e=>O(e?`rotation`:null)}),(0,$.jsx)(Ge,{open:E===`token-test`,onOpenChange:e=>O(e?`token-test`:null),accounts:t})]})}function qe({mode:e,onOpenChange:t,password:n,onPasswordChange:r,busy:i,onExport:s,onImport:c,error:l}){let d=(0,Q.useRef)(null),f=e===`export`;return(0,$.jsx)(N,{open:e!==null,onOpenChange:t,children:(0,$.jsxs)(A,{className:`sm:max-w-md`,children:[(0,$.jsxs)(O,{children:[(0,$.jsxs)(j,{className:`text-sm flex items-center gap-1.5`,children:[(0,$.jsx)(g,{className:`size-4`}),` `,f?`Export Codex Accounts`:`Import Codex Accounts`]}),(0,$.jsx)(M,{className:`text-xs leading-relaxed`,children:f?`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,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(q,{htmlFor:`codex-backup-password`,className:`text-xs`,children:`Password`}),(0,$.jsx)(I,{id:`codex-backup-password`,type:`password`,placeholder:f?`Choose a password`:`Password used for the export`,value:n,onChange:e=>r(e.target.value),className:`text-xs`,autoComplete:f?`new-password`:`current-password`}),(0,$.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:`A backup holds full logins — keep the file and its password together.`})]}),l&&(0,$.jsx)(`div`,{className:`text-[11px] p-2 rounded bg-error/10 text-error`,children:l}),(0,$.jsx)(`input`,{ref:d,type:`file`,accept:`application/json,.json`,className:`hidden`,onChange:e=>{let t=e.target.files?.[0];e.target.value=``,t&&c(t)}}),(0,$.jsxs)(k,{children:[(0,$.jsx)(D,{size:`sm`,variant:`outline`,className:`text-xs cursor-pointer`,onClick:()=>t(!1),children:`Cancel`}),(0,$.jsxs)(D,{size:`sm`,className:`text-xs cursor-pointer gap-1.5`,disabled:!n.trim()||i,onClick:()=>f?s():d.current?.click(),children:[i?(0,$.jsx)(o,{className:`size-3.5 animate-spin`}):f?(0,$.jsx)(u,{className:`size-3.5`}):(0,$.jsx)(a,{className:`size-3.5`}),f?`Download backup`:`Choose file`]})]})]})})}var Je=[{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 Ye({open:e,onOpenChange:t,strategy:n,onChange:r}){return(0,$.jsx)(N,{open:e,onOpenChange:t,children:(0,$.jsxs)(A,{className:`sm:max-w-md`,children:[(0,$.jsxs)(O,{children:[(0,$.jsx)(j,{className:`text-sm`,children:`Codex Rotation`}),(0,$.jsx)(M,{className:`text-xs leading-relaxed`,children:`How a new chat chooses among your Codex accounts.`})]}),(0,$.jsx)(`div`,{className:`space-y-2`,children:Je.map(e=>(0,$.jsxs)(`button`,{type:`button`,onClick:()=>r(e.value),"aria-current":n===e.value?`true`:void 0,className:b(`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,$.jsx)(`p`,{className:`text-sm font-medium`,children:e.label}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.hint})]},e.value))}),(0,$.jsx)(k,{children:(0,$.jsx)(D,{size:`sm`,variant:`outline`,className:`text-xs cursor-pointer`,onClick:()=>t(!1),children:`Done`})})]})})}function Xe(e){return e==null?null:Math.round(e*100)}function Ze({usage:e}){let t=e.session==null&&e.weekly==null;return(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(t||e.session!=null)&&(0,$.jsx)(ue,{label:`5-Hour Session`,pct:Xe(e.fiveHour),reset:oe(e.session),resetsAt:e.session?.resetsAt}),(t||e.weekly!=null)&&(0,$.jsx)(ue,{label:`Weekly`,pct:Xe(e.sevenDay),reset:oe(e.weekly),resetsAt:e.weekly?.resetsAt})]})}function Qe(e){let t=e=>Math.round((e??0)*100)>=100;return t(e.session?.utilization)||t(e.weekly?.utilization)}function $e(e){return Qe(e)&&(e.resetCredits?.available??0)>0}var et={reset:e=>`${e}: limits reset to 0%. The weekly reset date now counts from your next use.`,nothingToReset:e=>`${e}: nothing needed resetting, so the reset was kept.`,noCredit:e=>`${e} has no free reset left.`,alreadyRedeemed:e=>`${e}: that reset had already been used.`};function tt(e){return e?new Date(e).toLocaleString(void 0,{dateStyle:`medium`,timeStyle:`short`}):null}function nt({account:e,usage:t,onDone:n}){let r=T(),[i,a]=(0,Q.useState)(!1),[c,l]=(0,Q.useState)(!1);if(!$e(t))return null;let u=t.resetCredits;async function d(){l(!0);try{let t=await y.post(`/api/codex-accounts/${e.id}/reset-credit`);n(et[t.outcome]?.(e.label)??`${e.label}: ${t.outcome}`)}catch(e){n(e.message||`Could not use the reset`)}finally{l(!1),a(!1)}}let f=tt(t.weekly?.resetsAt),p=tt(u.nextExpiresAt),m=(0,$.jsxs)(`div`,{className:`space-y-3`,"data-testid":`codex-reset-credit-confirm`,children:[(0,$.jsxs)(`p`,{className:`text-sm`,children:[`Use 1 of `,(0,$.jsx)(`span`,{className:`font-medium`,children:e.label}),`'s `,u.available,` free reset`,u.available===1?``:`s`,`?`]}),(0,$.jsxs)(`ul`,{className:`text-xs text-text-secondary space-y-1.5 list-disc pl-4`,children:[(0,$.jsxs)(`li`,{children:[u.title??`Full reset`,`: the 5-hour and weekly usage go back to 0% now.`]}),(0,$.jsxs)(`li`,{children:[`The weekly reset date moves: the next one is about 7 days after you continue using Codex`,f?`, not ${f} as now`:``,`. You do not also get that one.`]}),p&&(0,$.jsxs)(`li`,{children:[`This spends the reset that expires first (`,p,`).`]})]}),(0,$.jsxs)(`div`,{className:`flex flex-col-reverse md:flex-row gap-2 md:justify-end pt-1`,children:[(0,$.jsx)(D,{variant:`outline`,onClick:()=>a(!1),disabled:c,className:`min-h-11`,children:`Keep it`}),(0,$.jsxs)(D,{onClick:()=>void d(),disabled:c,className:`min-h-11 gap-1.5`,children:[c?(0,$.jsx)(o,{className:`size-4 animate-spin`}):(0,$.jsx)(s,{className:`size-4`}),`Use reset`]})]})]});return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(D,{size:`sm`,variant:`outline`,className:`min-h-11 md:min-h-0 md:h-7 gap-1 px-2 text-[11px] cursor-pointer border-primary/40 text-primary`,onClick:()=>a(!0),disabled:c,children:[(0,$.jsx)(s,{className:`size-3.5`}),` Use reset`]}),i&&(r?(0,$.jsx)(w,{open:!0,onClose:()=>{c||a(!1)},children:(0,$.jsxs)(`div`,{className:`px-4 pb-4`,children:[(0,$.jsx)(`h2`,{className:`text-base font-semibold mb-3`,children:`Use a free reset`}),m]})}):(0,$.jsx)(N,{open:!0,onOpenChange:e=>{!e&&!c&&a(!1)},children:(0,$.jsxs)(A,{className:`sm:max-w-sm`,children:[(0,$.jsx)(O,{children:(0,$.jsx)(j,{className:`text-sm`,children:`Use a free reset`})}),m]})}))]})}var rt=1440*60*1e3,it=7,at=5;function ot(e,t=Date.now()){if(!e||e.windowHours!==168)return null;let n=new Date(e.resetsAt).getTime();if(!Number.isFinite(t)||!Number.isFinite(n)||n<=t)return null;let r=n-it*rt;if(t<r)return null;let i=Math.min(it-1,Math.floor((t-r)/rt)),a=0;for(let e=0;e<=i;e++){let t=new Date(r+e*rt).getUTCDay();t!==0&&t!==6&&a++}let o=a/at;return{day:a,cap:o,used:e.utilization,blocked:e.utilization>=o}}function st(){let[e,t]=(0,Q.useState)(null),n=de(()=>t(null)),[r,s]=(0,Q.useState)(null);return(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsx)(_e,{description:(0,$.jsxs)($.Fragment,{children:[`Each Codex account keeps its own login (`,(0,$.jsx)(`code`,{children:`CODEX_HOME`}),`). One is picked per chat by the rotation setting.`]}),onRefresh:()=>void n.load(),refreshing:n.loading,actions:(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(D,{size:`sm`,className:`cursor-pointer gap-1.5`,onClick:()=>t(`add`),children:[(0,$.jsx)(d,{className:`size-4`}),` Add account`]}),(0,$.jsxs)(D,{size:`sm`,variant:`outline`,className:`cursor-pointer gap-1.5`,onClick:()=>t(`export`),children:[(0,$.jsx)(u,{className:`size-4`}),` Export`]}),(0,$.jsxs)(D,{size:`sm`,variant:`outline`,className:`cursor-pointer gap-1.5`,onClick:()=>t(`import`),children:[(0,$.jsx)(a,{className:`size-4`}),` Import`]}),(0,$.jsxs)(D,{size:`sm`,variant:`outline`,className:`cursor-pointer gap-1.5`,onClick:()=>t(`rotation`),children:[(0,$.jsx)(_,{className:`size-4`}),` Rotation`]})]})}),(0,$.jsx)(le,{message:n.msg??n.err,onDismiss:()=>{n.setMsg(null),n.setErr(null)}}),(0,$.jsxs)(`section`,{className:`space-y-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-medium`,children:`Codex Accounts`}),(0,$.jsx)(`span`,{className:`text-[10px] text-muted-foreground capitalize`,children:n.strategy.replace(`-`,` `)})]}),n.loading&&n.accounts.length===0?(0,$.jsxs)(`div`,{className:`flex items-center gap-2 py-6 text-xs text-muted-foreground`,children:[(0,$.jsx)(o,{className:`size-4 animate-spin`}),` Loading accounts...`]}):n.accounts.length===0?(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-2 py-8 text-center`,children:[(0,$.jsx)(m,{className:`size-5 text-muted-foreground`}),(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No Codex accounts yet.`}),(0,$.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Chats use your default `,(0,$.jsx)(`code`,{children:`~/.codex`}),` login until you add one.`]})]}):(0,$.jsx)(se,{children:n.accounts.map(e=>{let t=n.usages[e.id]??{};return(0,$.jsxs)(me,{dense:!0,className:`min-w-[300px] shrink-0 snap-start${e.signedOut?` opacity-60`:``}`,"data-testid":`account-card`,"data-account-id":e.id,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`text-sm font-medium truncate flex-1 min-w-0`,children:e.label}),e.signedOut&&(0,$.jsx)(fe,{className:`text-[10px] text-error shrink-0 font-medium`,hint:`Codex rejected this account's login (revoked or expired), so no turn can run on it and it is skipped. The usage shown is the last reading. Click to sign in again — the account keeps its settings and chats.`,onClick:e.type===`chatgpt`?()=>s(e):void 0,children:`Sign in again`}),(0,$.jsx)(`span`,{className:`text-[10px] uppercase tracking-wide text-text-subtle border border-border rounded px-1 shrink-0`,children:e.type}),Y(e.planType)&&(0,$.jsx)(`span`,{className:`text-[10px] text-text-subtle shrink-0`,children:Y(e.planType)}),(0,$.jsx)(U,{checked:e.status!==`disabled`,onCheckedChange:()=>void n.toggle(e.id,e.status??`active`),disabled:n.toggling.has(e.id),"aria-label":e.status===`disabled`?`Enable account`:`Disable account`,className:`cursor-pointer shrink-0`}),(0,$.jsxs)(C,{children:[(0,$.jsx)(x,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,onClick:()=>void n.remove(e.id),"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,$.jsx)(f,{className:`size-4`})})}),(0,$.jsx)(S,{side:`top`,children:`Remove account`})]})]}),(0,$.jsx)(Ze,{usage:t}),t.resetCredits&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap text-[10px] text-text-subtle`,children:[(0,$.jsx)(X,{credits:t.resetCredits}),(0,$.jsx)(nt,{account:e,usage:t,onDone:e=>{n.setMsg(e),n.load()}})]}),t.session==null&&(()=>{let r=ot(t.weekly);return r?(0,$.jsxs)(`div`,{className:`flex min-h-12 items-center justify-between gap-3 rounded-md border px-2.5 py-1.5 ${e.dailyGuardEnabled&&r.blocked?`border-error/40 bg-error/5`:`border-border/50 bg-surface/40`}`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 space-y-0.5`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs font-medium ${e.dailyGuardEnabled&&r.blocked?`text-error`:`text-text-secondary`}`,children:[(0,$.jsx)(`span`,{children:`Daily guard`}),(0,$.jsxs)(C,{children:[(0,$.jsx)(x,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,"aria-label":`About Daily guard`,className:`text-text-subtle hover:text-text-primary cursor-help`,children:(0,$.jsx)(i,{className:`size-3.5`})})}),(0,$.jsx)(S,{side:`top`,className:`max-w-64 text-xs leading-relaxed`,children:`Spreads the weekly quota across five weekdays, adding 20% per weekday. Weekend slots keep the previous cap; unused allowance carries forward. Daily slots start at the reset time and use UTC weekdays. Turn it off any time to use the remaining quota freely.`})]})]}),(0,$.jsx)(`p`,{className:`text-[10px] tabular-nums ${e.dailyGuardEnabled&&r.blocked?`text-error`:`text-text-subtle`}`,children:e.dailyGuardEnabled&&r.blocked?`${Math.round(r.used*100)}% used / ${Math.round(r.cap*100)}% daily cap. New turns paused.`:`Weekday ${r.day}/5, ${Math.round(r.cap*100)}% daily cap`})]}),(0,$.jsxs)(`span`,{className:`hidden`,title:`Weekday ${r.day}/5: hold weekly usage at or below ${Math.round(r.cap*100)}% to last until reset.`,children:[`Daily guard `,e.dailyGuardEnabled?`· Weekday ${r.day}/5 cap ${Math.round(r.cap*100)}%`:``]}),(0,$.jsx)(U,{checked:!!e.dailyGuardEnabled,onCheckedChange:()=>void n.toggleDailyGuard(e.id,!!e.dailyGuardEnabled),disabled:n.toggling.has(e.id),"aria-label":e.dailyGuardEnabled?`Disable Daily guard`:`Enable Daily guard`,className:`cursor-pointer shrink-0`})]}):null})()]},e.id)})})]}),(0,$.jsx)(J,{open:e===`add`,onOpenChange:e=>{e||n.cancelLogin(),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,browser:n.browser,onStartBrowser:()=>void n.startBrowser(),loginStarting:n.loginStarting,callbackUrl:n.callbackUrl,onCallbackUrlChange:n.setCallbackUrl,submittingCallback:n.submittingCallback,onSubmitCallback:()=>void n.submitCallback(),error:n.err}),(0,$.jsx)(qe,{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}),r&&(0,$.jsx)(Z,{account:r,onClose:()=>s(null),onDone:()=>void n.load()}),(0,$.jsx)(Ye,{open:e===`rotation`,onOpenChange:e=>t(e?`rotation`:null),strategy:n.strategy,onChange:e=>void n.changeStrategy(e)})]})}var ct=[{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 lt(e){return e==null?null:Math.round(e*100)}function ut(){let[e,t]=(0,Q.useState)([]),[n,r]=(0,Q.useState)(`round-robin`),[i,a]=(0,Q.useState)({}),[s,u]=(0,Q.useState)(!0),[p,h]=(0,Q.useState)(null),[g,v]=(0,Q.useState)(null),[w,T]=(0,Q.useState)(new Set),[E,P]=(0,Q.useState)(null),[F,L]=(0,Q.useState)(null),[R,z]=(0,Q.useState)(``),[B,ee]=(0,Q.useState)(null),[te,ne]=(0,Q.useState)(!1),[V,re]=(0,Q.useState)(``),[H,ie]=(0,Q.useState)(!1),[ae,W]=(0,Q.useState)(null),G=(0,Q.useRef)(0),K=(0,Q.useRef)(!1),J=(0,Q.useRef)(!1),Y=(0,Q.useRef)(null),de=(0,Q.useRef)(null),X=(0,Q.useCallback)(async()=>{u(!0),v(null);try{let e=await y.get(`/api/antigravity-accounts`);t(e.accounts),r(e.strategy),a(await y.get(`/api/antigravity-accounts/usage`))}catch(e){v(e.message)}finally{u(!1)}},[]);(0,Q.useEffect)(()=>{X()},[X]);let fe=(0,Q.useCallback)(()=>{G.current+=1,K.current=!1,J.current=!1,de.current?.(),de.current=null;let e=Y.current;Y.current=null,e&&y.del(`/api/antigravity-accounts/login/${e}`).catch(()=>{})},[]);(0,Q.useEffect)(()=>fe,[fe]);let Z=(0,Q.useCallback)(()=>{fe(),ee(null),ne(!1),re(``),ie(!1)},[fe]),he=(0,Q.useCallback)(()=>{Z(),W(null),z(``),L(null),P(null)},[Z]),ge=(0,Q.useCallback)(e=>{let t=Date.now()+61e4,n=!1,r;de.current=()=>{n=!0,clearTimeout(r)};let i=async()=>{if(n)return;let a=null;try{a=await y.get(`/api/antigravity-accounts/login/${e}/status`)}catch{}if(!n){if(a?.state===`done`){Y.current=null,Z(),W(null),z(``),L(null),P(null),h(`Antigravity Google account connected.`),await X();return}if(a?.state===`error`||Date.now()>t){Y.current=null,Z(),W(a?.state===`error`?a.error??`Login failed.`:`Login timed out.`);return}r=setTimeout(i,2e3)}};i()},[X,Z]),ye=(0,Q.useCallback)(async e=>{if(K.current||Y.current||J.current)return;K.current=!0;let t=++G.current;ne(!0),W(null);try{let n=await y.post(`/api/antigravity-accounts/login`,{...R.trim()?{label:R.trim()}:{},...e?{accountId:e.id}:{}});if(t!==G.current){y.del(`/api/antigravity-accounts/login/${n.id}`).catch(()=>{});return}Y.current=n.id,ee(n),ge(n.id)}catch(e){t===G.current&&W(e.message)}finally{t===G.current&&(K.current=!1,ne(!1))}},[R,ge]),be=(0,Q.useCallback)(async()=>{if(!B||!V.trim()||J.current)return;let e=G.current;J.current=!0,ie(!0),W(null);try{let t=await y.post(`/api/antigravity-accounts/login/${B.id}/callback`,{code:V.trim()});if(e!==G.current)return;if(t?.state===`error`){Y.current=null,Z(),W(t.error??`Login failed.`);return}if(t?.state!==`done`)return;Y.current=null,Z(),z(``),L(null),P(null),h(`Antigravity Google account connected.`),await X()}catch(t){e===G.current&&(Y.current=null,Z(),W(t.message))}finally{e===G.current&&(J.current=!1,ie(!1))}},[B,V,X,Z]),xe=(0,Q.useCallback)(async(e,n)=>{T(t=>new Set(t).add(e)),v(null);try{let r=n===`disabled`?`active`:`disabled`;await y.patch(`/api/antigravity-accounts/${e}`,{status:r}),t(t=>t.map(t=>t.id===e?{...t,status:r}:t))}catch(e){v(e.message)}finally{T(t=>{let n=new Set(t);return n.delete(e),n})}},[]),Se=(0,Q.useCallback)(async e=>{v(null);try{await y.del(`/api/antigravity-accounts/${e}`),t(t=>t.filter(t=>t.id!==e))}catch(e){v(e.message)}},[]),Ce=(0,Q.useCallback)(async e=>{v(null);try{await y.put(`/api/antigravity-accounts/strategy`,{strategy:e}),r(e)}catch(e){v(e.message)}},[]),we=(0,Q.useCallback)(e=>{L(e),z(e.label),P(`add`)},[]);return(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsx)(_e,{description:(0,$.jsxs)($.Fragment,{children:[`Each Antigravity account keeps its own Google OAuth login (`,(0,$.jsx)(`code`,{children:`~/.ppm/antigravity-accounts`}),`) alongside your local IDE login (`,(0,$.jsx)(`code`,{children:`~/.gemini`}),`). One is picked per chat by the rotation setting.`]}),onRefresh:()=>void X(),refreshing:s,actions:(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(D,{size:`sm`,className:`cursor-pointer gap-1.5`,onClick:()=>{L(null),z(``),P(`add`)},children:[(0,$.jsx)(d,{className:`size-4`}),` Add account`]}),(0,$.jsxs)(D,{size:`sm`,variant:`outline`,className:`cursor-pointer gap-1.5`,onClick:()=>P(`rotation`),children:[(0,$.jsx)(_,{className:`size-4`}),` Rotation`]})]})}),(0,$.jsx)(le,{message:p??g,onDismiss:()=>{h(null),v(null)}}),(0,$.jsxs)(`section`,{className:`space-y-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-medium`,children:`Antigravity Accounts`}),(0,$.jsx)(`span`,{className:`text-[10px] text-muted-foreground capitalize`,children:n.replace(`-`,` `)})]}),s&&e.length===0?(0,$.jsxs)(`div`,{className:`flex items-center gap-2 py-6 text-xs text-muted-foreground`,children:[(0,$.jsx)(o,{className:`size-4 animate-spin`}),` Loading accounts...`]}):e.length===0?(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-2 py-8 text-center`,children:[(0,$.jsx)(m,{className:`size-5 text-muted-foreground`}),(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No Antigravity accounts yet.`}),(0,$.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Click `,(0,$.jsx)(`strong`,{children:`Add account`}),` to sign in with Google, or start Antigravity Desktop to auto-detect your local account.`]})]}):(0,$.jsx)(se,{children:e.map(e=>{let t=ve(i[e.id]??{}),n=t.session==null&&t.weekly==null&&(!t.weeklyScoped||t.weeklyScoped.length===0),r=e.id===`default`;return(0,$.jsxs)(me,{dense:!0,className:`min-w-[320px] shrink-0 snap-start`,"data-testid":`account-card`,"data-account-id":e.id,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,$.jsx)(`div`,{className:`text-sm font-medium truncate`,children:e.label}),e.email&&e.email!==e.label&&(0,$.jsx)(`div`,{className:`text-[11px] text-text-subtle truncate`,children:e.email})]}),(0,$.jsx)(`span`,{className:`text-[10px] uppercase tracking-wide text-text-subtle border border-border rounded px-1 shrink-0`,children:r?`~/.gemini`:`Google`}),e.planType&&(0,$.jsx)(`span`,{className:`text-[10px] font-medium text-primary bg-primary/10 border border-primary/20 rounded px-1.5 py-0.5 shrink-0`,children:e.planType}),(0,$.jsx)(U,{checked:e.status!==`disabled`,onCheckedChange:()=>void xe(e.id,e.status),disabled:w.has(e.id),"aria-label":e.status===`disabled`?`Enable account`:`Disable account`,className:`cursor-pointer shrink-0`}),!r&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(C,{children:[(0,$.jsx)(x,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,onClick:()=>we(e),"aria-label":`Sign in again`,className:`p-1.5 rounded cursor-pointer text-text-subtle hover:text-foreground hover:bg-surface-elevated transition-colors shrink-0`,children:(0,$.jsx)(c,{className:`size-3.5`})})}),(0,$.jsx)(S,{side:`top`,children:`Sign in again`})]}),(0,$.jsxs)(C,{children:[(0,$.jsx)(x,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,onClick:()=>void Se(e.id),"aria-label":`Remove account`,className:`p-1.5 rounded cursor-pointer text-text-subtle hover:text-error hover:bg-surface-elevated transition-colors shrink-0`,children:(0,$.jsx)(f,{className:`size-4`})})}),(0,$.jsx)(S,{side:`top`,children:`Remove account`})]})]})]}),(0,$.jsxs)(`div`,{className:`space-y-2 pt-1`,children:[(n||t.session!=null)&&(0,$.jsx)(ue,{label:`Gemini · 5-Hour Session`,pct:lt(t.fiveHour),reset:oe(t.session),resetsAt:t.session?.resetsAt}),(n||t.weekly!=null)&&(0,$.jsx)(ue,{label:`Gemini · Weekly`,pct:lt(t.sevenDay),reset:oe(t.weekly),resetsAt:t.weekly?.resetsAt}),t.weeklyScoped?.map(e=>(0,$.jsx)(ue,{label:e.label,pct:lt(e.utilization),reset:oe(e),resetsAt:e.resetsAt},e.label))]}),t.lastFetchedAt&&pe(t.lastFetchedAt)&&(0,$.jsxs)(`p`,{className:`text-[10px] text-warning`,children:[`Last read `,ce(Date.parse(t.lastFetchedAt)),`. Neither agy nor the Antigravity app has answered since.`]})]},e.id)})})]}),(0,$.jsx)(N,{open:E===`add`,onOpenChange:e=>{e||he()},children:(0,$.jsxs)(A,{className:`sm:max-w-md max-h-[90dvh] overflow-y-auto`,children:[(0,$.jsxs)(O,{children:[(0,$.jsx)(j,{className:`text-sm`,children:F?`Sign in again — ${F.label}`:`Add Antigravity Account`}),(0,$.jsx)(M,{className:`text-xs leading-relaxed`,children:F?`Sign in with Google to refresh this account's OAuth credentials.`:`Sign in with a Google account using Antigravity's OAuth PKCE flow. Each account is stored in its own isolated directory.`})]}),(0,$.jsxs)(`div`,{className:`space-y-3`,children:[!F&&(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(q,{htmlFor:`agy-label`,className:`text-xs`,children:`Label (optional)`}),(0,$.jsx)(I,{id:`agy-label`,placeholder:`e.g. Personal, Work, Shopee 2`,value:R,onChange:e=>z(e.target.value),disabled:te||H,className:`text-xs`})]}),(0,$.jsxs)(`div`,{className:`rounded-md border p-3 space-y-2.5`,children:[(0,$.jsx)(`p`,{className:`text-[11px] font-medium`,children:`Google OAuth Sign-In`}),B?(0,$.jsxs)(`div`,{className:`space-y-2.5 text-xs`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsxs)(`a`,{href:B.authUrl,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1.5 font-medium text-primary hover:underline`,children:[(0,$.jsx)(l,{className:`size-3.5`}),` Open Google Sign-In page`]}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>{Z(),W(null)},disabled:H,className:`text-[11px] text-muted-foreground hover:text-foreground underline cursor-pointer`,children:`Start over`})]}),(0,$.jsxs)(`p`,{className:`text-muted-foreground leading-relaxed`,children:[`1. Open the link above and sign in with your Google account.`,(0,$.jsx)(`br`,{}),`2. Copy the authorization code (or the full callback URL) shown after signing in and paste it below:`]}),(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(q,{htmlFor:`agy-auth-code`,className:`text-xs`,children:`Authorization Code or Callback URL`}),(0,$.jsx)(I,{id:`agy-auth-code`,type:`text`,autoComplete:`off`,spellCheck:!1,placeholder:`4/0A... or https://antigravity.google/oauth-callback?code=...`,value:V,onChange:e=>re(e.target.value),disabled:H,className:`text-xs font-mono`})]}),(0,$.jsxs)(D,{size:`sm`,className:`w-full cursor-pointer gap-1.5`,onClick:()=>void be(),disabled:!V.trim()||H,children:[H&&(0,$.jsx)(o,{className:`size-3.5 animate-spin`}),`Verify & Save Account`]})]}):(0,$.jsx)(D,{size:`sm`,className:`w-full cursor-pointer gap-1.5`,onClick:()=>void ye(F),disabled:te,children:te?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(o,{className:`size-4 animate-spin`}),` Generating Google sign-in link...`]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(l,{className:`size-4`}),` Sign in with Google`]})})]})]}),ae&&(0,$.jsx)(`div`,{role:`alert`,className:`text-[11px] p-2 rounded bg-error/10 text-error`,children:ae}),(0,$.jsx)(k,{children:(0,$.jsx)(D,{size:`sm`,variant:`outline`,className:`text-xs cursor-pointer`,onClick:he,children:`Cancel`})})]})}),(0,$.jsx)(N,{open:E===`rotation`,onOpenChange:e=>P(e?`rotation`:null),children:(0,$.jsxs)(A,{className:`sm:max-w-md`,children:[(0,$.jsxs)(O,{children:[(0,$.jsx)(j,{className:`text-sm`,children:`Antigravity Rotation`}),(0,$.jsx)(M,{className:`text-xs leading-relaxed`,children:`How a new chat chooses among your enabled Antigravity accounts.`})]}),(0,$.jsx)(`div`,{className:`space-y-2`,children:ct.map(e=>(0,$.jsxs)(`button`,{type:`button`,onClick:()=>void Ce(e.value),"aria-current":n===e.value?`true`:void 0,className:b(`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,$.jsx)(`p`,{className:`text-sm font-medium`,children:e.label}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.hint})]},e.value))}),(0,$.jsx)(k,{children:(0,$.jsx)(D,{size:`sm`,variant:`outline`,className:`text-xs cursor-pointer`,onClick:()=>P(null),children:`Done`})})]})})]})}var dt=[{id:`claude`,label:`Claude`},{id:`codex`,label:`Codex`},{id:`antigravity`,label:`Antigravity`}];function ft(){let[e,t]=(0,Q.useState)(null),[n,r]=(0,Q.useState)(`claude`);(0,Q.useEffect)(()=>{let e=!1;return R().then(n=>{e||t(new Set(Object.keys(n.providers??{})))}).catch(()=>{e||t(new Set([`claude`]))}),()=>{e=!0}},[]);let i=dt.filter(t=>t.id===`claude`||e?.has(t.id)),a=i.length>1;return(0,$.jsxs)(`div`,{className:`space-y-4`,"data-testid":`accounts-pane`,"data-provider":n,children:[a&&(0,$.jsx)(`div`,{className:`flex gap-1 border-b border-border/50`,children:i.map(e=>(0,$.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,$.jsx)(P,{providerId:e.id}),e.label]},e.id))}),e===null&&!a&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,$.jsx)(o,{className:`size-3 animate-spin`}),` Checking configured providers...`]}),n===`claude`?(0,$.jsx)(Ke,{}):n===`codex`?(0,$.jsx)(st,{}):(0,$.jsx)(ut,{})]})}export{ft as AccountsSettingsSection};
1
+ import{s as e}from"./rolldown-runtime-C5c2KzVm.js";import{D as t,E as n}from"./vendor-markdown-WX6NXGTJ.js";import"./vendor-ui-XWGn718B.js";import{At as r,J as i,Qr as a,Sn as o,_r as s,gr as c,gt as l,ht as u,lr as d,qr as f,ui as p,un as m,ut as h,wn as g,wr as _}from"./icons-CXY5ue_g.js";import{a as v,r as y}from"./api-client-vI7TyFOL.js";import{n as b}from"./utils-DMiycH3O.js";import"./portal-container-context-tAk8C8AE.js";import{i as x,n as S,t as C}from"./tooltip-CCx1ynhU.js";import{t as w}from"./mobile-bottom-sheet-CR0IYSBI.js";import"./use-visual-viewport-CFeFggvP.js";import{n as T}from"./use-is-mobile-_O8suyE-.js";import{r as E,t as D}from"./button-BCTqB-tu.js";import{a as O,i as k,n as A,o as j,r as M,t as N}from"./dialog-CoO-z2qj.js";import"./chat-preparation-cache-BjKMLTNJ.js";import"./provider-logos-m5ZC_yzc.js";import{t as P}from"./provider-selector-DcPsEA72.js";import{r as F}from"./clipboard-SyUe4kh-.js";import{t as I}from"./input-CcBfRi6-.js";import{S as L,a as R,b as z,g as B,h as ee,m as te,o as ne,r as V,v as re,y as H}from"./api-settings-D4cXrjrY.js";import{Fn as ie,In as ae,Ln as U,Mn as W,Nn as G,Pn as K,vr as q}from"./index-rFeA9cN0.js";import{C as oe,_ as J,a as se,b as ce,c as le,d as ue,f as Y,g as de,i as X,l as fe,m as Z,n as pe,o as me,p as he,r as ge,s as _e,t as ve,v as ye}from"./antigravity-usage-view-BBxDn7OP.js";var Q=e(t(),1),$=n(),be=[`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`,`Sun`],xe=Array.from({length:24},(e,t)=>t);function Se(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 Ce(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 we(e){return xe.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 Te(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 Ee(e){return e<.3?`bg-success`:e<.7?`bg-warning`:`bg-error`}function De({accountId:e}){let[t,n]=(0,Q.useState)(null),[r,i]=(0,Q.useState)(!0),[a,s]=(0,Q.useState)(`5h`);(0,Q.useEffect)(()=>{i(!0),te(e).then(n).catch(()=>n([])).finally(()=>i(!1))},[e]);let c=(0,Q.useMemo)(()=>t?Se(t,a):null,[t,a]),l=(0,Q.useMemo)(()=>c?Ce(c):[],[c]),u=(0,Q.useMemo)(()=>c?we(c):[],[c]),d=Math.max(...l,.01);if(Math.max(...u,.01),r)return(0,$.jsx)(`div`,{className:`flex items-center justify-center py-3`,children:(0,$.jsx)(o,{className:`size-3 animate-spin text-text-subtle`})});if(!t||t.length===0)return(0,$.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,$.jsxs)(`div`,{className:`mt-2 space-y-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(`span`,{className:`text-[10px] font-medium text-text-subtle`,children:`Usage Pattern (7d)`}),(0,$.jsxs)(`div`,{className:`flex gap-0.5 text-[9px]`,children:[(0,$.jsx)(`button`,{onClick:()=>s(`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,$.jsx)(`button`,{onClick:()=>s(`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,$.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,$.jsxs)(`div`,{children:[(0,$.jsx)(`span`,{className:`text-[9px] text-text-subtle`,children:`Avg usage by day of week`}),(0,$.jsx)(`div`,{className:`flex flex-col gap-[2px] mt-0.5`,children:be.map((e,t)=>{let n=l[t]??0;return(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(`span`,{className:`text-[8px] text-text-subtle w-5 shrink-0 text-right tabular-nums`,children:e}),(0,$.jsx)(`div`,{className:`flex-1 h-2.5 bg-surface-elevated rounded-sm overflow-hidden`,children:(0,$.jsx)(`div`,{className:`h-full rounded-sm transition-all ${Ee(n)}`,style:{width:`${Math.round(n/d*100)}%`}})}),(0,$.jsxs)(`span`,{className:`text-[8px] text-text-subtle w-6 shrink-0 text-right tabular-nums`,children:[Math.round(n*100),`%`]})]},e)})})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`span`,{className:`text-[9px] text-text-subtle`,children:`Avg usage by hour (0h-23h)`}),(0,$.jsx)(`div`,{className:`flex gap-[1px] mt-0.5`,children:xe.map(e=>{let t=u[e]??0;return(0,$.jsxs)(`div`,{className:`flex-1 flex flex-col items-center gap-[1px]`,children:[(0,$.jsx)(`div`,{className:`w-full aspect-square rounded-[2px] ${Te(t)}`,title:`${e}:00 — avg ${Math.round(t*100)}% usage`}),e%6==0&&(0,$.jsx)(`span`,{className:`text-[7px] text-text-subtle tabular-nums`,children:e})]},e)})})]}),c&&(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`span`,{className:`text-[9px] text-text-subtle`,children:`Day x Hour heatmap`}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-[1px] mt-0.5`,children:[be.map((e,t)=>(0,$.jsxs)(`div`,{className:`flex items-center gap-[1px]`,children:[(0,$.jsx)(`span`,{className:`text-[7px] text-text-subtle w-4 shrink-0 text-right`,children:e.charAt(0)}),xe.map(n=>{let r=c[t][n];return(0,$.jsx)(`div`,{className:`flex-1 aspect-square rounded-[1px] ${Te(r.avg)}`,title:`${e} ${n}:00 — ${r.count>0?`avg ${Math.round(r.avg*100)}% (${r.count} samples)`:`no data`}`},n)})]},e)),(0,$.jsxs)(`div`,{className:`flex items-center gap-[1px]`,children:[(0,$.jsx)(`span`,{className:`w-4 shrink-0`}),xe.map(e=>(0,$.jsx)(`div`,{className:`flex-1 text-center`,children:e%6==0&&(0,$.jsx)(`span`,{className:`text-[7px] text-text-subtle tabular-nums`,children:e})},e))]})]})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[8px] text-text-subtle`,children:[(0,$.jsx)(`span`,{children:`Low`}),(0,$.jsxs)(`div`,{className:`flex gap-[2px]`,children:[(0,$.jsx)(`div`,{className:`size-2 rounded-[1px] bg-success/30`}),(0,$.jsx)(`div`,{className:`size-2 rounded-[1px] bg-success/60`}),(0,$.jsx)(`div`,{className:`size-2 rounded-[1px] bg-warning/50`}),(0,$.jsx)(`div`,{className:`size-2 rounded-[1px] bg-warning/80`}),(0,$.jsx)(`div`,{className:`size-2 rounded-[1px] bg-error/80`})]}),(0,$.jsx)(`span`,{children:`High`}),(0,$.jsx)(`span`,{className:`ml-1`,children:`|`}),(0,$.jsx)(`div`,{className:`size-2 rounded-[1px] bg-surface-elevated border border-border/30`}),(0,$.jsx)(`span`,{children:`No data`})]})]})}function Oe({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,$.jsxs)(`section`,{className:`space-y-2 border-t border-border pt-3`,"data-testid":`account-profile-panel`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-medium`,children:`Profile`}),(0,$.jsx)(`button`,{className:`p-2 text-muted-foreground hover:text-foreground cursor-pointer`,onClick:n,"aria-label":`Close profile`,children:(0,$.jsx)(p,{className:`size-4`})})]}),(0,$.jsx)(`div`,{className:`grid grid-cols-[80px_1fr] gap-x-3 gap-y-1 text-xs`,children:r.map(([e,t])=>t?(0,$.jsxs)(`span`,{className:`contents`,children:[(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:e}),(0,$.jsx)(`span`,{className:`break-all`,children:t})]},e):null)}),(0,$.jsx)(De,{accountId:t})]})}function ke({display:e,onConfirm:t,onCancel:n}){let r=T(),i=(0,$.jsxs)(`div`,{className:`space-y-4`,"data-testid":`account-delete-confirm`,children:[(0,$.jsxs)(`p`,{className:`text-sm`,children:[`Remove `,(0,$.jsx)(`span`,{className:`font-medium`,children:e}),`?`]}),(0,$.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,$.jsxs)(`div`,{className:`flex flex-col-reverse md:flex-row gap-2 md:justify-end pt-2`,children:[(0,$.jsx)(D,{variant:`outline`,onClick:n,className:`min-h-11`,children:`Cancel`}),(0,$.jsx)(D,{variant:`destructive`,autoFocus:!1,onClick:t,className:`min-h-11`,children:`Remove account`})]})]});return r?(0,$.jsx)(w,{open:!0,onClose:n,children:(0,$.jsxs)(`div`,{className:`px-4 pb-4`,children:[(0,$.jsx)(`h2`,{className:`text-base font-semibold mb-3`,children:`Remove account`}),i]})}):(0,$.jsx)(N,{open:!0,onOpenChange:e=>{e||n()},children:(0,$.jsxs)(A,{className:`sm:max-w-sm`,children:[(0,$.jsx)(O,{children:(0,$.jsx)(j,{className:`text-sm`,children:`Remove account`})}),i]})})}var Ae=80;function je({current:e,onSave:t,onCancel:n}){let r=T(),[i,a]=(0,Q.useState)(e),[s,c]=(0,Q.useState)(!1),[l,u]=(0,Q.useState)(null),d=i.trim(),f=!!d&&d!==e&&!s,p=async()=>{if(f){c(!0),u(null);try{await t(d)}catch(e){u(e.message||`Could not rename the account`),c(!1)}}},m=()=>{s||n()},h=(0,$.jsxs)(`form`,{className:`space-y-4`,"data-testid":`account-rename-dialog`,onSubmit:e=>{e.preventDefault(),p()},children:[(0,$.jsx)(I,{autoFocus:!0,value:i,maxLength:Ae,onChange:e=>a(e.target.value),placeholder:`e.g. Personal, Work`,"aria-label":`Account name`,className:`min-h-11 text-sm md:min-h-9`}),l&&(0,$.jsx)(`p`,{className:`text-xs text-error`,role:`alert`,children:l}),(0,$.jsxs)(`div`,{className:`flex flex-col-reverse md:flex-row gap-2 md:justify-end`,children:[(0,$.jsx)(D,{type:`button`,variant:`outline`,onClick:m,disabled:s,className:`min-h-11 md:min-h-9`,children:`Cancel`}),(0,$.jsxs)(D,{type:`submit`,disabled:!f,className:`min-h-11 md:min-h-9`,children:[s&&(0,$.jsx)(o,{className:`size-4 animate-spin`}),` Save`]})]})]});return r?(0,$.jsx)(w,{open:!0,onClose:m,children:(0,$.jsxs)(`div`,{className:`px-4 pb-4`,children:[(0,$.jsx)(`h2`,{className:`text-base font-semibold mb-3`,children:`Rename account`}),h]})}):(0,$.jsx)(N,{open:!0,onOpenChange:e=>{e||m()},children:(0,$.jsxs)(A,{className:`sm:max-w-sm`,children:[(0,$.jsx)(O,{children:(0,$.jsx)(j,{className:`text-sm`,children:`Rename account`})}),h]})})}function Me(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 Ne({open:e,onOpenChange:t,accounts:n,preselectId:r,onMessage:i}){let a=n.filter(e=>e.hasRefreshToken),[s,c]=(0,Q.useState)(new Set),[l,d]=(0,Q.useState)(``),[f,p]=(0,Q.useState)(!1),[m,_]=(0,Q.useState)(!1),[y,b]=(0,Q.useState)(!1),[x,S]=(0,Q.useState)(!1);e&&!x&&(c(r?new Set([r]):new Set(a.map(e=>e.id))),S(!0)),!e&&x&&S(!1);function C(){t(!1),d(``),p(!1),_(!1)}async function w(e){if(s.size===0)return;b(!0);let t=l.trim()||`ppm-hienlh`;try{let n={"Content-Type":`application/json`},r=v();r&&(n.Authorization=`Bearer ${r}`);let a=await fetch(`/api/accounts/export`,{method:`POST`,headers:n,body:JSON.stringify({password:t,accountIds:[...s],includeRefreshToken:f,refreshBeforeExport:m})});if(!a.ok){let e=await a.json();throw Error(e.error??`Export failed: ${a.status}`)}let o=await a.text();e&&await F(o)?i?.(`Backup copied to clipboard!`):(Me(o),i?.(`Backup downloaded.`)),C()}catch{}b(!1)}let T=s.size>0&&!y;return(0,$.jsx)(N,{open:e,onOpenChange:e=>{e||C()},children:(0,$.jsxs)(A,{className:`sm:max-w-md`,children:[(0,$.jsxs)(O,{children:[(0,$.jsxs)(j,{className:`text-sm flex items-center gap-1.5`,children:[(0,$.jsx)(g,{className:`size-3.5`}),` Export Accounts`]}),(0,$.jsx)(M,{className:`text-xs`,children:`Select accounts and set a password to protect the backup.`})]}),(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between mb-1`,children:[(0,$.jsx)(`p`,{className:`text-[11px] font-medium text-muted-foreground`,children:`Accounts to export`}),(0,$.jsx)(`button`,{className:`text-[10px] text-primary hover:underline cursor-pointer`,onClick:()=>c(s.size===a.length?new Set:new Set(a.map(e=>e.id))),children:s.size===a.length?`Deselect all`:`Select all`})]}),a.length===0?(0,$.jsx)(`p`,{className:`text-[10px] text-muted-foreground p-2 border rounded`,children:`No exportable accounts.`}):(0,$.jsx)(`div`,{className:`max-h-36 overflow-y-auto space-y-1 border rounded p-2`,children:a.map(e=>(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{type:`checkbox`,id:`exp-${e.id}`,checked:s.has(e.id),onChange:t=>{let n=new Set(s);t.target.checked?n.add(e.id):n.delete(e.id),c(n)},className:`size-3.5 accent-primary cursor-pointer`}),(0,$.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,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsxs)(q,{className:`text-xs`,children:[`Password `,(0,$.jsx)(`span`,{className:`text-muted-foreground font-normal`,children:`(optional)`})]}),(0,$.jsx)(I,{type:`password`,placeholder:`Leave empty for default`,value:l,onChange:e=>d(e.target.value),className:`text-xs h-8`,autoComplete:`new-password`})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{type:`checkbox`,id:`exp-full`,checked:f,onChange:e=>p(e.target.checked),className:`size-3.5 accent-primary cursor-pointer`}),(0,$.jsx)(`label`,{htmlFor:`exp-full`,className:`text-[11px] cursor-pointer`,children:`Include refresh tokens (full transfer)`})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{type:`checkbox`,id:`exp-refresh`,checked:m,onChange:e=>_(e.target.checked),className:`size-3.5 accent-primary cursor-pointer`}),(0,$.jsx)(`label`,{htmlFor:`exp-refresh`,className:`text-[11px] cursor-pointer`,children:`Refresh tokens before export`})]}),f?(0,$.jsxs)(`div`,{className:`rounded-md border border-error/30 bg-error/5 p-2.5`,children:[(0,$.jsx)(`p`,{className:`text-[10px] font-medium text-error`,children:`Full transfer — source accounts will expire`}),(0,$.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:`Refresh tokens included. Source machine expires in ~1h after target refreshes.`})]}):m?(0,$.jsx)(`div`,{className:`rounded-md border border-warning/30 bg-warning/5 p-2.5`,children:(0,$.jsx)(`p`,{className:`text-[10px] font-medium text-warning`,children:`Refresh before export — invalidates previous shares`})}):(0,$.jsx)(`div`,{className:`rounded-md border border-success/30 bg-success/5 p-2.5`,children:(0,$.jsx)(`p`,{className:`text-[10px] font-medium text-success`,children:`Share current token (safe)`})}),(0,$.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:`Encrypted with AES-256-GCM + scrypt.`})]}),(0,$.jsxs)(k,{className:`gap-1.5 flex-col sm:flex-row`,children:[(0,$.jsx)(D,{size:`sm`,variant:`outline`,className:`text-xs h-7 cursor-pointer`,onClick:C,children:`Cancel`}),(0,$.jsxs)(D,{size:`sm`,variant:`outline`,className:`text-xs h-7 cursor-pointer`,disabled:!T,onClick:()=>w(!0),children:[(0,$.jsx)(h,{className:`size-3 mr-1`}),` Copy`]}),(0,$.jsx)(D,{size:`sm`,className:`text-xs h-7 cursor-pointer`,disabled:!T,onClick:()=>w(!1),children:y?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(o,{className:`size-3 animate-spin mr-1`}),` Exporting...`]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(u,{className:`size-3 mr-1`}),` Download`]})})]})]})})}function Pe({open:e,onOpenChange:t,onSuccess:n}){let[r,i]=(0,Q.useState)(``),[a,s]=(0,Q.useState)(``),[c,l]=(0,Q.useState)(!1),[u,d]=(0,Q.useState)(null);function f(){t(!1),i(``),s(``),d(null)}async function p(){if(r.trim()){l(!0),d(null);try{let e=await ee({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,$.jsx)(N,{open:e,onOpenChange:e=>{e||f()},children:(0,$.jsxs)(A,{className:`sm:max-w-md`,children:[(0,$.jsxs)(O,{children:[(0,$.jsxs)(j,{className:`text-sm flex items-center gap-1.5`,children:[(0,$.jsx)(g,{className:`size-3.5`}),` Import Accounts`]}),(0,$.jsx)(M,{className:`text-xs`,children:`Paste backup data and enter the export password. Imported accounts are temporary (~1h).`})]}),(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(q,{className:`text-xs`,children:`Backup data`}),(0,$.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,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsxs)(q,{className:`text-xs`,children:[`Password `,(0,$.jsx)(`span`,{className:`text-muted-foreground font-normal`,children:`(optional)`})]}),(0,$.jsx)(I,{type:`password`,placeholder:`Leave empty for default`,value:a,onChange:e=>s(e.target.value),className:`text-xs h-8`,autoComplete:`current-password`})]})]}),u&&(0,$.jsx)(`div`,{className:`text-[11px] p-2 rounded bg-error/10 text-error`,children:u}),(0,$.jsxs)(k,{children:[(0,$.jsx)(D,{size:`sm`,variant:`outline`,className:`text-xs h-7 cursor-pointer`,onClick:f,children:`Cancel`}),(0,$.jsx)(D,{size:`sm`,className:`text-xs h-7 cursor-pointer`,disabled:!r.trim()||c,onClick:p,children:c?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(o,{className:`size-3 animate-spin mr-1`}),` Importing...`]}):`Import`})]})]})})}var Fe=typeof window<`u`?window.matchMedia(`(min-width: 768px)`):null;function Ie(e){return Fe?.addEventListener(`change`,e),()=>Fe?.removeEventListener(`change`,e)}function Le(){return Fe?.matches??!0}function Re(){let[e,t]=(0,Q.useState)(null),[n,r]=(0,Q.useState)(!0);return(0,Q.useEffect)(()=>{r(!0),ne().then(t).finally(()=>r(!1))},[]),n?(0,$.jsx)(`p`,{className:`text-xs text-text-subtle py-4 text-center`,children:`Loading...`}):e?(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(`label`,{className:`text-xs font-medium text-text-primary`,children:`Rotation Strategy`}),(0,$.jsxs)(W,{value:e.strategy,onValueChange:async e=>{t(await L({strategy:e}))},children:[(0,$.jsx)(ie,{className:`w-full h-9 text-xs`,children:(0,$.jsx)(ae,{})}),(0,$.jsxs)(G,{children:[(0,$.jsx)(K,{value:`round-robin`,children:`Round-robin`}),(0,$.jsx)(K,{value:`fill-first`,children:`Fill-first`}),(0,$.jsx)(K,{value:`lowest-usage`,children:`Lowest usage`})]})]}),(0,$.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,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(`label`,{className:`text-xs font-medium text-text-primary`,children:`Max Retry`}),(0,$.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 L({maxRetry:n}))}}),(0,$.jsx)(`p`,{className:`text-[10px] text-text-subtle`,children:`How many accounts to try on failure. 0 = try all available accounts.`})]}),(0,$.jsxs)(`div`,{className:`space-y-1.5 border-t border-border pt-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(`label`,{className:`text-xs font-medium text-text-primary`,children:`Cooldown parking`}),(0,$.jsx)(U,{checked:e.cooldownEnabled,onCheckedChange:async e=>{t(await L({cooldownEnabled:e}))}})]}),(0,$.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,$.jsxs)(`div`,{className:`flex items-center justify-between text-xs border-t border-border pt-3`,children:[(0,$.jsx)(`span`,{className:`text-text-subtle`,children:`Active accounts`}),(0,$.jsx)(`span`,{className:`font-medium text-text-primary`,children:e.activeCount})]})]}):(0,$.jsx)(`p`,{className:`text-xs text-text-subtle py-4 text-center`,children:`Failed to load settings`})}function ze({open:e,onOpenChange:t}){let n=(0,Q.useSyncExternalStore)(Ie,Le);return e?n?(0,$.jsx)(N,{open:e,onOpenChange:t,children:(0,$.jsxs)(A,{className:`sm:max-w-sm`,children:[(0,$.jsx)(O,{children:(0,$.jsxs)(j,{className:`text-sm flex items-center gap-2`,children:[(0,$.jsx)(_,{className:`size-4`}),` Rotation & Retry`]})}),(0,$.jsx)(Re,{})]})}):(0,$.jsxs)($.Fragment,{children:[(0,$.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,$.jsxs)(`div`,{className:b(`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,$.jsx)(`div`,{className:`flex justify-center pt-3 pb-1`,children:(0,$.jsx)(`div`,{className:`w-10 h-1 rounded-full bg-border`})}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-2 border-b border-border`,children:[(0,$.jsxs)(`span`,{className:`text-sm font-semibold flex items-center gap-2`,children:[(0,$.jsx)(_,{className:`size-4`}),` Rotation & Retry`]}),(0,$.jsx)(`button`,{onClick:()=>t(!1),className:`flex items-center justify-center size-7 rounded-md hover:bg-surface-elevated transition-colors`,children:(0,$.jsx)(p,{className:`size-4`})})]}),(0,$.jsx)(`div`,{className:`px-4 py-4 pb-8`,children:(0,$.jsx)(Re,{})})]})]}):null}var Be=E(`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 Ve({className:e,variant:t,...n}){return(0,$.jsx)(`div`,{className:b(Be({variant:t}),e),...n})}function He(e){let t=Math.floor(Date.now()/1e3);return e>t?`${Math.floor((e-t)/60)}m`:`exp`}function Ue({accounts:e}){let[t,n]=(0,Q.useState)([]),[r,i]=(0,Q.useState)(!1),[a,s]=(0,Q.useState)(!1),[c,l]=(0,Q.useState)(new Map),u=e.filter(e=>e.hasRefreshToken);async function d(){if(u.length!==0){i(!0);try{let e=await H(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 z(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 m(){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,$.jsxs)(`section`,{className:`border-t pt-4 space-y-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsx)(`p`,{className:`text-xs font-medium`,children:`Simulate export`}),t.length>0&&(0,$.jsxs)(`span`,{className:`text-[10px] text-muted-foreground`,children:[t.length,` round(s)`]})]}),(0,$.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,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No OAuth account with a refresh token to export.`}):(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(U,{id:`sim-include-refresh`,checked:a,onCheckedChange:s,className:`cursor-pointer`}),(0,$.jsx)(q,{htmlFor:`sim-include-refresh`,className:`text-[11px] cursor-pointer`,children:`Include refresh tokens`})]}),(0,$.jsx)(D,{size:`sm`,className:`h-7 text-xs cursor-pointer`,disabled:r,onClick:()=>void d(),children:r?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(o,{className:`size-3 animate-spin mr-1`}),` Exporting...`]}):`Run export #${t.length+1}`})]}),t.length>0&&(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsxs)(D,{size:`sm`,variant:`outline`,className:`w-full h-7 text-[11px] cursor-pointer`,onClick:m,children:[`Test all tokens (`,t.reduce((e,t)=>e+t.items.length*3,0),`)`]}),t.map(e=>(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsxs)(`p`,{className:`text-xs font-medium text-primary`,children:[`Round #`,e.round]}),(0,$.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:e.time}),(0,$.jsx)(Ve,{variant:e.includeRefresh?`destructive`:`secondary`,className:`text-[9px] px-1 py-0`,children:e.includeRefresh?`with refresh`:`access only`})]}),e.items.map(t=>(0,$.jsxs)(`div`,{className:`p-2 rounded-lg border bg-card space-y-1.5`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`text-[11px] font-medium`,children:t.label??t.email??t.id.slice(0,8)}),t.tokenChanged&&(0,$.jsx)(Ve,{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,$.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[11px]`,children:[(0,$.jsx)(`span`,{className:`w-20 shrink-0 text-muted-foreground text-[10px]`,children:e.label}),(0,$.jsx)(`code`,{className:`flex-1 truncate font-mono text-[10px] bg-muted px-1 rounded`,children:e.preview??`N/A`}),e.expires&&(0,$.jsx)(`span`,{className:`text-[10px] text-muted-foreground shrink-0`,children:He(e.expires)}),e.token?(0,$.jsx)(D,{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,$.jsx)(o,{className:`size-3 animate-spin`}):`Test`}):(0,$.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:`-`}),t&&!t.loading&&(0,$.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 We(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 Ge({open:e,onOpenChange:t,accounts:n}){let[i,a]=(0,Q.useState)(new Map),[s,c]=(0,Q.useState)(!1);async function l(e){a(t=>new Map(t).set(e,{loading:!0}));try{let t=await re(e,s);a(n=>new Map(n).set(e,{loading:!1,result:t}))}catch(t){a(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,$.jsx)(N,{open:e,onOpenChange:t,children:(0,$.jsxs)(A,{className:`sm:max-w-xl max-h-[85vh] flex flex-col`,children:[(0,$.jsxs)(O,{children:[(0,$.jsxs)(j,{className:`text-sm flex items-center gap-1.5`,children:[(0,$.jsx)(r,{className:`size-4`}),` Token Test`]}),(0,$.jsx)(M,{className:`text-xs`,children:`Probe stored tokens for validity. Nothing is modified.`})]}),(0,$.jsxs)(`div`,{className:`space-y-4 overflow-y-auto flex-1 pr-1`,children:[(0,$.jsxs)(`section`,{className:`space-y-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsx)(`p`,{className:`text-xs font-medium`,children:`Current tokens`}),(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(U,{id:`token-test-refresh`,checked:s,onCheckedChange:c,className:`cursor-pointer`}),(0,$.jsx)(q,{htmlFor:`token-test-refresh`,className:`text-[11px] cursor-pointer`,children:`Also test refresh`})]}),(0,$.jsx)(D,{size:`sm`,variant:`outline`,className:`h-7 text-xs cursor-pointer`,onClick:u,children:`Test all`})]})]}),n.length===0&&(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No accounts to test.`}),(0,$.jsx)(`div`,{className:`space-y-1.5`,children:n.map(e=>{let t=i.get(e.id),n=t?.result?.accessToken.status;return(0,$.jsxs)(`div`,{className:`p-2 rounded border bg-card space-y-1`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium truncate block`,children:e.label??e.email??e.id.slice(0,8)}),e.expiresAt&&(0,$.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:We(e.expiresAt)})]}),(0,$.jsx)(D,{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,$.jsx)(o,{className:`size-3 animate-spin`}):`Test`})]}),t&&!t.loading&&(0,$.jsxs)(`div`,{className:`text-[11px] pl-2 border-l-2 border-muted`,children:[t.error&&(0,$.jsx)(`p`,{className:`text-error`,children:t.error}),n&&(0,$.jsxs)(`span`,{className:n.startsWith(`valid`)?`text-success`:`text-error`,children:[n,t.result?.accessToken.code?` (${t.result.accessToken.code})`:``]})]})]},e.id)})})]}),(0,$.jsx)(Ue,{accounts:n})]}),(0,$.jsx)(k,{children:(0,$.jsx)(D,{size:`sm`,variant:`outline`,className:`text-xs cursor-pointer`,onClick:()=>t(!1),children:`Close`})})]})})}function Ke(){let{usages:e,accounts:t,activeAccountId:n,initialLoading:i,refreshing:s,flashIds:c,reload:l}=he(),[f,p]=(0,Q.useState)(null),[h,g]=(0,Q.useState)(null),[v,y]=(0,Q.useState)(null),[b,x]=(0,Q.useState)(null),[S,C]=(0,Q.useState)(null),[w,T]=(0,Q.useState)(null),[E,O]=(0,Q.useState)(null),[k,A]=(0,Q.useState)(void 0);function j(e){l(),e&&p(e)}async function M(e,t){g(e);try{await B(e,{status:t===`disabled`?`active`:`disabled`})}catch(e){p(e.message)}g(null),l()}async function N(){if(v){try{await V(v.id),p(`Account "${v.display}" removed.`),l()}catch(e){p(`Failed to remove: ${e.message}`)}y(null)}}async function P(e){b&&(await B(b.id,{label:e}),x(null),p(`Account renamed to "${e}".`),l())}let F=new Map(t.map(e=>[e.id,e])),I=e[0]?.usage.lastFetchedAt;return(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsx)(_e,{description:`Connect multiple Claude accounts. PPM rotates between them automatically to avoid rate limits.`,onRefresh:()=>void l(),refreshing:s,disabled:i,actions:(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(D,{size:`sm`,className:`cursor-pointer gap-1.5`,onClick:()=>{A(void 0),O(`add`)},children:[(0,$.jsx)(d,{className:`size-4`}),` Add account`]}),(0,$.jsxs)(D,{size:`sm`,variant:`outline`,className:`cursor-pointer gap-1.5`,onClick:()=>{T(null),O(`export`)},children:[(0,$.jsx)(u,{className:`size-4`}),` Export`]}),(0,$.jsxs)(D,{size:`sm`,variant:`outline`,className:`cursor-pointer gap-1.5`,onClick:()=>O(`import`),children:[(0,$.jsx)(a,{className:`size-4`}),` Import`]}),(0,$.jsxs)(D,{size:`sm`,variant:`outline`,className:`cursor-pointer gap-1.5`,onClick:()=>O(`rotation`),children:[(0,$.jsx)(_,{className:`size-4`}),` Rotation`]}),(0,$.jsxs)(D,{size:`sm`,variant:`outline`,className:`cursor-pointer gap-1.5`,onClick:()=>O(`token-test`),children:[(0,$.jsx)(r,{className:`size-4`}),` Token test`]})]})}),(0,$.jsx)(le,{message:f,onDismiss:()=>p(null)}),(0,$.jsxs)(`section`,{className:`space-y-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-medium`,children:`Accounts`}),I&&(0,$.jsxs)(`span`,{className:`text-[10px] text-muted-foreground`,children:[`usage `,ce(new Date(I).getTime())]})]}),i?(0,$.jsxs)(`div`,{className:`flex items-center gap-2 py-6 text-xs text-muted-foreground`,children:[(0,$.jsx)(o,{className:`size-4 animate-spin`}),` Loading accounts...`]}):e.length===0?(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-2 py-8 text-center`,children:[(0,$.jsx)(m,{className:`size-5 text-muted-foreground`}),(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No accounts connected yet.`}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Add one to start using PPM.`})]}):(0,$.jsx)(se,{children:e.map(e=>(0,$.jsx)(ge,{layout:`strip`,entry:e,isActive:e.accountId===n,accountInfo:F.get(e.accountId),onToggle:M,toggling:h===e.accountId,onDelete:(e,t)=>y({id:e,display:t}),onRename:(e,t)=>x({id:e,current:t}),onExport:e=>{T(e),O(`export`)},onViewProfile:(e,t)=>C({profile:e,accountId:t}),onReauth:()=>{A({id:e.accountId,label:e.accountLabel??e.accountId.slice(0,8)}),O(`add`)},flash:c.has(e.accountId)},e.accountId))})]}),S&&(0,$.jsx)(Oe,{profile:S.profile,accountId:S.accountId,onClose:()=>C(null)}),v&&(0,$.jsx)(ke,{display:v.display,onConfirm:()=>void N(),onCancel:()=>y(null)}),b&&(0,$.jsx)(je,{current:b.current,onSave:P,onCancel:()=>x(null)}),(0,$.jsx)(ye,{open:E===`add`,onOpenChange:e=>{O(e?`add`:null),e||A(void 0)},onSuccess:j,signInAgainFor:k}),(0,$.jsx)(Ne,{open:E===`export`,onOpenChange:e=>{O(e?`export`:null),e||T(null)},accounts:t,preselectId:w,onMessage:p}),(0,$.jsx)(Pe,{open:E===`import`,onOpenChange:e=>O(e?`import`:null),onSuccess:j}),(0,$.jsx)(ze,{open:E===`rotation`,onOpenChange:e=>O(e?`rotation`:null)}),(0,$.jsx)(Ge,{open:E===`token-test`,onOpenChange:e=>O(e?`token-test`:null),accounts:t})]})}function qe({mode:e,onOpenChange:t,password:n,onPasswordChange:r,busy:i,onExport:s,onImport:c,error:l}){let d=(0,Q.useRef)(null),f=e===`export`;return(0,$.jsx)(N,{open:e!==null,onOpenChange:t,children:(0,$.jsxs)(A,{className:`sm:max-w-md`,children:[(0,$.jsxs)(O,{children:[(0,$.jsxs)(j,{className:`text-sm flex items-center gap-1.5`,children:[(0,$.jsx)(g,{className:`size-4`}),` `,f?`Export Codex Accounts`:`Import Codex Accounts`]}),(0,$.jsx)(M,{className:`text-xs leading-relaxed`,children:f?`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,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(q,{htmlFor:`codex-backup-password`,className:`text-xs`,children:`Password`}),(0,$.jsx)(I,{id:`codex-backup-password`,type:`password`,placeholder:f?`Choose a password`:`Password used for the export`,value:n,onChange:e=>r(e.target.value),className:`text-xs`,autoComplete:f?`new-password`:`current-password`}),(0,$.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:`A backup holds full logins — keep the file and its password together.`})]}),l&&(0,$.jsx)(`div`,{className:`text-[11px] p-2 rounded bg-error/10 text-error`,children:l}),(0,$.jsx)(`input`,{ref:d,type:`file`,accept:`application/json,.json`,className:`hidden`,onChange:e=>{let t=e.target.files?.[0];e.target.value=``,t&&c(t)}}),(0,$.jsxs)(k,{children:[(0,$.jsx)(D,{size:`sm`,variant:`outline`,className:`text-xs cursor-pointer`,onClick:()=>t(!1),children:`Cancel`}),(0,$.jsxs)(D,{size:`sm`,className:`text-xs cursor-pointer gap-1.5`,disabled:!n.trim()||i,onClick:()=>f?s():d.current?.click(),children:[i?(0,$.jsx)(o,{className:`size-3.5 animate-spin`}):f?(0,$.jsx)(u,{className:`size-3.5`}):(0,$.jsx)(a,{className:`size-3.5`}),f?`Download backup`:`Choose file`]})]})]})})}var Je=[{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 Ye({open:e,onOpenChange:t,strategy:n,onChange:r}){return(0,$.jsx)(N,{open:e,onOpenChange:t,children:(0,$.jsxs)(A,{className:`sm:max-w-md`,children:[(0,$.jsxs)(O,{children:[(0,$.jsx)(j,{className:`text-sm`,children:`Codex Rotation`}),(0,$.jsx)(M,{className:`text-xs leading-relaxed`,children:`How a new chat chooses among your Codex accounts.`})]}),(0,$.jsx)(`div`,{className:`space-y-2`,children:Je.map(e=>(0,$.jsxs)(`button`,{type:`button`,onClick:()=>r(e.value),"aria-current":n===e.value?`true`:void 0,className:b(`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,$.jsx)(`p`,{className:`text-sm font-medium`,children:e.label}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.hint})]},e.value))}),(0,$.jsx)(k,{children:(0,$.jsx)(D,{size:`sm`,variant:`outline`,className:`text-xs cursor-pointer`,onClick:()=>t(!1),children:`Done`})})]})})}function Xe(e){return e==null?null:Math.round(e*100)}function Ze({usage:e}){let t=e.session==null&&e.weekly==null;return(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(t||e.session!=null)&&(0,$.jsx)(ue,{label:`5-Hour Session`,pct:Xe(e.fiveHour),reset:oe(e.session),resetsAt:e.session?.resetsAt}),(t||e.weekly!=null)&&(0,$.jsx)(ue,{label:`Weekly`,pct:Xe(e.sevenDay),reset:oe(e.weekly),resetsAt:e.weekly?.resetsAt})]})}function Qe(e){let t=e=>Math.round((e??0)*100)>=100;return t(e.session?.utilization)||t(e.weekly?.utilization)}function $e(e){return Qe(e)&&(e.resetCredits?.available??0)>0}var et={reset:e=>`${e}: limits reset to 0%. The weekly reset date now counts from your next use.`,nothingToReset:e=>`${e}: nothing needed resetting, so the reset was kept.`,noCredit:e=>`${e} has no free reset left.`,alreadyRedeemed:e=>`${e}: that reset had already been used.`};function tt(e){return e?new Date(e).toLocaleString(void 0,{dateStyle:`medium`,timeStyle:`short`}):null}function nt({account:e,usage:t,onDone:n}){let r=T(),[i,a]=(0,Q.useState)(!1),[c,l]=(0,Q.useState)(!1);if(!$e(t))return null;let u=t.resetCredits;async function d(){l(!0);try{let t=await y.post(`/api/codex-accounts/${e.id}/reset-credit`);n(et[t.outcome]?.(e.label)??`${e.label}: ${t.outcome}`)}catch(e){n(e.message||`Could not use the reset`)}finally{l(!1),a(!1)}}let f=tt(t.weekly?.resetsAt),p=tt(u.nextExpiresAt),m=(0,$.jsxs)(`div`,{className:`space-y-3`,"data-testid":`codex-reset-credit-confirm`,children:[(0,$.jsxs)(`p`,{className:`text-sm`,children:[`Use 1 of `,(0,$.jsx)(`span`,{className:`font-medium`,children:e.label}),`'s `,u.available,` free reset`,u.available===1?``:`s`,`?`]}),(0,$.jsxs)(`ul`,{className:`text-xs text-text-secondary space-y-1.5 list-disc pl-4`,children:[(0,$.jsxs)(`li`,{children:[u.title??`Full reset`,`: the 5-hour and weekly usage go back to 0% now.`]}),(0,$.jsxs)(`li`,{children:[`The weekly reset date moves: the next one is about 7 days after you continue using Codex`,f?`, not ${f} as now`:``,`. You do not also get that one.`]}),p&&(0,$.jsxs)(`li`,{children:[`This spends the reset that expires first (`,p,`).`]})]}),(0,$.jsxs)(`div`,{className:`flex flex-col-reverse md:flex-row gap-2 md:justify-end pt-1`,children:[(0,$.jsx)(D,{variant:`outline`,onClick:()=>a(!1),disabled:c,className:`min-h-11`,children:`Keep it`}),(0,$.jsxs)(D,{onClick:()=>void d(),disabled:c,className:`min-h-11 gap-1.5`,children:[c?(0,$.jsx)(o,{className:`size-4 animate-spin`}):(0,$.jsx)(s,{className:`size-4`}),`Use reset`]})]})]});return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(D,{size:`sm`,variant:`outline`,className:`min-h-11 md:min-h-0 md:h-7 gap-1 px-2 text-[11px] cursor-pointer border-primary/40 text-primary`,onClick:()=>a(!0),disabled:c,children:[(0,$.jsx)(s,{className:`size-3.5`}),` Use reset`]}),i&&(r?(0,$.jsx)(w,{open:!0,onClose:()=>{c||a(!1)},children:(0,$.jsxs)(`div`,{className:`px-4 pb-4`,children:[(0,$.jsx)(`h2`,{className:`text-base font-semibold mb-3`,children:`Use a free reset`}),m]})}):(0,$.jsx)(N,{open:!0,onOpenChange:e=>{!e&&!c&&a(!1)},children:(0,$.jsxs)(A,{className:`sm:max-w-sm`,children:[(0,$.jsx)(O,{children:(0,$.jsx)(j,{className:`text-sm`,children:`Use a free reset`})}),m]})}))]})}var rt=1440*60*1e3,it=7,at=5;function ot(e,t=Date.now()){if(!e||e.windowHours!==168)return null;let n=new Date(e.resetsAt).getTime();if(!Number.isFinite(t)||!Number.isFinite(n)||n<=t)return null;let r=n-it*rt;if(t<r)return null;let i=Math.min(it-1,Math.floor((t-r)/rt)),a=0;for(let e=0;e<=i;e++){let t=new Date(r+e*rt).getUTCDay();t!==0&&t!==6&&a++}let o=a/at;return{day:a,cap:o,used:e.utilization,blocked:e.utilization>=o}}function st(){let[e,t]=(0,Q.useState)(null),n=de(()=>t(null)),[r,s]=(0,Q.useState)(null);return(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsx)(_e,{description:(0,$.jsxs)($.Fragment,{children:[`Each Codex account keeps its own login (`,(0,$.jsx)(`code`,{children:`CODEX_HOME`}),`). One is picked per chat by the rotation setting.`]}),onRefresh:()=>void n.load(),refreshing:n.loading,actions:(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(D,{size:`sm`,className:`cursor-pointer gap-1.5`,onClick:()=>t(`add`),children:[(0,$.jsx)(d,{className:`size-4`}),` Add account`]}),(0,$.jsxs)(D,{size:`sm`,variant:`outline`,className:`cursor-pointer gap-1.5`,onClick:()=>t(`export`),children:[(0,$.jsx)(u,{className:`size-4`}),` Export`]}),(0,$.jsxs)(D,{size:`sm`,variant:`outline`,className:`cursor-pointer gap-1.5`,onClick:()=>t(`import`),children:[(0,$.jsx)(a,{className:`size-4`}),` Import`]}),(0,$.jsxs)(D,{size:`sm`,variant:`outline`,className:`cursor-pointer gap-1.5`,onClick:()=>t(`rotation`),children:[(0,$.jsx)(_,{className:`size-4`}),` Rotation`]})]})}),(0,$.jsx)(le,{message:n.msg??n.err,onDismiss:()=>{n.setMsg(null),n.setErr(null)}}),(0,$.jsxs)(`section`,{className:`space-y-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-medium`,children:`Codex Accounts`}),(0,$.jsx)(`span`,{className:`text-[10px] text-muted-foreground capitalize`,children:n.strategy.replace(`-`,` `)})]}),n.loading&&n.accounts.length===0?(0,$.jsxs)(`div`,{className:`flex items-center gap-2 py-6 text-xs text-muted-foreground`,children:[(0,$.jsx)(o,{className:`size-4 animate-spin`}),` Loading accounts...`]}):n.accounts.length===0?(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-2 py-8 text-center`,children:[(0,$.jsx)(m,{className:`size-5 text-muted-foreground`}),(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No Codex accounts yet.`}),(0,$.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Chats use your default `,(0,$.jsx)(`code`,{children:`~/.codex`}),` login until you add one.`]})]}):(0,$.jsx)(se,{children:n.accounts.map(e=>{let t=n.usages[e.id]??{};return(0,$.jsxs)(me,{dense:!0,className:`min-w-[300px] shrink-0 snap-start${e.signedOut?` opacity-60`:``}`,"data-testid":`account-card`,"data-account-id":e.id,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`text-sm font-medium truncate flex-1 min-w-0`,children:e.label}),e.signedOut&&(0,$.jsx)(fe,{className:`text-[10px] text-error shrink-0 font-medium`,hint:`Codex rejected this account's login (revoked or expired), so no turn can run on it and it is skipped. The usage shown is the last reading. Click to sign in again — the account keeps its settings and chats.`,onClick:e.type===`chatgpt`?()=>s(e):void 0,children:`Sign in again`}),(0,$.jsx)(`span`,{className:`text-[10px] uppercase tracking-wide text-text-subtle border border-border rounded px-1 shrink-0`,children:e.type}),Y(e.planType)&&(0,$.jsx)(`span`,{className:`text-[10px] text-text-subtle shrink-0`,children:Y(e.planType)}),(0,$.jsx)(U,{checked:e.status!==`disabled`,onCheckedChange:()=>void n.toggle(e.id,e.status??`active`),disabled:n.toggling.has(e.id),"aria-label":e.status===`disabled`?`Enable account`:`Disable account`,className:`cursor-pointer shrink-0`}),(0,$.jsxs)(C,{children:[(0,$.jsx)(x,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,onClick:()=>void n.remove(e.id),"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,$.jsx)(f,{className:`size-4`})})}),(0,$.jsx)(S,{side:`top`,children:`Remove account`})]})]}),(0,$.jsx)(Ze,{usage:t}),t.resetCredits&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap text-[10px] text-text-subtle`,children:[(0,$.jsx)(X,{credits:t.resetCredits}),(0,$.jsx)(nt,{account:e,usage:t,onDone:e=>{n.setMsg(e),n.load()}})]}),t.session==null&&(()=>{let r=ot(t.weekly);return r?(0,$.jsxs)(`div`,{className:`flex min-h-12 items-center justify-between gap-3 rounded-md border px-2.5 py-1.5 ${e.dailyGuardEnabled&&r.blocked?`border-error/40 bg-error/5`:`border-border/50 bg-surface/40`}`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 space-y-0.5`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs font-medium ${e.dailyGuardEnabled&&r.blocked?`text-error`:`text-text-secondary`}`,children:[(0,$.jsx)(`span`,{children:`Daily guard`}),(0,$.jsxs)(C,{children:[(0,$.jsx)(x,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,"aria-label":`About Daily guard`,className:`text-text-subtle hover:text-text-primary cursor-help`,children:(0,$.jsx)(i,{className:`size-3.5`})})}),(0,$.jsx)(S,{side:`top`,className:`max-w-64 text-xs leading-relaxed`,children:`Spreads the weekly quota across five weekdays, adding 20% per weekday. Weekend slots keep the previous cap; unused allowance carries forward. Daily slots start at the reset time and use UTC weekdays. Turn it off any time to use the remaining quota freely.`})]})]}),(0,$.jsx)(`p`,{className:`text-[10px] tabular-nums ${e.dailyGuardEnabled&&r.blocked?`text-error`:`text-text-subtle`}`,children:e.dailyGuardEnabled&&r.blocked?`${Math.round(r.used*100)}% used / ${Math.round(r.cap*100)}% daily cap. New turns paused.`:`Weekday ${r.day}/5, ${Math.round(r.cap*100)}% daily cap`})]}),(0,$.jsxs)(`span`,{className:`hidden`,title:`Weekday ${r.day}/5: hold weekly usage at or below ${Math.round(r.cap*100)}% to last until reset.`,children:[`Daily guard `,e.dailyGuardEnabled?`· Weekday ${r.day}/5 cap ${Math.round(r.cap*100)}%`:``]}),(0,$.jsx)(U,{checked:!!e.dailyGuardEnabled,onCheckedChange:()=>void n.toggleDailyGuard(e.id,!!e.dailyGuardEnabled),disabled:n.toggling.has(e.id),"aria-label":e.dailyGuardEnabled?`Disable Daily guard`:`Enable Daily guard`,className:`cursor-pointer shrink-0`})]}):null})()]},e.id)})})]}),(0,$.jsx)(J,{open:e===`add`,onOpenChange:e=>{e||n.cancelLogin(),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,browser:n.browser,onStartBrowser:()=>void n.startBrowser(),loginStarting:n.loginStarting,callbackUrl:n.callbackUrl,onCallbackUrlChange:n.setCallbackUrl,submittingCallback:n.submittingCallback,onSubmitCallback:()=>void n.submitCallback(),error:n.err}),(0,$.jsx)(qe,{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}),r&&(0,$.jsx)(Z,{account:r,onClose:()=>s(null),onDone:()=>void n.load()}),(0,$.jsx)(Ye,{open:e===`rotation`,onOpenChange:e=>t(e?`rotation`:null),strategy:n.strategy,onChange:e=>void n.changeStrategy(e)})]})}var ct=[{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 lt(e){return e==null?null:Math.round(e*100)}function ut(){let[e,t]=(0,Q.useState)([]),[n,r]=(0,Q.useState)(`round-robin`),[i,a]=(0,Q.useState)({}),[s,u]=(0,Q.useState)(!0),[p,h]=(0,Q.useState)(null),[g,v]=(0,Q.useState)(null),[w,T]=(0,Q.useState)(new Set),[E,P]=(0,Q.useState)(null),[F,L]=(0,Q.useState)(null),[R,z]=(0,Q.useState)(``),[B,ee]=(0,Q.useState)(null),[te,ne]=(0,Q.useState)(!1),[V,re]=(0,Q.useState)(``),[H,ie]=(0,Q.useState)(!1),[ae,W]=(0,Q.useState)(null),G=(0,Q.useRef)(0),K=(0,Q.useRef)(!1),J=(0,Q.useRef)(!1),Y=(0,Q.useRef)(null),de=(0,Q.useRef)(null),X=(0,Q.useCallback)(async()=>{u(!0),v(null);try{let e=await y.get(`/api/antigravity-accounts`);t(e.accounts),r(e.strategy),a(await y.get(`/api/antigravity-accounts/usage`))}catch(e){v(e.message)}finally{u(!1)}},[]);(0,Q.useEffect)(()=>{X()},[X]);let fe=(0,Q.useCallback)(()=>{G.current+=1,K.current=!1,J.current=!1,de.current?.(),de.current=null;let e=Y.current;Y.current=null,e&&y.del(`/api/antigravity-accounts/login/${e}`).catch(()=>{})},[]);(0,Q.useEffect)(()=>fe,[fe]);let Z=(0,Q.useCallback)(()=>{fe(),ee(null),ne(!1),re(``),ie(!1)},[fe]),he=(0,Q.useCallback)(()=>{Z(),W(null),z(``),L(null),P(null)},[Z]),ge=(0,Q.useCallback)(e=>{let t=Date.now()+61e4,n=!1,r;de.current=()=>{n=!0,clearTimeout(r)};let i=async()=>{if(n)return;let a=null;try{a=await y.get(`/api/antigravity-accounts/login/${e}/status`)}catch{}if(!n){if(a?.state===`done`){Y.current=null,Z(),W(null),z(``),L(null),P(null),h(`Antigravity Google account connected.`),await X();return}if(a?.state===`error`||Date.now()>t){Y.current=null,Z(),W(a?.state===`error`?a.error??`Login failed.`:`Login timed out.`);return}r=setTimeout(i,2e3)}};i()},[X,Z]),ye=(0,Q.useCallback)(async e=>{if(K.current||Y.current||J.current)return;K.current=!0;let t=++G.current;ne(!0),W(null);try{let n=await y.post(`/api/antigravity-accounts/login`,{...R.trim()?{label:R.trim()}:{},...e?{accountId:e.id}:{}});if(t!==G.current){y.del(`/api/antigravity-accounts/login/${n.id}`).catch(()=>{});return}Y.current=n.id,ee(n),ge(n.id)}catch(e){t===G.current&&W(e.message)}finally{t===G.current&&(K.current=!1,ne(!1))}},[R,ge]),be=(0,Q.useCallback)(async()=>{if(!B||!V.trim()||J.current)return;let e=G.current;J.current=!0,ie(!0),W(null);try{let t=await y.post(`/api/antigravity-accounts/login/${B.id}/callback`,{code:V.trim()});if(e!==G.current)return;if(t?.state===`error`){Y.current=null,Z(),W(t.error??`Login failed.`);return}if(t?.state!==`done`)return;Y.current=null,Z(),z(``),L(null),P(null),h(`Antigravity Google account connected.`),await X()}catch(t){e===G.current&&(Y.current=null,Z(),W(t.message))}finally{e===G.current&&(J.current=!1,ie(!1))}},[B,V,X,Z]),xe=(0,Q.useCallback)(async(e,n)=>{T(t=>new Set(t).add(e)),v(null);try{let r=n===`disabled`?`active`:`disabled`;await y.patch(`/api/antigravity-accounts/${e}`,{status:r}),t(t=>t.map(t=>t.id===e?{...t,status:r}:t))}catch(e){v(e.message)}finally{T(t=>{let n=new Set(t);return n.delete(e),n})}},[]),Se=(0,Q.useCallback)(async e=>{v(null);try{await y.del(`/api/antigravity-accounts/${e}`),t(t=>t.filter(t=>t.id!==e))}catch(e){v(e.message)}},[]),Ce=(0,Q.useCallback)(async e=>{v(null);try{await y.put(`/api/antigravity-accounts/strategy`,{strategy:e}),r(e)}catch(e){v(e.message)}},[]),we=(0,Q.useCallback)(e=>{L(e),z(e.label),P(`add`)},[]);return(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsx)(_e,{description:(0,$.jsxs)($.Fragment,{children:[`Each Antigravity account keeps its own Google OAuth login (`,(0,$.jsx)(`code`,{children:`~/.ppm/antigravity-accounts`}),`) alongside your local IDE login (`,(0,$.jsx)(`code`,{children:`~/.gemini`}),`). One is picked per chat by the rotation setting.`]}),onRefresh:()=>void X(),refreshing:s,actions:(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(D,{size:`sm`,className:`cursor-pointer gap-1.5`,onClick:()=>{L(null),z(``),P(`add`)},children:[(0,$.jsx)(d,{className:`size-4`}),` Add account`]}),(0,$.jsxs)(D,{size:`sm`,variant:`outline`,className:`cursor-pointer gap-1.5`,onClick:()=>P(`rotation`),children:[(0,$.jsx)(_,{className:`size-4`}),` Rotation`]})]})}),(0,$.jsx)(le,{message:p??g,onDismiss:()=>{h(null),v(null)}}),(0,$.jsxs)(`section`,{className:`space-y-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-medium`,children:`Antigravity Accounts`}),(0,$.jsx)(`span`,{className:`text-[10px] text-muted-foreground capitalize`,children:n.replace(`-`,` `)})]}),s&&e.length===0?(0,$.jsxs)(`div`,{className:`flex items-center gap-2 py-6 text-xs text-muted-foreground`,children:[(0,$.jsx)(o,{className:`size-4 animate-spin`}),` Loading accounts...`]}):e.length===0?(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-2 py-8 text-center`,children:[(0,$.jsx)(m,{className:`size-5 text-muted-foreground`}),(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No Antigravity accounts yet.`}),(0,$.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Click `,(0,$.jsx)(`strong`,{children:`Add account`}),` to sign in with Google, or start Antigravity Desktop to auto-detect your local account.`]})]}):(0,$.jsx)(se,{children:e.map(e=>{let t=ve(i[e.id]??{}),n=t.session==null&&t.weekly==null&&(!t.weeklyScoped||t.weeklyScoped.length===0),r=e.id===`default`;return(0,$.jsxs)(me,{dense:!0,className:`min-w-[320px] shrink-0 snap-start`,"data-testid":`account-card`,"data-account-id":e.id,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,$.jsx)(`div`,{className:`text-sm font-medium truncate`,children:e.label}),e.email&&e.email!==e.label&&(0,$.jsx)(`div`,{className:`text-[11px] text-text-subtle truncate`,children:e.email})]}),(0,$.jsx)(`span`,{className:`text-[10px] uppercase tracking-wide text-text-subtle border border-border rounded px-1 shrink-0`,children:r?`~/.gemini`:`Google`}),e.planType&&(0,$.jsx)(`span`,{className:`text-[10px] font-medium text-primary bg-primary/10 border border-primary/20 rounded px-1.5 py-0.5 shrink-0`,children:e.planType}),(0,$.jsx)(U,{checked:e.status!==`disabled`,onCheckedChange:()=>void xe(e.id,e.status),disabled:w.has(e.id),"aria-label":e.status===`disabled`?`Enable account`:`Disable account`,className:`cursor-pointer shrink-0`}),!r&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(C,{children:[(0,$.jsx)(x,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,onClick:()=>we(e),"aria-label":`Sign in again`,className:`p-1.5 rounded cursor-pointer text-text-subtle hover:text-foreground hover:bg-surface-elevated transition-colors shrink-0`,children:(0,$.jsx)(c,{className:`size-3.5`})})}),(0,$.jsx)(S,{side:`top`,children:`Sign in again`})]}),(0,$.jsxs)(C,{children:[(0,$.jsx)(x,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,onClick:()=>void Se(e.id),"aria-label":`Remove account`,className:`p-1.5 rounded cursor-pointer text-text-subtle hover:text-error hover:bg-surface-elevated transition-colors shrink-0`,children:(0,$.jsx)(f,{className:`size-4`})})}),(0,$.jsx)(S,{side:`top`,children:`Remove account`})]})]})]}),(0,$.jsxs)(`div`,{className:`space-y-2 pt-1`,children:[(n||t.session!=null)&&(0,$.jsx)(ue,{label:`Gemini · 5-Hour Session`,pct:lt(t.fiveHour),reset:oe(t.session),resetsAt:t.session?.resetsAt}),(n||t.weekly!=null)&&(0,$.jsx)(ue,{label:`Gemini · Weekly`,pct:lt(t.sevenDay),reset:oe(t.weekly),resetsAt:t.weekly?.resetsAt}),t.weeklyScoped?.map(e=>(0,$.jsx)(ue,{label:e.label,pct:lt(e.utilization),reset:oe(e),resetsAt:e.resetsAt},e.label))]}),t.lastFetchedAt&&pe(t.lastFetchedAt)&&(0,$.jsxs)(`p`,{className:`text-[10px] text-warning`,children:[`Last read `,ce(Date.parse(t.lastFetchedAt)),`. Neither agy nor the Antigravity app has answered since.`]})]},e.id)})})]}),(0,$.jsx)(N,{open:E===`add`,onOpenChange:e=>{e||he()},children:(0,$.jsxs)(A,{className:`sm:max-w-md max-h-[90dvh] overflow-y-auto`,children:[(0,$.jsxs)(O,{children:[(0,$.jsx)(j,{className:`text-sm`,children:F?`Sign in again — ${F.label}`:`Add Antigravity Account`}),(0,$.jsx)(M,{className:`text-xs leading-relaxed`,children:F?`Sign in with Google to refresh this account's OAuth credentials.`:`Sign in with a Google account using Antigravity's OAuth PKCE flow. Each account is stored in its own isolated directory.`})]}),(0,$.jsxs)(`div`,{className:`space-y-3`,children:[!F&&(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(q,{htmlFor:`agy-label`,className:`text-xs`,children:`Label (optional)`}),(0,$.jsx)(I,{id:`agy-label`,placeholder:`e.g. Personal, Work, Shopee 2`,value:R,onChange:e=>z(e.target.value),disabled:te||H,className:`text-xs`})]}),(0,$.jsxs)(`div`,{className:`rounded-md border p-3 space-y-2.5`,children:[(0,$.jsx)(`p`,{className:`text-[11px] font-medium`,children:`Google OAuth Sign-In`}),B?(0,$.jsxs)(`div`,{className:`space-y-2.5 text-xs`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsxs)(`a`,{href:B.authUrl,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1.5 font-medium text-primary hover:underline`,children:[(0,$.jsx)(l,{className:`size-3.5`}),` Open Google Sign-In page`]}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>{Z(),W(null)},disabled:H,className:`text-[11px] text-muted-foreground hover:text-foreground underline cursor-pointer`,children:`Start over`})]}),(0,$.jsxs)(`p`,{className:`text-muted-foreground leading-relaxed`,children:[`1. Open the link above and sign in with your Google account.`,(0,$.jsx)(`br`,{}),`2. Copy the authorization code (or the full callback URL) shown after signing in and paste it below:`]}),(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(q,{htmlFor:`agy-auth-code`,className:`text-xs`,children:`Authorization Code or Callback URL`}),(0,$.jsx)(I,{id:`agy-auth-code`,type:`text`,autoComplete:`off`,spellCheck:!1,placeholder:`4/0A... or https://antigravity.google/oauth-callback?code=...`,value:V,onChange:e=>re(e.target.value),disabled:H,className:`text-xs font-mono`})]}),(0,$.jsxs)(D,{size:`sm`,className:`w-full cursor-pointer gap-1.5`,onClick:()=>void be(),disabled:!V.trim()||H,children:[H&&(0,$.jsx)(o,{className:`size-3.5 animate-spin`}),`Verify & Save Account`]})]}):(0,$.jsx)(D,{size:`sm`,className:`w-full cursor-pointer gap-1.5`,onClick:()=>void ye(F),disabled:te,children:te?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(o,{className:`size-4 animate-spin`}),` Generating Google sign-in link...`]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(l,{className:`size-4`}),` Sign in with Google`]})})]})]}),ae&&(0,$.jsx)(`div`,{role:`alert`,className:`text-[11px] p-2 rounded bg-error/10 text-error`,children:ae}),(0,$.jsx)(k,{children:(0,$.jsx)(D,{size:`sm`,variant:`outline`,className:`text-xs cursor-pointer`,onClick:he,children:`Cancel`})})]})}),(0,$.jsx)(N,{open:E===`rotation`,onOpenChange:e=>P(e?`rotation`:null),children:(0,$.jsxs)(A,{className:`sm:max-w-md`,children:[(0,$.jsxs)(O,{children:[(0,$.jsx)(j,{className:`text-sm`,children:`Antigravity Rotation`}),(0,$.jsx)(M,{className:`text-xs leading-relaxed`,children:`How a new chat chooses among your enabled Antigravity accounts.`})]}),(0,$.jsx)(`div`,{className:`space-y-2`,children:ct.map(e=>(0,$.jsxs)(`button`,{type:`button`,onClick:()=>void Ce(e.value),"aria-current":n===e.value?`true`:void 0,className:b(`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,$.jsx)(`p`,{className:`text-sm font-medium`,children:e.label}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.hint})]},e.value))}),(0,$.jsx)(k,{children:(0,$.jsx)(D,{size:`sm`,variant:`outline`,className:`text-xs cursor-pointer`,onClick:()=>P(null),children:`Done`})})]})})]})}var dt=[{id:`claude`,label:`Claude`},{id:`codex`,label:`Codex`},{id:`antigravity`,label:`Antigravity`}];function ft(){let[e,t]=(0,Q.useState)(null),[n,r]=(0,Q.useState)(`claude`);(0,Q.useEffect)(()=>{let e=!1;return R().then(n=>{e||t(new Set(Object.keys(n.providers??{})))}).catch(()=>{e||t(new Set([`claude`]))}),()=>{e=!0}},[]);let i=dt.filter(t=>t.id===`claude`||e?.has(t.id)),a=i.length>1;return(0,$.jsxs)(`div`,{className:`space-y-4`,"data-testid":`accounts-pane`,"data-provider":n,children:[a&&(0,$.jsx)(`div`,{className:`flex gap-1 border-b border-border/50`,children:i.map(e=>(0,$.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,$.jsx)(P,{providerId:e.id}),e.label]},e.id))}),e===null&&!a&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,$.jsx)(o,{className:`size-3 animate-spin`}),` Checking configured providers...`]}),n===`claude`?(0,$.jsx)(Ke,{}):n===`codex`?(0,$.jsx)(st,{}):(0,$.jsx)(ut,{})]})}export{ft as AccountsSettingsSection};
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/agent-session-window-content-D1Qz_Jtj.js","assets/rolldown-runtime-C5c2KzVm.js","assets/vendor-ui-XWGn718B.js","assets/vendor-markdown-WX6NXGTJ.js","assets/utils-DMiycH3O.js","assets/libesm-DtVH87tT.js","assets/api-client-vI7TyFOL.js","assets/open-ppm-tab-8o5Mp2VL.js","assets/settings-store-DBwLfOkD.js","assets/preload-helper-uTix4PVD.js","assets/react-DcQQAZIk.js","assets/settings-events-DwkLDkzD.js","assets/window-store-CUC3goyK.js","assets/minimal-mode-DDuML1Oi.js","assets/panel-store-BVDYuCvt.js","assets/session-list-sync-triggers-TcIGY5Gf.js","assets/project-store-CqelYf-s.js","assets/project-framework-store-B-WxvTpu.js","assets/open-assistant-CIClEfBP.js","assets/patch-tab-metadata-DrKrCjLH.js","assets/open-settings-CO64bJ_7.js","assets/settings-categories-Y3jjEzYq.js","assets/icons-CXY5ue_g.js","assets/use-is-mobile-_O8suyE-.js","assets/tab-store-DrKCCcn0.js","assets/design-tab-metadata-DfslGXRv.js","assets/chat-jump-store-DinYYGGj.js","assets/tool-cards-DtIbRB5W.js","assets/index-DdWNTpRC.js","assets/button-BCTqB-tu.js","assets/createLucideIcon-eJ-vX0nK.js","assets/extension-icons-ybU3E-fL.js","assets/git-commit-horizontal-Dd_uNUhV.js","assets/background-output-store-D2KAitP3.js","assets/open-db-tabs-hq8ISs9i.js","assets/explorer-model-Daztib0H.js","assets/db-connection-config-FJf8q_kG.js","assets/db-types-zK7v68L_.js","assets/db-explorer-store-DiyDlsSd.js","assets/db-drivers-B-KtKQnu.js","assets/open-logs-CrdQYlxl.js","assets/use-explorer-open-state-CUkj-Dq5.js","assets/remote-access-tab-store-BZ6vf17_.js","assets/use-is-touch-only-CsQzu0T-.js","assets/git-repo-store-CTm3j9tg.js","assets/extension-store-BA3neLjA.js","assets/keybindings-store-D88QDyfS.js","assets/build-message-with-attachments-CRWLGa4Y.js","assets/close-window-C-DU_r5Y.js","assets/model-thinking-selector-helpers-B9R_GCmG.js","assets/dialog-CoO-z2qj.js","assets/portal-container-context-tAk8C8AE.js","assets/input-CcBfRi6-.js","assets/mobile-bottom-sheet-CR0IYSBI.js","assets/use-visual-viewport-CFeFggvP.js","assets/ppm-tools-DkXwX2Et.js","assets/tab-open-protocol-BUpI8eRV.js","assets/split-sql-statements-Vmj3uOWf.js","assets/session-collab-rL-aatJP.js","assets/file-store-D4_OlIcj.js","assets/slash-command-picker-B2ckAVNi.js","assets/user-message-parse-CQHAZlXx.js","assets/assistant-name-store-DunABllt.js","assets/assistant-persona-B781SaSV.js","assets/provider-selector-DcPsEA72.js","assets/chat-preparation-cache-BjKMLTNJ.js","assets/provider-logos-m5ZC_yzc.js","assets/use-coarse-long-press-DK5QuzCK.js","assets/adaptive-context-menu-xX3GYsY2.js","assets/start-ellipsis-BmXdXC0j.js","assets/tooltip-CCx1ynhU.js","assets/api-settings-D4cXrjrY.js","assets/format-date-DJ_k51mc.js","assets/image-gallery-J7t6M0LS.js","assets/session-collab-client-DU-Iuwkh.js","assets/send-to-chat-oE-JUerN.js","assets/notification-store-6S918LfB.js","assets/unsaved-grid-rows-store-CVKm9pb0.js","assets/use-assistant-telegram-binding-BDrv3xPb.js","assets/impexp-state-XddrW0ht.js","assets/design-canvas-check-DoJFnvkp.js","assets/sql-identifiers-CzF5oBAB.js","assets/format-file-meta-x6OUDfb9.js","assets/fs-api-ZCc4I_Do.js","assets/dropdown-menu-cKkDmlOg.js","assets/scroll-area-DqE4p3pX.js","assets/use-git-repo-B0bQeLpv.js","assets/clipboard-SyUe4kh-.js","assets/file-icons-DFW8l2IL.js","assets/global-ws-channel-C5DnLfQG.js","assets/ws-auth-Bh6IMZdH.js","assets/streaming-store-mU2NFGwZ.js","assets/apply-theme-BU63HGCw.js","assets/resolve-theme-CCeC2iWE.js","assets/index-B28_HhQI.css","assets/agent-session-sheet-store-uxRCMO7m.js","assets/image-preview-geometry-RIr_he1m.js","assets/markdown-context-CrpXiAXV.js","assets/use-blob-url-wwGVIzzV.js","assets/html-preview-loads-D-HBaNoF.js"])))=>i.map(i=>d[i]);
2
- import{s as e}from"./rolldown-runtime-C5c2KzVm.js";import{D as t,E as n}from"./vendor-markdown-WX6NXGTJ.js";import"./vendor-ui-XWGn718B.js";import{ui as r}from"./icons-CXY5ue_g.js";import{t as i}from"./preload-helper-uTix4PVD.js";import"./portal-container-context-tAk8C8AE.js";import{t as a}from"./mobile-bottom-sheet-CR0IYSBI.js";import"./use-visual-viewport-CFeFggvP.js";import{t as o}from"./agent-session-sheet-store-uxRCMO7m.js";var s=e(t(),1),c=n(),l=(0,s.lazy)(()=>i(()=>import(`./agent-session-window-content-D1Qz_Jtj.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99])));function u(){let e=o(e=>e.payload),t=o(e=>e.close);return e?(0,c.jsxs)(a,{open:!0,onClose:t,zIndex:45,className:`flex h-[var(--sheet-vh)] flex-col p-0`,children:[(0,c.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border px-3 py-2 shrink-0`,children:[(0,c.jsx)(`span`,{className:`truncate text-sm font-medium text-text-primary`,children:e.title??`Agent session`}),(0,c.jsx)(`button`,{type:`button`,onClick:t,className:`ml-auto flex size-11 items-center justify-center rounded text-text-secondary hover:text-text-primary`,"aria-label":`Close`,children:(0,c.jsx)(r,{className:`size-5`})})]}),(0,c.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto`,children:(0,c.jsx)(s.Suspense,{fallback:(0,c.jsx)(`div`,{className:`p-4 text-sm text-text-2`,children:`Loading…`}),children:(0,c.jsx)(l,{id:`sheet-${e.sessionId}`,payload:e})})})]}):null}export{u as AgentSessionSheet};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/agent-session-window-content-Ct6ZHTtp.js","assets/rolldown-runtime-C5c2KzVm.js","assets/vendor-ui-XWGn718B.js","assets/vendor-markdown-WX6NXGTJ.js","assets/utils-DMiycH3O.js","assets/libesm-DtVH87tT.js","assets/api-client-vI7TyFOL.js","assets/open-ppm-tab-Ycg95vdE.js","assets/settings-store-DbEIO8Ou.js","assets/preload-helper-uTix4PVD.js","assets/react-DcQQAZIk.js","assets/settings-events-DwkLDkzD.js","assets/window-store-CUC3goyK.js","assets/minimal-mode-DDuML1Oi.js","assets/panel-store-CBSQTnq9.js","assets/session-list-sync-triggers-TcIGY5Gf.js","assets/project-store-CqelYf-s.js","assets/project-framework-store-B-WxvTpu.js","assets/open-assistant-B3VjLarr.js","assets/patch-tab-metadata-jquPSDfD.js","assets/open-settings-BJGUPvOw.js","assets/settings-categories-Y3jjEzYq.js","assets/icons-CXY5ue_g.js","assets/use-is-mobile-_O8suyE-.js","assets/tab-store-CiT16Eol.js","assets/design-tab-metadata-DfslGXRv.js","assets/chat-jump-store-DinYYGGj.js","assets/tool-cards-DUKn_XTY.js","assets/index-rFeA9cN0.js","assets/button-BCTqB-tu.js","assets/createLucideIcon-eJ-vX0nK.js","assets/extension-icons-ybU3E-fL.js","assets/git-commit-horizontal-Dd_uNUhV.js","assets/background-output-store-CYu95pMo.js","assets/open-db-tabs-CZCVwLtY.js","assets/explorer-model-CHQNPtY-.js","assets/db-connection-config-sCgRWO6g.js","assets/db-types-zK7v68L_.js","assets/db-explorer-store-DIVU5YE1.js","assets/db-drivers-B-KtKQnu.js","assets/open-logs-B8h-9fK0.js","assets/use-explorer-open-state-CUkj-Dq5.js","assets/remote-access-tab-store-DxDHebNj.js","assets/use-is-touch-only-CsQzu0T-.js","assets/git-repo-store-CTm3j9tg.js","assets/extension-store-BA3neLjA.js","assets/keybindings-store-D88QDyfS.js","assets/build-message-with-attachments-CaOUFGji.js","assets/close-window-xumIsJ3C.js","assets/model-thinking-selector-helpers-BR5Y_oCs.js","assets/dialog-CoO-z2qj.js","assets/portal-container-context-tAk8C8AE.js","assets/input-CcBfRi6-.js","assets/mobile-bottom-sheet-CR0IYSBI.js","assets/use-visual-viewport-CFeFggvP.js","assets/ppm-tools-DkXwX2Et.js","assets/tab-open-protocol-BUpI8eRV.js","assets/split-sql-statements-Vmj3uOWf.js","assets/session-collab-rL-aatJP.js","assets/file-store-D4_OlIcj.js","assets/slash-command-picker-B2ckAVNi.js","assets/user-message-parse-yeAjynUW.js","assets/assistant-name-store-D5teXZ9K.js","assets/assistant-persona-B781SaSV.js","assets/provider-selector-DcPsEA72.js","assets/chat-preparation-cache-BjKMLTNJ.js","assets/provider-logos-m5ZC_yzc.js","assets/use-coarse-long-press-DK5QuzCK.js","assets/adaptive-context-menu-xX3GYsY2.js","assets/start-ellipsis-BmXdXC0j.js","assets/tooltip-CCx1ynhU.js","assets/api-settings-D4cXrjrY.js","assets/format-date-DJ_k51mc.js","assets/image-gallery-J7t6M0LS.js","assets/session-collab-client-DOUeHjr_.js","assets/send-to-chat-bbnVuPiz.js","assets/notification-store-6S918LfB.js","assets/unsaved-grid-rows-store-CVKm9pb0.js","assets/use-assistant-telegram-binding-BElVy80Y.js","assets/impexp-state-XddrW0ht.js","assets/design-canvas-check-DoJFnvkp.js","assets/sql-identifiers-CzF5oBAB.js","assets/format-file-meta-x6OUDfb9.js","assets/fs-api-ZCc4I_Do.js","assets/dropdown-menu-cKkDmlOg.js","assets/scroll-area-DqE4p3pX.js","assets/use-git-repo-B0bQeLpv.js","assets/clipboard-SyUe4kh-.js","assets/file-icons-DFW8l2IL.js","assets/global-ws-channel-C5DnLfQG.js","assets/ws-auth-Bh6IMZdH.js","assets/streaming-store-mU2NFGwZ.js","assets/apply-theme-BU63HGCw.js","assets/resolve-theme-CCeC2iWE.js","assets/index-B28_HhQI.css","assets/agent-session-sheet-store-uxRCMO7m.js","assets/image-preview-geometry-RIr_he1m.js","assets/markdown-context-CrpXiAXV.js","assets/use-blob-url-wwGVIzzV.js","assets/html-preview-loads-D-HBaNoF.js"])))=>i.map(i=>d[i]);
2
+ import{s as e}from"./rolldown-runtime-C5c2KzVm.js";import{D as t,E as n}from"./vendor-markdown-WX6NXGTJ.js";import"./vendor-ui-XWGn718B.js";import{ui as r}from"./icons-CXY5ue_g.js";import{t as i}from"./preload-helper-uTix4PVD.js";import"./portal-container-context-tAk8C8AE.js";import{t as a}from"./mobile-bottom-sheet-CR0IYSBI.js";import"./use-visual-viewport-CFeFggvP.js";import{t as o}from"./agent-session-sheet-store-uxRCMO7m.js";var s=e(t(),1),c=n(),l=(0,s.lazy)(()=>i(()=>import(`./agent-session-window-content-Ct6ZHTtp.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99])));function u(){let e=o(e=>e.payload),t=o(e=>e.close);return e?(0,c.jsxs)(a,{open:!0,onClose:t,zIndex:45,className:`flex h-[var(--sheet-vh)] flex-col p-0`,children:[(0,c.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border px-3 py-2 shrink-0`,children:[(0,c.jsx)(`span`,{className:`truncate text-sm font-medium text-text-primary`,children:e.title??`Agent session`}),(0,c.jsx)(`button`,{type:`button`,onClick:t,className:`ml-auto flex size-11 items-center justify-center rounded text-text-secondary hover:text-text-primary`,"aria-label":`Close`,children:(0,c.jsx)(r,{className:`size-5`})})]}),(0,c.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto`,children:(0,c.jsx)(s.Suspense,{fallback:(0,c.jsx)(`div`,{className:`p-4 text-sm text-text-2`,children:`Loading…`}),children:(0,c.jsx)(l,{id:`sheet-${e.sessionId}`,payload:e})})})]}):null}export{u as AgentSessionSheet};
@@ -1 +1 @@
1
- import{s as e}from"./rolldown-runtime-C5c2KzVm.js";import"./settings-store-DBwLfOkD.js";import{D as t,E as n}from"./vendor-markdown-WX6NXGTJ.js";import"./vendor-ui-XWGn718B.js";import{L as r,P as i,Sn as a}from"./icons-CXY5ue_g.js";import{y as o}from"./api-client-vI7TyFOL.js";import{n as s}from"./utils-DMiycH3O.js";import"./window-store-CUC3goyK.js";import"./panel-store-BVDYuCvt.js";import"./project-store-CqelYf-s.js";import"./project-framework-store-B-WxvTpu.js";import"./session-list-sync-triggers-TcIGY5Gf.js";import"./tab-store-DrKCCcn0.js";import{n as c}from"./use-coarse-long-press-DK5QuzCK.js";import"./chat-jump-store-DinYYGGj.js";import"./use-is-mobile-_O8suyE-.js";import"./settings-categories-Y3jjEzYq.js";import"./open-settings-CO64bJ_7.js";import"./patch-tab-metadata-DrKrCjLH.js";import"./open-assistant-CIClEfBP.js";import"./open-ppm-tab-8o5Mp2VL.js";import"./session-collab-client-DU-Iuwkh.js";import"./session-collab-rL-aatJP.js";import"./notification-store-6S918LfB.js";import"./chat-preparation-cache-BjKMLTNJ.js";import"./provider-logos-m5ZC_yzc.js";import"./provider-selector-DcPsEA72.js";import"./file-store-D4_OlIcj.js";import"./streaming-store-mU2NFGwZ.js";import"./fs-api-ZCc4I_Do.js";import{n as l,r as u}from"./global-ws-channel-C5DnLfQG.js";import"./image-gallery-J7t6M0LS.js";import"./tab-open-protocol-BUpI8eRV.js";import"./design-canvas-check-DoJFnvkp.js";import{_ as d,a as f,i as p,t as m}from"./tool-cards-DtIbRB5W.js";import"./libesm-DtVH87tT.js";import{t as h}from"./markdown-context-CrpXiAXV.js";import"./use-blob-url-wwGVIzzV.js";import"./agent-session-sheet-store-uxRCMO7m.js";var g=e(t(),1),_=2e3;function v(e,t){let n=t.reset?[]:e.slice();for(let{ev:e,ts:r,k:i,replace:a}of t.events){let t=n.findIndex(e=>e.k===i);if(t!==-1){a&&(n[t]={k:i,ts:r,ev:e});continue}let o=n.length;for(;o>0&&n[o-1].ts>r;)o--;n.splice(o,0,{k:i,ts:r,ev:e})}return n.length>2e3?n.slice(n.length-_):n}function y(){return`ats-${Math.random().toString(36).slice(2,10)}`}function b(e){let{projectName:t,providerId:n,sessionId:r,source:i,fallbackEvents:a}=e,[o,s]=(0,g.useState)([]),[c,d]=(0,g.useState)(!1),[f,p]=(0,g.useState)(!1),[m,h]=(0,g.useState)(!0),[_,b]=(0,g.useState)(null);(0,g.useEffect)(()=>{let e=y(),a=[],o;s([]),d(!1),p(!1),h(!0),b(null);let c=()=>{u(JSON.stringify({type:`agent-transcript:subscribe`,subId:e,projectName:t,providerId:n,sessionId:r,source:i,...o?{cursor:o}:{}}))},f=t=>{let n=t.detail;n.subId===e&&(a=v(a,n),o=n.cursor,s(a),d(n.available),p(n.running),h(!1),b(null))},m=t=>{let n=t.detail;n.subId===e&&(d(!1),h(!1),b(n.code))};window.addEventListener(`agent-transcript:events`,f),window.addEventListener(`agent-transcript:error`,m);let g=l(c);return c(),()=>{window.removeEventListener(`agent-transcript:events`,f),window.removeEventListener(`agent-transcript:error`,m),g(),u(JSON.stringify({type:`agent-transcript:unsubscribe`,subId:e}))}},[JSON.stringify([t,n,r,i])]);let x=(0,g.useMemo)(()=>o.map(e=>e.ev),[o]);return{events:c?x:a??[],available:c,running:f,loading:m,error:_}}var x=n();function S(e){return e.filter(e=>e.type===`tool_use`).length}function C({status:e}){return e===`loading`?null:e===`running`?(0,x.jsxs)(`span`,{className:`flex items-center gap-1 text-[10px] text-primary shrink-0`,children:[(0,x.jsx)(a,{className:`size-2.5 animate-spin`}),` running`]}):e===`failed`?(0,x.jsx)(`span`,{className:`text-[10px] text-error shrink-0`,children:`failed`}):(0,x.jsx)(`span`,{className:`text-[10px] text-success shrink-0`,children:`done`})}function w({payload:e}){let t=e??{},n=t.sessionId?p(t.sessionId,t.source):``,l=f(e=>n?e.entries[n]:void 0),{events:u,available:_,running:v,loading:y,error:w}=b({projectName:t.projectName,providerId:t.providerId,sessionId:t.sessionId,source:t.source,fallbackEvents:l}),[T,E]=(0,g.useState)(!1),D=c(),O=(0,g.useMemo)(()=>S(u),[u]),k=u[u.length-1],A=!v&&!!k&&k.type===`tool_result`&&!!k.isError,j=y?`loading`:v?`running`:A?`failed`:`done`;return(0,x.jsx)(h.Provider,{value:o(t.projectName),children:(0,x.jsxs)(`div`,{className:`flex flex-col h-full min-h-0 bg-surface @container`,children:[(0,x.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-1.5 border-b border-border/30 shrink-0`,children:[(0,x.jsx)(`span`,{className:`truncate text-xs font-medium`,children:t.title??`Agent session`}),u.length>0&&(0,x.jsx)(`span`,{className:`text-[10px] text-text-subtle shrink-0`,children:d(O)}),(0,x.jsx)(C,{status:j}),!_&&!y&&(0,x.jsx)(`span`,{className:`ml-auto text-[10px] text-text-subtle shrink-0`,title:`No live transcript for this session — showing steps already held in memory`,children:`offline`})]}),!!t.prompt&&(0,x.jsxs)(`div`,{className:`border-b border-border/30 shrink-0`,children:[(0,x.jsxs)(`button`,{type:`button`,onClick:()=>E(e=>!e),className:s(`flex w-full items-center gap-1.5 px-3 py-1.5 text-[11px] text-text-subtle hover:text-foreground`,D?`min-h-[44px]`:`min-h-[28px]`),children:[T?(0,x.jsx)(i,{className:`size-3`}):(0,x.jsx)(r,{className:`size-3`}),`Prompt`]}),T&&(0,x.jsx)(`div`,{className:`px-3 pb-2 text-[11px] text-text-secondary whitespace-pre-wrap select-text`,children:t.prompt})]}),y&&u.length===0?(0,x.jsxs)(`div`,{className:`flex-1 flex items-center justify-center gap-2 text-xs text-text-subtle`,children:[(0,x.jsx)(a,{className:`size-3 animate-spin`}),`Loading session…`]}):u.length===0?(0,x.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-xs text-text-subtle px-4 text-center`,children:w?`Could not load this session`:`No recorded steps`}):(0,x.jsx)(m,{events:u,projectName:t.projectName,variant:`window`,className:`flex-1 min-h-0 overflow-y-auto px-3 py-2 space-y-1`})]})})}export{w as default};
1
+ import{s as e}from"./rolldown-runtime-C5c2KzVm.js";import"./settings-store-DbEIO8Ou.js";import{D as t,E as n}from"./vendor-markdown-WX6NXGTJ.js";import"./vendor-ui-XWGn718B.js";import{L as r,P as i,Sn as a}from"./icons-CXY5ue_g.js";import{y as o}from"./api-client-vI7TyFOL.js";import{n as s}from"./utils-DMiycH3O.js";import"./window-store-CUC3goyK.js";import"./panel-store-CBSQTnq9.js";import"./project-store-CqelYf-s.js";import"./project-framework-store-B-WxvTpu.js";import"./session-list-sync-triggers-TcIGY5Gf.js";import"./tab-store-CiT16Eol.js";import{n as c}from"./use-coarse-long-press-DK5QuzCK.js";import"./chat-jump-store-DinYYGGj.js";import"./use-is-mobile-_O8suyE-.js";import"./settings-categories-Y3jjEzYq.js";import"./open-settings-BJGUPvOw.js";import"./patch-tab-metadata-jquPSDfD.js";import"./open-assistant-B3VjLarr.js";import"./open-ppm-tab-Ycg95vdE.js";import"./session-collab-client-DOUeHjr_.js";import"./session-collab-rL-aatJP.js";import"./notification-store-6S918LfB.js";import"./chat-preparation-cache-BjKMLTNJ.js";import"./provider-logos-m5ZC_yzc.js";import"./provider-selector-DcPsEA72.js";import"./file-store-D4_OlIcj.js";import"./streaming-store-mU2NFGwZ.js";import"./fs-api-ZCc4I_Do.js";import{n as l,r as u}from"./global-ws-channel-C5DnLfQG.js";import"./image-gallery-J7t6M0LS.js";import"./tab-open-protocol-BUpI8eRV.js";import"./design-canvas-check-DoJFnvkp.js";import{_ as d,a as f,i as p,t as m}from"./tool-cards-DUKn_XTY.js";import"./libesm-DtVH87tT.js";import{t as h}from"./markdown-context-CrpXiAXV.js";import"./use-blob-url-wwGVIzzV.js";import"./agent-session-sheet-store-uxRCMO7m.js";var g=e(t(),1),_=2e3;function v(e,t){let n=t.reset?[]:e.slice();for(let{ev:e,ts:r,k:i,replace:a}of t.events){let t=n.findIndex(e=>e.k===i);if(t!==-1){a&&(n[t]={k:i,ts:r,ev:e});continue}let o=n.length;for(;o>0&&n[o-1].ts>r;)o--;n.splice(o,0,{k:i,ts:r,ev:e})}return n.length>2e3?n.slice(n.length-_):n}function y(){return`ats-${Math.random().toString(36).slice(2,10)}`}function b(e){let{projectName:t,providerId:n,sessionId:r,source:i,fallbackEvents:a}=e,[o,s]=(0,g.useState)([]),[c,d]=(0,g.useState)(!1),[f,p]=(0,g.useState)(!1),[m,h]=(0,g.useState)(!0),[_,b]=(0,g.useState)(null);(0,g.useEffect)(()=>{let e=y(),a=[],o;s([]),d(!1),p(!1),h(!0),b(null);let c=()=>{u(JSON.stringify({type:`agent-transcript:subscribe`,subId:e,projectName:t,providerId:n,sessionId:r,source:i,...o?{cursor:o}:{}}))},f=t=>{let n=t.detail;n.subId===e&&(a=v(a,n),o=n.cursor,s(a),d(n.available),p(n.running),h(!1),b(null))},m=t=>{let n=t.detail;n.subId===e&&(d(!1),h(!1),b(n.code))};window.addEventListener(`agent-transcript:events`,f),window.addEventListener(`agent-transcript:error`,m);let g=l(c);return c(),()=>{window.removeEventListener(`agent-transcript:events`,f),window.removeEventListener(`agent-transcript:error`,m),g(),u(JSON.stringify({type:`agent-transcript:unsubscribe`,subId:e}))}},[JSON.stringify([t,n,r,i])]);let x=(0,g.useMemo)(()=>o.map(e=>e.ev),[o]);return{events:c?x:a??[],available:c,running:f,loading:m,error:_}}var x=n();function S(e){return e.filter(e=>e.type===`tool_use`).length}function C({status:e}){return e===`loading`?null:e===`running`?(0,x.jsxs)(`span`,{className:`flex items-center gap-1 text-[10px] text-primary shrink-0`,children:[(0,x.jsx)(a,{className:`size-2.5 animate-spin`}),` running`]}):e===`failed`?(0,x.jsx)(`span`,{className:`text-[10px] text-error shrink-0`,children:`failed`}):(0,x.jsx)(`span`,{className:`text-[10px] text-success shrink-0`,children:`done`})}function w({payload:e}){let t=e??{},n=t.sessionId?p(t.sessionId,t.source):``,l=f(e=>n?e.entries[n]:void 0),{events:u,available:_,running:v,loading:y,error:w}=b({projectName:t.projectName,providerId:t.providerId,sessionId:t.sessionId,source:t.source,fallbackEvents:l}),[T,E]=(0,g.useState)(!1),D=c(),O=(0,g.useMemo)(()=>S(u),[u]),k=u[u.length-1],A=!v&&!!k&&k.type===`tool_result`&&!!k.isError,j=y?`loading`:v?`running`:A?`failed`:`done`;return(0,x.jsx)(h.Provider,{value:o(t.projectName),children:(0,x.jsxs)(`div`,{className:`flex flex-col h-full min-h-0 bg-surface @container`,children:[(0,x.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-1.5 border-b border-border/30 shrink-0`,children:[(0,x.jsx)(`span`,{className:`truncate text-xs font-medium`,children:t.title??`Agent session`}),u.length>0&&(0,x.jsx)(`span`,{className:`text-[10px] text-text-subtle shrink-0`,children:d(O)}),(0,x.jsx)(C,{status:j}),!_&&!y&&(0,x.jsx)(`span`,{className:`ml-auto text-[10px] text-text-subtle shrink-0`,title:`No live transcript for this session — showing steps already held in memory`,children:`offline`})]}),!!t.prompt&&(0,x.jsxs)(`div`,{className:`border-b border-border/30 shrink-0`,children:[(0,x.jsxs)(`button`,{type:`button`,onClick:()=>E(e=>!e),className:s(`flex w-full items-center gap-1.5 px-3 py-1.5 text-[11px] text-text-subtle hover:text-foreground`,D?`min-h-[44px]`:`min-h-[28px]`),children:[T?(0,x.jsx)(i,{className:`size-3`}):(0,x.jsx)(r,{className:`size-3`}),`Prompt`]}),T&&(0,x.jsx)(`div`,{className:`px-3 pb-2 text-[11px] text-text-secondary whitespace-pre-wrap select-text`,children:t.prompt})]}),y&&u.length===0?(0,x.jsxs)(`div`,{className:`flex-1 flex items-center justify-center gap-2 text-xs text-text-subtle`,children:[(0,x.jsx)(a,{className:`size-3 animate-spin`}),`Loading session…`]}):u.length===0?(0,x.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-xs text-text-subtle px-4 text-center`,children:w?`Could not load this session`:`No recorded steps`}):(0,x.jsx)(m,{events:u,projectName:t.projectName,variant:`window`,className:`flex-1 min-h-0 overflow-y-auto px-3 py-2 space-y-1`})]})})}export{w as default};
@@ -1 +1 @@
1
- import{s as e}from"./rolldown-runtime-C5c2KzVm.js";import"./settings-store-DBwLfOkD.js";import{D as t,E as n}from"./vendor-markdown-WX6NXGTJ.js";import"./vendor-ui-XWGn718B.js";import{Sn as r,Xr as i,r as a,wn as o,yr as s}from"./icons-CXY5ue_g.js";import{j as c}from"./api-client-vI7TyFOL.js";import{n as l}from"./utils-DMiycH3O.js";import{An as u,Dn as d,G as f,K as p,On as m,jn as h,kn as g}from"./index-DdWNTpRC.js";import{t as _}from"./use-monaco-theme-LNAN16lw.js";var v=e(t(),1),y=n();function b({metadata:e}){let t=e?.filePath,n=e?.name,l=e?.resourceType??`skill`,b=e?.scope??`user`,S=e?.readOnly===!0,C=e?.shadowed===!0,w=e?.shadowedBy,T=e?.project??``,[E,D]=(0,v.useState)(``),[O,k]=(0,v.useState)(``),[A,j]=(0,v.useState)(!0),[M,N]=(0,v.useState)(null),[P,F]=(0,v.useState)(!1),I=_(),L=(0,v.useRef)(``),R=E!==O;(0,v.useEffect)(()=>{let e=!1;return j(!0),N(null),u(t,T).then(t=>{e||(D(t.content),k(t.content),L.current=t.content)}).catch(t=>{e||N(t.message)}).finally(()=>{e||j(!1)}),()=>{e=!0}},[t,T]);let z=(0,v.useCallback)(async()=>{if(S||P)return;let e=L.current;if(e!==O){F(!0);try{await h(t,e,T),k(e),D(e),c.success(`Saved`),g.getState().reload()}catch(e){c.error(e.message)}finally{F(!1)}}},[t,T,O,S,P]);(0,v.useEffect)(()=>{let e=e=>{(e.ctrlKey||e.metaKey)&&e.key.toLowerCase()===`s`&&(e.preventDefault(),z())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[z]);let B=m[l];return(0,y.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,y.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border px-3 py-2 shrink-0`,children:[(0,y.jsx)(B,{className:`size-4 text-text-subtle`}),(0,y.jsx)(`span`,{className:`text-sm font-semibold`,children:n}),(0,y.jsx)(d,{scope:b}),R&&!S&&(0,y.jsx)(`span`,{className:`size-1.5 rounded-full bg-primary`,title:`Unsaved changes`}),(0,y.jsx)(`div`,{className:`flex-1`}),(0,y.jsxs)(`span`,{className:`hidden sm:block text-[11px] text-text-subtle`,children:[l,` · markdown`]}),!S&&(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)(`button`,{onClick:()=>D(O),disabled:!R||P,className:`flex items-center gap-1 rounded px-2 py-1 text-xs text-text-secondary hover:bg-surface-elevated disabled:opacity-40`,children:[(0,y.jsx)(i,{className:`size-3.5`}),` Revert`]}),(0,y.jsxs)(`button`,{onClick:()=>void z(),disabled:!R||P,className:`flex items-center gap-1 rounded bg-primary px-2.5 py-1 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-40`,children:[P?(0,y.jsx)(r,{className:`size-3.5 animate-spin`}):(0,y.jsx)(s,{className:`size-3.5`}),` Save`]})]})]}),S&&(0,y.jsx)(x,{icon:o,tone:`muted`,children:`Bundled resource — read-only. Duplicate it (from the AI Resources panel) to make an editable copy.`}),C&&w&&(0,y.jsxs)(x,{icon:a,tone:`warn`,children:[`This `,l,` is overridden by another “`,w.name,`” from a higher-priority source (`,w.source,`). It is currently inactive.`]}),(0,y.jsx)(`div`,{className:`min-h-0 flex-1`,children:A?(0,y.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,y.jsx)(r,{className:`size-5 animate-spin text-primary`})}):M?(0,y.jsx)(`div`,{className:`p-6 text-center text-sm text-destructive`,children:M}):(0,y.jsx)(p,{beforeMount:f,height:`100%`,language:`markdown`,theme:I,value:E,onChange:e=>{let t=e??``;L.current=t,D(t)},options:{readOnly:S,minimap:{enabled:!1},fontSize:13,wordWrap:`on`,scrollBeyondLastLine:!1,lineNumbers:`on`}})})]})}function x({icon:e,tone:t,children:n}){return(0,y.jsxs)(`div`,{className:l(`flex items-start gap-2 px-3 py-2 text-[12px] shrink-0 border-b border-border`,t===`warn`?`bg-amber-500/10 text-amber-300`:`bg-surface-elevated text-text-secondary`),children:[(0,y.jsx)(e,{className:`mt-0.5 size-3.5 shrink-0`}),(0,y.jsx)(`span`,{children:n})]})}export{b as AiResourceEditor};
1
+ import{s as e}from"./rolldown-runtime-C5c2KzVm.js";import"./settings-store-DbEIO8Ou.js";import{D as t,E as n}from"./vendor-markdown-WX6NXGTJ.js";import"./vendor-ui-XWGn718B.js";import{Sn as r,Xr as i,r as a,wn as o,yr as s}from"./icons-CXY5ue_g.js";import{j as c}from"./api-client-vI7TyFOL.js";import{n as l}from"./utils-DMiycH3O.js";import{An as u,Dn as d,G as f,K as p,On as m,jn as h,kn as g}from"./index-rFeA9cN0.js";import{t as _}from"./use-monaco-theme-D7J2RPBT.js";var v=e(t(),1),y=n();function b({metadata:e}){let t=e?.filePath,n=e?.name,l=e?.resourceType??`skill`,b=e?.scope??`user`,S=e?.readOnly===!0,C=e?.shadowed===!0,w=e?.shadowedBy,T=e?.project??``,[E,D]=(0,v.useState)(``),[O,k]=(0,v.useState)(``),[A,j]=(0,v.useState)(!0),[M,N]=(0,v.useState)(null),[P,F]=(0,v.useState)(!1),I=_(),L=(0,v.useRef)(``),R=E!==O;(0,v.useEffect)(()=>{let e=!1;return j(!0),N(null),u(t,T).then(t=>{e||(D(t.content),k(t.content),L.current=t.content)}).catch(t=>{e||N(t.message)}).finally(()=>{e||j(!1)}),()=>{e=!0}},[t,T]);let z=(0,v.useCallback)(async()=>{if(S||P)return;let e=L.current;if(e!==O){F(!0);try{await h(t,e,T),k(e),D(e),c.success(`Saved`),g.getState().reload()}catch(e){c.error(e.message)}finally{F(!1)}}},[t,T,O,S,P]);(0,v.useEffect)(()=>{let e=e=>{(e.ctrlKey||e.metaKey)&&e.key.toLowerCase()===`s`&&(e.preventDefault(),z())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[z]);let B=m[l];return(0,y.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,y.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border px-3 py-2 shrink-0`,children:[(0,y.jsx)(B,{className:`size-4 text-text-subtle`}),(0,y.jsx)(`span`,{className:`text-sm font-semibold`,children:n}),(0,y.jsx)(d,{scope:b}),R&&!S&&(0,y.jsx)(`span`,{className:`size-1.5 rounded-full bg-primary`,title:`Unsaved changes`}),(0,y.jsx)(`div`,{className:`flex-1`}),(0,y.jsxs)(`span`,{className:`hidden sm:block text-[11px] text-text-subtle`,children:[l,` · markdown`]}),!S&&(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)(`button`,{onClick:()=>D(O),disabled:!R||P,className:`flex items-center gap-1 rounded px-2 py-1 text-xs text-text-secondary hover:bg-surface-elevated disabled:opacity-40`,children:[(0,y.jsx)(i,{className:`size-3.5`}),` Revert`]}),(0,y.jsxs)(`button`,{onClick:()=>void z(),disabled:!R||P,className:`flex items-center gap-1 rounded bg-primary px-2.5 py-1 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-40`,children:[P?(0,y.jsx)(r,{className:`size-3.5 animate-spin`}):(0,y.jsx)(s,{className:`size-3.5`}),` Save`]})]})]}),S&&(0,y.jsx)(x,{icon:o,tone:`muted`,children:`Bundled resource — read-only. Duplicate it (from the AI Resources panel) to make an editable copy.`}),C&&w&&(0,y.jsxs)(x,{icon:a,tone:`warn`,children:[`This `,l,` is overridden by another “`,w.name,`” from a higher-priority source (`,w.source,`). It is currently inactive.`]}),(0,y.jsx)(`div`,{className:`min-h-0 flex-1`,children:A?(0,y.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,y.jsx)(r,{className:`size-5 animate-spin text-primary`})}):M?(0,y.jsx)(`div`,{className:`p-6 text-center text-sm text-destructive`,children:M}):(0,y.jsx)(p,{beforeMount:f,height:`100%`,language:`markdown`,theme:I,value:E,onChange:e=>{let t=e??``;L.current=t,D(t)},options:{readOnly:S,minimap:{enabled:!1},fontSize:13,wordWrap:`on`,scrollBeyondLastLine:!1,lineNumbers:`on`}})})]})}function x({icon:e,tone:t,children:n}){return(0,y.jsxs)(`div`,{className:l(`flex items-start gap-2 px-3 py-2 text-[12px] shrink-0 border-b border-border`,t===`warn`?`bg-amber-500/10 text-amber-300`:`bg-surface-elevated text-text-secondary`),children:[(0,y.jsx)(e,{className:`mt-0.5 size-3.5 shrink-0`}),(0,y.jsx)(`span`,{children:n})]})}export{b as AiResourceEditor};