@hienlh/ppm 0.26.37 → 0.26.38

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 (583) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/CLAUDE.md +1 -0
  3. package/assets/skills/ppm/SKILL.md +1 -1
  4. package/assets/skills/ppm/references/http-api.md +1 -1
  5. package/dist/web/assets/{accounts-settings-section-BEhO_tk8.js → accounts-settings-section-D-PqtQnD.js} +1 -1
  6. package/dist/web/assets/accounts-settings-section-D-PqtQnD.js.br +0 -0
  7. package/dist/web/assets/accounts-settings-section-D-PqtQnD.js.gz +0 -0
  8. package/dist/web/assets/{agent-session-sheet-CPGbWwvV.js → agent-session-sheet-BVUOHPel.js} +2 -2
  9. package/dist/web/assets/agent-session-sheet-BVUOHPel.js.br +0 -0
  10. package/dist/web/assets/agent-session-sheet-BVUOHPel.js.gz +0 -0
  11. package/dist/web/assets/{agent-session-window-content-Dg07wugC.js → agent-session-window-content-Ca7SCG6W.js} +1 -1
  12. package/dist/web/assets/agent-session-window-content-Ca7SCG6W.js.br +0 -0
  13. package/dist/web/assets/agent-session-window-content-Ca7SCG6W.js.gz +0 -0
  14. package/dist/web/assets/{ai-resource-editor-CtREVrLq.js → ai-resource-editor-D00Oam8J.js} +1 -1
  15. package/dist/web/assets/ai-resource-editor-D00Oam8J.js.br +0 -0
  16. package/dist/web/assets/ai-resource-editor-D00Oam8J.js.gz +0 -0
  17. package/dist/web/assets/{ai-settings-section-pI5l7zwf.js → ai-settings-section-BLe9-EpS.js} +1 -1
  18. package/dist/web/assets/ai-settings-section-BLe9-EpS.js.br +0 -0
  19. package/dist/web/assets/ai-settings-section-BLe9-EpS.js.gz +0 -0
  20. package/dist/web/assets/{ai-settings-section-D4V29bTK.js → ai-settings-section-CnkPwVLU.js} +1 -1
  21. package/dist/web/assets/ai-settings-section-CnkPwVLU.js.br +0 -0
  22. package/dist/web/assets/ai-settings-section-CnkPwVLU.js.gz +0 -0
  23. package/dist/web/assets/{android-tab-COBazVpe.js → android-tab-DLAzMiHC.js} +1 -1
  24. package/dist/web/assets/android-tab-DLAzMiHC.js.br +0 -0
  25. package/dist/web/assets/android-tab-DLAzMiHC.js.gz +0 -0
  26. package/dist/web/assets/{antigravity-usage-view-0ncr6xtB.js → antigravity-usage-view-BwJirJDB.js} +1 -1
  27. package/dist/web/assets/antigravity-usage-view-BwJirJDB.js.br +0 -0
  28. package/dist/web/assets/antigravity-usage-view-BwJirJDB.js.gz +0 -0
  29. package/dist/web/assets/{appearance-settings-section-C2EEFTJx.js → appearance-settings-section-Cg93hnbw.js} +1 -1
  30. package/dist/web/assets/appearance-settings-section-Cg93hnbw.js.br +0 -0
  31. package/dist/web/assets/appearance-settings-section-Cg93hnbw.js.gz +0 -0
  32. package/dist/web/assets/{apps-panel-B8S6bQbf.js → apps-panel-Dm_PuAAY.js} +1 -1
  33. package/dist/web/assets/apps-panel-Dm_PuAAY.js.br +0 -0
  34. package/dist/web/assets/apps-panel-Dm_PuAAY.js.gz +0 -0
  35. package/dist/web/assets/assistant-settings-dialog-DrNk9cLn.js +1 -0
  36. package/dist/web/assets/assistant-settings-dialog-DrNk9cLn.js.br +0 -0
  37. package/dist/web/assets/assistant-settings-dialog-DrNk9cLn.js.gz +0 -0
  38. package/dist/web/assets/assistant-settings-section-B8Jv55x9.js +10 -0
  39. package/dist/web/assets/assistant-settings-section-B8Jv55x9.js.br +0 -0
  40. package/dist/web/assets/assistant-settings-section-B8Jv55x9.js.gz +0 -0
  41. package/dist/web/assets/{assistant-tab-CQ_F6i7a.js → assistant-tab-CbqlNE1F.js} +1 -1
  42. package/dist/web/assets/assistant-tab-CbqlNE1F.js.br +0 -0
  43. package/dist/web/assets/assistant-tab-CbqlNE1F.js.gz +0 -0
  44. package/dist/web/assets/{branch-review-tab-X1OFlHua.js → branch-review-tab-BqX4APRf.js} +1 -1
  45. package/dist/web/assets/branch-review-tab-BqX4APRf.js.br +0 -0
  46. package/dist/web/assets/branch-review-tab-BqX4APRf.js.gz +0 -0
  47. package/dist/web/assets/{chat-tab-DvrdNeY6.js → chat-tab-DN7qq8cc.js} +1 -1
  48. package/dist/web/assets/chat-tab-DN7qq8cc.js.br +0 -0
  49. package/dist/web/assets/chat-tab-DN7qq8cc.js.gz +0 -0
  50. package/dist/web/assets/{chat-tab-CC4Kdd-2.js → chat-tab-fLAOpQ_u.js} +3 -3
  51. package/dist/web/assets/chat-tab-fLAOpQ_u.js.br +0 -0
  52. package/dist/web/assets/chat-tab-fLAOpQ_u.js.gz +0 -0
  53. package/dist/web/assets/{code-editor-DghKg-2t.js → code-editor-CfuElgqJ.js} +4 -4
  54. package/dist/web/assets/code-editor-CfuElgqJ.js.br +0 -0
  55. package/dist/web/assets/code-editor-CfuElgqJ.js.gz +0 -0
  56. package/dist/web/assets/{conflict-editor-DjMfF2Ic.js → conflict-editor-DICp8vBn.js} +1 -1
  57. package/dist/web/assets/conflict-editor-DICp8vBn.js.br +0 -0
  58. package/dist/web/assets/conflict-editor-DICp8vBn.js.gz +0 -0
  59. package/dist/web/assets/{connection-form-tab-4F3QZwjd.js → connection-form-tab-9hphAEjz.js} +1 -1
  60. package/dist/web/assets/connection-form-tab-9hphAEjz.js.br +0 -0
  61. package/dist/web/assets/connection-form-tab-9hphAEjz.js.gz +0 -0
  62. package/dist/web/assets/{csv-preview-DrXZZ19d.js → csv-preview-DlpTG0Dl.js} +1 -1
  63. package/dist/web/assets/csv-preview-DlpTG0Dl.js.br +0 -0
  64. package/dist/web/assets/csv-preview-DlpTG0Dl.js.gz +0 -0
  65. package/dist/web/assets/{database-drivers-section-CkRM5irG.js → database-drivers-section-BFHxL9mI.js} +1 -1
  66. package/dist/web/assets/database-drivers-section-BFHxL9mI.js.br +0 -0
  67. package/dist/web/assets/database-drivers-section-BFHxL9mI.js.gz +0 -0
  68. package/dist/web/assets/{db-tab-parts-CJ1YDKqH.js → db-tab-parts-D0qYynXq.js} +1 -1
  69. package/dist/web/assets/db-tab-parts-D0qYynXq.js.br +0 -0
  70. package/dist/web/assets/db-tab-parts-D0qYynXq.js.gz +0 -0
  71. package/dist/web/assets/{design-settings-section-CAK_hCh4.js → design-settings-section-mz5SAG_q.js} +1 -1
  72. package/dist/web/assets/design-settings-section-mz5SAG_q.js.br +0 -0
  73. package/dist/web/assets/design-settings-section-mz5SAG_q.js.gz +0 -0
  74. package/dist/web/assets/{design-tab-DE9hJ2Tp.js → design-tab-DsCF3mGH.js} +1 -1
  75. package/dist/web/assets/design-tab-DsCF3mGH.js.br +0 -0
  76. package/dist/web/assets/design-tab-DsCF3mGH.js.gz +0 -0
  77. package/dist/web/assets/{designs-sidebar-panel-Ccw_gDvw.js → designs-sidebar-panel-CsMfTvE7.js} +1 -1
  78. package/dist/web/assets/designs-sidebar-panel-CsMfTvE7.js.br +0 -0
  79. package/dist/web/assets/designs-sidebar-panel-CsMfTvE7.js.gz +0 -0
  80. package/dist/web/assets/{diff-viewer-BW6UFALQ.js → diff-viewer-DoVYLEDL.js} +1 -1
  81. package/dist/web/assets/diff-viewer-DoVYLEDL.js.br +0 -0
  82. package/dist/web/assets/diff-viewer-DoVYLEDL.js.gz +0 -0
  83. package/dist/web/assets/{docx-preview-BKDKCeHF.js → docx-preview-DQowG7xW.js} +1 -1
  84. package/dist/web/assets/docx-preview-DQowG7xW.js.br +0 -0
  85. package/dist/web/assets/docx-preview-DQowG7xW.js.gz +0 -0
  86. package/dist/web/assets/{editor-dialog-Dv85fQ2J.js → editor-dialog-Bll_0SLC.js} +1 -1
  87. package/dist/web/assets/{editor-dialog-Dv85fQ2J.js.br → editor-dialog-Bll_0SLC.js.br} +0 -0
  88. package/dist/web/assets/editor-dialog-Bll_0SLC.js.gz +0 -0
  89. package/dist/web/assets/{editor-language-service-BhZftNpk.js → editor-language-service-D0EdKzyF.js} +1 -1
  90. package/dist/web/assets/editor-language-service-D0EdKzyF.js.br +0 -0
  91. package/dist/web/assets/editor-language-service-D0EdKzyF.js.gz +0 -0
  92. package/dist/web/assets/{explorer-body-CTnhg-Dh.js → explorer-body-DV8x9eue.js} +1 -1
  93. package/dist/web/assets/explorer-body-DV8x9eue.js.br +0 -0
  94. package/dist/web/assets/explorer-body-DV8x9eue.js.gz +0 -0
  95. package/dist/web/assets/{explorer-window-content-BNbOw8hc.js → explorer-window-content-FunaKilr.js} +1 -1
  96. package/dist/web/assets/explorer-window-content-FunaKilr.js.br +0 -0
  97. package/dist/web/assets/explorer-window-content-FunaKilr.js.gz +0 -0
  98. package/dist/web/assets/{extension-manager-section-DFP5g4da.js → extension-manager-section-Bohs7fxs.js} +1 -1
  99. package/dist/web/assets/extension-manager-section-Bohs7fxs.js.br +0 -0
  100. package/dist/web/assets/extension-manager-section-Bohs7fxs.js.gz +0 -0
  101. package/dist/web/assets/{extension-webview-_3bdHWFj.js → extension-webview-7es2HdcX.js} +1 -1
  102. package/dist/web/assets/extension-webview-7es2HdcX.js.br +0 -0
  103. package/dist/web/assets/extension-webview-7es2HdcX.js.gz +0 -0
  104. package/dist/web/assets/{files-settings-section-D2dimKCL.js → files-settings-section-o1vjHPI9.js} +1 -1
  105. package/dist/web/assets/files-settings-section-o1vjHPI9.js.br +0 -0
  106. package/dist/web/assets/files-settings-section-o1vjHPI9.js.gz +0 -0
  107. package/dist/web/assets/{general-settings-section-CrVbQVQz.js → general-settings-section-BTqYjgEL.js} +1 -1
  108. package/dist/web/assets/general-settings-section-BTqYjgEL.js.br +0 -0
  109. package/dist/web/assets/general-settings-section-BTqYjgEL.js.gz +0 -0
  110. package/dist/web/assets/{git-log-panel-l4LbpPzQ.js → git-log-panel-B6NRKMAP.js} +1 -1
  111. package/dist/web/assets/git-log-panel-B6NRKMAP.js.br +0 -0
  112. package/dist/web/assets/git-log-panel-B6NRKMAP.js.gz +0 -0
  113. package/dist/web/assets/{git-review-tab-BrZSTQcW.js → git-review-tab-DQrht-6-.js} +1 -1
  114. package/dist/web/assets/git-review-tab-DQrht-6-.js.br +0 -0
  115. package/dist/web/assets/git-review-tab-DQrht-6-.js.gz +0 -0
  116. package/dist/web/assets/{glide-data-grid-DsDeT5uF.js → glide-data-grid-Dez_JZmI.js} +1 -1
  117. package/dist/web/assets/glide-data-grid-Dez_JZmI.js.br +0 -0
  118. package/dist/web/assets/glide-data-grid-Dez_JZmI.js.gz +0 -0
  119. package/dist/web/assets/{grid-save-dialog-DGKAHRTL.js → grid-save-dialog-Du-vI2V6.js} +1 -1
  120. package/dist/web/assets/grid-save-dialog-Du-vI2V6.js.br +0 -0
  121. package/dist/web/assets/grid-save-dialog-Du-vI2V6.js.gz +0 -0
  122. package/dist/web/assets/{group-chat-tab-CdwqdwYc.js → group-chat-tab-2g0gAxZ5.js} +1 -1
  123. package/dist/web/assets/group-chat-tab-2g0gAxZ5.js.br +0 -0
  124. package/dist/web/assets/group-chat-tab-2g0gAxZ5.js.gz +0 -0
  125. package/dist/web/assets/{impexp-tab-DB_yqgLE.js → impexp-tab-Bl6qCid8.js} +1 -1
  126. package/dist/web/assets/impexp-tab-Bl6qCid8.js.br +0 -0
  127. package/dist/web/assets/impexp-tab-Bl6qCid8.js.gz +0 -0
  128. package/dist/web/assets/{index-ix3m5QQT.js → index-BcmsW6J_.js} +6 -6
  129. package/dist/web/assets/index-BcmsW6J_.js.br +0 -0
  130. package/dist/web/assets/index-BcmsW6J_.js.gz +0 -0
  131. package/dist/web/assets/{jira-watcher-section-BWBiQlPs.js → jira-watcher-section-4689J17V.js} +1 -1
  132. package/dist/web/assets/{keybindings-store-QmeVPDSj.js → keybindings-store-CG_n7DH2.js} +1 -1
  133. package/dist/web/assets/{keyboard-shortcuts-section-DGJxSmeN.js → keyboard-shortcuts-section-DSqw8Ml8.js} +1 -1
  134. package/dist/web/assets/keyboard-shortcuts-section-DSqw8Ml8.js.br +0 -0
  135. package/dist/web/assets/keyboard-shortcuts-section-DSqw8Ml8.js.gz +0 -0
  136. package/dist/web/assets/{language-servers-section-BGlgHxKe.js → language-servers-section-DJBfaZA4.js} +2 -2
  137. package/dist/web/assets/language-servers-section-DJBfaZA4.js.br +0 -0
  138. package/dist/web/assets/language-servers-section-DJBfaZA4.js.gz +0 -0
  139. package/dist/web/assets/{logs-app-CQLEmiL0.js → logs-app-DxBVLDd2.js} +1 -1
  140. package/dist/web/assets/logs-app-DxBVLDd2.js.br +0 -0
  141. package/dist/web/assets/logs-app-DxBVLDd2.js.gz +0 -0
  142. package/dist/web/assets/{logs-tab-BUZ8Pl7m.js → logs-tab-D_072YXV.js} +1 -1
  143. package/dist/web/assets/{logs-window-content-Nk_lEwwi.js → logs-window-content-DDjtyE37.js} +1 -1
  144. package/dist/web/assets/{lsp-client-DI0orIfb.js → lsp-client-Cn0Gw2i1.js} +1 -1
  145. package/dist/web/assets/lsp-client-Cn0Gw2i1.js.br +0 -0
  146. package/dist/web/assets/lsp-client-Cn0Gw2i1.js.gz +0 -0
  147. package/dist/web/assets/{markdown-renderer-CTLbCvuX.js → markdown-renderer-DWs7wCJg.js} +1 -1
  148. package/dist/web/assets/markdown-renderer-DWs7wCJg.js.br +0 -0
  149. package/dist/web/assets/markdown-renderer-DWs7wCJg.js.gz +0 -0
  150. package/dist/web/assets/{markdown-renderer-5ELHEVko.js → markdown-renderer-lI4melkl.js} +1 -1
  151. package/dist/web/assets/markdown-renderer-lI4melkl.js.br +0 -0
  152. package/dist/web/assets/markdown-renderer-lI4melkl.js.gz +0 -0
  153. package/dist/web/assets/{mobile-explorer-sheet-DUXUIT_S.js → mobile-explorer-sheet-Cco1KQT4.js} +1 -1
  154. package/dist/web/assets/mobile-explorer-sheet-Cco1KQT4.js.br +9 -0
  155. package/dist/web/assets/mobile-explorer-sheet-Cco1KQT4.js.gz +0 -0
  156. package/dist/web/assets/{monaco-diff-editor-C51sEZ3h.js → monaco-diff-editor-EvkwLgOR.js} +1 -1
  157. package/dist/web/assets/{new-design-dialog-DyTs5NF3.js → new-design-dialog-B6H5SAs9.js} +1 -1
  158. package/dist/web/assets/new-design-dialog-B6H5SAs9.js.br +0 -0
  159. package/dist/web/assets/new-design-dialog-B6H5SAs9.js.gz +0 -0
  160. package/dist/web/assets/{notifications-settings-section-rDUrin7F.js → notifications-settings-section-BCQWsm1s.js} +1 -1
  161. package/dist/web/assets/notifications-settings-section-BCQWsm1s.js.br +0 -0
  162. package/dist/web/assets/notifications-settings-section-BCQWsm1s.js.gz +0 -0
  163. package/dist/web/assets/{onboarding-entry-CyjU3Cgr.js → onboarding-entry-CnoG7q-Z.js} +1 -1
  164. package/dist/web/assets/onboarding-entry-CnoG7q-Z.js.br +0 -0
  165. package/dist/web/assets/onboarding-entry-CnoG7q-Z.js.gz +0 -0
  166. package/dist/web/assets/{open-manager-chat-n5_HfX06.js → open-manager-chat-B5lk5qEJ.js} +1 -1
  167. package/dist/web/assets/open-manager-chat-B5lk5qEJ.js.br +0 -0
  168. package/dist/web/assets/open-manager-chat-B5lk5qEJ.js.gz +0 -0
  169. package/dist/web/assets/{open-manager-chat-Ds3FJ52k.js → open-manager-chat-DApW6Spm.js} +1 -1
  170. package/dist/web/assets/open-manager-chat-DApW6Spm.js.br +0 -0
  171. package/dist/web/assets/open-manager-chat-DApW6Spm.js.gz +0 -0
  172. package/dist/web/assets/{problems-panel-DLlLK8v8.js → problems-panel-DdkbdS0F.js} +1 -1
  173. package/dist/web/assets/problems-panel-DdkbdS0F.js.br +0 -0
  174. package/dist/web/assets/problems-panel-DdkbdS0F.js.gz +0 -0
  175. package/dist/web/assets/{process-table-RDK2LHuV.js → process-table-BumSkiKn.js} +1 -1
  176. package/dist/web/assets/process-table-BumSkiKn.js.br +0 -0
  177. package/dist/web/assets/process-table-BumSkiKn.js.gz +0 -0
  178. package/dist/web/assets/{proxy-settings-section-DiFiMJhe.js → proxy-settings-section-BeICHxOb.js} +1 -1
  179. package/dist/web/assets/proxy-settings-section-BeICHxOb.js.br +0 -0
  180. package/dist/web/assets/proxy-settings-section-BeICHxOb.js.gz +0 -0
  181. package/dist/web/assets/{query-tab-Bxm0IDr6.js → query-tab-CxJm6m5c.js} +1 -1
  182. package/dist/web/assets/query-tab-CxJm6m5c.js.br +0 -0
  183. package/dist/web/assets/query-tab-CxJm6m5c.js.gz +0 -0
  184. package/dist/web/assets/{release-notes-window-content-DNj9KYy_.js → release-notes-window-content-EDVVyIVd.js} +1 -1
  185. package/dist/web/assets/{remembered-approvals-section-BiBtGfyX.js → remembered-approvals-section-DU2uPVyI.js} +1 -1
  186. package/dist/web/assets/{remembered-approvals-section-BiBtGfyX.js.br → remembered-approvals-section-DU2uPVyI.js.br} +0 -0
  187. package/dist/web/assets/remembered-approvals-section-DU2uPVyI.js.gz +0 -0
  188. package/dist/web/assets/{remote-access-settings-section-Dnj8FTwS.js → remote-access-settings-section-CA30y1tx.js} +1 -1
  189. package/dist/web/assets/remote-access-settings-section-CA30y1tx.js.br +0 -0
  190. package/dist/web/assets/remote-access-settings-section-CA30y1tx.js.gz +0 -0
  191. package/dist/web/assets/{remote-desktop-clipboard-notice-BodoNltd.js → remote-desktop-clipboard-notice-X6O2j6Ei.js} +1 -1
  192. package/dist/web/assets/remote-desktop-clipboard-notice-X6O2j6Ei.js.br +0 -0
  193. package/dist/web/assets/remote-desktop-clipboard-notice-X6O2j6Ei.js.gz +0 -0
  194. package/dist/web/assets/{remote-desktop-mobile-sheet-_w3mYM_P.js → remote-desktop-mobile-sheet-CNiPZC_f.js} +2 -2
  195. package/dist/web/assets/remote-desktop-mobile-sheet-CNiPZC_f.js.br +0 -0
  196. package/dist/web/assets/remote-desktop-mobile-sheet-CNiPZC_f.js.gz +0 -0
  197. package/dist/web/assets/{remote-desktop-mobile-view-CMXT4IiE.js → remote-desktop-mobile-view-C6x7qx6_.js} +1 -1
  198. package/dist/web/assets/remote-desktop-mobile-view-C6x7qx6_.js.br +0 -0
  199. package/dist/web/assets/remote-desktop-mobile-view-C6x7qx6_.js.gz +0 -0
  200. package/dist/web/assets/{remote-desktop-readiness-gate-BN8sjRA7.js → remote-desktop-readiness-gate-BOkTob7N.js} +1 -1
  201. package/dist/web/assets/remote-desktop-readiness-gate-BOkTob7N.js.br +0 -0
  202. package/dist/web/assets/remote-desktop-readiness-gate-BOkTob7N.js.gz +0 -0
  203. package/dist/web/assets/{remote-desktop-window-content-CNT3V6WV.js → remote-desktop-window-content-NXUDCvxA.js} +1 -1
  204. package/dist/web/assets/remote-desktop-window-content-NXUDCvxA.js.br +0 -0
  205. package/dist/web/assets/remote-desktop-window-content-NXUDCvxA.js.gz +0 -0
  206. package/dist/web/assets/{rename-object-dialog-jTc0ilcX.js → rename-object-dialog-B0DVo1rh.js} +1 -1
  207. package/dist/web/assets/rename-object-dialog-B0DVo1rh.js.br +0 -0
  208. package/dist/web/assets/rename-object-dialog-B0DVo1rh.js.gz +0 -0
  209. package/dist/web/assets/{reveal-task-in-sidebar-D6S9NuwD.js → reveal-task-in-sidebar-BgY2MVyz.js} +1 -1
  210. package/dist/web/assets/{review-address-setup-DlNvPw0H.js → review-address-setup-Cp23SbVb.js} +1 -1
  211. package/dist/web/assets/review-address-setup-Cp23SbVb.js.br +0 -0
  212. package/dist/web/assets/review-address-setup-Cp23SbVb.js.gz +0 -0
  213. package/dist/web/assets/{review-code-n_E_bah4.js → review-code-o_RiZ7x7.js} +1 -1
  214. package/dist/web/assets/review-code-o_RiZ7x7.js.br +0 -0
  215. package/dist/web/assets/review-code-o_RiZ7x7.js.gz +0 -0
  216. package/dist/web/assets/{save-as-dialog-DNEArWI8.js → save-as-dialog-CI4kwdSY.js} +1 -1
  217. package/dist/web/assets/save-as-dialog-CI4kwdSY.js.br +0 -0
  218. package/dist/web/assets/save-as-dialog-CI4kwdSY.js.gz +0 -0
  219. package/dist/web/assets/{schedule-form-w1IqUBGt.js → schedule-form-BLVcjg5V.js} +3 -3
  220. package/dist/web/assets/schedule-form-BLVcjg5V.js.br +0 -0
  221. package/dist/web/assets/schedule-form-BLVcjg5V.js.gz +0 -0
  222. package/dist/web/assets/{schedule-script-editor-CE-07UUD.js → schedule-script-editor-VL3jHyiF.js} +1 -1
  223. package/dist/web/assets/schedule-script-editor-VL3jHyiF.js.br +0 -0
  224. package/dist/web/assets/schedule-script-editor-VL3jHyiF.js.gz +0 -0
  225. package/dist/web/assets/{schedules-app-Dr_UCkYQ.js → schedules-app-CB1rYvIj.js} +1 -1
  226. package/dist/web/assets/schedules-app-CB1rYvIj.js.br +0 -0
  227. package/dist/web/assets/schedules-app-CB1rYvIj.js.gz +0 -0
  228. package/dist/web/assets/{schedules-settings-section-DgJP_2hL.js → schedules-settings-section-j76Tzb5X.js} +3 -3
  229. package/dist/web/assets/schedules-settings-section-j76Tzb5X.js.br +0 -0
  230. package/dist/web/assets/schedules-settings-section-j76Tzb5X.js.gz +0 -0
  231. package/dist/web/assets/{schedules-tab-DvrCbSh2.js → schedules-tab-DL_Wx6k9.js} +1 -1
  232. package/dist/web/assets/schedules-tab-DL_Wx6k9.js.br +0 -0
  233. package/dist/web/assets/schedules-tab-DL_Wx6k9.js.gz +0 -0
  234. package/dist/web/assets/{schedules-ui-B8cBUXvy.js → schedules-ui-C4d-vaoO.js} +1 -1
  235. package/dist/web/assets/schedules-ui-C4d-vaoO.js.br +0 -0
  236. package/dist/web/assets/schedules-ui-C4d-vaoO.js.gz +0 -0
  237. package/dist/web/assets/{schedules-window-content-BdTqADTN.js → schedules-window-content-Df-_ZgXr.js} +1 -1
  238. package/dist/web/assets/schedules-window-content-Df-_ZgXr.js.br +0 -0
  239. package/dist/web/assets/schedules-window-content-Df-_ZgXr.js.gz +0 -0
  240. package/dist/web/assets/{session-review-tab-CHQwXl3k.js → session-review-tab-tJ_vIIiC.js} +1 -1
  241. package/dist/web/assets/session-review-tab-tJ_vIIiC.js.br +0 -0
  242. package/dist/web/assets/{session-review-tab-CHQwXl3k.js.gz → session-review-tab-tJ_vIIiC.js.gz} +0 -0
  243. package/dist/web/assets/{settings-body-BGi_yp6T.js → settings-body-BSaNoyv5.js} +1 -1
  244. package/dist/web/assets/settings-body-BSaNoyv5.js.br +0 -0
  245. package/dist/web/assets/settings-body-BSaNoyv5.js.gz +0 -0
  246. package/dist/web/assets/{settings-rows-DxAQdCNV.js → settings-rows-DBcJYfkQ.js} +1 -1
  247. package/dist/web/assets/settings-rows-DBcJYfkQ.js.br +0 -0
  248. package/dist/web/assets/settings-rows-DBcJYfkQ.js.gz +0 -0
  249. package/dist/web/assets/{settings-section-content-B2NMhI8X.js → settings-section-content-CINa4tfI.js} +1 -1
  250. package/dist/web/assets/{settings-section-content-BclHkj-U.js → settings-section-content-DIJ3EmpR.js} +2 -2
  251. package/dist/web/assets/settings-section-content-DIJ3EmpR.js.br +0 -0
  252. package/dist/web/assets/settings-section-content-DIJ3EmpR.js.gz +0 -0
  253. package/dist/web/assets/{settings-tab-H9KOVNSp.js → settings-tab-Ol_mOmGQ.js} +1 -1
  254. package/dist/web/assets/{settings-window-content-GIPC9SFL.js → settings-window-content-c07fzGyN.js} +1 -1
  255. package/dist/web/assets/{sql-object-tab-CMt5WjOZ.js → sql-object-tab-DGi3TT7w.js} +1 -1
  256. package/dist/web/assets/sql-object-tab-DGi3TT7w.js.br +0 -0
  257. package/dist/web/assets/sql-object-tab-DGi3TT7w.js.gz +0 -0
  258. package/dist/web/assets/{sqlite-viewer-BazSUbqq.js → sqlite-viewer-jhvIP7vo.js} +1 -1
  259. package/dist/web/assets/sqlite-viewer-jhvIP7vo.js.br +0 -0
  260. package/dist/web/assets/sqlite-viewer-jhvIP7vo.js.gz +0 -0
  261. package/dist/web/assets/{storage-settings-section-B1VnfN9n.js → storage-settings-section-ChVSDc0v.js} +1 -1
  262. package/dist/web/assets/storage-settings-section-ChVSDc0v.js.br +0 -0
  263. package/dist/web/assets/storage-settings-section-ChVSDc0v.js.gz +0 -0
  264. package/dist/web/assets/{structure-save-dialog-Dgh9tRdb.js → structure-save-dialog-BtMAoGIc.js} +1 -1
  265. package/dist/web/assets/structure-save-dialog-BtMAoGIc.js.br +0 -0
  266. package/dist/web/assets/structure-save-dialog-BtMAoGIc.js.gz +0 -0
  267. package/dist/web/assets/{structure-tab-DDMMTTcg.js → structure-tab-Ckt8FKGe.js} +1 -1
  268. package/dist/web/assets/structure-tab-Ckt8FKGe.js.br +0 -0
  269. package/dist/web/assets/structure-tab-Ckt8FKGe.js.gz +0 -0
  270. package/dist/web/assets/{system-monitor-body-BD8nBNey.js → system-monitor-body-DtB-B_Wz.js} +2 -2
  271. package/dist/web/assets/system-monitor-body-DtB-B_Wz.js.br +0 -0
  272. package/dist/web/assets/system-monitor-body-DtB-B_Wz.js.gz +0 -0
  273. package/dist/web/assets/{system-monitor-tab-CeN1RErt.js → system-monitor-tab-D5zybnxh.js} +1 -1
  274. package/dist/web/assets/{system-monitor-window-content-BN2JK7-U.js → system-monitor-window-content-Cu_-wvWZ.js} +1 -1
  275. package/dist/web/assets/{tab-host-window-content-C97cDVKH.js → tab-host-window-content-D7EqSSAt.js} +1 -1
  276. package/dist/web/assets/tab-host-window-content-D7EqSSAt.js.br +0 -0
  277. package/dist/web/assets/tab-host-window-content-D7EqSSAt.js.gz +0 -0
  278. package/dist/web/assets/{table-tab-Dy1uZWXy.js → table-tab-C9bOscgK.js} +1 -1
  279. package/dist/web/assets/table-tab-C9bOscgK.js.br +0 -0
  280. package/dist/web/assets/table-tab-C9bOscgK.js.gz +0 -0
  281. package/dist/web/assets/{task-detail-mobile-IaMJIz_N.js → task-detail-mobile-qeV_sNAp.js} +1 -1
  282. package/dist/web/assets/task-detail-mobile-qeV_sNAp.js.br +0 -0
  283. package/dist/web/assets/task-detail-mobile-qeV_sNAp.js.gz +0 -0
  284. package/dist/web/assets/{task-sheet-DVFo_TeZ.js → task-sheet-BeFuPXaK.js} +1 -1
  285. package/dist/web/assets/task-sheet-BeFuPXaK.js.br +0 -0
  286. package/dist/web/assets/task-sheet-BeFuPXaK.js.gz +0 -0
  287. package/dist/web/assets/{task-status-grid-B3Rh0z5j.js → task-status-grid-BWXxSln8.js} +1 -1
  288. package/dist/web/assets/task-status-grid-BWXxSln8.js.br +0 -0
  289. package/dist/web/assets/task-status-grid-BWXxSln8.js.gz +0 -0
  290. package/dist/web/assets/{task-tab-B_y6t0uh.js → task-tab-COXcAWDZ.js} +1 -1
  291. package/dist/web/assets/task-tab-COXcAWDZ.js.br +0 -0
  292. package/dist/web/assets/task-tab-COXcAWDZ.js.gz +0 -0
  293. package/dist/web/assets/{tasks-sidebar-panel-DGyqyNAq.js → tasks-sidebar-panel-Dcd6EEDk.js} +1 -1
  294. package/dist/web/assets/tasks-sidebar-panel-Dcd6EEDk.js.br +0 -0
  295. package/dist/web/assets/tasks-sidebar-panel-Dcd6EEDk.js.gz +0 -0
  296. package/dist/web/assets/{telegram-bot-token-field-DPChDRoY.js → telegram-bot-token-field-BfN342WZ.js} +1 -1
  297. package/dist/web/assets/telegram-bot-token-field-BfN342WZ.js.br +0 -0
  298. package/dist/web/assets/telegram-bot-token-field-BfN342WZ.js.gz +0 -0
  299. package/dist/web/assets/{terminal-tab-CMrkki1e.js → terminal-tab-CyQl3pxr.js} +1 -1
  300. package/dist/web/assets/terminal-tab-CyQl3pxr.js.br +0 -0
  301. package/dist/web/assets/terminal-tab-CyQl3pxr.js.gz +0 -0
  302. package/dist/web/assets/{tool-cards-ByfYqVsL.js → tool-cards-BMN3VW6q.js} +3 -3
  303. package/dist/web/assets/tool-cards-BMN3VW6q.js.br +0 -0
  304. package/dist/web/assets/tool-cards-BMN3VW6q.js.gz +0 -0
  305. package/dist/web/assets/{tools-settings-section-B3cpVpAc.js → tools-settings-section-CtPDlsRo.js} +1 -1
  306. package/dist/web/assets/tools-settings-section-CtPDlsRo.js.br +0 -0
  307. package/dist/web/assets/tools-settings-section-CtPDlsRo.js.gz +0 -0
  308. package/dist/web/assets/{use-db-read-DeRAN-5C.js → use-db-read-DdRO9Vkw.js} +1 -1
  309. package/dist/web/assets/use-db-read-DdRO9Vkw.js.br +0 -0
  310. package/dist/web/assets/use-db-read-DdRO9Vkw.js.gz +0 -0
  311. package/dist/web/assets/{use-inline-blame-x1_OPRN2.js → use-inline-blame-BZR16aV_.js} +1 -1
  312. package/dist/web/assets/use-inline-blame-BZR16aV_.js.br +0 -0
  313. package/dist/web/assets/use-inline-blame-BZR16aV_.js.gz +0 -0
  314. package/dist/web/assets/{use-lsp-kByMJgNI.js → use-lsp-Cm7adI5s.js} +1 -1
  315. package/dist/web/assets/use-lsp-Cm7adI5s.js.br +0 -0
  316. package/dist/web/assets/use-lsp-Cm7adI5s.js.gz +0 -0
  317. package/dist/web/assets/{use-monaco-theme-BQ-OZWX-.js → use-monaco-theme-BsFzXkdm.js} +1 -1
  318. package/dist/web/assets/{use-process-kill-DePGCnDh.js → use-process-kill-BD9HiWEg.js} +1 -1
  319. package/dist/web/assets/use-process-kill-BD9HiWEg.js.br +0 -0
  320. package/dist/web/assets/use-process-kill-BD9HiWEg.js.gz +0 -0
  321. package/dist/web/assets/{use-sql-schema-info-CEwen2i1.js → use-sql-schema-info-DWwquiuC.js} +1 -1
  322. package/dist/web/assets/use-sql-schema-info-DWwquiuC.js.br +0 -0
  323. package/dist/web/assets/use-sql-schema-info-DWwquiuC.js.gz +0 -0
  324. package/dist/web/assets/{use-websocket-C9n8q7-s.js → use-websocket-CBeEhzUm.js} +1 -1
  325. package/dist/web/assets/{vault-settings-section-Qf4G31wB.js → vault-settings-section-2J4xRjY_.js} +1 -1
  326. package/dist/web/assets/vault-settings-section-2J4xRjY_.js.br +0 -0
  327. package/dist/web/assets/vault-settings-section-2J4xRjY_.js.gz +0 -0
  328. package/dist/web/assets/{voice-settings-section-YdjYWdW7.js → voice-settings-section-Tc3W3koi.js} +1 -1
  329. package/dist/web/assets/voice-settings-section-Tc3W3koi.js.br +0 -0
  330. package/dist/web/assets/voice-settings-section-Tc3W3koi.js.gz +0 -0
  331. package/dist/web/assets/{web-browser-settings-section-XrT7sOpD.js → web-browser-settings-section-B9DJYdTK.js} +1 -1
  332. package/dist/web/assets/web-browser-settings-section-B9DJYdTK.js.br +0 -0
  333. package/dist/web/assets/web-browser-settings-section-B9DJYdTK.js.gz +0 -0
  334. package/dist/web/assets/{web-browser-tab-BuIPf4J8.js → web-browser-tab-DTw6FNL-.js} +1 -1
  335. package/dist/web/assets/{web-browser-view-DzyPBSfd.js → web-browser-view-D7u7Rl2v.js} +1 -1
  336. package/dist/web/assets/web-browser-view-D7u7Rl2v.js.br +0 -0
  337. package/dist/web/assets/web-browser-view-D7u7Rl2v.js.gz +0 -0
  338. package/dist/web/assets/{web-browser-window-content-B29mzsLG.js → web-browser-window-content-DHSag7jn.js} +1 -1
  339. package/dist/web/assets/{web-preview-tab-CNgD447y.js → web-preview-tab-CEqLBZGN.js} +1 -1
  340. package/dist/web/assets/web-preview-tab-CEqLBZGN.js.br +0 -0
  341. package/dist/web/assets/web-preview-tab-CEqLBZGN.js.gz +0 -0
  342. package/dist/web/assets/{xlsx-preview-b8gMgch2.js → xlsx-preview-DuXzgm1X.js} +1 -1
  343. package/dist/web/assets/xlsx-preview-DuXzgm1X.js.br +0 -0
  344. package/dist/web/assets/xlsx-preview-DuXzgm1X.js.gz +0 -0
  345. package/dist/web/index.html +2 -2
  346. package/dist/web/index.html.br +0 -0
  347. package/dist/web/index.html.gz +0 -0
  348. package/dist/web/sw.js +1 -1
  349. package/dist/web/sw.js.br +0 -0
  350. package/dist/web/sw.js.gz +0 -0
  351. package/docs/architecture/ppm-assistant.md +11 -3
  352. package/package.json +1 -1
  353. package/src/server/routes/settings.ts +8 -4
  354. package/src/services/assistant-settings-tools/settings-catalog-ai.ts +10 -0
  355. package/src/services/assistant-telegram/assistant-telegram-card-reminders.ts +224 -0
  356. package/src/services/assistant-telegram/assistant-telegram-cards.ts +3 -1
  357. package/src/services/assistant-telegram/assistant-telegram-commands.ts +10 -1
  358. package/src/services/assistant-telegram/assistant-telegram-db-notices.ts +8 -4
  359. package/src/services/assistant-telegram/assistant-telegram-manager-cards.ts +2 -0
  360. package/src/services/assistant-telegram/assistant-telegram-send-queue.ts +25 -0
  361. package/src/services/assistant-telegram/assistant-telegram-silence.ts +7 -90
  362. package/src/services/assistant-telegram/assistant-telegram.service.ts +6 -1
  363. package/src/services/telegram/telegram-bot-client.ts +41 -8
  364. package/src/shared/assistant-telegram-card-reminders.ts +20 -0
  365. package/src/shared/assistant-telegram-quiet.ts +1 -1
  366. package/src/types/config.ts +7 -0
  367. package/src/web/components/settings/assistant-telegram-settings.tsx +7 -2
  368. package/src/web/components/settings/telegram-card-reminder-settings.tsx +84 -0
  369. package/dist/web/assets/accounts-settings-section-BEhO_tk8.js.br +0 -0
  370. package/dist/web/assets/accounts-settings-section-BEhO_tk8.js.gz +0 -0
  371. package/dist/web/assets/agent-session-sheet-CPGbWwvV.js.br +0 -0
  372. package/dist/web/assets/agent-session-sheet-CPGbWwvV.js.gz +0 -0
  373. package/dist/web/assets/agent-session-window-content-Dg07wugC.js.br +0 -0
  374. package/dist/web/assets/agent-session-window-content-Dg07wugC.js.gz +0 -0
  375. package/dist/web/assets/ai-resource-editor-CtREVrLq.js.br +0 -0
  376. package/dist/web/assets/ai-resource-editor-CtREVrLq.js.gz +0 -0
  377. package/dist/web/assets/ai-settings-section-D4V29bTK.js.br +0 -0
  378. package/dist/web/assets/ai-settings-section-D4V29bTK.js.gz +0 -0
  379. package/dist/web/assets/ai-settings-section-pI5l7zwf.js.br +0 -0
  380. package/dist/web/assets/ai-settings-section-pI5l7zwf.js.gz +0 -0
  381. package/dist/web/assets/android-tab-COBazVpe.js.br +0 -0
  382. package/dist/web/assets/android-tab-COBazVpe.js.gz +0 -0
  383. package/dist/web/assets/antigravity-usage-view-0ncr6xtB.js.br +0 -0
  384. package/dist/web/assets/antigravity-usage-view-0ncr6xtB.js.gz +0 -0
  385. package/dist/web/assets/appearance-settings-section-C2EEFTJx.js.br +0 -0
  386. package/dist/web/assets/appearance-settings-section-C2EEFTJx.js.gz +0 -0
  387. package/dist/web/assets/apps-panel-B8S6bQbf.js.br +0 -0
  388. package/dist/web/assets/apps-panel-B8S6bQbf.js.gz +0 -0
  389. package/dist/web/assets/assistant-settings-dialog-Dkj30xcq.js +0 -1
  390. package/dist/web/assets/assistant-settings-dialog-Dkj30xcq.js.br +0 -0
  391. package/dist/web/assets/assistant-settings-dialog-Dkj30xcq.js.gz +0 -0
  392. package/dist/web/assets/assistant-settings-section-ChpHdoRK.js +0 -10
  393. package/dist/web/assets/assistant-settings-section-ChpHdoRK.js.br +0 -0
  394. package/dist/web/assets/assistant-settings-section-ChpHdoRK.js.gz +0 -0
  395. package/dist/web/assets/assistant-tab-CQ_F6i7a.js.br +0 -0
  396. package/dist/web/assets/assistant-tab-CQ_F6i7a.js.gz +0 -0
  397. package/dist/web/assets/branch-review-tab-X1OFlHua.js.br +0 -0
  398. package/dist/web/assets/branch-review-tab-X1OFlHua.js.gz +0 -0
  399. package/dist/web/assets/chat-tab-CC4Kdd-2.js.br +0 -0
  400. package/dist/web/assets/chat-tab-CC4Kdd-2.js.gz +0 -0
  401. package/dist/web/assets/chat-tab-DvrdNeY6.js.br +0 -0
  402. package/dist/web/assets/chat-tab-DvrdNeY6.js.gz +0 -0
  403. package/dist/web/assets/code-editor-DghKg-2t.js.br +0 -0
  404. package/dist/web/assets/code-editor-DghKg-2t.js.gz +0 -0
  405. package/dist/web/assets/conflict-editor-DjMfF2Ic.js.br +0 -0
  406. package/dist/web/assets/conflict-editor-DjMfF2Ic.js.gz +0 -0
  407. package/dist/web/assets/connection-form-tab-4F3QZwjd.js.br +0 -0
  408. package/dist/web/assets/connection-form-tab-4F3QZwjd.js.gz +0 -0
  409. package/dist/web/assets/csv-preview-DrXZZ19d.js.br +0 -0
  410. package/dist/web/assets/csv-preview-DrXZZ19d.js.gz +0 -0
  411. package/dist/web/assets/database-drivers-section-CkRM5irG.js.br +0 -0
  412. package/dist/web/assets/database-drivers-section-CkRM5irG.js.gz +0 -0
  413. package/dist/web/assets/db-tab-parts-CJ1YDKqH.js.br +0 -0
  414. package/dist/web/assets/db-tab-parts-CJ1YDKqH.js.gz +0 -0
  415. package/dist/web/assets/design-settings-section-CAK_hCh4.js.br +0 -0
  416. package/dist/web/assets/design-settings-section-CAK_hCh4.js.gz +0 -0
  417. package/dist/web/assets/design-tab-DE9hJ2Tp.js.br +0 -0
  418. package/dist/web/assets/design-tab-DE9hJ2Tp.js.gz +0 -0
  419. package/dist/web/assets/designs-sidebar-panel-Ccw_gDvw.js.br +0 -0
  420. package/dist/web/assets/designs-sidebar-panel-Ccw_gDvw.js.gz +0 -0
  421. package/dist/web/assets/diff-viewer-BW6UFALQ.js.br +0 -0
  422. package/dist/web/assets/diff-viewer-BW6UFALQ.js.gz +0 -0
  423. package/dist/web/assets/docx-preview-BKDKCeHF.js.br +0 -0
  424. package/dist/web/assets/docx-preview-BKDKCeHF.js.gz +0 -0
  425. package/dist/web/assets/editor-dialog-Dv85fQ2J.js.gz +0 -0
  426. package/dist/web/assets/editor-language-service-BhZftNpk.js.br +0 -0
  427. package/dist/web/assets/editor-language-service-BhZftNpk.js.gz +0 -0
  428. package/dist/web/assets/explorer-body-CTnhg-Dh.js.br +0 -0
  429. package/dist/web/assets/explorer-body-CTnhg-Dh.js.gz +0 -0
  430. package/dist/web/assets/explorer-window-content-BNbOw8hc.js.br +0 -0
  431. package/dist/web/assets/explorer-window-content-BNbOw8hc.js.gz +0 -0
  432. package/dist/web/assets/extension-manager-section-DFP5g4da.js.br +0 -0
  433. package/dist/web/assets/extension-manager-section-DFP5g4da.js.gz +0 -0
  434. package/dist/web/assets/extension-webview-_3bdHWFj.js.br +0 -0
  435. package/dist/web/assets/extension-webview-_3bdHWFj.js.gz +0 -0
  436. package/dist/web/assets/files-settings-section-D2dimKCL.js.br +0 -0
  437. package/dist/web/assets/files-settings-section-D2dimKCL.js.gz +0 -0
  438. package/dist/web/assets/general-settings-section-CrVbQVQz.js.br +0 -0
  439. package/dist/web/assets/general-settings-section-CrVbQVQz.js.gz +0 -0
  440. package/dist/web/assets/git-log-panel-l4LbpPzQ.js.br +0 -0
  441. package/dist/web/assets/git-log-panel-l4LbpPzQ.js.gz +0 -0
  442. package/dist/web/assets/git-review-tab-BrZSTQcW.js.br +0 -0
  443. package/dist/web/assets/git-review-tab-BrZSTQcW.js.gz +0 -0
  444. package/dist/web/assets/glide-data-grid-DsDeT5uF.js.br +0 -0
  445. package/dist/web/assets/glide-data-grid-DsDeT5uF.js.gz +0 -0
  446. package/dist/web/assets/grid-save-dialog-DGKAHRTL.js.br +0 -0
  447. package/dist/web/assets/grid-save-dialog-DGKAHRTL.js.gz +0 -0
  448. package/dist/web/assets/group-chat-tab-CdwqdwYc.js.br +0 -0
  449. package/dist/web/assets/group-chat-tab-CdwqdwYc.js.gz +0 -0
  450. package/dist/web/assets/impexp-tab-DB_yqgLE.js.br +0 -0
  451. package/dist/web/assets/impexp-tab-DB_yqgLE.js.gz +0 -0
  452. package/dist/web/assets/index-ix3m5QQT.js.br +0 -0
  453. package/dist/web/assets/index-ix3m5QQT.js.gz +0 -0
  454. package/dist/web/assets/keyboard-shortcuts-section-DGJxSmeN.js.br +0 -0
  455. package/dist/web/assets/keyboard-shortcuts-section-DGJxSmeN.js.gz +0 -0
  456. package/dist/web/assets/language-servers-section-BGlgHxKe.js.br +0 -0
  457. package/dist/web/assets/language-servers-section-BGlgHxKe.js.gz +0 -0
  458. package/dist/web/assets/logs-app-CQLEmiL0.js.br +0 -0
  459. package/dist/web/assets/logs-app-CQLEmiL0.js.gz +0 -0
  460. package/dist/web/assets/lsp-client-DI0orIfb.js.br +0 -0
  461. package/dist/web/assets/lsp-client-DI0orIfb.js.gz +0 -0
  462. package/dist/web/assets/markdown-renderer-5ELHEVko.js.br +0 -0
  463. package/dist/web/assets/markdown-renderer-5ELHEVko.js.gz +0 -0
  464. package/dist/web/assets/markdown-renderer-CTLbCvuX.js.br +0 -0
  465. package/dist/web/assets/markdown-renderer-CTLbCvuX.js.gz +0 -0
  466. package/dist/web/assets/mobile-explorer-sheet-DUXUIT_S.js.br +0 -0
  467. package/dist/web/assets/mobile-explorer-sheet-DUXUIT_S.js.gz +0 -0
  468. package/dist/web/assets/new-design-dialog-DyTs5NF3.js.br +0 -0
  469. package/dist/web/assets/new-design-dialog-DyTs5NF3.js.gz +0 -0
  470. package/dist/web/assets/notifications-settings-section-rDUrin7F.js.br +0 -0
  471. package/dist/web/assets/notifications-settings-section-rDUrin7F.js.gz +0 -0
  472. package/dist/web/assets/onboarding-entry-CyjU3Cgr.js.br +0 -0
  473. package/dist/web/assets/onboarding-entry-CyjU3Cgr.js.gz +0 -0
  474. package/dist/web/assets/open-manager-chat-Ds3FJ52k.js.br +0 -0
  475. package/dist/web/assets/open-manager-chat-Ds3FJ52k.js.gz +0 -0
  476. package/dist/web/assets/open-manager-chat-n5_HfX06.js.br +0 -0
  477. package/dist/web/assets/open-manager-chat-n5_HfX06.js.gz +0 -0
  478. package/dist/web/assets/problems-panel-DLlLK8v8.js.br +0 -0
  479. package/dist/web/assets/problems-panel-DLlLK8v8.js.gz +0 -0
  480. package/dist/web/assets/process-table-RDK2LHuV.js.br +0 -0
  481. package/dist/web/assets/process-table-RDK2LHuV.js.gz +0 -0
  482. package/dist/web/assets/proxy-settings-section-DiFiMJhe.js.br +0 -0
  483. package/dist/web/assets/proxy-settings-section-DiFiMJhe.js.gz +0 -0
  484. package/dist/web/assets/query-tab-Bxm0IDr6.js.br +0 -0
  485. package/dist/web/assets/query-tab-Bxm0IDr6.js.gz +0 -0
  486. package/dist/web/assets/remembered-approvals-section-BiBtGfyX.js.gz +0 -0
  487. package/dist/web/assets/remote-access-settings-section-Dnj8FTwS.js.br +0 -0
  488. package/dist/web/assets/remote-access-settings-section-Dnj8FTwS.js.gz +0 -0
  489. package/dist/web/assets/remote-desktop-clipboard-notice-BodoNltd.js.br +0 -0
  490. package/dist/web/assets/remote-desktop-clipboard-notice-BodoNltd.js.gz +0 -0
  491. package/dist/web/assets/remote-desktop-mobile-sheet-_w3mYM_P.js.br +0 -0
  492. package/dist/web/assets/remote-desktop-mobile-sheet-_w3mYM_P.js.gz +0 -0
  493. package/dist/web/assets/remote-desktop-mobile-view-CMXT4IiE.js.br +0 -0
  494. package/dist/web/assets/remote-desktop-mobile-view-CMXT4IiE.js.gz +0 -0
  495. package/dist/web/assets/remote-desktop-readiness-gate-BN8sjRA7.js.br +0 -0
  496. package/dist/web/assets/remote-desktop-readiness-gate-BN8sjRA7.js.gz +0 -0
  497. package/dist/web/assets/remote-desktop-window-content-CNT3V6WV.js.br +0 -0
  498. package/dist/web/assets/remote-desktop-window-content-CNT3V6WV.js.gz +0 -0
  499. package/dist/web/assets/rename-object-dialog-jTc0ilcX.js.br +0 -0
  500. package/dist/web/assets/rename-object-dialog-jTc0ilcX.js.gz +0 -0
  501. package/dist/web/assets/review-address-setup-DlNvPw0H.js.br +0 -0
  502. package/dist/web/assets/review-address-setup-DlNvPw0H.js.gz +0 -0
  503. package/dist/web/assets/review-code-n_E_bah4.js.br +0 -0
  504. package/dist/web/assets/review-code-n_E_bah4.js.gz +0 -0
  505. package/dist/web/assets/save-as-dialog-DNEArWI8.js.br +0 -0
  506. package/dist/web/assets/save-as-dialog-DNEArWI8.js.gz +0 -0
  507. package/dist/web/assets/schedule-form-w1IqUBGt.js.br +0 -0
  508. package/dist/web/assets/schedule-form-w1IqUBGt.js.gz +0 -0
  509. package/dist/web/assets/schedule-script-editor-CE-07UUD.js.br +0 -0
  510. package/dist/web/assets/schedule-script-editor-CE-07UUD.js.gz +0 -0
  511. package/dist/web/assets/schedules-app-Dr_UCkYQ.js.br +0 -0
  512. package/dist/web/assets/schedules-app-Dr_UCkYQ.js.gz +0 -0
  513. package/dist/web/assets/schedules-settings-section-DgJP_2hL.js.br +0 -0
  514. package/dist/web/assets/schedules-settings-section-DgJP_2hL.js.gz +0 -0
  515. package/dist/web/assets/schedules-tab-DvrCbSh2.js.br +0 -0
  516. package/dist/web/assets/schedules-tab-DvrCbSh2.js.gz +0 -0
  517. package/dist/web/assets/schedules-ui-B8cBUXvy.js.br +0 -0
  518. package/dist/web/assets/schedules-ui-B8cBUXvy.js.gz +0 -0
  519. package/dist/web/assets/schedules-window-content-BdTqADTN.js.br +0 -0
  520. package/dist/web/assets/schedules-window-content-BdTqADTN.js.gz +0 -0
  521. package/dist/web/assets/session-review-tab-CHQwXl3k.js.br +0 -0
  522. package/dist/web/assets/settings-body-BGi_yp6T.js.br +0 -0
  523. package/dist/web/assets/settings-body-BGi_yp6T.js.gz +0 -0
  524. package/dist/web/assets/settings-rows-DxAQdCNV.js.br +0 -0
  525. package/dist/web/assets/settings-rows-DxAQdCNV.js.gz +0 -0
  526. package/dist/web/assets/settings-section-content-BclHkj-U.js.br +0 -0
  527. package/dist/web/assets/settings-section-content-BclHkj-U.js.gz +0 -0
  528. package/dist/web/assets/sql-object-tab-CMt5WjOZ.js.br +0 -0
  529. package/dist/web/assets/sql-object-tab-CMt5WjOZ.js.gz +0 -0
  530. package/dist/web/assets/sqlite-viewer-BazSUbqq.js.br +0 -0
  531. package/dist/web/assets/sqlite-viewer-BazSUbqq.js.gz +0 -0
  532. package/dist/web/assets/storage-settings-section-B1VnfN9n.js.br +0 -0
  533. package/dist/web/assets/storage-settings-section-B1VnfN9n.js.gz +0 -0
  534. package/dist/web/assets/structure-save-dialog-Dgh9tRdb.js.br +0 -0
  535. package/dist/web/assets/structure-save-dialog-Dgh9tRdb.js.gz +0 -0
  536. package/dist/web/assets/structure-tab-DDMMTTcg.js.br +0 -0
  537. package/dist/web/assets/structure-tab-DDMMTTcg.js.gz +0 -0
  538. package/dist/web/assets/system-monitor-body-BD8nBNey.js.br +0 -0
  539. package/dist/web/assets/system-monitor-body-BD8nBNey.js.gz +0 -0
  540. package/dist/web/assets/tab-host-window-content-C97cDVKH.js.br +0 -0
  541. package/dist/web/assets/tab-host-window-content-C97cDVKH.js.gz +0 -0
  542. package/dist/web/assets/table-tab-Dy1uZWXy.js.br +0 -0
  543. package/dist/web/assets/table-tab-Dy1uZWXy.js.gz +0 -0
  544. package/dist/web/assets/task-detail-mobile-IaMJIz_N.js.br +0 -0
  545. package/dist/web/assets/task-detail-mobile-IaMJIz_N.js.gz +0 -0
  546. package/dist/web/assets/task-sheet-DVFo_TeZ.js.br +0 -0
  547. package/dist/web/assets/task-sheet-DVFo_TeZ.js.gz +0 -0
  548. package/dist/web/assets/task-status-grid-B3Rh0z5j.js.br +0 -0
  549. package/dist/web/assets/task-status-grid-B3Rh0z5j.js.gz +0 -0
  550. package/dist/web/assets/task-tab-B_y6t0uh.js.br +0 -0
  551. package/dist/web/assets/task-tab-B_y6t0uh.js.gz +0 -0
  552. package/dist/web/assets/tasks-sidebar-panel-DGyqyNAq.js.br +0 -0
  553. package/dist/web/assets/tasks-sidebar-panel-DGyqyNAq.js.gz +0 -0
  554. package/dist/web/assets/telegram-bot-token-field-DPChDRoY.js.br +0 -0
  555. package/dist/web/assets/telegram-bot-token-field-DPChDRoY.js.gz +0 -0
  556. package/dist/web/assets/terminal-tab-CMrkki1e.js.br +0 -0
  557. package/dist/web/assets/terminal-tab-CMrkki1e.js.gz +0 -0
  558. package/dist/web/assets/tool-cards-ByfYqVsL.js.br +0 -0
  559. package/dist/web/assets/tool-cards-ByfYqVsL.js.gz +0 -0
  560. package/dist/web/assets/tools-settings-section-B3cpVpAc.js.br +0 -0
  561. package/dist/web/assets/tools-settings-section-B3cpVpAc.js.gz +0 -0
  562. package/dist/web/assets/use-db-read-DeRAN-5C.js.br +0 -0
  563. package/dist/web/assets/use-db-read-DeRAN-5C.js.gz +0 -0
  564. package/dist/web/assets/use-inline-blame-x1_OPRN2.js.br +0 -0
  565. package/dist/web/assets/use-inline-blame-x1_OPRN2.js.gz +0 -0
  566. package/dist/web/assets/use-lsp-kByMJgNI.js.br +0 -0
  567. package/dist/web/assets/use-lsp-kByMJgNI.js.gz +0 -0
  568. package/dist/web/assets/use-process-kill-DePGCnDh.js.br +0 -0
  569. package/dist/web/assets/use-process-kill-DePGCnDh.js.gz +0 -0
  570. package/dist/web/assets/use-sql-schema-info-CEwen2i1.js.br +0 -0
  571. package/dist/web/assets/use-sql-schema-info-CEwen2i1.js.gz +0 -0
  572. package/dist/web/assets/vault-settings-section-Qf4G31wB.js.br +0 -0
  573. package/dist/web/assets/vault-settings-section-Qf4G31wB.js.gz +0 -0
  574. package/dist/web/assets/voice-settings-section-YdjYWdW7.js.br +0 -0
  575. package/dist/web/assets/voice-settings-section-YdjYWdW7.js.gz +0 -0
  576. package/dist/web/assets/web-browser-settings-section-XrT7sOpD.js.br +0 -0
  577. package/dist/web/assets/web-browser-settings-section-XrT7sOpD.js.gz +0 -0
  578. package/dist/web/assets/web-browser-view-DzyPBSfd.js.br +0 -0
  579. package/dist/web/assets/web-browser-view-DzyPBSfd.js.gz +0 -0
  580. package/dist/web/assets/web-preview-tab-CNgD447y.js.br +0 -0
  581. package/dist/web/assets/web-preview-tab-CNgD447y.js.gz +0 -0
  582. package/dist/web/assets/xlsx-preview-b8gMgch2.js.br +0 -0
  583. package/dist/web/assets/xlsx-preview-b8gMgch2.js.gz +0 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.26.38] - 2026-11-26
