@hienlh/ppm 0.26.39 → 0.26.41

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 (683) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/CLAUDE.md +1 -1
  3. package/assets/skills/ppm/SKILL.md +1 -1
  4. package/assets/skills/ppm/references/http-api.md +4 -1
  5. package/dist/web/assets/{accounts-settings-section-DEVh1ZH4.js → accounts-settings-section-DQ63-z3j.js} +1 -1
  6. package/dist/web/assets/accounts-settings-section-DQ63-z3j.js.br +0 -0
  7. package/dist/web/assets/accounts-settings-section-DQ63-z3j.js.gz +0 -0
  8. package/dist/web/assets/{agent-session-sheet-9C3OBt-T.js → agent-session-sheet-B_UZE28a.js} +2 -2
  9. package/dist/web/assets/agent-session-sheet-B_UZE28a.js.br +0 -0
  10. package/dist/web/assets/agent-session-sheet-B_UZE28a.js.gz +0 -0
  11. package/dist/web/assets/{agent-session-window-content-DQDQ5SGw.js → agent-session-window-content-CaFQViPK.js} +1 -1
  12. package/dist/web/assets/agent-session-window-content-CaFQViPK.js.br +0 -0
  13. package/dist/web/assets/agent-session-window-content-CaFQViPK.js.gz +0 -0
  14. package/dist/web/assets/{ai-resource-editor-DtvnVBCa.js → ai-resource-editor-7vq5Se1D.js} +1 -1
  15. package/dist/web/assets/ai-resource-editor-7vq5Se1D.js.br +0 -0
  16. package/dist/web/assets/ai-resource-editor-7vq5Se1D.js.gz +0 -0
  17. package/dist/web/assets/{ai-settings-section-CFXkVNdm.js → ai-settings-section-V0gc3BHi.js} +1 -1
  18. package/dist/web/assets/ai-settings-section-V0gc3BHi.js.br +0 -0
  19. package/dist/web/assets/ai-settings-section-V0gc3BHi.js.gz +0 -0
  20. package/dist/web/assets/{ai-settings-section-Bb8OIV3w.js → ai-settings-section-hKF3ynbM.js} +1 -1
  21. package/dist/web/assets/ai-settings-section-hKF3ynbM.js.br +0 -0
  22. package/dist/web/assets/ai-settings-section-hKF3ynbM.js.gz +0 -0
  23. package/dist/web/assets/{android-tab-BhyWQYkQ.js → android-tab-DvyizBxM.js} +1 -1
  24. package/dist/web/assets/android-tab-DvyizBxM.js.br +0 -0
  25. package/dist/web/assets/android-tab-DvyizBxM.js.gz +0 -0
  26. package/dist/web/assets/{antigravity-usage-view-BBuACANt.js → antigravity-usage-view-BXUaYGNj.js} +1 -1
  27. package/dist/web/assets/antigravity-usage-view-BXUaYGNj.js.br +0 -0
  28. package/dist/web/assets/antigravity-usage-view-BXUaYGNj.js.gz +0 -0
  29. package/dist/web/assets/{appearance-settings-section-D1co7CL_.js → appearance-settings-section-DbL1iD0c.js} +1 -1
  30. package/dist/web/assets/appearance-settings-section-DbL1iD0c.js.br +0 -0
  31. package/dist/web/assets/appearance-settings-section-DbL1iD0c.js.gz +0 -0
  32. package/dist/web/assets/{apps-panel-Cf9SxZRN.js → apps-panel-g9Cdmx1R.js} +1 -1
  33. package/dist/web/assets/apps-panel-g9Cdmx1R.js.br +0 -0
  34. package/dist/web/assets/apps-panel-g9Cdmx1R.js.gz +0 -0
  35. package/dist/web/assets/{assistant-settings-dialog-DrNk9cLn.js → assistant-settings-dialog-WD7-nag4.js} +1 -1
  36. package/dist/web/assets/assistant-settings-dialog-WD7-nag4.js.br +0 -0
  37. package/dist/web/assets/assistant-settings-dialog-WD7-nag4.js.gz +0 -0
  38. package/dist/web/assets/assistant-settings-section-td2Bmpbb.js +10 -0
  39. package/dist/web/assets/assistant-settings-section-td2Bmpbb.js.br +0 -0
  40. package/dist/web/assets/assistant-settings-section-td2Bmpbb.js.gz +0 -0
  41. package/dist/web/assets/{assistant-tab-DRmxXROI.js → assistant-tab-BOo4NPmN.js} +1 -1
  42. package/dist/web/assets/assistant-tab-BOo4NPmN.js.br +0 -0
  43. package/dist/web/assets/assistant-tab-BOo4NPmN.js.gz +0 -0
  44. package/dist/web/assets/{branch-review-tab-DwnbNz-c.js → branch-review-tab-DuAdJEgW.js} +1 -1
  45. package/dist/web/assets/branch-review-tab-DuAdJEgW.js.br +0 -0
  46. package/dist/web/assets/branch-review-tab-DuAdJEgW.js.gz +0 -0
  47. package/dist/web/assets/{build-message-with-attachments-CQod0B6Y.js → build-message-with-attachments-Dcfq8TCF.js} +1 -1
  48. package/dist/web/assets/build-message-with-attachments-Dcfq8TCF.js.br +0 -0
  49. package/dist/web/assets/build-message-with-attachments-Dcfq8TCF.js.gz +0 -0
  50. package/dist/web/assets/{chat-tab-ialTEX9C.js → chat-tab-DGSG1nim.js} +1 -1
  51. package/dist/web/assets/chat-tab-DGSG1nim.js.br +0 -0
  52. package/dist/web/assets/chat-tab-DGSG1nim.js.gz +0 -0
  53. package/dist/web/assets/{chat-tab-DHRPMjw_.js → chat-tab-cTdIFhvy.js} +3 -3
  54. package/dist/web/assets/chat-tab-cTdIFhvy.js.br +0 -0
  55. package/dist/web/assets/chat-tab-cTdIFhvy.js.gz +0 -0
  56. package/dist/web/assets/{code-editor-pwODeLL1.js → code-editor-CMpzD-I7.js} +4 -4
  57. package/dist/web/assets/code-editor-CMpzD-I7.js.br +0 -0
  58. package/dist/web/assets/code-editor-CMpzD-I7.js.gz +0 -0
  59. package/dist/web/assets/{conflict-editor-w9BfRu3L.js → conflict-editor-BL11j1ee.js} +1 -1
  60. package/dist/web/assets/conflict-editor-BL11j1ee.js.br +0 -0
  61. package/dist/web/assets/conflict-editor-BL11j1ee.js.gz +0 -0
  62. package/dist/web/assets/{connection-form-tab-C88RVldZ.js → connection-form-tab-ZIHgNydL.js} +1 -1
  63. package/dist/web/assets/connection-form-tab-ZIHgNydL.js.br +0 -0
  64. package/dist/web/assets/connection-form-tab-ZIHgNydL.js.gz +0 -0
  65. package/dist/web/assets/{csv-preview-BbEwEDG2.js → csv-preview-DygPsrM9.js} +1 -1
  66. package/dist/web/assets/csv-preview-DygPsrM9.js.br +0 -0
  67. package/dist/web/assets/csv-preview-DygPsrM9.js.gz +0 -0
  68. package/dist/web/assets/{database-drivers-section-DhF0MJAC.js → database-drivers-section-1P05jOJS.js} +1 -1
  69. package/dist/web/assets/database-drivers-section-1P05jOJS.js.br +0 -0
  70. package/dist/web/assets/database-drivers-section-1P05jOJS.js.gz +0 -0
  71. package/dist/web/assets/{db-tab-parts-DgUIcsg3.js → db-tab-parts-CPweACc-.js} +1 -1
  72. package/dist/web/assets/db-tab-parts-CPweACc-.js.br +0 -0
  73. package/dist/web/assets/db-tab-parts-CPweACc-.js.gz +0 -0
  74. package/dist/web/assets/{design-settings-section-2eBuvhKD.js → design-settings-section-B13YpuJ0.js} +1 -1
  75. package/dist/web/assets/design-settings-section-B13YpuJ0.js.br +0 -0
  76. package/dist/web/assets/design-settings-section-B13YpuJ0.js.gz +0 -0
  77. package/dist/web/assets/{design-tab-qQwUJIlG.js → design-tab-DjP31-ys.js} +1 -1
  78. package/dist/web/assets/design-tab-DjP31-ys.js.br +0 -0
  79. package/dist/web/assets/design-tab-DjP31-ys.js.gz +0 -0
  80. package/dist/web/assets/{designs-sidebar-panel-Ldc_JjVI.js → designs-sidebar-panel-BOa2pnl1.js} +1 -1
  81. package/dist/web/assets/designs-sidebar-panel-BOa2pnl1.js.br +0 -0
  82. package/dist/web/assets/designs-sidebar-panel-BOa2pnl1.js.gz +0 -0
  83. package/dist/web/assets/{diff-viewer-Cwn9nnLR.js → diff-viewer-avrNPfrj.js} +1 -1
  84. package/dist/web/assets/diff-viewer-avrNPfrj.js.br +0 -0
  85. package/dist/web/assets/diff-viewer-avrNPfrj.js.gz +0 -0
  86. package/dist/web/assets/{docx-preview-CNWvq51O.js → docx-preview-Bt-Nm-9S.js} +1 -1
  87. package/dist/web/assets/docx-preview-Bt-Nm-9S.js.br +0 -0
  88. package/dist/web/assets/docx-preview-Bt-Nm-9S.js.gz +0 -0
  89. package/dist/web/assets/{editor-dialog-Cjv5rT7t.js → editor-dialog-Bl5fkjzW.js} +1 -1
  90. package/dist/web/assets/editor-dialog-Bl5fkjzW.js.br +0 -0
  91. package/dist/web/assets/editor-dialog-Bl5fkjzW.js.gz +0 -0
  92. package/dist/web/assets/{editor-language-service-CSI7dq9B.js → editor-language-service-DIpL_WlY.js} +1 -1
  93. package/dist/web/assets/editor-language-service-DIpL_WlY.js.br +0 -0
  94. package/dist/web/assets/editor-language-service-DIpL_WlY.js.gz +0 -0
  95. package/dist/web/assets/{explorer-body-8aOV-5am.js → explorer-body-DZx0_utr.js} +1 -1
  96. package/dist/web/assets/explorer-body-DZx0_utr.js.br +0 -0
  97. package/dist/web/assets/explorer-body-DZx0_utr.js.gz +0 -0
  98. package/dist/web/assets/{explorer-window-content-DZ1uW1Yp.js → explorer-window-content-rQIQsbaL.js} +1 -1
  99. package/dist/web/assets/explorer-window-content-rQIQsbaL.js.br +0 -0
  100. package/dist/web/assets/explorer-window-content-rQIQsbaL.js.gz +0 -0
  101. package/dist/web/assets/{extension-manager-section-CymT0xOK.js → extension-manager-section-BNVrSI8U.js} +1 -1
  102. package/dist/web/assets/extension-manager-section-BNVrSI8U.js.br +0 -0
  103. package/dist/web/assets/extension-manager-section-BNVrSI8U.js.gz +0 -0
  104. package/dist/web/assets/{extension-webview-CQ06Ek8l.js → extension-webview-CkF7DEDh.js} +1 -1
  105. package/dist/web/assets/extension-webview-CkF7DEDh.js.br +0 -0
  106. package/dist/web/assets/extension-webview-CkF7DEDh.js.gz +0 -0
  107. package/dist/web/assets/{feature-intros-BNK1hj-A.js → feature-intros-CHJ2c-NE.js} +1 -1
  108. package/dist/web/assets/feature-intros-CHJ2c-NE.js.br +0 -0
  109. package/dist/web/assets/feature-intros-CHJ2c-NE.js.gz +0 -0
  110. package/dist/web/assets/{files-settings-section-C7IcwRur.js → files-settings-section-CMT9bJYE.js} +1 -1
  111. package/dist/web/assets/files-settings-section-CMT9bJYE.js.br +0 -0
  112. package/dist/web/assets/files-settings-section-CMT9bJYE.js.gz +0 -0
  113. package/dist/web/assets/{general-settings-section-D1RMy1aw.js → general-settings-section-DoBDWvVA.js} +1 -1
  114. package/dist/web/assets/general-settings-section-DoBDWvVA.js.br +0 -0
  115. package/dist/web/assets/general-settings-section-DoBDWvVA.js.gz +0 -0
  116. package/dist/web/assets/{git-log-panel-CfulXvdX.js → git-log-panel-CEEN0Hl8.js} +1 -1
  117. package/dist/web/assets/git-log-panel-CEEN0Hl8.js.br +0 -0
  118. package/dist/web/assets/git-log-panel-CEEN0Hl8.js.gz +0 -0
  119. package/dist/web/assets/{git-review-tab-CwmTIYPS.js → git-review-tab-CxVKLu-M.js} +1 -1
  120. package/dist/web/assets/git-review-tab-CxVKLu-M.js.br +0 -0
  121. package/dist/web/assets/git-review-tab-CxVKLu-M.js.gz +0 -0
  122. package/dist/web/assets/{glide-data-grid-BQab_Ysc.js → glide-data-grid-C0yMf2WR.js} +1 -1
  123. package/dist/web/assets/glide-data-grid-C0yMf2WR.js.br +0 -0
  124. package/dist/web/assets/glide-data-grid-C0yMf2WR.js.gz +0 -0
  125. package/dist/web/assets/{grid-save-dialog-BoPDFh_R.js → grid-save-dialog-B5_4eJa1.js} +1 -1
  126. package/dist/web/assets/grid-save-dialog-B5_4eJa1.js.br +0 -0
  127. package/dist/web/assets/grid-save-dialog-B5_4eJa1.js.gz +0 -0
  128. package/dist/web/assets/{group-chat-tab-BctxtC_y.js → group-chat-tab--_N-9ZKm.js} +1 -1
  129. package/dist/web/assets/group-chat-tab--_N-9ZKm.js.br +0 -0
  130. package/dist/web/assets/group-chat-tab--_N-9ZKm.js.gz +0 -0
  131. package/dist/web/assets/{impexp-tab-CtuAWcJC.js → impexp-tab-84l4S5fB.js} +1 -1
  132. package/dist/web/assets/impexp-tab-84l4S5fB.js.br +0 -0
  133. package/dist/web/assets/impexp-tab-84l4S5fB.js.gz +0 -0
  134. package/dist/web/assets/{index-HeDx2wIm.js → index-CToe9paM.js} +21 -21
  135. package/dist/web/assets/index-CToe9paM.js.br +0 -0
  136. package/dist/web/assets/index-CToe9paM.js.gz +0 -0
  137. package/dist/web/assets/index-D1toZxbF.css +1 -0
  138. package/dist/web/assets/index-D1toZxbF.css.br +0 -0
  139. package/dist/web/assets/index-D1toZxbF.css.gz +0 -0
  140. package/dist/web/assets/{jira-watcher-section-DRD7Ro5I.js → jira-watcher-section-DLOy5seB.js} +1 -1
  141. package/dist/web/assets/{keybindings-store-DZPc-cwC.js → keybindings-store-LqldhMUV.js} +1 -1
  142. package/dist/web/assets/{keyboard-shortcuts-section-BqXoHt9o.js → keyboard-shortcuts-section-BU-fDxXe.js} +1 -1
  143. package/dist/web/assets/keyboard-shortcuts-section-BU-fDxXe.js.br +0 -0
  144. package/dist/web/assets/keyboard-shortcuts-section-BU-fDxXe.js.gz +0 -0
  145. package/dist/web/assets/{language-servers-section-Cno8kA1_.js → language-servers-section-RJDv8RC7.js} +2 -2
  146. package/dist/web/assets/language-servers-section-RJDv8RC7.js.br +0 -0
  147. package/dist/web/assets/language-servers-section-RJDv8RC7.js.gz +0 -0
  148. package/dist/web/assets/{logs-app-CLQhFZSL.js → logs-app-B3CiUaZo.js} +1 -1
  149. package/dist/web/assets/logs-app-B3CiUaZo.js.br +0 -0
  150. package/dist/web/assets/logs-app-B3CiUaZo.js.gz +0 -0
  151. package/dist/web/assets/{logs-tab-mhXuRLyP.js → logs-tab-mAggf0I1.js} +1 -1
  152. package/dist/web/assets/{logs-window-content-HSOdS0L_.js → logs-window-content-Byp_UkCH.js} +1 -1
  153. package/dist/web/assets/{lsp-client-BAOlua0N.js → lsp-client-CLe53SLT.js} +1 -1
  154. package/dist/web/assets/lsp-client-CLe53SLT.js.br +0 -0
  155. package/dist/web/assets/lsp-client-CLe53SLT.js.gz +0 -0
  156. package/dist/web/assets/{markdown-renderer-DdhsSmUW.js → markdown-renderer-CjBb-9-Y.js} +1 -1
  157. package/dist/web/assets/markdown-renderer-CjBb-9-Y.js.br +0 -0
  158. package/dist/web/assets/markdown-renderer-CjBb-9-Y.js.gz +0 -0
  159. package/dist/web/assets/{markdown-renderer-B7tE2qXK.js → markdown-renderer-DYZv454R.js} +1 -1
  160. package/dist/web/assets/markdown-renderer-DYZv454R.js.br +0 -0
  161. package/dist/web/assets/markdown-renderer-DYZv454R.js.gz +0 -0
  162. package/dist/web/assets/{mobile-explorer-sheet-wvVfQE0U.js → mobile-explorer-sheet-BqGwUNhS.js} +1 -1
  163. package/dist/web/assets/mobile-explorer-sheet-BqGwUNhS.js.br +0 -0
  164. package/dist/web/assets/mobile-explorer-sheet-BqGwUNhS.js.gz +0 -0
  165. package/dist/web/assets/{monaco-diff-editor-CvceRPyE.js → monaco-diff-editor--qXfeWZN.js} +1 -1
  166. package/dist/web/assets/{new-design-dialog-XZnj47LU.js → new-design-dialog-CtKXkYuy.js} +1 -1
  167. package/dist/web/assets/new-design-dialog-CtKXkYuy.js.br +0 -0
  168. package/dist/web/assets/new-design-dialog-CtKXkYuy.js.gz +0 -0
  169. package/dist/web/assets/{notifications-settings-section-C9lZf9KY.js → notifications-settings-section-DX5xQuXT.js} +1 -1
  170. package/dist/web/assets/notifications-settings-section-DX5xQuXT.js.br +0 -0
  171. package/dist/web/assets/notifications-settings-section-DX5xQuXT.js.gz +0 -0
  172. package/dist/web/assets/{onboarding-entry-DaGjZ-08.js → onboarding-entry-CTeUblCQ.js} +1 -1
  173. package/dist/web/assets/onboarding-entry-CTeUblCQ.js.br +0 -0
  174. package/dist/web/assets/onboarding-entry-CTeUblCQ.js.gz +0 -0
  175. package/dist/web/assets/{open-manager-chat-oqMHXX1k.js → open-manager-chat-CJjHfOJa.js} +1 -1
  176. package/dist/web/assets/open-manager-chat-CJjHfOJa.js.br +0 -0
  177. package/dist/web/assets/open-manager-chat-CJjHfOJa.js.gz +0 -0
  178. package/dist/web/assets/{open-manager-chat-DVuYNkNx.js → open-manager-chat-D8ezNjyv.js} +1 -1
  179. package/dist/web/assets/open-manager-chat-D8ezNjyv.js.br +0 -0
  180. package/dist/web/assets/open-manager-chat-D8ezNjyv.js.gz +0 -0
  181. package/dist/web/assets/{ppm-tools-D46CufEw.js → ppm-tools-Bpl4lgH9.js} +1 -1
  182. package/dist/web/assets/{problems-panel-BZruxGUk.js → problems-panel-GqJ_ZBjK.js} +1 -1
  183. package/dist/web/assets/problems-panel-GqJ_ZBjK.js.br +0 -0
  184. package/dist/web/assets/problems-panel-GqJ_ZBjK.js.gz +0 -0
  185. package/dist/web/assets/{process-table-DK7lMU7-.js → process-table-BsYgs4j7.js} +1 -1
  186. package/dist/web/assets/process-table-BsYgs4j7.js.br +0 -0
  187. package/dist/web/assets/process-table-BsYgs4j7.js.gz +0 -0
  188. package/dist/web/assets/{proxy-settings-section-SC3IJuac.js → proxy-settings-section-D0VAC8yd.js} +1 -1
  189. package/dist/web/assets/proxy-settings-section-D0VAC8yd.js.br +0 -0
  190. package/dist/web/assets/proxy-settings-section-D0VAC8yd.js.gz +0 -0
  191. package/dist/web/assets/{query-tab-198wSDy4.js → query-tab-8ygY98D5.js} +1 -1
  192. package/dist/web/assets/query-tab-8ygY98D5.js.br +0 -0
  193. package/dist/web/assets/query-tab-8ygY98D5.js.gz +0 -0
  194. package/dist/web/assets/{release-notes-window-content-DyCvvwaM.js → release-notes-window-content-D_dO3Pjk.js} +1 -1
  195. package/dist/web/assets/{remembered-approvals-section-CTGnu4UB.js → remembered-approvals-section-0BSREd9X.js} +1 -1
  196. package/dist/web/assets/remembered-approvals-section-0BSREd9X.js.br +0 -0
  197. package/dist/web/assets/remembered-approvals-section-0BSREd9X.js.gz +0 -0
  198. package/dist/web/assets/{remote-access-settings-section-QAPYQO40.js → remote-access-settings-section-C45YSmLE.js} +1 -1
  199. package/dist/web/assets/remote-access-settings-section-C45YSmLE.js.br +0 -0
  200. package/dist/web/assets/remote-access-settings-section-C45YSmLE.js.gz +0 -0
  201. package/dist/web/assets/remote-desktop-clipboard-notice-DiszI66Q.js +1 -0
  202. package/dist/web/assets/remote-desktop-clipboard-notice-DiszI66Q.js.br +0 -0
  203. package/dist/web/assets/remote-desktop-clipboard-notice-DiszI66Q.js.gz +0 -0
  204. package/dist/web/assets/{remote-desktop-mobile-sheet-BeA-aSeF.js → remote-desktop-mobile-sheet-BAQO7eaT.js} +2 -2
  205. package/dist/web/assets/remote-desktop-mobile-sheet-BAQO7eaT.js.br +0 -0
  206. package/dist/web/assets/remote-desktop-mobile-sheet-BAQO7eaT.js.gz +0 -0
  207. package/dist/web/assets/remote-desktop-mobile-view-Clkko7So.js +1 -0
  208. package/dist/web/assets/remote-desktop-mobile-view-Clkko7So.js.br +0 -0
  209. package/dist/web/assets/remote-desktop-mobile-view-Clkko7So.js.gz +0 -0
  210. package/dist/web/assets/remote-desktop-readiness-gate-CgE2Rxsr.js +1 -0
  211. package/dist/web/assets/remote-desktop-readiness-gate-CgE2Rxsr.js.br +0 -0
  212. package/dist/web/assets/remote-desktop-readiness-gate-CgE2Rxsr.js.gz +0 -0
  213. package/dist/web/assets/remote-desktop-settings-section-CjOzlNg4.js +1 -0
  214. package/dist/web/assets/remote-desktop-settings-section-CjOzlNg4.js.br +0 -0
  215. package/dist/web/assets/remote-desktop-settings-section-CjOzlNg4.js.gz +0 -0
  216. package/dist/web/assets/remote-desktop-window-content-Ck8Jle_R.js +1 -0
  217. package/dist/web/assets/remote-desktop-window-content-Ck8Jle_R.js.br +0 -0
  218. package/dist/web/assets/remote-desktop-window-content-Ck8Jle_R.js.gz +0 -0
  219. package/dist/web/assets/{rename-object-dialog-Cm2fs1fN.js → rename-object-dialog-eeQ3Ry3F.js} +1 -1
  220. package/dist/web/assets/rename-object-dialog-eeQ3Ry3F.js.br +0 -0
  221. package/dist/web/assets/rename-object-dialog-eeQ3Ry3F.js.gz +0 -0
  222. package/dist/web/assets/{reveal-task-in-sidebar-BfCyTA3E.js → reveal-task-in-sidebar-DbDQfS5L.js} +1 -1
  223. package/dist/web/assets/{review-address-setup-B6Vjrz9r.js → review-address-setup-BIMTMFOp.js} +1 -1
  224. package/dist/web/assets/review-address-setup-BIMTMFOp.js.br +0 -0
  225. package/dist/web/assets/review-address-setup-BIMTMFOp.js.gz +0 -0
  226. package/dist/web/assets/{review-code-DcF_yOLk.js → review-code-DhZOgNP_.js} +1 -1
  227. package/dist/web/assets/review-code-DhZOgNP_.js.br +0 -0
  228. package/dist/web/assets/review-code-DhZOgNP_.js.gz +0 -0
  229. package/dist/web/assets/{save-as-dialog-DOOsO36V.js → save-as-dialog-BxuXI-0b.js} +1 -1
  230. package/dist/web/assets/save-as-dialog-BxuXI-0b.js.br +0 -0
  231. package/dist/web/assets/save-as-dialog-BxuXI-0b.js.gz +0 -0
  232. package/dist/web/assets/{schedule-form-ZjricDBe.js → schedule-form-DDgcBzJB.js} +3 -3
  233. package/dist/web/assets/schedule-form-DDgcBzJB.js.br +0 -0
  234. package/dist/web/assets/schedule-form-DDgcBzJB.js.gz +0 -0
  235. package/dist/web/assets/{schedule-script-editor-DS07jjvr.js → schedule-script-editor-rFq5PB24.js} +1 -1
  236. package/dist/web/assets/schedule-script-editor-rFq5PB24.js.br +0 -0
  237. package/dist/web/assets/schedule-script-editor-rFq5PB24.js.gz +0 -0
  238. package/dist/web/assets/{schedules-app-pErYGky8.js → schedules-app-BrkzKe8d.js} +1 -1
  239. package/dist/web/assets/schedules-app-BrkzKe8d.js.br +0 -0
  240. package/dist/web/assets/schedules-app-BrkzKe8d.js.gz +0 -0
  241. package/dist/web/assets/{schedules-settings-section-BIyYLM7y.js → schedules-settings-section-P801rm0Q.js} +3 -3
  242. package/dist/web/assets/schedules-settings-section-P801rm0Q.js.br +0 -0
  243. package/dist/web/assets/schedules-settings-section-P801rm0Q.js.gz +0 -0
  244. package/dist/web/assets/{schedules-tab-C4MzSQjn.js → schedules-tab-BnneDXN3.js} +1 -1
  245. package/dist/web/assets/schedules-tab-BnneDXN3.js.br +0 -0
  246. package/dist/web/assets/schedules-tab-BnneDXN3.js.gz +0 -0
  247. package/dist/web/assets/{schedules-ui-DR65Kkrm.js → schedules-ui-DnovuUgI.js} +1 -1
  248. package/dist/web/assets/schedules-ui-DnovuUgI.js.br +0 -0
  249. package/dist/web/assets/schedules-ui-DnovuUgI.js.gz +0 -0
  250. package/dist/web/assets/{schedules-window-content-klLV9bsT.js → schedules-window-content-D86LTMtU.js} +1 -1
  251. package/dist/web/assets/schedules-window-content-D86LTMtU.js.br +0 -0
  252. package/dist/web/assets/schedules-window-content-D86LTMtU.js.gz +0 -0
  253. package/dist/web/assets/{session-review-tab-MCN-NAOK.js → session-review-tab-N7N3m5Ia.js} +1 -1
  254. package/dist/web/assets/session-review-tab-N7N3m5Ia.js.br +0 -0
  255. package/dist/web/assets/session-review-tab-N7N3m5Ia.js.gz +0 -0
  256. package/dist/web/assets/{settings-body-CogOIdcd.js → settings-body-DXgWdp5L.js} +1 -1
  257. package/dist/web/assets/settings-body-DXgWdp5L.js.br +0 -0
  258. package/dist/web/assets/settings-body-DXgWdp5L.js.gz +0 -0
  259. package/dist/web/assets/{settings-rows-Fw0kZHvj.js → settings-rows-BnbnE7yp.js} +1 -1
  260. package/dist/web/assets/settings-rows-BnbnE7yp.js.br +0 -0
  261. package/dist/web/assets/settings-rows-BnbnE7yp.js.gz +0 -0
  262. package/dist/web/assets/settings-section-content-BvGekMGG.js +2 -0
  263. package/dist/web/assets/settings-section-content-BvGekMGG.js.br +0 -0
  264. package/dist/web/assets/settings-section-content-BvGekMGG.js.gz +0 -0
  265. package/dist/web/assets/{settings-section-content-DbntUh0w.js → settings-section-content-Sv2MuwGP.js} +1 -1
  266. package/dist/web/assets/{settings-tab-DXZt5tLn.js → settings-tab-X2U8nwEA.js} +1 -1
  267. package/dist/web/assets/{settings-window-content-CfxZcG68.js → settings-window-content-3Z7vlcY0.js} +1 -1
  268. package/dist/web/assets/{sql-object-tab-CI7kX6yl.js → sql-object-tab-Cxtq4UUD.js} +1 -1
  269. package/dist/web/assets/sql-object-tab-Cxtq4UUD.js.br +0 -0
  270. package/dist/web/assets/sql-object-tab-Cxtq4UUD.js.gz +0 -0
  271. package/dist/web/assets/{sqlite-viewer-B24YviWu.js → sqlite-viewer-In2COXL1.js} +1 -1
  272. package/dist/web/assets/sqlite-viewer-In2COXL1.js.br +0 -0
  273. package/dist/web/assets/sqlite-viewer-In2COXL1.js.gz +0 -0
  274. package/dist/web/assets/{storage-settings-section-DD5VJ_wA.js → storage-settings-section-D5Z66RLa.js} +1 -1
  275. package/dist/web/assets/storage-settings-section-D5Z66RLa.js.br +0 -0
  276. package/dist/web/assets/storage-settings-section-D5Z66RLa.js.gz +0 -0
  277. package/dist/web/assets/{structure-save-dialog-C5gBtT4a.js → structure-save-dialog-BpgXx5bc.js} +1 -1
  278. package/dist/web/assets/structure-save-dialog-BpgXx5bc.js.br +0 -0
  279. package/dist/web/assets/structure-save-dialog-BpgXx5bc.js.gz +0 -0
  280. package/dist/web/assets/{structure-tab-D04ISE5t.js → structure-tab-CrKg4mZv.js} +1 -1
  281. package/dist/web/assets/structure-tab-CrKg4mZv.js.br +0 -0
  282. package/dist/web/assets/structure-tab-CrKg4mZv.js.gz +0 -0
  283. package/dist/web/assets/{system-monitor-body-C0CTmM4H.js → system-monitor-body-BMOHavU-.js} +2 -2
  284. package/dist/web/assets/system-monitor-body-BMOHavU-.js.br +0 -0
  285. package/dist/web/assets/system-monitor-body-BMOHavU-.js.gz +0 -0
  286. package/dist/web/assets/{system-monitor-tab-9WjQpzfT.js → system-monitor-tab-CdabSuCr.js} +1 -1
  287. package/dist/web/assets/{system-monitor-window-content-BBjqBQJG.js → system-monitor-window-content-BPpT2gHn.js} +1 -1
  288. package/dist/web/assets/{tab-host-window-content-Drfdn_AL.js → tab-host-window-content-C-IzedFd.js} +1 -1
  289. package/dist/web/assets/tab-host-window-content-C-IzedFd.js.br +0 -0
  290. package/dist/web/assets/tab-host-window-content-C-IzedFd.js.gz +0 -0
  291. package/dist/web/assets/{table-tab-BemdDB86.js → table-tab-BgMLAJSd.js} +1 -1
  292. package/dist/web/assets/table-tab-BgMLAJSd.js.br +0 -0
  293. package/dist/web/assets/table-tab-BgMLAJSd.js.gz +0 -0
  294. package/dist/web/assets/{task-detail-mobile-Cg-aTvPs.js → task-detail-mobile-Dj4SwbIb.js} +1 -1
  295. package/dist/web/assets/task-detail-mobile-Dj4SwbIb.js.br +0 -0
  296. package/dist/web/assets/task-detail-mobile-Dj4SwbIb.js.gz +0 -0
  297. package/dist/web/assets/{task-sheet-Bt6RJkwp.js → task-sheet-DbrpZJYk.js} +1 -1
  298. package/dist/web/assets/task-sheet-DbrpZJYk.js.br +0 -0
  299. package/dist/web/assets/task-sheet-DbrpZJYk.js.gz +0 -0
  300. package/dist/web/assets/{task-status-grid-lgA1eYhJ.js → task-status-grid-CDB-h0MQ.js} +1 -1
  301. package/dist/web/assets/task-status-grid-CDB-h0MQ.js.br +0 -0
  302. package/dist/web/assets/task-status-grid-CDB-h0MQ.js.gz +0 -0
  303. package/dist/web/assets/{task-tab-DaNoD62w.js → task-tab-0ZayP3eM.js} +1 -1
  304. package/dist/web/assets/task-tab-0ZayP3eM.js.br +0 -0
  305. package/dist/web/assets/task-tab-0ZayP3eM.js.gz +0 -0
  306. package/dist/web/assets/{tasks-sidebar-panel-Cy6acEuS.js → tasks-sidebar-panel-CoytCObb.js} +1 -1
  307. package/dist/web/assets/tasks-sidebar-panel-CoytCObb.js.br +0 -0
  308. package/dist/web/assets/tasks-sidebar-panel-CoytCObb.js.gz +0 -0
  309. package/dist/web/assets/{telegram-bot-token-field-B2qx9Wrw.js → telegram-bot-token-field-D_Du0TCV.js} +1 -1
  310. package/dist/web/assets/telegram-bot-token-field-D_Du0TCV.js.br +0 -0
  311. package/dist/web/assets/telegram-bot-token-field-D_Du0TCV.js.gz +0 -0
  312. package/dist/web/assets/{terminal-tab-YUv1NIkW.js → terminal-tab-U1TCm4sd.js} +1 -1
  313. package/dist/web/assets/terminal-tab-U1TCm4sd.js.br +0 -0
  314. package/dist/web/assets/terminal-tab-U1TCm4sd.js.gz +0 -0
  315. package/dist/web/assets/{tool-cards-DUWj5RNK.js → tool-cards-C6d2_kWx.js} +3 -3
  316. package/dist/web/assets/tool-cards-C6d2_kWx.js.br +0 -0
  317. package/dist/web/assets/tool-cards-C6d2_kWx.js.gz +0 -0
  318. package/dist/web/assets/{tools-settings-section-DG3GUKxu.js → tools-settings-section-Bny7pj0V.js} +1 -1
  319. package/dist/web/assets/tools-settings-section-Bny7pj0V.js.br +0 -0
  320. package/dist/web/assets/tools-settings-section-Bny7pj0V.js.gz +0 -0
  321. package/dist/web/assets/{use-db-read-CFM7NqkD.js → use-db-read-DHbwHptB.js} +1 -1
  322. package/dist/web/assets/use-db-read-DHbwHptB.js.br +0 -0
  323. package/dist/web/assets/use-db-read-DHbwHptB.js.gz +0 -0
  324. package/dist/web/assets/{use-inline-blame-IeX8t-qC.js → use-inline-blame-DQnI-NzL.js} +1 -1
  325. package/dist/web/assets/use-inline-blame-DQnI-NzL.js.br +0 -0
  326. package/dist/web/assets/use-inline-blame-DQnI-NzL.js.gz +0 -0
  327. package/dist/web/assets/{use-lsp-B1Kx75hO.js → use-lsp-DHvpQJL1.js} +1 -1
  328. package/dist/web/assets/use-lsp-DHvpQJL1.js.br +0 -0
  329. package/dist/web/assets/use-lsp-DHvpQJL1.js.gz +0 -0
  330. package/dist/web/assets/{use-monaco-theme-6JvXyR9m.js → use-monaco-theme-B5TdBov8.js} +1 -1
  331. package/dist/web/assets/{use-process-kill-B8v1jodL.js → use-process-kill-DsqIf76y.js} +1 -1
  332. package/dist/web/assets/use-process-kill-DsqIf76y.js.br +0 -0
  333. package/dist/web/assets/use-process-kill-DsqIf76y.js.gz +0 -0
  334. package/dist/web/assets/{use-sql-schema-info-DNaKdydY.js → use-sql-schema-info-LzVYkqlF.js} +1 -1
  335. package/dist/web/assets/use-sql-schema-info-LzVYkqlF.js.br +0 -0
  336. package/dist/web/assets/use-sql-schema-info-LzVYkqlF.js.gz +0 -0
  337. package/dist/web/assets/{use-websocket-hejcKKI7.js → use-websocket-DXx2DGA6.js} +1 -1
  338. package/dist/web/assets/{vault-settings-section-rB1F_zDn.js → vault-settings-section-fr4abgU9.js} +1 -1
  339. package/dist/web/assets/vault-settings-section-fr4abgU9.js.br +0 -0
  340. package/dist/web/assets/vault-settings-section-fr4abgU9.js.gz +0 -0
  341. package/dist/web/assets/{voice-settings-section-DBWKoCdg.js → voice-settings-section-BU-LKUBY.js} +1 -1
  342. package/dist/web/assets/voice-settings-section-BU-LKUBY.js.br +0 -0
  343. package/dist/web/assets/voice-settings-section-BU-LKUBY.js.gz +0 -0
  344. package/dist/web/assets/{web-browser-settings-section-L3mQK6s9.js → web-browser-settings-section-BlToGssQ.js} +1 -1
  345. package/dist/web/assets/web-browser-settings-section-BlToGssQ.js.br +0 -0
  346. package/dist/web/assets/web-browser-settings-section-BlToGssQ.js.gz +0 -0
  347. package/dist/web/assets/{web-browser-tab-WpNykw-B.js → web-browser-tab-qT2WWIq9.js} +1 -1
  348. package/dist/web/assets/{web-browser-view-D5zQyqTr.js → web-browser-view-B-gt8lOz.js} +1 -1
  349. package/dist/web/assets/web-browser-view-B-gt8lOz.js.br +0 -0
  350. package/dist/web/assets/web-browser-view-B-gt8lOz.js.gz +0 -0
  351. package/dist/web/assets/{web-browser-window-content-CQ3lpUpT.js → web-browser-window-content-Dyr3cLTJ.js} +1 -1
  352. package/dist/web/assets/{web-preview-tab-d_zyKug-.js → web-preview-tab-O1XY_OOx.js} +1 -1
  353. package/dist/web/assets/web-preview-tab-O1XY_OOx.js.br +0 -0
  354. package/dist/web/assets/web-preview-tab-O1XY_OOx.js.gz +0 -0
  355. package/dist/web/assets/{xlsx-preview-wPPrZDIQ.js → xlsx-preview-ssJ6l4xo.js} +1 -1
  356. package/dist/web/assets/xlsx-preview-ssJ6l4xo.js.br +0 -0
  357. package/dist/web/assets/{xlsx-preview-wPPrZDIQ.js.gz → xlsx-preview-ssJ6l4xo.js.gz} +0 -0
  358. package/dist/web/index.html +6 -6
  359. package/dist/web/index.html.br +0 -0
  360. package/dist/web/index.html.gz +0 -0
  361. package/dist/web/sw.js +1 -1
  362. package/dist/web/sw.js.br +0 -0
  363. package/dist/web/sw.js.gz +0 -0
  364. package/docs/architecture/ppm-assistant.md +37 -1
  365. package/docs/project-overview-pdr.md +5 -5
  366. package/docs/project-roadmap.md +1 -1
  367. package/package.json +1 -1
  368. package/src/server/routes/remote-desktop.ts +50 -6
  369. package/src/server/routes/settings.ts +15 -14
  370. package/src/services/assistant-settings-tools/settings-catalog-ai.ts +4 -0
  371. package/src/services/assistant-telegram/assistant-telegram-actions.ts +14 -1
  372. package/src/services/assistant-telegram/assistant-telegram-button-codes.ts +10 -0
  373. package/src/services/assistant-telegram/assistant-telegram-card-kinds.ts +3 -0
  374. package/src/services/assistant-telegram/assistant-telegram-card-reminders.ts +28 -4
  375. package/src/services/assistant-telegram/assistant-telegram-cards-desk-draw.ts +163 -0
  376. package/src/services/assistant-telegram/assistant-telegram-cards-desk-reply.ts +45 -0
  377. package/src/services/assistant-telegram/assistant-telegram-cards-desk-store.ts +82 -0
  378. package/src/services/assistant-telegram/assistant-telegram-cards-desk.ts +431 -0
  379. package/src/services/assistant-telegram/assistant-telegram-cards.ts +37 -1
  380. package/src/services/assistant-telegram/assistant-telegram-commands.ts +9 -1
  381. package/src/services/assistant-telegram/assistant-telegram-db-notices.ts +29 -4
  382. package/src/services/assistant-telegram/assistant-telegram-inbound.ts +58 -1
  383. package/src/services/assistant-telegram/assistant-telegram-manager-cards.ts +82 -24
  384. package/src/services/assistant-telegram/assistant-telegram.service.ts +40 -7
  385. package/src/services/cloud-ws.service.ts +45 -28
  386. package/src/services/cloud.service.ts +32 -3
  387. package/src/services/db.service.ts +9 -1
  388. package/src/services/feature-intros.service.ts +12 -0
  389. package/src/services/notification.service.ts +0 -18
  390. package/src/services/peer-connections/peer-connections-db.ts +212 -0
  391. package/src/services/peer-connections/peer-connections-schema.ts +139 -0
  392. package/src/services/peer-connections/peer-crypto.ts +148 -0
  393. package/src/services/peer-connections/peer-envelope-codec.ts +111 -0
  394. package/src/services/peer-connections/peer-identity.ts +71 -0
  395. package/src/services/peer-connections/peer-inbox-db.ts +182 -0
  396. package/src/services/peer-connections/peer-invite-code.ts +159 -0
  397. package/src/services/peer-connections/peer-invites-db.ts +146 -0
  398. package/src/services/peer-connections/peer-key-store.ts +67 -0
  399. package/src/services/peer-connections/peer-outbox-db.ts +198 -0
  400. package/src/services/peer-connections/peer-pairing-keys.ts +111 -0
  401. package/src/services/peer-connections/peer-replay-guard.ts +94 -0
  402. package/src/services/peer-connections/peer-secret-file.ts +97 -0
  403. package/src/services/peer-connections/peer-transport-registry.ts +26 -0
  404. package/src/services/peer-connections/peer-transport.ts +29 -0
  405. package/src/services/remote-desktop/remote-desktop-capture-error.ts +38 -0
  406. package/src/services/remote-desktop/remote-desktop-displays-win32.ts +10 -0
  407. package/src/services/remote-desktop/remote-desktop-input-block.ts +98 -0
  408. package/src/services/remote-desktop/remote-desktop-input-win32.ts +18 -9
  409. package/src/services/remote-desktop/remote-desktop-requirements.ts +41 -6
  410. package/src/services/remote-desktop/remote-desktop-session.ts +36 -2
  411. package/src/services/remote-desktop/remote-desktop-win32-host.ts +150 -0
  412. package/src/services/remote-desktop/remote-desktop-win32-integrity.ts +117 -0
  413. package/src/services/remote-desktop/remote-desktop-win32-session-row.ts +97 -0
  414. package/src/services/remote-desktop/remote-desktop-win32-session.ts +98 -0
  415. package/src/services/remote-desktop/win32-helper/hardware-monitor-count.ts +47 -0
  416. package/src/services/remote-desktop/win32-helper/helper-install-plan.ts +53 -0
  417. package/src/services/remote-desktop/win32-helper/helper-json.ts +5 -0
  418. package/src/services/remote-desktop/win32-helper/helper-paths.ts +97 -0
  419. package/src/services/remote-desktop/win32-helper/helper-script.ts +228 -0
  420. package/src/services/remote-desktop/win32-helper/helper-service.ts +271 -0
  421. package/src/services/remote-desktop/win32-helper/helper-system.ts +78 -0
  422. package/src/services/remote-desktop/win32-helper/install-script.ts +206 -0
  423. package/src/services/remote-desktop/win32-helper/powershell-text.ts +38 -0
  424. package/src/services/remote-desktop/win32-helper/rate-limit-script.ts +51 -0
  425. package/src/services/remote-desktop/win32-helper/rescue-script.ts +121 -0
  426. package/src/services/remote-desktop/win32-helper/vdd-catalog.ts +46 -0
  427. package/src/services/remote-desktop/win32-helper/vdd-scripts.ts +228 -0
  428. package/src/services/remote-desktop/win32-helper/virtual-display-lease.ts +130 -0
  429. package/src/services/remote-desktop/win32-helper/virtual-display-mode.ts +132 -0
  430. package/src/services/remote-desktop/win32-helper/virtual-display-safety-script.ts +71 -0
  431. package/src/services/supervisor.ts +5 -0
  432. package/src/services/telegram/telegram-bot-client.ts +15 -1
  433. package/src/shared/feature-intros.ts +13 -2
  434. package/src/shared/peer-connections.ts +123 -0
  435. package/src/shared/peer-envelope.ts +225 -0
  436. package/src/types/config.ts +6 -0
  437. package/src/web/components/remote-desktop/ffmpeg-install-button.tsx +3 -2
  438. package/src/web/components/remote-desktop/remote-desktop-host-action-button.tsx +43 -0
  439. package/src/web/components/remote-desktop/remote-desktop-input-blocked-bar.tsx +67 -0
  440. package/src/web/components/remote-desktop/remote-desktop-mobile-view.tsx +5 -1
  441. package/src/web/components/remote-desktop/remote-desktop-readiness-gate.tsx +70 -74
  442. package/src/web/components/remote-desktop/remote-desktop-requirement-row.tsx +102 -0
  443. package/src/web/components/remote-desktop/remote-desktop-rescue-bar.tsx +72 -0
  444. package/src/web/components/remote-desktop/remote-desktop-window-content.tsx +3 -1
  445. package/src/web/components/remote-desktop/use-headless-rescue.ts +60 -0
  446. package/src/web/components/remote-desktop/use-remote-desktop-connection.ts +10 -0
  447. package/src/web/components/remote-desktop/use-remote-desktop-readiness.ts +38 -5
  448. package/src/web/components/settings/assistant-telegram-settings.tsx +13 -1
  449. package/src/web/components/settings/remote-desktop-headless-helper-confirm.tsx +70 -0
  450. package/src/web/components/settings/remote-desktop-headless-helper.tsx +110 -0
  451. package/src/web/components/settings/remote-desktop-settings-section.tsx +3 -0
  452. package/src/web/lib/onboarding/feature-intros-client.ts +3 -2
  453. package/dist/web/assets/accounts-settings-section-DEVh1ZH4.js.br +0 -0
  454. package/dist/web/assets/accounts-settings-section-DEVh1ZH4.js.gz +0 -0
  455. package/dist/web/assets/agent-session-sheet-9C3OBt-T.js.br +0 -0
  456. package/dist/web/assets/agent-session-sheet-9C3OBt-T.js.gz +0 -0
  457. package/dist/web/assets/agent-session-window-content-DQDQ5SGw.js.br +0 -0
  458. package/dist/web/assets/agent-session-window-content-DQDQ5SGw.js.gz +0 -0
  459. package/dist/web/assets/ai-resource-editor-DtvnVBCa.js.br +0 -0
  460. package/dist/web/assets/ai-resource-editor-DtvnVBCa.js.gz +0 -0
  461. package/dist/web/assets/ai-settings-section-Bb8OIV3w.js.br +0 -0
  462. package/dist/web/assets/ai-settings-section-Bb8OIV3w.js.gz +0 -0
  463. package/dist/web/assets/ai-settings-section-CFXkVNdm.js.br +0 -0
  464. package/dist/web/assets/ai-settings-section-CFXkVNdm.js.gz +0 -0
  465. package/dist/web/assets/android-tab-BhyWQYkQ.js.br +0 -0
  466. package/dist/web/assets/android-tab-BhyWQYkQ.js.gz +0 -0
  467. package/dist/web/assets/antigravity-usage-view-BBuACANt.js.br +0 -0
  468. package/dist/web/assets/antigravity-usage-view-BBuACANt.js.gz +0 -0
  469. package/dist/web/assets/appearance-settings-section-D1co7CL_.js.br +0 -0
  470. package/dist/web/assets/appearance-settings-section-D1co7CL_.js.gz +0 -0
  471. package/dist/web/assets/apps-panel-Cf9SxZRN.js.br +0 -0
  472. package/dist/web/assets/apps-panel-Cf9SxZRN.js.gz +0 -0
  473. package/dist/web/assets/assistant-settings-dialog-DrNk9cLn.js.br +0 -0
  474. package/dist/web/assets/assistant-settings-dialog-DrNk9cLn.js.gz +0 -0
  475. package/dist/web/assets/assistant-settings-section-CYWFGKYC.js +0 -10
  476. package/dist/web/assets/assistant-settings-section-CYWFGKYC.js.br +0 -0
  477. package/dist/web/assets/assistant-settings-section-CYWFGKYC.js.gz +0 -0
  478. package/dist/web/assets/assistant-tab-DRmxXROI.js.br +0 -0
  479. package/dist/web/assets/assistant-tab-DRmxXROI.js.gz +0 -0
  480. package/dist/web/assets/branch-review-tab-DwnbNz-c.js.br +0 -0
  481. package/dist/web/assets/branch-review-tab-DwnbNz-c.js.gz +0 -0
  482. package/dist/web/assets/build-message-with-attachments-CQod0B6Y.js.br +0 -0
  483. package/dist/web/assets/build-message-with-attachments-CQod0B6Y.js.gz +0 -0
  484. package/dist/web/assets/chat-tab-DHRPMjw_.js.br +0 -0
  485. package/dist/web/assets/chat-tab-DHRPMjw_.js.gz +0 -0
  486. package/dist/web/assets/chat-tab-ialTEX9C.js.br +0 -0
  487. package/dist/web/assets/chat-tab-ialTEX9C.js.gz +0 -0
  488. package/dist/web/assets/code-editor-pwODeLL1.js.br +0 -0
  489. package/dist/web/assets/code-editor-pwODeLL1.js.gz +0 -0
  490. package/dist/web/assets/conflict-editor-w9BfRu3L.js.br +0 -0
  491. package/dist/web/assets/conflict-editor-w9BfRu3L.js.gz +0 -0
  492. package/dist/web/assets/connection-form-tab-C88RVldZ.js.br +0 -0
  493. package/dist/web/assets/connection-form-tab-C88RVldZ.js.gz +0 -0
  494. package/dist/web/assets/csv-preview-BbEwEDG2.js.br +0 -0
  495. package/dist/web/assets/csv-preview-BbEwEDG2.js.gz +0 -0
  496. package/dist/web/assets/database-drivers-section-DhF0MJAC.js.br +0 -0
  497. package/dist/web/assets/database-drivers-section-DhF0MJAC.js.gz +0 -0
  498. package/dist/web/assets/db-tab-parts-DgUIcsg3.js.br +0 -0
  499. package/dist/web/assets/db-tab-parts-DgUIcsg3.js.gz +0 -0
  500. package/dist/web/assets/design-settings-section-2eBuvhKD.js.br +0 -0
  501. package/dist/web/assets/design-settings-section-2eBuvhKD.js.gz +0 -0
  502. package/dist/web/assets/design-tab-qQwUJIlG.js.br +0 -0
  503. package/dist/web/assets/design-tab-qQwUJIlG.js.gz +0 -0
  504. package/dist/web/assets/designs-sidebar-panel-Ldc_JjVI.js.br +0 -0
  505. package/dist/web/assets/designs-sidebar-panel-Ldc_JjVI.js.gz +0 -0
  506. package/dist/web/assets/diff-viewer-Cwn9nnLR.js.br +0 -0
  507. package/dist/web/assets/diff-viewer-Cwn9nnLR.js.gz +0 -0
  508. package/dist/web/assets/docx-preview-CNWvq51O.js.br +0 -0
  509. package/dist/web/assets/docx-preview-CNWvq51O.js.gz +0 -0
  510. package/dist/web/assets/editor-dialog-Cjv5rT7t.js.br +0 -0
  511. package/dist/web/assets/editor-dialog-Cjv5rT7t.js.gz +0 -0
  512. package/dist/web/assets/editor-language-service-CSI7dq9B.js.br +0 -0
  513. package/dist/web/assets/editor-language-service-CSI7dq9B.js.gz +0 -0
  514. package/dist/web/assets/explorer-body-8aOV-5am.js.br +0 -0
  515. package/dist/web/assets/explorer-body-8aOV-5am.js.gz +0 -0
  516. package/dist/web/assets/explorer-window-content-DZ1uW1Yp.js.br +0 -0
  517. package/dist/web/assets/explorer-window-content-DZ1uW1Yp.js.gz +0 -0
  518. package/dist/web/assets/extension-manager-section-CymT0xOK.js.br +0 -0
  519. package/dist/web/assets/extension-manager-section-CymT0xOK.js.gz +0 -0
  520. package/dist/web/assets/extension-webview-CQ06Ek8l.js.br +0 -0
  521. package/dist/web/assets/extension-webview-CQ06Ek8l.js.gz +0 -0
  522. package/dist/web/assets/feature-intros-BNK1hj-A.js.br +0 -0
  523. package/dist/web/assets/feature-intros-BNK1hj-A.js.gz +0 -0
  524. package/dist/web/assets/files-settings-section-C7IcwRur.js.br +0 -0
  525. package/dist/web/assets/files-settings-section-C7IcwRur.js.gz +0 -0
  526. package/dist/web/assets/general-settings-section-D1RMy1aw.js.br +0 -0
  527. package/dist/web/assets/general-settings-section-D1RMy1aw.js.gz +0 -0
  528. package/dist/web/assets/git-log-panel-CfulXvdX.js.br +0 -0
  529. package/dist/web/assets/git-log-panel-CfulXvdX.js.gz +0 -0
  530. package/dist/web/assets/git-review-tab-CwmTIYPS.js.br +0 -0
  531. package/dist/web/assets/git-review-tab-CwmTIYPS.js.gz +0 -0
  532. package/dist/web/assets/glide-data-grid-BQab_Ysc.js.br +0 -0
  533. package/dist/web/assets/glide-data-grid-BQab_Ysc.js.gz +0 -0
  534. package/dist/web/assets/grid-save-dialog-BoPDFh_R.js.br +0 -0
  535. package/dist/web/assets/grid-save-dialog-BoPDFh_R.js.gz +0 -0
  536. package/dist/web/assets/group-chat-tab-BctxtC_y.js.br +0 -0
  537. package/dist/web/assets/group-chat-tab-BctxtC_y.js.gz +0 -0
  538. package/dist/web/assets/impexp-tab-CtuAWcJC.js.br +0 -0
  539. package/dist/web/assets/impexp-tab-CtuAWcJC.js.gz +0 -0
  540. package/dist/web/assets/index-BrxyfrYc.css +0 -1
  541. package/dist/web/assets/index-BrxyfrYc.css.br +0 -0
  542. package/dist/web/assets/index-BrxyfrYc.css.gz +0 -0
  543. package/dist/web/assets/index-HeDx2wIm.js.br +0 -0
  544. package/dist/web/assets/index-HeDx2wIm.js.gz +0 -0
  545. package/dist/web/assets/keyboard-shortcuts-section-BqXoHt9o.js.br +0 -0
  546. package/dist/web/assets/keyboard-shortcuts-section-BqXoHt9o.js.gz +0 -0
  547. package/dist/web/assets/language-servers-section-Cno8kA1_.js.br +0 -0
  548. package/dist/web/assets/language-servers-section-Cno8kA1_.js.gz +0 -0
  549. package/dist/web/assets/logs-app-CLQhFZSL.js.br +0 -0
  550. package/dist/web/assets/logs-app-CLQhFZSL.js.gz +0 -0
  551. package/dist/web/assets/lsp-client-BAOlua0N.js.br +0 -0
  552. package/dist/web/assets/lsp-client-BAOlua0N.js.gz +0 -0
  553. package/dist/web/assets/markdown-renderer-B7tE2qXK.js.br +0 -0
  554. package/dist/web/assets/markdown-renderer-B7tE2qXK.js.gz +0 -0
  555. package/dist/web/assets/markdown-renderer-DdhsSmUW.js.br +0 -0
  556. package/dist/web/assets/markdown-renderer-DdhsSmUW.js.gz +0 -0
  557. package/dist/web/assets/mobile-explorer-sheet-wvVfQE0U.js.br +0 -0
  558. package/dist/web/assets/mobile-explorer-sheet-wvVfQE0U.js.gz +0 -0
  559. package/dist/web/assets/new-design-dialog-XZnj47LU.js.br +0 -0
  560. package/dist/web/assets/new-design-dialog-XZnj47LU.js.gz +0 -0
  561. package/dist/web/assets/notifications-settings-section-C9lZf9KY.js.br +0 -0
  562. package/dist/web/assets/notifications-settings-section-C9lZf9KY.js.gz +0 -0
  563. package/dist/web/assets/onboarding-entry-DaGjZ-08.js.br +0 -0
  564. package/dist/web/assets/onboarding-entry-DaGjZ-08.js.gz +0 -0
  565. package/dist/web/assets/open-manager-chat-DVuYNkNx.js.br +0 -0
  566. package/dist/web/assets/open-manager-chat-DVuYNkNx.js.gz +0 -0
  567. package/dist/web/assets/open-manager-chat-oqMHXX1k.js.br +0 -0
  568. package/dist/web/assets/open-manager-chat-oqMHXX1k.js.gz +0 -0
  569. package/dist/web/assets/problems-panel-BZruxGUk.js.br +0 -0
  570. package/dist/web/assets/problems-panel-BZruxGUk.js.gz +0 -0
  571. package/dist/web/assets/process-table-DK7lMU7-.js.br +0 -0
  572. package/dist/web/assets/process-table-DK7lMU7-.js.gz +0 -0
  573. package/dist/web/assets/proxy-settings-section-SC3IJuac.js.br +0 -0
  574. package/dist/web/assets/proxy-settings-section-SC3IJuac.js.gz +0 -0
  575. package/dist/web/assets/query-tab-198wSDy4.js.br +0 -0
  576. package/dist/web/assets/query-tab-198wSDy4.js.gz +0 -0
  577. package/dist/web/assets/remembered-approvals-section-CTGnu4UB.js.br +0 -0
  578. package/dist/web/assets/remembered-approvals-section-CTGnu4UB.js.gz +0 -0
  579. package/dist/web/assets/remote-access-settings-section-QAPYQO40.js.br +0 -0
  580. package/dist/web/assets/remote-access-settings-section-QAPYQO40.js.gz +0 -0
  581. package/dist/web/assets/remote-desktop-clipboard-notice-C6ZpoOES.js +0 -1
  582. package/dist/web/assets/remote-desktop-clipboard-notice-C6ZpoOES.js.br +0 -0
  583. package/dist/web/assets/remote-desktop-clipboard-notice-C6ZpoOES.js.gz +0 -0
  584. package/dist/web/assets/remote-desktop-mobile-sheet-BeA-aSeF.js.br +0 -0
  585. package/dist/web/assets/remote-desktop-mobile-sheet-BeA-aSeF.js.gz +0 -0
  586. package/dist/web/assets/remote-desktop-mobile-view-Cbc9MVGj.js +0 -1
  587. package/dist/web/assets/remote-desktop-mobile-view-Cbc9MVGj.js.br +0 -0
  588. package/dist/web/assets/remote-desktop-mobile-view-Cbc9MVGj.js.gz +0 -0
  589. package/dist/web/assets/remote-desktop-readiness-gate-BZ33Wtq8.js +0 -1
  590. package/dist/web/assets/remote-desktop-readiness-gate-BZ33Wtq8.js.br +0 -0
  591. package/dist/web/assets/remote-desktop-readiness-gate-BZ33Wtq8.js.gz +0 -0
  592. package/dist/web/assets/remote-desktop-settings-section-BsnndWlF.js +0 -1
  593. package/dist/web/assets/remote-desktop-settings-section-BsnndWlF.js.br +0 -0
  594. package/dist/web/assets/remote-desktop-settings-section-BsnndWlF.js.gz +0 -0
  595. package/dist/web/assets/remote-desktop-window-content-1Hx5mvvx.js +0 -1
  596. package/dist/web/assets/remote-desktop-window-content-1Hx5mvvx.js.br +0 -0
  597. package/dist/web/assets/remote-desktop-window-content-1Hx5mvvx.js.gz +0 -0
  598. package/dist/web/assets/rename-object-dialog-Cm2fs1fN.js.br +0 -0
  599. package/dist/web/assets/rename-object-dialog-Cm2fs1fN.js.gz +0 -0
  600. package/dist/web/assets/review-address-setup-B6Vjrz9r.js.br +0 -0
  601. package/dist/web/assets/review-address-setup-B6Vjrz9r.js.gz +0 -0
  602. package/dist/web/assets/review-code-DcF_yOLk.js.br +0 -0
  603. package/dist/web/assets/review-code-DcF_yOLk.js.gz +0 -0
  604. package/dist/web/assets/save-as-dialog-DOOsO36V.js.br +0 -0
  605. package/dist/web/assets/save-as-dialog-DOOsO36V.js.gz +0 -0
  606. package/dist/web/assets/schedule-form-ZjricDBe.js.br +0 -0
  607. package/dist/web/assets/schedule-form-ZjricDBe.js.gz +0 -0
  608. package/dist/web/assets/schedule-script-editor-DS07jjvr.js.br +0 -0
  609. package/dist/web/assets/schedule-script-editor-DS07jjvr.js.gz +0 -0
  610. package/dist/web/assets/schedules-app-pErYGky8.js.br +0 -0
  611. package/dist/web/assets/schedules-app-pErYGky8.js.gz +0 -0
  612. package/dist/web/assets/schedules-settings-section-BIyYLM7y.js.br +0 -0
  613. package/dist/web/assets/schedules-settings-section-BIyYLM7y.js.gz +0 -0
  614. package/dist/web/assets/schedules-tab-C4MzSQjn.js.br +0 -0
  615. package/dist/web/assets/schedules-tab-C4MzSQjn.js.gz +0 -0
  616. package/dist/web/assets/schedules-ui-DR65Kkrm.js.br +0 -0
  617. package/dist/web/assets/schedules-ui-DR65Kkrm.js.gz +0 -0
  618. package/dist/web/assets/schedules-window-content-klLV9bsT.js.br +0 -0
  619. package/dist/web/assets/schedules-window-content-klLV9bsT.js.gz +0 -0
  620. package/dist/web/assets/session-review-tab-MCN-NAOK.js.br +0 -0
  621. package/dist/web/assets/session-review-tab-MCN-NAOK.js.gz +0 -0
  622. package/dist/web/assets/settings-body-CogOIdcd.js.br +0 -0
  623. package/dist/web/assets/settings-body-CogOIdcd.js.gz +0 -0
  624. package/dist/web/assets/settings-rows-Fw0kZHvj.js.br +0 -0
  625. package/dist/web/assets/settings-rows-Fw0kZHvj.js.gz +0 -0
  626. package/dist/web/assets/settings-section-content-CYdaUq6N.js +0 -2
  627. package/dist/web/assets/settings-section-content-CYdaUq6N.js.br +0 -0
  628. package/dist/web/assets/settings-section-content-CYdaUq6N.js.gz +0 -0
  629. package/dist/web/assets/sql-object-tab-CI7kX6yl.js.br +0 -0
  630. package/dist/web/assets/sql-object-tab-CI7kX6yl.js.gz +0 -0
  631. package/dist/web/assets/sqlite-viewer-B24YviWu.js.br +0 -0
  632. package/dist/web/assets/sqlite-viewer-B24YviWu.js.gz +0 -0
  633. package/dist/web/assets/storage-settings-section-DD5VJ_wA.js.br +0 -0
  634. package/dist/web/assets/storage-settings-section-DD5VJ_wA.js.gz +0 -0
  635. package/dist/web/assets/structure-save-dialog-C5gBtT4a.js.br +0 -0
  636. package/dist/web/assets/structure-save-dialog-C5gBtT4a.js.gz +0 -0
  637. package/dist/web/assets/structure-tab-D04ISE5t.js.br +0 -0
  638. package/dist/web/assets/structure-tab-D04ISE5t.js.gz +0 -0
  639. package/dist/web/assets/system-monitor-body-C0CTmM4H.js.br +0 -0
  640. package/dist/web/assets/system-monitor-body-C0CTmM4H.js.gz +0 -0
  641. package/dist/web/assets/tab-host-window-content-Drfdn_AL.js.br +0 -0
  642. package/dist/web/assets/tab-host-window-content-Drfdn_AL.js.gz +0 -0
  643. package/dist/web/assets/table-tab-BemdDB86.js.br +0 -0
  644. package/dist/web/assets/table-tab-BemdDB86.js.gz +0 -0
  645. package/dist/web/assets/task-detail-mobile-Cg-aTvPs.js.br +0 -0
  646. package/dist/web/assets/task-detail-mobile-Cg-aTvPs.js.gz +0 -0
  647. package/dist/web/assets/task-sheet-Bt6RJkwp.js.br +0 -0
  648. package/dist/web/assets/task-sheet-Bt6RJkwp.js.gz +0 -0
  649. package/dist/web/assets/task-status-grid-lgA1eYhJ.js.br +0 -0
  650. package/dist/web/assets/task-status-grid-lgA1eYhJ.js.gz +0 -0
  651. package/dist/web/assets/task-tab-DaNoD62w.js.br +0 -0
  652. package/dist/web/assets/task-tab-DaNoD62w.js.gz +0 -0
  653. package/dist/web/assets/tasks-sidebar-panel-Cy6acEuS.js.br +0 -0
  654. package/dist/web/assets/tasks-sidebar-panel-Cy6acEuS.js.gz +0 -0
  655. package/dist/web/assets/telegram-bot-token-field-B2qx9Wrw.js.br +0 -0
  656. package/dist/web/assets/telegram-bot-token-field-B2qx9Wrw.js.gz +0 -0
  657. package/dist/web/assets/terminal-tab-YUv1NIkW.js.br +0 -0
  658. package/dist/web/assets/terminal-tab-YUv1NIkW.js.gz +0 -0
  659. package/dist/web/assets/tool-cards-DUWj5RNK.js.br +0 -0
  660. package/dist/web/assets/tool-cards-DUWj5RNK.js.gz +0 -0
  661. package/dist/web/assets/tools-settings-section-DG3GUKxu.js.br +0 -0
  662. package/dist/web/assets/tools-settings-section-DG3GUKxu.js.gz +0 -0
  663. package/dist/web/assets/use-db-read-CFM7NqkD.js.br +0 -0
  664. package/dist/web/assets/use-db-read-CFM7NqkD.js.gz +0 -0
  665. package/dist/web/assets/use-inline-blame-IeX8t-qC.js.br +0 -0
  666. package/dist/web/assets/use-inline-blame-IeX8t-qC.js.gz +0 -0
  667. package/dist/web/assets/use-lsp-B1Kx75hO.js.br +0 -0
  668. package/dist/web/assets/use-lsp-B1Kx75hO.js.gz +0 -0
  669. package/dist/web/assets/use-process-kill-B8v1jodL.js.br +0 -0
  670. package/dist/web/assets/use-process-kill-B8v1jodL.js.gz +0 -0
  671. package/dist/web/assets/use-sql-schema-info-DNaKdydY.js.br +0 -0
  672. package/dist/web/assets/use-sql-schema-info-DNaKdydY.js.gz +0 -0
  673. package/dist/web/assets/vault-settings-section-rB1F_zDn.js.br +0 -0
  674. package/dist/web/assets/vault-settings-section-rB1F_zDn.js.gz +0 -0
  675. package/dist/web/assets/voice-settings-section-DBWKoCdg.js.br +0 -0
  676. package/dist/web/assets/voice-settings-section-DBWKoCdg.js.gz +0 -0
  677. package/dist/web/assets/web-browser-settings-section-L3mQK6s9.js.br +0 -0
  678. package/dist/web/assets/web-browser-settings-section-L3mQK6s9.js.gz +0 -0
  679. package/dist/web/assets/web-browser-view-D5zQyqTr.js.br +0 -0
  680. package/dist/web/assets/web-browser-view-D5zQyqTr.js.gz +0 -0
  681. package/dist/web/assets/web-preview-tab-d_zyKug-.js.br +0 -0
  682. package/dist/web/assets/web-preview-tab-d_zyKug-.js.gz +0 -0
  683. package/dist/web/assets/xlsx-preview-wPPrZDIQ.js.br +0 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,31 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.26.41] - 2026-11-27
