@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
@@ -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{yt as r}from"./vendor-ui-BQzUk4nq.js";import{Ar as i,Et as a,Xr as o,_t as s,d as c,er as l,ht as u,ln as d,lr as f,nr as p,pi as m,rn as h,ti as g,ut as _,vt as v,wn as y}from"./icons-CpR5Vw3J.js";import{j as b}from"./api-client-DSCscZEd.js";import{n as x}from"./utils-DMiycH3O.js";import"./portal-container-context-C84rlnJ6.js";import"./mobile-bottom-sheet-C78UMLrn.js";import"./use-visual-viewport-tMLO63yY.js";import"./use-is-mobile-CrfIt67b.js";import{D as S,a as C,b as w,f as T,g as E,i as D,k as O,l as k,m as A,n as ee,o as j,r as M,s as te,w as N,x as P}from"./vault-Q5oPy0h3.js";import{t as ne}from"./vault-focus-store-BYABW4-C.js";import{t as F}from"./button-CtdEWN7U.js";import"./dialog-BWXzvHlC.js";import{r as I}from"./clipboard-DQuoK2EM.js";import{t as L}from"./input-CCVoN0-P.js";import"./design-canvas-check-DAc84j07.js";import"./tab-open-protocol-D5UyfEsm.js";import"./vault-tool-call-DSMwzVDz.js";import{_ as R,a as z,f as B,g as V,h as H,i as U,n as W,o as re,p as G,r as ie,s as ae,t as oe,v as K,y as q}from"./vault-fields-DrhqcOc6.js";import{t as J}from"./design-responsive-dialog-CC557bnX.js";import{n as Y,t as X}from"./settings-rows-Fw0kZHvj.js";var Z=e(t(),1);function se(){let[e,t]=(0,Z.useState)(null),[n,r]=(0,Z.useState)(null),i=(0,Z.useCallback)(async()=>{try{let[e,n]=await Promise.all([V.status(),V.items()]),i=n.filter(e=>e.tier===`public`),a=await Promise.all(i.map(e=>V.reveal(e.id).then(t=>[e.id,t.value])));t({status:e,items:n,publicValues:Object.fromEntries(a)}),r(null)}catch(e){r(R(e).message)}},[]);return(0,Z.useEffect)(()=>{i()},[i]),{data:e,error:n,refresh:i}}var Q=n();function ce({files:e,actions:t}){return e.length?(0,Q.jsx)(`ul`,{className:`mt-2 space-y-1.5`,"data-vault-files":``,children:e.map(e=>(0,Q.jsxs)(`li`,{className:`flex items-center gap-2 rounded-lg border border-border bg-panel-2/60 py-1 pl-2 pr-1`,"data-vault-file":e.id,children:[(0,Q.jsx)(`span`,{className:`flex size-9 shrink-0 items-center justify-center rounded-md bg-panel-2 text-text-secondary`,"aria-hidden":!0,children:e.type===`application/pdf`?(0,Q.jsx)(a,{className:`size-4`}):(0,Q.jsx)(h,{className:`size-4`})}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`p`,{className:`truncate text-sm`,children:e.label}),(0,Q.jsxs)(`p`,{className:`text-[11px] text-muted-foreground`,children:[j[e.type],` · `,N(e.size)]})]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0`,children:[(0,Q.jsx)(X,{label:`Preview ${e.label}`,onClick:()=>t.onPreview(e),children:(0,Q.jsx)(s,{className:`size-4`})}),(0,Q.jsx)(X,{label:`Download ${e.label}`,onClick:()=>t.onDownload(e),children:(0,Q.jsx)(u,{className:`size-4`})}),(0,Q.jsx)(X,{label:`Rename ${e.label}`,onClick:()=>t.onRename(e),children:(0,Q.jsx)(p,{className:`size-4`})}),(0,Q.jsx)(X,{label:`Delete ${e.label}`,danger:!0,onClick:()=>t.onDelete(e),children:(0,Q.jsx)(o,{className:`size-4`})})]})]},e.id))}):null}var le=3e4,ue=e=>new Date(e).toLocaleString(void 0,{dateStyle:`medium`,timeStyle:`short`});function de({item:e,publicValue:t,revealed:n,onShow:r,onHide:i,onEdit:a,onMove:u,onDelete:d,onAddFile:f,fileActions:m}){let h=q(!!n),[g,y]=(0,Z.useState)(!1),b=!!n&&n.until>h;(0,Z.useEffect)(()=>{n&&n.until<=h&&i?.()},[n,h,i]),(0,Z.useEffect)(()=>y(!1),[n]);let x=t??(b?n.value:null);return(0,Q.jsxs)(`div`,{className:`px-4 py-2`,"data-vault-item":e.id,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1 md:flex-row md:items-start md:gap-3`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsxs)(`p`,{className:`truncate text-sm`,children:[e.name,` `,(0,Q.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`· `,k[e.kind]]}),!!e.attachments?.length&&(0,Q.jsxs)(`span`,{className:`ml-1 inline-flex items-center gap-0.5 text-xs text-muted-foreground`,"data-vault-file-count":``,children:[`· `,(0,Q.jsx)(l,{className:`size-3`}),e.attachments.length]})]}),(0,Q.jsxs)(`p`,{className:`text-[11px] text-muted-foreground`,children:[`Updated `,ue(e.updatedAt)]})]}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-1 md:shrink-0`,children:[x!==null&&(0,Q.jsx)(X,{label:g?`Copied`:`Copy`,onClick:()=>void I(x).then(y),children:(0,Q.jsx)(_,{className:`size-4`})}),r&&(b?(0,Q.jsx)(X,{label:`Hide`,onClick:()=>i?.(),children:(0,Q.jsx)(v,{className:`size-4`})}):(0,Q.jsx)(X,{label:`Show`,onClick:r,children:(0,Q.jsx)(s,{className:`size-4`})})),(0,Q.jsx)(X,{label:`Edit`,onClick:a,children:(0,Q.jsx)(p,{className:`size-4`})}),f&&(0,Q.jsx)(X,{label:`Attach a photo or PDF`,onClick:f,children:(0,Q.jsx)(l,{className:`size-4`})}),(0,Q.jsx)(X,{label:`Move to another tier`,onClick:u,children:(0,Q.jsx)(c,{className:`size-4`})}),(0,Q.jsx)(X,{label:`Delete`,danger:!0,onClick:d,children:(0,Q.jsx)(o,{className:`size-4`})})]})]}),x!==null&&(0,Q.jsxs)(`div`,{className:`mt-1 flex items-start gap-2`,children:[(0,Q.jsx)(`code`,{className:`block max-h-60 min-w-0 flex-1 select-text overflow-auto whitespace-pre-wrap break-all rounded bg-panel-2 px-2 py-1 font-mono text-xs`,"data-vault-value":``,children:x}),b&&(0,Q.jsx)(`span`,{className:`shrink-0 pt-1 font-mono text-[11px] text-muted-foreground`,children:H(n.until-h)})]}),m&&e.attachments?.length?(0,Q.jsx)(ce,{files:e.attachments,actions:m}):null]})}function fe({items:e,values:t,onAdd:n,onEdit:r,onMove:i,onDelete:a}){return(0,Q.jsxs)(`section`,{className:`space-y-3`,"data-vault-tier":`public`,children:[(0,Q.jsx)(Y,{title:`Public`,children:oe}),(0,Q.jsxs)(`div`,{className:`divide-y divide-border rounded-lg border border-border`,children:[e.length===0&&(0,Q.jsx)(`p`,{className:`px-4 py-3 text-xs text-muted-foreground`,children:`No items yet.`}),e.map(e=>(0,Q.jsx)(de,{item:e,publicValue:t[e.id]??``,onEdit:()=>r(e),onMove:()=>i(e),onDelete:()=>a(e)},e.id))]}),(0,Q.jsxs)(F,{className:`h-11 md:h-9`,onClick:n,children:[(0,Q.jsx)(f,{className:`size-4`}),`Add`]})]})}var pe={secure:`Encrypted under its own password. The AI reads an item only after you type that password on a card in PPM, once or for a few minutes.`,sealed:`Encrypted under a second, separate password and never kept open. One item per card, shown to you unless you give it to the AI that once.`};function me({tier:e,status:t,items:n,revealed:r,now:a,actions:s}){let c=P[e],l=t.settingsOpenUntil-a,u=t.lockedUntil-a;return t.enabled?(0,Q.jsxs)(`section`,{className:`space-y-3`,"data-vault-tier":e,children:[(0,Q.jsx)(Y,{title:c,children:pe[e]}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs`,children:[e===`secure`&&(l>0?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-success/15 px-2 py-1 text-success`,"data-vault-unlocked":``,children:[(0,Q.jsx)(i,{className:`size-3.5`}),`Unlocked, `,H(l),` left`]}),(0,Q.jsx)(F,{variant:`outline`,className:`h-11 md:h-8`,onClick:s.onLock,children:`Lock now`})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-panel-2 px-2 py-1 text-text-secondary`,children:[(0,Q.jsx)(y,{className:`size-3.5`}),`Locked`]}),(0,Q.jsx)(F,{variant:`outline`,className:`h-11 md:h-8`,onClick:s.onUnlock,children:`Unlock for 5 minutes`})]})),e===`sealed`&&(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:`Asks for its password at every action.`}),u>0&&(0,Q.jsxs)(`span`,{className:`text-error`,"data-vault-locked-out":``,children:[`Too many wrong passwords — try again in `,Math.ceil(u/1e3),` s.`]})]}),(0,Q.jsxs)(`div`,{className:`divide-y divide-border rounded-lg border border-border`,children:[n.length===0&&(0,Q.jsx)(`p`,{className:`px-4 py-3 text-xs text-muted-foreground`,children:`No items yet.`}),n.map(e=>(0,Q.jsx)(de,{item:e,revealed:r?.id===e.id?r:null,onShow:()=>s.onShow(e),onHide:s.onHide,onEdit:()=>s.onEdit(e),onMove:()=>s.onMove(e),onDelete:()=>s.onDelete(e),onAddFile:()=>s.onAddFile(e),fileActions:s.fileActions},e.id))]}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Q.jsxs)(F,{className:`h-11 md:h-9`,onClick:s.onAdd,children:[(0,Q.jsx)(f,{className:`size-4`}),`Add`]}),(0,Q.jsxs)(F,{variant:`outline`,className:`h-11 md:h-9`,onClick:s.onChangePassword,children:[(0,Q.jsx)(d,{className:`size-4`}),`Change password`]}),(0,Q.jsxs)(F,{variant:`outline`,className:`h-11 md:h-9 text-error`,onClick:s.onDeleteTier,children:[(0,Q.jsx)(o,{className:`size-4`}),`Delete tier`]})]})]}):(0,Q.jsxs)(`section`,{className:`space-y-3`,"data-vault-tier":e,children:[(0,Q.jsx)(Y,{title:c,children:pe[e]}),(0,Q.jsxs)(F,{className:`h-11 md:h-9`,onClick:s.onEnable,children:[(0,Q.jsx)(y,{className:`size-4`}),`Turn on`]})]})}function he({prompt:e,onClose:t}){let[n,r]=(0,Z.useState)(``),[i,a]=(0,Z.useState)(!1),[o,s]=(0,Z.useState)(!1),[c,l]=(0,Z.useState)(null),[u,d]=(0,Z.useState)(!1),f=q(!!c?.lockedUntil);if((0,Z.useEffect)(()=>{r(``),a(!1),l(null),d(e?.askPassword??!1)},[e]),!e)return null;let p=(c?.lockedUntil??0)>f,m=!o&&!p&&(!u||n.length>0)&&(!e.acknowledge||i),h=async()=>{if(m){s(!0),l(null);try{await e.run(u?n:void 0),t()}catch(t){let n=R(t);n.needsPassword&&e.tier&&d(!0),l(n)}finally{s(!1)}}},g=c?K(c,f):null;return(0,Q.jsx)(J,{open:!0,onClose:()=>{o||t()},title:e.title,description:e.description,footer:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(F,{variant:`outline`,disabled:o,onClick:t,children:`Cancel`}),(0,Q.jsx)(F,{variant:e.danger?`destructive`:`default`,disabled:!m,onClick:()=>void h(),children:e.confirmLabel})]}),children:(0,Q.jsxs)(`form`,{className:`space-y-3`,onSubmit:e=>{e.preventDefault(),h()},children:[u&&e.tier&&(0,Q.jsx)(G,{label:`${P[e.tier]} tier password`,value:n,onChange:r,disabled:o,invalid:!!c}),e.acknowledge&&(0,Q.jsx)(B,{checked:i,onChange:a,disabled:o,dataAttr:`acknowledge`,children:e.acknowledge}),c&&(0,Q.jsxs)(`p`,{className:`text-xs text-error`,role:`alert`,children:[c.message,g&&` ${g}`]})]})})}function ge({edit:e,onClose:t,onDone:n}){let[r,i]=(0,Z.useState)(``),[a,o]=(0,Z.useState)(`other`),[s,c]=(0,Z.useState)(``),[l,u]=(0,Z.useState)(``),[d,f]=(0,Z.useState)(``),[p,m]=(0,Z.useState)(!1),[h,g]=(0,Z.useState)(!1),[_,v]=(0,Z.useState)(null),y=q(!!_?.lockedUntil);if((0,Z.useEffect)(()=>{i(e?.item?.name??``),o(e?.item?.kind??`other`),c(e?.value??``),u(``),f(``),m(e?.askPassword??!1),v(null)},[e]),!e)return null;let{tier:b,item:x}=e,S=b!==`public`,C=(_?.lockedUntil??0)>y,w=!h&&!C&&r.trim().length>0&&(x?!0:s.length>0)&&(!p||d.length>0),T=_?K(_,y):null,E=async()=>{if(!w)return;g(!0),v(null);let e=p?d:void 0;try{x?await V.updateItem(x.id,{name:r.trim(),kind:a,...s?{value:s}:{},...l?{note:l}:{}},e):await V.addItem({tier:b,name:r.trim(),kind:a,value:s,...l?{note:l}:{},password:e}),n(),t()}catch(e){let t=R(e);t.needsPassword&&S&&m(!0),v(t)}finally{g(!1)}};return(0,Q.jsx)(J,{open:!0,onClose:()=>{h||t()},title:`${x?`Edit`:`Add`} ${P[b]} item`,footer:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(F,{variant:`outline`,disabled:h,onClick:t,children:`Cancel`}),(0,Q.jsx)(F,{disabled:!w,onClick:()=>void E(),children:x?`Save`:`Add`})]}),children:(0,Q.jsxs)(`form`,{className:`space-y-3`,onSubmit:e=>{e.preventDefault(),E()},children:[b===`public`&&(0,Q.jsx)(W,{}),(0,Q.jsx)(z,{value:r,onChange:i,disabled:h}),b===`public`&&O(r)&&(0,Q.jsx)(ie,{}),(0,Q.jsx)(U,{value:a,onChange:o,disabled:h}),(0,Q.jsx)(ae,{value:s,onChange:c,disabled:h,masked:S,placeholder:x&&S?`New value (leave empty to keep the current one)`:`Value`}),(0,Q.jsx)(L,{"aria-label":`Note`,placeholder:x?`Note (leave empty to keep)`:`Note (optional)`,autoComplete:`off`,value:l,onChange:e=>u(e.target.value),disabled:h,className:`h-11 md:h-9`}),p&&S&&(0,Q.jsx)(G,{label:`${P[b]} tier password`,value:d,onChange:f,disabled:h,invalid:!!_}),_&&(0,Q.jsxs)(`p`,{className:`text-xs text-error`,role:`alert`,children:[_.message,T&&` ${T}`]})]})})}function _e({move:e,onClose:t,onDone:n}){let[r,i]=(0,Z.useState)(`secure`),[a,o]=(0,Z.useState)({}),[s,c]=(0,Z.useState)(!1),[l,u]=(0,Z.useState)(!1),[d,f]=(0,Z.useState)(null),p=q(!!d?.lockedUntil),m=t=>!!e&&t!==e.item.tier&&(t===`public`||e.enabled[t]);if((0,Z.useEffect)(()=>{i(w.find(m)??`public`),o({}),c(!1),f(null)},[e]),!e)return null;let h=[e.item.tier,r].filter(S).filter(t=>t===`sealed`||!e.secureOpen||s),g=(d?.lockedUntil??0)>p,_=!l&&!g&&m(r)&&h.every(e=>!!a[e]),v=d?K(d,p):null,y=async()=>{if(_){u(!0),f(null);try{let i={};for(let e of h)i[e]=a[e];await V.move(e.item.id,r,i),n(),t()}catch(e){let t=R(e);t.needsPassword&&c(!0),f(t)}finally{u(!1)}}};return(0,Q.jsx)(J,{open:!0,onClose:()=>{l||t()},title:`Move “${e.item.name}”`,description:`Now in the ${P[e.item.tier]} tier.`,footer:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(F,{variant:`outline`,disabled:l,onClick:t,children:`Cancel`}),(0,Q.jsx)(F,{disabled:!_,onClick:()=>void y(),children:`Move`})]}),children:(0,Q.jsxs)(`form`,{className:`space-y-3`,onSubmit:e=>{e.preventDefault(),y()},children:[(0,Q.jsx)(re,{value:r,onChange:i,enabled:m,disabled:l}),r===`public`&&(0,Q.jsx)(W,{}),h.map(e=>(0,Q.jsx)(G,{label:`${P[e]} tier password`,value:a[e]??``,onChange:t=>o(n=>({...n,[e]:t})),disabled:l,invalid:!!d},e)),d&&(0,Q.jsxs)(`p`,{className:`text-xs text-error`,role:`alert`,children:[d.message,v&&` ${v}`]})]})})}var ve=[`Too short`,`Weak`,`Fair`,`Good`,`Strong`];function ye(e,t){let n=[...e].length;if(n<t)return{score:0,label:ve[0]};let r=[/[a-z]/,/[A-Z]/,/\d/,/[^A-Za-z0-9]/].filter(t=>t.test(e)).length,i=new Set(e).size,a=1;(n>=t+4||r>=3)&&a++,n>=t*1.5&&r>=2&&a++,(n>=t*2||n>=t+4&&r>=4)&&a++,i<Math.min(6,n/2)&&(a=1);let o=Math.min(4,a);return{score:o,label:ve[o]}}var be=[`bg-error`,`bg-error`,`bg-warning`,`bg-success`,`bg-success`];function xe(e,t,n){let r=A[e];return[...t].length<r?`At least ${r} characters.`:t===n?null:`The two passwords differ.`}function Se({tier:e,password:t,confirm:n,onPassword:r,onConfirm:i,disabled:a,label:o=`New password`}){let s=A[e],c=ye(t,s),l=n.length>0&&n!==t;return(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(L,{type:`password`,autoComplete:`new-password`,spellCheck:!1,"aria-label":o,placeholder:o,value:t,onChange:e=>r(e.target.value),disabled:a,className:`h-11 md:h-9`}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,"data-vault-strength":c.score,children:[(0,Q.jsx)(`div`,{className:`flex flex-1 gap-1`,"aria-hidden":!0,children:[1,2,3,4].map(e=>(0,Q.jsx)(`span`,{className:x(`h-1.5 flex-1 rounded-full`,t&&c.score>=e?be[c.score]:`bg-panel-2`)},e))}),(0,Q.jsx)(`span`,{className:`w-20 text-right text-[11px] text-text-subtle`,children:t?c.label:`${s}+ characters`})]}),(0,Q.jsx)(L,{type:`password`,autoComplete:`new-password`,spellCheck:!1,"aria-label":`Type it again`,placeholder:`Type it again`,value:n,onChange:e=>i(e.target.value),disabled:a,"aria-invalid":l,className:`h-11 md:h-9`}),l&&(0,Q.jsx)(`p`,{className:`text-[11px] text-error`,children:`The two passwords differ.`})]})}function Ce(){return(0,Q.jsx)(`p`,{className:`rounded-md border border-error/50 bg-error/10 p-2 text-xs font-medium text-error`,"data-vault-forget-warning":``,children:`Forget this password and every item in this tier is lost for good; PPM cannot recover it.`})}function we({tier:e,onClose:t,onDone:n}){let[r,i]=(0,Z.useState)(``),[a,o]=(0,Z.useState)(``),[s,c]=(0,Z.useState)(!1),[l,u]=(0,Z.useState)(!1),[d,f]=(0,Z.useState)(null);if((0,Z.useEffect)(()=>{i(``),o(``),c(!1),f(null)},[e]),!e)return null;let p=xe(e,r,a),m=!l&&!p&&s,h=async()=>{if(m){u(!0),f(null);try{await V.enableTier(e,r),n(),t()}catch(e){f(R(e).message)}finally{u(!1)}}};return(0,Q.jsx)(J,{open:!0,onClose:()=>{l||t()},title:`Turn on the ${P[e]} tier`,description:e===`secure`?`Items here are encrypted. The AI reads them only after you type this password on a card.`:`Items here are encrypted under a second password. One item per card, shown to you unless you give it to the AI.`,footer:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(F,{variant:`outline`,disabled:l,onClick:t,children:`Cancel`}),(0,Q.jsx)(F,{disabled:!m,onClick:()=>void h(),children:`Turn on`})]}),children:(0,Q.jsxs)(`form`,{className:`space-y-3`,onSubmit:e=>{e.preventDefault(),h()},children:[(0,Q.jsx)(Se,{tier:e,password:r,confirm:a,onPassword:i,onConfirm:o,disabled:l,label:`${P[e]} tier password`}),e===`sealed`&&(0,Q.jsx)(`p`,{className:`text-xs text-text-secondary`,children:`This password must differ from the Secure tier's password.`}),(0,Q.jsx)(Ce,{}),(0,Q.jsx)(B,{checked:s,onChange:c,disabled:l,dataAttr:`forget-ack`,children:`I understand that PPM cannot recover this password or the items under it.`}),d&&(0,Q.jsx)(`p`,{className:`text-xs text-error`,role:`alert`,children:d})]})})}function Te({tier:e,onClose:t,onDone:n}){let[r,i]=(0,Z.useState)(``),[a,o]=(0,Z.useState)(``),[s,c]=(0,Z.useState)(``),[l,u]=(0,Z.useState)(!1),[d,f]=(0,Z.useState)(null),p=q(!!d?.lockedUntil);if((0,Z.useEffect)(()=>{i(``),o(``),c(``),f(null)},[e]),!e)return null;let m=(d?.lockedUntil??0)>p,h=!l&&!m&&r.length>0&&!xe(e,a,s),g=d?K(d,p):null,_=async()=>{if(h){u(!0),f(null);try{await V.changePassword(e,r,a),n(),t()}catch(e){f(R(e))}finally{u(!1)}}};return(0,Q.jsx)(J,{open:!0,onClose:()=>{l||t()},title:`Change the ${P[e]} tier password`,footer:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(F,{variant:`outline`,disabled:l,onClick:t,children:`Cancel`}),(0,Q.jsx)(F,{disabled:!h,onClick:()=>void _(),children:`Change password`})]}),children:(0,Q.jsxs)(`form`,{className:`space-y-3`,onSubmit:e=>{e.preventDefault(),_()},children:[(0,Q.jsx)(G,{label:`Current password`,value:r,onChange:i,disabled:l,invalid:!!d}),(0,Q.jsx)(Se,{tier:e,password:a,confirm:s,onPassword:o,onConfirm:c,disabled:l}),e===`sealed`&&(0,Q.jsx)(`p`,{className:`text-xs text-text-secondary`,children:`The new password must differ from the Secure tier's password.`}),(0,Q.jsx)(Ce,{}),d&&(0,Q.jsxs)(`p`,{className:`text-xs text-error`,role:`alert`,children:[d.message,g&&` ${g}`]})]})})}var Ee=/^image\/(jpeg|png|webp)$/,$=e=>Ee.test(e);function De(e,t,n=E){let r=Math.max(e,t);return r>n?n/r:1}async function Oe(e,t=E){if(!$(e.type))return{blob:e,name:e.name};let n=await createImageBitmap(e,{imageOrientation:`from-image`});try{let r=De(n.width,n.height,t),i=document.createElement(`canvas`);i.width=Math.max(1,Math.round(n.width*r)),i.height=Math.max(1,Math.round(n.height*r));let a=i.getContext(`2d`);if(!a)throw Error(`This browser could not prepare the photo. Tick “Keep the original” to upload it as it is.`);a.drawImage(n,0,0,i.width,i.height);let o=e.type===`image/png`?`image/png`:`image/jpeg`,s=await new Promise(e=>i.toBlob(e,o,.88));if(!s)throw Error(`This browser could not prepare the photo. Tick “Keep the original” to upload it as it is.`);return{blob:s,name:`${e.name.replace(/\.[^.]+$/,``)||`photo`}.${o===`image/png`?`png`:`jpg`}`}}finally{n.close()}}function ke({upload:e,onClose:t,onDone:n}){let[r,i]=(0,Z.useState)(null),[a,o]=(0,Z.useState)(``),[s,c]=(0,Z.useState)(!1),[l,u]=(0,Z.useState)(``),[d,f]=(0,Z.useState)(!1),[p,m]=(0,Z.useState)(!1),[h,_]=(0,Z.useState)(null),v=(0,Z.useRef)(null),y=q(!!h?.lockedUntil);if((0,Z.useEffect)(()=>{i(null),o(``),c(!1),u(``),f(e?.askPassword??!1),_(null)},[e]),!e)return null;let{item:b}=e,x=P[b.tier],S=(b.attachments?.length??0)>=10,w=(h?.lockedUntil??0)>y,T=!p&&!w&&!S&&!!r&&(!d||l.length>0),E=h?K(h,y):null,D=!!r&&(s||!$(r.type))&&r.size>10485760,O=async()=>{if(!(!T||!r||D)){m(!0),_(null);try{let e=s?{blob:r,name:r.name}:await Oe(r);await V.uploadFile(b.id,e.blob,e.name,{label:a.trim()||void 0,password:d?l:void 0}),n(),t()}catch(e){let t=R(e);t.needsPassword&&f(!0),_(t)}finally{m(!1)}}};return(0,Q.jsx)(J,{open:!0,onClose:()=>{p||t()},title:`Attach a file to “${b.name}”`,description:`Encrypted under the ${x} tier's key. Only you can open it, in PPM; no AI reads it.`,footer:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(F,{variant:`outline`,disabled:p,onClick:t,children:`Cancel`}),(0,Q.jsx)(F,{disabled:!T||D,onClick:()=>void O(),children:p?`Uploading…`:`Attach`})]}),children:(0,Q.jsxs)(`form`,{className:`space-y-3`,onSubmit:e=>{e.preventDefault(),O()},"data-vault-upload":``,children:[(0,Q.jsx)(`input`,{ref:v,type:`file`,accept:C.join(`,`),className:`sr-only`,"aria-label":`Choose a photo or PDF`,"data-vault-upload-input":``,onChange:e=>{i(e.target.files?.[0]??null),_(null),e.target.value=``}}),(0,Q.jsxs)(`button`,{type:`button`,disabled:p||S,onClick:()=>v.current?.click(),className:`flex min-h-20 w-full flex-col items-center justify-center gap-1 rounded-lg border border-dashed border-border px-3 py-3 text-center text-sm text-text-secondary can-hover:hover:bg-panel-2 disabled:opacity-50`,children:[(0,Q.jsx)(g,{className:`size-5`}),r?(0,Q.jsxs)(`span`,{className:`max-w-full truncate text-text-primary`,"data-vault-upload-chosen":``,children:[r.name,` · `,N(r.size)]}):(0,Q.jsx)(`span`,{children:`Choose a photo or PDF`}),(0,Q.jsxs)(`span`,{className:`text-[11px] text-text-subtle`,children:[`JPEG, PNG, WebP or PDF · up to `,M/(1024*1024),` MB · `,10,` per item`]})]}),S&&(0,Q.jsxs)(`p`,{className:`text-xs text-error`,children:[`This item already holds `,10,` files.`]}),(0,Q.jsx)(L,{"aria-label":`Label`,placeholder:`Label, e.g. Passport photo page (optional)`,autoComplete:`off`,maxLength:120,value:a,disabled:p,onChange:e=>o(e.target.value),className:`h-11 md:h-9`}),(0,Q.jsx)(`p`,{className:`text-[11px] text-text-subtle`,children:`The label is what lists and the AI see. The file's own name stays encrypted with the file.`}),r&&$(r.type)&&(0,Q.jsxs)(B,{checked:s,onChange:c,disabled:p,dataAttr:`keep-original`,children:[`Keep the original. Otherwise the photo is shrunk to `,2e3.toLocaleString(),` px and its EXIF (location, phone model) is removed before upload.`]}),D&&(0,Q.jsxs)(`p`,{className:`text-xs text-error`,children:[`This file is larger than `,10485760/(1024*1024),` MB.`]}),d&&(0,Q.jsx)(G,{label:`${x} tier password`,value:l,onChange:u,disabled:p,invalid:!!h}),h&&(0,Q.jsxs)(`p`,{className:`text-xs text-error`,role:`alert`,children:[h.message,E&&` ${E}`]})]})})}var Ae=e(r(),1);function je(e,t){let n=URL.createObjectURL(e),r=document.createElement(`a`);r.href=n,r.download=t,r.rel=`noopener`,document.body.appendChild(r),r.click(),r.remove(),setTimeout(()=>URL.revokeObjectURL(n),1e4)}function Me({view:e,onClose:t}){let n=q(!!e),[r,i]=(0,Z.useState)(null),a=e?.blob??null;(0,Z.useEffect)(()=>{if(!a)return;let e=URL.createObjectURL(a);return i(e),()=>{URL.revokeObjectURL(e),i(null)}},[a]),(0,Z.useEffect)(()=>{e&&n>=e.until&&t()},[e,n,t]),(0,Z.useEffect)(()=>{if(!e)return;let n=e=>{e.key===`Escape`&&t()};return window.addEventListener(`keydown`,n),()=>window.removeEventListener(`keydown`,n)},[e,t]);let o=e?.file.type===`application/pdf`,s=(0,Z.useMemo)(()=>!e||!r?null:o?(0,Q.jsx)(`iframe`,{title:e.file.label,src:r,className:`h-full w-full border-0 bg-white`,"data-vault-viewer-pdf":``}):(0,Q.jsx)(`img`,{src:r,alt:e.file.label,className:`max-h-full max-w-full object-contain`,"data-vault-viewer-image":``}),[e,r,o]);return e?(0,Ae.createPortal)((0,Q.jsxs)(`div`,{className:`fixed inset-0 z-[100] flex flex-col bg-black/95 text-white`,role:`dialog`,"aria-modal":`true`,"aria-label":e.file.label,"data-vault-viewer":``,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-white/10 px-3 py-2`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`p`,{className:`truncate text-sm font-medium`,children:e.file.label}),(0,Q.jsxs)(`p`,{className:`text-[11px] text-white/60`,children:[j[e.file.type],` · `,N(e.file.size)]})]}),(0,Q.jsx)(`span`,{className:`font-mono text-xs text-white/70`,"data-vault-viewer-countdown":``,children:H(e.until-n)}),(0,Q.jsx)(`button`,{type:`button`,onClick:t,"aria-label":`Close`,className:`inline-flex size-11 items-center justify-center rounded-lg can-hover:hover:bg-white/10`,children:(0,Q.jsx)(m,{className:`size-5`})})]}),(0,Q.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center p-2`,children:s}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 border-t border-white/10 px-3 py-2 pb-[max(0.5rem,env(safe-area-inset-bottom))]`,children:[(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>je(e.blob,e.fileName),className:`inline-flex h-11 items-center gap-2 rounded-lg border border-white/20 px-4 text-sm can-hover:hover:bg-white/10`,children:[(0,Q.jsx)(u,{className:`size-4`}),`Download`]}),(0,Q.jsx)(`p`,{className:`ml-auto text-[11px] text-white/60`,children:`Shown on this device only. No AI sees it; nothing is kept in the browser.`})]})]}),document.body):null}function Ne({file:e,onClose:t,onRename:n}){let[r,i]=(0,Z.useState)(e.label),a=r.trim(),o=a.length>0&&a!==e.label,s=()=>{o&&(t(),n(a))};return(0,Q.jsx)(J,{open:!0,onClose:t,title:`Rename file`,description:`The label is what lists and the AI see. Do not put a secret in it.`,footer:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(F,{variant:`outline`,onClick:t,children:`Cancel`}),(0,Q.jsx)(F,{disabled:!o,onClick:s,children:`Rename`})]}),children:(0,Q.jsx)(`form`,{onSubmit:e=>{e.preventDefault(),s()},children:(0,Q.jsx)(L,{"aria-label":`Label`,autoFocus:!0,autoComplete:`off`,maxLength:120,value:r,onChange:e=>i(e.target.value),className:`h-11 md:h-9`})})})}var Pe=[`ring-2`,`ring-primary`,`rounded-md`];function Fe(){let{data:e,error:t,refresh:n}=se(),[r,i]=(0,Z.useState)(null),[a,o]=(0,Z.useState)(null),[s,c]=(0,Z.useState)(null),[l,u]=(0,Z.useState)(null),[d,f]=(0,Z.useState)(null),[p,m]=(0,Z.useState)(null),[h,g]=(0,Z.useState)(null),[_,v]=(0,Z.useState)(null),[y,x]=(0,Z.useState)(null),S=q(!!e),C=(0,Z.useCallback)(()=>m(null),[]),w=(0,Z.useCallback)(()=>v(null),[]),E=ne(e=>e.itemId),[O,k]=(0,Z.useState)(null),A=!!e;if((0,Z.useEffect)(()=>{!A||!E||(ne.getState().clear(),k(E))},[A,E]),(0,Z.useEffect)(()=>{if(!O)return;let e=document.querySelector(`[data-vault-item="${CSS.escape(O)}"]`);if(!e){k(null);return}e.scrollIntoView({block:`center`,behavior:`smooth`}),e.classList.add(...Pe);let t=setTimeout(()=>k(null),4e3);return()=>{clearTimeout(t),e.classList.remove(...Pe)}},[O]),!e)return(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t??`Loading…`});let{status:j,items:M}=e,N=j.tiers.secure.settingsOpenUntil>S,F=e=>e===`sealed`||!N,I=()=>void n(),L=(e,t,n)=>{let r=async e=>{try{await t.run(e)}finally{I()}},a={...t,tier:e,run:r};if(e&&!n&&!F(e)){r(void 0).catch(e=>{let t=R(e);t.needsPassword?i({...a,askPassword:!0}):b.error(t.message)});return}i({...a,askPassword:e!==null&&F(e)})},z=e=>L(e.tier===`public`?null:e.tier,{title:`Delete “${e.name}”?`,description:`Deleted items stay in older backups until they expire.`,confirmLabel:`Delete`,danger:!0,run:async t=>{await V.deleteItem(e.id,t)}},!0),B=e=>c({item:e,enabled:{secure:j.tiers.secure.enabled,sealed:j.tiers.sealed.enabled},secureOpen:N}),H=e=>({onPreview:t=>L(e,{title:`Open “${t.label}”`,description:`Shown on this device for ${D/1e3} seconds. No AI sees it.`,confirmLabel:`Open`,run:async e=>{let{blob:n,fileName:r}=await V.openFile(t.id,{password:e});v({file:t,blob:n,fileName:r,until:Date.now()+D})}},!1),onDownload:t=>L(e,{title:`Download “${t.label}”`,description:`The file is saved decrypted to this device's downloads.`,confirmLabel:`Download`,run:async e=>{let{blob:n,fileName:r}=await V.openFile(t.id,{password:e,download:!0});je(n,r)}},e===`sealed`),onRename:e=>x(e),onDelete:t=>L(e,{title:`Delete “${t.label}”?`,description:`Deleted files stay in older backups until they expire.`,confirmLabel:`Delete`,danger:!0,run:async e=>{await V.deleteFile(t.id,e)}},!0)}),U=e=>({onEnable:()=>u(e),onAdd:()=>o({tier:e,askPassword:F(e)}),onShow:t=>L(e,{title:`Show “${t.name}”`,description:`Shown here for ${le/1e3} seconds.`,confirmLabel:`Show`,run:async e=>{let n=await V.reveal(t.id,e);m({id:t.id,value:n.value,until:Date.now()+le})}},!1),onHide:C,onEdit:t=>o({tier:e,item:t,askPassword:F(e)}),onMove:B,onDelete:z,onAddFile:t=>g({item:{...t,tier:e},askPassword:F(e)}),fileActions:H(e),onChangePassword:()=>f(e),onDeleteTier:()=>i({tier:e,askPassword:!0,title:`Delete the ${P[e]} tier?`,description:`The tier is turned off and every item and file in it is deleted. ${ee}`,confirmLabel:`Delete tier`,danger:!0,acknowledge:`Delete all ${j.tiers[e].itemCount} item${j.tiers[e].itemCount===1?``:`s`} in this tier for good.`,run:async t=>{try{await V.deleteTier(e,t??``)}finally{I()}}}),...e===`secure`?{onUnlock:()=>i({tier:e,askPassword:!0,title:`Unlock the Secure tier`,description:`Settings keeps it open for five minutes.`,confirmLabel:`Unlock`,run:async e=>{try{await V.unlockSecure(e??``)}finally{I()}}}),onLock:()=>{m(null),V.lock(`secure`).then(I,e=>b.error(R(e).message))}}:{}});return(0,Q.jsxs)(`div`,{className:`space-y-6`,children:[(0,Q.jsxs)(`p`,{className:`text-xs leading-relaxed text-muted-foreground`,children:[`Personal details the AI may need, kept in three tiers. The Secure and Sealed tiers are encrypted under passwords of their own, separate from PPM's password; neither password is stored, and a restart locks both. Deleted items stay in older backups until they expire.`,` `,te]}),(0,Q.jsx)(fe,{items:M.filter(e=>e.tier===`public`),values:e.publicValues,onAdd:()=>o({tier:`public`,askPassword:!1}),onEdit:t=>o({tier:`public`,item:t,value:e.publicValues[t.id],askPassword:!1}),onMove:B,onDelete:z}),T.map(e=>(0,Q.jsx)(me,{tier:e,status:j.tiers[e],items:M.filter(t=>t.tier===e),revealed:p,now:S,actions:U(e)},e)),(0,Q.jsx)(he,{prompt:r,onClose:()=>i(null)}),(0,Q.jsx)(ge,{edit:a,onClose:()=>o(null),onDone:I}),(0,Q.jsx)(_e,{move:s,onClose:()=>c(null),onDone:I}),(0,Q.jsx)(we,{tier:l,onClose:()=>u(null),onDone:I}),(0,Q.jsx)(Te,{tier:d,onClose:()=>f(null),onDone:I}),(0,Q.jsx)(ke,{upload:h,onClose:()=>g(null),onDone:I}),(0,Q.jsx)(Me,{view:_,onClose:w}),y&&(0,Q.jsx)(Ne,{file:y,onClose:()=>x(null),onRename:e=>{let t=M.find(e=>e.id===y.itemId)?.tier;!t||t===`public`||L(t,{title:`Rename “${y.label}”`,confirmLabel:`Rename`,run:async t=>{await V.renameFile(y.id,e,t)}},!1)}})]})}export{Fe as VaultSettingsSection};
1
+ import{s as e}from"./rolldown-runtime-C5c2KzVm.js";import{D as t,E as n}from"./vendor-markdown-26eoXJk7.js";import{yt as r}from"./vendor-ui-BQzUk4nq.js";import{Ar as i,Et as a,Xr as o,_t as s,d as c,er as l,ht as u,ln as d,lr as f,nr as p,pi as m,rn as h,ti as g,ut as _,vt as v,wn as y}from"./icons-CpR5Vw3J.js";import{j as b}from"./api-client-DSCscZEd.js";import{n as x}from"./utils-DMiycH3O.js";import"./portal-container-context-C84rlnJ6.js";import"./mobile-bottom-sheet-C78UMLrn.js";import"./use-visual-viewport-tMLO63yY.js";import"./use-is-mobile-CrfIt67b.js";import{D as S,a as C,b as w,f as T,g as E,i as D,k as O,l as k,m as A,n as ee,o as j,r as M,s as te,w as N,x as P}from"./vault-Q5oPy0h3.js";import{t as ne}from"./vault-focus-store-BYABW4-C.js";import{t as F}from"./button-CtdEWN7U.js";import"./dialog-BWXzvHlC.js";import{r as I}from"./clipboard-DQuoK2EM.js";import{t as L}from"./input-CCVoN0-P.js";import"./design-canvas-check-DAc84j07.js";import"./tab-open-protocol-D5UyfEsm.js";import"./vault-tool-call-DSMwzVDz.js";import{_ as R,a as z,f as B,g as V,h as H,i as U,n as W,o as re,p as G,r as ie,s as ae,t as oe,v as K,y as q}from"./vault-fields-DrhqcOc6.js";import{t as J}from"./design-responsive-dialog-CC557bnX.js";import{n as Y,t as X}from"./settings-rows-BnbnE7yp.js";var Z=e(t(),1);function se(){let[e,t]=(0,Z.useState)(null),[n,r]=(0,Z.useState)(null),i=(0,Z.useCallback)(async()=>{try{let[e,n]=await Promise.all([V.status(),V.items()]),i=n.filter(e=>e.tier===`public`),a=await Promise.all(i.map(e=>V.reveal(e.id).then(t=>[e.id,t.value])));t({status:e,items:n,publicValues:Object.fromEntries(a)}),r(null)}catch(e){r(R(e).message)}},[]);return(0,Z.useEffect)(()=>{i()},[i]),{data:e,error:n,refresh:i}}var Q=n();function ce({files:e,actions:t}){return e.length?(0,Q.jsx)(`ul`,{className:`mt-2 space-y-1.5`,"data-vault-files":``,children:e.map(e=>(0,Q.jsxs)(`li`,{className:`flex items-center gap-2 rounded-lg border border-border bg-panel-2/60 py-1 pl-2 pr-1`,"data-vault-file":e.id,children:[(0,Q.jsx)(`span`,{className:`flex size-9 shrink-0 items-center justify-center rounded-md bg-panel-2 text-text-secondary`,"aria-hidden":!0,children:e.type===`application/pdf`?(0,Q.jsx)(a,{className:`size-4`}):(0,Q.jsx)(h,{className:`size-4`})}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`p`,{className:`truncate text-sm`,children:e.label}),(0,Q.jsxs)(`p`,{className:`text-[11px] text-muted-foreground`,children:[j[e.type],` · `,N(e.size)]})]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0`,children:[(0,Q.jsx)(X,{label:`Preview ${e.label}`,onClick:()=>t.onPreview(e),children:(0,Q.jsx)(s,{className:`size-4`})}),(0,Q.jsx)(X,{label:`Download ${e.label}`,onClick:()=>t.onDownload(e),children:(0,Q.jsx)(u,{className:`size-4`})}),(0,Q.jsx)(X,{label:`Rename ${e.label}`,onClick:()=>t.onRename(e),children:(0,Q.jsx)(p,{className:`size-4`})}),(0,Q.jsx)(X,{label:`Delete ${e.label}`,danger:!0,onClick:()=>t.onDelete(e),children:(0,Q.jsx)(o,{className:`size-4`})})]})]},e.id))}):null}var le=3e4,ue=e=>new Date(e).toLocaleString(void 0,{dateStyle:`medium`,timeStyle:`short`});function de({item:e,publicValue:t,revealed:n,onShow:r,onHide:i,onEdit:a,onMove:u,onDelete:d,onAddFile:f,fileActions:m}){let h=q(!!n),[g,y]=(0,Z.useState)(!1),b=!!n&&n.until>h;(0,Z.useEffect)(()=>{n&&n.until<=h&&i?.()},[n,h,i]),(0,Z.useEffect)(()=>y(!1),[n]);let x=t??(b?n.value:null);return(0,Q.jsxs)(`div`,{className:`px-4 py-2`,"data-vault-item":e.id,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1 md:flex-row md:items-start md:gap-3`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsxs)(`p`,{className:`truncate text-sm`,children:[e.name,` `,(0,Q.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`· `,k[e.kind]]}),!!e.attachments?.length&&(0,Q.jsxs)(`span`,{className:`ml-1 inline-flex items-center gap-0.5 text-xs text-muted-foreground`,"data-vault-file-count":``,children:[`· `,(0,Q.jsx)(l,{className:`size-3`}),e.attachments.length]})]}),(0,Q.jsxs)(`p`,{className:`text-[11px] text-muted-foreground`,children:[`Updated `,ue(e.updatedAt)]})]}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-1 md:shrink-0`,children:[x!==null&&(0,Q.jsx)(X,{label:g?`Copied`:`Copy`,onClick:()=>void I(x).then(y),children:(0,Q.jsx)(_,{className:`size-4`})}),r&&(b?(0,Q.jsx)(X,{label:`Hide`,onClick:()=>i?.(),children:(0,Q.jsx)(v,{className:`size-4`})}):(0,Q.jsx)(X,{label:`Show`,onClick:r,children:(0,Q.jsx)(s,{className:`size-4`})})),(0,Q.jsx)(X,{label:`Edit`,onClick:a,children:(0,Q.jsx)(p,{className:`size-4`})}),f&&(0,Q.jsx)(X,{label:`Attach a photo or PDF`,onClick:f,children:(0,Q.jsx)(l,{className:`size-4`})}),(0,Q.jsx)(X,{label:`Move to another tier`,onClick:u,children:(0,Q.jsx)(c,{className:`size-4`})}),(0,Q.jsx)(X,{label:`Delete`,danger:!0,onClick:d,children:(0,Q.jsx)(o,{className:`size-4`})})]})]}),x!==null&&(0,Q.jsxs)(`div`,{className:`mt-1 flex items-start gap-2`,children:[(0,Q.jsx)(`code`,{className:`block max-h-60 min-w-0 flex-1 select-text overflow-auto whitespace-pre-wrap break-all rounded bg-panel-2 px-2 py-1 font-mono text-xs`,"data-vault-value":``,children:x}),b&&(0,Q.jsx)(`span`,{className:`shrink-0 pt-1 font-mono text-[11px] text-muted-foreground`,children:H(n.until-h)})]}),m&&e.attachments?.length?(0,Q.jsx)(ce,{files:e.attachments,actions:m}):null]})}function fe({items:e,values:t,onAdd:n,onEdit:r,onMove:i,onDelete:a}){return(0,Q.jsxs)(`section`,{className:`space-y-3`,"data-vault-tier":`public`,children:[(0,Q.jsx)(Y,{title:`Public`,children:oe}),(0,Q.jsxs)(`div`,{className:`divide-y divide-border rounded-lg border border-border`,children:[e.length===0&&(0,Q.jsx)(`p`,{className:`px-4 py-3 text-xs text-muted-foreground`,children:`No items yet.`}),e.map(e=>(0,Q.jsx)(de,{item:e,publicValue:t[e.id]??``,onEdit:()=>r(e),onMove:()=>i(e),onDelete:()=>a(e)},e.id))]}),(0,Q.jsxs)(F,{className:`h-11 md:h-9`,onClick:n,children:[(0,Q.jsx)(f,{className:`size-4`}),`Add`]})]})}var pe={secure:`Encrypted under its own password. The AI reads an item only after you type that password on a card in PPM, once or for a few minutes.`,sealed:`Encrypted under a second, separate password and never kept open. One item per card, shown to you unless you give it to the AI that once.`};function me({tier:e,status:t,items:n,revealed:r,now:a,actions:s}){let c=P[e],l=t.settingsOpenUntil-a,u=t.lockedUntil-a;return t.enabled?(0,Q.jsxs)(`section`,{className:`space-y-3`,"data-vault-tier":e,children:[(0,Q.jsx)(Y,{title:c,children:pe[e]}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs`,children:[e===`secure`&&(l>0?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-success/15 px-2 py-1 text-success`,"data-vault-unlocked":``,children:[(0,Q.jsx)(i,{className:`size-3.5`}),`Unlocked, `,H(l),` left`]}),(0,Q.jsx)(F,{variant:`outline`,className:`h-11 md:h-8`,onClick:s.onLock,children:`Lock now`})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-panel-2 px-2 py-1 text-text-secondary`,children:[(0,Q.jsx)(y,{className:`size-3.5`}),`Locked`]}),(0,Q.jsx)(F,{variant:`outline`,className:`h-11 md:h-8`,onClick:s.onUnlock,children:`Unlock for 5 minutes`})]})),e===`sealed`&&(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:`Asks for its password at every action.`}),u>0&&(0,Q.jsxs)(`span`,{className:`text-error`,"data-vault-locked-out":``,children:[`Too many wrong passwords — try again in `,Math.ceil(u/1e3),` s.`]})]}),(0,Q.jsxs)(`div`,{className:`divide-y divide-border rounded-lg border border-border`,children:[n.length===0&&(0,Q.jsx)(`p`,{className:`px-4 py-3 text-xs text-muted-foreground`,children:`No items yet.`}),n.map(e=>(0,Q.jsx)(de,{item:e,revealed:r?.id===e.id?r:null,onShow:()=>s.onShow(e),onHide:s.onHide,onEdit:()=>s.onEdit(e),onMove:()=>s.onMove(e),onDelete:()=>s.onDelete(e),onAddFile:()=>s.onAddFile(e),fileActions:s.fileActions},e.id))]}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Q.jsxs)(F,{className:`h-11 md:h-9`,onClick:s.onAdd,children:[(0,Q.jsx)(f,{className:`size-4`}),`Add`]}),(0,Q.jsxs)(F,{variant:`outline`,className:`h-11 md:h-9`,onClick:s.onChangePassword,children:[(0,Q.jsx)(d,{className:`size-4`}),`Change password`]}),(0,Q.jsxs)(F,{variant:`outline`,className:`h-11 md:h-9 text-error`,onClick:s.onDeleteTier,children:[(0,Q.jsx)(o,{className:`size-4`}),`Delete tier`]})]})]}):(0,Q.jsxs)(`section`,{className:`space-y-3`,"data-vault-tier":e,children:[(0,Q.jsx)(Y,{title:c,children:pe[e]}),(0,Q.jsxs)(F,{className:`h-11 md:h-9`,onClick:s.onEnable,children:[(0,Q.jsx)(y,{className:`size-4`}),`Turn on`]})]})}function he({prompt:e,onClose:t}){let[n,r]=(0,Z.useState)(``),[i,a]=(0,Z.useState)(!1),[o,s]=(0,Z.useState)(!1),[c,l]=(0,Z.useState)(null),[u,d]=(0,Z.useState)(!1),f=q(!!c?.lockedUntil);if((0,Z.useEffect)(()=>{r(``),a(!1),l(null),d(e?.askPassword??!1)},[e]),!e)return null;let p=(c?.lockedUntil??0)>f,m=!o&&!p&&(!u||n.length>0)&&(!e.acknowledge||i),h=async()=>{if(m){s(!0),l(null);try{await e.run(u?n:void 0),t()}catch(t){let n=R(t);n.needsPassword&&e.tier&&d(!0),l(n)}finally{s(!1)}}},g=c?K(c,f):null;return(0,Q.jsx)(J,{open:!0,onClose:()=>{o||t()},title:e.title,description:e.description,footer:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(F,{variant:`outline`,disabled:o,onClick:t,children:`Cancel`}),(0,Q.jsx)(F,{variant:e.danger?`destructive`:`default`,disabled:!m,onClick:()=>void h(),children:e.confirmLabel})]}),children:(0,Q.jsxs)(`form`,{className:`space-y-3`,onSubmit:e=>{e.preventDefault(),h()},children:[u&&e.tier&&(0,Q.jsx)(G,{label:`${P[e.tier]} tier password`,value:n,onChange:r,disabled:o,invalid:!!c}),e.acknowledge&&(0,Q.jsx)(B,{checked:i,onChange:a,disabled:o,dataAttr:`acknowledge`,children:e.acknowledge}),c&&(0,Q.jsxs)(`p`,{className:`text-xs text-error`,role:`alert`,children:[c.message,g&&` ${g}`]})]})})}function ge({edit:e,onClose:t,onDone:n}){let[r,i]=(0,Z.useState)(``),[a,o]=(0,Z.useState)(`other`),[s,c]=(0,Z.useState)(``),[l,u]=(0,Z.useState)(``),[d,f]=(0,Z.useState)(``),[p,m]=(0,Z.useState)(!1),[h,g]=(0,Z.useState)(!1),[_,v]=(0,Z.useState)(null),y=q(!!_?.lockedUntil);if((0,Z.useEffect)(()=>{i(e?.item?.name??``),o(e?.item?.kind??`other`),c(e?.value??``),u(``),f(``),m(e?.askPassword??!1),v(null)},[e]),!e)return null;let{tier:b,item:x}=e,S=b!==`public`,C=(_?.lockedUntil??0)>y,w=!h&&!C&&r.trim().length>0&&(x?!0:s.length>0)&&(!p||d.length>0),T=_?K(_,y):null,E=async()=>{if(!w)return;g(!0),v(null);let e=p?d:void 0;try{x?await V.updateItem(x.id,{name:r.trim(),kind:a,...s?{value:s}:{},...l?{note:l}:{}},e):await V.addItem({tier:b,name:r.trim(),kind:a,value:s,...l?{note:l}:{},password:e}),n(),t()}catch(e){let t=R(e);t.needsPassword&&S&&m(!0),v(t)}finally{g(!1)}};return(0,Q.jsx)(J,{open:!0,onClose:()=>{h||t()},title:`${x?`Edit`:`Add`} ${P[b]} item`,footer:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(F,{variant:`outline`,disabled:h,onClick:t,children:`Cancel`}),(0,Q.jsx)(F,{disabled:!w,onClick:()=>void E(),children:x?`Save`:`Add`})]}),children:(0,Q.jsxs)(`form`,{className:`space-y-3`,onSubmit:e=>{e.preventDefault(),E()},children:[b===`public`&&(0,Q.jsx)(W,{}),(0,Q.jsx)(z,{value:r,onChange:i,disabled:h}),b===`public`&&O(r)&&(0,Q.jsx)(ie,{}),(0,Q.jsx)(U,{value:a,onChange:o,disabled:h}),(0,Q.jsx)(ae,{value:s,onChange:c,disabled:h,masked:S,placeholder:x&&S?`New value (leave empty to keep the current one)`:`Value`}),(0,Q.jsx)(L,{"aria-label":`Note`,placeholder:x?`Note (leave empty to keep)`:`Note (optional)`,autoComplete:`off`,value:l,onChange:e=>u(e.target.value),disabled:h,className:`h-11 md:h-9`}),p&&S&&(0,Q.jsx)(G,{label:`${P[b]} tier password`,value:d,onChange:f,disabled:h,invalid:!!_}),_&&(0,Q.jsxs)(`p`,{className:`text-xs text-error`,role:`alert`,children:[_.message,T&&` ${T}`]})]})})}function _e({move:e,onClose:t,onDone:n}){let[r,i]=(0,Z.useState)(`secure`),[a,o]=(0,Z.useState)({}),[s,c]=(0,Z.useState)(!1),[l,u]=(0,Z.useState)(!1),[d,f]=(0,Z.useState)(null),p=q(!!d?.lockedUntil),m=t=>!!e&&t!==e.item.tier&&(t===`public`||e.enabled[t]);if((0,Z.useEffect)(()=>{i(w.find(m)??`public`),o({}),c(!1),f(null)},[e]),!e)return null;let h=[e.item.tier,r].filter(S).filter(t=>t===`sealed`||!e.secureOpen||s),g=(d?.lockedUntil??0)>p,_=!l&&!g&&m(r)&&h.every(e=>!!a[e]),v=d?K(d,p):null,y=async()=>{if(_){u(!0),f(null);try{let i={};for(let e of h)i[e]=a[e];await V.move(e.item.id,r,i),n(),t()}catch(e){let t=R(e);t.needsPassword&&c(!0),f(t)}finally{u(!1)}}};return(0,Q.jsx)(J,{open:!0,onClose:()=>{l||t()},title:`Move “${e.item.name}”`,description:`Now in the ${P[e.item.tier]} tier.`,footer:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(F,{variant:`outline`,disabled:l,onClick:t,children:`Cancel`}),(0,Q.jsx)(F,{disabled:!_,onClick:()=>void y(),children:`Move`})]}),children:(0,Q.jsxs)(`form`,{className:`space-y-3`,onSubmit:e=>{e.preventDefault(),y()},children:[(0,Q.jsx)(re,{value:r,onChange:i,enabled:m,disabled:l}),r===`public`&&(0,Q.jsx)(W,{}),h.map(e=>(0,Q.jsx)(G,{label:`${P[e]} tier password`,value:a[e]??``,onChange:t=>o(n=>({...n,[e]:t})),disabled:l,invalid:!!d},e)),d&&(0,Q.jsxs)(`p`,{className:`text-xs text-error`,role:`alert`,children:[d.message,v&&` ${v}`]})]})})}var ve=[`Too short`,`Weak`,`Fair`,`Good`,`Strong`];function ye(e,t){let n=[...e].length;if(n<t)return{score:0,label:ve[0]};let r=[/[a-z]/,/[A-Z]/,/\d/,/[^A-Za-z0-9]/].filter(t=>t.test(e)).length,i=new Set(e).size,a=1;(n>=t+4||r>=3)&&a++,n>=t*1.5&&r>=2&&a++,(n>=t*2||n>=t+4&&r>=4)&&a++,i<Math.min(6,n/2)&&(a=1);let o=Math.min(4,a);return{score:o,label:ve[o]}}var be=[`bg-error`,`bg-error`,`bg-warning`,`bg-success`,`bg-success`];function xe(e,t,n){let r=A[e];return[...t].length<r?`At least ${r} characters.`:t===n?null:`The two passwords differ.`}function Se({tier:e,password:t,confirm:n,onPassword:r,onConfirm:i,disabled:a,label:o=`New password`}){let s=A[e],c=ye(t,s),l=n.length>0&&n!==t;return(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(L,{type:`password`,autoComplete:`new-password`,spellCheck:!1,"aria-label":o,placeholder:o,value:t,onChange:e=>r(e.target.value),disabled:a,className:`h-11 md:h-9`}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,"data-vault-strength":c.score,children:[(0,Q.jsx)(`div`,{className:`flex flex-1 gap-1`,"aria-hidden":!0,children:[1,2,3,4].map(e=>(0,Q.jsx)(`span`,{className:x(`h-1.5 flex-1 rounded-full`,t&&c.score>=e?be[c.score]:`bg-panel-2`)},e))}),(0,Q.jsx)(`span`,{className:`w-20 text-right text-[11px] text-text-subtle`,children:t?c.label:`${s}+ characters`})]}),(0,Q.jsx)(L,{type:`password`,autoComplete:`new-password`,spellCheck:!1,"aria-label":`Type it again`,placeholder:`Type it again`,value:n,onChange:e=>i(e.target.value),disabled:a,"aria-invalid":l,className:`h-11 md:h-9`}),l&&(0,Q.jsx)(`p`,{className:`text-[11px] text-error`,children:`The two passwords differ.`})]})}function Ce(){return(0,Q.jsx)(`p`,{className:`rounded-md border border-error/50 bg-error/10 p-2 text-xs font-medium text-error`,"data-vault-forget-warning":``,children:`Forget this password and every item in this tier is lost for good; PPM cannot recover it.`})}function we({tier:e,onClose:t,onDone:n}){let[r,i]=(0,Z.useState)(``),[a,o]=(0,Z.useState)(``),[s,c]=(0,Z.useState)(!1),[l,u]=(0,Z.useState)(!1),[d,f]=(0,Z.useState)(null);if((0,Z.useEffect)(()=>{i(``),o(``),c(!1),f(null)},[e]),!e)return null;let p=xe(e,r,a),m=!l&&!p&&s,h=async()=>{if(m){u(!0),f(null);try{await V.enableTier(e,r),n(),t()}catch(e){f(R(e).message)}finally{u(!1)}}};return(0,Q.jsx)(J,{open:!0,onClose:()=>{l||t()},title:`Turn on the ${P[e]} tier`,description:e===`secure`?`Items here are encrypted. The AI reads them only after you type this password on a card.`:`Items here are encrypted under a second password. One item per card, shown to you unless you give it to the AI.`,footer:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(F,{variant:`outline`,disabled:l,onClick:t,children:`Cancel`}),(0,Q.jsx)(F,{disabled:!m,onClick:()=>void h(),children:`Turn on`})]}),children:(0,Q.jsxs)(`form`,{className:`space-y-3`,onSubmit:e=>{e.preventDefault(),h()},children:[(0,Q.jsx)(Se,{tier:e,password:r,confirm:a,onPassword:i,onConfirm:o,disabled:l,label:`${P[e]} tier password`}),e===`sealed`&&(0,Q.jsx)(`p`,{className:`text-xs text-text-secondary`,children:`This password must differ from the Secure tier's password.`}),(0,Q.jsx)(Ce,{}),(0,Q.jsx)(B,{checked:s,onChange:c,disabled:l,dataAttr:`forget-ack`,children:`I understand that PPM cannot recover this password or the items under it.`}),d&&(0,Q.jsx)(`p`,{className:`text-xs text-error`,role:`alert`,children:d})]})})}function Te({tier:e,onClose:t,onDone:n}){let[r,i]=(0,Z.useState)(``),[a,o]=(0,Z.useState)(``),[s,c]=(0,Z.useState)(``),[l,u]=(0,Z.useState)(!1),[d,f]=(0,Z.useState)(null),p=q(!!d?.lockedUntil);if((0,Z.useEffect)(()=>{i(``),o(``),c(``),f(null)},[e]),!e)return null;let m=(d?.lockedUntil??0)>p,h=!l&&!m&&r.length>0&&!xe(e,a,s),g=d?K(d,p):null,_=async()=>{if(h){u(!0),f(null);try{await V.changePassword(e,r,a),n(),t()}catch(e){f(R(e))}finally{u(!1)}}};return(0,Q.jsx)(J,{open:!0,onClose:()=>{l||t()},title:`Change the ${P[e]} tier password`,footer:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(F,{variant:`outline`,disabled:l,onClick:t,children:`Cancel`}),(0,Q.jsx)(F,{disabled:!h,onClick:()=>void _(),children:`Change password`})]}),children:(0,Q.jsxs)(`form`,{className:`space-y-3`,onSubmit:e=>{e.preventDefault(),_()},children:[(0,Q.jsx)(G,{label:`Current password`,value:r,onChange:i,disabled:l,invalid:!!d}),(0,Q.jsx)(Se,{tier:e,password:a,confirm:s,onPassword:o,onConfirm:c,disabled:l}),e===`sealed`&&(0,Q.jsx)(`p`,{className:`text-xs text-text-secondary`,children:`The new password must differ from the Secure tier's password.`}),(0,Q.jsx)(Ce,{}),d&&(0,Q.jsxs)(`p`,{className:`text-xs text-error`,role:`alert`,children:[d.message,g&&` ${g}`]})]})})}var Ee=/^image\/(jpeg|png|webp)$/,$=e=>Ee.test(e);function De(e,t,n=E){let r=Math.max(e,t);return r>n?n/r:1}async function Oe(e,t=E){if(!$(e.type))return{blob:e,name:e.name};let n=await createImageBitmap(e,{imageOrientation:`from-image`});try{let r=De(n.width,n.height,t),i=document.createElement(`canvas`);i.width=Math.max(1,Math.round(n.width*r)),i.height=Math.max(1,Math.round(n.height*r));let a=i.getContext(`2d`);if(!a)throw Error(`This browser could not prepare the photo. Tick “Keep the original” to upload it as it is.`);a.drawImage(n,0,0,i.width,i.height);let o=e.type===`image/png`?`image/png`:`image/jpeg`,s=await new Promise(e=>i.toBlob(e,o,.88));if(!s)throw Error(`This browser could not prepare the photo. Tick “Keep the original” to upload it as it is.`);return{blob:s,name:`${e.name.replace(/\.[^.]+$/,``)||`photo`}.${o===`image/png`?`png`:`jpg`}`}}finally{n.close()}}function ke({upload:e,onClose:t,onDone:n}){let[r,i]=(0,Z.useState)(null),[a,o]=(0,Z.useState)(``),[s,c]=(0,Z.useState)(!1),[l,u]=(0,Z.useState)(``),[d,f]=(0,Z.useState)(!1),[p,m]=(0,Z.useState)(!1),[h,_]=(0,Z.useState)(null),v=(0,Z.useRef)(null),y=q(!!h?.lockedUntil);if((0,Z.useEffect)(()=>{i(null),o(``),c(!1),u(``),f(e?.askPassword??!1),_(null)},[e]),!e)return null;let{item:b}=e,x=P[b.tier],S=(b.attachments?.length??0)>=10,w=(h?.lockedUntil??0)>y,T=!p&&!w&&!S&&!!r&&(!d||l.length>0),E=h?K(h,y):null,D=!!r&&(s||!$(r.type))&&r.size>10485760,O=async()=>{if(!(!T||!r||D)){m(!0),_(null);try{let e=s?{blob:r,name:r.name}:await Oe(r);await V.uploadFile(b.id,e.blob,e.name,{label:a.trim()||void 0,password:d?l:void 0}),n(),t()}catch(e){let t=R(e);t.needsPassword&&f(!0),_(t)}finally{m(!1)}}};return(0,Q.jsx)(J,{open:!0,onClose:()=>{p||t()},title:`Attach a file to “${b.name}”`,description:`Encrypted under the ${x} tier's key. Only you can open it, in PPM; no AI reads it.`,footer:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(F,{variant:`outline`,disabled:p,onClick:t,children:`Cancel`}),(0,Q.jsx)(F,{disabled:!T||D,onClick:()=>void O(),children:p?`Uploading…`:`Attach`})]}),children:(0,Q.jsxs)(`form`,{className:`space-y-3`,onSubmit:e=>{e.preventDefault(),O()},"data-vault-upload":``,children:[(0,Q.jsx)(`input`,{ref:v,type:`file`,accept:C.join(`,`),className:`sr-only`,"aria-label":`Choose a photo or PDF`,"data-vault-upload-input":``,onChange:e=>{i(e.target.files?.[0]??null),_(null),e.target.value=``}}),(0,Q.jsxs)(`button`,{type:`button`,disabled:p||S,onClick:()=>v.current?.click(),className:`flex min-h-20 w-full flex-col items-center justify-center gap-1 rounded-lg border border-dashed border-border px-3 py-3 text-center text-sm text-text-secondary can-hover:hover:bg-panel-2 disabled:opacity-50`,children:[(0,Q.jsx)(g,{className:`size-5`}),r?(0,Q.jsxs)(`span`,{className:`max-w-full truncate text-text-primary`,"data-vault-upload-chosen":``,children:[r.name,` · `,N(r.size)]}):(0,Q.jsx)(`span`,{children:`Choose a photo or PDF`}),(0,Q.jsxs)(`span`,{className:`text-[11px] text-text-subtle`,children:[`JPEG, PNG, WebP or PDF · up to `,M/(1024*1024),` MB · `,10,` per item`]})]}),S&&(0,Q.jsxs)(`p`,{className:`text-xs text-error`,children:[`This item already holds `,10,` files.`]}),(0,Q.jsx)(L,{"aria-label":`Label`,placeholder:`Label, e.g. Passport photo page (optional)`,autoComplete:`off`,maxLength:120,value:a,disabled:p,onChange:e=>o(e.target.value),className:`h-11 md:h-9`}),(0,Q.jsx)(`p`,{className:`text-[11px] text-text-subtle`,children:`The label is what lists and the AI see. The file's own name stays encrypted with the file.`}),r&&$(r.type)&&(0,Q.jsxs)(B,{checked:s,onChange:c,disabled:p,dataAttr:`keep-original`,children:[`Keep the original. Otherwise the photo is shrunk to `,2e3.toLocaleString(),` px and its EXIF (location, phone model) is removed before upload.`]}),D&&(0,Q.jsxs)(`p`,{className:`text-xs text-error`,children:[`This file is larger than `,10485760/(1024*1024),` MB.`]}),d&&(0,Q.jsx)(G,{label:`${x} tier password`,value:l,onChange:u,disabled:p,invalid:!!h}),h&&(0,Q.jsxs)(`p`,{className:`text-xs text-error`,role:`alert`,children:[h.message,E&&` ${E}`]})]})})}var Ae=e(r(),1);function je(e,t){let n=URL.createObjectURL(e),r=document.createElement(`a`);r.href=n,r.download=t,r.rel=`noopener`,document.body.appendChild(r),r.click(),r.remove(),setTimeout(()=>URL.revokeObjectURL(n),1e4)}function Me({view:e,onClose:t}){let n=q(!!e),[r,i]=(0,Z.useState)(null),a=e?.blob??null;(0,Z.useEffect)(()=>{if(!a)return;let e=URL.createObjectURL(a);return i(e),()=>{URL.revokeObjectURL(e),i(null)}},[a]),(0,Z.useEffect)(()=>{e&&n>=e.until&&t()},[e,n,t]),(0,Z.useEffect)(()=>{if(!e)return;let n=e=>{e.key===`Escape`&&t()};return window.addEventListener(`keydown`,n),()=>window.removeEventListener(`keydown`,n)},[e,t]);let o=e?.file.type===`application/pdf`,s=(0,Z.useMemo)(()=>!e||!r?null:o?(0,Q.jsx)(`iframe`,{title:e.file.label,src:r,className:`h-full w-full border-0 bg-white`,"data-vault-viewer-pdf":``}):(0,Q.jsx)(`img`,{src:r,alt:e.file.label,className:`max-h-full max-w-full object-contain`,"data-vault-viewer-image":``}),[e,r,o]);return e?(0,Ae.createPortal)((0,Q.jsxs)(`div`,{className:`fixed inset-0 z-[100] flex flex-col bg-black/95 text-white`,role:`dialog`,"aria-modal":`true`,"aria-label":e.file.label,"data-vault-viewer":``,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-white/10 px-3 py-2`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`p`,{className:`truncate text-sm font-medium`,children:e.file.label}),(0,Q.jsxs)(`p`,{className:`text-[11px] text-white/60`,children:[j[e.file.type],` · `,N(e.file.size)]})]}),(0,Q.jsx)(`span`,{className:`font-mono text-xs text-white/70`,"data-vault-viewer-countdown":``,children:H(e.until-n)}),(0,Q.jsx)(`button`,{type:`button`,onClick:t,"aria-label":`Close`,className:`inline-flex size-11 items-center justify-center rounded-lg can-hover:hover:bg-white/10`,children:(0,Q.jsx)(m,{className:`size-5`})})]}),(0,Q.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center p-2`,children:s}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 border-t border-white/10 px-3 py-2 pb-[max(0.5rem,env(safe-area-inset-bottom))]`,children:[(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>je(e.blob,e.fileName),className:`inline-flex h-11 items-center gap-2 rounded-lg border border-white/20 px-4 text-sm can-hover:hover:bg-white/10`,children:[(0,Q.jsx)(u,{className:`size-4`}),`Download`]}),(0,Q.jsx)(`p`,{className:`ml-auto text-[11px] text-white/60`,children:`Shown on this device only. No AI sees it; nothing is kept in the browser.`})]})]}),document.body):null}function Ne({file:e,onClose:t,onRename:n}){let[r,i]=(0,Z.useState)(e.label),a=r.trim(),o=a.length>0&&a!==e.label,s=()=>{o&&(t(),n(a))};return(0,Q.jsx)(J,{open:!0,onClose:t,title:`Rename file`,description:`The label is what lists and the AI see. Do not put a secret in it.`,footer:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(F,{variant:`outline`,onClick:t,children:`Cancel`}),(0,Q.jsx)(F,{disabled:!o,onClick:s,children:`Rename`})]}),children:(0,Q.jsx)(`form`,{onSubmit:e=>{e.preventDefault(),s()},children:(0,Q.jsx)(L,{"aria-label":`Label`,autoFocus:!0,autoComplete:`off`,maxLength:120,value:r,onChange:e=>i(e.target.value),className:`h-11 md:h-9`})})})}var Pe=[`ring-2`,`ring-primary`,`rounded-md`];function Fe(){let{data:e,error:t,refresh:n}=se(),[r,i]=(0,Z.useState)(null),[a,o]=(0,Z.useState)(null),[s,c]=(0,Z.useState)(null),[l,u]=(0,Z.useState)(null),[d,f]=(0,Z.useState)(null),[p,m]=(0,Z.useState)(null),[h,g]=(0,Z.useState)(null),[_,v]=(0,Z.useState)(null),[y,x]=(0,Z.useState)(null),S=q(!!e),C=(0,Z.useCallback)(()=>m(null),[]),w=(0,Z.useCallback)(()=>v(null),[]),E=ne(e=>e.itemId),[O,k]=(0,Z.useState)(null),A=!!e;if((0,Z.useEffect)(()=>{!A||!E||(ne.getState().clear(),k(E))},[A,E]),(0,Z.useEffect)(()=>{if(!O)return;let e=document.querySelector(`[data-vault-item="${CSS.escape(O)}"]`);if(!e){k(null);return}e.scrollIntoView({block:`center`,behavior:`smooth`}),e.classList.add(...Pe);let t=setTimeout(()=>k(null),4e3);return()=>{clearTimeout(t),e.classList.remove(...Pe)}},[O]),!e)return(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t??`Loading…`});let{status:j,items:M}=e,N=j.tiers.secure.settingsOpenUntil>S,F=e=>e===`sealed`||!N,I=()=>void n(),L=(e,t,n)=>{let r=async e=>{try{await t.run(e)}finally{I()}},a={...t,tier:e,run:r};if(e&&!n&&!F(e)){r(void 0).catch(e=>{let t=R(e);t.needsPassword?i({...a,askPassword:!0}):b.error(t.message)});return}i({...a,askPassword:e!==null&&F(e)})},z=e=>L(e.tier===`public`?null:e.tier,{title:`Delete “${e.name}”?`,description:`Deleted items stay in older backups until they expire.`,confirmLabel:`Delete`,danger:!0,run:async t=>{await V.deleteItem(e.id,t)}},!0),B=e=>c({item:e,enabled:{secure:j.tiers.secure.enabled,sealed:j.tiers.sealed.enabled},secureOpen:N}),H=e=>({onPreview:t=>L(e,{title:`Open “${t.label}”`,description:`Shown on this device for ${D/1e3} seconds. No AI sees it.`,confirmLabel:`Open`,run:async e=>{let{blob:n,fileName:r}=await V.openFile(t.id,{password:e});v({file:t,blob:n,fileName:r,until:Date.now()+D})}},!1),onDownload:t=>L(e,{title:`Download “${t.label}”`,description:`The file is saved decrypted to this device's downloads.`,confirmLabel:`Download`,run:async e=>{let{blob:n,fileName:r}=await V.openFile(t.id,{password:e,download:!0});je(n,r)}},e===`sealed`),onRename:e=>x(e),onDelete:t=>L(e,{title:`Delete “${t.label}”?`,description:`Deleted files stay in older backups until they expire.`,confirmLabel:`Delete`,danger:!0,run:async e=>{await V.deleteFile(t.id,e)}},!0)}),U=e=>({onEnable:()=>u(e),onAdd:()=>o({tier:e,askPassword:F(e)}),onShow:t=>L(e,{title:`Show “${t.name}”`,description:`Shown here for ${le/1e3} seconds.`,confirmLabel:`Show`,run:async e=>{let n=await V.reveal(t.id,e);m({id:t.id,value:n.value,until:Date.now()+le})}},!1),onHide:C,onEdit:t=>o({tier:e,item:t,askPassword:F(e)}),onMove:B,onDelete:z,onAddFile:t=>g({item:{...t,tier:e},askPassword:F(e)}),fileActions:H(e),onChangePassword:()=>f(e),onDeleteTier:()=>i({tier:e,askPassword:!0,title:`Delete the ${P[e]} tier?`,description:`The tier is turned off and every item and file in it is deleted. ${ee}`,confirmLabel:`Delete tier`,danger:!0,acknowledge:`Delete all ${j.tiers[e].itemCount} item${j.tiers[e].itemCount===1?``:`s`} in this tier for good.`,run:async t=>{try{await V.deleteTier(e,t??``)}finally{I()}}}),...e===`secure`?{onUnlock:()=>i({tier:e,askPassword:!0,title:`Unlock the Secure tier`,description:`Settings keeps it open for five minutes.`,confirmLabel:`Unlock`,run:async e=>{try{await V.unlockSecure(e??``)}finally{I()}}}),onLock:()=>{m(null),V.lock(`secure`).then(I,e=>b.error(R(e).message))}}:{}});return(0,Q.jsxs)(`div`,{className:`space-y-6`,children:[(0,Q.jsxs)(`p`,{className:`text-xs leading-relaxed text-muted-foreground`,children:[`Personal details the AI may need, kept in three tiers. The Secure and Sealed tiers are encrypted under passwords of their own, separate from PPM's password; neither password is stored, and a restart locks both. Deleted items stay in older backups until they expire.`,` `,te]}),(0,Q.jsx)(fe,{items:M.filter(e=>e.tier===`public`),values:e.publicValues,onAdd:()=>o({tier:`public`,askPassword:!1}),onEdit:t=>o({tier:`public`,item:t,value:e.publicValues[t.id],askPassword:!1}),onMove:B,onDelete:z}),T.map(e=>(0,Q.jsx)(me,{tier:e,status:j.tiers[e],items:M.filter(t=>t.tier===e),revealed:p,now:S,actions:U(e)},e)),(0,Q.jsx)(he,{prompt:r,onClose:()=>i(null)}),(0,Q.jsx)(ge,{edit:a,onClose:()=>o(null),onDone:I}),(0,Q.jsx)(_e,{move:s,onClose:()=>c(null),onDone:I}),(0,Q.jsx)(we,{tier:l,onClose:()=>u(null),onDone:I}),(0,Q.jsx)(Te,{tier:d,onClose:()=>f(null),onDone:I}),(0,Q.jsx)(ke,{upload:h,onClose:()=>g(null),onDone:I}),(0,Q.jsx)(Me,{view:_,onClose:w}),y&&(0,Q.jsx)(Ne,{file:y,onClose:()=>x(null),onRename:e=>{let t=M.find(e=>e.id===y.itemId)?.tier;!t||t===`public`||L(t,{title:`Rename “${y.label}”`,confirmLabel:`Rename`,run:async t=>{await V.renameFile(y.id,e,t)}},!1)}})]})}export{Fe as VaultSettingsSection};
@@ -1 +1 @@
1
- import{s as e}from"./rolldown-runtime-C5c2KzVm.js";import{t}from"./settings-store-DirmJxtu.js";import{D as n,E as r}from"./vendor-markdown-26eoXJk7.js";import"./vendor-ui-BQzUk4nq.js";import{$r as i,F as a,Fr as o,Nn as s,Pr as c,Sn as l,Xr as u,gr as d,ht as f,j as p,lr as m,pi as h,sr as g}from"./icons-CpR5Vw3J.js";import{a as _,j as v,r as y,v as b,y as x}from"./api-client-DSCscZEd.js";import{n as S}from"./utils-DMiycH3O.js";import"./window-store-Bl6ySrZZ.js";import"./panel-store-B5zTGca0.js";import{i as C}from"./project-store-BaGmhKos.js";import"./project-framework-store-vI8djw4a.js";import"./session-list-sync-triggers-_I5gGBSe.js";import"./vault-Q5oPy0h3.js";import"./session-collab-BD1AwcUC.js";import{t as w}from"./button-CtdEWN7U.js";import{t as T}from"./input-CCVoN0-P.js";import{i as E}from"./control-size-DFdAJqoq.js";import{t as D}from"./feature-intros-BNK1hj-A.js";import{i as O}from"./voice-message-CNThCsr3.js";import{a as k,c as A,n as j,t as M}from"./use-voice-message-recorder-BxjLFY10.js";import{Vn as N}from"./index-HeDx2wIm.js";import"./run-in-terminal-Bhp0sfyb.js";import{t as ee}from"./separator-TnMkIcEp.js";import{r as P}from"./settings-rows-Fw0kZHvj.js";import{t as te}from"./run-in-terminal-button-BP_KVP3Z.js";var F=e(n(),1),I=r();function L(e,t){let n=t.replace(/\s+/g,` `).trim();return!n||e.some(e=>e.toLowerCase()===n.toLowerCase())?null:[...e,n]}function R({words:e,learned:t=[],placeholder:n,busy:r,onWordsChange:i,onRemoveLearned:a}){let[o,s]=(0,F.useState)(``),l=()=>{let t=L(e,o);s(``),t&&i(t)};return(0,I.jsxs)(`div`,{className:`overflow-hidden rounded-xl border border-border bg-panel`,children:[(0,I.jsxs)(`div`,{className:`flex flex-wrap gap-1.5 px-3.5 py-3 max-md:gap-y-5`,children:[e.length===0&&t.length===0&&(0,I.jsx)(`span`,{className:`text-xs text-text-3`,children:`No words yet.`}),t.map(e=>(0,I.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 rounded-full border border-accent-2/40 bg-accent-2/10 py-0.5 pl-2.5 pr-1 font-mono text-[12.5px] text-text`,children:[(0,I.jsx)(c,{className:`size-3 shrink-0 text-accent-2`,"aria-label":`Learned`}),e.word,e.from&&(0,I.jsxs)(`span`,{className:`font-sans text-[11px] text-text-3`,children:[`← `,e.from]}),a&&(0,I.jsx)(z,{label:`Remove learned word ${e.word}`,disabled:r,onClick:()=>a(e.word)})]},`learned-${e.word}`)),e.map(t=>(0,I.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full border border-border-soft bg-panel-2 py-0.5 pl-2.5 pr-1 font-mono text-[12.5px] text-text`,children:[t,(0,I.jsx)(z,{label:`Remove ${t}`,disabled:r,onClick:()=>i(e.filter(e=>e!==t))})]},t))]}),t.length>0&&(0,I.jsxs)(`p`,{className:`flex items-center gap-1.5 px-3.5 pb-2 text-[11.5px] text-text-3`,children:[(0,I.jsx)(c,{className:`size-3 text-accent-2`}),`learned from your corrections`]}),(0,I.jsxs)(`form`,{className:`flex gap-2 px-3.5 pb-3`,onSubmit:e=>{e.preventDefault(),l()},children:[(0,I.jsx)(T,{value:o,onChange:e=>s(e.target.value),placeholder:n,"aria-label":n,disabled:r,className:`h-11 md:h-[34px]`}),(0,I.jsxs)(w,{type:`submit`,variant:`outline`,disabled:r||!o.trim(),className:`h-11 gap-1.5 md:h-[34px]`,children:[(0,I.jsx)(m,{className:`size-3.5`}),`Add`]})]})]})}function z({label:e,disabled:t,onClick:n}){return(0,I.jsx)(`button`,{type:`button`,onClick:n,disabled:t,"aria-label":e,title:e,className:`relative grid size-[18px] shrink-0 place-items-center rounded-full text-text-3 transition-colors before:absolute before:-inset-y-3.5 before:-inset-x-1 before:content-[''] can-hover:hover:bg-surface-hover can-hover:hover:text-text disabled:opacity-50 md:before:-inset-1`,children:(0,I.jsx)(h,{className:`size-3`})})}var B=10080*60*1e3;function V(e,t=new Date){let n=new Date(e);if(Number.isNaN(n.getTime()))return``;let r=e=>new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime(),i=Math.round((r(t)-r(n))/864e5);return i<=0?`today ${n.toTimeString().slice(0,5)}`:i===1?`yesterday`:i<7?n.toLocaleDateString(void 0,{weekday:`short`}):n.toLocaleDateString(void 0,{day:`numeric`,month:`short`})}function ne(e,t=new Date){let n=`learned ${V(e.at,t)}`;if(!e.lastUsedAt||e.lastUsedAt===e.at)return{text:n,title:n};let r=`used ${V(e.lastUsedAt,t)}`;return{text:r,title:`${n}, last ${r}`}}function re(e){return e.source===`cleanup`?`clean-up · ${e.hits??1}×`:e.source===`chat`?`chat · ${e.hits??1}×`:`your edit`}function ie(e){return e.source===`chat`?`chat · ${e.chats} of 3 chats or days`:`clean-up · seen ${e.hits}×`}function ae(e,t=new Date){let n=new Date(t.getFullYear(),t.getMonth(),t.getDate()).getTime();return e.filter(e=>Date.parse(e.at)>=n).map(e=>e.word)}function oe({learned:e,blocked:t,learning:n,busy:r,onUndo:a,onRestore:o,onSkip:s}){let[c,l]=(0,F.useState)(`week`),u=(0,F.useMemo)(()=>new Date,[e,t]),d=(0,F.useMemo)(()=>[...e].sort((e,t)=>t.at.localeCompare(e.at)),[e]),f=d.filter(e=>u.getTime()-Date.parse(e.at)<B),p=ae(e,u),m=c===`week`?f:d;return(0,I.jsxs)(`div`,{className:`overflow-hidden rounded-xl border border-border bg-panel`,"data-voice-learned-list":``,children:[(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 border-b border-border-soft px-3 py-2`,children:[(0,I.jsxs)(H,{active:c===`week`,onClick:()=>l(`week`),children:[`This week · `,f.length]}),(0,I.jsxs)(H,{active:c===`all`,onClick:()=>l(`all`),children:[`All · `,e.length]}),(0,I.jsxs)(H,{active:c===`learning`,onClick:()=>l(`learning`),children:[`Learning · `,n.length]}),(0,I.jsxs)(H,{active:c===`undone`,onClick:()=>l(`undone`),children:[`Undone · `,t.length]}),(0,I.jsx)(`span`,{className:`flex-1`}),(c===`week`||c===`all`)&&(0,I.jsxs)(w,{variant:`outline`,size:`sm`,disabled:r||p.length===0,onClick:()=>a(p),className:`h-11 w-full border-destructive/40 text-destructive md:h-[30px] md:w-auto`,children:[`Undo everything learned today`,p.length?` (${p.length})`:``]})]}),c===`learning`?n.length===0?(0,I.jsx)(U,{children:`Nothing being learned. A word the clean-up or the chat's AI read differently is counted here until it is learned.`}):(0,I.jsx)(`ul`,{children:n.map(e=>(0,I.jsx)(W,{word:e.to,heard:e.from,badge:ie(e),badgeTone:e.source===`chat`?`chat`:`cleanup`,when:{text:`seen ${V(e.at,u)}`,title:``},children:(0,I.jsx)(w,{variant:`outline`,size:`sm`,disabled:r,onClick:()=>s(e.to),className:`h-11 md:h-[30px]`,"aria-label":`Don't learn ${e.to}`,children:`Don't learn`})},`learning-${e.from}-${e.to}`))}):c===`undone`?t.length===0?(0,I.jsx)(U,{children:`Nothing undone. A word you undo stays here, and is never learned again until you restore it.`}):(0,I.jsx)(`ul`,{children:[...t].sort((e,t)=>t.at.localeCompare(e.at)).map(e=>(0,I.jsx)(W,{word:e.word,heard:e.from,badge:e.learning?.length?`not learned · Restore counts it again`:`undone · never again`,when:{text:`${e.learning?.length?`stopped`:`undone`} ${V(e.at,u)}`,title:``},dim:!0,children:(0,I.jsx)(w,{variant:`outline`,size:`sm`,disabled:r,onClick:()=>o(e.word),className:`h-11 md:h-[30px]`,children:`Restore`})},`blocked-${e.word}`))}):m.length===0?(0,I.jsx)(U,{children:c===`week`?`Nothing learned this week.`:`Nothing learned yet. Words appear here once the clean-up or the chat's AI has read them the same way a few times, or when you correct a transcript.`}):(0,I.jsx)(`ul`,{children:m.map(e=>(0,I.jsx)(W,{word:e.word,heard:e.from,badge:re(e),badgeTone:e.source===`cleanup`?`cleanup`:e.source===`chat`?`chat`:`edit`,when:ne(e,u),phrase:e.kind===`phrase`,children:(0,I.jsxs)(w,{variant:`outline`,size:`sm`,disabled:r,onClick:()=>a([e.word]),className:`h-11 gap-1.5 md:h-[30px]`,"aria-label":`Undo learned word ${e.word}`,children:[(0,I.jsx)(i,{className:`size-3.5`}),`Undo`]})},`learned-${e.word}`))})]})}function H({active:e,onClick:t,children:n}){return(0,I.jsx)(`button`,{type:`button`,onClick:t,"aria-pressed":e,className:S(`h-11 rounded-lg px-2.5 text-[12.5px] md:h-[30px]`,e?`bg-panel-2 text-text`:`text-text-2 hover:text-text`),children:n})}function U({children:e}){return(0,I.jsx)(`p`,{className:`px-4 py-4 text-xs leading-relaxed text-text-3`,children:e})}function W({word:e,heard:t,badge:n,badgeTone:r,when:i,dim:a,phrase:o,children:s}){return(0,I.jsxs)(`li`,{className:S(`grid grid-cols-[minmax(0,1fr)_auto] items-center gap-x-3 gap-y-1 border-t border-border-soft px-4 py-2.5 first:border-t-0`,`md:grid-cols-[minmax(0,1.2fr)_minmax(0,1fr)_auto_9.5rem_auto]`,a&&`text-text-dim`),children:[(0,I.jsx)(`span`,{className:`min-w-0 truncate text-sm font-semibold`,title:o?`Only the clean-up uses this one; Whisper is not told.`:void 0,children:e}),(0,I.jsx)(`span`,{className:`col-span-2 row-start-2 min-w-0 truncate text-[12.5px] text-text-3 line-through md:col-span-1 md:row-start-auto`,children:t}),(0,I.jsxs)(`span`,{className:`col-span-2 row-start-3 flex items-center gap-2 md:col-span-1 md:row-start-auto`,children:[(0,I.jsx)(`span`,{className:S(`whitespace-nowrap rounded-full border px-2 py-0.5 text-[10.5px]`,r===`cleanup`?`border-accent-2/40 text-accent-2`:r===`chat`?`border-info/40 text-info`:r===`edit`?`border-warning/40 text-warning`:`border-border text-text-3`),children:n}),(0,I.jsx)(`span`,{className:`text-xs text-text-3 md:hidden`,title:i.title||void 0,children:i.text})]}),(0,I.jsx)(`span`,{className:`hidden text-xs text-text-3 md:block`,title:i.title||void 0,children:i.text}),(0,I.jsx)(`span`,{className:`col-start-2 row-start-1 justify-self-end md:col-start-auto md:row-start-auto`,children:s})]})}var G={typed:{label:`your words`,dot:`bg-warning`,text:`text-text`},learned:{label:`learned`,dot:`bg-accent-2`,text:`text-text`},picked:{label:`picked up`,dot:`bg-primary`,text:`text-text-2`}},se=e=>e.reduce((e,t,n)=>e+t.word.length+(n?2:0),0);function ce({view:e,busy:t,projectSelect:n,save:r}){let i=e.selfLearning,a=Object.values(e.transcriptFix).includes(`haiku`);return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(K,{title:`Self-learning`,children:[(0,I.jsx)(P,{label:`Learn your words by itself`,note:`Without anyone editing a transcript, PPM picks up names and task codes for Whisper and learns a word once the clean-up or the chat's AI has read it the same way a few times. Learned words work at once; undo any of them below.`,checked:i,disabled:t,onChange:e=>r({selfLearning:e})}),i&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(P,{label:`Pick up words from the project`,note:`Project and chat names, recent task codes and titles, and CLAUDE.md terms, refreshed once a day. A project gets only its own words; the PPM Assistant gets every project's.`,checked:e.learnAutoVocabulary,disabled:t,onChange:e=>r({learnAutoVocabulary:e})}),(0,I.jsx)(P,{label:`Learn from the clean-up's corrections`,note:a?`A word the clean-up fixed the same way in three messages (two when the project already uses it) is learned, and one nobody says for 30 days leaves the list by itself. No extra Haiku call.`:`Needs the Haiku clean-up, which neither the chat box nor Telegram uses.`,checked:e.learnFromCleanup&&a,disabled:t||!a,onChange:e=>r({learnFromCleanup:e})}),(0,I.jsx)(P,{label:`Learn from how the AI read your words`,note:`A voice message sent as heard asks the AI to open its answer with "Hiểu là: heard → meant" when it read a word differently. The same reading in three messages is learned, and one nobody says for 30 days leaves the list by itself. No extra AI call.`,checked:e.learnFromChat,disabled:t,onChange:e=>r({learnFromChat:e})}),(0,I.jsx)(P,{label:`Weekly summary`,note:`Monday's morning digest lists the words learned that week. It asks nothing; undo here any time.`,checked:e.weeklySummary,disabled:t,onChange:e=>r({weeklySummary:e})})]})]}),i&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(K,{title:(0,I.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[`What Whisper hears first `,n]}),bare:!0,children:(0,I.jsx)(le,{words:e.whisperPrompt,max:e.whisperPromptMaxChars})}),(0,I.jsx)(K,{title:`Learned words · this project`,bare:!0,children:(0,I.jsx)(oe,{learned:e.projectLearned,blocked:e.projectBlocked,learning:e.projectLearning,busy:t,onUndo:e=>r({removeLearned:e}),onRestore:e=>r({restoreBlocked:[e]}),onSkip:e=>r({skipLearning:[e]})})})]})]})}function le({words:e,max:t}){let n=se(e),r=n=>e.filter(e=>e.source===n).reduce((e,t)=>e+t.word.length+2,0)/Math.max(t,1);return(0,I.jsxs)(`div`,{className:`overflow-hidden rounded-xl border border-border bg-panel`,"data-voice-prompt-preview":``,children:[(0,I.jsx)(`p`,{className:`break-words px-4 py-3 font-mono text-xs leading-relaxed`,children:e.length===0?(0,I.jsx)(`span`,{className:`text-text-3`,children:`Nothing yet: add words above, or wait for the first picked-up list.`}):e.map((t,n)=>(0,I.jsxs)(`span`,{className:G[t.source].text,children:[t.word,n<e.length-1?`, `:``]},`${n}:${t.word}`))}),(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1.5 border-t border-border-soft px-4 py-2.5 text-xs text-text-2`,children:[(0,I.jsxs)(`span`,{className:`font-mono`,children:[n,` / `,t,` characters`]}),(0,I.jsx)(`span`,{className:`flex h-1.5 min-w-24 flex-1 overflow-hidden rounded-full bg-panel-2`,"aria-hidden":!0,children:[`typed`,`learned`,`picked`].map(e=>(0,I.jsx)(`span`,{className:S(`h-full`,G[e].dot),style:{width:`${Math.min(100,r(e)*100)}%`}},e))}),(0,I.jsx)(`span`,{className:`flex flex-wrap gap-3`,children:[`typed`,`learned`,`picked`].map(e=>(0,I.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,I.jsx)(`span`,{className:S(`size-2 rounded-full`,G[e].dot)}),G[e].label]},e))})]})]})}function K({title:e,children:t,bare:n}){return(0,I.jsxs)(`section`,{children:[(0,I.jsx)(`div`,{className:`mb-2 text-[11px] font-semibold uppercase tracking-wider text-text-3`,children:e}),n?t:(0,I.jsx)(`div`,{className:`divide-y divide-border-soft overflow-hidden rounded-xl border border-border bg-panel`,children:t})]})}var ue=[{surface:`composer`,label:`Chat box`},{surface:`telegram`,label:`Telegram`}],de=[{value:`hints`,label:`As heard, with hints`},{value:`haiku`,label:`Tidy with Claude Haiku`}],fe=`As heard: Whisper's text goes as it is, with the words it misheard for you before attached for the AI that reads it — about 3 s sooner, no extra call. Claude Haiku: one call per message on your Claude account fixes misheard words and punctuation first, reading the last 8 messages, memory, CLAUDE.md and your word lists.`;function pe({value:e,disabled:t,onChange:n}){return(0,I.jsxs)(`div`,{className:`space-y-2.5 px-4 py-3`,"data-testid":`voice-transcript-fix`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`p`,{className:`text-sm`,children:`Misheard words`}),(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:fe})]}),ue.map(({surface:r,label:i})=>(0,I.jsxs)(`div`,{className:`flex flex-col gap-1.5 sm:flex-row sm:items-center sm:gap-3`,children:[(0,I.jsx)(`span`,{className:`w-20 shrink-0 text-xs font-medium text-text-2`,children:i}),(0,I.jsx)(`div`,{role:`radiogroup`,"aria-label":`${i}: misheard words`,className:`flex min-w-0 flex-1 gap-1.5`,children:de.map(i=>{let a=e[r]===i.value;return(0,I.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":a,disabled:t,"data-surface":r,"data-choice":i.value,onClick:()=>{a||n(r,i.value)},className:S(`h-11 min-w-0 flex-1 truncate rounded-lg border px-2.5 text-[12.5px] transition-colors md:h-8`,a?`border-accent-wash-border bg-accent-wash font-medium text-text`:`border-border bg-panel text-text-2 hover:bg-surface-hover`,t&&`cursor-default opacity-60`),children:i.label},i.value)})})]},r))]})}function me({onEnabledChange:e}){let t=C(e=>e.projects),n=C(e=>e.activeProject?.name),[r,i]=(0,F.useState)(()=>(n&&!x(n)?n:t[0]?.name)??`__assistant__`),[o,s]=(0,F.useState)(null),[c,l]=(0,F.useState)(!1),[u,d]=(0,F.useState)(!1),[f,p]=(0,F.useState)(0);N(`voice`,()=>p(e=>e+1)),(0,F.useEffect)(()=>{let e=!0,t=()=>k(r).then(t=>{e&&(s(t),l(!1))}).catch(()=>{e&&l(!0)});return t(),window.addEventListener(D,t),()=>{e=!1,window.removeEventListener(D,t)}},[r,f]),(0,F.useEffect)(()=>{o&&e?.(o.enabled)},[o,e]);let m=(0,F.useCallback)(async e=>{d(!0);try{s(await A({project:r,...e}))}catch(e){v.error(`Could not save the voice settings`,{description:e instanceof Error?e.message:String(e)})}finally{d(!1)}},[r]);if(c||!o)return null;let h=r===`__assistant__`?`PPM Assistant`:r,g=(0,I.jsxs)(`label`,{className:`relative inline-flex items-center`,children:[(0,I.jsxs)(`select`,{value:r,onChange:e=>i(e.target.value),"aria-label":`Project`,className:`h-11 appearance-none rounded-lg border border-border bg-panel py-0 pl-2.5 pr-7 text-[12.5px] font-medium normal-case tracking-normal text-text md:h-[30px]`,children:[t.filter(e=>!x(e.name)).map(e=>(0,I.jsx)(`option`,{value:e.name,children:e.name},e.name)),(0,I.jsx)(`option`,{value:b,children:`PPM Assistant`})]}),(0,I.jsx)(a,{className:`pointer-events-none absolute right-2 size-3 text-text-3`})]});return(0,I.jsxs)(`div`,{className:`space-y-6`,children:[(0,I.jsxs)(q,{title:`Voice messages`,children:[(0,I.jsx)(P,{label:`Voice messages`,note:`The mic in the chat box records a message and Whisper turns it into text on this host. Off: the mic dictates into the box as before.`,checked:o.enabled,disabled:u,onChange:e=>void m({enabled:e})}),o.enabled&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(P,{label:`Read the transcript before it is sent`,note:`Off: the transcript goes to the AI as soon as it is ready. When the clean-up fails it always waits for you.`,checked:o.reviewBeforeSend,disabled:u,onChange:e=>void m({reviewBeforeSend:e})}),(0,I.jsx)(pe,{value:o.transcriptFix,disabled:u,onChange:(e,t)=>void m({transcriptFix:{[e]:t}})}),Object.values(o.transcriptFix).includes(`haiku`)&&(0,I.jsx)(P,{label:`Fix Vietnamese words by context`,note:`The clean-up also fixes ordinary words Whisper misheard ("ta lệnh" → "ra lệnh") when the sentence makes the meaning clear. The Telegram card lists every word it changed.`,checked:o.vietnameseFixes,disabled:u,onChange:e=>void m({vietnameseFixes:e})}),(0,I.jsx)(J,{label:`Longest recording`,value:O(120)}),!o.whisperReady&&(0,I.jsx)(J,{label:`Whisper`,children:`Not installed on this host yet. Install it below; until then the mic offers the install.`})]})]}),o.enabled&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(q,{title:`Words · all projects`,bare:!0,children:(0,I.jsx)(R,{words:o.words,placeholder:`Add a word or name…`,busy:u,onWordsChange:e=>void m({words:e})})}),(0,I.jsx)(q,{bare:!0,title:(0,I.jsxs)(`span`,{className:`flex items-center gap-2`,children:[`Words · project`,g]}),children:(0,I.jsx)(R,{words:o.projectWords,learned:o.selfLearning?[]:o.projectLearned,placeholder:`Add a word for ${h}…`,busy:u,onWordsChange:e=>void m({projectWords:e}),onRemoveLearned:e=>void m({removeLearned:[e]})})}),(0,I.jsx)(ce,{view:o,busy:u,projectSelect:g,save:e=>void m(e)})]})]})}function q({title:e,children:t,bare:n}){return(0,I.jsxs)(`section`,{children:[(0,I.jsx)(`div`,{className:`mb-2 text-[11px] font-semibold uppercase tracking-wider text-text-3`,children:e}),n?t:(0,I.jsx)(`div`,{className:`divide-y divide-border-soft overflow-hidden rounded-xl border border-border bg-panel`,children:t})]})}function J({label:e,value:t,children:n}){return(0,I.jsxs)(`div`,{className:`flex min-h-11 items-center gap-3 px-4 py-2.5`,children:[(0,I.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,I.jsx)(`p`,{className:`text-sm`,children:e}),n&&(0,I.jsx)(`p`,{className:`text-xs leading-relaxed text-muted-foreground`,children:n})]}),t&&(0,I.jsx)(`span`,{className:`shrink-0 font-mono text-xs text-text-2`,children:t})]})}var Y=e=>`${Math.round(e/1e6)} MB`,he=e=>`${(e/1e9).toFixed(1)} GB`;function ge({gpu:e,cpuBytes:t,value:n,onChange:r}){if(!e.cudaBuild&&e.installedBuild!==`cuda`)return null;let i=e.cudaBuild?`Uses ${e.nvidia?.name??`the NVIDIA card`}: under a second per message. About ${he(e.cudaBuild.unpackedBytes)} on disk.`:`Installed, but no NVIDIA card that can use it answers right now.`;return(0,I.jsxs)(`div`,{className:`space-y-2`,children:[(0,I.jsx)(`p`,{className:`text-xs font-medium`,children:`Build`}),(0,I.jsxs)(`div`,{className:`flex flex-col sm:flex-row gap-2`,children:[(0,I.jsx)(X,{label:`CPU`,size:t?Y(t):null,note:`Works on any machine. A short message takes about 5 seconds.`,active:n===`cpu`,onClick:()=>r(`cpu`)}),(0,I.jsx)(X,{label:`GPU (NVIDIA)`,size:e.cudaBuild?Y(e.cudaBuild.bytes):null,note:i,active:n===`cuda`,onClick:()=>r(`cuda`)})]})]})}function X({label:e,size:t,note:n,active:r,onClick:i}){return(0,I.jsxs)(`button`,{type:`button`,onClick:i,"aria-pressed":r,className:S(`flex-1 rounded-lg border px-4 py-3 text-left transition-colors`,r?`border-primary ring-2 ring-primary`:`border-border hover:bg-muted/50`),children:[(0,I.jsxs)(`span`,{className:`flex items-center justify-between gap-3`,children:[(0,I.jsx)(`span`,{className:`text-sm font-medium`,children:e}),t&&(0,I.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:t})]}),(0,I.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:n})]})}var Z=e=>e.backend===`cuda`||e.backend===`metal`||e.backend===`gpu`;function _e(e){if(e.backend===null)return e.probing?`Checking whether it can use the GPU…`:`Not checked yet.`;if(Z(e)){let t=e.backend===`cuda`?`CUDA`:e.backend===`metal`?`Metal`:null,n=[e.device,t&&`(${t})`].filter(Boolean).join(` `);return e.useGpu?`Runs on the GPU${n?` — ${n}`:``}.`:`GPU turned off — runs on the CPU.`}return e.installedBuild===`cuda`?`The GPU build is installed but found no GPU it can use, so it runs on the CPU.`:`Runs on the CPU.`}function ve({status:e,onStatus:t}){let n=e.gpu,[r,i]=(0,F.useState)(!1);if(!e.ready||!n)return null;let a=async(e,n,r)=>{i(!0);try{t(await y.post(e,n))}catch(e){v.error(r??`Could not change the GPU setting`,{description:e instanceof Error?e.message:String(e)})}finally{i(!1)}},o=n.installedBuild===`cpu`&&n.cudaBuild;return(0,I.jsxs)(`div`,{className:`space-y-3 rounded-lg border border-border p-3`,children:[(0,I.jsxs)(`div`,{className:`space-y-1`,children:[(0,I.jsxs)(`p`,{className:`flex items-center gap-2 text-sm`,children:[n.probing&&(0,I.jsx)(l,{className:`size-3.5 animate-spin`}),_e(n)]}),o&&(0,I.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`This host has `,n.nvidia?.name??`an NVIDIA card`,`. Choose the GPU build below to transcribe in under a second.`]}),n.probeError&&n.installedBuild!==`cpu`&&(0,I.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Last check: `,n.probeError]})]}),Z(n)&&(0,I.jsx)(P,{label:`Use GPU`,note:`Off: Whisper leaves the GPU to other work and each message takes several seconds longer.`,checked:n.useGpu,disabled:r,onChange:e=>void a(`/api/speech/gpu`,{useGpu:e})}),n.lastFailure&&n.useGpu&&(0,I.jsxs)(`p`,{className:`text-xs text-warning`,children:[`The GPU failed on `,new Date(n.lastFailure.at).toLocaleString(),` (`,n.lastFailure.message,`), so that message was transcribed on the CPU instead.`]}),n.installedBuild!==`cpu`&&(0,I.jsxs)(w,{variant:`outline`,disabled:r||n.probing,onClick:()=>void a(`/api/speech/gpu/check`,void 0,`Could not check the GPU`),className:S(E,`cursor-pointer`),children:[r?(0,I.jsx)(l,{className:`size-3.5 animate-spin`}):(0,I.jsx)(d,{className:`size-3.5`}),`Check again`]})]})}var ye=`/whisper-test-sample.mp3`;async function Q(e,t,n){let r=_(),i=await fetch(`/api/speech/test?lang=${encodeURIComponent(t)}&device=${n}`,{method:`POST`,headers:{"Content-Type":`audio/wav`,...r?{Authorization:`Bearer ${r}`}:{}},body:e}),a=await i.json().catch(()=>null);if(!i.ok||!a?.ok||!a.data)throw Error(a?.error??`HTTP ${i.status}`);return a.data}function $(e){let t=e/1e3;return`${t<1?t.toFixed(2):t<10?t.toFixed(1):Math.round(t)} s`}function be(e,t){if(e<=0||t<=e)return null;let n=t/e;return`${n<10?n.toFixed(1):Math.round(n)}× faster on the GPU`}function xe(e){let t=e.backend===`cuda`?`CUDA`:e.backend===`metal`?`Metal`:null;return`${e.ranOn===`gpu`?`GPU${e.device?` — ${e.device}`:``}${t?` (${t})`:``}`:e.fellBack?`CPU (the GPU failed, so it ran again on the CPU)`:`CPU`} · ${e.model}`}var Se=`vi`;function Ce({status:e}){let[t,n]=(0,F.useState)(null),[r,i]=(0,F.useState)(null),[a,c]=(0,F.useState)(null),[u,d]=(0,F.useState)(null),[f,p]=(0,F.useState)(0),m=(0,F.useRef)(null),h=async(e,t)=>{m.current={wav:e,lang:t},i(null),c(null),d(null),n(`running`);try{i(await Q(e,t,`default`))}catch(e){d(e instanceof Error?e.message:String(e))}finally{n(null)}},_=M(e=>{n(`running`),j(e.blob).then(e=>h(e,Se)).catch(e=>{d(e instanceof Error?e.message:String(e)),n(null)})});(0,F.useEffect)(()=>{if(!_.recording)return;p(0);let e=Date.now(),t=setInterval(()=>p(Math.floor((Date.now()-e)/1e3)),250),n=setTimeout(()=>_.stop(),15*1e3);return()=>{clearInterval(t),clearTimeout(n)}},[_.recording]),(0,F.useEffect)(()=>()=>{m.current=null,_.cancel()},[]);let v=async()=>{d(null),n(`running`);try{await h(await j(await(await fetch(ye)).blob()),`en`)}catch(e){d(e instanceof Error?e.message:String(e)),n(null)}},y=async()=>{if(m.current){n(`comparing`),d(null);try{c(await Q(m.current.wav,m.current.lang,`cpu`))}catch(e){d(e instanceof Error?e.message:String(e))}finally{n(null)}}};if(!e.ready)return null;let b=_.supported&&typeof window<`u`&&window.isSecureContext,x=r?.ranOn===`gpu`,C=x&&a?be(r.ms,a.ms):null;return(0,I.jsxs)(`div`,{className:`space-y-3 rounded-lg border border-border p-3`,"data-testid":`whisper-test`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`p`,{className:`text-sm font-medium`,children:`Try it`}),(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Say a sentence and see what Whisper writes and how long it takes. The audio stays on this host and is deleted after the run.`})]}),(0,I.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[b&&(_.recording?(0,I.jsxs)(w,{onClick:_.stop,className:S(E,`cursor-pointer`),children:[(0,I.jsx)(o,{className:`size-3.5`}),`Stop · `,f,`s / `,15,`s`]}):(0,I.jsxs)(w,{onClick:()=>void _.start(),disabled:t!==null,className:S(E,`cursor-pointer`),children:[(0,I.jsx)(s,{className:`size-3.5`}),`Record a test`]})),(0,I.jsxs)(w,{variant:`outline`,onClick:()=>void v(),disabled:t!==null||_.recording,className:S(E,`cursor-pointer`),children:[(0,I.jsx)(g,{className:`size-3.5`}),`Use the sample (11 s, English)`]})]}),!b&&(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`The microphone needs HTTPS or localhost here, so only the sample can be used on this page.`}),t===`running`&&(0,I.jsxs)(`p`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,I.jsx)(l,{className:`size-3.5 animate-spin`}),` Transcribing on this host…`]}),u&&(0,I.jsx)(`p`,{className:`text-xs text-error`,children:u}),r&&(0,I.jsxs)(`div`,{className:`space-y-2 rounded-md bg-muted/50 p-3`,"data-testid":`whisper-test-result`,children:[(0,I.jsx)(`p`,{className:`text-sm break-words`,children:r.text||(0,I.jsx)(`span`,{className:`text-muted-foreground`,children:`(no speech heard)`})}),(0,I.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[(0,I.jsx)(`span`,{className:`font-medium text-foreground`,children:$(r.ms)}),` · `,xe(r)]}),a&&(0,I.jsxs)(`p`,{className:`text-xs text-muted-foreground`,"data-testid":`whisper-test-compare`,children:[`Same audio on the CPU: `,(0,I.jsx)(`span`,{className:`font-medium text-foreground`,children:$(a.ms)}),C?` — ${C}`:``]}),x&&!a&&(0,I.jsxs)(w,{variant:`outline`,onClick:()=>void y(),disabled:t!==null,className:S(E,`cursor-pointer`),children:[t===`comparing`&&(0,I.jsx)(l,{className:`size-3.5 animate-spin`}),t===`comparing`?`Running on the CPU…`:`Compare with the CPU`]})]})]})}var we={binary:`Downloading whisper.cpp`,model:`Downloading the model`,vad:`Downloading the voice detector`,verify:`Checking it runs here`,gpu:`Checking the GPU`};function Te(e,t){let n=e.gpu;return!n||n.installedBuild===`system`?null:t||(n.installedBuild?n.installedBuild:n.cudaBuild?`cuda`:`cpu`)}var Ee=e=>`${Math.round(e/1e6)} MB`;function De(){let e=t(e=>e.voiceEngine),n=t(e=>e.setVoiceEngine),[r,i]=(0,F.useState)(null),[a,o]=(0,F.useState)(!1),[s,c]=(0,F.useState)(null),[d,m]=(0,F.useState)(null),[h,g]=(0,F.useState)(!1),_=(0,F.useRef)(null),b=(0,F.useCallback)(async()=>{try{let e=await y.get(`/api/speech/status`);i(e),c(t=>t??e.model?.id??e.models.at(-1)?.id??null)}catch{}},[]);(0,F.useEffect)(()=>{b()},[b]);let x=!!r?.install&&!r.install.done,C=!!r?.gpu?.probing;(0,F.useEffect)(()=>{if(!(!x&&!C))return _.current=setTimeout(()=>void b(),700),()=>{_.current&&clearTimeout(_.current)}},[x,C,r,b]);let[T,E]=(0,F.useState)(!1),D=!!r?.installable;(0,F.useEffect)(()=>{if(!T||D)return;let e=setInterval(()=>{document.visibilityState===`visible`&&b()},4e3),t=setTimeout(()=>E(!1),10*6e4);return()=>{clearInterval(e),clearTimeout(t)}},[T,D,b]),(0,F.useEffect)(()=>{r&&!r.ready&&e===`whisper`&&n(`browser`)},[r,e,n]);let O=r?Te(r,d):null,k=async()=>{if(s){g(!0);try{await y.post(`/api/speech/install`,{model:s,...O?{build:O}:{}}),m(null),await b()}catch(e){v.error(`Could not start the install`,{description:e instanceof Error?e.message:String(e)})}finally{g(!1)}}},A=async()=>{g(!0);try{await y.post(`/api/speech/uninstall`),n(`browser`),await b()}catch(e){v.error(`Could not remove Whisper`,{description:e instanceof Error?e.message:String(e)})}finally{g(!1)}},j=r?.install??null,M=j&&j.totalBytes>0?Math.round(j.receivedBytes/j.totalBytes*100):null,N=r?.gpu?.installedBuild??null,P=!!O&&(N===`cpu`||N===`cuda`)&&O!==N,L=!!r?.model&&r.model.id!==s,R=O===`cuda`?`GPU build`:`CPU build`,z=r?.ready?L?`Switch to ${r.models.find(e=>e.id===s)?.label}${P?` (${R})`:``}`:P?`Switch to the ${R}`:`Installed`:`Install`,B=typeof window<`u`&&!window.isSecureContext;return(0,I.jsxs)(`div`,{className:`space-y-6`,children:[(0,I.jsx)(me,{onEnabledChange:o}),!a&&(0,I.jsxs)(`section`,{className:`space-y-3`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`h3`,{className:`text-sm font-medium`,children:`Speech to text`}),(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`What the mic button in the chat box uses. This device only.`})]}),(0,I.jsxs)(`div`,{className:`flex flex-col sm:flex-row gap-2`,children:[(0,I.jsx)(Oe,{label:`Browser`,note:`Text appears as you speak. Chrome, Edge and Safari only — the audio goes to their servers.`,value:`browser`,current:e,onChange:n}),r?.ready&&(0,I.jsx)(Oe,{label:`Whisper on this host`,note:`Works in any browser and the audio never leaves your machine. Text arrives when you stop talking.`,value:`whisper`,current:e,onChange:n})]}),B&&(0,I.jsx)(`p`,{className:`text-xs text-warning`,children:`This page is on plain HTTP, where browsers block the microphone entirely. Open PPM over HTTPS or on localhost to use either engine.`})]}),(0,I.jsx)(ee,{}),(0,I.jsxs)(`section`,{className:`space-y-3`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`h3`,{className:`text-sm font-medium`,children:`Whisper on this host`}),(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r?.ready?`Installed — whisper.cpp ${r.version}, model ${r.model?.label}.`:`Runs speech to text on the machine PPM is installed on. Nothing is sent to a cloud service.`})]}),r&&(0,I.jsx)(ve,{status:r,onStatus:i}),r&&!x&&(0,I.jsx)(Ce,{status:r}),r&&!r.installable&&(r.installHint?(0,I.jsxs)(`div`,{className:`space-y-2`,children:[(0,I.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`There is no prebuilt whisper.cpp for this platform, so it comes from Homebrew:`,` `,(0,I.jsx)(`code`,{className:`rounded bg-muted px-1 py-0.5`,children:r.installHint}),`. PPM types it into a terminal; press Enter there, and the models appear here once it is installed.`]}),(0,I.jsx)(te,{command:r.installHint,label:`Install with Homebrew`,onRun:()=>E(!0)})]}):(0,I.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`There is no prebuilt whisper.cpp for this platform. Install it yourself and PPM will find it:`,` `,(0,I.jsx)(`code`,{className:`rounded bg-muted px-1 py-0.5`,children:`whisper-cli on PATH`})]})),j&&!j.done&&(0,I.jsxs)(`div`,{className:`space-y-2`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,I.jsx)(l,{className:`size-3.5 animate-spin`}),(0,I.jsxs)(`span`,{children:[we[j.phase],j.phase===`binary`&&j.build===`cuda`?` (GPU build)`:``,M===null||j.phase===`gpu`?`…`:` — ${M}%`]})]}),(0,I.jsx)(`div`,{className:`h-1.5 w-full overflow-hidden rounded-full bg-muted`,children:(0,I.jsx)(`div`,{className:`h-full bg-primary transition-[width]`,style:{width:`${M??0}%`}})})]}),j?.error&&(0,I.jsx)(`p`,{className:`text-xs text-error`,children:j.error}),r?.installable&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`div`,{className:`space-y-2`,children:r.models.map(e=>{let t=s===e.id,n=r.model?.id===e.id;return(0,I.jsxs)(`button`,{type:`button`,onClick:()=>c(e.id),className:S(`w-full rounded-lg border px-4 py-3 text-left transition-colors`,t?`border-primary ring-2 ring-primary`:`border-border hover:bg-muted/50`),children:[(0,I.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,I.jsx)(`span`,{className:`text-sm font-medium`,children:e.label}),(0,I.jsxs)(`span`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[n&&(0,I.jsx)(p,{className:`size-3.5 text-success`}),Ee(e.bytes)]})]}),(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.note})]},e.id)})}),r.gpu&&O&&(0,I.jsx)(ge,{gpu:r.gpu,cpuBytes:r.cpuBuildBytes??null,value:O,onChange:m}),(0,I.jsxs)(`div`,{className:`flex flex-col sm:flex-row gap-2`,children:[(0,I.jsxs)(w,{onClick:k,disabled:h||x||!s||r.ready&&!L&&!P,className:`flex-1 gap-2 cursor-pointer`,children:[(0,I.jsx)(f,{className:`size-4`}),z]}),(r.model||r.binary?.source===`bundled`)&&(0,I.jsxs)(w,{variant:`outline`,onClick:A,disabled:h||x,className:`gap-2 cursor-pointer text-error`,children:[(0,I.jsx)(u,{className:`size-4`}),`Remove`]})]})]})]})]})}function Oe({label:e,note:t,value:n,current:r,onChange:i}){return(0,I.jsxs)(`button`,{type:`button`,onClick:()=>i(n),className:S(`flex-1 rounded-lg border px-4 py-3 text-left transition-colors`,r===n?`border-primary ring-2 ring-primary`:`border-border hover:bg-muted/50`),children:[(0,I.jsxs)(`span`,{className:`flex items-center gap-2 text-sm font-medium`,children:[(0,I.jsx)(s,{className:`size-4`}),e]}),(0,I.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:t})]})}export{De as VoiceSettingsSection};
1
+ import{s as e}from"./rolldown-runtime-C5c2KzVm.js";import{t}from"./settings-store-DirmJxtu.js";import{D as n,E as r}from"./vendor-markdown-26eoXJk7.js";import"./vendor-ui-BQzUk4nq.js";import{$r as i,F as a,Fr as o,Nn as s,Pr as c,Sn as l,Xr as u,gr as d,ht as f,j as p,lr as m,pi as h,sr as g}from"./icons-CpR5Vw3J.js";import{a as _,j as v,r as y,v as b,y as x}from"./api-client-DSCscZEd.js";import{n as S}from"./utils-DMiycH3O.js";import"./window-store-Bl6ySrZZ.js";import"./panel-store-B5zTGca0.js";import{i as C}from"./project-store-BaGmhKos.js";import"./project-framework-store-vI8djw4a.js";import"./session-list-sync-triggers-_I5gGBSe.js";import"./vault-Q5oPy0h3.js";import"./session-collab-BD1AwcUC.js";import{t as w}from"./button-CtdEWN7U.js";import{t as T}from"./input-CCVoN0-P.js";import{i as E}from"./control-size-DFdAJqoq.js";import{t as D}from"./feature-intros-CHJ2c-NE.js";import{i as O}from"./voice-message-CNThCsr3.js";import{a as k,c as A,n as j,t as M}from"./use-voice-message-recorder-BxjLFY10.js";import{Vn as N}from"./index-CToe9paM.js";import"./run-in-terminal-Bhp0sfyb.js";import{t as ee}from"./separator-TnMkIcEp.js";import{r as P}from"./settings-rows-BnbnE7yp.js";import{t as te}from"./run-in-terminal-button-BP_KVP3Z.js";var F=e(n(),1),I=r();function L(e,t){let n=t.replace(/\s+/g,` `).trim();return!n||e.some(e=>e.toLowerCase()===n.toLowerCase())?null:[...e,n]}function R({words:e,learned:t=[],placeholder:n,busy:r,onWordsChange:i,onRemoveLearned:a}){let[o,s]=(0,F.useState)(``),l=()=>{let t=L(e,o);s(``),t&&i(t)};return(0,I.jsxs)(`div`,{className:`overflow-hidden rounded-xl border border-border bg-panel`,children:[(0,I.jsxs)(`div`,{className:`flex flex-wrap gap-1.5 px-3.5 py-3 max-md:gap-y-5`,children:[e.length===0&&t.length===0&&(0,I.jsx)(`span`,{className:`text-xs text-text-3`,children:`No words yet.`}),t.map(e=>(0,I.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 rounded-full border border-accent-2/40 bg-accent-2/10 py-0.5 pl-2.5 pr-1 font-mono text-[12.5px] text-text`,children:[(0,I.jsx)(c,{className:`size-3 shrink-0 text-accent-2`,"aria-label":`Learned`}),e.word,e.from&&(0,I.jsxs)(`span`,{className:`font-sans text-[11px] text-text-3`,children:[`← `,e.from]}),a&&(0,I.jsx)(z,{label:`Remove learned word ${e.word}`,disabled:r,onClick:()=>a(e.word)})]},`learned-${e.word}`)),e.map(t=>(0,I.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full border border-border-soft bg-panel-2 py-0.5 pl-2.5 pr-1 font-mono text-[12.5px] text-text`,children:[t,(0,I.jsx)(z,{label:`Remove ${t}`,disabled:r,onClick:()=>i(e.filter(e=>e!==t))})]},t))]}),t.length>0&&(0,I.jsxs)(`p`,{className:`flex items-center gap-1.5 px-3.5 pb-2 text-[11.5px] text-text-3`,children:[(0,I.jsx)(c,{className:`size-3 text-accent-2`}),`learned from your corrections`]}),(0,I.jsxs)(`form`,{className:`flex gap-2 px-3.5 pb-3`,onSubmit:e=>{e.preventDefault(),l()},children:[(0,I.jsx)(T,{value:o,onChange:e=>s(e.target.value),placeholder:n,"aria-label":n,disabled:r,className:`h-11 md:h-[34px]`}),(0,I.jsxs)(w,{type:`submit`,variant:`outline`,disabled:r||!o.trim(),className:`h-11 gap-1.5 md:h-[34px]`,children:[(0,I.jsx)(m,{className:`size-3.5`}),`Add`]})]})]})}function z({label:e,disabled:t,onClick:n}){return(0,I.jsx)(`button`,{type:`button`,onClick:n,disabled:t,"aria-label":e,title:e,className:`relative grid size-[18px] shrink-0 place-items-center rounded-full text-text-3 transition-colors before:absolute before:-inset-y-3.5 before:-inset-x-1 before:content-[''] can-hover:hover:bg-surface-hover can-hover:hover:text-text disabled:opacity-50 md:before:-inset-1`,children:(0,I.jsx)(h,{className:`size-3`})})}var B=10080*60*1e3;function V(e,t=new Date){let n=new Date(e);if(Number.isNaN(n.getTime()))return``;let r=e=>new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime(),i=Math.round((r(t)-r(n))/864e5);return i<=0?`today ${n.toTimeString().slice(0,5)}`:i===1?`yesterday`:i<7?n.toLocaleDateString(void 0,{weekday:`short`}):n.toLocaleDateString(void 0,{day:`numeric`,month:`short`})}function ne(e,t=new Date){let n=`learned ${V(e.at,t)}`;if(!e.lastUsedAt||e.lastUsedAt===e.at)return{text:n,title:n};let r=`used ${V(e.lastUsedAt,t)}`;return{text:r,title:`${n}, last ${r}`}}function re(e){return e.source===`cleanup`?`clean-up · ${e.hits??1}×`:e.source===`chat`?`chat · ${e.hits??1}×`:`your edit`}function ie(e){return e.source===`chat`?`chat · ${e.chats} of 3 chats or days`:`clean-up · seen ${e.hits}×`}function ae(e,t=new Date){let n=new Date(t.getFullYear(),t.getMonth(),t.getDate()).getTime();return e.filter(e=>Date.parse(e.at)>=n).map(e=>e.word)}function oe({learned:e,blocked:t,learning:n,busy:r,onUndo:a,onRestore:o,onSkip:s}){let[c,l]=(0,F.useState)(`week`),u=(0,F.useMemo)(()=>new Date,[e,t]),d=(0,F.useMemo)(()=>[...e].sort((e,t)=>t.at.localeCompare(e.at)),[e]),f=d.filter(e=>u.getTime()-Date.parse(e.at)<B),p=ae(e,u),m=c===`week`?f:d;return(0,I.jsxs)(`div`,{className:`overflow-hidden rounded-xl border border-border bg-panel`,"data-voice-learned-list":``,children:[(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 border-b border-border-soft px-3 py-2`,children:[(0,I.jsxs)(H,{active:c===`week`,onClick:()=>l(`week`),children:[`This week · `,f.length]}),(0,I.jsxs)(H,{active:c===`all`,onClick:()=>l(`all`),children:[`All · `,e.length]}),(0,I.jsxs)(H,{active:c===`learning`,onClick:()=>l(`learning`),children:[`Learning · `,n.length]}),(0,I.jsxs)(H,{active:c===`undone`,onClick:()=>l(`undone`),children:[`Undone · `,t.length]}),(0,I.jsx)(`span`,{className:`flex-1`}),(c===`week`||c===`all`)&&(0,I.jsxs)(w,{variant:`outline`,size:`sm`,disabled:r||p.length===0,onClick:()=>a(p),className:`h-11 w-full border-destructive/40 text-destructive md:h-[30px] md:w-auto`,children:[`Undo everything learned today`,p.length?` (${p.length})`:``]})]}),c===`learning`?n.length===0?(0,I.jsx)(U,{children:`Nothing being learned. A word the clean-up or the chat's AI read differently is counted here until it is learned.`}):(0,I.jsx)(`ul`,{children:n.map(e=>(0,I.jsx)(W,{word:e.to,heard:e.from,badge:ie(e),badgeTone:e.source===`chat`?`chat`:`cleanup`,when:{text:`seen ${V(e.at,u)}`,title:``},children:(0,I.jsx)(w,{variant:`outline`,size:`sm`,disabled:r,onClick:()=>s(e.to),className:`h-11 md:h-[30px]`,"aria-label":`Don't learn ${e.to}`,children:`Don't learn`})},`learning-${e.from}-${e.to}`))}):c===`undone`?t.length===0?(0,I.jsx)(U,{children:`Nothing undone. A word you undo stays here, and is never learned again until you restore it.`}):(0,I.jsx)(`ul`,{children:[...t].sort((e,t)=>t.at.localeCompare(e.at)).map(e=>(0,I.jsx)(W,{word:e.word,heard:e.from,badge:e.learning?.length?`not learned · Restore counts it again`:`undone · never again`,when:{text:`${e.learning?.length?`stopped`:`undone`} ${V(e.at,u)}`,title:``},dim:!0,children:(0,I.jsx)(w,{variant:`outline`,size:`sm`,disabled:r,onClick:()=>o(e.word),className:`h-11 md:h-[30px]`,children:`Restore`})},`blocked-${e.word}`))}):m.length===0?(0,I.jsx)(U,{children:c===`week`?`Nothing learned this week.`:`Nothing learned yet. Words appear here once the clean-up or the chat's AI has read them the same way a few times, or when you correct a transcript.`}):(0,I.jsx)(`ul`,{children:m.map(e=>(0,I.jsx)(W,{word:e.word,heard:e.from,badge:re(e),badgeTone:e.source===`cleanup`?`cleanup`:e.source===`chat`?`chat`:`edit`,when:ne(e,u),phrase:e.kind===`phrase`,children:(0,I.jsxs)(w,{variant:`outline`,size:`sm`,disabled:r,onClick:()=>a([e.word]),className:`h-11 gap-1.5 md:h-[30px]`,"aria-label":`Undo learned word ${e.word}`,children:[(0,I.jsx)(i,{className:`size-3.5`}),`Undo`]})},`learned-${e.word}`))})]})}function H({active:e,onClick:t,children:n}){return(0,I.jsx)(`button`,{type:`button`,onClick:t,"aria-pressed":e,className:S(`h-11 rounded-lg px-2.5 text-[12.5px] md:h-[30px]`,e?`bg-panel-2 text-text`:`text-text-2 hover:text-text`),children:n})}function U({children:e}){return(0,I.jsx)(`p`,{className:`px-4 py-4 text-xs leading-relaxed text-text-3`,children:e})}function W({word:e,heard:t,badge:n,badgeTone:r,when:i,dim:a,phrase:o,children:s}){return(0,I.jsxs)(`li`,{className:S(`grid grid-cols-[minmax(0,1fr)_auto] items-center gap-x-3 gap-y-1 border-t border-border-soft px-4 py-2.5 first:border-t-0`,`md:grid-cols-[minmax(0,1.2fr)_minmax(0,1fr)_auto_9.5rem_auto]`,a&&`text-text-dim`),children:[(0,I.jsx)(`span`,{className:`min-w-0 truncate text-sm font-semibold`,title:o?`Only the clean-up uses this one; Whisper is not told.`:void 0,children:e}),(0,I.jsx)(`span`,{className:`col-span-2 row-start-2 min-w-0 truncate text-[12.5px] text-text-3 line-through md:col-span-1 md:row-start-auto`,children:t}),(0,I.jsxs)(`span`,{className:`col-span-2 row-start-3 flex items-center gap-2 md:col-span-1 md:row-start-auto`,children:[(0,I.jsx)(`span`,{className:S(`whitespace-nowrap rounded-full border px-2 py-0.5 text-[10.5px]`,r===`cleanup`?`border-accent-2/40 text-accent-2`:r===`chat`?`border-info/40 text-info`:r===`edit`?`border-warning/40 text-warning`:`border-border text-text-3`),children:n}),(0,I.jsx)(`span`,{className:`text-xs text-text-3 md:hidden`,title:i.title||void 0,children:i.text})]}),(0,I.jsx)(`span`,{className:`hidden text-xs text-text-3 md:block`,title:i.title||void 0,children:i.text}),(0,I.jsx)(`span`,{className:`col-start-2 row-start-1 justify-self-end md:col-start-auto md:row-start-auto`,children:s})]})}var G={typed:{label:`your words`,dot:`bg-warning`,text:`text-text`},learned:{label:`learned`,dot:`bg-accent-2`,text:`text-text`},picked:{label:`picked up`,dot:`bg-primary`,text:`text-text-2`}},se=e=>e.reduce((e,t,n)=>e+t.word.length+(n?2:0),0);function ce({view:e,busy:t,projectSelect:n,save:r}){let i=e.selfLearning,a=Object.values(e.transcriptFix).includes(`haiku`);return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(K,{title:`Self-learning`,children:[(0,I.jsx)(P,{label:`Learn your words by itself`,note:`Without anyone editing a transcript, PPM picks up names and task codes for Whisper and learns a word once the clean-up or the chat's AI has read it the same way a few times. Learned words work at once; undo any of them below.`,checked:i,disabled:t,onChange:e=>r({selfLearning:e})}),i&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(P,{label:`Pick up words from the project`,note:`Project and chat names, recent task codes and titles, and CLAUDE.md terms, refreshed once a day. A project gets only its own words; the PPM Assistant gets every project's.`,checked:e.learnAutoVocabulary,disabled:t,onChange:e=>r({learnAutoVocabulary:e})}),(0,I.jsx)(P,{label:`Learn from the clean-up's corrections`,note:a?`A word the clean-up fixed the same way in three messages (two when the project already uses it) is learned, and one nobody says for 30 days leaves the list by itself. No extra Haiku call.`:`Needs the Haiku clean-up, which neither the chat box nor Telegram uses.`,checked:e.learnFromCleanup&&a,disabled:t||!a,onChange:e=>r({learnFromCleanup:e})}),(0,I.jsx)(P,{label:`Learn from how the AI read your words`,note:`A voice message sent as heard asks the AI to open its answer with "Hiểu là: heard → meant" when it read a word differently. The same reading in three messages is learned, and one nobody says for 30 days leaves the list by itself. No extra AI call.`,checked:e.learnFromChat,disabled:t,onChange:e=>r({learnFromChat:e})}),(0,I.jsx)(P,{label:`Weekly summary`,note:`Monday's morning digest lists the words learned that week. It asks nothing; undo here any time.`,checked:e.weeklySummary,disabled:t,onChange:e=>r({weeklySummary:e})})]})]}),i&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(K,{title:(0,I.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[`What Whisper hears first `,n]}),bare:!0,children:(0,I.jsx)(le,{words:e.whisperPrompt,max:e.whisperPromptMaxChars})}),(0,I.jsx)(K,{title:`Learned words · this project`,bare:!0,children:(0,I.jsx)(oe,{learned:e.projectLearned,blocked:e.projectBlocked,learning:e.projectLearning,busy:t,onUndo:e=>r({removeLearned:e}),onRestore:e=>r({restoreBlocked:[e]}),onSkip:e=>r({skipLearning:[e]})})})]})]})}function le({words:e,max:t}){let n=se(e),r=n=>e.filter(e=>e.source===n).reduce((e,t)=>e+t.word.length+2,0)/Math.max(t,1);return(0,I.jsxs)(`div`,{className:`overflow-hidden rounded-xl border border-border bg-panel`,"data-voice-prompt-preview":``,children:[(0,I.jsx)(`p`,{className:`break-words px-4 py-3 font-mono text-xs leading-relaxed`,children:e.length===0?(0,I.jsx)(`span`,{className:`text-text-3`,children:`Nothing yet: add words above, or wait for the first picked-up list.`}):e.map((t,n)=>(0,I.jsxs)(`span`,{className:G[t.source].text,children:[t.word,n<e.length-1?`, `:``]},`${n}:${t.word}`))}),(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1.5 border-t border-border-soft px-4 py-2.5 text-xs text-text-2`,children:[(0,I.jsxs)(`span`,{className:`font-mono`,children:[n,` / `,t,` characters`]}),(0,I.jsx)(`span`,{className:`flex h-1.5 min-w-24 flex-1 overflow-hidden rounded-full bg-panel-2`,"aria-hidden":!0,children:[`typed`,`learned`,`picked`].map(e=>(0,I.jsx)(`span`,{className:S(`h-full`,G[e].dot),style:{width:`${Math.min(100,r(e)*100)}%`}},e))}),(0,I.jsx)(`span`,{className:`flex flex-wrap gap-3`,children:[`typed`,`learned`,`picked`].map(e=>(0,I.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,I.jsx)(`span`,{className:S(`size-2 rounded-full`,G[e].dot)}),G[e].label]},e))})]})]})}function K({title:e,children:t,bare:n}){return(0,I.jsxs)(`section`,{children:[(0,I.jsx)(`div`,{className:`mb-2 text-[11px] font-semibold uppercase tracking-wider text-text-3`,children:e}),n?t:(0,I.jsx)(`div`,{className:`divide-y divide-border-soft overflow-hidden rounded-xl border border-border bg-panel`,children:t})]})}var ue=[{surface:`composer`,label:`Chat box`},{surface:`telegram`,label:`Telegram`}],de=[{value:`hints`,label:`As heard, with hints`},{value:`haiku`,label:`Tidy with Claude Haiku`}],fe=`As heard: Whisper's text goes as it is, with the words it misheard for you before attached for the AI that reads it — about 3 s sooner, no extra call. Claude Haiku: one call per message on your Claude account fixes misheard words and punctuation first, reading the last 8 messages, memory, CLAUDE.md and your word lists.`;function pe({value:e,disabled:t,onChange:n}){return(0,I.jsxs)(`div`,{className:`space-y-2.5 px-4 py-3`,"data-testid":`voice-transcript-fix`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`p`,{className:`text-sm`,children:`Misheard words`}),(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:fe})]}),ue.map(({surface:r,label:i})=>(0,I.jsxs)(`div`,{className:`flex flex-col gap-1.5 sm:flex-row sm:items-center sm:gap-3`,children:[(0,I.jsx)(`span`,{className:`w-20 shrink-0 text-xs font-medium text-text-2`,children:i}),(0,I.jsx)(`div`,{role:`radiogroup`,"aria-label":`${i}: misheard words`,className:`flex min-w-0 flex-1 gap-1.5`,children:de.map(i=>{let a=e[r]===i.value;return(0,I.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":a,disabled:t,"data-surface":r,"data-choice":i.value,onClick:()=>{a||n(r,i.value)},className:S(`h-11 min-w-0 flex-1 truncate rounded-lg border px-2.5 text-[12.5px] transition-colors md:h-8`,a?`border-accent-wash-border bg-accent-wash font-medium text-text`:`border-border bg-panel text-text-2 hover:bg-surface-hover`,t&&`cursor-default opacity-60`),children:i.label},i.value)})})]},r))]})}function me({onEnabledChange:e}){let t=C(e=>e.projects),n=C(e=>e.activeProject?.name),[r,i]=(0,F.useState)(()=>(n&&!x(n)?n:t[0]?.name)??`__assistant__`),[o,s]=(0,F.useState)(null),[c,l]=(0,F.useState)(!1),[u,d]=(0,F.useState)(!1),[f,p]=(0,F.useState)(0);N(`voice`,()=>p(e=>e+1)),(0,F.useEffect)(()=>{let e=!0,t=()=>k(r).then(t=>{e&&(s(t),l(!1))}).catch(()=>{e&&l(!0)});return t(),window.addEventListener(D,t),()=>{e=!1,window.removeEventListener(D,t)}},[r,f]),(0,F.useEffect)(()=>{o&&e?.(o.enabled)},[o,e]);let m=(0,F.useCallback)(async e=>{d(!0);try{s(await A({project:r,...e}))}catch(e){v.error(`Could not save the voice settings`,{description:e instanceof Error?e.message:String(e)})}finally{d(!1)}},[r]);if(c||!o)return null;let h=r===`__assistant__`?`PPM Assistant`:r,g=(0,I.jsxs)(`label`,{className:`relative inline-flex items-center`,children:[(0,I.jsxs)(`select`,{value:r,onChange:e=>i(e.target.value),"aria-label":`Project`,className:`h-11 appearance-none rounded-lg border border-border bg-panel py-0 pl-2.5 pr-7 text-[12.5px] font-medium normal-case tracking-normal text-text md:h-[30px]`,children:[t.filter(e=>!x(e.name)).map(e=>(0,I.jsx)(`option`,{value:e.name,children:e.name},e.name)),(0,I.jsx)(`option`,{value:b,children:`PPM Assistant`})]}),(0,I.jsx)(a,{className:`pointer-events-none absolute right-2 size-3 text-text-3`})]});return(0,I.jsxs)(`div`,{className:`space-y-6`,children:[(0,I.jsxs)(q,{title:`Voice messages`,children:[(0,I.jsx)(P,{label:`Voice messages`,note:`The mic in the chat box records a message and Whisper turns it into text on this host. Off: the mic dictates into the box as before.`,checked:o.enabled,disabled:u,onChange:e=>void m({enabled:e})}),o.enabled&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(P,{label:`Read the transcript before it is sent`,note:`Off: the transcript goes to the AI as soon as it is ready. When the clean-up fails it always waits for you.`,checked:o.reviewBeforeSend,disabled:u,onChange:e=>void m({reviewBeforeSend:e})}),(0,I.jsx)(pe,{value:o.transcriptFix,disabled:u,onChange:(e,t)=>void m({transcriptFix:{[e]:t}})}),Object.values(o.transcriptFix).includes(`haiku`)&&(0,I.jsx)(P,{label:`Fix Vietnamese words by context`,note:`The clean-up also fixes ordinary words Whisper misheard ("ta lệnh" → "ra lệnh") when the sentence makes the meaning clear. The Telegram card lists every word it changed.`,checked:o.vietnameseFixes,disabled:u,onChange:e=>void m({vietnameseFixes:e})}),(0,I.jsx)(J,{label:`Longest recording`,value:O(120)}),!o.whisperReady&&(0,I.jsx)(J,{label:`Whisper`,children:`Not installed on this host yet. Install it below; until then the mic offers the install.`})]})]}),o.enabled&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(q,{title:`Words · all projects`,bare:!0,children:(0,I.jsx)(R,{words:o.words,placeholder:`Add a word or name…`,busy:u,onWordsChange:e=>void m({words:e})})}),(0,I.jsx)(q,{bare:!0,title:(0,I.jsxs)(`span`,{className:`flex items-center gap-2`,children:[`Words · project`,g]}),children:(0,I.jsx)(R,{words:o.projectWords,learned:o.selfLearning?[]:o.projectLearned,placeholder:`Add a word for ${h}…`,busy:u,onWordsChange:e=>void m({projectWords:e}),onRemoveLearned:e=>void m({removeLearned:[e]})})}),(0,I.jsx)(ce,{view:o,busy:u,projectSelect:g,save:e=>void m(e)})]})]})}function q({title:e,children:t,bare:n}){return(0,I.jsxs)(`section`,{children:[(0,I.jsx)(`div`,{className:`mb-2 text-[11px] font-semibold uppercase tracking-wider text-text-3`,children:e}),n?t:(0,I.jsx)(`div`,{className:`divide-y divide-border-soft overflow-hidden rounded-xl border border-border bg-panel`,children:t})]})}function J({label:e,value:t,children:n}){return(0,I.jsxs)(`div`,{className:`flex min-h-11 items-center gap-3 px-4 py-2.5`,children:[(0,I.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,I.jsx)(`p`,{className:`text-sm`,children:e}),n&&(0,I.jsx)(`p`,{className:`text-xs leading-relaxed text-muted-foreground`,children:n})]}),t&&(0,I.jsx)(`span`,{className:`shrink-0 font-mono text-xs text-text-2`,children:t})]})}var Y=e=>`${Math.round(e/1e6)} MB`,he=e=>`${(e/1e9).toFixed(1)} GB`;function ge({gpu:e,cpuBytes:t,value:n,onChange:r}){if(!e.cudaBuild&&e.installedBuild!==`cuda`)return null;let i=e.cudaBuild?`Uses ${e.nvidia?.name??`the NVIDIA card`}: under a second per message. About ${he(e.cudaBuild.unpackedBytes)} on disk.`:`Installed, but no NVIDIA card that can use it answers right now.`;return(0,I.jsxs)(`div`,{className:`space-y-2`,children:[(0,I.jsx)(`p`,{className:`text-xs font-medium`,children:`Build`}),(0,I.jsxs)(`div`,{className:`flex flex-col sm:flex-row gap-2`,children:[(0,I.jsx)(X,{label:`CPU`,size:t?Y(t):null,note:`Works on any machine. A short message takes about 5 seconds.`,active:n===`cpu`,onClick:()=>r(`cpu`)}),(0,I.jsx)(X,{label:`GPU (NVIDIA)`,size:e.cudaBuild?Y(e.cudaBuild.bytes):null,note:i,active:n===`cuda`,onClick:()=>r(`cuda`)})]})]})}function X({label:e,size:t,note:n,active:r,onClick:i}){return(0,I.jsxs)(`button`,{type:`button`,onClick:i,"aria-pressed":r,className:S(`flex-1 rounded-lg border px-4 py-3 text-left transition-colors`,r?`border-primary ring-2 ring-primary`:`border-border hover:bg-muted/50`),children:[(0,I.jsxs)(`span`,{className:`flex items-center justify-between gap-3`,children:[(0,I.jsx)(`span`,{className:`text-sm font-medium`,children:e}),t&&(0,I.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:t})]}),(0,I.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:n})]})}var Z=e=>e.backend===`cuda`||e.backend===`metal`||e.backend===`gpu`;function _e(e){if(e.backend===null)return e.probing?`Checking whether it can use the GPU…`:`Not checked yet.`;if(Z(e)){let t=e.backend===`cuda`?`CUDA`:e.backend===`metal`?`Metal`:null,n=[e.device,t&&`(${t})`].filter(Boolean).join(` `);return e.useGpu?`Runs on the GPU${n?` — ${n}`:``}.`:`GPU turned off — runs on the CPU.`}return e.installedBuild===`cuda`?`The GPU build is installed but found no GPU it can use, so it runs on the CPU.`:`Runs on the CPU.`}function ve({status:e,onStatus:t}){let n=e.gpu,[r,i]=(0,F.useState)(!1);if(!e.ready||!n)return null;let a=async(e,n,r)=>{i(!0);try{t(await y.post(e,n))}catch(e){v.error(r??`Could not change the GPU setting`,{description:e instanceof Error?e.message:String(e)})}finally{i(!1)}},o=n.installedBuild===`cpu`&&n.cudaBuild;return(0,I.jsxs)(`div`,{className:`space-y-3 rounded-lg border border-border p-3`,children:[(0,I.jsxs)(`div`,{className:`space-y-1`,children:[(0,I.jsxs)(`p`,{className:`flex items-center gap-2 text-sm`,children:[n.probing&&(0,I.jsx)(l,{className:`size-3.5 animate-spin`}),_e(n)]}),o&&(0,I.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`This host has `,n.nvidia?.name??`an NVIDIA card`,`. Choose the GPU build below to transcribe in under a second.`]}),n.probeError&&n.installedBuild!==`cpu`&&(0,I.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Last check: `,n.probeError]})]}),Z(n)&&(0,I.jsx)(P,{label:`Use GPU`,note:`Off: Whisper leaves the GPU to other work and each message takes several seconds longer.`,checked:n.useGpu,disabled:r,onChange:e=>void a(`/api/speech/gpu`,{useGpu:e})}),n.lastFailure&&n.useGpu&&(0,I.jsxs)(`p`,{className:`text-xs text-warning`,children:[`The GPU failed on `,new Date(n.lastFailure.at).toLocaleString(),` (`,n.lastFailure.message,`), so that message was transcribed on the CPU instead.`]}),n.installedBuild!==`cpu`&&(0,I.jsxs)(w,{variant:`outline`,disabled:r||n.probing,onClick:()=>void a(`/api/speech/gpu/check`,void 0,`Could not check the GPU`),className:S(E,`cursor-pointer`),children:[r?(0,I.jsx)(l,{className:`size-3.5 animate-spin`}):(0,I.jsx)(d,{className:`size-3.5`}),`Check again`]})]})}var ye=`/whisper-test-sample.mp3`;async function Q(e,t,n){let r=_(),i=await fetch(`/api/speech/test?lang=${encodeURIComponent(t)}&device=${n}`,{method:`POST`,headers:{"Content-Type":`audio/wav`,...r?{Authorization:`Bearer ${r}`}:{}},body:e}),a=await i.json().catch(()=>null);if(!i.ok||!a?.ok||!a.data)throw Error(a?.error??`HTTP ${i.status}`);return a.data}function $(e){let t=e/1e3;return`${t<1?t.toFixed(2):t<10?t.toFixed(1):Math.round(t)} s`}function be(e,t){if(e<=0||t<=e)return null;let n=t/e;return`${n<10?n.toFixed(1):Math.round(n)}× faster on the GPU`}function xe(e){let t=e.backend===`cuda`?`CUDA`:e.backend===`metal`?`Metal`:null;return`${e.ranOn===`gpu`?`GPU${e.device?` — ${e.device}`:``}${t?` (${t})`:``}`:e.fellBack?`CPU (the GPU failed, so it ran again on the CPU)`:`CPU`} · ${e.model}`}var Se=`vi`;function Ce({status:e}){let[t,n]=(0,F.useState)(null),[r,i]=(0,F.useState)(null),[a,c]=(0,F.useState)(null),[u,d]=(0,F.useState)(null),[f,p]=(0,F.useState)(0),m=(0,F.useRef)(null),h=async(e,t)=>{m.current={wav:e,lang:t},i(null),c(null),d(null),n(`running`);try{i(await Q(e,t,`default`))}catch(e){d(e instanceof Error?e.message:String(e))}finally{n(null)}},_=M(e=>{n(`running`),j(e.blob).then(e=>h(e,Se)).catch(e=>{d(e instanceof Error?e.message:String(e)),n(null)})});(0,F.useEffect)(()=>{if(!_.recording)return;p(0);let e=Date.now(),t=setInterval(()=>p(Math.floor((Date.now()-e)/1e3)),250),n=setTimeout(()=>_.stop(),15*1e3);return()=>{clearInterval(t),clearTimeout(n)}},[_.recording]),(0,F.useEffect)(()=>()=>{m.current=null,_.cancel()},[]);let v=async()=>{d(null),n(`running`);try{await h(await j(await(await fetch(ye)).blob()),`en`)}catch(e){d(e instanceof Error?e.message:String(e)),n(null)}},y=async()=>{if(m.current){n(`comparing`),d(null);try{c(await Q(m.current.wav,m.current.lang,`cpu`))}catch(e){d(e instanceof Error?e.message:String(e))}finally{n(null)}}};if(!e.ready)return null;let b=_.supported&&typeof window<`u`&&window.isSecureContext,x=r?.ranOn===`gpu`,C=x&&a?be(r.ms,a.ms):null;return(0,I.jsxs)(`div`,{className:`space-y-3 rounded-lg border border-border p-3`,"data-testid":`whisper-test`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`p`,{className:`text-sm font-medium`,children:`Try it`}),(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Say a sentence and see what Whisper writes and how long it takes. The audio stays on this host and is deleted after the run.`})]}),(0,I.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[b&&(_.recording?(0,I.jsxs)(w,{onClick:_.stop,className:S(E,`cursor-pointer`),children:[(0,I.jsx)(o,{className:`size-3.5`}),`Stop · `,f,`s / `,15,`s`]}):(0,I.jsxs)(w,{onClick:()=>void _.start(),disabled:t!==null,className:S(E,`cursor-pointer`),children:[(0,I.jsx)(s,{className:`size-3.5`}),`Record a test`]})),(0,I.jsxs)(w,{variant:`outline`,onClick:()=>void v(),disabled:t!==null||_.recording,className:S(E,`cursor-pointer`),children:[(0,I.jsx)(g,{className:`size-3.5`}),`Use the sample (11 s, English)`]})]}),!b&&(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`The microphone needs HTTPS or localhost here, so only the sample can be used on this page.`}),t===`running`&&(0,I.jsxs)(`p`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,I.jsx)(l,{className:`size-3.5 animate-spin`}),` Transcribing on this host…`]}),u&&(0,I.jsx)(`p`,{className:`text-xs text-error`,children:u}),r&&(0,I.jsxs)(`div`,{className:`space-y-2 rounded-md bg-muted/50 p-3`,"data-testid":`whisper-test-result`,children:[(0,I.jsx)(`p`,{className:`text-sm break-words`,children:r.text||(0,I.jsx)(`span`,{className:`text-muted-foreground`,children:`(no speech heard)`})}),(0,I.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[(0,I.jsx)(`span`,{className:`font-medium text-foreground`,children:$(r.ms)}),` · `,xe(r)]}),a&&(0,I.jsxs)(`p`,{className:`text-xs text-muted-foreground`,"data-testid":`whisper-test-compare`,children:[`Same audio on the CPU: `,(0,I.jsx)(`span`,{className:`font-medium text-foreground`,children:$(a.ms)}),C?` — ${C}`:``]}),x&&!a&&(0,I.jsxs)(w,{variant:`outline`,onClick:()=>void y(),disabled:t!==null,className:S(E,`cursor-pointer`),children:[t===`comparing`&&(0,I.jsx)(l,{className:`size-3.5 animate-spin`}),t===`comparing`?`Running on the CPU…`:`Compare with the CPU`]})]})]})}var we={binary:`Downloading whisper.cpp`,model:`Downloading the model`,vad:`Downloading the voice detector`,verify:`Checking it runs here`,gpu:`Checking the GPU`};function Te(e,t){let n=e.gpu;return!n||n.installedBuild===`system`?null:t||(n.installedBuild?n.installedBuild:n.cudaBuild?`cuda`:`cpu`)}var Ee=e=>`${Math.round(e/1e6)} MB`;function De(){let e=t(e=>e.voiceEngine),n=t(e=>e.setVoiceEngine),[r,i]=(0,F.useState)(null),[a,o]=(0,F.useState)(!1),[s,c]=(0,F.useState)(null),[d,m]=(0,F.useState)(null),[h,g]=(0,F.useState)(!1),_=(0,F.useRef)(null),b=(0,F.useCallback)(async()=>{try{let e=await y.get(`/api/speech/status`);i(e),c(t=>t??e.model?.id??e.models.at(-1)?.id??null)}catch{}},[]);(0,F.useEffect)(()=>{b()},[b]);let x=!!r?.install&&!r.install.done,C=!!r?.gpu?.probing;(0,F.useEffect)(()=>{if(!(!x&&!C))return _.current=setTimeout(()=>void b(),700),()=>{_.current&&clearTimeout(_.current)}},[x,C,r,b]);let[T,E]=(0,F.useState)(!1),D=!!r?.installable;(0,F.useEffect)(()=>{if(!T||D)return;let e=setInterval(()=>{document.visibilityState===`visible`&&b()},4e3),t=setTimeout(()=>E(!1),10*6e4);return()=>{clearInterval(e),clearTimeout(t)}},[T,D,b]),(0,F.useEffect)(()=>{r&&!r.ready&&e===`whisper`&&n(`browser`)},[r,e,n]);let O=r?Te(r,d):null,k=async()=>{if(s){g(!0);try{await y.post(`/api/speech/install`,{model:s,...O?{build:O}:{}}),m(null),await b()}catch(e){v.error(`Could not start the install`,{description:e instanceof Error?e.message:String(e)})}finally{g(!1)}}},A=async()=>{g(!0);try{await y.post(`/api/speech/uninstall`),n(`browser`),await b()}catch(e){v.error(`Could not remove Whisper`,{description:e instanceof Error?e.message:String(e)})}finally{g(!1)}},j=r?.install??null,M=j&&j.totalBytes>0?Math.round(j.receivedBytes/j.totalBytes*100):null,N=r?.gpu?.installedBuild??null,P=!!O&&(N===`cpu`||N===`cuda`)&&O!==N,L=!!r?.model&&r.model.id!==s,R=O===`cuda`?`GPU build`:`CPU build`,z=r?.ready?L?`Switch to ${r.models.find(e=>e.id===s)?.label}${P?` (${R})`:``}`:P?`Switch to the ${R}`:`Installed`:`Install`,B=typeof window<`u`&&!window.isSecureContext;return(0,I.jsxs)(`div`,{className:`space-y-6`,children:[(0,I.jsx)(me,{onEnabledChange:o}),!a&&(0,I.jsxs)(`section`,{className:`space-y-3`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`h3`,{className:`text-sm font-medium`,children:`Speech to text`}),(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`What the mic button in the chat box uses. This device only.`})]}),(0,I.jsxs)(`div`,{className:`flex flex-col sm:flex-row gap-2`,children:[(0,I.jsx)(Oe,{label:`Browser`,note:`Text appears as you speak. Chrome, Edge and Safari only — the audio goes to their servers.`,value:`browser`,current:e,onChange:n}),r?.ready&&(0,I.jsx)(Oe,{label:`Whisper on this host`,note:`Works in any browser and the audio never leaves your machine. Text arrives when you stop talking.`,value:`whisper`,current:e,onChange:n})]}),B&&(0,I.jsx)(`p`,{className:`text-xs text-warning`,children:`This page is on plain HTTP, where browsers block the microphone entirely. Open PPM over HTTPS or on localhost to use either engine.`})]}),(0,I.jsx)(ee,{}),(0,I.jsxs)(`section`,{className:`space-y-3`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`h3`,{className:`text-sm font-medium`,children:`Whisper on this host`}),(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r?.ready?`Installed — whisper.cpp ${r.version}, model ${r.model?.label}.`:`Runs speech to text on the machine PPM is installed on. Nothing is sent to a cloud service.`})]}),r&&(0,I.jsx)(ve,{status:r,onStatus:i}),r&&!x&&(0,I.jsx)(Ce,{status:r}),r&&!r.installable&&(r.installHint?(0,I.jsxs)(`div`,{className:`space-y-2`,children:[(0,I.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`There is no prebuilt whisper.cpp for this platform, so it comes from Homebrew:`,` `,(0,I.jsx)(`code`,{className:`rounded bg-muted px-1 py-0.5`,children:r.installHint}),`. PPM types it into a terminal; press Enter there, and the models appear here once it is installed.`]}),(0,I.jsx)(te,{command:r.installHint,label:`Install with Homebrew`,onRun:()=>E(!0)})]}):(0,I.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`There is no prebuilt whisper.cpp for this platform. Install it yourself and PPM will find it:`,` `,(0,I.jsx)(`code`,{className:`rounded bg-muted px-1 py-0.5`,children:`whisper-cli on PATH`})]})),j&&!j.done&&(0,I.jsxs)(`div`,{className:`space-y-2`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,I.jsx)(l,{className:`size-3.5 animate-spin`}),(0,I.jsxs)(`span`,{children:[we[j.phase],j.phase===`binary`&&j.build===`cuda`?` (GPU build)`:``,M===null||j.phase===`gpu`?`…`:` — ${M}%`]})]}),(0,I.jsx)(`div`,{className:`h-1.5 w-full overflow-hidden rounded-full bg-muted`,children:(0,I.jsx)(`div`,{className:`h-full bg-primary transition-[width]`,style:{width:`${M??0}%`}})})]}),j?.error&&(0,I.jsx)(`p`,{className:`text-xs text-error`,children:j.error}),r?.installable&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`div`,{className:`space-y-2`,children:r.models.map(e=>{let t=s===e.id,n=r.model?.id===e.id;return(0,I.jsxs)(`button`,{type:`button`,onClick:()=>c(e.id),className:S(`w-full rounded-lg border px-4 py-3 text-left transition-colors`,t?`border-primary ring-2 ring-primary`:`border-border hover:bg-muted/50`),children:[(0,I.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,I.jsx)(`span`,{className:`text-sm font-medium`,children:e.label}),(0,I.jsxs)(`span`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[n&&(0,I.jsx)(p,{className:`size-3.5 text-success`}),Ee(e.bytes)]})]}),(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.note})]},e.id)})}),r.gpu&&O&&(0,I.jsx)(ge,{gpu:r.gpu,cpuBytes:r.cpuBuildBytes??null,value:O,onChange:m}),(0,I.jsxs)(`div`,{className:`flex flex-col sm:flex-row gap-2`,children:[(0,I.jsxs)(w,{onClick:k,disabled:h||x||!s||r.ready&&!L&&!P,className:`flex-1 gap-2 cursor-pointer`,children:[(0,I.jsx)(f,{className:`size-4`}),z]}),(r.model||r.binary?.source===`bundled`)&&(0,I.jsxs)(w,{variant:`outline`,onClick:A,disabled:h||x,className:`gap-2 cursor-pointer text-error`,children:[(0,I.jsx)(u,{className:`size-4`}),`Remove`]})]})]})]})]})}function Oe({label:e,note:t,value:n,current:r,onChange:i}){return(0,I.jsxs)(`button`,{type:`button`,onClick:()=>i(n),className:S(`flex-1 rounded-lg border px-4 py-3 text-left transition-colors`,r===n?`border-primary ring-2 ring-primary`:`border-border hover:bg-muted/50`),children:[(0,I.jsxs)(`span`,{className:`flex items-center gap-2 text-sm font-medium`,children:[(0,I.jsx)(s,{className:`size-4`}),e]}),(0,I.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:t})]})}export{De as VoiceSettingsSection};
@@ -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{Kt as r,r as i}from"./icons-CpR5Vw3J.js";import{j as a,r as o}from"./api-client-DSCscZEd.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"./use-is-mobile-CrfIt67b.js";import"./settings-categories-B_629iML.js";import"./open-settings-CGqVSUo5.js";import{Qn as s,_n as c,hn as l}from"./index-HeDx2wIm.js";import{n as u}from"./web-browser-settings-BZVtGZ79.js";import{i as d}from"./web-browser-button-styles-ByWVMgQh.js";var f=e(t(),1),p=n();function m(e){return(0,p.jsxs)(`label`,{className:`flex items-start gap-3 py-1.5 cursor-pointer`,children:[(0,p.jsxs)(`div`,{className:`flex-1`,children:[(0,p.jsx)(`div`,{className:`text-sm`,children:e.title}),e.body&&(0,p.jsx)(`div`,{className:`text-xs text-muted-foreground leading-relaxed`,children:e.body})]}),(0,p.jsx)(s,{checked:e.checked,disabled:e.disabled,onCheckedChange:e.onChange,className:`mt-1`})]})}var h=`flex gap-2 rounded-md bg-warning/10 px-3 py-2 text-xs leading-relaxed`;function g(){let[e,t]=(0,f.useState)(null),n=(0,f.useCallback)(async()=>{try{t(await o.get(`/api/web-browser/capabilities`))}catch{}},[]);(0,f.useEffect)(()=>{n()},[n]);let s=async n=>{if(e)try{let r=await o.put(`/api/web-browser/settings`,{...e.settings,...n});t({...e,settings:r}),c()}catch(e){a.error(`Could not save`,{description:e instanceof Error?e.message:String(e)})}};if(!e)return(0,p.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:`Loading…`});let g=e.settings,_=e.publicRequest,v=g.autoFps?`auto`:Object.entries(u).find(([,e])=>e.fpsCap===g.fpsCap&&e.jpegQuality===g.jpegQuality)?.[0]??`custom`;return(0,p.jsxs)(`div`,{className:`space-y-6`,children:[(0,p.jsxs)(`section`,{className:`space-y-2`,children:[(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`h3`,{className:`text-sm font-medium`,children:`Web browser`}),(0,p.jsx)(`p`,{className:`text-xs text-muted-foreground leading-relaxed`,children:`A Chrome that runs on this host, shown in a PPM window (a tab on a phone). It uses its own profile: no logins shared with your Chrome or with AI chats' Playwright.`})]}),(0,p.jsx)(m,{title:`Turn on the web browser`,checked:g.enabled===!0,onChange:e=>void s({enabled:e})}),g.enabled===!0&&(0,p.jsxs)(`button`,{type:`button`,className:d,onClick:l,children:[(0,p.jsx)(r,{}),`Open the browser`]}),e.browsers.length===0?(0,p.jsxs)(`p`,{className:h,children:[(0,p.jsx)(i,{className:`size-4 shrink-0`}),`No Chrome or Edge found on this host. `,e.installHint]}):(0,p.jsxs)(`label`,{className:`flex items-center gap-3 py-1 text-sm`,children:[(0,p.jsx)(`span`,{className:`flex-1`,children:`Browser on this host`}),(0,p.jsx)(`select`,{className:`min-h-9 rounded-md border border-border bg-panel px-2 text-sm`,disabled:_,value:g.browserPath??e.browsers[0].path,onChange:e=>void s({browserPath:e.target.value}),children:e.browsers.map(e=>(0,p.jsxs)(`option`,{value:e.path,children:[e.name,` `,e.version]},e.path))})]})]}),(0,p.jsxs)(`section`,{className:`space-y-2`,children:[(0,p.jsx)(`h3`,{className:`text-sm font-medium`,children:`Memory`}),(0,p.jsxs)(`label`,{className:`flex items-center gap-3 py-1 text-sm`,children:[(0,p.jsxs)(`span`,{className:`flex-1`,children:[`Most tabs at once `,(0,p.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`(each page costs 100–500 MB)`})]}),(0,p.jsx)(`input`,{type:`number`,min:1,max:8,value:g.maxTabs,onChange:e=>void s({maxTabs:Number(e.target.value)}),className:`w-20 min-h-9 rounded-md border border-border bg-panel px-2`})]}),(0,p.jsxs)(`label`,{className:`flex items-center gap-3 py-1 text-sm`,children:[(0,p.jsx)(`span`,{className:`flex-1`,children:`Stop the browser after this many minutes unused`}),(0,p.jsx)(`input`,{type:`number`,min:2,max:120,value:g.idleStopMinutes,onChange:e=>void s({idleStopMinutes:Number(e.target.value)}),className:`w-20 min-h-9 rounded-md border border-border bg-panel px-2`})]}),(0,p.jsxs)(`label`,{className:`flex items-center gap-3 py-1 text-sm`,children:[(0,p.jsxs)(`span`,{className:`flex-1`,children:[`Picture `,(0,p.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`(more frames cost more bandwidth)`})]}),(0,p.jsxs)(`select`,{value:v,onChange:e=>{if(e.target.value===`auto`)return void s({autoFps:!0});let t=u[e.target.value];t&&s(t)},className:`min-h-9 rounded-md border border-border bg-panel px-2 text-sm`,children:[(0,p.jsxs)(`option`,{value:`auto`,children:[`Auto (up to `,30,` fps, follows the connection)`]}),(0,p.jsx)(`option`,{value:`saver`,children:`Saver (8 fps)`}),(0,p.jsx)(`option`,{value:`balanced`,children:`Balanced (12 fps)`}),(0,p.jsx)(`option`,{value:`smooth`,children:`Smooth (20 fps)`}),v===`custom`&&(0,p.jsxs)(`option`,{value:`custom`,children:[`Custom (`,g.fpsCap,` fps)`]})]})]}),(0,p.jsx)(m,{title:`Sound`,body:`Pages' sound plays on the device you view from; the host's speakers stay silent.`,checked:g.audio,onChange:e=>void s({audio:e})})]}),(0,p.jsxs)(`section`,{className:`space-y-2`,children:[(0,p.jsx)(`h3`,{className:`text-sm font-medium`,children:`What it may reach`}),_&&(0,p.jsxs)(`p`,{className:h,children:[(0,p.jsx)(i,{className:`size-4 shrink-0`}),`You are on a public link: these can only be changed from the LAN or Tailscale.`]}),(0,p.jsx)(m,{title:`Services on this machine (localhost)`,disabled:_,checked:g.allowLocalhost,body:`Dev servers and local tools. PPM's own ports are always blocked.`,onChange:e=>void s({allowLocalhost:e})}),(0,p.jsx)(m,{title:`Devices on your network (LAN)`,disabled:_,checked:g.allowLan,body:`Router, NAS, printers. Cloud metadata addresses are always blocked.`,onChange:e=>void s({allowLan:e})}),(0,p.jsx)(m,{title:`Use it over a public link`,disabled:_,checked:g.allowPublicTunnel,body:`When off, the browser opens only from the LAN or Tailscale.`,onChange:e=>void s({allowPublicTunnel:e})}),(0,p.jsx)(m,{title:`Let AI chats drive it`,disabled:_,checked:g.aiControl,body:`Each chat asks you once before it first uses the browser; you can take it back at any time.`,onChange:e=>void s({aiControl:e})}),g.allowPublicTunnel&&(g.allowLocalhost||g.allowLan)&&(0,p.jsxs)(`p`,{className:h,children:[(0,p.jsx)(i,{className:`size-4 shrink-0`}),`With a public link on, anyone holding PPM's password over the Internet can use this browser to open`,g.allowLocalhost&&g.allowLan?` this machine's local services and the devices on your home network`:g.allowLocalhost?` this machine's local services`:` the devices on your home network`,`.`]}),g.aiControl&&(0,p.jsxs)(`p`,{className:h,children:[(0,p.jsx)(i,{className:`size-4 shrink-0`}),`A page can try to talk an AI into clicking things on sites this browser is signed in to.`]})]}),(0,p.jsxs)(`section`,{className:`space-y-2`,children:[(0,p.jsx)(`h3`,{className:`text-sm font-medium`,children:`Data`}),(0,p.jsx)(`button`,{type:`button`,className:d,onClick:async()=>{window.confirm(`Clear the browser's logins, history and downloads on the host?`)&&(await o.post(`/api/web-browser/clear-data`),a.success(`Browsing data cleared`))},children:`Clear browsing data…`})]})]})}export{g as WebBrowserSettingsSection};
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{Kt as r,r as i}from"./icons-CpR5Vw3J.js";import{j as a,r as o}from"./api-client-DSCscZEd.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"./use-is-mobile-CrfIt67b.js";import"./settings-categories-B_629iML.js";import"./open-settings-CGqVSUo5.js";import{Qn as s,_n as c,hn as l}from"./index-CToe9paM.js";import{n as u}from"./web-browser-settings-BZVtGZ79.js";import{i as d}from"./web-browser-button-styles-ByWVMgQh.js";var f=e(t(),1),p=n();function m(e){return(0,p.jsxs)(`label`,{className:`flex items-start gap-3 py-1.5 cursor-pointer`,children:[(0,p.jsxs)(`div`,{className:`flex-1`,children:[(0,p.jsx)(`div`,{className:`text-sm`,children:e.title}),e.body&&(0,p.jsx)(`div`,{className:`text-xs text-muted-foreground leading-relaxed`,children:e.body})]}),(0,p.jsx)(s,{checked:e.checked,disabled:e.disabled,onCheckedChange:e.onChange,className:`mt-1`})]})}var h=`flex gap-2 rounded-md bg-warning/10 px-3 py-2 text-xs leading-relaxed`;function g(){let[e,t]=(0,f.useState)(null),n=(0,f.useCallback)(async()=>{try{t(await o.get(`/api/web-browser/capabilities`))}catch{}},[]);(0,f.useEffect)(()=>{n()},[n]);let s=async n=>{if(e)try{let r=await o.put(`/api/web-browser/settings`,{...e.settings,...n});t({...e,settings:r}),c()}catch(e){a.error(`Could not save`,{description:e instanceof Error?e.message:String(e)})}};if(!e)return(0,p.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:`Loading…`});let g=e.settings,_=e.publicRequest,v=g.autoFps?`auto`:Object.entries(u).find(([,e])=>e.fpsCap===g.fpsCap&&e.jpegQuality===g.jpegQuality)?.[0]??`custom`;return(0,p.jsxs)(`div`,{className:`space-y-6`,children:[(0,p.jsxs)(`section`,{className:`space-y-2`,children:[(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`h3`,{className:`text-sm font-medium`,children:`Web browser`}),(0,p.jsx)(`p`,{className:`text-xs text-muted-foreground leading-relaxed`,children:`A Chrome that runs on this host, shown in a PPM window (a tab on a phone). It uses its own profile: no logins shared with your Chrome or with AI chats' Playwright.`})]}),(0,p.jsx)(m,{title:`Turn on the web browser`,checked:g.enabled===!0,onChange:e=>void s({enabled:e})}),g.enabled===!0&&(0,p.jsxs)(`button`,{type:`button`,className:d,onClick:l,children:[(0,p.jsx)(r,{}),`Open the browser`]}),e.browsers.length===0?(0,p.jsxs)(`p`,{className:h,children:[(0,p.jsx)(i,{className:`size-4 shrink-0`}),`No Chrome or Edge found on this host. `,e.installHint]}):(0,p.jsxs)(`label`,{className:`flex items-center gap-3 py-1 text-sm`,children:[(0,p.jsx)(`span`,{className:`flex-1`,children:`Browser on this host`}),(0,p.jsx)(`select`,{className:`min-h-9 rounded-md border border-border bg-panel px-2 text-sm`,disabled:_,value:g.browserPath??e.browsers[0].path,onChange:e=>void s({browserPath:e.target.value}),children:e.browsers.map(e=>(0,p.jsxs)(`option`,{value:e.path,children:[e.name,` `,e.version]},e.path))})]})]}),(0,p.jsxs)(`section`,{className:`space-y-2`,children:[(0,p.jsx)(`h3`,{className:`text-sm font-medium`,children:`Memory`}),(0,p.jsxs)(`label`,{className:`flex items-center gap-3 py-1 text-sm`,children:[(0,p.jsxs)(`span`,{className:`flex-1`,children:[`Most tabs at once `,(0,p.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`(each page costs 100–500 MB)`})]}),(0,p.jsx)(`input`,{type:`number`,min:1,max:8,value:g.maxTabs,onChange:e=>void s({maxTabs:Number(e.target.value)}),className:`w-20 min-h-9 rounded-md border border-border bg-panel px-2`})]}),(0,p.jsxs)(`label`,{className:`flex items-center gap-3 py-1 text-sm`,children:[(0,p.jsx)(`span`,{className:`flex-1`,children:`Stop the browser after this many minutes unused`}),(0,p.jsx)(`input`,{type:`number`,min:2,max:120,value:g.idleStopMinutes,onChange:e=>void s({idleStopMinutes:Number(e.target.value)}),className:`w-20 min-h-9 rounded-md border border-border bg-panel px-2`})]}),(0,p.jsxs)(`label`,{className:`flex items-center gap-3 py-1 text-sm`,children:[(0,p.jsxs)(`span`,{className:`flex-1`,children:[`Picture `,(0,p.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`(more frames cost more bandwidth)`})]}),(0,p.jsxs)(`select`,{value:v,onChange:e=>{if(e.target.value===`auto`)return void s({autoFps:!0});let t=u[e.target.value];t&&s(t)},className:`min-h-9 rounded-md border border-border bg-panel px-2 text-sm`,children:[(0,p.jsxs)(`option`,{value:`auto`,children:[`Auto (up to `,30,` fps, follows the connection)`]}),(0,p.jsx)(`option`,{value:`saver`,children:`Saver (8 fps)`}),(0,p.jsx)(`option`,{value:`balanced`,children:`Balanced (12 fps)`}),(0,p.jsx)(`option`,{value:`smooth`,children:`Smooth (20 fps)`}),v===`custom`&&(0,p.jsxs)(`option`,{value:`custom`,children:[`Custom (`,g.fpsCap,` fps)`]})]})]}),(0,p.jsx)(m,{title:`Sound`,body:`Pages' sound plays on the device you view from; the host's speakers stay silent.`,checked:g.audio,onChange:e=>void s({audio:e})})]}),(0,p.jsxs)(`section`,{className:`space-y-2`,children:[(0,p.jsx)(`h3`,{className:`text-sm font-medium`,children:`What it may reach`}),_&&(0,p.jsxs)(`p`,{className:h,children:[(0,p.jsx)(i,{className:`size-4 shrink-0`}),`You are on a public link: these can only be changed from the LAN or Tailscale.`]}),(0,p.jsx)(m,{title:`Services on this machine (localhost)`,disabled:_,checked:g.allowLocalhost,body:`Dev servers and local tools. PPM's own ports are always blocked.`,onChange:e=>void s({allowLocalhost:e})}),(0,p.jsx)(m,{title:`Devices on your network (LAN)`,disabled:_,checked:g.allowLan,body:`Router, NAS, printers. Cloud metadata addresses are always blocked.`,onChange:e=>void s({allowLan:e})}),(0,p.jsx)(m,{title:`Use it over a public link`,disabled:_,checked:g.allowPublicTunnel,body:`When off, the browser opens only from the LAN or Tailscale.`,onChange:e=>void s({allowPublicTunnel:e})}),(0,p.jsx)(m,{title:`Let AI chats drive it`,disabled:_,checked:g.aiControl,body:`Each chat asks you once before it first uses the browser; you can take it back at any time.`,onChange:e=>void s({aiControl:e})}),g.allowPublicTunnel&&(g.allowLocalhost||g.allowLan)&&(0,p.jsxs)(`p`,{className:h,children:[(0,p.jsx)(i,{className:`size-4 shrink-0`}),`With a public link on, anyone holding PPM's password over the Internet can use this browser to open`,g.allowLocalhost&&g.allowLan?` this machine's local services and the devices on your home network`:g.allowLocalhost?` this machine's local services`:` the devices on your home network`,`.`]}),g.aiControl&&(0,p.jsxs)(`p`,{className:h,children:[(0,p.jsx)(i,{className:`size-4 shrink-0`}),`A page can try to talk an AI into clicking things on sites this browser is signed in to.`]})]}),(0,p.jsxs)(`section`,{className:`space-y-2`,children:[(0,p.jsx)(`h3`,{className:`text-sm font-medium`,children:`Data`}),(0,p.jsx)(`button`,{type:`button`,className:d,onClick:async()=>{window.confirm(`Clear the browser's logins, history and downloads on the host?`)&&(await o.post(`/api/web-browser/clear-data`),a.success(`Browsing data cleared`))},children:`Clear browsing data…`})]})]})}export{g as WebBrowserSettingsSection};
@@ -1 +1 @@
1
- import"./settings-store-DirmJxtu.js";import{E as e}from"./vendor-markdown-26eoXJk7.js";import"./vendor-ui-BQzUk4nq.js";import"./icons-CpR5Vw3J.js";import"./api-client-DSCscZEd.js";import"./portal-container-context-C84rlnJ6.js";import"./window-store-Bl6ySrZZ.js";import"./panel-store-B5zTGca0.js";import"./project-store-BaGmhKos.js";import"./project-framework-store-vI8djw4a.js";import"./session-list-sync-triggers-_I5gGBSe.js";import"./tab-store-CdpGgbmw.js";import"./mobile-bottom-sheet-C78UMLrn.js";import"./use-visual-viewport-tMLO63yY.js";import{n as t}from"./use-is-mobile-CrfIt67b.js";import"./settings-categories-B_629iML.js";import"./open-settings-CGqVSUo5.js";import"./ws-auth-BoXvat-e.js";import"./web-browser-button-styles-ByWVMgQh.js";import{t as n}from"./web-browser-view-D5zQyqTr.js";var r=e();function i(){return(0,r.jsx)(n,{phone:t()})}export{i as WebBrowserTab};
1
+ import"./settings-store-DirmJxtu.js";import{E as e}from"./vendor-markdown-26eoXJk7.js";import"./vendor-ui-BQzUk4nq.js";import"./icons-CpR5Vw3J.js";import"./api-client-DSCscZEd.js";import"./portal-container-context-C84rlnJ6.js";import"./window-store-Bl6ySrZZ.js";import"./panel-store-B5zTGca0.js";import"./project-store-BaGmhKos.js";import"./project-framework-store-vI8djw4a.js";import"./session-list-sync-triggers-_I5gGBSe.js";import"./tab-store-CdpGgbmw.js";import"./mobile-bottom-sheet-C78UMLrn.js";import"./use-visual-viewport-tMLO63yY.js";import{n as t}from"./use-is-mobile-CrfIt67b.js";import"./settings-categories-B_629iML.js";import"./open-settings-CGqVSUo5.js";import"./ws-auth-BoXvat-e.js";import"./web-browser-button-styles-ByWVMgQh.js";import{t as n}from"./web-browser-view-B-gt8lOz.js";var r=e();function i(){return(0,r.jsx)(n,{phone:t()})}export{i as WebBrowserTab};
@@ -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{Hn as r,Kt as i,Rn as a,Sn as o,Xr as s,ci as c,dn as l,gt as u,ht as d,lr as f,m as p,pi as m,r as h,si as g,ti as _,u as v,ur as y,w as b,wn as x,yr as S}from"./icons-CpR5Vw3J.js";import{a as C,j as ee,r as w}from"./api-client-DSCscZEd.js";import{n as T}from"./utils-DMiycH3O.js";import{t as te}from"./mobile-bottom-sheet-C78UMLrn.js";import{t as ne}from"./ws-auth-BoXvat-e.js";import{gn as re}from"./index-HeDx2wIm.js";import{i as E,s as ie,t as ae}from"./remote-desktop-coords-BI7h18Lu.js";import{a as D,i as O,n as k,r as oe,t as A}from"./web-browser-button-styles-ByWVMgQh.js";function se(e){let t=e instanceof Uint8Array?e:new Uint8Array(e);if(t.byteLength<12)return null;let n=new DataView(t.buffer,t.byteOffset,t.byteLength),r=n.getUint8(0),i=n.getUint32(1,!0),a=n.getUint16(5,!0),o=n.getUint16(7,!0),s=t.subarray(12);return r===1?{kind:r,seq:i,cssWidth:a,cssHeight:o,payload:s}:r===2?{kind:r,seq:i,sampleRate:a*10,channels:o,payload:s}:null}function ce(e,t){let n=ne(`/ws/web-browser`);return t&&e.protocol!==`https:`?`ws://${e.hostname}:${t}${n}`:`${e.protocol===`https:`?`wss:`:`ws:`}//${e.host}${n}`}var le=class{ws=null;lastInputAt=0;latencyMs=null;constructor(e){this.h=e}async connect(){this.close(),this.h.onState(`connecting`);let e;try{e=(await w.post(`/api/web-browser/session`)).nonce}catch(e){this.h.onState(`error`,e?.message??String(e));return}let t={BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1},n=t.DEV===!0&&typeof t.VITE_DEV_API_PORT==`string`?t.VITE_DEV_API_PORT:void 0,r=new WebSocket(ce(window.location,n));r.binaryType=`arraybuffer`,this.ws=r,r.onopen=()=>{r.send(JSON.stringify({type:`auth`,nonce:e})),this.h.onState(`open`)},r.onmessage=e=>{if(typeof e.data==`string`){try{this.h.onMessage(JSON.parse(e.data))}catch{}return}let t=se(e.data);if(t)if(t.kind===1){if(this.lastInputAt){let e=performance.now()-this.lastInputAt;this.latencyMs=this.latencyMs===null?e:Math.round(this.latencyMs*.7+e*.3),this.lastInputAt=0}this.h.onPicture(t)}else this.h.onSound(t)},r.onclose=e=>{this.ws===r&&(this.ws=null,this.h.onState(`closed`,e.reason||void 0))},r.onerror=()=>{}}get isOpen(){return this.ws?.readyState===WebSocket.OPEN}send(e){this.ws?.readyState===WebSocket.OPEN&&((e.type===`pointer`||e.type===`key`||e.type===`wheel`||e.type===`text`||e.type===`touch`)&&(this.lastInputAt||=performance.now()),this.ws.send(JSON.stringify(e)))}close(){let e=this.ws;if(this.ws=null,e){e.onclose=null;try{e.close()}catch{}}}},ue=class{decoding=!1;waiting=null;canvas=null;pageSize=null;drawn=0;constructor(e){this.ack=e}attach(e){this.canvas=e}push(e){this.waiting&&this.ack(this.waiting.seq),this.waiting=e,this.decoding||this.drain()}async drain(){for(this.decoding=!0;this.waiting;){let e=this.waiting;this.waiting=null;try{let t=await createImageBitmap(new Blob([e.payload],{type:`image/jpeg`})),n=this.canvas;n&&((n.width!==t.width||n.height!==t.height)&&(n.width=t.width,n.height=t.height),n.getContext(`2d`)?.drawImage(t,0,0),this.pageSize={width:e.cssWidth,height:e.cssHeight},this.drawn++),t.close()}catch{}this.ack(e.seq)}this.decoding=!1}},de=.12,fe=.6;function pe(e,t){let n=new DataView(e.buffer,e.byteOffset,e.byteLength),r=Math.floor(e.byteLength/2/t),i=Array.from({length:t},()=>new Float32Array(r));for(let e=0;e<r;e++)for(let r=0;r<t;r++)i[r][e]=n.getInt16((e*t+r)*2,!0)/32768;return i}function me(e,t){return t<e+.02||t>e+fe?e+de:t}var j=class{ctx=null;playHead=0;resume(){typeof AudioContext>`u`||(this.ctx??=new AudioContext,this.ctx.resume().catch(()=>{}))}push(e){let t=this.ctx;if(!t||t.state!==`running`||e.channels<1||e.sampleRate<8e3)return;let n=pe(e.payload,e.channels),r=n[0]?.length??0;if(!r)return;let i=t.createBuffer(e.channels,r,e.sampleRate);n.forEach((e,t)=>i.copyToChannel(e,t));let a=t.createBufferSource();a.buffer=i,a.connect(t.destination);let o=me(t.currentTime,this.playHead);a.start(o),this.playHead=o+i.duration}close(){this.ctx?.close().catch(()=>{}),this.ctx=null}},M=e(t(),1),N={conn:`idle`,connError:null,browser:null,browserMessage:null,ramMB:null,idleStopAt:null,tabs:[],activeTabId:null,isController:!0,dialog:null,chooser:null,downloads:[],blocked:null,ai:null,error:null,maxTabs:4,audioAvailable:!1};function P(e){let[t,n]=(0,M.useState)(N),r=(0,M.useRef)(null),i=(0,M.useRef)(null),a=(0,M.useRef)(null),o=(0,M.useRef)(null),s=(0,M.useRef)(null),c=(0,M.useRef)(e.muted);c.current=e.muted;let l=(0,M.useCallback)(e=>n(t=>({...t,...e})),[]),u=(0,M.useCallback)(e=>{switch(e.type){case`hello`:return l({tabs:e.tabs,activeTabId:e.activeTabId,maxTabs:e.limits.maxTabs,audioAvailable:e.limits.audio});case`tabs`:return l({tabs:e.list,activeTabId:e.activeTabId});case`status`:return l({browser:e.state,browserMessage:e.message??null,ramMB:e.ramMB,idleStopAt:e.idleStopAt,...e.state===`running`?{error:null}:{}});case`controller`:return l({isController:e.isYou});case`dialog`:return l({dialog:e});case`dialog.closed`:return n(t=>t.dialog?.id===e.id?{...t,dialog:null}:t);case`fileChooser`:return l({chooser:e});case`download`:return n(t=>({...t,downloads:[e,...t.downloads.filter(t=>t.id!==e.id)].slice(0,20)}));case`blocked`:return l({blocked:e});case`ai`:return l({ai:e});case`error`:return l({error:{code:e.code,message:e.message}});case`clipboard.copy`:ie(e.text).then(t=>{t||E(e.text)});return}},[l]),d=(0,M.useCallback)(()=>{a.current?.close();let e=new le({onState:(e,t)=>l({conn:e,connError:t??null}),onMessage:u,onPicture:e=>o.current?.push(e),onSound:e=>{c.current||s.current?.push(e)}});a.current=e,o.current=new ue(t=>e.send({type:`frame.ack`,seq:t})),o.current.attach(r.current),e.connect()},[u,l]);(0,M.useEffect)(()=>{if(e.visible)return d(),()=>{a.current?.close(),a.current=null,l({conn:`idle`})}},[e.visible,d,l]),(0,M.useEffect)(()=>{let n=i.current;if(!n||t.conn!==`open`)return;let r=null,o=()=>{let t=n.getBoundingClientRect();t.width<100||t.height<100||a.current?.send({type:`viewport`,cssWidth:Math.round(t.width),cssHeight:Math.round(t.height),dpr:Math.min(window.devicePixelRatio||1,3),mobile:e.mobile})};o(),a.current?.send({type:`visibility`,visible:!0});let s=new ResizeObserver(()=>{r&&clearTimeout(r),r=setTimeout(o,150)});return s.observe(n),()=>{s.disconnect(),r&&clearTimeout(r)}},[t.conn,e.mobile]);let f=(0,M.useCallback)(e=>{r.current=e,o.current?.attach(e)},[]),p=(0,M.useCallback)(()=>{s.current||=new j,s.current.resume()},[]);return(0,M.useEffect)(()=>()=>{s.current?.close()},[]),{state:t,patch:l,send:(0,M.useCallback)(e=>a.current?.send(e),[]),connect:d,surfaceRef:i,attachCanvas:f,unlockAudio:p,latency:()=>a.current?.latencyMs??null}}function F(e){return{alt:e.altKey,ctrl:e.ctrlKey,meta:e.metaKey,shift:e.shiftKey}}function I(e){return(e.ctrlKey||e.metaKey)&&!e.altKey&&(e.code===`KeyV`||e.key.toLowerCase()===`v`)}function L(e){return(e.ctrlKey||e.metaKey)&&!e.altKey&&(e.code===`KeyC`||e.code===`KeyX`)}function R(e,t){if(e.isComposing||e.key===`Process`||e.keyCode===229||e.key===`Dead`||e.key===`Unidentified`||I(e))return null;let n=e.ctrlKey||e.metaKey||e.altKey;return e.key.length===1&&!n?null:{type:`key`,down:t,key:e.key.slice(0,64),code:e.code.slice(0,64),location:e.location,modifiers:F(e),repeat:e.repeat}}function z(e,t){let n=e=>[{type:`key`,down:!0,key:e,code:e,location:0,modifiers:{},repeat:!1},{type:`key`,down:!1,key:e,code:e,location:0,modifiers:{},repeat:!1}];switch(e){case`insertText`:case`insertReplacementText`:return t?[{type:`text`,text:t}]:[];case`insertLineBreak`:case`insertParagraph`:return n(`Enter`);case`deleteContentBackward`:return n(`Backspace`);case`deleteContentForward`:return n(`Delete`);default:return null}}var B=[`left`,`middle`,`right`];function he(e,t,n){let r=(0,M.useRef)(n);r.current=n,(0,M.useEffect)(()=>{let i=e.current,a=t.current;if(!i||!a||!n.enabled)return;let o=e=>r.current.send(e),s=e=>ae(e.clientX,e.clientY,i.getBoundingClientRect()),c=new Map,l=()=>[...c].map(([e,t])=>({id:e,...t})),u=e=>{a.focus({preventScroll:!0}),i.setPointerCapture?.(e.pointerId),e.pointerType===`touch`?(c.set(e.pointerId,s(e)),o({type:`touch`,phase:c.size===1?`start`:`move`,points:l()})):o({type:`pointer`,...s(e),button:B[e.button]??`left`,down:!0,clickCount:Math.min(3,Math.max(1,e.detail||1))}),e.preventDefault()},d=e=>{if(e.pointerType===`touch`){if(!c.has(e.pointerId))return;c.set(e.pointerId,s(e)),o({type:`touch`,phase:`move`,points:l()})}else o({type:`pointer`,...s(e),button:`none`,down:null})},f=e=>{e.pointerType===`touch`?(c.delete(e.pointerId),o({type:`touch`,phase:e.type===`pointercancel`?`cancel`:`end`,points:l()}),e.type===`pointercancel`&&c.clear()):o({type:`pointer`,...s(e),button:B[e.button]??`left`,down:!1,clickCount:Math.min(3,Math.max(1,e.detail||1))})},p=e=>{e.preventDefault();let t=e.deltaMode===1?16:e.deltaMode===2?i.clientHeight:1;o({type:`wheel`,...s(e),dx:e.deltaX*t,dy:e.deltaY*t})},m=e=>e.preventDefault(),h=e=>{let t=R(e,e.type===`keydown`);t&&(e.preventDefault(),o(t),e.type===`keydown`&&L(e)&&setTimeout(()=>r.current.onCopy(),120))},g=e=>{let t=z(e.inputType,e.data);if(t){e.preventDefault();for(let e of t)o(e);a.value=``}},_=e=>{let t=e.data??``;o({type:`compose`,text:t,selStart:t.length,selEnd:t.length})},v=e=>{e.data?o({type:`text`,text:e.data}):o({type:`compose`,text:``,selStart:0,selEnd:0}),a.value=``},y=e=>{let t=e.clipboardData?.getData(`text/plain`);e.preventDefault(),t&&r.current.onPasteText(t)},b=()=>o({type:`releaseAll`});return i.addEventListener(`pointerdown`,u),i.addEventListener(`pointermove`,d),i.addEventListener(`pointerup`,f),i.addEventListener(`pointercancel`,f),i.addEventListener(`wheel`,p,{passive:!1}),i.addEventListener(`contextmenu`,m),a.addEventListener(`keydown`,h),a.addEventListener(`keyup`,h),a.addEventListener(`beforeinput`,g),a.addEventListener(`compositionupdate`,_),a.addEventListener(`compositionend`,v),a.addEventListener(`paste`,y),a.addEventListener(`blur`,b),()=>{i.removeEventListener(`pointerdown`,u),i.removeEventListener(`pointermove`,d),i.removeEventListener(`pointerup`,f),i.removeEventListener(`pointercancel`,f),i.removeEventListener(`wheel`,p),i.removeEventListener(`contextmenu`,m),a.removeEventListener(`keydown`,h),a.removeEventListener(`keyup`,h),a.removeEventListener(`beforeinput`,g),a.removeEventListener(`compositionupdate`,_),a.removeEventListener(`compositionend`,v),a.removeEventListener(`paste`,y),a.removeEventListener(`blur`,b)}},[e,t,n.enabled])}function ge(e){let[t,n]=(0,M.useState)(()=>typeof document>`u`||document.visibilityState===`visible`),[r,i]=(0,M.useState)(!0);return(0,M.useEffect)(()=>{let e=()=>n(document.visibilityState===`visible`);return document.addEventListener(`visibilitychange`,e),()=>document.removeEventListener(`visibilitychange`,e)},[]),(0,M.useEffect)(()=>{let t=e.current;if(!t||typeof IntersectionObserver>`u`)return;let n=new IntersectionObserver(e=>{let t=e[e.length-1];i(!!t&&t.isIntersecting&&t.boundingClientRect.width>0&&t.boundingClientRect.height>0)});return n.observe(t),()=>n.disconnect()},[e]),t&&r}var V=n(),H=A;function _e(e){let[t,n]=(0,M.useState)(!1),[i,o]=(0,M.useState)(e.tab?.url??``);(0,M.useEffect)(()=>{t||o(e.tab?.url===`about:blank`?``:e.tab?.url??``)},[e.tab?.url,t]);let s=e.tab?.url.startsWith(`https://`),c=(0,V.jsxs)(`button`,{type:`button`,onClick:e.onShowInfo,title:`Runs on the host machine — click for details`,className:`${k} border border-border text-text-2 hover:bg-panel-2`,children:[(0,V.jsx)(`span`,{className:`size-1.5 rounded-full bg-success`}),(0,V.jsx)(a,{className:`size-3.5`}),!e.phone&&(0,V.jsx)(`span`,{children:`On host`}),(0,V.jsx)(`span`,{className:`font-mono`,children:e.latencyMs===null?`—`:`${e.latencyMs} ms`})]}),u=(0,V.jsx)(`form`,{className:`flex-1 min-w-0`,onSubmit:t=>{t.preventDefault(),n(!1),e.onNavigate(i)},children:(0,V.jsxs)(`label`,{className:`flex items-center gap-1.5 h-7 rounded-full bg-panel-2 border border-border px-2.5 focus-within:ring-1 focus-within:ring-ring`,children:[s&&(0,V.jsx)(x,{className:`size-3.5 text-text-3 shrink-0`}),(0,V.jsx)(`input`,{value:i,onChange:e=>o(e.target.value),onFocus:e=>{n(!0),e.currentTarget.select()},onBlur:()=>n(!1),placeholder:`Search or type an address`,"aria-label":`Address`,inputMode:`url`,autoCapitalize:`off`,autoCorrect:`off`,spellCheck:!1,className:`flex-1 min-w-0 bg-transparent text-[13px] md:text-xs outline-none text-text`})]})}),f=(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`button`,{type:`button`,className:H,onClick:e.onBack,disabled:!e.tab?.canBack,"aria-label":`Back`,title:`Back`,children:(0,V.jsx)(v,{className:`size-4`})}),(0,V.jsx)(`button`,{type:`button`,className:H,onClick:e.onForward,disabled:!e.tab?.canForward,"aria-label":`Forward`,title:`Forward`,children:(0,V.jsx)(p,{className:`size-4`})}),e.tab?.loading?(0,V.jsx)(`button`,{type:`button`,className:H,onClick:e.onStop,"aria-label":`Stop loading`,title:`Stop loading`,children:(0,V.jsx)(m,{className:`size-4`})}):(0,V.jsx)(`button`,{type:`button`,className:H,onClick:e.onReload,"aria-label":`Reload`,title:`Reload`,children:(0,V.jsx)(S,{className:`size-4`})})]}),h=(0,V.jsxs)(`button`,{type:`button`,className:T(H,`relative`),onClick:e.onShowDownloads,"aria-label":`Downloads`,title:`Downloads`,children:[(0,V.jsx)(d,{className:`size-4`}),e.downloads>0&&(0,V.jsx)(`span`,{className:`absolute -top-1 -right-1 min-w-3.5 h-3.5 px-0.5 rounded-full bg-primary text-[9px] leading-[14px] text-white`,children:e.downloads})]}),g=(0,V.jsx)(`button`,{type:`button`,className:H,onClick:e.onShowMenu,"aria-label":`More`,title:`More`,children:(0,V.jsx)(r,{className:`size-4`})});return e.phone?(0,V.jsxs)(`div`,{role:`toolbar`,"aria-label":`Browser`,className:`shrink-0 border-t border-border bg-panel px-2 pt-1.5 pb-[max(0.375rem,env(safe-area-inset-bottom))]`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-2`,children:[c,u,(0,V.jsx)(`button`,{type:`button`,onClick:e.onShowTabs,"aria-label":`Tabs`,className:H,children:(0,V.jsx)(`span`,{className:`flex items-center justify-center size-4 rounded-[4px] border-[1.5px] border-current text-[10px] font-semibold leading-none`,children:e.tabCount})})]}),(0,V.jsxs)(`div`,{className:`flex items-center justify-around mt-1.5`,children:[f,(0,V.jsx)(`button`,{type:`button`,className:H,onClick:e.onKeyboard,"aria-label":`Keyboard`,title:`Keyboard`,children:(0,V.jsx)(l,{className:`size-4`})}),h,g]})]}):(0,V.jsxs)(`div`,{role:`toolbar`,"aria-label":`Browser`,className:`flex items-center gap-1 shrink-0 h-9 px-2 border-b border-border bg-panel`,children:[f,u,c,h,g]})}function U(e){if(e.title&&e.title!==`about:blank`)return e.title;if(e.url===`about:blank`||!e.url)return`New tab`;try{return new URL(e.url).host}catch{return e.url}}function W(e){let t=e.tabs.length>=e.maxTabs;return(0,V.jsxs)(`div`,{role:`tablist`,"aria-label":`Browser tabs`,className:T(e.vertical?`flex flex-col gap-1`:`flex items-center gap-1 shrink-0 h-9 px-2 pt-1 bg-rail border-b border-border overflow-x-auto`),children:[e.tabs.map(t=>(0,V.jsxs)(`div`,{role:`tab`,"aria-selected":t.id===e.activeTabId,className:T(`group flex items-center gap-1.5 min-w-0 rounded-md px-2 text-xs cursor-pointer select-none`,e.vertical?`min-h-10 text-sm`:`h-7 max-w-52`,t.id===e.activeTabId?`bg-panel text-text border border-border`:`text-text-2 hover:bg-panel-2`),onClick:()=>e.onActivate(t.id),children:[t.ai?(0,V.jsx)(b,{className:`size-3.5 shrink-0 text-accent-2`}):(0,V.jsx)(i,{className:`size-3.5 shrink-0 text-text-3`}),(0,V.jsx)(`span`,{className:`truncate flex-1`,children:U(t)}),(0,V.jsx)(`button`,{type:`button`,"aria-label":`Close ${U(t)}`,onClick:n=>{n.stopPropagation(),e.onClose(t.id)},className:T(A,!e.vertical&&`opacity-60 group-hover:opacity-100`),children:(0,V.jsx)(m,{className:`size-3`})})]},t.id)),(0,V.jsxs)(`button`,{type:`button`,onClick:e.onNew,disabled:t,"aria-label":`New tab`,title:t?`At most ${e.maxTabs} tabs (Settings → Web browser)`:`New tab`,className:e.vertical?T(k,`self-start text-text-2 hover:bg-panel-2`):A,children:[(0,V.jsx)(f,{className:`size-4`}),e.vertical&&`New tab`]})]})}var G=D,K=O;function q({icon:e,title:t,body:n,children:r}){return(0,V.jsxs)(`div`,{className:`absolute inset-0 z-10 flex flex-col items-center justify-center gap-3 p-6 text-center bg-background`,children:[(0,V.jsx)(`div`,{className:`text-text-3`,children:e}),(0,V.jsx)(`div`,{className:`text-sm font-medium text-text`,children:t}),n&&(0,V.jsx)(`div`,{className:`max-w-md text-xs leading-relaxed text-text-2`,children:n}),r&&(0,V.jsx)(`div`,{className:`flex flex-wrap justify-center gap-2 mt-1`,children:r})]})}var ve={"not-decided":`The web browser is not turned on`,disabled:`The web browser is turned off`,"no-browser":`No Chrome or Edge on the host`,"proxy-bypassed":`Stopped for safety`,"public-access":`Not available over a public link`,"auth-required":`Needs PPM sign-in to be enabled`};function ye(e){let{s:t}=e;if(t.error&&t.browser!==`running`){let n=[`not-decided`,`disabled`,`public-access`].includes(t.error.code);return(0,V.jsxs)(q,{icon:(0,V.jsx)(h,{className:`size-8`}),title:ve[t.error.code]??`The browser could not start`,body:t.error.message,children:[n&&(0,V.jsx)(`button`,{type:`button`,className:G,onClick:e.onOpenSettings,children:`Open Settings`}),(0,V.jsx)(`button`,{type:`button`,className:K,onClick:e.onStart,children:`Try again`})]})}return t.conn===`error`||t.conn===`closed`?(0,V.jsx)(q,{icon:(0,V.jsx)(i,{className:`size-8`}),title:`Disconnected from the browser`,body:t.connError??void 0,children:(0,V.jsx)(`button`,{type:`button`,className:G,onClick:e.onReconnect,children:`Reconnect`})}):t.conn===`connecting`||t.browser===`starting`||t.browser===null?(0,V.jsx)(q,{icon:(0,V.jsx)(o,{className:`size-8 animate-spin`}),title:`Starting the browser on the host…`}):t.browser===`stopped`||t.browser===`crashed`?(0,V.jsx)(q,{icon:(0,V.jsx)(y,{className:`size-8`}),title:t.browser===`crashed`?`The browser closed unexpectedly`:`The browser was stopped`,body:t.browserMessage??`It stops by itself after a while unused, to give its memory back.`,children:(0,V.jsx)(`button`,{type:`button`,className:G,onClick:e.onStart,children:`Start again`})}):t.isController?null:(0,V.jsx)(q,{icon:(0,V.jsx)(a,{className:`size-8`}),title:`In use on another device`,body:`Only one device controls the browser at a time.`,children:(0,V.jsx)(`button`,{type:`button`,className:G,onClick:e.onTakeover,children:`Use here`})})}function be(e){let[t,n]=(0,M.useState)(e.dialog.defaultText),{kind:r,origin:i,message:a}=e.dialog;return(0,V.jsx)(`div`,{className:`absolute inset-0 z-20 flex items-start justify-center bg-black/30 pt-10 px-4`,children:(0,V.jsxs)(`div`,{role:`alertdialog`,"aria-label":`${i||`This page`} says`,className:`w-full max-w-sm rounded-md border-2 border-dashed border-text-3 bg-white p-4 text-[#1f1f1f] shadow-lg font-sans`,children:[(0,V.jsxs)(`div`,{className:`mb-1 text-xs font-semibold text-[#5f6368]`,children:[i||`This page`,` says:`]}),(0,V.jsx)(`div`,{className:`whitespace-pre-wrap break-words text-sm`,children:r===`beforeunload`?`Leave this page? Changes you made may not be saved.`:a}),r===`prompt`&&(0,V.jsx)(`input`,{autoFocus:!0,value:t,onChange:e=>n(e.target.value),className:`mt-3 w-full rounded border border-[#dadce0] px-2 py-1.5 text-sm outline-none focus:border-[#1a73e8]`}),(0,V.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[r!==`alert`&&(0,V.jsx)(`button`,{type:`button`,className:`${k} text-[#1a73e8] hover:bg-[#f1f3f4]`,onClick:()=>e.onAnswer(!1),children:`Cancel`}),(0,V.jsx)(`button`,{type:`button`,className:`${k} bg-[#1a73e8] text-white`,onClick:()=>e.onAnswer(!0,r===`prompt`?t:void 0),children:r===`beforeunload`?`Leave`:`OK`})]})]})})}function xe(e){return!e.ai.active&&!e.ai.heldByUser?null:(0,V.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0 px-3 py-1 text-xs bg-accent-2/15 border-b border-border text-text`,children:[(0,V.jsx)(b,{className:`size-4 text-accent-2`}),(0,V.jsx)(`span`,{className:`flex-1 min-w-0 truncate`,children:e.ai.heldByUser?`You took the browser back from the AI.`:`AI is using the browser${e.ai.sessionTitle?` (${e.ai.sessionTitle})`:``}.`}),e.ai.heldByUser?(0,V.jsx)(`button`,{type:`button`,className:K,onClick:e.onGiveBack,children:`Let the AI continue`}):(0,V.jsx)(`button`,{type:`button`,className:G,onClick:e.onTakeBack,children:`Take back`})]})}var J=`flex w-full items-center gap-2 rounded-md px-3 py-2 md:py-1.5 text-sm text-left hover:bg-panel-2 disabled:opacity-40 [&_svg]:size-4`;function Y(e){return e.phone?(0,V.jsxs)(te,{open:!0,onClose:e.onClose,children:[e.title&&(0,V.jsx)(`div`,{className:`px-3 pb-2 text-sm font-semibold`,children:e.title}),(0,V.jsx)(`div`,{className:`flex flex-col gap-1 pb-2`,children:e.children})]}):(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`div`,{className:`absolute inset-0 z-20`,onClick:e.onClose}),(0,V.jsxs)(`div`,{className:`absolute right-2 top-11 z-30 w-80 rounded-lg border border-border bg-popover p-2 shadow-lg`,children:[e.title&&(0,V.jsx)(`div`,{className:`px-2 pb-1 text-xs font-semibold text-text-2`,children:e.title}),(0,V.jsx)(`div`,{className:`flex flex-col gap-0.5`,children:e.children})]})]})}function Se(e){return(0,V.jsxs)(`div`,{className:`flex flex-col gap-2 px-2 py-1 text-xs leading-relaxed text-text-2`,children:[(0,V.jsxs)(`p`,{children:[(0,V.jsx)(`b`,{className:`text-text`,children:`Runs on the host, not on this device.`}),` PPM shows the page as pictures and sends your mouse, keys and taps back.`]}),(0,V.jsxs)(`p`,{children:[`Round trip: `,(0,V.jsx)(`span`,{className:`font-mono`,children:e.latencyMs===null?`—`:`${e.latencyMs} ms`}),e.s.ramMB?` · RAM ${e.s.ramMB} MB`:``]}),(0,V.jsx)(`p`,{children:`Its own profile: it does not share logins with your Chrome, nor with AI chats' Playwright.`}),(0,V.jsx)(`p`,{children:`It can open this machine's local services and devices on your network, if Settings allow it; PPM's own ports and cloud metadata addresses are always blocked.`})]})}function Ce(e){return e.s.downloads.length===0?(0,V.jsx)(`div`,{className:`px-2 py-3 text-xs text-text-2`,children:`No downloads yet. Files stay on the host until you save them here.`}):(0,V.jsx)(V.Fragment,{children:e.s.downloads.map(e=>(0,V.jsxs)(`div`,{className:`flex items-center gap-2 px-2 py-1.5 text-sm`,children:[(0,V.jsx)(d,{className:`size-4 text-text-3 shrink-0`}),(0,V.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,V.jsx)(`div`,{className:`truncate`,children:e.name}),(0,V.jsx)(`div`,{className:`text-xs text-text-3`,children:e.state===`done`?X(e.sizeBytes??e.receivedBytes):e.state===`canceled`?`Canceled`:`${X(e.receivedBytes)}…`})]}),e.state===`done`&&(0,V.jsx)(`button`,{type:`button`,className:D,onClick:()=>void we(e.id),children:`Save`})]},e.id))})}async function we(e){let{url:t}=await w.post(`/api/web-browser/downloads/${encodeURIComponent(e)}/ticket`),n=document.createElement(`a`);n.href=t,n.rel=`noopener`,n.click()}function X(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(0)} KB`:`${(e/1024/1024).toFixed(1)} MB`}function Te(e){return(0,V.jsxs)(V.Fragment,{children:[e.url&&/^https?:\/\//.test(e.url)?(0,V.jsxs)(`a`,{className:J,href:e.url,target:`_blank`,rel:`noopener noreferrer`,children:[(0,V.jsx)(u,{className:`size-4`}),`Open in my browser`]}):(0,V.jsxs)(`button`,{type:`button`,className:J,disabled:!0,children:[(0,V.jsx)(u,{className:`size-4`}),`Open in my browser`]}),e.s.audioAvailable&&(0,V.jsxs)(`button`,{type:`button`,className:J,onClick:e.onToggleMute,children:[e.muted?(0,V.jsx)(c,{className:`size-4`}):(0,V.jsx)(g,{className:`size-4`}),e.muted?`Unmute`:`Mute`]}),(0,V.jsxs)(`button`,{type:`button`,className:J,onClick:e.onClear,children:[(0,V.jsx)(s,{className:`size-4`}),`Clear browsing data…`]}),(0,V.jsxs)(`button`,{type:`button`,className:`${J} text-destructive`,onClick:e.onCloseBrowser,children:[(0,V.jsx)(m,{className:`size-4`}),`Close the browser on the host`]})]})}function Z(e){let t=(0,M.useRef)(null),n=async t=>{if(!t?.length)return e.onCancel();let n=[];for(let r of Array.from(t)){let t=C(),i=await fetch(`/api/web-browser/uploads`,{method:`POST`,body:r,headers:{...t?{Authorization:`Bearer ${t}`}:{},"X-File-Name":encodeURIComponent(r.name),"Content-Type":`application/octet-stream`}}),a=await i.json().catch(()=>null);if(!i.ok||!a?.data?.id)return e.onCancel();n.push(a.data.id)}e.onChosen(n)};return(0,V.jsxs)(`div`,{className:`flex flex-col gap-2 px-2 py-1 text-sm`,children:[(0,V.jsxs)(`div`,{className:`text-xs text-text-2`,children:[`The page wants `,e.chooser.multiple?`files`:`a file`,` from you.`]}),(0,V.jsx)(`input`,{ref:t,type:`file`,className:`hidden`,multiple:e.chooser.multiple,accept:e.chooser.accept||void 0,onChange:e=>void n(e.target.files)}),(0,V.jsxs)(`button`,{type:`button`,className:D,onClick:()=>t.current?.click(),children:[(0,V.jsx)(_,{className:`size-4`}),`Choose from this device`]}),(0,V.jsx)(`button`,{type:`button`,className:O,onClick:e.onCancel,children:`Cancel`})]})}function Ee(e,t=Date.now()){let n=[];if(e.ramMB!==null&&n.push(e.ramMB>=1024?`RAM ${(e.ramMB/1024).toFixed(1)} GB`:`RAM ${e.ramMB} MB`),n.push(`${e.tabs.length} ${e.tabs.length===1?`tab`:`tabs`}`),e.idleStopAt){let r=Math.max(1,Math.round((e.idleStopAt-t)/6e4));n.push(`stops after ${r} min unused`)}return n.join(` · `)}function Q({s:e,onStop:t}){return e.browser===`running`?(0,V.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0 h-8 px-3 border-t border-border bg-panel text-xs text-text-3 font-mono`,children:[(0,V.jsx)(`span`,{className:`flex-1 truncate`,children:Ee(e)}),(0,V.jsxs)(`button`,{type:`button`,onClick:t,className:`${oe} font-sans`,children:[(0,V.jsx)(y,{className:`size-3.5`}),`Stop`]})]}):null}function $(e){switch(e){case`public-name-inward`:return`a public site pointed its name at this machine or your network (DNS rebinding); type the IP or a local name instead`;case`private-address`:return`this machine or your network is switched off in Settings → Web Browser`;case`own-port`:return`that is PPM itself`;case`metadata`:return`cloud metadata addresses are always blocked`;case`dns-failed`:return`the name could not be found`;case`scheme`:return`only http and https addresses open here`;case`tab-limit`:return`the most tabs are open; close one first`;case`public-access`:return`not available over a public link`;default:return e}}function De({phone:e}){let t=(0,M.useRef)(null),n=ge(t),[r,i]=(0,M.useState)(!1),[a,o]=(0,M.useState)(null),{state:s,patch:c,send:l,connect:u,surfaceRef:d,attachCanvas:f,unlockAudio:p,latency:m}=P({mobile:e,visible:n,muted:r}),h=(0,M.useRef)(null),g=s.tabs.find(e=>e.id===s.activeTabId),_=s.conn===`open`&&s.browser===`running`&&s.isController,[v,y]=(0,M.useState)(null);(0,M.useEffect)(()=>{let e=setInterval(()=>y(m()),1e3);return()=>clearInterval(e)},[m]),he(d,h,{enabled:_,send:l,onCopy:()=>l({type:`clipboard.copyRequest`}),onPasteText:e=>l({type:`clipboard.paste`,text:e})});let b=(0,M.useCallback)(async()=>{c({error:null});try{await w.post(`/api/web-browser/start`),u()}catch(e){let t=e;c({error:{code:t.code??`start-failed`,message:t.message}})}},[u,c]),x=async()=>{window.confirm(`Clear the browser's logins, history and downloads on the host?`)&&(await w.post(`/api/web-browser/clear-data`),ee.success(`Browsing data cleared`),o(null))},S=async()=>{await w.post(`/api/web-browser/stop`),o(null)},C=(0,V.jsx)(_e,{tab:g,latencyMs:v,downloads:s.downloads.filter(e=>e.state===`done`).length,phone:e,tabCount:s.tabs.length,onNavigate:e=>l({type:`navigate`,url:e}),onBack:()=>l({type:`back`}),onForward:()=>l({type:`forward`}),onReload:()=>l({type:`reload`}),onStop:()=>l({type:`stop`}),onShowInfo:()=>o(`info`),onShowDownloads:()=>o(`downloads`),onShowMenu:()=>o(`menu`),onShowTabs:()=>o(`tabs`),onKeyboard:()=>{p(),h.current?.focus()}});return(0,V.jsxs)(`div`,{ref:t,className:`relative flex h-full w-full flex-col bg-background`,children:[!e&&(0,V.jsx)(W,{tabs:s.tabs,activeTabId:s.activeTabId,maxTabs:s.maxTabs,onActivate:e=>l({type:`tab.activate`,tabId:e}),onClose:e=>l({type:`tab.close`,tabId:e}),onNew:()=>l({type:`tab.open`})}),!e&&C,s.ai&&(0,V.jsx)(xe,{ai:s.ai,onTakeBack:()=>l({type:`ai.release`}),onGiveBack:()=>l({type:`ai.return`})}),s.blocked&&(0,V.jsxs)(`div`,{role:`status`,className:`flex items-center gap-2 shrink-0 px-3 py-1 text-xs bg-warning/15 text-text border-b border-border`,children:[(0,V.jsxs)(`span`,{className:`flex-1 min-w-0 truncate`,title:`${s.blocked.url}: ${$(s.blocked.reason)}`,children:[`Blocked `,s.blocked.url,` — `,$(s.blocked.reason)]}),(0,V.jsx)(`button`,{type:`button`,className:`${k} hover:bg-panel-2`,onClick:()=>c({blocked:null}),children:`Dismiss`})]}),(0,V.jsxs)(`div`,{ref:d,className:`relative flex-1 min-h-0 overflow-hidden bg-white touch-none select-none`,onPointerDown:p,children:[(0,V.jsx)(`canvas`,{ref:f,className:`absolute inset-0 h-full w-full`,"aria-label":g?`Page: ${g.title||g.url}`:`Page`}),(0,V.jsx)(`textarea`,{ref:h,"aria-label":`Type into the page`,autoCapitalize:`off`,autoCorrect:`off`,spellCheck:!1,className:`absolute left-0 bottom-0 h-px w-px opacity-0 resize-none`}),(0,V.jsx)(ye,{s,onReconnect:u,onStart:()=>void b(),onTakeover:()=>l({type:`takeover`}),onOpenSettings:re}),s.dialog&&_&&(0,V.jsx)(be,{dialog:s.dialog,onAnswer:(e,t)=>{l({type:`dialog.answer`,id:s.dialog.id,accept:e,...t===void 0?{}:{text:t}}),c({dialog:null})}})]}),!e&&(0,V.jsx)(Q,{s,onStop:()=>void S()}),e&&C,a===`info`&&(0,V.jsx)(Y,{phone:e,onClose:()=>o(null),title:`Browser on the host`,children:(0,V.jsx)(Se,{s,latencyMs:v})}),a===`downloads`&&(0,V.jsx)(Y,{phone:e,onClose:()=>o(null),title:`Downloads`,children:(0,V.jsx)(Ce,{s})}),a===`menu`&&(0,V.jsxs)(Y,{phone:e,onClose:()=>o(null),children:[(0,V.jsx)(Te,{s,url:g?.url,muted:r,onToggleMute:()=>i(e=>!e),onClear:()=>void x(),onCloseBrowser:()=>void S()}),e&&(0,V.jsx)(Q,{s,onStop:()=>void S()})]}),a===`tabs`&&(0,V.jsx)(Y,{phone:e,onClose:()=>o(null),title:`Tabs`,children:(0,V.jsx)(W,{vertical:!0,tabs:s.tabs,activeTabId:s.activeTabId,maxTabs:s.maxTabs,onActivate:e=>{l({type:`tab.activate`,tabId:e}),o(null)},onClose:e=>l({type:`tab.close`,tabId:e}),onNew:()=>{l({type:`tab.open`}),o(null)}})}),s.chooser&&(0,V.jsx)(Y,{phone:e,onClose:()=>{l({type:`file.cancel`,chooserId:s.chooser.chooserId}),c({chooser:null})},title:`Upload`,children:(0,V.jsx)(Z,{chooser:s.chooser,onChosen:e=>{l({type:`file.choose`,chooserId:s.chooser.chooserId,uploadIds:e}),c({chooser:null})},onCancel:()=>{l({type:`file.cancel`,chooserId:s.chooser.chooserId}),c({chooser:null})}})})]})}export{De as t};
1
+ import{s as e}from"./rolldown-runtime-C5c2KzVm.js";import{D as t,E as n}from"./vendor-markdown-26eoXJk7.js";import{Hn as r,Kt as i,Rn as a,Sn as o,Xr as s,ci as c,dn as l,gt as u,ht as d,lr as f,m as p,pi as m,r as h,si as g,ti as _,u as v,ur as y,w as b,wn as x,yr as S}from"./icons-CpR5Vw3J.js";import{a as C,j as ee,r as w}from"./api-client-DSCscZEd.js";import{n as T}from"./utils-DMiycH3O.js";import{t as te}from"./mobile-bottom-sheet-C78UMLrn.js";import{t as ne}from"./ws-auth-BoXvat-e.js";import{gn as re}from"./index-CToe9paM.js";import{i as E,s as ie,t as ae}from"./remote-desktop-coords-BI7h18Lu.js";import{a as D,i as O,n as k,r as oe,t as A}from"./web-browser-button-styles-ByWVMgQh.js";function se(e){let t=e instanceof Uint8Array?e:new Uint8Array(e);if(t.byteLength<12)return null;let n=new DataView(t.buffer,t.byteOffset,t.byteLength),r=n.getUint8(0),i=n.getUint32(1,!0),a=n.getUint16(5,!0),o=n.getUint16(7,!0),s=t.subarray(12);return r===1?{kind:r,seq:i,cssWidth:a,cssHeight:o,payload:s}:r===2?{kind:r,seq:i,sampleRate:a*10,channels:o,payload:s}:null}function ce(e,t){let n=ne(`/ws/web-browser`);return t&&e.protocol!==`https:`?`ws://${e.hostname}:${t}${n}`:`${e.protocol===`https:`?`wss:`:`ws:`}//${e.host}${n}`}var le=class{ws=null;lastInputAt=0;latencyMs=null;constructor(e){this.h=e}async connect(){this.close(),this.h.onState(`connecting`);let e;try{e=(await w.post(`/api/web-browser/session`)).nonce}catch(e){this.h.onState(`error`,e?.message??String(e));return}let t={BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1},n=t.DEV===!0&&typeof t.VITE_DEV_API_PORT==`string`?t.VITE_DEV_API_PORT:void 0,r=new WebSocket(ce(window.location,n));r.binaryType=`arraybuffer`,this.ws=r,r.onopen=()=>{r.send(JSON.stringify({type:`auth`,nonce:e})),this.h.onState(`open`)},r.onmessage=e=>{if(typeof e.data==`string`){try{this.h.onMessage(JSON.parse(e.data))}catch{}return}let t=se(e.data);if(t)if(t.kind===1){if(this.lastInputAt){let e=performance.now()-this.lastInputAt;this.latencyMs=this.latencyMs===null?e:Math.round(this.latencyMs*.7+e*.3),this.lastInputAt=0}this.h.onPicture(t)}else this.h.onSound(t)},r.onclose=e=>{this.ws===r&&(this.ws=null,this.h.onState(`closed`,e.reason||void 0))},r.onerror=()=>{}}get isOpen(){return this.ws?.readyState===WebSocket.OPEN}send(e){this.ws?.readyState===WebSocket.OPEN&&((e.type===`pointer`||e.type===`key`||e.type===`wheel`||e.type===`text`||e.type===`touch`)&&(this.lastInputAt||=performance.now()),this.ws.send(JSON.stringify(e)))}close(){let e=this.ws;if(this.ws=null,e){e.onclose=null;try{e.close()}catch{}}}},ue=class{decoding=!1;waiting=null;canvas=null;pageSize=null;drawn=0;constructor(e){this.ack=e}attach(e){this.canvas=e}push(e){this.waiting&&this.ack(this.waiting.seq),this.waiting=e,this.decoding||this.drain()}async drain(){for(this.decoding=!0;this.waiting;){let e=this.waiting;this.waiting=null;try{let t=await createImageBitmap(new Blob([e.payload],{type:`image/jpeg`})),n=this.canvas;n&&((n.width!==t.width||n.height!==t.height)&&(n.width=t.width,n.height=t.height),n.getContext(`2d`)?.drawImage(t,0,0),this.pageSize={width:e.cssWidth,height:e.cssHeight},this.drawn++),t.close()}catch{}this.ack(e.seq)}this.decoding=!1}},de=.12,fe=.6;function pe(e,t){let n=new DataView(e.buffer,e.byteOffset,e.byteLength),r=Math.floor(e.byteLength/2/t),i=Array.from({length:t},()=>new Float32Array(r));for(let e=0;e<r;e++)for(let r=0;r<t;r++)i[r][e]=n.getInt16((e*t+r)*2,!0)/32768;return i}function me(e,t){return t<e+.02||t>e+fe?e+de:t}var j=class{ctx=null;playHead=0;resume(){typeof AudioContext>`u`||(this.ctx??=new AudioContext,this.ctx.resume().catch(()=>{}))}push(e){let t=this.ctx;if(!t||t.state!==`running`||e.channels<1||e.sampleRate<8e3)return;let n=pe(e.payload,e.channels),r=n[0]?.length??0;if(!r)return;let i=t.createBuffer(e.channels,r,e.sampleRate);n.forEach((e,t)=>i.copyToChannel(e,t));let a=t.createBufferSource();a.buffer=i,a.connect(t.destination);let o=me(t.currentTime,this.playHead);a.start(o),this.playHead=o+i.duration}close(){this.ctx?.close().catch(()=>{}),this.ctx=null}},M=e(t(),1),N={conn:`idle`,connError:null,browser:null,browserMessage:null,ramMB:null,idleStopAt:null,tabs:[],activeTabId:null,isController:!0,dialog:null,chooser:null,downloads:[],blocked:null,ai:null,error:null,maxTabs:4,audioAvailable:!1};function P(e){let[t,n]=(0,M.useState)(N),r=(0,M.useRef)(null),i=(0,M.useRef)(null),a=(0,M.useRef)(null),o=(0,M.useRef)(null),s=(0,M.useRef)(null),c=(0,M.useRef)(e.muted);c.current=e.muted;let l=(0,M.useCallback)(e=>n(t=>({...t,...e})),[]),u=(0,M.useCallback)(e=>{switch(e.type){case`hello`:return l({tabs:e.tabs,activeTabId:e.activeTabId,maxTabs:e.limits.maxTabs,audioAvailable:e.limits.audio});case`tabs`:return l({tabs:e.list,activeTabId:e.activeTabId});case`status`:return l({browser:e.state,browserMessage:e.message??null,ramMB:e.ramMB,idleStopAt:e.idleStopAt,...e.state===`running`?{error:null}:{}});case`controller`:return l({isController:e.isYou});case`dialog`:return l({dialog:e});case`dialog.closed`:return n(t=>t.dialog?.id===e.id?{...t,dialog:null}:t);case`fileChooser`:return l({chooser:e});case`download`:return n(t=>({...t,downloads:[e,...t.downloads.filter(t=>t.id!==e.id)].slice(0,20)}));case`blocked`:return l({blocked:e});case`ai`:return l({ai:e});case`error`:return l({error:{code:e.code,message:e.message}});case`clipboard.copy`:ie(e.text).then(t=>{t||E(e.text)});return}},[l]),d=(0,M.useCallback)(()=>{a.current?.close();let e=new le({onState:(e,t)=>l({conn:e,connError:t??null}),onMessage:u,onPicture:e=>o.current?.push(e),onSound:e=>{c.current||s.current?.push(e)}});a.current=e,o.current=new ue(t=>e.send({type:`frame.ack`,seq:t})),o.current.attach(r.current),e.connect()},[u,l]);(0,M.useEffect)(()=>{if(e.visible)return d(),()=>{a.current?.close(),a.current=null,l({conn:`idle`})}},[e.visible,d,l]),(0,M.useEffect)(()=>{let n=i.current;if(!n||t.conn!==`open`)return;let r=null,o=()=>{let t=n.getBoundingClientRect();t.width<100||t.height<100||a.current?.send({type:`viewport`,cssWidth:Math.round(t.width),cssHeight:Math.round(t.height),dpr:Math.min(window.devicePixelRatio||1,3),mobile:e.mobile})};o(),a.current?.send({type:`visibility`,visible:!0});let s=new ResizeObserver(()=>{r&&clearTimeout(r),r=setTimeout(o,150)});return s.observe(n),()=>{s.disconnect(),r&&clearTimeout(r)}},[t.conn,e.mobile]);let f=(0,M.useCallback)(e=>{r.current=e,o.current?.attach(e)},[]),p=(0,M.useCallback)(()=>{s.current||=new j,s.current.resume()},[]);return(0,M.useEffect)(()=>()=>{s.current?.close()},[]),{state:t,patch:l,send:(0,M.useCallback)(e=>a.current?.send(e),[]),connect:d,surfaceRef:i,attachCanvas:f,unlockAudio:p,latency:()=>a.current?.latencyMs??null}}function F(e){return{alt:e.altKey,ctrl:e.ctrlKey,meta:e.metaKey,shift:e.shiftKey}}function I(e){return(e.ctrlKey||e.metaKey)&&!e.altKey&&(e.code===`KeyV`||e.key.toLowerCase()===`v`)}function L(e){return(e.ctrlKey||e.metaKey)&&!e.altKey&&(e.code===`KeyC`||e.code===`KeyX`)}function R(e,t){if(e.isComposing||e.key===`Process`||e.keyCode===229||e.key===`Dead`||e.key===`Unidentified`||I(e))return null;let n=e.ctrlKey||e.metaKey||e.altKey;return e.key.length===1&&!n?null:{type:`key`,down:t,key:e.key.slice(0,64),code:e.code.slice(0,64),location:e.location,modifiers:F(e),repeat:e.repeat}}function z(e,t){let n=e=>[{type:`key`,down:!0,key:e,code:e,location:0,modifiers:{},repeat:!1},{type:`key`,down:!1,key:e,code:e,location:0,modifiers:{},repeat:!1}];switch(e){case`insertText`:case`insertReplacementText`:return t?[{type:`text`,text:t}]:[];case`insertLineBreak`:case`insertParagraph`:return n(`Enter`);case`deleteContentBackward`:return n(`Backspace`);case`deleteContentForward`:return n(`Delete`);default:return null}}var B=[`left`,`middle`,`right`];function he(e,t,n){let r=(0,M.useRef)(n);r.current=n,(0,M.useEffect)(()=>{let i=e.current,a=t.current;if(!i||!a||!n.enabled)return;let o=e=>r.current.send(e),s=e=>ae(e.clientX,e.clientY,i.getBoundingClientRect()),c=new Map,l=()=>[...c].map(([e,t])=>({id:e,...t})),u=e=>{a.focus({preventScroll:!0}),i.setPointerCapture?.(e.pointerId),e.pointerType===`touch`?(c.set(e.pointerId,s(e)),o({type:`touch`,phase:c.size===1?`start`:`move`,points:l()})):o({type:`pointer`,...s(e),button:B[e.button]??`left`,down:!0,clickCount:Math.min(3,Math.max(1,e.detail||1))}),e.preventDefault()},d=e=>{if(e.pointerType===`touch`){if(!c.has(e.pointerId))return;c.set(e.pointerId,s(e)),o({type:`touch`,phase:`move`,points:l()})}else o({type:`pointer`,...s(e),button:`none`,down:null})},f=e=>{e.pointerType===`touch`?(c.delete(e.pointerId),o({type:`touch`,phase:e.type===`pointercancel`?`cancel`:`end`,points:l()}),e.type===`pointercancel`&&c.clear()):o({type:`pointer`,...s(e),button:B[e.button]??`left`,down:!1,clickCount:Math.min(3,Math.max(1,e.detail||1))})},p=e=>{e.preventDefault();let t=e.deltaMode===1?16:e.deltaMode===2?i.clientHeight:1;o({type:`wheel`,...s(e),dx:e.deltaX*t,dy:e.deltaY*t})},m=e=>e.preventDefault(),h=e=>{let t=R(e,e.type===`keydown`);t&&(e.preventDefault(),o(t),e.type===`keydown`&&L(e)&&setTimeout(()=>r.current.onCopy(),120))},g=e=>{let t=z(e.inputType,e.data);if(t){e.preventDefault();for(let e of t)o(e);a.value=``}},_=e=>{let t=e.data??``;o({type:`compose`,text:t,selStart:t.length,selEnd:t.length})},v=e=>{e.data?o({type:`text`,text:e.data}):o({type:`compose`,text:``,selStart:0,selEnd:0}),a.value=``},y=e=>{let t=e.clipboardData?.getData(`text/plain`);e.preventDefault(),t&&r.current.onPasteText(t)},b=()=>o({type:`releaseAll`});return i.addEventListener(`pointerdown`,u),i.addEventListener(`pointermove`,d),i.addEventListener(`pointerup`,f),i.addEventListener(`pointercancel`,f),i.addEventListener(`wheel`,p,{passive:!1}),i.addEventListener(`contextmenu`,m),a.addEventListener(`keydown`,h),a.addEventListener(`keyup`,h),a.addEventListener(`beforeinput`,g),a.addEventListener(`compositionupdate`,_),a.addEventListener(`compositionend`,v),a.addEventListener(`paste`,y),a.addEventListener(`blur`,b),()=>{i.removeEventListener(`pointerdown`,u),i.removeEventListener(`pointermove`,d),i.removeEventListener(`pointerup`,f),i.removeEventListener(`pointercancel`,f),i.removeEventListener(`wheel`,p),i.removeEventListener(`contextmenu`,m),a.removeEventListener(`keydown`,h),a.removeEventListener(`keyup`,h),a.removeEventListener(`beforeinput`,g),a.removeEventListener(`compositionupdate`,_),a.removeEventListener(`compositionend`,v),a.removeEventListener(`paste`,y),a.removeEventListener(`blur`,b)}},[e,t,n.enabled])}function ge(e){let[t,n]=(0,M.useState)(()=>typeof document>`u`||document.visibilityState===`visible`),[r,i]=(0,M.useState)(!0);return(0,M.useEffect)(()=>{let e=()=>n(document.visibilityState===`visible`);return document.addEventListener(`visibilitychange`,e),()=>document.removeEventListener(`visibilitychange`,e)},[]),(0,M.useEffect)(()=>{let t=e.current;if(!t||typeof IntersectionObserver>`u`)return;let n=new IntersectionObserver(e=>{let t=e[e.length-1];i(!!t&&t.isIntersecting&&t.boundingClientRect.width>0&&t.boundingClientRect.height>0)});return n.observe(t),()=>n.disconnect()},[e]),t&&r}var V=n(),H=A;function _e(e){let[t,n]=(0,M.useState)(!1),[i,o]=(0,M.useState)(e.tab?.url??``);(0,M.useEffect)(()=>{t||o(e.tab?.url===`about:blank`?``:e.tab?.url??``)},[e.tab?.url,t]);let s=e.tab?.url.startsWith(`https://`),c=(0,V.jsxs)(`button`,{type:`button`,onClick:e.onShowInfo,title:`Runs on the host machine — click for details`,className:`${k} border border-border text-text-2 hover:bg-panel-2`,children:[(0,V.jsx)(`span`,{className:`size-1.5 rounded-full bg-success`}),(0,V.jsx)(a,{className:`size-3.5`}),!e.phone&&(0,V.jsx)(`span`,{children:`On host`}),(0,V.jsx)(`span`,{className:`font-mono`,children:e.latencyMs===null?`—`:`${e.latencyMs} ms`})]}),u=(0,V.jsx)(`form`,{className:`flex-1 min-w-0`,onSubmit:t=>{t.preventDefault(),n(!1),e.onNavigate(i)},children:(0,V.jsxs)(`label`,{className:`flex items-center gap-1.5 h-7 rounded-full bg-panel-2 border border-border px-2.5 focus-within:ring-1 focus-within:ring-ring`,children:[s&&(0,V.jsx)(x,{className:`size-3.5 text-text-3 shrink-0`}),(0,V.jsx)(`input`,{value:i,onChange:e=>o(e.target.value),onFocus:e=>{n(!0),e.currentTarget.select()},onBlur:()=>n(!1),placeholder:`Search or type an address`,"aria-label":`Address`,inputMode:`url`,autoCapitalize:`off`,autoCorrect:`off`,spellCheck:!1,className:`flex-1 min-w-0 bg-transparent text-[13px] md:text-xs outline-none text-text`})]})}),f=(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`button`,{type:`button`,className:H,onClick:e.onBack,disabled:!e.tab?.canBack,"aria-label":`Back`,title:`Back`,children:(0,V.jsx)(v,{className:`size-4`})}),(0,V.jsx)(`button`,{type:`button`,className:H,onClick:e.onForward,disabled:!e.tab?.canForward,"aria-label":`Forward`,title:`Forward`,children:(0,V.jsx)(p,{className:`size-4`})}),e.tab?.loading?(0,V.jsx)(`button`,{type:`button`,className:H,onClick:e.onStop,"aria-label":`Stop loading`,title:`Stop loading`,children:(0,V.jsx)(m,{className:`size-4`})}):(0,V.jsx)(`button`,{type:`button`,className:H,onClick:e.onReload,"aria-label":`Reload`,title:`Reload`,children:(0,V.jsx)(S,{className:`size-4`})})]}),h=(0,V.jsxs)(`button`,{type:`button`,className:T(H,`relative`),onClick:e.onShowDownloads,"aria-label":`Downloads`,title:`Downloads`,children:[(0,V.jsx)(d,{className:`size-4`}),e.downloads>0&&(0,V.jsx)(`span`,{className:`absolute -top-1 -right-1 min-w-3.5 h-3.5 px-0.5 rounded-full bg-primary text-[9px] leading-[14px] text-white`,children:e.downloads})]}),g=(0,V.jsx)(`button`,{type:`button`,className:H,onClick:e.onShowMenu,"aria-label":`More`,title:`More`,children:(0,V.jsx)(r,{className:`size-4`})});return e.phone?(0,V.jsxs)(`div`,{role:`toolbar`,"aria-label":`Browser`,className:`shrink-0 border-t border-border bg-panel px-2 pt-1.5 pb-[max(0.375rem,env(safe-area-inset-bottom))]`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-2`,children:[c,u,(0,V.jsx)(`button`,{type:`button`,onClick:e.onShowTabs,"aria-label":`Tabs`,className:H,children:(0,V.jsx)(`span`,{className:`flex items-center justify-center size-4 rounded-[4px] border-[1.5px] border-current text-[10px] font-semibold leading-none`,children:e.tabCount})})]}),(0,V.jsxs)(`div`,{className:`flex items-center justify-around mt-1.5`,children:[f,(0,V.jsx)(`button`,{type:`button`,className:H,onClick:e.onKeyboard,"aria-label":`Keyboard`,title:`Keyboard`,children:(0,V.jsx)(l,{className:`size-4`})}),h,g]})]}):(0,V.jsxs)(`div`,{role:`toolbar`,"aria-label":`Browser`,className:`flex items-center gap-1 shrink-0 h-9 px-2 border-b border-border bg-panel`,children:[f,u,c,h,g]})}function U(e){if(e.title&&e.title!==`about:blank`)return e.title;if(e.url===`about:blank`||!e.url)return`New tab`;try{return new URL(e.url).host}catch{return e.url}}function W(e){let t=e.tabs.length>=e.maxTabs;return(0,V.jsxs)(`div`,{role:`tablist`,"aria-label":`Browser tabs`,className:T(e.vertical?`flex flex-col gap-1`:`flex items-center gap-1 shrink-0 h-9 px-2 pt-1 bg-rail border-b border-border overflow-x-auto`),children:[e.tabs.map(t=>(0,V.jsxs)(`div`,{role:`tab`,"aria-selected":t.id===e.activeTabId,className:T(`group flex items-center gap-1.5 min-w-0 rounded-md px-2 text-xs cursor-pointer select-none`,e.vertical?`min-h-10 text-sm`:`h-7 max-w-52`,t.id===e.activeTabId?`bg-panel text-text border border-border`:`text-text-2 hover:bg-panel-2`),onClick:()=>e.onActivate(t.id),children:[t.ai?(0,V.jsx)(b,{className:`size-3.5 shrink-0 text-accent-2`}):(0,V.jsx)(i,{className:`size-3.5 shrink-0 text-text-3`}),(0,V.jsx)(`span`,{className:`truncate flex-1`,children:U(t)}),(0,V.jsx)(`button`,{type:`button`,"aria-label":`Close ${U(t)}`,onClick:n=>{n.stopPropagation(),e.onClose(t.id)},className:T(A,!e.vertical&&`opacity-60 group-hover:opacity-100`),children:(0,V.jsx)(m,{className:`size-3`})})]},t.id)),(0,V.jsxs)(`button`,{type:`button`,onClick:e.onNew,disabled:t,"aria-label":`New tab`,title:t?`At most ${e.maxTabs} tabs (Settings → Web browser)`:`New tab`,className:e.vertical?T(k,`self-start text-text-2 hover:bg-panel-2`):A,children:[(0,V.jsx)(f,{className:`size-4`}),e.vertical&&`New tab`]})]})}var G=D,K=O;function q({icon:e,title:t,body:n,children:r}){return(0,V.jsxs)(`div`,{className:`absolute inset-0 z-10 flex flex-col items-center justify-center gap-3 p-6 text-center bg-background`,children:[(0,V.jsx)(`div`,{className:`text-text-3`,children:e}),(0,V.jsx)(`div`,{className:`text-sm font-medium text-text`,children:t}),n&&(0,V.jsx)(`div`,{className:`max-w-md text-xs leading-relaxed text-text-2`,children:n}),r&&(0,V.jsx)(`div`,{className:`flex flex-wrap justify-center gap-2 mt-1`,children:r})]})}var ve={"not-decided":`The web browser is not turned on`,disabled:`The web browser is turned off`,"no-browser":`No Chrome or Edge on the host`,"proxy-bypassed":`Stopped for safety`,"public-access":`Not available over a public link`,"auth-required":`Needs PPM sign-in to be enabled`};function ye(e){let{s:t}=e;if(t.error&&t.browser!==`running`){let n=[`not-decided`,`disabled`,`public-access`].includes(t.error.code);return(0,V.jsxs)(q,{icon:(0,V.jsx)(h,{className:`size-8`}),title:ve[t.error.code]??`The browser could not start`,body:t.error.message,children:[n&&(0,V.jsx)(`button`,{type:`button`,className:G,onClick:e.onOpenSettings,children:`Open Settings`}),(0,V.jsx)(`button`,{type:`button`,className:K,onClick:e.onStart,children:`Try again`})]})}return t.conn===`error`||t.conn===`closed`?(0,V.jsx)(q,{icon:(0,V.jsx)(i,{className:`size-8`}),title:`Disconnected from the browser`,body:t.connError??void 0,children:(0,V.jsx)(`button`,{type:`button`,className:G,onClick:e.onReconnect,children:`Reconnect`})}):t.conn===`connecting`||t.browser===`starting`||t.browser===null?(0,V.jsx)(q,{icon:(0,V.jsx)(o,{className:`size-8 animate-spin`}),title:`Starting the browser on the host…`}):t.browser===`stopped`||t.browser===`crashed`?(0,V.jsx)(q,{icon:(0,V.jsx)(y,{className:`size-8`}),title:t.browser===`crashed`?`The browser closed unexpectedly`:`The browser was stopped`,body:t.browserMessage??`It stops by itself after a while unused, to give its memory back.`,children:(0,V.jsx)(`button`,{type:`button`,className:G,onClick:e.onStart,children:`Start again`})}):t.isController?null:(0,V.jsx)(q,{icon:(0,V.jsx)(a,{className:`size-8`}),title:`In use on another device`,body:`Only one device controls the browser at a time.`,children:(0,V.jsx)(`button`,{type:`button`,className:G,onClick:e.onTakeover,children:`Use here`})})}function be(e){let[t,n]=(0,M.useState)(e.dialog.defaultText),{kind:r,origin:i,message:a}=e.dialog;return(0,V.jsx)(`div`,{className:`absolute inset-0 z-20 flex items-start justify-center bg-black/30 pt-10 px-4`,children:(0,V.jsxs)(`div`,{role:`alertdialog`,"aria-label":`${i||`This page`} says`,className:`w-full max-w-sm rounded-md border-2 border-dashed border-text-3 bg-white p-4 text-[#1f1f1f] shadow-lg font-sans`,children:[(0,V.jsxs)(`div`,{className:`mb-1 text-xs font-semibold text-[#5f6368]`,children:[i||`This page`,` says:`]}),(0,V.jsx)(`div`,{className:`whitespace-pre-wrap break-words text-sm`,children:r===`beforeunload`?`Leave this page? Changes you made may not be saved.`:a}),r===`prompt`&&(0,V.jsx)(`input`,{autoFocus:!0,value:t,onChange:e=>n(e.target.value),className:`mt-3 w-full rounded border border-[#dadce0] px-2 py-1.5 text-sm outline-none focus:border-[#1a73e8]`}),(0,V.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[r!==`alert`&&(0,V.jsx)(`button`,{type:`button`,className:`${k} text-[#1a73e8] hover:bg-[#f1f3f4]`,onClick:()=>e.onAnswer(!1),children:`Cancel`}),(0,V.jsx)(`button`,{type:`button`,className:`${k} bg-[#1a73e8] text-white`,onClick:()=>e.onAnswer(!0,r===`prompt`?t:void 0),children:r===`beforeunload`?`Leave`:`OK`})]})]})})}function xe(e){return!e.ai.active&&!e.ai.heldByUser?null:(0,V.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0 px-3 py-1 text-xs bg-accent-2/15 border-b border-border text-text`,children:[(0,V.jsx)(b,{className:`size-4 text-accent-2`}),(0,V.jsx)(`span`,{className:`flex-1 min-w-0 truncate`,children:e.ai.heldByUser?`You took the browser back from the AI.`:`AI is using the browser${e.ai.sessionTitle?` (${e.ai.sessionTitle})`:``}.`}),e.ai.heldByUser?(0,V.jsx)(`button`,{type:`button`,className:K,onClick:e.onGiveBack,children:`Let the AI continue`}):(0,V.jsx)(`button`,{type:`button`,className:G,onClick:e.onTakeBack,children:`Take back`})]})}var J=`flex w-full items-center gap-2 rounded-md px-3 py-2 md:py-1.5 text-sm text-left hover:bg-panel-2 disabled:opacity-40 [&_svg]:size-4`;function Y(e){return e.phone?(0,V.jsxs)(te,{open:!0,onClose:e.onClose,children:[e.title&&(0,V.jsx)(`div`,{className:`px-3 pb-2 text-sm font-semibold`,children:e.title}),(0,V.jsx)(`div`,{className:`flex flex-col gap-1 pb-2`,children:e.children})]}):(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`div`,{className:`absolute inset-0 z-20`,onClick:e.onClose}),(0,V.jsxs)(`div`,{className:`absolute right-2 top-11 z-30 w-80 rounded-lg border border-border bg-popover p-2 shadow-lg`,children:[e.title&&(0,V.jsx)(`div`,{className:`px-2 pb-1 text-xs font-semibold text-text-2`,children:e.title}),(0,V.jsx)(`div`,{className:`flex flex-col gap-0.5`,children:e.children})]})]})}function Se(e){return(0,V.jsxs)(`div`,{className:`flex flex-col gap-2 px-2 py-1 text-xs leading-relaxed text-text-2`,children:[(0,V.jsxs)(`p`,{children:[(0,V.jsx)(`b`,{className:`text-text`,children:`Runs on the host, not on this device.`}),` PPM shows the page as pictures and sends your mouse, keys and taps back.`]}),(0,V.jsxs)(`p`,{children:[`Round trip: `,(0,V.jsx)(`span`,{className:`font-mono`,children:e.latencyMs===null?`—`:`${e.latencyMs} ms`}),e.s.ramMB?` · RAM ${e.s.ramMB} MB`:``]}),(0,V.jsx)(`p`,{children:`Its own profile: it does not share logins with your Chrome, nor with AI chats' Playwright.`}),(0,V.jsx)(`p`,{children:`It can open this machine's local services and devices on your network, if Settings allow it; PPM's own ports and cloud metadata addresses are always blocked.`})]})}function Ce(e){return e.s.downloads.length===0?(0,V.jsx)(`div`,{className:`px-2 py-3 text-xs text-text-2`,children:`No downloads yet. Files stay on the host until you save them here.`}):(0,V.jsx)(V.Fragment,{children:e.s.downloads.map(e=>(0,V.jsxs)(`div`,{className:`flex items-center gap-2 px-2 py-1.5 text-sm`,children:[(0,V.jsx)(d,{className:`size-4 text-text-3 shrink-0`}),(0,V.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,V.jsx)(`div`,{className:`truncate`,children:e.name}),(0,V.jsx)(`div`,{className:`text-xs text-text-3`,children:e.state===`done`?X(e.sizeBytes??e.receivedBytes):e.state===`canceled`?`Canceled`:`${X(e.receivedBytes)}…`})]}),e.state===`done`&&(0,V.jsx)(`button`,{type:`button`,className:D,onClick:()=>void we(e.id),children:`Save`})]},e.id))})}async function we(e){let{url:t}=await w.post(`/api/web-browser/downloads/${encodeURIComponent(e)}/ticket`),n=document.createElement(`a`);n.href=t,n.rel=`noopener`,n.click()}function X(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(0)} KB`:`${(e/1024/1024).toFixed(1)} MB`}function Te(e){return(0,V.jsxs)(V.Fragment,{children:[e.url&&/^https?:\/\//.test(e.url)?(0,V.jsxs)(`a`,{className:J,href:e.url,target:`_blank`,rel:`noopener noreferrer`,children:[(0,V.jsx)(u,{className:`size-4`}),`Open in my browser`]}):(0,V.jsxs)(`button`,{type:`button`,className:J,disabled:!0,children:[(0,V.jsx)(u,{className:`size-4`}),`Open in my browser`]}),e.s.audioAvailable&&(0,V.jsxs)(`button`,{type:`button`,className:J,onClick:e.onToggleMute,children:[e.muted?(0,V.jsx)(c,{className:`size-4`}):(0,V.jsx)(g,{className:`size-4`}),e.muted?`Unmute`:`Mute`]}),(0,V.jsxs)(`button`,{type:`button`,className:J,onClick:e.onClear,children:[(0,V.jsx)(s,{className:`size-4`}),`Clear browsing data…`]}),(0,V.jsxs)(`button`,{type:`button`,className:`${J} text-destructive`,onClick:e.onCloseBrowser,children:[(0,V.jsx)(m,{className:`size-4`}),`Close the browser on the host`]})]})}function Z(e){let t=(0,M.useRef)(null),n=async t=>{if(!t?.length)return e.onCancel();let n=[];for(let r of Array.from(t)){let t=C(),i=await fetch(`/api/web-browser/uploads`,{method:`POST`,body:r,headers:{...t?{Authorization:`Bearer ${t}`}:{},"X-File-Name":encodeURIComponent(r.name),"Content-Type":`application/octet-stream`}}),a=await i.json().catch(()=>null);if(!i.ok||!a?.data?.id)return e.onCancel();n.push(a.data.id)}e.onChosen(n)};return(0,V.jsxs)(`div`,{className:`flex flex-col gap-2 px-2 py-1 text-sm`,children:[(0,V.jsxs)(`div`,{className:`text-xs text-text-2`,children:[`The page wants `,e.chooser.multiple?`files`:`a file`,` from you.`]}),(0,V.jsx)(`input`,{ref:t,type:`file`,className:`hidden`,multiple:e.chooser.multiple,accept:e.chooser.accept||void 0,onChange:e=>void n(e.target.files)}),(0,V.jsxs)(`button`,{type:`button`,className:D,onClick:()=>t.current?.click(),children:[(0,V.jsx)(_,{className:`size-4`}),`Choose from this device`]}),(0,V.jsx)(`button`,{type:`button`,className:O,onClick:e.onCancel,children:`Cancel`})]})}function Ee(e,t=Date.now()){let n=[];if(e.ramMB!==null&&n.push(e.ramMB>=1024?`RAM ${(e.ramMB/1024).toFixed(1)} GB`:`RAM ${e.ramMB} MB`),n.push(`${e.tabs.length} ${e.tabs.length===1?`tab`:`tabs`}`),e.idleStopAt){let r=Math.max(1,Math.round((e.idleStopAt-t)/6e4));n.push(`stops after ${r} min unused`)}return n.join(` · `)}function Q({s:e,onStop:t}){return e.browser===`running`?(0,V.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0 h-8 px-3 border-t border-border bg-panel text-xs text-text-3 font-mono`,children:[(0,V.jsx)(`span`,{className:`flex-1 truncate`,children:Ee(e)}),(0,V.jsxs)(`button`,{type:`button`,onClick:t,className:`${oe} font-sans`,children:[(0,V.jsx)(y,{className:`size-3.5`}),`Stop`]})]}):null}function $(e){switch(e){case`public-name-inward`:return`a public site pointed its name at this machine or your network (DNS rebinding); type the IP or a local name instead`;case`private-address`:return`this machine or your network is switched off in Settings → Web Browser`;case`own-port`:return`that is PPM itself`;case`metadata`:return`cloud metadata addresses are always blocked`;case`dns-failed`:return`the name could not be found`;case`scheme`:return`only http and https addresses open here`;case`tab-limit`:return`the most tabs are open; close one first`;case`public-access`:return`not available over a public link`;default:return e}}function De({phone:e}){let t=(0,M.useRef)(null),n=ge(t),[r,i]=(0,M.useState)(!1),[a,o]=(0,M.useState)(null),{state:s,patch:c,send:l,connect:u,surfaceRef:d,attachCanvas:f,unlockAudio:p,latency:m}=P({mobile:e,visible:n,muted:r}),h=(0,M.useRef)(null),g=s.tabs.find(e=>e.id===s.activeTabId),_=s.conn===`open`&&s.browser===`running`&&s.isController,[v,y]=(0,M.useState)(null);(0,M.useEffect)(()=>{let e=setInterval(()=>y(m()),1e3);return()=>clearInterval(e)},[m]),he(d,h,{enabled:_,send:l,onCopy:()=>l({type:`clipboard.copyRequest`}),onPasteText:e=>l({type:`clipboard.paste`,text:e})});let b=(0,M.useCallback)(async()=>{c({error:null});try{await w.post(`/api/web-browser/start`),u()}catch(e){let t=e;c({error:{code:t.code??`start-failed`,message:t.message}})}},[u,c]),x=async()=>{window.confirm(`Clear the browser's logins, history and downloads on the host?`)&&(await w.post(`/api/web-browser/clear-data`),ee.success(`Browsing data cleared`),o(null))},S=async()=>{await w.post(`/api/web-browser/stop`),o(null)},C=(0,V.jsx)(_e,{tab:g,latencyMs:v,downloads:s.downloads.filter(e=>e.state===`done`).length,phone:e,tabCount:s.tabs.length,onNavigate:e=>l({type:`navigate`,url:e}),onBack:()=>l({type:`back`}),onForward:()=>l({type:`forward`}),onReload:()=>l({type:`reload`}),onStop:()=>l({type:`stop`}),onShowInfo:()=>o(`info`),onShowDownloads:()=>o(`downloads`),onShowMenu:()=>o(`menu`),onShowTabs:()=>o(`tabs`),onKeyboard:()=>{p(),h.current?.focus()}});return(0,V.jsxs)(`div`,{ref:t,className:`relative flex h-full w-full flex-col bg-background`,children:[!e&&(0,V.jsx)(W,{tabs:s.tabs,activeTabId:s.activeTabId,maxTabs:s.maxTabs,onActivate:e=>l({type:`tab.activate`,tabId:e}),onClose:e=>l({type:`tab.close`,tabId:e}),onNew:()=>l({type:`tab.open`})}),!e&&C,s.ai&&(0,V.jsx)(xe,{ai:s.ai,onTakeBack:()=>l({type:`ai.release`}),onGiveBack:()=>l({type:`ai.return`})}),s.blocked&&(0,V.jsxs)(`div`,{role:`status`,className:`flex items-center gap-2 shrink-0 px-3 py-1 text-xs bg-warning/15 text-text border-b border-border`,children:[(0,V.jsxs)(`span`,{className:`flex-1 min-w-0 truncate`,title:`${s.blocked.url}: ${$(s.blocked.reason)}`,children:[`Blocked `,s.blocked.url,` — `,$(s.blocked.reason)]}),(0,V.jsx)(`button`,{type:`button`,className:`${k} hover:bg-panel-2`,onClick:()=>c({blocked:null}),children:`Dismiss`})]}),(0,V.jsxs)(`div`,{ref:d,className:`relative flex-1 min-h-0 overflow-hidden bg-white touch-none select-none`,onPointerDown:p,children:[(0,V.jsx)(`canvas`,{ref:f,className:`absolute inset-0 h-full w-full`,"aria-label":g?`Page: ${g.title||g.url}`:`Page`}),(0,V.jsx)(`textarea`,{ref:h,"aria-label":`Type into the page`,autoCapitalize:`off`,autoCorrect:`off`,spellCheck:!1,className:`absolute left-0 bottom-0 h-px w-px opacity-0 resize-none`}),(0,V.jsx)(ye,{s,onReconnect:u,onStart:()=>void b(),onTakeover:()=>l({type:`takeover`}),onOpenSettings:re}),s.dialog&&_&&(0,V.jsx)(be,{dialog:s.dialog,onAnswer:(e,t)=>{l({type:`dialog.answer`,id:s.dialog.id,accept:e,...t===void 0?{}:{text:t}}),c({dialog:null})}})]}),!e&&(0,V.jsx)(Q,{s,onStop:()=>void S()}),e&&C,a===`info`&&(0,V.jsx)(Y,{phone:e,onClose:()=>o(null),title:`Browser on the host`,children:(0,V.jsx)(Se,{s,latencyMs:v})}),a===`downloads`&&(0,V.jsx)(Y,{phone:e,onClose:()=>o(null),title:`Downloads`,children:(0,V.jsx)(Ce,{s})}),a===`menu`&&(0,V.jsxs)(Y,{phone:e,onClose:()=>o(null),children:[(0,V.jsx)(Te,{s,url:g?.url,muted:r,onToggleMute:()=>i(e=>!e),onClear:()=>void x(),onCloseBrowser:()=>void S()}),e&&(0,V.jsx)(Q,{s,onStop:()=>void S()})]}),a===`tabs`&&(0,V.jsx)(Y,{phone:e,onClose:()=>o(null),title:`Tabs`,children:(0,V.jsx)(W,{vertical:!0,tabs:s.tabs,activeTabId:s.activeTabId,maxTabs:s.maxTabs,onActivate:e=>{l({type:`tab.activate`,tabId:e}),o(null)},onClose:e=>l({type:`tab.close`,tabId:e}),onNew:()=>{l({type:`tab.open`}),o(null)}})}),s.chooser&&(0,V.jsx)(Y,{phone:e,onClose:()=>{l({type:`file.cancel`,chooserId:s.chooser.chooserId}),c({chooser:null})},title:`Upload`,children:(0,V.jsx)(Z,{chooser:s.chooser,onChosen:e=>{l({type:`file.choose`,chooserId:s.chooser.chooserId,uploadIds:e}),c({chooser:null})},onCancel:()=>{l({type:`file.cancel`,chooserId:s.chooser.chooserId}),c({chooser:null})}})})]})}export{De as t};
@@ -1 +1 @@
1
- import"./settings-store-DirmJxtu.js";import{E as e}from"./vendor-markdown-26eoXJk7.js";import"./vendor-ui-BQzUk4nq.js";import"./icons-CpR5Vw3J.js";import"./api-client-DSCscZEd.js";import"./portal-container-context-C84rlnJ6.js";import"./window-store-Bl6ySrZZ.js";import"./panel-store-B5zTGca0.js";import"./project-store-BaGmhKos.js";import"./project-framework-store-vI8djw4a.js";import"./session-list-sync-triggers-_I5gGBSe.js";import"./tab-store-CdpGgbmw.js";import"./mobile-bottom-sheet-C78UMLrn.js";import"./use-visual-viewport-tMLO63yY.js";import"./use-is-mobile-CrfIt67b.js";import"./settings-categories-B_629iML.js";import"./open-settings-CGqVSUo5.js";import"./ws-auth-BoXvat-e.js";import"./web-browser-button-styles-ByWVMgQh.js";import{t}from"./web-browser-view-D5zQyqTr.js";var n=e();function r(e){return(0,n.jsx)(t,{phone:!1})}export{r as default};
1
+ import"./settings-store-DirmJxtu.js";import{E as e}from"./vendor-markdown-26eoXJk7.js";import"./vendor-ui-BQzUk4nq.js";import"./icons-CpR5Vw3J.js";import"./api-client-DSCscZEd.js";import"./portal-container-context-C84rlnJ6.js";import"./window-store-Bl6ySrZZ.js";import"./panel-store-B5zTGca0.js";import"./project-store-BaGmhKos.js";import"./project-framework-store-vI8djw4a.js";import"./session-list-sync-triggers-_I5gGBSe.js";import"./tab-store-CdpGgbmw.js";import"./mobile-bottom-sheet-C78UMLrn.js";import"./use-visual-viewport-tMLO63yY.js";import"./use-is-mobile-CrfIt67b.js";import"./settings-categories-B_629iML.js";import"./open-settings-CGqVSUo5.js";import"./ws-auth-BoXvat-e.js";import"./web-browser-button-styles-ByWVMgQh.js";import{t}from"./web-browser-view-B-gt8lOz.js";var n=e();function r(e){return(0,n.jsx)(t,{phone:!1})}export{r 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{Kt as r,gt as i,j as a,ut as o,wn as s,yr as c}from"./icons-CpR5Vw3J.js";import{j as l}from"./api-client-DSCscZEd.js";import"./window-store-Bl6ySrZZ.js";import{t as u}from"./panel-store-B5zTGca0.js";import"./project-store-BaGmhKos.js";import"./project-framework-store-vI8djw4a.js";import"./session-list-sync-triggers-_I5gGBSe.js";import{r as d}from"./clipboard-DQuoK2EM.js";import{Ln as f,Pn as p}from"./index-HeDx2wIm.js";var m=e(t(),1),h=n(),g=`flex items-center justify-center shrink-0 rounded min-h-11 min-w-11 md:min-h-7 md:min-w-7 text-muted-foreground hover:text-foreground hover:bg-muted`,_=3e3;function v(){return Promise.race([p.allowFraming(window.location.origin).then(()=>void 0,()=>void 0),new Promise(e=>setTimeout(e,_))])}function y({metadata:e,tabId:t}){let n=f(e?.url,window.location.origin),p=f(e?.currentUrl,window.location.origin),_=p&&n&&new URL(p).origin===new URL(n).origin?p:n,[y,b]=(0,m.useState)(_),[x,S]=(0,m.useState)(_),C=(0,m.useRef)(null),w=`${n}:${String(e?.aiOpenAt??``)}`,T=(0,m.useRef)(w),E=e?.via===`tailscale`||e?.via===`local`,[D,O]=(0,m.useState)(0),[k,A]=(0,m.useState)(!1),[j,M]=(0,m.useState)(!1);if((0,m.useEffect)(()=>{T.current!==w&&(T.current=w,b(n),S(n))},[w,n]),(0,m.useEffect)(()=>{let e=e=>{if(!n||!C.current?.contentWindow||e.source!==C.current.contentWindow||e.origin!==new URL(n).origin||e.data?.ppm!==`web-preview-navigation`)return;let r=f(e.data.url,window.location.origin);if(!(!r||new URL(r).origin!==e.origin)&&(b(r),t)){let e=u.getState(),n=Object.values(e.panels).flatMap(e=>e.tabs).find(e=>e.id===t);n&&n.metadata?.currentUrl!==r&&e.updateTab(t,{metadata:{...n.metadata,currentUrl:r}})}};return window.addEventListener(`message`,e),()=>window.removeEventListener(`message`,e)},[n,t]),(0,m.useEffect)(()=>{let e=!0;return v().then(()=>{e&&M(!0)}),()=>{e=!1}},[]),!y)return(0,h.jsx)(`div`,{role:`alert`,className:`p-4 text-sm text-destructive`,children:`This preview has no address PPM can show.`});let N=()=>{d(y).then(e=>{if(!e){l.error(`Failed to copy URL`);return}A(!0),setTimeout(()=>A(!1),2e3)})};return(0,h.jsxs)(`div`,{className:`flex h-full w-full flex-col-reverse md:flex-col bg-background`,children:[(0,h.jsxs)(`div`,{role:`toolbar`,"aria-label":`Web preview`,className:`flex items-center gap-2 md:gap-1 shrink-0 h-12 md:h-8 px-2 border-t md:border-t-0 md:border-b border-border`,children:[(0,h.jsx)(`span`,{className:`flex items-center justify-center shrink-0 size-7 text-muted-foreground`,title:e?.via===`local`?`Private: only this machine can open this address`:E?`Private: only devices in your tailnet can open this address`:`Public: anyone with this link can open it`,children:E?(0,h.jsx)(s,{className:`size-3.5`}):(0,h.jsx)(r,{className:`size-3.5`})}),(0,h.jsx)(`span`,{className:`flex-1 min-w-0 truncate text-xs text-muted-foreground select-all`,children:y}),(0,h.jsx)(`button`,{type:`button`,onClick:()=>void v().then(()=>{S(y),O(e=>e+1)}),title:`Reload`,"aria-label":`Reload`,className:g,children:(0,h.jsx)(c,{className:`size-4`})}),(0,h.jsx)(`button`,{type:`button`,onClick:N,title:`Copy URL`,"aria-label":`Copy URL`,className:g,children:k?(0,h.jsx)(a,{className:`size-4 text-success`}):(0,h.jsx)(o,{className:`size-4`})}),(0,h.jsx)(`a`,{href:y,target:`_blank`,rel:`noopener noreferrer`,title:`Open in browser`,"aria-label":`Open in browser`,className:g,children:(0,h.jsx)(i,{className:`size-4`})})]}),j?(0,h.jsx)(`iframe`,{ref:C,title:`Preview of ${y}`,src:x??void 0,sandbox:`allow-scripts allow-same-origin allow-forms allow-popups allow-popups-to-escape-sandbox allow-modals allow-downloads`,allow:`clipboard-read; clipboard-write; fullscreen`,referrerPolicy:`no-referrer`,className:`flex-1 min-h-0 w-full border-0 bg-white`},`${D}:${String(e?.aiOpenAt??``)}`):(0,h.jsx)(`div`,{className:`flex-1 min-h-0 w-full bg-white`})]})}export{y as WebPreviewTab};
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{Kt as r,gt as i,j as a,ut as o,wn as s,yr as c}from"./icons-CpR5Vw3J.js";import{j as l}from"./api-client-DSCscZEd.js";import"./window-store-Bl6ySrZZ.js";import{t as u}from"./panel-store-B5zTGca0.js";import"./project-store-BaGmhKos.js";import"./project-framework-store-vI8djw4a.js";import"./session-list-sync-triggers-_I5gGBSe.js";import{r as d}from"./clipboard-DQuoK2EM.js";import{Ln as f,Pn as p}from"./index-CToe9paM.js";var m=e(t(),1),h=n(),g=`flex items-center justify-center shrink-0 rounded min-h-11 min-w-11 md:min-h-7 md:min-w-7 text-muted-foreground hover:text-foreground hover:bg-muted`,_=3e3;function v(){return Promise.race([p.allowFraming(window.location.origin).then(()=>void 0,()=>void 0),new Promise(e=>setTimeout(e,_))])}function y({metadata:e,tabId:t}){let n=f(e?.url,window.location.origin),p=f(e?.currentUrl,window.location.origin),_=p&&n&&new URL(p).origin===new URL(n).origin?p:n,[y,b]=(0,m.useState)(_),[x,S]=(0,m.useState)(_),C=(0,m.useRef)(null),w=`${n}:${String(e?.aiOpenAt??``)}`,T=(0,m.useRef)(w),E=e?.via===`tailscale`||e?.via===`local`,[D,O]=(0,m.useState)(0),[k,A]=(0,m.useState)(!1),[j,M]=(0,m.useState)(!1);if((0,m.useEffect)(()=>{T.current!==w&&(T.current=w,b(n),S(n))},[w,n]),(0,m.useEffect)(()=>{let e=e=>{if(!n||!C.current?.contentWindow||e.source!==C.current.contentWindow||e.origin!==new URL(n).origin||e.data?.ppm!==`web-preview-navigation`)return;let r=f(e.data.url,window.location.origin);if(!(!r||new URL(r).origin!==e.origin)&&(b(r),t)){let e=u.getState(),n=Object.values(e.panels).flatMap(e=>e.tabs).find(e=>e.id===t);n&&n.metadata?.currentUrl!==r&&e.updateTab(t,{metadata:{...n.metadata,currentUrl:r}})}};return window.addEventListener(`message`,e),()=>window.removeEventListener(`message`,e)},[n,t]),(0,m.useEffect)(()=>{let e=!0;return v().then(()=>{e&&M(!0)}),()=>{e=!1}},[]),!y)return(0,h.jsx)(`div`,{role:`alert`,className:`p-4 text-sm text-destructive`,children:`This preview has no address PPM can show.`});let N=()=>{d(y).then(e=>{if(!e){l.error(`Failed to copy URL`);return}A(!0),setTimeout(()=>A(!1),2e3)})};return(0,h.jsxs)(`div`,{className:`flex h-full w-full flex-col-reverse md:flex-col bg-background`,children:[(0,h.jsxs)(`div`,{role:`toolbar`,"aria-label":`Web preview`,className:`flex items-center gap-2 md:gap-1 shrink-0 h-12 md:h-8 px-2 border-t md:border-t-0 md:border-b border-border`,children:[(0,h.jsx)(`span`,{className:`flex items-center justify-center shrink-0 size-7 text-muted-foreground`,title:e?.via===`local`?`Private: only this machine can open this address`:E?`Private: only devices in your tailnet can open this address`:`Public: anyone with this link can open it`,children:E?(0,h.jsx)(s,{className:`size-3.5`}):(0,h.jsx)(r,{className:`size-3.5`})}),(0,h.jsx)(`span`,{className:`flex-1 min-w-0 truncate text-xs text-muted-foreground select-all`,children:y}),(0,h.jsx)(`button`,{type:`button`,onClick:()=>void v().then(()=>{S(y),O(e=>e+1)}),title:`Reload`,"aria-label":`Reload`,className:g,children:(0,h.jsx)(c,{className:`size-4`})}),(0,h.jsx)(`button`,{type:`button`,onClick:N,title:`Copy URL`,"aria-label":`Copy URL`,className:g,children:k?(0,h.jsx)(a,{className:`size-4 text-success`}):(0,h.jsx)(o,{className:`size-4`})}),(0,h.jsx)(`a`,{href:y,target:`_blank`,rel:`noopener noreferrer`,title:`Open in browser`,"aria-label":`Open in browser`,className:g,children:(0,h.jsx)(i,{className:`size-4`})})]}),j?(0,h.jsx)(`iframe`,{ref:C,title:`Preview of ${y}`,src:x??void 0,sandbox:`allow-scripts allow-same-origin allow-forms allow-popups allow-popups-to-escape-sandbox allow-modals allow-downloads`,allow:`clipboard-read; clipboard-write; fullscreen`,referrerPolicy:`no-referrer`,className:`flex-1 min-h-0 w-full border-0 bg-white`},`${D}:${String(e?.aiOpenAt??``)}`):(0,h.jsx)(`div`,{className:`flex-1 min-h-0 w-full bg-white`})]})}export{y as WebPreviewTab};