4
+
5
+ ### Added
6
+
7
+ - **A setting for card reminders on Telegram**: turn them off or choose the wait (1–240 minutes, 5 by default) in Settings → PPM Assistant → Telegram; the Assistant can change both.
8
+
9
+ ### Fixed
10
+
11
+ - **One Telegram reminder for unanswered cards**: cards due together arrive as one message listing each card, each card is reminded about once, and a reminder due in quiet hours comes once they end.
12
+ - **A slow Telegram no longer duplicates messages**: a reminder whose send timed out is not sent again, and a card is sent at most twice.
13
+
3
14
  ## [0.26.37] - 2026-11-25
4
15
 
5
16
  ### Added
package/CLAUDE.md CHANGED
@@ -257,6 +257,7 @@ Related: `configService.save()`/`set()` throw when `load()` has not run, because
257
257
  - **Codex has no "ignore my `config.toml`", and merges a same-named MCP table key by key**: a server PPM defines under a name the user's config also uses gets the user's `command` beside PPM's `url` (measured on codex 0.161: the thread then fails to load its config), or the user's keys answering under a name PPM approved. An isolated session therefore reads the effective config with `config/read`, disables each user server by name, refuses the session on a name clash, and refuses it too when the config cannot be read (`codex-assistant-mcp-guard.ts`).