4
+
5
+ ### Fixed
6
+
7
+ - **"Bring session back" works with the Windows helper already installed (v2)**: it no longer hides the button and asks for a setup; the newer version is only suggested.
8
+ - **The Windows session row gives numbered steps for someone on a phone**: what to tap, what it costs, why it is safe from afar, and where to set up the helper if it is missing.
9
+ - **A capture failure from a disconnected Windows session is explained in plain words**, and no longer suggests reconnecting over RDP, which disconnects it again.
10
+ - **A tall Remote Desktop checklist scrolls back to its title** in a short window.
11
+
12
+ ## [0.26.40] - 2026-11-27
13
+
14
+ ### Added
15
+
16
+ - **Remote Desktop on a Windows PC left disconnected by RDP**: the checklist says so and brings the session back to the screen through a small helper installed from Settings → Remote Desktop with one administrator prompt.
17
+ - **A virtual display for Windows PCs with no monitor**: the same helper adds one (1920x1080); the checklist offers it instead of streaming Windows' 1024x768 fallback screen.
18
+ - **A safety net for those helper actions**: unless you confirm "I can still reach this PC" within 5 minutes, the PC gets a screen back by itself.
19
+ - **The viewer says when Windows ignores your input** because an administrator window is in front, and which app it is.
20
+ - **One pinned list of the cards waiting for you on Telegram**, each answerable from the list with its own buttons; asked once as a new feature, with a switch in Settings.
21
+
22
+ ### Fixed
23
+
24
+ - **Remote Desktop capture failures on Windows say why** (disconnected session or no display) instead of a bare "Capture failed".
25
+ - **A slow Remote Desktop helper no longer reads as a failure**: PPM waits up to 60 seconds and says "not known yet" when it has to stop waiting.
26
+ - **Renaming the machine in Settings no longer re-registers it with PPM Cloud.**
27
+ - **PPM Cloud reconnects with a new device key** after `ppm cloud link` instead of retrying the refused one.
28
+
3
29
  ## [0.26.39] - 2026-11-26
4
30
 
5
31
  ### Added
package/CLAUDE.md CHANGED
@@ -409,7 +409,7 @@ Before planning or implementing a new feature, read `docs/project-roadmap.md` to
409
409
  - `src/services/tab-tools-mcp/` — the AI's tab tools, `open_file` (optional `line`), `open_preview`, `open_url`, `read_terminal` and `run_in_terminal`, given to every chat that is not a design session while any is on in Settings → Tools (`ai.ppm_tools`, decided by `src/shared/ppm-tools.ts`; `open_file`/`open_preview` never switched there follow the older single switch `ai.tab_tools`, the other three default on, so the server reaches every chat by default); Claude's claude.ai Artifact tools are turned off while `open_preview` is on (`CLAUDE_CODE_DISABLE_ARTIFACT=1`), and a call to a tool turned off since is refused at the endpoint (`unavailable` in `mcp-http-endpoint.ts`), because a chat keeps the tools it started with. `/api/tab-tools-mcp` (`tab-tools-mcp-endpoint.ts`, mounted before auth) is built from the same parts as `/api/design-mcp`: `src/services/mcp-http-endpoint.ts` (JSON-only Streamable HTTP, a request with an `Origin` refused, 64 KB cap) and `src/services/mcp-session-tokens.ts` (per-session capability tokens, memory only, looked up by SHA-256); `tab-tools-mcp-tokens.ts` binds a token to the session id alone, so a warm spare's token is the one its session's turns mint. `tab-target.ts` resolves the agent's `path` under the editor's own read rules, and `tab-open-broker.ts` sends `tab_open` over the chat WebSocket and waits for the first `tab_open_result` (8 s for a file, 40 s for a page; 4 calls in flight and 20 a minute per session) — `deliverTabOpen` in `src/server/ws/chat.ts` picks the device that sent the turn's message, else every device showing the chat, and never buffers it for replay. Protocol and the per-provider tool names in `src/shared/tab-open-protocol.ts`; provider wiring `tabToolsMcpServers` (`claude-agent-sdk-query-options.ts`) and `tabToolsMcpConfig`/`tabToolsMcpEnv` (`codex-thread-params.ts`), from the access `chatService.prepareSendOptions` mints. Browser: `src/web/lib/open-ai-tab.ts` (answers `tab_open` from `use-chat.ts`: opens the tab, waits for the page, runs its check), `ai-tab-placement.ts` (pure: beside the chat on a desktop, the whole screen on a phone), `html-preview-loads.ts` (which preview shows which page, by load), `tab-tool-call.ts` + `src/web/components/chat/tab-tool-card.tsx` (the card and its Open button). The three tools that take no file: `open-url-tool.ts` (host servers only; an existing forward, else a private Tailscale forward it starts, else the address itself, which `openAiUrlTab` accepts only on a page loaded from loopback), `terminal-tools.ts` (`read_terminal` over the chat's project terminals plus the ones it opened; `run_in_terminal` starts the shell, has the device dock it via `openAiTerminal`, types one checked line with no newline) and `terminal-text.ts` (the raw buffer replayed through `@xterm/headless` into the lines the screen shows); their card is `src/web/components/chat/device-tool-card.tsx`. The HTML preview route serves the design canvas's CSP (`buildDesignCsp`, so the design CDNs load) and injects `design/bridge/html-preview-bridge.ts`, the design bridge's core plus its self-check. Docs `docs/architecture/ai-chat-and-providers.md` → AI tab tools; e2e `PPM_PLAYWRIGHT_MODULE=<playwright>/index.mjs node tests/e2e/ai-tab-tools-e2e.mjs` (scripted provider in `tests/e2e/fixtures/tab-tools-server.ts`, which also mounts the terminal socket; `PPM_TAB_TOOLS_WEB_DIR` reuses a scratch build; a stand-in `tailscale` on its `PATH` keeps `open_url` off the real tailnet) and `tests/e2e/html-preview-cdn-check-e2e.mjs`. Full design: `docs/architecture/ai-tab-tools.md`