258
258
  - **Claude's `settingSources: []` drops more than hooks and plugins**: authentication still works (it comes from `buildQueryEnv` and the CLI's credential store), but whatever only `~/.claude/settings.json` provides is gone too, its `env` block and `apiKeyHelper` included — a proxy or key helper configured only there does not reach an isolated query (PPM Assistant sessions, `completeOnce`).
259
259
  - **A chat message with no socket keeps the previous "chatting device" unless it clears it**: `lastSender` is written only when a socket sent the message, so a message from Telegram or a watch used to leave the last PPM tab that wrote as the target of the Assistant's screen tools, which then drove a desk screen while the user was on their phone. Every server origin (`telegram`, `watch`) clears it in `src/server/ws/chat.ts`; a new origin must too, or `ui_*` tools stop answering `no-device`.
260
+ - **A Telegram `sendMessage` that times out has usually arrived, so retrying it on every timeout multiplies it**: the Bot API has no idempotency key and no way to ask whether a message went out (a bot never sees its own messages in `getUpdates`). On 26/11/2026 Telegram answered slowly for two minutes (`getUpdates` 502s, then timeouts), and one card reminder went out five times: four 10 s timeouts, each delivered, then a success. The client now marks such a failure `maybeSent` (a timeout, a dropped connection, a 2xx whose body was cut off, a 504 page; a refused connection, a DNS failure or an unreachable network is not, since nothing was sent), gives `sendMessage` 30 s rather than 10, and the send queue repeats a `maybeSent` message at most once, 30 s later (`ifMaybeSent: "resend-once"`, the default, because a lost card leaves a decision waiting with nobody told), or never (`"drop"`, for reminders). So a card can arrive twice, never more. Another 5xx (502, 503) is still retried as before, so a long outage does not lose a card: the duplicates came from timeouts, and whether Telegram delivers a message it answered with a 502 is not known. Do not "fix" a second timeout by probing `getMe` and resending when it fails: on 26/11 `getUpdates` was timing out too, so the probe would have said "down" and resent the same duplicates. `card-reminders.test.ts` replays it with the fake's `delayNextAnswer`.
260
261
  - **Telegram HTML must be escaped before it is formatted, and a bot has one reader**: PPMBot's formatter converted Markdown without escaping, so one `<` or `&` in an answer made Telegram refuse the whole message ("can't parse entities"); `telegram/telegram-html-format.ts` escapes first and splits without cutting a tag. And Telegram answers a second `getUpdates` on the same bot with 409, so two programs (or a dev and a live PPM) on one bot starve each other — the bridge and the connect-link poller hand the bot over through `assistantBridgeReading`.
261
262
  - **Bun's `mock.module` is process-global, so a partial mock breaks *other* test files**: the mock outlives the file that set it, and any file run later in the same process that imports the real module gets the stub. A stub missing one export the real module has then fails *that* file at link time, far from the mock: `tunnel-registry-routes.test.ts` replaced `tunnel-spawn.ts` without `MAX_PROBE_FAILURES`, and `assistant-route-call.test.ts` — which loads the server's routers — failed only when the two ran together. Capture the real module first and spread it (`...RealTunnelSpawn`) under the overrides.
262
263
  - **A schedule's `updated_at` moves on its own**: the scheduler writes `last_run_at`/`next_fire_at` after every run and when a run opens its session, which bumps `updated_at`, so "unchanged since the card was built" cannot be judged by that column alone — a schedule firing every few minutes could never be approved. The Assistant's schedule tools accept an unchanged `updated_at` and otherwise compare the fields the card showed (`unchangedSince` in `assistant-schedule-shape.ts`).
@@ -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.26.37 at build time. Re-run `ppm export skill --install` to refresh. -->
86
+ <!-- Generated for PPM v0.26.38 at build time. Re-run `ppm export skill --install` to refresh. -->
@@ -926,4 +926,4 @@ Authenticate with `?token=<token>` (see Authentication).
926
926
  - `/ws/android`
927
927
  - `/ws/project/<project>/<type>/<id>` — `<type>`: `terminal`, `chat`, `group`, `lsp` (for `chat`, `<id>` is the session id)
928
928
 