410
410
  - `src/services/db-ai-tools/` — the AI chat's database tools, `db_query` (read-only), `open_query` (a Query tab holding a script the user runs) and `db_execute` (a change, once, after the user approves it with PPM's password), on the saved connections with *Available to the AI chat* on, each tool on or off in Settings → Tools (`ai.ppm_tools`, all three on by default; `src/shared/ppm-tools.ts`). `db_query` names only the change tools that are on (`dbChangeHint`). `/api/db-tools-mcp` (`db-ai-tools-endpoint.ts`, mounted before auth) is built like `/api/tab-tools-mcp`: `mcp-http-endpoint.ts` + per-session tokens (`db-ai-tools-tokens.ts`). `db-ai-tools-tool.ts` holds the tool definitions and limits, `db-ai-connections.ts` which connections (light on purpose: `chat.service.ts` imports it, and the CLI loads `chat.service.ts`), `db-ai-target.ts` the adapter config with the *tool's* `readonly`, `db-ai-run.ts` the runs (`QueryScriptRun` for reads, `runApprovedScript` for one approved transaction), `db-ai-format.ts` rows as fenced untrusted data, `db-approval-broker.ts` the wait for the user's answer. Shared names and the approval's shape in `src/shared/db-ai-tools.ts`; the password check in `src/services/ppm-password.ts`. Chat side: `announcePpmApproval` / `ppmApprovalResolved` in `src/server/ws/chat.ts`, onto the session's approval slot (`chat-pending-approval.ts`, origin `ppm`; shared with the session tools' cards through `chat-ppm-approvals.ts`); the answer route `POST /api/db/ai-approvals/:requestId` in `src/server/routes/database.ts`. Browser: `src/web/components/chat/db-execute-approval-card.tsx`, `db-tool-card.tsx` + `src/web/lib/db-tool-call.ts`, `openAiQueryTab` in `src/web/lib/open-ai-tab.ts`, and the Query tab's *Run with write access (once)* (`write-once-dialog.tsx`, `writeOnce` on `/query/script`). Docs `docs/architecture/ai-chat-and-providers.md` → AI database tools; e2e `PPM_PLAYWRIGHT_MODULE=<playwright>/index.mjs node tests/e2e/ai-db-tools-e2e.mjs` (scripted provider in `tests/e2e/fixtures/db-tools-server.ts`; `PPM_DB_TOOLS_WEB_DIR` reuses a scratch build).
411
411
  - `src/services/agent-transcript/` — one hub per `(providerId, sessionId)` streaming an Agent card's or teammate's own transcript live over `/ws/global`, independent of the chat WebSocket and of whether the root turn is still running. `session-ownership.ts` proves the session belongs to the caller's project before any file is named; `agent-transcript-sources.ts` resolves a card/teammate to the exact file(s), including Codex descendants via `session_meta.parent_thread_id`; `agent-transcript-session-hub.ts` + `agent-transcript-hub.ts` are the per-session tail/page/cursor loop, `agent-transcript-session-hub-activity.ts` the separate "who is running" feed. Protocol in `src/shared/agent-transcript-protocol.ts`; UI entry points `src/web/components/chat/{agent-card-summary,agent-session-window-content,agent-session-sheet,running-agents-bar}.tsx` via `use-agent-session-stream.ts`/`use-agent-activity.ts`; docs `docs/architecture/ai-chat-and-providers.md` → Agent session transcripts
412
- - `src/services/notification.service.ts` — notifications, configured in Settings → Notifications. `broadcast(type, payload, { stillUnseen })` drops a switched-off event, waits `delay_seconds` (one pending per session: a newer event replaces it) and sends only if `stillUnseen()` still holds — the chat is still unread, and for an approval the same request is still pending (`src/server/ws/chat.ts`); schedules and Jira pass none and always send. `deliver` fans out to push, Telegram and ntfy, plus PPM Cloud's `sendNotification`, which is inert in the server process because that connection lives in the supervisor. Settings shape and defaults in `src/shared/notification-settings.ts`, text and links in `notification-format.ts`. Push is standard Web Push with no dependency, `src/services/web-push/` (VAPID ES256 + RFC 8291 aes128gcm on WebCrypto; keys and subscriptions are the config rows `web_push_vapid` / `web_push_subscriptions` and never reach a browser); the browser half is `src/web/sw.ts` (`push`, and `notificationclick` → `src/web/sw-notification-click.ts`, which hands the session to an open window through `src/web/hooks/use-notification-clicks.ts`) and `src/web/lib/web-push-{support,client}.ts`. Telegram sends through `telegram-notification.service.ts` to the chats in the `telegram_notify_chats` config row, and to nobody else: the PPM Assistant's Telegram side has a bot and chats of its own (`telegram-bots.ts` — the `ppmbot_telegram` row and `clawbot_paired_chats`, names kept from PPMBot so nobody reconnects; both rows sit outside `CONFIG_TABLE_KEYS` like the VAPID key, and an install that shared one bot is split once, on first read). The one-tap Connect link is `telegram-connect.service.ts`, one per bot owner, which polls a bot itself unless the Assistant's Telegram bridge is reading that bot (`assistantBridgeReading`; Telegram allows one `getUpdates` reader per bot; the bots are compared by id, the digits before the token's colon). Every Telegram call goes through `src/services/telegram/` (one Bot API client whose base URL can be overridden only to a loopback address, and the Telegram HTML formatter), faked in tests by `tests/helpers/fake-telegram-bot-api.ts`. ntfy is `ntfy-notification.service.ts`: one JSON publish per notification (the header form cannot carry a non-ASCII title), the config row `ntfy` with its token in `SECRET_CONFIG_KEYS`, dropped when Settings saves a different server so it is not sent to the new one (`PUT /ntfy`; `ppm config set ntfy.server` does not drop it). Both channels take their link back into PPM from `notification-link.ts`: the tunnel URL, else the Tailscale Service address, else localhost — never the LAN address, which is plain HTTP on an insecure origin where the browser withholds every permission PPM asks for. Routes `src/server/routes/notifications.ts` (`/api/notifications/*`), UI `src/web/components/settings/notifications-settings-section.tsx` + `telegram-bot-token-field.tsx` + `ntfy-server-form.tsx`, fake ntfy for tests `tests/helpers/fake-ntfy-server.ts`
412
+ - `src/services/notification.service.ts` — notifications, configured in Settings → Notifications. `broadcast(type, payload, { stillUnseen })` drops a switched-off event, waits `delay_seconds` (one pending per session: a newer event replaces it) and sends only if `stillUnseen()` still holds — the chat is still unread, and for an approval the same request is still pending (`src/server/ws/chat.ts`); schedules and Jira pass none and always send. `deliver` fans out to push, Telegram and ntfy, and to nothing else: PPM Cloud's device connection carries no notifications (it lives in the supervisor, and Cloud only logs a message type it does not know). Settings shape and defaults in `src/shared/notification-settings.ts`, text and links in `notification-format.ts`. Push is standard Web Push with no dependency, `src/services/web-push/` (VAPID ES256 + RFC 8291 aes128gcm on WebCrypto; keys and subscriptions are the config rows `web_push_vapid` / `web_push_subscriptions` and never reach a browser); the browser half is `src/web/sw.ts` (`push`, and `notificationclick` → `src/web/sw-notification-click.ts`, which hands the session to an open window through `src/web/hooks/use-notification-clicks.ts`) and `src/web/lib/web-push-{support,client}.ts`. Telegram sends through `telegram-notification.service.ts` to the chats in the `telegram_notify_chats` config row, and to nobody else: the PPM Assistant's Telegram side has a bot and chats of its own (`telegram-bots.ts` — the `ppmbot_telegram` row and `clawbot_paired_chats`, names kept from PPMBot so nobody reconnects; both rows sit outside `CONFIG_TABLE_KEYS` like the VAPID key, and an install that shared one bot is split once, on first read). The one-tap Connect link is `telegram-connect.service.ts`, one per bot owner, which polls a bot itself unless the Assistant's Telegram bridge is reading that bot (`assistantBridgeReading`; Telegram allows one `getUpdates` reader per bot; the bots are compared by id, the digits before the token's colon). Every Telegram call goes through `src/services/telegram/` (one Bot API client whose base URL can be overridden only to a loopback address, and the Telegram HTML formatter), faked in tests by `tests/helpers/fake-telegram-bot-api.ts`. ntfy is `ntfy-notification.service.ts`: one JSON publish per notification (the header form cannot carry a non-ASCII title), the config row `ntfy` with its token in `SECRET_CONFIG_KEYS`, dropped when Settings saves a different server so it is not sent to the new one (`PUT /ntfy`; `ppm config set ntfy.server` does not drop it). Both channels take their link back into PPM from `notification-link.ts`: the tunnel URL, else the Tailscale Service address, else localhost — never the LAN address, which is plain HTTP on an insecure origin where the browser withholds every permission PPM asks for. Routes `src/server/routes/notifications.ts` (`/api/notifications/*`), UI `src/web/components/settings/notifications-settings-section.tsx` + `telegram-bot-token-field.tsx` + `ntfy-server-form.tsx`, fake ntfy for tests `tests/helpers/fake-ntfy-server.ts`
413
413
  - `src/services/remembered-approvals/` — "Allow & remember" on approval cards: a rule per project approves the same kind of request without a card. The kind is worked out on the server (`src/shared/remembered-approval-pattern.ts`) and the deny list (`src/shared/remembered-approval-denylist.ts`) is checked again on every request; only a person's press (`ws`, `assistant_card`, `telegram`) makes a rule, never an AI. Applied in `ws/chat.ts` before a provider card is offered and in `collabApprovalBroker`'s `autoApprove`; routes `/api/approval-rules` (list, remove, switch), Settings → Approvals (`settings/remembered-approvals-section.tsx`), migration 81. Docs `docs/architecture/ai-chat-and-providers.md` → Remembered approvals
414
414
  - `src/services/session-collab/` + `src/server/ws/chat-inject.ts` — session collaboration: a chat's AI opens other PPM sessions and messages any session of its project through `create_session`, `send_to_session` and `session_status` on `/api/sessions-mcp` (MCP server `ppm-sessions` / Codex `ppm_sessions`, mounted before auth, per-session capability tokens in `session-collab-tokens.ts`, minted by `chatService.prepareSendOptions`; never for Design chats, which may still be created with `create_session { design }` and messaged — they answer in their reply, which a wait hands back). `design_screenshot` on the same server renders a design's variants to PNG with a headless Chrome/Edge on the host (`src/services/design/shots/`, DevTools over `--remote-debugging-pipe` except on Windows where Bun cannot pass the pipe fds, kept 7 days, served at `/api/design-shots/<id>.png` behind the login), and `report_to_assistant { images }` puts them on a card that Telegram gets as photos (`assistant-telegram-card-photos.ts`); e2e `tests/e2e/collab-design-sessions-e2e.mjs`. `session-collab-endpoint.ts` resolves the caller from its token to its canonical id and project, then rate-limits (`collab-rate-limit.ts`) and dispatches to `collab-create.ts` / `collab-send.ts` / `collab-status.ts`; the rules take one `CollabEnv` (`collab-context.ts`, production `collab-env.ts`) so they are unit-tested without a server. `collab-waits.ts` is the wait registry (first of reply / turn end / timeout / cancel wins), `collab-approval-broker.ts` the create, pair-limit and escalation cards (answered at `POST /api/sessions-collab/approvals/:id`, shown through the generalized slot in `src/server/ws/chat-ppm-approvals.ts`), `pair-counter.ts` the per-pair counts and grants (sidecar `<ppm dir>/session-collab/pairs.json`), `session-links.service.ts` the `spawned_by`/`spawn_depth` columns and `linkedSessions()`. `chat-inject.ts`'s `deliverToSession` is the server's own door into a session — the browser path's `ensureSessionEntry`/`submitToSession` under the same per-session lock — reporting `inserted`/`queued`/`started` truthfully; no route exposes it. Shared shapes `src/shared/session-collab.ts`, settings `src/shared/session-collab-settings.ts` (`ai.session_collab`), the message block `src/shared/chat-from-session.ts`; routes `src/server/routes/session-collab.ts` (approvals, `…/sessions/:id/links`, `…/stop-children`). UI `src/web/components/chat/{from-session-bubble,session-collab-tool-card,linked-sessions-bar,linked-session-chip,spawned-session-badge,collab-approval-card}.tsx`, state `src/web/stores/session-collab-store.ts` + `src/web/hooks/use-linked-sessions.ts`. Docs `docs/architecture/ai-chat-and-providers.md` → Session collaboration; e2e `tests/e2e/session-collab-e2e.mjs` (run it in the image from `tests/e2e/docker/Dockerfile`)