929
- <!-- Generated from src/server/routes/ for PPM v0.26.37 -->
929
+ <!-- Generated from src/server/routes/ for PPM v0.26.38 -->
@@ -1 +1 @@
1
- import{s as e}from"./rolldown-runtime-C5c2KzVm.js";import{D as t,E as n}from"./vendor-markdown-26eoXJk7.js";import"./vendor-ui-BQzUk4nq.js";import{At as r,Er as i,Sn as a,Xr as o,Y as s,gr as c,gt as l,ht as u,lr as d,pi as f,ti as p,un as m,ut as h,vr as g,wn as _}from"./icons-CpR5Vw3J.js";import{a as v,r as y}from"./api-client-DSCscZEd.js";import{n as b}from"./utils-DMiycH3O.js";import"./portal-container-context-C84rlnJ6.js";import{i as x,n as S,t as C}from"./tooltip-CECVgROB.js";import{t as w}from"./mobile-bottom-sheet-C78UMLrn.js";import"./use-visual-viewport-tMLO63yY.js";import{n as T}from"./use-is-mobile-CrfIt67b.js";import{r as E,t as D}from"./button-CtdEWN7U.js";import{a as O,i as k,n as A,o as j,r as M,t as N}from"./dialog-BWXzvHlC.js";import"./chat-preparation-cache-D6KJ1ZMi.js";import"./provider-logos-zWlJBGXd.js";import{t as P}from"./provider-selector-CpYLloT9.js";import{r as F}from"./clipboard-DQuoK2EM.js";import{t as I}from"./input-CCVoN0-P.js";import"./control-size-DFdAJqoq.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-DOq_SIAU.js";import{Jn as ie,Nr as U,Qn as W,Xn as ae,Yn as G,Zn as K,qn as oe}from"./index-ix3m5QQT.js";import{C as q,E as J,O as se,S as ce,_ as Y,a as le,b as ue,c as X,d as de,g as fe,h as pe,i as me,j as he,m as ge,n as _e,o as ve,p as ye,r as be,s as xe,t as Se,u as Ce,w as we,x as Te,y as Ee}from"./antigravity-usage-view-0ncr6xtB.js";var Z=e(t(),1),Q=n(),De=[`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`,`Sun`],Oe=Array.from({length:24},(e,t)=>t);function ke(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 Ae(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 je(e){return Oe.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 Me(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 Ne(e){return e<.3?`bg-success`:e<.7?`bg-warning`:`bg-error`}function Pe({accountId:e}){let[t,n]=(0,Z.useState)(null),[r,i]=(0,Z.useState)(!0),[o,s]=(0,Z.useState)(`5h`);(0,Z.useEffect)(()=>{i(!0),te(e).then(n).catch(()=>n([])).finally(()=>i(!1))},[e]);let c=(0,Z.useMemo)(()=>t?ke(t,o):null,[t,o]),l=(0,Z.useMemo)(()=>c?Ae(c):[],[c]),u=(0,Z.useMemo)(()=>c?je(c):[],[c]),d=Math.max(...l,.01);if(Math.max(...u,.01),r)return(0,Q.jsx)(`div`,{className:`flex items-center justify-center py-3`,children:(0,Q.jsx)(a,{className:`size-3 animate-spin text-text-subtle`})});if(!t||t.length===0)return(0,Q.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,Q.jsxs)(`div`,{className:`mt-2 space-y-2`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsx)(`span`,{className:`text-[10px] font-medium text-text-subtle`,children:`Usage Pattern (7d)`}),(0,Q.jsxs)(`div`,{className:`flex gap-0.5 text-[9px]`,children:[(0,Q.jsx)(`button`,{onClick:()=>s(`5h`),className:`px-1.5 py-0.5 rounded cursor-pointer transition-colors ${o===`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,Q.jsx)(`button`,{onClick:()=>s(`weekly`),className:`px-1.5 py-0.5 rounded cursor-pointer transition-colors ${o===`weekly`?`bg-primary/15 text-primary`:`text-text-subtle hover:text-text-secondary`}`,title:`Weekly limit — resets every 7 days`,children:`Wk`})]})]}),(0,Q.jsxs)(`p`,{className:`text-[9px] text-text-subtle leading-tight`,children:[`Avg `,o===`5h`?`5-hour`:`weekly`,` limit usage over `,p,`d (`,f,` samples). Higher % = closer to rate limit. Hover cells for details.`]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`span`,{className:`text-[9px] text-text-subtle`,children:`Avg usage by day of week`}),(0,Q.jsx)(`div`,{className:`flex flex-col gap-[2px] mt-0.5`,children:De.map((e,t)=>{let n=l[t]??0;return(0,Q.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,Q.jsx)(`span`,{className:`text-[8px] text-text-subtle w-5 shrink-0 text-right tabular-nums`,children:e}),(0,Q.jsx)(`div`,{className:`flex-1 h-2.5 bg-surface-elevated rounded-sm overflow-hidden`,children:(0,Q.jsx)(`div`,{className:`h-full rounded-sm transition-all ${Ne(n)}`,style:{width:`${Math.round(n/d*100)}%`}})}),(0,Q.jsxs)(`span`,{className:`text-[8px] text-text-subtle w-6 shrink-0 text-right tabular-nums`,children:[Math.round(n*100),`%`]})]},e)})})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`span`,{className:`text-[9px] text-text-subtle`,children:`Avg usage by hour (0h-23h)`}),(0,Q.jsx)(`div`,{className:`flex gap-[1px] mt-0.5`,children:Oe.map(e=>{let t=u[e]??0;return(0,Q.jsxs)(`div`,{className:`flex-1 flex flex-col items-center gap-[1px]`,children:[(0,Q.jsx)(`div`,{className:`w-full aspect-square rounded-[2px] ${Me(t)}`,title:`${e}:00 — avg ${Math.round(t*100)}% usage`}),e%6==0&&(0,Q.jsx)(`span`,{className:`text-[7px] text-text-subtle tabular-nums`,children:e})]},e)})})]}),c&&(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`span`,{className:`text-[9px] text-text-subtle`,children:`Day x Hour heatmap`}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-[1px] mt-0.5`,children:[De.map((e,t)=>(0,Q.jsxs)(`div`,{className:`flex items-center gap-[1px]`,children:[(0,Q.jsx)(`span`,{className:`text-[7px] text-text-subtle w-4 shrink-0 text-right`,children:e.charAt(0)}),Oe.map(n=>{let r=c[t][n];return(0,Q.jsx)(`div`,{className:`flex-1 aspect-square rounded-[1px] ${Me(r.avg)}`,title:`${e} ${n}:00 — ${r.count>0?`avg ${Math.round(r.avg*100)}% (${r.count} samples)`:`no data`}`},n)})]},e)),(0,Q.jsxs)(`div`,{className:`flex items-center gap-[1px]`,children:[(0,Q.jsx)(`span`,{className:`w-4 shrink-0`}),Oe.map(e=>(0,Q.jsx)(`div`,{className:`flex-1 text-center`,children:e%6==0&&(0,Q.jsx)(`span`,{className:`text-[7px] text-text-subtle tabular-nums`,children:e})},e))]})]})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[8px] text-text-subtle`,children:[(0,Q.jsx)(`span`,{children:`Low`}),(0,Q.jsxs)(`div`,{className:`flex gap-[2px]`,children:[(0,Q.jsx)(`div`,{className:`size-2 rounded-[1px] bg-success/30`}),(0,Q.jsx)(`div`,{className:`size-2 rounded-[1px] bg-success/60`}),(0,Q.jsx)(`div`,{className:`size-2 rounded-[1px] bg-warning/50`}),(0,Q.jsx)(`div`,{className:`size-2 rounded-[1px] bg-warning/80`}),(0,Q.jsx)(`div`,{className:`size-2 rounded-[1px] bg-error/80`})]}),(0,Q.jsx)(`span`,{children:`High`}),(0,Q.jsx)(`span`,{className:`ml-1`,children:`|`}),(0,Q.jsx)(`div`,{className:`size-2 rounded-[1px] bg-surface-elevated border border-border/30`}),(0,Q.jsx)(`span`,{children:`No data`})]})]})}function Fe({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,Q.jsxs)(`section`,{className:`space-y-2 border-t border-border pt-3`,"data-testid":`account-profile-panel`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsx)(`h3`,{className:`text-sm font-medium`,children:`Profile`}),(0,Q.jsx)(`button`,{className:`p-2 text-muted-foreground hover:text-foreground cursor-pointer`,onClick:n,"aria-label":`Close profile`,children:(0,Q.jsx)(f,{className:`size-4`})})]}),(0,Q.jsx)(`div`,{className:`grid grid-cols-[80px_1fr] gap-x-3 gap-y-1 text-xs`,children:r.map(([e,t])=>t?(0,Q.jsxs)(`span`,{className:`contents`,children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:e}),(0,Q.jsx)(`span`,{className:`break-all`,children:t})]},e):null)}),(0,Q.jsx)(Pe,{accountId:t})]})}function Ie({display:e,onConfirm:t,onCancel:n}){let r=T(),i=(0,Q.jsxs)(`div`,{className:`space-y-4`,"data-testid":`account-delete-confirm`,children:[(0,Q.jsxs)(`p`,{className:`text-sm`,children:[`Remove `,(0,Q.jsx)(`span`,{className:`font-medium`,children:e}),`?`]}),(0,Q.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,Q.jsxs)(`div`,{className:`flex flex-col-reverse md:flex-row gap-2 md:justify-end pt-2`,children:[(0,Q.jsx)(D,{variant:`outline`,onClick:n,className:`min-h-11`,children:`Cancel`}),(0,Q.jsx)(D,{variant:`destructive`,autoFocus:!1,onClick:t,className:`min-h-11`,children:`Remove account`})]})]});return r?(0,Q.jsx)(w,{open:!0,onClose:n,children:(0,Q.jsxs)(`div`,{className:`px-4 pb-4`,children:[(0,Q.jsx)(`h2`,{className:`text-base font-semibold mb-3`,children:`Remove account`}),i]})}):(0,Q.jsx)(N,{open:!0,onOpenChange:e=>{e||n()},children:(0,Q.jsxs)(A,{className:`sm:max-w-sm`,children:[(0,Q.jsx)(O,{children:(0,Q.jsx)(j,{className:`text-sm`,children:`Remove account`})}),i]})})}var Le=80;function Re({current:e,onSave:t,onCancel:n}){let r=T(),[i,o]=(0,Z.useState)(e),[s,c]=(0,Z.useState)(!1),[l,u]=(0,Z.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,Q.jsxs)(`form`,{className:`space-y-4`,"data-testid":`account-rename-dialog`,onSubmit:e=>{e.preventDefault(),p()},children:[(0,Q.jsx)(I,{autoFocus:!0,value:i,maxLength:Le,onChange:e=>o(e.target.value),placeholder:`e.g. Personal, Work`,"aria-label":`Account name`,className:`min-h-11 text-sm md:min-h-9`}),l&&(0,Q.jsx)(`p`,{className:`text-xs text-error`,role:`alert`,children:l}),(0,Q.jsxs)(`div`,{className:`flex flex-col-reverse md:flex-row gap-2 md:justify-end`,children:[(0,Q.jsx)(D,{type:`button`,variant:`outline`,onClick:m,disabled:s,className:`min-h-11 md:min-h-9`,children:`Cancel`}),(0,Q.jsxs)(D,{type:`submit`,disabled:!f,className:`min-h-11 md:min-h-9`,children:[s&&(0,Q.jsx)(a,{className:`size-4 animate-spin`}),` Save`]})]})]});return r?(0,Q.jsx)(w,{open:!0,onClose:m,children:(0,Q.jsxs)(`div`,{className:`px-4 pb-4`,children:[(0,Q.jsx)(`h2`,{className:`text-base font-semibold mb-3`,children:`Rename account`}),h]})}):(0,Q.jsx)(N,{open:!0,onOpenChange:e=>{e||m()},children:(0,Q.jsxs)(A,{className:`sm:max-w-sm`,children:[(0,Q.jsx)(O,{children:(0,Q.jsx)(j,{className:`text-sm`,children:`Rename account`})}),h]})})}function ze(e){return(e?.grants??[]).reduce((e,t)=>e+t.resetsLeft,0)}var Be={session:`5-hour reset`,fable:`Fable reset`,full:`full reset`,weekly:`weekly reset`},$=(e,t=!1)=>t?Be[e][0].toUpperCase()+Be[e].slice(1):Be[e],Ve={five_hour:`5-hour limit`,seven_day:`weekly limit`,seven_day_opus:`Opus weekly limit`,seven_day_sonnet:`Sonnet weekly limit`},He=(e,t)=>e.clears.includes(t)||t===`seven_day`&&e.givesBackWeekly;function Ue(e,t,n=Date.now()){let r=!!t.cooldownUntil&&Date.parse(t.cooldownUntil)>n;if(e.usableNow&&!e.paused&&e.resetsLeft>0&&!r)return null;if(e.paused)return`it is paused`;if(e.resetsLeft===0)return`none left`;switch(e.unavailableReason??(r?`cooldown`:void 0)??e.blocking.map(e=>({five_hour:`blocked_five_hour`,seven_day:`blocked_seven_day`,seven_day_opus:`blocked_opus`,seven_day_sonnet:`blocked_sonnet`})[e]).find(Boolean)??(e.blocking.length?`blocked_other`:void 0)??(t.atLimit&&!t.exhausted.some(t=>He(e,t))?`cannot_clear`:void 0)??(e.useRequiresLimit?`needs_limit`:`unavailable`)){case`cooldown`:return`a reset was just used, try again in a minute`;case`blocked_five_hour`:return`can't be used while you're at your ${Ve.five_hour}`;case`blocked_seven_day`:return`can't be used while you're at your ${Ve.seven_day}`;case`blocked_opus`:return`can't be used while you're at your ${Ve.seven_day_opus}`;case`blocked_sonnet`:return`can't be used while you're at your ${Ve.seven_day_sonnet}`;case`blocked_other`:return`can't be used while you're at another limit it doesn't refill`;case`cannot_clear`:return`doesn't refill the limit you've reached`;case`needs_limit`:return`usable once you reach a limit it refills`;default:return`can't be used right now`}}function We(e){let t=new Set;e.givesBackWeekly&&t.add(`Fable`);for(let n of e.clears)n===`five_hour`?t.add(`5-hour`):n===`seven_day`?t.add(`weekly`):n===`seven_day_overage_included`?t.add(e.givesBackWeekly?`Fable`:`weekly`):n===`seven_day_opus`?t.add(`Opus weekly`):n===`seven_day_sonnet`&&t.add(`Sonnet weekly`);let n=[...t],r=n.pop();return r?n.length?`${n.join(`, `)} and ${r} limits`:`${r} limit`:`limits`}function Ge(e,t){if(t.exhausted.some(t=>He(e,t)))return null;let n=$(e.kind),r=null;for(let t of e.clears){let n=e.percentUsed[t];n!==void 0&&(r===null||n>r.used)&&(r={limit:t,used:n})}let i=r&&Ve[r.limit];return r&&i&&r.used<100?`You still have ${100-r.used}% of your ${i} left. Use your ${n} anyway?`:`You haven't reached a limit yet. Use your ${n} anyway?`}function Ke(e,t,n={}){let r=n.kind?$(n.kind):`reset`;switch(t){case`reset`:return`${e}: ${n.kind===`fable`?`Fable reset used. What Fable used is back in your weekly limit`:n.kind===`session`?`5-hour limit reset`:n.kind===`weekly`?`Weekly limits reset`:`Limits reset`}.${n.weeklyResetsAt?` Your weekly reset day stays ${new Date(n.weeklyResetsAt).toLocaleString(void 0,{weekday:`short`,month:`short`,day:`numeric`,hour:`numeric`,minute:`2-digit`})}.`:``}${typeof n.resetsLeft==`number`?` ${n.resetsLeft===0?`No`:n.resetsLeft} ${r}${n.resetsLeft===1?``:`s`} left.`:``}`;case`already_used`:return`${e}: that ${r} had already been used.`;case`not_limited`:return`${e}: nothing needed resetting, so the ${r} was kept.`;case`cooldown`:return`${e}: a reset was used moments ago. Nothing was used; try again in a minute.`;case`ineligible`:return`${e}: Anthropic no longer offers this account limit resets. Nothing was used.`;case`rate_limited`:return`${e}: Anthropic is turning requests away for now. Nothing was used; try again in a minute.`;case`auth_error`:return`${e}: Anthropic refused the account's sign-in. Nothing was used; sign in again and retry.`;case`unavailable`:return n.reason===`reset_unconfirmed`||n.reason===`stamp_indeterminate`?`${e}: couldn't confirm the reset went through. If the limits are not refilled in a moment, try again.`:`${e}: couldn't reset the limits${n.reason?` (${n.reason.replace(/_/g,` `)})`:``}. Nothing was used; try again in a moment.`;default:return`${e}: couldn't tell whether the reset went through. Check the limits in a moment before trying again.`}}function qe(e){let t=e.givesBackWeekly?` and gives back what Fable used of your weekly limit. It doesn't reset your whole week`:``;return`Refills your ${We(e)}${t}. Your weekly reset day stays the same.`}function Je(e){let t=new Map;for(let n of e){let e=`${n.kind}|${n.endsAt??``}`,r=t.get(e)??{kind:n.kind,count:0,endsAt:n.endsAt};r.count+=n.resetsLeft,t.set(e,r)}return[...t].map(([e,t])=>({key:e,title:(0,Q.jsxs)(Q.Fragment,{children:[$(t.kind,!0),t.count>1&&(0,Q.jsxs)(`span`,{className:`text-text-subtle`,children:[` ×`,t.count]})]}),expiresAt:t.endsAt}))}function Ye({account:e,resets:t,onDone:n}){let[r,i]=(0,Z.useState)(!1),[o,s]=(0,Z.useState)(null),[c,l]=(0,Z.useState)(!1),u=(t?.grants??[]).filter(e=>e.resetsLeft>0);if(!t||!u.length)return(0,Q.jsx)(q,{count:0,lines:[],usable:!1,onOpen:()=>{}});let d=e=>Ue(e,t),f=()=>{c||(i(!1),s(null))};async function p(t){l(!0);try{let r=await y.post(`/api/accounts/${e.id}/limit-reset`,{grantId:t.id});n(Ke(e.label,r.result,r))}catch(e){n(e.message||`Could not use the reset`)}finally{l(!1),i(!1),s(null)}}let m=(0,Q.jsx)(`div`,{className:`space-y-2`,"data-testid":`claude-limit-resets`,children:u.map(e=>(0,Q.jsx)(ce,{testId:`claude-reset-${e.id}`,title:(0,Q.jsxs)(Q.Fragment,{children:[$(e.kind,!0),e.resetsLeft>1&&(0,Q.jsxs)(`span`,{className:`text-text-subtle font-normal`,children:[` ×`,e.resetsLeft]})]}),detail:qe(e),expiresAt:e.endsAt,action:`Reset for free`,blockedReason:d(e),onUse:()=>s(e)},e.id))}),h=o&&(()=>{let n=$(o.kind),r=Ge(o,t);return(0,Q.jsxs)(`div`,{className:`space-y-3`,"data-testid":`claude-limit-reset-confirm`,children:[(0,Q.jsxs)(`p`,{className:`text-sm`,children:[`Use `,(0,Q.jsx)(`span`,{className:`font-medium`,children:e.label}),`'s `,n,`?`]}),(0,Q.jsxs)(`ul`,{className:`text-xs text-text-secondary space-y-1.5 list-disc pl-4`,children:[(0,Q.jsx)(`li`,{children:qe(o)}),r&&(0,Q.jsx)(`li`,{className:`text-warning`,children:r}),(0,Q.jsxs)(`li`,{children:[o.resetsLeft>1?`${o.resetsLeft} of this kind left`:`The only one of this kind`,o.endsAt?`, use by ${J(o.endsAt)}`:``,`.`]})]}),(0,Q.jsxs)(`div`,{className:`flex flex-col-reverse md:flex-row gap-2 md:justify-end pt-1`,children:[(0,Q.jsx)(D,{variant:`outline`,onClick:()=>s(null),disabled:c,className:`h-7 max-md:h-[26px]`,children:`Keep it`}),(0,Q.jsxs)(D,{onClick:()=>void p(o),disabled:c,className:`h-7 max-md:h-[26px] gap-1.5`,children:[c?(0,Q.jsx)(a,{className:`size-4 animate-spin`}):(0,Q.jsx)(g,{className:`size-4`}),`Yes, use my `,n]})]})]})})(),_=ze(t);return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(q,{count:_,lines:Je(u),usable:u.some(e=>!d(e)),onOpen:()=>i(!0)}),r&&(0,Q.jsx)(we,{title:o?`Use a ${$(o.kind)}?`:`Limit resets · ${_} available`,onClose:f,children:h||m})]})}function Xe(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 Ze({open:e,onOpenChange:t,accounts:n,preselectId:r,onMessage:i}){let o=n.filter(e=>e.hasRefreshToken),[s,c]=(0,Z.useState)(new Set),[l,d]=(0,Z.useState)(``),[f,p]=(0,Z.useState)(!1),[m,g]=(0,Z.useState)(!1),[y,b]=(0,Z.useState)(!1),[x,S]=(0,Z.useState)(!1);e&&!x&&(c(r?new Set([r]):new Set(o.map(e=>e.id))),S(!0)),!e&&x&&S(!1);function C(){t(!1),d(``),p(!1),g(!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!`):(Xe(o),i?.(`Backup downloaded.`)),C()}catch{}b(!1)}let T=s.size>0&&!y;return(0,Q.jsx)(N,{open:e,onOpenChange:e=>{e||C()},children:(0,Q.jsxs)(A,{className:`sm:max-w-md`,children:[(0,Q.jsxs)(O,{children:[(0,Q.jsxs)(j,{className:`text-sm flex items-center gap-1.5`,children:[(0,Q.jsx)(_,{className:`size-3.5`}),` Export Accounts`]}),(0,Q.jsx)(M,{className:`text-xs`,children:`Select accounts and set a password to protect the backup.`})]}),(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between mb-1`,children:[(0,Q.jsx)(`p`,{className:`text-[11px] font-medium text-muted-foreground`,children:`Accounts to export`}),(0,Q.jsx)(`button`,{className:`text-[10px] text-primary hover:underline cursor-pointer`,onClick:()=>c(s.size===o.length?new Set:new Set(o.map(e=>e.id))),children:s.size===o.length?`Deselect all`:`Select all`})]}),o.length===0?(0,Q.jsx)(`p`,{className:`text-[10px] text-muted-foreground p-2 border rounded`,children:`No exportable accounts.`}):(0,Q.jsx)(`div`,{className:`max-h-36 overflow-y-auto space-y-1 border rounded p-2`,children:o.map(e=>(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.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,Q.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,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsxs)(U,{className:`text-xs`,children:[`Password `,(0,Q.jsx)(`span`,{className:`text-muted-foreground font-normal`,children:`(optional)`})]}),(0,Q.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,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,id:`exp-full`,checked:f,onChange:e=>p(e.target.checked),className:`size-3.5 accent-primary cursor-pointer`}),(0,Q.jsx)(`label`,{htmlFor:`exp-full`,className:`text-[11px] cursor-pointer`,children:`Include refresh tokens (full transfer)`})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,id:`exp-refresh`,checked:m,onChange:e=>g(e.target.checked),className:`size-3.5 accent-primary cursor-pointer`}),(0,Q.jsx)(`label`,{htmlFor:`exp-refresh`,className:`text-[11px] cursor-pointer`,children:`Refresh tokens before export`})]}),f?(0,Q.jsxs)(`div`,{className:`rounded-md border border-error/30 bg-error/5 p-2.5`,children:[(0,Q.jsx)(`p`,{className:`text-[10px] font-medium text-error`,children:`Full transfer — source accounts will expire`}),(0,Q.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:`Refresh tokens included. Source machine expires in ~1h after target refreshes.`})]}):m?(0,Q.jsx)(`div`,{className:`rounded-md border border-warning/30 bg-warning/5 p-2.5`,children:(0,Q.jsx)(`p`,{className:`text-[10px] font-medium text-warning`,children:`Refresh before export — invalidates previous shares`})}):(0,Q.jsx)(`div`,{className:`rounded-md border border-success/30 bg-success/5 p-2.5`,children:(0,Q.jsx)(`p`,{className:`text-[10px] font-medium text-success`,children:`Share current token (safe)`})}),(0,Q.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:`Encrypted with AES-256-GCM + scrypt.`})]}),(0,Q.jsxs)(k,{className:`gap-1.5 flex-col sm:flex-row`,children:[(0,Q.jsx)(D,{size:`sm`,variant:`outline`,className:`text-xs h-7 cursor-pointer`,onClick:C,children:`Cancel`}),(0,Q.jsxs)(D,{size:`sm`,variant:`outline`,className:`text-xs h-7 cursor-pointer`,disabled:!T,onClick:()=>w(!0),children:[(0,Q.jsx)(h,{className:`size-3 mr-1`}),` Copy`]}),(0,Q.jsx)(D,{size:`sm`,className:`text-xs h-7 cursor-pointer`,disabled:!T,onClick:()=>w(!1),children:y?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(a,{className:`size-3 animate-spin mr-1`}),` Exporting...`]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(u,{className:`size-3 mr-1`}),` Download`]})})]})]})})}function Qe({open:e,onOpenChange:t,onSuccess:n}){let[r,i]=(0,Z.useState)(``),[o,s]=(0,Z.useState)(``),[c,l]=(0,Z.useState)(!1),[u,d]=(0,Z.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:o.trim()||`ppm-hienlh`});f(),n(`Imported ${e.imported} account(s)`)}catch(e){d(e.message||`Import failed`)}l(!1)}}return(0,Q.jsx)(N,{open:e,onOpenChange:e=>{e||f()},children:(0,Q.jsxs)(A,{className:`sm:max-w-md`,children:[(0,Q.jsxs)(O,{children:[(0,Q.jsxs)(j,{className:`text-sm flex items-center gap-1.5`,children:[(0,Q.jsx)(_,{className:`size-3.5`}),` Import Accounts`]}),(0,Q.jsx)(M,{className:`text-xs`,children:`Paste backup data and enter the export password. Imported accounts are temporary (~1h).`})]}),(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(U,{className:`text-xs`,children:`Backup data`}),(0,Q.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,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsxs)(U,{className:`text-xs`,children:[`Password `,(0,Q.jsx)(`span`,{className:`text-muted-foreground font-normal`,children:`(optional)`})]}),(0,Q.jsx)(I,{type:`password`,placeholder:`Leave empty for default`,value:o,onChange:e=>s(e.target.value),className:`text-xs h-8`,autoComplete:`current-password`})]})]}),u&&(0,Q.jsx)(`div`,{className:`text-[11px] p-2 rounded bg-error/10 text-error`,children:u}),(0,Q.jsxs)(k,{children:[(0,Q.jsx)(D,{size:`sm`,variant:`outline`,className:`text-xs h-7 cursor-pointer`,onClick:f,children:`Cancel`}),(0,Q.jsx)(D,{size:`sm`,className:`text-xs h-7 cursor-pointer`,disabled:!r.trim()||c,onClick:p,children:c?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(a,{className:`size-3 animate-spin mr-1`}),` Importing...`]}):`Import`})]})]})})}var $e=typeof window<`u`?window.matchMedia(`(min-width: 768px)`):null;function et(e){return $e?.addEventListener(`change`,e),()=>$e?.removeEventListener(`change`,e)}function tt(){return $e?.matches??!0}function nt(){let[e,t]=(0,Z.useState)(null),[n,r]=(0,Z.useState)(!0);return(0,Z.useEffect)(()=>{r(!0),ne().then(t).finally(()=>r(!1))},[]),n?(0,Q.jsx)(`p`,{className:`text-xs text-text-subtle py-4 text-center`,children:`Loading...`}):e?(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(`label`,{className:`text-xs font-medium text-text-primary`,children:`Rotation Strategy`}),(0,Q.jsxs)(oe,{value:e.strategy,onValueChange:async e=>{t(await L({strategy:e}))},children:[(0,Q.jsx)(ae,{className:`w-full h-9 text-xs`,children:(0,Q.jsx)(K,{})}),(0,Q.jsxs)(ie,{children:[(0,Q.jsx)(G,{value:`round-robin`,children:`Round-robin`}),(0,Q.jsx)(G,{value:`fill-first`,children:`Fill-first`}),(0,Q.jsx)(G,{value:`lowest-usage`,children:`Lowest usage`})]})]}),(0,Q.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,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(`label`,{className:`text-xs font-medium text-text-primary`,children:`Max Retry`}),(0,Q.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,Q.jsx)(`p`,{className:`text-[10px] text-text-subtle`,children:`How many accounts to try on failure. 0 = try all available accounts.`})]}),(0,Q.jsxs)(`div`,{className:`space-y-1.5 border-t border-border pt-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsx)(`label`,{className:`text-xs font-medium text-text-primary`,children:`Cooldown parking`}),(0,Q.jsx)(W,{checked:e.cooldownEnabled,onCheckedChange:async e=>{t(await L({cooldownEnabled:e}))}})]}),(0,Q.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,Q.jsxs)(`div`,{className:`flex items-center justify-between text-xs border-t border-border pt-3`,children:[(0,Q.jsx)(`span`,{className:`text-text-subtle`,children:`Active accounts`}),(0,Q.jsx)(`span`,{className:`font-medium text-text-primary`,children:e.activeCount})]})]}):(0,Q.jsx)(`p`,{className:`text-xs text-text-subtle py-4 text-center`,children:`Failed to load settings`})}function rt({open:e,onOpenChange:t}){let n=(0,Z.useSyncExternalStore)(et,tt);return e?n?(0,Q.jsx)(N,{open:e,onOpenChange:t,children:(0,Q.jsxs)(A,{className:`sm:max-w-sm`,children:[(0,Q.jsx)(O,{children:(0,Q.jsxs)(j,{className:`text-sm flex items-center gap-2`,children:[(0,Q.jsx)(i,{className:`size-4`}),` Rotation & Retry`]})}),(0,Q.jsx)(nt,{})]})}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.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,Q.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,Q.jsx)(`div`,{className:`flex justify-center pt-3 pb-1`,children:(0,Q.jsx)(`div`,{className:`w-10 h-1 rounded-full bg-border`})}),(0,Q.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-2 border-b border-border`,children:[(0,Q.jsxs)(`span`,{className:`text-sm font-semibold flex items-center gap-2`,children:[(0,Q.jsx)(i,{className:`size-4`}),` Rotation & Retry`]}),(0,Q.jsx)(`button`,{onClick:()=>t(!1),className:`flex items-center justify-center size-7 rounded-md hover:bg-surface-elevated transition-colors`,children:(0,Q.jsx)(f,{className:`size-4`})})]}),(0,Q.jsx)(`div`,{className:`px-4 py-4 pb-8`,children:(0,Q.jsx)(nt,{})})]})]}):null}var it=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 at({className:e,variant:t,...n}){return(0,Q.jsx)(`div`,{className:b(it({variant:t}),e),...n})}function ot(e){let t=Math.floor(Date.now()/1e3);return e>t?`${Math.floor((e-t)/60)}m`:`exp`}function st({accounts:e}){let[t,n]=(0,Z.useState)([]),[r,i]=(0,Z.useState)(!1),[o,s]=(0,Z.useState)(!1),[c,l]=(0,Z.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),o);n(t=>[...t,{round:t.length+1,time:new Date().toLocaleTimeString(),includeRefresh:o,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,Q.jsxs)(`section`,{className:`border-t pt-4 space-y-2`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Q.jsx)(`p`,{className:`text-xs font-medium`,children:`Simulate export`}),t.length>0&&(0,Q.jsxs)(`span`,{className:`text-[10px] text-muted-foreground`,children:[t.length,` round(s)`]})]}),(0,Q.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,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No OAuth account with a refresh token to export.`}):(0,Q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Q.jsx)(W,{id:`sim-include-refresh`,checked:o,onCheckedChange:s,className:`cursor-pointer`}),(0,Q.jsx)(U,{htmlFor:`sim-include-refresh`,className:`text-[11px] cursor-pointer`,children:`Include refresh tokens`})]}),(0,Q.jsx)(D,{size:`sm`,className:`h-7 text-xs cursor-pointer`,disabled:r,onClick:()=>void d(),children:r?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(a,{className:`size-3 animate-spin mr-1`}),` Exporting...`]}):`Run export #${t.length+1}`})]}),t.length>0&&(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[(0,Q.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,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsxs)(`p`,{className:`text-xs font-medium text-primary`,children:[`Round #`,e.round]}),(0,Q.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:e.time}),(0,Q.jsx)(at,{variant:e.includeRefresh?`destructive`:`secondary`,className:`text-[9px] px-1 py-0`,children:e.includeRefresh?`with refresh`:`access only`})]}),e.items.map(t=>(0,Q.jsxs)(`div`,{className:`p-2 rounded-lg border bg-card space-y-1.5`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`text-[11px] font-medium`,children:t.label??t.email??t.id.slice(0,8)}),t.tokenChanged&&(0,Q.jsx)(at,{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,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[11px]`,children:[(0,Q.jsx)(`span`,{className:`w-20 shrink-0 text-muted-foreground text-[10px]`,children:e.label}),(0,Q.jsx)(`code`,{className:`flex-1 truncate font-mono text-[10px] bg-muted px-1 rounded`,children:e.preview??`N/A`}),e.expires&&(0,Q.jsx)(`span`,{className:`text-[10px] text-muted-foreground shrink-0`,children:ot(e.expires)}),e.token?(0,Q.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,Q.jsx)(a,{className:`size-3 animate-spin`}):`Test`}):(0,Q.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:`-`}),t&&!t.loading&&(0,Q.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 ct(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 lt({open:e,onOpenChange:t,accounts:n}){let[i,o]=(0,Z.useState)(new Map),[s,c]=(0,Z.useState)(!1);async function l(e){o(t=>new Map(t).set(e,{loading:!0}));try{let t=await re(e,s);o(n=>new Map(n).set(e,{loading:!1,result:t}))}catch(t){o(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,Q.jsx)(N,{open:e,onOpenChange:t,children:(0,Q.jsxs)(A,{className:`sm:max-w-xl max-h-[85vh] flex flex-col`,children:[(0,Q.jsxs)(O,{children:[(0,Q.jsxs)(j,{className:`text-sm flex items-center gap-1.5`,children:[(0,Q.jsx)(r,{className:`size-4`}),` Token Test`]}),(0,Q.jsx)(M,{className:`text-xs`,children:`Probe stored tokens for validity. Nothing is modified.`})]}),(0,Q.jsxs)(`div`,{className:`space-y-4 overflow-y-auto flex-1 pr-1`,children:[(0,Q.jsxs)(`section`,{className:`space-y-2`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Q.jsx)(`p`,{className:`text-xs font-medium`,children:`Current tokens`}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Q.jsx)(W,{id:`token-test-refresh`,checked:s,onCheckedChange:c,className:`cursor-pointer`}),(0,Q.jsx)(U,{htmlFor:`token-test-refresh`,className:`text-[11px] cursor-pointer`,children:`Also test refresh`})]}),(0,Q.jsx)(D,{size:`sm`,variant:`outline`,className:`h-7 text-xs cursor-pointer`,onClick:u,children:`Test all`})]})]}),n.length===0&&(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No accounts to test.`}),(0,Q.jsx)(`div`,{className:`space-y-1.5`,children:n.map(e=>{let t=i.get(e.id),n=t?.result?.accessToken.status;return(0,Q.jsxs)(`div`,{className:`p-2 rounded border bg-card space-y-1`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`span`,{className:`text-xs font-medium truncate block`,children:e.label??e.email??e.id.slice(0,8)}),e.expiresAt&&(0,Q.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:ct(e.expiresAt)})]}),(0,Q.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,Q.jsx)(a,{className:`size-3 animate-spin`}):`Test`})]}),t&&!t.loading&&(0,Q.jsxs)(`div`,{className:`text-[11px] pl-2 border-l-2 border-muted`,children:[t.error&&(0,Q.jsx)(`p`,{className:`text-error`,children:t.error}),n&&(0,Q.jsxs)(`span`,{className:n.startsWith(`valid`)?`text-success`:`text-error`,children:[n,t.result?.accessToken.code?` (${t.result.accessToken.code})`:``]})]})]},e.id)})})]}),(0,Q.jsx)(st,{accounts:n})]}),(0,Q.jsx)(k,{children:(0,Q.jsx)(D,{size:`sm`,variant:`outline`,className:`text-xs cursor-pointer`,onClick:()=>t(!1),children:`Close`})})]})})}function ut(){let{usages:e,accounts:t,activeAccountId:n,initialLoading:o,refreshing:s,flashIds:c,reload:l}=fe(),[f,h]=(0,Z.useState)(null),[g,_]=(0,Z.useState)(null),[v,y]=(0,Z.useState)(null),[b,x]=(0,Z.useState)(null),[S,C]=(0,Z.useState)(null),[w,T]=(0,Z.useState)(null),[E,O]=(0,Z.useState)(null),[k,A]=(0,Z.useState)(void 0);function j(e){l(),e&&h(e)}async function M(e,t){_(e);try{await B(e,{status:t===`disabled`?`active`:`disabled`})}catch(e){h(e.message)}_(null),l()}async function N(){if(v){try{await V(v.id),h(`Account "${v.display}" removed.`),l()}catch(e){h(`Failed to remove: ${e.message}`)}y(null)}}async function P(e){b&&(await B(b.id,{label:e}),x(null),h(`Account renamed to "${e}".`),l())}let F=new Map(t.map(e=>[e.id,e])),I=e[0]?.usage.lastFetchedAt;return(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsx)(ve,{description:`Connect multiple Claude accounts. PPM rotates between them automatically to avoid rate limits.`,onRefresh:()=>void l(),refreshing:s,disabled:o,actions:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(D,{size:`sm`,className:`cursor-pointer gap-1.5`,onClick:()=>{A(void 0),O(`add`)},children:[(0,Q.jsx)(d,{className:`size-4`}),` Add account`]}),(0,Q.jsxs)(D,{size:`sm`,variant:`outline`,className:`cursor-pointer gap-1.5`,onClick:()=>{T(null),O(`export`)},children:[(0,Q.jsx)(u,{className:`size-4`}),` Export`]}),(0,Q.jsxs)(D,{size:`sm`,variant:`outline`,className:`cursor-pointer gap-1.5`,onClick:()=>O(`import`),children:[(0,Q.jsx)(p,{className:`size-4`}),` Import`]}),(0,Q.jsxs)(D,{size:`sm`,variant:`outline`,className:`cursor-pointer gap-1.5`,onClick:()=>O(`rotation`),children:[(0,Q.jsx)(i,{className:`size-4`}),` Rotation`]}),(0,Q.jsxs)(D,{size:`sm`,variant:`outline`,className:`cursor-pointer gap-1.5`,onClick:()=>O(`token-test`),children:[(0,Q.jsx)(r,{className:`size-4`}),` Token test`]})]})}),(0,Q.jsx)(xe,{message:f,onDismiss:()=>h(null)}),(0,Q.jsxs)(`section`,{className:`space-y-2`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsx)(`h3`,{className:`text-sm font-medium`,children:`Accounts`}),I&&(0,Q.jsxs)(`span`,{className:`text-[10px] text-muted-foreground`,children:[`usage `,se(new Date(I).getTime())]})]}),o?(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 py-6 text-xs text-muted-foreground`,children:[(0,Q.jsx)(a,{className:`size-4 animate-spin`}),` Loading accounts...`]}):e.length===0?(0,Q.jsxs)(`div`,{className:`flex flex-col items-center gap-2 py-8 text-center`,children:[(0,Q.jsx)(m,{className:`size-5 text-muted-foreground`}),(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No accounts connected yet.`}),(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Add one to start using PPM.`})]}):(0,Q.jsx)(me,{children:e.map(e=>(0,Q.jsx)(be,{layout:`strip`,entry:e,isActive:e.accountId===n,accountInfo:F.get(e.accountId),onToggle:M,toggling:g===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),resetCreditAction:(0,Q.jsx)(Ye,{account:{id:e.accountId,label:e.accountLabel??e.accountId.slice(0,8)},resets:e.usage.limitResets,onDone:e=>{h(e),l()}})},e.accountId))})]}),S&&(0,Q.jsx)(Fe,{profile:S.profile,accountId:S.accountId,onClose:()=>C(null)}),v&&(0,Q.jsx)(Ie,{display:v.display,onConfirm:()=>void N(),onCancel:()=>y(null)}),b&&(0,Q.jsx)(Re,{current:b.current,onSave:P,onCancel:()=>x(null)}),(0,Q.jsx)(Te,{open:E===`add`,onOpenChange:e=>{O(e?`add`:null),e||A(void 0)},onSuccess:j,signInAgainFor:k}),(0,Q.jsx)(Ze,{open:E===`export`,onOpenChange:e=>{O(e?`export`:null),e||T(null)},accounts:t,preselectId:w,onMessage:h}),(0,Q.jsx)(Qe,{open:E===`import`,onOpenChange:e=>O(e?`import`:null),onSuccess:j}),(0,Q.jsx)(rt,{open:E===`rotation`,onOpenChange:e=>O(e?`rotation`:null)}),(0,Q.jsx)(lt,{open:E===`token-test`,onOpenChange:e=>O(e?`token-test`:null),accounts:t})]})}function dt({mode:e,onOpenChange:t,password:n,onPasswordChange:r,busy:i,onExport:o,onImport:s,error:c}){let l=(0,Z.useRef)(null),d=e===`export`;return(0,Q.jsx)(N,{open:e!==null,onOpenChange:t,children:(0,Q.jsxs)(A,{className:`sm:max-w-md`,children:[(0,Q.jsxs)(O,{children:[(0,Q.jsxs)(j,{className:`text-sm flex items-center gap-1.5`,children:[(0,Q.jsx)(_,{className:`size-4`}),` `,d?`Export Codex Accounts`:`Import Codex Accounts`]}),(0,Q.jsx)(M,{className:`text-xs leading-relaxed`,children:d?`Writes a password-encrypted file containing each account's login.`:`Reads a backup file. The password must be the one it was exported with.`})]}),(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(U,{htmlFor:`codex-backup-password`,className:`text-xs`,children:`Password`}),(0,Q.jsx)(I,{id:`codex-backup-password`,type:`password`,placeholder:d?`Choose a password`:`Password used for the export`,value:n,onChange:e=>r(e.target.value),className:`text-xs`,autoComplete:d?`new-password`:`current-password`}),(0,Q.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:`A backup holds full logins — keep the file and its password together.`})]}),c&&(0,Q.jsx)(`div`,{className:`text-[11px] p-2 rounded bg-error/10 text-error`,children:c}),(0,Q.jsx)(`input`,{ref:l,type:`file`,accept:`application/json,.json`,className:`hidden`,onChange:e=>{let t=e.target.files?.[0];e.target.value=``,t&&s(t)}}),(0,Q.jsxs)(k,{children:[(0,Q.jsx)(D,{size:`sm`,variant:`outline`,className:`text-xs cursor-pointer`,onClick:()=>t(!1),children:`Cancel`}),(0,Q.jsxs)(D,{size:`sm`,className:`text-xs cursor-pointer gap-1.5`,disabled:!n.trim()||i,onClick:()=>d?o():l.current?.click(),children:[i?(0,Q.jsx)(a,{className:`size-3.5 animate-spin`}):d?(0,Q.jsx)(u,{className:`size-3.5`}):(0,Q.jsx)(p,{className:`size-3.5`}),d?`Download backup`:`Choose file`]})]})]})})}var ft=[{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 pt({open:e,onOpenChange:t,strategy:n,onChange:r}){return(0,Q.jsx)(N,{open:e,onOpenChange:t,children:(0,Q.jsxs)(A,{className:`sm:max-w-md`,children:[(0,Q.jsxs)(O,{children:[(0,Q.jsx)(j,{className:`text-sm`,children:`Codex Rotation`}),(0,Q.jsx)(M,{className:`text-xs leading-relaxed`,children:`How a new chat chooses among your Codex accounts.`})]}),(0,Q.jsx)(`div`,{className:`space-y-2`,children:ft.map(e=>(0,Q.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,Q.jsx)(`p`,{className:`text-sm font-medium`,children:e.label}),(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.hint})]},e.value))}),(0,Q.jsx)(k,{children:(0,Q.jsx)(D,{size:`sm`,variant:`outline`,className:`text-xs cursor-pointer`,onClick:()=>t(!1),children:`Done`})})]})})}function mt(e){return e==null?null:Math.round(e*100)}function ht({usage:e}){let t=e.session==null&&e.weekly==null;return(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(t||e.session!=null)&&(0,Q.jsx)(Ce,{label:`5-Hour Session`,pct:mt(e.fiveHour),reset:he(e.session),resetsAt:e.session?.resetsAt}),(t||e.weekly!=null)&&(0,Q.jsx)(Ce,{label:`Weekly`,pct:mt(e.sevenDay),reset:he(e.weekly),resetsAt:e.weekly?.resetsAt})]})}function gt(e){let t=e=>Math.round((e??0)*100)>=100;return t(e.session?.utilization)||t(e.weekly?.utilization)}var _t={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.`},vt=`Usable once a limit is reached: a reset moves the weekly reset date, so spending one earlier wastes what is left of the window.`;function yt(e){return e.credits?.length?e.credits:Array.from({length:e.available},(t,n)=>n===0?{id:e.nextCreditId,title:e.title,expiresAt:e.nextExpiresAt}:{title:e.title})}function bt({account:e,usage:t,onDone:n}){let[r,i]=(0,Z.useState)(!1),[o,s]=(0,Z.useState)(null),[c,l]=(0,Z.useState)(!1),u=t.resetCredits;if(!u||u.available===0)return(0,Q.jsx)(q,{count:0,lines:[],usable:!1,onOpen:()=>{}});let d=yt(u),f=gt(t),p=()=>{c||(i(!1),s(null))};async function m(t){l(!0);try{let r=await y.post(`/api/codex-accounts/${e.id}/reset-credit`,t.id?{creditId:t.id}:{});n(_t[r.outcome]?.(e.label)??`${e.label}: ${r.outcome}`)}catch(e){n(e.message||`Could not use the reset`)}finally{l(!1),i(!1),s(null)}}let h=t.weekly?.resetsAt?J(t.weekly.resetsAt):null,_=o&&(0,Q.jsxs)(`div`,{className:`space-y-3`,"data-testid":`codex-reset-credit-confirm`,children:[(0,Q.jsxs)(`p`,{className:`text-sm`,children:[`Use 1 of `,(0,Q.jsx)(`span`,{className:`font-medium`,children:e.label}),`'s `,u.available,` free reset`,u.available===1?``:`s`,`?`]}),(0,Q.jsxs)(`ul`,{className:`text-xs text-text-secondary space-y-1.5 list-disc pl-4`,children:[(0,Q.jsxs)(`li`,{children:[o.title??`Full reset`,`: the 5-hour and weekly usage go back to 0% now.`]}),(0,Q.jsxs)(`li`,{children:[`The weekly reset date moves: the next one is about 7 days after you continue using Codex`,h?`, not ${h} as now`:``,`. You do not also get that one.`]}),o.expiresAt&&(0,Q.jsxs)(`li`,{children:[`This reset expires `,J(o.expiresAt),`.`]})]}),(0,Q.jsxs)(`div`,{className:`flex flex-col-reverse md:flex-row gap-2 md:justify-end pt-1`,children:[(0,Q.jsx)(D,{variant:`outline`,onClick:()=>s(null),disabled:c,className:`h-7 max-md:h-[26px]`,children:`Keep it`}),(0,Q.jsxs)(D,{onClick:()=>void m(o),disabled:c,className:`h-7 max-md:h-[26px] gap-1.5`,children:[c?(0,Q.jsx)(a,{className:`size-4 animate-spin`}):(0,Q.jsx)(g,{className:`size-4`}),`Use reset`]})]})]});return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(q,{count:u.available,lines:d.map((e,t)=>({key:e.id??String(t),title:e.title??`Full reset`,expiresAt:e.expiresAt})),usable:f,onOpen:()=>i(!0)}),r&&(0,Q.jsx)(we,{title:o?`Use a free reset`:`Free resets · ${u.available} available`,onClose:p,children:_||(0,Q.jsxs)(`div`,{className:`space-y-2`,"data-testid":`codex-reset-credits`,children:[!f&&(0,Q.jsx)(`p`,{className:`text-xs text-warning`,children:vt}),d.map((e,t)=>(0,Q.jsx)(ce,{title:e.title??`Full reset`,detail:`Resets the 5-hour and weekly usage to 0%. The weekly reset date then counts from your next use.`,expiresAt:e.expiresAt,action:`Use reset`,blockedReason:f?null:!0,onUse:()=>s(e)},e.id??t))]})})]})}var xt=1440*60*1e3,St=7,Ct=5;function wt(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-St*xt;if(t<r)return null;let i=Math.min(St-1,Math.floor((t-r)/xt)),a=0;for(let e=0;e<=i;e++){let t=new Date(r+e*xt).getUTCDay();t!==0&&t!==6&&a++}let o=a/Ct;return{day:a,cap:o,used:e.utilization,blocked:e.utilization>=o}}function Tt(){let[e,t]=(0,Z.useState)(null),n=Ee(()=>t(null)),[r,c]=(0,Z.useState)(null);return(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsx)(ve,{description:(0,Q.jsxs)(Q.Fragment,{children:[`Each Codex account keeps its own login (`,(0,Q.jsx)(`code`,{children:`CODEX_HOME`}),`). One is picked per chat by the rotation setting.`]}),onRefresh:()=>void n.load(),refreshing:n.loading,actions:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(D,{size:`sm`,className:`cursor-pointer gap-1.5`,onClick:()=>t(`add`),children:[(0,Q.jsx)(d,{className:`size-4`}),` Add account`]}),(0,Q.jsxs)(D,{size:`sm`,variant:`outline`,className:`cursor-pointer gap-1.5`,onClick:()=>t(`export`),children:[(0,Q.jsx)(u,{className:`size-4`}),` Export`]}),(0,Q.jsxs)(D,{size:`sm`,variant:`outline`,className:`cursor-pointer gap-1.5`,onClick:()=>t(`import`),children:[(0,Q.jsx)(p,{className:`size-4`}),` Import`]}),(0,Q.jsxs)(D,{size:`sm`,variant:`outline`,className:`cursor-pointer gap-1.5`,onClick:()=>t(`rotation`),children:[(0,Q.jsx)(i,{className:`size-4`}),` Rotation`]})]})}),(0,Q.jsx)(xe,{message:n.msg??n.err,onDismiss:()=>{n.setMsg(null),n.setErr(null)}}),(0,Q.jsxs)(`section`,{className:`space-y-2`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsx)(`h3`,{className:`text-sm font-medium`,children:`Codex Accounts`}),(0,Q.jsx)(`span`,{className:`text-[10px] text-muted-foreground capitalize`,children:n.strategy.replace(`-`,` `)})]}),n.loading&&n.accounts.length===0?(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 py-6 text-xs text-muted-foreground`,children:[(0,Q.jsx)(a,{className:`size-4 animate-spin`}),` Loading accounts...`]}):n.accounts.length===0?(0,Q.jsxs)(`div`,{className:`flex flex-col items-center gap-2 py-8 text-center`,children:[(0,Q.jsx)(m,{className:`size-5 text-muted-foreground`}),(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No Codex accounts yet.`}),(0,Q.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Chats use your default `,(0,Q.jsx)(`code`,{children:`~/.codex`}),` login until you add one.`]})]}):(0,Q.jsx)(me,{children:n.accounts.map(e=>{let t=n.usages[e.id]??{};return(0,Q.jsxs)(le,{dense:!0,className:`flex flex-col min-w-[300px] shrink-0 snap-start${e.signedOut?` opacity-60`:``}`,"data-testid":`account-card`,"data-account-id":e.id,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`text-sm font-medium truncate flex-1 min-w-0`,children:e.label}),e.signedOut&&(0,Q.jsx)(X,{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`?()=>c(e):void 0,children:`Sign in again`}),(0,Q.jsx)(`span`,{className:`text-[10px] uppercase tracking-wide text-text-subtle border border-border rounded px-1 shrink-0`,children:e.type}),pe(e.planType)&&(0,Q.jsx)(`span`,{className:`text-[10px] text-text-subtle shrink-0`,children:pe(e.planType)}),(0,Q.jsx)(W,{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,Q.jsxs)(C,{children:[(0,Q.jsx)(x,{asChild:!0,children:(0,Q.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,Q.jsx)(o,{className:`size-4`})})}),(0,Q.jsx)(S,{side:`top`,children:`Remove account`})]})]}),(0,Q.jsx)(ht,{usage:t}),t.session==null&&(()=>{let r=wt(t.weekly);return r?(0,Q.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,Q.jsxs)(`div`,{className:`min-w-0 space-y-0.5`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs font-medium ${e.dailyGuardEnabled&&r.blocked?`text-error`:`text-text-secondary`}`,children:[(0,Q.jsx)(`span`,{children:`Daily guard`}),(0,Q.jsxs)(C,{children:[(0,Q.jsx)(x,{asChild:!0,children:(0,Q.jsx)(`button`,{type:`button`,"aria-label":`About Daily guard`,className:`text-text-subtle hover:text-text-primary cursor-help`,children:(0,Q.jsx)(s,{className:`size-3.5`})})}),(0,Q.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,Q.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,Q.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,Q.jsx)(W,{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})(),(0,Q.jsx)(`div`,{className:`mt-auto`,children:(0,Q.jsx)(bt,{account:e,usage:t,onDone:e=>{n.setMsg(e),n.load()}})})]},e.id)})})]}),(0,Q.jsx)(ue,{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,Q.jsx)(dt,{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,Q.jsx)(Y,{account:r,onClose:()=>c(null),onDone:()=>void n.load()}),(0,Q.jsx)(pt,{open:e===`rotation`,onOpenChange:e=>t(e?`rotation`:null),strategy:n.strategy,onChange:e=>void n.changeStrategy(e)})]})}var Et=[{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 Dt(e){return e==null?null:Math.round(e*100)}function Ot(){let[e,t]=(0,Z.useState)([]),[n,r]=(0,Z.useState)(`round-robin`),[s,u]=(0,Z.useState)({}),[f,p]=(0,Z.useState)(!0),[h,g]=(0,Z.useState)(null),[_,v]=(0,Z.useState)(null),[w,T]=(0,Z.useState)(new Set),[E,P]=(0,Z.useState)(null),[F,L]=(0,Z.useState)(null),[R,z]=(0,Z.useState)(``),[B,ee]=(0,Z.useState)(null),[te,ne]=(0,Z.useState)(!1),[V,re]=(0,Z.useState)(``),[H,ie]=(0,Z.useState)(!1),[ae,G]=(0,Z.useState)(null),K=(0,Z.useRef)(0),oe=(0,Z.useRef)(!1),q=(0,Z.useRef)(!1),J=(0,Z.useRef)(null),ce=(0,Z.useRef)(null),Y=(0,Z.useCallback)(async()=>{p(!0),v(null);try{let e=await y.get(`/api/antigravity-accounts`);t(e.accounts),r(e.strategy),u(await y.get(`/api/antigravity-accounts/usage`))}catch(e){v(e.message)}finally{p(!1)}},[]);(0,Z.useEffect)(()=>{Y()},[Y]);let ue=(0,Z.useCallback)(()=>{K.current+=1,oe.current=!1,q.current=!1,ce.current?.(),ce.current=null;let e=J.current;J.current=null,e&&y.del(`/api/antigravity-accounts/login/${e}`).catch(()=>{})},[]);(0,Z.useEffect)(()=>ue,[ue]);let X=(0,Z.useCallback)(()=>{ue(),ee(null),ne(!1),re(``),ie(!1)},[ue]),de=(0,Z.useCallback)(()=>{X(),G(null),z(``),L(null),P(null)},[X]),fe=(0,Z.useCallback)(e=>{let t=Date.now()+61e4,n=!1,r;ce.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`){J.current=null,X(),G(null),z(``),L(null),P(null),g(`Antigravity Google account connected.`),await Y();return}if(a?.state===`error`||Date.now()>t){J.current=null,X(),G(a?.state===`error`?a.error??`Login failed.`:`Login timed out.`);return}r=setTimeout(i,2e3)}};i()},[Y,X]),pe=(0,Z.useCallback)(async e=>{if(oe.current||J.current||q.current)return;oe.current=!0;let t=++K.current;ne(!0),G(null);try{let n=await y.post(`/api/antigravity-accounts/login`,{...R.trim()?{label:R.trim()}:{},...e?{accountId:e.id}:{}});if(t!==K.current){y.del(`/api/antigravity-accounts/login/${n.id}`).catch(()=>{});return}J.current=n.id,ee(n),fe(n.id)}catch(e){t===K.current&&G(e.message)}finally{t===K.current&&(oe.current=!1,ne(!1))}},[R,fe]),ge=(0,Z.useCallback)(async()=>{if(!B||!V.trim()||q.current)return;let e=K.current;q.current=!0,ie(!0),G(null);try{let t=await y.post(`/api/antigravity-accounts/login/${B.id}/callback`,{code:V.trim()});if(e!==K.current)return;if(t?.state===`error`){J.current=null,X(),G(t.error??`Login failed.`);return}if(t?.state!==`done`)return;J.current=null,X(),z(``),L(null),P(null),g(`Antigravity Google account connected.`),await Y()}catch(t){e===K.current&&(J.current=null,X(),G(t.message))}finally{e===K.current&&(q.current=!1,ie(!1))}},[B,V,Y,X]),ye=(0,Z.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})}},[]),be=(0,Z.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)}},[]),we=(0,Z.useCallback)(async e=>{v(null);try{await y.put(`/api/antigravity-accounts/strategy`,{strategy:e}),r(e)}catch(e){v(e.message)}},[]),Te=(0,Z.useCallback)(e=>{L(e),z(e.label),P(`add`)},[]);return(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsx)(ve,{description:(0,Q.jsxs)(Q.Fragment,{children:[`Each Antigravity account keeps its own Google OAuth login (`,(0,Q.jsx)(`code`,{children:`~/.ppm/antigravity-accounts`}),`) alongside your local IDE login (`,(0,Q.jsx)(`code`,{children:`~/.gemini`}),`). One is picked per chat by the rotation setting.`]}),onRefresh:()=>void Y(),refreshing:f,actions:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(D,{size:`sm`,className:`cursor-pointer gap-1.5`,onClick:()=>{L(null),z(``),P(`add`)},children:[(0,Q.jsx)(d,{className:`size-4`}),` Add account`]}),(0,Q.jsxs)(D,{size:`sm`,variant:`outline`,className:`cursor-pointer gap-1.5`,onClick:()=>P(`rotation`),children:[(0,Q.jsx)(i,{className:`size-4`}),` Rotation`]})]})}),(0,Q.jsx)(xe,{message:h??_,onDismiss:()=>{g(null),v(null)}}),(0,Q.jsxs)(`section`,{className:`space-y-2`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsx)(`h3`,{className:`text-sm font-medium`,children:`Antigravity Accounts`}),(0,Q.jsx)(`span`,{className:`text-[10px] text-muted-foreground capitalize`,children:n.replace(`-`,` `)})]}),f&&e.length===0?(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 py-6 text-xs text-muted-foreground`,children:[(0,Q.jsx)(a,{className:`size-4 animate-spin`}),` Loading accounts...`]}):e.length===0?(0,Q.jsxs)(`div`,{className:`flex flex-col items-center gap-2 py-8 text-center`,children:[(0,Q.jsx)(m,{className:`size-5 text-muted-foreground`}),(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No Antigravity accounts yet.`}),(0,Q.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Click `,(0,Q.jsx)(`strong`,{children:`Add account`}),` to sign in with Google, or start Antigravity Desktop to auto-detect your local account.`]})]}):(0,Q.jsx)(me,{children:e.map(e=>{let t=Se(s[e.id]??{}),n=t.session==null&&t.weekly==null&&(!t.weeklyScoped||t.weeklyScoped.length===0),r=e.id===`default`;return(0,Q.jsxs)(le,{dense:!0,className:`min-w-[320px] shrink-0 snap-start`,"data-testid":`account-card`,"data-account-id":e.id,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Q.jsx)(`div`,{className:`text-sm font-medium truncate`,children:e.label}),e.email&&e.email!==e.label&&(0,Q.jsx)(`div`,{className:`text-[11px] text-text-subtle truncate`,children:e.email})]}),(0,Q.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,Q.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,Q.jsx)(W,{checked:e.status!==`disabled`,onCheckedChange:()=>void ye(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,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(C,{children:[(0,Q.jsx)(x,{asChild:!0,children:(0,Q.jsx)(`button`,{type:`button`,onClick:()=>Te(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,Q.jsx)(c,{className:`size-3.5`})})}),(0,Q.jsx)(S,{side:`top`,children:`Sign in again`})]}),(0,Q.jsxs)(C,{children:[(0,Q.jsx)(x,{asChild:!0,children:(0,Q.jsx)(`button`,{type:`button`,onClick:()=>void be(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,Q.jsx)(o,{className:`size-4`})})}),(0,Q.jsx)(S,{side:`top`,children:`Remove account`})]})]})]}),(0,Q.jsxs)(`div`,{className:`space-y-2 pt-1`,children:[(n||t.session!=null)&&(0,Q.jsx)(Ce,{label:`Gemini · 5-Hour Session`,pct:Dt(t.fiveHour),reset:he(t.session),resetsAt:t.session?.resetsAt}),(n||t.weekly!=null)&&(0,Q.jsx)(Ce,{label:`Gemini · Weekly`,pct:Dt(t.sevenDay),reset:he(t.weekly),resetsAt:t.weekly?.resetsAt}),t.weeklyScoped?.map(e=>(0,Q.jsx)(Ce,{label:e.label,pct:Dt(e.utilization),reset:he(e),resetsAt:e.resetsAt},e.label))]}),t.lastFetchedAt&&_e(t.lastFetchedAt)&&(0,Q.jsxs)(`p`,{className:`text-[10px] text-warning`,children:[`Last read `,se(Date.parse(t.lastFetchedAt)),`. Neither agy nor the Antigravity app has answered since.`]})]},e.id)})})]}),(0,Q.jsx)(N,{open:E===`add`,onOpenChange:e=>{e||de()},children:(0,Q.jsxs)(A,{className:`sm:max-w-md max-h-[90dvh] overflow-y-auto`,children:[(0,Q.jsxs)(O,{children:[(0,Q.jsx)(j,{className:`text-sm`,children:F?`Sign in again — ${F.label}`:`Add Antigravity Account`}),(0,Q.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,Q.jsxs)(`div`,{className:`space-y-3`,children:[!F&&(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(U,{htmlFor:`agy-label`,className:`text-xs`,children:`Label (optional)`}),(0,Q.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,Q.jsxs)(`div`,{className:`rounded-md border p-3 space-y-2.5`,children:[(0,Q.jsx)(`p`,{className:`text-[11px] font-medium`,children:`Google OAuth Sign-In`}),B?(0,Q.jsxs)(`div`,{className:`space-y-2.5 text-xs`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Q.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,Q.jsx)(l,{className:`size-3.5`}),` Open Google Sign-In page`]}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>{X(),G(null)},disabled:H,className:`text-[11px] text-muted-foreground hover:text-foreground underline cursor-pointer`,children:`Start over`})]}),(0,Q.jsxs)(`p`,{className:`text-muted-foreground leading-relaxed`,children:[`1. Open the link above and sign in with your Google account.`,(0,Q.jsx)(`br`,{}),`2. Copy the authorization code (or the full callback URL) shown after signing in and paste it below:`]}),(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(U,{htmlFor:`agy-auth-code`,className:`text-xs`,children:`Authorization Code or Callback URL`}),(0,Q.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,Q.jsxs)(D,{size:`sm`,className:`w-full cursor-pointer gap-1.5`,onClick:()=>void ge(),disabled:!V.trim()||H,children:[H&&(0,Q.jsx)(a,{className:`size-3.5 animate-spin`}),`Verify & Save Account`]})]}):(0,Q.jsx)(D,{size:`sm`,className:`w-full cursor-pointer gap-1.5`,onClick:()=>void pe(F),disabled:te,children:te?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(a,{className:`size-4 animate-spin`}),` Generating Google sign-in link...`]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(l,{className:`size-4`}),` Sign in with Google`]})})]})]}),ae&&(0,Q.jsx)(`div`,{role:`alert`,className:`text-[11px] p-2 rounded bg-error/10 text-error`,children:ae}),(0,Q.jsx)(k,{children:(0,Q.jsx)(D,{size:`sm`,variant:`outline`,className:`text-xs cursor-pointer`,onClick:de,children:`Cancel`})})]})}),(0,Q.jsx)(N,{open:E===`rotation`,onOpenChange:e=>P(e?`rotation`:null),children:(0,Q.jsxs)(A,{className:`sm:max-w-md`,children:[(0,Q.jsxs)(O,{children:[(0,Q.jsx)(j,{className:`text-sm`,children:`Antigravity Rotation`}),(0,Q.jsx)(M,{className:`text-xs leading-relaxed`,children:`How a new chat chooses among your enabled Antigravity accounts.`})]}),(0,Q.jsx)(`div`,{className:`space-y-2`,children:Et.map(e=>(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>void we(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,Q.jsx)(`p`,{className:`text-sm font-medium`,children:e.label}),(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.hint})]},e.value))}),(0,Q.jsx)(k,{children:(0,Q.jsx)(D,{size:`sm`,variant:`outline`,className:`text-xs cursor-pointer`,onClick:()=>P(null),children:`Done`})})]})})]})}var kt=[{id:`claude`,label:`Claude`},{id:`codex`,label:`Codex`},{id:`antigravity`,label:`Antigravity`}];function At(){let[e,t]=(0,Z.useState)(null),[n,r]=(0,Z.useState)(()=>ge()),[i,o]=(0,Z.useState)(n?.provider??`claude`),s=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{let e=()=>{let e=ge();e&&(o(e.provider),r(e))};return window.addEventListener(de,e),()=>window.removeEventListener(de,e)},[]),(0,Z.useEffect)(()=>{if(n)return ye(()=>s.current,n.accountId)},[n]),(0,Z.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 c=kt.filter(t=>t.id===`claude`||e?.has(t.id)),l=c.length>1;return(0,Q.jsxs)(`div`,{ref:s,className:`space-y-4`,"data-testid":`accounts-pane`,"data-provider":i,children:[l&&(0,Q.jsx)(`div`,{className:`flex gap-1 border-b border-border/50`,children:c.map(e=>(0,Q.jsxs)(`button`,{onClick:()=>o(e.id),"data-testid":`accounts-tab-${e.id}`,"aria-current":i===e.id?`page`:void 0,className:`flex items-center gap-1.5 px-3 py-2 text-xs rounded-t transition-colors cursor-pointer ${i===e.id?`text-primary border-b-2 border-primary font-medium`:`text-text-subtle hover:text-text-secondary`}`,children:[(0,Q.jsx)(P,{providerId:e.id}),e.label]},e.id))}),e===null&&!l&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,Q.jsx)(a,{className:`size-3 animate-spin`}),` Checking configured providers...`]}),i===`claude`?(0,Q.jsx)(ut,{}):i===`codex`?(0,Q.jsx)(Tt,{}):(0,Q.jsx)(Ot,{})]})}export{At as AccountsSettingsSection};
1
+ import{s as e}from"./rolldown-runtime-C5c2KzVm.js";import{D as t,E as n}from"./vendor-markdown-26eoXJk7.js";import"./vendor-ui-BQzUk4nq.js";import{At as r,Er as i,Sn as a,Xr as o,Y as s,gr as c,gt as l,ht as u,lr as d,pi as f,ti as p,un as m,ut as h,vr as g,wn as _}from"./icons-CpR5Vw3J.js";import{a as v,r as y}from"./api-client-DSCscZEd.js";import{n as b}from"./utils-DMiycH3O.js";import"./portal-container-context-C84rlnJ6.js";import{i as x,n as S,t as C}from"./tooltip-CECVgROB.js";import{t as w}from"./mobile-bottom-sheet-C78UMLrn.js";import"./use-visual-viewport-tMLO63yY.js";import{n as T}from"./use-is-mobile-CrfIt67b.js";import{r as E,t as D}from"./button-CtdEWN7U.js";import{a as O,i as k,n as A,o as j,r as M,t as N}from"./dialog-BWXzvHlC.js";import"./chat-preparation-cache-D6KJ1ZMi.js";import"./provider-logos-zWlJBGXd.js";import{t as P}from"./provider-selector-CpYLloT9.js";import{r as F}from"./clipboard-DQuoK2EM.js";import{t as I}from"./input-CCVoN0-P.js";import"./control-size-DFdAJqoq.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-DOq_SIAU.js";import{Jn as ie,Nr as U,Qn as W,Xn as ae,Yn as G,Zn as K,qn as oe}from"./index-BcmsW6J_.js";import{C as q,E as J,O as se,S as ce,_ as Y,a as le,b as ue,c as X,d as de,g as fe,h as pe,i as me,j as he,m as ge,n as _e,o as ve,p as ye,r as be,s as xe,t as Se,u as Ce,w as we,x as Te,y as Ee}from"./antigravity-usage-view-BwJirJDB.js";var Z=e(t(),1),Q=n(),De=[`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`,`Sun`],Oe=Array.from({length:24},(e,t)=>t);function ke(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 Ae(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 je(e){return Oe.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 Me(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 Ne(e){return e<.3?`bg-success`:e<.7?`bg-warning`:`bg-error`}function Pe({accountId:e}){let[t,n]=(0,Z.useState)(null),[r,i]=(0,Z.useState)(!0),[o,s]=(0,Z.useState)(`5h`);(0,Z.useEffect)(()=>{i(!0),te(e).then(n).catch(()=>n([])).finally(()=>i(!1))},[e]);let c=(0,Z.useMemo)(()=>t?ke(t,o):null,[t,o]),l=(0,Z.useMemo)(()=>c?Ae(c):[],[c]),u=(0,Z.useMemo)(()=>c?je(c):[],[c]),d=Math.max(...l,.01);if(Math.max(...u,.01),r)return(0,Q.jsx)(`div`,{className:`flex items-center justify-center py-3`,children:(0,Q.jsx)(a,{className:`size-3 animate-spin text-text-subtle`})});if(!t||t.length===0)return(0,Q.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,Q.jsxs)(`div`,{className:`mt-2 space-y-2`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsx)(`span`,{className:`text-[10px] font-medium text-text-subtle`,children:`Usage Pattern (7d)`}),(0,Q.jsxs)(`div`,{className:`flex gap-0.5 text-[9px]`,children:[(0,Q.jsx)(`button`,{onClick:()=>s(`5h`),className:`px-1.5 py-0.5 rounded cursor-pointer transition-colors ${o===`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,Q.jsx)(`button`,{onClick:()=>s(`weekly`),className:`px-1.5 py-0.5 rounded cursor-pointer transition-colors ${o===`weekly`?`bg-primary/15 text-primary`:`text-text-subtle hover:text-text-secondary`}`,title:`Weekly limit — resets every 7 days`,children:`Wk`})]})]}),(0,Q.jsxs)(`p`,{className:`text-[9px] text-text-subtle leading-tight`,children:[`Avg `,o===`5h`?`5-hour`:`weekly`,` limit usage over `,p,`d (`,f,` samples). Higher % = closer to rate limit. Hover cells for details.`]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`span`,{className:`text-[9px] text-text-subtle`,children:`Avg usage by day of week`}),(0,Q.jsx)(`div`,{className:`flex flex-col gap-[2px] mt-0.5`,children:De.map((e,t)=>{let n=l[t]??0;return(0,Q.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,Q.jsx)(`span`,{className:`text-[8px] text-text-subtle w-5 shrink-0 text-right tabular-nums`,children:e}),(0,Q.jsx)(`div`,{className:`flex-1 h-2.5 bg-surface-elevated rounded-sm overflow-hidden`,children:(0,Q.jsx)(`div`,{className:`h-full rounded-sm transition-all ${Ne(n)}`,style:{width:`${Math.round(n/d*100)}%`}})}),(0,Q.jsxs)(`span`,{className:`text-[8px] text-text-subtle w-6 shrink-0 text-right tabular-nums`,children:[Math.round(n*100),`%`]})]},e)})})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`span`,{className:`text-[9px] text-text-subtle`,children:`Avg usage by hour (0h-23h)`}),(0,Q.jsx)(`div`,{className:`flex gap-[1px] mt-0.5`,children:Oe.map(e=>{let t=u[e]??0;return(0,Q.jsxs)(`div`,{className:`flex-1 flex flex-col items-center gap-[1px]`,children:[(0,Q.jsx)(`div`,{className:`w-full aspect-square rounded-[2px] ${Me(t)}`,title:`${e}:00 — avg ${Math.round(t*100)}% usage`}),e%6==0&&(0,Q.jsx)(`span`,{className:`text-[7px] text-text-subtle tabular-nums`,children:e})]},e)})})]}),c&&(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`span`,{className:`text-[9px] text-text-subtle`,children:`Day x Hour heatmap`}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-[1px] mt-0.5`,children:[De.map((e,t)=>(0,Q.jsxs)(`div`,{className:`flex items-center gap-[1px]`,children:[(0,Q.jsx)(`span`,{className:`text-[7px] text-text-subtle w-4 shrink-0 text-right`,children:e.charAt(0)}),Oe.map(n=>{let r=c[t][n];return(0,Q.jsx)(`div`,{className:`flex-1 aspect-square rounded-[1px] ${Me(r.avg)}`,title:`${e} ${n}:00 — ${r.count>0?`avg ${Math.round(r.avg*100)}% (${r.count} samples)`:`no data`}`},n)})]},e)),(0,Q.jsxs)(`div`,{className:`flex items-center gap-[1px]`,children:[(0,Q.jsx)(`span`,{className:`w-4 shrink-0`}),Oe.map(e=>(0,Q.jsx)(`div`,{className:`flex-1 text-center`,children:e%6==0&&(0,Q.jsx)(`span`,{className:`text-[7px] text-text-subtle tabular-nums`,children:e})},e))]})]})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[8px] text-text-subtle`,children:[(0,Q.jsx)(`span`,{children:`Low`}),(0,Q.jsxs)(`div`,{className:`flex gap-[2px]`,children:[(0,Q.jsx)(`div`,{className:`size-2 rounded-[1px] bg-success/30`}),(0,Q.jsx)(`div`,{className:`size-2 rounded-[1px] bg-success/60`}),(0,Q.jsx)(`div`,{className:`size-2 rounded-[1px] bg-warning/50`}),(0,Q.jsx)(`div`,{className:`size-2 rounded-[1px] bg-warning/80`}),(0,Q.jsx)(`div`,{className:`size-2 rounded-[1px] bg-error/80`})]}),(0,Q.jsx)(`span`,{children:`High`}),(0,Q.jsx)(`span`,{className:`ml-1`,children:`|`}),(0,Q.jsx)(`div`,{className:`size-2 rounded-[1px] bg-surface-elevated border border-border/30`}),(0,Q.jsx)(`span`,{children:`No data`})]})]})}function Fe({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,Q.jsxs)(`section`,{className:`space-y-2 border-t border-border pt-3`,"data-testid":`account-profile-panel`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsx)(`h3`,{className:`text-sm font-medium`,children:`Profile`}),(0,Q.jsx)(`button`,{className:`p-2 text-muted-foreground hover:text-foreground cursor-pointer`,onClick:n,"aria-label":`Close profile`,children:(0,Q.jsx)(f,{className:`size-4`})})]}),(0,Q.jsx)(`div`,{className:`grid grid-cols-[80px_1fr] gap-x-3 gap-y-1 text-xs`,children:r.map(([e,t])=>t?(0,Q.jsxs)(`span`,{className:`contents`,children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:e}),(0,Q.jsx)(`span`,{className:`break-all`,children:t})]},e):null)}),(0,Q.jsx)(Pe,{accountId:t})]})}function Ie({display:e,onConfirm:t,onCancel:n}){let r=T(),i=(0,Q.jsxs)(`div`,{className:`space-y-4`,"data-testid":`account-delete-confirm`,children:[(0,Q.jsxs)(`p`,{className:`text-sm`,children:[`Remove `,(0,Q.jsx)(`span`,{className:`font-medium`,children:e}),`?`]}),(0,Q.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,Q.jsxs)(`div`,{className:`flex flex-col-reverse md:flex-row gap-2 md:justify-end pt-2`,children:[(0,Q.jsx)(D,{variant:`outline`,onClick:n,className:`min-h-11`,children:`Cancel`}),(0,Q.jsx)(D,{variant:`destructive`,autoFocus:!1,onClick:t,className:`min-h-11`,children:`Remove account`})]})]});return r?(0,Q.jsx)(w,{open:!0,onClose:n,children:(0,Q.jsxs)(`div`,{className:`px-4 pb-4`,children:[(0,Q.jsx)(`h2`,{className:`text-base font-semibold mb-3`,children:`Remove account`}),i]})}):(0,Q.jsx)(N,{open:!0,onOpenChange:e=>{e||n()},children:(0,Q.jsxs)(A,{className:`sm:max-w-sm`,children:[(0,Q.jsx)(O,{children:(0,Q.jsx)(j,{className:`text-sm`,children:`Remove account`})}),i]})})}var Le=80;function Re({current:e,onSave:t,onCancel:n}){let r=T(),[i,o]=(0,Z.useState)(e),[s,c]=(0,Z.useState)(!1),[l,u]=(0,Z.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,Q.jsxs)(`form`,{className:`space-y-4`,"data-testid":`account-rename-dialog`,onSubmit:e=>{e.preventDefault(),p()},children:[(0,Q.jsx)(I,{autoFocus:!0,value:i,maxLength:Le,onChange:e=>o(e.target.value),placeholder:`e.g. Personal, Work`,"aria-label":`Account name`,className:`min-h-11 text-sm md:min-h-9`}),l&&(0,Q.jsx)(`p`,{className:`text-xs text-error`,role:`alert`,children:l}),(0,Q.jsxs)(`div`,{className:`flex flex-col-reverse md:flex-row gap-2 md:justify-end`,children:[(0,Q.jsx)(D,{type:`button`,variant:`outline`,onClick:m,disabled:s,className:`min-h-11 md:min-h-9`,children:`Cancel`}),(0,Q.jsxs)(D,{type:`submit`,disabled:!f,className:`min-h-11 md:min-h-9`,children:[s&&(0,Q.jsx)(a,{className:`size-4 animate-spin`}),` Save`]})]})]});return r?(0,Q.jsx)(w,{open:!0,onClose:m,children:(0,Q.jsxs)(`div`,{className:`px-4 pb-4`,children:[(0,Q.jsx)(`h2`,{className:`text-base font-semibold mb-3`,children:`Rename account`}),h]})}):(0,Q.jsx)(N,{open:!0,onOpenChange:e=>{e||m()},children:(0,Q.jsxs)(A,{className:`sm:max-w-sm`,children:[(0,Q.jsx)(O,{children:(0,Q.jsx)(j,{className:`text-sm`,children:`Rename account`})}),h]})})}function ze(e){return(e?.grants??[]).reduce((e,t)=>e+t.resetsLeft,0)}var Be={session:`5-hour reset`,fable:`Fable reset`,full:`full reset`,weekly:`weekly reset`},$=(e,t=!1)=>t?Be[e][0].toUpperCase()+Be[e].slice(1):Be[e],Ve={five_hour:`5-hour limit`,seven_day:`weekly limit`,seven_day_opus:`Opus weekly limit`,seven_day_sonnet:`Sonnet weekly limit`},He=(e,t)=>e.clears.includes(t)||t===`seven_day`&&e.givesBackWeekly;function Ue(e,t,n=Date.now()){let r=!!t.cooldownUntil&&Date.parse(t.cooldownUntil)>n;if(e.usableNow&&!e.paused&&e.resetsLeft>0&&!r)return null;if(e.paused)return`it is paused`;if(e.resetsLeft===0)return`none left`;switch(e.unavailableReason??(r?`cooldown`:void 0)??e.blocking.map(e=>({five_hour:`blocked_five_hour`,seven_day:`blocked_seven_day`,seven_day_opus:`blocked_opus`,seven_day_sonnet:`blocked_sonnet`})[e]).find(Boolean)??(e.blocking.length?`blocked_other`:void 0)??(t.atLimit&&!t.exhausted.some(t=>He(e,t))?`cannot_clear`:void 0)??(e.useRequiresLimit?`needs_limit`:`unavailable`)){case`cooldown`:return`a reset was just used, try again in a minute`;case`blocked_five_hour`:return`can't be used while you're at your ${Ve.five_hour}`;case`blocked_seven_day`:return`can't be used while you're at your ${Ve.seven_day}`;case`blocked_opus`:return`can't be used while you're at your ${Ve.seven_day_opus}`;case`blocked_sonnet`:return`can't be used while you're at your ${Ve.seven_day_sonnet}`;case`blocked_other`:return`can't be used while you're at another limit it doesn't refill`;case`cannot_clear`:return`doesn't refill the limit you've reached`;case`needs_limit`:return`usable once you reach a limit it refills`;default:return`can't be used right now`}}function We(e){let t=new Set;e.givesBackWeekly&&t.add(`Fable`);for(let n of e.clears)n===`five_hour`?t.add(`5-hour`):n===`seven_day`?t.add(`weekly`):n===`seven_day_overage_included`?t.add(e.givesBackWeekly?`Fable`:`weekly`):n===`seven_day_opus`?t.add(`Opus weekly`):n===`seven_day_sonnet`&&t.add(`Sonnet weekly`);let n=[...t],r=n.pop();return r?n.length?`${n.join(`, `)} and ${r} limits`:`${r} limit`:`limits`}function Ge(e,t){if(t.exhausted.some(t=>He(e,t)))return null;let n=$(e.kind),r=null;for(let t of e.clears){let n=e.percentUsed[t];n!==void 0&&(r===null||n>r.used)&&(r={limit:t,used:n})}let i=r&&Ve[r.limit];return r&&i&&r.used<100?`You still have ${100-r.used}% of your ${i} left. Use your ${n} anyway?`:`You haven't reached a limit yet. Use your ${n} anyway?`}function Ke(e,t,n={}){let r=n.kind?$(n.kind):`reset`;switch(t){case`reset`:return`${e}: ${n.kind===`fable`?`Fable reset used. What Fable used is back in your weekly limit`:n.kind===`session`?`5-hour limit reset`:n.kind===`weekly`?`Weekly limits reset`:`Limits reset`}.${n.weeklyResetsAt?` Your weekly reset day stays ${new Date(n.weeklyResetsAt).toLocaleString(void 0,{weekday:`short`,month:`short`,day:`numeric`,hour:`numeric`,minute:`2-digit`})}.`:``}${typeof n.resetsLeft==`number`?` ${n.resetsLeft===0?`No`:n.resetsLeft} ${r}${n.resetsLeft===1?``:`s`} left.`:``}`;case`already_used`:return`${e}: that ${r} had already been used.`;case`not_limited`:return`${e}: nothing needed resetting, so the ${r} was kept.`;case`cooldown`:return`${e}: a reset was used moments ago. Nothing was used; try again in a minute.`;case`ineligible`:return`${e}: Anthropic no longer offers this account limit resets. Nothing was used.`;case`rate_limited`:return`${e}: Anthropic is turning requests away for now. Nothing was used; try again in a minute.`;case`auth_error`:return`${e}: Anthropic refused the account's sign-in. Nothing was used; sign in again and retry.`;case`unavailable`:return n.reason===`reset_unconfirmed`||n.reason===`stamp_indeterminate`?`${e}: couldn't confirm the reset went through. If the limits are not refilled in a moment, try again.`:`${e}: couldn't reset the limits${n.reason?` (${n.reason.replace(/_/g,` `)})`:``}. Nothing was used; try again in a moment.`;default:return`${e}: couldn't tell whether the reset went through. Check the limits in a moment before trying again.`}}function qe(e){let t=e.givesBackWeekly?` and gives back what Fable used of your weekly limit. It doesn't reset your whole week`:``;return`Refills your ${We(e)}${t}. Your weekly reset day stays the same.`}function Je(e){let t=new Map;for(let n of e){let e=`${n.kind}|${n.endsAt??``}`,r=t.get(e)??{kind:n.kind,count:0,endsAt:n.endsAt};r.count+=n.resetsLeft,t.set(e,r)}return[...t].map(([e,t])=>({key:e,title:(0,Q.jsxs)(Q.Fragment,{children:[$(t.kind,!0),t.count>1&&(0,Q.jsxs)(`span`,{className:`text-text-subtle`,children:[` ×`,t.count]})]}),expiresAt:t.endsAt}))}function Ye({account:e,resets:t,onDone:n}){let[r,i]=(0,Z.useState)(!1),[o,s]=(0,Z.useState)(null),[c,l]=(0,Z.useState)(!1),u=(t?.grants??[]).filter(e=>e.resetsLeft>0);if(!t||!u.length)return(0,Q.jsx)(q,{count:0,lines:[],usable:!1,onOpen:()=>{}});let d=e=>Ue(e,t),f=()=>{c||(i(!1),s(null))};async function p(t){l(!0);try{let r=await y.post(`/api/accounts/${e.id}/limit-reset`,{grantId:t.id});n(Ke(e.label,r.result,r))}catch(e){n(e.message||`Could not use the reset`)}finally{l(!1),i(!1),s(null)}}let m=(0,Q.jsx)(`div`,{className:`space-y-2`,"data-testid":`claude-limit-resets`,children:u.map(e=>(0,Q.jsx)(ce,{testId:`claude-reset-${e.id}`,title:(0,Q.jsxs)(Q.Fragment,{children:[$(e.kind,!0),e.resetsLeft>1&&(0,Q.jsxs)(`span`,{className:`text-text-subtle font-normal`,children:[` ×`,e.resetsLeft]})]}),detail:qe(e),expiresAt:e.endsAt,action:`Reset for free`,blockedReason:d(e),onUse:()=>s(e)},e.id))}),h=o&&(()=>{let n=$(o.kind),r=Ge(o,t);return(0,Q.jsxs)(`div`,{className:`space-y-3`,"data-testid":`claude-limit-reset-confirm`,children:[(0,Q.jsxs)(`p`,{className:`text-sm`,children:[`Use `,(0,Q.jsx)(`span`,{className:`font-medium`,children:e.label}),`'s `,n,`?`]}),(0,Q.jsxs)(`ul`,{className:`text-xs text-text-secondary space-y-1.5 list-disc pl-4`,children:[(0,Q.jsx)(`li`,{children:qe(o)}),r&&(0,Q.jsx)(`li`,{className:`text-warning`,children:r}),(0,Q.jsxs)(`li`,{children:[o.resetsLeft>1?`${o.resetsLeft} of this kind left`:`The only one of this kind`,o.endsAt?`, use by ${J(o.endsAt)}`:``,`.`]})]}),(0,Q.jsxs)(`div`,{className:`flex flex-col-reverse md:flex-row gap-2 md:justify-end pt-1`,children:[(0,Q.jsx)(D,{variant:`outline`,onClick:()=>s(null),disabled:c,className:`h-7 max-md:h-[26px]`,children:`Keep it`}),(0,Q.jsxs)(D,{onClick:()=>void p(o),disabled:c,className:`h-7 max-md:h-[26px] gap-1.5`,children:[c?(0,Q.jsx)(a,{className:`size-4 animate-spin`}):(0,Q.jsx)(g,{className:`size-4`}),`Yes, use my `,n]})]})]})})(),_=ze(t);return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(q,{count:_,lines:Je(u),usable:u.some(e=>!d(e)),onOpen:()=>i(!0)}),r&&(0,Q.jsx)(we,{title:o?`Use a ${$(o.kind)}?`:`Limit resets · ${_} available`,onClose:f,children:h||m})]})}function Xe(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 Ze({open:e,onOpenChange:t,accounts:n,preselectId:r,onMessage:i}){let o=n.filter(e=>e.hasRefreshToken),[s,c]=(0,Z.useState)(new Set),[l,d]=(0,Z.useState)(``),[f,p]=(0,Z.useState)(!1),[m,g]=(0,Z.useState)(!1),[y,b]=(0,Z.useState)(!1),[x,S]=(0,Z.useState)(!1);e&&!x&&(c(r?new Set([r]):new Set(o.map(e=>e.id))),S(!0)),!e&&x&&S(!1);function C(){t(!1),d(``),p(!1),g(!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!`):(Xe(o),i?.(`Backup downloaded.`)),C()}catch{}b(!1)}let T=s.size>0&&!y;return(0,Q.jsx)(N,{open:e,onOpenChange:e=>{e||C()},children:(0,Q.jsxs)(A,{className:`sm:max-w-md`,children:[(0,Q.jsxs)(O,{children:[(0,Q.jsxs)(j,{className:`text-sm flex items-center gap-1.5`,children:[(0,Q.jsx)(_,{className:`size-3.5`}),` Export Accounts`]}),(0,Q.jsx)(M,{className:`text-xs`,children:`Select accounts and set a password to protect the backup.`})]}),(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between mb-1`,children:[(0,Q.jsx)(`p`,{className:`text-[11px] font-medium text-muted-foreground`,children:`Accounts to export`}),(0,Q.jsx)(`button`,{className:`text-[10px] text-primary hover:underline cursor-pointer`,onClick:()=>c(s.size===o.length?new Set:new Set(o.map(e=>e.id))),children:s.size===o.length?`Deselect all`:`Select all`})]}),o.length===0?(0,Q.jsx)(`p`,{className:`text-[10px] text-muted-foreground p-2 border rounded`,children:`No exportable accounts.`}):(0,Q.jsx)(`div`,{className:`max-h-36 overflow-y-auto space-y-1 border rounded p-2`,children:o.map(e=>(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.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,Q.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,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsxs)(U,{className:`text-xs`,children:[`Password `,(0,Q.jsx)(`span`,{className:`text-muted-foreground font-normal`,children:`(optional)`})]}),(0,Q.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,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,id:`exp-full`,checked:f,onChange:e=>p(e.target.checked),className:`size-3.5 accent-primary cursor-pointer`}),(0,Q.jsx)(`label`,{htmlFor:`exp-full`,className:`text-[11px] cursor-pointer`,children:`Include refresh tokens (full transfer)`})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,id:`exp-refresh`,checked:m,onChange:e=>g(e.target.checked),className:`size-3.5 accent-primary cursor-pointer`}),(0,Q.jsx)(`label`,{htmlFor:`exp-refresh`,className:`text-[11px] cursor-pointer`,children:`Refresh tokens before export`})]}),f?(0,Q.jsxs)(`div`,{className:`rounded-md border border-error/30 bg-error/5 p-2.5`,children:[(0,Q.jsx)(`p`,{className:`text-[10px] font-medium text-error`,children:`Full transfer — source accounts will expire`}),(0,Q.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:`Refresh tokens included. Source machine expires in ~1h after target refreshes.`})]}):m?(0,Q.jsx)(`div`,{className:`rounded-md border border-warning/30 bg-warning/5 p-2.5`,children:(0,Q.jsx)(`p`,{className:`text-[10px] font-medium text-warning`,children:`Refresh before export — invalidates previous shares`})}):(0,Q.jsx)(`div`,{className:`rounded-md border border-success/30 bg-success/5 p-2.5`,children:(0,Q.jsx)(`p`,{className:`text-[10px] font-medium text-success`,children:`Share current token (safe)`})}),(0,Q.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:`Encrypted with AES-256-GCM + scrypt.`})]}),(0,Q.jsxs)(k,{className:`gap-1.5 flex-col sm:flex-row`,children:[(0,Q.jsx)(D,{size:`sm`,variant:`outline`,className:`text-xs h-7 cursor-pointer`,onClick:C,children:`Cancel`}),(0,Q.jsxs)(D,{size:`sm`,variant:`outline`,className:`text-xs h-7 cursor-pointer`,disabled:!T,onClick:()=>w(!0),children:[(0,Q.jsx)(h,{className:`size-3 mr-1`}),` Copy`]}),(0,Q.jsx)(D,{size:`sm`,className:`text-xs h-7 cursor-pointer`,disabled:!T,onClick:()=>w(!1),children:y?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(a,{className:`size-3 animate-spin mr-1`}),` Exporting...`]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(u,{className:`size-3 mr-1`}),` Download`]})})]})]})})}function Qe({open:e,onOpenChange:t,onSuccess:n}){let[r,i]=(0,Z.useState)(``),[o,s]=(0,Z.useState)(``),[c,l]=(0,Z.useState)(!1),[u,d]=(0,Z.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:o.trim()||`ppm-hienlh`});f(),n(`Imported ${e.imported} account(s)`)}catch(e){d(e.message||`Import failed`)}l(!1)}}return(0,Q.jsx)(N,{open:e,onOpenChange:e=>{e||f()},children:(0,Q.jsxs)(A,{className:`sm:max-w-md`,children:[(0,Q.jsxs)(O,{children:[(0,Q.jsxs)(j,{className:`text-sm flex items-center gap-1.5`,children:[(0,Q.jsx)(_,{className:`size-3.5`}),` Import Accounts`]}),(0,Q.jsx)(M,{className:`text-xs`,children:`Paste backup data and enter the export password. Imported accounts are temporary (~1h).`})]}),(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(U,{className:`text-xs`,children:`Backup data`}),(0,Q.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,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsxs)(U,{className:`text-xs`,children:[`Password `,(0,Q.jsx)(`span`,{className:`text-muted-foreground font-normal`,children:`(optional)`})]}),(0,Q.jsx)(I,{type:`password`,placeholder:`Leave empty for default`,value:o,onChange:e=>s(e.target.value),className:`text-xs h-8`,autoComplete:`current-password`})]})]}),u&&(0,Q.jsx)(`div`,{className:`text-[11px] p-2 rounded bg-error/10 text-error`,children:u}),(0,Q.jsxs)(k,{children:[(0,Q.jsx)(D,{size:`sm`,variant:`outline`,className:`text-xs h-7 cursor-pointer`,onClick:f,children:`Cancel`}),(0,Q.jsx)(D,{size:`sm`,className:`text-xs h-7 cursor-pointer`,disabled:!r.trim()||c,onClick:p,children:c?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(a,{className:`size-3 animate-spin mr-1`}),` Importing...`]}):`Import`})]})]})})}var $e=typeof window<`u`?window.matchMedia(`(min-width: 768px)`):null;function et(e){return $e?.addEventListener(`change`,e),()=>$e?.removeEventListener(`change`,e)}function tt(){return $e?.matches??!0}function nt(){let[e,t]=(0,Z.useState)(null),[n,r]=(0,Z.useState)(!0);return(0,Z.useEffect)(()=>{r(!0),ne().then(t).finally(()=>r(!1))},[]),n?(0,Q.jsx)(`p`,{className:`text-xs text-text-subtle py-4 text-center`,children:`Loading...`}):e?(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(`label`,{className:`text-xs font-medium text-text-primary`,children:`Rotation Strategy`}),(0,Q.jsxs)(oe,{value:e.strategy,onValueChange:async e=>{t(await L({strategy:e}))},children:[(0,Q.jsx)(ae,{className:`w-full h-9 text-xs`,children:(0,Q.jsx)(K,{})}),(0,Q.jsxs)(ie,{children:[(0,Q.jsx)(G,{value:`round-robin`,children:`Round-robin`}),(0,Q.jsx)(G,{value:`fill-first`,children:`Fill-first`}),(0,Q.jsx)(G,{value:`lowest-usage`,children:`Lowest usage`})]})]}),(0,Q.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,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(`label`,{className:`text-xs font-medium text-text-primary`,children:`Max Retry`}),(0,Q.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,Q.jsx)(`p`,{className:`text-[10px] text-text-subtle`,children:`How many accounts to try on failure. 0 = try all available accounts.`})]}),(0,Q.jsxs)(`div`,{className:`space-y-1.5 border-t border-border pt-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsx)(`label`,{className:`text-xs font-medium text-text-primary`,children:`Cooldown parking`}),(0,Q.jsx)(W,{checked:e.cooldownEnabled,onCheckedChange:async e=>{t(await L({cooldownEnabled:e}))}})]}),(0,Q.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,Q.jsxs)(`div`,{className:`flex items-center justify-between text-xs border-t border-border pt-3`,children:[(0,Q.jsx)(`span`,{className:`text-text-subtle`,children:`Active accounts`}),(0,Q.jsx)(`span`,{className:`font-medium text-text-primary`,children:e.activeCount})]})]}):(0,Q.jsx)(`p`,{className:`text-xs text-text-subtle py-4 text-center`,children:`Failed to load settings`})}function rt({open:e,onOpenChange:t}){let n=(0,Z.useSyncExternalStore)(et,tt);return e?n?(0,Q.jsx)(N,{open:e,onOpenChange:t,children:(0,Q.jsxs)(A,{className:`sm:max-w-sm`,children:[(0,Q.jsx)(O,{children:(0,Q.jsxs)(j,{className:`text-sm flex items-center gap-2`,children:[(0,Q.jsx)(i,{className:`size-4`}),` Rotation & Retry`]})}),(0,Q.jsx)(nt,{})]})}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.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,Q.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,Q.jsx)(`div`,{className:`flex justify-center pt-3 pb-1`,children:(0,Q.jsx)(`div`,{className:`w-10 h-1 rounded-full bg-border`})}),(0,Q.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-2 border-b border-border`,children:[(0,Q.jsxs)(`span`,{className:`text-sm font-semibold flex items-center gap-2`,children:[(0,Q.jsx)(i,{className:`size-4`}),` Rotation & Retry`]}),(0,Q.jsx)(`button`,{onClick:()=>t(!1),className:`flex items-center justify-center size-7 rounded-md hover:bg-surface-elevated transition-colors`,children:(0,Q.jsx)(f,{className:`size-4`})})]}),(0,Q.jsx)(`div`,{className:`px-4 py-4 pb-8`,children:(0,Q.jsx)(nt,{})})]})]}):null}var it=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 at({className:e,variant:t,...n}){return(0,Q.jsx)(`div`,{className:b(it({variant:t}),e),...n})}function ot(e){let t=Math.floor(Date.now()/1e3);return e>t?`${Math.floor((e-t)/60)}m`:`exp`}function st({accounts:e}){let[t,n]=(0,Z.useState)([]),[r,i]=(0,Z.useState)(!1),[o,s]=(0,Z.useState)(!1),[c,l]=(0,Z.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),o);n(t=>[...t,{round:t.length+1,time:new Date().toLocaleTimeString(),includeRefresh:o,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,Q.jsxs)(`section`,{className:`border-t pt-4 space-y-2`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Q.jsx)(`p`,{className:`text-xs font-medium`,children:`Simulate export`}),t.length>0&&(0,Q.jsxs)(`span`,{className:`text-[10px] text-muted-foreground`,children:[t.length,` round(s)`]})]}),(0,Q.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,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No OAuth account with a refresh token to export.`}):(0,Q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Q.jsx)(W,{id:`sim-include-refresh`,checked:o,onCheckedChange:s,className:`cursor-pointer`}),(0,Q.jsx)(U,{htmlFor:`sim-include-refresh`,className:`text-[11px] cursor-pointer`,children:`Include refresh tokens`})]}),(0,Q.jsx)(D,{size:`sm`,className:`h-7 text-xs cursor-pointer`,disabled:r,onClick:()=>void d(),children:r?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(a,{className:`size-3 animate-spin mr-1`}),` Exporting...`]}):`Run export #${t.length+1}`})]}),t.length>0&&(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[(0,Q.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,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsxs)(`p`,{className:`text-xs font-medium text-primary`,children:[`Round #`,e.round]}),(0,Q.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:e.time}),(0,Q.jsx)(at,{variant:e.includeRefresh?`destructive`:`secondary`,className:`text-[9px] px-1 py-0`,children:e.includeRefresh?`with refresh`:`access only`})]}),e.items.map(t=>(0,Q.jsxs)(`div`,{className:`p-2 rounded-lg border bg-card space-y-1.5`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`text-[11px] font-medium`,children:t.label??t.email??t.id.slice(0,8)}),t.tokenChanged&&(0,Q.jsx)(at,{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,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[11px]`,children:[(0,Q.jsx)(`span`,{className:`w-20 shrink-0 text-muted-foreground text-[10px]`,children:e.label}),(0,Q.jsx)(`code`,{className:`flex-1 truncate font-mono text-[10px] bg-muted px-1 rounded`,children:e.preview??`N/A`}),e.expires&&(0,Q.jsx)(`span`,{className:`text-[10px] text-muted-foreground shrink-0`,children:ot(e.expires)}),e.token?(0,Q.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,Q.jsx)(a,{className:`size-3 animate-spin`}):`Test`}):(0,Q.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:`-`}),t&&!t.loading&&(0,Q.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 ct(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 lt({open:e,onOpenChange:t,accounts:n}){let[i,o]=(0,Z.useState)(new Map),[s,c]=(0,Z.useState)(!1);async function l(e){o(t=>new Map(t).set(e,{loading:!0}));try{let t=await re(e,s);o(n=>new Map(n).set(e,{loading:!1,result:t}))}catch(t){o(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,Q.jsx)(N,{open:e,onOpenChange:t,children:(0,Q.jsxs)(A,{className:`sm:max-w-xl max-h-[85vh] flex flex-col`,children:[(0,Q.jsxs)(O,{children:[(0,Q.jsxs)(j,{className:`text-sm flex items-center gap-1.5`,children:[(0,Q.jsx)(r,{className:`size-4`}),` Token Test`]}),(0,Q.jsx)(M,{className:`text-xs`,children:`Probe stored tokens for validity. Nothing is modified.`})]}),(0,Q.jsxs)(`div`,{className:`space-y-4 overflow-y-auto flex-1 pr-1`,children:[(0,Q.jsxs)(`section`,{className:`space-y-2`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Q.jsx)(`p`,{className:`text-xs font-medium`,children:`Current tokens`}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Q.jsx)(W,{id:`token-test-refresh`,checked:s,onCheckedChange:c,className:`cursor-pointer`}),(0,Q.jsx)(U,{htmlFor:`token-test-refresh`,className:`text-[11px] cursor-pointer`,children:`Also test refresh`})]}),(0,Q.jsx)(D,{size:`sm`,variant:`outline`,className:`h-7 text-xs cursor-pointer`,onClick:u,children:`Test all`})]})]}),n.length===0&&(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No accounts to test.`}),(0,Q.jsx)(`div`,{className:`space-y-1.5`,children:n.map(e=>{let t=i.get(e.id),n=t?.result?.accessToken.status;return(0,Q.jsxs)(`div`,{className:`p-2 rounded border bg-card space-y-1`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`span`,{className:`text-xs font-medium truncate block`,children:e.label??e.email??e.id.slice(0,8)}),e.expiresAt&&(0,Q.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:ct(e.expiresAt)})]}),(0,Q.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,Q.jsx)(a,{className:`size-3 animate-spin`}):`Test`})]}),t&&!t.loading&&(0,Q.jsxs)(`div`,{className:`text-[11px] pl-2 border-l-2 border-muted`,children:[t.error&&(0,Q.jsx)(`p`,{className:`text-error`,children:t.error}),n&&(0,Q.jsxs)(`span`,{className:n.startsWith(`valid`)?`text-success`:`text-error`,children:[n,t.result?.accessToken.code?` (${t.result.accessToken.code})`:``]})]})]},e.id)})})]}),(0,Q.jsx)(st,{accounts:n})]}),(0,Q.jsx)(k,{children:(0,Q.jsx)(D,{size:`sm`,variant:`outline`,className:`text-xs cursor-pointer`,onClick:()=>t(!1),children:`Close`})})]})})}function ut(){let{usages:e,accounts:t,activeAccountId:n,initialLoading:o,refreshing:s,flashIds:c,reload:l}=fe(),[f,h]=(0,Z.useState)(null),[g,_]=(0,Z.useState)(null),[v,y]=(0,Z.useState)(null),[b,x]=(0,Z.useState)(null),[S,C]=(0,Z.useState)(null),[w,T]=(0,Z.useState)(null),[E,O]=(0,Z.useState)(null),[k,A]=(0,Z.useState)(void 0);function j(e){l(),e&&h(e)}async function M(e,t){_(e);try{await B(e,{status:t===`disabled`?`active`:`disabled`})}catch(e){h(e.message)}_(null),l()}async function N(){if(v){try{await V(v.id),h(`Account "${v.display}" removed.`),l()}catch(e){h(`Failed to remove: ${e.message}`)}y(null)}}async function P(e){b&&(await B(b.id,{label:e}),x(null),h(`Account renamed to "${e}".`),l())}let F=new Map(t.map(e=>[e.id,e])),I=e[0]?.usage.lastFetchedAt;return(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsx)(ve,{description:`Connect multiple Claude accounts. PPM rotates between them automatically to avoid rate limits.`,onRefresh:()=>void l(),refreshing:s,disabled:o,actions:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(D,{size:`sm`,className:`cursor-pointer gap-1.5`,onClick:()=>{A(void 0),O(`add`)},children:[(0,Q.jsx)(d,{className:`size-4`}),` Add account`]}),(0,Q.jsxs)(D,{size:`sm`,variant:`outline`,className:`cursor-pointer gap-1.5`,onClick:()=>{T(null),O(`export`)},children:[(0,Q.jsx)(u,{className:`size-4`}),` Export`]}),(0,Q.jsxs)(D,{size:`sm`,variant:`outline`,className:`cursor-pointer gap-1.5`,onClick:()=>O(`import`),children:[(0,Q.jsx)(p,{className:`size-4`}),` Import`]}),(0,Q.jsxs)(D,{size:`sm`,variant:`outline`,className:`cursor-pointer gap-1.5`,onClick:()=>O(`rotation`),children:[(0,Q.jsx)(i,{className:`size-4`}),` Rotation`]}),(0,Q.jsxs)(D,{size:`sm`,variant:`outline`,className:`cursor-pointer gap-1.5`,onClick:()=>O(`token-test`),children:[(0,Q.jsx)(r,{className:`size-4`}),` Token test`]})]})}),(0,Q.jsx)(xe,{message:f,onDismiss:()=>h(null)}),(0,Q.jsxs)(`section`,{className:`space-y-2`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsx)(`h3`,{className:`text-sm font-medium`,children:`Accounts`}),I&&(0,Q.jsxs)(`span`,{className:`text-[10px] text-muted-foreground`,children:[`usage `,se(new Date(I).getTime())]})]}),o?(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 py-6 text-xs text-muted-foreground`,children:[(0,Q.jsx)(a,{className:`size-4 animate-spin`}),` Loading accounts...`]}):e.length===0?(0,Q.jsxs)(`div`,{className:`flex flex-col items-center gap-2 py-8 text-center`,children:[(0,Q.jsx)(m,{className:`size-5 text-muted-foreground`}),(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No accounts connected yet.`}),(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Add one to start using PPM.`})]}):(0,Q.jsx)(me,{children:e.map(e=>(0,Q.jsx)(be,{layout:`strip`,entry:e,isActive:e.accountId===n,accountInfo:F.get(e.accountId),onToggle:M,toggling:g===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),resetCreditAction:(0,Q.jsx)(Ye,{account:{id:e.accountId,label:e.accountLabel??e.accountId.slice(0,8)},resets:e.usage.limitResets,onDone:e=>{h(e),l()}})},e.accountId))})]}),S&&(0,Q.jsx)(Fe,{profile:S.profile,accountId:S.accountId,onClose:()=>C(null)}),v&&(0,Q.jsx)(Ie,{display:v.display,onConfirm:()=>void N(),onCancel:()=>y(null)}),b&&(0,Q.jsx)(Re,{current:b.current,onSave:P,onCancel:()=>x(null)}),(0,Q.jsx)(Te,{open:E===`add`,onOpenChange:e=>{O(e?`add`:null),e||A(void 0)},onSuccess:j,signInAgainFor:k}),(0,Q.jsx)(Ze,{open:E===`export`,onOpenChange:e=>{O(e?`export`:null),e||T(null)},accounts:t,preselectId:w,onMessage:h}),(0,Q.jsx)(Qe,{open:E===`import`,onOpenChange:e=>O(e?`import`:null),onSuccess:j}),(0,Q.jsx)(rt,{open:E===`rotation`,onOpenChange:e=>O(e?`rotation`:null)}),(0,Q.jsx)(lt,{open:E===`token-test`,onOpenChange:e=>O(e?`token-test`:null),accounts:t})]})}function dt({mode:e,onOpenChange:t,password:n,onPasswordChange:r,busy:i,onExport:o,onImport:s,error:c}){let l=(0,Z.useRef)(null),d=e===`export`;return(0,Q.jsx)(N,{open:e!==null,onOpenChange:t,children:(0,Q.jsxs)(A,{className:`sm:max-w-md`,children:[(0,Q.jsxs)(O,{children:[(0,Q.jsxs)(j,{className:`text-sm flex items-center gap-1.5`,children:[(0,Q.jsx)(_,{className:`size-4`}),` `,d?`Export Codex Accounts`:`Import Codex Accounts`]}),(0,Q.jsx)(M,{className:`text-xs leading-relaxed`,children:d?`Writes a password-encrypted file containing each account's login.`:`Reads a backup file. The password must be the one it was exported with.`})]}),(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(U,{htmlFor:`codex-backup-password`,className:`text-xs`,children:`Password`}),(0,Q.jsx)(I,{id:`codex-backup-password`,type:`password`,placeholder:d?`Choose a password`:`Password used for the export`,value:n,onChange:e=>r(e.target.value),className:`text-xs`,autoComplete:d?`new-password`:`current-password`}),(0,Q.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:`A backup holds full logins — keep the file and its password together.`})]}),c&&(0,Q.jsx)(`div`,{className:`text-[11px] p-2 rounded bg-error/10 text-error`,children:c}),(0,Q.jsx)(`input`,{ref:l,type:`file`,accept:`application/json,.json`,className:`hidden`,onChange:e=>{let t=e.target.files?.[0];e.target.value=``,t&&s(t)}}),(0,Q.jsxs)(k,{children:[(0,Q.jsx)(D,{size:`sm`,variant:`outline`,className:`text-xs cursor-pointer`,onClick:()=>t(!1),children:`Cancel`}),(0,Q.jsxs)(D,{size:`sm`,className:`text-xs cursor-pointer gap-1.5`,disabled:!n.trim()||i,onClick:()=>d?o():l.current?.click(),children:[i?(0,Q.jsx)(a,{className:`size-3.5 animate-spin`}):d?(0,Q.jsx)(u,{className:`size-3.5`}):(0,Q.jsx)(p,{className:`size-3.5`}),d?`Download backup`:`Choose file`]})]})]})})}var ft=[{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 pt({open:e,onOpenChange:t,strategy:n,onChange:r}){return(0,Q.jsx)(N,{open:e,onOpenChange:t,children:(0,Q.jsxs)(A,{className:`sm:max-w-md`,children:[(0,Q.jsxs)(O,{children:[(0,Q.jsx)(j,{className:`text-sm`,children:`Codex Rotation`}),(0,Q.jsx)(M,{className:`text-xs leading-relaxed`,children:`How a new chat chooses among your Codex accounts.`})]}),(0,Q.jsx)(`div`,{className:`space-y-2`,children:ft.map(e=>(0,Q.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,Q.jsx)(`p`,{className:`text-sm font-medium`,children:e.label}),(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.hint})]},e.value))}),(0,Q.jsx)(k,{children:(0,Q.jsx)(D,{size:`sm`,variant:`outline`,className:`text-xs cursor-pointer`,onClick:()=>t(!1),children:`Done`})})]})})}function mt(e){return e==null?null:Math.round(e*100)}function ht({usage:e}){let t=e.session==null&&e.weekly==null;return(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(t||e.session!=null)&&(0,Q.jsx)(Ce,{label:`5-Hour Session`,pct:mt(e.fiveHour),reset:he(e.session),resetsAt:e.session?.resetsAt}),(t||e.weekly!=null)&&(0,Q.jsx)(Ce,{label:`Weekly`,pct:mt(e.sevenDay),reset:he(e.weekly),resetsAt:e.weekly?.resetsAt})]})}function gt(e){let t=e=>Math.round((e??0)*100)>=100;return t(e.session?.utilization)||t(e.weekly?.utilization)}var _t={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.`},vt=`Usable once a limit is reached: a reset moves the weekly reset date, so spending one earlier wastes what is left of the window.`;function yt(e){return e.credits?.length?e.credits:Array.from({length:e.available},(t,n)=>n===0?{id:e.nextCreditId,title:e.title,expiresAt:e.nextExpiresAt}:{title:e.title})}function bt({account:e,usage:t,onDone:n}){let[r,i]=(0,Z.useState)(!1),[o,s]=(0,Z.useState)(null),[c,l]=(0,Z.useState)(!1),u=t.resetCredits;if(!u||u.available===0)return(0,Q.jsx)(q,{count:0,lines:[],usable:!1,onOpen:()=>{}});let d=yt(u),f=gt(t),p=()=>{c||(i(!1),s(null))};async function m(t){l(!0);try{let r=await y.post(`/api/codex-accounts/${e.id}/reset-credit`,t.id?{creditId:t.id}:{});n(_t[r.outcome]?.(e.label)??`${e.label}: ${r.outcome}`)}catch(e){n(e.message||`Could not use the reset`)}finally{l(!1),i(!1),s(null)}}let h=t.weekly?.resetsAt?J(t.weekly.resetsAt):null,_=o&&(0,Q.jsxs)(`div`,{className:`space-y-3`,"data-testid":`codex-reset-credit-confirm`,children:[(0,Q.jsxs)(`p`,{className:`text-sm`,children:[`Use 1 of `,(0,Q.jsx)(`span`,{className:`font-medium`,children:e.label}),`'s `,u.available,` free reset`,u.available===1?``:`s`,`?`]}),(0,Q.jsxs)(`ul`,{className:`text-xs text-text-secondary space-y-1.5 list-disc pl-4`,children:[(0,Q.jsxs)(`li`,{children:[o.title??`Full reset`,`: the 5-hour and weekly usage go back to 0% now.`]}),(0,Q.jsxs)(`li`,{children:[`The weekly reset date moves: the next one is about 7 days after you continue using Codex`,h?`, not ${h} as now`:``,`. You do not also get that one.`]}),o.expiresAt&&(0,Q.jsxs)(`li`,{children:[`This reset expires `,J(o.expiresAt),`.`]})]}),(0,Q.jsxs)(`div`,{className:`flex flex-col-reverse md:flex-row gap-2 md:justify-end pt-1`,children:[(0,Q.jsx)(D,{variant:`outline`,onClick:()=>s(null),disabled:c,className:`h-7 max-md:h-[26px]`,children:`Keep it`}),(0,Q.jsxs)(D,{onClick:()=>void m(o),disabled:c,className:`h-7 max-md:h-[26px] gap-1.5`,children:[c?(0,Q.jsx)(a,{className:`size-4 animate-spin`}):(0,Q.jsx)(g,{className:`size-4`}),`Use reset`]})]})]});return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(q,{count:u.available,lines:d.map((e,t)=>({key:e.id??String(t),title:e.title??`Full reset`,expiresAt:e.expiresAt})),usable:f,onOpen:()=>i(!0)}),r&&(0,Q.jsx)(we,{title:o?`Use a free reset`:`Free resets · ${u.available} available`,onClose:p,children:_||(0,Q.jsxs)(`div`,{className:`space-y-2`,"data-testid":`codex-reset-credits`,children:[!f&&(0,Q.jsx)(`p`,{className:`text-xs text-warning`,children:vt}),d.map((e,t)=>(0,Q.jsx)(ce,{title:e.title??`Full reset`,detail:`Resets the 5-hour and weekly usage to 0%. The weekly reset date then counts from your next use.`,expiresAt:e.expiresAt,action:`Use reset`,blockedReason:f?null:!0,onUse:()=>s(e)},e.id??t))]})})]})}var xt=1440*60*1e3,St=7,Ct=5;function wt(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-St*xt;if(t<r)return null;let i=Math.min(St-1,Math.floor((t-r)/xt)),a=0;for(let e=0;e<=i;e++){let t=new Date(r+e*xt).getUTCDay();t!==0&&t!==6&&a++}let o=a/Ct;return{day:a,cap:o,used:e.utilization,blocked:e.utilization>=o}}function Tt(){let[e,t]=(0,Z.useState)(null),n=Ee(()=>t(null)),[r,c]=(0,Z.useState)(null);return(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsx)(ve,{description:(0,Q.jsxs)(Q.Fragment,{children:[`Each Codex account keeps its own login (`,(0,Q.jsx)(`code`,{children:`CODEX_HOME`}),`). One is picked per chat by the rotation setting.`]}),onRefresh:()=>void n.load(),refreshing:n.loading,actions:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(D,{size:`sm`,className:`cursor-pointer gap-1.5`,onClick:()=>t(`add`),children:[(0,Q.jsx)(d,{className:`size-4`}),` Add account`]}),(0,Q.jsxs)(D,{size:`sm`,variant:`outline`,className:`cursor-pointer gap-1.5`,onClick:()=>t(`export`),children:[(0,Q.jsx)(u,{className:`size-4`}),` Export`]}),(0,Q.jsxs)(D,{size:`sm`,variant:`outline`,className:`cursor-pointer gap-1.5`,onClick:()=>t(`import`),children:[(0,Q.jsx)(p,{className:`size-4`}),` Import`]}),(0,Q.jsxs)(D,{size:`sm`,variant:`outline`,className:`cursor-pointer gap-1.5`,onClick:()=>t(`rotation`),children:[(0,Q.jsx)(i,{className:`size-4`}),` Rotation`]})]})}),(0,Q.jsx)(xe,{message:n.msg??n.err,onDismiss:()=>{n.setMsg(null),n.setErr(null)}}),(0,Q.jsxs)(`section`,{className:`space-y-2`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsx)(`h3`,{className:`text-sm font-medium`,children:`Codex Accounts`}),(0,Q.jsx)(`span`,{className:`text-[10px] text-muted-foreground capitalize`,children:n.strategy.replace(`-`,` `)})]}),n.loading&&n.accounts.length===0?(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 py-6 text-xs text-muted-foreground`,children:[(0,Q.jsx)(a,{className:`size-4 animate-spin`}),` Loading accounts...`]}):n.accounts.length===0?(0,Q.jsxs)(`div`,{className:`flex flex-col items-center gap-2 py-8 text-center`,children:[(0,Q.jsx)(m,{className:`size-5 text-muted-foreground`}),(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No Codex accounts yet.`}),(0,Q.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Chats use your default `,(0,Q.jsx)(`code`,{children:`~/.codex`}),` login until you add one.`]})]}):(0,Q.jsx)(me,{children:n.accounts.map(e=>{let t=n.usages[e.id]??{};return(0,Q.jsxs)(le,{dense:!0,className:`flex flex-col min-w-[300px] shrink-0 snap-start${e.signedOut?` opacity-60`:``}`,"data-testid":`account-card`,"data-account-id":e.id,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`text-sm font-medium truncate flex-1 min-w-0`,children:e.label}),e.signedOut&&(0,Q.jsx)(X,{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`?()=>c(e):void 0,children:`Sign in again`}),(0,Q.jsx)(`span`,{className:`text-[10px] uppercase tracking-wide text-text-subtle border border-border rounded px-1 shrink-0`,children:e.type}),pe(e.planType)&&(0,Q.jsx)(`span`,{className:`text-[10px] text-text-subtle shrink-0`,children:pe(e.planType)}),(0,Q.jsx)(W,{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,Q.jsxs)(C,{children:[(0,Q.jsx)(x,{asChild:!0,children:(0,Q.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,Q.jsx)(o,{className:`size-4`})})}),(0,Q.jsx)(S,{side:`top`,children:`Remove account`})]})]}),(0,Q.jsx)(ht,{usage:t}),t.session==null&&(()=>{let r=wt(t.weekly);return r?(0,Q.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,Q.jsxs)(`div`,{className:`min-w-0 space-y-0.5`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs font-medium ${e.dailyGuardEnabled&&r.blocked?`text-error`:`text-text-secondary`}`,children:[(0,Q.jsx)(`span`,{children:`Daily guard`}),(0,Q.jsxs)(C,{children:[(0,Q.jsx)(x,{asChild:!0,children:(0,Q.jsx)(`button`,{type:`button`,"aria-label":`About Daily guard`,className:`text-text-subtle hover:text-text-primary cursor-help`,children:(0,Q.jsx)(s,{className:`size-3.5`})})}),(0,Q.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,Q.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,Q.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,Q.jsx)(W,{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})(),(0,Q.jsx)(`div`,{className:`mt-auto`,children:(0,Q.jsx)(bt,{account:e,usage:t,onDone:e=>{n.setMsg(e),n.load()}})})]},e.id)})})]}),(0,Q.jsx)(ue,{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,Q.jsx)(dt,{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,Q.jsx)(Y,{account:r,onClose:()=>c(null),onDone:()=>void n.load()}),(0,Q.jsx)(pt,{open:e===`rotation`,onOpenChange:e=>t(e?`rotation`:null),strategy:n.strategy,onChange:e=>void n.changeStrategy(e)})]})}var Et=[{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 Dt(e){return e==null?null:Math.round(e*100)}function Ot(){let[e,t]=(0,Z.useState)([]),[n,r]=(0,Z.useState)(`round-robin`),[s,u]=(0,Z.useState)({}),[f,p]=(0,Z.useState)(!0),[h,g]=(0,Z.useState)(null),[_,v]=(0,Z.useState)(null),[w,T]=(0,Z.useState)(new Set),[E,P]=(0,Z.useState)(null),[F,L]=(0,Z.useState)(null),[R,z]=(0,Z.useState)(``),[B,ee]=(0,Z.useState)(null),[te,ne]=(0,Z.useState)(!1),[V,re]=(0,Z.useState)(``),[H,ie]=(0,Z.useState)(!1),[ae,G]=(0,Z.useState)(null),K=(0,Z.useRef)(0),oe=(0,Z.useRef)(!1),q=(0,Z.useRef)(!1),J=(0,Z.useRef)(null),ce=(0,Z.useRef)(null),Y=(0,Z.useCallback)(async()=>{p(!0),v(null);try{let e=await y.get(`/api/antigravity-accounts`);t(e.accounts),r(e.strategy),u(await y.get(`/api/antigravity-accounts/usage`))}catch(e){v(e.message)}finally{p(!1)}},[]);(0,Z.useEffect)(()=>{Y()},[Y]);let ue=(0,Z.useCallback)(()=>{K.current+=1,oe.current=!1,q.current=!1,ce.current?.(),ce.current=null;let e=J.current;J.current=null,e&&y.del(`/api/antigravity-accounts/login/${e}`).catch(()=>{})},[]);(0,Z.useEffect)(()=>ue,[ue]);let X=(0,Z.useCallback)(()=>{ue(),ee(null),ne(!1),re(``),ie(!1)},[ue]),de=(0,Z.useCallback)(()=>{X(),G(null),z(``),L(null),P(null)},[X]),fe=(0,Z.useCallback)(e=>{let t=Date.now()+61e4,n=!1,r;ce.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`){J.current=null,X(),G(null),z(``),L(null),P(null),g(`Antigravity Google account connected.`),await Y();return}if(a?.state===`error`||Date.now()>t){J.current=null,X(),G(a?.state===`error`?a.error??`Login failed.`:`Login timed out.`);return}r=setTimeout(i,2e3)}};i()},[Y,X]),pe=(0,Z.useCallback)(async e=>{if(oe.current||J.current||q.current)return;oe.current=!0;let t=++K.current;ne(!0),G(null);try{let n=await y.post(`/api/antigravity-accounts/login`,{...R.trim()?{label:R.trim()}:{},...e?{accountId:e.id}:{}});if(t!==K.current){y.del(`/api/antigravity-accounts/login/${n.id}`).catch(()=>{});return}J.current=n.id,ee(n),fe(n.id)}catch(e){t===K.current&&G(e.message)}finally{t===K.current&&(oe.current=!1,ne(!1))}},[R,fe]),ge=(0,Z.useCallback)(async()=>{if(!B||!V.trim()||q.current)return;let e=K.current;q.current=!0,ie(!0),G(null);try{let t=await y.post(`/api/antigravity-accounts/login/${B.id}/callback`,{code:V.trim()});if(e!==K.current)return;if(t?.state===`error`){J.current=null,X(),G(t.error??`Login failed.`);return}if(t?.state!==`done`)return;J.current=null,X(),z(``),L(null),P(null),g(`Antigravity Google account connected.`),await Y()}catch(t){e===K.current&&(J.current=null,X(),G(t.message))}finally{e===K.current&&(q.current=!1,ie(!1))}},[B,V,Y,X]),ye=(0,Z.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})}},[]),be=(0,Z.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)}},[]),we=(0,Z.useCallback)(async e=>{v(null);try{await y.put(`/api/antigravity-accounts/strategy`,{strategy:e}),r(e)}catch(e){v(e.message)}},[]),Te=(0,Z.useCallback)(e=>{L(e),z(e.label),P(`add`)},[]);return(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsx)(ve,{description:(0,Q.jsxs)(Q.Fragment,{children:[`Each Antigravity account keeps its own Google OAuth login (`,(0,Q.jsx)(`code`,{children:`~/.ppm/antigravity-accounts`}),`) alongside your local IDE login (`,(0,Q.jsx)(`code`,{children:`~/.gemini`}),`). One is picked per chat by the rotation setting.`]}),onRefresh:()=>void Y(),refreshing:f,actions:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(D,{size:`sm`,className:`cursor-pointer gap-1.5`,onClick:()=>{L(null),z(``),P(`add`)},children:[(0,Q.jsx)(d,{className:`size-4`}),` Add account`]}),(0,Q.jsxs)(D,{size:`sm`,variant:`outline`,className:`cursor-pointer gap-1.5`,onClick:()=>P(`rotation`),children:[(0,Q.jsx)(i,{className:`size-4`}),` Rotation`]})]})}),(0,Q.jsx)(xe,{message:h??_,onDismiss:()=>{g(null),v(null)}}),(0,Q.jsxs)(`section`,{className:`space-y-2`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsx)(`h3`,{className:`text-sm font-medium`,children:`Antigravity Accounts`}),(0,Q.jsx)(`span`,{className:`text-[10px] text-muted-foreground capitalize`,children:n.replace(`-`,` `)})]}),f&&e.length===0?(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 py-6 text-xs text-muted-foreground`,children:[(0,Q.jsx)(a,{className:`size-4 animate-spin`}),` Loading accounts...`]}):e.length===0?(0,Q.jsxs)(`div`,{className:`flex flex-col items-center gap-2 py-8 text-center`,children:[(0,Q.jsx)(m,{className:`size-5 text-muted-foreground`}),(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No Antigravity accounts yet.`}),(0,Q.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Click `,(0,Q.jsx)(`strong`,{children:`Add account`}),` to sign in with Google, or start Antigravity Desktop to auto-detect your local account.`]})]}):(0,Q.jsx)(me,{children:e.map(e=>{let t=Se(s[e.id]??{}),n=t.session==null&&t.weekly==null&&(!t.weeklyScoped||t.weeklyScoped.length===0),r=e.id===`default`;return(0,Q.jsxs)(le,{dense:!0,className:`min-w-[320px] shrink-0 snap-start`,"data-testid":`account-card`,"data-account-id":e.id,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Q.jsx)(`div`,{className:`text-sm font-medium truncate`,children:e.label}),e.email&&e.email!==e.label&&(0,Q.jsx)(`div`,{className:`text-[11px] text-text-subtle truncate`,children:e.email})]}),(0,Q.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,Q.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,Q.jsx)(W,{checked:e.status!==`disabled`,onCheckedChange:()=>void ye(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,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(C,{children:[(0,Q.jsx)(x,{asChild:!0,children:(0,Q.jsx)(`button`,{type:`button`,onClick:()=>Te(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,Q.jsx)(c,{className:`size-3.5`})})}),(0,Q.jsx)(S,{side:`top`,children:`Sign in again`})]}),(0,Q.jsxs)(C,{children:[(0,Q.jsx)(x,{asChild:!0,children:(0,Q.jsx)(`button`,{type:`button`,onClick:()=>void be(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,Q.jsx)(o,{className:`size-4`})})}),(0,Q.jsx)(S,{side:`top`,children:`Remove account`})]})]})]}),(0,Q.jsxs)(`div`,{className:`space-y-2 pt-1`,children:[(n||t.session!=null)&&(0,Q.jsx)(Ce,{label:`Gemini · 5-Hour Session`,pct:Dt(t.fiveHour),reset:he(t.session),resetsAt:t.session?.resetsAt}),(n||t.weekly!=null)&&(0,Q.jsx)(Ce,{label:`Gemini · Weekly`,pct:Dt(t.sevenDay),reset:he(t.weekly),resetsAt:t.weekly?.resetsAt}),t.weeklyScoped?.map(e=>(0,Q.jsx)(Ce,{label:e.label,pct:Dt(e.utilization),reset:he(e),resetsAt:e.resetsAt},e.label))]}),t.lastFetchedAt&&_e(t.lastFetchedAt)&&(0,Q.jsxs)(`p`,{className:`text-[10px] text-warning`,children:[`Last read `,se(Date.parse(t.lastFetchedAt)),`. Neither agy nor the Antigravity app has answered since.`]})]},e.id)})})]}),(0,Q.jsx)(N,{open:E===`add`,onOpenChange:e=>{e||de()},children:(0,Q.jsxs)(A,{className:`sm:max-w-md max-h-[90dvh] overflow-y-auto`,children:[(0,Q.jsxs)(O,{children:[(0,Q.jsx)(j,{className:`text-sm`,children:F?`Sign in again — ${F.label}`:`Add Antigravity Account`}),(0,Q.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,Q.jsxs)(`div`,{className:`space-y-3`,children:[!F&&(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(U,{htmlFor:`agy-label`,className:`text-xs`,children:`Label (optional)`}),(0,Q.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,Q.jsxs)(`div`,{className:`rounded-md border p-3 space-y-2.5`,children:[(0,Q.jsx)(`p`,{className:`text-[11px] font-medium`,children:`Google OAuth Sign-In`}),B?(0,Q.jsxs)(`div`,{className:`space-y-2.5 text-xs`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Q.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,Q.jsx)(l,{className:`size-3.5`}),` Open Google Sign-In page`]}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>{X(),G(null)},disabled:H,className:`text-[11px] text-muted-foreground hover:text-foreground underline cursor-pointer`,children:`Start over`})]}),(0,Q.jsxs)(`p`,{className:`text-muted-foreground leading-relaxed`,children:[`1. Open the link above and sign in with your Google account.`,(0,Q.jsx)(`br`,{}),`2. Copy the authorization code (or the full callback URL) shown after signing in and paste it below:`]}),(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(U,{htmlFor:`agy-auth-code`,className:`text-xs`,children:`Authorization Code or Callback URL`}),(0,Q.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,Q.jsxs)(D,{size:`sm`,className:`w-full cursor-pointer gap-1.5`,onClick:()=>void ge(),disabled:!V.trim()||H,children:[H&&(0,Q.jsx)(a,{className:`size-3.5 animate-spin`}),`Verify & Save Account`]})]}):(0,Q.jsx)(D,{size:`sm`,className:`w-full cursor-pointer gap-1.5`,onClick:()=>void pe(F),disabled:te,children:te?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(a,{className:`size-4 animate-spin`}),` Generating Google sign-in link...`]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(l,{className:`size-4`}),` Sign in with Google`]})})]})]}),ae&&(0,Q.jsx)(`div`,{role:`alert`,className:`text-[11px] p-2 rounded bg-error/10 text-error`,children:ae}),(0,Q.jsx)(k,{children:(0,Q.jsx)(D,{size:`sm`,variant:`outline`,className:`text-xs cursor-pointer`,onClick:de,children:`Cancel`})})]})}),(0,Q.jsx)(N,{open:E===`rotation`,onOpenChange:e=>P(e?`rotation`:null),children:(0,Q.jsxs)(A,{className:`sm:max-w-md`,children:[(0,Q.jsxs)(O,{children:[(0,Q.jsx)(j,{className:`text-sm`,children:`Antigravity Rotation`}),(0,Q.jsx)(M,{className:`text-xs leading-relaxed`,children:`How a new chat chooses among your enabled Antigravity accounts.`})]}),(0,Q.jsx)(`div`,{className:`space-y-2`,children:Et.map(e=>(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>void we(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,Q.jsx)(`p`,{className:`text-sm font-medium`,children:e.label}),(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.hint})]},e.value))}),(0,Q.jsx)(k,{children:(0,Q.jsx)(D,{size:`sm`,variant:`outline`,className:`text-xs cursor-pointer`,onClick:()=>P(null),children:`Done`})})]})})]})}var kt=[{id:`claude`,label:`Claude`},{id:`codex`,label:`Codex`},{id:`antigravity`,label:`Antigravity`}];function At(){let[e,t]=(0,Z.useState)(null),[n,r]=(0,Z.useState)(()=>ge()),[i,o]=(0,Z.useState)(n?.provider??`claude`),s=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{let e=()=>{let e=ge();e&&(o(e.provider),r(e))};return window.addEventListener(de,e),()=>window.removeEventListener(de,e)},[]),(0,Z.useEffect)(()=>{if(n)return ye(()=>s.current,n.accountId)},[n]),(0,Z.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 c=kt.filter(t=>t.id===`claude`||e?.has(t.id)),l=c.length>1;return(0,Q.jsxs)(`div`,{ref:s,className:`space-y-4`,"data-testid":`accounts-pane`,"data-provider":i,children:[l&&(0,Q.jsx)(`div`,{className:`flex gap-1 border-b border-border/50`,children:c.map(e=>(0,Q.jsxs)(`button`,{onClick:()=>o(e.id),"data-testid":`accounts-tab-${e.id}`,"aria-current":i===e.id?`page`:void 0,className:`flex items-center gap-1.5 px-3 py-2 text-xs rounded-t transition-colors cursor-pointer ${i===e.id?`text-primary border-b-2 border-primary font-medium`:`text-text-subtle hover:text-text-secondary`}`,children:[(0,Q.jsx)(P,{providerId:e.id}),e.label]},e.id))}),e===null&&!l&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,Q.jsx)(a,{className:`size-3 animate-spin`}),` Checking configured providers...`]}),i===`claude`?(0,Q.jsx)(ut,{}):i===`codex`?(0,Q.jsx)(Tt,{}):(0,Q.jsx)(Ot,{})]})}export{At as AccountsSettingsSection};
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/agent-session-window-content-Dg07wugC.js","assets/rolldown-runtime-C5c2KzVm.js","assets/vendor-ui-BQzUk4nq.js","assets/vendor-markdown-26eoXJk7.js","assets/button-CtdEWN7U.js","assets/utils-DMiycH3O.js","assets/libesm-B_LCqxF2.js","assets/api-client-DSCscZEd.js","assets/open-ppm-tab-d8_3ai-M.js","assets/settings-store-DirmJxtu.js","assets/preload-helper-uTix4PVD.js","assets/react-BH62_kP1.js","assets/settings-events-BzBnHQWJ.js","assets/window-store-Bl6ySrZZ.js","assets/minimal-mode-DDuML1Oi.js","assets/file-browser-locate-C6ckBRTU.js","assets/use-explorer-open-state-xgkY0uH0.js","assets/use-is-mobile-CrfIt67b.js","assets/panel-store-B5zTGca0.js","assets/session-list-sync-triggers-_I5gGBSe.js","assets/project-store-BaGmhKos.js","assets/project-framework-store-vI8djw4a.js","assets/vault-Q5oPy0h3.js","assets/open-assistant-uhdReWoG.js","assets/patch-tab-metadata-DzBKXZ8Z.js","assets/assistant-settings-tab-store-BFJ4pM3_.js","assets/settings-categories-B_629iML.js","assets/icons-CpR5Vw3J.js","assets/open-settings-CGqVSUo5.js","assets/tab-store-CdpGgbmw.js","assets/design-tab-metadata-o2TAAwEt.js","assets/chat-jump-store-BzDl2wpf.js","assets/vault-focus-store-BYABW4-C.js","assets/assistant-managers-DBFW4Vy_.js","assets/assistant-persona-CiWkGBFh.js","assets/assistant-settings-changes-client-yYOd0NDP.js","assets/assistant-settings-api-DvAT6QKt.js","assets/tool-cards-ByfYqVsL.js","assets/index-ix3m5QQT.js","assets/createLucideIcon-nOpXneg9.js","assets/extension-icons-BSSI8zJe.js","assets/git-commit-horizontal-BJpjDb3H.js","assets/assistant-settings-B17q1iTi.js","assets/assistant-digest-XqNJJf0c.js","assets/assistant-settings-dialog-Dkj30xcq.js","assets/feature-intros-BNK1hj-A.js","assets/session-collab-BD1AwcUC.js","assets/dialog-BWXzvHlC.js","assets/portal-container-context-C84rlnJ6.js","assets/mobile-bottom-sheet-C78UMLrn.js","assets/use-visual-viewport-tMLO63yY.js","assets/open-db-tabs-SyNM2EhJ.js","assets/explorer-model-CMB2DLaE.js","assets/db-connection-config-DKVbmtru.js","assets/db-types-C1hMYmOv.js","assets/db-sidebar-reveal-DT3XJ69t.js","assets/db-drivers-BIKN5HLb.js","assets/impexp-state-HsrqffES.js","assets/design-canvas-check-DAc84j07.js","assets/model-thinking-selector-helpers-CSb4sOPu.js","assets/input-CCVoN0-P.js","assets/file-store-DvNGR1CA.js","assets/slash-command-picker-xIZbJS-p.js","assets/build-message-with-attachments-CQod0B6Y.js","assets/task-format-BZIV3kD8.js","assets/open-task-C-XSSORs.js","assets/use-manager-chats-7IXu1wX5.js","assets/open-chat-session-B8FHbA1S.js","assets/open-chat-in-window-v7025zeE.js","assets/clipboard-DQuoK2EM.js","assets/ppm-tools-D46CufEw.js","assets/db-ai-tools-x8SPCTHe.js","assets/split-sql-statements-0B9v-kNm.js","assets/tab-open-protocol-D5UyfEsm.js","assets/user-message-parse-DG85Nt5-.js","assets/voice-message-CNThCsr3.js","assets/set-manager-chat-dialog-CZm1uMTC.js","assets/provider-selector-CpYLloT9.js","assets/chat-preparation-cache-D6KJ1ZMi.js","assets/provider-logos-zWlJBGXd.js","assets/use-coarse-long-press-r69G14r1.js","assets/task-chip-peek-dtuuhUxI.js","assets/task-links-card-D4IzxjS0.js","assets/dropdown-menu-DMZtzfk5.js","assets/radio-dot-UO7SfziL.js","assets/control-size-DFdAJqoq.js","assets/adaptive-context-menu-BY4ki-EE.js","assets/start-ellipsis-BQ0FJowG.js","assets/tooltip-CECVgROB.js","assets/use-voice-message-recorder-BxjLFY10.js","assets/api-settings-DOq_SIAU.js","assets/format-date-E9rSy4Po.js","assets/image-gallery-BvIkGPUA.js","assets/session-collab-client-BxXx812Z.js","assets/send-to-chat-Saa9Tfu2.js","assets/notification-store-hHQ6I1WT.js","assets/unsaved-grid-rows-store-DKZSxIbb.js","assets/sql-identifiers-D62yiJWh.js","assets/db-explorer-store-Bzw8bf2f.js","assets/format-file-meta-B4qeznFu.js","assets/fs-api-COsHlRxJ.js","assets/scroll-area-DKwnCaCu.js","assets/use-git-repo-BjCnSkJ0.js","assets/git-repo-store-BCgyxqGc.js","assets/use-schedules-b8L8CH0W.js","assets/file-icons-wTYRmxJu.js","assets/global-ws-channel-C7BkbuOy.js","assets/ws-auth-BoXvat-e.js","assets/streaming-store-Dq4AjFuk.js","assets/apply-theme-BeLRfsSu.js","assets/resolve-theme-BHAgAaFk.js","assets/index-BrxyfrYc.css","assets/vault-tool-call-DSMwzVDz.js","assets/agent-session-sheet-store-5Azq2b1n.js","assets/image-preview-geometry-BGYjT5qH.js","assets/markdown-context-yGQ4E4_7.js","assets/use-blob-url-CoPtAkb7.js","assets/html-preview-loads-BsMjOwLP.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-26eoXJk7.js";import"./vendor-ui-BQzUk4nq.js";import{pi as r}from"./icons-CpR5Vw3J.js";import{t as i}from"./preload-helper-uTix4PVD.js";import"./portal-container-context-C84rlnJ6.js";import{t as a}from"./mobile-bottom-sheet-C78UMLrn.js";import"./use-visual-viewport-tMLO63yY.js";import{t as o}from"./agent-session-sheet-store-5Azq2b1n.js";var s=e(t(),1),c=n(),l=(0,s.lazy)(()=>i(()=>import(`./agent-session-window-content-Dg07wugC.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,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117])));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-Ca7SCG6W.js","assets/rolldown-runtime-C5c2KzVm.js","assets/vendor-ui-BQzUk4nq.js","assets/vendor-markdown-26eoXJk7.js","assets/button-CtdEWN7U.js","assets/utils-DMiycH3O.js","assets/libesm-B_LCqxF2.js","assets/api-client-DSCscZEd.js","assets/open-ppm-tab-d8_3ai-M.js","assets/settings-store-DirmJxtu.js","assets/preload-helper-uTix4PVD.js","assets/react-BH62_kP1.js","assets/settings-events-BzBnHQWJ.js","assets/window-store-Bl6ySrZZ.js","assets/minimal-mode-DDuML1Oi.js","assets/file-browser-locate-C6ckBRTU.js","assets/use-explorer-open-state-xgkY0uH0.js","assets/use-is-mobile-CrfIt67b.js","assets/panel-store-B5zTGca0.js","assets/session-list-sync-triggers-_I5gGBSe.js","assets/project-store-BaGmhKos.js","assets/project-framework-store-vI8djw4a.js","assets/vault-Q5oPy0h3.js","assets/open-assistant-uhdReWoG.js","assets/patch-tab-metadata-DzBKXZ8Z.js","assets/assistant-settings-tab-store-BFJ4pM3_.js","assets/settings-categories-B_629iML.js","assets/icons-CpR5Vw3J.js","assets/open-settings-CGqVSUo5.js","assets/tab-store-CdpGgbmw.js","assets/design-tab-metadata-o2TAAwEt.js","assets/chat-jump-store-BzDl2wpf.js","assets/vault-focus-store-BYABW4-C.js","assets/assistant-managers-DBFW4Vy_.js","assets/assistant-persona-CiWkGBFh.js","assets/assistant-settings-changes-client-yYOd0NDP.js","assets/assistant-settings-api-DvAT6QKt.js","assets/tool-cards-BMN3VW6q.js","assets/index-BcmsW6J_.js","assets/createLucideIcon-nOpXneg9.js","assets/extension-icons-BSSI8zJe.js","assets/git-commit-horizontal-BJpjDb3H.js","assets/assistant-settings-B17q1iTi.js","assets/assistant-digest-XqNJJf0c.js","assets/assistant-settings-dialog-DrNk9cLn.js","assets/feature-intros-BNK1hj-A.js","assets/session-collab-BD1AwcUC.js","assets/dialog-BWXzvHlC.js","assets/portal-container-context-C84rlnJ6.js","assets/mobile-bottom-sheet-C78UMLrn.js","assets/use-visual-viewport-tMLO63yY.js","assets/open-db-tabs-SyNM2EhJ.js","assets/explorer-model-CMB2DLaE.js","assets/db-connection-config-DKVbmtru.js","assets/db-types-C1hMYmOv.js","assets/db-sidebar-reveal-DT3XJ69t.js","assets/db-drivers-BIKN5HLb.js","assets/impexp-state-HsrqffES.js","assets/design-canvas-check-DAc84j07.js","assets/model-thinking-selector-helpers-CSb4sOPu.js","assets/input-CCVoN0-P.js","assets/file-store-DvNGR1CA.js","assets/slash-command-picker-xIZbJS-p.js","assets/build-message-with-attachments-CQod0B6Y.js","assets/task-format-BZIV3kD8.js","assets/open-task-C-XSSORs.js","assets/use-manager-chats-7IXu1wX5.js","assets/open-chat-session-B8FHbA1S.js","assets/open-chat-in-window-v7025zeE.js","assets/clipboard-DQuoK2EM.js","assets/ppm-tools-D46CufEw.js","assets/db-ai-tools-x8SPCTHe.js","assets/split-sql-statements-0B9v-kNm.js","assets/tab-open-protocol-D5UyfEsm.js","assets/user-message-parse-DG85Nt5-.js","assets/voice-message-CNThCsr3.js","assets/set-manager-chat-dialog-CZm1uMTC.js","assets/provider-selector-CpYLloT9.js","assets/chat-preparation-cache-D6KJ1ZMi.js","assets/provider-logos-zWlJBGXd.js","assets/use-coarse-long-press-r69G14r1.js","assets/task-chip-peek-dtuuhUxI.js","assets/task-links-card-D4IzxjS0.js","assets/dropdown-menu-DMZtzfk5.js","assets/radio-dot-UO7SfziL.js","assets/control-size-DFdAJqoq.js","assets/adaptive-context-menu-BY4ki-EE.js","assets/start-ellipsis-BQ0FJowG.js","assets/tooltip-CECVgROB.js","assets/use-voice-message-recorder-BxjLFY10.js","assets/api-settings-DOq_SIAU.js","assets/format-date-E9rSy4Po.js","assets/image-gallery-BvIkGPUA.js","assets/session-collab-client-BxXx812Z.js","assets/send-to-chat-Saa9Tfu2.js","assets/notification-store-hHQ6I1WT.js","assets/unsaved-grid-rows-store-DKZSxIbb.js","assets/sql-identifiers-D62yiJWh.js","assets/db-explorer-store-Bzw8bf2f.js","assets/format-file-meta-B4qeznFu.js","assets/fs-api-COsHlRxJ.js","assets/scroll-area-DKwnCaCu.js","assets/use-git-repo-BjCnSkJ0.js","assets/git-repo-store-BCgyxqGc.js","assets/use-schedules-b8L8CH0W.js","assets/file-icons-wTYRmxJu.js","assets/global-ws-channel-C7BkbuOy.js","assets/ws-auth-BoXvat-e.js","assets/streaming-store-Dq4AjFuk.js","assets/apply-theme-BeLRfsSu.js","assets/resolve-theme-BHAgAaFk.js","assets/index-BrxyfrYc.css","assets/vault-tool-call-DSMwzVDz.js","assets/agent-session-sheet-store-5Azq2b1n.js","assets/image-preview-geometry-BGYjT5qH.js","assets/markdown-context-yGQ4E4_7.js","assets/use-blob-url-CoPtAkb7.js","assets/html-preview-loads-BsMjOwLP.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-26eoXJk7.js";import"./vendor-ui-BQzUk4nq.js";import{pi as r}from"./icons-CpR5Vw3J.js";import{t as i}from"./preload-helper-uTix4PVD.js";import"./portal-container-context-C84rlnJ6.js";import{t as a}from"./mobile-bottom-sheet-C78UMLrn.js";import"./use-visual-viewport-tMLO63yY.js";import{t as o}from"./agent-session-sheet-store-5Azq2b1n.js";var s=e(t(),1),c=n(),l=(0,s.lazy)(()=>i(()=>import(`./agent-session-window-content-Ca7SCG6W.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,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117])));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-DirmJxtu.js";import{D as t,E as n}from"./vendor-markdown-26eoXJk7.js";import"./vendor-ui-BQzUk4nq.js";import{F as r,R as i,Sn as a}from"./icons-CpR5Vw3J.js";import{y as o}from"./api-client-DSCscZEd.js";import{n as s}from"./utils-DMiycH3O.js";import"./portal-container-context-C84rlnJ6.js";import"./window-store-Bl6ySrZZ.js";import"./panel-store-B5zTGca0.js";import"./project-store-BaGmhKos.js";import"./project-framework-store-vI8djw4a.js";import"./session-list-sync-triggers-_I5gGBSe.js";import"./tab-store-CdpGgbmw.js";import"./mobile-bottom-sheet-C78UMLrn.js";import"./use-visual-viewport-tMLO63yY.js";import{n as c}from"./use-coarse-long-press-r69G14r1.js";import"./chat-jump-store-BzDl2wpf.js";import"./use-is-mobile-CrfIt67b.js";import"./settings-categories-B_629iML.js";import"./open-settings-CGqVSUo5.js";import"./patch-tab-metadata-DzBKXZ8Z.js";import"./open-assistant-uhdReWoG.js";import"./open-ppm-tab-d8_3ai-M.js";import"./vault-Q5oPy0h3.js";import"./assistant-settings-tab-store-BFJ4pM3_.js";import"./vault-focus-store-BYABW4-C.js";import"./file-browser-locate-C6ckBRTU.js";import"./use-explorer-open-state-xgkY0uH0.js";import"./open-chat-session-B8FHbA1S.js";import"./open-chat-in-window-v7025zeE.js";import"./session-collab-client-BxXx812Z.js";import"./session-collab-BD1AwcUC.js";import"./assistant-managers-DBFW4Vy_.js";import"./use-manager-chats-7IXu1wX5.js";import"./radio-dot-UO7SfziL.js";import"./notification-store-hHQ6I1WT.js";import"./button-CtdEWN7U.js";import"./chat-preparation-cache-D6KJ1ZMi.js";import"./provider-logos-zWlJBGXd.js";import"./provider-selector-CpYLloT9.js";import"./file-store-DvNGR1CA.js";import"./streaming-store-Dq4AjFuk.js";import"./open-task-C-XSSORs.js";import"./dropdown-menu-DMZtzfk5.js";import"./fs-api-COsHlRxJ.js";import"./task-format-BZIV3kD8.js";import"./control-size-DFdAJqoq.js";import"./assistant-persona-CiWkGBFh.js";import"./assistant-settings-api-DvAT6QKt.js";import{n as l,r as u}from"./global-ws-channel-C7BkbuOy.js";import"./task-chip-peek-dtuuhUxI.js";import"./image-gallery-BvIkGPUA.js";import"./design-canvas-check-DAc84j07.js";import"./tab-open-protocol-D5UyfEsm.js";import"./task-links-card-D4IzxjS0.js";import{a as d,i as f,t as p,v as m}from"./tool-cards-ByfYqVsL.js";import"./libesm-B_LCqxF2.js";import{t as h}from"./markdown-context-yGQ4E4_7.js";import"./vault-tool-call-DSMwzVDz.js";import"./use-blob-url-CoPtAkb7.js";import"./assistant-settings-changes-client-yYOd0NDP.js";import"./agent-session-sheet-store-5Azq2b1n.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?f(t.sessionId,t.source):``,l=d(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:m(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)(r,{className:`size-3`}):(0,x.jsx)(i,{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)(p,{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-DirmJxtu.js";import{D as t,E as n}from"./vendor-markdown-26eoXJk7.js";import"./vendor-ui-BQzUk4nq.js";import{F as r,R as i,Sn as a}from"./icons-CpR5Vw3J.js";import{y as o}from"./api-client-DSCscZEd.js";import{n as s}from"./utils-DMiycH3O.js";import"./portal-container-context-C84rlnJ6.js";import"./window-store-Bl6ySrZZ.js";import"./panel-store-B5zTGca0.js";import"./project-store-BaGmhKos.js";import"./project-framework-store-vI8djw4a.js";import"./session-list-sync-triggers-_I5gGBSe.js";import"./tab-store-CdpGgbmw.js";import"./mobile-bottom-sheet-C78UMLrn.js";import"./use-visual-viewport-tMLO63yY.js";import{n as c}from"./use-coarse-long-press-r69G14r1.js";import"./chat-jump-store-BzDl2wpf.js";import"./use-is-mobile-CrfIt67b.js";import"./settings-categories-B_629iML.js";import"./open-settings-CGqVSUo5.js";import"./patch-tab-metadata-DzBKXZ8Z.js";import"./open-assistant-uhdReWoG.js";import"./open-ppm-tab-d8_3ai-M.js";import"./vault-Q5oPy0h3.js";import"./assistant-settings-tab-store-BFJ4pM3_.js";import"./vault-focus-store-BYABW4-C.js";import"./file-browser-locate-C6ckBRTU.js";import"./use-explorer-open-state-xgkY0uH0.js";import"./open-chat-session-B8FHbA1S.js";import"./open-chat-in-window-v7025zeE.js";import"./session-collab-client-BxXx812Z.js";import"./session-collab-BD1AwcUC.js";import"./assistant-managers-DBFW4Vy_.js";import"./use-manager-chats-7IXu1wX5.js";import"./radio-dot-UO7SfziL.js";import"./notification-store-hHQ6I1WT.js";import"./button-CtdEWN7U.js";import"./chat-preparation-cache-D6KJ1ZMi.js";import"./provider-logos-zWlJBGXd.js";import"./provider-selector-CpYLloT9.js";import"./file-store-DvNGR1CA.js";import"./streaming-store-Dq4AjFuk.js";import"./open-task-C-XSSORs.js";import"./dropdown-menu-DMZtzfk5.js";import"./fs-api-COsHlRxJ.js";import"./task-format-BZIV3kD8.js";import"./control-size-DFdAJqoq.js";import"./assistant-persona-CiWkGBFh.js";import"./assistant-settings-api-DvAT6QKt.js";import{n as l,r as u}from"./global-ws-channel-C7BkbuOy.js";import"./task-chip-peek-dtuuhUxI.js";import"./image-gallery-BvIkGPUA.js";import"./design-canvas-check-DAc84j07.js";import"./tab-open-protocol-D5UyfEsm.js";import"./task-links-card-D4IzxjS0.js";import{a as d,i as f,t as p,v as m}from"./tool-cards-BMN3VW6q.js";import"./libesm-B_LCqxF2.js";import{t as h}from"./markdown-context-yGQ4E4_7.js";import"./vault-tool-call-DSMwzVDz.js";import"./use-blob-url-CoPtAkb7.js";import"./assistant-settings-changes-client-yYOd0NDP.js";import"./agent-session-sheet-store-5Azq2b1n.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?f(t.sessionId,t.source):``,l=d(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:m(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)(r,{className:`size-3`}):(0,x.jsx)(i,{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)(p,{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-DirmJxtu.js";import{D as t,E as n}from"./vendor-markdown-26eoXJk7.js";import"./vendor-ui-BQzUk4nq.js";import{$r as r,Sn as i,br as a,r as o,wn as s}from"./icons-CpR5Vw3J.js";import{j as c}from"./api-client-DSCscZEd.js";import{n as l}from"./utils-DMiycH3O.js";import{Gn as u,Hn as d,J as f,Kn as p,Un as m,Wn as h,q as g}from"./index-ix3m5QQT.js";import{t as _}from"./use-monaco-theme-BQ-OZWX-.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 p(t,e,T),k(e),D(e),c.success(`Saved`),h.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)(r,{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)(i,{className:`size-3.5 animate-spin`}):(0,y.jsx)(a,{className:`size-3.5`}),` Save`]})]})]}),S&&(0,y.jsx)(x,{icon:s,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:o,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)(i,{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)(f,{beforeMount:g,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-DirmJxtu.js";import{D as t,E as n}from"./vendor-markdown-26eoXJk7.js";import"./vendor-ui-BQzUk4nq.js";import{$r as r,Sn as i,br as a,r as o,wn as s}from"./icons-CpR5Vw3J.js";import{j as c}from"./api-client-DSCscZEd.js";import{n as l}from"./utils-DMiycH3O.js";import{Gn as u,Hn as d,J as f,Kn as p,Un as m,Wn as h,q as g}from"./index-BcmsW6J_.js";import{t as _}from"./use-monaco-theme-BsFzXkdm.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 p(t,e,T),k(e),D(e),c.success(`Saved`),h.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)(r,{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)(i,{className:`size-3.5 animate-spin`}):(0,y.jsx)(a,{className:`size-3.5`}),` Save`]})]})]}),S&&(0,y.jsx)(x,{icon:s,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:o,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)(i,{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)(f,{beforeMount:g,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 +1 @@
1
- import"./settings-store-DirmJxtu.js";import"./vendor-markdown-26eoXJk7.js";import"./vendor-ui-BQzUk4nq.js";import"./icons-CpR5Vw3J.js";import"./api-client-DSCscZEd.js";import"./portal-container-context-C84rlnJ6.js";import"./window-store-Bl6ySrZZ.js";import"./panel-store-B5zTGca0.js";import"./project-store-BaGmhKos.js";import"./project-framework-store-vI8djw4a.js";import"./session-list-sync-triggers-_I5gGBSe.js";import"./tab-store-CdpGgbmw.js";import"./mobile-bottom-sheet-C78UMLrn.js";import"./use-visual-viewport-tMLO63yY.js";import"./use-is-mobile-CrfIt67b.js";import"./settings-categories-B_629iML.js";import"./open-settings-CGqVSUo5.js";import"./button-CtdEWN7U.js";import"./dialog-BWXzvHlC.js";import"./chat-preparation-cache-D6KJ1ZMi.js";import"./provider-logos-zWlJBGXd.js";import"./provider-selector-CpYLloT9.js";import"./input-CCVoN0-P.js";import"./model-thinking-selector-helpers-CSb4sOPu.js";import"./api-settings-DOq_SIAU.js";import{t as e}from"./ai-settings-section-D4V29bTK.js";export{e as AISettingsSection};
1
+ import"./settings-store-DirmJxtu.js";import"./vendor-markdown-26eoXJk7.js";import"./vendor-ui-BQzUk4nq.js";import"./icons-CpR5Vw3J.js";import"./api-client-DSCscZEd.js";import"./portal-container-context-C84rlnJ6.js";import"./window-store-Bl6ySrZZ.js";import"./panel-store-B5zTGca0.js";import"./project-store-BaGmhKos.js";import"./project-framework-store-vI8djw4a.js";import"./session-list-sync-triggers-_I5gGBSe.js";import"./tab-store-CdpGgbmw.js";import"./mobile-bottom-sheet-C78UMLrn.js";import"./use-visual-viewport-tMLO63yY.js";import"./use-is-mobile-CrfIt67b.js";import"./settings-categories-B_629iML.js";import"./open-settings-CGqVSUo5.js";import"./button-CtdEWN7U.js";import"./dialog-BWXzvHlC.js";import"./chat-preparation-cache-D6KJ1ZMi.js";import"./provider-logos-zWlJBGXd.js";import"./provider-selector-CpYLloT9.js";import"./input-CCVoN0-P.js";import"./model-thinking-selector-helpers-CSb4sOPu.js";import"./api-settings-DOq_SIAU.js";import{t as e}from"./ai-settings-section-CnkPwVLU.js";export{e as AISettingsSection};