415
415
  - `src/services/session-turns/` — cross-session turn references: one chat points at single turns of other Claude/Codex sessions (chips) and its AI reads them (`search_sessions`, `list_session_turns`, `read_session_turns` on `/api/tab-tools-mcp`). `session-turn-index.service.ts` resolves a session only through `assertSessionInProject` and scans it incrementally (`turn-index-claude.ts`, `turn-index-codex.ts`, cached by `turn-index-cache.ts`), `session-turn-reader.ts` reads turns by byte range and answers `stale` rather than another turn, `stamp-message-turns.ts` puts `turnId`/`turnN` on every history message, `turn-grant-ledger.ts` is the only thing that lets the AI read another project's turn (written by the chat socket from a browser send's `turnRefs`, `<ppm dir>/session-turn-grants/`), `turn-access.ts` enforces it, `turn-render.ts` renders a turn without raw tool output, `session-search.ts` searches `search-index-v3.db`. Routes `src/server/routes/chat-session-turns.ts` (`/turns`, `/turns/:turnId`) and `chat-turn-window.ts` (`/turn-window`); the tools in `src/services/tab-tools-mcp/session-history-*.ts`; block codec `src/shared/chat-turn-ref.ts` + `chat-message-blocks.ts`; real-prompt predicate `src/shared/user-prompt-kind.ts`. UI: `copy-turn-link-button.tsx`, `turn-ref-chip.tsx`, `use-composer-turn-refs.ts`, `turn-binding-store.ts`, `open-turn-ref.ts`, and the history window (`chat-history-window.tsx`, `use-history-window.ts`, `use-scroll-anchor-pin.ts`, `use-chat-turn-jump.ts`). Docs `docs/architecture/ai-chat-and-providers.md` → Session turn references and `workspace-and-ui.md` → Turn links, chips and the history window; e2e `PPM_PLAYWRIGHT_MODULE=<playwright-core>/index.mjs node tests/e2e/session-turn-refs-e2e.mjs`
@@ -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.39 at build time. Re-run `ppm export skill --install` to refresh. -->
86
+ <!-- Generated for PPM v0.26.41 at build time. Re-run `ppm export skill --install` to refresh. -->
@@ -664,6 +664,9 @@ JSON responses are wrapped: `{ "ok": true, "data": … }` or `{ "ok": false, "er
664
664
  - `GET /api/remote-desktop/requirements/ffmpeg/install`
665
665
  - `POST /api/remote-desktop/requirements/ffmpeg/install`
666
666
  - `POST /api/remote-desktop/requirements/:id/:action`
667
+ - `GET /api/remote-desktop/headless-helper`
668
+ - `GET /api/remote-desktop/headless-helper/rescue`
669
+ - `POST /api/remote-desktop/headless-helper/:kind`
667
670
  - `POST /api/remote-desktop/session`
668
671
  - `POST /api/remote-desktop/whep/:ticket`
669
672
  - `GET /api/remote-desktop/relay`
@@ -926,4 +929,4 @@ Authenticate with `?token=<token>` (see Authentication).
926
929
  - `/ws/android`
927
930
  - `/ws/project/<project>/<type>/<id>` — `<type>`: `terminal`, `chat`, `group`, `lsp` (for `chat`, `<id>` is the session id)
928
931
 
929
- <!-- Generated from src/server/routes/ for PPM v0.26.39 -->
932
+ <!-- Generated from src/server/routes/ for PPM v0.26.41 -->
@@ -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-HeDx2wIm.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-BBuACANt.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-CToe9paM.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-BXUaYGNj.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-DQDQ5SGw.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-DUWj5RNK.js","assets/index-HeDx2wIm.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-DQDQ5SGw.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-CaFQViPK.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-C6d2_kWx.js","assets/index-CToe9paM.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-WD7-nag4.js","assets/feature-intros-CHJ2c-NE.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-Dcfq8TCF.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-Bpl4lgH9.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-D1toZxbF.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-CaFQViPK.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-DUWj5RNK.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-C6d2_kWx.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-HeDx2wIm.js";import{t as _}from"./use-monaco-theme-6JvXyR9m.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-CToe9paM.js";import{t as _}from"./use-monaco-theme-B5TdBov8.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};